@statelyai/sdk 0.4.0 → 0.4.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
@@ -267,6 +267,30 @@ Update the displayed machine.
267
267
 
268
268
  Change the embed mode or theme at runtime.
269
269
 
270
+ #### `embed.setSettings(settings)`
271
+
272
+ Update editor settings at runtime. Merges with existing settings.
273
+
274
+ ```ts
275
+ embed.setSettings({
276
+ appearance: { colorMode: 'light' },
277
+ canvas: { showGrid: false },
278
+ });
279
+ ```
280
+
281
+ Available core settings:
282
+
283
+ | Path | Type | Default |
284
+ |------|------|---------|
285
+ | `appearance.colorMode` | `'light' \| 'dark' \| 'system'` | `'dark'` |
286
+ | `canvas.showGrid` | `boolean` | `true` |
287
+ | `canvas.viewMode` | `'graph' \| 'list'` | `'graph'` |
288
+ | `canvas.enableSnapLines` | `boolean` | `true` |
289
+ | `canvas.dimUnselected` | `boolean` | `true` |
290
+ | `validation.showValidations` | `boolean` | `true` |
291
+ | `autolayout.autoEnabled` | `boolean` | `false` |
292
+ | `developer.devMode` | `boolean` | `false` |
293
+
270
294
  #### `embed.export(format, options?)`
271
295
 
272
296
  Export the current machine. Returns a promise.
package/dist/embed.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as EmbedMode, c as ExportFormatMap, d as UploadResult, i as EmbedEventName, l as InitOptions, n as EmbedEventHandler, o as ExportCallOptions, r as EmbedEventMap, s as ExportFormat, t as CommentsConfig } from "./protocol-BgXSkIuc.mjs";
1
+ import { a as EmbedMode, c as ExportFormatMap, d as UploadResult, i as EmbedEventName, l as InitOptions, n as EmbedEventHandler, o as ExportCallOptions, r as EmbedEventMap, s as ExportFormat, t as CommentsConfig } from "./protocol-CZVFCSg3.mjs";
2
2
 
3
3
  //#region src/embed.d.ts
