@pixerate/editor-react 0.95.0 → 0.97.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 (56) hide show
  1. package/README.md +2 -0
  2. package/dist/animation-editor/index.cjs +1261 -198
  3. package/dist/animation-editor/index.js +4 -2
  4. package/dist/canvas/index.cjs +1439 -376
  5. package/dist/canvas/index.js +4 -2
  6. package/dist/chunk-3I7FOSLF.js +988 -0
  7. package/dist/{chunk-OTGJEYHV.js → chunk-5LFQ2UQZ.js} +75 -68
  8. package/dist/chunk-KIRIU53A.js +72 -0
  9. package/dist/{chunk-6YRSQW2V.js → chunk-NC4RLZTK.js} +1 -1
  10. package/dist/chunk-Q7LAFHGP.js +655 -0
  11. package/dist/color/ColorPicker.d.cts +30 -0
  12. package/dist/color/ColorPicker.d.ts +30 -0
  13. package/dist/color/DualColorPicker.d.cts +29 -0
  14. package/dist/color/DualColorPicker.d.ts +29 -0
  15. package/dist/color/index.cjs +1067 -0
  16. package/dist/color/index.d.cts +7 -0
  17. package/dist/color/index.d.ts +7 -0
  18. package/dist/color/index.js +14 -0
  19. package/dist/color/useColorScheme.d.cts +16 -0
  20. package/dist/color/useColorScheme.d.ts +16 -0
  21. package/dist/effects/EffectAuthoringEditor.d.cts +22 -0
  22. package/dist/effects/EffectAuthoringEditor.d.ts +22 -0
  23. package/dist/effects/EffectParameters.d.cts +5 -1
  24. package/dist/effects/EffectParameters.d.ts +5 -1
  25. package/dist/effects/index.cjs +1624 -127
  26. package/dist/effects/index.d.cts +2 -0
  27. package/dist/effects/index.d.ts +2 -0
  28. package/dist/effects/index.js +8 -2
  29. package/dist/effects/useEffectAuthoring.d.cts +6 -0
  30. package/dist/effects/useEffectAuthoring.d.ts +6 -0
  31. package/dist/gradient/FillPicker.d.cts +27 -0
  32. package/dist/gradient/FillPicker.d.ts +27 -0
  33. package/dist/gradient/GradientEditor.d.cts +21 -0
  34. package/dist/gradient/GradientEditor.d.ts +21 -0
  35. package/dist/gradient/index.cjs +1601 -0
  36. package/dist/gradient/index.d.cts +6 -0
  37. package/dist/gradient/index.d.ts +6 -0
  38. package/dist/gradient/index.js +617 -0
  39. package/dist/gradient/useGradientController.d.cts +10 -0
  40. package/dist/gradient/useGradientController.d.ts +10 -0
  41. package/dist/image-editor/index.cjs +1763 -700
  42. package/dist/image-editor/index.js +5 -3
  43. package/dist/index.cjs +2181 -1118
  44. package/dist/index.js +5 -3
  45. package/dist/paint-editor/index.cjs +1254 -191
  46. package/dist/paint-editor/index.js +4 -2
  47. package/dist/parameters/fields.d.cts +1 -1
  48. package/dist/parameters/fields.d.ts +1 -1
  49. package/dist/parameters/index.cjs +1218 -173
  50. package/dist/parameters/index.js +3 -1
  51. package/dist/vector/index.cjs +1240 -177
  52. package/dist/vector/index.js +4 -2
  53. package/dist/video-editor/index.cjs +1251 -188
  54. package/dist/video-editor/index.js +4 -2
  55. package/package.json +29 -3
  56. package/dist/chunk-5R67YSSD.js +0 -205
@@ -3,8 +3,10 @@ import {
3
3
  EffectsBrowser,
4
4
  useEffectDescription,
5
5
  useEffects
6
- } from "../chunk-5R67YSSD.js";
7
- import "../chunk-OTGJEYHV.js";
6
+ } from "../chunk-Q7LAFHGP.js";
7
+ import "../chunk-5LFQ2UQZ.js";
8
+ import "../chunk-KIRIU53A.js";
9
+ import "../chunk-3I7FOSLF.js";
8
10
  import {
9
11
  PresenceLayer,
10
12
  useAgentPlayback,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixerate/editor-react",
3
- "version": "0.95.0",
3
+ "version": "0.97.0",
4
4
  "description": "React bindings and prompt/rich-text components for @pixerate/editor",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -163,6 +163,26 @@
163
163
  "types": "./dist/video-editor/index.d.cts",
164
164
  "default": "./dist/video-editor/index.cjs"
165
165
  }
166
+ },
167
+ "./color": {
168
+ "import": {
169
+ "types": "./dist/color/index.d.ts",
170
+ "default": "./dist/color/index.js"
171
+ },
172
+ "require": {
173
+ "types": "./dist/color/index.d.cts",
174
+ "default": "./dist/color/index.cjs"
175
+ }
176
+ },
177
+ "./gradient": {
178
+ "import": {
179
+ "types": "./dist/gradient/index.d.ts",
180
+ "default": "./dist/gradient/index.js"
181
+ },
182
+ "require": {
183
+ "types": "./dist/gradient/index.d.cts",
184
+ "default": "./dist/gradient/index.cjs"
185
+ }
166
186
  }
167
187
  },
168
188
  "typesVersions": {
@@ -205,6 +225,12 @@
205
225
  ],
206
226
  "video-editor": [
207
227
  "./dist/video-editor/index.d.ts"
228
+ ],
229
+ "color": [
230
+ "./dist/color/index.d.ts"
231
+ ],
232
+ "gradient": [
233
+ "./dist/gradient/index.d.ts"
208
234
  ]
209
235
  }
210
236
  },
@@ -219,7 +245,7 @@
219
245
  },
220
246
  "peerDependencies": {
221
247
  "@dagrejs/dagre": "^1.1.8",
222
- "@pixerate/editor": ">=0.146.0 <1.0.0-0",
248
+ "@pixerate/editor": ">=0.148.0 <1.0.0-0",
223
249
  "@tiptap/core": "^2.27.3",
224
250
  "@tiptap/pm": "^2.27.3",
225
251
  "@tiptap/react": "^2.27.3",
@@ -246,7 +272,7 @@
246
272
  "tsup": "^9.0.0",
247
273
  "typescript": "^5.7.3",
248
274
  "vitest": "^5.0.5",
249
- "@pixerate/editor": "0.146.0"
275
+ "@pixerate/editor": "0.148.0"
250
276
  },
251
277
  "scripts": {
252
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-OTGJEYHV.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
- };