@buoy-gg/route-events 7.0.41 → 7.0.42

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 (102) hide show
  1. package/README.md +11 -64
  2. package/lib/commonjs/RouteObserver.js +1 -54
  3. package/lib/commonjs/RouteParser.js +1 -314
  4. package/lib/commonjs/RouteTracker.js +1 -112
  5. package/lib/commonjs/RouteTracker.web.js +1 -12
  6. package/lib/commonjs/browserRouteRegistry.js +1 -30
  7. package/lib/commonjs/browserRoutes.js +1 -96
  8. package/lib/commonjs/components/NavigationStack.js +2 -572
  9. package/lib/commonjs/components/ReactNavigationRoutes.js +1 -836
  10. package/lib/commonjs/components/ReactNavigationRoutes.web.js +1 -12
  11. package/lib/commonjs/components/RouteEventDetail.js +1 -97
  12. package/lib/commonjs/components/RouteEventExpandedContent.js +1 -204
  13. package/lib/commonjs/components/RouteEventItemCompact.js +1 -191
  14. package/lib/commonjs/components/RouteEventsModalWithTabs.js +1 -734
  15. package/lib/commonjs/components/RouteEventsTimeline.js +1 -107
  16. package/lib/commonjs/components/RouteFilterViewV2.js +1 -42
  17. package/lib/commonjs/components/RoutesSitemap.js +2 -1035
  18. package/lib/commonjs/expoRouterStore.js +1 -121
  19. package/lib/commonjs/expoRouterStore.web.js +1 -44
  20. package/lib/commonjs/hooks/useRouteEvents.js +1 -57
  21. package/lib/commonjs/index.js +1 -168
  22. package/lib/commonjs/preset.js +1 -69
  23. package/lib/commonjs/stores/navigationStackStore.js +1 -45
  24. package/lib/commonjs/stores/routeEventStore.js +1 -136
  25. package/lib/commonjs/sync/routeEventsSyncAdapter.js +1 -275
  26. package/lib/commonjs/useNavigationStack.js +1 -408
  27. package/lib/commonjs/useNavigationStack.web.js +1 -32
  28. package/lib/commonjs/useRouteObserver.js +1 -73
  29. package/lib/commonjs/useRouteObserverReactNavigation.js +1 -109
  30. package/lib/commonjs/useRouteSitemap.js +1 -255
  31. package/lib/commonjs/utils/routeTemplate.js +1 -79
  32. package/lib/commonjs/utils/safeReactNavigation.js +1 -194
  33. package/lib/commonjs/utils/safeReactNavigation.web.js +1 -36
  34. package/lib/commonjs/utils/testIDs.js +1 -63
  35. package/lib/module/RouteObserver.js +1 -49
  36. package/lib/module/RouteParser.js +1 -309
  37. package/lib/module/RouteTracker.js +1 -109
  38. package/lib/module/RouteTracker.web.js +1 -8
  39. package/lib/module/browserRouteRegistry.js +1 -24
  40. package/lib/module/browserRoutes.js +1 -92
  41. package/lib/module/components/NavigationStack.js +2 -568
  42. package/lib/module/components/ReactNavigationRoutes.js +1 -832
  43. package/lib/module/components/ReactNavigationRoutes.web.js +1 -3
  44. package/lib/module/components/RouteEventDetail.js +1 -93
  45. package/lib/module/components/RouteEventExpandedContent.js +1 -200
  46. package/lib/module/components/RouteEventItemCompact.js +1 -187
  47. package/lib/module/components/RouteEventsModalWithTabs.js +1 -731
  48. package/lib/module/components/RouteEventsTimeline.js +1 -103
  49. package/lib/module/components/RouteFilterViewV2.js +1 -38
  50. package/lib/module/components/RoutesSitemap.js +2 -1033
  51. package/lib/module/expoRouterStore.js +1 -114
  52. package/lib/module/expoRouterStore.web.js +1 -37
  53. package/lib/module/hooks/useRouteEvents.js +1 -54
  54. package/lib/module/index.js +1 -70
  55. package/lib/module/preset.js +1 -66
  56. package/lib/module/stores/navigationStackStore.js +1 -41
  57. package/lib/module/stores/routeEventStore.js +1 -128
  58. package/lib/module/sync/routeEventsSyncAdapter.js +1 -273
  59. package/lib/module/useNavigationStack.js +1 -404
  60. package/lib/module/useNavigationStack.web.js +1 -28
  61. package/lib/module/useRouteObserver.js +1 -70
  62. package/lib/module/useRouteObserverReactNavigation.js +1 -106
  63. package/lib/module/useRouteSitemap.js +1 -250
  64. package/lib/module/utils/routeTemplate.js +1 -73
  65. package/lib/module/utils/safeReactNavigation.js +1 -185
  66. package/lib/module/utils/safeReactNavigation.web.js +1 -27
  67. package/lib/module/utils/testIDs.js +1 -55
  68. package/lib/web/index.mjs +4 -5
  69. package/package.json +5 -5
  70. package/lib/typescript/RouteObserver.d.ts.map +0 -1
  71. package/lib/typescript/RouteParser.d.ts.map +0 -1
  72. package/lib/typescript/RouteTracker.d.ts.map +0 -1
  73. package/lib/typescript/RouteTracker.web.d.ts.map +0 -1
  74. package/lib/typescript/browserRouteRegistry.d.ts.map +0 -1
  75. package/lib/typescript/browserRoutes.d.ts.map +0 -1
  76. package/lib/typescript/components/NavigationStack.d.ts.map +0 -1
  77. package/lib/typescript/components/ReactNavigationRoutes.d.ts.map +0 -1
  78. package/lib/typescript/components/ReactNavigationRoutes.web.d.ts.map +0 -1
  79. package/lib/typescript/components/RouteEventDetail.d.ts.map +0 -1
  80. package/lib/typescript/components/RouteEventExpandedContent.d.ts.map +0 -1
  81. package/lib/typescript/components/RouteEventItemCompact.d.ts.map +0 -1
  82. package/lib/typescript/components/RouteEventsModalWithTabs.d.ts.map +0 -1
  83. package/lib/typescript/components/RouteEventsTimeline.d.ts.map +0 -1
  84. package/lib/typescript/components/RouteFilterViewV2.d.ts.map +0 -1
  85. package/lib/typescript/components/RoutesSitemap.d.ts.map +0 -1
  86. package/lib/typescript/expoRouterStore.d.ts.map +0 -1
  87. package/lib/typescript/expoRouterStore.web.d.ts.map +0 -1
  88. package/lib/typescript/hooks/useRouteEvents.d.ts.map +0 -1
  89. package/lib/typescript/index.d.ts.map +0 -1
  90. package/lib/typescript/preset.d.ts.map +0 -1
  91. package/lib/typescript/stores/navigationStackStore.d.ts.map +0 -1
  92. package/lib/typescript/stores/routeEventStore.d.ts.map +0 -1
  93. package/lib/typescript/sync/routeEventsSyncAdapter.d.ts.map +0 -1
  94. package/lib/typescript/useNavigationStack.d.ts.map +0 -1
  95. package/lib/typescript/useNavigationStack.web.d.ts.map +0 -1
  96. package/lib/typescript/useRouteObserver.d.ts.map +0 -1
  97. package/lib/typescript/useRouteObserverReactNavigation.d.ts.map +0 -1
  98. package/lib/typescript/useRouteSitemap.d.ts.map +0 -1
  99. package/lib/typescript/utils/routeTemplate.d.ts.map +0 -1
  100. package/lib/typescript/utils/safeReactNavigation.d.ts.map +0 -1
  101. package/lib/typescript/utils/safeReactNavigation.web.d.ts.map +0 -1
  102. package/lib/typescript/utils/testIDs.d.ts.map +0 -1
