@flowsterix/react 0.1.0

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.
Files changed (96) hide show
  1. package/dist/adapters/radixDialog.d.ts +18 -0
  2. package/dist/adapters/radixDialog.d.ts.map +1 -0
  3. package/dist/chunk-RCASLQRS.mjs +24 -0
  4. package/dist/chunk-RPA2S5UP.mjs +280 -0
  5. package/dist/chunk-U757YVZP.mjs +50 -0
  6. package/dist/components/OverlayBackdrop.d.ts +34 -0
  7. package/dist/components/OverlayBackdrop.d.ts.map +1 -0
  8. package/dist/components/TourFocusManager.d.ts +11 -0
  9. package/dist/components/TourFocusManager.d.ts.map +1 -0
  10. package/dist/components/TourPopoverPortal.d.ts +57 -0
  11. package/dist/components/TourPopoverPortal.d.ts.map +1 -0
  12. package/dist/components/__tests__/TourFocusManager.test.d.ts +2 -0
  13. package/dist/components/__tests__/TourFocusManager.test.d.ts.map +1 -0
  14. package/dist/context.d.ts +56 -0
  15. package/dist/context.d.ts.map +1 -0
  16. package/dist/hooks/__tests__/scrollMargin.test.d.ts +2 -0
  17. package/dist/hooks/__tests__/scrollMargin.test.d.ts.map +1 -0
  18. package/dist/hooks/__tests__/useBodyScrollLock.test.d.ts +2 -0
  19. package/dist/hooks/__tests__/useBodyScrollLock.test.d.ts.map +1 -0
  20. package/dist/hooks/__tests__/useHiddenTargetFallback.test.d.ts +2 -0
  21. package/dist/hooks/__tests__/useHiddenTargetFallback.test.d.ts.map +1 -0
  22. package/dist/hooks/__tests__/waitForPredicate.test.d.ts +2 -0
  23. package/dist/hooks/__tests__/waitForPredicate.test.d.ts.map +1 -0
  24. package/dist/hooks/scrollMargin.d.ts +15 -0
  25. package/dist/hooks/scrollMargin.d.ts.map +1 -0
  26. package/dist/hooks/useAdvanceRules.d.ts +3 -0
  27. package/dist/hooks/useAdvanceRules.d.ts.map +1 -0
  28. package/dist/hooks/useBodyScrollLock.d.ts +2 -0
  29. package/dist/hooks/useBodyScrollLock.d.ts.map +1 -0
  30. package/dist/hooks/useDelayAdvance.d.ts +14 -0
  31. package/dist/hooks/useDelayAdvance.d.ts.map +1 -0
  32. package/dist/hooks/useHiddenTargetFallback.d.ts +16 -0
  33. package/dist/hooks/useHiddenTargetFallback.d.ts.map +1 -0
  34. package/dist/hooks/useHudDescription.d.ts +13 -0
  35. package/dist/hooks/useHudDescription.d.ts.map +1 -0
  36. package/dist/hooks/useHudShortcuts.d.ts +7 -0
  37. package/dist/hooks/useHudShortcuts.d.ts.map +1 -0
  38. package/dist/hooks/useHudState.d.ts +27 -0
  39. package/dist/hooks/useHudState.d.ts.map +1 -0
  40. package/dist/hooks/useHudTargetIssue.d.ts +21 -0
  41. package/dist/hooks/useHudTargetIssue.d.ts.map +1 -0
  42. package/dist/hooks/useTourControls.d.ts +17 -0
  43. package/dist/hooks/useTourControls.d.ts.map +1 -0
  44. package/dist/hooks/useTourFocusDominance.d.ts +9 -0
  45. package/dist/hooks/useTourFocusDominance.d.ts.map +1 -0
  46. package/dist/hooks/useTourHud.d.ts +61 -0
  47. package/dist/hooks/useTourHud.d.ts.map +1 -0
  48. package/dist/hooks/useTourOverlay.d.ts +70 -0
  49. package/dist/hooks/useTourOverlay.d.ts.map +1 -0
  50. package/dist/hooks/useTourTarget.d.ts +16 -0
  51. package/dist/hooks/useTourTarget.d.ts.map +1 -0
  52. package/dist/hooks/useViewportRect.d.ts +3 -0
  53. package/dist/hooks/useViewportRect.d.ts.map +1 -0
  54. package/dist/hooks/waitForPredicate.d.ts +15 -0
  55. package/dist/hooks/waitForPredicate.d.ts.map +1 -0
  56. package/dist/index.cjs +4207 -0
  57. package/dist/index.d.ts +45 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.mjs +3851 -0
  60. package/dist/labels.d.ts +22 -0
  61. package/dist/labels.d.ts.map +1 -0
  62. package/dist/motion/animationAdapter.d.ts +40 -0
  63. package/dist/motion/animationAdapter.d.ts.map +1 -0
  64. package/dist/motion/useHudMotion.d.ts +14 -0
  65. package/dist/motion/useHudMotion.d.ts.map +1 -0
  66. package/dist/router/index.cjs +275 -0
  67. package/dist/router/index.d.ts +5 -0
  68. package/dist/router/index.d.ts.map +1 -0
  69. package/dist/router/index.mjs +30 -0
  70. package/dist/router/nextAppRouterAdapter.cjs +224 -0
  71. package/dist/router/nextAppRouterAdapter.d.ts +2 -0
  72. package/dist/router/nextAppRouterAdapter.d.ts.map +1 -0
  73. package/dist/router/nextAppRouterAdapter.mjs +35 -0
  74. package/dist/router/nextPagesRouterAdapter.cjs +217 -0
  75. package/dist/router/nextPagesRouterAdapter.d.ts +2 -0
  76. package/dist/router/nextPagesRouterAdapter.d.ts.map +1 -0
  77. package/dist/router/nextPagesRouterAdapter.mjs +28 -0
  78. package/dist/router/reactRouterAdapter.cjs +220 -0
  79. package/dist/router/reactRouterAdapter.d.ts +2 -0
  80. package/dist/router/reactRouterAdapter.d.ts.map +1 -0
  81. package/dist/router/reactRouterAdapter.mjs +31 -0
  82. package/dist/router/routeGating.d.ts +13 -0
  83. package/dist/router/routeGating.d.ts.map +1 -0
  84. package/dist/router/tanstackRouterAdapter.cjs +202 -0
  85. package/dist/router/tanstackRouterAdapter.d.ts +2 -0
  86. package/dist/router/tanstackRouterAdapter.d.ts.map +1 -0
  87. package/dist/router/tanstackRouterAdapter.mjs +7 -0
  88. package/dist/router/tanstackRouterSync.d.ts +20 -0
  89. package/dist/router/tanstackRouterSync.d.ts.map +1 -0
  90. package/dist/router/utils.d.ts +2 -0
  91. package/dist/router/utils.d.ts.map +1 -0
  92. package/dist/utils/dom.d.ts +22 -0
  93. package/dist/utils/dom.d.ts.map +1 -0
  94. package/dist/utils/focus.d.ts +4 -0
  95. package/dist/utils/focus.d.ts.map +1 -0
  96. package/package.json +96 -0
