@tscircuit/pcb-viewer 1.11.396 → 1.11.398

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 CHANGED
@@ -4,13 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod) => function __require2() {
7
+ var __commonJS = (cb, mod) => function __require() {
14
8
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
9
  };
16
10
  var __copyProps = (to, from, except, desc) => {
@@ -924,263 +918,6 @@ var require_svgson_umd = __commonJS({
924
918
  }
925
919
  });
926
920
 
927
- // node_modules/react-dom/cjs/react-dom.development.js
928
- var require_react_dom_development = __commonJS({
929
- "node_modules/react-dom/cjs/react-dom.development.js"(exports) {
930
- "use strict";
931
- (function() {
932
- function noop2() {
933
- }
934
- function testStringCoercion(value) {
935
- return "" + value;
936
- }
937
- function createPortal$1(children, containerInfo, implementation) {
938
- var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;
939
- try {
940
- testStringCoercion(key);
941
- var JSCompiler_inline_result = false;
942
- } catch (e) {
943
- JSCompiler_inline_result = true;
944
- }
945
- JSCompiler_inline_result && (console.error(
946
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
947
- "function" === typeof Symbol && Symbol.toStringTag && key[Symbol.toStringTag] || key.constructor.name || "Object"
948
- ), testStringCoercion(key));
949
- return {
950
- $$typeof: REACT_PORTAL_TYPE,
951
- key: null == key ? null : "" + key,
952
- children,
953
- containerInfo,
954
- implementation
955
- };
956
- }
957
- function getCrossOriginStringAs(as, input) {
958
- if ("font" === as) return "";
959
- if ("string" === typeof input)
960
- return "use-credentials" === input ? input : "";
961
- }
962
- function getValueDescriptorExpectingObjectForWarning(thing) {
963
- return null === thing ? "`null`" : void 0 === thing ? "`undefined`" : "" === thing ? "an empty string" : 'something with type "' + typeof thing + '"';
964
- }
965
- function getValueDescriptorExpectingEnumForWarning(thing) {
966
- return null === thing ? "`null`" : void 0 === thing ? "`undefined`" : "" === thing ? "an empty string" : "string" === typeof thing ? JSON.stringify(thing) : "number" === typeof thing ? "`" + thing + "`" : 'something with type "' + typeof thing + '"';
967
- }
968
- function resolveDispatcher() {
969
- var dispatcher = ReactSharedInternals.H;
970
- null === dispatcher && console.error(
971
- "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
972
- );
973
- return dispatcher;
974
- }
975
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
976
- var React4 = __require("react"), Internals = {
977
- d: {
978
- f: noop2,
979
- r: function() {
980
- throw Error(
981
- "Invalid form element. requestFormReset must be passed a form that was rendered by React."
982
- );
983
- },
984
- D: noop2,
985
- C: noop2,
986
- L: noop2,
987
- m: noop2,
988
- X: noop2,
989
- S: noop2,
990
- M: noop2
991
- },
992
- p: 0,
993
- findDOMNode: null
994
- }, REACT_PORTAL_TYPE = Symbol.for("react.portal"), ReactSharedInternals = React4.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
995
- "function" === typeof Map && null != Map.prototype && "function" === typeof Map.prototype.forEach && "function" === typeof Set && null != Set.prototype && "function" === typeof Set.prototype.clear && "function" === typeof Set.prototype.forEach || console.error(
996
- "React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"
997
- );
998
- exports.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = Internals;
999
- exports.createPortal = function(children, container) {
1000
- var key = 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : null;
1001
- if (!container || 1 !== container.nodeType && 9 !== container.nodeType && 11 !== container.nodeType)
1002
- throw Error("Target container is not a DOM element.");
1003
- return createPortal$1(children, container, null, key);
1004
- };
1005
- exports.flushSync = function(fn) {
1006
- var previousTransition = ReactSharedInternals.T, previousUpdatePriority = Internals.p;
1007
- try {
1008
- if (ReactSharedInternals.T = null, Internals.p = 2, fn)
1009
- return fn();
1010
- } finally {
1011
- ReactSharedInternals.T = previousTransition, Internals.p = previousUpdatePriority, Internals.d.f() && console.error(
1012
- "flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task."
1013
- );
1014
- }
1015
- };
1016
- exports.preconnect = function(href, options) {
1017
- "string" === typeof href && href ? null != options && "object" !== typeof options ? console.error(
1018
- "ReactDOM.preconnect(): Expected the `options` argument (second) to be an object but encountered %s instead. The only supported option at this time is `crossOrigin` which accepts a string.",
1019
- getValueDescriptorExpectingEnumForWarning(options)
1020
- ) : null != options && "string" !== typeof options.crossOrigin && console.error(
1021
- "ReactDOM.preconnect(): Expected the `crossOrigin` option (second argument) to be a string but encountered %s instead. Try removing this option or passing a string value instead.",
1022
- getValueDescriptorExpectingObjectForWarning(options.crossOrigin)
1023
- ) : console.error(
1024
- "ReactDOM.preconnect(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
1025
- getValueDescriptorExpectingObjectForWarning(href)
1026
- );
1027
- "string" === typeof href && (options ? (options = options.crossOrigin, options = "string" === typeof options ? "use-credentials" === options ? options : "" : void 0) : options = null, Internals.d.C(href, options));
1028
- };
1029
- exports.prefetchDNS = function(href) {
1030
- if ("string" !== typeof href || !href)
1031
- console.error(
1032
- "ReactDOM.prefetchDNS(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
1033
- getValueDescriptorExpectingObjectForWarning(href)
1034
- );
1035
- else if (1 < arguments.length) {
1036
- var options = arguments[1];
1037
- "object" === typeof options && options.hasOwnProperty("crossOrigin") ? console.error(
1038
- "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. It looks like the you are attempting to set a crossOrigin property for this DNS lookup hint. Browsers do not perform DNS queries using CORS and setting this attribute on the resource hint has no effect. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",
1039
- getValueDescriptorExpectingEnumForWarning(options)
1040
- ) : console.error(
1041
- "ReactDOM.prefetchDNS(): Expected only one argument, `href`, but encountered %s as a second argument instead. This argument is reserved for future options and is currently disallowed. Try calling ReactDOM.prefetchDNS() with just a single string argument, `href`.",
1042
- getValueDescriptorExpectingEnumForWarning(options)
1043
- );
1044
- }
1045
- "string" === typeof href && Internals.d.D(href);
1046
- };
1047
- exports.preinit = function(href, options) {
1048
- "string" === typeof href && href ? null == options || "object" !== typeof options ? console.error(
1049
- "ReactDOM.preinit(): Expected the `options` argument (second) to be an object with an `as` property describing the type of resource to be preinitialized but encountered %s instead.",
1050
- getValueDescriptorExpectingEnumForWarning(options)
1051
- ) : "style" !== options.as && "script" !== options.as && console.error(
1052
- 'ReactDOM.preinit(): Expected the `as` property in the `options` argument (second) to contain a valid value describing the type of resource to be preinitialized but encountered %s instead. Valid values for `as` are "style" and "script".',
1053
- getValueDescriptorExpectingEnumForWarning(options.as)
1054
- ) : console.error(
1055
- "ReactDOM.preinit(): Expected the `href` argument (first) to be a non-empty string but encountered %s instead.",
1056
- getValueDescriptorExpectingObjectForWarning(href)
1057
- );
1058
- if ("string" === typeof href && options && "string" === typeof options.as) {
1059
- var as = options.as, crossOrigin = getCrossOriginStringAs(as, options.crossOrigin), integrity = "string" === typeof options.integrity ? options.integrity : void 0, fetchPriority = "string" === typeof options.fetchPriority ? options.fetchPriority : void 0;
1060
- "style" === as ? Internals.d.S(
1061
- href,
1062
- "string" === typeof options.precedence ? options.precedence : void 0,
1063
- {
1064
- crossOrigin,
1065
- integrity,
1066
- fetchPriority
1067
- }
1068
- ) : "script" === as && Internals.d.X(href, {
1069
- crossOrigin,
1070
- integrity,
1071
- fetchPriority,
1072
- nonce: "string" === typeof options.nonce ? options.nonce : void 0
1073
- });
1074
- }
1075
- };
1076
- exports.preinitModule = function(href, options) {
1077
- var encountered = "";
1078
- "string" === typeof href && href || (encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".");
1079
- void 0 !== options && "object" !== typeof options ? encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + "." : options && "as" in options && "script" !== options.as && (encountered += " The `as` option encountered was " + getValueDescriptorExpectingEnumForWarning(options.as) + ".");
1080
- if (encountered)
1081
- console.error(
1082
- "ReactDOM.preinitModule(): Expected up to two arguments, a non-empty `href` string and, optionally, an `options` object with a valid `as` property.%s",
1083
- encountered
1084
- );
1085
- else
1086
- switch (encountered = options && "string" === typeof options.as ? options.as : "script", encountered) {
1087
- case "script":
1088
- break;
1089
- default:
1090
- encountered = getValueDescriptorExpectingEnumForWarning(encountered), console.error(
1091
- 'ReactDOM.preinitModule(): Currently the only supported "as" type for this function is "script" but received "%s" instead. This warning was generated for `href` "%s". In the future other module types will be supported, aligning with the import-attributes proposal. Learn more here: (https://github.com/tc39/proposal-import-attributes)',
1092
- encountered,
1093
- href
1094
- );
1095
- }
1096
- if ("string" === typeof href)
1097
- if ("object" === typeof options && null !== options) {
1098
- if (null == options.as || "script" === options.as)
1099
- encountered = getCrossOriginStringAs(
1100
- options.as,
1101
- options.crossOrigin
1102
- ), Internals.d.M(href, {
1103
- crossOrigin: encountered,
1104
- integrity: "string" === typeof options.integrity ? options.integrity : void 0,
1105
- nonce: "string" === typeof options.nonce ? options.nonce : void 0
1106
- });
1107
- } else null == options && Internals.d.M(href);
1108
- };
1109
- exports.preload = function(href, options) {
1110
- var encountered = "";
1111
- "string" === typeof href && href || (encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".");
1112
- null == options || "object" !== typeof options ? encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + "." : "string" === typeof options.as && options.as || (encountered += " The `as` option encountered was " + getValueDescriptorExpectingObjectForWarning(options.as) + ".");
1113
- encountered && console.error(
1114
- 'ReactDOM.preload(): Expected two arguments, a non-empty `href` string and an `options` object with an `as` property valid for a `<link rel="preload" as="..." />` tag.%s',
1115
- encountered
1116
- );
1117
- if ("string" === typeof href && "object" === typeof options && null !== options && "string" === typeof options.as) {
1118
- encountered = options.as;
1119
- var crossOrigin = getCrossOriginStringAs(
1120
- encountered,
1121
- options.crossOrigin
1122
- );
1123
- Internals.d.L(href, encountered, {
1124
- crossOrigin,
1125
- integrity: "string" === typeof options.integrity ? options.integrity : void 0,
1126
- nonce: "string" === typeof options.nonce ? options.nonce : void 0,
1127
- type: "string" === typeof options.type ? options.type : void 0,
1128
- fetchPriority: "string" === typeof options.fetchPriority ? options.fetchPriority : void 0,
1129
- referrerPolicy: "string" === typeof options.referrerPolicy ? options.referrerPolicy : void 0,
1130
- imageSrcSet: "string" === typeof options.imageSrcSet ? options.imageSrcSet : void 0,
1131
- imageSizes: "string" === typeof options.imageSizes ? options.imageSizes : void 0,
1132
- media: "string" === typeof options.media ? options.media : void 0
1133
- });
1134
- }
1135
- };
1136
- exports.preloadModule = function(href, options) {
1137
- var encountered = "";
1138
- "string" === typeof href && href || (encountered += " The `href` argument encountered was " + getValueDescriptorExpectingObjectForWarning(href) + ".");
1139
- void 0 !== options && "object" !== typeof options ? encountered += " The `options` argument encountered was " + getValueDescriptorExpectingObjectForWarning(options) + "." : options && "as" in options && "string" !== typeof options.as && (encountered += " The `as` option encountered was " + getValueDescriptorExpectingObjectForWarning(options.as) + ".");
1140
- encountered && console.error(
1141
- 'ReactDOM.preloadModule(): Expected two arguments, a non-empty `href` string and, optionally, an `options` object with an `as` property valid for a `<link rel="modulepreload" as="..." />` tag.%s',
1142
- encountered
1143
- );
1144
- "string" === typeof href && (options ? (encountered = getCrossOriginStringAs(
1145
- options.as,
1146
- options.crossOrigin
1147
- ), Internals.d.m(href, {
1148
- as: "string" === typeof options.as && "script" !== options.as ? options.as : void 0,
1149
- crossOrigin: encountered,
1150
- integrity: "string" === typeof options.integrity ? options.integrity : void 0
1151
- })) : Internals.d.m(href));
1152
- };
1153
- exports.requestFormReset = function(form) {
1154
- Internals.d.r(form);
1155
- };
1156
- exports.unstable_batchedUpdates = function(fn, a) {
1157
- return fn(a);
1158
- };
1159
- exports.useFormState = function(action, initialState, permalink) {
1160
- return resolveDispatcher().useFormState(action, initialState, permalink);
1161
- };
1162
- exports.useFormStatus = function() {
1163
- return resolveDispatcher().useHostTransitionStatus();
1164
- };
1165
- exports.version = "19.1.0";
1166
- "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1167
- })();
1168
- }
1169
- });
1170
-
1171
- // node_modules/react-dom/index.js
1172
- var require_react_dom = __commonJS({
1173
- "node_modules/react-dom/index.js"(exports, module) {
1174
- "use strict";
1175
- if (false) {
1176
- checkDCE();
1177
- module.exports = null;
1178
- } else {
1179
- module.exports = require_react_dom_development();
1180
- }
1181
- }
1182
- });
1183
-
1184
921
  // src/PCBViewer.tsx
1185
922
  import { applyEditEvents } from "@tscircuit/core";
1186
923
 
@@ -5622,7 +5359,8 @@ var filterTraceByLayers = (trace, targetLayers) => {
5622
5359
  const wireCount = filteredRoute.filter(
5623
5360
  (segment) => segment.route_type === "wire"
5624
5361
  ).length;
5625
- if (wireCount < 2) return null;
5362
+ const hasVia = filteredRoute.some((segment) => segment.route_type === "via");
5363
+ if (wireCount < 2 && !hasVia) return null;
5626
5364
  return {
5627
5365
  ...trace,
5628
5366
  route: filteredRoute
@@ -5640,7 +5378,7 @@ var showTraceSegmentsInsideHiddenCopperPours = (trace) => ({
5640
5378
  };
5641
5379
  })
5642
5380
  });
