@dxos/react-ui-canvas 0.8.1 → 0.8.2-main.10c050d

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