@statelyai/sdk 0.16.2 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +4 -4
- package/dist/{inspect-BScvqVcM.d.mts → inspect-BZFzyeew.d.mts} +12 -5
- package/dist/{inspect-DxOsKzlq.mjs → inspect-CF_6aEnv.mjs} +12 -6
- package/dist/inspect.d.mts +1 -1
- package/dist/inspect.mjs +1 -1
- package/dist/protocol.d.mts +9 -3
- package/dist/protocol.mjs +9 -1
- package/dist/{statelyPragma-Bm9O4XV6.mjs → statelyPragma-Th0gdXfx.mjs} +0 -1
- package/dist/sync.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -170,12 +170,24 @@ actor.start();
|
|
|
170
170
|
If you already have the actor reference, `inspector.attach(actor)` subscribes to
|
|
171
171
|
its system and backfills actors that are already running.
|
|
172
172
|
|
|
173
|
+
When authored source is available, return it from `extractMachine` so the
|
|
174
|
+
visualizer preserves executable guards, inputs, and outputs instead of only a
|
|
175
|
+
JSON-safe machine structure:
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
const inspector = createInspector({
|
|
179
|
+
extractMachine: (actor) =>
|
|
180
|
+
actor.logic === machine ? machineSource : actor.logic?.config,
|
|
181
|
+
});
|
|
182
|
+
```
|
|
183
|
+
|
|
173
184
|
Stopped actors remain in `inspector.actors` and in reconnect checkpoints, so
|
|
174
185
|
completed request-scoped runs stay available for inspection.
|
|
175
186
|
|
|
176
187
|
XState v5 and v6 inspection events normalize to independent actor, event,
|
|
177
188
|
snapshot, and stop observations before crossing the WebSocket protocol.
|
|
178
|
-
`actorId` is system-local
|
|
189
|
+
`actorId` is system-local and `sessionId` is process-local. A room uses
|
|
190
|
+
`producerId + sessionId` as the global actor identity.
|
|
179
191
|
Observations captured before the first transport registration replay in order
|
|
180
192
|
after the initial actor-tree baseline. Reconnects use the latest checkpoint.
|
|
181
193
|
In Node, the inspector opens in the default browser automatically. The SDK
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
|
|
2
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
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";
|
|
4
|
-
import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, ProjectEmbedMachine, UploadResult, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
4
|
+
import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, 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
6
|
import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-2Thaw42j.mjs";
|
|
7
7
|
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-
|
|
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
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";
|
|
10
10
|
import { OAuthAuthorizationServerMetadata, OAuthClientRegistrationResponse, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
|
|
11
11
|
import { PlanSyncOptions, PullSyncResult, PushLocalMachineLinksResult, PushSyncOptions, PushSyncProjectOptions, PushSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
|
|
@@ -32,4 +32,4 @@ declare function findStatelyPragmaAttachments(sourceText: string, fileName?: str
|
|
|
32
32
|
declare function getStatelyPragma(sourceText: string, fileName?: string, machineIndex?: number): StatelyPragma | undefined;
|
|
33
33
|
declare function upsertStatelyPragma(sourceText: string, id: string, options?: UpsertStatelyPragmaOptions): string;
|
|
34
34
|
//#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, type EditorCapabilities, 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, 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 };
|
|
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, type EditorCapabilities, 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 };
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-B_ig9Znn.mjs";
|
|
2
|
-
import { INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
2
|
+
import { INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
3
3
|
import { createStatelyEmbed } from "./embed.mjs";
|
|
4
4
|
import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
|
|
5
|
-
import { n as createStatelyInspector, t as createInspector } from "./inspect-
|
|
5
|
+
import { n as createStatelyInspector, t as createInspector } from "./inspect-CF_6aEnv.mjs";
|
|
6
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-
|
|
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-Th0gdXfx.mjs";
|
|
8
8
|
import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
|
|
9
9
|
import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
|
|
10
10
|
import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
|
|
11
11
|
import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
|
|
12
12
|
import { createInspectionRelay } from "./relay.mjs";
|
|
13
13
|
|
|
14
|
-
export { DEFAULT_STATELY_BASE_URL, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, 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 };
|
|
14
|
+
export { DEFAULT_STATELY_BASE_URL, 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 };
|
|
@@ -62,7 +62,7 @@ interface InspectorInspectionEvent {
|
|
|
62
62
|
readonly actorRef: unknown;
|
|
63
63
|
}
|
|
64
64
|
interface AdoptedActor {
|
|
65
|
-
/**
|
|
65
|
+
/** XState process-local `actor.sessionId`. Pair with inspector.producerId. */
|
|
66
66
|
sessionId: string;
|
|
67
67
|
/** System-local `actor.id`. */
|
|
68
68
|
actorId: string;
|
|
@@ -76,7 +76,7 @@ interface AdoptedActor {
|
|
|
76
76
|
snapshot: unknown | null;
|
|
77
77
|
/** Whether the actor has stopped. Stopped actors remain inspectable. */
|
|
78
78
|
stopped: boolean;
|
|
79
|
-
/** Machine config sent to the visualizer, or `null` for non-machine actors. */
|
|
79
|
+
/** Machine source or config sent to the visualizer, or `null` for non-machine actors. */
|
|
80
80
|
machineConfig: unknown;
|
|
81
81
|
}
|
|
82
82
|
/** One observed snapshot, independent of the XState inspection version. */
|
|
@@ -161,8 +161,15 @@ interface CreateInspectorOptions {
|
|
|
161
161
|
*/
|
|
162
162
|
serializeSnapshot?: (snapshot: MinimalSnapshot) => unknown;
|
|
163
163
|
/**
|
|
164
|
-
* Extract the machine
|
|
165
|
-
*
|
|
164
|
+
* Extract the machine sent to the visualizer for a given actor. Return an
|
|
165
|
+
* XState source string to preserve executable expressions, a machine config
|
|
166
|
+
* object for structural inspection, or `null` for non-machine actors.
|
|
167
|
+
* Defaults to reading `actor.logic.config`.
|
|
168
|
+
*/
|
|
169
|
+
extractMachine?: (actor: any, source?: unknown) => unknown;
|
|
170
|
+
/**
|
|
171
|
+
* Extract the machine config for a given actor.
|
|
172
|
+
* @deprecated Use {@link extractMachine}; it also accepts source strings.
|
|
166
173
|
*/
|
|
167
174
|
extractMachineConfig?: (actor: any, source?: unknown) => unknown;
|
|
168
175
|
/** Selected actor session id to focus on first. */
|
|
@@ -186,7 +193,7 @@ interface CreateInspectorOptions {
|
|
|
186
193
|
transport?: Transport;
|
|
187
194
|
}
|
|
188
195
|
interface Inspector {
|
|
189
|
-
/** Snapshot of
|
|
196
|
+
/** Snapshot of this producer's actors keyed by XState `sessionId`. */
|
|
190
197
|
readonly actors: ReadonlyMap<string, AdoptedActor>;
|
|
191
198
|
/** Unguessable inspection room capability. */
|
|
192
199
|
readonly roomId: string;
|
|
@@ -28,7 +28,7 @@ async function openBrowser(url) {
|
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/version.ts
|
|
31
|
-
const SDK_VERSION = "0.
|
|
31
|
+
const SDK_VERSION = "0.17.0";
|
|
32
32
|
function inspectionRuntime() {
|
|
33
33
|
if (typeof window !== "undefined") return "browser";
|
|
34
34
|
if (typeof process !== "undefined" && process.versions?.node) return "node";
|
|
@@ -53,7 +53,8 @@ function generateRoomId() {
|
|
|
53
53
|
function createInspector(options = {}) {
|
|
54
54
|
const environmentUrl = typeof process !== "undefined" ? process.env?.STATELY_INSPECT_URL : void 0;
|
|
55
55
|
const url = options.url ?? environmentUrl ?? "wss://sky.stately.ai";
|
|
56
|
-
const { inspectorBaseUrl, autoOpen = true, name, serializeSnapshot = defaultSerializeSnapshot,
|
|
56
|
+
const { inspectorBaseUrl, autoOpen = true, name, serializeSnapshot = defaultSerializeSnapshot, selectedSessionId: configuredSelectedSessionId, selectedActorId, panels, theme, readOnly, depth, capabilities, transport: injectedTransport } = options;
|
|
57
|
+
const extractMachine = options.extractMachine ?? options.extractMachineConfig ?? defaultExtractMachineConfig;
|
|
57
58
|
const roomId = options.roomId ?? options.sessionId ?? getInspectionRoomId(url) ?? generateRoomId();
|
|
58
59
|
const producerId = options.producerId ?? generateRoomId();
|
|
59
60
|
const roomUrls = injectedTransport ? null : createInspectionRoomUrls({
|
|
@@ -101,6 +102,7 @@ function createInspector(options = {}) {
|
|
|
101
102
|
transport.send(msg);
|
|
102
103
|
}
|
|
103
104
|
function handleTransportReady() {
|
|
105
|
+
if (destroyed) return;
|
|
104
106
|
if (!transportWasReady) {
|
|
105
107
|
transportWasReady = true;
|
|
106
108
|
if (!initSent) sendInit();
|
|
@@ -125,14 +127,15 @@ function createInspector(options = {}) {
|
|
|
125
127
|
});
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
|
-
transport.onReady(() => {
|
|
130
|
+
const stopTransportReady = transport.onReady(() => {
|
|
129
131
|
if (!initialized) {
|
|
130
132
|
pendingTransportReady = true;
|
|
131
133
|
return;
|
|
132
134
|
}
|
|
133
135
|
handleTransportReady();
|
|
134
136
|
});
|
|
135
|
-
transport.onError?.((failure) => {
|
|
137
|
+
const stopTransportError = transport.onError?.((failure) => {
|
|
138
|
+
if (destroyed) return;
|
|
136
139
|
const error = new Error(failure.message);
|
|
137
140
|
if (!readySettled) {
|
|
138
141
|
readySettled = true;
|
|
@@ -141,7 +144,7 @@ function createInspector(options = {}) {
|
|
|
141
144
|
emitLocal("error", failure);
|
|
142
145
|
events.emit("error", failure);
|
|
143
146
|
});
|
|
144
|
-
transport.onMessage((msg) => {
|
|
147
|
+
const stopTransportMessages = transport.onMessage((msg) => {
|
|
145
148
|
if (destroyed) return;
|
|
146
149
|
switch (msg.type) {
|
|
147
150
|
case "@statelyai.retrieved":
|
|
@@ -205,7 +208,7 @@ function createInspector(options = {}) {
|
|
|
205
208
|
systemId: actorRef.systemId,
|
|
206
209
|
snapshot: details?.snapshot ? serializeSnapshot(details.snapshot) : snapshotValue(actorRef),
|
|
207
210
|
stopped: stoppedValue(actorRef, details?.snapshot),
|
|
208
|
-
machineConfig:
|
|
211
|
+
machineConfig: extractMachine(actorRef, details?.source ?? actorRef.src)
|
|
209
212
|
};
|
|
210
213
|
}
|
|
211
214
|
function toSystemEntry(entry) {
|
|
@@ -555,6 +558,9 @@ function createInspector(options = {}) {
|
|
|
555
558
|
try {
|
|
556
559
|
for (const { subscription } of inspectedRoots.values()) subscription.unsubscribe();
|
|
557
560
|
} catch {}
|
|
561
|
+
stopTransportReady();
|
|
562
|
+
stopTransportError?.();
|
|
563
|
+
stopTransportMessages();
|
|
558
564
|
if (ownsTransport) transport.destroy();
|
|
559
565
|
exportManager.clear("Inspector destroyed");
|
|
560
566
|
events.clear();
|
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 InspectorInspectionEvent, d as createStatelyInspector, f as Transport, i as InspectedSnapshot, l as ManualActorOptions, n as CreateInspectorOptions, o as Inspector, r as InspectedEvent, s as InspectorEvents, t as AdoptedActor, u as createInspector } from "./inspect-
|
|
2
|
+
import { a as InspectedTransition, c as InspectorInspectionEvent, d as createStatelyInspector, f as Transport, i as InspectedSnapshot, l as ManualActorOptions, n as CreateInspectorOptions, o as Inspector, r as InspectedEvent, s as InspectorEvents, t as AdoptedActor, u as createInspector } from "./inspect-BZFzyeew.mjs";
|
|
3
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 };
|
package/dist/inspect.mjs
CHANGED
package/dist/protocol.d.mts
CHANGED
|
@@ -3,6 +3,12 @@ import { i as StatelyGraph } from "./graph-DuOeLGvh.mjs";
|
|
|
3
3
|
//#region src/protocol.d.ts
|
|
4
4
|
/** Query parameter carrying the unguessable inspection room capability. */
|
|
5
5
|
declare const INSPECTION_ROOM_QUERY_PARAM = "r";
|
|
6
|
+
/**
|
|
7
|
+
* Create the room-global identity for one producer-local actor session.
|
|
8
|
+
* XState session ids are process-local; the producer id supplies the missing
|
|
9
|
+
* cross-process namespace.
|
|
10
|
+
*/
|
|
11
|
+
declare function createInspectionActorId(producerId: string, sessionId: string): string;
|
|
6
12
|
interface InspectionRoomUrls {
|
|
7
13
|
roomId: string;
|
|
8
14
|
relayUrl: string;
|
|
@@ -334,11 +340,11 @@ interface InspectSnapshotMessage {
|
|
|
334
340
|
type: '@statelyai.inspectSnapshot';
|
|
335
341
|
snapshot: unknown;
|
|
336
342
|
event: unknown | null;
|
|
337
|
-
/**
|
|
343
|
+
/** Producer-local actor session id, when this snapshot belongs to an actor. */
|
|
338
344
|
sessionId?: string;
|
|
339
345
|
}
|
|
340
346
|
interface ActorSystemEntry {
|
|
341
|
-
/**
|
|
347
|
+
/** XState process-local `actor.sessionId`; pair with relay `producerId`. */
|
|
342
348
|
sessionId: string;
|
|
343
349
|
/** System-local xstate `actor.id`. */
|
|
344
350
|
actorId: string;
|
|
@@ -549,4 +555,4 @@ declare const PREFIX = "@statelyai.";
|
|
|
549
555
|
/** Current WebSocket inspection protocol version. */
|
|
550
556
|
declare const INSPECTION_PROTOCOL_VERSION = 2;
|
|
551
557
|
//#endregion
|
|
552
|
-
export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, 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, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorEventMessage, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, SystemSelectActorMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VizMessage, createInspectionRoomUrls, getInspectionRoomId };
|
|
558
|
+
export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ErrorMessage, ExportCallOptions, ExportFormat, ExportFormatMap, 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, SessionMessage, SetApiKeyMessage, SetModeMessage, SetSettingsMessage, SetThemeMessage, SourceLocation, SourceRange, StateSourceLocation, SystemActorEventMessage, SystemActorRegisteredMessage, SystemActorSnapshotMessage, SystemActorStoppedMessage, SystemInitMessage, SystemSelectActorMessage, ToastMessage, UpdateMessage, UploadCapabilitiesMessage, UploadFileInfo, UploadRequestMessage, UploadResponseMessage, UploadResult, ValidationIssue, VizMessage, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId };
|
package/dist/protocol.mjs
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
//#region src/protocol.ts
|
|
2
2
|
/** Query parameter carrying the unguessable inspection room capability. */
|
|
3
3
|
const INSPECTION_ROOM_QUERY_PARAM = "r";
|
|
4
|
+
/**
|
|
5
|
+
* Create the room-global identity for one producer-local actor session.
|
|
6
|
+
* XState session ids are process-local; the producer id supplies the missing
|
|
7
|
+
* cross-process namespace.
|
|
8
|
+
*/
|
|
9
|
+
function createInspectionActorId(producerId, sessionId) {
|
|
10
|
+
return `${encodeURIComponent(producerId)}:${encodeURIComponent(sessionId)}`;
|
|
11
|
+
}
|
|
4
12
|
/** Resolve the transport and browser URLs required by the inspection protocol. */
|
|
5
13
|
function createInspectionRoomUrls(options) {
|
|
6
14
|
const relayUrl = new URL(options.url);
|
|
@@ -35,4 +43,4 @@ const PREFIX = "@statelyai.";
|
|
|
35
43
|
const INSPECTION_PROTOCOL_VERSION = 2;
|
|
36
44
|
|
|
37
45
|
//#endregion
|
|
38
|
-
export { INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, PREFIX, createInspectionRoomUrls, getInspectionRoomId };
|
|
46
|
+
export { INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, PREFIX, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { a as array, c as literal, d as record, f as string, i as _enum, l as number, m as unknown, o as boolean, p as union, s as discriminatedUnion, u as object } from "./studio-txdyJHD7.mjs";
|
|
2
2
|
import ts from "typescript";
|
|
3
|
-
import "xstate";
|
|
4
3
|
import "xstate/graph";
|
|
5
4
|
|
|
6
5
|
//#region ../../node_modules/.pnpm/js-yaml@4.2.0/node_modules/js-yaml/dist/js-yaml.mjs
|
package/dist/sync.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as createStatelyClient } from "./studio-txdyJHD7.mjs";
|
|
2
|
-
import { i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as xstateSourceToConfig, n as getStatelyPragma, p as serializeJS, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-
|
|
2
|
+
import { i as INLINE_EXPRESSION_DIRECTIVE_FIELDS, m as xstateSourceToConfig, n as getStatelyPragma, p as serializeJS, r as upsertStatelyPragma, s as detectXStateSourceProfile, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-Th0gdXfx.mjs";
|
|
3
3
|
import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
|
|
4
4
|
import * as ts$1 from "typescript";
|
|
5
5
|
import ts from "typescript";
|