@statelyai/sdk 0.26.0 → 0.26.2

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,11 @@ 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
+
62
67
  <!-- Embed version configuration and events from src/embed.ts and src/protocol.ts -->
63
68
 
64
69
  Automatic version capture is opt-in. Pass `versionAutoSave: { intervalMs }` to
@@ -73,9 +78,9 @@ Restrict an embed by passing a resolved access policy:
73
78
  ```ts
74
79
  embed.init({
75
80
  machine: myMachineConfig,
76
- mode: 'viewing',
81
+ mode: "viewing",
77
82
  readOnly: true,
78
- readOnlyReason: 'free-plan',
83
+ readOnlyReason: "free-plan",
79
84
  capabilities: {
80
85
  edit: false,
81
86
  export: false,
@@ -83,11 +88,11 @@ embed.init({
83
88
  simulate: false,
84
89
  navigateHierarchy: false,
85
90
  maxDepth: 1,
86
- panels: ['structure', 'details', 'validations'],
91
+ panels: ["structure", "details", "validations"],
87
92
  },
88
93
  });
89
94
 
90
- embed.on('capabilityDenied', (event) => {
95
+ embed.on("capabilityDenied", (event) => {
91
96
  console.warn(event.message);
92
97
  });
93
98
  ```
@@ -108,6 +113,9 @@ Sync HTTP contract.
108
113
  Remote authentication failures are surfaced as `EditorSyncError` with HTTP
109
114
  status and protocol error code metadata so hosts can refresh credentials and
110
115
  retry once without depending on response-message text.
116
+ Source write and refresh failures include an `EditorHostDiagnostic` with a
117
+ unique diagnostic ID, phase, and structured details so host logs can be shared
118
+ without exposing source text by default.
111
119
  Hosts keep ownership of files, credentials, UI, and transport adapters.
112
120
 
113
121
  <!-- supported editor export formats from packages/editor/src/formatConfig.ts -->
@@ -132,17 +140,17 @@ Programmatic access to hosted Stately resources, credential verification, and
132
140
  deterministic machine-config extraction.
133
141
 
134
142
  ```ts
135
- import { createStatelyClient } from '@statelyai/sdk';
143
+ import { createStatelyClient } from "@statelyai/sdk";
136
144
 
137
145
  const studio = createStatelyClient({
138
146
  credential: {
139
- type: 'oauth',
147
+ type: "oauth",
140
148
  accessToken: process.env.STATELY_ACCESS_TOKEN!,
141
149
  },
142
150
  });
143
151
 
144
152
  const projects = await studio.projects.list();
145
- const machine = await studio.machines.get('machine-id');
153
+ const machine = await studio.machines.get("machine-id");
146
154
  const extracted = await studio.code.extractMachines({
147
155
  code: sourceCode,
148
156
  });
@@ -201,8 +209,8 @@ Stream live actor-system state to the hosted Stately inspector. Zero-config
201
209
  inspection needs no API key or local relay.
202
210
 
203
211
  ```ts
204
- import { createActor } from 'xstate';
205
- import { createInspector } from '@statelyai/sdk';
212
+ import { createActor } from "xstate";
213
+ import { createInspector } from "@statelyai/sdk";
206
214
 
207
215
  const inspector = createInspector();
208
216
  const { inspect } = inspector;
@@ -220,8 +228,7 @@ JSON-safe machine structure:
220
228
 
221
229
  ```ts
222
230
  const inspector = createInspector({
223
- extractMachine: (actor) =>
224
- actor.logic === machine ? machineSource : actor.logic?.config,
231
+ extractMachine: (actor) => (actor.logic === machine ? machineSource : actor.logic?.config),
225
232
  });
226
233
  ```
227
234
 
@@ -328,7 +335,7 @@ A fully self-contained deployment with no external auth looks like:
328
335
 
329
336
  ```ts
330
337
  const embed = createStatelyEmbed({
331
- baseUrl: 'https://your-editor.example.com',
338
+ baseUrl: "https://your-editor.example.com",
332
339
  });
333
340
  ```
334
341
 
