@buoy-gg/route-events 7.0.16 → 7.0.18
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.
|
@@ -3,12 +3,75 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.routeEventsSyncAdapter = void 0;
|
|
6
|
+
exports.routeEventsSyncAdapter = exports.SNAPSHOT_PARAM_INLINE_LIMIT = void 0;
|
|
7
7
|
var _sharedUi = require("@buoy-gg/shared-ui");
|
|
8
8
|
var _routeEventStore = require("../stores/routeEventStore");
|
|
9
9
|
var _navigationStackStore = require("../stores/navigationStackStore");
|
|
10
10
|
var _RouteParser = require("../RouteParser");
|
|
11
11
|
var _expoRouterStore = require("../expoRouterStore");
|
|
12
|
+
/**
|
|
13
|
+
* Navigation params larger than this are NOT streamed in the snapshot.
|
|
14
|
+
* Apps routinely pass whole user objects (or a stringified payload) through
|
|
15
|
+
* `navigate(..., { user })`; 500 of those on every route change exceed the
|
|
16
|
+
* 2MB emit budget and drop the Routes panel. Pathname/segments stay inline.
|
|
17
|
+
*/
|
|
18
|
+
const SNAPSHOT_PARAM_INLINE_LIMIT = exports.SNAPSHOT_PARAM_INLINE_LIMIT = 16 * 1024;
|
|
19
|
+
const PARAMS_ON_DEVICE = Object.freeze({
|
|
20
|
+
__buoyOmitted: "route-params",
|
|
21
|
+
note: "Navigation params stay on the device."
|
|
22
|
+
});
|
|
23
|
+
function jsonLongerThan(value, limit) {
|
|
24
|
+
let bytes = 0;
|
|
25
|
+
const stack = [value];
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
while (stack.length > 0) {
|
|
28
|
+
if (bytes > limit) return true;
|
|
29
|
+
const v = stack.pop();
|
|
30
|
+
if (v === null || v === undefined) bytes += 4;else if (typeof v === "string") bytes += v.length + 2;else if (typeof v === "number") bytes += 8;else if (typeof v === "boolean") bytes += 5;else if (typeof v === "object") {
|
|
31
|
+
if (seen.has(v)) continue;
|
|
32
|
+
seen.add(v);
|
|
33
|
+
if (Array.isArray(v)) {
|
|
34
|
+
bytes += 2 + v.length;
|
|
35
|
+
for (let i = 0; i < v.length; i++) stack.push(v[i]);
|
|
36
|
+
} else {
|
|
37
|
+
bytes += 2;
|
|
38
|
+
for (const k in v) {
|
|
39
|
+
bytes += k.length + 4;
|
|
40
|
+
stack.push(v[k]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} else bytes += 4;
|
|
44
|
+
}
|
|
45
|
+
return bytes > limit;
|
|
46
|
+
}
|
|
47
|
+
function shouldOmitParams(params) {
|
|
48
|
+
if (params == null) return false;
|
|
49
|
+
try {
|
|
50
|
+
JSON.stringify(params);
|
|
51
|
+
} catch {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
return jsonLongerThan(params, SNAPSHOT_PARAM_INLINE_LIMIT);
|
|
55
|
+
}
|
|
56
|
+
function toWireParams(params) {
|
|
57
|
+
if (!shouldOmitParams(params)) return params;
|
|
58
|
+
return PARAMS_ON_DEVICE;
|
|
59
|
+
}
|
|
60
|
+
function toWireEvent(event) {
|
|
61
|
+
if (!shouldOmitParams(event.params)) return event;
|
|
62
|
+
return {
|
|
63
|
+
...event,
|
|
64
|
+
params: toWireParams(event.params)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function toWireStackItem(item) {
|
|
68
|
+
if (!shouldOmitParams(item.params)) return item;
|
|
69
|
+
return {
|
|
70
|
+
...item,
|
|
71
|
+
params: toWireParams(item.params)
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
12
75
|
/**
|
|
13
76
|
* Serializable snapshot of the device's route tree, sent to the dashboard so
|
|
14
77
|
* the Routes tab can render a sitemap (the raw expo-router RouteNode itself is
|
|
@@ -47,9 +110,9 @@ function getSitemapSnapshot() {
|
|
|
47
110
|
const routeEventsSyncAdapter = exports.routeEventsSyncAdapter = {
|
|
48
111
|
version: 3,
|
|
49
112
|
getSnapshot: () => ({
|
|
50
|
-
events: _routeEventStore.routeEventStore.getEvents(),
|
|
113
|
+
events: _routeEventStore.routeEventStore.getEvents().map(toWireEvent),
|
|
51
114
|
sitemap: getSitemapSnapshot(),
|
|
52
|
-
stack: _navigationStackStore.navigationStackStore.getStack()
|
|
115
|
+
stack: _navigationStackStore.navigationStackStore.getStack().map(toWireStackItem)
|
|
53
116
|
}),
|
|
54
117
|
subscribe: onChange => {
|
|
55
118
|
const unsubscribeEvents = _routeEventStore.routeEventStore.subscribeToEvents(onChange);
|
|
@@ -5,6 +5,68 @@ import { routeEventStore } from "../stores/routeEventStore";
|
|
|
5
5
|
import { navigationStackStore } from "../stores/navigationStackStore";
|
|
6
6
|
import { RouteParser } from "../RouteParser";
|
|
7
7
|
import { loadRouteNode, getRouteNodeMetadata } from "../expoRouterStore";
|
|
8
|
+
/**
|
|
9
|
+
* Navigation params larger than this are NOT streamed in the snapshot.
|
|
10
|
+
* Apps routinely pass whole user objects (or a stringified payload) through
|
|
11
|
+
* `navigate(..., { user })`; 500 of those on every route change exceed the
|
|
12
|
+
* 2MB emit budget and drop the Routes panel. Pathname/segments stay inline.
|
|
13
|
+
*/
|
|
14
|
+
export const SNAPSHOT_PARAM_INLINE_LIMIT = 16 * 1024;
|
|
15
|
+
const PARAMS_ON_DEVICE = Object.freeze({
|
|
16
|
+
__buoyOmitted: "route-params",
|
|
17
|
+
note: "Navigation params stay on the device."
|
|
18
|
+
});
|
|
19
|
+
function jsonLongerThan(value, limit) {
|
|
20
|
+
let bytes = 0;
|
|
21
|
+
const stack = [value];
|
|
22
|
+
const seen = new Set();
|
|
23
|
+
while (stack.length > 0) {
|
|
24
|
+
if (bytes > limit) return true;
|
|
25
|
+
const v = stack.pop();
|
|
26
|
+
if (v === null || v === undefined) bytes += 4;else if (typeof v === "string") bytes += v.length + 2;else if (typeof v === "number") bytes += 8;else if (typeof v === "boolean") bytes += 5;else if (typeof v === "object") {
|
|
27
|
+
if (seen.has(v)) continue;
|
|
28
|
+
seen.add(v);
|
|
29
|
+
if (Array.isArray(v)) {
|
|
30
|
+
bytes += 2 + v.length;
|
|
31
|
+
for (let i = 0; i < v.length; i++) stack.push(v[i]);
|
|
32
|
+
} else {
|
|
33
|
+
bytes += 2;
|
|
34
|
+
for (const k in v) {
|
|
35
|
+
bytes += k.length + 4;
|
|
36
|
+
stack.push(v[k]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} else bytes += 4;
|
|
40
|
+
}
|
|
41
|
+
return bytes > limit;
|
|
42
|
+
}
|
|
43
|
+
function shouldOmitParams(params) {
|
|
44
|
+
if (params == null) return false;
|
|
45
|
+
try {
|
|
46
|
+
JSON.stringify(params);
|
|
47
|
+
} catch {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return jsonLongerThan(params, SNAPSHOT_PARAM_INLINE_LIMIT);
|
|
51
|
+
}
|
|
52
|
+
function toWireParams(params) {
|
|
53
|
+
if (!shouldOmitParams(params)) return params;
|
|
54
|
+
return PARAMS_ON_DEVICE;
|
|
55
|
+
}
|
|
56
|
+
function toWireEvent(event) {
|
|
57
|
+
if (!shouldOmitParams(event.params)) return event;
|
|
58
|
+
return {
|
|
59
|
+
...event,
|
|
60
|
+
params: toWireParams(event.params)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function toWireStackItem(item) {
|
|
64
|
+
if (!shouldOmitParams(item.params)) return item;
|
|
65
|
+
return {
|
|
66
|
+
...item,
|
|
67
|
+
params: toWireParams(item.params)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
8
70
|
|
|
9
71
|
/**
|
|
10
72
|
* Serializable snapshot of the device's route tree, sent to the dashboard so
|
|
@@ -44,9 +106,9 @@ function getSitemapSnapshot() {
|
|
|
44
106
|
export const routeEventsSyncAdapter = {
|
|
45
107
|
version: 3,
|
|
46
108
|
getSnapshot: () => ({
|
|
47
|
-
events: routeEventStore.getEvents(),
|
|
109
|
+
events: routeEventStore.getEvents().map(toWireEvent),
|
|
48
110
|
sitemap: getSitemapSnapshot(),
|
|
49
|
-
stack: navigationStackStore.getStack()
|
|
111
|
+
stack: navigationStackStore.getStack().map(toWireStackItem)
|
|
50
112
|
}),
|
|
51
113
|
subscribe: onChange => {
|
|
52
114
|
const unsubscribeEvents = routeEventStore.subscribeToEvents(onChange);
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { type RouteInfo } from "../RouteParser";
|
|
2
2
|
import type { RouteChangeEvent } from "../RouteObserver";
|
|
3
3
|
import type { StackDisplayItem } from "../useNavigationStack";
|
|
4
|
+
/**
|
|
5
|
+
* Navigation params larger than this are NOT streamed in the snapshot.
|
|
6
|
+
* Apps routinely pass whole user objects (or a stringified payload) through
|
|
7
|
+
* `navigate(..., { user })`; 500 of those on every route change exceed the
|
|
8
|
+
* 2MB emit budget and drop the Routes panel. Pathname/segments stay inline.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SNAPSHOT_PARAM_INLINE_LIMIT: number;
|
|
4
11
|
/**
|
|
5
12
|
* Serializable snapshot of the device's route tree, sent to the dashboard so
|
|
6
13
|
* the Routes tab can render a sitemap (the raw expo-router RouteNode itself is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routeEventsSyncAdapter.d.ts","sourceRoot":"","sources":["../../../src/sync/routeEventsSyncAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,6EAA6E;IAC7E,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,mEAAmE;IACnE,MAAM,EAAE,OAAO,GAAG,KAAK,GAAG,IAAI,CAAC;IAC/B,6EAA6E;IAC7E,aAAa,EAAE,MAAM,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BACgB,OAAO;;;uCAcK,OAAO;;;kCAUZ,OAAO;;;;;;;;;;CAuBpC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/route-events",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.18",
|
|
4
4
|
"description": "Navigation devtool for React Native — live stack, full sitemap, jump to any screen. Expo Router & React Navigation. Part of Buoy devtools.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@buoy-gg/floating-tools-core": "^7.0.
|
|
30
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
29
|
+
"@buoy-gg/floating-tools-core": "^7.0.18",
|
|
30
|
+
"@buoy-gg/shared-ui": "^7.0.18"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@buoy-gg/license": "7.0.
|
|
33
|
+
"@buoy-gg/license": "7.0.18",
|
|
34
34
|
"@react-native-async-storage/async-storage": "^2.0.0 || ^3.1.0",
|
|
35
35
|
"@react-navigation/native": "*",
|
|
36
36
|
"expo-router": "*",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/react-native": "^0.73.0",
|
|
53
53
|
"expo-router": "~5.0.7",
|
|
54
54
|
"typescript": "~5.8.3",
|
|
55
|
-
"@buoy-gg/license": "^7.0.
|
|
55
|
+
"@buoy-gg/license": "^7.0.18"
|
|
56
56
|
},
|
|
57
57
|
"react-native-builder-bob": {
|
|
58
58
|
"source": "src",
|