@statelyai/sdk 0.36.0 → 0.37.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 CHANGED
@@ -53,8 +53,36 @@ The embed `apiKey` is sent to the iframe over `postMessage` after the editor
53
53
  handshake; it is not included in the iframe URL. Call `embed.setApiKey(token)`
54
54
  when the host refreshes the access token.
55
55
 
56
+ <!-- source-preserving embed.planSourceUpdate from src/embed.ts and editor-sync route -->
57
+
58
+ For a Git-backed XState JSON or JSONC file, keep the exact blob text in the host.
59
+ On save, pass the edited graph and original blob text to the configured editor:
60
+
61
+ ```ts
62
+ const plan = await embed.planSourceUpdate({
63
+ source: { fileName: 'machines/checkout.jsonc', text: originalBlobText },
64
+ nextGraph: savedGraph,
65
+ });
66
+ if (plan.status === 'changed') {
67
+ // Commit plan.text only if the Git blob revision still matches the one read.
68
+ // Advance originalBlobText and the host's graph baseline after commit succeeds.
69
+ }
70
+ if (plan.status === 'unsupported') console.warn(plan.reason);
71
+ ```
72
+
73
+ JSON and JSONC contain one machine; omit `source.machineIndex` for this method.
74
+ The call returns the complete updated text, focused zero-based UTF-16
75
+ `edits`, and a semantic graph `diff`. The graph diff is not a Git patch; GitLab
76
+ constructs its merge-request diff from the committed text. The call does not
77
+ read or write Git. It requires the editor-sync endpoint on the editor at
78
+ `baseUrl`, an allowed API origin, and editor-sync write access. This one-file
79
+ method supports XState `.json` and `.jsonc` sources; imported TypeScript
80
+ definitions require the document-based Editor Sync parse/apply APIs.
81
+
56
82
  Use `viewMode: 'list'` on `createStatelyEmbed` to add `?view=list` to the
57
83
  iframe URL, or subscribe to `viewModeChanged` when the user switches views.
84
+ Pass the initial `theme` or `settings.appearance.colorMode` when creating the
85
+ embed so its loading screen uses that color mode before initialization.
58
86
 
59
87
  Custom profiles and formats can be supplied when the embed is created. Their
60
88
  serializable manifests are sent to the iframe; detector, importer, exporter,
package/dist/embed.d.mts CHANGED
@@ -2,6 +2,7 @@ import { n as ProfileManifest } from "./index-CoxF4Saw.mjs";
2
2
  import { i as StatelyGraph } from "./graph-B6xUxqR5.mjs";
3
3
  import { D as ExportCallOptions, F as InitOptions, G as MachineInitOptions, Gt as UploadResult, J as MachineVersionAutoSaveOptions, O as ExportFormat, Q as ProjectEmbedMachine, S as EmbedExtensionsManifest, Yt as ViewerOptions, _ as EmbedDocumentLanguage, at as ProjectWorkspaceAction, b as EmbedEventName, ct as ProjectWorkspaceCapabilities, d as CommentsConfig, dt as ProjectWorkspaceMachineOrigin, et as ProjectInitOptions, g as EmbedDocument, k as ExportFormatMap, lt as ProjectWorkspaceConfig, m as EditorCapabilities, on as EmbedPanelConfig, ot as ProjectWorkspaceActionIcon, pt as ProjectWorkspaceProject, q as MachineSourceLocations, r as CapabilityDeniedEvent, sn as EmbedPanelPosition, ut as ProjectWorkspaceMachine, v as EmbedEventHandler, w as EmbedMode, y as EmbedEventMap } from "./protocol-CP3DSl5u.mjs";
4
4
  import { AssetUploadAdapter } from "./assetStorage.mjs";
5
+ import { GraphDiff } from "@statelyai/graph";
5
6
 
6
7
  //#region src/embed.d.ts