@@ -1,96 +1 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.startBrowserRouteCapture = startBrowserRouteCapture;
7
- var _utils = require("@buoy-gg/shared-ui/utils");
8
- var _RouteObserver = require("./RouteObserver");
9
- var _routeEventStore = require("./stores/routeEventStore");
10
- var _navigationStackStore = require("./stores/navigationStackStore");
11
- let leases = 0;
12
- let stop;
13
- function startBrowserRouteCapture() {
14
- if (typeof window === 'undefined') return () => {};
15
- if (leases++ === 0) {
16
- _routeEventStore.routeEventStore.hydrateBootCapture();
17
- let previousPathname;
18
- let previousTime;
19
- let lastHref = '';
20
- const visits = [];
21
- let cursor = -1;
22
- const update = change => {
23
- if (change.href === lastHref && change.kind === 'pop') return;
24
- if (change.kind === 'replace' && cursor >= 0) visits[cursor] = change.href;else if (change.kind === 'pop') {
25
- const index = visits.lastIndexOf(change.href, cursor - 1);
26
- const forward = visits.indexOf(change.href, cursor + 1);
27
- if (index >= 0) cursor = index;else if (forward >= 0) cursor = forward;else {
28
- visits.splice(cursor + 1);
29
- visits.push(change.href);
30
- cursor++;
31
- }
32
- } else {
33
- visits.splice(cursor + 1);
34
- visits.push(change.href);
35
- cursor++;
36
- }
37
- lastHref = change.href;
38
- const url = (0, _utils.getBrowserRouteURL)(change.href);
39
- const timestamp = Date.now();
40
- _RouteObserver.routeObserver.emit({
41
- pathname: url.pathname,
42
- params: Object.fromEntries(url.searchParams),
43
- segments: url.pathname.split('/').filter(Boolean),
44
- previousPathname,
45
- timestamp,
46
- timeSincePrevious: previousTime === undefined ? undefined : timestamp - previousTime
47
- });
48
- previousPathname = url.pathname;
49
- previousTime = timestamp;
50
- _navigationStackStore.navigationStackStore.setStack(visits.map((href, index) => {
51
- const location = (0, _utils.getBrowserRouteURL)(href);
52
- return {
53
- key: `browser:${index}`,
54
- name: location.pathname,
55
- pathname: location.pathname,
56
- params: Object.fromEntries(location.searchParams),
57
- index,
58
- isFocused: index === cursor,
59
- canPop: index > 0
60
- };
61
- }));
62
- };
63
- const goTo = index => {
64
- if (!Number.isInteger(index) || index < 0 || index >= visits.length) throw new Error('That browser history entry is unavailable.');
65
- window.history.go(index - cursor);
66
- };
67
- _navigationStackStore.navigationStackStore.setActions({
68
- navigateToIndex: goTo,
69
- popToIndex: goTo,
70
- goBack: _utils.browserRouter.back,
71
- popToTop: () => goTo(0),
72
- navigateToRoute: (name, params) => {
73
- _utils.browserRouter.push({
74
- pathname: name,
75
- params: params
76
- });
77
- return true;
78
- }
79
- });
80
- stop = (0, _utils.subscribeBrowserNavigation)(update);
81
- update({
82
- href: (0, _utils.getBrowserHref)(),
83
- kind: 'initial'
84
- });
85
- }
86
- let released = false;
87
- return () => {
88
- if (released) return;
89
- released = true;
90
- if (--leases === 0) {
91
- stop?.();
92
- stop = undefined;
93
- _navigationStackStore.navigationStackStore.setActions(null);
94
- }
95
- };
96
- }
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.startBrowserRouteCapture=startBrowserRouteCapture;var _utils=require("@buoy-gg/shared-ui/utils");var _RouteObserver=require("./RouteObserver");var _routeEventStore=require("./stores/routeEventStore");var _navigationStackStore=require("./stores/navigationStackStore");let leases=0;let stop;function startBrowserRouteCapture(){if(typeof window==="undefined")return()=>{};if(leases++===0){_routeEventStore.routeEventStore.hydrateBootCapture();let l;let i;let m="";const r=[];let t=-1;const c=e=>{if(e.href===m&&e.kind==="pop")return;if(e.kind==="replace"&&t>=0)r[t]=e.href;else if(e.kind==="pop"){const a=r.lastIndexOf(e.href,t-1);const o=r.indexOf(e.href,t+1);if(a>=0)t=a;else if(o>=0)t=o;else{r.splice(t+1);r.push(e.href);t++}}else{r.splice(t+1);r.push(e.href);t++}m=e.href;const s=(0,_utils.getBrowserRouteURL)(e.href);const u=Date.now();_RouteObserver.routeObserver.emit({pathname:s.pathname,params:Object.fromEntries(s.searchParams),segments:s.pathname.split("/").filter(Boolean),previousPathname:l,timestamp:u,timeSincePrevious:i===void 0?void 0:u-i});l=s.pathname;i=u;_navigationStackStore.navigationStackStore.setStack(r.map((a,o)=>{const p=(0,_utils.getBrowserRouteURL)(a);return{key:`browser:${o}`,name:p.pathname,pathname:p.pathname,params:Object.fromEntries(p.searchParams),index:o,isFocused:o===t,canPop:o>0}}))};const n=e=>{if(!Number.isInteger(e)||e<0||e>=r.length)throw new Error("That browser history entry is unavailable.");window.history.go(e-t)};_navigationStackStore.navigationStackStore.setActions({navigateToIndex:n,popToIndex:n,goBack:_utils.browserRouter.back,popToTop:()=>n(0),navigateToRoute:(e,s)=>{_utils.browserRouter.push({pathname:e,params:s});return true}});stop=(0,_utils.subscribeBrowserNavigation)(c);c({href:(0,_utils.getBrowserHref)(),kind:"initial"})}let f=false;return()=>{if(f)return;f=true;if(--leases===0){stop?.();stop=void 0;_navigationStackStore.navigationStackStore.setActions(null)}}}