@pixerate/editor 0.154.0 → 0.156.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/animation-editor/index.cjs +60 -61
- package/dist/animation-editor/index.js +5 -6
- package/dist/{brushstrokeRender-YAZVQUXY.cjs → brushstrokeRender-5WANQIG4.cjs} +10 -10
- package/dist/{brushstrokeRender-EUDQTDYS.js → brushstrokeRender-Q4LI22QV.js} +3 -3
- package/dist/canvas/index.cjs +23 -24
- package/dist/canvas/index.js +3 -4
- package/dist/chart/index.cjs +2 -3
- package/dist/chart/index.js +1 -2
- package/dist/{chunk-AGZ47XY2.js → chunk-2N2QPO3H.js} +6 -2
- package/dist/{chunk-NMXPOKF3.js → chunk-45XXVHVG.js} +1 -1
- package/dist/{chunk-FLOGD3QB.js → chunk-6UPGM3JB.js} +2 -2
- package/dist/{chunk-6FUAHCVI.cjs → chunk-7NW46N7I.cjs} +16 -16
- package/dist/{chunk-ORDXMBD4.js → chunk-A5UCR2TO.js} +10 -3
- package/dist/{chunk-PI45JMP7.cjs → chunk-CD7PLU77.cjs} +81 -81
- package/dist/{chunk-LRRCMRSL.cjs → chunk-EBDCRTZI.cjs} +20 -16
- package/dist/{chunk-OLCYQLFE.js → chunk-EL5PAHNP.js} +1 -1
- package/dist/{chunk-PUC43JPT.cjs → chunk-EYVVIZJ3.cjs} +1 -1
- package/dist/{chunk-BXMIBMVG.cjs → chunk-JGKCC5OF.cjs} +65 -58
- package/dist/chunk-M4MIZPQI.cjs +393 -0
- package/dist/{chunk-LIXLD433.cjs → chunk-MHEXLG3M.cjs} +35 -35
- package/dist/chunk-NHLYK3AX.js +393 -0
- package/dist/{chunk-RHXW4TA5.cjs → chunk-QMI5HZWA.cjs} +7 -7
- package/dist/{chunk-XFDQEAOS.cjs → chunk-RQCMSEM5.cjs} +2 -2
- package/dist/{chunk-BCY22GBH.js → chunk-SDHZG5TF.js} +1 -1
- package/dist/{chunk-HVX35M2I.cjs → chunk-WI7QJA7A.cjs} +2 -2
- package/dist/{chunk-UILRJQFD.js → chunk-WNAAWLZ5.js} +1 -1
- package/dist/{chunk-4J4MC3F5.js → chunk-YXOW456B.js} +1 -1
- package/dist/{chunk-Y64YPIFT.js → chunk-ZQWLWDZI.js} +1 -1
- package/dist/diagram/index.cjs +2 -3
- package/dist/diagram/index.js +1 -2
- package/dist/image-editor/controller.d.cts +8 -0
- package/dist/image-editor/controller.d.ts +8 -0
- package/dist/image-editor/editorDocument.d.cts +16 -0
- package/dist/image-editor/editorDocument.d.ts +16 -0
- package/dist/image-editor/index.cjs +787 -737
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +56 -6
- package/dist/index.cjs +4 -5
- package/dist/index.js +2 -3
- package/dist/paint/grain.d.cts +7 -0
- package/dist/paint/grain.d.ts +7 -0
- package/dist/paint/index.cjs +3 -3
- package/dist/paint/index.js +2 -2
- package/dist/paint-editor/controller.d.cts +38 -0
- package/dist/paint-editor/controller.d.ts +38 -0
- package/dist/paint-editor/document.d.cts +8 -0
- package/dist/paint-editor/document.d.ts +8 -0
- package/dist/paint-editor/editorDocument.d.cts +17 -0
- package/dist/paint-editor/editorDocument.d.ts +17 -0
- package/dist/paint-editor/index.cjs +476 -273
- package/dist/paint-editor/index.d.cts +1 -0
- package/dist/paint-editor/index.d.ts +1 -0
- package/dist/paint-editor/index.js +216 -13
- package/dist/paint-editor/paper.d.cts +8 -0
- package/dist/paint-editor/paper.d.ts +8 -0
- package/dist/paint-editor/stencils.d.cts +2 -0
- package/dist/paint-editor/stencils.d.ts +2 -0
- package/dist/paint-editor/wet.d.cts +1 -0
- package/dist/paint-editor/wet.d.ts +1 -0
- package/dist/parameters/index.cjs +2 -3
- package/dist/parameters/index.js +1 -2
- package/dist/persistence/assets.d.cts +51 -0
- package/dist/persistence/assets.d.ts +51 -0
- package/dist/persistence/editorDocument.d.cts +12 -0
- package/dist/persistence/editorDocument.d.ts +12 -0
- package/dist/persistence/index.cjs +32 -8
- package/dist/persistence/index.d.cts +1 -0
- package/dist/persistence/index.d.ts +1 -0
- package/dist/persistence/index.js +34 -10
- package/dist/spreadsheet/index.cjs +3 -4
- package/dist/spreadsheet/index.js +2 -3
- package/dist/tokens/index.cjs +3 -4
- package/dist/tokens/index.js +2 -3
- package/dist/vector/index.cjs +952 -953
- package/dist/vector/index.js +5 -6
- package/dist/video-editor/index.cjs +2 -3
- package/dist/video-editor/index.js +1 -2
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +16 -24
- package/skills/pixerate-image-editor/references/smart-objects.md +28 -0
- package/skills/pixerate-paint-editor/SKILL.md +26 -6
- package/dist/chunk-5H2C3QSF.cjs +0 -134
- package/dist/chunk-GNV54DLO.js +0 -134
- package/dist/chunk-L5OWG2NA.cjs +0 -135
- package/dist/chunk-WHKNYFM2.js +0 -135
package/dist/chunk-WHKNYFM2.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isUnsafeJsonKey,
|
|
3
|
-
stripPrototypeKeys
|
|
4
|
-
} from "./chunk-HF5QZS7Z.js";
|
|
5
|
-
|
|
6
|
-
// src/persistence/migrate.ts
|
|
7
|
-
function hasLoadProblems(report) {
|
|
8
|
-
return report.problems.length > 0 || report.readOnly !== null;
|
|
9
|
-
}
|
|
10
|
-
function createLoadReport(partial = {}) {
|
|
11
|
-
return {
|
|
12
|
-
migratedFrom: null,
|
|
13
|
-
version: null,
|
|
14
|
-
problems: [],
|
|
15
|
-
readOnly: null,
|
|
16
|
-
unknownKeys: [],
|
|
17
|
-
...partial
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21
|
-
var deepClone = (value) => typeof structuredClone === "function" ? structuredClone(value) : JSON.parse(JSON.stringify(value));
|
|
22
|
-
function toObject(json) {
|
|
23
|
-
let value = json;
|
|
24
|
-
if (typeof json === "string") {
|
|
25
|
-
try {
|
|
26
|
-
value = JSON.parse(json);
|
|
27
|
-
} catch {
|
|
28
|
-
return void 0;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return isObject(value) ? stripPrototypeKeys(deepClone(value)) : void 0;
|
|
32
|
-
}
|
|
33
|
-
function migrateDocument(json, options) {
|
|
34
|
-
const versionKey = options.versionKey ?? "version";
|
|
35
|
-
const target = options.currentVersion;
|
|
36
|
-
const original = toObject(json);
|
|
37
|
-
if (!original) {
|
|
38
|
-
return {
|
|
39
|
-
doc: { [versionKey]: target },
|
|
40
|
-
report: createLoadReport({
|
|
41
|
-
readOnly: { kind: "invalid", message: "document is not a JSON object" }
|
|
42
|
-
})
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
const raw = original[versionKey];
|
|
46
|
-
const found = typeof raw === "number" && Number.isInteger(raw) && raw >= 0 ? raw : null;
|
|
47
|
-
const from = found ?? options.missingVersion ?? target;
|
|
48
|
-
const report = createLoadReport({ version: found });
|
|
49
|
-
if (from > target) {
|
|
50
|
-
report.readOnly = {
|
|
51
|
-
kind: "newerVersion",
|
|
52
|
-
version: from,
|
|
53
|
-
supported: target,
|
|
54
|
-
message: `document has version ${from}, newer than the supported ${target}`
|
|
55
|
-
};
|
|
56
|
-
return { doc: original, report };
|
|
57
|
-
}
|
|
58
|
-
if (from === target) {
|
|
59
|
-
original[versionKey] = target;
|
|
60
|
-
return { doc: original, report };
|
|
61
|
-
}
|
|
62
|
-
let doc = deepClone(original);
|
|
63
|
-
for (let step = from; step < target; step++) {
|
|
64
|
-
const fn = options.steps?.[step];
|
|
65
|
-
if (!fn) {
|
|
66
|
-
report.readOnly = {
|
|
67
|
-
kind: "migrationFailed",
|
|
68
|
-
from: step,
|
|
69
|
-
message: `no migration step from version ${step}`
|
|
70
|
-
};
|
|
71
|
-
return { doc: original, report };
|
|
72
|
-
}
|
|
73
|
-
try {
|
|
74
|
-
doc = fn(doc) ?? doc;
|
|
75
|
-
} catch (error) {
|
|
76
|
-
report.readOnly = {
|
|
77
|
-
kind: "migrationFailed",
|
|
78
|
-
from: step,
|
|
79
|
-
message: `migration from version ${step} failed: ${error instanceof Error ? error.message : String(error)}`
|
|
80
|
-
};
|
|
81
|
-
return { doc: original, report };
|
|
82
|
-
}
|
|
83
|
-
doc[versionKey] = step + 1;
|
|
84
|
-
}
|
|
85
|
-
report.migratedFrom = from;
|
|
86
|
-
return { doc, report };
|
|
87
|
-
}
|
|
88
|
-
function loadSections(doc, sections, options = {}) {
|
|
89
|
-
const source = isObject(doc) ? doc : {};
|
|
90
|
-
const ignore = new Set(options.ignore ?? ["version"]);
|
|
91
|
-
const value = {};
|
|
92
|
-
const problems = [];
|
|
93
|
-
for (const key of Object.keys(sections)) {
|
|
94
|
-
const spec = sections[key];
|
|
95
|
-
const fallback = () => typeof spec.defaults === "function" ? spec.defaults() : spec.defaults;
|
|
96
|
-
if (!Object.prototype.hasOwnProperty.call(source, key)) {
|
|
97
|
-
value[key] = fallback();
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
try {
|
|
101
|
-
const parsed = spec.parse(source[key]);
|
|
102
|
-
if (parsed === void 0) throw new Error("invalid value");
|
|
103
|
-
value[key] = parsed;
|
|
104
|
-
} catch (error) {
|
|
105
|
-
problems.push({
|
|
106
|
-
section: key,
|
|
107
|
-
message: error instanceof Error ? error.message : String(error)
|
|
108
|
-
});
|
|
109
|
-
value[key] = fallback();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
const unknown = {};
|
|
113
|
-
for (const key of Object.keys(source)) {
|
|
114
|
-
if (!(key in sections) && !ignore.has(key) && !isUnsafeJsonKey(key)) unknown[key] = source[key];
|
|
115
|
-
}
|
|
116
|
-
return { value, problems, unknown };
|
|
117
|
-
}
|
|
118
|
-
function loadDocument(json, sections, options) {
|
|
119
|
-
const { doc, report } = migrateDocument(json, options);
|
|
120
|
-
const ignore = options.ignore ?? [options.versionKey ?? "version"];
|
|
121
|
-
const result = loadSections(report.readOnly?.kind === "invalid" ? {} : doc, sections, {
|
|
122
|
-
ignore
|
|
123
|
-
});
|
|
124
|
-
report.problems = result.problems;
|
|
125
|
-
report.unknownKeys = Object.keys(result.unknown);
|
|
126
|
-
return { ...result, report };
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export {
|
|
130
|
-
hasLoadProblems,
|
|
131
|
-
createLoadReport,
|
|
132
|
-
migrateDocument,
|
|
133
|
-
loadSections,
|
|
134
|
-
loadDocument
|
|
135
|
-
};
|