@pixerate/editor-react 0.96.0 → 0.98.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 (48) hide show
  1. package/README.md +2 -2
  2. package/dist/animation-editor/index.cjs +24 -6
  3. package/dist/animation-editor/index.js +2 -2
  4. package/dist/canvas/index.cjs +24 -6
  5. package/dist/canvas/index.js +2 -2
  6. package/dist/chart/index.cjs +2 -2
  7. package/dist/chart/index.js +1 -1
  8. package/dist/{chunk-7I73DW4V.js → chunk-NEQI2ZIU.js} +1 -1
  9. package/dist/chunk-Q7LAFHGP.js +655 -0
  10. package/dist/{chunk-GECXTPSH.js → chunk-S6C2W5JW.js} +1 -1
  11. package/dist/{chunk-IPVWWVSF.js → chunk-SI2V7XPZ.js} +2 -2
  12. package/dist/{chunk-IY6YOY5B.js → chunk-TFEKLNC7.js} +3083 -3031
  13. package/dist/effects/EffectAuthoringEditor.d.cts +22 -0
  14. package/dist/effects/EffectAuthoringEditor.d.ts +22 -0
  15. package/dist/effects/EffectParameters.d.cts +5 -1
  16. package/dist/effects/EffectParameters.d.ts +5 -1
  17. package/dist/effects/index.cjs +456 -4
  18. package/dist/effects/index.d.cts +2 -0
  19. package/dist/effects/index.d.ts +2 -0
  20. package/dist/effects/index.js +5 -1
  21. package/dist/effects/useEffectAuthoring.d.cts +6 -0
  22. package/dist/effects/useEffectAuthoring.d.ts +6 -0
  23. package/dist/image-editor/ImageEditor.d.cts +3 -1
  24. package/dist/image-editor/ImageEditor.d.ts +3 -1
  25. package/dist/image-editor/ImageEditorCanvas.d.cts +77 -0
  26. package/dist/image-editor/ImageEditorCanvas.d.ts +77 -0
  27. package/dist/image-editor/ImageEffectControls.d.cts +12 -0
  28. package/dist/image-editor/ImageEffectControls.d.ts +12 -0
  29. package/dist/image-editor/index.cjs +4709 -4644
  30. package/dist/image-editor/index.d.cts +2 -0
  31. package/dist/image-editor/index.d.ts +2 -0
  32. package/dist/image-editor/index.js +7 -3
  33. package/dist/index.cjs +5125 -5060
  34. package/dist/index.js +9 -5
  35. package/dist/paint-editor/index.cjs +24 -6
  36. package/dist/paint-editor/index.js +2 -2
  37. package/dist/parameters/index.cjs +2 -2
  38. package/dist/parameters/index.js +2 -2
  39. package/dist/playback/PresenceLayer.d.cts +3 -1
  40. package/dist/playback/PresenceLayer.d.ts +3 -1
  41. package/dist/spreadsheet/index.cjs +2 -2
  42. package/dist/spreadsheet/index.js +2 -2
  43. package/dist/vector/index.cjs +24 -6
  44. package/dist/vector/index.js +2 -2
  45. package/dist/video-editor/index.cjs +24 -6
  46. package/dist/video-editor/index.js +2 -2
  47. package/package.json +3 -3
  48. package/dist/chunk-GLSOQNQR.js +0 -205
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useElementPlaybackSurface
3
- } from "./chunk-7I73DW4V.js";
3
+ } from "./chunk-NEQI2ZIU.js";
4
4
  import {
5
5
  ChartCanvas,
6
6
  ChartDataGrid,
@@ -21,7 +21,7 @@ import {
21
21
  useSpreadsheetClipboard,
22
22
  useSpreadsheetEditor,
23
23
  useSpreadsheetViewport
24
- } from "./chunk-GECXTPSH.js";
24
+ } from "./chunk-S6C2W5JW.js";
25
25
  import {
26
26
  AdjustmentLayersPanel,
27
27
  BrushOptionsBar,
@@ -31,6 +31,8 @@ import {
31
31
  FreeTransformOptionsBar,
32
32
  Histogram,
33
33
  ImageEditor,
34
+ ImageEditorCanvas,
35
+ ImageEffectControls,
34
36
  ImageProviderEffectsPanel,
35
37
  LayerEffectsPanel,
36
38
  LayersPanel,
@@ -42,9 +44,9 @@ import {
42
44
  useImageEditor,
43
45
  useImageEffectsTools,
44
46
  useImageHistogram
45
- } from "./chunk-IY6YOY5B.js";
47
+ } from "./chunk-TFEKLNC7.js";
46
48
  import "./chunk-AJCWF6SN.js";
47
- import "./chunk-GLSOQNQR.js";
49
+ import "./chunk-Q7LAFHGP.js";
48
50
  import "./chunk-5LFQ2UQZ.js";
49
51
  import "./chunk-KIRIU53A.js";
50
52
  import "./chunk-3I7FOSLF.js";
@@ -53,7 +55,7 @@ import {
53
55
  PresenceLayer,
54
56
  useAgentPlayback,
55
57
  usePlaybackSurface
56
- } from "./chunk-IPVWWVSF.js";
58
+ } from "./chunk-SI2V7XPZ.js";
57
59
  import {
58
60
  CommandPalette,
59
61
  useCommandPalette,
@@ -2417,6 +2419,8 @@ export {
2417
2419
  Histogram,
2418
2420
  HistoryManager2 as HistoryManager,
2419
2421
  ImageEditor,
2422
+ ImageEditorCanvas,
2423
+ ImageEffectControls,
2420
2424
  ImageProviderEffectsPanel,
2421
2425
  InsertTableGrid,
2422
2426
  JobProgress,
@@ -1386,7 +1386,7 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
1386
1386
  // src/playback/PresenceLayer.tsx
1387
1387
  var import_react13 = __toESM(require("react"), 1);
1388
1388
  var import_jsx_runtime13 = require("react/jsx-runtime");
1389
- function PresenceLayer({ presence, viewport, className = "" }) {
1389
+ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
1390
1390
  const { actors } = (0, import_react13.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
1391
1391
  if (!actors.length) return null;
1392
1392
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
@@ -1396,7 +1396,7 @@ function PresenceLayer({ presence, viewport, className = "" }) {
1396
1396
  className: `pixerate-presence ${className}`.trim(),
1397
1397
  "aria-hidden": "true",
1398
1398
  "data-testid": "presence-layer",
1399
- style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
1399
+ style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: clip ? "hidden" : "visible", zIndex: 50 },
1400
1400
  children: actors.map((a) => {
1401
1401
  const at = map(a);
1402
1402
  const ring = a.focus && (() => {
@@ -2972,13 +2972,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
2972
2972
 
2973
2973
  // src/effects/EffectParameters.tsx
2974
2974
  var import_jsx_runtime19 = require("react/jsx-runtime");
2975
- function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
2975
+ function EffectParameters({
2976
+ description,
2977
+ values,
2978
+ onChange,
2979
+ onReset,
2980
+ keyframed,
2981
+ onPreset,
2982
+ onPresetName,
2983
+ renderControlAddon,
2984
+ disabled = false,
2985
+ className = ""
2986
+ }) {
2976
2987
  const fields = (0, import_react21.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
2977
2988
  const idBase = (0, import_react21.useId)();
2978
2989
  const gesture = import_react21.default.useRef(null);
2979
2990
  const count = import_react21.default.useRef(0);
2980
2991
  return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
2981
- onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
2992
+ (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
2982
2993
  "select",
2983
2994
  {
2984
2995
  className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
@@ -2986,8 +2997,14 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
2986
2997
  value: "",
2987
2998
  disabled,
2988
2999
  onChange: (e) => {
2989
- const preset = description.presets.find((p) => p.name === e.currentTarget.value);
2990
- if (preset) onPreset({ ...description.defaults, ...preset.values });
3000
+ const name = e.currentTarget.value;
3001
+ if (!name) return;
3002
+ if (onPresetName) {
3003
+ onPresetName(name);
3004
+ } else if (onPreset) {
3005
+ const preset = description.presets.find((p) => p.name === name);
3006
+ if (preset) onPreset({ ...description.defaults, ...preset.values });
3007
+ }
2991
3008
  },
2992
3009
  children: [
2993
3010
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("option", { value: "", children: "Presets\u2026" }),
@@ -3005,6 +3022,7 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
3005
3022
  /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: "flex items-center gap-1.5", children: [
3006
3023
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
3007
3024
  keyed && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
3025
+ renderControlAddon?.(field.id),
3008
3026
  onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
3009
3027
  ] }),
3010
3028
  /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
@@ -5,7 +5,7 @@ import {
5
5
  EffectParameters,
6
6
  EffectsBrowser,
7
7
  useEffectDescription
8
- } from "../chunk-GLSOQNQR.js";
8
+ } from "../chunk-Q7LAFHGP.js";
9
9
  import "../chunk-5LFQ2UQZ.js";
10
10
  import "../chunk-KIRIU53A.js";
11
11
  import "../chunk-3I7FOSLF.js";
@@ -13,7 +13,7 @@ import {
13
13
  PresenceLayer,
14
14
  useAgentPlayback,
15
15
  usePlaybackSurface
16
- } from "../chunk-IPVWWVSF.js";
16
+ } from "../chunk-SI2V7XPZ.js";
17
17
 
18
18
  // src/paint-editor/usePaintEditor.ts
19
19
  import { useMemo, useState, useSyncExternalStore } from "react";
@@ -1623,7 +1623,7 @@ function useElementPlaybackSurface(playback, id, element, options) {
1623
1623
  // src/playback/PresenceLayer.tsx
1624
1624
  var import_react9 = __toESM(require("react"), 1);
1625
1625
  var import_jsx_runtime5 = require("react/jsx-runtime");
1626
- function PresenceLayer({ presence, viewport, className = "" }) {
1626
+ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
1627
1627
  const { actors } = (0, import_react9.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
1628
1628
  if (!actors.length) return null;
1629
1629
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
@@ -1633,7 +1633,7 @@ function PresenceLayer({ presence, viewport, className = "" }) {
1633
1633
  className: `pixerate-presence ${className}`.trim(),
1634
1634
  "aria-hidden": "true",
1635
1635
  "data-testid": "presence-layer",
1636
- style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
1636
+ style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: clip ? "hidden" : "visible", zIndex: 50 },
1637
1637
  children: actors.map((a) => {
1638
1638
  const at = map(a);
1639
1639
  const ring = a.focus && (() => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useElementPlaybackSurface
3
- } from "../chunk-7I73DW4V.js";
3
+ } from "../chunk-NEQI2ZIU.js";
4
4
  import {
5
5
  KeyframeDiamond,
6
6
  ParameterColor,
@@ -21,7 +21,7 @@ import "../chunk-3I7FOSLF.js";
21
21
  import {
22
22
  PresenceLayer,
23
23
  useAgentPlayback
24
- } from "../chunk-IPVWWVSF.js";
24
+ } from "../chunk-SI2V7XPZ.js";
25
25
 
26
26
  // src/parameters/useParameters.ts
27
27
  import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
@@ -18,6 +18,8 @@ export interface PresenceLayerProps {
18
18
  x: number;
19
19
  y: number;
20
20
  });
21
+ /** Clip the cursors to the layer's box (default true). `false` lets a cursor visit chrome outside it. */
22
+ clip?: boolean;
21
23
  className?: string;
22
24
  }
23
25
  /**
@@ -25,4 +27,4 @@ export interface PresenceLayerProps {
25
27
  * in a `position: relative` box over the surface. It has the `pixerate-presence` class, so
26
28
  * snapshots and exports leave it out.
27
29
  */
28
- export declare function PresenceLayer({ presence, viewport, className }: PresenceLayerProps): React.JSX.Element | null;
30
+ export declare function PresenceLayer({ presence, viewport, clip, className }: PresenceLayerProps): React.JSX.Element | null;
@@ -18,6 +18,8 @@ export interface PresenceLayerProps {
18
18
  x: number;
19
19
  y: number;
20
20
  });
21
+ /** Clip the cursors to the layer's box (default true). `false` lets a cursor visit chrome outside it. */
22
+ clip?: boolean;
21
23
  className?: string;
22
24
  }
23
25
  /**
@@ -25,4 +27,4 @@ export interface PresenceLayerProps {
25
27
  * in a `position: relative` box over the surface. It has the `pixerate-presence` class, so
26
28
  * snapshots and exports leave it out.
27
29
  */
28
- export declare function PresenceLayer({ presence, viewport, className }: PresenceLayerProps): React.JSX.Element | null;
30
+ export declare function PresenceLayer({ presence, viewport, clip, className }: PresenceLayerProps): React.JSX.Element | null;
@@ -334,7 +334,7 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
334
334
  // src/playback/PresenceLayer.tsx
335
335
  var import_react4 = __toESM(require("react"), 1);
336
336
  var import_jsx_runtime2 = require("react/jsx-runtime");
337
- function PresenceLayer({ presence, viewport, className = "" }) {
337
+ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
338
338
  const { actors } = (0, import_react4.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
339
339
  if (!actors.length) return null;
340
340
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
@@ -344,7 +344,7 @@ function PresenceLayer({ presence, viewport, className = "" }) {
344
344
  className: `pixerate-presence ${className}`.trim(),
345
345
  "aria-hidden": "true",
346
346
  "data-testid": "presence-layer",
347
- style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
347
+ style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: clip ? "hidden" : "visible", zIndex: 50 },
348
348
  children: actors.map((a) => {
349
349
  const at = map(a);
350
350
  const ring = a.focus && (() => {
@@ -12,8 +12,8 @@ import {
12
12
  useSpreadsheetClipboard,
13
13
  useSpreadsheetEditor,
14
14
  useSpreadsheetViewport
15
- } from "../chunk-GECXTPSH.js";
16
- import "../chunk-IPVWWVSF.js";
15
+ } from "../chunk-S6C2W5JW.js";
16
+ import "../chunk-SI2V7XPZ.js";
17
17
  export {
18
18
  FormulaHints,
19
19
  NameManager,
@@ -194,7 +194,7 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
194
194
  // src/playback/PresenceLayer.tsx
195
195
  var import_react4 = __toESM(require("react"), 1);
196
196
  var import_jsx_runtime2 = require("react/jsx-runtime");
197
- function PresenceLayer({ presence, viewport, className = "" }) {
197
+ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
198
198
  const { actors } = (0, import_react4.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
199
199
  if (!actors.length) return null;
200
200
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
@@ -204,7 +204,7 @@ function PresenceLayer({ presence, viewport, className = "" }) {
204
204
  className: `pixerate-presence ${className}`.trim(),
205
205
  "aria-hidden": "true",
206
206
  "data-testid": "presence-layer",
207
- style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
207
+ style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: clip ? "hidden" : "visible", zIndex: 50 },
208
208
  children: actors.map((a) => {
209
209
  const at = map(a);
210
210
  const ring = a.focus && (() => {
@@ -4654,13 +4654,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
4654
4654
 
4655
4655
  // src/effects/EffectParameters.tsx
4656
4656
  var import_jsx_runtime27 = require("react/jsx-runtime");
4657
- function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
4657
+ function EffectParameters({
4658
+ description,
4659
+ values,
4660
+ onChange,
4661
+ onReset,
4662
+ keyframed,
4663
+ onPreset,
4664
+ onPresetName,
4665
+ renderControlAddon,
4666
+ disabled = false,
4667
+ className = ""
4668
+ }) {
4658
4669
  const fields = (0, import_react22.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
4659
4670
  const idBase = (0, import_react22.useId)();
4660
4671
  const gesture = import_react22.default.useRef(null);
4661
4672
  const count = import_react22.default.useRef(0);
4662
4673
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
4663
- onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
4674
+ (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
4664
4675
  "select",
4665
4676
  {
4666
4677
  className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
@@ -4668,8 +4679,14 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
4668
4679
  value: "",
4669
4680
  disabled,
4670
4681
  onChange: (e) => {
4671
- const preset = description.presets.find((p) => p.name === e.currentTarget.value);
4672
- if (preset) onPreset({ ...description.defaults, ...preset.values });
4682
+ const name = e.currentTarget.value;
4683
+ if (!name) return;
4684
+ if (onPresetName) {
4685
+ onPresetName(name);
4686
+ } else if (onPreset) {
4687
+ const preset = description.presets.find((p) => p.name === name);
4688
+ if (preset) onPreset({ ...description.defaults, ...preset.values });
4689
+ }
4673
4690
  },
4674
4691
  children: [
4675
4692
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("option", { value: "", children: "Presets\u2026" }),
@@ -4687,6 +4704,7 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
4687
4704
  /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { className: "flex items-center gap-1.5", children: [
4688
4705
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
4689
4706
  keyed && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
4707
+ renderControlAddon?.(field.id),
4690
4708
  onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
4691
4709
  ] }),
4692
4710
  /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
@@ -3,7 +3,7 @@ import {
3
3
  EffectsBrowser,
4
4
  useEffectDescription,
5
5
  useEffects
6
- } from "../chunk-GLSOQNQR.js";
6
+ } from "../chunk-Q7LAFHGP.js";
7
7
  import "../chunk-5LFQ2UQZ.js";
8
8
  import "../chunk-KIRIU53A.js";
9
9
  import "../chunk-3I7FOSLF.js";
@@ -11,7 +11,7 @@ import {
11
11
  PresenceLayer,
12
12
  useAgentPlayback,
13
13
  usePlaybackSurface
14
- } from "../chunk-IPVWWVSF.js";
14
+ } from "../chunk-SI2V7XPZ.js";
15
15
 
16
16
  // src/vector/useVectorEditor.ts
17
17
  import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
@@ -301,7 +301,7 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
301
301
  // src/playback/PresenceLayer.tsx
302
302
  var import_react6 = __toESM(require("react"), 1);
303
303
  var import_jsx_runtime5 = require("react/jsx-runtime");
304
- function PresenceLayer({ presence, viewport, className = "" }) {
304
+ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
305
305
  const { actors } = (0, import_react6.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
306
306
  if (!actors.length) return null;
307
307
  const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
@@ -311,7 +311,7 @@ function PresenceLayer({ presence, viewport, className = "" }) {
311
311
  className: `pixerate-presence ${className}`.trim(),
312
312
  "aria-hidden": "true",
313
313
  "data-testid": "presence-layer",
314
- style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
314
+ style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: clip ? "hidden" : "visible", zIndex: 50 },
315
315
  children: actors.map((a) => {
316
316
  const at = map(a);
317
317
  const ring = a.focus && (() => {
@@ -2842,13 +2842,24 @@ function ParameterFieldControl({ field: field2, value, onChange, resolveFile, ..
2842
2842
 
2843
2843
  // src/effects/EffectParameters.tsx
2844
2844
  var import_jsx_runtime15 = require("react/jsx-runtime");
2845
- function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
2845
+ function EffectParameters({
2846
+ description,
2847
+ values,
2848
+ onChange,
2849
+ onReset,
2850
+ keyframed,
2851
+ onPreset,
2852
+ onPresetName,
2853
+ renderControlAddon,
2854
+ disabled = false,
2855
+ className = ""
2856
+ }) {
2846
2857
  const fields = (0, import_react18.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
2847
2858
  const idBase = (0, import_react18.useId)();
2848
2859
  const gesture = import_react18.default.useRef(null);
2849
2860
  const count = import_react18.default.useRef(0);
2850
2861
  return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
2851
- onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2862
+ (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
2852
2863
  "select",
2853
2864
  {
2854
2865
  className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
@@ -2856,8 +2867,14 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
2856
2867
  value: "",
2857
2868
  disabled,
2858
2869
  onChange: (e) => {
2859
- const preset = description.presets.find((p) => p.name === e.currentTarget.value);
2860
- if (preset) onPreset({ ...description.defaults, ...preset.values });
2870
+ const name = e.currentTarget.value;
2871
+ if (!name) return;
2872
+ if (onPresetName) {
2873
+ onPresetName(name);
2874
+ } else if (onPreset) {
2875
+ const preset = description.presets.find((p) => p.name === name);
2876
+ if (preset) onPreset({ ...description.defaults, ...preset.values });
2877
+ }
2861
2878
  },
2862
2879
  children: [
2863
2880
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("option", { value: "", children: "Presets\u2026" }),
@@ -2875,6 +2892,7 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
2875
2892
  /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1.5", children: [
2876
2893
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field2.description, children: label }),
2877
2894
  keyed && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
2895
+ renderControlAddon?.(field2.id),
2878
2896
  onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field2.id), children: "\u21BA" })
2879
2897
  ] }),
2880
2898
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
@@ -3,7 +3,7 @@ import {
3
3
  EffectsBrowser,
4
4
  useEffectDescription,
5
5
  useEffects
6
- } from "../chunk-GLSOQNQR.js";
6
+ } from "../chunk-Q7LAFHGP.js";
7
7
  import "../chunk-5LFQ2UQZ.js";
8
8
  import "../chunk-KIRIU53A.js";
9
9
  import "../chunk-3I7FOSLF.js";
@@ -11,7 +11,7 @@ import {
11
11
  PresenceLayer,
12
12
  useAgentPlayback,
13
13
  usePlaybackSurface
14
- } from "../chunk-IPVWWVSF.js";
14
+ } from "../chunk-SI2V7XPZ.js";
15
15
 
16
16
  // src/video-editor/useVideoEditor.ts
17
17
  import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.96.0",
3
+ "version": "0.98.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -245,7 +245,7 @@
245
245
  },
246
246
  "peerDependencies": {
247
247
  "@dagrejs/dagre": "^1.1.8",
248
- "@pixerate/editor": ">=0.147.0 <1.0.0-0",
248
+ "@pixerate/editor": ">=0.148.0 <1.0.0-0",
249
249
  "@tiptap/core": "^2.27.3",
250
250
  "@tiptap/pm": "^2.27.3",
251
251
  "@tiptap/react": "^2.27.3",
@@ -272,7 +272,7 @@
272
272
  "tsup": "^9.0.0",
273
273
  "typescript": "^5.7.3",
274
274
  "vitest": "^5.0.5",
275
- "@pixerate/editor": "0.147.0"
275
+ "@pixerate/editor": "0.148.0"
276
276
  },
277
277
  "scripts": {
278
278
  "build": "tsup && tsc -p tsconfig.build.json && node ../../scripts/finalize-declarations.mjs dist",
@@ -1,205 +0,0 @@
1
- import {
2
- ParameterFieldControl
3
- } from "./chunk-5LFQ2UQZ.js";
4
-
5
- // src/effects/useEffects.ts
6
- import { useEffect, useState } from "react";
7
- function useEffects(host, provider) {
8
- useEffect(() => {
9
- if (!host || !provider) return;
10
- return host.useEffects(provider);
11
- }, [host, provider]);
12
- }
13
- function useEffectDescription(provider, effect) {
14
- const [state, setState] = useState({ key: "", description: null, error: null });
15
- const key = provider && effect ? `${provider.id}:${effect}` : "";
16
- useEffect(() => {
17
- if (!provider || !effect) return;
18
- let live = true;
19
- Promise.resolve().then(() => provider.describe(effect)).then(
20
- (description) => live && setState({ key, description, error: null }),
21
- (e) => live && setState({ key, description: null, error: e instanceof Error ? e.message : String(e) })
22
- );
23
- return () => {
24
- live = false;
25
- };
26
- }, [provider, effect, key]);
27
- return state.key === key ? { description: state.description, error: state.error } : { description: null, error: null };
28
- }
29
-
30
- // src/effects/EffectThumbnail.tsx
31
- import { useEffect as useEffect2, useRef, useState as useState2 } from "react";
32
- import { renderEffectThumbnail } from "@pixerate/editor/effects";
33
- import { jsx } from "react/jsx-runtime";
34
- function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
35
- const ref = useRef(null);
36
- const [failed, setFailed] = useState2(effect.kind === "motion");
37
- useEffect2(() => {
38
- if (effect.kind === "motion") return;
39
- let live = true;
40
- renderEffectThumbnail(provider, effect, { width, height }).then(
41
- (pixels) => {
42
- const ctx = live ? ref.current?.getContext("2d") : null;
43
- if (!ctx || typeof ImageData === "undefined") return;
44
- ctx.putImageData(new ImageData(new Uint8ClampedArray(pixels.data), pixels.width, pixels.height), 0, 0);
45
- },
46
- () => live && setFailed(true)
47
- );
48
- return () => {
49
- live = false;
50
- };
51
- }, [provider, effect, width, height]);
52
- return /* @__PURE__ */ jsx(
53
- "div",
54
- {
55
- className: `relative overflow-hidden rounded border border-border bg-[repeating-conic-gradient(#8884_0_25%,transparent_0_50%)] bg-[length:12px_12px] ${className}`,
56
- style: { aspectRatio: `${width} / ${height}` },
57
- "data-effect-thumbnail": effect.id,
58
- children: failed ? /* @__PURE__ */ jsx("span", { className: "absolute inset-0 flex items-center justify-center text-[10px] text-muted-foreground", children: effect.kind === "motion" ? "Motion" : "No preview" }) : /* @__PURE__ */ jsx("canvas", { ref, width, height, className: "h-full w-full", "aria-hidden": "true" })
59
- }
60
- );
61
- }
62
-
63
- // src/effects/EffectsBrowser.tsx
64
- import { useEffect as useEffect3, useMemo, useState as useState3 } from "react";
65
- import { EFFECT_USE_LABELS } from "@pixerate/editor/effects";
66
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
67
- function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
68
- const [all, setAll] = useState3([]);
69
- const [query, setQuery] = useState3("");
70
- const [category, setCategory] = useState3("");
71
- const [use, setUse] = useState3("");
72
- const [error, setError] = useState3(null);
73
- useEffect3(() => {
74
- if (!provider) return setAll([]);
75
- let live = true;
76
- Promise.resolve().then(() => provider.list()).then(
77
- (list) => live && (setAll(list), setError(null)),
78
- (e) => live && setError(e instanceof Error ? e.message : String(e))
79
- );
80
- return () => {
81
- live = false;
82
- };
83
- }, [provider]);
84
- const [found, setFound] = useState3([]);
85
- useEffect3(() => {
86
- if (!provider) return setFound([]);
87
- let live = true;
88
- Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
89
- return () => {
90
- live = false;
91
- };
92
- }, [provider, query, category, use]);
93
- const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (uses ? e.kind !== "motion" || uses.includes("motion") : e.kind !== "motion") && (!uses || e.uses.some((u) => uses.includes(u)));
94
- const categories = useMemo(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
95
- const shown = found.filter(allowed);
96
- if (!provider)
97
- return /* @__PURE__ */ jsx2("div", { className: `rounded-md border border-dashed border-border p-3 text-xs text-muted-foreground ${className}`, "data-effects-browser": "", "data-effects-unavailable": "", children: "No effects provider is registered, so effects cannot be added. Effects already in the document are kept." });
98
- return /* @__PURE__ */ jsxs("section", { className: `flex flex-col gap-2 ${className}`, "data-effects-browser": "", "aria-label": "Effects browser", children: [
99
- title && /* @__PURE__ */ jsx2("h3", { className: "text-xs font-semibold", children: title }),
100
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
101
- /* @__PURE__ */ jsx2(
102
- "input",
103
- {
104
- type: "search",
105
- className: "min-w-0 flex-1 rounded border border-border bg-transparent px-1.5 py-0.5 text-xs",
106
- placeholder: "Search effects",
107
- "aria-label": "Search effects",
108
- value: query,
109
- onChange: (e) => setQuery(e.currentTarget.value)
110
- }
111
- ),
112
- /* @__PURE__ */ jsxs("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Category", value: category, onChange: (e) => setCategory(e.currentTarget.value), children: [
113
- /* @__PURE__ */ jsx2("option", { value: "", children: "All categories" }),
114
- categories.map((c) => /* @__PURE__ */ jsx2("option", { value: c, children: c }, c))
115
- ] }),
116
- uses && uses.length > 1 && /* @__PURE__ */ jsxs("select", { className: "rounded border border-border bg-transparent px-1 py-0.5 text-xs", "aria-label": "Use", value: use, onChange: (e) => setUse(e.currentTarget.value), children: [
117
- /* @__PURE__ */ jsx2("option", { value: "", children: "Any use" }),
118
- uses.map((u) => /* @__PURE__ */ jsx2("option", { value: u, children: EFFECT_USE_LABELS[u] }, u))
119
- ] })
120
- ] }),
121
- error && /* @__PURE__ */ jsx2("p", { role: "alert", className: "text-[11px] text-destructive", children: error }),
122
- /* @__PURE__ */ jsx2("ul", { className: "grid max-h-96 grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-1.5 overflow-y-auto", role: "list", children: shown.map((e) => /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsxs(
123
- "button",
124
- {
125
- type: "button",
126
- className: "flex w-full flex-col gap-1 rounded border border-transparent p-1 text-left hover:border-border focus-visible:border-border",
127
- title: e.description ?? e.name,
128
- "data-effect-id": e.id,
129
- onClick: () => onPick(e),
130
- children: [
131
- thumbnails && /* @__PURE__ */ jsx2(EffectThumbnail, { provider, effect: e }),
132
- /* @__PURE__ */ jsx2("span", { className: "truncate text-[11px] font-medium", children: e.name }),
133
- /* @__PURE__ */ jsx2("span", { className: "truncate text-[10px] text-muted-foreground", children: e.uses.map((u) => EFFECT_USE_LABELS[u]).join(" \xB7 ") })
134
- ]
135
- }
136
- ) }, e.id)) }),
137
- !shown.length && !error && /* @__PURE__ */ jsx2("p", { className: "text-[11px] text-muted-foreground", children: "No effects match." })
138
- ] });
139
- }
140
-
141
- // src/effects/EffectParameters.tsx
142
- import React3, { useId, useMemo as useMemo2 } from "react";
143
- import { effectFieldValue, effectParameterFields } from "@pixerate/editor/effects";
144
- import { parameterLabel, parameterValuesEqual } from "@pixerate/editor/parameters";
145
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
146
- function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
147
- const fields = useMemo2(() => effectParameterFields(description), [description]);
148
- const idBase = useId();
149
- const gesture = React3.useRef(null);
150
- const count = React3.useRef(0);
151
- return /* @__PURE__ */ jsxs2("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
152
- onPreset && description.presets.length > 0 && /* @__PURE__ */ jsxs2(
153
- "select",
154
- {
155
- className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
156
- "aria-label": `${description.name} presets`,
157
- value: "",
158
- disabled,
159
- onChange: (e) => {
160
- const preset = description.presets.find((p) => p.name === e.currentTarget.value);
161
- if (preset) onPreset({ ...description.defaults, ...preset.values });
162
- },
163
- children: [
164
- /* @__PURE__ */ jsx3("option", { value: "", children: "Presets\u2026" }),
165
- description.presets.map((p) => /* @__PURE__ */ jsx3("option", { value: p.name, children: p.name }, p.name))
166
- ]
167
- }
168
- ),
169
- fields.map((field) => {
170
- const label = parameterLabel(field);
171
- const inputId = `${idBase}-${field.id}`;
172
- const keyed = keyframed?.has(field.id) ?? false;
173
- const value = effectFieldValue(field, values[field.id]);
174
- const changed = !keyed && !parameterValuesEqual(value, field.default);
175
- return /* @__PURE__ */ jsxs2("div", { className: "space-y-1", "data-effect-control": field.id, children: [
176
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-1.5", children: [
177
- /* @__PURE__ */ jsx3("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
178
- keyed && /* @__PURE__ */ jsx3("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
179
- onReset && changed && !disabled && /* @__PURE__ */ jsx3("button", { type: "button", className: "rounded px-1 text-[11px] text-muted-foreground hover:text-foreground", "aria-label": `Reset ${label}`, onClick: () => onReset(field.id), children: "\u21BA" })
180
- ] }),
181
- /* @__PURE__ */ jsx3(
182
- ParameterFieldControl,
183
- {
184
- field,
185
- value,
186
- id: inputId,
187
- disabled: disabled || keyed,
188
- onChange: (v) => onChange(field.id, v, gesture.current),
189
- onGestureStart: () => gesture.current = `${idBase}:${field.id}:${++count.current}`,
190
- onGestureEnd: () => gesture.current = null
191
- }
192
- )
193
- ] }, field.id);
194
- }),
195
- !fields.length && /* @__PURE__ */ jsx3("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
196
- ] });
197
- }
198
-
199
- export {
200
- useEffects,
201
- useEffectDescription,
202
- EffectThumbnail,
203
- EffectsBrowser,
204
- EffectParameters
205
- };