5643
- var getTraceClipContextElements = (elements, showCopperPours) => showCopperPours ? elements : [];
5381
+ var getTraceClipContextElements = (elements, showCopperPours) => showCopperPours ? elements : elements.filter((element) => element.type !== "pcb_copper_pour");
5644
5382
  var getHighlightedTraceElementIds = ({
5645
5383
  primitives
5646
5384
  }) => {
@@ -6275,6 +6013,7 @@ function drawSoldermaskElementsForLayer({
6275
6013
  hoverDrawer.realToCanvasMat = realToCanvasMat;
6276
6014
  hoverDrawer.drawElements(hoveredElements, {
6277
6015
  layers,
6016
+ clipContextElements: elements,
6278
6017
  drawSoldermask: true,
6279
6018
  drawSoldermaskTop,
6280
6019
  drawSoldermaskBottom,
@@ -6336,7 +6075,13 @@ function drawPcbViaElementsForLayer({
6336
6075
  if (nonHighlightedElements.length > 0) {
6337
6076
  const drawer = new CircuitToCanvasDrawer16(canvas);
6338
6077
  drawer.realToCanvasMat = realToCanvasMat;
6339
- drawer.drawElements(nonHighlightedElements, { layers, drawSoldermask });
6078
+ drawer.drawElements(nonHighlightedElements, {
6079
+ layers,
6080
+ drawSoldermask,
6081
+ drawSoldermaskTop: layers.includes("top_copper"),
6082
+ drawSoldermaskBottom: layers.includes("bottom_copper"),
6083
+ clipContextElements: elements
6084
+ });
6340
6085
  }
6341
6086
  if (highlightedElements.length > 0) {
6342
6087
  const highlightDrawer = new CircuitToCanvasDrawer16(canvas);
@@ -6344,7 +6089,10 @@ function drawPcbViaElementsForLayer({
6344
6089
  highlightDrawer.realToCanvasMat = realToCanvasMat;
6345
6090
  highlightDrawer.drawElements(highlightedElements, {
6346
6091
  layers,
6347
- drawSoldermask
6092
+ drawSoldermask,
6093
+ drawSoldermaskTop: layers.includes("top_copper"),
6094
+ drawSoldermaskBottom: layers.includes("bottom_copper"),
6095
+ clipContextElements: elements
6348
6096
  });
6349
6097
  }
6350
6098
  }
@@ -10919,7 +10667,7 @@ import { css as css3 } from "@emotion/css";
10919
10667
  // package.json
10920
10668
  var package_default = {
10921
10669
  name: "@tscircuit/pcb-viewer",
10922
- version: "1.11.395",
10670
+ version: "1.11.397",
10923
10671
  main: "dist/index.js",
10924
10672
  type: "module",
10925
10673
  repository: {
@@ -10929,7 +10677,7 @@ var package_default = {
10929
10677
  license: "MIT",
10930
10678
  scripts: {
10931
10679
  start: "cosmos",
10932
- build: "tsup ./src/index.tsx --platform browser --external @tscircuit/core --dts --sourcemap --format esm --outDir dist",
10680
+ build: "tsup ./src/index.tsx --platform browser --dts --sourcemap --format esm --outDir dist",
10933
10681
  yalc: "npm run build && yalc push",
10934
10682
  format: "biome format . --write",
10935
10683
  "format:check": "biome format .",
@@ -10970,6 +10718,7 @@ var package_default = {
10970
10718
  },
10971
10719
  peerDependencies: {
10972
10720
  react: "*",
10721
+ "react-dom": "*",
10973
10722
  tscircuit: "*"
10974
10723
  },
10975
10724
  dependencies: {
@@ -10977,8 +10726,8 @@ var package_default = {
10977
10726
  "@tscircuit/alphabet": "^0.0.25",
10978
10727
  "@tscircuit/math-utils": "^0.0.36",
10979
10728
  "@vitejs/plugin-react": "^5.0.2",
10980
- "circuit-json": "^0.0.469",
10981
- "circuit-to-canvas": "0.0.124",
10729
+ "circuit-json": "^0.0.492",
10730
+ "circuit-to-canvas": "0.0.128",
10982
10731
  color: "^4.2.3",
10983
10732
  "react-supergrid": "^1.0.10",
10984
10733
  "react-toastify": "^10.0.5",
@@ -11078,9 +10827,9 @@ var useMobileTouch = (onClick, options = { stopPropagation: true }) => {
11078
10827
  };
11079
10828
 
11080
10829
  // src/components/VisibilityContextMenu.tsx
11081
- var import_react_dom = __toESM(require_react_dom(), 1);
11082
10830
  import { css as css2 } from "@emotion/css";
11083
10831
  import { useEffect as useEffect14, useRef as useRef11, useState as useState9 } from "react";
10832
+ import { createPortal } from "react-dom";
11084
10833
  import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
11085
10834
  var menuStyle = css2`
11086
10835
  background: #222;
@@ -11143,7 +10892,7 @@ var VisibilityContextMenu = ({
11143
10892
  window.removeEventListener("scroll", onClose, true);
11144
10893
  };
11145
10894
  }, [onClose]);
11146
- return (0, import_react_dom.createPortal)(
10895
+ return createPortal(
11147
10896
  /* @__PURE__ */ jsx19(
11148
10897
  "div",
11149
10898
  {
@@ -12786,6 +12535,16 @@ var calculateCircuitJsonKey = (circuitJson) => {
12786
12535
  if (element.type === "pcb_trace") {
12787
12536
  const routeLength = (element.route ?? []).length;
12788
12537
  signature += `:${routeLength}`;
12538
+ for (const point of element.route ?? []) {
12539
+ if (point.route_type !== "via") continue;
12540
+ signature += `:${point.tented_on_top}:${point.tented_on_bottom}`;
12541
+ }
12542
+ }
12543
+ if (element.type === "pcb_board") {
12544
+ signature += `:${element.default_via_tented_on_top}:${element.default_via_tented_on_bottom}`;
12545
+ }
12546
+ if (element.type === "pcb_via") {
12547
+ signature += `:${element.tented_on_top}:${element.tented_on_bottom}`;
12789
12548
  }
12790
12549
  elementSignatures.push(signature);
12791
12550
  }
@@ -13035,16 +12794,5 @@ svgson/dist/svgson.umd.js:
13035
12794
  * @author Feross Aboukhadijeh <https://feross.org>
13036
12795
  * @license MIT
13037
12796
  *)
13038
-
13039
- react-dom/cjs/react-dom.development.js:
13040
- (**
13041
- * @license React
13042
- * react-dom.development.js
13043
- *
13044
- * Copyright (c) Meta Platforms, Inc. and affiliates.
13045
- *
13046
- * This source code is licensed under the MIT license found in the
13047
- * LICENSE file in the root directory of this source tree.
13048
- *)
13049
12797
  */
13050
12798
  //# sourceMappingURL=index.js.map