@pixerate/editor 0.132.0 → 0.134.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 (90) hide show
  1. package/dist/animation-editor/index.cjs +55 -55
  2. package/dist/animation-editor/index.d.cts +4 -4
  3. package/dist/animation-editor/index.d.ts +4 -4
  4. package/dist/animation-editor/index.js +2 -2
  5. package/dist/{bezier-oCBfrGDG.d.cts → bezier-J8i4uqSH.d.cts} +1 -1
  6. package/dist/{bezier-0IHDCvv_.d.ts → bezier-lNEOp0Jx.d.ts} +1 -1
  7. package/dist/canvas/index.d.cts +7 -7
  8. package/dist/canvas/index.d.ts +7 -7
  9. package/dist/{chunk-MZXQTKUM.cjs → chunk-24ATT2PE.cjs} +10 -6
  10. package/dist/chunk-24ATT2PE.cjs.map +1 -0
  11. package/dist/{chunk-AHUYMDYW.js → chunk-2HC4DRF4.js} +10 -6
  12. package/dist/chunk-2HC4DRF4.js.map +1 -0
  13. package/dist/{chunk-YRZ6NVE3.js → chunk-6CTZAGZ2.js} +235 -4
  14. package/dist/chunk-6CTZAGZ2.js.map +1 -0
  15. package/dist/{chunk-ECVI5QRE.js → chunk-7RJ6P7MI.js} +2 -2
  16. package/dist/{chunk-G5FX56KX.js → chunk-ESIWZMMK.js} +51 -11
  17. package/dist/chunk-ESIWZMMK.js.map +1 -0
  18. package/dist/{chunk-IEYXYMRQ.js → chunk-HHTCDFZC.js} +99 -5
  19. package/dist/chunk-HHTCDFZC.js.map +1 -0
  20. package/dist/{chunk-W6M7C7R3.cjs → chunk-NVTHUPJ6.cjs} +236 -5
  21. package/dist/chunk-NVTHUPJ6.cjs.map +1 -0
  22. package/dist/{chunk-OYPJGGF3.cjs → chunk-T6TV6HY6.cjs} +36 -36
  23. package/dist/{chunk-OYPJGGF3.cjs.map → chunk-T6TV6HY6.cjs.map} +1 -1
  24. package/dist/{chunk-55UEZIU4.cjs → chunk-YAFS2QFZ.cjs} +231 -191
  25. package/dist/chunk-YAFS2QFZ.cjs.map +1 -0
  26. package/dist/{chunk-YYJKIESX.cjs → chunk-Z2H7KECK.cjs} +153 -59
  27. package/dist/chunk-Z2H7KECK.cjs.map +1 -0
  28. package/dist/effects/index.d.cts +4 -4
  29. package/dist/effects/index.d.ts +4 -4
  30. package/dist/{export-D-gkjBkB.d.cts → export-BGdT02aL.d.cts} +10 -10
  31. package/dist/{export-CfAogLEr.d.cts → export-DMeG6E06.d.ts} +1 -1
  32. package/dist/{export-ByJvAvR7.d.ts → export-Dng22YB8.d.ts} +10 -10
  33. package/dist/{export-Crl82sbE.d.ts → export-KzubBKo7.d.cts} +1 -1
  34. package/dist/{helpers-BCd2-PAR.d.ts → helpers-Coa4e2j_.d.ts} +35 -1
  35. package/dist/{helpers-CoIeXQnW.d.cts → helpers-DHl28yLO.d.cts} +35 -1
  36. package/dist/image-editor/index.cjs +983 -874
  37. package/dist/image-editor/index.cjs.map +1 -1
  38. package/dist/image-editor/index.d.cts +32 -13
  39. package/dist/image-editor/index.d.ts +32 -13
  40. package/dist/image-editor/index.js +124 -15
  41. package/dist/image-editor/index.js.map +1 -1
  42. package/dist/{opentype-BDahNRTe.d.cts → opentype-BWR7Qv8W.d.cts} +1 -1
  43. package/dist/{opentype-BQFEvy-t.d.ts → opentype-Dfcx6wFx.d.ts} +1 -1
  44. package/dist/paint/index.cjs +8 -2
  45. package/dist/paint/index.cjs.map +1 -1
  46. package/dist/paint/index.d.cts +14 -3
  47. package/dist/paint/index.d.ts +14 -3
  48. package/dist/paint/index.js +7 -1
  49. package/dist/paint-editor/index.cjs +78 -78
  50. package/dist/paint-editor/index.d.cts +7 -7
  51. package/dist/paint-editor/index.d.ts +7 -7
  52. package/dist/paint-editor/index.js +3 -3
  53. package/dist/{pathfinder-DaVdT8jq.d.ts → pathfinder-Celbi3e6.d.ts} +1 -1
  54. package/dist/{pathfinder-01ZgAwqV.d.cts → pathfinder-D8KQ6blQ.d.cts} +1 -1
  55. package/dist/{pool-D2A3WTt9.d.ts → pool-8JZGWHvR.d.ts} +1 -1
  56. package/dist/{pool-D6a45MoE.d.cts → pool-BfuxBKTd.d.cts} +1 -1
  57. package/dist/{rand-pQQ2sJTk.d.ts → rand-BaqEOs1Y.d.ts} +17 -4
  58. package/dist/{rand-DTXAssW1.d.cts → rand-DdpFzCo6.d.cts} +17 -4
  59. package/dist/raster/index.cjs +2 -2
  60. package/dist/raster/index.d.cts +4 -4
  61. package/dist/raster/index.d.ts +4 -4
  62. package/dist/raster/index.js +1 -1
  63. package/dist/{svg-DELNVerw.d.ts → svg-CxxqG3_W.d.ts} +2 -2
  64. package/dist/{svg-CcDz7Zq2.d.cts → svg-pwXWq6s2.d.cts} +2 -2
  65. package/dist/{tools-BFvkFnRj.d.cts → tools-3EBjR91b.d.cts} +1 -1
  66. package/dist/{tools-D7ws-OKL.d.ts → tools-y1M6O3UT.d.ts} +1 -1
  67. package/dist/vector/index.cjs +1642 -1046
  68. package/dist/vector/index.cjs.map +1 -1
  69. package/dist/vector/index.d.cts +275 -93
  70. package/dist/vector/index.d.ts +275 -93
  71. package/dist/vector/index.js +607 -11
  72. package/dist/vector/index.js.map +1 -1
  73. package/dist/video-editor/index.d.cts +4 -4
  74. package/dist/video-editor/index.d.ts +4 -4
  75. package/dist/{warp-2N9wkOkL.d.ts → warp-C1gwu2G_.d.ts} +1 -1
  76. package/dist/{warp-DErXW5rz.d.cts → warp-Ceqdz7kj.d.cts} +1 -1
  77. package/package.json +1 -1
  78. package/skills/pixerate-image-editor/SKILL.md +1 -1
  79. package/skills/pixerate-image-editor/references/retouching.md +3 -2
  80. package/skills/pixerate-vector/SKILL.md +12 -53
  81. package/skills/pixerate-vector/references/pitfalls.md +62 -0
  82. package/dist/chunk-55UEZIU4.cjs.map +0 -1
  83. package/dist/chunk-AHUYMDYW.js.map +0 -1
  84. package/dist/chunk-G5FX56KX.js.map +0 -1
  85. package/dist/chunk-IEYXYMRQ.js.map +0 -1
  86. package/dist/chunk-MZXQTKUM.cjs.map +0 -1
  87. package/dist/chunk-W6M7C7R3.cjs.map +0 -1
  88. package/dist/chunk-YRZ6NVE3.js.map +0 -1
  89. package/dist/chunk-YYJKIESX.cjs.map +0 -1
  90. /package/dist/{chunk-ECVI5QRE.js.map → chunk-7RJ6P7MI.js.map} +0 -0
