@tscircuit/3d-viewer 0.0.526 → 0.0.527

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.d.ts CHANGED
@@ -61,6 +61,7 @@ interface LayerVisibilityState {
61
61
  modelsMarkedDNP: boolean;
62
62
  modelBoundingBoxes: boolean;
63
63
  threedAxis: boolean;
64
+ pcbNotes: boolean;
64
65
  backgroundStart: boolean;
65
66
  backgroundEnd: boolean;
66
67
  }
package/dist/index.js CHANGED
@@ -14469,6 +14469,7 @@ var defaultVisibility = {
14469
14469
  modelsMarkedDNP: false,
14470
14470
  modelBoundingBoxes: false,
14471
14471
  threedAxis: false,
14472
+ pcbNotes: false,
14472
14473
  backgroundStart: true,
14473
14474
  backgroundEnd: true
14474
14475
  };
@@ -28768,7 +28769,7 @@ import * as THREE16 from "three";
28768
28769
  // package.json
28769
28770
  var package_default = {
28770
28771
  name: "@tscircuit/3d-viewer",
28771
- version: "0.0.525",
28772
+ version: "0.0.526",
28772
28773
  main: "./dist/index.js",
28773
28774
  module: "./dist/index.js",
28774
28775
  type: "module",
@@ -28798,7 +28799,7 @@ var package_default = {
28798
28799
  "@jscad/regl-renderer": "^2.6.12",
28799
28800
  "@jscad/stl-serializer": "^2.1.20",
28800
28801
  "circuit-json": "^0.0.372",
28801
- "circuit-to-canvas": "^0.0.83",
28802
+ "circuit-to-canvas": "^0.0.87",
28802
28803
  "react-hot-toast": "^2.6.0",
28803
28804
  three: "^0.165.0",
28804
28805
  "three-stdlib": "^2.36.0",
@@ -32988,7 +32989,8 @@ function createCombinedBoardTextures({
32988
32989
  boardData,
32989
32990
  traceTextureResolution
32990
32991
  }) : null;
32991
- const pcbNoteTexture = showSilkscreen ? createPcbNoteTextureForLayer({
32992
+ const showPcbNotes = visibility?.pcbNotes ?? false;
32993
+ const pcbNoteTexture = showPcbNotes ? createPcbNoteTextureForLayer({
32992
32994
  layer,
32993
32995
  circuitJson,
32994
32996
  boardData,
@@ -36631,10 +36633,6 @@ var oppositeSideMap = {
36631
36633
  bottom: "top",
36632
36634
  top: "bottom"
36633
36635
  };
36634
- var oppositeAlignmentMap = {
36635
- start: "end",
36636
- end: "start"
36637
- };
36638
36636
  function clamp2(start, value, end) {
36639
36637
  return max(start, min(value, end));
36640
36638
  }
@@ -36653,9 +36651,9 @@ function getOppositeAxis(axis) {
36653
36651
  function getAxisLength(axis) {
36654
36652
  return axis === "y" ? "height" : "width";
36655
36653
  }
36656
- var yAxisSides = /* @__PURE__ */ new Set(["top", "bottom"]);
36657
36654
  function getSideAxis(placement) {
36658
- return yAxisSides.has(getSide(placement)) ? "y" : "x";
36655
+ const firstChar = placement[0];
36656
+ return firstChar === "t" || firstChar === "b" ? "y" : "x";
36659
36657
  }
36660
36658
  function getAlignmentAxis(placement) {
36661
36659
  return getOppositeAxis(getSideAxis(placement));
@@ -36678,7 +36676,7 @@ function getExpandedPlacements(placement) {
36678
36676
  return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
36679
36677
  }
36680
36678
  function getOppositeAlignmentPlacement(placement) {
36681
- return placement.replace(/start|end/g, (alignment) => oppositeAlignmentMap[alignment]);
36679
+ return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
36682
36680
  }
36683
36681
  var lrPlacement = ["left", "right"];
36684
36682
  var rlPlacement = ["right", "left"];
@@ -36709,7 +36707,8 @@ function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
36709
36707
  return list;
36710
36708
  }
36711
36709
  function getOppositePlacement(placement) {
36712
- return placement.replace(/left|right|bottom|top/g, (side) => oppositeSideMap[side]);
36710
+ const side = getSide(placement);
36711
+ return oppositeSideMap[side] + placement.slice(side.length);
36713
36712
  }
36714
36713
  function expandPaddingObject(padding) {
36715
36714
  return {
@@ -36859,6 +36858,7 @@ async function detectOverflow(state, options) {
36859
36858
  right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
36860
36859
  };
36861
36860
  }
36861
+ var MAX_RESET_COUNT = 50;
36862
36862
  var computePosition = async (reference, floating, config) => {
36863
36863
  const {
36864
36864
  placement = "bottom",
@@ -36866,7 +36866,10 @@ var computePosition = async (reference, floating, config) => {
36866
36866
  middleware = [],
36867
36867
  platform: platform2
36868
36868
  } = config;
36869
- const validMiddleware = middleware.filter(Boolean);
36869
+ const platformWithDetectOverflow = platform2.detectOverflow ? platform2 : {
36870
+ ...platform2,
36871
+ detectOverflow
36872
+ };
36870
36873
  const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(floating));
36871
36874
  let rects = await platform2.getElementRects({
36872
36875
  reference,
@@ -36878,14 +36881,17 @@ var computePosition = async (reference, floating, config) => {
36878
36881
  y
36879
36882
  } = computeCoordsFromPlacement(rects, placement, rtl);
36880
36883
  let statefulPlacement = placement;
36881
- let middlewareData = {};
36882
36884
  let resetCount = 0;
36883
- for (let i = 0; i < validMiddleware.length; i++) {
36884
- var _platform$detectOverf;
36885
+ const middlewareData = {};
36886
+ for (let i = 0; i < middleware.length; i++) {
36887
+ const currentMiddleware = middleware[i];
36888
+ if (!currentMiddleware) {
36889
+ continue;
36890
+ }
36885
36891
  const {
36886
36892
  name,
36887
36893
  fn
36888
- } = validMiddleware[i];
36894
+ } = currentMiddleware;
36889
36895
  const {
36890
36896
  x: nextX,
36891
36897
  y: nextY,
@@ -36899,10 +36905,7 @@ var computePosition = async (reference, floating, config) => {
36899
36905
  strategy,
36900
36906
  middlewareData,
36901
36907
  rects,
36902
- platform: {
36903
- ...platform2,
36904
- detectOverflow: (_platform$detectOverf = platform2.detectOverflow) != null ? _platform$detectOverf : detectOverflow
36905
- },
36908
+ platform: platformWithDetectOverflow,
36906
36909
  elements: {
36907
36910
  reference,
36908
36911
  floating
@@ -36910,14 +36913,11 @@ var computePosition = async (reference, floating, config) => {
36910
36913
  });
36911
36914
  x = nextX != null ? nextX : x;
36912
36915
  y = nextY != null ? nextY : y;
36913
- middlewareData = {
36914
- ...middlewareData,
36915
- [name]: {
36916
- ...middlewareData[name],
36917
- ...data
36918
- }
36916
+ middlewareData[name] = {
36917
+ ...middlewareData[name],
36918
+ ...data
36919
36919
  };
36920
- if (reset && resetCount <= 50) {
36920
+ if (reset && resetCount < MAX_RESET_COUNT) {
36921
36921
  resetCount++;
36922
36922
  if (typeof reset === "object") {
36923
36923
  if (reset.placement) {
@@ -37505,7 +37505,6 @@ function isShadowRoot(value) {
37505
37505
  }
37506
37506
  return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
37507
37507
  }
37508
- var invalidOverflowDisplayValues = /* @__PURE__ */ new Set(["inline", "contents"]);
37509
37508
  function isOverflowElement(element) {
37510
37509
  const {
37511
37510
  overflow,
@@ -37513,29 +37512,31 @@ function isOverflowElement(element) {
37513
37512
  overflowY,
37514
37513
  display
37515
37514
  } = getComputedStyle2(element);
37516
- return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && !invalidOverflowDisplayValues.has(display);
37515
+ return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
37517
37516
  }
37518
- var tableElements = /* @__PURE__ */ new Set(["table", "td", "th"]);
37519
37517
  function isTableElement(element) {
37520
- return tableElements.has(getNodeName(element));
37518
+ return /^(table|td|th)$/.test(getNodeName(element));
37521
37519
  }
37522
- var topLayerSelectors = [":popover-open", ":modal"];
37523
37520
  function isTopLayer(element) {
37524
- return topLayerSelectors.some((selector) => {
37525
- try {
37526
- return element.matches(selector);
37527
- } catch (_e) {
37528
- return false;
37521
+ try {
37522
+ if (element.matches(":popover-open")) {
37523
+ return true;
37529
37524
  }
37530
- });
37525
+ } catch (_e) {
37526
+ }
37527
+ try {
37528
+ return element.matches(":modal");
37529
+ } catch (_e) {
37530
+ return false;
37531
+ }
37531
37532
  }
37532
- var transformProperties = ["transform", "translate", "scale", "rotate", "perspective"];
37533
- var willChangeValues = ["transform", "translate", "scale", "rotate", "perspective", "filter"];
37534
- var containValues = ["paint", "layout", "strict", "content"];
37533
+ var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
37534
+ var containRe = /paint|layout|strict|content/;
37535
+ var isNotNone = (value) => !!value && value !== "none";
37536
+ var isWebKitValue;
37535
37537
  function isContainingBlock(elementOrCss) {
37536
- const webkit = isWebKit();
37537
37538
  const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
37538
- return transformProperties.some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || willChangeValues.some((value) => (css.willChange || "").includes(value)) || containValues.some((value) => (css.contain || "").includes(value));
37539
+ return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
37539
37540
  }
37540
37541
  function getContainingBlock(element) {
37541
37542
  let currentNode = getParentNode(element);
@@ -37550,12 +37551,13 @@ function getContainingBlock(element) {
37550
37551
  return null;
37551
37552
  }
37552
37553
  function isWebKit() {
37553
- if (typeof CSS === "undefined" || !CSS.supports) return false;
37554
- return CSS.supports("-webkit-backdrop-filter", "none");
37554
+ if (isWebKitValue == null) {
37555
+ isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
37556
+ }
37557
+ return isWebKitValue;
37555
37558
  }
37556
- var lastTraversableNodeNames = /* @__PURE__ */ new Set(["html", "body", "#document"]);
37557
37559
  function isLastTraversableNode(node) {
37558
- return lastTraversableNodeNames.has(getNodeName(node));
37560
+ return /^(html|body|#document)$/.test(getNodeName(node));
37559
37561
  }
37560
37562
  function getComputedStyle2(element) {
37561
37563
  return getWindow(element).getComputedStyle(element);
@@ -37609,8 +37611,9 @@ function getOverflowAncestors(node, list, traverseIframes) {
37609
37611
  if (isBody) {
37610
37612
  const frameElement = getFrameElement(win);
37611
37613
  return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
37614
+ } else {
37615
+ return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
37612
37616
  }
37613
- return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
37614
37617
  }
37615
37618
  function getFrameElement(win) {
37616
37619
  return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
@@ -37774,7 +37777,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
37774
37777
  if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
37775
37778
  scroll = getNodeScroll(offsetParent);
37776
37779
  }
37777
- if (isHTMLElement(offsetParent)) {
37780
+ if (isOffsetParentAnElement) {
37778
37781
  const offsetRect = getBoundingClientRect(offsetParent);
37779
37782
  scale2 = getScale(offsetParent);
37780
37783
  offsets.x = offsetRect.x + offsetParent.clientLeft;
@@ -37848,7 +37851,6 @@ function getViewportRect(element, strategy) {
37848
37851
  y
37849
37852
  };
37850
37853
  }
37851
- var absoluteOrFixed = /* @__PURE__ */ new Set(["absolute", "fixed"]);
37852
37854
  function getInnerBoundingClientRect(element, strategy) {
37853
37855
  const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
37854
37856
  const top = clientRect.top + element.clientTop;
@@ -37906,7 +37908,7 @@ function getClippingElementAncestors(element, cache) {
37906
37908
  if (!currentNodeIsContaining && computedStyle.position === "fixed") {
37907
37909
  currentContainingBlockComputedStyle = null;
37908
37910
  }
37909
- const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && absoluteOrFixed.has(currentContainingBlockComputedStyle.position) || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
37911
+ const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
37910
37912
  if (shouldDropCurrentNode) {
37911
37913
  result = result.filter((ancestor) => ancestor !== currentNode);
37912
37914
  } else {
@@ -37926,20 +37928,23 @@ function getClippingRect(_ref) {
37926
37928
  } = _ref;
37927
37929
  const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
37928
37930
  const clippingAncestors = [...elementClippingAncestors, rootBoundary];
37929
- const firstClippingAncestor = clippingAncestors[0];
37930
- const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
37931
- const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
37932
- accRect.top = max(rect.top, accRect.top);
37933
- accRect.right = min(rect.right, accRect.right);
37934
- accRect.bottom = min(rect.bottom, accRect.bottom);
37935
- accRect.left = max(rect.left, accRect.left);
37936
- return accRect;
37937
- }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
37931
+ const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
37932
+ let top = firstRect.top;
37933
+ let right = firstRect.right;
37934
+ let bottom = firstRect.bottom;
37935
+ let left = firstRect.left;
37936
+ for (let i = 1; i < clippingAncestors.length; i++) {
37937
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i], strategy);
37938
+ top = max(rect.top, top);
37939
+ right = min(rect.right, right);
37940
+ bottom = min(rect.bottom, bottom);
37941
+ left = max(rect.left, left);
37942
+ }
37938
37943
  return {
37939
- width: clippingRect.right - clippingRect.left,
37940
- height: clippingRect.bottom - clippingRect.top,
37941
- x: clippingRect.left,
37942
- y: clippingRect.top
37944
+ width: right - left,
37945
+ height: bottom - top,
37946
+ x: left,
37947
+ y: top
37943
37948
  };
37944
37949
  }
37945
37950
  function getDimensions(element) {
@@ -38148,7 +38153,7 @@ function autoUpdate(reference, floating, update, options) {
38148
38153
  animationFrame = false
38149
38154
  } = options;
38150
38155
  const referenceEl = unwrapElement(reference);
38151
- const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...getOverflowAncestors(floating)] : [];
38156
+ const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
38152
38157
  ancestors.forEach((ancestor) => {
38153
38158
  ancestorScroll && ancestor.addEventListener("scroll", update, {
38154
38159
  passive: true
@@ -38161,7 +38166,7 @@ function autoUpdate(reference, floating, update, options) {
38161
38166
  if (elementResize) {
38162
38167
  resizeObserver = new ResizeObserver((_ref) => {
38163
38168
  let [firstEntry] = _ref;
38164
- if (firstEntry && firstEntry.target === referenceEl && resizeObserver) {
38169
+ if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
38165
38170
  resizeObserver.unobserve(floating);
38166
38171
  cancelAnimationFrame(reobserveFrame);
38167
38172
  reobserveFrame = requestAnimationFrame(() => {
@@ -38174,7 +38179,9 @@ function autoUpdate(reference, floating, update, options) {
38174
38179
  if (referenceEl && !animationFrame) {
38175
38180
  resizeObserver.observe(referenceEl);
38176
38181
  }
38177
- resizeObserver.observe(floating);
38182
+ if (floating) {
38183
+ resizeObserver.observe(floating);
38184
+ }
38178
38185
  }
38179
38186
  let frameId;
38180
38187
  let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
@@ -38482,34 +38489,61 @@ var arrow$1 = (options) => {
38482
38489
  }
38483
38490
  };
38484
38491
  };
38485
- var offset3 = (options, deps) => ({
38486
- ...offset2(options),
38487
- options: [options, deps]
38488
- });
38489
- var shift3 = (options, deps) => ({
38490
- ...shift2(options),
38491
- options: [options, deps]
38492
- });
38493
- var limitShift3 = (options, deps) => ({
38494
- ...limitShift2(options),
38495
- options: [options, deps]
38496
- });
38497
- var flip3 = (options, deps) => ({
38498
- ...flip2(options),
38499
- options: [options, deps]
38500
- });
38501
- var size3 = (options, deps) => ({
38502
- ...size2(options),
38503
- options: [options, deps]
38504
- });
38505
- var hide3 = (options, deps) => ({
38506
- ...hide2(options),
38507
- options: [options, deps]
38508
- });
38509
- var arrow3 = (options, deps) => ({
38510
- ...arrow$1(options),
38511
- options: [options, deps]
38512
- });
38492
+ var offset3 = (options, deps) => {
38493
+ const result = offset2(options);
38494
+ return {
38495
+ name: result.name,
38496
+ fn: result.fn,
38497
+ options: [options, deps]
38498
+ };
38499
+ };
38500
+ var shift3 = (options, deps) => {
38501
+ const result = shift2(options);
38502
+ return {
38503
+ name: result.name,
38504
+ fn: result.fn,
38505
+ options: [options, deps]
38506
+ };
38507
+ };
38508
+ var limitShift3 = (options, deps) => {
38509
+ const result = limitShift2(options);
38510
+ return {
38511
+ fn: result.fn,
38512
+ options: [options, deps]
38513
+ };
38514
+ };
38515
+ var flip3 = (options, deps) => {
38516
+ const result = flip2(options);
38517
+ return {
38518
+ name: result.name,
38519
+ fn: result.fn,
38520
+ options: [options, deps]
38521
+ };
38522
+ };
38523
+ var size3 = (options, deps) => {
38524
+ const result = size2(options);
38525
+ return {
38526
+ name: result.name,
38527
+ fn: result.fn,
38528
+ options: [options, deps]
38529
+ };
38530
+ };
38531
+ var hide3 = (options, deps) => {
38532
+ const result = hide2(options);
38533
+ return {
38534
+ name: result.name,
38535
+ fn: result.fn,
38536
+ options: [options, deps]
38537
+ };
38538
+ };
38539
+ var arrow3 = (options, deps) => {
38540
+ const result = arrow$1(options);
38541
+ return {
38542
+ name: result.name,
38543
+ fn: result.fn,
38544
+ options: [options, deps]
38545
+ };
38546
+ };
38513
38547
 
38514
38548
  // node_modules/@radix-ui/react-arrow/dist/index.mjs
38515
38549
  import * as React29 from "react";
@@ -41399,6 +41433,27 @@ var AppearanceMenu = () => {
41399
41433
  ]
41400
41434
  }
41401
41435
  ),
41436
+ /* @__PURE__ */ jsxs8(
41437
+ Item22,
41438
+ {
41439
+ style: {
41440
+ ...itemStyles,
41441
+ backgroundColor: hoveredItem === "pcbNotes" ? "#404040" : "transparent"
41442
+ },
41443
+ onSelect: (e) => e.preventDefault(),
41444
+ onPointerDown: (e) => {
41445
+ e.preventDefault();
41446
+ setLayerVisibility("pcbNotes", !visibility.pcbNotes);
41447
+ },
41448
+ onMouseEnter: () => setHoveredItem("pcbNotes"),
41449
+ onMouseLeave: () => setHoveredItem(null),
41450
+ onTouchStart: () => setHoveredItem("pcbNotes"),
41451
+ children: [
41452
+ /* @__PURE__ */ jsx35("span", { style: iconContainerStyles, children: visibility.pcbNotes && /* @__PURE__ */ jsx35(CheckIcon, {}) }),
41453
+ /* @__PURE__ */ jsx35("span", { style: { display: "flex", alignItems: "center" }, children: "PCB Notes" })
41454
+ ]
41455
+ }
41456
+ ),
41402
41457
  /* @__PURE__ */ jsxs8(
41403
41458
  Item22,
41404
41459
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/3d-viewer",
3
- "version": "0.0.526",
3
+ "version": "0.0.527",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "type": "module",
@@ -30,7 +30,7 @@
30
30
  "@jscad/regl-renderer": "^2.6.12",
31
31
  "@jscad/stl-serializer": "^2.1.20",
32
32
  "circuit-json": "^0.0.372",
33
- "circuit-to-canvas": "^0.0.83",
33
+ "circuit-to-canvas": "^0.0.87",
34
34
  "react-hot-toast": "^2.6.0",
35
35
  "three": "^0.165.0",
36
36
  "three-stdlib": "^2.36.0",