@@ -340,8 +347,8 @@ npx @statelyai/sdk relay
340
347
 
341
348
  ```ts
342
349
  const inspector = createInspector({
343
- url: 'ws://localhost:4242',
344
- inspectorBaseUrl: 'http://localhost:3000/inspect',
350
+ url: "ws://localhost:4242",
351
+ inspectorBaseUrl: "http://localhost:3000/inspect",
345
352
  });
346
353
  ```
347
354
 
@@ -106,6 +106,16 @@ const editorSyncAccessResponseSchema = object({ access: editorSyncAccessSchema }
106
106
 
107
107
  //#endregion
108
108
  //#region src/editorHostSession.ts
109
+ let diagnosticSequence = 0;
110
+ function createDiagnostic(code, phase, details) {
111
+ return {
112
+ id: `stately-${Date.now().toString(36)}-${(++diagnosticSequence).toString(36)}`,
113
+ code,
114
+ phase,
115
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
116
+ ...details ? { details } : {}
117
+ };
118
+ }
109
119
  var EditorSyncError = class extends Error {
110
120
  status;
111
121
  code;
@@ -255,14 +265,12 @@ var EditorHostSession = class {
255
265
  await this.save(message);
256
266
  } catch (error) {
257
267
  const text = formatError(error, "Failed to apply Viz changes.");
258
- this.options.send({
259
- type: "@statelyai.toast",
260
- message: text,
261
- toastType: "error"
262
- });
263
- this.options.showError?.(text);
268
+ this.reportSourceSyncError(text, "save", { errorName: error instanceof Error ? error.name : void 0 }, message.requestId);
264
269
  }
265
270
  break;
271
+ case "@statelyai.refresh":
272
+ await this.handleSavedDocument(this.options.source.rootUri);
273
+ break;
266
274
  case "@statelyai.retrieved":
267
275
  this.resolveRetrieved(message.requestId, message.data);
268
276
  break;
@@ -275,7 +283,7 @@ var EditorHostSession = class {
275
283
  break;
276
284
  }
277
285
  }
278
- this.options.showError?.(message.message);
286
+ this.options.showError?.(message.diagnostic ? `${message.message} (diagnostic ${message.diagnostic.id})` : message.message);
279
287
  break;
280
288
  case "@statelyai.clipboardRead": {
281
289
  let text = "";
@@ -367,6 +375,7 @@ var EditorHostSession = class {
367
375
  this.lastPersistedGraph = message.graph;
368
376
  this.options.send({
369
377
  type: "@statelyai.saved",
378
+ ...message.requestId ? { requestId: message.requestId } : {},
370
379
  graph: message.graph
371
380
  });
372
381
  return;
@@ -387,13 +396,12 @@ var EditorHostSession = class {
387
396
  preserveStatelyMetadata: this.options.source.getPreserveStatelyMetadata?.(this.options.source.rootUri) ?? true
388
397
  });
389
398
  if (response.replacements.length === 0) {
390
- const text = "Unable to apply Viz changes to the source file automatically.";
391
- this.options.send({
392
- type: "@statelyai.toast",
393
- message: text,
394
- toastType: "error"
395
- });
396
- this.options.showError?.(text);
399
+ this.reportSourceSyncError("Could not write visual changes to the source file. Your visual edits are still unsaved.", "save", {
400
+ reason: "no_replacements",
401
+ patchCount: message.patches?.length ?? 0,
402
+ profile: this.currentSourceLocations?.profileRef ?? this.currentSourceLocations?.profile,
403
+ sourceFile: this.options.source.rootFileName.split(/[\\/]/).pop()
404
+ }, message.requestId);
397
405
  return;
398
406
  }
399
407
  this.selfEditCount++;
@@ -407,6 +415,7 @@ var EditorHostSession = class {
407
415
  this.lastPersistedGraph = message.graph;
408
416
  this.options.send({
409
417
  type: "@statelyai.saved",
418
+ ...message.requestId ? { requestId: message.requestId } : {},
410
419
  graph: message.graph
411
420
  });
412
421
  }
@@ -432,9 +441,32 @@ var EditorHostSession = class {
432
441
  sourceLocations: update.sourceLocations
433
442
  });
434
443
  } catch (error) {
435
- this.options.showError?.(formatError(error, "Failed to read the saved document."));
444
+ this.reportSourceSyncError(formatError(error, "Failed to read the saved document."), "update", {
445
+ errorName: error instanceof Error ? error.name : void 0,
446
+ sourceFile: this.options.source.rootFileName.split(/[\\/]/).pop()
447
+ });
436
448
  }
