@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,22 @@
1
+ export interface TourLabels {
2
+ back: string;
3
+ next: string;
4
+ finish: string;
5
+ skip: string;
6
+ holdToConfirm: string;
7
+ ariaStepProgress: (params: {
8
+ current: number;
9
+ total: number;
10
+ }) => string;
11
+ ariaTimeRemaining: (params: {
12
+ ms: number;
13
+ }) => string;
14
+ ariaDelayProgress: string;
15
+ formatTimeRemaining: (params: {
16
+ ms: number;
17
+ }) => string;
18
+ }
19
+ export declare const defaultLabels: TourLabels;
20
+ export declare const LabelsProvider: import("react").Provider<TourLabels>;
21
+ export declare function useTourLabels(): TourLabels;
22
+ //# sourceMappingURL=labels.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../src/labels.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IAEzB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,MAAM,CAAA;IAGrB,gBAAgB,EAAE,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAA;IACxE,iBAAiB,EAAE,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAA;IACrD,iBAAiB,EAAE,MAAM,CAAA;IAGzB,mBAAmB,EAAE,CAAC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,KAAK,MAAM,CAAA;CACxD;AAED,eAAO,MAAM,aAAa,EAAE,UAa3B,CAAA;AAID,eAAO,MAAM,cAAc,sCAAyB,CAAA;AAEpD,wBAAgB,aAAa,IAAI,UAAU,CAE1C"}
@@ -0,0 +1,40 @@
1
+ import type { Transition } from 'motion/react';
2
+ import { motion } from 'motion/react';
3
+ import type { ReactNode } from 'react';
4
+ export interface AnimationAdapterComponents {
5
+ MotionDiv: typeof motion.div;
6
+ MotionSection: typeof motion.section;
7
+ MotionSvg: typeof motion.svg;
8
+ MotionDefs: typeof motion.defs;
9
+ MotionMask: typeof motion.mask;
10
+ MotionRect: typeof motion.rect;
11
+ MotionSpan: typeof motion.span;
12
+ MotionButton: typeof motion.button;
13
+ }
14
+ export interface AnimationAdapterTransitions {
15
+ overlayHighlight?: Transition;
16
+ overlayFade?: Transition;
17
+ popoverEntrance?: Transition;
18
+ popoverExit?: Transition;
19
+ popoverContent?: Transition;
20
+ delayIndicator?: Transition;
21
+ }
22
+ export interface AnimationAdapter {
23
+ components: AnimationAdapterComponents;
24
+ transitions: AnimationAdapterTransitions;
25
+ }
26
+ export interface AnimationAdapterProviderProps {
27
+ adapter?: AnimationAdapter;
28
+ children: ReactNode;
29
+ }
30
+ export declare const AnimationAdapterProvider: ({ adapter, children, }: AnimationAdapterProviderProps) => import("react/jsx-runtime").JSX.Element;
31
+ export declare const useAnimationAdapter: () => AnimationAdapter;
32
+ export declare const defaultAnimationAdapter: AnimationAdapter;
33
+ export declare const reducedMotionAnimationAdapter: AnimationAdapter;
34
+ export interface UseAnimationAdapterOptions {
35
+ defaultAdapter?: AnimationAdapter;
36
+ reducedMotionAdapter?: AnimationAdapter;
37
+ enabled?: boolean;
38
+ }
39
+ export declare const usePreferredAnimationAdapter: (options?: UseAnimationAdapterOptions) => AnimationAdapter;
40
+ //# sourceMappingURL=animationAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animationAdapter.d.ts","sourceRoot":"","sources":["../../src/motion/animationAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGtC,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,OAAO,MAAM,CAAC,GAAG,CAAA;IAC5B,aAAa,EAAE,OAAO,MAAM,CAAC,OAAO,CAAA;IACpC,SAAS,EAAE,OAAO,MAAM,CAAC,GAAG,CAAA;IAC5B,UAAU,EAAE,OAAO,MAAM,CAAC,IAAI,CAAA;IAC9B,UAAU,EAAE,OAAO,MAAM,CAAC,IAAI,CAAA;IAC9B,UAAU,EAAE,OAAO,MAAM,CAAC,IAAI,CAAA;IAC9B,UAAU,EAAE,OAAO,MAAM,CAAC,IAAI,CAAA;IAC9B,YAAY,EAAE,OAAO,MAAM,CAAC,MAAM,CAAA;CACnC;AAED,MAAM,WAAW,2BAA2B;IAC1C,gBAAgB,CAAC,EAAE,UAAU,CAAA;IAC7B,WAAW,CAAC,EAAE,UAAU,CAAA;IACxB,eAAe,CAAC,EAAE,UAAU,CAAA;IAC5B,WAAW,CAAC,EAAE,UAAU,CAAA;IACxB,cAAc,CAAC,EAAE,UAAU,CAAA;IAC3B,cAAc,CAAC,EAAE,UAAU,CAAA;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,0BAA0B,CAAA;IACtC,WAAW,EAAE,2BAA2B,CAAA;CACzC;AA+CD,MAAM,WAAW,6BAA6B;IAC5C,OAAO,CAAC,EAAE,gBAAgB,CAAA;IAC1B,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,eAAO,MAAM,wBAAwB,GAAI,wBAGtC,6BAA6B,4CAO/B,CAAA;AAED,eAAO,MAAM,mBAAmB,QAAO,gBAEtC,CAAA;AAED,eAAO,MAAM,uBAAuB,kBAAiB,CAAA;AAErD,eAAO,MAAM,6BAA6B,EAAE,gBA6B3C,CAAA;AAID,MAAM,WAAW,0BAA0B;IACzC,cAAc,CAAC,EAAE,gBAAgB,CAAA;IACjC,oBAAoB,CAAC,EAAE,gBAAgB,CAAA;IACvC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,4BAA4B,GACvC,UAAU,0BAA0B,KACnC,gBA6BF,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { Transition } from 'motion/react';
2
+ import type { AnimationAdapterComponents } from './animationAdapter';
3
+ export interface UseHudMotionResult {
4
+ components: AnimationAdapterComponents;
5
+ transitions: {
6
+ highlight: Transition;
7
+ overlayFade: Transition;
8
+ popoverEntrance: Transition;
9
+ popoverExit: Transition;
10
+ popoverContent: Transition;
11
+ };
12
+ }
13
+ export declare const useHudMotion: () => UseHudMotionResult;
14
+ //# sourceMappingURL=useHudMotion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHudMotion.d.ts","sourceRoot":"","sources":["../../src/motion/useHudMotion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAG9C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAA;AAgCpE,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,0BAA0B,CAAA;IACtC,WAAW,EAAE;QACX,SAAS,EAAE,UAAU,CAAA;QACrB,WAAW,EAAE,UAAU,CAAA;QACvB,eAAe,EAAE,UAAU,CAAA;QAC3B,WAAW,EAAE,UAAU,CAAA;QACvB,cAAc,EAAE,UAAU,CAAA;KAC3B,CAAA;CACF;AAED,eAAO,MAAM,YAAY,QAAO,kBA0B/B,CAAA"}
@@ -0,0 +1,275 @@
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/index.ts
31
+ var router_exports = {};
32
+ __export(router_exports, {
33
+ TanStackRouterSync: () => TanStackRouterSync,
34
+ createPathString: () => createPathString,
35
+ getCurrentRoutePath: () => getCurrentRoutePath,
36
+ getTanStackRouter: () => getTanStackRouter,
37
+ getTourRouter: () => getTourRouter,
38
+ notifyRouteChange: () => notifyRouteChange,
39
+ routeGatingChannel: () => routeGatingChannel,
40
+ setTanStackRouter: () => setTanStackRouter,
41
+ setTourRouter: () => setTourRouter,
42
+ subscribeToRouteChanges: () => subscribeToRouteChanges,
43
+ useTanStackRouterTourAdapter: () => useTanStackRouterTourAdapter
44
+ });
45
+ module.exports = __toCommonJS(router_exports);
46
+
47
+ // src/utils/dom.ts
48
+ var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
49
+
50
+ // src/router/routeGating.ts
51
+ var DEFAULT_POLL_MS = 150;
52
+ var normalizePathname = (pathname) => {
53
+ if (typeof pathname !== "string" || pathname.length === 0) {
54
+ return "/";
55
+ }
56
+ return pathname.startsWith("/") ? pathname : `/${pathname}`;
57
+ };
58
+ var normalizePrefixedSegment = (value, prefix) => {
59
+ if (typeof value !== "string" || value.length === 0) {
60
+ return "";
61
+ }
62
+ return value.startsWith(prefix) ? value : `${prefix}${value}`;
63
+ };
64
+ var getWindowPath = () => {
65
+ if (!isBrowser) return "/";
66
+ const { pathname, search, hash } = window.location;
67
+ return normalizePathname(pathname) + normalizePrefixedSegment(search, "?") + normalizePrefixedSegment(hash, "#");
68
+ };
69
+ var normalizeExternalPath = (path) => {
70
+ if (path.length === 0) {
71
+ return "/";
72
+ }
73
+ try {
74
+ const parsed = new URL(path, "http://flowsterix.local");
75
+ return normalizePathname(parsed.pathname) + normalizePrefixedSegment(parsed.search, "?") + normalizePrefixedSegment(parsed.hash, "#");
76
+ } catch {
77
+ const [withoutHash, hash = ""] = path.split("#");
78
+ const [base, search = ""] = withoutHash.split("?");
79
+ return normalizePathname(base) + normalizePrefixedSegment(search ? `?${search}` : "", "?") + normalizePrefixedSegment(hash ? `#${hash}` : "", "#");
80
+ }
81
+ };
82
+ var RouteGatingChannel = class {
83
+ #listeners = /* @__PURE__ */ new Set();
84
+ #currentPath = getWindowPath();
85
+ #teardown = null;
86
+ #attachDefaultListeners() {
87
+ if (!isBrowser) return;
88
+ if (this.#teardown) return;
89
+ let lastPath = getWindowPath();
90
+ const emitIfChanged = () => {
91
+ const nextPath = getWindowPath();
92
+ if (nextPath === lastPath) return;
93
+ lastPath = nextPath;
94
+ this.notify(nextPath);
95
+ };
96
+ const handler = () => emitIfChanged();
97
+ window.addEventListener("popstate", handler);
98
+ window.addEventListener("hashchange", handler);
99
+ const pollId = window.setInterval(emitIfChanged, DEFAULT_POLL_MS);
100
+ this.#teardown = () => {
101
+ window.removeEventListener("popstate", handler);
102
+ window.removeEventListener("hashchange", handler);
103
+ window.clearInterval(pollId);
104
+ this.#teardown = null;
105
+ };
106
+ }
107
+ #detachDefaultListeners() {
108
+ if (this.#listeners.size > 0) return;
109
+ this.#teardown?.();
110
+ this.#teardown = null;
111
+ }
112
+ getCurrentPath() {
113
+ if (isBrowser) {
114
+ this.#currentPath = getWindowPath();
115
+ }
116
+ return this.#currentPath;
117
+ }
118
+ notify(path) {
119
+ const resolved = typeof path === "string" && path.length > 0 ? normalizeExternalPath(path) : this.getCurrentPath();
120
+ if (resolved === this.#currentPath) {
121
+ this.#currentPath = resolved;
122
+ return;
123
+ }
124
+ this.#currentPath = resolved;
125
+ for (const listener of Array.from(this.#listeners)) {
126
+ try {
127
+ listener(resolved);
128
+ } catch (error) {
129
+ console.warn("[tour][route-gating] listener error", error);
130
+ }
131
+ }
132
+ }
133
+ subscribe(listener) {
134
+ if (this.#listeners.has(listener)) {
135
+ return () => {
136
+ this.#listeners.delete(listener);
137
+ this.#detachDefaultListeners();
138
+ };
139
+ }
140
+ this.#listeners.add(listener);
141
+ if (this.#listeners.size === 1) {
142
+ this.#attachDefaultListeners();
143
+ }
144
+ const current = this.getCurrentPath();
145
+ try {
146
+ listener(current);
147
+ } catch (error) {
148
+ console.warn("[tour][route-gating] listener error", error);
149
+ }
150
+ return () => {
151
+ this.#listeners.delete(listener);
152
+ this.#detachDefaultListeners();
153
+ };
154
+ }
155
+ };
156
+ var routeGatingChannel = new RouteGatingChannel();
157
+ var getCurrentRoutePath = () => routeGatingChannel.getCurrentPath();
158
+ var notifyRouteChange = (path) => {
159
+ routeGatingChannel.notify(path);
160
+ };
161
+ var subscribeToRouteChanges = (listener) => {
162
+ return routeGatingChannel.subscribe(listener);
163
+ };
164
+
165
+ // src/router/utils.ts
166
+ var ensurePrefix = (value, prefix) => value.startsWith(prefix) ? value : `${prefix}${value}`;
167
+ var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
168
+ var toSearchString = (value) => {
169
+ if (!isNonEmptyString(value)) {
170
+ if (value instanceof URLSearchParams) {
171
+ const serialized = value.toString();
172
+ return serialized.length > 0 ? `?${serialized}` : "";
173
+ }
174
+ if (typeof value === "object" && value !== null) {
175
+ try {
176
+ const params = new URLSearchParams();
177
+ for (const [key, raw] of Object.entries(
178
+ value
179
+ )) {
180
+ if (raw === void 0 || raw === null) continue;
181
+ params.set(key, String(raw));
182
+ }
183
+ const serialized = params.toString();
184
+ return serialized.length > 0 ? `?${serialized}` : "";
185
+ } catch {
186
+ return "";
187
+ }
188
+ }
189
+ return "";
190
+ }
191
+ if (value === "?") return "";
192
+ return value.startsWith("?") ? value : ensurePrefix(value, "?");
193
+ };
194
+ var toHashString = (value) => {
195
+ if (!isNonEmptyString(value)) {
196
+ return "";
197
+ }
198
+ if (value === "#") return "";
199
+ return value.startsWith("#") ? value : ensurePrefix(value, "#");
200
+ };
201
+ var createPathString = (pathname, search, hash) => {
202
+ const normalizedPath = isNonEmptyString(pathname) ? pathname.startsWith("/") ? pathname : `/${pathname}` : "/";
203
+ const searchPart = toSearchString(search);
204
+ const hashPart = toHashString(hash);
205
+ return `${normalizedPath}${searchPart}${hashPart}`;
206
+ };
207
+
208
+ // src/router/tanstackRouterAdapter.tsx
209
+ var import_react_router = require("@tanstack/react-router");
210
+ var import_react = require("react");
211
+ var useTanStackRouterTourAdapter = () => {
212
+ const location = (0, import_react_router.useRouterState)({
213
+ select: (state) => state.location
214
+ });
215
+ (0, import_react.useEffect)(() => {
216
+ const resolvedPathname = typeof location.pathname === "string" && location.pathname.length > 0 ? location.pathname : "/";
217
+ const resolvedSearch = "searchStr" in location && typeof location.searchStr === "string" ? location.searchStr : typeof location.search === "string" ? location.search : "";
218
+ const resolvedHash = typeof location.hash === "string" ? location.hash : "";
219
+ const path = typeof location.href === "string" && location.href.length > 0 ? location.href : createPathString(resolvedPathname, resolvedSearch, resolvedHash);
220
+ notifyRouteChange(path);
221
+ }, [location]);
222
+ };
223
+
224
+ // src/router/tanstackRouterSync.tsx
225
+ var TanStackRouter = __toESM(require("@tanstack/react-router"), 1);
226
+ var import_react2 = require("react");
227
+ var currentRouter = null;
228
+ var setTourRouter = (router) => {
229
+ currentRouter = router;
230
+ };
231
+ var setTanStackRouter = setTourRouter;
232
+ var getTourRouter = () => {
233
+ return currentRouter;
234
+ };
235
+ var getTanStackRouter = getTourRouter;
236
+ var TanStackRouterSync = ({
237
+ onRouterAvailable
238
+ }) => {
239
+ const useRouter2 = TanStackRouter.useRouter;
240
+ if (typeof useRouter2 !== "function") {
241
+ if (typeof console !== "undefined") {
242
+ console.warn(
243
+ "[tour][router] TanStackRouterSync requires @tanstack/react-router. Call this component only inside TanStack Router environments."
244
+ );
245
+ }
246
+ return null;
247
+ }
248
+ useTanStackRouterTourAdapter();
249
+ const router = useRouter2();
250
+ (0, import_react2.useEffect)(() => {
251
+ setTourRouter(router);
252
+ onRouterAvailable?.(router);
253
+ return () => {
254
+ if (getTourRouter() === router) {
255
+ setTourRouter(null);
256
+ }
257
+ onRouterAvailable?.(null);
258
+ };
259
+ }, [router, onRouterAvailable]);
260
+ return null;
261
+ };
262
+ // Annotate the CommonJS export names for ESM import in node:
263
+ 0 && (module.exports = {
264
+ TanStackRouterSync,
265
+ createPathString,
266
+ getCurrentRoutePath,
267
+ getTanStackRouter,
268
+ getTourRouter,
269
+ notifyRouteChange,
270
+ routeGatingChannel,
271
+ setTanStackRouter,
272
+ setTourRouter,
273
+ subscribeToRouteChanges,
274
+ useTanStackRouterTourAdapter
275
+ });
@@ -0,0 +1,5 @@
1
+ export { getCurrentRoutePath, notifyRouteChange, routeGatingChannel, subscribeToRouteChanges, } from './routeGating';
2
+ export { createPathString } from './utils';
3
+ export { useTanStackRouterTourAdapter } from './tanstackRouterAdapter';
4
+ export { getTanStackRouter, getTourRouter, setTanStackRouter, setTourRouter, TanStackRouterSync, } from './tanstackRouterSync';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAA;AAEtE,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,kBAAkB,GACnB,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,30 @@
1
+ import {
2
+ TanStackRouterSync,
3
+ getTanStackRouter,
4
+ getTourRouter,
5
+ setTanStackRouter,
6
+ setTourRouter
7
+ } from "../chunk-U757YVZP.mjs";
8
+ import {
9
+ useTanStackRouterTourAdapter
10
+ } from "../chunk-RCASLQRS.mjs";
11
+ import {
12
+ createPathString,
13
+ getCurrentRoutePath,
14
+ notifyRouteChange,
15
+ routeGatingChannel,
16
+ subscribeToRouteChanges
17
+ } from "../chunk-RPA2S5UP.mjs";
18
+ export {
19
+ TanStackRouterSync,
20
+ createPathString,
21
+ getCurrentRoutePath,
22
+ getTanStackRouter,
23
+ getTourRouter,
24
+ notifyRouteChange,
25
+ routeGatingChannel,
26
+ setTanStackRouter,
27
+ setTourRouter,
28
+ subscribeToRouteChanges,
29
+ useTanStackRouterTourAdapter
30
+ };
@@ -0,0 +1,224 @@
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");
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/nextAppRouterAdapter.tsx
197
+ var useNextAppRouterTourAdapter = () => {
198
+ const usePathname2 = typeof NextNavigation.usePathname === "function" ? NextNavigation.usePathname : null;
199
+ const useSearchParams2 = typeof NextNavigation.useSearchParams === "function" ? NextNavigation.useSearchParams : null;
200
+ if (!usePathname2 || !useSearchParams2) {
201
+ if (typeof console !== "undefined") {
202
+ console.warn(
203
+ "[tour][router] useNextAppRouterTourAdapter requires next/navigation. Call this hook only in Next.js App Router environments."
204
+ );
205
+ }
206
+ return;
207
+ }
208
+ const pathname = usePathname2();
209
+ const searchParams = useSearchParams2();
210
+ const searchValue = searchParams?.toString() ?? "";
211
+ (0, import_react.useEffect)(() => {
212
+ if (typeof pathname !== "string") return;
213
+ const path = createPathString(
214
+ pathname,
215
+ searchValue.length > 0 ? `?${searchValue}` : "",
216
+ void 0
217
+ );
218
+ notifyRouteChange(path);
219
+ }, [pathname, searchValue]);
220
+ };
221
+ // Annotate the CommonJS export names for ESM import in node:
222
+ 0 && (module.exports = {
223
+ useNextAppRouterTourAdapter
224
+ });
@@ -0,0 +1,2 @@
1
+ export declare const useNextAppRouterTourAdapter: () => void;
2
+ //# sourceMappingURL=nextAppRouterAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nextAppRouterAdapter.d.ts","sourceRoot":"","sources":["../../src/router/nextAppRouterAdapter.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,2BAA2B,YAkCvC,CAAA"}
@@ -0,0 +1,35 @@
1
+ import {
2
+ createPathString,
3
+ notifyRouteChange
4
+ } from "../chunk-RPA2S5UP.mjs";
5
+
6
+ // src/router/nextAppRouterAdapter.tsx
7
+ import * as NextNavigation from "next/navigation";
8
+ import { useEffect } from "react";
9
+ var useNextAppRouterTourAdapter = () => {
10
+ const usePathname2 = typeof NextNavigation.usePathname === "function" ? NextNavigation.usePathname : null;
11
+ const useSearchParams2 = typeof NextNavigation.useSearchParams === "function" ? NextNavigation.useSearchParams : null;
12
+ if (!usePathname2 || !useSearchParams2) {
13
+ if (typeof console !== "undefined") {
14
+ console.warn(
15
+ "[tour][router] useNextAppRouterTourAdapter requires next/navigation. Call this hook only in Next.js App Router environments."
16
+ );
17
+ }
18
+ return;
19
+ }
20
+ const pathname = usePathname2();
21
+ const searchParams = useSearchParams2();
22
+ const searchValue = searchParams?.toString() ?? "";
23
+ useEffect(() => {
24
+ if (typeof pathname !== "string") return;
25
+ const path = createPathString(
26
+ pathname,
27
+ searchValue.length > 0 ? `?${searchValue}` : "",
28
+ void 0
29
+ );
30
+ notifyRouteChange(path);
31
+ }, [pathname, searchValue]);
32
+ };
33
+ export {
34
+ useNextAppRouterTourAdapter
35
+ };