@pixerate/editor 0.121.0 → 0.122.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 (36) hide show
  1. package/THIRD_PARTY_NOTICES.md +1 -1
  2. package/dist/{chunk-GLOOH65Y.cjs → chunk-4PUPGALM.cjs} +196 -103
  3. package/dist/chunk-4PUPGALM.cjs.map +1 -0
  4. package/dist/{chunk-4I54JSJ6.js → chunk-CLTTLLWA.js} +1089 -981
  5. package/dist/chunk-CLTTLLWA.js.map +1 -0
  6. package/dist/{chunk-LL3RAN55.cjs → chunk-DFFBJV3U.cjs} +1839 -1731
  7. package/dist/chunk-DFFBJV3U.cjs.map +1 -0
  8. package/dist/{chunk-E6N5KLMA.js → chunk-IX3YKUVK.js} +96 -3
  9. package/dist/chunk-IX3YKUVK.js.map +1 -0
  10. package/dist/{render-B05K68_h.d.ts → deep-DLwKZDFr.d.ts} +143 -134
  11. package/dist/{render-DnAbIKcs.d.cts → deep-QS3ppbMX.d.cts} +143 -134
  12. package/dist/{export-D2D8hb_u.d.ts → export-VmTofKIk.d.ts} +11 -4
  13. package/dist/{export-fP2hZYjm.d.cts → export-jKKj8Fg8.d.cts} +11 -4
  14. package/dist/image-editor/index.cjs +678 -672
  15. package/dist/image-editor/index.cjs.map +1 -1
  16. package/dist/image-editor/index.d.cts +17 -5
  17. package/dist/image-editor/index.d.ts +17 -5
  18. package/dist/image-editor/index.js +8 -2
  19. package/dist/image-editor/index.js.map +1 -1
  20. package/dist/paint-editor/index.cjs +68 -68
  21. package/dist/paint-editor/index.d.cts +2 -2
  22. package/dist/paint-editor/index.d.ts +2 -2
  23. package/dist/paint-editor/index.js +2 -2
  24. package/dist/raster/index.cjs +2 -2
  25. package/dist/raster/index.d.cts +29 -7
  26. package/dist/raster/index.d.ts +29 -7
  27. package/dist/raster/index.js +1 -1
  28. package/package.json +1 -1
  29. package/skills/pixerate-canvas/SKILL.md +23 -1
  30. package/skills/pixerate-image-editor/SKILL.md +7 -1
  31. package/skills/pixerate-image-editor/references/photoshop-files.md +4 -3
  32. package/skills/pixerate-paint-editor/SKILL.md +32 -7
  33. package/dist/chunk-4I54JSJ6.js.map +0 -1
  34. package/dist/chunk-E6N5KLMA.js.map +0 -1
  35. package/dist/chunk-GLOOH65Y.cjs.map +0 -1
  36. package/dist/chunk-LL3RAN55.cjs.map +0 -1
@@ -34,7 +34,7 @@ import {
34
34
  validateEffectGradient,
35
35
  validateLayerEffects,
36
36
  warpSurface
37
- } from "./chunk-4I54JSJ6.js";
37
+ } from "./chunk-CLTTLLWA.js";
38
38
  import {
39
39
  affineFromHomography,
40
40
  applyHomography,
@@ -63,6 +63,8 @@ import {
63
63
  surfaceFromPixels,
64
64
  tileKey,
65
65
  tilesInRect,
66
+ to32From8,
67
+ to8From32,
66
68
  translateSurface,
67
69
  writeDeepRegion
68
70
  } from "./chunk-HKDTM6VC.js";
@@ -2183,6 +2185,67 @@ function applyProcess2Adjustments(imageData, adjustments) {
2183
2185
  if (hasOpacity) data[i + 3] = clamp(data[i + 3] * opacity);
2184
2186
  }
2185
2187
  }
