@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
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { type EffectAuthoringSession } from '@pixerate/editor/effects';
3
+ export interface EffectAuthoringEditorProps {
4
+ /** The effect authoring session to edit. */
5
+ session: EffectAuthoringSession | null;
6
+ /** Whether to show the source code editor pane when supported (default true). */
7
+ showSource?: boolean;
8
+ /** Whether to show the keyframe timeline below parameters (default true). */
9
+ showTimeline?: boolean;
10
+ /** Size of the preview canvas (default 480 × 270). */
11
+ previewSize?: {
12
+ width: number;
13
+ height: number;
14
+ };
15
+ /** Additional CSS class names. */
16
+ className?: string;
17
+ }
18
+ /**
19
+ * Visual effect authoring editor: preview canvas, source code pane with line gutter,
20
+ * parameter controls with keyframe toggles, and keyframe timeline.
21
+ */
22
+ export declare function EffectAuthoringEditor({ session, showSource, showTimeline, previewSize, className }: EffectAuthoringEditorProps): React.JSX.Element;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import { type EffectAuthoringSession } from '@pixerate/editor/effects';
3
+ export interface EffectAuthoringEditorProps {
4
+ /** The effect authoring session to edit. */
5
+ session: EffectAuthoringSession | null;
6
+ /** Whether to show the source code editor pane when supported (default true). */
7
+ showSource?: boolean;
8
+ /** Whether to show the keyframe timeline below parameters (default true). */
9
+ showTimeline?: boolean;
10
+ /** Size of the preview canvas (default 480 × 270). */
11
+ previewSize?: {
12
+ width: number;
13
+ height: number;
14
+ };
15
+ /** Additional CSS class names. */
16
+ className?: string;
17
+ }
18
+ /**
19
+ * Visual effect authoring editor: preview canvas, source code pane with line gutter,
20
+ * parameter controls with keyframe toggles, and keyframe timeline.
21
+ */
22
+ export declare function EffectAuthoringEditor({ session, showSource, showTimeline, previewSize, className }: EffectAuthoringEditorProps): React.JSX.Element;
@@ -17,6 +17,10 @@ export interface EffectParametersProps {
17
17
  keyframed?: ReadonlySet<string>;
18
18
  /** Applies a preset's values. */
19
19
  onPreset?: (values: Readonly<Record<string, unknown>>) => void;
20
+ /** Applies a preset by name. */
21
+ onPresetName?: (name: string) => void;
22
+ /** Optional addon rendered next to the control label (e.g. keyframe toggle button). */
23
+ renderControlAddon?: (control: string) => React.ReactNode;
20
24
  disabled?: boolean;
21
25
  className?: string;
22
26
  }
@@ -25,4 +29,4 @@ export interface EffectParametersProps {
25
29
  * numbers, switches, choices, colour pickers, vectors and text, with each control's description,
26
30
  * per-control reset and the effect's presets.
27
31
  */
28
- export declare function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled, className }: EffectParametersProps): React.JSX.Element;
32
+ export declare function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, onPresetName, renderControlAddon, disabled, className }: EffectParametersProps): React.JSX.Element;
@@ -17,6 +17,10 @@ export interface EffectParametersProps {
17
17
  keyframed?: ReadonlySet<string>;
18
18
  /** Applies a preset's values. */
19
19
  onPreset?: (values: Readonly<Record<string, unknown>>) => void;
20
+ /** Applies a preset by name. */
21
+ onPresetName?: (name: string) => void;
22
+ /** Optional addon rendered next to the control label (e.g. keyframe toggle button). */
23
+ renderControlAddon?: (control: string) => React.ReactNode;
20
24
  disabled?: boolean;
21
25
  className?: string;
22
26
  }
@@ -25,4 +29,4 @@ export interface EffectParametersProps {
25
29
  * numbers, switches, choices, colour pickers, vectors and text, with each control's description,
26
30
  * per-control reset and the effect's presets.
27
31
  */
28
- export declare function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled, className }: EffectParametersProps): React.JSX.Element;
32
+ export declare function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, onPresetName, renderControlAddon, disabled, className }: EffectParametersProps): React.JSX.Element;
@@ -31,9 +31,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/effects/index.ts
32
32
  var effects_exports = {};
