@buoy-gg/network 7.0.12 → 7.0.13
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/lib/commonjs/index.js +13 -0
- package/lib/commonjs/network/components/NetworkDetailStepper.js +26 -14
- package/lib/commonjs/network/components/NetworkEventDetailView.js +56 -11
- package/lib/commonjs/network/components/NetworkHeaderLive.js +6 -1
- package/lib/commonjs/network/components/NetworkListScreen.js +9 -4
- package/lib/commonjs/network/components/NetworkModal.js +64 -24
- package/lib/commonjs/network/hooks/useNetworkSelection.js +53 -0
- package/lib/commonjs/network/utils/networkSelectionStore.js +193 -0
- package/lib/module/index.js +4 -0
- package/lib/module/network/components/NetworkDetailStepper.js +27 -15
- package/lib/module/network/components/NetworkEventDetailView.js +56 -11
- package/lib/module/network/components/NetworkHeaderLive.js +6 -1
- package/lib/module/network/components/NetworkListScreen.js +9 -4
- package/lib/module/network/components/NetworkModal.js +64 -24
- package/lib/module/network/hooks/useNetworkSelection.js +46 -0
- package/lib/module/network/utils/networkSelectionStore.js +188 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/network/components/NetworkDetailStepper.d.ts +8 -5
- package/lib/typescript/network/components/NetworkDetailStepper.d.ts.map +1 -1
- package/lib/typescript/network/components/NetworkEventDetailView.d.ts +36 -1
- package/lib/typescript/network/components/NetworkEventDetailView.d.ts.map +1 -1
- package/lib/typescript/network/components/NetworkHeaderLive.d.ts +5 -2
- package/lib/typescript/network/components/NetworkHeaderLive.d.ts.map +1 -1
- package/lib/typescript/network/components/NetworkListScreen.d.ts.map +1 -1
- package/lib/typescript/network/components/NetworkModal.d.ts.map +1 -1
- package/lib/typescript/network/hooks/useNetworkSelection.d.ts +26 -0
- package/lib/typescript/network/hooks/useNetworkSelection.d.ts.map +1 -0
- package/lib/typescript/network/utils/networkSelectionStore.d.ts +117 -0
- package/lib/typescript/network/utils/networkSelectionStore.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which request the detail view is showing, and where it sits in the list —
|
|
3
|
+
* the prev/next CURSOR.
|
|
4
|
+
*
|
|
5
|
+
* ## Why this is a store and not `useState` in the modal
|
|
6
|
+
*
|
|
7
|
+
* It used to be `useState` in `NetworkModalInner`. Every tap on Previous/Next
|
|
8
|
+
* therefore dirtied the modal ROOT, which re-rendered `JsModal` (1833 lines,
|
|
9
|
+
* nine useStates, animations/gestures/persistence — and it can never bail out,
|
|
10
|
+
* because its `header` prop is a fresh object literal every render), the whole
|
|
11
|
+
* header, and all five screens. None of them care which request is selected;
|
|
12
|
+
* they only care THAT one is.
|
|
13
|
+
*
|
|
14
|
+
* This is the same argument `NetworkModal`'s own header comment already makes
|
|
15
|
+
* about network events ("with the subscription here, 15 events re-rendered
|
|
16
|
+
* JsModal + every header button 15×"). Stepping is that same class of
|
|
17
|
+
* high-frequency churn, and it was sitting in the same wrong place. Now the
|
|
18
|
+
* root subscribes to `hasSelection` — a boolean that flips twice a session —
|
|
19
|
+
* while the footer, the body and the header's pin actions subscribe to the
|
|
20
|
+
* parts they actually render.
|
|
21
|
+
*
|
|
22
|
+
* ## The three cursors
|
|
23
|
+
*
|
|
24
|
+
* `selectedId` is where the USER is. It moves on the tap, synchronously.
|
|
25
|
+
*
|
|
26
|
+
* `bodyId` is what the detail body is allowed to render, and it deliberately
|
|
27
|
+
* LAGS: drawing a request means handing its payload to the virtualized data
|
|
28
|
+
* viewer to flatten, and that has no business blocking the next tap. It
|
|
29
|
+
* catches up only once the selection has held still for `settleMs`, so a
|
|
30
|
+
* burst of taps renders the request you land on and none of the ones you flew
|
|
31
|
+
* past. (`useDeferredValue` was tried here first and is the wrong tool — it
|
|
32
|
+
* lowers the priority of that work without preventing it, so every settled
|
|
33
|
+
* step still queued a flatten and each one delayed the touch behind it.)
|
|
34
|
+
*
|
|
35
|
+
* `renderedId` is what actually made it to the screen, reported by the detail
|
|
36
|
+
* screen after commit. Nothing in the product reads it; it exists so the
|
|
37
|
+
* benchmark harness can measure "time until request N was really painted"
|
|
38
|
+
* separately from "time until the cursor reached N".
|
|
39
|
+
*/
|
|
40
|
+
import type { NetworkEvent } from "../types";
|
|
41
|
+
export interface NetworkSelectionState {
|
|
42
|
+
/** Navigable order — exactly what the list screen renders. */
|
|
43
|
+
ids: readonly string[];
|
|
44
|
+
/** Cursor position in `ids`, or -1 when the selection isn't in the list. */
|
|
45
|
+
index: number;
|
|
46
|
+
/** Where the user is. Moves synchronously on tap. */
|
|
47
|
+
selectedId: string | null;
|
|
48
|
+
/** What the body may render. Lags `selectedId` by `settleMs`. */
|
|
49
|
+
bodyId: string | null;
|
|
50
|
+
/** What the body actually committed. Benchmark instrumentation only. */
|
|
51
|
+
renderedId: string | null;
|
|
52
|
+
}
|
|
53
|
+
export type NetworkSelectionSubscriber = (state: NetworkSelectionState) => void;
|
|
54
|
+
/**
|
|
55
|
+
* How long the selection must hold still before the body renders it. Short
|
|
56
|
+
* enough that a single step reads as immediate (the footer and header have
|
|
57
|
+
* already moved), long enough that a burst collapses to one render.
|
|
58
|
+
*/
|
|
59
|
+
export declare const DEFAULT_SETTLE_MS = 120;
|
|
60
|
+
declare class NetworkSelectionStore {
|
|
61
|
+
private ids;
|
|
62
|
+
private index;
|
|
63
|
+
private selectedId;
|
|
64
|
+
private bodyId;
|
|
65
|
+
private renderedId;
|
|
66
|
+
private settleMs;
|
|
67
|
+
private settleTimer;
|
|
68
|
+
private subscribers;
|
|
69
|
+
private snapshot;
|
|
70
|
+
private buildSnapshot;
|
|
71
|
+
/**
|
|
72
|
+
* One immutable snapshot per mutation, so subscribers can identity-compare
|
|
73
|
+
* and `useSyncExternalStore` stays happy.
|
|
74
|
+
*/
|
|
75
|
+
private emit;
|
|
76
|
+
getState(): NetworkSelectionState;
|
|
77
|
+
subscribe(subscriber: NetworkSelectionSubscriber): () => void;
|
|
78
|
+
/**
|
|
79
|
+
* Publish the navigable order. Called by the stepper whenever its derived
|
|
80
|
+
* list changes (filter, search, pins, new requests arriving).
|
|
81
|
+
*
|
|
82
|
+
* The cursor is re-anchored BY ID, not by position: the live list is
|
|
83
|
+
* newest-first and new requests are prepended, so holding an index would
|
|
84
|
+
* silently slide the selection onto a different request every time one
|
|
85
|
+
* landed.
|
|
86
|
+
*/
|
|
87
|
+
setIds(ids: readonly string[]): void;
|
|
88
|
+
select(id: string | null): void;
|
|
89
|
+
clear(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Move the cursor. O(1) — the whole reason `index` is stored rather than
|
|
92
|
+
* re-derived with a `findIndex` on every render.
|
|
93
|
+
*
|
|
94
|
+
* Returns the id it landed on, or null if the move was out of bounds (the
|
|
95
|
+
* footer disables its arrows at the ends, but the benchmark driver calls
|
|
96
|
+
* this directly and needs to know when it has run off the end).
|
|
97
|
+
*/
|
|
98
|
+
step(delta: number): string | null;
|
|
99
|
+
/**
|
|
100
|
+
* Opening and closing skip the settle delay: there is no in-flight render to
|
|
101
|
+
* protect on a null↔id transition, and waiting there just reads as a hang.
|
|
102
|
+
* Only id → id steps debounce.
|
|
103
|
+
*/
|
|
104
|
+
private scheduleBody;
|
|
105
|
+
/** Benchmark toggle — `?settle=0` measures the gate's contribution. */
|
|
106
|
+
setSettleMs(ms: number): void;
|
|
107
|
+
getSettleMs(): number;
|
|
108
|
+
/** Reported by the detail screen after commit. Instrumentation only. */
|
|
109
|
+
reportRendered(id: string | null): void;
|
|
110
|
+
/** Test/bench helper — drop all cursor state without touching the events. */
|
|
111
|
+
reset(): void;
|
|
112
|
+
}
|
|
113
|
+
export declare const networkSelectionStore: NetworkSelectionStore;
|
|
114
|
+
/** Convenience for publishing an event list as the navigable order. */
|
|
115
|
+
export declare function toSelectionIds(events: readonly NetworkEvent[]): string[];
|
|
116
|
+
export {};
|
|
117
|
+
//# sourceMappingURL=networkSelectionStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"networkSelect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AI,IAAI;IAIb;;;;;;;OAOG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAYlC;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAiBpB,uEAAuE;IACvE,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAI7B,WAAW,IAAI,MAAM;IAIrB,wEAAwE;IACxE,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAMvC,6EAA6E;IAC7E,KAAK,IAAI,IAAI;CAUd;AAED,eAAO,MAAM,qBAAqB,uBAA8B,CAAC;AAEjE,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,EAAE,CAExE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/network",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.13",
|
|
4
4
|
"description": "In-app network inspector for React Native — requests, responses, timing & errors live, with GraphQL operation parsing. Part of Buoy devtools.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
29
|
+
"@buoy-gg/shared-ui": "^7.0.13"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "*",
|