@statelyai/sdk 0.25.0 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -23,24 +23,24 @@ npm install @statelyai/sdk
23
23
  Drop a fully interactive state machine editor into any web app. The embed communicates over `postMessage` and gives you full control over theme, layout, panels, read-only mode, and more.
24
24
 
25
25
  ```ts
26
- import { createStatelyEmbed } from '@statelyai/sdk';
26
+ import { createStatelyEmbed } from "@statelyai/sdk";
27
27
 
28
28
  const embed = createStatelyEmbed({
29
- baseUrl: 'https://editor.stately.ai',
30
- apiKey: 'your-api-key',
29
+ baseUrl: "https://editor.stately.ai",
30
+ apiKey: "your-api-key",
31
31
  });
32
32
 
33
- embed.mount(document.getElementById('editor')!);
33
+ embed.mount(document.getElementById("editor")!);
34
34
 
35
35
  embed.init({
36
36
  machine: myMachineConfig,
37
- format: 'xstate',
38
- mode: 'editing',
39
- theme: 'dark',
40
- settings: { canvas: { viewMode: 'list' } },
37
+ format: "xstate",
38
+ mode: "editing",
39
+ theme: "dark",
40
+ settings: { canvas: { viewMode: "list" } },
41
41
  documents: [
42
- { path: 'README.md', content: '# How this workflow works' },
43
- { path: 'src/machine.ts', content: machineSource },
42
+ { path: "README.md", content: "# How this workflow works" },
43
+ { path: "src/machine.ts", content: machineSource },
44
44
  ],
45
45
  });
46
46
  ```
@@ -59,6 +59,18 @@ RPC methods and payloads are validated before host code runs, and malformed
59
59
  graphs returned by custom importers are rejected.
60
60
  Use `defaultProfile` and `defaultFormat` to choose the initial custom pair.
61
61
 
62
+ The Get started launchpad is host-configurable. Pass serializable `examples` to
63
+ `embed.init()` (or the project equivalent) to show the Examples section; omit
64
+ the option or pass an empty array to keep it hidden. The editor does not ship a
65
+ default catalog, so self-hosted deployments can provide their own examples.
66
+
67
+ <!-- Embed version configuration and events from src/embed.ts and src/protocol.ts -->
68
+
69
+ Automatic version capture is opt-in. Pass `versionAutoSave: { intervalMs }` to
70
+ the embed and handle `versionSaveRequested` to persist immutable snapshots in
71
+ the host, or omit it to keep versioning manual. Hosts with server-side
72
+ auto-versioning should choose one capture path per save.
73
+
62
74
  Restrict an embed by passing a resolved access policy:
63
75
 
64
76
  <!-- restricted MachineInitOptions from src/protocol.ts -->
@@ -66,9 +78,9 @@ Restrict an embed by passing a resolved access policy:
66
78
  ```ts
67
79
  embed.init({
68
80
  machine: myMachineConfig,
69
- mode: 'viewing',
81
+ mode: "viewing",
70
82
  readOnly: true,
71
- readOnlyReason: 'free-plan',
83
+ readOnlyReason: "free-plan",
72
84
  capabilities: {
73
85
  edit: false,
74
86
  export: false,
@@ -76,11 +88,11 @@ embed.init({
76
88
  simulate: false,
77
89
  navigateHierarchy: false,
78
90
  maxDepth: 1,
79
- panels: ['structure', 'details', 'validations'],
91
+ panels: ["structure", "details", "validations"],
80
92
  },
81
93
  });
82
94
 
83
- embed.on('capabilityDenied', (event) => {
95
+ embed.on("capabilityDenied", (event) => {
84
96
  console.warn(event.message);
85
97
  });
86
98
  ```
@@ -115,6 +127,7 @@ Key capabilities:
115
127
  - **Comments** via Liveblocks integration (optional)
116
128
  - **Asset uploads** with built-in S3 and Supabase adapters, or bring your own upload handler
117
129
  - **Runtime settings** - toggle color mode, grid, snap lines, and view mode on the fly
130
+ - **Automatic versions** - optionally request host-owned immutable snapshots at a configured interval
118
131
 
119
132
  ### Resource API client
120
133
 
@@ -124,17 +137,17 @@ Programmatic access to hosted Stately resources, credential verification, and
124
137
  deterministic machine-config extraction.
125
138
 
126
139
  ```ts
127
- import { createStatelyClient } from '@statelyai/sdk';
140
+ import { createStatelyClient } from "@statelyai/sdk";
128
141
 
129
142
  const studio = createStatelyClient({
130
143
  credential: {
131
- type: 'oauth',
144
+ type: "oauth",
132
145
  accessToken: process.env.STATELY_ACCESS_TOKEN!,
133
146
  },
134
147
  });
135
148
 
136
149
  const projects = await studio.projects.list();
137
- const machine = await studio.machines.get('machine-id');
150
+ const machine = await studio.machines.get("machine-id");
138
151
  const extracted = await studio.code.extractMachines({
139
152
  code: sourceCode,
140
153
  });
@@ -193,8 +206,8 @@ Stream live actor-system state to the hosted Stately inspector. Zero-config
193
206
  inspection needs no API key or local relay.
194
207
 
195
208
  ```ts
196
- import { createActor } from 'xstate';
197
- import { createInspector } from '@statelyai/sdk';
209
+ import { createActor } from "xstate";
210
+ import { createInspector } from "@statelyai/sdk";
198
211
 
199
212
  const inspector = createInspector();
200
213
  const { inspect } = inspector;
@@ -212,8 +225,7 @@ JSON-safe machine structure:
212
225
 
213
226
  ```ts
214
227
  const inspector = createInspector({
215
- extractMachine: (actor) =>
216
- actor.logic === machine ? machineSource : actor.logic?.config,
228
+ extractMachine: (actor) => (actor.logic === machine ? machineSource : actor.logic?.config),
217
229
  });
218
230
  ```
219
231
 
@@ -320,7 +332,7 @@ A fully self-contained deployment with no external auth looks like:
320
332
 
321
333
  ```ts
322
334
  const embed = createStatelyEmbed({
323
- baseUrl: 'https://your-editor.example.com',
335
+ baseUrl: "https://your-editor.example.com",
324
336
  });
325
337
  ```
326
338
 
@@ -332,8 +344,8 @@ npx @statelyai/sdk relay
332
344
 
333
345
  ```ts
334
346
  const inspector = createInspector({
335
- url: 'ws://localhost:4242',
336
- inspectorBaseUrl: 'http://localhost:3000/inspect',
347
+ url: "ws://localhost:4242",
348
+ inspectorBaseUrl: "http://localhost:3000/inspect",
337
349
  });
338
350
  ```
339
351
 
