@base44-preview/cli 0.0.36-pr.353.8cc7da8 → 0.0.36-pr.353.a0e4035

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -163321,168 +163321,6 @@ var require_dist2 = __commonJS((exports) => {
163321
163321
  __exportStar(require_legacy(), exports);
163322
163322
  });
163323
163323
 
163324
- // node_modules/lodash/isObject.js
163325
- var require_isObject = __commonJS((exports, module) => {
163326
- function isObject5(value) {
163327
- var type = typeof value;
163328
- return value != null && (type == "object" || type == "function");
163329
- }
163330
- module.exports = isObject5;
163331
- });
163332
-
163333
- // node_modules/lodash/now.js
163334
- var require_now = __commonJS((exports, module) => {
163335
- var root2 = require__root();
163336
- var now = function() {
163337
- return root2.Date.now();
163338
- };
163339
- module.exports = now;
163340
- });
163341
-
163342
- // node_modules/lodash/_trimmedEndIndex.js
163343
- var require__trimmedEndIndex = __commonJS((exports, module) => {
163344
- var reWhitespace = /\s/;
163345
- function trimmedEndIndex(string4) {
163346
- var index = string4.length;
163347
- while (index-- && reWhitespace.test(string4.charAt(index))) {}
163348
- return index;
163349
- }
163350
- module.exports = trimmedEndIndex;
163351
- });
163352
-
163353
- // node_modules/lodash/_baseTrim.js
163354
- var require__baseTrim = __commonJS((exports, module) => {
163355
- var trimmedEndIndex = require__trimmedEndIndex();
163356
- var reTrimStart = /^\s+/;
163357
- function baseTrim(string4) {
163358
- return string4 ? string4.slice(0, trimmedEndIndex(string4) + 1).replace(reTrimStart, "") : string4;
163359
- }
163360
- module.exports = baseTrim;
163361
- });
163362
-
163363
- // node_modules/lodash/toNumber.js
163364
- var require_toNumber = __commonJS((exports, module) => {
163365
- var baseTrim = require__baseTrim();
163366
- var isObject5 = require_isObject();
163367
- var isSymbol = require_isSymbol();
163368
- var NAN = 0 / 0;
163369
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
163370
- var reIsBinary = /^0b[01]+$/i;
163371
- var reIsOctal = /^0o[0-7]+$/i;
163372
- var freeParseInt = parseInt;
163373
- function toNumber(value) {
163374
- if (typeof value == "number") {
163375
- return value;
163376
- }
163377
- if (isSymbol(value)) {
163378
- return NAN;
163379
- }
163380
- if (isObject5(value)) {
163381
- var other = typeof value.valueOf == "function" ? value.valueOf() : value;
163382
- value = isObject5(other) ? other + "" : other;
163383
- }
163384
- if (typeof value != "string") {
163385
- return value === 0 ? value : +value;
163386
- }
163387
- value = baseTrim(value);
163388
- var isBinary = reIsBinary.test(value);
163389
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
163390
- }
163391
- module.exports = toNumber;
163392
- });
163393
-
163394
- // node_modules/lodash/debounce.js
163395
- var require_debounce = __commonJS((exports, module) => {
163396
- var isObject5 = require_isObject();
163397
- var now = require_now();
163398
- var toNumber = require_toNumber();
163399
- var FUNC_ERROR_TEXT = "Expected a function";
163400
- var nativeMax = Math.max;
163401
- var nativeMin = Math.min;
163402
- function debounce(func, wait, options8) {
163403
- var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
163404
- if (typeof func != "function") {
163405
- throw new TypeError(FUNC_ERROR_TEXT);
163406
- }
163407
- wait = toNumber(wait) || 0;
163408
- if (isObject5(options8)) {
163409
- leading = !!options8.leading;
163410
- maxing = "maxWait" in options8;
163411
- maxWait = maxing ? nativeMax(toNumber(options8.maxWait) || 0, wait) : maxWait;
163412
- trailing = "trailing" in options8 ? !!options8.trailing : trailing;
163413
- }
163414
- function invokeFunc(time3) {
163415
- var args = lastArgs, thisArg = lastThis;
163416
- lastArgs = lastThis = undefined;
163417
- lastInvokeTime = time3;
163418
- result = func.apply(thisArg, args);
163419
- return result;
163420
- }
163421
- function leadingEdge(time3) {
163422
- lastInvokeTime = time3;
163423
- timerId = setTimeout(timerExpired, wait);
163424
- return leading ? invokeFunc(time3) : result;
163425
- }
163426
- function remainingWait(time3) {
163427
- var timeSinceLastCall = time3 - lastCallTime, timeSinceLastInvoke = time3 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
163428
- return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
163429
- }
163430
- function shouldInvoke(time3) {
163431
- var timeSinceLastCall = time3 - lastCallTime, timeSinceLastInvoke = time3 - lastInvokeTime;
163432
- return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
163433
- }
163434
- function timerExpired() {
163435
- var time3 = now();
163436
- if (shouldInvoke(time3)) {
163437
- return trailingEdge(time3);
163438
- }
163439
- timerId = setTimeout(timerExpired, remainingWait(time3));
163440
- }
163441
- function trailingEdge(time3) {
163442
- timerId = undefined;
163443
- if (trailing && lastArgs) {
163444
- return invokeFunc(time3);
163445
- }
163446
- lastArgs = lastThis = undefined;
163447
- return result;
163448
- }
163449
- function cancel() {
163450
- if (timerId !== undefined) {
163451
- clearTimeout(timerId);
163452
- }
163453
- lastInvokeTime = 0;
163454
- lastArgs = lastCallTime = lastThis = timerId = undefined;
163455
- }
163456
- function flush() {
163457
- return timerId === undefined ? result : trailingEdge(now());
163458
- }
163459
- function debounced() {
163460
- var time3 = now(), isInvoking = shouldInvoke(time3);
163461
- lastArgs = arguments;
163462
- lastThis = this;
163463
- lastCallTime = time3;
163464
- if (isInvoking) {
163465
- if (timerId === undefined) {
163466
- return leadingEdge(lastCallTime);
163467
- }
163468
- if (maxing) {
163469
- clearTimeout(timerId);
163470
- timerId = setTimeout(timerExpired, wait);
163471
- return invokeFunc(lastCallTime);
163472
- }
163473
- }
163474
- if (timerId === undefined) {
163475
- timerId = setTimeout(timerExpired, wait);
163476
- }
163477
- return result;
163478
- }
163479
- debounced.cancel = cancel;
163480
- debounced.flush = flush;
163481
- return debounced;
163482
- }
163483
- module.exports = debounce;
163484
- });
163485
-
163486
163324
  // node_modules/tmp/lib/tmp.js
