@dxos/react-ui-canvas 0.7.5-main.499c70c
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/LICENSE +8 -0
- package/README.md +3 -0
- package/dist/lib/browser/index.mjs +525 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/node/index.cjs +559 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/lib/node-esm/index.mjs +527 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/types/src/components/Canvas/Canvas.d.ts +15 -0
- package/dist/types/src/components/Canvas/Canvas.d.ts.map +1 -0
- package/dist/types/src/components/Canvas/Canvas.stories.d.ts +8 -0
- package/dist/types/src/components/Canvas/Canvas.stories.d.ts.map +1 -0
- package/dist/types/src/components/Canvas/index.d.ts +2 -0
- package/dist/types/src/components/Canvas/index.d.ts.map +1 -0
- package/dist/types/src/components/FPS.d.ts +9 -0
- package/dist/types/src/components/FPS.d.ts.map +1 -0
- package/dist/types/src/components/Grid/Grid.d.ts +18 -0
- package/dist/types/src/components/Grid/Grid.d.ts.map +1 -0
- package/dist/types/src/components/Grid/Grid.stories.d.ts +8 -0
- package/dist/types/src/components/Grid/Grid.stories.d.ts.map +1 -0
- package/dist/types/src/components/Grid/index.d.ts +2 -0
- package/dist/types/src/components/Grid/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +4 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/projection.d.ts +58 -0
- package/dist/types/src/hooks/projection.d.ts.map +1 -0
- package/dist/types/src/hooks/useProjection.d.ts +12 -0
- package/dist/types/src/hooks/useProjection.d.ts.map +1 -0
- package/dist/types/src/hooks/useWheel.d.ts +7 -0
- package/dist/types/src/hooks/useWheel.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +20 -0
- package/dist/types/src/types.d.ts.map +1 -0
- package/dist/types/src/util/index.d.ts +3 -0
- package/dist/types/src/util/index.d.ts.map +1 -0
- package/dist/types/src/util/svg.d.ts +33 -0
- package/dist/types/src/util/svg.d.ts.map +1 -0
- package/dist/types/src/util/svg.stories.d.ts +6 -0
- package/dist/types/src/util/svg.stories.d.ts.map +1 -0
- package/dist/types/src/util/util.d.ts +16 -0
- package/dist/types/src/util/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +61 -0
- package/src/components/Canvas/Canvas.stories.tsx +82 -0
- package/src/components/Canvas/Canvas.tsx +83 -0
- package/src/components/Canvas/index.ts +5 -0
- package/src/components/FPS.tsx +98 -0
- package/src/components/Grid/Grid.stories.tsx +43 -0
- package/src/components/Grid/Grid.tsx +61 -0
- package/src/components/Grid/index.ts +5 -0
- package/src/components/index.ts +7 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/projection.tsx +149 -0
- package/src/hooks/useProjection.tsx +28 -0
- package/src/hooks/useWheel.tsx +55 -0
- package/src/index.ts +8 -0
- package/src/types.ts +13 -0
- package/src/util/index.ts +6 -0
- package/src/util/svg.stories.tsx +45 -0
- package/src/util/svg.tsx +131 -0
- package/src/util/util.ts +39 -0
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
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
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var node_exports = {};
|
|
30
|
+
__export(node_exports, {
|
|
31
|
+
Arrow: () => Arrow,
|
|
32
|
+
Canvas: () => Canvas,
|
|
33
|
+
CanvasContext: () => CanvasContext,
|
|
34
|
+
DATA_TEST_ID: () => DATA_TEST_ID,
|
|
35
|
+
Dimension: () => Dimension,
|
|
36
|
+
FPS: () => FPS,
|
|
37
|
+
Grid: () => Grid,
|
|
38
|
+
GridPattern: () => GridPattern,
|
|
39
|
+
Marker: () => Marker,
|
|
40
|
+
Markers: () => Markers,
|
|
41
|
+
Point: () => Point,
|
|
42
|
+
ProjectionMapper: () => ProjectionMapper,
|
|
43
|
+
Rect: () => Rect,
|
|
44
|
+
createPath: () => createPath,
|
|
45
|
+
defaultOffset: () => defaultOffset,
|
|
46
|
+
getRelativePoint: () => getRelativePoint,
|
|
47
|
+
getZoomTransform: () => getZoomTransform,
|
|
48
|
+
testId: () => testId,
|
|
49
|
+
useProjection: () => useProjection,
|
|
50
|
+
useWheel: () => useWheel,
|
|
51
|
+
zoomInPlace: () => zoomInPlace,
|
|
52
|
+
zoomTo: () => zoomTo
|
|
53
|
+
});
|
|
54
|
+
module.exports = __toCommonJS(node_exports);
|
|
55
|
+
var import_react = __toESM(require("react"));
|
|
56
|
+
var import_react_resize_detector = require("react-resize-detector");
|
|
57
|
+
var import_react_ui_theme = require("@dxos/react-ui-theme");
|
|
58
|
+
var d3 = __toESM(require("d3"));
|
|
59
|
+
var import_transformation_matrix = require("transformation-matrix");
|
|
60
|
+
var import_react2 = require("react");
|
|
61
|
+
var import_debug = require("@dxos/debug");
|
|
62
|
+
var import_bind_event_listener = require("bind-event-listener");
|
|
63
|
+
var import_react3 = require("react");
|
|
64
|
+
var import_react4 = __toESM(require("react"));
|
|
65
|
+
var import_react_ui_theme2 = require("@dxos/react-ui-theme");
|
|
66
|
+
var import_react5 = __toESM(require("react"));
|
|
67
|
+
var import_react_ui_theme3 = require("@dxos/react-ui-theme");
|
|
68
|
+
var import_react6 = __toESM(require("react"));
|
|
69
|
+
var import_react_ui_theme4 = require("@dxos/react-ui-theme");
|
|
70
|
+
var import_effect = require("@dxos/effect");
|
|
71
|
+
var defaultOffset = {
|
|
72
|
+
x: 0,
|
|
73
|
+
y: 0
|
|
74
|
+
};
|
|
75
|
+
var ProjectionMapper = class {
|
|
76
|
+
constructor(bounds, scale, offset) {
|
|
77
|
+
this._bounds = {
|
|
78
|
+
width: 0,
|
|
79
|
+
height: 0
|
|
80
|
+
};
|
|
81
|
+
this._scale = 1;
|
|
82
|
+
this._offset = defaultOffset;
|
|
83
|
+
this._toScreen = (0, import_transformation_matrix.identity)();
|
|
84
|
+
this._toModel = (0, import_transformation_matrix.identity)();
|
|
85
|
+
if (bounds && scale && offset) {
|
|
86
|
+
this.update(bounds, scale, offset);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
update(bounds, scale, offset) {
|
|
90
|
+
this._bounds = bounds;
|
|
91
|
+
this._scale = scale;
|
|
92
|
+
this._offset = offset;
|
|
93
|
+
this._toScreen = (0, import_transformation_matrix.compose)((0, import_transformation_matrix.translate)(this._offset.x, this._offset.y), (0, import_transformation_matrix.scale)(this._scale));
|
|
94
|
+
this._toModel = (0, import_transformation_matrix.inverse)(this._toScreen);
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
get bounds() {
|
|
98
|
+
return this._bounds;
|
|
99
|
+
}
|
|
100
|
+
get scale() {
|
|
101
|
+
return this._scale;
|
|
102
|
+
}
|
|
103
|
+
get offset() {
|
|
104
|
+
return this._offset;
|
|
105
|
+
}
|
|
106
|
+
toScreen(points) {
|
|
107
|
+
return (0, import_transformation_matrix.applyToPoints)(this._toScreen, points);
|
|
108
|
+
}
|
|
109
|
+
toModel(points) {
|
|
110
|
+
return (0, import_transformation_matrix.applyToPoints)(this._toModel, points);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
var getZoomTransform = ({ scale, offset, pos, newScale }) => {
|
|
114
|
+
return {
|
|
115
|
+
scale: newScale,
|
|
116
|
+
offset: {
|
|
117
|
+
x: pos.x - (pos.x - offset.x) * (newScale / scale),
|
|
118
|
+
y: pos.y - (pos.y - offset.y) * (newScale / scale)
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
var zoomInPlace = (setTransform, pos, offset, current, next, delay = 200) => {
|
|
123
|
+
const is = d3.interpolate(current, next);
|
|
124
|
+
d3.transition().ease(d3.easeSinOut).duration(delay).tween("zoom", () => (t) => {
|
|
125
|
+
const newScale = is(t);
|
|
126
|
+
setTransform(getZoomTransform({
|
|
127
|
+
scale: current,
|
|
128
|
+
newScale,
|
|
129
|
+
offset,
|
|
130
|
+
pos
|
|
131
|
+
}));
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
var zoomTo = (setTransform, current, next, delay = 200) => {
|
|
135
|
+
const is = d3.interpolateObject({
|
|
136
|
+
scale: current.scale,
|
|
137
|
+
...current.offset
|
|
138
|
+
}, {
|
|
139
|
+
scale: next.scale,
|
|
140
|
+
...next.offset
|
|
141
|
+
});
|
|
142
|
+
d3.transition().ease(d3.easeSinOut).duration(delay).tween("zoom", () => (t) => {
|
|
143
|
+
const { scale, x, y } = is(t);
|
|
144
|
+
setTransform({
|
|
145
|
+
scale,
|
|
146
|
+
offset: {
|
|
147
|
+
x,
|
|
148
|
+
y
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
var CanvasContext = /* @__PURE__ */ (0, import_react2.createContext)(null);
|
|
154
|
+
var useProjection = () => {
|
|
155
|
+
return (0, import_react2.useContext)(CanvasContext) ?? (0, import_debug.raise)(new Error("Missing CanvasContext"));
|
|
156
|
+
};
|
|
157
|
+
var createPath = (points, join = false) => {
|
|
158
|
+
return [
|
|
159
|
+
"M",
|
|
160
|
+
points.map(({ x, y }) => `${x},${y}`).join(" L "),
|
|
161
|
+
join ? "Z" : ""
|
|
162
|
+
].join(" ");
|
|
163
|
+
};
|
|
164
|
+
var Markers = ({ id = "dx-marker", classNames }) => {
|
|
165
|
+
return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(Arrow, {
|
|
166
|
+
id: `${id}-arrow-start`,
|
|
167
|
+
dir: "start",
|
|
168
|
+
classNames
|
|
169
|
+
}), /* @__PURE__ */ import_react4.default.createElement(Arrow, {
|
|
170
|
+
id: `${id}-arrow-end`,
|
|
171
|
+
dir: "end",
|
|
172
|
+
classNames
|
|
173
|
+
}), /* @__PURE__ */ import_react4.default.createElement(Arrow, {
|
|
174
|
+
id: `${id}-triangle-start`,
|
|
175
|
+
dir: "start",
|
|
176
|
+
closed: true,
|
|
177
|
+
classNames
|
|
178
|
+
}), /* @__PURE__ */ import_react4.default.createElement(Arrow, {
|
|
179
|
+
id: `${id}-triangle-end`,
|
|
180
|
+
dir: "end",
|
|
181
|
+
closed: true,
|
|
182
|
+
classNames
|
|
183
|
+
}), /* @__PURE__ */ import_react4.default.createElement(Marker, {
|
|
184
|
+
id: `${id}-circle`,
|
|
185
|
+
pos: {
|
|
186
|
+
x: 6,
|
|
187
|
+
y: 6
|
|
188
|
+
},
|
|
189
|
+
size: {
|
|
190
|
+
width: 12,
|
|
191
|
+
height: 12
|
|
192
|
+
}
|
|
193
|
+
}, /* @__PURE__ */ import_react4.default.createElement("circle", {
|
|
194
|
+
cx: 6,
|
|
195
|
+
cy: 6,
|
|
196
|
+
r: 5,
|
|
197
|
+
stroke: "context-stroke",
|
|
198
|
+
className: (0, import_react_ui_theme2.mx)(classNames)
|
|
199
|
+
})));
|
|
200
|
+
};
|
|
201
|
+
var Marker = ({ id, className, children, pos: { x: refX, y: refY }, size: { width: markerWidth, height: markerHeight }, fill, ...rest }) => /* @__PURE__ */ import_react4.default.createElement("marker", {
|
|
202
|
+
id,
|
|
203
|
+
className,
|
|
204
|
+
refX,
|
|
205
|
+
refY,
|
|
206
|
+
markerWidth,
|
|
207
|
+
markerHeight,
|
|
208
|
+
markerUnits: "strokeWidth",
|
|
209
|
+
orient: "auto",
|
|
210
|
+
...rest
|
|
211
|
+
}, children);
|
|
212
|
+
var Arrow = ({ classNames, id, size = 16, dir = "end", closed = false }) => /* @__PURE__ */ import_react4.default.createElement(Marker, {
|
|
213
|
+
id,
|
|
214
|
+
size: {
|
|
215
|
+
width: size,
|
|
216
|
+
height: size
|
|
217
|
+
},
|
|
218
|
+
pos: dir === "end" ? {
|
|
219
|
+
x: size,
|
|
220
|
+
y: size / 2
|
|
221
|
+
} : {
|
|
222
|
+
x: 0,
|
|
223
|
+
y: size / 2
|
|
224
|
+
}
|
|
225
|
+
}, /* @__PURE__ */ import_react4.default.createElement("path", {
|
|
226
|
+
fill: closed ? void 0 : "none",
|
|
227
|
+
stroke: "context-stroke",
|
|
228
|
+
className: (0, import_react_ui_theme2.mx)(classNames),
|
|
229
|
+
d: createPath(dir === "end" ? [
|
|
230
|
+
{
|
|
231
|
+
x: 1,
|
|
232
|
+
y: 1
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
x: size,
|
|
236
|
+
y: size / 2
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
x: 1,
|
|
240
|
+
y: size - 1
|
|
241
|
+
}
|
|
242
|
+
] : [
|
|
243
|
+
{
|
|
244
|
+
x: size - 1,
|
|
245
|
+
y: 1
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
x: 0,
|
|
249
|
+
y: size / 2
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
x: size - 1,
|
|
253
|
+
y: size - 1
|
|
254
|
+
}
|
|
255
|
+
], closed)
|
|
256
|
+
}));
|
|
257
|
+
var GridPattern = ({ classNames, id, size, offset }) => /* @__PURE__ */ import_react4.default.createElement("pattern", {
|
|
258
|
+
id,
|
|
259
|
+
x: (size / 2 + offset.x) % size,
|
|
260
|
+
y: (size / 2 + offset.y) % size,
|
|
261
|
+
width: size,
|
|
262
|
+
height: size,
|
|
263
|
+
patternUnits: "userSpaceOnUse"
|
|
264
|
+
}, /* @__PURE__ */ import_react4.default.createElement("g", {
|
|
265
|
+
className: (0, import_react_ui_theme2.mx)(classNames)
|
|
266
|
+
}, /* @__PURE__ */ import_react4.default.createElement("line", {
|
|
267
|
+
x1: 0,
|
|
268
|
+
y1: size / 2,
|
|
269
|
+
x2: size,
|
|
270
|
+
y2: size / 2
|
|
271
|
+
}), /* @__PURE__ */ import_react4.default.createElement("line", {
|
|
272
|
+
x1: size / 2,
|
|
273
|
+
y1: 0,
|
|
274
|
+
x2: size / 2,
|
|
275
|
+
y2: size
|
|
276
|
+
})));
|
|
277
|
+
var logged = false;
|
|
278
|
+
var getRelativePoint = (el, ev) => {
|
|
279
|
+
const rect = el.getBoundingClientRect();
|
|
280
|
+
return {
|
|
281
|
+
x: ev.clientX - rect.x,
|
|
282
|
+
y: ev.clientY - rect.top
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
var testId = (id, inspect = false) => {
|
|
286
|
+
if (inspect) {
|
|
287
|
+
if (!logged) {
|
|
288
|
+
console.log("Open storybook in expanded window;\nthen run INSPECT()");
|
|
289
|
+
logged = true;
|
|
290
|
+
}
|
|
291
|
+
window.INSPECT = () => {
|
|
292
|
+
const el = document.querySelector(`[data-test-id="${id}"]`);
|
|
293
|
+
window.inspect(el);
|
|
294
|
+
console.log(el);
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
return {
|
|
298
|
+
[DATA_TEST_ID]: id
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
var DATA_TEST_ID = "data-test-id";
|
|
302
|
+
var useWheel = (el, setProjection) => {
|
|
303
|
+
(0, import_react3.useEffect)(() => {
|
|
304
|
+
if (!el) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
return (0, import_bind_event_listener.bindAll)(el, [
|
|
308
|
+
{
|
|
309
|
+
type: "wheel",
|
|
310
|
+
options: {
|
|
311
|
+
capture: true,
|
|
312
|
+
passive: false
|
|
313
|
+
},
|
|
314
|
+
listener: (ev) => {
|
|
315
|
+
ev.preventDefault();
|
|
316
|
+
if (ev.ctrlKey) {
|
|
317
|
+
if (!el) {
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
setProjection(({ scale, offset }) => {
|
|
321
|
+
const pos = getRelativePoint(el, ev);
|
|
322
|
+
const scaleSensitivity = 0.01;
|
|
323
|
+
const newScale = scale * Math.exp(-ev.deltaY * scaleSensitivity);
|
|
324
|
+
return getZoomTransform({
|
|
325
|
+
scale,
|
|
326
|
+
offset,
|
|
327
|
+
newScale,
|
|
328
|
+
pos
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
} else {
|
|
332
|
+
setProjection(({ scale, offset: { x, y } }) => {
|
|
333
|
+
return {
|
|
334
|
+
scale,
|
|
335
|
+
offset: {
|
|
336
|
+
x: x - ev.deltaX,
|
|
337
|
+
y: y - ev.deltaY
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
]);
|
|
345
|
+
}, [
|
|
346
|
+
el,
|
|
347
|
+
setProjection
|
|
348
|
+
]);
|
|
349
|
+
};
|
|
350
|
+
var Canvas = /* @__PURE__ */ (0, import_react.forwardRef)(({ children, classNames, scale: _scale = 1, offset: _offset = defaultOffset, ...props }, forwardedRef) => {
|
|
351
|
+
const { ref, width = 0, height = 0 } = (0, import_react_resize_detector.useResizeDetector)();
|
|
352
|
+
const [{ scale, offset }, setProjection] = (0, import_react.useState)({
|
|
353
|
+
scale: _scale,
|
|
354
|
+
offset: _offset
|
|
355
|
+
});
|
|
356
|
+
(0, import_react.useEffect)(() => {
|
|
357
|
+
if (width && height && offset === defaultOffset) {
|
|
358
|
+
setProjection({
|
|
359
|
+
scale,
|
|
360
|
+
offset: {
|
|
361
|
+
x: width / 2,
|
|
362
|
+
y: height / 2
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
}, [
|
|
367
|
+
width,
|
|
368
|
+
height,
|
|
369
|
+
scale,
|
|
370
|
+
offset
|
|
371
|
+
]);
|
|
372
|
+
const projection = (0, import_react.useMemo)(() => new ProjectionMapper(), []);
|
|
373
|
+
(0, import_react.useEffect)(() => {
|
|
374
|
+
projection.update({
|
|
375
|
+
width,
|
|
376
|
+
height
|
|
377
|
+
}, scale, offset);
|
|
378
|
+
}, [
|
|
379
|
+
projection,
|
|
380
|
+
scale,
|
|
381
|
+
offset,
|
|
382
|
+
width,
|
|
383
|
+
height
|
|
384
|
+
]);
|
|
385
|
+
const styles = (0, import_react.useMemo)(() => {
|
|
386
|
+
return {
|
|
387
|
+
// NOTE: Order is important.
|
|
388
|
+
transform: `translate(${offset.x}px, ${offset.y}px) scale(${scale})`,
|
|
389
|
+
visibility: width && height ? "visible" : "hidden"
|
|
390
|
+
};
|
|
391
|
+
}, [
|
|
392
|
+
scale,
|
|
393
|
+
offset
|
|
394
|
+
]);
|
|
395
|
+
(0, import_react.useImperativeHandle)(forwardedRef, () => {
|
|
396
|
+
return {
|
|
397
|
+
setProjection: async (projection2) => {
|
|
398
|
+
setProjection(projection2);
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
}, [
|
|
402
|
+
ref
|
|
403
|
+
]);
|
|
404
|
+
return /* @__PURE__ */ import_react.default.createElement(CanvasContext.Provider, {
|
|
405
|
+
value: {
|
|
406
|
+
root: ref.current,
|
|
407
|
+
width,
|
|
408
|
+
height,
|
|
409
|
+
scale,
|
|
410
|
+
offset,
|
|
411
|
+
styles,
|
|
412
|
+
projection,
|
|
413
|
+
setProjection
|
|
414
|
+
}
|
|
415
|
+
}, /* @__PURE__ */ import_react.default.createElement("div", {
|
|
416
|
+
role: "none",
|
|
417
|
+
...props,
|
|
418
|
+
className: (0, import_react_ui_theme.mx)("absolute inset-0 overflow-hidden", classNames),
|
|
419
|
+
ref
|
|
420
|
+
}, children));
|
|
421
|
+
});
|
|
422
|
+
var SEC = 1e3;
|
|
423
|
+
var FPS = ({ classNames, width = 60, height = 30, bar = "bg-cyan-500" }) => {
|
|
424
|
+
const [{ fps, max, len }, dispatch] = (0, import_react5.useReducer)((state) => {
|
|
425
|
+
const currentTime = Date.now();
|
|
426
|
+
if (currentTime > state.prevTime + SEC) {
|
|
427
|
+
const nextFPS = [
|
|
428
|
+
...new Array(Math.floor((currentTime - state.prevTime - SEC) / SEC)).fill(0),
|
|
429
|
+
Math.max(1, Math.round(state.frames * SEC / (currentTime - state.prevTime)))
|
|
430
|
+
];
|
|
431
|
+
return {
|
|
432
|
+
max: Math.max(state.max, ...nextFPS),
|
|
433
|
+
len: Math.min(state.len + nextFPS.length, width),
|
|
434
|
+
fps: [
|
|
435
|
+
...state.fps,
|
|
436
|
+
...nextFPS
|
|
437
|
+
].slice(-width),
|
|
438
|
+
frames: 1,
|
|
439
|
+
prevTime: currentTime
|
|
440
|
+
};
|
|
441
|
+
} else {
|
|
442
|
+
return {
|
|
443
|
+
...state,
|
|
444
|
+
frames: state.frames + 1
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
}, {
|
|
448
|
+
max: 0,
|
|
449
|
+
len: 0,
|
|
450
|
+
fps: [],
|
|
451
|
+
frames: 0,
|
|
452
|
+
prevTime: Date.now()
|
|
453
|
+
});
|
|
454
|
+
const requestRef = (0, import_react5.useRef)();
|
|
455
|
+
const tick = () => {
|
|
456
|
+
dispatch();
|
|
457
|
+
requestRef.current = requestAnimationFrame(tick);
|
|
458
|
+
};
|
|
459
|
+
(0, import_react5.useEffect)(() => {
|
|
460
|
+
requestRef.current = requestAnimationFrame(tick);
|
|
461
|
+
return () => {
|
|
462
|
+
if (requestRef.current) {
|
|
463
|
+
cancelAnimationFrame(requestRef.current);
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
}, []);
|
|
467
|
+
return /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
468
|
+
style: {
|
|
469
|
+
width: width + 6
|
|
470
|
+
},
|
|
471
|
+
className: (0, import_react_ui_theme3.mx)("relative flex flex-col p-0.5", "bg-base text-xs text-subdued font-thin pointer-events-none border border-separator", classNames)
|
|
472
|
+
}, /* @__PURE__ */ import_react5.default.createElement("div", null, fps[len - 1], " FPS"), /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
473
|
+
className: "w-full relative",
|
|
474
|
+
style: {
|
|
475
|
+
height
|
|
476
|
+
}
|
|
477
|
+
}, fps.map((frame, i) => /* @__PURE__ */ import_react5.default.createElement("div", {
|
|
478
|
+
key: `fps-${i}`,
|
|
479
|
+
className: bar,
|
|
480
|
+
style: {
|
|
481
|
+
position: "absolute",
|
|
482
|
+
bottom: 0,
|
|
483
|
+
right: `${len - 1 - i}px`,
|
|
484
|
+
height: `${height * frame / max}px`,
|
|
485
|
+
width: 1
|
|
486
|
+
}
|
|
487
|
+
}))));
|
|
488
|
+
};
|
|
489
|
+
var gridRatios = [
|
|
490
|
+
1 / 4,
|
|
491
|
+
1,
|
|
492
|
+
4,
|
|
493
|
+
16
|
|
494
|
+
];
|
|
495
|
+
var defaultOffset2 = {
|
|
496
|
+
x: 0,
|
|
497
|
+
y: 0
|
|
498
|
+
};
|
|
499
|
+
var createId = (parent, grid) => `dx-canvas-grid-${parent}-${grid}`;
|
|
500
|
+
var Grid = /* @__PURE__ */ (0, import_react6.forwardRef)(({ id: parentId, size: gridSize, scale = 1, offset = defaultOffset2, classNames }, forwardedRef) => {
|
|
501
|
+
const grids = (0, import_react6.useMemo)(() => gridRatios.map((ratio) => ({
|
|
502
|
+
id: ratio,
|
|
503
|
+
size: ratio * gridSize * scale
|
|
504
|
+
})).filter(({ size }) => size >= gridSize && size <= 256), [
|
|
505
|
+
gridSize,
|
|
506
|
+
scale
|
|
507
|
+
]);
|
|
508
|
+
return /* @__PURE__ */ import_react6.default.createElement("svg", {
|
|
509
|
+
...testId("dx-canvas-grid"),
|
|
510
|
+
ref: forwardedRef,
|
|
511
|
+
className: (0, import_react_ui_theme4.mx)("absolute inset-0 w-full h-full pointer-events-none touch-none select-none", "stroke-neutral-500", classNames)
|
|
512
|
+
}, /* @__PURE__ */ import_react6.default.createElement("defs", null, grids.map(({ id, size }) => /* @__PURE__ */ import_react6.default.createElement(GridPattern, {
|
|
513
|
+
key: id,
|
|
514
|
+
id: createId(parentId, id),
|
|
515
|
+
offset,
|
|
516
|
+
size
|
|
517
|
+
}))), /* @__PURE__ */ import_react6.default.createElement("g", null, grids.map(({ id }, i) => /* @__PURE__ */ import_react6.default.createElement("rect", {
|
|
518
|
+
key: id,
|
|
519
|
+
opacity: 0.1 + i * 0.05,
|
|
520
|
+
fill: `url(#${createId(parentId, id)})`,
|
|
521
|
+
width: "100%",
|
|
522
|
+
height: "100%"
|
|
523
|
+
}))));
|
|
524
|
+
});
|
|
525
|
+
var Point = import_effect.S.Struct({
|
|
526
|
+
x: import_effect.S.Number,
|
|
527
|
+
y: import_effect.S.Number
|
|
528
|
+
});
|
|
529
|
+
var Dimension = import_effect.S.Struct({
|
|
530
|
+
width: import_effect.S.Number,
|
|
531
|
+
height: import_effect.S.Number
|
|
532
|
+
});
|
|
533
|
+
var Rect = import_effect.S.extend(Point, Dimension);
|
|
534
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
535
|
+
0 && (module.exports = {
|
|
536
|
+
Arrow,
|
|
537
|
+
Canvas,
|
|
538
|
+
CanvasContext,
|
|
539
|
+
DATA_TEST_ID,
|
|
540
|
+
Dimension,
|
|
541
|
+
FPS,
|
|
542
|
+
Grid,
|
|
543
|
+
GridPattern,
|
|
544
|
+
Marker,
|
|
545
|
+
Markers,
|
|
546
|
+
Point,
|
|
547
|
+
ProjectionMapper,
|
|
548
|
+
Rect,
|
|
549
|
+
createPath,
|
|
550
|
+
defaultOffset,
|
|
551
|
+
getRelativePoint,
|
|
552
|
+
getZoomTransform,
|
|
553
|
+
testId,
|
|
554
|
+
useProjection,
|
|
555
|
+
useWheel,
|
|
556
|
+
zoomInPlace,
|
|
557
|
+
zoomTo
|
|
558
|
+
});
|
|
559
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/Canvas/Canvas.tsx", "../../../src/hooks/projection.tsx", "../../../src/hooks/useProjection.tsx", "../../../src/hooks/useWheel.tsx", "../../../src/util/svg.tsx", "../../../src/util/util.ts", "../../../src/components/FPS.tsx", "../../../src/components/Grid/Grid.tsx", "../../../src/types.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport React, {\n type CSSProperties,\n type PropsWithChildren,\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n type HTMLAttributes,\n} from 'react';\nimport { useResizeDetector } from 'react-resize-detector';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { defaultOffset, CanvasContext, ProjectionMapper, type ProjectionState } from '../../hooks';\n\nexport interface CanvasController {\n setProjection(projection: ProjectionState): Promise<void>;\n}\n\nexport type CanvasProps = ThemedClassName<PropsWithChildren<Partial<ProjectionState> & HTMLAttributes<HTMLDivElement>>>;\n\n/**\n * Root canvas component.\n * Manages CSS projection.\n */\nexport const Canvas = forwardRef<CanvasController, CanvasProps>(\n ({ children, classNames, scale: _scale = 1, offset: _offset = defaultOffset, ...props }, forwardedRef) => {\n // Size.\n const { ref, width = 0, height = 0 } = useResizeDetector();\n\n // Projection.\n const [{ scale, offset }, setProjection] = useState<ProjectionState>({ scale: _scale, offset: _offset });\n useEffect(() => {\n if (width && height && offset === defaultOffset) {\n setProjection({ scale, offset: { x: width / 2, y: height / 2 } });\n }\n }, [width, height, scale, offset]);\n\n // Projection mapper.\n const projection = useMemo(() => new ProjectionMapper(), []);\n useEffect(() => {\n projection.update({ width, height }, scale, offset);\n }, [projection, scale, offset, width, height]);\n\n // CSS transforms.\n const styles = useMemo<CSSProperties>(() => {\n return {\n // NOTE: Order is important.\n transform: `translate(${offset.x}px, ${offset.y}px) scale(${scale})`,\n visibility: width && height ? 'visible' : 'hidden',\n };\n }, [scale, offset]);\n\n // Controller.\n useImperativeHandle(\n forwardedRef,\n () => {\n return {\n setProjection: async (projection: ProjectionState) => {\n setProjection(projection);\n },\n };\n },\n [ref],\n );\n\n return (\n <CanvasContext.Provider\n value={{ root: ref.current, width, height, scale, offset, styles, projection, setProjection }}\n >\n <div role='none' {...props} className={mx('absolute inset-0 overflow-hidden', classNames)} ref={ref}>\n {children}\n </div>\n </CanvasContext.Provider>\n );\n },\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport * as d3 from 'd3';\nimport {\n type Matrix,\n applyToPoints,\n compose,\n inverse,\n translate as translateMatrix,\n identity,\n scale as scaleMatrix,\n} from 'transformation-matrix';\n\nimport { type Point, type Dimension } from '../types';\n\nexport const defaultOffset: Point = { x: 0, y: 0 };\n\n// TODO(burdon): Rotation also?\nexport type ProjectionState = {\n scale: number;\n offset: Point;\n};\n\n// TODO(burdon): Tradeoff between stable ProjectionMapping object that can be used with live values within a closure,\n// vs. a reactive object that can trigger updates?\n\n/**\n * Maps between screen and model coordinates.\n */\nexport interface Projection {\n get bounds(): Dimension;\n get scale(): number;\n get offset(): Point;\n\n /**\n * Maps the model space to the screen offset (from the top-left of the element).\n */\n toScreen(points: Point[]): Point[];\n\n /**\n * Maps the pointer coordinate (from the top-left of the element) to the model space.\n */\n toModel(points: Point[]): Point[];\n}\n\nexport class ProjectionMapper implements Projection {\n private _bounds: Dimension = { width: 0, height: 0 };\n private _scale: number = 1;\n private _offset: Point = defaultOffset;\n private _toScreen: Matrix = identity();\n private _toModel: Matrix = identity();\n\n constructor(bounds?: Dimension, scale?: number, offset?: Point) {\n if (bounds && scale && offset) {\n this.update(bounds, scale, offset);\n }\n }\n\n update(bounds: Dimension, scale: number, offset: Point) {\n this._bounds = bounds;\n this._scale = scale;\n this._offset = offset;\n this._toScreen = compose(translateMatrix(this._offset.x, this._offset.y), scaleMatrix(this._scale));\n this._toModel = inverse(this._toScreen);\n return this;\n }\n\n get bounds() {\n return this._bounds;\n }\n\n get scale() {\n return this._scale;\n }\n\n get offset() {\n return this._offset;\n }\n\n toScreen(points: Point[]): Point[] {\n return applyToPoints(this._toScreen, points);\n }\n\n toModel(points: Point[]): Point[] {\n return applyToPoints(this._toModel, points);\n }\n}\n\n/**\n * Maintain position while zooming.\n */\nexport const getZoomTransform = ({\n scale,\n offset,\n pos,\n newScale,\n}: ProjectionState & { pos: Point; newScale: number }): ProjectionState => {\n return {\n scale: newScale,\n offset: {\n x: pos.x - (pos.x - offset.x) * (newScale / scale),\n y: pos.y - (pos.y - offset.y) * (newScale / scale),\n },\n };\n};\n\n/**\n * Zoom while keeping the specified position in place.\n */\n// TODO(burdon): Convert to object.\nexport const zoomInPlace = (\n setTransform: (state: ProjectionState) => void,\n pos: Point,\n offset: Point,\n current: number,\n next: number,\n delay = 200,\n) => {\n const is = d3.interpolate(current, next);\n d3.transition()\n .ease(d3.easeSinOut)\n .duration(delay)\n .tween('zoom', () => (t) => {\n const newScale = is(t);\n setTransform(getZoomTransform({ scale: current, newScale, offset, pos }));\n });\n};\n\n/**\n * Zoom to new scale and position.\n */\n// TODO(burdon): Convert to object.\nexport const zoomTo = (\n setTransform: (state: ProjectionState) => void,\n current: ProjectionState,\n next: ProjectionState,\n delay = 200,\n) => {\n const is = d3.interpolateObject({ scale: current.scale, ...current.offset }, { scale: next.scale, ...next.offset });\n d3.transition()\n .ease(d3.easeSinOut)\n .duration(delay)\n .tween('zoom', () => (t) => {\n const { scale, x, y } = is(t);\n setTransform({ scale, offset: { x, y } });\n });\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type CSSProperties, type Dispatch, type SetStateAction, createContext, useContext } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type Projection, type ProjectionState } from './projection';\n\nexport type CanvasContext = ProjectionState & {\n root: HTMLDivElement;\n width: number;\n height: number;\n styles: CSSProperties;\n projection: Projection;\n setProjection: Dispatch<SetStateAction<ProjectionState>>;\n};\n\n/**\n * @internal\n */\n// TODO(burdon): Use radix?\nexport const CanvasContext = createContext<CanvasContext | null>(null);\n\nexport const useProjection = (): CanvasContext => {\n return useContext(CanvasContext) ?? raise(new Error('Missing CanvasContext'));\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { bindAll } from 'bind-event-listener';\nimport { type Dispatch, type SetStateAction, useEffect } from 'react';\n\nimport { getZoomTransform, type ProjectionState } from './projection';\nimport { getRelativePoint } from '../util';\n\n/**\n * Handle wheel events to update the transform state (zoom and offset).\n */\nexport const useWheel = (el: HTMLDivElement | null, setProjection: Dispatch<SetStateAction<ProjectionState>>) => {\n useEffect(() => {\n if (!el) {\n return;\n }\n\n return bindAll(el, [\n {\n type: 'wheel',\n options: { capture: true, passive: false },\n listener: (ev: WheelEvent) => {\n ev.preventDefault();\n\n // Zoom or pan.\n if (ev.ctrlKey) {\n if (!el) {\n return;\n }\n\n // Keep centered while zooming.\n setProjection(({ scale, offset }) => {\n const pos = getRelativePoint(el, ev);\n const scaleSensitivity = 0.01;\n const newScale = scale * Math.exp(-ev.deltaY * scaleSensitivity);\n return getZoomTransform({ scale, offset, newScale, pos });\n });\n } else {\n setProjection(({ scale, offset: { x, y } }) => {\n return {\n scale,\n offset: {\n x: x - ev.deltaX,\n y: y - ev.deltaY,\n },\n };\n });\n }\n },\n },\n ]);\n }, [el, setProjection]);\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { type PropsWithChildren, type SVGProps } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { type Dimension, type Point } from '../types';\n\n// Refs\n// - https://airbnb.io/visx/gallery\n// - https://github.com/tldraw/tldraw/blob/main/packages/editor/src/lib/primitives/Vec.ts\n\nexport const createPath = (points: Point[], join = false) => {\n return ['M', points.map(({ x, y }) => `${x},${y}`).join(' L '), join ? 'Z' : ''].join(' ');\n};\n\n/**\n * https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths\n * NOTE: Leave space around shape for line width.\n */\nexport const Markers = ({ id = 'dx-marker', classNames }: ThemedClassName<{ id?: string }>) => {\n return (\n <>\n <Arrow id={`${id}-arrow-start`} dir='start' classNames={classNames} />\n <Arrow id={`${id}-arrow-end`} dir='end' classNames={classNames} />\n <Arrow id={`${id}-triangle-start`} dir='start' closed classNames={classNames} />\n <Arrow id={`${id}-triangle-end`} dir='end' closed classNames={classNames} />\n <Marker id={`${id}-circle`} pos={{ x: 6, y: 6 }} size={{ width: 12, height: 12 }}>\n <circle cx={6} cy={6} r={5} stroke={'context-stroke'} className={mx(classNames)} />\n </Marker>\n </>\n );\n};\n\nexport type MarkerProps = SVGProps<SVGMarkerElement> &\n PropsWithChildren<\n ThemedClassName<{\n id: string;\n pos: Point;\n size: Dimension;\n fill?: boolean;\n }>\n >;\n\n/**\n * https://www.w3.org/TR/SVG2/painting.html#Markers\n */\nexport const Marker = ({\n id,\n className,\n children,\n pos: { x: refX, y: refY },\n size: { width: markerWidth, height: markerHeight },\n fill,\n ...rest\n}: MarkerProps) => (\n <marker\n id={id}\n className={className}\n {...{\n refX,\n refY,\n markerWidth,\n markerHeight,\n markerUnits: 'strokeWidth',\n orient: 'auto',\n ...rest,\n }}\n >\n {children}\n </marker>\n);\n\nexport const Arrow = ({\n classNames,\n id,\n size = 16,\n dir = 'end',\n closed = false,\n}: ThemedClassName<{ id: string; size?: number; dir?: 'start' | 'end'; closed?: boolean }>) => (\n <Marker\n id={id}\n size={{ width: size, height: size }}\n pos={dir === 'end' ? { x: size, y: size / 2 } : { x: 0, y: size / 2 }}\n >\n <path\n fill={closed ? undefined : 'none'}\n stroke={'context-stroke'}\n className={mx(classNames)}\n d={createPath(\n dir === 'end'\n ? [\n { x: 1, y: 1 },\n { x: size, y: size / 2 },\n { x: 1, y: size - 1 },\n ]\n : [\n { x: size - 1, y: 1 },\n { x: 0, y: size / 2 },\n { x: size - 1, y: size - 1 },\n ],\n closed,\n )}\n />\n </Marker>\n);\n\nexport const GridPattern = ({\n classNames,\n id,\n size,\n offset,\n}: ThemedClassName<{ id: string; size: number; offset: Point }>) => (\n <pattern\n id={id}\n x={(size / 2 + offset.x) % size}\n y={(size / 2 + offset.y) % size}\n width={size}\n height={size}\n patternUnits='userSpaceOnUse'\n >\n {/* TODO(burdon): vars. */}\n <g className={mx(classNames)}>\n <line x1={0} y1={size / 2} x2={size} y2={size / 2} />\n <line x1={size / 2} y1={0} x2={size / 2} y2={size} />\n </g>\n </pattern>\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nlet logged = false;\n\n/**\n * Get the relative point of the cursor.\n * NOTE: ev.offset returns the position relative to the target.\n */\nexport const getRelativePoint = (el: HTMLElement, ev: MouseEvent) => {\n const rect = el.getBoundingClientRect();\n return { x: ev.clientX - rect.x, y: ev.clientY - rect.top };\n};\n\n/**\n *\n */\n// TODO(burdon): Factor out.\nexport const testId = <ID = string>(id: ID, inspect = false) => {\n if (inspect) {\n if (!logged) {\n // eslint-disable-next-line no-console\n console.log('Open storybook in expanded window;\\nthen run INSPECT()');\n logged = true;\n }\n\n (window as any).INSPECT = () => {\n const el = document.querySelector(`[data-test-id=\"${id}\"]`);\n (window as any).inspect(el);\n // eslint-disable-next-line no-console\n console.log(el);\n };\n }\n\n return { [DATA_TEST_ID]: id };\n};\n\nexport const DATA_TEST_ID = 'data-test-id';\n", "//\n// Copyright 2024 DXOS.org\n// Adapted from: https://github.com/smplrspace/react-fps-stats\n//\n\nimport React, { useEffect, useReducer, useRef } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nexport type FPSProps = ThemedClassName<{\n width?: number;\n height?: number;\n bar?: string;\n}>;\n\ntype State = {\n max: number;\n len: number;\n fps: number[];\n frames: number;\n prevTime: number;\n};\n\nconst SEC = 1_000;\n\nexport const FPS = ({ classNames, width = 60, height = 30, bar = 'bg-cyan-500' }: FPSProps) => {\n const [{ fps, max, len }, dispatch] = useReducer(\n (state: State) => {\n const currentTime = Date.now();\n if (currentTime > state.prevTime + SEC) {\n const nextFPS = [\n ...new Array(Math.floor((currentTime - state.prevTime - SEC) / SEC)).fill(0),\n Math.max(1, Math.round((state.frames * SEC) / (currentTime - state.prevTime))),\n ];\n return {\n max: Math.max(state.max, ...nextFPS),\n len: Math.min(state.len + nextFPS.length, width),\n fps: [...state.fps, ...nextFPS].slice(-width),\n frames: 1,\n prevTime: currentTime,\n };\n } else {\n return { ...state, frames: state.frames + 1 };\n }\n },\n {\n max: 0,\n len: 0,\n fps: [],\n frames: 0,\n prevTime: Date.now(),\n },\n );\n\n const requestRef = useRef<number>();\n const tick = () => {\n dispatch();\n requestRef.current = requestAnimationFrame(tick);\n };\n\n useEffect(() => {\n requestRef.current = requestAnimationFrame(tick);\n return () => {\n if (requestRef.current) {\n cancelAnimationFrame(requestRef.current);\n }\n };\n }, []);\n\n return (\n <div\n style={{ width: width + 6 }}\n className={mx(\n 'relative flex flex-col p-0.5',\n 'bg-base text-xs text-subdued font-thin pointer-events-none border border-separator',\n classNames,\n )}\n >\n <div>{fps[len - 1]} FPS</div>\n <div className='w-full relative' style={{ height }}>\n {fps.map((frame, i) => (\n <div\n key={`fps-${i}`}\n className={bar}\n style={{\n position: 'absolute',\n bottom: 0,\n right: `${len - 1 - i}px`,\n height: `${(height * frame) / max}px`,\n width: 1,\n }}\n />\n ))}\n </div>\n </div>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { forwardRef, useMemo } from 'react';\n\nimport { type ThemedClassName } from '@dxos/react-ui';\nimport { mx } from '@dxos/react-ui-theme';\n\nimport { type Point } from '../../types';\nimport { GridPattern, testId } from '../../util';\n\nconst gridRatios = [1 / 4, 1, 4, 16];\n\nconst defaultOffset: Point = { x: 0, y: 0 };\n\nconst createId = (parent: string, grid: number) => `dx-canvas-grid-${parent}-${grid}`;\n\nexport type GridProps = ThemedClassName<{ id: string; size: number; scale?: number; offset?: Point }>;\n\nexport const Grid = forwardRef<SVGSVGElement, GridProps>(\n ({ id: parentId, size: gridSize, scale = 1, offset = defaultOffset, classNames }, forwardedRef) => {\n const grids = useMemo(\n () =>\n gridRatios\n .map((ratio) => ({ id: ratio, size: ratio * gridSize * scale }))\n .filter(({ size }) => size >= gridSize && size <= 256),\n [gridSize, scale],\n );\n\n return (\n <svg\n {...testId('dx-canvas-grid')}\n ref={forwardedRef}\n className={mx(\n 'absolute inset-0 w-full h-full pointer-events-none touch-none select-none',\n 'stroke-neutral-500',\n classNames,\n )}\n >\n {/* NOTE: The pattern is offset so that the middle of the pattern aligns with the grid. */}\n <defs>\n {grids.map(({ id, size }) => (\n <GridPattern key={id} id={createId(parentId, id)} offset={offset} size={size} />\n ))}\n </defs>\n <g>\n {grids.map(({ id }, i) => (\n <rect\n key={id}\n opacity={0.1 + i * 0.05}\n fill={`url(#${createId(parentId, id)})`}\n width='100%'\n height='100%'\n />\n ))}\n </g>\n </svg>\n );\n },\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { S } from '@dxos/effect';\n\nexport const Point = S.Struct({ x: S.Number, y: S.Number });\nexport const Dimension = S.Struct({ width: S.Number, height: S.Number });\nexport const Rect = S.extend(Point, Dimension);\n\nexport type Point = S.Schema.Type<typeof Point>;\nexport type Dimension = S.Schema.Type<typeof Dimension>;\nexport type Rect = S.Schema.Type<typeof Rect>;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBASO;AACP,mCAAkC;AAGlC,4BAAmB;ACbnB,SAAoB;AACpB,mCAQO;ACTP,IAAAA,gBAAkG;AAElG,mBAAsB;ACFtB,iCAAwB;AACxB,IAAAA,gBAA8D;ACD9D,IAAAA,gBAA6D;AAG7D,IAAAC,yBAAmB;AEFnB,IAAAD,gBAAqD;AAGrD,IAAAC,yBAAmB;ACJnB,IAAAD,gBAA2C;AAG3C,IAAAC,yBAAmB;ACHnB,oBAAkB;APaX,IAAMC,gBAAuB;EAAEC,GAAG;EAAGC,GAAG;AAAE;AA8B1C,IAAMC,mBAAN,MAAMA;EAOXC,YAAYC,QAAoBC,OAAgBC,QAAgB;AANxDC,SAAAA,UAAqB;MAAEC,OAAO;MAAGC,QAAQ;IAAE;AAC3CC,SAAAA,SAAiB;AACjBC,SAAAA,UAAiBZ;AACjBa,SAAAA,gBAAoBC,uCAAAA;AACpBC,SAAAA,eAAmBD,uCAAAA;AAGzB,QAAIT,UAAUC,SAASC,QAAQ;AAC7B,WAAKS,OAAOX,QAAQC,OAAOC,MAAAA;IAC7B;EACF;EAEAS,OAAOX,QAAmBC,OAAeC,QAAe;AACtD,SAAKC,UAAUH;AACf,SAAKM,SAASL;AACd,SAAKM,UAAU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H,8BAAAA,QAAA,cAACuC,QAAAA;IACC6E,KAAKtH;IACLsI,SAAS,MAAMjB,IAAI;IACnBjG,MAAM,QAAQuG,SAASI,UAAU/H,EAAAA,CAAAA;IACjC5C,OAAM;IACNC,QAAO;;AAMnB,CAAA;ACrDK,IAAMkL,QAAQC,gBAAEC,OAAO;EAAE7L,GAAG4L,gBAAEE;EAAQ7L,GAAG2L,gBAAEE;AAAO,CAAA;AAClD,IAAMC,YAAYH,gBAAEC,OAAO;EAAErL,OAAOoL,gBAAEE;EAAQrL,QAAQmL,gBAAEE;AAAO,CAAA;AAC/D,IAAME,OAAOJ,gBAAEK,OAAON,OAAOI,SAAAA;",
|
|
6
|
+
"names": ["import_react", "import_react_ui_theme", "defaultOffset", "x", "y", "ProjectionMapper", "constructor", "bounds", "scale", "offset", "_bounds", "width", "height", "_scale", "_offset", "_toScreen", "identity", "_toModel", "update", "compose", "translateMatrix", "scaleMatrix", "inverse", "toScreen", "points", "applyToPoints", "toModel", "getZoomTransform", "pos", "newScale", "zoomInPlace", "setTransform", "current", "next", "delay", "is", "interpolate", "transition", "ease", "easeSinOut", "duration", "tween", "t", "zoomTo", "interpolateObject", "CanvasContext", "createContext", "useProjection", "useContext", "raise", "Error", "createPath", "join", "map", "Markers", "id", "classNames", "React", "Arrow", "dir", "closed", "Marker", "size", "circle", "cx", "cy", "r", "stroke", "className", "mx", "children", "refX", "refY", "markerWidth", "markerHeight", "fill", "rest", "marker", "markerUnits", "orient", "path", "undefined", "d", "GridPattern", "pattern", "patternUnits", "g", "line", "x1", "y1", "x2", "y2", "logged", "getRelativePoint", "el", "ev", "rect", "getBoundingClientRect", "clientX", "clientY", "top", "testId", "inspect", "console", "log", "window", "INSPECT", "document", "querySelector", "DATA_TEST_ID", "useWheel", "setProjection", "useEffect", "bindAll", "type", "options", "capture", "passive", "listener", "preventDefault", "ctrlKey", "scaleSensitivity", "Math", "exp", "deltaY", "deltaX", "Canvas", "forwardRef", "props", "forwardedRef", "ref", "useResizeDetector", "useState", "projection", "useMemo", "styles", "transform", "visibility", "useImperativeHandle", "Provider", "value", "root", "div", "role", "SEC", "FPS", "bar", "fps", "max", "len", "dispatch", "useReducer", "state", "currentTime", "Date", "now", "prevTime", "nextFPS", "Array", "floor", "round", "frames", "min", "length", "slice", "requestRef", "useRef", "tick", "requestAnimationFrame", "cancelAnimationFrame", "style", "frame", "i", "key", "position", "bottom", "right", "gridRatios", "createId", "parent", "grid", "Grid", "parentId", "gridSize", "grids", "ratio", "filter", "svg", "defs", "opacity", "Point", "S", "Struct", "Number", "Dimension", "Rect", "extend"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"packages/ui/react-ui-canvas/src/hooks/projection.tsx":{"bytes":11640,"imports":[{"path":"d3","kind":"import-statement","external":true},{"path":"transformation-matrix","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-canvas/src/hooks/useProjection.tsx":{"bytes":2104,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-canvas/src/util/svg.tsx":{"bytes":12581,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-canvas/src/util/util.ts":{"bytes":3716,"imports":[],"format":"esm"},"packages/ui/react-ui-canvas/src/util/index.ts":{"bytes":571,"imports":[{"path":"packages/ui/react-ui-canvas/src/util/svg.tsx","kind":"import-statement","original":"./svg"},{"path":"packages/ui/react-ui-canvas/src/util/util.ts","kind":"import-statement","original":"./util"}],"format":"esm"},"packages/ui/react-ui-canvas/src/hooks/useWheel.tsx":{"bytes":6037,"imports":[{"path":"bind-event-listener","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-canvas/src/hooks/projection.tsx","kind":"import-statement","original":"./projection"},{"path":"packages/ui/react-ui-canvas/src/util/index.ts","kind":"import-statement","original":"../util"}],"format":"esm"},"packages/ui/react-ui-canvas/src/hooks/index.ts":{"bytes":704,"imports":[{"path":"packages/ui/react-ui-canvas/src/hooks/projection.tsx","kind":"import-statement","original":"./projection"},{"path":"packages/ui/react-ui-canvas/src/hooks/useProjection.tsx","kind":"import-statement","original":"./useProjection"},{"path":"packages/ui/react-ui-canvas/src/hooks/useWheel.tsx","kind":"import-statement","original":"./useWheel"}],"format":"esm"},"packages/ui/react-ui-canvas/src/components/Canvas/Canvas.tsx":{"bytes":8640,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-canvas/src/hooks/index.ts","kind":"import-statement","original":"../../hooks"}],"format":"esm"},"packages/ui/react-ui-canvas/src/components/Canvas/index.ts":{"bytes":511,"imports":[{"path":"packages/ui/react-ui-canvas/src/components/Canvas/Canvas.tsx","kind":"import-statement","original":"./Canvas"}],"format":"esm"},"packages/ui/react-ui-canvas/src/components/FPS.tsx":{"bytes":9035,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-canvas/src/components/Grid/Grid.tsx":{"bytes":6244,"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"packages/ui/react-ui-canvas/src/util/index.ts","kind":"import-statement","original":"../../util"}],"format":"esm"},"packages/ui/react-ui-canvas/src/components/Grid/index.ts":{"bytes":507,"imports":[{"path":"packages/ui/react-ui-canvas/src/components/Grid/Grid.tsx","kind":"import-statement","original":"./Grid"}],"format":"esm"},"packages/ui/react-ui-canvas/src/components/index.ts":{"bytes":663,"imports":[{"path":"packages/ui/react-ui-canvas/src/components/Canvas/index.ts","kind":"import-statement","original":"./Canvas"},{"path":"packages/ui/react-ui-canvas/src/components/FPS.tsx","kind":"import-statement","original":"./FPS"},{"path":"packages/ui/react-ui-canvas/src/components/Grid/index.ts","kind":"import-statement","original":"./Grid"}],"format":"esm"},"packages/ui/react-ui-canvas/src/types.ts":{"bytes":1632,"imports":[{"path":"@dxos/effect","kind":"import-statement","external":true}],"format":"esm"},"packages/ui/react-ui-canvas/src/index.ts":{"bytes":747,"imports":[{"path":"packages/ui/react-ui-canvas/src/components/index.ts","kind":"import-statement","original":"./components"},{"path":"packages/ui/react-ui-canvas/src/hooks/index.ts","kind":"import-statement","original":"./hooks"},{"path":"packages/ui/react-ui-canvas/src/types.ts","kind":"import-statement","original":"./types"},{"path":"packages/ui/react-ui-canvas/src/util/index.ts","kind":"import-statement","original":"./util"}],"format":"esm"}},"outputs":{"packages/ui/react-ui-canvas/dist/lib/node/index.cjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":30793},"packages/ui/react-ui-canvas/dist/lib/node/index.cjs":{"imports":[{"path":"react","kind":"import-statement","external":true},{"path":"react-resize-detector","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"d3","kind":"import-statement","external":true},{"path":"transformation-matrix","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/debug","kind":"import-statement","external":true},{"path":"bind-event-listener","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"react","kind":"import-statement","external":true},{"path":"@dxos/react-ui-theme","kind":"import-statement","external":true},{"path":"@dxos/effect","kind":"import-statement","external":true}],"exports":["Arrow","Canvas","CanvasContext","DATA_TEST_ID","Dimension","FPS","Grid","GridPattern","Marker","Markers","Point","ProjectionMapper","Rect","createPath","defaultOffset","getRelativePoint","getZoomTransform","testId","useProjection","useWheel","zoomInPlace","zoomTo"],"entryPoint":"packages/ui/react-ui-canvas/src/index.ts","inputs":{"packages/ui/react-ui-canvas/src/components/Canvas/Canvas.tsx":{"bytesInOutput":1857},"packages/ui/react-ui-canvas/src/hooks/projection.tsx":{"bytesInOutput":2111},"packages/ui/react-ui-canvas/src/hooks/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-canvas/src/hooks/useProjection.tsx":{"bytesInOutput":257},"packages/ui/react-ui-canvas/src/hooks/useWheel.tsx":{"bytesInOutput":1208},"packages/ui/react-ui-canvas/src/util/svg.tsx":{"bytesInOutput":2736},"packages/ui/react-ui-canvas/src/util/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-canvas/src/util/util.ts":{"bytesInOutput":589},"packages/ui/react-ui-canvas/src/components/Canvas/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-canvas/src/components/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-canvas/src/components/FPS.tsx":{"bytesInOutput":2064},"packages/ui/react-ui-canvas/src/components/Grid/Grid.tsx":{"bytesInOutput":1339},"packages/ui/react-ui-canvas/src/components/Grid/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-canvas/src/index.ts":{"bytesInOutput":0},"packages/ui/react-ui-canvas/src/types.ts":{"bytesInOutput":198}},"bytes":13308}}}
|