@agent-scope/core 1.0.1
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/dist/index.cjs +341 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +633 -0
- package/dist/index.d.ts +633 -0
- package/dist/index.js +322 -0
- package/dist/index.js.map +1 -0
- package/package.json +38 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All primitive and structural JavaScript value types that can appear in a
|
|
3
|
+
* serialized value payload.
|
|
4
|
+
*
|
|
5
|
+
* - `'truncated'` — The value was too large / deeply nested and was cut off.
|
|
6
|
+
* - `'circular'` — A circular reference was detected at this position.
|
|
7
|
+
*/
|
|
8
|
+
type SerializedValueType = "string" | "number" | "boolean" | "null" | "undefined" | "object" | "array" | "function" | "symbol" | "bigint" | "date" | "map" | "set" | "circular" | "truncated";
|
|
9
|
+
/**
|
|
10
|
+
* A safely-serialized snapshot of a JavaScript value.
|
|
11
|
+
*
|
|
12
|
+
* Because arbitrary React props and state can reference non-serializable
|
|
13
|
+
* objects (functions, symbols, circular graphs, etc.), every value crossing
|
|
14
|
+
* the wire is wrapped in this envelope.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // A plain string
|
|
18
|
+
* { type: 'string', value: 'hello', preview: '"hello"' }
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // A truncated object
|
|
22
|
+
* { type: 'truncated', preview: '{ a: 1, b: 2, … }' }
|
|
23
|
+
*/
|
|
24
|
+
interface SerializedValue {
|
|
25
|
+
/** Discriminant describing the original JavaScript type. */
|
|
26
|
+
type: SerializedValueType;
|
|
27
|
+
/**
|
|
28
|
+
* The actual value, only present for primitives and simple composites that
|
|
29
|
+
* can be round-tripped through JSON without loss.
|
|
30
|
+
*
|
|
31
|
+
* For types where `value` is absent (`function`, `symbol`, `circular`,
|
|
32
|
+
* `truncated`), rely on `preview` instead.
|
|
33
|
+
*/
|
|
34
|
+
value?: unknown;
|
|
35
|
+
/**
|
|
36
|
+
* A human-readable string representation suitable for display in DevTools.
|
|
37
|
+
*
|
|
38
|
+
* Always present when `value` is absent; optional (but encouraged) for
|
|
39
|
+
* primitive types so that tooling can render without extra formatting.
|
|
40
|
+
*/
|
|
41
|
+
preview?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Describes a single React context consumed by a component.
|
|
46
|
+
*
|
|
47
|
+
* Recorded for every `React.createContext` context that a component reads
|
|
48
|
+
* during render, including both `useContext` and legacy `contextType`.
|
|
49
|
+
*/
|
|
50
|
+
interface ContextConsumption {
|
|
51
|
+
/**
|
|
52
|
+
* The `displayName` set on the context object via
|
|
53
|
+
* `MyContext.displayName = 'MyContext'`.
|
|
54
|
+
*
|
|
55
|
+
* `null` when the context was not given a display name (unfortunately
|
|
56
|
+
* common with anonymous or library-authored contexts).
|
|
57
|
+
*/
|
|
58
|
+
contextName: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* A serialized snapshot of the context value at the time of capture.
|
|
61
|
+
*
|
|
62
|
+
* Reflects the value provided by the nearest `<Context.Provider>` ancestor,
|
|
63
|
+
* or the default value from `React.createContext(defaultValue)` when no
|
|
64
|
+
* provider is present.
|
|
65
|
+
*/
|
|
66
|
+
value: SerializedValue;
|
|
67
|
+
/**
|
|
68
|
+
* Whether this context consumption triggered a re-render of the component
|
|
69
|
+
* during the capture window (i.e. the value changed between the previous
|
|
70
|
+
* and current render).
|
|
71
|
+
*/
|
|
72
|
+
didTriggerRender: boolean;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* All React hook types tracked by the Scope runtime.
|
|
77
|
+
*
|
|
78
|
+
* Built-in hooks are listed by their canonical name. Any hook whose name
|
|
79
|
+
* could not be identified (or a third-party hook not in this list) maps to
|
|
80
|
+
* `'custom'`.
|
|
81
|
+
*/
|
|
82
|
+
type HookType = "useState" | "useReducer" | "useEffect" | "useLayoutEffect" | "useMemo" | "useCallback" | "useRef" | "useContext" | "useId" | "useSyncExternalStore" | "useTransition" | "useDeferredValue" | "custom";
|
|
83
|
+
/**
|
|
84
|
+
* A snapshot of a single hook slot recorded for a component during a render.
|
|
85
|
+
*
|
|
86
|
+
* Hook slots are ordered by call order within the component function body.
|
|
87
|
+
* The combination of component ID + hook index is stable across renders as
|
|
88
|
+
* long as the rules of hooks are respected.
|
|
89
|
+
*/
|
|
90
|
+
interface HookState {
|
|
91
|
+
/**
|
|
92
|
+
* The type of hook. `'custom'` is used for third-party or project-local
|
|
93
|
+
* hooks that wrap one or more built-in hooks.
|
|
94
|
+
*/
|
|
95
|
+
type: HookType;
|
|
96
|
+
/**
|
|
97
|
+
* The inferred name of a custom hook, e.g. `"useTheme"` or `"useLocalStorage"`.
|
|
98
|
+
*
|
|
99
|
+
* `null` for built-in hooks where the name is already conveyed by `type`.
|
|
100
|
+
*/
|
|
101
|
+
name: string | null;
|
|
102
|
+
/**
|
|
103
|
+
* Serialized snapshot of the hook's current value.
|
|
104
|
+
*
|
|
105
|
+
* - For `useState` / `useReducer`: the current state value.
|
|
106
|
+
* - For `useMemo` / `useCallback`: the memoized value / function reference.
|
|
107
|
+
* - For `useRef`: the current `.current` value.
|
|
108
|
+
* - For `useContext`: the current context value (mirrored in `ContextConsumption`).
|
|
109
|
+
* - For effect hooks and others: typically `undefined` (no meaningful value).
|
|
110
|
+
*/
|
|
111
|
+
value: SerializedValue;
|
|
112
|
+
/**
|
|
113
|
+
* Serialized snapshot of the hook's dependency array.
|
|
114
|
+
*
|
|
115
|
+
* Present for `useEffect`, `useLayoutEffect`, `useMemo`, `useCallback`,
|
|
116
|
+
* and `useSyncExternalStore`. `null` for hooks that do not accept deps.
|
|
117
|
+
*/
|
|
118
|
+
deps: SerializedValue[] | null;
|
|
119
|
+
/**
|
|
120
|
+
* Whether the effect hook registered a cleanup function on its last run.
|
|
121
|
+
*
|
|
122
|
+
* `true` — a cleanup was returned.
|
|
123
|
+
* `false` — no cleanup (the effect returned `undefined` or `void`).
|
|
124
|
+
* `null` — not applicable (non-effect hook or cleanup state unknown).
|
|
125
|
+
*/
|
|
126
|
+
hasCleanup: boolean | null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Source location information pointing back to the original source file.
|
|
131
|
+
*
|
|
132
|
+
* Populated from React's `__source` prop (injected by the React JSX transform
|
|
133
|
+
* when `development` mode is enabled) or from babel-plugin-transform-react-jsx-source.
|
|
134
|
+
*/
|
|
135
|
+
interface SourceLocation {
|
|
136
|
+
/** Absolute or relative path to the source file. */
|
|
137
|
+
fileName: string;
|
|
138
|
+
/** 1-based line number of the JSX element. */
|
|
139
|
+
lineNumber: number;
|
|
140
|
+
/** 1-based column number of the JSX element. */
|
|
141
|
+
columnNumber: number;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The React component implementation strategy.
|
|
146
|
+
*
|
|
147
|
+
* - `'function'` — Standard function component.
|
|
148
|
+
* - `'class'` — Class component extending `React.Component` or `React.PureComponent`.
|
|
149
|
+
* - `'forward_ref'` — Component wrapped with `React.forwardRef`.
|
|
150
|
+
* - `'memo'` — Component wrapped with `React.memo` (may also be `forward_ref` inside).
|
|
151
|
+
* - `'host'` — A host (DOM / native) element such as `<div>` or `<input>`.
|
|
152
|
+
*/
|
|
153
|
+
type ComponentType = "function" | "class" | "forward_ref" | "memo" | "host";
|
|
154
|
+
/**
|
|
155
|
+
* A node in the captured React component tree.
|
|
156
|
+
*
|
|
157
|
+
* Each `ComponentNode` corresponds to a single React fiber at the time of
|
|
158
|
+
* capture. The tree is a depth-first snapshot; fiber siblings are siblings
|
|
159
|
+
* in `children`.
|
|
160
|
+
*
|
|
161
|
+
* @remarks
|
|
162
|
+
* Host elements (type `'host'`) still appear in the tree so consumers have a
|
|
163
|
+
* full structural picture, but their `state`, `context`, and `source` fields
|
|
164
|
+
* are typically empty.
|
|
165
|
+
*/
|
|
166
|
+
interface ComponentNode {
|
|
167
|
+
/**
|
|
168
|
+
* The React fiber's internal numeric ID. Stable for the lifetime of a
|
|
169
|
+
* mounted component; reused after unmount.
|
|
170
|
+
*/
|
|
171
|
+
id: number;
|
|
172
|
+
/**
|
|
173
|
+
* The resolved display name of the component.
|
|
174
|
+
*
|
|
175
|
+
* Resolution order:
|
|
176
|
+
* 1. `Component.displayName`
|
|
177
|
+
* 2. `Component.name` (function/class name)
|
|
178
|
+
* 3. The JSX tag name for host elements (e.g. `"div"`)
|
|
179
|
+
* 4. `"Anonymous"` as a last resort
|
|
180
|
+
*/
|
|
181
|
+
name: string;
|
|
182
|
+
/**
|
|
183
|
+
* Implementation strategy of the component.
|
|
184
|
+
* @see {@link ComponentType}
|
|
185
|
+
*/
|
|
186
|
+
type: ComponentType;
|
|
187
|
+
/**
|
|
188
|
+
* Source location of the component definition, derived from babel's
|
|
189
|
+
* `__source` prop or the DevTools fiber source data.
|
|
190
|
+
*
|
|
191
|
+
* `null` for host elements and in production builds where source maps are
|
|
192
|
+
* stripped.
|
|
193
|
+
*/
|
|
194
|
+
source: SourceLocation | null;
|
|
195
|
+
/**
|
|
196
|
+
* Serialized snapshot of the component's props at the time of capture.
|
|
197
|
+
*
|
|
198
|
+
* For host elements this reflects the element's HTML attributes / React
|
|
199
|
+
* props. Children are included as a serialized value (not expanded into
|
|
200
|
+
* sub-nodes; the tree already encodes the hierarchy via `children`).
|
|
201
|
+
*/
|
|
202
|
+
props: SerializedValue;
|
|
203
|
+
/**
|
|
204
|
+
* Ordered list of hook slots recorded for this component.
|
|
205
|
+
*
|
|
206
|
+
* Ordered by hook call-order (i.e. slot 0 = first `use*` call in the
|
|
207
|
+
* component body). Empty for class components and host elements.
|
|
208
|
+
*/
|
|
209
|
+
state: HookState[];
|
|
210
|
+
/**
|
|
211
|
+
* All React contexts consumed by this component during the capture window.
|
|
212
|
+
*/
|
|
213
|
+
context: ContextConsumption[];
|
|
214
|
+
/**
|
|
215
|
+
* Number of times this component rendered during the capture window.
|
|
216
|
+
*
|
|
217
|
+
* A value of `1` is expected for a fresh mount; values > 1 indicate
|
|
218
|
+
* re-renders within the window (useful for surfacing performance issues).
|
|
219
|
+
*/
|
|
220
|
+
renderCount: number;
|
|
221
|
+
/**
|
|
222
|
+
* Total wall-clock time in milliseconds spent in this component's render
|
|
223
|
+
* across all renders recorded in `renderCount`.
|
|
224
|
+
*
|
|
225
|
+
* Measured from the start of the fiber's `beginWork` to the end of
|
|
226
|
+
* `completeWork`. Does not include child render time.
|
|
227
|
+
*/
|
|
228
|
+
renderDuration: number;
|
|
229
|
+
/**
|
|
230
|
+
* Ordered list of child component nodes.
|
|
231
|
+
*
|
|
232
|
+
* Depth-first; an empty array means the component is a leaf node.
|
|
233
|
+
*/
|
|
234
|
+
children: ComponentNode[];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* The console method level of a captured console call.
|
|
239
|
+
*/
|
|
240
|
+
type ConsoleLevel = "log" | "warn" | "error" | "info" | "debug" | "group" | "groupCollapsed" | "table" | "trace";
|
|
241
|
+
/**
|
|
242
|
+
* A single intercepted `console.*` call recorded during the capture window.
|
|
243
|
+
*/
|
|
244
|
+
interface ConsoleEntry {
|
|
245
|
+
/**
|
|
246
|
+
* The console method that was called, e.g. `"warn"`, `"error"`, `"log"`.
|
|
247
|
+
*/
|
|
248
|
+
level: ConsoleLevel;
|
|
249
|
+
/**
|
|
250
|
+
* Serialized snapshot of each argument passed to the console method.
|
|
251
|
+
*
|
|
252
|
+
* Arguments are captured in order. Large or circular values are
|
|
253
|
+
* represented with `SerializedValue.type === 'truncated' | 'circular'`.
|
|
254
|
+
*/
|
|
255
|
+
args: SerializedValue[];
|
|
256
|
+
/**
|
|
257
|
+
* Unix timestamp (milliseconds) when this console call occurred.
|
|
258
|
+
*/
|
|
259
|
+
timestamp: number;
|
|
260
|
+
/**
|
|
261
|
+
* The display name of the nearest React component on the call-stack at the
|
|
262
|
+
* time of the console call, if it could be attributed.
|
|
263
|
+
*
|
|
264
|
+
* `null` when attribution is unavailable (e.g. called outside a render).
|
|
265
|
+
*/
|
|
266
|
+
componentName: string | null;
|
|
267
|
+
/**
|
|
268
|
+
* A condensed single-line text preview built from the raw arguments, useful
|
|
269
|
+
* for quick rendering in lists.
|
|
270
|
+
*/
|
|
271
|
+
preview: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Semantic version of the `PageReport` schema.
|
|
276
|
+
*
|
|
277
|
+
* Consumers should compare this value when reading stored reports to detect
|
|
278
|
+
* schema drift. Follows semver: breaking changes bump the major version.
|
|
279
|
+
*/
|
|
280
|
+
declare const SCHEMA_VERSION: "0.1.0";
|
|
281
|
+
/**
|
|
282
|
+
* All valid React hook types tracked by the Scope runtime.
|
|
283
|
+
*
|
|
284
|
+
* @see {@link HookType}
|
|
285
|
+
*/
|
|
286
|
+
declare const HOOK_TYPES: readonly HookType[];
|
|
287
|
+
/**
|
|
288
|
+
* All valid component implementation strategies.
|
|
289
|
+
*
|
|
290
|
+
* @see {@link ComponentType}
|
|
291
|
+
*/
|
|
292
|
+
declare const COMPONENT_TYPES: readonly ComponentType[];
|
|
293
|
+
/**
|
|
294
|
+
* All valid serialized value types.
|
|
295
|
+
*
|
|
296
|
+
* @see {@link SerializedValueType}
|
|
297
|
+
*/
|
|
298
|
+
declare const SERIALIZED_VALUE_TYPES: readonly SerializedValueType[];
|
|
299
|
+
/**
|
|
300
|
+
* All valid console entry levels.
|
|
301
|
+
*
|
|
302
|
+
* @see {@link ConsoleLevel}
|
|
303
|
+
*/
|
|
304
|
+
declare const CONSOLE_LEVELS: readonly ConsoleLevel[];
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* A JavaScript error captured during the page report window.
|
|
308
|
+
*
|
|
309
|
+
* Covers both unhandled exceptions (`window.onerror` / `unhandledrejection`)
|
|
310
|
+
* and errors thrown inside React error boundaries.
|
|
311
|
+
*/
|
|
312
|
+
interface CapturedError {
|
|
313
|
+
/**
|
|
314
|
+
* The error message string, taken from `Error.prototype.message` when
|
|
315
|
+
* available, or the string-coerced thrown value otherwise.
|
|
316
|
+
*/
|
|
317
|
+
message: string;
|
|
318
|
+
/**
|
|
319
|
+
* The error constructor name, e.g. `"TypeError"`, `"RangeError"`, or the
|
|
320
|
+
* name of a custom subclass. `"Error"` for plain `new Error(…)`.
|
|
321
|
+
*/
|
|
322
|
+
name: string;
|
|
323
|
+
/**
|
|
324
|
+
* The raw stack trace string as provided by the runtime.
|
|
325
|
+
*
|
|
326
|
+
* Source-mapped frames are NOT performed here; consumers that need mapped
|
|
327
|
+
* stacks should apply a source-map transform at analysis time.
|
|
328
|
+
*
|
|
329
|
+
* `null` when the thrown value was not an `Error` instance or the runtime
|
|
330
|
+
* did not provide a stack.
|
|
331
|
+
*/
|
|
332
|
+
stack: string | null;
|
|
333
|
+
/**
|
|
334
|
+
* Source location pointing to where the error was thrown, derived from the
|
|
335
|
+
* top frame of `stack` when parseable. `null` otherwise.
|
|
336
|
+
*/
|
|
337
|
+
source: SourceLocation | null;
|
|
338
|
+
/**
|
|
339
|
+
* The display name of the nearest React component in whose render / effect
|
|
340
|
+
* the error originated, if it could be attributed.
|
|
341
|
+
*/
|
|
342
|
+
componentName: string | null;
|
|
343
|
+
/**
|
|
344
|
+
* Unix timestamp (milliseconds) at the moment the error was observed.
|
|
345
|
+
*/
|
|
346
|
+
timestamp: number;
|
|
347
|
+
/**
|
|
348
|
+
* How the error was captured.
|
|
349
|
+
*
|
|
350
|
+
* - `'boundary'` — caught by a React ErrorBoundary
|
|
351
|
+
* - `'unhandled'` — surfaced via `window.onerror`
|
|
352
|
+
* - `'rejection'` — surfaced via `window.onunhandledrejection`
|
|
353
|
+
* - `'console'` — passed to `console.error` directly
|
|
354
|
+
*/
|
|
355
|
+
capturedBy: "boundary" | "unhandled" | "rejection" | "console";
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Routing information extracted from the active URL at the time the page
|
|
360
|
+
* report was captured.
|
|
361
|
+
*
|
|
362
|
+
* Framework-specific adapters (Next.js, React Router, TanStack Router, etc.)
|
|
363
|
+
* should fill in as many fields as they can resolve; unknown fields are `null`.
|
|
364
|
+
*/
|
|
365
|
+
interface RouteInfo {
|
|
366
|
+
/**
|
|
367
|
+
* The matched route pattern, e.g. `/users/:id` or `/blog/[slug]`.
|
|
368
|
+
*
|
|
369
|
+
* `null` when the framework could not identify a named route for the
|
|
370
|
+
* current URL.
|
|
371
|
+
*/
|
|
372
|
+
pattern: string | null;
|
|
373
|
+
/**
|
|
374
|
+
* Extracted route parameters, e.g. `{ id: '42' }`.
|
|
375
|
+
*
|
|
376
|
+
* `null` when no dynamic segments are present or the adapter cannot
|
|
377
|
+
* resolve them.
|
|
378
|
+
*/
|
|
379
|
+
params: Record<string, string> | null;
|
|
380
|
+
/**
|
|
381
|
+
* Parsed query-string entries at the time of capture.
|
|
382
|
+
*
|
|
383
|
+
* Keys map to the *first* occurrence of each parameter name. Use the raw
|
|
384
|
+
* `url` on the parent `PageReport` for full fidelity.
|
|
385
|
+
*/
|
|
386
|
+
query: Record<string, string>;
|
|
387
|
+
/**
|
|
388
|
+
* The name of the route as defined in the router configuration, if any.
|
|
389
|
+
* Useful for grouping reports by named route in analytics.
|
|
390
|
+
*/
|
|
391
|
+
name: string | null;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Information about a single `<Suspense>` boundary observed in the component
|
|
396
|
+
* tree at capture time.
|
|
397
|
+
*/
|
|
398
|
+
interface SuspenseBoundaryInfo {
|
|
399
|
+
/**
|
|
400
|
+
* Stable numeric identifier for this boundary, corresponding to the React
|
|
401
|
+
* fiber's internal ID.
|
|
402
|
+
*/
|
|
403
|
+
id: number;
|
|
404
|
+
/**
|
|
405
|
+
* Display name of the component that rendered this `<Suspense>` boundary.
|
|
406
|
+
*
|
|
407
|
+
* When the boundary is rendered inline (not wrapped), this will be the name
|
|
408
|
+
* of the nearest named ancestor component.
|
|
409
|
+
*/
|
|
410
|
+
componentName: string;
|
|
411
|
+
/**
|
|
412
|
+
* Whether the boundary was in a suspended (loading) state at the moment the
|
|
413
|
+
* report was captured.
|
|
414
|
+
*/
|
|
415
|
+
isSuspended: boolean;
|
|
416
|
+
/**
|
|
417
|
+
* Total wall-clock time in milliseconds that this boundary spent in the
|
|
418
|
+
* suspended state during the capture window.
|
|
419
|
+
*
|
|
420
|
+
* `null` when the boundary was never triggered or timing data is unavailable.
|
|
421
|
+
*/
|
|
422
|
+
suspendedDuration: number | null;
|
|
423
|
+
/**
|
|
424
|
+
* Name of the fallback component or element rendered while suspended.
|
|
425
|
+
*
|
|
426
|
+
* `null` when the fallback is `null` / not identifiable.
|
|
427
|
+
*/
|
|
428
|
+
fallbackName: string | null;
|
|
429
|
+
/**
|
|
430
|
+
* Source location of the `<Suspense>` element in the original source.
|
|
431
|
+
*/
|
|
432
|
+
source: SourceLocation | null;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* A complete snapshot of a React application page at a single point in time.
|
|
437
|
+
*
|
|
438
|
+
* `PageReport` is the top-level transport and storage unit for Scope. Every
|
|
439
|
+
* other type in `@agent-scope/core` is a node or sub-node of this structure.
|
|
440
|
+
*
|
|
441
|
+
* @example
|
|
442
|
+
* ```ts
|
|
443
|
+
* const report: PageReport = {
|
|
444
|
+
* url: 'https://app.example.com/dashboard',
|
|
445
|
+
* route: { pattern: '/dashboard', params: null, query: {}, name: 'dashboard' },
|
|
446
|
+
* timestamp: Date.now(),
|
|
447
|
+
* capturedIn: 42,
|
|
448
|
+
* tree: rootComponentNode,
|
|
449
|
+
* errors: [],
|
|
450
|
+
* suspenseBoundaries: [],
|
|
451
|
+
* consoleEntries: [],
|
|
452
|
+
* };
|
|
453
|
+
* ```
|
|
454
|
+
*/
|
|
455
|
+
interface PageReport {
|
|
456
|
+
/**
|
|
457
|
+
* The full URL of the page at capture time, including protocol, host, path,
|
|
458
|
+
* and query string. Fragment (`#hash`) is excluded.
|
|
459
|
+
*/
|
|
460
|
+
url: string;
|
|
461
|
+
/**
|
|
462
|
+
* Router-level metadata for the current URL, populated by a
|
|
463
|
+
* framework-specific adapter.
|
|
464
|
+
*
|
|
465
|
+
* `null` when no routing adapter is installed or the current URL could not
|
|
466
|
+
* be matched to a known route.
|
|
467
|
+
*/
|
|
468
|
+
route: RouteInfo | null;
|
|
469
|
+
/**
|
|
470
|
+
* Unix timestamp in milliseconds when the capture was initiated.
|
|
471
|
+
*
|
|
472
|
+
* Use this to correlate reports across users, sessions, or CI runs.
|
|
473
|
+
*/
|
|
474
|
+
timestamp: number;
|
|
475
|
+
/**
|
|
476
|
+
* Total wall-clock time in milliseconds from the start of the capture
|
|
477
|
+
* request to the moment the final `PageReport` object was assembled.
|
|
478
|
+
*
|
|
479
|
+
* Useful for monitoring the overhead of the Scope runtime itself.
|
|
480
|
+
*/
|
|
481
|
+
capturedIn: number;
|
|
482
|
+
/**
|
|
483
|
+
* The root node of the captured React component tree.
|
|
484
|
+
*
|
|
485
|
+
* Typically corresponds to the top-most fiber in the React tree (e.g. the
|
|
486
|
+
* element passed to `ReactDOM.createRoot(...).render(<App />)`).
|
|
487
|
+
*/
|
|
488
|
+
tree: ComponentNode;
|
|
489
|
+
/**
|
|
490
|
+
* All JavaScript errors observed during the capture window.
|
|
491
|
+
*
|
|
492
|
+
* Includes unhandled exceptions, unhandled promise rejections, React error
|
|
493
|
+
* boundary catches, and direct `console.error` calls attributed to an error.
|
|
494
|
+
*/
|
|
495
|
+
errors: CapturedError[];
|
|
496
|
+
/**
|
|
497
|
+
* All `<Suspense>` boundaries found in the component tree, flattened into a
|
|
498
|
+
* list for quick access without tree traversal.
|
|
499
|
+
*/
|
|
500
|
+
suspenseBoundaries: SuspenseBoundaryInfo[];
|
|
501
|
+
/**
|
|
502
|
+
* All `console.*` calls intercepted during the capture window.
|
|
503
|
+
*
|
|
504
|
+
* Entries are ordered by `timestamp` ascending.
|
|
505
|
+
*/
|
|
506
|
+
consoleEntries: ConsoleEntry[];
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Type guard for {@link SourceLocation}.
|
|
511
|
+
*
|
|
512
|
+
* @param value - Any value to test.
|
|
513
|
+
* @returns `true` when `value` conforms to the `SourceLocation` interface.
|
|
514
|
+
*/
|
|
515
|
+
declare function isSourceLocation(value: unknown): value is SourceLocation;
|
|
516
|
+
/**
|
|
517
|
+
* Type guard for {@link SerializedValue}.
|
|
518
|
+
*
|
|
519
|
+
* @param value - Any value to test.
|
|
520
|
+
* @returns `true` when `value` conforms to the `SerializedValue` interface.
|
|
521
|
+
*/
|
|
522
|
+
declare function isSerializedValue(value: unknown): value is SerializedValue;
|
|
523
|
+
/**
|
|
524
|
+
* Type guard for {@link RouteInfo}.
|
|
525
|
+
*
|
|
526
|
+
* @param value - Any value to test.
|
|
527
|
+
* @returns `true` when `value` conforms to the `RouteInfo` interface.
|
|
528
|
+
*/
|
|
529
|
+
declare function isRouteInfo(value: unknown): value is RouteInfo;
|
|
530
|
+
/**
|
|
531
|
+
* Type guard for {@link ContextConsumption}.
|
|
532
|
+
*
|
|
533
|
+
* @param value - Any value to test.
|
|
534
|
+
* @returns `true` when `value` conforms to the `ContextConsumption` interface.
|
|
535
|
+
*/
|
|
536
|
+
declare function isContextConsumption(value: unknown): value is ContextConsumption;
|
|
537
|
+
/**
|
|
538
|
+
* Type guard for {@link HookState}.
|
|
539
|
+
*
|
|
540
|
+
* @param value - Any value to test.
|
|
541
|
+
* @returns `true` when `value` conforms to the `HookState` interface.
|
|
542
|
+
*/
|
|
543
|
+
declare function isHookState(value: unknown): value is HookState;
|
|
544
|
+
/**
|
|
545
|
+
* Type guard for {@link ComponentNode}.
|
|
546
|
+
*
|
|
547
|
+
* Performs a shallow check of the node itself; `children` are verified to be
|
|
548
|
+
* arrays of objects but are **not** recursively validated to keep the guard
|
|
549
|
+
* O(1) per node. Use {@link isComponentNodeDeep} for full tree validation.
|
|
550
|
+
*
|
|
551
|
+
* @param value - Any value to test.
|
|
552
|
+
* @returns `true` when `value` conforms to the `ComponentNode` interface.
|
|
553
|
+
*/
|
|
554
|
+
declare function isComponentNode(value: unknown): value is ComponentNode;
|
|
555
|
+
/**
|
|
556
|
+
* Recursively validates a `ComponentNode` and its entire subtree.
|
|
557
|
+
*
|
|
558
|
+
* @param value - Any value to test.
|
|
559
|
+
* @returns `true` when `value` and all descendant nodes conform to `ComponentNode`.
|
|
560
|
+
*/
|
|
561
|
+
declare function isComponentNodeDeep(value: unknown): value is ComponentNode;
|
|
562
|
+
/**
|
|
563
|
+
* Type guard for {@link CapturedError}.
|
|
564
|
+
*
|
|
565
|
+
* @param value - Any value to test.
|
|
566
|
+
* @returns `true` when `value` conforms to the `CapturedError` interface.
|
|
567
|
+
*/
|
|
568
|
+
declare function isCapturedError(value: unknown): value is CapturedError;
|
|
569
|
+
/**
|
|
570
|
+
* Type guard for {@link SuspenseBoundaryInfo}.
|
|
571
|
+
*
|
|
572
|
+
* @param value - Any value to test.
|
|
573
|
+
* @returns `true` when `value` conforms to the `SuspenseBoundaryInfo` interface.
|
|
574
|
+
*/
|
|
575
|
+
declare function isSuspenseBoundaryInfo(value: unknown): value is SuspenseBoundaryInfo;
|
|
576
|
+
/**
|
|
577
|
+
* Type guard for {@link ConsoleEntry}.
|
|
578
|
+
*
|
|
579
|
+
* @param value - Any value to test.
|
|
580
|
+
* @returns `true` when `value` conforms to the `ConsoleEntry` interface.
|
|
581
|
+
*/
|
|
582
|
+
declare function isConsoleEntry(value: unknown): value is ConsoleEntry;
|
|
583
|
+
/**
|
|
584
|
+
* Type guard for {@link PageReport}.
|
|
585
|
+
*
|
|
586
|
+
* Validates the top-level shape of a `PageReport`. The component tree
|
|
587
|
+
* (`tree`) is shallowly validated via {@link isComponentNode}. Use
|
|
588
|
+
* {@link isPageReportDeep} if you need full recursive tree validation.
|
|
589
|
+
*
|
|
590
|
+
* @param value - Any value to test.
|
|
591
|
+
* @returns `true` when `value` conforms to the `PageReport` interface.
|
|
592
|
+
*/
|
|
593
|
+
declare function isPageReport(value: unknown): value is PageReport;
|
|
594
|
+
/**
|
|
595
|
+
* Like {@link isPageReport} but also recursively validates the entire
|
|
596
|
+
* component tree via {@link isComponentNodeDeep}.
|
|
597
|
+
*
|
|
598
|
+
* @param value - Any value to test.
|
|
599
|
+
* @returns `true` when `value` and its full component tree are valid.
|
|
600
|
+
*/
|
|
601
|
+
declare function isPageReportDeep(value: unknown): value is PageReport;
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* serialize() — Convert any JavaScript value to a SerializedValue snapshot.
|
|
605
|
+
*
|
|
606
|
+
* Features:
|
|
607
|
+
* - Handles all primitives: string, number, boolean, null, undefined
|
|
608
|
+
* - Handles complex types: object, array, function, symbol, bigint
|
|
609
|
+
* - Handles built-ins: Date, Map, Set
|
|
610
|
+
* - Circular reference detection via WeakSet → { type: 'circular' }
|
|
611
|
+
* - Depth limiting → { type: 'truncated' }
|
|
612
|
+
* - Configurable truncation for strings, arrays, and object properties
|
|
613
|
+
*/
|
|
614
|
+
|
|
615
|
+
interface SerializeOptions {
|
|
616
|
+
/** Maximum recursion depth for nested objects/arrays. Default: 5. */
|
|
617
|
+
maxDepth?: number;
|
|
618
|
+
/** Maximum length of serialized strings before truncation. Default: 200. */
|
|
619
|
+
maxStringLength?: number;
|
|
620
|
+
/** Maximum number of array items to serialize. Default: 100. */
|
|
621
|
+
maxArrayLength?: number;
|
|
622
|
+
/** Maximum number of object properties to serialize. Default: 50. */
|
|
623
|
+
maxProperties?: number;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Convert any JavaScript value to a safely-serialized {@link SerializedValue}.
|
|
627
|
+
*
|
|
628
|
+
* @param value - The value to serialize.
|
|
629
|
+
* @param options - Optional tuning parameters.
|
|
630
|
+
*/
|
|
631
|
+
declare function serialize(value: unknown, options?: SerializeOptions): SerializedValue;
|
|
632
|
+
|
|
633
|
+
export { COMPONENT_TYPES, CONSOLE_LEVELS, type CapturedError, type ComponentNode, type ComponentType, type ConsoleEntry, type ConsoleLevel, type ContextConsumption, HOOK_TYPES, type HookState, type HookType, type PageReport, type RouteInfo, SCHEMA_VERSION, SERIALIZED_VALUE_TYPES, type SerializeOptions, type SerializedValue, type SerializedValueType, type SourceLocation, type SuspenseBoundaryInfo, isCapturedError, isComponentNode, isComponentNodeDeep, isConsoleEntry, isContextConsumption, isHookState, isPageReport, isPageReportDeep, isRouteInfo, isSerializedValue, isSourceLocation, isSuspenseBoundaryInfo, serialize };
|