7
8
  interface AssetConfig {
@@ -37,6 +38,34 @@ type EmbedGraph = EmbedEntity & {
37
38
  nodes?: EmbedEntity[];
38
39
  edges?: EmbedEntity[];
39
40
  };
41
+ /** One zero-based UTF-16 source edit, relative to the supplied original text. */
42
+ interface SourceUpdateEdit {
43
+ range: {
44
+ startLine: number;
45
+ startChar: number;
46
+ endLine: number;
47
+ endChar: number;
48
+ };
49
+ newText: string;
50
+ }
51
+ interface SourceUpdatePlan {
52
+ status: 'changed' | 'unchanged' | 'unsupported';
53
+ /** Complete updated file; commit this after checking the Git blob revision. */
54
+ text: string;
55
+ edits: SourceUpdateEdit[];
56
+ /** Semantic graph changes, not a Git patch. */
57
+ diff: GraphDiff;
58
+ reason?: string;
59
+ }
60
+ interface PlanSourceUpdateInput {
61
+ source: {
62
+ fileName: string;
63
+ text: string;
64
+ machineIndex?: number;
65
+ };
66
+ /** Edited graph from the embed, with stable node and edge IDs. */
67
+ nextGraph: StatelyGraph;
68
+ }
40
69
  type EmbedFormatContext = {
41
70
  profile: EmbedProfileDefinition;
42
71
  resolveGraphData(graph: EmbedGraph): Record<string, unknown>;
@@ -114,6 +143,8 @@ interface StatelyEmbedOptions extends Partial<MachineInitOptions> {
114
143
  onCapabilityDenied?: (event: CapabilityDeniedEvent) => void;
115
144
  }
116
145
  interface StatelyEmbed {
146
+ /** Plan one-file XState JSON/JSONC writeback on the configured editor server. Does not write. */
147
+ planSourceUpdate(input: PlanSourceUpdateInput): Promise<SourceUpdatePlan>;
117
148
  /** Attach to an existing iframe element. Sets src and begins handshake. */
118
149
  attach(iframe: HTMLIFrameElement): void;
119
150
  /** Create an iframe and mount it into a container element. */
@@ -152,4 +183,4 @@ interface StatelyEmbed {
152
183
  }
153
184
  declare function createStatelyEmbed(options: StatelyEmbedOptions): StatelyEmbed;
154
185
  //#endregion
155
- export { AssetConfig, type CapabilityDeniedEvent, type CommentsConfig, type EditorCapabilities, type EmbedDocument, type EmbedDocumentLanguage, EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExtensionsManifest, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, type EmbedMode, type EmbedPanelConfig, type EmbedPanelPosition, EmbedProfileDefinition, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type MachineInitOptions, type MachineSourceLocations, type MachineVersionAutoSaveOptions, type ProjectEmbedMachine, type ProjectInitOptions, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceMachineOrigin, type ProjectWorkspaceProject, StatelyEmbed, StatelyEmbedOptions, type UploadResult, type ViewerOptions, createStatelyEmbed };
186
+ export { AssetConfig, type CapabilityDeniedEvent, type CommentsConfig, type EditorCapabilities, type EmbedDocument, type EmbedDocumentLanguage, EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExtensionsManifest, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, type EmbedMode, type EmbedPanelConfig, type EmbedPanelPosition, EmbedProfileDefinition, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type InitOptions, type MachineInitOptions, type MachineSourceLocations, type MachineVersionAutoSaveOptions, PlanSourceUpdateInput, type ProjectEmbedMachine, type ProjectInitOptions, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceMachineOrigin, type ProjectWorkspaceProject, SourceUpdateEdit, SourceUpdatePlan, StatelyEmbed, StatelyEmbedOptions, type UploadResult, type ViewerOptions, createStatelyEmbed };
package/dist/embed.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./protocol-BsBGRISR.mjs";
2
- import { c as createPendingExportManager, l as settingsWithViewMode, r as createPostMessageTransport, s as createEventRegistry, t as SDK_VERSION, u as toInitMessage } from "./version-DS2izNeF.mjs";
2
+ import { c as createPendingExportManager, l as settingsWithViewMode, r as createPostMessageTransport, s as createEventRegistry, t as SDK_VERSION, u as toInitMessage } from "./version-olQZ7Dn0.mjs";
3
3
  import { EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol.mjs";
4
4
 
5
5
  //#region src/embed.ts
@@ -34,6 +34,10 @@ function buildEmbedUrl(options) {
34
34
  const url = new URL(base);
35
35
  if (normalizeApiKey(options.apiKey)) url.searchParams.set("auth", "message");
36
36
  if (options.viewMode) url.searchParams.set("view", options.viewMode);
37
+ const appearance = options.settings?.appearance;
38
+ const settingsMode = appearance && typeof appearance === "object" && "colorMode" in appearance ? appearance.colorMode : void 0;
39
+ const colorMode = options.theme ?? settingsMode;
40
+ if (colorMode === "light" || colorMode === "dark" || colorMode === "system") url.searchParams.set("theme", colorMode);
37
41
  return url.toString();
38
42
  }
39
43
  function serializeExtensions(options) {
@@ -540,6 +544,28 @@ function createStatelyEmbed(options) {
540
544
  export(format, callOptions) {
541
545
  return exportManager.start(format, callOptions, "Embed is destroyed", () => destroyed);
542
546
  },
547
+ async planSourceUpdate(input) {
548
+ if (destroyed) throw new Error("Embed is destroyed");
549
+ const response = await fetch(new URL("/api/editor-sync/plan-source-update", options.baseUrl), {
550
+ method: "POST",
551
+ headers: {
552
+ "Content-Type": "application/json",
553
+ "X-Stately-Editor-Sync-Version": "1",
554
+ ...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
555
+ },
556
+ body: JSON.stringify(input)
557
+ });
558
+ const protocolVersion = response.headers.get("X-Stately-Editor-Sync-Version");
559
+ if (protocolVersion !== null && protocolVersion !== "1") throw new Error(`Unsupported editor-sync protocol ${protocolVersion}`);
560
+ const result = await response.json();
561
+ if (!response.ok) throw new Error(result?.error ?? `Source update failed (${response.status})`);
562
+ if (!result || ![
563
+ "changed",
564
+ "unchanged",
565
+ "unsupported"
566
+ ].includes(result.status) || typeof result.text !== "string" || !Array.isArray(result.edits)) throw new Error("Invalid source update response");
567
+ return result;
568
+ },
543
569
  on(event, handler) {
544
570
  events.on(event, handler);
545
571
  },
package/dist/index.d.mts CHANGED
@@ -5,9 +5,9 @@ import { $t as createInspectionRoomUrls, B as InspectionSentEvent, D as ExportCa
5
5
  import { AssetUploadAdapter, AssetUploadContext, AssetUploadRequest, CreateS3AssetUploadAdapterOptions, CreateSupabaseAssetUploadAdapterOptions, S3UploadTarget, SupabaseStorageClient, createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
6
6
  import { StatelyAuthMode, StatelyCredential, createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
7
7
  import { EDITOR_PROTOCOL_VERSION, EditorHostDiagnostic, EditorHostExportFormat, EditorHostInboundMessage, EditorHostInitOptions, EditorHostOutboundMessage, EditorHostValidationIssue } from "./editorHostProtocol.mjs";
8
- import { AssetConfig, EmbedEntity, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, EmbedProfileDefinition, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
8
+ import { AssetConfig, EmbedEntity, EmbedFormatContext, EmbedFormatDefinition, EmbedGraph, EmbedProfileDefinition, PlanSourceUpdateInput, SourceUpdateEdit, SourceUpdatePlan, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
9
9
  import { _ as createWebSocketTransport, a as InspectedTransition, c as InspectorDiscoveryEntry, d as ManualActorOptions, f as createInspector, g as createPostMessageTransport, h as TransportFailure, i as InspectedSnapshot, l as InspectorEvents, m as Transport, n as CreateInspectorOptions, o as Inspector, p as createStatelyInspector, r as InspectedEvent, s as InspectorConnection, t as AdoptedActor, u as InspectorInspectionEvent } from "./inspect-Douvt5k_.mjs";
10
10
  import { A as Machine, C as StudioMachineRecord, D as VerifyApiKeyResponse, E as UpdateProjectInput, F as ProjectVisibility, I as VerifyResult, L as XStateVersion, M as Project, N as ProjectMachineSummary, O as createStatelyClient, P as ProjectSummary, R as ResourceErrorCode, S as StudioClientOptions, T as UpdateMachineInput, _ as ProjectMachine, a as CreateMachineTemplate, b as StudioApiErrorOptions, c as EnsureProjectInput, d as ExtractedMachine, f as GetMachineOptions, g as ProjectData, h as LegacyUpdateMachineInput, i as CreateMachineInput, j as MachineVersion, k as ExtractedMachines, l as ExtractMachinesInput, m as LegacyProjectVisibility, n as CreateMachineFromDefinitionInput, o as CreateProjectInput, r as CreateMachineFromTemplateInput, s as DEFAULT_STATELY_BASE_URL, t as ConnectedRepo, u as ExtractMachinesResponse, v as RepoType, w as StudioRequestOptions, x as StudioClient, y as StudioApiError } from "./studio-DvEgrtk1.mjs";
11
11
  import { OAuthAuthorizationServerMetadata, OAuthClientRegistrationResponse, OAuthProtectedResourceMetadata, OAuthTokenResponse, PkcePair, buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
12
12
  import { CreateInspectionRelayOptions, InspectionRelay, InspectionRelayEffect, InspectionRelayPeer, InspectionRelayRole, InspectionRelaySnapshot, createInspectionRelay } from "./relay.mjs";
13
- export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EditorHostDiagnostic, type EditorHostExportFormat, type EditorHostInboundMessage, type EditorHostInitOptions, type EditorHostOutboundMessage, type EditorHostValidationIssue, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExample, type EmbedFormatContext, type EmbedFormatDefinition, type EmbedGraph, type EmbedMode, type EmbedPanelConfig, type EmbedPanelPosition, type EmbedProfileDefinition, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorConnection, type InspectorDiscoveryEntry, type InspectorEvents, type InspectorInspectionEvent, type InspectorLoadedEvent, type InspectorSettings, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineVersion, type MachineVersionAutoSaveOptions, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PresentationMetadataInitializer, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceMachineOrigin, type ProjectWorkspaceProject, type RepoType, 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 StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type VerifyApiKeyResponse, type VerifyResult, type ViewerOptions, type XStateVersion, assertEmbedExamples, buildAuthorizeUrl, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, fromStudioMachine, getCredentialToken, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine, mergeInspectorSettings, refreshToken, registerOAuthClient, resolveInspectorSettings, studioMachineConverter, toStudioMachine };
13
+ export { type ActionLocation, type AdoptedActor, type AssetConfig, type AssetUploadAdapter, type AssetUploadContext, type AssetUploadRequest, type CapabilityDeniedCapability, type CapabilityDeniedEvent, type CommentsConfig, type ConnectedRepo, type CreateInspectionRelayOptions, type CreateInspectorOptions, type CreateMachineFromDefinitionInput, type CreateMachineFromTemplateInput, type CreateMachineInput, type CreateMachineTemplate, type CreateProjectInput, type CreateS3AssetUploadAdapterOptions, type CreateSupabaseAssetUploadAdapterOptions, DEFAULT_STATELY_BASE_URL, type DigraphAction, type DigraphConfig, type DigraphEdgeConfig, type DigraphNodeConfig, EDITOR_PROTOCOL_VERSION, EMBED_DOCUMENT_LANGUAGES, EMBED_DOCUMENT_LIMITS, type EditorCapabilities, type EditorHostDiagnostic, type EditorHostExportFormat, type EditorHostInboundMessage, type EditorHostInitOptions, type EditorHostOutboundMessage, type EditorHostValidationIssue, type EmbedDocument, type EmbedDocumentLanguage, type EmbedEntity, type EmbedEventHandler, type EmbedEventMap, type EmbedEventName, type EmbedExample, type EmbedFormatContext, type EmbedFormatDefinition, type EmbedGraph, type EmbedMode, type EmbedPanelConfig, type EmbedPanelPosition, type EmbedProfileDefinition, type EnsureProjectInput, type EventTypeData, type ExportCallOptions, type ExportFormat, type ExportFormatMap, type ExtractMachinesInput, type ExtractMachinesResponse, type ExtractedMachine, type ExtractedMachines, type GetMachineOptions, type GraphPatch, INSPECTION_PROTOCOL_VERSION, INSPECTION_ROOM_QUERY_PARAM, type InitOptions, type InspectedEvent, type InspectedSnapshot, type InspectedTransition, type InspectionAction, type InspectionRelay, type InspectionRelayEffect, type InspectionRelayPeer, type InspectionRelayRole, type InspectionRelaySnapshot, type InspectionSentEvent, type InspectionTakenTransition, type Inspector, type InspectorConnection, type InspectorDiscoveryEntry, type InspectorEvents, type InspectorInspectionEvent, type InspectorLoadedEvent, type InspectorSettings, type LegacyProjectVisibility, type LegacyUpdateMachineInput, type Machine, type MachineVersion, type MachineVersionAutoSaveOptions, type ManualActorOptions, type OAuthAuthorizationServerMetadata, type OAuthClientRegistrationResponse, type OAuthProtectedResourceMetadata, type OAuthTokenResponse, type PkcePair, type PlanSourceUpdateInput, type PresentationMetadataInitializer, type Project, type ProjectData, type ProjectEmbedMachine, type ProjectMachine, type ProjectMachineSummary, type ProjectSummary, type ProjectVisibility, type ProjectWorkspaceAction, type ProjectWorkspaceActionIcon, type ProjectWorkspaceCapabilities, type ProjectWorkspaceConfig, type ProjectWorkspaceMachine, type ProjectWorkspaceMachineOrigin, type ProjectWorkspaceProject, type RepoType, type ResourceErrorCode, type S3UploadTarget, type SourceUpdateEdit, type SourceUpdatePlan, 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 StudioAction, StudioApiError, type StudioApiErrorOptions, type StudioClient, type StudioClientOptions, type StudioEdge, type StudioMachine, type StudioMachineRecord, type StudioNode, type StudioRequestOptions, type SupabaseStorageClient, type Transport, type TransportFailure, type UpdateMachineInput, type UpdateProjectInput, type UploadResult, type VerifyApiKeyResponse, type VerifyResult, type ViewerOptions, type XStateVersion, assertEmbedExamples, buildAuthorizeUrl, createAuthorizationHeader, createInspectionActorId, createInspectionRelay, createInspectionRoomUrls, createInspector, createPkcePair, createPostMessageTransport, createS3AssetUploadAdapter, createStatelyApiClient, createStatelyApiUrl, createStatelyClient, createStatelyEmbed, createStatelyInspector, createSupabaseAssetUploadAdapter, createWebSocketTransport, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, fromStudioMachine, getCredentialToken, getInspectionRoomId, isEmbedExample, isEmbedExampleMachine, mergeInspectorSettings, refreshToken, registerOAuthClient, resolveInspectorSettings, studioMachineConverter, toStudioMachine };
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { n as StudioApiError, r as createStatelyClient, t as DEFAULT_STATELY_BASE_URL } from "./studio-DhzM6zFx.mjs";
2
2
  import { c as createInspectionRoomUrls, d as isEmbedExampleMachine, f as mergeInspectorSettings, i as INSPECTION_ROOM_QUERY_PARAM, l as getInspectionRoomId, n as EMBED_DOCUMENT_LIMITS, o as assertEmbedExamples, p as resolveInspectorSettings, r as INSPECTION_PROTOCOL_VERSION, s as createInspectionActorId, t as EMBED_DOCUMENT_LANGUAGES, u as isEmbedExample } from "./protocol-BsBGRISR.mjs";
3
- import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-DS2izNeF.mjs";
3
+ import { i as createWebSocketTransport, r as createPostMessageTransport } from "./version-olQZ7Dn0.mjs";
4
4
  import { EDITOR_PROTOCOL_VERSION } from "./editorHostProtocol.mjs";
5
5
  import { createStatelyEmbed } from "./embed.mjs";
6
6
  import { createS3AssetUploadAdapter, createSupabaseAssetUploadAdapter } from "./assetStorage.mjs";
7
- import { n as createStatelyInspector, t as createInspector } from "./inspect-BoMln78S.mjs";
7
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-wHowbxnf.mjs";
8
8
  import { createAuthorizationHeader, getCredentialToken } from "./auth.mjs";
9
9
  import { buildAuthorizeUrl, createPkcePair, discoverAuthorizationServer, discoverProtectedResource, exchangeCodeForToken, refreshToken, registerOAuthClient } from "./oauth.mjs";
10
10
  import { StatelyApiError, createStatelyApiClient, createStatelyApiUrl } from "./api.mjs";
@@ -1,5 +1,5 @@
1
1
  import { c as createInspectionRoomUrls, f as mergeInspectorSettings, l as getInspectionRoomId, p as resolveInspectorSettings, r as INSPECTION_PROTOCOL_VERSION } from "./protocol-BsBGRISR.mjs";
2
- import { a as assertEmbedDocuments, c as createPendingExportManager, i as createWebSocketTransport, n as inspectionRuntime, o as assertEmbedPanels, s as createEventRegistry, t as SDK_VERSION } from "./version-DS2izNeF.mjs";
2
+ import { a as assertEmbedDocuments, c as createPendingExportManager, i as createWebSocketTransport, n as inspectionRuntime, o as assertEmbedPanels, s as createEventRegistry, t as SDK_VERSION } from "./version-olQZ7Dn0.mjs";
3
3
 
4
4
  //#region src/openBrowser.ts
5
5
  async function openBrowser(url) {
@@ -96,15 +96,22 @@ function createInspector(options = {}) {
96
96
  inspectorBaseUrl
97
97
  });
98
98
  const relayUrl = roomUrls?.relayUrl ?? null;
99
- const inspectorUrl = roomUrls?.inspectorUrl ?? null;
99
+ const getInspectorUrl = () => {
100
+ if (!roomUrls?.inspectorUrl) return null;
101
+ const url = new URL(roomUrls.inspectorUrl);
102
+ url.searchParams.set("theme", viewerSettings.appearance?.colorMode ?? "dark");
103
+ return url.toString();
104
+ };
100
105
  const connection = {
101
- inspectorUrl,
106
+ get inspectorUrl() {
107
+ return getInspectorUrl();
108
+ },
102
109
  relayUrl,
103
110
  roomId,
104
111
  producerId
105
112
  };
106
113
  const displayName = name ?? "system:manual";
107
- if (inspectorUrl && launch === "none") console.info(`[Stately Inspector] ${inspectorUrl}`);
114
+ if (connection.inspectorUrl && launch === "none") console.info(`[Stately Inspector] ${connection.inspectorUrl}`);
108
115
  const browserRegistry = isBrowserRuntime() ? getBrowserInspectorRegistry() : void 0;
109
116
  browserRegistry?.set(producerId, connection);
110
117
  const browserLaunchUnsupported = launch === "browser" && isBrowserRuntime();
@@ -189,7 +196,8 @@ function createInspector(options = {}) {
189
196
  events.emit("error", failure);
190
197
  return;
191
198
  }
192
- if (inspectorUrl) openBrowser(inspectorUrl).catch((error) => {
199
+ const url = connection.inspectorUrl;
200
+ if (url) openBrowser(url).catch((error) => {
193
201
  const failure = {
194
202
  code: "open_failed",
195
203
  message: error instanceof Error ? error.message : "Unable to open the inspector browser"
@@ -778,7 +786,9 @@ function createInspector(options = {}) {
778
786
  get sessionId() {
779
787
  return roomId;
780
788
  },
781
- inspectorUrl,
789
+ get inspectorUrl() {
790
+ return connection.inspectorUrl;
791
+ },
782
792
  ready,
783
793
  inspect: safelyHandleInspectionEvent,
784
794
  attach: attachActor,
package/dist/inspect.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./protocol-BsBGRISR.mjs";
2
- import "./version-DS2izNeF.mjs";
3
- import { n as createStatelyInspector, t as createInspector } from "./inspect-BoMln78S.mjs";
2
+ import "./version-olQZ7Dn0.mjs";
3
+ import { n as createStatelyInspector, t as createInspector } from "./inspect-wHowbxnf.mjs";
4
4
 
5
5
  export { createInspector, createStatelyInspector };
@@ -378,7 +378,7 @@ function createWebSocketTransport(options) {
378
378
 
379
379
  //#endregion
380
380
  //#region src/version.ts
381
- const SDK_VERSION = "0.36.0";
381
+ const SDK_VERSION = "0.37.1";
382
382
  function inspectionRuntime() {
383
383
  if (typeof window !== "undefined") return "browser";
384
384
  if (typeof process !== "undefined" && process.versions?.node) return "node";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/sdk",
3
- "version": "0.36.0",
3
+ "version": "0.37.1",
4
4
  "license": "MIT",
5
5
  "bin": {
6
6
  "stately-sdk": "./dist/bin.mjs"