@flowsterix/react 0.11.0 → 0.12.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 (33) hide show
  1. package/dist/chunk-D5LQLRSU.cjs +289 -0
  2. package/dist/chunk-FCOKCGV3.cjs +21 -0
  3. package/dist/chunk-HPVLOLCD.cjs +1 -0
  4. package/dist/components/TourPopoverPortal.d.ts +1 -1
  5. package/dist/components/TourPopoverPortal.d.ts.map +1 -1
  6. package/dist/context.d.ts +6 -0
  7. package/dist/context.d.ts.map +1 -1
  8. package/dist/devtools/DevToolsProvider.d.ts.map +1 -1
  9. package/dist/devtools/components/FlowEditModal.d.ts.map +1 -1
  10. package/dist/devtools/components/FlowItem.d.ts.map +1 -1
  11. package/dist/devtools/components/GrabberOverlay.d.ts +1 -0
  12. package/dist/devtools/components/GrabberOverlay.d.ts.map +1 -1
  13. package/dist/devtools/components/StepItem.d.ts.map +1 -1
  14. package/dist/devtools/components/StepList.d.ts.map +1 -1
  15. package/dist/devtools/components/TabNav.d.ts.map +1 -1
  16. package/dist/devtools/components/Toolbar.d.ts.map +1 -1
  17. package/dist/devtools/globalBridge.d.ts +24 -0
  18. package/dist/devtools/globalBridge.d.ts.map +1 -0
  19. package/dist/devtools/hooks/useFlowsData.d.ts.map +1 -1
  20. package/dist/devtools/index.cjs +849 -577
  21. package/dist/devtools/index.mjs +605 -281
  22. package/dist/devtools/motion.d.ts +64 -0
  23. package/dist/devtools/motion.d.ts.map +1 -0
  24. package/dist/hooks/useHiddenTargetFallback.d.ts.map +1 -1
  25. package/dist/hooks/useTourOverlay.d.ts.map +1 -1
  26. package/dist/index.cjs +701 -927
  27. package/dist/index.mjs +116 -42
  28. package/dist/router/index.cjs +13 -202
  29. package/dist/router/nextAppRouterAdapter.cjs +11 -200
  30. package/dist/router/nextPagesRouterAdapter.cjs +10 -199
  31. package/dist/router/reactRouterAdapter.cjs +10 -199
  32. package/dist/router/tanstackRouterAdapter.cjs +22 -214
  33. package/package.json +1 -1
@@ -1,206 +1,15 @@
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);
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 _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; }
29
2
 
30
- // src/router/tanstackRouterAdapter.tsx
31
- var tanstackRouterAdapter_exports = {};
32
- __export(tanstackRouterAdapter_exports, {
33
- TanStackRouterSync: () => TanStackRouterSync,
34
- getTanStackRouter: () => getTanStackRouter,
35
- getTourRouter: () => getTourRouter,
36
- setTanStackRouter: () => setTanStackRouter,
37
- setTourRouter: () => setTourRouter,
38
- useTanStackRouterTourAdapter: () => useTanStackRouterTourAdapter
39
- });
40
- module.exports = __toCommonJS(tanstackRouterAdapter_exports);
41
- var import_react_router = require("@tanstack/react-router");
42
- var import_react2 = require("react");
43
3
 
44
- // src/utils/dom.ts
45
- var isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
4
+ var _chunkD5LQLRSUcjs = require('../chunk-D5LQLRSU.cjs');
46
5
 
