@pixerate/editor-react 0.112.0 → 0.113.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.
@@ -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
  {