2188
+ function applyProcess2Float(data, adjustments, linear) {
2189
+ const hasColor = !!adjustments.brightness || !!adjustments.contrast || !!adjustments.saturation || !!adjustments.exposure || !!adjustments.temperature || !!adjustments.tint;
2190
+ if (!hasColor) return;
2191
+ const { m, luts, scale, saturation } = getProcess2Plan(adjustments);
2192
+ const N = TONE_LUT_SIZE;
2193
+ const wr = LUMA_709[0], wg = LUMA_709[1], wb = LUMA_709[2];
2194
+ const c = [0, 0, 0];
2195
+ const dec = (v) => v <= 0.04045 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4);
2196
+ const enc = (v) => v <= 0 ? 0 : v >= 1 ? 1 : v <= 31308e-7 ? v * 12.92 : 1.055 * Math.pow(v, 1 / 2.4) - 0.055;
2197
+ for (let i = 0; i < data.length; i += 4) {
2198
+ if (!(data[i + 3] > 0)) continue;
2199
+ const r0 = linear ? data[i] : dec(data[i]);
2200
+ const g0 = linear ? data[i + 1] : dec(data[i + 1]);
2201
+ const b0 = linear ? data[i + 2] : dec(data[i + 2]);
2202
+ c[0] = m[0] * r0 + m[1] * g0 + m[2] * b0;
2203
+ c[1] = m[3] * r0 + m[4] * g0 + m[5] * b0;
2204
+ c[2] = m[6] * r0 + m[7] * g0 + m[8] * b0;
2205
+ for (let ch = 0; ch < 3; ch++) {
2206
+ const lut = luts[ch];
2207
+ const v = c[ch];
2208
+ let f;
2209
+ if (v <= 0) c[ch] = lut[0];
2210
+ else if ((f = v * scale[ch]) >= N) c[ch] = linear ? lut[N] + (lut[N] - lut[N - 1]) * (f - N) : lut[N];
2211
+ else {
2212
+ const k = f | 0;
2213
+ c[ch] = lut[k] + (lut[k + 1] - lut[k]) * (f - k);
2214
+ }
2215
+ }
2216
+ if (saturation !== 1) {
2217
+ const y = wr * c[0] + wg * c[1] + wb * c[2];
2218
+ for (let ch = 0; ch < 3; ch++) c[ch] = y + (c[ch] - y) * saturation;
2219
+ }
2220
+ for (let ch = 0; ch < 3; ch++) data[i + ch] = linear ? Math.max(0, c[ch]) : enc(c[ch]);
2221
+ }
2222
+ }
2223
+ function applyBoxBlurFloat(imageData, radius) {
2224
+ if (radius < 1) return;
2225
+ const { width: w, height: h, data: src } = imageData;
2226
+ const temp = new Float32Array(src.length);
2227
+ const n = 2 * radius + 1;
2228
+ for (let y = 0; y < h; y++) {
2229
+ for (let x = 0; x < w; x++) {
2230
+ const d = (y * w + x) * 4;
2231
+ for (let c = 0; c < 4; c++) {
2232
+ let s = 0;
2233
+ for (let k = -radius; k <= radius; k++) s += src[(y * w + Math.min(w - 1, Math.max(0, x + k))) * 4 + c];
2234
+ temp[d + c] = s / n;
2235
+ }
2236
+ }
2237
+ }
2238
+ for (let x = 0; x < w; x++) {
2239
+ for (let y = 0; y < h; y++) {
2240
+ const d = (y * w + x) * 4;
2241
+ for (let c = 0; c < 4; c++) {
2242
+ let s = 0;
2243
+ for (let k = -radius; k <= radius; k++) s += temp[(Math.min(h - 1, Math.max(0, y + k)) * w + x) * 4 + c];
2244
+ src[d + c] = s / n;
2245
+ }
2246
+ }
2247
+ }
2248
+ }
2186
2249
  function applyBoxBlur(imageData, radius) {
2187
2250
  applyFastBoxBlur(imageData, radius);
2188
2251
  }