437
449
  }
450
+ reportSourceSyncError(message, phase, details, requestId) {
451
+ const diagnostic = createDiagnostic(phase === "save" ? "source_sync_failed" : "source_update_failed", phase, {
452
+ protocolVersion: EDITOR_PROTOCOL_VERSION,
453
+ client: this.options.client,
454
+ ...details
455
+ });
456
+ this.options.send({
457
+ type: "@statelyai.error",
458
+ code: diagnostic.code,
459
+ message,
460
+ diagnostic,
461
+ ...requestId ? { requestId } : {}
462
+ });
463
+ this.options.send({
464
+ type: "@statelyai.toast",
465
+ message: phase === "save" ? "Visual changes were not written to the source file." : "The source file could not be applied to the visual editor.",
466
+ toastType: "error"
467
+ });
468
+ this.options.showError?.(`${message} (diagnostic ${diagnostic.id})`);
469
+ }
438
470
  updateWatchedSourceUris(sourceLocations) {
439
471
  this.watchedSourceUris.clear();
440
472
  for (const uri of stateSourceLocationUris(sourceLocations)) if (uri !== this.options.source.rootUri) this.watchedSourceUris.add(uri);
@@ -2,6 +2,13 @@ import { a as EditorSyncParseRequest, d as EditorSyncTextReplacement, f as Machi
2
2
 
3
3
  //#region src/editorHostProtocol.d.ts
4
4
  declare const EDITOR_PROTOCOL_VERSION = 1;
5
+ type EditorHostDiagnostic = {
6
+ id: string;
7
+ code: string;
8
+ phase: 'initialize' | 'save' | 'update' | 'export';
9
+ timestamp: string;
10
+ details?: Record<string, unknown>;
11
+ };
5
12
  type EditorHostExportFormat = 'xstate-v6' | 'xstate' | 'async' | 'xstate-json' | 'xgraph' | 'digraph' | 'd2' | 'mermaid' | 'redux' | 'zustand' | 'asl-json' | 'asl-yaml' | 'scxml';
6
13
  interface EditorHostValidationIssue {
7
14
  nodeIds: string[];
@@ -25,11 +32,14 @@ type EditorHostInboundMessage = {
25
32
  sourceLocations?: MachineSourceLocations;
26
33
  } | {
27
34
  type: '@statelyai.save';
35
+ requestId?: string;
28
36
  graph: unknown;
29
37
  machineConfig: unknown;
30
38
  patches?: unknown[];
31
39
  validations?: EditorHostValidationIssue[];
32
40
  sourceLocations?: MachineSourceLocations;
41
+ } | {
42
+ type: '@statelyai.refresh';
33
43
  } | {
34
44
  type: '@statelyai.retrieved';
35
45
  requestId: string;
@@ -39,6 +49,7 @@ type EditorHostInboundMessage = {
39
49
  code: string;
40
50
  message: string;
41
51
  requestId?: string;
52
+ diagnostic?: EditorHostDiagnostic;
42
53
  } | {
43
54
  type: '@statelyai.clipboardRead';
44
55
  requestId: string;
@@ -92,6 +103,7 @@ type EditorHostOutboundMessage = {
92
103
  sourceLocations?: MachineSourceLocations;
93
104
  } | {
94
105
  type: '@statelyai.saved';
106
+ requestId?: string;
95
107
  graph: unknown;
96
108
  } | {
97
109
  type: '@statelyai.retrieve';
@@ -105,6 +117,8 @@ type EditorHostOutboundMessage = {
105
117
  type: '@statelyai.error';
106
118
  code: string;
107
119
  message: string;
120
+ requestId?: string;
121
+ diagnostic?: EditorHostDiagnostic;
108
122
  } | {
109
123
  type: '@statelyai.clipboardReadResponse';
110
124
  requestId: string;
@@ -185,10 +199,11 @@ declare class EditorHostSession {
185
199
  private initialize;
186
200
  private save;
187
201
  private handleSavedDocument;
202
+ private reportSourceSyncError;
188
203
  private updateWatchedSourceUris;
189
204
  private getSerializedPayload;
190
205
  private requestSerialized;
191
206
  private resolveRetrieved;
192
207
  }
193
208
  //#endregion
194
- export { EditorSyncError as a, fetchEditorSyncAccess as c, EditorHostInboundMessage as d, EditorHostInitOptions as f, EditorSyncBackend as i, EDITOR_PROTOCOL_VERSION as l, EditorHostValidationIssue as m, EditorHostSessionOptions as n, RemoteEditorSyncBackendOptions as o, EditorHostOutboundMessage as p, EditorSourceHost as r, createRemoteEditorSyncBackend as s, EditorHostSession as t, EditorHostExportFormat as u };
209
+ export { EditorSyncError as a, fetchEditorSyncAccess as c, EditorHostExportFormat as d, EditorHostInboundMessage as f, EditorHostValidationIssue as h, EditorSyncBackend as i, EDITOR_PROTOCOL_VERSION as l, EditorHostOutboundMessage as m, EditorHostSessionOptions as n, RemoteEditorSyncBackendOptions as o, EditorHostInitOptions as p, EditorSourceHost as r, createRemoteEditorSyncBackend as s, EditorHostSession as t, EditorHostDiagnostic as u };
@@ -1,2 +1,2 @@
1
- import { a as EditorSyncError, 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";
2
- export { EDITOR_PROTOCOL_VERSION, EditorHostExportFormat, EditorHostInboundMessage, EditorHostInitOptions, EditorHostOutboundMessage, EditorHostSession, EditorHostSessionOptions, EditorHostValidationIssue, EditorSourceHost, EditorSyncBackend, EditorSyncError, RemoteEditorSyncBackendOptions, createRemoteEditorSyncBackend, fetchEditorSyncAccess };
1
+ import { a as EditorSyncError, c as fetchEditorSyncAccess, d as EditorHostExportFormat, f as EditorHostInboundMessage, h as EditorHostValidationIssue, i as EditorSyncBackend, l as EDITOR_PROTOCOL_VERSION, m as EditorHostOutboundMessage, n as EditorHostSessionOptions, o as RemoteEditorSyncBackendOptions, p as EditorHostInitOptions, r as EditorSourceHost, s as createRemoteEditorSyncBackend, t as EditorHostSession, u as EditorHostDiagnostic } from "./editorHostSession-DFjM-RoT.mjs";
2
+ export { EDITOR_PROTOCOL_VERSION, EditorHostDiagnostic, EditorHostExportFormat, EditorHostInboundMessage, EditorHostInitOptions, EditorHostOutboundMessage, EditorHostSession, EditorHostSessionOptions, EditorHostValidationIssue, EditorSourceHost, EditorSyncBackend, EditorSyncError, RemoteEditorSyncBackendOptions, createRemoteEditorSyncBackend, fetchEditorSyncAccess };
@@ -1,5 +1,5 @@
1
1
  import "./openapi-BTDjYWXd.mjs";
2
2
  import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-Bko7wge8.mjs";
3
- import { i as fetchEditorSyncAccess, n as EditorSyncError, r as createRemoteEditorSyncBackend, t as EditorHostSession } from "./editorHostSession-BwS-EiBJ.mjs";
3
+ import { i as fetchEditorSyncAccess, n as EditorSyncError, r as createRemoteEditorSyncBackend, t as EditorHostSession } from "./editorHostSession-CwGeXJ6g.mjs";
4
4
 
5
5
  export { EDITOR_PROTOCOL_VERSION, EditorHostSession, EditorSyncError, createRemoteEditorSyncBackend, fetchEditorSyncAccess };
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-u0s4xat2.mjs";
1
+ import { a as createEventRegistry, o as createPendingExportManager, r as createPostMessageTransport, s as toInitMessage, t as SDK_VERSION } from "./version-DKSLBwJ9.mjs";
2
2
  import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-Bko7wge8.mjs";
3
3
 
4
4
  //#region src/embed.ts
@@ -82,6 +82,7 @@ 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,
@@ -101,6 +102,7 @@ function extractInitOptions(options) {
101
102
  readOnlyReason: options.readOnlyReason,
102
103
  depth: options.depth,
103
104
  capabilities: options.capabilities,
105
+ examples: options.examples,
104
106
  panels: options.panels,
105
107
  comments: options.comments,
106
108
  sourceLocations: options.sourceLocations,
@@ -281,6 +283,7 @@ function createStatelyEmbed(options) {
281
283
  const save = data;
282
284
  options.onSave?.(save.graph, save.machineConfig);
283
285
  events.emit("save", {
286
+ requestId: save.requestId,
284
287
  graph: save.graph,
285
288
  machineConfig: save.machineConfig,
286
289
  machineId: save.machineId,
package/dist/index.d.mts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
2
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
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, 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, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.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
- 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";
7
+ import { c as fetchEditorSyncAccess, d as EditorHostExportFormat, f as EditorHostInboundMessage, h as EditorHostValidationIssue, i as EditorSyncBackend, l as EDITOR_PROTOCOL_VERSION, m as EditorHostOutboundMessage, n as EditorHostSessionOptions, o as RemoteEditorSyncBackendOptions, p as EditorHostInitOptions, r as EditorSourceHost, s as createRemoteEditorSyncBackend, t as EditorHostSession, u as EditorHostDiagnostic } from "./editorHostSession-DFjM-RoT.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
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";
@@ -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 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, 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 EditorHostDiagnostic, 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-u0s4xat2.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-DKSLBwJ9.mjs";
4
4
  import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-Bko7wge8.mjs";
5
5
  import { createStatelyEmbed } from "./embed.mjs";
6
- import { i as fetchEditorSyncAccess, r as createRemoteEditorSyncBackend, t as EditorHostSession } from "./editorHostSession-BwS-EiBJ.mjs";
6
+ import { i as fetchEditorSyncAccess, r as createRemoteEditorSyncBackend, t as EditorHostSession } from "./editorHostSession-CwGeXJ6g.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-DNM-Qs93.mjs";
10
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-BA3EPIz9.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-u0s4xat2.mjs";
2
+ import { a as createEventRegistry, i as createWebSocketTransport, n as inspectionRuntime, o as createPendingExportManager, t as SDK_VERSION } from "./version-DKSLBwJ9.mjs";
3
3
 
4
4
  //#region src/openBrowser.ts
5
5
  async function openBrowser(url) {
package/dist/inspect.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import "./version-u0s4xat2.mjs";
2
- import { n as createStatelyInspector, t as createInspector } from "./inspect-DNM-Qs93.mjs";
1
+ import "./version-DKSLBwJ9.mjs";
2
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-BA3EPIz9.mjs";
3
3
 
4
4
  export { createInspector, createStatelyInspector };
@@ -231,6 +231,7 @@ interface EmbedEventMap {
231
231
  sourceLocations?: MachineSourceLocations;
232
232
  };
233
233
  save: {
234
+ requestId?: string;
234
235
  graph: StatelyGraph;
235
236
  machineConfig: unknown;
236
237
  machineId?: string;
@@ -293,6 +294,20 @@ interface EmbedExtensionsManifest {
293
294
  defaultProfile?: string;
294
295
  defaultFormat?: string;
295
296
  }
297
+ /** Host-provided examples shown in the editor's Get started launchpad. */
298
+ interface EmbedExample {
299
+ id: string;
300
+ title: string;
301
+ description: string;
302
+ category: string;
303
+ machine: unknown;
304
+ }
305
+ /** Check whether an example machine has a shape supported by the editor. */
306
+ declare function isEmbedExampleMachine(value: unknown): value is Record<string, unknown>;
307
+ /** Check whether an unknown value is a valid serialized embed example. */
308
+ declare function isEmbedExample(value: unknown): value is EmbedExample;
309
+ /** Reject malformed host-provided examples before creating an init message. */
310
+ declare function assertEmbedExamples(examples: readonly EmbedExample[] | undefined): void;
296
311
  interface MachineInitOptions {
297
312
  machine: unknown;
298
313
  /** Ephemeral, read-only reference documents owned by the embed host. */
@@ -305,6 +320,7 @@ interface MachineInitOptions {
305
320
  readOnlyReason?: ReadOnlyReason;
306
321
  depth?: number;
307
322
  capabilities?: EditorCapabilities;
323
+ examples?: readonly EmbedExample[];
308
324
  panels?: {
309
325
  leftPanels?: string[];
310
326
  rightPanels?: string[];
@@ -342,6 +358,7 @@ interface ProjectInitOptions {
342
358
  readOnly?: boolean;
343
359
  depth?: number;
344
360
  capabilities?: EditorCapabilities;
361
+ examples?: readonly EmbedExample[];
345
362
  panels?: {
346
363
  leftPanels?: string[];
347
364
  rightPanels?: string[];
@@ -371,6 +388,7 @@ interface InitMessage {
371
388
  readOnlyReason?: ReadOnlyReason;
372
389
  depth?: number;
373
390
  capabilities?: EditorCapabilities;
391
+ examples?: readonly EmbedExample[];
374
392
  leftPanels?: string[];
375
393
  rightPanels?: string[];
376
394
  activePanels?: string[];
@@ -390,6 +408,7 @@ interface SetApiKeyMessage {
390
408
  }
391
409
  interface SavedMessage {
392
410
  type: '@statelyai.saved';
411
+ requestId?: string;
393
412
  graph: unknown;
394
413
  }
395
414
  interface ClipboardReadResponseMessage {
@@ -421,6 +440,7 @@ interface ProjectInitMessage {
421
440
  readOnly?: boolean;
422
441
  depth?: number;
423
442
  capabilities?: EditorCapabilities;
443
+ examples?: readonly EmbedExample[];
424
444
  leftPanels?: string[];
425
445
  rightPanels?: string[];
426
446
  activePanels?: string[];
@@ -612,6 +632,7 @@ interface ChangeMessage {
612
632
  }
613
633
  interface SaveMessage {
614
634
  type: '@statelyai.save';
635
+ requestId?: string;
615
636
  graph: StatelyGraph;
616
637
  machineConfig: unknown;
617
638
  machineId?: string;
@@ -748,4 +769,4 @@ declare const PREFIX = "@statelyai.";
748
769
  /** Current WebSocket inspection protocol version. */
749
770
  declare const INSPECTION_PROTOCOL_VERSION = 2;
750
771
  //#endregion
751
- 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, 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, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId };
772
+ 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
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,
@@ -145,6 +147,7 @@ function toInitMessage(options) {
145
147
  readOnlyReason: options.readOnlyReason,
146
148
  depth: options.depth,
147
149
  capabilities: options.capabilities,
150
+ examples: options.examples,
148
151
  leftPanels: options.panels?.leftPanels,
149
152
  rightPanels: options.panels?.rightPanels,
150
153
  activePanels: options.panels?.activePanels,
@@ -335,7 +338,7 @@ function createWebSocketTransport(options) {
335
338
 
336
339
  //#endregion
337
340
  //#region src/version.ts
338
- const SDK_VERSION = "0.26.0";
341
+ const SDK_VERSION = "0.26.2";
339
342
  function inspectionRuntime() {
340
343
  if (typeof window !== "undefined") return "browser";
341
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.26.0",
3
+ "version": "0.26.2",
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.11",
97
- "@statelyai/graph-tools": "0.4.0"
96
+ "@statelyai/api-contract": "0.3.12",
97
+ "@statelyai/graph-tools": "0.4.1"
98
98
  },
99
99
  "engines": {
100
100
  "node": ">=22.4"