163487
163325
  var require_tmp = __commonJS((exports, module) => {
163488
163326
  /*!
@@ -210564,6 +210402,168 @@ var require_multer = __commonJS((exports, module) => {
210564
210402
  module.exports.MulterError = MulterError;
210565
210403
  });
210566
210404
 
210405
+ // node_modules/lodash/isObject.js
210406
+ var require_isObject = __commonJS((exports, module) => {
210407
+ function isObject5(value) {
210408
+ var type = typeof value;
210409
+ return value != null && (type == "object" || type == "function");
210410
+ }
210411
+ module.exports = isObject5;
210412
+ });
210413
+
210414
+ // node_modules/lodash/now.js
210415
+ var require_now = __commonJS((exports, module) => {
210416
+ var root2 = require__root();
210417
+ var now = function() {
210418
+ return root2.Date.now();
210419
+ };
210420
+ module.exports = now;
210421
+ });
210422
+
210423
+ // node_modules/lodash/_trimmedEndIndex.js
210424
+ var require__trimmedEndIndex = __commonJS((exports, module) => {
210425
+ var reWhitespace = /\s/;
210426
+ function trimmedEndIndex(string4) {
210427
+ var index = string4.length;
210428
+ while (index-- && reWhitespace.test(string4.charAt(index))) {}
210429
+ return index;
210430
+ }
210431
+ module.exports = trimmedEndIndex;
210432
+ });
210433
+
210434
+ // node_modules/lodash/_baseTrim.js
210435
+ var require__baseTrim = __commonJS((exports, module) => {
210436
+ var trimmedEndIndex = require__trimmedEndIndex();
210437
+ var reTrimStart = /^\s+/;
210438
+ function baseTrim(string4) {
210439
+ return string4 ? string4.slice(0, trimmedEndIndex(string4) + 1).replace(reTrimStart, "") : string4;
210440
+ }
210441
+ module.exports = baseTrim;
210442
+ });
210443
+
210444
+ // node_modules/lodash/toNumber.js
210445
+ var require_toNumber = __commonJS((exports, module) => {
210446
+ var baseTrim = require__baseTrim();
210447
+ var isObject5 = require_isObject();
210448
+ var isSymbol = require_isSymbol();
210449
+ var NAN = 0 / 0;
210450
+ var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
210451
+ var reIsBinary = /^0b[01]+$/i;
210452
+ var reIsOctal = /^0o[0-7]+$/i;
210453
+ var freeParseInt = parseInt;
210454
+ function toNumber(value) {
210455
+ if (typeof value == "number") {
210456
+ return value;
210457
+ }
210458
+ if (isSymbol(value)) {
210459
+ return NAN;
210460
+ }
210461
+ if (isObject5(value)) {
210462
+ var other = typeof value.valueOf == "function" ? value.valueOf() : value;
210463
+ value = isObject5(other) ? other + "" : other;
210464
+ }
210465
+ if (typeof value != "string") {
210466
+ return value === 0 ? value : +value;
210467
+ }
210468
+ value = baseTrim(value);
210469
+ var isBinary = reIsBinary.test(value);
210470
+ return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
210471
+ }
210472
+ module.exports = toNumber;
210473
+ });
210474
+
210475
+ // node_modules/lodash/debounce.js
210476
+ var require_debounce = __commonJS((exports, module) => {
210477
+ var isObject5 = require_isObject();
210478
+ var now = require_now();
210479
+ var toNumber = require_toNumber();
210480
+ var FUNC_ERROR_TEXT = "Expected a function";
210481
+ var nativeMax = Math.max;
210482
+ var nativeMin = Math.min;
210483
+ function debounce(func, wait, options8) {
210484
+ var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
210485
+ if (typeof func != "function") {
210486
+ throw new TypeError(FUNC_ERROR_TEXT);
210487
+ }
210488
+ wait = toNumber(wait) || 0;
210489
+ if (isObject5(options8)) {
210490
+ leading = !!options8.leading;
210491
+ maxing = "maxWait" in options8;
210492
+ maxWait = maxing ? nativeMax(toNumber(options8.maxWait) || 0, wait) : maxWait;
210493
+ trailing = "trailing" in options8 ? !!options8.trailing : trailing;
210494
+ }
210495
+ function invokeFunc(time3) {
210496
+ var args = lastArgs, thisArg = lastThis;
210497
+ lastArgs = lastThis = undefined;
210498
+ lastInvokeTime = time3;
210499
+ result = func.apply(thisArg, args);
210500
+ return result;
210501
+ }
210502
+ function leadingEdge(time3) {
210503
+ lastInvokeTime = time3;
210504
+ timerId = setTimeout(timerExpired, wait);
210505
+ return leading ? invokeFunc(time3) : result;
210506
+ }
210507
+ function remainingWait(time3) {
210508
+ var timeSinceLastCall = time3 - lastCallTime, timeSinceLastInvoke = time3 - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
210509
+ return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
210510
+ }
210511
+ function shouldInvoke(time3) {
210512
+ var timeSinceLastCall = time3 - lastCallTime, timeSinceLastInvoke = time3 - lastInvokeTime;
210513
+ return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
210514
+ }
210515
+ function timerExpired() {
210516
+ var time3 = now();
210517
+ if (shouldInvoke(time3)) {
210518
+ return trailingEdge(time3);
210519
+ }
210520
+ timerId = setTimeout(timerExpired, remainingWait(time3));
210521
+ }
210522
+ function trailingEdge(time3) {
210523
+ timerId = undefined;
210524
+ if (trailing && lastArgs) {
210525
+ return invokeFunc(time3);
210526
+ }
210527
+ lastArgs = lastThis = undefined;
210528
+ return result;
210529
+ }
210530
+ function cancel() {
210531
+ if (timerId !== undefined) {
210532
+ clearTimeout(timerId);
210533
+ }
210534
+ lastInvokeTime = 0;
210535
+ lastArgs = lastCallTime = lastThis = timerId = undefined;
210536
+ }
210537
+ function flush() {
210538
+ return timerId === undefined ? result : trailingEdge(now());
210539
+ }
210540
+ function debounced() {
210541
+ var time3 = now(), isInvoking = shouldInvoke(time3);
210542
+ lastArgs = arguments;
210543
+ lastThis = this;
210544
+ lastCallTime = time3;
210545
+ if (isInvoking) {
210546
+ if (timerId === undefined) {
210547
+ return leadingEdge(lastCallTime);
210548
+ }
210549
+ if (maxing) {
210550
+ clearTimeout(timerId);
210551
+ timerId = setTimeout(timerExpired, wait);
210552
+ return invokeFunc(lastCallTime);
210553
+ }
210554
+ }
210555
+ if (timerId === undefined) {
210556
+ timerId = setTimeout(timerExpired, wait);
210557
+ }
210558
+ return result;
210559
+ }
210560
+ debounced.cancel = cancel;
210561
+ debounced.flush = flush;
210562
+ return debounced;
210563
+ }
210564
+ module.exports = debounce;
210565
+ });
210566
+
210567
210567
  // node_modules/@vercel/detect-agent/dist/index.js
210568
210568
  var require_dist5 = __commonJS((exports, module) => {
210569
210569
  var __defProp4 = Object.defineProperty;
@@ -210589,8 +210589,8 @@ var require_dist5 = __commonJS((exports, module) => {
210589
210589
  determineAgent: () => determineAgent
210590
210590
  });
210591
210591
  module.exports = __toCommonJS(src_exports);
210592
- var import_promises19 = __require("node:fs/promises");
210593
- var import_node_fs20 = __require("node:fs");
210592
+ var import_promises22 = __require("node:fs/promises");
210593
+ var import_node_fs21 = __require("node:fs");
210594
210594
  var DEVIN_LOCAL_PATH = "/opt/.devin";
210595
210595
  var CURSOR2 = "cursor";
210596
210596
  var CURSOR_CLI = "cursor-cli";
@@ -210647,7 +210647,7 @@ var require_dist5 = __commonJS((exports, module) => {
210647
210647
  return { isAgent: true, agent: { name: REPLIT } };
210648
210648
  }
210649
210649
  try {
210650
- await (0, import_promises19.access)(DEVIN_LOCAL_PATH, import_node_fs20.constants.F_OK);
210650
+ await (0, import_promises22.access)(DEVIN_LOCAL_PATH, import_node_fs21.constants.F_OK);
210651
210651
  return { isAgent: true, agent: { name: DEVIN } };
210652
210652
  } catch (error48) {}
210653
210653
  return { isAgent: false, agent: undefined };
@@ -241907,11 +241907,12 @@ var package_default = {
241907
241907
  "@types/ejs": "^3.1.5",
241908
241908
  "@types/express": "^5.0.6",
241909
241909
  "@types/json-schema": "^7.0.15",
241910
- "@types/lodash": "^4.17.16",
241911
- "@types/node": "^22.10.5",
241910
+ "@types/lodash": "^4.17.24",
241912
241911
  "@types/multer": "^2.0.0",
241912
+ "@types/node": "^22.10.5",
241913
241913
  "@vercel/detect-agent": "^1.1.0",
241914
241914
  chalk: "^5.6.2",
241915
+ chokidar: "^5.0.0",
241915
241916
  commander: "^12.1.0",
241916
241917
  "common-tags": "^1.8.2",
241917
241918
  cors: "^2.8.5",
@@ -241927,9 +241928,9 @@ var package_default = {
241927
241928
  json5: "^2.2.3",
241928
241929
  knip: "^5.83.1",
241929
241930
  ky: "^1.14.2",
241930
- lodash: "^4.17.21",
241931
- multer: "^2.0.0",
241931
+ lodash: "^4.17.23",
241932
241932
  msw: "^2.12.10",
241933
+ multer: "^2.0.0",
241933
241934
  nanoid: "^5.1.6",
241934
241935
  open: "^11.0.0",
241935
241936
  "p-wait-for": "^6.0.0",
@@ -243859,8 +243860,7 @@ function getTypesCommand(context) {
243859
243860
  }
243860
243861
 
243861
243862
  // src/cli/dev/dev-server/main.ts
243862
- import { watch } from "node:fs";
243863
- import { dirname as dirname12, join as join16 } from "node:path";
243863
+ import { dirname as dirname14, join as join18 } from "node:path";
243864
243864
  var import_cors = __toESM(require_lib4(), 1);
243865
243865
  var import_express4 = __toESM(require_express(), 1);
243866
243866
 
@@ -243980,7 +243980,6 @@ async function getPorts(options8) {
243980
243980
 
243981
243981
  // src/cli/dev/dev-server/main.ts
243982
243982
  var import_http_proxy_middleware2 = __toESM(require_dist2(), 1);
243983
- var import_debounce = __toESM(require_debounce(), 1);
243984
243983
 
243985
243984
  // node_modules/tmp-promise/index.js
243986
243985
  var { promisify: promisify11 } = __require("util");
@@ -244069,6 +244068,10 @@ class FunctionManager {
244069
244068
  try {
244070
244069
  return await promise2;
244071
244070
  } finally {
244071
+ if (!this.starting.has(name2) && this.running.has(name2)) {
244072
+ this.running.get(name2)?.process.kill();
244073
+ this.running.delete(name2);
244074
+ }
244072
244075
  this.starting.delete(name2);
244073
244076
  }
244074
244077
  }
@@ -244129,7 +244132,9 @@ class FunctionManager {
244129
244132
  }
244130
244133
  });
244131
244134
  process21.on("exit", (code2) => {
244132
- this.logger.log(`[dev-server] Function "${name2}" exited with code ${code2}`);
244135
+ if (code2 !== null) {
244136
+ this.logger.log(`[dev-server] Function "${name2}" exited with code ${code2}`);
244137
+ }
244133
244138
  this.running.delete(name2);
244134
244139
  });
244135
244140
  process21.on("error", (error48) => {
@@ -244584,23 +244589,1714 @@ function createCustomIntegrationRoutes(remoteProxy, logger) {
244584
244589
  return router;
244585
244590
  }
244586
244591
 
244587
- // src/cli/dev/dev-server/main.ts
244588
- var DEFAULT_PORT = 4400;
244589
- var BASE44_APP_URL = "https://base44.app";
244590
- var WATCH_DEBOUNCE_MS = 300;
244591
- async function watchDir(dir, onChange, logger) {
244592
- if (!await pathExists(dir)) {
244593
- return null;
244592
+ // src/cli/dev/dev-server/watcher.ts
244593
+ import { relative as relative4 } from "node:path";
244594
+
244595
+ // node_modules/chokidar/index.js
244596
+ import { EventEmitter as EventEmitter3 } from "node:events";
244597
+ import { stat as statcb, Stats } from "node:fs";
244598
+ import { readdir as readdir3, stat as stat4 } from "node:fs/promises";
244599
+ import * as sp3 from "node:path";
244600
+
244601
+ // node_modules/readdirp/index.js
244602
+ import { lstat as lstat2, readdir as readdir2, realpath, stat as stat2 } from "node:fs/promises";
244603
+ import { join as pjoin, relative as prelative, resolve as presolve, sep as psep } from "node:path";
244604
+ import { Readable as Readable6 } from "node:stream";
244605
+ var EntryTypes = {
244606
+ FILE_TYPE: "files",
244607
+ DIR_TYPE: "directories",
244608
+ FILE_DIR_TYPE: "files_directories",
244609
+ EVERYTHING_TYPE: "all"
244610
+ };
244611
+ var defaultOptions = {
244612
+ root: ".",
244613
+ fileFilter: (_entryInfo) => true,
244614
+ directoryFilter: (_entryInfo) => true,
244615
+ type: EntryTypes.FILE_TYPE,
244616
+ lstat: false,
244617
+ depth: 2147483648,
244618
+ alwaysStat: false,
244619
+ highWaterMark: 4096
244620
+ };
244621
+ Object.freeze(defaultOptions);
244622
+ var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
244623
+ var NORMAL_FLOW_ERRORS = new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
244624
+ var ALL_TYPES = [
244625
+ EntryTypes.DIR_TYPE,
244626
+ EntryTypes.EVERYTHING_TYPE,
244627
+ EntryTypes.FILE_DIR_TYPE,
244628
+ EntryTypes.FILE_TYPE
244629
+ ];
244630
+ var DIR_TYPES = new Set([
244631
+ EntryTypes.DIR_TYPE,
244632
+ EntryTypes.EVERYTHING_TYPE,
244633
+ EntryTypes.FILE_DIR_TYPE
244634
+ ]);
244635
+ var FILE_TYPES2 = new Set([
244636
+ EntryTypes.EVERYTHING_TYPE,
244637
+ EntryTypes.FILE_DIR_TYPE,
244638
+ EntryTypes.FILE_TYPE
244639
+ ]);
244640
+ var isNormalFlowError = (error48) => NORMAL_FLOW_ERRORS.has(error48.code);
244641
+ var wantBigintFsStats = process.platform === "win32";
244642
+ var emptyFn = (_entryInfo) => true;
244643
+ var normalizeFilter = (filter2) => {
244644
+ if (filter2 === undefined)
244645
+ return emptyFn;
244646
+ if (typeof filter2 === "function")
244647
+ return filter2;
244648
+ if (typeof filter2 === "string") {
244649
+ const fl6 = filter2.trim();
244650
+ return (entry) => entry.basename === fl6;
244651
+ }
244652
+ if (Array.isArray(filter2)) {
244653
+ const trItems = filter2.map((item) => item.trim());
244654
+ return (entry) => trItems.some((f7) => entry.basename === f7);
244655
+ }
244656
+ return emptyFn;
244657
+ };
244658
+
244659
+ class ReaddirpStream extends Readable6 {
244660
+ parents;
244661
+ reading;
244662
+ parent;
244663
+ _stat;
244664
+ _maxDepth;
244665
+ _wantsDir;
244666
+ _wantsFile;
244667
+ _wantsEverything;
244668
+ _root;
244669
+ _isDirent;
244670
+ _statsProp;
244671
+ _rdOptions;
244672
+ _fileFilter;
244673
+ _directoryFilter;
244674
+ constructor(options8 = {}) {
244675
+ super({
244676
+ objectMode: true,
244677
+ autoDestroy: true,
244678
+ highWaterMark: options8.highWaterMark
244679
+ });
244680
+ const opts = { ...defaultOptions, ...options8 };
244681
+ const { root: root2, type } = opts;
244682
+ this._fileFilter = normalizeFilter(opts.fileFilter);
244683
+ this._directoryFilter = normalizeFilter(opts.directoryFilter);
244684
+ const statMethod = opts.lstat ? lstat2 : stat2;
244685
+ if (wantBigintFsStats) {
244686
+ this._stat = (path19) => statMethod(path19, { bigint: true });
244687
+ } else {
244688
+ this._stat = statMethod;
244689
+ }
244690
+ this._maxDepth = opts.depth != null && Number.isSafeInteger(opts.depth) ? opts.depth : defaultOptions.depth;
244691
+ this._wantsDir = type ? DIR_TYPES.has(type) : false;
244692
+ this._wantsFile = type ? FILE_TYPES2.has(type) : false;
244693
+ this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
244694
+ this._root = presolve(root2);
244695
+ this._isDirent = !opts.alwaysStat;
244696
+ this._statsProp = this._isDirent ? "dirent" : "stats";
244697
+ this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
244698
+ this.parents = [this._exploreDir(root2, 1)];
244699
+ this.reading = false;
244700
+ this.parent = undefined;
244701
+ }
244702
+ async _read(batch) {
244703
+ if (this.reading)
244704
+ return;
244705
+ this.reading = true;
244706
+ try {
244707
+ while (!this.destroyed && batch > 0) {
244708
+ const par = this.parent;
244709
+ const fil = par && par.files;
244710
+ if (fil && fil.length > 0) {
244711
+ const { path: path19, depth } = par;
244712
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path19));
244713
+ const awaited = await Promise.all(slice);
244714
+ for (const entry of awaited) {
244715
+ if (!entry)
244716
+ continue;
244717
+ if (this.destroyed)
244718
+ return;
244719
+ const entryType = await this._getEntryType(entry);
244720
+ if (entryType === "directory" && this._directoryFilter(entry)) {
244721
+ if (depth <= this._maxDepth) {
244722
+ this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
244723
+ }
244724
+ if (this._wantsDir) {
244725
+ this.push(entry);
244726
+ batch--;
244727
+ }
244728
+ } else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
244729
+ if (this._wantsFile) {
244730
+ this.push(entry);
244731
+ batch--;
244732
+ }
244733
+ }
244734
+ }
244735
+ } else {
244736
+ const parent = this.parents.pop();
244737
+ if (!parent) {
244738
+ this.push(null);
244739
+ break;
244740
+ }
244741
+ this.parent = await parent;
244742
+ if (this.destroyed)
244743
+ return;
244744
+ }
244745
+ }
244746
+ } catch (error48) {
244747
+ this.destroy(error48);
244748
+ } finally {
244749
+ this.reading = false;
244750
+ }
244751
+ }
244752
+ async _exploreDir(path19, depth) {
244753
+ let files;
244754
+ try {
244755
+ files = await readdir2(path19, this._rdOptions);
244756
+ } catch (error48) {
244757
+ this._onError(error48);
244758
+ }
244759
+ return { files, depth, path: path19 };
244760
+ }
244761
+ async _formatEntry(dirent, path19) {
244762
+ let entry;
244763
+ const basename4 = this._isDirent ? dirent.name : dirent;
244764
+ try {
244765
+ const fullPath = presolve(pjoin(path19, basename4));
244766
+ entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
244767
+ entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
244768
+ } catch (err) {
244769
+ this._onError(err);
244770
+ return;
244771
+ }
244772
+ return entry;
244773
+ }
244774
+ _onError(err) {
244775
+ if (isNormalFlowError(err) && !this.destroyed) {
244776
+ this.emit("warn", err);
244777
+ } else {
244778
+ this.destroy(err);
244779
+ }
244780
+ }
244781
+ async _getEntryType(entry) {
244782
+ if (!entry && this._statsProp in entry) {
244783
+ return "";
244784
+ }
244785
+ const stats = entry[this._statsProp];
244786
+ if (stats.isFile())
244787
+ return "file";
244788
+ if (stats.isDirectory())
244789
+ return "directory";
244790
+ if (stats && stats.isSymbolicLink()) {
244791
+ const full = entry.fullPath;
244792
+ try {
244793
+ const entryRealPath = await realpath(full);
244794
+ const entryRealPathStats = await lstat2(entryRealPath);
244795
+ if (entryRealPathStats.isFile()) {
244796
+ return "file";
244797
+ }
244798
+ if (entryRealPathStats.isDirectory()) {
244799
+ const len = entryRealPath.length;
244800
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === psep) {
244801
+ const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
244802
+ recursiveError.code = RECURSIVE_ERROR_CODE;
244803
+ return this._onError(recursiveError);
244804
+ }
244805
+ return "directory";
244806
+ }
244807
+ } catch (error48) {
244808
+ this._onError(error48);
244809
+ return "";
244810
+ }
244811
+ }
244812
+ }
244813
+ _includeAsFile(entry) {
244814
+ const stats = entry && entry[this._statsProp];
244815
+ return stats && this._wantsEverything && !stats.isDirectory();
244816
+ }
244817
+ }
244818
+ function readdirp(root2, options8 = {}) {
244819
+ let type = options8.entryType || options8.type;
244820
+ if (type === "both")
244821
+ type = EntryTypes.FILE_DIR_TYPE;
244822
+ if (type)
244823
+ options8.type = type;
244824
+ if (!root2) {
244825
+ throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
244826
+ } else if (typeof root2 !== "string") {
244827
+ throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
244828
+ } else if (type && !ALL_TYPES.includes(type)) {
244829
+ throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
244830
+ }
244831
+ options8.root = root2;
244832
+ return new ReaddirpStream(options8);
244833
+ }
244834
+
244835
+ // node_modules/chokidar/handler.js
244836
+ import { watch as fs_watch, unwatchFile, watchFile } from "node:fs";
244837
+ import { realpath as fsrealpath, lstat as lstat3, open as open2, stat as stat3 } from "node:fs/promises";
244838
+ import { type as osType } from "node:os";
244839
+ import * as sp2 from "node:path";
244840
+ var STR_DATA = "data";
244841
+ var STR_END = "end";
244842
+ var STR_CLOSE = "close";
244843
+ var EMPTY_FN = () => {};
244844
+ var pl6 = process.platform;
244845
+ var isWindows4 = pl6 === "win32";
244846
+ var isMacos = pl6 === "darwin";
244847
+ var isLinux = pl6 === "linux";
244848
+ var isFreeBSD = pl6 === "freebsd";
244849
+ var isIBMi = osType() === "OS400";
244850
+ var EVENTS = {
244851
+ ALL: "all",
244852
+ READY: "ready",
244853
+ ADD: "add",
244854
+ CHANGE: "change",
244855
+ ADD_DIR: "addDir",
244856
+ UNLINK: "unlink",
244857
+ UNLINK_DIR: "unlinkDir",
244858
+ RAW: "raw",
244859
+ ERROR: "error"
244860
+ };
244861
+ var EV = EVENTS;
244862
+ var THROTTLE_MODE_WATCH = "watch";
244863
+ var statMethods = { lstat: lstat3, stat: stat3 };
244864
+ var KEY_LISTENERS = "listeners";
244865
+ var KEY_ERR = "errHandlers";
244866
+ var KEY_RAW = "rawEmitters";
244867
+ var HANDLER_KEYS2 = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
244868
+ var binaryExtensions = new Set([
244869
+ "3dm",
244870
+ "3ds",
244871
+ "3g2",
244872
+ "3gp",
244873
+ "7z",
244874
+ "a",
244875
+ "aac",
244876
+ "adp",
244877
+ "afdesign",
244878
+ "afphoto",
244879
+ "afpub",
244880
+ "ai",
244881
+ "aif",
244882
+ "aiff",
244883
+ "alz",
244884
+ "ape",
244885
+ "apk",
244886
+ "appimage",
244887
+ "ar",
244888
+ "arj",
244889
+ "asf",
244890
+ "au",
244891
+ "avi",
244892
+ "bak",
244893
+ "baml",
244894
+ "bh",
244895
+ "bin",
244896
+ "bk",
244897
+ "bmp",
244898
+ "btif",
244899
+ "bz2",
244900
+ "bzip2",
244901
+ "cab",
244902
+ "caf",
244903
+ "cgm",
244904
+ "class",
244905
+ "cmx",
244906
+ "cpio",
244907
+ "cr2",
244908
+ "cur",
244909
+ "dat",
244910
+ "dcm",
244911
+ "deb",
244912
+ "dex",
244913
+ "djvu",
244914
+ "dll",
244915
+ "dmg",
244916
+ "dng",
244917
+ "doc",
244918
+ "docm",
244919
+ "docx",
244920
+ "dot",
244921
+ "dotm",
244922
+ "dra",
244923
+ "DS_Store",
244924
+ "dsk",
244925
+ "dts",
244926
+ "dtshd",
244927
+ "dvb",
244928
+ "dwg",
244929
+ "dxf",
244930
+ "ecelp4800",
244931
+ "ecelp7470",
244932
+ "ecelp9600",
244933
+ "egg",
244934
+ "eol",
244935
+ "eot",
244936
+ "epub",
244937
+ "exe",
244938
+ "f4v",
244939
+ "fbs",
244940
+ "fh",
244941
+ "fla",
244942
+ "flac",
244943
+ "flatpak",
244944
+ "fli",
244945
+ "flv",
244946
+ "fpx",
244947
+ "fst",
244948
+ "fvt",
244949
+ "g3",
244950
+ "gh",
244951
+ "gif",
244952
+ "graffle",
244953
+ "gz",
244954
+ "gzip",
244955
+ "h261",
244956
+ "h263",
244957
+ "h264",
244958
+ "icns",
244959
+ "ico",
244960
+ "ief",
244961
+ "img",
244962
+ "ipa",
244963
+ "iso",
244964
+ "jar",
244965
+ "jpeg",
244966
+ "jpg",
244967
+ "jpgv",
244968
+ "jpm",
244969
+ "jxr",
244970
+ "key",
244971
+ "ktx",
244972
+ "lha",
244973
+ "lib",
244974
+ "lvp",
244975
+ "lz",
244976
+ "lzh",
244977
+ "lzma",
244978
+ "lzo",
244979
+ "m3u",
244980
+ "m4a",
244981
+ "m4v",
244982
+ "mar",
244983
+ "mdi",
244984
+ "mht",
244985
+ "mid",
244986
+ "midi",
244987
+ "mj2",
244988
+ "mka",
244989
+ "mkv",
244990
+ "mmr",
244991
+ "mng",
244992
+ "mobi",
244993
+ "mov",
244994
+ "movie",
244995
+ "mp3",
244996
+ "mp4",
244997
+ "mp4a",
244998
+ "mpeg",
244999
+ "mpg",
245000
+ "mpga",
245001
+ "mxu",
245002
+ "nef",
245003
+ "npx",
245004
+ "numbers",
245005
+ "nupkg",
245006
+ "o",
245007
+ "odp",
245008
+ "ods",
245009
+ "odt",
245010
+ "oga",
245011
+ "ogg",
245012
+ "ogv",
245013
+ "otf",
245014
+ "ott",
245015
+ "pages",
245016
+ "pbm",
245017
+ "pcx",
245018
+ "pdb",
245019
+ "pdf",
245020
+ "pea",
245021
+ "pgm",
245022
+ "pic",
245023
+ "png",
245024
+ "pnm",
245025
+ "pot",
245026
+ "potm",
245027
+ "potx",
245028
+ "ppa",
245029
+ "ppam",
245030
+ "ppm",
245031
+ "pps",
245032
+ "ppsm",
245033
+ "ppsx",
245034
+ "ppt",
245035
+ "pptm",
245036
+ "pptx",
245037
+ "psd",
245038
+ "pya",
245039
+ "pyc",
245040
+ "pyo",
245041
+ "pyv",
245042
+ "qt",
245043
+ "rar",
245044
+ "ras",
245045
+ "raw",
245046
+ "resources",
245047
+ "rgb",
245048
+ "rip",
245049
+ "rlc",
245050
+ "rmf",
245051
+ "rmvb",
245052
+ "rpm",
245053
+ "rtf",
245054
+ "rz",
245055
+ "s3m",
245056
+ "s7z",
245057
+ "scpt",
245058
+ "sgi",
245059
+ "shar",
245060
+ "snap",
245061
+ "sil",
245062
+ "sketch",
245063
+ "slk",
245064
+ "smv",
245065
+ "snk",
245066
+ "so",
245067
+ "stl",
245068
+ "suo",
245069
+ "sub",
245070
+ "swf",
245071
+ "tar",
245072
+ "tbz",
245073
+ "tbz2",
245074
+ "tga",
245075
+ "tgz",
245076
+ "thmx",
245077
+ "tif",
245078
+ "tiff",
245079
+ "tlz",
245080
+ "ttc",
245081
+ "ttf",
245082
+ "txz",
245083
+ "udf",
245084
+ "uvh",
245085
+ "uvi",
245086
+ "uvm",
245087
+ "uvp",
245088
+ "uvs",
245089
+ "uvu",
245090
+ "viv",
245091
+ "vob",
245092
+ "war",
245093
+ "wav",
245094
+ "wax",
245095
+ "wbmp",
245096
+ "wdp",
245097
+ "weba",
245098
+ "webm",
245099
+ "webp",
245100
+ "whl",
245101
+ "wim",
245102
+ "wm",
245103
+ "wma",
245104
+ "wmv",
245105
+ "wmx",
245106
+ "woff",
245107
+ "woff2",
245108
+ "wrm",
245109
+ "wvx",
245110
+ "xbm",
245111
+ "xif",
245112
+ "xla",
245113
+ "xlam",
245114
+ "xls",
245115
+ "xlsb",
245116
+ "xlsm",
245117
+ "xlsx",
245118
+ "xlt",
245119
+ "xltm",
245120
+ "xltx",
245121
+ "xm",
245122
+ "xmind",
245123
+ "xpi",
245124
+ "xpm",
245125
+ "xwd",
245126
+ "xz",
245127
+ "z",
245128
+ "zip",
245129
+ "zipx"
245130
+ ]);
245131
+ var isBinaryPath = (filePath) => binaryExtensions.has(sp2.extname(filePath).slice(1).toLowerCase());
245132
+ var foreach = (val, fn9) => {
245133
+ if (val instanceof Set) {
245134
+ val.forEach(fn9);
245135
+ } else {
245136
+ fn9(val);
245137
+ }
245138
+ };
245139
+ var addAndConvert = (main, prop, item) => {
245140
+ let container = main[prop];
245141
+ if (!(container instanceof Set)) {
245142
+ main[prop] = container = new Set([container]);
245143
+ }
245144
+ container.add(item);
245145
+ };
245146
+ var clearItem = (cont) => (key2) => {
245147
+ const set2 = cont[key2];
245148
+ if (set2 instanceof Set) {
245149
+ set2.clear();
245150
+ } else {
245151
+ delete cont[key2];
245152
+ }
245153
+ };
245154
+ var delFromSet = (main, prop, item) => {
245155
+ const container = main[prop];
245156
+ if (container instanceof Set) {
245157
+ container.delete(item);
245158
+ } else if (container === item) {
245159
+ delete main[prop];
245160
+ }
245161
+ };
245162
+ var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
245163
+ var FsWatchInstances = new Map;
245164
+ function createFsWatchInstance(path19, options8, listener, errHandler, emitRaw) {
245165
+ const handleEvent = (rawEvent, evPath) => {
245166
+ listener(path19);
245167
+ emitRaw(rawEvent, evPath, { watchedPath: path19 });
245168
+ if (evPath && path19 !== evPath) {
245169
+ fsWatchBroadcast(sp2.resolve(path19, evPath), KEY_LISTENERS, sp2.join(path19, evPath));
245170
+ }
245171
+ };
245172
+ try {
245173
+ return fs_watch(path19, {
245174
+ persistent: options8.persistent
245175
+ }, handleEvent);
245176
+ } catch (error48) {
245177
+ errHandler(error48);
245178
+ return;
245179
+ }
245180
+ }
245181
+ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
245182
+ const cont = FsWatchInstances.get(fullPath);
245183
+ if (!cont)
245184
+ return;
245185
+ foreach(cont[listenerType], (listener) => {
245186
+ listener(val1, val2, val3);
245187
+ });
245188
+ };
245189
+ var setFsWatchListener = (path19, fullPath, options8, handlers) => {
245190
+ const { listener, errHandler, rawEmitter } = handlers;
245191
+ let cont = FsWatchInstances.get(fullPath);
245192
+ let watcher;
245193
+ if (!options8.persistent) {
245194
+ watcher = createFsWatchInstance(path19, options8, listener, errHandler, rawEmitter);
245195
+ if (!watcher)
245196
+ return;
245197
+ return watcher.close.bind(watcher);
245198
+ }
245199
+ if (cont) {
245200
+ addAndConvert(cont, KEY_LISTENERS, listener);
245201
+ addAndConvert(cont, KEY_ERR, errHandler);
245202
+ addAndConvert(cont, KEY_RAW, rawEmitter);
245203
+ } else {
245204
+ watcher = createFsWatchInstance(path19, options8, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
245205
+ if (!watcher)
245206
+ return;
245207
+ watcher.on(EV.ERROR, async (error48) => {
245208
+ const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
245209
+ if (cont)
245210
+ cont.watcherUnusable = true;
245211
+ if (isWindows4 && error48.code === "EPERM") {
245212
+ try {
245213
+ const fd = await open2(path19, "r");
245214
+ await fd.close();
245215
+ broadcastErr(error48);
245216
+ } catch (err) {}
245217
+ } else {
245218
+ broadcastErr(error48);
245219
+ }
245220
+ });
245221
+ cont = {
245222
+ listeners: listener,
245223
+ errHandlers: errHandler,
245224
+ rawEmitters: rawEmitter,
245225
+ watcher
245226
+ };
245227
+ FsWatchInstances.set(fullPath, cont);
245228
+ }
245229
+ return () => {
245230
+ delFromSet(cont, KEY_LISTENERS, listener);
245231
+ delFromSet(cont, KEY_ERR, errHandler);
245232
+ delFromSet(cont, KEY_RAW, rawEmitter);
245233
+ if (isEmptySet(cont.listeners)) {
245234
+ cont.watcher.close();
245235
+ FsWatchInstances.delete(fullPath);
245236
+ HANDLER_KEYS2.forEach(clearItem(cont));
245237
+ cont.watcher = undefined;
245238
+ Object.freeze(cont);
245239
+ }
245240
+ };
245241
+ };
245242
+ var FsWatchFileInstances = new Map;
245243
+ var setFsWatchFileListener = (path19, fullPath, options8, handlers) => {
245244
+ const { listener, rawEmitter } = handlers;
245245
+ let cont = FsWatchFileInstances.get(fullPath);
245246
+ const copts = cont && cont.options;
245247
+ if (copts && (copts.persistent < options8.persistent || copts.interval > options8.interval)) {
245248
+ unwatchFile(fullPath);
245249
+ cont = undefined;
245250
+ }
245251
+ if (cont) {
245252
+ addAndConvert(cont, KEY_LISTENERS, listener);
245253
+ addAndConvert(cont, KEY_RAW, rawEmitter);
245254
+ } else {
245255
+ cont = {
245256
+ listeners: listener,
245257
+ rawEmitters: rawEmitter,
245258
+ options: options8,
245259
+ watcher: watchFile(fullPath, options8, (curr, prev) => {
245260
+ foreach(cont.rawEmitters, (rawEmitter2) => {
245261
+ rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
245262
+ });
245263
+ const currmtime = curr.mtimeMs;
245264
+ if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
245265
+ foreach(cont.listeners, (listener2) => listener2(path19, curr));
245266
+ }
245267
+ })
245268
+ };
245269
+ FsWatchFileInstances.set(fullPath, cont);
245270
+ }
245271
+ return () => {
245272
+ delFromSet(cont, KEY_LISTENERS, listener);
245273
+ delFromSet(cont, KEY_RAW, rawEmitter);
245274
+ if (isEmptySet(cont.listeners)) {
245275
+ FsWatchFileInstances.delete(fullPath);
245276
+ unwatchFile(fullPath);
245277
+ cont.options = cont.watcher = undefined;
245278
+ Object.freeze(cont);
245279
+ }
245280
+ };
245281
+ };
245282
+
245283
+ class NodeFsHandler {
245284
+ fsw;
245285
+ _boundHandleError;
245286
+ constructor(fsW) {
245287
+ this.fsw = fsW;
245288
+ this._boundHandleError = (error48) => fsW._handleError(error48);
245289
+ }
245290
+ _watchWithNodeFs(path19, listener) {
245291
+ const opts = this.fsw.options;
245292
+ const directory = sp2.dirname(path19);
245293
+ const basename5 = sp2.basename(path19);
245294
+ const parent = this.fsw._getWatchedDir(directory);
245295
+ parent.add(basename5);
245296
+ const absolutePath = sp2.resolve(path19);
245297
+ const options8 = {
245298
+ persistent: opts.persistent
245299
+ };
245300
+ if (!listener)
245301
+ listener = EMPTY_FN;
245302
+ let closer;
245303
+ if (opts.usePolling) {
245304
+ const enableBin = opts.interval !== opts.binaryInterval;
245305
+ options8.interval = enableBin && isBinaryPath(basename5) ? opts.binaryInterval : opts.interval;
245306
+ closer = setFsWatchFileListener(path19, absolutePath, options8, {
245307
+ listener,
245308
+ rawEmitter: this.fsw._emitRaw
245309
+ });
245310
+ } else {
245311
+ closer = setFsWatchListener(path19, absolutePath, options8, {
245312
+ listener,
245313
+ errHandler: this._boundHandleError,
245314
+ rawEmitter: this.fsw._emitRaw
245315
+ });
245316
+ }
245317
+ return closer;
245318
+ }
245319
+ _handleFile(file2, stats, initialAdd) {
245320
+ if (this.fsw.closed) {
245321
+ return;
245322
+ }
245323
+ const dirname13 = sp2.dirname(file2);
245324
+ const basename5 = sp2.basename(file2);
245325
+ const parent = this.fsw._getWatchedDir(dirname13);
245326
+ let prevStats = stats;
245327
+ if (parent.has(basename5))
245328
+ return;
245329
+ const listener = async (path19, newStats) => {
245330
+ if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
245331
+ return;
245332
+ if (!newStats || newStats.mtimeMs === 0) {
245333
+ try {
245334
+ const newStats2 = await stat3(file2);
245335
+ if (this.fsw.closed)
245336
+ return;
245337
+ const at13 = newStats2.atimeMs;
245338
+ const mt12 = newStats2.mtimeMs;
245339
+ if (!at13 || at13 <= mt12 || mt12 !== prevStats.mtimeMs) {
245340
+ this.fsw._emit(EV.CHANGE, file2, newStats2);
245341
+ }
245342
+ if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
245343
+ this.fsw._closeFile(path19);
245344
+ prevStats = newStats2;
245345
+ const closer2 = this._watchWithNodeFs(file2, listener);
245346
+ if (closer2)
245347
+ this.fsw._addPathCloser(path19, closer2);
245348
+ } else {
245349
+ prevStats = newStats2;
245350
+ }
245351
+ } catch (error48) {
245352
+ this.fsw._remove(dirname13, basename5);
245353
+ }
245354
+ } else if (parent.has(basename5)) {
245355
+ const at13 = newStats.atimeMs;
245356
+ const mt12 = newStats.mtimeMs;
245357
+ if (!at13 || at13 <= mt12 || mt12 !== prevStats.mtimeMs) {
245358
+ this.fsw._emit(EV.CHANGE, file2, newStats);
245359
+ }
245360
+ prevStats = newStats;
245361
+ }
245362
+ };
245363
+ const closer = this._watchWithNodeFs(file2, listener);
245364
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file2)) {
245365
+ if (!this.fsw._throttle(EV.ADD, file2, 0))
245366
+ return;
245367
+ this.fsw._emit(EV.ADD, file2, stats);
245368
+ }
245369
+ return closer;
245370
+ }
245371
+ async _handleSymlink(entry, directory, path19, item) {
245372
+ if (this.fsw.closed) {
245373
+ return;
245374
+ }
245375
+ const full = entry.fullPath;
245376
+ const dir = this.fsw._getWatchedDir(directory);
245377
+ if (!this.fsw.options.followSymlinks) {
245378
+ this.fsw._incrReadyCount();
245379
+ let linkPath;
245380
+ try {
245381
+ linkPath = await fsrealpath(path19);
245382
+ } catch (e8) {
245383
+ this.fsw._emitReady();
245384
+ return true;
245385
+ }
245386
+ if (this.fsw.closed)
245387
+ return;
245388
+ if (dir.has(item)) {
245389
+ if (this.fsw._symlinkPaths.get(full) !== linkPath) {
245390
+ this.fsw._symlinkPaths.set(full, linkPath);
245391
+ this.fsw._emit(EV.CHANGE, path19, entry.stats);
245392
+ }
245393
+ } else {
245394
+ dir.add(item);
245395
+ this.fsw._symlinkPaths.set(full, linkPath);
245396
+ this.fsw._emit(EV.ADD, path19, entry.stats);
245397
+ }
245398
+ this.fsw._emitReady();
245399
+ return true;
245400
+ }
245401
+ if (this.fsw._symlinkPaths.has(full)) {
245402
+ return true;
245403
+ }
245404
+ this.fsw._symlinkPaths.set(full, true);
245405
+ }
245406
+ _handleRead(directory, initialAdd, wh2, target, dir, depth, throttler) {
245407
+ directory = sp2.join(directory, "");
245408
+ const throttleKey = target ? `${directory}:${target}` : directory;
245409
+ throttler = this.fsw._throttle("readdir", throttleKey, 1000);
245410
+ if (!throttler)
245411
+ return;
245412
+ const previous = this.fsw._getWatchedDir(wh2.path);
245413
+ const current = new Set;
245414
+ let stream = this.fsw._readdirp(directory, {
245415
+ fileFilter: (entry) => wh2.filterPath(entry),
245416
+ directoryFilter: (entry) => wh2.filterDir(entry)
245417
+ });
245418
+ if (!stream)
245419
+ return;
245420
+ stream.on(STR_DATA, async (entry) => {
245421
+ if (this.fsw.closed) {
245422
+ stream = undefined;
245423
+ return;
245424
+ }
245425
+ const item = entry.path;
245426
+ let path19 = sp2.join(directory, item);
245427
+ current.add(item);
245428
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path19, item)) {
245429
+ return;
245430
+ }
245431
+ if (this.fsw.closed) {
245432
+ stream = undefined;
245433
+ return;
245434
+ }
245435
+ if (item === target || !target && !previous.has(item)) {
245436
+ this.fsw._incrReadyCount();
245437
+ path19 = sp2.join(dir, sp2.relative(dir, path19));
245438
+ this._addToNodeFs(path19, initialAdd, wh2, depth + 1);
245439
+ }
245440
+ }).on(EV.ERROR, this._boundHandleError);
245441
+ return new Promise((resolve7, reject) => {
245442
+ if (!stream)
245443
+ return reject();
245444
+ stream.once(STR_END, () => {
245445
+ if (this.fsw.closed) {
245446
+ stream = undefined;
245447
+ return;
245448
+ }
245449
+ const wasThrottled = throttler ? throttler.clear() : false;
245450
+ resolve7(undefined);
245451
+ previous.getChildren().filter((item) => {
245452
+ return item !== directory && !current.has(item);
245453
+ }).forEach((item) => {
245454
+ this.fsw._remove(directory, item);
245455
+ });
245456
+ stream = undefined;
245457
+ if (wasThrottled)
245458
+ this._handleRead(directory, false, wh2, target, dir, depth, throttler);
245459
+ });
245460
+ });
245461
+ }
245462
+ async _handleDir(dir, stats, initialAdd, depth, target, wh2, realpath2) {
245463
+ const parentDir = this.fsw._getWatchedDir(sp2.dirname(dir));
245464
+ const tracked = parentDir.has(sp2.basename(dir));
245465
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
245466
+ this.fsw._emit(EV.ADD_DIR, dir, stats);
245467
+ }
245468
+ parentDir.add(sp2.basename(dir));
245469
+ this.fsw._getWatchedDir(dir);
245470
+ let throttler;
245471
+ let closer;
245472
+ const oDepth = this.fsw.options.depth;
245473
+ if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath2)) {
245474
+ if (!target) {
245475
+ await this._handleRead(dir, initialAdd, wh2, target, dir, depth, throttler);
245476
+ if (this.fsw.closed)
245477
+ return;
245478
+ }
245479
+ closer = this._watchWithNodeFs(dir, (dirPath, stats2) => {
245480
+ if (stats2 && stats2.mtimeMs === 0)
245481
+ return;
245482
+ this._handleRead(dirPath, false, wh2, target, dir, depth, throttler);
245483
+ });
245484
+ }
245485
+ return closer;
244594
245486
  }
244595
- const debouncedOnChange = import_debounce.default(async () => {
245487
+ async _addToNodeFs(path19, initialAdd, priorWh, depth, target) {
245488
+ const ready = this.fsw._emitReady;
245489
+ if (this.fsw._isIgnored(path19) || this.fsw.closed) {
245490
+ ready();
245491
+ return false;
245492
+ }
245493
+ const wh2 = this.fsw._getWatchHelpers(path19);
245494
+ if (priorWh) {
245495
+ wh2.filterPath = (entry) => priorWh.filterPath(entry);
245496
+ wh2.filterDir = (entry) => priorWh.filterDir(entry);
245497
+ }
244596
245498
  try {
244597
- await onChange();
245499
+ const stats = await statMethods[wh2.statMethod](wh2.watchPath);
245500
+ if (this.fsw.closed)
245501
+ return;
245502
+ if (this.fsw._isIgnored(wh2.watchPath, stats)) {
245503
+ ready();
245504
+ return false;
245505
+ }
245506
+ const follow = this.fsw.options.followSymlinks;
245507
+ let closer;
245508
+ if (stats.isDirectory()) {
245509
+ const absPath = sp2.resolve(path19);
245510
+ const targetPath = follow ? await fsrealpath(path19) : path19;
245511
+ if (this.fsw.closed)
245512
+ return;
245513
+ closer = await this._handleDir(wh2.watchPath, stats, initialAdd, depth, target, wh2, targetPath);
245514
+ if (this.fsw.closed)
245515
+ return;
245516
+ if (absPath !== targetPath && targetPath !== undefined) {
245517
+ this.fsw._symlinkPaths.set(absPath, targetPath);
245518
+ }
245519
+ } else if (stats.isSymbolicLink()) {
245520
+ const targetPath = follow ? await fsrealpath(path19) : path19;
245521
+ if (this.fsw.closed)
245522
+ return;
245523
+ const parent = sp2.dirname(wh2.watchPath);
245524
+ this.fsw._getWatchedDir(parent).add(wh2.watchPath);
245525
+ this.fsw._emit(EV.ADD, wh2.watchPath, stats);
245526
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path19, wh2, targetPath);
245527
+ if (this.fsw.closed)
245528
+ return;
245529
+ if (targetPath !== undefined) {
245530
+ this.fsw._symlinkPaths.set(sp2.resolve(path19), targetPath);
245531
+ }
245532
+ } else {
245533
+ closer = this._handleFile(wh2.watchPath, stats, initialAdd);
245534
+ }
245535
+ ready();
245536
+ if (closer)
245537
+ this.fsw._addPathCloser(path19, closer);
245538
+ return false;
244598
245539
  } catch (error48) {
244599
- logger.error(`[dev-server] Watch handler failed for ${dir}`, error48 instanceof Error ? error48 : undefined);
245540
+ if (this.fsw._handleError(error48)) {
245541
+ ready();
245542
+ return path19;
245543
+ }
245544
+ }
245545
+ }
245546
+ }
245547
+
245548
+ // node_modules/chokidar/index.js
245549
+ /*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) */
245550
+ var SLASH = "/";
245551
+ var SLASH_SLASH = "//";
245552
+ var ONE_DOT = ".";
245553
+ var TWO_DOTS = "..";
245554
+ var STRING_TYPE = "string";
245555
+ var BACK_SLASH_RE = /\\/g;
245556
+ var DOUBLE_SLASH_RE = /\/\//g;
245557
+ var DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
245558
+ var REPLACER_RE = /^\.[/\\]/;
245559
+ function arrify(item) {
245560
+ return Array.isArray(item) ? item : [item];
245561
+ }
245562
+ var isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
245563
+ function createPattern(matcher) {
245564
+ if (typeof matcher === "function")
245565
+ return matcher;
245566
+ if (typeof matcher === "string")
245567
+ return (string4) => matcher === string4;
245568
+ if (matcher instanceof RegExp)
245569
+ return (string4) => matcher.test(string4);
245570
+ if (typeof matcher === "object" && matcher !== null) {
245571
+ return (string4) => {
245572
+ if (matcher.path === string4)
245573
+ return true;
245574
+ if (matcher.recursive) {
245575
+ const relative4 = sp3.relative(matcher.path, string4);
245576
+ if (!relative4) {
245577
+ return false;
245578
+ }
245579
+ return !relative4.startsWith("..") && !sp3.isAbsolute(relative4);
245580
+ }
245581
+ return false;
245582
+ };
245583
+ }
245584
+ return () => false;
245585
+ }
245586
+ function normalizePath(path19) {
245587
+ if (typeof path19 !== "string")
245588
+ throw new Error("string expected");
245589
+ path19 = sp3.normalize(path19);
245590
+ path19 = path19.replace(/\\/g, "/");
245591
+ let prepend = false;
245592
+ if (path19.startsWith("//"))
245593
+ prepend = true;
245594
+ path19 = path19.replace(DOUBLE_SLASH_RE, "/");
245595
+ if (prepend)
245596
+ path19 = "/" + path19;
245597
+ return path19;
245598
+ }
245599
+ function matchPatterns(patterns, testString, stats) {
245600
+ const path19 = normalizePath(testString);
245601
+ for (let index = 0;index < patterns.length; index++) {
245602
+ const pattern = patterns[index];
245603
+ if (pattern(path19, stats)) {
245604
+ return true;
245605
+ }
245606
+ }
245607
+ return false;
245608
+ }
245609
+ function anymatch(matchers, testString) {
245610
+ if (matchers == null) {
245611
+ throw new TypeError("anymatch: specify first argument");
245612
+ }
245613
+ const matchersArray = arrify(matchers);
245614
+ const patterns = matchersArray.map((matcher) => createPattern(matcher));
245615
+ if (testString == null) {
245616
+ return (testString2, stats) => {
245617
+ return matchPatterns(patterns, testString2, stats);
245618
+ };
245619
+ }
245620
+ return matchPatterns(patterns, testString);
245621
+ }
245622
+ var unifyPaths = (paths_) => {
245623
+ const paths = arrify(paths_).flat();
245624
+ if (!paths.every((p4) => typeof p4 === STRING_TYPE)) {
245625
+ throw new TypeError(`Non-string provided as watch path: ${paths}`);
245626
+ }
245627
+ return paths.map(normalizePathToUnix);
245628
+ };
245629
+ var toUnix = (string4) => {
245630
+ let str = string4.replace(BACK_SLASH_RE, SLASH);
245631
+ let prepend = false;
245632
+ if (str.startsWith(SLASH_SLASH)) {
245633
+ prepend = true;
245634
+ }
245635
+ str = str.replace(DOUBLE_SLASH_RE, SLASH);
245636
+ if (prepend) {
245637
+ str = SLASH + str;
245638
+ }
245639
+ return str;
245640
+ };
245641
+ var normalizePathToUnix = (path19) => toUnix(sp3.normalize(toUnix(path19)));
245642
+ var normalizeIgnored = (cwd = "") => (path19) => {
245643
+ if (typeof path19 === "string") {
245644
+ return normalizePathToUnix(sp3.isAbsolute(path19) ? path19 : sp3.join(cwd, path19));
245645
+ } else {
245646
+ return path19;
245647
+ }
245648
+ };
245649
+ var getAbsolutePath = (path19, cwd) => {
245650
+ if (sp3.isAbsolute(path19)) {
245651
+ return path19;
245652
+ }
245653
+ return sp3.join(cwd, path19);
245654
+ };
245655
+ var EMPTY_SET = Object.freeze(new Set);
245656
+
245657
+ class DirEntry {
245658
+ path;
245659
+ _removeWatcher;
245660
+ items;
245661
+ constructor(dir, removeWatcher) {
245662
+ this.path = dir;
245663
+ this._removeWatcher = removeWatcher;
245664
+ this.items = new Set;
245665
+ }
245666
+ add(item) {
245667
+ const { items } = this;
245668
+ if (!items)
245669
+ return;
245670
+ if (item !== ONE_DOT && item !== TWO_DOTS)
245671
+ items.add(item);
245672
+ }
245673
+ async remove(item) {
245674
+ const { items } = this;
245675
+ if (!items)
245676
+ return;
245677
+ items.delete(item);
245678
+ if (items.size > 0)
245679
+ return;
245680
+ const dir = this.path;
245681
+ try {
245682
+ await readdir3(dir);
245683
+ } catch (err) {
245684
+ if (this._removeWatcher) {
245685
+ this._removeWatcher(sp3.dirname(dir), sp3.basename(dir));
245686
+ }
245687
+ }
245688
+ }
245689
+ has(item) {
245690
+ const { items } = this;
245691
+ if (!items)
245692
+ return;
245693
+ return items.has(item);
245694
+ }
245695
+ getChildren() {
245696
+ const { items } = this;
245697
+ if (!items)
245698
+ return [];
245699
+ return [...items.values()];
245700
+ }
245701
+ dispose() {
245702
+ this.items.clear();
245703
+ this.path = "";
245704
+ this._removeWatcher = EMPTY_FN;
245705
+ this.items = EMPTY_SET;
245706
+ Object.freeze(this);
245707
+ }
245708
+ }
245709
+ var STAT_METHOD_F = "stat";
245710
+ var STAT_METHOD_L = "lstat";
245711
+
245712
+ class WatchHelper {
245713
+ fsw;
245714
+ path;
245715
+ watchPath;
245716
+ fullWatchPath;
245717
+ dirParts;
245718
+ followSymlinks;
245719
+ statMethod;
245720
+ constructor(path19, follow, fsw) {
245721
+ this.fsw = fsw;
245722
+ const watchPath = path19;
245723
+ this.path = path19 = path19.replace(REPLACER_RE, "");
245724
+ this.watchPath = watchPath;
245725
+ this.fullWatchPath = sp3.resolve(watchPath);
245726
+ this.dirParts = [];
245727
+ this.dirParts.forEach((parts) => {
245728
+ if (parts.length > 1)
245729
+ parts.pop();
245730
+ });
245731
+ this.followSymlinks = follow;
245732
+ this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
245733
+ }
245734
+ entryPath(entry) {
245735
+ return sp3.join(this.watchPath, sp3.relative(this.watchPath, entry.fullPath));
245736
+ }
245737
+ filterPath(entry) {
245738
+ const { stats } = entry;
245739
+ if (stats && stats.isSymbolicLink())
245740
+ return this.filterDir(entry);
245741
+ const resolvedPath = this.entryPath(entry);
245742
+ return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
245743
+ }
245744
+ filterDir(entry) {
245745
+ return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
245746
+ }
245747
+ }
245748
+
245749
+ class FSWatcher extends EventEmitter3 {
245750
+ closed;
245751
+ options;
245752
+ _closers;
245753
+ _ignoredPaths;
245754
+ _throttled;
245755
+ _streams;
245756
+ _symlinkPaths;
245757
+ _watched;
245758
+ _pendingWrites;
245759
+ _pendingUnlinks;
245760
+ _readyCount;
245761
+ _emitReady;
245762
+ _closePromise;
245763
+ _userIgnored;
245764
+ _readyEmitted;
245765
+ _emitRaw;
245766
+ _boundRemove;
245767
+ _nodeFsHandler;
245768
+ constructor(_opts = {}) {
245769
+ super();
245770
+ this.closed = false;
245771
+ this._closers = new Map;
245772
+ this._ignoredPaths = new Set;
245773
+ this._throttled = new Map;
245774
+ this._streams = new Set;
245775
+ this._symlinkPaths = new Map;
245776
+ this._watched = new Map;
245777
+ this._pendingWrites = new Map;
245778
+ this._pendingUnlinks = new Map;
245779
+ this._readyCount = 0;
245780
+ this._readyEmitted = false;
245781
+ const awf = _opts.awaitWriteFinish;
245782
+ const DEF_AWF = { stabilityThreshold: 2000, pollInterval: 100 };
245783
+ const opts = {
245784
+ persistent: true,
245785
+ ignoreInitial: false,
245786
+ ignorePermissionErrors: false,
245787
+ interval: 100,
245788
+ binaryInterval: 300,
245789
+ followSymlinks: true,
245790
+ usePolling: false,
245791
+ atomic: true,
245792
+ ..._opts,
245793
+ ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
245794
+ awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === "object" ? { ...DEF_AWF, ...awf } : false
245795
+ };
245796
+ if (isIBMi)
245797
+ opts.usePolling = true;
245798
+ if (opts.atomic === undefined)
245799
+ opts.atomic = !opts.usePolling;
245800
+ const envPoll = process.env.CHOKIDAR_USEPOLLING;
245801
+ if (envPoll !== undefined) {
245802
+ const envLower = envPoll.toLowerCase();
245803
+ if (envLower === "false" || envLower === "0")
245804
+ opts.usePolling = false;
245805
+ else if (envLower === "true" || envLower === "1")
245806
+ opts.usePolling = true;
245807
+ else
245808
+ opts.usePolling = !!envLower;
245809
+ }
245810
+ const envInterval = process.env.CHOKIDAR_INTERVAL;
245811
+ if (envInterval)
245812
+ opts.interval = Number.parseInt(envInterval, 10);
245813
+ let readyCalls = 0;
245814
+ this._emitReady = () => {
245815
+ readyCalls++;
245816
+ if (readyCalls >= this._readyCount) {
245817
+ this._emitReady = EMPTY_FN;
245818
+ this._readyEmitted = true;
245819
+ process.nextTick(() => this.emit(EVENTS.READY));
245820
+ }
245821
+ };
245822
+ this._emitRaw = (...args) => this.emit(EVENTS.RAW, ...args);
245823
+ this._boundRemove = this._remove.bind(this);
245824
+ this.options = opts;
245825
+ this._nodeFsHandler = new NodeFsHandler(this);
245826
+ Object.freeze(opts);
245827
+ }
245828
+ _addIgnoredPath(matcher) {
245829
+ if (isMatcherObject(matcher)) {
245830
+ for (const ignored of this._ignoredPaths) {
245831
+ if (isMatcherObject(ignored) && ignored.path === matcher.path && ignored.recursive === matcher.recursive) {
245832
+ return;
245833
+ }
245834
+ }
245835
+ }
245836
+ this._ignoredPaths.add(matcher);
245837
+ }
245838
+ _removeIgnoredPath(matcher) {
245839
+ this._ignoredPaths.delete(matcher);
245840
+ if (typeof matcher === "string") {
245841
+ for (const ignored of this._ignoredPaths) {
245842
+ if (isMatcherObject(ignored) && ignored.path === matcher) {
245843
+ this._ignoredPaths.delete(ignored);
245844
+ }
245845
+ }
245846
+ }
245847
+ }
245848
+ add(paths_, _origAdd, _internal) {
245849
+ const { cwd } = this.options;
245850
+ this.closed = false;
245851
+ this._closePromise = undefined;
245852
+ let paths = unifyPaths(paths_);
245853
+ if (cwd) {
245854
+ paths = paths.map((path19) => {
245855
+ const absPath = getAbsolutePath(path19, cwd);
245856
+ return absPath;
245857
+ });
245858
+ }
245859
+ paths.forEach((path19) => {
245860
+ this._removeIgnoredPath(path19);
245861
+ });
245862
+ this._userIgnored = undefined;
245863
+ if (!this._readyCount)
245864
+ this._readyCount = 0;
245865
+ this._readyCount += paths.length;
245866
+ Promise.all(paths.map(async (path19) => {
245867
+ const res = await this._nodeFsHandler._addToNodeFs(path19, !_internal, undefined, 0, _origAdd);
245868
+ if (res)
245869
+ this._emitReady();
245870
+ return res;
245871
+ })).then((results) => {
245872
+ if (this.closed)
245873
+ return;
245874
+ results.forEach((item) => {
245875
+ if (item)
245876
+ this.add(sp3.dirname(item), sp3.basename(_origAdd || item));
245877
+ });
245878
+ });
245879
+ return this;
245880
+ }
245881
+ unwatch(paths_) {
245882
+ if (this.closed)
245883
+ return this;
245884
+ const paths = unifyPaths(paths_);
245885
+ const { cwd } = this.options;
245886
+ paths.forEach((path19) => {
245887
+ if (!sp3.isAbsolute(path19) && !this._closers.has(path19)) {
245888
+ if (cwd)
245889
+ path19 = sp3.join(cwd, path19);
245890
+ path19 = sp3.resolve(path19);
245891
+ }
245892
+ this._closePath(path19);
245893
+ this._addIgnoredPath(path19);
245894
+ if (this._watched.has(path19)) {
245895
+ this._addIgnoredPath({
245896
+ path: path19,
245897
+ recursive: true
245898
+ });
245899
+ }
245900
+ this._userIgnored = undefined;
245901
+ });
245902
+ return this;
245903
+ }
245904
+ close() {
245905
+ if (this._closePromise) {
245906
+ return this._closePromise;
245907
+ }
245908
+ this.closed = true;
245909
+ this.removeAllListeners();
245910
+ const closers = [];
245911
+ this._closers.forEach((closerList) => closerList.forEach((closer) => {
245912
+ const promise2 = closer();
245913
+ if (promise2 instanceof Promise)
245914
+ closers.push(promise2);
245915
+ }));
245916
+ this._streams.forEach((stream) => stream.destroy());
245917
+ this._userIgnored = undefined;
245918
+ this._readyCount = 0;
245919
+ this._readyEmitted = false;
245920
+ this._watched.forEach((dirent) => dirent.dispose());
245921
+ this._closers.clear();
245922
+ this._watched.clear();
245923
+ this._streams.clear();
245924
+ this._symlinkPaths.clear();
245925
+ this._throttled.clear();
245926
+ this._closePromise = closers.length ? Promise.all(closers).then(() => {
245927
+ return;
245928
+ }) : Promise.resolve();
245929
+ return this._closePromise;
245930
+ }
245931
+ getWatched() {
245932
+ const watchList = {};
245933
+ this._watched.forEach((entry, dir) => {
245934
+ const key2 = this.options.cwd ? sp3.relative(this.options.cwd, dir) : dir;
245935
+ const index = key2 || ONE_DOT;
245936
+ watchList[index] = entry.getChildren().sort();
245937
+ });
245938
+ return watchList;
245939
+ }
245940
+ emitWithAll(event, args) {
245941
+ this.emit(event, ...args);
245942
+ if (event !== EVENTS.ERROR)
245943
+ this.emit(EVENTS.ALL, event, ...args);
245944
+ }
245945
+ async _emit(event, path19, stats) {
245946
+ if (this.closed)
245947
+ return;
245948
+ const opts = this.options;
245949
+ if (isWindows4)
245950
+ path19 = sp3.normalize(path19);
245951
+ if (opts.cwd)
245952
+ path19 = sp3.relative(opts.cwd, path19);
245953
+ const args = [path19];
245954
+ if (stats != null)
245955
+ args.push(stats);
245956
+ const awf = opts.awaitWriteFinish;
245957
+ let pw;
245958
+ if (awf && (pw = this._pendingWrites.get(path19))) {
245959
+ pw.lastChange = new Date;
245960
+ return this;
245961
+ }
245962
+ if (opts.atomic) {
245963
+ if (event === EVENTS.UNLINK) {
245964
+ this._pendingUnlinks.set(path19, [event, ...args]);
245965
+ setTimeout(() => {
245966
+ this._pendingUnlinks.forEach((entry, path20) => {
245967
+ this.emit(...entry);
245968
+ this.emit(EVENTS.ALL, ...entry);
245969
+ this._pendingUnlinks.delete(path20);
245970
+ });
245971
+ }, typeof opts.atomic === "number" ? opts.atomic : 100);
245972
+ return this;
245973
+ }
245974
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path19)) {
245975
+ event = EVENTS.CHANGE;
245976
+ this._pendingUnlinks.delete(path19);
245977
+ }
245978
+ }
245979
+ if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
245980
+ const awfEmit = (err, stats2) => {
245981
+ if (err) {
245982
+ event = EVENTS.ERROR;
245983
+ args[0] = err;
245984
+ this.emitWithAll(event, args);
245985
+ } else if (stats2) {
245986
+ if (args.length > 1) {
245987
+ args[1] = stats2;
245988
+ } else {
245989
+ args.push(stats2);
245990
+ }
245991
+ this.emitWithAll(event, args);
245992
+ }
245993
+ };
245994
+ this._awaitWriteFinish(path19, awf.stabilityThreshold, event, awfEmit);
245995
+ return this;
245996
+ }
245997
+ if (event === EVENTS.CHANGE) {
245998
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path19, 50);
245999
+ if (isThrottled)
246000
+ return this;
246001
+ }
246002
+ if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
246003
+ const fullPath = opts.cwd ? sp3.join(opts.cwd, path19) : path19;
246004
+ let stats2;
246005
+ try {
246006
+ stats2 = await stat4(fullPath);
246007
+ } catch (err) {}
246008
+ if (!stats2 || this.closed)
246009
+ return;
246010
+ args.push(stats2);
246011
+ }
246012
+ this.emitWithAll(event, args);
246013
+ return this;
246014
+ }
246015
+ _handleError(error48) {
246016
+ const code2 = error48 && error48.code;
246017
+ if (error48 && code2 !== "ENOENT" && code2 !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code2 !== "EPERM" && code2 !== "EACCES")) {
246018
+ this.emit(EVENTS.ERROR, error48);
246019
+ }
246020
+ return error48 || this.closed;
246021
+ }
246022
+ _throttle(actionType, path19, timeout3) {
246023
+ if (!this._throttled.has(actionType)) {
246024
+ this._throttled.set(actionType, new Map);
246025
+ }
246026
+ const action = this._throttled.get(actionType);
246027
+ if (!action)
246028
+ throw new Error("invalid throttle");
246029
+ const actionPath = action.get(path19);
246030
+ if (actionPath) {
246031
+ actionPath.count++;
246032
+ return false;
246033
+ }
246034
+ let timeoutObject;
246035
+ const clear = () => {
246036
+ const item = action.get(path19);
246037
+ const count2 = item ? item.count : 0;
246038
+ action.delete(path19);
246039
+ clearTimeout(timeoutObject);
246040
+ if (item)
246041
+ clearTimeout(item.timeoutObject);
246042
+ return count2;
246043
+ };
246044
+ timeoutObject = setTimeout(clear, timeout3);
246045
+ const thr = { timeoutObject, clear, count: 0 };
246046
+ action.set(path19, thr);
246047
+ return thr;
246048
+ }
246049
+ _incrReadyCount() {
246050
+ return this._readyCount++;
246051
+ }
246052
+ _awaitWriteFinish(path19, threshold, event, awfEmit) {
246053
+ const awf = this.options.awaitWriteFinish;
246054
+ if (typeof awf !== "object")
246055
+ return;
246056
+ const pollInterval = awf.pollInterval;
246057
+ let timeoutHandler;
246058
+ let fullPath = path19;
246059
+ if (this.options.cwd && !sp3.isAbsolute(path19)) {
246060
+ fullPath = sp3.join(this.options.cwd, path19);
246061
+ }
246062
+ const now = new Date;
246063
+ const writes = this._pendingWrites;
246064
+ function awaitWriteFinishFn(prevStat) {
246065
+ statcb(fullPath, (err, curStat) => {
246066
+ if (err || !writes.has(path19)) {
246067
+ if (err && err.code !== "ENOENT")
246068
+ awfEmit(err);
246069
+ return;
246070
+ }
246071
+ const now2 = Number(new Date);
246072
+ if (prevStat && curStat.size !== prevStat.size) {
246073
+ writes.get(path19).lastChange = now2;
246074
+ }
246075
+ const pw = writes.get(path19);
246076
+ const df3 = now2 - pw.lastChange;
246077
+ if (df3 >= threshold) {
246078
+ writes.delete(path19);
246079
+ awfEmit(undefined, curStat);
246080
+ } else {
246081
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
246082
+ }
246083
+ });
246084
+ }
246085
+ if (!writes.has(path19)) {
246086
+ writes.set(path19, {
246087
+ lastChange: now,
246088
+ cancelWait: () => {
246089
+ writes.delete(path19);
246090
+ clearTimeout(timeoutHandler);
246091
+ return event;
246092
+ }
246093
+ });
246094
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
246095
+ }
246096
+ }
246097
+ _isIgnored(path19, stats) {
246098
+ if (this.options.atomic && DOT_RE.test(path19))
246099
+ return true;
246100
+ if (!this._userIgnored) {
246101
+ const { cwd } = this.options;
246102
+ const ign = this.options.ignored;
246103
+ const ignored = (ign || []).map(normalizeIgnored(cwd));
246104
+ const ignoredPaths = [...this._ignoredPaths];
246105
+ const list3 = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
246106
+ this._userIgnored = anymatch(list3, undefined);
246107
+ }
246108
+ return this._userIgnored(path19, stats);
246109
+ }
246110
+ _isntIgnored(path19, stat5) {
246111
+ return !this._isIgnored(path19, stat5);
246112
+ }
246113
+ _getWatchHelpers(path19) {
246114
+ return new WatchHelper(path19, this.options.followSymlinks, this);
246115
+ }
246116
+ _getWatchedDir(directory) {
246117
+ const dir = sp3.resolve(directory);
246118
+ if (!this._watched.has(dir))
246119
+ this._watched.set(dir, new DirEntry(dir, this._boundRemove));
246120
+ return this._watched.get(dir);
246121
+ }
246122
+ _hasReadPermissions(stats) {
246123
+ if (this.options.ignorePermissionErrors)
246124
+ return true;
246125
+ return Boolean(Number(stats.mode) & 256);
246126
+ }
246127
+ _remove(directory, item, isDirectory3) {
246128
+ const path19 = sp3.join(directory, item);
246129
+ const fullPath = sp3.resolve(path19);
246130
+ isDirectory3 = isDirectory3 != null ? isDirectory3 : this._watched.has(path19) || this._watched.has(fullPath);
246131
+ if (!this._throttle("remove", path19, 100))
246132
+ return;
246133
+ if (!isDirectory3 && this._watched.size === 1) {
246134
+ this.add(directory, item, true);
246135
+ }
246136
+ const wp5 = this._getWatchedDir(path19);
246137
+ const nestedDirectoryChildren = wp5.getChildren();
246138
+ nestedDirectoryChildren.forEach((nested) => this._remove(path19, nested));
246139
+ const parent = this._getWatchedDir(directory);
246140
+ const wasTracked = parent.has(item);
246141
+ parent.remove(item);
246142
+ if (this._symlinkPaths.has(fullPath)) {
246143
+ this._symlinkPaths.delete(fullPath);
246144
+ }
246145
+ let relPath = path19;
246146
+ if (this.options.cwd)
246147
+ relPath = sp3.relative(this.options.cwd, path19);
246148
+ if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
246149
+ const event = this._pendingWrites.get(relPath).cancelWait();
246150
+ if (event === EVENTS.ADD)
246151
+ return;
246152
+ }
246153
+ this._watched.delete(path19);
246154
+ this._watched.delete(fullPath);
246155
+ const eventName = isDirectory3 ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
246156
+ if (wasTracked && !this._isIgnored(path19))
246157
+ this._emit(eventName, path19);
246158
+ this._closePath(path19);
246159
+ }
246160
+ _closePath(path19) {
246161
+ this._closeFile(path19);
246162
+ const dir = sp3.dirname(path19);
246163
+ this._getWatchedDir(dir).remove(sp3.basename(path19));
246164
+ }
246165
+ _closeFile(path19) {
246166
+ const closers = this._closers.get(path19);
246167
+ if (!closers)
246168
+ return;
246169
+ closers.forEach((closer) => closer());
246170
+ this._closers.delete(path19);
246171
+ }
246172
+ _addPathCloser(path19, closer) {
246173
+ if (!closer)
246174
+ return;
246175
+ let list3 = this._closers.get(path19);
246176
+ if (!list3) {
246177
+ list3 = [];
246178
+ this._closers.set(path19, list3);
246179
+ }
246180
+ list3.push(closer);
246181
+ }
246182
+ _readdirp(root2, opts) {
246183
+ if (this.closed)
246184
+ return;
246185
+ const options8 = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
246186
+ let stream = readdirp(root2, options8);
246187
+ this._streams.add(stream);
246188
+ stream.once(STR_CLOSE, () => {
246189
+ stream = undefined;
246190
+ });
246191
+ stream.once(STR_END, () => {
246192
+ if (stream) {
246193
+ this._streams.delete(stream);
246194
+ stream = undefined;
246195
+ }
246196
+ });
246197
+ return stream;
246198
+ }
246199
+ }
246200
+ function watch(paths, options8 = {}) {
246201
+ const watcher = new FSWatcher(options8);
246202
+ watcher.add(paths);
246203
+ return watcher;
246204
+ }
246205
+
246206
+ // src/cli/dev/dev-server/watcher.ts
246207
+ var import_debounce = __toESM(require_debounce(), 1);
246208
+ var WATCH_DEBOUNCE_MS = 300;
246209
+ var WATCH_QUEUE_DELAY_MS = 500;
246210
+
246211
+ class WatchBase44 {
246212
+ itemsToWatch;
246213
+ onChange;
246214
+ logger;
246215
+ watchers = [];
246216
+ queueWaitForCreation = [];
246217
+ queueWaitForCreationTimeout = null;
246218
+ constructor(itemsToWatch, onChange, logger) {
246219
+ this.itemsToWatch = itemsToWatch;
246220
+ this.onChange = onChange;
246221
+ this.logger = logger;
246222
+ }
246223
+ async start() {
246224
+ if (this.watchers.length > 0 || this.queueWaitForCreation.length > 0) {
246225
+ return;
246226
+ }
246227
+ for (const item of this.itemsToWatch) {
246228
+ if (await pathExists(item.path)) {
246229
+ this.watchers.push(this.watchTarget(item));
246230
+ } else {
246231
+ this.queueWaitForCreation.push(item);
246232
+ }
246233
+ }
246234
+ this.watchCreationQueue();
246235
+ }
246236
+ async close() {
246237
+ if (this.queueWaitForCreationTimeout) {
246238
+ clearTimeout(this.queueWaitForCreationTimeout);
246239
+ this.queueWaitForCreationTimeout = null;
246240
+ }
246241
+ for (const watcher of this.watchers) {
246242
+ await watcher.close();
246243
+ }
246244
+ this.watchers = [];
246245
+ this.queueWaitForCreation = [];
246246
+ }
246247
+ watchCreationQueue() {
246248
+ if (this.queueWaitForCreationTimeout) {
246249
+ clearTimeout(this.queueWaitForCreationTimeout);
244600
246250
  }
244601
- }, WATCH_DEBOUNCE_MS);
244602
- return watch(dir, { recursive: true }, debouncedOnChange);
246251
+ this.queueWaitForCreationTimeout = setTimeout(async () => {
246252
+ const toRemove = [];
246253
+ for (const entry of this.queueWaitForCreation) {
246254
+ if (await pathExists(entry.path)) {
246255
+ this.watchers.push(this.watchTarget(entry));
246256
+ toRemove.push(entry);
246257
+ }
246258
+ }
246259
+ this.queueWaitForCreation = this.queueWaitForCreation.filter((entry) => !toRemove.includes(entry));
246260
+ if (this.queueWaitForCreation.length > 0) {
246261
+ this.watchCreationQueue();
246262
+ } else {
246263
+ this.queueWaitForCreationTimeout = null;
246264
+ }
246265
+ }, WATCH_QUEUE_DELAY_MS);
246266
+ }
246267
+ watchTarget(item) {
246268
+ const handler = import_debounce.default(async (_event, path19) => {
246269
+ try {
246270
+ await this.onChange(item.name, relative4(item.path, path19));
246271
+ } catch (err) {
246272
+ this.logger.error(`Reload failed for ${item.name}`, err instanceof Error ? err : undefined);
246273
+ }
246274
+ }, WATCH_DEBOUNCE_MS);
246275
+ const watcher = watch(item.path, {
246276
+ ignoreInitial: true
246277
+ });
246278
+ watcher.on("all", handler);
246279
+ watcher.on("unlinkDir", async (deletedPath) => {
246280
+ if (deletedPath !== item.path) {
246281
+ return;
246282
+ }
246283
+ await watcher.close();
246284
+ this.queueWaitForCreation.push(item);
246285
+ this.watchCreationQueue();
246286
+ setTimeout(() => {
246287
+ this.watchers = this.watchers.filter((watcher2) => !watcher2.closed);
246288
+ });
246289
+ });
246290
+ watcher.on("error", (err) => {
246291
+ this.logger.error(`[dev-server] Watch handler failed for ${item.path}`, err instanceof Error ? err : undefined);
246292
+ });
246293
+ return watcher;
246294
+ }
244603
246295
  }
