@buoy-gg/route-events 7.0.41 → 7.0.43
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/README.md +11 -64
- package/lib/commonjs/RouteObserver.js +1 -54
- package/lib/commonjs/RouteParser.js +1 -314
- package/lib/commonjs/RouteTracker.js +1 -112
- package/lib/commonjs/RouteTracker.web.js +1 -12
- package/lib/commonjs/browserRouteRegistry.js +1 -30
- package/lib/commonjs/browserRoutes.js +1 -96
- package/lib/commonjs/components/NavigationStack.js +2 -572
- package/lib/commonjs/components/ReactNavigationRoutes.js +1 -836
- package/lib/commonjs/components/ReactNavigationRoutes.web.js +1 -12
- package/lib/commonjs/components/RouteEventDetail.js +1 -97
- package/lib/commonjs/components/RouteEventExpandedContent.js +1 -204
- package/lib/commonjs/components/RouteEventItemCompact.js +1 -191
- package/lib/commonjs/components/RouteEventsModalWithTabs.js +1 -734
- package/lib/commonjs/components/RouteEventsTimeline.js +1 -107
- package/lib/commonjs/components/RouteFilterViewV2.js +1 -42
- package/lib/commonjs/components/RoutesSitemap.js +2 -1035
- package/lib/commonjs/expoRouterStore.js +1 -121
- package/lib/commonjs/expoRouterStore.web.js +1 -44
- package/lib/commonjs/hooks/useRouteEvents.js +1 -57
- package/lib/commonjs/index.js +1 -168
- package/lib/commonjs/preset.js +1 -69
- package/lib/commonjs/stores/navigationStackStore.js +1 -45
- package/lib/commonjs/stores/routeEventStore.js +1 -136
- package/lib/commonjs/sync/routeEventsSyncAdapter.js +1 -275
- package/lib/commonjs/useNavigationStack.js +1 -408
- package/lib/commonjs/useNavigationStack.web.js +1 -32
- package/lib/commonjs/useRouteObserver.js +1 -73
- package/lib/commonjs/useRouteObserverReactNavigation.js +1 -109
- package/lib/commonjs/useRouteSitemap.js +1 -255
- package/lib/commonjs/utils/routeTemplate.js +1 -79
- package/lib/commonjs/utils/safeReactNavigation.js +1 -194
- package/lib/commonjs/utils/safeReactNavigation.web.js +1 -36
- package/lib/commonjs/utils/testIDs.js +1 -63
- package/lib/module/RouteObserver.js +1 -49
- package/lib/module/RouteParser.js +1 -309
- package/lib/module/RouteTracker.js +1 -109
- package/lib/module/RouteTracker.web.js +1 -8
- package/lib/module/browserRouteRegistry.js +1 -24
- package/lib/module/browserRoutes.js +1 -92
- package/lib/module/components/NavigationStack.js +2 -568
- package/lib/module/components/ReactNavigationRoutes.js +1 -832
- package/lib/module/components/ReactNavigationRoutes.web.js +1 -3
- package/lib/module/components/RouteEventDetail.js +1 -93
- package/lib/module/components/RouteEventExpandedContent.js +1 -200
- package/lib/module/components/RouteEventItemCompact.js +1 -187
- package/lib/module/components/RouteEventsModalWithTabs.js +1 -731
- package/lib/module/components/RouteEventsTimeline.js +1 -103
- package/lib/module/components/RouteFilterViewV2.js +1 -38
- package/lib/module/components/RoutesSitemap.js +2 -1033
- package/lib/module/expoRouterStore.js +1 -114
- package/lib/module/expoRouterStore.web.js +1 -37
- package/lib/module/hooks/useRouteEvents.js +1 -54
- package/lib/module/index.js +1 -70
- package/lib/module/preset.js +1 -66
- package/lib/module/stores/navigationStackStore.js +1 -41
- package/lib/module/stores/routeEventStore.js +1 -128
- package/lib/module/sync/routeEventsSyncAdapter.js +1 -273
- package/lib/module/useNavigationStack.js +1 -404
- package/lib/module/useNavigationStack.web.js +1 -28
- package/lib/module/useRouteObserver.js +1 -70
- package/lib/module/useRouteObserverReactNavigation.js +1 -106
- package/lib/module/useRouteSitemap.js +1 -250
- package/lib/module/utils/routeTemplate.js +1 -73
- package/lib/module/utils/safeReactNavigation.js +1 -185
- package/lib/module/utils/safeReactNavigation.web.js +1 -27
- package/lib/module/utils/testIDs.js +1 -55
- package/lib/web/index.mjs +4 -5
- package/package.json +6 -11
- package/lib/typescript/RouteObserver.d.ts.map +0 -1
- package/lib/typescript/RouteParser.d.ts.map +0 -1
- package/lib/typescript/RouteTracker.d.ts.map +0 -1
- package/lib/typescript/RouteTracker.web.d.ts.map +0 -1
- package/lib/typescript/browserRouteRegistry.d.ts.map +0 -1
- package/lib/typescript/browserRoutes.d.ts.map +0 -1
- package/lib/typescript/components/NavigationStack.d.ts.map +0 -1
- package/lib/typescript/components/ReactNavigationRoutes.d.ts.map +0 -1
- package/lib/typescript/components/ReactNavigationRoutes.web.d.ts.map +0 -1
- package/lib/typescript/components/RouteEventDetail.d.ts.map +0 -1
- package/lib/typescript/components/RouteEventExpandedContent.d.ts.map +0 -1
- package/lib/typescript/components/RouteEventItemCompact.d.ts.map +0 -1
- package/lib/typescript/components/RouteEventsModalWithTabs.d.ts.map +0 -1
- package/lib/typescript/components/RouteEventsTimeline.d.ts.map +0 -1
- package/lib/typescript/components/RouteFilterViewV2.d.ts.map +0 -1
- package/lib/typescript/components/RoutesSitemap.d.ts.map +0 -1
- package/lib/typescript/expoRouterStore.d.ts.map +0 -1
- package/lib/typescript/expoRouterStore.web.d.ts.map +0 -1
- package/lib/typescript/hooks/useRouteEvents.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/preset.d.ts.map +0 -1
- package/lib/typescript/stores/navigationStackStore.d.ts.map +0 -1
- package/lib/typescript/stores/routeEventStore.d.ts.map +0 -1
- package/lib/typescript/sync/routeEventsSyncAdapter.d.ts.map +0 -1
- package/lib/typescript/useNavigationStack.d.ts.map +0 -1
- package/lib/typescript/useNavigationStack.web.d.ts.map +0 -1
- package/lib/typescript/useRouteObserver.d.ts.map +0 -1
- package/lib/typescript/useRouteObserverReactNavigation.d.ts.map +0 -1
- package/lib/typescript/useRouteSitemap.d.ts.map +0 -1
- package/lib/typescript/utils/routeTemplate.d.ts.map +0 -1
- package/lib/typescript/utils/safeReactNavigation.d.ts.map +0 -1
- package/lib/typescript/utils/safeReactNavigation.web.d.ts.map +0 -1
- 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)}}}
|