@pixerate/editor-react 0.92.0 → 0.94.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/animation-editor/AnimationEditor.d.cts +14 -3
- package/dist/animation-editor/AnimationEditor.d.ts +14 -3
- package/dist/animation-editor/AnimationRecordPanel.d.cts +17 -0
- package/dist/animation-editor/AnimationRecordPanel.d.ts +17 -0
- package/dist/animation-editor/AnimationStage.d.cts +8 -2
- package/dist/animation-editor/AnimationStage.d.ts +8 -2
- package/dist/animation-editor/index.cjs +607 -405
- package/dist/animation-editor/index.d.cts +1 -0
- package/dist/animation-editor/index.d.ts +1 -0
- package/dist/animation-editor/index.js +359 -242
- package/dist/canvas/index.cjs +3 -2
- package/dist/canvas/index.js +4 -4
- package/dist/chart/ChartEditor.d.cts +12 -1
- package/dist/chart/ChartEditor.d.ts +12 -1
- package/dist/chart/index.cjs +187 -29
- package/dist/chart/index.js +74 -10
- package/dist/{chunk-6MDTFAPY.js → chunk-6YRSQW2V.js} +5 -5
- package/dist/chunk-7I73DW4V.js +43 -0
- package/dist/{chunk-GML6BYCN.js → chunk-GECXTPSH.js} +53 -3
- package/dist/{chunk-ECBC4HD7.js → chunk-IPVWWVSF.js} +3 -2
- package/dist/image-editor/index.cjs +3 -2
- package/dist/image-editor/index.js +2 -2
- package/dist/index.cjs +609 -527
- package/dist/index.js +10 -6
- package/dist/paint-editor/PaintEditor.d.cts +12 -1
- package/dist/paint-editor/PaintEditor.d.ts +12 -1
- package/dist/paint-editor/index.cjs +319 -164
- package/dist/paint-editor/index.js +84 -11
- package/dist/parameters/ParametersPanel.d.cts +11 -1
- package/dist/parameters/ParametersPanel.d.ts +11 -1
- package/dist/parameters/index.cjs +190 -41
- package/dist/parameters/index.js +23 -4
- package/dist/playback/index.d.cts +1 -0
- package/dist/playback/index.d.ts +1 -0
- package/dist/playback/useElementPlaybackSurface.d.cts +19 -0
- package/dist/playback/useElementPlaybackSurface.d.ts +19 -0
- package/dist/playback/usePlaybackSurface.d.cts +3 -1
- package/dist/playback/usePlaybackSurface.d.ts +3 -1
- package/dist/spreadsheet/SpreadsheetEditor.d.cts +10 -0
- package/dist/spreadsheet/SpreadsheetEditor.d.ts +10 -0
- package/dist/spreadsheet/index.cjs +443 -313
- package/dist/spreadsheet/index.js +2 -1
- package/dist/vector/index.cjs +3 -2
- package/dist/vector/index.js +5 -5
- package/dist/video-editor/VideoEditor.d.cts +6 -1
- package/dist/video-editor/VideoEditor.d.ts +6 -1
- package/dist/video-editor/VideoTimeline.d.cts +11 -1
- package/dist/video-editor/VideoTimeline.d.ts +11 -1
- package/dist/video-editor/index.cjs +463 -332
- package/dist/video-editor/index.js +53 -5
- package/package.json +3 -3
|
@@ -7,6 +7,11 @@ import {
|
|
|
7
7
|
useEffectDescription
|
|
8
8
|
} from "../chunk-5R67YSSD.js";
|
|
9
9
|
import "../chunk-OTGJEYHV.js";
|
|
10
|
+
import {
|
|
11
|
+
PresenceLayer,
|
|
12
|
+
useAgentPlayback,
|
|
13
|
+
usePlaybackSurface
|
|
14
|
+
} from "../chunk-IPVWWVSF.js";
|
|
10
15
|
|
|
11
16
|
// src/paint-editor/usePaintEditor.ts
|
|
12
17
|
import { useMemo, useState, useSyncExternalStore } from "react";
|
|
@@ -1215,7 +1220,8 @@ var StickerPanel = ({ controller, className }) => {
|
|
|
1215
1220
|
};
|
|
1216
1221
|
|
|
1217
1222
|
// src/paint-editor/PaintEditor.tsx
|
|
1218
|
-
import { useState as useState10 } from "react";
|
|
1223
|
+
import { useRef as useRef7, useState as useState10 } from "react";
|
|
1224
|
+
import { PaintPresence as PaintPresence2, documentToScreen as documentToScreen2, screenToDocument } from "@pixerate/editor/paint-editor";
|
|
1219
1225
|
|
|
1220
1226
|
// src/paint-editor/PaintEffectsPanel.tsx
|
|
1221
1227
|
import { useEffect as useEffect3, useRef as useRef6, useState as useState9 } from "react";
|
|
@@ -1359,28 +1365,95 @@ var PaintEffectsPanel = ({ controller, className }) => {
|
|
|
1359
1365
|
|
|
1360
1366
|
// src/paint-editor/PaintEditor.tsx
|
|
1361
1367
|
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1362
|
-
var
|
|
1368
|
+
var PAINT_CONTROLS = {
|
|
1369
|
+
"mixing-pad": '[data-testid="mixing-pad"]',
|
|
1370
|
+
lighting: '[data-testid="light-panel"]',
|
|
1371
|
+
symmetry: '[aria-label="Symmetry"]'
|
|
1372
|
+
};
|
|
1373
|
+
var PaintEditor = ({ controller, fileName, height = 720, presence, className, playback, playbackId = "paint", onPlaybackReveal }) => {
|
|
1363
1374
|
const [tool, setTool] = useState10("brush");
|
|
1364
1375
|
const [tab, setTab] = useState10("color");
|
|
1376
|
+
const tabRef = useRef7(tab);
|
|
1377
|
+
tabRef.current = tab;
|
|
1378
|
+
const rootRef = useRef7(null);
|
|
1379
|
+
const [ownPresence] = useState10(() => new PaintPresence2());
|
|
1380
|
+
const ambientPlayback = useAgentPlayback();
|
|
1381
|
+
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
1382
|
+
const viewBox = () => {
|
|
1383
|
+
const el = rootRef.current?.querySelector('[data-testid="paint-canvas"]');
|
|
1384
|
+
const r = el?.getBoundingClientRect();
|
|
1385
|
+
return r && r.width > 0 ? r : null;
|
|
1386
|
+
};
|
|
1387
|
+
const docToClient = (p) => {
|
|
1388
|
+
const r = viewBox();
|
|
1389
|
+
if (!r) return null;
|
|
1390
|
+
const q = documentToScreen2(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x, p.y);
|
|
1391
|
+
return { x: r.left + q.x, y: r.top + q.y };
|
|
1392
|
+
};
|
|
1393
|
+
const clientToDoc = (p) => {
|
|
1394
|
+
const r = viewBox();
|
|
1395
|
+
return r ? screenToDocument(controller.getState().view, controller.document.canvas, { width: r.width, height: r.height }, p.x - r.left, p.y - r.top) : null;
|
|
1396
|
+
};
|
|
1397
|
+
const elementRect = (selector) => {
|
|
1398
|
+
const r = rootRef.current?.querySelector(selector)?.getBoundingClientRect();
|
|
1399
|
+
if (!r || r.width <= 0) return null;
|
|
1400
|
+
const c = clientToDoc({ x: r.left + r.width / 2, y: r.top + r.height / 2 });
|
|
1401
|
+
const zoom = controller.getState().view.zoom || 1;
|
|
1402
|
+
return c ? { x: c.x - r.width / zoom / 2, y: c.y - r.height / zoom / 2, width: r.width / zoom, height: r.height / zoom } : null;
|
|
1403
|
+
};
|
|
1404
|
+
const agentPresence = usePlaybackSurface(
|
|
1405
|
+
playing,
|
|
1406
|
+
playbackId,
|
|
1407
|
+
{
|
|
1408
|
+
locate: (ref) => {
|
|
1409
|
+
if (ref.kind === "panel") return elementRect(`[data-paint-tab="${CSS.escape(ref.id)}"]`);
|
|
1410
|
+
if (ref.kind === "panel-body") return elementRect(`[data-paint-panel="${CSS.escape(ref.id)}"]`);
|
|
1411
|
+
if (ref.kind === "control" && PAINT_CONTROLS[ref.id]) return elementRect(PAINT_CONTROLS[ref.id]);
|
|
1412
|
+
return null;
|
|
1413
|
+
},
|
|
1414
|
+
open: async (ref) => {
|
|
1415
|
+
if (ref.kind !== "panel" || tabRef.current === ref.id) return;
|
|
1416
|
+
rootRef.current?.querySelector(`[data-paint-tab="${CSS.escape(ref.id)}"]`)?.click();
|
|
1417
|
+
await new Promise((resolve) => setTimeout(resolve, 60));
|
|
1418
|
+
},
|
|
1419
|
+
bounds: () => ({ x: 0, y: 0, width: controller.document.canvas.width, height: controller.document.canvas.height }),
|
|
1420
|
+
visible: () => {
|
|
1421
|
+
const r = rootRef.current?.getBoundingClientRect();
|
|
1422
|
+
return !!r && r.width > 0 && r.height > 0 && !(typeof document !== "undefined" && document.visibilityState === "hidden");
|
|
1423
|
+
},
|
|
1424
|
+
toViewport: (p) => docToClient(p) ?? p,
|
|
1425
|
+
fromViewport: (p) => clientToDoc(p) ?? p,
|
|
1426
|
+
reveal: () => onPlaybackReveal?.()
|
|
1427
|
+
},
|
|
1428
|
+
presence ?? ownPresence
|
|
1429
|
+
);
|
|
1430
|
+
const docToRoot = (p) => {
|
|
1431
|
+
const c = docToClient(p);
|
|
1432
|
+
const box = rootRef.current?.getBoundingClientRect();
|
|
1433
|
+
return c && box ? { x: c.x - box.left, y: c.y - box.top } : p;
|
|
1434
|
+
};
|
|
1365
1435
|
const [error, setError] = useState10(null);
|
|
1366
1436
|
const effects = usePaintEffectsProvider(controller);
|
|
1367
1437
|
const tabs = effects ? ["color", "wet", "paper", "layers", "effects"] : ["color", "wet", "paper", "layers"];
|
|
1368
|
-
return /* @__PURE__ */ jsxs11("div", { className: `flex flex-col gap-2 rounded-xl border border-slate-800 bg-slate-900 p-2 ${className ?? ""}`, style: { height }, "data-testid": "paint-editor", children: [
|
|
1438
|
+
return /* @__PURE__ */ jsxs11("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: [
|
|
1439
|
+
playing && /* @__PURE__ */ jsx12(PresenceLayer, { presence: agentPresence, viewport: docToRoot }),
|
|
1369
1440
|
/* @__PURE__ */ jsx12(PaintToolbar, { controller, tool, onToolChange: setTool, fileName }),
|
|
1370
1441
|
/* @__PURE__ */ jsxs11("div", { className: "flex min-h-0 flex-1 gap-2", children: [
|
|
1371
1442
|
/* @__PURE__ */ jsx12(BrushPanel, { controller, className: "w-60 shrink-0 overflow-y-auto pr-1" }),
|
|
1372
1443
|
/* @__PURE__ */ jsxs11("div", { className: "flex min-w-0 flex-1 flex-col", children: [
|
|
1373
|
-
/* @__PURE__ */ jsx12(PaintCanvas, { controller, tool, onError: setError, presence, className: "flex-1 rounded-lg" }),
|
|
1444
|
+
/* @__PURE__ */ jsx12(PaintCanvas, { controller, tool, onError: setError, presence: playing ? void 0 : presence, className: "flex-1 rounded-lg" }),
|
|
1374
1445
|
error && /* @__PURE__ */ jsx12("p", { role: "alert", className: "mt-1 text-[11px] text-rose-400", children: error })
|
|
1375
1446
|
] }),
|
|
1376
1447
|
/* @__PURE__ */ jsxs11("div", { className: "flex w-64 shrink-0 flex-col gap-2 overflow-y-auto pr-1", children: [
|
|
1377
|
-
/* @__PURE__ */ jsx12("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx12("button", { type: "button", role: "tab", "aria-selected": tab === t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1448
|
+
/* @__PURE__ */ jsx12("div", { className: "flex gap-1", role: "tablist", "aria-label": "Paint panels", children: tabs.map((t) => /* @__PURE__ */ jsx12("button", { type: "button", role: "tab", "aria-selected": tab === t, "data-paint-tab": t, className: chip(tab === t), onClick: () => setTab(t), children: t === "color" ? "Colour" : t === "wet" ? "Wet" : t === "paper" ? "Paper" : t === "layers" ? "Layers" : "Effects" }, t)) }),
|
|
1449
|
+
/* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-2", "data-paint-panel": tab, children: [
|
|
1450
|
+
tab === "color" && /* @__PURE__ */ jsx12(ColorPanel, { controller }),
|
|
1451
|
+
tab === "wet" && /* @__PURE__ */ jsx12(WetPanel, { controller }),
|
|
1452
|
+
tab === "paper" && /* @__PURE__ */ jsx12(PaperPanel, { controller }),
|
|
1453
|
+
tab === "layers" && /* @__PURE__ */ jsx12(PaintLayersPanel, { controller }),
|
|
1454
|
+
tab === "layers" && /* @__PURE__ */ jsx12(StickerPanel, { controller }),
|
|
1455
|
+
tab === "effects" && effects && /* @__PURE__ */ jsx12(PaintEffectsPanel, { controller })
|
|
1456
|
+
] })
|
|
1384
1457
|
] })
|
|
1385
1458
|
] })
|
|
1386
1459
|
] });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { AgentPlayback } from '@pixerate/editor/tools';
|
|
2
3
|
import { type ParametersController } from '@pixerate/editor/parameters';
|
|
3
4
|
import { type ParameterImageProps } from './fields.cjs';
|
|
4
5
|
export interface ParametersPanelProps {
|
|
@@ -18,10 +19,19 @@ export interface ParametersPanelProps {
|
|
|
18
19
|
/** Shown when the schema has no fields. */
|
|
19
20
|
emptyMessage?: React.ReactNode;
|
|
20
21
|
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Agent playback: act out `parameters.*` commands here with the agent's cursor (default: the
|
|
24
|
+
* nearest `AgentPlaybackProvider`; `null` turns it off).
|
|
25
|
+
*/
|
|
26
|
+
playback?: AgentPlayback | null;
|
|
27
|
+
/** The playback surface id (default `parameters`, where the parameter commands play). */
|
|
28
|
+
playbackId?: string;
|
|
29
|
+
/** Bring the panel on screen (switch to its tab) before the agent acts. */
|
|
30
|
+
onPlaybackReveal?: () => void | Promise<void>;
|
|
21
31
|
}
|
|
22
32
|
/**
|
|
23
33
|
* Renders a whole parameter schema: collapsible groups, one control per visible field,
|
|
24
34
|
* keyframe diamonds, per-field reset, presets, and undo / redo / reset / randomize. Slider
|
|
25
35
|
* drags and colour picks are one undo step each.
|
|
26
36
|
*/
|
|
27
|
-
export declare function ParametersPanel({ controller, title, showToolbar, showPresets, showKeyframes, showFieldReset, resolveFile, emptyMessage, className, }: ParametersPanelProps): React.JSX.Element;
|
|
37
|
+
export declare function ParametersPanel({ controller, title, showToolbar, showPresets, showKeyframes, showFieldReset, resolveFile, emptyMessage, className, playback, playbackId, onPlaybackReveal, }: ParametersPanelProps): React.JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { AgentPlayback } from '@pixerate/editor/tools';
|
|
2
3
|
import { type ParametersController } from '@pixerate/editor/parameters';
|
|
3
4
|
import { type ParameterImageProps } from './fields.js';
|
|
4
5
|
export interface ParametersPanelProps {
|
|
@@ -18,10 +19,19 @@ export interface ParametersPanelProps {
|
|
|
18
19
|
/** Shown when the schema has no fields. */
|
|
19
20
|
emptyMessage?: React.ReactNode;
|
|
20
21
|
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Agent playback: act out `parameters.*` commands here with the agent's cursor (default: the
|
|
24
|
+
* nearest `AgentPlaybackProvider`; `null` turns it off).
|
|
25
|
+
*/
|
|
26
|
+
playback?: AgentPlayback | null;
|
|
27
|
+
/** The playback surface id (default `parameters`, where the parameter commands play). */
|
|
28
|
+
playbackId?: string;
|
|
29
|
+
/** Bring the panel on screen (switch to its tab) before the agent acts. */
|
|
30
|
+
onPlaybackReveal?: () => void | Promise<void>;
|
|
21
31
|
}
|
|
22
32
|
/**
|
|
23
33
|
* Renders a whole parameter schema: collapsible groups, one control per visible field,
|
|
24
34
|
* keyframe diamonds, per-field reset, presets, and undo / redo / reset / randomize. Slider
|
|
25
35
|
* drags and colour picks are one undo step each.
|
|
26
36
|
*/
|
|
27
|
-
export declare function ParametersPanel({ controller, title, showToolbar, showPresets, showKeyframes, showFieldReset, resolveFile, emptyMessage, className, }: ParametersPanelProps): React.JSX.Element;
|
|
37
|
+
export declare function ParametersPanel({ controller, title, showToolbar, showPresets, showKeyframes, showFieldReset, resolveFile, emptyMessage, className, playback, playbackId, onPlaybackReveal, }: ParametersPanelProps): React.JSX.Element;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/parameters/index.ts
|
|
@@ -480,9 +490,136 @@ function ParameterFieldControl({ field, value, onChange, resolveFile, ...rest })
|
|
|
480
490
|
}
|
|
481
491
|
|
|
482
492
|
// src/parameters/ParametersPanel.tsx
|
|
493
|
+
var import_react7 = require("react");
|
|
494
|
+
|
|
495
|
+
// src/playback/AgentPlaybackContext.tsx
|
|
483
496
|
var import_react3 = require("react");
|
|
484
|
-
var import_parameters3 = require("@pixerate/editor/parameters");
|
|
485
497
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
498
|
+
var AgentPlaybackContext = (0, import_react3.createContext)(null);
|
|
499
|
+
function useAgentPlayback() {
|
|
500
|
+
return (0, import_react3.useContext)(AgentPlaybackContext);
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
// src/playback/useElementPlaybackSurface.ts
|
|
504
|
+
var import_react5 = require("react");
|
|
505
|
+
|
|
506
|
+
// src/playback/usePlaybackSurface.ts
|
|
507
|
+
var import_react4 = require("react");
|
|
508
|
+
var import_tools = require("@pixerate/editor/tools");
|
|
509
|
+
function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
|
|
510
|
+
const ambient = useAgentPlayback();
|
|
511
|
+
const target = playback === void 0 ? ambient : playback;
|
|
512
|
+
const [ownPresence] = (0, import_react4.useState)(() => new import_tools.PresenceStore());
|
|
513
|
+
const presence = sharedPresence ?? ownPresence;
|
|
514
|
+
const latest = (0, import_react4.useRef)(options);
|
|
515
|
+
latest.current = options;
|
|
516
|
+
(0, import_react4.useEffect)(() => {
|
|
517
|
+
if (!target || !id) return;
|
|
518
|
+
const o = () => latest.current;
|
|
519
|
+
const surface = {
|
|
520
|
+
presence,
|
|
521
|
+
locate: (ref) => o().locate?.(ref) ?? null,
|
|
522
|
+
bounds: () => o().bounds?.() ?? null,
|
|
523
|
+
visible: () => o().visible?.() ?? true,
|
|
524
|
+
toViewport: (p) => o().toViewport?.(p) ?? p,
|
|
525
|
+
fromViewport: (p) => o().fromViewport?.(p) ?? p,
|
|
526
|
+
beginGesture: (key) => o().beginGesture?.(key),
|
|
527
|
+
endGesture: () => o().endGesture?.(),
|
|
528
|
+
reveal: () => o().reveal?.(),
|
|
529
|
+
open: (ref) => o().open?.(ref),
|
|
530
|
+
get defaultKind() {
|
|
531
|
+
return o().defaultKind;
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
const detach = target.attach(id, surface);
|
|
535
|
+
return () => {
|
|
536
|
+
detach();
|
|
537
|
+
for (const a of presence.getState().actors) presence.remove(a.id);
|
|
538
|
+
};
|
|
539
|
+
}, [target, id, presence]);
|
|
540
|
+
return presence;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// src/playback/useElementPlaybackSurface.ts
|
|
544
|
+
function useElementPlaybackSurface(playback, id, element, options) {
|
|
545
|
+
const latest = (0, import_react5.useRef)(options);
|
|
546
|
+
latest.current = options;
|
|
547
|
+
const box = () => element.current?.getBoundingClientRect() ?? null;
|
|
548
|
+
return usePlaybackSurface(playback, id, {
|
|
549
|
+
get defaultKind() {
|
|
550
|
+
return latest.current.defaultKind;
|
|
551
|
+
},
|
|
552
|
+
locate: (ref) => {
|
|
553
|
+
const selector = latest.current.selectors[ref.kind]?.(ref.id);
|
|
554
|
+
const b = box();
|
|
555
|
+
const r = selector ? element.current?.querySelector(selector)?.getBoundingClientRect() : null;
|
|
556
|
+
return b && r && r.width > 0 ? { x: r.left - b.left, y: r.top - b.top, width: r.width, height: r.height } : null;
|
|
557
|
+
},
|
|
558
|
+
bounds: () => {
|
|
559
|
+
const r = box();
|
|
560
|
+
return r && r.width > 0 ? { x: 0, y: 0, width: r.width, height: r.height } : null;
|
|
561
|
+
},
|
|
562
|
+
visible: () => {
|
|
563
|
+
const r = box();
|
|
564
|
+
return !!r && r.width > 0 && r.height > 0 && !(typeof document !== "undefined" && document.visibilityState === "hidden");
|
|
565
|
+
},
|
|
566
|
+
toViewport: (p) => {
|
|
567
|
+
const r = box();
|
|
568
|
+
return { x: (r?.left ?? 0) + p.x, y: (r?.top ?? 0) + p.y };
|
|
569
|
+
},
|
|
570
|
+
fromViewport: (p) => {
|
|
571
|
+
const r = box();
|
|
572
|
+
return { x: p.x - (r?.left ?? 0), y: p.y - (r?.top ?? 0) };
|
|
573
|
+
},
|
|
574
|
+
reveal: () => latest.current.reveal?.()
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// src/playback/PresenceLayer.tsx
|
|
579
|
+
var import_react6 = __toESM(require("react"), 1);
|
|
580
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
581
|
+
function PresenceLayer({ presence, viewport, className = "" }) {
|
|
582
|
+
const { actors } = (0, import_react6.useSyncExternalStore)(presence.subscribe, presence.getState, presence.getState);
|
|
583
|
+
if (!actors.length) return null;
|
|
584
|
+
const map = typeof viewport === "function" ? viewport : viewport ? (p) => ({ x: p.x * viewport.zoom + viewport.x, y: p.y * viewport.zoom + viewport.y }) : (p) => p;
|
|
585
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
586
|
+
"div",
|
|
587
|
+
{
|
|
588
|
+
className: `pixerate-presence ${className}`.trim(),
|
|
589
|
+
"aria-hidden": "true",
|
|
590
|
+
"data-testid": "presence-layer",
|
|
591
|
+
style: { position: "absolute", inset: 0, pointerEvents: "none", overflow: "hidden", zIndex: 50 },
|
|
592
|
+
children: actors.map((a) => {
|
|
593
|
+
const at = map(a);
|
|
594
|
+
const ring = a.focus && (() => {
|
|
595
|
+
const tl = map(a.focus);
|
|
596
|
+
const br = map({ x: a.focus.x + a.focus.width, y: a.focus.y + a.focus.height });
|
|
597
|
+
return { left: tl.x - 4, top: tl.y - 4, width: br.x - tl.x + 8, height: br.y - tl.y + 8 };
|
|
598
|
+
})();
|
|
599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_react6.default.Fragment, { children: [
|
|
600
|
+
ring && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
601
|
+
"div",
|
|
602
|
+
{
|
|
603
|
+
"data-actor-focus": a.id,
|
|
604
|
+
style: { position: "absolute", ...ring, borderRadius: 8, border: `2px solid ${a.color}`, background: `${a.color}14`, transition: "all 160ms ease-out" }
|
|
605
|
+
}
|
|
606
|
+
),
|
|
607
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-actor": a.id, style: { position: "absolute", left: 0, top: 0, transform: `translate(${at.x}px, ${at.y}px)` }, children: [
|
|
608
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "18", height: "20", viewBox: "0 0 12 18", style: { display: "block", transform: a.pressed ? "scale(0.85)" : void 0, transformOrigin: "0 0", filter: "drop-shadow(0 1px 2px rgba(0,0,0,.35))" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M0,0 L0,14 L4,10.5 L7,17 L9.5,16 L6.5,9.5 L11.5,9.5 Z", style: { fill: a.color, stroke: "#ffffff", strokeWidth: 1 } }) }),
|
|
609
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { position: "absolute", left: 14, top: 16, display: "flex", flexDirection: "column", alignItems: "flex-start", gap: 4 }, children: [
|
|
610
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { whiteSpace: "nowrap", borderRadius: 999, padding: "1px 7px", fontSize: 11, fontWeight: 600, color: "#ffffff", background: a.color }, children: a.name }),
|
|
611
|
+
a.message && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "data-actor-message": a.id, style: { width: "max-content", maxWidth: 240, borderRadius: 8, borderTopLeftRadius: 0, padding: "4px 8px", fontSize: 12, color: "#1e293b", background: "#ffffff", boxShadow: "0 4px 12px rgba(15,23,42,.18)" }, children: a.message })
|
|
612
|
+
] })
|
|
613
|
+
] })
|
|
614
|
+
] }, a.id);
|
|
615
|
+
})
|
|
616
|
+
}
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// src/parameters/ParametersPanel.tsx
|
|
621
|
+
var import_parameters3 = require("@pixerate/editor/parameters");
|
|
622
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
486
623
|
function FieldRow({
|
|
487
624
|
controller,
|
|
488
625
|
state,
|
|
@@ -497,11 +634,11 @@ function FieldRow({
|
|
|
497
634
|
const value = state.values[field.id];
|
|
498
635
|
const error = state.errors[field.id];
|
|
499
636
|
const changed = !(0, import_parameters3.parameterValuesEqual)(value, state.defaults[field.id]);
|
|
500
|
-
return /* @__PURE__ */ (0,
|
|
501
|
-
/* @__PURE__ */ (0,
|
|
502
|
-
showKeyframes && /* @__PURE__ */ (0,
|
|
503
|
-
/* @__PURE__ */ (0,
|
|
504
|
-
showFieldReset && changed && !field.readOnly && /* @__PURE__ */ (0,
|
|
637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { "data-parameter-id": field.id, "data-parameter-type": field.type, className: "space-y-1", children: [
|
|
638
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex min-h-[1.25rem] items-center gap-1.5", children: [
|
|
639
|
+
showKeyframes && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(KeyframeDiamond, { state: state.keys[field.id] ?? "none", label, onToggle: () => controller.toggleKeyframe(field.id) }),
|
|
640
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: inputId, className: "min-w-0 flex-1 truncate text-xs font-medium text-foreground", title: field.description, children: label }),
|
|
641
|
+
showFieldReset && changed && !field.readOnly && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
505
642
|
"button",
|
|
506
643
|
{
|
|
507
644
|
type: "button",
|
|
@@ -513,8 +650,8 @@ function FieldRow({
|
|
|
513
650
|
}
|
|
514
651
|
)
|
|
515
652
|
] }),
|
|
516
|
-
field.description && /* @__PURE__ */ (0,
|
|
517
|
-
/* @__PURE__ */ (0,
|
|
653
|
+
field.description && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-[11px] leading-snug text-muted-foreground", children: field.description }),
|
|
654
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
518
655
|
ParameterFieldControl,
|
|
519
656
|
{
|
|
520
657
|
field,
|
|
@@ -526,13 +663,13 @@ function FieldRow({
|
|
|
526
663
|
onGestureEnd: () => controller.endGesture()
|
|
527
664
|
}
|
|
528
665
|
),
|
|
529
|
-
error && /* @__PURE__ */ (0,
|
|
666
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: error })
|
|
530
667
|
] });
|
|
531
668
|
}
|
|
532
669
|
function PresetBar({ controller, state }) {
|
|
533
|
-
const [saving, setSaving] = (0,
|
|
534
|
-
const [name, setName] = (0,
|
|
535
|
-
const [message, setMessage] = (0,
|
|
670
|
+
const [saving, setSaving] = (0, import_react7.useState)(false);
|
|
671
|
+
const [name, setName] = (0, import_react7.useState)("");
|
|
672
|
+
const [message, setMessage] = (0, import_react7.useState)(null);
|
|
536
673
|
const active = state.presets.find((p) => p.name === state.activePreset);
|
|
537
674
|
const save = (e) => {
|
|
538
675
|
e.preventDefault();
|
|
@@ -543,9 +680,9 @@ function PresetBar({ controller, state }) {
|
|
|
543
680
|
setMessage(null);
|
|
544
681
|
} else setMessage(result.message);
|
|
545
682
|
};
|
|
546
|
-
return /* @__PURE__ */ (0,
|
|
547
|
-
/* @__PURE__ */ (0,
|
|
548
|
-
/* @__PURE__ */ (0,
|
|
683
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "space-y-1.5", "data-parameter-presets": "", children: [
|
|
684
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-1.5", children: [
|
|
685
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
549
686
|
"select",
|
|
550
687
|
{
|
|
551
688
|
"aria-label": "Preset",
|
|
@@ -553,16 +690,16 @@ function PresetBar({ controller, state }) {
|
|
|
553
690
|
value: state.activePreset ?? "",
|
|
554
691
|
onChange: (e) => e.target.value && controller.applyPreset(e.target.value),
|
|
555
692
|
children: [
|
|
556
|
-
/* @__PURE__ */ (0,
|
|
557
|
-
state.presets.map((p) => /* @__PURE__ */ (0,
|
|
693
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "", children: state.presets.length ? "Presets\u2026" : "No presets" }),
|
|
694
|
+
state.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: p.name, title: p.description, children: p.name }, p.name))
|
|
558
695
|
]
|
|
559
696
|
}
|
|
560
697
|
),
|
|
561
|
-
/* @__PURE__ */ (0,
|
|
562
|
-
active && !active.builtIn && /* @__PURE__ */ (0,
|
|
698
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: parameterButtonClass, onClick: () => setSaving((s) => !s), "aria-expanded": saving, children: "Save\u2026" }),
|
|
699
|
+
active && !active.builtIn && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: parameterButtonClass, "aria-label": `Delete preset ${active.name}`, onClick: () => controller.deletePreset(active.name), children: "Delete" })
|
|
563
700
|
] }),
|
|
564
|
-
saving && /* @__PURE__ */ (0,
|
|
565
|
-
/* @__PURE__ */ (0,
|
|
701
|
+
saving && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("form", { className: "flex items-center gap-1.5", onSubmit: save, children: [
|
|
702
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
566
703
|
"input",
|
|
567
704
|
{
|
|
568
705
|
autoFocus: true,
|
|
@@ -573,9 +710,9 @@ function PresetBar({ controller, state }) {
|
|
|
573
710
|
onChange: (e) => setName(e.target.value)
|
|
574
711
|
}
|
|
575
712
|
),
|
|
576
|
-
/* @__PURE__ */ (0,
|
|
713
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "submit", className: parameterButtonClass, children: "Save" })
|
|
577
714
|
] }),
|
|
578
|
-
message && /* @__PURE__ */ (0,
|
|
715
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { role: "alert", className: "text-[11px] text-destructive", children: message })
|
|
579
716
|
] });
|
|
580
717
|
}
|
|
581
718
|
function ParametersPanel({
|
|
@@ -587,16 +724,27 @@ function ParametersPanel({
|
|
|
587
724
|
showFieldReset = true,
|
|
588
725
|
resolveFile,
|
|
589
726
|
emptyMessage = "No parameters.",
|
|
590
|
-
className = ""
|
|
727
|
+
className = "",
|
|
728
|
+
playback,
|
|
729
|
+
playbackId = "parameters",
|
|
730
|
+
onPlaybackReveal
|
|
591
731
|
}) {
|
|
592
732
|
const state = useParametersState(controller);
|
|
593
|
-
const
|
|
733
|
+
const rootRef = (0, import_react7.useRef)(null);
|
|
734
|
+
const ambientPlayback = useAgentPlayback();
|
|
735
|
+
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
736
|
+
const agentPresence = useElementPlaybackSurface(playing, playbackId, rootRef, {
|
|
737
|
+
defaultKind: "parameter",
|
|
738
|
+
selectors: { parameter: (id) => `[data-parameter-id="${CSS.escape(id)}"]` },
|
|
739
|
+
reveal: onPlaybackReveal
|
|
740
|
+
});
|
|
741
|
+
const idBase = (0, import_react7.useId)();
|
|
594
742
|
const keys = showKeyframes ?? state.keyframesEnabled;
|
|
595
743
|
const heading = title === void 0 ? state.schema.title : title;
|
|
596
744
|
const renderItems = (items) => items.map((item) => {
|
|
597
745
|
if (state.visible[item.id] === false) return null;
|
|
598
746
|
if ((0, import_parameters3.isParameterGroup)(item)) return renderGroup(item);
|
|
599
|
-
return /* @__PURE__ */ (0,
|
|
747
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
600
748
|
FieldRow,
|
|
601
749
|
{
|
|
602
750
|
controller,
|
|
@@ -613,8 +761,8 @@ function ParametersPanel({
|
|
|
613
761
|
const renderGroup = (group) => {
|
|
614
762
|
const collapsed = !!state.collapsed[group.id];
|
|
615
763
|
const bodyId = `${idBase}-group-${group.id}`;
|
|
616
|
-
return /* @__PURE__ */ (0,
|
|
617
|
-
/* @__PURE__ */ (0,
|
|
764
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { "data-parameter-group": group.id, className: "rounded-md border border-border", children: [
|
|
765
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
618
766
|
"button",
|
|
619
767
|
{
|
|
620
768
|
type: "button",
|
|
@@ -623,22 +771,22 @@ function ParametersPanel({
|
|
|
623
771
|
onClick: () => controller.toggleCollapsed(group.id),
|
|
624
772
|
className: "flex w-full items-center gap-1.5 px-2 py-1.5 text-left text-xs font-semibold text-foreground hover:bg-muted",
|
|
625
773
|
children: [
|
|
626
|
-
/* @__PURE__ */ (0,
|
|
774
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { "aria-hidden": "true", className: `inline-block text-[10px] text-muted-foreground transition-transform ${collapsed ? "" : "rotate-90"}`, children: "\u25B6" }),
|
|
627
775
|
(0, import_parameters3.parameterLabel)(group)
|
|
628
776
|
]
|
|
629
777
|
}
|
|
630
778
|
),
|
|
631
|
-
!collapsed && /* @__PURE__ */ (0,
|
|
632
|
-
group.description && /* @__PURE__ */ (0,
|
|
779
|
+
!collapsed && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { id: bodyId, className: "space-y-3 border-t border-border px-2 py-2", children: [
|
|
780
|
+
group.description && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-[11px] text-muted-foreground", children: group.description }),
|
|
633
781
|
renderItems(group.fields)
|
|
634
782
|
] })
|
|
635
783
|
] }, group.id);
|
|
636
784
|
};
|
|
637
|
-
return /* @__PURE__ */ (0,
|
|
638
|
-
(heading || showToolbar) && /* @__PURE__ */ (0,
|
|
639
|
-
heading && /* @__PURE__ */ (0,
|
|
640
|
-
showToolbar && /* @__PURE__ */ (0,
|
|
641
|
-
/* @__PURE__ */ (0,
|
|
785
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ref: rootRef, className: `relative space-y-3 text-foreground ${className}`, "data-parameters-panel": "", children: [
|
|
786
|
+
(heading || showToolbar) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
787
|
+
heading && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", { className: "mr-auto text-sm font-semibold", children: heading }),
|
|
788
|
+
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Parameter actions", children: [
|
|
789
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
642
790
|
"button",
|
|
643
791
|
{
|
|
644
792
|
type: "button",
|
|
@@ -649,7 +797,7 @@ function ParametersPanel({
|
|
|
649
797
|
children: "Undo"
|
|
650
798
|
}
|
|
651
799
|
),
|
|
652
|
-
/* @__PURE__ */ (0,
|
|
800
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
653
801
|
"button",
|
|
654
802
|
{
|
|
655
803
|
type: "button",
|
|
@@ -660,12 +808,13 @@ function ParametersPanel({
|
|
|
660
808
|
children: "Redo"
|
|
661
809
|
}
|
|
662
810
|
),
|
|
663
|
-
/* @__PURE__ */ (0,
|
|
664
|
-
/* @__PURE__ */ (0,
|
|
811
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: parameterButtonClass, disabled: !state.modified, onClick: () => controller.reset(), children: "Reset" }),
|
|
812
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: parameterButtonClass, onClick: () => controller.randomize(), children: "Randomize" })
|
|
665
813
|
] })
|
|
666
814
|
] }),
|
|
667
|
-
showPresets && /* @__PURE__ */ (0,
|
|
668
|
-
state.fields.length === 0 ? /* @__PURE__ */ (0,
|
|
815
|
+
showPresets && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PresetBar, { controller, state }),
|
|
816
|
+
state.fields.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "text-xs text-muted-foreground", children: emptyMessage }) : renderItems(state.schema.fields),
|
|
817
|
+
playing && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PresenceLayer, { presence: agentPresence })
|
|
669
818
|
] });
|
|
670
819
|
}
|
|
671
820
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/parameters/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useElementPlaybackSurface
|
|
3
|
+
} from "../chunk-7I73DW4V.js";
|
|
1
4
|
import {
|
|
2
5
|
KeyframeDiamond,
|
|
3
6
|
ParameterColor,
|
|
@@ -13,6 +16,10 @@ import {
|
|
|
13
16
|
parameterButtonClass,
|
|
14
17
|
parameterInputClass
|
|
15
18
|
} from "../chunk-OTGJEYHV.js";
|
|
19
|
+
import {
|
|
20
|
+
PresenceLayer,
|
|
21
|
+
useAgentPlayback
|
|
22
|
+
} from "../chunk-IPVWWVSF.js";
|
|
16
23
|
|
|
17
24
|
// src/parameters/useParameters.ts
|
|
18
25
|
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
@@ -68,7 +75,7 @@ function useParameterCommands(registry, controller, options = {}) {
|
|
|
68
75
|
}
|
|
69
76
|
|
|
70
77
|
// src/parameters/ParametersPanel.tsx
|
|
71
|
-
import { useId, useState } from "react";
|
|
78
|
+
import { useId, useRef as useRef2, useState } from "react";
|
|
72
79
|
import {
|
|
73
80
|
isParameterGroup,
|
|
74
81
|
parameterLabel,
|
|
@@ -179,9 +186,20 @@ function ParametersPanel({
|
|
|
179
186
|
showFieldReset = true,
|
|
180
187
|
resolveFile,
|
|
181
188
|
emptyMessage = "No parameters.",
|
|
182
|
-
className = ""
|
|
189
|
+
className = "",
|
|
190
|
+
playback,
|
|
191
|
+
playbackId = "parameters",
|
|
192
|
+
onPlaybackReveal
|
|
183
193
|
}) {
|
|
184
194
|
const state = useParametersState(controller);
|
|
195
|
+
const rootRef = useRef2(null);
|
|
196
|
+
const ambientPlayback = useAgentPlayback();
|
|
197
|
+
const playing = (playback === void 0 ? ambientPlayback : playback) ?? null;
|
|
198
|
+
const agentPresence = useElementPlaybackSurface(playing, playbackId, rootRef, {
|
|
199
|
+
defaultKind: "parameter",
|
|
200
|
+
selectors: { parameter: (id) => `[data-parameter-id="${CSS.escape(id)}"]` },
|
|
201
|
+
reveal: onPlaybackReveal
|
|
202
|
+
});
|
|
185
203
|
const idBase = useId();
|
|
186
204
|
const keys = showKeyframes ?? state.keyframesEnabled;
|
|
187
205
|
const heading = title === void 0 ? state.schema.title : title;
|
|
@@ -226,7 +244,7 @@ function ParametersPanel({
|
|
|
226
244
|
] })
|
|
227
245
|
] }, group.id);
|
|
228
246
|
};
|
|
229
|
-
return /* @__PURE__ */ jsxs("div", { className: `space-y-3 text-foreground ${className}`, "data-parameters-panel": "", children: [
|
|
247
|
+
return /* @__PURE__ */ jsxs("div", { ref: rootRef, className: `relative space-y-3 text-foreground ${className}`, "data-parameters-panel": "", children: [
|
|
230
248
|
(heading || showToolbar) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
231
249
|
heading && /* @__PURE__ */ jsx("h3", { className: "mr-auto text-sm font-semibold", children: heading }),
|
|
232
250
|
showToolbar && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", role: "toolbar", "aria-label": "Parameter actions", children: [
|
|
@@ -257,7 +275,8 @@ function ParametersPanel({
|
|
|
257
275
|
] })
|
|
258
276
|
] }),
|
|
259
277
|
showPresets && /* @__PURE__ */ jsx(PresetBar, { controller, state }),
|
|
260
|
-
state.fields.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: emptyMessage }) : renderItems(state.schema.fields)
|
|
278
|
+
state.fields.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: emptyMessage }) : renderItems(state.schema.fields),
|
|
279
|
+
playing && /* @__PURE__ */ jsx(PresenceLayer, { presence: agentPresence })
|
|
261
280
|
] });
|
|
262
281
|
}
|
|
263
282
|
export {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { PresenceLayer, type PresenceLayerProps } from "./PresenceLayer.cjs";
|
|
2
2
|
export { AgentPlaybackProvider, useAgentPlayback } from "./AgentPlaybackContext.cjs";
|
|
3
3
|
export { usePlaybackSurface, type PlaybackSurfaceOptions } from "./usePlaybackSurface.cjs";
|
|
4
|
+
export { useElementPlaybackSurface, type ElementPlaybackSurfaceOptions } from "./useElementPlaybackSurface.cjs";
|
package/dist/playback/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { PresenceLayer, type PresenceLayerProps } from "./PresenceLayer.js";
|
|
2
2
|
export { AgentPlaybackProvider, useAgentPlayback } from "./AgentPlaybackContext.js";
|
|
3
3
|
export { usePlaybackSurface, type PlaybackSurfaceOptions } from "./usePlaybackSurface.js";
|
|
4
|
+
export { useElementPlaybackSurface, type ElementPlaybackSurfaceOptions } from "./useElementPlaybackSurface.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
import type { AgentPlayback, PresenceStore } from "@pixerate/editor/tools";
|
|
3
|
+
export interface ElementPlaybackSurfaceOptions {
|
|
4
|
+
/** The kind of a bare `id` / `ids` argument (e.g. `parameter`). */
|
|
5
|
+
defaultKind?: string;
|
|
6
|
+
/**
|
|
7
|
+
* A CSS selector for each ref kind the surface can find inside the element, e.g.
|
|
8
|
+
* `{ parameter: (id) => \`[data-parameter-id="${CSS.escape(id)}"]\` }`.
|
|
9
|
+
*/
|
|
10
|
+
selectors: Record<string, (id: string) => string>;
|
|
11
|
+
/** Bring the element on screen (switch to its tab) before the agent acts. */
|
|
12
|
+
reveal?: () => void | Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A playback surface for a plain DOM component: coordinates are pixels of `element`'s box, and
|
|
16
|
+
* refs are found by the CSS selectors given per kind. Draw the cursors with `<PresenceLayer>`
|
|
17
|
+
* inside the element (make it `position: relative`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function useElementPlaybackSurface(playback: AgentPlayback | null | undefined, id: string | null | undefined, element: RefObject<HTMLElement | null>, options: ElementPlaybackSurfaceOptions): PresenceStore;
|