@statelyai/sdk 0.18.0 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +33 -2
  2. package/dist/auth.d.mts +1 -1
  3. package/dist/editor-sync-types-C-zWaaVk.d.mts +95 -0
  4. package/dist/editorHostProtocol-D_h4y3rX.mjs +5 -0
  5. package/dist/editorHostSession-CCTwvUOB.mjs +479 -0
  6. package/dist/editorHostSession-lL7wPLnL.d.mts +184 -0
  7. package/dist/editorHostSession.d.mts +2 -0
  8. package/dist/editorHostSession.mjs +4 -0
  9. package/dist/embed.d.mts +1 -1
  10. package/dist/embed.mjs +31 -3
  11. package/dist/{graph-DuOeLGvh.d.mts → graph-yDK-MM3G.d.mts} +6 -4
  12. package/dist/graph.d.mts +1 -1
  13. package/dist/{index-ag6K2iAS.d.mts → index-BAkQThnl.d.mts} +9 -9
  14. package/dist/index.d.mts +7 -6
  15. package/dist/index.mjs +7 -5
  16. package/dist/{inspect-BZFzyeew.d.mts → inspect-CGJR4iZK.d.mts} +13 -3
  17. package/dist/{inspect-llcqYpZ1.mjs → inspect-DWu20a8g.mjs} +58 -31
  18. package/dist/inspect.d.mts +1 -1
  19. package/dist/inspect.mjs +2 -2
  20. package/dist/patchTypes.d.mts +1 -1
  21. package/dist/protocol.d.mts +44 -50
  22. package/dist/protocol.mjs +2 -2
  23. package/dist/{studio-txdyJHD7.mjs → schemas-b9wG-zYl.mjs} +15 -396
  24. package/dist/{statelyPragma-Bm9O4XV6.mjs → statelyPragma-CIzsR_Sx.mjs} +977 -934
  25. package/dist/studio-DHGspwII.mjs +397 -0
  26. package/dist/{studio-Bk_u41gu.d.mts → studio-YSppd-am.d.mts} +2 -2
  27. package/dist/studio.d.mts +1 -1
  28. package/dist/studio.mjs +1 -1
  29. package/dist/sync.d.mts +2 -2
  30. package/dist/sync.mjs +12 -5
  31. package/dist/{transport-CyCrdKyz.mjs → version-YJizbJxR.mjs} +14 -4
  32. package/package.json +7 -3
  33. /package/dist/{auth-2Thaw42j.d.mts → auth-B0ZTKri2.d.mts} +0 -0
