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