@statelyai/sdk 0.33.0 → 0.34.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.
Files changed (40) hide show
  1. package/README.md +21 -4
  2. package/dist/assetStorage.d.mts +1 -1
  3. package/dist/auth.d.mts +1 -1
  4. package/dist/bin.mjs +1 -0
  5. package/dist/{dist-wbhkeGh6.mjs → dist-NJFkDQjK.mjs} +170 -77
  6. package/dist/{editorHostSession-DfmHzpls.mjs → editorHostSession-Bj5YcijC.mjs} +2 -2
  7. package/dist/{editorHostSession-C6yxOmSO.d.mts → editorHostSession-DBLSyHJs.d.mts} +2 -2
  8. package/dist/editorHostSession.d.mts +1 -1
  9. package/dist/editorHostSession.mjs +3 -3
  10. package/dist/embed.d.mts +4 -4
  11. package/dist/embed.mjs +5 -4
  12. package/dist/{graph-CR_g-mOq.d.mts → graph-Ciocekxl.d.mts} +1 -1
  13. package/dist/graph.d.mts +1 -1
  14. package/dist/{index-DlOZxzrW.d.mts → index-DZivqh0u.d.mts} +21 -4
  15. package/dist/index.d.mts +8 -8
  16. package/dist/index.mjs +9 -9
  17. package/dist/{inspect-CunxIl8H.d.mts → inspect-BbvfH0Q1.d.mts} +18 -9
  18. package/dist/{inspect-C-eEfU3T.mjs → inspect-DW30GMge.mjs} +45 -7
  19. package/dist/inspect.d.mts +3 -3
  20. package/dist/inspect.mjs +3 -2
  21. package/dist/node-relay.mjs +1 -1
  22. package/dist/patchTypes.d.mts +1 -1
  23. package/dist/{protocol-CQL9Ubt9.d.mts → protocol-B7q2lWj_.d.mts} +48 -76
  24. package/dist/protocol-BsBGRISR.mjs +116 -0
  25. package/dist/protocol.d.mts +2 -2
  26. package/dist/protocol.mjs +2 -86
  27. package/dist/relay.d.mts +1 -1
  28. package/dist/relay.mjs +23 -3
  29. package/dist/{studio-rSI54Ese.mjs → studio-BZP6DaIO.mjs} +50 -15
  30. package/dist/{studio-DV5IIGhV.d.mts → studio-CKdEPGKY.d.mts} +56 -17
  31. package/dist/studio.d.mts +1 -1
  32. package/dist/studio.mjs +1 -1
  33. package/dist/sync.d.mts +2 -2
  34. package/dist/sync.mjs +5 -10
  35. package/dist/{version-BblbkW8-.mjs → version-BEfUEyPL.mjs} +17 -5
  36. package/package.json +3 -3
  37. /package/dist/{auth-Dg7prjeL.d.mts → auth-CVFc85uF.d.mts} +0 -0
  38. /package/dist/{editor-sync-types-CPpzTSnT.d.mts → editor-sync-types-D7YYz6fb.d.mts} +0 -0
  39. /package/dist/{editorHostProtocol-Bko7wge8.mjs → editorHostProtocol-B2_t3Le7.mjs} +0 -0
  40. /package/dist/{statelyPragma-D46lczJR.mjs → statelyPragma-YtVaBuIe.mjs} +0 -0
@@ -1,6 +1,6 @@
1
- import { i as ProfileManifest } from "./index-DlOZxzrW.mjs";
2
- import { i as StatelyGraph } from "./graph-CR_g-mOq.mjs";
3
- import { c as EditorSyncSourceLocation, f as MachineSourceLocations$1, l as EditorSyncSourceRange, t as EditorCapabilities$1, u as EditorSyncStateSourceLocation } from "./editor-sync-types-CPpzTSnT.mjs";
1
+ import { i as ProfileManifest } from "./index-DZivqh0u.mjs";
2
+ import { i as StatelyGraph } from "./graph-Ciocekxl.mjs";
3
+ import { c as EditorSyncSourceLocation, f as MachineSourceLocations$1, l as EditorSyncSourceRange, t as EditorCapabilities$1, u as EditorSyncStateSourceLocation } from "./editor-sync-types-D7YYz6fb.mjs";
4
4
 
5
5
  //#region src/embedPanel.d.ts
6
6
  type EmbedPanelPosition = 'left' | 'right' | 'bottom';
@@ -14,6 +14,11 @@ interface EmbedPanelConfig {
14
14
  initiallyOpen?: boolean;
15
15
  }
16
16
  //#endregion
17
+ //#region src/inspectorSettings.d.ts
18
+ /** Also filters untrusted wire data to the inspection presentation subset. */
19
+ declare function mergeInspectorSettings(previous: InspectorSettings, value: unknown): InspectorSettings;
20
+ declare function resolveInspectorSettings(options: Pick<ViewerOptions<unknown>, 'settings' | 'theme' | 'viewMode'>): InspectorSettings;
21
+ //#endregion
17
22
  //#region src/protocol.d.ts
18
23
  /** Query parameter carrying the unguessable inspection room capability. */
19
24
  declare const INSPECTION_ROOM_QUERY_PARAM = "r";
@@ -345,23 +350,46 @@ declare function isEmbedExampleMachine(value: unknown): value is Record<string,
345
350
  declare function isEmbedExample(value: unknown): value is EmbedExample;
346
351
  /** Reject malformed host-provided examples before creating an init message. */
347
352
  declare function assertEmbedExamples(examples: readonly EmbedExample[] | undefined): void;
