@tscircuit/pcb-viewer 1.9.2 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -11455,20 +11455,20 @@ var require_dist3 = __commonJS({
11455
11455
  });
11456
11456
  module2.exports = __toCommonJS2(src_exports2);
11457
11457
  var import_transformation_matrix10 = require("transformation-matrix");
11458
- var import_react19 = require("react");
11458
+ var import_react20 = require("react");
11459
11459
  var useMouseMatrixTransform2 = function() {
11460
11460
  var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
11461
- var extRef = (0, import_react19.useRef)(null);
11462
- var _ref = _sliced_to_array((0, import_react19.useState)(0), 2), lastDragCancelTime = _ref[0], setLastDragCancelTime = _ref[1];
11461
+ var extRef = (0, import_react20.useRef)(null);
11462
+ var _ref = _sliced_to_array((0, import_react20.useState)(0), 2), lastDragCancelTime = _ref[0], setLastDragCancelTime = _ref[1];
11463
11463
  var _props_canvasElm;
11464
11464
  var outerCanvasElm = (_props_canvasElm = props.canvasElm) !== null && _props_canvasElm !== void 0 ? _props_canvasElm : extRef.current;
11465
11465
  var _props_initialTransform;
11466
- var _ref1 = _sliced_to_array((0, import_react19.useState)((_props_initialTransform = props.initialTransform) !== null && _props_initialTransform !== void 0 ? _props_initialTransform : (0, import_transformation_matrix10.identity)()), 2), internalTransform = _ref1[0], setInternalTransform = _ref1[1];
11467
- var _ref2 = _sliced_to_array((0, import_react19.useState)(0), 2), waitCounter = _ref2[0], setWaitCounter = _ref2[1];
11468
- var _ref3 = _sliced_to_array((0, import_react19.useReducer)(function(s) {
11466
+ var _ref1 = _sliced_to_array((0, import_react20.useState)((_props_initialTransform = props.initialTransform) !== null && _props_initialTransform !== void 0 ? _props_initialTransform : (0, import_transformation_matrix10.identity)()), 2), internalTransform = _ref1[0], setInternalTransform = _ref1[1];
11467
+ var _ref2 = _sliced_to_array((0, import_react20.useState)(0), 2), waitCounter = _ref2[0], setWaitCounter = _ref2[1];
11468
+ var _ref3 = _sliced_to_array((0, import_react20.useReducer)(function(s) {
11469
11469
  return s + 1;
11470
11470
  }, 0), 2), extChangeCounter = _ref3[0], incExtChangeCounter = _ref3[1];
11471
- var setTransform = (0, import_react19.useCallback)(function(newTransform) {
11471
+ var setTransform = (0, import_react20.useCallback)(function(newTransform) {
11472
11472
  if (props.onSetTransform) {
11473
11473
  props.onSetTransform(newTransform);
11474
11474
  }
@@ -11479,7 +11479,7 @@ var require_dist3 = __commonJS({
11479
11479
  props.onSetTransform,
11480
11480
  setInternalTransform
11481
11481
  ]);
11482
- var setTransformExt = (0, import_react19.useCallback)(function(newTransform) {
11482
+ var setTransformExt = (0, import_react20.useCallback)(function(newTransform) {
11483
11483
  setTransform(newTransform);
11484
11484
  incExtChangeCounter();
11485
11485
  }, [
@@ -11487,10 +11487,10 @@ var require_dist3 = __commonJS({
11487
11487
  ]);
11488
11488
  var _props_transform;
11489
11489
  var transform = (_props_transform = props.transform) !== null && _props_transform !== void 0 ? _props_transform : internalTransform;
11490
- var cancelDrag = (0, import_react19.useCallback)(function() {
11490
+ var cancelDrag = (0, import_react20.useCallback)(function() {
11491
11491
  setLastDragCancelTime(Date.now());
11492
11492
  }, []);
11493
- (0, import_react19.useEffect)(function() {
11493
+ (0, import_react20.useEffect)(function() {
11494
11494
  var handleMouseDown = function handleMouseDown(e) {
11495
11495
  m0 = getMousePos(e);
11496
11496
  if (Date.now() - lastDragCancelTime < 100) return;
@@ -11582,7 +11582,7 @@ var require_dist3 = __commonJS({
11582
11582
  extChangeCounter,
11583
11583
  lastDragCancelTime
11584
11584
  ]);
11585
- var applyTransformToPoint = (0, import_react19.useCallback)(function(obj) {
11585
+ var applyTransformToPoint = (0, import_react20.useCallback)(function(obj) {
11586
11586
  return (0, import_transformation_matrix10.applyToPoint)(transform, obj);
11587
11587
  }, [
11588
11588
  transform
@@ -11613,236 +11613,14 @@ __export(src_exports, {
11613
11613
  });
11614
11614
  module.exports = __toCommonJS(src_exports);
11615
11615
  // src/PCBViewer.tsx
11616
- var import_react18 = require("react");
11616
+ var import_react19 = require("react");
11617
11617
  var import_react_fiber = require("@tscircuit/react-fiber");
11618
11618
  var import_builder2 = require("@tscircuit/builder");
11619
+ // src/components/CanvasElementsRenderer.tsx
11620
+ var import_react15 = require("react");
11619
11621
  // src/components/CanvasPrimitiveRenderer.tsx
11620
11622
  var import_react_supergrid = require("react-supergrid");
11621
11623
  var import_react4 = require("react");
11622
- // src/assets/alphabet.ts
11623
- var svgAlphabet = {
11624
- "0": "M0.4544564813877358 0L0.2723441540828736 0.03592830447352719L0.1086847233315459 0.14528754990019965L0.020630545837255005 0.3040632652221331L0 0.5395277421960205L0.049259221760993496 0.7369487828466779L0.18080513776237842 0.9005494166306564L0.37036887043974215 0.9872116270037247L0.5864663759301132 1L0.8148695622827444 0.9332890276148733L0.9326583645506394 0.8113052246023419L1 0.4031281830668562L0.833288960385582 0.09886798567812842L0.6801767918233781 0.02483708485091681L0.4544564813877358 0",
11625
- "1": "M 0.198 0.272 L 0.537 0 L 0.54 1",
11626
- "2": "M0.069593147751606 0.19461498231706575L0.1039380353319058 0.1224291500164194L0.20543361884368308 0.05510832064153169L0.3717712794432549 0.009452970962689482L0.4785344452623127 0L0.663238590738758 0.008714098643339864L0.8017933618843684 0.04769189395915288L0.8775637379550322 0.10746757678258442L0.9047778372591005 0.17693069668193287L0.9029710920770878 0.2231347105796246L0.8704496788008566 0.30047744598157516L0.7292906538577354 0.4508486051631194L0.3737955032119913 0.7369006417749693L0 1L1 1",
11627
- "3": "M0.03917438899874637 0.19855364635107545L0.15510940508963084 0.06745632622133718L0.37598645522339846 0L0.8486391893813088 0.0652271323161611L0.9782182415054349 0.21747394183735683L0.9213133780517754 0.3547560290117714L0.6504271515903481 0.4543436297681271L0.22975249764129613 0.48476611625264143L0.7659038682744629 0.5411919558122493L0.9258712987734741 0.6203185665660985L1 0.7458360609169667L0.8938813281118737 0.9059190913045964L0.6166890258875837 1L0.261528440153542 0.9874861530507921L0 0.8837289530851273",
11628
- "4": "M0.7328897338403042 0L0 0.6684672518568535L1 0.6684672518568535M0.7243346007604563 0.4530722484807562L0.7243346007604563 1",
11629
- "5": "M 0 0 L 0 0.4973 L 0.4262 0.4319 L 0.7305 0.4565 L 0.8516 0.5009 L 0.9357 0.5639 L 1 0.7356 L 0.9696 0.8248 L 0.8898 0.895 L 0.733 0.9602 L 0.5518 0.9945 L 0.3814 1 L 0.2379 0.9821 L 0.1219 0.947 L 0 0.8748 M 0 0 L 1 0",
11630
- "6": "M0.6964601700926856 0L0.3639239026215478 0.0743562375769351L0.1415931962925719 0.21735490179786915L0.009977939399608712 0.46336322325406004L0.00029622007592593224 0.7083131475173043L0.09408885043224748 0.8746809149767036L0.3379247445101846 0.9876686500961888L0.7109203869569624 1L0.9260852957913362 0.9103558029693921L1 0.7716571969091733L0.9824294723385016 0.6390635485705886L0.7446504992867332 0.4733643097729175L0.31028858071607296 0.47578021640899115L0.1208702146816024 0.5481452483973847L0 0.6616669755788906",
11631
- "7": "M0 0L1 0L0.9246479649697582 0.030539772727272752L0.8850302419354837 0.05075757575757579L0.7922946068548385 0.11079545454545457L0.7419268208165322 0.15213068181818185L0.6907258064516127 0.20202020202020204L0.6400666267641127 0.26122159090909086L0.5913243447580644 0.33049242424242414L0.5458740234374998 0.4105902777777778L0.5050907258064514 0.5022727272727272L0.4703495148689514 0.6062973484848484L0.43257456133442534 0.787133049242424L0.41612903225806447 1",
11632
- "8": "M0.5143001078924863 0L0.16007477667923162 0.10731570786949331L0.14924628550868277 0.3146018498698755L0.2939585848842112 0.41617921794558677L0.8648302624811545 0.5385163833653317L1 0.7775820770511038L0.8180842915260376 0.9505845566922285L0.41968938540525413 1L0.08062381919779889 0.882831681184498L0 0.6936376947135333L0.17150171673893433 0.5188652309607817L0.6529263782780712 0.4242818653203618L0.8650205888491803 0.29644027376796367L0.8702067371119496 0.09910067291661573L0.5143001078924863 0",
11633
- "9": "M1 0.25379591792994305L0.9514789771111742 0.11679361536614272L0.8702482473521467 0.05711741614054847L0.7327445265851579 0.015213872471965633L0.525248180711544 0L0.3292056884418538 0.012928195113745608L0.15997632037247655 0.058762870026191856L0.05266940041228321 0.12882439350476L0 0.2562067822770946L0.11316462894512366 0.4121335905917837L0.2403060136479954 0.4603365890068938L0.4097241967586011 0.4745978388276783L0.8642414300184816 0.420815170259988L0.9732054796346318 0.34537434075898393L1 0.25379591792994305M0.9647426784191072 0.35488595400360495L0.4756895081034974 1",
11634
- A: "M0 1L0.4808333333333333 0L1 1M0.24250000000000002 0.6099439775910365L0.7341666666666666 0.6099439775910365",
11635
- B: "M0 1L0 0.0117369978777208L0.30665717153513444 0L0.5874522807082946 0.03451403469442413L0.7766202217193218 0.15033936404895643L0.7471969743588041 0.31967962568332936L0.5246013359741988 0.4102978954282461L0.04378745314885416 0.44918617613783574L0.5112949594180156 0.469692928091109L0.8540266515643348 0.5552749498651879L1 0.6868463175009967L0.9880091196159324 0.8570018204672155L0.922301719975498 0.9321708046604659L0.7584266951758925 0.9932594737131338L0 1",
11636
- C: "M1 0.23038928858890784L0.9328355511865092 0.12426412616785204L0.8096380839483327 0.04912601676267708L0.5763225801788256 0L0.4039037709527492 0.015028068281399815L0.2519579390951737 0.06533979308999706L0.10359458463139784 0.18146243506591617L0 0.4862728453971315L0.08129580872733055 0.792689266886982L0.20257034847159672 0.9160822255736587L0.3286572892798542 0.9738230826074175L0.5742878414421707 1L0.7883510303801312 0.9665431511195721L0.946851033994232 0.8689071500976585L1 0.7311049027121912",
11637
- D: "M0 1L0.015604366822624637 0.020770988281483303L0.22564758265176144 0L0.3865476147957666 0.0024153386496795644L0.6479126635475078 0.051745644338731314L0.841191887805517 0.15827717679529366L0.9517008345536152 0.30172260586872185L0.9957536578687336 0.4504541551987709L1 0.5624359222498485L0.9798483279164735 0.6584121775234548L0.9386273319285215 0.7395945263504481L0.806292129480815 0.8624239259880274L0.6296239151398265 0.9406169638094516L0.3397492767598845 0.9954164354263132L0 1",
11638
- E: "M0 0L0 1M0 0L1 0M0 0.5L0.7 0.5M0 1L1 1",
11639
- F: "M0 0L0 1M0.011363636363636364 0.006802721088435374L1 0.006802721088435374M0.011363636363636364 0.4965986394557823L0.8409090909090909 0.4965986394557823",
11640
- G: "M0.902666857540557 0.03860785012651126L0.6504261864675637 0L0.3838947267237336 0.015442305268228053L0.21293332876776194 0.07706794377239819L0.07799659974941617 0.1994951236187481L0 0.46380381528937314L0.04159964421546915 0.7502491408002389L0.13176692977834842 0.8535497868383203L0.2709176262273927 0.936767572377719L0.4386472596876406 0.9891638569283179L0.6145513562841309 1L0.7782254421419019 0.9585373611026471L0.9092650433859927 0.8540372997461425L1 0.5556012645283437L0.5583959277303046 0.55491741080559",
11641
- H: "M0 0L0 1M0 0.4788732394366197L0.989010989010989 0.4788732394366197M1 0L1 1",
11642
- I: "M0.5 0L0.5 1",
11643
- J: "M0.9976457238788704 0L1 0.7396412315872798L0.9773931362096968 0.8322033314977973L0.9345115952458736 0.882296255506608L0.8743862896259549 0.9221331222466961L0.8024024079884948 0.9526431718061675L0.6443996712151668 0.9893997797356828L0.5035848940343224 1L0.3127211130319937 0.9877004749449337L0.17201910858386513 0.9539509911894274L0.10357419806379677 0.9212555066079295L0.053656568662899015 0.8816079295154184L0.020759483663648916 0.8360407488986785L0.003376206348523566 0.7855864537444934L0 0.7312775330396476",
11644
- K: "M0 0L0 1M0.8787878787878788 0.06666666666666667L0 0.6148148148148148M0.3333333333333333 0.45925925925925926L1 0.9777777777777777",
11645
- L: "M0 0L0 1L1 1",
11646
- M: "M0 1L0 0L0.5 0.6512L1 0L1 1",
11647
- N: "M0 1L0 0L1 1L0.9803729146221786 0",
11648
- O: "M0.4718499217948183 1L0.2896765846490613 0.9606979309189402L0.12315162147934663 0.8411184486080473L0 0.4352399966492615L0.11730398524516283 0.13145645436014852L0.2612197451988078 0.04493357858878059L0.5104071592772554 0L0.7450113425917159 0.05393013710105273L0.882367950645524 0.15242300282020502L1 0.5224527406249126L0.9414597290654386 0.7560662329321755L0.8371289514446183 0.8910800547287298L0.6518259868433511 0.9830452628933628L0.4718499217948183 1",
11649
- P: "M0 1L0 0.018871774228013626L0.29609603495819875 0L0.5609840637427541 0.011794858892508529L0.7332142696692472 0.04353904702296349L0.8102258645858864 0.0691965055027166L0.9330504315465442 0.14445061754775845L0.9876391714147118 0.22527816445836535L1 0.3434414070631638L0.9510549958116356 0.41772808046663146L0.8746646891596713 0.45879131862541683L0.7528523813396283 0.49171525113425024L0.5766919939969619 0.5153253033973054L0.33725744877712827 0.5284469008187558L0.025622667325582785 0.529905468802775",
11650
- Q: "M0.4618887943546369 0.9755918167206952L0.28356128136544534 0.9372490397450218L0.12055179272160406 0.8205882753548176L0 0.4246165790405623L0.1148276047430244 0.12824784112887844L0.25570518844754375 0.043836831567190586L0.49963205786237674 0L0.7292835601228574 0.0526138004304122L0.8637404608452104 0.14870263423138746L0.9788892040030622 0.5097006183769648L0.9215847647858059 0.7376120297474734L0.8194564929275405 0.869330409436378L0.6380654214095985 0.9590509139448092L0.4618887943546369 0.9755918167206952M0.5824181120212351 0.6861805006946525L1 1",
11651
- R: "M0 0.9928375167236815L0 0.02590227442068435L0.3611517274211098 0L0.6146286724700761 0.008660554424468435L0.7675462459194776 0.035269459580494614L0.831839975516866 0.056961676692569484L0.8847592491838954 0.08519560521497332L0.9238557535364527 0.120683646438422L0.9583303225312839 0.21691797435320384L0.955092470586235 0.3022616904894429L0.9198097669001631 0.3640573439322699L0.8564862239866702 0.40639258627024005L0.7691258543593579 0.43335506909190874L0.601775027203482 0.4539166070813109L0.023939064200217658 0.46997623755243123M0.5038084874863982 0.5108023922274467L1 1",
11652
- S: "M0.8886929689221953 0.15146982162688968L0.7276173683050475 0.013780286031594946L0.34582323121005076 0L0.1318235250900008 0.09920162734298861L0.0444543935052531 0.2811287071349243L0.08064065829108809 0.3709571405906485L0.21603115127470426 0.4485505768228281L0.7525409135992945 0.5111160926769565L0.9330263665417677 0.5850732219351329L1 0.7129938124702524L0.9117772389978691 0.9130572743138187L0.6423187128058188 1L0.29586019579751677 0.9935291584506244L0.10638454191462794 0.9229845198431584L0 0.7570771288048773",
11653
- T: "M0 0L1 0M0.5148514851485149 0L0.5148514851485149 1",
11654
- U: "M0 0L0.0023103778751369115 0.5467447428390111L0.01823032542100219 0.6954785891481812L0.05895528135268338 0.8056480226151669L0.13703402031421133 0.8894445726483398L0.23918400876232196 0.9448524533417946L0.3917887458926616 0.9848674531975652L0.584341627875137 1L0.7194816196604602 0.9848501456716763L0.8303268115073934 0.9449411544119768L0.8966613970084885 0.898186315516197L0.9251437568455642 0.867453197565408L0.9687114937020809 0.7890904895145239L0.9890470974808324 0.6852857184065537L1 0.0014769088758762145",
11655
- V: "M0 0L0.5348837209302325 1L1 0",
11656
- W: "M0 0L0.23300090661831369 0.9873417721518988L0.49954669084315495 0.30081906180193585L0.7851314596554849 1L1 0.0215934475055845",
11657
- X: "M0 0L0.9893617021276596 1M1 0L0.010638297872340425 1",
11658
- Y: "M0 0L0.4860515021459227 0.44712562100780695M1 0.0014194464158977947L0.48927038626609437 0.44996451383960256L0.5075107296137339 1",
11659
- Z: "M0 0L1 0L0 1L1 1",
11660
- ".": "M 0.49 1 L 0.41 1",
11661
- "*": "M 0.5 0.25 L 0.8 0.25 M 0.5 0.25 L 0.5927 0.4402 M 0.5 0.25 L 0.2573 0.3676 M 0.5 0.25 L 0.2573 0.1324 M 0.5 0.25 L 0.599 0.055",
11662
- "(": "M0.75 0L0.25 0.5L0.25 0.5L0.75 1",
11663
- ")": "M0.25 0L0.75 0.5L0.75 0.5L0.25 1",
11664
- "-": "M0 0.5L1 0.5",
11665
- "+": "M 0 0.5 L 1 0.5 M 0.5 0.125 L 0.5 0.875",
11666
- "=": "M0 0.25L1 0.25M0 0.75L1 0.75",
11667
- _: "M0 1 L1 1",
11668
- "[": "M0.75 0L0.25 0L0.25 1L0.75 1",
11669
- "]": "M0.25 0L0.75 0L0.75 1L0.25 1",
11670
- "<": "M0.75 0L0.25 0.5L0.25 0.5L0.75 1",
11671
- ">": "M0.25 0L0.75 0.5L0.75 0.5L0.25 1",
11672
- "'": "M 0.5 0 L 0.5 0.5",
11673
- '"': "M 0.25 0 L 0.25 0.5 M 0.75 0 L 0.75 0.5"
11674
- };
11675
- var lineAlphabet = {};
11676
- for(var letter in svgAlphabet)_loop(letter);
11677
- // src/lib/convert-text-to-lines.ts
11678
- var LETTER_HEIGHT_TO_WIDTH_RATIO = 0.6;
11679
- var LETTER_HEIGHT_TO_SPACE_RATIO = 0.2;
11680
- var getTextWidth = function(text) {
11681
- return text.text.length * text.size * LETTER_HEIGHT_TO_WIDTH_RATIO + (text.text.length - 1) * text.size * LETTER_HEIGHT_TO_SPACE_RATIO;
11682
- };
11683
- var convertTextToLines = function(text) {
11684
- var strokeWidth = text.size / 8;
11685
- var letterWidth = text.size * LETTER_HEIGHT_TO_WIDTH_RATIO;
11686
- var letterSpace = text.size * LETTER_HEIGHT_TO_SPACE_RATIO;
11687
- var lines = [];
11688
- for(var letterIndex = 0; letterIndex < text.text.length; letterIndex++){
11689
- var letter = text.text[letterIndex];
11690
- var letterLines = lineAlphabet[letter.toUpperCase()];
11691
- if (!letterLines) continue;
11692
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
11693
- try {
11694
- for(var _iterator = letterLines[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
11695
- var _step_value = _step.value, x1 = _step_value.x1, y1 = _step_value.y1, x2 = _step_value.x2, y2 = _step_value.y2;
11696
- lines.push({
11697
- pcb_drawing_type: "line",
11698
- x1: text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x1,
11699
- y1: text.y + text.size * y1,
11700
- x2: text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x2,
11701
- y2: text.y + text.size * y2,
11702
- width: strokeWidth,
11703
- layer: text.layer,
11704
- unit: text.unit
11705
- });
11706
- }
11707
- } catch (err) {
11708
- _didIteratorError = true;
11709
- _iteratorError = err;
11710
- } finally{
11711
- try {
11712
- if (!_iteratorNormalCompletion && _iterator.return != null) {
11713
- _iterator.return();
11714
- }
11715
- } finally{
11716
- if (_didIteratorError) {
11717
- throw _iteratorError;
11718
- }
11719
- }
11720
- }
11721
- }
11722
- return lines;
11723
- };
11724
- // src/lib/draw-primitives.ts
11725
- var drawLine = function(drawer, line) {
11726
- drawer.equip({
11727
- size: line.zoomIndependent ? line.width / drawer.transform.a : line.width,
11728
- shape: line.squareCap ? "square" : "circle",
11729
- color: line.layer
11730
- });
11731
- drawer.moveTo(line.x1, line.y1);
11732
- drawer.lineTo(line.x2, line.y2);
11733
- };
11734
- var drawText = function(drawer, text) {
11735
- drawer.equip({
11736
- fontSize: text.size,
11737
- color: text.layer
11738
- });
11739
- var alignOffset = {
11740
- x: 0,
11741
- y: 0
11742
- };
11743
- var textWidth = getTextWidth(text);
11744
- var textHeight = text.size;
11745
- if (text.align === "top_left") {
11746
- alignOffset.y = -textHeight;
11747
- } else if (text.align === "bottom_right") {
11748
- alignOffset.x = -textWidth;
11749
- } else if (text.align === "top_right") {
11750
- alignOffset.x = -textWidth;
11751
- alignOffset.y = -textHeight;
11752
- } else if (text.align === "center") {
11753
- alignOffset.x = -textWidth / 2;
11754
- alignOffset.y = -textHeight / 2;
11755
- }
11756
- var _text_x;
11757
- (_text_x = text.x) !== null && _text_x !== void 0 ? _text_x : text.x = 0;
11758
- var _text_y;
11759
- (_text_y = text.y) !== null && _text_y !== void 0 ? _text_y : text.y = 0;
11760
- var text_lines = convertTextToLines(_object_spread_props(_object_spread({}, text), {
11761
- x: text.x + alignOffset.x,
11762
- y: text.y + alignOffset.y
11763
- }));
11764
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
11765
- try {
11766
- for(var _iterator = text_lines[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
11767
- var line = _step.value;
11768
- drawLine(drawer, line);
11769
- }
11770
- } catch (err) {
11771
- _didIteratorError = true;
11772
- _iteratorError = err;
11773
- } finally{
11774
- try {
11775
- if (!_iteratorNormalCompletion && _iterator.return != null) {
11776
- _iterator.return();
11777
- }
11778
- } finally{
11779
- if (_didIteratorError) {
11780
- throw _iteratorError;
11781
- }
11782
- }
11783
- }
11784
- };
11785
- var drawRect = function(drawer, rect) {
11786
- drawer.equip({
11787
- color: rect.layer
11788
- });
11789
- drawer.rect(rect.x, rect.y, rect.w, rect.h, rect.mesh_fill);
11790
- };
11791
- var drawCircle = function(drawer, circle) {
11792
- drawer.equip({
11793
- color: circle.layer
11794
- });
11795
- drawer.circle(circle.x, circle.y, circle.r, circle.mesh_fill);
11796
- };
11797
- var drawOval = function(drawer, oval) {
11798
- drawer.equip({
11799
- color: oval.layer
11800
- });
11801
- drawer.oval(oval.x, oval.y, oval.rX, oval.rY);
11802
- };
11803
- var drawPill = function(drawer, pill) {
11804
- drawer.equip({
11805
- color: pill.layer
11806
- });
11807
- drawer.pill(pill.x, pill.y, pill.w, pill.h);
11808
- };
11809
- var drawPolygon = function(drawer, polygon) {
11810
- drawer.equip({
11811
- color: polygon.layer
11812
- });
11813
- drawer.polygon(polygon.points);
11814
- };
11815
- var drawPrimitive = function(drawer, primitive) {
11816
- switch(primitive.pcb_drawing_type){
11817
- case "line":
11818
- return drawLine(drawer, primitive);
11819
- case "text":
11820
- return drawText(drawer, primitive);
11821
- case "rect":
11822
- return drawRect(drawer, primitive);
11823
- case "circle":
11824
- return drawCircle(drawer, primitive);
11825
- case "oval":
11826
- return drawOval(drawer, primitive);
11827
- case "pill":
11828
- return drawPill(drawer, primitive);
11829
- case "polygon":
11830
- return drawPolygon(drawer, primitive);
11831
- }
11832
- };
11833
- var drawPrimitives = function(drawer, primitives) {
11834
- primitives.sort(function(a, b) {
11835
- var layerOrder = [
11836
- "bottom",
11837
- "top",
11838
- "drill"
11839
- ];
11840
- return layerOrder.indexOf(a.layer) - layerOrder.indexOf(b.layer);
11841
- });
11842
- primitives.forEach(function(primitive) {
11843
- return drawPrimitive(drawer, primitive);
11844
- });
11845
- };
11846
11624
  // src/lib/Drawer.ts
11847
11625
  var import_transformation_matrix = require("transformation-matrix");
11848
11626
  // src/lib/colors.ts
@@ -12390,9 +12168,9 @@ var Drawer = /*#__PURE__*/ function() {
12390
12168
  key: "applyAperture",
12391
12169
  value: function applyAperture() {
12392
12170
  var _this = this, transform = _this.transform, aperture = _this.aperture;
12393
- var size = aperture.size, mode = aperture.mode, color = aperture.color, fontSize = aperture.fontSize;
12394
- if (color in this.ctxLayerMap) {
12395
- this.aperture.layer = color;
12171
+ var size = aperture.size, mode = aperture.mode, color2 = aperture.color, fontSize = aperture.fontSize;
12172
+ if (color2 in this.ctxLayerMap) {
12173
+ this.aperture.layer = color2;
12396
12174
  } else {
12397
12175
  this.aperture.layer = "other";
12398
12176
  }
@@ -12400,13 +12178,13 @@ var Drawer = /*#__PURE__*/ function() {
12400
12178
  if (!ctx) {
12401
12179
  throw new Error('No context for layer "'.concat(this.foregroundLayer, '"'));
12402
12180
  }
12403
- if (!color) color = "undefined";
12181
+ if (!color2) color2 = "undefined";
12404
12182
  ctx.lineWidth = scaleOnly(transform, size);
12405
12183
  ctx.lineCap = "round";
12406
12184
  if (mode === "add") {
12407
- var colorString = (color === null || color === void 0 ? void 0 : color[0]) === "#" || (color === null || color === void 0 ? void 0 : color.startsWith("rgb")) ? color : LAYER_NAME_TO_COLOR[color === null || color === void 0 ? void 0 : color.toLowerCase()] ? LAYER_NAME_TO_COLOR[color === null || color === void 0 ? void 0 : color.toLowerCase()] : null;
12185
+ var colorString = (color2 === null || color2 === void 0 ? void 0 : color2[0]) === "#" || (color2 === null || color2 === void 0 ? void 0 : color2.startsWith("rgb")) ? color2 : LAYER_NAME_TO_COLOR[color2 === null || color2 === void 0 ? void 0 : color2.toLowerCase()] ? LAYER_NAME_TO_COLOR[color2 === null || color2 === void 0 ? void 0 : color2.toLowerCase()] : null;
12408
12186
  if (colorString === null) {
12409
- console.warn('Color mapping for "'.concat(color, '" not found'));
12187
+ console.warn('Color mapping for "'.concat(color2, '" not found'));
12410
12188
  colorString = "white";
12411
12189
  }
12412
12190
  ctx.fillStyle = colorString;
@@ -12457,6 +12235,238 @@ var Drawer = /*#__PURE__*/ function() {
12457
12235
  ]);
12458
12236
  return Drawer;
12459
12237
  }();
12238
+ // src/assets/alphabet.ts
12239
+ var svgAlphabet = {
12240
+ "0": "M0.4544564813877358 0L0.2723441540828736 0.03592830447352719L0.1086847233315459 0.14528754990019965L0.020630545837255005 0.3040632652221331L0 0.5395277421960205L0.049259221760993496 0.7369487828466779L0.18080513776237842 0.9005494166306564L0.37036887043974215 0.9872116270037247L0.5864663759301132 1L0.8148695622827444 0.9332890276148733L0.9326583645506394 0.8113052246023419L1 0.4031281830668562L0.833288960385582 0.09886798567812842L0.6801767918233781 0.02483708485091681L0.4544564813877358 0",
12241
+ "1": "M 0.198 0.272 L 0.537 0 L 0.54 1",
12242
+ "2": "M0.069593147751606 0.19461498231706575L0.1039380353319058 0.1224291500164194L0.20543361884368308 0.05510832064153169L0.3717712794432549 0.009452970962689482L0.4785344452623127 0L0.663238590738758 0.008714098643339864L0.8017933618843684 0.04769189395915288L0.8775637379550322 0.10746757678258442L0.9047778372591005 0.17693069668193287L0.9029710920770878 0.2231347105796246L0.8704496788008566 0.30047744598157516L0.7292906538577354 0.4508486051631194L0.3737955032119913 0.7369006417749693L0 1L1 1",
12243
+ "3": "M0.03917438899874637 0.19855364635107545L0.15510940508963084 0.06745632622133718L0.37598645522339846 0L0.8486391893813088 0.0652271323161611L0.9782182415054349 0.21747394183735683L0.9213133780517754 0.3547560290117714L0.6504271515903481 0.4543436297681271L0.22975249764129613 0.48476611625264143L0.7659038682744629 0.5411919558122493L0.9258712987734741 0.6203185665660985L1 0.7458360609169667L0.8938813281118737 0.9059190913045964L0.6166890258875837 1L0.261528440153542 0.9874861530507921L0 0.8837289530851273",
12244
+ "4": "M0.7328897338403042 0L0 0.6684672518568535L1 0.6684672518568535M0.7243346007604563 0.4530722484807562L0.7243346007604563 1",
12245
+ "5": "M 0 0 L 0 0.4973 L 0.4262 0.4319 L 0.7305 0.4565 L 0.8516 0.5009 L 0.9357 0.5639 L 1 0.7356 L 0.9696 0.8248 L 0.8898 0.895 L 0.733 0.9602 L 0.5518 0.9945 L 0.3814 1 L 0.2379 0.9821 L 0.1219 0.947 L 0 0.8748 M 0 0 L 1 0",
12246
+ "6": "M0.6964601700926856 0L0.3639239026215478 0.0743562375769351L0.1415931962925719 0.21735490179786915L0.009977939399608712 0.46336322325406004L0.00029622007592593224 0.7083131475173043L0.09408885043224748 0.8746809149767036L0.3379247445101846 0.9876686500961888L0.7109203869569624 1L0.9260852957913362 0.9103558029693921L1 0.7716571969091733L0.9824294723385016 0.6390635485705886L0.7446504992867332 0.4733643097729175L0.31028858071607296 0.47578021640899115L0.1208702146816024 0.5481452483973847L0 0.6616669755788906",
12247
+ "7": "M0 0L1 0L0.9246479649697582 0.030539772727272752L0.8850302419354837 0.05075757575757579L0.7922946068548385 0.11079545454545457L0.7419268208165322 0.15213068181818185L0.6907258064516127 0.20202020202020204L0.6400666267641127 0.26122159090909086L0.5913243447580644 0.33049242424242414L0.5458740234374998 0.4105902777777778L0.5050907258064514 0.5022727272727272L0.4703495148689514 0.6062973484848484L0.43257456133442534 0.787133049242424L0.41612903225806447 1",
12248
+ "8": "M0.5143001078924863 0L0.16007477667923162 0.10731570786949331L0.14924628550868277 0.3146018498698755L0.2939585848842112 0.41617921794558677L0.8648302624811545 0.5385163833653317L1 0.7775820770511038L0.8180842915260376 0.9505845566922285L0.41968938540525413 1L0.08062381919779889 0.882831681184498L0 0.6936376947135333L0.17150171673893433 0.5188652309607817L0.6529263782780712 0.4242818653203618L0.8650205888491803 0.29644027376796367L0.8702067371119496 0.09910067291661573L0.5143001078924863 0",
12249
+ "9": "M1 0.25379591792994305L0.9514789771111742 0.11679361536614272L0.8702482473521467 0.05711741614054847L0.7327445265851579 0.015213872471965633L0.525248180711544 0L0.3292056884418538 0.012928195113745608L0.15997632037247655 0.058762870026191856L0.05266940041228321 0.12882439350476L0 0.2562067822770946L0.11316462894512366 0.4121335905917837L0.2403060136479954 0.4603365890068938L0.4097241967586011 0.4745978388276783L0.8642414300184816 0.420815170259988L0.9732054796346318 0.34537434075898393L1 0.25379591792994305M0.9647426784191072 0.35488595400360495L0.4756895081034974 1",
12250
+ A: "M0 1L0.4808333333333333 0L1 1M0.24250000000000002 0.6099439775910365L0.7341666666666666 0.6099439775910365",
12251
+ B: "M0 1L0 0.0117369978777208L0.30665717153513444 0L0.5874522807082946 0.03451403469442413L0.7766202217193218 0.15033936404895643L0.7471969743588041 0.31967962568332936L0.5246013359741988 0.4102978954282461L0.04378745314885416 0.44918617613783574L0.5112949594180156 0.469692928091109L0.8540266515643348 0.5552749498651879L1 0.6868463175009967L0.9880091196159324 0.8570018204672155L0.922301719975498 0.9321708046604659L0.7584266951758925 0.9932594737131338L0 1",
12252
+ C: "M1 0.23038928858890784L0.9328355511865092 0.12426412616785204L0.8096380839483327 0.04912601676267708L0.5763225801788256 0L0.4039037709527492 0.015028068281399815L0.2519579390951737 0.06533979308999706L0.10359458463139784 0.18146243506591617L0 0.4862728453971315L0.08129580872733055 0.792689266886982L0.20257034847159672 0.9160822255736587L0.3286572892798542 0.9738230826074175L0.5742878414421707 1L0.7883510303801312 0.9665431511195721L0.946851033994232 0.8689071500976585L1 0.7311049027121912",
12253
+ D: "M0 1L0.015604366822624637 0.020770988281483303L0.22564758265176144 0L0.3865476147957666 0.0024153386496795644L0.6479126635475078 0.051745644338731314L0.841191887805517 0.15827717679529366L0.9517008345536152 0.30172260586872185L0.9957536578687336 0.4504541551987709L1 0.5624359222498485L0.9798483279164735 0.6584121775234548L0.9386273319285215 0.7395945263504481L0.806292129480815 0.8624239259880274L0.6296239151398265 0.9406169638094516L0.3397492767598845 0.9954164354263132L0 1",
12254
+ E: "M0 0L0 1M0 0L1 0M0 0.5L0.7 0.5M0 1L1 1",
12255
+ F: "M0 0L0 1M0.011363636363636364 0.006802721088435374L1 0.006802721088435374M0.011363636363636364 0.4965986394557823L0.8409090909090909 0.4965986394557823",
12256
+ G: "M0.902666857540557 0.03860785012651126L0.6504261864675637 0L0.3838947267237336 0.015442305268228053L0.21293332876776194 0.07706794377239819L0.07799659974941617 0.1994951236187481L0 0.46380381528937314L0.04159964421546915 0.7502491408002389L0.13176692977834842 0.8535497868383203L0.2709176262273927 0.936767572377719L0.4386472596876406 0.9891638569283179L0.6145513562841309 1L0.7782254421419019 0.9585373611026471L0.9092650433859927 0.8540372997461425L1 0.5556012645283437L0.5583959277303046 0.55491741080559",
12257
+ H: "M0 0L0 1M0 0.4788732394366197L0.989010989010989 0.4788732394366197M1 0L1 1",
12258
+ I: "M0.5 0L0.5 1",
12259
+ J: "M0.9976457238788704 0L1 0.7396412315872798L0.9773931362096968 0.8322033314977973L0.9345115952458736 0.882296255506608L0.8743862896259549 0.9221331222466961L0.8024024079884948 0.9526431718061675L0.6443996712151668 0.9893997797356828L0.5035848940343224 1L0.3127211130319937 0.9877004749449337L0.17201910858386513 0.9539509911894274L0.10357419806379677 0.9212555066079295L0.053656568662899015 0.8816079295154184L0.020759483663648916 0.8360407488986785L0.003376206348523566 0.7855864537444934L0 0.7312775330396476",
12260
+ K: "M0 0L0 1M0.8787878787878788 0.06666666666666667L0 0.6148148148148148M0.3333333333333333 0.45925925925925926L1 0.9777777777777777",
12261
+ L: "M0 0L0 1L1 1",
12262
+ M: "M0 1L0 0L0.5 0.6512L1 0L1 1",
12263
+ N: "M0 1L0 0L1 1L0.9803729146221786 0",
12264
+ O: "M0.4718499217948183 1L0.2896765846490613 0.9606979309189402L0.12315162147934663 0.8411184486080473L0 0.4352399966492615L0.11730398524516283 0.13145645436014852L0.2612197451988078 0.04493357858878059L0.5104071592772554 0L0.7450113425917159 0.05393013710105273L0.882367950645524 0.15242300282020502L1 0.5224527406249126L0.9414597290654386 0.7560662329321755L0.8371289514446183 0.8910800547287298L0.6518259868433511 0.9830452628933628L0.4718499217948183 1",
12265
+ P: "M0 1L0 0.018871774228013626L0.29609603495819875 0L0.5609840637427541 0.011794858892508529L0.7332142696692472 0.04353904702296349L0.8102258645858864 0.0691965055027166L0.9330504315465442 0.14445061754775845L0.9876391714147118 0.22527816445836535L1 0.3434414070631638L0.9510549958116356 0.41772808046663146L0.8746646891596713 0.45879131862541683L0.7528523813396283 0.49171525113425024L0.5766919939969619 0.5153253033973054L0.33725744877712827 0.5284469008187558L0.025622667325582785 0.529905468802775",
12266
+ Q: "M0.4618887943546369 0.9755918167206952L0.28356128136544534 0.9372490397450218L0.12055179272160406 0.8205882753548176L0 0.4246165790405623L0.1148276047430244 0.12824784112887844L0.25570518844754375 0.043836831567190586L0.49963205786237674 0L0.7292835601228574 0.0526138004304122L0.8637404608452104 0.14870263423138746L0.9788892040030622 0.5097006183769648L0.9215847647858059 0.7376120297474734L0.8194564929275405 0.869330409436378L0.6380654214095985 0.9590509139448092L0.4618887943546369 0.9755918167206952M0.5824181120212351 0.6861805006946525L1 1",
12267
+ R: "M0 0.9928375167236815L0 0.02590227442068435L0.3611517274211098 0L0.6146286724700761 0.008660554424468435L0.7675462459194776 0.035269459580494614L0.831839975516866 0.056961676692569484L0.8847592491838954 0.08519560521497332L0.9238557535364527 0.120683646438422L0.9583303225312839 0.21691797435320384L0.955092470586235 0.3022616904894429L0.9198097669001631 0.3640573439322699L0.8564862239866702 0.40639258627024005L0.7691258543593579 0.43335506909190874L0.601775027203482 0.4539166070813109L0.023939064200217658 0.46997623755243123M0.5038084874863982 0.5108023922274467L1 1",
12268
+ S: "M0.8886929689221953 0.15146982162688968L0.7276173683050475 0.013780286031594946L0.34582323121005076 0L0.1318235250900008 0.09920162734298861L0.0444543935052531 0.2811287071349243L0.08064065829108809 0.3709571405906485L0.21603115127470426 0.4485505768228281L0.7525409135992945 0.5111160926769565L0.9330263665417677 0.5850732219351329L1 0.7129938124702524L0.9117772389978691 0.9130572743138187L0.6423187128058188 1L0.29586019579751677 0.9935291584506244L0.10638454191462794 0.9229845198431584L0 0.7570771288048773",
12269
+ T: "M0 0L1 0M0.5148514851485149 0L0.5148514851485149 1",
12270
+ U: "M0 0L0.0023103778751369115 0.5467447428390111L0.01823032542100219 0.6954785891481812L0.05895528135268338 0.8056480226151669L0.13703402031421133 0.8894445726483398L0.23918400876232196 0.9448524533417946L0.3917887458926616 0.9848674531975652L0.584341627875137 1L0.7194816196604602 0.9848501456716763L0.8303268115073934 0.9449411544119768L0.8966613970084885 0.898186315516197L0.9251437568455642 0.867453197565408L0.9687114937020809 0.7890904895145239L0.9890470974808324 0.6852857184065537L1 0.0014769088758762145",
12271
+ V: "M0 0L0.5348837209302325 1L1 0",
12272
+ W: "M0 0L0.23300090661831369 0.9873417721518988L0.49954669084315495 0.30081906180193585L0.7851314596554849 1L1 0.0215934475055845",
12273
+ X: "M0 0L0.9893617021276596 1M1 0L0.010638297872340425 1",
12274
+ Y: "M0 0L0.4860515021459227 0.44712562100780695M1 0.0014194464158977947L0.48927038626609437 0.44996451383960256L0.5075107296137339 1",
12275
+ Z: "M0 0L1 0L0 1L1 1",
12276
+ ".": "M 0.49 1 L 0.41 1",
12277
+ "*": "M 0.5 0.25 L 0.8 0.25 M 0.5 0.25 L 0.5927 0.4402 M 0.5 0.25 L 0.2573 0.3676 M 0.5 0.25 L 0.2573 0.1324 M 0.5 0.25 L 0.599 0.055",
12278
+ "(": "M0.75 0L0.25 0.5L0.25 0.5L0.75 1",
12279
+ ")": "M0.25 0L0.75 0.5L0.75 0.5L0.25 1",
12280
+ "-": "M0 0.5L1 0.5",
12281
+ "+": "M 0 0.5 L 1 0.5 M 0.5 0.125 L 0.5 0.875",
12282
+ "=": "M0 0.25L1 0.25M0 0.75L1 0.75",
12283
+ _: "M0 1 L1 1",
12284
+ "[": "M0.75 0L0.25 0L0.25 1L0.75 1",
12285
+ "]": "M0.25 0L0.75 0L0.75 1L0.25 1",
12286
+ "<": "M0.75 0L0.25 0.5L0.25 0.5L0.75 1",
12287
+ ">": "M0.25 0L0.75 0.5L0.75 0.5L0.25 1",
12288
+ "'": "M 0.5 0 L 0.5 0.5",
12289
+ '"': "M 0.25 0 L 0.25 0.5 M 0.75 0 L 0.75 0.5"
12290
+ };
12291
+ var lineAlphabet = {};
12292
+ for(var letter in svgAlphabet)_loop(letter);
12293
+ // src/lib/convert-text-to-lines.ts
12294
+ var LETTER_HEIGHT_TO_WIDTH_RATIO = 0.6;
12295
+ var LETTER_HEIGHT_TO_SPACE_RATIO = 0.2;
12296
+ var getTextWidth = function(text) {
12297
+ return text.text.length * text.size * LETTER_HEIGHT_TO_WIDTH_RATIO + (text.text.length - 1) * text.size * LETTER_HEIGHT_TO_SPACE_RATIO;
12298
+ };
12299
+ var convertTextToLines = function(text) {
12300
+ var strokeWidth = text.size / 8;
12301
+ var letterWidth = text.size * LETTER_HEIGHT_TO_WIDTH_RATIO;
12302
+ var letterSpace = text.size * LETTER_HEIGHT_TO_SPACE_RATIO;
12303
+ var lines = [];
12304
+ for(var letterIndex = 0; letterIndex < text.text.length; letterIndex++){
12305
+ var letter = text.text[letterIndex];
12306
+ var letterLines = lineAlphabet[letter.toUpperCase()];
12307
+ if (!letterLines) continue;
12308
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
12309
+ try {
12310
+ for(var _iterator = letterLines[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
12311
+ var _step_value = _step.value, x1 = _step_value.x1, y1 = _step_value.y1, x2 = _step_value.x2, y2 = _step_value.y2;
12312
+ lines.push({
12313
+ pcb_drawing_type: "line",
12314
+ x1: text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x1,
12315
+ y1: text.y + text.size * y1,
12316
+ x2: text.x + (letterWidth + letterSpace) * letterIndex + letterWidth * x2,
12317
+ y2: text.y + text.size * y2,
12318
+ width: strokeWidth,
12319
+ layer: text.layer,
12320
+ unit: text.unit
12321
+ });
12322
+ }
12323
+ } catch (err) {
12324
+ _didIteratorError = true;
12325
+ _iteratorError = err;
12326
+ } finally{
12327
+ try {
12328
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
12329
+ _iterator.return();
12330
+ }
12331
+ } finally{
12332
+ if (_didIteratorError) {
12333
+ throw _iteratorError;
12334
+ }
12335
+ }
12336
+ }
12337
+ }
12338
+ return lines;
12339
+ };
12340
+ // src/lib/draw-primitives.ts
12341
+ var import_color = __toESM(require("color"));
12342
+ function getColor(primitive) {
12343
+ if (primitive.is_mouse_over) {
12344
+ return (0, import_color.default)(LAYER_NAME_TO_COLOR[primitive.layer]).lighten(0.5).rgb().toString();
12345
+ }
12346
+ return LAYER_NAME_TO_COLOR[primitive.layer];
12347
+ }
12348
+ var drawLine = function(drawer, line) {
12349
+ drawer.equip({
12350
+ size: line.zoomIndependent ? line.width / drawer.transform.a : line.width,
12351
+ shape: line.squareCap ? "square" : "circle",
12352
+ color: line.layer
12353
+ });
12354
+ drawer.moveTo(line.x1, line.y1);
12355
+ drawer.lineTo(line.x2, line.y2);
12356
+ };
12357
+ var drawText = function(drawer, text) {
12358
+ drawer.equip({
12359
+ fontSize: text.size,
12360
+ color: text.layer
12361
+ });
12362
+ var alignOffset = {
12363
+ x: 0,
12364
+ y: 0
12365
+ };
12366
+ var textWidth = getTextWidth(text);
12367
+ var textHeight = text.size;
12368
+ if (text.align === "top_left") {
12369
+ alignOffset.y = -textHeight;
12370
+ } else if (text.align === "bottom_right") {
12371
+ alignOffset.x = -textWidth;
12372
+ } else if (text.align === "top_right") {
12373
+ alignOffset.x = -textWidth;
12374
+ alignOffset.y = -textHeight;
12375
+ } else if (text.align === "center") {
12376
+ alignOffset.x = -textWidth / 2;
12377
+ alignOffset.y = -textHeight / 2;
12378
+ }
12379
+ var _text_x;
12380
+ (_text_x = text.x) !== null && _text_x !== void 0 ? _text_x : text.x = 0;
12381
+ var _text_y;
12382
+ (_text_y = text.y) !== null && _text_y !== void 0 ? _text_y : text.y = 0;
12383
+ var text_lines = convertTextToLines(_object_spread_props(_object_spread({}, text), {
12384
+ x: text.x + alignOffset.x,
12385
+ y: text.y + alignOffset.y
12386
+ }));
12387
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
12388
+ try {
12389
+ for(var _iterator = text_lines[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
12390
+ var line = _step.value;
12391
+ drawLine(drawer, line);
12392
+ }
12393
+ } catch (err) {
12394
+ _didIteratorError = true;
12395
+ _iteratorError = err;
12396
+ } finally{
12397
+ try {
12398
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
12399
+ _iterator.return();
12400
+ }
12401
+ } finally{
12402
+ if (_didIteratorError) {
12403
+ throw _iteratorError;
12404
+ }
12405
+ }
12406
+ }
12407
+ };
12408
+ var drawRect = function(drawer, rect) {
12409
+ drawer.equip({
12410
+ color: getColor(rect),
12411
+ layer: rect.layer
12412
+ });
12413
+ drawer.rect(rect.x, rect.y, rect.w, rect.h, rect.mesh_fill);
12414
+ };
12415
+ var drawCircle = function(drawer, circle) {
12416
+ drawer.equip({
12417
+ color: circle.layer
12418
+ });
12419
+ drawer.circle(circle.x, circle.y, circle.r, circle.mesh_fill);
12420
+ };
12421
+ var drawOval = function(drawer, oval) {
12422
+ drawer.equip({
12423
+ color: oval.layer
12424
+ });
12425
+ drawer.oval(oval.x, oval.y, oval.rX, oval.rY);
12426
+ };
12427
+ var drawPill = function(drawer, pill) {
12428
+ drawer.equip({
12429
+ color: pill.layer
12430
+ });
12431
+ drawer.pill(pill.x, pill.y, pill.w, pill.h);
12432
+ };
12433
+ var drawPolygon = function(drawer, polygon) {
12434
+ drawer.equip({
12435
+ color: polygon.layer
12436
+ });
12437
+ drawer.polygon(polygon.points);
12438
+ };
12439
+ var drawPrimitive = function(drawer, primitive) {
12440
+ switch(primitive.pcb_drawing_type){
12441
+ case "line":
12442
+ return drawLine(drawer, primitive);
12443
+ case "text":
12444
+ return drawText(drawer, primitive);
12445
+ case "rect":
12446
+ return drawRect(drawer, primitive);
12447
+ case "circle":
12448
+ return drawCircle(drawer, primitive);
12449
+ case "oval":
12450
+ return drawOval(drawer, primitive);
12451
+ case "pill":
12452
+ return drawPill(drawer, primitive);
12453
+ case "polygon":
12454
+ return drawPolygon(drawer, primitive);
12455
+ }
12456
+ };
12457
+ var drawPrimitives = function(drawer, primitives) {
12458
+ primitives.sort(function(a, b) {
12459
+ var layerOrder = [
12460
+ "bottom",
12461
+ "top",
12462
+ "drill"
12463
+ ];
12464
+ return layerOrder.indexOf(a.layer) - layerOrder.indexOf(b.layer);
12465
+ });
12466
+ primitives.forEach(function(primitive) {
12467
+ return drawPrimitive(drawer, primitive);
12468
+ });
12469
+ };
12460
12470
  // src/global-store.ts
12461
12471
  var import_zustand = require("zustand");
12462
12472
  // src/components/ContextProviders.tsx
@@ -12594,7 +12604,7 @@ var CanvasPrimitiveRenderer = function(param) {
12594
12604
  });
12595
12605
  };
12596
12606
  // src/components/CanvasElementsRenderer.tsx
12597
- var import_react15 = require("react");
12607
+ var import_react16 = require("react");
12598
12608
  // src/lib/convert-element-to-primitive.ts
12599
12609
  var import_soup_util = __toESM(require_dist2());
12600
12610
  // src/lib/util/expand-stroke.ts
@@ -12676,6 +12686,7 @@ function getExpandedStroke(strokeInput, defaultWidth) {
12676
12686
  return _to_consumable_array(leftSide).concat(_to_consumable_array(rightSide));
12677
12687
  }
12678
12688
  // src/lib/convert-element-to-primitive.ts
12689
+ var globalPcbDrawingObjectCount = 0;
12679
12690
  var convertElementToPrimitives = function(element, allElements) {
12680
12691
  var _pcb_port_get;
12681
12692
  var _parent_pcb_component = "pcb_component_id" in element ? allElements.find(function(elm) {
@@ -12695,6 +12706,7 @@ var convertElementToPrimitives = function(element, allElements) {
12695
12706
  if (outline && outline.length > 2) {
12696
12707
  return outline.map(function(point, index, array) {
12697
12708
  return {
12709
+ _pcb_drawing_object_id: "line_".concat(globalPcbDrawingObjectCount++),
12698
12710
  pcb_drawing_type: "line",
12699
12711
  x1: point.x,
12700
12712
  y1: point.y,
@@ -12710,6 +12722,7 @@ var convertElementToPrimitives = function(element, allElements) {
12710
12722
  }
12711
12723
  return [
12712
12724
  {
12725
+ _pcb_drawing_object_id: "line_".concat(globalPcbDrawingObjectCount++),
12713
12726
  pcb_drawing_type: "line",
12714
12727
  x1: center.x - width / 2,
12715
12728
  y1: center.y - height / 2,
@@ -12722,6 +12735,7 @@ var convertElementToPrimitives = function(element, allElements) {
12722
12735
  _element: element
12723
12736
  },
12724
12737
  {
12738
+ _pcb_drawing_object_id: "line_".concat(globalPcbDrawingObjectCount++),
12725
12739
  pcb_drawing_type: "line",
12726
12740
  x1: center.x - width / 2,
12727
12741
  y1: center.y + height / 2,
@@ -12734,6 +12748,7 @@ var convertElementToPrimitives = function(element, allElements) {
12734
12748
  _element: element
12735
12749
  },
12736
12750
  {
12751
+ _pcb_drawing_object_id: "line_".concat(globalPcbDrawingObjectCount++),
12737
12752
  pcb_drawing_type: "line",
12738
12753
  x1: center.x - width / 2,
12739
12754
  y1: center.y - height / 2,
@@ -12746,6 +12761,7 @@ var convertElementToPrimitives = function(element, allElements) {
12746
12761
  _element: element
12747
12762
  },
12748
12763
  {
12764
+ _pcb_drawing_object_id: "line_".concat(globalPcbDrawingObjectCount++),
12749
12765
  pcb_drawing_type: "line",
12750
12766
  x1: center.x + width / 2,
12751
12767
  y1: center.y - height / 2,
@@ -12765,6 +12781,7 @@ var convertElementToPrimitives = function(element, allElements) {
12765
12781
  var shape = element.shape, x = element.x, y = element.y, width1 = element.width, height1 = element.height, layer = element.layer;
12766
12782
  return [
12767
12783
  {
12784
+ _pcb_drawing_object_id: "rect_".concat(globalPcbDrawingObjectCount++),
12768
12785
  pcb_drawing_type: "rect",
12769
12786
  x: x,
12770
12787
  y: y,
@@ -12781,6 +12798,7 @@ var convertElementToPrimitives = function(element, allElements) {
12781
12798
  var x1 = element.x, y1 = element.y, radius = element.radius, layer1 = element.layer;
12782
12799
  return [
12783
12800
  {
12801
+ _pcb_drawing_object_id: "circle_".concat(globalPcbDrawingObjectCount++),
12784
12802
  pcb_drawing_type: "circle",
12785
12803
  x: x1,
12786
12804
  y: y1,
@@ -12801,6 +12819,7 @@ var convertElementToPrimitives = function(element, allElements) {
12801
12819
  var x2 = element.x, y2 = element.y, hole_diameter = element.hole_diameter;
12802
12820
  return [
12803
12821
  {
12822
+ _pcb_drawing_object_id: "circle_".concat(globalPcbDrawingObjectCount++),
12804
12823
  pcb_drawing_type: "circle",
12805
12824
  x: x2,
12806
12825
  y: y2,
@@ -12820,6 +12839,7 @@ var convertElementToPrimitives = function(element, allElements) {
12820
12839
  var x3 = element.x, y3 = element.y, hole_diameter1 = element.hole_diameter, outer_diameter = element.outer_diameter;
12821
12840
  return [
12822
12841
  {
12842
+ _pcb_drawing_object_id: "circle_".concat(globalPcbDrawingObjectCount++),
12823
12843
  pcb_drawing_type: "circle",
12824
12844
  x: x3,
12825
12845
  y: y3,
@@ -12832,6 +12852,7 @@ var convertElementToPrimitives = function(element, allElements) {
12832
12852
  _source_port: _source_port
12833
12853
  },
12834
12854
  {
12855
+ _pcb_drawing_object_id: "circle_".concat(globalPcbDrawingObjectCount++),
12835
12856
  pcb_drawing_type: "circle",
12836
12857
  x: x3,
12837
12858
  y: y3,
@@ -12844,6 +12865,7 @@ var convertElementToPrimitives = function(element, allElements) {
12844
12865
  var x4 = element.x, y4 = element.y, outer_height = element.outer_height, outer_width = element.outer_width, hole_height = element.hole_height, hole_width = element.hole_width;
12845
12866
  return [
12846
12867
  {
12868
+ _pcb_drawing_object_id: "oval_".concat(globalPcbDrawingObjectCount++),
12847
12869
  pcb_drawing_type: "oval",
12848
12870
  x: x4,
12849
12871
  y: y4,
@@ -12857,6 +12879,7 @@ var convertElementToPrimitives = function(element, allElements) {
12857
12879
  _source_port: _source_port
12858
12880
  },
12859
12881
  {
12882
+ _pcb_drawing_object_id: "oval_".concat(globalPcbDrawingObjectCount++),
12860
12883
  pcb_drawing_type: "oval",
12861
12884
  x: x4,
12862
12885
  y: y4,
@@ -12869,6 +12892,7 @@ var convertElementToPrimitives = function(element, allElements) {
12869
12892
  var x5 = element.x, y5 = element.y, outer_height1 = element.outer_height, outer_width1 = element.outer_width, hole_height1 = element.hole_height, hole_width1 = element.hole_width;
12870
12893
  return [
12871
12894
  {
12895
+ _pcb_drawing_object_id: "pill_".concat(globalPcbDrawingObjectCount++),
12872
12896
  pcb_drawing_type: "pill",
12873
12897
  x: x5,
12874
12898
  y: y5,
@@ -12882,6 +12906,7 @@ var convertElementToPrimitives = function(element, allElements) {
12882
12906
  _source_port: _source_port
12883
12907
  },
12884
12908
  {
12909
+ _pcb_drawing_object_id: "pill_".concat(globalPcbDrawingObjectCount++),
12885
12910
  pcb_drawing_type: "pill",
12886
12911
  x: x5,
12887
12912
  y: y5,
@@ -12900,6 +12925,7 @@ var convertElementToPrimitives = function(element, allElements) {
12900
12925
  var center1 = element.center, radius1 = element.radius;
12901
12926
  return [
12902
12927
  {
12928
+ _pcb_drawing_object_id: "circle_".concat(globalPcbDrawingObjectCount++),
12903
12929
  pcb_drawing_type: "circle",
12904
12930
  x: center1.x,
12905
12931
  y: center1.y,
@@ -12915,6 +12941,7 @@ var convertElementToPrimitives = function(element, allElements) {
12915
12941
  var x6 = element.x, y6 = element.y, width2 = element.width, height2 = element.height;
12916
12942
  return [
12917
12943
  {
12944
+ _pcb_drawing_object_id: "rect_".concat(globalPcbDrawingObjectCount++),
12918
12945
  pcb_drawing_type: "rect",
12919
12946
  x: x6,
12920
12947
  y: y6,
@@ -12942,6 +12969,7 @@ var convertElementToPrimitives = function(element, allElements) {
12942
12969
  });
12943
12970
  var expandedStroke = getExpandedStroke(strokeInput, 0.5);
12944
12971
  primitives.push({
12972
+ _pcb_drawing_object_id: "polygon_".concat(globalPcbDrawingObjectCount++),
12945
12973
  pcb_drawing_type: "polygon",
12946
12974
  points: expandedStroke,
12947
12975
  layer: element.route[0].layer
@@ -12949,6 +12977,7 @@ var convertElementToPrimitives = function(element, allElements) {
12949
12977
  element.route.forEach(function(r) {
12950
12978
  if (r.route_type === "via") {
12951
12979
  primitives.push({
12980
+ _pcb_drawing_object_id: "circle_".concat(globalPcbDrawingObjectCount++),
12952
12981
  pcb_drawing_type: "circle",
12953
12982
  x: r.x,
12954
12983
  y: r.y,
@@ -12969,6 +12998,7 @@ var convertElementToPrimitives = function(element, allElements) {
12969
12998
  if (route.route_type === "wire") {
12970
12999
  if (prevX !== null && prevY !== null) {
12971
13000
  primitives.push({
13001
+ _pcb_drawing_object_id: "line_".concat(globalPcbDrawingObjectCount++),
12972
13002
  pcb_drawing_type: "line",
12973
13003
  x1: prevX,
12974
13004
  y1: prevY,
@@ -13004,6 +13034,7 @@ var convertElementToPrimitives = function(element, allElements) {
13004
13034
  var x7 = element.x, y7 = element.y, outer_diameter1 = element.outer_diameter, hole_diameter2 = element.hole_diameter, from_layer = element.from_layer, to_layer = element.to_layer;
13005
13035
  return [
13006
13036
  {
13037
+ _pcb_drawing_object_id: "circle_".concat(globalPcbDrawingObjectCount++),
13007
13038
  pcb_drawing_type: "circle",
13008
13039
  x: x7,
13009
13040
  y: y7,
@@ -13014,6 +13045,7 @@ var convertElementToPrimitives = function(element, allElements) {
13014
13045
  _parent_source_component: _parent_source_component
13015
13046
  },
13016
13047
  {
13048
+ _pcb_drawing_object_id: "circle_".concat(globalPcbDrawingObjectCount++),
13017
13049
  pcb_drawing_type: "circle",
13018
13050
  x: x7,
13019
13051
  y: y7,
@@ -13024,6 +13056,7 @@ var convertElementToPrimitives = function(element, allElements) {
13024
13056
  _parent_source_component: _parent_source_component
13025
13057
  },
13026
13058
  {
13059
+ _pcb_drawing_object_id: "circle_".concat(globalPcbDrawingObjectCount++),
13027
13060
  pcb_drawing_type: "circle",
13028
13061
  x: x7,
13029
13062
  y: y7,
@@ -13039,6 +13072,7 @@ var convertElementToPrimitives = function(element, allElements) {
13039
13072
  {
13040
13073
  return [
13041
13074
  {
13075
+ _pcb_drawing_object_id: "rect_".concat(globalPcbDrawingObjectCount++),
13042
13076
  pcb_drawing_type: "rect",
13043
13077
  x: element.center.x,
13044
13078
  y: element.center.y,
@@ -13052,6 +13086,7 @@ var convertElementToPrimitives = function(element, allElements) {
13052
13086
  {
13053
13087
  return [
13054
13088
  {
13089
+ _pcb_drawing_object_id: "circle_".concat(globalPcbDrawingObjectCount++),
13055
13090
  pcb_drawing_type: "circle",
13056
13091
  x: element.center.x,
13057
13092
  y: element.center.y,
@@ -13064,6 +13099,7 @@ var convertElementToPrimitives = function(element, allElements) {
13064
13099
  {
13065
13100
  return [
13066
13101
  {
13102
+ _pcb_drawing_object_id: "oval_".concat(globalPcbDrawingObjectCount++),
13067
13103
  pcb_drawing_type: "oval",
13068
13104
  x: element.center.x,
13069
13105
  y: element.center.y,
@@ -13077,6 +13113,7 @@ var convertElementToPrimitives = function(element, allElements) {
13077
13113
  {
13078
13114
  return [
13079
13115
  {
13116
+ _pcb_drawing_object_id: "pill_".concat(globalPcbDrawingObjectCount++),
13080
13117
  pcb_drawing_type: "pill",
13081
13118
  x: element.center.x,
13082
13119
  y: element.center.y,
@@ -13090,6 +13127,7 @@ var convertElementToPrimitives = function(element, allElements) {
13090
13127
  {
13091
13128
  return [
13092
13129
  {
13130
+ _pcb_drawing_object_id: "line_".concat(globalPcbDrawingObjectCount++),
13093
13131
  pcb_drawing_type: "line",
13094
13132
  x1: element.x1,
13095
13133
  y1: element.y1,
@@ -13117,6 +13155,7 @@ var convertElementToPrimitives = function(element, allElements) {
13117
13155
  var nextPoint = route1[index + 1];
13118
13156
  var _element_stroke_width;
13119
13157
  return {
13158
+ _pcb_drawing_object_id: "line_".concat(globalPcbDrawingObjectCount++),
13120
13159
  pcb_drawing_type: "line",
13121
13160
  x1: point.x,
13122
13161
  y1: point.y,
@@ -13137,6 +13176,7 @@ var convertElementToPrimitives = function(element, allElements) {
13137
13176
  var _element_anchor_alignment;
13138
13177
  return [
13139
13178
  {
13179
+ _pcb_drawing_object_id: "text_".concat(globalPcbDrawingObjectCount++),
13140
13180
  pcb_drawing_type: "text",
13141
13181
  x: element.anchor_position.x,
13142
13182
  y: element.anchor_position.y,
@@ -13152,6 +13192,7 @@ var convertElementToPrimitives = function(element, allElements) {
13152
13192
  var _element_anchor_alignment1;
13153
13193
  return [
13154
13194
  {
13195
+ _pcb_drawing_object_id: "text_".concat(globalPcbDrawingObjectCount++),
13155
13196
  pcb_drawing_type: "text",
13156
13197
  x: element.anchor_position.x,
13157
13198
  y: element.anchor_position.y,
@@ -13230,7 +13271,7 @@ var HighlightedPrimitiveBoxWithText = function(param) {
13230
13271
  var si = (_primitive_same_space_index = primitive.same_space_index) !== null && _primitive_same_space_index !== void 0 ? _primitive_same_space_index : 0;
13231
13272
  var sip = 26;
13232
13273
  var _layerColorHightlightMap_primitive__element_layer;
13233
- var color = (_layerColorHightlightMap_primitive__element_layer = layerColorHightlightMap[primitive === null || primitive === void 0 ? void 0 : (_primitive__element = primitive._element) === null || _primitive__element === void 0 ? void 0 : _primitive__element.layer]) !== null && _layerColorHightlightMap_primitive__element_layer !== void 0 ? _layerColorHightlightMap_primitive__element_layer : "red";
13274
+ var color2 = (_layerColorHightlightMap_primitive__element_layer = layerColorHightlightMap[primitive === null || primitive === void 0 ? void 0 : (_primitive__element = primitive._element) === null || _primitive__element === void 0 ? void 0 : _primitive__element.layer]) !== null && _layerColorHightlightMap_primitive__element_layer !== void 0 ? _layerColorHightlightMap_primitive__element_layer : "red";
13234
13275
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", {
13235
13276
  style: {
13236
13277
  position: "absolute",
@@ -13238,7 +13279,7 @@ var HighlightedPrimitiveBoxWithText = function(param) {
13238
13279
  top: y - h / 2 - 8,
13239
13280
  width: w + 16,
13240
13281
  height: h + 16,
13241
- color: color
13282
+ color: color2
13242
13283
  },
13243
13284
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", {
13244
13285
  style: {
@@ -13250,7 +13291,7 @@ var HighlightedPrimitiveBoxWithText = function(param) {
13250
13291
  height: finalState ? "calc(100% + ".concat(sip * 2 * si, "px)") : "100%",
13251
13292
  marginLeft: finalState ? "".concat(-sip * si, "px") : 0,
13252
13293
  marginTop: finalState ? "".concat(-sip * si, "px") : 0,
13253
- border: "1px solid ".concat(color),
13294
+ border: "1px solid ".concat(color2),
13254
13295
  opacity: finalState ? 1 : si === 0 ? 1 : 0,
13255
13296
  transition: "width 0.2s, height 0.2s, margin-left 0.2s, margin-top 0.2s, opacity 0.2s"
13256
13297
  },
@@ -13283,10 +13324,17 @@ var ElementOverlayBox = function(param) {
13283
13324
  })
13284
13325
  });
13285
13326
  };
13327
+ // src/lib/util/if-sets-match-exactly.ts
13328
+ function ifSetsMatchExactly(set1, set2) {
13329
+ if (set1.size !== set2.size) return false;
13330
+ return Array.from(set1).every(function(item) {
13331
+ return set2.has(item);
13332
+ });
13333
+ }
13286
13334
  // src/components/MouseElementTracker.tsx
13287
13335
  var import_jsx_runtime4 = require("react/jsx-runtime");
13288
13336
  var MouseElementTracker = function(param) {
13289
- var children = param.children, transform = param.transform, primitives = param.primitives;
13337
+ var children = param.children, transform = param.transform, primitives = param.primitives, onMouseHoverOverPrimitives = param.onMouseHoverOverPrimitives;
13290
13338
  var _ref = _sliced_to_array((0, import_react6.useState)([]), 2), mousedPrimitives = _ref[0], setMousedPrimitives = _ref[1];
13291
13339
  var highlightedPrimitives = (0, import_react7.useMemo)(function() {
13292
13340
  var highlightedPrimitives2 = [];
@@ -13348,7 +13396,7 @@ var MouseElementTracker = function(param) {
13348
13396
  x: x,
13349
13397
  y: y
13350
13398
  });
13351
- var mousedPrimitives2 = [];
13399
+ var newMousedPrimitives = [];
13352
13400
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13353
13401
  try {
13354
13402
  for(var _iterator = primitives[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
@@ -13358,7 +13406,7 @@ var MouseElementTracker = function(param) {
13358
13406
  var w = "w" in primitive ? primitive.w : primitive.r * 2;
13359
13407
  var h = "h" in primitive ? primitive.h : primitive.r * 2;
13360
13408
  if (Math.abs(primitive.x - rwPoint.x) < w / 2 && Math.abs(primitive.y - rwPoint.y) < h / 2) {
13361
- mousedPrimitives2.push(primitive);
13409
+ newMousedPrimitives.push(primitive);
13362
13410
  }
13363
13411
  }
13364
13412
  } catch (err) {
@@ -13375,7 +13423,15 @@ var MouseElementTracker = function(param) {
13375
13423
  }
13376
13424
  }
13377
13425
  }
13378
- setMousedPrimitives(mousedPrimitives2);
13426
+ if (ifSetsMatchExactly(new Set(newMousedPrimitives.map(function(p) {
13427
+ return p._pcb_drawing_object_id;
13428
+ })), new Set(mousedPrimitives.map(function(p) {
13429
+ return p._pcb_drawing_object_id;
13430
+ })))) {
13431
+ return;
13432
+ }
13433
+ setMousedPrimitives(newMousedPrimitives);
13434
+ onMouseHoverOverPrimitives(newMousedPrimitives);
13379
13435
  }
13380
13436
  },
13381
13437
  children: [
@@ -13657,7 +13713,7 @@ var import_soup2 = __toESM(require_dist());
13657
13713
  // package.json
13658
13714
  var package_default = {
13659
13715
  name: "@tscircuit/pcb-viewer",
13660
- version: "1.9.1",
13716
+ version: "1.9.2",
13661
13717
  main: "dist/index.js",
13662
13718
  repository: "tscircuit/pcb-viewer",
13663
13719
  license: "MIT",
@@ -13687,6 +13743,7 @@ var package_default = {
13687
13743
  "@tscircuit/react-fiber": "^1.1.25",
13688
13744
  "@tscircuit/soup": "^0.0.61",
13689
13745
  "@tscircuit/soup-util": "^0.0.13",
13746
+ "@types/color": "^3.0.6",
13690
13747
  "@types/node": "18.7.23",
13691
13748
  "@types/react": "^18.3.3",
13692
13749
  next: "^14.1.4",
@@ -14707,17 +14764,51 @@ var RatsNestOverlay = function(param) {
14707
14764
  var import_jsx_runtime13 = require("react/jsx-runtime");
14708
14765
  var CanvasElementsRenderer = function(props) {
14709
14766
  var transform = props.transform, elements = props.elements;
14710
- var primitives = (0, import_react15.useMemo)(function() {
14711
- var primitives2 = props.elements.flatMap(function(elm) {
14767
+ var primitivesWithoutInteractionMetadata = (0, import_react16.useMemo)(function() {
14768
+ var primitivesWithoutInteractionMetadata2 = props.elements.flatMap(function(elm) {
14712
14769
  return convertElementToPrimitives(elm, props.elements);
14713
14770
  });
14714
- return primitives2;
14771
+ return primitivesWithoutInteractionMetadata2;
14715
14772
  }, [
14716
14773
  props.elements
14717
14774
  ]);
14775
+ var _ref = _sliced_to_array((0, import_react15.useState)(primitivesWithoutInteractionMetadata), 2), primitives = _ref[0], setPrimitives = _ref[1];
14718
14776
  return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(MouseElementTracker, {
14719
14777
  transform: transform,
14720
- primitives: primitives,
14778
+ primitives: primitivesWithoutInteractionMetadata,
14779
+ onMouseHoverOverPrimitives: function(primitivesHoveredOver) {
14780
+ var primitiveIdsWithMouseOver = new Set(primitivesHoveredOver.map(function(p) {
14781
+ return p._pcb_drawing_object_id;
14782
+ }));
14783
+ var newPrimitives = [];
14784
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
14785
+ try {
14786
+ for(var _iterator = primitivesWithoutInteractionMetadata[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
14787
+ var primitive = _step.value;
14788
+ var newPrimitive = _object_spread({}, primitive);
14789
+ if (primitiveIdsWithMouseOver.has(primitive._pcb_drawing_object_id)) {
14790
+ newPrimitive.is_mouse_over = true;
14791
+ } else {
14792
+ newPrimitive.is_mouse_over = false;
14793
+ }
14794
+ newPrimitives.push(newPrimitive);
14795
+ }
14796
+ } catch (err) {
14797
+ _didIteratorError = true;
14798
+ _iteratorError = err;
14799
+ } finally{
14800
+ try {
14801
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
14802
+ _iterator.return();
14803
+ }
14804
+ } finally{
14805
+ if (_didIteratorError) {
14806
+ throw _iteratorError;
14807
+ }
14808
+ }
14809
+ }
14810
+ setPrimitives(newPrimitives);
14811
+ },
14721
14812
  children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(EditPlacementOverlay, {
14722
14813
  disabled: !props.allowEditing,
14723
14814
  transform: transform,
@@ -14763,11 +14854,11 @@ var import_use_mouse_matrix_transform = __toESM(require_dist3());
14763
14854
  var noop = function noop() {};
14764
14855
  var isBrowser = typeof window !== "undefined";
14765
14856
  // node_modules/react-use/esm/useIsomorphicLayoutEffect.js
14766
- var import_react16 = require("react");
14767
- var useIsomorphicLayoutEffect = isBrowser ? import_react16.useLayoutEffect : import_react16.useEffect;
14857
+ var import_react17 = require("react");
14858
+ var useIsomorphicLayoutEffect = isBrowser ? import_react17.useLayoutEffect : import_react17.useEffect;
14768
14859
  var useIsomorphicLayoutEffect_default = useIsomorphicLayoutEffect;
14769
14860
  // node_modules/react-use/esm/useMeasure.js
14770
- var import_react17 = require("react");
14861
+ var import_react18 = require("react");
14771
14862
  var defaultState = {
14772
14863
  x: 0,
14773
14864
  y: 0,
@@ -14779,9 +14870,9 @@ var defaultState = {
14779
14870
  right: 0
14780
14871
  };
14781
14872
  function useMeasure() {
14782
- var _a = (0, import_react17.useState)(null), element = _a[0], ref = _a[1];
14783
- var _b = (0, import_react17.useState)(defaultState), rect = _b[0], setRect = _b[1];
14784
- var observer = (0, import_react17.useMemo)(function() {
14873
+ var _a = (0, import_react18.useState)(null), element = _a[0], ref = _a[1];
14874
+ var _b = (0, import_react18.useState)(defaultState), rect = _b[0], setRect = _b[1];
14875
+ var observer = (0, import_react18.useMemo)(function() {
14785
14876
  return new window.ResizeObserver(function(entries) {
14786
14877
  if (entries[0]) {
14787
14878
  var _a2 = entries[0].contentRect, x = _a2.x, y = _a2.y, width = _a2.width, height = _a2.height, top_1 = _a2.top, left = _a2.left, bottom = _a2.bottom, right = _a2.right;
@@ -14890,16 +14981,16 @@ var import_jsx_runtime14 = require("react/jsx-runtime");
14890
14981
  var defaultTransform = (0, import_transformation_matrix9.compose)((0, import_transformation_matrix9.translate)(400, 300), (0, import_transformation_matrix9.scale)(40, -40));
14891
14982
  var PCBViewer = function(param) {
14892
14983
  var children = param.children, soup = param.soup, _param_height = param.height, height = _param_height === void 0 ? 600 : _param_height, initialState = param.initialState, _param_allowEditing = param.allowEditing, allowEditing = _param_allowEditing === void 0 ? true : _param_allowEditing, editEventsProp = param.editEvents, onEditEventsChanged = param.onEditEventsChanged;
14893
- var _ref = _sliced_to_array((0, import_react18.useState)([]), 2), stateElements = _ref[0], setStateElements = _ref[1];
14984
+ var _ref = _sliced_to_array((0, import_react19.useState)([]), 2), stateElements = _ref[0], setStateElements = _ref[1];
14894
14985
  var _useMeasure_default = _sliced_to_array(useMeasure_default(), 2), ref = _useMeasure_default[0], refDimensions = _useMeasure_default[1];
14895
- var _ref1 = _sliced_to_array((0, import_react18.useState)(defaultTransform), 2), transform = _ref1[0], setTransformInternal = _ref1[1];
14986
+ var _ref1 = _sliced_to_array((0, import_react19.useState)(defaultTransform), 2), transform = _ref1[0], setTransformInternal = _ref1[1];
14896
14987
  var _ref2 = (0, import_use_mouse_matrix_transform.default)({
14897
14988
  transform: transform,
14898
14989
  onSetTransform: setTransformInternal
14899
14990
  }), transformRef = _ref2.ref, setTransform = _ref2.setTransform, cancelPanDrag = _ref2.cancelDrag;
14900
- var _ref3 = _sliced_to_array((0, import_react18.useState)([]), 2), editEvents = _ref3[0], setEditEvents = _ref3[1];
14991
+ var _ref3 = _sliced_to_array((0, import_react19.useState)([]), 2), editEvents = _ref3[0], setEditEvents = _ref3[1];
14901
14992
  editEvents = editEventsProp !== null && editEventsProp !== void 0 ? editEventsProp : editEvents;
14902
- var _ref4 = _sliced_to_array((0, import_react18.useState)(null), 2), error = _ref4[0], setError = _ref4[1];
14993
+ var _ref4 = _sliced_to_array((0, import_react19.useState)(null), 2), error = _ref4[0], setError = _ref4[1];
14903
14994
  var resetTransform = function() {
14904
14995
  var elmBounds = (refDimensions === null || refDimensions === void 0 ? void 0 : refDimensions.width) > 0 ? refDimensions : {
14905
14996
  width: 500,
@@ -14923,7 +15014,7 @@ var PCBViewer = function(param) {
14923
15014
  setTransform((0, import_transformation_matrix9.compose)((0, import_transformation_matrix9.translate)(((_elmBounds_width1 = elmBounds.width) !== null && _elmBounds_width1 !== void 0 ? _elmBounds_width1 : 0) / 2, ((_elmBounds_height1 = elmBounds.height) !== null && _elmBounds_height1 !== void 0 ? _elmBounds_height1 : 0) / 2), // translate(100, 0),
14924
15015
  (0, import_transformation_matrix9.scale)(scaleFactor, -scaleFactor, 0, 0), (0, import_transformation_matrix9.translate)(-center.x, -center.y)));
14925
15016
  };
14926
- (0, import_react18.useEffect)(function() {
15017
+ (0, import_react19.useEffect)(function() {
14927
15018
  var doRender = function doRender() {
14928
15019
  return _doRender.apply(this, arguments);
14929
15020
  };
@@ -14959,7 +15050,7 @@ var PCBViewer = function(param) {
14959
15050
  }, [
14960
15051
  children
14961
15052
  ]);
14962
- (0, import_react18.useEffect)(function() {
15053
+ (0, import_react19.useEffect)(function() {
14963
15054
  if (refDimensions && refDimensions.width !== 0 && (children || soup)) {
14964
15055
  resetTransform();
14965
15056
  }
@@ -14980,7 +15071,7 @@ var PCBViewer = function(param) {
14980
15071
  var pcbElmsPreEdit = (soup !== null && soup !== void 0 ? soup : stateElements).filter(function(e) {
14981
15072
  return e.type.startsWith("pcb_") || e.type.startsWith("source_");
14982
15073
  });
14983
- var elements = (0, import_react18.useMemo)(function() {
15074
+ var elements = (0, import_react19.useMemo)(function() {
14984
15075
  return applyEditEvents(pcbElmsPreEdit, editEvents);
14985
15076
  }, [
14986
15077
  pcbElmsPreEdit,