@pixerate/editor-react 0.98.0 → 0.99.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 (40) hide show
  1. package/dist/animation-editor/index.cjs +11 -7
  2. package/dist/animation-editor/index.js +7 -7
  3. package/dist/canvas/index.cjs +20 -11
  4. package/dist/canvas/index.js +14 -9
  5. package/dist/canvas/useCanvasPlaybackSurface.d.cts +8 -2
  6. package/dist/canvas/useCanvasPlaybackSurface.d.ts +8 -2
  7. package/dist/chart/index.cjs +8 -4
  8. package/dist/chart/index.js +2 -2
  9. package/dist/{chunk-TFEKLNC7.js → chunk-EFF4YWJK.js} +390 -358
  10. package/dist/{chunk-S6C2W5JW.js → chunk-EP6MSQN4.js} +1 -1
  11. package/dist/{chunk-AILJ4JOW.js → chunk-GDPWLGPD.js} +3 -3
  12. package/dist/{chunk-SI2V7XPZ.js → chunk-GNO54NFG.js} +5 -1
  13. package/dist/{chunk-NEQI2ZIU.js → chunk-V2YC5T4R.js} +14 -8
  14. package/dist/image-editor/AdjustmentLayersPanel.d.cts +2 -0
  15. package/dist/image-editor/AdjustmentLayersPanel.d.ts +2 -0
  16. package/dist/image-editor/ControlSlider.d.cts +2 -0
  17. package/dist/image-editor/ControlSlider.d.ts +2 -0
  18. package/dist/image-editor/CurvesEditor.d.cts +2 -0
  19. package/dist/image-editor/CurvesEditor.d.ts +2 -0
  20. package/dist/image-editor/ImageEffectControls.d.cts +3 -1
  21. package/dist/image-editor/ImageEffectControls.d.ts +3 -1
  22. package/dist/image-editor/index.cjs +397 -361
  23. package/dist/image-editor/index.js +2 -2
  24. package/dist/image-editor/styles.d.cts +51 -0
  25. package/dist/image-editor/styles.d.ts +51 -0
  26. package/dist/index.cjs +437 -395
  27. package/dist/index.js +5 -5
  28. package/dist/paint-editor/index.cjs +8 -4
  29. package/dist/paint-editor/index.js +4 -4
  30. package/dist/parameters/index.cjs +18 -8
  31. package/dist/parameters/index.js +2 -2
  32. package/dist/playback/useElementPlaybackSurface.d.cts +5 -4
  33. package/dist/playback/useElementPlaybackSurface.d.ts +5 -4
  34. package/dist/spreadsheet/index.cjs +5 -1
  35. package/dist/spreadsheet/index.js +2 -2
  36. package/dist/vector/index.cjs +5 -1
  37. package/dist/vector/index.js +1 -1
  38. package/dist/video-editor/index.cjs +11 -7
  39. package/dist/video-editor/index.js +7 -7
  40. package/package.json +3 -3
@@ -88,18 +88,18 @@ function useAnimationEditor(controllerOrOptions = {}) {
88
88
  return { controller, state, ...actions };
89
89
  }
90
90
  function useAnimationEditorTools(registry, controller, options = {}) {
91
- const { id, namespace, readOnly, rasterize } = options;
91
+ const { id, namespace, readOnly, rasterize, playbackSurface } = options;
92
92
  (0, import_react.useEffect)(() => {
93
93
  if (!registry) return;
94
- return registry.register((0, import_animation_editor.createAnimationEditorToolProvider)(controller, { id, namespace, readOnly, rasterize }));
95
- }, [registry, controller, id, namespace, readOnly, rasterize]);
94
+ return registry.register((0, import_animation_editor.createAnimationEditorToolProvider)(controller, { id, namespace, readOnly, rasterize, playbackSurface }));
95
+ }, [registry, controller, id, namespace, readOnly, rasterize, playbackSurface]);
96
96
  }
