@tscircuit/core 0.0.1424 → 0.0.1425

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.
Files changed (2) hide show
  1. package/dist/index.js +238 -178
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22346,6 +22346,177 @@ function Group_getRoutingPhasePlans(group) {
22346
22346
  return plans;
22347
22347
  }
22348
22348
 
22349
+ // package.json
22350
+ var package_default = {
22351
+ name: "@tscircuit/core",
22352
+ type: "module",
22353
+ version: "0.0.1424",
22354
+ types: "dist/index.d.ts",
22355
+ main: "dist/index.js",
22356
+ module: "dist/index.js",
22357
+ exports: {
22358
+ ".": {
22359
+ import: "./dist/index.js",
22360
+ types: "./dist/index.d.ts"
22361
+ }
22362
+ },
22363
+ files: [
22364
+ "dist"
22365
+ ],
22366
+ repository: {
22367
+ type: "git",
22368
+ url: "https://github.com/tscircuit/core"
22369
+ },
22370
+ scripts: {
22371
+ build: "tsup-node",
22372
+ format: "biome format . --write",
22373
+ "measure-bundle": "howfat -r table .",
22374
+ "pkg-pr-new-release": "bunx pkg-pr-new publish --comment=off --peerDeps",
22375
+ "smoke-test:dist": "bun run scripts/smoke-tests/test-dist-simple-circuit.tsx",
22376
+ "build:benchmarking": "bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist",
22377
+ "build:benchmarking:watch": `chokidar "./{benchmarking,lib}/**/*.{ts,tsx}" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'`,
22378
+ "start:benchmarking": 'concurrently "bun run build:benchmarking:watch" "live-server ./benchmarking-dist"',
22379
+ "generate-test-plan": "bun run scripts/generate-test-plan.ts"
22380
+ },
22381
+ devDependencies: {
22382
+ "@biomejs/biome": "^1.8.3",
22383
+ "@resvg/resvg-js": "^2.6.2",
22384
+ "@tscircuit/alphabet": "0.0.25",
22385
+ "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
22386
+ "@tscircuit/capacity-autorouter": "^0.0.655",
22387
+ "@tscircuit/checks": "0.0.142",
22388
+ "@tscircuit/circuit-json-util": "^0.0.97",
22389
+ "@tscircuit/common": "^0.0.20",
22390
+ "@tscircuit/copper-pour-solver": "0.0.38",
22391
+ "@tscircuit/footprinter": "^0.0.371",
22392
+ "@tscircuit/image-utils": "^0.0.8",
22393
+ "@tscircuit/infer-cable-insertion-point": "^0.0.2",
22394
+ "@tscircuit/infgrid-ijump-astar": "^0.0.35",
22395
+ "@tscircuit/jlcpcb-manufacturing-specs": "git+https://github.com/tscircuit/jlcpcb-manufacturing-specs#e08af159db01a37db007e33f0a7268d0e4a279a5",
22396
+ "@tscircuit/krt-wasm": "^0.1.1",
22397
+ "@tscircuit/log-soup": "^1.0.2",
22398
+ "@tscircuit/matchpack": "^0.0.33",
22399
+ "@tscircuit/math-utils": "^0.0.36",
22400
+ "@tscircuit/miniflex": "^0.0.4",
22401
+ "@tscircuit/ngspice-spice-engine": "^0.0.19",
22402
+ "@tscircuit/props": "^0.0.571",
22403
+ "@tscircuit/schematic-match-adapt": "^0.0.18",
22404
+ "@tscircuit/schematic-trace-solver": "^0.0.95",
22405
+ "@tscircuit/solver-utils": "^0.0.16",
22406
+ "@tscircuit/soup-util": "^0.0.41",
22407
+ "@types/bun": "^1.2.16",
22408
+ "@types/debug": "^4.1.12",
22409
+ "@types/react": "^19.1.8",
22410
+ "@types/react-dom": "^19.1.6",
22411
+ "@types/react-reconciler": "^0.28.9",
22412
+ "bpc-graph": "^0.0.57",
22413
+ "bun-match-svg": "0.0.12",
22414
+ "calculate-elbow": "^0.0.12",
22415
+ "chokidar-cli": "^3.0.0",
22416
+ "circuit-json": "^0.0.447",
22417
+ "circuit-json-to-bpc": "^0.0.13",
22418
+ "circuit-json-to-connectivity-map": "^0.0.23",
22419
+ "circuit-json-to-gltf": "^0.0.105",
22420
+ "circuit-json-to-spice": "^0.0.40",
22421
+ "circuit-to-svg": "^0.0.371",
22422
+ concurrently: "^9.1.2",
22423
+ "connectivity-map": "^1.0.0",
22424
+ debug: "^4.3.6",
22425
+ flatbush: "^4.5.0",
22426
+ "graphics-debug": "^0.0.95",
22427
+ howfat: "^0.3.8",
22428
+ "kicad-to-circuit-json": "^0.0.97",
22429
+ kicadts: "^0.0.47",
22430
+ "live-server": "^1.2.2",
22431
+ "looks-same": "^9.0.1",
22432
+ minicssgrid: "^0.0.9",
22433
+ "pkg-pr-new": "^0.0.37",
22434
+ poppygl: "^0.0.25",
22435
+ react: "^19.1.0",
22436
+ "react-dom": "^19.1.0",
22437
+ "schematic-symbols": "^0.0.231",
22438
+ spicets: "^0.0.2",
22439
+ spicey: "^0.0.14",
22440
+ "stack-svgs": "^0.0.1",
22441
+ "ts-expect": "^1.3.0",
22442
+ tsup: "^8.2.4"
22443
+ },
22444
+ peerDependencies: {
22445
+ "@tscircuit/capacity-autorouter": "*",
22446
+ "@tscircuit/checks": "*",
22447
+ "@tscircuit/circuit-json-util": "*",
22448
+ "@tscircuit/footprinter": "*",
22449
+ "@tscircuit/infgrid-ijump-astar": "*",
22450
+ "@tscircuit/math-utils": "*",
22451
+ "@tscircuit/props": "*",
22452
+ "@tscircuit/schematic-match-adapt": "*",
22453
+ "circuit-json-to-bpc": "*",
22454
+ "bpc-graph": "*",
22455
+ "@tscircuit/matchpack": "*",
22456
+ "circuit-json": "*",
22457
+ "circuit-json-to-connectivity-map": "*",
22458
+ "schematic-symbols": "*",
22459
+ typescript: "^5.0.0"
22460
+ },
22461
+ dependencies: {
22462
+ "@flatten-js/core": "^1.6.2",
22463
+ "@lume/kiwi": "^0.4.3",
22464
+ "calculate-cell-boundaries": "^0.0.13",
22465
+ "calculate-packing": "0.0.75",
22466
+ "css-select": "5.1.0",
22467
+ "format-si-unit": "^0.0.7",
22468
+ nanoid: "^5.0.7",
22469
+ "performance-now": "^2.1.0",
22470
+ "react-reconciler": "^0.32.0",
22471
+ "svg-path-commander": "^2.1.11",
22472
+ "transformation-matrix": "^2.16.1",
22473
+ zod: "^3.25.67"
22474
+ }
22475
+ };
22476
+
22477
+ // lib/components/primitive-components/Group/Group_localAutoroutingCache.ts
22478
+ var getFnv1aHash = (value) => {
22479
+ let hash = 2166136261;
22480
+ for (let i = 0; i < value.length; i++) {
22481
+ hash ^= value.charCodeAt(i);
22482
+ hash = Math.imul(hash, 16777619);
22483
+ }
22484
+ return hash >>> 0;
22485
+ };
22486
+ var getSrjHash = (simpleRouteJson) => {
22487
+ const serializedSrj = JSON.stringify(simpleRouteJson);
22488
+ const hash1 = getFnv1aHash(serializedSrj);
22489
+ const hash2 = getFnv1aHash(`${serializedSrj}${hash1}`);
22490
+ return `${hash1.toString(16).padStart(8, "0")}${hash2.toString(16).padStart(8, "0")}`;
22491
+ };
22492
+ var getLocalAutoroutingCacheKey = (simpleRouteJson) => `routes:core@${package_default.version}:srj:${getSrjHash(simpleRouteJson)}`;
22493
+ var getCachedLocalAutoroutingPhaseResult = async ({
22494
+ cacheEngine,
22495
+ cacheKey
22496
+ }) => {
22497
+ if (!cacheEngine) return null;
22498
+ try {
22499
+ const cachedResult = await cacheEngine.getItem(cacheKey);
22500
+ if (!cachedResult) return null;
22501
+ const parsedResult = JSON.parse(cachedResult);
22502
+ if (!parsedResult || !Array.isArray(parsedResult.traces)) return null;
22503
+ return parsedResult;
22504
+ } catch {
22505
+ return null;
22506
+ }
22507
+ };
22508
+ var cacheLocalAutoroutingPhaseResult = async ({
22509
+ cacheEngine,
22510
+ cacheKey,
22511
+ result
22512
+ }) => {
22513
+ if (!cacheEngine) return;
22514
+ try {
22515
+ await cacheEngine.setItem(cacheKey, JSON.stringify(result));
22516
+ } catch {
22517
+ }
22518
+ };
22519
+
22349
22520
  // lib/components/primitive-components/Group/Group_phasedAutoroutingUtils.ts
