@tscircuit/cli 0.1.469 → 0.1.471

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/main.js +638 -334
  2. package/package.json +4 -4
package/dist/main.js CHANGED
@@ -1596,7 +1596,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
1596
1596
  return arg.length > 1 && arg[0] === "-";
1597
1597
  }
1598
1598
  const negativeNumberArg = (arg) => {
1599
- if (!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(arg))
1599
+ if (!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(arg))
1600
1600
  return false;
1601
1601
  return !this._getCommandAndAncestors().some((cmd) => cmd.options.map((opt) => opt.short).some((short) => /^-\d$/.test(short)));
1602
1602
  };
@@ -52173,9 +52173,9 @@ var require_fs = __commonJS((exports2) => {
52173
52173
  var require_path = __commonJS((exports2) => {
52174
52174
  Object.defineProperty(exports2, "__esModule", { value: true });
52175
52175
  exports2.convertPosixPathToPattern = exports2.convertWindowsPathToPattern = exports2.convertPathToPattern = exports2.escapePosixPath = exports2.escapeWindowsPath = exports2.escape = exports2.removeLeadingDotSegment = exports2.makeAbsolute = exports2.unixify = undefined;
52176
- var os3 = __require("os");
52176
+ var os2 = __require("os");
52177
52177
  var path14 = __require("path");
52178
- var IS_WINDOWS_PLATFORM = os3.platform() === "win32";
52178
+ var IS_WINDOWS_PLATFORM = os2.platform() === "win32";
52179
52179
  var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
52180
52180
  var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
52181
52181
  var WINDOWS_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()[\]{}]|^!|[!+@](?=\())/g;
@@ -53442,7 +53442,7 @@ var require_braces = __commonJS((exports2, module2) => {
53442
53442
  module2.exports = braces;
53443
53443
  });
53444
53444
 
53445
- // node_modules/picomatch/lib/constants.js
53445
+ // node_modules/micromatch/node_modules/picomatch/lib/constants.js
53446
53446
  var require_constants3 = __commonJS((exports2, module2) => {
53447
53447
  var path14 = __require("path");
53448
53448
  var WIN_SLASH = "\\\\/";
@@ -53582,7 +53582,7 @@ var require_constants3 = __commonJS((exports2, module2) => {
53582
53582
  };
53583
53583
  });
53584
53584
 
53585
- // node_modules/picomatch/lib/utils.js
53585
+ // node_modules/micromatch/node_modules/picomatch/lib/utils.js
53586
53586
  var require_utils3 = __commonJS((exports2) => {
53587
53587
  var path14 = __require("path");
53588
53588
  var win32 = process.platform === "win32";
@@ -53642,7 +53642,7 @@ var require_utils3 = __commonJS((exports2) => {
53642
53642
  };
53643
53643
  });
53644
53644
 
53645
- // node_modules/picomatch/lib/scan.js
53645
+ // node_modules/micromatch/node_modules/picomatch/lib/scan.js
53646
53646
  var require_scan = __commonJS((exports2, module2) => {
53647
53647
  var utils = require_utils3();
53648
53648
  var {
@@ -53957,7 +53957,7 @@ var require_scan = __commonJS((exports2, module2) => {
53957
53957
  module2.exports = scan;
53958
53958
  });
53959
53959
 
53960
- // node_modules/picomatch/lib/parse.js
53960
+ // node_modules/micromatch/node_modules/picomatch/lib/parse.js
53961
53961
  var require_parse3 = __commonJS((exports2, module2) => {
53962
53962
  var constants = require_constants3();
53963
53963
  var utils = require_utils3();
@@ -54735,7 +54735,7 @@ var require_parse3 = __commonJS((exports2, module2) => {
54735
54735
  module2.exports = parse3;
54736
54736
  });
54737
54737
 
54738
- // node_modules/picomatch/lib/picomatch.js
54738
+ // node_modules/micromatch/node_modules/picomatch/lib/picomatch.js
54739
54739
  var require_picomatch = __commonJS((exports2, module2) => {
54740
54740
  var path14 = __require("path");
54741
54741
  var scan = require_scan();
@@ -57205,8 +57205,8 @@ var require_settings4 = __commonJS((exports2) => {
57205
57205
  Object.defineProperty(exports2, "__esModule", { value: true });
57206
57206
  exports2.DEFAULT_FILE_SYSTEM_ADAPTER = undefined;
57207
57207
  var fs13 = __require("fs");
57208
- var os3 = __require("os");
57209
- var CPU_COUNT = Math.max(os3.cpus().length, 1);
57208
+ var os2 = __require("os");
57209
+ var CPU_COUNT = Math.max(os2.cpus().length, 1);
57210
57210
  exports2.DEFAULT_FILE_SYSTEM_ADAPTER = {
57211
57211
  lstat: fs13.lstat,
57212
57212
  lstatSync: fs13.lstatSync,
@@ -70470,13 +70470,18 @@ import path7 from "node:path";
70470
70470
  import fs4 from "node:fs";
70471
70471
  import { promisify } from "node:util";
70472
70472
 
70473
- // node_modules/stubborn-fs/dist/attemptify.js
70474
- var attemptifyAsync = (fn, onError) => {
70473
+ // node_modules/stubborn-utils/dist/attemptify_async.js
70474
+ var attemptifyAsync = (fn, options) => {
70475
+ const { onError } = options;
70475
70476
  return function attemptified(...args) {
70476
70477
  return fn.apply(undefined, args).catch(onError);
70477
70478
  };
70478
70479
  };
70479
- var attemptifySync = (fn, onError) => {
70480
+ var attemptify_async_default = attemptifyAsync;
70481
+
70482
+ // node_modules/stubborn-utils/dist/attemptify_sync.js
70483
+ var attemptifySync = (fn, options) => {
70484
+ const { onError } = options;
70480
70485
  return function attemptified(...args) {
70481
70486
  try {
70482
70487
  return fn.apply(undefined, args);
@@ -70485,14 +70490,62 @@ var attemptifySync = (fn, onError) => {
70485
70490
  }
70486
70491
  };
70487
70492
  };
70493
+ var attemptify_sync_default = attemptifySync;
70494
+
70495
+ // node_modules/stubborn-utils/dist/constants.js
70496
+ var RETRY_INTERVAL = 250;
70497
+
70498
+ // node_modules/stubborn-utils/dist/retryify_async.js
70499
+ var retryifyAsync = (fn, options) => {
70500
+ const { isRetriable } = options;
70501
+ return function retryified(options2) {
70502
+ const { timeout } = options2;
70503
+ const interval = options2.interval ?? RETRY_INTERVAL;
70504
+ const timestamp = Date.now() + timeout;
70505
+ return function attempt(...args) {
70506
+ return fn.apply(undefined, args).catch((error) => {
70507
+ if (!isRetriable(error))
70508
+ throw error;
70509
+ if (Date.now() >= timestamp)
70510
+ throw error;
70511
+ const delay = Math.round(interval * Math.random());
70512
+ if (delay > 0) {
70513
+ const delayPromise = new Promise((resolve) => setTimeout(resolve, delay));
70514
+ return delayPromise.then(() => attempt.apply(undefined, args));
70515
+ } else {
70516
+ return attempt.apply(undefined, args);
70517
+ }
70518
+ });
70519
+ };
70520
+ };
70521
+ };
70522
+ var retryify_async_default = retryifyAsync;
70523
+
70524
+ // node_modules/stubborn-utils/dist/retryify_sync.js
70525
+ var retryifySync = (fn, options) => {
70526
+ const { isRetriable } = options;
70527
+ return function retryified(options2) {
70528
+ const { timeout } = options2;
70529
+ const timestamp = Date.now() + timeout;
70530
+ return function attempt(...args) {
70531
+ while (true) {
70532
+ try {
70533
+ return fn.apply(undefined, args);
70534
+ } catch (error) {
70535
+ if (!isRetriable(error))
70536
+ throw error;
70537
+ if (Date.now() >= timestamp)
70538
+ throw error;
70539
+ continue;
70540
+ }
70541
+ }
70542
+ };
70543
+ };
70544
+ };
70545
+ var retryify_sync_default = retryifySync;
70488
70546
 
70489
70547
  // node_modules/stubborn-fs/dist/constants.js
70490
70548
  import process3 from "node:process";
70491
- var IS_USER_ROOT = process3.getuid ? !process3.getuid() : false;
70492
- var LIMIT_FILES_DESCRIPTORS = 1e4;
70493
- var NOOP = () => {
70494
- return;
70495
- };
70496
70549
 
70497
70550
  // node_modules/stubborn-fs/dist/handlers.js
70498
70551
  var Handlers = {
@@ -70527,153 +70580,70 @@ var Handlers = {
70527
70580
  };
70528
70581
  var handlers_default = Handlers;
70529
70582
 
70530
- // node_modules/stubborn-fs/dist/retryify_queue.js
70531
- class RetryfyQueue {
70532
- constructor() {
70533
- this.interval = 25;
70534
- this.intervalId = undefined;
70535
- this.limit = LIMIT_FILES_DESCRIPTORS;
70536
- this.queueActive = new Set;
70537
- this.queueWaiting = new Set;
70538
- this.init = () => {
70539
- if (this.intervalId)
70540
- return;
70541
- this.intervalId = setInterval(this.tick, this.interval);
70542
- };
70543
- this.reset = () => {
70544
- if (!this.intervalId)
70545
- return;
70546
- clearInterval(this.intervalId);
70547
- delete this.intervalId;
70548
- };
70549
- this.add = (fn) => {
70550
- this.queueWaiting.add(fn);
70551
- if (this.queueActive.size < this.limit / 2) {
70552
- this.tick();
70553
- } else {
70554
- this.init();
70555
- }
70556
- };
70557
- this.remove = (fn) => {
70558
- this.queueWaiting.delete(fn);
70559
- this.queueActive.delete(fn);
70560
- };
70561
- this.schedule = () => {
70562
- return new Promise((resolve) => {
70563
- const cleanup = () => this.remove(resolver);
70564
- const resolver = () => resolve(cleanup);
70565
- this.add(resolver);
70566
- });
70567
- };
70568
- this.tick = () => {
70569
- if (this.queueActive.size >= this.limit)
70570
- return;
70571
- if (!this.queueWaiting.size)
70572
- return this.reset();
70573
- for (const fn of this.queueWaiting) {
70574
- if (this.queueActive.size >= this.limit)
70575
- break;
70576
- this.queueWaiting.delete(fn);
70577
- this.queueActive.add(fn);
70578
- fn();
70579
- }
70580
- };
70583
+ // node_modules/stubborn-fs/dist/constants.js
70584
+ var ATTEMPTIFY_CHANGE_ERROR_OPTIONS = {
70585
+ onError: handlers_default.onChangeError
70586
+ };
70587
+ var ATTEMPTIFY_NOOP_OPTIONS = {
70588
+ onError: () => {
70589
+ return;
70581
70590
  }
70582
- }
70583
- var retryify_queue_default = new RetryfyQueue;
70584
-
70585
- // node_modules/stubborn-fs/dist/retryify.js
70586
- var retryifyAsync = (fn, isRetriableError) => {
70587
- return function retrified(timestamp) {
70588
- return function attempt(...args) {
70589
- return retryify_queue_default.schedule().then((cleanup) => {
70590
- const onResolve = (result) => {
70591
- cleanup();
70592
- return result;
70593
- };
70594
- const onReject = (error) => {
70595
- cleanup();
70596
- if (Date.now() >= timestamp)
70597
- throw error;
70598
- if (isRetriableError(error)) {
70599
- const delay = Math.round(100 * Math.random());
70600
- const delayPromise = new Promise((resolve) => setTimeout(resolve, delay));
70601
- return delayPromise.then(() => attempt.apply(undefined, args));
70602
- }
70603
- throw error;
70604
- };
70605
- return fn.apply(undefined, args).then(onResolve, onReject);
70606
- });
70607
- };
70608
- };
70609
70591
  };
70610
- var retryifySync = (fn, isRetriableError) => {
70611
- return function retrified(timestamp) {
70612
- return function attempt(...args) {
70613
- try {
70614
- return fn.apply(undefined, args);
70615
- } catch (error) {
70616
- if (Date.now() > timestamp)
70617
- throw error;
70618
- if (isRetriableError(error))
70619
- return attempt.apply(undefined, args);
70620
- throw error;
70621
- }
70622
- };
70623
- };
70592
+ var IS_USER_ROOT = process3.getuid ? !process3.getuid() : false;
70593
+ var RETRYIFY_OPTIONS = {
70594
+ isRetriable: handlers_default.isRetriableError
70624
70595
  };
70625
70596
 
70626
70597
  // node_modules/stubborn-fs/dist/index.js
70627
70598
  var FS = {
70628
70599
  attempt: {
70629
- chmod: attemptifyAsync(promisify(fs4.chmod), handlers_default.onChangeError),
70630
- chown: attemptifyAsync(promisify(fs4.chown), handlers_default.onChangeError),
70631
- close: attemptifyAsync(promisify(fs4.close), NOOP),
70632
- fsync: attemptifyAsync(promisify(fs4.fsync), NOOP),
70633
- mkdir: attemptifyAsync(promisify(fs4.mkdir), NOOP),
70634
- realpath: attemptifyAsync(promisify(fs4.realpath), NOOP),
70635
- stat: attemptifyAsync(promisify(fs4.stat), NOOP),
70636
- unlink: attemptifyAsync(promisify(fs4.unlink), NOOP),
70637
- chmodSync: attemptifySync(fs4.chmodSync, handlers_default.onChangeError),
70638
- chownSync: attemptifySync(fs4.chownSync, handlers_default.onChangeError),
70639
- closeSync: attemptifySync(fs4.closeSync, NOOP),
70640
- existsSync: attemptifySync(fs4.existsSync, NOOP),
70641
- fsyncSync: attemptifySync(fs4.fsync, NOOP),
70642
- mkdirSync: attemptifySync(fs4.mkdirSync, NOOP),
70643
- realpathSync: attemptifySync(fs4.realpathSync, NOOP),
70644
- statSync: attemptifySync(fs4.statSync, NOOP),
70645
- unlinkSync: attemptifySync(fs4.unlinkSync, NOOP)
70600
+ chmod: attemptify_async_default(promisify(fs4.chmod), ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
70601
+ chown: attemptify_async_default(promisify(fs4.chown), ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
70602
+ close: attemptify_async_default(promisify(fs4.close), ATTEMPTIFY_NOOP_OPTIONS),
70603
+ fsync: attemptify_async_default(promisify(fs4.fsync), ATTEMPTIFY_NOOP_OPTIONS),
70604
+ mkdir: attemptify_async_default(promisify(fs4.mkdir), ATTEMPTIFY_NOOP_OPTIONS),
70605
+ realpath: attemptify_async_default(promisify(fs4.realpath), ATTEMPTIFY_NOOP_OPTIONS),
70606
+ stat: attemptify_async_default(promisify(fs4.stat), ATTEMPTIFY_NOOP_OPTIONS),
70607
+ unlink: attemptify_async_default(promisify(fs4.unlink), ATTEMPTIFY_NOOP_OPTIONS),
70608
+ chmodSync: attemptify_sync_default(fs4.chmodSync, ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
70609
+ chownSync: attemptify_sync_default(fs4.chownSync, ATTEMPTIFY_CHANGE_ERROR_OPTIONS),
70610
+ closeSync: attemptify_sync_default(fs4.closeSync, ATTEMPTIFY_NOOP_OPTIONS),
70611
+ existsSync: attemptify_sync_default(fs4.existsSync, ATTEMPTIFY_NOOP_OPTIONS),
70612
+ fsyncSync: attemptify_sync_default(fs4.fsync, ATTEMPTIFY_NOOP_OPTIONS),
70613
+ mkdirSync: attemptify_sync_default(fs4.mkdirSync, ATTEMPTIFY_NOOP_OPTIONS),
70614
+ realpathSync: attemptify_sync_default(fs4.realpathSync, ATTEMPTIFY_NOOP_OPTIONS),
70615
+ statSync: attemptify_sync_default(fs4.statSync, ATTEMPTIFY_NOOP_OPTIONS),
70616
+ unlinkSync: attemptify_sync_default(fs4.unlinkSync, ATTEMPTIFY_NOOP_OPTIONS)
70646
70617
  },
70647
70618
  retry: {
70648
- close: retryifyAsync(promisify(fs4.close), handlers_default.isRetriableError),
70649
- fsync: retryifyAsync(promisify(fs4.fsync), handlers_default.isRetriableError),
70650
- open: retryifyAsync(promisify(fs4.open), handlers_default.isRetriableError),
70651
- readFile: retryifyAsync(promisify(fs4.readFile), handlers_default.isRetriableError),
70652
- rename: retryifyAsync(promisify(fs4.rename), handlers_default.isRetriableError),
70653
- stat: retryifyAsync(promisify(fs4.stat), handlers_default.isRetriableError),
70654
- write: retryifyAsync(promisify(fs4.write), handlers_default.isRetriableError),
70655
- writeFile: retryifyAsync(promisify(fs4.writeFile), handlers_default.isRetriableError),
70656
- closeSync: retryifySync(fs4.closeSync, handlers_default.isRetriableError),
70657
- fsyncSync: retryifySync(fs4.fsyncSync, handlers_default.isRetriableError),
70658
- openSync: retryifySync(fs4.openSync, handlers_default.isRetriableError),
70659
- readFileSync: retryifySync(fs4.readFileSync, handlers_default.isRetriableError),
70660
- renameSync: retryifySync(fs4.renameSync, handlers_default.isRetriableError),
70661
- statSync: retryifySync(fs4.statSync, handlers_default.isRetriableError),
70662
- writeSync: retryifySync(fs4.writeSync, handlers_default.isRetriableError),
70663
- writeFileSync: retryifySync(fs4.writeFileSync, handlers_default.isRetriableError)
70619
+ close: retryify_async_default(promisify(fs4.close), RETRYIFY_OPTIONS),
70620
+ fsync: retryify_async_default(promisify(fs4.fsync), RETRYIFY_OPTIONS),
70621
+ open: retryify_async_default(promisify(fs4.open), RETRYIFY_OPTIONS),
70622
+ readFile: retryify_async_default(promisify(fs4.readFile), RETRYIFY_OPTIONS),
70623
+ rename: retryify_async_default(promisify(fs4.rename), RETRYIFY_OPTIONS),
70624
+ stat: retryify_async_default(promisify(fs4.stat), RETRYIFY_OPTIONS),
70625
+ write: retryify_async_default(promisify(fs4.write), RETRYIFY_OPTIONS),
70626
+ writeFile: retryify_async_default(promisify(fs4.writeFile), RETRYIFY_OPTIONS),
70627
+ closeSync: retryify_sync_default(fs4.closeSync, RETRYIFY_OPTIONS),
70628
+ fsyncSync: retryify_sync_default(fs4.fsyncSync, RETRYIFY_OPTIONS),
70629
+ openSync: retryify_sync_default(fs4.openSync, RETRYIFY_OPTIONS),
70630
+ readFileSync: retryify_sync_default(fs4.readFileSync, RETRYIFY_OPTIONS),
70631
+ renameSync: retryify_sync_default(fs4.renameSync, RETRYIFY_OPTIONS),
70632
+ statSync: retryify_sync_default(fs4.statSync, RETRYIFY_OPTIONS),
70633
+ writeSync: retryify_sync_default(fs4.writeSync, RETRYIFY_OPTIONS),
70634
+ writeFileSync: retryify_sync_default(fs4.writeFileSync, RETRYIFY_OPTIONS)
70664
70635
  }
70665
70636
  };
70666
70637
  var dist_default = FS;
70667
70638
 
70668
70639
  // node_modules/atomically/dist/constants.js
70669
- import os2 from "node:os";
70670
70640
  import process4 from "node:process";
70671
70641
  var DEFAULT_ENCODING = "utf8";
70672
70642
  var DEFAULT_FILE_MODE = 438;
70673
70643
  var DEFAULT_FOLDER_MODE = 511;
70674
70644
  var DEFAULT_WRITE_OPTIONS = {};
70675
- var DEFAULT_USER_UID = os2.userInfo().uid;
70676
- var DEFAULT_USER_GID = os2.userInfo().gid;
70645
+ var DEFAULT_USER_UID = process4.geteuid ? process4.geteuid() : -1;
70646
+ var DEFAULT_USER_GID = process4.getegid ? process4.getegid() : -1;
70677
70647
  var DEFAULT_TIMEOUT_SYNC = 1000;
70678
70648
  var IS_POSIX = !!process4.getuid;
70679
70649
  var IS_USER_ROOT2 = process4.getuid ? !process4.getuid() : false;
@@ -70702,12 +70672,12 @@ var IS_LINUX = process5.platform === "linux";
70702
70672
  var IS_WINDOWS = process5.platform === "win32";
70703
70673
 
70704
70674
  // node_modules/when-exit/dist/node/signals.js
70705
- var Signals = ["SIGABRT", "SIGALRM", "SIGHUP", "SIGINT", "SIGTERM"];
70675
+ var Signals = ["SIGHUP", "SIGINT", "SIGTERM"];
70706
70676
  if (!IS_WINDOWS) {
70707
- Signals.push("SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
70677
+ Signals.push("SIGALRM", "SIGABRT", "SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
70708
70678
  }
70709
70679
  if (IS_LINUX) {
70710
- Signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT", "SIGUNUSED");
70680
+ Signals.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT");
70711
70681
  }
70712
70682
  var signals_default = Signals;
70713
70683
 
@@ -70808,7 +70778,8 @@ var temp_default = Temp;
70808
70778
  function writeFileSync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
70809
70779
  if (isString(options))
70810
70780
  return writeFileSync(filePath, data, { encoding: options });
70811
- const timeout = Date.now() + ((options.timeout ?? DEFAULT_TIMEOUT_SYNC) || -1);
70781
+ const timeout = options.timeout ?? DEFAULT_TIMEOUT_SYNC;
70782
+ const retryOptions = { timeout };
70812
70783
  let tempDisposer = null;
70813
70784
  let tempPath = null;
70814
70785
  let fd = null;
@@ -70838,23 +70809,23 @@ function writeFileSync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
70838
70809
  recursive: true
70839
70810
  });
70840
70811
  }
70841
- fd = dist_default.retry.openSync(timeout)(tempPath, "w", options.mode || DEFAULT_FILE_MODE);
70812
+ fd = dist_default.retry.openSync(retryOptions)(tempPath, "w", options.mode || DEFAULT_FILE_MODE);
70842
70813
  if (options.tmpCreated) {
70843
70814
  options.tmpCreated(tempPath);
70844
70815
  }
70845
70816
  if (isString(data)) {
70846
- dist_default.retry.writeSync(timeout)(fd, data, 0, options.encoding || DEFAULT_ENCODING);
70817
+ dist_default.retry.writeSync(retryOptions)(fd, data, 0, options.encoding || DEFAULT_ENCODING);
70847
70818
  } else if (!isUndefined(data)) {
70848
- dist_default.retry.writeSync(timeout)(fd, data, 0, data.length, 0);
70819
+ dist_default.retry.writeSync(retryOptions)(fd, data, 0, data.length, 0);
70849
70820
  }
70850
70821
  if (options.fsync !== false) {
70851
70822
  if (options.fsyncWait !== false) {
70852
- dist_default.retry.fsyncSync(timeout)(fd);
70823
+ dist_default.retry.fsyncSync(retryOptions)(fd);
70853
70824
  } else {
70854
70825
  dist_default.attempt.fsync(fd);
70855
70826
  }
70856
70827
  }
70857
- dist_default.retry.closeSync(timeout)(fd);
70828
+ dist_default.retry.closeSync(retryOptions)(fd);
70858
70829
  fd = null;
70859
70830
  if (options.chown && (options.chown.uid !== DEFAULT_USER_UID || options.chown.gid !== DEFAULT_USER_GID)) {
70860
70831
  dist_default.attempt.chownSync(tempPath, options.chown.uid, options.chown.gid);
@@ -70863,13 +70834,13 @@ function writeFileSync(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
70863
70834
  dist_default.attempt.chmodSync(tempPath, options.mode);
70864
70835
  }
70865
70836
  try {
70866
- dist_default.retry.renameSync(timeout)(tempPath, filePath);
70837
+ dist_default.retry.renameSync(retryOptions)(tempPath, filePath);
70867
70838
  } catch (error) {
70868
70839
  if (!isException(error))
70869
70840
  throw error;
70870
70841
  if (error.code !== "ENAMETOOLONG")
70871
70842
  throw error;
70872
- dist_default.retry.renameSync(timeout)(tempPath, temp_default.truncate(filePath));
70843
+ dist_default.retry.renameSync(retryOptions)(tempPath, temp_default.truncate(filePath));
70873
70844
  }
70874
70845
  tempDisposer();
70875
70846
  tempPath = null;
@@ -71595,13 +71566,36 @@ class HTTPError extends Error {
71595
71566
  }
71596
71567
  }
71597
71568
 
71598
- // node_modules/ky/distribution/errors/TimeoutError.js
71599
- class TimeoutError extends Error {
71600
- request;
71601
- constructor(request) {
71602
- super(`Request timed out: ${request.method} ${request.url}`);
71603
- this.name = "TimeoutError";
71604
- this.request = request;
71569
+ // node_modules/ky/distribution/errors/NonError.js
71570
+ class NonError extends Error {
71571
+ name = "NonError";
71572
+ value;
71573
+ constructor(value) {
71574
+ let message = "Non-error value was thrown";
71575
+ try {
71576
+ if (typeof value === "string") {
71577
+ message = value;
71578
+ } else if (value && typeof value === "object" && "message" in value && typeof value.message === "string") {
71579
+ message = value.message;
71580
+ }
71581
+ } catch {}
71582
+ super(message);
71583
+ this.value = value;
71584
+ }
71585
+ }
71586
+
71587
+ // node_modules/ky/distribution/errors/ForceRetryError.js
71588
+ class ForceRetryError extends Error {
71589
+ name = "ForceRetryError";
71590
+ customDelay;
71591
+ code;
71592
+ customRequest;
71593
+ constructor(options) {
71594
+ const cause = options?.cause ? options.cause instanceof Error ? options.cause : new NonError(options.cause) : undefined;
71595
+ super(options?.code ? `Forced retry: ${options.code}` : "Forced retry", cause ? { cause } : undefined);
71596
+ this.customDelay = options?.delay;
71597
+ this.code = options?.code;
71598
+ this.customRequest = options?.request;
71605
71599
  }
71606
71600
  }
71607
71601
 
@@ -71650,6 +71644,14 @@ var responseTypes = {
71650
71644
  var maxSafeTimeout = 2147483647;
71651
71645
  var usualFormBoundarySize = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length;
71652
71646
  var stop = Symbol("stop");
71647
+
71648
+ class RetryMarker {
71649
+ options;
71650
+ constructor(options) {
71651
+ this.options = options;
71652
+ }
71653
+ }
71654
+ var retry = (options) => new RetryMarker(options);
71653
71655
  var kyOptionKeys = {
71654
71656
  json: true,
71655
71657
  parseJson: true,
@@ -71662,7 +71664,11 @@ var kyOptionKeys = {
71662
71664
  throwHttpErrors: true,
71663
71665
  onDownloadProgress: true,
71664
71666
  onUploadProgress: true,
71665
- fetch: true
71667
+ fetch: true,
71668
+ context: true
71669
+ };
71670
+ var vendorSpecificOptions = {
71671
+ next: true
71666
71672
  };
71667
71673
  var requestOptionsRegistry = {
71668
71674
  method: true,
@@ -71678,9 +71684,7 @@ var requestOptionsRegistry = {
71678
71684
  keepalive: true,
71679
71685
  signal: true,
71680
71686
  window: true,
71681
- dispatcher: true,
71682
- duplex: true,
71683
- priority: true
71687
+ duplex: true
71684
71688
  };
71685
71689
 
71686
71690
  // node_modules/ky/distribution/utils/body.js
@@ -71757,7 +71761,7 @@ var streamResponse = (response, onDownloadProgress) => {
71757
71761
  headers: response.headers
71758
71762
  });
71759
71763
  }
71760
- const totalBytes = Number(response.headers.get("content-length")) || 0;
71764
+ const totalBytes = Math.max(0, Number(response.headers.get("content-length")) || 0);
71761
71765
  return new Response(withProgress(response.body, totalBytes, onDownloadProgress), {
71762
71766
  status: response.status,
71763
71767
  statusText: response.statusText,
@@ -71809,10 +71813,44 @@ var mergeHooks = (original = {}, incoming = {}) => ({
71809
71813
  afterResponse: newHookValue(original, incoming, "afterResponse"),
71810
71814
  beforeError: newHookValue(original, incoming, "beforeError")
71811
71815
  });
71816
+ var appendSearchParameters = (target, source) => {
71817
+ const result = new URLSearchParams;
71818
+ for (const input of [target, source]) {
71819
+ if (input === undefined) {
71820
+ continue;
71821
+ }
71822
+ if (input instanceof URLSearchParams) {
71823
+ for (const [key, value] of input.entries()) {
71824
+ result.append(key, value);
71825
+ }
71826
+ } else if (Array.isArray(input)) {
71827
+ for (const pair of input) {
71828
+ if (!Array.isArray(pair) || pair.length !== 2) {
71829
+ throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
71830
+ }
71831
+ result.append(String(pair[0]), String(pair[1]));
71832
+ }
71833
+ } else if (isObject2(input)) {
71834
+ for (const [key, value] of Object.entries(input)) {
71835
+ if (value !== undefined) {
71836
+ result.append(key, String(value));
71837
+ }
71838
+ }
71839
+ } else {
71840
+ const parameters = new URLSearchParams(input);
71841
+ for (const [key, value] of parameters.entries()) {
71842
+ result.append(key, value);
71843
+ }
71844
+ }
71845
+ }
71846
+ return result;
71847
+ };
71812
71848
  var deepMerge = (...sources) => {
71813
71849
  let returnValue = {};
71814
71850
  let headers = {};
71815
71851
  let hooks = {};
71852
+ let searchParameters;
71853
+ const signals = [];
71816
71854
  for (const source of sources) {
71817
71855
  if (Array.isArray(source)) {
71818
71856
  if (!Array.isArray(returnValue)) {
@@ -71821,6 +71859,28 @@ var deepMerge = (...sources) => {
71821
71859
  returnValue = [...returnValue, ...source];
71822
71860
  } else if (isObject2(source)) {
71823
71861
  for (let [key, value] of Object.entries(source)) {
71862
+ if (key === "signal" && value instanceof globalThis.AbortSignal) {
71863
+ signals.push(value);
71864
+ continue;
71865
+ }
71866
+ if (key === "context") {
71867
+ if (value !== undefined && value !== null && (!isObject2(value) || Array.isArray(value))) {
71868
+ throw new TypeError("The `context` option must be an object");
71869
+ }
71870
+ returnValue = {
71871
+ ...returnValue,
71872
+ context: value === undefined || value === null ? {} : { ...returnValue.context, ...value }
71873
+ };
71874
+ continue;
71875
+ }
71876
+ if (key === "searchParams") {
71877
+ if (value === undefined || value === null) {
71878
+ searchParameters = undefined;
71879
+ } else {
71880
+ searchParameters = searchParameters === undefined ? value : appendSearchParameters(searchParameters, value);
71881
+ }
71882
+ continue;
71883
+ }
71824
71884
  if (isObject2(value) && key in returnValue) {
71825
71885
  value = deepMerge(returnValue[key], value);
71826
71886
  }
@@ -71836,6 +71896,21 @@ var deepMerge = (...sources) => {
71836
71896
  }
71837
71897
  }
71838
71898
  }
71899
+ if (searchParameters !== undefined) {
71900
+ returnValue.searchParams = searchParameters;
71901
+ }
71902
+ if (signals.length > 0) {
71903
+ if (signals.length === 1) {
71904
+ returnValue.signal = signals[0];
71905
+ } else if (supportsAbortSignal) {
71906
+ returnValue.signal = AbortSignal.any(signals);
71907
+ } else {
71908
+ returnValue.signal = signals.at(-1);
71909
+ }
71910
+ }
71911
+ if (returnValue.context === undefined) {
71912
+ returnValue.context = {};
71913
+ }
71839
71914
  return returnValue;
71840
71915
  };
71841
71916
 
@@ -71851,27 +71926,39 @@ var defaultRetryOptions = {
71851
71926
  afterStatusCodes: retryAfterStatusCodes,
71852
71927
  maxRetryAfter: Number.POSITIVE_INFINITY,
71853
71928
  backoffLimit: Number.POSITIVE_INFINITY,
71854
- delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1000
71929
+ delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1000,
71930
+ jitter: undefined,
71931
+ retryOnTimeout: false
71855
71932
  };
71856
- var normalizeRetryOptions = (retry = {}) => {
71857
- if (typeof retry === "number") {
71933
+ var normalizeRetryOptions = (retry2 = {}) => {
71934
+ if (typeof retry2 === "number") {
71858
71935
  return {
71859
71936
  ...defaultRetryOptions,
71860
- limit: retry
71937
+ limit: retry2
71861
71938
  };
71862
71939
  }
71863
- if (retry.methods && !Array.isArray(retry.methods)) {
71940
+ if (retry2.methods && !Array.isArray(retry2.methods)) {
71864
71941
  throw new Error("retry.methods must be an array");
71865
71942
  }
71866
- if (retry.statusCodes && !Array.isArray(retry.statusCodes)) {
71943
+ if (retry2.statusCodes && !Array.isArray(retry2.statusCodes)) {
71867
71944
  throw new Error("retry.statusCodes must be an array");
71868
71945
  }
71869
71946
  return {
71870
71947
  ...defaultRetryOptions,
71871
- ...retry
71948
+ ...retry2
71872
71949
  };
71873
71950
  };
71874
71951
 
71952
+ // node_modules/ky/distribution/errors/TimeoutError.js
71953
+ class TimeoutError extends Error {
71954
+ request;
71955
+ constructor(request) {
71956
+ super(`Request timed out: ${request.method} ${request.url}`);
71957
+ this.name = "TimeoutError";
71958
+ this.request = request;
71959
+ }
71960
+ }
71961
+
71875
71962
  // node_modules/ky/distribution/utils/timeout.js
71876
71963
  async function timeout(request, init2, abortController, options) {
71877
71964
  return new Promise((resolve, reject) => {
@@ -71909,7 +71996,10 @@ async function delay(ms, { signal }) {
71909
71996
  var findUnknownOptions = (request, options) => {
71910
71997
  const unknownOptions = {};
71911
71998
  for (const key in options) {
71912
- if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && !(key in request)) {
71999
+ if (!Object.hasOwn(options, key)) {
72000
+ continue;
72001
+ }
72002
+ if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && (!(key in request) || (key in vendorSpecificOptions))) {
71913
72003
  unknownOptions[key] = options[key];
71914
72004
  }
71915
72005
  }
@@ -71934,44 +72024,59 @@ var hasSearchParameters = (search) => {
71934
72024
  return Boolean(search);
71935
72025
  };
71936
72026
 
72027
+ // node_modules/ky/distribution/utils/type-guards.js
72028
+ function isHTTPError(error) {
72029
+ return error instanceof HTTPError || error?.name === HTTPError.name;
72030
+ }
72031
+ function isTimeoutError(error) {
72032
+ return error instanceof TimeoutError || error?.name === TimeoutError.name;
72033
+ }
72034
+
71937
72035
  // node_modules/ky/distribution/core/Ky.js
71938
72036
  class Ky {
71939
72037
  static create(input, options) {
71940
72038
  const ky = new Ky(input, options);
71941
72039
  const function_ = async () => {
71942
- if (typeof ky._options.timeout === "number" && ky._options.timeout > maxSafeTimeout) {
72040
+ if (typeof ky.#options.timeout === "number" && ky.#options.timeout > maxSafeTimeout) {
71943
72041
  throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
71944
72042
  }
71945
72043
  await Promise.resolve();
71946
- let response = await ky._fetch();
71947
- for (const hook of ky._options.hooks.afterResponse) {
71948
- const modifiedResponse = await hook(ky.request, ky._options, ky._decorateResponse(response.clone()));
72044
+ let response = await ky.#fetch();
72045
+ for (const hook of ky.#options.hooks.afterResponse) {
72046
+ const clonedResponse = ky.#decorateResponse(response.clone());
72047
+ const modifiedResponse = await hook(ky.request, ky.#getNormalizedOptions(), clonedResponse, { retryCount: ky.#retryCount });
71949
72048
  if (modifiedResponse instanceof globalThis.Response) {
71950
72049
  response = modifiedResponse;
71951
72050
  }
72051
+ if (modifiedResponse instanceof RetryMarker) {
72052
+ await Promise.all([
72053
+ clonedResponse.body?.cancel(),
72054
+ response.body?.cancel()
72055
+ ]);
72056
+ throw new ForceRetryError(modifiedResponse.options);
72057
+ }
71952
72058
  }
71953
- ky._decorateResponse(response);
71954
- if (!response.ok && ky._options.throwHttpErrors) {
71955
- let error = new HTTPError(response, ky.request, ky._options);
71956
- for (const hook of ky._options.hooks.beforeError) {
71957
- error = await hook(error);
72059
+ ky.#decorateResponse(response);
72060
+ if (!response.ok && (typeof ky.#options.throwHttpErrors === "function" ? ky.#options.throwHttpErrors(response.status) : ky.#options.throwHttpErrors)) {
72061
+ let error = new HTTPError(response, ky.request, ky.#getNormalizedOptions());
72062
+ for (const hook of ky.#options.hooks.beforeError) {
72063
+ error = await hook(error, { retryCount: ky.#retryCount });
71958
72064
  }
71959
72065
  throw error;
71960
72066
  }
71961
- if (ky._options.onDownloadProgress) {
71962
- if (typeof ky._options.onDownloadProgress !== "function") {
72067
+ if (ky.#options.onDownloadProgress) {
72068
+ if (typeof ky.#options.onDownloadProgress !== "function") {
71963
72069
  throw new TypeError("The `onDownloadProgress` option must be a function");
71964
72070
  }
71965
72071
  if (!supportsResponseStreams) {
71966
72072
  throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
71967
72073
  }
71968
- return streamResponse(response.clone(), ky._options.onDownloadProgress);
72074
+ return streamResponse(response.clone(), ky.#options.onDownloadProgress);
71969
72075
  }
71970
72076
  return response;
71971
72077
  };
71972
- const isRetriableMethod = ky._options.retry.methods.includes(ky.request.method.toLowerCase());
71973
- const result = (isRetriableMethod ? ky._retry(function_) : function_()).finally(async () => {
71974
- const originalRequest = ky._originalRequest;
72078
+ const result = ky.#retry(function_).finally(async () => {
72079
+ const originalRequest = ky.#originalRequest;
71975
72080
  const cleanupPromises = [];
71976
72081
  if (originalRequest && !originalRequest.bodyUsed) {
71977
72082
  cleanupPromises.push(originalRequest.body?.cancel());
@@ -72013,150 +72118,215 @@ class Ky {
72013
72118
  return searchParams;
72014
72119
  }
72015
72120
  request;
72016
- abortController;
72017
- _retryCount = 0;
72018
- _input;
72019
- _options;
72020
- _originalRequest;
72121
+ #abortController;
72122
+ #retryCount = 0;
72123
+ #input;
72124
+ #options;
72125
+ #originalRequest;
72126
+ #userProvidedAbortSignal;
72127
+ #cachedNormalizedOptions;
72021
72128
  constructor(input, options = {}) {
72022
- this._input = input;
72023
- this._options = {
72129
+ this.#input = input;
72130
+ this.#options = {
72024
72131
  ...options,
72025
- headers: mergeHeaders(this._input.headers, options.headers),
72132
+ headers: mergeHeaders(this.#input.headers, options.headers),
72026
72133
  hooks: mergeHooks({
72027
72134
  beforeRequest: [],
72028
72135
  beforeRetry: [],
72029
72136
  beforeError: [],
72030
72137
  afterResponse: []
72031
72138
  }, options.hooks),
72032
- method: normalizeRequestMethod(options.method ?? this._input.method ?? "GET"),
72139
+ method: normalizeRequestMethod(options.method ?? this.#input.method ?? "GET"),
72033
72140
  prefixUrl: String(options.prefixUrl || ""),
72034
72141
  retry: normalizeRetryOptions(options.retry),
72035
- throwHttpErrors: options.throwHttpErrors !== false,
72142
+ throwHttpErrors: options.throwHttpErrors ?? true,
72036
72143
  timeout: options.timeout ?? 1e4,
72037
- fetch: options.fetch ?? globalThis.fetch.bind(globalThis)
72144
+ fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
72145
+ context: options.context ?? {}
72038
72146
  };
72039
- if (typeof this._input !== "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request)) {
72147
+ if (typeof this.#input !== "string" && !(this.#input instanceof URL || this.#input instanceof globalThis.Request)) {
72040
72148
  throw new TypeError("`input` must be a string, URL, or Request");
72041
72149
  }
72042
- if (this._options.prefixUrl && typeof this._input === "string") {
72043
- if (this._input.startsWith("/")) {
72150
+ if (this.#options.prefixUrl && typeof this.#input === "string") {
72151
+ if (this.#input.startsWith("/")) {
72044
72152
  throw new Error("`input` must not begin with a slash when using `prefixUrl`");
72045
72153
  }
72046
- if (!this._options.prefixUrl.endsWith("/")) {
72047
- this._options.prefixUrl += "/";
72154
+ if (!this.#options.prefixUrl.endsWith("/")) {
72155
+ this.#options.prefixUrl += "/";
72048
72156
  }
72049
- this._input = this._options.prefixUrl + this._input;
72157
+ this.#input = this.#options.prefixUrl + this.#input;
72050
72158
  }
72051
72159
  if (supportsAbortController && supportsAbortSignal) {
72052
- const originalSignal = this._options.signal ?? this._input.signal;
72053
- this.abortController = new globalThis.AbortController;
72054
- this._options.signal = originalSignal ? AbortSignal.any([originalSignal, this.abortController.signal]) : this.abortController.signal;
72160
+ this.#userProvidedAbortSignal = this.#options.signal ?? this.#input.signal;
72161
+ this.#abortController = new globalThis.AbortController;
72162
+ this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
72055
72163
  }
72056
72164
  if (supportsRequestStreams) {
72057
- this._options.duplex = "half";
72165
+ this.#options.duplex = "half";
72166
+ }
72167
+ if (this.#options.json !== undefined) {
72168
+ this.#options.body = this.#options.stringifyJson?.(this.#options.json) ?? JSON.stringify(this.#options.json);
72169
+ this.#options.headers.set("content-type", this.#options.headers.get("content-type") ?? "application/json");
72058
72170
  }
72059
- if (this._options.json !== undefined) {
72060
- this._options.body = this._options.stringifyJson?.(this._options.json) ?? JSON.stringify(this._options.json);
72061
- this._options.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json");
72171
+ const userProvidedContentType = options.headers && new globalThis.Headers(options.headers).has("content-type");
72172
+ if (this.#input instanceof globalThis.Request && (supportsFormData && this.#options.body instanceof globalThis.FormData || this.#options.body instanceof URLSearchParams) && !userProvidedContentType) {
72173
+ this.#options.headers.delete("content-type");
72062
72174
  }
72063
- this.request = new globalThis.Request(this._input, this._options);
72064
- if (hasSearchParameters(this._options.searchParams)) {
72065
- const textSearchParams = typeof this._options.searchParams === "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(Ky.#normalizeSearchParams(this._options.searchParams)).toString();
72175
+ this.request = new globalThis.Request(this.#input, this.#options);
72176
+ if (hasSearchParameters(this.#options.searchParams)) {
72177
+ const textSearchParams = typeof this.#options.searchParams === "string" ? this.#options.searchParams.replace(/^\?/, "") : new URLSearchParams(Ky.#normalizeSearchParams(this.#options.searchParams)).toString();
72066
72178
  const searchParams = "?" + textSearchParams;
72067
72179
  const url = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
72068
- if ((supportsFormData && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"])) {
72069
- this.request.headers.delete("content-type");
72070
- }
72071
- this.request = new globalThis.Request(new globalThis.Request(url, { ...this.request }), this._options);
72180
+ this.request = new globalThis.Request(url, this.#options);
72072
72181
  }
72073
- if (this._options.onUploadProgress) {
72074
- if (typeof this._options.onUploadProgress !== "function") {
72182
+ if (this.#options.onUploadProgress) {
72183
+ if (typeof this.#options.onUploadProgress !== "function") {
72075
72184
  throw new TypeError("The `onUploadProgress` option must be a function");
72076
72185
  }
72077
72186
  if (!supportsRequestStreams) {
72078
72187
  throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
72079
72188
  }
72080
- const originalBody = this.request.body;
72081
- if (originalBody) {
72082
- this.request = streamRequest(this.request, this._options.onUploadProgress, this._options.body);
72189
+ this.request = this.#wrapRequestWithUploadProgress(this.request, this.#options.body ?? undefined);
72190
+ }
72191
+ }
72192
+ #calculateDelay() {
72193
+ const retryDelay = this.#options.retry.delay(this.#retryCount);
72194
+ let jitteredDelay = retryDelay;
72195
+ if (this.#options.retry.jitter === true) {
72196
+ jitteredDelay = Math.random() * retryDelay;
72197
+ } else if (typeof this.#options.retry.jitter === "function") {
72198
+ jitteredDelay = this.#options.retry.jitter(retryDelay);
72199
+ if (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {
72200
+ jitteredDelay = retryDelay;
72083
72201
  }
72084
72202
  }
72203
+ return Math.min(this.#options.retry.backoffLimit, jitteredDelay);
72085
72204
  }
72086
- _calculateRetryDelay(error) {
72087
- this._retryCount++;
72088
- if (this._retryCount > this._options.retry.limit || error instanceof TimeoutError) {
72205
+ async#calculateRetryDelay(error) {
72206
+ this.#retryCount++;
72207
+ if (this.#retryCount > this.#options.retry.limit) {
72208
+ throw error;
72209
+ }
72210
+ const errorObject = error instanceof Error ? error : new NonError(error);
72211
+ if (errorObject instanceof ForceRetryError) {
72212
+ return errorObject.customDelay ?? this.#calculateDelay();
72213
+ }
72214
+ if (!this.#options.retry.methods.includes(this.request.method.toLowerCase())) {
72215
+ throw error;
72216
+ }
72217
+ if (this.#options.retry.shouldRetry !== undefined) {
72218
+ const result = await this.#options.retry.shouldRetry({ error: errorObject, retryCount: this.#retryCount });
72219
+ if (result === false) {
72220
+ throw error;
72221
+ }
72222
+ if (result === true) {
72223
+ return this.#calculateDelay();
72224
+ }
72225
+ }
72226
+ if (isTimeoutError(error) && !this.#options.retry.retryOnTimeout) {
72089
72227
  throw error;
72090
72228
  }
72091
- if (error instanceof HTTPError) {
72092
- if (!this._options.retry.statusCodes.includes(error.response.status)) {
72229
+ if (isHTTPError(error)) {
72230
+ if (!this.#options.retry.statusCodes.includes(error.response.status)) {
72093
72231
  throw error;
72094
72232
  }
72095
- const retryAfter = error.response.headers.get("Retry-After") ?? error.response.headers.get("RateLimit-Reset") ?? error.response.headers.get("X-RateLimit-Reset") ?? error.response.headers.get("X-Rate-Limit-Reset");
72096
- if (retryAfter && this._options.retry.afterStatusCodes.includes(error.response.status)) {
72233
+ const retryAfter = error.response.headers.get("Retry-After") ?? error.response.headers.get("RateLimit-Reset") ?? error.response.headers.get("X-RateLimit-Retry-After") ?? error.response.headers.get("X-RateLimit-Reset") ?? error.response.headers.get("X-Rate-Limit-Reset");
72234
+ if (retryAfter && this.#options.retry.afterStatusCodes.includes(error.response.status)) {
72097
72235
  let after = Number(retryAfter) * 1000;
72098
72236
  if (Number.isNaN(after)) {
72099
72237
  after = Date.parse(retryAfter) - Date.now();
72100
72238
  } else if (after >= Date.parse("2024-01-01")) {
72101
72239
  after -= Date.now();
72102
72240
  }
72103
- const max = this._options.retry.maxRetryAfter ?? after;
72241
+ const max = this.#options.retry.maxRetryAfter ?? after;
72104
72242
  return after < max ? after : max;
72105
72243
  }
72106
72244
  if (error.response.status === 413) {
72107
72245
  throw error;
72108
72246
  }
72109
72247
  }
72110
- const retryDelay = this._options.retry.delay(this._retryCount);
72111
- return Math.min(this._options.retry.backoffLimit, retryDelay);
72248
+ return this.#calculateDelay();
72112
72249
  }
72113
- _decorateResponse(response) {
72114
- if (this._options.parseJson) {
72115
- response.json = async () => this._options.parseJson(await response.text());
72250
+ #decorateResponse(response) {
72251
+ if (this.#options.parseJson) {
72252
+ response.json = async () => this.#options.parseJson(await response.text());
72116
72253
  }
72117
72254
  return response;
72118
72255
  }
72119
- async _retry(function_) {
72256
+ async#retry(function_) {
72120
72257
  try {
72121
72258
  return await function_();
72122
72259
  } catch (error) {
72123
- const ms = Math.min(this._calculateRetryDelay(error), maxSafeTimeout);
72124
- if (this._retryCount < 1) {
72260
+ const ms = Math.min(await this.#calculateRetryDelay(error), maxSafeTimeout);
72261
+ if (this.#retryCount < 1) {
72125
72262
  throw error;
72126
72263
  }
72127
- await delay(ms, { signal: this._options.signal });
72128
- for (const hook of this._options.hooks.beforeRetry) {
72264
+ await delay(ms, this.#userProvidedAbortSignal ? { signal: this.#userProvidedAbortSignal } : {});
72265
+ if (error instanceof ForceRetryError && error.customRequest) {
72266
+ const managedRequest = this.#options.signal ? new globalThis.Request(error.customRequest, { signal: this.#options.signal }) : new globalThis.Request(error.customRequest);
72267
+ this.#assignRequest(managedRequest);
72268
+ }
72269
+ for (const hook of this.#options.hooks.beforeRetry) {
72129
72270
  const hookResult = await hook({
72130
72271
  request: this.request,
72131
- options: this._options,
72272
+ options: this.#getNormalizedOptions(),
72132
72273
  error,
72133
- retryCount: this._retryCount
72274
+ retryCount: this.#retryCount
72134
72275
  });
72276
+ if (hookResult instanceof globalThis.Request) {
72277
+ this.#assignRequest(hookResult);
72278
+ break;
72279
+ }
72280
+ if (hookResult instanceof globalThis.Response) {
72281
+ return hookResult;
72282
+ }
72135
72283
  if (hookResult === stop) {
72136
72284
  return;
72137
72285
  }
72138
72286
  }
72139
- return this._retry(function_);
72287
+ return this.#retry(function_);
72140
72288
  }
72141
72289
  }
72142
- async _fetch() {
72143
- for (const hook of this._options.hooks.beforeRequest) {
72144
- const result = await hook(this.request, this._options);
72145
- if (result instanceof Request) {
72146
- this.request = result;
72147
- break;
72148
- }
72290
+ async#fetch() {
72291
+ if (this.#abortController?.signal.aborted) {
72292
+ this.#abortController = new globalThis.AbortController;
72293
+ this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
72294
+ this.request = new globalThis.Request(this.request, { signal: this.#options.signal });
72295
+ }
72296
+ for (const hook of this.#options.hooks.beforeRequest) {
72297
+ const result = await hook(this.request, this.#getNormalizedOptions(), { retryCount: this.#retryCount });
72149
72298
  if (result instanceof Response) {
72150
72299
  return result;
72151
72300
  }
72301
+ if (result instanceof globalThis.Request) {
72302
+ this.#assignRequest(result);
72303
+ break;
72304
+ }
72305
+ }
72306
+ const nonRequestOptions = findUnknownOptions(this.request, this.#options);
72307
+ this.#originalRequest = this.request;
72308
+ this.request = this.#originalRequest.clone();
72309
+ if (this.#options.timeout === false) {
72310
+ return this.#options.fetch(this.#originalRequest, nonRequestOptions);
72152
72311
  }
72153
- const nonRequestOptions = findUnknownOptions(this.request, this._options);
72154
- this._originalRequest = this.request;
72155
- this.request = this._originalRequest.clone();
72156
- if (this._options.timeout === false) {
72157
- return this._options.fetch(this._originalRequest, nonRequestOptions);
72312
+ return timeout(this.#originalRequest, nonRequestOptions, this.#abortController, this.#options);
72313
+ }
72314
+ #getNormalizedOptions() {
72315
+ if (!this.#cachedNormalizedOptions) {
72316
+ const { hooks, ...normalizedOptions } = this.#options;
72317
+ this.#cachedNormalizedOptions = Object.freeze(normalizedOptions);
72158
72318
  }
72159
- return timeout(this._originalRequest, nonRequestOptions, this.abortController, this._options);
72319
+ return this.#cachedNormalizedOptions;
72320
+ }
72321
+ #assignRequest(request) {
72322
+ this.#cachedNormalizedOptions = undefined;
72323
+ this.request = this.#wrapRequestWithUploadProgress(request);
72324
+ }
72325
+ #wrapRequestWithUploadProgress(request, originalBody) {
72326
+ if (!this.#options.onUploadProgress || !request.body) {
72327
+ return request;
72328
+ }
72329
+ return streamRequest(request, this.#options.onUploadProgress, originalBody ?? this.#options.body ?? undefined);
72160
72330
  }
72161
72331
  }
72162
72332
 
@@ -72175,6 +72345,7 @@ var createInstance = (defaults) => {
72175
72345
  return createInstance(validateAndMerge(defaults, newDefaults));
72176
72346
  };
72177
72347
  ky.stop = stop;
72348
+ ky.retry = retry;
72178
72349
  return ky;
72179
72350
  };
72180
72351
  var ky = createInstance();
@@ -72198,7 +72369,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
72198
72369
  import { execSync as execSync2 } from "node:child_process";
72199
72370
  var import_semver2 = __toESM2(require_semver2(), 1);
72200
72371
  // package.json
72201
- var version = "0.1.468";
72372
+ var version = "0.1.470";
72202
72373
  var package_default = {
72203
72374
  name: "@tscircuit/cli",
72204
72375
  version,
@@ -72209,7 +72380,7 @@ var package_default = {
72209
72380
  "@tscircuit/circuit-json-util": "0.0.67",
72210
72381
  "@tscircuit/fake-snippets": "^0.0.128",
72211
72382
  "@tscircuit/file-server": "^0.0.32",
72212
- "@tscircuit/math-utils": "0.0.21",
72383
+ "@tscircuit/math-utils": "0.0.29",
72213
72384
  "@tscircuit/props": "^0.0.371",
72214
72385
  "@tscircuit/runframe": "^0.0.1233",
72215
72386
  "@tscircuit/schematic-match-adapt": "^0.0.22",
@@ -72223,6 +72394,7 @@ var package_default = {
72223
72394
  "@types/semver": "^7.5.8",
72224
72395
  "bun-match-svg": "^0.0.12",
72225
72396
  chokidar: "4.0.1",
72397
+ "circuit-json": "^0.0.306",
72226
72398
  "circuit-json-to-gltf": "^0.0.14",
72227
72399
  "circuit-json-to-kicad": "^0.0.3",
72228
72400
  "circuit-json-to-readable-netlist": "^0.0.13",
@@ -72257,10 +72429,9 @@ var package_default = {
72257
72429
  semver: "^7.6.3",
72258
72430
  sharp: "0.32.6",
72259
72431
  tempy: "^3.1.0",
72260
- tscircuit: "^0.0.757-libonly",
72432
+ tscircuit: "^0.0.880-libonly",
72261
72433
  tsx: "^4.7.1",
72262
72434
  "typed-ky": "^0.0.4",
72263
- "circuit-json": "^0.0.275",
72264
72435
  zod: "3"
72265
72436
  },
72266
72437
  peerDependencies: {
@@ -94235,10 +94406,10 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
94235
94406
  // lib/eecircuit-engine/run-simulation.ts
94236
94407
  import { promises as fs26, existsSync as existsSync9 } from "node:fs";
94237
94408
  import path26 from "node:path";
94238
- import os3 from "node:os";
94409
+ import os2 from "node:os";
94239
94410
  var sim = null;
94240
94411
  var fetchSimulation = async () => {
94241
- const tempFilePath = path26.join(os3.tmpdir(), "eecircuit-engine-1.5.2.mjs");
94412
+ const tempFilePath = path26.join(os2.tmpdir(), "eecircuit-engine-1.5.2.mjs");
94242
94413
  if (!existsSync9(tempFilePath)) {
94243
94414
  const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
94244
94415
  const response = await fetch(url);
@@ -100996,7 +101167,7 @@ var zo = rs.find((t2) => t2.text === "{REF}");
100996
101167
  zo.y = 0;
100997
101168
  zo.x = 0.35;
100998
101169
  zo.anchor = "middle_left";
100999
- var os4 = es;
101170
+ var os3 = es;
101000
101171
  var is = { paths: { path11: { type: "path", points: [{ x: -0.39, y: 0 }, { x: 0.06, y: -0.01 }], color: "primary", fill: false }, path40: { type: "path", points: [{ x: 0.07, y: 0.19 }, { x: 0.07, y: -0.18 }], color: "primary", fill: false }, "path12-1": { type: "path", points: [{ x: 0.28, y: 0.53 }, { x: 0.28, y: 0.11 }], color: "primary", fill: false }, "path12-1-5": { type: "path", points: [{ x: 0.29, y: -0.53 }, { x: 0.29, y: -0.1 }], color: "primary", fill: false }, path2: { type: "path", points: [{ x: 0.07, y: 0.11 }, { x: 0.29, y: 0.11 }], color: "primary", fill: false }, "path2-5": { type: "path", points: [{ x: 0.07, y: -0.1 }, { x: 0.29, y: -0.1 }], color: "primary", fill: false }, path15: { type: "path", points: [{ x: -0.08, y: 0.06 }, { x: -0.08, y: -0.07 }, { x: 0.01, y: 0 }, { x: -0.08, y: 0.06 }], color: "primary", fill: true } }, texts: { top1: { type: "text", text: "{REF}", x: -0.15, y: 0.36 }, bottom1: { type: "text", text: "{VAL}", x: 0.04, y: -0.42 } }, refblocks: { top1: { x: 0.28, y: 0.55 }, bottom1: { x: 0.29, y: -0.55 }, left1: { x: -0.4, y: 0 } }, bounds: { minX: -0.43, maxX: 0.43, minY: -0.58, maxY: 0.58, width: 0.85, height: 1.16, centerX: 0, centerY: 0 }, circles: { path1: { type: "circle", x: 0.14, y: 0, radius: 0.29, color: "primary", fill: false } } };
101001
101172
  var { paths: ud, texts: ls, bounds: Ke, refblocks: Oo, circles: vd } = is;
101002
101173
  var t0 = s({ primitives: [...Object.values(ud), ...Object.values(vd), { ...ls.top1, anchor: "middle_right", x: 0 }, { ...ls.bottom1, anchor: "middle_right", x: 0 }], ports: [{ ...Oo.top1, labels: ["1", "drain"] }, { ...Oo.bottom1, labels: ["2", "source"] }, { ...Oo.left1, labels: ["3", "gate"] }], size: { width: Ke.width, height: Ke.height }, center: { x: Ke.centerX, y: Ke.centerY } });
@@ -101585,7 +101756,7 @@ var mb = Cl.primitives.find((t3) => t3.type === "text" && t3.text === "{VAL}");
101585
101756
  sb.anchor = "middle_left";
101586
101757
  mb.anchor = "middle_right";
101587
101758
  var B1 = Cl;
101588
- var q1 = { ac_voltmeter_down: Ul, ac_voltmeter_horz: Wl, ac_voltmeter_left: Zl, ac_voltmeter_right: Kl, ac_voltmeter_up: ep, ac_voltmeter_vert: op, avalanche_diode_down: lp, avalanche_diode_horz: pp, avalanche_diode_left: yp, avalanche_diode_right: xp, avalanche_diode_up: mp, avalanche_diode_vert: fp, backward_diode_down: cp, backward_diode_left: Dt, backward_diode_right: _p, backward_diode_up: gp, battery_horz: Wt, battery_vert: Ap, boxresistor_down: Fp, boxresistor_left: Ep, boxresistor_right: Lp, boxresistor_small_down: jp, boxresistor_small_left: zp, boxresistor_small_right: Jp, boxresistor_small_up: Mp, boxresistor_up: Ip, bridged_ground_down: Dp, bridged_ground_left: Wp, bridged_ground_right: te, bridged_ground_up: Qp, capacitor_down: ta, capacitor_left: ea, capacitor_polarized_down: oa, capacitor_polarized_left: ia, capacitor_polarized_right: pa, capacitor_polarized_up: ya, capacitor_right: xa, capacitor_up: ma, constant_current_diode_down: fa, constant_current_diode_horz: ha, constant_current_diode_left: da, constant_current_diode_right: ba, constant_current_diode_up: ga, constant_current_diode_vert: va, crystal_4pin_down: wa, crystal_4pin_left: Aa, crystal_4pin_right: Pa, crystal_4pin_up: Sa, crystal_down: Ra, crystal_left: Ta, crystal_right: Ea, crystal_up: Xa, darlington_pair_transistor_down: La, darlington_pair_transistor_horz: Va, darlington_pair_transistor_left: ja, darlington_pair_transistor_right: ka, darlington_pair_transistor_up: za, darlington_pair_transistor_vert: Oa, dc_ammeter_horz: wt, dc_ammeter_vert: Ca, dc_voltmeter_down: Ia, dc_voltmeter_horz: qa, dc_voltmeter_left: Ua, dc_voltmeter_right: Wa, dc_voltmeter_up: Za, dc_voltmeter_vert: Ka, diac_down: ty, diac_horz: ey, diac_left: ry, diac_right: oy, diac_up: iy, diac_vert: ly, diode_down: ay, diode_left: yy, diode_right: $2, diode_up: xy, dpdt_normally_closed_switch_down: my, dpdt_normally_closed_switch_left: ny, dpdt_normally_closed_switch_right: M, dpdt_normally_closed_switch_up: fy, dpdt_switch_down: cy, dpdt_switch_left: dy, dpdt_switch_right: C, dpdt_switch_up: by, dpst_normally_closed_switch_down: gy, dpst_normally_closed_switch_left: uy, dpst_normally_closed_switch_right: N, dpst_normally_closed_switch_up: vy, dpst_switch_down: Ay, dpst_switch_left: Py, dpst_switch_right: I, dpst_switch_up: Sy, ferrite_bead_down: Ry, ferrite_bead_left: Ty, ferrite_bead_right: Fe, ferrite_bead_up: Se, filled_diode_down: Yy, filled_diode_horz: Ly, filled_diode_left: jy, filled_diode_right: zy, filled_diode_up: Jy, filled_diode_vert: My, frequency_meter_horz: At2, frequency_meter_vert: By, fuse_horz: ke, fuse_vert: Uy, ground_down: Gy, ground_horz: Wy, ground_left: Hy, ground_right: Zy, ground_up: Qy, ground_vert: Ky2, ground2_down: ex, ground2_left: ox, ground2_right: lx, ground2_up: ax, gunn_diode_horz: yx, gunn_diode_vert: xx, icled_down: mx, icled_left: nx, icled_right: q, icled_up: fx, igbt_transistor_horz: ze, igbt_transistor_vert: dx, illuminated_push_button_normally_open_horz: Oe, illuminated_push_button_normally_open_vert: ux, inductor_down: Px, inductor_left: Sx, inductor_right: _t, inductor_up: $e, laser_diode_down: Fx, laser_diode_left: Rx, laser_diode_right: D, laser_diode_up: Tx, led_down: Lx, led_left: Vx, led_right: gt, led_up: Ce, light_dependent_resistor_horz: Ie, light_dependent_resistor_vert: $x, mosfet_depletion_normally_on_horz: qe, mosfet_depletion_normally_on_vert: Ix, mushroom_head_normally_open_momentary_horz: Ue, mushroom_head_normally_open_momentary_vert: Ux, n_channel_d_mosfet_transistor_horz: He, n_channel_d_mosfet_transistor_vert: Qx, n_channel_e_mosfet_transistor_horz: Qe, n_channel_e_mosfet_transistor_vert: os4, njfet_transistor_horz: t0, njfet_transistor_vert: ys, not_connected_down: ms, not_connected_left: ns, not_connected_right: U, not_connected_up: fs28, npn_bipolar_transistor_down: hs, npn_bipolar_transistor_horz: cs, npn_bipolar_transistor_left: ds, npn_bipolar_transistor_right: bs, npn_bipolar_transistor_up: _s, npn_bipolar_transistor_vert: gs, opamp_no_power_down: vs, opamp_no_power_left: ws, opamp_no_power_right: G, opamp_no_power_up: As, opamp_with_power_down: Ss, opamp_with_power_left: Fs, opamp_with_power_right: W, opamp_with_power_up: Rs, p_channel_d_mosfet_transistor_horz: a0, p_channel_d_mosfet_transistor_vert: Ls, p_channel_e_mosfet_transistor_horz: x0, p_channel_e_mosfet_transistor_vert: Os, photodiode_horz: s0, photodiode_vert: Cs, pjfet_transistor_horz: n0, pjfet_transistor_vert: Ds, pnp_bipolar_transistor_down: Us, pnp_bipolar_transistor_horz: Gs, pnp_bipolar_transistor_left: Ws, pnp_bipolar_transistor_right: Hs, pnp_bipolar_transistor_up: Zs, pnp_bipolar_transistor_vert: Qs, potentiometer_horz: g0, potentiometer_vert: rm, potentiometer2_down: pm, potentiometer2_left: am, potentiometer2_right: H, potentiometer2_up: ym, potentiometer3_down: xm, potentiometer3_left: sm, potentiometer3_right: mm, potentiometer3_up: nm, power_factor_meter_horz: S0, power_factor_meter_vert: dm, push_button_normally_closed_momentary_horz: R0, push_button_normally_closed_momentary_vert: um, push_button_normally_open_momentary_horz: E0, push_button_normally_open_momentary_vert: Pm, rectifier_diode_horz: L0, rectifier_diode_vert: Rm, resistor_down: Em, resistor_left: Xm, resistor_right: Vm, resistor_up: km, resonator_down: Om, resonator_horz: M0, resonator_left: Jm, resonator_right: K, resonator_up: $m, resonator_vert: Mm, schottky_diode_down: Nm, schottky_diode_left: Im, schottky_diode_right: tt, schottky_diode_up: Bm, silicon_controlled_rectifier_horz: C0, silicon_controlled_rectifier_vert: Um, solderjumper2_bridged12_down: Gm, solderjumper2_bridged12_left: Wm, solderjumper2_bridged12_right: Hm, solderjumper2_bridged12_up: Zm, solderjumper2_down: Qm, solderjumper2_left: Km, solderjumper2_right: tn, solderjumper2_up: en, solderjumper3_bridged12_down: rn, solderjumper3_bridged12_left: on2, solderjumper3_bridged12_right: ln, solderjumper3_bridged12_up: pn, solderjumper3_bridged123_down: an, solderjumper3_bridged123_left: yn, solderjumper3_bridged123_right: xn, solderjumper3_bridged123_up: sn, solderjumper3_bridged23_down: mn, solderjumper3_bridged23_left: nn, solderjumper3_bridged23_right: fn, solderjumper3_bridged23_up: hn, solderjumper3_down: cn, solderjumper3_left: dn, solderjumper3_right: bn, solderjumper3_up: _n, spdt_normally_closed_switch_down: un, spdt_normally_closed_switch_left: vn, spdt_normally_closed_switch_right: at, spdt_normally_closed_switch_up: wn, spdt_switch_down: Pn, spdt_switch_left: Sn, spdt_switch_right: yt, spdt_switch_up: Fn, spst_normally_closed_switch_down: Rn, spst_normally_closed_switch_left: Tn, spst_normally_closed_switch_right: xt, spst_normally_closed_switch_up: En, spst_switch_down: Yn, spst_switch_left: Xn, spst_switch_right: st, spst_switch_up: Ln, square_wave_down: Vn, square_wave_left: jn, square_wave_right: kn, square_wave_up: zn, step_recovery_diode_horz: N0, step_recovery_diode_vert: On, tachometer_horz: Tt, tachometer_vert: Cn, testpoint_down: Bn, testpoint_left: qn, testpoint_right: nt, testpoint_up: Gn, tilted_ground_down: Hn, tilted_ground_left: Zn, tilted_ground_right: ut, tilted_ground_up: B0, triac_horz: q0, triac_vert: t1, tunnel_diode_horz: U0, tunnel_diode_vert: i1, unijunction_transistor_horz: W0, unijunction_transistor_vert: s1, usbc: n1, var_meter_horz: Z0, var_meter_vert: c1, varactor_diode_horz: K0, varactor_diode_vert: g1, varistor_horz: er, varistor_vert: A1, varmeter_horz: Et, varmeter_vert: R1, vcc_down: T1, vcc_left: E1, vcc_right: Y1, vcc_up: X1, volt_meter_horz: or, volt_meter_vert: L1, watt_hour_meter_horz: Yt, watt_hour_meter_vert: z1, wattmeter_horz: Xt, wattmeter_vert: M1, zener_diode_horz: ar, zener_diode_vert: B1 };
101759
+ var q1 = { ac_voltmeter_down: Ul, ac_voltmeter_horz: Wl, ac_voltmeter_left: Zl, ac_voltmeter_right: Kl, ac_voltmeter_up: ep, ac_voltmeter_vert: op, avalanche_diode_down: lp, avalanche_diode_horz: pp, avalanche_diode_left: yp, avalanche_diode_right: xp, avalanche_diode_up: mp, avalanche_diode_vert: fp, backward_diode_down: cp, backward_diode_left: Dt, backward_diode_right: _p, backward_diode_up: gp, battery_horz: Wt, battery_vert: Ap, boxresistor_down: Fp, boxresistor_left: Ep, boxresistor_right: Lp, boxresistor_small_down: jp, boxresistor_small_left: zp, boxresistor_small_right: Jp, boxresistor_small_up: Mp, boxresistor_up: Ip, bridged_ground_down: Dp, bridged_ground_left: Wp, bridged_ground_right: te, bridged_ground_up: Qp, capacitor_down: ta, capacitor_left: ea, capacitor_polarized_down: oa, capacitor_polarized_left: ia, capacitor_polarized_right: pa, capacitor_polarized_up: ya, capacitor_right: xa, capacitor_up: ma, constant_current_diode_down: fa, constant_current_diode_horz: ha, constant_current_diode_left: da, constant_current_diode_right: ba, constant_current_diode_up: ga, constant_current_diode_vert: va, crystal_4pin_down: wa, crystal_4pin_left: Aa, crystal_4pin_right: Pa, crystal_4pin_up: Sa, crystal_down: Ra, crystal_left: Ta, crystal_right: Ea, crystal_up: Xa, darlington_pair_transistor_down: La, darlington_pair_transistor_horz: Va, darlington_pair_transistor_left: ja, darlington_pair_transistor_right: ka, darlington_pair_transistor_up: za, darlington_pair_transistor_vert: Oa, dc_ammeter_horz: wt, dc_ammeter_vert: Ca, dc_voltmeter_down: Ia, dc_voltmeter_horz: qa, dc_voltmeter_left: Ua, dc_voltmeter_right: Wa, dc_voltmeter_up: Za, dc_voltmeter_vert: Ka, diac_down: ty, diac_horz: ey, diac_left: ry, diac_right: oy, diac_up: iy, diac_vert: ly, diode_down: ay, diode_left: yy, diode_right: $2, diode_up: xy, dpdt_normally_closed_switch_down: my, dpdt_normally_closed_switch_left: ny, dpdt_normally_closed_switch_right: M, dpdt_normally_closed_switch_up: fy, dpdt_switch_down: cy, dpdt_switch_left: dy, dpdt_switch_right: C, dpdt_switch_up: by, dpst_normally_closed_switch_down: gy, dpst_normally_closed_switch_left: uy, dpst_normally_closed_switch_right: N, dpst_normally_closed_switch_up: vy, dpst_switch_down: Ay, dpst_switch_left: Py, dpst_switch_right: I, dpst_switch_up: Sy, ferrite_bead_down: Ry, ferrite_bead_left: Ty, ferrite_bead_right: Fe, ferrite_bead_up: Se, filled_diode_down: Yy, filled_diode_horz: Ly, filled_diode_left: jy, filled_diode_right: zy, filled_diode_up: Jy, filled_diode_vert: My, frequency_meter_horz: At2, frequency_meter_vert: By, fuse_horz: ke, fuse_vert: Uy, ground_down: Gy, ground_horz: Wy, ground_left: Hy, ground_right: Zy, ground_up: Qy, ground_vert: Ky2, ground2_down: ex, ground2_left: ox, ground2_right: lx, ground2_up: ax, gunn_diode_horz: yx, gunn_diode_vert: xx, icled_down: mx, icled_left: nx, icled_right: q, icled_up: fx, igbt_transistor_horz: ze, igbt_transistor_vert: dx, illuminated_push_button_normally_open_horz: Oe, illuminated_push_button_normally_open_vert: ux, inductor_down: Px, inductor_left: Sx, inductor_right: _t, inductor_up: $e, laser_diode_down: Fx, laser_diode_left: Rx, laser_diode_right: D, laser_diode_up: Tx, led_down: Lx, led_left: Vx, led_right: gt, led_up: Ce, light_dependent_resistor_horz: Ie, light_dependent_resistor_vert: $x, mosfet_depletion_normally_on_horz: qe, mosfet_depletion_normally_on_vert: Ix, mushroom_head_normally_open_momentary_horz: Ue, mushroom_head_normally_open_momentary_vert: Ux, n_channel_d_mosfet_transistor_horz: He, n_channel_d_mosfet_transistor_vert: Qx, n_channel_e_mosfet_transistor_horz: Qe, n_channel_e_mosfet_transistor_vert: os3, njfet_transistor_horz: t0, njfet_transistor_vert: ys, not_connected_down: ms, not_connected_left: ns, not_connected_right: U, not_connected_up: fs28, npn_bipolar_transistor_down: hs, npn_bipolar_transistor_horz: cs, npn_bipolar_transistor_left: ds, npn_bipolar_transistor_right: bs, npn_bipolar_transistor_up: _s, npn_bipolar_transistor_vert: gs, opamp_no_power_down: vs, opamp_no_power_left: ws, opamp_no_power_right: G, opamp_no_power_up: As, opamp_with_power_down: Ss, opamp_with_power_left: Fs, opamp_with_power_right: W, opamp_with_power_up: Rs, p_channel_d_mosfet_transistor_horz: a0, p_channel_d_mosfet_transistor_vert: Ls, p_channel_e_mosfet_transistor_horz: x0, p_channel_e_mosfet_transistor_vert: Os, photodiode_horz: s0, photodiode_vert: Cs, pjfet_transistor_horz: n0, pjfet_transistor_vert: Ds, pnp_bipolar_transistor_down: Us, pnp_bipolar_transistor_horz: Gs, pnp_bipolar_transistor_left: Ws, pnp_bipolar_transistor_right: Hs, pnp_bipolar_transistor_up: Zs, pnp_bipolar_transistor_vert: Qs, potentiometer_horz: g0, potentiometer_vert: rm, potentiometer2_down: pm, potentiometer2_left: am, potentiometer2_right: H, potentiometer2_up: ym, potentiometer3_down: xm, potentiometer3_left: sm, potentiometer3_right: mm, potentiometer3_up: nm, power_factor_meter_horz: S0, power_factor_meter_vert: dm, push_button_normally_closed_momentary_horz: R0, push_button_normally_closed_momentary_vert: um, push_button_normally_open_momentary_horz: E0, push_button_normally_open_momentary_vert: Pm, rectifier_diode_horz: L0, rectifier_diode_vert: Rm, resistor_down: Em, resistor_left: Xm, resistor_right: Vm, resistor_up: km, resonator_down: Om, resonator_horz: M0, resonator_left: Jm, resonator_right: K, resonator_up: $m, resonator_vert: Mm, schottky_diode_down: Nm, schottky_diode_left: Im, schottky_diode_right: tt, schottky_diode_up: Bm, silicon_controlled_rectifier_horz: C0, silicon_controlled_rectifier_vert: Um, solderjumper2_bridged12_down: Gm, solderjumper2_bridged12_left: Wm, solderjumper2_bridged12_right: Hm, solderjumper2_bridged12_up: Zm, solderjumper2_down: Qm, solderjumper2_left: Km, solderjumper2_right: tn, solderjumper2_up: en, solderjumper3_bridged12_down: rn, solderjumper3_bridged12_left: on2, solderjumper3_bridged12_right: ln, solderjumper3_bridged12_up: pn, solderjumper3_bridged123_down: an, solderjumper3_bridged123_left: yn, solderjumper3_bridged123_right: xn, solderjumper3_bridged123_up: sn, solderjumper3_bridged23_down: mn, solderjumper3_bridged23_left: nn, solderjumper3_bridged23_right: fn, solderjumper3_bridged23_up: hn, solderjumper3_down: cn, solderjumper3_left: dn, solderjumper3_right: bn, solderjumper3_up: _n, spdt_normally_closed_switch_down: un, spdt_normally_closed_switch_left: vn, spdt_normally_closed_switch_right: at, spdt_normally_closed_switch_up: wn, spdt_switch_down: Pn, spdt_switch_left: Sn, spdt_switch_right: yt, spdt_switch_up: Fn, spst_normally_closed_switch_down: Rn, spst_normally_closed_switch_left: Tn, spst_normally_closed_switch_right: xt, spst_normally_closed_switch_up: En, spst_switch_down: Yn, spst_switch_left: Xn, spst_switch_right: st, spst_switch_up: Ln, square_wave_down: Vn, square_wave_left: jn, square_wave_right: kn, square_wave_up: zn, step_recovery_diode_horz: N0, step_recovery_diode_vert: On, tachometer_horz: Tt, tachometer_vert: Cn, testpoint_down: Bn, testpoint_left: qn, testpoint_right: nt, testpoint_up: Gn, tilted_ground_down: Hn, tilted_ground_left: Zn, tilted_ground_right: ut, tilted_ground_up: B0, triac_horz: q0, triac_vert: t1, tunnel_diode_horz: U0, tunnel_diode_vert: i1, unijunction_transistor_horz: W0, unijunction_transistor_vert: s1, usbc: n1, var_meter_horz: Z0, var_meter_vert: c1, varactor_diode_horz: K0, varactor_diode_vert: g1, varistor_horz: er, varistor_vert: A1, varmeter_horz: Et, varmeter_vert: R1, vcc_down: T1, vcc_left: E1, vcc_right: Y1, vcc_up: X1, volt_meter_horz: or, volt_meter_vert: L1, watt_hour_meter_horz: Yt, watt_hour_meter_vert: z1, wattmeter_horz: Xt, wattmeter_vert: M1, zener_diode_horz: ar, zener_diode_vert: B1 };
101589
101760
  var Y$ = Object.fromEntries(Object.keys(q1).map((t3) => [t3, t3]));
101590
101761
  function doesLineIntersectLine([a12, a22], [b12, b22], {
101591
101762
  lineThickness = 0
@@ -109281,7 +109452,7 @@ Learn more about data fetching with Hooks: https://react.dev/link/hooks-data-fet
109281
109452
  function attachSuspenseRetryListeners(finishedWork, wakeables) {
109282
109453
  var retryCache = getRetryCache(finishedWork);
109283
109454
  wakeables.forEach(function(wakeable) {
109284
- var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
109455
+ var retry2 = resolveRetryWakeable.bind(null, finishedWork, wakeable);
109285
109456
  if (!retryCache.has(wakeable)) {
109286
109457
  retryCache.add(wakeable);
109287
109458
  if (isDevToolsPresent)
@@ -109289,7 +109460,7 @@ Learn more about data fetching with Hooks: https://react.dev/link/hooks-data-fet
109289
109460
  restorePendingUpdaters(inProgressRoot, inProgressLanes);
109290
109461
  else
109291
109462
  throw Error("Expected finished root and lanes to be set. This is a bug in React.");
109292
- wakeable.then(retry, retry);
109463
+ wakeable.then(retry2, retry2);
109293
109464
  }
109294
109465
  });
109295
109466
  }
@@ -121836,8 +122007,8 @@ Check the render method of \`` + ownerName + "`.";
121836
122007
  } else if (isSuspenseInstancePending(suspenseInstance)) {
121837
122008
  workInProgress2.flags |= DidCapture;
121838
122009
  workInProgress2.child = current22.child;
121839
- var retry = retryDehydratedSuspenseBoundary.bind(null, current22);
121840
- registerSuspenseInstanceRetry(suspenseInstance, retry);
122010
+ var retry2 = retryDehydratedSuspenseBoundary.bind(null, current22);
122011
+ registerSuspenseInstanceRetry(suspenseInstance, retry2);
121841
122012
  return null;
121842
122013
  } else {
121843
122014
  reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress2, suspenseInstance, suspenseState.treeContext);
@@ -124391,7 +124562,7 @@ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-f
124391
124562
  retryCache = finishedWork.stateNode = new PossiblyWeakSet;
124392
124563
  }
124393
124564
  wakeables.forEach(function(wakeable) {
124394
- var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
124565
+ var retry2 = resolveRetryWakeable.bind(null, finishedWork, wakeable);
124395
124566
  if (!retryCache.has(wakeable)) {
124396
124567
  retryCache.add(wakeable);
124397
124568
  {
@@ -124403,7 +124574,7 @@ Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-f
124403
124574
  }
124404
124575
  }
124405
124576
  }
124406
- wakeable.then(retry, retry);
124577
+ wakeable.then(retry2, retry2);
124407
124578
  }
124408
124579
  });
124409
124580
  }
@@ -140951,7 +141122,7 @@ var import_debug62 = __toESM3(require_browser(), 1);
140951
141122
  var import_react = __toESM3(require_react(), 1);
140952
141123
  var import_react_reconciler = __toESM3(require_react_reconciler(), 1);
140953
141124
  var import_react_reconciler_18 = __toESM3(require_react_reconciler_18(), 1);
140954
- var import_constants13 = __toESM3(require_constants6(), 1);
141125
+ var import_constants14 = __toESM3(require_constants6(), 1);
140955
141126
  var import_debug72 = __toESM3(require_browser(), 1);
140956
141127
  var import_debug82 = __toESM3(require_browser(), 1);
140957
141128
  var esm_exports2 = {};
@@ -185986,9 +186157,9 @@ var hostConfig = {
185986
186157
  detachDeletedInstance: (node) => {
185987
186158
  throw new Error("Function not implemented.");
185988
186159
  },
185989
- getCurrentEventPriority: () => import_constants13.DefaultEventPriority,
185990
- getCurrentUpdatePriority: () => import_constants13.DefaultEventPriority,
185991
- resolveUpdatePriority: () => import_constants13.DefaultEventPriority,
186160
+ getCurrentEventPriority: () => import_constants14.DefaultEventPriority,
186161
+ getCurrentUpdatePriority: () => import_constants14.DefaultEventPriority,
186162
+ resolveUpdatePriority: () => import_constants14.DefaultEventPriority,
185992
186163
  setCurrentUpdatePriority: () => {},
185993
186164
  maySuspendCommit: () => false,
185994
186165
  supportsHydration: false
@@ -195691,8 +195862,8 @@ var registerRemove = (program3) => {
195691
195862
  };
195692
195863
 
195693
195864
  // cli/build/register.ts
195694
- import path32 from "node:path";
195695
- import fs33 from "node:fs";
195865
+ import path33 from "node:path";
195866
+ import fs34 from "node:fs";
195696
195867
 
195697
195868
  // cli/build/build-file.ts
195698
195869
  import path29 from "node:path";
@@ -195966,9 +196137,125 @@ var buildPreviewImages = async ({
195966
196137
  });
195967
196138
  };
195968
196139
 
196140
+ // cli/build/transpile.ts
196141
+ import path32 from "node:path";
196142
+ import fs33 from "node:fs";
196143
+ import { rollup } from "rollup";
196144
+ import typescript from "@rollup/plugin-typescript";
196145
+ import resolve11 from "@rollup/plugin-node-resolve";
196146
+ import commonjs from "@rollup/plugin-commonjs";
196147
+ import json from "@rollup/plugin-json";
196148
+ import dts from "rollup-plugin-dts";
196149
+ var transpileFile = async ({
196150
+ input,
196151
+ outputDir,
196152
+ projectDir
196153
+ }) => {
196154
+ try {
196155
+ fs33.mkdirSync(outputDir, { recursive: true });
196156
+ console.log("Building ESM bundle...");
196157
+ const esmBundle = await rollup({
196158
+ input,
196159
+ external: (id2) => {
196160
+ return !id2.startsWith(".") && !id2.startsWith("/");
196161
+ },
196162
+ plugins: [
196163
+ resolve11({
196164
+ extensions: [".ts", ".tsx", ".js", ".jsx"]
196165
+ }),
196166
+ commonjs(),
196167
+ json(),
196168
+ typescript({
196169
+ jsx: "react",
196170
+ tsconfig: false,
196171
+ compilerOptions: {
196172
+ target: "ES2020",
196173
+ module: "ESNext",
196174
+ jsx: "react",
196175
+ declaration: false,
196176
+ sourceMap: false,
196177
+ skipLibCheck: true,
196178
+ resolveJsonModule: true,
196179
+ allowSyntheticDefaultImports: true
196180
+ }
196181
+ })
196182
+ ]
196183
+ });
196184
+ await esmBundle.write({
196185
+ file: path32.join(outputDir, "index.js"),
196186
+ format: "es",
196187
+ sourcemap: false
196188
+ });
196189
+ console.log(`ESM bundle written to ${path32.relative(projectDir, path32.join(outputDir, "index.js"))}`);
196190
+ console.log("Building CommonJS bundle...");
196191
+ const cjsBundle = await rollup({
196192
+ input,
196193
+ external: (id2) => {
196194
+ return !id2.startsWith(".") && !id2.startsWith("/");
196195
+ },
196196
+ plugins: [
196197
+ resolve11({
196198
+ extensions: [".ts", ".tsx", ".js", ".jsx"]
196199
+ }),
196200
+ commonjs(),
196201
+ json(),
196202
+ typescript({
196203
+ jsx: "react",
196204
+ tsconfig: false,
196205
+ compilerOptions: {
196206
+ target: "ES2020",
196207
+ module: "CommonJS",
196208
+ jsx: "react",
196209
+ declaration: false,
196210
+ sourceMap: false,
196211
+ skipLibCheck: true,
196212
+ resolveJsonModule: true,
196213
+ allowSyntheticDefaultImports: true
196214
+ }
196215
+ })
196216
+ ]
196217
+ });
196218
+ await cjsBundle.write({
196219
+ file: path32.join(outputDir, "index.cjs"),
196220
+ format: "cjs",
196221
+ sourcemap: false
196222
+ });
196223
+ console.log(`CommonJS bundle written to ${path32.relative(projectDir, path32.join(outputDir, "index.cjs"))}`);
196224
+ console.log("Generating type declarations...");
196225
+ const dtsBundle = await rollup({
196226
+ input,
196227
+ external: (id2) => {
196228
+ return !id2.startsWith(".") && !id2.startsWith("/");
196229
+ },
196230
+ plugins: [
196231
+ dts({
196232
+ respectExternal: true
196233
+ })
196234
+ ]
196235
+ });
196236
+ const dtsOutput = await dtsBundle.generate({
196237
+ format: "es"
196238
+ });
196239
+ let dtsContent = dtsOutput.output[0].code;
196240
+ dtsContent = dtsContent.replace(/import \* as [\w_]+ from ['"]react\/jsx-runtime['"];?\s*\n?/g, "");
196241
+ dtsContent = dtsContent.replace(/[\w_]+\.JSX\.Element/g, "any");
196242
+ dtsContent = dtsContent.replace(/export\s*{\s*};\s*$/gm, "").trim();
196243
+ fs33.writeFileSync(path32.join(outputDir, "index.d.ts"), dtsContent);
196244
+ console.log(`Type declarations written to ${path32.relative(projectDir, path32.join(outputDir, "index.d.ts"))}`);
196245
+ console.log(kleur_default.green("Transpilation complete!"));
196246
+ return true;
196247
+ } catch (err) {
196248
+ console.error(kleur_default.red(`Transpilation failed: ${err}`));
196249
+ if (err instanceof Error && err.stack) {
196250
+ console.error(err.stack);
196251
+ }
196252
+ return false;
196253
+ }
196254
+ };
196255
+
195969
196256
  // cli/build/register.ts
195970
196257
  var registerBuild = (program3) => {
195971
- program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--disable-pcb", "Disable PCB outputs").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").action(async (file, options) => {
196258
+ program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--disable-pcb", "Disable PCB outputs").option("--disable-parts-engine", "Disable the parts engine").option("--site", "Generate a static site in the dist directory").option("--transpile", "Transpile the entry file to JavaScript").option("--preview-images", "Generate preview images in the dist directory").option("--all-images", "Generate preview images for every successful build output").action(async (file, options) => {
195972
196259
  try {
195973
196260
  const { projectDir, circuitFiles, mainEntrypoint } = await getBuildEntrypoints({
195974
196261
  fileOrDir: file
@@ -195985,17 +196272,17 @@ var registerBuild = (program3) => {
195985
196272
  }
195986
196273
  return config;
195987
196274
  })();
195988
- const distDir = path32.join(projectDir, "dist");
195989
- fs33.mkdirSync(distDir, { recursive: true });
196275
+ const distDir = path33.join(projectDir, "dist");
196276
+ fs34.mkdirSync(distDir, { recursive: true });
195990
196277
  console.log(`Building ${circuitFiles.length} file(s)...`);
195991
196278
  let hasErrors = false;
195992
196279
  const staticFileReferences = [];
195993
196280
  const builtFiles = [];
195994
196281
  for (const filePath of circuitFiles) {
195995
- const relative9 = path32.relative(projectDir, filePath);
196282
+ const relative9 = path33.relative(projectDir, filePath);
195996
196283
  console.log(`Building ${relative9}...`);
195997
196284
  const outputDirName = relative9.replace(/(\.board|\.circuit)?\.tsx$/, "");
195998
- const outputPath = path32.join(distDir, outputDirName, "circuit.json");
196285
+ const outputPath = path33.join(distDir, outputDirName, "circuit.json");
195999
196286
  const ok = await buildFile(filePath, outputPath, projectDir, {
196000
196287
  ignoreErrors: options?.ignoreErrors,
196001
196288
  ignoreWarnings: options?.ignoreWarnings,
@@ -196009,9 +196296,9 @@ var registerBuild = (program3) => {
196009
196296
  if (!ok) {
196010
196297
  hasErrors = true;
196011
196298
  } else if (options?.site) {
196012
- const normalizedSourcePath = relative9.split(path32.sep).join("/");
196013
- const relativeOutputPath = path32.join(outputDirName, "circuit.json");
196014
- const normalizedOutputPath = relativeOutputPath.split(path32.sep).join("/");
196299
+ const normalizedSourcePath = relative9.split(path33.sep).join("/");
196300
+ const relativeOutputPath = path33.join(outputDirName, "circuit.json");
196301
+ const normalizedOutputPath = relativeOutputPath.split(path33.sep).join("/");
196015
196302
  staticFileReferences.push({
196016
196303
  filePath: normalizedSourcePath,
196017
196304
  fileStaticAssetUrl: `./${normalizedOutputPath}`
@@ -196031,13 +196318,30 @@ var registerBuild = (program3) => {
196031
196318
  allImages: options?.allImages
196032
196319
  });
196033
196320
  }
196321
+ if (options?.transpile) {
196322
+ console.log("Transpiling entry file...");
196323
+ const entryFile = mainEntrypoint || circuitFiles[0];
196324
+ if (!entryFile) {
196325
+ console.error("No entry file found for transpilation");
196326
+ process.exit(1);
196327
+ }
196328
+ const transpileSuccess = await transpileFile({
196329
+ input: entryFile,
196330
+ outputDir: distDir,
196331
+ projectDir
196332
+ });
196333
+ if (!transpileSuccess) {
196334
+ console.error("Transpilation failed");
196335
+ process.exit(1);
196336
+ }
196337
+ }
196034
196338
  if (options?.site) {
196035
196339
  const indexHtml = getStaticIndexHtmlFile({
196036
196340
  files: staticFileReferences,
196037
196341
  standaloneScriptSrc: "./standalone.min.js"
196038
196342
  });
196039
- fs33.writeFileSync(path32.join(distDir, "index.html"), indexHtml);
196040
- fs33.writeFileSync(path32.join(distDir, "standalone.min.js"), standalone_min_default);
196343
+ fs34.writeFileSync(path33.join(distDir, "index.html"), indexHtml);
196344
+ fs34.writeFileSync(path33.join(distDir, "standalone.min.js"), standalone_min_default);
196041
196345
  }
196042
196346
  console.log("Build complete!");
196043
196347
  process.exit(0);
@@ -196050,8 +196354,8 @@ var registerBuild = (program3) => {
196050
196354
  };
196051
196355
 
196052
196356
  // lib/shared/snapshot-project.ts
196053
- import fs35 from "node:fs";
196054
- import path33 from "node:path";
196357
+ import fs36 from "node:fs";
196358
+ import path34 from "node:path";
196055
196359
  import looksSame2 from "looks-same";
196056
196360
  import {
196057
196361
  convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
@@ -196062,7 +196366,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
196062
196366
 
196063
196367
  // lib/shared/compare-images.ts
196064
196368
  import looksSame from "looks-same";
196065
- import fs34 from "node:fs/promises";
196369
+ import fs35 from "node:fs/promises";
196066
196370
  var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
196067
196371
  const { equal: equal2 } = await looksSame(buffer1, buffer2, {
196068
196372
  strict: false,
@@ -196078,7 +196382,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
196078
196382
  tolerance: 2
196079
196383
  });
196080
196384
  } else {
196081
- await fs34.writeFile(diffPath, buffer2);
196385
+ await fs35.writeFile(diffPath, buffer2);
196082
196386
  }
196083
196387
  }
196084
196388
  return { equal: equal2 };
@@ -196103,7 +196407,7 @@ var snapshotProject = async ({
196103
196407
  ...DEFAULT_IGNORED_PATTERNS,
196104
196408
  ...ignored.map(normalizeIgnorePattern)
196105
196409
  ];
196106
- const resolvedPaths = filePaths.map((f) => path33.resolve(projectDir, f));
196410
+ const resolvedPaths = filePaths.map((f) => path34.resolve(projectDir, f));
196107
196411
  const boardFiles = findBoardFiles({
196108
196412
  projectDir,
196109
196413
  ignore,
@@ -196117,7 +196421,7 @@ var snapshotProject = async ({
196117
196421
  const mismatches = [];
196118
196422
  let didUpdate = false;
196119
196423
  for (const file of boardFiles) {
196120
- const relativeFilePath = path33.relative(projectDir, file);
196424
+ const relativeFilePath = path34.relative(projectDir, file);
196121
196425
  let circuitJson;
196122
196426
  let pcbSvg;
196123
196427
  let schSvg;
@@ -196171,17 +196475,17 @@ var snapshotProject = async ({
196171
196475
  } catch (error) {
196172
196476
  const errorMessage = error instanceof Error ? error.message : String(error);
196173
196477
  if (errorMessage.includes("No pcb_board found in circuit JSON")) {
196174
- const fileDir = path33.dirname(file);
196175
- const relativeDir = path33.relative(projectDir, fileDir);
196176
- const snapDir2 = snapshotsDirName ? path33.join(projectDir, snapshotsDirName, relativeDir) : path33.join(fileDir, "__snapshots__");
196177
- const base2 = path33.basename(file).replace(/\.tsx$/, "");
196178
- const snap3dPath = path33.join(snapDir2, `${base2}-3d.snap.png`);
196179
- const existing3dSnapshot = fs35.existsSync(snap3dPath);
196478
+ const fileDir = path34.dirname(file);
196479
+ const relativeDir = path34.relative(projectDir, fileDir);
196480
+ const snapDir2 = snapshotsDirName ? path34.join(projectDir, snapshotsDirName, relativeDir) : path34.join(fileDir, "__snapshots__");
196481
+ const base2 = path34.basename(file).replace(/\.tsx$/, "");
196482
+ const snap3dPath = path34.join(snapDir2, `${base2}-3d.snap.png`);
196483
+ const existing3dSnapshot = fs36.existsSync(snap3dPath);
196180
196484
  if (existing3dSnapshot) {
196181
196485
  onError(kleur_default.red(`
196182
196486
  ❌ Failed to generate 3D snapshot for ${relativeFilePath}:
196183
196487
  `) + kleur_default.red(` No pcb_board found in circuit JSON
196184
- `) + kleur_default.red(` Existing snapshot: ${path33.relative(projectDir, snap3dPath)}
196488
+ `) + kleur_default.red(` Existing snapshot: ${path34.relative(projectDir, snap3dPath)}
196185
196489
  `));
196186
196490
  return onExit(1);
196187
196491
  } else {
@@ -196197,9 +196501,9 @@ var snapshotProject = async ({
196197
196501
  }
196198
196502
  }
196199
196503
  }
196200
- const snapDir = snapshotsDirName ? path33.join(projectDir, snapshotsDirName, path33.relative(projectDir, path33.dirname(file))) : path33.join(path33.dirname(file), "__snapshots__");
196201
- fs35.mkdirSync(snapDir, { recursive: true });
196202
- const base = path33.basename(file).replace(/\.tsx$/, "");
196504
+ const snapDir = snapshotsDirName ? path34.join(projectDir, snapshotsDirName, path34.relative(projectDir, path34.dirname(file))) : path34.join(path34.dirname(file), "__snapshots__");
196505
+ fs36.mkdirSync(snapDir, { recursive: true });
196506
+ const base = path34.basename(file).replace(/\.tsx$/, "");
196203
196507
  const snapshots = [];
196204
196508
  if (pcbOnly || !schematicOnly) {
196205
196509
  snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
@@ -196217,31 +196521,31 @@ var snapshotProject = async ({
196217
196521
  for (const snapshot of snapshots) {
196218
196522
  const { type } = snapshot;
196219
196523
  const is3d = type === "3d";
196220
- const snapPath = path33.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
196221
- const existing = fs35.existsSync(snapPath);
196524
+ const snapPath = path34.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
196525
+ const existing = fs36.existsSync(snapPath);
196222
196526
  const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
196223
196527
  const newContentForFile = snapshot.content;
196224
196528
  if (!existing) {
196225
- fs35.writeFileSync(snapPath, newContentForFile);
196226
- console.log("✅", kleur_default.gray(path33.relative(projectDir, snapPath)));
196529
+ fs36.writeFileSync(snapPath, newContentForFile);
196530
+ console.log("✅", kleur_default.gray(path34.relative(projectDir, snapPath)));
196227
196531
  didUpdate = true;
196228
196532
  continue;
196229
196533
  }
196230
- const oldContentBuffer = fs35.readFileSync(snapPath);
196534
+ const oldContentBuffer = fs36.readFileSync(snapPath);
196231
196535
  const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
196232
196536
  const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
196233
196537
  if (update) {
196234
196538
  if (!forceUpdate && equal2) {
196235
- console.log("✅", kleur_default.gray(path33.relative(projectDir, snapPath)));
196539
+ console.log("✅", kleur_default.gray(path34.relative(projectDir, snapPath)));
196236
196540
  } else {
196237
- fs35.writeFileSync(snapPath, newContentForFile);
196238
- console.log("✅", kleur_default.gray(path33.relative(projectDir, snapPath)));
196541
+ fs36.writeFileSync(snapPath, newContentForFile);
196542
+ console.log("✅", kleur_default.gray(path34.relative(projectDir, snapPath)));
196239
196543
  didUpdate = true;
196240
196544
  }
196241
196545
  } else if (!equal2) {
196242
196546
  mismatches.push(`${snapPath} (diff: ${diffPath})`);
196243
196547
  } else {
196244
- console.log("✅", kleur_default.gray(path33.relative(projectDir, snapPath)));
196548
+ console.log("✅", kleur_default.gray(path34.relative(projectDir, snapPath)));
196245
196549
  }
196246
196550
  }
196247
196551
  }
@@ -196280,22 +196584,22 @@ var registerSnapshot = (program3) => {
196280
196584
  };
196281
196585
 
196282
196586
  // lib/shared/setup-github-actions.ts
196283
- import fs36 from "node:fs";
196284
- import path34 from "node:path";
196587
+ import fs37 from "node:fs";
196588
+ import path35 from "node:path";
196285
196589
  var setupGithubActions = (projectDir = process.cwd()) => {
196286
196590
  const findGitRoot = (startDir) => {
196287
- let dir = path34.resolve(startDir);
196288
- while (dir !== path34.parse(dir).root) {
196289
- if (fs36.existsSync(path34.join(dir, ".git"))) {
196591
+ let dir = path35.resolve(startDir);
196592
+ while (dir !== path35.parse(dir).root) {
196593
+ if (fs37.existsSync(path35.join(dir, ".git"))) {
196290
196594
  return dir;
196291
196595
  }
196292
- dir = path34.dirname(dir);
196596
+ dir = path35.dirname(dir);
196293
196597
  }
196294
196598
  return null;
196295
196599
  };
196296
196600
  const gitRoot = findGitRoot(projectDir) ?? projectDir;
196297
- const workflowsDir = path34.join(gitRoot, ".github", "workflows");
196298
- fs36.mkdirSync(workflowsDir, { recursive: true });
196601
+ const workflowsDir = path35.join(gitRoot, ".github", "workflows");
196602
+ fs37.mkdirSync(workflowsDir, { recursive: true });
196299
196603
  const buildWorkflow = `name: tscircuit Build
196300
196604
 
196301
196605
  on:
@@ -196334,8 +196638,8 @@ jobs:
196334
196638
  - run: bun install
196335
196639
  - run: bunx tsci snapshot
196336
196640
  `;
196337
- writeFileIfNotExists(path34.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
196338
- writeFileIfNotExists(path34.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
196641
+ writeFileIfNotExists(path35.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
196642
+ writeFileIfNotExists(path35.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
196339
196643
  };
196340
196644
 
196341
196645
  // cli/setup/register.ts
@@ -196361,8 +196665,8 @@ var registerSetup = (program3) => {
196361
196665
  };
196362
196666
 
196363
196667
  // cli/convert/register.ts
196364
- import fs37 from "node:fs/promises";
196365
- import path35 from "node:path";
196668
+ import fs38 from "node:fs/promises";
196669
+ import path36 from "node:path";
196366
196670
  import { parseKicadModToCircuitJson } from "kicad-component-converter";
196367
196671
 
196368
196672
  // node_modules/@tscircuit/mm/dist/index.js
@@ -196482,15 +196786,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
196482
196786
  var registerConvert = (program3) => {
196483
196787
  program3.command("convert").description("Convert a .kicad_mod footprint to a tscircuit component").argument("<file>", "Path to the .kicad_mod file").option("-o, --output <path>", "Output TSX file path").option("-n, --name <component>", "Component name for export").action(async (file, options) => {
196484
196788
  try {
196485
- const inputPath = path35.resolve(file);
196486
- const modContent = await fs37.readFile(inputPath, "utf-8");
196789
+ const inputPath = path36.resolve(file);
196790
+ const modContent = await fs38.readFile(inputPath, "utf-8");
196487
196791
  const circuitJson = await parseKicadModToCircuitJson(modContent);
196488
- const componentName = options.name ?? path35.basename(inputPath, ".kicad_mod");
196792
+ const componentName = options.name ?? path36.basename(inputPath, ".kicad_mod");
196489
196793
  const tsx = convertCircuitJsonToTscircuit(circuitJson, {
196490
196794
  componentName
196491
196795
  });
196492
- const outputPath = options.output ? path35.resolve(options.output) : path35.join(path35.dirname(inputPath), `${componentName}.tsx`);
196493
- await fs37.writeFile(outputPath, tsx);
196796
+ const outputPath = options.output ? path36.resolve(options.output) : path36.join(path36.dirname(inputPath), `${componentName}.tsx`);
196797
+ await fs38.writeFile(outputPath, tsx);
196494
196798
  console.log(kleur_default.green(`Converted ${outputPath}`));
196495
196799
  } catch (error) {
196496
196800
  console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);