@@ -2381,6 +2444,27 @@ function runLayerFilters(data, width, height, filters) {
2381
2444
  else if (f.kind === "blur") applyBoxBlur({ width, height, data }, Math.min(Math.round(f.radius), 40));
2382
2445
  }
2383
2446
  }
2447
+ function runLayerFiltersFloat(data, width, height, filters, linear) {
2448
+ for (const f of filters) {
2449
+ if (!isActiveFilter(f)) continue;
2450
+ if (f.kind === "blur") applyBoxBlurFloat({ width, height, data }, Math.min(Math.round(f.radius), 40));
2451
+ else if (f.kind === "develop") {
2452
+ const adj = developAdjustments(f);
2453
+ if (normalizeProcessVersion(adj.process) === LATEST_PROCESS_VERSION) applyProcess2Float(data, adj, linear);
2454
+ else {
2455
+ const bytes = linear ? to8From32(data, 4) : Uint8ClampedArray.from(data, (v) => v * 255);
2456
+ applyLegacyAdjustments({ data: bytes }, adj);
2457
+ if (linear) data.set(to32From8(bytes, 4));
2458
+ else for (let i = 0; i < data.length; i++) data[i] = bytes[i] / 255;
2459
+ }
2460
+ }
2461
+ }
2462
+ }
2463
+ function filterReach(filters) {
2464
+ let r = 0;
2465
+ for (const f of filters) if (isActiveFilter(f) && f.kind === "blur") r += Math.min(Math.round(f.radius), 40);
2466
+ return r;
2467
+ }
2384
2468
  var filterSpecCache = /* @__PURE__ */ new WeakMap();
2385
2469
  function pixelFilterSpec(layer) {
2386
2470
  const list2 = layer.filters;
@@ -2431,7 +2515,13 @@ var LayerCompositor = class extends RasterCompositor {
2431
2515
  };
2432
2516
  function compositeDeep(layers, rect, sources, depth) {
2433
2517
  const deep = new DeepCompositor(new LayerCompositor(), PHOTO_PROFILE, {
2434
- applyFilterRunDeep: (run, acc, _r, masks) => applyAdjustmentLayersFloat(acc, run.map(adjustmentNodeAsLayer), masks)
2518
+ applyFilterRunDeep: (run, acc, _r, masks) => applyAdjustmentLayersFloat(acc, run.map(adjustmentNodeAsLayer), masks),
2519
+ pixelFiltersDeep: (l) => {
2520
+ if (l.type !== "pixel") return null;
2521
+ const filters = (l.filters ?? []).filter(isActiveFilter);
2522
+ if (!filters.length) return null;
2523
+ return { reach: filterReach(filters), apply: (data, width, height, linear) => runLayerFiltersFloat(data, width, height, filters, linear) };
2524
+ }
2435
2525
  }, depth);
2436
2526
  return deep.composite(layers, rect, sources);
2437
2527
  }
@@ -11548,6 +11638,8 @@ export {
11548
11638
  applyAdjustments,
11549
11639
  applyLegacyAdjustments,
11550
11640
  applyProcess2Adjustments,
11641
+ applyProcess2Float,
11642
+ applyBoxBlurFloat,
11551
11643
  applyBoxBlur,
11552
11644
  applyDepthMask,
11553
11645
  removeAlpha,
@@ -11569,6 +11661,7 @@ export {
11569
11661
  adjustmentNodeAsLayer,
11570
11662
  depthMaskAlpha,
11571
11663
  runLayerFilters,
11664
+ runLayerFiltersFloat,
11572
11665
  LayerCompositor,
11573
11666
  compositeDeep,
11574
11667
  DEFAULT_ADJUSTMENTS_VALUES,
@@ -11772,4 +11865,4 @@ export {
11772
11865
  smartContentsFile,
11773
11866
  exportPsd
11774
11867
  };
11775
- //# sourceMappingURL=chunk-E6N5KLMA.js.map
11868
+ //# sourceMappingURL=chunk-IX3YKUVK.js.map