@statelyai/sdk 0.29.1 → 0.31.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.
Files changed (34) hide show
  1. package/README.md +15 -0
  2. package/dist/assetStorage.d.mts +1 -1
  3. package/dist/auth.d.mts +1 -1
  4. package/dist/{statelyPragma-p1vu8PmH.mjs → dist-wbhkeGh6.mjs} +468 -204
  5. package/dist/{editor-sync-types-DB1N6QUK.d.mts → editor-sync-types-CPpzTSnT.d.mts} +4 -0
  6. package/dist/{editorHostSession-vSt07IJV.d.mts → editorHostSession-Bo-YhDEG.d.mts} +105 -6
  7. package/dist/{editorHostSession-DNpXPNAc.mjs → editorHostSession-CT8y0yzG.mjs} +380 -20
  8. package/dist/editorHostSession.d.mts +2 -2
  9. package/dist/editorHostSession.mjs +3 -2
  10. package/dist/embed.d.mts +3 -4
  11. package/dist/embed.mjs +5 -2
  12. package/dist/{graph-C8E1Exad.d.mts → graph-CR_g-mOq.d.mts} +1 -1
  13. package/dist/graph.d.mts +1 -1
  14. package/dist/{index-D4pdeDpT.d.mts → index-DlOZxzrW.d.mts} +92 -2
  15. package/dist/index.d.mts +8 -9
  16. package/dist/index.mjs +6 -5
  17. package/dist/{inspect-D61HS-t7.d.mts → inspect-BoWXrB-V.d.mts} +3 -2
  18. package/dist/{inspect-dmCvrIl1.mjs → inspect-DoDj7iWa.mjs} +25 -1
  19. package/dist/inspect.d.mts +2 -2
  20. package/dist/inspect.mjs +2 -2
  21. package/dist/patchTypes.d.mts +1 -1
  22. package/dist/protocol-2cvzJtGN.d.mts +846 -0
  23. package/dist/protocol.d.mts +2 -821
  24. package/dist/relay.d.mts +1 -1
  25. package/dist/statelyPragma-D46lczJR.mjs +102 -0
  26. package/dist/{studio-D-yqFd0u.d.mts → studio-DV5IIGhV.d.mts} +2 -2
  27. package/dist/studio.d.mts +1 -1
  28. package/dist/sync.d.mts +2 -2
  29. package/dist/sync.mjs +411 -30
  30. package/dist/{version-DC3yW9Dk.mjs → version-B6OHpDiz.mjs} +1 -1
  31. package/package.json +3 -3
  32. package/schemas/statelyai.schema.json +6 -0
  33. package/dist/embedPanel-Bpbq4sfJ.d.mts +0 -13
  34. /package/dist/{auth-BPyCCHYo.d.mts → auth-Dg7prjeL.d.mts} +0 -0
@@ -65,6 +65,8 @@ interface EditorSyncDocumentContext {
65
65
  rootFileName: string;
66
66
  rootDir: string;
67
67
  documents: EditorSyncSourceDocument[];
68
+ /** Zero-based machine occurrence within the root source document. */
69
+ machineIndex?: number;
68
70
  }
69
71
  type EditorSyncParseRequest = EditorSyncDocumentContext;
