@iteraai/react-component-inspector 0.1.0

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.
Files changed (59) hide show
  1. package/README.md +168 -0
  2. package/dist/adapters/base/baseAdapter.d.ts +24 -0
  3. package/dist/adapters/base/createReactInspectorAdapter.d.ts +6 -0
  4. package/dist/adapters/base/index.d.ts +4 -0
  5. package/dist/adapters/base/runtimeConfig.d.ts +4 -0
  6. package/dist/adapters/base/sourceMetadata.d.ts +3 -0
  7. package/dist/adapters/base/types.d.ts +23 -0
  8. package/dist/adapters/cra/craAdapter.d.ts +6 -0
  9. package/dist/adapters/cra/index.d.ts +3 -0
  10. package/dist/adapters/fiber/fiberAdapter.d.ts +9 -0
  11. package/dist/adapters/fiber/highlightTarget.d.ts +2 -0
  12. package/dist/adapters/fiber/index.d.ts +3 -0
  13. package/dist/adapters/fiber/nodeIdentity.d.ts +14 -0
  14. package/dist/adapters/fiber/nodeLookup.d.ts +23 -0
  15. package/dist/adapters/fiber/props.d.ts +2 -0
  16. package/dist/adapters/fiber/rootDiscovery.d.ts +2 -0
  17. package/dist/adapters/fiber/source.d.ts +2 -0
  18. package/dist/adapters/fiber/spike/devtoolsProbe.d.ts +2 -0
  19. package/dist/adapters/fiber/spike/displayName.d.ts +1 -0
  20. package/dist/adapters/fiber/spike/fallbackDecision.d.ts +26 -0
  21. package/dist/adapters/fiber/spike/fiberTraversal.d.ts +12 -0
  22. package/dist/adapters/fiber/spike/types.d.ts +35 -0
  23. package/dist/adapters/fiber/traversal.d.ts +31 -0
  24. package/dist/adapters/fiber/treeMapping.d.ts +8 -0
  25. package/dist/adapters/fiber/types.d.ts +35 -0
  26. package/dist/adapters/next/index.d.ts +3 -0
  27. package/dist/adapters/next/nextAdapter.d.ts +6 -0
  28. package/dist/adapters/vite/index.d.ts +3 -0
  29. package/dist/adapters/vite/viteAdapter.d.ts +6 -0
  30. package/dist/bridgeRuntime.d.ts +37 -0
  31. package/dist/bridgeRuntime.js +7 -0
  32. package/dist/bridgeRuntime.js.map +1 -0
  33. package/dist/chunks/bridgeRuntime-Da4khSK2.js +2278 -0
  34. package/dist/chunks/bridgeRuntime-Da4khSK2.js.map +1 -0
  35. package/dist/chunks/embeddedBootstrap-v-MS8cPB.js +358 -0
  36. package/dist/chunks/embeddedBootstrap-v-MS8cPB.js.map +1 -0
  37. package/dist/devtoolsInlineBackendHook.d.ts +5 -0
  38. package/dist/embeddedBootstrap.d.ts +24 -0
  39. package/dist/embeddedBootstrap.js +7 -0
  40. package/dist/embeddedBootstrap.js.map +1 -0
  41. package/dist/embeddedRuntimeTelemetry.d.ts +34 -0
  42. package/dist/highlighter.d.ts +6 -0
  43. package/dist/index.d.ts +13 -0
  44. package/dist/index.js +49 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/iterationInspector/index.d.ts +2 -0
  47. package/dist/iterationInspector/runtime.d.ts +23 -0
  48. package/dist/iterationInspector/types.d.ts +74 -0
  49. package/dist/iterationInspector.js +708 -0
  50. package/dist/iterationInspector.js.map +1 -0
  51. package/dist/reactDevtoolsInlineBackend.d.ts +7 -0
  52. package/dist/reactTreeAdapter.d.ts +3 -0
  53. package/dist/security/bridgeTelemetry.d.ts +50 -0
  54. package/dist/security/inspectorSecurityEvents.d.ts +18 -0
  55. package/dist/security/messageSizePolicy.d.ts +19 -0
  56. package/dist/security/redactionPolicy.d.ts +2 -0
  57. package/dist/security/tokenValidation.d.ts +15 -0
  58. package/dist/serializer.d.ts +10 -0
  59. package/package.json +77 -0