97
97
  function useAnimationEffectsTools(registry, controller, options = {}) {
98
- const { id, namespace, readOnly } = options;
98
+ const { id, namespace, readOnly, playbackSurface } = options;
99
99
  (0, import_react.useEffect)(() => {
100
100
  if (!registry) return;
101
- return registry.register((0, import_animation_editor.createAnimationEffectsToolProvider)(controller, { id, namespace, readOnly }));
102
- }, [registry, controller, id, namespace, readOnly]);
101
+ return registry.register((0, import_animation_editor.createAnimationEffectsToolProvider)(controller, { id, namespace, readOnly, playbackSurface }));
102
+ }, [registry, controller, id, namespace, readOnly, playbackSurface]);
103
103
  }
104
104
 
105
105
  // src/animation-editor/AnimationStage.tsx
@@ -253,7 +253,11 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
253
253
  beginGesture: (key) => o().beginGesture?.(key),
254
254
  endGesture: () => o().endGesture?.(),
255
255
  reveal: () => o().reveal?.(),
256
- open: (ref) => o().open?.(ref),
256
+ // Only a surface whose options can open things has `open`, so playback skips `open` steps
257
+ // (and their wait) everywhere else. Read per step, like the other options.
258
+ get open() {
259
+ return o().open ? (ref) => o().open?.(ref) : void 0;
260
+ },
257
261
  get defaultKind() {
258
262
  return o().defaultKind;
259
263
  }
@@ -11,7 +11,7 @@ import {
11
11
  PresenceLayer,
12
12
  useAgentPlayback,
13
13
  usePlaybackSurface
14
- } from "../chunk-SI2V7XPZ.js";
14
+ } from "../chunk-GNO54NFG.js";
15
15
 
16
16
  // src/animation-editor/useAnimationEditor.ts
17
17
  import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
@@ -55,18 +55,18 @@ function useAnimationEditor(controllerOrOptions = {}) {
55
55
  return { controller, state, ...actions };
56
56
  }
57
57
  function useAnimationEditorTools(registry, controller, options = {}) {
58
- const { id, namespace, readOnly, rasterize } = options;
58
+ const { id, namespace, readOnly, rasterize, playbackSurface } = options;
59
59
  useEffect(() => {
60
60
  if (!registry) return;
61
- return registry.register(createAnimationEditorToolProvider(controller, { id, namespace, readOnly, rasterize }));
62
- }, [registry, controller, id, namespace, readOnly, rasterize]);
61
+ return registry.register(createAnimationEditorToolProvider(controller, { id, namespace, readOnly, rasterize, playbackSurface }));
62
+ }, [registry, controller, id, namespace, readOnly, rasterize, playbackSurface]);
63
63
  }
64
64
  function useAnimationEffectsTools(registry, controller, options = {}) {
65
- const { id, namespace, readOnly } = options;
65
+ const { id, namespace, readOnly, playbackSurface } = options;
66
66
  useEffect(() => {
67
67
  if (!registry) return;
68
- return registry.register(createAnimationEffectsToolProvider(controller, { id, namespace, readOnly }));
69
- }, [registry, controller, id, namespace, readOnly]);
68
+ return registry.register(createAnimationEffectsToolProvider(controller, { id, namespace, readOnly, playbackSurface }));
69
+ }, [registry, controller, id, namespace, readOnly, playbackSurface]);
70
70
  }
71
71
 
72
72
  // src/animation-editor/AnimationStage.tsx