246296
+
246297
+ // src/cli/dev/dev-server/main.ts
246298
+ var DEFAULT_PORT = 4400;
246299
+ var BASE44_APP_URL = "https://base44.app";
244604
246300
  async function createDevServer(options8) {
244605
246301
  const { port: userPort } = options8;
244606
246302
  const port = userPort ?? await getPorts({ port: DEFAULT_PORT });
@@ -244647,7 +246343,7 @@ async function createDevServer(options8) {
244647
246343
  devLogger.warn(`"${req.originalUrl}" is not supported in local development, passing call to production`);
244648
246344
  remoteProxy(req, res, next);
244649
246345
  });
244650
- const server = await new Promise((resolve6, reject) => {
246346
+ const server = await new Promise((resolve8, reject) => {
244651
246347
  const s5 = app.listen(port, "127.0.0.1", (err) => {
244652
246348
  if (err) {
244653
246349
  if ("code" in err && err.code === "EADDRINUSE") {
@@ -244656,7 +246352,7 @@ async function createDevServer(options8) {
244656
246352
  reject(err);
244657
246353
  }
244658
246354
  } else {
244659
- resolve6(s5);
246355
+ resolve8(s5);
244660
246356
  }
244661
246357
  });
244662
246358
  });
@@ -244664,20 +246360,27 @@ async function createDevServer(options8) {
244664
246360
  emitEntityEvent = (appId, entityName, event) => {
244665
246361
  broadcastEntityEvent(io6, appId, entityName, event);
244666
246362
  };
244667
- const configDir = dirname12(project2.configPath);
244668
- const functionsDir = join16(configDir, project2.functionsDir);
244669
- const functionsWatcher = await watchDir(functionsDir, async () => {
244670
- const { functions: functions2 } = await options8.loadResources();
244671
- functionManager.reload(functions2);
244672
- const names = functionManager.getFunctionNames();
244673
- if (names.length > 0) {
244674
- devLogger.log(`Reloaded functions: ${names.sort().join(", ")}`);
244675
- } else {
244676
- devLogger.log("All functions removed");
246363
+ const base44ConfigWatcher = new WatchBase44([
246364
+ {
246365
+ name: "functions",
246366
+ path: join18(dirname14(project2.configPath), project2.functionsDir)
246367
+ }
246368
+ ], async (name2) => {
246369
+ if (name2 === "functions") {
246370
+ const { functions: functions2 } = await options8.loadResources();
246371
+ const previousFunctionCount = functionManager.getFunctionNames().length;
246372
+ functionManager.reload(functions2);
246373
+ const names = functionManager.getFunctionNames();
246374
+ if (names.length > 0) {
246375
+ devLogger.log(`Reloaded functions: ${names.sort().join(", ")}`);
246376
+ } else if (previousFunctionCount > 0) {
246377
+ devLogger.log("All functions removed");
246378
+ }
244677
246379
  }
244678
246380
  }, devLogger);
246381
+ await base44ConfigWatcher.start();
244679
246382
  const shutdown = () => {
244680
- functionsWatcher?.close();
246383
+ base44ConfigWatcher.close();
244681
246384
  io6.close();
244682
246385
  functionManager.stopAll();
244683
246386
  server.close();
@@ -244708,7 +246411,7 @@ function getDevCommand(context) {
244708
246411
  }
244709
246412
 
244710
246413
  // src/cli/commands/project/eject.ts
244711
- import { resolve as resolve6 } from "node:path";
246414
+ import { resolve as resolve8 } from "node:path";
244712
246415
  var import_kebabCase2 = __toESM(require_kebabCase(), 1);
244713
246416
  async function eject(options8) {
244714
246417
  const projects = await listProjects();
@@ -244757,7 +246460,7 @@ async function eject(options8) {
244757
246460
  Ne("Operation cancelled.");
244758
246461
  throw new CLIExitError(0);
244759
246462
  }
244760
- const resolvedPath = resolve6(selectedPath);
246463
+ const resolvedPath = resolve8(selectedPath);
244761
246464
  await runTask("Downloading your project's code...", async (updateMessage) => {
244762
246465
  await createProjectFilesForExistingProject({
244763
246466
  projectId,
@@ -244833,7 +246536,7 @@ var import_detect_agent = __toESM(require_dist5(), 1);
244833
246536
  import { release, type } from "node:os";
244834
246537
 
244835
246538
  // node_modules/posthog-node/dist/extensions/error-tracking/modifiers/module.node.mjs
244836
- import { dirname as dirname13, posix, sep } from "path";
246539
+ import { dirname as dirname15, posix, sep } from "path";
244837
246540
  function createModulerModifier() {
244838
246541
  const getModuleFromFileName = createGetModuleFromFilename();
244839
246542
  return async (frames) => {
@@ -244842,12 +246545,12 @@ function createModulerModifier() {
244842
246545
  return frames;
244843
246546
  };
244844
246547
  }
244845
- function createGetModuleFromFilename(basePath = process.argv[1] ? dirname13(process.argv[1]) : process.cwd(), isWindows4 = sep === "\\") {
244846
- const normalizedBase = isWindows4 ? normalizeWindowsPath2(basePath) : basePath;
246548
+ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname15(process.argv[1]) : process.cwd(), isWindows5 = sep === "\\") {
246549
+ const normalizedBase = isWindows5 ? normalizeWindowsPath2(basePath) : basePath;
244847
246550
  return (filename) => {
244848
246551
  if (!filename)
244849
246552
  return;
244850
- const normalizedFilename = isWindows4 ? normalizeWindowsPath2(filename) : filename;
246553
+ const normalizedFilename = isWindows5 ? normalizeWindowsPath2(filename) : filename;
244851
246554
  let { dir, base: file2, ext } = posix.parse(normalizedFilename);
244852
246555
  if (ext === ".js" || ext === ".mjs" || ext === ".cjs")
244853
246556
  file2 = file2.slice(0, -1 * ext.length);
@@ -247120,14 +248823,14 @@ async function addSourceContext(frames) {
247120
248823
  return frames;
247121
248824
  }
247122
248825
  function getContextLinesFromFile(path19, ranges, output) {
247123
- return new Promise((resolve7) => {
248826
+ return new Promise((resolve9) => {
247124
248827
  const stream = createReadStream2(path19);
247125
248828
  const lineReaded = createInterface2({
247126
248829
  input: stream
247127
248830
  });
247128
248831
  function destroyStreamAndResolve() {
247129
248832
  stream.destroy();
247130
- resolve7();
248833
+ resolve9();
247131
248834
  }
247132
248835
  let lineNumber = 0;
247133
248836
  let currentRangeIndex = 0;
@@ -248239,15 +249942,15 @@ class PostHogBackendClient extends PostHogCoreStateless {
248239
249942
  return true;
248240
249943
  if (this.featureFlagsPoller === undefined)
248241
249944
  return false;
248242
- return new Promise((resolve7) => {
249945
+ return new Promise((resolve9) => {
248243
249946
  const timeout3 = setTimeout(() => {
248244
249947
  cleanup();
248245
- resolve7(false);
249948
+ resolve9(false);
248246
249949
  }, timeoutMs);
248247
249950
  const cleanup = this._events.on("localEvaluationFlagsLoaded", (count2) => {
248248
249951
  clearTimeout(timeout3);
248249
249952
  cleanup();
248250
- resolve7(count2 > 0);
249953
+ resolve9(count2 > 0);
248251
249954
  });
248252
249955
  });
248253
249956
  }
@@ -249060,4 +250763,4 @@ export {
249060
250763
  CLIExitError
249061
250764
  };
249062
250765
 
249063
- //# debugId=85AAC033AD084DA464756E2164756E21
250766
+ //# debugId=FBC11F0B5DEDDDCE64756E2164756E21