@pixerate/editor 0.231.0 → 0.232.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 +25 -25
- package/dist/animation-editor/index.js +1 -1
- package/dist/canvas/index.cjs +7 -7
- package/dist/canvas/index.js +1 -1
- package/dist/{chunk-OPSK22DL.cjs → chunk-2K5TELHV.cjs} +19 -2
- package/dist/{chunk-CSM5T6SE.js → chunk-6QLTUGMO.js} +1 -1
- package/dist/{chunk-5T3H7CGG.cjs → chunk-A653N65Q.cjs} +7 -7
- package/dist/{chunk-SBPGIZQN.js → chunk-MUSZYMBX.js} +1 -1
- package/dist/{chunk-TCZ2J7PR.js → chunk-PQYDJ2AV.js} +18 -1
- package/dist/{chunk-C73U5UI3.cjs → chunk-RG4O6K2A.cjs} +14 -14
- package/dist/effects/conformance.d.cts +4 -1
- package/dist/effects/conformance.d.ts +4 -1
- package/dist/effects/errors.d.cts +6 -1
- package/dist/effects/errors.d.ts +6 -1
- package/dist/effects/fake-templates.d.cts +17 -0
- package/dist/effects/fake-templates.d.ts +17 -0
- package/dist/effects/fake.d.cts +6 -1
- package/dist/effects/fake.d.ts +6 -1
- package/dist/effects/index.cjs +537 -74
- package/dist/effects/index.d.cts +1 -0
- package/dist/effects/index.d.ts +1 -0
- package/dist/effects/index.js +466 -3
- package/dist/effects/templates.d.cts +56 -0
- package/dist/effects/templates.d.ts +56 -0
- package/dist/effects/types.d.cts +212 -0
- package/dist/effects/types.d.ts +212 -0
- package/dist/image-editor/controller.d.cts +12 -0
- package/dist/image-editor/controller.d.ts +12 -0
- package/dist/image-editor/index.cjs +189 -144
- package/dist/image-editor/index.js +48 -3
- package/dist/paint-editor/index.cjs +7 -7
- package/dist/paint-editor/index.js +2 -2
- package/dist/vector/index.cjs +6 -6
- package/dist/vector/index.js +1 -1
- package/dist/video-editor/index.cjs +329 -329
- package/dist/video-editor/index.js +3 -3
- package/package.json +1 -1
- package/skills/pixerate-animation-editor/SKILL.md +37 -0
|
@@ -744,7 +744,7 @@ import {
|
|
|
744
744
|
createEffectToolProvider,
|
|
745
745
|
linearToSrgb,
|
|
746
746
|
resolveEffectValues
|
|
747
|
-
} from "../chunk-
|
|
747
|
+
} from "../chunk-PQYDJ2AV.js";
|
|
748
748
|
import "../chunk-V2ZCJRDM.js";
|
|
749
749
|
import {
|
|
750
750
|
BrushstrokeCache,
|
|
@@ -7141,6 +7141,50 @@ var ImageEditorController = class {
|
|
|
7141
7141
|
const enc = encodeSurface(surface);
|
|
7142
7142
|
return enc ? enc.url : null;
|
|
7143
7143
|
}
|
|
7144
|
+
maskedImageCache = /* @__PURE__ */ new WeakMap();
|
|
7145
|
+
/**
|
|
7146
|
+
* A pixel layer's own pixels with its raster and vector masks applied, cropped to what shows: a
|
|
7147
|
+
* PNG data URL and its document bounds, or `null` for an unknown or non-pixel layer, or when
|
|
7148
|
+
* nothing shows. Opacity, blending, filters and effects are left out, as in `getLayerDataURL`.
|
|
7149
|
+
* Use it for a masked layer, whose stored pixels (a whole copy, for Separate Subject's subject)
|
|
7150
|
+
* are not what it shows.
|
|
7151
|
+
*/
|
|
7152
|
+
getMaskedLayerImage(id) {
|
|
7153
|
+
const layer = this.getLayer(id);
|
|
7154
|
+
if (!layer || layer.type !== "pixel") return null;
|
|
7155
|
+
const surface = this.surfaceOf(layer);
|
|
7156
|
+
const cached = this.maskedImageCache.get(layer);
|
|
7157
|
+
if (cached && cached.surface === surface) return cached.image;
|
|
7158
|
+
const b = this.getLayerBounds(id);
|
|
7159
|
+
let image = null;
|
|
7160
|
+
if (b) {
|
|
7161
|
+
const content = { ...layer, visible: true, opacity: 1, blend: "normal" };
|
|
7162
|
+
delete content.clipped;
|
|
7163
|
+
delete content.fillOpacity;
|
|
7164
|
+
delete content.effects;
|
|
7165
|
+
delete content.filters;
|
|
7166
|
+
const data = this.compositor.composite([content], b, this.compositorSources());
|
|
7167
|
+
let x0 = b.width, y0 = b.height, x1 = -1, y1 = -1;
|
|
7168
|
+
for (let y = 0; y < b.height; y++) {
|
|
7169
|
+
for (let x = 0; x < b.width; x++) {
|
|
7170
|
+
if (!data[(y * b.width + x) * 4 + 3]) continue;
|
|
7171
|
+
if (x < x0) x0 = x;
|
|
7172
|
+
if (x > x1) x1 = x;
|
|
7173
|
+
if (y < y0) y0 = y;
|
|
7174
|
+
if (y > y1) y1 = y;
|
|
7175
|
+
}
|
|
7176
|
+
}
|
|
7177
|
+
if (x1 >= 0) {
|
|
7178
|
+
const w = x1 - x0 + 1;
|
|
7179
|
+
const h = y1 - y0 + 1;
|
|
7180
|
+
const out = new Uint8ClampedArray(w * h * 4);
|
|
7181
|
+
for (let y = 0; y < h; y++) out.set(data.subarray(((y0 + y) * b.width + x0) * 4, ((y0 + y) * b.width + x0 + w) * 4), y * w * 4);
|
|
7182
|
+
image = { url: pngDataUrl(w, h, out, 4), bounds: { x: b.x + x0, y: b.y + y0, width: w, height: h } };
|
|
7183
|
+
}
|
|
7184
|
+
}
|
|
7185
|
+
this.maskedImageCache.set(layer, { surface, image });
|
|
7186
|
+
return image;
|
|
7187
|
+
}
|
|
7144
7188
|
/**
|
|
7145
7189
|
* Composites the layer stack in document space without a canvas (annotation layers need one
|
|
7146
7190
|
* and are left out): `rect` (default: the canvas) as RGBA, straight alpha. Crop, rotation and
|
|
@@ -20820,7 +20864,8 @@ function extractNormalizedLayerItems(controller, fallbackImageUrl = "") {
|
|
|
20820
20864
|
const imgW = state.imageDimensions?.width || 1;
|
|
20821
20865
|
const imgH = state.imageDimensions?.height || 1;
|
|
20822
20866
|
return ctrlLayers.map((l) => {
|
|
20823
|
-
const
|
|
20867
|
+
const masked = l.type === "pixel" && (l.mask || l.vectorMask) ? controller.getMaskedLayerImage(l.id) : null;
|
|
20868
|
+
const bounds = masked?.bounds || controller.getLayerBounds(l.id) || {
|
|
20824
20869
|
x: 0,
|
|
20825
20870
|
y: 0,
|
|
20826
20871
|
width: imgW,
|
|
@@ -20828,7 +20873,7 @@ function extractNormalizedLayerItems(controller, fallbackImageUrl = "") {
|
|
|
20828
20873
|
};
|
|
20829
20874
|
const sLayer = sLayerMap.get(l.id);
|
|
20830
20875
|
const assetKey = sLayer?.asset;
|
|
20831
|
-
const layerDataUrl = assetKey && assets[assetKey] || assets[l.id] || (sLayer?.source === "document" ? fallbackImageUrl : "");
|
|
20876
|
+
const layerDataUrl = masked?.url || assetKey && assets[assetKey] || assets[l.id] || (sLayer?.source === "document" ? fallbackImageUrl : "");
|
|
20832
20877
|
return {
|
|
20833
20878
|
id: l.id,
|
|
20834
20879
|
name: l.name || "Untitled Layer",
|
|
@@ -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; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8; var _class9; var _class10; var _class11; var _class12;
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkA653N65Qcjs = require('../chunk-A653N65Q.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -137,7 +137,7 @@ require('../chunk-NM3G4VQT.cjs');
|
|
|
137
137
|
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
var
|
|
140
|
+
var _chunk2K5TELHVcjs = require('../chunk-2K5TELHV.cjs');
|
|
141
141
|
require('../chunk-WOFXZ3XU.cjs');
|
|
142
142
|
|
|
143
143
|
|
|
@@ -3213,7 +3213,7 @@ function timeLapseVideo(frameCount, width, height, fps, holdMs, name = "Time-lap
|
|
|
3213
3213
|
}
|
|
3214
3214
|
const video = { version: 1, name, width: w, height: h, fps, background: "#000000", assets, tracks: [{ id: "v1", kind: "video", clips }] };
|
|
3215
3215
|
const durationMs = frameCount ? clips[clips.length - 1].start + clips[clips.length - 1].duration : 0;
|
|
3216
|
-
return { video, ffmpeg:
|
|
3216
|
+
return { video, ffmpeg: _chunkA653N65Qcjs.toVideoFfmpeg.call(void 0, video, { output: "timelapse.mp4" }), durationMs };
|
|
3217
3217
|
}
|
|
3218
3218
|
async function buildTimeLapse(source, target, options = {}) {
|
|
3219
3219
|
const maxSide = Math.max(32, Math.min(4096, Math.round(_nullishCoalesce(options.maxSide, () => ( 720)))));
|
|
@@ -3296,7 +3296,7 @@ function checkPaintEffectPlace(d, place) {
|
|
|
3296
3296
|
else if (d.uses.includes("filter") && place !== "light") instead = "; run it on a layer's dried paint with apply_effect instead";
|
|
3297
3297
|
else if (place === "light" && d.uses.some((u) => PAINT_EFFECT_PLACES.layer.includes(u))) instead = "; add it as an effect layer (add_effect_layer) or fill a layer with it (fill_layer_with_effect) instead";
|
|
3298
3298
|
else if (place === "paper" && d.uses.some((u) => u === "overlay" || u === "title")) instead = "; add it as an effect layer with add_effect_layer instead";
|
|
3299
|
-
throw new (0,
|
|
3299
|
+
throw new (0, _chunk2K5TELHVcjs.EffectUnsupportedError)(`"${d.id}" (${d.name}) is a ${d.uses.join(" / ") || d.kind} effect, and ${PLACE_WORDS[place]}${instead}.`, d.id);
|
|
3300
3300
|
}
|
|
3301
3301
|
var PAPER_EFFECT_BLENDS = ["multiply", "normal", "overlay", "soft-light", "screen", "color"];
|
|
3302
3302
|
var paperVersion = 1;
|
|
@@ -3479,7 +3479,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
3479
3479
|
/** Set while an operation that changes wet paint runs: the simulation before it (for undo). */
|
|
3480
3480
|
__init106() {this.wetOp = null}
|
|
3481
3481
|
/** The effects provider slot (see `setEffectsProvider`). */
|
|
3482
|
-
__init107() {this.effects = new (0,
|
|
3482
|
+
__init107() {this.effects = new (0, _chunk2K5TELHVcjs.EffectsSlot)()}
|
|
3483
3483
|
__init108() {this.effectsRenderer = new PaintEffectsRenderer()}
|
|
3484
3484
|
__init109() {this.paperEffectNodeCache = null}
|
|
3485
3485
|
constructor(options = {}) {;_class10.prototype.__init72.call(this);_class10.prototype.__init73.call(this);_class10.prototype.__init74.call(this);_class10.prototype.__init75.call(this);_class10.prototype.__init76.call(this);_class10.prototype.__init77.call(this);_class10.prototype.__init78.call(this);_class10.prototype.__init79.call(this);_class10.prototype.__init80.call(this);_class10.prototype.__init81.call(this);_class10.prototype.__init82.call(this);_class10.prototype.__init83.call(this);_class10.prototype.__init84.call(this);_class10.prototype.__init85.call(this);_class10.prototype.__init86.call(this);_class10.prototype.__init87.call(this);_class10.prototype.__init88.call(this);_class10.prototype.__init89.call(this);_class10.prototype.__init90.call(this);_class10.prototype.__init91.call(this);_class10.prototype.__init92.call(this);_class10.prototype.__init93.call(this);_class10.prototype.__init94.call(this);_class10.prototype.__init95.call(this);_class10.prototype.__init96.call(this);_class10.prototype.__init97.call(this);_class10.prototype.__init98.call(this);_class10.prototype.__init99.call(this);_class10.prototype.__init100.call(this);_class10.prototype.__init101.call(this);_class10.prototype.__init102.call(this);_class10.prototype.__init103.call(this);_class10.prototype.__init104.call(this);_class10.prototype.__init105.call(this);_class10.prototype.__init106.call(this);_class10.prototype.__init107.call(this);_class10.prototype.__init108.call(this);_class10.prototype.__init109.call(this);_class10.prototype.__init110.call(this);_class10.prototype.__init111.call(this);_class10.prototype.__init112.call(this);_class10.prototype.__init113.call(this);
|
|
@@ -4154,7 +4154,7 @@ var PaintEditorController = (_class10 = class _PaintEditorController {
|
|
|
4154
4154
|
if (v === null) merged[k] = d.defaults[k];
|
|
4155
4155
|
else given[k] = v;
|
|
4156
4156
|
}
|
|
4157
|
-
return { ...merged, ...
|
|
4157
|
+
return { ...merged, ..._chunk2K5TELHVcjs.resolveEffectValues.call(void 0, { ...d, defaults: merged }, given) };
|
|
4158
4158
|
}
|
|
4159
4159
|
/** Renders a generator, overlay or title effect at the canvas size. */
|
|
4160
4160
|
renderEffectCanvas(d, values, time = 0) {
|
|
@@ -8917,7 +8917,7 @@ function createPaintEffectsToolProvider(controller, options = {}) {
|
|
|
8917
8917
|
if (changes.enabled !== void 0) throw new Error("enabled does not apply here: hide an effect layer with update_layer visible false, or remove the effect paper.");
|
|
8918
8918
|
};
|
|
8919
8919
|
const values = (v) => v;
|
|
8920
|
-
return withPaintPlayback(
|
|
8920
|
+
return withPaintPlayback(_chunk2K5TELHVcjs.createEffectToolProvider.call(void 0, {
|
|
8921
8921
|
id: _nullishCoalesce(options.id, () => ( "paint-effects")),
|
|
8922
8922
|
namespace: options.namespace,
|
|
8923
8923
|
title: "Paint effects",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
toVideoFfmpeg
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-6QLTUGMO.js";
|
|
4
4
|
import {
|
|
5
5
|
deserializeLayers,
|
|
6
6
|
exportPsd,
|
|
@@ -137,7 +137,7 @@ import {
|
|
|
137
137
|
EffectsSlot,
|
|
138
138
|
createEffectToolProvider,
|
|
139
139
|
resolveEffectValues
|
|
140
|
-
} from "../chunk-
|
|
140
|
+
} from "../chunk-PQYDJ2AV.js";
|
|
141
141
|
import "../chunk-V2ZCJRDM.js";
|
|
142
142
|
import {
|
|
143
143
|
CoverageMap,
|
package/dist/vector/index.cjs
CHANGED
|
@@ -558,7 +558,7 @@ var _chunkNM3G4VQTcjs = require('../chunk-NM3G4VQT.cjs');
|
|
|
558
558
|
|
|
559
559
|
|
|
560
560
|
|
|
561
|
-
var
|
|
561
|
+
var _chunk2K5TELHVcjs = require('../chunk-2K5TELHV.cjs');
|
|
562
562
|
require('../chunk-WOFXZ3XU.cjs');
|
|
563
563
|
|
|
564
564
|
|
|
@@ -7328,7 +7328,7 @@ var VectorEditorController = (_class7 = class _VectorEditorController {
|
|
|
7328
7328
|
}
|
|
7329
7329
|
// --- Provider effects ---
|
|
7330
7330
|
/** The effects provider slot (see `setEffectsProvider`). */
|
|
7331
|
-
__init59() {this.effects = new (0,
|
|
7331
|
+
__init59() {this.effects = new (0, _chunk2K5TELHVcjs.EffectsSlot)()}
|
|
7332
7332
|
/** The registered effects provider, or `null`. */
|
|
7333
7333
|
get effectsProvider() {
|
|
7334
7334
|
return this.effects.provider;
|
|
@@ -7352,10 +7352,10 @@ var VectorEditorController = (_class7 = class _VectorEditorController {
|
|
|
7352
7352
|
/** The effect's picture as group children, scaled into `box` (an affine fit). */
|
|
7353
7353
|
async vectorEffectPicture(effect, values) {
|
|
7354
7354
|
const provider = this.effects.require();
|
|
7355
|
-
if (!provider.applyVectorEffect) throw new (0,
|
|
7355
|
+
if (!provider.applyVectorEffect) throw new (0, _chunk2K5TELHVcjs.EffectUnsupportedError)(`${provider.name} has no vector effects.`);
|
|
7356
7356
|
const d = await provider.describe(effect);
|
|
7357
|
-
if (d.kind !== "vector") throw new (0,
|
|
7358
|
-
const resolved =
|
|
7357
|
+
if (d.kind !== "vector") throw new (0, _chunk2K5TELHVcjs.EffectUnsupportedError)(`"${d.id}" (${d.name}) is a ${d.kind} effect; the vector editor adds vector effects, which bring their own picture${d.kind === "motion" ? " (apply motion in the animation editor)" : ""}.`, d.id);
|
|
7358
|
+
const resolved = _chunk2K5TELHVcjs.resolveEffectValues.call(void 0, d, values);
|
|
7359
7359
|
const motion = await provider.applyVectorEffect(d.id, this.toSvg(), resolved);
|
|
7360
7360
|
const parsed = _chunkBQE3Y6ZOcjs.parseVectorSvg.call(void 0, motion.svg);
|
|
7361
7361
|
if (!parsed.nodes.length) throw new Error(`"${d.name}" drew no shapes the editor can read.`);
|
|
@@ -18172,7 +18172,7 @@ function createVectorEffectsToolProvider(controller, options = {}) {
|
|
|
18172
18172
|
const effects = _optionalChain([g, 'optionalAccess', _765 => _765.providerEffect]) ? [info(g)] : [];
|
|
18173
18173
|
return { target: id, effect: _nullishCoalesce(removed, () => ( effects[0])), effects };
|
|
18174
18174
|
};
|
|
18175
|
-
return
|
|
18175
|
+
return _chunk2K5TELHVcjs.createEffectToolProvider.call(void 0, {
|
|
18176
18176
|
id: _nullishCoalesce(options.id, () => ( "vector-effects")),
|
|
18177
18177
|
namespace: options.namespace,
|
|
18178
18178
|
title: "Vector effects",
|
package/dist/vector/index.js
CHANGED