@statelyai/sdk 0.12.2 → 0.13.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 CHANGED
@@ -30,11 +30,14 @@ embed.init({
30
30
 
31
31
  Restrict an embed by passing a resolved access policy:
32
32
 
33
+ <!-- restricted MachineInitOptions from src/protocol.ts -->
34
+
33
35
  ```ts
34
36
  embed.init({
35
37
  machine: myMachineConfig,
36
38
  mode: 'viewing',
37
39
  readOnly: true,
40
+ readOnlyReason: 'free-plan',
38
41
  capabilities: {
39
42
  edit: false,
40
43
  export: false,
@@ -51,6 +54,10 @@ embed.on('capabilityDenied', (event) => {
51
54
  });
52
55
  ```
53
56
 
57
+ `readOnlyReason: 'free-plan'` shows a persistent **Upgrade to edit** action.
58
+ Use `access-unverified` when reopening or signing in, rather than upgrading, is
59
+ the appropriate recovery action.
60
+
54
61
  Key capabilities:
55
62
 
56
63
  - **Mount or attach** to any container element or existing iframe
@@ -110,19 +117,27 @@ self-hosted deployments that intentionally accept unauthenticated calls.
110
117
 
111
118
  ### Inspector
112
119
 
120
+ <!-- createInspector API from src/inspect.ts -->
121
+
113
122
  Stream live actor-system state to the Stately inspector over WebSockets, with support for automatic XState actor adoption and manual actor registration.
114
123
 
115
124
  ```ts
116
125
  import { createActor } from 'xstate';
117
- import { createStatelyInspector } from '@statelyai/sdk';
126
+ import { createInspector } from '@statelyai/sdk';
118
127
 
119
128
  const actor = createActor(machine);
120
- const inspector = createStatelyInspector({ autoOpen: true });
129
+ const inspector = createInspector({
130
+ url: 'ws://localhost:1999/inspect/local',
131
+ });
121
132
 
122
133
  inspector.inspect(actor);
123
134
  actor.start();
124
135
  ```
125
136
 
137
+ XState v5 and v6 inspection events normalize to actor, transition, and stop
138
+ events before crossing the WebSocket protocol.
139
+ In Node, the inspector opens in the default browser automatically.
140
+
126
141
  ### CLI and sync
127
142
 
128
143
  A `statelyai` CLI for syncing local XState source files with Stately Studio projects: push local machines to the cloud, pull remote changes back into source, and open a local file in a browser-backed visual editor session.
package/dist/auth.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-DO1-eQcU.mjs";
1
+ import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-DmPZiERd.mjs";
2
2
  export { StatelyAuthMode, StatelyCredential, createAuthorizationHeader, getCredentialToken };
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-D0nlFaLn.mjs";
1
+ import { a as createPendingExportManager, i as createEventRegistry, n as createPostMessageTransport, o as toInitMessage } from "./transport-D2Ud05yg.mjs";
2
2
 
3
3
  //#region src/embed.ts
4
4
  function buildEmbedUrl(options) {
@@ -26,6 +26,7 @@ function extractInitOptions(options) {
26
26
  mode: options.mode,
27
27
  theme: options.theme,
28
28
  readOnly: options.readOnly,
29
+ readOnlyReason: options.readOnlyReason,
29
30
  depth: options.depth,
30
31
  capabilities: options.capabilities,
31
32
  panels: options.panels,
@@ -1,4 +1,4 @@
1
- import { r as CodeExpression } from "./index-BRW2DecD.mjs";
1
+ import { r as CodeExpression } from "./index-DVjNSTuQ.mjs";
2
2
  import * as _statelyai_graph0 from "@statelyai/graph";
3
3
  import { Graph } from "@statelyai/graph";
4
4
 
package/dist/graph.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as studioMachineConverter, a as StatelyGraphData, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, n as StatelyActorImplementation, o as StatelyGuard, p as StudioEventTypeData, r as StatelyEdgeData, s as StatelyImplementation, t as StatelyAction, u as StatelyTagImplementation, v as toStudioMachine } from "./graph-Dq5ycdSq.mjs";
1
+ import { _ as studioMachineConverter, a as StatelyGraphData, c as StatelyInvoke, d as StudioAction, f as StudioEdge, g as fromStudioMachine, h as StudioNode, i as StatelyGraph, l as StatelyNodeData, m as StudioMachine, n as StatelyActorImplementation, o as StatelyGuard, p as StudioEventTypeData, r as StatelyEdgeData, s as StatelyImplementation, t as StatelyAction, u as StatelyTagImplementation, v as toStudioMachine } from "./graph-R0sbxnZ7.mjs";
2
2
  export { StatelyAction, StatelyActorImplementation, StatelyEdgeData, StatelyGraph, StatelyGraphData, StatelyGuard, StatelyImplementation, StatelyInvoke, StatelyNodeData, StatelyTagImplementation, StudioAction, StudioEdge, StudioEventTypeData, StudioMachine, StudioNode, fromStudioMachine, studioMachineConverter, toStudioMachine };
package/dist/index.d.mts CHANGED
@@ -1,14 +1,15 @@
1
1
  import { StatelyApiClientOptions, StatelyApiError, StatelyApiUrlOptions, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
2
- import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, InitOptions, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
2
+ import { CapabilityDeniedCapability, CapabilityDeniedEvent, CommentsConfig, EditorCapabilities, EmbedEventHandler, EmbedEventMap, EmbedEventName, EmbedMode, ExportCallOptions, ExportFormat, ExportFormatMap, INSPECTION_PROTOCOL_VERSION, InitOptions, InspectionAction, InspectionSentEvent, InspectionTakenTransition, ProjectEmbedMachine, UploadResult } from "./protocol.mjs";
3
3
  import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
4
- import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-DO1-eQcU.mjs";
4
+ import { i as getCredentialToken, n as StatelyCredential, r as createAuthorizationHeader, t as StatelyAuthMode } from "./auth-DmPZiERd.mjs";
5
5
  import { AssetConfig, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
6
- 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-BRW2DecD.mjs";
7
- 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-Dq5ycdSq.mjs";
8
- import { a as ManualActorOptions, c as createPostMessageTransport, i as InspectorEvents, l as createWebSocketTransport, n as CreateInspectorOptions, o as createStatelyInspector, r as Inspector, s as Transport, t as AdoptedActor } from "./inspect-BmZUcnZB.mjs";
6
+ 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-DVjNSTuQ.mjs";
7
+ 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-R0sbxnZ7.mjs";
8
+ import { a as InspectorEvents, c as createStatelyInspector, d as MultiplexedWebSocketConnectionOptions, f as Transport, h as createWebSocketTransport, i as Inspector, l as MultiplexedChannelOptions, m as createPostMessageTransport, n as CreateInspectorOptions, o as ManualActorOptions, p as createMultiplexedWebSocketConnection, r as InspectedTransition, s as createInspector, t as AdoptedActor, u as MultiplexedWebSocketConnection } from "./inspect-BMHheAvx.mjs";
9
9
  import { ConnectedRepo, CreateMachineFromDefinitionInput, CreateMachineFromTemplateInput, CreateMachineInput, CreateMachineTemplate, CreateProjectInput, EnsureProjectInput, ExtractMachinesResponse, ExtractedMachine, GetMachineOptions, ProjectData, ProjectMachine, ProjectVisibility, RepoType, StudioApiError, StudioClient, StudioClientOptions, StudioMachineRecord, UpdateMachineInput, VerifyApiKeyResponse, XStateVersion, createStatelyClient } from "./studio.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";
12
+ import { CreateInspectionRelayOptions, InspectionRelay, InspectionRelayEffect, InspectionRelayPeer, InspectionRelayRole, InspectionRelaySnapshot, createInspectionRelay } from "./relay.mjs";
12
13
  //#region src/statelyPragma.d.ts
13
14
  interface StatelyPragma {
14
15
  tag: '@statelyai';
@@ -31,4 +32,4 @@ declare function findStatelyPragmaAttachments(sourceText: string, fileName?: str
31
32
  declare function getStatelyPragma(sourceText: string, fileName?: string, machineIndex?: number): StatelyPragma | undefined;
32
33
  declare function upsertStatelyPragma(sourceText: string, id: string, options?: UpsertStatelyPragmaOptions): string;
33
34
  //#endregion
34
- export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CodeGenGraph, type CommentsConfig, type ConnectedRepo, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, 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 ExtractMachinesResponse, type ExtractedMachine, type GetMachineOptions, type GraphPatch, type InitOptions, type Inspector, type InspectorEvents, type MachineConfigOptions, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectVisibility, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RepoType, type ResolvedSyncInput, 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 StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type UpdateMachineInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type XStateTSOptions, type XStateVersion, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, 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, 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 ExtractMachinesResponse, type ExtractedMachine, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, type InitOptions, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorEvents, type MachineConfigOptions, type ManualActorOptions, type MultiplexedChannelOptions, type MultiplexedWebSocketConnection, type MultiplexedWebSocketConnectionOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSyncOptions, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectVisibility, type PullSyncResult, type PushLocalMachineLinksResult, type PushSyncOptions, type PushSyncProjectOptions, type PushSyncResult, RawCode, type RepoType, type ResolvedSyncInput, 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 StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type SupabaseStorageClient, type SyncInputFormat, type SyncPlan, type SyncPlanSummary, type Transport, type UpdateMachineInput, type UploadResult, type UpsertStatelyPragmaOptions, type VerifyApiKeyResponse, type XStateTSOptions, type XStateVersion, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionRelay, createInspector, createMultiplexedWebSocketConnection, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
package/dist/index.mjs CHANGED
@@ -1,12 +1,14 @@
1
- import { n as createWebSocketTransport, t as createPostMessageTransport } from "./transport-D0nlFaLn.mjs";
1
+ import { n as createPostMessageTransport, r as createWebSocketTransport, t as createMultiplexedWebSocketConnection } from "./transport-D2Ud05yg.mjs";
2
+ import { INSPECTION_PROTOCOL_VERSION } from "./protocol.mjs";
2
3
  import { createStatelyEmbed } from "./embed.mjs";
3
4
  import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
4
- import { createStatelyInspector } from "./inspect.mjs";
5
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-D9GyHTTW.mjs";
5
6
  import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
6
7
  import { StudioApiError, createStatelyClient } from "./studio.mjs";
7
8
  import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
8
9
  import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
9
- import { a as eventsSchemaToTSType, c as jsonSchemaToTSType, f as findStatelyPragmaAttachments, l as raw, m as upsertStatelyPragma, n as RawCode, o as graphToMachineConfig, p as getStatelyPragma, r as contextSchemaToTSType, s as graphToXStateTS, u as serializeJS } from "./dist-C-AdA8Iw.mjs";
10
+ import { a as eventsSchemaToTSType, c as jsonSchemaToTSType, f as findStatelyPragmaAttachments, l as raw, m as upsertStatelyPragma, n as RawCode, o as graphToMachineConfig, p as getStatelyPragma, r as contextSchemaToTSType, s as graphToXStateTS, u as serializeJS } from "./dist-CHGcvOdQ.mjs";
10
11
  import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
12
+ import { createInspectionRelay } from "./relay.mjs";
11
13
 
12
- export { RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
14
+ export { INSPECTION_PROTOCOL_VERSION, RawCode, StatelyApiError, StudioApiError, buildAuthorizeUrl, contextSchemaToTSType, createAuthorizationHeader, createInspectionRelay, createInspector, createMultiplexedWebSocketConnection, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, eventsSchemaToTSType, exchangeCodeForToken, findStatelyPragmaAttachments, fromStudioMachine, getCredentialToken, getStatelyPragma, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, refreshToken, registerOAuthClient, serializeJS, studioMachineConverter, toStudioMachine, upsertStatelyPragma };
@@ -1,4 +1,4 @@
1
- import { EditorCapabilities, EmbedEventMap, ExportCallOptions, ExportFormat, ExportFormatMap, ProtocolMessage } from "./protocol.mjs";
1
+ import { EditorCapabilities, EmbedEventMap, ExportCallOptions, ExportFormat, ExportFormatMap, InspectionAction, InspectionSentEvent, InspectionTakenTransition, ProtocolMessage } from "./protocol.mjs";
2
2
 
3
3
  //#region src/transport.d.ts
4
4
  interface Transport {
@@ -29,6 +29,39 @@ interface WebSocketTransportOptions {
29
29
  maxReconnectAttempts?: number;
30
30
  }
31
31
  declare function createWebSocketTransport(options: WebSocketTransportOptions): Transport;
32
+ interface MultiplexedWebSocketConnectionOptions {
33
+ url: string;
34
+ role: 'client' | 'viz';
35
+ /** First (primary) session to register on connect. */
36
+ sessionId: string;
37
+ /** Metadata for the primary session. */
38
+ metadata?: {
39
+ name?: string;
40
+ machineId?: string;
41
+ };
42
+ reconnect?: boolean;
43
+ maxReconnectAttempts?: number;
44
+ }
45
+ interface MultiplexedChannelOptions {
46
+ /** Session id this channel targets. */
47
+ sessionId: string;
48
+ /** Optional metadata for this session. */
49
+ metadata?: {
50
+ name?: string;
51
+ machineId?: string;
52
+ };
53
+ }
54
+ interface MultiplexedWebSocketConnection {
55
+ /** Open a channel for a sessionId. Re-opening an existing session returns the same channel. */
56
+ openChannel(options: MultiplexedChannelOptions): Transport;
57
+ /** Close the connection and all its channels. */
58
+ destroy(): void;
59
+ /** Whether the underlying WebSocket is connected + the primary session is registered. */
60
+ readonly ready: boolean;
61
+ /** Primary session id (first registered). */
62
+ readonly primarySessionId: string;
63
+ }
64
+ declare function createMultiplexedWebSocketConnection(options: MultiplexedWebSocketConnectionOptions): MultiplexedWebSocketConnection;
32
65
  //#endregion
33
66
  //#region src/inspect.d.ts
34
67
  interface MinimalActorRef {
@@ -39,6 +72,7 @@ interface MinimalActorRef {
39
72
  logic?: {
40
73
  config?: unknown;
41
74
  };
75
+ src?: unknown;
42
76
  getSnapshot(): MinimalSnapshot;
43
77
  system: {
44
78
  inspect: (observer: (event: InspectionEvent) => void) => {
@@ -56,6 +90,10 @@ type InspectionEvent = {
56
90
  type: '@xstate.actor';
57
91
  actorRef: MinimalActorRef;
58
92
  rootId: string;
93
+ parentRef?: MinimalActorRef;
94
+ id?: string;
95
+ src?: unknown;
96
+ snapshot?: MinimalSnapshot;
59
97
  } | {
60
98
  type: '@xstate.snapshot';
61
99
  actorRef: MinimalActorRef;
@@ -68,12 +106,34 @@ type InspectionEvent = {
68
106
  rootId: string;
69
107
  sourceRef?: MinimalActorRef;
70
108
  event: unknown;
109
+ } | {
110
+ type: '@xstate.transition';
111
+ actorRef: MinimalActorRef;
112
+ rootId: string;
113
+ snapshot: MinimalSnapshot;
114
+ event: unknown;
115
+ sourceRef?: MinimalActorRef;
116
+ targetRef?: MinimalActorRef;
117
+ eventType?: string;
118
+ microsteps?: unknown[];
119
+ actions?: Array<{
120
+ type: string;
121
+ params: unknown;
122
+ }>;
123
+ sent?: Array<{
124
+ targetRef?: MinimalActorRef;
125
+ targetId: string;
126
+ event: unknown;
127
+ delay?: number;
128
+ id?: string;
129
+ }>;
71
130
  } | {
72
131
  type: '@xstate.microstep';
73
132
  actorRef: MinimalActorRef;
74
133
  rootId: string;
75
134
  snapshot: MinimalSnapshot;
76
135
  event: unknown;
136
+ _transitions?: unknown[];
77
137
  } | {
78
138
  type: '@xstate.action';
79
139
  actorRef: MinimalActorRef;
@@ -99,9 +159,28 @@ interface AdoptedActor {
99
159
  /** Machine config sent to the visualizer, or `null` for non-machine actors. */
100
160
  machineConfig: unknown;
101
161
  }
162
+ /** One normalized transition, independent of the XState inspection version. */
163
+ interface InspectedTransition {
164
+ actorId: string;
165
+ sourceActorId: string | null;
166
+ previousSnapshot: unknown | null;
167
+ snapshot: unknown;
168
+ event: unknown | null;
169
+ actions: InspectionAction[];
170
+ transitions: InspectionTakenTransition[];
171
+ sent: InspectionSentEvent[];
172
+ }
102
173
  interface InspectorEvents {
174
+ actor: AdoptedActor;
175
+ transition: InspectedTransition;
176
+ stop: {
177
+ actorId: string;
178
+ };
179
+ /** @deprecated Use `actor`. */
103
180
  register: AdoptedActor;
181
+ /** @deprecated Use `transition`. */
104
182
  snapshot: AdoptedActor;
183
+ /** @deprecated Use `stop`. */
105
184
  stopped: {
106
185
  actorId: string;
107
186
  };
@@ -141,7 +220,7 @@ interface CreateInspectorOptions {
141
220
  * Extract the machine config for a given actor. Defaults to reading
142
221
  * `actor.logic.config`. Return `null` for non-machine actors.
143
222
  */
144
- extractMachineConfig?: (actor: any) => unknown;
223
+ extractMachineConfig?: (actor: any, source?: unknown) => unknown;
145
224
  /** Selected actor id to focus on first. Defaults to the first inspected root. */
146
225
  selectedActorId?: string;
147
226
  /** Panel layout forwarded into the system init message. */
@@ -200,6 +279,8 @@ interface Inspector {
200
279
  /** Tear down the WebSocket + xstate subscription. */
201
280
  destroy(): void;
202
281
  }
203
- declare function createStatelyInspector(options?: CreateInspectorOptions): Inspector;
282
+ declare function createInspector(options?: CreateInspectorOptions): Inspector;
283
+ /** @deprecated Use {@link createInspector}. */
284
+ declare const createStatelyInspector: typeof createInspector;
204
285
  //#endregion
205
- export { ManualActorOptions as a, createPostMessageTransport as c, InspectorEvents as i, createWebSocketTransport as l, CreateInspectorOptions as n, createStatelyInspector as o, Inspector as r, Transport as s, AdoptedActor as t };
286
+ export { InspectorEvents as a, createStatelyInspector as c, MultiplexedWebSocketConnectionOptions as d, Transport as f, createWebSocketTransport as h, Inspector as i, MultiplexedChannelOptions as l, createPostMessageTransport as m, CreateInspectorOptions as n, ManualActorOptions as o, createMultiplexedWebSocketConnection as p, InspectedTransition as r, createInspector as s, AdoptedActor as t, MultiplexedWebSocketConnection as u };