@dxos/react-ui-canvas 0.8.2-staging.7ac8446 → 0.8.2

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.
@@ -1,10 +1,11 @@
1
1
  // packages/ui/react-ui-canvas/src/components/Canvas/Canvas.tsx
2
+ import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
2
3
  import React2, { forwardRef, useEffect as useEffect2, useImperativeHandle, useMemo, useState } from "react";
3
4
  import { useResizeDetector } from "react-resize-detector";
4
5
  import { mx as mx2 } from "@dxos/react-ui-theme";
5
6
 
6
7
  // packages/ui/react-ui-canvas/src/hooks/projection.tsx
7
- import * as d3 from "d3";
8
+ import { interpolate, interpolateObject, transition, easeSinOut } from "d3";
8
9
  import { applyToPoints, compose, identity, inverse, scale as scaleMatrix, translate as translateMatrix } from "transformation-matrix";
9
10
  var defaultOrigin = {
10
11
  x: 0,
@@ -62,8 +63,8 @@ var getZoomTransform = ({ scale, offset, pos, newScale }) => {
62
63
  };
63
64
  };
64
65
  var zoomInPlace = (setTransform, pos, offset, current, next, delay = 200) => {
65
- const is = d3.interpolate(current, next);
66
- d3.transition().ease(d3.easeSinOut).duration(delay).tween("zoom", () => (t) => {
66
+ const is = interpolate(current, next);
67
+ transition().ease(easeSinOut).duration(delay).tween("zoom", () => (t) => {
67
68
  const newScale = is(t);
68
69
  setTransform(getZoomTransform({
69
70
  scale: current,
@@ -76,14 +77,14 @@ var zoomInPlace = (setTransform, pos, offset, current, next, delay = 200) => {
76
77
  var noop = () => {
77
78
  };
78
79
  var zoomTo = (setTransform, current, next, delay = 200, cb = noop) => {
79
- const is = d3.interpolateObject({
80
+ const is = interpolateObject({
80
81
  scale: current.scale,
81
82
  ...current.offset
82
83
  }, {
83
84
  scale: next.scale,
84
85
  ...next.offset
85
86
  });
86
- d3.transition().ease(d3.easeSinOut).duration(delay).tween("zoom", () => (t) => {
87
+ transition().ease(easeSinOut).duration(delay).tween("zoom", () => (t) => {
87
88
  const { scale, x, y } = is(t);
88
89
  setTransform({
89
90
  scale,
@@ -108,6 +109,7 @@ import { bindAll } from "bind-event-listener";
108
109
  import { useEffect } from "react";
109
110
 
110
111
  // packages/ui/react-ui-canvas/src/util/svg.tsx
112
+ import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
111
113
  import React from "react";
112
114
  import { mx } from "@dxos/react-ui-theme";
113
115
  var createPath = (points, join = false) => {
@@ -118,118 +120,144 @@ var createPath = (points, join = false) => {
118
120
  ].join(" ");
119
121
  };
120
122
  var Markers = ({ id = "dx-marker", classNames }) => {
121
- return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Arrow, {
122
- id: `${id}-arrow-start`,
123
- dir: "start",
124
- classNames
125
- }), /* @__PURE__ */ React.createElement(Arrow, {
126
- id: `${id}-arrow-end`,
127
- dir: "end",
128
- classNames
129
- }), /* @__PURE__ */ React.createElement(Arrow, {
130
- id: `${id}-triangle-start`,
131
- dir: "start",
132
- closed: true,
133
- classNames
134
- }), /* @__PURE__ */ React.createElement(Arrow, {
135
- id: `${id}-triangle-end`,
136
- dir: "end",
137
- closed: true,
138
- classNames
139
- }), /* @__PURE__ */ React.createElement(Marker, {
140
- id: `${id}-circle`,
141
- pos: {
142
- x: 8,
143
- y: 8
144
- },
145
- size: {
146
- width: 16,
147
- height: 16
148
- }
149
- }, /* @__PURE__ */ React.createElement("circle", {
150
- cx: 8,
151
- cy: 8,
152
- r: 5,
153
- stroke: "context-stroke",
154
- className: mx(classNames)
155
- })));
123
+ var _effect = _useSignals();
124
+ try {
125
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Arrow, {
126
+ id: `${id}-arrow-start`,
127
+ dir: "start",
128
+ classNames
129
+ }), /* @__PURE__ */ React.createElement(Arrow, {
130
+ id: `${id}-arrow-end`,
131
+ dir: "end",
132
+ classNames
133
+ }), /* @__PURE__ */ React.createElement(Arrow, {
134
+ id: `${id}-triangle-start`,
135
+ dir: "start",
136
+ closed: true,
137
+ classNames
138
+ }), /* @__PURE__ */ React.createElement(Arrow, {
139
+ id: `${id}-triangle-end`,
140
+ dir: "end",
141
+ closed: true,
142
+ classNames
143
+ }), /* @__PURE__ */ React.createElement(Marker, {
144
+ id: `${id}-circle`,
145
+ pos: {
146
+ x: 8,
147
+ y: 8
148
+ },
149
+ size: {
150
+ width: 16,
151
+ height: 16
152
+ }
153
+ }, /* @__PURE__ */ React.createElement("circle", {
154
+ cx: 8,
155
+ cy: 8,
156
+ r: 5,
157
+ stroke: "context-stroke",
158
+ className: mx(classNames)
159
+ })));
160
+ } finally {
161
+ _effect.f();
162
+ }
156
163
  };
157
- var Marker = ({ id, className, children, pos: { x: refX, y: refY }, size: { width: markerWidth, height: markerHeight }, fill, ...rest }) => /* @__PURE__ */ React.createElement("marker", {
158
- id,
159
- className,
160
- refX,
161
- refY,
162
- markerWidth,
163
- markerHeight,
164
- markerUnits: "strokeWidth",
165
- orient: "auto",
166
- ...rest
167
- }, children);
168
- var Arrow = ({ classNames, id, size = 16, dir = "end", closed = false }) => /* @__PURE__ */ React.createElement(Marker, {
169
- id,
170
- size: {
171
- width: size,
172
- height: size
173
- },
174
- pos: dir === "end" ? {
175
- x: size,
176
- y: size / 2
177
- } : {
178
- x: 0,
179
- y: size / 2
164
+ var Marker = ({ id, className, children, pos: { x: refX, y: refY }, size: { width: markerWidth, height: markerHeight }, fill, ...rest }) => {
165
+ var _effect = _useSignals();
166
+ try {
167
+ return /* @__PURE__ */ React.createElement("marker", {
168
+ id,
169
+ className,
170
+ refX,
171
+ refY,
172
+ markerWidth,
173
+ markerHeight,
174
+ markerUnits: "strokeWidth",
175
+ orient: "auto",
176
+ ...rest
177
+ }, children);
178
+ } finally {
179
+ _effect.f();
180
180
  }
181
- }, /* @__PURE__ */ React.createElement("path", {
182
- fill: closed ? void 0 : "none",
183
- stroke: "context-stroke",
184
- className: mx(classNames),
185
- d: createPath(dir === "end" ? [
186
- {
187
- x: 1,
188
- y: 1
189
- },
190
- {
191
- x: size,
192
- y: size / 2
193
- },
194
- {
195
- x: 1,
196
- y: size - 1
197
- }
198
- ] : [
199
- {
200
- x: size - 1,
201
- y: 1
202
- },
203
- {
204
- x: 0,
205
- y: size / 2
206
- },
207
- {
208
- x: size - 1,
209
- y: size - 1
210
- }
211
- ], closed)
212
- }));
213
- var GridPattern = ({ classNames, id, size, offset }) => /* @__PURE__ */ React.createElement("pattern", {
214
- id,
215
- x: (size / 2 + offset.x) % size,
216
- y: (size / 2 + offset.y) % size,
217
- width: size,
218
- height: size,
219
- patternUnits: "userSpaceOnUse"
220
- }, /* @__PURE__ */ React.createElement("g", {
221
- className: mx(classNames)
222
- }, /* @__PURE__ */ React.createElement("line", {
223
- x1: 0,
224
- y1: size / 2,
225
- x2: size,
226
- y2: size / 2
227
- }), /* @__PURE__ */ React.createElement("line", {
228
- x1: size / 2,
229
- y1: 0,
230
- x2: size / 2,
231
- y2: size
232
- })));
181
+ };
182
+ var Arrow = ({ classNames, id, size = 16, dir = "end", closed = false }) => {
183
+ var _effect = _useSignals();
184
+ try {
185
+ return /* @__PURE__ */ React.createElement(Marker, {
186
+ id,
187
+ size: {
188
+ width: size,
189
+ height: size
190
+ },
191
+ pos: dir === "end" ? {
192
+ x: size,
193
+ y: size / 2
194
+ } : {
195
+ x: 0,
196
+ y: size / 2
197
+ }
198
+ }, /* @__PURE__ */ React.createElement("path", {
199
+ fill: closed ? void 0 : "none",
200
+ stroke: "context-stroke",
201
+ className: mx(classNames),
202
+ d: createPath(dir === "end" ? [
203
+ {
204
+ x: 1,
205
+ y: 1
206
+ },
207
+ {
208
+ x: size,
209
+ y: size / 2
210
+ },
211
+ {
212
+ x: 1,
213
+ y: size - 1
214
+ }
215
+ ] : [
216
+ {
217
+ x: size - 1,
218
+ y: 1
219
+ },
220
+ {
221
+ x: 0,
222
+ y: size / 2
223
+ },
224
+ {
225
+ x: size - 1,
226
+ y: size - 1
227
+ }
228
+ ], closed)
229
+ }));
230
+ } finally {
231
+ _effect.f();
232
+ }
233
+ };
234
+ var GridPattern = ({ classNames, id, size, offset }) => {
235
+ var _effect = _useSignals();
236
+ try {
237
+ return /* @__PURE__ */ React.createElement("pattern", {
238
+ id,
239
+ x: (size / 2 + offset.x) % size,
240
+ y: (size / 2 + offset.y) % size,
241
+ width: size,
242
+ height: size,
243
+ patternUnits: "userSpaceOnUse"
244
+ }, /* @__PURE__ */ React.createElement("g", {
245
+ className: mx(classNames)
246
+ }, /* @__PURE__ */ React.createElement("line", {
247
+ x1: 0,
248
+ y1: size / 2,
249
+ x2: size,
250
+ y2: size / 2
251
+ }), /* @__PURE__ */ React.createElement("line", {
252
+ x1: size / 2,
253
+ y1: 0,
254
+ x2: size / 2,
255
+ y2: size
256
+ })));
257
+ } finally {
258
+ _effect.f();
259
+ }
260
+ };
233
261
 
234
262
  // packages/ui/react-ui-canvas/src/util/util.ts
235
263
  var logged = false;
@@ -352,155 +380,167 @@ var hasFocus = (element) => {
352
380
 
353
381
  // packages/ui/react-ui-canvas/src/components/Canvas/Canvas.tsx
354
382
  var Canvas = /* @__PURE__ */ forwardRef(({ children, classNames, scale: _scale = 1, offset: _offset = defaultOrigin, ...props }, forwardedRef) => {
355
- const { ref, width = 0, height = 0 } = useResizeDetector();
356
- const [ready, setReady] = useState(false);
357
- const [{ scale, offset }, setProjection] = useState({
358
- scale: _scale,
359
- offset: _offset
360
- });
361
- useEffect2(() => {
362
- if (width && height && offset === defaultOrigin) {
363
- setProjection({
364
- scale,
365
- offset: {
366
- x: width / 2,
367
- y: height / 2
368
- }
369
- });
370
- }
371
- }, [
372
- width,
373
- height,
374
- scale,
375
- offset
376
- ]);
377
- const projection = useMemo(() => new ProjectionMapper(), []);
378
- useEffect2(() => {
379
- projection.update({
380
- width,
381
- height
382
- }, scale, offset);
383
- if (offset !== defaultOrigin) {
384
- setReady(true);
385
- }
386
- }, [
387
- projection,
388
- scale,
389
- offset,
390
- width,
391
- height
392
- ]);
393
- const styles = useMemo(() => {
394
- return {
395
- // NOTE: Order is important.
396
- transform: `translate(${offset.x}px, ${offset.y}px) scale(${scale})`,
397
- visibility: width && height ? "visible" : "hidden"
398
- };
399
- }, [
400
- scale,
401
- offset
402
- ]);
403
- useImperativeHandle(forwardedRef, () => {
404
- return {
405
- setProjection: async (projection2) => {
406
- setProjection(projection2);
383
+ var _effect = _useSignals2();
384
+ try {
385
+ const { ref, width = 0, height = 0 } = useResizeDetector();
386
+ const [ready, setReady] = useState(false);
387
+ const [{ scale, offset }, setProjection] = useState({
388
+ scale: _scale,
389
+ offset: _offset
390
+ });
391
+ useEffect2(() => {
392
+ if (width && height && offset === defaultOrigin) {
393
+ setProjection({
394
+ scale,
395
+ offset: {
396
+ x: width / 2,
397
+ y: height / 2
398
+ }
399
+ });
407
400
  }
408
- };
409
- }, [
410
- ref
411
- ]);
412
- return /* @__PURE__ */ React2.createElement(CanvasContext.Provider, {
413
- value: {
414
- root: ref.current,
415
- ready,
401
+ }, [
416
402
  width,
417
403
  height,
418
404
  scale,
419
- offset,
420
- styles,
405
+ offset
406
+ ]);
407
+ const projection = useMemo(() => new ProjectionMapper(), []);
408
+ useEffect2(() => {
409
+ projection.update({
410
+ width,
411
+ height
412
+ }, scale, offset);
413
+ if (offset !== defaultOrigin) {
414
+ setReady(true);
415
+ }
416
+ }, [
421
417
  projection,
422
- setProjection
423
- }
424
- }, /* @__PURE__ */ React2.createElement("div", {
425
- role: "none",
426
- ...props,
427
- className: mx2("absolute inset-0 overflow-hidden", classNames),
428
- ref
429
- }, ready ? children : null));
418
+ scale,
419
+ offset,
420
+ width,
421
+ height
422
+ ]);
423
+ const styles = useMemo(() => {
424
+ return {
425
+ // NOTE: Order is important.
426
+ transform: `translate(${offset.x}px, ${offset.y}px) scale(${scale})`,
427
+ visibility: width && height ? "visible" : "hidden"
428
+ };
429
+ }, [
430
+ scale,
431
+ offset
432
+ ]);
433
+ useImperativeHandle(forwardedRef, () => {
434
+ return {
435
+ setProjection: async (projection2) => {
436
+ setProjection(projection2);
437
+ }
438
+ };
439
+ }, [
440
+ ref
441
+ ]);
442
+ return /* @__PURE__ */ React2.createElement(CanvasContext.Provider, {
443
+ value: {
444
+ root: ref.current,
445
+ ready,
446
+ width,
447
+ height,
448
+ scale,
449
+ offset,
450
+ styles,
451
+ projection,
452
+ setProjection
453
+ }
454
+ }, /* @__PURE__ */ React2.createElement("div", {
455
+ role: "none",
456
+ ...props,
457
+ className: mx2("absolute inset-0 overflow-hidden", classNames),
458
+ ref
459
+ }, ready ? children : null));
460
+ } finally {
461
+ _effect.f();
462
+ }
430
463
  });
431
464
 
432
465
  // packages/ui/react-ui-canvas/src/components/FPS.tsx
466
+ import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
433
467
  import React3, { useEffect as useEffect3, useReducer, useRef } from "react";
434
468
  import { mx as mx3 } from "@dxos/react-ui-theme";
435
469
  var SEC = 1e3;
436
470
  var FPS = ({ classNames, width = 60, height = 30, bar = "bg-cyan-500" }) => {
437
- const [{ fps, max, len }, dispatch] = useReducer((state) => {
438
- const currentTime = Date.now();
439
- if (currentTime > state.prevTime + SEC) {
440
- const nextFPS = [
441
- ...new Array(Math.floor((currentTime - state.prevTime - SEC) / SEC)).fill(0),
442
- Math.max(1, Math.round(state.frames * SEC / (currentTime - state.prevTime)))
443
- ];
444
- return {
445
- max: Math.max(state.max, ...nextFPS),
446
- len: Math.min(state.len + nextFPS.length, width),
447
- fps: [
448
- ...state.fps,
449
- ...nextFPS
450
- ].slice(-width),
451
- frames: 1,
452
- prevTime: currentTime
453
- };
454
- } else {
455
- return {
456
- ...state,
457
- frames: state.frames + 1
458
- };
459
- }
460
- }, {
461
- max: 0,
462
- len: 0,
463
- fps: [],
464
- frames: 0,
465
- prevTime: Date.now()
466
- });
467
- const requestRef = useRef();
468
- const tick = () => {
469
- dispatch();
470
- requestRef.current = requestAnimationFrame(tick);
471
- };
472
- useEffect3(() => {
473
- requestRef.current = requestAnimationFrame(tick);
474
- return () => {
475
- if (requestRef.current) {
476
- cancelAnimationFrame(requestRef.current);
471
+ var _effect = _useSignals3();
472
+ try {
473
+ const [{ fps, max, len }, dispatch] = useReducer((state) => {
474
+ const currentTime = Date.now();
475
+ if (currentTime > state.prevTime + SEC) {
476
+ const nextFPS = [
477
+ ...new Array(Math.floor((currentTime - state.prevTime - SEC) / SEC)).fill(0),
478
+ Math.max(1, Math.round(state.frames * SEC / (currentTime - state.prevTime)))
479
+ ];
480
+ return {
481
+ max: Math.max(state.max, ...nextFPS),
482
+ len: Math.min(state.len + nextFPS.length, width),
483
+ fps: [
484
+ ...state.fps,
485
+ ...nextFPS
486
+ ].slice(-width),
487
+ frames: 1,
488
+ prevTime: currentTime
489
+ };
490
+ } else {
491
+ return {
492
+ ...state,
493
+ frames: state.frames + 1
494
+ };
477
495
  }
496
+ }, {
497
+ max: 0,
498
+ len: 0,
499
+ fps: [],
500
+ frames: 0,
501
+ prevTime: Date.now()
502
+ });
503
+ const requestRef = useRef();
504
+ const tick = () => {
505
+ dispatch();
506
+ requestRef.current = requestAnimationFrame(tick);
478
507
  };
479
- }, []);
480
- return /* @__PURE__ */ React3.createElement("div", {
481
- style: {
482
- width: width + 6
483
- },
484
- className: mx3("relative flex flex-col p-0.5", "bg-baseSurface text-xs text-subdued font-thin pointer-events-none border border-separator", classNames)
485
- }, /* @__PURE__ */ React3.createElement("div", null, fps[len - 1], " FPS"), /* @__PURE__ */ React3.createElement("div", {
486
- className: "w-full relative",
487
- style: {
488
- height
489
- }
490
- }, fps.map((frame, i) => /* @__PURE__ */ React3.createElement("div", {
491
- key: `fps-${i}`,
492
- className: bar,
493
- style: {
494
- position: "absolute",
495
- bottom: 0,
496
- right: `${len - 1 - i}px`,
497
- height: `${height * frame / max}px`,
498
- width: 1
499
- }
500
- }))));
508
+ useEffect3(() => {
509
+ requestRef.current = requestAnimationFrame(tick);
510
+ return () => {
511
+ if (requestRef.current) {
512
+ cancelAnimationFrame(requestRef.current);
513
+ }
514
+ };
515
+ }, []);
516
+ return /* @__PURE__ */ React3.createElement("div", {
517
+ style: {
518
+ width: width + 6
519
+ },
520
+ className: mx3("relative flex flex-col p-0.5", "bg-baseSurface text-xs text-subdued font-thin pointer-events-none border border-separator", classNames)
521
+ }, /* @__PURE__ */ React3.createElement("div", null, fps[len - 1], " FPS"), /* @__PURE__ */ React3.createElement("div", {
522
+ className: "w-full relative",
523
+ style: {
524
+ height
525
+ }
526
+ }, fps.map((frame, i) => /* @__PURE__ */ React3.createElement("div", {
527
+ key: `fps-${i}`,
528
+ className: bar,
529
+ style: {
530
+ position: "absolute",
531
+ bottom: 0,
532
+ right: `${len - 1 - i}px`,
533
+ height: `${height * frame / max}px`,
534
+ width: 1
535
+ }
536
+ }))));
537
+ } finally {
538
+ _effect.f();
539
+ }
501
540
  };
502
541
 
503
542
  // packages/ui/react-ui-canvas/src/components/Grid/Grid.tsx
543
+ import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
504
544
  import React4, { forwardRef as forwardRef2, useMemo as useMemo2, useId } from "react";
505
545
  import { useForwardedRef } from "@dxos/react-ui";
506
546
  import { mx as mx4 } from "@dxos/react-ui-theme";
@@ -517,65 +557,75 @@ var defaultOffset = {
517
557
  };
518
558
  var createId = (parent, grid) => `dx-canvas-grid-${parent}-${grid}`;
519
559
  var GridComponent = /* @__PURE__ */ forwardRef2(({ size: gridSize = defaultGridSize, scale = 1, offset = defaultOffset, showAxes = true, classNames }, forwardedRef) => {
520
- const svgRef = useForwardedRef(forwardedRef);
521
- const instanceId = useId();
522
- const grids = useMemo2(() => gridRatios.map((ratio) => ({
523
- id: ratio,
524
- size: ratio * gridSize * scale
525
- })).filter(({ size }) => size >= gridSize && size <= 256), [
526
- gridSize,
527
- scale
528
- ]);
529
- const { width = 0, height = 0 } = svgRef.current?.getBoundingClientRect() ?? {};
530
- return /* @__PURE__ */ React4.createElement("svg", {
531
- ...testId("dx-canvas-grid"),
532
- ref: svgRef,
533
- className: mx4("absolute inset-0 w-full h-full pointer-events-none touch-none select-none", "stroke-neutral-500", classNames)
534
- }, /* @__PURE__ */ React4.createElement("defs", null, grids.map(({ id, size }) => /* @__PURE__ */ React4.createElement(GridPattern, {
535
- key: id,
536
- id: createId(instanceId, id),
537
- offset,
538
- size
539
- }))), showAxes && /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("line", {
540
- x1: 0,
541
- y1: offset.y,
542
- x2: width,
543
- y2: offset.y,
544
- className: "stroke-neutral-500 opacity-40"
545
- }), /* @__PURE__ */ React4.createElement("line", {
546
- x1: offset.x,
547
- y1: 0,
548
- x2: offset.x,
549
- y2: height,
550
- className: "stroke-neutral-500 opacity-40"
551
- })), /* @__PURE__ */ React4.createElement("g", null, grids.map(({ id }, i) => /* @__PURE__ */ React4.createElement("rect", {
552
- key: id,
553
- opacity: 0.1 + i * 0.05,
554
- fill: `url(#${createId(instanceId, id)})`,
555
- width: "100%",
556
- height: "100%"
557
- }))));
560
+ var _effect = _useSignals4();
561
+ try {
562
+ const svgRef = useForwardedRef(forwardedRef);
563
+ const instanceId = useId();
564
+ const grids = useMemo2(() => gridRatios.map((ratio) => ({
565
+ id: ratio,
566
+ size: ratio * gridSize * scale
567
+ })).filter(({ size }) => size >= gridSize && size <= 256), [
568
+ gridSize,
569
+ scale
570
+ ]);
571
+ const { width = 0, height = 0 } = svgRef.current?.getBoundingClientRect() ?? {};
572
+ return /* @__PURE__ */ React4.createElement("svg", {
573
+ ...testId("dx-canvas-grid"),
574
+ ref: svgRef,
575
+ className: mx4("absolute inset-0 w-full h-full pointer-events-none touch-none select-none", "stroke-neutral-500", classNames)
576
+ }, /* @__PURE__ */ React4.createElement("defs", null, grids.map(({ id, size }) => /* @__PURE__ */ React4.createElement(GridPattern, {
577
+ key: id,
578
+ id: createId(instanceId, id),
579
+ offset,
580
+ size
581
+ }))), showAxes && /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("line", {
582
+ x1: 0,
583
+ y1: offset.y,
584
+ x2: width,
585
+ y2: offset.y,
586
+ className: "stroke-neutral-500 opacity-40"
587
+ }), /* @__PURE__ */ React4.createElement("line", {
588
+ x1: offset.x,
589
+ y1: 0,
590
+ x2: offset.x,
591
+ y2: height,
592
+ className: "stroke-neutral-500 opacity-40"
593
+ })), /* @__PURE__ */ React4.createElement("g", null, grids.map(({ id }, i) => /* @__PURE__ */ React4.createElement("rect", {
594
+ key: id,
595
+ opacity: 0.1 + i * 0.05,
596
+ fill: `url(#${createId(instanceId, id)})`,
597
+ width: "100%",
598
+ height: "100%"
599
+ }))));
600
+ } finally {
601
+ _effect.f();
602
+ }
558
603
  });
559
604
  var Grid = (props) => {
560
- const { scale, offset } = useCanvasContext();
561
- return /* @__PURE__ */ React4.createElement(GridComponent, {
562
- ...props,
563
- scale,
564
- offset
565
- });
605
+ var _effect = _useSignals4();
606
+ try {
607
+ const { scale, offset } = useCanvasContext();
608
+ return /* @__PURE__ */ React4.createElement(GridComponent, {
609
+ ...props,
610
+ scale,
611
+ offset
612
+ });
613
+ } finally {
614
+ _effect.f();
615
+ }
566
616
  };
567
617
 
568
618
  // packages/ui/react-ui-canvas/src/types.ts
569
- import { Schema as S } from "effect";
570
- var Point = S.Struct({
571
- x: S.Number,
572
- y: S.Number
619
+ import { Schema } from "effect";
620
+ var Point = Schema.Struct({
621
+ x: Schema.Number,
622
+ y: Schema.Number
573
623
  });
574
- var Dimension = S.Struct({
575
- width: S.Number,
576
- height: S.Number
624
+ var Dimension = Schema.Struct({
625
+ width: Schema.Number,
626
+ height: Schema.Number
577
627
  });
578
- var Rect = S.extend(Point, Dimension);
628
+ var Rect = Schema.extend(Point, Dimension);
579
629
  export {
580
630
  Arrow,
581
631
  Canvas,