copperflow 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +265 -2
- package/dist/app/THIRD_PARTY_LICENSES.txt +118 -0
- package/dist/app/assets/NewPartDialog-Qb7NwhBb.js +160 -0
- package/dist/app/assets/index-CSWIIMFE.css +1 -0
- package/dist/app/assets/index-C_TXwo-N.js +19 -0
- package/dist/app/index.html +15 -0
- package/dist/app/theme-boot.js +3 -0
- package/dist/cli-commands.d.ts +14 -0
- package/dist/cli-commands.js +285 -0
- package/dist/cli-commands.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +24 -0
- package/dist/cli.js.map +1 -0
- package/dist/core/analyze.d.ts +29 -0
- package/dist/core/analyze.js +284 -0
- package/dist/core/analyze.js.map +1 -0
- package/dist/core/annotations.d.ts +77 -0
- package/dist/core/annotations.js +138 -0
- package/dist/core/annotations.js.map +1 -0
- package/dist/core/board-edits.d.ts +8 -0
- package/dist/core/board-edits.js +56 -0
- package/dist/core/board-edits.js.map +1 -0
- package/dist/core/board-items.d.ts +40 -0
- package/dist/core/board-items.js +95 -0
- package/dist/core/board-items.js.map +1 -0
- package/dist/core/bom.d.ts +35 -0
- package/dist/core/bom.js +146 -0
- package/dist/core/bom.js.map +1 -0
- package/dist/core/check.d.ts +42 -0
- package/dist/core/check.js +91 -0
- package/dist/core/check.js.map +1 -0
- package/dist/core/checks-line.d.ts +7 -0
- package/dist/core/checks-line.js +8 -0
- package/dist/core/checks-line.js.map +1 -0
- package/dist/core/connection-names.d.ts +2 -0
- package/dist/core/connection-names.js +16 -0
- package/dist/core/connection-names.js.map +1 -0
- package/dist/core/design-source.d.ts +6 -0
- package/dist/core/design-source.js +14 -0
- package/dist/core/design-source.js.map +1 -0
- package/dist/core/drawing-edits.d.ts +19 -0
- package/dist/core/drawing-edits.js +158 -0
- package/dist/core/drawing-edits.js.map +1 -0
- package/dist/core/drawing-identity.d.ts +12 -0
- package/dist/core/drawing-identity.js +32 -0
- package/dist/core/drawing-identity.js.map +1 -0
- package/dist/core/drawing-names.d.ts +10 -0
- package/dist/core/drawing-names.js +30 -0
- package/dist/core/drawing-names.js.map +1 -0
- package/dist/core/drawing-scan.d.ts +41 -0
- package/dist/core/drawing-scan.js +82 -0
- package/dist/core/drawing-scan.js.map +1 -0
- package/dist/core/edit-error.d.ts +5 -0
- package/dist/core/edit-error.js +9 -0
- package/dist/core/edit-error.js.map +1 -0
- package/dist/core/edit-text.d.ts +28 -0
- package/dist/core/edit-text.js +89 -0
- package/dist/core/edit-text.js.map +1 -0
- package/dist/core/edit.d.ts +13 -0
- package/dist/core/edit.js +341 -0
- package/dist/core/edit.js.map +1 -0
- package/dist/core/fabrication.d.ts +39 -0
- package/dist/core/fabrication.js +94 -0
- package/dist/core/fabrication.js.map +1 -0
- package/dist/core/file-writes.d.ts +18 -0
- package/dist/core/file-writes.js +81 -0
- package/dist/core/file-writes.js.map +1 -0
- package/dist/core/fs-utils.d.ts +13 -0
- package/dist/core/fs-utils.js +51 -0
- package/dist/core/fs-utils.js.map +1 -0
- package/dist/core/history.d.ts +80 -0
- package/dist/core/history.js +161 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/index.d.ts +21 -0
- package/dist/core/index.js +22 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/instance-edits.d.ts +15 -0
- package/dist/core/instance-edits.js +69 -0
- package/dist/core/instance-edits.js.map +1 -0
- package/dist/core/instance-locks.d.ts +10 -0
- package/dist/core/instance-locks.js +16 -0
- package/dist/core/instance-locks.js.map +1 -0
- package/dist/core/instance-requests.d.ts +45 -0
- package/dist/core/instance-requests.js +93 -0
- package/dist/core/instance-requests.js.map +1 -0
- package/dist/core/layout-edits.d.ts +51 -0
- package/dist/core/layout-edits.js +82 -0
- package/dist/core/layout-edits.js.map +1 -0
- package/dist/core/layout-file.d.ts +80 -0
- package/dist/core/layout-file.js +209 -0
- package/dist/core/layout-file.js.map +1 -0
- package/dist/core/layout-locks.d.ts +38 -0
- package/dist/core/layout-locks.js +39 -0
- package/dist/core/layout-locks.js.map +1 -0
- package/dist/core/layout-records.d.ts +72 -0
- package/dist/core/layout-records.js +146 -0
- package/dist/core/layout-records.js.map +1 -0
- package/dist/core/library.d.ts +128 -0
- package/dist/core/library.js +378 -0
- package/dist/core/library.js.map +1 -0
- package/dist/core/literals.d.ts +19 -0
- package/dist/core/literals.js +106 -0
- package/dist/core/literals.js.map +1 -0
- package/dist/core/make-sheet.d.ts +44 -0
- package/dist/core/make-sheet.js +130 -0
- package/dist/core/make-sheet.js.map +1 -0
- package/dist/core/netlist.d.ts +41 -0
- package/dist/core/netlist.js +147 -0
- package/dist/core/netlist.js.map +1 -0
- package/dist/core/new-circuit-sheets.d.ts +35 -0
- package/dist/core/new-circuit-sheets.js +146 -0
- package/dist/core/new-circuit-sheets.js.map +1 -0
- package/dist/core/new-circuit.d.ts +65 -0
- package/dist/core/new-circuit.js +83 -0
- package/dist/core/new-circuit.js.map +1 -0
- package/dist/core/page-edits.d.ts +25 -0
- package/dist/core/page-edits.js +180 -0
- package/dist/core/page-edits.js.map +1 -0
- package/dist/core/pin-types.d.ts +8 -0
- package/dist/core/pin-types.js +10 -0
- package/dist/core/pin-types.js.map +1 -0
- package/dist/core/place.d.ts +30 -0
- package/dist/core/place.js +77 -0
- package/dist/core/place.js.map +1 -0
- package/dist/core/placement-write.d.ts +56 -0
- package/dist/core/placement-write.js +222 -0
- package/dist/core/placement-write.js.map +1 -0
- package/dist/core/pour-edits.d.ts +20 -0
- package/dist/core/pour-edits.js +241 -0
- package/dist/core/pour-edits.js.map +1 -0
- package/dist/core/project-text.d.ts +15 -0
- package/dist/core/project-text.js +58 -0
- package/dist/core/project-text.js.map +1 -0
- package/dist/core/project.d.ts +23 -0
- package/dist/core/project.js +63 -0
- package/dist/core/project.js.map +1 -0
- package/dist/core/rename-designators.d.ts +23 -0
- package/dist/core/rename-designators.js +83 -0
- package/dist/core/rename-designators.js.map +1 -0
- package/dist/core/rename-parts.d.ts +12 -0
- package/dist/core/rename-parts.js +129 -0
- package/dist/core/rename-parts.js.map +1 -0
- package/dist/core/rules-edit.d.ts +7 -0
- package/dist/core/rules-edit.js +56 -0
- package/dist/core/rules-edit.js.map +1 -0
- package/dist/core/selectors.d.ts +11 -0
- package/dist/core/selectors.js +33 -0
- package/dist/core/selectors.js.map +1 -0
- package/dist/core/sheet-cut-layout.d.ts +13 -0
- package/dist/core/sheet-cut-layout.js +62 -0
- package/dist/core/sheet-cut-layout.js.map +1 -0
- package/dist/core/sheet-cut-text.d.ts +23 -0
- package/dist/core/sheet-cut-text.js +129 -0
- package/dist/core/sheet-cut-text.js.map +1 -0
- package/dist/core/sheet-cut.d.ts +55 -0
- package/dist/core/sheet-cut.js +204 -0
- package/dist/core/sheet-cut.js.map +1 -0
- package/dist/core/sheet-edits.d.ts +12 -0
- package/dist/core/sheet-edits.js +107 -0
- package/dist/core/sheet-edits.js.map +1 -0
- package/dist/core/sheet-files.d.ts +31 -0
- package/dist/core/sheet-files.js +134 -0
- package/dist/core/sheet-files.js.map +1 -0
- package/dist/core/sheet-layout.d.ts +27 -0
- package/dist/core/sheet-layout.js +60 -0
- package/dist/core/sheet-layout.js.map +1 -0
- package/dist/core/summary.d.ts +10 -0
- package/dist/core/summary.js +79 -0
- package/dist/core/summary.js.map +1 -0
- package/dist/core/track-split.d.ts +22 -0
- package/dist/core/track-split.js +24 -0
- package/dist/core/track-split.js.map +1 -0
- package/dist/core/types.d.ts +309 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/unroute.d.ts +56 -0
- package/dist/core/unroute.js +87 -0
- package/dist/core/unroute.js.map +1 -0
- package/dist/core/workspace.d.ts +94 -0
- package/dist/core/workspace.js +376 -0
- package/dist/core/workspace.js.map +1 -0
- package/dist/engine/autoplace.d.ts +18 -0
- package/dist/engine/autoplace.js +68 -0
- package/dist/engine/autoplace.js.map +1 -0
- package/dist/engine/board.d.ts +12 -0
- package/dist/engine/board.js +60 -0
- package/dist/engine/board.js.map +1 -0
- package/dist/engine/checks/copper-clearance.d.ts +7 -0
- package/dist/engine/checks/copper-clearance.js +116 -0
- package/dist/engine/checks/copper-clearance.js.map +1 -0
- package/dist/engine/checks/copper-notes.d.ts +11 -0
- package/dist/engine/checks/copper-notes.js +17 -0
- package/dist/engine/checks/copper-notes.js.map +1 -0
- package/dist/engine/checks/copper-pieces.d.ts +26 -0
- package/dist/engine/checks/copper-pieces.js +42 -0
- package/dist/engine/checks/copper-pieces.js.map +1 -0
- package/dist/engine/checks/copper-violation.d.ts +9 -0
- package/dist/engine/checks/copper-violation.js +11 -0
- package/dist/engine/checks/copper-violation.js.map +1 -0
- package/dist/engine/checks/drc-copper.d.ts +14 -0
- package/dist/engine/checks/drc-copper.js +139 -0
- package/dist/engine/checks/drc-copper.js.map +1 -0
- package/dist/engine/checks/drc-pads.d.ts +8 -0
- package/dist/engine/checks/drc-pads.js +172 -0
- package/dist/engine/checks/drc-pads.js.map +1 -0
- package/dist/engine/checks/drc-parts.d.ts +5 -0
- package/dist/engine/checks/drc-parts.js +208 -0
- package/dist/engine/checks/drc-parts.js.map +1 -0
- package/dist/engine/checks/drc-pours.d.ts +6 -0
- package/dist/engine/checks/drc-pours.js +240 -0
- package/dist/engine/checks/drc-pours.js.map +1 -0
- package/dist/engine/checks/erc.d.ts +6 -0
- package/dist/engine/checks/erc.js +94 -0
- package/dist/engine/checks/erc.js.map +1 -0
- package/dist/engine/checks/fillet-guard.d.ts +29 -0
- package/dist/engine/checks/fillet-guard.js +75 -0
- package/dist/engine/checks/fillet-guard.js.map +1 -0
- package/dist/engine/checks/geometry.d.ts +25 -0
- package/dist/engine/checks/geometry.js +182 -0
- package/dist/engine/checks/geometry.js.map +1 -0
- package/dist/engine/checks/grid-index.d.ts +24 -0
- package/dist/engine/checks/grid-index.js +57 -0
- package/dist/engine/checks/grid-index.js.map +1 -0
- package/dist/engine/checks/index.d.ts +16 -0
- package/dist/engine/checks/index.js +55 -0
- package/dist/engine/checks/index.js.map +1 -0
- package/dist/engine/checks/limits.d.ts +7 -0
- package/dist/engine/checks/limits.js +10 -0
- package/dist/engine/checks/limits.js.map +1 -0
- package/dist/engine/checks/unplaced-parts.d.ts +4 -0
- package/dist/engine/checks/unplaced-parts.js +29 -0
- package/dist/engine/checks/unplaced-parts.js.map +1 -0
- package/dist/engine/checks/violation.d.ts +14 -0
- package/dist/engine/checks/violation.js +7 -0
- package/dist/engine/checks/violation.js.map +1 -0
- package/dist/engine/component.d.ts +34 -0
- package/dist/engine/component.js +125 -0
- package/dist/engine/component.js.map +1 -0
- package/dist/engine/copper.d.ts +63 -0
- package/dist/engine/copper.js +276 -0
- package/dist/engine/copper.js.map +1 -0
- package/dist/engine/design.d.ts +21 -0
- package/dist/engine/design.js +63 -0
- package/dist/engine/design.js.map +1 -0
- package/dist/engine/diagnostics.d.ts +2 -0
- package/dist/engine/diagnostics.js +6 -0
- package/dist/engine/diagnostics.js.map +1 -0
- package/dist/engine/drawing-ids.d.ts +23 -0
- package/dist/engine/drawing-ids.js +45 -0
- package/dist/engine/drawing-ids.js.map +1 -0
- package/dist/engine/drawing-kinds.d.ts +18 -0
- package/dist/engine/drawing-kinds.js +102 -0
- package/dist/engine/drawing-kinds.js.map +1 -0
- package/dist/engine/drawing-reader.d.ts +42 -0
- package/dist/engine/drawing-reader.js +97 -0
- package/dist/engine/drawing-reader.js.map +1 -0
- package/dist/engine/drawings.d.ts +35 -0
- package/dist/engine/drawings.js +94 -0
- package/dist/engine/drawings.js.map +1 -0
- package/dist/engine/elaborate.d.ts +8 -0
- package/dist/engine/elaborate.js +490 -0
- package/dist/engine/elaborate.js.map +1 -0
- package/dist/engine/engine-worker.d.ts +1 -0
- package/dist/engine/engine-worker.js +17 -0
- package/dist/engine/engine-worker.js.map +1 -0
- package/dist/engine/engine.d.ts +41 -0
- package/dist/engine/engine.js +95 -0
- package/dist/engine/engine.js.map +1 -0
- package/dist/engine/evaluate.d.ts +10 -0
- package/dist/engine/evaluate.js +125 -0
- package/dist/engine/evaluate.js.map +1 -0
- package/dist/engine/fab/bom-csv.d.ts +5 -0
- package/dist/engine/fab/bom-csv.js +16 -0
- package/dist/engine/fab/bom-csv.js.map +1 -0
- package/dist/engine/fab/csv.d.ts +4 -0
- package/dist/engine/fab/csv.js +11 -0
- package/dist/engine/fab/csv.js.map +1 -0
- package/dist/engine/fab/designators.d.ts +42 -0
- package/dist/engine/fab/designators.js +109 -0
- package/dist/engine/fab/designators.js.map +1 -0
- package/dist/engine/fab/excellon.d.ts +23 -0
- package/dist/engine/fab/excellon.js +82 -0
- package/dist/engine/fab/excellon.js.map +1 -0
- package/dist/engine/fab/export.d.ts +33 -0
- package/dist/engine/fab/export.js +105 -0
- package/dist/engine/fab/export.js.map +1 -0
- package/dist/engine/fab/gerber.d.ts +53 -0
- package/dist/engine/fab/gerber.js +151 -0
- package/dist/engine/fab/gerber.js.map +1 -0
- package/dist/engine/fab/layers.d.ts +26 -0
- package/dist/engine/fab/layers.js +162 -0
- package/dist/engine/fab/layers.js.map +1 -0
- package/dist/engine/fab/names.d.ts +20 -0
- package/dist/engine/fab/names.js +58 -0
- package/dist/engine/fab/names.js.map +1 -0
- package/dist/engine/fab/pick-and-place.d.ts +5 -0
- package/dist/engine/fab/pick-and-place.js +36 -0
- package/dist/engine/fab/pick-and-place.js.map +1 -0
- package/dist/engine/fab/stroke-font.d.ts +8 -0
- package/dist/engine/fab/stroke-font.js +83 -0
- package/dist/engine/fab/stroke-font.js.map +1 -0
- package/dist/engine/fab/zip.d.ts +14 -0
- package/dist/engine/fab/zip.js +93 -0
- package/dist/engine/fab/zip.js.map +1 -0
- package/dist/engine/fillet-plan.d.ts +39 -0
- package/dist/engine/fillet-plan.js +87 -0
- package/dist/engine/fillet-plan.js.map +1 -0
- package/dist/engine/fillet.d.ts +54 -0
- package/dist/engine/fillet.js +175 -0
- package/dist/engine/fillet.js.map +1 -0
- package/dist/engine/footprints/bga.d.ts +14 -0
- package/dist/engine/footprints/bga.js +122 -0
- package/dist/engine/footprints/bga.js.map +1 -0
- package/dist/engine/footprints/chip.d.ts +3 -0
- package/dist/engine/footprints/chip.js +52 -0
- package/dist/engine/footprints/chip.js.map +1 -0
- package/dist/engine/footprints/crystal.d.ts +4 -0
- package/dist/engine/footprints/crystal.js +47 -0
- package/dist/engine/footprints/crystal.js.map +1 -0
- package/dist/engine/footprints/dfn.d.ts +13 -0
- package/dist/engine/footprints/dfn.js +52 -0
- package/dist/engine/footprints/dfn.js.map +1 -0
- package/dist/engine/footprints/dip.d.ts +8 -0
- package/dist/engine/footprints/dip.js +65 -0
- package/dist/engine/footprints/dip.js.map +1 -0
- package/dist/engine/footprints/dual.d.ts +14 -0
- package/dist/engine/footprints/dual.js +171 -0
- package/dist/engine/footprints/dual.js.map +1 -0
- package/dist/engine/footprints/exposed.d.ts +27 -0
- package/dist/engine/footprints/exposed.js +50 -0
- package/dist/engine/footprints/exposed.js.map +1 -0
- package/dist/engine/footprints/file.d.ts +65 -0
- package/dist/engine/footprints/file.js +141 -0
- package/dist/engine/footprints/file.js.map +1 -0
- package/dist/engine/footprints/ic.d.ts +34 -0
- package/dist/engine/footprints/ic.js +31 -0
- package/dist/engine/footprints/ic.js.map +1 -0
- package/dist/engine/footprints/index.d.ts +17 -0
- package/dist/engine/footprints/index.js +104 -0
- package/dist/engine/footprints/index.js.map +1 -0
- package/dist/engine/footprints/ipc7251.d.ts +30 -0
- package/dist/engine/footprints/ipc7251.js +44 -0
- package/dist/engine/footprints/ipc7251.js.map +1 -0
- package/dist/engine/footprints/ipc7351.d.ts +179 -0
- package/dist/engine/footprints/ipc7351.js +194 -0
- package/dist/engine/footprints/ipc7351.js.map +1 -0
- package/dist/engine/footprints/jedec.d.ts +24 -0
- package/dist/engine/footprints/jedec.js +148 -0
- package/dist/engine/footprints/jedec.js.map +1 -0
- package/dist/engine/footprints/known.d.ts +6 -0
- package/dist/engine/footprints/known.js +76 -0
- package/dist/engine/footprints/known.js.map +1 -0
- package/dist/engine/footprints/molded.d.ts +8 -0
- package/dist/engine/footprints/molded.js +76 -0
- package/dist/engine/footprints/molded.js.map +1 -0
- package/dist/engine/footprints/outline.d.ts +64 -0
- package/dist/engine/footprints/outline.js +187 -0
- package/dist/engine/footprints/outline.js.map +1 -0
- package/dist/engine/footprints/parse.d.ts +32 -0
- package/dist/engine/footprints/parse.js +68 -0
- package/dist/engine/footprints/parse.js.map +1 -0
- package/dist/engine/footprints/pinrow.d.ts +11 -0
- package/dist/engine/footprints/pinrow.js +102 -0
- package/dist/engine/footprints/pinrow.js.map +1 -0
- package/dist/engine/footprints/quad.d.ts +7 -0
- package/dist/engine/footprints/quad.js +135 -0
- package/dist/engine/footprints/quad.js.map +1 -0
- package/dist/engine/footprints/radial.d.ts +7 -0
- package/dist/engine/footprints/radial.js +62 -0
- package/dist/engine/footprints/radial.js.map +1 -0
- package/dist/engine/footprints/sod.d.ts +8 -0
- package/dist/engine/footprints/sod.js +60 -0
- package/dist/engine/footprints/sod.js.map +1 -0
- package/dist/engine/footprints/sot.d.ts +4 -0
- package/dist/engine/footprints/sot.js +72 -0
- package/dist/engine/footprints/sot.js.map +1 -0
- package/dist/engine/footprints/sotpower.d.ts +4 -0
- package/dist/engine/footprints/sotpower.js +98 -0
- package/dist/engine/footprints/sotpower.js.map +1 -0
- package/dist/engine/footprints/to220.d.ts +4 -0
- package/dist/engine/footprints/to220.js +49 -0
- package/dist/engine/footprints/to220.js.map +1 -0
- package/dist/engine/footprints/to92.d.ts +4 -0
- package/dist/engine/footprints/to92.js +43 -0
- package/dist/engine/footprints/to92.js.map +1 -0
- package/dist/engine/footprints/types.d.ts +50 -0
- package/dist/engine/footprints/types.js +3 -0
- package/dist/engine/footprints/types.js.map +1 -0
- package/dist/engine/hole.d.ts +15 -0
- package/dist/engine/hole.js +28 -0
- package/dist/engine/hole.js.map +1 -0
- package/dist/engine/index.d.ts +6 -0
- package/dist/engine/index.js +6 -0
- package/dist/engine/index.js.map +1 -0
- package/dist/engine/instance-anchor.d.ts +16 -0
- package/dist/engine/instance-anchor.js +45 -0
- package/dist/engine/instance-anchor.js.map +1 -0
- package/dist/engine/jsx-runtime.d.ts +26 -0
- package/dist/engine/jsx-runtime.js +49 -0
- package/dist/engine/jsx-runtime.js.map +1 -0
- package/dist/engine/keepout.d.ts +9 -0
- package/dist/engine/keepout.js +50 -0
- package/dist/engine/keepout.js.map +1 -0
- package/dist/engine/kinds.d.ts +34 -0
- package/dist/engine/kinds.js +134 -0
- package/dist/engine/kinds.js.map +1 -0
- package/dist/engine/model.d.ts +310 -0
- package/dist/engine/model.js +5 -0
- package/dist/engine/model.js.map +1 -0
- package/dist/engine/nets.d.ts +6 -0
- package/dist/engine/nets.js +49 -0
- package/dist/engine/nets.js.map +1 -0
- package/dist/engine/no-connect.d.ts +28 -0
- package/dist/engine/no-connect.js +36 -0
- package/dist/engine/no-connect.js.map +1 -0
- package/dist/engine/order.d.ts +7 -0
- package/dist/engine/order.js +25 -0
- package/dist/engine/order.js.map +1 -0
- package/dist/engine/pad-text.d.ts +20 -0
- package/dist/engine/pad-text.js +26 -0
- package/dist/engine/pad-text.js.map +1 -0
- package/dist/engine/part-labels.d.ts +29 -0
- package/dist/engine/part-labels.js +28 -0
- package/dist/engine/part-labels.js.map +1 -0
- package/dist/engine/pcb-place/blocks.d.ts +46 -0
- package/dist/engine/pcb-place/blocks.js +186 -0
- package/dist/engine/pcb-place/blocks.js.map +1 -0
- package/dist/engine/pcb-place/constructive.d.ts +73 -0
- package/dist/engine/pcb-place/constructive.js +515 -0
- package/dist/engine/pcb-place/constructive.js.map +1 -0
- package/dist/engine/pcb-place/edge.d.ts +7 -0
- package/dist/engine/pcb-place/edge.js +78 -0
- package/dist/engine/pcb-place/edge.js.map +1 -0
- package/dist/engine/pcb-place/fit-board.d.ts +22 -0
- package/dist/engine/pcb-place/fit-board.js +48 -0
- package/dist/engine/pcb-place/fit-board.js.map +1 -0
- package/dist/engine/pcb-place/geometry.d.ts +45 -0
- package/dist/engine/pcb-place/geometry.js +158 -0
- package/dist/engine/pcb-place/geometry.js.map +1 -0
- package/dist/engine/pcb-place/index.d.ts +81 -0
- package/dist/engine/pcb-place/index.js +98 -0
- package/dist/engine/pcb-place/index.js.map +1 -0
- package/dist/engine/pcb-place/refine.d.ts +32 -0
- package/dist/engine/pcb-place/refine.js +220 -0
- package/dist/engine/pcb-place/refine.js.map +1 -0
- package/dist/engine/pcb-place/roles.d.ts +37 -0
- package/dist/engine/pcb-place/roles.js +127 -0
- package/dist/engine/pcb-place/roles.js.map +1 -0
- package/dist/engine/pcb-place/scope.d.ts +80 -0
- package/dist/engine/pcb-place/scope.js +107 -0
- package/dist/engine/pcb-place/scope.js.map +1 -0
- package/dist/engine/pcb-place/score.d.ts +40 -0
- package/dist/engine/pcb-place/score.js +140 -0
- package/dist/engine/pcb-place/score.js.map +1 -0
- package/dist/engine/pcb.d.ts +72 -0
- package/dist/engine/pcb.js +153 -0
- package/dist/engine/pcb.js.map +1 -0
- package/dist/engine/pour/build.d.ts +32 -0
- package/dist/engine/pour/build.js +108 -0
- package/dist/engine/pour/build.js.map +1 -0
- package/dist/engine/pour/cache.d.ts +8 -0
- package/dist/engine/pour/cache.js +55 -0
- package/dist/engine/pour/cache.js.map +1 -0
- package/dist/engine/pour/clip.d.ts +50 -0
- package/dist/engine/pour/clip.js +72 -0
- package/dist/engine/pour/clip.js.map +1 -0
- package/dist/engine/pour/fill.d.ts +22 -0
- package/dist/engine/pour/fill.js +112 -0
- package/dist/engine/pour/fill.js.map +1 -0
- package/dist/engine/pour/islands.d.ts +8 -0
- package/dist/engine/pour/islands.js +19 -0
- package/dist/engine/pour/islands.js.map +1 -0
- package/dist/engine/pour/joins.d.ts +18 -0
- package/dist/engine/pour/joins.js +74 -0
- package/dist/engine/pour/joins.js.map +1 -0
- package/dist/engine/pour/obstacles.d.ts +45 -0
- package/dist/engine/pour/obstacles.js +85 -0
- package/dist/engine/pour/obstacles.js.map +1 -0
- package/dist/engine/pour/resolve.d.ts +21 -0
- package/dist/engine/pour/resolve.js +19 -0
- package/dist/engine/pour/resolve.js.map +1 -0
- package/dist/engine/pour/shapes.d.ts +9 -0
- package/dist/engine/pour/shapes.js +62 -0
- package/dist/engine/pour/shapes.js.map +1 -0
- package/dist/engine/pour/thermal.d.ts +16 -0
- package/dist/engine/pour/thermal.js +38 -0
- package/dist/engine/pour/thermal.js.map +1 -0
- package/dist/engine/project-files.d.ts +18 -0
- package/dist/engine/project-files.js +58 -0
- package/dist/engine/project-files.js.map +1 -0
- package/dist/engine/ratsnest.d.ts +16 -0
- package/dist/engine/ratsnest.js +69 -0
- package/dist/engine/ratsnest.js.map +1 -0
- package/dist/engine/read-props.d.ts +22 -0
- package/dist/engine/read-props.js +74 -0
- package/dist/engine/read-props.js.map +1 -0
- package/dist/engine/router/astar.d.ts +74 -0
- package/dist/engine/router/astar.js +231 -0
- package/dist/engine/router/astar.js.map +1 -0
- package/dist/engine/router/blockers.d.ts +4 -0
- package/dist/engine/router/blockers.js +69 -0
- package/dist/engine/router/blockers.js.map +1 -0
- package/dist/engine/router/cleanup.d.ts +21 -0
- package/dist/engine/router/cleanup.js +157 -0
- package/dist/engine/router/cleanup.js.map +1 -0
- package/dist/engine/router/clear.d.ts +18 -0
- package/dist/engine/router/clear.js +39 -0
- package/dist/engine/router/clear.js.map +1 -0
- package/dist/engine/router/congestion.d.ts +79 -0
- package/dist/engine/router/congestion.js +212 -0
- package/dist/engine/router/congestion.js.map +1 -0
- package/dist/engine/router/connect.d.ts +79 -0
- package/dist/engine/router/connect.js +174 -0
- package/dist/engine/router/connect.js.map +1 -0
- package/dist/engine/router/ends.d.ts +25 -0
- package/dist/engine/router/ends.js +135 -0
- package/dist/engine/router/ends.js.map +1 -0
- package/dist/engine/router/grid.d.ts +131 -0
- package/dist/engine/router/grid.js +297 -0
- package/dist/engine/router/grid.js.map +1 -0
- package/dist/engine/router/keep-clear.d.ts +10 -0
- package/dist/engine/router/keep-clear.js +60 -0
- package/dist/engine/router/keep-clear.js.map +1 -0
- package/dist/engine/router/obstacles.d.ts +18 -0
- package/dist/engine/router/obstacles.js +66 -0
- package/dist/engine/router/obstacles.js.map +1 -0
- package/dist/engine/router/path.d.ts +34 -0
- package/dist/engine/router/path.js +41 -0
- package/dist/engine/router/path.js.map +1 -0
- package/dist/engine/router/pour-rounds.d.ts +17 -0
- package/dist/engine/router/pour-rounds.js +124 -0
- package/dist/engine/router/pour-rounds.js.map +1 -0
- package/dist/engine/router/replicate.d.ts +32 -0
- package/dist/engine/router/replicate.js +143 -0
- package/dist/engine/router/replicate.js.map +1 -0
- package/dist/engine/router/rip-up.d.ts +5 -0
- package/dist/engine/router/rip-up.js +95 -0
- package/dist/engine/router/rip-up.js.map +1 -0
- package/dist/engine/router/route-board.d.ts +109 -0
- package/dist/engine/router/route-board.js +223 -0
- package/dist/engine/router/route-board.js.map +1 -0
- package/dist/engine/rules/classes.d.ts +14 -0
- package/dist/engine/rules/classes.js +50 -0
- package/dist/engine/rules/classes.js.map +1 -0
- package/dist/engine/rules/load.d.ts +14 -0
- package/dist/engine/rules/load.js +146 -0
- package/dist/engine/rules/load.js.map +1 -0
- package/dist/engine/rules/profiles.d.ts +5 -0
- package/dist/engine/rules/profiles.js +53 -0
- package/dist/engine/rules/profiles.js.map +1 -0
- package/dist/engine/rules/rotations.d.ts +31 -0
- package/dist/engine/rules/rotations.js +124 -0
- package/dist/engine/rules/rotations.js.map +1 -0
- package/dist/engine/rules/schema.d.ts +82 -0
- package/dist/engine/rules/schema.js +59 -0
- package/dist/engine/rules/schema.js.map +1 -0
- package/dist/engine/rules/track-defaults.d.ts +23 -0
- package/dist/engine/rules/track-defaults.js +26 -0
- package/dist/engine/rules/track-defaults.js.map +1 -0
- package/dist/engine/schematic-astar.d.ts +37 -0
- package/dist/engine/schematic-astar.js +202 -0
- package/dist/engine/schematic-astar.js.map +1 -0
- package/dist/engine/schematic-geometry.d.ts +23 -0
- package/dist/engine/schematic-geometry.js +49 -0
- package/dist/engine/schematic-geometry.js.map +1 -0
- package/dist/engine/schematic-grid.d.ts +60 -0
- package/dist/engine/schematic-grid.js +150 -0
- package/dist/engine/schematic-grid.js.map +1 -0
- package/dist/engine/schematic-nets.d.ts +38 -0
- package/dist/engine/schematic-nets.js +157 -0
- package/dist/engine/schematic-nets.js.map +1 -0
- package/dist/engine/schematic-pages.d.ts +9 -0
- package/dist/engine/schematic-pages.js +52 -0
- package/dist/engine/schematic-pages.js.map +1 -0
- package/dist/engine/schematic-place-chains.d.ts +22 -0
- package/dist/engine/schematic-place-chains.js +111 -0
- package/dist/engine/schematic-place-chains.js.map +1 -0
- package/dist/engine/schematic-place-plan.d.ts +43 -0
- package/dist/engine/schematic-place-plan.js +155 -0
- package/dist/engine/schematic-place-plan.js.map +1 -0
- package/dist/engine/schematic-place-units.d.ts +38 -0
- package/dist/engine/schematic-place-units.js +101 -0
- package/dist/engine/schematic-place-units.js.map +1 -0
- package/dist/engine/schematic-place.d.ts +5 -0
- package/dist/engine/schematic-place.js +268 -0
- package/dist/engine/schematic-place.js.map +1 -0
- package/dist/engine/schematic-route.d.ts +37 -0
- package/dist/engine/schematic-route.js +288 -0
- package/dist/engine/schematic-route.js.map +1 -0
- package/dist/engine/schematic-sheets.d.ts +22 -0
- package/dist/engine/schematic-sheets.js +104 -0
- package/dist/engine/schematic-sheets.js.map +1 -0
- package/dist/engine/schematic.d.ts +64 -0
- package/dist/engine/schematic.js +200 -0
- package/dist/engine/schematic.js.map +1 -0
- package/dist/engine/selectors.d.ts +25 -0
- package/dist/engine/selectors.js +28 -0
- package/dist/engine/selectors.js.map +1 -0
- package/dist/engine/sheet-ports.d.ts +44 -0
- package/dist/engine/sheet-ports.js +126 -0
- package/dist/engine/sheet-ports.js.map +1 -0
- package/dist/engine/sheet-symbol.d.ts +52 -0
- package/dist/engine/sheet-symbol.js +92 -0
- package/dist/engine/sheet-symbol.js.map +1 -0
- package/dist/engine/sheets.d.ts +79 -0
- package/dist/engine/sheets.js +159 -0
- package/dist/engine/sheets.js.map +1 -0
- package/dist/engine/symbols/box.d.ts +8 -0
- package/dist/engine/symbols/box.js +83 -0
- package/dist/engine/symbols/box.js.map +1 -0
- package/dist/engine/symbols/index.d.ts +8 -0
- package/dist/engine/symbols/index.js +58 -0
- package/dist/engine/symbols/index.js.map +1 -0
- package/dist/engine/symbols/passives.d.ts +16 -0
- package/dist/engine/symbols/passives.js +58 -0
- package/dist/engine/symbols/passives.js.map +1 -0
- package/dist/engine/symbols/power.d.ts +5 -0
- package/dist/engine/symbols/power.js +10 -0
- package/dist/engine/symbols/power.js.map +1 -0
- package/dist/engine/symbols/semis.d.ts +10 -0
- package/dist/engine/symbols/semis.js +62 -0
- package/dist/engine/symbols/semis.js.map +1 -0
- package/dist/engine/symbols/types.d.ts +83 -0
- package/dist/engine/symbols/types.js +61 -0
- package/dist/engine/symbols/types.js.map +1 -0
- package/dist/engine/traces.d.ts +29 -0
- package/dist/engine/traces.js +102 -0
- package/dist/engine/traces.js.map +1 -0
- package/dist/engine/units.d.ts +4 -0
- package/dist/engine/units.js +31 -0
- package/dist/engine/units.js.map +1 -0
- package/dist/engine/worker-env.d.ts +9 -0
- package/dist/engine/worker-env.js +12 -0
- package/dist/engine/worker-env.js.map +1 -0
- package/dist/library/attach-datasheet.d.ts +20 -0
- package/dist/library/attach-datasheet.js +61 -0
- package/dist/library/attach-datasheet.js.map +1 -0
- package/dist/library/easyeda-footprint.d.ts +41 -0
- package/dist/library/easyeda-footprint.js +255 -0
- package/dist/library/easyeda-footprint.js.map +1 -0
- package/dist/library/easyeda-path.d.ts +13 -0
- package/dist/library/easyeda-path.js +133 -0
- package/dist/library/easyeda-path.js.map +1 -0
- package/dist/library/easyeda-symbol.d.ts +20 -0
- package/dist/library/easyeda-symbol.js +53 -0
- package/dist/library/easyeda-symbol.js.map +1 -0
- package/dist/library/import-lcsc.d.ts +30 -0
- package/dist/library/import-lcsc.js +155 -0
- package/dist/library/import-lcsc.js.map +1 -0
- package/dist/library/lcsc-part.d.ts +40 -0
- package/dist/library/lcsc-part.js +153 -0
- package/dist/library/lcsc-part.js.map +1 -0
- package/dist/library/new-part.d.ts +50 -0
- package/dist/library/new-part.js +160 -0
- package/dist/library/new-part.js.map +1 -0
- package/dist/library/pin-table.d.ts +23 -0
- package/dist/library/pin-table.js +92 -0
- package/dist/library/pin-table.js.map +1 -0
- package/dist/mcp/batch.d.ts +111 -0
- package/dist/mcp/batch.js +241 -0
- package/dist/mcp/batch.js.map +1 -0
- package/dist/mcp/board-summary.d.ts +19 -0
- package/dist/mcp/board-summary.js +144 -0
- package/dist/mcp/board-summary.js.map +1 -0
- package/dist/mcp/compact-sheets.d.ts +31 -0
- package/dist/mcp/compact-sheets.js +63 -0
- package/dist/mcp/compact-sheets.js.map +1 -0
- package/dist/mcp/compact-tool-list.d.ts +8 -0
- package/dist/mcp/compact-tool-list.js +42 -0
- package/dist/mcp/compact-tool-list.js.map +1 -0
- package/dist/mcp/compact.d.ts +33 -0
- package/dist/mcp/compact.js +189 -0
- package/dist/mcp/compact.js.map +1 -0
- package/dist/mcp/copper-summary.d.ts +26 -0
- package/dist/mcp/copper-summary.js +122 -0
- package/dist/mcp/copper-summary.js.map +1 -0
- package/dist/mcp/copper-tools.d.ts +93 -0
- package/dist/mcp/copper-tools.js +228 -0
- package/dist/mcp/copper-tools.js.map +1 -0
- package/dist/mcp/copper-under.d.ts +16 -0
- package/dist/mcp/copper-under.js +46 -0
- package/dist/mcp/copper-under.js.map +1 -0
- package/dist/mcp/create-part.d.ts +71 -0
- package/dist/mcp/create-part.js +31 -0
- package/dist/mcp/create-part.js.map +1 -0
- package/dist/mcp/datasheet-tools.d.ts +14 -0
- package/dist/mcp/datasheet-tools.js +15 -0
- package/dist/mcp/datasheet-tools.js.map +1 -0
- package/dist/mcp/fillet-tools.d.ts +24 -0
- package/dist/mcp/fillet-tools.js +52 -0
- package/dist/mcp/fillet-tools.js.map +1 -0
- package/dist/mcp/guide.d.ts +37 -0
- package/dist/mcp/guide.js +78 -0
- package/dist/mcp/guide.js.map +1 -0
- package/dist/mcp/import-part.d.ts +13 -0
- package/dist/mcp/import-part.js +20 -0
- package/dist/mcp/import-part.js.map +1 -0
- package/dist/mcp/make-sheet.d.ts +18 -0
- package/dist/mcp/make-sheet.js +29 -0
- package/dist/mcp/make-sheet.js.map +1 -0
- package/dist/mcp/new-circuit.d.ts +77 -0
- package/dist/mcp/new-circuit.js +114 -0
- package/dist/mcp/new-circuit.js.map +1 -0
- package/dist/mcp/place-tools.d.ts +46 -0
- package/dist/mcp/place-tools.js +121 -0
- package/dist/mcp/place-tools.js.map +1 -0
- package/dist/mcp/pour-tools.d.ts +126 -0
- package/dist/mcp/pour-tools.js +105 -0
- package/dist/mcp/pour-tools.js.map +1 -0
- package/dist/mcp/project-tools.d.ts +36 -0
- package/dist/mcp/project-tools.js +115 -0
- package/dist/mcp/project-tools.js.map +1 -0
- package/dist/mcp/route-by-ref.d.ts +20 -0
- package/dist/mcp/route-by-ref.js +70 -0
- package/dist/mcp/route-by-ref.js.map +1 -0
- package/dist/mcp/route-tools.d.ts +54 -0
- package/dist/mcp/route-tools.js +173 -0
- package/dist/mcp/route-tools.js.map +1 -0
- package/dist/mcp/server.d.ts +9 -0
- package/dist/mcp/server.js +290 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/skill-install.d.ts +13 -0
- package/dist/skill-install.js +28 -0
- package/dist/skill-install.js.map +1 -0
- package/dist/studio/fit-board.d.ts +11 -0
- package/dist/studio/fit-board.js +15 -0
- package/dist/studio/fit-board.js.map +1 -0
- package/dist/studio/layout-schema.d.ts +157 -0
- package/dist/studio/layout-schema.js +32 -0
- package/dist/studio/layout-schema.js.map +1 -0
- package/dist/studio/live.d.ts +79 -0
- package/dist/studio/live.js +187 -0
- package/dist/studio/live.js.map +1 -0
- package/dist/studio/place-events.d.ts +60 -0
- package/dist/studio/place-events.js +42 -0
- package/dist/studio/place-events.js.map +1 -0
- package/dist/studio/place-runner.d.ts +62 -0
- package/dist/studio/place-runner.js +205 -0
- package/dist/studio/place-runner.js.map +1 -0
- package/dist/studio/place-worker.d.ts +1 -0
- package/dist/studio/place-worker.js +23 -0
- package/dist/studio/place-worker.js.map +1 -0
- package/dist/studio/route-events.d.ts +64 -0
- package/dist/studio/route-events.js +61 -0
- package/dist/studio/route-events.js.map +1 -0
- package/dist/studio/route-runner.d.ts +90 -0
- package/dist/studio/route-runner.js +272 -0
- package/dist/studio/route-runner.js.map +1 -0
- package/dist/studio/router-worker.d.ts +1 -0
- package/dist/studio/router-worker.js +17 -0
- package/dist/studio/router-worker.js.map +1 -0
- package/dist/studio/server.d.ts +32 -0
- package/dist/studio/server.js +610 -0
- package/dist/studio/server.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/package.json +64 -4
- package/skills/copperflow/SKILL.md +199 -0
- package/skills/copperflow/references/copper.md +82 -0
- package/skills/copperflow/references/design-rules.md +163 -0
- package/skills/copperflow/references/design-workflow.md +199 -0
- package/skills/copperflow/references/editable-subset.md +83 -0
- package/skills/copperflow/references/parts-library.md +83 -0
- package/skills/copperflow/references/writing-circuits.md +62 -0
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { readFile, stat } from "node:fs/promises";
|
|
3
|
+
import { createServer } from "node:http";
|
|
4
|
+
import { basename, extname, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { z, ZodError } from "zod";
|
|
7
|
+
import { BUILTIN_PARTS, buildBom, exportFabrication, exportPackage, listParts, partDir, placePart, readPart, verifyPart, addMark, applyLayoutEdits, circuitPathFor, createCircuitFile, editCircuit, renameDesignators, projectPath, EditError, isInside, isLayoutFile, listCircuits, listSheets, listHistory, loadCircuit, lockParts, makeSubSheet, previewSubSheet, redoChange, removeMark, resolveCircuit, undoChange, unlockParts, updateAnnotations, } from "../core/index.js";
|
|
8
|
+
import { Engine } from "../engine/engine.js";
|
|
9
|
+
import { setFilletRadius } from "../core/rules-edit.js";
|
|
10
|
+
import { readProject } from "../core/project.js";
|
|
11
|
+
import { boardSkeleton } from "../core/netlist.js";
|
|
12
|
+
import { RULES_PATH } from "../engine/rules/load.js";
|
|
13
|
+
import { layoutPathFor, readLayoutText } from "../core/layout-file.js";
|
|
14
|
+
import { lockedPartsAt, lockedStart } from "../core/layout-locks.js";
|
|
15
|
+
import { readIfThere } from "../core/file-writes.js";
|
|
16
|
+
import { unrouteEdits, unrouteSummary } from "../core/unroute.js";
|
|
17
|
+
import { resolveLayoutFile } from "../core/workspace.js";
|
|
18
|
+
import { COMMERCIAL_NOTE, importLcscPart } from "../library/import-lcsc.js";
|
|
19
|
+
import { writeNewPart } from "../library/new-part.js";
|
|
20
|
+
import { FOOTPRINT_FILE } from "../core/library.js";
|
|
21
|
+
import { PIN_TYPES } from "../core/pin-types.js";
|
|
22
|
+
import { LayoutBody } from "./layout-schema.js";
|
|
23
|
+
import { LiveProject } from "./live.js";
|
|
24
|
+
import { RouteRunner, routeWorkerFactory } from "./route-runner.js";
|
|
25
|
+
import { PlaceRunner, placeWorkerFactory } from "./place-runner.js";
|
|
26
|
+
import { fitBoardEdit } from "./fit-board.js";
|
|
27
|
+
const DEFAULT_PORT = 4777;
|
|
28
|
+
const DEFAULT_MAX_STREAMS = 16;
|
|
29
|
+
const MAX_CONNECTIONS = 64;
|
|
30
|
+
const REQUEST_TIMEOUT_MS = 15_000;
|
|
31
|
+
const MAX_BODY_BYTES = 1024 * 1024;
|
|
32
|
+
const HEARTBEAT_MS = 25_000;
|
|
33
|
+
const SECURITY_HEADERS = {
|
|
34
|
+
"x-content-type-options": "nosniff",
|
|
35
|
+
"x-frame-options": "DENY",
|
|
36
|
+
"referrer-policy": "no-referrer",
|
|
37
|
+
"cross-origin-resource-policy": "same-origin",
|
|
38
|
+
"content-security-policy": [
|
|
39
|
+
"default-src 'self'",
|
|
40
|
+
"script-src 'self'",
|
|
41
|
+
"style-src 'self' 'unsafe-inline'",
|
|
42
|
+
"img-src 'self' data: blob:",
|
|
43
|
+
"font-src 'self' data:",
|
|
44
|
+
"worker-src 'self' blob:",
|
|
45
|
+
"connect-src 'self'",
|
|
46
|
+
"object-src 'none'",
|
|
47
|
+
"base-uri 'none'",
|
|
48
|
+
"form-action 'none'",
|
|
49
|
+
"frame-ancestors 'none'",
|
|
50
|
+
].join("; "),
|
|
51
|
+
};
|
|
52
|
+
const TYPES = {
|
|
53
|
+
".html": "text/html; charset=utf-8",
|
|
54
|
+
".js": "text/javascript; charset=utf-8",
|
|
55
|
+
".css": "text/css; charset=utf-8",
|
|
56
|
+
".svg": "image/svg+xml",
|
|
57
|
+
".png": "image/png",
|
|
58
|
+
".json": "application/json",
|
|
59
|
+
".wasm": "application/wasm",
|
|
60
|
+
".woff2": "font/woff2",
|
|
61
|
+
".map": "application/json",
|
|
62
|
+
".txt": "text/plain; charset=utf-8",
|
|
63
|
+
};
|
|
64
|
+
const literal = z.union([z.string().max(500), z.number(), z.boolean()]);
|
|
65
|
+
const props = z.record(z.string().max(64), literal);
|
|
66
|
+
const file = z.string().min(1).max(500);
|
|
67
|
+
const point = z.object({ x: z.number().finite(), y: z.number().finite() });
|
|
68
|
+
/** A drawing prop: `points` takes a point list (the core checks which key may), every other prop a literal. */
|
|
69
|
+
const drawingProps = z.record(z.string().max(64), z.union([literal, z.array(point).max(1000)]));
|
|
70
|
+
/** setProps also takes a point (a moved label's offset) and null (removes the prop); the core checks which key may. */
|
|
71
|
+
const setPropValues = z.record(z.string().max(64), z.union([literal, point, z.null()]));
|
|
72
|
+
const EditSchema = z.discriminatedUnion("kind", [
|
|
73
|
+
z.object({ kind: z.literal("setProps"), part: z.string(), props: setPropValues }),
|
|
74
|
+
z.object({ kind: z.literal("removePart"), part: z.string() }),
|
|
75
|
+
z.object({
|
|
76
|
+
kind: z.literal("addPart"),
|
|
77
|
+
tag: z.string().max(64),
|
|
78
|
+
name: z.string().max(64),
|
|
79
|
+
props: props.optional(),
|
|
80
|
+
pinLabels: z.record(z.string().max(16), z.string().max(64)).optional(),
|
|
81
|
+
importFrom: z.string().max(200).optional(),
|
|
82
|
+
page: z.string().max(64).optional(),
|
|
83
|
+
}),
|
|
84
|
+
z.object({
|
|
85
|
+
kind: z.literal("addTrace"),
|
|
86
|
+
from: z.string(),
|
|
87
|
+
to: z.string(),
|
|
88
|
+
props: props.optional(),
|
|
89
|
+
schematicRouteHints: z
|
|
90
|
+
.array(z.object({ x: z.number().finite(), y: z.number().finite() }))
|
|
91
|
+
.max(200)
|
|
92
|
+
.optional(),
|
|
93
|
+
page: z.string().max(64).optional(),
|
|
94
|
+
}),
|
|
95
|
+
z.object({ kind: z.literal("removeTrace"), from: z.string(), to: z.string() }),
|
|
96
|
+
z.object({
|
|
97
|
+
kind: z.literal("setTraceHints"),
|
|
98
|
+
from: z.string(),
|
|
99
|
+
to: z.string(),
|
|
100
|
+
schematicRouteHints: z
|
|
101
|
+
.array(z.object({ x: z.number().finite(), y: z.number().finite() }))
|
|
102
|
+
.max(200),
|
|
103
|
+
}),
|
|
104
|
+
z.object({ kind: z.literal("addDrawing"), tag: z.string().max(64), name: z.string().max(64).optional(), props: drawingProps, page: z.string().max(64).optional() }),
|
|
105
|
+
z.object({ kind: z.literal("removeDrawing"), id: z.string().max(200) }),
|
|
106
|
+
z.object({ kind: z.literal("setDrawingProps"), id: z.string().max(200), props: drawingProps }),
|
|
107
|
+
z.object({ kind: z.literal("movePartToPage"), part: z.string(), page: z.string().max(64) }),
|
|
108
|
+
z.object({ kind: z.literal("addPage"), name: z.string().max(64) }),
|
|
109
|
+
z.object({ kind: z.literal("renamePage"), from: z.string().max(64), to: z.string().max(64) }),
|
|
110
|
+
z.object({ kind: z.literal("removePage"), name: z.string().max(64) }),
|
|
111
|
+
z.object({ kind: z.literal("renamePort"), from: z.string().max(64), to: z.string().max(64) }),
|
|
112
|
+
z.object({ kind: z.literal("setSheetSize"), width: z.number().finite().nullable().optional(), height: z.number().finite().nullable().optional() }),
|
|
113
|
+
z.object({ kind: z.literal("setConnections"), part: z.string(), connections: z.record(z.string().max(64), z.string().max(64)) }),
|
|
114
|
+
z.object({ kind: z.literal("addPour"), net: z.string().max(200), layer: z.string().max(16), outline: z.array(point).max(1000).optional(), props: props.optional() }),
|
|
115
|
+
z.object({ kind: z.literal("setPour"), id: z.string().max(64), props: z.record(z.string().max(64), z.union([literal, z.array(point).max(1000), z.null()])) }),
|
|
116
|
+
z.object({ kind: z.literal("removePour"), id: z.string().max(64) }),
|
|
117
|
+
z.object({ kind: z.literal("addHole"), x: z.number().finite(), y: z.number().finite(), diameter: z.number().finite() }),
|
|
118
|
+
z.object({ kind: z.literal("setHole"), id: z.string().max(64), props: z.record(z.string().max(64), z.number().finite()) }),
|
|
119
|
+
z.object({ kind: z.literal("removeHole"), id: z.string().max(64) }),
|
|
120
|
+
]);
|
|
121
|
+
const Bodies = {
|
|
122
|
+
// "Keep these positions" writes every auto-placed part in one request.
|
|
123
|
+
edit: z.object({ file, summary: z.string().min(1).max(200), edits: z.array(EditSchema).min(1).max(500) }),
|
|
124
|
+
lock: z.object({ file, parts: z.array(z.string()).min(1).max(200), locked: z.boolean() }),
|
|
125
|
+
mark: z.object({
|
|
126
|
+
file,
|
|
127
|
+
text: z.string().min(1).max(500),
|
|
128
|
+
view: z.enum(["pcb", "schematic"]).optional(),
|
|
129
|
+
x: z.number().optional(),
|
|
130
|
+
y: z.number().optional(),
|
|
131
|
+
}),
|
|
132
|
+
unmark: z.object({ file, id: z.string() }),
|
|
133
|
+
undo: z.object({ id: z.string().optional() }),
|
|
134
|
+
redo: z.object({ id: z.string().optional() }),
|
|
135
|
+
build: z.object({ file }),
|
|
136
|
+
place: z.object({ file, part: z.string().min(1).max(64), name: z.string().max(40).optional(), props: props.optional(), page: z.string().max(64).optional() }),
|
|
137
|
+
verify: z.object({ id: z.string().min(1).max(64), by: z.string().min(1).max(100), against: z.string().min(1).max(300), confirm: z.string() }),
|
|
138
|
+
// Library → Import by LCSC number: one part, written unverified.
|
|
139
|
+
importPart: z.object({ lcsc: z.string().min(1).max(20), id: z.string().min(1).max(64).optional(), replace: z.boolean().optional() }),
|
|
140
|
+
// Library → New part…: the part written from a datasheet; the writer checks every field again.
|
|
141
|
+
createPart: z.object({
|
|
142
|
+
id: z.string().min(1).max(64),
|
|
143
|
+
title: z.string().min(1).max(200),
|
|
144
|
+
manufacturer: z.string().max(200).optional(),
|
|
145
|
+
mpn: z.string().max(100).optional(),
|
|
146
|
+
package: z.union([z.string().min(1).max(100), z.object({ file: z.literal(FOOTPRINT_FILE) }).strict()]),
|
|
147
|
+
pins: z.array(z.object({ number: z.string().max(10), name: z.string().max(100), type: z.enum(PIN_TYPES), description: z.string().max(200).optional() }).strict()).min(1).max(2000),
|
|
148
|
+
suppliers: z.record(z.string().max(40), z.string().max(100)).optional(),
|
|
149
|
+
datasheet: z.object({ url: z.string().max(2000) }).strict().optional(),
|
|
150
|
+
replace: z.boolean().optional(),
|
|
151
|
+
}),
|
|
152
|
+
// The Design rules panel: a radius in mm, or null for the default.
|
|
153
|
+
rules: z.object({ filletRadius: z.number().nullable(), file: z.string().optional() }),
|
|
154
|
+
// Route → Autoroute: the whole board, some nets, the connections of some parts, or one sub-sheet instance.
|
|
155
|
+
route: z.object({
|
|
156
|
+
file,
|
|
157
|
+
scope: z.discriminatedUnion("kind", [
|
|
158
|
+
z.object({ kind: z.literal("all") }).strict(),
|
|
159
|
+
z.object({ kind: z.literal("nets"), nets: z.array(z.string().min(1).max(200)).min(1).max(500) }).strict(),
|
|
160
|
+
z.object({ kind: z.literal("parts"), parts: z.array(z.string().min(1).max(64)).min(1).max(500) }).strict(),
|
|
161
|
+
z.object({ kind: z.literal("instance"), instance: z.string().min(1).max(200) }).strict(),
|
|
162
|
+
]),
|
|
163
|
+
}),
|
|
164
|
+
// Place → Autoplace: the parts nobody placed or locked, on the whole board, of some parts or of one instance.
|
|
165
|
+
autoplace: z.object({
|
|
166
|
+
file,
|
|
167
|
+
scope: z.discriminatedUnion("kind", [
|
|
168
|
+
z.object({ kind: z.literal("all") }).strict(),
|
|
169
|
+
z.object({ kind: z.literal("parts"), parts: z.array(z.string().min(1).max(64)).min(1).max(500) }).strict(),
|
|
170
|
+
z.object({ kind: z.literal("instance"), instance: z.string().min(1).max(200) }).strict(),
|
|
171
|
+
]),
|
|
172
|
+
fit: z.boolean().optional(),
|
|
173
|
+
}),
|
|
174
|
+
// Layout → Fit board: the rectangle round the parts, with a margin in mm.
|
|
175
|
+
fitBoard: z.object({ file, margin: z.number().min(0).max(50).optional() }),
|
|
176
|
+
// Route → Unroute: the router's copper among the ids, or all of it.
|
|
177
|
+
unroute: z.object({ file, ids: z.array(z.string().min(1).max(32)).max(5000).optional() }),
|
|
178
|
+
// Edit → Make sub-sheet: `preview` answers what it would do and writes nothing.
|
|
179
|
+
makeSheet: z.object({
|
|
180
|
+
file,
|
|
181
|
+
name: z.string().min(1).max(64),
|
|
182
|
+
parts: z.array(z.string().max(64)).max(500),
|
|
183
|
+
rename: z.boolean().optional(),
|
|
184
|
+
instance: z.string().max(64).optional(),
|
|
185
|
+
preview: z.boolean().optional(),
|
|
186
|
+
}),
|
|
187
|
+
// File → New circuit: an empty circuit file with a board, written through the core as one history entry.
|
|
188
|
+
newCircuit: z.object({ file: z.string().min(1).max(200).regex(/^[\w\- ./]+\.circuit\.tsx$/), width: z.number().positive().max(1000), height: z.number().positive().max(1000) }),
|
|
189
|
+
// Design → Annotate designators: the parts renamed, and the layout file's nets with them, as one history entry.
|
|
190
|
+
renameParts: z.object({ file, summary: z.string().min(1).max(200), mapping: z.array(z.object({ from: z.string().max(64), to: z.string().max(64) })).min(1).max(2000) }),
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* The circuit a history entry's file builds: itself, or the circuit beside a layout file. rules.yaml builds none
|
|
194
|
+
* itself: the watcher builds every circuit again when an engine file changes.
|
|
195
|
+
*/
|
|
196
|
+
const builtFrom = (file) => (file === RULES_PATH ? undefined : isLayoutFile(file) ? circuitPathFor(file) : file);
|
|
197
|
+
class HttpError extends Error {
|
|
198
|
+
status;
|
|
199
|
+
constructor(status, message) {
|
|
200
|
+
super(message);
|
|
201
|
+
this.status = status;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/** Starts the Studio web server on 127.0.0.1. */
|
|
205
|
+
export async function startStudio(options) {
|
|
206
|
+
const root = resolve(options.root);
|
|
207
|
+
const staticDir = resolve(options.staticDir ?? fileURLToPath(new URL("../app/", import.meta.url)));
|
|
208
|
+
const token = randomBytes(24).toString("hex");
|
|
209
|
+
const building = builderFor(options.builder);
|
|
210
|
+
const live = new LiveProject(root, building.builder);
|
|
211
|
+
const streams = new Set();
|
|
212
|
+
const maxStreams = options.maxStreams ?? DEFAULT_MAX_STREAMS;
|
|
213
|
+
let port = 0;
|
|
214
|
+
const router = new RouteRunner({
|
|
215
|
+
root,
|
|
216
|
+
build: (circuit) => building.builder.build(root, circuit),
|
|
217
|
+
announce: (event) => live.announce("route", event),
|
|
218
|
+
nextMark: () => live.nextMark(),
|
|
219
|
+
requestBuild: (circuit) => live.requestBuild(circuit),
|
|
220
|
+
createWorker: options.routeWorker === null ? undefined : (options.routeWorker ?? (await routeWorkerFactory())),
|
|
221
|
+
});
|
|
222
|
+
const placer = new PlaceRunner({
|
|
223
|
+
root,
|
|
224
|
+
build: (circuit) => building.builder.build(root, circuit),
|
|
225
|
+
announce: (event) => live.announce("place", event),
|
|
226
|
+
nextMark: () => live.nextMark(),
|
|
227
|
+
requestBuild: (circuit) => live.requestBuild(circuit),
|
|
228
|
+
createWorker: options.placeWorker === null ? undefined : (options.placeWorker ?? (await placeWorkerFactory())),
|
|
229
|
+
});
|
|
230
|
+
const server = createServer((req, res) => {
|
|
231
|
+
handle(req, res).catch((error) => sendError(res, error, root));
|
|
232
|
+
});
|
|
233
|
+
server.requestTimeout = REQUEST_TIMEOUT_MS;
|
|
234
|
+
server.maxConnections = MAX_CONNECTIONS;
|
|
235
|
+
async function handle(req, res) {
|
|
236
|
+
const host = req.headers.host;
|
|
237
|
+
if (host !== `127.0.0.1:${port}` && host !== `localhost:${port}`)
|
|
238
|
+
throw new HttpError(403, "Unexpected Host header");
|
|
239
|
+
const origin = req.headers.origin;
|
|
240
|
+
if (origin !== undefined && origin !== `http://127.0.0.1:${port}` && origin !== `http://localhost:${port}`) {
|
|
241
|
+
throw new HttpError(403, "Cross-origin requests are not allowed");
|
|
242
|
+
}
|
|
243
|
+
const url = new URL(req.url ?? "/", `http://${host}`);
|
|
244
|
+
if (!url.pathname.startsWith("/api/"))
|
|
245
|
+
return serveStatic(url.pathname, res);
|
|
246
|
+
const given = req.headers["x-copperflow-token"];
|
|
247
|
+
if (typeof given !== "string" || !sameToken(given, token))
|
|
248
|
+
throw new HttpError(403, "Missing or wrong session token");
|
|
249
|
+
/** Builds the circuit a history entry's file belongs to, when there is one. */
|
|
250
|
+
const rebuild = (file) => {
|
|
251
|
+
const circuit = builtFrom(file);
|
|
252
|
+
if (circuit !== undefined)
|
|
253
|
+
live.requestBuild(circuit);
|
|
254
|
+
};
|
|
255
|
+
/** The live design when it is current for the circuit file, else a fresh build. */
|
|
256
|
+
const designOf = async (circuit) => (await live.currentDesign(circuit)) ?? (await building.builder.build(root, circuit));
|
|
257
|
+
const route = `${req.method} ${url.pathname}`;
|
|
258
|
+
const query = (name) => {
|
|
259
|
+
const value = url.searchParams.get(name);
|
|
260
|
+
if (!value)
|
|
261
|
+
throw new HttpError(400, `Missing ${name}`);
|
|
262
|
+
return value;
|
|
263
|
+
};
|
|
264
|
+
switch (route) {
|
|
265
|
+
case "GET /api/events":
|
|
266
|
+
return openEvents(res);
|
|
267
|
+
case "GET /api/circuits":
|
|
268
|
+
return send(res, await listCircuits(root));
|
|
269
|
+
case "GET /api/sheets":
|
|
270
|
+
return send(res, await listSheets(root));
|
|
271
|
+
case "GET /api/project":
|
|
272
|
+
return send(res, { name: basename(root) });
|
|
273
|
+
case "GET /api/project-memory":
|
|
274
|
+
return send(res, { text: (await readProject(root)) ?? null });
|
|
275
|
+
case "GET /api/circuit": {
|
|
276
|
+
const { model, annotations, violations, file: name } = await loadCircuit(root, query("file"));
|
|
277
|
+
return send(res, { file: name, model, annotations, violations });
|
|
278
|
+
}
|
|
279
|
+
// Builds name the file without parsing it: a file with a syntax error still has a (failed) build.
|
|
280
|
+
case "GET /api/build":
|
|
281
|
+
return send(res, live.getBuild((await resolveCircuit(root, query("file"))).file));
|
|
282
|
+
case "GET /api/history":
|
|
283
|
+
return send(res, await listHistory(root, Number(url.searchParams.get("limit") ?? 50) || 50));
|
|
284
|
+
case "POST /api/build": {
|
|
285
|
+
const body = Bodies.build.parse(await readJson(req));
|
|
286
|
+
live.requestBuild((await resolveCircuit(root, body.file)).file);
|
|
287
|
+
return send(res, { status: "building" }, 202);
|
|
288
|
+
}
|
|
289
|
+
case "POST /api/edit": {
|
|
290
|
+
const body = Bodies.edit.parse(await readJson(req));
|
|
291
|
+
const result = await editCircuit(root, body.file, body.edits, { author: "human", summary: body.summary });
|
|
292
|
+
// After the write and before the build it asks for: a build with a larger start mark read this change.
|
|
293
|
+
const writeMark = live.nextMark();
|
|
294
|
+
live.requestBuild(result.entry.file);
|
|
295
|
+
return send(res, { entryId: result.entry.id, violations: result.violations, writeMark });
|
|
296
|
+
}
|
|
297
|
+
// The new sheet file rides on the circuit file's entry, so the build that follows reads both.
|
|
298
|
+
case "POST /api/make-sheet": {
|
|
299
|
+
const { file: name, preview, ...request } = Bodies.makeSheet.parse(await readJson(req));
|
|
300
|
+
if (preview)
|
|
301
|
+
return send(res, await previewSubSheet(root, name, request));
|
|
302
|
+
const result = await makeSubSheet(root, name, request, { author: "human", engine: { build: (_root, circuit) => designOf(circuit) } });
|
|
303
|
+
const writeMark = live.nextMark();
|
|
304
|
+
live.requestBuild(result.entry.file);
|
|
305
|
+
return send(res, { entryId: result.entry.id, preview: result.preview, writeMark });
|
|
306
|
+
}
|
|
307
|
+
case "POST /api/rename-parts": {
|
|
308
|
+
const body = Bodies.renameParts.parse(await readJson(req));
|
|
309
|
+
const { entry } = await renameDesignators(root, body.file, body.mapping, { author: "human", summary: body.summary, engine: { build: (_root, circuit) => designOf(circuit) } });
|
|
310
|
+
const writeMark = live.nextMark();
|
|
311
|
+
live.requestBuild(entry.file);
|
|
312
|
+
return send(res, { entryId: entry.id, writeMark });
|
|
313
|
+
}
|
|
314
|
+
case "POST /api/new-circuit": {
|
|
315
|
+
const body = Bodies.newCircuit.parse(await readJson(req));
|
|
316
|
+
const target = projectPath(root, body.file);
|
|
317
|
+
const entry = await createCircuitFile(root, target, boardSkeleton({ width: body.width, height: body.height }), { author: "human", summary: `create ${target} (empty, ${body.width} × ${body.height} mm board)` });
|
|
318
|
+
live.requestBuild(entry.file);
|
|
319
|
+
return send(res, { file: entry.file, entryId: entry.id });
|
|
320
|
+
}
|
|
321
|
+
// Copper goes to the layout file beside the circuit; the built design tells which tracks start on locked parts.
|
|
322
|
+
case "POST /api/layout": {
|
|
323
|
+
const body = LayoutBody.parse(await readJson(req));
|
|
324
|
+
const result = await applyLayoutEdits(root, body.file, body.edits, { author: "human", summary: body.summary, design: designOf, ...(body.sheet ? { sheet: body.sheet } : {}) });
|
|
325
|
+
const writeMark = live.nextMark();
|
|
326
|
+
live.requestBuild(circuitPathFor(result.file));
|
|
327
|
+
return send(res, { entryId: result.entry.id, created: result.created, writeMark });
|
|
328
|
+
}
|
|
329
|
+
// The run goes on after the answer; its progress and its end come as "route" events.
|
|
330
|
+
case "POST /api/route": {
|
|
331
|
+
const body = Bodies.route.parse(await readJson(req));
|
|
332
|
+
if (router.running !== undefined)
|
|
333
|
+
throw new HttpError(409, `The board of ${router.running} is being routed; cancel it or wait for it to end`);
|
|
334
|
+
return send(res, { status: "routing", file: await router.start(body.file, body.scope) }, 202);
|
|
335
|
+
}
|
|
336
|
+
case "POST /api/route/cancel":
|
|
337
|
+
return send(res, { cancelled: router.cancel() });
|
|
338
|
+
// The run goes on after the answer; its progress and its end come as "place" events.
|
|
339
|
+
case "POST /api/autoplace": {
|
|
340
|
+
const body = Bodies.autoplace.parse(await readJson(req));
|
|
341
|
+
if (placer.running !== undefined)
|
|
342
|
+
throw new HttpError(409, `The board of ${placer.running} is being placed; cancel it or wait for it to end`);
|
|
343
|
+
if (router.running !== undefined)
|
|
344
|
+
throw new HttpError(409, `The board of ${router.running} is being routed; cancel it or wait for it to end`);
|
|
345
|
+
return send(res, { status: "placing", file: await placer.start(body.file, body.scope, body.fit ?? false) }, 202);
|
|
346
|
+
}
|
|
347
|
+
case "POST /api/autoplace/cancel":
|
|
348
|
+
return send(res, { cancelled: placer.cancel() });
|
|
349
|
+
case "POST /api/fit-board": {
|
|
350
|
+
const body = Bodies.fitBoard.parse(await readJson(req));
|
|
351
|
+
const circuit = await resolveCircuit(root, body.file);
|
|
352
|
+
const fit = fitBoardEdit(await building.builder.build(root, circuit.file), body.margin);
|
|
353
|
+
if ("error" in fit)
|
|
354
|
+
throw new HttpError(400, fit.error);
|
|
355
|
+
const result = await editCircuit(root, circuit.file, [fit.edit], { author: "human", summary: fit.summary });
|
|
356
|
+
const writeMark = live.nextMark();
|
|
357
|
+
live.requestBuild(circuit.file);
|
|
358
|
+
return send(res, { entryId: result.entry.id, summary: fit.summary, writeMark });
|
|
359
|
+
}
|
|
360
|
+
case "POST /api/unroute": {
|
|
361
|
+
const body = Bodies.unroute.parse(await readJson(req));
|
|
362
|
+
const layout = await resolveLayoutFile(root, layoutNameOf(body.file));
|
|
363
|
+
const source = await readIfThere(layout.path);
|
|
364
|
+
const records = source === undefined ? [] : readLayoutText(source, layout.file).records;
|
|
365
|
+
// A router track starting on a part locked since counts as locked: it is left and named, not refused with the rest.
|
|
366
|
+
const locked = await lockedPartsAt(layout.circuitPath);
|
|
367
|
+
const lockedPart = locked.size === 0 ? undefined : lockedStart(locked, await designOf(layout.circuit));
|
|
368
|
+
const tracks = records.filter((r) => r.t === "track");
|
|
369
|
+
const { edits, skipped, kept } = unrouteEdits({ tracks, vias: records.filter((r) => r.t === "via") }, { ...(body.ids ? { ids: body.ids } : {}), ...(lockedPart ? { lockedPart: (track) => lockedPart(tracks.find((one) => one.id === track.id)) } : {}) });
|
|
370
|
+
if (edits.length === 0) {
|
|
371
|
+
const none = body.ids ? "None of the selected copper was made by the router and unlocked; Unroute removes only that" : "The board has no unlocked router copper to remove";
|
|
372
|
+
throw new HttpError(400, skipped.length === 0 ? none : `${none}: ${skipped.join("; ")}`);
|
|
373
|
+
}
|
|
374
|
+
const result = await applyLayoutEdits(root, layout.circuit, edits, { author: "human", summary: unrouteSummary(edits, skipped, kept.length), design: designOf });
|
|
375
|
+
const writeMark = live.nextMark();
|
|
376
|
+
live.requestBuild(layout.circuit);
|
|
377
|
+
return send(res, { entryId: result.entry.id, summary: result.entry.summary, writeMark });
|
|
378
|
+
}
|
|
379
|
+
case "POST /api/lock": {
|
|
380
|
+
const body = Bodies.lock.parse(await readJson(req));
|
|
381
|
+
const { model } = await loadCircuit(root, body.file);
|
|
382
|
+
const now = new Date().toISOString();
|
|
383
|
+
const next = await updateAnnotations(root, body.file, (a) => body.locked ? lockParts(a, model, body.parts, now) : unlockParts(a, body.parts));
|
|
384
|
+
return send(res, next);
|
|
385
|
+
}
|
|
386
|
+
case "POST /api/mark": {
|
|
387
|
+
const { file: name, ...input } = Bodies.mark.parse(await readJson(req));
|
|
388
|
+
let id = "";
|
|
389
|
+
await updateAnnotations(root, name, (a) => {
|
|
390
|
+
const result = addMark(a, input, new Date().toISOString());
|
|
391
|
+
id = result.mark.id;
|
|
392
|
+
return result.annotations;
|
|
393
|
+
});
|
|
394
|
+
return send(res, { id });
|
|
395
|
+
}
|
|
396
|
+
case "POST /api/unmark": {
|
|
397
|
+
const body = Bodies.unmark.parse(await readJson(req));
|
|
398
|
+
return send(res, await updateAnnotations(root, body.file, (a) => removeMark(a, body.id)));
|
|
399
|
+
}
|
|
400
|
+
case "POST /api/rules": {
|
|
401
|
+
const body = Bodies.rules.parse(await readJson(req));
|
|
402
|
+
const entry = await setFilletRadius(root, body.filletRadius ?? undefined, { author: "human" });
|
|
403
|
+
// The write's mark, as an edit's: a build that started after it read the new radius. The open circuit is built now
|
|
404
|
+
// (the watcher builds every circuit again when rules.yaml changes, but later), so the mark is met soon.
|
|
405
|
+
const writeMark = live.nextMark();
|
|
406
|
+
if (body.file)
|
|
407
|
+
live.requestBuild((await loadCircuit(root, body.file)).file);
|
|
408
|
+
return send(res, { entryId: entry.id, summary: entry.summary, writeMark });
|
|
409
|
+
}
|
|
410
|
+
case "GET /api/parts":
|
|
411
|
+
return send(res, { library: await listParts(root), builtin: BUILTIN_PARTS });
|
|
412
|
+
case "GET /api/part": {
|
|
413
|
+
const id = query("id");
|
|
414
|
+
const part = await readPart(root, id);
|
|
415
|
+
const checklist = await readFile(resolve(partDir(root, id), "verification.md"), "utf8").catch(() => "");
|
|
416
|
+
return send(res, { id, part, checklist });
|
|
417
|
+
}
|
|
418
|
+
case "POST /api/place": {
|
|
419
|
+
const { file: name, ...request } = Bodies.place.parse(await readJson(req));
|
|
420
|
+
const result = await placePart(root, name, request, { author: "human" });
|
|
421
|
+
live.requestBuild(result.entry.file);
|
|
422
|
+
return send(res, { entryId: result.entry.id, name: result.name });
|
|
423
|
+
}
|
|
424
|
+
case "POST /api/verify": {
|
|
425
|
+
const body = Bodies.verify.parse(await readJson(req));
|
|
426
|
+
// The person types the id back, as in the CLI, so a stray click cannot verify a part.
|
|
427
|
+
if (body.confirm.trim() !== body.id)
|
|
428
|
+
throw new HttpError(400, `Type ${body.id} exactly to confirm`);
|
|
429
|
+
await verifyPart(root, body.id, { by: body.by, against: body.against }, new Date().toISOString());
|
|
430
|
+
return send(res, { id: body.id });
|
|
431
|
+
}
|
|
432
|
+
case "POST /api/import-part": {
|
|
433
|
+
const body = Bodies.importPart.parse(await readJson(req));
|
|
434
|
+
const now = new Date().toISOString();
|
|
435
|
+
const result = await importLcscPart(root, body.lcsc, { now, replace: body.replace === true, ...(body.id ? { id: body.id } : {}), ...(options.fetch ? { fetch: options.fetch } : {}) });
|
|
436
|
+
const { id, lcsc, part, files, pads, notes } = result;
|
|
437
|
+
return send(res, { id, lcsc, title: part.title, pins: Object.keys(part.pins).length, pads, files, notes, terms: COMMERCIAL_NOTE });
|
|
438
|
+
}
|
|
439
|
+
case "POST /api/create-part": {
|
|
440
|
+
const { replace, ...input } = Bodies.createPart.parse(await readJson(req));
|
|
441
|
+
const result = await writeNewPart(root, input, { now: new Date().toISOString(), replace: replace === true });
|
|
442
|
+
const { id, part, files, notes, verification, checklist } = result;
|
|
443
|
+
return send(res, { id, title: part.title, pins: Object.keys(part.pins).length, footprint: part.footprint, files, notes, verification, checklist });
|
|
444
|
+
}
|
|
445
|
+
case "GET /api/bom": {
|
|
446
|
+
const circuit = (await loadCircuit(root, query("file"))).file;
|
|
447
|
+
return send(res, await buildBom(root, circuit, { design: await designOf(circuit) }));
|
|
448
|
+
}
|
|
449
|
+
case "POST /api/package": {
|
|
450
|
+
const circuit = (await loadCircuit(root, Bodies.build.parse(await readJson(req)).file)).file;
|
|
451
|
+
return send(res, await exportPackage(root, circuit, { design: await designOf(circuit) }));
|
|
452
|
+
}
|
|
453
|
+
// The fabrication files go beside the circuit. Not while the router runs (it would export the board before the
|
|
454
|
+
// run's copper); the export takes the design in the project's write queue, so no write lands between the two.
|
|
455
|
+
case "POST /api/export": {
|
|
456
|
+
const circuit = (await resolveCircuit(root, Bodies.build.parse(await readJson(req)).file)).file;
|
|
457
|
+
if (router.running !== undefined)
|
|
458
|
+
throw new HttpError(409, `The board of ${router.running} is being routed; cancel it or wait for it to end before exporting`);
|
|
459
|
+
const result = await exportFabrication(root, circuit, { engine: { build: (_root, file) => designOf(file) } });
|
|
460
|
+
if (!result.written)
|
|
461
|
+
throw new HttpError(422, `No fabrication files written: ${result.errors.join("; ")}`);
|
|
462
|
+
return send(res, result);
|
|
463
|
+
}
|
|
464
|
+
// Undo and redo write the file too: their write mark, as an edit's, lets the keys wait for the build that read them.
|
|
465
|
+
case "POST /api/undo": {
|
|
466
|
+
const body = Bodies.undo.parse(await readJson(req));
|
|
467
|
+
const entry = await undoChange(root, { author: "human", design: designOf, ...(body.id ? { id: body.id } : {}) });
|
|
468
|
+
const writeMark = live.nextMark();
|
|
469
|
+
rebuild(entry.file);
|
|
470
|
+
return send(res, { entryId: entry.id, summary: entry.summary, writeMark });
|
|
471
|
+
}
|
|
472
|
+
case "POST /api/redo": {
|
|
473
|
+
const body = Bodies.redo.parse(await readJson(req));
|
|
474
|
+
const entry = await redoChange(root, { author: "human", design: designOf, ...(body.id ? { id: body.id } : {}) });
|
|
475
|
+
const writeMark = live.nextMark();
|
|
476
|
+
rebuild(entry.file);
|
|
477
|
+
return send(res, { entryId: entry.id, summary: entry.summary, writeMark });
|
|
478
|
+
}
|
|
479
|
+
default:
|
|
480
|
+
throw new HttpError(404, `No route ${route}`);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
async function serveStatic(pathname, res) {
|
|
484
|
+
let decoded;
|
|
485
|
+
try {
|
|
486
|
+
decoded = decodeURIComponent(pathname);
|
|
487
|
+
}
|
|
488
|
+
catch {
|
|
489
|
+
throw new HttpError(400, "Bad path");
|
|
490
|
+
}
|
|
491
|
+
const relative = decoded === "/" ? "index.html" : decoded.slice(1);
|
|
492
|
+
const path = resolve(staticDir, relative);
|
|
493
|
+
if (decoded.includes("\0") || !isInside(staticDir, path))
|
|
494
|
+
throw new HttpError(404, "Not found");
|
|
495
|
+
const info = await stat(path).catch(() => undefined);
|
|
496
|
+
if (!info?.isFile())
|
|
497
|
+
throw new HttpError(404, "Not found");
|
|
498
|
+
const type = TYPES[extname(path)] ?? "application/octet-stream";
|
|
499
|
+
res.writeHead(200, { "content-type": type, "cache-control": "no-store", ...SECURITY_HEADERS });
|
|
500
|
+
const content = await readFile(path);
|
|
501
|
+
res.end(content);
|
|
502
|
+
}
|
|
503
|
+
function openEvents(res) {
|
|
504
|
+
if (streams.size >= maxStreams)
|
|
505
|
+
throw new HttpError(429, "Too many open event streams");
|
|
506
|
+
res.writeHead(200, {
|
|
507
|
+
"content-type": "text/event-stream",
|
|
508
|
+
"cache-control": "no-store",
|
|
509
|
+
connection: "keep-alive",
|
|
510
|
+
...SECURITY_HEADERS,
|
|
511
|
+
});
|
|
512
|
+
res.write(": connected\n\n");
|
|
513
|
+
streams.add(res);
|
|
514
|
+
const unsubscribe = live.subscribe((event, data) => res.write(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`));
|
|
515
|
+
const heartbeat = setInterval(() => res.write(": ping\n\n"), HEARTBEAT_MS);
|
|
516
|
+
res.on("close", () => {
|
|
517
|
+
clearInterval(heartbeat);
|
|
518
|
+
unsubscribe();
|
|
519
|
+
streams.delete(res);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
await new Promise((done, fail) => {
|
|
523
|
+
server.once("error", fail);
|
|
524
|
+
server.listen(options.port ?? DEFAULT_PORT, "127.0.0.1", () => done());
|
|
525
|
+
}).catch(async (error) => {
|
|
526
|
+
await building.stop();
|
|
527
|
+
throw error;
|
|
528
|
+
});
|
|
529
|
+
const address = server.address();
|
|
530
|
+
port = typeof address === "object" && address ? address.port : 0;
|
|
531
|
+
live.start();
|
|
532
|
+
return {
|
|
533
|
+
url: `http://127.0.0.1:${port}`,
|
|
534
|
+
token,
|
|
535
|
+
openUrl: `http://127.0.0.1:${port}/#token=${token}`,
|
|
536
|
+
close: async () => {
|
|
537
|
+
router.cancel();
|
|
538
|
+
placer.cancel();
|
|
539
|
+
live.stop();
|
|
540
|
+
await building.stop();
|
|
541
|
+
for (const stream of streams)
|
|
542
|
+
stream.end();
|
|
543
|
+
server.closeAllConnections();
|
|
544
|
+
await new Promise((done) => server.close(() => done()));
|
|
545
|
+
},
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
/** The layout file a request names: itself, or the one beside a circuit file. */
|
|
549
|
+
function layoutNameOf(file) {
|
|
550
|
+
if (isLayoutFile(file))
|
|
551
|
+
return file;
|
|
552
|
+
try {
|
|
553
|
+
return layoutPathFor(file);
|
|
554
|
+
}
|
|
555
|
+
catch (error) {
|
|
556
|
+
throw new HttpError(400, error.message);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
/** The given builder, or a new engine that the Studio owns and so stops when it closes. */
|
|
560
|
+
function builderFor(given) {
|
|
561
|
+
if (given)
|
|
562
|
+
return { builder: given, stop: async () => undefined };
|
|
563
|
+
const engine = new Engine();
|
|
564
|
+
return { builder: engine, stop: () => engine.stop() };
|
|
565
|
+
}
|
|
566
|
+
function send(res, data, status = 200) {
|
|
567
|
+
res.writeHead(status, { "content-type": "application/json", "cache-control": "no-store", ...SECURITY_HEADERS });
|
|
568
|
+
res.end(JSON.stringify({ ok: true, data }));
|
|
569
|
+
}
|
|
570
|
+
function sendError(res, error, root) {
|
|
571
|
+
// Node system errors (EPERM, ENOENT, ...) carry a string code and paths; they are not user errors.
|
|
572
|
+
const unexpected = !(error instanceof EditError) && typeof error?.code === "string";
|
|
573
|
+
if (unexpected)
|
|
574
|
+
console.error("copperflow studio:", error);
|
|
575
|
+
const status = unexpected
|
|
576
|
+
? 500
|
|
577
|
+
: error instanceof HttpError
|
|
578
|
+
? error.status
|
|
579
|
+
: error instanceof EditError
|
|
580
|
+
? { locked: 409, readonly: 409, not_found: 404, invalid: 400, parse: 400 }[error.code]
|
|
581
|
+
: 400;
|
|
582
|
+
const message = unexpected
|
|
583
|
+
? "Internal error; see the terminal running copperflow studio"
|
|
584
|
+
: error instanceof ZodError
|
|
585
|
+
? error.issues.map((i) => `${i.path.join(".") || "body"}: ${i.message}`).join("; ")
|
|
586
|
+
: error.message.split(root).join(".");
|
|
587
|
+
if (res.headersSent) {
|
|
588
|
+
res.end();
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
res.writeHead(status, { "content-type": "application/json", "cache-control": "no-store", ...SECURITY_HEADERS });
|
|
592
|
+
res.end(JSON.stringify({ ok: false, error: message }));
|
|
593
|
+
}
|
|
594
|
+
async function readJson(req) {
|
|
595
|
+
let size = 0;
|
|
596
|
+
const chunks = [];
|
|
597
|
+
for await (const chunk of req) {
|
|
598
|
+
size += chunk.length;
|
|
599
|
+
if (size > MAX_BODY_BYTES)
|
|
600
|
+
throw new HttpError(413, "Request body is too large");
|
|
601
|
+
chunks.push(chunk);
|
|
602
|
+
}
|
|
603
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}");
|
|
604
|
+
}
|
|
605
|
+
function sameToken(given, expected) {
|
|
606
|
+
const a = Buffer.from(given);
|
|
607
|
+
const b = Buffer.from(expected);
|
|
608
|
+
return a.length === b.length && timingSafeEqual(a, b);
|
|
609
|
+
}
|
|
610
|
+
//# sourceMappingURL=server.js.map
|