@pixerate/editor 0.164.0 → 0.166.0

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 (146) hide show
  1. package/dist/agent/index.cjs +54 -39
  2. package/dist/agent/index.js +24 -9
  3. package/dist/animation/index.cjs +6 -5
  4. package/dist/animation/index.js +5 -4
  5. package/dist/animation-editor/index.cjs +65 -64
  6. package/dist/animation-editor/index.js +8 -7
  7. package/dist/bridge/cli.cjs +3 -3
  8. package/dist/bridge/cli.js +2 -2
  9. package/dist/bridge/index.cjs +3 -3
  10. package/dist/bridge/index.js +2 -2
  11. package/dist/canvas/index.cjs +89 -87
  12. package/dist/canvas/index.js +11 -9
  13. package/dist/chart/controller.d.cts +60 -2
  14. package/dist/chart/controller.d.ts +60 -2
  15. package/dist/chart/index.cjs +657 -163
  16. package/dist/chart/index.d.cts +3 -0
  17. package/dist/chart/index.d.ts +3 -0
  18. package/dist/chart/index.js +512 -18
  19. package/dist/chart/layout-families.d.cts +14 -0
  20. package/dist/chart/layout-families.d.ts +14 -0
  21. package/dist/chart/layout-shared.d.cts +5 -0
  22. package/dist/chart/layout-shared.d.ts +5 -0
  23. package/dist/chart/links.d.cts +34 -0
  24. package/dist/chart/links.d.ts +34 -0
  25. package/dist/chart/mermaid.d.cts +9 -6
  26. package/dist/chart/mermaid.d.ts +9 -6
  27. package/dist/chart/race.d.cts +26 -0
  28. package/dist/chart/race.d.ts +26 -0
  29. package/dist/chart/schemas.d.cts +5 -0
  30. package/dist/chart/schemas.d.ts +5 -0
  31. package/dist/chart/spec.d.cts +3 -2
  32. package/dist/chart/spec.d.ts +3 -2
  33. package/dist/chart/style.d.cts +33 -0
  34. package/dist/chart/style.d.ts +33 -0
  35. package/dist/chart/types.d.cts +28 -2
  36. package/dist/chart/types.d.ts +28 -2
  37. package/dist/{chunk-ZVNAMTFO.cjs → chunk-3FSUJIXN.cjs} +18 -174
  38. package/dist/{chunk-RQCMSEM5.cjs → chunk-4QUUHTGJ.cjs} +2 -2
  39. package/dist/{chunk-CIPIESX4.cjs → chunk-4ZC5QJE2.cjs} +3 -3
  40. package/dist/{chunk-S6X2QRVU.cjs → chunk-5UEFBM2M.cjs} +1 -138
  41. package/dist/{chunk-5FNGLV2D.js → chunk-5UNQDC3Q.js} +18 -3
  42. package/dist/{chunk-YSAGBIRW.cjs → chunk-6FYIFGBW.cjs} +16 -16
  43. package/dist/{chunk-QYZGBVNC.js → chunk-7272D3K2.js} +10 -8
  44. package/dist/{chunk-462WGGXX.cjs → chunk-AMX23CSN.cjs} +27 -16
  45. package/dist/{chunk-3VLOOO3G.js → chunk-BDIM6NVW.js} +1 -1
  46. package/dist/{chunk-R3P2M7HU.cjs → chunk-BPX4Z3N3.cjs} +355 -207
  47. package/dist/{chunk-D54JHQK2.cjs → chunk-CHLV7UFP.cjs} +51 -51
  48. package/dist/{chunk-OXERWBKE.js → chunk-DFCAR7AW.js} +3 -3
  49. package/dist/{chunk-GZ2FM3ZB.js → chunk-DKNEQX7T.js} +6 -162
  50. package/dist/{chunk-JCXMJUQO.cjs → chunk-EGZM52EO.cjs} +3 -3
  51. package/dist/{chunk-ES3UEVUT.cjs → chunk-EUIDTZNQ.cjs} +112 -110
  52. package/dist/{chunk-H3OEM3Q2.js → chunk-F6R67I3A.js} +1 -1
  53. package/dist/{chunk-3NEZJCBY.js → chunk-FR432ROA.js} +349 -201
  54. package/dist/chunk-HIDFL5LQ.js +484 -0
  55. package/dist/{chunk-22KLZZGH.cjs → chunk-HXOBOHH2.cjs} +8 -8
  56. package/dist/{chunk-MKTDELCD.js → chunk-I5MRJW7B.js} +1 -1
  57. package/dist/{chunk-SDHZG5TF.js → chunk-ILP77UD6.js} +160 -2
  58. package/dist/{chunk-Z4P2RBMJ.js → chunk-ITANXMZD.js} +177 -3
  59. package/dist/chunk-KGRZMHZB.js +204 -0
  60. package/dist/{chunk-SET6KJOP.js → chunk-LPIKXPBM.js} +1 -1
  61. package/dist/{chunk-BQWGN5WH.js → chunk-M2TPMYJE.js} +1 -1
  62. package/dist/{chunk-GTELFJRE.cjs → chunk-M5GLQQWG.cjs} +2 -2
  63. package/dist/{chunk-4VU4CP7R.js → chunk-MHLU6GRJ.js} +1 -138
  64. package/dist/{chunk-NZD2MZJC.cjs → chunk-MZFZSVUJ.cjs} +38 -23
  65. package/dist/{chunk-DAPQGA55.js → chunk-NQQDGGXY.js} +2 -2
  66. package/dist/chunk-O6OGNDND.js +164 -0
  67. package/dist/{chunk-PA3IMPPS.cjs → chunk-OVYQAYGH.cjs} +81 -81
  68. package/dist/{chunk-YXOW456B.js → chunk-PPEDZ5WR.js} +1 -1
  69. package/dist/{chunk-24M7VD6M.cjs → chunk-S4EIAIEW.cjs} +7 -7
  70. package/dist/{chunk-M4MIZPQI.cjs → chunk-SJ2CPTQC.cjs} +189 -15
  71. package/dist/{chunk-YGG7WDWT.cjs → chunk-SZWVMB3B.cjs} +24 -18
  72. package/dist/chunk-TFF2GTGN.cjs +153 -0
  73. package/dist/chunk-TTCJPX4U.cjs +204 -0
  74. package/dist/{chunk-SBQVEBSU.cjs → chunk-UUUTEVX6.cjs} +242 -68
  75. package/dist/{chunk-WI7QJA7A.cjs → chunk-UXETV2NC.cjs} +161 -3
  76. package/dist/{chunk-GKNEJ6EN.cjs → chunk-V5L2G22R.cjs} +321 -107
  77. package/dist/{chunk-TALQONZ5.js → chunk-VB2CY6EG.js} +3 -3
  78. package/dist/{chunk-QY4KUDMY.js → chunk-VRXXAXUT.js} +2 -2
  79. package/dist/chunk-VU6WQSMB.cjs +164 -0
  80. package/dist/{chunk-NHLYK3AX.js → chunk-XBQX76CT.js} +182 -8
  81. package/dist/{chunk-5AARIS3R.cjs → chunk-XCDGM7TD.cjs} +37 -37
  82. package/dist/{chunk-POR54B55.js → chunk-XNU45TYA.js} +7 -1
  83. package/dist/{chunk-EVXQNQND.js → chunk-XZB3TJ6K.js} +16 -5
  84. package/dist/chunk-YBAPT7NL.js +153 -0
  85. package/dist/{chunk-SZA42R4N.js → chunk-YUFTVNLX.js} +230 -16
  86. package/dist/chunk-Z2UQYMPS.cjs +484 -0
  87. package/dist/color/index.cjs +5 -3
  88. package/dist/color/index.js +12 -10
  89. package/dist/diagram/index.cjs +55 -243
  90. package/dist/diagram/index.js +12 -200
  91. package/dist/export/index.cjs +7 -6
  92. package/dist/export/index.js +6 -5
  93. package/dist/extensions/index.cjs +12 -9
  94. package/dist/extensions/index.js +11 -8
  95. package/dist/gradient/index.cjs +29 -27
  96. package/dist/gradient/index.js +6 -4
  97. package/dist/image-editor/index.cjs +644 -643
  98. package/dist/image-editor/index.js +7 -6
  99. package/dist/index.cjs +21 -18
  100. package/dist/index.js +14 -11
  101. package/dist/paint-editor/index.cjs +19 -18
  102. package/dist/paint-editor/index.js +7 -6
  103. package/dist/parameters/index.cjs +2 -2
  104. package/dist/parameters/index.js +1 -1
  105. package/dist/persistence/assetWrites.d.cts +22 -0
  106. package/dist/persistence/assetWrites.d.ts +22 -0
  107. package/dist/persistence/assets.d.cts +71 -0
  108. package/dist/persistence/assets.d.ts +71 -0
  109. package/dist/persistence/documentStore.d.cts +17 -1
  110. package/dist/persistence/documentStore.d.ts +17 -1
  111. package/dist/persistence/documentTools.d.cts +5 -1
  112. package/dist/persistence/documentTools.d.ts +5 -1
  113. package/dist/persistence/editorAutosave.d.cts +7 -0
  114. package/dist/persistence/editorAutosave.d.ts +7 -0
  115. package/dist/persistence/index.cjs +141 -21
  116. package/dist/persistence/index.js +130 -10
  117. package/dist/persistence/storage.d.cts +13 -1
  118. package/dist/persistence/storage.d.ts +13 -1
  119. package/dist/spreadsheet/index.cjs +3 -3
  120. package/dist/spreadsheet/index.js +2 -2
  121. package/dist/tokens/index.cjs +11 -3
  122. package/dist/tokens/index.d.cts +1 -0
  123. package/dist/tokens/index.d.ts +1 -0
  124. package/dist/tokens/index.js +10 -2
  125. package/dist/tokens/style.d.cts +36 -0
  126. package/dist/tokens/style.d.ts +36 -0
  127. package/dist/tools/index.cjs +15 -3
  128. package/dist/tools/index.d.cts +2 -0
  129. package/dist/tools/index.d.ts +2 -0
  130. package/dist/tools/index.js +14 -2
  131. package/dist/tools/style-tools.d.cts +19 -0
  132. package/dist/tools/style-tools.d.ts +19 -0
  133. package/dist/tools/style.d.cts +212 -0
  134. package/dist/tools/style.d.ts +212 -0
  135. package/dist/tools/view.d.cts +6 -0
  136. package/dist/tools/view.d.ts +6 -0
  137. package/dist/typography/index.cjs +8 -6
  138. package/dist/typography/index.js +5 -3
  139. package/dist/vector/index.cjs +953 -952
  140. package/dist/vector/index.js +7 -6
  141. package/dist/video-editor/index.cjs +8 -7
  142. package/dist/video-editor/index.js +6 -5
  143. package/package.json +1 -1
  144. package/skills/pixerate-chart/SKILL.md +20 -2
  145. package/dist/chunk-ERAGQL2N.cjs +0 -68
  146. package/dist/chunk-KMU6QJB7.js +0 -68
