@tscircuit/schematic-viewer 1.1.20 → 1.1.22
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/index.js +208 -124
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/tsconfig.json +1 -2
- package/tsup.config.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -1,34 +1,13 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
var reactSupergrid = require('react-supergrid');
|
|
5
|
-
var builder = require('@tscircuit/builder');
|
|
6
|
-
var TscReactFiber = require('@tscircuit/react-fiber');
|
|
7
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
-
var useMouseMatrixTransform = require('use-mouse-matrix-transform');
|
|
9
|
-
var reactErrorBoundary = require('react-error-boundary');
|
|
10
|
-
|
|
11
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var TscReactFiber__default = /*#__PURE__*/_interopDefault(TscReactFiber);
|
|
14
|
-
|
|
15
1
|
var __create = Object.create;
|
|
16
2
|
var __defProp = Object.defineProperty;
|
|
17
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
18
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
19
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
20
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
21
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
22
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
23
|
-
}) : x)(function(x) {
|
|
24
|
-
if (typeof require !== "undefined")
|
|
25
|
-
return require.apply(this, arguments);
|
|
26
|
-
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
27
|
-
});
|
|
28
7
|
var __esm = (fn, res) => function __init() {
|
|
29
8
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
30
9
|
};
|
|
31
|
-
var __commonJS = (cb, mod) => function
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
32
11
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
33
12
|
};
|
|
34
13
|
var __export = (target, all) => {
|
|
@@ -56,7 +35,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
56
35
|
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js
|
|
57
36
|
var require_use_sync_external_store_shim_production_min = __commonJS({
|
|
58
37
|
"node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js"(exports) {
|
|
59
|
-
|
|
38
|
+
"use strict";
|
|
39
|
+
var e = require("react");
|
|
60
40
|
function h(a, b) {
|
|
61
41
|
return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
|
|
62
42
|
}
|
|
@@ -102,12 +82,14 @@ var require_use_sync_external_store_shim_production_min = __commonJS({
|
|
|
102
82
|
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
|
|
103
83
|
var require_use_sync_external_store_shim_development = __commonJS({
|
|
104
84
|
"node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
|
|
85
|
+
"use strict";
|
|
105
86
|
if (process.env.NODE_ENV !== "production") {
|
|
106
87
|
(function() {
|
|
88
|
+
"use strict";
|
|
107
89
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
108
90
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
109
91
|
}
|
|
110
|
-
var React =
|
|
92
|
+
var React = require("react");
|
|
111
93
|
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
112
94
|
function error(format) {
|
|
113
95
|
{
|
|
@@ -221,11 +203,12 @@ var require_use_sync_external_store_shim_development = __commonJS({
|
|
|
221
203
|
|
|
222
204
|
// node_modules/use-sync-external-store/shim/index.js
|
|
223
205
|
var require_shim = __commonJS({
|
|
224
|
-
"node_modules/use-sync-external-store/shim/index.js"(exports,
|
|
206
|
+
"node_modules/use-sync-external-store/shim/index.js"(exports, module2) {
|
|
207
|
+
"use strict";
|
|
225
208
|
if (process.env.NODE_ENV === "production") {
|
|
226
|
-
|
|
209
|
+
module2.exports = require_use_sync_external_store_shim_production_min();
|
|
227
210
|
} else {
|
|
228
|
-
|
|
211
|
+
module2.exports = require_use_sync_external_store_shim_development();
|
|
229
212
|
}
|
|
230
213
|
}
|
|
231
214
|
});
|
|
@@ -233,7 +216,8 @@ var require_shim = __commonJS({
|
|
|
233
216
|
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js
|
|
234
217
|
var require_with_selector_production_min = __commonJS({
|
|
235
218
|
"node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.min.js"(exports) {
|
|
236
|
-
|
|
219
|
+
"use strict";
|
|
220
|
+
var h = require("react");
|
|
237
221
|
var n = require_shim();
|
|
238
222
|
function p(a, b) {
|
|
239
223
|
return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
|
|
@@ -294,12 +278,14 @@ var require_with_selector_production_min = __commonJS({
|
|
|
294
278
|
// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
|
|
295
279
|
var require_with_selector_development = __commonJS({
|
|
296
280
|
"node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
|
|
281
|
+
"use strict";
|
|
297
282
|
if (process.env.NODE_ENV !== "production") {
|
|
298
283
|
(function() {
|
|
284
|
+
"use strict";
|
|
299
285
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
|
|
300
286
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
301
287
|
}
|
|
302
|
-
var React =
|
|
288
|
+
var React = require("react");
|
|
303
289
|
var shim = require_shim();
|
|
304
290
|
function is(x, y) {
|
|
305
291
|
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y;
|
|
@@ -381,19 +367,20 @@ var require_with_selector_development = __commonJS({
|
|
|
381
367
|
|
|
382
368
|
// node_modules/use-sync-external-store/shim/with-selector.js
|
|
383
369
|
var require_with_selector = __commonJS({
|
|
384
|
-
"node_modules/use-sync-external-store/shim/with-selector.js"(exports,
|
|
370
|
+
"node_modules/use-sync-external-store/shim/with-selector.js"(exports, module2) {
|
|
371
|
+
"use strict";
|
|
385
372
|
if (process.env.NODE_ENV === "production") {
|
|
386
|
-
|
|
373
|
+
module2.exports = require_with_selector_production_min();
|
|
387
374
|
} else {
|
|
388
|
-
|
|
375
|
+
module2.exports = require_with_selector_development();
|
|
389
376
|
}
|
|
390
377
|
}
|
|
391
378
|
});
|
|
392
379
|
|
|
393
380
|
// node_modules/parse-svg-path/index.js
|
|
394
381
|
var require_parse_svg_path = __commonJS({
|
|
395
|
-
"node_modules/parse-svg-path/index.js"(exports,
|
|
396
|
-
|
|
382
|
+
"node_modules/parse-svg-path/index.js"(exports, module2) {
|
|
383
|
+
module2.exports = parse;
|
|
397
384
|
var length = { a: 7, c: 6, h: 1, l: 2, m: 2, q: 4, s: 4, t: 2, v: 1, z: 0 };
|
|
398
385
|
var segment = /([astvzqmhlc])([^astvzqmhlc]*)/ig;
|
|
399
386
|
function parse(path) {
|
|
@@ -428,8 +415,8 @@ var require_parse_svg_path = __commonJS({
|
|
|
428
415
|
|
|
429
416
|
// node_modules/abs-svg-path/index.js
|
|
430
417
|
var require_abs_svg_path = __commonJS({
|
|
431
|
-
"node_modules/abs-svg-path/index.js"(exports,
|
|
432
|
-
|
|
418
|
+
"node_modules/abs-svg-path/index.js"(exports, module2) {
|
|
419
|
+
module2.exports = absolutize;
|
|
433
420
|
function absolutize(path) {
|
|
434
421
|
var startX = 0;
|
|
435
422
|
var startY = 0;
|
|
@@ -641,8 +628,9 @@ var init_modules = __esm({
|
|
|
641
628
|
|
|
642
629
|
// node_modules/normalize-svg-path/index.js
|
|
643
630
|
var require_normalize_svg_path = __commonJS({
|
|
644
|
-
"node_modules/normalize-svg-path/index.js"(exports,
|
|
645
|
-
|
|
631
|
+
"node_modules/normalize-svg-path/index.js"(exports, module2) {
|
|
632
|
+
"use strict";
|
|
633
|
+
module2.exports = normalize;
|
|
646
634
|
var arcToCurve = (init_modules(), __toCommonJS(modules_exports));
|
|
647
635
|
function normalize(path) {
|
|
648
636
|
var prev;
|
|
@@ -754,8 +742,9 @@ var require_normalize_svg_path = __commonJS({
|
|
|
754
742
|
|
|
755
743
|
// node_modules/is-svg-path/index.js
|
|
756
744
|
var require_is_svg_path = __commonJS({
|
|
757
|
-
"node_modules/is-svg-path/index.js"(exports,
|
|
758
|
-
|
|
745
|
+
"node_modules/is-svg-path/index.js"(exports, module2) {
|
|
746
|
+
"use strict";
|
|
747
|
+
module2.exports = function isPath(str) {
|
|
759
748
|
if (typeof str !== "string")
|
|
760
749
|
return false;
|
|
761
750
|
str = str.trim();
|
|
@@ -768,12 +757,13 @@ var require_is_svg_path = __commonJS({
|
|
|
768
757
|
|
|
769
758
|
// node_modules/svg-path-bounds/index.js
|
|
770
759
|
var require_svg_path_bounds = __commonJS({
|
|
771
|
-
"node_modules/svg-path-bounds/index.js"(exports,
|
|
760
|
+
"node_modules/svg-path-bounds/index.js"(exports, module2) {
|
|
761
|
+
"use strict";
|
|
772
762
|
var parse = require_parse_svg_path();
|
|
773
763
|
var abs = require_abs_svg_path();
|
|
774
764
|
var normalize = require_normalize_svg_path();
|
|
775
765
|
var isSvgPath = require_is_svg_path();
|
|
776
|
-
|
|
766
|
+
module2.exports = pathBounds;
|
|
777
767
|
function pathBounds(path) {
|
|
778
768
|
if (Array.isArray(path) && path.length === 1 && typeof path[0] === "string")
|
|
779
769
|
path = path[0];
|
|
@@ -809,7 +799,7 @@ var require_svg_path_bounds = __commonJS({
|
|
|
809
799
|
|
|
810
800
|
// node_modules/debounce/index.js
|
|
811
801
|
var require_debounce = __commonJS({
|
|
812
|
-
"node_modules/debounce/index.js"(exports,
|
|
802
|
+
"node_modules/debounce/index.js"(exports, module2) {
|
|
813
803
|
function debounce(func, wait, immediate) {
|
|
814
804
|
var timeout, args, context, timestamp, result;
|
|
815
805
|
if (null == wait)
|
|
@@ -826,6 +816,7 @@ var require_debounce = __commonJS({
|
|
|
826
816
|
}
|
|
827
817
|
}
|
|
828
818
|
}
|
|
819
|
+
;
|
|
829
820
|
var debounced = function() {
|
|
830
821
|
context = this;
|
|
831
822
|
args = arguments;
|
|
@@ -856,13 +847,13 @@ var require_debounce = __commonJS({
|
|
|
856
847
|
return debounced;
|
|
857
848
|
}
|
|
858
849
|
debounce.debounce = debounce;
|
|
859
|
-
|
|
850
|
+
module2.exports = debounce;
|
|
860
851
|
}
|
|
861
852
|
});
|
|
862
853
|
|
|
863
854
|
// node_modules/svg-path-generator/lib/svg-path-generator.js
|
|
864
855
|
var require_svg_path_generator = __commonJS({
|
|
865
|
-
"node_modules/svg-path-generator/lib/svg-path-generator.js"(exports,
|
|
856
|
+
"node_modules/svg-path-generator/lib/svg-path-generator.js"(exports, module2) {
|
|
866
857
|
function SvgPathGenerator(path) {
|
|
867
858
|
if (!(this instanceof SvgPathGenerator)) {
|
|
868
859
|
return new SvgPathGenerator(path);
|
|
@@ -870,7 +861,7 @@ var require_svg_path_generator = __commonJS({
|
|
|
870
861
|
this.currentPath = (path || "") + " ";
|
|
871
862
|
this.isRelative = false;
|
|
872
863
|
}
|
|
873
|
-
|
|
864
|
+
module2.exports = SvgPathGenerator;
|
|
874
865
|
SvgPathGenerator.prototype.toString = function() {
|
|
875
866
|
return this.end();
|
|
876
867
|
};
|
|
@@ -934,11 +925,24 @@ var require_svg_path_generator = __commonJS({
|
|
|
934
925
|
|
|
935
926
|
// node_modules/svg-path-generator/index.js
|
|
936
927
|
var require_svg_path_generator2 = __commonJS({
|
|
937
|
-
"node_modules/svg-path-generator/index.js"(exports,
|
|
938
|
-
|
|
928
|
+
"node_modules/svg-path-generator/index.js"(exports, module2) {
|
|
929
|
+
module2.exports = require_svg_path_generator();
|
|
939
930
|
}
|
|
940
931
|
});
|
|
941
932
|
|
|
933
|
+
// src/index.ts
|
|
934
|
+
var src_exports = {};
|
|
935
|
+
__export(src_exports, {
|
|
936
|
+
Schematic: () => Schematic
|
|
937
|
+
});
|
|
938
|
+
module.exports = __toCommonJS(src_exports);
|
|
939
|
+
|
|
940
|
+
// src/Schematic.tsx
|
|
941
|
+
var import_react6 = require("react");
|
|
942
|
+
var import_react_supergrid = require("react-supergrid");
|
|
943
|
+
var import_builder3 = require("@tscircuit/builder");
|
|
944
|
+
var import_react_fiber = __toESM(require("@tscircuit/react-fiber"));
|
|
945
|
+
|
|
942
946
|
// src/lib/utils/collect-element-refs.ts
|
|
943
947
|
var collectElementRefs = (elm, allElms) => {
|
|
944
948
|
const source_port = allElms.find(
|
|
@@ -999,6 +1003,7 @@ var createStoreImpl = (createState) => {
|
|
|
999
1003
|
var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
|
|
1000
1004
|
|
|
1001
1005
|
// node_modules/zustand/esm/index.js
|
|
1006
|
+
var import_react = require("react");
|
|
1002
1007
|
var import_with_selector = __toESM(require_with_selector());
|
|
1003
1008
|
var { useSyncExternalStoreWithSelector } = import_with_selector.default;
|
|
1004
1009
|
function useStore(api, selector = api.getState, equalityFn) {
|
|
@@ -1009,7 +1014,7 @@ function useStore(api, selector = api.getState, equalityFn) {
|
|
|
1009
1014
|
selector,
|
|
1010
1015
|
equalityFn
|
|
1011
1016
|
);
|
|
1012
|
-
|
|
1017
|
+
(0, import_react.useDebugValue)(slice);
|
|
1013
1018
|
return slice;
|
|
1014
1019
|
}
|
|
1015
1020
|
var createImpl = (createState) => {
|
|
@@ -1080,6 +1085,9 @@ function compose(...matrices) {
|
|
|
1080
1085
|
return transform(...matrices);
|
|
1081
1086
|
}
|
|
1082
1087
|
|
|
1088
|
+
// node_modules/transformation-matrix/src/rotate.js
|
|
1089
|
+
var { cos, sin, PI } = Math;
|
|
1090
|
+
|
|
1083
1091
|
// node_modules/transformation-matrix/src/scale.js
|
|
1084
1092
|
function scale(sx, sy = void 0, cx = void 0, cy = void 0) {
|
|
1085
1093
|
if (isUndefined(sy))
|
|
@@ -1102,6 +1110,9 @@ function scale(sx, sy = void 0, cx = void 0, cy = void 0) {
|
|
|
1102
1110
|
]);
|
|
1103
1111
|
}
|
|
1104
1112
|
|
|
1113
|
+
// node_modules/transformation-matrix/src/skew.js
|
|
1114
|
+
var { tan } = Math;
|
|
1115
|
+
|
|
1105
1116
|
// node_modules/transformation-matrix/src/fromTransformAttribute.autogenerated.js
|
|
1106
1117
|
function peg$subclass(child, parent) {
|
|
1107
1118
|
function C() {
|
|
@@ -1250,6 +1261,10 @@ function getSVGPathBounds(ds) {
|
|
|
1250
1261
|
return { minX, maxX, minY, maxY, width: maxX - minX, height: maxY - minY };
|
|
1251
1262
|
}
|
|
1252
1263
|
var get_svg_path_bounds_default = getSVGPathBounds;
|
|
1264
|
+
|
|
1265
|
+
// src/schematic-components/SVGPathComponent.tsx
|
|
1266
|
+
var import_react2 = require("react");
|
|
1267
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1253
1268
|
var SVGPathComponent = ({
|
|
1254
1269
|
size,
|
|
1255
1270
|
center,
|
|
@@ -1260,7 +1275,9 @@ var SVGPathComponent = ({
|
|
|
1260
1275
|
}) => {
|
|
1261
1276
|
const ct = useCameraTransform();
|
|
1262
1277
|
const pathBounds = get_svg_path_bounds_default(paths.map((p) => p.d));
|
|
1263
|
-
Math.abs(pathBounds.width / pathBounds.height - size.width / size.height) > 0.01;
|
|
1278
|
+
const badRatio = Math.abs(pathBounds.width / pathBounds.height - size.width / size.height) > 0.01;
|
|
1279
|
+
if (badRatio) {
|
|
1280
|
+
}
|
|
1264
1281
|
pathBounds.height = Math.max(pathBounds.height, 1);
|
|
1265
1282
|
pathBounds.width = Math.max(pathBounds.width, 1);
|
|
1266
1283
|
const absoluteCenter = applyToPoint(ct, center);
|
|
@@ -1270,12 +1287,12 @@ var SVGPathComponent = ({
|
|
|
1270
1287
|
width: Math.max(1, actualAbsWidth),
|
|
1271
1288
|
height: Math.max(1, actualAbsHeight)
|
|
1272
1289
|
};
|
|
1273
|
-
const [hovering, setHovering] =
|
|
1290
|
+
const [hovering, setHovering] = (0, import_react2.useState)(false);
|
|
1274
1291
|
const svgLeft = absoluteCenter.x - absoluteSize.width / 2;
|
|
1275
1292
|
const svgTop = absoluteCenter.y - absoluteSize.height / 2;
|
|
1276
|
-
return /* @__PURE__ */
|
|
1277
|
-
hovering && /* @__PURE__ */
|
|
1278
|
-
/* @__PURE__ */
|
|
1293
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1294
|
+
hovering && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1295
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1279
1296
|
"div",
|
|
1280
1297
|
{
|
|
1281
1298
|
style: {
|
|
@@ -1291,7 +1308,7 @@ var SVGPathComponent = ({
|
|
|
1291
1308
|
}
|
|
1292
1309
|
}
|
|
1293
1310
|
),
|
|
1294
|
-
/* @__PURE__ */
|
|
1311
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1295
1312
|
"div",
|
|
1296
1313
|
{
|
|
1297
1314
|
style: {
|
|
@@ -1309,7 +1326,7 @@ var SVGPathComponent = ({
|
|
|
1309
1326
|
}
|
|
1310
1327
|
)
|
|
1311
1328
|
] }),
|
|
1312
|
-
/* @__PURE__ */
|
|
1329
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1313
1330
|
"svg",
|
|
1314
1331
|
{
|
|
1315
1332
|
onMouseOver: () => setHovering(Boolean(hoverContent)),
|
|
@@ -1328,7 +1345,7 @@ var SVGPathComponent = ({
|
|
|
1328
1345
|
width: absoluteSize.width,
|
|
1329
1346
|
height: absoluteSize.height,
|
|
1330
1347
|
viewBox: `${pathBounds.minX} ${pathBounds.minY} ${pathBounds.width} ${pathBounds.height}`,
|
|
1331
|
-
children: paths.map((p, i) => /* @__PURE__ */
|
|
1348
|
+
children: paths.map((p, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1332
1349
|
"path",
|
|
1333
1350
|
{
|
|
1334
1351
|
fill: p.fill ?? "none",
|
|
@@ -1344,8 +1361,11 @@ var SVGPathComponent = ({
|
|
|
1344
1361
|
] });
|
|
1345
1362
|
};
|
|
1346
1363
|
var SVGPathComponent_default = SVGPathComponent;
|
|
1364
|
+
|
|
1365
|
+
// src/schematic-components/SimpleResistor.tsx
|
|
1366
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
1347
1367
|
var SimpleResistor = ({ component: { source, schematic } }) => {
|
|
1348
|
-
return /* @__PURE__ */
|
|
1368
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1349
1369
|
SVGPathComponent_default,
|
|
1350
1370
|
{
|
|
1351
1371
|
rotation: schematic.rotation,
|
|
@@ -1361,10 +1381,13 @@ var SimpleResistor = ({ component: { source, schematic } }) => {
|
|
|
1361
1381
|
}
|
|
1362
1382
|
);
|
|
1363
1383
|
};
|
|
1384
|
+
|
|
1385
|
+
// src/schematic-components/SimpleCapacitor.tsx
|
|
1386
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1364
1387
|
var SimpleCapacitor = ({
|
|
1365
1388
|
component: { source, schematic }
|
|
1366
1389
|
}) => {
|
|
1367
|
-
return /* @__PURE__ */
|
|
1390
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
1368
1391
|
SVGPathComponent_default,
|
|
1369
1392
|
{
|
|
1370
1393
|
rotation: schematic.rotation,
|
|
@@ -1380,6 +1403,13 @@ var SimpleCapacitor = ({
|
|
|
1380
1403
|
);
|
|
1381
1404
|
};
|
|
1382
1405
|
|
|
1406
|
+
// src/lib/hooks/use-maybe-promise.ts
|
|
1407
|
+
var import_react3 = require("react");
|
|
1408
|
+
|
|
1409
|
+
// src/schematic-components/ProjectComponent.tsx
|
|
1410
|
+
var import_builder = require("@tscircuit/builder");
|
|
1411
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1412
|
+
|
|
1383
1413
|
// src/lib/utils/direction-to-vec.ts
|
|
1384
1414
|
var directionToVec = (direction) => {
|
|
1385
1415
|
if (direction === "up")
|
|
@@ -1393,17 +1423,20 @@ var directionToVec = (direction) => {
|
|
|
1393
1423
|
else
|
|
1394
1424
|
throw new Error("Invalid direction");
|
|
1395
1425
|
};
|
|
1426
|
+
|
|
1427
|
+
// src/schematic-components/SchematicPort.tsx
|
|
1428
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1396
1429
|
var SchematicPort = ({
|
|
1397
1430
|
port: { source_port, source_component, schematic }
|
|
1398
1431
|
}) => {
|
|
1399
1432
|
const hoverName = source_component?.name ? `.${source_component.name} > .${source_port?.name ?? source_port?.pin_number}` : `.${source_port?.name ?? source_port?.pin_number}`;
|
|
1400
|
-
return /* @__PURE__ */
|
|
1433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1401
1434
|
SVGPathComponent,
|
|
1402
1435
|
{
|
|
1403
1436
|
rotation: 0,
|
|
1404
|
-
hoverContent: /* @__PURE__ */
|
|
1437
|
+
hoverContent: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
1405
1438
|
hoverName,
|
|
1406
|
-
/* @__PURE__ */
|
|
1439
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("br", {}),
|
|
1407
1440
|
source_port?.pin_number && `Pin ${source_port.pin_number}`
|
|
1408
1441
|
] }),
|
|
1409
1442
|
center: schematic.center,
|
|
@@ -1427,6 +1460,7 @@ var SchematicPort = ({
|
|
|
1427
1460
|
var SchematicPort_default = SchematicPort;
|
|
1428
1461
|
|
|
1429
1462
|
// node_modules/react-use-measure/dist/web.js
|
|
1463
|
+
var import_react4 = require("react");
|
|
1430
1464
|
var import_debounce = __toESM(require_debounce());
|
|
1431
1465
|
function useMeasure(_temp) {
|
|
1432
1466
|
let {
|
|
@@ -1444,7 +1478,7 @@ function useMeasure(_temp) {
|
|
|
1444
1478
|
if (!ResizeObserver) {
|
|
1445
1479
|
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");
|
|
1446
1480
|
}
|
|
1447
|
-
const [bounds, set] =
|
|
1481
|
+
const [bounds, set] = (0, import_react4.useState)({
|
|
1448
1482
|
left: 0,
|
|
1449
1483
|
top: 0,
|
|
1450
1484
|
width: 0,
|
|
@@ -1454,7 +1488,7 @@ function useMeasure(_temp) {
|
|
|
1454
1488
|
x: 0,
|
|
1455
1489
|
y: 0
|
|
1456
1490
|
});
|
|
1457
|
-
const state =
|
|
1491
|
+
const state = (0, import_react4.useRef)({
|
|
1458
1492
|
element: null,
|
|
1459
1493
|
scrollContainers: null,
|
|
1460
1494
|
resizeObserver: null,
|
|
@@ -1462,12 +1496,12 @@ function useMeasure(_temp) {
|
|
|
1462
1496
|
});
|
|
1463
1497
|
const scrollDebounce = debounce ? typeof debounce === "number" ? debounce : debounce.scroll : null;
|
|
1464
1498
|
const resizeDebounce = debounce ? typeof debounce === "number" ? debounce : debounce.resize : null;
|
|
1465
|
-
const mounted =
|
|
1466
|
-
|
|
1499
|
+
const mounted = (0, import_react4.useRef)(false);
|
|
1500
|
+
(0, import_react4.useEffect)(() => {
|
|
1467
1501
|
mounted.current = true;
|
|
1468
1502
|
return () => void (mounted.current = false);
|
|
1469
1503
|
});
|
|
1470
|
-
const [forceRefresh, resizeChange, scrollChange] =
|
|
1504
|
+
const [forceRefresh, resizeChange, scrollChange] = (0, import_react4.useMemo)(() => {
|
|
1471
1505
|
const callback = () => {
|
|
1472
1506
|
if (!state.current.element)
|
|
1473
1507
|
return;
|
|
@@ -1533,22 +1567,22 @@ function useMeasure(_temp) {
|
|
|
1533
1567
|
};
|
|
1534
1568
|
useOnWindowScroll(scrollChange, Boolean(scroll));
|
|
1535
1569
|
useOnWindowResize(resizeChange);
|
|
1536
|
-
|
|
1570
|
+
(0, import_react4.useEffect)(() => {
|
|
1537
1571
|
removeListeners();
|
|
1538
1572
|
addListeners();
|
|
1539
1573
|
}, [scroll, scrollChange, resizeChange]);
|
|
1540
|
-
|
|
1574
|
+
(0, import_react4.useEffect)(() => removeListeners, []);
|
|
1541
1575
|
return [ref, bounds, forceRefresh];
|
|
1542
1576
|
}
|
|
1543
1577
|
function useOnWindowResize(onWindowResize) {
|
|
1544
|
-
|
|
1578
|
+
(0, import_react4.useEffect)(() => {
|
|
1545
1579
|
const cb = onWindowResize;
|
|
1546
1580
|
window.addEventListener("resize", cb);
|
|
1547
1581
|
return () => void window.removeEventListener("resize", cb);
|
|
1548
1582
|
}, [onWindowResize]);
|
|
1549
1583
|
}
|
|
1550
1584
|
function useOnWindowScroll(onScroll, enabled) {
|
|
1551
|
-
|
|
1585
|
+
(0, import_react4.useEffect)(() => {
|
|
1552
1586
|
if (enabled) {
|
|
1553
1587
|
const cb = onScroll;
|
|
1554
1588
|
window.addEventListener("scroll", cb, {
|
|
@@ -1574,6 +1608,9 @@ function findScrollContainers(element) {
|
|
|
1574
1608
|
}
|
|
1575
1609
|
var keys = ["x", "y", "top", "bottom", "left", "right", "width", "height"];
|
|
1576
1610
|
var areBoundsEqual = (a, b) => keys.every((key) => a[key] === b[key]);
|
|
1611
|
+
|
|
1612
|
+
// src/schematic-components/SchematicText.tsx
|
|
1613
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1577
1614
|
var SchematicText = ({ schematic_text }) => {
|
|
1578
1615
|
const ct = useCameraTransform();
|
|
1579
1616
|
const { text, position, anchor } = schematic_text;
|
|
@@ -1587,7 +1624,7 @@ var SchematicText = ({ schematic_text }) => {
|
|
|
1587
1624
|
} else if (anchor === "right") {
|
|
1588
1625
|
offset = [-bounds.width, -bounds.height / 2];
|
|
1589
1626
|
}
|
|
1590
|
-
return /* @__PURE__ */
|
|
1627
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1591
1628
|
"div",
|
|
1592
1629
|
{
|
|
1593
1630
|
ref: boundsRef,
|
|
@@ -1605,8 +1642,11 @@ var SchematicText_default = SchematicText;
|
|
|
1605
1642
|
|
|
1606
1643
|
// src/schematic-components/SchematicTrace.tsx
|
|
1607
1644
|
var import_svg_path_generator = __toESM(require_svg_path_generator2());
|
|
1645
|
+
|
|
1646
|
+
// src/schematic-components/RenderError.tsx
|
|
1647
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1608
1648
|
var RenderError_default = ({ text }) => {
|
|
1609
|
-
return /* @__PURE__ */
|
|
1649
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1610
1650
|
"div",
|
|
1611
1651
|
{
|
|
1612
1652
|
style: {
|
|
@@ -1624,10 +1664,13 @@ var RenderError_default = ({ text }) => {
|
|
|
1624
1664
|
}
|
|
1625
1665
|
);
|
|
1626
1666
|
};
|
|
1667
|
+
|
|
1668
|
+
// src/schematic-components/SchematicTrace.tsx
|
|
1669
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1627
1670
|
var SchematicTrace = ({ trace: { source, schematic } }) => {
|
|
1628
1671
|
const edges = schematic.edges;
|
|
1629
1672
|
if (edges.length === 0) {
|
|
1630
|
-
return /* @__PURE__ */
|
|
1673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(RenderError_default, { text: `Route with 0 edges (${source.source_trace_id})` });
|
|
1631
1674
|
}
|
|
1632
1675
|
const path = (0, import_svg_path_generator.default)();
|
|
1633
1676
|
for (let i = 0; i < edges.length; i++) {
|
|
@@ -1642,7 +1685,7 @@ var SchematicTrace = ({ trace: { source, schematic } }) => {
|
|
|
1642
1685
|
x: pathBounds.minX + pathBounds.width / 2,
|
|
1643
1686
|
y: pathBounds.minY + pathBounds.height / 2
|
|
1644
1687
|
};
|
|
1645
|
-
return /* @__PURE__ */
|
|
1688
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1646
1689
|
SVGPathComponent_default,
|
|
1647
1690
|
{
|
|
1648
1691
|
rotation: 0,
|
|
@@ -1659,6 +1702,10 @@ var SchematicTrace = ({ trace: { source, schematic } }) => {
|
|
|
1659
1702
|
);
|
|
1660
1703
|
};
|
|
1661
1704
|
var SchematicTrace_default = SchematicTrace;
|
|
1705
|
+
|
|
1706
|
+
// src/schematic-components/SchematicBug.tsx
|
|
1707
|
+
var import_builder2 = require("@tscircuit/builder");
|
|
1708
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1662
1709
|
var SchematicBug = ({ component: { source, schematic } }) => {
|
|
1663
1710
|
const port_arrangement = {
|
|
1664
1711
|
top_size: 0,
|
|
@@ -1667,8 +1714,8 @@ var SchematicBug = ({ component: { source, schematic } }) => {
|
|
|
1667
1714
|
};
|
|
1668
1715
|
let bugw = schematic.size.width;
|
|
1669
1716
|
let bugh = schematic.size.height;
|
|
1670
|
-
const { total_ports, width, height } =
|
|
1671
|
-
const port_indices =
|
|
1717
|
+
const { total_ports, width, height } = (0, import_builder2.getPortArrangementSize)(port_arrangement);
|
|
1718
|
+
const port_indices = (0, import_builder2.getPortIndices)(port_arrangement);
|
|
1672
1719
|
if (isNaN(bugw))
|
|
1673
1720
|
bugw = width;
|
|
1674
1721
|
if (isNaN(bugh))
|
|
@@ -1680,7 +1727,7 @@ var SchematicBug = ({ component: { source, schematic } }) => {
|
|
|
1680
1727
|
d: `M ${-bugw / 2} ${-bugh / 2} L ${bugw / 2} ${-bugh / 2} L ${bugw / 2} ${bugh / 2} L ${-bugw / 2} ${bugh / 2}Z`
|
|
1681
1728
|
},
|
|
1682
1729
|
...port_indices.map((portNum) => {
|
|
1683
|
-
const pos =
|
|
1730
|
+
const pos = (0, import_builder2.getPortPosition)(port_arrangement, portNum);
|
|
1684
1731
|
const x2 = pos.side === "left" ? -bugw / 2 : pos.side === "right" ? bugw / 2 : pos.x;
|
|
1685
1732
|
const y2 = pos.side === "top" ? -bugh / 2 : pos.side === "bottom" ? bugh / 2 : pos.y;
|
|
1686
1733
|
return {
|
|
@@ -1695,7 +1742,7 @@ var SchematicBug = ({ component: { source, schematic } }) => {
|
|
|
1695
1742
|
x: schematic.center.x + (actualSize.minX + actualSize.maxX) / 2,
|
|
1696
1743
|
y: schematic.center.y + (actualSize.minY + actualSize.maxY) / 2
|
|
1697
1744
|
};
|
|
1698
|
-
return /* @__PURE__ */
|
|
1745
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1699
1746
|
SVGPathComponent_default,
|
|
1700
1747
|
{
|
|
1701
1748
|
rotation: schematic.rotation,
|
|
@@ -1705,10 +1752,13 @@ var SchematicBug = ({ component: { source, schematic } }) => {
|
|
|
1705
1752
|
}
|
|
1706
1753
|
);
|
|
1707
1754
|
};
|
|
1755
|
+
|
|
1756
|
+
// src/schematic-components/SimplePowerSource.tsx
|
|
1757
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1708
1758
|
var SimplePowerSource = ({
|
|
1709
1759
|
component: { source, schematic }
|
|
1710
1760
|
}) => {
|
|
1711
|
-
return /* @__PURE__ */
|
|
1761
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1712
1762
|
SVGPathComponent_default,
|
|
1713
1763
|
{
|
|
1714
1764
|
rotation: schematic.rotation,
|
|
@@ -1724,8 +1774,11 @@ var SimplePowerSource = ({
|
|
|
1724
1774
|
}
|
|
1725
1775
|
);
|
|
1726
1776
|
};
|
|
1777
|
+
|
|
1778
|
+
// src/schematic-components/SimpleGround.tsx
|
|
1779
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1727
1780
|
var SimpleGround = ({ component: { source, schematic } }) => {
|
|
1728
|
-
return /* @__PURE__ */
|
|
1781
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1729
1782
|
SVGPathComponent_default,
|
|
1730
1783
|
{
|
|
1731
1784
|
rotation: schematic.rotation,
|
|
@@ -1741,8 +1794,11 @@ var SimpleGround = ({ component: { source, schematic } }) => {
|
|
|
1741
1794
|
}
|
|
1742
1795
|
);
|
|
1743
1796
|
};
|
|
1797
|
+
|
|
1798
|
+
// src/schematic-components/SimpleInductor.tsx
|
|
1799
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1744
1800
|
var SimpleInductor = ({ component: { source, schematic } }) => {
|
|
1745
|
-
return /* @__PURE__ */
|
|
1801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1746
1802
|
SVGPathComponent_default,
|
|
1747
1803
|
{
|
|
1748
1804
|
rotation: schematic.rotation,
|
|
@@ -1759,34 +1815,40 @@ var SimpleInductor = ({ component: { source, schematic } }) => {
|
|
|
1759
1815
|
}
|
|
1760
1816
|
);
|
|
1761
1817
|
};
|
|
1818
|
+
|
|
1819
|
+
// src/schematic-components/SimpleDiode.tsx
|
|
1820
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1821
|
+
|
|
1822
|
+
// src/schematic-components/SchematicComponent.tsx
|
|
1823
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1762
1824
|
var SchematicComponent = ({ component }) => {
|
|
1763
1825
|
const { source, schematic } = component;
|
|
1764
1826
|
if (!source.ftype)
|
|
1765
1827
|
return null;
|
|
1766
1828
|
switch (source.ftype) {
|
|
1767
1829
|
case "simple_resistor": {
|
|
1768
|
-
return /* @__PURE__ */
|
|
1830
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleResistor, { component: { source, schematic } });
|
|
1769
1831
|
}
|
|
1770
1832
|
case "simple_capacitor": {
|
|
1771
|
-
return /* @__PURE__ */
|
|
1833
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleCapacitor, { component: { source, schematic } });
|
|
1772
1834
|
}
|
|
1773
1835
|
case "simple_power_source": {
|
|
1774
|
-
return /* @__PURE__ */
|
|
1836
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimplePowerSource, { component: { source, schematic } });
|
|
1775
1837
|
}
|
|
1776
1838
|
case "simple_ground": {
|
|
1777
|
-
return /* @__PURE__ */
|
|
1839
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleGround, { component: { source, schematic } });
|
|
1778
1840
|
}
|
|
1779
1841
|
case "simple_inductor": {
|
|
1780
|
-
return /* @__PURE__ */
|
|
1842
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SimpleInductor, { component: { source, schematic } });
|
|
1781
1843
|
}
|
|
1782
1844
|
case "simple_bug": {
|
|
1783
|
-
return /* @__PURE__ */
|
|
1845
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(SchematicBug, { component: { source, schematic } });
|
|
1784
1846
|
}
|
|
1785
1847
|
case "simple_diode": {
|
|
1786
1848
|
return null;
|
|
1787
1849
|
}
|
|
1788
1850
|
default: {
|
|
1789
|
-
return /* @__PURE__ */
|
|
1851
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { children: [
|
|
1790
1852
|
"unknown ftype: ",
|
|
1791
1853
|
component.source.ftype
|
|
1792
1854
|
] });
|
|
@@ -1794,9 +1856,12 @@ var SchematicComponent = ({ component }) => {
|
|
|
1794
1856
|
}
|
|
1795
1857
|
};
|
|
1796
1858
|
var SchematicComponent_default = SchematicComponent;
|
|
1859
|
+
|
|
1860
|
+
// src/schematic-components/SchematicBox.tsx
|
|
1861
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1797
1862
|
var SchematicBox = ({ box: { schematic } }) => {
|
|
1798
1863
|
const { width: w, height: h } = schematic;
|
|
1799
|
-
return /* @__PURE__ */
|
|
1864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1800
1865
|
SVGPathComponent,
|
|
1801
1866
|
{
|
|
1802
1867
|
rotation: 0,
|
|
@@ -1816,8 +1881,11 @@ var SchematicBox_default = SchematicBox;
|
|
|
1816
1881
|
|
|
1817
1882
|
// src/schematic-components/SchematicLine.tsx
|
|
1818
1883
|
var import_svg_path_generator2 = __toESM(require_svg_path_generator2());
|
|
1884
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1819
1885
|
var SchematicLine = ({ line: { schematic } }) => {
|
|
1820
1886
|
const { x1, x2, y1, y2 } = schematic;
|
|
1887
|
+
const dx = x2 - x1;
|
|
1888
|
+
const dy = y2 - y1;
|
|
1821
1889
|
const path = (0, import_svg_path_generator2.default)();
|
|
1822
1890
|
path.moveTo(x1, y1);
|
|
1823
1891
|
path.lineTo(x2, y2);
|
|
@@ -1829,7 +1897,7 @@ var SchematicLine = ({ line: { schematic } }) => {
|
|
|
1829
1897
|
x: pathBounds.minX + pathBounds.width / 2,
|
|
1830
1898
|
y: pathBounds.minY + pathBounds.height / 2
|
|
1831
1899
|
};
|
|
1832
|
-
return /* @__PURE__ */
|
|
1900
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1833
1901
|
SVGPathComponent,
|
|
1834
1902
|
{
|
|
1835
1903
|
rotation: 0,
|
|
@@ -1849,6 +1917,7 @@ var SchematicLine_default = SchematicLine;
|
|
|
1849
1917
|
|
|
1850
1918
|
// src/schematic-components/SchematicPath.tsx
|
|
1851
1919
|
var import_svg_path_generator3 = __toESM(require_svg_path_generator2());
|
|
1920
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1852
1921
|
var SchematicPath = (props) => {
|
|
1853
1922
|
const { points, is_filled, is_closed, fill_color } = props.path.schematic;
|
|
1854
1923
|
if (points.length === 0)
|
|
@@ -1869,7 +1938,7 @@ var SchematicPath = (props) => {
|
|
|
1869
1938
|
x: pathBounds.minX + pathBounds.width / 2,
|
|
1870
1939
|
y: pathBounds.minY + pathBounds.height / 2
|
|
1871
1940
|
};
|
|
1872
|
-
return /* @__PURE__ */
|
|
1941
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1873
1942
|
SVGPathComponent,
|
|
1874
1943
|
{
|
|
1875
1944
|
rotation: 0,
|
|
@@ -1887,12 +1956,15 @@ var SchematicPath = (props) => {
|
|
|
1887
1956
|
);
|
|
1888
1957
|
};
|
|
1889
1958
|
var SchematicPath_default = SchematicPath;
|
|
1959
|
+
|
|
1960
|
+
// src/schematic-components/SchematicElement.tsx
|
|
1961
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1890
1962
|
var SchematicElement = ({
|
|
1891
1963
|
element,
|
|
1892
1964
|
allElements
|
|
1893
1965
|
}) => {
|
|
1894
1966
|
if (element.type === "schematic_component") {
|
|
1895
|
-
return /* @__PURE__ */
|
|
1967
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1896
1968
|
SchematicComponent_default,
|
|
1897
1969
|
{
|
|
1898
1970
|
component: collectElementRefs(element, allElements)
|
|
@@ -1900,44 +1972,55 @@ var SchematicElement = ({
|
|
|
1900
1972
|
);
|
|
1901
1973
|
}
|
|
1902
1974
|
if (element.type === "schematic_trace") {
|
|
1903
|
-
return /* @__PURE__ */
|
|
1975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicTrace_default, { trace: collectElementRefs(element, allElements) });
|
|
1904
1976
|
}
|
|
1905
1977
|
if (element.type === "schematic_port") {
|
|
1906
|
-
return /* @__PURE__ */
|
|
1978
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicPort_default, { port: collectElementRefs(element, allElements) });
|
|
1907
1979
|
}
|
|
1908
1980
|
if (element.type === "schematic_box") {
|
|
1909
|
-
return /* @__PURE__ */
|
|
1981
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicBox_default, { box: collectElementRefs(element, allElements) });
|
|
1910
1982
|
}
|
|
1911
1983
|
if (element.type === "schematic_line") {
|
|
1912
|
-
return /* @__PURE__ */
|
|
1984
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicLine_default, { line: collectElementRefs(element, allElements) });
|
|
1913
1985
|
}
|
|
1914
1986
|
if (element.type === "schematic_path") {
|
|
1915
|
-
return /* @__PURE__ */
|
|
1987
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicPath_default, { path: collectElementRefs(element, allElements) });
|
|
1916
1988
|
}
|
|
1917
1989
|
if (element.type === "schematic_text") {
|
|
1918
|
-
return /* @__PURE__ */
|
|
1990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicText_default, { schematic_text: element });
|
|
1919
1991
|
}
|
|
1920
1992
|
if (element.type === "source_error") {
|
|
1921
|
-
return /* @__PURE__ */
|
|
1993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RenderError_default, { text: element.message });
|
|
1922
1994
|
}
|
|
1923
1995
|
return null;
|
|
1924
1996
|
};
|
|
1925
|
-
|
|
1926
|
-
|
|
1997
|
+
|
|
1998
|
+
// src/Schematic.tsx
|
|
1999
|
+
var import_use_mouse_matrix_transform = require("use-mouse-matrix-transform");
|
|
2000
|
+
var import_react_error_boundary = require("react-error-boundary");
|
|
2001
|
+
|
|
2002
|
+
// src/schematic-components/TableViewer.tsx
|
|
2003
|
+
var import_react5 = require("react");
|
|
2004
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2005
|
+
var LazyTableViewer = (0, import_react5.lazy)(
|
|
2006
|
+
() => import("@tscircuit/table-viewer").then((m) => ({
|
|
1927
2007
|
default: m.SoupTableViewer
|
|
1928
2008
|
}))
|
|
1929
2009
|
);
|
|
1930
|
-
var TableViewer = (params) => /* @__PURE__ */
|
|
1931
|
-
|
|
2010
|
+
var TableViewer = (params) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_react5.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { children: "Loading..." }), children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(LazyTableViewer, { ...params }) });
|
|
2011
|
+
|
|
2012
|
+
// src/Schematic.tsx
|
|
2013
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2014
|
+
var ErrorBoundary = import_react_error_boundary.ErrorBoundary;
|
|
1932
2015
|
var fallbackRender = (elm) => ({ error, resetErrorBoundary }) => {
|
|
1933
|
-
return /* @__PURE__ */
|
|
2016
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { style: { color: "red" }, children: [
|
|
1934
2017
|
"error rendering ",
|
|
1935
2018
|
elm.type,
|
|
1936
2019
|
": ",
|
|
1937
2020
|
error.toString()
|
|
1938
2021
|
] });
|
|
1939
2022
|
};
|
|
1940
|
-
var toMMSINeg = (v, z) => v >= 0 ?
|
|
2023
|
+
var toMMSINeg = (v, z) => v >= 0 ? (0, import_react_supergrid.toMMSI)(v, z) : `-${(0, import_react_supergrid.toMMSI)(-v, z)}`;
|
|
1941
2024
|
var Schematic = ({
|
|
1942
2025
|
children,
|
|
1943
2026
|
elements: initialElements,
|
|
@@ -1946,23 +2029,23 @@ var Schematic = ({
|
|
|
1946
2029
|
showTable
|
|
1947
2030
|
}) => {
|
|
1948
2031
|
initialSoup = initialSoup ?? initialElements ?? [];
|
|
1949
|
-
const [elements, setElements] =
|
|
1950
|
-
const [project, setProject] =
|
|
2032
|
+
const [elements, setElements] = (0, import_react6.useState)(initialSoup ?? []);
|
|
2033
|
+
const [project, setProject] = (0, import_react6.useState)(null);
|
|
1951
2034
|
const setCameraTransform = useRenderContext((s) => s.setCameraTransform);
|
|
1952
2035
|
const cameraTransform = useRenderContext((s) => s.camera_transform);
|
|
1953
2036
|
const [boundsRef, bounds] = useMeasure();
|
|
1954
|
-
const { ref, setTransform } =
|
|
2037
|
+
const { ref, setTransform } = (0, import_use_mouse_matrix_transform.useMouseMatrixTransform)({
|
|
1955
2038
|
onSetTransform: (transform2) => {
|
|
1956
2039
|
setCameraTransform(transform2);
|
|
1957
2040
|
}
|
|
1958
2041
|
// initialTransform: compose(scale(100, 100, 0, 0)),
|
|
1959
2042
|
});
|
|
1960
|
-
const setElementsAndCamera =
|
|
2043
|
+
const setElementsAndCamera = (0, import_react6.useCallback)(
|
|
1961
2044
|
(elements2) => {
|
|
1962
2045
|
const elmBounds = ref.current.getBoundingClientRect();
|
|
1963
2046
|
const { center, width, height } = elements2.some(
|
|
1964
2047
|
(e) => e.type.startsWith("schematic_")
|
|
1965
|
-
) ?
|
|
2048
|
+
) ? (0, import_builder3.findBoundsAndCenter)(
|
|
1966
2049
|
elements2.filter((e) => e.type.startsWith("schematic_"))
|
|
1967
2050
|
) : { center: { x: 0, y: 0 }, width: 1e-3, height: 1e-3 };
|
|
1968
2051
|
const scaleFactor = Math.min(
|
|
@@ -1971,7 +2054,7 @@ var Schematic = ({
|
|
|
1971
2054
|
100
|
|
1972
2055
|
);
|
|
1973
2056
|
setElements(elements2);
|
|
1974
|
-
setProject(
|
|
2057
|
+
setProject((0, import_builder3.createProjectFromElements)(elements2));
|
|
1975
2058
|
setTransform(
|
|
1976
2059
|
compose(
|
|
1977
2060
|
translate((elmBounds.width ?? 0) / 2, (elmBounds.height ?? 0) / 2),
|
|
@@ -1983,21 +2066,21 @@ var Schematic = ({
|
|
|
1983
2066
|
},
|
|
1984
2067
|
[setElements, setTransform]
|
|
1985
2068
|
);
|
|
1986
|
-
|
|
2069
|
+
(0, import_react6.useEffect)(() => {
|
|
1987
2070
|
if (initialSoup.length > 0) {
|
|
1988
2071
|
setElementsAndCamera(initialSoup);
|
|
1989
2072
|
return;
|
|
1990
2073
|
}
|
|
1991
|
-
const projectBuilder =
|
|
1992
|
-
(
|
|
2074
|
+
const projectBuilder = (0, import_builder3.createProjectBuilder)();
|
|
2075
|
+
(import_react_fiber.createRoot ?? import_react_fiber.default.createRoot)().render(children, projectBuilder).then(async (elements2) => {
|
|
1993
2076
|
setElementsAndCamera(elements2);
|
|
1994
2077
|
}).catch((e) => {
|
|
1995
2078
|
console.error("ERROR RENDERING CIRCUIT");
|
|
1996
2079
|
throw e;
|
|
1997
2080
|
});
|
|
1998
2081
|
}, [children]);
|
|
1999
|
-
return /* @__PURE__ */
|
|
2000
|
-
/* @__PURE__ */
|
|
2082
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_jsx_runtime20.Fragment, { children: [
|
|
2083
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
|
|
2001
2084
|
"div",
|
|
2002
2085
|
{
|
|
2003
2086
|
style: {
|
|
@@ -2015,8 +2098,8 @@ var Schematic = ({
|
|
|
2015
2098
|
boundsRef(el);
|
|
2016
2099
|
},
|
|
2017
2100
|
children: [
|
|
2018
|
-
/* @__PURE__ */
|
|
2019
|
-
|
|
2101
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2102
|
+
import_react_supergrid.SuperGrid,
|
|
2020
2103
|
{
|
|
2021
2104
|
stringifyCoord: (x, y, z) => {
|
|
2022
2105
|
if (z === 0)
|
|
@@ -2028,7 +2111,7 @@ var Schematic = ({
|
|
|
2028
2111
|
transform: cameraTransform
|
|
2029
2112
|
}
|
|
2030
2113
|
),
|
|
2031
|
-
elements?.map((elm, i) => /* @__PURE__ */
|
|
2114
|
+
elements?.map((elm, i) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ErrorBoundary, { fallbackRender: fallbackRender(elm), children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
2032
2115
|
SchematicElement,
|
|
2033
2116
|
{
|
|
2034
2117
|
element: elm,
|
|
@@ -2039,9 +2122,13 @@ var Schematic = ({
|
|
|
2039
2122
|
]
|
|
2040
2123
|
}
|
|
2041
2124
|
),
|
|
2042
|
-
showTable !== false && elements && /* @__PURE__ */
|
|
2125
|
+
showTable !== false && elements && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(TableViewer, { elements })
|
|
2043
2126
|
] });
|
|
2044
2127
|
};
|
|
2128
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
2129
|
+
0 && (module.exports = {
|
|
2130
|
+
Schematic
|
|
2131
|
+
});
|
|
2045
2132
|
/*! Bundled license information:
|
|
2046
2133
|
|
|
2047
2134
|
use-sync-external-store/cjs/use-sync-external-store-shim.production.min.js:
|
|
@@ -2088,7 +2175,4 @@ use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.developme
|
|
|
2088
2175
|
* LICENSE file in the root directory of this source tree.
|
|
2089
2176
|
*)
|
|
2090
2177
|
*/
|
|
2091
|
-
|
|
2092
|
-
exports.Schematic = Schematic;
|
|
2093
|
-
//# sourceMappingURL=out.js.map
|
|
2094
2178
|
//# sourceMappingURL=index.js.map
|