@@ -0,0 +1,217 @@
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");
38
+
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
+
153
+ // src/router/utils.ts
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
+ };
195
+
196
+ // src/router/nextPagesRouterAdapter.tsx
197
+ var useNextPagesRouterTourAdapter = () => {
198
+ const useRouter2 = typeof NextRouter.useRouter === "function" ? NextRouter.useRouter : null;
199
+ if (!useRouter2) {
200
+ if (typeof console !== "undefined") {
201
+ console.warn(
202
+ "[tour][router] useNextPagesRouterTourAdapter requires next/router. Call this hook only in Next.js Pages Router environments."
203
+ );
204
+ }
205
+ return;
206
+ }
207
+ const router = useRouter2();
208
+ const pathCandidate = typeof router.asPath === "string" && router.asPath.length > 0 ? router.asPath : router.pathname;
209
+ (0, import_react.useEffect)(() => {
210
+ const path = typeof pathCandidate === "string" && pathCandidate.length > 0 ? pathCandidate : createPathString(router.pathname ?? "/");
211
+ notifyRouteChange(path);
212
+ }, [pathCandidate, router.pathname]);
213
+ };
214
+ // Annotate the CommonJS export names for ESM import in node:
215
+ 0 && (module.exports = {
216
+ useNextPagesRouterTourAdapter
217
+ });
@@ -0,0 +1,2 @@
1
+ export declare const useNextPagesRouterTourAdapter: () => void;
2
+ //# sourceMappingURL=nextPagesRouterAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextPagesRouterAdapter.d.ts","sourceRoot":"","sources":["../../src/router/nextPagesRouterAdapter.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,6BAA6B,YA2BzC,CAAA"}
@@ -0,0 +1,28 @@
1
+ import {
2
+ createPathString,
3
+ notifyRouteChange
4
+ } from "../chunk-RPA2S5UP.mjs";
5
+
6
+ // src/router/nextPagesRouterAdapter.tsx
7
+ import * as NextRouter from "next/router";
8
+ import { useEffect } from "react";
9
+ var useNextPagesRouterTourAdapter = () => {
10
+ const useRouter2 = typeof NextRouter.useRouter === "function" ? NextRouter.useRouter : null;
11
+ if (!useRouter2) {
12
+ if (typeof console !== "undefined") {
13
+ console.warn(
14
+ "[tour][router] useNextPagesRouterTourAdapter requires next/router. Call this hook only in Next.js Pages Router environments."
15
+ );
16
+ }
17
+ return;
18
+ }
19
+ const router = useRouter2();
20
+ const pathCandidate = typeof router.asPath === "string" && router.asPath.length > 0 ? router.asPath : router.pathname;
21
+ useEffect(() => {
22
+ const path = typeof pathCandidate === "string" && pathCandidate.length > 0 ? pathCandidate : createPathString(router.pathname ?? "/");
23
+ notifyRouteChange(path);
24
+ }, [pathCandidate, router.pathname]);
25
+ };
26
+ export {
27
+ useNextPagesRouterTourAdapter
28
+ };
@@ -0,0 +1,220 @@
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);
38
+
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
+
153
+ // src/router/utils.ts
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
+ };
195
+
196
+ // src/router/reactRouterAdapter.tsx
197
+ var useReactRouterTourAdapter = () => {
198
+ const useLocation2 = typeof ReactRouterDom.useLocation === "function" ? ReactRouterDom.useLocation : null;
199
+ if (!useLocation2) {
200
+ if (typeof console !== "undefined") {
201
+ console.warn(
202
+ "[tour][router] useReactRouterTourAdapter requires react-router-dom. Call this hook only in React Router environments."
203
+ );
204
+ }
205
+ return;
206
+ }
207
+ const location = useLocation2();
208
+ (0, import_react.useEffect)(() => {
209
+ const path = createPathString(
210
+ location.pathname,
211
+ location.search,
212
+ location.hash
213
+ );
214
+ notifyRouteChange(path);
215
+ }, [location.pathname, location.search, location.hash]);
216
+ };
217
+ // Annotate the CommonJS export names for ESM import in node:
218
+ 0 && (module.exports = {
219
+ useReactRouterTourAdapter
220
+ });
@@ -0,0 +1,2 @@
1
+ export declare const useReactRouterTourAdapter: () => void;
2
+ //# sourceMappingURL=reactRouterAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactRouterAdapter.d.ts","sourceRoot":"","sources":["../../src/router/reactRouterAdapter.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,yBAAyB,YAyBrC,CAAA"}
@@ -0,0 +1,31 @@
1
+ import {
2
+ createPathString,
3
+ notifyRouteChange
4
+ } from "../chunk-RPA2S5UP.mjs";
5
+
6
+ // src/router/reactRouterAdapter.tsx
7
+ import { useEffect } from "react";
8
+ import * as ReactRouterDom from "react-router-dom";
9
+ var useReactRouterTourAdapter = () => {
10
+ const useLocation2 = typeof ReactRouterDom.useLocation === "function" ? ReactRouterDom.useLocation : null;
11
+ if (!useLocation2) {
12
+ if (typeof console !== "undefined") {
13
+ console.warn(
14
+ "[tour][router] useReactRouterTourAdapter requires react-router-dom. Call this hook only in React Router environments."
15
+ );
16
+ }
17
+ return;
18
+ }
19
+ const location = useLocation2();
20
+ useEffect(() => {
21
+ const path = createPathString(
22
+ location.pathname,
23
+ location.search,
24
+ location.hash
25
+ );
26
+ notifyRouteChange(path);
27
+ }, [location.pathname, location.search, location.hash]);
28
+ };
29
+ export {
30
+ useReactRouterTourAdapter
31
+ };
@@ -0,0 +1,13 @@
1
+ export type RouteChangeListener = (path: string) => void;
2
+ declare class RouteGatingChannel {
3
+ #private;
4
+ getCurrentPath(): string;
5
+ notify(path?: string): void;
6
+ subscribe(listener: RouteChangeListener): () => void;
7
+ }
8
+ export declare const routeGatingChannel: RouteGatingChannel;
9
+ export declare const getCurrentRoutePath: () => string;
10
+ export declare const notifyRouteChange: (path?: string) => void;
11
+ export declare const subscribeToRouteChanges: (listener: RouteChangeListener) => () => void;
12
+ export {};
13
+ //# sourceMappingURL=routeGating.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routeGating.d.ts","sourceRoot":"","sources":["../../src/router/routeGating.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;AAsDxD,cAAM,kBAAkB;;IAsCtB,cAAc,IAAI,MAAM;IAOxB,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;IAmBpB,SAAS,CAAC,QAAQ,EAAE,mBAAmB;CAyBxC;AAED,eAAO,MAAM,kBAAkB,oBAA2B,CAAA;AAE1D,eAAO,MAAM,mBAAmB,cAA4C,CAAA;AAE5E,eAAO,MAAM,iBAAiB,GAAI,OAAO,MAAM,SAE9C,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,UAAU,mBAAmB,eAEpE,CAAA"}