@statelyai/sdk 0.16.2 → 0.18.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 +18 -1
- package/dist/embed.d.mts +2 -2
- package/dist/embed.mjs +3 -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-llcqYpZ1.mjs} +13 -7
- package/dist/inspect.d.mts +1 -1
- package/dist/inspect.mjs +2 -1
- package/dist/protocol.d.mts +31 -3
- package/dist/protocol.mjs +23 -1
- package/dist/{transport-B_ig9Znn.mjs → transport-CyCrdKyz.mjs} +25 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,6 +37,10 @@ embed.init({
|
|
|
37
37
|
format: 'xstate',
|
|
38
38
|
mode: 'editing',
|
|
39
39
|
theme: 'dark',
|
|
40
|
+
documents: [
|
|
41
|
+
{ path: 'README.md', content: '# How this workflow works' },
|
|
42
|
+
{ path: 'src/machine.ts', content: machineSource },
|
|
43
|
+
],
|
|
40
44
|
});
|
|
41
45
|
```
|
|
42
46
|
|
|
@@ -76,6 +80,7 @@ Key capabilities:
|
|
|
76
80
|
- **Two-way sync** - push machine configs in, get changes and saves back via event callbacks
|
|
77
81
|
- **Export** to multiple formats: XState v5, XState JSON, Mermaid, Redux, Zustand, ASL, SCXML, and more
|
|
78
82
|
- **Access policies** for read-only, no-export, no-AI, shallow-viewer embeds
|
|
83
|
+
- **Reference documents** supplied as ordered, read-only Markdown, code, or text
|
|
79
84
|
- **Comments** via Liveblocks integration (optional)
|
|
80
85
|
- **Asset uploads** with built-in S3 and Supabase adapters, or bring your own upload handler
|
|
81
86
|
- **Runtime settings** - toggle color mode, grid, snap lines, autolayout, and view mode on the fly
|
|
@@ -170,12 +175,24 @@ actor.start();
|
|
|
170
175
|
If you already have the actor reference, `inspector.attach(actor)` subscribes to
|
|
171
176
|
its system and backfills actors that are already running.
|
|
172
177
|
|
|
178
|
+
When authored source is available, return it from `extractMachine` so the
|
|
179
|
+
visualizer preserves executable guards, inputs, and outputs instead of only a
|
|
180
|
+
JSON-safe machine structure:
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
const inspector = createInspector({
|
|
184
|
+
extractMachine: (actor) =>
|
|
185
|
+
actor.logic === machine ? machineSource : actor.logic?.config,
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
173
189
|
Stopped actors remain in `inspector.actors` and in reconnect checkpoints, so
|
|
174
190
|
completed request-scoped runs stay available for inspection.
|
|
175
191
|
|
|
176
192
|
XState v5 and v6 inspection events normalize to independent actor, event,
|
|
177
193
|
snapshot, and stop observations before crossing the WebSocket protocol.
|
|
178
|
-
`actorId` is system-local
|
|
194
|
+
`actorId` is system-local and `sessionId` is process-local. A room uses
|
|
195
|
+
`producerId + sessionId` as the global actor identity.
|
|
179
196
|
Observations captured before the first transport registration replay in order
|
|
180
197
|
after the initial actor-tree baseline. Reconnects use the latest checkpoint.
|
|
181
198
|
In Node, the inspector opens in the default browser automatically. The SDK
|
package/dist/embed.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as StatelyGraph } from "./graph-DuOeLGvh.mjs";
|
|
2
|
-
import { CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, MachineInitOptions, MachineSourceLocations, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
|
|
2
|
+
import { CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, MachineInitOptions, MachineSourceLocations, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
|
|
3
3
|
import { AssetUploadAdapter } from "./assetStorage.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/embed.d.ts
|
|
@@ -91,4 +91,4 @@ interface StatelyEmbed {
|
|
|
91
91
|
}
|
|
92
92
|
declare function createStatelyEmbed(options: StatelyEmbedOptions): StatelyEmbed;
|
|
93
93
|
//#endregion
|
|
94
|
-
export { AssetConfig, type CapabilityDeniedEvent, type CommentsConfig, type EditorCapabilities, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type MachineInitOptions, type MachineSourceLocations, type ProjectEmbedMachine, StatelyEmbed, StatelyEmbedOptions, type UploadResult, createStatelyEmbed };
|
|
94
|
+
export { AssetConfig, type CapabilityDeniedEvent, type CommentsConfig, type EditorCapabilities, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type MachineInitOptions, type MachineSourceLocations, type ProjectEmbedMachine, StatelyEmbed, StatelyEmbedOptions, type UploadResult, createStatelyEmbed };
|
package/dist/embed.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as toInitMessage, i as createPendingExportManager, r as createEventRegistry, t as createPostMessageTransport } from "./transport-
|
|
1
|
+
import { a as toInitMessage, i as createPendingExportManager, r as createEventRegistry, t as createPostMessageTransport } from "./transport-CyCrdKyz.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/embed.ts
|
|
4
4
|
function buildEmbedUrl(options) {
|
|
@@ -10,6 +10,7 @@ function buildEmbedUrl(options) {
|
|
|
10
10
|
function extractInitOptions(options) {
|
|
11
11
|
if (options.machines) return {
|
|
12
12
|
machines: options.machines,
|
|
13
|
+
documents: options.documents,
|
|
13
14
|
currentMachineId: options.currentMachineId,
|
|
14
15
|
mode: options.mode,
|
|
15
16
|
theme: options.theme,
|
|
@@ -22,6 +23,7 @@ function extractInitOptions(options) {
|
|
|
22
23
|
};
|
|
23
24
|
if (options.machine !== void 0) return {
|
|
24
25
|
machine: options.machine,
|
|
26
|
+
documents: options.documents,
|
|
25
27
|
format: options.format,
|
|
26
28
|
mode: options.mode,
|
|
27
29
|
theme: options.theme,
|
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, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, ProjectEmbedMachine, UploadResult, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
5
5
|
import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
|
|
6
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, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedMode, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorEvents, type InspectorInspectionEvent, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineConfigOptions, type MachineVersion, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RepoType, type ResolvedSyncInput, type ResourceErrorCode, type S3UploadTarget, type StateNodeJSONData, type StatelyAction, type StatelyApiClientOptions, StatelyApiError, type StatelyApiUrlOptions, type StatelyAuthMode, type StatelyCredential, type StatelyEdgeData, type StatelyEmbed, type StatelyEmbedOptions, type StatelyGraph, type StatelyGraphData, type StatelyGuard, type StatelyInvoke, type StatelyNodeData, type StatelyPragma, type StatelyPragmaAttachment, type StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type VerifyResult, type XStateTSOptions, type XStateVersion, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
2
|
+
import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-CyCrdKyz.mjs";
|
|
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-llcqYpZ1.mjs";
|
|
6
6
|
import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-txdyJHD7.mjs";
|
|
7
7
|
import { a as RawCode, c as eventsSchemaToTSType, d as jsonSchemaToTSType, f as raw, l as graphToMachineConfig, n as getStatelyPragma, o as contextSchemaToTSType, p as serializeJS, r as upsertStatelyPragma, t as findStatelyPragmaAttachments, u as graphToXStateTS } from "./statelyPragma-Bm9O4XV6.mjs";
|
|
8
8
|
import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
|
|
@@ -11,4 +11,4 @@ import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./
|
|
|
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, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getInspectionRoomId, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
|
|
@@ -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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as createPendingExportManager, n as createWebSocketTransport, r as createEventRegistry } from "./transport-B_ig9Znn.mjs";
|
|
2
1
|
import { INSPECTION_PROTOCOL_VERSION, createInspectionRoomUrls, getInspectionRoomId } from "./protocol.mjs";
|
|
2
|
+
import { i as createPendingExportManager, n as createWebSocketTransport, r as createEventRegistry } from "./transport-CyCrdKyz.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/openBrowser.ts
|
|
5
5
|
async function openBrowser(url) {
|
|
@@ -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.18.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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./transport-CyCrdKyz.mjs";
|
|
2
|
+
import { n as createStatelyInspector, t as createInspector } from "./inspect-llcqYpZ1.mjs";
|
|
2
3
|
|
|
3
4
|
export { createInspector, createStatelyInspector };
|
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;
|
|
@@ -29,6 +35,21 @@ interface ProjectEmbedMachine {
|
|
|
29
35
|
name?: string;
|
|
30
36
|
machine: unknown;
|
|
31
37
|
}
|
|
38
|
+
declare const EMBED_DOCUMENT_LANGUAGES: readonly ["markdown", "typescript", "javascript", "json", "xml", "mermaid", "text"];
|
|
39
|
+
type EmbedDocumentLanguage = (typeof EMBED_DOCUMENT_LANGUAGES)[number];
|
|
40
|
+
declare const EMBED_DOCUMENT_LIMITS: {
|
|
41
|
+
readonly maxDocuments: 100;
|
|
42
|
+
readonly maxDocumentLength: number;
|
|
43
|
+
readonly maxTotalLength: number;
|
|
44
|
+
};
|
|
45
|
+
/** Read-only text supplied by an embed host for display beside a machine. */
|
|
46
|
+
interface EmbedDocument {
|
|
47
|
+
/** Relative POSIX path used as the document's stable identity. */
|
|
48
|
+
path: string;
|
|
49
|
+
content: string;
|
|
50
|
+
/** Overrides renderer detection from the path's file extension. */
|
|
51
|
+
language?: EmbedDocumentLanguage;
|
|
52
|
+
}
|
|
32
53
|
interface ValidationIssue {
|
|
33
54
|
nodeIds: string[];
|
|
34
55
|
edgeIds: string[];
|
|
@@ -192,6 +213,8 @@ type EmbedEventName = keyof EmbedEventMap;
|
|
|
192
213
|
type EmbedEventHandler<K extends EmbedEventName> = (data: EmbedEventMap[K]) => void;
|
|
193
214
|
interface MachineInitOptions {
|
|
194
215
|
machine: unknown;
|
|
216
|
+
/** Ephemeral, read-only reference documents owned by the embed host. */
|
|
217
|
+
documents?: EmbedDocument[];
|
|
195
218
|
format?: string;
|
|
196
219
|
mode?: EmbedMode;
|
|
197
220
|
theme?: 'light' | 'dark';
|
|
@@ -226,6 +249,8 @@ interface MachineInitOptions {
|
|
|
226
249
|
}
|
|
227
250
|
interface ProjectInitOptions {
|
|
228
251
|
machines: ProjectEmbedMachine[];
|
|
252
|
+
/** Ephemeral, read-only reference documents shared across the project. */
|
|
253
|
+
documents?: EmbedDocument[];
|
|
229
254
|
currentMachineId?: string;
|
|
230
255
|
mode?: EmbedMode;
|
|
231
256
|
theme?: 'light' | 'dark';
|
|
@@ -248,6 +273,7 @@ type InitOptions = MachineInitOptions | ProjectInitOptions;
|
|
|
248
273
|
interface InitMessage {
|
|
249
274
|
type: '@statelyai.init';
|
|
250
275
|
machine: unknown;
|
|
276
|
+
documents?: EmbedDocument[];
|
|
251
277
|
format?: string;
|
|
252
278
|
mode?: EmbedMode;
|
|
253
279
|
theme?: 'light' | 'dark';
|
|
@@ -274,6 +300,7 @@ interface SetApiKeyMessage {
|
|
|
274
300
|
interface ProjectInitMessage {
|
|
275
301
|
type: '@statelyai.project.init';
|
|
276
302
|
machines: ProjectEmbedMachine[];
|
|
303
|
+
documents?: EmbedDocument[];
|
|
277
304
|
currentMachineId?: string;
|
|
278
305
|
mode?: EmbedMode;
|
|
279
306
|
theme?: 'light' | 'dark';
|
|
@@ -334,11 +361,11 @@ interface InspectSnapshotMessage {
|
|
|
334
361
|
type: '@statelyai.inspectSnapshot';
|
|
335
362
|
snapshot: unknown;
|
|
336
363
|
event: unknown | null;
|
|
337
|
-
/**
|
|
364
|
+
/** Producer-local actor session id, when this snapshot belongs to an actor. */
|
|
338
365
|
sessionId?: string;
|
|
339
366
|
}
|
|
340
367
|
interface ActorSystemEntry {
|
|
341
|
-
/**
|
|
368
|
+
/** XState process-local `actor.sessionId`; pair with relay `producerId`. */
|
|
342
369
|
sessionId: string;
|
|
343
370
|
/** System-local xstate `actor.id`. */
|
|
344
371
|
actorId: string;
|
|
@@ -378,6 +405,7 @@ interface SystemInitMessage {
|
|
|
378
405
|
actors: ActorSystemEntry[];
|
|
379
406
|
/** Actor session id the viz should focus first. Defaults to the root. */
|
|
380
407
|
selectedSessionId?: string;
|
|
408
|
+
documents?: EmbedDocument[];
|
|
381
409
|
mode?: EmbedMode;
|
|
382
410
|
theme?: 'light' | 'dark';
|
|
383
411
|
readOnly?: boolean;
|
|
@@ -549,4 +577,4 @@ declare const PREFIX = "@statelyai.";
|
|
|
549
577
|
/** Current WebSocket inspection protocol version. */
|
|
550
578
|
declare const INSPECTION_PROTOCOL_VERSION = 2;
|
|
551
579
|
//#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 };
|
|
580
|
+
export { ActorSystemEntry, CapabilityDeniedCapability, CapabilityDeniedEvent, CapabilityDeniedMessage, ChangeMessage, ClientMessage, CommentsConfig, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, EditorCapabilities, EmbedDocument, EmbedDocumentLanguage, 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);
|
|
@@ -30,9 +38,23 @@ function createInspectionRoomUrls(options) {
|
|
|
30
38
|
function getInspectionRoomId(value) {
|
|
31
39
|
return new URL(value).searchParams.get(INSPECTION_ROOM_QUERY_PARAM)?.trim() || null;
|
|
32
40
|
}
|
|
41
|
+
const EMBED_DOCUMENT_LANGUAGES = [
|
|
42
|
+
"markdown",
|
|
43
|
+
"typescript",
|
|
44
|
+
"javascript",
|
|
45
|
+
"json",
|
|
46
|
+
"xml",
|
|
47
|
+
"mermaid",
|
|
48
|
+
"text"
|
|
49
|
+
];
|
|
50
|
+
const EMBED_DOCUMENT_LIMITS = {
|
|
51
|
+
maxDocuments: 100,
|
|
52
|
+
maxDocumentLength: 512 * 1024,
|
|
53
|
+
maxTotalLength: 2 * 1024 * 1024
|
|
54
|
+
};
|
|
33
55
|
const PREFIX = "@statelyai.";
|
|
34
56
|
/** Current WebSocket inspection protocol version. */
|
|
35
57
|
const INSPECTION_PROTOCOL_VERSION = 2;
|
|
36
58
|
|
|
37
59
|
//#endregion
|
|
38
|
-
export { INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, PREFIX, createInspectionRoomUrls, getInspectionRoomId };
|
|
60
|
+
export { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, PREFIX, createInspectionActorId, createInspectionRoomUrls, getInspectionRoomId };
|
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
import { INSPECTION_PROTOCOL_VERSION, PREFIX } from "./protocol.mjs";
|
|
1
|
+
import { EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, INSPECTION_PROTOCOL_VERSION, PREFIX } from "./protocol.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/clientUtils.ts
|
|
4
|
+
const embedDocumentLanguages = new Set(EMBED_DOCUMENT_LANGUAGES);
|
|
5
|
+
function assertEmbedDocuments(documents) {
|
|
6
|
+
if (!documents) return;
|
|
7
|
+
if (documents.length > EMBED_DOCUMENT_LIMITS.maxDocuments) throw new TypeError(`Embed documents are limited to ${EMBED_DOCUMENT_LIMITS.maxDocuments}.`);
|
|
8
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9
|
+
let totalLength = 0;
|
|
10
|
+
for (const document of documents) {
|
|
11
|
+
const path = document?.path;
|
|
12
|
+
const content = document?.content;
|
|
13
|
+
const language = document?.language;
|
|
14
|
+
const segments = typeof path === "string" ? path.split("/") : [];
|
|
15
|
+
if (typeof path !== "string" || path.length === 0 || path.startsWith("/") || path.includes("\\") || segments.some((segment) => segment.length === 0 || segment === "." || segment === "..")) throw new TypeError("Embed document paths must be non-empty relative POSIX paths.");
|
|
16
|
+
if (seen.has(path)) throw new TypeError(`Duplicate embed document path: ${path}`);
|
|
17
|
+
if (typeof content !== "string") throw new TypeError(`Embed document content must be text: ${path}`);
|
|
18
|
+
if (language !== void 0 && (typeof language !== "string" || !embedDocumentLanguages.has(language))) throw new TypeError(`Unsupported embed document language: ${language}`);
|
|
19
|
+
if (content.length > EMBED_DOCUMENT_LIMITS.maxDocumentLength) throw new TypeError(`Embed document exceeds the 512 KiB character limit: ${path}`);
|
|
20
|
+
seen.add(path);
|
|
21
|
+
totalLength += content.length;
|
|
22
|
+
}
|
|
23
|
+
if (totalLength > EMBED_DOCUMENT_LIMITS.maxTotalLength) throw new TypeError("Embed documents exceed the 2 MiB character limit.");
|
|
24
|
+
}
|
|
4
25
|
const jsonResultFormats = new Set([
|
|
5
26
|
"digraph",
|
|
6
27
|
"xstate-json",
|
|
@@ -91,9 +112,11 @@ function createPendingExportManager(sendRetrieve) {
|
|
|
91
112
|
};
|
|
92
113
|
}
|
|
93
114
|
function toInitMessage(options) {
|
|
115
|
+
assertEmbedDocuments(options.documents);
|
|
94
116
|
if ("machines" in options) return {
|
|
95
117
|
type: "@statelyai.project.init",
|
|
96
118
|
machines: options.machines,
|
|
119
|
+
documents: options.documents,
|
|
97
120
|
currentMachineId: options.currentMachineId,
|
|
98
121
|
mode: options.mode,
|
|
99
122
|
theme: options.theme,
|
|
@@ -109,6 +132,7 @@ function toInitMessage(options) {
|
|
|
109
132
|
return {
|
|
110
133
|
type: "@statelyai.init",
|
|
111
134
|
machine: options.machine,
|
|
135
|
+
documents: options.documents,
|
|
112
136
|
format: options.format,
|
|
113
137
|
mode: options.mode,
|
|
114
138
|
theme: options.theme,
|