@tscircuit/cli 0.1.1250 → 0.1.1251

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 (3) hide show
  1. package/dist/cli/main.js +338 -338
  2. package/dist/lib/index.js +17506 -8256
  3. package/package.json +1 -1
package/dist/cli/main.js CHANGED
@@ -95346,18 +95346,18 @@ globstar while`, file, fr3, pattern, pr3, swallowee);
95346
95346
  abs = abs.replace(/\\/g, "/");
95347
95347
  return abs;
95348
95348
  }
95349
- function isIgnored(self2, path48) {
95349
+ function isIgnored(self2, path49) {
95350
95350
  if (!self2.ignore.length)
95351
95351
  return false;
95352
95352
  return self2.ignore.some(function(item) {
95353
- return item.matcher.match(path48) || !!(item.gmatcher && item.gmatcher.match(path48));
95353
+ return item.matcher.match(path49) || !!(item.gmatcher && item.gmatcher.match(path49));
95354
95354
  });
95355
95355
  }
95356
- function childrenIgnored(self2, path48) {
95356
+ function childrenIgnored(self2, path49) {
95357
95357
  if (!self2.ignore.length)
95358
95358
  return false;
95359
95359
  return self2.ignore.some(function(item) {
95360
- return !!(item.gmatcher && item.gmatcher.match(path48));
95360
+ return !!(item.gmatcher && item.gmatcher.match(path49));
95361
95361
  });
95362
95362
  }
95363
95363
  }
@@ -96388,8 +96388,8 @@ See: https://github.com/isaacs/node-glob/issues/167`);
96388
96388
  "node_modules/glob-promise/lib/index.js"(exports3, module22) {
96389
96389
  var glob2 = require_glob();
96390
96390
  var promise = function(pattern, options) {
96391
- return new Promise((resolve9, reject) => {
96392
- glob2(pattern, options, (err, files) => err === null ? resolve9(files) : reject(err));
96391
+ return new Promise((resolve10, reject) => {
96392
+ glob2(pattern, options, (err, files) => err === null ? resolve10(files) : reject(err));
96393
96393
  });
96394
96394
  };
96395
96395
  module22.exports = promise;
@@ -99964,7 +99964,7 @@ var import_perfect_cli = __toESM2(require_dist2(), 1);
99964
99964
  // lib/getVersion.ts
99965
99965
  import { createRequire as createRequire2 } from "node:module";
99966
99966
  // package.json
99967
- var version = "0.1.1249";
99967
+ var version = "0.1.1250";
99968
99968
  var package_default = {
99969
99969
  name: "@tscircuit/cli",
99970
99970
  version,
@@ -241656,9 +241656,64 @@ import * as fs51 from "node:fs";
241656
241656
  import * as net from "node:net";
241657
241657
  import * as path54 from "node:path";
241658
241658
 
241659
- // cli/dev/DevServer.ts
241660
- import fs49 from "node:fs";
241661
- import path52 from "node:path";
241659
+ // cli/dev/resolve-dev-target.ts
241660
+ import * as fs45 from "node:fs";
241661
+ import * as path47 from "node:path";
241662
+ var findSelectableFiles = (projectDir) => {
241663
+ const boardFiles = findBoardFiles({ projectDir }).filter((file) => fs45.existsSync(file)).sort();
241664
+ if (boardFiles.length > 0) {
241665
+ return boardFiles;
241666
+ }
241667
+ const files = globbySync(["**/*.tsx", "**/*.ts", "**/*.circuit.json"], {
241668
+ cwd: projectDir,
241669
+ ignore: DEFAULT_IGNORED_PATTERNS
241670
+ });
241671
+ return files.map((file) => path47.resolve(projectDir, file)).filter((file) => fs45.existsSync(file)).sort();
241672
+ };
241673
+ var isValidDevFile = (filePath) => {
241674
+ return filePath.endsWith(".tsx") || filePath.endsWith(".ts") || filePath.endsWith(".circuit.json");
241675
+ };
241676
+ var resolveDevTarget = async (file) => {
241677
+ let projectDir = process.cwd();
241678
+ if (file) {
241679
+ const resolvedPath = path47.resolve(file);
241680
+ if (fs45.existsSync(resolvedPath) && fs45.statSync(resolvedPath).isDirectory()) {
241681
+ projectDir = resolvedPath;
241682
+ const availableFiles2 = findSelectableFiles(projectDir);
241683
+ if (availableFiles2.length === 0) {
241684
+ console.log(`No .tsx, .ts, or .circuit.json files found in ${projectDir}. Run 'tsci init' to bootstrap a basic project.`);
241685
+ return null;
241686
+ }
241687
+ console.log("Selected file:", path47.relative(projectDir, availableFiles2[0]));
241688
+ return { absolutePath: availableFiles2[0], projectDir };
241689
+ }
241690
+ if (!fs45.existsSync(resolvedPath)) {
241691
+ console.error(`Error: File not found: ${file}`);
241692
+ return null;
241693
+ }
241694
+ if (!isValidDevFile(resolvedPath)) {
241695
+ console.error("Error: Only .tsx, .ts, and .circuit.json files are supported");
241696
+ return null;
241697
+ }
241698
+ return { absolutePath: resolvedPath, projectDir };
241699
+ }
241700
+ const entrypointPath = await getEntrypoint({ onError: () => {} });
241701
+ if (entrypointPath && fs45.existsSync(entrypointPath)) {
241702
+ console.log("Found entrypoint at:", entrypointPath);
241703
+ return { absolutePath: entrypointPath, projectDir };
241704
+ }
241705
+ const availableFiles = findSelectableFiles(projectDir);
241706
+ if (availableFiles.length === 0) {
241707
+ console.log("No .tsx, .ts, or .circuit.json files found in the project. Run 'tsci init' to bootstrap a basic project.");
241708
+ return null;
241709
+ }
241710
+ console.log("Selected file:", path47.relative(projectDir, availableFiles[0]));
241711
+ return { absolutePath: availableFiles[0], projectDir };
241712
+ };
241713
+
241714
+ // lib/dev/DevServer.ts
241715
+ import fs50 from "node:fs";
241716
+ import path53 from "node:path";
241662
241717
 
241663
241718
  // node_modules/chokidar/esm/index.js
241664
241719
  import { stat as statcb } from "fs";
@@ -241737,7 +241792,7 @@ class ReaddirpStream extends Readable {
241737
241792
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
241738
241793
  const statMethod = opts.lstat ? lstat : stat;
241739
241794
  if (wantBigintFsStats) {
241740
- this._stat = (path47) => statMethod(path47, { bigint: true });
241795
+ this._stat = (path48) => statMethod(path48, { bigint: true });
241741
241796
  } else {
241742
241797
  this._stat = statMethod;
241743
241798
  }
@@ -241762,8 +241817,8 @@ class ReaddirpStream extends Readable {
241762
241817
  const par = this.parent;
241763
241818
  const fil = par && par.files;
241764
241819
  if (fil && fil.length > 0) {
241765
- const { path: path47, depth } = par;
241766
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path47));
241820
+ const { path: path48, depth } = par;
241821
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path48));
241767
241822
  const awaited = await Promise.all(slice);
241768
241823
  for (const entry of awaited) {
241769
241824
  if (!entry)
@@ -241803,20 +241858,20 @@ class ReaddirpStream extends Readable {
241803
241858
  this.reading = false;
241804
241859
  }
241805
241860
  }
241806
- async _exploreDir(path47, depth) {
241861
+ async _exploreDir(path48, depth) {
241807
241862
  let files;
241808
241863
  try {
241809
- files = await readdir(path47, this._rdOptions);
241864
+ files = await readdir(path48, this._rdOptions);
241810
241865
  } catch (error) {
241811
241866
  this._onError(error);
241812
241867
  }
241813
- return { files, depth, path: path47 };
241868
+ return { files, depth, path: path48 };
241814
241869
  }
241815
- async _formatEntry(dirent, path47) {
241870
+ async _formatEntry(dirent, path48) {
241816
241871
  let entry;
241817
241872
  const basename4 = this._isDirent ? dirent.name : dirent;
241818
241873
  try {
241819
- const fullPath = presolve(pjoin(path47, basename4));
241874
+ const fullPath = presolve(pjoin(path48, basename4));
241820
241875
  entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
241821
241876
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
241822
241877
  } catch (err) {
@@ -242214,16 +242269,16 @@ var delFromSet = (main, prop, item) => {
242214
242269
  };
242215
242270
  var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
242216
242271
  var FsWatchInstances = new Map;
242217
- function createFsWatchInstance(path47, options, listener, errHandler, emitRaw) {
242272
+ function createFsWatchInstance(path48, options, listener, errHandler, emitRaw) {
242218
242273
  const handleEvent = (rawEvent, evPath) => {
242219
- listener(path47);
242220
- emitRaw(rawEvent, evPath, { watchedPath: path47 });
242221
- if (evPath && path47 !== evPath) {
242222
- fsWatchBroadcast(sysPath.resolve(path47, evPath), KEY_LISTENERS, sysPath.join(path47, evPath));
242274
+ listener(path48);
242275
+ emitRaw(rawEvent, evPath, { watchedPath: path48 });
242276
+ if (evPath && path48 !== evPath) {
242277
+ fsWatchBroadcast(sysPath.resolve(path48, evPath), KEY_LISTENERS, sysPath.join(path48, evPath));
242223
242278
  }
242224
242279
  };
242225
242280
  try {
242226
- return fs_watch(path47, {
242281
+ return fs_watch(path48, {
242227
242282
  persistent: options.persistent
242228
242283
  }, handleEvent);
242229
242284
  } catch (error) {
@@ -242239,12 +242294,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
242239
242294
  listener(val1, val2, val3);
242240
242295
  });
242241
242296
  };
242242
- var setFsWatchListener = (path47, fullPath, options, handlers) => {
242297
+ var setFsWatchListener = (path48, fullPath, options, handlers) => {
242243
242298
  const { listener, errHandler, rawEmitter } = handlers;
242244
242299
  let cont = FsWatchInstances.get(fullPath);
242245
242300
  let watcher;
242246
242301
  if (!options.persistent) {
242247
- watcher = createFsWatchInstance(path47, options, listener, errHandler, rawEmitter);
242302
+ watcher = createFsWatchInstance(path48, options, listener, errHandler, rawEmitter);
242248
242303
  if (!watcher)
242249
242304
  return;
242250
242305
  return watcher.close.bind(watcher);
@@ -242254,7 +242309,7 @@ var setFsWatchListener = (path47, fullPath, options, handlers) => {
242254
242309
  addAndConvert(cont, KEY_ERR, errHandler);
242255
242310
  addAndConvert(cont, KEY_RAW, rawEmitter);
242256
242311
  } else {
242257
- watcher = createFsWatchInstance(path47, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
242312
+ watcher = createFsWatchInstance(path48, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
242258
242313
  if (!watcher)
242259
242314
  return;
242260
242315
  watcher.on(EV.ERROR, async (error) => {
@@ -242263,7 +242318,7 @@ var setFsWatchListener = (path47, fullPath, options, handlers) => {
242263
242318
  cont.watcherUnusable = true;
242264
242319
  if (isWindows && error.code === "EPERM") {
242265
242320
  try {
242266
- const fd3 = await open(path47, "r");
242321
+ const fd3 = await open(path48, "r");
242267
242322
  await fd3.close();
242268
242323
  broadcastErr(error);
242269
242324
  } catch (err) {}
@@ -242293,7 +242348,7 @@ var setFsWatchListener = (path47, fullPath, options, handlers) => {
242293
242348
  };
242294
242349
  };
242295
242350
  var FsWatchFileInstances = new Map;
242296
- var setFsWatchFileListener = (path47, fullPath, options, handlers) => {
242351
+ var setFsWatchFileListener = (path48, fullPath, options, handlers) => {
242297
242352
  const { listener, rawEmitter } = handlers;
242298
242353
  let cont = FsWatchFileInstances.get(fullPath);
242299
242354
  const copts = cont && cont.options;
@@ -242315,7 +242370,7 @@ var setFsWatchFileListener = (path47, fullPath, options, handlers) => {
242315
242370
  });
242316
242371
  const currmtime = curr.mtimeMs;
242317
242372
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
242318
- foreach(cont.listeners, (listener2) => listener2(path47, curr));
242373
+ foreach(cont.listeners, (listener2) => listener2(path48, curr));
242319
242374
  }
242320
242375
  })
242321
242376
  };
@@ -242338,13 +242393,13 @@ class NodeFsHandler {
242338
242393
  this.fsw = fsW;
242339
242394
  this._boundHandleError = (error) => fsW._handleError(error);
242340
242395
  }
242341
- _watchWithNodeFs(path47, listener) {
242396
+ _watchWithNodeFs(path48, listener) {
242342
242397
  const opts = this.fsw.options;
242343
- const directory = sysPath.dirname(path47);
242344
- const basename5 = sysPath.basename(path47);
242398
+ const directory = sysPath.dirname(path48);
242399
+ const basename5 = sysPath.basename(path48);
242345
242400
  const parent = this.fsw._getWatchedDir(directory);
242346
242401
  parent.add(basename5);
242347
- const absolutePath = sysPath.resolve(path47);
242402
+ const absolutePath = sysPath.resolve(path48);
242348
242403
  const options = {
242349
242404
  persistent: opts.persistent
242350
242405
  };
@@ -242354,12 +242409,12 @@ class NodeFsHandler {
242354
242409
  if (opts.usePolling) {
242355
242410
  const enableBin = opts.interval !== opts.binaryInterval;
242356
242411
  options.interval = enableBin && isBinaryPath(basename5) ? opts.binaryInterval : opts.interval;
242357
- closer = setFsWatchFileListener(path47, absolutePath, options, {
242412
+ closer = setFsWatchFileListener(path48, absolutePath, options, {
242358
242413
  listener,
242359
242414
  rawEmitter: this.fsw._emitRaw
242360
242415
  });
242361
242416
  } else {
242362
- closer = setFsWatchListener(path47, absolutePath, options, {
242417
+ closer = setFsWatchListener(path48, absolutePath, options, {
242363
242418
  listener,
242364
242419
  errHandler: this._boundHandleError,
242365
242420
  rawEmitter: this.fsw._emitRaw
@@ -242377,7 +242432,7 @@ class NodeFsHandler {
242377
242432
  let prevStats = stats;
242378
242433
  if (parent.has(basename5))
242379
242434
  return;
242380
- const listener = async (path47, newStats) => {
242435
+ const listener = async (path48, newStats) => {
242381
242436
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
242382
242437
  return;
242383
242438
  if (!newStats || newStats.mtimeMs === 0) {
@@ -242391,11 +242446,11 @@ class NodeFsHandler {
242391
242446
  this.fsw._emit(EV.CHANGE, file, newStats2);
242392
242447
  }
242393
242448
  if ((isMacos || isLinux) && prevStats.ino !== newStats2.ino) {
242394
- this.fsw._closeFile(path47);
242449
+ this.fsw._closeFile(path48);
242395
242450
  prevStats = newStats2;
242396
242451
  const closer2 = this._watchWithNodeFs(file, listener);
242397
242452
  if (closer2)
242398
- this.fsw._addPathCloser(path47, closer2);
242453
+ this.fsw._addPathCloser(path48, closer2);
242399
242454
  } else {
242400
242455
  prevStats = newStats2;
242401
242456
  }
@@ -242419,7 +242474,7 @@ class NodeFsHandler {
242419
242474
  }
242420
242475
  return closer;
242421
242476
  }
242422
- async _handleSymlink(entry, directory, path47, item) {
242477
+ async _handleSymlink(entry, directory, path48, item) {
242423
242478
  if (this.fsw.closed) {
242424
242479
  return;
242425
242480
  }
@@ -242429,7 +242484,7 @@ class NodeFsHandler {
242429
242484
  this.fsw._incrReadyCount();
242430
242485
  let linkPath;
242431
242486
  try {
242432
- linkPath = await fsrealpath(path47);
242487
+ linkPath = await fsrealpath(path48);
242433
242488
  } catch (e4) {
242434
242489
  this.fsw._emitReady();
242435
242490
  return true;
@@ -242439,12 +242494,12 @@ class NodeFsHandler {
242439
242494
  if (dir.has(item)) {
242440
242495
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
242441
242496
  this.fsw._symlinkPaths.set(full, linkPath);
242442
- this.fsw._emit(EV.CHANGE, path47, entry.stats);
242497
+ this.fsw._emit(EV.CHANGE, path48, entry.stats);
242443
242498
  }
242444
242499
  } else {
242445
242500
  dir.add(item);
242446
242501
  this.fsw._symlinkPaths.set(full, linkPath);
242447
- this.fsw._emit(EV.ADD, path47, entry.stats);
242502
+ this.fsw._emit(EV.ADD, path48, entry.stats);
242448
242503
  }
242449
242504
  this.fsw._emitReady();
242450
242505
  return true;
@@ -242473,9 +242528,9 @@ class NodeFsHandler {
242473
242528
  return;
242474
242529
  }
242475
242530
  const item = entry.path;
242476
- let path47 = sysPath.join(directory, item);
242531
+ let path48 = sysPath.join(directory, item);
242477
242532
  current2.add(item);
242478
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path47, item)) {
242533
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path48, item)) {
242479
242534
  return;
242480
242535
  }
242481
242536
  if (this.fsw.closed) {
@@ -242484,11 +242539,11 @@ class NodeFsHandler {
242484
242539
  }
242485
242540
  if (item === target || !target && !previous.has(item)) {
242486
242541
  this.fsw._incrReadyCount();
242487
- path47 = sysPath.join(dir, sysPath.relative(dir, path47));
242488
- this._addToNodeFs(path47, initialAdd, wh3, depth + 1);
242542
+ path48 = sysPath.join(dir, sysPath.relative(dir, path48));
242543
+ this._addToNodeFs(path48, initialAdd, wh3, depth + 1);
242489
242544
  }
242490
242545
  }).on(EV.ERROR, this._boundHandleError);
242491
- return new Promise((resolve7, reject) => {
242546
+ return new Promise((resolve8, reject) => {
242492
242547
  if (!stream)
242493
242548
  return reject();
242494
242549
  stream.once(STR_END, () => {
@@ -242497,7 +242552,7 @@ class NodeFsHandler {
242497
242552
  return;
242498
242553
  }
242499
242554
  const wasThrottled = throttler ? throttler.clear() : false;
242500
- resolve7(undefined);
242555
+ resolve8(undefined);
242501
242556
  previous.getChildren().filter((item) => {
242502
242557
  return item !== directory && !current2.has(item);
242503
242558
  }).forEach((item) => {
@@ -242534,13 +242589,13 @@ class NodeFsHandler {
242534
242589
  }
242535
242590
  return closer;
242536
242591
  }
242537
- async _addToNodeFs(path47, initialAdd, priorWh, depth, target) {
242592
+ async _addToNodeFs(path48, initialAdd, priorWh, depth, target) {
242538
242593
  const ready = this.fsw._emitReady;
242539
- if (this.fsw._isIgnored(path47) || this.fsw.closed) {
242594
+ if (this.fsw._isIgnored(path48) || this.fsw.closed) {
242540
242595
  ready();
242541
242596
  return false;
242542
242597
  }
242543
- const wh3 = this.fsw._getWatchHelpers(path47);
242598
+ const wh3 = this.fsw._getWatchHelpers(path48);
242544
242599
  if (priorWh) {
242545
242600
  wh3.filterPath = (entry) => priorWh.filterPath(entry);
242546
242601
  wh3.filterDir = (entry) => priorWh.filterDir(entry);
@@ -242556,8 +242611,8 @@ class NodeFsHandler {
242556
242611
  const follow = this.fsw.options.followSymlinks;
242557
242612
  let closer;
242558
242613
  if (stats.isDirectory()) {
242559
- const absPath = sysPath.resolve(path47);
242560
- const targetPath = follow ? await fsrealpath(path47) : path47;
242614
+ const absPath = sysPath.resolve(path48);
242615
+ const targetPath = follow ? await fsrealpath(path48) : path48;
242561
242616
  if (this.fsw.closed)
242562
242617
  return;
242563
242618
  closer = await this._handleDir(wh3.watchPath, stats, initialAdd, depth, target, wh3, targetPath);
@@ -242567,29 +242622,29 @@ class NodeFsHandler {
242567
242622
  this.fsw._symlinkPaths.set(absPath, targetPath);
242568
242623
  }
242569
242624
  } else if (stats.isSymbolicLink()) {
242570
- const targetPath = follow ? await fsrealpath(path47) : path47;
242625
+ const targetPath = follow ? await fsrealpath(path48) : path48;
242571
242626
  if (this.fsw.closed)
242572
242627
  return;
242573
242628
  const parent = sysPath.dirname(wh3.watchPath);
242574
242629
  this.fsw._getWatchedDir(parent).add(wh3.watchPath);
242575
242630
  this.fsw._emit(EV.ADD, wh3.watchPath, stats);
242576
- closer = await this._handleDir(parent, stats, initialAdd, depth, path47, wh3, targetPath);
242631
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path48, wh3, targetPath);
242577
242632
  if (this.fsw.closed)
242578
242633
  return;
242579
242634
  if (targetPath !== undefined) {
242580
- this.fsw._symlinkPaths.set(sysPath.resolve(path47), targetPath);
242635
+ this.fsw._symlinkPaths.set(sysPath.resolve(path48), targetPath);
242581
242636
  }
242582
242637
  } else {
242583
242638
  closer = this._handleFile(wh3.watchPath, stats, initialAdd);
242584
242639
  }
242585
242640
  ready();
242586
242641
  if (closer)
242587
- this.fsw._addPathCloser(path47, closer);
242642
+ this.fsw._addPathCloser(path48, closer);
242588
242643
  return false;
242589
242644
  } catch (error) {
242590
242645
  if (this.fsw._handleError(error)) {
242591
242646
  ready();
242592
- return path47;
242647
+ return path48;
242593
242648
  }
242594
242649
  }
242595
242650
  }
@@ -242621,37 +242676,37 @@ function createPattern(matcher) {
242621
242676
  if (matcher.path === string)
242622
242677
  return true;
242623
242678
  if (matcher.recursive) {
242624
- const relative7 = sysPath2.relative(matcher.path, string);
242625
- if (!relative7) {
242679
+ const relative8 = sysPath2.relative(matcher.path, string);
242680
+ if (!relative8) {
242626
242681
  return false;
242627
242682
  }
242628
- return !relative7.startsWith("..") && !sysPath2.isAbsolute(relative7);
242683
+ return !relative8.startsWith("..") && !sysPath2.isAbsolute(relative8);
242629
242684
  }
242630
242685
  return false;
242631
242686
  };
242632
242687
  }
242633
242688
  return () => false;
242634
242689
  }
242635
- function normalizePath(path47) {
242636
- if (typeof path47 !== "string")
242690
+ function normalizePath(path48) {
242691
+ if (typeof path48 !== "string")
242637
242692
  throw new Error("string expected");
242638
- path47 = sysPath2.normalize(path47);
242639
- path47 = path47.replace(/\\/g, "/");
242693
+ path48 = sysPath2.normalize(path48);
242694
+ path48 = path48.replace(/\\/g, "/");
242640
242695
  let prepend2 = false;
242641
- if (path47.startsWith("//"))
242696
+ if (path48.startsWith("//"))
242642
242697
  prepend2 = true;
242643
242698
  const DOUBLE_SLASH_RE2 = /\/\//;
242644
- while (path47.match(DOUBLE_SLASH_RE2))
242645
- path47 = path47.replace(DOUBLE_SLASH_RE2, "/");
242699
+ while (path48.match(DOUBLE_SLASH_RE2))
242700
+ path48 = path48.replace(DOUBLE_SLASH_RE2, "/");
242646
242701
  if (prepend2)
242647
- path47 = "/" + path47;
242648
- return path47;
242702
+ path48 = "/" + path48;
242703
+ return path48;
242649
242704
  }
242650
242705
  function matchPatterns(patterns, testString, stats) {
242651
- const path47 = normalizePath(testString);
242706
+ const path48 = normalizePath(testString);
242652
242707
  for (let index = 0;index < patterns.length; index++) {
242653
242708
  const pattern = patterns[index];
242654
- if (pattern(path47, stats)) {
242709
+ if (pattern(path48, stats)) {
242655
242710
  return true;
242656
242711
  }
242657
242712
  }
@@ -242691,19 +242746,19 @@ var toUnix = (string) => {
242691
242746
  }
242692
242747
  return str;
242693
242748
  };
242694
- var normalizePathToUnix = (path47) => toUnix(sysPath2.normalize(toUnix(path47)));
242695
- var normalizeIgnored = (cwd = "") => (path47) => {
242696
- if (typeof path47 === "string") {
242697
- return normalizePathToUnix(sysPath2.isAbsolute(path47) ? path47 : sysPath2.join(cwd, path47));
242749
+ var normalizePathToUnix = (path48) => toUnix(sysPath2.normalize(toUnix(path48)));
242750
+ var normalizeIgnored = (cwd = "") => (path48) => {
242751
+ if (typeof path48 === "string") {
242752
+ return normalizePathToUnix(sysPath2.isAbsolute(path48) ? path48 : sysPath2.join(cwd, path48));
242698
242753
  } else {
242699
- return path47;
242754
+ return path48;
242700
242755
  }
242701
242756
  };
242702
- var getAbsolutePath = (path47, cwd) => {
242703
- if (sysPath2.isAbsolute(path47)) {
242704
- return path47;
242757
+ var getAbsolutePath = (path48, cwd) => {
242758
+ if (sysPath2.isAbsolute(path48)) {
242759
+ return path48;
242705
242760
  }
242706
- return sysPath2.join(cwd, path47);
242761
+ return sysPath2.join(cwd, path48);
242707
242762
  };
242708
242763
  var EMPTY_SET = Object.freeze(new Set);
242709
242764
 
@@ -242760,10 +242815,10 @@ var STAT_METHOD_F = "stat";
242760
242815
  var STAT_METHOD_L = "lstat";
242761
242816
 
242762
242817
  class WatchHelper {
242763
- constructor(path47, follow, fsw) {
242818
+ constructor(path48, follow, fsw) {
242764
242819
  this.fsw = fsw;
242765
- const watchPath = path47;
242766
- this.path = path47 = path47.replace(REPLACER_RE, "");
242820
+ const watchPath = path48;
242821
+ this.path = path48 = path48.replace(REPLACER_RE, "");
242767
242822
  this.watchPath = watchPath;
242768
242823
  this.fullWatchPath = sysPath2.resolve(watchPath);
242769
242824
  this.dirParts = [];
@@ -242876,20 +242931,20 @@ class FSWatcher extends EventEmitter {
242876
242931
  this._closePromise = undefined;
242877
242932
  let paths = unifyPaths(paths_);
242878
242933
  if (cwd) {
242879
- paths = paths.map((path47) => {
242880
- const absPath = getAbsolutePath(path47, cwd);
242934
+ paths = paths.map((path48) => {
242935
+ const absPath = getAbsolutePath(path48, cwd);
242881
242936
  return absPath;
242882
242937
  });
242883
242938
  }
242884
- paths.forEach((path47) => {
242885
- this._removeIgnoredPath(path47);
242939
+ paths.forEach((path48) => {
242940
+ this._removeIgnoredPath(path48);
242886
242941
  });
242887
242942
  this._userIgnored = undefined;
242888
242943
  if (!this._readyCount)
242889
242944
  this._readyCount = 0;
242890
242945
  this._readyCount += paths.length;
242891
- Promise.all(paths.map(async (path47) => {
242892
- const res2 = await this._nodeFsHandler._addToNodeFs(path47, !_internal, undefined, 0, _origAdd);
242946
+ Promise.all(paths.map(async (path48) => {
242947
+ const res2 = await this._nodeFsHandler._addToNodeFs(path48, !_internal, undefined, 0, _origAdd);
242893
242948
  if (res2)
242894
242949
  this._emitReady();
242895
242950
  return res2;
@@ -242908,17 +242963,17 @@ class FSWatcher extends EventEmitter {
242908
242963
  return this;
242909
242964
  const paths = unifyPaths(paths_);
242910
242965
  const { cwd } = this.options;
242911
- paths.forEach((path47) => {
242912
- if (!sysPath2.isAbsolute(path47) && !this._closers.has(path47)) {
242966
+ paths.forEach((path48) => {
242967
+ if (!sysPath2.isAbsolute(path48) && !this._closers.has(path48)) {
242913
242968
  if (cwd)
242914
- path47 = sysPath2.join(cwd, path47);
242915
- path47 = sysPath2.resolve(path47);
242969
+ path48 = sysPath2.join(cwd, path48);
242970
+ path48 = sysPath2.resolve(path48);
242916
242971
  }
242917
- this._closePath(path47);
242918
- this._addIgnoredPath(path47);
242919
- if (this._watched.has(path47)) {
242972
+ this._closePath(path48);
242973
+ this._addIgnoredPath(path48);
242974
+ if (this._watched.has(path48)) {
242920
242975
  this._addIgnoredPath({
242921
- path: path47,
242976
+ path: path48,
242922
242977
  recursive: true
242923
242978
  });
242924
242979
  }
@@ -242967,38 +243022,38 @@ class FSWatcher extends EventEmitter {
242967
243022
  if (event !== EVENTS.ERROR)
242968
243023
  this.emit(EVENTS.ALL, ...args);
242969
243024
  }
242970
- async _emit(event, path47, stats) {
243025
+ async _emit(event, path48, stats) {
242971
243026
  if (this.closed)
242972
243027
  return;
242973
243028
  const opts = this.options;
242974
243029
  if (isWindows)
242975
- path47 = sysPath2.normalize(path47);
243030
+ path48 = sysPath2.normalize(path48);
242976
243031
  if (opts.cwd)
242977
- path47 = sysPath2.relative(opts.cwd, path47);
242978
- const args = [event, path47];
243032
+ path48 = sysPath2.relative(opts.cwd, path48);
243033
+ const args = [event, path48];
242979
243034
  if (stats != null)
242980
243035
  args.push(stats);
242981
243036
  const awf = opts.awaitWriteFinish;
242982
243037
  let pw;
242983
- if (awf && (pw = this._pendingWrites.get(path47))) {
243038
+ if (awf && (pw = this._pendingWrites.get(path48))) {
242984
243039
  pw.lastChange = new Date;
242985
243040
  return this;
242986
243041
  }
242987
243042
  if (opts.atomic) {
242988
243043
  if (event === EVENTS.UNLINK) {
242989
- this._pendingUnlinks.set(path47, args);
243044
+ this._pendingUnlinks.set(path48, args);
242990
243045
  setTimeout(() => {
242991
- this._pendingUnlinks.forEach((entry, path48) => {
243046
+ this._pendingUnlinks.forEach((entry, path49) => {
242992
243047
  this.emit(...entry);
242993
243048
  this.emit(EVENTS.ALL, ...entry);
242994
- this._pendingUnlinks.delete(path48);
243049
+ this._pendingUnlinks.delete(path49);
242995
243050
  });
242996
243051
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
242997
243052
  return this;
242998
243053
  }
242999
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path47)) {
243054
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path48)) {
243000
243055
  event = args[0] = EVENTS.CHANGE;
243001
- this._pendingUnlinks.delete(path47);
243056
+ this._pendingUnlinks.delete(path48);
243002
243057
  }
243003
243058
  }
243004
243059
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -243016,16 +243071,16 @@ class FSWatcher extends EventEmitter {
243016
243071
  this.emitWithAll(event, args);
243017
243072
  }
243018
243073
  };
243019
- this._awaitWriteFinish(path47, awf.stabilityThreshold, event, awfEmit);
243074
+ this._awaitWriteFinish(path48, awf.stabilityThreshold, event, awfEmit);
243020
243075
  return this;
243021
243076
  }
243022
243077
  if (event === EVENTS.CHANGE) {
243023
- const isThrottled = !this._throttle(EVENTS.CHANGE, path47, 50);
243078
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path48, 50);
243024
243079
  if (isThrottled)
243025
243080
  return this;
243026
243081
  }
243027
243082
  if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
243028
- const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path47) : path47;
243083
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path48) : path48;
243029
243084
  let stats2;
243030
243085
  try {
243031
243086
  stats2 = await stat3(fullPath);
@@ -243044,23 +243099,23 @@ class FSWatcher extends EventEmitter {
243044
243099
  }
243045
243100
  return error || this.closed;
243046
243101
  }
243047
- _throttle(actionType, path47, timeout2) {
243102
+ _throttle(actionType, path48, timeout2) {
243048
243103
  if (!this._throttled.has(actionType)) {
243049
243104
  this._throttled.set(actionType, new Map);
243050
243105
  }
243051
243106
  const action = this._throttled.get(actionType);
243052
243107
  if (!action)
243053
243108
  throw new Error("invalid throttle");
243054
- const actionPath = action.get(path47);
243109
+ const actionPath = action.get(path48);
243055
243110
  if (actionPath) {
243056
243111
  actionPath.count++;
243057
243112
  return false;
243058
243113
  }
243059
243114
  let timeoutObject;
243060
243115
  const clear = () => {
243061
- const item = action.get(path47);
243116
+ const item = action.get(path48);
243062
243117
  const count = item ? item.count : 0;
243063
- action.delete(path47);
243118
+ action.delete(path48);
243064
243119
  clearTimeout(timeoutObject);
243065
243120
  if (item)
243066
243121
  clearTimeout(item.timeoutObject);
@@ -243068,50 +243123,50 @@ class FSWatcher extends EventEmitter {
243068
243123
  };
243069
243124
  timeoutObject = setTimeout(clear, timeout2);
243070
243125
  const thr = { timeoutObject, clear, count: 0 };
243071
- action.set(path47, thr);
243126
+ action.set(path48, thr);
243072
243127
  return thr;
243073
243128
  }
243074
243129
  _incrReadyCount() {
243075
243130
  return this._readyCount++;
243076
243131
  }
243077
- _awaitWriteFinish(path47, threshold, event, awfEmit) {
243132
+ _awaitWriteFinish(path48, threshold, event, awfEmit) {
243078
243133
  const awf = this.options.awaitWriteFinish;
243079
243134
  if (typeof awf !== "object")
243080
243135
  return;
243081
243136
  const pollInterval = awf.pollInterval;
243082
243137
  let timeoutHandler;
243083
- let fullPath = path47;
243084
- if (this.options.cwd && !sysPath2.isAbsolute(path47)) {
243085
- fullPath = sysPath2.join(this.options.cwd, path47);
243138
+ let fullPath = path48;
243139
+ if (this.options.cwd && !sysPath2.isAbsolute(path48)) {
243140
+ fullPath = sysPath2.join(this.options.cwd, path48);
243086
243141
  }
243087
243142
  const now = new Date;
243088
243143
  const writes = this._pendingWrites;
243089
243144
  function awaitWriteFinishFn(prevStat) {
243090
243145
  statcb(fullPath, (err, curStat) => {
243091
- if (err || !writes.has(path47)) {
243146
+ if (err || !writes.has(path48)) {
243092
243147
  if (err && err.code !== "ENOENT")
243093
243148
  awfEmit(err);
243094
243149
  return;
243095
243150
  }
243096
243151
  const now2 = Number(new Date);
243097
243152
  if (prevStat && curStat.size !== prevStat.size) {
243098
- writes.get(path47).lastChange = now2;
243153
+ writes.get(path48).lastChange = now2;
243099
243154
  }
243100
- const pw = writes.get(path47);
243155
+ const pw = writes.get(path48);
243101
243156
  const df3 = now2 - pw.lastChange;
243102
243157
  if (df3 >= threshold) {
243103
- writes.delete(path47);
243158
+ writes.delete(path48);
243104
243159
  awfEmit(undefined, curStat);
243105
243160
  } else {
243106
243161
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
243107
243162
  }
243108
243163
  });
243109
243164
  }
243110
- if (!writes.has(path47)) {
243111
- writes.set(path47, {
243165
+ if (!writes.has(path48)) {
243166
+ writes.set(path48, {
243112
243167
  lastChange: now,
243113
243168
  cancelWait: () => {
243114
- writes.delete(path47);
243169
+ writes.delete(path48);
243115
243170
  clearTimeout(timeoutHandler);
243116
243171
  return event;
243117
243172
  }
@@ -243119,8 +243174,8 @@ class FSWatcher extends EventEmitter {
243119
243174
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
243120
243175
  }
243121
243176
  }
243122
- _isIgnored(path47, stats) {
243123
- if (this.options.atomic && DOT_RE.test(path47))
243177
+ _isIgnored(path48, stats) {
243178
+ if (this.options.atomic && DOT_RE.test(path48))
243124
243179
  return true;
243125
243180
  if (!this._userIgnored) {
243126
243181
  const { cwd } = this.options;
@@ -243130,13 +243185,13 @@ class FSWatcher extends EventEmitter {
243130
243185
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
243131
243186
  this._userIgnored = anymatch(list, undefined);
243132
243187
  }
243133
- return this._userIgnored(path47, stats);
243188
+ return this._userIgnored(path48, stats);
243134
243189
  }
243135
- _isntIgnored(path47, stat4) {
243136
- return !this._isIgnored(path47, stat4);
243190
+ _isntIgnored(path48, stat4) {
243191
+ return !this._isIgnored(path48, stat4);
243137
243192
  }
243138
- _getWatchHelpers(path47) {
243139
- return new WatchHelper(path47, this.options.followSymlinks, this);
243193
+ _getWatchHelpers(path48) {
243194
+ return new WatchHelper(path48, this.options.followSymlinks, this);
243140
243195
  }
243141
243196
  _getWatchedDir(directory) {
243142
243197
  const dir = sysPath2.resolve(directory);
@@ -243150,57 +243205,57 @@ class FSWatcher extends EventEmitter {
243150
243205
  return Boolean(Number(stats.mode) & 256);
243151
243206
  }
243152
243207
  _remove(directory, item, isDirectory2) {
243153
- const path47 = sysPath2.join(directory, item);
243154
- const fullPath = sysPath2.resolve(path47);
243155
- isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(path47) || this._watched.has(fullPath);
243156
- if (!this._throttle("remove", path47, 100))
243208
+ const path48 = sysPath2.join(directory, item);
243209
+ const fullPath = sysPath2.resolve(path48);
243210
+ isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(path48) || this._watched.has(fullPath);
243211
+ if (!this._throttle("remove", path48, 100))
243157
243212
  return;
243158
243213
  if (!isDirectory2 && this._watched.size === 1) {
243159
243214
  this.add(directory, item, true);
243160
243215
  }
243161
- const wp3 = this._getWatchedDir(path47);
243216
+ const wp3 = this._getWatchedDir(path48);
243162
243217
  const nestedDirectoryChildren = wp3.getChildren();
243163
- nestedDirectoryChildren.forEach((nested) => this._remove(path47, nested));
243218
+ nestedDirectoryChildren.forEach((nested) => this._remove(path48, nested));
243164
243219
  const parent = this._getWatchedDir(directory);
243165
243220
  const wasTracked = parent.has(item);
243166
243221
  parent.remove(item);
243167
243222
  if (this._symlinkPaths.has(fullPath)) {
243168
243223
  this._symlinkPaths.delete(fullPath);
243169
243224
  }
243170
- let relPath = path47;
243225
+ let relPath = path48;
243171
243226
  if (this.options.cwd)
243172
- relPath = sysPath2.relative(this.options.cwd, path47);
243227
+ relPath = sysPath2.relative(this.options.cwd, path48);
243173
243228
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
243174
243229
  const event = this._pendingWrites.get(relPath).cancelWait();
243175
243230
  if (event === EVENTS.ADD)
243176
243231
  return;
243177
243232
  }
243178
- this._watched.delete(path47);
243233
+ this._watched.delete(path48);
243179
243234
  this._watched.delete(fullPath);
243180
243235
  const eventName = isDirectory2 ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
243181
- if (wasTracked && !this._isIgnored(path47))
243182
- this._emit(eventName, path47);
243183
- this._closePath(path47);
243236
+ if (wasTracked && !this._isIgnored(path48))
243237
+ this._emit(eventName, path48);
243238
+ this._closePath(path48);
243184
243239
  }
243185
- _closePath(path47) {
243186
- this._closeFile(path47);
243187
- const dir = sysPath2.dirname(path47);
243188
- this._getWatchedDir(dir).remove(sysPath2.basename(path47));
243240
+ _closePath(path48) {
243241
+ this._closeFile(path48);
243242
+ const dir = sysPath2.dirname(path48);
243243
+ this._getWatchedDir(dir).remove(sysPath2.basename(path48));
243189
243244
  }
243190
- _closeFile(path47) {
243191
- const closers = this._closers.get(path47);
243245
+ _closeFile(path48) {
243246
+ const closers = this._closers.get(path48);
243192
243247
  if (!closers)
243193
243248
  return;
243194
243249
  closers.forEach((closer) => closer());
243195
- this._closers.delete(path47);
243250
+ this._closers.delete(path48);
243196
243251
  }
243197
- _addPathCloser(path47, closer) {
243252
+ _addPathCloser(path48, closer) {
243198
243253
  if (!closer)
243199
243254
  return;
243200
- let list = this._closers.get(path47);
243255
+ let list = this._closers.get(path48);
243201
243256
  if (!list) {
243202
243257
  list = [];
243203
- this._closers.set(path47, list);
243258
+ this._closers.set(path48, list);
243204
243259
  }
243205
243260
  list.push(closer);
243206
243261
  }
@@ -243228,21 +243283,21 @@ function watch(paths, options = {}) {
243228
243283
  return watcher;
243229
243284
  }
243230
243285
 
243231
- // cli/dev/DevServer.ts
243286
+ // lib/dev/DevServer.ts
243232
243287
  import Debug3 from "debug";
243233
243288
 
243234
243289
  // lib/dependency-analysis/getNodeModuleDependencies.ts
243235
243290
  import * as ts3 from "typescript";
243236
- import * as path47 from "path";
243237
- import * as fs45 from "fs";
243291
+ import * as path48 from "path";
243292
+ import * as fs46 from "fs";
243238
243293
  function getAllDependencyPackages(projectDir) {
243239
- const packageJsonPath = path47.join(projectDir, "package.json");
243294
+ const packageJsonPath = path48.join(projectDir, "package.json");
243240
243295
  const allPackages = new Set;
243241
- if (!fs45.existsSync(packageJsonPath)) {
243296
+ if (!fs46.existsSync(packageJsonPath)) {
243242
243297
  return allPackages;
243243
243298
  }
243244
243299
  try {
243245
- const packageJson = JSON.parse(fs45.readFileSync(packageJsonPath, "utf-8"));
243300
+ const packageJson = JSON.parse(fs46.readFileSync(packageJsonPath, "utf-8"));
243246
243301
  const deps = packageJson.dependencies || {};
243247
243302
  const devDeps = packageJson.devDependencies || {};
243248
243303
  for (const packageName of Object.keys(deps)) {
@@ -243257,11 +243312,11 @@ function getAllDependencyPackages(projectDir) {
243257
243312
  return allPackages;
243258
243313
  }
243259
243314
  function getNodeModuleImports(filePath) {
243260
- const absolutePath = path47.resolve(filePath);
243261
- if (!fs45.existsSync(absolutePath)) {
243315
+ const absolutePath = path48.resolve(filePath);
243316
+ if (!fs46.existsSync(absolutePath)) {
243262
243317
  return [];
243263
243318
  }
243264
- const content = fs45.readFileSync(absolutePath, "utf-8");
243319
+ const content = fs46.readFileSync(absolutePath, "utf-8");
243265
243320
  const sourceFile = ts3.createSourceFile(absolutePath, content, ts3.ScriptTarget.Latest, true);
243266
243321
  const imports = new Set;
243267
243322
  function visit(node) {
@@ -243311,17 +243366,17 @@ function resolveNodeModuleImport({
243311
243366
  }) {
243312
243367
  const packageName = getPackageNameFromImport(importPath);
243313
243368
  const searchPaths = [
243314
- path47.join(projectDir, "node_modules", packageName)
243369
+ path48.join(projectDir, "node_modules", packageName)
243315
243370
  ];
243316
243371
  if (searchFromDir) {
243317
- let currentDir = path47.dirname(searchFromDir);
243318
- const projectDirNormalized = path47.normalize(projectDir);
243372
+ let currentDir = path48.dirname(searchFromDir);
243373
+ const projectDirNormalized = path48.normalize(projectDir);
243319
243374
  while (currentDir.startsWith(projectDirNormalized)) {
243320
- const candidatePath = path47.join(currentDir, "node_modules", packageName);
243375
+ const candidatePath = path48.join(currentDir, "node_modules", packageName);
243321
243376
  if (!searchPaths.includes(candidatePath)) {
243322
243377
  searchPaths.push(candidatePath);
243323
243378
  }
243324
- const parentDir = path47.dirname(currentDir);
243379
+ const parentDir = path48.dirname(currentDir);
243325
243380
  if (parentDir === currentDir)
243326
243381
  break;
243327
243382
  currentDir = parentDir;
@@ -243329,7 +243384,7 @@ function resolveNodeModuleImport({
243329
243384
  }
243330
243385
  let packageDir;
243331
243386
  for (const candidatePath of searchPaths) {
243332
- if (fs45.existsSync(candidatePath)) {
243387
+ if (fs46.existsSync(candidatePath)) {
243333
243388
  packageDir = candidatePath;
243334
243389
  break;
243335
243390
  }
@@ -243337,25 +243392,25 @@ function resolveNodeModuleImport({
243337
243392
  if (!packageDir) {
243338
243393
  return [];
243339
243394
  }
243340
- const packageJsonPath = path47.join(packageDir, "package.json");
243341
- const hasPackageJson = fs45.existsSync(packageJsonPath);
243342
- const packageJson = hasPackageJson ? JSON.parse(fs45.readFileSync(packageJsonPath, "utf-8")) : null;
243395
+ const packageJsonPath = path48.join(packageDir, "package.json");
243396
+ const hasPackageJson = fs46.existsSync(packageJsonPath);
243397
+ const packageJson = hasPackageJson ? JSON.parse(fs46.readFileSync(packageJsonPath, "utf-8")) : null;
243343
243398
  const resolvedFiles = [];
243344
243399
  if (importPath !== packageName) {
243345
243400
  const subpath = importPath.slice(packageName.length + 1);
243346
243401
  const possiblePaths = [
243347
- path47.join(packageDir, subpath),
243348
- path47.join(packageDir, `${subpath}.js`),
243349
- path47.join(packageDir, `${subpath}.mjs`),
243350
- path47.join(packageDir, `${subpath}.ts`),
243351
- path47.join(packageDir, `${subpath}.tsx`),
243352
- path47.join(packageDir, subpath, "index.js"),
243353
- path47.join(packageDir, subpath, "index.mjs"),
243354
- path47.join(packageDir, subpath, "index.ts"),
243355
- path47.join(packageDir, subpath, "index.tsx")
243402
+ path48.join(packageDir, subpath),
243403
+ path48.join(packageDir, `${subpath}.js`),
243404
+ path48.join(packageDir, `${subpath}.mjs`),
243405
+ path48.join(packageDir, `${subpath}.ts`),
243406
+ path48.join(packageDir, `${subpath}.tsx`),
243407
+ path48.join(packageDir, subpath, "index.js"),
243408
+ path48.join(packageDir, subpath, "index.mjs"),
243409
+ path48.join(packageDir, subpath, "index.ts"),
243410
+ path48.join(packageDir, subpath, "index.tsx")
243356
243411
  ];
243357
243412
  for (const p3 of possiblePaths) {
243358
- if (fs45.existsSync(p3) && fs45.statSync(p3).isFile()) {
243413
+ if (fs46.existsSync(p3) && fs46.statSync(p3).isFile()) {
243359
243414
  resolvedFiles.push(p3);
243360
243415
  break;
243361
243416
  }
@@ -243387,25 +243442,25 @@ function resolveNodeModuleImport({
243387
243442
  resolveExportValue(packageJson.exports?.["."]?.require)
243388
243443
  ].filter((entry) => typeof entry === "string");
243389
243444
  for (const entry of entryPoints) {
243390
- const entryPath = path47.join(packageDir, entry);
243391
- if (fs45.existsSync(entryPath) && fs45.statSync(entryPath).isFile()) {
243445
+ const entryPath = path48.join(packageDir, entry);
243446
+ if (fs46.existsSync(entryPath) && fs46.statSync(entryPath).isFile()) {
243392
243447
  resolvedFiles.push(entryPath);
243393
243448
  }
243394
243449
  }
243395
243450
  if (resolvedFiles.length === 0) {
243396
243451
  const fallbackPaths = [
243397
- path47.join(packageDir, "index.js"),
243398
- path47.join(packageDir, "index.mjs"),
243399
- path47.join(packageDir, "index.ts"),
243400
- path47.join(packageDir, "index.tsx"),
243401
- path47.join(packageDir, "dist", "index.js"),
243402
- path47.join(packageDir, "dist", "index.mjs"),
243403
- path47.join(packageDir, "lib", "index.js"),
243404
- path47.join(packageDir, "src", "index.ts"),
243405
- path47.join(packageDir, "src", "index.tsx")
243452
+ path48.join(packageDir, "index.js"),
243453
+ path48.join(packageDir, "index.mjs"),
243454
+ path48.join(packageDir, "index.ts"),
243455
+ path48.join(packageDir, "index.tsx"),
243456
+ path48.join(packageDir, "dist", "index.js"),
243457
+ path48.join(packageDir, "dist", "index.mjs"),
243458
+ path48.join(packageDir, "lib", "index.js"),
243459
+ path48.join(packageDir, "src", "index.ts"),
243460
+ path48.join(packageDir, "src", "index.tsx")
243406
243461
  ];
243407
243462
  for (const p3 of fallbackPaths) {
243408
- if (fs45.existsSync(p3) && fs45.statSync(p3).isFile()) {
243463
+ if (fs46.existsSync(p3) && fs46.statSync(p3).isFile()) {
243409
243464
  resolvedFiles.push(p3);
243410
243465
  break;
243411
243466
  }
@@ -243443,12 +243498,12 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
243443
243498
  }
243444
243499
  }
243445
243500
  function getLocalDependencies(filePath) {
243446
- const absolutePath = path47.resolve(filePath);
243447
- const baseDir = path47.dirname(absolutePath);
243448
- if (!fs45.existsSync(absolutePath)) {
243501
+ const absolutePath = path48.resolve(filePath);
243502
+ const baseDir = path48.dirname(absolutePath);
243503
+ if (!fs46.existsSync(absolutePath)) {
243449
243504
  return [];
243450
243505
  }
243451
- const content = fs45.readFileSync(absolutePath, "utf-8");
243506
+ const content = fs46.readFileSync(absolutePath, "utf-8");
243452
243507
  const sourceFile = ts3.createSourceFile(absolutePath, content, ts3.ScriptTarget.Latest, true);
243453
243508
  const dependencies = [];
243454
243509
  function visit(node) {
@@ -243470,20 +243525,20 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
243470
243525
  }
243471
243526
  function resolveLocalImport(importPath, baseDir) {
243472
243527
  const extensions = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
243473
- const resolvedPath = path47.resolve(baseDir, importPath);
243474
- if (fs45.existsSync(resolvedPath) && fs45.statSync(resolvedPath).isFile()) {
243528
+ const resolvedPath = path48.resolve(baseDir, importPath);
243529
+ if (fs46.existsSync(resolvedPath) && fs46.statSync(resolvedPath).isFile()) {
243475
243530
  return resolvedPath;
243476
243531
  }
243477
243532
  for (const ext of extensions) {
243478
243533
  const pathWithExt = resolvedPath + ext;
243479
- if (fs45.existsSync(pathWithExt)) {
243534
+ if (fs46.existsSync(pathWithExt)) {
243480
243535
  return pathWithExt;
243481
243536
  }
243482
243537
  }
243483
- if (fs45.existsSync(resolvedPath) && fs45.statSync(resolvedPath).isDirectory()) {
243538
+ if (fs46.existsSync(resolvedPath) && fs46.statSync(resolvedPath).isDirectory()) {
243484
243539
  for (const ext of extensions) {
243485
- const indexPath = path47.join(resolvedPath, `index${ext}`);
243486
- if (fs45.existsSync(indexPath)) {
243540
+ const indexPath = path48.join(resolvedPath, `index${ext}`);
243541
+ if (fs46.existsSync(indexPath)) {
243487
243542
  return indexPath;
243488
243543
  }
243489
243544
  }
@@ -243508,12 +243563,12 @@ var EXCLUDED_PACKAGE_DIRECTORIES = new Set([
243508
243563
  function collectLocalPackageFiles(packageDir) {
243509
243564
  const buildDirs = ["dist", "build"];
243510
243565
  for (const dirName of buildDirs) {
243511
- const dirPath = path47.join(packageDir, dirName);
243512
- if (fs45.existsSync(dirPath)) {
243566
+ const dirPath = path48.join(packageDir, dirName);
243567
+ if (fs46.existsSync(dirPath)) {
243513
243568
  const files = walkDirectory(dirPath, new Set);
243514
243569
  if (files.length > 0) {
243515
- const packageJsonPath = path47.join(packageDir, "package.json");
243516
- if (fs45.existsSync(packageJsonPath)) {
243570
+ const packageJsonPath = path48.join(packageDir, "package.json");
243571
+ if (fs46.existsSync(packageJsonPath)) {
243517
243572
  files.push(packageJsonPath);
243518
243573
  }
243519
243574
  return files;
@@ -243524,11 +243579,11 @@ function collectLocalPackageFiles(packageDir) {
243524
243579
  }
243525
243580
  function walkDirectory(dir, excludedDirs) {
243526
243581
  const files = [];
243527
- if (!fs45.existsSync(dir))
243582
+ if (!fs46.existsSync(dir))
243528
243583
  return files;
243529
- const entries = fs45.readdirSync(dir, { withFileTypes: true });
243584
+ const entries = fs46.readdirSync(dir, { withFileTypes: true });
243530
243585
  for (const entry of entries) {
243531
- const fullPath = path47.join(dir, entry.name);
243586
+ const fullPath = path48.join(dir, entry.name);
243532
243587
  if (entry.isDirectory()) {
243533
243588
  if (excludedDirs.has(entry.name)) {
243534
243589
  continue;
@@ -243589,13 +243644,13 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
243589
243644
  processedPackages.add(packageName);
243590
243645
  if (resolvedFiles.length > 0) {
243591
243646
  const firstResolvedFile = resolvedFiles[0];
243592
- let packageDir = path47.dirname(firstResolvedFile);
243647
+ let packageDir = path48.dirname(firstResolvedFile);
243593
243648
  let hasPackageJson = false;
243594
243649
  while (packageDir.includes("node_modules")) {
243595
- const packageJsonPath = path47.join(packageDir, "package.json");
243596
- if (fs45.existsSync(packageJsonPath)) {
243650
+ const packageJsonPath = path48.join(packageDir, "package.json");
243651
+ if (fs46.existsSync(packageJsonPath)) {
243597
243652
  try {
243598
- const pkgJson = JSON.parse(fs45.readFileSync(packageJsonPath, "utf-8"));
243653
+ const pkgJson = JSON.parse(fs46.readFileSync(packageJsonPath, "utf-8"));
243599
243654
  if (pkgJson.name === packageName) {
243600
243655
  hasPackageJson = true;
243601
243656
  break;
@@ -243603,15 +243658,15 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
243603
243658
  } catch {}
243604
243659
  }
243605
243660
  const expectedPackagePath = packageName.startsWith("@") ? `node_modules/${packageName}` : `node_modules/${packageName}`;
243606
- if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g, path47.sep))) {
243661
+ if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g, path48.sep))) {
243607
243662
  break;
243608
243663
  }
243609
- const parentDir = path47.dirname(packageDir);
243664
+ const parentDir = path48.dirname(packageDir);
243610
243665
  if (parentDir === packageDir)
243611
243666
  break;
243612
243667
  packageDir = parentDir;
243613
243668
  }
243614
- if (fs45.existsSync(packageDir)) {
243669
+ if (fs46.existsSync(packageDir)) {
243615
243670
  if (hasPackageJson) {
243616
243671
  const packageFiles = collectLocalPackageFiles(packageDir);
243617
243672
  packageFiles.forEach((file) => allFiles.add(file));
@@ -243677,7 +243732,7 @@ class EventsWatcher extends EventEmitter2 {
243677
243732
  }
243678
243733
 
243679
243734
  // lib/server/createHttpServer.ts
243680
- import * as fs47 from "node:fs";
243735
+ import * as fs48 from "node:fs";
243681
243736
  import * as http from "node:http";
243682
243737
 
243683
243738
  // node_modules/winterspec/dist/edge/transform-to-node.js
@@ -244380,10 +244435,10 @@ var databaseSchema = z7.object({
244380
244435
  files: z7.array(fileSchema).default([]),
244381
244436
  events: z7.array(eventSchema).default([])
244382
244437
  });
244383
- function normalizePath2(path48) {
244384
- if (!path48 || path48 === "/")
244438
+ function normalizePath2(path49) {
244439
+ if (!path49 || path49 === "/")
244385
244440
  return "";
244386
- let normalized = path48.replace(/\\+/g, "/").replace(/\/\/+/, "/");
244441
+ let normalized = path49.replace(/\\+/g, "/").replace(/\/\/+/, "/");
244387
244442
  if (normalized.startsWith("/")) {
244388
244443
  normalized = normalized.slice(1);
244389
244444
  }
@@ -245240,14 +245295,14 @@ var getIndex = async (mainComponentPath, fileServerApiBaseUrl) => {
245240
245295
  };
245241
245296
 
245242
245297
  // lib/server/kicad-pcm-proxy.ts
245243
- import * as fs46 from "node:fs";
245244
- import * as path48 from "node:path";
245298
+ import * as fs47 from "node:fs";
245299
+ import * as path49 from "node:path";
245245
245300
  var getSourceFilesChecksum = (projectDir) => {
245246
245301
  const sourceFiles = globbySync(["**/*.tsx", "**/*.ts", "**/*.json", "!node_modules/**", "!dist/**"], { cwd: projectDir });
245247
245302
  let checksum = "";
245248
245303
  for (const file of sourceFiles) {
245249
245304
  try {
245250
- const stat4 = fs46.statSync(path48.join(projectDir, file));
245305
+ const stat4 = fs47.statSync(path49.join(projectDir, file));
245251
245306
  checksum += `${file}:${stat4.mtimeMs};`;
245252
245307
  } catch {}
245253
245308
  }
@@ -245267,9 +245322,9 @@ var createKicadPcmProxy = ({
245267
245322
  };
245268
245323
  const handleRequest = async (url2, res2) => {
245269
245324
  const requestedFile = url2.pathname.replace(/^\/pcm\/?/, "") || "repository.json";
245270
- const distDir = path48.join(projectDir, "dist");
245271
- const pcmDir = path48.join(distDir, "pcm");
245272
- const filePath = path48.join(pcmDir, requestedFile);
245325
+ const distDir = path49.join(projectDir, "dist");
245326
+ const pcmDir = path49.join(distDir, "pcm");
245327
+ const filePath = path49.join(pcmDir, requestedFile);
245273
245328
  const currentChecksum = getSourceFilesChecksum(projectDir);
245274
245329
  const needsRebuild = currentChecksum !== pcmState.lastFileChecksum;
245275
245330
  if (needsRebuild) {
@@ -245314,12 +245369,12 @@ Rebuilding KiCad PCM assets...`));
245314
245369
  }
245315
245370
  }
245316
245371
  }
245317
- if (!fs46.existsSync(filePath)) {
245372
+ if (!fs47.existsSync(filePath)) {
245318
245373
  res2.writeHead(404);
245319
245374
  res2.end(`PCM file not found: ${requestedFile}`);
245320
245375
  return;
245321
245376
  }
245322
- const ext = path48.extname(filePath).toLowerCase();
245377
+ const ext = path49.extname(filePath).toLowerCase();
245323
245378
  let contentType = "application/octet-stream";
245324
245379
  if (ext === ".json") {
245325
245380
  contentType = "application/json";
@@ -245327,7 +245382,7 @@ Rebuilding KiCad PCM assets...`));
245327
245382
  contentType = "application/zip";
245328
245383
  }
245329
245384
  try {
245330
- const content = fs46.readFileSync(filePath);
245385
+ const content = fs47.readFileSync(filePath);
245331
245386
  res2.writeHead(200, { "Content-Type": contentType });
245332
245387
  res2.end(content);
245333
245388
  } catch (error) {
@@ -245407,7 +245462,7 @@ var createHttpServer = async ({
245407
245462
  return;
245408
245463
  }
245409
245464
  try {
245410
- const content = fs47.readFileSync(standaloneFilePath, "utf8");
245465
+ const content = fs48.readFileSync(standaloneFilePath, "utf8");
245411
245466
  res2.writeHead(200, {
245412
245467
  "Content-Type": "application/javascript; charset=utf-8"
245413
245468
  });
@@ -245441,17 +245496,17 @@ var createHttpServer = async ({
245441
245496
  res2.writeHead(404);
245442
245497
  res2.end("Not found");
245443
245498
  });
245444
- return new Promise((resolve9) => {
245499
+ return new Promise((resolve10) => {
245445
245500
  server.listen(port, () => {
245446
- resolve9({ server });
245501
+ resolve10({ server });
245447
245502
  });
245448
245503
  });
245449
245504
  };
245450
245505
 
245451
245506
  // lib/shared/push-snippet.ts
245452
245507
  var import_semver3 = __toESM2(require_semver2(), 1);
245453
- import * as fs48 from "node:fs";
245454
- import * as path51 from "node:path";
245508
+ import * as fs49 from "node:fs";
245509
+ import * as path52 from "node:path";
245455
245510
  import Debug2 from "debug";
245456
245511
 
245457
245512
  // lib/utils/validate-package-name.ts
@@ -245468,8 +245523,8 @@ var validatePackageName = (name) => {
245468
245523
  return null;
245469
245524
  };
245470
245525
 
245471
- // cli/dev/get-package-file-paths.ts
245472
- import * as path49 from "node:path";
245526
+ // lib/dev/get-package-file-paths.ts
245527
+ import * as path50 from "node:path";
245473
245528
  var getPackageFilePaths = (projectDir, ignored = []) => {
245474
245529
  const ignorePatterns = [
245475
245530
  ...DEFAULT_IGNORED_PATTERNS,
@@ -245480,7 +245535,7 @@ var getPackageFilePaths = (projectDir, ignored = []) => {
245480
245535
  ignore: ignorePatterns
245481
245536
  });
245482
245537
  fileNames.sort();
245483
- return fileNames.map((fileName) => path49.join(projectDir, fileName));
245538
+ return fileNames.map((fileName) => path50.join(projectDir, fileName));
245484
245539
  };
245485
245540
 
245486
245541
  // lib/utils/check-org-access.ts
@@ -245496,7 +245551,7 @@ var checkOrgAccess = async (ky3, orgTscircuitHandle) => {
245496
245551
  };
245497
245552
 
245498
245553
  // lib/shared/is-binary-file.ts
245499
- import * as path50 from "node:path";
245554
+ import * as path51 from "node:path";
245500
245555
  var BINARY_FILE_EXTENSIONS = new Set([
245501
245556
  ".glb",
245502
245557
  ".gltf",
@@ -245512,7 +245567,7 @@ var BINARY_FILE_EXTENSIONS = new Set([
245512
245567
  ".tar"
245513
245568
  ]);
245514
245569
  var isBinaryFile = (filePath) => {
245515
- const ext = path50.extname(filePath).toLowerCase();
245570
+ const ext = path51.extname(filePath).toLowerCase();
245516
245571
  return BINARY_FILE_EXTENSIONS.has(ext);
245517
245572
  };
245518
245573
 
@@ -245538,8 +245593,8 @@ var debug11 = Debug2("tsci:push-snippet");
245538
245593
  var getArchivePayload = async (filePaths, projectDir, packageNameWithVersion) => {
245539
245594
  const zip = new import_jszip4.default;
245540
245595
  for (const fullFilePath of filePaths) {
245541
- const relativeFilePath = path51.relative(projectDir, fullFilePath);
245542
- zip.file(relativeFilePath, fs48.readFileSync(fullFilePath));
245596
+ const relativeFilePath = path52.relative(projectDir, fullFilePath);
245597
+ zip.file(relativeFilePath, fs49.readFileSync(fullFilePath));
245543
245598
  }
245544
245599
  const archive = await zip.generateAsync({
245545
245600
  type: "uint8array",
@@ -245577,24 +245632,24 @@ var pushSnippet = async ({
245577
245632
  return onExit(1);
245578
245633
  }
245579
245634
  const packageJsonPath = [
245580
- path51.resolve(path51.join(path51.dirname(snippetFilePath), "package.json")),
245581
- path51.resolve(path51.join(process.cwd(), "package.json"))
245582
- ].find((path52) => fs48.existsSync(path52));
245583
- const projectDir = packageJsonPath ? path51.dirname(packageJsonPath) : path51.dirname(snippetFilePath);
245635
+ path52.resolve(path52.join(path52.dirname(snippetFilePath), "package.json")),
245636
+ path52.resolve(path52.join(process.cwd(), "package.json"))
245637
+ ].find((path53) => fs49.existsSync(path53));
245638
+ const projectDir = packageJsonPath ? path52.dirname(packageJsonPath) : path52.dirname(snippetFilePath);
245584
245639
  if (!packageJsonPath) {
245585
245640
  onError("No package.json found, try running 'tsci init' to bootstrap the project");
245586
245641
  return onExit(1);
245587
245642
  }
245588
245643
  let packageJson = {};
245589
- if (fs48.existsSync(packageJsonPath)) {
245644
+ if (fs49.existsSync(packageJsonPath)) {
245590
245645
  try {
245591
- packageJson = JSON.parse(fs48.readFileSync(packageJsonPath).toString());
245646
+ packageJson = JSON.parse(fs49.readFileSync(packageJsonPath).toString());
245592
245647
  } catch {
245593
245648
  onError("Invalid package.json");
245594
245649
  return onExit(1);
245595
245650
  }
245596
245651
  }
245597
- if (!fs48.existsSync(snippetFilePath)) {
245652
+ if (!fs49.existsSync(snippetFilePath)) {
245598
245653
  onError(`File not found: ${snippetFilePath}`);
245599
245654
  return onExit(1);
245600
245655
  }
@@ -245635,7 +245690,7 @@ var pushSnippet = async ({
245635
245690
  }
245636
245691
  unscopedPackageName = inputName;
245637
245692
  packageJson.name = `@tsci/${currentUsername}.${unscopedPackageName}`;
245638
- fs48.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
245693
+ fs49.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
245639
245694
  }
245640
245695
  let accountName = currentUsername;
245641
245696
  if (packageJsonAuthor && currentUsername !== packageJsonAuthor) {
@@ -245666,7 +245721,7 @@ var pushSnippet = async ({
245666
245721
  const updatePackageJsonVersion = (newVersion) => {
245667
245722
  try {
245668
245723
  packageJson.version = newVersion ?? `${packageVersion}`;
245669
- fs48.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
245724
+ fs49.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
245670
245725
  } catch (error) {
245671
245726
  onError(`Failed to update package.json version: ${error}`);
245672
245727
  }
@@ -245774,7 +245829,7 @@ var pushSnippet = async ({
245774
245829
  json: archivePayload
245775
245830
  });
245776
245831
  for (const fullFilePath of filePaths) {
245777
- const relativeFilePath = path51.relative(projectDir, fullFilePath);
245832
+ const relativeFilePath = path52.relative(projectDir, fullFilePath);
245778
245833
  uploadResults.succeeded.push(relativeFilePath);
245779
245834
  }
245780
245835
  log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
@@ -245784,8 +245839,8 @@ var pushSnippet = async ({
245784
245839
  }
245785
245840
  if (uploadResults.succeeded.length === 0) {
245786
245841
  for (const fullFilePath of filePaths) {
245787
- const relativeFilePath = path51.relative(projectDir, fullFilePath);
245788
- const fileBuffer = fs48.readFileSync(fullFilePath);
245842
+ const relativeFilePath = path52.relative(projectDir, fullFilePath);
245843
+ const fileBuffer = fs49.readFileSync(fullFilePath);
245789
245844
  const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
245790
245845
  const payload = {
245791
245846
  file_path: relativeFilePath,
@@ -245851,7 +245906,7 @@ Publish completed with ${uploadResults.succeeded.length} files uploaded and ${up
245851
245906
  return onExit(0);
245852
245907
  };
245853
245908
 
245854
- // cli/dev/DevServer.ts
245909
+ // lib/dev/DevServer.ts
245855
245910
  var debug13 = Debug3("tscircuit:devserver");
245856
245911
  var BINARY_FILE_EXTENSIONS2 = new Set([".glb", ".png", ".jpeg", ".jpg"]);
245857
245912
 
@@ -245874,7 +245929,7 @@ class DevServer {
245874
245929
  }) {
245875
245930
  this.port = port;
245876
245931
  this.componentFilePath = componentFilePath;
245877
- this.projectDir = projectDir ?? path52.dirname(componentFilePath);
245932
+ this.projectDir = projectDir ?? path53.dirname(componentFilePath);
245878
245933
  this.kicadPcm = kicadPcm ?? false;
245879
245934
  const projectConfig2 = loadProjectConfig(this.projectDir);
245880
245935
  this.ignoredFiles = projectConfig2?.ignoredFiles ?? [];
@@ -245885,7 +245940,7 @@ class DevServer {
245885
245940
  async start() {
245886
245941
  const { server } = await createHttpServer({
245887
245942
  port: this.port,
245888
- defaultMainComponentPath: path52.relative(this.projectDir, this.componentFilePath),
245943
+ defaultMainComponentPath: path53.relative(this.projectDir, this.componentFilePath),
245889
245944
  kicadPcm: this.kicadPcm,
245890
245945
  projectDir: this.projectDir,
245891
245946
  entryFile: this.componentFilePath
@@ -245901,7 +245956,7 @@ class DevServer {
245901
245956
  this.filesystemWatcher = watch(this.projectDir, {
245902
245957
  persistent: true,
245903
245958
  ignoreInitial: true,
245904
- ignored: (p3) => shouldIgnorePath(path52.relative(this.projectDir, p3), this.ignoredFiles)
245959
+ ignored: (p3) => shouldIgnorePath(path53.relative(this.projectDir, p3), this.ignoredFiles)
245905
245960
  });
245906
245961
  this.filesystemWatcher.on("change", (filePath) => this.handleFileChangedOnFilesystem(filePath));
245907
245962
  this.filesystemWatcher.on("add", (filePath) => this.handleFileChangedOnFilesystem(filePath));
@@ -245916,27 +245971,27 @@ class DevServer {
245916
245971
  const { file } = await this.fsKy.get("api/files/get", {
245917
245972
  searchParams: { file_path: ev.file_path }
245918
245973
  }).json();
245919
- const fullPath = path52.join(this.projectDir, ev.file_path);
245920
- const dirPath = path52.dirname(fullPath);
245921
- if (!fs49.existsSync(dirPath)) {
245922
- fs49.mkdirSync(dirPath, { recursive: true });
245974
+ const fullPath = path53.join(this.projectDir, ev.file_path);
245975
+ const dirPath = path53.dirname(fullPath);
245976
+ if (!fs50.existsSync(dirPath)) {
245977
+ fs50.mkdirSync(dirPath, { recursive: true });
245923
245978
  }
245924
245979
  if (file.binary_content_b64) {
245925
245980
  const decodedContent = Buffer.from(file.binary_content_b64, "base64");
245926
- fs49.writeFileSync(fullPath, decodedContent);
245981
+ fs50.writeFileSync(fullPath, decodedContent);
245927
245982
  } else {
245928
- fs49.writeFileSync(fullPath, file.text_content ?? "", "utf-8");
245983
+ fs50.writeFileSync(fullPath, file.text_content ?? "", "utf-8");
245929
245984
  }
245930
245985
  }
245931
245986
  async handleFileDeletedEventFromServer(ev) {
245932
- const fullPath = path52.join(this.projectDir, ev.file_path);
245933
- if (fs49.existsSync(fullPath)) {
245987
+ const fullPath = path53.join(this.projectDir, ev.file_path);
245988
+ if (fs50.existsSync(fullPath)) {
245934
245989
  debug13(`Deleting file ${ev.file_path} from filesystem`);
245935
- fs49.unlinkSync(fullPath);
245990
+ fs50.unlinkSync(fullPath);
245936
245991
  }
245937
245992
  }
245938
245993
  async handleFileChangedOnFilesystem(absoluteFilePath) {
245939
- const relativeFilePath = path52.relative(this.projectDir, absoluteFilePath);
245994
+ const relativeFilePath = path53.relative(this.projectDir, absoluteFilePath);
245940
245995
  if (relativeFilePath.includes("manual-edits.json"))
245941
245996
  return;
245942
245997
  if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
@@ -245951,14 +246006,14 @@ class DevServer {
245951
246006
  await this.checkAndUploadNewNodeModules(absoluteFilePath);
245952
246007
  }
245953
246008
  async checkAndUploadNewNodeModules(filePath) {
245954
- const ext = path52.extname(filePath).toLowerCase();
246009
+ const ext = path53.extname(filePath).toLowerCase();
245955
246010
  const isSourceFile = [".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext);
245956
246011
  if (!isSourceFile)
245957
246012
  return;
245958
246013
  try {
245959
246014
  const nodeModuleFiles = getAllNodeModuleFilePaths(filePath, this.projectDir);
245960
246015
  const newFiles = nodeModuleFiles.filter((file) => {
245961
- const relativePath = path52.relative(this.projectDir, file);
246016
+ const relativePath = path53.relative(this.projectDir, file);
245962
246017
  return !this.uploadedNodeModules.has(relativePath);
245963
246018
  });
245964
246019
  if (newFiles.length === 0)
@@ -245971,7 +246026,7 @@ class DevServer {
245971
246026
  }
245972
246027
  }
245973
246028
  async handleFileRemovedFromFilesystem(absoluteFilePath) {
245974
- const relativeFilePath = path52.relative(this.projectDir, absoluteFilePath);
246029
+ const relativeFilePath = path53.relative(this.projectDir, absoluteFilePath);
245975
246030
  if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
245976
246031
  return;
245977
246032
  if (!relativeFilePath || relativeFilePath.trim() === "") {
@@ -246009,8 +246064,8 @@ class DevServer {
246009
246064
  debug13(`Successfully deleted file ${relativeFilePath} from server`);
246010
246065
  }
246011
246066
  async handleFileRename(oldPath, newPath) {
246012
- const oldRelativePath = path52.relative(this.projectDir, oldPath);
246013
- const newRelativePath = path52.relative(this.projectDir, newPath);
246067
+ const oldRelativePath = path53.relative(this.projectDir, oldPath);
246068
+ const newRelativePath = path53.relative(this.projectDir, newPath);
246014
246069
  if (shouldIgnorePath(oldRelativePath, this.ignoredFiles) || shouldIgnorePath(newRelativePath, this.ignoredFiles))
246015
246070
  return;
246016
246071
  await this.handleFileRemovedFromFilesystem(oldPath);
@@ -246028,7 +246083,7 @@ class DevServer {
246028
246083
  });
246029
246084
  const filePaths = getPackageFilePaths(this.projectDir, this.ignoredFiles);
246030
246085
  for (const filePath of filePaths) {
246031
- const relativeFilePath = path52.relative(this.projectDir, filePath);
246086
+ const relativeFilePath = path53.relative(this.projectDir, filePath);
246032
246087
  const filePayload = this.createFileUploadPayload(filePath, relativeFilePath);
246033
246088
  await this.postFileUpsert({
246034
246089
  filePath: relativeFilePath,
@@ -246060,7 +246115,7 @@ class DevServer {
246060
246115
  }
246061
246116
  async uploadNodeModuleFiles(files) {
246062
246117
  for (const nodeModuleFile of files) {
246063
- const relativeFilePath = path52.relative(this.projectDir, nodeModuleFile);
246118
+ const relativeFilePath = path53.relative(this.projectDir, nodeModuleFile);
246064
246119
  this.uploadedNodeModules.add(relativeFilePath);
246065
246120
  const filePayload = this.createFileUploadPayload(nodeModuleFile, relativeFilePath);
246066
246121
  await this.postFileUpsert({
@@ -246105,7 +246160,7 @@ class DevServer {
246105
246160
  formData.set("file_path", filePath);
246106
246161
  formData.set("initiator", initiator);
246107
246162
  const binaryBytes = Uint8Array.from(binaryContent);
246108
- formData.set("binary_file", new Blob([binaryBytes]), path52.basename(filePath));
246163
+ formData.set("binary_file", new Blob([binaryBytes]), path53.basename(filePath));
246109
246164
  const response = await fetch(`http://localhost:${this.port}/api/files/upsert-multipart`, {
246110
246165
  method: "POST",
246111
246166
  body: formData
@@ -246145,12 +246200,12 @@ class DevServer {
246145
246200
  await this.filesystemWatcher?.close();
246146
246201
  }
246147
246202
  createFileUploadPayload(absoluteFilePath, relativeFilePath) {
246148
- const ext = path52.extname(relativeFilePath).toLowerCase();
246203
+ const ext = path53.extname(relativeFilePath).toLowerCase();
246149
246204
  if (BINARY_FILE_EXTENSIONS2.has(ext)) {
246150
- const fileBuffer = fs49.readFileSync(absoluteFilePath);
246205
+ const fileBuffer = fs50.readFileSync(absoluteFilePath);
246151
246206
  return { binary_content: fileBuffer };
246152
246207
  }
246153
- return { text_content: fs49.readFileSync(absoluteFilePath, "utf-8") };
246208
+ return { text_content: fs50.readFileSync(absoluteFilePath, "utf-8") };
246154
246209
  }
246155
246210
  async handleInstallPackage(full_package_name) {
246156
246211
  const postEvent = async (event, message) => {
@@ -246179,61 +246234,6 @@ class DevServer {
246179
246234
  }
246180
246235
  }
246181
246236
 
246182
- // cli/dev/resolve-dev-target.ts
246183
- import * as fs50 from "node:fs";
246184
- import * as path53 from "node:path";
246185
- var findSelectableFiles = (projectDir) => {
246186
- const boardFiles = findBoardFiles({ projectDir }).filter((file) => fs50.existsSync(file)).sort();
246187
- if (boardFiles.length > 0) {
246188
- return boardFiles;
246189
- }
246190
- const files = globbySync(["**/*.tsx", "**/*.ts", "**/*.circuit.json"], {
246191
- cwd: projectDir,
246192
- ignore: DEFAULT_IGNORED_PATTERNS
246193
- });
246194
- return files.map((file) => path53.resolve(projectDir, file)).filter((file) => fs50.existsSync(file)).sort();
246195
- };
246196
- var isValidDevFile = (filePath) => {
246197
- return filePath.endsWith(".tsx") || filePath.endsWith(".ts") || filePath.endsWith(".circuit.json");
246198
- };
246199
- var resolveDevTarget = async (file) => {
246200
- let projectDir = process.cwd();
246201
- if (file) {
246202
- const resolvedPath = path53.resolve(file);
246203
- if (fs50.existsSync(resolvedPath) && fs50.statSync(resolvedPath).isDirectory()) {
246204
- projectDir = resolvedPath;
246205
- const availableFiles2 = findSelectableFiles(projectDir);
246206
- if (availableFiles2.length === 0) {
246207
- console.log(`No .tsx, .ts, or .circuit.json files found in ${projectDir}. Run 'tsci init' to bootstrap a basic project.`);
246208
- return null;
246209
- }
246210
- console.log("Selected file:", path53.relative(projectDir, availableFiles2[0]));
246211
- return { absolutePath: availableFiles2[0], projectDir };
246212
- }
246213
- if (!fs50.existsSync(resolvedPath)) {
246214
- console.error(`Error: File not found: ${file}`);
246215
- return null;
246216
- }
246217
- if (!isValidDevFile(resolvedPath)) {
246218
- console.error("Error: Only .tsx, .ts, and .circuit.json files are supported");
246219
- return null;
246220
- }
246221
- return { absolutePath: resolvedPath, projectDir };
246222
- }
246223
- const entrypointPath = await getEntrypoint({ onError: () => {} });
246224
- if (entrypointPath && fs50.existsSync(entrypointPath)) {
246225
- console.log("Found entrypoint at:", entrypointPath);
246226
- return { absolutePath: entrypointPath, projectDir };
246227
- }
246228
- const availableFiles = findSelectableFiles(projectDir);
246229
- if (availableFiles.length === 0) {
246230
- console.log("No .tsx, .ts, or .circuit.json files found in the project. Run 'tsci init' to bootstrap a basic project.");
246231
- return null;
246232
- }
246233
- console.log("Selected file:", path53.relative(projectDir, availableFiles[0]));
246234
- return { absolutePath: availableFiles[0], projectDir };
246235
- };
246236
-
246237
246237
  // cli/dev/register.ts
246238
246238
  var isPortAvailable = (port) => {
246239
246239
  return new Promise((resolve11) => {