47
- // src/router/routeGating.ts
48
- var DEFAULT_POLL_MS = 150;
49
- var normalizePathname = (pathname) => {
50
- if (typeof pathname !== "string" || pathname.length === 0) {
51
- return "/";
52
- }
53
- return pathname.startsWith("/") ? pathname : `/${pathname}`;
54
- };
55
- var normalizePrefixedSegment = (value, prefix) => {
56
- if (typeof value !== "string" || value.length === 0) {
57
- return "";
58
- }
59
- return value.startsWith(prefix) ? value : `${prefix}${value}`;
60
- };
61
- var getWindowPath = () => {
62
- if (!isBrowser) return "/";
63
- const { pathname, search, hash } = window.location;
64
- return normalizePathname(pathname) + normalizePrefixedSegment(search, "?") + normalizePrefixedSegment(hash, "#");
65
- };
66
- var normalizeExternalPath = (path) => {
67
- if (path.length === 0) {
68
- return "/";
69
- }
70
- try {
71
- const parsed = new URL(path, "http://flowsterix.local");
72
- return normalizePathname(parsed.pathname) + normalizePrefixedSegment(parsed.search, "?") + normalizePrefixedSegment(parsed.hash, "#");
73
- } catch {
74
- const [withoutHash, hash = ""] = path.split("#");
75
- const [base, search = ""] = withoutHash.split("?");
76
- return normalizePathname(base) + normalizePrefixedSegment(search ? `?${search}` : "", "?") + normalizePrefixedSegment(hash ? `#${hash}` : "", "#");
77
- }
78
- };
79
- var RouteGatingChannel = class {
80
- #listeners = /* @__PURE__ */ new Set();
81
- #currentPath = getWindowPath();
82
- #teardown = null;
83
- #attachDefaultListeners() {
84
- if (!isBrowser) return;
85
- if (this.#teardown) return;
86
- let lastPath = getWindowPath();
87
- const emitIfChanged = () => {
88
- const nextPath = getWindowPath();
89
- if (nextPath === lastPath) return;
90
- lastPath = nextPath;
91
- this.notify(nextPath);
92
- };
93
- const handler = () => emitIfChanged();
94
- window.addEventListener("popstate", handler);
95
- window.addEventListener("hashchange", handler);
96
- const pollId = window.setInterval(emitIfChanged, DEFAULT_POLL_MS);
97
- this.#teardown = () => {
98
- window.removeEventListener("popstate", handler);
99
- window.removeEventListener("hashchange", handler);
100
- window.clearInterval(pollId);
101
- this.#teardown = null;
102
- };
103
- }
104
- #detachDefaultListeners() {
105
- if (this.#listeners.size > 0) return;
106
- this.#teardown?.();
107
- this.#teardown = null;
108
- }
109
- getCurrentPath() {
110
- if (isBrowser) {
111
- this.#currentPath = getWindowPath();
112
- }
113
- return this.#currentPath;
114
- }
115
- notify(path) {
116
- const resolved = typeof path === "string" && path.length > 0 ? normalizeExternalPath(path) : this.getCurrentPath();
117
- if (resolved === this.#currentPath) {
118
- this.#currentPath = resolved;
119
- return;
120
- }
121
- this.#currentPath = resolved;
122
- for (const listener of Array.from(this.#listeners)) {
123
- try {
124
- listener(resolved);
125
- } catch (error) {
126
- console.warn("[tour][route-gating] listener error", error);
127
- }
128
- }
129
- }
130
- subscribe(listener) {
131
- if (this.#listeners.has(listener)) {
132
- return () => {
133
- this.#listeners.delete(listener);
134
- this.#detachDefaultListeners();
135
- };
136
- }
137
- this.#listeners.add(listener);
138
- if (this.#listeners.size === 1) {
139
- this.#attachDefaultListeners();
140
- }
141
- const current = this.getCurrentPath();
142
- try {
143
- listener(current);
144
- } catch (error) {
145
- console.warn("[tour][route-gating] listener error", error);
146
- }
147
- return () => {
148
- this.#listeners.delete(listener);
149
- this.#detachDefaultListeners();
150
- };
151
- }
152
- };
153
- var routeGatingChannel = new RouteGatingChannel();
154
- var notifyRouteChange = (path) => {
155
- routeGatingChannel.notify(path);
156
- };
157
-
158
- // src/router/utils.ts
159
- var ensurePrefix = (value, prefix) => value.startsWith(prefix) ? value : `${prefix}${value}`;
160
- var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
161
- var toSearchString = (value) => {
162
- if (!isNonEmptyString(value)) {
163
- if (value instanceof URLSearchParams) {
164
- const serialized = value.toString();
165
- return serialized.length > 0 ? `?${serialized}` : "";
166
- }
167
- if (typeof value === "object" && value !== null) {
168
- try {
169
- const params = new URLSearchParams();
170
- for (const [key, raw] of Object.entries(
171
- value
172
- )) {
173
- if (raw === void 0 || raw === null) continue;
174
- params.set(key, String(raw));
175
- }
176
- const serialized = params.toString();
177
- return serialized.length > 0 ? `?${serialized}` : "";
178
- } catch {
179
- return "";
180
- }
181
- }
182
- return "";
183
- }
184
- if (value === "?") return "";
185
- return value.startsWith("?") ? value : ensurePrefix(value, "?");
186
- };
187
- var toHashString = (value) => {
188
- if (!isNonEmptyString(value)) {
189
- return "";
190
- }
191
- if (value === "#") return "";
192
- return value.startsWith("#") ? value : ensurePrefix(value, "#");
193
- };
194
- var createPathString = (pathname, search, hash) => {
195
- const normalizedPath = isNonEmptyString(pathname) ? pathname.startsWith("/") ? pathname : `/${pathname}` : "/";
196
- const searchPart = toSearchString(search);
197
- const hashPart = toHashString(hash);
198
- return `${normalizedPath}${searchPart}${hashPart}`;
199
- };
6
+ // src/router/tanstackRouterAdapter.tsx
7
+ var _reactrouter = require('@tanstack/react-router'); var TanStackRouter = _interopRequireWildcard(_reactrouter);
8
+ var _react = require('react');
200
9
 
