graphics-debug 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +0 -1
- package/dist/cli/cli.js.map +1 -1
- package/dist/lib/react.d.ts +8 -0
- package/dist/lib/react.js +508 -0
- package/dist/lib/react.js.map +1 -0
- package/dist/lib/types.d.ts +10 -0
- package/package.json +22 -4
package/dist/cli/cli.js
CHANGED
package/dist/cli/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../cli/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\"\nimport { readFileSync } from \"node:fs\"\nimport { writeFileSync } from \"node:fs\"\nimport {\n getSvgsFromLogString,\n getHtmlFromLogString,\n getGraphicsObjectsFromLogString,\n} from \"../lib\"\n\nasync function getInput(): Promise<string> {\n // Check if there's data being piped in\n if (process.stdin.isTTY && process.stderr.isTTY) {\n console.error(\n \"Error: No input provided. Pipe in content with graphics objects.\",\n )\n process.exit(1)\n }\n\n const chunks = []\n\n // Read from stdin if available\n if (!process.stdin.isTTY) {\n for await (const chunk of process.stdin) {\n chunks.push(chunk)\n }\n }\n\n return chunks.join(\"\")\n}\n\nasync function main() {\n const { values } = parseArgs({\n options: {\n html: { type: \"boolean\" },\n url: { type: \"boolean\" },\n help: { type: \"boolean\" },\n },\n })\n\n if (values.help) {\n console.log(`\nUsage: graphics-debug [options]\n\nOptions:\n --html Output a single HTML file with all graphics\n --url Print a url to view the graphics in a browser\n --help Show this help message\n\nExamples:\n cat debug.log | graphics-debug\n echo '{ graphics: { points: [{x: 0, y: 0}] } }' | graphics-debug --html\n `)\n process.exit(0)\n }\n\n const input = await getInput()\n\n if (values.html) {\n const html = getHtmlFromLogString(input)\n writeFileSync(\"graphicsdebug.debug.html\", html)\n console.log('Wrote to \"graphicsdebug.debug.html\"')\n } else if (values.url) {\n const graphicsObjects = getGraphicsObjectsFromLogString(input)\n if (graphicsObjects.length === 0) {\n console.error(\"No graphics objects found in input\")\n process.exit(0)\n }\n\n const { url } = await fetch(\"https://gdstore.seve.workers.dev/store\", {\n method: \"POST\",\n body: JSON.stringify({\n graphicsObjects: getGraphicsObjectsFromLogString(input),\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n }).then((res) => res.json())\n\n const token = url.split(\"/get/\").pop()\n\n console.log(`https://graphicsdebug.com/t/${token}`)\n } else {\n const svgs = getSvgsFromLogString(input)\n svgs.forEach((svg, i) => {\n const filename = `${svg.title.toLowerCase().replace(/\\s+/g, \"-\")}-${i + 1}.debug.svg`\n writeFileSync(filename, svg.svg)\n console.log(`Wrote to \"${filename}\"`)\n })\n }\n}\n\nmain().catch((err) => {\n console.error(\"Error:\", err)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;AACA,SAAS,iBAAiB;
|
|
1
|
+
{"version":3,"sources":["../../cli/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { parseArgs } from \"node:util\"\nimport { readFileSync } from \"node:fs\"\nimport { writeFileSync } from \"node:fs\"\nimport {\n getSvgsFromLogString,\n getHtmlFromLogString,\n getGraphicsObjectsFromLogString,\n} from \"../lib\"\n\nasync function getInput(): Promise<string> {\n // Check if there's data being piped in\n if (process.stdin.isTTY && process.stderr.isTTY) {\n console.error(\n \"Error: No input provided. Pipe in content with graphics objects.\",\n )\n process.exit(1)\n }\n\n const chunks = []\n\n // Read from stdin if available\n if (!process.stdin.isTTY) {\n for await (const chunk of process.stdin) {\n chunks.push(chunk)\n }\n }\n\n return chunks.join(\"\")\n}\n\nasync function main() {\n const { values } = parseArgs({\n options: {\n html: { type: \"boolean\" },\n url: { type: \"boolean\" },\n help: { type: \"boolean\" },\n },\n })\n\n if (values.help) {\n console.log(`\nUsage: graphics-debug [options]\n\nOptions:\n --html Output a single HTML file with all graphics\n --url Print a url to view the graphics in a browser\n --help Show this help message\n\nExamples:\n cat debug.log | graphics-debug\n echo '{ graphics: { points: [{x: 0, y: 0}] } }' | graphics-debug --html\n `)\n process.exit(0)\n }\n\n const input = await getInput()\n\n if (values.html) {\n const html = getHtmlFromLogString(input)\n writeFileSync(\"graphicsdebug.debug.html\", html)\n console.log('Wrote to \"graphicsdebug.debug.html\"')\n } else if (values.url) {\n const graphicsObjects = getGraphicsObjectsFromLogString(input)\n if (graphicsObjects.length === 0) {\n console.error(\"No graphics objects found in input\")\n process.exit(0)\n }\n\n const { url } = await fetch(\"https://gdstore.seve.workers.dev/store\", {\n method: \"POST\",\n body: JSON.stringify({\n graphicsObjects: getGraphicsObjectsFromLogString(input),\n }),\n headers: {\n \"Content-Type\": \"application/json\",\n },\n }).then((res) => res.json())\n\n const token = url.split(\"/get/\").pop()\n\n console.log(`https://graphicsdebug.com/t/${token}`)\n } else {\n const svgs = getSvgsFromLogString(input)\n svgs.forEach((svg, i) => {\n const filename = `${svg.title.toLowerCase().replace(/\\s+/g, \"-\")}-${i + 1}.debug.svg`\n writeFileSync(filename, svg.svg)\n console.log(`Wrote to \"${filename}\"`)\n })\n }\n}\n\nmain().catch((err) => {\n console.error(\"Error:\", err)\n process.exit(1)\n})\n"],"mappings":";;;;;;;;;;;AACA,SAAS,iBAAiB;AAE1B,SAAS,qBAAqB;AAO9B,eAAe,WAA4B;AAEzC,MAAI,QAAQ,MAAM,SAAS,QAAQ,OAAO,OAAO;AAC/C,YAAQ;AAAA,MACN;AAAA,IACF;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,SAAS,CAAC;AAGhB,MAAI,CAAC,QAAQ,MAAM,OAAO;AACxB,qBAAiB,SAAS,QAAQ,OAAO;AACvC,aAAO,KAAK,KAAK;AAAA,IACnB;AAAA,EACF;AAEA,SAAO,OAAO,KAAK,EAAE;AACvB;AAEA,eAAe,OAAO;AACpB,QAAM,EAAE,OAAO,IAAI,UAAU;AAAA,IAC3B,SAAS;AAAA,MACP,MAAM,EAAE,MAAM,UAAU;AAAA,MACxB,KAAK,EAAE,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GAAG;AAC3B,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
// site/components/InteractiveGraphics/InteractiveGraphics.tsx
|
|
2
|
+
import {
|
|
3
|
+
compose,
|
|
4
|
+
scale,
|
|
5
|
+
translate
|
|
6
|
+
} from "transformation-matrix";
|
|
7
|
+
import { useMemo, useState as useState4 } from "react";
|
|
8
|
+
import useMouseMatrixTransform from "use-mouse-matrix-transform";
|
|
9
|
+
import { SuperGrid } from "react-supergrid";
|
|
10
|
+
import useResizeObserver from "@react-hook/resize-observer";
|
|
11
|
+
|
|
12
|
+
// site/components/InteractiveGraphics/Line.tsx
|
|
13
|
+
import { applyToPoint } from "transformation-matrix";
|
|
14
|
+
import { lighten } from "polished";
|
|
15
|
+
import { useState } from "react";
|
|
16
|
+
|
|
17
|
+
// site/components/InteractiveGraphics/Tooltip.tsx
|
|
18
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
|
+
var Tooltip = ({ text }) => {
|
|
20
|
+
return /* @__PURE__ */ jsx(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
style: {
|
|
24
|
+
background: "white",
|
|
25
|
+
border: "1px solid #ccc",
|
|
26
|
+
boxShadow: "0 0 10px 0 rgba(0, 0, 0, 0.1)",
|
|
27
|
+
borderRadius: "4px",
|
|
28
|
+
padding: "4px 8px",
|
|
29
|
+
fontSize: "12px",
|
|
30
|
+
minWidth: "150px",
|
|
31
|
+
maxWidth: "300px",
|
|
32
|
+
overflow: "hidden",
|
|
33
|
+
textOverflow: "ellipsis",
|
|
34
|
+
whiteSpace: "pre-wrap"
|
|
35
|
+
},
|
|
36
|
+
children: text
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// site/utils/distToLineSegment.ts
|
|
42
|
+
var distToLineSegment = (px, py, x1, y1, x2, y2) => {
|
|
43
|
+
const A = px - x1;
|
|
44
|
+
const B = py - y1;
|
|
45
|
+
const C = x2 - x1;
|
|
46
|
+
const D = y2 - y1;
|
|
47
|
+
const dot = A * C + B * D;
|
|
48
|
+
const lenSq = C * C + D * D;
|
|
49
|
+
let param = -1;
|
|
50
|
+
if (lenSq !== 0) param = dot / lenSq;
|
|
51
|
+
let xx = 0;
|
|
52
|
+
let yy = 0;
|
|
53
|
+
if (param < 0) {
|
|
54
|
+
xx = x1;
|
|
55
|
+
yy = y1;
|
|
56
|
+
} else if (param > 1) {
|
|
57
|
+
xx = x2;
|
|
58
|
+
yy = y2;
|
|
59
|
+
} else {
|
|
60
|
+
xx = x1 + param * C;
|
|
61
|
+
yy = y1 + param * D;
|
|
62
|
+
}
|
|
63
|
+
const dx = px - xx;
|
|
64
|
+
const dy = py - yy;
|
|
65
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// site/components/InteractiveGraphics/defaultColors.ts
|
|
69
|
+
var defaultColors = [
|
|
70
|
+
"rgba(239, 68, 68, 0.8)",
|
|
71
|
+
// red-300
|
|
72
|
+
"rgba(249, 115, 22, 0.8)",
|
|
73
|
+
// orange-300
|
|
74
|
+
"rgba(245, 158, 11, 0.8)",
|
|
75
|
+
// amber-300
|
|
76
|
+
"rgba(234, 179, 8, 0.8)",
|
|
77
|
+
// yellow-300
|
|
78
|
+
"rgba(132, 204, 22, 0.8)",
|
|
79
|
+
// lime-300
|
|
80
|
+
"rgba(34, 197, 94, 0.8)",
|
|
81
|
+
// green-300
|
|
82
|
+
"rgba(16, 185, 129, 0.8)",
|
|
83
|
+
// emerald-300
|
|
84
|
+
"rgba(20, 184, 166, 0.8)",
|
|
85
|
+
// teal-300
|
|
86
|
+
"rgba(6, 182, 212, 0.8)",
|
|
87
|
+
// cyan-300
|
|
88
|
+
"rgba(14, 165, 233, 0.8)",
|
|
89
|
+
// sky-300
|
|
90
|
+
"rgba(59, 130, 246, 0.8)",
|
|
91
|
+
// blue-300
|
|
92
|
+
"rgba(99, 102, 241, 0.8)",
|
|
93
|
+
// indigo-300
|
|
94
|
+
"rgba(139, 92, 246, 0.8)",
|
|
95
|
+
// violet-300
|
|
96
|
+
"rgba(168, 85, 247, 0.8)",
|
|
97
|
+
// purple-300
|
|
98
|
+
"rgba(217, 70, 239, 0.8)",
|
|
99
|
+
// fuchsia-300
|
|
100
|
+
"rgba(236, 72, 153, 0.8)",
|
|
101
|
+
// pink-300
|
|
102
|
+
"rgba(249, 168, 212, 0.8)",
|
|
103
|
+
// rose-300
|
|
104
|
+
"rgba(161, 161, 170, 0.8)"
|
|
105
|
+
// zinc-300
|
|
106
|
+
];
|
|
107
|
+
|
|
108
|
+
// site/components/InteractiveGraphics/Line.tsx
|
|
109
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
110
|
+
var Line = ({
|
|
111
|
+
line,
|
|
112
|
+
index,
|
|
113
|
+
interactiveState
|
|
114
|
+
}) => {
|
|
115
|
+
const { activeLayers, activeStep, realToScreen } = interactiveState;
|
|
116
|
+
const {
|
|
117
|
+
points,
|
|
118
|
+
layer,
|
|
119
|
+
step,
|
|
120
|
+
strokeColor,
|
|
121
|
+
strokeWidth = 1 / realToScreen.a
|
|
122
|
+
} = line;
|
|
123
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
124
|
+
const [mousePos, setMousePos] = useState({ x: 0, y: 0 });
|
|
125
|
+
const screenPoints = points.map((p) => applyToPoint(realToScreen, p));
|
|
126
|
+
const handleMouseMove = (e) => {
|
|
127
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
128
|
+
const mouseX = e.clientX - rect.left;
|
|
129
|
+
const mouseY = e.clientY - rect.top;
|
|
130
|
+
const hoverThreshold = 10;
|
|
131
|
+
setMousePos({ x: mouseX, y: mouseY });
|
|
132
|
+
let isNearLine = false;
|
|
133
|
+
for (let i = 0; i < screenPoints.length - 1; i++) {
|
|
134
|
+
const dist = distToLineSegment(
|
|
135
|
+
mouseX,
|
|
136
|
+
mouseY,
|
|
137
|
+
screenPoints[i].x,
|
|
138
|
+
screenPoints[i].y,
|
|
139
|
+
screenPoints[i + 1].x,
|
|
140
|
+
screenPoints[i + 1].y
|
|
141
|
+
);
|
|
142
|
+
if (dist < hoverThreshold) {
|
|
143
|
+
isNearLine = true;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
setIsHovered(isNearLine);
|
|
148
|
+
};
|
|
149
|
+
const baseColor = strokeColor ?? defaultColors[index % defaultColors.length];
|
|
150
|
+
return /* @__PURE__ */ jsxs(
|
|
151
|
+
"svg",
|
|
152
|
+
{
|
|
153
|
+
style: {
|
|
154
|
+
position: "absolute",
|
|
155
|
+
top: 0,
|
|
156
|
+
left: 0,
|
|
157
|
+
right: 0,
|
|
158
|
+
bottom: 0
|
|
159
|
+
},
|
|
160
|
+
onMouseMove: handleMouseMove,
|
|
161
|
+
onMouseLeave: () => setIsHovered(false),
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ jsx2(
|
|
164
|
+
"polyline",
|
|
165
|
+
{
|
|
166
|
+
points: screenPoints.map((p) => `${p.x},${p.y}`).join(" "),
|
|
167
|
+
stroke: isHovered ? lighten(0.2, baseColor) : baseColor,
|
|
168
|
+
strokeWidth: strokeWidth * realToScreen.a
|
|
169
|
+
}
|
|
170
|
+
),
|
|
171
|
+
isHovered && line.label && /* @__PURE__ */ jsx2(
|
|
172
|
+
"foreignObject",
|
|
173
|
+
{
|
|
174
|
+
x: mousePos.x,
|
|
175
|
+
y: mousePos.y - 40,
|
|
176
|
+
width: 300,
|
|
177
|
+
height: 40,
|
|
178
|
+
children: /* @__PURE__ */ jsx2(Tooltip, { text: line.label })
|
|
179
|
+
}
|
|
180
|
+
)
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// site/components/InteractiveGraphics/Point.tsx
|
|
187
|
+
import { applyToPoint as applyToPoint2 } from "transformation-matrix";
|
|
188
|
+
import { lighten as lighten2 } from "polished";
|
|
189
|
+
import { useState as useState2 } from "react";
|
|
190
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
191
|
+
var Point = ({
|
|
192
|
+
point,
|
|
193
|
+
interactiveState,
|
|
194
|
+
index
|
|
195
|
+
}) => {
|
|
196
|
+
const { color, label, layer, step } = point;
|
|
197
|
+
const { activeLayers, activeStep, realToScreen } = interactiveState;
|
|
198
|
+
const [isHovered, setIsHovered] = useState2(false);
|
|
199
|
+
const screenPoint = applyToPoint2(realToScreen, point);
|
|
200
|
+
const size = 10;
|
|
201
|
+
return /* @__PURE__ */ jsx3(
|
|
202
|
+
"div",
|
|
203
|
+
{
|
|
204
|
+
style: {
|
|
205
|
+
position: "absolute",
|
|
206
|
+
left: screenPoint.x - size / 2,
|
|
207
|
+
top: screenPoint.y - size / 2,
|
|
208
|
+
width: size,
|
|
209
|
+
height: size,
|
|
210
|
+
borderRadius: "50%",
|
|
211
|
+
border: `2px solid ${isHovered ? lighten2(0.2, color ?? defaultColors[index % defaultColors.length]) : color ?? defaultColors[index % defaultColors.length]}`,
|
|
212
|
+
cursor: "pointer",
|
|
213
|
+
transition: "border-color 0.2s"
|
|
214
|
+
},
|
|
215
|
+
onMouseEnter: () => setIsHovered(true),
|
|
216
|
+
onMouseLeave: () => setIsHovered(false),
|
|
217
|
+
children: isHovered && /* @__PURE__ */ jsx3(
|
|
218
|
+
"div",
|
|
219
|
+
{
|
|
220
|
+
style: {
|
|
221
|
+
position: "absolute",
|
|
222
|
+
bottom: "100%",
|
|
223
|
+
left: "50%",
|
|
224
|
+
transform: "translateX(-50%)",
|
|
225
|
+
marginBottom: 8
|
|
226
|
+
},
|
|
227
|
+
children: /* @__PURE__ */ jsx3(
|
|
228
|
+
Tooltip,
|
|
229
|
+
{
|
|
230
|
+
text: `${label ? `${label}
|
|
231
|
+
` : ""}x: ${point.x.toFixed(2)}, y: ${point.y.toFixed(2)}`
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// site/components/InteractiveGraphics/Rect.tsx
|
|
241
|
+
import { applyToPoint as applyToPoint3 } from "transformation-matrix";
|
|
242
|
+
import { lighten as lighten3 } from "polished";
|
|
243
|
+
import { useState as useState3 } from "react";
|
|
244
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
245
|
+
var Rect = ({
|
|
246
|
+
rect,
|
|
247
|
+
interactiveState,
|
|
248
|
+
index
|
|
249
|
+
}) => {
|
|
250
|
+
const defaultColor = defaultColors[index % defaultColors.length];
|
|
251
|
+
const { center, width, height, fill, stroke, layer, step } = rect;
|
|
252
|
+
const { activeLayers, activeStep, realToScreen } = interactiveState;
|
|
253
|
+
const [isHovered, setIsHovered] = useState3(false);
|
|
254
|
+
const screenCenter = applyToPoint3(realToScreen, center);
|
|
255
|
+
const screenWidth = width * realToScreen.a;
|
|
256
|
+
const screenHeight = height * Math.abs(realToScreen.d);
|
|
257
|
+
const hasStrokeOrFill = fill !== void 0 || stroke !== void 0;
|
|
258
|
+
let backgroundColor = hasStrokeOrFill ? fill || "transparent" : defaultColor;
|
|
259
|
+
if (isHovered) {
|
|
260
|
+
backgroundColor = lighten3(0.2, backgroundColor);
|
|
261
|
+
}
|
|
262
|
+
return /* @__PURE__ */ jsx4(
|
|
263
|
+
"div",
|
|
264
|
+
{
|
|
265
|
+
style: {
|
|
266
|
+
position: "absolute",
|
|
267
|
+
left: screenCenter.x - screenWidth / 2,
|
|
268
|
+
top: screenCenter.y - screenHeight / 2,
|
|
269
|
+
width: screenWidth,
|
|
270
|
+
height: screenHeight,
|
|
271
|
+
backgroundColor,
|
|
272
|
+
border: stroke ? `2px solid ${isHovered ? lighten3(0.2, stroke) : stroke}` : "none",
|
|
273
|
+
cursor: "pointer",
|
|
274
|
+
transition: "border-color 0.2s"
|
|
275
|
+
},
|
|
276
|
+
onMouseEnter: () => setIsHovered(true),
|
|
277
|
+
onMouseLeave: () => setIsHovered(false),
|
|
278
|
+
children: isHovered && rect.label && /* @__PURE__ */ jsx4(
|
|
279
|
+
"div",
|
|
280
|
+
{
|
|
281
|
+
style: {
|
|
282
|
+
position: "absolute",
|
|
283
|
+
bottom: "100%",
|
|
284
|
+
left: "50%",
|
|
285
|
+
transform: "translateX(-50%)",
|
|
286
|
+
marginBottom: 8
|
|
287
|
+
},
|
|
288
|
+
children: /* @__PURE__ */ jsx4(Tooltip, { text: rect.label })
|
|
289
|
+
}
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
// site/utils/getGraphicsBounds.ts
|
|
296
|
+
var getGraphicsBounds = (graphics) => {
|
|
297
|
+
const bounds = {
|
|
298
|
+
minX: Infinity,
|
|
299
|
+
minY: Infinity,
|
|
300
|
+
maxX: -Infinity,
|
|
301
|
+
maxY: -Infinity
|
|
302
|
+
};
|
|
303
|
+
for (const line of graphics.lines ?? []) {
|
|
304
|
+
for (const point of line.points ?? []) {
|
|
305
|
+
bounds.minX = Math.min(bounds.minX, point.x);
|
|
306
|
+
bounds.minY = Math.min(bounds.minY, point.y);
|
|
307
|
+
bounds.maxX = Math.max(bounds.maxX, point.x);
|
|
308
|
+
bounds.maxY = Math.max(bounds.maxY, point.y);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
for (const rect of graphics.rects ?? []) {
|
|
312
|
+
const { center, width, height } = rect;
|
|
313
|
+
const halfWidth = width / 2;
|
|
314
|
+
const halfHeight = height / 2;
|
|
315
|
+
bounds.minX = Math.min(bounds.minX, center.x - halfWidth);
|
|
316
|
+
bounds.minY = Math.min(bounds.minY, center.y - halfHeight);
|
|
317
|
+
bounds.maxX = Math.max(bounds.maxX, center.x + halfWidth);
|
|
318
|
+
bounds.maxY = Math.max(bounds.maxY, center.y + halfHeight);
|
|
319
|
+
}
|
|
320
|
+
for (const point of graphics.points ?? []) {
|
|
321
|
+
bounds.minX = Math.min(bounds.minX, point.x);
|
|
322
|
+
bounds.minY = Math.min(bounds.minY, point.y);
|
|
323
|
+
bounds.maxX = Math.max(bounds.maxX, point.x);
|
|
324
|
+
bounds.maxY = Math.max(bounds.maxY, point.y);
|
|
325
|
+
}
|
|
326
|
+
return bounds;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
// site/components/InteractiveGraphics/InteractiveGraphics.tsx
|
|
330
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
331
|
+
var InteractiveGraphics = ({
|
|
332
|
+
graphics
|
|
333
|
+
}) => {
|
|
334
|
+
const [activeLayers, setActiveLayers] = useState4(null);
|
|
335
|
+
const [activeStep, setActiveStep] = useState4(null);
|
|
336
|
+
const [size, setSize] = useState4({ width: 600, height: 600 });
|
|
337
|
+
const availableLayers = Array.from(
|
|
338
|
+
/* @__PURE__ */ new Set([
|
|
339
|
+
...graphics.lines?.map((l) => l.layer).filter(Boolean) ?? [],
|
|
340
|
+
...graphics.rects?.map((r) => r.layer).filter(Boolean) ?? [],
|
|
341
|
+
...graphics.points?.map((p) => p.layer).filter(Boolean) ?? []
|
|
342
|
+
])
|
|
343
|
+
);
|
|
344
|
+
const maxStep = Math.max(
|
|
345
|
+
0,
|
|
346
|
+
...graphics.lines?.map((l) => l.step).filter(Boolean) ?? [],
|
|
347
|
+
...graphics.rects?.map((r) => r.step).filter(Boolean) ?? [],
|
|
348
|
+
...graphics.points?.map((p) => p.step).filter(Boolean) ?? []
|
|
349
|
+
);
|
|
350
|
+
const graphicsBoundsWithPadding = useMemo(() => {
|
|
351
|
+
const actualBounds = getGraphicsBounds(graphics);
|
|
352
|
+
const width = actualBounds.maxX - actualBounds.minX;
|
|
353
|
+
const height = actualBounds.maxY - actualBounds.minY;
|
|
354
|
+
return {
|
|
355
|
+
minX: actualBounds.minX - width / 10,
|
|
356
|
+
minY: actualBounds.minY - height / 10,
|
|
357
|
+
maxX: actualBounds.maxX + width / 10,
|
|
358
|
+
maxY: actualBounds.maxY + height / 10
|
|
359
|
+
};
|
|
360
|
+
}, [graphics]);
|
|
361
|
+
const { transform: realToScreen, ref } = useMouseMatrixTransform({
|
|
362
|
+
initialTransform: compose(
|
|
363
|
+
translate(size.width / 2, size.height / 2),
|
|
364
|
+
scale(
|
|
365
|
+
Math.min(
|
|
366
|
+
size.width / (graphicsBoundsWithPadding.maxX - graphicsBoundsWithPadding.minX),
|
|
367
|
+
size.height / (graphicsBoundsWithPadding.maxY - graphicsBoundsWithPadding.minY)
|
|
368
|
+
),
|
|
369
|
+
-Math.min(
|
|
370
|
+
size.width / (graphicsBoundsWithPadding.maxX - graphicsBoundsWithPadding.minX),
|
|
371
|
+
size.height / (graphicsBoundsWithPadding.maxY - graphicsBoundsWithPadding.minY)
|
|
372
|
+
)
|
|
373
|
+
),
|
|
374
|
+
translate(
|
|
375
|
+
-(graphicsBoundsWithPadding.maxX + graphicsBoundsWithPadding.minX) / 2,
|
|
376
|
+
-(graphicsBoundsWithPadding.maxY + graphicsBoundsWithPadding.minY) / 2
|
|
377
|
+
)
|
|
378
|
+
)
|
|
379
|
+
});
|
|
380
|
+
useResizeObserver(ref, (entry) => {
|
|
381
|
+
setSize({
|
|
382
|
+
width: entry.contentRect.width,
|
|
383
|
+
height: entry.contentRect.height
|
|
384
|
+
});
|
|
385
|
+
});
|
|
386
|
+
const interactiveState = {
|
|
387
|
+
activeLayers,
|
|
388
|
+
activeStep,
|
|
389
|
+
realToScreen
|
|
390
|
+
};
|
|
391
|
+
const showToolbar = availableLayers.length > 1 || maxStep > 0;
|
|
392
|
+
const filterLayerAndStep = (obj) => {
|
|
393
|
+
if (activeLayers && obj.layer && !activeLayers.includes(obj.layer))
|
|
394
|
+
return false;
|
|
395
|
+
if (activeStep !== null && obj.step !== void 0 && obj.step !== activeStep)
|
|
396
|
+
return false;
|
|
397
|
+
return true;
|
|
398
|
+
};
|
|
399
|
+
return /* @__PURE__ */ jsxs2("div", { children: [
|
|
400
|
+
showToolbar && /* @__PURE__ */ jsxs2("div", { style: { margin: 8 }, children: [
|
|
401
|
+
availableLayers.length > 1 && /* @__PURE__ */ jsxs2(
|
|
402
|
+
"select",
|
|
403
|
+
{
|
|
404
|
+
value: activeLayers ? activeLayers[0] : "",
|
|
405
|
+
onChange: (e) => {
|
|
406
|
+
const value = e.target.value;
|
|
407
|
+
setActiveLayers(value === "" ? null : [value]);
|
|
408
|
+
},
|
|
409
|
+
style: { marginRight: 8 },
|
|
410
|
+
children: [
|
|
411
|
+
/* @__PURE__ */ jsx5("option", { value: "", children: "All Layers" }),
|
|
412
|
+
availableLayers.map((layer) => /* @__PURE__ */ jsx5("option", { value: layer, children: layer }, layer))
|
|
413
|
+
]
|
|
414
|
+
}
|
|
415
|
+
),
|
|
416
|
+
maxStep > 0 && /* @__PURE__ */ jsxs2(
|
|
417
|
+
"div",
|
|
418
|
+
{
|
|
419
|
+
style: { display: "inline-flex", alignItems: "center", gap: 8 },
|
|
420
|
+
children: [
|
|
421
|
+
"Step:",
|
|
422
|
+
/* @__PURE__ */ jsx5(
|
|
423
|
+
"input",
|
|
424
|
+
{
|
|
425
|
+
type: "number",
|
|
426
|
+
min: 0,
|
|
427
|
+
max: maxStep,
|
|
428
|
+
value: activeStep ?? 0,
|
|
429
|
+
onChange: (e) => {
|
|
430
|
+
const value = parseInt(e.target.value);
|
|
431
|
+
setActiveStep(Number.isNaN(value) ? null : value);
|
|
432
|
+
},
|
|
433
|
+
disabled: activeStep === null
|
|
434
|
+
}
|
|
435
|
+
),
|
|
436
|
+
/* @__PURE__ */ jsxs2("label", { children: [
|
|
437
|
+
/* @__PURE__ */ jsx5(
|
|
438
|
+
"input",
|
|
439
|
+
{
|
|
440
|
+
type: "checkbox",
|
|
441
|
+
style: { marginRight: 4 },
|
|
442
|
+
checked: activeStep !== null,
|
|
443
|
+
onChange: (e) => {
|
|
444
|
+
setActiveStep(e.target.checked ? 0 : null);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
),
|
|
448
|
+
"Filter by step"
|
|
449
|
+
] })
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
)
|
|
453
|
+
] }),
|
|
454
|
+
/* @__PURE__ */ jsxs2(
|
|
455
|
+
"div",
|
|
456
|
+
{
|
|
457
|
+
ref,
|
|
458
|
+
style: {
|
|
459
|
+
position: "relative",
|
|
460
|
+
height: 600,
|
|
461
|
+
overflow: "hidden"
|
|
462
|
+
},
|
|
463
|
+
children: [
|
|
464
|
+
graphics.lines?.filter(filterLayerAndStep)?.map((l, i) => /* @__PURE__ */ jsx5(
|
|
465
|
+
Line,
|
|
466
|
+
{
|
|
467
|
+
line: l,
|
|
468
|
+
index: i,
|
|
469
|
+
interactiveState
|
|
470
|
+
},
|
|
471
|
+
i
|
|
472
|
+
)),
|
|
473
|
+
graphics.rects?.filter(filterLayerAndStep)?.map((r, i) => /* @__PURE__ */ jsx5(
|
|
474
|
+
Rect,
|
|
475
|
+
{
|
|
476
|
+
rect: r,
|
|
477
|
+
index: i,
|
|
478
|
+
interactiveState
|
|
479
|
+
},
|
|
480
|
+
i
|
|
481
|
+
)),
|
|
482
|
+
graphics.points?.filter(filterLayerAndStep)?.map((p, i) => /* @__PURE__ */ jsx5(
|
|
483
|
+
Point,
|
|
484
|
+
{
|
|
485
|
+
point: p,
|
|
486
|
+
index: i,
|
|
487
|
+
interactiveState
|
|
488
|
+
},
|
|
489
|
+
i
|
|
490
|
+
)),
|
|
491
|
+
/* @__PURE__ */ jsx5(
|
|
492
|
+
SuperGrid,
|
|
493
|
+
{
|
|
494
|
+
stringifyCoord: (x, y) => `${x.toFixed(2)}, ${y.toFixed(2)}`,
|
|
495
|
+
width: size.width,
|
|
496
|
+
height: size.height,
|
|
497
|
+
transform: realToScreen
|
|
498
|
+
}
|
|
499
|
+
)
|
|
500
|
+
]
|
|
501
|
+
}
|
|
502
|
+
)
|
|
503
|
+
] });
|
|
504
|
+
};
|
|
505
|
+
export {
|
|
506
|
+
InteractiveGraphics
|
|
507
|
+
};
|
|
508
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../site/components/InteractiveGraphics/InteractiveGraphics.tsx","../../site/components/InteractiveGraphics/Line.tsx","../../site/components/InteractiveGraphics/Tooltip.tsx","../../site/utils/distToLineSegment.ts","../../site/components/InteractiveGraphics/defaultColors.ts","../../site/components/InteractiveGraphics/Point.tsx","../../site/components/InteractiveGraphics/Rect.tsx","../../site/utils/getGraphicsBounds.ts"],"sourcesContent":["import {\n compose,\n type Matrix,\n applyToPoint,\n scale,\n translate,\n} from \"transformation-matrix\"\nimport { GraphicsObject } from \"../../../lib\"\nimport { useMemo, useState } from \"react\"\nimport useMouseMatrixTransform from \"use-mouse-matrix-transform\"\nimport { InteractiveState } from \"./InteractiveState\"\nimport { SuperGrid } from \"react-supergrid\"\nimport useResizeObserver from \"@react-hook/resize-observer\"\nimport { Line } from \"./Line\"\nimport { Point } from \"./Point\"\nimport { Rect } from \"./Rect\"\nimport { getGraphicsBounds } from \"site/utils/getGraphicsBounds\"\n\nexport const InteractiveGraphics = ({\n graphics,\n}: { graphics: GraphicsObject }) => {\n const [activeLayers, setActiveLayers] = useState<string[] | null>(null)\n const [activeStep, setActiveStep] = useState<number | null>(null)\n const [size, setSize] = useState({ width: 600, height: 600 })\n const availableLayers: string[] = Array.from(\n new Set([\n ...(graphics.lines?.map((l) => l.layer!).filter(Boolean) ?? []),\n ...(graphics.rects?.map((r) => r.layer!).filter(Boolean) ?? []),\n ...(graphics.points?.map((p) => p.layer!).filter(Boolean) ?? []),\n ]),\n )\n const maxStep = Math.max(\n 0,\n ...(graphics.lines?.map((l) => l.step!).filter(Boolean) ?? []),\n ...(graphics.rects?.map((r) => r.step!).filter(Boolean) ?? []),\n ...(graphics.points?.map((p) => p.step!).filter(Boolean) ?? []),\n )\n\n const graphicsBoundsWithPadding = useMemo(() => {\n const actualBounds = getGraphicsBounds(graphics)\n const width = actualBounds.maxX - actualBounds.minX\n const height = actualBounds.maxY - actualBounds.minY\n return {\n minX: actualBounds.minX - width / 10,\n minY: actualBounds.minY - height / 10,\n maxX: actualBounds.maxX + width / 10,\n maxY: actualBounds.maxY + height / 10,\n }\n }, [graphics])\n\n const { transform: realToScreen, ref } = useMouseMatrixTransform({\n initialTransform: compose(\n translate(size.width / 2, size.height / 2),\n scale(\n Math.min(\n size.width /\n (graphicsBoundsWithPadding.maxX - graphicsBoundsWithPadding.minX),\n size.height /\n (graphicsBoundsWithPadding.maxY - graphicsBoundsWithPadding.minY),\n ),\n -Math.min(\n size.width /\n (graphicsBoundsWithPadding.maxX - graphicsBoundsWithPadding.minX),\n size.height /\n (graphicsBoundsWithPadding.maxY - graphicsBoundsWithPadding.minY),\n ),\n ),\n translate(\n -(graphicsBoundsWithPadding.maxX + graphicsBoundsWithPadding.minX) / 2,\n -(graphicsBoundsWithPadding.maxY + graphicsBoundsWithPadding.minY) / 2,\n ),\n ),\n })\n\n useResizeObserver(ref, (entry: ResizeObserverEntry) => {\n setSize({\n width: entry.contentRect.width,\n height: entry.contentRect.height,\n })\n })\n\n const interactiveState: InteractiveState = {\n activeLayers: activeLayers,\n activeStep: activeStep,\n realToScreen: realToScreen,\n }\n\n const showToolbar = availableLayers.length > 1 || maxStep > 0\n\n const filterLayerAndStep = (obj: { layer?: string; step?: number }) => {\n if (activeLayers && obj.layer && !activeLayers.includes(obj.layer))\n return false\n if (\n activeStep !== null &&\n obj.step !== undefined &&\n obj.step !== activeStep\n )\n return false\n return true\n }\n\n return (\n <div>\n {showToolbar && (\n <div style={{ margin: 8 }}>\n {availableLayers.length > 1 && (\n <select\n value={activeLayers ? activeLayers[0] : \"\"}\n onChange={(e) => {\n const value = e.target.value\n setActiveLayers(value === \"\" ? null : [value])\n }}\n style={{ marginRight: 8 }}\n >\n <option value=\"\">All Layers</option>\n {availableLayers.map((layer) => (\n <option key={layer} value={layer}>\n {layer}\n </option>\n ))}\n </select>\n )}\n\n {maxStep > 0 && (\n <div\n style={{ display: \"inline-flex\", alignItems: \"center\", gap: 8 }}\n >\n Step:\n <input\n type=\"number\"\n min={0}\n max={maxStep}\n value={activeStep ?? 0}\n onChange={(e) => {\n const value = parseInt(e.target.value)\n setActiveStep(Number.isNaN(value) ? null : value)\n }}\n disabled={activeStep === null}\n />\n <label>\n <input\n type=\"checkbox\"\n style={{ marginRight: 4 }}\n checked={activeStep !== null}\n onChange={(e) => {\n setActiveStep(e.target.checked ? 0 : null)\n }}\n />\n Filter by step\n </label>\n </div>\n )}\n </div>\n )}\n\n <div\n ref={ref}\n style={{\n position: \"relative\",\n height: 600,\n overflow: \"hidden\",\n }}\n >\n {graphics.lines?.filter(filterLayerAndStep)?.map((l, i) => (\n <Line\n key={i}\n line={l}\n index={i}\n interactiveState={interactiveState}\n />\n ))}\n {graphics.rects?.filter(filterLayerAndStep)?.map((r, i) => (\n <Rect\n key={i}\n rect={r}\n index={i}\n interactiveState={interactiveState}\n />\n ))}\n {graphics.points?.filter(filterLayerAndStep)?.map((p, i) => (\n <Point\n key={i}\n point={p}\n index={i}\n interactiveState={interactiveState}\n />\n ))}\n <SuperGrid\n stringifyCoord={(x, y) => `${x.toFixed(2)}, ${y.toFixed(2)}`}\n width={size.width}\n height={size.height}\n transform={realToScreen}\n />\n </div>\n </div>\n )\n}\n","import type * as Types from \"lib/types\"\nimport { applyToPoint } from \"transformation-matrix\"\nimport type { InteractiveState } from \"./InteractiveState\"\nimport { lighten } from \"polished\"\nimport { useState } from \"react\"\nimport { Tooltip } from \"./Tooltip\"\nimport { distToLineSegment } from \"site/utils/distToLineSegment\"\nimport { defaultColors } from \"./defaultColors\"\n\nexport const Line = ({\n line,\n index,\n interactiveState,\n}: { line: Types.Line; index: number; interactiveState: InteractiveState }) => {\n const { activeLayers, activeStep, realToScreen } = interactiveState\n const {\n points,\n layer,\n step,\n strokeColor,\n strokeWidth = 1 / realToScreen.a,\n } = line\n const [isHovered, setIsHovered] = useState(false)\n const [mousePos, setMousePos] = useState({ x: 0, y: 0 })\n\n const screenPoints = points.map((p) => applyToPoint(realToScreen, p))\n\n const handleMouseMove = (e: React.MouseEvent) => {\n const rect = e.currentTarget.getBoundingClientRect()\n const mouseX = e.clientX - rect.left\n const mouseY = e.clientY - rect.top\n const hoverThreshold = 10 // pixels\n\n setMousePos({ x: mouseX, y: mouseY })\n\n // Check distance to each line segment\n let isNearLine = false\n for (let i = 0; i < screenPoints.length - 1; i++) {\n const dist = distToLineSegment(\n mouseX,\n mouseY,\n screenPoints[i].x,\n screenPoints[i].y,\n screenPoints[i + 1].x,\n screenPoints[i + 1].y,\n )\n if (dist < hoverThreshold) {\n isNearLine = true\n break\n }\n }\n\n setIsHovered(isNearLine)\n }\n\n const baseColor = strokeColor ?? defaultColors[index % defaultColors.length]\n\n return (\n <svg\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n right: 0,\n bottom: 0,\n }}\n onMouseMove={handleMouseMove}\n onMouseLeave={() => setIsHovered(false)}\n >\n <polyline\n points={screenPoints.map((p) => `${p.x},${p.y}`).join(\" \")}\n stroke={isHovered ? lighten(0.2, baseColor) : baseColor}\n strokeWidth={strokeWidth * realToScreen.a}\n />\n {isHovered && line.label && (\n <foreignObject\n x={mousePos.x}\n y={mousePos.y - 40}\n width={300}\n height={40}\n >\n <Tooltip text={line.label} />\n </foreignObject>\n )}\n </svg>\n )\n}\n","export const Tooltip = ({ text }: { text: string }) => {\n return (\n <div\n style={{\n background: \"white\",\n border: \"1px solid #ccc\",\n boxShadow: \"0 0 10px 0 rgba(0, 0, 0, 0.1)\",\n borderRadius: \"4px\",\n padding: \"4px 8px\",\n fontSize: \"12px\",\n minWidth: \"150px\",\n maxWidth: \"300px\",\n overflow: \"hidden\",\n textOverflow: \"ellipsis\",\n whiteSpace: \"pre-wrap\",\n }}\n >\n {text}\n </div>\n )\n}\n","// Calculate distance from point to line segment\nexport const distToLineSegment = (\n px: number,\n py: number,\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n) => {\n const A = px - x1\n const B = py - y1\n const C = x2 - x1\n const D = y2 - y1\n\n const dot = A * C + B * D\n const lenSq = C * C + D * D\n let param = -1\n\n if (lenSq !== 0) param = dot / lenSq\n\n let xx = 0\n let yy = 0\n\n if (param < 0) {\n xx = x1\n yy = y1\n } else if (param > 1) {\n xx = x2\n yy = y2\n } else {\n xx = x1 + param * C\n yy = y1 + param * D\n }\n\n const dx = px - xx\n const dy = py - yy\n return Math.sqrt(dx * dx + dy * dy)\n}\n","// These are default colors if no color is provided\n// colors are made based on the index of the item in the array\n\nexport const defaultColors = [\n \"rgba(239, 68, 68, 0.8)\", // red-300\n \"rgba(249, 115, 22, 0.8)\", // orange-300\n \"rgba(245, 158, 11, 0.8)\", // amber-300\n \"rgba(234, 179, 8, 0.8)\", // yellow-300\n \"rgba(132, 204, 22, 0.8)\", // lime-300\n \"rgba(34, 197, 94, 0.8)\", // green-300\n \"rgba(16, 185, 129, 0.8)\", // emerald-300\n \"rgba(20, 184, 166, 0.8)\", // teal-300\n \"rgba(6, 182, 212, 0.8)\", // cyan-300\n \"rgba(14, 165, 233, 0.8)\", // sky-300\n \"rgba(59, 130, 246, 0.8)\", // blue-300\n \"rgba(99, 102, 241, 0.8)\", // indigo-300\n \"rgba(139, 92, 246, 0.8)\", // violet-300\n \"rgba(168, 85, 247, 0.8)\", // purple-300\n \"rgba(217, 70, 239, 0.8)\", // fuchsia-300\n \"rgba(236, 72, 153, 0.8)\", // pink-300\n \"rgba(249, 168, 212, 0.8)\", // rose-300\n \"rgba(161, 161, 170, 0.8)\", // zinc-300\n]\n","import type * as Types from \"lib/types\"\nimport { applyToPoint } from \"transformation-matrix\"\nimport type { InteractiveState } from \"./InteractiveState\"\nimport { lighten } from \"polished\"\nimport { useState } from \"react\"\nimport { Tooltip } from \"./Tooltip\"\nimport { defaultColors } from \"./defaultColors\"\n\nexport const Point = ({\n point,\n interactiveState,\n index,\n}: {\n point: Types.Point\n interactiveState: InteractiveState\n index: number\n}) => {\n const { color, label, layer, step } = point\n const { activeLayers, activeStep, realToScreen } = interactiveState\n const [isHovered, setIsHovered] = useState(false)\n\n const screenPoint = applyToPoint(realToScreen, point)\n const size = 10\n\n return (\n <div\n style={{\n position: \"absolute\",\n left: screenPoint.x - size / 2,\n top: screenPoint.y - size / 2,\n width: size,\n height: size,\n borderRadius: \"50%\",\n border: `2px solid ${\n isHovered\n ? lighten(0.2, color ?? defaultColors[index % defaultColors.length])\n : (color ?? defaultColors[index % defaultColors.length])\n }`,\n cursor: \"pointer\",\n transition: \"border-color 0.2s\",\n }}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {isHovered && (\n <div\n style={{\n position: \"absolute\",\n bottom: \"100%\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n marginBottom: 8,\n }}\n >\n <Tooltip\n text={`${label ? `${label}\\n` : \"\"}x: ${point.x.toFixed(2)}, y: ${point.y.toFixed(2)}`}\n />\n </div>\n )}\n </div>\n )\n}\n","import type * as Types from \"lib/types\"\nimport { applyToPoint } from \"transformation-matrix\"\nimport type { InteractiveState } from \"./InteractiveState\"\nimport { lighten } from \"polished\"\nimport { useState } from \"react\"\nimport { Tooltip } from \"./Tooltip\"\nimport { defaultColors } from \"./defaultColors\"\n\nexport const Rect = ({\n rect,\n interactiveState,\n index,\n}: {\n rect: Types.Rect\n interactiveState: InteractiveState\n index: number\n}) => {\n const defaultColor = defaultColors[index % defaultColors.length]\n const { center, width, height, fill, stroke, layer, step } = rect\n const { activeLayers, activeStep, realToScreen } = interactiveState\n const [isHovered, setIsHovered] = useState(false)\n\n const screenCenter = applyToPoint(realToScreen, center)\n const screenWidth = width * realToScreen.a\n const screenHeight = height * Math.abs(realToScreen.d)\n\n // Default style when neither fill nor stroke is specified\n const hasStrokeOrFill = fill !== undefined || stroke !== undefined\n\n let backgroundColor = hasStrokeOrFill ? fill || \"transparent\" : defaultColor\n if (isHovered) {\n backgroundColor = lighten(0.2, backgroundColor)\n }\n\n return (\n <div\n style={{\n position: \"absolute\",\n left: screenCenter.x - screenWidth / 2,\n top: screenCenter.y - screenHeight / 2,\n width: screenWidth,\n height: screenHeight,\n backgroundColor,\n border: stroke\n ? `2px solid ${isHovered ? lighten(0.2, stroke) : stroke}`\n : \"none\",\n cursor: \"pointer\",\n transition: \"border-color 0.2s\",\n }}\n onMouseEnter={() => setIsHovered(true)}\n onMouseLeave={() => setIsHovered(false)}\n >\n {isHovered && rect.label && (\n <div\n style={{\n position: \"absolute\",\n bottom: \"100%\",\n left: \"50%\",\n transform: \"translateX(-50%)\",\n marginBottom: 8,\n }}\n >\n <Tooltip text={rect.label} />\n </div>\n )}\n </div>\n )\n}\n","import { GraphicsObject } from \"lib/types\"\n\nexport const getGraphicsBounds = (graphics: GraphicsObject) => {\n const bounds = {\n minX: Infinity,\n minY: Infinity,\n maxX: -Infinity,\n maxY: -Infinity,\n }\n for (const line of graphics.lines ?? []) {\n for (const point of line.points ?? []) {\n bounds.minX = Math.min(bounds.minX, point.x)\n bounds.minY = Math.min(bounds.minY, point.y)\n bounds.maxX = Math.max(bounds.maxX, point.x)\n bounds.maxY = Math.max(bounds.maxY, point.y)\n }\n }\n for (const rect of graphics.rects ?? []) {\n const { center, width, height } = rect\n const halfWidth = width / 2\n const halfHeight = height / 2\n bounds.minX = Math.min(bounds.minX, center.x - halfWidth)\n bounds.minY = Math.min(bounds.minY, center.y - halfHeight)\n bounds.maxX = Math.max(bounds.maxX, center.x + halfWidth)\n bounds.maxY = Math.max(bounds.maxY, center.y + halfHeight)\n }\n for (const point of graphics.points ?? []) {\n bounds.minX = Math.min(bounds.minX, point.x)\n bounds.minY = Math.min(bounds.minY, point.y)\n bounds.maxX = Math.max(bounds.maxX, point.x)\n bounds.maxY = Math.max(bounds.maxY, point.y)\n }\n return bounds\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EAGA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,SAAS,YAAAA,iBAAgB;AAClC,OAAO,6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AC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAAA,cAC1D,OAAO,KAAK;AAAA,cACZ,QAAQ,KAAK;AAAA,cACb,WAAW;AAAA;AAAA,UACb;AAAA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":["useState","jsx","applyToPoint","lighten","useState","jsx","useState","applyToPoint","lighten","applyToPoint","lighten","useState","jsx","useState","applyToPoint","lighten","jsx","jsxs","useState"]}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ interface Point {
|
|
|
3
3
|
y: number;
|
|
4
4
|
color?: string;
|
|
5
5
|
label?: string;
|
|
6
|
+
layer?: string;
|
|
7
|
+
step?: number;
|
|
6
8
|
}
|
|
7
9
|
interface Line {
|
|
8
10
|
points: {
|
|
@@ -11,6 +13,9 @@ interface Line {
|
|
|
11
13
|
}[];
|
|
12
14
|
strokeWidth?: number;
|
|
13
15
|
strokeColor?: string;
|
|
16
|
+
layer?: string;
|
|
17
|
+
step?: number;
|
|
18
|
+
label?: string;
|
|
14
19
|
}
|
|
15
20
|
interface Rect {
|
|
16
21
|
center: {
|
|
@@ -22,6 +27,9 @@ interface Rect {
|
|
|
22
27
|
fill?: string;
|
|
23
28
|
stroke?: string;
|
|
24
29
|
color?: string;
|
|
30
|
+
layer?: string;
|
|
31
|
+
step?: number;
|
|
32
|
+
label?: string;
|
|
25
33
|
}
|
|
26
34
|
interface Circle {
|
|
27
35
|
center: {
|
|
@@ -31,6 +39,8 @@ interface Circle {
|
|
|
31
39
|
radius: number;
|
|
32
40
|
fill?: string;
|
|
33
41
|
stroke?: string;
|
|
42
|
+
layer?: string;
|
|
43
|
+
step?: number;
|
|
34
44
|
}
|
|
35
45
|
interface GraphicsObject {
|
|
36
46
|
points?: Point[];
|
package/package.json
CHANGED
|
@@ -2,16 +2,27 @@
|
|
|
2
2
|
"name": "graphics-debug",
|
|
3
3
|
"main": "dist/lib/index.js",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.8",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
8
8
|
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/lib/index.d.ts",
|
|
12
|
+
"import": "./dist/lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./react": {
|
|
15
|
+
"types": "./dist/lib/react.d.ts",
|
|
16
|
+
"import": "./dist/lib/react.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
9
19
|
"bin": {
|
|
10
20
|
"graphics-debug": "./dist/cli/cli.js",
|
|
11
21
|
"gd": "./dist/cli/cli.js"
|
|
12
22
|
},
|
|
13
23
|
"scripts": {
|
|
14
|
-
"start": "
|
|
24
|
+
"start": "cosmos",
|
|
25
|
+
"start:landing": "vite",
|
|
15
26
|
"build": "tsup-node ./cli ./lib --dts --format esm --sourcemap",
|
|
16
27
|
"format": "biome format --write .",
|
|
17
28
|
"format:check": "biome format .",
|
|
@@ -19,6 +30,7 @@
|
|
|
19
30
|
},
|
|
20
31
|
"devDependencies": {
|
|
21
32
|
"@biomejs/biome": "^1.9.4",
|
|
33
|
+
"@react-hook/resize-observer": "^2.0.2",
|
|
22
34
|
"@types/bun": "latest",
|
|
23
35
|
"@types/debug": "^4.1.12",
|
|
24
36
|
"@types/jsdom": "^21.1.7",
|
|
@@ -31,18 +43,24 @@
|
|
|
31
43
|
"debug": "^4.3.7",
|
|
32
44
|
"jsdom": "^25.0.1",
|
|
33
45
|
"react": "^18.3.1",
|
|
46
|
+
"react-cosmos": "^6.2.3",
|
|
47
|
+
"react-cosmos-plugin-vite": "^6.2.0",
|
|
34
48
|
"react-dom": "^18.3.1",
|
|
35
49
|
"tsup": "^8.3.5",
|
|
36
|
-
"vite": "^5.4.11"
|
|
50
|
+
"vite": "^5.4.11",
|
|
51
|
+
"vite-tsconfig-paths": "^5.1.4"
|
|
37
52
|
},
|
|
38
53
|
"peerDependencies": {
|
|
39
54
|
"typescript": "^5.0.0"
|
|
40
55
|
},
|
|
41
56
|
"dependencies": {
|
|
42
57
|
"@types/react-router-dom": "^5.3.3",
|
|
58
|
+
"polished": "^4.3.1",
|
|
43
59
|
"pretty": "^2.0.0",
|
|
44
60
|
"react-router-dom": "^6.28.0",
|
|
61
|
+
"react-supergrid": "^1.0.10",
|
|
45
62
|
"svgson": "^5.3.1",
|
|
46
|
-
"transformation-matrix": "^2.16.1"
|
|
63
|
+
"transformation-matrix": "^2.16.1",
|
|
64
|
+
"use-mouse-matrix-transform": "^1.3.0"
|
|
47
65
|
}
|
|
48
66
|
}
|