348
- interface MachineInitOptions {
349
- machine: unknown;
350
- /** Ephemeral, read-only reference documents owned by the embed host. */
353
+ /** Display configuration shared by embeds and inspectors. */
354
+ interface ViewerOptions<Settings = Record<string, unknown>> {
355
+ /** Ephemeral, read-only reference documents owned by the host. */
351
356
  documents?: EmbedDocument[];
352
- format?: string;
353
- extensions?: EmbedExtensionsManifest;
354
- mode?: EmbedMode;
357
+ panels?: EmbedPanelConfig[];
355
358
  theme?: 'light' | 'dark';
359
+ viewMode?: 'graph' | 'list';
360
+ settings?: Settings;
356
361
  readOnly?: boolean;
357
- readOnlyReason?: ReadOnlyReason;
358
362
  depth?: number;
359
363
  capabilities?: EditorCapabilities;
364
+ }
365
+ /** Inspection only accepts presentation preferences, never authoring settings. */
366
+ interface InspectorSettings {
367
+ appearance?: {
368
+ colorMode?: 'light' | 'dark' | 'system';
369
+ };
370
+ canvas?: {
371
+ viewMode?: 'graph' | 'list';
372
+ showGrid?: boolean;
373
+ dimUnselected?: boolean;
374
+ edgeHighlightWidth?: number;
375
+ };
376
+ }
377
+ /** A viewer mounted and its selected surface is usable (including an empty system). */
378
+ interface InspectorLoadedEvent {
379
+ producerId?: string;
380
+ }
381
+ interface SystemLoadedMessage extends InspectorLoadedEvent {
382
+ type: '@statelyai.system.loaded';
383
+ }
384
+ interface MachineInitOptions extends ViewerOptions {
385
+ machine: unknown;
386
+ format?: string;
387
+ extensions?: EmbedExtensionsManifest;
388
+ mode?: EmbedMode;
389
+ readOnlyReason?: ReadOnlyReason;
360
390
  examples?: readonly EmbedExample[];
361
- panels?: EmbedPanelConfig[];
362
391
  comments?: CommentsConfig;
363
392
  sourceLocations?: MachineSourceLocations;
364
- settings?: Record<string, unknown>;
365
393
  /**
366
394
  * Show a persistent "Save to apply" pill in the embed whenever Viz has
367
395
  * local edits that have not yet been saved. Intended for contexts like
@@ -381,27 +409,19 @@ interface MachineInitOptions {
381
409
  /** Omit to disable automatic version requests. */
382
410
  versionAutoSave?: MachineVersionAutoSaveOptions;
383
411
  }
384
- interface ProjectInitOptions {
412
+ interface ProjectInitOptions extends ViewerOptions {
385
413
  machines: ProjectEmbedMachine[];
386
414
  /** Optional project-level chrome owned by the embed host. */
387
415
  chrome?: {
388
416
  /** Reserve a header row above the editor canvas. */header?: boolean;
389
417
  };
390
- /** Ephemeral, read-only reference documents shared across the project. */
391
- documents?: EmbedDocument[];
392
418
  currentMachineId?: string;
393
419
  mode?: EmbedMode;
394
- theme?: 'light' | 'dark';
395
- readOnly?: boolean;
396
420
  readOnlyReason?: ReadOnlyReason;
397
- depth?: number;
398
- capabilities?: EditorCapabilities;
399
421
  examples?: readonly EmbedExample[];
400
- panels?: EmbedPanelConfig[];
401
422
  commentsByMachineId?: Record<string, CommentsConfig>;
402
423
  projectWorkspace?: ProjectWorkspaceConfig;
403
424
  projectWorkspaceOpen?: boolean;
404
- settings?: Record<string, unknown>;
405
425
  unsavedIndicator?: {
406
426
  enabled?: boolean;
407
427
  mode?: 'structural' | 'all';
@@ -410,35 +430,14 @@ interface ProjectInitOptions {
410
430
  versionAutoSave?: MachineVersionAutoSaveOptions;
411
431
  }
412
432
  type InitOptions = MachineInitOptions | ProjectInitOptions;
413
- interface InitMessage {
433
+ interface InitMessage extends MachineInitOptions {
414
434
  type: '@statelyai.init';
415
- machine: unknown;
416
- documents?: EmbedDocument[];
417
- format?: string;
418
- extensions?: EmbedExtensionsManifest;
419
- mode?: EmbedMode;
420
- theme?: 'light' | 'dark';
421
- readOnly?: boolean;
422
- readOnlyReason?: ReadOnlyReason;
423
- depth?: number;
424
- capabilities?: EditorCapabilities;
425
- examples?: readonly EmbedExample[];
426
- panels?: EmbedPanelConfig[];
427
435
  /** @deprecated Use `panels`. */
428
436
  leftPanels?: string[];
429
437
  /** @deprecated Use `panels`. */
430
438
  rightPanels?: string[];
431
439
  /** @deprecated Use `panels[].initiallyOpen`. */
432
440
  activePanels?: string[];
433
- comments?: CommentsConfig;
434
- sourceLocations?: MachineSourceLocations;
435
- settings?: Record<string, unknown>;
436
- /** Mirror of `InitOptions.unsavedIndicator`. */
437
- unsavedIndicator?: {
438
- enabled?: boolean;
439
- mode?: 'structural' | 'all';
440
- };
441
- versionAutoSave?: MachineVersionAutoSaveOptions;
442
441
  }
443
442
  interface SetApiKeyMessage {
444
443
  type: '@statelyai.setApiKey';
@@ -468,37 +467,14 @@ interface ClipboardWriteMessage {
468
467
  requestId: string;
469
468
  text: string;
470
469
  }
471
- interface ProjectInitMessage {
470
+ interface ProjectInitMessage extends ProjectInitOptions {
472
471
  type: '@statelyai.project.init';
473
- machines: ProjectEmbedMachine[];
474
- chrome?: {
475
- header?: boolean;
476
- };
477
- documents?: EmbedDocument[];
478
- currentMachineId?: string;
479
- mode?: EmbedMode;
480
- theme?: 'light' | 'dark';
481
- readOnly?: boolean;
482
- readOnlyReason?: ReadOnlyReason;
483
- depth?: number;
484
- capabilities?: EditorCapabilities;
485
- examples?: readonly EmbedExample[];
486
- panels?: EmbedPanelConfig[];
487
472
  /** @deprecated Use `panels`. */
488
473
  leftPanels?: string[];
489
474
  /** @deprecated Use `panels`. */
490
475
  rightPanels?: string[];
491
476
  /** @deprecated Use `panels[].initiallyOpen`. */
492
477
  activePanels?: string[];
493
- commentsByMachineId?: Record<string, CommentsConfig>;
494
- projectWorkspace?: ProjectWorkspaceConfig;
495
- projectWorkspaceOpen?: boolean;
496
- settings?: Record<string, unknown>;
497
- unsavedIndicator?: {
498
- enabled?: boolean;
499
- mode?: 'structural' | 'all';
500
- };
501
- versionAutoSave?: MachineVersionAutoSaveOptions;
502
478
  sessionId?: string;
503
479
  }
504
480
  interface ProjectUpdateMessage {
@@ -554,6 +530,8 @@ interface ToastDismissMessage {
554
530
  }
555
531
  interface InspectSnapshotMessage {
556
532
  type: '@statelyai.inspectSnapshot';
533
+ /** Taken transitions, when supplied by the producer. */
534
+ transitions?: InspectionTakenTransition[];
557
535
  snapshot: unknown;
558
536
  event: unknown | null;
559
537
  /** Producer-local actor session id, when this snapshot belongs to an actor. */
@@ -597,7 +575,7 @@ interface InspectionSentEvent {
597
575
  delay?: number;
598
576
  id?: string;
599
577
  }
600
- interface SystemInitMessage {
578
+ interface SystemInitMessage extends ViewerOptions<InspectorSettings> {
601
579
  type: '@statelyai.system.init';
602
580
  protocolVersion: number;
603
581
  /** All known actors at the moment the system is first streamed. */
@@ -606,13 +584,7 @@ interface SystemInitMessage {
606
584
  machines?: Record<string, MachinePayload>;
607
585
  /** Actor session id the viz should focus first. Defaults to the root. */
608
586
  selectedSessionId?: string;
609
- documents?: EmbedDocument[];
610
587
  mode?: EmbedMode;
611
- theme?: 'light' | 'dark';
612
- readOnly?: boolean;
613
- depth?: number;
614
- capabilities?: EditorCapabilities;
615
- panels?: EmbedPanelConfig[];
616
588
  /** @deprecated Use `panels`. */
617
589
  leftPanels?: string[];
618
590
  /** @deprecated Use `panels`. */
@@ -833,7 +805,7 @@ interface ExtensionResultMessage {
833
805
  /** All messages a client (embed/inspector) can send to the viz. */
834
806
  type ClientMessage = InitMessage | SetApiKeyMessage | EditorHandshakeMessage | SavedMessage | ClipboardReadResponseMessage | ClipboardWriteResponseMessage | ProjectInitMessage | ProjectUpdateMessage | ProjectSelectMachineMessage | ProjectSetWorkspaceOpenMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | ToastDismissMessage | InspectSnapshotMessage | SystemInitMessage | SystemSelectActorMessage | SystemActorRegisteredMessage | SystemActorEventMessage | SystemActorSnapshotMessage | SystemActorStoppedMessage | UploadCapabilitiesMessage | UploadResponseMessage | ExtensionResultMessage | ErrorMessage;
835
807
  /** All messages the viz can send back to a client. */
836
- type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | VersionSaveRequestedMessage | ProjectMachineSelectedMessage | ProjectWorkspaceActionMessage | ProjectWorkspaceOpenChangedMessage | ViewModeChangedMessage | PanelChangedMessage | ModeChangedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | ClipboardReadMessage | ClipboardWriteMessage | UploadRequestMessage | ExtensionCallMessage;
808
+ type VizMessage = SystemLoadedMessage | ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | VersionSaveRequestedMessage | ProjectMachineSelectedMessage | ProjectWorkspaceActionMessage | ProjectWorkspaceOpenChangedMessage | ViewModeChangedMessage | PanelChangedMessage | ModeChangedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | ClipboardReadMessage | ClipboardWriteMessage | UploadRequestMessage | ExtensionCallMessage;
837
809
  interface InspectionClientMetadata {
838
810
  name?: string;
839
811
  machineId?: string;
@@ -862,4 +834,4 @@ declare const PREFIX = "@statelyai.";
862
834
  /** Current WebSocket inspection protocol version. */
863
835
  declare const INSPECTION_PROTOCOL_VERSION = 2;
864
836
  //#endregion
865
- export { ProjectMachineSelectedMessage as $, EmbedPanelConfig as $t, ExtensionCallMessage as A, SystemActorRegisteredMessage as At, InspectionSentEvent as B, UploadRequestMessage as Bt, EmbedFormatManifest as C, SetModeMessage as Ct, ExportCallOptions as D, SourceRange as Dt, ErrorMessage as E, SourceLocation as Et, InitOptions as F, ToastDismissMessage as Ft, MachineSourceLocations as G, ViewModeChangedMessage as Gt, LoadedMessage as H, UploadResult as Ht, InspectSnapshotMessage as I, ToastMessage as It, PREFIX as J, createInspectionActorId as Jt, MachineVersionAutoSaveOptions as K, VizMessage as Kt, InspectionAction as L, UpdateMessage as Lt, INSPECTION_PROTOCOL_VERSION as M, SystemActorStoppedMessage as Mt, INSPECTION_ROOM_QUERY_PARAM as N, SystemInitMessage as Nt, ExportFormat as O, StateSourceLocation as Ot, InitMessage as P, SystemSelectActorMessage as Pt, ProjectInitOptions as Q, isEmbedExampleMachine as Qt, InspectionClientMetadata as R, UploadCapabilitiesMessage as Rt, EmbedExtensionsManifest as S, SetApiKeyMessage as St, ErrorCode as T, SetThemeMessage as Tt, MachineInitOptions as U, ValidationIssue as Ut, InspectionTakenTransition as V, UploadResponseMessage as Vt, MachinePayload as W, VersionSaveRequestedMessage as Wt, ProjectEmbedMachine as X, getInspectionRoomId as Xt, PanelChangedMessage as Y, createInspectionRoomUrls as Yt, ProjectInitMessage as Z, isEmbedExample as Zt, EmbedDocumentLanguage as _, RetrieveMessage as _t, ChangeMessage as a, ProjectWorkspaceActionMessage as at, EmbedEventName as b, SavedMessage as bt, ClipboardReadResponseMessage as c, ProjectWorkspaceMachine as ct, CommentsConfig as d, ProjectWorkspaceProject as dt, EmbedPanelPosition as en, ProjectSelectMachineMessage as et, EMBED_DOCUMENT_LANGUAGES as f, ProtocolMessage as ft, EmbedDocument as g, RegisteredMessage as gt, EditorHandshakeMessage as h, RegisterMessage as ht, CapabilityDeniedMessage as i, ProjectWorkspaceActionIcon as it, ExtensionResultMessage as j, SystemActorSnapshotMessage as jt, ExportFormatMap as k, SystemActorEventMessage as kt, ClipboardWriteMessage as l, ProjectWorkspaceMachineOrigin as lt, EditorCapabilities as m, ReadyMessage as mt, CapabilityDeniedCapability as n, ProjectUpdateMessage as nt, ClientMessage as o, ProjectWorkspaceCapabilities as ot, EMBED_DOCUMENT_LIMITS as p, ReadOnlyReason as pt, ModeChangedMessage as q, assertEmbedExamples as qt, CapabilityDeniedEvent as r, ProjectWorkspaceAction as rt, ClipboardReadMessage as s, ProjectWorkspaceConfig as st, ActorSystemEntry as t, ProjectSetWorkspaceOpenMessage as tt, ClipboardWriteResponseMessage as u, ProjectWorkspaceOpenChangedMessage as ut, EmbedEventHandler as v, RetrievedMessage as vt, EmbedMode as w, SetSettingsMessage as wt, EmbedExample as x, SessionMessage as xt, EmbedEventMap as y, SaveMessage as yt, InspectionRoomUrls as z, UploadFileInfo as zt };
837
+ export { ProjectInitMessage as $, createInspectionRoomUrls as $t, ExtensionCallMessage as A, StateSourceLocation as At, InspectionSentEvent as B, UpdateMessage as Bt, EmbedFormatManifest as C, SessionMessage as Ct, ExportCallOptions as D, SetThemeMessage as Dt, ErrorMessage as E, SetSettingsMessage as Et, InitOptions as F, SystemInitMessage as Ft, MachineInitOptions as G, UploadResult as Gt, InspectorLoadedEvent as H, UploadFileInfo as Ht, InspectSnapshotMessage as I, SystemLoadedMessage as It, MachineVersionAutoSaveOptions as J, ViewModeChangedMessage as Jt, MachinePayload as K, ValidationIssue as Kt, InspectionAction as L, SystemSelectActorMessage as Lt, INSPECTION_PROTOCOL_VERSION as M, SystemActorRegisteredMessage as Mt, INSPECTION_ROOM_QUERY_PARAM as N, SystemActorSnapshotMessage as Nt, ExportFormat as O, SourceLocation as Ot, InitMessage as P, SystemActorStoppedMessage as Pt, ProjectEmbedMachine as Q, createInspectionActorId as Qt, InspectionClientMetadata as R, ToastDismissMessage as Rt, EmbedExtensionsManifest as S, SavedMessage as St, ErrorCode as T, SetModeMessage as Tt, InspectorSettings as U, UploadRequestMessage as Ut, InspectionTakenTransition as V, UploadCapabilitiesMessage as Vt, LoadedMessage as W, UploadResponseMessage as Wt, PREFIX as X, VizMessage as Xt, ModeChangedMessage as Y, ViewerOptions as Yt, PanelChangedMessage as Z, assertEmbedExamples as Zt, EmbedDocumentLanguage as _, RegisterMessage as _t, ChangeMessage as a, EmbedPanelConfig as an, ProjectWorkspaceAction as at, EmbedEventName as b, RetrievedMessage as bt, ClipboardReadResponseMessage as c, ProjectWorkspaceCapabilities as ct, CommentsConfig as d, ProjectWorkspaceMachineOrigin as dt, getInspectionRoomId as en, ProjectInitOptions as et, EMBED_DOCUMENT_LANGUAGES as f, ProjectWorkspaceOpenChangedMessage as ft, EmbedDocument as g, ReadyMessage as gt, EditorHandshakeMessage as h, ReadOnlyReason as ht, CapabilityDeniedMessage as i, resolveInspectorSettings as in, ProjectUpdateMessage as it, ExtensionResultMessage as j, SystemActorEventMessage as jt, ExportFormatMap as k, SourceRange as kt, ClipboardWriteMessage as l, ProjectWorkspaceConfig as lt, EditorCapabilities as m, ProtocolMessage as mt, CapabilityDeniedCapability as n, isEmbedExampleMachine as nn, ProjectSelectMachineMessage as nt, ClientMessage as o, EmbedPanelPosition as on, ProjectWorkspaceActionIcon as ot, EMBED_DOCUMENT_LIMITS as p, ProjectWorkspaceProject as pt, MachineSourceLocations as q, VersionSaveRequestedMessage as qt, CapabilityDeniedEvent as r, mergeInspectorSettings as rn, ProjectSetWorkspaceOpenMessage as rt, ClipboardReadMessage as s, ProjectWorkspaceActionMessage as st, ActorSystemEntry as t, isEmbedExample as tn, ProjectMachineSelectedMessage as tt, ClipboardWriteResponseMessage as u, ProjectWorkspaceMachine as ut, EmbedEventHandler as v, RegisteredMessage as vt, EmbedMode as w, SetApiKeyMessage as wt, EmbedExample as x, SaveMessage as xt, EmbedEventMap as y, RetrieveMessage as yt, InspectionRoomUrls as z, ToastMessage as zt };
@@ -0,0 +1,116 @@
1
+ //#region src/inspectorSettings.ts
2
+ const record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
3
+ /** Also filters untrusted wire data to the inspection presentation subset. */
4
+ function mergeInspectorSettings(previous, value) {
5
+ const input = record(value);
6
+ const appearance = record(input.appearance);
7
+ const canvas = record(input.canvas);
8
+ const result = {
9
+ appearance: { ...previous.appearance },
10
+ canvas: { ...previous.canvas }
11
+ };
12
+ if ([
13
+ "light",
14
+ "dark",
15
+ "system"
16
+ ].includes(String(appearance.colorMode))) result.appearance.colorMode = appearance.colorMode;
17
+ if (canvas.viewMode === "graph" || canvas.viewMode === "list") result.canvas.viewMode = canvas.viewMode;
18
+ for (const key of ["showGrid", "dimUnselected"]) if (typeof canvas[key] === "boolean") result.canvas[key] = canvas[key];
19
+ if (typeof canvas.edgeHighlightWidth === "number" && Number.isFinite(canvas.edgeHighlightWidth) && canvas.edgeHighlightWidth >= 0) result.canvas.edgeHighlightWidth = canvas.edgeHighlightWidth;
20
+ return result;
21
+ }
22
+ function resolveInspectorSettings(options) {
23
+ return mergeInspectorSettings(mergeInspectorSettings({}, options.settings), {
24
+ appearance: { colorMode: options.theme },
25
+ canvas: { viewMode: options.viewMode }
26
+ });
27
+ }
28
+
29
+ //#endregion
30
+ //#region src/protocol.ts
31
+ /** Query parameter carrying the unguessable inspection room capability. */
32
+ const INSPECTION_ROOM_QUERY_PARAM = "r";
33
+ /**
34
+ * Create the room-global identity for one producer-local actor session.
35
+ * Runtime and producer-resolved session ids may use different uniqueness
36
+ * domains; the producer id supplies a stable room namespace.
37
+ */
38
+ function createInspectionActorId(producerId, sessionId) {
39
+ return `${encodeURIComponent(producerId)}:${encodeURIComponent(sessionId)}`;
40
+ }
41
+ /** Resolve the transport and browser URLs required by the inspection protocol. */
42
+ function createInspectionRoomUrls(options) {
43
+ const relayUrl = new URL(options.url);
44
+ if (relayUrl.protocol !== "ws:" && relayUrl.protocol !== "wss:") throw new Error("Inspection relay URLs must use ws: or wss:.");
45
+ const existingRoomId = relayUrl.searchParams.get(INSPECTION_ROOM_QUERY_PARAM);
46
+ if (existingRoomId && existingRoomId !== options.roomId) throw new Error("Inspection relay URL room does not match roomId.");
47
+ relayUrl.searchParams.set(INSPECTION_ROOM_QUERY_PARAM, options.roomId);
48
+ if (options.inspectorBaseUrl) {
49
+ const inspectorUrl = new URL(options.inspectorBaseUrl);
50
+ inspectorUrl.searchParams.set("ws", relayUrl.toString());
51
+ inspectorUrl.searchParams.set(INSPECTION_ROOM_QUERY_PARAM, options.roomId);
52
+ return {
53
+ roomId: options.roomId,
54
+ relayUrl: relayUrl.toString(),
55
+ inspectorUrl: inspectorUrl.toString()
56
+ };
57
+ }
58
+ const inspectorUrl = new URL(relayUrl);
59
+ inspectorUrl.protocol = relayUrl.protocol === "wss:" ? "https:" : "http:";
60
+ return {
61
+ roomId: options.roomId,
62
+ relayUrl: relayUrl.toString(),
63
+ inspectorUrl: inspectorUrl.toString()
64
+ };
65
+ }
66
+ /** Read a room capability from a conforming relay or inspector URL. */
67
+ function getInspectionRoomId(value) {
68
+ return new URL(value).searchParams.get(INSPECTION_ROOM_QUERY_PARAM)?.trim() || null;
69
+ }
70
+ const EMBED_DOCUMENT_LANGUAGES = [
71
+ "markdown",
72
+ "typescript",
73
+ "javascript",
74
+ "json",
75
+ "xml",
76
+ "mermaid",
77
+ "text"
78
+ ];
79
+ const EMBED_DOCUMENT_LIMITS = {
80
+ maxDocuments: 100,
81
+ maxDocumentLength: 512 * 1024,
82
+ maxTotalLength: 2 * 1024 * 1024
83
+ };
84
+ function isRecord(value) {
85
+ return typeof value === "object" && value !== null && !Array.isArray(value);
86
+ }
87
+ function hasOwn(value, key) {
88
+ return Object.prototype.hasOwnProperty.call(value, key);
89
+ }
90
+ /** Check whether an example machine has a shape supported by the editor. */
91
+ function isEmbedExampleMachine(value) {
92
+ if (!isRecord(value)) return false;
93
+ if (hasOwn(value, "rootNode")) return isRecord(value.rootNode);
94
+ if (hasOwn(value, "root") && hasOwn(value, "states")) return isRecord(value.states);
95
+ if (hasOwn(value, "states")) return isRecord(value.states);
96
+ if (hasOwn(value, "States")) return isRecord(value.States);
97
+ return hasOwn(value, "nodes") && Array.isArray(value.nodes) && hasOwn(value, "edges") && Array.isArray(value.edges) && hasOwn(value, "data") && isRecord(value.data);
98
+ }
99
+ /** Check whether an unknown value is a valid serialized embed example. */
100
+ function isEmbedExample(value) {
101
+ return isRecord(value) && typeof value.id === "string" && typeof value.title === "string" && typeof value.description === "string" && typeof value.category === "string" && isEmbedExampleMachine(value.machine);
102
+ }
103
+ /** Reject malformed host-provided examples before creating an init message. */
104
+ function assertEmbedExamples(examples) {
105
+ if (examples === void 0) return;
106
+ if (!Array.isArray(examples)) throw new TypeError("Embed examples must be an array.");
107
+ examples.forEach((example, index) => {
108
+ if (!isEmbedExample(example)) throw new TypeError(`Invalid embed example at index ${index}.`);
109
+ });
110
+ }
111
+ const PREFIX = "@statelyai.";
112
+ /** Current WebSocket inspection protocol version. */
113
+ const INSPECTION_PROTOCOL_VERSION = 2;
114
+
115
+ //#endregion
116
+ export { PREFIX as a, createInspectionRoomUrls as c, isEmbedExampleMachine as d, mergeInspectorSettings as f, INSPECTION_ROOM_QUERY_PARAM as i, getInspectionRoomId as l, EMBED_DOCUMENT_LIMITS as n, assertEmbedExamples as o, resolveInspectorSettings as p, INSPECTION_PROTOCOL_VERSION as r, createInspectionActorId as s, EMBED_DOCUMENT_LANGUAGES as t, isEmbedExample as u };
@@ -1,2 +1,2 @@
1
- import { $ as ProjectMachineSelectedMessage, $t as EmbedPanelConfig, A as ExtensionCallMessage, At as SystemActorRegisteredMessage, B as InspectionSentEvent, Bt as UploadRequestMessage, C as EmbedFormatManifest, Ct as SetModeMessage, D as ExportCallOptions, Dt as SourceRange, E as ErrorMessage, Et as SourceLocation, F as InitOptions, Ft as ToastDismissMessage, G as MachineSourceLocations, Gt as ViewModeChangedMessage, H as LoadedMessage, Ht as UploadResult, I as InspectSnapshotMessage, It as ToastMessage, J as PREFIX, Jt as createInspectionActorId, K as MachineVersionAutoSaveOptions, Kt as VizMessage, L as InspectionAction, Lt as UpdateMessage, M as INSPECTION_PROTOCOL_VERSION, Mt as SystemActorStoppedMessage, N as INSPECTION_ROOM_QUERY_PARAM, Nt as SystemInitMessage, O as ExportFormat, Ot as StateSourceLocation, P as InitMessage, Pt as SystemSelectActorMessage, Q as ProjectInitOptions, Qt as isEmbedExampleMachine, R as InspectionClientMetadata, Rt as UploadCapabilitiesMessage, S as EmbedExtensionsManifest, St as SetApiKeyMessage, T as ErrorCode, Tt as SetThemeMessage, U as MachineInitOptions, Ut as ValidationIssue, V as InspectionTakenTransition, Vt as UploadResponseMessage, W as MachinePayload, Wt as VersionSaveRequestedMessage, X as ProjectEmbedMachine, Xt as getInspectionRoomId, Y as PanelChangedMessage, Yt as createInspectionRoomUrls, Z as ProjectInitMessage, Zt as isEmbedExample, _ as EmbedDocumentLanguage, _t as RetrieveMessage, a as ChangeMessage, at as ProjectWorkspaceActionMessage, b as EmbedEventName, bt as SavedMessage, c as ClipboardReadResponseMessage, ct as ProjectWorkspaceMachine, d as CommentsConfig, dt as ProjectWorkspaceProject, en as EmbedPanelPosition, et as ProjectSelectMachineMessage, f as EMBED_DOCUMENT_LANGUAGES, ft as ProtocolMessage, g as EmbedDocument, gt as RegisteredMessage, h as EditorHandshakeMessage, ht as RegisterMessage, i as CapabilityDeniedMessage, it as ProjectWorkspaceActionIcon, j as ExtensionResultMessage, jt as SystemActorSnapshotMessage, k as ExportFormatMap, kt as SystemActorEventMessage, l as ClipboardWriteMessage, lt as ProjectWorkspaceMachineOrigin, m as EditorCapabilities, mt as ReadyMessage, n as CapabilityDeniedCapability, nt as ProjectUpdateMessage, o as ClientMessage, ot as ProjectWorkspaceCapabilities, p as EMBED_DOCUMENT_LIMITS, pt as ReadOnlyReason, q as ModeChangedMessage, qt as assertEmbedExamples, r as CapabilityDeniedEvent, rt as ProjectWorkspaceAction, s as ClipboardReadMessage, st as ProjectWorkspaceConfig, t as ActorSystemEntry, tt as ProjectSetWorkspaceOpenMessage, u as ClipboardWriteResponseMessage, ut as ProjectWorkspaceOpenChangedMessage, v as EmbedEventHandler, vt as RetrievedMessage, w as EmbedMode, wt as SetSettingsMessage, x as EmbedExample, xt as SessionMessage, y as EmbedEventMap, yt as SaveMessage, z as InspectionRoomUrls, zt as UploadFileInfo } from "./protocol-CQL9Ubt9.mjs";
2
- export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, ClipboardReadMessage, ClipboardReadResponseMessage, ClipboardWriteMessage, ClipboardWriteResponseMessage, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EditorHandshakeMessage, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExample, EmbedExtensionsManifest, EmbedFormatManifest, EmbedMode, EmbedPanelConfig, EmbedPanelPosition, ErrorCode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, ExtensionCallMessage, ExtensionResultMessage, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitMessage, InitOptions, InspectSnapshotMessage, InspectionAction, InspectionClientMetadata, InspectionRoomUrls, InspectionSentEvent, InspectionTakenTransition, LoadedMessage, MachineInitOptions, MachinePayload, MachineSourceLocations, MachineVersionAutoSaveOptions, ModeChangedMessage, PREFIX, PanelChangedMessage, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectSetWorkspaceOpenMessage, ProjectUpdateMessage, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceActionMessage, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceMachineOrigin, ProjectWorkspaceOpenChangedMessage, ProjectWorkspaceProject, ProtocolMessage, ReadOnlyReason, ReadyMessage, RegisterMessage, RegisteredMessage, RetrieveMessage, RetrievedMessage, SaveMessage, SavedMessage, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorEventMessage, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, SystemSelectActorMessage, ToastDismissMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VersionSaveRequestedMessage, ViewModeChangedMessage, VizMessage, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine };
1
+ import { $ as ProjectInitMessage, $t as createInspectionRoomUrls, A as ExtensionCallMessage, At as StateSourceLocation, B as InspectionSentEvent, Bt as UpdateMessage, C as EmbedFormatManifest, Ct as SessionMessage, D as ExportCallOptions, Dt as SetThemeMessage, E as ErrorMessage, Et as SetSettingsMessage, F as InitOptions, Ft as SystemInitMessage, G as MachineInitOptions, Gt as UploadResult, H as InspectorLoadedEvent, Ht as UploadFileInfo, I as InspectSnapshotMessage, It as SystemLoadedMessage, J as MachineVersionAutoSaveOptions, Jt as ViewModeChangedMessage, K as MachinePayload, Kt as ValidationIssue, L as InspectionAction, Lt as SystemSelectActorMessage, M as INSPECTION_PROTOCOL_VERSION, Mt as SystemActorRegisteredMessage, N as INSPECTION_ROOM_QUERY_PARAM, Nt as SystemActorSnapshotMessage, O as ExportFormat, Ot as SourceLocation, P as InitMessage, Pt as SystemActorStoppedMessage, Q as ProjectEmbedMachine, Qt as createInspectionActorId, R as InspectionClientMetadata, Rt as ToastDismissMessage, S as EmbedExtensionsManifest, St as SavedMessage, T as ErrorCode, Tt as SetModeMessage, U as InspectorSettings, Ut as UploadRequestMessage, V as InspectionTakenTransition, Vt as UploadCapabilitiesMessage, W as LoadedMessage, Wt as UploadResponseMessage, X as PREFIX, Xt as VizMessage, Y as ModeChangedMessage, Yt as ViewerOptions, Z as PanelChangedMessage, Zt as assertEmbedExamples, _ as EmbedDocumentLanguage, _t as RegisterMessage, a as ChangeMessage, an as EmbedPanelConfig, at as ProjectWorkspaceAction, b as EmbedEventName, bt as RetrievedMessage, c as ClipboardReadResponseMessage, ct as ProjectWorkspaceCapabilities, d as CommentsConfig, dt as ProjectWorkspaceMachineOrigin, en as getInspectionRoomId, et as ProjectInitOptions, f as EMBED_DOCUMENT_LANGUAGES, ft as ProjectWorkspaceOpenChangedMessage, g as EmbedDocument, gt as ReadyMessage, h as EditorHandshakeMessage, ht as ReadOnlyReason, i as CapabilityDeniedMessage, in as resolveInspectorSettings, it as ProjectUpdateMessage, j as ExtensionResultMessage, jt as SystemActorEventMessage, k as ExportFormatMap, kt as SourceRange, l as ClipboardWriteMessage, lt as ProjectWorkspaceConfig, m as EditorCapabilities, mt as ProtocolMessage, n as CapabilityDeniedCapability, nn as isEmbedExampleMachine, nt as ProjectSelectMachineMessage, o as ClientMessage, on as EmbedPanelPosition, ot as ProjectWorkspaceActionIcon, p as EMBED_DOCUMENT_LIMITS, pt as ProjectWorkspaceProject, q as MachineSourceLocations, qt as VersionSaveRequestedMessage, r as CapabilityDeniedEvent, rn as mergeInspectorSettings, rt as ProjectSetWorkspaceOpenMessage, s as ClipboardReadMessage, st as ProjectWorkspaceActionMessage, t as ActorSystemEntry, tn as isEmbedExample, tt as ProjectMachineSelectedMessage, u as ClipboardWriteResponseMessage, ut as ProjectWorkspaceMachine, v as EmbedEventHandler, vt as RegisteredMessage, w as EmbedMode, wt as SetApiKeyMessage, x as EmbedExample, xt as SaveMessage, y as EmbedEventMap, yt as RetrieveMessage, z as InspectionRoomUrls, zt as ToastMessage } from "./protocol-B7q2lWj_.mjs";
2
+ export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, ClipboardReadMessage, ClipboardReadResponseMessage, ClipboardWriteMessage, ClipboardWriteResponseMessage, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EditorHandshakeMessage, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExample, EmbedExtensionsManifest, EmbedFormatManifest, EmbedMode, EmbedPanelConfig, EmbedPanelPosition, ErrorCode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, ExtensionCallMessage, ExtensionResultMessage, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitMessage, InitOptions, InspectSnapshotMessage, InspectionAction, InspectionClientMetadata, InspectionRoomUrls, InspectionSentEvent, InspectionTakenTransition, InspectorLoadedEvent, InspectorSettings, LoadedMessage, MachineInitOptions, MachinePayload, MachineSourceLocations, MachineVersionAutoSaveOptions, ModeChangedMessage, PREFIX, PanelChangedMessage, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectSetWorkspaceOpenMessage, ProjectUpdateMessage, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceActionMessage, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceMachineOrigin, ProjectWorkspaceOpenChangedMessage, ProjectWorkspaceProject, ProtocolMessage, ReadOnlyReason, ReadyMessage, RegisterMessage, RegisteredMessage, RetrieveMessage, RetrievedMessage, SaveMessage, SavedMessage, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorEventMessage, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, SystemLoadedMessage, SystemSelectActorMessage, ToastDismissMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VersionSaveRequestedMessage, ViewModeChangedMessage, ViewerOptions, VizMessage, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine, mergeInspectorSettings, resolveInspectorSettings };
package/dist/protocol.mjs CHANGED
@@ -1,87 +1,3 @@
1
- //#region src/protocol.ts
2
- /** Query parameter carrying the unguessable inspection room capability. */
3
- const INSPECTION_ROOM_QUERY_PARAM = "r";
4
- /**
5
- * Create the room-global identity for one producer-local actor session.
6
- * Runtime and producer-resolved session ids may use different uniqueness
7
- * domains; the producer id supplies a stable room namespace.
8
- */
9
- function createInspectionActorId(producerId, sessionId) {
10
- return `${encodeURIComponent(producerId)}:${encodeURIComponent(sessionId)}`;
11
- }
12
- /** Resolve the transport and browser URLs required by the inspection protocol. */
13
- function createInspectionRoomUrls(options) {
14
- const relayUrl = new URL(options.url);
15
- if (relayUrl.protocol !== "ws:" && relayUrl.protocol !== "wss:") throw new Error("Inspection relay URLs must use ws: or wss:.");
16
- const existingRoomId = relayUrl.searchParams.get(INSPECTION_ROOM_QUERY_PARAM);
17
- if (existingRoomId && existingRoomId !== options.roomId) throw new Error("Inspection relay URL room does not match roomId.");
18
- relayUrl.searchParams.set(INSPECTION_ROOM_QUERY_PARAM, options.roomId);
19
- if (options.inspectorBaseUrl) {
20
- const inspectorUrl = new URL(options.inspectorBaseUrl);
21
- inspectorUrl.searchParams.set("ws", relayUrl.toString());
22
- inspectorUrl.searchParams.set(INSPECTION_ROOM_QUERY_PARAM, options.roomId);
23
- return {
24
- roomId: options.roomId,
25
- relayUrl: relayUrl.toString(),
26
- inspectorUrl: inspectorUrl.toString()
27
- };
28
- }
29
- const inspectorUrl = new URL(relayUrl);
30
- inspectorUrl.protocol = relayUrl.protocol === "wss:" ? "https:" : "http:";
31
- return {
32
- roomId: options.roomId,
33
- relayUrl: relayUrl.toString(),
34
- inspectorUrl: inspectorUrl.toString()
35
- };
36
- }
37
- /** Read a room capability from a conforming relay or inspector URL. */
38
- function getInspectionRoomId(value) {
39
- return new URL(value).searchParams.get(INSPECTION_ROOM_QUERY_PARAM)?.trim() || null;
40
- }
41
- const EMBED_DOCUMENT_LANGUAGES = [
42
- "markdown",
43
- "typescript",
44
- "javascript",
45
- "json",
46
- "xml",
47
- "mermaid",
48
- "text"
49
- ];
50
- const EMBED_DOCUMENT_LIMITS = {
51
- maxDocuments: 100,
52
- maxDocumentLength: 512 * 1024,
53
- maxTotalLength: 2 * 1024 * 1024
54
- };
55
- function isRecord(value) {
56
- return typeof value === "object" && value !== null && !Array.isArray(value);
57
- }
58
- function hasOwn(value, key) {
59
- return Object.prototype.hasOwnProperty.call(value, key);
60
- }
61
- /** Check whether an example machine has a shape supported by the editor. */
62
- function isEmbedExampleMachine(value) {
63
- if (!isRecord(value)) return false;
64
- if (hasOwn(value, "rootNode")) return isRecord(value.rootNode);
65
- if (hasOwn(value, "root") && hasOwn(value, "states")) return isRecord(value.states);
66
- if (hasOwn(value, "states")) return isRecord(value.states);
67
- if (hasOwn(value, "States")) return isRecord(value.States);
68
- return hasOwn(value, "nodes") && Array.isArray(value.nodes) && hasOwn(value, "edges") && Array.isArray(value.edges) && hasOwn(value, "data") && isRecord(value.data);
69
- }
70
- /** Check whether an unknown value is a valid serialized embed example. */
71
- function isEmbedExample(value) {
72
- return isRecord(value) && typeof value.id === "string" && typeof value.title === "string" && typeof value.description === "string" && typeof value.category === "string" && isEmbedExampleMachine(value.machine);
73
- }
74
- /** Reject malformed host-provided examples before creating an init message. */
75
- function assertEmbedExamples(examples) {
76
- if (examples === void 0) return;
77
- if (!Array.isArray(examples)) throw new TypeError("Embed examples must be an array.");
78
- examples.forEach((example, index) => {
79
- if (!isEmbedExample(example)) throw new TypeError(`Invalid embed example at index ${index}.`);
80
- });
81
- }
82
- const PREFIX = "@statelyai.";
83
- /** Current WebSocket inspection protocol version. */
84
- const INSPECTION_PROTOCOL_VERSION = 2;
1
+ import { a as PREFIX, c as createInspectionRoomUrls, d as isEmbedExampleMachine, f as mergeInspectorSettings, i as INSPECTION_ROOM_QUERY_PARAM, l as getInspectionRoomId, n as EMBED_DOCUMENT_LIMITS, o as assertEmbedExamples, p as resolveInspectorSettings, r as INSPECTION_PROTOCOL_VERSION, s as createInspectionActorId, t as EMBED_DOCUMENT_LANGUAGES, u as isEmbedExample } from "./protocol-BsBGRISR.mjs";
85
2
 
86
- //#endregion
87
- export { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, PREFIX, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine };
3
+ export { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, PREFIX, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine, mergeInspectorSettings, resolveInspectorSettings };
package/dist/relay.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { ft as ProtocolMessage } from "./protocol-CQL9Ubt9.mjs";
1
+ import { mt as ProtocolMessage } from "./protocol-B7q2lWj_.mjs";
2
2
 
3
3
  //#region src/relay.d.ts
4
4
  type InspectionRelayRole = 'producer' | 'viewer';
package/dist/relay.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { INSPECTION_PROTOCOL_VERSION, PREFIX } from "./protocol.mjs";
1
+ import { a as PREFIX, f as mergeInspectorSettings, p as resolveInspectorSettings, r as INSPECTION_PROTOCOL_VERSION } from "./protocol-BsBGRISR.mjs";
2
2
 
3
3
  //#region src/relay.ts
4
4
  const REPLAYABLE_MESSAGE_TYPES = new Set([
@@ -8,15 +8,17 @@ const REPLAYABLE_MESSAGE_TYPES = new Set([
8
8
  "@statelyai.system.actorRegistered",
9
9
  "@statelyai.system.actorEvent",
10
10
  "@statelyai.system.actorSnapshot",
11
- "@statelyai.system.actorStopped"
11
+ "@statelyai.system.actorStopped",
12
+ "@statelyai.setSettings",
13
+ "@statelyai.system.selectActor"
12
14
  ]);
13
15
  const FORWARD_ONLY_MESSAGE_TYPES = new Set([
14
- "@statelyai.system.selectActor",
15
16
  "@statelyai.retrieve",
16
17
  "@statelyai.retrieved",
17
18
  "@statelyai.error",
18
19
  "@statelyai.ready",
19
20
  "@statelyai.loaded",
21
+ "@statelyai.system.loaded",
20
22
  "@statelyai.capabilityDenied",
21
23
  "@statelyai.register",
22
24
  "@statelyai.registered"
@@ -39,6 +41,7 @@ function validationError(message) {
39
41
  if (!isSupportedMessageType(message.type)) return `Unsupported inspection message type ${String(message.type)}`;
40
42
  const hasString = (key) => typeof message[key] === "string" && message[key] !== "";
41
43
  switch (message.type) {
44
+ case "@statelyai.setSettings": return message.settings && typeof message.settings === "object" && !Array.isArray(message.settings) ? null : "setSettings requires a settings object";
42
45
  case "@statelyai.system.init": return message.protocolVersion === INSPECTION_PROTOCOL_VERSION && Array.isArray(message.actors) ? null : "system.init requires the current protocolVersion and actors array";
43
46
  case "@statelyai.system.selectActor":
44
47
  case "@statelyai.system.actorStopped": return hasString("sessionId") ? null : `${message.type} requires sessionId`;
@@ -61,6 +64,23 @@ function errorMessage(code, message) {
61
64
  function compactReplay(replay, message, max) {
62
65
  const record = message;
63
66
  const type = record.type;
67
+ if (type === "@statelyai.setSettings" || type === "@statelyai.system.selectActor") {
68
+ const index = replay.findIndex((entry) => entry.type === "@statelyai.system.init");
69
+ const init = replay[index];
70
+ if (init?.type === "@statelyai.system.init") {
71
+ if (type === "@statelyai.setSettings") {
72
+ const { theme: _theme, viewMode: _viewMode, ...rest } = init;
73
+ replay[index] = {
74
+ ...rest,
75
+ settings: mergeInspectorSettings(resolveInspectorSettings(init), record.settings)
76
+ };
77
+ } else replay[index] = {
78
+ ...init,
79
+ selectedSessionId: record.sessionId
80
+ };
81
+ return;
82
+ }
83
+ }
64
84
  if (type === "@statelyai.system.init") for (let index = replay.length - 1; index >= 0; index--) {
65
85
  const replayType = replay[index].type;
66
86
  if (replayType === "@statelyai.system.init" || replayType.startsWith("@statelyai.system.actor")) replay.splice(index, 1);