@statelyai/sdk 0.32.0 → 0.34.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 (40) hide show
  1. package/README.md +24 -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-BqyuKldr.d.mts → editorHostSession-DwD_9cER.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-GI2nE3J9.mjs → inspect-0dMcaOz_.mjs} +50 -6
  18. package/dist/{inspect-C18TbR-o.d.mts → inspect-D-L0qj9L.d.mts} +21 -9
  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-C-tx0WI6.d.mts → protocol-AeHm956D.d.mts} +50 -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-1vqjW2Am.mjs → version-DxDSBJta.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 {
@@ -575,6 +551,8 @@ interface ActorSystemEntry {
575
551
  /** Whether this actor stopped before this checkpoint was sent. */
576
552
  stopped?: boolean;
577
553
  }
554
+ /** Source text or machine config used to render a declared machine. */
555
+ type MachinePayload = unknown;
578
556
  /** JSON-safe record of an action executed during an inspected transition. */
579
557
  interface InspectionAction {
580
558
  type: string;
@@ -595,20 +573,16 @@ interface InspectionSentEvent {
595
573
  delay?: number;
596
574
  id?: string;
597
575
  }
598
- interface SystemInitMessage {
576
+ interface SystemInitMessage extends ViewerOptions<InspectorSettings> {
599
577
  type: '@statelyai.system.init';
600
578
  protocolVersion: number;
601
579
  /** All known actors at the moment the system is first streamed. */
602
580
  actors: ActorSystemEntry[];
581
+ /** Machine definitions available before their first actor exists. */
582
+ machines?: Record<string, MachinePayload>;
603
583
  /** Actor session id the viz should focus first. Defaults to the root. */
604
584
  selectedSessionId?: string;
605
- documents?: EmbedDocument[];
606
585
  mode?: EmbedMode;
607
- theme?: 'light' | 'dark';
608
- readOnly?: boolean;
609
- depth?: number;
610
- capabilities?: EditorCapabilities;
611
- panels?: EmbedPanelConfig[];
612
586
  /** @deprecated Use `panels`. */
613
587
  leftPanels?: string[];
614
588
  /** @deprecated Use `panels`. */
@@ -829,7 +803,7 @@ interface ExtensionResultMessage {
829
803
  /** All messages a client (embed/inspector) can send to the viz. */
830
804
  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;
831
805
  /** All messages the viz can send back to a client. */
832
- type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | VersionSaveRequestedMessage | ProjectMachineSelectedMessage | ProjectWorkspaceActionMessage | ProjectWorkspaceOpenChangedMessage | ViewModeChangedMessage | PanelChangedMessage | ModeChangedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | ClipboardReadMessage | ClipboardWriteMessage | UploadRequestMessage | ExtensionCallMessage;
806
+ type VizMessage = SystemLoadedMessage | ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | VersionSaveRequestedMessage | ProjectMachineSelectedMessage | ProjectWorkspaceActionMessage | ProjectWorkspaceOpenChangedMessage | ViewModeChangedMessage | PanelChangedMessage | ModeChangedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | ClipboardReadMessage | ClipboardWriteMessage | UploadRequestMessage | ExtensionCallMessage;
833
807
  interface InspectionClientMetadata {
834
808
  name?: string;
835
809
  machineId?: string;
@@ -858,4 +832,4 @@ declare const PREFIX = "@statelyai.";
858
832
  /** Current WebSocket inspection protocol version. */
859
833
  declare const INSPECTION_PROTOCOL_VERSION = 2;
860
834
  //#endregion
861
- export { ProjectSelectMachineMessage as $, EmbedPanelPosition as $t, ExtensionCallMessage as A, SystemActorSnapshotMessage as At, InspectionSentEvent as B, UploadResponseMessage as Bt, EmbedFormatManifest as C, SetSettingsMessage as Ct, ExportCallOptions as D, StateSourceLocation as Dt, ErrorMessage as E, SourceRange as Et, InitOptions as F, ToastMessage as Ft, MachineVersionAutoSaveOptions as G, VizMessage as Gt, LoadedMessage as H, ValidationIssue as Ht, InspectSnapshotMessage as I, UpdateMessage as It, PanelChangedMessage as J, createInspectionRoomUrls as Jt, ModeChangedMessage as K, assertEmbedExamples as Kt, InspectionAction as L, UploadCapabilitiesMessage as Lt, INSPECTION_PROTOCOL_VERSION as M, SystemInitMessage as Mt, INSPECTION_ROOM_QUERY_PARAM as N, SystemSelectActorMessage as Nt, ExportFormat as O, SystemActorEventMessage as Ot, InitMessage as P, ToastDismissMessage as Pt, ProjectMachineSelectedMessage as Q, EmbedPanelConfig as Qt, InspectionClientMetadata as R, UploadFileInfo as Rt, EmbedExtensionsManifest as S, SetModeMessage as St, ErrorCode as T, SourceLocation as Tt, MachineInitOptions as U, VersionSaveRequestedMessage as Ut, InspectionTakenTransition as V, UploadResult as Vt, MachineSourceLocations as W, ViewModeChangedMessage as Wt, ProjectInitMessage as X, isEmbedExample as Xt, ProjectEmbedMachine as Y, getInspectionRoomId as Yt, ProjectInitOptions as Z, isEmbedExampleMachine as Zt, EmbedDocumentLanguage as _, RetrievedMessage as _t, ChangeMessage as a, ProjectWorkspaceCapabilities as at, EmbedEventName as b, SessionMessage as bt, ClipboardReadResponseMessage as c, ProjectWorkspaceMachineOrigin as ct, CommentsConfig as d, ProtocolMessage as dt, ProjectSetWorkspaceOpenMessage as et, EMBED_DOCUMENT_LANGUAGES as f, ReadOnlyReason as ft, EmbedDocument as g, RetrieveMessage as gt, EditorHandshakeMessage as h, RegisteredMessage as ht, CapabilityDeniedMessage as i, ProjectWorkspaceActionMessage as it, ExtensionResultMessage as j, SystemActorStoppedMessage as jt, ExportFormatMap as k, SystemActorRegisteredMessage as kt, ClipboardWriteMessage as l, ProjectWorkspaceOpenChangedMessage as lt, EditorCapabilities as m, RegisterMessage as mt, CapabilityDeniedCapability as n, ProjectWorkspaceAction as nt, ClientMessage as o, ProjectWorkspaceConfig as ot, EMBED_DOCUMENT_LIMITS as p, ReadyMessage as pt, PREFIX as q, createInspectionActorId as qt, CapabilityDeniedEvent as r, ProjectWorkspaceActionIcon as rt, ClipboardReadMessage as s, ProjectWorkspaceMachine as st, ActorSystemEntry as t, ProjectUpdateMessage as tt, ClipboardWriteResponseMessage as u, ProjectWorkspaceProject as ut, EmbedEventHandler as v, SaveMessage as vt, EmbedMode as w, SetThemeMessage as wt, EmbedExample as x, SetApiKeyMessage as xt, EmbedEventMap as y, SavedMessage as yt, InspectionRoomUrls as z, UploadRequestMessage as zt };
835
+ 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 ProjectSelectMachineMessage, $t as EmbedPanelPosition, A as ExtensionCallMessage, At as SystemActorSnapshotMessage, B as InspectionSentEvent, Bt as UploadResponseMessage, C as EmbedFormatManifest, Ct as SetSettingsMessage, D as ExportCallOptions, Dt as StateSourceLocation, E as ErrorMessage, Et as SourceRange, F as InitOptions, Ft as ToastMessage, G as MachineVersionAutoSaveOptions, Gt as VizMessage, H as LoadedMessage, Ht as ValidationIssue, I as InspectSnapshotMessage, It as UpdateMessage, J as PanelChangedMessage, Jt as createInspectionRoomUrls, K as ModeChangedMessage, Kt as assertEmbedExamples, L as InspectionAction, Lt as UploadCapabilitiesMessage, M as INSPECTION_PROTOCOL_VERSION, Mt as SystemInitMessage, N as INSPECTION_ROOM_QUERY_PARAM, Nt as SystemSelectActorMessage, O as ExportFormat, Ot as SystemActorEventMessage, P as InitMessage, Pt as ToastDismissMessage, Q as ProjectMachineSelectedMessage, Qt as EmbedPanelConfig, R as InspectionClientMetadata, Rt as UploadFileInfo, S as EmbedExtensionsManifest, St as SetModeMessage, T as ErrorCode, Tt as SourceLocation, U as MachineInitOptions, Ut as VersionSaveRequestedMessage, V as InspectionTakenTransition, Vt as UploadResult, W as MachineSourceLocations, Wt as ViewModeChangedMessage, X as ProjectInitMessage, Xt as isEmbedExample, Y as ProjectEmbedMachine, Yt as getInspectionRoomId, Z as ProjectInitOptions, Zt as isEmbedExampleMachine, _ as EmbedDocumentLanguage, _t as RetrievedMessage, a as ChangeMessage, at as ProjectWorkspaceCapabilities, b as EmbedEventName, bt as SessionMessage, c as ClipboardReadResponseMessage, ct as ProjectWorkspaceMachineOrigin, d as CommentsConfig, dt as ProtocolMessage, et as ProjectSetWorkspaceOpenMessage, f as EMBED_DOCUMENT_LANGUAGES, ft as ReadOnlyReason, g as EmbedDocument, gt as RetrieveMessage, h as EditorHandshakeMessage, ht as RegisteredMessage, i as CapabilityDeniedMessage, it as ProjectWorkspaceActionMessage, j as ExtensionResultMessage, jt as SystemActorStoppedMessage, k as ExportFormatMap, kt as SystemActorRegisteredMessage, l as ClipboardWriteMessage, lt as ProjectWorkspaceOpenChangedMessage, m as EditorCapabilities, mt as RegisterMessage, n as CapabilityDeniedCapability, nt as ProjectWorkspaceAction, o as ClientMessage, ot as ProjectWorkspaceConfig, p as EMBED_DOCUMENT_LIMITS, pt as ReadyMessage, q as PREFIX, qt as createInspectionActorId, r as CapabilityDeniedEvent, rt as ProjectWorkspaceActionIcon, s as ClipboardReadMessage, st as ProjectWorkspaceMachine, t as ActorSystemEntry, tt as ProjectUpdateMessage, u as ClipboardWriteResponseMessage, ut as ProjectWorkspaceProject, v as EmbedEventHandler, vt as SaveMessage, w as EmbedMode, wt as SetThemeMessage, x as EmbedExample, xt as SetApiKeyMessage, y as EmbedEventMap, yt as SavedMessage, z as InspectionRoomUrls, zt as UploadRequestMessage } from "./protocol-C-tx0WI6.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, 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-AeHm956D.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 { dt as ProtocolMessage } from "./protocol-C-tx0WI6.mjs";
1
+ import { mt as ProtocolMessage } from "./protocol-AeHm956D.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);