201
10
  // src/router/tanstackRouterSync.tsx
202
- var TanStackRouter = __toESM(require("@tanstack/react-router"), 1);
203
- var import_react = require("react");
11
+
12
+
204
13
  var currentRouter = null;
205
14
  var setTourRouter = (router) => {
206
15
  currentRouter = router;
@@ -224,14 +33,14 @@ var TanStackRouterSync = ({
224
33
  }
225
34
  useTanStackRouterTourAdapter();
226
35
  const router = useRouter2();
227
- (0, import_react.useEffect)(() => {
36
+ _react.useEffect.call(void 0, () => {
228
37
  setTourRouter(router);
229
- onRouterAvailable?.(router);
38
+ _optionalChain([onRouterAvailable, 'optionalCall', _ => _(router)]);
230
39
  return () => {
231
40
  if (getTourRouter() === router) {
232
41
  setTourRouter(null);
233
42
  }
234
- onRouterAvailable?.(null);
43
+ _optionalChain([onRouterAvailable, 'optionalCall', _2 => _2(null)]);
235
44
  };
236
45
  }, [router, onRouterAvailable]);
237
46
  return null;
@@ -239,23 +48,22 @@ var TanStackRouterSync = ({
239
48
 
240
49
  // src/router/tanstackRouterAdapter.tsx
241
50
  var useTanStackRouterTourAdapter = () => {
242
- const location = (0, import_react_router.useRouterState)({
51
+ const location = _reactrouter.useRouterState.call(void 0, {
243
52
  select: (state) => state.location
244
53
  });
245
- (0, import_react2.useEffect)(() => {
54
+ _react.useEffect.call(void 0, () => {
246
55
  const resolvedPathname = typeof location.pathname === "string" && location.pathname.length > 0 ? location.pathname : "/";
247
56
  const resolvedSearch = "searchStr" in location && typeof location.searchStr === "string" ? location.searchStr : typeof location.search === "string" ? location.search : "";
248
57
  const resolvedHash = typeof location.hash === "string" ? location.hash : "";
249
- const path = typeof location.href === "string" && location.href.length > 0 ? location.href : createPathString(resolvedPathname, resolvedSearch, resolvedHash);
250
- notifyRouteChange(path);
58
+ const path = typeof location.href === "string" && location.href.length > 0 ? location.href : _chunkD5LQLRSUcjs.createPathString.call(void 0, resolvedPathname, resolvedSearch, resolvedHash);
59
+ _chunkD5LQLRSUcjs.notifyRouteChange.call(void 0, path);
251
60
  }, [location]);
252
61
  };
253
- // Annotate the CommonJS export names for ESM import in node:
254
- 0 && (module.exports = {
255
- TanStackRouterSync,
256
- getTanStackRouter,
257
- getTourRouter,
258
- setTanStackRouter,
259
- setTourRouter,
260
- useTanStackRouterTourAdapter
261
- });
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+ exports.TanStackRouterSync = TanStackRouterSync; exports.getTanStackRouter = getTanStackRouter; exports.getTourRouter = getTourRouter; exports.setTanStackRouter = setTanStackRouter; exports.setTourRouter = setTourRouter; exports.useTanStackRouterTourAdapter = useTanStackRouterTourAdapter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowsterix/react",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "React bindings for Flowsterix - guided tours and onboarding flows",
5
5
  "license": "MIT",
6
6
  "repository": {