@@ -0,0 +1,184 @@
1
+ import { a as EditorSyncParseRequest, d as EditorSyncTextReplacement, f as MachineSourceLocations, i as EditorSyncApplyResponse, n as EditorSyncAccess, o as EditorSyncParseResponse, r as EditorSyncApplyRequest, s as EditorSyncSourceDocument, t as EditorCapabilities } from "./editor-sync-types-C-zWaaVk.mjs";
2
+
3
+ //#region src/editorHostProtocol.d.ts
4
+ declare const EDITOR_PROTOCOL_VERSION = 1;
5
+ type EditorHostExportFormat = 'xstate-v6' | 'xstate' | 'async' | 'xstate-json' | 'xgraph' | 'digraph' | 'd2' | 'mermaid' | 'redux' | 'zustand' | 'asl-json' | 'asl-yaml' | 'scxml';
6
+ interface EditorHostValidationIssue {
7
+ nodeIds: string[];
8
+ edgeIds: string[];
9
+ level: 'info' | 'warning' | 'error';
10
+ message: string;
11
+ }
12
+ type EditorHostInboundMessage = {
13
+ type: '@statelyai.ready';
14
+ version?: string;
15
+ protocolVersion?: number;
16
+ } | {
17
+ type: '@statelyai.loaded';
18
+ graph: unknown;
19
+ sourceLocations?: MachineSourceLocations;
20
+ } | {
21
+ type: '@statelyai.change';
22
+ graph: unknown;
23
+ machineConfig: unknown;
24
+ patches?: unknown[];
25
+ sourceLocations?: MachineSourceLocations;
26
+ } | {
27
+ type: '@statelyai.save';
28
+ graph: unknown;
29
+ machineConfig: unknown;
30
+ patches?: unknown[];
31
+ validations?: EditorHostValidationIssue[];
32
+ sourceLocations?: MachineSourceLocations;
33
+ } | {
34
+ type: '@statelyai.retrieved';
35
+ requestId: string;
36
+ data: unknown;
37
+ } | {
38
+ type: '@statelyai.error';
39
+ code: string;
40
+ message: string;
41
+ requestId?: string;
42
+ } | {
43
+ type: '@statelyai.clipboardRead';
44
+ requestId: string;
45
+ } | {
46
+ type: '@statelyai.clipboardWrite';
47
+ requestId: string;
48
+ text: string;
49
+ };
50
+ interface EditorHostInitOptions {
51
+ settings?: Record<string, unknown>;
52
+ leftPanels?: string[];
53
+ rightPanels?: string[];
54
+ activePanels?: string[];
55
+ unsavedIndicator?: {
56
+ enabled?: boolean;
57
+ mode?: 'structural' | 'all';
58
+ };
59
+ }
60
+ type EditorHostOutboundMessage = {
61
+ type: '@statelyai.init';
62
+ machine: unknown;
63
+ format?: string;
64
+ mode?: 'editing' | 'viewing';
65
+ theme?: 'light' | 'dark';
66
+ readOnly?: boolean;
67
+ readOnlyReason?: 'free-plan' | 'access-unverified';
68
+ capabilities?: EditorCapabilities;
69
+ sourceLocations?: MachineSourceLocations;
70
+ settings?: Record<string, unknown>;
71
+ leftPanels?: string[];
72
+ rightPanels?: string[];
73
+ activePanels?: string[];
74
+ unsavedIndicator?: {
75
+ enabled?: boolean;
76
+ mode?: 'structural' | 'all';
77
+ };
78
+ } | {
79
+ type: '@statelyai.setApiKey';
80
+ apiKey: string;
81
+ } | {
82
+ type: '@statelyai.handshake';
83
+ protocolVersion: number;
84
+ client?: {
85
+ name: string;
86
+ version: string;
87
+ };
88
+ } | {
89
+ type: '@statelyai.update';
90
+ machine: unknown;
91
+ format?: string;
92
+ sourceLocations?: MachineSourceLocations;
93
+ } | {
94
+ type: '@statelyai.saved';
95
+ graph: unknown;
96
+ } | {
97
+ type: '@statelyai.retrieve';
98
+ requestId: string;
99
+ format: EditorHostExportFormat;
100
+ } | {
101
+ type: '@statelyai.toast';
102
+ message: string;
103
+ toastType?: 'success' | 'error' | 'info' | 'warning';
104
+ } | {
105
+ type: '@statelyai.error';
106
+ code: string;
107
+ message: string;
108
+ } | {
109
+ type: '@statelyai.clipboardReadResponse';
110
+ requestId: string;
111
+ text: string;
112
+ } | {
113
+ type: '@statelyai.clipboardWriteResponse';
114
+ requestId: string;
115
+ ok: boolean;
116
+ };
117
+ //#endregion
118
+ //#region src/editorHostSession.d.ts
119
+ interface EditorSyncBackend {
120
+ parse(request: EditorSyncParseRequest): Promise<EditorSyncParseResponse>;
121
+ apply(request: EditorSyncApplyRequest): Promise<EditorSyncApplyResponse>;
122
+ }
123
+ interface RemoteEditorSyncBackendOptions {
124
+ editorUrl: string;
125
+ apiKey?: string;
126
+ fetch?: typeof globalThis.fetch;
127
+ }
128
+ declare function createRemoteEditorSyncBackend(options: RemoteEditorSyncBackendOptions): EditorSyncBackend;
129
+ declare function fetchEditorSyncAccess(options: RemoteEditorSyncBackendOptions): Promise<EditorSyncAccess>;
130
+ interface EditorSourceHost {
131
+ rootUri: string;
132
+ rootFileName: string;
133
+ rootDir: string;
134
+ collectDocuments(extraUris?: readonly string[]): Promise<EditorSyncSourceDocument[]>;
135
+ applyReplacements(replacements: EditorSyncTextReplacement[], rootUri: string): Promise<string[]>;
136
+ saveDocuments?(uris: string[]): Promise<void>;
137
+ watchSavedDocuments?(listener: (uri: string) => void | Promise<void>): {
138
+ dispose(): void;
139
+ };
140
+ getPreserveStatelyMetadata?(uri: string): boolean;
141
+ }
142
+ interface EditorHostSessionOptions {
143
+ source: EditorSourceHost;
144
+ sync: EditorSyncBackend;
145
+ send(message: EditorHostOutboundMessage): void;
146
+ access?: EditorSyncAccess;
147
+ apiKey?: string;
148
+ getTheme?(): 'light' | 'dark';
149
+ showError?(message: string): void;
150
+ readClipboard?(): Promise<string>;
151
+ writeClipboard?(text: string): Promise<void>;
152
+ init?: EditorHostInitOptions;
153
+ client?: {
154
+ name: string;
155
+ version: string;
156
+ };
157
+ }
158
+ declare class EditorHostSession {
159
+ private options;
160
+ private editorProtocolState;
161
+ private currentGraph;
162
+ private lastPersistedGraph;
163
+ private currentFormat;
164
+ private currentSourceLocations;
165
+ private access;
166
+ private watchedSourceUris;
167
+ private selfEditCount;
168
+ private watcher;
169
+ private retrieveRequestCount;
170
+ private pendingRetrievals;
171
+ constructor(options: EditorHostSessionOptions);
172
+ dispose(): void;
173
+ notifySavedDocument(uri?: string): Promise<void>;
174
+ receive(message: EditorHostInboundMessage): Promise<void>;
175
+ private initialize;
176
+ private save;
177
+ private handleSavedDocument;
178
+ private updateWatchedSourceUris;
179
+ private getSerializedPayload;
180
+ private requestSerialized;
181
+ private resolveRetrieved;
182
+ }
183
+ //#endregion
184
+ export { RemoteEditorSyncBackendOptions as a, EDITOR_PROTOCOL_VERSION as c, EditorHostInitOptions as d, EditorHostOutboundMessage as f, EditorSyncBackend as i, EditorHostExportFormat as l, EditorHostSessionOptions as n, createRemoteEditorSyncBackend as o, EditorHostValidationIssue as p, EditorSourceHost as r, fetchEditorSyncAccess as s, EditorHostSession as t, EditorHostInboundMessage as u };
@@ -0,0 +1,2 @@
1
+ import { a as RemoteEditorSyncBackendOptions, c as EDITOR_PROTOCOL_VERSION, d as EditorHostInitOptions, f as EditorHostOutboundMessage, i as EditorSyncBackend, l as EditorHostExportFormat, n as EditorHostSessionOptions, o as createRemoteEditorSyncBackend, p as EditorHostValidationIssue, r as EditorSourceHost, s as fetchEditorSyncAccess, t as EditorHostSession, u as EditorHostInboundMessage } from "./editorHostSession-lL7wPLnL.mjs";
2
+ export { EDITOR_PROTOCOL_VERSION, EditorHostExportFormat, EditorHostInboundMessage, EditorHostInitOptions, EditorHostOutboundMessage, EditorHostSession, EditorHostSessionOptions, EditorHostValidationIssue, EditorSourceHost, EditorSyncBackend, RemoteEditorSyncBackendOptions, createRemoteEditorSyncBackend, fetchEditorSyncAccess };
@@ -0,0 +1,4 @@
1
+ import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-D_h4y3rX.mjs";
2
+ import { n as createRemoteEditorSyncBackend, r as fetchEditorSyncAccess, t as EditorHostSession } from "./editorHostSession-CCTwvUOB.mjs";
3
+
4
+ export { EDITOR_PROTOCOL_VERSION, EditorHostSession, createRemoteEditorSyncBackend, fetchEditorSyncAccess };
package/dist/embed.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as StatelyGraph } from "./graph-DuOeLGvh.mjs";
1
+ import { i as StatelyGraph } from "./graph-yDK-MM3G.mjs";
2
2
  import { CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, MachineInitOptions, MachineSourceLocations, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
3
3
  import { AssetUploadAdapter } from "./assetStorage.mjs";
4
4
 
package/dist/embed.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { a as toInitMessage, i as createPendingExportManager, r as createEventRegistry, t as createPostMessageTransport } from "./transport-CyCrdKyz.mjs";
1
+ import { a as createEventRegistry, o as createPendingExportManager, r as createPostMessageTransport, s as toInitMessage, t as SDK_VERSION } from "./version-YJizbJxR.mjs";
2
+ import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-D_h4y3rX.mjs";
2
3
 
3
4
  //#region src/embed.ts
4
5
  function buildEmbedUrl(options) {
@@ -45,6 +46,7 @@ function createStatelyEmbed(options) {
45
46
  let transport = null;
46
47
  let ownedIframe = false;
47
48
  let destroyed = false;
49
+ let editorProtocolCompatible;
48
50
  const pendingMessages = [];
49
51
  const events = createEventRegistry();
50
52
  const exportManager = createPendingExportManager((message) => send(message));
@@ -56,6 +58,7 @@ function createStatelyEmbed(options) {
56
58
  const assetAccept = options.assets?.accept ?? assetUploadAdapter?.accept;
57
59
  const assetMaxFileSize = options.assets?.maxFileSize ?? assetUploadAdapter?.maxFileSize;
58
60
  function send(msg) {
61
+ if (editorProtocolCompatible === false) return;
59
62
  if (!transport?.ready) {
60
63
  pendingMessages.push(msg);
61
64
  return;
@@ -63,7 +66,7 @@ function createStatelyEmbed(options) {
63
66
  transport.send(msg);
64
67
  }
65
68
  function flush() {
66
- if (!transport) return;
69
+ if (!transport || editorProtocolCompatible === false) return;
67
70
  while (pendingMessages.length > 0) {
68
71
  const msg = pendingMessages.shift();
69
72
  transport.send(msg);
@@ -74,6 +77,27 @@ function createStatelyEmbed(options) {
74
77
  switch (data.type) {
75
78
  case "@statelyai.ready": {
76
79
  const ready = data;
80
+ if (ready.protocolVersion !== void 0) {
81
+ if (ready.protocolVersion !== EDITOR_PROTOCOL_VERSION) {
82
+ editorProtocolCompatible = false;
83
+ const error = {
84
+ code: "unsupported_protocol",
85
+ message: `Editor protocol ${ready.protocolVersion} is unsupported; this SDK supports ${EDITOR_PROTOCOL_VERSION}.`
86
+ };
87
+ options.onError?.(error);
88
+ events.emit("error", error);
89
+ break;
90
+ }
91
+ editorProtocolCompatible = true;
92
+ send({
93
+ type: "@statelyai.handshake",
94
+ protocolVersion: EDITOR_PROTOCOL_VERSION,
95
+ client: {
96
+ name: "@statelyai/sdk",
97
+ version: SDK_VERSION
98
+ }
99
+ });
100
+ } else editorProtocolCompatible = true;
77
101
  flush();
78
102
  if (uploadAsset) send({
79
103
  type: "@statelyai.uploadCapabilities",
@@ -189,6 +213,7 @@ function createStatelyEmbed(options) {
189
213
  }
190
214
  function replaceTransport(nextTransport) {
191
215
  transport?.destroy();
216
+ editorProtocolCompatible = void 0;
192
217
  transport = nextTransport;
193
218
  }
194
219
  function setupTransport(el) {
@@ -198,7 +223,10 @@ function createStatelyEmbed(options) {
198
223
  });
199
224
  replaceTransport(nextTransport);
200
225
  nextTransport.onMessage(handleMessage);
201
- nextTransport.onReady(flush);
226
+ nextTransport.onReady(() => {
227
+ editorProtocolCompatible ??= true;
228
+ flush();
229
+ });
202
230
  }
203
231
  const embed = {
204
232
  attach(el) {
@@ -1,4 +1,4 @@
1
- import { r as CodeExpression } from "./index-ag6K2iAS.mjs";
1
+ import { r as CodeExpression } from "./index-BAkQThnl.mjs";
2
2
  import * as _statelyai_graph0 from "@statelyai/graph";
3
3
  import { Graph } from "@statelyai/graph";
4
4
 
@@ -204,7 +204,7 @@ interface DigraphData {
204
204
  }
205
205
  interface DigraphConfig {
206
206
  id: string;
207
- profile?: 'xstate-v5' | 'xstate-v6-alpha';
207
+ profile?: `@${string}/${string}@${string}` | 'xstate-v5' | 'xstate-v6-alpha';
208
208
  rootNode: DigraphNodeConfig;
209
209
  edges: DigraphEdgeConfig[];
210
210
  context: Record<string, JsonItem> | JsonExpressionString;
@@ -335,7 +335,7 @@ interface StatelyEdgeData {
335
335
  meta?: Record<string, unknown> | null;
336
336
  }
337
337
  interface StatelyGraphData {
338
- profile?: 'xstate-v5' | 'xstate-v6-alpha';
338
+ profile?: `@${string}/${string}@${string}` | 'xstate-v5' | 'xstate-v6-alpha';
339
339
  schemas?: {
340
340
  context?: Record<string, SimpleJsonSchema> | null;
341
341
  events?: Record<string, SimpleJsonSchemaObject> | null;
@@ -385,7 +385,9 @@ interface StatelyTagImplementation {
385
385
  icon?: string;
386
386
  color?: string;
387
387
  }
388
- type StatelyGraph = Graph<StatelyNodeData, StatelyEdgeData, StatelyGraphData>;
388
+ type StatelyGraph = Graph<StatelyNodeData, StatelyEdgeData, StatelyGraphData> & {
389
+ xgraphSchemaVersion?: '1.0.0';
390
+ };
389
391
  type StudioMachine = DigraphConfig;
390
392
  type StudioNode = DigraphNodeConfig;
391
393
  type StudioEdge = DigraphEdgeConfig;
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-DuOeLGvh.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-yDK-MM3G.mjs";
2
2
  export { StatelyAction, StatelyActorImplementation, StatelyEdgeData, StatelyGraph, StatelyGraphData, StatelyGuard, StatelyImplementation, StatelyInvoke, StatelyNodeData, StatelyTagImplementation, StudioAction, StudioEdge, StudioEventTypeData, StudioMachine, StudioNode, fromStudioMachine, studioMachineConverter, toStudioMachine };
@@ -2276,10 +2276,14 @@ interface JSONSchema7 {
2276
2276
  }
2277
2277
  //#endregion
2278
2278
  //#region ../graph-tools/dist/index.d.mts
2279
+ declare const LEGACY_MACHINE_PROFILES: readonly ["xstate-v5", "xstate-v6-alpha"];
2280
+ type LegacyMachineProfile = (typeof LEGACY_MACHINE_PROFILES)[number];
2279
2281
  //#endregion
2280
- //#region src/machineProfile.d.ts
2281
- declare const MACHINE_PROFILES: readonly ["xstate-v5", "xstate-v6-alpha"];
2282
- type MachineProfile = (typeof MACHINE_PROFILES)[number];
2282
+ //#region src/profiles/profileRefs.d.ts
2283
+ type ProfileName = `@${string}/${string}`;
2284
+ type ProfileSpecifier = `${ProfileName}@${string}`;
2285
+ type ResolvedProfileRef = ProfileSpecifier;
2286
+ type ProfileRefInput = ResolvedProfileRef | LegacyMachineProfile;
2283
2287
  //#endregion
2284
2288
  //#region src/codegenTypes.d.ts
2285
2289
  interface CodeGenAction {
@@ -2384,7 +2388,7 @@ interface CodeGenActorImplementation {
2384
2388
  } | null;
2385
2389
  }
2386
2390
  interface CodeGenGraphData {
2387
- profile?: MachineProfile;
2391
+ profile?: ProfileRefInput;
2388
2392
  context?: Record<string, unknown> | CodeExpression | null;
2389
2393
  schemas?: {
2390
2394
  context?: Record<string, JSONSchema7> | null;
@@ -2445,11 +2449,7 @@ declare class RawCode {
2445
2449
  }
2446
2450
  declare function raw(code: string): RawCode;
2447
2451
  declare function serializeJS(value: unknown, indent?: number, step?: number): string; //#endregion
2448
- //#region src/v6Simulation.d.ts
2449
- /**
2450
- * Adapts Viz's serializable choice projection to XState v6's executable
2451
- * `choice` function. Other v6 config stays untouched.
2452
- */
2452
+ //#region src/profiles/xgraphMetadata.d.ts
2453
2453
  //#endregion
2454
2454
  //#region src/graphToXStateTS.d.ts
2455
2455
  interface XStateTSOptions extends MachineConfigOptions {
package/dist/index.d.mts CHANGED
@@ -1,12 +1,13 @@
1
1
  import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
2
- import { _ as serializeJS, c as MachineConfigOptions, d as contextSchemaToTSType, f as eventsSchemaToTSType, g as raw, h as jsonSchemaToTSType, i as CodeGenGraph, l as RawCode, m as graphToXStateTS, o as GraphPatch, p as graphToMachineConfig, t as ActionLocation, u as XStateTSOptions } from "./index-ag6K2iAS.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-DuOeLGvh.mjs";
2
+ import { _ as serializeJS, c as MachineConfigOptions, d as contextSchemaToTSType, f as eventsSchemaToTSType, g as raw, h as jsonSchemaToTSType, i as CodeGenGraph, l as RawCode, m as graphToXStateTS, o as GraphPatch, p as graphToMachineConfig, t as ActionLocation, u as XStateTSOptions } from "./index-BAkQThnl.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-yDK-MM3G.mjs";
4
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, UploadResult, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
5
5
  import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
6
- import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-2Thaw42j.mjs";
6
+ import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-B0ZTKri2.mjs";
7
+ import { a as RemoteEditorSyncBackendOptions, c as EDITOR_PROTOCOL_VERSION, d as EditorHostInitOptions, f as EditorHostOutboundMessage, i as EditorSyncBackend, l as EditorHostExportFormat, n as EditorHostSessionOptions, o as createRemoteEditorSyncBackend, p as EditorHostValidationIssue, r as EditorSourceHost, s as fetchEditorSyncAccess, t as EditorHostSession, u as EditorHostInboundMessage } from "./editorHostSession-lL7wPLnL.mjs";
7
8
  import { AssetConfig, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
8
- import { a as InspectedTransition, c as InspectorInspectionEvent, d as createStatelyInspector, f as Transport, h as createWebSocketTransport, i as InspectedSnapshot, l as ManualActorOptions, m as createPostMessageTransport, n as CreateInspectorOptions, o as Inspector, p as TransportFailure, r as InspectedEvent, s as InspectorEvents, t as AdoptedActor, u as createInspector } from "./inspect-BZFzyeew.mjs";
9
- 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-Bk_u41gu.mjs";
9
+ import { a as InspectedTransition, c as InspectorInspectionEvent, d as createStatelyInspector, f as Transport, h as createWebSocketTransport, i as InspectedSnapshot, l as ManualActorOptions, m as createPostMessageTransport, n as CreateInspectorOptions, o as Inspector, p as TransportFailure, r as InspectedEvent, s as InspectorEvents, t as AdoptedActor, u as createInspector } from "./inspect-CGJR4iZK.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-YSppd-am.mjs";
10
11
  import { OAuthAuthorizationServerMetadata, OAuthClientRegistrationResponse, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
11
12
  import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
12
13
  import { CreateInspectionRelayOptions, InspectionRelay, InspectionRelayEffect, InspectionRelayPeer, InspectionRelayRole, InspectionRelaySnapshot, createInspectionRelay } from "./relay.mjs";
@@ -32,4 +33,4 @@ declare function findStatelyPragmaAttachments(sourceText: string, fileName?: str
32
33
  declare function getStatelyPragma(sourceText: string, fileName?: string, machineIndex?: number): StatelyPragma | undefined;
33
34
  declare function upsertStatelyPragma(sourceText: string, id: string, options?: UpsertStatelyPragmaOptions): string;
34
35
  //#endregion
35
- 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, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, 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 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 PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, 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, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, 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 EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, 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 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 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 };
package/dist/index.mjs CHANGED
@@ -1,14 +1,16 @@
1
1
  import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
2
- import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-CyCrdKyz.mjs";
2
+ import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-YJizbJxR.mjs";
3
+ import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-D_h4y3rX.mjs";
3
4
  import { createStatelyEmbed } from "./embed.mjs";
5
+ import { n as createRemoteEditorSyncBackend, r as fetchEditorSyncAccess, t as EditorHostSession } from "./editorHostSession-CCTwvUOB.mjs";
6
+ import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-DHGspwII.mjs";
7
+ 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-CIzsR_Sx.mjs";
4
8
  import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
5
- import { n as createStatelyInspector, t as createInspector } from "./inspect-llcqYpZ1.mjs";
6
- import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-txdyJHD7.mjs";
7
- import { a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, f as raw, l as graphToMachineConfig, n as getStatelyPragma, o as contextSchemaToTSType, p as serializeJS, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-Bm9O4XV6.mjs";
9
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-DWu20a8g.mjs";
8
10
  import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
9
11
  import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
10
12
  import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
11
13
  import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
12
14
  import { createInspectionRelay } from "./relay.mjs";
13
15
 
14
- export { DEFAULT_STATELY_BASE_URL, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
16
+ 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 };
@@ -62,7 +62,7 @@ interface InspectorInspectionEvent {
62
62
  readonly actorRef: unknown;
63
63
  }
64
64
  interface AdoptedActor {
65
- /** XState process-local `actor.sessionId`. Pair with inspector.producerId. */
65
+ /** Producer-local session id; defaults to XState's `actor.sessionId`. */
66
66
  sessionId: string;
67
67
  /** System-local `actor.id`. */
68
68
  actorId: string;
@@ -137,7 +137,10 @@ interface CreateInspectorOptions {
137
137
  url?: string;
138
138
  /** Unguessable inspection room capability. Defaults to a random UUID. */
139
139
  roomId?: string;
140
- /** Stable identity for this producer connection. Defaults to a random UUID. */
140
+ /**
141
+ * Stable identity for this producer across reconnects and restored Inspector
142
+ * instances. Defaults to a random UUID.
143
+ */
141
144
  producerId?: string;
142
145
  /**
143
146
  * Inspector UI base URL when hosted separately from the WebSocket relay. The
@@ -172,6 +175,13 @@ interface CreateInspectorOptions {
172
175
  * @deprecated Use {@link extractMachine}; it also accepts source strings.
173
176
  */
174
177
  extractMachineConfig?: (actor: any, source?: unknown) => unknown;
178
+ /**
179
+ * Resolve the producer-local identity used for an actor on the inspection
180
+ * wire. Defaults to XState's runtime `actor.sessionId`. The resolver runs
181
+ * once per runtime actor and must return a non-empty id that is unique among
182
+ * all actors observed by this inspector.
183
+ */
184
+ resolveSessionId?: (actor: any, defaultSessionId: string) => string;
175
185
  /** Selected actor session id to focus on first. */
176
186
  selectedSessionId?: string;
177
187
  /** @deprecated Use {@link selectedSessionId}. */
@@ -193,7 +203,7 @@ interface CreateInspectorOptions {
193
203
  transport?: Transport;
194
204
  }
195
205
  interface Inspector {
196
- /** Snapshot of this producer's actors keyed by XState `sessionId`. */
206
+ /** Snapshot of this producer's actors keyed by resolved `sessionId`. */
197
207
  readonly actors: ReadonlyMap<string, AdoptedActor>;
198
208
  /** Unguessable inspection room capability. */
199
209
  readonly roomId: string;