33
33
  __export(effects_exports, {
34
+ EffectAuthoringEditor: () => EffectAuthoringEditor,
34
35
  EffectParameters: () => EffectParameters,
35
36
  EffectThumbnail: () => EffectThumbnail,
36
37
  EffectsBrowser: () => EffectsBrowser,
38
+ useEffectAuthoring: () => useEffectAuthoring,
37
39
  useEffectDescription: () => useEffectDescription,
38
40
  useEffects: () => useEffects
39
41
  });
@@ -1588,13 +1590,24 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
1588
1590
 
1589
1591
  // src/effects/EffectParameters.tsx
1590
1592
  var import_jsx_runtime6 = require("react/jsx-runtime");
1591
- function EffectParameters({ description, values, onChange, onReset, keyframed, onPreset, disabled = false, className = "" }) {
1593
+ function EffectParameters({
1594
+ description,
1595
+ values,
1596
+ onChange,
1597
+ onReset,
1598
+ keyframed,
1599
+ onPreset,
1600
+ onPresetName,
1601
+ renderControlAddon,
1602
+ disabled = false,
1603
+ className = ""
1604
+ }) {
1592
1605
  const fields = (0, import_react8.useMemo)(() => (0, import_effects3.effectParameterFields)(description), [description]);
1593
1606
  const idBase = (0, import_react8.useId)();
1594
1607
  const gesture = import_react8.default.useRef(null);
1595
1608
  const count = import_react8.default.useRef(0);
1596
1609
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `space-y-2 ${className}`, "data-effect-parameters": description.id, children: [
1597
- onPreset && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1610
+ (onPreset || onPresetName) && description.presets.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1598
1611
  "select",
1599
1612
  {
1600
1613
  className: "w-full rounded border border-border bg-transparent px-1 py-0.5 text-xs",
@@ -1602,8 +1615,14 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1602
1615
  value: "",
1603
1616
  disabled,
1604
1617
  onChange: (e) => {
1605
- const preset = description.presets.find((p) => p.name === e.currentTarget.value);
1606
- if (preset) onPreset({ ...description.defaults, ...preset.values });
1618
+ const name = e.currentTarget.value;
1619
+ if (!name) return;
1620
+ if (onPresetName) {
1621
+ onPresetName(name);
1622
+ } else if (onPreset) {
1623
+ const preset = description.presets.find((p) => p.name === name);
1624
+ if (preset) onPreset({ ...description.defaults, ...preset.values });
1625
+ }
1607
1626
  },
1608
1627
  children: [
1609
1628
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "", children: "Presets\u2026" }),
@@ -1621,6 +1640,7 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1621
1640
  /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex items-center gap-1.5", children: [
1622
1641
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium", title: field.description, children: label }),
1623
1642
  keyed && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "text-[10px] text-muted-foreground", children: "keyframed" }),
1643
+ renderControlAddon?.(field.id),
1624
1644
  onReset && changed && !disabled && /* @__PURE__ */ (0, import_jsx_runtime6.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" })
1625
1645
  ] }),
1626
1646
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
@@ -1640,11 +1660,443 @@ function EffectParameters({ description, values, onChange, onReset, keyframed, o
1640
1660
  !fields.length && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "text-[11px] text-muted-foreground", children: "No controls." })
1641
1661
  ] });
1642
1662
  }
