@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.
Files changed (86) hide show
  1. package/dist/animation-editor/index.cjs +60 -61
  2. package/dist/animation-editor/index.js +5 -6
  3. package/dist/{brushstrokeRender-YAZVQUXY.cjs → brushstrokeRender-5WANQIG4.cjs} +10 -10
  4. package/dist/{brushstrokeRender-EUDQTDYS.js → brushstrokeRender-Q4LI22QV.js} +3 -3
  5. package/dist/canvas/index.cjs +23 -24
  6. package/dist/canvas/index.js +3 -4
  7. package/dist/chart/index.cjs +2 -3
  8. package/dist/chart/index.js +1 -2
  9. package/dist/{chunk-AGZ47XY2.js → chunk-2N2QPO3H.js} +6 -2
  10. package/dist/{chunk-NMXPOKF3.js → chunk-45XXVHVG.js} +1 -1
  11. package/dist/{chunk-FLOGD3QB.js → chunk-6UPGM3JB.js} +2 -2
  12. package/dist/{chunk-6FUAHCVI.cjs → chunk-7NW46N7I.cjs} +16 -16
  13. package/dist/{chunk-ORDXMBD4.js → chunk-A5UCR2TO.js} +10 -3
  14. package/dist/{chunk-PI45JMP7.cjs → chunk-CD7PLU77.cjs} +81 -81
  15. package/dist/{chunk-LRRCMRSL.cjs → chunk-EBDCRTZI.cjs} +20 -16
  16. package/dist/{chunk-OLCYQLFE.js → chunk-EL5PAHNP.js} +1 -1
  17. package/dist/{chunk-PUC43JPT.cjs → chunk-EYVVIZJ3.cjs} +1 -1
  18. package/dist/{chunk-BXMIBMVG.cjs → chunk-JGKCC5OF.cjs} +65 -58
  19. package/dist/chunk-M4MIZPQI.cjs +393 -0
  20. package/dist/{chunk-LIXLD433.cjs → chunk-MHEXLG3M.cjs} +35 -35
  21. package/dist/chunk-NHLYK3AX.js +393 -0
  22. package/dist/{chunk-RHXW4TA5.cjs → chunk-QMI5HZWA.cjs} +7 -7
  23. package/dist/{chunk-XFDQEAOS.cjs → chunk-RQCMSEM5.cjs} +2 -2
  24. package/dist/{chunk-BCY22GBH.js → chunk-SDHZG5TF.js} +1 -1
  25. package/dist/{chunk-HVX35M2I.cjs → chunk-WI7QJA7A.cjs} +2 -2
  26. package/dist/{chunk-UILRJQFD.js → chunk-WNAAWLZ5.js} +1 -1
  27. package/dist/{chunk-4J4MC3F5.js → chunk-YXOW456B.js} +1 -1
  28. package/dist/{chunk-Y64YPIFT.js → chunk-ZQWLWDZI.js} +1 -1
  29. package/dist/diagram/index.cjs +2 -3
  30. package/dist/diagram/index.js +1 -2
  31. package/dist/image-editor/controller.d.cts +8 -0
  32. package/dist/image-editor/controller.d.ts +8 -0
  33. package/dist/image-editor/editorDocument.d.cts +16 -0
  34. package/dist/image-editor/editorDocument.d.ts +16 -0
  35. package/dist/image-editor/index.cjs +787 -737
  36. package/dist/image-editor/index.d.cts +1 -0
  37. package/dist/image-editor/index.d.ts +1 -0
  38. package/dist/image-editor/index.js +56 -6
  39. package/dist/index.cjs +4 -5
  40. package/dist/index.js +2 -3
  41. package/dist/paint/grain.d.cts +7 -0
  42. package/dist/paint/grain.d.ts +7 -0
  43. package/dist/paint/index.cjs +3 -3
  44. package/dist/paint/index.js +2 -2
  45. package/dist/paint-editor/controller.d.cts +38 -0
  46. package/dist/paint-editor/controller.d.ts +38 -0
  47. package/dist/paint-editor/document.d.cts +8 -0
  48. package/dist/paint-editor/document.d.ts +8 -0
  49. package/dist/paint-editor/editorDocument.d.cts +17 -0
  50. package/dist/paint-editor/editorDocument.d.ts +17 -0
  51. package/dist/paint-editor/index.cjs +476 -273
  52. package/dist/paint-editor/index.d.cts +1 -0
  53. package/dist/paint-editor/index.d.ts +1 -0
  54. package/dist/paint-editor/index.js +216 -13
  55. package/dist/paint-editor/paper.d.cts +8 -0
  56. package/dist/paint-editor/paper.d.ts +8 -0
  57. package/dist/paint-editor/stencils.d.cts +2 -0
  58. package/dist/paint-editor/stencils.d.ts +2 -0
  59. package/dist/paint-editor/wet.d.cts +1 -0
  60. package/dist/paint-editor/wet.d.ts +1 -0
  61. package/dist/parameters/index.cjs +2 -3
  62. package/dist/parameters/index.js +1 -2
  63. package/dist/persistence/assets.d.cts +51 -0
  64. package/dist/persistence/assets.d.ts +51 -0
  65. package/dist/persistence/editorDocument.d.cts +12 -0
  66. package/dist/persistence/editorDocument.d.ts +12 -0
  67. package/dist/persistence/index.cjs +32 -8
  68. package/dist/persistence/index.d.cts +1 -0
  69. package/dist/persistence/index.d.ts +1 -0
  70. package/dist/persistence/index.js +34 -10
  71. package/dist/spreadsheet/index.cjs +3 -4
  72. package/dist/spreadsheet/index.js +2 -3
  73. package/dist/tokens/index.cjs +3 -4
  74. package/dist/tokens/index.js +2 -3
  75. package/dist/vector/index.cjs +952 -953
  76. package/dist/vector/index.js +5 -6
  77. package/dist/video-editor/index.cjs +2 -3
  78. package/dist/video-editor/index.js +1 -2
  79. package/package.json +1 -1
  80. package/skills/pixerate-image-editor/SKILL.md +16 -24
  81. package/skills/pixerate-image-editor/references/smart-objects.md +28 -0
  82. package/skills/pixerate-paint-editor/SKILL.md +26 -6
  83. package/dist/chunk-5H2C3QSF.cjs +0 -134
  84. package/dist/chunk-GNV54DLO.js +0 -134
  85. package/dist/chunk-L5OWG2NA.cjs +0 -135
  86. package/dist/chunk-WHKNYFM2.js +0 -135
@@ -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
- };