70
72
  interface EditorSyncParseResponse {
@@ -81,7 +83,9 @@ interface EditorSyncApplyRequest extends EditorSyncDocumentContext {
81
83
  sourceLocations?: MachineSourceLocations;
82
84
  serialized?: Record<string, string>;
83
85
  preserveStatelyMetadata?: boolean;
86
+ sourceUpdateStrategy?: SourceUpdateStrategy;
84
87
  }
88
+ type SourceUpdateStrategy = 'preserve' | 'rewrite';
85
89
  interface EditorSyncTextReplacement {
86
90
  uri?: string;
87
91
  range: EditorSyncSourceRange;
@@ -1,5 +1,5 @@
1
- import { t as EmbedPanelConfig } from "./embedPanel-Bpbq4sfJ.mjs";
2
- import { a as EditorSyncParseRequest, d as EditorSyncTextReplacement, f as MachineSourceLocations, i as EditorSyncApplyResponse, n as EditorSyncAccess, o as EditorSyncParseResponse, r as EditorSyncApplyRequest, s as EditorSyncSourceDocument, t as EditorCapabilities } from "./editor-sync-types-DB1N6QUK.mjs";
1
+ import { Y as ProjectEmbedMachine, Zt as EmbedPanelConfig, ot as ProjectWorkspaceConfig } from "./protocol-2cvzJtGN.mjs";
2
+ import { a as EditorSyncParseRequest, d as EditorSyncTextReplacement, f as MachineSourceLocations, i as EditorSyncApplyResponse, n as EditorSyncAccess, o as EditorSyncParseResponse, r as EditorSyncApplyRequest, s as EditorSyncSourceDocument, t as EditorCapabilities } from "./editor-sync-types-CPpzTSnT.mjs";
3
3
 
4
4
  //#region src/editorHostProtocol.d.ts
5
5
  declare const EDITOR_PROTOCOL_VERSION = 1;
@@ -24,11 +24,13 @@ type EditorHostInboundMessage = {
24
24
  } | {
25
25
  type: '@statelyai.loaded';
26
26
  graph: unknown;
27
+ machineId?: string;
27
28
  sourceLocations?: MachineSourceLocations;
28
29
  } | {
29
30
  type: '@statelyai.change';
30
31
  graph: unknown;
31
32
  machineConfig: unknown;
33
+ machineId?: string;
32
34
  patches?: unknown[];
33
35
  sourceLocations?: MachineSourceLocations;
34
36
  } | {
@@ -36,19 +38,24 @@ type EditorHostInboundMessage = {
36
38
  requestId?: string;
37
39
  graph: unknown;
38
40
  machineConfig: unknown;
41
+ machineId?: string;
39
42
  patches?: unknown[];
40
43
  validations?: EditorHostValidationIssue[];
41
44
  sourceLocations?: MachineSourceLocations;
45
+ sourceUpdateStrategy?: 'preserve' | 'rewrite';
42
46
  } | {
43
47
  type: '@statelyai.refresh';
48
+ machineId?: string;
44
49
  } | {
45
50
  type: '@statelyai.retrieved';
46
51
  requestId: string;
47
52
  data: unknown;
53
+ machineId?: string;
48
54
  } | {
49
55
  type: '@statelyai.error';
50
56
  code: string;
51
57
  message: string;
58
+ machineId?: string;
52
59
  requestId?: string;
53
60
  diagnostic?: EditorHostDiagnostic;
54
61
  } | {
@@ -58,6 +65,18 @@ type EditorHostInboundMessage = {
58
65
  type: '@statelyai.clipboardWrite';
59
66
  requestId: string;
60
67
  text: string;
68
+ } | {
69
+ type: '@statelyai.project.machineSelected';
70
+ machineId: string;
71
+ } | {
72
+ type: '@statelyai.project.workspaceAction';
73
+ actionId: string;
74
+ projectId?: string;
75
+ machineId?: string;
76
+ data?: unknown;
77
+ } | {
78
+ type: '@statelyai.project.workspaceOpenChanged';
79
+ open: boolean;
61
80
  };
62
81
  interface EditorHostInitOptions {
63
82
  settings?: Record<string, unknown>;
@@ -92,6 +111,32 @@ type EditorHostOutboundMessage = {
92
111
  enabled?: boolean;
93
112
  mode?: 'structural' | 'all';
94
113
  };
114
+ } | {
115
+ type: '@statelyai.project.init';
116
+ machines: ProjectEmbedMachine[];
117
+ currentMachineId?: string;
118
+ mode?: 'editing' | 'viewing';
119
+ theme?: 'light' | 'dark';
120
+ readOnly?: boolean;
121
+ readOnlyReason?: 'free-plan' | 'access-unverified';
122
+ capabilities?: EditorCapabilities;
123
+ projectWorkspace?: ProjectWorkspaceConfig;
124
+ projectWorkspaceOpen?: boolean;
125
+ settings?: Record<string, unknown>;
126
+ panels?: EmbedPanelConfig[];
127
+ unsavedIndicator?: {
128
+ enabled?: boolean;
129
+ mode?: 'structural' | 'all';
130
+ };
131
+ } | {
132
+ type: '@statelyai.project.update';
133
+ machines: ProjectEmbedMachine[];
134
+ currentMachineId?: string;
135
+ projectWorkspace?: ProjectWorkspaceConfig;
136
+ projectWorkspaceOpen?: boolean;
137
+ } | {
138
+ type: '@statelyai.project.selectMachine';
139
+ machineId: string;
95
140
  } | {
96
141
  type: '@statelyai.setApiKey';
97
142
  apiKey: string;
@@ -106,23 +151,28 @@ type EditorHostOutboundMessage = {
106
151
  type: '@statelyai.update';
107
152
  machine: unknown;
108
153
  format?: string;
154
+ machineId?: string;
109
155
  sourceLocations?: MachineSourceLocations;
110
156
  } | {
111
157
  type: '@statelyai.saved';
112
158
  requestId?: string;
113
159
  graph: unknown;
160
+ machineId?: string;
114
161
  } | {
115
162
  type: '@statelyai.retrieve';
116
163
  requestId: string;
117
164
  format: EditorHostExportFormat;
165
+ machineId?: string;
118
166
  } | {
119
167
  type: '@statelyai.toast';
120
168
  message: string;
121
169
  toastType?: 'success' | 'error' | 'info' | 'warning';
170
+ machineId?: string;
122
171
  } | {
123
172
  type: '@statelyai.error';
124
173
  code: string;
125
174
  message: string;
175
+ machineId?: string;
126
176
  requestId?: string;
127
177
  diagnostic?: EditorHostDiagnostic;
128
178
  } | {
@@ -156,6 +206,8 @@ interface EditorSourceHost {
156
206
  rootUri: string;
157
207
  rootFileName: string;
158
208
  rootDir: string;
209
+ /** Zero-based machine occurrence within the root source document. */
210
+ machineIndex?: number;
159
211
  collectDocuments(extraUris?: readonly string[]): Promise<EditorSyncSourceDocument[]>;
160
212
  applyReplacements(replacements: EditorSyncTextReplacement[], rootUri: string): Promise<string[]>;
161
213
  saveDocuments?(uris: string[]): Promise<void>;
@@ -168,6 +220,7 @@ interface EditorSourceHost {
168
220
  getPreserveStatelyMetadata?(uri: string): boolean;
169
221
  }
170
222
  interface EditorHostSessionOptions {
223
+ sourceUpdateStrategy?: 'preserve' | 'rewrite';
171
224
  source: EditorSourceHost;
172
225
  sync: EditorSyncBackend;
173
226
  send(message: EditorHostOutboundMessage): void;
@@ -183,8 +236,16 @@ interface EditorHostSessionOptions {
183
236
  version: string;
184
237
  };
185
238
  }
239
+ type SaveReminderState = {
240
+ shown: boolean;
241
+ };
242
+ type SelfEditState = {
243
+ count: number;
244
+ };
186
245
  declare class EditorHostSession {
187
246
  private options;
247
+ private saveReminderState;
248
+ private selfEditState;
188
249
  private editorProtocolState;
189
250
  private currentGraph;
190
251
  private lastPersistedGraph;
@@ -192,13 +253,11 @@ declare class EditorHostSession {
192
253
  private currentSourceLocations;
193
254
  private access;
194
255
  private watchedSourceUris;
195
- private selfEditCount;
196
- private saveReminderShown;
197
256
  private watcher;
198
257
  private changeWatcher;
199
258
  private retrieveRequestCount;
200
259
  private pendingRetrievals;
201
- constructor(options: EditorHostSessionOptions);
260
+ constructor(options: EditorHostSessionOptions, saveReminderState?: SaveReminderState, selfEditState?: SelfEditState);
202
261
  dispose(): void;
203
262
  notifySavedDocument(uri?: string): Promise<void>;
204
263
  receive(message: EditorHostInboundMessage): Promise<void>;
@@ -211,5 +270,45 @@ declare class EditorHostSession {
211
270
  private requestSerialized;
212
271
  private resolveRetrieved;
213
272
  }
273
+ interface EditorHostWorkspaceMachine {
274
+ id: string;
275
+ name?: string;
276
+ sourceReference?: string;
277
+ source: EditorSourceHost;
278
+ }
279
+ type EditorHostWorkspaceSessionOptions = Omit<EditorHostSessionOptions, 'source' | 'send'> & {
280
+ machines: EditorHostWorkspaceMachine[];
281
+ send(message: EditorHostOutboundMessage): void;
282
+ currentMachineId?: string;
283
+ workspaceName?: string;
284
+ projectWorkspaceOpen?: boolean;
285
+ };
286
+ /**
287
+ * Runs one source-sync session per discovered machine while presenting the
288
+ * editor's project/workspace protocol as a single surface.
289
+ */
290
+ declare class EditorHostWorkspaceSession {
291
+ private options;
292
+ private children;
293
+ private machineDefinitions;
294
+ private initialMessages;
295
+ private selectedMachineId;
296
+ private sentHandshake;
297
+ private sentApiKey;
298
+ private initialized;
299
+ private projectWorkspaceOpen;
300
+ private retrieveRequestCount;
301
+ private pendingRetrievals;
302
+ private saveReminderStates;
303
+ private selfEditStates;
304
+ constructor(options: EditorHostWorkspaceSessionOptions);
305
+ receive(message: EditorHostInboundMessage): Promise<void>;
306
+ selectMachine(machineId: string): void;
307
+ dispose(): void;
308
+ private handleChildMessage;
309
+ private flushProjectInit;
310
+ private getProjectMachines;
311
+ private getProjectWorkspace;
312
+ }
214
313
  //#endregion
215
- export { EditorSyncError as a, fetchEditorSyncAccess as c, EditorHostExportFormat as d, EditorHostInboundMessage as f, EditorHostValidationIssue as h, EditorSyncBackend as i, EDITOR_PROTOCOL_VERSION as l, EditorHostOutboundMessage as m, EditorHostSessionOptions as n, RemoteEditorSyncBackendOptions as o, EditorHostInitOptions as p, EditorSourceHost as r, createRemoteEditorSyncBackend as s, EditorHostSession as t, EditorHostDiagnostic as u };
314
+ export { EditorHostOutboundMessage as _, EditorHostWorkspaceSessionOptions as a, EditorSyncError as c, fetchEditorSyncAccess as d, EDITOR_PROTOCOL_VERSION as f, EditorHostInitOptions as g, EditorHostInboundMessage as h, EditorHostWorkspaceSession as i, RemoteEditorSyncBackendOptions as l, EditorHostExportFormat as m, EditorHostSessionOptions as n, EditorSourceHost as o, EditorHostDiagnostic as p, EditorHostWorkspaceMachine as r, EditorSyncBackend as s, EditorHostSession as t, createRemoteEditorSyncBackend as u, EditorHostValidationIssue as v };