@tscircuit/schematic-viewer 1.0.1 → 1.0.3
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/.github/workflows/release.yml +4 -2
- package/dist/index.d.ts +7 -0
- package/dist/index.js +2235 -0
- package/dist/index.js.map +1 -0
- package/package.json +1 -1
- package/tsconfig.json +1 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,2235 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __esm = (fn, res) => function __init() {
|
|
8
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
9
|
+
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
|
|
31
|
+
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js
|
|
32
|
+
var require_use_sync_external_store_shim_production_min = __commonJS({
|
|
33
|
+
"node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js"(exports) {
|
|
34
|
+
"use strict";
|
|
35
|
+
var e = require("react");
|
|
36
|
+
function h(a, b) {
|
|
37
|
+
return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
|
|
38
|
+
}
|
|
39
|
+
var k = "function" === typeof Object.is ? Object.is : h;
|
|
40
|
+
var l = e.useState;
|
|
41
|
+
var m = e.useEffect;
|
|
42
|
+
var n = e.useLayoutEffect;
|
|
43
|
+
var p = e.useDebugValue;
|
|
44
|
+
function q(a, b) {
|
|
45
|
+
var d = b(), f = l({ inst: { value: d, getSnapshot: b } }), c = f[0].inst, g = f[1];
|
|
46
|
+
n(function() {
|
|
47
|
+
c.value = d;
|
|
48
|
+
c.getSnapshot = b;
|
|
49
|
+
r(c) && g({ inst: c });
|
|
50
|
+
}, [a, d, b]);
|
|
51
|
+
m(function() {
|
|
52
|
+
r(c) && g({ inst: c });
|
|
53
|
+
return a(function() {
|
|
54
|
+
r(c) && g({ inst: c });
|
|
55
|
+
});
|
|
56
|
+
}, [a]);
|
|
57
|
+
p(d);
|
|
58
|
+
return d;
|
|
59
|
+
}
|
|
60
|
+
function r(a) {
|
|
61
|
+
var b = a.getSnapshot;
|
|
62
|
+
a = a.value;
|
|
63
|
+
try {
|
|
64
|
+
var d = b();
|
|
65
|
+
return !k(a, d);
|
|
66
|
+
} catch (f) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function t(a, b) {
|
|
71
|
+
return b();
|
|
72
|
+
}
|
|
73
|
+
var u = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
|
|
74
|
+
exports.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
|
|
79
|
+
var require_use_sync_external_store_shim_development = __commonJS({
|
|
80
|
+
"node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
|
|
81
|
+
"use strict";
|
|
82
|
+
if (process.env.NODE_ENV !== "production") {
|
|
83
|
+
(function() {
|
|
84
|
+
"use strict";
|
|
85
|
+
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
86
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
87
|
+
}
|
|
88
|
+
var React = require("react");
|
|
89
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
90
|
+
function error(format) {
|
|
91
|
+
{
|
|
92
|
+
{
|
|
93
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
94
|
+
args[_key2 - 1] = arguments[_key2];
|
|
95
|
+
}
|
|
96
|
+
printWarning("error", format, args);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function printWarning(level, format, args) {
|
|
101
|
+
{
|
|
102
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
103
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
104
|
+
if (stack !== "") {
|
|
105
|
+
format += "%s";
|
|
106
|
+
args = args.concat([stack]);
|
|
107
|
+
}
|
|
108
|
+
var argsWithFormat = args.map(function(item) {
|
|
109
|
+
return String(item);
|
|
110
|
+
});
|
|
111
|
+
argsWithFormat.unshift("Warning: " + format);
|
|
112
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function is(x, y) {
|
|
116
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
|
117
|
+
}
|
|
118
|
+
var objectIs = typeof Object.is === "function" ? Object.is : is;
|
|
119
|
+
var useState4 = React.useState, useEffect4 = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue2 = React.useDebugValue;
|
|
120
|
+
var didWarnOld18Alpha = false;
|
|
121
|
+
var didWarnUncachedGetSnapshot = false;
|
|
122
|
+
function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
|
|
123
|
+
{
|
|
124
|
+
if (!didWarnOld18Alpha) {
|
|
125
|
+
if (React.startTransition !== void 0) {
|
|
126
|
+
didWarnOld18Alpha = true;
|
|
127
|
+
error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
var value = getSnapshot();
|
|
132
|
+
{
|
|
133
|
+
if (!didWarnUncachedGetSnapshot) {
|
|
134
|
+
var cachedValue = getSnapshot();
|
|
135
|
+
if (!objectIs(value, cachedValue)) {
|
|
136
|
+
error("The result of getSnapshot should be cached to avoid an infinite loop");
|
|
137
|
+
didWarnUncachedGetSnapshot = true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
var _useState = useState4({
|
|
142
|
+
inst: {
|
|
143
|
+
value,
|
|
144
|
+
getSnapshot
|
|
145
|
+
}
|
|
146
|
+
}), inst = _useState[0].inst, forceUpdate = _useState[1];
|
|
147
|
+
useLayoutEffect(function() {
|
|
148
|
+
inst.value = value;
|
|
149
|
+
inst.getSnapshot = getSnapshot;
|
|
150
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
151
|
+
forceUpdate({
|
|
152
|
+
inst
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}, [subscribe, value, getSnapshot]);
|
|
156
|
+
useEffect4(function() {
|
|
157
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
158
|
+
forceUpdate({
|
|
159
|
+
inst
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
var handleStoreChange = function() {
|
|
163
|
+
if (checkIfSnapshotChanged(inst)) {
|
|
164
|
+
forceUpdate({
|
|
165
|
+
inst
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
return subscribe(handleStoreChange);
|
|
170
|
+
}, [subscribe]);
|
|
171
|
+
useDebugValue2(value);
|
|
172
|
+
return value;
|
|
173
|
+
}
|
|
174
|
+
function checkIfSnapshotChanged(inst) {
|
|
175
|
+
var latestGetSnapshot = inst.getSnapshot;
|
|
176
|
+
var prevValue = inst.value;
|
|
177
|
+
try {
|
|
178
|
+
var nextValue = latestGetSnapshot();
|
|
179
|
+
return !objectIs(prevValue, nextValue);
|
|
180
|
+
} catch (error2) {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
|
|
185
|
+
return getSnapshot();
|
|
186
|
+
}
|
|
187
|
+
var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
188
|
+
var isServerEnvironment = !canUseDOM;
|
|
189
|
+
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
190
|
+
var useSyncExternalStore$2 = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim;
|
|
191
|
+
exports.useSyncExternalStore = useSyncExternalStore$2;
|
|
192
|
+
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
|
|
193
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
194
|
+
}
|
|
195
|
+
})();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// node_modules/use-sync-external-store/shim/index.js
|
|
201
|
+
var require_shim = __commonJS({
|
|
202
|
+
"node_modules/use-sync-external-store/shim/index.js"(exports, module2) {
|
|
203
|
+
"use strict";
|
|
204
|
+
if (process.env.NODE_ENV === "production") {
|
|
205
|
+
module2.exports = require_use_sync_external_store_shim_production_min();
|
|
206
|
+
} else {
|
|
207
|
+
module2.exports = require_use_sync_external_store_shim_development();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js
|
|
213
|
+
var require_with_selector_production_min = __commonJS({
|
|
214
|
+
"node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js"(exports) {
|
|
215
|
+
"use strict";
|
|
216
|
+
var h = require("react");
|
|
217
|
+
var n = require_shim();
|
|
218
|
+
function p(a, b) {
|
|
219
|
+
return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
|
|
220
|
+
}
|
|
221
|
+
var q = "function" === typeof Object.is ? Object.is : p;
|
|
222
|
+
var r = n.useSyncExternalStore;
|
|
223
|
+
var t = h.useRef;
|
|
224
|
+
var u = h.useEffect;
|
|
225
|
+
var v = h.useMemo;
|
|
226
|
+
var w = h.useDebugValue;
|
|
227
|
+
exports.useSyncExternalStoreWithSelector = function(a, b, e, l, g) {
|
|
228
|
+
var c = t(null);
|
|
229
|
+
if (null === c.current) {
|
|
230
|
+
var f = { hasValue: false, value: null };
|
|
231
|
+
c.current = f;
|
|
232
|
+
} else
|
|
233
|
+
f = c.current;
|
|
234
|
+
c = v(function() {
|
|
235
|
+
function a2(a3) {
|
|
236
|
+
if (!c2) {
|
|
237
|
+
c2 = true;
|
|
238
|
+
d2 = a3;
|
|
239
|
+
a3 = l(a3);
|
|
240
|
+
if (void 0 !== g && f.hasValue) {
|
|
241
|
+
var b2 = f.value;
|
|
242
|
+
if (g(b2, a3))
|
|
243
|
+
return k = b2;
|
|
244
|
+
}
|
|
245
|
+
return k = a3;
|
|
246
|
+
}
|
|
247
|
+
b2 = k;
|
|
248
|
+
if (q(d2, a3))
|
|
249
|
+
return b2;
|
|
250
|
+
var e2 = l(a3);
|
|
251
|
+
if (void 0 !== g && g(b2, e2))
|
|
252
|
+
return b2;
|
|
253
|
+
d2 = a3;
|
|
254
|
+
return k = e2;
|
|
255
|
+
}
|
|
256
|
+
var c2 = false, d2, k, m = void 0 === e ? null : e;
|
|
257
|
+
return [function() {
|
|
258
|
+
return a2(b());
|
|
259
|
+
}, null === m ? void 0 : function() {
|
|
260
|
+
return a2(m());
|
|
261
|
+
}];
|
|
262
|
+
}, [b, e, l, g]);
|
|
263
|
+
var d = r(a, c[0], c[1]);
|
|
264
|
+
u(function() {
|
|
265
|
+
f.hasValue = true;
|
|
266
|
+
f.value = d;
|
|
267
|
+
}, [d]);
|
|
268
|
+
w(d);
|
|
269
|
+
return d;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
|
|
275
|
+
var require_with_selector_development = __commonJS({
|
|
276
|
+
"node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
|
|
277
|
+
"use strict";
|
|
278
|
+
if (process.env.NODE_ENV !== "production") {
|
|
279
|
+
(function() {
|
|
280
|
+
"use strict";
|
|
281
|
+
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
282
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
283
|
+
}
|
|
284
|
+
var React = require("react");
|
|
285
|
+
var shim = require_shim();
|
|
286
|
+
function is(x, y) {
|
|
287
|
+
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
|
288
|
+
}
|
|
289
|
+
var objectIs = typeof Object.is === "function" ? Object.is : is;
|
|
290
|
+
var useSyncExternalStore = shim.useSyncExternalStore;
|
|
291
|
+
var useRef2 = React.useRef, useEffect4 = React.useEffect, useMemo2 = React.useMemo, useDebugValue2 = React.useDebugValue;
|
|
292
|
+
function useSyncExternalStoreWithSelector2(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
293
|
+
var instRef = useRef2(null);
|
|
294
|
+
var inst;
|
|
295
|
+
if (instRef.current === null) {
|
|
296
|
+
inst = {
|
|
297
|
+
hasValue: false,
|
|
298
|
+
value: null
|
|
299
|
+
};
|
|
300
|
+
instRef.current = inst;
|
|
301
|
+
} else {
|
|
302
|
+
inst = instRef.current;
|
|
303
|
+
}
|
|
304
|
+
var _useMemo = useMemo2(function() {
|
|
305
|
+
var hasMemo = false;
|
|
306
|
+
var memoizedSnapshot;
|
|
307
|
+
var memoizedSelection;
|
|
308
|
+
var memoizedSelector = function(nextSnapshot) {
|
|
309
|
+
if (!hasMemo) {
|
|
310
|
+
hasMemo = true;
|
|
311
|
+
memoizedSnapshot = nextSnapshot;
|
|
312
|
+
var _nextSelection = selector(nextSnapshot);
|
|
313
|
+
if (isEqual !== void 0) {
|
|
314
|
+
if (inst.hasValue) {
|
|
315
|
+
var currentSelection = inst.value;
|
|
316
|
+
if (isEqual(currentSelection, _nextSelection)) {
|
|
317
|
+
memoizedSelection = currentSelection;
|
|
318
|
+
return currentSelection;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
memoizedSelection = _nextSelection;
|
|
323
|
+
return _nextSelection;
|
|
324
|
+
}
|
|
325
|
+
var prevSnapshot = memoizedSnapshot;
|
|
326
|
+
var prevSelection = memoizedSelection;
|
|
327
|
+
if (objectIs(prevSnapshot, nextSnapshot)) {
|
|
328
|
+
return prevSelection;
|
|
329
|
+
}
|
|
330
|
+
var nextSelection = selector(nextSnapshot);
|
|
331
|
+
if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
|
|
332
|
+
return prevSelection;
|
|
333
|
+
}
|
|
334
|
+
memoizedSnapshot = nextSnapshot;
|
|
335
|
+
memoizedSelection = nextSelection;
|
|
336
|
+
return nextSelection;
|
|
337
|
+
};
|
|
338
|
+
var maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot;
|
|
339
|
+
var getSnapshotWithSelector = function() {
|
|
340
|
+
return memoizedSelector(getSnapshot());
|
|
341
|
+
};
|
|
342
|
+
var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : function() {
|
|
343
|
+
return memoizedSelector(maybeGetServerSnapshot());
|
|
344
|
+
};
|
|
345
|
+
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
346
|
+
}, [getSnapshot, getServerSnapshot, selector, isEqual]), getSelection = _useMemo[0], getServerSelection = _useMemo[1];
|
|
347
|
+
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
348
|
+
useEffect4(function() {
|
|
349
|
+
inst.hasValue = true;
|
|
350
|
+
inst.value = value;
|
|
351
|
+
}, [value]);
|
|
352
|
+
useDebugValue2(value);
|
|
353
|
+
return value;
|
|
354
|
+
}
|
|
355
|
+
exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector2;
|
|
356
|
+
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
|
|
357
|
+
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
358
|
+
}
|
|
359
|
+
})();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// node_modules/use-sync-external-store/shim/with-selector.js
|
|
365
|
+
var require_with_selector = __commonJS({
|
|
366
|
+
"node_modules/use-sync-external-store/shim/with-selector.js"(exports, module2) {
|
|
367
|
+
"use strict";
|
|
368
|
+
if (process.env.NODE_ENV === "production") {
|
|
369
|
+
module2.exports = require_with_selector_production_min();
|
|
370
|
+
} else {
|
|
371
|
+
module2.exports = require_with_selector_development();
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// node_modules/parse-svg-path/index.js
|
|
377
|
+
var require_parse_svg_path = __commonJS({
|
|
378
|
+
"node_modules/parse-svg-path/index.js"(exports, module2) {
|
|
379
|
+
module2.exports = parse;
|
|
380
|
+
var length = { a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0 };
|
|
381
|
+
var segment = /([astvzqmhlc])([^astvzqmhlc]*)/ig;
|
|
382
|
+
function parse(path) {
|
|
383
|
+
var data = [];
|
|
384
|
+
path.replace(segment, function(_, command, args) {
|
|
385
|
+
var type = command.toLowerCase();
|
|
386
|
+
args = parseValues(args);
|
|
387
|
+
if (type == "m" && args.length > 2) {
|
|
388
|
+
data.push([command].concat(args.splice(0, 2)));
|
|
389
|
+
type = "l";
|
|
390
|
+
command = command == "m" ? "l" : "L";
|
|
391
|
+
}
|
|
392
|
+
while (true) {
|
|
393
|
+
if (args.length == length[type]) {
|
|
394
|
+
args.unshift(command);
|
|
395
|
+
return data.push(args);
|
|
396
|
+
}
|
|
397
|
+
if (args.length < length[type])
|
|
398
|
+
throw new Error("malformed path data");
|
|
399
|
+
data.push([command].concat(args.splice(0, length[type])));
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
return data;
|
|
403
|
+
}
|
|
404
|
+
var number = /-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/ig;
|
|
405
|
+
function parseValues(args) {
|
|
406
|
+
var numbers = args.match(number);
|
|
407
|
+
return numbers ? numbers.map(Number) : [];
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
// node_modules/abs-svg-path/index.js
|
|
413
|
+
var require_abs_svg_path = __commonJS({
|
|
414
|
+
"node_modules/abs-svg-path/index.js"(exports, module2) {
|
|
415
|
+
module2.exports = absolutize;
|
|
416
|
+
function absolutize(path) {
|
|
417
|
+
var startX = 0;
|
|
418
|
+
var startY = 0;
|
|
419
|
+
var x = 0;
|
|
420
|
+
var y = 0;
|
|
421
|
+
return path.map(function(seg) {
|
|
422
|
+
seg = seg.slice();
|
|
423
|
+
var type = seg[0];
|
|
424
|
+
var command = type.toUpperCase();
|
|
425
|
+
if (type != command) {
|
|
426
|
+
seg[0] = command;
|
|
427
|
+
switch (type) {
|
|
428
|
+
case "a":
|
|
429
|
+
seg[6] += x;
|
|
430
|
+
seg[7] += y;
|
|
431
|
+
break;
|
|
432
|
+
case "v":
|
|
433
|
+
seg[1] += y;
|
|
434
|
+
break;
|
|
435
|
+
case "h":
|
|
436
|
+
seg[1] += x;
|
|
437
|
+
break;
|
|
438
|
+
default:
|
|
439
|
+
for (var i = 1; i < seg.length; ) {
|
|
440
|
+
seg[i++] += x;
|
|
441
|
+
seg[i++] += y;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
switch (command) {
|
|
446
|
+
case "Z":
|
|
447
|
+
x = startX;
|
|
448
|
+
y = startY;
|
|
449
|
+
break;
|
|
450
|
+
case "H":
|
|
451
|
+
x = seg[1];
|
|
452
|
+
break;
|
|
453
|
+
case "V":
|
|
454
|
+
y = seg[1];
|
|
455
|
+
break;
|
|
456
|
+
case "M":
|
|
457
|
+
x = startX = seg[1];
|
|
458
|
+
y = startY = seg[2];
|
|
459
|
+
break;
|
|
460
|
+
default:
|
|
461
|
+
x = seg[seg.length - 2];
|
|
462
|
+
y = seg[seg.length - 1];
|
|
463
|
+
}
|
|
464
|
+
return seg;
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
// node_modules/svg-arc-to-cubic-bezier/modules/index.js
|
|
471
|
+
var modules_exports = {};
|
|
472
|
+
__export(modules_exports, {
|
|
473
|
+
default: () => modules_default
|
|
474
|
+
});
|
|
475
|
+
var _slicedToArray, TAU, mapToEllipse, approxUnitArc, vectorAngle, getArcCenter, arcToBezier, modules_default;
|
|
476
|
+
var init_modules = __esm({
|
|
477
|
+
"node_modules/svg-arc-to-cubic-bezier/modules/index.js"() {
|
|
478
|
+
_slicedToArray = function() {
|
|
479
|
+
function sliceIterator(arr, i) {
|
|
480
|
+
var _arr = [];
|
|
481
|
+
var _n = true;
|
|
482
|
+
var _d = false;
|
|
483
|
+
var _e = void 0;
|
|
484
|
+
try {
|
|
485
|
+
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
486
|
+
_arr.push(_s.value);
|
|
487
|
+
if (i && _arr.length === i)
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
} catch (err) {
|
|
491
|
+
_d = true;
|
|
492
|
+
_e = err;
|
|
493
|
+
} finally {
|
|
494
|
+
try {
|
|
495
|
+
if (!_n && _i["return"])
|
|
496
|
+
_i["return"]();
|
|
497
|
+
} finally {
|
|
498
|
+
if (_d)
|
|
499
|
+
throw _e;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
return _arr;
|
|
503
|
+
}
|
|
504
|
+
return function(arr, i) {
|
|
505
|
+
if (Array.isArray(arr)) {
|
|
506
|
+
return arr;
|
|
507
|
+
} else if (Symbol.iterator in Object(arr)) {
|
|
508
|
+
return sliceIterator(arr, i);
|
|
509
|
+
} else {
|
|
510
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
}();
|
|
514
|
+
TAU = Math.PI * 2;
|
|
515
|
+
mapToEllipse = function mapToEllipse2(_ref, rx, ry, cosphi, sinphi, centerx, centery) {
|
|
516
|
+
var x = _ref.x, y = _ref.y;
|
|
517
|
+
x *= rx;
|
|
518
|
+
y *= ry;
|
|
519
|
+
var xp = cosphi * x - sinphi * y;
|
|
520
|
+
var yp = sinphi * x + cosphi * y;
|
|
521
|
+
return {
|
|
522
|
+
x: xp + centerx,
|
|
523
|
+
y: yp + centery
|
|
524
|
+
};
|
|
525
|
+
};
|
|
526
|
+
approxUnitArc = function approxUnitArc2(ang1, ang2) {
|
|
527
|
+
var a = ang2 === 1.5707963267948966 ? 0.551915024494 : ang2 === -1.5707963267948966 ? -0.551915024494 : 4 / 3 * Math.tan(ang2 / 4);
|
|
528
|
+
var x1 = Math.cos(ang1);
|
|
529
|
+
var y1 = Math.sin(ang1);
|
|
530
|
+
var x2 = Math.cos(ang1 + ang2);
|
|
531
|
+
var y2 = Math.sin(ang1 + ang2);
|
|
532
|
+
return [{
|
|
533
|
+
x: x1 - y1 * a,
|
|
534
|
+
y: y1 + x1 * a
|
|
535
|
+
}, {
|
|
536
|
+
x: x2 + y2 * a,
|
|
537
|
+
y: y2 - x2 * a
|
|
538
|
+
}, {
|
|
539
|
+
x: x2,
|
|
540
|
+
y: y2
|
|
541
|
+
}];
|
|
542
|
+
};
|
|
543
|
+
vectorAngle = function vectorAngle2(ux, uy, vx, vy) {
|
|
544
|
+
var sign = ux * vy - uy * vx < 0 ? -1 : 1;
|
|
545
|
+
var dot = ux * vx + uy * vy;
|
|
546
|
+
if (dot > 1) {
|
|
547
|
+
dot = 1;
|
|
548
|
+
}
|
|
549
|
+
if (dot < -1) {
|
|
550
|
+
dot = -1;
|
|
551
|
+
}
|
|
552
|
+
return sign * Math.acos(dot);
|
|
553
|
+
};
|
|
554
|
+
getArcCenter = function getArcCenter2(px, py, cx, cy, rx, ry, largeArcFlag, sweepFlag, sinphi, cosphi, pxp, pyp) {
|
|
555
|
+
var rxsq = Math.pow(rx, 2);
|
|
556
|
+
var rysq = Math.pow(ry, 2);
|
|
557
|
+
var pxpsq = Math.pow(pxp, 2);
|
|
558
|
+
var pypsq = Math.pow(pyp, 2);
|
|
559
|
+
var radicant = rxsq * rysq - rxsq * pypsq - rysq * pxpsq;
|
|
560
|
+
if (radicant < 0) {
|
|
561
|
+
radicant = 0;
|
|
562
|
+
}
|
|
563
|
+
radicant /= rxsq * pypsq + rysq * pxpsq;
|
|
564
|
+
radicant = Math.sqrt(radicant) * (largeArcFlag === sweepFlag ? -1 : 1);
|
|
565
|
+
var centerxp = radicant * rx / ry * pyp;
|
|
566
|
+
var centeryp = radicant * -ry / rx * pxp;
|
|
567
|
+
var centerx = cosphi * centerxp - sinphi * centeryp + (px + cx) / 2;
|
|
568
|
+
var centery = sinphi * centerxp + cosphi * centeryp + (py + cy) / 2;
|
|
569
|
+
var vx1 = (pxp - centerxp) / rx;
|
|
570
|
+
var vy1 = (pyp - centeryp) / ry;
|
|
571
|
+
var vx2 = (-pxp - centerxp) / rx;
|
|
572
|
+
var vy2 = (-pyp - centeryp) / ry;
|
|
573
|
+
var ang1 = vectorAngle(1, 0, vx1, vy1);
|
|
574
|
+
var ang2 = vectorAngle(vx1, vy1, vx2, vy2);
|
|
575
|
+
if (sweepFlag === 0 && ang2 > 0) {
|
|
576
|
+
ang2 -= TAU;
|
|
577
|
+
}
|
|
578
|
+
if (sweepFlag === 1 && ang2 < 0) {
|
|
579
|
+
ang2 += TAU;
|
|
580
|
+
}
|
|
581
|
+
return [centerx, centery, ang1, ang2];
|
|
582
|
+
};
|
|
583
|
+
arcToBezier = function arcToBezier2(_ref2) {
|
|
584
|
+
var px = _ref2.px, py = _ref2.py, cx = _ref2.cx, cy = _ref2.cy, rx = _ref2.rx, ry = _ref2.ry, _ref2$xAxisRotation = _ref2.xAxisRotation, xAxisRotation = _ref2$xAxisRotation === void 0 ? 0 : _ref2$xAxisRotation, _ref2$largeArcFlag = _ref2.largeArcFlag, largeArcFlag = _ref2$largeArcFlag === void 0 ? 0 : _ref2$largeArcFlag, _ref2$sweepFlag = _ref2.sweepFlag, sweepFlag = _ref2$sweepFlag === void 0 ? 0 : _ref2$sweepFlag;
|
|
585
|
+
var curves = [];
|
|
586
|
+
if (rx === 0 || ry === 0) {
|
|
587
|
+
return [];
|
|
588
|
+
}
|
|
589
|
+
var sinphi = Math.sin(xAxisRotation * TAU / 360);
|
|
590
|
+
var cosphi = Math.cos(xAxisRotation * TAU / 360);
|
|
591
|
+
var pxp = cosphi * (px - cx) / 2 + sinphi * (py - cy) / 2;
|
|
592
|
+
var pyp = -sinphi * (px - cx) / 2 + cosphi * (py - cy) / 2;
|
|
593
|
+
if (pxp === 0 && pyp === 0) {
|
|
594
|
+
return [];
|
|
595
|
+
}
|
|
596
|
+
rx = Math.abs(rx);
|
|
597
|
+
ry = Math.abs(ry);
|
|
598
|
+
var lambda = Math.pow(pxp, 2) / Math.pow(rx, 2) + Math.pow(pyp, 2) / Math.pow(ry, 2);
|
|
599
|
+
if (lambda > 1) {
|
|
600
|
+
rx *= Math.sqrt(lambda);
|
|
601
|
+
ry *= Math.sqrt(lambda);
|
|
602
|
+
}
|
|
603
|
+
var _getArcCenter = getArcCenter(px, py, cx, cy, rx, ry, largeArcFlag, sweepFlag, sinphi, cosphi, pxp, pyp), _getArcCenter2 = _slicedToArray(_getArcCenter, 4), centerx = _getArcCenter2[0], centery = _getArcCenter2[1], ang1 = _getArcCenter2[2], ang2 = _getArcCenter2[3];
|
|
604
|
+
var ratio = Math.abs(ang2) / (TAU / 4);
|
|
605
|
+
if (Math.abs(1 - ratio) < 1e-7) {
|
|
606
|
+
ratio = 1;
|
|
607
|
+
}
|
|
608
|
+
var segments = Math.max(Math.ceil(ratio), 1);
|
|
609
|
+
ang2 /= segments;
|
|
610
|
+
for (var i = 0; i < segments; i++) {
|
|
611
|
+
curves.push(approxUnitArc(ang1, ang2));
|
|
612
|
+
ang1 += ang2;
|
|
613
|
+
}
|
|
614
|
+
return curves.map(function(curve) {
|
|
615
|
+
var _mapToEllipse = mapToEllipse(curve[0], rx, ry, cosphi, sinphi, centerx, centery), x1 = _mapToEllipse.x, y1 = _mapToEllipse.y;
|
|
616
|
+
var _mapToEllipse2 = mapToEllipse(curve[1], rx, ry, cosphi, sinphi, centerx, centery), x2 = _mapToEllipse2.x, y2 = _mapToEllipse2.y;
|
|
617
|
+
var _mapToEllipse3 = mapToEllipse(curve[2], rx, ry, cosphi, sinphi, centerx, centery), x = _mapToEllipse3.x, y = _mapToEllipse3.y;
|
|
618
|
+
return { x1, y1, x2, y2, x, y };
|
|
619
|
+
});
|
|
620
|
+
};
|
|
621
|
+
modules_default = arcToBezier;
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
// node_modules/normalize-svg-path/index.js
|
|
626
|
+
var require_normalize_svg_path = __commonJS({
|
|
627
|
+
"node_modules/normalize-svg-path/index.js"(exports, module2) {
|
|
628
|
+
"use strict";
|
|
629
|
+
module2.exports = normalize;
|
|
630
|
+
var arcToCurve = (init_modules(), __toCommonJS(modules_exports));
|
|
631
|
+
function normalize(path) {
|
|
632
|
+
var prev;
|
|
633
|
+
var result = [];
|
|
634
|
+
var bezierX = 0;
|
|
635
|
+
var bezierY = 0;
|
|
636
|
+
var startX = 0;
|
|
637
|
+
var startY = 0;
|
|
638
|
+
var quadX = null;
|
|
639
|
+
var quadY = null;
|
|
640
|
+
var x = 0;
|
|
641
|
+
var y = 0;
|
|
642
|
+
for (var i = 0, len = path.length; i < len; i++) {
|
|
643
|
+
var seg = path[i];
|
|
644
|
+
var command = seg[0];
|
|
645
|
+
switch (command) {
|
|
646
|
+
case "M":
|
|
647
|
+
startX = seg[1];
|
|
648
|
+
startY = seg[2];
|
|
649
|
+
break;
|
|
650
|
+
case "A":
|
|
651
|
+
var curves = arcToCurve({
|
|
652
|
+
px: x,
|
|
653
|
+
py: y,
|
|
654
|
+
cx: seg[6],
|
|
655
|
+
cy: seg[7],
|
|
656
|
+
rx: seg[1],
|
|
657
|
+
ry: seg[2],
|
|
658
|
+
xAxisRotation: seg[3],
|
|
659
|
+
largeArcFlag: seg[4],
|
|
660
|
+
sweepFlag: seg[5]
|
|
661
|
+
});
|
|
662
|
+
if (!curves.length)
|
|
663
|
+
continue;
|
|
664
|
+
for (var j = 0, c; j < curves.length; j++) {
|
|
665
|
+
c = curves[j];
|
|
666
|
+
seg = ["C", c.x1, c.y1, c.x2, c.y2, c.x, c.y];
|
|
667
|
+
if (j < curves.length - 1)
|
|
668
|
+
result.push(seg);
|
|
669
|
+
}
|
|
670
|
+
break;
|
|
671
|
+
case "S":
|
|
672
|
+
var cx = x;
|
|
673
|
+
var cy = y;
|
|
674
|
+
if (prev == "C" || prev == "S") {
|
|
675
|
+
cx += cx - bezierX;
|
|
676
|
+
cy += cy - bezierY;
|
|
677
|
+
}
|
|
678
|
+
seg = ["C", cx, cy, seg[1], seg[2], seg[3], seg[4]];
|
|
679
|
+
break;
|
|
680
|
+
case "T":
|
|
681
|
+
if (prev == "Q" || prev == "T") {
|
|
682
|
+
quadX = x * 2 - quadX;
|
|
683
|
+
quadY = y * 2 - quadY;
|
|
684
|
+
} else {
|
|
685
|
+
quadX = x;
|
|
686
|
+
quadY = y;
|
|
687
|
+
}
|
|
688
|
+
seg = quadratic(x, y, quadX, quadY, seg[1], seg[2]);
|
|
689
|
+
break;
|
|
690
|
+
case "Q":
|
|
691
|
+
quadX = seg[1];
|
|
692
|
+
quadY = seg[2];
|
|
693
|
+
seg = quadratic(x, y, seg[1], seg[2], seg[3], seg[4]);
|
|
694
|
+
break;
|
|
695
|
+
case "L":
|
|
696
|
+
seg = line(x, y, seg[1], seg[2]);
|
|
697
|
+
break;
|
|
698
|
+
case "H":
|
|
699
|
+
seg = line(x, y, seg[1], y);
|
|
700
|
+
break;
|
|
701
|
+
case "V":
|
|
702
|
+
seg = line(x, y, x, seg[1]);
|
|
703
|
+
break;
|
|
704
|
+
case "Z":
|
|
705
|
+
seg = line(x, y, startX, startY);
|
|
706
|
+
break;
|
|
707
|
+
}
|
|
708
|
+
prev = command;
|
|
709
|
+
x = seg[seg.length - 2];
|
|
710
|
+
y = seg[seg.length - 1];
|
|
711
|
+
if (seg.length > 4) {
|
|
712
|
+
bezierX = seg[seg.length - 4];
|
|
713
|
+
bezierY = seg[seg.length - 3];
|
|
714
|
+
} else {
|
|
715
|
+
bezierX = x;
|
|
716
|
+
bezierY = y;
|
|
717
|
+
}
|
|
718
|
+
result.push(seg);
|
|
719
|
+
}
|
|
720
|
+
return result;
|
|
721
|
+
}
|
|
722
|
+
function line(x1, y1, x2, y2) {
|
|
723
|
+
return ["C", x1, y1, x2, y2, x2, y2];
|
|
724
|
+
}
|
|
725
|
+
function quadratic(x1, y1, cx, cy, x2, y2) {
|
|
726
|
+
return [
|
|
727
|
+
"C",
|
|
728
|
+
x1 / 3 + 2 / 3 * cx,
|
|
729
|
+
y1 / 3 + 2 / 3 * cy,
|
|
730
|
+
x2 / 3 + 2 / 3 * cx,
|
|
731
|
+
y2 / 3 + 2 / 3 * cy,
|
|
732
|
+
x2,
|
|
733
|
+
y2
|
|
734
|
+
];
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
// node_modules/is-svg-path/index.js
|
|
740
|
+
var require_is_svg_path = __commonJS({
|
|
741
|
+
"node_modules/is-svg-path/index.js"(exports, module2) {
|
|
742
|
+
"use strict";
|
|
743
|
+
module2.exports = function isPath(str) {
|
|
744
|
+
if (typeof str !== "string")
|
|
745
|
+
return false;
|
|
746
|
+
str = str.trim();
|
|
747
|
+
if (/^[mzlhvcsqta]\s*[-+.0-9][^mlhvzcsqta]+/i.test(str) && /[\dz]$/i.test(str) && str.length > 4)
|
|
748
|
+
return true;
|
|
749
|
+
return false;
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
|
|
754
|
+
// node_modules/svg-path-bounds/index.js
|
|
755
|
+
var require_svg_path_bounds = __commonJS({
|
|
756
|
+
"node_modules/svg-path-bounds/index.js"(exports, module2) {
|
|
757
|
+
"use strict";
|
|
758
|
+
var parse = require_parse_svg_path();
|
|
759
|
+
var abs = require_abs_svg_path();
|
|
760
|
+
var normalize = require_normalize_svg_path();
|
|
761
|
+
var isSvgPath = require_is_svg_path();
|
|
762
|
+
module2.exports = pathBounds;
|
|
763
|
+
function pathBounds(path) {
|
|
764
|
+
if (Array.isArray(path) && path.length === 1 && typeof path[0] === "string")
|
|
765
|
+
path = path[0];
|
|
766
|
+
if (typeof path === "string") {
|
|
767
|
+
if (!isSvgPath(path))
|
|
768
|
+
throw Error("String is not an SVG path.");
|
|
769
|
+
path = parse(path);
|
|
770
|
+
}
|
|
771
|
+
if (!Array.isArray(path))
|
|
772
|
+
throw Error("Argument should be a string or an array of path segments.");
|
|
773
|
+
path = abs(path);
|
|
774
|
+
path = normalize(path);
|
|
775
|
+
if (!path.length)
|
|
776
|
+
return [0, 0, 0, 0];
|
|
777
|
+
var bounds = [Infinity, Infinity, -Infinity, -Infinity];
|
|
778
|
+
for (var i = 0, l = path.length; i < l; i++) {
|
|
779
|
+
var points = path[i].slice(1);
|
|
780
|
+
for (var j = 0; j < points.length; j += 2) {
|
|
781
|
+
if (points[j + 0] < bounds[0])
|
|
782
|
+
bounds[0] = points[j + 0];
|
|
783
|
+
if (points[j + 1] < bounds[1])
|
|
784
|
+
bounds[1] = points[j + 1];
|
|
785
|
+
if (points[j + 0] > bounds[2])
|
|
786
|
+
bounds[2] = points[j + 0];
|
|
787
|
+
if (points[j + 1] > bounds[3])
|
|
788
|
+
bounds[3] = points[j + 1];
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
return bounds;
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
// node_modules/debounce/index.js
|
|
797
|
+
var require_debounce = __commonJS({
|
|
798
|
+
"node_modules/debounce/index.js"(exports, module2) {
|
|
799
|
+
function debounce(func, wait, immediate) {
|
|
800
|
+
var timeout, args, context, timestamp, result;
|
|
801
|
+
if (null == wait)
|
|
802
|
+
wait = 100;
|
|
803
|
+
function later() {
|
|
804
|
+
var last = Date.now() - timestamp;
|
|
805
|
+
if (last < wait && last >= 0) {
|
|
806
|
+
timeout = setTimeout(later, wait - last);
|
|
807
|
+
} else {
|
|
808
|
+
timeout = null;
|
|
809
|
+
if (!immediate) {
|
|
810
|
+
result = func.apply(context, args);
|
|
811
|
+
context = args = null;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
;
|
|
816
|
+
var debounced = function() {
|
|
817
|
+
context = this;
|
|
818
|
+
args = arguments;
|
|
819
|
+
timestamp = Date.now();
|
|
820
|
+
var callNow = immediate && !timeout;
|
|
821
|
+
if (!timeout)
|
|
822
|
+
timeout = setTimeout(later, wait);
|
|
823
|
+
if (callNow) {
|
|
824
|
+
result = func.apply(context, args);
|
|
825
|
+
context = args = null;
|
|
826
|
+
}
|
|
827
|
+
return result;
|
|
828
|
+
};
|
|
829
|
+
debounced.clear = function() {
|
|
830
|
+
if (timeout) {
|
|
831
|
+
clearTimeout(timeout);
|
|
832
|
+
timeout = null;
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
debounced.flush = function() {
|
|
836
|
+
if (timeout) {
|
|
837
|
+
result = func.apply(context, args);
|
|
838
|
+
context = args = null;
|
|
839
|
+
clearTimeout(timeout);
|
|
840
|
+
timeout = null;
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
return debounced;
|
|
844
|
+
}
|
|
845
|
+
debounce.debounce = debounce;
|
|
846
|
+
module2.exports = debounce;
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
|
|
850
|
+
// node_modules/svg-path-generator/lib/svg-path-generator.js
|
|
851
|
+
var require_svg_path_generator = __commonJS({
|
|
852
|
+
"node_modules/svg-path-generator/lib/svg-path-generator.js"(exports, module2) {
|
|
853
|
+
function SvgPathGenerator(path) {
|
|
854
|
+
if (!(this instanceof SvgPathGenerator)) {
|
|
855
|
+
return new SvgPathGenerator(path);
|
|
856
|
+
}
|
|
857
|
+
this.currentPath = (path || "") + " ";
|
|
858
|
+
this.isRelative = false;
|
|
859
|
+
}
|
|
860
|
+
module2.exports = SvgPathGenerator;
|
|
861
|
+
SvgPathGenerator.prototype.toString = function() {
|
|
862
|
+
return this.end();
|
|
863
|
+
};
|
|
864
|
+
SvgPathGenerator.prototype.moveTo = function() {
|
|
865
|
+
this._appendData("M", arguments);
|
|
866
|
+
return this;
|
|
867
|
+
};
|
|
868
|
+
SvgPathGenerator.prototype.close = SvgPathGenerator.prototype.closePath = function() {
|
|
869
|
+
this._appendData("Z", []);
|
|
870
|
+
return this;
|
|
871
|
+
};
|
|
872
|
+
SvgPathGenerator.prototype.lineTo = function() {
|
|
873
|
+
this._appendData("L", arguments);
|
|
874
|
+
return this;
|
|
875
|
+
};
|
|
876
|
+
SvgPathGenerator.prototype.horizontalLineTo = function(x) {
|
|
877
|
+
this._appendData("H", [x]);
|
|
878
|
+
return this;
|
|
879
|
+
};
|
|
880
|
+
SvgPathGenerator.prototype.verticalLineTo = function(y) {
|
|
881
|
+
this._appendData("V", [y]);
|
|
882
|
+
return this;
|
|
883
|
+
};
|
|
884
|
+
SvgPathGenerator.prototype.curveTo = function() {
|
|
885
|
+
this._appendData("C", arguments);
|
|
886
|
+
return this;
|
|
887
|
+
};
|
|
888
|
+
SvgPathGenerator.prototype.smoothCurveTo = function() {
|
|
889
|
+
this._appendData("S", arguments);
|
|
890
|
+
return this;
|
|
891
|
+
};
|
|
892
|
+
SvgPathGenerator.prototype.bezierCurveTo = function() {
|
|
893
|
+
this._appendData("Q", arguments);
|
|
894
|
+
return this;
|
|
895
|
+
};
|
|
896
|
+
SvgPathGenerator.prototype.smoothBezierCurveTo = function() {
|
|
897
|
+
this._appendData("T", arguments);
|
|
898
|
+
return this;
|
|
899
|
+
};
|
|
900
|
+
SvgPathGenerator.prototype.ellipticalArc = function() {
|
|
901
|
+
this._appendData("A", arguments);
|
|
902
|
+
return this;
|
|
903
|
+
};
|
|
904
|
+
SvgPathGenerator.prototype.relative = function() {
|
|
905
|
+
this.isRelative = true;
|
|
906
|
+
return this;
|
|
907
|
+
};
|
|
908
|
+
SvgPathGenerator.prototype.end = function() {
|
|
909
|
+
return this.currentPath.trim();
|
|
910
|
+
};
|
|
911
|
+
SvgPathGenerator.prototype._appendData = function(symbol, args) {
|
|
912
|
+
args = Array.prototype.slice.call(args);
|
|
913
|
+
if (this.isRelative) {
|
|
914
|
+
symbol = symbol.toLowerCase();
|
|
915
|
+
this.isRelative = false;
|
|
916
|
+
}
|
|
917
|
+
this.currentPath += symbol + " " + args.join(" ") + " ";
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
// node_modules/svg-path-generator/index.js
|
|
923
|
+
var require_svg_path_generator2 = __commonJS({
|
|
924
|
+
"node_modules/svg-path-generator/index.js"(exports, module2) {
|
|
925
|
+
module2.exports = require_svg_path_generator();
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
|
|
929
|
+
// node_modules/lodash/_baseRange.js
|
|
930
|
+
var require_baseRange = __commonJS({
|
|
931
|
+
"node_modules/lodash/_baseRange.js"(exports, module2) {
|
|
932
|
+
var nativeCeil = Math.ceil;
|
|
933
|
+
var nativeMax = Math.max;
|
|
934
|
+
function baseRange(start, end, step, fromRight) {
|
|
935
|
+
var index = -1, length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), result = Array(length);
|
|
936
|
+
while (length--) {
|
|
937
|
+
result[fromRight ? length : ++index] = start;
|
|
938
|
+
start += step;
|
|
939
|
+
}
|
|
940
|
+
return result;
|
|
941
|
+
}
|
|
942
|
+
module2.exports = baseRange;
|
|
943
|
+
}
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
// node_modules/lodash/eq.js
|
|
947
|
+
var require_eq = __commonJS({
|
|
948
|
+
"node_modules/lodash/eq.js"(exports, module2) {
|
|
949
|
+
function eq(value, other) {
|
|
950
|
+
return value === other || value !== value && other !== other;
|
|
951
|
+
}
|
|
952
|
+
module2.exports = eq;
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
// node_modules/lodash/_freeGlobal.js
|
|
957
|
+
var require_freeGlobal = __commonJS({
|
|
958
|
+
"node_modules/lodash/_freeGlobal.js"(exports, module2) {
|
|
959
|
+
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
960
|
+
module2.exports = freeGlobal;
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
// node_modules/lodash/_root.js
|
|
965
|
+
var require_root = __commonJS({
|
|
966
|
+
"node_modules/lodash/_root.js"(exports, module2) {
|
|
967
|
+
var freeGlobal = require_freeGlobal();
|
|
968
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
969
|
+
var root = freeGlobal || freeSelf || Function("return this")();
|
|
970
|
+
module2.exports = root;
|
|
971
|
+
}
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
// node_modules/lodash/_Symbol.js
|
|
975
|
+
var require_Symbol = __commonJS({
|
|
976
|
+
"node_modules/lodash/_Symbol.js"(exports, module2) {
|
|
977
|
+
var root = require_root();
|
|
978
|
+
var Symbol2 = root.Symbol;
|
|
979
|
+
module2.exports = Symbol2;
|
|
980
|
+
}
|
|
981
|
+
});
|
|
982
|
+
|
|
983
|
+
// node_modules/lodash/_getRawTag.js
|
|
984
|
+
var require_getRawTag = __commonJS({
|
|
985
|
+
"node_modules/lodash/_getRawTag.js"(exports, module2) {
|
|
986
|
+
var Symbol2 = require_Symbol();
|
|
987
|
+
var objectProto = Object.prototype;
|
|
988
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
989
|
+
var nativeObjectToString = objectProto.toString;
|
|
990
|
+
var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
|
|
991
|
+
function getRawTag(value) {
|
|
992
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
|
|
993
|
+
try {
|
|
994
|
+
value[symToStringTag] = void 0;
|
|
995
|
+
var unmasked = true;
|
|
996
|
+
} catch (e) {
|
|
997
|
+
}
|
|
998
|
+
var result = nativeObjectToString.call(value);
|
|
999
|
+
if (unmasked) {
|
|
1000
|
+
if (isOwn) {
|
|
1001
|
+
value[symToStringTag] = tag;
|
|
1002
|
+
} else {
|
|
1003
|
+
delete value[symToStringTag];
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
return result;
|
|
1007
|
+
}
|
|
1008
|
+
module2.exports = getRawTag;
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
|
|
1012
|
+
// node_modules/lodash/_objectToString.js
|
|
1013
|
+
var require_objectToString = __commonJS({
|
|
1014
|
+
"node_modules/lodash/_objectToString.js"(exports, module2) {
|
|
1015
|
+
var objectProto = Object.prototype;
|
|
1016
|
+
var nativeObjectToString = objectProto.toString;
|
|
1017
|
+
function objectToString(value) {
|
|
1018
|
+
return nativeObjectToString.call(value);
|
|
1019
|
+
}
|
|
1020
|
+
module2.exports = objectToString;
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
// node_modules/lodash/_baseGetTag.js
|
|
1025
|
+
var require_baseGetTag = __commonJS({
|
|
1026
|
+
"node_modules/lodash/_baseGetTag.js"(exports, module2) {
|
|
1027
|
+
var Symbol2 = require_Symbol();
|
|
1028
|
+
var getRawTag = require_getRawTag();
|
|
1029
|
+
var objectToString = require_objectToString();
|
|
1030
|
+
var nullTag = "[object Null]";
|
|
1031
|
+
var undefinedTag = "[object Undefined]";
|
|
1032
|
+
var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
|
|
1033
|
+
function baseGetTag(value) {
|
|
1034
|
+
if (value == null) {
|
|
1035
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
1036
|
+
}
|
|
1037
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
1038
|
+
}
|
|
1039
|
+
module2.exports = baseGetTag;
|
|
1040
|
+
}
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
// node_modules/lodash/isObject.js
|
|
1044
|
+
var require_isObject = __commonJS({
|
|
1045
|
+
"node_modules/lodash/isObject.js"(exports, module2) {
|
|
1046
|
+
function isObject2(value) {
|
|
1047
|
+
var type = typeof value;
|
|
1048
|
+
return value != null && (type == "object" || type == "function");
|
|
1049
|
+
}
|
|
1050
|
+
module2.exports = isObject2;
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
// node_modules/lodash/isFunction.js
|
|
1055
|
+
var require_isFunction = __commonJS({
|
|
1056
|
+
"node_modules/lodash/isFunction.js"(exports, module2) {
|
|
1057
|
+
var baseGetTag = require_baseGetTag();
|
|
1058
|
+
var isObject2 = require_isObject();
|
|
1059
|
+
var asyncTag = "[object AsyncFunction]";
|
|
1060
|
+
var funcTag = "[object Function]";
|
|
1061
|
+
var genTag = "[object GeneratorFunction]";
|
|
1062
|
+
var proxyTag = "[object Proxy]";
|
|
1063
|
+
function isFunction(value) {
|
|
1064
|
+
if (!isObject2(value)) {
|
|
1065
|
+
return false;
|
|
1066
|
+
}
|
|
1067
|
+
var tag = baseGetTag(value);
|
|
1068
|
+
return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
1069
|
+
}
|
|
1070
|
+
module2.exports = isFunction;
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
// node_modules/lodash/isLength.js
|
|
1075
|
+
var require_isLength = __commonJS({
|
|
1076
|
+
"node_modules/lodash/isLength.js"(exports, module2) {
|
|
1077
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
1078
|
+
function isLength(value) {
|
|
1079
|
+
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
1080
|
+
}
|
|
1081
|
+
module2.exports = isLength;
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
|
|
1085
|
+
// node_modules/lodash/isArrayLike.js
|
|
1086
|
+
var require_isArrayLike = __commonJS({
|
|
1087
|
+
"node_modules/lodash/isArrayLike.js"(exports, module2) {
|
|
1088
|
+
var isFunction = require_isFunction();
|
|
1089
|
+
var isLength = require_isLength();
|
|
1090
|
+
function isArrayLike(value) {
|
|
1091
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
1092
|
+
}
|
|
1093
|
+
module2.exports = isArrayLike;
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
// node_modules/lodash/_isIndex.js
|
|
1098
|
+
var require_isIndex = __commonJS({
|
|
1099
|
+
"node_modules/lodash/_isIndex.js"(exports, module2) {
|
|
1100
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
1101
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
1102
|
+
function isIndex(value, length) {
|
|
1103
|
+
var type = typeof value;
|
|
1104
|
+
length = length == null ? MAX_SAFE_INTEGER : length;
|
|
1105
|
+
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
1106
|
+
}
|
|
1107
|
+
module2.exports = isIndex;
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
// node_modules/lodash/_isIterateeCall.js
|
|
1112
|
+
var require_isIterateeCall = __commonJS({
|
|
1113
|
+
"node_modules/lodash/_isIterateeCall.js"(exports, module2) {
|
|
1114
|
+
var eq = require_eq();
|
|
1115
|
+
var isArrayLike = require_isArrayLike();
|
|
1116
|
+
var isIndex = require_isIndex();
|
|
1117
|
+
var isObject2 = require_isObject();
|
|
1118
|
+
function isIterateeCall(value, index, object) {
|
|
1119
|
+
if (!isObject2(object)) {
|
|
1120
|
+
return false;
|
|
1121
|
+
}
|
|
1122
|
+
var type = typeof index;
|
|
1123
|
+
if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) {
|
|
1124
|
+
return eq(object[index], value);
|
|
1125
|
+
}
|
|
1126
|
+
return false;
|
|
1127
|
+
}
|
|
1128
|
+
module2.exports = isIterateeCall;
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
// node_modules/lodash/_trimmedEndIndex.js
|
|
1133
|
+
var require_trimmedEndIndex = __commonJS({
|
|
1134
|
+
"node_modules/lodash/_trimmedEndIndex.js"(exports, module2) {
|
|
1135
|
+
var reWhitespace = /\s/;
|
|
1136
|
+
function trimmedEndIndex(string) {
|
|
1137
|
+
var index = string.length;
|
|
1138
|
+
while (index-- && reWhitespace.test(string.charAt(index))) {
|
|
1139
|
+
}
|
|
1140
|
+
return index;
|
|
1141
|
+
}
|
|
1142
|
+
module2.exports = trimmedEndIndex;
|
|
1143
|
+
}
|
|
1144
|
+
});
|
|
1145
|
+
|
|
1146
|
+
// node_modules/lodash/_baseTrim.js
|
|
1147
|
+
var require_baseTrim = __commonJS({
|
|
1148
|
+
"node_modules/lodash/_baseTrim.js"(exports, module2) {
|
|
1149
|
+
var trimmedEndIndex = require_trimmedEndIndex();
|
|
1150
|
+
var reTrimStart = /^\s+/;
|
|
1151
|
+
function baseTrim(string) {
|
|
1152
|
+
return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
|
|
1153
|
+
}
|
|
1154
|
+
module2.exports = baseTrim;
|
|
1155
|
+
}
|
|
1156
|
+
});
|
|
1157
|
+
|
|
1158
|
+
// node_modules/lodash/isObjectLike.js
|
|
1159
|
+
var require_isObjectLike = __commonJS({
|
|
1160
|
+
"node_modules/lodash/isObjectLike.js"(exports, module2) {
|
|
1161
|
+
function isObjectLike(value) {
|
|
1162
|
+
return value != null && typeof value == "object";
|
|
1163
|
+
}
|
|
1164
|
+
module2.exports = isObjectLike;
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
|
|
1168
|
+
// node_modules/lodash/isSymbol.js
|
|
1169
|
+
var require_isSymbol = __commonJS({
|
|
1170
|
+
"node_modules/lodash/isSymbol.js"(exports, module2) {
|
|
1171
|
+
var baseGetTag = require_baseGetTag();
|
|
1172
|
+
var isObjectLike = require_isObjectLike();
|
|
1173
|
+
var symbolTag = "[object Symbol]";
|
|
1174
|
+
function isSymbol(value) {
|
|
1175
|
+
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
|
|
1176
|
+
}
|
|
1177
|
+
module2.exports = isSymbol;
|
|
1178
|
+
}
|
|
1179
|
+
});
|
|
1180
|
+
|
|
1181
|
+
// node_modules/lodash/toNumber.js
|
|
1182
|
+
var require_toNumber = __commonJS({
|
|
1183
|
+
"node_modules/lodash/toNumber.js"(exports, module2) {
|
|
1184
|
+
var baseTrim = require_baseTrim();
|
|
1185
|
+
var isObject2 = require_isObject();
|
|
1186
|
+
var isSymbol = require_isSymbol();
|
|
1187
|
+
var NAN = 0 / 0;
|
|
1188
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
1189
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
1190
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
1191
|
+
var freeParseInt = parseInt;
|
|
1192
|
+
function toNumber(value) {
|
|
1193
|
+
if (typeof value == "number") {
|
|
1194
|
+
return value;
|
|
1195
|
+
}
|
|
1196
|
+
if (isSymbol(value)) {
|
|
1197
|
+
return NAN;
|
|
1198
|
+
}
|
|
1199
|
+
if (isObject2(value)) {
|
|
1200
|
+
var other = typeof value.valueOf == "function" ? value.valueOf() : value;
|
|
1201
|
+
value = isObject2(other) ? other + "" : other;
|
|
1202
|
+
}
|
|
1203
|
+
if (typeof value != "string") {
|
|
1204
|
+
return value === 0 ? value : +value;
|
|
1205
|
+
}
|
|
1206
|
+
value = baseTrim(value);
|
|
1207
|
+
var isBinary = reIsBinary.test(value);
|
|
1208
|
+
return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
|
|
1209
|
+
}
|
|
1210
|
+
module2.exports = toNumber;
|
|
1211
|
+
}
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
// node_modules/lodash/toFinite.js
|
|
1215
|
+
var require_toFinite = __commonJS({
|
|
1216
|
+
"node_modules/lodash/toFinite.js"(exports, module2) {
|
|
1217
|
+
var toNumber = require_toNumber();
|
|
1218
|
+
var INFINITY = 1 / 0;
|
|
1219
|
+
var MAX_INTEGER = 17976931348623157e292;
|
|
1220
|
+
function toFinite(value) {
|
|
1221
|
+
if (!value) {
|
|
1222
|
+
return value === 0 ? value : 0;
|
|
1223
|
+
}
|
|
1224
|
+
value = toNumber(value);
|
|
1225
|
+
if (value === INFINITY || value === -INFINITY) {
|
|
1226
|
+
var sign = value < 0 ? -1 : 1;
|
|
1227
|
+
return sign * MAX_INTEGER;
|
|
1228
|
+
}
|
|
1229
|
+
return value === value ? value : 0;
|
|
1230
|
+
}
|
|
1231
|
+
module2.exports = toFinite;
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
|
|
1235
|
+
// node_modules/lodash/_createRange.js
|
|
1236
|
+
var require_createRange = __commonJS({
|
|
1237
|
+
"node_modules/lodash/_createRange.js"(exports, module2) {
|
|
1238
|
+
var baseRange = require_baseRange();
|
|
1239
|
+
var isIterateeCall = require_isIterateeCall();
|
|
1240
|
+
var toFinite = require_toFinite();
|
|
1241
|
+
function createRange(fromRight) {
|
|
1242
|
+
return function(start, end, step) {
|
|
1243
|
+
if (step && typeof step != "number" && isIterateeCall(start, end, step)) {
|
|
1244
|
+
end = step = void 0;
|
|
1245
|
+
}
|
|
1246
|
+
start = toFinite(start);
|
|
1247
|
+
if (end === void 0) {
|
|
1248
|
+
end = start;
|
|
1249
|
+
start = 0;
|
|
1250
|
+
} else {
|
|
1251
|
+
end = toFinite(end);
|
|
1252
|
+
}
|
|
1253
|
+
step = step === void 0 ? start < end ? 1 : -1 : toFinite(step);
|
|
1254
|
+
return baseRange(start, end, step, fromRight);
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
module2.exports = createRange;
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
|
|
1261
|
+
// node_modules/lodash/range.js
|
|
1262
|
+
var require_range = __commonJS({
|
|
1263
|
+
"node_modules/lodash/range.js"(exports, module2) {
|
|
1264
|
+
var createRange = require_createRange();
|
|
1265
|
+
var range2 = createRange();
|
|
1266
|
+
module2.exports = range2;
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
1269
|
+
|
|
1270
|
+
// src/index.ts
|
|
1271
|
+
var src_exports = {};
|
|
1272
|
+
__export(src_exports, {
|
|
1273
|
+
Schematic: () => Schematic
|
|
1274
|
+
});
|
|
1275
|
+
module.exports = __toCommonJS(src_exports);
|
|
1276
|
+
|
|
1277
|
+
// src/Schematic.tsx
|
|
1278
|
+
var import_react4 = require("react");
|
|
1279
|
+
var import_builder2 = require("@tscircuit/builder");
|
|
1280
|
+
var import_react_fiber = require("@tscircuit/react-fiber");
|
|
1281
|
+
|
|
1282
|
+
// src/lib/utils/collect-element-refs.ts
|
|
1283
|
+
var collectElementRefs = (elm, allElms) => {
|
|
1284
|
+
const source_component = allElms.find(
|
|
1285
|
+
(e) => e.type === "source_component" && e.source_component_id === elm.source_component_id
|
|
1286
|
+
);
|
|
1287
|
+
if (["schematic_component", "schematic_trace", "schematic_port"].includes(
|
|
1288
|
+
elm.type
|
|
1289
|
+
)) {
|
|
1290
|
+
return {
|
|
1291
|
+
schematic: elm,
|
|
1292
|
+
source: source_component
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
return null;
|
|
1296
|
+
};
|
|
1297
|
+
|
|
1298
|
+
// src/schematic-components/MovableGrid/index.tsx
|
|
1299
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1300
|
+
|
|
1301
|
+
// node_modules/zustand/esm/vanilla.mjs
|
|
1302
|
+
var createStoreImpl = (createState) => {
|
|
1303
|
+
let state;
|
|
1304
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
1305
|
+
const setState = (partial, replace) => {
|
|
1306
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
1307
|
+
if (nextState !== state) {
|
|
1308
|
+
const previousState = state;
|
|
1309
|
+
state = replace ? nextState : Object.assign({}, state, nextState);
|
|
1310
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
const getState = () => state;
|
|
1314
|
+
const subscribe = (listener) => {
|
|
1315
|
+
listeners.add(listener);
|
|
1316
|
+
return () => listeners.delete(listener);
|
|
1317
|
+
};
|
|
1318
|
+
const destroy = () => listeners.clear();
|
|
1319
|
+
const api = { setState, getState, subscribe, destroy };
|
|
1320
|
+
state = createState(
|
|
1321
|
+
setState,
|
|
1322
|
+
getState,
|
|
1323
|
+
api
|
|
1324
|
+
);
|
|
1325
|
+
return api;
|
|
1326
|
+
};
|
|
1327
|
+
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
1328
|
+
|
|
1329
|
+
// node_modules/zustand/esm/index.mjs
|
|
1330
|
+
var import_react = require("react");
|
|
1331
|
+
var import_with_selector = __toESM(require_with_selector(), 1);
|
|
1332
|
+
var { useSyncExternalStoreWithSelector } = import_with_selector.default;
|
|
1333
|
+
function useStore(api, selector = api.getState, equalityFn) {
|
|
1334
|
+
const slice = useSyncExternalStoreWithSelector(
|
|
1335
|
+
api.subscribe,
|
|
1336
|
+
api.getState,
|
|
1337
|
+
api.getServerState || api.getState,
|
|
1338
|
+
selector,
|
|
1339
|
+
equalityFn
|
|
1340
|
+
);
|
|
1341
|
+
(0, import_react.useDebugValue)(slice);
|
|
1342
|
+
return slice;
|
|
1343
|
+
}
|
|
1344
|
+
var createImpl = (createState) => {
|
|
1345
|
+
const api = typeof createState === "function" ? createStore(createState) : createState;
|
|
1346
|
+
const useBoundStore = (selector, equalityFn) => useStore(api, selector, equalityFn);
|
|
1347
|
+
Object.assign(useBoundStore, api);
|
|
1348
|
+
return useBoundStore;
|
|
1349
|
+
};
|
|
1350
|
+
var create = (createState) => createState ? createImpl(createState) : createImpl;
|
|
1351
|
+
var create$1 = create;
|
|
1352
|
+
|
|
1353
|
+
// node_modules/transformation-matrix/src/applyToPoint.js
|
|
1354
|
+
function applyToPoint(matrix, point) {
|
|
1355
|
+
return Array.isArray(point) ? [
|
|
1356
|
+
matrix.a * point[0] + matrix.c * point[1] + matrix.e,
|
|
1357
|
+
matrix.b * point[0] + matrix.d * point[1] + matrix.f
|
|
1358
|
+
] : {
|
|
1359
|
+
x: matrix.a * point.x + matrix.c * point.y + matrix.e,
|
|
1360
|
+
y: matrix.b * point.x + matrix.d * point.y + matrix.f
|
|
1361
|
+
};
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
// node_modules/transformation-matrix/src/utils.js
|
|
1365
|
+
function isUndefined(val) {
|
|
1366
|
+
return typeof val === "undefined";
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
// node_modules/transformation-matrix/src/translate.js
|
|
1370
|
+
function translate(tx, ty = 0) {
|
|
1371
|
+
return {
|
|
1372
|
+
a: 1,
|
|
1373
|
+
c: 0,
|
|
1374
|
+
e: tx,
|
|
1375
|
+
b: 0,
|
|
1376
|
+
d: 1,
|
|
1377
|
+
f: ty
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
// node_modules/transformation-matrix/src/transform.js
|
|
1382
|
+
function transform(...matrices) {
|
|
1383
|
+
matrices = Array.isArray(matrices[0]) ? matrices[0] : matrices;
|
|
1384
|
+
const multiply = (m1, m2) => {
|
|
1385
|
+
return {
|
|
1386
|
+
a: m1.a * m2.a + m1.c * m2.b,
|
|
1387
|
+
c: m1.a * m2.c + m1.c * m2.d,
|
|
1388
|
+
e: m1.a * m2.e + m1.c * m2.f + m1.e,
|
|
1389
|
+
b: m1.b * m2.a + m1.d * m2.b,
|
|
1390
|
+
d: m1.b * m2.c + m1.d * m2.d,
|
|
1391
|
+
f: m1.b * m2.e + m1.d * m2.f + m1.f
|
|
1392
|
+
};
|
|
1393
|
+
};
|
|
1394
|
+
switch (matrices.length) {
|
|
1395
|
+
case 0:
|
|
1396
|
+
throw new Error("no matrices provided");
|
|
1397
|
+
case 1:
|
|
1398
|
+
return matrices[0];
|
|
1399
|
+
case 2:
|
|
1400
|
+
return multiply(matrices[0], matrices[1]);
|
|
1401
|
+
default: {
|
|
1402
|
+
const [m1, m2, ...rest] = matrices;
|
|
1403
|
+
const m = multiply(m1, m2);
|
|
1404
|
+
return transform(m, ...rest);
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
function compose(...matrices) {
|
|
1409
|
+
return transform(...matrices);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
// node_modules/transformation-matrix/src/rotate.js
|
|
1413
|
+
var { cos, sin, PI } = Math;
|
|
1414
|
+
|
|
1415
|
+
// node_modules/transformation-matrix/src/scale.js
|
|
1416
|
+
function scale(sx, sy = void 0, cx = void 0, cy = void 0) {
|
|
1417
|
+
if (isUndefined(sy))
|
|
1418
|
+
sy = sx;
|
|
1419
|
+
const scaleMatrix = {
|
|
1420
|
+
a: sx,
|
|
1421
|
+
c: 0,
|
|
1422
|
+
e: 0,
|
|
1423
|
+
b: 0,
|
|
1424
|
+
d: sy,
|
|
1425
|
+
f: 0
|
|
1426
|
+
};
|
|
1427
|
+
if (isUndefined(cx) || isUndefined(cy)) {
|
|
1428
|
+
return scaleMatrix;
|
|
1429
|
+
}
|
|
1430
|
+
return transform([
|
|
1431
|
+
translate(cx, cy),
|
|
1432
|
+
scaleMatrix,
|
|
1433
|
+
translate(-cx, -cy)
|
|
1434
|
+
]);
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1437
|
+
// node_modules/transformation-matrix/src/skew.js
|
|
1438
|
+
var { tan } = Math;
|
|
1439
|
+
|
|
1440
|
+
// node_modules/transformation-matrix/src/fromTransformAttribute.autogenerated.js
|
|
1441
|
+
function peg$subclass(child, parent) {
|
|
1442
|
+
function C() {
|
|
1443
|
+
this.constructor = child;
|
|
1444
|
+
}
|
|
1445
|
+
C.prototype = parent.prototype;
|
|
1446
|
+
child.prototype = new C();
|
|
1447
|
+
}
|
|
1448
|
+
function peg$SyntaxError(message, expected, found, location) {
|
|
1449
|
+
var self2 = Error.call(this, message);
|
|
1450
|
+
if (Object.setPrototypeOf) {
|
|
1451
|
+
Object.setPrototypeOf(self2, peg$SyntaxError.prototype);
|
|
1452
|
+
}
|
|
1453
|
+
self2.expected = expected;
|
|
1454
|
+
self2.found = found;
|
|
1455
|
+
self2.location = location;
|
|
1456
|
+
self2.name = "SyntaxError";
|
|
1457
|
+
return self2;
|
|
1458
|
+
}
|
|
1459
|
+
peg$subclass(peg$SyntaxError, Error);
|
|
1460
|
+
function peg$padEnd(str, targetLength, padString) {
|
|
1461
|
+
padString = padString || " ";
|
|
1462
|
+
if (str.length > targetLength) {
|
|
1463
|
+
return str;
|
|
1464
|
+
}
|
|
1465
|
+
targetLength -= str.length;
|
|
1466
|
+
padString += padString.repeat(targetLength);
|
|
1467
|
+
return str + padString.slice(0, targetLength);
|
|
1468
|
+
}
|
|
1469
|
+
peg$SyntaxError.prototype.format = function(sources) {
|
|
1470
|
+
var str = "Error: " + this.message;
|
|
1471
|
+
if (this.location) {
|
|
1472
|
+
var src = null;
|
|
1473
|
+
var k;
|
|
1474
|
+
for (k = 0; k < sources.length; k++) {
|
|
1475
|
+
if (sources[k].source === this.location.source) {
|
|
1476
|
+
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
1477
|
+
break;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
var s = this.location.start;
|
|
1481
|
+
var loc = this.location.source + ":" + s.line + ":" + s.column;
|
|
1482
|
+
if (src) {
|
|
1483
|
+
var e = this.location.end;
|
|
1484
|
+
var filler = peg$padEnd("", s.line.toString().length, " ");
|
|
1485
|
+
var line = src[s.line - 1];
|
|
1486
|
+
var last = s.line === e.line ? e.column : line.length + 1;
|
|
1487
|
+
var hatLen = last - s.column || 1;
|
|
1488
|
+
str += "\n --> " + loc + "\n" + filler + " |\n" + s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
1489
|
+
} else {
|
|
1490
|
+
str += "\n at " + loc;
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
return str;
|
|
1494
|
+
};
|
|
1495
|
+
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
1496
|
+
var DESCRIBE_EXPECTATION_FNS = {
|
|
1497
|
+
literal: function(expectation) {
|
|
1498
|
+
return '"' + literalEscape(expectation.text) + '"';
|
|
1499
|
+
},
|
|
1500
|
+
class: function(expectation) {
|
|
1501
|
+
var escapedParts = expectation.parts.map(function(part) {
|
|
1502
|
+
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
1503
|
+
});
|
|
1504
|
+
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
1505
|
+
},
|
|
1506
|
+
any: function() {
|
|
1507
|
+
return "any character";
|
|
1508
|
+
},
|
|
1509
|
+
end: function() {
|
|
1510
|
+
return "end of input";
|
|
1511
|
+
},
|
|
1512
|
+
other: function(expectation) {
|
|
1513
|
+
return expectation.description;
|
|
1514
|
+
}
|
|
1515
|
+
};
|
|
1516
|
+
function hex(ch) {
|
|
1517
|
+
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
1518
|
+
}
|
|
1519
|
+
function literalEscape(s) {
|
|
1520
|
+
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
1521
|
+
return "\\x0" + hex(ch);
|
|
1522
|
+
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
1523
|
+
return "\\x" + hex(ch);
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
function classEscape(s) {
|
|
1527
|
+
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
1528
|
+
return "\\x0" + hex(ch);
|
|
1529
|
+
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
1530
|
+
return "\\x" + hex(ch);
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
function describeExpectation(expectation) {
|
|
1534
|
+
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
1535
|
+
}
|
|
1536
|
+
function describeExpected(expected2) {
|
|
1537
|
+
var descriptions = expected2.map(describeExpectation);
|
|
1538
|
+
var i, j;
|
|
1539
|
+
descriptions.sort();
|
|
1540
|
+
if (descriptions.length > 0) {
|
|
1541
|
+
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
1542
|
+
if (descriptions[i - 1] !== descriptions[i]) {
|
|
1543
|
+
descriptions[j] = descriptions[i];
|
|
1544
|
+
j++;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
descriptions.length = j;
|
|
1548
|
+
}
|
|
1549
|
+
switch (descriptions.length) {
|
|
1550
|
+
case 1:
|
|
1551
|
+
return descriptions[0];
|
|
1552
|
+
case 2:
|
|
1553
|
+
return descriptions[0] + " or " + descriptions[1];
|
|
1554
|
+
default:
|
|
1555
|
+
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
function describeFound(found2) {
|
|
1559
|
+
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
1560
|
+
}
|
|
1561
|
+
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
1562
|
+
};
|
|
1563
|
+
|
|
1564
|
+
// src/lib/render-context/index.ts
|
|
1565
|
+
var useRenderContext = create$1((set, get) => ({
|
|
1566
|
+
camera_transform: compose(scale(100, 100, 0, 0)),
|
|
1567
|
+
setCameraTransform: (transform2) => set({ camera_transform: transform2 })
|
|
1568
|
+
}));
|
|
1569
|
+
var useCameraTransform = () => useRenderContext((s) => s.camera_transform);
|
|
1570
|
+
|
|
1571
|
+
// src/lib/utils/get-svg-path-bounds.ts
|
|
1572
|
+
var import_svg_path_bounds = __toESM(require_svg_path_bounds());
|
|
1573
|
+
function getSVGPathBounds(ds) {
|
|
1574
|
+
if (typeof ds === "string")
|
|
1575
|
+
ds = [ds];
|
|
1576
|
+
let minX = Infinity, maxX = -Infinity, minY = Infinity, maxY = -Infinity;
|
|
1577
|
+
for (const d of ds) {
|
|
1578
|
+
const [left, top, right, bottom] = (0, import_svg_path_bounds.default)(d);
|
|
1579
|
+
minX = Math.min(left, minX);
|
|
1580
|
+
maxX = Math.max(right, maxX);
|
|
1581
|
+
minY = Math.min(top, minY);
|
|
1582
|
+
maxY = Math.max(bottom, maxY);
|
|
1583
|
+
}
|
|
1584
|
+
return { minX, maxX, minY, maxY, width: maxX - minX, height: maxY - minY };
|
|
1585
|
+
}
|
|
1586
|
+
var get_svg_path_bounds_default = getSVGPathBounds;
|
|
1587
|
+
|
|
1588
|
+
// src/schematic-components/SVGPathComponent.tsx
|
|
1589
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1590
|
+
var SVGPathComponent = ({ size, center, rotation, paths }) => {
|
|
1591
|
+
const ct = useCameraTransform();
|
|
1592
|
+
const pathBounds = get_svg_path_bounds_default(paths.map((p) => p.d));
|
|
1593
|
+
const badRatio = Math.abs(pathBounds.width / pathBounds.height - size.width / size.height) > 0.01;
|
|
1594
|
+
if (badRatio) {
|
|
1595
|
+
console.warn(
|
|
1596
|
+
`Ratio doesn't match for component. ${pathBounds.width}:${pathBounds.height} is not close to ${size.width}:${size.height}`
|
|
1597
|
+
);
|
|
1598
|
+
}
|
|
1599
|
+
pathBounds.height = Math.max(pathBounds.height, 1);
|
|
1600
|
+
pathBounds.width = Math.max(pathBounds.width, 1);
|
|
1601
|
+
const absoluteCenter = applyToPoint(ct, center);
|
|
1602
|
+
const absoluteSize = {
|
|
1603
|
+
width: Math.max(1, size.width * ct.a),
|
|
1604
|
+
height: Math.max(1, size.height * ct.d)
|
|
1605
|
+
};
|
|
1606
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", {
|
|
1607
|
+
style: {
|
|
1608
|
+
position: "absolute",
|
|
1609
|
+
transform: rotation === 0 ? "" : `rotate(${rotation}rad)`,
|
|
1610
|
+
left: absoluteCenter.x - absoluteSize.width / 2,
|
|
1611
|
+
top: absoluteCenter.y - absoluteSize.height / 2
|
|
1612
|
+
},
|
|
1613
|
+
overflow: "visible",
|
|
1614
|
+
width: absoluteSize.width,
|
|
1615
|
+
height: absoluteSize.height,
|
|
1616
|
+
viewBox: `${pathBounds.minX} ${pathBounds.minY} ${pathBounds.width} ${pathBounds.height}`,
|
|
1617
|
+
children: paths.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", {
|
|
1618
|
+
fill: "none",
|
|
1619
|
+
strokeWidth: 2 * (p.strokeWidth || 1),
|
|
1620
|
+
stroke: p.stroke || "red",
|
|
1621
|
+
d: p.d
|
|
1622
|
+
}, i))
|
|
1623
|
+
});
|
|
1624
|
+
};
|
|
1625
|
+
var SVGPathComponent_default = SVGPathComponent;
|
|
1626
|
+
|
|
1627
|
+
// src/schematic-components/SimpleResistor.tsx
|
|
1628
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1629
|
+
var SimpleResistor = ({ component: { source, schematic } }) => {
|
|
1630
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SVGPathComponent_default, {
|
|
1631
|
+
rotation: schematic.rotation,
|
|
1632
|
+
center: schematic.center,
|
|
1633
|
+
size: schematic.size,
|
|
1634
|
+
paths: [
|
|
1635
|
+
{
|
|
1636
|
+
stroke: "red",
|
|
1637
|
+
strokeWidth: 1,
|
|
1638
|
+
d: "M 0 15 l 10 0 l 0 -6 l 20 0 l 0 12 l -20 0 l 0 -6 m 20 0 l 10 0"
|
|
1639
|
+
}
|
|
1640
|
+
]
|
|
1641
|
+
});
|
|
1642
|
+
};
|
|
1643
|
+
|
|
1644
|
+
// src/schematic-components/SimpleCapacitor.tsx
|
|
1645
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1646
|
+
var SimpleCapacitor = ({
|
|
1647
|
+
component: { source, schematic }
|
|
1648
|
+
}) => {
|
|
1649
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SVGPathComponent_default, {
|
|
1650
|
+
rotation: schematic.rotation,
|
|
1651
|
+
center: schematic.center,
|
|
1652
|
+
size: schematic.size,
|
|
1653
|
+
paths: [
|
|
1654
|
+
{ stroke: "red", strokeWidth: 1, d: "M 0 15 l 12 0" },
|
|
1655
|
+
{ stroke: "red", strokeWidth: 2, d: "M 12 0 l 0 30" },
|
|
1656
|
+
{ stroke: "red", strokeWidth: 2, d: "M 18 0 l 0 30" },
|
|
1657
|
+
{ stroke: "red", strokeWidth: 1, d: "M 18 15 l 12 0" }
|
|
1658
|
+
]
|
|
1659
|
+
});
|
|
1660
|
+
};
|
|
1661
|
+
|
|
1662
|
+
// src/lib/hooks/use-maybe-promise.ts
|
|
1663
|
+
var import_react2 = require("react");
|
|
1664
|
+
|
|
1665
|
+
// src/schematic-components/ProjectComponent.tsx
|
|
1666
|
+
var import_builder = require("@tscircuit/builder");
|
|
1667
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1668
|
+
|
|
1669
|
+
// src/lib/utils/direction-to-vec.ts
|
|
1670
|
+
var directionToVec = (direction) => {
|
|
1671
|
+
if (direction === "up")
|
|
1672
|
+
return { x: 0, y: -1 };
|
|
1673
|
+
else if (direction === "down")
|
|
1674
|
+
return { x: 0, y: 1 };
|
|
1675
|
+
else if (direction === "left")
|
|
1676
|
+
return { x: -1, y: 0 };
|
|
1677
|
+
else if (direction === "right")
|
|
1678
|
+
return { x: 1, y: 0 };
|
|
1679
|
+
else
|
|
1680
|
+
throw new Error("Invalid direction");
|
|
1681
|
+
};
|
|
1682
|
+
|
|
1683
|
+
// src/schematic-components/SchematicPort.tsx
|
|
1684
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1685
|
+
var SchematicPort = ({ port: { source, schematic } }) => {
|
|
1686
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SVGPathComponent, {
|
|
1687
|
+
rotation: 0,
|
|
1688
|
+
center: schematic.center,
|
|
1689
|
+
size: { width: 0.2, height: 0.2 },
|
|
1690
|
+
paths: [
|
|
1691
|
+
{
|
|
1692
|
+
stroke: "blue",
|
|
1693
|
+
strokeWidth: 1,
|
|
1694
|
+
d: "M 0 0 l 10 0 l 0 10 l -10 0 z"
|
|
1695
|
+
},
|
|
1696
|
+
schematic.facing_direction ? {
|
|
1697
|
+
stroke: "blue",
|
|
1698
|
+
strokeWidth: 0.5,
|
|
1699
|
+
d: `M 5 5 l ${directionToVec(schematic.facing_direction).x * 7} ${directionToVec(schematic.facing_direction).y * 7}`
|
|
1700
|
+
} : null
|
|
1701
|
+
].filter(Boolean)
|
|
1702
|
+
});
|
|
1703
|
+
};
|
|
1704
|
+
var SchematicPort_default = SchematicPort;
|
|
1705
|
+
|
|
1706
|
+
// node_modules/react-use-measure/dist/web.js
|
|
1707
|
+
var import_react3 = require("react");
|
|
1708
|
+
var import_debounce = __toESM(require_debounce());
|
|
1709
|
+
function useMeasure(_temp) {
|
|
1710
|
+
let {
|
|
1711
|
+
debounce,
|
|
1712
|
+
scroll,
|
|
1713
|
+
polyfill,
|
|
1714
|
+
offsetSize
|
|
1715
|
+
} = _temp === void 0 ? {
|
|
1716
|
+
debounce: 0,
|
|
1717
|
+
scroll: false,
|
|
1718
|
+
offsetSize: false
|
|
1719
|
+
} : _temp;
|
|
1720
|
+
const ResizeObserver = polyfill || (typeof window === "undefined" ? class ResizeObserver {
|
|
1721
|
+
} : window.ResizeObserver);
|
|
1722
|
+
if (!ResizeObserver) {
|
|
1723
|
+
throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");
|
|
1724
|
+
}
|
|
1725
|
+
const [bounds, set] = (0, import_react3.useState)({
|
|
1726
|
+
left: 0,
|
|
1727
|
+
top: 0,
|
|
1728
|
+
width: 0,
|
|
1729
|
+
height: 0,
|
|
1730
|
+
bottom: 0,
|
|
1731
|
+
right: 0,
|
|
1732
|
+
x: 0,
|
|
1733
|
+
y: 0
|
|
1734
|
+
});
|
|
1735
|
+
const state = (0, import_react3.useRef)({
|
|
1736
|
+
element: null,
|
|
1737
|
+
scrollContainers: null,
|
|
1738
|
+
resizeObserver: null,
|
|
1739
|
+
lastBounds: bounds
|
|
1740
|
+
});
|
|
1741
|
+
const scrollDebounce = debounce ? typeof debounce === "number" ? debounce : debounce.scroll : null;
|
|
1742
|
+
const resizeDebounce = debounce ? typeof debounce === "number" ? debounce : debounce.resize : null;
|
|
1743
|
+
const mounted = (0, import_react3.useRef)(false);
|
|
1744
|
+
(0, import_react3.useEffect)(() => {
|
|
1745
|
+
mounted.current = true;
|
|
1746
|
+
return () => void (mounted.current = false);
|
|
1747
|
+
});
|
|
1748
|
+
const [forceRefresh, resizeChange, scrollChange] = (0, import_react3.useMemo)(() => {
|
|
1749
|
+
const callback = () => {
|
|
1750
|
+
if (!state.current.element)
|
|
1751
|
+
return;
|
|
1752
|
+
const {
|
|
1753
|
+
left,
|
|
1754
|
+
top,
|
|
1755
|
+
width,
|
|
1756
|
+
height,
|
|
1757
|
+
bottom,
|
|
1758
|
+
right,
|
|
1759
|
+
x,
|
|
1760
|
+
y
|
|
1761
|
+
} = state.current.element.getBoundingClientRect();
|
|
1762
|
+
const size = {
|
|
1763
|
+
left,
|
|
1764
|
+
top,
|
|
1765
|
+
width,
|
|
1766
|
+
height,
|
|
1767
|
+
bottom,
|
|
1768
|
+
right,
|
|
1769
|
+
x,
|
|
1770
|
+
y
|
|
1771
|
+
};
|
|
1772
|
+
if (state.current.element instanceof HTMLElement && offsetSize) {
|
|
1773
|
+
size.height = state.current.element.offsetHeight;
|
|
1774
|
+
size.width = state.current.element.offsetWidth;
|
|
1775
|
+
}
|
|
1776
|
+
Object.freeze(size);
|
|
1777
|
+
if (mounted.current && !areBoundsEqual(state.current.lastBounds, size))
|
|
1778
|
+
set(state.current.lastBounds = size);
|
|
1779
|
+
};
|
|
1780
|
+
return [callback, resizeDebounce ? (0, import_debounce.default)(callback, resizeDebounce) : callback, scrollDebounce ? (0, import_debounce.default)(callback, scrollDebounce) : callback];
|
|
1781
|
+
}, [set, offsetSize, scrollDebounce, resizeDebounce]);
|
|
1782
|
+
function removeListeners() {
|
|
1783
|
+
if (state.current.scrollContainers) {
|
|
1784
|
+
state.current.scrollContainers.forEach((element) => element.removeEventListener("scroll", scrollChange, true));
|
|
1785
|
+
state.current.scrollContainers = null;
|
|
1786
|
+
}
|
|
1787
|
+
if (state.current.resizeObserver) {
|
|
1788
|
+
state.current.resizeObserver.disconnect();
|
|
1789
|
+
state.current.resizeObserver = null;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
function addListeners() {
|
|
1793
|
+
if (!state.current.element)
|
|
1794
|
+
return;
|
|
1795
|
+
state.current.resizeObserver = new ResizeObserver(scrollChange);
|
|
1796
|
+
state.current.resizeObserver.observe(state.current.element);
|
|
1797
|
+
if (scroll && state.current.scrollContainers) {
|
|
1798
|
+
state.current.scrollContainers.forEach((scrollContainer) => scrollContainer.addEventListener("scroll", scrollChange, {
|
|
1799
|
+
capture: true,
|
|
1800
|
+
passive: true
|
|
1801
|
+
}));
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
const ref = (node) => {
|
|
1805
|
+
if (!node || node === state.current.element)
|
|
1806
|
+
return;
|
|
1807
|
+
removeListeners();
|
|
1808
|
+
state.current.element = node;
|
|
1809
|
+
state.current.scrollContainers = findScrollContainers(node);
|
|
1810
|
+
addListeners();
|
|
1811
|
+
};
|
|
1812
|
+
useOnWindowScroll(scrollChange, Boolean(scroll));
|
|
1813
|
+
useOnWindowResize(resizeChange);
|
|
1814
|
+
(0, import_react3.useEffect)(() => {
|
|
1815
|
+
removeListeners();
|
|
1816
|
+
addListeners();
|
|
1817
|
+
}, [scroll, scrollChange, resizeChange]);
|
|
1818
|
+
(0, import_react3.useEffect)(() => removeListeners, []);
|
|
1819
|
+
return [ref, bounds, forceRefresh];
|
|
1820
|
+
}
|
|
1821
|
+
function useOnWindowResize(onWindowResize) {
|
|
1822
|
+
(0, import_react3.useEffect)(() => {
|
|
1823
|
+
const cb = onWindowResize;
|
|
1824
|
+
window.addEventListener("resize", cb);
|
|
1825
|
+
return () => void window.removeEventListener("resize", cb);
|
|
1826
|
+
}, [onWindowResize]);
|
|
1827
|
+
}
|
|
1828
|
+
function useOnWindowScroll(onScroll, enabled) {
|
|
1829
|
+
(0, import_react3.useEffect)(() => {
|
|
1830
|
+
if (enabled) {
|
|
1831
|
+
const cb = onScroll;
|
|
1832
|
+
window.addEventListener("scroll", cb, {
|
|
1833
|
+
capture: true,
|
|
1834
|
+
passive: true
|
|
1835
|
+
});
|
|
1836
|
+
return () => void window.removeEventListener("scroll", cb, true);
|
|
1837
|
+
}
|
|
1838
|
+
}, [onScroll, enabled]);
|
|
1839
|
+
}
|
|
1840
|
+
function findScrollContainers(element) {
|
|
1841
|
+
const result = [];
|
|
1842
|
+
if (!element || element === document.body)
|
|
1843
|
+
return result;
|
|
1844
|
+
const {
|
|
1845
|
+
overflow,
|
|
1846
|
+
overflowX,
|
|
1847
|
+
overflowY
|
|
1848
|
+
} = window.getComputedStyle(element);
|
|
1849
|
+
if ([overflow, overflowX, overflowY].some((prop) => prop === "auto" || prop === "scroll"))
|
|
1850
|
+
result.push(element);
|
|
1851
|
+
return [...result, ...findScrollContainers(element.parentElement)];
|
|
1852
|
+
}
|
|
1853
|
+
var keys = ["x", "y", "top", "bottom", "left", "right", "width", "height"];
|
|
1854
|
+
var areBoundsEqual = (a, b) => keys.every((key) => a[key] === b[key]);
|
|
1855
|
+
|
|
1856
|
+
// src/schematic-components/SchematicText.tsx
|
|
1857
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1858
|
+
var SchematicText = ({ schematic_text }) => {
|
|
1859
|
+
const ct = useCameraTransform();
|
|
1860
|
+
const { text, position, anchor } = schematic_text;
|
|
1861
|
+
const tPos = applyToPoint(ct, position);
|
|
1862
|
+
const [boundsRef, bounds] = useMeasure();
|
|
1863
|
+
let offset = [0, 0];
|
|
1864
|
+
if (anchor === "center") {
|
|
1865
|
+
offset = [-bounds.width / 2, -bounds.height / 2];
|
|
1866
|
+
} else if (anchor === "left") {
|
|
1867
|
+
offset = [0, -bounds.height / 2];
|
|
1868
|
+
} else if (anchor === "right") {
|
|
1869
|
+
offset = [-bounds.width, -bounds.height / 2];
|
|
1870
|
+
}
|
|
1871
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", {
|
|
1872
|
+
ref: boundsRef,
|
|
1873
|
+
style: {
|
|
1874
|
+
fontFamily: "'IBM Plex Mono', monospace",
|
|
1875
|
+
position: "absolute",
|
|
1876
|
+
left: tPos.x + offset[0],
|
|
1877
|
+
top: tPos.y + offset[1]
|
|
1878
|
+
},
|
|
1879
|
+
children: text
|
|
1880
|
+
});
|
|
1881
|
+
};
|
|
1882
|
+
var SchematicText_default = SchematicText;
|
|
1883
|
+
|
|
1884
|
+
// src/schematic-components/SchematicTrace.tsx
|
|
1885
|
+
var import_svg_path_generator = __toESM(require_svg_path_generator2());
|
|
1886
|
+
|
|
1887
|
+
// src/schematic-components/RenderError.tsx
|
|
1888
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1889
|
+
var RenderError_default = ({ text }) => {
|
|
1890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", {
|
|
1891
|
+
style: {
|
|
1892
|
+
position: "fixed",
|
|
1893
|
+
backgroundColor: "red",
|
|
1894
|
+
color: "white",
|
|
1895
|
+
fontSize: 14,
|
|
1896
|
+
fontFamily: "sans-serif",
|
|
1897
|
+
padding: 5,
|
|
1898
|
+
right: 0,
|
|
1899
|
+
top: 0,
|
|
1900
|
+
opacity: 0.75
|
|
1901
|
+
},
|
|
1902
|
+
children: text
|
|
1903
|
+
});
|
|
1904
|
+
};
|
|
1905
|
+
|
|
1906
|
+
// src/schematic-components/SchematicTrace.tsx
|
|
1907
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1908
|
+
var SchematicTrace = ({ trace: { source, schematic } }) => {
|
|
1909
|
+
const edges = schematic.edges;
|
|
1910
|
+
if (edges.length === 0) {
|
|
1911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RenderError_default, {
|
|
1912
|
+
text: "Route with 0 edges"
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
const path = (0, import_svg_path_generator.default)();
|
|
1916
|
+
for (let i = 0; i < edges.length; i++) {
|
|
1917
|
+
path.moveTo(edges[i].from.x, edges[i].from.y);
|
|
1918
|
+
path.lineTo(edges[i].to.x, edges[i].to.y);
|
|
1919
|
+
}
|
|
1920
|
+
const d = path.toString();
|
|
1921
|
+
const pathBounds = get_svg_path_bounds_default(d);
|
|
1922
|
+
pathBounds.height = Math.max(pathBounds.height, 1);
|
|
1923
|
+
pathBounds.width = Math.max(pathBounds.width, 1);
|
|
1924
|
+
const center = {
|
|
1925
|
+
x: pathBounds.minX + pathBounds.width / 2,
|
|
1926
|
+
y: pathBounds.minY + pathBounds.height / 2
|
|
1927
|
+
};
|
|
1928
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(SVGPathComponent_default, {
|
|
1929
|
+
rotation: 0,
|
|
1930
|
+
center,
|
|
1931
|
+
size: pathBounds,
|
|
1932
|
+
paths: [
|
|
1933
|
+
{
|
|
1934
|
+
stroke: "green",
|
|
1935
|
+
strokeWidth: 0.02,
|
|
1936
|
+
d
|
|
1937
|
+
}
|
|
1938
|
+
]
|
|
1939
|
+
});
|
|
1940
|
+
};
|
|
1941
|
+
var SchematicTrace_default = SchematicTrace;
|
|
1942
|
+
|
|
1943
|
+
// src/schematic-components/SchematicBug.tsx
|
|
1944
|
+
var import_range = __toESM(require_range());
|
|
1945
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1946
|
+
var SchematicBug = ({ component: { source, schematic } }) => {
|
|
1947
|
+
const ports_arrangement = schematic.port_arrangement;
|
|
1948
|
+
const port_labels = schematic.port_labels;
|
|
1949
|
+
const bugw = 30;
|
|
1950
|
+
const rh = 15;
|
|
1951
|
+
const pd = 7.5;
|
|
1952
|
+
const bugh = Math.max(ports_arrangement.left_size, ports_arrangement.right_size) * rh;
|
|
1953
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SVGPathComponent_default, {
|
|
1954
|
+
rotation: schematic.rotation,
|
|
1955
|
+
center: schematic.center,
|
|
1956
|
+
size: schematic.size,
|
|
1957
|
+
paths: [
|
|
1958
|
+
{
|
|
1959
|
+
stroke: "red",
|
|
1960
|
+
strokeWidth: 1,
|
|
1961
|
+
d: `M 0 0 L ${bugw} 0 L ${bugw} ${bugh} L 0 ${bugh}Z`
|
|
1962
|
+
},
|
|
1963
|
+
...(0, import_range.default)(
|
|
1964
|
+
0,
|
|
1965
|
+
ports_arrangement.left_size + ports_arrangement.right_size
|
|
1966
|
+
).map((i) => {
|
|
1967
|
+
const ls = ports_arrangement.left_size;
|
|
1968
|
+
const left = i < ls;
|
|
1969
|
+
const rowi = i % ls;
|
|
1970
|
+
const p1 = [left ? 0 : bugw, rh / 2 + rowi * rh];
|
|
1971
|
+
const rd = [left ? -pd : pd, 0];
|
|
1972
|
+
return {
|
|
1973
|
+
stroke: "red",
|
|
1974
|
+
strokeWidth: 1,
|
|
1975
|
+
d: `M ${p1.join(" ")} l ${rd.join(" ")}`
|
|
1976
|
+
};
|
|
1977
|
+
})
|
|
1978
|
+
]
|
|
1979
|
+
});
|
|
1980
|
+
};
|
|
1981
|
+
|
|
1982
|
+
// src/schematic-components/SimplePowerSource.tsx
|
|
1983
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1984
|
+
var SimplePowerSource = ({
|
|
1985
|
+
component: { source, schematic }
|
|
1986
|
+
}) => {
|
|
1987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SVGPathComponent_default, {
|
|
1988
|
+
rotation: schematic.rotation,
|
|
1989
|
+
center: schematic.center,
|
|
1990
|
+
size: schematic.size,
|
|
1991
|
+
paths: [
|
|
1992
|
+
{
|
|
1993
|
+
stroke: "red",
|
|
1994
|
+
strokeWidth: 1,
|
|
1995
|
+
d: "M 0 -17 L 0 -3 M -8 3 L 8 3 M 0 17 L 0 3 M -12 -3 L 12 -3"
|
|
1996
|
+
}
|
|
1997
|
+
]
|
|
1998
|
+
});
|
|
1999
|
+
};
|
|
2000
|
+
|
|
2001
|
+
// src/schematic-components/SimpleGround.tsx
|
|
2002
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
2003
|
+
var SimpleGround = ({ component: { source, schematic } }) => {
|
|
2004
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SVGPathComponent_default, {
|
|
2005
|
+
rotation: schematic.rotation,
|
|
2006
|
+
center: schematic.center,
|
|
2007
|
+
size: schematic.size,
|
|
2008
|
+
paths: [
|
|
2009
|
+
{
|
|
2010
|
+
stroke: "red",
|
|
2011
|
+
strokeWidth: 0.7,
|
|
2012
|
+
d: "M -3 3 L 3 3 M -6 0 L 6 0 M -9 -3 L 9 -3 M 0 -3 L 0 -12"
|
|
2013
|
+
}
|
|
2014
|
+
]
|
|
2015
|
+
});
|
|
2016
|
+
};
|
|
2017
|
+
|
|
2018
|
+
// src/schematic-components/SimpleInductor.tsx
|
|
2019
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2020
|
+
var SimpleInductor = ({ component: { source, schematic } }) => {
|
|
2021
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SVGPathComponent_default, {
|
|
2022
|
+
rotation: schematic.rotation,
|
|
2023
|
+
center: schematic.center,
|
|
2024
|
+
size: schematic.size,
|
|
2025
|
+
paths: [
|
|
2026
|
+
{
|
|
2027
|
+
stroke: "red",
|
|
2028
|
+
strokeWidth: 1,
|
|
2029
|
+
d: "m 371,710.41665 h -14 c -0.0421,-16.39898 -14.02104,-16.39898 -14,0 -0.021,-16.399 -14.04182,-16.34072 -14,0 -2.6e-4,-16.45722 -14.04236,-16.45722 -14,0 2.8e-4,-16.3407 -13.97896,-16.39898 -14,0 -0.0421,-16.39898 -13.91338,-16.39898 -13.91338,0 H 273"
|
|
2030
|
+
}
|
|
2031
|
+
]
|
|
2032
|
+
});
|
|
2033
|
+
};
|
|
2034
|
+
|
|
2035
|
+
// src/schematic-components/SimpleDiode.tsx
|
|
2036
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
2037
|
+
var SimpleDiode = ({ component: { source, schematic } }) => {
|
|
2038
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SVGPathComponent_default, {
|
|
2039
|
+
rotation: schematic.rotation,
|
|
2040
|
+
center: schematic.center,
|
|
2041
|
+
size: schematic.size,
|
|
2042
|
+
paths: [
|
|
2043
|
+
{ stroke: "red", strokeWidth: 2, d: "M 0,0 H 21" },
|
|
2044
|
+
{ stroke: "red", strokeWidth: 2, d: "M 49,0 H 59" },
|
|
2045
|
+
{ stroke: "red", strokeWidth: 2, d: "M 49,0 L 21 14 V -14 Z" },
|
|
2046
|
+
{ stroke: "red", strokeWidth: 2, d: "M 49,-14 V 14" }
|
|
2047
|
+
]
|
|
2048
|
+
});
|
|
2049
|
+
};
|
|
2050
|
+
|
|
2051
|
+
// src/schematic-components/SchematicComponent.tsx
|
|
2052
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2053
|
+
var SchematicComponent = ({ component }) => {
|
|
2054
|
+
const { source, schematic } = component;
|
|
2055
|
+
switch (source.ftype) {
|
|
2056
|
+
case "simple_resistor": {
|
|
2057
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimpleResistor, {
|
|
2058
|
+
component: { source, schematic }
|
|
2059
|
+
});
|
|
2060
|
+
}
|
|
2061
|
+
case "simple_capacitor": {
|
|
2062
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimpleCapacitor, {
|
|
2063
|
+
component: { source, schematic }
|
|
2064
|
+
});
|
|
2065
|
+
}
|
|
2066
|
+
case "simple_power_source": {
|
|
2067
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimplePowerSource, {
|
|
2068
|
+
component: { source, schematic }
|
|
2069
|
+
});
|
|
2070
|
+
}
|
|
2071
|
+
case "simple_ground": {
|
|
2072
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimpleGround, {
|
|
2073
|
+
component: { source, schematic }
|
|
2074
|
+
});
|
|
2075
|
+
}
|
|
2076
|
+
case "simple_inductor": {
|
|
2077
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimpleInductor, {
|
|
2078
|
+
component: { source, schematic }
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
case "simple_bug": {
|
|
2082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SchematicBug, {
|
|
2083
|
+
component: { source, schematic }
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
case "simple_diode": {
|
|
2087
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(SimpleDiode, {
|
|
2088
|
+
component: { source, schematic }
|
|
2089
|
+
});
|
|
2090
|
+
}
|
|
2091
|
+
default: {
|
|
2092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", {
|
|
2093
|
+
children: [
|
|
2094
|
+
"unknown ftype: ",
|
|
2095
|
+
component.source.ftype
|
|
2096
|
+
]
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
var SchematicComponent_default = SchematicComponent;
|
|
2102
|
+
|
|
2103
|
+
// src/schematic-components/SchematicElement.tsx
|
|
2104
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
2105
|
+
var SchematicElement = ({
|
|
2106
|
+
element,
|
|
2107
|
+
allElements
|
|
2108
|
+
}) => {
|
|
2109
|
+
if (element.type === "schematic_component") {
|
|
2110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SchematicComponent_default, {
|
|
2111
|
+
component: collectElementRefs(element, allElements)
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
if (element.type === "schematic_trace") {
|
|
2115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SchematicTrace_default, {
|
|
2116
|
+
trace: collectElementRefs(element, allElements)
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
if (element.type === "schematic_port") {
|
|
2120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SchematicPort_default, {
|
|
2121
|
+
port: collectElementRefs(element, allElements)
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2124
|
+
if (element.type === "schematic_text") {
|
|
2125
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(SchematicText_default, {
|
|
2126
|
+
schematic_text: element
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
return null;
|
|
2130
|
+
};
|
|
2131
|
+
|
|
2132
|
+
// src/Schematic.tsx
|
|
2133
|
+
var import_use_mouse_matrix_transform = require("use-mouse-matrix-transform");
|
|
2134
|
+
var import_react_error_boundary = require("react-error-boundary");
|
|
2135
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2136
|
+
var fallbackRender = (elm) => ({ error, resetErrorBoundary }) => {
|
|
2137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", {
|
|
2138
|
+
style: { color: "red" },
|
|
2139
|
+
children: [
|
|
2140
|
+
"error rendering ",
|
|
2141
|
+
elm.type,
|
|
2142
|
+
": ",
|
|
2143
|
+
error.toString()
|
|
2144
|
+
]
|
|
2145
|
+
});
|
|
2146
|
+
};
|
|
2147
|
+
var Schematic = ({
|
|
2148
|
+
children,
|
|
2149
|
+
elements: initialElements = [],
|
|
2150
|
+
style
|
|
2151
|
+
}) => {
|
|
2152
|
+
const [elements, setElements] = (0, import_react4.useState)(initialElements);
|
|
2153
|
+
const [project, setProject] = (0, import_react4.useState)(null);
|
|
2154
|
+
const setCameraTransform = useRenderContext((s) => s.setCameraTransform);
|
|
2155
|
+
const { ref } = (0, import_use_mouse_matrix_transform.useMouseMatrixTransform)({
|
|
2156
|
+
onSetTransform: (transform2) => setCameraTransform(transform2),
|
|
2157
|
+
initialTransform: compose(scale(100, 100, 0, 0))
|
|
2158
|
+
});
|
|
2159
|
+
(0, import_react4.useEffect)(() => {
|
|
2160
|
+
if (initialElements.length > 0) {
|
|
2161
|
+
setProject((0, import_builder2.createProjectFromElements)(initialElements));
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
const projectBuilder = (0, import_builder2.createProjectBuilder)();
|
|
2165
|
+
(0, import_react_fiber.createRoot)().render(children, projectBuilder).then(async (elements2) => {
|
|
2166
|
+
setElements(elements2);
|
|
2167
|
+
setProject((0, import_builder2.createProjectFromElements)(elements2));
|
|
2168
|
+
}).catch((e) => {
|
|
2169
|
+
console.error("ERROR RENDERING CIRCUIT");
|
|
2170
|
+
throw e;
|
|
2171
|
+
});
|
|
2172
|
+
}, [children]);
|
|
2173
|
+
if (elements.length === 0)
|
|
2174
|
+
return null;
|
|
2175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", {
|
|
2176
|
+
style: {
|
|
2177
|
+
width: "100%",
|
|
2178
|
+
backgroundColor: "rgba(255,255,255,0)",
|
|
2179
|
+
minHeight: 200,
|
|
2180
|
+
overflow: "hidden",
|
|
2181
|
+
position: "relative",
|
|
2182
|
+
cursor: "grab",
|
|
2183
|
+
...style
|
|
2184
|
+
},
|
|
2185
|
+
ref,
|
|
2186
|
+
children: elements.map((elm) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_error_boundary.ErrorBoundary, {
|
|
2187
|
+
fallbackRender: fallbackRender(elm),
|
|
2188
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(SchematicElement, {
|
|
2189
|
+
element: elm,
|
|
2190
|
+
allElements: elements
|
|
2191
|
+
}, JSON.stringify(elm))
|
|
2192
|
+
}))
|
|
2193
|
+
});
|
|
2194
|
+
};
|
|
2195
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2196
|
+
0 && (module.exports = {
|
|
2197
|
+
Schematic
|
|
2198
|
+
});
|
|
2199
|
+
/**
|
|
2200
|
+
* @license React
|
|
2201
|
+
* use-sync-external-store-shim.development.js
|
|
2202
|
+
*
|
|
2203
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2204
|
+
*
|
|
2205
|
+
* This source code is licensed under the MIT license found in the
|
|
2206
|
+
* LICENSE file in the root directory of this source tree.
|
|
2207
|
+
*/
|
|
2208
|
+
/**
|
|
2209
|
+
* @license React
|
|
2210
|
+
* use-sync-external-store-shim.production.min.js
|
|
2211
|
+
*
|
|
2212
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2213
|
+
*
|
|
2214
|
+
* This source code is licensed under the MIT license found in the
|
|
2215
|
+
* LICENSE file in the root directory of this source tree.
|
|
2216
|
+
*/
|
|
2217
|
+
/**
|
|
2218
|
+
* @license React
|
|
2219
|
+
* use-sync-external-store-shim/with-selector.development.js
|
|
2220
|
+
*
|
|
2221
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2222
|
+
*
|
|
2223
|
+
* This source code is licensed under the MIT license found in the
|
|
2224
|
+
* LICENSE file in the root directory of this source tree.
|
|
2225
|
+
*/
|
|
2226
|
+
/**
|
|
2227
|
+
* @license React
|
|
2228
|
+
* use-sync-external-store-shim/with-selector.production.min.js
|
|
2229
|
+
*
|
|
2230
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
2231
|
+
*
|
|
2232
|
+
* This source code is licensed under the MIT license found in the
|
|
2233
|
+
* LICENSE file in the root directory of this source tree.
|
|
2234
|
+
*/
|
|
2235
|
+
//# sourceMappingURL=index.js.map
|