@pixerate/editor-react 0.112.0 → 0.112.1

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.
@@ -3,7 +3,7 @@ import {
3
3
  EffectsBrowser,
4
4
  useEffectDescription,
5
5
  useEffects
6
- } from "../chunk-ZQ6H2C7N.js";
6
+ } from "../chunk-BWEARAWR.js";
7
7
  import "../chunk-5LFQ2UQZ.js";
8
8
  import "../chunk-KIRIU53A.js";
9
9
  import "../chunk-3I7FOSLF.js";
@@ -2,7 +2,7 @@ import {
2
2
  EffectParameters,
3
3
  EffectsBrowser,
4
4
  useEffectDescription
5
- } from "../chunk-ZQ6H2C7N.js";
5
+ } from "../chunk-BWEARAWR.js";
6
6
  import "../chunk-5LFQ2UQZ.js";
7
7
  import "../chunk-KIRIU53A.js";
8
8
  import "../chunk-3I7FOSLF.js";
@@ -248,6 +248,7 @@ function EffectAuthoringEditor({
248
248
  const pendingRef = useRef2(false);
249
249
  const timeRef = useRef2(0);
250
250
  const inputsRef = useRef2({});
251
+ const [previewError, setPreviewError] = useState4(null);
251
252
  const [savingPreset, setSavingPreset] = useState4(false);
252
253
  const [presetName, setPresetName] = useState4("");
253
254
  const textareaRef = useRef2(null);
@@ -255,6 +256,9 @@ function EffectAuthoringEditor({
255
256
  const [sourceCode, setSourceCode] = useState4("");
256
257
  const sourceDebounceRef = useRef2(null);
257
258
  useEffect4(() => {
259
+ const canvas = canvasRef.current;
260
+ canvas?.getContext("2d")?.clearRect(0, 0, canvas.width, canvas.height);
261
+ setPreviewError(null);
258
262
  if (!session) {
259
263
  if (rendererRef.current) {
260
264
  rendererRef.current.dispose();
@@ -272,6 +276,8 @@ function EffectAuthoringEditor({
272
276
  createdRenderer = renderer;
273
277
  rendererRef.current = renderer;
274
278
  setRendererReady((c) => c + 1);
279
+ }).catch((e) => {
280
+ if (live) setPreviewError(session.getState().previewError || (e instanceof Error ? e.message : String(e)));
275
281
  });
276
282
  return () => {
277
283
  live = false;
@@ -300,7 +306,13 @@ function EffectAuthoringEditor({
300
306
  if (ctx && typeof ImageData !== "undefined") {
301
307
  ctx.putImageData(new ImageData(new Uint8ClampedArray(pixels.data), pixels.width, pixels.height), 0, 0);
302
308
  }
303
- } catch {
309
+ if (rendererRef.current === renderer) setPreviewError(null);
310
+ } catch (e) {
311
+ if (rendererRef.current === renderer) {
312
+ const canvas = canvasRef.current;
313
+ canvas?.getContext("2d")?.clearRect(0, 0, canvas.width, canvas.height);
314
+ setPreviewError(e instanceof Error ? e.message : String(e));
315
+ }
304
316
  }
305
317
  } while (pendingRef.current);
306
318
  } finally {
@@ -447,16 +459,19 @@ function EffectAuthoringEditor({
447
459
  /* @__PURE__ */ jsxs3("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
448
460
  /* @__PURE__ */ jsxs3("div", { className: "space-y-2", children: [
449
461
  /* @__PURE__ */ jsx4("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Preview" }),
450
- /* @__PURE__ */ jsx4("div", { className: "relative flex aspect-video w-full items-center justify-center overflow-hidden rounded border border-border bg-black", children: /* @__PURE__ */ jsx4(
451
- "canvas",
452
- {
453
- ref: canvasRef,
454
- width: previewSize.width,
455
- height: previewSize.height,
456
- className: "h-full w-full object-contain",
457
- "aria-label": "Effect preview canvas"
458
- }
459
- ) }),
462
+ /* @__PURE__ */ jsxs3("div", { className: "relative flex aspect-video w-full items-center justify-center overflow-hidden rounded border border-border bg-black", children: [
463
+ /* @__PURE__ */ jsx4(
464
+ "canvas",
465
+ {
466
+ ref: canvasRef,
467
+ width: previewSize.width,
468
+ height: previewSize.height,
469
+ className: "h-full w-full object-contain",
470
+ "aria-label": "Effect preview canvas"
471
+ }
472
+ ),
473
+ previewError && /* @__PURE__ */ jsx4("div", { className: "absolute inset-0 flex items-center justify-center p-4 text-center text-xs text-white/80", role: "status", "data-effect-preview-error": true, children: previewError })
474
+ ] }),
460
475
  state.issues.length > 0 && /* @__PURE__ */ jsx4("div", { className: "space-y-1 rounded border border-destructive/20 bg-destructive/10 p-2 text-xs", "data-effect-issues": true, children: state.issues.map((issue, idx) => /* @__PURE__ */ jsxs3(
461
476
  "div",
462
477
  {
@@ -6,7 +6,7 @@ import {
6
6
  EffectsBrowser,
7
7
  useEffectDescription,
8
8
  useEffects
9
- } from "./chunk-ZQ6H2C7N.js";
9
+ } from "./chunk-BWEARAWR.js";
10
10
  import {
11
11
  PresenceLayer,
12
12
  useAgentPlayback,
@@ -1695,6 +1695,7 @@ function EffectAuthoringEditor({
1695
1695
  const pendingRef = (0, import_react10.useRef)(false);
1696
1696
  const timeRef = (0, import_react10.useRef)(0);
1697
1697
  const inputsRef = (0, import_react10.useRef)({});
1698
+ const [previewError, setPreviewError] = (0, import_react10.useState)(null);
1698
1699
  const [savingPreset, setSavingPreset] = (0, import_react10.useState)(false);
1699
1700
  const [presetName, setPresetName] = (0, import_react10.useState)("");
1700
1701
  const textareaRef = (0, import_react10.useRef)(null);
@@ -1702,6 +1703,9 @@ function EffectAuthoringEditor({
1702
1703
  const [sourceCode, setSourceCode] = (0, import_react10.useState)("");
1703
1704
  const sourceDebounceRef = (0, import_react10.useRef)(null);
1704
1705
  (0, import_react10.useEffect)(() => {
1706
+ const canvas = canvasRef.current;
1707
+ canvas?.getContext("2d")?.clearRect(0, 0, canvas.width, canvas.height);
1708
+ setPreviewError(null);
1705
1709
  if (!session) {
1706
1710
  if (rendererRef.current) {
1707
1711
  rendererRef.current.dispose();
@@ -1719,6 +1723,8 @@ function EffectAuthoringEditor({
1719
1723
  createdRenderer = renderer;
1720
1724
  rendererRef.current = renderer;
1721
1725
  setRendererReady((c) => c + 1);
1726
+ }).catch((e) => {
1727
+ if (live) setPreviewError(session.getState().previewError || (e instanceof Error ? e.message : String(e)));
1722
1728
  });
1723
1729
  return () => {
1724
1730
  live = false;
@@ -1747,7 +1753,13 @@ function EffectAuthoringEditor({
1747
1753
  if (ctx && typeof ImageData !== "undefined") {
1748
1754
  ctx.putImageData(new ImageData(new Uint8ClampedArray(pixels.data), pixels.width, pixels.height), 0, 0);
1749
1755
  }
1750
- } catch {
1756
+ if (rendererRef.current === renderer) setPreviewError(null);
1757
+ } catch (e) {
1758
+ if (rendererRef.current === renderer) {
1759
+ const canvas = canvasRef.current;
1760
+ canvas?.getContext("2d")?.clearRect(0, 0, canvas.width, canvas.height);
1761
+ setPreviewError(e instanceof Error ? e.message : String(e));
1762
+ }
1751
1763
  }
1752
1764
  } while (pendingRef.current);
1753
1765
  } finally {
@@ -1894,16 +1906,19 @@ function EffectAuthoringEditor({
1894
1906
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
1895
1907
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-2", children: [
1896
1908
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Preview" }),
1897
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "relative flex aspect-video w-full items-center justify-center overflow-hidden rounded border border-border bg-black", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1898
- "canvas",
1899
- {
1900
- ref: canvasRef,
1901
- width: previewSize.width,
1902
- height: previewSize.height,
1903
- className: "h-full w-full object-contain",
1904
- "aria-label": "Effect preview canvas"
1905
- }
1906
- ) }),
1909
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "relative flex aspect-video w-full items-center justify-center overflow-hidden rounded border border-border bg-black", children: [
1910
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1911
+ "canvas",
1912
+ {
1913
+ ref: canvasRef,
1914
+ width: previewSize.width,
1915
+ height: previewSize.height,
1916
+ className: "h-full w-full object-contain",
1917
+ "aria-label": "Effect preview canvas"
1918
+ }
1919
+ ),
1920
+ previewError && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "absolute inset-0 flex items-center justify-center p-4 text-center text-xs text-white/80", role: "status", "data-effect-preview-error": true, children: previewError })
1921
+ ] }),
1907
1922
  state.issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "space-y-1 rounded border border-destructive/20 bg-destructive/10 p-2 text-xs", "data-effect-issues": true, children: state.issues.map((issue, idx) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
1908
1923
  "div",
1909
1924
  {
@@ -6,7 +6,7 @@ import {
6
6
  useEffectAuthoring,
7
7
  useEffectDescription,
8
8
  useEffects
9
- } from "../chunk-ZQ6H2C7N.js";
9
+ } from "../chunk-BWEARAWR.js";
10
10
  import "../chunk-5LFQ2UQZ.js";
11
11
  import "../chunk-KIRIU53A.js";
12
12
  import "../chunk-3I7FOSLF.js";
@@ -20,9 +20,9 @@ import {
20
20
  useImageEditor,
21
21
  useImageEffectsTools,
22
22
  useImageHistogram
23
- } from "../chunk-6XI62THS.js";
23
+ } from "../chunk-X2AGIMF3.js";
24
24
  import "../chunk-AJCWF6SN.js";
25
- import "../chunk-ZQ6H2C7N.js";
25
+ import "../chunk-BWEARAWR.js";
26
26
  import "../chunk-5LFQ2UQZ.js";
27
27
  import "../chunk-KIRIU53A.js";
28
28
  import "../chunk-3I7FOSLF.js";
package/dist/index.js CHANGED
@@ -44,9 +44,9 @@ import {
44
44
  useImageEditor,
45
45
  useImageEffectsTools,
46
46
  useImageHistogram
47
- } from "./chunk-6XI62THS.js";
47
+ } from "./chunk-X2AGIMF3.js";
48
48
  import "./chunk-AJCWF6SN.js";
49
- import "./chunk-ZQ6H2C7N.js";
49
+ import "./chunk-BWEARAWR.js";
50
50
  import "./chunk-5LFQ2UQZ.js";
51
51
  import "./chunk-KIRIU53A.js";
52
52
  import "./chunk-3I7FOSLF.js";
@@ -5,7 +5,7 @@ import {
5
5
  EffectParameters,
6
6
  EffectsBrowser,
7
7
  useEffectDescription
8
- } from "../chunk-ZQ6H2C7N.js";
8
+ } from "../chunk-BWEARAWR.js";
9
9
  import "../chunk-5LFQ2UQZ.js";
10
10
  import "../chunk-KIRIU53A.js";
11
11
  import "../chunk-3I7FOSLF.js";
@@ -3,7 +3,7 @@ import {
3
3
  EffectsBrowser,
4
4
  useEffectDescription,
5
5
  useEffects
6
- } from "../chunk-ZQ6H2C7N.js";
6
+ } from "../chunk-BWEARAWR.js";
7
7
  import "../chunk-5LFQ2UQZ.js";
8
8
  import "../chunk-KIRIU53A.js";
9
9
  import "../chunk-3I7FOSLF.js";
@@ -3271,6 +3271,7 @@ function EffectAuthoringEditor({
3271
3271
  const pendingRef = (0, import_react23.useRef)(false);
3272
3272
  const timeRef = (0, import_react23.useRef)(0);
3273
3273
  const inputsRef = (0, import_react23.useRef)({});
3274
+ const [previewError, setPreviewError] = (0, import_react23.useState)(null);
3274
3275
  const [savingPreset, setSavingPreset] = (0, import_react23.useState)(false);
3275
3276
  const [presetName, setPresetName] = (0, import_react23.useState)("");
3276
3277
  const textareaRef = (0, import_react23.useRef)(null);
@@ -3278,6 +3279,9 @@ function EffectAuthoringEditor({
3278
3279
  const [sourceCode, setSourceCode] = (0, import_react23.useState)("");
3279
3280
  const sourceDebounceRef = (0, import_react23.useRef)(null);
3280
3281
  (0, import_react23.useEffect)(() => {
3282
+ const canvas = canvasRef.current;
3283
+ canvas?.getContext("2d")?.clearRect(0, 0, canvas.width, canvas.height);
3284
+ setPreviewError(null);
3281
3285
  if (!session) {
3282
3286
  if (rendererRef.current) {
3283
3287
  rendererRef.current.dispose();
@@ -3295,6 +3299,8 @@ function EffectAuthoringEditor({
3295
3299
  createdRenderer = renderer;
3296
3300
  rendererRef.current = renderer;
3297
3301
  setRendererReady((c) => c + 1);
3302
+ }).catch((e) => {
3303
+ if (live) setPreviewError(session.getState().previewError || (e instanceof Error ? e.message : String(e)));
3298
3304
  });
3299
3305
  return () => {
3300
3306
  live = false;
@@ -3323,7 +3329,13 @@ function EffectAuthoringEditor({
3323
3329
  if (ctx && typeof ImageData !== "undefined") {
3324
3330
  ctx.putImageData(new ImageData(new Uint8ClampedArray(pixels.data), pixels.width, pixels.height), 0, 0);
3325
3331
  }
3326
- } catch {
3332
+ if (rendererRef.current === renderer) setPreviewError(null);
3333
+ } catch (e) {
3334
+ if (rendererRef.current === renderer) {
3335
+ const canvas = canvasRef.current;
3336
+ canvas?.getContext("2d")?.clearRect(0, 0, canvas.width, canvas.height);
3337
+ setPreviewError(e instanceof Error ? e.message : String(e));
3338
+ }
3327
3339
  }
3328
3340
  } while (pendingRef.current);
3329
3341
  } finally {
@@ -3470,16 +3482,19 @@ function EffectAuthoringEditor({
3470
3482
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
3471
3483
  /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "space-y-2", children: [
3472
3484
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Preview" }),
3473
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "relative flex aspect-video w-full items-center justify-center overflow-hidden rounded border border-border bg-black", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3474
- "canvas",
3475
- {
3476
- ref: canvasRef,
3477
- width: previewSize.width,
3478
- height: previewSize.height,
3479
- className: "h-full w-full object-contain",
3480
- "aria-label": "Effect preview canvas"
3481
- }
3482
- ) }),
3485
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "relative flex aspect-video w-full items-center justify-center overflow-hidden rounded border border-border bg-black", children: [
3486
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3487
+ "canvas",
3488
+ {
3489
+ ref: canvasRef,
3490
+ width: previewSize.width,
3491
+ height: previewSize.height,
3492
+ className: "h-full w-full object-contain",
3493
+ "aria-label": "Effect preview canvas"
3494
+ }
3495
+ ),
3496
+ previewError && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "absolute inset-0 flex items-center justify-center p-4 text-center text-xs text-white/80", role: "status", "data-effect-preview-error": true, children: previewError })
3497
+ ] }),
3483
3498
  state.issues.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "space-y-1 rounded border border-destructive/20 bg-destructive/10 p-2 text-xs", "data-effect-issues": true, children: state.issues.map((issue, idx) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3484
3499
  "div",
3485
3500
  {
@@ -4,7 +4,7 @@ import {
4
4
  EffectsBrowser,
5
5
  useEffectDescription,
6
6
  useEffects
7
- } from "../chunk-ZQ6H2C7N.js";
7
+ } from "../chunk-BWEARAWR.js";
8
8
  import "../chunk-5LFQ2UQZ.js";
9
9
  import "../chunk-KIRIU53A.js";
10
10
  import "../chunk-3I7FOSLF.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.112.0",
3
+ "version": "0.112.1",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -258,7 +258,7 @@
258
258
  },
259
259
  "peerDependencies": {
260
260
  "@dagrejs/dagre": "^1.1.8",
261
- "@pixerate/editor": ">=0.167.0 <1.0.0-0",
261
+ "@pixerate/editor": ">=0.168.0 <1.0.0-0",
262
262
  "@tiptap/core": "^2.27.3",
263
263
  "@tiptap/pm": "^2.27.3",
264
264
  "@tiptap/react": "^2.27.3",
@@ -285,7 +285,7 @@
285
285
  "tsup": "^9.0.0",
286
286
  "typescript": "^5.7.3",
287
287
  "vitest": "^5.0.5",
288
- "@pixerate/editor": "0.167.0"
288
+ "@pixerate/editor": "0.168.0"
289
289
  },
290
290
  "scripts": {
291
291
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",