@pixerate/editor-react 0.159.0 → 0.161.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.
- package/dist/hooks/usePromptEditor.d.cts +11 -1
- package/dist/hooks/usePromptEditor.d.ts +11 -1
- package/dist/index.cjs +1920 -1869
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +195 -145
- package/dist/loading-node/LoadingIndicator.d.cts +13 -0
- package/dist/loading-node/LoadingIndicator.d.ts +13 -0
- package/dist/loading-node/index.d.cts +1 -0
- package/dist/loading-node/index.d.ts +1 -0
- package/dist/paint-editor/StickerPanel.d.cts +3 -3
- package/dist/paint-editor/StickerPanel.d.ts +3 -3
- package/dist/paint-editor/index.cjs +108 -92
- package/dist/paint-editor/index.js +29 -13
- package/package.json +3 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { LoadingNodeViewMount, LoadingNodeViewState } from '@pixerate/editor';
|
|
3
|
+
export interface LoadingIndicatorProps {
|
|
4
|
+
/** What the editor's `loadingNode` passes (see `LoadingNodeViewState`). */
|
|
5
|
+
state: LoadingNodeViewState;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The `nodeView` for the core `loadingNode`, drawing `component` inside each placeholder in its
|
|
9
|
+
* own React root: `LoadingNode.configure({ nodeView: createReactLoadingNodeView(MyLoader) })`.
|
|
10
|
+
* The placeholder keeps `role="status"` and its `aria-label`, so the component can be decorative.
|
|
11
|
+
* Works with any TipTap editor (it does not need `EditorContent`); app context does not reach it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createReactLoadingNodeView(component: React.ComponentType<LoadingIndicatorProps>): LoadingNodeViewMount;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { LoadingNodeViewMount, LoadingNodeViewState } from '@pixerate/editor';
|
|
3
|
+
export interface LoadingIndicatorProps {
|
|
4
|
+
/** What the editor's `loadingNode` passes (see `LoadingNodeViewState`). */
|
|
5
|
+
state: LoadingNodeViewState;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The `nodeView` for the core `loadingNode`, drawing `component` inside each placeholder in its
|
|
9
|
+
* own React root: `LoadingNode.configure({ nodeView: createReactLoadingNodeView(MyLoader) })`.
|
|
10
|
+
* The placeholder keeps `role="status"` and its `aria-label`, so the component can be decorative.
|
|
11
|
+
* Works with any TipTap editor (it does not need `EditorContent`); app context does not reach it.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createReactLoadingNodeView(component: React.ComponentType<LoadingIndicatorProps>): LoadingNodeViewMount;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LoadingIndicator.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LoadingIndicator.js';
|
|
@@ -5,8 +5,8 @@ export interface StickerPanelProps {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* The active layer's stickers: pick one
|
|
9
|
-
* bring it to the front or back, or delete it
|
|
10
|
-
* layer without stickers.
|
|
8
|
+
* The active layer's stickers: pick one (here, or with the Stickers tool on the canvas) to change
|
|
9
|
+
* its stamp, place, size, rotation, opacity and colour, bring it to the front or back, or delete it
|
|
10
|
+
* (each change one undo step). Shows nothing for a layer without stickers.
|
|
11
11
|
*/
|
|
12
12
|
export declare const StickerPanel: React.FC<StickerPanelProps>;
|
|
@@ -5,8 +5,8 @@ export interface StickerPanelProps {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
|
-
* The active layer's stickers: pick one
|
|
9
|
-
* bring it to the front or back, or delete it
|
|
10
|
-
* layer without stickers.
|
|
8
|
+
* The active layer's stickers: pick one (here, or with the Stickers tool on the canvas) to change
|
|
9
|
+
* its stamp, place, size, rotation, opacity and colour, bring it to the front or back, or delete it
|
|
10
|
+
* (each change one undo step). Shows nothing for a layer without stickers.
|
|
11
11
|
*/
|
|
12
12
|
export declare const StickerPanel: React.FC<StickerPanelProps>;
|
|
@@ -203,8 +203,8 @@ var PaintCanvas = ({ controller, tool = "brush", showGuides = true, fitOnMount =
|
|
|
203
203
|
y1: l.from.y,
|
|
204
204
|
x2: l.to.x,
|
|
205
205
|
y2: l.to.y,
|
|
206
|
-
stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : "#f472b6",
|
|
207
|
-
strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" ? 0.8 : 0.35,
|
|
206
|
+
stroke: l.kind === "symmetry" ? "#22d3ee" : l.kind === "stencil" ? "#fbbf24" : l.kind === "sticker" ? "#818cf8" : "#f472b6",
|
|
207
|
+
strokeOpacity: l.kind === "symmetry" || l.kind === "stencil" || l.kind === "sticker" ? 0.8 : 0.35,
|
|
208
208
|
strokeWidth: 1 / state.view.zoom,
|
|
209
209
|
strokeDasharray: l.kind === "symmetry" ? `${6 / state.view.zoom} ${4 / state.view.zoom}` : void 0
|
|
210
210
|
},
|
|
@@ -1300,13 +1300,13 @@ var WetPanel = ({ controller, className }) => {
|
|
|
1300
1300
|
};
|
|
1301
1301
|
|
|
1302
1302
|
// src/paint-editor/StickerPanel.tsx
|
|
1303
|
-
var import_react10 = require("react");
|
|
1304
1303
|
var import_paint_editor12 = require("@pixerate/editor/paint-editor");
|
|
1305
1304
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1306
1305
|
var StickerPanel = ({ controller, className }) => {
|
|
1307
1306
|
const state = usePaintEditorState(controller);
|
|
1308
1307
|
const [error, attempt] = useAttempt();
|
|
1309
|
-
const
|
|
1308
|
+
const picked = state.selectedSticker;
|
|
1309
|
+
const setPicked = (id) => controller.selectSticker(id);
|
|
1310
1310
|
const layerId = state.document.activeLayerId;
|
|
1311
1311
|
const stickers = layerId ? state.document.stickers?.[layerId] ?? [] : [];
|
|
1312
1312
|
if (!stickers.length) return null;
|
|
@@ -1323,6 +1323,22 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1323
1323
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Stamp" }),
|
|
1324
1324
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("select", { "aria-label": "Sticker stamp", value: sel.stamp, onChange: (e) => attempt(() => controller.updateSticker(layerId, sel.id, { stamp: e.target.value })), className: "rounded bg-slate-800 px-1 py-0.5", children: import_paint_editor12.STAMP_KINDS.map((k) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: k, children: import_paint_editor12.STAMP_LABELS[k] }, k)) })
|
|
1325
1325
|
] }),
|
|
1326
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center justify-between gap-2", children: [
|
|
1327
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Position" }),
|
|
1328
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "flex gap-1", children: ["x", "y"].map((k) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1329
|
+
"input",
|
|
1330
|
+
{
|
|
1331
|
+
type: "number",
|
|
1332
|
+
"aria-label": `Sticker ${k}`,
|
|
1333
|
+
defaultValue: sel[k],
|
|
1334
|
+
step: 1,
|
|
1335
|
+
onBlur: (e) => Number(e.target.value) !== sel[k] && attempt(() => controller.updateSticker(layerId, sel.id, { [k]: Number(e.target.value) })),
|
|
1336
|
+
onKeyDown: (e) => e.key === "Enter" && e.currentTarget.blur(),
|
|
1337
|
+
className: "w-16 rounded bg-slate-800 px-1 py-0.5"
|
|
1338
|
+
},
|
|
1339
|
+
`${sel.id}-${k}-${sel[k]}`
|
|
1340
|
+
)) })
|
|
1341
|
+
] }),
|
|
1326
1342
|
import_paint_editor12.STICKER_SLIDERS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PaintSlider, { control: c, value: (0, import_paint_editor12.readPath)(sel, c.path), onCommit: (v) => attempt(() => controller.updateSticker(layerId, sel.id, { [c.path]: v })) }, c.path)),
|
|
1327
1343
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("label", { className: "flex items-center justify-between", children: [
|
|
1328
1344
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "text-slate-400", children: "Colour" }),
|
|
@@ -1339,28 +1355,28 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1339
1355
|
};
|
|
1340
1356
|
|
|
1341
1357
|
// src/paint-editor/PaintEditor.tsx
|
|
1342
|
-
var
|
|
1358
|
+
var import_react23 = require("react");
|
|
1343
1359
|
var import_paint_editor14 = require("@pixerate/editor/paint-editor");
|
|
1344
1360
|
|
|
1345
1361
|
// src/playback/AgentPlaybackContext.tsx
|
|
1346
|
-
var
|
|
1362
|
+
var import_react10 = require("react");
|
|
1347
1363
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1348
|
-
var AgentPlaybackContext = (0,
|
|
1364
|
+
var AgentPlaybackContext = (0, import_react10.createContext)(null);
|
|
1349
1365
|
function useAgentPlayback() {
|
|
1350
|
-
return (0,
|
|
1366
|
+
return (0, import_react10.useContext)(AgentPlaybackContext);
|
|
1351
1367
|
}
|
|
1352
1368
|
|
|
1353
1369
|
// src/playback/usePlaybackSurface.ts
|
|
1354
|
-
var
|
|
1370
|
+
var import_react11 = require("react");
|
|
1355
1371
|
var import_tools = require("@pixerate/editor/tools");
|
|
1356
1372
|
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
1357
1373
|
const ambient = useAgentPlayback();
|
|
1358
1374
|
const target = playback === void 0 ? ambient : playback;
|
|
1359
|
-
const [ownPresence] = (0,
|
|
1375
|
+
const [ownPresence] = (0, import_react11.useState)(() => new import_tools.PresenceStore());
|
|
1360
1376
|
const presence = sharedPresence ?? ownPresence;
|
|
1361
|
-
const latest = (0,
|
|
1377
|
+
const latest = (0, import_react11.useRef)(options);
|
|
1362
1378
|
latest.current = options;
|
|
1363
|
-
(0,
|
|
1379
|
+
(0, import_react11.useEffect)(() => {
|
|
1364
1380
|
if (!target || !id) return;
|
|
1365
1381
|
const o = () => latest.current;
|
|
1366
1382
|
const surface = {
|
|
@@ -1392,10 +1408,10 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
|
1392
1408
|
}
|
|
1393
1409
|
|
|
1394
1410
|
// src/playback/PresenceLayer.tsx
|
|
1395
|
-
var
|
|
1411
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
1396
1412
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1397
1413
|
function PresenceLayer({ presence, viewport, clip = true, renderCursor, className = "" }) {
|
|
1398
|
-
const { actors } = (0,
|
|
1414
|
+
const { actors } = (0, import_react12.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
1399
1415
|
if (!actors.length) return null;
|
|
1400
1416
|
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
1401
1417
|
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
@@ -1412,7 +1428,7 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
1412
1428
|
const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
|
|
1413
1429
|
return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
|
|
1414
1430
|
})();
|
|
1415
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
1431
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_react12.default.Fragment, { children: [
|
|
1416
1432
|
ring && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1417
1433
|
"div",
|
|
1418
1434
|
{
|
|
@@ -1434,15 +1450,15 @@ function PresenceLayer({ presence, viewport, clip = true, renderCursor, classNam
|
|
|
1434
1450
|
}
|
|
1435
1451
|
|
|
1436
1452
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1437
|
-
var
|
|
1453
|
+
var import_react22 = require("react");
|
|
1438
1454
|
var import_paint_editor13 = require("@pixerate/editor/paint-editor");
|
|
1439
1455
|
|
|
1440
1456
|
// src/effects/useEffects.ts
|
|
1441
|
-
var
|
|
1457
|
+
var import_react13 = require("react");
|
|
1442
1458
|
function useEffectDescription(provider, effect) {
|
|
1443
|
-
const [state, setState] = (0,
|
|
1459
|
+
const [state, setState] = (0, import_react13.useState)({ key: "", description: null, error: null });
|
|
1444
1460
|
const key = provider && effect ? `${provider.id}:${effect}` : "";
|
|
1445
|
-
(0,
|
|
1461
|
+
(0, import_react13.useEffect)(() => {
|
|
1446
1462
|
if (!provider || !effect) return;
|
|
1447
1463
|
let live = true;
|
|
1448
1464
|
Promise.resolve().then(() => provider.describe(effect)).then(
|
|
@@ -1457,14 +1473,14 @@ function useEffectDescription(provider, effect) {
|
|
|
1457
1473
|
}
|
|
1458
1474
|
|
|
1459
1475
|
// src/effects/EffectThumbnail.tsx
|
|
1460
|
-
var
|
|
1476
|
+
var import_react14 = require("react");
|
|
1461
1477
|
var import_effects = require("@pixerate/editor/effects");
|
|
1462
1478
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1463
1479
|
var LABELS = { motion: "Motion", camera: "Camera" };
|
|
1464
1480
|
function EffectThumbnail({ provider, effect, width = 96, height = 54, className = "" }) {
|
|
1465
|
-
const ref = (0,
|
|
1466
|
-
const [failed, setFailed] = (0,
|
|
1467
|
-
(0,
|
|
1481
|
+
const ref = (0, import_react14.useRef)(null);
|
|
1482
|
+
const [failed, setFailed] = (0, import_react14.useState)(effect.kind in LABELS);
|
|
1483
|
+
(0, import_react14.useEffect)(() => {
|
|
1468
1484
|
if (effect.kind in LABELS) return;
|
|
1469
1485
|
let live = true;
|
|
1470
1486
|
(0, import_effects.renderEffectThumbnail)(provider, effect, { width, height }).then(
|
|
@@ -1491,16 +1507,16 @@ function EffectThumbnail({ provider, effect, width = 96, height = 54, className
|
|
|
1491
1507
|
}
|
|
1492
1508
|
|
|
1493
1509
|
// src/effects/EffectsBrowser.tsx
|
|
1494
|
-
var
|
|
1510
|
+
var import_react15 = require("react");
|
|
1495
1511
|
var import_effects2 = require("@pixerate/editor/effects");
|
|
1496
1512
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1497
1513
|
function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, title = "Effects", className = "" }) {
|
|
1498
|
-
const [all, setAll] = (0,
|
|
1499
|
-
const [query, setQuery] = (0,
|
|
1500
|
-
const [category, setCategory] = (0,
|
|
1501
|
-
const [use, setUse] = (0,
|
|
1502
|
-
const [error, setError] = (0,
|
|
1503
|
-
(0,
|
|
1514
|
+
const [all, setAll] = (0, import_react15.useState)([]);
|
|
1515
|
+
const [query, setQuery] = (0, import_react15.useState)("");
|
|
1516
|
+
const [category, setCategory] = (0, import_react15.useState)("");
|
|
1517
|
+
const [use, setUse] = (0, import_react15.useState)("");
|
|
1518
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
1519
|
+
(0, import_react15.useEffect)(() => {
|
|
1504
1520
|
if (!provider) return setAll([]);
|
|
1505
1521
|
let live = true;
|
|
1506
1522
|
Promise.resolve().then(() => provider.list()).then(
|
|
@@ -1511,8 +1527,8 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1511
1527
|
live = false;
|
|
1512
1528
|
};
|
|
1513
1529
|
}, [provider]);
|
|
1514
|
-
const [found, setFound] = (0,
|
|
1515
|
-
(0,
|
|
1530
|
+
const [found, setFound] = (0, import_react15.useState)([]);
|
|
1531
|
+
(0, import_react15.useEffect)(() => {
|
|
1516
1532
|
if (!provider) return setFound([]);
|
|
1517
1533
|
let live = true;
|
|
1518
1534
|
Promise.resolve().then(() => provider.search(query, { ...category ? { category } : {}, ...use ? { use } : {} })).then((list) => live && setFound(list), () => live && setFound([]));
|
|
@@ -1521,7 +1537,7 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1521
1537
|
};
|
|
1522
1538
|
}, [provider, query, category, use]);
|
|
1523
1539
|
const allowed = (e) => (!kinds || kinds.includes(e.kind)) && (0, import_effects2.effectOffered)(e, uses);
|
|
1524
|
-
const categories = (0,
|
|
1540
|
+
const categories = (0, import_react15.useMemo)(() => [...new Set(all.filter(allowed).map((e) => e.category))], [all, uses, kinds]);
|
|
1525
1541
|
const shown = found.filter(allowed);
|
|
1526
1542
|
if (!provider)
|
|
1527
1543
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("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." });
|
|
@@ -1569,12 +1585,12 @@ function EffectsBrowser({ provider, uses, kinds, onPick, thumbnails = true, titl
|
|
|
1569
1585
|
}
|
|
1570
1586
|
|
|
1571
1587
|
// src/effects/EffectParameters.tsx
|
|
1572
|
-
var
|
|
1588
|
+
var import_react21 = __toESM(require("react"), 1);
|
|
1573
1589
|
var import_effects3 = require("@pixerate/editor/effects");
|
|
1574
1590
|
var import_parameters2 = require("@pixerate/editor/parameters");
|
|
1575
1591
|
|
|
1576
1592
|
// src/parameters/fields.tsx
|
|
1577
|
-
var
|
|
1593
|
+
var import_react20 = require("react");
|
|
1578
1594
|
var import_parameters = require("@pixerate/editor/parameters");
|
|
1579
1595
|
|
|
1580
1596
|
// src/color/index.ts
|
|
@@ -1587,7 +1603,7 @@ __export(color_exports, {
|
|
|
1587
1603
|
});
|
|
1588
1604
|
|
|
1589
1605
|
// src/color/ColorPicker.tsx
|
|
1590
|
-
var
|
|
1606
|
+
var import_react16 = require("react");
|
|
1591
1607
|
var import_color = require("@pixerate/editor/color");
|
|
1592
1608
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1593
1609
|
var LOCAL_STORAGE_KEY = "pixerate:color:recent";
|
|
@@ -1627,24 +1643,24 @@ var ColorPicker = ({
|
|
|
1627
1643
|
id,
|
|
1628
1644
|
"aria-label": ariaLabel = "Color picker"
|
|
1629
1645
|
}) => {
|
|
1630
|
-
const generatedId = (0,
|
|
1646
|
+
const generatedId = (0, import_react16.useId)();
|
|
1631
1647
|
const pickerId = id || generatedId;
|
|
1632
|
-
const [pickerState, setPickerState] = (0,
|
|
1648
|
+
const [pickerState, setPickerState] = (0, import_react16.useState)(
|
|
1633
1649
|
() => (0, import_color.pickerStateFromColor)(value) ?? DEFAULT_PICKER_STATE
|
|
1634
1650
|
);
|
|
1635
|
-
const stateRef = (0,
|
|
1651
|
+
const stateRef = (0, import_react16.useRef)(pickerState);
|
|
1636
1652
|
stateRef.current = pickerState;
|
|
1637
|
-
(0,
|
|
1653
|
+
(0, import_react16.useEffect)(() => {
|
|
1638
1654
|
const next = (0, import_color.pickerStateFromColor)(value, stateRef.current);
|
|
1639
1655
|
if (next) {
|
|
1640
1656
|
setPickerState(next);
|
|
1641
1657
|
}
|
|
1642
1658
|
}, [value]);
|
|
1643
|
-
const [internalRecent, setInternalRecent] = (0,
|
|
1659
|
+
const [internalRecent, setInternalRecent] = (0, import_react16.useState)(
|
|
1644
1660
|
() => controlledRecent ? [] : readLocalRecents()
|
|
1645
1661
|
);
|
|
1646
1662
|
const activeRecent = controlledRecent ?? internalRecent;
|
|
1647
|
-
const recordRecent = (0,
|
|
1663
|
+
const recordRecent = (0, import_react16.useCallback)(
|
|
1648
1664
|
(color) => {
|
|
1649
1665
|
const updated = (0, import_color.pushRecentColor)(activeRecent, color, 12);
|
|
1650
1666
|
if (!controlledRecent) {
|
|
@@ -1655,11 +1671,11 @@ var ColorPicker = ({
|
|
|
1655
1671
|
},
|
|
1656
1672
|
[activeRecent, controlledRecent, onRecentChange]
|
|
1657
1673
|
);
|
|
1658
|
-
const [textDraft, setTextDraft] = (0,
|
|
1659
|
-
const [isInvalid, setIsInvalid] = (0,
|
|
1660
|
-
const [isClipped, setIsClipped] = (0,
|
|
1661
|
-
const isTypingRef = (0,
|
|
1662
|
-
(0,
|
|
1674
|
+
const [textDraft, setTextDraft] = (0, import_react16.useState)(value);
|
|
1675
|
+
const [isInvalid, setIsInvalid] = (0, import_react16.useState)(false);
|
|
1676
|
+
const [isClipped, setIsClipped] = (0, import_react16.useState)(false);
|
|
1677
|
+
const isTypingRef = (0, import_react16.useRef)(false);
|
|
1678
|
+
(0, import_react16.useEffect)(() => {
|
|
1663
1679
|
if (!isTypingRef.current) {
|
|
1664
1680
|
setTextDraft(value);
|
|
1665
1681
|
setIsInvalid(false);
|
|
@@ -1667,11 +1683,11 @@ var ColorPicker = ({
|
|
|
1667
1683
|
setIsClipped(Boolean(parsed && !(0, import_color.inSrgbGamut)(parsed)));
|
|
1668
1684
|
}
|
|
1669
1685
|
}, [value]);
|
|
1670
|
-
const [hasEyeDropper, setHasEyeDropper] = (0,
|
|
1671
|
-
(0,
|
|
1686
|
+
const [hasEyeDropper, setHasEyeDropper] = (0, import_react16.useState)(false);
|
|
1687
|
+
(0, import_react16.useEffect)(() => {
|
|
1672
1688
|
setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
|
|
1673
1689
|
}, []);
|
|
1674
|
-
const emitColorChange = (0,
|
|
1690
|
+
const emitColorChange = (0, import_react16.useCallback)(
|
|
1675
1691
|
(nextState) => {
|
|
1676
1692
|
setPickerState(nextState);
|
|
1677
1693
|
const hex = (0, import_color.pickerStateToHex)(nextState, alpha);
|
|
@@ -1679,10 +1695,10 @@ var ColorPicker = ({
|
|
|
1679
1695
|
},
|
|
1680
1696
|
[alpha, onChange]
|
|
1681
1697
|
);
|
|
1682
|
-
const latest = (0,
|
|
1698
|
+
const latest = (0, import_react16.useRef)({ emitColorChange, recordRecent, onGestureEnd, alpha });
|
|
1683
1699
|
latest.current = { emitColorChange, recordRecent, onGestureEnd, alpha };
|
|
1684
|
-
const endDragRef = (0,
|
|
1685
|
-
(0,
|
|
1700
|
+
const endDragRef = (0, import_react16.useRef)(null);
|
|
1701
|
+
(0, import_react16.useEffect)(() => () => endDragRef.current?.(), []);
|
|
1686
1702
|
const startDrag = (e, next) => {
|
|
1687
1703
|
if (disabled) return;
|
|
1688
1704
|
e.preventDefault();
|
|
@@ -1784,7 +1800,7 @@ var ColorPicker = ({
|
|
|
1784
1800
|
} catch {
|
|
1785
1801
|
}
|
|
1786
1802
|
};
|
|
1787
|
-
const contrastResult = (0,
|
|
1803
|
+
const contrastResult = (0, import_react16.useMemo)(() => {
|
|
1788
1804
|
if (!contrastAgainst) return null;
|
|
1789
1805
|
const fg = (0, import_color.parseColor)(value);
|
|
1790
1806
|
const bg = (0, import_color.parseColor)(contrastAgainst);
|
|
@@ -2211,7 +2227,7 @@ var ColorPicker = ({
|
|
|
2211
2227
|
};
|
|
2212
2228
|
|
|
2213
2229
|
// src/color/DualColorPicker.tsx
|
|
2214
|
-
var
|
|
2230
|
+
var import_react17 = require("react");
|
|
2215
2231
|
var import_color2 = require("@pixerate/editor/color");
|
|
2216
2232
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2217
2233
|
function DualColorPicker({
|
|
@@ -2228,8 +2244,8 @@ function DualColorPicker({
|
|
|
2228
2244
|
disabled = false,
|
|
2229
2245
|
className = ""
|
|
2230
2246
|
}) {
|
|
2231
|
-
const sameId = (0,
|
|
2232
|
-
const [internalScheme, setInternalScheme] = (0,
|
|
2247
|
+
const sameId = (0, import_react17.useId)();
|
|
2248
|
+
const [internalScheme, setInternalScheme] = (0, import_react17.useState)("light");
|
|
2233
2249
|
const activeScheme = controlledScheme ?? internalScheme;
|
|
2234
2250
|
const handleSchemeSelect = (nextScheme) => {
|
|
2235
2251
|
if (onSchemeChange) {
|
|
@@ -2240,7 +2256,7 @@ function DualColorPicker({
|
|
|
2240
2256
|
};
|
|
2241
2257
|
const dual = (0, import_color2.normalizeDualColor)(value) ?? { light: "#000000", dark: "#000000" };
|
|
2242
2258
|
const isSame = dual.light.toLowerCase() === dual.dark.toLowerCase();
|
|
2243
|
-
const [sameInBoth, setSameInBoth] = (0,
|
|
2259
|
+
const [sameInBoth, setSameInBoth] = (0, import_react17.useState)(isSame);
|
|
2244
2260
|
const handleSameToggle = (e) => {
|
|
2245
2261
|
const nextSame = e.target.checked;
|
|
2246
2262
|
setSameInBoth(nextSame);
|
|
@@ -2549,7 +2565,7 @@ function DualColorPicker({
|
|
|
2549
2565
|
}
|
|
2550
2566
|
|
|
2551
2567
|
// src/color/useColorScheme.ts
|
|
2552
|
-
var
|
|
2568
|
+
var import_react18 = require("react");
|
|
2553
2569
|
var import_color3 = require("@pixerate/editor/color");
|
|
2554
2570
|
function getSnapshot(attribute) {
|
|
2555
2571
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -2574,7 +2590,7 @@ function getServerSnapshot() {
|
|
|
2574
2590
|
function useColorScheme(options) {
|
|
2575
2591
|
const override = options?.override;
|
|
2576
2592
|
const attribute = options?.attribute;
|
|
2577
|
-
const subscribe = (0,
|
|
2593
|
+
const subscribe = (0, import_react18.useMemo)(() => {
|
|
2578
2594
|
return (callback) => {
|
|
2579
2595
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
2580
2596
|
return () => {
|
|
@@ -2600,7 +2616,7 @@ function useColorScheme(options) {
|
|
|
2600
2616
|
};
|
|
2601
2617
|
};
|
|
2602
2618
|
}, [attribute]);
|
|
2603
|
-
const detected = (0,
|
|
2619
|
+
const detected = (0, import_react18.useSyncExternalStore)(
|
|
2604
2620
|
subscribe,
|
|
2605
2621
|
() => getSnapshot(attribute),
|
|
2606
2622
|
getServerSnapshot
|
|
@@ -2617,11 +2633,11 @@ function useResolvedColor(value, scheme) {
|
|
|
2617
2633
|
__reExport(color_exports, require("@pixerate/editor/color"));
|
|
2618
2634
|
|
|
2619
2635
|
// src/parameters/controls.tsx
|
|
2620
|
-
var
|
|
2636
|
+
var import_react19 = require("react");
|
|
2621
2637
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2622
|
-
var ParameterComponentsContext = (0,
|
|
2638
|
+
var ParameterComponentsContext = (0, import_react19.createContext)({});
|
|
2623
2639
|
function useParameterComponents() {
|
|
2624
|
-
return (0,
|
|
2640
|
+
return (0, import_react19.useContext)(ParameterComponentsContext);
|
|
2625
2641
|
}
|
|
2626
2642
|
function resolveParameterComponents(explicit, context) {
|
|
2627
2643
|
return {
|
|
@@ -2642,9 +2658,9 @@ var parameterInputClass = "h-7 w-full min-w-0 rounded-md border border-input bg-
|
|
|
2642
2658
|
var parameterButtonClass = "inline-flex h-7 items-center justify-center gap-1 rounded-md border border-input bg-background px-2 text-xs text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50";
|
|
2643
2659
|
var rangeClass = "h-4 w-full min-w-0 flex-1 cursor-pointer accent-primary disabled:cursor-not-allowed disabled:opacity-50";
|
|
2644
2660
|
function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown, style, ...rest }) {
|
|
2645
|
-
const inputRef = (0,
|
|
2646
|
-
const lastCommitted = (0,
|
|
2647
|
-
(0,
|
|
2661
|
+
const inputRef = (0, import_react20.useRef)(null);
|
|
2662
|
+
const lastCommitted = (0, import_react20.useRef)(null);
|
|
2663
|
+
(0, import_react20.useLayoutEffect)(() => {
|
|
2648
2664
|
lastCommitted.current = null;
|
|
2649
2665
|
const el = inputRef.current;
|
|
2650
2666
|
if (el && el.value !== value) el.value = value;
|
|
@@ -2655,9 +2671,9 @@ function ParameterCommitInput({ value, onCommit, multiline, className, onKeyDown
|
|
|
2655
2671
|
onCommit(text, el);
|
|
2656
2672
|
lastCommitted.current = el.value === text ? text : null;
|
|
2657
2673
|
};
|
|
2658
|
-
const commitRef = (0,
|
|
2674
|
+
const commitRef = (0, import_react20.useRef)(commit);
|
|
2659
2675
|
commitRef.current = commit;
|
|
2660
|
-
(0,
|
|
2676
|
+
(0, import_react20.useEffect)(() => {
|
|
2661
2677
|
const el = inputRef.current;
|
|
2662
2678
|
if (!el) return;
|
|
2663
2679
|
const change = () => commitRef.current(el);
|
|
@@ -2732,7 +2748,7 @@ function ParameterSlider(props) {
|
|
|
2732
2748
|
const ctx = useParameterComponents();
|
|
2733
2749
|
const resolved = resolveParameterComponents(components, ctx);
|
|
2734
2750
|
const CustomSlider = resolved.slider;
|
|
2735
|
-
const dragging = (0,
|
|
2751
|
+
const dragging = (0, import_react20.useRef)(false);
|
|
2736
2752
|
const start = () => {
|
|
2737
2753
|
if (dragging.current) return;
|
|
2738
2754
|
dragging.current = true;
|
|
@@ -2864,17 +2880,17 @@ function ParameterSelect(props) {
|
|
|
2864
2880
|
}
|
|
2865
2881
|
function ParameterColor({ field, value, onChange, onGestureStart, onGestureEnd, disabled, id, components }) {
|
|
2866
2882
|
const CustomColor = resolveParameterComponents(components, useParameterComponents()).color;
|
|
2867
|
-
const [open, setOpen] = (0,
|
|
2868
|
-
const containerRef = (0,
|
|
2869
|
-
const buttonRef = (0,
|
|
2870
|
-
const popoverRef = (0,
|
|
2883
|
+
const [open, setOpen] = (0, import_react20.useState)(false);
|
|
2884
|
+
const containerRef = (0, import_react20.useRef)(null);
|
|
2885
|
+
const buttonRef = (0, import_react20.useRef)(null);
|
|
2886
|
+
const popoverRef = (0, import_react20.useRef)(null);
|
|
2871
2887
|
const alpha = !!field.alpha;
|
|
2872
2888
|
const hex = (0, import_parameters.normalizeHexColor)(value, true) ?? "#000000ff";
|
|
2873
2889
|
const rgb = hex.slice(0, 7);
|
|
2874
2890
|
const shown = alpha ? hex : rgb;
|
|
2875
2891
|
const off = disabled || field.readOnly;
|
|
2876
2892
|
const name = (0, import_parameters.parameterLabel)(field);
|
|
2877
|
-
(0,
|
|
2893
|
+
(0, import_react20.useEffect)(() => {
|
|
2878
2894
|
if (!open) return;
|
|
2879
2895
|
const onPointerDown = (e) => {
|
|
2880
2896
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
@@ -3121,10 +3137,10 @@ function EffectParameters({
|
|
|
3121
3137
|
className = "",
|
|
3122
3138
|
components
|
|
3123
3139
|
}) {
|
|
3124
|
-
const fields = (0,
|
|
3125
|
-
const idBase = (0,
|
|
3126
|
-
const gesture =
|
|
3127
|
-
const count =
|
|
3140
|
+
const fields = (0, import_react21.useMemo)(() => (0, import_effects3.effectParameterFields)(description, { fonts }), [description, fonts]);
|
|
3141
|
+
const idBase = (0, import_react21.useId)();
|
|
3142
|
+
const gesture = import_react21.default.useRef(null);
|
|
3143
|
+
const count = import_react21.default.useRef(0);
|
|
3128
3144
|
const CustomPresetSelect = resolveParameterComponents(components, useParameterComponents()).select;
|
|
3129
3145
|
const handlePresetSelect = (name) => {
|
|
3130
3146
|
if (!name) return;
|
|
@@ -3201,8 +3217,8 @@ function EffectParameters({
|
|
|
3201
3217
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
3202
3218
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3203
3219
|
function usePaintEffectsProvider(controller) {
|
|
3204
|
-
const [provider, setProvider] = (0,
|
|
3205
|
-
(0,
|
|
3220
|
+
const [provider, setProvider] = (0, import_react22.useState)(controller.effectsProvider);
|
|
3221
|
+
(0, import_react22.useEffect)(() => {
|
|
3206
3222
|
setProvider(controller.effectsProvider);
|
|
3207
3223
|
return controller.effects.subscribe(setProvider);
|
|
3208
3224
|
}, [controller]);
|
|
@@ -3210,14 +3226,14 @@ function usePaintEffectsProvider(controller) {
|
|
|
3210
3226
|
}
|
|
3211
3227
|
function usePaintEffectsTools(registry, controller, options = {}) {
|
|
3212
3228
|
const { id, namespace, readOnly, playbackSurface } = options;
|
|
3213
|
-
(0,
|
|
3229
|
+
(0, import_react22.useEffect)(() => {
|
|
3214
3230
|
if (!registry) return;
|
|
3215
3231
|
return registry.register((0, import_paint_editor13.createPaintEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
|
|
3216
3232
|
}, [registry, controller, id, namespace, readOnly, playbackSurface]);
|
|
3217
3233
|
}
|
|
3218
3234
|
function Controls({ provider, effect, name, values, apply }) {
|
|
3219
3235
|
const { description, error } = useEffectDescription(provider, effect);
|
|
3220
|
-
const drags = (0,
|
|
3236
|
+
const drags = (0, import_react22.useRef)(/* @__PURE__ */ new Set());
|
|
3221
3237
|
if (!provider) return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("p", { className: "text-[11px] text-slate-400", children: [
|
|
3222
3238
|
'No effects provider: "',
|
|
3223
3239
|
name ?? effect,
|
|
@@ -3252,14 +3268,14 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
3252
3268
|
const state = usePaintEditorState(controller);
|
|
3253
3269
|
const provider = usePaintEffectsProvider(controller);
|
|
3254
3270
|
const [error, attempt] = useAttempt();
|
|
3255
|
-
const [browse, setBrowse] = (0,
|
|
3256
|
-
const [busy, setBusy] = (0,
|
|
3271
|
+
const [browse, setBrowse] = (0, import_react22.useState)(null);
|
|
3272
|
+
const [busy, setBusy] = (0, import_react22.useState)(false);
|
|
3257
3273
|
const paper = controller.getPaperEffect();
|
|
3258
3274
|
const activeId = state.document.activeLayerId;
|
|
3259
3275
|
const layerEffect = activeId ? controller.getEffectLayer(activeId) : void 0;
|
|
3260
3276
|
const active = activeId ? controller.getLayer(activeId) : void 0;
|
|
3261
3277
|
const effectPaint = state.effectPaint;
|
|
3262
|
-
const thumbnail = (0,
|
|
3278
|
+
const thumbnail = (0, import_react22.useMemo)(() => effectPaint && !state.effectPaintRendering ? controller.effectPaintThumbnail(48) : null, [controller, effectPaint, state.effectPaintRendering]);
|
|
3263
3279
|
const run = (work) => attempt(() => {
|
|
3264
3280
|
setBusy(true);
|
|
3265
3281
|
return work().finally(() => setBusy(false));
|
|
@@ -3361,12 +3377,12 @@ var PAINT_CONTROLS = {
|
|
|
3361
3377
|
symmetry: '[aria-label="Symmetry"]'
|
|
3362
3378
|
};
|
|
3363
3379
|
var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
3364
|
-
const [tool, setTool] = (0,
|
|
3365
|
-
const [tab, setTab] = (0,
|
|
3366
|
-
const tabRef = (0,
|
|
3380
|
+
const [tool, setTool] = (0, import_react23.useState)("brush");
|
|
3381
|
+
const [tab, setTab] = (0, import_react23.useState)("color");
|
|
3382
|
+
const tabRef = (0, import_react23.useRef)(tab);
|
|
3367
3383
|
tabRef.current = tab;
|
|
3368
|
-
const rootRef = (0,
|
|
3369
|
-
const [ownPresence] = (0,
|
|
3384
|
+
const rootRef = (0, import_react23.useRef)(null);
|
|
3385
|
+
const [ownPresence] = (0, import_react23.useState)(() => new import_paint_editor14.PaintPresence());
|
|
3370
3386
|
const ambientPlayback = useAgentPlayback();
|
|
3371
3387
|
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
3372
3388
|
const viewBox = () => {
|
|
@@ -3422,7 +3438,7 @@ var PaintEditor = ({ controller, fileName, height = 720, presence, className, pl
|
|
|
3422
3438
|
const box = rootRef.current?.getBoundingClientRect();
|
|
3423
3439
|
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
3424
3440
|
};
|
|
3425
|
-
const [error, setError] = (0,
|
|
3441
|
+
const [error, setError] = (0, import_react23.useState)(null);
|
|
3426
3442
|
const effects = usePaintEffectsProvider(controller);
|
|
3427
3443
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
3428
3444
|
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("div", { ref: rootRef, className: `relative flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
|