@volter/editor-sdk 0.5.57 → 0.5.59

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@volter/editor-sdk",
3
3
  "author": "Volter AI, Inc.",
4
4
  "license": "Apache-2.0",
5
- "version": "0.5.57",
5
+ "version": "0.5.59",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -70,7 +70,7 @@
70
70
  "typescript": "^5.6.0",
71
71
  "undici": "^7.28.0",
72
72
  "zod": "^4.3.6",
73
- "@volter/editor-project": "0.5.57",
73
+ "@volter/editor-project": "0.5.59",
74
74
  "@types/node": "^22.0.0"
75
75
  },
76
76
  "peerDependencies": {
package/src/client.ts CHANGED
@@ -471,6 +471,11 @@ export class EditorClient {
471
471
  await this.command({ type: 'play' });
472
472
  }
473
473
 
474
+ /** Refuse shutdown if a document cannot be saved. Does not stop the server. */
475
+ async prepareClose(): Promise<void> {
476
+ await this.command({ type: 'session-prepare-close' });
477
+ }
478
+
474
479
  /** Stops play, and finalizes this run's recording before the surface it was
475
480
  * photographing is torn down. The capture is absent when nothing recorded. */
476
481
  async stop(): Promise<{ recording?: GameplayRecordingCapture }> {
package/src/host.ts CHANGED
@@ -563,6 +563,9 @@ export interface EditorHostSession {
563
563
  * A lane that owns a worker, a socket or a device ends it here.
564
564
  */
565
565
  onEnded(fn: () => void): () => void;
566
+ /** Save before an explicit session close, while HTTP and the relay are live.
567
+ * Rejection cancels close; onEnded remains forced resource teardown. */
568
+ onBeforeClose(fn: () => Promise<void>): () => void;
566
569
  /**
567
570
  * PUBLISH (or retract, with null) THIS LANE'S OUT-OF-PROCESS WORKER METER, so
568
571
  * the tab census carries it out on the heartbeat — the one channel that still
@@ -894,13 +897,18 @@ export interface EditorHostHistoryElement {
894
897
  */
895
898
  /** The frame's own undo, for every editor affordance that is not a chord. */
896
899
  export interface EditorHostHistoryDelegate {
897
- undo(): void;
898
- redo(): void;
900
+ undo(): void | boolean | Promise<void | boolean>;
901
+ redo(): void | boolean | Promise<void | boolean>;
899
902
  canUndo(): boolean;
900
903
  canRedo(): boolean;
904
+ undoLabel?(): string | null;
905
+ redoLabel?(): string | null;
901
906
  }
902
907
 
903
908
  export interface EditorHostHistory {
909
+ /** Record a native document edit in the workbench's existing history.
910
+ * The document owns restoration; the frame owns ordering and shortcuts. */
911
+ record(element: EditorHostHistoryElement): void;
904
912
  /**
905
913
  * Install the frame's own undo as the one stack. Called once its service
906
914
  * exists, which is AFTER the editor mounts.
@@ -919,6 +927,11 @@ export interface EditorHostHistory {
919
927
  * already possible, so it pushes what it missed first, in order.
920
928
  */
921
929
  onElement(listener: (element: EditorHostHistoryElement) => void): () => void;
930
+ /** Discard history for replaced/closed native documents, never ordinary edits. */
931
+ invalidate(resources: readonly string[]): void;
932
+ onInvalidated(listener: (resources: readonly string[]) => void): () => void;
933
+ /** The workbench finished moving its own stack (including keyboard commands). */
934
+ changed(): void;
922
935
  /** Everything recorded so far, oldest first. */
923
936
  elements(): readonly EditorHostHistoryElement[];
924
937
  /**
@@ -114,6 +114,7 @@ const alwaysRefresh = (timeoutMs = DEFAULT_RELAY_COMMAND_TIMEOUT_MS): RelayComma
114
114
  * Rows without an explicit budget take {@link DEFAULT_RELAY_COMMAND_TIMEOUT_MS}.
115
115
  */
116
116
  export const RELAY_COMMANDS = {
117
+ 'session-prepare-close': noDerivedRefresh(120_000),
117
118
  // ---- Selection and framing ---------------------------------------------
118
119
  select: noDerivedRefresh(30_000),
119
120
  'select-multiple': noDerivedRefresh(),