@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,114 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
let cachedStore = null;
|
|
4
|
-
let cachedStoreSource = null;
|
|
5
|
-
let importError = null;
|
|
6
|
-
let hasLoggedMissingStore = false;
|
|
7
|
-
let hasLoggedMissingRouteNode = false;
|
|
8
|
-
let lastRouteNodeTimestamp = null;
|
|
9
|
-
function logOnce(message, error) {
|
|
10
|
-
if (__DEV__) {
|
|
11
|
-
if (error) {
|
|
12
|
-
console.error(`[RouteEvents] ${message}`, error);
|
|
13
|
-
} else {
|
|
14
|
-
console.warn(`[RouteEvents] ${message}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Attempt to require the expo-router store from known locations.
|
|
21
|
-
* Returns null (with a logged error in dev) when expo-router is not available.
|
|
22
|
-
*
|
|
23
|
-
* Note: The store uses getters that read from an internal storeRef.
|
|
24
|
-
* The storeRef gets populated when Expo Router's useStore() hook runs.
|
|
25
|
-
* So we cache the store reference but its property values update over time.
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* Whether the expo-router store can be loaded in this runtime. The store is
|
|
29
|
-
* pulled in via CommonJS `require`, which only exists under Metro/Node. On the
|
|
30
|
-
* web (e.g. the desktop dashboard rendering these RN tools via react-native-web)
|
|
31
|
-
* `require` is undefined, the route tree lives on the device — not here — and
|
|
32
|
-
* there is nothing to load. Callers use this to skip polling/logging.
|
|
33
|
-
*/
|
|
34
|
-
export function isExpoRouterStoreSupported() {
|
|
35
|
-
return typeof require !== "undefined";
|
|
36
|
-
}
|
|
37
|
-
export function getExpoRouterStore() {
|
|
38
|
-
if (cachedStore) {
|
|
39
|
-
return cachedStore;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// No `require` (web): bail quietly rather than throwing ReferenceError and
|
|
43
|
-
// logging a misleading "install expo-router" message on the dashboard.
|
|
44
|
-
if (!isExpoRouterStoreSupported()) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
const loadFromBuild = () => {
|
|
48
|
-
try {
|
|
49
|
-
const module = require("expo-router/build/global-state/router-store");
|
|
50
|
-
if (module?.store) {
|
|
51
|
-
cachedStore = module.store;
|
|
52
|
-
cachedStoreSource = "build";
|
|
53
|
-
importError = null;
|
|
54
|
-
hasLoggedMissingStore = false;
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
} catch (error) {
|
|
58
|
-
importError = error;
|
|
59
|
-
}
|
|
60
|
-
return false;
|
|
61
|
-
};
|
|
62
|
-
const loadFromSrc = () => {
|
|
63
|
-
try {
|
|
64
|
-
const module = require("expo-router/src/global-state/router-store");
|
|
65
|
-
if (module?.store) {
|
|
66
|
-
cachedStore = module.store;
|
|
67
|
-
cachedStoreSource = "src";
|
|
68
|
-
importError = null;
|
|
69
|
-
hasLoggedMissingStore = false;
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
} catch (error) {
|
|
73
|
-
importError = error;
|
|
74
|
-
}
|
|
75
|
-
return false;
|
|
76
|
-
};
|
|
77
|
-
if (loadFromBuild() || loadFromSrc()) {
|
|
78
|
-
return cachedStore;
|
|
79
|
-
}
|
|
80
|
-
if (!hasLoggedMissingStore) {
|
|
81
|
-
logOnce("Unable to load expo-router internals. @buoy-gg/route-events requires expo-router >= 2.0.0. Install expo-router and ensure it is configured before using the Routes tab.", importError ?? undefined);
|
|
82
|
-
hasLoggedMissingStore = true;
|
|
83
|
-
}
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Returns the current RouteNode tree (if available).
|
|
89
|
-
* Logs a helpful warning in development when the tree is missing even though
|
|
90
|
-
* the navigation ref is ready.
|
|
91
|
-
*/
|
|
92
|
-
export function loadRouteNode() {
|
|
93
|
-
const store = getExpoRouterStore();
|
|
94
|
-
if (!store) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
if (store.routeNode) {
|
|
98
|
-
hasLoggedMissingRouteNode = false;
|
|
99
|
-
lastRouteNodeTimestamp = Date.now();
|
|
100
|
-
return store.routeNode;
|
|
101
|
-
}
|
|
102
|
-
const isReady = store.navigationRef?.isReady?.();
|
|
103
|
-
if (__DEV__ && !hasLoggedMissingRouteNode && isReady) {
|
|
104
|
-
logOnce("Expo Router route tree is unavailable. Ensure your app directory is configured and that expo-router is initialized before opening the Route Events devtool.");
|
|
105
|
-
hasLoggedMissingRouteNode = true;
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
export function getRouteNodeMetadata() {
|
|
110
|
-
return {
|
|
111
|
-
source: cachedStoreSource,
|
|
112
|
-
lastLoadedAt: lastRouteNodeTimestamp
|
|
113
|
-
};
|
|
114
|
-
}
|
|
1
|
+
"use strict";let o=null;let l=null;let u=null;let n=false;let s=false;let i=null;function a(e,r){if(__DEV__){if(r){console.error(`[RouteEvents] ${e}`,r)}else{console.warn(`[RouteEvents] ${e}`)}}}export function isExpoRouterStoreSupported(){return typeof require!=="undefined"}export function getExpoRouterStore(){if(o){return o}if(!isExpoRouterStoreSupported()){return null}const e=()=>{try{const t=require("expo-router/build/global-state/router-store");if(t?.store){o=t.store;l="build";u=null;n=false;return true}}catch(t){u=t}return false};const r=()=>{try{const t=require("expo-router/src/global-state/router-store");if(t?.store){o=t.store;l="src";u=null;n=false;return true}}catch(t){u=t}return false};if(e()||r()){return o}if(!n){a("Unable to load expo-router internals. @buoy-gg/route-events requires expo-router >= 2.0.0. Install expo-router and ensure it is configured before using the Routes tab.",u??void 0);n=true}return null}export function loadRouteNode(){const e=getExpoRouterStore();if(!e){return null}if(e.routeNode){s=false;i=Date.now();return e.routeNode}const r=e.navigationRef?.isReady?.();if(__DEV__&&!s&&r){a("Expo Router route tree is unavailable. Ensure your app directory is configured and that expo-router is initialized before opening the Route Events devtool.");s=true}return null}export function getRouteNodeMetadata(){return{source:l,lastLoadedAt:i}}
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import { getBrowserHref } from '@buoy-gg/shared-ui/utils';
|
|
4
|
-
import { getBrowserRoutePaths, getBrowserRoutesUpdatedAt } from './browserRouteRegistry';
|
|
5
|
-
export function isExpoRouterStoreSupported() {
|
|
6
|
-
return typeof window !== 'undefined';
|
|
7
|
-
}
|
|
8
|
-
export function loadRouteNode() {
|
|
9
|
-
if (!isExpoRouterStoreSupported()) return null;
|
|
10
|
-
const paths = new Set([...getBrowserRoutePaths(), new URL(getBrowserHref()).pathname]);
|
|
11
|
-
return {
|
|
12
|
-
route: '',
|
|
13
|
-
type: 'layout',
|
|
14
|
-
contextKey: 'browser',
|
|
15
|
-
children: [...paths].map(path => ({
|
|
16
|
-
route: path.replace(/^\//, '') || 'index',
|
|
17
|
-
type: 'route',
|
|
18
|
-
contextKey: path,
|
|
19
|
-
children: [],
|
|
20
|
-
dynamic: null
|
|
21
|
-
}))
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export function getExpoRouterStore() {
|
|
25
|
-
return {
|
|
26
|
-
routeNode: loadRouteNode(),
|
|
27
|
-
navigationRef: {
|
|
28
|
-
isReady: () => typeof window !== 'undefined'
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
export function getRouteNodeMetadata() {
|
|
33
|
-
return {
|
|
34
|
-
source: null,
|
|
35
|
-
lastLoadedAt: getBrowserRoutesUpdatedAt()
|
|
36
|
-
};
|
|
37
|
-
}
|
|
1
|
+
"use strict";import{getBrowserHref as o}from"@buoy-gg/shared-ui/utils";import{getBrowserRoutePaths as r,getBrowserRoutesUpdatedAt as n}from"./browserRouteRegistry";export function isExpoRouterStoreSupported(){return typeof window!=="undefined"}export function loadRouteNode(){if(!isExpoRouterStoreSupported())return null;const t=new Set([...r(),new URL(o()).pathname]);return{route:"",type:"layout",contextKey:"browser",children:[...t].map(e=>({route:e.replace(/^\//,"")||"index",type:"route",contextKey:e,children:[],dynamic:null}))}}export function getExpoRouterStore(){return{routeNode:loadRouteNode(),navigationRef:{isReady:()=>typeof window!=="undefined"}}}export function getRouteNodeMetadata(){return{source:null,lastLoadedAt:n()}}
|
|
@@ -1,54 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* useRouteEvents Hook
|
|
5
|
-
*
|
|
6
|
-
* React hook for subscribing to route events from the centralized store.
|
|
7
|
-
* Uses self-managing Subscribable pattern - the store automatically
|
|
8
|
-
* subscribes to routeObserver when this hook mounts and unsubscribes
|
|
9
|
-
* when all subscribers unmount.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* function MyComponent() {
|
|
14
|
-
* const { events, clearEvents, isListening } = useRouteEvents();
|
|
15
|
-
*
|
|
16
|
-
* return (
|
|
17
|
-
* <View>
|
|
18
|
-
* {events.map((event) => (
|
|
19
|
-
* <Text key={event.timestamp.toString()}>
|
|
20
|
-
* {event.pathname}
|
|
21
|
-
* </Text>
|
|
22
|
-
* ))}
|
|
23
|
-
* </View>
|
|
24
|
-
* );
|
|
25
|
-
* }
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import { useEventStoreEvents } from "@buoy-gg/shared-ui";
|
|
30
|
-
import { routeEventStore } from "../stores/routeEventStore";
|
|
31
|
-
|
|
32
|
-
// Re-export RouteChangeEvent for convenience
|
|
33
|
-
|
|
34
|
-
export function useRouteEvents(options = {}) {
|
|
35
|
-
const {
|
|
36
|
-
maxEvents = 500,
|
|
37
|
-
enabled = true
|
|
38
|
-
} = options;
|
|
39
|
-
// Subscribing auto-starts the route observer (Subscribable pattern), and
|
|
40
|
-
// the shared hook frame-coalesces navigation bursts into one commit.
|
|
41
|
-
const {
|
|
42
|
-
events,
|
|
43
|
-
clearEvents,
|
|
44
|
-
isActive
|
|
45
|
-
} = useEventStoreEvents(routeEventStore, {
|
|
46
|
-
maxEvents,
|
|
47
|
-
enabled
|
|
48
|
-
});
|
|
49
|
-
return {
|
|
50
|
-
events,
|
|
51
|
-
clearEvents,
|
|
52
|
-
isListening: isActive
|
|
53
|
-
};
|
|
54
|
-
}
|
|
1
|
+
"use strict";import{useEventStoreEvents as i}from"@buoy-gg/shared-ui";import{routeEventStore as u}from"../stores/routeEventStore";export function useRouteEvents(e={}){const{maxEvents:t=500,enabled:n=true}=e;const{events:s,clearEvents:r,isActive:o}=i(u,{maxEvents:t,enabled:n});return{events:s,clearEvents:r,isListening:o}}
|
package/lib/module/index.js
CHANGED
|
@@ -1,70 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @buoy-gg/route-events
|
|
5
|
-
*
|
|
6
|
-
* Route tracking and navigation DevTools for React Native.
|
|
7
|
-
* Supports React Navigation and Expo Router.
|
|
8
|
-
*
|
|
9
|
-
* PUBLIC API - Only these exports are supported for external use.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// =============================================================================
|
|
13
|
-
// PRESET (Primary entry point for users)
|
|
14
|
-
// =============================================================================
|
|
15
|
-
export { routeEventsToolPreset, createRouteEventsTool } from "./preset";
|
|
16
|
-
|
|
17
|
-
// =============================================================================
|
|
18
|
-
// MAIN COMPONENT
|
|
19
|
-
// =============================================================================
|
|
20
|
-
// `RoutesToolView` is the same tool rendered inline (header bar + body + footer)
|
|
21
|
-
// instead of inside a JsModal — for hosts that show tools in a panel.
|
|
22
|
-
export { RouteEventsModalWithTabs, RoutesToolView } from "./components/RouteEventsModalWithTabs";
|
|
23
|
-
// =============================================================================
|
|
24
|
-
// ROUTE TRACKER (Required - place inside your navigation tree)
|
|
25
|
-
// =============================================================================
|
|
26
|
-
export { RouteTracker } from "./RouteTracker";
|
|
27
|
-
export { registerBrowserRoutes } from "./browserRouteRegistry";
|
|
28
|
-
|
|
29
|
-
// =============================================================================
|
|
30
|
-
// COMPONENTS (For custom UI implementations)
|
|
31
|
-
// =============================================================================
|
|
32
|
-
export { RoutesSitemap } from "./components/RoutesSitemap";
|
|
33
|
-
export { NavigationStack } from "./components/NavigationStack";
|
|
34
|
-
export { RouteEventItemCompact } from "./components/RouteEventItemCompact";
|
|
35
|
-
export { RouteEventExpandedContent } from "./components/RouteEventExpandedContent";
|
|
36
|
-
export { RouteEventDetail } from "./components/RouteEventDetail";
|
|
37
|
-
// =============================================================================
|
|
38
|
-
// HOOKS (For consuming route data)
|
|
39
|
-
// =============================================================================
|
|
40
|
-
export { useRouteObserver } from "./useRouteObserver";
|
|
41
|
-
export { useRouteObserverReactNavigation } from "./useRouteObserverReactNavigation";
|
|
42
|
-
export { useRouteEvents } from "./hooks/useRouteEvents";
|
|
43
|
-
export { useRouteSitemap, useRoute, useParentRoutes } from "./useRouteSitemap";
|
|
44
|
-
export { useNavigationStack } from "./useNavigationStack";
|
|
45
|
-
// =============================================================================
|
|
46
|
-
// EXTERNAL SYNC (Adapter for @buoy-gg/external-sync's useExternalSync)
|
|
47
|
-
// =============================================================================
|
|
48
|
-
export { routeEventsSyncAdapter } from "./sync/routeEventsSyncAdapter";
|
|
49
|
-
|
|
50
|
-
// =============================================================================
|
|
51
|
-
// TYPES
|
|
52
|
-
// =============================================================================
|
|
53
|
-
|
|
54
|
-
// =============================================================================
|
|
55
|
-
// UTILITIES (For advanced use cases)
|
|
56
|
-
// =============================================================================
|
|
57
|
-
export { RouteParser } from "./RouteParser";
|
|
58
|
-
export { RouteObserver } from "./RouteObserver";
|
|
59
|
-
|
|
60
|
-
// =============================================================================
|
|
61
|
-
// INTERNAL EXPORTS (For @buoy-gg/* packages only - not part of public API)
|
|
62
|
-
// =============================================================================
|
|
63
|
-
/** @internal - Singleton instance for cross-package communication */
|
|
64
|
-
export { routeObserver } from "./RouteObserver";
|
|
65
|
-
/** @internal - Event store for centralized route event management */
|
|
66
|
-
export { routeEventStore } from "./stores/routeEventStore";
|
|
67
|
-
/** @internal - Navigation-stack store: web/alt-framework hosts without
|
|
68
|
-
* <RouteTracker /> feed it via setStack/setActions so the sync adapter's
|
|
69
|
-
* stack snapshot + remote stack actions work. */
|
|
70
|
-
export { navigationStackStore } from "./stores/navigationStackStore";
|
|
1
|
+
"use strict";export{routeEventsToolPreset,createRouteEventsTool}from"./preset";export{RouteEventsModalWithTabs,RoutesToolView}from"./components/RouteEventsModalWithTabs";export{RouteTracker}from"./RouteTracker";export{registerBrowserRoutes}from"./browserRouteRegistry";export{RoutesSitemap}from"./components/RoutesSitemap";export{NavigationStack}from"./components/NavigationStack";export{RouteEventItemCompact}from"./components/RouteEventItemCompact";export{RouteEventExpandedContent}from"./components/RouteEventExpandedContent";export{RouteEventDetail}from"./components/RouteEventDetail";export{useRouteObserver}from"./useRouteObserver";export{useRouteObserverReactNavigation}from"./useRouteObserverReactNavigation";export{useRouteEvents}from"./hooks/useRouteEvents";export{useRouteSitemap,useRoute,useParentRoutes}from"./useRouteSitemap";export{useNavigationStack}from"./useNavigationStack";export{routeEventsSyncAdapter}from"./sync/routeEventsSyncAdapter";export{RouteParser}from"./RouteParser";export{RouteObserver}from"./RouteObserver";export{routeObserver}from"./RouteObserver";export{routeEventStore}from"./stores/routeEventStore";export{navigationStackStore}from"./stores/navigationStackStore";
|
package/lib/module/preset.js
CHANGED
|
@@ -1,66 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Pre-configured route events tool for FloatingDevTools
|
|
5
|
-
*
|
|
6
|
-
* This preset provides a zero-config way to add route tracking to your dev tools.
|
|
7
|
-
* Just import and spread it into your apps array!
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* import { routeEventsToolPreset } from '@buoy-gg/route-events';
|
|
12
|
-
*
|
|
13
|
-
* const installedApps = [
|
|
14
|
-
* routeEventsToolPreset, // That's it!
|
|
15
|
-
* // ...other tools
|
|
16
|
-
* ];
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { RoutesIcon } from "@buoy-gg/floating-tools-core";
|
|
21
|
-
import { RouteEventsModalWithTabs } from "./components/RouteEventsModalWithTabs";
|
|
22
|
-
import { createToolFactory, defineToolPreset } from "@buoy-gg/shared-ui";
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Pre-configured route events tool for FloatingDevTools.
|
|
26
|
-
* Includes:
|
|
27
|
-
* - Route sitemap browser
|
|
28
|
-
* - Event timeline with filtering
|
|
29
|
-
* - Navigation stack visualization
|
|
30
|
-
* - Automatic route tracking (no setup needed)
|
|
31
|
-
*/
|
|
32
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
33
|
-
export const routeEventsToolPreset = defineToolPreset({
|
|
34
|
-
id: "route-events",
|
|
35
|
-
name: "ROUTES",
|
|
36
|
-
description: "Route tracking & navigation inspector",
|
|
37
|
-
slot: "both",
|
|
38
|
-
icon: ({
|
|
39
|
-
size
|
|
40
|
-
}) => /*#__PURE__*/_jsx(RoutesIcon, {
|
|
41
|
-
size: size
|
|
42
|
-
}),
|
|
43
|
-
component: RouteEventsModalWithTabs,
|
|
44
|
-
props: {
|
|
45
|
-
enableSharedModalDimensions: false
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Create a custom route events tool configuration.
|
|
51
|
-
* Use this if you want to override default settings.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```tsx
|
|
55
|
-
* import { createRouteEventsTool } from '@buoy-gg/route-events';
|
|
56
|
-
*
|
|
57
|
-
* const myRouteTool = createRouteEventsTool({
|
|
58
|
-
* name: "MY ROUTES",
|
|
59
|
-
* color: "#a78bfa",
|
|
60
|
-
* enableSharedModalDimensions: true,
|
|
61
|
-
* });
|
|
62
|
-
* ```
|
|
63
|
-
*/
|
|
64
|
-
export const createRouteEventsTool = createToolFactory(routeEventsToolPreset, options => ({
|
|
65
|
-
enableSharedModalDimensions: options.enableSharedModalDimensions ?? false
|
|
66
|
-
}));
|
|
1
|
+
"use strict";import{RoutesIcon as e}from"@buoy-gg/floating-tools-core";import{RouteEventsModalWithTabs as t}from"./components/RouteEventsModalWithTabs";import{createToolFactory as s,defineToolPreset as n}from"@buoy-gg/shared-ui";import{jsx as r}from"react/jsx-runtime";export const routeEventsToolPreset=n({id:"route-events",name:"ROUTES",description:"Route tracking & navigation inspector",slot:"both",icon:({size:o})=>r(e,{size:o}),component:t,props:{enableSharedModalDimensions:false}});export const createRouteEventsTool=s(routeEventsToolPreset,o=>({enableSharedModalDimensions:o.enableSharedModalDimensions??false}));
|
|
@@ -1,41 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Navigation Stack Store
|
|
5
|
-
*
|
|
6
|
-
* Holds the latest serializable navigation stack plus references to the live
|
|
7
|
-
* navigation action functions. The stack is captured inside the navigation tree
|
|
8
|
-
* by <RouteTracker /> (which runs useNavigationStack), and read by the
|
|
9
|
-
* route-events sync adapter so the dashboard can render the Stack tab and drive
|
|
10
|
-
* navigation on the device remotely.
|
|
11
|
-
*
|
|
12
|
-
* The stack itself (StackDisplayItem[]) is JSON-serializable and synced to the
|
|
13
|
-
* dashboard. The action functions are NOT serialized — they stay on the device
|
|
14
|
-
* and are invoked when the dashboard sends a remote action.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
class NavigationStackStore {
|
|
18
|
-
stack = [];
|
|
19
|
-
actions = null;
|
|
20
|
-
listeners = new Set();
|
|
21
|
-
getStack() {
|
|
22
|
-
return this.stack;
|
|
23
|
-
}
|
|
24
|
-
setStack(stack) {
|
|
25
|
-
this.stack = stack;
|
|
26
|
-
this.listeners.forEach(listener => listener());
|
|
27
|
-
}
|
|
28
|
-
getActions() {
|
|
29
|
-
return this.actions;
|
|
30
|
-
}
|
|
31
|
-
setActions(actions) {
|
|
32
|
-
this.actions = actions;
|
|
33
|
-
}
|
|
34
|
-
subscribe(listener) {
|
|
35
|
-
this.listeners.add(listener);
|
|
36
|
-
return () => {
|
|
37
|
-
this.listeners.delete(listener);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export const navigationStackStore = new NavigationStackStore();
|
|
1
|
+
"use strict";class e{stack=[];actions=null;listeners=new Set;getStack(){return this.stack}setStack(t){this.stack=t;this.listeners.forEach(s=>s())}getActions(){return this.actions}setActions(t){this.actions=t}subscribe(t){this.listeners.add(t);return()=>{this.listeners.delete(t)}}}export const navigationStackStore=new e;
|
|
@@ -1,128 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Route Event Store
|
|
5
|
-
*
|
|
6
|
-
* Centralized store that aggregates route change events from the RouteObserver.
|
|
7
|
-
* Uses BaseEventStore pattern - the store automatically subscribes to routeObserver
|
|
8
|
-
* when the first subscriber joins and unsubscribes when the last subscriber leaves.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* import { routeEventStore } from '@buoy-gg/route-events';
|
|
13
|
-
*
|
|
14
|
-
* // Subscribe to route events - automatically starts listening!
|
|
15
|
-
* const unsubscribe = routeEventStore.subscribeToEvents((events) => {
|
|
16
|
-
* console.log('Route events:', events);
|
|
17
|
-
* });
|
|
18
|
-
*
|
|
19
|
-
* // Later, clean up - automatically stops if no other subscribers
|
|
20
|
-
* unsubscribe();
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
import { BaseEventStore, devToolsStorageKeys, persistentStorage } from "@buoy-gg/shared-ui";
|
|
25
|
-
import { routeObserver } from "../RouteObserver";
|
|
26
|
-
|
|
27
|
-
// Re-export types for convenience
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Listener callback type for route events array
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Listener callback for individual new events
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
class RouteEventStore extends BaseEventStore {
|
|
38
|
-
// Unsubscribe function for routeObserver
|
|
39
|
-
routeObserverUnsubscribe = null;
|
|
40
|
-
// The store's own subscription — see setBootCapture.
|
|
41
|
-
bootCaptureRelease = null;
|
|
42
|
-
bootCaptureHydrated = false;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Capture from app launch, not from the first open of the tool.
|
|
46
|
-
*
|
|
47
|
-
* A BaseEventStore only listens while something subscribes to it, and for
|
|
48
|
-
* routes that was the open modal or a watching desktop — so every
|
|
49
|
-
* navigation before the tool was first opened was simply never recorded,
|
|
50
|
-
* and the Events tab opened on "No route events yet" after a session of
|
|
51
|
-
* navigating. (It looked fine on any machine with Buoy Desktop running,
|
|
52
|
-
* because the desktop's watch subscribed at boot.) Network and storage both
|
|
53
|
-
* capture from launch; this holds a subscription of the store's own so
|
|
54
|
-
* routes does too.
|
|
55
|
-
*
|
|
56
|
-
* The hold follows the tool's persisted monitoring switch: the modal calls
|
|
57
|
-
* this on every toggle, and `hydrateBootCapture` reads the persisted value
|
|
58
|
-
* at boot so a paused tool stays paused across a relaunch.
|
|
59
|
-
*/
|
|
60
|
-
setBootCapture(enabled) {
|
|
61
|
-
if (enabled && !this.bootCaptureRelease) {
|
|
62
|
-
this.bootCaptureRelease = this.subscribeToEvents(() => {});
|
|
63
|
-
} else if (!enabled && this.bootCaptureRelease) {
|
|
64
|
-
this.bootCaptureRelease();
|
|
65
|
-
this.bootCaptureRelease = null;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** Arm boot capture from the persisted monitoring switch (default on). */
|
|
70
|
-
hydrateBootCapture() {
|
|
71
|
-
if (this.bootCaptureHydrated) return;
|
|
72
|
-
this.bootCaptureHydrated = true;
|
|
73
|
-
void persistentStorage.getItem(devToolsStorageKeys.routeEvents.isMonitoring()).then(raw => {
|
|
74
|
-
// The modal may already have decided while the read was in flight.
|
|
75
|
-
if (this.bootCaptureRelease) return;
|
|
76
|
-
this.setBootCapture(raw !== "false");
|
|
77
|
-
}).catch(() => this.setBootCapture(true));
|
|
78
|
-
}
|
|
79
|
-
constructor() {
|
|
80
|
-
super({
|
|
81
|
-
storeName: "route-events",
|
|
82
|
-
maxEvents: 500
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Start listening to route changes from routeObserver
|
|
88
|
-
*/
|
|
89
|
-
startCapturing() {
|
|
90
|
-
if (!this.routeObserverUnsubscribe) {
|
|
91
|
-
this.routeObserverUnsubscribe = routeObserver.addListener(event => {
|
|
92
|
-
this.addEvent(event);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Stop listening to route changes
|
|
99
|
-
*/
|
|
100
|
-
stopCapturing() {
|
|
101
|
-
if (this.routeObserverUnsubscribe) {
|
|
102
|
-
this.routeObserverUnsubscribe();
|
|
103
|
-
this.routeObserverUnsubscribe = null;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Check if currently listening (has subscribers)
|
|
109
|
-
*/
|
|
110
|
-
isCapturing() {
|
|
111
|
-
return this.routeObserverUnsubscribe !== null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Alias for backwards compatibility
|
|
115
|
-
isListening() {
|
|
116
|
-
return this.isCapturing();
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Singleton instance
|
|
121
|
-
export const routeEventStore = new RouteEventStore();
|
|
122
|
-
|
|
123
|
-
// Convenience exports
|
|
124
|
-
export const subscribeToRouteEvents = listener => routeEventStore.subscribeToEvents(listener);
|
|
125
|
-
export const onRouteEvent = callback => routeEventStore.onEvent(callback);
|
|
126
|
-
export const getRouteEvents = () => routeEventStore.getEvents();
|
|
127
|
-
export const clearRouteEvents = () => routeEventStore.clearEvents();
|
|
128
|
-
export const isRouteListening = () => routeEventStore.isListening();
|
|
1
|
+
"use strict";import{BaseEventStore as s,devToolsStorageKeys as r,persistentStorage as o}from"@buoy-gg/shared-ui";import{routeObserver as i}from"../RouteObserver";class u extends s{routeObserverUnsubscribe=null;bootCaptureRelease=null;bootCaptureHydrated=false;setBootCapture(e){if(e&&!this.bootCaptureRelease){this.bootCaptureRelease=this.subscribeToEvents(()=>{})}else if(!e&&this.bootCaptureRelease){this.bootCaptureRelease();this.bootCaptureRelease=null}}hydrateBootCapture(){if(this.bootCaptureHydrated)return;this.bootCaptureHydrated=true;void o.getItem(r.routeEvents.isMonitoring()).then(e=>{if(this.bootCaptureRelease)return;this.setBootCapture(e!=="false")}).catch(()=>this.setBootCapture(true))}constructor(){super({storeName:"route-events",maxEvents:500})}startCapturing(){if(!this.routeObserverUnsubscribe){this.routeObserverUnsubscribe=i.addListener(e=>{this.addEvent(e)})}}stopCapturing(){if(this.routeObserverUnsubscribe){this.routeObserverUnsubscribe();this.routeObserverUnsubscribe=null}}isCapturing(){return this.routeObserverUnsubscribe!==null}isListening(){return this.isCapturing()}}export const routeEventStore=new u;export const subscribeToRouteEvents=t=>routeEventStore.subscribeToEvents(t);export const onRouteEvent=t=>routeEventStore.onEvent(t);export const getRouteEvents=()=>routeEventStore.getEvents();export const clearRouteEvents=()=>routeEventStore.clearEvents();export const isRouteListening=()=>routeEventStore.isListening();
|