22350
22521
  function isWirePoint(point6) {
22351
22522
  return point6.route_type === "wire";
@@ -23851,65 +24022,84 @@ var Group5 = class extends NormalComponent3 {
23851
24022
  componentDisplayName: this.getString(),
23852
24023
  simpleRouteJson
23853
24024
  });
24025
+ const cacheEngine = phaseAutorouterConfig.algorithmFn ? void 0 : this.root?.platform?.localCacheEngine;
24026
+ const cacheKey = cacheEngine ? getLocalAutoroutingCacheKey(simpleRouteJson) : void 0;
24027
+ const cachedResult = cacheKey ? await getCachedLocalAutoroutingPhaseResult({ cacheEngine, cacheKey }) : null;
23854
24028
  let autorouter;
23855
- if (phaseAutorouterConfig.algorithmFn) {
23856
- autorouter = await phaseAutorouterConfig.algorithmFn(simpleRouteJson);
23857
- } else {
23858
- const autorouterVersion2 = this.props.autorouterVersion;
23859
- const effortLevel = this.props.autorouterEffortLevel;
23860
- const effort = effortLevel ? Number.parseInt(effortLevel.replace("x", ""), 10) : void 0;
23861
- autorouter = new TscircuitAutorouter(simpleRouteJson, {
23862
- // Optional configuration parameters
23863
- capacityDepth: phaseAutorouterConfig.capacityDepth,
23864
- targetMinCapacity: phaseAutorouterConfig.targetMinCapacity,
23865
- useAssignableSolver: phaseIsLaserPrefabPreset || isSingleLayerBoard,
23866
- useAutoJumperSolver: phaseIsAutoJumperPreset,
23867
- useLaserPrefabSolver: phaseIsLaserPrefabPreset,
23868
- autorouterVersion: autorouterVersion2,
23869
- effort,
23870
- onSolverStarted: ({ solverName, solverParams }) => this.root?.emit("solver:started", {
23871
- type: "solver:started",
23872
- solverName,
23873
- solverParams,
23874
- componentName: this.getString()
23875
- })
23876
- });
23877
- }
23878
- const routingPromise = new Promise(
23879
- (resolve, reject) => {
23880
- autorouter.on("complete", (event) => {
23881
- debug12(`[${this.getString()}] local autorouting complete`);
23882
- resolve(event.traces);
23883
- });
23884
- autorouter.on("error", (event) => {
23885
- debug12(
23886
- `[${this.getString()}] local autorouting error: ${event.error.message}`
23887
- );
23888
- reject(event.error);
24029
+ try {
24030
+ let traces;
24031
+ if (cachedResult) {
24032
+ debug12(`[${this.getString()}] using cached local autorouting result`);
24033
+ traces = cachedResult.traces;
24034
+ } else {
24035
+ if (phaseAutorouterConfig.algorithmFn) {
24036
+ autorouter = await phaseAutorouterConfig.algorithmFn(simpleRouteJson);
24037
+ } else {
24038
+ const autorouterVersion2 = this.props.autorouterVersion;
24039
+ const effortLevel = this.props.autorouterEffortLevel;
24040
+ const effort = effortLevel ? Number.parseInt(effortLevel.replace("x", ""), 10) : void 0;
24041
+ autorouter = new TscircuitAutorouter(simpleRouteJson, {
24042
+ capacityDepth: phaseAutorouterConfig.capacityDepth,
24043
+ targetMinCapacity: phaseAutorouterConfig.targetMinCapacity,
24044
+ useAssignableSolver: phaseIsLaserPrefabPreset || isSingleLayerBoard,
24045
+ useAutoJumperSolver: phaseIsAutoJumperPreset,
24046
+ useLaserPrefabSolver: phaseIsLaserPrefabPreset,
24047
+ autorouterVersion: autorouterVersion2,
24048
+ effort,
24049
+ onSolverStarted: ({ solverName, solverParams }) => this.root?.emit("solver:started", {
24050
+ type: "solver:started",
24051
+ solverName,
24052
+ solverParams,
24053
+ componentName: this.getString()
24054
+ })
24055
+ });
24056
+ }
24057
+ if (!autorouter) {
24058
+ throw new Error("Failed to create local autorouter");
24059
+ }
24060
+ const activeAutorouter = autorouter;
24061
+ const routingPromise = new Promise(
24062
+ (resolve, reject) => {
24063
+ activeAutorouter.on("complete", (event) => {
24064
+ debug12(`[${this.getString()}] local autorouting complete`);
24065
+ resolve(event.traces);
24066
+ });
24067
+ activeAutorouter.on("error", (event) => {
24068
+ debug12(
24069
+ `[${this.getString()}] local autorouting error: ${event.error.message}`
24070
+ );
24071
+ reject(event.error);
24072
+ });
24073
+ }
24074
+ );
24075
+ activeAutorouter.on("progress", (event) => {
24076
+ this.root?.emit("autorouting:progress", {
24077
+ subcircuit_id: this.subcircuit_id,
24078
+ componentDisplayName: this.getString(),
24079
+ ...event
24080
+ });
23889
24081
  });
24082
+ activeAutorouter.start();
24083
+ traces = await routingPromise;
23890
24084
  }
23891
- );
23892
- autorouter.on("progress", (event) => {
23893
- this.root?.emit("autorouting:progress", {
23894
- subcircuit_id: this.subcircuit_id,
23895
- componentDisplayName: this.getString(),
23896
- ...event
23897
- });
23898
- });
23899
- autorouter.start();
23900
- try {
23901
- const traces = await routingPromise;
23902
24085
  const outputSimpleRouteJson = {
23903
24086
  ...simpleRouteJson,
23904
24087
  traces
23905
24088
  };
24089
+ if (!cachedResult && cacheKey) {
24090
+ await cacheLocalAutoroutingPhaseResult({
24091
+ cacheEngine,
24092
+ cacheKey,
24093
+ result: outputSimpleRouteJson
24094
+ });
24095
+ }
23906
24096
  this.root?.emit("autorouting:end", {
23907
24097
  type: "autorouting:end",
23908
24098
  subcircuit_id: this.subcircuit_id,
23909
24099
  componentDisplayName: this.getString(),
23910
24100
  simpleRouteJson: outputSimpleRouteJson
23911
24101
  });
23912
- if (autorouter.getConnectedOffboardObstacles) {
24102
+ if (autorouter?.getConnectedOffboardObstacles) {
23913
24103
  const connectedOffboardObstacles = autorouter.getConnectedOffboardObstacles();
23914
24104
  createSourceTracesFromOffboardConnections({
23915
24105
  db,
@@ -23918,7 +24108,7 @@ var Group5 = class extends NormalComponent3 {
23918
24108
  subcircuit_id: this.subcircuit_id
23919
24109
  });
23920
24110
  }
23921
- const solver = autorouter.solver;
24111
+ const solver = autorouter?.solver;
23922
24112
  if (solver?.getOutputJumpers) {
23923
24113
  outputJumpers.push(...solver.getOutputJumpers() || []);
23924
24114
  }
@@ -23969,7 +24159,7 @@ var Group5 = class extends NormalComponent3 {
23969
24159
  });
23970
24160
  throw error;
23971
24161
  } finally {
23972
- autorouter.stop();
24162
+ autorouter?.stop();
23973
24163
  }
23974
24164
  }
23975
24165
  this._asyncAutoroutingResult = {
@@ -25647,136 +25837,6 @@ import { su as su5 } from "@tscircuit/circuit-json-util";
25647
25837
  import Debug15 from "debug";
25648
25838
  import { isValidElement as isValidElement2 } from "react";
25649
25839
  import { identity as identity5 } from "transformation-matrix";
25650
-
25651
- // package.json
25652
- var package_default = {
25653
- name: "@tscircuit/core",
25654
- type: "module",
25655
- version: "0.0.1423",
25656
- types: "dist/index.d.ts",
25657
- main: "dist/index.js",
25658
- module: "dist/index.js",
25659
- exports: {
25660
- ".": {
25661
- import: "./dist/index.js",
25662
- types: "./dist/index.d.ts"
25663
- }
25664
- },
25665
- files: [
25666
- "dist"
25667
- ],
25668
- repository: {
25669
- type: "git",
25670
- url: "https://github.com/tscircuit/core"
25671
- },
25672
- scripts: {
25673
- build: "tsup-node",
25674
- format: "biome format . --write",
25675
- "measure-bundle": "howfat -r table .",
25676
- "pkg-pr-new-release": "bunx pkg-pr-new publish --comment=off --peerDeps",
25677
- "smoke-test:dist": "bun run scripts/smoke-tests/test-dist-simple-circuit.tsx",
25678
- "build:benchmarking": "bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist",
25679
- "build:benchmarking:watch": `chokidar "./{benchmarking,lib}/**/*.{ts,tsx}" -c 'bun build --experimental-html ./benchmarking/website/index.html --outdir ./benchmarking-dist'`,
25680
- "start:benchmarking": 'concurrently "bun run build:benchmarking:watch" "live-server ./benchmarking-dist"',
25681
- "generate-test-plan": "bun run scripts/generate-test-plan.ts"
25682
- },
25683
- devDependencies: {
25684
- "@biomejs/biome": "^1.8.3",
25685
- "@resvg/resvg-js": "^2.6.2",
25686
- "@tscircuit/alphabet": "0.0.25",
25687
- "@tscircuit/breakout-point-solver": "github:tscircuit/breakout-point-solver#bac9629",
25688
- "@tscircuit/capacity-autorouter": "^0.0.655",
25689
- "@tscircuit/checks": "0.0.142",
25690
- "@tscircuit/circuit-json-util": "^0.0.97",
25691
- "@tscircuit/common": "^0.0.20",
25692
- "@tscircuit/copper-pour-solver": "0.0.38",
25693
- "@tscircuit/footprinter": "^0.0.371",
25694
- "@tscircuit/image-utils": "^0.0.8",
25695
- "@tscircuit/infer-cable-insertion-point": "^0.0.2",
25696
- "@tscircuit/infgrid-ijump-astar": "^0.0.35",
25697
- "@tscircuit/jlcpcb-manufacturing-specs": "git+https://github.com/tscircuit/jlcpcb-manufacturing-specs#e08af159db01a37db007e33f0a7268d0e4a279a5",
25698
- "@tscircuit/krt-wasm": "^0.1.1",
25699
- "@tscircuit/log-soup": "^1.0.2",
25700
- "@tscircuit/matchpack": "^0.0.33",
25701
- "@tscircuit/math-utils": "^0.0.36",
25702
- "@tscircuit/miniflex": "^0.0.4",
25703
- "@tscircuit/ngspice-spice-engine": "^0.0.19",
25704
- "@tscircuit/props": "^0.0.571",
25705
- "@tscircuit/schematic-match-adapt": "^0.0.18",
25706
- "@tscircuit/schematic-trace-solver": "^0.0.95",
25707
- "@tscircuit/solver-utils": "^0.0.16",
25708
- "@tscircuit/soup-util": "^0.0.41",
25709
- "@types/bun": "^1.2.16",
25710
- "@types/debug": "^4.1.12",
25711
- "@types/react": "^19.1.8",
25712
- "@types/react-dom": "^19.1.6",
25713
- "@types/react-reconciler": "^0.28.9",
25714
- "bpc-graph": "^0.0.57",
25715
- "bun-match-svg": "0.0.12",
25716
- "calculate-elbow": "^0.0.12",
25717
- "chokidar-cli": "^3.0.0",
25718
- "circuit-json": "^0.0.447",
25719
- "circuit-json-to-bpc": "^0.0.13",
25720
- "circuit-json-to-connectivity-map": "^0.0.23",
25721
- "circuit-json-to-gltf": "^0.0.105",
25722
- "circuit-json-to-spice": "^0.0.40",
25723
- "circuit-to-svg": "^0.0.371",
25724
- concurrently: "^9.1.2",
25725
- "connectivity-map": "^1.0.0",
25726
- debug: "^4.3.6",
25727
- flatbush: "^4.5.0",
25728
- "graphics-debug": "^0.0.95",
25729
- howfat: "^0.3.8",
25730
- "kicad-to-circuit-json": "^0.0.97",
25731
- kicadts: "^0.0.47",
25732
- "live-server": "^1.2.2",
25733
- "looks-same": "^9.0.1",
25734
- minicssgrid: "^0.0.9",
25735
- "pkg-pr-new": "^0.0.37",
25736
- poppygl: "^0.0.25",
25737
- react: "^19.1.0",
25738
- "react-dom": "^19.1.0",
25739
- "schematic-symbols": "^0.0.231",
25740
- spicets: "^0.0.2",
25741
- spicey: "^0.0.14",
25742
- "stack-svgs": "^0.0.1",
25743
- "ts-expect": "^1.3.0",
25744
- tsup: "^8.2.4"
25745
- },
25746
- peerDependencies: {
25747
- "@tscircuit/capacity-autorouter": "*",
25748
- "@tscircuit/checks": "*",
25749
- "@tscircuit/circuit-json-util": "*",
25750
- "@tscircuit/footprinter": "*",
25751
- "@tscircuit/infgrid-ijump-astar": "*",
25752
- "@tscircuit/math-utils": "*",
25753
- "@tscircuit/props": "*",
25754
- "@tscircuit/schematic-match-adapt": "*",
25755
- "circuit-json-to-bpc": "*",
25756
- "bpc-graph": "*",
25757
- "@tscircuit/matchpack": "*",
25758
- "circuit-json": "*",
25759
- "circuit-json-to-connectivity-map": "*",
25760
- "schematic-symbols": "*",
25761
- typescript: "^5.0.0"
25762
- },
25763
- dependencies: {
25764
- "@flatten-js/core": "^1.6.2",
25765
- "@lume/kiwi": "^0.4.3",
25766
- "calculate-cell-boundaries": "^0.0.13",
25767
- "calculate-packing": "0.0.75",
25768
- "css-select": "5.1.0",
25769
- "format-si-unit": "^0.0.7",
25770
- nanoid: "^5.0.7",
25771
- "performance-now": "^2.1.0",
25772
- "react-reconciler": "^0.32.0",
25773
- "svg-path-commander": "^2.1.11",
25774
- "transformation-matrix": "^2.16.1",
25775
- zod: "^3.25.67"
25776
- }
25777
- };
25778
-
25779
- // lib/IsolatedCircuit.ts
25780
25840
  var IsolatedCircuit = class {
25781
25841
  firstChild = null;
25782
25842
  children;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1424",
4
+ "version": "0.0.1425",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",