portograph 0.0.0-stage → 0.2.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/README.md +233 -2
- package/bin/cli.mjs +256 -0
- package/bin/compute.mjs +177 -0
- package/bin/font-check.d.mts +4 -0
- package/bin/font-check.mjs +58 -0
- package/bin/portograph.mjs +23 -0
- package/dist/cli.d.cts +109 -0
- package/dist/cli.d.ts +109 -0
- package/dist/geometry/index.d.cts +14 -0
- package/dist/geometry/index.d.ts +14 -0
- package/dist/geometry/oriented.d.cts +34 -0
- package/dist/geometry/oriented.d.ts +34 -0
- package/dist/geometry/planar.d.cts +69 -0
- package/dist/geometry/planar.d.ts +69 -0
- package/dist/index.cjs +20 -0
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +1 -0
- package/dist/internal.d.cts +73 -0
- package/dist/internal.d.ts +73 -0
- package/dist/layout/alignment-targets.d.cts +76 -0
- package/dist/layout/alignment-targets.d.ts +76 -0
- package/dist/layout/approach.d.cts +13 -0
- package/dist/layout/approach.d.ts +13 -0
- package/dist/layout/attempt-counters.d.cts +117 -0
- package/dist/layout/attempt-counters.d.ts +117 -0
- package/dist/layout/attempt-ledger.d.cts +31 -0
- package/dist/layout/attempt-ledger.d.ts +31 -0
- package/dist/layout/attempt-timings.d.cts +41 -0
- package/dist/layout/attempt-timings.d.ts +41 -0
- package/dist/layout/bands.d.cts +348 -0
- package/dist/layout/bands.d.ts +348 -0
- package/dist/layout/bar-width.d.cts +9 -0
- package/dist/layout/bar-width.d.ts +9 -0
- package/dist/layout/bars.d.cts +26 -0
- package/dist/layout/bars.d.ts +26 -0
- package/dist/layout/block-checks.d.cts +5 -0
- package/dist/layout/block-checks.d.ts +5 -0
- package/dist/layout/box-writers.d.cts +53 -0
- package/dist/layout/box-writers.d.ts +53 -0
- package/dist/layout/bundle-channel.d.cts +8 -0
- package/dist/layout/bundle-channel.d.ts +8 -0
- package/dist/layout/bundle-geometry.d.cts +163 -0
- package/dist/layout/bundle-geometry.d.ts +163 -0
- package/dist/layout/bundle-junctions.d.cts +41 -0
- package/dist/layout/bundle-junctions.d.ts +41 -0
- package/dist/layout/bundle-merge.d.cts +4 -0
- package/dist/layout/bundle-merge.d.ts +4 -0
- package/dist/layout/bundle-need.d.cts +23 -0
- package/dist/layout/bundle-need.d.ts +23 -0
- package/dist/layout/bundle-order.d.cts +10 -0
- package/dist/layout/bundle-order.d.ts +10 -0
- package/dist/layout/bundle-paths.d.cts +33 -0
- package/dist/layout/bundle-paths.d.ts +33 -0
- package/dist/layout/bundles.d.cts +5 -0
- package/dist/layout/bundles.d.ts +5 -0
- package/dist/layout/bus-room.d.cts +48 -0
- package/dist/layout/bus-room.d.ts +48 -0
- package/dist/layout/bus.d.cts +100 -0
- package/dist/layout/bus.d.ts +100 -0
- package/dist/layout/centre.d.cts +108 -0
- package/dist/layout/centre.d.ts +108 -0
- package/dist/layout/chord-boxes.d.cts +9 -0
- package/dist/layout/chord-boxes.d.ts +9 -0
- package/dist/layout/chord-clear.d.cts +32 -0
- package/dist/layout/chord-clear.d.ts +32 -0
- package/dist/layout/close-up.d.cts +37 -0
- package/dist/layout/close-up.d.ts +37 -0
- package/dist/layout/column-arrangement.d.cts +37 -0
- package/dist/layout/column-arrangement.d.ts +37 -0
- package/dist/layout/columns.d.cts +240 -0
- package/dist/layout/columns.d.ts +240 -0
- package/dist/layout/constraints/catalogue.d.cts +25 -0
- package/dist/layout/constraints/catalogue.d.ts +25 -0
- package/dist/layout/constraints/evaluate.d.cts +24 -0
- package/dist/layout/constraints/evaluate.d.ts +24 -0
- package/dist/layout/constraints/index.d.cts +8 -0
- package/dist/layout/constraints/index.d.ts +8 -0
- package/dist/layout/constraints/separation.d.cts +33 -0
- package/dist/layout/constraints/separation.d.ts +33 -0
- package/dist/layout/constraints/types.d.cts +65 -0
- package/dist/layout/constraints/types.d.ts +65 -0
- package/dist/layout/corridor-order.d.cts +61 -0
- package/dist/layout/corridor-order.d.ts +61 -0
- package/dist/layout/course-bypass.d.cts +63 -0
- package/dist/layout/course-bypass.d.ts +63 -0
- package/dist/layout/course-gap.d.cts +54 -0
- package/dist/layout/course-gap.d.ts +54 -0
- package/dist/layout/course-lanes.d.cts +79 -0
- package/dist/layout/course-lanes.d.ts +79 -0
- package/dist/layout/course-measure.d.cts +114 -0
- package/dist/layout/course-measure.d.ts +114 -0
- package/dist/layout/course-plan.d.cts +22 -0
- package/dist/layout/course-plan.d.ts +22 -0
- package/dist/layout/course-rows.d.cts +51 -0
- package/dist/layout/course-rows.d.ts +51 -0
- package/dist/layout/courses.d.cts +31 -0
- package/dist/layout/courses.d.ts +31 -0
- package/dist/layout/decide.d.cts +123 -0
- package/dist/layout/decide.d.ts +123 -0
- package/dist/layout/diagonal-text.d.cts +49 -0
- package/dist/layout/diagonal-text.d.ts +49 -0
- package/dist/layout/direct-families.d.cts +91 -0
- package/dist/layout/direct-families.d.ts +91 -0
- package/dist/layout/elk-graph.d.cts +36 -0
- package/dist/layout/elk-graph.d.ts +36 -0
- package/dist/layout/elk-worker.d.cts +34 -0
- package/dist/layout/elk-worker.d.ts +34 -0
- package/dist/layout/end-trim.d.cts +41 -0
- package/dist/layout/end-trim.d.ts +41 -0
- package/dist/layout/face-centre.d.cts +25 -0
- package/dist/layout/face-centre.d.ts +25 -0
- package/dist/layout/fan-admission.d.cts +47 -0
- package/dist/layout/fan-admission.d.ts +47 -0
- package/dist/layout/fan-spread.d.cts +43 -0
- package/dist/layout/fan-spread.d.ts +43 -0
- package/dist/layout/feed-order.d.cts +53 -0
- package/dist/layout/feed-order.d.ts +53 -0
- package/dist/layout/feed-split.d.cts +34 -0
- package/dist/layout/feed-split.d.ts +34 -0
- package/dist/layout/flanks.d.cts +21 -0
- package/dist/layout/flanks.d.ts +21 -0
- package/dist/layout/frame-paths.d.cts +209 -0
- package/dist/layout/frame-paths.d.ts +209 -0
- package/dist/layout/frames.d.cts +112 -0
- package/dist/layout/frames.d.ts +112 -0
- package/dist/layout/gap-band.d.cts +10 -0
- package/dist/layout/gap-band.d.ts +10 -0
- package/dist/layout/gap-plan.d.cts +229 -0
- package/dist/layout/gap-plan.d.ts +229 -0
- package/dist/layout/gap-room.d.cts +71 -0
- package/dist/layout/gap-room.d.ts +71 -0
- package/dist/layout/gap-runs.d.cts +95 -0
- package/dist/layout/gap-runs.d.ts +95 -0
- package/dist/layout/given-back.d.cts +23 -0
- package/dist/layout/given-back.d.ts +23 -0
- package/dist/layout/grid-chains.d.cts +84 -0
- package/dist/layout/grid-chains.d.ts +84 -0
- package/dist/layout/grid.d.cts +314 -0
- package/dist/layout/grid.d.ts +314 -0
- package/dist/layout/group-exit-check.d.cts +36 -0
- package/dist/layout/group-exit-check.d.ts +36 -0
- package/dist/layout/group-exits.d.cts +53 -0
- package/dist/layout/group-exits.d.ts +53 -0
- package/dist/layout/group-padding.d.cts +6 -0
- package/dist/layout/group-padding.d.ts +6 -0
- package/dist/layout/growth-guard.d.cts +25 -0
- package/dist/layout/growth-guard.d.ts +25 -0
- package/dist/layout/joint-order.d.cts +149 -0
- package/dist/layout/joint-order.d.ts +149 -0
- package/dist/layout/label-room-guard.d.cts +8 -0
- package/dist/layout/label-room-guard.d.ts +8 -0
- package/dist/layout/lane-kind.d.cts +11 -0
- package/dist/layout/lane-kind.d.ts +11 -0
- package/dist/layout/lanes.d.cts +278 -0
- package/dist/layout/lanes.d.ts +278 -0
- package/dist/layout/legend.d.cts +88 -0
- package/dist/layout/legend.d.ts +88 -0
- package/dist/layout/lift-judge.d.cts +28 -0
- package/dist/layout/lift-judge.d.ts +28 -0
- package/dist/layout/lift.d.cts +164 -0
- package/dist/layout/lift.d.ts +164 -0
- package/dist/layout/link-label-geometry.d.cts +32 -0
- package/dist/layout/link-label-geometry.d.ts +32 -0
- package/dist/layout/link-labels.d.cts +129 -0
- package/dist/layout/link-labels.d.ts +129 -0
- package/dist/layout/link-layer.d.cts +6 -0
- package/dist/layout/link-layer.d.ts +6 -0
- package/dist/layout/move-reservations.d.cts +49 -0
- package/dist/layout/move-reservations.d.ts +49 -0
- package/dist/layout/mutation.d.cts +32 -0
- package/dist/layout/mutation.d.ts +32 -0
- package/dist/layout/node-geometry.d.cts +3 -0
- package/dist/layout/node-geometry.d.ts +3 -0
- package/dist/layout/objective.d.cts +232 -0
- package/dist/layout/objective.d.ts +232 -0
- package/dist/layout/overlay-nest.d.cts +27 -0
- package/dist/layout/overlay-nest.d.ts +27 -0
- package/dist/layout/overlay-order.d.cts +140 -0
- package/dist/layout/overlay-order.d.ts +140 -0
- package/dist/layout/overlay-paths.d.cts +303 -0
- package/dist/layout/overlay-paths.d.ts +303 -0
- package/dist/layout/overlay-place.d.cts +99 -0
- package/dist/layout/overlay-place.d.ts +99 -0
- package/dist/layout/overlay-tracks.d.cts +93 -0
- package/dist/layout/overlay-tracks.d.ts +93 -0
- package/dist/layout/overlay-window.d.cts +83 -0
- package/dist/layout/overlay-window.d.ts +83 -0
- package/dist/layout/parallel-sets.d.cts +51 -0
- package/dist/layout/parallel-sets.d.ts +51 -0
- package/dist/layout/parent-stand.d.cts +40 -0
- package/dist/layout/parent-stand.d.ts +40 -0
- package/dist/layout/path-end.d.cts +34 -0
- package/dist/layout/path-end.d.ts +34 -0
- package/dist/layout/peers.d.cts +28 -0
- package/dist/layout/peers.d.ts +28 -0
- package/dist/layout/pill-reach.d.cts +14 -0
- package/dist/layout/pill-reach.d.ts +14 -0
- package/dist/layout/placement-attempt.d.cts +58 -0
- package/dist/layout/placement-attempt.d.ts +58 -0
- package/dist/layout/placement-refusal.d.cts +67 -0
- package/dist/layout/placement-refusal.d.ts +67 -0
- package/dist/layout/port-insets.d.cts +15 -0
- package/dist/layout/port-insets.d.ts +15 -0
- package/dist/layout/port-side.d.cts +8 -0
- package/dist/layout/port-side.d.ts +8 -0
- package/dist/layout/postconditions.d.cts +40 -0
- package/dist/layout/postconditions.d.ts +40 -0
- package/dist/layout/rank-cells.d.cts +24 -0
- package/dist/layout/rank-cells.d.ts +24 -0
- package/dist/layout/rank-input.d.cts +8 -0
- package/dist/layout/rank-input.d.ts +8 -0
- package/dist/layout/ranks.d.cts +36 -0
- package/dist/layout/ranks.d.ts +36 -0
- package/dist/layout/read/arrangement.d.cts +3 -0
- package/dist/layout/read/arrangement.d.ts +3 -0
- package/dist/layout/read/canton.d.cts +48 -0
- package/dist/layout/read/canton.d.ts +48 -0
- package/dist/layout/read/chain.d.cts +11 -0
- package/dist/layout/read/chain.d.ts +11 -0
- package/dist/layout/read/courses.d.cts +67 -0
- package/dist/layout/read/courses.d.ts +67 -0
- package/dist/layout/read/crossings.d.cts +79 -0
- package/dist/layout/read/crossings.d.ts +79 -0
- package/dist/layout/read/feeds.d.cts +53 -0
- package/dist/layout/read/feeds.d.ts +53 -0
- package/dist/layout/read/overlay-straight.d.cts +33 -0
- package/dist/layout/read/overlay-straight.d.ts +33 -0
- package/dist/layout/read/parent-spread.d.cts +13 -0
- package/dist/layout/read/parent-spread.d.ts +13 -0
- package/dist/layout/read/tier.d.cts +19 -0
- package/dist/layout/read/tier.d.ts +19 -0
- package/dist/layout/read/title-edge.d.cts +19 -0
- package/dist/layout/read/title-edge.d.ts +19 -0
- package/dist/layout/rectangle-index.d.cts +33 -0
- package/dist/layout/rectangle-index.d.ts +33 -0
- package/dist/layout/region-rebuild.d.cts +9 -0
- package/dist/layout/region-rebuild.d.ts +9 -0
- package/dist/layout/regions.d.cts +37 -0
- package/dist/layout/regions.d.ts +37 -0
- package/dist/layout/reservation-checks.d.cts +16 -0
- package/dist/layout/reservation-checks.d.ts +16 -0
- package/dist/layout/reservations.d.cts +267 -0
- package/dist/layout/reservations.d.ts +267 -0
- package/dist/layout/row-paths.d.cts +62 -0
- package/dist/layout/row-paths.d.ts +62 -0
- package/dist/layout/rows.d.cts +5 -0
- package/dist/layout/rows.d.ts +5 -0
- package/dist/layout/rule-geometry-hook.d.cts +5 -0
- package/dist/layout/rule-geometry-hook.d.ts +5 -0
- package/dist/layout/run-label-box.d.cts +139 -0
- package/dist/layout/run-label-box.d.ts +139 -0
- package/dist/layout/side-chords.d.cts +55 -0
- package/dist/layout/side-chords.d.ts +55 -0
- package/dist/layout/side-hints.d.cts +34 -0
- package/dist/layout/side-hints.d.ts +34 -0
- package/dist/layout/side-judge.d.cts +65 -0
- package/dist/layout/side-judge.d.ts +65 -0
- package/dist/layout/side-lanes.d.cts +27 -0
- package/dist/layout/side-lanes.d.ts +27 -0
- package/dist/layout/side-measure.d.cts +55 -0
- package/dist/layout/side-measure.d.ts +55 -0
- package/dist/layout/sides-one.d.cts +24 -0
- package/dist/layout/sides-one.d.ts +24 -0
- package/dist/layout/sides-two.d.cts +159 -0
- package/dist/layout/sides-two.d.ts +159 -0
- package/dist/layout/size.d.cts +114 -0
- package/dist/layout/size.d.ts +114 -0
- package/dist/layout/skeleton-geometry.d.cts +38 -0
- package/dist/layout/skeleton-geometry.d.ts +38 -0
- package/dist/layout/skeleton-graph.d.cts +33 -0
- package/dist/layout/skeleton-graph.d.ts +33 -0
- package/dist/layout/skeleton.d.cts +21 -0
- package/dist/layout/skeleton.d.ts +21 -0
- package/dist/layout/solid-blocks.d.cts +24 -0
- package/dist/layout/solid-blocks.d.ts +24 -0
- package/dist/layout/span-judge.d.cts +13 -0
- package/dist/layout/span-judge.d.ts +13 -0
- package/dist/layout/span-lanes.d.cts +37 -0
- package/dist/layout/span-lanes.d.ts +37 -0
- package/dist/layout/span-measure.d.cts +35 -0
- package/dist/layout/span-measure.d.ts +35 -0
- package/dist/layout/stagger.d.cts +40 -0
- package/dist/layout/stagger.d.ts +40 -0
- package/dist/layout/title-room.d.cts +50 -0
- package/dist/layout/title-room.d.ts +50 -0
- package/dist/layout/tolerance.d.cts +60 -0
- package/dist/layout/tolerance.d.ts +60 -0
- package/dist/layout/trial-copy.d.cts +9 -0
- package/dist/layout/trial-copy.d.ts +9 -0
- package/dist/layout/trial-findings.d.cts +25 -0
- package/dist/layout/trial-findings.d.ts +25 -0
- package/dist/layout/trunk.d.cts +69 -0
- package/dist/layout/trunk.d.ts +69 -0
- package/dist/layout/turn-measure.d.cts +42 -0
- package/dist/layout/turn-measure.d.ts +42 -0
- package/dist/layout/turn-order.d.cts +83 -0
- package/dist/layout/turn-order.d.ts +83 -0
- package/dist/migrate/index.d.cts +13 -0
- package/dist/migrate/index.d.ts +13 -0
- package/dist/model/classes.d.cts +21 -0
- package/dist/model/classes.d.ts +21 -0
- package/dist/model/document.d.cts +174 -0
- package/dist/model/document.d.ts +174 -0
- package/dist/model/geometry.d.cts +12 -0
- package/dist/model/geometry.d.ts +12 -0
- package/dist/model/index.d.cts +5 -0
- package/dist/model/index.d.ts +5 -0
- package/dist/model/json-equality.d.cts +2 -0
- package/dist/model/json-equality.d.ts +2 -0
- package/dist/model/layout.d.cts +1142 -0
- package/dist/model/layout.d.ts +1142 -0
- package/dist/model/link-ids.d.cts +16 -0
- package/dist/model/link-ids.d.ts +16 -0
- package/dist/model/model.d.cts +26 -0
- package/dist/model/model.d.ts +26 -0
- package/dist/model/read-cache.d.cts +20 -0
- package/dist/model/read-cache.d.ts +20 -0
- package/dist/node.cjs +43 -0
- package/dist/node.d.cts +6 -0
- package/dist/parse/css.d.cts +2 -0
- package/dist/parse/css.d.ts +2 -0
- package/dist/parse/index.d.cts +23 -0
- package/dist/parse/index.d.ts +23 -0
- package/dist/parse/link-order.d.cts +24 -0
- package/dist/parse/link-order.d.ts +24 -0
- package/dist/parse/validation.d.cts +39 -0
- package/dist/parse/validation.d.ts +39 -0
- package/dist/pipeline/budget.d.cts +28 -0
- package/dist/pipeline/budget.d.ts +28 -0
- package/dist/pipeline/deadline.d.cts +1 -0
- package/dist/pipeline/deadline.d.ts +1 -0
- package/dist/pipeline/driver.d.cts +14 -0
- package/dist/pipeline/driver.d.ts +14 -0
- package/dist/pipeline/env.d.cts +54 -0
- package/dist/pipeline/env.d.ts +54 -0
- package/dist/pipeline/index.d.cts +17 -0
- package/dist/pipeline/index.d.ts +17 -0
- package/dist/pipeline/initial.d.cts +3 -0
- package/dist/pipeline/initial.d.ts +3 -0
- package/dist/pipeline/lift-round.d.cts +9 -0
- package/dist/pipeline/lift-round.d.ts +9 -0
- package/dist/pipeline/limits.d.cts +16 -0
- package/dist/pipeline/limits.d.ts +16 -0
- package/dist/pipeline/options.d.cts +85 -0
- package/dist/pipeline/options.d.ts +85 -0
- package/dist/pipeline/place.d.cts +9 -0
- package/dist/pipeline/place.d.ts +9 -0
- package/dist/pipeline/publish.d.cts +4 -0
- package/dist/pipeline/publish.d.ts +4 -0
- package/dist/pipeline/round.d.cts +86 -0
- package/dist/pipeline/round.d.ts +86 -0
- package/dist/pipeline/rounds.d.cts +85 -0
- package/dist/pipeline/rounds.d.ts +85 -0
- package/dist/pipeline/state.d.cts +46 -0
- package/dist/pipeline/state.d.ts +46 -0
- package/dist/pipeline/width-budget.d.cts +6 -0
- package/dist/pipeline/width-budget.d.ts +6 -0
- package/dist/portograph-avoid-worker.mjs +260 -0
- package/dist/portograph.js +43369 -0
- package/dist/portograph.umd.cjs +154 -0
- package/dist/profiles/network/content.d.cts +29 -0
- package/dist/profiles/network/content.d.ts +29 -0
- package/dist/profiles/network/icons.d.cts +27 -0
- package/dist/profiles/network/icons.d.ts +27 -0
- package/dist/profiles/network/snack.d.cts +50 -0
- package/dist/profiles/network/snack.d.ts +50 -0
- package/dist/profiles/network/theme.d.cts +246 -0
- package/dist/profiles/network/theme.d.ts +246 -0
- package/dist/profiles/network/themes.d.cts +60 -0
- package/dist/profiles/network/themes.d.ts +60 -0
- package/dist/profiles/network/tiers.d.cts +8 -0
- package/dist/profiles/network/tiers.d.ts +8 -0
- package/dist/render/anonymous-end.d.cts +8 -0
- package/dist/render/anonymous-end.d.ts +8 -0
- package/dist/render/author-css.d.cts +9 -0
- package/dist/render/author-css.d.ts +9 -0
- package/dist/render/check-options.d.cts +8 -0
- package/dist/render/check-options.d.ts +8 -0
- package/dist/render/drawio.d.cts +35 -0
- package/dist/render/drawio.d.ts +35 -0
- package/dist/render/frame-order.d.cts +36 -0
- package/dist/render/frame-order.d.ts +36 -0
- package/dist/render/index.d.cts +19 -0
- package/dist/render/index.d.ts +19 -0
- package/dist/render/shared.d.cts +137 -0
- package/dist/render/shared.d.ts +137 -0
- package/dist/render/svg.d.cts +22 -0
- package/dist/render/svg.d.ts +22 -0
- package/dist/render/theme.d.cts +81 -0
- package/dist/render/theme.d.ts +81 -0
- package/dist/render/tooltips.d.cts +11 -0
- package/dist/render/tooltips.d.ts +11 -0
- package/dist/resolve/fan-family.d.cts +19 -0
- package/dist/resolve/fan-family.d.ts +19 -0
- package/dist/resolve/index.d.cts +30 -0
- package/dist/resolve/index.d.ts +30 -0
- package/dist/resolve/mesh-bus.d.cts +19 -0
- package/dist/resolve/mesh-bus.d.ts +19 -0
- package/dist/resolve/solid-blocks.d.cts +2 -0
- package/dist/resolve/solid-blocks.d.ts +2 -0
- package/dist/route/containment.d.cts +8 -0
- package/dist/route/containment.d.ts +8 -0
- package/dist/route/index.d.cts +48 -0
- package/dist/route/index.d.ts +48 -0
- package/dist/route/obstacles.d.cts +59 -0
- package/dist/route/obstacles.d.ts +59 -0
- package/dist/route/paths.d.cts +100 -0
- package/dist/route/paths.d.ts +100 -0
- package/dist/route/plan.d.cts +182 -0
- package/dist/route/plan.d.ts +182 -0
- package/dist/route/reservations.d.cts +15 -0
- package/dist/route/reservations.d.ts +15 -0
- package/dist/route/types.d.cts +59 -0
- package/dist/route/types.d.ts +59 -0
- package/dist/route/validate.d.cts +41 -0
- package/dist/route/validate.d.ts +41 -0
- package/dist/route/worker.d.cts +73 -0
- package/dist/route/worker.d.ts +73 -0
- package/dist/score/counts.d.cts +12 -0
- package/dist/score/counts.d.ts +12 -0
- package/dist/score/gates.d.cts +16 -0
- package/dist/score/gates.d.ts +16 -0
- package/dist/score/geometry.d.cts +2 -0
- package/dist/score/geometry.d.ts +2 -0
- package/dist/score/index.d.cts +5 -0
- package/dist/score/index.d.ts +5 -0
- package/dist/score/metrics.d.cts +7 -0
- package/dist/score/metrics.d.ts +7 -0
- package/dist/score/model.d.cts +76 -0
- package/dist/score/model.d.ts +76 -0
- package/dist/score/types.d.cts +135 -0
- package/dist/score/types.d.ts +135 -0
- package/dist/text/font-metrics.d.cts +9 -0
- package/dist/text/font-metrics.d.ts +9 -0
- package/dist/text/index.d.cts +32 -0
- package/dist/text/index.d.ts +32 -0
- package/dist/theme/content.d.cts +33 -0
- package/dist/theme/content.d.ts +33 -0
- package/dist/theme/geometry.d.cts +81 -0
- package/dist/theme/geometry.d.ts +81 -0
- package/dist/theme/legend.d.cts +26 -0
- package/dist/theme/legend.d.ts +26 -0
- package/dist/warm-elk.cjs +43 -0
- package/package.json +109 -4
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Diagnostic, LayoutModel } from '../model/index.cjs';
|
|
2
|
+
import { Reservations } from '../layout/reservations.cjs';
|
|
3
|
+
import { SideOffer } from '../layout/side-measure.cjs';
|
|
4
|
+
export interface State {
|
|
5
|
+
/** The kept result of stages 1 to 7e: the model a measure reads, and the key of the stage-3 sizes. */
|
|
6
|
+
kept7e: LayoutModel;
|
|
7
|
+
/** Set on a trial's tentative state (the span's fans): the model whose ELK fallback a re-run is compared with. */
|
|
8
|
+
fallbackFrom?: LayoutModel;
|
|
9
|
+
/** The kept result of stage 7f on `kept7e`: the baseline every offer is measured on. */
|
|
10
|
+
base: LayoutModel;
|
|
11
|
+
/** The routed baseline, and the routed result of the last kept trial. */
|
|
12
|
+
routedBase?: LayoutModel;
|
|
13
|
+
routedFinal?: LayoutModel;
|
|
14
|
+
/** What the 7f run of the baseline did, for phase 3b's trigger: whether it moved the placement, and its first settled copy. */
|
|
15
|
+
baseMoved: boolean;
|
|
16
|
+
baseUnmoved?: LayoutModel | undefined;
|
|
17
|
+
/** The ledger every placement run is told to keep. */
|
|
18
|
+
kept: Reservations;
|
|
19
|
+
/** The fan rounds' and the side round's cut notes, the notes of the kept rounds, and the notes of the side trials that were kept. */
|
|
20
|
+
cuts: Diagnostic[];
|
|
21
|
+
sideNotes: Diagnostic[];
|
|
22
|
+
keptNotes: Diagnostic[];
|
|
23
|
+
/** The side round: what each kept hint promised, the refused offers, the link of each hinted port, and whether the extra trial of the unmoved baseline is running. */
|
|
24
|
+
promised: SideOffer['promised'];
|
|
25
|
+
refused: Set<string>;
|
|
26
|
+
trialLinks: Map<string, string>;
|
|
27
|
+
silent: boolean;
|
|
28
|
+
/** The side measures made so far: the index of the round that measures next. */
|
|
29
|
+
sideRound: number;
|
|
30
|
+
/** Whether the unmoved baseline was rebuilt for a side offer: it is rebuilt at most once in a command. */
|
|
31
|
+
unmovedRebuilt: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The course round's second trial, set when its first trial is refused: `without-steps` when that trial held a step course beside a poor-route course (the
|
|
34
|
+
* second trial offers the poor routes alone), `none` otherwise (a second trial would repeat the first). Absent before the first refusal.
|
|
35
|
+
*/
|
|
36
|
+
courseRetry?: 'without-steps' | 'none';
|
|
37
|
+
}
|
|
38
|
+
/** One try of a round, built from its ledger: the 7e result, the 7f result, the routed result and what 7f did. */
|
|
39
|
+
export interface Trial {
|
|
40
|
+
ledger: Reservations;
|
|
41
|
+
trial7e: LayoutModel;
|
|
42
|
+
trial: LayoutModel;
|
|
43
|
+
routedTrial: LayoutModel;
|
|
44
|
+
moved: boolean;
|
|
45
|
+
unmoved: LayoutModel | undefined;
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Diagnostic, LayoutModel } from '../model/index.js';
|
|
2
|
+
import { Reservations } from '../layout/reservations.js';
|
|
3
|
+
import { SideOffer } from '../layout/side-measure.js';
|
|
4
|
+
export interface State {
|
|
5
|
+
/** The kept result of stages 1 to 7e: the model a measure reads, and the key of the stage-3 sizes. */
|
|
6
|
+
kept7e: LayoutModel;
|
|
7
|
+
/** Set on a trial's tentative state (the span's fans): the model whose ELK fallback a re-run is compared with. */
|
|
8
|
+
fallbackFrom?: LayoutModel;
|
|
9
|
+
/** The kept result of stage 7f on `kept7e`: the baseline every offer is measured on. */
|
|
10
|
+
base: LayoutModel;
|
|
11
|
+
/** The routed baseline, and the routed result of the last kept trial. */
|
|
12
|
+
routedBase?: LayoutModel;
|
|
13
|
+
routedFinal?: LayoutModel;
|
|
14
|
+
/** What the 7f run of the baseline did, for phase 3b's trigger: whether it moved the placement, and its first settled copy. */
|
|
15
|
+
baseMoved: boolean;
|
|
16
|
+
baseUnmoved?: LayoutModel | undefined;
|
|
17
|
+
/** The ledger every placement run is told to keep. */
|
|
18
|
+
kept: Reservations;
|
|
19
|
+
/** The fan rounds' and the side round's cut notes, the notes of the kept rounds, and the notes of the side trials that were kept. */
|
|
20
|
+
cuts: Diagnostic[];
|
|
21
|
+
sideNotes: Diagnostic[];
|
|
22
|
+
keptNotes: Diagnostic[];
|
|
23
|
+
/** The side round: what each kept hint promised, the refused offers, the link of each hinted port, and whether the extra trial of the unmoved baseline is running. */
|
|
24
|
+
promised: SideOffer['promised'];
|
|
25
|
+
refused: Set<string>;
|
|
26
|
+
trialLinks: Map<string, string>;
|
|
27
|
+
silent: boolean;
|
|
28
|
+
/** The side measures made so far: the index of the round that measures next. */
|
|
29
|
+
sideRound: number;
|
|
30
|
+
/** Whether the unmoved baseline was rebuilt for a side offer: it is rebuilt at most once in a command. */
|
|
31
|
+
unmovedRebuilt: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The course round's second trial, set when its first trial is refused: `without-steps` when that trial held a step course beside a poor-route course (the
|
|
34
|
+
* second trial offers the poor routes alone), `none` otherwise (a second trial would repeat the first). Absent before the first refusal.
|
|
35
|
+
*/
|
|
36
|
+
courseRetry?: 'without-steps' | 'none';
|
|
37
|
+
}
|
|
38
|
+
/** One try of a round, built from its ledger: the 7e result, the 7f result, the routed result and what 7f did. */
|
|
39
|
+
export interface Trial {
|
|
40
|
+
ledger: Reservations;
|
|
41
|
+
trial7e: LayoutModel;
|
|
42
|
+
trial: LayoutModel;
|
|
43
|
+
routedTrial: LayoutModel;
|
|
44
|
+
moved: boolean;
|
|
45
|
+
unmoved: LayoutModel | undefined;
|
|
46
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LayoutModel, StaggerRow } from '../model/layout.cjs';
|
|
2
|
+
import { NormalisedDocument } from '../model/document.cjs';
|
|
3
|
+
import { LayoutOptions } from './options.cjs';
|
|
4
|
+
type Run = (document: NormalisedDocument, options: LayoutOptions, rows?: StaggerRow[]) => Promise<LayoutModel>;
|
|
5
|
+
export declare function fitWidthBudget(input: NormalisedDocument, options: LayoutOptions, run: Run): Promise<LayoutModel>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { LayoutModel, StaggerRow } from '../model/layout.js';
|
|
2
|
+
import { NormalisedDocument } from '../model/document.js';
|
|
3
|
+
import { LayoutOptions } from './options.js';
|
|
4
|
+
type Run = (document: NormalisedDocument, options: LayoutOptions, rows?: StaggerRow[]) => Promise<LayoutModel>;
|
|
5
|
+
export declare function fitWidthBudget(input: NormalisedDocument, options: LayoutOptions, run: Run): Promise<LayoutModel>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* portograph libavoid worker (stage 8).
|
|
3
|
+
*
|
|
4
|
+
* `Router.processTransaction()` is synchronous WASM work, so it runs here in a real terminable
|
|
5
|
+
* worker: the host can kill this thread when the route budget expires. One message routes one
|
|
6
|
+
* batch with its own Router; the host owns batch order and every geometric decision. Nothing here
|
|
7
|
+
* reads the layout model, the filesystem or the current working directory — the host passes the
|
|
8
|
+
* module and WASM URLs it resolved.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** One initialization promise per module/WASM pair. `AvoidLib.load` only checks a finished instance. */
|
|
12
|
+
const runtimes = new Map();
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Load one libavoid runtime. Concurrent first calls share one promise, so the upstream loader
|
|
16
|
+
* cannot instantiate two modules; a failed load is evicted so a corrected URL can be retried.
|
|
17
|
+
*/
|
|
18
|
+
export function loadAvoid(moduleUrl, wasmUrl, importModule = specifier => import(specifier)) {
|
|
19
|
+
const key = JSON.stringify([moduleUrl, wasmUrl]);
|
|
20
|
+
let pending = runtimes.get(key);
|
|
21
|
+
if (pending === undefined) {
|
|
22
|
+
pending = (async () => {
|
|
23
|
+
const module = await importModule(moduleUrl);
|
|
24
|
+
const lib = module && module.AvoidLib;
|
|
25
|
+
if (!lib || typeof lib.load !== 'function' || typeof lib.getInstance !== 'function') {
|
|
26
|
+
throw new Error(`libavoid module ${moduleUrl} does not export AvoidLib`);
|
|
27
|
+
}
|
|
28
|
+
await lib.load(wasmUrl);
|
|
29
|
+
return lib.getInstance();
|
|
30
|
+
})();
|
|
31
|
+
pending.catch(() => { if (runtimes.get(key) === pending) runtimes.delete(key); });
|
|
32
|
+
runtimes.set(key, pending);
|
|
33
|
+
}
|
|
34
|
+
return pending;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** All directions; libavoid's ConnDirFlags are top 1, bottom 2, left 4, right 8. */
|
|
38
|
+
const ALL_DIRECTIONS = 15;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Collision tolerance. This is `EPS` in `src/score/geometry.ts`, and it must stay that value: the
|
|
42
|
+
* adapter has to reach the same answer as the host about a visited checkpoint, or it re-solves a
|
|
43
|
+
* route the host would have taken.
|
|
44
|
+
*/
|
|
45
|
+
const EPS = 1e-7;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Whether a segment touches a point, boundary contact included. This is `segmentRect` from
|
|
49
|
+
* `src/score/geometry.ts` against a rectangle of zero size, written out here because the worker
|
|
50
|
+
* loads as plain JavaScript and imports nothing from the library.
|
|
51
|
+
*/
|
|
52
|
+
function segmentTouches(from, to, point) {
|
|
53
|
+
let low = 0, high = 1;
|
|
54
|
+
for (const [origin, delta, at] of [[from.x, to.x - from.x, point.x], [from.y, to.y - from.y, point.y]]) {
|
|
55
|
+
if (delta === 0) { if (origin < at - EPS || origin > at + EPS) return false; }
|
|
56
|
+
else {
|
|
57
|
+
const a = (at - EPS - origin) / delta, b = (at + EPS - origin) / delta;
|
|
58
|
+
low = Math.max(low, Math.min(a, b));
|
|
59
|
+
high = Math.min(high, Math.max(a, b));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return low <= high;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Whether a returned polyline really passes through every checkpoint, in the order they were asked
|
|
67
|
+
* for. This is the host's own test — `polylineDistance` and `checkpointsHonoured` in
|
|
68
|
+
* `src/route/paths.ts` — repeated here so the adapter can see a dropped checkpoint while it can
|
|
69
|
+
* still ask again, and it must give the same answer the host will. Distance is measured along the
|
|
70
|
+
* whole route, not along one segment, so two checkpoints on one straight run stay ordered.
|
|
71
|
+
*/
|
|
72
|
+
export function checkpointsVisited(points, checkpoints) {
|
|
73
|
+
const at = (point, after) => {
|
|
74
|
+
let travelled = 0;
|
|
75
|
+
for (let index = 0; index + 1 < points.length; index++) {
|
|
76
|
+
const from = points[index], to = points[index + 1];
|
|
77
|
+
if (segmentTouches(from, to, point)) {
|
|
78
|
+
const reached = travelled + Math.hypot(point.x - from.x, point.y - from.y);
|
|
79
|
+
if (reached >= after - EPS) return reached;
|
|
80
|
+
}
|
|
81
|
+
travelled += Math.hypot(to.x - from.x, to.y - from.y);
|
|
82
|
+
}
|
|
83
|
+
return -1;
|
|
84
|
+
};
|
|
85
|
+
let cursor = -1;
|
|
86
|
+
for (const checkpoint of checkpoints) {
|
|
87
|
+
const reached = at(checkpoint, cursor);
|
|
88
|
+
if (reached < 0) return false;
|
|
89
|
+
cursor = reached;
|
|
90
|
+
}
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Exact straight visibility against the already expanded obstacle set. */
|
|
95
|
+
function directRoute(batch, connector) {
|
|
96
|
+
const endpoint = value => {
|
|
97
|
+
if (value.kind === 'point') return { x: value.x, y: value.y, directions: ALL_DIRECTIONS };
|
|
98
|
+
return batch.shapes.find(shape => shape.id === value.shape)?.pins?.find(pin => pin.classId === value.classId);
|
|
99
|
+
};
|
|
100
|
+
const a = endpoint(connector.from), b = endpoint(connector.to);
|
|
101
|
+
if (!a || !b || (a.x !== b.x && a.y !== b.y) || (a.x === b.x && a.y === b.y)) return;
|
|
102
|
+
const direction = a.x === b.x ? (b.y > a.y ? 2 : 1) : (b.x > a.x ? 8 : 4);
|
|
103
|
+
const opposite = ({ 1: 2, 2: 1, 4: 8, 8: 4 })[direction];
|
|
104
|
+
if (!(a.directions & direction) || !(b.directions & opposite)) return;
|
|
105
|
+
const vertical = a.x === b.x, axis = vertical ? 'y' : 'x', cross = vertical ? 'x' : 'y';
|
|
106
|
+
const sign = b[axis] > a[axis] ? 1 : -1;
|
|
107
|
+
let cursor = 0;
|
|
108
|
+
for (const checkpoint of connector.checkpoints || []) {
|
|
109
|
+
const distance = (checkpoint[axis] - a[axis]) * sign;
|
|
110
|
+
if (checkpoint[cross] !== a[cross] || distance < cursor || distance > (b[axis] - a[axis]) * sign
|
|
111
|
+
|| !((checkpoint.arrival ?? ALL_DIRECTIONS) & opposite)
|
|
112
|
+
|| !((checkpoint.departure ?? ALL_DIRECTIONS) & direction)) return;
|
|
113
|
+
cursor = distance;
|
|
114
|
+
}
|
|
115
|
+
for (const shape of batch.shapes) {
|
|
116
|
+
// A monotone outward segment can leave its source and enter its target, but no foreign shape.
|
|
117
|
+
if (connector.from.kind === 'pin' && shape.id === connector.from.shape) continue;
|
|
118
|
+
if (connector.to.kind === 'pin' && shape.id === connector.to.shape) continue;
|
|
119
|
+
const box = shape.bounds;
|
|
120
|
+
if (Math.max(a.x, b.x) >= box.x && Math.min(a.x, b.x) <= box.x + box.width
|
|
121
|
+
&& Math.max(a.y, b.y) >= box.y && Math.min(a.y, b.y) <= box.y + box.height) return;
|
|
122
|
+
}
|
|
123
|
+
return [{ x: a.x, y: a.y }, { x: b.x, y: b.y }];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Route one batch. Every shape, pin, endpoint and checkpoint is given by the host in absolute
|
|
128
|
+
* coordinates; obstacles already carry their clearance, so the shape buffer stays at 0.
|
|
129
|
+
*
|
|
130
|
+
* The Router destructor deletes its shapes, pins and connectors, so only the temporary value
|
|
131
|
+
* objects are released here.
|
|
132
|
+
*/
|
|
133
|
+
export function routeBatch(Avoid, batch) {
|
|
134
|
+
const router = new Avoid.Router(Avoid.RouterFlag.OrthogonalRouting.value);
|
|
135
|
+
const temporaries = [];
|
|
136
|
+
const track = value => { temporaries.push(value); return value; };
|
|
137
|
+
const point = (x, y) => track(new Avoid.Point(x, y));
|
|
138
|
+
try {
|
|
139
|
+
router.setRoutingParameter(Avoid.RoutingParameter.shapeBufferDistance, batch.shapeBufferDistance);
|
|
140
|
+
for (const [name, value] of Object.entries(batch.parameters || {})) {
|
|
141
|
+
const parameter = Avoid.RoutingParameter[name];
|
|
142
|
+
if (parameter === undefined) throw new Error(`Unknown libavoid routing parameter ${name}`);
|
|
143
|
+
router.setRoutingParameter(parameter, value);
|
|
144
|
+
}
|
|
145
|
+
const shapes = new Map();
|
|
146
|
+
for (const shape of batch.shapes) {
|
|
147
|
+
const box = shape.bounds;
|
|
148
|
+
if (shapes.has(shape.id)) throw new Error(`Duplicate obstacle id ${shape.id}`);
|
|
149
|
+
const rectangle = track(new Avoid.Rectangle(point(box.x, box.y), point(box.x + box.width, box.y + box.height)));
|
|
150
|
+
const ref = new Avoid.ShapeRef(router, rectangle);
|
|
151
|
+
shapes.set(shape.id, ref);
|
|
152
|
+
for (const pin of shape.pins || []) {
|
|
153
|
+
// Offsets are measured from the obstacle's top-left corner, so a pin stays on the drawn
|
|
154
|
+
// node boundary inside its expanded routing rectangle.
|
|
155
|
+
const created = new Avoid.ShapeConnectionPin(ref, pin.classId, pin.x - box.x, pin.y - box.y, false, 0, pin.directions);
|
|
156
|
+
created.setExclusive(pin.exclusive === true);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
const endpoint = value => {
|
|
160
|
+
if (value.kind === 'point') return track(new Avoid.ConnEnd(point(value.x, value.y)));
|
|
161
|
+
const shape = shapes.get(value.shape);
|
|
162
|
+
if (shape === undefined) throw new Error(`Connector endpoint references unknown obstacle ${value.shape}`);
|
|
163
|
+
return track(new Avoid.ConnEnd(shape, value.classId));
|
|
164
|
+
};
|
|
165
|
+
const setCheckpoints = (ref, checkpoints) => {
|
|
166
|
+
const vector = track(new Avoid.CheckpointVector());
|
|
167
|
+
for (const checkpoint of checkpoints) {
|
|
168
|
+
vector.push_back(track(new Avoid.Checkpoint(point(checkpoint.x, checkpoint.y),
|
|
169
|
+
checkpoint.arrival === undefined ? ALL_DIRECTIONS : checkpoint.arrival,
|
|
170
|
+
checkpoint.departure === undefined ? ALL_DIRECTIONS : checkpoint.departure)));
|
|
171
|
+
}
|
|
172
|
+
ref.setRoutingCheckpoints(vector);
|
|
173
|
+
};
|
|
174
|
+
const connectors = batch.connectors.map(connector => {
|
|
175
|
+
const direct = directRoute(batch, connector);
|
|
176
|
+
const ref = new Avoid.ConnRef(router, endpoint(connector.from), endpoint(connector.to));
|
|
177
|
+
// Collinear checkpoints are already on a clear direct route. Passing them to libavoid
|
|
178
|
+
// 0.5.0-beta.5 can truncate its result at the final checkpoint. Keep this connector in
|
|
179
|
+
// the transaction, but omit redundant hints; the host still checks every requested one.
|
|
180
|
+
const checkpoints = direct ? [] : connector.checkpoints || [];
|
|
181
|
+
if (checkpoints.length) setCheckpoints(ref, checkpoints);
|
|
182
|
+
// `asked` is what this connector currently holds; a retry below narrows it.
|
|
183
|
+
return { id: connector.id, ref, connector, checkpoints, asked: checkpoints };
|
|
184
|
+
});
|
|
185
|
+
router.processTransaction();
|
|
186
|
+
// `displayRoute()` and `at()` hand back independent native copies in this binding, so each one
|
|
187
|
+
// is released here; only the copied coordinates leave the worker.
|
|
188
|
+
const extract = ({ id, ref }) => {
|
|
189
|
+
const route = ref.displayRoute(), size = route.size(), points = [];
|
|
190
|
+
try {
|
|
191
|
+
for (let index = 0; index < size; index++) {
|
|
192
|
+
const at = route.at(index);
|
|
193
|
+
try { points.push({ x: at.x, y: at.y }); } finally { at.delete(); }
|
|
194
|
+
}
|
|
195
|
+
} finally { route.delete(); }
|
|
196
|
+
return { connector: id, points };
|
|
197
|
+
};
|
|
198
|
+
let routes = connectors.map(extract), retry = false;
|
|
199
|
+
for (const [index, item] of connectors.entries()) {
|
|
200
|
+
const points = routes[index].points, last = points.at(-1);
|
|
201
|
+
const checkpoint = item.checkpoints.at(-1);
|
|
202
|
+
if (!last || points.length < 2 || !checkpoint || last.x !== checkpoint.x || last.y !== checkpoint.y) continue;
|
|
203
|
+
// The same upstream defect can truncate a route at its final checkpoint, whether the missing
|
|
204
|
+
// leg continues the last segment straight or follows a bend. That leg is the destination's
|
|
205
|
+
// own stem — the checkpoint lies on the perpendicular from its anchor — so it is straight and
|
|
206
|
+
// clear by construction, and the hint is redundant. Re-solve once without it; never append a
|
|
207
|
+
// guessed endpoint to returned geometry. The host still checks every requested checkpoint.
|
|
208
|
+
const continuation = directRoute(batch, { from: { kind: 'point', ...checkpoint }, to: item.connector.to, checkpoints: [] });
|
|
209
|
+
if (!continuation) continue;
|
|
210
|
+
item.asked = item.checkpoints.slice(0, -1);
|
|
211
|
+
setCheckpoints(item.ref, item.asked);
|
|
212
|
+
retry = true;
|
|
213
|
+
}
|
|
214
|
+
if (retry) { router.processTransaction(); routes = connectors.map(extract); }
|
|
215
|
+
// A checkpoint carries two things: the point, which is a reservation the host verifies, and a
|
|
216
|
+
// direction mask, which is only a hint — `checkpointsHonoured` never reads it. This build drops
|
|
217
|
+
// the whole checkpoint, silently, when it cannot meet the mask, and the host then has to reject
|
|
218
|
+
// a route that missed a reservation. So when a checkpoint is missing from the answer, ask once
|
|
219
|
+
// more for the same points with no mask. Nothing here invents geometry: the host still checks
|
|
220
|
+
// every point it asked for, and still rejects the route when one is absent.
|
|
221
|
+
let relaxed = false;
|
|
222
|
+
for (const [index, item] of connectors.entries()) {
|
|
223
|
+
if (!item.asked.length || checkpointsVisited(routes[index].points, item.asked)) continue;
|
|
224
|
+
item.asked = item.asked.map(checkpoint => ({ ...checkpoint, arrival: ALL_DIRECTIONS, departure: ALL_DIRECTIONS }));
|
|
225
|
+
setCheckpoints(item.ref, item.asked);
|
|
226
|
+
relaxed = true;
|
|
227
|
+
}
|
|
228
|
+
if (relaxed) { router.processTransaction(); routes = connectors.map(extract); }
|
|
229
|
+
return routes;
|
|
230
|
+
} finally {
|
|
231
|
+
// Release every temporary even if one of them is already gone, so the Router itself is always
|
|
232
|
+
// deleted: it owns the shapes, pins and connectors and frees them in turn.
|
|
233
|
+
for (const value of temporaries.reverse()) {
|
|
234
|
+
try { value.delete(); } catch { /* already released */ }
|
|
235
|
+
}
|
|
236
|
+
router.delete();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export const ROUTE_REQUEST = 'portograph-route';
|
|
241
|
+
export const ROUTE_RESPONSE = 'portograph-routed';
|
|
242
|
+
|
|
243
|
+
/** Answer one host request. Failures reply; they never leave the host waiting for its deadline. */
|
|
244
|
+
export async function handleRouteMessage(message, reply) {
|
|
245
|
+
try {
|
|
246
|
+
const Avoid = await loadAvoid(message.moduleUrl, message.wasmUrl);
|
|
247
|
+
reply({ kind: ROUTE_RESPONSE, id: message.id, ok: true, routes: routeBatch(Avoid, message.batch) });
|
|
248
|
+
} catch (error) {
|
|
249
|
+
reply({ kind: ROUTE_RESPONSE, id: message.id, ok: false, error: String(error && error.message ? error.message : error) });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Registered only inside a real worker scope; importing this module elsewhere stays side-effect free.
|
|
254
|
+
if (typeof globalThis.addEventListener === 'function' && typeof globalThis.postMessage === 'function') {
|
|
255
|
+
globalThis.addEventListener('message', event => {
|
|
256
|
+
const message = event && event.data;
|
|
257
|
+
if (!message || message.kind !== ROUTE_REQUEST) return;
|
|
258
|
+
void handleRouteMessage(message, response => { globalThis.postMessage(response); });
|
|
259
|
+
});
|
|
260
|
+
}
|