@deviltea/widget-inspector 0.0.0 → 0.0.4

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.
@@ -0,0 +1,428 @@
1
+ import { n as InspectableValue } from "./value-b6hG7snB.mjs";
2
+ import { WidgetConfigJsonSchema } from "@deviltea/widget-core";
3
+ //#region src/protocol.d.ts
4
+ interface InspectorProtocolVersion {
5
+ readonly major: number;
6
+ readonly minor: number;
7
+ }
8
+ declare const INSPECTOR_PROTOCOL_VERSION: Readonly<{
9
+ major: 0;
10
+ minor: 3;
11
+ }>;
12
+ interface InspectorCapabilities {
13
+ readonly methods: readonly InspectorRequestMethod[];
14
+ readonly events: readonly InspectorEventName[];
15
+ }
16
+ interface WidgetRef {
17
+ readonly runtimeId: string;
18
+ readonly nodeId: number;
19
+ }
20
+ interface InspectorPreviewPoint {
21
+ readonly coordinateSpace: 'preview-viewport';
22
+ readonly x: number;
23
+ readonly y: number;
24
+ }
25
+ interface InspectorGeometryRect {
26
+ readonly x: number;
27
+ readonly y: number;
28
+ readonly width: number;
29
+ readonly height: number;
30
+ }
31
+ type InspectorGeometryVisibility = 'visible' | 'clipped' | 'hidden' | 'missing';
32
+ interface InspectorGeometrySnapshot {
33
+ readonly coordinateSpace: 'preview-viewport';
34
+ readonly revision: number;
35
+ readonly visibility: InspectorGeometryVisibility;
36
+ readonly rects: readonly InspectorGeometryRect[];
37
+ }
38
+ interface InspectorSemanticTarget {
39
+ readonly ref: WidgetRef;
40
+ readonly widgetId: string;
41
+ readonly widgetType: string;
42
+ }
43
+ type InspectorHitTestResult = {
44
+ readonly target: null;
45
+ } | {
46
+ readonly target: InspectorSemanticTarget;
47
+ readonly geometry: InspectorGeometrySnapshot;
48
+ };
49
+ interface InspectorMemberRef {
50
+ readonly type: 'state' | 'property';
51
+ readonly name: string;
52
+ }
53
+ interface InspectorConfigMetadata {
54
+ readonly description: string;
55
+ readonly schema: WidgetConfigJsonSchema | null;
56
+ }
57
+ interface InspectorBlueprintCapabilities {
58
+ readonly config: boolean;
59
+ readonly slots: boolean;
60
+ readonly state: boolean;
61
+ readonly properties: boolean;
62
+ readonly methods: boolean;
63
+ /** Added in protocol 0.2. Absence on a 0.1 snapshot means the capability is unavailable to that peer. */
64
+ readonly events?: boolean;
65
+ }
66
+ interface InspectorSlot {
67
+ readonly name: string;
68
+ readonly placement?: 'slot' | 'raw-slot';
69
+ readonly children: readonly number[];
70
+ }
71
+ interface InspectorDependencyReference {
72
+ readonly target: {
73
+ readonly type: 'self';
74
+ } | {
75
+ readonly type: 'root';
76
+ } | {
77
+ readonly type: 'parent';
78
+ readonly optional: boolean;
79
+ } | {
80
+ readonly type: 'widget';
81
+ readonly widgetId: string;
82
+ readonly optional: boolean;
83
+ };
84
+ readonly operation: {
85
+ readonly type: 'state-get';
86
+ readonly key: string;
87
+ } | {
88
+ readonly type: 'state-set';
89
+ readonly key: string;
90
+ } | {
91
+ readonly type: 'property-get';
92
+ readonly name: string;
93
+ } | {
94
+ readonly type: 'method-invoke';
95
+ readonly name: string;
96
+ };
97
+ }
98
+ type InspectorDependency = {
99
+ readonly status: 'resolved';
100
+ readonly path: readonly (string | number)[];
101
+ readonly reference: InspectorDependencyReference;
102
+ readonly target: {
103
+ readonly nodeId: number;
104
+ readonly member: {
105
+ readonly type: 'state' | 'property' | 'method';
106
+ readonly name: string;
107
+ };
108
+ };
109
+ } | {
110
+ readonly status: 'absent';
111
+ readonly path: readonly (string | number)[];
112
+ readonly reference: InspectorDependencyReference;
113
+ } | {
114
+ readonly status: 'invalid';
115
+ readonly path: readonly (string | number)[];
116
+ readonly reference: InspectorDependencyReference;
117
+ readonly targetNodeId?: number;
118
+ };
119
+ interface InspectorStateMember {
120
+ readonly type: 'state';
121
+ readonly name: string;
122
+ }
123
+ interface InspectorPropertyMember {
124
+ readonly type: 'property';
125
+ readonly name: string;
126
+ readonly dependencies: readonly InspectorDependency[];
127
+ }
128
+ interface InspectorEventMember {
129
+ readonly type: 'event';
130
+ readonly name: string;
131
+ readonly description: string;
132
+ }
133
+ interface InspectorMethodMember {
134
+ readonly type: 'method';
135
+ readonly name: string;
136
+ readonly transitivelyWrites: boolean;
137
+ readonly dependencies: readonly InspectorDependency[];
138
+ }
139
+ type InspectorDiagnosticLocation = {
140
+ readonly type: 'source';
141
+ } | {
142
+ readonly type: 'widget';
143
+ readonly nodeId: number;
144
+ } | {
145
+ readonly type: 'slot';
146
+ readonly nodeId: number;
147
+ readonly slot: string;
148
+ } | {
149
+ readonly type: 'slot-child';
150
+ readonly nodeId: number;
151
+ readonly slot: string;
152
+ readonly index: number;
153
+ } | {
154
+ readonly type: 'property';
155
+ readonly nodeId: number;
156
+ readonly name: string;
157
+ } | {
158
+ readonly type: 'method';
159
+ readonly nodeId: number;
160
+ readonly name: string;
161
+ };
162
+ interface InspectorDiagnostic {
163
+ readonly code: string;
164
+ readonly message: string;
165
+ readonly location: InspectorDiagnosticLocation;
166
+ readonly related?: readonly InspectorDiagnosticLocation[];
167
+ readonly path?: readonly (string | number)[];
168
+ readonly reason?: string;
169
+ readonly dependency?: InspectorDependencyReference;
170
+ }
171
+ interface InspectorBlueprintNode {
172
+ readonly nodeId: number;
173
+ readonly resolved: boolean;
174
+ readonly widgetId?: string;
175
+ readonly widgetType?: string;
176
+ readonly capabilities?: InspectorBlueprintCapabilities;
177
+ readonly config?: InspectorConfigMetadata | null;
178
+ readonly sourceSlots: readonly InspectorSlot[];
179
+ readonly semanticSlots?: readonly InspectorSlot[];
180
+ readonly state?: readonly InspectorStateMember[];
181
+ readonly properties?: readonly InspectorPropertyMember[];
182
+ readonly methods?: readonly InspectorMethodMember[];
183
+ readonly events?: readonly InspectorEventMember[];
184
+ readonly diagnostics: readonly InspectorDiagnostic[];
185
+ }
186
+ interface InspectorEvaluationCycle {
187
+ readonly members: readonly {
188
+ readonly nodeId: number;
189
+ readonly member: {
190
+ readonly type: 'property' | 'method';
191
+ readonly name: string;
192
+ };
193
+ }[];
194
+ }
195
+ interface InspectorBlueprintSnapshot {
196
+ readonly runtimeId: string;
197
+ readonly rootNodeId: number;
198
+ readonly nodes: readonly InspectorBlueprintNode[];
199
+ readonly invalidCycles: readonly InspectorEvaluationCycle[];
200
+ }
201
+ interface InspectorRuntimeStateSnapshot {
202
+ readonly type: 'state';
203
+ readonly name: string;
204
+ readonly value: InspectableValue;
205
+ }
206
+ type InspectorRuntimePropertyResult = {
207
+ readonly ok: true;
208
+ readonly value: InspectableValue;
209
+ } | {
210
+ readonly ok: false;
211
+ readonly diagnostics: readonly InspectorRuntimeDiagnostic[];
212
+ };
213
+ interface InspectorRuntimeDiagnosticLocation {
214
+ readonly type: 'state' | 'property' | 'method';
215
+ readonly widgetId: string;
216
+ readonly name: string;
217
+ }
218
+ interface InspectorRuntimeDiagnostic {
219
+ readonly code: string;
220
+ readonly message: string;
221
+ readonly location: InspectorRuntimeDiagnosticLocation;
222
+ readonly path?: readonly (string | number)[];
223
+ readonly reason?: string;
224
+ readonly dependency?: InspectorDependencyReference;
225
+ readonly candidate?: InspectableValue;
226
+ readonly received?: InspectableValue;
227
+ readonly result?: InspectableValue;
228
+ readonly args?: readonly InspectableValue[];
229
+ readonly related?: readonly InspectorRuntimeDiagnosticLocation[];
230
+ readonly cause?: InspectorRuntimeDiagnostic;
231
+ }
232
+ interface InspectorRuntimePropertySnapshot {
233
+ readonly type: 'property';
234
+ readonly name: string;
235
+ readonly snapshot: {
236
+ readonly status: 'never-evaluated';
237
+ } | {
238
+ readonly status: 'completed';
239
+ readonly result: InspectorRuntimePropertyResult;
240
+ };
241
+ }
242
+ type InspectorRuntimeMemberSnapshot = InspectorRuntimeStateSnapshot | InspectorRuntimePropertySnapshot;
243
+ interface InspectorRuntimeWidgetSnapshot {
244
+ readonly ref: WidgetRef;
245
+ readonly widgetId: string;
246
+ readonly widgetType: string;
247
+ readonly members: readonly InspectorRuntimeMemberSnapshot[];
248
+ }
249
+ interface InspectorRuntimeSummary {
250
+ readonly runtimeId: string;
251
+ readonly rootNodeId: number;
252
+ }
253
+ interface InspectorHandshakeResult {
254
+ readonly protocol: InspectorProtocolVersion;
255
+ readonly capabilities: InspectorCapabilities;
256
+ }
257
+ interface InspectorSubscriptionSnapshot {
258
+ readonly subscriptionId: string;
259
+ readonly member: InspectorRuntimeMemberSnapshot;
260
+ }
261
+ interface InspectorRequestMap {
262
+ readonly 'handshake': {
263
+ readonly params: {
264
+ readonly protocol: InspectorProtocolVersion;
265
+ };
266
+ readonly result: InspectorHandshakeResult;
267
+ };
268
+ readonly 'runtime.list': {
269
+ readonly params: Record<string, never>;
270
+ readonly result: {
271
+ readonly runtimes: readonly InspectorRuntimeSummary[];
272
+ };
273
+ };
274
+ readonly 'blueprint.getSnapshot': {
275
+ readonly params: {
276
+ readonly runtimeId: string;
277
+ };
278
+ readonly result: InspectorBlueprintSnapshot;
279
+ };
280
+ readonly 'runtime.getWidgetSnapshot': {
281
+ readonly params: {
282
+ readonly ref: WidgetRef;
283
+ };
284
+ readonly result: InspectorRuntimeWidgetSnapshot;
285
+ };
286
+ readonly 'runtime.subscribeMember': {
287
+ readonly params: {
288
+ readonly ref: WidgetRef;
289
+ readonly member: InspectorMemberRef;
290
+ };
291
+ readonly result: InspectorSubscriptionSnapshot;
292
+ };
293
+ readonly 'runtime.unsubscribeMember': {
294
+ readonly params: {
295
+ readonly subscriptionId: string;
296
+ };
297
+ readonly result: {
298
+ readonly removed: boolean;
299
+ };
300
+ };
301
+ readonly 'runtime.subscribeEvent': {
302
+ readonly params: {
303
+ readonly ref: WidgetRef;
304
+ readonly event: string;
305
+ };
306
+ readonly result: {
307
+ readonly subscriptionId: string;
308
+ readonly event: string;
309
+ };
310
+ };
311
+ readonly 'runtime.unsubscribeEvent': {
312
+ readonly params: {
313
+ readonly subscriptionId: string;
314
+ };
315
+ readonly result: {
316
+ readonly removed: boolean;
317
+ };
318
+ };
319
+ readonly 'inspect.hitTest': {
320
+ readonly params: InspectorPreviewPoint;
321
+ readonly result: InspectorHitTestResult;
322
+ };
323
+ readonly 'geometry.resolve': {
324
+ readonly params: {
325
+ readonly ref: WidgetRef;
326
+ };
327
+ readonly result: InspectorGeometrySnapshot;
328
+ };
329
+ readonly 'inspect.enable': {
330
+ readonly params: Record<string, never>;
331
+ readonly result: {
332
+ readonly enabled: true;
333
+ };
334
+ };
335
+ readonly 'inspect.disable': {
336
+ readonly params: Record<string, never>;
337
+ readonly result: {
338
+ readonly enabled: false;
339
+ };
340
+ };
341
+ readonly 'highlight.show': {
342
+ readonly params: {
343
+ readonly ref: WidgetRef;
344
+ };
345
+ readonly result: {
346
+ readonly highlighted: boolean;
347
+ };
348
+ };
349
+ readonly 'highlight.clear': {
350
+ readonly params: Record<string, never>;
351
+ readonly result: {
352
+ readonly highlighted: false;
353
+ };
354
+ };
355
+ }
356
+ type InspectorRequestMethod = keyof InspectorRequestMap;
357
+ type InspectorRequestParams<Method extends InspectorRequestMethod> = InspectorRequestMap[Method]['params'];
358
+ type InspectorRequestResult<Method extends InspectorRequestMethod> = InspectorRequestMap[Method]['result'];
359
+ interface InspectorProtocolError {
360
+ readonly code: 'invalid-message' | 'unsupported-version' | 'unknown-method' | 'invalid-params' | 'runtime-not-found' | 'widget-not-found' | 'member-not-found' | 'event-not-found' | 'disconnected' | 'subscription-limit' | 'internal-error';
361
+ readonly message: string;
362
+ }
363
+ type InspectorRequestMessage = { [Method in InspectorRequestMethod]: {
364
+ readonly protocol: InspectorProtocolVersion;
365
+ readonly kind: 'request';
366
+ readonly requestId: string;
367
+ readonly method: Method;
368
+ readonly params: InspectorRequestParams<Method>;
369
+ }; }[InspectorRequestMethod];
370
+ type InspectorResponseMessage = {
371
+ readonly protocol: InspectorProtocolVersion;
372
+ readonly kind: 'response';
373
+ readonly requestId: string;
374
+ readonly ok: true;
375
+ readonly result: unknown;
376
+ } | {
377
+ readonly protocol: InspectorProtocolVersion;
378
+ readonly kind: 'response';
379
+ readonly requestId: string;
380
+ readonly ok: false;
381
+ readonly error: InspectorProtocolError;
382
+ };
383
+ interface InspectorEventMap {
384
+ readonly 'runtime.eventOccurred': {
385
+ readonly subscriptionId: string;
386
+ readonly ref: WidgetRef;
387
+ readonly event: string;
388
+ readonly args: readonly InspectableValue[];
389
+ };
390
+ readonly 'geometry.invalidated': {
391
+ readonly revision: number;
392
+ };
393
+ readonly 'runtime.memberChanged': {
394
+ readonly subscriptionId: string;
395
+ readonly ref: WidgetRef;
396
+ readonly member: InspectorRuntimeMemberSnapshot;
397
+ };
398
+ readonly 'inspect.hovered': {
399
+ readonly ref: WidgetRef | null;
400
+ readonly widgetId?: string;
401
+ readonly widgetType?: string;
402
+ };
403
+ readonly 'inspect.selected': {
404
+ readonly ref: WidgetRef;
405
+ readonly widgetId: string;
406
+ readonly widgetType: string;
407
+ };
408
+ readonly 'agent.status': {
409
+ readonly inspectEnabled: boolean;
410
+ };
411
+ }
412
+ type InspectorEventName = keyof InspectorEventMap;
413
+ type InspectorEventMessage = { [Event in InspectorEventName]: {
414
+ readonly protocol: InspectorProtocolVersion;
415
+ readonly kind: 'event';
416
+ readonly event: Event;
417
+ readonly payload: InspectorEventMap[Event];
418
+ }; }[InspectorEventName];
419
+ type InspectorMessage = InspectorRequestMessage | InspectorResponseMessage | InspectorEventMessage;
420
+ declare function isInspectorRequestMethod(value: unknown): value is InspectorRequestMethod;
421
+ declare function isInspectorRequestParams<Method extends InspectorRequestMethod>(method: Method, value: unknown): value is InspectorRequestParams<Method>;
422
+ declare function parseInspectorRequestMessage(value: unknown): InspectorRequestMessage | null;
423
+ declare function parseInspectorResponseMessage(value: unknown): InspectorResponseMessage | null;
424
+ declare function isInspectorRequestResult<Method extends InspectorRequestMethod>(method: Method, value: unknown, protocolMinor?: number): value is InspectorRequestResult<Method>;
425
+ declare function parseInspectorEventMessage(value: unknown): InspectorEventMessage | null;
426
+ declare function isCompatibleProtocolVersion(remote: InspectorProtocolVersion): boolean;
427
+ //#endregion
428
+ export { INSPECTOR_PROTOCOL_VERSION, InspectorBlueprintCapabilities, InspectorBlueprintNode, InspectorBlueprintSnapshot, InspectorCapabilities, InspectorConfigMetadata, InspectorDependency, InspectorDependencyReference, InspectorDiagnostic, InspectorDiagnosticLocation, InspectorEvaluationCycle, InspectorEventMap, InspectorEventMember, InspectorEventMessage, InspectorEventName, InspectorGeometryRect, InspectorGeometrySnapshot, InspectorGeometryVisibility, InspectorHandshakeResult, InspectorHitTestResult, InspectorMemberRef, InspectorMessage, InspectorMethodMember, InspectorPreviewPoint, InspectorPropertyMember, InspectorProtocolError, InspectorProtocolVersion, InspectorRequestMap, InspectorRequestMessage, InspectorRequestMethod, InspectorRequestParams, InspectorRequestResult, InspectorResponseMessage, InspectorRuntimeDiagnostic, InspectorRuntimeDiagnosticLocation, InspectorRuntimeMemberSnapshot, InspectorRuntimePropertyResult, InspectorRuntimePropertySnapshot, InspectorRuntimeStateSnapshot, InspectorRuntimeSummary, InspectorRuntimeWidgetSnapshot, InspectorSemanticTarget, InspectorSlot, InspectorStateMember, InspectorSubscriptionSnapshot, WidgetRef, isCompatibleProtocolVersion, isInspectorRequestMethod, isInspectorRequestParams, isInspectorRequestResult, parseInspectorEventMessage, parseInspectorRequestMessage, parseInspectorResponseMessage };
@@ -0,0 +1,2 @@
1
+ import { a as isInspectorRequestResult, c as parseInspectorResponseMessage, i as isInspectorRequestParams, n as isCompatibleProtocolVersion, o as parseInspectorEventMessage, r as isInspectorRequestMethod, s as parseInspectorRequestMessage, t as INSPECTOR_PROTOCOL_VERSION } from "./protocol-D1gtirOC.mjs";
2
+ export { INSPECTOR_PROTOCOL_VERSION, isCompatibleProtocolVersion, isInspectorRequestMethod, isInspectorRequestParams, isInspectorRequestResult, parseInspectorEventMessage, parseInspectorRequestMessage, parseInspectorResponseMessage };
@@ -0,0 +1,27 @@
1
+ //#region src/transport.d.ts
2
+ interface InspectorTransport {
3
+ send: (message: unknown) => void;
4
+ subscribe: (listener: (message: unknown) => void) => () => void;
5
+ subscribeClose: (listener: () => void) => () => void;
6
+ close: () => void;
7
+ readonly closed: boolean;
8
+ }
9
+ interface InProcessInspectorTransportPair {
10
+ readonly client: InspectorTransport;
11
+ readonly agent: InspectorTransport;
12
+ }
13
+ declare function createInProcessInspectorTransportPair(): InProcessInspectorTransportPair;
14
+ /**
15
+ * Adapts a dedicated MessagePort to the same transport contract used by the in-process A1 bridge.
16
+ *
17
+ * Messages are JSON-cloned before posting even though MessagePort supports the wider structured-clone
18
+ * algorithm. The Inspector protocol intentionally keeps a JSON-safe baseline so iframe and future
19
+ * extension transports cannot observe different wire semantics.
20
+ *
21
+ * The explicit close envelope notifies the peer before the local native port is closed. Browser
22
+ * integration coverage pins delivery order on Chromium; native peer `close` events remain an
23
+ * additional signal where the platform implements them.
24
+ */
25
+ declare function createMessagePortInspectorTransport(port: MessagePort): InspectorTransport;
26
+ //#endregion
27
+ export { InProcessInspectorTransportPair, InspectorTransport, createInProcessInspectorTransportPair, createMessagePortInspectorTransport };
@@ -0,0 +1,138 @@
1
+ //#region src/transport.ts
2
+ const MESSAGE_PORT_INSPECTOR_TRANSPORT_TYPE = "@deviltea/widget-inspector/message-port-inspector-transport";
3
+ function isMessagePortInspectorTransportCloseEnvelope(value) {
4
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
5
+ const candidate = value;
6
+ return candidate.type === MESSAGE_PORT_INSPECTOR_TRANSPORT_TYPE && candidate.version === 1 && candidate.kind === "close";
7
+ }
8
+ function cloneJson(value) {
9
+ return JSON.parse(JSON.stringify(value));
10
+ }
11
+ function createInProcessInspectorTransportPair() {
12
+ const clientListeners = /* @__PURE__ */ new Set();
13
+ const agentListeners = /* @__PURE__ */ new Set();
14
+ const closeListeners = /* @__PURE__ */ new Set();
15
+ let closed = false;
16
+ function endpoint(ownListeners, peerListeners) {
17
+ return {
18
+ get closed() {
19
+ return closed;
20
+ },
21
+ send(message) {
22
+ if (closed) throw new Error("Inspector transport is closed.");
23
+ const cloned = cloneJson(message);
24
+ for (const listener of [...peerListeners]) listener(cloned);
25
+ },
26
+ subscribe(listener) {
27
+ if (closed) return () => {};
28
+ ownListeners.add(listener);
29
+ return () => ownListeners.delete(listener);
30
+ },
31
+ subscribeClose(listener) {
32
+ if (closed) {
33
+ listener();
34
+ return () => {};
35
+ }
36
+ closeListeners.add(listener);
37
+ return () => closeListeners.delete(listener);
38
+ },
39
+ close() {
40
+ if (closed) return;
41
+ closed = true;
42
+ clientListeners.clear();
43
+ agentListeners.clear();
44
+ const listeners = [...closeListeners];
45
+ closeListeners.clear();
46
+ for (const listener of listeners) listener();
47
+ }
48
+ };
49
+ }
50
+ return {
51
+ client: endpoint(clientListeners, agentListeners),
52
+ agent: endpoint(agentListeners, clientListeners)
53
+ };
54
+ }
55
+ /**
56
+ * Adapts a dedicated MessagePort to the same transport contract used by the in-process A1 bridge.
57
+ *
58
+ * Messages are JSON-cloned before posting even though MessagePort supports the wider structured-clone
59
+ * algorithm. The Inspector protocol intentionally keeps a JSON-safe baseline so iframe and future
60
+ * extension transports cannot observe different wire semantics.
61
+ *
62
+ * The explicit close envelope notifies the peer before the local native port is closed. Browser
63
+ * integration coverage pins delivery order on Chromium; native peer `close` events remain an
64
+ * additional signal where the platform implements them.
65
+ */
66
+ function createMessagePortInspectorTransport(port) {
67
+ const messageListeners = /* @__PURE__ */ new Set();
68
+ const closeListeners = /* @__PURE__ */ new Set();
69
+ let closed = false;
70
+ function markClosed() {
71
+ if (closed) return;
72
+ closed = true;
73
+ port.removeEventListener("message", onMessage);
74
+ port.removeEventListener("close", onClose);
75
+ messageListeners.clear();
76
+ const listeners = [...closeListeners];
77
+ closeListeners.clear();
78
+ for (const listener of listeners) listener();
79
+ }
80
+ function onMessage(event) {
81
+ if (closed) return;
82
+ if (isMessagePortInspectorTransportCloseEnvelope(event.data)) {
83
+ try {
84
+ markClosed();
85
+ } finally {
86
+ port.close();
87
+ }
88
+ return;
89
+ }
90
+ for (const listener of [...messageListeners]) listener(event.data);
91
+ }
92
+ function onClose() {
93
+ markClosed();
94
+ }
95
+ port.addEventListener("message", onMessage);
96
+ port.addEventListener("close", onClose);
97
+ port.start();
98
+ return {
99
+ get closed() {
100
+ return closed;
101
+ },
102
+ send(message) {
103
+ if (closed) throw new Error("Inspector transport is closed.");
104
+ port.postMessage(cloneJson(message));
105
+ },
106
+ subscribe(listener) {
107
+ if (closed) return () => {};
108
+ messageListeners.add(listener);
109
+ return () => messageListeners.delete(listener);
110
+ },
111
+ subscribeClose(listener) {
112
+ if (closed) {
113
+ listener();
114
+ return () => {};
115
+ }
116
+ closeListeners.add(listener);
117
+ return () => closeListeners.delete(listener);
118
+ },
119
+ close() {
120
+ if (closed) return;
121
+ const envelope = {
122
+ type: MESSAGE_PORT_INSPECTOR_TRANSPORT_TYPE,
123
+ version: 1,
124
+ kind: "close"
125
+ };
126
+ try {
127
+ port.postMessage(envelope);
128
+ } catch {}
129
+ try {
130
+ markClosed();
131
+ } finally {
132
+ port.close();
133
+ }
134
+ }
135
+ };
136
+ }
137
+ //#endregion
138
+ export { createInProcessInspectorTransportPair, createMessagePortInspectorTransport };
@@ -0,0 +1,53 @@
1
+ //#region src/value.d.ts
2
+ interface InspectableValueEncodingOptions {
3
+ readonly maxDepth?: number;
4
+ readonly maxEntries?: number;
5
+ readonly maxStringLength?: number;
6
+ }
7
+ type InspectableValue = {
8
+ readonly type: 'null';
9
+ } | {
10
+ readonly type: 'undefined';
11
+ } | {
12
+ readonly type: 'boolean';
13
+ readonly value: boolean;
14
+ } | {
15
+ readonly type: 'string';
16
+ readonly value: string;
17
+ readonly truncated: boolean;
18
+ } | {
19
+ readonly type: 'number';
20
+ readonly value: number;
21
+ } | {
22
+ readonly type: 'number-special';
23
+ readonly value: 'nan' | 'positive-infinity' | 'negative-infinity' | 'negative-zero';
24
+ } | {
25
+ readonly type: 'bigint';
26
+ readonly value: string;
27
+ } | {
28
+ readonly type: 'array';
29
+ readonly id: number;
30
+ readonly items: readonly InspectableValue[];
31
+ readonly truncated: boolean;
32
+ } | {
33
+ readonly type: 'object';
34
+ readonly id: number;
35
+ readonly entries: readonly InspectableObjectEntry[];
36
+ readonly truncated: boolean;
37
+ } | {
38
+ readonly type: 'reference';
39
+ readonly ref: number;
40
+ } | {
41
+ readonly type: 'opaque';
42
+ readonly kind: 'function' | 'symbol' | 'dom-node' | 'class-instance' | 'uninspectable' | 'unknown-object';
43
+ } | {
44
+ readonly type: 'truncated';
45
+ readonly reason: 'max-depth';
46
+ };
47
+ interface InspectableObjectEntry {
48
+ readonly key: string;
49
+ readonly value: InspectableValue;
50
+ }
51
+ declare function encodeInspectableValue(value: unknown, options?: InspectableValueEncodingOptions): InspectableValue;
52
+ //#endregion
53
+ export { encodeInspectableValue as i, InspectableValue as n, InspectableValueEncodingOptions as r, InspectableObjectEntry as t };
@@ -0,0 +1,2 @@
1
+ import { i as encodeInspectableValue, n as InspectableValue, r as InspectableValueEncodingOptions, t as InspectableObjectEntry } from "./value-b6hG7snB.mjs";
2
+ export { InspectableObjectEntry, InspectableValue, InspectableValueEncodingOptions, encodeInspectableValue };