copperflow 0.0.0-stage → 0.3.1

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 (767) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +265 -2
  4. package/dist/app/THIRD_PARTY_LICENSES.txt +118 -0
  5. package/dist/app/assets/NewPartDialog-Qb7NwhBb.js +160 -0
  6. package/dist/app/assets/index-CSWIIMFE.css +1 -0
  7. package/dist/app/assets/index-C_TXwo-N.js +19 -0
  8. package/dist/app/index.html +15 -0
  9. package/dist/app/theme-boot.js +3 -0
  10. package/dist/cli-commands.d.ts +14 -0
  11. package/dist/cli-commands.js +285 -0
  12. package/dist/cli-commands.js.map +1 -0
  13. package/dist/cli.d.ts +2 -0
  14. package/dist/cli.js +24 -0
  15. package/dist/cli.js.map +1 -0
  16. package/dist/core/analyze.d.ts +29 -0
  17. package/dist/core/analyze.js +284 -0
  18. package/dist/core/analyze.js.map +1 -0
  19. package/dist/core/annotations.d.ts +77 -0
  20. package/dist/core/annotations.js +138 -0
  21. package/dist/core/annotations.js.map +1 -0
  22. package/dist/core/board-edits.d.ts +8 -0
  23. package/dist/core/board-edits.js +56 -0
  24. package/dist/core/board-edits.js.map +1 -0
  25. package/dist/core/board-items.d.ts +40 -0
  26. package/dist/core/board-items.js +95 -0
  27. package/dist/core/board-items.js.map +1 -0
  28. package/dist/core/bom.d.ts +35 -0
  29. package/dist/core/bom.js +146 -0
  30. package/dist/core/bom.js.map +1 -0
  31. package/dist/core/check.d.ts +42 -0
  32. package/dist/core/check.js +91 -0
  33. package/dist/core/check.js.map +1 -0
  34. package/dist/core/checks-line.d.ts +7 -0
  35. package/dist/core/checks-line.js +8 -0
  36. package/dist/core/checks-line.js.map +1 -0
  37. package/dist/core/connection-names.d.ts +2 -0
  38. package/dist/core/connection-names.js +16 -0
  39. package/dist/core/connection-names.js.map +1 -0
  40. package/dist/core/design-source.d.ts +6 -0
  41. package/dist/core/design-source.js +14 -0
  42. package/dist/core/design-source.js.map +1 -0
  43. package/dist/core/drawing-edits.d.ts +19 -0
  44. package/dist/core/drawing-edits.js +158 -0
  45. package/dist/core/drawing-edits.js.map +1 -0
  46. package/dist/core/drawing-identity.d.ts +12 -0
  47. package/dist/core/drawing-identity.js +32 -0
  48. package/dist/core/drawing-identity.js.map +1 -0
  49. package/dist/core/drawing-names.d.ts +10 -0
  50. package/dist/core/drawing-names.js +30 -0
  51. package/dist/core/drawing-names.js.map +1 -0
  52. package/dist/core/drawing-scan.d.ts +41 -0
  53. package/dist/core/drawing-scan.js +82 -0
  54. package/dist/core/drawing-scan.js.map +1 -0
  55. package/dist/core/edit-error.d.ts +5 -0
  56. package/dist/core/edit-error.js +9 -0
  57. package/dist/core/edit-error.js.map +1 -0
  58. package/dist/core/edit-text.d.ts +28 -0
  59. package/dist/core/edit-text.js +89 -0
  60. package/dist/core/edit-text.js.map +1 -0
  61. package/dist/core/edit.d.ts +13 -0
  62. package/dist/core/edit.js +341 -0
  63. package/dist/core/edit.js.map +1 -0
  64. package/dist/core/fabrication.d.ts +39 -0
  65. package/dist/core/fabrication.js +94 -0
  66. package/dist/core/fabrication.js.map +1 -0
  67. package/dist/core/file-writes.d.ts +18 -0
  68. package/dist/core/file-writes.js +81 -0
  69. package/dist/core/file-writes.js.map +1 -0
  70. package/dist/core/fs-utils.d.ts +13 -0
  71. package/dist/core/fs-utils.js +51 -0
  72. package/dist/core/fs-utils.js.map +1 -0
  73. package/dist/core/history.d.ts +80 -0
  74. package/dist/core/history.js +161 -0
  75. package/dist/core/history.js.map +1 -0
  76. package/dist/core/index.d.ts +21 -0
  77. package/dist/core/index.js +22 -0
  78. package/dist/core/index.js.map +1 -0
  79. package/dist/core/instance-edits.d.ts +15 -0
  80. package/dist/core/instance-edits.js +69 -0
  81. package/dist/core/instance-edits.js.map +1 -0
  82. package/dist/core/instance-locks.d.ts +10 -0
  83. package/dist/core/instance-locks.js +16 -0
  84. package/dist/core/instance-locks.js.map +1 -0
  85. package/dist/core/instance-requests.d.ts +45 -0
  86. package/dist/core/instance-requests.js +93 -0
  87. package/dist/core/instance-requests.js.map +1 -0
  88. package/dist/core/layout-edits.d.ts +51 -0
  89. package/dist/core/layout-edits.js +82 -0
  90. package/dist/core/layout-edits.js.map +1 -0
  91. package/dist/core/layout-file.d.ts +80 -0
  92. package/dist/core/layout-file.js +209 -0
  93. package/dist/core/layout-file.js.map +1 -0
  94. package/dist/core/layout-locks.d.ts +38 -0
  95. package/dist/core/layout-locks.js +39 -0
  96. package/dist/core/layout-locks.js.map +1 -0
  97. package/dist/core/layout-records.d.ts +72 -0
  98. package/dist/core/layout-records.js +146 -0
  99. package/dist/core/layout-records.js.map +1 -0
  100. package/dist/core/library.d.ts +128 -0
  101. package/dist/core/library.js +378 -0
  102. package/dist/core/library.js.map +1 -0
  103. package/dist/core/literals.d.ts +19 -0
  104. package/dist/core/literals.js +106 -0
  105. package/dist/core/literals.js.map +1 -0
  106. package/dist/core/make-sheet.d.ts +44 -0
  107. package/dist/core/make-sheet.js +130 -0
  108. package/dist/core/make-sheet.js.map +1 -0
  109. package/dist/core/netlist.d.ts +41 -0
  110. package/dist/core/netlist.js +147 -0
  111. package/dist/core/netlist.js.map +1 -0
  112. package/dist/core/new-circuit-sheets.d.ts +35 -0
  113. package/dist/core/new-circuit-sheets.js +146 -0
  114. package/dist/core/new-circuit-sheets.js.map +1 -0
  115. package/dist/core/new-circuit.d.ts +65 -0
  116. package/dist/core/new-circuit.js +83 -0
  117. package/dist/core/new-circuit.js.map +1 -0
  118. package/dist/core/page-edits.d.ts +25 -0
  119. package/dist/core/page-edits.js +180 -0
  120. package/dist/core/page-edits.js.map +1 -0
  121. package/dist/core/pin-types.d.ts +8 -0
  122. package/dist/core/pin-types.js +10 -0
  123. package/dist/core/pin-types.js.map +1 -0
  124. package/dist/core/place.d.ts +30 -0
  125. package/dist/core/place.js +77 -0
  126. package/dist/core/place.js.map +1 -0
  127. package/dist/core/placement-write.d.ts +56 -0
  128. package/dist/core/placement-write.js +222 -0
  129. package/dist/core/placement-write.js.map +1 -0
  130. package/dist/core/pour-edits.d.ts +20 -0
  131. package/dist/core/pour-edits.js +241 -0
  132. package/dist/core/pour-edits.js.map +1 -0
  133. package/dist/core/project-text.d.ts +15 -0
  134. package/dist/core/project-text.js +58 -0
  135. package/dist/core/project-text.js.map +1 -0
  136. package/dist/core/project.d.ts +23 -0
  137. package/dist/core/project.js +63 -0
  138. package/dist/core/project.js.map +1 -0
  139. package/dist/core/rename-designators.d.ts +23 -0
  140. package/dist/core/rename-designators.js +83 -0
  141. package/dist/core/rename-designators.js.map +1 -0
  142. package/dist/core/rename-parts.d.ts +12 -0
  143. package/dist/core/rename-parts.js +129 -0
  144. package/dist/core/rename-parts.js.map +1 -0
  145. package/dist/core/rules-edit.d.ts +7 -0
  146. package/dist/core/rules-edit.js +56 -0
  147. package/dist/core/rules-edit.js.map +1 -0
  148. package/dist/core/selectors.d.ts +11 -0
  149. package/dist/core/selectors.js +33 -0
  150. package/dist/core/selectors.js.map +1 -0
  151. package/dist/core/sheet-cut-layout.d.ts +13 -0
  152. package/dist/core/sheet-cut-layout.js +62 -0
  153. package/dist/core/sheet-cut-layout.js.map +1 -0
  154. package/dist/core/sheet-cut-text.d.ts +23 -0
  155. package/dist/core/sheet-cut-text.js +129 -0
  156. package/dist/core/sheet-cut-text.js.map +1 -0
  157. package/dist/core/sheet-cut.d.ts +55 -0
  158. package/dist/core/sheet-cut.js +204 -0
  159. package/dist/core/sheet-cut.js.map +1 -0
  160. package/dist/core/sheet-edits.d.ts +12 -0
  161. package/dist/core/sheet-edits.js +107 -0
  162. package/dist/core/sheet-edits.js.map +1 -0
  163. package/dist/core/sheet-files.d.ts +31 -0
  164. package/dist/core/sheet-files.js +134 -0
  165. package/dist/core/sheet-files.js.map +1 -0
  166. package/dist/core/sheet-layout.d.ts +27 -0
  167. package/dist/core/sheet-layout.js +60 -0
  168. package/dist/core/sheet-layout.js.map +1 -0
  169. package/dist/core/summary.d.ts +10 -0
  170. package/dist/core/summary.js +79 -0
  171. package/dist/core/summary.js.map +1 -0
  172. package/dist/core/track-split.d.ts +22 -0
  173. package/dist/core/track-split.js +24 -0
  174. package/dist/core/track-split.js.map +1 -0
  175. package/dist/core/types.d.ts +309 -0
  176. package/dist/core/types.js +2 -0
  177. package/dist/core/types.js.map +1 -0
  178. package/dist/core/unroute.d.ts +56 -0
  179. package/dist/core/unroute.js +87 -0
  180. package/dist/core/unroute.js.map +1 -0
  181. package/dist/core/workspace.d.ts +94 -0
  182. package/dist/core/workspace.js +376 -0
  183. package/dist/core/workspace.js.map +1 -0
  184. package/dist/engine/autoplace.d.ts +18 -0
  185. package/dist/engine/autoplace.js +68 -0
  186. package/dist/engine/autoplace.js.map +1 -0
  187. package/dist/engine/board.d.ts +12 -0
  188. package/dist/engine/board.js +60 -0
  189. package/dist/engine/board.js.map +1 -0
  190. package/dist/engine/checks/copper-clearance.d.ts +7 -0
  191. package/dist/engine/checks/copper-clearance.js +116 -0
  192. package/dist/engine/checks/copper-clearance.js.map +1 -0
  193. package/dist/engine/checks/copper-notes.d.ts +11 -0
  194. package/dist/engine/checks/copper-notes.js +17 -0
  195. package/dist/engine/checks/copper-notes.js.map +1 -0
  196. package/dist/engine/checks/copper-pieces.d.ts +26 -0
  197. package/dist/engine/checks/copper-pieces.js +42 -0
  198. package/dist/engine/checks/copper-pieces.js.map +1 -0
  199. package/dist/engine/checks/copper-violation.d.ts +9 -0
  200. package/dist/engine/checks/copper-violation.js +11 -0
  201. package/dist/engine/checks/copper-violation.js.map +1 -0
  202. package/dist/engine/checks/drc-copper.d.ts +14 -0
  203. package/dist/engine/checks/drc-copper.js +139 -0
  204. package/dist/engine/checks/drc-copper.js.map +1 -0
  205. package/dist/engine/checks/drc-pads.d.ts +8 -0
  206. package/dist/engine/checks/drc-pads.js +172 -0
  207. package/dist/engine/checks/drc-pads.js.map +1 -0
  208. package/dist/engine/checks/drc-parts.d.ts +5 -0
  209. package/dist/engine/checks/drc-parts.js +208 -0
  210. package/dist/engine/checks/drc-parts.js.map +1 -0
  211. package/dist/engine/checks/drc-pours.d.ts +6 -0
  212. package/dist/engine/checks/drc-pours.js +240 -0
  213. package/dist/engine/checks/drc-pours.js.map +1 -0
  214. package/dist/engine/checks/erc.d.ts +6 -0
  215. package/dist/engine/checks/erc.js +94 -0
  216. package/dist/engine/checks/erc.js.map +1 -0
  217. package/dist/engine/checks/fillet-guard.d.ts +29 -0
  218. package/dist/engine/checks/fillet-guard.js +75 -0
  219. package/dist/engine/checks/fillet-guard.js.map +1 -0
  220. package/dist/engine/checks/geometry.d.ts +25 -0
  221. package/dist/engine/checks/geometry.js +182 -0
  222. package/dist/engine/checks/geometry.js.map +1 -0
  223. package/dist/engine/checks/grid-index.d.ts +24 -0
  224. package/dist/engine/checks/grid-index.js +57 -0
  225. package/dist/engine/checks/grid-index.js.map +1 -0
  226. package/dist/engine/checks/index.d.ts +16 -0
  227. package/dist/engine/checks/index.js +55 -0
  228. package/dist/engine/checks/index.js.map +1 -0
  229. package/dist/engine/checks/limits.d.ts +7 -0
  230. package/dist/engine/checks/limits.js +10 -0
  231. package/dist/engine/checks/limits.js.map +1 -0
  232. package/dist/engine/checks/unplaced-parts.d.ts +4 -0
  233. package/dist/engine/checks/unplaced-parts.js +29 -0
  234. package/dist/engine/checks/unplaced-parts.js.map +1 -0
  235. package/dist/engine/checks/violation.d.ts +14 -0
  236. package/dist/engine/checks/violation.js +7 -0
  237. package/dist/engine/checks/violation.js.map +1 -0
  238. package/dist/engine/component.d.ts +34 -0
  239. package/dist/engine/component.js +125 -0
  240. package/dist/engine/component.js.map +1 -0
  241. package/dist/engine/copper.d.ts +63 -0
  242. package/dist/engine/copper.js +276 -0
  243. package/dist/engine/copper.js.map +1 -0
  244. package/dist/engine/design.d.ts +21 -0
  245. package/dist/engine/design.js +63 -0
  246. package/dist/engine/design.js.map +1 -0
  247. package/dist/engine/diagnostics.d.ts +2 -0
  248. package/dist/engine/diagnostics.js +6 -0
  249. package/dist/engine/diagnostics.js.map +1 -0
  250. package/dist/engine/drawing-ids.d.ts +23 -0
  251. package/dist/engine/drawing-ids.js +45 -0
  252. package/dist/engine/drawing-ids.js.map +1 -0
  253. package/dist/engine/drawing-kinds.d.ts +18 -0
  254. package/dist/engine/drawing-kinds.js +102 -0
  255. package/dist/engine/drawing-kinds.js.map +1 -0
  256. package/dist/engine/drawing-reader.d.ts +42 -0
  257. package/dist/engine/drawing-reader.js +97 -0
  258. package/dist/engine/drawing-reader.js.map +1 -0
  259. package/dist/engine/drawings.d.ts +35 -0
  260. package/dist/engine/drawings.js +94 -0
  261. package/dist/engine/drawings.js.map +1 -0
  262. package/dist/engine/elaborate.d.ts +8 -0
  263. package/dist/engine/elaborate.js +490 -0
  264. package/dist/engine/elaborate.js.map +1 -0
  265. package/dist/engine/engine-worker.d.ts +1 -0
  266. package/dist/engine/engine-worker.js +17 -0
  267. package/dist/engine/engine-worker.js.map +1 -0
  268. package/dist/engine/engine.d.ts +41 -0
  269. package/dist/engine/engine.js +95 -0
  270. package/dist/engine/engine.js.map +1 -0
  271. package/dist/engine/evaluate.d.ts +10 -0
  272. package/dist/engine/evaluate.js +125 -0
  273. package/dist/engine/evaluate.js.map +1 -0
  274. package/dist/engine/fab/bom-csv.d.ts +5 -0
  275. package/dist/engine/fab/bom-csv.js +16 -0
  276. package/dist/engine/fab/bom-csv.js.map +1 -0
  277. package/dist/engine/fab/csv.d.ts +4 -0
  278. package/dist/engine/fab/csv.js +11 -0
  279. package/dist/engine/fab/csv.js.map +1 -0
  280. package/dist/engine/fab/designators.d.ts +42 -0
  281. package/dist/engine/fab/designators.js +109 -0
  282. package/dist/engine/fab/designators.js.map +1 -0
  283. package/dist/engine/fab/excellon.d.ts +23 -0
  284. package/dist/engine/fab/excellon.js +82 -0
  285. package/dist/engine/fab/excellon.js.map +1 -0
  286. package/dist/engine/fab/export.d.ts +33 -0
  287. package/dist/engine/fab/export.js +105 -0
  288. package/dist/engine/fab/export.js.map +1 -0
  289. package/dist/engine/fab/gerber.d.ts +53 -0
  290. package/dist/engine/fab/gerber.js +151 -0
  291. package/dist/engine/fab/gerber.js.map +1 -0
  292. package/dist/engine/fab/layers.d.ts +26 -0
  293. package/dist/engine/fab/layers.js +162 -0
  294. package/dist/engine/fab/layers.js.map +1 -0
  295. package/dist/engine/fab/names.d.ts +20 -0
  296. package/dist/engine/fab/names.js +58 -0
  297. package/dist/engine/fab/names.js.map +1 -0
  298. package/dist/engine/fab/pick-and-place.d.ts +5 -0
  299. package/dist/engine/fab/pick-and-place.js +36 -0
  300. package/dist/engine/fab/pick-and-place.js.map +1 -0
  301. package/dist/engine/fab/stroke-font.d.ts +8 -0
  302. package/dist/engine/fab/stroke-font.js +83 -0
  303. package/dist/engine/fab/stroke-font.js.map +1 -0
  304. package/dist/engine/fab/zip.d.ts +14 -0
  305. package/dist/engine/fab/zip.js +93 -0
  306. package/dist/engine/fab/zip.js.map +1 -0
  307. package/dist/engine/fillet-plan.d.ts +39 -0
  308. package/dist/engine/fillet-plan.js +87 -0
  309. package/dist/engine/fillet-plan.js.map +1 -0
  310. package/dist/engine/fillet.d.ts +54 -0
  311. package/dist/engine/fillet.js +175 -0
  312. package/dist/engine/fillet.js.map +1 -0
  313. package/dist/engine/footprints/bga.d.ts +14 -0
  314. package/dist/engine/footprints/bga.js +122 -0
  315. package/dist/engine/footprints/bga.js.map +1 -0
  316. package/dist/engine/footprints/chip.d.ts +3 -0
  317. package/dist/engine/footprints/chip.js +52 -0
  318. package/dist/engine/footprints/chip.js.map +1 -0
  319. package/dist/engine/footprints/crystal.d.ts +4 -0
  320. package/dist/engine/footprints/crystal.js +47 -0
  321. package/dist/engine/footprints/crystal.js.map +1 -0
  322. package/dist/engine/footprints/dfn.d.ts +13 -0
  323. package/dist/engine/footprints/dfn.js +52 -0
  324. package/dist/engine/footprints/dfn.js.map +1 -0
  325. package/dist/engine/footprints/dip.d.ts +8 -0
  326. package/dist/engine/footprints/dip.js +65 -0
  327. package/dist/engine/footprints/dip.js.map +1 -0
  328. package/dist/engine/footprints/dual.d.ts +14 -0
  329. package/dist/engine/footprints/dual.js +171 -0
  330. package/dist/engine/footprints/dual.js.map +1 -0
  331. package/dist/engine/footprints/exposed.d.ts +27 -0
  332. package/dist/engine/footprints/exposed.js +50 -0
  333. package/dist/engine/footprints/exposed.js.map +1 -0
  334. package/dist/engine/footprints/file.d.ts +65 -0
  335. package/dist/engine/footprints/file.js +141 -0
  336. package/dist/engine/footprints/file.js.map +1 -0
  337. package/dist/engine/footprints/ic.d.ts +34 -0
  338. package/dist/engine/footprints/ic.js +31 -0
  339. package/dist/engine/footprints/ic.js.map +1 -0
  340. package/dist/engine/footprints/index.d.ts +17 -0
  341. package/dist/engine/footprints/index.js +104 -0
  342. package/dist/engine/footprints/index.js.map +1 -0
  343. package/dist/engine/footprints/ipc7251.d.ts +30 -0
  344. package/dist/engine/footprints/ipc7251.js +44 -0
  345. package/dist/engine/footprints/ipc7251.js.map +1 -0
  346. package/dist/engine/footprints/ipc7351.d.ts +179 -0
  347. package/dist/engine/footprints/ipc7351.js +194 -0
  348. package/dist/engine/footprints/ipc7351.js.map +1 -0
  349. package/dist/engine/footprints/jedec.d.ts +24 -0
  350. package/dist/engine/footprints/jedec.js +148 -0
  351. package/dist/engine/footprints/jedec.js.map +1 -0
  352. package/dist/engine/footprints/known.d.ts +6 -0
  353. package/dist/engine/footprints/known.js +76 -0
  354. package/dist/engine/footprints/known.js.map +1 -0
  355. package/dist/engine/footprints/molded.d.ts +8 -0
  356. package/dist/engine/footprints/molded.js +76 -0
  357. package/dist/engine/footprints/molded.js.map +1 -0
  358. package/dist/engine/footprints/outline.d.ts +64 -0
  359. package/dist/engine/footprints/outline.js +187 -0
  360. package/dist/engine/footprints/outline.js.map +1 -0
  361. package/dist/engine/footprints/parse.d.ts +32 -0
  362. package/dist/engine/footprints/parse.js +68 -0
  363. package/dist/engine/footprints/parse.js.map +1 -0
  364. package/dist/engine/footprints/pinrow.d.ts +11 -0
  365. package/dist/engine/footprints/pinrow.js +102 -0
  366. package/dist/engine/footprints/pinrow.js.map +1 -0
  367. package/dist/engine/footprints/quad.d.ts +7 -0
  368. package/dist/engine/footprints/quad.js +135 -0
  369. package/dist/engine/footprints/quad.js.map +1 -0
  370. package/dist/engine/footprints/radial.d.ts +7 -0
  371. package/dist/engine/footprints/radial.js +62 -0
  372. package/dist/engine/footprints/radial.js.map +1 -0
  373. package/dist/engine/footprints/sod.d.ts +8 -0
  374. package/dist/engine/footprints/sod.js +60 -0
  375. package/dist/engine/footprints/sod.js.map +1 -0
  376. package/dist/engine/footprints/sot.d.ts +4 -0
  377. package/dist/engine/footprints/sot.js +72 -0
  378. package/dist/engine/footprints/sot.js.map +1 -0
  379. package/dist/engine/footprints/sotpower.d.ts +4 -0
  380. package/dist/engine/footprints/sotpower.js +98 -0
  381. package/dist/engine/footprints/sotpower.js.map +1 -0
  382. package/dist/engine/footprints/to220.d.ts +4 -0
  383. package/dist/engine/footprints/to220.js +49 -0
  384. package/dist/engine/footprints/to220.js.map +1 -0
  385. package/dist/engine/footprints/to92.d.ts +4 -0
  386. package/dist/engine/footprints/to92.js +43 -0
  387. package/dist/engine/footprints/to92.js.map +1 -0
  388. package/dist/engine/footprints/types.d.ts +50 -0
  389. package/dist/engine/footprints/types.js +3 -0
  390. package/dist/engine/footprints/types.js.map +1 -0
  391. package/dist/engine/hole.d.ts +15 -0
  392. package/dist/engine/hole.js +28 -0
  393. package/dist/engine/hole.js.map +1 -0
  394. package/dist/engine/index.d.ts +6 -0
  395. package/dist/engine/index.js +6 -0
  396. package/dist/engine/index.js.map +1 -0
  397. package/dist/engine/instance-anchor.d.ts +16 -0
  398. package/dist/engine/instance-anchor.js +45 -0
  399. package/dist/engine/instance-anchor.js.map +1 -0
  400. package/dist/engine/jsx-runtime.d.ts +26 -0
  401. package/dist/engine/jsx-runtime.js +49 -0
  402. package/dist/engine/jsx-runtime.js.map +1 -0
  403. package/dist/engine/keepout.d.ts +9 -0
  404. package/dist/engine/keepout.js +50 -0
  405. package/dist/engine/keepout.js.map +1 -0
  406. package/dist/engine/kinds.d.ts +34 -0
  407. package/dist/engine/kinds.js +134 -0
  408. package/dist/engine/kinds.js.map +1 -0
  409. package/dist/engine/model.d.ts +310 -0
  410. package/dist/engine/model.js +5 -0
  411. package/dist/engine/model.js.map +1 -0
  412. package/dist/engine/nets.d.ts +6 -0
  413. package/dist/engine/nets.js +49 -0
  414. package/dist/engine/nets.js.map +1 -0
  415. package/dist/engine/no-connect.d.ts +28 -0
  416. package/dist/engine/no-connect.js +36 -0
  417. package/dist/engine/no-connect.js.map +1 -0
  418. package/dist/engine/order.d.ts +7 -0
  419. package/dist/engine/order.js +25 -0
  420. package/dist/engine/order.js.map +1 -0
  421. package/dist/engine/pad-text.d.ts +20 -0
  422. package/dist/engine/pad-text.js +26 -0
  423. package/dist/engine/pad-text.js.map +1 -0
  424. package/dist/engine/part-labels.d.ts +29 -0
  425. package/dist/engine/part-labels.js +28 -0
  426. package/dist/engine/part-labels.js.map +1 -0
  427. package/dist/engine/pcb-place/blocks.d.ts +46 -0
  428. package/dist/engine/pcb-place/blocks.js +186 -0
  429. package/dist/engine/pcb-place/blocks.js.map +1 -0
  430. package/dist/engine/pcb-place/constructive.d.ts +73 -0
  431. package/dist/engine/pcb-place/constructive.js +515 -0
  432. package/dist/engine/pcb-place/constructive.js.map +1 -0
  433. package/dist/engine/pcb-place/edge.d.ts +7 -0
  434. package/dist/engine/pcb-place/edge.js +78 -0
  435. package/dist/engine/pcb-place/edge.js.map +1 -0
  436. package/dist/engine/pcb-place/fit-board.d.ts +22 -0
  437. package/dist/engine/pcb-place/fit-board.js +48 -0
  438. package/dist/engine/pcb-place/fit-board.js.map +1 -0
  439. package/dist/engine/pcb-place/geometry.d.ts +45 -0
  440. package/dist/engine/pcb-place/geometry.js +158 -0
  441. package/dist/engine/pcb-place/geometry.js.map +1 -0
  442. package/dist/engine/pcb-place/index.d.ts +81 -0
  443. package/dist/engine/pcb-place/index.js +98 -0
  444. package/dist/engine/pcb-place/index.js.map +1 -0
  445. package/dist/engine/pcb-place/refine.d.ts +32 -0
  446. package/dist/engine/pcb-place/refine.js +220 -0
  447. package/dist/engine/pcb-place/refine.js.map +1 -0
  448. package/dist/engine/pcb-place/roles.d.ts +37 -0
  449. package/dist/engine/pcb-place/roles.js +127 -0
  450. package/dist/engine/pcb-place/roles.js.map +1 -0
  451. package/dist/engine/pcb-place/scope.d.ts +80 -0
  452. package/dist/engine/pcb-place/scope.js +107 -0
  453. package/dist/engine/pcb-place/scope.js.map +1 -0
  454. package/dist/engine/pcb-place/score.d.ts +40 -0
  455. package/dist/engine/pcb-place/score.js +140 -0
  456. package/dist/engine/pcb-place/score.js.map +1 -0
  457. package/dist/engine/pcb.d.ts +72 -0
  458. package/dist/engine/pcb.js +153 -0
  459. package/dist/engine/pcb.js.map +1 -0
  460. package/dist/engine/pour/build.d.ts +32 -0
  461. package/dist/engine/pour/build.js +108 -0
  462. package/dist/engine/pour/build.js.map +1 -0
  463. package/dist/engine/pour/cache.d.ts +8 -0
  464. package/dist/engine/pour/cache.js +55 -0
  465. package/dist/engine/pour/cache.js.map +1 -0
  466. package/dist/engine/pour/clip.d.ts +50 -0
  467. package/dist/engine/pour/clip.js +72 -0
  468. package/dist/engine/pour/clip.js.map +1 -0
  469. package/dist/engine/pour/fill.d.ts +22 -0
  470. package/dist/engine/pour/fill.js +112 -0
  471. package/dist/engine/pour/fill.js.map +1 -0
  472. package/dist/engine/pour/islands.d.ts +8 -0
  473. package/dist/engine/pour/islands.js +19 -0
  474. package/dist/engine/pour/islands.js.map +1 -0
  475. package/dist/engine/pour/joins.d.ts +18 -0
  476. package/dist/engine/pour/joins.js +74 -0
  477. package/dist/engine/pour/joins.js.map +1 -0
  478. package/dist/engine/pour/obstacles.d.ts +45 -0
  479. package/dist/engine/pour/obstacles.js +85 -0
  480. package/dist/engine/pour/obstacles.js.map +1 -0
  481. package/dist/engine/pour/resolve.d.ts +21 -0
  482. package/dist/engine/pour/resolve.js +19 -0
  483. package/dist/engine/pour/resolve.js.map +1 -0
  484. package/dist/engine/pour/shapes.d.ts +9 -0
  485. package/dist/engine/pour/shapes.js +62 -0
  486. package/dist/engine/pour/shapes.js.map +1 -0
  487. package/dist/engine/pour/thermal.d.ts +16 -0
  488. package/dist/engine/pour/thermal.js +38 -0
  489. package/dist/engine/pour/thermal.js.map +1 -0
  490. package/dist/engine/project-files.d.ts +18 -0
  491. package/dist/engine/project-files.js +58 -0
  492. package/dist/engine/project-files.js.map +1 -0
  493. package/dist/engine/ratsnest.d.ts +16 -0
  494. package/dist/engine/ratsnest.js +69 -0
  495. package/dist/engine/ratsnest.js.map +1 -0
  496. package/dist/engine/read-props.d.ts +22 -0
  497. package/dist/engine/read-props.js +74 -0
  498. package/dist/engine/read-props.js.map +1 -0
  499. package/dist/engine/router/astar.d.ts +74 -0
  500. package/dist/engine/router/astar.js +231 -0
  501. package/dist/engine/router/astar.js.map +1 -0
  502. package/dist/engine/router/blockers.d.ts +4 -0
  503. package/dist/engine/router/blockers.js +69 -0
  504. package/dist/engine/router/blockers.js.map +1 -0
  505. package/dist/engine/router/cleanup.d.ts +21 -0
  506. package/dist/engine/router/cleanup.js +157 -0
  507. package/dist/engine/router/cleanup.js.map +1 -0
  508. package/dist/engine/router/clear.d.ts +18 -0
  509. package/dist/engine/router/clear.js +39 -0
  510. package/dist/engine/router/clear.js.map +1 -0
  511. package/dist/engine/router/congestion.d.ts +79 -0
  512. package/dist/engine/router/congestion.js +212 -0
  513. package/dist/engine/router/congestion.js.map +1 -0
  514. package/dist/engine/router/connect.d.ts +79 -0
  515. package/dist/engine/router/connect.js +174 -0
  516. package/dist/engine/router/connect.js.map +1 -0
  517. package/dist/engine/router/ends.d.ts +25 -0
  518. package/dist/engine/router/ends.js +135 -0
  519. package/dist/engine/router/ends.js.map +1 -0
  520. package/dist/engine/router/grid.d.ts +131 -0
  521. package/dist/engine/router/grid.js +297 -0
  522. package/dist/engine/router/grid.js.map +1 -0
  523. package/dist/engine/router/keep-clear.d.ts +10 -0
  524. package/dist/engine/router/keep-clear.js +60 -0
  525. package/dist/engine/router/keep-clear.js.map +1 -0
  526. package/dist/engine/router/obstacles.d.ts +18 -0
  527. package/dist/engine/router/obstacles.js +66 -0
  528. package/dist/engine/router/obstacles.js.map +1 -0
  529. package/dist/engine/router/path.d.ts +34 -0
  530. package/dist/engine/router/path.js +41 -0
  531. package/dist/engine/router/path.js.map +1 -0
  532. package/dist/engine/router/pour-rounds.d.ts +17 -0
  533. package/dist/engine/router/pour-rounds.js +124 -0
  534. package/dist/engine/router/pour-rounds.js.map +1 -0
  535. package/dist/engine/router/replicate.d.ts +32 -0
  536. package/dist/engine/router/replicate.js +143 -0
  537. package/dist/engine/router/replicate.js.map +1 -0
  538. package/dist/engine/router/rip-up.d.ts +5 -0
  539. package/dist/engine/router/rip-up.js +95 -0
  540. package/dist/engine/router/rip-up.js.map +1 -0
  541. package/dist/engine/router/route-board.d.ts +109 -0
  542. package/dist/engine/router/route-board.js +223 -0
  543. package/dist/engine/router/route-board.js.map +1 -0
  544. package/dist/engine/rules/classes.d.ts +14 -0
  545. package/dist/engine/rules/classes.js +50 -0
  546. package/dist/engine/rules/classes.js.map +1 -0
  547. package/dist/engine/rules/load.d.ts +14 -0
  548. package/dist/engine/rules/load.js +146 -0
  549. package/dist/engine/rules/load.js.map +1 -0
  550. package/dist/engine/rules/profiles.d.ts +5 -0
  551. package/dist/engine/rules/profiles.js +53 -0
  552. package/dist/engine/rules/profiles.js.map +1 -0
  553. package/dist/engine/rules/rotations.d.ts +31 -0
  554. package/dist/engine/rules/rotations.js +124 -0
  555. package/dist/engine/rules/rotations.js.map +1 -0
  556. package/dist/engine/rules/schema.d.ts +82 -0
  557. package/dist/engine/rules/schema.js +59 -0
  558. package/dist/engine/rules/schema.js.map +1 -0
  559. package/dist/engine/rules/track-defaults.d.ts +23 -0
  560. package/dist/engine/rules/track-defaults.js +26 -0
  561. package/dist/engine/rules/track-defaults.js.map +1 -0
  562. package/dist/engine/schematic-astar.d.ts +37 -0
  563. package/dist/engine/schematic-astar.js +202 -0
  564. package/dist/engine/schematic-astar.js.map +1 -0
  565. package/dist/engine/schematic-geometry.d.ts +23 -0
  566. package/dist/engine/schematic-geometry.js +49 -0
  567. package/dist/engine/schematic-geometry.js.map +1 -0
  568. package/dist/engine/schematic-grid.d.ts +60 -0
  569. package/dist/engine/schematic-grid.js +150 -0
  570. package/dist/engine/schematic-grid.js.map +1 -0
  571. package/dist/engine/schematic-nets.d.ts +38 -0
  572. package/dist/engine/schematic-nets.js +157 -0
  573. package/dist/engine/schematic-nets.js.map +1 -0
  574. package/dist/engine/schematic-pages.d.ts +9 -0
  575. package/dist/engine/schematic-pages.js +52 -0
  576. package/dist/engine/schematic-pages.js.map +1 -0
  577. package/dist/engine/schematic-place-chains.d.ts +22 -0
  578. package/dist/engine/schematic-place-chains.js +111 -0
  579. package/dist/engine/schematic-place-chains.js.map +1 -0
  580. package/dist/engine/schematic-place-plan.d.ts +43 -0
  581. package/dist/engine/schematic-place-plan.js +155 -0
  582. package/dist/engine/schematic-place-plan.js.map +1 -0
  583. package/dist/engine/schematic-place-units.d.ts +38 -0
  584. package/dist/engine/schematic-place-units.js +101 -0
  585. package/dist/engine/schematic-place-units.js.map +1 -0
  586. package/dist/engine/schematic-place.d.ts +5 -0
  587. package/dist/engine/schematic-place.js +268 -0
  588. package/dist/engine/schematic-place.js.map +1 -0
  589. package/dist/engine/schematic-route.d.ts +37 -0
  590. package/dist/engine/schematic-route.js +288 -0
  591. package/dist/engine/schematic-route.js.map +1 -0
  592. package/dist/engine/schematic-sheets.d.ts +22 -0
  593. package/dist/engine/schematic-sheets.js +104 -0
  594. package/dist/engine/schematic-sheets.js.map +1 -0
  595. package/dist/engine/schematic.d.ts +64 -0
  596. package/dist/engine/schematic.js +200 -0
  597. package/dist/engine/schematic.js.map +1 -0
  598. package/dist/engine/selectors.d.ts +25 -0
  599. package/dist/engine/selectors.js +28 -0
  600. package/dist/engine/selectors.js.map +1 -0
  601. package/dist/engine/sheet-ports.d.ts +44 -0
  602. package/dist/engine/sheet-ports.js +126 -0
  603. package/dist/engine/sheet-ports.js.map +1 -0
  604. package/dist/engine/sheet-symbol.d.ts +52 -0
  605. package/dist/engine/sheet-symbol.js +92 -0
  606. package/dist/engine/sheet-symbol.js.map +1 -0
  607. package/dist/engine/sheets.d.ts +79 -0
  608. package/dist/engine/sheets.js +159 -0
  609. package/dist/engine/sheets.js.map +1 -0
  610. package/dist/engine/symbols/box.d.ts +8 -0
  611. package/dist/engine/symbols/box.js +83 -0
  612. package/dist/engine/symbols/box.js.map +1 -0
  613. package/dist/engine/symbols/index.d.ts +8 -0
  614. package/dist/engine/symbols/index.js +58 -0
  615. package/dist/engine/symbols/index.js.map +1 -0
  616. package/dist/engine/symbols/passives.d.ts +16 -0
  617. package/dist/engine/symbols/passives.js +58 -0
  618. package/dist/engine/symbols/passives.js.map +1 -0
  619. package/dist/engine/symbols/power.d.ts +5 -0
  620. package/dist/engine/symbols/power.js +10 -0
  621. package/dist/engine/symbols/power.js.map +1 -0
  622. package/dist/engine/symbols/semis.d.ts +10 -0
  623. package/dist/engine/symbols/semis.js +62 -0
  624. package/dist/engine/symbols/semis.js.map +1 -0
  625. package/dist/engine/symbols/types.d.ts +83 -0
  626. package/dist/engine/symbols/types.js +61 -0
  627. package/dist/engine/symbols/types.js.map +1 -0
  628. package/dist/engine/traces.d.ts +29 -0
  629. package/dist/engine/traces.js +102 -0
  630. package/dist/engine/traces.js.map +1 -0
  631. package/dist/engine/units.d.ts +4 -0
  632. package/dist/engine/units.js +31 -0
  633. package/dist/engine/units.js.map +1 -0
  634. package/dist/engine/worker-env.d.ts +9 -0
  635. package/dist/engine/worker-env.js +12 -0
  636. package/dist/engine/worker-env.js.map +1 -0
  637. package/dist/library/attach-datasheet.d.ts +20 -0
  638. package/dist/library/attach-datasheet.js +61 -0
  639. package/dist/library/attach-datasheet.js.map +1 -0
  640. package/dist/library/easyeda-footprint.d.ts +41 -0
  641. package/dist/library/easyeda-footprint.js +255 -0
  642. package/dist/library/easyeda-footprint.js.map +1 -0
  643. package/dist/library/easyeda-path.d.ts +13 -0
  644. package/dist/library/easyeda-path.js +133 -0
  645. package/dist/library/easyeda-path.js.map +1 -0
  646. package/dist/library/easyeda-symbol.d.ts +20 -0
  647. package/dist/library/easyeda-symbol.js +53 -0
  648. package/dist/library/easyeda-symbol.js.map +1 -0
  649. package/dist/library/import-lcsc.d.ts +30 -0
  650. package/dist/library/import-lcsc.js +155 -0
  651. package/dist/library/import-lcsc.js.map +1 -0
  652. package/dist/library/lcsc-part.d.ts +40 -0
  653. package/dist/library/lcsc-part.js +153 -0
  654. package/dist/library/lcsc-part.js.map +1 -0
  655. package/dist/library/new-part.d.ts +50 -0
  656. package/dist/library/new-part.js +160 -0
  657. package/dist/library/new-part.js.map +1 -0
  658. package/dist/library/pin-table.d.ts +23 -0
  659. package/dist/library/pin-table.js +92 -0
  660. package/dist/library/pin-table.js.map +1 -0
  661. package/dist/mcp/batch.d.ts +111 -0
  662. package/dist/mcp/batch.js +241 -0
  663. package/dist/mcp/batch.js.map +1 -0
  664. package/dist/mcp/board-summary.d.ts +19 -0
  665. package/dist/mcp/board-summary.js +144 -0
  666. package/dist/mcp/board-summary.js.map +1 -0
  667. package/dist/mcp/compact-sheets.d.ts +31 -0
  668. package/dist/mcp/compact-sheets.js +63 -0
  669. package/dist/mcp/compact-sheets.js.map +1 -0
  670. package/dist/mcp/compact-tool-list.d.ts +8 -0
  671. package/dist/mcp/compact-tool-list.js +42 -0
  672. package/dist/mcp/compact-tool-list.js.map +1 -0
  673. package/dist/mcp/compact.d.ts +33 -0
  674. package/dist/mcp/compact.js +189 -0
  675. package/dist/mcp/compact.js.map +1 -0
  676. package/dist/mcp/copper-summary.d.ts +26 -0
  677. package/dist/mcp/copper-summary.js +122 -0
  678. package/dist/mcp/copper-summary.js.map +1 -0
  679. package/dist/mcp/copper-tools.d.ts +93 -0
  680. package/dist/mcp/copper-tools.js +228 -0
  681. package/dist/mcp/copper-tools.js.map +1 -0
  682. package/dist/mcp/copper-under.d.ts +16 -0
  683. package/dist/mcp/copper-under.js +46 -0
  684. package/dist/mcp/copper-under.js.map +1 -0
  685. package/dist/mcp/create-part.d.ts +71 -0
  686. package/dist/mcp/create-part.js +31 -0
  687. package/dist/mcp/create-part.js.map +1 -0
  688. package/dist/mcp/datasheet-tools.d.ts +14 -0
  689. package/dist/mcp/datasheet-tools.js +15 -0
  690. package/dist/mcp/datasheet-tools.js.map +1 -0
  691. package/dist/mcp/fillet-tools.d.ts +24 -0
  692. package/dist/mcp/fillet-tools.js +52 -0
  693. package/dist/mcp/fillet-tools.js.map +1 -0
  694. package/dist/mcp/guide.d.ts +37 -0
  695. package/dist/mcp/guide.js +78 -0
  696. package/dist/mcp/guide.js.map +1 -0
  697. package/dist/mcp/import-part.d.ts +13 -0
  698. package/dist/mcp/import-part.js +20 -0
  699. package/dist/mcp/import-part.js.map +1 -0
  700. package/dist/mcp/make-sheet.d.ts +18 -0
  701. package/dist/mcp/make-sheet.js +29 -0
  702. package/dist/mcp/make-sheet.js.map +1 -0
  703. package/dist/mcp/new-circuit.d.ts +77 -0
  704. package/dist/mcp/new-circuit.js +114 -0
  705. package/dist/mcp/new-circuit.js.map +1 -0
  706. package/dist/mcp/place-tools.d.ts +46 -0
  707. package/dist/mcp/place-tools.js +121 -0
  708. package/dist/mcp/place-tools.js.map +1 -0
  709. package/dist/mcp/pour-tools.d.ts +126 -0
  710. package/dist/mcp/pour-tools.js +105 -0
  711. package/dist/mcp/pour-tools.js.map +1 -0
  712. package/dist/mcp/project-tools.d.ts +36 -0
  713. package/dist/mcp/project-tools.js +115 -0
  714. package/dist/mcp/project-tools.js.map +1 -0
  715. package/dist/mcp/route-by-ref.d.ts +20 -0
  716. package/dist/mcp/route-by-ref.js +70 -0
  717. package/dist/mcp/route-by-ref.js.map +1 -0
  718. package/dist/mcp/route-tools.d.ts +54 -0
  719. package/dist/mcp/route-tools.js +173 -0
  720. package/dist/mcp/route-tools.js.map +1 -0
  721. package/dist/mcp/server.d.ts +9 -0
  722. package/dist/mcp/server.js +290 -0
  723. package/dist/mcp/server.js.map +1 -0
  724. package/dist/skill-install.d.ts +13 -0
  725. package/dist/skill-install.js +28 -0
  726. package/dist/skill-install.js.map +1 -0
  727. package/dist/studio/fit-board.d.ts +11 -0
  728. package/dist/studio/fit-board.js +15 -0
  729. package/dist/studio/fit-board.js.map +1 -0
  730. package/dist/studio/layout-schema.d.ts +157 -0
  731. package/dist/studio/layout-schema.js +32 -0
  732. package/dist/studio/layout-schema.js.map +1 -0
  733. package/dist/studio/live.d.ts +79 -0
  734. package/dist/studio/live.js +187 -0
  735. package/dist/studio/live.js.map +1 -0
  736. package/dist/studio/place-events.d.ts +60 -0
  737. package/dist/studio/place-events.js +42 -0
  738. package/dist/studio/place-events.js.map +1 -0
  739. package/dist/studio/place-runner.d.ts +62 -0
  740. package/dist/studio/place-runner.js +205 -0
  741. package/dist/studio/place-runner.js.map +1 -0
  742. package/dist/studio/place-worker.d.ts +1 -0
  743. package/dist/studio/place-worker.js +23 -0
  744. package/dist/studio/place-worker.js.map +1 -0
  745. package/dist/studio/route-events.d.ts +64 -0
  746. package/dist/studio/route-events.js +61 -0
  747. package/dist/studio/route-events.js.map +1 -0
  748. package/dist/studio/route-runner.d.ts +90 -0
  749. package/dist/studio/route-runner.js +272 -0
  750. package/dist/studio/route-runner.js.map +1 -0
  751. package/dist/studio/router-worker.d.ts +1 -0
  752. package/dist/studio/router-worker.js +17 -0
  753. package/dist/studio/router-worker.js.map +1 -0
  754. package/dist/studio/server.d.ts +32 -0
  755. package/dist/studio/server.js +610 -0
  756. package/dist/studio/server.js.map +1 -0
  757. package/dist/version.d.ts +1 -0
  758. package/dist/version.js +2 -0
  759. package/dist/version.js.map +1 -0
  760. package/package.json +64 -4
  761. package/skills/copperflow/SKILL.md +199 -0
  762. package/skills/copperflow/references/copper.md +82 -0
  763. package/skills/copperflow/references/design-rules.md +163 -0
  764. package/skills/copperflow/references/design-workflow.md +199 -0
  765. package/skills/copperflow/references/editable-subset.md +83 -0
  766. package/skills/copperflow/references/parts-library.md +83 -0
  767. package/skills/copperflow/references/writing-circuits.md +62 -0