package/README.md ADDED
@@ -0,0 +1,168 @@
1
+ # `@iteraai/react-component-inspector`
2
+
3
+ Browser bridge and iteration runtime for customer React apps embedded in the hosted Itera editor.
4
+
5
+ This is the current public React implementation of the component inspector SDK. It preserves the existing bridge/runtime behavior from `Web/libs/react-inspector-bridge` and carries it forward under the package name `@iteraai/react-component-inspector`.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @iteraai/react-component-inspector @iteraai/inspector-protocol react react-dom
11
+ ```
12
+
13
+ Peer dependency support:
14
+
15
+ - `react`: `^18.3.0 || ^19.0.0`
16
+ - `react-dom`: `^18.3.0 || ^19.0.0`
17
+
18
+ This package targets browser DOM runtimes. It is meant to run inside the customer app iframe or preview surface that the hosted editor embeds.
19
+
20
+ ## Public Entry Points
21
+
22
+ | Import path | Purpose |
23
+ | ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
24
+ | `@iteraai/react-component-inspector` | Root exports for bootstrap helpers, bridge helpers, adapter/runtime config, telemetry helpers, and token validation. |
25
+ | `@iteraai/react-component-inspector/embeddedBootstrap` | Embedded bootstrap helpers. |
26
+ | `@iteraai/react-component-inspector/bridgeRuntime` | Low-level bridge initialization and teardown. |
27
+ | `@iteraai/react-component-inspector/iterationInspector` | Element-selection runtime and message types for iteration mode. |
28
+
29
+ ## Embedded Bridge Quick Start
30
+
31
+ Use the bootstrap helper when you want the standard embedded bridge behavior:
32
+
33
+ ```ts
34
+ import { bootstrapEmbeddedInspectorBridge } from "@iteraai/react-component-inspector";
35
+ import { bootIterationInspectorRuntime } from "@iteraai/react-component-inspector/iterationInspector";
36
+
37
+ const bridge = bootstrapEmbeddedInspectorBridge({
38
+ enabled: true,
39
+ hostOrigins: ["https://app.iteraapp.com", "https://preview.iteraapp.com"],
40
+ });
41
+
42
+ bootIterationInspectorRuntime();
43
+
44
+ window.addEventListener("beforeunload", () => {
45
+ bridge.destroy();
46
+ });
47
+ ```
48
+
49
+ What `bootstrapEmbeddedInspectorBridge` does by default:
50
+
51
+ - Initializes the bridge in `development` mode
52
+ - Enables the `tree`, `props`, and `highlight` capabilities
53
+ - Uses `runtimeConfig: { adapter: 'fiber' }`
54
+ - Installs the React DevTools inline backend hook unless you opt out
55
+ - Starts optional embedded runtime telemetry when configured
56
+
57
+ For local development defaults, `initDevEmbeddedInspectorBridge()` is a thinner shortcut that defaults to:
58
+
59
+ - `enabled: true`
60
+ - `killSwitchActive: false`
61
+ - `hostOrigins: ['https://app.iteraapp.com']`
62
+ - `runtimeConfig: { adapter: 'fiber' }`
63
+
64
+ ## When To Use The Low-Level Bridge API
65
+
66
+ Use `initInspectorBridge` when you need lower-level control over runtime configuration, security, or adapter wiring.
67
+
68
+ ```ts
69
+ import { initInspectorBridge } from "@iteraai/react-component-inspector/bridgeRuntime";
70
+
71
+ const bridge = initInspectorBridge({
72
+ enabled: true,
73
+ hostOrigins: ["https://app.iteraapp.com"],
74
+ mode: "development",
75
+ runtimeConfig: {
76
+ adapter: "fiber",
77
+ },
78
+ security: {
79
+ enabled: true,
80
+ },
81
+ });
82
+
83
+ window.addEventListener("beforeunload", () => {
84
+ bridge.destroy();
85
+ });
86
+ ```
87
+
88
+ Use the low-level API if you need any of the following:
89
+
90
+ - Secure `HELLO` handshakes with session-token validation
91
+ - A custom `treeAdapter`
92
+ - A custom `adapterFactory`
93
+ - Direct control over bridge handlers or telemetry hooks
94
+
95
+ If you call `initInspectorBridge` without `treeAdapter`, `adapterFactory`, or `runtimeConfig`, the bridge can still handshake, but tree/props/snapshot requests do not have an adapter behind them.
96
+
97
+ ## Origin And Session-Token Requirements
98
+
99
+ Embedded bridge requirements:
100
+
101
+ - `hostOrigins` must contain at least one trusted hosted-editor origin or the bridge stays disabled.
102
+ - Messages from untrusted origins are ignored before protocol parsing.
103
+ - `bootstrapEmbeddedInspectorBridge` accepts `hostOrigins` as either an array or a comma-separated string and trims empty entries.
104
+ - `mode: 'production'`, `enabled: false`, or `killSwitchActive: true` disables the bridge.
105
+
106
+ Secure session-token behavior:
107
+
108
+ - Bridge security is only available through `initInspectorBridge`, not the higher-level bootstrap helper.
109
+ - When `security.enabled` is `true`, the host `HELLO` payload must include `auth.sessionToken`.
110
+ - The default validator rejects missing tokens, blank tokens, and expired `auth.metadata.expiresAt` values.
111
+ - Provide `security.tokenValidator` if you need stronger token validation than the built-in non-empty/not-expired checks.
112
+
113
+ ## Supported React Runtime Targets
114
+
115
+ The exported runtime adapter targets are:
116
+
117
+ - `auto`
118
+ - `vite`
119
+ - `next`
120
+ - `cra`
121
+ - `fiber`
122
+
123
+ Current guidance:
124
+
125
+ - The customer-facing bootstrap helpers use `fiber` today.
126
+ - Prefer `fiber` for parity with the preserved `Web` behavior unless you are intentionally wiring a custom adapter path.
127
+ - `vite`, `next`, and `cra` remain exported adapter targets for direct runtime configuration and future expansion.
128
+
129
+ ## Current Runtime Behavior
130
+
131
+ The current implementation is intentionally documented as-is rather than generalized.
132
+
133
+ - Trusted `HELLO` messages receive `READY`; `PING` receives `PONG`.
134
+ - `REQUEST_TREE` returns a capped tree snapshot. Tree responses can include truncation metadata when the node count exceeds the current limit.
135
+ - `REQUEST_NODE_PROPS` serializes props into JSON-safe values and uses `__iteraType` placeholders for unsupported values.
136
+ - Sensitive prop keys matching names such as `token`, `password`, `secret`, or `authorization` are redacted.
137
+ - `REQUEST_SNAPSHOT` currently returns a placeholder SVG capture plus the DOM HTML snapshot when it fits the response size budget.
138
+ - If the HTML portion would make the snapshot too large, the bridge omits the HTML and sets `htmlTruncated: true`.
139
+ - After the host handshake, the bridge posts `PATH_UPDATED` messages on `itera-preview-path` for the initial location and subsequent history/hash navigation.
140
+
141
+ ## Iteration Inspector Runtime
142
+
143
+ The iteration runtime uses the separate `itera:iteration-inspector` channel.
144
+
145
+ ```ts
146
+ import { bootIterationInspectorRuntime } from "@iteraai/react-component-inspector/iterationInspector";
147
+
148
+ bootIterationInspectorRuntime();
149
+ ```
150
+
151
+ Current runtime behavior:
152
+
153
+ - `bootIterationInspectorRuntime()` returns `null` when the page is not embedded in an iframe unless `allowSelfMessaging: true` is passed.
154
+ - The runtime emits `runtime_ready`, `mode_changed`, `element_selected`, `selection_invalidated`, and optional `debug_log` messages.
155
+ - It listens for `enter_select_mode`, `exit_select_mode`, and `clear_hover` parent messages.
156
+ - The first accepted parent origin is pinned for the lifetime of the started runtime; messages from a different origin are ignored until the runtime stops.
157
+ - `enter_select_mode` supports `single` and `persistent` selection modes.
158
+ - Selected elements can be invalidated on reloads, route changes, or DOM node detachment.
159
+
160
+ ## Runtime Telemetry
161
+
162
+ If you opt in through `runtimeTelemetry`, the embedded runtime can post telemetry messages on `ara:embedded-runtime-telemetry` for:
163
+
164
+ - `console.error`
165
+ - `window.onerror`
166
+ - `unhandledrejection`
167
+
168
+ Those messages are forwarded separately from the main inspector protocol and are intended for host/editor-side debugging and observability.
@@ -0,0 +1,24 @@
1
+ import { TreeNode, TreeSnapshotMeta } from '../../../../inspector-protocol/src/index.ts';
2
+ import { ReactInspectorAdapterContract } from './types';
3
+ export type ReactTreeSnapshot = {
4
+ nodes: TreeNode[];
5
+ rootIds: string[];
6
+ meta?: TreeSnapshotMeta;
7
+ };
8
+ export type CappedReactTreeSnapshot = ReactTreeSnapshot & {
9
+ meta?: TreeSnapshotMeta;
10
+ };
11
+ export declare const MAX_TREE_SNAPSHOT_NODE_COUNT = 200;
12
+ export declare const capTreeSnapshot: (snapshot: ReactTreeSnapshot, maxNodeCount?: number) => CappedReactTreeSnapshot;
13
+ export type BaseAdapterNodeLookup = {
14
+ node: TreeNode;
15
+ nodeById: ReadonlyMap<string, TreeNode>;
16
+ snapshot: ReactTreeSnapshot;
17
+ };
18
+ export type CreateBaseReactInspectorAdapterOptions = {
19
+ getTreeSnapshot: () => ReactTreeSnapshot;
20
+ getNodeProps?: (lookup: BaseAdapterNodeLookup) => unknown | undefined;
21
+ getDomElement?: (lookup: BaseAdapterNodeLookup) => Element | null;
22
+ getReactComponentPathForElement?: (element: Element) => ReadonlyArray<string> | undefined;
23
+ };
24
+ export declare const createBaseReactInspectorAdapter: (options: CreateBaseReactInspectorAdapterOptions) => ReactInspectorAdapterContract;
@@ -0,0 +1,6 @@
1
+ import { ReactInspectorAdapterContract, ReactInspectorRuntimeConfig } from './types';
2
+ import { EmbeddedBridgeTelemetryHooks } from '../../security/bridgeTelemetry';
3
+ export type CreateReactInspectorAdapterOptions = Readonly<{
4
+ telemetry?: EmbeddedBridgeTelemetryHooks;
5
+ }>;
6
+ export declare const createReactInspectorAdapter: (runtimeConfig?: ReactInspectorRuntimeConfig, options?: CreateReactInspectorAdapterOptions) => ReactInspectorAdapterContract;
@@ -0,0 +1,4 @@
1
+ export { capTreeSnapshot, createBaseReactInspectorAdapter, MAX_TREE_SNAPSHOT_NODE_COUNT, type BaseAdapterNodeLookup, type CappedReactTreeSnapshot, type CreateBaseReactInspectorAdapterOptions, type ReactTreeSnapshot, } from './baseAdapter';
2
+ export { createReactInspectorAdapter } from './createReactInspectorAdapter';
3
+ export { defaultReactInspectorAdapterCapabilities, defaultReactInspectorRuntimeConfig, resolveReactInspectorRuntimeConfig, } from './runtimeConfig';
4
+ export { reactInspectorRuntimeAdapterTargets, type ReactInspectorAdapterCapabilities, type ReactInspectorAdapterContract, type ReactInspectorRuntimeAdapterTarget, type ReactInspectorRuntimeConfig, type ResolvedReactInspectorRuntimeConfig, } from './types';
@@ -0,0 +1,4 @@
1
+ import { ReactInspectorAdapterCapabilities, ReactInspectorRuntimeConfig, ResolvedReactInspectorRuntimeConfig } from './types';
2
+ export declare const defaultReactInspectorAdapterCapabilities: ReactInspectorAdapterCapabilities;
3
+ export declare const defaultReactInspectorRuntimeConfig: ResolvedReactInspectorRuntimeConfig;
4
+ export declare const resolveReactInspectorRuntimeConfig: (runtimeConfig?: ReactInspectorRuntimeConfig) => ResolvedReactInspectorRuntimeConfig;
@@ -0,0 +1,3 @@
1
+ import { TreeNodeSource } from '../../../../inspector-protocol/src/index.ts';
2
+ export declare const normalizeTreeNodeSource: (value: unknown) => TreeNodeSource | undefined;
3
+ export declare const getNormalizedTreeNodeSourceFromElement: (element: Element) => TreeNodeSource | undefined;
@@ -0,0 +1,23 @@
1
+ import { ReactTreeSnapshot } from './baseAdapter';
2
+ export declare const reactInspectorRuntimeAdapterTargets: readonly ["auto", "vite", "next", "cra", "fiber"];
3
+ export type ReactInspectorRuntimeAdapterTarget = (typeof reactInspectorRuntimeAdapterTargets)[number];
4
+ export type ReactInspectorAdapterCapabilities = Readonly<{
5
+ tree: boolean;
6
+ props: boolean;
7
+ highlight: boolean;
8
+ }>;
9
+ export type ReactInspectorComponentPath = ReadonlyArray<string>;
10
+ export type ReactInspectorAdapterContract = {
11
+ getTreeSnapshot: () => ReactTreeSnapshot;
12
+ getNodeProps: (nodeId: string) => unknown | undefined;
13
+ getDomElement: (nodeId: string) => Element | null;
14
+ getReactComponentPathForElement?: (element: Element) => ReactInspectorComponentPath | undefined;
15
+ };
16
+ export type ReactInspectorRuntimeConfig = {
17
+ adapter?: ReactInspectorRuntimeAdapterTarget;
18
+ capabilities?: Partial<ReactInspectorAdapterCapabilities>;
19
+ };
20
+ export type ResolvedReactInspectorRuntimeConfig = {
21
+ adapter: ReactInspectorRuntimeAdapterTarget;
22
+ capabilities: ReactInspectorAdapterCapabilities;
23
+ };
@@ -0,0 +1,6 @@
1
+ import { ReactInspectorAdapterContract } from '../base/types';
2
+ type CreateCraReactInspectorAdapterOptions = {
3
+ doc?: Document;
4
+ };
5
+ export declare const createCraReactInspectorAdapter: (options?: CreateCraReactInspectorAdapterOptions) => ReactInspectorAdapterContract;
6
+ export {};
@@ -0,0 +1,3 @@
1
+ import { ReactInspectorRuntimeAdapterTarget } from '../base/types';
2
+ export { createCraReactInspectorAdapter } from './craAdapter';
3
+ export declare const reactInspectorCraAdapterTarget: ReactInspectorRuntimeAdapterTarget;
@@ -0,0 +1,9 @@
1
+ import { ReactInspectorAdapterContract } from '../base/types';
2
+ import { RootDiscoveryResult } from './types';
3
+ export type FiberAdapterSnapshotDiagnostics = Readonly<{
4
+ discoveryResult: RootDiscoveryResult;
5
+ }>;
6
+ export type CreateFiberReactInspectorAdapterOptions = Readonly<{
7
+ onSnapshotDiagnostics?: (diagnostics: FiberAdapterSnapshotDiagnostics) => void;
8
+ }>;
9
+ export declare const createFiberReactInspectorAdapter: (options?: CreateFiberReactInspectorAdapterOptions) => ReactInspectorAdapterContract;
@@ -0,0 +1,2 @@
1
+ import { FiberNodeLookupPayload } from './nodeLookup';
2
+ export declare const resolveFiberHighlightTarget: (lookupPayload: FiberNodeLookupPayload) => Element | null;
@@ -0,0 +1,3 @@
1
+ import { ReactInspectorRuntimeAdapterTarget } from '../base/types';
2
+ export { createFiberReactInspectorAdapter } from './fiberAdapter';
3
+ export declare const reactInspectorFiberAdapterTarget: ReactInspectorRuntimeAdapterTarget;
@@ -0,0 +1,14 @@
1
+ import { FiberTraversalRecord } from './traversal';
2
+ export type FiberNodeIdentityResult = Readonly<{
3
+ nodeIdByRecordKey: ReadonlyMap<string, string>;
4
+ }>;
5
+ export type FiberNodeIdentityAllocator = Readonly<{
6
+ allocateNodeIds: (records: FiberTraversalRecord[]) => FiberNodeIdentityResult;
7
+ }>;
8
+ export declare const toFiberNodeIdentitySignature: (record: FiberTraversalRecord) => {
9
+ readonly rendererId: number;
10
+ readonly rendererRootIndex: number;
11
+ readonly parentKey: string;
12
+ readonly tag: number;
13
+ };
14
+ export declare const createFiberNodeIdentityAllocator: () => FiberNodeIdentityAllocator;
@@ -0,0 +1,23 @@
1
+ import { ReactTreeSnapshot } from '../base/baseAdapter';
2
+ import { FiberTraversalResult } from './traversal';
3
+ export type FiberNodeLookupPayload = Readonly<{
4
+ nodeId: string;
5
+ recordKey: string;
6
+ fiber: unknown;
7
+ tag: number;
8
+ rendererId: number;
9
+ rendererRootIndex: number;
10
+ path: string;
11
+ parentNodeId: string | null;
12
+ childNodeIds: string[];
13
+ }>;
14
+ export type FiberNodeLookup = Readonly<{
15
+ refreshFromSnapshot: (options: {
16
+ traversalResult: FiberTraversalResult;
17
+ nodeIdByRecordKey: ReadonlyMap<string, string>;
18
+ snapshot: ReactTreeSnapshot;
19
+ }) => void;
20
+ resolveByNodeId: (nodeId: string) => FiberNodeLookupPayload | undefined;
21
+ resolveClosestComponentPathForElement: (element: Element) => ReadonlyArray<string> | undefined;
22
+ }>;
23
+ export declare const createFiberNodeLookup: () => FiberNodeLookup;
@@ -0,0 +1,2 @@
1
+ import { FiberNodeLookupPayload } from './nodeLookup';
2
+ export declare const readFiberNodeProps: (lookupPayload: FiberNodeLookupPayload) => unknown | undefined;
@@ -0,0 +1,2 @@
1
+ import { RootDiscoveryResult, RootDiscoveryWindow } from './types';
2
+ export declare const discoverFiberRoots: (windowRef?: RootDiscoveryWindow) => RootDiscoveryResult;
@@ -0,0 +1,2 @@
1
+ import { TreeNodeSource } from '../../../../inspector-protocol/src/index.ts';
2
+ export declare const readFiberNodeSource: (fiberValue: unknown) => TreeNodeSource | undefined;
@@ -0,0 +1,2 @@
1
+ import { DevtoolsProbeResult, DevtoolsProbeWindow } from './types';
2
+ export declare const probeDevtoolsFiberRoots: (windowRef?: DevtoolsProbeWindow) => DevtoolsProbeResult;
@@ -0,0 +1 @@
1
+ export declare const resolveFiberDisplayName: (fiber: unknown) => string;
@@ -0,0 +1,26 @@
1
+ import { DevtoolsProbeResult } from './types';
2
+ export declare const FIBER_FALLBACK_ACTION = "fallback-to-tag-adapter";
3
+ export type FiberUnsupportedState = 'hook-missing' | 'renderer-empty' | 'root-missing' | 'traversal-failed';
4
+ export type FiberFallbackAction = typeof FIBER_FALLBACK_ACTION;
5
+ export type FiberDecisionDiagnostics = Readonly<{
6
+ source: 'fiber-spike';
7
+ probeStatus: DevtoolsProbeResult['status'] | 'unavailable';
8
+ probeReason: string;
9
+ rendererId?: number;
10
+ details?: unknown;
11
+ unsupportedState?: FiberUnsupportedState;
12
+ }>;
13
+ export type FiberFallbackDecision = Readonly<{
14
+ outcome: 'continue-fiber';
15
+ diagnostics: FiberDecisionDiagnostics;
16
+ } | {
17
+ outcome: 'fallback';
18
+ unsupportedState: FiberUnsupportedState;
19
+ action: FiberFallbackAction;
20
+ diagnostics: FiberDecisionDiagnostics;
21
+ }>;
22
+ export type FiberFallbackInput = Readonly<{
23
+ probeResult?: unknown;
24
+ traversalError?: unknown;
25
+ }>;
26
+ export declare const decideFiberFallback: (input?: FiberFallbackInput) => FiberFallbackDecision;
@@ -0,0 +1,12 @@
1
+ import { TreeNode } from '../../../../../inspector-protocol/src/index.ts';
2
+ import { DevtoolsProbeResult, FiberRootRef } from './types';
3
+ export type FiberSpikeTreeNode = TreeNode & Readonly<{
4
+ rendererId: number;
5
+ fiber: unknown;
6
+ }>;
7
+ export type FiberTraversalSnapshot = Readonly<{
8
+ nodes: FiberSpikeTreeNode[];
9
+ rootIds: string[];
10
+ }>;
11
+ export declare const traverseFiberRoots: (roots: FiberRootRef[]) => FiberTraversalSnapshot;
12
+ export declare const traverseFiberRootsFromProbe: (probeResult: DevtoolsProbeResult) => FiberTraversalSnapshot;
@@ -0,0 +1,35 @@
1
+ export type DevtoolsProbeWindow = {
2
+ __REACT_DEVTOOLS_GLOBAL_HOOK__?: unknown;
3
+ };
4
+ export type RendererRef = Readonly<{
5
+ rendererId: number;
6
+ renderer: unknown;
7
+ }>;
8
+ export type FiberRootRef = Readonly<{
9
+ rendererId: number;
10
+ root: unknown;
11
+ }>;
12
+ export type DevtoolsProbeUnsupportedReason = 'hook-missing' | 'hook-malformed' | 'renderers-malformed' | 'fiber-roots-reader-missing' | 'fiber-roots-malformed';
13
+ export type DevtoolsProbeEmptyReason = 'renderer-empty' | 'root-empty';
14
+ export type DevtoolsProbeErrorReason = 'fiber-roots-read-failed' | 'probe-failed';
15
+ export type DevtoolsProbeOkResult = Readonly<{
16
+ status: 'ok';
17
+ renderers: RendererRef[];
18
+ roots: FiberRootRef[];
19
+ }>;
20
+ export type DevtoolsProbeUnsupportedResult = Readonly<{
21
+ status: 'unsupported';
22
+ reason: DevtoolsProbeUnsupportedReason;
23
+ }>;
24
+ export type DevtoolsProbeEmptyResult = Readonly<{
25
+ status: 'empty';
26
+ reason: DevtoolsProbeEmptyReason;
27
+ renderers: RendererRef[];
28
+ }>;
29
+ export type DevtoolsProbeErrorResult = Readonly<{
30
+ status: 'error';
31
+ reason: DevtoolsProbeErrorReason;
32
+ rendererId?: number;
33
+ details?: unknown;
34
+ }>;
35
+ export type DevtoolsProbeResult = DevtoolsProbeOkResult | DevtoolsProbeUnsupportedResult | DevtoolsProbeEmptyResult | DevtoolsProbeErrorResult;
@@ -0,0 +1,31 @@
1
+ import { FiberRootRef, RootDiscoveryResult } from './types';
2
+ export type FiberTraversalBudget = Readonly<{
3
+ maxRecords: number;
4
+ maxTraversalSteps: number;
5
+ }>;
6
+ export type FiberTraversalExhaustedBy = 'record-limit' | 'step-limit';
7
+ export type FiberTraversalMeta = Readonly<{
8
+ truncated: boolean;
9
+ exhaustedBy: FiberTraversalExhaustedBy | null;
10
+ includedRecordCount: number;
11
+ traversalStepCount: number;
12
+ budget: FiberTraversalBudget;
13
+ }>;
14
+ export type FiberTraversalRecord = Readonly<{
15
+ key: string;
16
+ rendererId: number;
17
+ rendererRootIndex: number;
18
+ path: string;
19
+ tag: number;
20
+ fiber: unknown;
21
+ parentKey: string | null;
22
+ childKeys: string[];
23
+ }>;
24
+ export type FiberTraversalResult = Readonly<{
25
+ records: FiberTraversalRecord[];
26
+ rootRecordKeys: string[];
27
+ meta?: FiberTraversalMeta;
28
+ }>;
29
+ export declare const DEFAULT_FIBER_TRAVERSAL_BUDGET: FiberTraversalBudget;
30
+ export declare const traverseFiberRoots: (roots: FiberRootRef[], budget?: Partial<FiberTraversalBudget>) => FiberTraversalResult;
31
+ export declare const traverseDiscoveredFiberRoots: (discoveryResult: RootDiscoveryResult, budget?: Partial<FiberTraversalBudget>) => FiberTraversalResult;
@@ -0,0 +1,8 @@
1
+ import { ReactTreeSnapshot } from '../base/baseAdapter';
2
+ import { FiberTraversalResult } from './traversal';
3
+ type FiberTreeMappingOptions = Readonly<{
4
+ traversalResult: FiberTraversalResult;
5
+ nodeIdByRecordKey: ReadonlyMap<string, string>;
6
+ }>;
7
+ export declare const mapFiberTraversalToTreeSnapshot: (options: FiberTreeMappingOptions) => ReactTreeSnapshot;
8
+ export {};
@@ -0,0 +1,35 @@
1
+ export type RootDiscoveryWindow = {
2
+ __REACT_DEVTOOLS_GLOBAL_HOOK__?: unknown;
3
+ };
4
+ export type RendererRef = Readonly<{
5
+ rendererId: number;
6
+ renderer: unknown;
7
+ }>;
8
+ export type FiberRootRef = Readonly<{
9
+ rendererId: number;
10
+ root: unknown;
11
+ }>;
12
+ export type RootDiscoveryUnsupportedReason = 'hook-missing' | 'hook-malformed' | 'renderers-malformed' | 'fiber-roots-reader-missing' | 'fiber-roots-malformed';
13
+ export type RootDiscoveryEmptyReason = 'renderer-empty' | 'root-empty';
14
+ export type RootDiscoveryErrorReason = 'fiber-roots-read-failed' | 'probe-failed';
15
+ export type RootDiscoveryOkResult = Readonly<{
16
+ status: 'ok';
17
+ renderers: RendererRef[];
18
+ roots: FiberRootRef[];
19
+ }>;
20
+ export type RootDiscoveryUnsupportedResult = Readonly<{
21
+ status: 'unsupported';
22
+ reason: RootDiscoveryUnsupportedReason;
23
+ }>;
24
+ export type RootDiscoveryEmptyResult = Readonly<{
25
+ status: 'empty';
26
+ reason: RootDiscoveryEmptyReason;
27
+ renderers: RendererRef[];
28
+ }>;
29
+ export type RootDiscoveryErrorResult = Readonly<{
30
+ status: 'error';
31
+ reason: RootDiscoveryErrorReason;
32
+ rendererId?: number;
33
+ details?: unknown;
34
+ }>;
35
+ export type RootDiscoveryResult = RootDiscoveryOkResult | RootDiscoveryUnsupportedResult | RootDiscoveryEmptyResult | RootDiscoveryErrorResult;
@@ -0,0 +1,3 @@
1
+ import { ReactInspectorRuntimeAdapterTarget } from '../base/types';
2
+ export { createNextReactInspectorAdapter } from './nextAdapter';
3
+ export declare const reactInspectorNextAdapterTarget: ReactInspectorRuntimeAdapterTarget;
@@ -0,0 +1,6 @@
1
+ import { ReactInspectorAdapterContract } from '../base/types';
2
+ type CreateNextReactInspectorAdapterOptions = {
3
+ doc?: Document;
4
+ };
5
+ export declare const createNextReactInspectorAdapter: (options?: CreateNextReactInspectorAdapterOptions) => ReactInspectorAdapterContract;
6
+ export {};
@@ -0,0 +1,3 @@
1
+ import { ReactInspectorRuntimeAdapterTarget } from '../base/types';
2
+ export { createViteReactInspectorAdapter } from './viteAdapter';
3
+ export declare const reactInspectorViteAdapterTarget: ReactInspectorRuntimeAdapterTarget;
@@ -0,0 +1,6 @@
1
+ import { ReactInspectorAdapterContract } from '../base/types';
2
+ type CreateViteReactInspectorAdapterOptions = {
3
+ doc?: Document;
4
+ };
5
+ export declare const createViteReactInspectorAdapter: (options?: CreateViteReactInspectorAdapterOptions) => ReactInspectorAdapterContract;
6
+ export {};
@@ -0,0 +1,37 @@
1
+ import { HostToEmbeddedMessage } from '../../inspector-protocol/src/index.ts';
2
+ import { ReactInspectorRuntimeConfig } from './adapters/base/types';
3
+ import { ReactTreeAdapter } from './reactTreeAdapter';
4
+ import { EmbeddedBridgeTelemetryHooks } from './security/bridgeTelemetry';
5
+ import { InspectorBridgeSecurityOptions } from './security/tokenValidation';
6
+ type InspectorBridgeMode = 'development' | 'iteration' | 'production';
7
+ export type InspectorBridgeRequestHandlers = {
8
+ onHighlightNode?: (message: HostToEmbeddedMessage) => void;
9
+ onClearHighlight?: (message: HostToEmbeddedMessage) => void;
10
+ };
11
+ export type InitInspectorBridgeOptions = {
12
+ hostOrigins: readonly string[];
13
+ enabled: boolean;
14
+ killSwitchActive?: boolean;
15
+ mode?: InspectorBridgeMode;
16
+ runtimeConfig?: ReactInspectorRuntimeConfig;
17
+ capabilities?: string[];
18
+ treeAdapter?: ReactTreeAdapter;
19
+ adapterFactory?: (runtimeConfig?: ReactInspectorRuntimeConfig) => ReactTreeAdapter | undefined;
20
+ handlers?: InspectorBridgeRequestHandlers;
21
+ security?: InspectorBridgeSecurityOptions;
22
+ telemetry?: EmbeddedBridgeTelemetryHooks;
23
+ };
24
+ type InspectorBridge = {
25
+ destroy: () => void;
26
+ };
27
+ type EmbeddedReactInspectorSelectionApi = {
28
+ getReactComponentPathForElement: (element: Element) => ReadonlyArray<string> | undefined;
29
+ };
30
+ declare global {
31
+ interface Window {
32
+ __ARA_EMBEDDED_REACT_INSPECTOR_SELECTION__?: EmbeddedReactInspectorSelectionApi | undefined;
33
+ }
34
+ }
35
+ export declare const initInspectorBridge: (options: InitInspectorBridgeOptions) => InspectorBridge;
36
+ export declare const destroyInspectorBridge: () => void;
37
+ export {};
@@ -0,0 +1,7 @@
1
+ import "@iteraai/inspector-protocol";
2
+ import { g as o, i as t } from "./chunks/bridgeRuntime-Da4khSK2.js";
3
+ export {
4
+ o as destroyInspectorBridge,
5
+ t as initInspectorBridge
6
+ };
7
+ //# sourceMappingURL=bridgeRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bridgeRuntime.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}