@@ -82,6 +82,7 @@ var VECTOR_MASK_TYPES = ["clip", "alpha", "luminance"];
82
82
  var VECTOR_SYMMETRY_MODES = ["vertical", "horizontal", "dual", "diagonal", "radial"];
83
83
  var VECTOR_TEXT_ALIGNS = ["left", "center", "right", "justify"];
84
84
  var VECTOR_PATH_TEXT_BASELINES = ["baseline", "ascender", "descender", "center"];
85
+ var VECTOR_PERSPECTIVE_PLANES = ["floor", "left", "right", "side", "front"];
85
86
  var VECTOR_CONSTRAINT_KINDS = [
86
87
  "coincident",
87
88
  "collinear",
@@ -3205,10 +3206,11 @@ var drawnCache = /* @__PURE__ */ new WeakMap();
3205
3206
  function vectorFrameDrawn(node) {
3206
3207
  let hit = drawnCache.get(node);
3207
3208
  if (hit) return hit;
3208
- const { frame, ...group } = node;
3209
+ const { frame, masterArt, ...group } = node;
3209
3210
  const rect = vectorFrameRectPath(frame);
3211
+ const below = masterArt ?? [];
3210
3212
  const fill = frame.fill !== void 0 && frame.fill !== null && frame.fill !== "none" ? [{ id: `${node.id}~frame-fill`, type: "path", fill: frame.fill, stroke: null, subpaths: rect }] : [];
3211
- hit = frame.clip === false ? { ...group, children: [...fill, ...node.children] } : { ...group, mask: { type: "clip" }, children: [{ id: `${node.id}~frame-clip`, type: "path", fill: "#000000", stroke: null, subpaths: rect }, ...fill, ...node.children] };
3213
+ hit = frame.clip === false ? { ...group, children: [...fill, ...below, ...node.children] } : { ...group, mask: { type: "clip" }, children: [{ id: `${node.id}~frame-clip`, type: "path", fill: "#000000", stroke: null, subpaths: rect }, ...fill, ...below, ...node.children] };
3212
3214
  drawnCache.set(node, hit);
3213
3215
  return hit;
3214
3216
  }
@@ -3253,6 +3255,8 @@ function sanitizeVectorFrame(value) {
3253
3255
  const out = { x: r.x, y: r.y, width: r.width, height: r.height };
3254
3256
  if (typeof r.fill === "string" || r.fill && typeof r.fill === "object") out.fill = r.fill;
3255
3257
  if (r.clip === false) out.clip = false;
3258
+ if (r.master === true) out.master = true;
3259
+ if (typeof r.masterId === "string" && r.masterId) out.masterId = r.masterId;
3256
3260
  return out;
3257
3261
  }
3258
3262
  function sanitizeVectorResizing(value) {
@@ -7531,6 +7535,84 @@ function vectorEnteredGroups(nodes, ids) {
7531
7535
  return out;
7532
7536
  }
7533
7537
 
7538
+ // src/vector/pages.ts
7539
+ function isVectorMasterPage(node) {
7540
+ return isVectorFrame(node) && !!node.frame.master;
7541
+ }
7542
+ function vectorPages(doc) {
7543
+ return doc.nodes.filter((n) => isVectorFrame(n) && !n.frame.master);
7544
+ }
7545
+ function vectorMasterPages(doc) {
7546
+ return doc.nodes.filter(isVectorMasterPage);
7547
+ }
7548
+ function fillTokens(node, page, pages) {
7549
+ const map = (s) => s.replace(/\{page\}/g, String(page)).replace(/\{pages\}/g, String(pages));
7550
+ if (!/\{pages?\}/.test(node.text)) return node;
7551
+ if (!node.runs?.length) return { ...node, text: map(node.text) };
7552
+ let at2 = 0;
7553
+ let text = "";
7554
+ const runs = [];
7555
+ for (const r of node.runs) {
7556
+ const part = map(node.text.slice(at2, at2 + r.length));
7557
+ at2 += r.length;
7558
+ text += part;
7559
+ runs.push({ ...r, length: part.length });
7560
+ }
7561
+ return { ...node, text: text + map(node.text.slice(at2)), runs };
7562
+ }
7563
+ function onPage(node, pageId, page, pages) {
7564
+ const id = `${pageId}~master~${node.id}`;
7565
+ if (node.type === "group") return { ...node, id, children: node.children.map((c) => onPage(c, pageId, page, pages)) };
7566
+ if (node.type === "text") return { ...fillTokens(node, page, pages), id, locked: true };
7567
+ return { ...node, id, locked: true };
7568
+ }
7569
+ var artCache = /* @__PURE__ */ new WeakMap();
7570
+ function vectorMasterArt(master, page, number, count) {
7571
+ const f = page.frame;
7572
+ const key = `${page.id}|${f.x}|${f.y}|${f.width}|${f.height}|${number}|${count}`;
7573
+ let byKey = artCache.get(master);
7574
+ const hit = byKey?.get(key);
7575
+ if (hit) return hit;
7576
+ const art = master.children.filter((c) => c.visible !== false).map((c) => {
7577
+ const box = vectorNodeBounds(c);
7578
+ const m = box ? vectorFrameChildMatrix(c.resizing, box, master.frame, page.frame) : null;
7579
+ return onPage(m ? transformVectorNode(c, m) : c, page.id, number, count);
7580
+ });
7581
+ if (!byKey) artCache.set(master, byKey = /* @__PURE__ */ new Map());
7582
+ byKey.set(key, art);
7583
+ return art;
7584
+ }
7585
+ function resolveVectorMasterPages(doc) {
7586
+ const masters = new Map(vectorMasterPages(doc).map((m) => [m.id, m]));
7587
+ const pages = vectorPages(doc);
7588
+ const numbers = new Map(pages.map((p, i) => [p.id, i + 1]));
7589
+ let changed = false;
7590
+ const nodes = doc.nodes.map((n) => {
7591
+ if (!isVectorFrame(n)) return n;
7592
+ const master = !n.frame.master && n.frame.masterId ? masters.get(n.frame.masterId) : void 0;
7593
+ const art = master ? vectorMasterArt(master, n, numbers.get(n.id) ?? 0, pages.length) : void 0;
7594
+ if (art === n.masterArt || !art && !n.masterArt) return n;
7595
+ changed = true;
7596
+ if (!art) {
7597
+ const { masterArt: _m, ...rest } = n;
7598
+ return rest;
7599
+ }
7600
+ return { ...n, masterArt: art };
7601
+ });
7602
+ return changed ? { ...doc, nodes } : doc;
7603
+ }
7604
+ function stripVectorMasterArt(doc) {
7605
+ if (!doc.nodes.some((n) => n.type === "group" && n.masterArt)) return doc;
7606
+ return {
7607
+ ...doc,
7608
+ nodes: doc.nodes.map((n) => {
7609
+ if (n.type !== "group" || !n.masterArt) return n;
7610
+ const { masterArt: _m, ...rest } = n;
7611
+ return rest;
7612
+ })
7613
+ };
7614
+ }
7615
+
7534
7616
  // src/vector/connectors.ts
7535
7617
  var SIDES = ["top", "right", "bottom", "left", "center"];
7536
7618
  function isVectorConnector(node) {
@@ -8144,7 +8226,7 @@ function blendFromAttribute(value, m) {
8144
8226
  return out;
8145
8227
  }
8146
8228
  function vectorDocumentToSvg(doc, options = {}) {
8147
- doc = resolveVectorLenses(resolveVectorSymbols(doc));
8229
+ doc = resolveVectorLenses(resolveVectorMasterPages(resolveVectorSymbols(doc)));
8148
8230
  const precision = options.precision ?? 3;
8149
8231
  const prefix = options.idPrefix ?? "vg-";
8150
8232
  const pretty = options.pretty !== false;
@@ -8405,6 +8487,11 @@ function vectorDocumentToSvg(doc, options = {}) {
8405
8487
  ref = ` clip-path="url(#${escapeAttr2(id)})"`;
8406
8488
  }
8407
8489
  lines.push(`${indent(depth + 1)}<g data-vector-part="frame-contents"${ref}>`);
8490
+ if (node.masterArt?.length) {
8491
+ lines.push(`${indent(depth + 2)}<g data-vector-part="frame-master">`);
8492
+ for (const child of node.masterArt) emit2(child, depth + 3);
8493
+ lines.push(`${indent(depth + 2)}</g>`);
8494
+ }
8408
8495
  for (const child of node.children) emit2(child, depth + 2);
8409
8496
  lines.push(`${indent(depth + 1)}</g>`);
8410
8497
  lines.push(`${indent(depth)}</g>`);
@@ -9226,7 +9313,7 @@ function parseVectorSvg(svg, options = {}) {
9226
9313
  const raw = parseJson(g.attrs["data-vector-frame"]);
9227
9314
  const frame = sanitizeVectorFrame(raw);
9228
9315
  const contentsEl = g.children.find((c) => c.name === "g" && c.attrs["data-vector-part"] === "frame-contents");
9229
- const children = contentsEl ? visit2(contentsEl, style, m) : [];
9316
+ const children = contentsEl ? visit2({ ...contentsEl, children: contentsEl.children.filter((c) => c.attrs["data-vector-part"] !== "frame-master") }, style, m) : [];
9230
9317
  const id = idFor(g);
9231
9318
  if (!frame) return children.length ? { id, type: "group", ...meta, children } : null;
9232
9319
  const { rigid, residual } = decomposeRigid(m);
@@ -10150,6 +10237,7 @@ export {
10150
10237
  VECTOR_SYMMETRY_MODES,
10151
10238
  VECTOR_TEXT_ALIGNS,
10152
10239
  VECTOR_PATH_TEXT_BASELINES,
10240
+ VECTOR_PERSPECTIVE_PLANES,
10153
10241
  VECTOR_CONSTRAINT_KINDS,
10154
10242
  VECTOR_TOOLS,
10155
10243
  VECTOR_TRANSFORM_HANDLES,
@@ -10506,6 +10594,12 @@ export {
10506
10594
  sanitizeVectorEffects,
10507
10595
  transformVectorEffects,
10508
10596
  vectorEnteredGroups,
10597
+ isVectorMasterPage,
10598
+ vectorPages,
10599
+ vectorMasterPages,
10600
+ vectorMasterArt,
10601
+ resolveVectorMasterPages,
10602
+ stripVectorMasterArt,
10509
10603
  isVectorConnector,
10510
10604
  vectorConnectionSites,
10511
10605
  nearestVectorConnectionSite,
@@ -10580,4 +10674,4 @@ export {
10580
10674
  lineSubpath,
10581
10675
  roundSubpaths
10582
10676
  };
10583
- //# sourceMappingURL=chunk-IEYXYMRQ.js.map
10677
+ //# sourceMappingURL=chunk-HHTCDFZC.js.map