@@ -7,7 +7,7 @@ import {
7
7
  resolveExternalAssets,
8
8
  serializeLayers,
9
9
  serializeLayersExternal
10
- } from "../chunk-3VLOOO3G.js";
10
+ } from "../chunk-BDIM6NVW.js";
11
11
  import "../chunk-3CI7FRMK.js";
12
12
  import {
13
13
  EffectRendererPool
@@ -54,7 +54,7 @@ import {
54
54
  realPresenceClock,
55
55
  tweenPresenceCursor
56
56
  } from "../chunk-O2ANJFUF.js";
57
- import "../chunk-SET6KJOP.js";
57
+ import "../chunk-LPIKXPBM.js";
58
58
  import {
59
59
  BRUSH_ID,
60
60
  BRUSH_ROTATIONS,
@@ -227,17 +227,18 @@ import "../chunk-VDGBHYC7.js";
227
227
  import {
228
228
  createEditorAssetRegistry,
229
229
  defineEditorDocument
230
- } from "../chunk-NHLYK3AX.js";
230
+ } from "../chunk-XBQX76CT.js";
231
231
  import "../chunk-HF5QZS7Z.js";
232
- import "../chunk-BQWGN5WH.js";
232
+ import "../chunk-M2TPMYJE.js";
233
233
  import "../chunk-2WPNAGHI.js";
234
234
  import {
235
235
  HARMONY_KINDS,
236
236
  colorHarmony,
237
237
  hueToWheel,
238
238
  wheelToHue
239
- } from "../chunk-QYZGBVNC.js";
240
- import "../chunk-4VU4CP7R.js";
239
+ } from "../chunk-7272D3K2.js";
240
+ import "../chunk-YBAPT7NL.js";
241
+ import "../chunk-MHLU6GRJ.js";
241
242
  import "../chunk-6ONMQ6WF.js";