4
4
  interface AssetConfig {
@@ -49,6 +49,8 @@ interface StatelyEmbed {
49
49
  setMode(mode: EmbedMode): void;
50
50
  /** Change the embed theme. */
51
51
  setTheme(theme: 'light' | 'dark'): void;
52
+ /** Update editor settings. Merges with existing settings. */
53
+ setSettings(settings: Record<string, unknown>): void;
52
54
  /** Export the current machine in a given format. Returns a promise. */
53
55
  export<F extends ExportFormat>(format: F, options?: ExportCallOptions<F>): Promise<ExportFormatMap[F]['result']>;
54
56
  /** Subscribe to an embed event. */
package/dist/embed.mjs CHANGED
@@ -158,7 +158,7 @@ function createStatelyEmbed(options) {
158
158
  el.style.border = "none";
159
159
  el.style.width = "100%";
160
160
  el.style.height = "100%";
161
- el.setAttribute("sandbox", "allow-scripts allow-same-origin");
161
+ el.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox");
162
162
  el.setAttribute("allow", "clipboard-read; clipboard-write");
163
163
  container.appendChild(el);
164
164
  iframe = el;
@@ -188,6 +188,12 @@ function createStatelyEmbed(options) {
188
188
  theme
189
189
  });
190
190
  },
191
+ setSettings(settings) {
192
+ send({
193
+ type: "@statelyai.setSettings",
194
+ settings
195
+ });
196
+ },
191
197
  toast(message, toastType) {
192
198
  send({
193
199
  type: "@statelyai.toast",
@@ -252,7 +252,7 @@ function graphToMachineConfig(graph, options = {}) {
252
252
  const targetNode = graph.nodes.find((n) => n.id === edge.targetId);
253
253
  const resolvedTarget = targetNode ? targetNode.parentId === node.parentId ? targetNode.data.key : `#${targetNode.id}` : "";
254
254
  const type = edge.data.eventType ?? "";
255
- const transitionMeta = buildMeta(edge.data.meta, edge.data.color);
255
+ const transitionMeta = showMeta ? buildMeta(edge.data.meta, edge.data.color) : void 0;
256
256
  const transitionObject = {
257
257
  target: `${resolvedTarget}`,
258
258
  ...edge.data.transitionType === "reenter" ? { reenter: true } : void 0,
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  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-BfezxFKJ.mjs";
2
2
  import { a as ProjectMachine, c as StudioClientOptions, i as ProjectData, l as VerifyApiKeyResponse, n as ExtractedMachine, o as StudioApiError, r as GetMachineOptions, s as StudioClient, t as ExtractMachinesResponse, u as createStatelyClient } from "./studio-D2uQhrvX.mjs";
3
3
  import { PlanSyncOptions, PullSyncResult, ResolvedSyncInput, SyncInputFormat, SyncPlan, SyncPlanSummary } from "./sync.mjs";
4
- import { a as EmbedMode, c as ExportFormatMap, d as UploadResult, i as EmbedEventName, l as InitOptions, n as EmbedEventHandler, o as ExportCallOptions, r as EmbedEventMap, s as ExportFormat, t as CommentsConfig, u as ProtocolMessage } from "./protocol-BgXSkIuc.mjs";
4
+ import { a as EmbedMode, c as ExportFormatMap, d as UploadResult, i as EmbedEventName, l as InitOptions, n as EmbedEventHandler, o as ExportCallOptions, r as EmbedEventMap, s as ExportFormat, t as CommentsConfig, u as ProtocolMessage } from "./protocol-CZVFCSg3.mjs";
5
5
  import { AssetConfig, StatelyEmbed, StatelyEmbedOptions, createStatelyEmbed } from "./embed.mjs";
6
6
  import { CreateInspectorOptions, InspectOptions, Inspector, createStatelyInspector } from "./inspect.mjs";
7
7
  import { JSONSchema7 } from "json-schema";
package/dist/index.mjs CHANGED
@@ -3,6 +3,6 @@ import { createStatelyEmbed } from "./embed.mjs";
3
3
  import { createStatelyInspector } from "./inspect.mjs";
4
4
  import { StudioApiError, createStatelyClient } from "./studio.mjs";
5
5
  import { fromStudioMachine, studioMachineConverter, toStudioMachine } from "./graph.mjs";
6
- import { a as graphToMachineConfig, c as serializeJS, i as jsonSchemaToTSType, n as contextSchemaToTSType, o as RawCode, r as eventsSchemaToTSType, s as raw, t as graphToXStateTS } from "./graphToXStateTS-C6HQUrBB.mjs";
6
+ import { a as graphToMachineConfig, c as serializeJS, i as jsonSchemaToTSType, n as contextSchemaToTSType, o as RawCode, r as eventsSchemaToTSType, s as raw, t as graphToXStateTS } from "./graphToXStateTS-Cfp_fxSH.mjs";
7
7
 
8
8
  export { RawCode, StudioApiError, contextSchemaToTSType, createPostMessageTransport, createStatelyClient, createStatelyEmbed, createStatelyInspector, createWebSocketTransport, eventsSchemaToTSType, fromStudioMachine, graphToMachineConfig, graphToXStateTS, jsonSchemaToTSType, raw, serializeJS, studioMachineConverter, toStudioMachine };
@@ -1,4 +1,4 @@
1
- import { a as EmbedMode, c as ExportFormatMap, i as EmbedEventName, n as EmbedEventHandler, o as ExportCallOptions, r as EmbedEventMap, s as ExportFormat } from "./protocol-BgXSkIuc.mjs";
1
+ import { a as EmbedMode, c as ExportFormatMap, i as EmbedEventName, n as EmbedEventHandler, o as ExportCallOptions, r as EmbedEventMap, s as ExportFormat } from "./protocol-CZVFCSg3.mjs";
2
2
 
3
3
  //#region src/inspect.d.ts
4
4
  interface CreateInspectorOptions {
@@ -107,6 +107,10 @@ interface SetThemeMessage {
107
107
  type: '@statelyai.setTheme';
108
108
  theme: 'light' | 'dark';
109
109
  }
110
+ interface SetSettingsMessage {
111
+ type: '@statelyai.setSettings';
112
+ settings: Record<string, unknown>;
113
+ }
110
114
  interface RetrieveMessage {
111
115
  type: '@statelyai.retrieve';
112
116
  requestId: string;
@@ -193,7 +197,7 @@ interface UploadResponseMessage {
193
197
  result: UploadResult;
194
198
  }
195
199
  /** All messages a client (embed/inspector) can send to the viz. */
196
- type ClientMessage = InitMessage | UpdateMessage | SetModeMessage | SetThemeMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | UploadCapabilitiesMessage | UploadResponseMessage | ErrorMessage;
200
+ type ClientMessage = InitMessage | UpdateMessage | SetModeMessage | SetThemeMessage | SetSettingsMessage | RetrieveMessage | ToastMessage | InspectSnapshotMessage | UploadCapabilitiesMessage | UploadResponseMessage | ErrorMessage;
197
201
  /** All messages the viz can send back to a client. */
198
202
  type VizMessage = ReadyMessage | LoadedMessage | ChangeMessage | SaveMessage | RetrievedMessage | ErrorMessage | UploadRequestMessage;
199
203
  interface RegisterMessage {
package/dist/sync.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createStatelyClient } from "./studio.mjs";
2
2
  import { fromStudioMachine, toStudioMachine } from "./graph.mjs";
3
- import { t as graphToXStateTS } from "./graphToXStateTS-C6HQUrBB.mjs";
3
+ import { t as graphToXStateTS } from "./graphToXStateTS-Cfp_fxSH.mjs";
4
4
  import { getDiff, isEmptyDiff } from "@statelyai/graph";
5
5
  import fs from "node:fs/promises";
6
6
  import path from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statelyai/sdk",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "dist"