@pixerate/editor 0.140.3 → 0.141.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/canvasPlayback.d.cts +15 -0
- package/dist/agent/canvasPlayback.d.ts +15 -0
- package/dist/agent/index.cjs +144 -23
- package/dist/agent/index.d.cts +1 -0
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.js +125 -4
- package/dist/agent/providers.d.cts +8 -0
- package/dist/agent/providers.d.ts +8 -0
- package/dist/agent/types.d.cts +3 -0
- package/dist/agent/types.d.ts +3 -0
- package/dist/animation/index.cjs +2 -2
- package/dist/animation/index.js +1 -1
- package/dist/animation/presence.d.cts +1 -75
- package/dist/animation/presence.d.ts +1 -75
- package/dist/animation-editor/index.cjs +55 -55
- package/dist/animation-editor/index.js +2 -2
- 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/index.cjs +336 -646
- package/dist/canvas/index.d.cts +1 -0
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/index.js +44 -354
- package/dist/canvas/playback.d.cts +14 -0
- package/dist/canvas/playback.d.ts +14 -0
- package/dist/chart/index.cjs +7 -7
- package/dist/chart/index.js +1 -1
- package/dist/chunk-6SFREX6H.cjs +406 -0
- package/dist/{chunk-XGOU44RJ.js → chunk-77SG47WT.js} +80 -9
- package/dist/{chunk-2SHFIVC3.js → chunk-DAS7M4RY.js} +1 -1
- package/dist/chunk-DW4CV5H4.js +591 -0
- package/dist/{chunk-UMS6YFA6.js → chunk-EAQ4BGNS.js} +1 -1
- package/dist/{chunk-AGCD3EHB.cjs → chunk-ENIZYNEF.cjs} +7 -7
- package/dist/{chunk-VSR5A22L.cjs → chunk-H6FX45CP.cjs} +35 -35
- package/dist/{chunk-RCUX6CT2.cjs → chunk-HRI3ZMDM.cjs} +110 -39
- package/dist/chunk-MFFE55CS.js +406 -0
- package/dist/{chunk-BSGPXPTW.js → chunk-PEEP2YR7.js} +1 -1
- package/dist/{chunk-RB62U6MS.js → chunk-RFBFTLVN.js} +27 -5
- package/dist/chunk-UBRYHNRU.cjs +591 -0
- package/dist/{chunk-GEY73RUW.cjs → chunk-UJGAA6AK.cjs} +1 -1
- package/dist/{chunk-6UZCFD7Y.js → chunk-VM6JYWXQ.js} +1 -1
- package/dist/{chunk-O3ZU6QIZ.cjs → chunk-XNZWATSB.cjs} +81 -81
- package/dist/{chunk-HDK3T2QS.cjs → chunk-Y4BWZB6J.cjs} +29 -7
- package/dist/commands/index.cjs +37 -1
- package/dist/commands/index.js +36 -0
- package/dist/commands/registry.d.cts +11 -0
- package/dist/commands/registry.d.ts +11 -0
- package/dist/diagram/index.cjs +7 -7
- package/dist/diagram/index.js +1 -1
- package/dist/image-editor/index.cjs +720 -628
- package/dist/image-editor/index.d.cts +1 -0
- package/dist/image-editor/index.d.ts +1 -0
- package/dist/image-editor/index.js +109 -17
- package/dist/image-editor/playback.d.cts +22 -0
- package/dist/image-editor/playback.d.ts +22 -0
- package/dist/paint-editor/index.cjs +13 -13
- package/dist/paint-editor/index.js +3 -3
- package/dist/tools/index.cjs +33 -3
- package/dist/tools/index.d.cts +2 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +32 -2
- package/dist/tools/playback.d.cts +205 -0
- package/dist/tools/playback.d.ts +205 -0
- package/dist/tools/presence.d.cts +82 -0
- package/dist/tools/presence.d.ts +82 -0
- package/dist/tools/registry.d.cts +45 -6
- package/dist/tools/registry.d.ts +45 -6
- package/dist/tools/view.d.cts +2 -4
- package/dist/tools/view.d.ts +2 -4
- package/dist/vector/index.cjs +1159 -1042
- package/dist/vector/index.d.cts +1 -0
- package/dist/vector/index.d.ts +1 -0
- package/dist/vector/index.js +142 -25
- package/dist/vector/playback.d.cts +13 -0
- package/dist/vector/playback.d.ts +13 -0
- package/package.json +1 -1
- package/skills/pixerate-agent-tools/SKILL.md +13 -0
- package/skills/pixerate-canvas/SKILL.md +3 -0
- package/skills/pixerate-image-editor/SKILL.md +2 -2
- package/skills/pixerate-vector/SKILL.md +5 -0
- package/dist/chunk-BTZS3KZY.js +0 -221
- package/dist/chunk-MRD3NXKR.cjs +0 -221
- /package/dist/{chunk-K73HMKQP.js → chunk-PLKIYNJZ.js} +0 -0
- /package/dist/{chunk-LACYURUW.cjs → chunk-TNCWKC5M.cjs} +0 -0
|
@@ -89,7 +89,7 @@ var _chunkONZJD2ODcjs = require('./chunk-ONZJD2OD.cjs');
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
var
|
|
92
|
+
var _chunkHRI3ZMDMcjs = require('./chunk-HRI3ZMDM.cjs');
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
|
|
@@ -3262,7 +3262,7 @@ function mapAnchor(a, f) {
|
|
|
3262
3262
|
return out;
|
|
3263
3263
|
}
|
|
3264
3264
|
function mapSubpaths(subpaths, f) {
|
|
3265
|
-
return
|
|
3265
|
+
return _chunkHRI3ZMDMcjs.expandVectorCorners.call(void 0, subpaths).map((sp) => ({ closed: sp.closed, anchors: sp.anchors.map((a) => mapAnchor(a, f)) }));
|
|
3266
3266
|
}
|
|
3267
3267
|
function liveShapeSubpaths(live) {
|
|
3268
3268
|
let out;
|
|
@@ -3270,19 +3270,19 @@ function liveShapeSubpaths(live) {
|
|
|
3270
3270
|
case "rect": {
|
|
3271
3271
|
const x = Math.min(live.x, live.x + live.width);
|
|
3272
3272
|
const y = Math.min(live.y, live.y + live.height);
|
|
3273
|
-
const sp =
|
|
3273
|
+
const sp = _chunkHRI3ZMDMcjs.rectSubpath.call(void 0, { x, y, width: Math.abs(live.width), height: Math.abs(live.height) });
|
|
3274
3274
|
const r = _nullishCoalesce(live.radii, () => ( [0, 0, 0, 0]));
|
|
3275
|
-
out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ?
|
|
3275
|
+
out = [{ closed: true, anchors: sp.anchors.map((a, i) => r[i] > 0 ? _chunkHRI3ZMDMcjs.setAnchorCorner.call(void 0, a, r[i]) : a) }];
|
|
3276
3276
|
break;
|
|
3277
3277
|
}
|
|
3278
3278
|
case "ellipse":
|
|
3279
|
-
out = [
|
|
3279
|
+
out = [_chunkHRI3ZMDMcjs.ellipseSubpath.call(void 0, normBox(live))];
|
|
3280
3280
|
break;
|
|
3281
3281
|
case "polygon":
|
|
3282
|
-
out = [
|
|
3282
|
+
out = [_chunkHRI3ZMDMcjs.polygonSubpath.call(void 0, normBox(live), live.sides)];
|
|
3283
3283
|
break;
|
|
3284
3284
|
case "star":
|
|
3285
|
-
out = [
|
|
3285
|
+
out = [_chunkHRI3ZMDMcjs.starSubpath.call(void 0, normBox(live), live.points, Math.max(0, Math.min(1, live.innerRatio)))];
|
|
3286
3286
|
break;
|
|
3287
3287
|
case "line": {
|
|
3288
3288
|
const a = { x: live.x1, y: live.y1 };
|
|
@@ -3305,7 +3305,7 @@ function liveShapeSubpaths(live) {
|
|
|
3305
3305
|
}
|
|
3306
3306
|
}
|
|
3307
3307
|
const m = live.transform;
|
|
3308
|
-
return m && !
|
|
3308
|
+
return m && !_chunkHRI3ZMDMcjs.isIdentityMatrix.call(void 0, m) ? mapSubpaths(out, (p) => _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, p)) : out;
|
|
3309
3309
|
}
|
|
3310
3310
|
function normBox(b) {
|
|
3311
3311
|
return { x: Math.min(b.x, b.x + b.width), y: Math.min(b.y, b.y + b.height), width: Math.abs(b.width), height: Math.abs(b.height) };
|
|
@@ -3317,7 +3317,7 @@ var pathCache = /* @__PURE__ */ new WeakMap();
|
|
|
3317
3317
|
function componentPath(c) {
|
|
3318
3318
|
let p = pathCache.get(c.subpaths);
|
|
3319
3319
|
if (!p) {
|
|
3320
|
-
p =
|
|
3320
|
+
p = _chunkHRI3ZMDMcjs.subpathsToBezier.call(void 0, c.subpaths);
|
|
3321
3321
|
pathCache.set(c.subpaths, p);
|
|
3322
3322
|
}
|
|
3323
3323
|
return p;
|
|
@@ -3640,7 +3640,7 @@ function matrixArg(v, path) {
|
|
|
3640
3640
|
if (!Array.isArray(v) || v.length !== 6 || !v.every(isNum)) fail2(`${path} must be six numbers [a, b, c, d, e, f].`);
|
|
3641
3641
|
const m = v;
|
|
3642
3642
|
if (Math.abs(m[0] * m[3] - m[1] * m[2]) < 1e-12) fail2(`${path} is singular.`);
|
|
3643
|
-
return
|
|
3643
|
+
return _chunkHRI3ZMDMcjs.isIdentityMatrix.call(void 0, m) ? void 0 : [...m];
|
|
3644
3644
|
}
|
|
3645
3645
|
function normalizeLiveShape(v, path = "shape") {
|
|
3646
3646
|
if (!v || typeof v !== "object") return fail2(`${path} must be an object with kind ${LIVE_SHAPE_KINDS.join(", ")}.`);
|
|
@@ -3701,7 +3701,7 @@ function normalizeSubpaths(v, path = "subpaths") {
|
|
|
3701
3701
|
if (typeof v === "string") {
|
|
3702
3702
|
let subs;
|
|
3703
3703
|
try {
|
|
3704
|
-
subs =
|
|
3704
|
+
subs = _chunkHRI3ZMDMcjs.bezierToSubpaths.call(void 0, v);
|
|
3705
3705
|
} catch (e5) {
|
|
3706
3706
|
return fail2(`${path}: could not read the SVG path data.`);
|
|
3707
3707
|
}
|
|
@@ -3787,15 +3787,15 @@ function updateShapeLayer(layers, id, change, env, action = "edit it") {
|
|
|
3787
3787
|
function transformShapeComponents(components, f, affine) {
|
|
3788
3788
|
return components.map((c) => {
|
|
3789
3789
|
if (affine && c.live) {
|
|
3790
|
-
const live = { ...c.live, transform:
|
|
3791
|
-
if (
|
|
3790
|
+
const live = { ...c.live, transform: _chunkHRI3ZMDMcjs.multiplyMatrices.call(void 0, _nullishCoalesce(c.live.transform, () => ( _chunkHRI3ZMDMcjs.IDENTITY_MATRIX)), affine) };
|
|
3791
|
+
if (_chunkHRI3ZMDMcjs.isIdentityMatrix.call(void 0, live.transform)) delete live.transform;
|
|
3792
3792
|
return { op: c.op, subpaths: liveShapeSubpaths(live), live };
|
|
3793
3793
|
}
|
|
3794
3794
|
return { op: c.op, subpaths: mapSubpaths(c.subpaths, f) };
|
|
3795
3795
|
});
|
|
3796
3796
|
}
|
|
3797
3797
|
function offsetShape(layer, dx, dy, env) {
|
|
3798
|
-
const m =
|
|
3798
|
+
const m = _chunkHRI3ZMDMcjs.translateMatrix.call(void 0, dx, dy);
|
|
3799
3799
|
const next = { ...layer, components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), m) };
|
|
3800
3800
|
delete next.annotation;
|
|
3801
3801
|
return rerenderShape(next, env);
|
|
@@ -3803,7 +3803,7 @@ function offsetShape(layer, dx, dy, env) {
|
|
|
3803
3803
|
function mergeShapeComponents(components, fillRule = "nonzero") {
|
|
3804
3804
|
if (components.length < 2) return [...components];
|
|
3805
3805
|
const path = shapeOutline(components, fillRule);
|
|
3806
|
-
const subpaths =
|
|
3806
|
+
const subpaths = _chunkHRI3ZMDMcjs.bezierToSubpaths.call(void 0, path);
|
|
3807
3807
|
if (!subpaths.length) fail2("The components combine to nothing (the operations remove every area), so there is nothing to merge into.");
|
|
3808
3808
|
return [{ op: "combine", subpaths }];
|
|
3809
3809
|
}
|
|
@@ -3820,7 +3820,7 @@ function annotationPaint(color, opacity) {
|
|
|
3820
3820
|
function shapeFromAnnotation(a) {
|
|
3821
3821
|
const opacity = _nullishCoalesce(a.opacity, () => ( 1));
|
|
3822
3822
|
const lineWidth = "strokeWidth" in a && a.strokeWidth > 0 ? a.strokeWidth : 1;
|
|
3823
|
-
const rotation = a.rotation ?
|
|
3823
|
+
const rotation = a.rotation ? _chunkHRI3ZMDMcjs.rotateMatrix.call(void 0, a.rotation, { x: a.x, y: a.y }) : void 0;
|
|
3824
3824
|
const t = rotation ? { transform: rotation } : {};
|
|
3825
3825
|
const live = (l) => liveComponent(l);
|
|
3826
3826
|
switch (a.type) {
|
|
@@ -3863,7 +3863,7 @@ function shapeFromAnnotation(a) {
|
|
|
3863
3863
|
case "pen": {
|
|
3864
3864
|
const paint = annotationPaint(a.strokeColor, opacity);
|
|
3865
3865
|
if (!paint) return null;
|
|
3866
|
-
const pts = rotation ? a.points.map((p) =>
|
|
3866
|
+
const pts = rotation ? a.points.map((p) => _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, rotation, p)) : a.points;
|
|
3867
3867
|
const subpaths = pts.length > 1 ? [{ closed: false, anchors: pts.map((p) => ({ x: p.x, y: p.y })) }] : [];
|
|
3868
3868
|
return {
|
|
3869
3869
|
components: [{ op: "combine", subpaths }],
|
|
@@ -3896,7 +3896,7 @@ var fail3 = (message) => {
|
|
|
3896
3896
|
};
|
|
3897
3897
|
var TEXT_RENDER_MARGIN = _chunkHGTDMKNEcjs.MAX_EFFECT_REACH;
|
|
3898
3898
|
function textMatrix(layer) {
|
|
3899
|
-
return _nullishCoalesce(layer.transform, () => (
|
|
3899
|
+
return _nullishCoalesce(layer.transform, () => ( _chunkHRI3ZMDMcjs.IDENTITY_MATRIX));
|
|
3900
3900
|
}
|
|
3901
3901
|
function rectCorners(r) {
|
|
3902
3902
|
return [
|
|
@@ -3907,7 +3907,7 @@ function rectCorners(r) {
|
|
|
3907
3907
|
];
|
|
3908
3908
|
}
|
|
3909
3909
|
function docRect(r, m) {
|
|
3910
|
-
const pts = rectCorners(r).map((p) =>
|
|
3910
|
+
const pts = rectCorners(r).map((p) => _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, p));
|
|
3911
3911
|
const x0 = Math.floor(Math.min(...pts.map((p) => p.x)));
|
|
3912
3912
|
const y0 = Math.floor(Math.min(...pts.map((p) => p.y)));
|
|
3913
3913
|
const x1 = Math.ceil(Math.max(...pts.map((p) => p.x)));
|
|
@@ -3940,14 +3940,14 @@ function inkBounds(layout) {
|
|
|
3940
3940
|
}
|
|
3941
3941
|
function textOutlines(layer, shaper) {
|
|
3942
3942
|
if (!shaper.outline) fail3(`The text shaper "${shaper.id}" cannot give glyph outlines; plug in an outline shaper (createOutlineTextShaper) to convert text to shapes.`);
|
|
3943
|
-
const layout =
|
|
3943
|
+
const layout = _chunkHRI3ZMDMcjs.layoutText.call(void 0, layer, shaper);
|
|
3944
3944
|
const m = textMatrix(layer);
|
|
3945
3945
|
const out = [];
|
|
3946
3946
|
for (const l of layout.lines) {
|
|
3947
3947
|
for (const f of l.fragments) {
|
|
3948
|
-
let path =
|
|
3949
|
-
for (const r of
|
|
3950
|
-
out.push({ fragment: f, path:
|
|
3948
|
+
let path = _chunkHRI3ZMDMcjs.textFragmentOutline.call(void 0, shaper, layer.text, f);
|
|
3949
|
+
for (const r of _chunkHRI3ZMDMcjs.textDecorations.call(void 0, f, l)) path = [...path, ..._chunkHRI3ZMDMcjs.textRectPath.call(void 0, r)];
|
|
3950
|
+
out.push({ fragment: f, path: _chunkHRI3ZMDMcjs.isIdentityMatrix.call(void 0, m) ? path : _chunkGF2RBSDMcjs.transformBezierPath.call(void 0, path, m) });
|
|
3951
3951
|
}
|
|
3952
3952
|
}
|
|
3953
3953
|
return out;
|
|
@@ -4003,7 +4003,7 @@ function renderOnCanvas(layer, shaper, region, env) {
|
|
|
4003
4003
|
const canvas = env.createCanvas(region.width, region.height);
|
|
4004
4004
|
const ctx = canvas.getContext("2d");
|
|
4005
4005
|
if (!ctx || typeof ctx.getImageData !== "function") return null;
|
|
4006
|
-
const layout =
|
|
4006
|
+
const layout = _chunkHRI3ZMDMcjs.layoutText.call(void 0, layer, shaper);
|
|
4007
4007
|
const m = textMatrix(layer);
|
|
4008
4008
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
4009
4009
|
ctx.clearRect(0, 0, region.width, region.height);
|
|
@@ -4015,8 +4015,8 @@ function renderOnCanvas(layer, shaper, region, env) {
|
|
|
4015
4015
|
ctx.globalAlpha = _nullishCoalesce(f.style.opacity, () => ( 1));
|
|
4016
4016
|
const s = layer.text.slice(f.start, f.end);
|
|
4017
4017
|
if (!f.spaced) shaper.draw(ctx, s, f.font, f.x, f.y);
|
|
4018
|
-
else for (let k = 0; k < s.length; k++) if (!
|
|
4019
|
-
for (const d of
|
|
4018
|
+
else for (let k = 0; k < s.length; k++) if (!_chunkHRI3ZMDMcjs.isTextSpace.call(void 0, s[k])) shaper.draw(ctx, s[k], f.font, f.x + f.carets[k], f.y);
|
|
4019
|
+
for (const d of _chunkHRI3ZMDMcjs.textDecorations.call(void 0, f, l)) ctx.fillRect(d.x, d.y, d.width, d.height);
|
|
4020
4020
|
}
|
|
4021
4021
|
}
|
|
4022
4022
|
ctx.globalAlpha = 1;
|
|
@@ -4027,7 +4027,7 @@ function renderOnCanvas(layer, shaper, region, env) {
|
|
|
4027
4027
|
function renderText(layer, env) {
|
|
4028
4028
|
const shaper = env.shaper;
|
|
4029
4029
|
if (!shaper || !shaper.outline && !shaper.draw) return null;
|
|
4030
|
-
const layout =
|
|
4030
|
+
const layout = _chunkHRI3ZMDMcjs.layoutText.call(void 0, layer, shaper);
|
|
4031
4031
|
const ink = inkBounds(layout);
|
|
4032
4032
|
const clip = { x: -TEXT_RENDER_MARGIN, y: -TEXT_RENDER_MARGIN, width: env.width + 2 * TEXT_RENDER_MARGIN, height: env.height + 2 * TEXT_RENDER_MARGIN };
|
|
4033
4033
|
const region = ink ? intersect2(docRect(ink, textMatrix(layer)), clip) : null;
|
|
@@ -4127,7 +4127,7 @@ function patchParagraphStyle(base, patch, path = "paragraph") {
|
|
|
4127
4127
|
continue;
|
|
4128
4128
|
}
|
|
4129
4129
|
const value = k === "autoLeading" ? num(v, `${path}.${k}`, 0.1, 10) : num(v, `${path}.${k}`, -1e4, 1e4);
|
|
4130
|
-
if (k === "autoLeading" && value ===
|
|
4130
|
+
if (k === "autoLeading" && value === _chunkHRI3ZMDMcjs.DEFAULT_AUTO_LEADING || k !== "autoLeading" && value === 0) delete o[k];
|
|
4131
4131
|
else o[k] = value;
|
|
4132
4132
|
} else fail3(`${path}.${k} is not a paragraph style field; use ${PARAGRAPH_STYLE_FIELDS.join(", ")}.`);
|
|
4133
4133
|
}
|
|
@@ -4164,14 +4164,14 @@ function createTypeLayer(init, env, id = newLayerId(), lenient = false) {
|
|
|
4164
4164
|
opacity: 1,
|
|
4165
4165
|
blend: "normal",
|
|
4166
4166
|
text: text3,
|
|
4167
|
-
runs:
|
|
4168
|
-
paragraphs:
|
|
4167
|
+
runs: _chunkHRI3ZMDMcjs.fitRuns.call(void 0, init.runs, text3.length, _chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE),
|
|
4168
|
+
paragraphs: _chunkHRI3ZMDMcjs.fitParagraphRuns.call(void 0, _nullishCoalesce(init.paragraphs, () => ( [{ length: text3.length, style: {} }])), text3),
|
|
4169
4169
|
frame: init.frame,
|
|
4170
4170
|
surface: _chunkCWM3CUUXcjs.emptySurface.call(void 0, 4),
|
|
4171
4171
|
offset: { x: 0, y: 0 }
|
|
4172
4172
|
};
|
|
4173
|
-
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _61 => _61.runs, 'access', _62 => _62[0], 'optionalAccess', _63 => _63.style]), () => (
|
|
4174
|
-
if (init.transform && !
|
|
4173
|
+
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([init, 'access', _61 => _61.runs, 'access', _62 => _62[0], 'optionalAccess', _63 => _63.style]), () => ( _chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE)) }];
|
|
4174
|
+
if (init.transform && !_chunkHRI3ZMDMcjs.isIdentityMatrix.call(void 0, init.transform)) layer.transform = init.transform;
|
|
4175
4175
|
if (lenient && !renderText(layer, env)) return { ...layer, rendering: "stored" };
|
|
4176
4176
|
return rerenderText(layer, env);
|
|
4177
4177
|
}
|
|
@@ -4181,24 +4181,24 @@ function updateTypeLayer(layers, id, change, env, action = "edit it") {
|
|
|
4181
4181
|
const patch = change(current);
|
|
4182
4182
|
const next = { ...current, ...patch };
|
|
4183
4183
|
if (!("annotation" in patch)) delete next.annotation;
|
|
4184
|
-
if ("text" in patch || "runs" in patch) next.runs =
|
|
4185
|
-
if (!next.runs.length) next.runs = [{ length: 0, style:
|
|
4186
|
-
if ("text" in patch || "paragraphs" in patch) next.paragraphs =
|
|
4184
|
+
if ("text" in patch || "runs" in patch) next.runs = _chunkHRI3ZMDMcjs.fitRuns.call(void 0, next.runs, next.text.length, _nullishCoalesce(_optionalChain([current, 'access', _64 => _64.runs, 'access', _65 => _65[0], 'optionalAccess', _66 => _66.style]), () => ( _chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE)));
|
|
4185
|
+
if (!next.runs.length) next.runs = [{ length: 0, style: _chunkHRI3ZMDMcjs.styleAt.call(void 0, current.runs, 0, _chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE) }];
|
|
4186
|
+
if ("text" in patch || "paragraphs" in patch) next.paragraphs = _chunkHRI3ZMDMcjs.fitParagraphRuns.call(void 0, next.paragraphs, next.text);
|
|
4187
4187
|
const rendered = rerenderText(next, env);
|
|
4188
4188
|
return { layers: _chunkHGTDMKNEcjs.mapLayer.call(void 0, layers, id, () => rendered), layer: rendered };
|
|
4189
4189
|
}
|
|
4190
4190
|
function replaceTextRange(layer, start, end, insert) {
|
|
4191
4191
|
const text3 = layer.text.slice(0, start) + insert + layer.text.slice(end);
|
|
4192
|
-
const style =
|
|
4193
|
-
const runs =
|
|
4194
|
-
const pstyle =
|
|
4195
|
-
const paragraphs =
|
|
4196
|
-
return { text: text3, runs, paragraphs:
|
|
4192
|
+
const style = _chunkHRI3ZMDMcjs.styleAt.call(void 0, layer.runs, start > 0 && start === layer.text.length ? start - 1 : start, _chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE);
|
|
4193
|
+
const runs = _chunkHRI3ZMDMcjs.spliceRuns.call(void 0, layer.runs, start, end, insert.length, style);
|
|
4194
|
+
const pstyle = _chunkHRI3ZMDMcjs.styleAt.call(void 0, layer.paragraphs, start, {});
|
|
4195
|
+
const paragraphs = _chunkHRI3ZMDMcjs.spliceRuns.call(void 0, layer.paragraphs, start, end, insert.length, pstyle);
|
|
4196
|
+
return { text: text3, runs, paragraphs: _chunkHRI3ZMDMcjs.fitParagraphRuns.call(void 0, paragraphs, text3) };
|
|
4197
4197
|
}
|
|
4198
4198
|
function transformTypeLayer(layer, m) {
|
|
4199
|
-
const t =
|
|
4199
|
+
const t = _chunkHRI3ZMDMcjs.multiplyMatrices.call(void 0, textMatrix(layer), m);
|
|
4200
4200
|
const next = { ...layer };
|
|
4201
|
-
if (
|
|
4201
|
+
if (_chunkHRI3ZMDMcjs.isIdentityMatrix.call(void 0, t)) delete next.transform;
|
|
4202
4202
|
else next.transform = t;
|
|
4203
4203
|
delete next.annotation;
|
|
4204
4204
|
return next;
|
|
@@ -4206,7 +4206,7 @@ function transformTypeLayer(layer, m) {
|
|
|
4206
4206
|
function typeFrame(layer, shaper) {
|
|
4207
4207
|
if (layer.frame.kind === "box") return { x: 0, y: 0, width: layer.frame.width, height: layer.frame.height };
|
|
4208
4208
|
if (!shaper) return fail3("Type layers need a text shaper to be measured; none is set here.");
|
|
4209
|
-
const b =
|
|
4209
|
+
const b = _chunkHRI3ZMDMcjs.layoutText.call(void 0, layer, shaper).bounds;
|
|
4210
4210
|
return { x: b.x, y: b.y, width: Math.max(b.width, 1), height: Math.max(b.height, 1) };
|
|
4211
4211
|
}
|
|
4212
4212
|
function typeAsPixelLayer(layer) {
|
|
@@ -4214,7 +4214,7 @@ function typeAsPixelLayer(layer) {
|
|
|
4214
4214
|
return { ...rest, type: "pixel", surface: layer.surface, offset: { x: 0, y: 0 } };
|
|
4215
4215
|
}
|
|
4216
4216
|
function toTextSpace(layer, p) {
|
|
4217
|
-
return
|
|
4217
|
+
return _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, _chunkHRI3ZMDMcjs.invertMatrix.call(void 0, textMatrix(layer)), p);
|
|
4218
4218
|
}
|
|
4219
4219
|
function typeFromAnnotation(a) {
|
|
4220
4220
|
if (a.type !== "text") return null;
|
|
@@ -4228,7 +4228,7 @@ function typeFromAnnotation(a) {
|
|
|
4228
4228
|
if (op !== 1) style.opacity = op;
|
|
4229
4229
|
const text3 = t.text.replace(/\r?\n|\r/g, " ");
|
|
4230
4230
|
const translate = [1, 0, 0, 1, t.x, t.y];
|
|
4231
|
-
const transform = t.rotation ?
|
|
4231
|
+
const transform = t.rotation ? _chunkHRI3ZMDMcjs.multiplyMatrices.call(void 0, translate, _chunkHRI3ZMDMcjs.rotateMatrix.call(void 0, t.rotation, { x: t.x, y: t.y })) : translate;
|
|
4232
4232
|
return { text: text3, runs: [{ length: text3.length, style }], frame: { kind: "point", origin: "top" }, transform };
|
|
4233
4233
|
}
|
|
4234
4234
|
function annotationOfType(layer) {
|
|
@@ -4562,7 +4562,7 @@ function identityTransform(box2) {
|
|
|
4562
4562
|
}
|
|
4563
4563
|
function cornersFromMatrix(box2, m) {
|
|
4564
4564
|
const q2 = _chunkQT26RHKKcjs.boxQuad.call(void 0, box2);
|
|
4565
|
-
return [
|
|
4565
|
+
return [_chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, q2[0]), _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, q2[1]), _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, q2[2]), _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, q2[3])];
|
|
4566
4566
|
}
|
|
4567
4567
|
function matrixFromCorners(box2, corners, eps = 1e-6) {
|
|
4568
4568
|
const [tl, tr, br, bl] = corners;
|
|
@@ -4579,7 +4579,7 @@ function transformHomography(geometry) {
|
|
|
4579
4579
|
function hasWarp(geometry) {
|
|
4580
4580
|
const w = geometry.warp;
|
|
4581
4581
|
if (!w) return false;
|
|
4582
|
-
const id =
|
|
4582
|
+
const id = _chunkHRI3ZMDMcjs.identityWarpMesh.call(void 0, geometry.box, w.us.length - 1, w.vs.length - 1);
|
|
4583
4583
|
if (id.points.length !== w.points.length || id.us.some((u, i) => Math.abs(u - w.us[i]) > 1e-12) || id.vs.some((v, i) => Math.abs(v - w.vs[i]) > 1e-12)) return true;
|
|
4584
4584
|
return w.points.some((p, i) => Math.abs(p.x - id.points[i].x) > 1e-6 || Math.abs(p.y - id.points[i].y) > 1e-6);
|
|
4585
4585
|
}
|
|
@@ -4594,7 +4594,7 @@ function transformMap(geometry) {
|
|
|
4594
4594
|
const { box: box2 } = geometry;
|
|
4595
4595
|
const warp = hasWarp(geometry) ? geometry.warp : null;
|
|
4596
4596
|
if (!warp) return (p) => _chunkQT26RHKKcjs.applyHomography.call(void 0, h, p);
|
|
4597
|
-
return (p) => _chunkQT26RHKKcjs.applyHomography.call(void 0, h,
|
|
4597
|
+
return (p) => _chunkQT26RHKKcjs.applyHomography.call(void 0, h, _chunkHRI3ZMDMcjs.evalWarpMesh.call(void 0, warp, (p.x - box2.x) / box2.width, (p.y - box2.y) / box2.height));
|
|
4598
4598
|
}
|
|
4599
4599
|
function transformedPoint(geometry, fx, fy) {
|
|
4600
4600
|
const f = transformMap(geometry);
|
|
@@ -4638,8 +4638,8 @@ function matrixFromParams(box2, params) {
|
|
|
4638
4638
|
const tx = Math.tan((_nullishCoalesce(params.skewX, () => ( 0))) * Math.PI / 180);
|
|
4639
4639
|
const ty = Math.tan((_nullishCoalesce(params.skewY, () => ( 0))) * Math.PI / 180);
|
|
4640
4640
|
const ref = referencePoint(box2, params.reference);
|
|
4641
|
-
const linear =
|
|
4642
|
-
return
|
|
4641
|
+
const linear = _chunkHRI3ZMDMcjs.multiplyMatrices.call(void 0, _chunkHRI3ZMDMcjs.multiplyMatrices.call(void 0, [1, ty, tx, 1, 0, 0], [sx, 0, 0, sy, 0, 0]), _chunkHRI3ZMDMcjs.rotateMatrix.call(void 0, _nullishCoalesce(params.rotate, () => ( 0))));
|
|
4642
|
+
return _chunkHRI3ZMDMcjs.multiplyMatrices.call(void 0, _chunkHRI3ZMDMcjs.matrixAbout.call(void 0, linear, ref), _chunkHRI3ZMDMcjs.translateMatrix.call(void 0, _nullishCoalesce(params.dx, () => ( 0)), _nullishCoalesce(params.dy, () => ( 0))));
|
|
4643
4643
|
}
|
|
4644
4644
|
function describeTransform(geometry, reference = "center") {
|
|
4645
4645
|
const m = hasWarp(geometry) ? null : matrixFromCorners(geometry.box, geometry.corners);
|
|
@@ -4656,7 +4656,7 @@ function describeTransform(geometry, reference = "center") {
|
|
|
4656
4656
|
const shear = sxAbs ? (a * c + b * d) / sxAbs : 0;
|
|
4657
4657
|
const sy = sxAbs ? (a * d - b * c) / sxAbs : 0;
|
|
4658
4658
|
const skew = sxAbs ? Math.atan(shear / sxAbs) * 180 / Math.PI : 0;
|
|
4659
|
-
const at =
|
|
4659
|
+
const at = _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, ref);
|
|
4660
4660
|
const clean = (v) => Math.abs(v) < 1e-9 ? 0 : v;
|
|
4661
4661
|
return {
|
|
4662
4662
|
affine: true,
|
|
@@ -4674,24 +4674,24 @@ function applyParams(geometry, params) {
|
|
|
4674
4674
|
const ref = params.reference && typeof params.reference === "object" ? params.reference : anchorPoint(geometry, _nullishCoalesce(params.reference, () => ( "center")));
|
|
4675
4675
|
const m = matrixFromParams({ x: ref.x, y: ref.y, width: 0, height: 0 }, { ...params, reference: ref });
|
|
4676
4676
|
const c = geometry.corners;
|
|
4677
|
-
return [
|
|
4677
|
+
return [_chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, c[0]), _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, c[1]), _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, c[2]), _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, c[3])];
|
|
4678
4678
|
}
|
|
4679
4679
|
function flipCorners(geometry, axis) {
|
|
4680
4680
|
const c = anchorPoint(geometry, "center");
|
|
4681
4681
|
const m = axis === "horizontal" ? [-1, 0, 0, 1, 2 * c.x, 0] : [1, 0, 0, -1, 0, 2 * c.y];
|
|
4682
4682
|
const q2 = geometry.corners;
|
|
4683
|
-
return [
|
|
4683
|
+
return [_chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, q2[0]), _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, q2[1]), _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, q2[2]), _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, m, q2[3])];
|
|
4684
4684
|
}
|
|
4685
4685
|
function boxPointOf(geometry, p) {
|
|
4686
4686
|
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
4687
|
-
if (m) return
|
|
4687
|
+
if (m) return _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, _chunkHRI3ZMDMcjs.invertMatrix.call(void 0, m), p);
|
|
4688
4688
|
return null;
|
|
4689
4689
|
}
|
|
4690
4690
|
function presetWarp(box2, preset) {
|
|
4691
|
-
return
|
|
4691
|
+
return _chunkHRI3ZMDMcjs.warpPresetMesh.call(void 0, preset, box2);
|
|
4692
4692
|
}
|
|
4693
4693
|
function isValidWarp(mesh) {
|
|
4694
|
-
return
|
|
4694
|
+
return _chunkHRI3ZMDMcjs.isValidWarpMesh.call(void 0, mesh);
|
|
4695
4695
|
}
|
|
4696
4696
|
function geometryHomography(geometry) {
|
|
4697
4697
|
const m = matrixFromCorners(geometry.box, geometry.corners);
|
|
@@ -4957,7 +4957,7 @@ function normalizePlacement(raw, contents) {
|
|
|
4957
4957
|
}
|
|
4958
4958
|
const out = { corners: c.map((p) => ({ x: p.x, y: p.y })) };
|
|
4959
4959
|
if (raw.warp) {
|
|
4960
|
-
if (!
|
|
4960
|
+
if (!_chunkHRI3ZMDMcjs.isValidWarpMesh.call(void 0, raw.warp)) fail4("warp must be a mesh with us and vs (knots from 0 to 1, increasing) and (3\xB7columns + 1) \xD7 (3\xB7rows + 1) finite points in contents pixels.");
|
|
4961
4961
|
out.warp = { us: [...raw.warp.us], vs: [...raw.warp.vs], points: raw.warp.points.map((p) => ({ x: p.x, y: p.y })) };
|
|
4962
4962
|
}
|
|
4963
4963
|
if (raw.interpolation !== void 0) {
|
|
@@ -5060,7 +5060,7 @@ function translateLayer(layer, dx, dy) {
|
|
|
5060
5060
|
case "shape": {
|
|
5061
5061
|
const next = {
|
|
5062
5062
|
...layer,
|
|
5063
|
-
components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }),
|
|
5063
|
+
components: transformShapeComponents(layer.components, (p) => ({ x: p.x + dx, y: p.y + dy }), _chunkHRI3ZMDMcjs.translateMatrix.call(void 0, dx, dy)),
|
|
5064
5064
|
surface: _chunkCWM3CUUXcjs.translateSurface.call(void 0, layer.surface, dx, dy),
|
|
5065
5065
|
mask: moveMask(layer.mask)
|
|
5066
5066
|
};
|
|
@@ -5069,7 +5069,7 @@ function translateLayer(layer, dx, dy) {
|
|
|
5069
5069
|
return next;
|
|
5070
5070
|
}
|
|
5071
5071
|
case "type": {
|
|
5072
|
-
const next = { ...transformTypeLayer(layer,
|
|
5072
|
+
const next = { ...transformTypeLayer(layer, _chunkHRI3ZMDMcjs.translateMatrix.call(void 0, dx, dy)), surface: _chunkCWM3CUUXcjs.translateSurface.call(void 0, layer.surface, dx, dy), mask: moveMask(layer.mask) };
|
|
5073
5073
|
if (!next.mask) delete next.mask;
|
|
5074
5074
|
return next;
|
|
5075
5075
|
}
|
|
@@ -5255,7 +5255,7 @@ function refitPlacement(layer, contents) {
|
|
|
5255
5255
|
});
|
|
5256
5256
|
const out = { corners: pts };
|
|
5257
5257
|
if (layer.placement.interpolation) out.interpolation = layer.placement.interpolation;
|
|
5258
|
-
if (layer.placement.warp) out.warp =
|
|
5258
|
+
if (layer.placement.warp) out.warp = _chunkHRI3ZMDMcjs.mapWarpMeshPoints.call(void 0, layer.placement.warp, (p) => ({ x: p.x * W1 / W0, y: p.y * H1 / H0 }));
|
|
5259
5259
|
return out;
|
|
5260
5260
|
}
|
|
5261
5261
|
function normalizeSmartFilter(raw, id = newLayerId("flt")) {
|
|
@@ -5569,7 +5569,7 @@ function readType(r, base, ctx) {
|
|
|
5569
5569
|
const text3 = normalizeText(_nullishCoalesce(r.text, () => ( "")));
|
|
5570
5570
|
const runs = (Array.isArray(r.runs) ? r.runs : []).map((run, i) => ({
|
|
5571
5571
|
length: Math.max(0, Math.floor(num2(_optionalChain([run, 'optionalAccess', _139 => _139.length]), 0, 1e9, 0))),
|
|
5572
|
-
style: patchTextStyle(
|
|
5572
|
+
style: patchTextStyle(_chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE, _optionalChain([run, 'optionalAccess', _140 => _140.style]) && typeof run.style === "object" ? run.style : {}, `runs[${i}].style`)
|
|
5573
5573
|
}));
|
|
5574
5574
|
const paragraphs = (Array.isArray(r.paragraphs) ? r.paragraphs : []).map((p, i) => ({
|
|
5575
5575
|
length: Math.max(0, Math.floor(num2(_optionalChain([p, 'optionalAccess', _141 => _141.length]), 0, 1e9, 0))),
|
|
@@ -5582,13 +5582,13 @@ function readType(r, base, ctx) {
|
|
|
5582
5582
|
...base,
|
|
5583
5583
|
type: "type",
|
|
5584
5584
|
text: text3,
|
|
5585
|
-
runs:
|
|
5586
|
-
paragraphs:
|
|
5585
|
+
runs: _chunkHRI3ZMDMcjs.fitRuns.call(void 0, runs, text3.length, _chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE),
|
|
5586
|
+
paragraphs: _chunkHRI3ZMDMcjs.fitParagraphRuns.call(void 0, paragraphs.length ? paragraphs : [{ length: text3.length, style: {} }], text3),
|
|
5587
5587
|
frame,
|
|
5588
5588
|
surface: _chunkCWM3CUUXcjs.emptySurface.call(void 0, 4),
|
|
5589
5589
|
offset: { x: 0, y: 0 }
|
|
5590
5590
|
};
|
|
5591
|
-
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _145 => _145[0], 'optionalAccess', _146 => _146.style]), () => (
|
|
5591
|
+
if (!layer.runs.length) layer.runs = [{ length: 0, style: _nullishCoalesce(_optionalChain([runs, 'access', _145 => _145[0], 'optionalAccess', _146 => _146.style]), () => ( _chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE)) }];
|
|
5592
5592
|
if (m) layer.transform = m;
|
|
5593
5593
|
if (r.antiAlias === false) layer.antiAlias = false;
|
|
5594
5594
|
if (typeof r.fillOpacity === "number" && r.fillOpacity !== 1) layer.fillOpacity = num2(r.fillOpacity, 0, 1, 1);
|
|
@@ -6041,7 +6041,7 @@ function readSmartObject(r, base, ctx) {
|
|
|
6041
6041
|
let placement;
|
|
6042
6042
|
try {
|
|
6043
6043
|
const raw = { corners: p.corners };
|
|
6044
|
-
if (p.warp &&
|
|
6044
|
+
if (p.warp && _chunkHRI3ZMDMcjs.isValidWarpMesh.call(void 0, p.warp)) raw.warp = p.warp;
|
|
6045
6045
|
if (_chunkHGTDMKNEcjs.isInterpolation.call(void 0, p.interpolation)) raw.interpolation = p.interpolation;
|
|
6046
6046
|
placement = normalizePlacement(raw, contents);
|
|
6047
6047
|
} catch (e) {
|
|
@@ -7024,7 +7024,7 @@ function vectorBlockForComponents(components, inverted, width, height, flags = 0
|
|
|
7024
7024
|
const fr = (p) => ({ x: p.x / w, y: p.y / h });
|
|
7025
7025
|
const subpaths = [];
|
|
7026
7026
|
components.forEach((c, ci) => {
|
|
7027
|
-
|
|
7027
|
+
_chunkHRI3ZMDMcjs.expandVectorCorners.call(void 0, c.subpaths).forEach((sp, si) => {
|
|
7028
7028
|
if (!sp.anchors.length) return;
|
|
7029
7029
|
subpaths.push({
|
|
7030
7030
|
closed: sp.closed,
|
|
@@ -7746,7 +7746,7 @@ function merged(levels) {
|
|
|
7746
7746
|
function charStyle(d, fonts, notes) {
|
|
7747
7747
|
const n = (k) => eNum(eGet(d, k));
|
|
7748
7748
|
const flag = (k) => eBool(eGet(d, k));
|
|
7749
|
-
const s = { ...
|
|
7749
|
+
const s = { ..._chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE };
|
|
7750
7750
|
const fi = n("Font");
|
|
7751
7751
|
const ps = fi !== void 0 ? fonts[fi] : void 0;
|
|
7752
7752
|
if (ps) {
|
|
@@ -7829,7 +7829,7 @@ function typeFromTySh(data, notes) {
|
|
|
7829
7829
|
}
|
|
7830
7830
|
const edText = _nullishCoalesce(eStr(ePath(_nullishCoalesce(engine, () => ( void 0)), ["EngineDict", "Editor", "Text"])), () => ( ""));
|
|
7831
7831
|
const text3 = (_nullishCoalesce(txt, () => ( edText.replace(/\r$/, "")))).replace(/\r\n?/g, "\n");
|
|
7832
|
-
let runs = [{ length: text3.length, style: { ...
|
|
7832
|
+
let runs = [{ length: text3.length, style: { ..._chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE } }];
|
|
7833
7833
|
let paragraphs = [{ length: text3.length, style: {} }];
|
|
7834
7834
|
let frame = { kind: "point" };
|
|
7835
7835
|
let transform = t.transform;
|
|
@@ -7885,14 +7885,14 @@ function typeFromTySh(data, notes) {
|
|
|
7885
7885
|
const b = eArray(ePath(shape, ["Cookie", "Photoshop", "BoxBounds"])).map((v) => _nullishCoalesce(eNum(v), () => ( 0)));
|
|
7886
7886
|
if (b.length === 4 && b[2] > b[0] && b[3] > b[1]) {
|
|
7887
7887
|
frame = { kind: "box", width: b[2] - b[0], height: b[3] - b[1] };
|
|
7888
|
-
transform =
|
|
7888
|
+
transform = _chunkHRI3ZMDMcjs.multiplyMatrices.call(void 0, [1, 0, 0, 1, b[0], b[1]], t.transform);
|
|
7889
7889
|
}
|
|
7890
7890
|
}
|
|
7891
7891
|
}
|
|
7892
7892
|
return {
|
|
7893
7893
|
text: text3,
|
|
7894
|
-
runs:
|
|
7895
|
-
paragraphs:
|
|
7894
|
+
runs: _chunkHRI3ZMDMcjs.fitRuns.call(void 0, runs, text3.length, _chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE),
|
|
7895
|
+
paragraphs: _chunkHRI3ZMDMcjs.fitParagraphRuns.call(void 0, paragraphs, text3),
|
|
7896
7896
|
frame,
|
|
7897
7897
|
transform,
|
|
7898
7898
|
antiAlias,
|
|
@@ -7966,7 +7966,7 @@ function buildEngineData(layer, template) {
|
|
|
7966
7966
|
fonts.push(ps);
|
|
7967
7967
|
return fonts.length - 1;
|
|
7968
7968
|
};
|
|
7969
|
-
const runs =
|
|
7969
|
+
const runs = _chunkHRI3ZMDMcjs.fitRuns.call(void 0, layer.runs, layer.text.length, _chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE);
|
|
7970
7970
|
const sruns = [];
|
|
7971
7971
|
const slens = [];
|
|
7972
7972
|
runs.forEach((r, i) => {
|
|
@@ -7974,10 +7974,10 @@ function buildEngineData(layer, template) {
|
|
|
7974
7974
|
slens.push(E.int(r.length + (i === runs.length - 1 ? 1 : 0)));
|
|
7975
7975
|
});
|
|
7976
7976
|
if (!runs.length) {
|
|
7977
|
-
sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(
|
|
7977
|
+
sruns.push(E.dict([["StyleSheet", E.dict([["StyleSheetData", styleSheetData(_chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE, fontIndex(postScriptFor(_chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE)))]])]]));
|
|
7978
7978
|
slens.push(E.int(1));
|
|
7979
7979
|
}
|
|
7980
|
-
const paras =
|
|
7980
|
+
const paras = _chunkHRI3ZMDMcjs.fitParagraphRuns.call(void 0, layer.paragraphs, layer.text);
|
|
7981
7981
|
const pruns = [];
|
|
7982
7982
|
const plens = [];
|
|
7983
7983
|
paras.forEach((p, i) => {
|
|
@@ -8033,7 +8033,7 @@ function buildEngineData(layer, template) {
|
|
|
8033
8033
|
eSet(e, key, rd);
|
|
8034
8034
|
}
|
|
8035
8035
|
eSet(rd, "FontSet", fontSet);
|
|
8036
|
-
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _211 => _211[0], 'optionalAccess', _212 => _212.style]), () => (
|
|
8036
|
+
if (!eGet(rd, "StyleSheetSet")) eSet(rd, "StyleSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["StyleSheetData", styleSheetData(_nullishCoalesce(_optionalChain([runs, 'access', _211 => _211[0], 'optionalAccess', _212 => _212.style]), () => ( _chunkHRI3ZMDMcjs.DEFAULT_TEXT_STYLE)), 0)]])]));
|
|
8037
8037
|
if (!eGet(rd, "ParagraphSheetSet")) eSet(rd, "ParagraphSheetSet", E.array([E.dict([["Name", E.str("Normal RGB")], ["DefaultStyleSheet", E.int(0)], ["Properties", paragraphProperties({})]])]));
|
|
8038
8038
|
if (!eGet(rd, "TheNormalStyleSheet")) eSet(rd, "TheNormalStyleSheet", E.int(0));
|
|
8039
8039
|
if (!eGet(rd, "TheNormalParagraphSheet")) eSet(rd, "TheNormalParagraphSheet", E.int(0));
|
|
@@ -8044,13 +8044,13 @@ function inkBounds2(layer) {
|
|
|
8044
8044
|
if (layer.frame.kind === "box") return [0, 0, layer.frame.width, layer.frame.height];
|
|
8045
8045
|
const b = _chunkCWM3CUUXcjs.contentBounds.call(void 0, layer.surface);
|
|
8046
8046
|
if (!b) return [0, 0, 0, 0];
|
|
8047
|
-
const inv =
|
|
8047
|
+
const inv = _chunkHRI3ZMDMcjs.invertMatrix.call(void 0, textMatrix(layer));
|
|
8048
8048
|
const pts = [
|
|
8049
8049
|
{ x: b.x, y: b.y },
|
|
8050
8050
|
{ x: b.x + b.width, y: b.y },
|
|
8051
8051
|
{ x: b.x + b.width, y: b.y + b.height },
|
|
8052
8052
|
{ x: b.x, y: b.y + b.height }
|
|
8053
|
-
].map((p) =>
|
|
8053
|
+
].map((p) => _chunkHRI3ZMDMcjs.applyMatrix.call(void 0, inv, p));
|
|
8054
8054
|
return [Math.min(...pts.map((p) => p.x)), Math.min(...pts.map((p) => p.y)), Math.max(...pts.map((p) => p.x)), Math.max(...pts.map((p) => p.y))];
|
|
8055
8055
|
}
|
|
8056
8056
|
function tyShForLayer(layer) {
|
|
@@ -8517,7 +8517,7 @@ function filterMaskItem(placed, mask, area) {
|
|
|
8517
8517
|
var warpStyleOf = (name) => {
|
|
8518
8518
|
if (!name.startsWith("warp")) return null;
|
|
8519
8519
|
const s = _optionalChain([name, 'access', _226 => _226[4], 'optionalAccess', _227 => _227.toLowerCase, 'call', _228 => _228()]) + name.slice(5);
|
|
8520
|
-
return
|
|
8520
|
+
return _chunkHRI3ZMDMcjs.WARP_STYLES.includes(s) ? s : null;
|
|
8521
8521
|
};
|
|
8522
8522
|
function warpFromDescriptor(w, contents) {
|
|
8523
8523
|
const full = { x: 0, y: 0, width: contents.width, height: contents.height };
|
|
@@ -8547,7 +8547,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
8547
8547
|
} else {
|
|
8548
8548
|
const style = warpStyleOf(styleName);
|
|
8549
8549
|
if (!style) return void 0;
|
|
8550
|
-
mesh =
|
|
8550
|
+
mesh = _chunkHRI3ZMDMcjs.warpPresetMesh.call(void 0,
|
|
8551
8551
|
{
|
|
8552
8552
|
style,
|
|
8553
8553
|
bend: _nullishCoalesce(descNumber(w, "warpValue"), () => ( 0)),
|
|
@@ -8562,7 +8562,7 @@ function warpFromDescriptor(w, contents) {
|
|
|
8562
8562
|
const same = Math.abs(bounds.x) < 1e-6 && Math.abs(bounds.y) < 1e-6 && Math.abs(bounds.width - contents.width) < 1e-6 && Math.abs(bounds.height - contents.height) < 1e-6;
|
|
8563
8563
|
if (!same) {
|
|
8564
8564
|
const m = mesh;
|
|
8565
|
-
mesh =
|
|
8565
|
+
mesh = _chunkHRI3ZMDMcjs.fitWarpMesh.call(void 0, (s, t) => _chunkHRI3ZMDMcjs.evalWarpMesh.call(void 0, m, (s * contents.width - bounds.x) / bounds.width, (t * contents.height - bounds.y) / bounds.height), [0, 1], [0, 1]);
|
|
8566
8566
|
}
|
|
8567
8567
|
return { mesh, frame };
|
|
8568
8568
|
}
|
|
@@ -10138,7 +10138,7 @@ function importSmart(ctx, rec, name, notes, props) {
|
|
|
10138
10138
|
if (placement && (size.width !== contents.width || size.height !== contents.height)) {
|
|
10139
10139
|
const kx = contents.width / size.width;
|
|
10140
10140
|
const ky = contents.height / size.height;
|
|
10141
|
-
if (placement.warp) placement = { ...placement, warp:
|
|
10141
|
+
if (placement.warp) placement = { ...placement, warp: _chunkHRI3ZMDMcjs.mapWarpMeshPoints.call(void 0, placement.warp, (p) => ({ x: p.x * kx, y: p.y * ky })) };
|
|
10142
10142
|
}
|
|
10143
10143
|
}
|
|
10144
10144
|
if (!contents || !placement) {
|
|
@@ -413,7 +413,7 @@ function readTools(provider) {
|
|
|
413
413
|
return typeof provider.tools === "function" ? provider.tools() : provider.tools;
|
|
414
414
|
}
|
|
415
415
|
function toDefinition2(name, tool) {
|
|
416
|
-
const { handler: _handler, name: _name, ...rest } = tool;
|
|
416
|
+
const { handler: _handler, name: _name, plan: _plan, playback: _playback, ...rest } = tool;
|
|
417
417
|
return { name, ...rest };
|
|
418
418
|
}
|
|
419
419
|
function errorResult(error) {
|
|
@@ -442,10 +442,11 @@ var ToolRegistry = (_class2 = class {
|
|
|
442
442
|
__init7() {this.capabilities = { tools: { listChanged: true } }}
|
|
443
443
|
__init8() {this.entries = []}
|
|
444
444
|
__init9() {this.listeners = /* @__PURE__ */ new Set()}
|
|
445
|
+
__init10() {this.middleware = []}
|
|
445
446
|
|
|
446
|
-
|
|
447
|
+
__init11() {this.timer = null}
|
|
447
448
|
|
|
448
|
-
constructor(options = {}) {;_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);
|
|
449
|
+
constructor(options = {}) {;_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);
|
|
449
450
|
this.options = {
|
|
450
451
|
namespaces: _nullishCoalesce(options.namespaces, () => ( "always")),
|
|
451
452
|
onCollision: _nullishCoalesce(options.onCollision, () => ( "namespace")),
|
|
@@ -502,6 +503,17 @@ var ToolRegistry = (_class2 = class {
|
|
|
502
503
|
this.notifyListChanged();
|
|
503
504
|
return true;
|
|
504
505
|
}
|
|
506
|
+
/**
|
|
507
|
+
* Adds a middleware that wraps every tool call (first added runs outermost), e.g. agent
|
|
508
|
+
* playback's `playback.middleware`. Returns a function that removes it.
|
|
509
|
+
*/
|
|
510
|
+
use(middleware) {
|
|
511
|
+
this.middleware.push(middleware);
|
|
512
|
+
return () => {
|
|
513
|
+
const index = this.middleware.indexOf(middleware);
|
|
514
|
+
if (index !== -1) this.middleware.splice(index, 1);
|
|
515
|
+
};
|
|
516
|
+
}
|
|
505
517
|
/** Registered provider ids in registration order. */
|
|
506
518
|
providerIds() {
|
|
507
519
|
return this.entries.map((e) => e.provider.id);
|
|
@@ -609,11 +621,16 @@ var ToolRegistry = (_class2 = class {
|
|
|
609
621
|
}
|
|
610
622
|
}
|
|
611
623
|
try {
|
|
612
|
-
const
|
|
624
|
+
const context = {
|
|
613
625
|
name,
|
|
614
626
|
providerId: found.provider.id,
|
|
615
|
-
signal: options.signal
|
|
616
|
-
|
|
627
|
+
signal: options.signal,
|
|
628
|
+
...options.actor ? { actor: options.actor } : {}
|
|
629
|
+
};
|
|
630
|
+
const call = { name, tool: found.tool, provider: found.provider, args: input, context };
|
|
631
|
+
const chain = [...this.middleware];
|
|
632
|
+
const run = async (i) => i < chain.length ? chain[i](call, () => run(i + 1)) : found.tool.handler(call.args, context);
|
|
633
|
+
const value = await run(0);
|
|
617
634
|
return toToolResult(value);
|
|
618
635
|
} catch (error) {
|
|
619
636
|
return errorResult({
|
|
@@ -896,6 +913,7 @@ function createMcpServer(registry, options) {
|
|
|
896
913
|
};
|
|
897
914
|
const readSkillPath = (path) => _nullishCoalesce(_optionalChain([skillFiles, 'optionalAccess', _24 => _24[path]]), () => ( _optionalChain([skillFiles, 'optionalAccess', _25 => _25[`./${path}`]])));
|
|
898
915
|
let initialized = false;
|
|
916
|
+
let actor;
|
|
899
917
|
let unsubscribe = null;
|
|
900
918
|
const running = /* @__PURE__ */ new Map();
|
|
901
919
|
const startNotifications = () => {
|
|
@@ -909,6 +927,10 @@ function createMcpServer(registry, options) {
|
|
|
909
927
|
const params = _nullishCoalesce(request.params, () => ( {}));
|
|
910
928
|
switch (request.method) {
|
|
911
929
|
case "initialize": {
|
|
930
|
+
const client = params.clientInfo;
|
|
931
|
+
if (client && typeof client.name === "string" && client.name) {
|
|
932
|
+
actor = { id: `mcp:${client.name}`, name: typeof client.title === "string" && client.title ? client.title : client.name };
|
|
933
|
+
}
|
|
912
934
|
const instructions = typeof options.instructions === "function" ? options.instructions(registry) : options.instructions;
|
|
913
935
|
const requested = String(_nullishCoalesce(params.protocolVersion, () => ( "")));
|
|
914
936
|
const protocolVersion = MCP_PROTOCOL_VERSIONS.includes(requested) ? requested : MCP_PROTOCOL_VERSIONS[0];
|
|
@@ -951,7 +973,7 @@ function createMcpServer(registry, options) {
|
|
|
951
973
|
const controller = new AbortController();
|
|
952
974
|
if (!isNotification) running.set(id, controller);
|
|
953
975
|
try {
|
|
954
|
-
const result = await registry.callTool(name, _nullishCoalesce(args, () => ( {})), { signal: controller.signal });
|
|
976
|
+
const result = await registry.callTool(name, _nullishCoalesce(args, () => ( {})), { signal: controller.signal, ...actor ? { actor } : {} });
|
|
955
977
|
if (controller.signal.aborted) return null;
|
|
956
978
|
return { jsonrpc: "2.0", id, result };
|
|
957
979
|
} finally {
|