1663
+
1664
+ // src/effects/useEffectAuthoring.ts
1665
+ var import_react9 = require("react");
1666
+ function useEffectAuthoring(session) {
1667
+ return (0, import_react9.useSyncExternalStore)(
1668
+ (callback) => {
1669
+ if (!session) return () => {
1670
+ };
1671
+ return session.subscribe(callback);
1672
+ },
1673
+ () => session ? session.getState() : null,
1674
+ () => null
1675
+ );
1676
+ }
1677
+
1678
+ // src/effects/EffectAuthoringEditor.tsx
1679
+ var import_react10 = require("react");
1680
+ var import_effects4 = require("@pixerate/editor/effects");
1681
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1682
+ function EffectAuthoringEditor({
1683
+ session,
1684
+ showSource = true,
1685
+ showTimeline = true,
1686
+ previewSize = { width: 480, height: 270 },
1687
+ className = ""
1688
+ }) {
1689
+ const state = useEffectAuthoring(session);
1690
+ const canvasRef = (0, import_react10.useRef)(null);
1691
+ const rendererRef = (0, import_react10.useRef)(null);
1692
+ const [rendererReady, setRendererReady] = (0, import_react10.useState)(0);
1693
+ const renderingRef = (0, import_react10.useRef)(false);
1694
+ const pendingRef = (0, import_react10.useRef)(false);
1695
+ const timeRef = (0, import_react10.useRef)(0);
1696
+ const inputsRef = (0, import_react10.useRef)({});
1697
+ const [savingPreset, setSavingPreset] = (0, import_react10.useState)(false);
1698
+ const [presetName, setPresetName] = (0, import_react10.useState)("");
1699
+ const textareaRef = (0, import_react10.useRef)(null);
1700
+ const gutterRef = (0, import_react10.useRef)(null);
1701
+ const [sourceCode, setSourceCode] = (0, import_react10.useState)("");
1702
+ const sourceDebounceRef = (0, import_react10.useRef)(null);
1703
+ (0, import_react10.useEffect)(() => {
1704
+ if (!session) {
1705
+ if (rendererRef.current) {
1706
+ rendererRef.current.dispose();
1707
+ rendererRef.current = null;
1708
+ }
1709
+ return;
1710
+ }
1711
+ let live = true;
1712
+ let createdRenderer = null;
1713
+ Promise.resolve(session.createPreview(previewSize)).then((renderer) => {
1714
+ if (!live) {
1715
+ renderer.dispose();
1716
+ return;
1717
+ }
1718
+ createdRenderer = renderer;
1719
+ rendererRef.current = renderer;
1720
+ setRendererReady((c) => c + 1);
1721
+ });
1722
+ return () => {
1723
+ live = false;
1724
+ if (createdRenderer) {
1725
+ createdRenderer.dispose();
1726
+ }
1727
+ if (rendererRef.current === createdRenderer) {
1728
+ rendererRef.current = null;
1729
+ }
1730
+ };
1731
+ }, [session, previewSize.width, previewSize.height]);
1732
+ const pump = (0, import_react10.useCallback)(async () => {
1733
+ if (renderingRef.current) {
1734
+ pendingRef.current = true;
1735
+ return;
1736
+ }
1737
+ renderingRef.current = true;
1738
+ try {
1739
+ do {
1740
+ pendingRef.current = false;
1741
+ const renderer = rendererRef.current;
1742
+ if (!renderer) break;
1743
+ try {
1744
+ const pixels = await renderer.render({ time: timeRef.current, inputs: inputsRef.current });
1745
+ const ctx = rendererRef.current === renderer ? canvasRef.current?.getContext("2d") : null;
1746
+ if (ctx && typeof ImageData !== "undefined") {
1747
+ ctx.putImageData(new ImageData(new Uint8ClampedArray(pixels.data), pixels.width, pixels.height), 0, 0);
1748
+ }
1749
+ } catch {
1750
+ }
1751
+ } while (pendingRef.current);
1752
+ } finally {
1753
+ renderingRef.current = false;
1754
+ }
1755
+ }, []);
1756
+ const inputSpecs = state?.description.inputs;
1757
+ (0, import_react10.useEffect)(() => {
1758
+ inputsRef.current = inputSpecs ? (0, import_effects4.effectSampleInputs)({ inputs: inputSpecs }, previewSize) : {};
1759
+ }, [inputSpecs, previewSize.width, previewSize.height]);
1760
+ (0, import_react10.useEffect)(() => {
1761
+ if (!state) return;
1762
+ timeRef.current = state.time;
1763
+ void pump();
1764
+ }, [state, rendererReady, pump]);
1765
+ (0, import_react10.useEffect)(() => {
1766
+ if (state?.source !== null && state?.source !== void 0) {
1767
+ setSourceCode(state.source);
1768
+ }
1769
+ }, [state?.source]);
1770
+ (0, import_react10.useEffect)(() => {
1771
+ return () => {
1772
+ if (sourceDebounceRef.current) clearTimeout(sourceDebounceRef.current);
1773
+ };
1774
+ }, []);
1775
+ if (!session || !state) {
1776
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: `p-4 text-center text-xs text-muted-foreground ${className}`, children: "No effect authoring session is open." });
1777
+ }
1778
+ const hasSource = showSource && state.sourceLanguage !== null && typeof session.setSource === "function";
1779
+ const handleSourceChange = (e) => {
1780
+ const val = e.target.value;
1781
+ setSourceCode(val);
1782
+ if (sourceDebounceRef.current) clearTimeout(sourceDebounceRef.current);
1783
+ sourceDebounceRef.current = setTimeout(() => {
1784
+ session.setSource?.(val);
1785
+ }, 300);
1786
+ };
1787
+ const handleSavePreset = (e) => {
1788
+ e.preventDefault();
1789
+ const trimmed = presetName.trim();
1790
+ if (trimmed) {
1791
+ session.savePreset(trimmed);
1792
+ setSavingPreset(false);
1793
+ setPresetName("");
1794
+ }
1795
+ };
1796
+ const jumpToLine = (lineNum) => {
1797
+ if (!textareaRef.current) return;
1798
+ const lines = sourceCode.split("\n");
1799
+ let offset = 0;
1800
+ for (let i = 0; i < lineNum - 1 && i < lines.length; i++) {
1801
+ offset += lines[i].length + 1;
1802
+ }
1803
+ textareaRef.current.focus();
1804
+ textareaRef.current.setSelectionRange(offset, offset);
1805
+ };
1806
+ const sourceLines = sourceCode.split("\n");
1807
+ const issueLines = new Set(
1808
+ state.issues.map((i) => i.line).filter((l) => typeof l === "number")
1809
+ );
1810
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `space-y-4 rounded border border-border bg-background p-4 text-foreground ${className}`, "data-effect-authoring-editor": state.name, children: [
1811
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border pb-3", children: [
1812
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2", children: [
1813
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1814
+ "button",
1815
+ {
1816
+ type: "button",
1817
+ className: "rounded border border-border px-2.5 py-1 text-xs font-medium hover:bg-muted",
1818
+ "aria-label": state.playing ? "Pause playback" : "Start playback",
1819
+ onClick: () => state.playing ? session.pause() : session.play(),
1820
+ children: state.playing ? "Pause" : "Play"
1821
+ }
1822
+ ),
1823
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { className: "font-mono text-xs text-muted-foreground", "data-time-readout": true, children: [
1824
+ state.time,
1825
+ "ms / ",
1826
+ state.duration,
1827
+ "ms"
1828
+ ] })
1829
+ ] }),
1830
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2", children: [
1831
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1832
+ "button",
1833
+ {
1834
+ type: "button",
1835
+ className: "rounded border border-border px-2 py-1 text-xs disabled:opacity-40 hover:bg-muted",
1836
+ "aria-label": "Undo",
1837
+ disabled: !state.canUndo,
1838
+ onClick: () => session.undo(),
1839
+ children: "Undo"
1840
+ }
1841
+ ),
1842
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1843
+ "button",
1844
+ {
1845
+ type: "button",
1846
+ className: "rounded border border-border px-2 py-1 text-xs disabled:opacity-40 hover:bg-muted",
1847
+ "aria-label": "Redo",
1848
+ disabled: !state.canRedo,
1849
+ onClick: () => session.redo(),
1850
+ children: "Redo"
1851
+ }
1852
+ ),
1853
+ savingPreset ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("form", { onSubmit: handleSavePreset, className: "flex items-center gap-1", children: [
1854
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1855
+ "input",
1856
+ {
1857
+ type: "text",
1858
+ className: "rounded border border-border bg-background px-1.5 py-0.5 text-xs",
1859
+ placeholder: "Preset name",
1860
+ autoFocus: true,
1861
+ value: presetName,
1862
+ onChange: (e) => setPresetName(e.target.value)
1863
+ }
1864
+ ),
1865
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1866
+ "button",
1867
+ {
1868
+ type: "submit",
1869
+ className: "rounded bg-primary px-2 py-0.5 text-xs text-primary-foreground",
1870
+ children: "Save"
1871
+ }
1872
+ ),
1873
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1874
+ "button",
1875
+ {
1876
+ type: "button",
1877
+ className: "rounded border border-border px-1.5 py-0.5 text-xs hover:bg-muted",
1878
+ onClick: () => setSavingPreset(false),
1879
+ children: "Cancel"
1880
+ }
1881
+ )
1882
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1883
+ "button",
1884
+ {
1885
+ type: "button",
1886
+ className: "rounded border border-border px-2 py-1 text-xs hover:bg-muted",
1887
+ onClick: () => setSavingPreset(true),
1888
+ children: "Save preset\u2026"
1889
+ }
1890
+ )
1891
+ ] })
1892
+ ] }),
1893
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
1894
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-2", children: [
1895
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Preview" }),
1896
+ /* @__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)(
1897
+ "canvas",
1898
+ {
1899
+ ref: canvasRef,
1900
+ width: previewSize.width,
1901
+ height: previewSize.height,
1902
+ className: "h-full w-full object-contain",
1903
+ "aria-label": "Effect preview canvas"
1904
+ }
1905
+ ) }),
1906
+ 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)(
1907
+ "div",
1908
+ {
1909
+ className: `cursor-pointer ${issue.severity === "error" ? "text-destructive" : "text-amber-500"}`,
1910
+ onClick: () => issue.line !== void 0 && jumpToLine(issue.line),
1911
+ children: [
1912
+ issue.line !== void 0 ? `Line ${issue.line}: ` : "",
1913
+ issue.message
1914
+ ]
1915
+ },
1916
+ idx
1917
+ )) })
1918
+ ] }),
1919
+ hasSource && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-2", "data-effect-source-pane": true, children: [
1920
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex items-center justify-between text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("span", { children: [
1921
+ "Source (",
1922
+ state.sourceLanguage,
1923
+ ")"
1924
+ ] }) }),
1925
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex h-64 rounded border border-border bg-muted/20 font-mono text-xs", children: [
1926
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { ref: gutterRef, className: "select-none overflow-hidden border-r border-border bg-muted/40 px-2 py-2 text-right text-muted-foreground", "aria-hidden": "true", children: sourceLines.map((_, i) => {
1927
+ const lineNum = i + 1;
1928
+ const hasIssue = issueLines.has(lineNum);
1929
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1930
+ "div",
1931
+ {
1932
+ "data-gutter-line": lineNum,
1933
+ className: hasIssue ? "font-bold text-destructive" : "",
1934
+ children: lineNum
1935
+ },
1936
+ i
1937
+ );
1938
+ }) }),
1939
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1940
+ "textarea",
1941
+ {
1942
+ ref: textareaRef,
1943
+ value: sourceCode,
1944
+ onChange: handleSourceChange,
1945
+ onScroll: (e) => {
1946
+ if (gutterRef.current) gutterRef.current.scrollTop = e.currentTarget.scrollTop;
1947
+ },
1948
+ "aria-label": "Effect source code",
1949
+ spellCheck: false,
1950
+ wrap: "off",
1951
+ className: "flex-1 resize-none bg-transparent p-2 font-mono text-xs text-foreground focus:outline-none"
1952
+ }
1953
+ )
1954
+ ] })
1955
+ ] })
1956
+ ] }),
1957
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-2 border-t border-border pt-4", children: [
1958
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Parameters" }),
1959
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1960
+ EffectParameters,
1961
+ {
1962
+ description: state.description,
1963
+ values: state.values,
1964
+ onChange: (control, val, gesture) => session.setValue(control, val, { gesture }),
1965
+ onReset: (control) => session.resetValues([control]),
1966
+ onPresetName: (name) => session.applyPreset(name),
1967
+ renderControlAddon: (control) => {
1968
+ const track = state.tracks[control];
1969
+ const isAnimated = Boolean(track && track.length > 0);
1970
+ const hasKeyframeAtPlayhead = isAnimated && track.some((kf) => kf.time === state.time);
1971
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1972
+ "button",
1973
+ {
1974
+ type: "button",
1975
+ "data-keyframe-toggle": control,
1976
+ "aria-label": hasKeyframeAtPlayhead ? `Remove keyframe for ${control}` : `Add keyframe for ${control}`,
1977
+ onClick: () => {
1978
+ if (hasKeyframeAtPlayhead) {
1979
+ session.removeKeyframe(control, state.time);
1980
+ } else {
1981
+ session.setKeyframe(control, state.time);
1982
+ }
1983
+ },
1984
+ className: `rounded px-1 text-xs transition-colors ${hasKeyframeAtPlayhead ? "text-primary font-bold" : isAnimated ? "text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1985
+ title: hasKeyframeAtPlayhead ? "Remove keyframe at playhead" : "Add keyframe at playhead",
1986
+ children: hasKeyframeAtPlayhead ? "\u25C6" : "\u25C7"
1987
+ }
1988
+ );
1989
+ }
1990
+ }
1991
+ )
1992
+ ] }),
1993
+ showTimeline && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-3 border-t border-border pt-4", "data-effect-timeline": true, children: [
1994
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-wrap items-center justify-between gap-4", children: [
1995
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground", children: "Timeline" }),
1996
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-3 text-xs", children: [
1997
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center gap-1.5", children: [
1998
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Duration:" }),
1999
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DurationField, { duration: state.duration, onCommit: (duration) => session.setTiming({ duration }) }),
2000
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-muted-foreground", children: "ms" })
2001
+ ] }),
2002
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("label", { className: "flex items-center gap-1.5 cursor-pointer", children: [
2003
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2004
+ "input",
2005
+ {
2006
+ type: "checkbox",
2007
+ "aria-label": "Loop playback",
2008
+ checked: state.loop,
2009
+ onChange: (e) => session.setTiming({ loop: e.target.checked })
2010
+ }
2011
+ ),
2012
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { children: "Loop" })
2013
+ ] })
2014
+ ] })
2015
+ ] }),
2016
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "space-y-1", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2017
+ "input",
2018
+ {
2019
+ type: "range",
2020
+ "aria-label": "Timeline scrubber",
2021
+ min: 0,
2022
+ max: state.duration,
2023
+ value: state.time,
2024
+ onChange: (e) => session.seek(Number(e.target.value)),
2025
+ className: "w-full cursor-pointer accent-primary"
2026
+ }
2027
+ ) }),
2028
+ Object.entries(state.tracks).length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "space-y-2 pt-1", children: Object.entries(state.tracks).map(([control, keyframes]) => {
2029
+ if (!keyframes || keyframes.length === 0) return null;
2030
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "space-y-1", "data-track": control, children: [
2031
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center justify-between text-xs text-muted-foreground", children: [
2032
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "font-medium", children: control }),
2033
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2034
+ "button",
2035
+ {
2036
+ type: "button",
2037
+ className: "text-[11px] hover:text-foreground",
2038
+ onClick: () => session.clearTrack(control),
2039
+ "aria-label": `Clear animation track for ${control}`,
2040
+ children: "Clear track"
2041
+ }
2042
+ )
2043
+ ] }),
2044
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "relative h-4 w-full rounded bg-muted/40", children: keyframes.map((kf, i) => {
2045
+ const leftPct = Math.max(
2046
+ 0,
2047
+ Math.min(100, kf.time / (state.duration || 1) * 100)
2048
+ );
2049
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2050
+ "button",
2051
+ {
2052
+ type: "button",
2053
+ onClick: () => session.seek(kf.time),
2054
+ "aria-label": `Seek to ${control} keyframe at ${kf.time}ms`,
2055
+ title: `${control} @ ${kf.time}ms`,
2056
+ style: { left: `${leftPct}%` },
2057
+ className: "absolute top-1/2 -translate-x-1/2 -translate-y-1/2 text-[10px] text-primary hover:scale-125",
2058
+ children: "\u25C6"
2059
+ },
2060
+ i
2061
+ );
2062
+ }) })
2063
+ ] }, control);
2064
+ }) })
2065
+ ] })
2066
+ ] });
2067
+ }
2068
+ function DurationField({ duration, onCommit }) {
2069
+ const [draft, setDraft] = (0, import_react10.useState)(String(duration));
2070
+ (0, import_react10.useEffect)(() => setDraft(String(duration)), [duration]);
2071
+ const commit = () => {
2072
+ const next = Number(draft);
2073
+ if (Number.isFinite(next) && next >= 1 && next !== duration) onCommit(next);
2074
+ else setDraft(String(duration));
2075
+ };
2076
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2077
+ "input",
2078
+ {
2079
+ type: "number",
2080
+ "aria-label": "Duration",
2081
+ min: 1,
2082
+ value: draft,
2083
+ onChange: (e) => setDraft(e.target.value),
2084
+ onBlur: commit,
2085
+ onKeyDown: (e) => {
2086
+ if (e.key === "Enter") commit();
2087
+ else if (e.key === "Escape") setDraft(String(duration));
2088
+ },
2089
+ className: "w-16 rounded border border-border bg-background px-1.5 py-0.5 text-xs font-mono"
2090
+ }
2091
+ );
2092
+ }
1643
2093
  // Annotate the CommonJS export names for ESM import in node:
1644
2094
  0 && (module.exports = {
2095
+ EffectAuthoringEditor,
1645
2096
  EffectParameters,
1646
2097
  EffectThumbnail,
1647
2098
  EffectsBrowser,
2099
+ useEffectAuthoring,
1648
2100
  useEffectDescription,
1649
2101
  useEffects
1650
2102
  });
@@ -2,3 +2,5 @@ export * from './useEffects.cjs';
2
2
  export * from './EffectThumbnail.cjs';
3
3
  export * from './EffectsBrowser.cjs';
4
4
  export * from './EffectParameters.cjs';
5
+ export * from './useEffectAuthoring.cjs';
6
+ export * from './EffectAuthoringEditor.cjs';
@@ -2,3 +2,5 @@ export * from './useEffects.js';
2
2
  export * from './EffectThumbnail.js';
3
3
  export * from './EffectsBrowser.js';
4
4
  export * from './EffectParameters.js';
5
+ export * from './useEffectAuthoring.js';
6
+ export * from './EffectAuthoringEditor.js';
@@ -1,17 +1,21 @@
1
1
  import {
2
+ EffectAuthoringEditor,
2
3
  EffectParameters,
3
4
  EffectThumbnail,
4
5
  EffectsBrowser,
6
+ useEffectAuthoring,
5
7
  useEffectDescription,
6
8
  useEffects
7
- } from "../chunk-GLSOQNQR.js";
9
+ } from "../chunk-Q7LAFHGP.js";
8
10
  import "../chunk-5LFQ2UQZ.js";
9
11
  import "../chunk-KIRIU53A.js";
10
12
  import "../chunk-3I7FOSLF.js";
11
13
  export {
14
+ EffectAuthoringEditor,
12
15
  EffectParameters,
13
16
  EffectThumbnail,
14
17
  EffectsBrowser,
18
+ useEffectAuthoring,
15
19
  useEffectDescription,
16
20
  useEffects
17
21
  };
@@ -0,0 +1,6 @@
1
+ import type { EffectAuthoringSession, EffectAuthoringState } from '@pixerate/editor/effects';
2
+ /**
3
+ * Subscribes a React component to the observable state of an effect authoring session.
4
+ * Re-renders only when the session's state changes. Returns null when session is null.
5
+ */
6
+ export declare function useEffectAuthoring(session: EffectAuthoringSession | null): EffectAuthoringState | null;
@@ -0,0 +1,6 @@
1
+ import type { EffectAuthoringSession, EffectAuthoringState } from '@pixerate/editor/effects';
2
+ /**
3
+ * Subscribes a React component to the observable state of an effect authoring session.
4
+ * Re-renders only when the session's state changes. Returns null when session is null.
5
+ */
6
+ export declare function useEffectAuthoring(session: EffectAuthoringSession | null): EffectAuthoringState | null;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import type { AgentPlayback } from '@pixerate/editor/tools';
3
- import type { ExportOptions, InpaintHook, RemoveBackgroundHook, ImageEditorAIHooks } from '@pixerate/editor/image-editor';
3
+ import type { ExportOptions, ImageEditorFit, InpaintHook, RemoveBackgroundHook, ImageEditorAIHooks } from '@pixerate/editor/image-editor';
4
4
  import { type UseImageEditorReturn } from './useImageEditor.cjs';
5
5
  import type { EffectProvider } from '@pixerate/editor/effects';
6
6
  export interface ImageEditorProps {
@@ -13,6 +13,8 @@ export interface ImageEditorProps {
13
13
  onInpaint?: InpaintHook;
14
14
  onRemoveBackground?: RemoveBackgroundHook;
15
15
  aiHooks?: ImageEditorAIHooks;
16
+ /** How the image fits the canvas (default: the renderer's). */
17
+ fit?: ImageEditorFit;
16
18
  /**
17
19
  * An effects provider (see `@pixerate/editor/effects`), registered with the controller while
18
20
  * mounted: filter effects as smart filters and generator or overlay effects as effect layers,