package/dist/embed.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { i as ProfileManifest } from "./index-DuvCSThi.mjs";
2
- import { i as StatelyGraph } from "./graph-BGUND7ZF.mjs";
3
- import { CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExtensionsManifest, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, MachineInitOptions, MachineSourceLocations, ProjectEmbedMachine, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceProject, UploadResult } from "./protocol.mjs";
1
+ import { i as ProfileManifest } from "./index-DKRB-u93.mjs";
2
+ import { i as StatelyGraph } from "./graph-DoUReqxz.mjs";
3
+ import { CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExtensionsManifest, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, MachineInitOptions, MachineSourceLocations, MachineVersionAutoSaveOptions, ProjectEmbedMachine, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceMachineOrigin, ProjectWorkspaceProject, UploadResult } from "./protocol.mjs";
4
4
  import { AssetUploadAdapter } from "./assetStorage.mjs";
5
5
 
6
6
  //#region src/embed.d.ts
@@ -104,6 +104,7 @@ interface StatelyEmbedOptions extends Partial<MachineInitOptions> {
104
104
  onLoaded?: (graph: StatelyGraph) => void;
105
105
  onChange?: (graph: StatelyGraph, machineConfig: unknown) => void;
106
106
  onSave?: (graph: StatelyGraph, machineConfig: unknown) => void;
107
+ onVersionSaveRequested?: (event: EmbedEventMap['versionSaveRequested']) => void;
107
108
  onViewModeChanged?: (viewMode: 'graph' | 'list') => void;
108
109
  onError?: (error: {
109
110
  code: string;
@@ -150,4 +151,4 @@ interface StatelyEmbed {
150
151
  }
151
152
  declare function createStatelyEmbed(options: StatelyEmbedOptions): StatelyEmbed;
152
153
  //#endregion
153
- export { AssetConfig, type CapabilityDeniedEvent, type CommentsConfig, type EditorCapabilities, type EmbedDocument, type EmbedDocumentLanguage, EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExtensionsManifest, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, type EmbedMode, EmbedProfileDefinition, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type MachineInitOptions, type MachineSourceLocations, type ProjectEmbedMachine, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceProject, StatelyEmbed, StatelyEmbedOptions, type UploadResult, createStatelyEmbed };
154
+ export { AssetConfig, type CapabilityDeniedEvent, type CommentsConfig, type EditorCapabilities, type EmbedDocument, type EmbedDocumentLanguage, EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExtensionsManifest, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, type EmbedMode, EmbedProfileDefinition, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type MachineInitOptions, type MachineSourceLocations, type MachineVersionAutoSaveOptions, type ProjectEmbedMachine, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceMachineOrigin, type ProjectWorkspaceProject, StatelyEmbed, StatelyEmbedOptions, type UploadResult, createStatelyEmbed };
package/dist/embed.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as createEventRegistry, o as createPendingExportManager, r as createPostMessageTransport, s as toInitMessage, t as SDK_VERSION } from "./version-BfcJU2pO.mjs";
1
+ import { a as createEventRegistry, o as createPendingExportManager, r as createPostMessageTransport, s as toInitMessage, t as SDK_VERSION } from "./version-BDSD4qfI.mjs";
2
2
  import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-Bko7wge8.mjs";
3
3
 
4
4
  //#region src/embed.ts
@@ -82,12 +82,14 @@ function extractInitOptions(options) {
82
82
  readOnly: options.readOnly,
83
83
  depth: options.depth,
84
84
  capabilities: options.capabilities,
85
+ examples: options.examples,
85
86
  panels: options.panels,
86
87
  commentsByMachineId: options.commentsByMachineId,
87
88
  projectWorkspace: options.projectWorkspace,
88
89
  projectWorkspaceOpen: options.projectWorkspaceOpen,
89
90
  settings: options.settings,
90
- unsavedIndicator: options.unsavedIndicator
91
+ unsavedIndicator: options.unsavedIndicator,
92
+ versionAutoSave: options.versionAutoSave
91
93
  };
92
94
  if (options.machine !== void 0) return {
93
95
  machine: options.machine,
@@ -100,11 +102,13 @@ function extractInitOptions(options) {
100
102
  readOnlyReason: options.readOnlyReason,
101
103
  depth: options.depth,
102
104
  capabilities: options.capabilities,
105
+ examples: options.examples,
103
106
  panels: options.panels,
104
107
  comments: options.comments,
105
108
  sourceLocations: options.sourceLocations,
106
109
  settings: options.settings,
107
- unsavedIndicator: options.unsavedIndicator
110
+ unsavedIndicator: options.unsavedIndicator,
111
+ versionAutoSave: options.versionAutoSave
108
112
  };
109
113
  return null;
110
114
  }
@@ -288,6 +292,21 @@ function createStatelyEmbed(options) {
288
292
  });
289
293
  break;
290
294
  }
295
+ case "@statelyai.versionSaveRequested": {
296
+ const version = data;
297
+ const event = {
298
+ graph: version.graph,
299
+ machineConfig: version.machineConfig,
300
+ machineId: version.machineId,
301
+ patches: version.patches,
302
+ createdBy: version.createdBy,
303
+ captureType: version.captureType,
304
+ sourceLocations: version.sourceLocations
305
+ };
306
+ options.onVersionSaveRequested?.(event);
307
+ events.emit("versionSaveRequested", event);
308
+ break;
309
+ }
291
310
  case "@statelyai.project.machineSelected":
292
311
  events.emit("machineSelected", { machineId: String(data.machineId) });
293
312
  break;
@@ -1,4 +1,4 @@
1
- import { t as CodeExpression } from "./index-DuvCSThi.mjs";
1
+ import { t as CodeExpression } from "./index-DKRB-u93.mjs";
2
2
  import * as _statelyai_graph0 from "@statelyai/graph";
3
3
  import { Graph } from "@statelyai/graph";
4
4
 
package/dist/graph.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as studioMachineConverter, a as StatelyGraphData, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, n as StatelyActorImplementation, o as StatelyGuard, p as StudioEventTypeData, r as StatelyEdgeData, s as StatelyImplementation, t as StatelyAction, u as StatelyTagImplementation, v as toStudioMachine } from "./graph-BGUND7ZF.mjs";
1
+ import { _ as studioMachineConverter, a as StatelyGraphData, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, n as StatelyActorImplementation, o as StatelyGuard, p as StudioEventTypeData, r as StatelyEdgeData, s as StatelyImplementation, t as StatelyAction, u as StatelyTagImplementation, v as toStudioMachine } from "./graph-DoUReqxz.mjs";
2
2
  export { StatelyAction, StatelyActorImplementation, StatelyEdgeData, StatelyGraph, StatelyGraphData, StatelyGuard, StatelyImplementation, StatelyInvoke, StatelyNodeData, StatelyTagImplementation, StudioAction, StudioEdge, StudioEventTypeData, StudioMachine, StudioNode, fromStudioMachine, studioMachineConverter, toStudioMachine };