@@ -0,0 +1,55 @@
1
+ import { fillPours } from "./fill.js";
2
+ /** How many boards' fills are kept: the Studio rebuilds one board over and over, the agent may switch between a few. */
3
+ const CAPACITY = 8;
4
+ const entries = new Map();
5
+ /** A 53-bit string hash (cyrb53): quick to compute, and a hit is still checked against the whole key. */
6
+ function hash(text) {
7
+ let [h1, h2] = [0xdeadbeef, 0x41c6ce57];
8
+ for (let i = 0; i < text.length; i++) {
9
+ const code = text.charCodeAt(i);
10
+ h1 = Math.imul(h1 ^ code, 2654435761);
11
+ h2 = Math.imul(h2 ^ code, 1597334677);
12
+ }
13
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
14
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
15
+ return 4294967296 * (2097151 & h2) + (h1 >>> 0);
16
+ }
17
+ /**
18
+ * Everything the fill depends on, and nothing else: no source positions, so editing another line of the file does
19
+ * not refill the pours.
20
+ */
21
+ export function pourInputKey(inputs) {
22
+ const { board, pads, tracks, vias, rules } = inputs;
23
+ const nets = [...new Set([...pads.map((p) => p.net), ...tracks.map((t) => t.net), ...vias.map((v) => v.net), ...(board.pours ?? []).map((p) => p.net)])];
24
+ return JSON.stringify({
25
+ outline: board.outline,
26
+ keepouts: board.keepouts.map((k) => [k.outline, k.layers]),
27
+ holes: (board.holes ?? []).map((h) => [h.x, h.y, h.diameter]),
28
+ pours: (board.pours ?? []).map(({ source: _source, ...pour }) => pour),
29
+ pads: pads.map((p) => [p.shape, p.x, p.y, p.width, p.height, p.rotation, p.layers, p.cornerRadius ?? null, p.net ?? null]),
30
+ tracks: tracks.map((t) => [t.layer, t.width, t.points, t.net ?? null, t.missingLayer ?? null]),
31
+ vias: vias.map((v) => [v.at, v.diameter, v.layers, v.net ?? null, v.missingLayer ?? null]),
32
+ rules: [rules.fabrication.boardEdgeClearance, rules.fabrication.minClearance, rules.classes.map((c) => [c.name, c.clearance]), rules.classClearance],
33
+ classes: [undefined, ...nets].map((net) => [net ?? null, inputs.classOf(net)]),
34
+ });
35
+ }
36
+ /** The fills of the board's pours, computed once for each distinct input and then served from the cache. */
37
+ export function cachedPourFills(inputs) {
38
+ if ((inputs.board.pours ?? []).length === 0)
39
+ return [];
40
+ const key = pourInputKey(inputs);
41
+ const code = hash(key);
42
+ const known = entries.get(code);
43
+ if (known && known.key === key) {
44
+ entries.delete(code);
45
+ entries.set(code, known);
46
+ return known.fills;
47
+ }
48
+ const fills = fillPours(inputs);
49
+ entries.delete(code);
50
+ entries.set(code, { key, fills });
51
+ while (entries.size > CAPACITY)
52
+ entries.delete(entries.keys().next().value);
53
+ return fills;
54
+ }
55
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/engine/pour/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkC,MAAM,WAAW,CAAA;AAErE,wHAAwH;AACxH,MAAM,QAAQ,GAAG,CAAC,CAAA;AAOlB,MAAM,OAAO,GAAG,IAAI,GAAG,EAAiB,CAAA;AAExC,yGAAyG;AACzG,SAAS,IAAI,CAAC,IAAY;IACxB,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAC/B,EAAE,GAAG,IAAI,CAAC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AAG,SAAS,CAAC,MAAM,CAAC,CAAA;IAC/B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACpB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAA;IACjC,OAAO,OAAO,CAAC,IAAI,GAAG,QAAQ;QAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAe,CAAC,CAAA;IACrF,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -0,0 +1,50 @@
1
+ import type { Point } from "../model.js";
2
+ /**
3
+ * Polygon booleans and offsets on clipper-lib. Coordinates are whole micrometres (rounded once, on the way in), so
4
+ * every operation is exact and the same input always gives the same output. Areas are filled by the non-zero rule;
5
+ * results are strictly simple (no self-touching outlines), outers counter-clockwise and holes clockwise (y up).
6
+ */
7
+ export interface IntPoint {
8
+ X: number;
9
+ Y: number;
10
+ }
11
+ export type Path = IntPoint[];
12
+ export type Paths = Path[];
13
+ /** One piece of filled area: an outline and the holes in it. */
14
+ export interface Region {
15
+ outer: Path;
16
+ holes: Path[];
17
+ }
18
+ export declare const UNITS_PER_MM = 1000;
19
+ /** How far a round offset's corners may fall inside the true arc, in units (2 µm). */
20
+ export declare const ARC_TOLERANCE = 2;
21
+ export declare const toPath: (points: readonly Point[]) => Path;
22
+ export declare const toPoints: (path: Path) => Point[];
23
+ /** Everything the paths cover. */
24
+ export declare const union: (paths: Paths) => Paths;
25
+ /** What `a` covers outside `b`. */
26
+ export declare const difference: (a: Paths, b: Paths) => Paths;
27
+ /** What both cover. */
28
+ export declare const intersection: (a: Paths, b: Paths) => Paths;
29
+ /** The area grown (or shrunk, for a negative `mm`) by `mm`; miter keeps straight corners square, round rounds them. */
30
+ export declare function offset(paths: Paths, mm: number, join: "miter" | "round"): Paths;
31
+ /** The area as separate pieces, each an outline with its holes; an outline inside a hole is a piece of its own. */
32
+ export declare function regions(paths: Paths): Region[];
33
+ /** The signed area in square units: positive for a counter-clockwise outline. */
34
+ export declare const pathArea: (path: Path) => number;
35
+ /** The path counter-clockwise, so it adds to the area however it was drawn: a lone outline, never one with holes. */
36
+ export declare const counterClockwise: (path: Path) => Path;
37
+ /** The area of a region in square units: its outline less its holes. */
38
+ export declare const regionArea: (region: Region) => number;
39
+ /** True when the point is inside the region or on its edge. */
40
+ export declare function regionHolds(region: Region, point: IntPoint): boolean;
41
+ /** The box round some paths, in units. */
42
+ export interface Bounds {
43
+ minX: number;
44
+ minY: number;
45
+ maxX: number;
46
+ maxY: number;
47
+ }
48
+ export declare function boundsOf(paths: Paths): Bounds;
49
+ export declare const boxesMeet: (a: Bounds, b: Bounds) => boolean;
50
+ export declare const boxHolds: (b: Bounds, p: IntPoint) => boolean;
@@ -0,0 +1,72 @@
1
+ import ClipperLib from "clipper-lib";
2
+ export const UNITS_PER_MM = 1000;
3
+ /** How far a round offset's corners may fall inside the true arc, in units (2 µm). */
4
+ export const ARC_TOLERANCE = 2;
5
+ const MITER_LIMIT = 2;
6
+ const toUnits = (mm) => Math.round(mm * UNITS_PER_MM);
7
+ export const toPath = (points) => points.map((p) => ({ X: toUnits(p.x), Y: toUnits(p.y) }));
8
+ export const toPoints = (path) => path.map((p) => ({ x: p.X / UNITS_PER_MM, y: p.Y / UNITS_PER_MM }));
9
+ function clipper(subject, clip) {
10
+ const engine = new ClipperLib.Clipper();
11
+ engine.StrictlySimple = true;
12
+ engine.AddPaths(subject.filter((path) => path.length >= 3), ClipperLib.PolyType.ptSubject, true);
13
+ engine.AddPaths(clip.filter((path) => path.length >= 3), ClipperLib.PolyType.ptClip, true);
14
+ return engine;
15
+ }
16
+ function run(type, subject, clip) {
17
+ const out = [];
18
+ const fill = ClipperLib.PolyFillType.pftNonZero;
19
+ clipper(subject, clip).Execute(type, out, fill, fill);
20
+ return out;
21
+ }
22
+ /** Everything the paths cover. */
23
+ export const union = (paths) => run(ClipperLib.ClipType.ctUnion, paths, []);
24
+ /** What `a` covers outside `b`. */
25
+ export const difference = (a, b) => run(ClipperLib.ClipType.ctDifference, a, b);
26
+ /** What both cover. */
27
+ export const intersection = (a, b) => run(ClipperLib.ClipType.ctIntersection, a, b);
28
+ /** The area grown (or shrunk, for a negative `mm`) by `mm`; miter keeps straight corners square, round rounds them. */
29
+ export function offset(paths, mm, join) {
30
+ const kept = paths.filter((path) => path.length >= 3);
31
+ if (kept.length === 0)
32
+ return [];
33
+ const engine = new ClipperLib.ClipperOffset(MITER_LIMIT, ARC_TOLERANCE);
34
+ engine.AddPaths(kept, join === "miter" ? ClipperLib.JoinType.jtMiter : ClipperLib.JoinType.jtRound, ClipperLib.EndType.etClosedPolygon);
35
+ const out = [];
36
+ engine.Execute(out, mm * UNITS_PER_MM);
37
+ return union(out);
38
+ }
39
+ /** The area as separate pieces, each an outline with its holes; an outline inside a hole is a piece of its own. */
40
+ export function regions(paths) {
41
+ const tree = new ClipperLib.PolyTree();
42
+ const fill = ClipperLib.PolyFillType.pftNonZero;
43
+ clipper(paths, []).Execute(ClipperLib.ClipType.ctUnion, tree, fill, fill);
44
+ return ClipperLib.JS.PolyTreeToExPolygons(tree).map((piece) => ({ outer: piece.outer, holes: piece.holes }));
45
+ }
46
+ /** The signed area in square units: positive for a counter-clockwise outline. */
47
+ export const pathArea = (path) => ClipperLib.Clipper.Area(path);
48
+ /** The path counter-clockwise, so it adds to the area however it was drawn: a lone outline, never one with holes. */
49
+ export const counterClockwise = (path) => (pathArea(path) < 0 ? [...path].reverse() : path);
50
+ /** The area of a region in square units: its outline less its holes. */
51
+ export const regionArea = (region) => Math.abs(pathArea(region.outer)) - region.holes.reduce((sum, hole) => sum + Math.abs(pathArea(hole)), 0);
52
+ /** True when the point is inside the region or on its edge. */
53
+ export function regionHolds(region, point) {
54
+ if (ClipperLib.Clipper.PointInPolygon(point, region.outer) === 0)
55
+ return false;
56
+ return region.holes.every((hole) => ClipperLib.Clipper.PointInPolygon(point, hole) !== 1);
57
+ }
58
+ export function boundsOf(paths) {
59
+ const box = { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity };
60
+ for (const path of paths) {
61
+ for (const p of path) {
62
+ box.minX = Math.min(box.minX, p.X);
63
+ box.minY = Math.min(box.minY, p.Y);
64
+ box.maxX = Math.max(box.maxX, p.X);
65
+ box.maxY = Math.max(box.maxY, p.Y);
66
+ }
67
+ }
68
+ return box;
69
+ }
70
+ export const boxesMeet = (a, b) => a.minX <= b.maxX && b.minX <= a.maxX && a.minY <= b.maxY && b.minY <= a.maxY;
71
+ export const boxHolds = (b, p) => p.X >= b.minX && p.X <= b.maxX && p.Y >= b.minY && p.Y <= b.maxY;
72
+ //# sourceMappingURL=clip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clip.js","sourceRoot":"","sources":["../../../src/engine/pour/clip.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAA;AAqBpC,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAA;AAChC,sFAAsF;AACtF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAA;AAC9B,MAAM,WAAW,GAAG,CAAC,CAAA;AAErB,MAAM,OAAO,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,YAAY,CAAC,CAAA;AAE7D,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAwB,EAAQ,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AACnH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAU,EAAW,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC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CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAA"}
@@ -0,0 +1,22 @@
1
+ import type { Point, PourLayer } from "../model.js";
2
+ import { type PourInputs } from "./obstacles.js";
3
+ /** A piece of a pour's copper: its outline (counter-clockwise, y up) and its holes (clockwise), in mm. */
4
+ export interface PourPolygon {
5
+ outer: Point[];
6
+ holes: Point[][];
7
+ }
8
+ /** A pour's computed copper: the pieces on its layer and their area in mm². Never written to a file. */
9
+ export interface PourFill {
10
+ id: string;
11
+ net: string;
12
+ layer: PourLayer;
13
+ polygons: PourPolygon[];
14
+ area: number;
15
+ }
16
+ export type { PourInputs };
17
+ /**
18
+ * Fills every pour of the board, deterministically: higher priority first (equal ones in source order), each keeping
19
+ * clear of the fills before it on its layer. The result is in the board's pour order. A board without a usable
20
+ * outline fills nothing.
21
+ */
22
+ export declare function fillPours(inputs: PourInputs): PourFill[];
@@ -0,0 +1,112 @@
1
+ import { boundsOf, boxesMeet, boxHolds, difference, intersection, offset, pathArea, regionArea, regionHolds, regions, toPath, toPoints, union, UNITS_PER_MM, } from "./clip.js";
2
+ import { connectedPieces } from "./islands.js";
3
+ import { layerCopper } from "./obstacles.js";
4
+ /** A piece or hole smaller than this, in µm² (0.0001 mm²), is a crumb of rounding and is dropped. */
5
+ const MIN_PIECE_AREA = 100;
6
+ const AREA_DIGITS = 1e6;
7
+ /** The board's outline shrunk by the board-edge clearance, and cut to the pour's own outline when it has one. */
8
+ function pourRegion(pour, inputs) {
9
+ const board = offset(union([toPath(inputs.board.outline)]), -inputs.rules.fabrication.boardEdgeClearance, "miter");
10
+ return pour.outline ? intersection(board, union([toPath(pour.outline)])) : board;
11
+ }
12
+ /**
13
+ * A morphological open: shrink by half `width`, grow back with round corners. Copper narrower than `width` vanishes,
14
+ * sharp tips included (a mitred grow would rebuild them); convex corners come back rounded by half `width`. The result
15
+ * is cut back to the area it came from, so the open never adds copper.
16
+ */
17
+ function open(paths, width) {
18
+ if (paths.length === 0)
19
+ return [];
20
+ return intersection(offset(offset(paths, -width / 2, "miter"), width / 2, "round"), paths);
21
+ }
22
+ /**
23
+ * The path when it has size; a crumb of rounding is dropped. Points are not merged or moved: clipper's output is
24
+ * already free of repeats, and moving a point could bring the copper closer to what it keeps clear of.
25
+ */
26
+ function tidy(path) {
27
+ return path.length >= 3 && Math.abs(pathArea(path)) >= MIN_PIECE_AREA ? path : undefined;
28
+ }
29
+ /** The path turned to the wanted direction and started at its lowest-left point, so equal shapes print equally. */
30
+ function canonical(path, counterClockwise) {
31
+ const turned = pathArea(path) > 0 === counterClockwise ? path : [...path].reverse();
32
+ const start = turned.reduce((best, p, i) => {
33
+ const q = turned[best];
34
+ return p.X < q.X || (p.X === q.X && p.Y < q.Y) ? i : best;
35
+ }, 0);
36
+ return [...turned.slice(start), ...turned.slice(0, start)];
37
+ }
38
+ const firstPoint = (path) => path[0] ?? { X: 0, Y: 0 };
39
+ const byFirstPoint = (a, b) => firstPoint(a).X - firstPoint(b).X || firstPoint(a).Y - firstPoint(b).Y;
40
+ function tidyRegions(pieces) {
41
+ return pieces.flatMap((piece) => {
42
+ const outer = tidy(piece.outer);
43
+ if (outer === undefined)
44
+ return [];
45
+ const holes = piece.holes.map(tidy).filter((hole) => hole !== undefined).map((hole) => canonical(hole, false));
46
+ return [{ outer: canonical(outer, true), holes: holes.sort(byFirstPoint) }];
47
+ });
48
+ }
49
+ /** True when one of the pieces holds the point. */
50
+ function holds(pieces, point) {
51
+ return pieces.some((piece) => boxHolds(piece.box, point) && regionHolds(piece.region, point));
52
+ }
53
+ /**
54
+ * The spokes that join the fill: a spoke is kept only when the opened fill holds its tip, so a pad whose surroundings
55
+ * were opened away gets none (and no lone cross). A kept spoke keeps out of every other same-net pad's relief gap,
56
+ * and out of everything the fill keeps out of.
57
+ */
58
+ function joiningSpokes(reliefs, opened, allowed) {
59
+ if (reliefs.length === 0)
60
+ return [];
61
+ const pieces = regions(opened).map((region) => ({ region, box: boundsOf([region.outer]) }));
62
+ const cutBoxes = reliefs.map((relief) => boundsOf([relief.cut]));
63
+ const kept = reliefs.flatMap((relief, i) => {
64
+ const spokes = relief.spokes.filter((spoke) => holds(pieces, spoke.tip)).map((spoke) => spoke.path);
65
+ if (spokes.length === 0)
66
+ return [];
67
+ const box = boundsOf(spokes);
68
+ const others = reliefs.filter((other, j) => j !== i && boxesMeet(box, cutBoxes[j])).map((other) => other.cut);
69
+ return others.length > 0 ? difference(spokes, others) : spokes;
70
+ });
71
+ return kept.length > 0 ? intersection(kept, allowed) : [];
72
+ }
73
+ /** The copper of one pour: the region less the obstacles and relief gaps, opened, with spokes, without islands. */
74
+ function fillOne(pour, inputs, earlier) {
75
+ const copper = layerCopper(pour, inputs, earlier);
76
+ const allowed = difference(pourRegion(pour, inputs), copper.obstacles);
77
+ const cuts = copper.reliefs.map((relief) => relief.cut);
78
+ const cut = cuts.length > 0 ? difference(allowed, cuts) : allowed;
79
+ const opened = open(cut, pour.minWidth);
80
+ const spokes = joiningSpokes(copper.reliefs, opened, allowed);
81
+ const all = regions([...opened, ...spokes]);
82
+ // With no copper of its net on the layer yet there is nothing to join: the pour keeps its whole fill.
83
+ const pieces = copper.anchors.length > 0 ? connectedPieces(all, copper.anchors) : all;
84
+ return tidyRegions(pieces).sort((a, b) => byFirstPoint(a.outer, b.outer));
85
+ }
86
+ const regionPaths = (pieces) => pieces.flatMap((piece) => [piece.outer, ...piece.holes]);
87
+ function asFill(pour, pieces) {
88
+ const squareUnits = pieces.reduce((sum, piece) => sum + regionArea(piece), 0);
89
+ const area = Math.round((squareUnits / (UNITS_PER_MM * UNITS_PER_MM)) * AREA_DIGITS) / AREA_DIGITS;
90
+ const polygons = pieces.map((piece) => ({ outer: toPoints(piece.outer), holes: piece.holes.map(toPoints) }));
91
+ return { id: pour.id, net: pour.net, layer: pour.layer, polygons, area };
92
+ }
93
+ /**
94
+ * Fills every pour of the board, deterministically: higher priority first (equal ones in source order), each keeping
95
+ * clear of the fills before it on its layer. The result is in the board's pour order. A board without a usable
96
+ * outline fills nothing.
97
+ */
98
+ export function fillPours(inputs) {
99
+ const pours = inputs.board.pours ?? [];
100
+ if (inputs.board.outline.length < 3)
101
+ return pours.map((pour) => asFill(pour, []));
102
+ const order = pours.map((pour, index) => ({ pour, index })).sort((a, b) => b.pour.priority - a.pour.priority || a.index - b.index);
103
+ const earlier = [];
104
+ const filled = new Map();
105
+ for (const { pour } of order) {
106
+ const pieces = fillOne(pour, inputs, earlier);
107
+ earlier.push({ net: pour.net, layer: pour.layer, paths: regionPaths(pieces) });
108
+ filled.set(pour.id, asFill(pour, pieces));
109
+ }
110
+ return pours.map((pour) => filled.get(pour.id));
111
+ }
112
+ //# sourceMappingURL=fill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fill.js","sourceRoot":"","sources":["../../../src/engine/pour/fill.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,UAAU,EACV,WAAW,EACX,OAAO,EACP,MAAM,EACN,QAAQ,EACR,KAAK,EACL,YAAY,GAMb,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAqD,MAAM,gBAAgB,CAAA;AAmB/F,qGAAqG;AACrG,MAAM,cAAc,GAAG,GAAG,CAAA;AAC1B,MAAM,WAAW,GAAG,GAAG,CAAA;AAEvB,iHAAiH;AACjH,SAAS,UAAU,CAAC,IAAgB,EAAE,MAAkB;IACtD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,kBAAkB,EA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E,MAAM,CAAC,CAAC,CAAA;IAC3C,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAa,CAAC,CAAA;AAC7D,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type Path, type Region } from "./clip.js";
2
+ /**
3
+ * The pieces of a fill that touch the net: those that overlap at least one anchor, the outline of a piece of the
4
+ * pour's own net's copper on the layer (a pad, a track segment as a capsule, a via's disc), grown a hair so copper
5
+ * that only meets the piece's edge counts too. The rest are islands. A piece is measured against the anchors whose
6
+ * boxes meet its own, all in one intersection.
7
+ */
8
+ export declare function connectedPieces(pieces: readonly Region[], anchors: readonly Path[]): Region[];
@@ -0,0 +1,19 @@
1
+ import { boundsOf, boxesMeet, intersection } from "./clip.js";
2
+ /**
3
+ * The pieces of a fill that touch the net: those that overlap at least one anchor, the outline of a piece of the
4
+ * pour's own net's copper on the layer (a pad, a track segment as a capsule, a via's disc), grown a hair so copper
5
+ * that only meets the piece's edge counts too. The rest are islands. A piece is measured against the anchors whose
6
+ * boxes meet its own, all in one intersection.
7
+ */
8
+ export function connectedPieces(pieces, anchors) {
9
+ const anchorBoxes = anchors.map((anchor) => boundsOf([anchor]));
10
+ return pieces.filter((piece) => {
11
+ const box = boundsOf([piece.outer]);
12
+ const near = anchors.filter((_, i) => {
13
+ const anchorBox = anchorBoxes[i];
14
+ return anchorBox !== undefined && boxesMeet(box, anchorBox);
15
+ });
16
+ return near.length > 0 && intersection([piece.outer, ...piece.holes], near).length > 0;
17
+ });
18
+ }
19
+ //# sourceMappingURL=islands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"islands.js","sourceRoot":"","sources":["../../../src/engine/pour/islands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAA0B,MAAM,WAAW,CAAA;AAErF;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAyB,EAAE,OAAwB;IACjF,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAC/D,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAC7B,MAAM,GAAG,GAAG,QAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;QACnC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YACnC,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;YAChC,OAAO,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;QAC7D,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAA;IACxF,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { type PcbTrack, type PcbVia } from "../copper.js";
2
+ import type { WorldPad } from "../pcb.js";
3
+ import type { PourFill } from "./fill.js";
4
+ /** The connections the pours make per net (`PcbLayout.pourMade`). */
5
+ export type PourMade = readonly {
6
+ net: string;
7
+ count: number;
8
+ }[];
9
+ /**
10
+ * "3 connections on GND are made by pours" (or, with `more`, "3 more on GND are made by pours"): the total and the nets
11
+ * (three at most are named), as the sentence the check and the router both use. Undefined when the pours make none.
12
+ */
13
+ export declare function pourMadeText(made: PourMade, more?: boolean): string | undefined;
14
+ /**
15
+ * For each piece of each fill (pours in order, pieces in order), the ids of its net's copper it touches, in pad, track
16
+ * and via order. A piece touching nothing gives an empty list.
17
+ */
18
+ export declare function pourJoins(fills: readonly PourFill[], pads: readonly WorldPad[], tracks: readonly PcbTrack[], vias: readonly PcbVia[]): string[][];
@@ -0,0 +1,74 @@
1
+ import { padShape } from "../checks/geometry.js";
2
+ import { viaSpan } from "../copper.js";
3
+ import { naturalCompare } from "../order.js";
4
+ import { boundsOf, boxesMeet, boxHolds, intersection, regionHolds, toPath } from "./clip.js";
5
+ import { shapeOutline } from "./shapes.js";
6
+ /**
7
+ * Which copper each piece of fill touches: for every pour, piece by piece, the ids of the pads, tracks and vias of the
8
+ * pour's own net on its layer that the piece's copper meets. Only the pour's own net is looked at: the fill keeps clear
9
+ * of every other net by construction, and the copper checks measure that. A piece holding a point of the copper (a pad's
10
+ * or via's centre, a track's points) touches it; otherwise the copper's outline, grown 1 µm so meeting at an edge counts,
11
+ * is intersected with the piece.
12
+ */
13
+ /** How far copper is grown to find the pieces it touches, in mm: 1 µm, as for the fill's islands. */
14
+ const TOUCH = 0.001;
15
+ const padOnLayer = (pad, layer) => pad.layers === "through" || pad.layers === layer;
16
+ function trackShapes(track) {
17
+ const radius = track.width / 2;
18
+ if (track.points.length < 2)
19
+ return track.points.map((p) => ({ core: [p], radius }));
20
+ return track.points.slice(1).map((p, i) => ({ core: [track.points[i], p], radius }));
21
+ }
22
+ /** The pour's own net's copper on its layer, pads first, then tracks and vias, each as test points and outlines. */
23
+ function itemsOf(fill, pads, tracks, vias) {
24
+ const onBoard = (item) => item.missingLayer === undefined;
25
+ return [
26
+ ...pads
27
+ .filter((pad) => pad.net === fill.net && padOnLayer(pad, fill.layer))
28
+ .flatMap((pad) => {
29
+ const shape = padShape(pad);
30
+ return shape === undefined ? [] : [{ id: pad.id, points: [{ x: pad.x, y: pad.y }], shapes: [shape] }];
31
+ }),
32
+ ...tracks.filter((track) => onBoard(track) && track.net === fill.net && track.layer === fill.layer).map((track) => ({ id: track.id, points: track.points, shapes: trackShapes(track) })),
33
+ ...vias
34
+ .filter((via) => onBoard(via) && via.net === fill.net && viaSpan(via).has(fill.layer))
35
+ .map((via) => ({ id: via.id, points: [via.at], shapes: [{ core: [via.at], radius: via.diameter / 2 }] })),
36
+ ];
37
+ }
38
+ const holds = (piece, p) => boxHolds(piece.box, p) && regionHolds(piece.region, p);
39
+ function touches(piece, item) {
40
+ if (toPath(item.points).some((p) => holds(piece, p)))
41
+ return true;
42
+ const outlines = item.shapes.map((shape) => toPath(shapeOutline(shape, TOUCH))).filter((path) => path.length >= 3);
43
+ if (outlines.length === 0 || !boxesMeet(piece.box, boundsOf(outlines)))
44
+ return false;
45
+ return intersection([piece.region.outer, ...piece.region.holes], outlines).length > 0;
46
+ }
47
+ /**
48
+ * "3 connections on GND are made by pours" (or, with `more`, "3 more on GND are made by pours"): the total and the nets
49
+ * (three at most are named), as the sentence the check and the router both use. Undefined when the pours make none.
50
+ */
51
+ export function pourMadeText(made, more = false) {
52
+ const total = made.reduce((sum, one) => sum + one.count, 0);
53
+ if (total === 0)
54
+ return undefined;
55
+ const nets = [...new Set(made.map((one) => one.net.replace(/^net[.:]/, "")))].sort(naturalCompare);
56
+ const named = `${nets.slice(0, 3).join(", ")}${nets.length > 3 ? ` and ${nets.length - 3} more` : ""}`;
57
+ const what = more ? `${total} more` : total === 1 ? "1 connection" : `${total} connections`;
58
+ return `${what} on ${named} ${total === 1 ? "is" : "are"} made by pours`;
59
+ }
60
+ /**
61
+ * For each piece of each fill (pours in order, pieces in order), the ids of its net's copper it touches, in pad, track
62
+ * and via order. A piece touching nothing gives an empty list.
63
+ */
64
+ export function pourJoins(fills, pads, tracks, vias) {
65
+ return fills.flatMap((fill) => {
66
+ const items = itemsOf(fill, pads, tracks, vias);
67
+ return fill.polygons.map((polygon) => {
68
+ const region = { outer: toPath(polygon.outer), holes: polygon.holes.map(toPath) };
69
+ const piece = { region, box: boundsOf([region.outer]) };
70
+ return items.filter((item) => touches(piece, item)).map((item) => item.id);
71
+ });
72
+ });
73
+ }
74
+ //# sourceMappingURL=joins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"joins.js","sourceRoot":"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AG,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;QAC/C,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;YACnC,MAAM,MAAM,GAAW,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;YACzF,MAAM,KAAK,GAAU,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAA;YAC9D,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC5E,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { ClassOf } from "../checks/copper-pieces.js";
2
+ import { type PcbTrack, type PcbVia } from "../copper.js";
3
+ import type { Board, CopperPour, PourLayer } from "../model.js";
4
+ import type { WorldPad } from "../pcb.js";
5
+ import type { Rules } from "../rules/schema.js";
6
+ import { type IntPoint, type Path, type Paths } from "./clip.js";
7
+ /** What a pour's fill is computed from: the board (outline, keepouts, holes), the placed pads, the copper, the rules. */
8
+ export interface PourInputs {
9
+ board: Board;
10
+ pads: readonly WorldPad[];
11
+ tracks: readonly PcbTrack[];
12
+ vias: readonly PcbVia[];
13
+ rules: Rules;
14
+ /** The net class of a net; copper without a net is in the default class. */
15
+ classOf: ClassOf;
16
+ }
17
+ /** A fill already computed, which pours of lower priority on its layer keep clear of. */
18
+ export interface EarlierFill {
19
+ net: string;
20
+ layer: PourLayer;
21
+ paths: Paths;
22
+ }
23
+ /** What a pour meets on its layer. */
24
+ export interface LayerCopper {
25
+ /**
26
+ * What the fill keeps out of, as one area: other nets' copper and earlier fills grown by the clearance, keepouts,
27
+ * holes. Every outline is turned counter-clockwise before the union, so a keepout drawn clockwise does not cancel
28
+ * a pad it overlaps under the non-zero rule.
29
+ */
30
+ obstacles: Paths;
31
+ /** The relief round each of the pour's own pads (relief pours only). */
32
+ reliefs: PadRelief[];
33
+ /** Outlines of the pour's own net's copper on the layer: a piece of fill meeting none of them is an island. */
34
+ anchors: Paths;
35
+ }
36
+ /** A pad's relief: the pad grown by the gap, and its spokes, each with the point the fill must hold to keep it. */
37
+ export interface PadRelief {
38
+ cut: Path;
39
+ spokes: {
40
+ path: Path;
41
+ tip: IntPoint;
42
+ }[];
43
+ }
44
+ /** Everything the pour meets on its layer, from the inputs and the fills of the pours that come before it. */
45
+ export declare function layerCopper(pour: CopperPour, inputs: PourInputs, earlier: readonly EarlierFill[]): LayerCopper;
@@ -0,0 +1,85 @@
1
+ import { padShape } from "../checks/geometry.js";
2
+ import { viaSpan } from "../copper.js";
3
+ import { requiredClearance } from "../rules/classes.js";
4
+ import { counterClockwise, offset, toPath, union } from "./clip.js";
5
+ import { shapeOutline } from "./shapes.js";
6
+ import { thermalRelief } from "./thermal.js";
7
+ /**
8
+ * How much further than the clearance obstacles are grown, in mm: rounding to 1 µm and a round offset's sides
9
+ * (within 2 µm of the true arc) never bring the fill closer than the clearance.
10
+ */
11
+ const MARGIN = 0.003;
12
+ /**
13
+ * How much further than the clearance an earlier fill is grown, in mm: 10 µm. Both outlines are arcs drawn as chords
14
+ * (each up to 2 µm inside the true arc) and rounded to 1 µm, and a fill's sliver between two arcs can sit nearer
15
+ * still; 10 µm dominates all of it, so two fills always end at least the clearance apart.
16
+ */
17
+ const FILL_MARGIN = 0.01;
18
+ /** How far the pour's own copper is grown to find the pieces it touches, in mm: 1 µm, so meeting at an edge counts. */
19
+ const TOUCH = 0.001;
20
+ const padOnLayer = (pad, layer) => pad.layers === "through" || pad.layers === layer;
21
+ function trackShapes(track) {
22
+ const radius = track.width / 2;
23
+ if (track.points.length < 2)
24
+ return track.points.map((p) => ({ core: [p], radius }));
25
+ return track.points.slice(1).map((p, i) => ({ core: [track.points[i], p], radius }));
26
+ }
27
+ /** The gap the pour keeps to copper of another class: the pour's own clearance when larger than the rules'. */
28
+ function gapTo(pour, inputs, net) {
29
+ const required = requiredClearance(inputs.rules, inputs.classOf(pour.net), inputs.classOf(net));
30
+ return Math.max(pour.clearance ?? 0, required);
31
+ }
32
+ /** The tracks and vias on the pour's layer (copper on a layer the board lacks joins nothing and is left out). */
33
+ function layerItems(pour, inputs) {
34
+ const tracks = inputs.tracks.filter((track) => track.missingLayer === undefined && track.layer === pour.layer);
35
+ const vias = inputs.vias.filter((via) => via.missingLayer === undefined && viaSpan(via).has(pour.layer));
36
+ return { tracks, vias };
37
+ }
38
+ /** Other nets' pads, tracks and vias on the layer, each grown by the clearance: one simple outline apiece. */
39
+ function otherNets(pour, inputs) {
40
+ const grown = (shape, net) => toPath(shapeOutline(shape, gapTo(pour, inputs, net) + MARGIN));
41
+ const { tracks, vias } = layerItems(pour, inputs);
42
+ const pads = inputs.pads.filter((pad) => padOnLayer(pad, pour.layer) && pad.net !== pour.net);
43
+ return [
44
+ ...pads.flatMap((pad) => {
45
+ const shape = padShape(pad);
46
+ return shape === undefined ? [] : [grown(shape, pad.net)];
47
+ }),
48
+ ...tracks.filter((track) => track.net !== pour.net).flatMap((track) => trackShapes(track).map((shape) => grown(shape, track.net))),
49
+ ...vias.filter((via) => via.net !== pour.net).map((via) => grown({ core: [via.at], radius: via.diameter / 2 }, via.net)),
50
+ ];
51
+ }
52
+ /** The earlier fills of other nets on the layer grown by the clearance; each comes out of the offset with its holes. */
53
+ function earlierFills(pour, inputs, earlier) {
54
+ const fills = earlier.filter((fill) => fill.layer === pour.layer && fill.net !== pour.net);
55
+ return fills.flatMap((fill) => offset(fill.paths, gapTo(pour, inputs, fill.net) + FILL_MARGIN, "round"));
56
+ }
57
+ function boardObstacles(pour, inputs) {
58
+ const edge = inputs.rules.fabrication.boardEdgeClearance;
59
+ const keepouts = inputs.board.keepouts.filter((keepout) => keepout.layers === "all" || keepout.layers === pour.layer);
60
+ const holes = (inputs.board.holes ?? []).map((hole) => shapeOutline({ core: [{ x: hole.x, y: hole.y }], radius: hole.diameter / 2 }, edge + MARGIN));
61
+ return [...keepouts.map((keepout) => toPath(keepout.outline)), ...holes.map(toPath)];
62
+ }
63
+ function ownNet(pour, inputs) {
64
+ const pads = inputs.pads.filter((pad) => padOnLayer(pad, pour.layer) && pad.net === pour.net);
65
+ const { tracks, vias } = layerItems(pour, inputs);
66
+ const shapes = [
67
+ ...pads.flatMap((pad) => padShape(pad) ?? []),
68
+ ...tracks.filter((track) => track.net === pour.net).flatMap(trackShapes),
69
+ ...vias.filter((via) => via.net === pour.net).map((via) => ({ core: [via.at], radius: via.diameter / 2 })),
70
+ ];
71
+ const reliefs = pour.thermal === "relief" ? pads.flatMap((pad) => thermalRelief(pad, pour.thermalGap, pour.thermalWidth) ?? []) : [];
72
+ return {
73
+ reliefs: reliefs.map((relief) => ({
74
+ cut: toPath(relief.cut),
75
+ spokes: relief.spokes.map((spoke, i) => ({ path: toPath(spoke), tip: toPath([relief.tips[i]])[0] })),
76
+ })),
77
+ anchors: shapes.map((shape) => toPath(shapeOutline(shape, TOUCH))).filter((path) => path.length >= 3),
78
+ };
79
+ }
80
+ /** Everything the pour meets on its layer, from the inputs and the fills of the pours that come before it. */
81
+ export function layerCopper(pour, inputs, earlier) {
82
+ const outlines = [...otherNets(pour, inputs), ...boardObstacles(pour, inputs)].map(counterClockwise);
83
+ return { obstacles: union([...outlines, ...earlierFills(pour, inputs, earlier)]), ...ownNet(pour, inputs) };
84
+ }
85
+ //# sourceMappingURL=obstacles.js.map