@statelyai/sdk 0.12.3 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -12
- package/dist/auth.d.mts +1 -1
- package/dist/embed.mjs +1 -1
- package/dist/{graph-Dq5ycdSq.d.mts → graph-R0sbxnZ7.d.mts} +1 -1
- package/dist/graph.d.mts +1 -1
- package/dist/index.d.mts +7 -6
- package/dist/index.mjs +6 -4
- package/dist/{inspect-BmZUcnZB.d.mts → inspect-COqtklcn.d.mts} +88 -6
- package/dist/inspect-pcNCbL7j.mjs +469 -0
- package/dist/inspect.d.mts +3 -3
- package/dist/inspect.mjs +2 -305
- package/dist/patchTypes.d.mts +1 -1
- package/dist/protocol.d.mts +35 -6
- package/dist/protocol.mjs +3 -1
- package/dist/relay.d.mts +43 -0
- package/dist/relay.mjs +153 -0
- package/dist/studio.d.mts +1 -1
- package/dist/sync.d.mts +1 -1
- package/dist/sync.mjs +1 -1
- package/dist/{transport-DysvAtl5.mjs → transport-D2Ud05yg.mjs} +178 -2
- package/package.json +6 -1
- /package/dist/{auth-DO1-eQcU.d.mts → auth-DmPZiERd.d.mts} +0 -0
- /package/dist/{dist-C-AdA8Iw.mjs → dist-CHGcvOdQ.mjs} +0 -0
- /package/dist/{index-BRW2DecD.d.mts → index-DVjNSTuQ.d.mts} +0 -0
package/README.md
CHANGED
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
# @statelyai/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The public alpha SDK for embedding the Stately visual editor, inspecting live
|
|
4
|
+
actor systems, and using the Stately Studio API.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
APIs may change between minor releases. Review generated source changes before
|
|
7
|
+
committing them.
|
|
6
8
|
|
|
7
|
-
##
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
<!-- install command derived from package.json#name -->
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @statelyai/sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Capabilities
|
|
8
18
|
|
|
9
19
|
### Embeddable editor
|
|
10
20
|
|
|
21
|
+
<!-- createStatelyEmbed usage from src/embed.ts and the hosted editor URL -->
|
|
22
|
+
|
|
11
23
|
Drop a fully interactive state machine editor into any web app. The embed communicates over `postMessage` and gives you full control over theme, layout, panels, read-only mode, and more.
|
|
12
24
|
|
|
13
25
|
```ts
|
|
14
26
|
import { createStatelyEmbed } from '@statelyai/sdk';
|
|
15
27
|
|
|
16
28
|
const embed = createStatelyEmbed({
|
|
17
|
-
baseUrl: 'https://stately.ai',
|
|
29
|
+
baseUrl: 'https://editor.stately.ai',
|
|
18
30
|
apiKey: 'your-api-key',
|
|
19
31
|
});
|
|
20
32
|
|
|
@@ -70,7 +82,10 @@ Key capabilities:
|
|
|
70
82
|
|
|
71
83
|
### Self-hosting
|
|
72
84
|
|
|
73
|
-
|
|
85
|
+
<!-- self-host configuration from the editor app auth and editor-sync routes -->
|
|
86
|
+
|
|
87
|
+
The SDK works with both the hosted Stately editor (`editor.stately.ai`) and
|
|
88
|
+
self-hosted deployments.
|
|
74
89
|
|
|
75
90
|
When self-hosting, authentication is handled by your editor server, not by this npm package. The editor host supports configurable auth strategies, and you can disable API-key checks for editor-sync endpoints when running behind your own auth layer.
|
|
76
91
|
|
|
@@ -88,8 +103,6 @@ Key environment variables for self-hosted deployments:
|
|
|
88
103
|
| --------------------------- | -------------------------------------------- |
|
|
89
104
|
| `AUTH_PROVIDER` | Auth strategy used by the editor host |
|
|
90
105
|
| `EDITOR_SYNC_AUTH_REQUIRED` | Set to `false` to skip editor-sync API-key checks |
|
|
91
|
-
| `STATELY_API_KEY` | Server-side API key for Stately data fetching |
|
|
92
|
-
| `STATELY_API_URL` | Stately API base URL override |
|
|
93
106
|
| `NEXT_PUBLIC_BASE_URL` | Public-facing editor URL |
|
|
94
107
|
|
|
95
108
|
### Studio API client
|
|
@@ -117,22 +130,38 @@ self-hosted deployments that intentionally accept unauthenticated calls.
|
|
|
117
130
|
|
|
118
131
|
### Inspector
|
|
119
132
|
|
|
133
|
+
<!-- createInspector API from src/inspect.ts -->
|
|
134
|
+
|
|
120
135
|
Stream live actor-system state to the Stately inspector over WebSockets, with support for automatic XState actor adoption and manual actor registration.
|
|
121
136
|
|
|
122
137
|
```ts
|
|
123
138
|
import { createActor } from 'xstate';
|
|
124
|
-
import {
|
|
139
|
+
import { createInspector } from '@statelyai/sdk';
|
|
125
140
|
|
|
126
141
|
const actor = createActor(machine);
|
|
127
|
-
const inspector =
|
|
142
|
+
const inspector = createInspector({
|
|
143
|
+
url: 'ws://localhost:4242',
|
|
144
|
+
});
|
|
128
145
|
|
|
129
146
|
inspector.inspect(actor);
|
|
130
147
|
actor.start();
|
|
131
148
|
```
|
|
132
149
|
|
|
150
|
+
XState v5 and v6 inspection events normalize to actor, transition, and stop
|
|
151
|
+
events before crossing the WebSocket protocol.
|
|
152
|
+
In Node, the inspector opens in the default browser automatically. The SDK
|
|
153
|
+
generates a cryptographically random session capability; hosted inspectors send
|
|
154
|
+
signed-out users through OAuth and return them to that same live session. The
|
|
155
|
+
Node process does not need a Stately API key.
|
|
156
|
+
|
|
133
157
|
### CLI and sync
|
|
134
158
|
|
|
135
|
-
|
|
159
|
+
<!-- CLI package identity and commands from ../cli/package.json and ../cli/src/cli.ts#COMMANDS -->
|
|
160
|
+
|
|
161
|
+
The separate [`statelyai`](https://www.npmjs.com/package/statelyai) CLI syncs
|
|
162
|
+
local XState source files with Stately Studio projects: push local machines,
|
|
163
|
+
pull remote changes, and open a local file in a browser-backed visual editor
|
|
164
|
+
session.
|
|
136
165
|
|
|
137
166
|
```bash
|
|
138
167
|
npx statelyai push
|
|
@@ -144,6 +173,7 @@ npx statelyai open ./checkout.machine.ts
|
|
|
144
173
|
|
|
145
174
|
Convert between Studio graph data, XState machine configs, and TypeScript source. Generate types from JSON Schema.
|
|
146
175
|
|
|
147
|
-
##
|
|
176
|
+
## Support
|
|
148
177
|
|
|
149
|
-
|
|
178
|
+
For pricing and self-hosting details, contact
|
|
179
|
+
[team@stately.ai](mailto:team@stately.ai).
|
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-
|
|
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
|
|
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) {
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
8
|
-
import { a as
|
|
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-COqtklcn.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
|
|
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-pcNCbL7j.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-
|
|
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
|
};
|
|
@@ -125,8 +204,9 @@ interface CreateInspectorOptions {
|
|
|
125
204
|
/** Auto-open browser to visualizer. Default: `true`. */
|
|
126
205
|
autoOpen?: boolean;
|
|
127
206
|
/**
|
|
128
|
-
* Relay session
|
|
129
|
-
* value the
|
|
207
|
+
* Relay session capability. Defaults to a cryptographically random UUID.
|
|
208
|
+
* This is the `?session=<id>` value the visualizer connects with. Custom
|
|
209
|
+
* values used with a hosted relay must be unguessable.
|
|
130
210
|
*/
|
|
131
211
|
sessionId?: string;
|
|
132
212
|
/** Display name for this system in the visualizer. */
|
|
@@ -141,7 +221,7 @@ interface CreateInspectorOptions {
|
|
|
141
221
|
* Extract the machine config for a given actor. Defaults to reading
|
|
142
222
|
* `actor.logic.config`. Return `null` for non-machine actors.
|
|
143
223
|
*/
|
|
144
|
-
extractMachineConfig?: (actor: any) => unknown;
|
|
224
|
+
extractMachineConfig?: (actor: any, source?: unknown) => unknown;
|
|
145
225
|
/** Selected actor id to focus on first. Defaults to the first inspected root. */
|
|
146
226
|
selectedActorId?: string;
|
|
147
227
|
/** Panel layout forwarded into the system init message. */
|
|
@@ -200,6 +280,8 @@ interface Inspector {
|
|
|
200
280
|
/** Tear down the WebSocket + xstate subscription. */
|
|
201
281
|
destroy(): void;
|
|
202
282
|
}
|
|
203
|
-
declare function
|
|
283
|
+
declare function createInspector(options?: CreateInspectorOptions): Inspector;
|
|
284
|
+
/** @deprecated Use {@link createInspector}. */
|
|
285
|
+
declare const createStatelyInspector: typeof createInspector;
|
|
204
286
|
//#endregion
|
|
205
|
-
export {
|
|
287
|
+
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 };
|