@statelyai/sdk 0.22.1 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -6
- package/dist/{editorHostSession-BZE_Wm0m.mjs → editorHostSession-BwS-EiBJ.mjs} +18 -1
- package/dist/{editorHostSession-CMwC9KKh.d.mts → editorHostSession-DTXKcLhR.d.mts} +5 -0
- package/dist/editorHostSession.d.mts +1 -1
- package/dist/editorHostSession.mjs +1 -1
- package/dist/embed.d.mts +12 -3
- package/dist/embed.mjs +26 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/{inspect-CGJR4iZK.d.mts → inspect-Br_vS_lK.d.mts} +13 -2
- package/dist/{inspect-CXkNcKu4.mjs → inspect-CWFYJT9G.mjs} +44 -6
- package/dist/inspect.d.mts +2 -2
- package/dist/inspect.mjs +2 -2
- package/dist/protocol.d.mts +77 -3
- package/dist/{statelyPragma-DfKQ-kPr.mjs → statelyPragma-0djA1cnm.mjs} +9 -2
- package/dist/sync.mjs +3 -2
- package/dist/{version-yzel-kpS.mjs → version-DX-_ZovM.mjs} +3 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -240,10 +240,11 @@ may be producer-resolved. A room uses `producerId + sessionId` as the global
|
|
|
240
240
|
actor identity.
|
|
241
241
|
Observations captured before the first transport registration replay in order
|
|
242
242
|
after the initial actor-tree baseline. Reconnects use the latest checkpoint.
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
243
|
+
The SDK connects to `wss://sky.stately.ai`, logs the inspector URL, and does not
|
|
244
|
+
open a browser by default. Pass `launch: 'browser'` to open it explicitly from
|
|
245
|
+
Node. It generates a UUID v4 `?r=` room bearer capability. Multiple producers
|
|
246
|
+
and viewers can share that room. Anyone with the URL can inspect its data, so
|
|
247
|
+
keep it private. Hosted replay expires after 24
|
|
247
248
|
hours without activity. Only actor checkpoints and observations are replayed;
|
|
248
249
|
export traffic is live-only, and auth/upload/embed-control messages are rejected.
|
|
249
250
|
AI-backed features remain separately authenticated.
|
|
@@ -258,8 +259,11 @@ and request metadata. A source origin can identify a site or customer, so this
|
|
|
258
259
|
is operational telemetry rather than anonymous data. Pass a self-hosted `url`
|
|
259
260
|
to opt out of Stately-hosted collection.
|
|
260
261
|
|
|
261
|
-
|
|
262
|
-
|
|
262
|
+
`inspector.inspectorUrl` is available immediately. Await `inspector.ready` when
|
|
263
|
+
the next step depends on successful relay registration, or listen for the
|
|
264
|
+
`connected` event when reconnects matter. The default `launch: 'none'` is safe
|
|
265
|
+
for test runners, automation, and CI; pass `launch: 'browser'` only when the SDK
|
|
266
|
+
should open the default browser from Node.
|
|
263
267
|
`inspectorBaseUrl` targets an inspector UI hosted separately from the WebSocket
|
|
264
268
|
relay. An explicit `url` wins over `STATELY_INSPECT_URL`, which wins over the
|
|
265
269
|
hosted default. See `@statelyai/sdk/protocol` for the versioned message and
|
|
@@ -177,15 +177,32 @@ var EditorHostSession = class {
|
|
|
177
177
|
access;
|
|
178
178
|
watchedSourceUris = /* @__PURE__ */ new Set();
|
|
179
179
|
selfEditCount = 0;
|
|
180
|
+
saveReminderShown = false;
|
|
180
181
|
watcher;
|
|
182
|
+
changeWatcher;
|
|
181
183
|
retrieveRequestCount = 0;
|
|
182
184
|
pendingRetrievals = /* @__PURE__ */ new Map();
|
|
183
185
|
constructor(options) {
|
|
184
186
|
this.options = options;
|
|
185
|
-
this.watcher = options.source.watchSavedDocuments?.((uri) =>
|
|
187
|
+
this.watcher = options.source.watchSavedDocuments?.((uri) => {
|
|
188
|
+
this.saveReminderShown = false;
|
|
189
|
+
return this.handleSavedDocument(uri);
|
|
190
|
+
});
|
|
191
|
+
this.changeWatcher = options.source.watchChangedDocuments?.((uri) => {
|
|
192
|
+
if (uri !== this.options.source.rootUri && !this.watchedSourceUris.has(uri)) return;
|
|
193
|
+
if (this.selfEditCount > 0) return;
|
|
194
|
+
if (this.saveReminderShown) return;
|
|
195
|
+
this.saveReminderShown = true;
|
|
196
|
+
this.options.send({
|
|
197
|
+
type: "@statelyai.toast",
|
|
198
|
+
message: "Save code to see changes.",
|
|
199
|
+
toastType: "info"
|
|
200
|
+
});
|
|
201
|
+
});
|
|
186
202
|
}
|
|
187
203
|
dispose() {
|
|
188
204
|
this.watcher?.dispose();
|
|
205
|
+
this.changeWatcher?.dispose();
|
|
189
206
|
for (const pending of this.pendingRetrievals.values()) pending.reject(/* @__PURE__ */ new Error("Editor session disposed before export completed."));
|
|
190
207
|
this.pendingRetrievals.clear();
|
|
191
208
|
}
|
|
@@ -142,6 +142,9 @@ interface EditorSourceHost {
|
|
|
142
142
|
watchSavedDocuments?(listener: (uri: string) => void | Promise<void>): {
|
|
143
143
|
dispose(): void;
|
|
144
144
|
};
|
|
145
|
+
watchChangedDocuments?(listener: (uri: string) => void): {
|
|
146
|
+
dispose(): void;
|
|
147
|
+
};
|
|
145
148
|
getPreserveStatelyMetadata?(uri: string): boolean;
|
|
146
149
|
}
|
|
147
150
|
interface EditorHostSessionOptions {
|
|
@@ -170,7 +173,9 @@ declare class EditorHostSession {
|
|
|
170
173
|
private access;
|
|
171
174
|
private watchedSourceUris;
|
|
172
175
|
private selfEditCount;
|
|
176
|
+
private saveReminderShown;
|
|
173
177
|
private watcher;
|
|
178
|
+
private changeWatcher;
|
|
174
179
|
private retrieveRequestCount;
|
|
175
180
|
private pendingRetrievals;
|
|
176
181
|
constructor(options: EditorHostSessionOptions);
|
|
@@ -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-
|
|
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
2
|
export { EDITOR_PROTOCOL_VERSION, 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-
|
|
3
|
+
import { i as fetchEditorSyncAccess, n as EditorSyncError, r as createRemoteEditorSyncBackend, t as EditorHostSession } from "./editorHostSession-BwS-EiBJ.mjs";
|
|
4
4
|
|
|
5
5
|
export { EDITOR_PROTOCOL_VERSION, EditorHostSession, EditorSyncError, createRemoteEditorSyncBackend, fetchEditorSyncAccess };
|
package/dist/embed.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as ProfileManifest } from "./index-D_pO_Pr8.mjs";
|
|
2
2
|
import { i as StatelyGraph } from "./graph-1fwR0Ynl.mjs";
|
|
3
|
-
import { CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExtensionsManifest, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, MachineInitOptions, MachineSourceLocations, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
|
|
3
|
+
import { CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExtensionsManifest, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, MachineInitOptions, MachineSourceLocations, ProjectEmbedMachine, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceProject, UploadResult } from "./protocol.mjs";
|
|
4
4
|
import { AssetUploadAdapter } from "./assetStorage.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/embed.d.ts
|
|
@@ -89,6 +89,10 @@ interface StatelyEmbedOptions extends Partial<MachineInitOptions> {
|
|
|
89
89
|
currentMachineId?: string;
|
|
90
90
|
/** Project mode only — initial comments keyed by machine id. */
|
|
91
91
|
commentsByMachineId?: Record<string, CommentsConfig>;
|
|
92
|
+
/** Project mode only — optional host-provided sidebar content/actions. */
|
|
93
|
+
projectWorkspace?: ProjectWorkspaceConfig;
|
|
94
|
+
/** Project mode only — whether the project workspace starts open. */
|
|
95
|
+
projectWorkspaceOpen?: boolean;
|
|
92
96
|
/** Asset upload configuration. If omitted, files are stored as base64 data URLs. */
|
|
93
97
|
assets?: AssetConfig;
|
|
94
98
|
profiles?: readonly EmbedProfileDefinition[];
|
|
@@ -116,9 +120,14 @@ interface StatelyEmbed {
|
|
|
116
120
|
/** Update the machine (shorthand for update message). */
|
|
117
121
|
updateMachine(machine: unknown, format?: string, sourceLocations?: MachineSourceLocations): void;
|
|
118
122
|
/** Update the project machine list without re-creating the iframe. */
|
|
119
|
-
updateProject(machines: ProjectEmbedMachine[], currentMachineId?: string, commentsByMachineId?: Record<string, CommentsConfig
|
|
123
|
+
updateProject(machines: ProjectEmbedMachine[], currentMachineId?: string, commentsByMachineId?: Record<string, CommentsConfig>, projectOptions?: {
|
|
124
|
+
projectWorkspace?: ProjectWorkspaceConfig;
|
|
125
|
+
projectWorkspaceOpen?: boolean;
|
|
126
|
+
}): void;
|
|
120
127
|
/** Select the active machine in project mode. */
|
|
121
128
|
selectMachine(machineId: string): void;
|
|
129
|
+
/** Open or close the project sidebar in project mode. */
|
|
130
|
+
setProjectWorkspaceOpen(open: boolean): void;
|
|
122
131
|
/** Change the embed mode. */
|
|
123
132
|
setMode(mode: EmbedMode): void;
|
|
124
133
|
/** Change the embed theme. */
|
|
@@ -138,4 +147,4 @@ interface StatelyEmbed {
|
|
|
138
147
|
}
|
|
139
148
|
declare function createStatelyEmbed(options: StatelyEmbedOptions): StatelyEmbed;
|
|
140
149
|
//#endregion
|
|
141
|
-
export { AssetConfig, type CapabilityDeniedEvent, type CommentsConfig, type EditorCapabilities, type EmbedDocument, type EmbedDocumentLanguage, EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExtensionsManifest, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, type EmbedMode, EmbedProfileDefinition, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type MachineInitOptions, type MachineSourceLocations, type ProjectEmbedMachine, StatelyEmbed, StatelyEmbedOptions, type UploadResult, createStatelyEmbed };
|
|
150
|
+
export { AssetConfig, type CapabilityDeniedEvent, type CommentsConfig, type EditorCapabilities, type EmbedDocument, type EmbedDocumentLanguage, EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExtensionsManifest, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, type EmbedMode, EmbedProfileDefinition, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type MachineInitOptions, type MachineSourceLocations, type ProjectEmbedMachine, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceProject, StatelyEmbed, StatelyEmbedOptions, type UploadResult, createStatelyEmbed };
|
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-
|
|
1
|
+
import { a as createEventRegistry, o as createPendingExportManager, r as createPostMessageTransport, s as toInitMessage, t as SDK_VERSION } from "./version-DX-_ZovM.mjs";
|
|
2
2
|
import { t as EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol-Bko7wge8.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/embed.ts
|
|
@@ -81,6 +81,8 @@ function extractInitOptions(options) {
|
|
|
81
81
|
capabilities: options.capabilities,
|
|
82
82
|
panels: options.panels,
|
|
83
83
|
commentsByMachineId: options.commentsByMachineId,
|
|
84
|
+
projectWorkspace: options.projectWorkspace,
|
|
85
|
+
projectWorkspaceOpen: options.projectWorkspaceOpen,
|
|
84
86
|
settings: options.settings,
|
|
85
87
|
unsavedIndicator: options.unsavedIndicator
|
|
86
88
|
};
|
|
@@ -278,6 +280,19 @@ function createStatelyEmbed(options) {
|
|
|
278
280
|
case "@statelyai.project.machineSelected":
|
|
279
281
|
events.emit("machineSelected", { machineId: String(data.machineId) });
|
|
280
282
|
break;
|
|
283
|
+
case "@statelyai.project.workspaceAction": {
|
|
284
|
+
const action = data;
|
|
285
|
+
events.emit("projectWorkspaceAction", {
|
|
286
|
+
actionId: String(action.actionId),
|
|
287
|
+
projectId: typeof action.projectId === "string" ? action.projectId : void 0,
|
|
288
|
+
machineId: typeof action.machineId === "string" ? action.machineId : void 0,
|
|
289
|
+
...action.data !== void 0 ? { data: action.data } : {}
|
|
290
|
+
});
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
case "@statelyai.project.workspaceOpenChanged":
|
|
294
|
+
events.emit("projectWorkspaceOpenChanged", { open: Boolean(data.open) });
|
|
295
|
+
break;
|
|
281
296
|
case "@statelyai.viewModeChanged": {
|
|
282
297
|
const viewMode = data;
|
|
283
298
|
options.onViewModeChanged?.(viewMode.viewMode);
|
|
@@ -410,12 +425,14 @@ function createStatelyEmbed(options) {
|
|
|
410
425
|
sourceLocations
|
|
411
426
|
});
|
|
412
427
|
},
|
|
413
|
-
updateProject(machines, currentMachineId, commentsByMachineId) {
|
|
428
|
+
updateProject(machines, currentMachineId, commentsByMachineId, projectOptions) {
|
|
414
429
|
send({
|
|
415
430
|
type: "@statelyai.project.update",
|
|
416
431
|
machines,
|
|
417
432
|
currentMachineId,
|
|
418
|
-
commentsByMachineId
|
|
433
|
+
commentsByMachineId,
|
|
434
|
+
projectWorkspace: projectOptions?.projectWorkspace,
|
|
435
|
+
projectWorkspaceOpen: projectOptions?.projectWorkspaceOpen
|
|
419
436
|
});
|
|
420
437
|
},
|
|
421
438
|
selectMachine(machineId) {
|
|
@@ -424,6 +441,12 @@ function createStatelyEmbed(options) {
|
|
|
424
441
|
machineId
|
|
425
442
|
});
|
|
426
443
|
},
|
|
444
|
+
setProjectWorkspaceOpen(open) {
|
|
445
|
+
send({
|
|
446
|
+
type: "@statelyai.project.setWorkspaceOpen",
|
|
447
|
+
open
|
|
448
|
+
});
|
|
449
|
+
},
|
|
427
450
|
setMode(mode) {
|
|
428
451
|
send({
|
|
429
452
|
type: "@statelyai.setMode",
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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-D_pO_Pr8.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-1fwR0Ynl.mjs";
|
|
4
|
-
import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, ProjectEmbedMachine, UploadResult, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
4
|
+
import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, ProjectEmbedMachine, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceProject, UploadResult, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
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-
|
|
7
|
+
import { c as fetchEditorSyncAccess, d as EditorHostInboundMessage, f as EditorHostInitOptions, i as EditorSyncBackend, l as EDITOR_PROTOCOL_VERSION, m as EditorHostValidationIssue, n as EditorHostSessionOptions, o as RemoteEditorSyncBackendOptions, p as EditorHostOutboundMessage, r as EditorSourceHost, s as createRemoteEditorSyncBackend, t as EditorHostSession, u as EditorHostExportFormat } from "./editorHostSession-DTXKcLhR.mjs";
|
|
8
8
|
import { AssetConfig, EmbedEntity, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, EmbedProfileDefinition, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
|
|
9
|
-
import { a as InspectedTransition, c as
|
|
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-CkrbMK00.mjs";
|
|
11
11
|
import { OAuthAuthorizationServerMetadata, OAuthClientRegistrationResponse, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
|
|
12
12
|
import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
|
|
@@ -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 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 };
|
|
36
|
+
export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EditorHostExportFormat, type EditorHostInboundMessage, type EditorHostInitOptions, type EditorHostOutboundMessage, EditorHostSession, type EditorHostSessionOptions, type EditorHostValidationIssue, type EditorSourceHost, type EditorSyncBackend, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedFormatContext, type EmbedFormatDefinition, type EmbedGraph, type EmbedMode, type EmbedProfileDefinition, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorConnection, type InspectorDiscoveryEntry, type InspectorEvents, type InspectorInspectionEvent, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineConfigOptions, type MachineVersion, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceProject, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RemoteEditorSyncBackendOptions, type RepoType, type ResolvedSyncInput, type ResourceErrorCode, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyAuthMode, type StatelyCredential, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type VerifyResult, type XStateTSOptions, type XStateVersion, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createRemoteEditorSyncBackend, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, fetchEditorSyncAccess, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import "./openapi-BTDjYWXd.mjs";
|
|
2
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-
|
|
3
|
+
import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-DX-_ZovM.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-
|
|
6
|
+
import { i as fetchEditorSyncAccess, r as createRemoteEditorSyncBackend, t as EditorHostSession } from "./editorHostSession-BwS-EiBJ.mjs";
|
|
7
7
|
import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-iNSHtNmP.mjs";
|
|
8
|
-
import { a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, l as graphToMachineConfig, m as serializeJS, n as getStatelyPragma, o as contextSchemaToTSType, p as raw, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-
|
|
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-0djA1cnm.mjs";
|
|
9
9
|
import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
|
|
10
|
-
import { n as createStatelyInspector, t as createInspector } from "./inspect-
|
|
10
|
+
import { n as createStatelyInspector, t as createInspector } from "./inspect-CWFYJT9G.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";
|
|
@@ -100,7 +100,16 @@ interface InspectedEvent {
|
|
|
100
100
|
sourceSessionId: string | null;
|
|
101
101
|
event: unknown;
|
|
102
102
|
}
|
|
103
|
+
interface InspectorConnection {
|
|
104
|
+
inspectorUrl: string | null;
|
|
105
|
+
relayUrl: string | null;
|
|
106
|
+
roomId: string;
|
|
107
|
+
producerId: string;
|
|
108
|
+
}
|
|
109
|
+
/** Browser-page discovery metadata consumed by the Stately DevTools extension. */
|
|
110
|
+
type InspectorDiscoveryEntry = InspectorConnection;
|
|
103
111
|
interface InspectorEvents {
|
|
112
|
+
connected: InspectorConnection;
|
|
104
113
|
actor: AdoptedActor;
|
|
105
114
|
event: InspectedEvent;
|
|
106
115
|
snapshot: InspectedSnapshot;
|
|
@@ -148,7 +157,9 @@ interface CreateInspectorOptions {
|
|
|
148
157
|
* is derived from the relay URL by replacing `ws` with `http`.
|
|
149
158
|
*/
|
|
150
159
|
inspectorBaseUrl?: string;
|
|
151
|
-
/**
|
|
160
|
+
/** How to launch the inspector UI. Defaults to `none` in every runtime. */
|
|
161
|
+
launch?: 'none' | 'browser';
|
|
162
|
+
/** @deprecated Use `launch: 'browser'` or `launch: 'none'`. */
|
|
152
163
|
autoOpen?: boolean;
|
|
153
164
|
/**
|
|
154
165
|
* Legacy name for the unguessable room capability.
|
|
@@ -260,4 +271,4 @@ declare function createInspector(options?: CreateInspectorOptions): Inspector;
|
|
|
260
271
|
/** @deprecated Use {@link createInspector}. */
|
|
261
272
|
declare const createStatelyInspector: typeof createInspector;
|
|
262
273
|
//#endregion
|
|
263
|
-
export { InspectedTransition as a,
|
|
274
|
+
export { createWebSocketTransport as _, InspectedTransition as a, InspectorDiscoveryEntry as c, ManualActorOptions as d, createInspector as f, createPostMessageTransport as g, TransportFailure as h, InspectedSnapshot as i, InspectorEvents as l, Transport as m, CreateInspectorOptions as n, Inspector as o, createStatelyInspector as p, InspectedEvent as r, InspectorConnection as s, AdoptedActor as t, InspectorInspectionEvent as u };
|
|
@@ -1,9 +1,9 @@
|
|
|
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-
|
|
2
|
+
import { a as createEventRegistry, i as createWebSocketTransport, n as inspectionRuntime, o as createPendingExportManager, t as SDK_VERSION } from "./version-DX-_ZovM.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/openBrowser.ts
|
|
5
5
|
async function openBrowser(url) {
|
|
6
|
-
if (typeof process === "undefined" || !process.versions?.node || typeof process.getBuiltinModule !== "function")
|
|
6
|
+
if (typeof process === "undefined" || !process.versions?.node || typeof process.getBuiltinModule !== "function") throw new Error("Opening a browser is not supported in this runtime.");
|
|
7
7
|
const { spawn } = process.getBuiltinModule("node:child_process");
|
|
8
8
|
const child = spawn(process.platform === "darwin" ? "open" : process.platform === "win32" ? "powershell.exe" : "xdg-open", process.platform === "win32" ? [
|
|
9
9
|
"-NoProfile",
|
|
@@ -37,6 +37,19 @@ function isStoppedSnapshot(snapshot) {
|
|
|
37
37
|
const status = snapshot?.status;
|
|
38
38
|
return status === "done" || status === "stopped" || status === "error";
|
|
39
39
|
}
|
|
40
|
+
const browserInspectorRegistryKey = "__statelyInspectorsV1";
|
|
41
|
+
function isBrowserRuntime() {
|
|
42
|
+
return typeof window !== "undefined" && window === globalThis;
|
|
43
|
+
}
|
|
44
|
+
function getBrowserInspectorRegistry() {
|
|
45
|
+
const global = globalThis;
|
|
46
|
+
if (!global.__statelyInspectorsV1) Object.defineProperty(global, browserInspectorRegistryKey, {
|
|
47
|
+
value: /* @__PURE__ */ new Map(),
|
|
48
|
+
enumerable: false,
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
return global.__statelyInspectorsV1;
|
|
52
|
+
}
|
|
40
53
|
function generateRoomId() {
|
|
41
54
|
if (!globalThis.crypto?.randomUUID) throw new Error("createInspector() requires crypto.randomUUID() to generate a secure room capability. Pass roomId explicitly in older runtimes.");
|
|
42
55
|
return globalThis.crypto.randomUUID();
|
|
@@ -44,7 +57,8 @@ function generateRoomId() {
|
|
|
44
57
|
function createInspector(options = {}) {
|
|
45
58
|
const environmentUrl = typeof process !== "undefined" ? process.env?.STATELY_INSPECT_URL : void 0;
|
|
46
59
|
const url = options.url ?? environmentUrl ?? "wss://sky.stately.ai";
|
|
47
|
-
const { inspectorBaseUrl,
|
|
60
|
+
const { inspectorBaseUrl, name, serializeSnapshot = defaultSerializeSnapshot, selectedSessionId: configuredSelectedSessionId, selectedActorId, panels, theme, readOnly, depth, capabilities, transport: injectedTransport } = options;
|
|
61
|
+
const launch = options.launch ?? (options.autoOpen === true ? "browser" : "none");
|
|
48
62
|
const extractMachine = options.extractMachine ?? options.extractMachineConfig ?? defaultExtractMachineConfig;
|
|
49
63
|
const roomId = options.roomId ?? options.sessionId ?? getInspectionRoomId(url) ?? generateRoomId();
|
|
50
64
|
const producerId = options.producerId ?? generateRoomId();
|
|
@@ -55,13 +69,24 @@ function createInspector(options = {}) {
|
|
|
55
69
|
});
|
|
56
70
|
const relayUrl = roomUrls?.relayUrl ?? null;
|
|
57
71
|
const inspectorUrl = roomUrls?.inspectorUrl ?? null;
|
|
72
|
+
const connection = {
|
|
73
|
+
inspectorUrl,
|
|
74
|
+
relayUrl,
|
|
75
|
+
roomId,
|
|
76
|
+
producerId
|
|
77
|
+
};
|
|
58
78
|
const displayName = name ?? "system:manual";
|
|
79
|
+
if (inspectorUrl && launch === "none") console.info(`[Stately Inspector] ${inspectorUrl}`);
|
|
80
|
+
const browserRegistry = isBrowserRuntime() ? getBrowserInspectorRegistry() : void 0;
|
|
81
|
+
browserRegistry?.set(producerId, connection);
|
|
82
|
+
const browserLaunchUnsupported = launch === "browser" && isBrowserRuntime();
|
|
83
|
+
if (browserLaunchUnsupported) console.warn("createInspector({ launch: 'browser' }) cannot open a browser from a browser runtime. Open inspectorUrl from a user gesture or use the Stately DevTools extension.");
|
|
59
84
|
let destroyed = false;
|
|
60
85
|
let initSent = false;
|
|
61
86
|
let initialized = false;
|
|
62
87
|
let pendingTransportReady = false;
|
|
63
88
|
let transportWasReady = false;
|
|
64
|
-
let
|
|
89
|
+
let didLaunch = false;
|
|
65
90
|
let resolveReady;
|
|
66
91
|
let rejectReady;
|
|
67
92
|
let readySettled = false;
|
|
@@ -106,8 +131,20 @@ function createInspector(options = {}) {
|
|
|
106
131
|
initSent = false;
|
|
107
132
|
sendInit();
|
|
108
133
|
}
|
|
109
|
-
|
|
110
|
-
|
|
134
|
+
queueMicrotask(() => {
|
|
135
|
+
if (!destroyed) emitLocal("connected", connection);
|
|
136
|
+
});
|
|
137
|
+
if (launch === "browser" && !didLaunch && ownsTransport) {
|
|
138
|
+
didLaunch = true;
|
|
139
|
+
if (browserLaunchUnsupported) {
|
|
140
|
+
const failure = {
|
|
141
|
+
code: "unsupported_launch",
|
|
142
|
+
message: "createInspector({ launch: 'browser' }) is unsupported in browser runtimes."
|
|
143
|
+
};
|
|
144
|
+
emitLocal("error", failure);
|
|
145
|
+
events.emit("error", failure);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
111
148
|
if (inspectorUrl) openBrowser(inspectorUrl).catch((error) => {
|
|
112
149
|
const failure = {
|
|
113
150
|
code: "open_failed",
|
|
@@ -581,6 +618,7 @@ function createInspector(options = {}) {
|
|
|
581
618
|
destroy() {
|
|
582
619
|
if (destroyed) return;
|
|
583
620
|
destroyed = true;
|
|
621
|
+
if (browserRegistry?.get(producerId) === connection) browserRegistry.delete(producerId);
|
|
584
622
|
try {
|
|
585
623
|
for (const { subscription } of inspectedRoots.values()) subscription.unsubscribe();
|
|
586
624
|
} catch {}
|
package/dist/inspect.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InspectionAction, InspectionSentEvent, InspectionTakenTransition } from "./protocol.mjs";
|
|
2
|
-
import { a as InspectedTransition, c as
|
|
3
|
-
export { AdoptedActor, CreateInspectorOptions, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InspectedEvent, InspectedSnapshot, InspectedTransition, InspectionAction, InspectionSentEvent, InspectionTakenTransition, Inspector, InspectorEvents, InspectorInspectionEvent, ManualActorOptions, Transport, createInspector, createStatelyInspector };
|
|
2
|
+
import { a as InspectedTransition, c as InspectorDiscoveryEntry, d as ManualActorOptions, f as createInspector, 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";
|
|
3
|
+
export { AdoptedActor, CreateInspectorOptions, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InspectedEvent, InspectedSnapshot, InspectedTransition, InspectionAction, InspectionSentEvent, InspectionTakenTransition, Inspector, InspectorConnection, InspectorDiscoveryEntry, InspectorEvents, InspectorInspectionEvent, ManualActorOptions, Transport, createInspector, createStatelyInspector };
|
package/dist/inspect.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./version-
|
|
2
|
-
import { n as createStatelyInspector, t as createInspector } from "./inspect-
|
|
1
|
+
import "./version-DX-_ZovM.mjs";
|
|
2
|
+
import { n as createStatelyInspector, t as createInspector } from "./inspect-CWFYJT9G.mjs";
|
|
3
3
|
|
|
4
4
|
export { createInspector, createStatelyInspector };
|
package/dist/protocol.d.mts
CHANGED
|
@@ -35,8 +35,52 @@ interface CommentsConfig {
|
|
|
35
35
|
interface ProjectEmbedMachine {
|
|
36
36
|
id: string;
|
|
37
37
|
name?: string;
|
|
38
|
+
/** Optional host project scope for machine-to-machine references. */
|
|
39
|
+
projectId?: string;
|
|
38
40
|
machine: unknown;
|
|
39
41
|
}
|
|
42
|
+
type ProjectWorkspaceActionIcon = 'arrow-left' | 'copy' | 'fork' | 'history';
|
|
43
|
+
interface ProjectWorkspaceAction {
|
|
44
|
+
id: string;
|
|
45
|
+
label: string;
|
|
46
|
+
icon?: ProjectWorkspaceActionIcon;
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
}
|
|
49
|
+
interface ProjectWorkspaceMachine {
|
|
50
|
+
id: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
}
|
|
53
|
+
interface ProjectWorkspaceProject {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
machines: ProjectWorkspaceMachine[];
|
|
57
|
+
rootMachineId?: string;
|
|
58
|
+
}
|
|
59
|
+
/** Host-backed operations for the built-in workspace controls. */
|
|
60
|
+
interface ProjectWorkspaceCapabilities {
|
|
61
|
+
renameProject?: ProjectWorkspaceAction;
|
|
62
|
+
createMachine?: ProjectWorkspaceAction;
|
|
63
|
+
renameMachine?: ProjectWorkspaceAction;
|
|
64
|
+
copyMachine?: ProjectWorkspaceAction;
|
|
65
|
+
deleteMachine?: ProjectWorkspaceAction;
|
|
66
|
+
setRootMachine?: ProjectWorkspaceAction;
|
|
67
|
+
}
|
|
68
|
+
/** Serializable workspace tree rendered by project-mode embeds. */
|
|
69
|
+
interface ProjectWorkspaceConfig {
|
|
70
|
+
/** Visible projects; pass one entry when embedding a single project. */
|
|
71
|
+
projects: ProjectWorkspaceProject[];
|
|
72
|
+
defaultProjectId?: string;
|
|
73
|
+
backAction?: ProjectWorkspaceAction;
|
|
74
|
+
userAvatarUrl?: string;
|
|
75
|
+
machineSelectionDisabled?: boolean;
|
|
76
|
+
/** Optional host-backed operations for the built-in workspace controls. */
|
|
77
|
+
workspaceCapabilities?: ProjectWorkspaceCapabilities;
|
|
78
|
+
/** Actions rendered from the workspace options menu. */
|
|
79
|
+
workspaceActions?: ProjectWorkspaceAction[];
|
|
80
|
+
/** Optional actions keyed by project or machine id. */
|
|
81
|
+
projectActions?: Record<string, ProjectWorkspaceAction[]>;
|
|
82
|
+
machineActions?: Record<string, ProjectWorkspaceAction[]>;
|
|
83
|
+
}
|
|
40
84
|
declare const EMBED_DOCUMENT_LANGUAGES: readonly ["markdown", "typescript", "javascript", "json", "xml", "mermaid", "text"];
|
|
41
85
|
type EmbedDocumentLanguage = (typeof EMBED_DOCUMENT_LANGUAGES)[number];
|
|
42
86
|
declare const EMBED_DOCUMENT_LIMITS: {
|
|
@@ -171,6 +215,15 @@ interface EmbedEventMap {
|
|
|
171
215
|
machineSelected: {
|
|
172
216
|
machineId: string;
|
|
173
217
|
};
|
|
218
|
+
projectWorkspaceAction: {
|
|
219
|
+
actionId: string;
|
|
220
|
+
projectId?: string;
|
|
221
|
+
machineId?: string;
|
|
222
|
+
data?: unknown;
|
|
223
|
+
};
|
|
224
|
+
projectWorkspaceOpenChanged: {
|
|
225
|
+
open: boolean;
|
|
226
|
+
};
|
|
174
227
|
viewModeChanged: {
|
|
175
228
|
viewMode: 'graph' | 'list';
|
|
176
229
|
machineId?: string;
|
|
@@ -249,6 +302,8 @@ interface ProjectInitOptions {
|
|
|
249
302
|
activePanels?: string[];
|
|
250
303
|
};
|
|
251
304
|
commentsByMachineId?: Record<string, CommentsConfig>;
|
|
305
|
+
projectWorkspace?: ProjectWorkspaceConfig;
|
|
306
|
+
projectWorkspaceOpen?: boolean;
|
|
252
307
|
settings?: Record<string, unknown>;
|
|
253
308
|
unsavedIndicator?: {
|
|
254
309
|
enabled?: boolean;
|
|
@@ -321,6 +376,8 @@ interface ProjectInitMessage {
|
|
|
321
376
|
rightPanels?: string[];
|
|
322
377
|
activePanels?: string[];
|
|
323
378
|
commentsByMachineId?: Record<string, CommentsConfig>;
|
|
379
|
+
projectWorkspace?: ProjectWorkspaceConfig;
|
|
380
|
+
projectWorkspaceOpen?: boolean;
|
|
324
381
|
settings?: Record<string, unknown>;
|
|
325
382
|
unsavedIndicator?: {
|
|
326
383
|
enabled?: boolean;
|
|
@@ -333,11 +390,17 @@ interface ProjectUpdateMessage {
|
|
|
333
390
|
machines: ProjectEmbedMachine[];
|
|
334
391
|
currentMachineId?: string;
|
|
335
392
|
commentsByMachineId?: Record<string, CommentsConfig>;
|
|
393
|
+
projectWorkspace?: ProjectWorkspaceConfig;
|
|
394
|
+
projectWorkspaceOpen?: boolean;
|
|
336
395
|
}
|
|
337
396
|
interface ProjectSelectMachineMessage {
|
|
338
397
|
type: '@statelyai.project.selectMachine';
|
|
339
398
|
machineId: string;
|
|
340
399
|
}
|
|
400
|
+
interface ProjectSetWorkspaceOpenMessage {
|
|
401
|
+
type: '@statelyai.project.setWorkspaceOpen';
|
|
402
|
+
open: boolean;
|
|
403
|
+
}
|
|
341
404
|
interface UpdateMessage {
|
|
342
405
|
type: '@statelyai.update';
|
|
343
406
|
machine: unknown;
|
|
@@ -510,6 +573,17 @@ interface ProjectMachineSelectedMessage {
|
|
|
510
573
|
type: '@statelyai.project.machineSelected';
|
|
511
574
|
machineId: string;
|
|
512
575
|
}
|
|
576
|
+
interface ProjectWorkspaceActionMessage {
|
|
577
|
+
type: '@statelyai.project.workspaceAction';
|
|
578
|
+
actionId: string;
|
|
579
|
+
projectId?: string;
|
|
580
|
+
machineId?: string;
|
|
581
|
+
data?: unknown;
|
|
582
|
+
}
|
|
583
|
+
interface ProjectWorkspaceOpenChangedMessage {
|
|
584
|
+
type: '@statelyai.project.workspaceOpenChanged';
|
|
585
|
+
open: boolean;
|
|
586
|
+
}
|
|
513
587
|
interface ViewModeChangedMessage {
|
|
514
588
|
type: '@statelyai.viewModeChanged';
|
|
515
589
|
viewMode: 'graph' | 'list';
|
|
@@ -583,9 +657,9 @@ interface ExtensionResultMessage {
|
|
|
583
657
|
error?: string;
|
|
584
658
|
}
|
|
585
659
|
/** All messages a client (embed/inspector) can send to the viz. */
|
|
586
|
-
type ClientMessage = InitMessage | SetApiKeyMessage | EditorHandshakeMessage | SavedMessage | ClipboardReadResponseMessage | ClipboardWriteResponseMessage | ProjectInitMessage | ProjectUpdateMessage | ProjectSelectMachineMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | SystemInitMessage | SystemSelectActorMessage | SystemActorRegisteredMessage | SystemActorEventMessage | SystemActorSnapshotMessage | SystemActorStoppedMessage | UploadCapabilitiesMessage | UploadResponseMessage | ExtensionResultMessage | ErrorMessage;
|
|
660
|
+
type ClientMessage = InitMessage | SetApiKeyMessage | EditorHandshakeMessage | SavedMessage | ClipboardReadResponseMessage | ClipboardWriteResponseMessage | ProjectInitMessage | ProjectUpdateMessage | ProjectSelectMachineMessage | ProjectSetWorkspaceOpenMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | SystemInitMessage | SystemSelectActorMessage | SystemActorRegisteredMessage | SystemActorEventMessage | SystemActorSnapshotMessage | SystemActorStoppedMessage | UploadCapabilitiesMessage | UploadResponseMessage | ExtensionResultMessage | ErrorMessage;
|
|
587
661
|
/** All messages the viz can send back to a client. */
|
|
588
|
-
type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | ProjectMachineSelectedMessage | ViewModeChangedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | ClipboardReadMessage | ClipboardWriteMessage | UploadRequestMessage | ExtensionCallMessage;
|
|
662
|
+
type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | ProjectMachineSelectedMessage | ProjectWorkspaceActionMessage | ProjectWorkspaceOpenChangedMessage | ViewModeChangedMessage | RetrievedMessage | ErrorMessage | CapabilityDeniedMessage | ClipboardReadMessage | ClipboardWriteMessage | UploadRequestMessage | ExtensionCallMessage;
|
|
589
663
|
interface InspectionClientMetadata {
|
|
590
664
|
name?: string;
|
|
591
665
|
machineId?: string;
|
|
@@ -614,4 +688,4 @@ declare const PREFIX = "@statelyai.";
|
|
|
614
688
|
/** Current WebSocket inspection protocol version. */
|
|
615
689
|
declare const INSPECTION_PROTOCOL_VERSION = 2;
|
|
616
690
|
//#endregion
|
|
617
|
-
export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, ClipboardReadMessage, ClipboardReadResponseMessage, ClipboardWriteMessage, ClipboardWriteResponseMessage, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EditorHandshakeMessage, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExtensionsManifest, EmbedFormatManifest, EmbedMode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, ExtensionCallMessage, ExtensionResultMessage, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitMessage, InitOptions, InspectSnapshotMessage, InspectionAction, InspectionClientMetadata, InspectionRoomUrls, InspectionSentEvent, InspectionTakenTransition, LoadedMessage, MachineInitOptions, MachineSourceLocations, PREFIX, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectUpdateMessage, ProtocolMessage, ReadOnlyReason, ReadyMessage, RegisterMessage, RegisteredMessage, RetrieveMessage, RetrievedMessage, SaveMessage, SavedMessage, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorEventMessage, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, SystemSelectActorMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, ViewModeChangedMessage, VizMessage, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId };
|
|
691
|
+
export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, ClipboardReadMessage, ClipboardReadResponseMessage, ClipboardWriteMessage, ClipboardWriteResponseMessage, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EditorHandshakeMessage, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedExtensionsManifest, EmbedFormatManifest, EmbedMode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, ExtensionCallMessage, ExtensionResultMessage, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitMessage, InitOptions, InspectSnapshotMessage, InspectionAction, InspectionClientMetadata, InspectionRoomUrls, InspectionSentEvent, InspectionTakenTransition, LoadedMessage, MachineInitOptions, MachineSourceLocations, PREFIX, ProjectEmbedMachine, ProjectInitMessage, ProjectInitOptions, ProjectMachineSelectedMessage, ProjectSelectMachineMessage, ProjectSetWorkspaceOpenMessage, ProjectUpdateMessage, ProjectWorkspaceAction, ProjectWorkspaceActionIcon, ProjectWorkspaceActionMessage, ProjectWorkspaceCapabilities, ProjectWorkspaceConfig, ProjectWorkspaceMachine, ProjectWorkspaceOpenChangedMessage, ProjectWorkspaceProject, ProtocolMessage, ReadOnlyReason, ReadyMessage, RegisterMessage, RegisteredMessage, RetrieveMessage, RetrievedMessage, SaveMessage, SavedMessage, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorEventMessage, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, SystemSelectActorMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, ViewModeChangedMessage, VizMessage, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId };
|
|
@@ -4077,10 +4077,13 @@ function collectBindings(file) {
|
|
|
4077
4077
|
}
|
|
4078
4078
|
function isCreateMachineCall(node) {
|
|
4079
4079
|
const expression = node.expression;
|
|
4080
|
-
if (ts.isIdentifier(expression)) return expression.text
|
|
4081
|
-
if (ts.isPropertyAccessExpression(expression)) return expression.name.text
|
|
4080
|
+
if (ts.isIdentifier(expression)) return isMachineFactoryName(expression.text);
|
|
4081
|
+
if (ts.isPropertyAccessExpression(expression)) return isMachineFactoryName(expression.name.text);
|
|
4082
4082
|
return false;
|
|
4083
4083
|
}
|
|
4084
|
+
function isMachineFactoryName(name) {
|
|
4085
|
+
return name === "createMachine" || name === "createMachineFromConfig";
|
|
4086
|
+
}
|
|
4084
4087
|
function setupCallForCreateMachine(node, bindings) {
|
|
4085
4088
|
if (!ts.isPropertyAccessExpression(node.expression)) return null;
|
|
4086
4089
|
let receiver = unwrapExpression(node.expression.expression);
|
|
@@ -4140,6 +4143,10 @@ function hasV6Syntax(source) {
|
|
|
4140
4143
|
}
|
|
4141
4144
|
function visitMachineCalls(node) {
|
|
4142
4145
|
if (ts.isCallExpression(node) && isCreateMachineCall(node)) {
|
|
4146
|
+
if ((ts.isIdentifier(node.expression) ? node.expression.text : ts.isPropertyAccessExpression(node.expression) ? node.expression.name.text : void 0) === "createMachineFromConfig") {
|
|
4147
|
+
found = true;
|
|
4148
|
+
return;
|
|
4149
|
+
}
|
|
4143
4150
|
const config = node.arguments[0];
|
|
4144
4151
|
if (config) visitSyntax(config);
|
|
4145
4152
|
const setupConfig = setupCallForCreateMachine(node, bindings)?.arguments[0];
|
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-
|
|
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-0djA1cnm.mjs";
|
|
4
4
|
import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
|
|
5
5
|
import * as ts$1 from "typescript";
|
|
6
6
|
import ts from "typescript";
|
|
@@ -704,7 +704,8 @@ function getEnumMemberName(name) {
|
|
|
704
704
|
return null;
|
|
705
705
|
}
|
|
706
706
|
function isCreateMachineExpression$1(expression) {
|
|
707
|
-
|
|
707
|
+
const isMachineFactoryName = (name) => name === "createMachine" || name === "createMachineFromConfig";
|
|
708
|
+
return ts$1.isIdentifier(expression) && isMachineFactoryName(expression.text) || ts$1.isPropertyAccessExpression(expression) && isMachineFactoryName(expression.name.text);
|
|
708
709
|
}
|
|
709
710
|
function unwrapObjectLiteralExpression(expression) {
|
|
710
711
|
const unwrapped = unwrapExpression$1(expression);
|
|
@@ -127,6 +127,8 @@ function toInitMessage(options) {
|
|
|
127
127
|
rightPanels: options.panels?.rightPanels,
|
|
128
128
|
activePanels: options.panels?.activePanels,
|
|
129
129
|
commentsByMachineId: options.commentsByMachineId,
|
|
130
|
+
projectWorkspace: options.projectWorkspace,
|
|
131
|
+
projectWorkspaceOpen: options.projectWorkspaceOpen,
|
|
130
132
|
settings: options.settings,
|
|
131
133
|
unsavedIndicator: options.unsavedIndicator
|
|
132
134
|
};
|
|
@@ -331,7 +333,7 @@ function createWebSocketTransport(options) {
|
|
|
331
333
|
|
|
332
334
|
//#endregion
|
|
333
335
|
//#region src/version.ts
|
|
334
|
-
const SDK_VERSION = "0.
|
|
336
|
+
const SDK_VERSION = "0.23.1";
|
|
335
337
|
function inspectionRuntime() {
|
|
336
338
|
if (typeof window !== "undefined") return "browser";
|
|
337
339
|
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.
|
|
3
|
+
"version": "0.23.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"stately-sdk": "./dist/bin.mjs"
|
|
@@ -93,8 +93,8 @@
|
|
|
93
93
|
"jsdom": "^27.4.0",
|
|
94
94
|
"tsdown": "0.21.0-beta.2",
|
|
95
95
|
"vitest": "^3.2.4",
|
|
96
|
-
"@statelyai/api-contract": "0.3.
|
|
97
|
-
"@statelyai/graph-tools": "0.2.
|
|
96
|
+
"@statelyai/api-contract": "0.3.8",
|
|
97
|
+
"@statelyai/graph-tools": "0.2.2"
|
|
98
98
|
},
|
|
99
99
|
"engines": {
|
|
100
100
|
"node": ">=22.4"
|