@pixerate/editor 0.163.0 → 0.165.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.
- package/dist/agent/index.cjs +54 -39
- package/dist/agent/index.js +24 -9
- package/dist/animation/index.cjs +6 -5
- package/dist/animation/index.js +5 -4
- package/dist/animation-editor/index.cjs +65 -64
- package/dist/animation-editor/index.js +8 -7
- package/dist/bridge/cli.cjs +3 -3
- package/dist/bridge/cli.js +2 -2
- package/dist/bridge/index.cjs +3 -3
- package/dist/bridge/index.js +2 -2
- package/dist/canvas/displacement.d.cts +34 -2
- package/dist/canvas/displacement.d.ts +34 -2
- package/dist/canvas/explosion-tools.d.cts +43 -0
- package/dist/canvas/explosion-tools.d.ts +43 -0
- package/dist/canvas/explosionLayout.d.cts +50 -0
- package/dist/canvas/explosionLayout.d.ts +50 -0
- package/dist/canvas/explosionState.d.cts +52 -0
- package/dist/canvas/explosionState.d.ts +52 -0
- package/dist/canvas/index.cjs +512 -168
- package/dist/canvas/index.d.cts +3 -0
- package/dist/canvas/index.d.ts +3 -0
- package/dist/canvas/index.js +434 -90
- package/dist/canvas/types.d.cts +27 -2
- package/dist/canvas/types.d.ts +27 -2
- package/dist/chart/controller.d.cts +31 -2
- package/dist/chart/controller.d.ts +31 -2
- package/dist/chart/index.cjs +504 -132
- package/dist/chart/index.d.cts +2 -0
- package/dist/chart/index.d.ts +2 -0
- package/dist/chart/index.js +386 -14
- package/dist/chart/layout-families.d.cts +7 -0
- package/dist/chart/layout-families.d.ts +7 -0
- package/dist/chart/links.d.cts +34 -0
- package/dist/chart/links.d.ts +34 -0
- package/dist/chart/mermaid.d.cts +9 -6
- package/dist/chart/mermaid.d.ts +9 -6
- package/dist/chart/schemas.d.cts +3 -0
- package/dist/chart/schemas.d.ts +3 -0
- package/dist/chart/spec.d.cts +3 -2
- package/dist/chart/spec.d.ts +3 -2
- package/dist/chart/style.d.cts +33 -0
- package/dist/chart/style.d.ts +33 -0
- package/dist/chart/types.d.cts +24 -2
- package/dist/chart/types.d.ts +24 -2
- package/dist/{chunk-TALQONZ5.js → chunk-2J5VLJHC.js} +3 -3
- package/dist/{chunk-3NEZJCBY.js → chunk-2ZRN43IN.js} +340 -201
- package/dist/{chunk-ZVNAMTFO.cjs → chunk-3FSUJIXN.cjs} +18 -174
- package/dist/{chunk-RQCMSEM5.cjs → chunk-4QUUHTGJ.cjs} +2 -2
- package/dist/{chunk-CIPIESX4.cjs → chunk-4ZC5QJE2.cjs} +3 -3
- package/dist/{chunk-S6X2QRVU.cjs → chunk-5UEFBM2M.cjs} +1 -138
- package/dist/{chunk-YSAGBIRW.cjs → chunk-64VWWR5U.cjs} +16 -16
- package/dist/{chunk-QYZGBVNC.js → chunk-7272D3K2.js} +10 -8
- package/dist/{chunk-462WGGXX.cjs → chunk-AMX23CSN.cjs} +27 -16
- package/dist/{chunk-3VLOOO3G.js → chunk-BDIM6NVW.js} +1 -1
- package/dist/{chunk-POR54B55.js → chunk-CRFSQWKQ.js} +4 -1
- package/dist/{chunk-GZ2FM3ZB.js → chunk-DKNEQX7T.js} +6 -162
- package/dist/{chunk-JCXMJUQO.cjs → chunk-EGZM52EO.cjs} +3 -3
- package/dist/{chunk-ES3UEVUT.cjs → chunk-EUIDTZNQ.cjs} +112 -110
- package/dist/{chunk-H3OEM3Q2.js → chunk-F6R67I3A.js} +1 -1
- package/dist/{chunk-5FNGLV2D.js → chunk-FEU2XVQH.js} +15 -3
- package/dist/{chunk-SZA42R4N.js → chunk-FRBRLKNQ.js} +154 -16
- package/dist/chunk-HIDFL5LQ.js +484 -0
- package/dist/{chunk-MKTDELCD.js → chunk-I5MRJW7B.js} +1 -1
- package/dist/{chunk-SDHZG5TF.js → chunk-ILP77UD6.js} +160 -2
- package/dist/{chunk-GKNEJ6EN.cjs → chunk-IMRXC7OA.cjs} +241 -103
- package/dist/chunk-KGRZMHZB.js +204 -0
- package/dist/{chunk-SET6KJOP.js → chunk-LPIKXPBM.js} +1 -1
- package/dist/{chunk-BQWGN5WH.js → chunk-M2TPMYJE.js} +1 -1
- package/dist/{chunk-GTELFJRE.cjs → chunk-M5GLQQWG.cjs} +2 -2
- package/dist/{chunk-4VU4CP7R.js → chunk-MHLU6GRJ.js} +1 -138
- package/dist/{chunk-D54JHQK2.cjs → chunk-MKXK6E4O.cjs} +51 -51
- package/dist/{chunk-DAPQGA55.js → chunk-N7NBGT2Y.js} +2 -2
- package/dist/chunk-O6OGNDND.js +164 -0
- package/dist/{chunk-22KLZZGH.cjs → chunk-ODFCS7HF.cjs} +8 -8
- package/dist/{chunk-PA3IMPPS.cjs → chunk-OVYQAYGH.cjs} +81 -81
- package/dist/{chunk-YXOW456B.js → chunk-PPEDZ5WR.js} +1 -1
- package/dist/{chunk-YGG7WDWT.cjs → chunk-Q25WAFTD.cjs} +21 -18
- package/dist/{chunk-SBQVEBSU.cjs → chunk-QO2T6KA5.cjs} +165 -67
- package/dist/{chunk-24M7VD6M.cjs → chunk-S4EIAIEW.cjs} +7 -7
- package/dist/{chunk-M4MIZPQI.cjs → chunk-SJ2CPTQC.cjs} +189 -15
- package/dist/chunk-TFF2GTGN.cjs +153 -0
- package/dist/chunk-TTCJPX4U.cjs +204 -0
- package/dist/{chunk-NZD2MZJC.cjs → chunk-TVQW26AV.cjs} +35 -23
- package/dist/{chunk-R3P2M7HU.cjs → chunk-UVXTOZ2B.cjs} +346 -207
- package/dist/{chunk-WI7QJA7A.cjs → chunk-UXETV2NC.cjs} +161 -3
- package/dist/{chunk-Z4P2RBMJ.js → chunk-V5GSY3NC.js} +101 -3
- package/dist/{chunk-QY4KUDMY.js → chunk-VRXXAXUT.js} +2 -2
- package/dist/chunk-VU6WQSMB.cjs +164 -0
- package/dist/{chunk-OXERWBKE.js → chunk-X5W645RI.js} +3 -3
- package/dist/{chunk-NHLYK3AX.js → chunk-XBQX76CT.js} +182 -8
- package/dist/{chunk-5AARIS3R.cjs → chunk-XCDGM7TD.cjs} +37 -37
- package/dist/{chunk-EVXQNQND.js → chunk-XZB3TJ6K.js} +16 -5
- package/dist/chunk-YBAPT7NL.js +153 -0
- package/dist/chunk-Z2UQYMPS.cjs +484 -0
- package/dist/color/index.cjs +5 -3
- package/dist/color/index.js +12 -10
- package/dist/diagram/index.cjs +55 -243
- package/dist/diagram/index.js +12 -200
- package/dist/export/index.cjs +7 -6
- package/dist/export/index.js +6 -5
- package/dist/extensions/index.cjs +12 -9
- package/dist/extensions/index.js +11 -8
- package/dist/gradient/index.cjs +29 -27
- package/dist/gradient/index.js +6 -4
- package/dist/image-editor/index.cjs +644 -643
- package/dist/image-editor/index.js +7 -6
- package/dist/index.cjs +21 -18
- package/dist/index.js +14 -11
- package/dist/paint-editor/index.cjs +19 -18
- package/dist/paint-editor/index.js +7 -6
- package/dist/parameters/index.cjs +2 -2
- package/dist/parameters/index.js +1 -1
- package/dist/persistence/assetWrites.d.cts +22 -0
- package/dist/persistence/assetWrites.d.ts +22 -0
- package/dist/persistence/assets.d.cts +71 -0
- package/dist/persistence/assets.d.ts +71 -0
- package/dist/persistence/documentStore.d.cts +17 -1
- package/dist/persistence/documentStore.d.ts +17 -1
- package/dist/persistence/documentTools.d.cts +5 -1
- package/dist/persistence/documentTools.d.ts +5 -1
- package/dist/persistence/editorAutosave.d.cts +7 -0
- package/dist/persistence/editorAutosave.d.ts +7 -0
- package/dist/persistence/index.cjs +141 -21
- package/dist/persistence/index.js +130 -10
- package/dist/persistence/storage.d.cts +13 -1
- package/dist/persistence/storage.d.ts +13 -1
- package/dist/spreadsheet/index.cjs +3 -3
- package/dist/spreadsheet/index.js +2 -2
- package/dist/tokens/index.cjs +11 -3
- package/dist/tokens/index.d.cts +1 -0
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.js +10 -2
- package/dist/tokens/style.d.cts +36 -0
- package/dist/tokens/style.d.ts +36 -0
- package/dist/tools/index.cjs +15 -3
- package/dist/tools/index.d.cts +2 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +14 -2
- package/dist/tools/style-tools.d.cts +19 -0
- package/dist/tools/style-tools.d.ts +19 -0
- package/dist/tools/style.d.cts +212 -0
- package/dist/tools/style.d.ts +212 -0
- package/dist/tools/view.d.cts +6 -0
- package/dist/tools/view.d.ts +6 -0
- package/dist/typography/index.cjs +8 -6
- package/dist/typography/index.js +5 -3
- package/dist/vector/index.cjs +953 -952
- package/dist/vector/index.js +7 -6
- package/dist/video-editor/index.cjs +8 -7
- package/dist/video-editor/index.js +6 -5
- package/package.json +1 -1
- package/skills/README.md +12 -0
- package/skills/pixerate-agent-tools/SKILL.md +34 -1
- package/skills/pixerate-chart/SKILL.md +41 -9
- package/skills/pixerate-image-editor/SKILL.md +2 -0
- package/skills/pixerate-paint-editor/SKILL.md +2 -0
- package/skills/pixerate-tokens/SKILL.md +5 -0
- package/dist/chunk-ERAGQL2N.cjs +0 -68
- package/dist/chunk-KMU6QJB7.js +0 -68
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
resolveExternalAssets,
|
|
8
8
|
serializeLayers,
|
|
9
9
|
serializeLayersExternal
|
|
10
|
-
} from "../chunk-
|
|
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-
|
|
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-
|
|
230
|
+
} from "../chunk-XBQX76CT.js";
|
|
231
231
|
import "../chunk-HF5QZS7Z.js";
|
|
232
|
-
import "../chunk-
|
|
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-
|
|
240
|
-
import "../chunk-
|
|
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
|
|
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
|
|
1330
|
+
return _chunkSJ2CPTQCcjs.defineEditorDocument.call(void 0, {
|
|
1331
1331
|
kind: "parameters",
|
|
1332
1332
|
get: () => controller.toJSON(),
|
|
1333
1333
|
load: (document, { history }) => {
|
package/dist/parameters/index.js
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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>;
|