@@ -2199,6 +2199,7 @@ declare const graphPatchSchema: ZodDiscriminatedUnion<[ZodObject<{
2199
2199
  description: ZodOptional<ZodString>;
2200
2200
  initialId: ZodOptional<ZodNullable<ZodString>>;
2201
2201
  initialInput: ZodOptional<ZodUnknown>;
2202
+ output: ZodOptional<ZodUnknown>;
2202
2203
  timeout: ZodOptional<ZodUnknown>;
2203
2204
  route: ZodOptional<ZodUnknown>;
2204
2205
  }, $strip>;
@@ -2278,9 +2279,10 @@ declare const graphPatchSchema: ZodDiscriminatedUnion<[ZodObject<{
2278
2279
  final: "final";
2279
2280
  choice: "choice";
2280
2281
  }>>>;
2281
- stateDescription: ZodOptional<ZodString>;
2282
+ stateDescription: ZodOptional<ZodNullable<ZodString>>;
2282
2283
  initialId: ZodOptional<ZodNullable<ZodString>>;
2283
2284
  initialInput: ZodOptional<ZodUnknown>;
2285
+ output: ZodOptional<ZodUnknown>;
2284
2286
  timeout: ZodOptional<ZodUnknown>;
2285
2287
  route: ZodOptional<ZodUnknown>;
2286
2288
  color: ZodOptional<ZodNullable<ZodEnum<{
@@ -2339,7 +2341,7 @@ declare const graphPatchSchema: ZodDiscriminatedUnion<[ZodObject<{
2339
2341
  sourceId: ZodOptional<ZodString>;
2340
2342
  targetId: ZodOptional<ZodString>;
2341
2343
  eventType: ZodOptional<ZodString>;
2342
- matches: ZodOptional<ZodRecord<ZodString, ZodUnknown>>;
2344
+ matches: ZodOptional<ZodNullable<ZodRecord<ZodString, ZodUnknown>>>;
2343
2345
  transitionType: ZodOptional<ZodEnum<{
2344
2346
  normal: "normal";
2345
2347
  targetless: "targetless";
@@ -2434,11 +2436,11 @@ declare const graphPatchSchema: ZodDiscriminatedUnion<[ZodObject<{
2434
2436
  nodeId: ZodString;
2435
2437
  invokeId: ZodString;
2436
2438
  data: ZodObject<{
2437
- invocationId: ZodOptional<ZodString>;
2439
+ invocationId: ZodOptional<ZodNullable<ZodString>>;
2438
2440
  src: ZodOptional<ZodString>;
2439
2441
  srcExpression: ZodOptional<ZodUnknown>;
2440
- code: ZodOptional<ZodString>;
2441
- registryKey: ZodOptional<ZodString>;
2442
+ code: ZodOptional<ZodNullable<ZodString>>;
2443
+ registryKey: ZodOptional<ZodNullable<ZodString>>;
2442
2444
  timeout: ZodOptional<ZodUnknown>;
2443
2445
  input: ZodOptional<ZodUnknown>;
2444
2446
  output: ZodOptional<ZodUnknown>;
@@ -2474,7 +2476,7 @@ declare const graphPatchSchema: ZodDiscriminatedUnion<[ZodObject<{
2474
2476
  implementationId: ZodString;
2475
2477
  data: ZodObject<{
2476
2478
  name: ZodOptional<ZodString>;
2477
- code: ZodOptional<ZodString>;
2479
+ code: ZodOptional<ZodNullable<ZodString>>;
2478
2480
  }, $strip>;
2479
2481
  }, $strip>, ZodObject<{
2480
2482
  op: ZodLiteral<"deleteImplementation">;
@@ -2533,7 +2535,7 @@ declare const graphPatchSchema: ZodDiscriminatedUnion<[ZodObject<{
2533
2535
  }, $strip>, ZodObject<{
2534
2536
  op: ZodLiteral<"setContext">;
2535
2537
  description: ZodOptional<ZodString>;
2536
- context: ZodRecord<ZodString, ZodUnknown>;
2538
+ context: ZodNullable<ZodRecord<ZodString, ZodUnknown>>;
2537
2539
  }, $strip>, ZodObject<{
2538
2540
  op: ZodLiteral<"updateSchemas">;
2539
2541
  description: ZodOptional<ZodString>;
@@ -2945,6 +2947,8 @@ interface XStateTSOptions extends MachineConfigOptions {
2945
2947
  xstateV6SchemaFormat?: 'types' | 'zod';
2946
2948
  }
2947
2949
  declare function graphToXStateTS(graph: CodeGenGraph, options?: XStateTSOptions): string; //#endregion
2950
+ //#region src/emittedNodeIds.d.ts
2951
+ //#endregion
2948
2952
  //#region src/jsonSchemaToTSType.d.ts
2949
2953
  declare function jsonSchemaToTSType(schema: JSONSchema7 | undefined | null): string;
2950
2954
  /**
package/dist/index.d.mts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
2
- import { _ as GraphPatch, a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, f as raw, l as graphToMachineConfig, m as ActionLocation, n as CodeGenGraph, o as XStateTSOptions, p as serializeJS, r as MachineConfigOptions, s as contextSchemaToTSType, u as graphToXStateTS } from "./index-DuvCSThi.mjs";
3
- import { C as EventTypeData, S as DigraphNodeConfig, _ as studioMachineConverter, a as StatelyGraphData, b as DigraphConfig, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, o as StatelyGuard, r as StatelyEdgeData, t as StatelyAction, v as toStudioMachine, w as StateNodeJSONData, x as DigraphEdgeConfig, y as DigraphAction } from "./graph-BGUND7ZF.mjs";
4
- import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, ProjectEmbedMachine, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceProject, UploadResult, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
2
+ import { _ as GraphPatch, a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, f as raw, l as graphToMachineConfig, m as ActionLocation, n as CodeGenGraph, o as XStateTSOptions, p as serializeJS, r as MachineConfigOptions, s as contextSchemaToTSType, u as graphToXStateTS } from "./index-DKRB-u93.mjs";
3
+ import { C as EventTypeData, S as DigraphNodeConfig, _ as studioMachineConverter, a as StatelyGraphData, b as DigraphConfig, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, o as StatelyGuard, r as StatelyEdgeData, t as StatelyAction, v as toStudioMachine, w as StateNodeJSONData, x as DigraphEdgeConfig, y as DigraphAction } from "./graph-DoUReqxz.mjs";
4
+ import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExample, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, MachineVersionAutoSaveOptions, ProjectEmbedMachine, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceMachineOrigin, ProjectWorkspaceProject, UploadResult, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine } from "./protocol.mjs";
5
5
  import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
6
6
  import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-B0ZTKri2.mjs";
7
7
  import { c as fetchEditorSyncAccess, d as EditorHostInboundMessage, f as EditorHostInitOptions, i as EditorSyncBackend, l as EDITOR_PROTOCOL_VERSION, m as EditorHostValidationIssue, n as EditorHostSessionOptions, o as RemoteEditorSyncBackendOptions, p as EditorHostOutboundMessage, r as EditorSourceHost, s as createRemoteEditorSyncBackend, t as EditorHostSession, u as EditorHostExportFormat } from "./editorHostSession-DTXKcLhR.mjs";
8
8
  import { AssetConfig, EmbedEntity, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, EmbedProfileDefinition, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
9
9
  import { _ as createWebSocketTransport, a as InspectedTransition, c as InspectorDiscoveryEntry, d as ManualActorOptions, f as createInspector, g as createPostMessageTransport, h as TransportFailure, i as InspectedSnapshot, l as InspectorEvents, m as Transport, n as CreateInspectorOptions, o as Inspector, p as createStatelyInspector, r as InspectedEvent, s as InspectorConnection, t as AdoptedActor, u as InspectorInspectionEvent } from "./inspect-Br_vS_lK.mjs";
10
- import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-erXbdakn.mjs";
10
+ import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-B6P177N3.mjs";
11
11
  import { OAuthAuthorizationServerMetadata, OAuthClientRegistrationResponse, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
12
12
  import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
13
13
  import { CreateInspectionRelayOptions, InspectionRelay, InspectionRelayEffect, InspectionRelayPeer, InspectionRelayRole, InspectionRelaySnapshot, createInspectionRelay } from "./relay.mjs";
@@ -33,4 +33,4 @@ declare function findStatelyPragmaAttachments(sourceText: string, fileName?: str
33
33
  declare function getStatelyPragma(sourceText: string, fileName?: string, machineIndex?: number): StatelyPragma | undefined;
34
34
  declare function upsertStatelyPragma(sourceText: string, id: string, options?: UpsertStatelyPragmaOptions): string;
35
35
  //#endregion
36
- export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EditorHostExportFormat, type EditorHostInboundMessage, type EditorHostInitOptions, type EditorHostOutboundMessage, EditorHostSession, type EditorHostSessionOptions, type EditorHostValidationIssue, type EditorSourceHost, type EditorSyncBackend, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedFormatContext, type EmbedFormatDefinition, type EmbedGraph, type EmbedMode, type EmbedProfileDefinition, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorConnection, type InspectorDiscoveryEntry, type InspectorEvents, type InspectorInspectionEvent, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineConfigOptions, type MachineVersion, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceProject, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RemoteEditorSyncBackendOptions, type RepoType, type ResolvedSyncInput, type ResourceErrorCode, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyAuthMode, type StatelyCredential, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type VerifyResult, type XStateTSOptions, type XStateVersion, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
36
+ export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EditorHostExportFormat, type EditorHostInboundMessage, type EditorHostInitOptions, type EditorHostOutboundMessage, EditorHostSession, type EditorHostSessionOptions, type EditorHostValidationIssue, type EditorSourceHost, type EditorSyncBackend, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExample, type EmbedFormatContext, type EmbedFormatDefinition, type EmbedGraph, type EmbedMode, type EmbedProfileDefinition, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorConnection, type InspectorDiscoveryEntry, type InspectorEvents, type InspectorInspectionEvent, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineConfigOptions, type MachineVersion, type MachineVersionAutoSaveOptions, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceMachineOrigin, type ProjectWorkspaceProject, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RemoteEditorSyncBackendOptions, type RepoType, type ResolvedSyncInput, type ResourceErrorCode, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyAuthMode, type StatelyCredential, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type VerifyResult, type XStateTSOptions, type XStateVersion, assertEmbedExamples, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, isEmbedExample, isEmbedExampleMachine, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
1
  import "./openapi-BTDjYWXd.mjs";
2
- import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
3
- import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-BfcJU2pO.mjs";
2
+ import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine } from "./protocol.mjs";
3
+ import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-BDSD4qfI.mjs";
4
4
  import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-Bko7wge8.mjs";
5
5
  import { createStatelyEmbed } from "./embed.mjs";
6
6
  import { i as fetchEditorSyncAccess, r as createRemoteEditorSyncBackend, t as EditorHostSession } from "./editorHostSession-BwS-EiBJ.mjs";
7
7
  import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-iNSHtNmP.mjs";
8
- import { a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, l as graphToMachineConfig, m as serializeJS, n as getStatelyPragma, o as contextSchemaToTSType, p as raw, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-B-axv279.mjs";
8
+ import { a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, l as graphToMachineConfig, m as serializeJS, n as getStatelyPragma, o as contextSchemaToTSType, p as raw, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-CWxhEIcZ.mjs";
9
9
  import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
10
- import { n as createStatelyInspector, t as createInspector } from "./inspect-QlXh72hZ.mjs";
10
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-nZNCuv4E.mjs";
11
11
  import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
12
12
  import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
13
13
  import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
14
14
  import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
15
15
  import { createInspectionRelay } from "./relay.mjs";
16
16
 
17
- export { DEFAULT_STATELY_BASE_URL, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorHostSession, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
17
+ export { DEFAULT_STATELY_BASE_URL, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorHostSession, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, RawCode, StatelyApiError, StudioApiError, assertEmbedExamples, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, isEmbedExample, isEmbedExampleMachine, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
@@ -1,5 +1,5 @@
1
1
  import { INSPECTION_PROTOCOL_VERSION, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
2
- import { a as createEventRegistry, i as createWebSocketTransport, n as inspectionRuntime, o as createPendingExportManager, t as SDK_VERSION } from "./version-BfcJU2pO.mjs";
2
+ import { a as createEventRegistry, i as createWebSocketTransport, n as inspectionRuntime, o as createPendingExportManager, t as SDK_VERSION } from "./version-BDSD4qfI.mjs";
3
3
 
4
4
  //#region src/openBrowser.ts
5
5
  async function openBrowser(url) {
@@ -95,7 +95,10 @@ function createInspector(options = {}) {
95
95
  rejectReady = reject;
96
96
  });
97
97
  ready.catch(() => {});
98
+ const INIT_PLACEHOLDER = { __pendingInit: true };
99
+ const isInitPlaceholder = (message) => message === INIT_PLACEHOLDER;
98
100
  const pendingMessages = [];
101
+ let initQueueIndex = null;
99
102
  const events = createEventRegistry();
100
103
  const localListeners = {};
101
104
  const transport = injectedTransport ?? createWebSocketTransport({
@@ -110,8 +113,18 @@ function createInspector(options = {}) {
110
113
  });
111
114
  const ownsTransport = !injectedTransport;
112
115
  const exportManager = createPendingExportManager((message) => send(message));
116
+ /**
117
+ * Build the queued init payload now, so it captures the actor tree as it was
118
+ * before whatever is being queued next.
119
+ */
120
+ function materializePendingInit() {
121
+ if (initQueueIndex === null) return;
122
+ if (pendingMessages[initQueueIndex] !== INIT_PLACEHOLDER) return;
123
+ pendingMessages[initQueueIndex] = buildInitMessage();
124
+ }
113
125
  function send(msg) {
114
126
  if (!transport.ready) {
127
+ materializePendingInit();
115
128
  pendingMessages.push(msg);
116
129
  return;
117
130
  }
@@ -123,11 +136,14 @@ function createInspector(options = {}) {
123
136
  transportWasReady = true;
124
137
  if (!initSent) sendInit();
125
138
  const queued = pendingMessages.splice(0);
126
- for (const message of queued) transport.send(message);
139
+ initQueueIndex = null;
140
+ for (const message of queued) if (isInitPlaceholder(message)) transport.send(buildInitMessage());
141
+ else transport.send(message);
127
142
  readySettled = true;
128
143
  resolveReady();
129
144
  } else {
130
145
  pendingMessages.length = 0;
146
+ initQueueIndex = null;
131
147
  initSent = false;
132
148
  sendInit();
133
149
  }
@@ -292,11 +308,11 @@ function createInspector(options = {}) {
292
308
  }
293
309
  const inspectedRoots = /* @__PURE__ */ new Map();
294
310
  const observedRootIds = /* @__PURE__ */ new Set();
295
- function sendInit() {
311
+ function buildInitMessage() {
296
312
  for (const [rootActorId, { actor }] of inspectedRoots) backfillActorTree(actor, rootActorId);
297
313
  const allEntries = Array.from(actors.values());
298
314
  const selectedSessionId = configuredSelectedSessionId ?? selectedActorId ?? observedRootIds.values().next().value ?? allEntries[0]?.sessionId;
299
- send({
315
+ return {
300
316
  type: "@statelyai.system.init",
301
317
  protocolVersion: INSPECTION_PROTOCOL_VERSION,
302
318
  mode: "inspecting",
@@ -309,7 +325,13 @@ function createInspector(options = {}) {
309
325
  ...panels?.leftPanels && { leftPanels: panels.leftPanels },
310
326
  ...panels?.rightPanels && { rightPanels: panels.rightPanels },
311
327
  ...panels?.activePanels && { activePanels: panels.activePanels }
312
- });
328
+ };
329
+ }
330
+ function sendInit() {
331
+ if (!transport.ready) {
332
+ if (initQueueIndex === null) initQueueIndex = pendingMessages.push(INIT_PLACEHOLDER) - 1;
333
+ else if (pendingMessages[initQueueIndex] !== INIT_PLACEHOLDER) pendingMessages[initQueueIndex] = buildInitMessage();
334
+ } else transport.send(buildInitMessage());
313
335
  initSent = true;
314
336
  }
315
337
  function handleActor(actorRef, rootActorId, details) {
@@ -433,6 +455,7 @@ function createInspector(options = {}) {
433
455
  }
434
456
  function handleInspectionEvent(inspectionEvent) {
435
457
  if (destroyed) return;
458
+ materializePendingInit();
436
459
  const event = inspectionEvent;
437
460
  const rootActorId = rootSessionIdOf(event.rootId, event.actorRef);
438
461
  const isNewRoot = !observedRootIds.has(rootActorId);
@@ -484,6 +507,7 @@ function createInspector(options = {}) {
484
507
  const rootActorId = sessionIdOf(root);
485
508
  const existing = inspectedRoots.get(rootActorId);
486
509
  if (existing) return existing.subscription;
510
+ materializePendingInit();
487
511
  resolveActorTreeSessionIds(root);
488
512
  observedRootIds.add(rootActorId);
489
513
  const subscription = root.system.inspect(handleInspectionEvent);
@@ -521,7 +545,7 @@ function createInspector(options = {}) {
521
545
  machineConfig: opts?.machine ?? null
522
546
  };
523
547
  actors.set(sessionId, entry);
524
- if (!initSent) sendInit();
548
+ if (!initSent || !transport.ready) sendInit();
525
549
  else send({
526
550
  type: "@statelyai.system.actorRegistered",
527
551
  sessionId,
@@ -535,6 +559,7 @@ function createInspector(options = {}) {
535
559
  function manualSnapshot(actorId, snapshot, event) {
536
560
  const sessionId = getManualSessionId(actorId);
537
561
  if (!actors.has(sessionId)) manualRegister(actorId);
562
+ materializePendingInit();
538
563
  const entry = actors.get(sessionId);
539
564
  const previousSnapshot = entry.snapshot;
540
565
  const inspectedSnapshot = {
@@ -566,12 +591,14 @@ function createInspector(options = {}) {
566
591
  const eventObj = typeof event === "string" ? { type: event } : { ...event };
567
592
  const sessionId = getManualSessionId(actorId);
568
593
  if (!actors.has(sessionId)) manualRegister(actorId);
594
+ materializePendingInit();
569
595
  handleEvent(sessionId, eventObj, eventOpts?.source ? getManualSessionId(eventOpts.source) : null);
570
596
  }
571
597
  function manualStop(actorId) {
572
598
  const sessionId = getManualSessionId(actorId);
573
599
  const entry = actors.get(sessionId);
574
600
  if (!entry || entry.stopped) return;
601
+ materializePendingInit();
575
602
  entry.stopped = true;
576
603
  if (initSent) send({
577
604
  type: "@statelyai.system.actorStopped",
@@ -634,6 +661,7 @@ function createInspector(options = {}) {
634
661
  observedRootIds.clear();
635
662
  pendingTransitions.clear();
636
663
  pendingMessages.length = 0;
664
+ initQueueIndex = null;
637
665
  for (const set of Object.values(localListeners)) set?.clear();
638
666
  }
639
667
  };
package/dist/inspect.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import "./version-BfcJU2pO.mjs";
2
- import { n as createStatelyInspector, t as createInspector } from "./inspect-QlXh72hZ.mjs";
1
+ import "./version-BDSD4qfI.mjs";
2
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-nZNCuv4E.mjs";
3
3
 
4
4
  export { createInspector, createStatelyInspector };
@@ -1,2 +1,2 @@
1
- import { _ as GraphPatch, g as EditorStateType, h as CanvasColor, m as ActionLocation, v as ImplementationSourceType } from "./index-DuvCSThi.mjs";
1
+ import { _ as GraphPatch, g as EditorStateType, h as CanvasColor, m as ActionLocation, v as ImplementationSourceType } from "./index-DKRB-u93.mjs";
2
2
  export { type ActionLocation, type CanvasColor, type EditorStateType, type GraphPatch, type ImplementationSourceType };
@@ -1,5 +1,5 @@
1
- import { i as ProfileManifest } from "./index-DuvCSThi.mjs";
2
- import { i as StatelyGraph } from "./graph-BGUND7ZF.mjs";
1
+ import { i as ProfileManifest } from "./index-DKRB-u93.mjs";
2
+ import { i as StatelyGraph } from "./graph-DoUReqxz.mjs";
3
3
  import { c as EditorSyncSourceLocation, f as MachineSourceLocations$1, l as EditorSyncSourceRange, t as EditorCapabilities$1, u as EditorSyncStateSourceLocation } from "./editor-sync-types-C-zWaaVk.mjs";
4
4
 
5
5
  //#region src/protocol.d.ts
@@ -37,6 +37,9 @@ interface ProjectEmbedMachine {
37
37
  name?: string;
38
38
  /** Optional host project scope for machine-to-machine references. */
39
39
  projectId?: string;
40
+ createdAt?: number;
41
+ updatedAt?: number;
42
+ origin?: ProjectWorkspaceMachineOrigin;
40
43
  machine: unknown;
41
44
  }
42
45
  type ProjectWorkspaceActionIcon = 'arrow-left' | 'copy' | 'fork' | 'history';
@@ -46,9 +49,33 @@ interface ProjectWorkspaceAction {
46
49
  icon?: ProjectWorkspaceActionIcon;
47
50
  disabled?: boolean;
48
51
  }
52
+ interface ProjectWorkspaceMachineOrigin {
53
+ parentMachineId: string;
54
+ type: 'version' | 'fork';
55
+ createdBy?: {
56
+ type: string;
57
+ id?: string;
58
+ name?: string;
59
+ };
60
+ captureType?: string;
61
+ }
62
+ /** Opt-in host-facing automatic version capture policy. */
63
+ interface MachineVersionAutoSaveOptions {
64
+ /** Minimum time between automatic versions, in milliseconds. */
65
+ intervalMs: number;
66
+ createdBy?: {
67
+ type: string;
68
+ id?: string;
69
+ name?: string;
70
+ };
71
+ captureType?: string;
72
+ }
49
73
  interface ProjectWorkspaceMachine {
50
74
  id: string;
51
75
  name?: string;
76
+ createdAt?: number;
77
+ updatedAt?: number;
78
+ origin?: ProjectWorkspaceMachineOrigin;
52
79
  }
53
80
  interface ProjectWorkspaceProject {
54
81
  id: string;
@@ -60,6 +87,8 @@ interface ProjectWorkspaceProject {
60
87
  interface ProjectWorkspaceCapabilities {
61
88
  renameProject?: ProjectWorkspaceAction;
62
89
  createMachine?: ProjectWorkspaceAction;
90
+ createMachineVersion?: ProjectWorkspaceAction;
91
+ restoreMachineVersion?: ProjectWorkspaceAction;
63
92
  renameMachine?: ProjectWorkspaceAction;
64
93
  copyMachine?: ProjectWorkspaceAction;
65
94
  deleteMachine?: ProjectWorkspaceAction;
@@ -81,7 +110,7 @@ interface ProjectWorkspaceConfigBase {
81
110
  }
82
111
  /** Serializable workspace tree rendered by project-mode embeds. */
83
112
  type ProjectWorkspaceConfig = (ProjectWorkspaceConfigBase & {
84
- /** Single-project mode: hides project CRUD and flattens its machines. */project: ProjectWorkspaceProject;
113
+ /** Single-project mode: hides project CRUD for this project. */project: ProjectWorkspaceProject;
85
114
  projects?: never;
86
115
  }) | (ProjectWorkspaceConfigBase & {
87
116
  /** Multi-project mode: renders a collapsible project tree. */projects: ProjectWorkspaceProject[];
@@ -209,6 +238,15 @@ interface EmbedEventMap {
209
238
  validations?: ValidationIssue[];
210
239
  sourceLocations?: MachineSourceLocations;
211
240
  };
241
+ versionSaveRequested: {
242
+ graph: StatelyGraph;
243
+ machineConfig: unknown;
244
+ machineId?: string;
245
+ patches?: unknown[];
246
+ createdBy: NonNullable<MachineVersionAutoSaveOptions['createdBy']>;
247
+ captureType: string;
248
+ sourceLocations?: MachineSourceLocations;
249
+ };
212
250
  error: {
213
251
  code: string;
214
252
  message: string;
@@ -255,6 +293,20 @@ interface EmbedExtensionsManifest {
255
293
  defaultProfile?: string;
256
294
  defaultFormat?: string;
257
295
  }
296
+ /** Host-provided examples shown in the editor's Get started launchpad. */
297
+ interface EmbedExample {
298
+ id: string;
299
+ title: string;
300
+ description: string;
301
+ category: string;
302
+ machine: unknown;
303
+ }
304
+ /** Check whether an example machine has a shape supported by the editor. */
305
+ declare function isEmbedExampleMachine(value: unknown): value is Record<string, unknown>;
306
+ /** Check whether an unknown value is a valid serialized embed example. */
307
+ declare function isEmbedExample(value: unknown): value is EmbedExample;
308
+ /** Reject malformed host-provided examples before creating an init message. */
309
+ declare function assertEmbedExamples(examples: readonly EmbedExample[] | undefined): void;
258
310
  interface MachineInitOptions {
259
311
  machine: unknown;
260
312
  /** Ephemeral, read-only reference documents owned by the embed host. */
@@ -267,6 +319,7 @@ interface MachineInitOptions {
267
319
  readOnlyReason?: ReadOnlyReason;
268
320
  depth?: number;
269
321
  capabilities?: EditorCapabilities;
322
+ examples?: readonly EmbedExample[];
270
323
  panels?: {
271
324
  leftPanels?: string[];
272
325
  rightPanels?: string[];
@@ -291,6 +344,8 @@ interface MachineInitOptions {
291
344
  enabled?: boolean;
292
345
  mode?: 'structural' | 'all';
293
346
  };
347
+ /** Omit to disable automatic version requests. */
348
+ versionAutoSave?: MachineVersionAutoSaveOptions;
294
349
  }
295
350
  interface ProjectInitOptions {
296
351
  machines: ProjectEmbedMachine[];
@@ -302,6 +357,7 @@ interface ProjectInitOptions {
302
357
  readOnly?: boolean;
303
358
  depth?: number;
304
359
  capabilities?: EditorCapabilities;
360
+ examples?: readonly EmbedExample[];
305
361
  panels?: {
306
362
  leftPanels?: string[];
307
363
  rightPanels?: string[];
@@ -315,6 +371,8 @@ interface ProjectInitOptions {
315
371
  enabled?: boolean;
316
372
  mode?: 'structural' | 'all';
317
373
  };
374
+ /** Omit to disable automatic version requests. */
375
+ versionAutoSave?: MachineVersionAutoSaveOptions;
318
376
  }
319
377
  type InitOptions = MachineInitOptions | ProjectInitOptions;
320
378
  interface InitMessage {
@@ -329,6 +387,7 @@ interface InitMessage {
329
387
  readOnlyReason?: ReadOnlyReason;
330
388
  depth?: number;
331
389
  capabilities?: EditorCapabilities;
390
+ examples?: readonly EmbedExample[];
332
391
  leftPanels?: string[];
333
392
  rightPanels?: string[];
334
393
  activePanels?: string[];
@@ -340,6 +399,7 @@ interface InitMessage {
340
399
  enabled?: boolean;
341
400
  mode?: 'structural' | 'all';
342
401
  };
402
+ versionAutoSave?: MachineVersionAutoSaveOptions;
343
403
  }
344
404
  interface SetApiKeyMessage {
345
405
  type: '@statelyai.setApiKey';
@@ -378,6 +438,7 @@ interface ProjectInitMessage {
378
438
  readOnly?: boolean;
379
439
  depth?: number;
380
440
  capabilities?: EditorCapabilities;
441
+ examples?: readonly EmbedExample[];
381
442
  leftPanels?: string[];
382
443
  rightPanels?: string[];
383
444
  activePanels?: string[];
@@ -389,6 +450,7 @@ interface ProjectInitMessage {
389
450
  enabled?: boolean;
390
451
  mode?: 'structural' | 'all';
391
452
  };
453
+ versionAutoSave?: MachineVersionAutoSaveOptions;
392
454
  sessionId?: string;
393
455
  }
394
456
  interface ProjectUpdateMessage {
@@ -575,6 +637,16 @@ interface SaveMessage {
575
637
  validations?: ValidationIssue[];
576
638
  sourceLocations?: MachineSourceLocations;
577
639
  }
640
+ interface VersionSaveRequestedMessage {
641
+ type: '@statelyai.versionSaveRequested';
642
+ graph: StatelyGraph;
643
+ machineConfig: unknown;
644
+ machineId?: string;
645
+ patches?: unknown[];
646
+ createdBy: NonNullable<MachineVersionAutoSaveOptions['createdBy']>;
647
+ captureType: string;
648
+ sourceLocations?: MachineSourceLocations;
649
+ }
578
650
  interface ProjectMachineSelectedMessage {
579
651
  type: '@statelyai.project.machineSelected';
580
652
  machineId: string;
@@ -665,7 +737,7 @@ interface ExtensionResultMessage {
665
737
  /** All messages a client (embed/inspector) can send to the viz. */
666
738
  type ClientMessage = InitMessage | SetApiKeyMessage | EditorHandshakeMessage | SavedMessage | ClipboardReadResponseMessage | ClipboardWriteResponseMessage | ProjectInitMessage | ProjectUpdateMessage | ProjectSelectMachineMessage | ProjectSetWorkspaceOpenMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | SystemInitMessage | SystemSelectActorMessage | SystemActorRegisteredMessage | SystemActorEventMessage | SystemActorSnapshotMessage | SystemActorStoppedMessage | UploadCapabilitiesMessage | UploadResponseMessage | ExtensionResultMessage | ErrorMessage;
667
739
  /** All messages the viz can send back to a client. */
668
- type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | ProjectMachineSelectedMessage | ProjectWorkspaceActionMessage | ProjectWorkspaceOpenChangedMessage | ViewModeChangedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | ClipboardReadMessage | ClipboardWriteMessage | UploadRequestMessage | ExtensionCallMessage;
740
+ type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | VersionSaveRequestedMessage | ProjectMachineSelectedMessage | ProjectWorkspaceActionMessage | ProjectWorkspaceOpenChangedMessage | ViewModeChangedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | ClipboardReadMessage | ClipboardWriteMessage | UploadRequestMessage | ExtensionCallMessage;
669
741
  interface InspectionClientMetadata {
670
742
  name?: string;
671
743
  machineId?: string;
@@ -694,4 +766,4 @@ declare const PREFIX = "@statelyai.";
694
766
  /** Current WebSocket inspection protocol version. */
695
767
  declare const INSPECTION_PROTOCOL_VERSION = 2;
696
768
  //#endregion
697
- 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, EmbedExtensionsManifest, EmbedFormatManifest, EmbedMode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, ExtensionCallMessage, ExtensionResultMessage, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitMessage, InitOptions, InspectSnapshotMessage, InspectionAction, InspectionClientMetadata, InspectionRoomUrls, InspectionSentEvent, InspectionTakenTransition, LoadedMessage, MachineInitOptions, MachineSourceLocations, PREFIX, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectSetWorkspaceOpenMessage, ProjectUpdateMessage, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceActionMessage, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, 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, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, ViewModeChangedMessage, VizMessage, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId };
769
+ 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, 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, PREFIX, 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, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VersionSaveRequestedMessage, ViewModeChangedMessage, VizMessage, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine };
package/dist/protocol.mjs CHANGED
@@ -52,9 +52,36 @@ const EMBED_DOCUMENT_LIMITS = {
52
52
  maxDocumentLength: 512 * 1024,
53
53
  maxTotalLength: 2 * 1024 * 1024
54
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
+ }
55
82
  const PREFIX = "@statelyai.";
56
83
  /** Current WebSocket inspection protocol version. */
57
84
  const INSPECTION_PROTOCOL_VERSION = 2;
58
85
 
59
86
  //#endregion
60
- export { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, PREFIX, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId };
87
+ export { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, PREFIX, assertEmbedExamples, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine };
@@ -1,6 +1,5 @@
1
1
  import { a as discriminatedUnion, c as object, d as union, f as unknown, i as custom, l as record, n as array, o as literal, r as boolean, s as number, t as _enum, u as string } from "./openapi-BTDjYWXd.mjs";
2
2
  import ts from "typescript";
3
- import "xstate";
4
3
  import "xstate/graph";
5
4
 
6
5
  //#region ../../node_modules/.pnpm/js-yaml@4.2.0/node_modules/js-yaml/dist/js-yaml.mjs
@@ -1,4 +1,4 @@
1
- import { A as output, C as ZodNumber, D as ZodString, E as ZodRecord, O as ZodUnion, S as ZodNullable, T as ZodOptional, b as ZodEnum, j as $strip, k as ZodUnknown, w as ZodObject, x as ZodLiteral, y as ZodArray } from "./index-DuvCSThi.mjs";
1
+ import { A as output, C as ZodNumber, D as ZodString, E as ZodRecord, O as ZodUnion, S as ZodNullable, T as ZodOptional, b as ZodEnum, j as $strip, k as ZodUnknown, w as ZodObject, x as ZodLiteral, y as ZodArray } from "./index-DKRB-u93.mjs";
2
2
  import { n as StatelyCredential, t as StatelyAuthMode } from "./auth-B0ZTKri2.mjs";
3
3
 
4
4
  //#region ../api-contract/dist/errors.d.mts
package/dist/studio.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, p as LegacyExtractMachinesOptions, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-erXbdakn.mjs";
1
+ import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, p as LegacyExtractMachinesOptions, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-B6P177N3.mjs";
2
2
  export { ConnectedRepo, CreateMachineFromDefinitionInput, CreateMachineFromTemplateInput, CreateMachineInput, CreateMachineTemplate, CreateProjectInput, DEFAULT_STATELY_BASE_URL, EnsureProjectInput, ExtractMachinesInput, ExtractMachinesResponse, ExtractedMachine, ExtractedMachines, GetMachineOptions, LegacyExtractMachinesOptions, LegacyProjectVisibility, LegacyUpdateMachineInput, Machine, MachineVersion, Project, ProjectData, ProjectMachine, ProjectMachineSummary, ProjectSummary, ProjectVisibility, RepoType, ResourceErrorCode, StudioApiError, StudioApiErrorOptions, StudioClient, StudioClientOptions, StudioMachineRecord, StudioRequestOptions, UpdateMachineInput, UpdateProjectInput, VerifyApiKeyResponse, VerifyResult, XStateVersion, createStatelyClient };
package/dist/sync.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { b as DigraphConfig, i as StatelyGraph } from "./graph-BGUND7ZF.mjs";
2
- import { C as StudioMachineRecord, L as XStateVersion, g as ProjectData, o as CreateProjectInput, x as StudioClient } from "./studio-erXbdakn.mjs";
1
+ import { b as DigraphConfig, i as StatelyGraph } from "./graph-DoUReqxz.mjs";
2
+ import { C as StudioMachineRecord, L as XStateVersion, g as ProjectData, o as CreateProjectInput, x as StudioClient } from "./studio-B6P177N3.mjs";
3
3
  import { GraphDiff } from "@statelyai/graph";
4
4
 
5
5
  //#region src/sync.d.ts
package/dist/sync.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./openapi-BTDjYWXd.mjs";
2
2
  import { r as createStatelyClient } from "./studio-iNSHtNmP.mjs";
3
- import { f as normalizeMachineProfile, h as xstateSourceToConfig, i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as serializeJS, n as getStatelyPragma, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-B-axv279.mjs";
3
+ import { f as normalizeMachineProfile, h as xstateSourceToConfig, i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as serializeJS, n as getStatelyPragma, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-CWxhEIcZ.mjs";
4
4
  import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
5
5
  import * as ts$1 from "typescript";
6
6
  import ts from "typescript";
@@ -1,4 +1,4 @@
1
- import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, PREFIX } from "./protocol.mjs";
1
+ import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, PREFIX, assertEmbedExamples } from "./protocol.mjs";
2
2
 
3
3
  //#region src/clientUtils.ts
4
4
  const embedDocumentLanguages = new Set(EMBED_DOCUMENT_LANGUAGES);
@@ -113,6 +113,7 @@ function createPendingExportManager(sendRetrieve) {
113
113
  }
114
114
  function toInitMessage(options) {
115
115
  assertEmbedDocuments(options.documents);
116
+ assertEmbedExamples(options.examples);
116
117
  if ("machines" in options) return {
117
118
  type: "@statelyai.project.init",
118
119
  machines: options.machines,
@@ -123,6 +124,7 @@ function toInitMessage(options) {
123
124
  readOnly: options.readOnly,
124
125
  depth: options.depth,
125
126
  capabilities: options.capabilities,
127
+ examples: options.examples,
126
128
  leftPanels: options.panels?.leftPanels,
127
129
  rightPanels: options.panels?.rightPanels,
128
130
  activePanels: options.panels?.activePanels,
@@ -130,7 +132,8 @@ function toInitMessage(options) {
130
132
  projectWorkspace: options.projectWorkspace,
131
133
  projectWorkspaceOpen: options.projectWorkspaceOpen,
132
134
  settings: options.settings,
133
- unsavedIndicator: options.unsavedIndicator
135
+ unsavedIndicator: options.unsavedIndicator,
136
+ versionAutoSave: options.versionAutoSave
134
137
  };
135
138
  return {
136
139
  type: "@statelyai.init",
@@ -144,13 +147,15 @@ function toInitMessage(options) {
144
147
  readOnlyReason: options.readOnlyReason,
145
148
  depth: options.depth,
146
149
  capabilities: options.capabilities,
150
+ examples: options.examples,
147
151
  leftPanels: options.panels?.leftPanels,
148
152
  rightPanels: options.panels?.rightPanels,
149
153
  activePanels: options.panels?.activePanels,
150
154
  comments: options.comments,
151
155
  sourceLocations: options.sourceLocations,
152
156
  settings: options.settings,
153
- unsavedIndicator: options.unsavedIndicator
157
+ unsavedIndicator: options.unsavedIndicator,
158
+ versionAutoSave: options.versionAutoSave
154
159
  };
155
160
  }
156
161
 
@@ -333,7 +338,7 @@ function createWebSocketTransport(options) {
333
338
 
334
339
  //#endregion
335
340
  //#region src/version.ts
336
- const SDK_VERSION = "0.25.0";
341
+ const SDK_VERSION = "0.26.1";
337
342
  function inspectionRuntime() {
338
343
  if (typeof window !== "undefined") return "browser";
339
344
  if (typeof process !== "undefined" && process.versions?.node) return "node";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/sdk",
3
- "version": "0.25.0",
3
+ "version": "0.26.1",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "stately-sdk": "./dist/bin.mjs"
@@ -93,8 +93,8 @@
93
93
  "jsdom": "^27.4.0",
94
94
  "tsdown": "0.21.0-beta.2",
95
95
  "vitest": "^3.2.4",
96
- "@statelyai/api-contract": "0.3.9",
97
- "@statelyai/graph-tools": "0.3.0"
96
+ "@statelyai/api-contract": "0.3.11",
97
+ "@statelyai/graph-tools": "0.4.0"
98
98
  },
99
99
  "engines": {
100
100
  "node": ">=22.4"