@tscircuit/cli 0.1.2410 → 0.1.2412
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 +1417 -138
- package/dist/cli/main.js +2 -2
- package/dist/cli/snapshot/snapshot.worker.js +1417 -138
- package/dist/lib/index.js +1342 -1343
- package/package.json +8 -6
- package/types/tscircuit.config.schema.json +8 -0
package/dist/lib/index.js
CHANGED
|
@@ -45307,6 +45307,651 @@ var require_semver2 = __commonJS2(function(exports2, module2) {
|
|
|
45307
45307
|
};
|
|
45308
45308
|
});
|
|
45309
45309
|
|
|
45310
|
+
// node_modules/earcut/src/earcut.js
|
|
45311
|
+
function earcut(data, holeIndices, dim = 2) {
|
|
45312
|
+
const hasHoles = holeIndices && holeIndices.length;
|
|
45313
|
+
const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
|
|
45314
|
+
if (steiners.size)
|
|
45315
|
+
steiners.clear();
|
|
45316
|
+
let outerNode = linkedList(data, 0, outerLen, dim, true);
|
|
45317
|
+
const triangles = [];
|
|
45318
|
+
if (!outerNode || outerNode.next === outerNode.prev)
|
|
45319
|
+
return triangles;
|
|
45320
|
+
let minX = 0, minY = 0, invSize = 0;
|
|
45321
|
+
if (hasHoles)
|
|
45322
|
+
outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
|
|
45323
|
+
if (data.length > 80 * dim) {
|
|
45324
|
+
minX = data[0];
|
|
45325
|
+
minY = data[1];
|
|
45326
|
+
let maxX = minX;
|
|
45327
|
+
let maxY = minY;
|
|
45328
|
+
for (let i = dim;i < outerLen; i += dim) {
|
|
45329
|
+
const x = data[i];
|
|
45330
|
+
const y = data[i + 1];
|
|
45331
|
+
if (x < minX)
|
|
45332
|
+
minX = x;
|
|
45333
|
+
if (y < minY)
|
|
45334
|
+
minY = y;
|
|
45335
|
+
if (x > maxX)
|
|
45336
|
+
maxX = x;
|
|
45337
|
+
if (y > maxY)
|
|
45338
|
+
maxY = y;
|
|
45339
|
+
}
|
|
45340
|
+
invSize = Math.max(maxX - minX, maxY - minY);
|
|
45341
|
+
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
45342
|
+
}
|
|
45343
|
+
earcutLinked(outerNode, triangles, minX, minY, invSize);
|
|
45344
|
+
return triangles;
|
|
45345
|
+
}
|
|
45346
|
+
function linkedList(data, start, end, dim, clockwise) {
|
|
45347
|
+
let last = null;
|
|
45348
|
+
if (clockwise === signedArea(data, start, end, dim) > 0) {
|
|
45349
|
+
for (let i = start;i < end; i += dim)
|
|
45350
|
+
last = insertNode(i / dim | 0, data[i], data[i + 1], last);
|
|
45351
|
+
} else {
|
|
45352
|
+
for (let i = end - dim;i >= start; i -= dim)
|
|
45353
|
+
last = insertNode(i / dim | 0, data[i], data[i + 1], last);
|
|
45354
|
+
}
|
|
45355
|
+
if (last && equals(last, last.next)) {
|
|
45356
|
+
removeNode(last);
|
|
45357
|
+
last = last.next;
|
|
45358
|
+
}
|
|
45359
|
+
return last;
|
|
45360
|
+
}
|
|
45361
|
+
function filterPoints(start, end = start) {
|
|
45362
|
+
const full = end === start;
|
|
45363
|
+
let p = start, again;
|
|
45364
|
+
do {
|
|
45365
|
+
again = false;
|
|
45366
|
+
if (p !== p.next && (steiners.size === 0 || !steiners.has(p)) && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
|
|
45367
|
+
if (full || p === end)
|
|
45368
|
+
end = p.prev;
|
|
45369
|
+
filteredOut = true;
|
|
45370
|
+
removeNode(p);
|
|
45371
|
+
p = p.prev;
|
|
45372
|
+
again = true;
|
|
45373
|
+
} else if (full || p !== end) {
|
|
45374
|
+
p = p.next;
|
|
45375
|
+
again = !full;
|
|
45376
|
+
}
|
|
45377
|
+
} while (again || p !== end);
|
|
45378
|
+
return end;
|
|
45379
|
+
}
|
|
45380
|
+
function earcutLinked(ear, triangles, minX, minY, invSize) {
|
|
45381
|
+
if (invSize)
|
|
45382
|
+
indexCurve(ear, minX, minY, invSize);
|
|
45383
|
+
let stop = ear, cured = false;
|
|
45384
|
+
while (ear.prev !== ear.next) {
|
|
45385
|
+
const prev = ear.prev;
|
|
45386
|
+
const next = ear.next;
|
|
45387
|
+
if (area(prev, ear, next) < 0 && (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear))) {
|
|
45388
|
+
triangles.push(prev.i, ear.i, next.i);
|
|
45389
|
+
removeNode(ear);
|
|
45390
|
+
ear = next;
|
|
45391
|
+
stop = next;
|
|
45392
|
+
continue;
|
|
45393
|
+
}
|
|
45394
|
+
ear = next;
|
|
45395
|
+
if (ear === stop) {
|
|
45396
|
+
filteredOut = false;
|
|
45397
|
+
ear = filterPoints(ear);
|
|
45398
|
+
if (filteredOut) {
|
|
45399
|
+
stop = ear;
|
|
45400
|
+
continue;
|
|
45401
|
+
}
|
|
45402
|
+
if (!cured) {
|
|
45403
|
+
ear = cureLocalIntersections(ear, triangles);
|
|
45404
|
+
stop = ear;
|
|
45405
|
+
cured = true;
|
|
45406
|
+
continue;
|
|
45407
|
+
}
|
|
45408
|
+
splitEarcut(ear, triangles, minX, minY, invSize);
|
|
45409
|
+
break;
|
|
45410
|
+
}
|
|
45411
|
+
}
|
|
45412
|
+
}
|
|
45413
|
+
function isEar(ear) {
|
|
45414
|
+
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);
|
|
45415
|
+
let p = c.next;
|
|
45416
|
+
while (p !== a) {
|
|
45417
|
+
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)
|
|
45418
|
+
return false;
|
|
45419
|
+
p = p.next;
|
|
45420
|
+
}
|
|
45421
|
+
return true;
|
|
45422
|
+
}
|
|
45423
|
+
function isEarHashed(ear, minX, minY, invSize) {
|
|
45424
|
+
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);
|
|
45425
|
+
let p = ear.prevZ;
|
|
45426
|
+
while (p && p.z >= minZ) {
|
|
45427
|
+
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)
|
|
45428
|
+
return false;
|
|
45429
|
+
p = p.prevZ;
|
|
45430
|
+
}
|
|
45431
|
+
let n = ear.nextZ;
|
|
45432
|
+
while (n && n.z <= maxZ) {
|
|
45433
|
+
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)
|
|
45434
|
+
return false;
|
|
45435
|
+
n = n.nextZ;
|
|
45436
|
+
}
|
|
45437
|
+
return true;
|
|
45438
|
+
}
|
|
45439
|
+
function cureLocalIntersections(start, triangles) {
|
|
45440
|
+
let p = start;
|
|
45441
|
+
let cured = false;
|
|
45442
|
+
do {
|
|
45443
|
+
const a = p.prev, b = p.next.next;
|
|
45444
|
+
if (intersects(a, p, p.next, b, false) && locallyInside(a, b) && locallyInside(b, a)) {
|
|
45445
|
+
triangles.push(a.i, p.i, b.i);
|
|
45446
|
+
removeNode(p);
|
|
45447
|
+
removeNode(p.next);
|
|
45448
|
+
p = start = b;
|
|
45449
|
+
cured = true;
|
|
45450
|
+
}
|
|
45451
|
+
p = p.next;
|
|
45452
|
+
} while (p !== start);
|
|
45453
|
+
return cured ? filterPoints(p) : p;
|
|
45454
|
+
}
|
|
45455
|
+
function splitEarcut(start, triangles, minX, minY, invSize) {
|
|
45456
|
+
let a = start;
|
|
45457
|
+
do {
|
|
45458
|
+
let b = a.next.next;
|
|
45459
|
+
while (b !== a.prev) {
|
|
45460
|
+
if (a.i !== b.i && isValidDiagonal(a, b)) {
|
|
45461
|
+
let c = splitPolygon(a, b);
|
|
45462
|
+
a = filterPoints(a, a.next);
|
|
45463
|
+
c = filterPoints(c, c.next);
|
|
45464
|
+
earcutLinked(a, triangles, minX, minY, invSize);
|
|
45465
|
+
earcutLinked(c, triangles, minX, minY, invSize);
|
|
45466
|
+
return;
|
|
45467
|
+
}
|
|
45468
|
+
b = b.next;
|
|
45469
|
+
}
|
|
45470
|
+
a = a.next;
|
|
45471
|
+
} while (a !== start);
|
|
45472
|
+
}
|
|
45473
|
+
function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
45474
|
+
const queue = [];
|
|
45475
|
+
for (let i = 0, len = holeIndices.length;i < len; i++) {
|
|
45476
|
+
const start = holeIndices[i] * dim;
|
|
45477
|
+
const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
45478
|
+
const list = linkedList(data, start, end, dim, false);
|
|
45479
|
+
if (list === list.next)
|
|
45480
|
+
steiners.add(list);
|
|
45481
|
+
queue.push(getLeftmost(list));
|
|
45482
|
+
}
|
|
45483
|
+
queue.sort(compareXYSlope);
|
|
45484
|
+
buildBlockIndex(data.length / dim, holeIndices.length);
|
|
45485
|
+
indexSegment(outerNode, outerNode);
|
|
45486
|
+
indexActive = true;
|
|
45487
|
+
for (let i = 0;i < queue.length; i++) {
|
|
45488
|
+
outerNode = eliminateHole(queue[i], outerNode);
|
|
45489
|
+
}
|
|
45490
|
+
indexActive = false;
|
|
45491
|
+
return filterPoints(outerNode);
|
|
45492
|
+
}
|
|
45493
|
+
function compareXYSlope(a, b) {
|
|
45494
|
+
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);
|
|
45495
|
+
}
|
|
45496
|
+
function eliminateHole(hole, outerNode) {
|
|
45497
|
+
const bridge = findHoleBridge(hole, outerNode);
|
|
45498
|
+
if (!bridge) {
|
|
45499
|
+
return outerNode;
|
|
45500
|
+
}
|
|
45501
|
+
const bridgeReverse = splitPolygon(bridge, hole);
|
|
45502
|
+
const bridge2 = bridgeReverse.next;
|
|
45503
|
+
indexSegment(bridge, bridge2.next);
|
|
45504
|
+
filterPoints(bridgeReverse, bridgeReverse.next);
|
|
45505
|
+
return filterPoints(bridge, bridge.next);
|
|
45506
|
+
}
|
|
45507
|
+
function buildBlockIndex(maxNodes, numHoles) {
|
|
45508
|
+
const maxBlocks = Math.ceil((maxNodes + 2 * numHoles) / K) + numHoles + 2;
|
|
45509
|
+
if (blockBBox.length < maxBlocks * 4)
|
|
45510
|
+
blockBBox = new Float64Array(maxBlocks * 4);
|
|
45511
|
+
numBlocks = 0;
|
|
45512
|
+
}
|
|
45513
|
+
function indexSegment(head, stop) {
|
|
45514
|
+
let p = head;
|
|
45515
|
+
do {
|
|
45516
|
+
const b = numBlocks++;
|
|
45517
|
+
blockHead[b] = p;
|
|
45518
|
+
let minX = p.x, minY = p.y, maxX = p.x, maxY = p.y;
|
|
45519
|
+
let k = 0;
|
|
45520
|
+
do {
|
|
45521
|
+
const c = p.next;
|
|
45522
|
+
p.z = b;
|
|
45523
|
+
if (c.x < minX)
|
|
45524
|
+
minX = c.x;
|
|
45525
|
+
if (c.x > maxX)
|
|
45526
|
+
maxX = c.x;
|
|
45527
|
+
if (c.y < minY)
|
|
45528
|
+
minY = c.y;
|
|
45529
|
+
if (c.y > maxY)
|
|
45530
|
+
maxY = c.y;
|
|
45531
|
+
p = c;
|
|
45532
|
+
} while (++k < K && p !== stop);
|
|
45533
|
+
blockStop[b] = p;
|
|
45534
|
+
const g = b * 4;
|
|
45535
|
+
blockBBox[g] = minX;
|
|
45536
|
+
blockBBox[g + 1] = minY;
|
|
45537
|
+
blockBBox[g + 2] = maxX;
|
|
45538
|
+
blockBBox[g + 3] = maxY;
|
|
45539
|
+
} while (p !== stop);
|
|
45540
|
+
}
|
|
45541
|
+
function growBlock(head, tail) {
|
|
45542
|
+
const g = head.z * 4;
|
|
45543
|
+
if (tail.x < blockBBox[g])
|
|
45544
|
+
blockBBox[g] = tail.x;
|
|
45545
|
+
if (tail.y < blockBBox[g + 1])
|
|
45546
|
+
blockBBox[g + 1] = tail.y;
|
|
45547
|
+
if (tail.x > blockBBox[g + 2])
|
|
45548
|
+
blockBBox[g + 2] = tail.x;
|
|
45549
|
+
if (tail.y > blockBBox[g + 3])
|
|
45550
|
+
blockBBox[g + 3] = tail.y;
|
|
45551
|
+
}
|
|
45552
|
+
function liveBlockStop(b) {
|
|
45553
|
+
let stop = blockStop[b];
|
|
45554
|
+
while (stop.prev.next !== stop)
|
|
45555
|
+
stop = stop.next;
|
|
45556
|
+
blockStop[b] = stop;
|
|
45557
|
+
return stop;
|
|
45558
|
+
}
|
|
45559
|
+
function liveBlockHead(b) {
|
|
45560
|
+
let head = blockHead[b];
|
|
45561
|
+
while (head.prev.next !== head)
|
|
45562
|
+
head = head.next;
|
|
45563
|
+
blockHead[b] = head;
|
|
45564
|
+
return head;
|
|
45565
|
+
}
|
|
45566
|
+
function findHoleBridge(hole, outerNode) {
|
|
45567
|
+
let p = outerNode;
|
|
45568
|
+
const hx = hole.x;
|
|
45569
|
+
const hy = hole.y;
|
|
45570
|
+
let qx = -Infinity;
|
|
45571
|
+
let m;
|
|
45572
|
+
if (equals(hole, p))
|
|
45573
|
+
return p;
|
|
45574
|
+
for (let b = 0, g = 0;b < numBlocks; b++, g += 4) {
|
|
45575
|
+
if (hy < blockBBox[g + 1] || hy > blockBBox[g + 3] || blockBBox[g] > hx || blockBBox[g + 2] <= qx)
|
|
45576
|
+
continue;
|
|
45577
|
+
const stop = liveBlockStop(b);
|
|
45578
|
+
p = liveBlockHead(b);
|
|
45579
|
+
do {
|
|
45580
|
+
if (p.prev.next === p) {
|
|
45581
|
+
if (equals(hole, p.next))
|
|
45582
|
+
return p.next;
|
|
45583
|
+
else if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
|
|
45584
|
+
const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
45585
|
+
if (x <= hx && x > qx) {
|
|
45586
|
+
qx = x;
|
|
45587
|
+
m = p.x < p.next.x ? p : p.next;
|
|
45588
|
+
if (x === hx)
|
|
45589
|
+
return m;
|
|
45590
|
+
}
|
|
45591
|
+
}
|
|
45592
|
+
}
|
|
45593
|
+
p = p.next;
|
|
45594
|
+
} while (p !== stop);
|
|
45595
|
+
}
|
|
45596
|
+
if (!m)
|
|
45597
|
+
return null;
|
|
45598
|
+
const mx = m.x;
|
|
45599
|
+
const my = m.y;
|
|
45600
|
+
const tminY = Math.min(hy, my);
|
|
45601
|
+
const tmaxY = Math.max(hy, my);
|
|
45602
|
+
let tanMin = Infinity;
|
|
45603
|
+
for (let b = 0, g = 0;b < numBlocks; b++, g += 4) {
|
|
45604
|
+
if (blockBBox[g + 2] < mx || blockBBox[g] > hx || blockBBox[g + 3] < tminY || blockBBox[g + 1] > tmaxY)
|
|
45605
|
+
continue;
|
|
45606
|
+
const stop = liveBlockStop(b);
|
|
45607
|
+
p = liveBlockHead(b);
|
|
45608
|
+
do {
|
|
45609
|
+
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)) {
|
|
45610
|
+
const tan = Math.abs(hy - p.y) / (hx - p.x);
|
|
45611
|
+
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)))) {
|
|
45612
|
+
m = p;
|
|
45613
|
+
tanMin = tan;
|
|
45614
|
+
}
|
|
45615
|
+
}
|
|
45616
|
+
p = p.next;
|
|
45617
|
+
} while (p !== stop);
|
|
45618
|
+
}
|
|
45619
|
+
return m;
|
|
45620
|
+
}
|
|
45621
|
+
function sectorContainsSector(m, p) {
|
|
45622
|
+
return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
|
|
45623
|
+
}
|
|
45624
|
+
function indexCurve(start, minX, minY, invSize) {
|
|
45625
|
+
let p = start;
|
|
45626
|
+
let n = 0;
|
|
45627
|
+
do {
|
|
45628
|
+
p.z = zOrder(p.x, p.y, minX, minY, invSize);
|
|
45629
|
+
sortArr[n++] = p;
|
|
45630
|
+
p = p.next;
|
|
45631
|
+
} while (p !== start);
|
|
45632
|
+
sortNodes(n);
|
|
45633
|
+
let prev = null;
|
|
45634
|
+
for (let i = 0;i < n; i++) {
|
|
45635
|
+
const node = sortArr[i];
|
|
45636
|
+
node.prevZ = prev;
|
|
45637
|
+
if (prev)
|
|
45638
|
+
prev.nextZ = node;
|
|
45639
|
+
prev = node;
|
|
45640
|
+
}
|
|
45641
|
+
prev.nextZ = null;
|
|
45642
|
+
sortArr.fill(null, 0, n);
|
|
45643
|
+
sortBuf.fill(null, 0, n);
|
|
45644
|
+
}
|
|
45645
|
+
function sortNodes(n) {
|
|
45646
|
+
if (n <= 32) {
|
|
45647
|
+
for (let i = 1;i < n; i++) {
|
|
45648
|
+
const node = sortArr[i], z = node.z;
|
|
45649
|
+
let j = i - 1;
|
|
45650
|
+
while (j >= 0 && sortArr[j].z > z) {
|
|
45651
|
+
sortArr[j + 1] = sortArr[j];
|
|
45652
|
+
j--;
|
|
45653
|
+
}
|
|
45654
|
+
sortArr[j + 1] = node;
|
|
45655
|
+
}
|
|
45656
|
+
return;
|
|
45657
|
+
}
|
|
45658
|
+
if (zArr.length < n) {
|
|
45659
|
+
zArr = new Uint32Array(n);
|
|
45660
|
+
zBuf = new Uint32Array(n);
|
|
45661
|
+
sortBuf = new Array(n);
|
|
45662
|
+
}
|
|
45663
|
+
for (let i = 0;i < n; i++)
|
|
45664
|
+
zArr[i] = sortArr[i].z;
|
|
45665
|
+
radixPass(n, sortArr, zArr, sortBuf, zBuf, 0);
|
|
45666
|
+
radixPass(n, sortBuf, zBuf, sortArr, zArr, 8);
|
|
45667
|
+
radixPass(n, sortArr, zArr, sortBuf, zBuf, 16);
|
|
45668
|
+
radixPass(n, sortBuf, zBuf, sortArr, zArr, 24);
|
|
45669
|
+
}
|
|
45670
|
+
function radixPass(n, src, srcZ, dst, dstZ, shift) {
|
|
45671
|
+
counts.fill(0);
|
|
45672
|
+
for (let i = 0;i < n; i++)
|
|
45673
|
+
counts[srcZ[i] >>> shift & 255]++;
|
|
45674
|
+
let sum = 0;
|
|
45675
|
+
for (let b = 0;b < 256; b++) {
|
|
45676
|
+
const c = counts[b];
|
|
45677
|
+
counts[b] = sum;
|
|
45678
|
+
sum += c;
|
|
45679
|
+
}
|
|
45680
|
+
for (let i = 0;i < n; i++) {
|
|
45681
|
+
const z = srcZ[i];
|
|
45682
|
+
const pos = counts[z >>> shift & 255]++;
|
|
45683
|
+
dst[pos] = src[i];
|
|
45684
|
+
dstZ[pos] = z;
|
|
45685
|
+
}
|
|
45686
|
+
}
|
|
45687
|
+
function zOrder(x, y, minX, minY, invSize) {
|
|
45688
|
+
x = (x - minX) * invSize | 0;
|
|
45689
|
+
y = (y - minY) * invSize | 0;
|
|
45690
|
+
x = (x | x << 8) & 16711935;
|
|
45691
|
+
x = (x | x << 4) & 252645135;
|
|
45692
|
+
x = (x | x << 2) & 858993459;
|
|
45693
|
+
x = (x | x << 1) & 1431655765;
|
|
45694
|
+
y = (y | y << 8) & 16711935;
|
|
45695
|
+
y = (y | y << 4) & 252645135;
|
|
45696
|
+
y = (y | y << 2) & 858993459;
|
|
45697
|
+
y = (y | y << 1) & 1431655765;
|
|
45698
|
+
return x | y << 1;
|
|
45699
|
+
}
|
|
45700
|
+
function getLeftmost(start) {
|
|
45701
|
+
let p = start, leftmost = start;
|
|
45702
|
+
do {
|
|
45703
|
+
if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y)
|
|
45704
|
+
leftmost = p;
|
|
45705
|
+
p = p.next;
|
|
45706
|
+
} while (p !== start);
|
|
45707
|
+
return leftmost;
|
|
45708
|
+
}
|
|
45709
|
+
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
45710
|
+
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);
|
|
45711
|
+
}
|
|
45712
|
+
function isValidDiagonal(a, b) {
|
|
45713
|
+
const zeroLength = equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0;
|
|
45714
|
+
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));
|
|
45715
|
+
}
|
|
45716
|
+
function area(p, q, r) {
|
|
45717
|
+
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
45718
|
+
}
|
|
45719
|
+
function equals(p1, p2) {
|
|
45720
|
+
return p1.x === p2.x && p1.y === p2.y;
|
|
45721
|
+
}
|
|
45722
|
+
function intersects(p1, q1, p2, q2, includeBoundary = true) {
|
|
45723
|
+
const o1 = area(p1, q1, p2);
|
|
45724
|
+
const o2 = area(p1, q1, q2);
|
|
45725
|
+
const o3 = area(p2, q2, p1);
|
|
45726
|
+
const o4 = area(p2, q2, q1);
|
|
45727
|
+
if ((o1 > 0 && o2 < 0 || o1 < 0 && o2 > 0) && (o3 > 0 && o4 < 0 || o3 < 0 && o4 > 0))
|
|
45728
|
+
return true;
|
|
45729
|
+
if (!includeBoundary)
|
|
45730
|
+
return false;
|
|
45731
|
+
if (o1 === 0 && onSegment(p1, p2, q1))
|
|
45732
|
+
return true;
|
|
45733
|
+
if (o2 === 0 && onSegment(p1, q2, q1))
|
|
45734
|
+
return true;
|
|
45735
|
+
if (o3 === 0 && onSegment(p2, p1, q2))
|
|
45736
|
+
return true;
|
|
45737
|
+
if (o4 === 0 && onSegment(p2, q1, q2))
|
|
45738
|
+
return true;
|
|
45739
|
+
return false;
|
|
45740
|
+
}
|
|
45741
|
+
function onSegment(p, q, r) {
|
|
45742
|
+
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);
|
|
45743
|
+
}
|
|
45744
|
+
function intersectsPolygon(a, b) {
|
|
45745
|
+
const minX = Math.min(a.x, b.x);
|
|
45746
|
+
const maxX = Math.max(a.x, b.x);
|
|
45747
|
+
const minY = Math.min(a.y, b.y);
|
|
45748
|
+
const maxY = Math.max(a.y, b.y);
|
|
45749
|
+
let p = a;
|
|
45750
|
+
do {
|
|
45751
|
+
const n = p.next;
|
|
45752
|
+
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) {
|
|
45753
|
+
p = n;
|
|
45754
|
+
continue;
|
|
45755
|
+
}
|
|
45756
|
+
if (p.i !== a.i && n.i !== a.i && p.i !== b.i && n.i !== b.i && intersects(p, n, a, b))
|
|
45757
|
+
return true;
|
|
45758
|
+
p = n;
|
|
45759
|
+
} while (p !== a);
|
|
45760
|
+
return false;
|
|
45761
|
+
}
|
|
45762
|
+
function locallyInside(a, b) {
|
|
45763
|
+
return area(a.prev, a, a.next) < 0 ? area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 : area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
|
|
45764
|
+
}
|
|
45765
|
+
function middleInside(a, b) {
|
|
45766
|
+
let p = a;
|
|
45767
|
+
let inside = false;
|
|
45768
|
+
const px = (a.x + b.x) / 2;
|
|
45769
|
+
const py = (a.y + b.y) / 2;
|
|
45770
|
+
do {
|
|
45771
|
+
const n = p.next;
|
|
45772
|
+
if (p.y > py !== n.y > py && px < (n.x - p.x) * (py - p.y) / (n.y - p.y) + p.x)
|
|
45773
|
+
inside = !inside;
|
|
45774
|
+
p = n;
|
|
45775
|
+
} while (p !== a);
|
|
45776
|
+
return inside;
|
|
45777
|
+
}
|
|
45778
|
+
function splitPolygon(a, b) {
|
|
45779
|
+
const a2 = createNode(a.i, a.x, a.y), b2 = createNode(b.i, b.x, b.y), an = a.next, bp = b.prev;
|
|
45780
|
+
a.next = b;
|
|
45781
|
+
b.prev = a;
|
|
45782
|
+
a2.next = an;
|
|
45783
|
+
an.prev = a2;
|
|
45784
|
+
b2.next = a2;
|
|
45785
|
+
a2.prev = b2;
|
|
45786
|
+
bp.next = b2;
|
|
45787
|
+
b2.prev = bp;
|
|
45788
|
+
return b2;
|
|
45789
|
+
}
|
|
45790
|
+
function insertNode(i, x, y, last) {
|
|
45791
|
+
const p = createNode(i, x, y);
|
|
45792
|
+
if (!last) {
|
|
45793
|
+
p.prev = p;
|
|
45794
|
+
p.next = p;
|
|
45795
|
+
} else {
|
|
45796
|
+
p.next = last.next;
|
|
45797
|
+
p.prev = last;
|
|
45798
|
+
last.next.prev = p;
|
|
45799
|
+
last.next = p;
|
|
45800
|
+
}
|
|
45801
|
+
return p;
|
|
45802
|
+
}
|
|
45803
|
+
function removeNode(p) {
|
|
45804
|
+
p.next.prev = p.prev;
|
|
45805
|
+
p.prev.next = p.next;
|
|
45806
|
+
if (p.prevZ)
|
|
45807
|
+
p.prevZ.nextZ = p.nextZ;
|
|
45808
|
+
if (p.nextZ)
|
|
45809
|
+
p.nextZ.prevZ = p.prevZ;
|
|
45810
|
+
if (indexActive)
|
|
45811
|
+
growBlock(p.prev, p.next);
|
|
45812
|
+
}
|
|
45813
|
+
function createNode(i, x, y) {
|
|
45814
|
+
return {
|
|
45815
|
+
i,
|
|
45816
|
+
x,
|
|
45817
|
+
y,
|
|
45818
|
+
prev: null,
|
|
45819
|
+
next: null,
|
|
45820
|
+
z: 0,
|
|
45821
|
+
prevZ: null,
|
|
45822
|
+
nextZ: null
|
|
45823
|
+
};
|
|
45824
|
+
}
|
|
45825
|
+
function signedArea(data, start, end, dim) {
|
|
45826
|
+
let sum = 0;
|
|
45827
|
+
for (let i = start, j = end - dim;i < end; i += dim) {
|
|
45828
|
+
sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
|
|
45829
|
+
j = i;
|
|
45830
|
+
}
|
|
45831
|
+
return sum;
|
|
45832
|
+
}
|
|
45833
|
+
function refine(triangles, coords, dim = 2) {
|
|
45834
|
+
const t = triangles;
|
|
45835
|
+
const n = t.length;
|
|
45836
|
+
if (n < 6)
|
|
45837
|
+
return;
|
|
45838
|
+
ensureScratch(n);
|
|
45839
|
+
gen++;
|
|
45840
|
+
he.fill(-1, 0, n);
|
|
45841
|
+
let i = 0;
|
|
45842
|
+
for (let e = 0;e < n; e++) {
|
|
45843
|
+
const a = t[e], b = t[nextHE(e)];
|
|
45844
|
+
const lo = a < b ? a : b, hi = a < b ? b : a;
|
|
45845
|
+
let h = (Math.imul(lo, 2654435761) ^ Math.imul(hi, 2246822507)) & hMask;
|
|
45846
|
+
while (hStamp[h] === gen) {
|
|
45847
|
+
const s = hTable[h];
|
|
45848
|
+
if (s !== -1) {
|
|
45849
|
+
const sa = t[s], sb = t[nextHE(s)];
|
|
45850
|
+
if (sa === lo && sb === hi || sa === hi && sb === lo) {
|
|
45851
|
+
he[e] = s;
|
|
45852
|
+
he[s] = e;
|
|
45853
|
+
hTable[h] = -1;
|
|
45854
|
+
edgeStamp[s] = 1;
|
|
45855
|
+
edgeStack[i++] = s;
|
|
45856
|
+
break;
|
|
45857
|
+
}
|
|
45858
|
+
}
|
|
45859
|
+
h = h + 1 & hMask;
|
|
45860
|
+
}
|
|
45861
|
+
if (hStamp[h] !== gen) {
|
|
45862
|
+
hTable[h] = e;
|
|
45863
|
+
hStamp[h] = gen;
|
|
45864
|
+
}
|
|
45865
|
+
}
|
|
45866
|
+
while (i > 0) {
|
|
45867
|
+
const a = edgeStack[--i];
|
|
45868
|
+
edgeStamp[a] = 0;
|
|
45869
|
+
const b = he[a];
|
|
45870
|
+
if (b === -1)
|
|
45871
|
+
continue;
|
|
45872
|
+
const a0 = a - a % 3;
|
|
45873
|
+
const b0 = b - b % 3;
|
|
45874
|
+
const ar = a0 + (a + 2) % 3;
|
|
45875
|
+
const al = a0 + (a + 1) % 3;
|
|
45876
|
+
const bl = b0 + (b + 2) % 3;
|
|
45877
|
+
const br = b0 + (b + 1) % 3;
|
|
45878
|
+
const p0 = t[ar], pr = t[a], pl = t[al], p1 = t[bl];
|
|
45879
|
+
const x0 = coords[p0 * dim], y0 = coords[p0 * dim + 1];
|
|
45880
|
+
const xr = coords[pr * dim], yr = coords[pr * dim + 1];
|
|
45881
|
+
const xl = coords[pl * dim], yl = coords[pl * dim + 1];
|
|
45882
|
+
const x1 = coords[p1 * dim], y1 = coords[p1 * dim + 1];
|
|
45883
|
+
if (!inCircle(x0, y0, xr, yr, xl, yl, x1, y1) && orient(x0, y0, xr, yr, x1, y1) > 0 && orient(x0, y0, x1, y1, xl, yl) > 0) {
|
|
45884
|
+
t[a] = p1;
|
|
45885
|
+
t[b] = p0;
|
|
45886
|
+
const hbl = he[bl], har = he[ar];
|
|
45887
|
+
he[a] = hbl;
|
|
45888
|
+
if (hbl !== -1)
|
|
45889
|
+
he[hbl] = a;
|
|
45890
|
+
he[b] = har;
|
|
45891
|
+
if (har !== -1)
|
|
45892
|
+
he[har] = b;
|
|
45893
|
+
he[ar] = bl;
|
|
45894
|
+
he[bl] = ar;
|
|
45895
|
+
if (hbl !== -1 && edgeStamp[a] === 0) {
|
|
45896
|
+
edgeStamp[a] = 1;
|
|
45897
|
+
edgeStack[i++] = a;
|
|
45898
|
+
}
|
|
45899
|
+
if (har !== -1 && edgeStamp[b] === 0) {
|
|
45900
|
+
edgeStamp[b] = 1;
|
|
45901
|
+
edgeStack[i++] = b;
|
|
45902
|
+
}
|
|
45903
|
+
if (he[al] !== -1 && edgeStamp[al] === 0) {
|
|
45904
|
+
edgeStamp[al] = 1;
|
|
45905
|
+
edgeStack[i++] = al;
|
|
45906
|
+
}
|
|
45907
|
+
if (he[br] !== -1 && edgeStamp[br] === 0) {
|
|
45908
|
+
edgeStamp[br] = 1;
|
|
45909
|
+
edgeStack[i++] = br;
|
|
45910
|
+
}
|
|
45911
|
+
}
|
|
45912
|
+
}
|
|
45913
|
+
}
|
|
45914
|
+
function orient(ax, ay, bx, by, cx, cy) {
|
|
45915
|
+
return (bx - ax) * (cy - ay) - (by - ay) * (cx - ax);
|
|
45916
|
+
}
|
|
45917
|
+
function inCircle(ax, ay, bx, by, cx, cy, px, py) {
|
|
45918
|
+
const dx = ax - px, dy = ay - py, ex = bx - px, ey = by - py, fx = cx - px, fy = cy - py;
|
|
45919
|
+
const ap = dx * dx + dy * dy, bp = ex * ex + ey * ey, cp = fx * fx + fy * fy;
|
|
45920
|
+
const s = ap + bp + cp;
|
|
45921
|
+
return dx * (ey * cp - bp * fy) - dy * (ex * cp - bp * fx) + ap * (ex * fy - ey * fx) <= 0.0000000000001 * s * s;
|
|
45922
|
+
}
|
|
45923
|
+
function nextHE(e) {
|
|
45924
|
+
return e - e % 3 + (e + 1) % 3;
|
|
45925
|
+
}
|
|
45926
|
+
function ensureScratch(n) {
|
|
45927
|
+
if (!edgeStack || edgeStack.length < n)
|
|
45928
|
+
edgeStack = new Int32Array(n);
|
|
45929
|
+
if (!he || he.length < n)
|
|
45930
|
+
he = new Int32Array(n);
|
|
45931
|
+
if (!edgeStamp || edgeStamp.length < n)
|
|
45932
|
+
edgeStamp = new Uint8Array(n);
|
|
45933
|
+
let size = 1;
|
|
45934
|
+
while (size < n * 4)
|
|
45935
|
+
size <<= 1;
|
|
45936
|
+
if (!hTable || hTable.length < size) {
|
|
45937
|
+
hTable = new Int32Array(size);
|
|
45938
|
+
hStamp = new Uint32Array(size);
|
|
45939
|
+
}
|
|
45940
|
+
hMask = size - 1;
|
|
45941
|
+
}
|
|
45942
|
+
var steiners, filteredOut = false, indexActive = false, K = 16, blockBBox, numBlocks = 0, blockHead, blockStop, sortArr, sortBuf, zArr, zBuf, counts, edgeStack, he, hTable, hStamp, edgeStamp, hMask = 0, gen = 0;
|
|
45943
|
+
var init_earcut = __esm(() => {
|
|
45944
|
+
steiners = new Set;
|
|
45945
|
+
blockBBox = new Float64Array(0);
|
|
45946
|
+
blockHead = [];
|
|
45947
|
+
blockStop = [];
|
|
45948
|
+
sortArr = [];
|
|
45949
|
+
sortBuf = [];
|
|
45950
|
+
zArr = new Uint32Array(0);
|
|
45951
|
+
zBuf = new Uint32Array(0);
|
|
45952
|
+
counts = new Uint32Array(256);
|
|
45953
|
+
});
|
|
45954
|
+
|
|
45310
45955
|
// node_modules/splaytree/dist/splaytree.umd.cjs
|
|
45311
45956
|
var require_splaytree_umd = __commonJS2(function(exports2, module2) {
|
|
45312
45957
|
(function(h, c) {
|
|
@@ -69121,7 +69766,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
69121
69766
|
}));
|
|
69122
69767
|
};
|
|
69123
69768
|
// package.json
|
|
69124
|
-
var version = "0.1.
|
|
69769
|
+
var version = "0.1.2411";
|
|
69125
69770
|
var package_default = {
|
|
69126
69771
|
name: "@tscircuit/cli",
|
|
69127
69772
|
version,
|
|
@@ -69212,7 +69857,7 @@ var package_default = {
|
|
|
69212
69857
|
"perfect-cli": "^1.0.21",
|
|
69213
69858
|
playwright: "^1.57.0",
|
|
69214
69859
|
"polygon-clipping": "^0.15.7",
|
|
69215
|
-
poppygl: "0.0.
|
|
69860
|
+
poppygl: "0.0.37",
|
|
69216
69861
|
prompts: "^2.4.2",
|
|
69217
69862
|
"proper-lockfile": "^4.1.2",
|
|
69218
69863
|
redaxios: "^0.5.1",
|
|
@@ -69225,7 +69870,8 @@ var package_default = {
|
|
|
69225
69870
|
tscircuit: "0.0.2647-libonly",
|
|
69226
69871
|
tsx: "^4.7.1",
|
|
69227
69872
|
"typed-ky": "^0.0.4",
|
|
69228
|
-
zod: "^3.23.8"
|
|
69873
|
+
zod: "^3.23.8",
|
|
69874
|
+
"@tscircuit/circuit-json-to-drawing": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-to-drawing/0.0.3.tgz"
|
|
69229
69875
|
},
|
|
69230
69876
|
peerDependencies: {
|
|
69231
69877
|
"@tscircuit/math-utils": "0.0.36",
|
|
@@ -69249,9 +69895,10 @@ var package_default = {
|
|
|
69249
69895
|
overrides: {
|
|
69250
69896
|
"circuit-json": "^0.0.534",
|
|
69251
69897
|
altiumts: "0.0.59",
|
|
69252
|
-
poppygl: "0.0.
|
|
69253
|
-
"@tscircuit/core": "^0.0.
|
|
69254
|
-
"jscad-planner": "0.0.
|
|
69898
|
+
poppygl: "0.0.37",
|
|
69899
|
+
"@tscircuit/core": "^0.0.2204",
|
|
69900
|
+
"jscad-planner": "0.0.21",
|
|
69901
|
+
"jscad-fiber": "0.0.92"
|
|
69255
69902
|
},
|
|
69256
69903
|
scripts: {
|
|
69257
69904
|
start: "bun run dev",
|
|
@@ -71292,1399 +71939,744 @@ class Conf {
|
|
|
71292
71939
|
this.path = path5.resolve(options.cwd, `${options.configName ?? "config"}${fileExtension}`);
|
|
71293
71940
|
const fileStore = this.store;
|
|
71294
71941
|
const store = Object.assign(createPlainObject(), options.defaults, fileStore);
|
|
71295
|
-
if (options.migrations) {
|
|
71296
|
-
if (!options.projectVersion) {
|
|
71297
|
-
throw new Error("Please specify the `projectVersion` option.");
|
|
71298
|
-
}
|
|
71299
|
-
this._migrate(options.migrations, options.projectVersion, options.beforeEachMigration);
|
|
71300
|
-
}
|
|
71301
|
-
this._validate(store);
|
|
71302
|
-
try {
|
|
71303
|
-
assert.deepEqual(fileStore, store);
|
|
71304
|
-
} catch {
|
|
71305
|
-
this.store = store;
|
|
71306
|
-
}
|
|
71307
|
-
if (options.watch) {
|
|
71308
|
-
this._watch();
|
|
71309
|
-
}
|
|
71310
|
-
}
|
|
71311
|
-
get(key, defaultValue) {
|
|
71312
|
-
if (this.#options.accessPropertiesByDotNotation) {
|
|
71313
|
-
return this._get(key, defaultValue);
|
|
71314
|
-
}
|
|
71315
|
-
const { store } = this;
|
|
71316
|
-
return key in store ? store[key] : defaultValue;
|
|
71317
|
-
}
|
|
71318
|
-
set(key, value) {
|
|
71319
|
-
if (typeof key !== "string" && typeof key !== "object") {
|
|
71320
|
-
throw new TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof key}`);
|
|
71321
|
-
}
|
|
71322
|
-
if (typeof key !== "object" && value === undefined) {
|
|
71323
|
-
throw new TypeError("Use `delete()` to clear values");
|
|
71324
|
-
}
|
|
71325
|
-
if (this._containsReservedKey(key)) {
|
|
71326
|
-
throw new TypeError(`Please don't use the ${INTERNAL_KEY} key, as it's used to manage this module internal operations.`);
|
|
71327
|
-
}
|
|
71328
|
-
const { store } = this;
|
|
71329
|
-
const set = (key, value) => {
|
|
71330
|
-
checkValueType(key, value);
|
|
71331
|
-
if (this.#options.accessPropertiesByDotNotation) {
|
|
71332
|
-
setProperty(store, key, value);
|
|
71333
|
-
} else {
|
|
71334
|
-
store[key] = value;
|
|
71335
|
-
}
|
|
71336
|
-
};
|
|
71337
|
-
if (typeof key === "object") {
|
|
71338
|
-
const object = key;
|
|
71339
|
-
for (const [key, value] of Object.entries(object)) {
|
|
71340
|
-
set(key, value);
|
|
71341
|
-
}
|
|
71342
|
-
} else {
|
|
71343
|
-
set(key, value);
|
|
71344
|
-
}
|
|
71345
|
-
this.store = store;
|
|
71346
|
-
}
|
|
71347
|
-
has(key) {
|
|
71348
|
-
if (this.#options.accessPropertiesByDotNotation) {
|
|
71349
|
-
return hasProperty(this.store, key);
|
|
71350
|
-
}
|
|
71351
|
-
return key in this.store;
|
|
71352
|
-
}
|
|
71353
|
-
reset(...keys) {
|
|
71354
|
-
for (const key of keys) {
|
|
71355
|
-
if (isExist(this.#defaultValues[key])) {
|
|
71356
|
-
this.set(key, this.#defaultValues[key]);
|
|
71357
|
-
}
|
|
71358
|
-
}
|
|
71359
|
-
}
|
|
71360
|
-
delete(key) {
|
|
71361
|
-
const { store } = this;
|
|
71362
|
-
if (this.#options.accessPropertiesByDotNotation) {
|
|
71363
|
-
deleteProperty(store, key);
|
|
71364
|
-
} else {
|
|
71365
|
-
delete store[key];
|
|
71366
|
-
}
|
|
71367
|
-
this.store = store;
|
|
71368
|
-
}
|
|
71369
|
-
clear() {
|
|
71370
|
-
this.store = createPlainObject();
|
|
71371
|
-
for (const key of Object.keys(this.#defaultValues)) {
|
|
71372
|
-
this.reset(key);
|
|
71373
|
-
}
|
|
71374
|
-
}
|
|
71375
|
-
onDidChange(key, callback) {
|
|
71376
|
-
if (typeof key !== "string") {
|
|
71377
|
-
throw new TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof key}`);
|
|
71378
|
-
}
|
|
71379
|
-
if (typeof callback !== "function") {
|
|
71380
|
-
throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof callback}`);
|
|
71381
|
-
}
|
|
71382
|
-
return this._handleChange(() => this.get(key), callback);
|
|
71383
|
-
}
|
|
71384
|
-
onDidAnyChange(callback) {
|
|
71385
|
-
if (typeof callback !== "function") {
|
|
71386
|
-
throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof callback}`);
|
|
71387
|
-
}
|
|
71388
|
-
return this._handleChange(() => this.store, callback);
|
|
71389
|
-
}
|
|
71390
|
-
get size() {
|
|
71391
|
-
return Object.keys(this.store).length;
|
|
71392
|
-
}
|
|
71393
|
-
get store() {
|
|
71394
|
-
try {
|
|
71395
|
-
const data = fs3.readFileSync(this.path, this.#encryptionKey ? null : "utf8");
|
|
71396
|
-
const dataString = this._encryptData(data);
|
|
71397
|
-
const deserializedData = this._deserialize(dataString);
|
|
71398
|
-
this._validate(deserializedData);
|
|
71399
|
-
return Object.assign(createPlainObject(), deserializedData);
|
|
71400
|
-
} catch (error) {
|
|
71401
|
-
if (error?.code === "ENOENT") {
|
|
71402
|
-
this._ensureDirectory();
|
|
71403
|
-
return createPlainObject();
|
|
71404
|
-
}
|
|
71405
|
-
if (this.#options.clearInvalidConfig && error.name === "SyntaxError") {
|
|
71406
|
-
return createPlainObject();
|
|
71407
|
-
}
|
|
71408
|
-
throw error;
|
|
71409
|
-
}
|
|
71410
|
-
}
|
|
71411
|
-
set store(value) {
|
|
71412
|
-
this._ensureDirectory();
|
|
71413
|
-
this._validate(value);
|
|
71414
|
-
this._write(value);
|
|
71415
|
-
this.events.dispatchEvent(new Event("change"));
|
|
71416
|
-
}
|
|
71417
|
-
*[Symbol.iterator]() {
|
|
71418
|
-
for (const [key, value] of Object.entries(this.store)) {
|
|
71419
|
-
yield [key, value];
|
|
71420
|
-
}
|
|
71421
|
-
}
|
|
71422
|
-
_encryptData(data) {
|
|
71423
|
-
if (!this.#encryptionKey) {
|
|
71424
|
-
return typeof data === "string" ? data : uint8ArrayToString(data);
|
|
71425
|
-
}
|
|
71426
|
-
try {
|
|
71427
|
-
const initializationVector = data.slice(0, 16);
|
|
71428
|
-
const password = crypto2.pbkdf2Sync(this.#encryptionKey, initializationVector.toString(), 1e4, 32, "sha512");
|
|
71429
|
-
const decipher = crypto2.createDecipheriv(encryptionAlgorithm, password, initializationVector);
|
|
71430
|
-
const slice = data.slice(17);
|
|
71431
|
-
const dataUpdate = typeof slice === "string" ? stringToUint8Array(slice) : slice;
|
|
71432
|
-
return uint8ArrayToString(concatUint8Arrays([decipher.update(dataUpdate), decipher.final()]));
|
|
71433
|
-
} catch {}
|
|
71434
|
-
return data.toString();
|
|
71435
|
-
}
|
|
71436
|
-
_handleChange(getter, callback) {
|
|
71437
|
-
let currentValue = getter();
|
|
71438
|
-
const onChange = () => {
|
|
71439
|
-
const oldValue = currentValue;
|
|
71440
|
-
const newValue = getter();
|
|
71441
|
-
if (isDeepStrictEqual(newValue, oldValue)) {
|
|
71442
|
-
return;
|
|
71443
|
-
}
|
|
71444
|
-
currentValue = newValue;
|
|
71445
|
-
callback.call(this, newValue, oldValue);
|
|
71446
|
-
};
|
|
71447
|
-
this.events.addEventListener("change", onChange);
|
|
71448
|
-
return () => {
|
|
71449
|
-
this.events.removeEventListener("change", onChange);
|
|
71450
|
-
};
|
|
71451
|
-
}
|
|
71452
|
-
_deserialize = (value) => JSON.parse(value);
|
|
71453
|
-
_serialize = (value) => JSON.stringify(value, undefined, "\t");
|
|
71454
|
-
_validate(data) {
|
|
71455
|
-
if (!this.#validator) {
|
|
71456
|
-
return;
|
|
71457
|
-
}
|
|
71458
|
-
const valid = this.#validator(data);
|
|
71459
|
-
if (valid || !this.#validator.errors) {
|
|
71460
|
-
return;
|
|
71461
|
-
}
|
|
71462
|
-
const errors = this.#validator.errors.map(({ instancePath, message = "" }) => `\`${instancePath.slice(1)}\` ${message}`);
|
|
71463
|
-
throw new Error("Config schema violation: " + errors.join("; "));
|
|
71464
|
-
}
|
|
71465
|
-
_ensureDirectory() {
|
|
71466
|
-
fs3.mkdirSync(path5.dirname(this.path), { recursive: true });
|
|
71467
|
-
}
|
|
71468
|
-
_write(value) {
|
|
71469
|
-
let data = this._serialize(value);
|
|
71470
|
-
if (this.#encryptionKey) {
|
|
71471
|
-
const initializationVector = crypto2.randomBytes(16);
|
|
71472
|
-
const password = crypto2.pbkdf2Sync(this.#encryptionKey, initializationVector.toString(), 1e4, 32, "sha512");
|
|
71473
|
-
const cipher = crypto2.createCipheriv(encryptionAlgorithm, password, initializationVector);
|
|
71474
|
-
data = concatUint8Arrays([initializationVector, stringToUint8Array(":"), cipher.update(stringToUint8Array(data)), cipher.final()]);
|
|
71475
|
-
}
|
|
71476
|
-
if (process7.env.SNAP) {
|
|
71477
|
-
fs3.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
71478
|
-
} else {
|
|
71479
|
-
try {
|
|
71480
|
-
writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
71481
|
-
} catch (error) {
|
|
71482
|
-
if (error?.code === "EXDEV") {
|
|
71483
|
-
fs3.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
71484
|
-
return;
|
|
71485
|
-
}
|
|
71486
|
-
throw error;
|
|
71487
|
-
}
|
|
71488
|
-
}
|
|
71489
|
-
}
|
|
71490
|
-
_watch() {
|
|
71491
|
-
this._ensureDirectory();
|
|
71492
|
-
if (!fs3.existsSync(this.path)) {
|
|
71493
|
-
this._write(createPlainObject());
|
|
71494
|
-
}
|
|
71495
|
-
if (process7.platform === "win32") {
|
|
71496
|
-
fs3.watch(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
71497
|
-
this.events.dispatchEvent(new Event("change"));
|
|
71498
|
-
}, { wait: 100 }));
|
|
71499
|
-
} else {
|
|
71500
|
-
fs3.watchFile(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
71501
|
-
this.events.dispatchEvent(new Event("change"));
|
|
71502
|
-
}, { wait: 5000 }));
|
|
71503
|
-
}
|
|
71504
|
-
}
|
|
71505
|
-
_migrate(migrations, versionToMigrate, beforeEachMigration) {
|
|
71506
|
-
let previousMigratedVersion = this._get(MIGRATION_KEY, "0.0.0");
|
|
71507
|
-
const newerVersions = Object.keys(migrations).filter((candidateVersion) => this._shouldPerformMigration(candidateVersion, previousMigratedVersion, versionToMigrate));
|
|
71508
|
-
let storeBackup = { ...this.store };
|
|
71509
|
-
for (const version of newerVersions) {
|
|
71510
|
-
try {
|
|
71511
|
-
if (beforeEachMigration) {
|
|
71512
|
-
beforeEachMigration(this, {
|
|
71513
|
-
fromVersion: previousMigratedVersion,
|
|
71514
|
-
toVersion: version,
|
|
71515
|
-
finalVersion: versionToMigrate,
|
|
71516
|
-
versions: newerVersions
|
|
71517
|
-
});
|
|
71518
|
-
}
|
|
71519
|
-
const migration = migrations[version];
|
|
71520
|
-
migration?.(this);
|
|
71521
|
-
this._set(MIGRATION_KEY, version);
|
|
71522
|
-
previousMigratedVersion = version;
|
|
71523
|
-
storeBackup = { ...this.store };
|
|
71524
|
-
} catch (error) {
|
|
71525
|
-
this.store = storeBackup;
|
|
71526
|
-
throw new Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${error}`);
|
|
71527
|
-
}
|
|
71528
|
-
}
|
|
71529
|
-
if (this._isVersionInRangeFormat(previousMigratedVersion) || !import_semver.default.eq(previousMigratedVersion, versionToMigrate)) {
|
|
71530
|
-
this._set(MIGRATION_KEY, versionToMigrate);
|
|
71531
|
-
}
|
|
71532
|
-
}
|
|
71533
|
-
_containsReservedKey(key) {
|
|
71534
|
-
if (typeof key === "object") {
|
|
71535
|
-
const firsKey = Object.keys(key)[0];
|
|
71536
|
-
if (firsKey === INTERNAL_KEY) {
|
|
71537
|
-
return true;
|
|
71538
|
-
}
|
|
71539
|
-
}
|
|
71540
|
-
if (typeof key !== "string") {
|
|
71541
|
-
return false;
|
|
71542
|
-
}
|
|
71543
|
-
if (this.#options.accessPropertiesByDotNotation) {
|
|
71544
|
-
if (key.startsWith(`${INTERNAL_KEY}.`)) {
|
|
71545
|
-
return true;
|
|
71546
|
-
}
|
|
71547
|
-
return false;
|
|
71548
|
-
}
|
|
71549
|
-
return false;
|
|
71550
|
-
}
|
|
71551
|
-
_isVersionInRangeFormat(version) {
|
|
71552
|
-
return import_semver.default.clean(version) === null;
|
|
71553
|
-
}
|
|
71554
|
-
_shouldPerformMigration(candidateVersion, previousMigratedVersion, versionToMigrate) {
|
|
71555
|
-
if (this._isVersionInRangeFormat(candidateVersion)) {
|
|
71556
|
-
if (previousMigratedVersion !== "0.0.0" && import_semver.default.satisfies(previousMigratedVersion, candidateVersion)) {
|
|
71557
|
-
return false;
|
|
71558
|
-
}
|
|
71559
|
-
return import_semver.default.satisfies(versionToMigrate, candidateVersion);
|
|
71560
|
-
}
|
|
71561
|
-
if (import_semver.default.lte(candidateVersion, previousMigratedVersion)) {
|
|
71562
|
-
return false;
|
|
71563
|
-
}
|
|
71564
|
-
if (import_semver.default.gt(candidateVersion, versionToMigrate)) {
|
|
71565
|
-
return false;
|
|
71566
|
-
}
|
|
71567
|
-
return true;
|
|
71568
|
-
}
|
|
71569
|
-
_get(key, defaultValue) {
|
|
71570
|
-
return getProperty(this.store, key, defaultValue);
|
|
71571
|
-
}
|
|
71572
|
-
_set(key, value) {
|
|
71573
|
-
const { store } = this;
|
|
71574
|
-
setProperty(store, key, value);
|
|
71575
|
-
this.store = store;
|
|
71576
|
-
}
|
|
71577
|
-
}
|
|
71578
|
-
|
|
71579
|
-
// node_modules/jwt-decode/build/esm/index.js
|
|
71580
|
-
class InvalidTokenError extends Error {
|
|
71581
|
-
}
|
|
71582
|
-
InvalidTokenError.prototype.name = "InvalidTokenError";
|
|
71583
|
-
function b64DecodeUnicode(str) {
|
|
71584
|
-
return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
|
|
71585
|
-
let code = p.charCodeAt(0).toString(16).toUpperCase();
|
|
71586
|
-
if (code.length < 2) {
|
|
71587
|
-
code = "0" + code;
|
|
71588
|
-
}
|
|
71589
|
-
return "%" + code;
|
|
71590
|
-
}));
|
|
71591
|
-
}
|
|
71592
|
-
function base64UrlDecode(str) {
|
|
71593
|
-
let output = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
71594
|
-
switch (output.length % 4) {
|
|
71595
|
-
case 0:
|
|
71596
|
-
break;
|
|
71597
|
-
case 2:
|
|
71598
|
-
output += "==";
|
|
71599
|
-
break;
|
|
71600
|
-
case 3:
|
|
71601
|
-
output += "=";
|
|
71602
|
-
break;
|
|
71603
|
-
default:
|
|
71604
|
-
throw new Error("base64 string is not of the correct length");
|
|
71605
|
-
}
|
|
71606
|
-
try {
|
|
71607
|
-
return b64DecodeUnicode(output);
|
|
71608
|
-
} catch (err) {
|
|
71609
|
-
return atob(output);
|
|
71610
|
-
}
|
|
71611
|
-
}
|
|
71612
|
-
function jwtDecode(token, options) {
|
|
71613
|
-
if (typeof token !== "string") {
|
|
71614
|
-
throw new InvalidTokenError("Invalid token specified: must be a string");
|
|
71615
|
-
}
|
|
71616
|
-
options || (options = {});
|
|
71617
|
-
const pos = options.header === true ? 0 : 1;
|
|
71618
|
-
const part = token.split(".")[pos];
|
|
71619
|
-
if (typeof part !== "string") {
|
|
71620
|
-
throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`);
|
|
71621
|
-
}
|
|
71622
|
-
let decoded;
|
|
71623
|
-
try {
|
|
71624
|
-
decoded = base64UrlDecode(part);
|
|
71625
|
-
} catch (e) {
|
|
71626
|
-
throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${pos + 1} (${e.message})`);
|
|
71627
|
-
}
|
|
71628
|
-
try {
|
|
71629
|
-
return JSON.parse(decoded);
|
|
71630
|
-
} catch (e) {
|
|
71631
|
-
throw new InvalidTokenError(`Invalid token specified: invalid json for part #${pos + 1} (${e.message})`);
|
|
71632
|
-
}
|
|
71633
|
-
}
|
|
71634
|
-
|
|
71635
|
-
// lib/cli-config/index.ts
|
|
71636
|
-
import fs5 from "node:fs";
|
|
71637
|
-
import os3 from "node:os";
|
|
71638
|
-
import path7 from "node:path";
|
|
71639
|
-
|
|
71640
|
-
// lib/shared/handle-registry-auth-error.ts
|
|
71641
|
-
import fs4 from "node:fs";
|
|
71642
|
-
import os2 from "node:os";
|
|
71643
|
-
import path6 from "node:path";
|
|
71644
|
-
|
|
71645
|
-
// node_modules/kleur/index.mjs
|
|
71646
|
-
var FORCE_COLOR;
|
|
71647
|
-
var NODE_DISABLE_COLORS;
|
|
71648
|
-
var NO_COLOR;
|
|
71649
|
-
var TERM;
|
|
71650
|
-
var isTTY = true;
|
|
71651
|
-
if (typeof process !== "undefined") {
|
|
71652
|
-
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
|
|
71653
|
-
isTTY = process.stdout && process.stdout.isTTY;
|
|
71654
|
-
}
|
|
71655
|
-
var $ = {
|
|
71656
|
-
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY),
|
|
71657
|
-
reset: init(0, 0),
|
|
71658
|
-
bold: init(1, 22),
|
|
71659
|
-
dim: init(2, 22),
|
|
71660
|
-
italic: init(3, 23),
|
|
71661
|
-
underline: init(4, 24),
|
|
71662
|
-
inverse: init(7, 27),
|
|
71663
|
-
hidden: init(8, 28),
|
|
71664
|
-
strikethrough: init(9, 29),
|
|
71665
|
-
black: init(30, 39),
|
|
71666
|
-
red: init(31, 39),
|
|
71667
|
-
green: init(32, 39),
|
|
71668
|
-
yellow: init(33, 39),
|
|
71669
|
-
blue: init(34, 39),
|
|
71670
|
-
magenta: init(35, 39),
|
|
71671
|
-
cyan: init(36, 39),
|
|
71672
|
-
white: init(37, 39),
|
|
71673
|
-
gray: init(90, 39),
|
|
71674
|
-
grey: init(90, 39),
|
|
71675
|
-
bgBlack: init(40, 49),
|
|
71676
|
-
bgRed: init(41, 49),
|
|
71677
|
-
bgGreen: init(42, 49),
|
|
71678
|
-
bgYellow: init(43, 49),
|
|
71679
|
-
bgBlue: init(44, 49),
|
|
71680
|
-
bgMagenta: init(45, 49),
|
|
71681
|
-
bgCyan: init(46, 49),
|
|
71682
|
-
bgWhite: init(47, 49)
|
|
71683
|
-
};
|
|
71684
|
-
function run(arr, str) {
|
|
71685
|
-
let i = 0, tmp, beg = "", end = "";
|
|
71686
|
-
for (;i < arr.length; i++) {
|
|
71687
|
-
tmp = arr[i];
|
|
71688
|
-
beg += tmp.open;
|
|
71689
|
-
end += tmp.close;
|
|
71690
|
-
if (!!~str.indexOf(tmp.close)) {
|
|
71691
|
-
str = str.replace(tmp.rgx, tmp.close + tmp.open);
|
|
71692
|
-
}
|
|
71693
|
-
}
|
|
71694
|
-
return beg + str + end;
|
|
71695
|
-
}
|
|
71696
|
-
function chain(has, keys) {
|
|
71697
|
-
let ctx = { has, keys };
|
|
71698
|
-
ctx.reset = $.reset.bind(ctx);
|
|
71699
|
-
ctx.bold = $.bold.bind(ctx);
|
|
71700
|
-
ctx.dim = $.dim.bind(ctx);
|
|
71701
|
-
ctx.italic = $.italic.bind(ctx);
|
|
71702
|
-
ctx.underline = $.underline.bind(ctx);
|
|
71703
|
-
ctx.inverse = $.inverse.bind(ctx);
|
|
71704
|
-
ctx.hidden = $.hidden.bind(ctx);
|
|
71705
|
-
ctx.strikethrough = $.strikethrough.bind(ctx);
|
|
71706
|
-
ctx.black = $.black.bind(ctx);
|
|
71707
|
-
ctx.red = $.red.bind(ctx);
|
|
71708
|
-
ctx.green = $.green.bind(ctx);
|
|
71709
|
-
ctx.yellow = $.yellow.bind(ctx);
|
|
71710
|
-
ctx.blue = $.blue.bind(ctx);
|
|
71711
|
-
ctx.magenta = $.magenta.bind(ctx);
|
|
71712
|
-
ctx.cyan = $.cyan.bind(ctx);
|
|
71713
|
-
ctx.white = $.white.bind(ctx);
|
|
71714
|
-
ctx.gray = $.gray.bind(ctx);
|
|
71715
|
-
ctx.grey = $.grey.bind(ctx);
|
|
71716
|
-
ctx.bgBlack = $.bgBlack.bind(ctx);
|
|
71717
|
-
ctx.bgRed = $.bgRed.bind(ctx);
|
|
71718
|
-
ctx.bgGreen = $.bgGreen.bind(ctx);
|
|
71719
|
-
ctx.bgYellow = $.bgYellow.bind(ctx);
|
|
71720
|
-
ctx.bgBlue = $.bgBlue.bind(ctx);
|
|
71721
|
-
ctx.bgMagenta = $.bgMagenta.bind(ctx);
|
|
71722
|
-
ctx.bgCyan = $.bgCyan.bind(ctx);
|
|
71723
|
-
ctx.bgWhite = $.bgWhite.bind(ctx);
|
|
71724
|
-
return ctx;
|
|
71725
|
-
}
|
|
71726
|
-
function init(open, close) {
|
|
71727
|
-
let blk = {
|
|
71728
|
-
open: `\x1B[${open}m`,
|
|
71729
|
-
close: `\x1B[${close}m`,
|
|
71730
|
-
rgx: new RegExp(`\\x1b\\[${close}m`, "g")
|
|
71731
|
-
};
|
|
71732
|
-
return function(txt) {
|
|
71733
|
-
if (this !== undefined && this.has !== undefined) {
|
|
71734
|
-
!!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
|
|
71735
|
-
return txt === undefined ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
|
|
71736
|
-
}
|
|
71737
|
-
return txt === undefined ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
|
|
71738
|
-
};
|
|
71739
|
-
}
|
|
71740
|
-
var kleur_default = $;
|
|
71741
|
-
|
|
71742
|
-
// lib/shared/handle-registry-auth-error.ts
|
|
71743
|
-
var AUTH_TOKEN_REGEX = /^\/\/npm\.tscircuit\.com\/:_authToken=(.+)$/m;
|
|
71744
|
-
function isUnauthorizedError(error) {
|
|
71745
|
-
const output = [
|
|
71746
|
-
error instanceof Error ? error.message : "",
|
|
71747
|
-
error?.stderr?.toString?.() ?? "",
|
|
71748
|
-
error?.stdout?.toString?.() ?? ""
|
|
71749
|
-
].join(`
|
|
71750
|
-
`);
|
|
71751
|
-
const registryErrorMatch = output.match(/error:\s*(\{[\s\S]*?\})/i);
|
|
71752
|
-
if (registryErrorMatch) {
|
|
71753
|
-
const errorBody = registryErrorMatch[1];
|
|
71754
|
-
const errorCode = errorBody.match(/error_code\s*:\s*['"]?([^,'"}\s]+)/i)?.[1] ?? "";
|
|
71755
|
-
const message = errorBody.match(/message\s*:\s*['"]?([^'"}]+)/i)?.[1] ?? "";
|
|
71756
|
-
if (/unauth|token|auth/i.test(errorCode) || /unauth|token|auth/i.test(message)) {
|
|
71757
|
-
return true;
|
|
71942
|
+
if (options.migrations) {
|
|
71943
|
+
if (!options.projectVersion) {
|
|
71944
|
+
throw new Error("Please specify the `projectVersion` option.");
|
|
71945
|
+
}
|
|
71946
|
+
this._migrate(options.migrations, options.projectVersion, options.beforeEachMigration);
|
|
71947
|
+
}
|
|
71948
|
+
this._validate(store);
|
|
71949
|
+
try {
|
|
71950
|
+
assert.deepEqual(fileStore, store);
|
|
71951
|
+
} catch {
|
|
71952
|
+
this.store = store;
|
|
71953
|
+
}
|
|
71954
|
+
if (options.watch) {
|
|
71955
|
+
this._watch();
|
|
71758
71956
|
}
|
|
71759
71957
|
}
|
|
71760
|
-
|
|
71761
|
-
|
|
71762
|
-
|
|
71763
|
-
|
|
71764
|
-
|
|
71765
|
-
|
|
71766
|
-
return AUTH_TOKEN_REGEX.test(content);
|
|
71767
|
-
}
|
|
71768
|
-
function handleRegistryAuthError({
|
|
71769
|
-
error,
|
|
71770
|
-
projectDir
|
|
71771
|
-
}) {
|
|
71772
|
-
if (!isUnauthorizedError(error))
|
|
71773
|
-
return;
|
|
71774
|
-
const npmrcPaths = [
|
|
71775
|
-
path6.join(projectDir, ".npmrc"),
|
|
71776
|
-
path6.join(os2.homedir(), ".npmrc")
|
|
71777
|
-
];
|
|
71778
|
-
const hasToken = npmrcPaths.some(hasTsciAuthToken);
|
|
71779
|
-
if (hasToken) {
|
|
71780
|
-
console.warn(kleur_default.yellow("Your tscircuit session token appears to be missing or expired. Run `tsci auth setup-npmrc` to refresh it before retrying."));
|
|
71781
|
-
} else {
|
|
71782
|
-
console.warn(kleur_default.yellow("No tscircuit session token is loaded in your .npmrc files. Run `tsci auth setup-npmrc` to add one and retry the install."));
|
|
71958
|
+
get(key, defaultValue) {
|
|
71959
|
+
if (this.#options.accessPropertiesByDotNotation) {
|
|
71960
|
+
return this._get(key, defaultValue);
|
|
71961
|
+
}
|
|
71962
|
+
const { store } = this;
|
|
71963
|
+
return key in store ? store[key] : defaultValue;
|
|
71783
71964
|
}
|
|
71784
|
-
|
|
71785
|
-
|
|
71786
|
-
|
|
71787
|
-
|
|
71788
|
-
|
|
71789
|
-
|
|
71790
|
-
|
|
71791
|
-
|
|
71792
|
-
};
|
|
71793
|
-
|
|
71794
|
-
|
|
71795
|
-
|
|
71796
|
-
|
|
71797
|
-
|
|
71798
|
-
|
|
71799
|
-
|
|
71800
|
-
|
|
71801
|
-
|
|
71802
|
-
|
|
71803
|
-
if (
|
|
71804
|
-
|
|
71805
|
-
|
|
71806
|
-
|
|
71807
|
-
|
|
71808
|
-
|
|
71965
|
+
set(key, value) {
|
|
71966
|
+
if (typeof key !== "string" && typeof key !== "object") {
|
|
71967
|
+
throw new TypeError(`Expected \`key\` to be of type \`string\` or \`object\`, got ${typeof key}`);
|
|
71968
|
+
}
|
|
71969
|
+
if (typeof key !== "object" && value === undefined) {
|
|
71970
|
+
throw new TypeError("Use `delete()` to clear values");
|
|
71971
|
+
}
|
|
71972
|
+
if (this._containsReservedKey(key)) {
|
|
71973
|
+
throw new TypeError(`Please don't use the ${INTERNAL_KEY} key, as it's used to manage this module internal operations.`);
|
|
71974
|
+
}
|
|
71975
|
+
const { store } = this;
|
|
71976
|
+
const set = (key, value) => {
|
|
71977
|
+
checkValueType(key, value);
|
|
71978
|
+
if (this.#options.accessPropertiesByDotNotation) {
|
|
71979
|
+
setProperty(store, key, value);
|
|
71980
|
+
} else {
|
|
71981
|
+
store[key] = value;
|
|
71982
|
+
}
|
|
71983
|
+
};
|
|
71984
|
+
if (typeof key === "object") {
|
|
71985
|
+
const object = key;
|
|
71986
|
+
for (const [key, value] of Object.entries(object)) {
|
|
71987
|
+
set(key, value);
|
|
71988
|
+
}
|
|
71989
|
+
} else {
|
|
71990
|
+
set(key, value);
|
|
71809
71991
|
}
|
|
71992
|
+
this.store = store;
|
|
71810
71993
|
}
|
|
71811
|
-
|
|
71812
|
-
|
|
71813
|
-
|
|
71814
|
-
|
|
71815
|
-
|
|
71816
|
-
if (decoded.tscircuit_handle)
|
|
71817
|
-
cliConfig.set("tscircuitHandle", decoded.tscircuit_handle);
|
|
71818
|
-
if (decoded.account_id)
|
|
71819
|
-
cliConfig.set("accountId", decoded.account_id);
|
|
71820
|
-
if (decoded.session_id)
|
|
71821
|
-
cliConfig.set("sessionId", decoded.session_id);
|
|
71822
|
-
};
|
|
71823
|
-
var clearSession = () => {
|
|
71824
|
-
cliConfig.clear();
|
|
71825
|
-
};
|
|
71826
|
-
var getRegistryApiUrl = () => {
|
|
71827
|
-
return cliConfig.get("registryApiUrl") ?? "https://registry-api.tscircuit.com";
|
|
71828
|
-
};
|
|
71829
|
-
|
|
71830
|
-
// lib/shared/parts-engine-base-urls.ts
|
|
71831
|
-
var partsEngineBaseUrlEnvVars = {
|
|
71832
|
-
jlcsearch: "TSCIRCUIT_JLCSEARCH_BASE_URL",
|
|
71833
|
-
digikey: "TSCIRCUIT_DIGIKEY_BASE_URL",
|
|
71834
|
-
mouser: "TSCIRCUIT_MOUSER_BASE_URL",
|
|
71835
|
-
"datasheet-api": "TSCIRCUIT_DATASHEET_API_BASE_URL"
|
|
71836
|
-
};
|
|
71837
|
-
var getPartsEngineBaseUrl = (provider, defaultBaseUrl) => {
|
|
71838
|
-
const environmentVariable = partsEngineBaseUrlEnvVars[provider];
|
|
71839
|
-
const baseUrl = process.env[environmentVariable] ?? defaultBaseUrl;
|
|
71840
|
-
return baseUrl.replace(/\/+$/, "");
|
|
71841
|
-
};
|
|
71842
|
-
var getPartsEngineBaseUrls = () => {
|
|
71843
|
-
const baseUrls = {};
|
|
71844
|
-
for (const environmentVariable of Object.values(partsEngineBaseUrlEnvVars)) {
|
|
71845
|
-
const baseUrl = process.env[environmentVariable];
|
|
71846
|
-
if (baseUrl !== undefined)
|
|
71847
|
-
baseUrls[environmentVariable] = baseUrl;
|
|
71994
|
+
has(key) {
|
|
71995
|
+
if (this.#options.accessPropertiesByDotNotation) {
|
|
71996
|
+
return hasProperty(this.store, key);
|
|
71997
|
+
}
|
|
71998
|
+
return key in this.store;
|
|
71848
71999
|
}
|
|
71849
|
-
|
|
71850
|
-
|
|
71851
|
-
|
|
71852
|
-
|
|
71853
|
-
|
|
71854
|
-
|
|
71855
|
-
// lib/site/getIndex.ts
|
|
71856
|
-
var getIndex = async ({
|
|
71857
|
-
mainComponentPath,
|
|
71858
|
-
fileServerApiBaseUrl,
|
|
71859
|
-
jscdnBaseUrl,
|
|
71860
|
-
extraRunFrameTabs = []
|
|
71861
|
-
} = {}) => {
|
|
71862
|
-
const standalone = process.env.TSCIRCUIT_STANDALONE === "1";
|
|
71863
|
-
const evalVersion = package_default.devDependencies["@tscircuit/eval"];
|
|
71864
|
-
const standaloneScript = standalone ? `
|
|
71865
|
-
window.TSCIRCUIT_LATEST_EVAL_VERSION = ${JSON.stringify(evalVersion)};
|
|
71866
|
-
window.TSCIRCUIT_ALLOW_SELECTING_EVAL_VERSION = false;
|
|
71867
|
-
window.TSCIRCUIT_TELEMETRY_DISABLED = true;` : "";
|
|
71868
|
-
const sessionToken = getSessionToken();
|
|
71869
|
-
const tokenScript = sessionToken ? `
|
|
71870
|
-
window.TSCIRCUIT_REGISTRY_TOKEN = ${JSON.stringify(sessionToken)};` : "";
|
|
71871
|
-
const fileServerApiScript = fileServerApiBaseUrl ? `
|
|
71872
|
-
window.TSCIRCUIT_FILESERVER_API_BASE_URL = ${JSON.stringify(fileServerApiBaseUrl)};` : "";
|
|
71873
|
-
const jscdnScript = jscdnBaseUrl ? `
|
|
71874
|
-
window.TSCIRCUIT_JSCDN_BASE_URL = ${JSON.stringify(jscdnBaseUrl).replace(/</g, "\\u003c")};` : "";
|
|
71875
|
-
const partsEngineBaseUrls = getPartsEngineBaseUrls();
|
|
71876
|
-
const partsEngineScript = Object.keys(partsEngineBaseUrls).length ? `
|
|
71877
|
-
Object.assign(window, ${JSON.stringify(partsEngineBaseUrls).replace(/</g, "\\u003c")});` : "";
|
|
71878
|
-
return `<html>
|
|
71879
|
-
<head>
|
|
71880
|
-
<meta charset="UTF-8" />
|
|
71881
|
-
${standalone ? '<link rel="icon" href="data:,">' : '<link rel="icon" type="image/png" href="https://github.com/tscircuit.png">'}
|
|
71882
|
-
</head>
|
|
71883
|
-
<body>
|
|
71884
|
-
<script>
|
|
71885
|
-
${mainComponentPath ? `window.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH = ${serializeScriptValue(mainComponentPath)};` : ""}
|
|
71886
|
-
window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI = true;${tokenScript}${fileServerApiScript}${jscdnScript}${partsEngineScript}${standaloneScript}
|
|
71887
|
-
window.TSCIRCUIT_EXTRA_RUNFRAME_TABS = ${serializeScriptValue(extraRunFrameTabs)};
|
|
71888
|
-
</script>
|
|
71889
|
-
${standalone ? "" : '<script src="https://cdn.tailwindcss.com"></script>'}
|
|
71890
|
-
<div id="root">loading...</div>
|
|
71891
|
-
<script>
|
|
71892
|
-
globalThis.process = { env: { NODE_ENV: "production" } }
|
|
71893
|
-
</script>
|
|
71894
|
-
${fileServerApiBaseUrl ? '<script src="/extra-runframe-tabs.js" defer></script>' : ""}
|
|
71895
|
-
<script type="module" src="/standalone.min.js"></script>
|
|
71896
|
-
</body>
|
|
71897
|
-
</html>`;
|
|
71898
|
-
};
|
|
71899
|
-
|
|
71900
|
-
// lib/server/kicad-pcm-proxy.ts
|
|
71901
|
-
import * as fs15 from "node:fs";
|
|
71902
|
-
import * as path17 from "node:path";
|
|
71903
|
-
|
|
71904
|
-
// cli/build/build-kicad-pcm.ts
|
|
71905
|
-
import path15 from "node:path";
|
|
71906
|
-
import fs11 from "node:fs";
|
|
71907
|
-
|
|
71908
|
-
// lib/shared/convert-to-kicad-library.tsx
|
|
71909
|
-
import fs7 from "node:fs";
|
|
71910
|
-
import path11 from "node:path";
|
|
71911
|
-
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
71912
|
-
|
|
71913
|
-
// node_modules/circuit-json-to-kicad/dist/index.js
|
|
71914
|
-
import { cju } from "@tscircuit/circuit-json-util";
|
|
71915
|
-
import { KicadSch } from "kicadts";
|
|
71916
|
-
import { compose as compose2, scale, translate as translate2 } from "transformation-matrix";
|
|
71917
|
-
import {
|
|
71918
|
-
At,
|
|
71919
|
-
Color,
|
|
71920
|
-
Sheet,
|
|
71921
|
-
SheetFill,
|
|
71922
|
-
SheetInstancePage,
|
|
71923
|
-
SheetInstancePath,
|
|
71924
|
-
SheetInstancesForSheet,
|
|
71925
|
-
SheetInstancesProject,
|
|
71926
|
-
SheetProperty,
|
|
71927
|
-
SheetSize,
|
|
71928
|
-
Stroke,
|
|
71929
|
-
TextEffects,
|
|
71930
|
-
TextEffectsFont,
|
|
71931
|
-
TextEffectsJustify
|
|
71932
|
-
} from "kicadts";
|
|
71933
|
-
import { TitleBlock, TitleBlockComment } from "kicadts";
|
|
71934
|
-
import {
|
|
71935
|
-
EmbeddedFonts,
|
|
71936
|
-
LibSymbols,
|
|
71937
|
-
SchematicSymbol as SchematicSymbol4,
|
|
71938
|
-
SymbolPinNames,
|
|
71939
|
-
SymbolPinNumbers,
|
|
71940
|
-
SymbolPower
|
|
71941
|
-
} from "kicadts";
|
|
71942
|
-
import { symbols as symbols3 } from "schematic-symbols";
|
|
71943
|
-
import { symbols } from "schematic-symbols";
|
|
71944
|
-
import { symbols as symbols2 } from "schematic-symbols";
|
|
71945
|
-
import { SchematicSymbol } from "kicadts";
|
|
71946
|
-
import {
|
|
71947
|
-
compose,
|
|
71948
|
-
scale as createScaleMatrix,
|
|
71949
|
-
translate
|
|
71950
|
-
} from "transformation-matrix";
|
|
71951
|
-
import { SymbolArc } from "kicadts";
|
|
71952
|
-
import { applyToPoint } from "transformation-matrix";
|
|
71953
|
-
import { SymbolCircle } from "kicadts";
|
|
71954
|
-
import { applyToPoint as applyToPoint2 } from "transformation-matrix";
|
|
71955
|
-
import { Pts, Stroke as Stroke2, SymbolPolyline, SymbolPolylineFill, Xy } from "kicadts";
|
|
71956
|
-
import { applyToPoint as applyToPoint3 } from "transformation-matrix";
|
|
71957
|
-
import { SymbolRectangle } from "kicadts";
|
|
71958
|
-
import { applyToPoint as applyToPoint4 } from "transformation-matrix";
|
|
71959
|
-
import { SymbolText, TextEffects as TextEffects2, TextEffectsFont as TextEffectsFont2 } from "kicadts";
|
|
71960
|
-
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
71961
|
-
import { SymbolProperty } from "kicadts";
|
|
71962
|
-
import { TextEffects as TextEffects3, TextEffectsFont as TextEffectsFont3 } from "kicadts";
|
|
71963
|
-
import {
|
|
71964
|
-
SchematicSymbol as SchematicSymbol3,
|
|
71965
|
-
SymbolPin,
|
|
71966
|
-
SymbolPinName,
|
|
71967
|
-
SymbolPinNumber,
|
|
71968
|
-
TextEffects as TextEffects4,
|
|
71969
|
-
TextEffectsFont as TextEffectsFont4
|
|
71970
|
-
} from "kicadts";
|
|
71971
|
-
import { applyToPoint as applyToPoint6, scale as createScaleMatrix2 } from "transformation-matrix";
|
|
71972
|
-
import {
|
|
71973
|
-
Polyline,
|
|
71974
|
-
Pts as Pts2,
|
|
71975
|
-
SchematicArc,
|
|
71976
|
-
SchematicRectangle,
|
|
71977
|
-
SchematicText,
|
|
71978
|
-
Stroke as Stroke3,
|
|
71979
|
-
SymbolArcFill,
|
|
71980
|
-
SymbolRectangleFill,
|
|
71981
|
-
TextEffects as TextEffects5,
|
|
71982
|
-
TextEffectsFont as TextEffectsFont5,
|
|
71983
|
-
TextEffectsJustify as TextEffectsJustify2,
|
|
71984
|
-
Uuid,
|
|
71985
|
-
Xy as Xy2
|
|
71986
|
-
} from "kicadts";
|
|
71987
|
-
import { applyToPoint as applyToPoint7 } from "transformation-matrix";
|
|
71988
|
-
import {
|
|
71989
|
-
SchematicSymbol as SchematicSymbol5,
|
|
71990
|
-
SymbolLibId,
|
|
71991
|
-
SymbolProperty as SymbolProperty2,
|
|
71992
|
-
SymbolPin as SymbolPin2,
|
|
71993
|
-
SymbolInstances,
|
|
71994
|
-
SymbolInstancesProject,
|
|
71995
|
-
SymbolInstancePath,
|
|
71996
|
-
TextEffects as TextEffects6,
|
|
71997
|
-
TextEffectsFont as TextEffectsFont6,
|
|
71998
|
-
TextEffectsJustify as TextEffectsJustify3,
|
|
71999
|
-
GlobalLabel
|
|
72000
|
-
} from "kicadts";
|
|
72001
|
-
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
72002
|
-
import { symbols as symbols4 } from "schematic-symbols";
|
|
72003
|
-
import { formatSiUnit } from "format-si-unit";
|
|
72004
|
-
import {
|
|
72005
|
-
EmbeddedFonts as EmbeddedFonts2,
|
|
72006
|
-
SchematicSymbol as SchematicSymbol6,
|
|
72007
|
-
SymbolInstancePath as SymbolInstancePath2,
|
|
72008
|
-
SymbolInstances as SymbolInstances2,
|
|
72009
|
-
SymbolInstancesProject as SymbolInstancesProject2,
|
|
72010
|
-
SymbolLibId as SymbolLibId2,
|
|
72011
|
-
SymbolPin as SymbolPin3,
|
|
72012
|
-
SymbolPinNames as SymbolPinNames2,
|
|
72013
|
-
SymbolPinNumbers as SymbolPinNumbers2,
|
|
72014
|
-
SymbolProperty as SymbolProperty3,
|
|
72015
|
-
TextEffects as TextEffects7,
|
|
72016
|
-
TextEffectsFont as TextEffectsFont7,
|
|
72017
|
-
TextEffectsJustify as TextEffectsJustify4
|
|
72018
|
-
} from "kicadts";
|
|
72019
|
-
import { applyToPoint as applyToPoint9 } from "transformation-matrix";
|
|
72020
|
-
import { Wire, Pts as Pts3, Xy as Xy3, Stroke as Stroke4, Junction } from "kicadts";
|
|
72021
|
-
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
72022
|
-
import {
|
|
72023
|
-
SheetInstances,
|
|
72024
|
-
SheetInstancesRootPath,
|
|
72025
|
-
SheetInstancesRootPage,
|
|
72026
|
-
EmbeddedFonts as EmbeddedFonts3
|
|
72027
|
-
} from "kicadts";
|
|
72028
|
-
import { Paper, Uuid as Uuid4 } from "kicadts";
|
|
72029
|
-
import { KicadPcb as KicadPcb2 } from "kicadts";
|
|
72030
|
-
import { cju as cju2 } from "@tscircuit/circuit-json-util";
|
|
72031
|
-
import { compose as compose7, translate as translate7, scale as scale5 } from "transformation-matrix";
|
|
72032
|
-
|
|
72033
|
-
// node_modules/earcut/src/earcut.js
|
|
72034
|
-
var steiners = new Set;
|
|
72035
|
-
var filteredOut = false;
|
|
72036
|
-
function earcut(data, holeIndices, dim = 2) {
|
|
72037
|
-
const hasHoles = holeIndices && holeIndices.length;
|
|
72038
|
-
const outerLen = hasHoles ? holeIndices[0] * dim : data.length;
|
|
72039
|
-
if (steiners.size)
|
|
72040
|
-
steiners.clear();
|
|
72041
|
-
let outerNode = linkedList(data, 0, outerLen, dim, true);
|
|
72042
|
-
const triangles = [];
|
|
72043
|
-
if (!outerNode || outerNode.next === outerNode.prev)
|
|
72044
|
-
return triangles;
|
|
72045
|
-
let minX = 0, minY = 0, invSize = 0;
|
|
72046
|
-
if (hasHoles)
|
|
72047
|
-
outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
|
|
72048
|
-
if (data.length > 80 * dim) {
|
|
72049
|
-
minX = data[0];
|
|
72050
|
-
minY = data[1];
|
|
72051
|
-
let maxX = minX;
|
|
72052
|
-
let maxY = minY;
|
|
72053
|
-
for (let i = dim;i < outerLen; i += dim) {
|
|
72054
|
-
const x = data[i];
|
|
72055
|
-
const y = data[i + 1];
|
|
72056
|
-
if (x < minX)
|
|
72057
|
-
minX = x;
|
|
72058
|
-
if (y < minY)
|
|
72059
|
-
minY = y;
|
|
72060
|
-
if (x > maxX)
|
|
72061
|
-
maxX = x;
|
|
72062
|
-
if (y > maxY)
|
|
72063
|
-
maxY = y;
|
|
72000
|
+
reset(...keys) {
|
|
72001
|
+
for (const key of keys) {
|
|
72002
|
+
if (isExist(this.#defaultValues[key])) {
|
|
72003
|
+
this.set(key, this.#defaultValues[key]);
|
|
72004
|
+
}
|
|
72064
72005
|
}
|
|
72065
|
-
invSize = Math.max(maxX - minX, maxY - minY);
|
|
72066
|
-
invSize = invSize !== 0 ? 32767 / invSize : 0;
|
|
72067
72006
|
}
|
|
72068
|
-
|
|
72069
|
-
|
|
72070
|
-
|
|
72071
|
-
|
|
72072
|
-
|
|
72073
|
-
|
|
72074
|
-
|
|
72075
|
-
|
|
72076
|
-
} else {
|
|
72077
|
-
for (let i = end - dim;i >= start; i -= dim)
|
|
72078
|
-
last = insertNode(i / dim | 0, data[i], data[i + 1], last);
|
|
72007
|
+
delete(key) {
|
|
72008
|
+
const { store } = this;
|
|
72009
|
+
if (this.#options.accessPropertiesByDotNotation) {
|
|
72010
|
+
deleteProperty(store, key);
|
|
72011
|
+
} else {
|
|
72012
|
+
delete store[key];
|
|
72013
|
+
}
|
|
72014
|
+
this.store = store;
|
|
72079
72015
|
}
|
|
72080
|
-
|
|
72081
|
-
|
|
72082
|
-
|
|
72016
|
+
clear() {
|
|
72017
|
+
this.store = createPlainObject();
|
|
72018
|
+
for (const key of Object.keys(this.#defaultValues)) {
|
|
72019
|
+
this.reset(key);
|
|
72020
|
+
}
|
|
72083
72021
|
}
|
|
72084
|
-
|
|
72085
|
-
|
|
72086
|
-
|
|
72087
|
-
const full = end === start;
|
|
72088
|
-
let p = start, again;
|
|
72089
|
-
do {
|
|
72090
|
-
again = false;
|
|
72091
|
-
if (p !== p.next && (steiners.size === 0 || !steiners.has(p)) && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
|
|
72092
|
-
if (full || p === end)
|
|
72093
|
-
end = p.prev;
|
|
72094
|
-
filteredOut = true;
|
|
72095
|
-
removeNode(p);
|
|
72096
|
-
p = p.prev;
|
|
72097
|
-
again = true;
|
|
72098
|
-
} else if (full || p !== end) {
|
|
72099
|
-
p = p.next;
|
|
72100
|
-
again = !full;
|
|
72022
|
+
onDidChange(key, callback) {
|
|
72023
|
+
if (typeof key !== "string") {
|
|
72024
|
+
throw new TypeError(`Expected \`key\` to be of type \`string\`, got ${typeof key}`);
|
|
72101
72025
|
}
|
|
72102
|
-
|
|
72103
|
-
|
|
72104
|
-
}
|
|
72105
|
-
function earcutLinked(ear, triangles, minX, minY, invSize) {
|
|
72106
|
-
if (invSize)
|
|
72107
|
-
indexCurve(ear, minX, minY, invSize);
|
|
72108
|
-
let stop = ear, cured = false;
|
|
72109
|
-
while (ear.prev !== ear.next) {
|
|
72110
|
-
const prev = ear.prev;
|
|
72111
|
-
const next = ear.next;
|
|
72112
|
-
if (area(prev, ear, next) < 0 && (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear))) {
|
|
72113
|
-
triangles.push(prev.i, ear.i, next.i);
|
|
72114
|
-
removeNode(ear);
|
|
72115
|
-
ear = next;
|
|
72116
|
-
stop = next;
|
|
72117
|
-
continue;
|
|
72026
|
+
if (typeof callback !== "function") {
|
|
72027
|
+
throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof callback}`);
|
|
72118
72028
|
}
|
|
72119
|
-
|
|
72120
|
-
|
|
72121
|
-
|
|
72122
|
-
|
|
72123
|
-
|
|
72124
|
-
|
|
72125
|
-
|
|
72029
|
+
return this._handleChange(() => this.get(key), callback);
|
|
72030
|
+
}
|
|
72031
|
+
onDidAnyChange(callback) {
|
|
72032
|
+
if (typeof callback !== "function") {
|
|
72033
|
+
throw new TypeError(`Expected \`callback\` to be of type \`function\`, got ${typeof callback}`);
|
|
72034
|
+
}
|
|
72035
|
+
return this._handleChange(() => this.store, callback);
|
|
72036
|
+
}
|
|
72037
|
+
get size() {
|
|
72038
|
+
return Object.keys(this.store).length;
|
|
72039
|
+
}
|
|
72040
|
+
get store() {
|
|
72041
|
+
try {
|
|
72042
|
+
const data = fs3.readFileSync(this.path, this.#encryptionKey ? null : "utf8");
|
|
72043
|
+
const dataString = this._encryptData(data);
|
|
72044
|
+
const deserializedData = this._deserialize(dataString);
|
|
72045
|
+
this._validate(deserializedData);
|
|
72046
|
+
return Object.assign(createPlainObject(), deserializedData);
|
|
72047
|
+
} catch (error) {
|
|
72048
|
+
if (error?.code === "ENOENT") {
|
|
72049
|
+
this._ensureDirectory();
|
|
72050
|
+
return createPlainObject();
|
|
72126
72051
|
}
|
|
72127
|
-
if (
|
|
72128
|
-
|
|
72129
|
-
stop = ear;
|
|
72130
|
-
cured = true;
|
|
72131
|
-
continue;
|
|
72052
|
+
if (this.#options.clearInvalidConfig && error.name === "SyntaxError") {
|
|
72053
|
+
return createPlainObject();
|
|
72132
72054
|
}
|
|
72133
|
-
|
|
72134
|
-
break;
|
|
72055
|
+
throw error;
|
|
72135
72056
|
}
|
|
72136
72057
|
}
|
|
72137
|
-
|
|
72138
|
-
|
|
72139
|
-
|
|
72140
|
-
|
|
72141
|
-
|
|
72142
|
-
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)
|
|
72143
|
-
return false;
|
|
72144
|
-
p = p.next;
|
|
72058
|
+
set store(value) {
|
|
72059
|
+
this._ensureDirectory();
|
|
72060
|
+
this._validate(value);
|
|
72061
|
+
this._write(value);
|
|
72062
|
+
this.events.dispatchEvent(new Event("change"));
|
|
72145
72063
|
}
|
|
72146
|
-
|
|
72147
|
-
|
|
72148
|
-
|
|
72149
|
-
|
|
72150
|
-
|
|
72151
|
-
|
|
72152
|
-
if (
|
|
72153
|
-
return
|
|
72154
|
-
|
|
72064
|
+
*[Symbol.iterator]() {
|
|
72065
|
+
for (const [key, value] of Object.entries(this.store)) {
|
|
72066
|
+
yield [key, value];
|
|
72067
|
+
}
|
|
72068
|
+
}
|
|
72069
|
+
_encryptData(data) {
|
|
72070
|
+
if (!this.#encryptionKey) {
|
|
72071
|
+
return typeof data === "string" ? data : uint8ArrayToString(data);
|
|
72072
|
+
}
|
|
72073
|
+
try {
|
|
72074
|
+
const initializationVector = data.slice(0, 16);
|
|
72075
|
+
const password = crypto2.pbkdf2Sync(this.#encryptionKey, initializationVector.toString(), 1e4, 32, "sha512");
|
|
72076
|
+
const decipher = crypto2.createDecipheriv(encryptionAlgorithm, password, initializationVector);
|
|
72077
|
+
const slice = data.slice(17);
|
|
72078
|
+
const dataUpdate = typeof slice === "string" ? stringToUint8Array(slice) : slice;
|
|
72079
|
+
return uint8ArrayToString(concatUint8Arrays([decipher.update(dataUpdate), decipher.final()]));
|
|
72080
|
+
} catch {}
|
|
72081
|
+
return data.toString();
|
|
72082
|
+
}
|
|
72083
|
+
_handleChange(getter, callback) {
|
|
72084
|
+
let currentValue = getter();
|
|
72085
|
+
const onChange = () => {
|
|
72086
|
+
const oldValue = currentValue;
|
|
72087
|
+
const newValue = getter();
|
|
72088
|
+
if (isDeepStrictEqual(newValue, oldValue)) {
|
|
72089
|
+
return;
|
|
72090
|
+
}
|
|
72091
|
+
currentValue = newValue;
|
|
72092
|
+
callback.call(this, newValue, oldValue);
|
|
72093
|
+
};
|
|
72094
|
+
this.events.addEventListener("change", onChange);
|
|
72095
|
+
return () => {
|
|
72096
|
+
this.events.removeEventListener("change", onChange);
|
|
72097
|
+
};
|
|
72155
72098
|
}
|
|
72156
|
-
|
|
72157
|
-
|
|
72158
|
-
|
|
72159
|
-
|
|
72160
|
-
|
|
72099
|
+
_deserialize = (value) => JSON.parse(value);
|
|
72100
|
+
_serialize = (value) => JSON.stringify(value, undefined, "\t");
|
|
72101
|
+
_validate(data) {
|
|
72102
|
+
if (!this.#validator) {
|
|
72103
|
+
return;
|
|
72104
|
+
}
|
|
72105
|
+
const valid = this.#validator(data);
|
|
72106
|
+
if (valid || !this.#validator.errors) {
|
|
72107
|
+
return;
|
|
72108
|
+
}
|
|
72109
|
+
const errors = this.#validator.errors.map(({ instancePath, message = "" }) => `\`${instancePath.slice(1)}\` ${message}`);
|
|
72110
|
+
throw new Error("Config schema violation: " + errors.join("; "));
|
|
72161
72111
|
}
|
|
72162
|
-
|
|
72163
|
-
}
|
|
72164
|
-
|
|
72165
|
-
|
|
72166
|
-
|
|
72167
|
-
|
|
72168
|
-
|
|
72169
|
-
|
|
72170
|
-
|
|
72171
|
-
|
|
72172
|
-
removeNode(p.next);
|
|
72173
|
-
p = start = b;
|
|
72174
|
-
cured = true;
|
|
72112
|
+
_ensureDirectory() {
|
|
72113
|
+
fs3.mkdirSync(path5.dirname(this.path), { recursive: true });
|
|
72114
|
+
}
|
|
72115
|
+
_write(value) {
|
|
72116
|
+
let data = this._serialize(value);
|
|
72117
|
+
if (this.#encryptionKey) {
|
|
72118
|
+
const initializationVector = crypto2.randomBytes(16);
|
|
72119
|
+
const password = crypto2.pbkdf2Sync(this.#encryptionKey, initializationVector.toString(), 1e4, 32, "sha512");
|
|
72120
|
+
const cipher = crypto2.createCipheriv(encryptionAlgorithm, password, initializationVector);
|
|
72121
|
+
data = concatUint8Arrays([initializationVector, stringToUint8Array(":"), cipher.update(stringToUint8Array(data)), cipher.final()]);
|
|
72175
72122
|
}
|
|
72176
|
-
|
|
72177
|
-
|
|
72178
|
-
|
|
72179
|
-
|
|
72180
|
-
|
|
72181
|
-
|
|
72182
|
-
|
|
72183
|
-
|
|
72184
|
-
|
|
72185
|
-
|
|
72186
|
-
|
|
72187
|
-
a = filterPoints(a, a.next);
|
|
72188
|
-
c = filterPoints(c, c.next);
|
|
72189
|
-
earcutLinked(a, triangles, minX, minY, invSize);
|
|
72190
|
-
earcutLinked(c, triangles, minX, minY, invSize);
|
|
72191
|
-
return;
|
|
72123
|
+
if (process7.env.SNAP) {
|
|
72124
|
+
fs3.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
72125
|
+
} else {
|
|
72126
|
+
try {
|
|
72127
|
+
writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
72128
|
+
} catch (error) {
|
|
72129
|
+
if (error?.code === "EXDEV") {
|
|
72130
|
+
fs3.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
72131
|
+
return;
|
|
72132
|
+
}
|
|
72133
|
+
throw error;
|
|
72192
72134
|
}
|
|
72193
|
-
b = b.next;
|
|
72194
72135
|
}
|
|
72195
|
-
a = a.next;
|
|
72196
|
-
} while (a !== start);
|
|
72197
|
-
}
|
|
72198
|
-
var indexActive = false;
|
|
72199
|
-
function eliminateHoles(data, holeIndices, outerNode, dim) {
|
|
72200
|
-
const queue = [];
|
|
72201
|
-
for (let i = 0, len = holeIndices.length;i < len; i++) {
|
|
72202
|
-
const start = holeIndices[i] * dim;
|
|
72203
|
-
const end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
|
|
72204
|
-
const list = linkedList(data, start, end, dim, false);
|
|
72205
|
-
if (list === list.next)
|
|
72206
|
-
steiners.add(list);
|
|
72207
|
-
queue.push(getLeftmost(list));
|
|
72208
|
-
}
|
|
72209
|
-
queue.sort(compareXYSlope);
|
|
72210
|
-
buildBlockIndex(data.length / dim, holeIndices.length);
|
|
72211
|
-
indexSegment(outerNode, outerNode);
|
|
72212
|
-
indexActive = true;
|
|
72213
|
-
for (let i = 0;i < queue.length; i++) {
|
|
72214
|
-
outerNode = eliminateHole(queue[i], outerNode);
|
|
72215
72136
|
}
|
|
72216
|
-
|
|
72217
|
-
|
|
72218
|
-
|
|
72219
|
-
|
|
72220
|
-
|
|
72221
|
-
|
|
72222
|
-
|
|
72223
|
-
|
|
72224
|
-
|
|
72225
|
-
|
|
72137
|
+
_watch() {
|
|
72138
|
+
this._ensureDirectory();
|
|
72139
|
+
if (!fs3.existsSync(this.path)) {
|
|
72140
|
+
this._write(createPlainObject());
|
|
72141
|
+
}
|
|
72142
|
+
if (process7.platform === "win32") {
|
|
72143
|
+
fs3.watch(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
72144
|
+
this.events.dispatchEvent(new Event("change"));
|
|
72145
|
+
}, { wait: 100 }));
|
|
72146
|
+
} else {
|
|
72147
|
+
fs3.watchFile(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
72148
|
+
this.events.dispatchEvent(new Event("change"));
|
|
72149
|
+
}, { wait: 5000 }));
|
|
72150
|
+
}
|
|
72226
72151
|
}
|
|
72227
|
-
|
|
72228
|
-
|
|
72229
|
-
|
|
72230
|
-
|
|
72231
|
-
|
|
72232
|
-
|
|
72233
|
-
|
|
72234
|
-
|
|
72235
|
-
|
|
72236
|
-
|
|
72237
|
-
|
|
72238
|
-
|
|
72239
|
-
|
|
72240
|
-
if (blockBBox.length < maxBlocks * 4)
|
|
72241
|
-
blockBBox = new Float64Array(maxBlocks * 4);
|
|
72242
|
-
numBlocks = 0;
|
|
72243
|
-
}
|
|
72244
|
-
function indexSegment(head, stop) {
|
|
72245
|
-
let p = head;
|
|
72246
|
-
do {
|
|
72247
|
-
const b = numBlocks++;
|
|
72248
|
-
blockHead[b] = p;
|
|
72249
|
-
let minX = p.x, minY = p.y, maxX = p.x, maxY = p.y;
|
|
72250
|
-
let k = 0;
|
|
72251
|
-
do {
|
|
72252
|
-
const c = p.next;
|
|
72253
|
-
p.z = b;
|
|
72254
|
-
if (c.x < minX)
|
|
72255
|
-
minX = c.x;
|
|
72256
|
-
if (c.x > maxX)
|
|
72257
|
-
maxX = c.x;
|
|
72258
|
-
if (c.y < minY)
|
|
72259
|
-
minY = c.y;
|
|
72260
|
-
if (c.y > maxY)
|
|
72261
|
-
maxY = c.y;
|
|
72262
|
-
p = c;
|
|
72263
|
-
} while (++k < K && p !== stop);
|
|
72264
|
-
blockStop[b] = p;
|
|
72265
|
-
const g = b * 4;
|
|
72266
|
-
blockBBox[g] = minX;
|
|
72267
|
-
blockBBox[g + 1] = minY;
|
|
72268
|
-
blockBBox[g + 2] = maxX;
|
|
72269
|
-
blockBBox[g + 3] = maxY;
|
|
72270
|
-
} while (p !== stop);
|
|
72271
|
-
}
|
|
72272
|
-
function growBlock(head, tail) {
|
|
72273
|
-
const g = head.z * 4;
|
|
72274
|
-
if (tail.x < blockBBox[g])
|
|
72275
|
-
blockBBox[g] = tail.x;
|
|
72276
|
-
if (tail.y < blockBBox[g + 1])
|
|
72277
|
-
blockBBox[g + 1] = tail.y;
|
|
72278
|
-
if (tail.x > blockBBox[g + 2])
|
|
72279
|
-
blockBBox[g + 2] = tail.x;
|
|
72280
|
-
if (tail.y > blockBBox[g + 3])
|
|
72281
|
-
blockBBox[g + 3] = tail.y;
|
|
72282
|
-
}
|
|
72283
|
-
function liveBlockStop(b) {
|
|
72284
|
-
let stop = blockStop[b];
|
|
72285
|
-
while (stop.prev.next !== stop)
|
|
72286
|
-
stop = stop.next;
|
|
72287
|
-
blockStop[b] = stop;
|
|
72288
|
-
return stop;
|
|
72289
|
-
}
|
|
72290
|
-
function liveBlockHead(b) {
|
|
72291
|
-
let head = blockHead[b];
|
|
72292
|
-
while (head.prev.next !== head)
|
|
72293
|
-
head = head.next;
|
|
72294
|
-
blockHead[b] = head;
|
|
72295
|
-
return head;
|
|
72296
|
-
}
|
|
72297
|
-
function findHoleBridge(hole, outerNode) {
|
|
72298
|
-
let p = outerNode;
|
|
72299
|
-
const hx = hole.x;
|
|
72300
|
-
const hy = hole.y;
|
|
72301
|
-
let qx = -Infinity;
|
|
72302
|
-
let m;
|
|
72303
|
-
if (equals(hole, p))
|
|
72304
|
-
return p;
|
|
72305
|
-
for (let b = 0, g = 0;b < numBlocks; b++, g += 4) {
|
|
72306
|
-
if (hy < blockBBox[g + 1] || hy > blockBBox[g + 3] || blockBBox[g] > hx || blockBBox[g + 2] <= qx)
|
|
72307
|
-
continue;
|
|
72308
|
-
const stop = liveBlockStop(b);
|
|
72309
|
-
p = liveBlockHead(b);
|
|
72310
|
-
do {
|
|
72311
|
-
if (p.prev.next === p) {
|
|
72312
|
-
if (equals(hole, p.next))
|
|
72313
|
-
return p.next;
|
|
72314
|
-
else if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
|
|
72315
|
-
const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
|
|
72316
|
-
if (x <= hx && x > qx) {
|
|
72317
|
-
qx = x;
|
|
72318
|
-
m = p.x < p.next.x ? p : p.next;
|
|
72319
|
-
if (x === hx)
|
|
72320
|
-
return m;
|
|
72321
|
-
}
|
|
72152
|
+
_migrate(migrations, versionToMigrate, beforeEachMigration) {
|
|
72153
|
+
let previousMigratedVersion = this._get(MIGRATION_KEY, "0.0.0");
|
|
72154
|
+
const newerVersions = Object.keys(migrations).filter((candidateVersion) => this._shouldPerformMigration(candidateVersion, previousMigratedVersion, versionToMigrate));
|
|
72155
|
+
let storeBackup = { ...this.store };
|
|
72156
|
+
for (const version of newerVersions) {
|
|
72157
|
+
try {
|
|
72158
|
+
if (beforeEachMigration) {
|
|
72159
|
+
beforeEachMigration(this, {
|
|
72160
|
+
fromVersion: previousMigratedVersion,
|
|
72161
|
+
toVersion: version,
|
|
72162
|
+
finalVersion: versionToMigrate,
|
|
72163
|
+
versions: newerVersions
|
|
72164
|
+
});
|
|
72322
72165
|
}
|
|
72166
|
+
const migration = migrations[version];
|
|
72167
|
+
migration?.(this);
|
|
72168
|
+
this._set(MIGRATION_KEY, version);
|
|
72169
|
+
previousMigratedVersion = version;
|
|
72170
|
+
storeBackup = { ...this.store };
|
|
72171
|
+
} catch (error) {
|
|
72172
|
+
this.store = storeBackup;
|
|
72173
|
+
throw new Error(`Something went wrong during the migration! Changes applied to the store until this failed migration will be restored. ${error}`);
|
|
72323
72174
|
}
|
|
72324
|
-
|
|
72325
|
-
|
|
72175
|
+
}
|
|
72176
|
+
if (this._isVersionInRangeFormat(previousMigratedVersion) || !import_semver.default.eq(previousMigratedVersion, versionToMigrate)) {
|
|
72177
|
+
this._set(MIGRATION_KEY, versionToMigrate);
|
|
72178
|
+
}
|
|
72326
72179
|
}
|
|
72327
|
-
|
|
72328
|
-
|
|
72329
|
-
|
|
72330
|
-
|
|
72331
|
-
|
|
72332
|
-
const tmaxY = Math.max(hy, my);
|
|
72333
|
-
let tanMin = Infinity;
|
|
72334
|
-
for (let b = 0, g = 0;b < numBlocks; b++, g += 4) {
|
|
72335
|
-
if (blockBBox[g + 2] < mx || blockBBox[g] > hx || blockBBox[g + 3] < tminY || blockBBox[g + 1] > tmaxY)
|
|
72336
|
-
continue;
|
|
72337
|
-
const stop = liveBlockStop(b);
|
|
72338
|
-
p = liveBlockHead(b);
|
|
72339
|
-
do {
|
|
72340
|
-
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)) {
|
|
72341
|
-
const tan = Math.abs(hy - p.y) / (hx - p.x);
|
|
72342
|
-
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)))) {
|
|
72343
|
-
m = p;
|
|
72344
|
-
tanMin = tan;
|
|
72345
|
-
}
|
|
72180
|
+
_containsReservedKey(key) {
|
|
72181
|
+
if (typeof key === "object") {
|
|
72182
|
+
const firsKey = Object.keys(key)[0];
|
|
72183
|
+
if (firsKey === INTERNAL_KEY) {
|
|
72184
|
+
return true;
|
|
72346
72185
|
}
|
|
72347
|
-
|
|
72348
|
-
|
|
72186
|
+
}
|
|
72187
|
+
if (typeof key !== "string") {
|
|
72188
|
+
return false;
|
|
72189
|
+
}
|
|
72190
|
+
if (this.#options.accessPropertiesByDotNotation) {
|
|
72191
|
+
if (key.startsWith(`${INTERNAL_KEY}.`)) {
|
|
72192
|
+
return true;
|
|
72193
|
+
}
|
|
72194
|
+
return false;
|
|
72195
|
+
}
|
|
72196
|
+
return false;
|
|
72349
72197
|
}
|
|
72350
|
-
|
|
72351
|
-
|
|
72352
|
-
function sectorContainsSector(m, p) {
|
|
72353
|
-
return area(m.prev, m, p.prev) < 0 && area(p.next, m, m.next) < 0;
|
|
72354
|
-
}
|
|
72355
|
-
var sortArr = [];
|
|
72356
|
-
var sortBuf = [];
|
|
72357
|
-
var zArr = new Uint32Array(0);
|
|
72358
|
-
var zBuf = new Uint32Array(0);
|
|
72359
|
-
var counts = new Uint32Array(256);
|
|
72360
|
-
function indexCurve(start, minX, minY, invSize) {
|
|
72361
|
-
let p = start;
|
|
72362
|
-
let n = 0;
|
|
72363
|
-
do {
|
|
72364
|
-
p.z = zOrder(p.x, p.y, minX, minY, invSize);
|
|
72365
|
-
sortArr[n++] = p;
|
|
72366
|
-
p = p.next;
|
|
72367
|
-
} while (p !== start);
|
|
72368
|
-
sortNodes(n);
|
|
72369
|
-
let prev = null;
|
|
72370
|
-
for (let i = 0;i < n; i++) {
|
|
72371
|
-
const node = sortArr[i];
|
|
72372
|
-
node.prevZ = prev;
|
|
72373
|
-
if (prev)
|
|
72374
|
-
prev.nextZ = node;
|
|
72375
|
-
prev = node;
|
|
72198
|
+
_isVersionInRangeFormat(version) {
|
|
72199
|
+
return import_semver.default.clean(version) === null;
|
|
72376
72200
|
}
|
|
72377
|
-
|
|
72378
|
-
|
|
72379
|
-
|
|
72380
|
-
|
|
72381
|
-
function sortNodes(n) {
|
|
72382
|
-
if (n <= 32) {
|
|
72383
|
-
for (let i = 1;i < n; i++) {
|
|
72384
|
-
const node = sortArr[i], z = node.z;
|
|
72385
|
-
let j = i - 1;
|
|
72386
|
-
while (j >= 0 && sortArr[j].z > z) {
|
|
72387
|
-
sortArr[j + 1] = sortArr[j];
|
|
72388
|
-
j--;
|
|
72201
|
+
_shouldPerformMigration(candidateVersion, previousMigratedVersion, versionToMigrate) {
|
|
72202
|
+
if (this._isVersionInRangeFormat(candidateVersion)) {
|
|
72203
|
+
if (previousMigratedVersion !== "0.0.0" && import_semver.default.satisfies(previousMigratedVersion, candidateVersion)) {
|
|
72204
|
+
return false;
|
|
72389
72205
|
}
|
|
72390
|
-
|
|
72206
|
+
return import_semver.default.satisfies(versionToMigrate, candidateVersion);
|
|
72391
72207
|
}
|
|
72392
|
-
|
|
72393
|
-
|
|
72394
|
-
|
|
72395
|
-
|
|
72396
|
-
|
|
72397
|
-
|
|
72208
|
+
if (import_semver.default.lte(candidateVersion, previousMigratedVersion)) {
|
|
72209
|
+
return false;
|
|
72210
|
+
}
|
|
72211
|
+
if (import_semver.default.gt(candidateVersion, versionToMigrate)) {
|
|
72212
|
+
return false;
|
|
72213
|
+
}
|
|
72214
|
+
return true;
|
|
72398
72215
|
}
|
|
72399
|
-
|
|
72400
|
-
|
|
72401
|
-
radixPass(n, sortArr, zArr, sortBuf, zBuf, 0);
|
|
72402
|
-
radixPass(n, sortBuf, zBuf, sortArr, zArr, 8);
|
|
72403
|
-
radixPass(n, sortArr, zArr, sortBuf, zBuf, 16);
|
|
72404
|
-
radixPass(n, sortBuf, zBuf, sortArr, zArr, 24);
|
|
72405
|
-
}
|
|
72406
|
-
function radixPass(n, src, srcZ, dst, dstZ, shift) {
|
|
72407
|
-
counts.fill(0);
|
|
72408
|
-
for (let i = 0;i < n; i++)
|
|
72409
|
-
counts[srcZ[i] >>> shift & 255]++;
|
|
72410
|
-
let sum = 0;
|
|
72411
|
-
for (let b = 0;b < 256; b++) {
|
|
72412
|
-
const c = counts[b];
|
|
72413
|
-
counts[b] = sum;
|
|
72414
|
-
sum += c;
|
|
72216
|
+
_get(key, defaultValue) {
|
|
72217
|
+
return getProperty(this.store, key, defaultValue);
|
|
72415
72218
|
}
|
|
72416
|
-
|
|
72417
|
-
const
|
|
72418
|
-
|
|
72419
|
-
|
|
72420
|
-
dstZ[pos] = z;
|
|
72219
|
+
_set(key, value) {
|
|
72220
|
+
const { store } = this;
|
|
72221
|
+
setProperty(store, key, value);
|
|
72222
|
+
this.store = store;
|
|
72421
72223
|
}
|
|
72422
72224
|
}
|
|
72423
|
-
|
|
72424
|
-
|
|
72425
|
-
|
|
72426
|
-
x = (x | x << 8) & 16711935;
|
|
72427
|
-
x = (x | x << 4) & 252645135;
|
|
72428
|
-
x = (x | x << 2) & 858993459;
|
|
72429
|
-
x = (x | x << 1) & 1431655765;
|
|
72430
|
-
y = (y | y << 8) & 16711935;
|
|
72431
|
-
y = (y | y << 4) & 252645135;
|
|
72432
|
-
y = (y | y << 2) & 858993459;
|
|
72433
|
-
y = (y | y << 1) & 1431655765;
|
|
72434
|
-
return x | y << 1;
|
|
72435
|
-
}
|
|
72436
|
-
function getLeftmost(start) {
|
|
72437
|
-
let p = start, leftmost = start;
|
|
72438
|
-
do {
|
|
72439
|
-
if (p.x < leftmost.x || p.x === leftmost.x && p.y < leftmost.y)
|
|
72440
|
-
leftmost = p;
|
|
72441
|
-
p = p.next;
|
|
72442
|
-
} while (p !== start);
|
|
72443
|
-
return leftmost;
|
|
72444
|
-
}
|
|
72445
|
-
function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
72446
|
-
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);
|
|
72447
|
-
}
|
|
72448
|
-
function isValidDiagonal(a, b) {
|
|
72449
|
-
const zeroLength = equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0;
|
|
72450
|
-
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));
|
|
72451
|
-
}
|
|
72452
|
-
function area(p, q, r) {
|
|
72453
|
-
return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
|
72454
|
-
}
|
|
72455
|
-
function equals(p1, p2) {
|
|
72456
|
-
return p1.x === p2.x && p1.y === p2.y;
|
|
72457
|
-
}
|
|
72458
|
-
function intersects(p1, q1, p2, q2, includeBoundary = true) {
|
|
72459
|
-
const o1 = area(p1, q1, p2);
|
|
72460
|
-
const o2 = area(p1, q1, q2);
|
|
72461
|
-
const o3 = area(p2, q2, p1);
|
|
72462
|
-
const o4 = area(p2, q2, q1);
|
|
72463
|
-
if ((o1 > 0 && o2 < 0 || o1 < 0 && o2 > 0) && (o3 > 0 && o4 < 0 || o3 < 0 && o4 > 0))
|
|
72464
|
-
return true;
|
|
72465
|
-
if (!includeBoundary)
|
|
72466
|
-
return false;
|
|
72467
|
-
if (o1 === 0 && onSegment(p1, p2, q1))
|
|
72468
|
-
return true;
|
|
72469
|
-
if (o2 === 0 && onSegment(p1, q2, q1))
|
|
72470
|
-
return true;
|
|
72471
|
-
if (o3 === 0 && onSegment(p2, p1, q2))
|
|
72472
|
-
return true;
|
|
72473
|
-
if (o4 === 0 && onSegment(p2, q1, q2))
|
|
72474
|
-
return true;
|
|
72475
|
-
return false;
|
|
72476
|
-
}
|
|
72477
|
-
function onSegment(p, q, r) {
|
|
72478
|
-
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);
|
|
72225
|
+
|
|
72226
|
+
// node_modules/jwt-decode/build/esm/index.js
|
|
72227
|
+
class InvalidTokenError extends Error {
|
|
72479
72228
|
}
|
|
72480
|
-
|
|
72481
|
-
|
|
72482
|
-
|
|
72483
|
-
|
|
72484
|
-
|
|
72485
|
-
|
|
72486
|
-
do {
|
|
72487
|
-
const n = p.next;
|
|
72488
|
-
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) {
|
|
72489
|
-
p = n;
|
|
72490
|
-
continue;
|
|
72229
|
+
InvalidTokenError.prototype.name = "InvalidTokenError";
|
|
72230
|
+
function b64DecodeUnicode(str) {
|
|
72231
|
+
return decodeURIComponent(atob(str).replace(/(.)/g, (m, p) => {
|
|
72232
|
+
let code = p.charCodeAt(0).toString(16).toUpperCase();
|
|
72233
|
+
if (code.length < 2) {
|
|
72234
|
+
code = "0" + code;
|
|
72491
72235
|
}
|
|
72492
|
-
|
|
72493
|
-
|
|
72494
|
-
p = n;
|
|
72495
|
-
} while (p !== a);
|
|
72496
|
-
return false;
|
|
72236
|
+
return "%" + code;
|
|
72237
|
+
}));
|
|
72497
72238
|
}
|
|
72498
|
-
function
|
|
72499
|
-
|
|
72239
|
+
function base64UrlDecode(str) {
|
|
72240
|
+
let output = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
72241
|
+
switch (output.length % 4) {
|
|
72242
|
+
case 0:
|
|
72243
|
+
break;
|
|
72244
|
+
case 2:
|
|
72245
|
+
output += "==";
|
|
72246
|
+
break;
|
|
72247
|
+
case 3:
|
|
72248
|
+
output += "=";
|
|
72249
|
+
break;
|
|
72250
|
+
default:
|
|
72251
|
+
throw new Error("base64 string is not of the correct length");
|
|
72252
|
+
}
|
|
72253
|
+
try {
|
|
72254
|
+
return b64DecodeUnicode(output);
|
|
72255
|
+
} catch (err) {
|
|
72256
|
+
return atob(output);
|
|
72257
|
+
}
|
|
72500
72258
|
}
|
|
72501
|
-
function
|
|
72502
|
-
|
|
72503
|
-
|
|
72504
|
-
|
|
72505
|
-
|
|
72506
|
-
|
|
72507
|
-
|
|
72508
|
-
|
|
72509
|
-
|
|
72510
|
-
|
|
72511
|
-
|
|
72512
|
-
|
|
72259
|
+
function jwtDecode(token, options) {
|
|
72260
|
+
if (typeof token !== "string") {
|
|
72261
|
+
throw new InvalidTokenError("Invalid token specified: must be a string");
|
|
72262
|
+
}
|
|
72263
|
+
options || (options = {});
|
|
72264
|
+
const pos = options.header === true ? 0 : 1;
|
|
72265
|
+
const part = token.split(".")[pos];
|
|
72266
|
+
if (typeof part !== "string") {
|
|
72267
|
+
throw new InvalidTokenError(`Invalid token specified: missing part #${pos + 1}`);
|
|
72268
|
+
}
|
|
72269
|
+
let decoded;
|
|
72270
|
+
try {
|
|
72271
|
+
decoded = base64UrlDecode(part);
|
|
72272
|
+
} catch (e) {
|
|
72273
|
+
throw new InvalidTokenError(`Invalid token specified: invalid base64 for part #${pos + 1} (${e.message})`);
|
|
72274
|
+
}
|
|
72275
|
+
try {
|
|
72276
|
+
return JSON.parse(decoded);
|
|
72277
|
+
} catch (e) {
|
|
72278
|
+
throw new InvalidTokenError(`Invalid token specified: invalid json for part #${pos + 1} (${e.message})`);
|
|
72279
|
+
}
|
|
72513
72280
|
}
|
|
72514
|
-
|
|
72515
|
-
|
|
72516
|
-
|
|
72517
|
-
|
|
72518
|
-
|
|
72519
|
-
|
|
72520
|
-
|
|
72521
|
-
|
|
72522
|
-
|
|
72523
|
-
|
|
72524
|
-
|
|
72281
|
+
|
|
72282
|
+
// lib/cli-config/index.ts
|
|
72283
|
+
import fs5 from "node:fs";
|
|
72284
|
+
import os3 from "node:os";
|
|
72285
|
+
import path7 from "node:path";
|
|
72286
|
+
|
|
72287
|
+
// lib/shared/handle-registry-auth-error.ts
|
|
72288
|
+
import fs4 from "node:fs";
|
|
72289
|
+
import os2 from "node:os";
|
|
72290
|
+
import path6 from "node:path";
|
|
72291
|
+
|
|
72292
|
+
// node_modules/kleur/index.mjs
|
|
72293
|
+
var FORCE_COLOR;
|
|
72294
|
+
var NODE_DISABLE_COLORS;
|
|
72295
|
+
var NO_COLOR;
|
|
72296
|
+
var TERM;
|
|
72297
|
+
var isTTY = true;
|
|
72298
|
+
if (typeof process !== "undefined") {
|
|
72299
|
+
({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env || {});
|
|
72300
|
+
isTTY = process.stdout && process.stdout.isTTY;
|
|
72525
72301
|
}
|
|
72526
|
-
|
|
72527
|
-
|
|
72528
|
-
|
|
72529
|
-
|
|
72530
|
-
|
|
72531
|
-
|
|
72532
|
-
|
|
72533
|
-
|
|
72534
|
-
|
|
72535
|
-
|
|
72302
|
+
var $ = {
|
|
72303
|
+
enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== "dumb" && (FORCE_COLOR != null && FORCE_COLOR !== "0" || isTTY),
|
|
72304
|
+
reset: init(0, 0),
|
|
72305
|
+
bold: init(1, 22),
|
|
72306
|
+
dim: init(2, 22),
|
|
72307
|
+
italic: init(3, 23),
|
|
72308
|
+
underline: init(4, 24),
|
|
72309
|
+
inverse: init(7, 27),
|
|
72310
|
+
hidden: init(8, 28),
|
|
72311
|
+
strikethrough: init(9, 29),
|
|
72312
|
+
black: init(30, 39),
|
|
72313
|
+
red: init(31, 39),
|
|
72314
|
+
green: init(32, 39),
|
|
72315
|
+
yellow: init(33, 39),
|
|
72316
|
+
blue: init(34, 39),
|
|
72317
|
+
magenta: init(35, 39),
|
|
72318
|
+
cyan: init(36, 39),
|
|
72319
|
+
white: init(37, 39),
|
|
72320
|
+
gray: init(90, 39),
|
|
72321
|
+
grey: init(90, 39),
|
|
72322
|
+
bgBlack: init(40, 49),
|
|
72323
|
+
bgRed: init(41, 49),
|
|
72324
|
+
bgGreen: init(42, 49),
|
|
72325
|
+
bgYellow: init(43, 49),
|
|
72326
|
+
bgBlue: init(44, 49),
|
|
72327
|
+
bgMagenta: init(45, 49),
|
|
72328
|
+
bgCyan: init(46, 49),
|
|
72329
|
+
bgWhite: init(47, 49)
|
|
72330
|
+
};
|
|
72331
|
+
function run(arr, str) {
|
|
72332
|
+
let i = 0, tmp, beg = "", end = "";
|
|
72333
|
+
for (;i < arr.length; i++) {
|
|
72334
|
+
tmp = arr[i];
|
|
72335
|
+
beg += tmp.open;
|
|
72336
|
+
end += tmp.close;
|
|
72337
|
+
if (!!~str.indexOf(tmp.close)) {
|
|
72338
|
+
str = str.replace(tmp.rgx, tmp.close + tmp.open);
|
|
72339
|
+
}
|
|
72536
72340
|
}
|
|
72537
|
-
return
|
|
72341
|
+
return beg + str + end;
|
|
72538
72342
|
}
|
|
72539
|
-
function
|
|
72540
|
-
|
|
72541
|
-
|
|
72542
|
-
|
|
72543
|
-
|
|
72544
|
-
|
|
72545
|
-
|
|
72546
|
-
|
|
72547
|
-
|
|
72343
|
+
function chain(has, keys) {
|
|
72344
|
+
let ctx = { has, keys };
|
|
72345
|
+
ctx.reset = $.reset.bind(ctx);
|
|
72346
|
+
ctx.bold = $.bold.bind(ctx);
|
|
72347
|
+
ctx.dim = $.dim.bind(ctx);
|
|
72348
|
+
ctx.italic = $.italic.bind(ctx);
|
|
72349
|
+
ctx.underline = $.underline.bind(ctx);
|
|
72350
|
+
ctx.inverse = $.inverse.bind(ctx);
|
|
72351
|
+
ctx.hidden = $.hidden.bind(ctx);
|
|
72352
|
+
ctx.strikethrough = $.strikethrough.bind(ctx);
|
|
72353
|
+
ctx.black = $.black.bind(ctx);
|
|
72354
|
+
ctx.red = $.red.bind(ctx);
|
|
72355
|
+
ctx.green = $.green.bind(ctx);
|
|
72356
|
+
ctx.yellow = $.yellow.bind(ctx);
|
|
72357
|
+
ctx.blue = $.blue.bind(ctx);
|
|
72358
|
+
ctx.magenta = $.magenta.bind(ctx);
|
|
72359
|
+
ctx.cyan = $.cyan.bind(ctx);
|
|
72360
|
+
ctx.white = $.white.bind(ctx);
|
|
72361
|
+
ctx.gray = $.gray.bind(ctx);
|
|
72362
|
+
ctx.grey = $.grey.bind(ctx);
|
|
72363
|
+
ctx.bgBlack = $.bgBlack.bind(ctx);
|
|
72364
|
+
ctx.bgRed = $.bgRed.bind(ctx);
|
|
72365
|
+
ctx.bgGreen = $.bgGreen.bind(ctx);
|
|
72366
|
+
ctx.bgYellow = $.bgYellow.bind(ctx);
|
|
72367
|
+
ctx.bgBlue = $.bgBlue.bind(ctx);
|
|
72368
|
+
ctx.bgMagenta = $.bgMagenta.bind(ctx);
|
|
72369
|
+
ctx.bgCyan = $.bgCyan.bind(ctx);
|
|
72370
|
+
ctx.bgWhite = $.bgWhite.bind(ctx);
|
|
72371
|
+
return ctx;
|
|
72548
72372
|
}
|
|
72549
|
-
function
|
|
72550
|
-
|
|
72551
|
-
|
|
72552
|
-
|
|
72553
|
-
|
|
72554
|
-
|
|
72555
|
-
|
|
72556
|
-
|
|
72557
|
-
|
|
72558
|
-
|
|
72373
|
+
function init(open, close) {
|
|
72374
|
+
let blk = {
|
|
72375
|
+
open: `\x1B[${open}m`,
|
|
72376
|
+
close: `\x1B[${close}m`,
|
|
72377
|
+
rgx: new RegExp(`\\x1b\\[${close}m`, "g")
|
|
72378
|
+
};
|
|
72379
|
+
return function(txt) {
|
|
72380
|
+
if (this !== undefined && this.has !== undefined) {
|
|
72381
|
+
!!~this.has.indexOf(open) || (this.has.push(open), this.keys.push(blk));
|
|
72382
|
+
return txt === undefined ? this : $.enabled ? run(this.keys, txt + "") : txt + "";
|
|
72383
|
+
}
|
|
72384
|
+
return txt === undefined ? chain([open], [blk]) : $.enabled ? run([blk], txt + "") : txt + "";
|
|
72559
72385
|
};
|
|
72560
72386
|
}
|
|
72561
|
-
|
|
72562
|
-
|
|
72563
|
-
|
|
72564
|
-
|
|
72565
|
-
|
|
72387
|
+
var kleur_default = $;
|
|
72388
|
+
|
|
72389
|
+
// lib/shared/handle-registry-auth-error.ts
|
|
72390
|
+
var AUTH_TOKEN_REGEX = /^\/\/npm\.tscircuit\.com\/:_authToken=(.+)$/m;
|
|
72391
|
+
function isUnauthorizedError(error) {
|
|
72392
|
+
const output = [
|
|
72393
|
+
error instanceof Error ? error.message : "",
|
|
72394
|
+
error?.stderr?.toString?.() ?? "",
|
|
72395
|
+
error?.stdout?.toString?.() ?? ""
|
|
72396
|
+
].join(`
|
|
72397
|
+
`);
|
|
72398
|
+
const registryErrorMatch = output.match(/error:\s*(\{[\s\S]*?\})/i);
|
|
72399
|
+
if (registryErrorMatch) {
|
|
72400
|
+
const errorBody = registryErrorMatch[1];
|
|
72401
|
+
const errorCode = errorBody.match(/error_code\s*:\s*['"]?([^,'"}\s]+)/i)?.[1] ?? "";
|
|
72402
|
+
const message = errorBody.match(/message\s*:\s*['"]?([^'"}]+)/i)?.[1] ?? "";
|
|
72403
|
+
if (/unauth|token|auth/i.test(errorCode) || /unauth|token|auth/i.test(message)) {
|
|
72404
|
+
return true;
|
|
72405
|
+
}
|
|
72566
72406
|
}
|
|
72567
|
-
return
|
|
72407
|
+
return /\b(401|E401)\b/i.test(output) || /unauthorized/i.test(output);
|
|
72568
72408
|
}
|
|
72569
|
-
|
|
72570
|
-
|
|
72571
|
-
|
|
72572
|
-
|
|
72573
|
-
|
|
72574
|
-
|
|
72575
|
-
|
|
72576
|
-
|
|
72577
|
-
|
|
72578
|
-
|
|
72579
|
-
if (
|
|
72409
|
+
function hasTsciAuthToken(npmrcPath) {
|
|
72410
|
+
if (!fs4.existsSync(npmrcPath))
|
|
72411
|
+
return false;
|
|
72412
|
+
const content = fs4.readFileSync(npmrcPath, "utf-8");
|
|
72413
|
+
return AUTH_TOKEN_REGEX.test(content);
|
|
72414
|
+
}
|
|
72415
|
+
function handleRegistryAuthError({
|
|
72416
|
+
error,
|
|
72417
|
+
projectDir
|
|
72418
|
+
}) {
|
|
72419
|
+
if (!isUnauthorizedError(error))
|
|
72580
72420
|
return;
|
|
72581
|
-
|
|
72582
|
-
|
|
72583
|
-
|
|
72584
|
-
|
|
72585
|
-
|
|
72586
|
-
|
|
72587
|
-
|
|
72588
|
-
|
|
72589
|
-
|
|
72590
|
-
const s = hTable[h];
|
|
72591
|
-
if (s !== -1) {
|
|
72592
|
-
const sa = t[s], sb = t[nextHE(s)];
|
|
72593
|
-
if (sa === lo && sb === hi || sa === hi && sb === lo) {
|
|
72594
|
-
he[e] = s;
|
|
72595
|
-
he[s] = e;
|
|
72596
|
-
hTable[h] = -1;
|
|
72597
|
-
edgeStamp[s] = 1;
|
|
72598
|
-
edgeStack[i++] = s;
|
|
72599
|
-
break;
|
|
72600
|
-
}
|
|
72601
|
-
}
|
|
72602
|
-
h = h + 1 & hMask;
|
|
72603
|
-
}
|
|
72604
|
-
if (hStamp[h] !== gen) {
|
|
72605
|
-
hTable[h] = e;
|
|
72606
|
-
hStamp[h] = gen;
|
|
72607
|
-
}
|
|
72421
|
+
const npmrcPaths = [
|
|
72422
|
+
path6.join(projectDir, ".npmrc"),
|
|
72423
|
+
path6.join(os2.homedir(), ".npmrc")
|
|
72424
|
+
];
|
|
72425
|
+
const hasToken = npmrcPaths.some(hasTsciAuthToken);
|
|
72426
|
+
if (hasToken) {
|
|
72427
|
+
console.warn(kleur_default.yellow("Your tscircuit session token appears to be missing or expired. Run `tsci auth setup-npmrc` to refresh it before retrying."));
|
|
72428
|
+
} else {
|
|
72429
|
+
console.warn(kleur_default.yellow("No tscircuit session token is loaded in your .npmrc files. Run `tsci auth setup-npmrc` to add one and retry the install."));
|
|
72608
72430
|
}
|
|
72609
|
-
|
|
72610
|
-
|
|
72611
|
-
|
|
72612
|
-
|
|
72613
|
-
|
|
72431
|
+
}
|
|
72432
|
+
|
|
72433
|
+
// lib/cli-config/index.ts
|
|
72434
|
+
var getCliConfig = (opts = {}) => {
|
|
72435
|
+
return new Conf({
|
|
72436
|
+
projectName: "tscircuit",
|
|
72437
|
+
cwd: opts.configDir || process.env.TSCIRCUIT_CONFIG_DIR || undefined
|
|
72438
|
+
});
|
|
72439
|
+
};
|
|
72440
|
+
var cliConfig = getCliConfig();
|
|
72441
|
+
var getSessionToken = () => {
|
|
72442
|
+
return process.env.TSCIRCUIT_TOKEN || cliConfig.get("sessionToken");
|
|
72443
|
+
};
|
|
72444
|
+
var getSessionTokenFromNpmrc = () => {
|
|
72445
|
+
const npmrcPaths = [
|
|
72446
|
+
path7.join(process.cwd(), ".npmrc"),
|
|
72447
|
+
path7.join(os3.homedir(), ".npmrc")
|
|
72448
|
+
];
|
|
72449
|
+
for (const npmrcPath of npmrcPaths) {
|
|
72450
|
+
if (!fs5.existsSync(npmrcPath))
|
|
72614
72451
|
continue;
|
|
72615
|
-
const
|
|
72616
|
-
const
|
|
72617
|
-
|
|
72618
|
-
|
|
72619
|
-
const bl = b0 + (b + 2) % 3;
|
|
72620
|
-
const br = b0 + (b + 1) % 3;
|
|
72621
|
-
const p0 = t[ar], pr = t[a], pl = t[al], p1 = t[bl];
|
|
72622
|
-
const x0 = coords[p0 * dim], y0 = coords[p0 * dim + 1];
|
|
72623
|
-
const xr = coords[pr * dim], yr = coords[pr * dim + 1];
|
|
72624
|
-
const xl = coords[pl * dim], yl = coords[pl * dim + 1];
|
|
72625
|
-
const x1 = coords[p1 * dim], y1 = coords[p1 * dim + 1];
|
|
72626
|
-
if (!inCircle(x0, y0, xr, yr, xl, yl, x1, y1) && orient(x0, y0, xr, yr, x1, y1) > 0 && orient(x0, y0, x1, y1, xl, yl) > 0) {
|
|
72627
|
-
t[a] = p1;
|
|
72628
|
-
t[b] = p0;
|
|
72629
|
-
const hbl = he[bl], har = he[ar];
|
|
72630
|
-
he[a] = hbl;
|
|
72631
|
-
if (hbl !== -1)
|
|
72632
|
-
he[hbl] = a;
|
|
72633
|
-
he[b] = har;
|
|
72634
|
-
if (har !== -1)
|
|
72635
|
-
he[har] = b;
|
|
72636
|
-
he[ar] = bl;
|
|
72637
|
-
he[bl] = ar;
|
|
72638
|
-
if (hbl !== -1 && edgeStamp[a] === 0) {
|
|
72639
|
-
edgeStamp[a] = 1;
|
|
72640
|
-
edgeStack[i++] = a;
|
|
72641
|
-
}
|
|
72642
|
-
if (har !== -1 && edgeStamp[b] === 0) {
|
|
72643
|
-
edgeStamp[b] = 1;
|
|
72644
|
-
edgeStack[i++] = b;
|
|
72645
|
-
}
|
|
72646
|
-
if (he[al] !== -1 && edgeStamp[al] === 0) {
|
|
72647
|
-
edgeStamp[al] = 1;
|
|
72648
|
-
edgeStack[i++] = al;
|
|
72649
|
-
}
|
|
72650
|
-
if (he[br] !== -1 && edgeStamp[br] === 0) {
|
|
72651
|
-
edgeStamp[br] = 1;
|
|
72652
|
-
edgeStack[i++] = br;
|
|
72653
|
-
}
|
|
72452
|
+
const content = fs5.readFileSync(npmrcPath, "utf-8");
|
|
72453
|
+
const match = content.match(AUTH_TOKEN_REGEX);
|
|
72454
|
+
if (match?.[1]) {
|
|
72455
|
+
return match[1].trim();
|
|
72654
72456
|
}
|
|
72655
72457
|
}
|
|
72656
|
-
|
|
72657
|
-
|
|
72658
|
-
|
|
72659
|
-
|
|
72660
|
-
|
|
72661
|
-
|
|
72662
|
-
|
|
72663
|
-
|
|
72664
|
-
|
|
72665
|
-
|
|
72666
|
-
|
|
72667
|
-
|
|
72668
|
-
|
|
72669
|
-
|
|
72670
|
-
|
|
72671
|
-
|
|
72672
|
-
|
|
72673
|
-
|
|
72674
|
-
|
|
72675
|
-
|
|
72676
|
-
|
|
72677
|
-
|
|
72678
|
-
|
|
72679
|
-
|
|
72680
|
-
|
|
72681
|
-
|
|
72458
|
+
return;
|
|
72459
|
+
};
|
|
72460
|
+
var setSessionToken = (token) => {
|
|
72461
|
+
cliConfig.set("sessionToken", token);
|
|
72462
|
+
const decoded = jwtDecode(token);
|
|
72463
|
+
if (decoded.tscircuit_handle)
|
|
72464
|
+
cliConfig.set("tscircuitHandle", decoded.tscircuit_handle);
|
|
72465
|
+
if (decoded.account_id)
|
|
72466
|
+
cliConfig.set("accountId", decoded.account_id);
|
|
72467
|
+
if (decoded.session_id)
|
|
72468
|
+
cliConfig.set("sessionId", decoded.session_id);
|
|
72469
|
+
};
|
|
72470
|
+
var clearSession = () => {
|
|
72471
|
+
cliConfig.clear();
|
|
72472
|
+
};
|
|
72473
|
+
var getRegistryApiUrl = () => {
|
|
72474
|
+
return cliConfig.get("registryApiUrl") ?? "https://registry-api.tscircuit.com";
|
|
72475
|
+
};
|
|
72476
|
+
|
|
72477
|
+
// lib/shared/parts-engine-base-urls.ts
|
|
72478
|
+
var partsEngineBaseUrlEnvVars = {
|
|
72479
|
+
jlcsearch: "TSCIRCUIT_JLCSEARCH_BASE_URL",
|
|
72480
|
+
digikey: "TSCIRCUIT_DIGIKEY_BASE_URL",
|
|
72481
|
+
mouser: "TSCIRCUIT_MOUSER_BASE_URL",
|
|
72482
|
+
"datasheet-api": "TSCIRCUIT_DATASHEET_API_BASE_URL"
|
|
72483
|
+
};
|
|
72484
|
+
var getPartsEngineBaseUrl = (provider, defaultBaseUrl) => {
|
|
72485
|
+
const environmentVariable = partsEngineBaseUrlEnvVars[provider];
|
|
72486
|
+
const baseUrl = process.env[environmentVariable] ?? defaultBaseUrl;
|
|
72487
|
+
return baseUrl.replace(/\/+$/, "");
|
|
72488
|
+
};
|
|
72489
|
+
var getPartsEngineBaseUrls = () => {
|
|
72490
|
+
const baseUrls = {};
|
|
72491
|
+
for (const environmentVariable of Object.values(partsEngineBaseUrlEnvVars)) {
|
|
72492
|
+
const baseUrl = process.env[environmentVariable];
|
|
72493
|
+
if (baseUrl !== undefined)
|
|
72494
|
+
baseUrls[environmentVariable] = baseUrl;
|
|
72682
72495
|
}
|
|
72683
|
-
|
|
72684
|
-
}
|
|
72496
|
+
return baseUrls;
|
|
72497
|
+
};
|
|
72498
|
+
|
|
72499
|
+
// lib/site/serialize-script-value.ts
|
|
72500
|
+
var serializeScriptValue = (value) => JSON.stringify(value).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
72501
|
+
|
|
72502
|
+
// lib/site/getIndex.ts
|
|
72503
|
+
var getIndex = async ({
|
|
72504
|
+
mainComponentPath,
|
|
72505
|
+
fileServerApiBaseUrl,
|
|
72506
|
+
jscdnBaseUrl,
|
|
72507
|
+
extraRunFrameTabs = []
|
|
72508
|
+
} = {}) => {
|
|
72509
|
+
const standalone = process.env.TSCIRCUIT_STANDALONE === "1";
|
|
72510
|
+
const evalVersion = package_default.devDependencies["@tscircuit/eval"];
|
|
72511
|
+
const standaloneScript = standalone ? `
|
|
72512
|
+
window.TSCIRCUIT_LATEST_EVAL_VERSION = ${JSON.stringify(evalVersion)};
|
|
72513
|
+
window.TSCIRCUIT_ALLOW_SELECTING_EVAL_VERSION = false;
|
|
72514
|
+
window.TSCIRCUIT_TELEMETRY_DISABLED = true;` : "";
|
|
72515
|
+
const sessionToken = getSessionToken();
|
|
72516
|
+
const tokenScript = sessionToken ? `
|
|
72517
|
+
window.TSCIRCUIT_REGISTRY_TOKEN = ${JSON.stringify(sessionToken)};` : "";
|
|
72518
|
+
const fileServerApiScript = fileServerApiBaseUrl ? `
|
|
72519
|
+
window.TSCIRCUIT_FILESERVER_API_BASE_URL = ${JSON.stringify(fileServerApiBaseUrl)};` : "";
|
|
72520
|
+
const jscdnScript = jscdnBaseUrl ? `
|
|
72521
|
+
window.TSCIRCUIT_JSCDN_BASE_URL = ${JSON.stringify(jscdnBaseUrl).replace(/</g, "\\u003c")};` : "";
|
|
72522
|
+
const partsEngineBaseUrls = getPartsEngineBaseUrls();
|
|
72523
|
+
const partsEngineScript = Object.keys(partsEngineBaseUrls).length ? `
|
|
72524
|
+
Object.assign(window, ${JSON.stringify(partsEngineBaseUrls).replace(/</g, "\\u003c")});` : "";
|
|
72525
|
+
return `<html>
|
|
72526
|
+
<head>
|
|
72527
|
+
<meta charset="UTF-8" />
|
|
72528
|
+
${standalone ? '<link rel="icon" href="data:,">' : '<link rel="icon" type="image/png" href="https://github.com/tscircuit.png">'}
|
|
72529
|
+
</head>
|
|
72530
|
+
<body>
|
|
72531
|
+
<script>
|
|
72532
|
+
${mainComponentPath ? `window.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH = ${serializeScriptValue(mainComponentPath)};` : ""}
|
|
72533
|
+
window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI = true;${tokenScript}${fileServerApiScript}${jscdnScript}${partsEngineScript}${standaloneScript}
|
|
72534
|
+
window.TSCIRCUIT_EXTRA_RUNFRAME_TABS = ${serializeScriptValue(extraRunFrameTabs)};
|
|
72535
|
+
</script>
|
|
72536
|
+
${standalone ? "" : '<script src="https://cdn.tailwindcss.com"></script>'}
|
|
72537
|
+
<div id="root">loading...</div>
|
|
72538
|
+
<script>
|
|
72539
|
+
globalThis.process = { env: { NODE_ENV: "production" } }
|
|
72540
|
+
</script>
|
|
72541
|
+
${fileServerApiBaseUrl ? '<script src="/extra-runframe-tabs.js" defer></script>' : ""}
|
|
72542
|
+
<script type="module" src="/standalone.min.js"></script>
|
|
72543
|
+
</body>
|
|
72544
|
+
</html>`;
|
|
72545
|
+
};
|
|
72546
|
+
|
|
72547
|
+
// lib/server/kicad-pcm-proxy.ts
|
|
72548
|
+
import * as fs15 from "node:fs";
|
|
72549
|
+
import * as path17 from "node:path";
|
|
72550
|
+
|
|
72551
|
+
// cli/build/build-kicad-pcm.ts
|
|
72552
|
+
import path15 from "node:path";
|
|
72553
|
+
import fs11 from "node:fs";
|
|
72554
|
+
|
|
72555
|
+
// lib/shared/convert-to-kicad-library.tsx
|
|
72556
|
+
import fs7 from "node:fs";
|
|
72557
|
+
import path11 from "node:path";
|
|
72558
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
72685
72559
|
|
|
72686
72560
|
// node_modules/circuit-json-to-kicad/dist/index.js
|
|
72687
|
-
|
|
72561
|
+
init_earcut();
|
|
72562
|
+
import { cju } from "@tscircuit/circuit-json-util";
|
|
72563
|
+
import { KicadSch } from "kicadts";
|
|
72564
|
+
import { compose as compose2, scale, translate as translate2 } from "transformation-matrix";
|
|
72565
|
+
import {
|
|
72566
|
+
At,
|
|
72567
|
+
Color,
|
|
72568
|
+
Sheet,
|
|
72569
|
+
SheetFill,
|
|
72570
|
+
SheetInstancePage,
|
|
72571
|
+
SheetInstancePath,
|
|
72572
|
+
SheetInstancesForSheet,
|
|
72573
|
+
SheetInstancesProject,
|
|
72574
|
+
SheetProperty,
|
|
72575
|
+
SheetSize,
|
|
72576
|
+
Stroke,
|
|
72577
|
+
TextEffects,
|
|
72578
|
+
TextEffectsFont,
|
|
72579
|
+
TextEffectsJustify
|
|
72580
|
+
} from "kicadts";
|
|
72581
|
+
import { TitleBlock, TitleBlockComment } from "kicadts";
|
|
72582
|
+
import {
|
|
72583
|
+
EmbeddedFonts,
|
|
72584
|
+
LibSymbols,
|
|
72585
|
+
SchematicSymbol as SchematicSymbol4,
|
|
72586
|
+
SymbolPinNames,
|
|
72587
|
+
SymbolPinNumbers,
|
|
72588
|
+
SymbolPower
|
|
72589
|
+
} from "kicadts";
|
|
72590
|
+
import { symbols as symbols3 } from "schematic-symbols";
|
|
72591
|
+
import { symbols } from "schematic-symbols";
|
|
72592
|
+
import { symbols as symbols2 } from "schematic-symbols";
|
|
72593
|
+
import { SchematicSymbol } from "kicadts";
|
|
72594
|
+
import {
|
|
72595
|
+
compose,
|
|
72596
|
+
scale as createScaleMatrix,
|
|
72597
|
+
translate
|
|
72598
|
+
} from "transformation-matrix";
|
|
72599
|
+
import { SymbolArc } from "kicadts";
|
|
72600
|
+
import { applyToPoint } from "transformation-matrix";
|
|
72601
|
+
import { SymbolCircle } from "kicadts";
|
|
72602
|
+
import { applyToPoint as applyToPoint2 } from "transformation-matrix";
|
|
72603
|
+
import { Pts, Stroke as Stroke2, SymbolPolyline, SymbolPolylineFill, Xy } from "kicadts";
|
|
72604
|
+
import { applyToPoint as applyToPoint3 } from "transformation-matrix";
|
|
72605
|
+
import { SymbolRectangle } from "kicadts";
|
|
72606
|
+
import { applyToPoint as applyToPoint4 } from "transformation-matrix";
|
|
72607
|
+
import { SymbolText, TextEffects as TextEffects2, TextEffectsFont as TextEffectsFont2 } from "kicadts";
|
|
72608
|
+
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
72609
|
+
import { SymbolProperty } from "kicadts";
|
|
72610
|
+
import { TextEffects as TextEffects3, TextEffectsFont as TextEffectsFont3 } from "kicadts";
|
|
72611
|
+
import {
|
|
72612
|
+
SchematicSymbol as SchematicSymbol3,
|
|
72613
|
+
SymbolPin,
|
|
72614
|
+
SymbolPinName,
|
|
72615
|
+
SymbolPinNumber,
|
|
72616
|
+
TextEffects as TextEffects4,
|
|
72617
|
+
TextEffectsFont as TextEffectsFont4
|
|
72618
|
+
} from "kicadts";
|
|
72619
|
+
import { applyToPoint as applyToPoint6, scale as createScaleMatrix2 } from "transformation-matrix";
|
|
72620
|
+
import {
|
|
72621
|
+
Polyline,
|
|
72622
|
+
Pts as Pts2,
|
|
72623
|
+
SchematicArc,
|
|
72624
|
+
SchematicRectangle,
|
|
72625
|
+
SchematicText,
|
|
72626
|
+
Stroke as Stroke3,
|
|
72627
|
+
SymbolArcFill,
|
|
72628
|
+
SymbolRectangleFill,
|
|
72629
|
+
TextEffects as TextEffects5,
|
|
72630
|
+
TextEffectsFont as TextEffectsFont5,
|
|
72631
|
+
TextEffectsJustify as TextEffectsJustify2,
|
|
72632
|
+
Uuid,
|
|
72633
|
+
Xy as Xy2
|
|
72634
|
+
} from "kicadts";
|
|
72635
|
+
import { applyToPoint as applyToPoint7 } from "transformation-matrix";
|
|
72636
|
+
import {
|
|
72637
|
+
SchematicSymbol as SchematicSymbol5,
|
|
72638
|
+
SymbolLibId,
|
|
72639
|
+
SymbolProperty as SymbolProperty2,
|
|
72640
|
+
SymbolPin as SymbolPin2,
|
|
72641
|
+
SymbolInstances,
|
|
72642
|
+
SymbolInstancesProject,
|
|
72643
|
+
SymbolInstancePath,
|
|
72644
|
+
TextEffects as TextEffects6,
|
|
72645
|
+
TextEffectsFont as TextEffectsFont6,
|
|
72646
|
+
TextEffectsJustify as TextEffectsJustify3,
|
|
72647
|
+
GlobalLabel
|
|
72648
|
+
} from "kicadts";
|
|
72649
|
+
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
72650
|
+
import { symbols as symbols4 } from "schematic-symbols";
|
|
72651
|
+
import { formatSiUnit } from "format-si-unit";
|
|
72652
|
+
import {
|
|
72653
|
+
EmbeddedFonts as EmbeddedFonts2,
|
|
72654
|
+
SchematicSymbol as SchematicSymbol6,
|
|
72655
|
+
SymbolInstancePath as SymbolInstancePath2,
|
|
72656
|
+
SymbolInstances as SymbolInstances2,
|
|
72657
|
+
SymbolInstancesProject as SymbolInstancesProject2,
|
|
72658
|
+
SymbolLibId as SymbolLibId2,
|
|
72659
|
+
SymbolPin as SymbolPin3,
|
|
72660
|
+
SymbolPinNames as SymbolPinNames2,
|
|
72661
|
+
SymbolPinNumbers as SymbolPinNumbers2,
|
|
72662
|
+
SymbolProperty as SymbolProperty3,
|
|
72663
|
+
TextEffects as TextEffects7,
|
|
72664
|
+
TextEffectsFont as TextEffectsFont7,
|
|
72665
|
+
TextEffectsJustify as TextEffectsJustify4
|
|
72666
|
+
} from "kicadts";
|
|
72667
|
+
import { applyToPoint as applyToPoint9 } from "transformation-matrix";
|
|
72668
|
+
import { Wire, Pts as Pts3, Xy as Xy3, Stroke as Stroke4, Junction } from "kicadts";
|
|
72669
|
+
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
72670
|
+
import {
|
|
72671
|
+
SheetInstances,
|
|
72672
|
+
SheetInstancesRootPath,
|
|
72673
|
+
SheetInstancesRootPage,
|
|
72674
|
+
EmbeddedFonts as EmbeddedFonts3
|
|
72675
|
+
} from "kicadts";
|
|
72676
|
+
import { Paper, Uuid as Uuid4 } from "kicadts";
|
|
72677
|
+
import { KicadPcb as KicadPcb2 } from "kicadts";
|
|
72678
|
+
import { cju as cju2 } from "@tscircuit/circuit-json-util";
|
|
72679
|
+
import { compose as compose7, translate as translate7, scale as scale5 } from "transformation-matrix";
|
|
72688
72680
|
import {
|
|
72689
72681
|
Layer,
|
|
72690
72682
|
Pts as Pts4,
|
|
@@ -72724,6 +72716,7 @@ import {
|
|
|
72724
72716
|
TextEffects as TextEffects8,
|
|
72725
72717
|
TextEffectsFont as TextEffectsFont8
|
|
72726
72718
|
} from "kicadts";
|
|
72719
|
+
var import_polygon_clipping = __toESM3(require_polygon_clipping_cjs(), 1);
|
|
72727
72720
|
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
72728
72721
|
import {
|
|
72729
72722
|
Property as Property2,
|
|
@@ -81113,6 +81106,8 @@ var projectConfigSchema = z21.object({
|
|
|
81113
81106
|
kicadLibrary: z21.boolean().optional(),
|
|
81114
81107
|
kicadPcm: z21.boolean().optional(),
|
|
81115
81108
|
previewImages: z21.boolean().optional(),
|
|
81109
|
+
drawings: z21.boolean().optional(),
|
|
81110
|
+
drawing: z21.string().optional(),
|
|
81116
81111
|
glbs: z21.boolean().optional(),
|
|
81117
81112
|
step: z21.boolean().optional(),
|
|
81118
81113
|
workerTimeoutMs: z21.number().int().positive().optional(),
|
|
@@ -86270,7 +86265,11 @@ var pushSnippet = async ({
|
|
|
86270
86265
|
onError(`Error creating release: ${error}`);
|
|
86271
86266
|
return onExit(1);
|
|
86272
86267
|
}
|
|
86273
|
-
const
|
|
86268
|
+
const projectConfig = loadProjectConfig(projectDir);
|
|
86269
|
+
const filePaths = getPackageFilePaths(projectDir, [
|
|
86270
|
+
...projectConfig?.ignoredFiles ?? [],
|
|
86271
|
+
...includeDist ? [] : ["**/dist/**"]
|
|
86272
|
+
]);
|
|
86274
86273
|
const uploadResults = { succeeded: [], failed: [] };
|
|
86275
86274
|
const packageNameWithVersion = `${scopedPackageName}@${releaseVersion}`;
|
|
86276
86275
|
const files = getUploadFiles(filePaths, projectDir);
|