@@ -511,6 +511,7 @@ function PresenceLayer({ presence, viewport, clip = true, className = "" }) {
511
511
  // src/canvas/useCanvasPlaybackSurface.ts
512
512
  var import_react4 = require("react");
513
513
  var import_canvas = require("@pixerate/editor/canvas");
514
+ var import_tools2 = require("@pixerate/editor/tools");
514
515
 
515
516
  // src/playback/usePlaybackSurface.ts
516
517
  var import_react3 = require("react");
@@ -545,7 +546,11 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
545
546
  beginGesture: (key) => o().beginGesture?.(key),
546
547
  endGesture: () => o().endGesture?.(),
547
548
  reveal: () => o().reveal?.(),
548
- open: (ref) => o().open?.(ref),
549
+ // Only a surface whose options can open things has `open`, so playback skips `open` steps
550
+ // (and their wait) everywhere else. Read per step, like the other options.
551
+ get open() {
552
+ return o().open ? (ref) => o().open?.(ref) : void 0;
553
+ },
549
554
  get defaultKind() {
550
555
  return o().defaultKind;
551
556
  }
@@ -563,7 +568,7 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
563
568
  function useCanvasPlaybackSurface(playback, id, options) {
564
569
  const latest = (0, import_react4.useRef)(options);
565
570
  latest.current = options;
566
- const locate = (0, import_react4.useMemo)(
571
+ const locateFlow = (0, import_react4.useMemo)(
567
572
  () => (0, import_canvas.createCanvasPlaybackLocator)({
568
573
  getNodes: () => latest.current.getNodes(),
569
574
  getEdges: () => latest.current.getEdges?.() ?? [],
@@ -574,9 +579,14 @@ function useCanvasPlaybackSurface(playback, id, options) {
574
579
  []
575
580
  );
576
581
  const box = () => latest.current.container.current?.getBoundingClientRect() ?? null;
582
+ const fromViewport = (p) => {
583
+ const r = box();
584
+ const { x, y, zoom } = latest.current.viewport;
585
+ return { x: (p.x - (r?.left ?? 0) - x) / zoom, y: (p.y - (r?.top ?? 0) - y) / zoom };
586
+ };
577
587
  return usePlaybackSurface(playback, id, {
578
588
  defaultKind: "node",
579
- locate,
589
+ locate: (ref) => locateFlow(ref) ?? (0, import_tools2.locatePlaybackChrome)(ref, latest.current, fromViewport),
580
590
  bounds: () => {
581
591
  const r = box();
582
592
  const { x, y, zoom } = latest.current.viewport;
@@ -593,12 +603,11 @@ function useCanvasPlaybackSurface(playback, id, options) {
593
603
  const { x, y, zoom } = latest.current.viewport;
594
604
  return { x: (r?.left ?? 0) + p.x * zoom + x, y: (r?.top ?? 0) + p.y * zoom + y };
595
605
  },
596
- fromViewport: (p) => {
597
- const r = box();
598
- const { x, y, zoom } = latest.current.viewport;
599
- return { x: (p.x - (r?.left ?? 0) - x) / zoom, y: (p.y - (r?.top ?? 0) - y) / zoom };
600
- },
601
- reveal: () => latest.current.reveal?.()
606
+ fromViewport,
607
+ reveal: () => latest.current.reveal?.(),
608
+ get open() {
609
+ return latest.current.open ? (ref) => latest.current.open?.(ref) : void 0;
610
+ }
602
611
  });
603
612
  }
604
613
 
@@ -1415,7 +1424,7 @@ function useCanvasScenes(options = {}) {
1415
1424
  // src/canvas/useCanvasCapture.ts
1416
1425
  var import_react14 = require("react");
1417
1426
  var import_canvas9 = require("@pixerate/editor/canvas");
1418
- var import_tools2 = require("@pixerate/editor/tools");
1427
+ var import_tools3 = require("@pixerate/editor/tools");
1419
1428
  function useCanvasCapture(options) {
1420
1429
  const optionsRef = (0, import_react14.useRef)(options);
1421
1430
  optionsRef.current = options;
@@ -1432,7 +1441,7 @@ function useCanvasCapture(options) {
1432
1441
  getViewport: () => latest().getViewport(),
1433
1442
  getNodes: () => latest().getNodes(),
1434
1443
  getNodeRect: (node, nodes) => (latest().getNodeRect ?? import_canvas9.canvasNodeCaptureRect)(node, nodes),
1435
- rasterize: (element, raster) => (latest().rasterize ?? import_tools2.rasterizeElement)(element, raster)
1444
+ rasterize: (element, raster) => (latest().rasterize ?? import_tools3.rasterizeElement)(element, raster)
1436
1445
  });
1437
1446
  }, [options.id, options.namespace]);
1438
1447
  }
@@ -9,7 +9,7 @@ import "../chunk-3I7FOSLF.js";
9
9
  import {
10
10
  PresenceLayer,
11
11
  usePlaybackSurface
12
- } from "../chunk-SI2V7XPZ.js";
12
+ } from "../chunk-GNO54NFG.js";
13
13
 
14
14
  // src/canvas/AgentPresenceLayer.tsx
15
15
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -78,10 +78,11 @@ function AgentPresenceLayer({ presences, className = "" }) {
78
78
  // src/canvas/useCanvasPlaybackSurface.ts
79
79
  import { useMemo, useRef } from "react";
80
80
  import { createCanvasPlaybackLocator } from "@pixerate/editor/canvas";
81
+ import { locatePlaybackChrome } from "@pixerate/editor/tools";
81
82
  function useCanvasPlaybackSurface(playback, id, options) {
82
83
  const latest = useRef(options);
83
84
  latest.current = options;
84
- const locate = useMemo(
85
+ const locateFlow = useMemo(
85
86
  () => createCanvasPlaybackLocator({
86
87
  getNodes: () => latest.current.getNodes(),
87
88
  getEdges: () => latest.current.getEdges?.() ?? [],
@@ -92,9 +93,14 @@ function useCanvasPlaybackSurface(playback, id, options) {
92
93
  []
93
94
  );
94
95
  const box = () => latest.current.container.current?.getBoundingClientRect() ?? null;
96
+ const fromViewport = (p) => {
97
+ const r = box();
98
+ const { x, y, zoom } = latest.current.viewport;
99
+ return { x: (p.x - (r?.left ?? 0) - x) / zoom, y: (p.y - (r?.top ?? 0) - y) / zoom };
100
+ };
95
101
  return usePlaybackSurface(playback, id, {
96
102
  defaultKind: "node",
97
- locate,
103
+ locate: (ref) => locateFlow(ref) ?? locatePlaybackChrome(ref, latest.current, fromViewport),
98
104
  bounds: () => {
99
105
  const r = box();
100
106
  const { x, y, zoom } = latest.current.viewport;
@@ -111,12 +117,11 @@ function useCanvasPlaybackSurface(playback, id, options) {
111
117
  const { x, y, zoom } = latest.current.viewport;
112
118
  return { x: (r?.left ?? 0) + p.x * zoom + x, y: (r?.top ?? 0) + p.y * zoom + y };
113
119
  },
114
- fromViewport: (p) => {
115
- const r = box();
116
- const { x, y, zoom } = latest.current.viewport;
117
- return { x: (p.x - (r?.left ?? 0) - x) / zoom, y: (p.y - (r?.top ?? 0) - y) / zoom };
118
- },
119
- reveal: () => latest.current.reveal?.()
120
+ fromViewport,
121
+ reveal: () => latest.current.reveal?.(),
122
+ get open() {
123
+ return latest.current.open ? (ref) => latest.current.open?.(ref) : void 0;
124
+ }
120
125
  });
121
126
  }
122
127
 
@@ -1,7 +1,13 @@
1
1
  import { type RefObject } from 'react';
2
2
  import { type CanvasEdge, type CanvasNode, type NodeRectOptions } from '@pixerate/editor/canvas';
3
- import type { AgentPlayback, PresenceStore } from '@pixerate/editor/tools';
4
- export interface UseCanvasPlaybackSurfaceOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
3
+ import { type AgentPlayback, type PlaybackChromeOptions, type PresenceStore } from '@pixerate/editor/tools';
4
+ /**
5
+ * `locate`, `locateElement` and `open` (see `PlaybackChromeOptions`) let the host's own chrome over
6
+ * the canvas (a HUD, toolbar or panels) answer refs the canvas does not find, such as
7
+ * `{ kind: 'panel' | 'control', id }`: `locate` in flow coordinates, `locateElement` as an element
8
+ * whose client box is mapped into flow coordinates through the viewport.
9
+ */
10
+ export interface UseCanvasPlaybackSurfaceOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> extends PlaybackChromeOptions {
5
11
  /** The flow's nodes and edges now (e.g. React Flow's `getNodes` / `getEdges`). */
6
12
  getNodes: () => readonly TNode[];
7
13
  getEdges?: () => readonly TEdge[];
@@ -1,7 +1,13 @@
1
1
  import { type RefObject } from 'react';
2
2
  import { type CanvasEdge, type CanvasNode, type NodeRectOptions } from '@pixerate/editor/canvas';
3
- import type { AgentPlayback, PresenceStore } from '@pixerate/editor/tools';
4
- export interface UseCanvasPlaybackSurfaceOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> {
3
+ import { type AgentPlayback, type PlaybackChromeOptions, type PresenceStore } from '@pixerate/editor/tools';
4
+ /**
5
+ * `locate`, `locateElement` and `open` (see `PlaybackChromeOptions`) let the host's own chrome over
6
+ * the canvas (a HUD, toolbar or panels) answer refs the canvas does not find, such as
7
+ * `{ kind: 'panel' | 'control', id }`: `locate` in flow coordinates, `locateElement` as an element
8
+ * whose client box is mapped into flow coordinates through the viewport.
9
+ */
10
+ export interface UseCanvasPlaybackSurfaceOptions<TNode extends CanvasNode = CanvasNode, TEdge extends CanvasEdge = CanvasEdge> extends PlaybackChromeOptions {
5
11
  /** The flow's nodes and edges now (e.g. React Flow's `getNodes` / `getEdges`). */
6
12
  getNodes: () => readonly TNode[];
7
13
  getEdges?: () => readonly TEdge[];
@@ -100,12 +100,12 @@ function useChartCommands(registry, controller, options = {}) {
100
100
  function useChartToolProvider(registry, controller, options = {}) {
101
101
  const latest = (0, import_react.useRef)(options);
102
102
  latest.current = options;
103
- const { id, namespace } = options;
103
+ const { id, namespace, playbackSurface } = options;
104
104
  (0, import_react.useEffect)(() => {
105
105
  if (!registry) return;
106
106
  const { rasterize, ...rest } = latest.current;
107
- return registry.register((0, import_chart.createChartToolProvider)(controller, { ...rest, id, namespace, rasterize: rasterize === false ? void 0 : rasterize ?? (0, import_chart.createChartRasterizer)() }));
108
- }, [registry, controller, id, namespace]);
107
+ return registry.register((0, import_chart.createChartToolProvider)(controller, { ...rest, id, namespace, playbackSurface, rasterize: rasterize === false ? void 0 : rasterize ?? (0, import_chart.createChartRasterizer)() }));
108
+ }, [registry, controller, id, namespace, playbackSurface]);
109
109
  }
110
110
  function useOfficeChartToolProvider(registry, options = {}) {
111
111
  const latest = (0, import_react.useRef)(options);
@@ -818,7 +818,11 @@ function usePlaybackSurface(playback, id, options = {}, sharedPresence) {
818
818
  beginGesture: (key) => o().beginGesture?.(key),
819
819
  endGesture: () => o().endGesture?.(),
820
820
  reveal: () => o().reveal?.(),
821
- open: (ref) => o().open?.(ref),
821
+ // Only a surface whose options can open things has `open`, so playback skips `open` steps
822
+ // (and their wait) everywhere else. Read per step, like the other options.
823
+ get open() {
824
+ return o().open ? (ref) => o().open?.(ref) : void 0;
825
+ },
822
826
  get defaultKind() {
823
827
  return o().defaultKind;
824
828
  }
@@ -20,12 +20,12 @@ import {
20
20
  useChartState,
21
21
  useChartToolProvider,
22
22
  useOfficeChartToolProvider
23
- } from "../chunk-AILJ4JOW.js";
23
+ } from "../chunk-GDPWLGPD.js";
24
24
  import {
25
25
  PresenceLayer,
26
26
  useAgentPlayback,
27
27
  usePlaybackSurface
28
- } from "../chunk-SI2V7XPZ.js";
28
+ } from "../chunk-GNO54NFG.js";
29
29
 
30
30
  // src/chart/ChartEditor.tsx
31
31
  import { useRef, useState } from "react";