242
243
 
243
244
  // src/paint-editor/document.ts
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class;
2
2
 
3
- var _chunkM4MIZPQIcjs = require('../chunk-M4MIZPQI.cjs');
3
+ var _chunkSJ2CPTQCcjs = require('../chunk-SJ2CPTQC.cjs');
4
4
  require('../chunk-2BSBFBOA.cjs');
5
5
 
6
6
 
@@ -1327,7 +1327,7 @@ function mapRange(value, from, to, options) {
1327
1327
  // src/parameters/editorDocument.ts
1328
1328
  var isRecord = (value) => !!value && typeof value === "object" && !Array.isArray(value);
1329
1329
  function createParametersEditorDocument(controller) {
1330
- return _chunkM4MIZPQIcjs.defineEditorDocument.call(void 0, {
1330
+ return _chunkSJ2CPTQCcjs.defineEditorDocument.call(void 0, {
1331
1331
  kind: "parameters",
1332
1332
  get: () => controller.toJSON(),
1333
1333
  load: (document, { history }) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  defineEditorDocument
3
- } from "../chunk-NHLYK3AX.js";
3
+ } from "../chunk-XBQX76CT.js";
4
4
  import "../chunk-HF5QZS7Z.js";
5
5
  import {
6
6
  HistoryManager
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Coordination between asset writes and asset garbage collection (internal: not exported from
3
+ * the package). Collection must never delete an asset that a write in flight is about to point a
4
+ * document at, so:
5
+ *
6
+ * - every write that persists assets leases their references until its document is written, and
7
+ * a running collection skips leased references and references leased while it runs;
8
+ * - where the Web Locks API exists, writes hold a shared lock and collection an exclusive one,
9
+ * which extends the same guarantee to other tabs on the same origin.
10
+ */
11
+ /** Marks `refs` as about to be referenced by a document write; call the result when it is written. */
12
+ export declare function leaseAssetRefs(refs: Iterable<string>): () => void;
13
+ /**
14
+ * Starts recording references that are, or become, leased. `touched` holds every reference
15
+ * leased now or at any time until `stop()`.
16
+ */
17
+ export declare function watchAssetLeases(): {
18
+ touched: Set<string>;
19
+ stop(): void;
20
+ };
21
+ /** Runs `task` under the cross-tab asset lock for `prefix` when the Web Locks API exists. */
22
+ export declare function withAssetLock<T>(prefix: string, mode: "shared" | "exclusive", task: () => Promise<T>): Promise<T>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Coordination between asset writes and asset garbage collection (internal: not exported from
3
+ * the package). Collection must never delete an asset that a write in flight is about to point a
4
+ * document at, so:
5
+ *
6
+ * - every write that persists assets leases their references until its document is written, and
7
+ * a running collection skips leased references and references leased while it runs;
8
+ * - where the Web Locks API exists, writes hold a shared lock and collection an exclusive one,
9
+ * which extends the same guarantee to other tabs on the same origin.
10
+ */
11
+ /** Marks `refs` as about to be referenced by a document write; call the result when it is written. */
12
+ export declare function leaseAssetRefs(refs: Iterable<string>): () => void;
13
+ /**
14
+ * Starts recording references that are, or become, leased. `touched` holds every reference
15
+ * leased now or at any time until `stop()`.
16
+ */
17
+ export declare function watchAssetLeases(): {
18
+ touched: Set<string>;
19
+ stop(): void;
20
+ };
21
+ /** Runs `task` under the cross-tab asset lock for `prefix` when the Web Locks API exists. */
22
+ export declare function withAssetLock<T>(prefix: string, mode: "shared" | "exclusive", task: () => Promise<T>): Promise<T>;
@@ -17,6 +17,11 @@ export interface EditorAssetRegistry {
17
17
  /** Puts data read back from storage under its reference. */
18
18
  set(ref: string, data: string): void;
19
19
  readonly size: number;
20
+ /**
21
+ * Every reference the registry holds. Optional for custom registries, but
22
+ * `collectEditorAssetGarbage({ keep })` needs it to protect a registry's assets.
23
+ */
24
+ refs?(): string[];
20
25
  }
21
26
  /** Whether a string is inline binary data worth keeping out of the document. */
22
27
  export declare function isInlineAsset(value: string): boolean;
@@ -49,3 +54,69 @@ export declare function preloadEditorAssets(storage: StorageAdapter, registry: E
49
54
  * document store uses for an editor whose document has `assets`.
50
55
  */
51
56
  export declare function withEditorAssets(storage: StorageAdapter, registry: EditorAssetRegistry, options?: EditorAssetStorageOptions): StorageAdapter;
57
+ export interface EditorAssetGarbageOptions extends EditorAssetStorageOptions {
58
+ /**
59
+ * More assets to keep although no stored value refers to them: asset registries (e.g. an open
60
+ * editor's `doc.assets`), editor documents with `assets`, asset references, or documents /
61
+ * JSON text whose references to keep.
62
+ */
63
+ keep?: ReadonlyArray<unknown>;
64
+ /** Report what would be deleted without deleting anything (default `false`). */
65
+ dryRun?: boolean;
66
+ /**
67
+ * Delete only these references (e.g. from a dry run). Every one must still be unreferenced,
68
+ * or nothing is deleted and the call throws naming them.
69
+ */
70
+ only?: ReadonlyArray<string>;
71
+ }
72
+ export interface EditorAssetGarbageReport {
73
+ /** Assets found in storage. */
74
+ assets: number;
75
+ /** Stored values read for references (documents, the index, autosave snapshots, anything else). */
76
+ scannedKeys: number;
77
+ /** Assets a stored value refers to. */
78
+ referenced: number;
79
+ /** Unreferenced assets kept because of `keep` or a write in flight. */
80
+ kept: number;
81
+ /** References of the assets nothing refers to (limited by `only`); deleted unless `dryRun`. */
82
+ unreferenced: string[];
83
+ /** Characters of data the unreferenced assets hold. */
84
+ unreferencedChars: number;
85
+ /** References deleted (empty on a dry run). */
86
+ removed: string[];
87
+ /** Characters of data deleted. */
88
+ freedChars: number;
89
+ dryRun: boolean;
90
+ }
91
+ /**
92
+ * Deletes the stored assets that nothing refers to. Every other value in `storage` (named
93
+ * documents, the document index, autosave snapshots, anything else) is read and its
94
+ * `pixerate-asset:` references are kept, so pass the whole storage the editors write to (a
95
+ * `withEditorAssets` wrapper works too, but reads assets into its registry). Assets in `keep`,
96
+ * and assets a write in flight in this realm is about to refer to, are never deleted; where the
97
+ * Web Locks API exists, writes in other tabs are waited for too. Needs `storage.keys` (every
98
+ * built-in adapter has it) and throws without it.
99
+ *
100
+ * Run it after removing documents, after an autosave snapshot was retired (`markClean`), or on
101
+ * demand. Deleting an asset that an open editor's registry still holds is safe: the collection
102
+ * invalidates every session's "already written" cache, so its next save writes the asset again.
103
+ */
104
+ export declare function collectEditorAssetGarbage(storage: StorageAdapter, options?: EditorAssetGarbageOptions): Promise<EditorAssetGarbageReport>;
105
+ /**
106
+ * `collectEditorAssetGarbage` for automatic, best-effort runs: resolves `null` instead of
107
+ * throwing when the storage cannot list keys or the collection fails.
108
+ */
109
+ export declare function tryCollectEditorAssetGarbage(storage: StorageAdapter, options?: EditorAssetGarbageOptions): Promise<EditorAssetGarbageReport | null>;
110
+ /**
111
+ * The collection an editor autosave runs after retiring a snapshot (`markClean`, `discard`):
112
+ * best effort, keeping the assets `doc` uses now, and only for documents with `assets`.
113
+ * `setting` is the autosave's `collectAssetGarbage` option (default on). Pass the unwrapped storage.
114
+ *
115
+ * Not the whole registry: a recovery check reads the old snapshot's assets into it, so keeping
116
+ * it would keep exactly what `discard` throws away. Assets only the registry (e.g. undo) still
117
+ * holds are written again by the next save.
118
+ */
119
+ export declare function collectRetiredEditorAssets(storage: StorageAdapter, doc: {
120
+ assets?: EditorAssetRegistry;
121
+ getDocument(): unknown;
122
+ }, setting?: boolean | Omit<EditorAssetGarbageOptions, "dryRun" | "only">): Promise<EditorAssetGarbageReport | null>;
@@ -17,6 +17,11 @@ export interface EditorAssetRegistry {
17
17
  /** Puts data read back from storage under its reference. */
18
18
  set(ref: string, data: string): void;
19
19
  readonly size: number;
20
+ /**
21
+ * Every reference the registry holds. Optional for custom registries, but
22
+ * `collectEditorAssetGarbage({ keep })` needs it to protect a registry's assets.
23
+ */
24
+ refs?(): string[];
20
25
  }
21
26
  /** Whether a string is inline binary data worth keeping out of the document. */
22
27
  export declare function isInlineAsset(value: string): boolean;
@@ -49,3 +54,69 @@ export declare function preloadEditorAssets(storage: StorageAdapter, registry: E
49
54
  * document store uses for an editor whose document has `assets`.
50
55
  */
51
56
  export declare function withEditorAssets(storage: StorageAdapter, registry: EditorAssetRegistry, options?: EditorAssetStorageOptions): StorageAdapter;
57
+ export interface EditorAssetGarbageOptions extends EditorAssetStorageOptions {
58
+ /**
59
+ * More assets to keep although no stored value refers to them: asset registries (e.g. an open
60
+ * editor's `doc.assets`), editor documents with `assets`, asset references, or documents /
61
+ * JSON text whose references to keep.
62
+ */
63
+ keep?: ReadonlyArray<unknown>;
64
+ /** Report what would be deleted without deleting anything (default `false`). */
65
+ dryRun?: boolean;
66
+ /**
67
+ * Delete only these references (e.g. from a dry run). Every one must still be unreferenced,
68
+ * or nothing is deleted and the call throws naming them.
69
+ */
70
+ only?: ReadonlyArray<string>;
71
+ }
72
+ export interface EditorAssetGarbageReport {
73
+ /** Assets found in storage. */
74
+ assets: number;
75
+ /** Stored values read for references (documents, the index, autosave snapshots, anything else). */
76
+ scannedKeys: number;
77
+ /** Assets a stored value refers to. */
78
+ referenced: number;
79
+ /** Unreferenced assets kept because of `keep` or a write in flight. */
80
+ kept: number;
81
+ /** References of the assets nothing refers to (limited by `only`); deleted unless `dryRun`. */
82
+ unreferenced: string[];
83
+ /** Characters of data the unreferenced assets hold. */
84
+ unreferencedChars: number;
85
+ /** References deleted (empty on a dry run). */
86
+ removed: string[];
87
+ /** Characters of data deleted. */
88
+ freedChars: number;
89
+ dryRun: boolean;
90
+ }
91
+ /**
92
+ * Deletes the stored assets that nothing refers to. Every other value in `storage` (named
93
+ * documents, the document index, autosave snapshots, anything else) is read and its
94
+ * `pixerate-asset:` references are kept, so pass the whole storage the editors write to (a
95
+ * `withEditorAssets` wrapper works too, but reads assets into its registry). Assets in `keep`,
96
+ * and assets a write in flight in this realm is about to refer to, are never deleted; where the
97
+ * Web Locks API exists, writes in other tabs are waited for too. Needs `storage.keys` (every
98
+ * built-in adapter has it) and throws without it.
99
+ *
100
+ * Run it after removing documents, after an autosave snapshot was retired (`markClean`), or on
101
+ * demand. Deleting an asset that an open editor's registry still holds is safe: the collection
102
+ * invalidates every session's "already written" cache, so its next save writes the asset again.
103
+ */
104
+ export declare function collectEditorAssetGarbage(storage: StorageAdapter, options?: EditorAssetGarbageOptions): Promise<EditorAssetGarbageReport>;
105
+ /**
106
+ * `collectEditorAssetGarbage` for automatic, best-effort runs: resolves `null` instead of
107
+ * throwing when the storage cannot list keys or the collection fails.
108
+ */
109
+ export declare function tryCollectEditorAssetGarbage(storage: StorageAdapter, options?: EditorAssetGarbageOptions): Promise<EditorAssetGarbageReport | null>;
110
+ /**
111
+ * The collection an editor autosave runs after retiring a snapshot (`markClean`, `discard`):
112
+ * best effort, keeping the assets `doc` uses now, and only for documents with `assets`.
113
+ * `setting` is the autosave's `collectAssetGarbage` option (default on). Pass the unwrapped storage.
114
+ *
115
+ * Not the whole registry: a recovery check reads the old snapshot's assets into it, so keeping
116
+ * it would keep exactly what `discard` throws away. Assets only the registry (e.g. undo) still
117
+ * holds are written again by the next save.
118
+ */
119
+ export declare function collectRetiredEditorAssets(storage: StorageAdapter, doc: {
120
+ assets?: EditorAssetRegistry;
121
+ getDocument(): unknown;
122
+ }, setting?: boolean | Omit<EditorAssetGarbageOptions, "dryRun" | "only">): Promise<EditorAssetGarbageReport | null>;
@@ -1,4 +1,5 @@
1
1
  import { type EditorDocument, type EditorDocumentFile } from "./editorDocument.cjs";
2
+ import { type EditorAssetGarbageOptions, type EditorAssetGarbageReport } from "./assets.cjs";
2
3
  import type { LoadReport } from "./migrate.cjs";
3
4
  import type { StorageAdapter } from "./storage.cjs";
4
5
  /** One saved document as the index lists it (no document read needed). */
@@ -17,6 +18,12 @@ export interface EditorDocumentStoreOptions {
17
18
  namespace?: string;
18
19
  /** Wall clock for `savedAt` (default `Date.now`). */
19
20
  now?: () => number;
21
+ /**
22
+ * After `remove`, delete the stored assets nothing refers to any more
23
+ * (`collectEditorAssetGarbage`, best effort; default `true`). Needs `storage.keys`; pass
24
+ * options (e.g. `keep` with open editors' registries) or `false` to turn it off.
25
+ */
26
+ collectAssetGarbage?: boolean | Omit<EditorAssetGarbageOptions, "dryRun" | "only">;
20
27
  }
21
28
  export interface EditorDocumentStore {
22
29
  /**
@@ -37,8 +44,17 @@ export interface EditorDocumentStore {
37
44
  }): Promise<SavedEditorDocument & {
38
45
  report: LoadReport;
39
46
  }>;
40
- /** Deletes a saved document; `false` when there was none. */
47
+ /**
48
+ * Deletes a saved document; `false` when there was none. Then deletes the assets nothing
49
+ * refers to any more, unless `collectAssetGarbage: false`.
50
+ */
41
51
  remove(key: string): Promise<boolean>;
52
+ /**
53
+ * Deletes (or with `dryRun`, finds) the stored assets nothing refers to, queued after the
54
+ * store's other operations (see `collectEditorAssetGarbage`). Only present when the storage
55
+ * can list its keys.
56
+ */
57
+ collectAssetGarbage?(options?: EditorAssetGarbageOptions): Promise<EditorAssetGarbageReport>;
42
58
  }
43
59
  /** `"Release flow v2"` → `"release-flow-v2"` (the key part of a saved name). */
44
60
  export declare function slugifyDocumentName(name: string): string;
@@ -1,4 +1,5 @@
1
1
  import { type EditorDocument, type EditorDocumentFile } from "./editorDocument.js";
2
+ import { type EditorAssetGarbageOptions, type EditorAssetGarbageReport } from "./assets.js";
2
3
  import type { LoadReport } from "./migrate.js";
3
4
  import type { StorageAdapter } from "./storage.js";
4
5
  /** One saved document as the index lists it (no document read needed). */
@@ -17,6 +18,12 @@ export interface EditorDocumentStoreOptions {
17
18
  namespace?: string;
18
19
  /** Wall clock for `savedAt` (default `Date.now`). */
19
20
  now?: () => number;
21
+ /**
22
+ * After `remove`, delete the stored assets nothing refers to any more
23
+ * (`collectEditorAssetGarbage`, best effort; default `true`). Needs `storage.keys`; pass
24
+ * options (e.g. `keep` with open editors' registries) or `false` to turn it off.
25
+ */
26
+ collectAssetGarbage?: boolean | Omit<EditorAssetGarbageOptions, "dryRun" | "only">;
20
27
  }
21
28
  export interface EditorDocumentStore {
22
29
  /**
@@ -37,8 +44,17 @@ export interface EditorDocumentStore {
37
44
  }): Promise<SavedEditorDocument & {
38
45
  report: LoadReport;
39
46
  }>;
40
- /** Deletes a saved document; `false` when there was none. */
47
+ /**
48
+ * Deletes a saved document; `false` when there was none. Then deletes the assets nothing
49
+ * refers to any more, unless `collectAssetGarbage: false`.
50
+ */
41
51
  remove(key: string): Promise<boolean>;
52
+ /**
53
+ * Deletes (or with `dryRun`, finds) the stored assets nothing refers to, queued after the
54
+ * store's other operations (see `collectEditorAssetGarbage`). Only present when the storage
55
+ * can list its keys.
56
+ */
57
+ collectAssetGarbage?(options?: EditorAssetGarbageOptions): Promise<EditorAssetGarbageReport>;
42
58
  }
43
59
  /** `"Release flow v2"` → `"release-flow-v2"` (the key part of a saved name). */
44
60
  export declare function slugifyDocumentName(name: string): string;
@@ -17,7 +17,11 @@ export interface DocumentToolProviderOptions {
17
17
  * whose own provider already has them.
18
18
  */
19
19
  history?: boolean;
20
- /** Saved documents: adds `save_<kind>_document`, `list_saved_<kind>_documents` and `open_saved_<kind>_document`. */
20
+ /**
21
+ * Saved documents: adds `save_<kind>_document`, `list_saved_<kind>_documents` and `open_saved_<kind>_document`.
22
+ * For documents with `assets` (image, paint) on a storage that lists keys, also
23
+ * `find_unreferenced_<kind>_assets` and `delete_unreferenced_<kind>_assets`.
24
+ */
21
25
  store?: EditorDocumentStore;
22
26
  /** Name `save_<kind>_document` uses when none is given (default "Untitled <noun>"). */
23
27
  name?: () => string | undefined;
@@ -17,7 +17,11 @@ export interface DocumentToolProviderOptions {
17
17
  * whose own provider already has them.
18
18
  */
19
19
  history?: boolean;
20
- /** Saved documents: adds `save_<kind>_document`, `list_saved_<kind>_documents` and `open_saved_<kind>_document`. */
20
+ /**
21
+ * Saved documents: adds `save_<kind>_document`, `list_saved_<kind>_documents` and `open_saved_<kind>_document`.
22
+ * For documents with `assets` (image, paint) on a storage that lists keys, also
23
+ * `find_unreferenced_<kind>_assets` and `delete_unreferenced_<kind>_assets`.
24
+ */
21
25
  store?: EditorDocumentStore;
22
26
  /** Name `save_<kind>_document` uses when none is given (default "Untitled <noun>"). */
23
27
  name?: () => string | undefined;
@@ -1,5 +1,6 @@
1
1
  import { type AutosaveController, type AutosaveControllerOptions, type AutosaveRecovery } from "./autosave.cjs";
2
2
  import { type EditorDocument, type EditorDocumentFile } from "./editorDocument.cjs";
3
+ import { type EditorAssetGarbageOptions } from "./assets.cjs";
3
4
  import type { LoadReport } from "./migrate.cjs";
4
5
  import { type DirtyFlagSource, type RevisionTracker } from "./revisions.cjs";
5
6
  export interface EditorAutosaveOptions extends Omit<AutosaveControllerOptions<EditorDocumentFile>, "getSnapshot" | "serialize" | "deserialize" | "revision" | "savedRevision" | "key"> {
@@ -10,6 +11,12 @@ export interface EditorAutosaveOptions extends Omit<AutosaveControllerOptions<Ed
10
11
  * saved state needs no snapshot. Without it, every change counts until `markClean()`.
11
12
  */
12
13
  dirty?: DirtyFlagSource;
14
+ /**
15
+ * For documents with `assets`: after `markClean` or `discard` retire a snapshot, delete the
16
+ * stored assets nothing refers to any more (`collectEditorAssetGarbage`, best effort, keeping
17
+ * the assets the document uses now; default `true`). Needs `storage.keys`; `false` turns it off.
18
+ */
19
+ collectAssetGarbage?: boolean | Omit<EditorAssetGarbageOptions, "dryRun" | "only">;
13
20
  }
14
21
  export interface EditorAutosave {
15
22
  readonly controller: AutosaveController<EditorDocumentFile>;
@@ -1,5 +1,6 @@
1
1
  import { type AutosaveController, type AutosaveControllerOptions, type AutosaveRecovery } from "./autosave.js";
2
2
  import { type EditorDocument, type EditorDocumentFile } from "./editorDocument.js";
3
+ import { type EditorAssetGarbageOptions } from "./assets.js";
3
4
  import type { LoadReport } from "./migrate.js";
4
5
  import { type DirtyFlagSource, type RevisionTracker } from "./revisions.js";
5
6
  export interface EditorAutosaveOptions extends Omit<AutosaveControllerOptions<EditorDocumentFile>, "getSnapshot" | "serialize" | "deserialize" | "revision" | "savedRevision" | "key"> {
@@ -10,6 +11,12 @@ export interface EditorAutosaveOptions extends Omit<AutosaveControllerOptions<Ed
10
11
  * saved state needs no snapshot. Without it, every change counts until `markClean()`.
11
12
  */
12
13
  dirty?: DirtyFlagSource;
14
+ /**
15
+ * For documents with `assets`: after `markClean` or `discard` retire a snapshot, delete the
16
+ * stored assets nothing refers to any more (`collectEditorAssetGarbage`, best effort, keeping
17
+ * the assets the document uses now; default `true`). Needs `storage.keys`; `false` turns it off.
18
+ */
19
+ collectAssetGarbage?: boolean | Omit<EditorAssetGarbageOptions, "dryRun" | "only">;
13
20
  }
14
21
  export interface EditorAutosave {
15
22
  readonly controller: AutosaveController<EditorDocumentFile>;