@flowsterix/react 0.11.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-D5LQLRSU.cjs +289 -0
- package/dist/chunk-FCOKCGV3.cjs +21 -0
- package/dist/chunk-HPVLOLCD.cjs +1 -0
- package/dist/components/TourPopoverPortal.d.ts +1 -1
- package/dist/components/TourPopoverPortal.d.ts.map +1 -1
- package/dist/context.d.ts +6 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/devtools/globalBridge.d.ts +24 -0
- package/dist/devtools/globalBridge.d.ts.map +1 -0
- package/dist/devtools/hooks/useFlowsData.d.ts.map +1 -1
- package/dist/devtools/index.cjs +409 -430
- package/dist/devtools/index.mjs +52 -21
- package/dist/hooks/useHiddenTargetFallback.d.ts.map +1 -1
- package/dist/hooks/useTourOverlay.d.ts.map +1 -1
- package/dist/index.cjs +701 -927
- package/dist/index.mjs +116 -42
- package/dist/router/index.cjs +13 -202
- package/dist/router/nextAppRouterAdapter.cjs +11 -200
- package/dist/router/nextPagesRouterAdapter.cjs +10 -199
- package/dist/router/reactRouterAdapter.cjs +10 -199
- package/dist/router/tanstackRouterAdapter.cjs +22 -214
- package/package.json +1 -1
|
@@ -1,199 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/router/nextAppRouterAdapter.tsx
|
|
31
|
-
var nextAppRouterAdapter_exports = {};
|
|
32
|
-
__export(nextAppRouterAdapter_exports, {
|
|
33
|
-
useNextAppRouterTourAdapter: () => useNextAppRouterTourAdapter
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(nextAppRouterAdapter_exports);
|
|
36
|
-
var NextNavigation = __toESM(require("next/navigation"), 1);
|
|
37
|
-
var import_react = require("react");
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
38
2
|
|
|
39
|
-
// src/utils/dom.ts
|
|
40
|
-
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
41
|
-
|
|
42
|
-
// src/router/routeGating.ts
|
|
43
|
-
var DEFAULT_POLL_MS = 150;
|
|
44
|
-
var normalizePathname = (pathname) => {
|
|
45
|
-
if (typeof pathname !== "string" || pathname.length === 0) {
|
|
46
|
-
return "/";
|
|
47
|
-
}
|
|
48
|
-
return pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
49
|
-
};
|
|
50
|
-
var normalizePrefixedSegment = (value, prefix) => {
|
|
51
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
52
|
-
return "";
|
|
53
|
-
}
|
|
54
|
-
return value.startsWith(prefix) ? value : `${prefix}${value}`;
|
|
55
|
-
};
|
|
56
|
-
var getWindowPath = () => {
|
|
57
|
-
if (!isBrowser) return "/";
|
|
58
|
-
const { pathname, search, hash } = window.location;
|
|
59
|
-
return normalizePathname(pathname) + normalizePrefixedSegment(search, "?") + normalizePrefixedSegment(hash, "#");
|
|
60
|
-
};
|
|
61
|
-
var normalizeExternalPath = (path) => {
|
|
62
|
-
if (path.length === 0) {
|
|
63
|
-
return "/";
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
const parsed = new URL(path, "http://flowsterix.local");
|
|
67
|
-
return normalizePathname(parsed.pathname) + normalizePrefixedSegment(parsed.search, "?") + normalizePrefixedSegment(parsed.hash, "#");
|
|
68
|
-
} catch {
|
|
69
|
-
const [withoutHash, hash = ""] = path.split("#");
|
|
70
|
-
const [base, search = ""] = withoutHash.split("?");
|
|
71
|
-
return normalizePathname(base) + normalizePrefixedSegment(search ? `?${search}` : "", "?") + normalizePrefixedSegment(hash ? `#${hash}` : "", "#");
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var RouteGatingChannel = class {
|
|
75
|
-
#listeners = /* @__PURE__ */ new Set();
|
|
76
|
-
#currentPath = getWindowPath();
|
|
77
|
-
#teardown = null;
|
|
78
|
-
#attachDefaultListeners() {
|
|
79
|
-
if (!isBrowser) return;
|
|
80
|
-
if (this.#teardown) return;
|
|
81
|
-
let lastPath = getWindowPath();
|
|
82
|
-
const emitIfChanged = () => {
|
|
83
|
-
const nextPath = getWindowPath();
|
|
84
|
-
if (nextPath === lastPath) return;
|
|
85
|
-
lastPath = nextPath;
|
|
86
|
-
this.notify(nextPath);
|
|
87
|
-
};
|
|
88
|
-
const handler = () => emitIfChanged();
|
|
89
|
-
window.addEventListener("popstate", handler);
|
|
90
|
-
window.addEventListener("hashchange", handler);
|
|
91
|
-
const pollId = window.setInterval(emitIfChanged, DEFAULT_POLL_MS);
|
|
92
|
-
this.#teardown = () => {
|
|
93
|
-
window.removeEventListener("popstate", handler);
|
|
94
|
-
window.removeEventListener("hashchange", handler);
|
|
95
|
-
window.clearInterval(pollId);
|
|
96
|
-
this.#teardown = null;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
#detachDefaultListeners() {
|
|
100
|
-
if (this.#listeners.size > 0) return;
|
|
101
|
-
this.#teardown?.();
|
|
102
|
-
this.#teardown = null;
|
|
103
|
-
}
|
|
104
|
-
getCurrentPath() {
|
|
105
|
-
if (isBrowser) {
|
|
106
|
-
this.#currentPath = getWindowPath();
|
|
107
|
-
}
|
|
108
|
-
return this.#currentPath;
|
|
109
|
-
}
|
|
110
|
-
notify(path) {
|
|
111
|
-
const resolved = typeof path === "string" && path.length > 0 ? normalizeExternalPath(path) : this.getCurrentPath();
|
|
112
|
-
if (resolved === this.#currentPath) {
|
|
113
|
-
this.#currentPath = resolved;
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
this.#currentPath = resolved;
|
|
117
|
-
for (const listener of Array.from(this.#listeners)) {
|
|
118
|
-
try {
|
|
119
|
-
listener(resolved);
|
|
120
|
-
} catch (error) {
|
|
121
|
-
console.warn("[tour][route-gating] listener error", error);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
subscribe(listener) {
|
|
126
|
-
if (this.#listeners.has(listener)) {
|
|
127
|
-
return () => {
|
|
128
|
-
this.#listeners.delete(listener);
|
|
129
|
-
this.#detachDefaultListeners();
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
this.#listeners.add(listener);
|
|
133
|
-
if (this.#listeners.size === 1) {
|
|
134
|
-
this.#attachDefaultListeners();
|
|
135
|
-
}
|
|
136
|
-
const current = this.getCurrentPath();
|
|
137
|
-
try {
|
|
138
|
-
listener(current);
|
|
139
|
-
} catch (error) {
|
|
140
|
-
console.warn("[tour][route-gating] listener error", error);
|
|
141
|
-
}
|
|
142
|
-
return () => {
|
|
143
|
-
this.#listeners.delete(listener);
|
|
144
|
-
this.#detachDefaultListeners();
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
var routeGatingChannel = new RouteGatingChannel();
|
|
149
|
-
var notifyRouteChange = (path) => {
|
|
150
|
-
routeGatingChannel.notify(path);
|
|
151
|
-
};
|
|
152
3
|
|
|
153
|
-
|
|
154
|
-
var ensurePrefix = (value, prefix) => value.startsWith(prefix) ? value : `${prefix}${value}`;
|
|
155
|
-
var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
|
|
156
|
-
var toSearchString = (value) => {
|
|
157
|
-
if (!isNonEmptyString(value)) {
|
|
158
|
-
if (value instanceof URLSearchParams) {
|
|
159
|
-
const serialized = value.toString();
|
|
160
|
-
return serialized.length > 0 ? `?${serialized}` : "";
|
|
161
|
-
}
|
|
162
|
-
if (typeof value === "object" && value !== null) {
|
|
163
|
-
try {
|
|
164
|
-
const params = new URLSearchParams();
|
|
165
|
-
for (const [key, raw] of Object.entries(
|
|
166
|
-
value
|
|
167
|
-
)) {
|
|
168
|
-
if (raw === void 0 || raw === null) continue;
|
|
169
|
-
params.set(key, String(raw));
|
|
170
|
-
}
|
|
171
|
-
const serialized = params.toString();
|
|
172
|
-
return serialized.length > 0 ? `?${serialized}` : "";
|
|
173
|
-
} catch {
|
|
174
|
-
return "";
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return "";
|
|
178
|
-
}
|
|
179
|
-
if (value === "?") return "";
|
|
180
|
-
return value.startsWith("?") ? value : ensurePrefix(value, "?");
|
|
181
|
-
};
|
|
182
|
-
var toHashString = (value) => {
|
|
183
|
-
if (!isNonEmptyString(value)) {
|
|
184
|
-
return "";
|
|
185
|
-
}
|
|
186
|
-
if (value === "#") return "";
|
|
187
|
-
return value.startsWith("#") ? value : ensurePrefix(value, "#");
|
|
188
|
-
};
|
|
189
|
-
var createPathString = (pathname, search, hash) => {
|
|
190
|
-
const normalizedPath = isNonEmptyString(pathname) ? pathname.startsWith("/") ? pathname : `/${pathname}` : "/";
|
|
191
|
-
const searchPart = toSearchString(search);
|
|
192
|
-
const hashPart = toHashString(hash);
|
|
193
|
-
return `${normalizedPath}${searchPart}${hashPart}`;
|
|
194
|
-
};
|
|
4
|
+
var _chunkD5LQLRSUcjs = require('../chunk-D5LQLRSU.cjs');
|
|
195
5
|
|
|
196
6
|
// src/router/nextAppRouterAdapter.tsx
|
|
7
|
+
var _navigation = require('next/navigation'); var NextNavigation = _interopRequireWildcard(_navigation);
|
|
8
|
+
var _react = require('react');
|
|
197
9
|
var useNextAppRouterTourAdapter = () => {
|
|
198
10
|
const usePathname2 = typeof NextNavigation.usePathname === "function" ? NextNavigation.usePathname : null;
|
|
199
11
|
const useSearchParams2 = typeof NextNavigation.useSearchParams === "function" ? NextNavigation.useSearchParams : null;
|
|
@@ -207,18 +19,17 @@ var useNextAppRouterTourAdapter = () => {
|
|
|
207
19
|
}
|
|
208
20
|
const pathname = usePathname2();
|
|
209
21
|
const searchParams = useSearchParams2();
|
|
210
|
-
const searchValue = searchParams
|
|
211
|
-
(0,
|
|
22
|
+
const searchValue = _nullishCoalesce(_optionalChain([searchParams, 'optionalAccess', _ => _.toString, 'call', _2 => _2()]), () => ( ""));
|
|
23
|
+
_react.useEffect.call(void 0, () => {
|
|
212
24
|
if (typeof pathname !== "string") return;
|
|
213
|
-
const path = createPathString(
|
|
25
|
+
const path = _chunkD5LQLRSUcjs.createPathString.call(void 0,
|
|
214
26
|
pathname,
|
|
215
27
|
searchValue.length > 0 ? `?${searchValue}` : "",
|
|
216
28
|
void 0
|
|
217
29
|
);
|
|
218
|
-
notifyRouteChange(path);
|
|
30
|
+
_chunkD5LQLRSUcjs.notifyRouteChange.call(void 0, path);
|
|
219
31
|
}, [pathname, searchValue]);
|
|
220
32
|
};
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
});
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
exports.useNextAppRouterTourAdapter = useNextAppRouterTourAdapter;
|
|
@@ -1,199 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/router/nextPagesRouterAdapter.tsx
|
|
31
|
-
var nextPagesRouterAdapter_exports = {};
|
|
32
|
-
__export(nextPagesRouterAdapter_exports, {
|
|
33
|
-
useNextPagesRouterTourAdapter: () => useNextPagesRouterTourAdapter
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(nextPagesRouterAdapter_exports);
|
|
36
|
-
var NextRouter = __toESM(require("next/router"), 1);
|
|
37
|
-
var import_react = require("react");
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
38
2
|
|
|
39
|
-
// src/utils/dom.ts
|
|
40
|
-
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
41
|
-
|
|
42
|
-
// src/router/routeGating.ts
|
|
43
|
-
var DEFAULT_POLL_MS = 150;
|
|
44
|
-
var normalizePathname = (pathname) => {
|
|
45
|
-
if (typeof pathname !== "string" || pathname.length === 0) {
|
|
46
|
-
return "/";
|
|
47
|
-
}
|
|
48
|
-
return pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
49
|
-
};
|
|
50
|
-
var normalizePrefixedSegment = (value, prefix) => {
|
|
51
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
52
|
-
return "";
|
|
53
|
-
}
|
|
54
|
-
return value.startsWith(prefix) ? value : `${prefix}${value}`;
|
|
55
|
-
};
|
|
56
|
-
var getWindowPath = () => {
|
|
57
|
-
if (!isBrowser) return "/";
|
|
58
|
-
const { pathname, search, hash } = window.location;
|
|
59
|
-
return normalizePathname(pathname) + normalizePrefixedSegment(search, "?") + normalizePrefixedSegment(hash, "#");
|
|
60
|
-
};
|
|
61
|
-
var normalizeExternalPath = (path) => {
|
|
62
|
-
if (path.length === 0) {
|
|
63
|
-
return "/";
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
const parsed = new URL(path, "http://flowsterix.local");
|
|
67
|
-
return normalizePathname(parsed.pathname) + normalizePrefixedSegment(parsed.search, "?") + normalizePrefixedSegment(parsed.hash, "#");
|
|
68
|
-
} catch {
|
|
69
|
-
const [withoutHash, hash = ""] = path.split("#");
|
|
70
|
-
const [base, search = ""] = withoutHash.split("?");
|
|
71
|
-
return normalizePathname(base) + normalizePrefixedSegment(search ? `?${search}` : "", "?") + normalizePrefixedSegment(hash ? `#${hash}` : "", "#");
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var RouteGatingChannel = class {
|
|
75
|
-
#listeners = /* @__PURE__ */ new Set();
|
|
76
|
-
#currentPath = getWindowPath();
|
|
77
|
-
#teardown = null;
|
|
78
|
-
#attachDefaultListeners() {
|
|
79
|
-
if (!isBrowser) return;
|
|
80
|
-
if (this.#teardown) return;
|
|
81
|
-
let lastPath = getWindowPath();
|
|
82
|
-
const emitIfChanged = () => {
|
|
83
|
-
const nextPath = getWindowPath();
|
|
84
|
-
if (nextPath === lastPath) return;
|
|
85
|
-
lastPath = nextPath;
|
|
86
|
-
this.notify(nextPath);
|
|
87
|
-
};
|
|
88
|
-
const handler = () => emitIfChanged();
|
|
89
|
-
window.addEventListener("popstate", handler);
|
|
90
|
-
window.addEventListener("hashchange", handler);
|
|
91
|
-
const pollId = window.setInterval(emitIfChanged, DEFAULT_POLL_MS);
|
|
92
|
-
this.#teardown = () => {
|
|
93
|
-
window.removeEventListener("popstate", handler);
|
|
94
|
-
window.removeEventListener("hashchange", handler);
|
|
95
|
-
window.clearInterval(pollId);
|
|
96
|
-
this.#teardown = null;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
#detachDefaultListeners() {
|
|
100
|
-
if (this.#listeners.size > 0) return;
|
|
101
|
-
this.#teardown?.();
|
|
102
|
-
this.#teardown = null;
|
|
103
|
-
}
|
|
104
|
-
getCurrentPath() {
|
|
105
|
-
if (isBrowser) {
|
|
106
|
-
this.#currentPath = getWindowPath();
|
|
107
|
-
}
|
|
108
|
-
return this.#currentPath;
|
|
109
|
-
}
|
|
110
|
-
notify(path) {
|
|
111
|
-
const resolved = typeof path === "string" && path.length > 0 ? normalizeExternalPath(path) : this.getCurrentPath();
|
|
112
|
-
if (resolved === this.#currentPath) {
|
|
113
|
-
this.#currentPath = resolved;
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
this.#currentPath = resolved;
|
|
117
|
-
for (const listener of Array.from(this.#listeners)) {
|
|
118
|
-
try {
|
|
119
|
-
listener(resolved);
|
|
120
|
-
} catch (error) {
|
|
121
|
-
console.warn("[tour][route-gating] listener error", error);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
subscribe(listener) {
|
|
126
|
-
if (this.#listeners.has(listener)) {
|
|
127
|
-
return () => {
|
|
128
|
-
this.#listeners.delete(listener);
|
|
129
|
-
this.#detachDefaultListeners();
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
this.#listeners.add(listener);
|
|
133
|
-
if (this.#listeners.size === 1) {
|
|
134
|
-
this.#attachDefaultListeners();
|
|
135
|
-
}
|
|
136
|
-
const current = this.getCurrentPath();
|
|
137
|
-
try {
|
|
138
|
-
listener(current);
|
|
139
|
-
} catch (error) {
|
|
140
|
-
console.warn("[tour][route-gating] listener error", error);
|
|
141
|
-
}
|
|
142
|
-
return () => {
|
|
143
|
-
this.#listeners.delete(listener);
|
|
144
|
-
this.#detachDefaultListeners();
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
var routeGatingChannel = new RouteGatingChannel();
|
|
149
|
-
var notifyRouteChange = (path) => {
|
|
150
|
-
routeGatingChannel.notify(path);
|
|
151
|
-
};
|
|
152
3
|
|
|
153
|
-
|
|
154
|
-
var ensurePrefix = (value, prefix) => value.startsWith(prefix) ? value : `${prefix}${value}`;
|
|
155
|
-
var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
|
|
156
|
-
var toSearchString = (value) => {
|
|
157
|
-
if (!isNonEmptyString(value)) {
|
|
158
|
-
if (value instanceof URLSearchParams) {
|
|
159
|
-
const serialized = value.toString();
|
|
160
|
-
return serialized.length > 0 ? `?${serialized}` : "";
|
|
161
|
-
}
|
|
162
|
-
if (typeof value === "object" && value !== null) {
|
|
163
|
-
try {
|
|
164
|
-
const params = new URLSearchParams();
|
|
165
|
-
for (const [key, raw] of Object.entries(
|
|
166
|
-
value
|
|
167
|
-
)) {
|
|
168
|
-
if (raw === void 0 || raw === null) continue;
|
|
169
|
-
params.set(key, String(raw));
|
|
170
|
-
}
|
|
171
|
-
const serialized = params.toString();
|
|
172
|
-
return serialized.length > 0 ? `?${serialized}` : "";
|
|
173
|
-
} catch {
|
|
174
|
-
return "";
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return "";
|
|
178
|
-
}
|
|
179
|
-
if (value === "?") return "";
|
|
180
|
-
return value.startsWith("?") ? value : ensurePrefix(value, "?");
|
|
181
|
-
};
|
|
182
|
-
var toHashString = (value) => {
|
|
183
|
-
if (!isNonEmptyString(value)) {
|
|
184
|
-
return "";
|
|
185
|
-
}
|
|
186
|
-
if (value === "#") return "";
|
|
187
|
-
return value.startsWith("#") ? value : ensurePrefix(value, "#");
|
|
188
|
-
};
|
|
189
|
-
var createPathString = (pathname, search, hash) => {
|
|
190
|
-
const normalizedPath = isNonEmptyString(pathname) ? pathname.startsWith("/") ? pathname : `/${pathname}` : "/";
|
|
191
|
-
const searchPart = toSearchString(search);
|
|
192
|
-
const hashPart = toHashString(hash);
|
|
193
|
-
return `${normalizedPath}${searchPart}${hashPart}`;
|
|
194
|
-
};
|
|
4
|
+
var _chunkD5LQLRSUcjs = require('../chunk-D5LQLRSU.cjs');
|
|
195
5
|
|
|
196
6
|
// src/router/nextPagesRouterAdapter.tsx
|
|
7
|
+
var _router = require('next/router'); var NextRouter = _interopRequireWildcard(_router);
|
|
8
|
+
var _react = require('react');
|
|
197
9
|
var useNextPagesRouterTourAdapter = () => {
|
|
198
10
|
const useRouter2 = typeof NextRouter.useRouter === "function" ? NextRouter.useRouter : null;
|
|
199
11
|
if (!useRouter2) {
|
|
@@ -206,12 +18,11 @@ var useNextPagesRouterTourAdapter = () => {
|
|
|
206
18
|
}
|
|
207
19
|
const router = useRouter2();
|
|
208
20
|
const pathCandidate = typeof router.asPath === "string" && router.asPath.length > 0 ? router.asPath : router.pathname;
|
|
209
|
-
(0,
|
|
210
|
-
const path = typeof pathCandidate === "string" && pathCandidate.length > 0 ? pathCandidate : createPathString(router.pathname
|
|
211
|
-
notifyRouteChange(path);
|
|
21
|
+
_react.useEffect.call(void 0, () => {
|
|
22
|
+
const path = typeof pathCandidate === "string" && pathCandidate.length > 0 ? pathCandidate : _chunkD5LQLRSUcjs.createPathString.call(void 0, _nullishCoalesce(router.pathname, () => ( "/")));
|
|
23
|
+
_chunkD5LQLRSUcjs.notifyRouteChange.call(void 0, path);
|
|
212
24
|
}, [pathCandidate, router.pathname]);
|
|
213
25
|
};
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
});
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
exports.useNextPagesRouterTourAdapter = useNextPagesRouterTourAdapter;
|
|
@@ -1,199 +1,11 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/router/reactRouterAdapter.tsx
|
|
31
|
-
var reactRouterAdapter_exports = {};
|
|
32
|
-
__export(reactRouterAdapter_exports, {
|
|
33
|
-
useReactRouterTourAdapter: () => useReactRouterTourAdapter
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(reactRouterAdapter_exports);
|
|
36
|
-
var import_react = require("react");
|
|
37
|
-
var ReactRouterDom = __toESM(require("react-router-dom"), 1);
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
38
2
|
|
|
39
|
-
// src/utils/dom.ts
|
|
40
|
-
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
41
|
-
|
|
42
|
-
// src/router/routeGating.ts
|
|
43
|
-
var DEFAULT_POLL_MS = 150;
|
|
44
|
-
var normalizePathname = (pathname) => {
|
|
45
|
-
if (typeof pathname !== "string" || pathname.length === 0) {
|
|
46
|
-
return "/";
|
|
47
|
-
}
|
|
48
|
-
return pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
49
|
-
};
|
|
50
|
-
var normalizePrefixedSegment = (value, prefix) => {
|
|
51
|
-
if (typeof value !== "string" || value.length === 0) {
|
|
52
|
-
return "";
|
|
53
|
-
}
|
|
54
|
-
return value.startsWith(prefix) ? value : `${prefix}${value}`;
|
|
55
|
-
};
|
|
56
|
-
var getWindowPath = () => {
|
|
57
|
-
if (!isBrowser) return "/";
|
|
58
|
-
const { pathname, search, hash } = window.location;
|
|
59
|
-
return normalizePathname(pathname) + normalizePrefixedSegment(search, "?") + normalizePrefixedSegment(hash, "#");
|
|
60
|
-
};
|
|
61
|
-
var normalizeExternalPath = (path) => {
|
|
62
|
-
if (path.length === 0) {
|
|
63
|
-
return "/";
|
|
64
|
-
}
|
|
65
|
-
try {
|
|
66
|
-
const parsed = new URL(path, "http://flowsterix.local");
|
|
67
|
-
return normalizePathname(parsed.pathname) + normalizePrefixedSegment(parsed.search, "?") + normalizePrefixedSegment(parsed.hash, "#");
|
|
68
|
-
} catch {
|
|
69
|
-
const [withoutHash, hash = ""] = path.split("#");
|
|
70
|
-
const [base, search = ""] = withoutHash.split("?");
|
|
71
|
-
return normalizePathname(base) + normalizePrefixedSegment(search ? `?${search}` : "", "?") + normalizePrefixedSegment(hash ? `#${hash}` : "", "#");
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
var RouteGatingChannel = class {
|
|
75
|
-
#listeners = /* @__PURE__ */ new Set();
|
|
76
|
-
#currentPath = getWindowPath();
|
|
77
|
-
#teardown = null;
|
|
78
|
-
#attachDefaultListeners() {
|
|
79
|
-
if (!isBrowser) return;
|
|
80
|
-
if (this.#teardown) return;
|
|
81
|
-
let lastPath = getWindowPath();
|
|
82
|
-
const emitIfChanged = () => {
|
|
83
|
-
const nextPath = getWindowPath();
|
|
84
|
-
if (nextPath === lastPath) return;
|
|
85
|
-
lastPath = nextPath;
|
|
86
|
-
this.notify(nextPath);
|
|
87
|
-
};
|
|
88
|
-
const handler = () => emitIfChanged();
|
|
89
|
-
window.addEventListener("popstate", handler);
|
|
90
|
-
window.addEventListener("hashchange", handler);
|
|
91
|
-
const pollId = window.setInterval(emitIfChanged, DEFAULT_POLL_MS);
|
|
92
|
-
this.#teardown = () => {
|
|
93
|
-
window.removeEventListener("popstate", handler);
|
|
94
|
-
window.removeEventListener("hashchange", handler);
|
|
95
|
-
window.clearInterval(pollId);
|
|
96
|
-
this.#teardown = null;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
#detachDefaultListeners() {
|
|
100
|
-
if (this.#listeners.size > 0) return;
|
|
101
|
-
this.#teardown?.();
|
|
102
|
-
this.#teardown = null;
|
|
103
|
-
}
|
|
104
|
-
getCurrentPath() {
|
|
105
|
-
if (isBrowser) {
|
|
106
|
-
this.#currentPath = getWindowPath();
|
|
107
|
-
}
|
|
108
|
-
return this.#currentPath;
|
|
109
|
-
}
|
|
110
|
-
notify(path) {
|
|
111
|
-
const resolved = typeof path === "string" && path.length > 0 ? normalizeExternalPath(path) : this.getCurrentPath();
|
|
112
|
-
if (resolved === this.#currentPath) {
|
|
113
|
-
this.#currentPath = resolved;
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
this.#currentPath = resolved;
|
|
117
|
-
for (const listener of Array.from(this.#listeners)) {
|
|
118
|
-
try {
|
|
119
|
-
listener(resolved);
|
|
120
|
-
} catch (error) {
|
|
121
|
-
console.warn("[tour][route-gating] listener error", error);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
subscribe(listener) {
|
|
126
|
-
if (this.#listeners.has(listener)) {
|
|
127
|
-
return () => {
|
|
128
|
-
this.#listeners.delete(listener);
|
|
129
|
-
this.#detachDefaultListeners();
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
this.#listeners.add(listener);
|
|
133
|
-
if (this.#listeners.size === 1) {
|
|
134
|
-
this.#attachDefaultListeners();
|
|
135
|
-
}
|
|
136
|
-
const current = this.getCurrentPath();
|
|
137
|
-
try {
|
|
138
|
-
listener(current);
|
|
139
|
-
} catch (error) {
|
|
140
|
-
console.warn("[tour][route-gating] listener error", error);
|
|
141
|
-
}
|
|
142
|
-
return () => {
|
|
143
|
-
this.#listeners.delete(listener);
|
|
144
|
-
this.#detachDefaultListeners();
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
var routeGatingChannel = new RouteGatingChannel();
|
|
149
|
-
var notifyRouteChange = (path) => {
|
|
150
|
-
routeGatingChannel.notify(path);
|
|
151
|
-
};
|
|
152
3
|
|
|
153
|
-
|
|
154
|
-
var ensurePrefix = (value, prefix) => value.startsWith(prefix) ? value : `${prefix}${value}`;
|
|
155
|
-
var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
|
|
156
|
-
var toSearchString = (value) => {
|
|
157
|
-
if (!isNonEmptyString(value)) {
|
|
158
|
-
if (value instanceof URLSearchParams) {
|
|
159
|
-
const serialized = value.toString();
|
|
160
|
-
return serialized.length > 0 ? `?${serialized}` : "";
|
|
161
|
-
}
|
|
162
|
-
if (typeof value === "object" && value !== null) {
|
|
163
|
-
try {
|
|
164
|
-
const params = new URLSearchParams();
|
|
165
|
-
for (const [key, raw] of Object.entries(
|
|
166
|
-
value
|
|
167
|
-
)) {
|
|
168
|
-
if (raw === void 0 || raw === null) continue;
|
|
169
|
-
params.set(key, String(raw));
|
|
170
|
-
}
|
|
171
|
-
const serialized = params.toString();
|
|
172
|
-
return serialized.length > 0 ? `?${serialized}` : "";
|
|
173
|
-
} catch {
|
|
174
|
-
return "";
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return "";
|
|
178
|
-
}
|
|
179
|
-
if (value === "?") return "";
|
|
180
|
-
return value.startsWith("?") ? value : ensurePrefix(value, "?");
|
|
181
|
-
};
|
|
182
|
-
var toHashString = (value) => {
|
|
183
|
-
if (!isNonEmptyString(value)) {
|
|
184
|
-
return "";
|
|
185
|
-
}
|
|
186
|
-
if (value === "#") return "";
|
|
187
|
-
return value.startsWith("#") ? value : ensurePrefix(value, "#");
|
|
188
|
-
};
|
|
189
|
-
var createPathString = (pathname, search, hash) => {
|
|
190
|
-
const normalizedPath = isNonEmptyString(pathname) ? pathname.startsWith("/") ? pathname : `/${pathname}` : "/";
|
|
191
|
-
const searchPart = toSearchString(search);
|
|
192
|
-
const hashPart = toHashString(hash);
|
|
193
|
-
return `${normalizedPath}${searchPart}${hashPart}`;
|
|
194
|
-
};
|
|
4
|
+
var _chunkD5LQLRSUcjs = require('../chunk-D5LQLRSU.cjs');
|
|
195
5
|
|
|
196
6
|
// src/router/reactRouterAdapter.tsx
|
|
7
|
+
var _react = require('react');
|
|
8
|
+
var _reactrouterdom = require('react-router-dom'); var ReactRouterDom = _interopRequireWildcard(_reactrouterdom);
|
|
197
9
|
var useReactRouterTourAdapter = () => {
|
|
198
10
|
const useLocation2 = typeof ReactRouterDom.useLocation === "function" ? ReactRouterDom.useLocation : null;
|
|
199
11
|
if (!useLocation2) {
|
|
@@ -205,16 +17,15 @@ var useReactRouterTourAdapter = () => {
|
|
|
205
17
|
return;
|
|
206
18
|
}
|
|
207
19
|
const location = useLocation2();
|
|
208
|
-
(0,
|
|
209
|
-
const path = createPathString(
|
|
20
|
+
_react.useEffect.call(void 0, () => {
|
|
21
|
+
const path = _chunkD5LQLRSUcjs.createPathString.call(void 0,
|
|
210
22
|
location.pathname,
|
|
211
23
|
location.search,
|
|
212
24
|
location.hash
|
|
213
25
|
);
|
|
214
|
-
notifyRouteChange(path);
|
|
26
|
+
_chunkD5LQLRSUcjs.notifyRouteChange.call(void 0, path);
|
|
215
27
|
}, [location.pathname, location.search, location.hash]);
|
|
216
28
|
};
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
exports.useReactRouterTourAdapter = useReactRouterTourAdapter;
|