@tscircuit/cli 0.1.1673 → 0.1.1675
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/build/build.worker.js +1 -1
- package/dist/cli/main.js +366 -259
- package/dist/lib/index.js +259 -165
- package/package.json +3 -3
package/dist/lib/index.js
CHANGED
|
@@ -39819,7 +39819,7 @@ var require_fast_uri = __commonJS((exports2, module2) => {
|
|
|
39819
39819
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
39820
39820
|
if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
39821
39821
|
try {
|
|
39822
|
-
parsed.host = URL
|
|
39822
|
+
parsed.host = new URL("http://" + parsed.host).hostname;
|
|
39823
39823
|
} catch (e) {
|
|
39824
39824
|
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
39825
39825
|
}
|
|
@@ -59949,6 +59949,7 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
59949
59949
|
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
59950
59950
|
var RETURN_FALSE = () => false;
|
|
59951
59951
|
var sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY);
|
|
59952
|
+
var negateRange = (range) => range.startsWith("!") || range.startsWith("\\^") ? `^${range.slice(range[0] === "!" ? 1 : 2)}` : range;
|
|
59952
59953
|
var cleanRangeBackSlash = (slashes) => {
|
|
59953
59954
|
const { length } = slashes;
|
|
59954
59955
|
return slashes.slice(0, length - length % 2);
|
|
@@ -59986,7 +59987,7 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
59986
59987
|
() => "\\/"
|
|
59987
59988
|
],
|
|
59988
59989
|
[
|
|
59989
|
-
|
|
59990
|
+
/^\^*(?:\\\*\\\*\\\/)+/,
|
|
59990
59991
|
() => "^(?:.*\\/)?"
|
|
59991
59992
|
],
|
|
59992
59993
|
[
|
|
@@ -60016,7 +60017,7 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
60016
60017
|
],
|
|
60017
60018
|
[
|
|
60018
60019
|
/(\\)?\[([^\]/]*?)(\\*)($|\])/g,
|
|
60019
|
-
(match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${sanitizeRange(range)}${endEscape}]` : "[]" : "[]"
|
|
60020
|
+
(match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${negateRange(sanitizeRange(range))}${endEscape}]` : "[]" : "[]"
|
|
60020
60021
|
],
|
|
60021
60022
|
[
|
|
60022
60023
|
/(?:[^*])$/,
|
|
@@ -65811,7 +65812,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
65811
65812
|
}));
|
|
65812
65813
|
};
|
|
65813
65814
|
// package.json
|
|
65814
|
-
var version = "0.1.
|
|
65815
|
+
var version = "0.1.1673";
|
|
65815
65816
|
var package_default = {
|
|
65816
65817
|
name: "@tscircuit/cli",
|
|
65817
65818
|
version,
|
|
@@ -65827,7 +65828,7 @@ var package_default = {
|
|
|
65827
65828
|
"@tscircuit/circuit-json-placement-analysis": "^0.0.6",
|
|
65828
65829
|
"@tscircuit/circuit-json-routing-analysis": "^0.0.6",
|
|
65829
65830
|
"@tscircuit/circuit-json-schematic-placement-analysis": "github:tscircuit/circuit-json-schematic-placement-analysis#b6d5fe675adc26a2fc988aa081e6fb51e6bf696a",
|
|
65830
|
-
"@tscircuit/eval": "^0.0.
|
|
65831
|
+
"@tscircuit/eval": "^0.0.1008",
|
|
65831
65832
|
"@tscircuit/fake-snippets": "^0.0.182",
|
|
65832
65833
|
"@tscircuit/file-server": "^0.0.32",
|
|
65833
65834
|
"@tscircuit/footprinter": "^0.0.374",
|
|
@@ -65893,7 +65894,7 @@ var package_default = {
|
|
|
65893
65894
|
semver: "^7.6.3",
|
|
65894
65895
|
stepts: "^0.0.3",
|
|
65895
65896
|
tempy: "^3.1.0",
|
|
65896
|
-
tscircuit: "0.0.
|
|
65897
|
+
tscircuit: "0.0.2084-libonly",
|
|
65897
65898
|
tsx: "^4.7.1",
|
|
65898
65899
|
"typed-ky": "^0.0.4",
|
|
65899
65900
|
zod: "^3.23.8"
|
|
@@ -68526,14 +68527,18 @@ import { cju as cju2 } from "@tscircuit/circuit-json-util";
|
|
|
68526
68527
|
import { compose as compose6, translate as translate6, scale as scale4 } from "transformation-matrix";
|
|
68527
68528
|
|
|
68528
68529
|
// node_modules/earcut/src/earcut.js
|
|
68530
|
+
var steiners = new Set;
|
|
68531
|
+
var filteredOut = false;
|
|
68529
68532
|
function earcut(data, holeIndices, dim = 2) {
|
|
68530
68533
|
const hasHoles = holeIndices && holeIndices.length;
|
|
68531
68534
|
const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
|
|
68535
|
+
if (steiners.size)
|
|
68536
|
+
steiners.clear();
|
|
68532
68537
|
let outerNode = linkedList(data, 0, outerLen, dim, true);
|
|
68533
68538
|
const triangles = [];
|
|
68534
68539
|
if (!outerNode || outerNode.next === outerNode.prev)
|
|
68535
68540
|
return triangles;
|
|
68536
|
-
let minX, minY, invSize;
|
|
68541
|
+
let minX = 0, minY = 0, invSize = 0;
|
|
68537
68542
|
if (hasHoles)
|
|
68538
68543
|
outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
|
|
68539
68544
|
if (data.length > 80 * dim) {
|
|
@@ -68556,11 +68561,11 @@ function earcut(data, holeIndices, dim = 2) {
|
|
|
68556
68561
|
invSize = Math.max(maxX - minX, maxY - minY);
|
|
68557
68562
|
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
68558
68563
|
}
|
|
68559
|
-
earcutLinked(outerNode, triangles,
|
|
68564
|
+
earcutLinked(outerNode, triangles, minX, minY, invSize);
|
|
68560
68565
|
return triangles;
|
|
68561
68566
|
}
|
|
68562
68567
|
function linkedList(data, start, end, dim, clockwise) {
|
|
68563
|
-
let last;
|
|
68568
|
+
let last = null;
|
|
68564
68569
|
if (clockwise === signedArea(data, start, end, dim) > 0) {
|
|
68565
68570
|
for (let i = start;i < end; i += dim)
|
|
68566
68571
|
last = insertNode(i / dim | 0, data[i], data[i + 1], last);
|
|
@@ -68574,93 +68579,79 @@ function linkedList(data, start, end, dim, clockwise) {
|
|
|
68574
68579
|
}
|
|
68575
68580
|
return last;
|
|
68576
68581
|
}
|
|
68577
|
-
function filterPoints(start, end) {
|
|
68578
|
-
|
|
68579
|
-
return start;
|
|
68580
|
-
if (!end)
|
|
68581
|
-
end = start;
|
|
68582
|
+
function filterPoints(start, end = start) {
|
|
68583
|
+
const full = end === start;
|
|
68582
68584
|
let p = start, again;
|
|
68583
68585
|
do {
|
|
68584
68586
|
again = false;
|
|
68585
|
-
if (
|
|
68587
|
+
if (p !== p.next && (steiners.size === 0 || !steiners.has(p)) && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
|
|
68588
|
+
if (full || p === end)
|
|
68589
|
+
end = p.prev;
|
|
68590
|
+
filteredOut = true;
|
|
68586
68591
|
removeNode(p);
|
|
68587
|
-
p =
|
|
68588
|
-
if (p === p.next)
|
|
68589
|
-
break;
|
|
68592
|
+
p = p.prev;
|
|
68590
68593
|
again = true;
|
|
68591
|
-
} else {
|
|
68594
|
+
} else if (full || p !== end) {
|
|
68592
68595
|
p = p.next;
|
|
68596
|
+
again = !full;
|
|
68593
68597
|
}
|
|
68594
68598
|
} while (again || p !== end);
|
|
68595
68599
|
return end;
|
|
68596
68600
|
}
|
|
68597
|
-
function earcutLinked(ear, triangles,
|
|
68598
|
-
if (
|
|
68599
|
-
return;
|
|
68600
|
-
if (!pass && invSize)
|
|
68601
|
+
function earcutLinked(ear, triangles, minX, minY, invSize) {
|
|
68602
|
+
if (invSize)
|
|
68601
68603
|
indexCurve(ear, minX, minY, invSize);
|
|
68602
|
-
let stop = ear;
|
|
68604
|
+
let stop = ear, cured = false;
|
|
68603
68605
|
while (ear.prev !== ear.next) {
|
|
68604
68606
|
const prev = ear.prev;
|
|
68605
68607
|
const next = ear.next;
|
|
68606
|
-
if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
|
|
68608
|
+
if (area(prev, ear, next) < 0 && (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear))) {
|
|
68607
68609
|
triangles.push(prev.i, ear.i, next.i);
|
|
68608
68610
|
removeNode(ear);
|
|
68609
|
-
ear = next
|
|
68610
|
-
stop = next
|
|
68611
|
+
ear = next;
|
|
68612
|
+
stop = next;
|
|
68611
68613
|
continue;
|
|
68612
68614
|
}
|
|
68613
68615
|
ear = next;
|
|
68614
68616
|
if (ear === stop) {
|
|
68615
|
-
|
|
68616
|
-
|
|
68617
|
-
|
|
68618
|
-
|
|
68619
|
-
|
|
68620
|
-
} else if (pass === 2) {
|
|
68621
|
-
splitEarcut(ear, triangles, dim, minX, minY, invSize);
|
|
68617
|
+
filteredOut = false;
|
|
68618
|
+
ear = filterPoints(ear);
|
|
68619
|
+
if (filteredOut) {
|
|
68620
|
+
stop = ear;
|
|
68621
|
+
continue;
|
|
68622
68622
|
}
|
|
68623
|
+
if (!cured) {
|
|
68624
|
+
ear = cureLocalIntersections(ear, triangles);
|
|
68625
|
+
stop = ear;
|
|
68626
|
+
cured = true;
|
|
68627
|
+
continue;
|
|
68628
|
+
}
|
|
68629
|
+
splitEarcut(ear, triangles, minX, minY, invSize);
|
|
68623
68630
|
break;
|
|
68624
68631
|
}
|
|
68625
68632
|
}
|
|
68626
68633
|
}
|
|
68627
68634
|
function isEar(ear) {
|
|
68628
|
-
const a = ear.prev, b = ear, c = ear.next;
|
|
68629
|
-
if (area(a, b, c) >= 0)
|
|
68630
|
-
return false;
|
|
68631
|
-
const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
68632
|
-
const x0 = Math.min(ax, bx, cx), y0 = Math.min(ay, by, cy), x1 = Math.max(ax, bx, cx), y1 = Math.max(ay, by, cy);
|
|
68635
|
+
const a = ear.prev, b = ear, c = ear.next, ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y, x0 = Math.min(ax, bx, cx), y0 = Math.min(ay, by, cy), x1 = Math.max(ax, bx, cx), y1 = Math.max(ay, by, cy);
|
|
68633
68636
|
let p = c.next;
|
|
68634
68637
|
while (p !== a) {
|
|
68635
|
-
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&
|
|
68638
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && !(ax === p.x && ay === p.y) && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
|
|
68636
68639
|
return false;
|
|
68637
68640
|
p = p.next;
|
|
68638
68641
|
}
|
|
68639
68642
|
return true;
|
|
68640
68643
|
}
|
|
68641
68644
|
function isEarHashed(ear, minX, minY, invSize) {
|
|
68642
|
-
const a = ear.prev, b = ear, c = ear.next;
|
|
68643
|
-
|
|
68644
|
-
return false;
|
|
68645
|
-
const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
|
|
68646
|
-
const x0 = Math.min(ax, bx, cx), y0 = Math.min(ay, by, cy), x1 = Math.max(ax, bx, cx), y1 = Math.max(ay, by, cy);
|
|
68647
|
-
const minZ = zOrder(x0, y0, minX, minY, invSize), maxZ = zOrder(x1, y1, minX, minY, invSize);
|
|
68648
|
-
let { prevZ: p, nextZ: n } = ear;
|
|
68649
|
-
while (p && p.z >= minZ && n && n.z <= maxZ) {
|
|
68650
|
-
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
|
|
68651
|
-
return false;
|
|
68652
|
-
p = p.prevZ;
|
|
68653
|
-
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
|
|
68654
|
-
return false;
|
|
68655
|
-
n = n.nextZ;
|
|
68656
|
-
}
|
|
68645
|
+
const a = ear.prev, b = ear, c = ear.next, ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y, x0 = Math.min(ax, bx, cx), y0 = Math.min(ay, by, cy), x1 = Math.max(ax, bx, cx), y1 = Math.max(ay, by, cy), minZ = zOrder(x0, y0, minX, minY, invSize), maxZ = zOrder(x1, y1, minX, minY, invSize);
|
|
68646
|
+
let p = ear.prevZ;
|
|
68657
68647
|
while (p && p.z >= minZ) {
|
|
68658
|
-
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !==
|
|
68648
|
+
if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== c && !(ax === p.x && ay === p.y) && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
|
|
68659
68649
|
return false;
|
|
68660
68650
|
p = p.prevZ;
|
|
68661
68651
|
}
|
|
68652
|
+
let n = ear.nextZ;
|
|
68662
68653
|
while (n && n.z <= maxZ) {
|
|
68663
|
-
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !==
|
|
68654
|
+
if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== c && !(ax === n.x && ay === n.y) && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
|
|
68664
68655
|
return false;
|
|
68665
68656
|
n = n.nextZ;
|
|
68666
68657
|
}
|
|
@@ -68668,19 +68659,21 @@ function isEarHashed(ear, minX, minY, invSize) {
|
|
|
68668
68659
|
}
|
|
68669
68660
|
function cureLocalIntersections(start, triangles) {
|
|
68670
68661
|
let p = start;
|
|
68662
|
+
let cured = false;
|
|
68671
68663
|
do {
|
|
68672
68664
|
const a = p.prev, b = p.next.next;
|
|
68673
|
-
if (
|
|
68665
|
+
if (intersects(a, p, p.next, b, false) && locallyInside(a, b) && locallyInside(b, a)) {
|
|
68674
68666
|
triangles.push(a.i, p.i, b.i);
|
|
68675
68667
|
removeNode(p);
|
|
68676
68668
|
removeNode(p.next);
|
|
68677
68669
|
p = start = b;
|
|
68670
|
+
cured = true;
|
|
68678
68671
|
}
|
|
68679
68672
|
p = p.next;
|
|
68680
68673
|
} while (p !== start);
|
|
68681
|
-
return filterPoints(p);
|
|
68674
|
+
return cured ? filterPoints(p) : p;
|
|
68682
68675
|
}
|
|
68683
|
-
function splitEarcut(start, triangles,
|
|
68676
|
+
function splitEarcut(start, triangles, minX, minY, invSize) {
|
|
68684
68677
|
let a = start;
|
|
68685
68678
|
do {
|
|
68686
68679
|
let b = a.next.next;
|
|
@@ -68689,8 +68682,8 @@ function splitEarcut(start, triangles, dim, minX, minY, invSize) {
|
|
|
68689
68682
|
let c = splitPolygon(a, b);
|
|
68690
68683
|
a = filterPoints(a, a.next);
|
|
68691
68684
|
c = filterPoints(c, c.next);
|
|
68692
|
-
earcutLinked(a, triangles,
|
|
68693
|
-
earcutLinked(c, triangles,
|
|
68685
|
+
earcutLinked(a, triangles, minX, minY, invSize);
|
|
68686
|
+
earcutLinked(c, triangles, minX, minY, invSize);
|
|
68694
68687
|
return;
|
|
68695
68688
|
}
|
|
68696
68689
|
b = b.next;
|
|
@@ -68698,6 +68691,7 @@ function splitEarcut(start, triangles, dim, minX, minY, invSize) {
|
|
|
68698
68691
|
a = a.next;
|
|
68699
68692
|
} while (a !== start);
|
|
68700
68693
|
}
|
|
68694
|
+
var indexActive = false;
|
|
68701
68695
|
function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
68702
68696
|
const queue = [];
|
|
68703
68697
|
for (let i = 0, len = holeIndices.length;i < len; i++) {
|
|
@@ -68705,26 +68699,21 @@ function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
|
68705
68699
|
const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
68706
68700
|
const list = linkedList(data, start, end, dim, false);
|
|
68707
68701
|
if (list === list.next)
|
|
68708
|
-
list
|
|
68702
|
+
steiners.add(list);
|
|
68709
68703
|
queue.push(getLeftmost(list));
|
|
68710
68704
|
}
|
|
68711
68705
|
queue.sort(compareXYSlope);
|
|
68706
|
+
buildBlockIndex(data.length / dim, holeIndices.length);
|
|
68707
|
+
indexSegment(outerNode, outerNode);
|
|
68708
|
+
indexActive = true;
|
|
68712
68709
|
for (let i = 0;i < queue.length; i++) {
|
|
68713
68710
|
outerNode = eliminateHole(queue[i], outerNode);
|
|
68714
68711
|
}
|
|
68715
|
-
|
|
68712
|
+
indexActive = false;
|
|
68713
|
+
return filterPoints(outerNode);
|
|
68716
68714
|
}
|
|
68717
68715
|
function compareXYSlope(a, b) {
|
|
68718
|
-
|
|
68719
|
-
if (result === 0) {
|
|
68720
|
-
result = a.y - b.y;
|
|
68721
|
-
if (result === 0) {
|
|
68722
|
-
const aSlope = (a.next.y - a.y) / (a.next.x - a.x);
|
|
68723
|
-
const bSlope = (b.next.y - b.y) / (b.next.x - b.x);
|
|
68724
|
-
result = aSlope - bSlope;
|
|
68725
|
-
}
|
|
68726
|
-
}
|
|
68727
|
-
return result;
|
|
68716
|
+
return a.x - b.x || a.y - b.y || (a.next.y - a.y) / (a.next.x - a.x) - (b.next.y - b.y) / (b.next.x - b.x);
|
|
68728
68717
|
}
|
|
68729
68718
|
function eliminateHole(hole, outerNode) {
|
|
68730
68719
|
const bridge = findHoleBridge(hole, outerNode);
|
|
@@ -68732,9 +68721,83 @@ function eliminateHole(hole, outerNode) {
|
|
|
68732
68721
|
return outerNode;
|
|
68733
68722
|
}
|
|
68734
68723
|
const bridgeReverse = splitPolygon(bridge, hole);
|
|
68724
|
+
const bridge2 = bridgeReverse.next;
|
|
68725
|
+
indexSegment(bridge, bridge2.next);
|
|
68735
68726
|
filterPoints(bridgeReverse, bridgeReverse.next);
|
|
68736
68727
|
return filterPoints(bridge, bridge.next);
|
|
68737
68728
|
}
|
|
68729
|
+
var K = 16;
|
|
68730
|
+
var blockBBox = new Float64Array(0);
|
|
68731
|
+
var numBlocks = 0;
|
|
68732
|
+
var blockHead = [];
|
|
68733
|
+
var blockStop = [];
|
|
68734
|
+
function buildBlockIndex(maxNodes, numHoles) {
|
|
68735
|
+
const maxBlocks = Math.ceil((maxNodes + 2 * numHoles) / K) + numHoles + 2;
|
|
68736
|
+
if (blockBBox.length < maxBlocks * 4)
|
|
68737
|
+
blockBBox = new Float64Array(maxBlocks * 4);
|
|
68738
|
+
numBlocks = 0;
|
|
68739
|
+
}
|
|
68740
|
+
function indexSegment(head, stop) {
|
|
68741
|
+
let p = head;
|
|
68742
|
+
do {
|
|
68743
|
+
const b = numBlocks++;
|
|
68744
|
+
blockHead[b] = p;
|
|
68745
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
68746
|
+
let k = 0;
|
|
68747
|
+
do {
|
|
68748
|
+
const c = p.next;
|
|
68749
|
+
p.z = b;
|
|
68750
|
+
if (p.x < minX)
|
|
68751
|
+
minX = p.x;
|
|
68752
|
+
if (p.x > maxX)
|
|
68753
|
+
maxX = p.x;
|
|
68754
|
+
if (p.y < minY)
|
|
68755
|
+
minY = p.y;
|
|
68756
|
+
if (p.y > maxY)
|
|
68757
|
+
maxY = p.y;
|
|
68758
|
+
if (c.x < minX)
|
|
68759
|
+
minX = c.x;
|
|
68760
|
+
if (c.x > maxX)
|
|
68761
|
+
maxX = c.x;
|
|
68762
|
+
if (c.y < minY)
|
|
68763
|
+
minY = c.y;
|
|
68764
|
+
if (c.y > maxY)
|
|
68765
|
+
maxY = c.y;
|
|
68766
|
+
p = c;
|
|
68767
|
+
} while (++k < K && p !== stop);
|
|
68768
|
+
blockStop[b] = p;
|
|
68769
|
+
const g = b * 4;
|
|
68770
|
+
blockBBox[g] = minX;
|
|
68771
|
+
blockBBox[g + 1] = minY;
|
|
68772
|
+
blockBBox[g + 2] = maxX;
|
|
68773
|
+
blockBBox[g + 3] = maxY;
|
|
68774
|
+
} while (p !== stop);
|
|
68775
|
+
}
|
|
68776
|
+
function growBlock(head, tail) {
|
|
68777
|
+
const g = head.z * 4;
|
|
68778
|
+
if (tail.x < blockBBox[g])
|
|
68779
|
+
blockBBox[g] = tail.x;
|
|
68780
|
+
if (tail.y < blockBBox[g + 1])
|
|
68781
|
+
blockBBox[g + 1] = tail.y;
|
|
68782
|
+
if (tail.x > blockBBox[g + 2])
|
|
68783
|
+
blockBBox[g + 2] = tail.x;
|
|
68784
|
+
if (tail.y > blockBBox[g + 3])
|
|
68785
|
+
blockBBox[g + 3] = tail.y;
|
|
68786
|
+
}
|
|
68787
|
+
function liveBlockStop(b) {
|
|
68788
|
+
let stop = blockStop[b];
|
|
68789
|
+
while (stop.prev.next !== stop)
|
|
68790
|
+
stop = stop.next;
|
|
68791
|
+
blockStop[b] = stop;
|
|
68792
|
+
return stop;
|
|
68793
|
+
}
|
|
68794
|
+
function liveBlockHead(b) {
|
|
68795
|
+
let head = blockHead[b];
|
|
68796
|
+
while (head.prev.next !== head)
|
|
68797
|
+
head = head.next;
|
|
68798
|
+
blockHead[b] = head;
|
|
68799
|
+
return head;
|
|
68800
|
+
}
|
|
68738
68801
|
function findHoleBridge(hole, outerNode) {
|
|
68739
68802
|
let p = outerNode;
|
|
68740
68803
|
const hx = hole.x;
|
|
@@ -68743,98 +68806,121 @@ function findHoleBridge(hole, outerNode) {
|
|
|
68743
68806
|
let m;
|
|
68744
68807
|
if (equals(hole, p))
|
|
68745
68808
|
return p;
|
|
68746
|
-
|
|
68747
|
-
if (
|
|
68748
|
-
|
|
68749
|
-
|
|
68750
|
-
|
|
68751
|
-
|
|
68752
|
-
|
|
68753
|
-
|
|
68754
|
-
|
|
68755
|
-
|
|
68809
|
+
for (let b = 0, g = 0;b < numBlocks; b++, g += 4) {
|
|
68810
|
+
if (hy < blockBBox[g + 1] || hy > blockBBox[g + 3] || blockBBox[g] > hx || blockBBox[g + 2] <= qx)
|
|
68811
|
+
continue;
|
|
68812
|
+
const stop = liveBlockStop(b);
|
|
68813
|
+
p = liveBlockHead(b);
|
|
68814
|
+
do {
|
|
68815
|
+
if (p.prev.next === p) {
|
|
68816
|
+
if (equals(hole, p.next))
|
|
68817
|
+
return p.next;
|
|
68818
|
+
else if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
|
|
68819
|
+
const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
68820
|
+
if (x <= hx && x > qx) {
|
|
68821
|
+
qx = x;
|
|
68822
|
+
m = p.x < p.next.x ? p : p.next;
|
|
68823
|
+
if (x === hx)
|
|
68824
|
+
return m;
|
|
68825
|
+
}
|
|
68826
|
+
}
|
|
68756
68827
|
}
|
|
68757
|
-
|
|
68758
|
-
p
|
|
68759
|
-
}
|
|
68828
|
+
p = p.next;
|
|
68829
|
+
} while (p !== stop);
|
|
68830
|
+
}
|
|
68760
68831
|
if (!m)
|
|
68761
68832
|
return null;
|
|
68762
|
-
const stop = m;
|
|
68763
68833
|
const mx = m.x;
|
|
68764
68834
|
const my = m.y;
|
|
68835
|
+
const tminY = Math.min(hy, my);
|
|
68836
|
+
const tmaxY = Math.max(hy, my);
|
|
68765
68837
|
let tanMin = Infinity;
|
|
68766
|
-
|
|
68767
|
-
|
|
68768
|
-
|
|
68769
|
-
|
|
68770
|
-
|
|
68771
|
-
|
|
68772
|
-
|
|
68838
|
+
for (let b = 0, g = 0;b < numBlocks; b++, g += 4) {
|
|
68839
|
+
if (blockBBox[g + 2] < mx || blockBBox[g] > hx || blockBBox[g + 3] < tminY || blockBBox[g + 1] > tmaxY)
|
|
68840
|
+
continue;
|
|
68841
|
+
const stop = liveBlockStop(b);
|
|
68842
|
+
p = liveBlockHead(b);
|
|
68843
|
+
do {
|
|
68844
|
+
if (p.prev.next === p && hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
|
|
68845
|
+
const tan = Math.abs(hy - p.y) / (hx - p.x);
|
|
68846
|
+
if ((locallyInside(p, hole) || p.y === hy && p.next.y === hy && p.next.x > hx) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
|
|
68847
|
+
m = p;
|
|
68848
|
+
tanMin = tan;
|
|
68849
|
+
}
|
|
68773
68850
|
}
|
|
68774
|
-
|
|
68775
|
-
p
|
|
68776
|
-
}
|
|
68851
|
+
p = p.next;
|
|
68852
|
+
} while (p !== stop);
|
|
68853
|
+
}
|
|
68777
68854
|
return m;
|
|
68778
68855
|
}
|
|
68779
68856
|
function sectorContainsSector(m, p) {
|
|
68780
68857
|
return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
|
|
68781
68858
|
}
|
|
68859
|
+
var sortArr = [];
|
|
68860
|
+
var sortBuf = [];
|
|
68861
|
+
var zArr = new Uint32Array(0);
|
|
68862
|
+
var zBuf = new Uint32Array(0);
|
|
68863
|
+
var counts = new Uint32Array(256);
|
|
68782
68864
|
function indexCurve(start, minX, minY, invSize) {
|
|
68783
68865
|
let p = start;
|
|
68866
|
+
let n = 0;
|
|
68784
68867
|
do {
|
|
68785
|
-
|
|
68786
|
-
|
|
68787
|
-
p.prevZ = p.prev;
|
|
68788
|
-
p.nextZ = p.next;
|
|
68868
|
+
p.z = zOrder(p.x, p.y, minX, minY, invSize);
|
|
68869
|
+
sortArr[n++] = p;
|
|
68789
68870
|
p = p.next;
|
|
68790
68871
|
} while (p !== start);
|
|
68791
|
-
|
|
68792
|
-
|
|
68793
|
-
|
|
68872
|
+
sortNodes(n);
|
|
68873
|
+
let prev = null;
|
|
68874
|
+
for (let i = 0;i < n; i++) {
|
|
68875
|
+
const node = sortArr[i];
|
|
68876
|
+
node.prevZ = prev;
|
|
68877
|
+
if (prev)
|
|
68878
|
+
prev.nextZ = node;
|
|
68879
|
+
prev = node;
|
|
68880
|
+
}
|
|
68881
|
+
prev.nextZ = null;
|
|
68794
68882
|
}
|
|
68795
|
-
function
|
|
68796
|
-
|
|
68797
|
-
|
|
68798
|
-
|
|
68799
|
-
|
|
68800
|
-
|
|
68801
|
-
|
|
68802
|
-
|
|
68803
|
-
numMerges = 0;
|
|
68804
|
-
while (p) {
|
|
68805
|
-
numMerges++;
|
|
68806
|
-
let q = p;
|
|
68807
|
-
let pSize = 0;
|
|
68808
|
-
for (let i = 0;i < inSize; i++) {
|
|
68809
|
-
pSize++;
|
|
68810
|
-
q = q.nextZ;
|
|
68811
|
-
if (!q)
|
|
68812
|
-
break;
|
|
68883
|
+
function sortNodes(n) {
|
|
68884
|
+
if (n <= 32) {
|
|
68885
|
+
for (let i = 1;i < n; i++) {
|
|
68886
|
+
const node = sortArr[i], z21 = node.z;
|
|
68887
|
+
let j = i - 1;
|
|
68888
|
+
while (j >= 0 && sortArr[j].z > z21) {
|
|
68889
|
+
sortArr[j + 1] = sortArr[j];
|
|
68890
|
+
j--;
|
|
68813
68891
|
}
|
|
68814
|
-
|
|
68815
|
-
while (pSize > 0 || qSize > 0 && q) {
|
|
68816
|
-
if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
|
|
68817
|
-
e = p;
|
|
68818
|
-
p = p.nextZ;
|
|
68819
|
-
pSize--;
|
|
68820
|
-
} else {
|
|
68821
|
-
e = q;
|
|
68822
|
-
q = q.nextZ;
|
|
68823
|
-
qSize--;
|
|
68824
|
-
}
|
|
68825
|
-
if (tail)
|
|
68826
|
-
tail.nextZ = e;
|
|
68827
|
-
else
|
|
68828
|
-
list = e;
|
|
68829
|
-
e.prevZ = tail;
|
|
68830
|
-
tail = e;
|
|
68831
|
-
}
|
|
68832
|
-
p = q;
|
|
68892
|
+
sortArr[j + 1] = node;
|
|
68833
68893
|
}
|
|
68834
|
-
|
|
68835
|
-
|
|
68836
|
-
|
|
68837
|
-
|
|
68894
|
+
return;
|
|
68895
|
+
}
|
|
68896
|
+
if (zArr.length < n) {
|
|
68897
|
+
zArr = new Uint32Array(n);
|
|
68898
|
+
zBuf = new Uint32Array(n);
|
|
68899
|
+
sortBuf = new Array(n);
|
|
68900
|
+
}
|
|
68901
|
+
for (let i = 0;i < n; i++)
|
|
68902
|
+
zArr[i] = sortArr[i].z;
|
|
68903
|
+
radixPass(n, sortArr, zArr, sortBuf, zBuf, 0);
|
|
68904
|
+
radixPass(n, sortBuf, zBuf, sortArr, zArr, 8);
|
|
68905
|
+
radixPass(n, sortArr, zArr, sortBuf, zBuf, 16);
|
|
68906
|
+
radixPass(n, sortBuf, zBuf, sortArr, zArr, 24);
|
|
68907
|
+
}
|
|
68908
|
+
function radixPass(n, src, srcZ, dst, dstZ, shift) {
|
|
68909
|
+
counts.fill(0);
|
|
68910
|
+
for (let i = 0;i < n; i++)
|
|
68911
|
+
counts[srcZ[i] >>> shift & 255]++;
|
|
68912
|
+
let sum = 0;
|
|
68913
|
+
for (let b = 0;b < 256; b++) {
|
|
68914
|
+
const c = counts[b];
|
|
68915
|
+
counts[b] = sum;
|
|
68916
|
+
sum += c;
|
|
68917
|
+
}
|
|
68918
|
+
for (let i = 0;i < n; i++) {
|
|
68919
|
+
const z21 = srcZ[i];
|
|
68920
|
+
const pos = counts[z21 >>> shift & 255]++;
|
|
68921
|
+
dst[pos] = src[i];
|
|
68922
|
+
dstZ[pos] = z21;
|
|
68923
|
+
}
|
|
68838
68924
|
}
|
|
68839
68925
|
function zOrder(x, y, minX, minY, invSize) {
|
|
68840
68926
|
x = (x - minX) * invSize | 0;
|
|
@@ -68861,11 +68947,9 @@ function getLeftmost(start) {
|
|
|
68861
68947
|
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
68862
68948
|
return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
|
|
68863
68949
|
}
|
|
68864
|
-
function pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, px, py) {
|
|
68865
|
-
return !(ax === px && ay === py) && pointInTriangle(ax, ay, bx, by, cx, cy, px, py);
|
|
68866
|
-
}
|
|
68867
68950
|
function isValidDiagonal(a, b) {
|
|
68868
|
-
|
|
68951
|
+
const zeroLength = equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0;
|
|
68952
|
+
return a.next.i !== b.i && (zeroLength || locallyInside(a, b) && locallyInside(b, a) && (area(a.prev, a, b.prev) !== 0 || area(a, b.prev, b) !== 0)) && !intersectsPolygon(a, b) && (zeroLength || middleInside(a, b));
|
|
68869
68953
|
}
|
|
68870
68954
|
function area(p, q, r) {
|
|
68871
68955
|
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
@@ -68873,13 +68957,15 @@ function area(p, q, r) {
|
|
|
68873
68957
|
function equals(p1, p2) {
|
|
68874
68958
|
return p1.x === p2.x && p1.y === p2.y;
|
|
68875
68959
|
}
|
|
68876
|
-
function intersects(p1, q1, p2, q2) {
|
|
68877
|
-
const o1 =
|
|
68878
|
-
const o2 =
|
|
68879
|
-
const o3 =
|
|
68880
|
-
const o4 =
|
|
68881
|
-
if (o1
|
|
68960
|
+
function intersects(p1, q1, p2, q2, includeBoundary = true) {
|
|
68961
|
+
const o1 = area(p1, q1, p2);
|
|
68962
|
+
const o2 = area(p1, q1, q2);
|
|
68963
|
+
const o3 = area(p2, q2, p1);
|
|
68964
|
+
const o4 = area(p2, q2, q1);
|
|
68965
|
+
if ((o1 > 0 && o2 < 0 || o1 < 0 && o2 > 0) && (o3 > 0 && o4 < 0 || o3 < 0 && o4 > 0))
|
|
68882
68966
|
return true;
|
|
68967
|
+
if (!includeBoundary)
|
|
68968
|
+
return false;
|
|
68883
68969
|
if (o1 === 0 && onSegment(p1, p2, q1))
|
|
68884
68970
|
return true;
|
|
68885
68971
|
if (o2 === 0 && onSegment(p1, q2, q1))
|
|
@@ -68893,15 +68979,21 @@ function intersects(p1, q1, p2, q2) {
|
|
|
68893
68979
|
function onSegment(p, q, r) {
|
|
68894
68980
|
return q.x <= Math.max(p.x, r.x) && q.x >= Math.min(p.x, r.x) && q.y <= Math.max(p.y, r.y) && q.y >= Math.min(p.y, r.y);
|
|
68895
68981
|
}
|
|
68896
|
-
function sign(num) {
|
|
68897
|
-
return num > 0 ? 1 : num < 0 ? -1 : 0;
|
|
68898
|
-
}
|
|
68899
68982
|
function intersectsPolygon(a, b) {
|
|
68983
|
+
const minX = Math.min(a.x, b.x);
|
|
68984
|
+
const maxX = Math.max(a.x, b.x);
|
|
68985
|
+
const minY = Math.min(a.y, b.y);
|
|
68986
|
+
const maxY = Math.max(a.y, b.y);
|
|
68900
68987
|
let p = a;
|
|
68901
68988
|
do {
|
|
68902
|
-
|
|
68989
|
+
const n = p.next;
|
|
68990
|
+
if (p.x > maxX && n.x > maxX || p.x < minX && n.x < minX || p.y > maxY && n.y > maxY || p.y < minY && n.y < minY) {
|
|
68991
|
+
p = n;
|
|
68992
|
+
continue;
|
|
68993
|
+
}
|
|
68994
|
+
if (p.i !== a.i && n.i !== a.i && p.i !== b.i && n.i !== b.i && intersects(p, n, a, b))
|
|
68903
68995
|
return true;
|
|
68904
|
-
p =
|
|
68996
|
+
p = n;
|
|
68905
68997
|
} while (p !== a);
|
|
68906
68998
|
return false;
|
|
68907
68999
|
}
|
|
@@ -68914,9 +69006,10 @@ function middleInside(a, b) {
|
|
|
68914
69006
|
const px = (a.x + b.x) / 2;
|
|
68915
69007
|
const py = (a.y + b.y) / 2;
|
|
68916
69008
|
do {
|
|
68917
|
-
|
|
69009
|
+
const n = p.next;
|
|
69010
|
+
if (p.y > py !== n.y > py && px < (n.x - p.x) * (py - p.y) / (n.y - p.y) + p.x)
|
|
68918
69011
|
inside = !inside;
|
|
68919
|
-
p =
|
|
69012
|
+
p = n;
|
|
68920
69013
|
} while (p !== a);
|
|
68921
69014
|
return inside;
|
|
68922
69015
|
}
|
|
@@ -68952,6 +69045,8 @@ function removeNode(p) {
|
|
|
68952
69045
|
p.prevZ.nextZ = p.nextZ;
|
|
68953
69046
|
if (p.nextZ)
|
|
68954
69047
|
p.nextZ.prevZ = p.prevZ;
|
|
69048
|
+
if (indexActive)
|
|
69049
|
+
growBlock(p.prev, p.next);
|
|
68955
69050
|
}
|
|
68956
69051
|
function createNode(i, x, y) {
|
|
68957
69052
|
return {
|
|
@@ -68962,8 +69057,7 @@ function createNode(i, x, y) {
|
|
|
68962
69057
|
next: null,
|
|
68963
69058
|
z: 0,
|
|
68964
69059
|
prevZ: null,
|
|
68965
|
-
nextZ: null
|
|
68966
|
-
steiner: false
|
|
69060
|
+
nextZ: null
|
|
68967
69061
|
};
|
|
68968
69062
|
}
|
|
68969
69063
|
function signedArea(data, start, end, dim) {
|