kandown 0.1.4 → 0.2.1

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/bin/tui.js CHANGED
@@ -902,21 +902,21 @@ var require_react_development = __commonJS({
902
902
  );
903
903
  actScopeDepth = prevActScopeDepth;
904
904
  }
905
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
905
+ function recursivelyFlushAsyncActWork(returnValue, resolve3, reject) {
906
906
  var queue = ReactSharedInternals.actQueue;
907
907
  if (null !== queue)
908
908
  if (0 !== queue.length)
909
909
  try {
910
910
  flushActQueue(queue);
911
911
  enqueueTask(function() {
912
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
912
+ return recursivelyFlushAsyncActWork(returnValue, resolve3, reject);
913
913
  });
914
914
  return;
915
915
  } catch (error) {
916
916
  ReactSharedInternals.thrownErrors.push(error);
917
917
  }
918
918
  else ReactSharedInternals.actQueue = null;
919
- 0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
919
+ 0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve3(returnValue);
920
920
  }
921
921
  function flushActQueue(queue) {
922
922
  if (!isFlushing) {
@@ -1103,7 +1103,7 @@ var require_react_development = __commonJS({
1103
1103
  ));
1104
1104
  });
1105
1105
  return {
1106
- then: function(resolve, reject) {
1106
+ then: function(resolve3, reject) {
1107
1107
  didAwaitActCall = true;
1108
1108
  thenable.then(
1109
1109
  function(returnValue) {
@@ -1113,7 +1113,7 @@ var require_react_development = __commonJS({
1113
1113
  flushActQueue(queue), enqueueTask(function() {
1114
1114
  return recursivelyFlushAsyncActWork(
1115
1115
  returnValue,
1116
- resolve,
1116
+ resolve3,
1117
1117
  reject
1118
1118
  );
1119
1119
  });
@@ -1127,7 +1127,7 @@ var require_react_development = __commonJS({
1127
1127
  ReactSharedInternals.thrownErrors.length = 0;
1128
1128
  reject(_thrownError);
1129
1129
  }
1130
- } else resolve(returnValue);
1130
+ } else resolve3(returnValue);
1131
1131
  },
1132
1132
  function(error) {
1133
1133
  popActScope(prevActQueue, prevActScopeDepth);
@@ -1149,15 +1149,15 @@ var require_react_development = __commonJS({
1149
1149
  if (0 < ReactSharedInternals.thrownErrors.length)
1150
1150
  throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
1151
1151
  return {
1152
- then: function(resolve, reject) {
1152
+ then: function(resolve3, reject) {
1153
1153
  didAwaitActCall = true;
1154
1154
  0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
1155
1155
  return recursivelyFlushAsyncActWork(
1156
1156
  returnValue$jscomp$0,
1157
- resolve,
1157
+ resolve3,
1158
1158
  reject
1159
1159
  );
1160
- })) : resolve(returnValue$jscomp$0);
1160
+ })) : resolve3(returnValue$jscomp$0);
1161
1161
  }
1162
1162
  };
1163
1163
  };
@@ -3043,8 +3043,8 @@ var require_react_reconciler_production = __commonJS({
3043
3043
  currentEntangledActionThenable = {
3044
3044
  status: "pending",
3045
3045
  value: void 0,
3046
- then: function(resolve) {
3047
- entangledListeners.push(resolve);
3046
+ then: function(resolve3) {
3047
+ entangledListeners.push(resolve3);
3048
3048
  }
3049
3049
  };
3050
3050
  }
@@ -3067,8 +3067,8 @@ var require_react_reconciler_production = __commonJS({
3067
3067
  status: "pending",
3068
3068
  value: null,
3069
3069
  reason: null,
3070
- then: function(resolve) {
3071
- listeners.push(resolve);
3070
+ then: function(resolve3) {
3071
+ listeners.push(resolve3);
3072
3072
  }
3073
3073
  };
3074
3074
  thenable.then(
@@ -12667,8 +12667,8 @@ var require_react_reconciler_development = __commonJS({
12667
12667
  currentEntangledActionThenable = {
12668
12668
  status: "pending",
12669
12669
  value: void 0,
12670
- then: function(resolve) {
12671
- entangledListeners.push(resolve);
12670
+ then: function(resolve3) {
12671
+ entangledListeners.push(resolve3);
12672
12672
  }
12673
12673
  };
12674
12674
  }
@@ -12691,8 +12691,8 @@ var require_react_reconciler_development = __commonJS({
12691
12691
  status: "pending",
12692
12692
  value: null,
12693
12693
  reason: null,
12694
- then: function(resolve) {
12695
- listeners.push(resolve);
12694
+ then: function(resolve3) {
12695
+ listeners.push(resolve3);
12696
12696
  }
12697
12697
  };
12698
12698
  thenable.then(
@@ -26202,13 +26202,13 @@ var require_extension = __commonJS({
26202
26202
  var require_websocket = __commonJS({
26203
26203
  "node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket.js"(exports, module) {
26204
26204
  "use strict";
26205
- var EventEmitter3 = __require("events");
26205
+ var EventEmitter4 = __require("events");
26206
26206
  var https = __require("https");
26207
26207
  var http = __require("http");
26208
26208
  var net = __require("net");
26209
26209
  var tls = __require("tls");
26210
26210
  var { randomBytes, createHash } = __require("crypto");
26211
- var { Duplex, Readable } = __require("stream");
26211
+ var { Duplex, Readable: Readable2 } = __require("stream");
26212
26212
  var { URL: URL2 } = __require("url");
26213
26213
  var PerMessageDeflate2 = require_permessage_deflate();
26214
26214
  var Receiver2 = require_receiver();
@@ -26234,7 +26234,7 @@ var require_websocket = __commonJS({
26234
26234
  var protocolVersions = [8, 13];
26235
26235
  var readyStates = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
26236
26236
  var subprotocolRegex = /^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;
26237
- var WebSocket2 = class _WebSocket extends EventEmitter3 {
26237
+ var WebSocket2 = class _WebSocket extends EventEmitter4 {
26238
26238
  /**
26239
26239
  * Create a new `WebSocket`.
26240
26240
  *
@@ -27146,7 +27146,7 @@ var require_stream = __commonJS({
27146
27146
  };
27147
27147
  duplex._final = function(callback) {
27148
27148
  if (ws.readyState === ws.CONNECTING) {
27149
- ws.once("open", function open() {
27149
+ ws.once("open", function open2() {
27150
27150
  duplex._final(callback);
27151
27151
  });
27152
27152
  return;
@@ -27167,7 +27167,7 @@ var require_stream = __commonJS({
27167
27167
  };
27168
27168
  duplex._write = function(chunk, encoding, callback) {
27169
27169
  if (ws.readyState === ws.CONNECTING) {
27170
- ws.once("open", function open() {
27170
+ ws.once("open", function open2() {
27171
27171
  duplex._write(chunk, encoding, callback);
27172
27172
  });
27173
27173
  return;
@@ -27231,7 +27231,7 @@ var require_subprotocol = __commonJS({
27231
27231
  var require_websocket_server = __commonJS({
27232
27232
  "node_modules/.pnpm/ws@8.20.0/node_modules/ws/lib/websocket-server.js"(exports, module) {
27233
27233
  "use strict";
27234
- var EventEmitter3 = __require("events");
27234
+ var EventEmitter4 = __require("events");
27235
27235
  var http = __require("http");
27236
27236
  var { Duplex } = __require("stream");
27237
27237
  var { createHash } = __require("crypto");
@@ -27244,7 +27244,7 @@ var require_websocket_server = __commonJS({
27244
27244
  var RUNNING = 0;
27245
27245
  var CLOSING = 1;
27246
27246
  var CLOSED = 2;
27247
- var WebSocketServer2 = class extends EventEmitter3 {
27247
+ var WebSocketServer2 = class extends EventEmitter4 {
27248
27248
  /**
27249
27249
  * Create a `WebSocketServer` instance.
27250
27250
  *
@@ -27968,7 +27968,7 @@ var require_backend = __commonJS({
27968
27968
  return [initialArg, function() {
27969
27969
  }];
27970
27970
  },
27971
- useRef: function useRef4(initialValue) {
27971
+ useRef: function useRef5(initialValue) {
27972
27972
  var hook = nextHook();
27973
27973
  initialValue = null !== hook ? hook.memoizedState : {
27974
27974
  current: initialValue
@@ -30441,12 +30441,12 @@ var require_backend = __commonJS({
30441
30441
  }
30442
30442
  return ("string" === r ? String : Number)(t);
30443
30443
  }
30444
- var EventEmitter3 = /* @__PURE__ */ (function() {
30445
- function EventEmitter4() {
30446
- _classCallCheck(this, EventEmitter4);
30444
+ var EventEmitter4 = /* @__PURE__ */ (function() {
30445
+ function EventEmitter5() {
30446
+ _classCallCheck(this, EventEmitter5);
30447
30447
  _defineProperty(this, "listenersMap", /* @__PURE__ */ new Map());
30448
30448
  }
30449
- return _createClass(EventEmitter4, [{
30449
+ return _createClass(EventEmitter5, [{
30450
30450
  key: "addListener",
30451
30451
  value: function addListener(event, listener) {
30452
30452
  var listeners = this.listenersMap.get(event);
@@ -33846,7 +33846,7 @@ var require_backend = __commonJS({
33846
33846
  } while (this._messageQueue.length);
33847
33847
  }
33848
33848
  }]);
33849
- })(EventEmitter3);
33849
+ })(EventEmitter4);
33850
33850
  const src_bridge = Bridge;
33851
33851
  ;
33852
33852
  function storage_localStorageGetItem(key) {
@@ -34704,7 +34704,7 @@ var require_backend = __commonJS({
34704
34704
  this._bridge.send("unsupportedRendererVersion");
34705
34705
  }
34706
34706
  }]);
34707
- })(EventEmitter3);
34707
+ })(EventEmitter4);
34708
34708
  ;
34709
34709
  function DevToolsConsolePatching_typeof(o) {
34710
34710
  "@babel/helpers - typeof";
@@ -44413,22 +44413,22 @@ var init_devtools = __esm({
44413
44413
  init_devtools_window_polyfill();
44414
44414
  init_wrapper();
44415
44415
  import_react_devtools_core = __toESM(require_backend(), 1);
44416
- isDevToolsReachable = async () => new Promise((resolve) => {
44416
+ isDevToolsReachable = async () => new Promise((resolve3) => {
44417
44417
  const socket = new wrapper_default("ws://localhost:8097");
44418
44418
  const timeout = setTimeout(() => {
44419
44419
  socket.terminate();
44420
- resolve(false);
44420
+ resolve3(false);
44421
44421
  }, 2e3);
44422
44422
  timeout.unref();
44423
44423
  socket.on("open", () => {
44424
44424
  clearTimeout(timeout);
44425
44425
  socket.terminate();
44426
- resolve(true);
44426
+ resolve3(true);
44427
44427
  });
44428
44428
  socket.on("error", () => {
44429
44429
  clearTimeout(timeout);
44430
44430
  socket.terminate();
44431
- resolve(false);
44431
+ resolve3(false);
44432
44432
  });
44433
44433
  });
44434
44434
  if (await isDevToolsReachable()) {
@@ -50505,18 +50505,18 @@ var proto = Object.defineProperties(() => {
50505
50505
  }
50506
50506
  }
50507
50507
  });
50508
- var createStyler = (open, close, parent) => {
50508
+ var createStyler = (open2, close, parent) => {
50509
50509
  let openAll;
50510
50510
  let closeAll;
50511
50511
  if (parent === void 0) {
50512
- openAll = open;
50512
+ openAll = open2;
50513
50513
  closeAll = close;
50514
50514
  } else {
50515
- openAll = parent.openAll + open;
50515
+ openAll = parent.openAll + open2;
50516
50516
  closeAll = close + parent.closeAll;
50517
50517
  }
50518
50518
  return {
50519
- open,
50519
+ open: open2,
50520
50520
  close,
50521
50521
  openAll,
50522
50522
  closeAll,
@@ -52678,8 +52678,8 @@ var kittyModifiers = {
52678
52678
  var noop = () => {
52679
52679
  };
52680
52680
  var textEncoder = new TextEncoder();
52681
- var yieldImmediate = async () => new Promise((resolve) => {
52682
- setImmediate(resolve);
52681
+ var yieldImmediate = async () => new Promise((resolve3) => {
52682
+ setImmediate(resolve3);
52683
52683
  });
52684
52684
  var kittyQueryEscapeByte = 27;
52685
52685
  var kittyQueryOpenBracketByte = 91;
@@ -52883,8 +52883,8 @@ var Ink = class {
52883
52883
  };
52884
52884
  }
52885
52885
  this.initKittyKeyboard();
52886
- this.exitPromise = new Promise((resolve, reject) => {
52887
- this.resolveExitPromise = resolve;
52886
+ this.exitPromise = new Promise((resolve3, reject) => {
52887
+ this.resolveExitPromise = resolve3;
52888
52888
  this.rejectExitPromise = reject;
52889
52889
  });
52890
52890
  void this.exitPromise.catch(noop);
@@ -53177,9 +53177,9 @@ var Ink = class {
53177
53177
  settleThrottle(this.throttledOnRender, canWriteToStdout);
53178
53178
  settleThrottle(this.throttledLog, canWriteToStdout);
53179
53179
  if (canWriteToStdout && hasWritableState) {
53180
- await new Promise((resolve) => {
53180
+ await new Promise((resolve3) => {
53181
53181
  this.options.stdout.write("", () => {
53182
- resolve();
53182
+ resolve3();
53183
53183
  });
53184
53184
  });
53185
53185
  return;
@@ -53246,8 +53246,8 @@ var Ink = class {
53246
53246
  async awaitNextRender() {
53247
53247
  if (!this.nextRenderCommit) {
53248
53248
  let resolveRender;
53249
- const promise = new Promise((resolve) => {
53250
- resolveRender = resolve;
53249
+ const promise = new Promise((resolve3) => {
53250
+ resolveRender = resolve3;
53251
53251
  });
53252
53252
  this.nextRenderCommit = { promise, resolve: resolveRender };
53253
53253
  }
@@ -54147,7 +54147,7 @@ var SECTION_ICONS = {
54147
54147
  Fields: "\u{1F4DD}",
54148
54148
  Notifications: "\u{1F514}"
54149
54149
  };
54150
- function Settings({ kandownDir }) {
54150
+ function Settings({ kandownDir, version }) {
54151
54151
  const { exit } = use_app_default();
54152
54152
  const [config, setConfig] = (0, import_react34.useState)(null);
54153
54153
  const [focusIndex, setFocusIndex] = (0, import_react34.useState)(0);
@@ -54227,12 +54227,23 @@ function Settings({ kandownDir }) {
54227
54227
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { children: [
54228
54228
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, color: "cyan", children: " \u256D\u2500 " }),
54229
54229
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, color: "white", children: "KANDOWN SETTINGS" }),
54230
+ version && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { dimColor: true, children: [
54231
+ " v",
54232
+ version
54233
+ ] }),
54230
54234
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Text, { bold: true, color: "cyan", children: " \u2500\u256E" })
54231
54235
  ] }),
54232
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Box_default, { children: showSaved && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: "green", bold: true, children: [
54233
- "\u2713 saved",
54234
- " "
54235
- ] }) })
54236
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Box_default, { children: [
54237
+ version && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { dimColor: true, children: [
54238
+ "v",
54239
+ version,
54240
+ " "
54241
+ ] }),
54242
+ showSaved && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Text, { color: "green", bold: true, children: [
54243
+ "\u2713 saved",
54244
+ " "
54245
+ ] })
54246
+ ] })
54236
54247
  ] }),
54237
54248
  SECTIONS.map((section) => {
54238
54249
  const items = SETTINGS.filter((s) => s.section === section);
@@ -54317,9 +54328,1702 @@ function ValueDisplay({ setting, value, focused }) {
54317
54328
  // src/cli/screens/board.tsx
54318
54329
  var import_react36 = __toESM(require_react(), 1);
54319
54330
 
54331
+ // node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
54332
+ import { stat as statcb } from "fs";
54333
+ import { stat as stat3, readdir as readdir2 } from "fs/promises";
54334
+ import { EventEmitter as EventEmitter3 } from "events";
54335
+ import * as sysPath2 from "path";
54336
+
54337
+ // node_modules/.pnpm/readdirp@4.1.2/node_modules/readdirp/esm/index.js
54338
+ import { stat, lstat, readdir, realpath } from "fs/promises";
54339
+ import { Readable } from "stream";
54340
+ import { resolve as presolve, relative as prelative, join as pjoin, sep as psep } from "path";
54341
+ var EntryTypes = {
54342
+ FILE_TYPE: "files",
54343
+ DIR_TYPE: "directories",
54344
+ FILE_DIR_TYPE: "files_directories",
54345
+ EVERYTHING_TYPE: "all"
54346
+ };
54347
+ var defaultOptions = {
54348
+ root: ".",
54349
+ fileFilter: (_entryInfo) => true,
54350
+ directoryFilter: (_entryInfo) => true,
54351
+ type: EntryTypes.FILE_TYPE,
54352
+ lstat: false,
54353
+ depth: 2147483648,
54354
+ alwaysStat: false,
54355
+ highWaterMark: 4096
54356
+ };
54357
+ Object.freeze(defaultOptions);
54358
+ var RECURSIVE_ERROR_CODE = "READDIRP_RECURSIVE_ERROR";
54359
+ var NORMAL_FLOW_ERRORS = /* @__PURE__ */ new Set(["ENOENT", "EPERM", "EACCES", "ELOOP", RECURSIVE_ERROR_CODE]);
54360
+ var ALL_TYPES = [
54361
+ EntryTypes.DIR_TYPE,
54362
+ EntryTypes.EVERYTHING_TYPE,
54363
+ EntryTypes.FILE_DIR_TYPE,
54364
+ EntryTypes.FILE_TYPE
54365
+ ];
54366
+ var DIR_TYPES = /* @__PURE__ */ new Set([
54367
+ EntryTypes.DIR_TYPE,
54368
+ EntryTypes.EVERYTHING_TYPE,
54369
+ EntryTypes.FILE_DIR_TYPE
54370
+ ]);
54371
+ var FILE_TYPES = /* @__PURE__ */ new Set([
54372
+ EntryTypes.EVERYTHING_TYPE,
54373
+ EntryTypes.FILE_DIR_TYPE,
54374
+ EntryTypes.FILE_TYPE
54375
+ ]);
54376
+ var isNormalFlowError = (error) => NORMAL_FLOW_ERRORS.has(error.code);
54377
+ var wantBigintFsStats = process.platform === "win32";
54378
+ var emptyFn = (_entryInfo) => true;
54379
+ var normalizeFilter = (filter) => {
54380
+ if (filter === void 0)
54381
+ return emptyFn;
54382
+ if (typeof filter === "function")
54383
+ return filter;
54384
+ if (typeof filter === "string") {
54385
+ const fl = filter.trim();
54386
+ return (entry) => entry.basename === fl;
54387
+ }
54388
+ if (Array.isArray(filter)) {
54389
+ const trItems = filter.map((item) => item.trim());
54390
+ return (entry) => trItems.some((f) => entry.basename === f);
54391
+ }
54392
+ return emptyFn;
54393
+ };
54394
+ var ReaddirpStream = class extends Readable {
54395
+ constructor(options = {}) {
54396
+ super({
54397
+ objectMode: true,
54398
+ autoDestroy: true,
54399
+ highWaterMark: options.highWaterMark
54400
+ });
54401
+ const opts = { ...defaultOptions, ...options };
54402
+ const { root, type } = opts;
54403
+ this._fileFilter = normalizeFilter(opts.fileFilter);
54404
+ this._directoryFilter = normalizeFilter(opts.directoryFilter);
54405
+ const statMethod = opts.lstat ? lstat : stat;
54406
+ if (wantBigintFsStats) {
54407
+ this._stat = (path) => statMethod(path, { bigint: true });
54408
+ } else {
54409
+ this._stat = statMethod;
54410
+ }
54411
+ this._maxDepth = opts.depth ?? defaultOptions.depth;
54412
+ this._wantsDir = type ? DIR_TYPES.has(type) : false;
54413
+ this._wantsFile = type ? FILE_TYPES.has(type) : false;
54414
+ this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
54415
+ this._root = presolve(root);
54416
+ this._isDirent = !opts.alwaysStat;
54417
+ this._statsProp = this._isDirent ? "dirent" : "stats";
54418
+ this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
54419
+ this.parents = [this._exploreDir(root, 1)];
54420
+ this.reading = false;
54421
+ this.parent = void 0;
54422
+ }
54423
+ async _read(batch) {
54424
+ if (this.reading)
54425
+ return;
54426
+ this.reading = true;
54427
+ try {
54428
+ while (!this.destroyed && batch > 0) {
54429
+ const par = this.parent;
54430
+ const fil = par && par.files;
54431
+ if (fil && fil.length > 0) {
54432
+ const { path, depth } = par;
54433
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path));
54434
+ const awaited = await Promise.all(slice);
54435
+ for (const entry of awaited) {
54436
+ if (!entry)
54437
+ continue;
54438
+ if (this.destroyed)
54439
+ return;
54440
+ const entryType = await this._getEntryType(entry);
54441
+ if (entryType === "directory" && this._directoryFilter(entry)) {
54442
+ if (depth <= this._maxDepth) {
54443
+ this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
54444
+ }
54445
+ if (this._wantsDir) {
54446
+ this.push(entry);
54447
+ batch--;
54448
+ }
54449
+ } else if ((entryType === "file" || this._includeAsFile(entry)) && this._fileFilter(entry)) {
54450
+ if (this._wantsFile) {
54451
+ this.push(entry);
54452
+ batch--;
54453
+ }
54454
+ }
54455
+ }
54456
+ } else {
54457
+ const parent = this.parents.pop();
54458
+ if (!parent) {
54459
+ this.push(null);
54460
+ break;
54461
+ }
54462
+ this.parent = await parent;
54463
+ if (this.destroyed)
54464
+ return;
54465
+ }
54466
+ }
54467
+ } catch (error) {
54468
+ this.destroy(error);
54469
+ } finally {
54470
+ this.reading = false;
54471
+ }
54472
+ }
54473
+ async _exploreDir(path, depth) {
54474
+ let files;
54475
+ try {
54476
+ files = await readdir(path, this._rdOptions);
54477
+ } catch (error) {
54478
+ this._onError(error);
54479
+ }
54480
+ return { files, depth, path };
54481
+ }
54482
+ async _formatEntry(dirent, path) {
54483
+ let entry;
54484
+ const basename3 = this._isDirent ? dirent.name : dirent;
54485
+ try {
54486
+ const fullPath = presolve(pjoin(path, basename3));
54487
+ entry = { path: prelative(this._root, fullPath), fullPath, basename: basename3 };
54488
+ entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
54489
+ } catch (err) {
54490
+ this._onError(err);
54491
+ return;
54492
+ }
54493
+ return entry;
54494
+ }
54495
+ _onError(err) {
54496
+ if (isNormalFlowError(err) && !this.destroyed) {
54497
+ this.emit("warn", err);
54498
+ } else {
54499
+ this.destroy(err);
54500
+ }
54501
+ }
54502
+ async _getEntryType(entry) {
54503
+ if (!entry && this._statsProp in entry) {
54504
+ return "";
54505
+ }
54506
+ const stats = entry[this._statsProp];
54507
+ if (stats.isFile())
54508
+ return "file";
54509
+ if (stats.isDirectory())
54510
+ return "directory";
54511
+ if (stats && stats.isSymbolicLink()) {
54512
+ const full = entry.fullPath;
54513
+ try {
54514
+ const entryRealPath = await realpath(full);
54515
+ const entryRealPathStats = await lstat(entryRealPath);
54516
+ if (entryRealPathStats.isFile()) {
54517
+ return "file";
54518
+ }
54519
+ if (entryRealPathStats.isDirectory()) {
54520
+ const len = entryRealPath.length;
54521
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === psep) {
54522
+ const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
54523
+ recursiveError.code = RECURSIVE_ERROR_CODE;
54524
+ return this._onError(recursiveError);
54525
+ }
54526
+ return "directory";
54527
+ }
54528
+ } catch (error) {
54529
+ this._onError(error);
54530
+ return "";
54531
+ }
54532
+ }
54533
+ }
54534
+ _includeAsFile(entry) {
54535
+ const stats = entry && entry[this._statsProp];
54536
+ return stats && this._wantsEverything && !stats.isDirectory();
54537
+ }
54538
+ };
54539
+ function readdirp(root, options = {}) {
54540
+ let type = options.entryType || options.type;
54541
+ if (type === "both")
54542
+ type = EntryTypes.FILE_DIR_TYPE;
54543
+ if (type)
54544
+ options.type = type;
54545
+ if (!root) {
54546
+ throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");
54547
+ } else if (typeof root !== "string") {
54548
+ throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");
54549
+ } else if (type && !ALL_TYPES.includes(type)) {
54550
+ throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(", ")}`);
54551
+ }
54552
+ options.root = root;
54553
+ return new ReaddirpStream(options);
54554
+ }
54555
+
54556
+ // node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/handler.js
54557
+ import { watchFile, unwatchFile, watch as fs_watch } from "fs";
54558
+ import { open, stat as stat2, lstat as lstat2, realpath as fsrealpath } from "fs/promises";
54559
+ import * as sysPath from "path";
54560
+ import { type as osType } from "os";
54561
+ var STR_DATA = "data";
54562
+ var STR_END = "end";
54563
+ var STR_CLOSE = "close";
54564
+ var EMPTY_FN = () => {
54565
+ };
54566
+ var pl = process.platform;
54567
+ var isWindows3 = pl === "win32";
54568
+ var isMacos = pl === "darwin";
54569
+ var isLinux2 = pl === "linux";
54570
+ var isFreeBSD = pl === "freebsd";
54571
+ var isIBMi = osType() === "OS400";
54572
+ var EVENTS = {
54573
+ ALL: "all",
54574
+ READY: "ready",
54575
+ ADD: "add",
54576
+ CHANGE: "change",
54577
+ ADD_DIR: "addDir",
54578
+ UNLINK: "unlink",
54579
+ UNLINK_DIR: "unlinkDir",
54580
+ RAW: "raw",
54581
+ ERROR: "error"
54582
+ };
54583
+ var EV = EVENTS;
54584
+ var THROTTLE_MODE_WATCH = "watch";
54585
+ var statMethods = { lstat: lstat2, stat: stat2 };
54586
+ var KEY_LISTENERS = "listeners";
54587
+ var KEY_ERR = "errHandlers";
54588
+ var KEY_RAW = "rawEmitters";
54589
+ var HANDLER_KEYS = [KEY_LISTENERS, KEY_ERR, KEY_RAW];
54590
+ var binaryExtensions = /* @__PURE__ */ new Set([
54591
+ "3dm",
54592
+ "3ds",
54593
+ "3g2",
54594
+ "3gp",
54595
+ "7z",
54596
+ "a",
54597
+ "aac",
54598
+ "adp",
54599
+ "afdesign",
54600
+ "afphoto",
54601
+ "afpub",
54602
+ "ai",
54603
+ "aif",
54604
+ "aiff",
54605
+ "alz",
54606
+ "ape",
54607
+ "apk",
54608
+ "appimage",
54609
+ "ar",
54610
+ "arj",
54611
+ "asf",
54612
+ "au",
54613
+ "avi",
54614
+ "bak",
54615
+ "baml",
54616
+ "bh",
54617
+ "bin",
54618
+ "bk",
54619
+ "bmp",
54620
+ "btif",
54621
+ "bz2",
54622
+ "bzip2",
54623
+ "cab",
54624
+ "caf",
54625
+ "cgm",
54626
+ "class",
54627
+ "cmx",
54628
+ "cpio",
54629
+ "cr2",
54630
+ "cur",
54631
+ "dat",
54632
+ "dcm",
54633
+ "deb",
54634
+ "dex",
54635
+ "djvu",
54636
+ "dll",
54637
+ "dmg",
54638
+ "dng",
54639
+ "doc",
54640
+ "docm",
54641
+ "docx",
54642
+ "dot",
54643
+ "dotm",
54644
+ "dra",
54645
+ "DS_Store",
54646
+ "dsk",
54647
+ "dts",
54648
+ "dtshd",
54649
+ "dvb",
54650
+ "dwg",
54651
+ "dxf",
54652
+ "ecelp4800",
54653
+ "ecelp7470",
54654
+ "ecelp9600",
54655
+ "egg",
54656
+ "eol",
54657
+ "eot",
54658
+ "epub",
54659
+ "exe",
54660
+ "f4v",
54661
+ "fbs",
54662
+ "fh",
54663
+ "fla",
54664
+ "flac",
54665
+ "flatpak",
54666
+ "fli",
54667
+ "flv",
54668
+ "fpx",
54669
+ "fst",
54670
+ "fvt",
54671
+ "g3",
54672
+ "gh",
54673
+ "gif",
54674
+ "graffle",
54675
+ "gz",
54676
+ "gzip",
54677
+ "h261",
54678
+ "h263",
54679
+ "h264",
54680
+ "icns",
54681
+ "ico",
54682
+ "ief",
54683
+ "img",
54684
+ "ipa",
54685
+ "iso",
54686
+ "jar",
54687
+ "jpeg",
54688
+ "jpg",
54689
+ "jpgv",
54690
+ "jpm",
54691
+ "jxr",
54692
+ "key",
54693
+ "ktx",
54694
+ "lha",
54695
+ "lib",
54696
+ "lvp",
54697
+ "lz",
54698
+ "lzh",
54699
+ "lzma",
54700
+ "lzo",
54701
+ "m3u",
54702
+ "m4a",
54703
+ "m4v",
54704
+ "mar",
54705
+ "mdi",
54706
+ "mht",
54707
+ "mid",
54708
+ "midi",
54709
+ "mj2",
54710
+ "mka",
54711
+ "mkv",
54712
+ "mmr",
54713
+ "mng",
54714
+ "mobi",
54715
+ "mov",
54716
+ "movie",
54717
+ "mp3",
54718
+ "mp4",
54719
+ "mp4a",
54720
+ "mpeg",
54721
+ "mpg",
54722
+ "mpga",
54723
+ "mxu",
54724
+ "nef",
54725
+ "npx",
54726
+ "numbers",
54727
+ "nupkg",
54728
+ "o",
54729
+ "odp",
54730
+ "ods",
54731
+ "odt",
54732
+ "oga",
54733
+ "ogg",
54734
+ "ogv",
54735
+ "otf",
54736
+ "ott",
54737
+ "pages",
54738
+ "pbm",
54739
+ "pcx",
54740
+ "pdb",
54741
+ "pdf",
54742
+ "pea",
54743
+ "pgm",
54744
+ "pic",
54745
+ "png",
54746
+ "pnm",
54747
+ "pot",
54748
+ "potm",
54749
+ "potx",
54750
+ "ppa",
54751
+ "ppam",
54752
+ "ppm",
54753
+ "pps",
54754
+ "ppsm",
54755
+ "ppsx",
54756
+ "ppt",
54757
+ "pptm",
54758
+ "pptx",
54759
+ "psd",
54760
+ "pya",
54761
+ "pyc",
54762
+ "pyo",
54763
+ "pyv",
54764
+ "qt",
54765
+ "rar",
54766
+ "ras",
54767
+ "raw",
54768
+ "resources",
54769
+ "rgb",
54770
+ "rip",
54771
+ "rlc",
54772
+ "rmf",
54773
+ "rmvb",
54774
+ "rpm",
54775
+ "rtf",
54776
+ "rz",
54777
+ "s3m",
54778
+ "s7z",
54779
+ "scpt",
54780
+ "sgi",
54781
+ "shar",
54782
+ "snap",
54783
+ "sil",
54784
+ "sketch",
54785
+ "slk",
54786
+ "smv",
54787
+ "snk",
54788
+ "so",
54789
+ "stl",
54790
+ "suo",
54791
+ "sub",
54792
+ "swf",
54793
+ "tar",
54794
+ "tbz",
54795
+ "tbz2",
54796
+ "tga",
54797
+ "tgz",
54798
+ "thmx",
54799
+ "tif",
54800
+ "tiff",
54801
+ "tlz",
54802
+ "ttc",
54803
+ "ttf",
54804
+ "txz",
54805
+ "udf",
54806
+ "uvh",
54807
+ "uvi",
54808
+ "uvm",
54809
+ "uvp",
54810
+ "uvs",
54811
+ "uvu",
54812
+ "viv",
54813
+ "vob",
54814
+ "war",
54815
+ "wav",
54816
+ "wax",
54817
+ "wbmp",
54818
+ "wdp",
54819
+ "weba",
54820
+ "webm",
54821
+ "webp",
54822
+ "whl",
54823
+ "wim",
54824
+ "wm",
54825
+ "wma",
54826
+ "wmv",
54827
+ "wmx",
54828
+ "woff",
54829
+ "woff2",
54830
+ "wrm",
54831
+ "wvx",
54832
+ "xbm",
54833
+ "xif",
54834
+ "xla",
54835
+ "xlam",
54836
+ "xls",
54837
+ "xlsb",
54838
+ "xlsm",
54839
+ "xlsx",
54840
+ "xlt",
54841
+ "xltm",
54842
+ "xltx",
54843
+ "xm",
54844
+ "xmind",
54845
+ "xpi",
54846
+ "xpm",
54847
+ "xwd",
54848
+ "xz",
54849
+ "z",
54850
+ "zip",
54851
+ "zipx"
54852
+ ]);
54853
+ var isBinaryPath = (filePath) => binaryExtensions.has(sysPath.extname(filePath).slice(1).toLowerCase());
54854
+ var foreach = (val, fn) => {
54855
+ if (val instanceof Set) {
54856
+ val.forEach(fn);
54857
+ } else {
54858
+ fn(val);
54859
+ }
54860
+ };
54861
+ var addAndConvert = (main, prop, item) => {
54862
+ let container = main[prop];
54863
+ if (!(container instanceof Set)) {
54864
+ main[prop] = container = /* @__PURE__ */ new Set([container]);
54865
+ }
54866
+ container.add(item);
54867
+ };
54868
+ var clearItem = (cont) => (key) => {
54869
+ const set = cont[key];
54870
+ if (set instanceof Set) {
54871
+ set.clear();
54872
+ } else {
54873
+ delete cont[key];
54874
+ }
54875
+ };
54876
+ var delFromSet = (main, prop, item) => {
54877
+ const container = main[prop];
54878
+ if (container instanceof Set) {
54879
+ container.delete(item);
54880
+ } else if (container === item) {
54881
+ delete main[prop];
54882
+ }
54883
+ };
54884
+ var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
54885
+ var FsWatchInstances = /* @__PURE__ */ new Map();
54886
+ function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
54887
+ const handleEvent = (rawEvent, evPath) => {
54888
+ listener(path);
54889
+ emitRaw(rawEvent, evPath, { watchedPath: path });
54890
+ if (evPath && path !== evPath) {
54891
+ fsWatchBroadcast(sysPath.resolve(path, evPath), KEY_LISTENERS, sysPath.join(path, evPath));
54892
+ }
54893
+ };
54894
+ try {
54895
+ return fs_watch(path, {
54896
+ persistent: options.persistent
54897
+ }, handleEvent);
54898
+ } catch (error) {
54899
+ errHandler(error);
54900
+ return void 0;
54901
+ }
54902
+ }
54903
+ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
54904
+ const cont = FsWatchInstances.get(fullPath);
54905
+ if (!cont)
54906
+ return;
54907
+ foreach(cont[listenerType], (listener) => {
54908
+ listener(val1, val2, val3);
54909
+ });
54910
+ };
54911
+ var setFsWatchListener = (path, fullPath, options, handlers) => {
54912
+ const { listener, errHandler, rawEmitter } = handlers;
54913
+ let cont = FsWatchInstances.get(fullPath);
54914
+ let watcher;
54915
+ if (!options.persistent) {
54916
+ watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
54917
+ if (!watcher)
54918
+ return;
54919
+ return watcher.close.bind(watcher);
54920
+ }
54921
+ if (cont) {
54922
+ addAndConvert(cont, KEY_LISTENERS, listener);
54923
+ addAndConvert(cont, KEY_ERR, errHandler);
54924
+ addAndConvert(cont, KEY_RAW, rawEmitter);
54925
+ } else {
54926
+ watcher = createFsWatchInstance(
54927
+ path,
54928
+ options,
54929
+ fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
54930
+ errHandler,
54931
+ // no need to use broadcast here
54932
+ fsWatchBroadcast.bind(null, fullPath, KEY_RAW)
54933
+ );
54934
+ if (!watcher)
54935
+ return;
54936
+ watcher.on(EV.ERROR, async (error) => {
54937
+ const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
54938
+ if (cont)
54939
+ cont.watcherUnusable = true;
54940
+ if (isWindows3 && error.code === "EPERM") {
54941
+ try {
54942
+ const fd = await open(path, "r");
54943
+ await fd.close();
54944
+ broadcastErr(error);
54945
+ } catch (err) {
54946
+ }
54947
+ } else {
54948
+ broadcastErr(error);
54949
+ }
54950
+ });
54951
+ cont = {
54952
+ listeners: listener,
54953
+ errHandlers: errHandler,
54954
+ rawEmitters: rawEmitter,
54955
+ watcher
54956
+ };
54957
+ FsWatchInstances.set(fullPath, cont);
54958
+ }
54959
+ return () => {
54960
+ delFromSet(cont, KEY_LISTENERS, listener);
54961
+ delFromSet(cont, KEY_ERR, errHandler);
54962
+ delFromSet(cont, KEY_RAW, rawEmitter);
54963
+ if (isEmptySet(cont.listeners)) {
54964
+ cont.watcher.close();
54965
+ FsWatchInstances.delete(fullPath);
54966
+ HANDLER_KEYS.forEach(clearItem(cont));
54967
+ cont.watcher = void 0;
54968
+ Object.freeze(cont);
54969
+ }
54970
+ };
54971
+ };
54972
+ var FsWatchFileInstances = /* @__PURE__ */ new Map();
54973
+ var setFsWatchFileListener = (path, fullPath, options, handlers) => {
54974
+ const { listener, rawEmitter } = handlers;
54975
+ let cont = FsWatchFileInstances.get(fullPath);
54976
+ const copts = cont && cont.options;
54977
+ if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
54978
+ unwatchFile(fullPath);
54979
+ cont = void 0;
54980
+ }
54981
+ if (cont) {
54982
+ addAndConvert(cont, KEY_LISTENERS, listener);
54983
+ addAndConvert(cont, KEY_RAW, rawEmitter);
54984
+ } else {
54985
+ cont = {
54986
+ listeners: listener,
54987
+ rawEmitters: rawEmitter,
54988
+ options,
54989
+ watcher: watchFile(fullPath, options, (curr, prev) => {
54990
+ foreach(cont.rawEmitters, (rawEmitter2) => {
54991
+ rawEmitter2(EV.CHANGE, fullPath, { curr, prev });
54992
+ });
54993
+ const currmtime = curr.mtimeMs;
54994
+ if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
54995
+ foreach(cont.listeners, (listener2) => listener2(path, curr));
54996
+ }
54997
+ })
54998
+ };
54999
+ FsWatchFileInstances.set(fullPath, cont);
55000
+ }
55001
+ return () => {
55002
+ delFromSet(cont, KEY_LISTENERS, listener);
55003
+ delFromSet(cont, KEY_RAW, rawEmitter);
55004
+ if (isEmptySet(cont.listeners)) {
55005
+ FsWatchFileInstances.delete(fullPath);
55006
+ unwatchFile(fullPath);
55007
+ cont.options = cont.watcher = void 0;
55008
+ Object.freeze(cont);
55009
+ }
55010
+ };
55011
+ };
55012
+ var NodeFsHandler = class {
55013
+ constructor(fsW) {
55014
+ this.fsw = fsW;
55015
+ this._boundHandleError = (error) => fsW._handleError(error);
55016
+ }
55017
+ /**
55018
+ * Watch file for changes with fs_watchFile or fs_watch.
55019
+ * @param path to file or dir
55020
+ * @param listener on fs change
55021
+ * @returns closer for the watcher instance
55022
+ */
55023
+ _watchWithNodeFs(path, listener) {
55024
+ const opts = this.fsw.options;
55025
+ const directory = sysPath.dirname(path);
55026
+ const basename3 = sysPath.basename(path);
55027
+ const parent = this.fsw._getWatchedDir(directory);
55028
+ parent.add(basename3);
55029
+ const absolutePath = sysPath.resolve(path);
55030
+ const options = {
55031
+ persistent: opts.persistent
55032
+ };
55033
+ if (!listener)
55034
+ listener = EMPTY_FN;
55035
+ let closer;
55036
+ if (opts.usePolling) {
55037
+ const enableBin = opts.interval !== opts.binaryInterval;
55038
+ options.interval = enableBin && isBinaryPath(basename3) ? opts.binaryInterval : opts.interval;
55039
+ closer = setFsWatchFileListener(path, absolutePath, options, {
55040
+ listener,
55041
+ rawEmitter: this.fsw._emitRaw
55042
+ });
55043
+ } else {
55044
+ closer = setFsWatchListener(path, absolutePath, options, {
55045
+ listener,
55046
+ errHandler: this._boundHandleError,
55047
+ rawEmitter: this.fsw._emitRaw
55048
+ });
55049
+ }
55050
+ return closer;
55051
+ }
55052
+ /**
55053
+ * Watch a file and emit add event if warranted.
55054
+ * @returns closer for the watcher instance
55055
+ */
55056
+ _handleFile(file, stats, initialAdd) {
55057
+ if (this.fsw.closed) {
55058
+ return;
55059
+ }
55060
+ const dirname4 = sysPath.dirname(file);
55061
+ const basename3 = sysPath.basename(file);
55062
+ const parent = this.fsw._getWatchedDir(dirname4);
55063
+ let prevStats = stats;
55064
+ if (parent.has(basename3))
55065
+ return;
55066
+ const listener = async (path, newStats) => {
55067
+ if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
55068
+ return;
55069
+ if (!newStats || newStats.mtimeMs === 0) {
55070
+ try {
55071
+ const newStats2 = await stat2(file);
55072
+ if (this.fsw.closed)
55073
+ return;
55074
+ const at = newStats2.atimeMs;
55075
+ const mt = newStats2.mtimeMs;
55076
+ if (!at || at <= mt || mt !== prevStats.mtimeMs) {
55077
+ this.fsw._emit(EV.CHANGE, file, newStats2);
55078
+ }
55079
+ if ((isMacos || isLinux2 || isFreeBSD) && prevStats.ino !== newStats2.ino) {
55080
+ this.fsw._closeFile(path);
55081
+ prevStats = newStats2;
55082
+ const closer2 = this._watchWithNodeFs(file, listener);
55083
+ if (closer2)
55084
+ this.fsw._addPathCloser(path, closer2);
55085
+ } else {
55086
+ prevStats = newStats2;
55087
+ }
55088
+ } catch (error) {
55089
+ this.fsw._remove(dirname4, basename3);
55090
+ }
55091
+ } else if (parent.has(basename3)) {
55092
+ const at = newStats.atimeMs;
55093
+ const mt = newStats.mtimeMs;
55094
+ if (!at || at <= mt || mt !== prevStats.mtimeMs) {
55095
+ this.fsw._emit(EV.CHANGE, file, newStats);
55096
+ }
55097
+ prevStats = newStats;
55098
+ }
55099
+ };
55100
+ const closer = this._watchWithNodeFs(file, listener);
55101
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
55102
+ if (!this.fsw._throttle(EV.ADD, file, 0))
55103
+ return;
55104
+ this.fsw._emit(EV.ADD, file, stats);
55105
+ }
55106
+ return closer;
55107
+ }
55108
+ /**
55109
+ * Handle symlinks encountered while reading a dir.
55110
+ * @param entry returned by readdirp
55111
+ * @param directory path of dir being read
55112
+ * @param path of this item
55113
+ * @param item basename of this item
55114
+ * @returns true if no more processing is needed for this entry.
55115
+ */
55116
+ async _handleSymlink(entry, directory, path, item) {
55117
+ if (this.fsw.closed) {
55118
+ return;
55119
+ }
55120
+ const full = entry.fullPath;
55121
+ const dir = this.fsw._getWatchedDir(directory);
55122
+ if (!this.fsw.options.followSymlinks) {
55123
+ this.fsw._incrReadyCount();
55124
+ let linkPath;
55125
+ try {
55126
+ linkPath = await fsrealpath(path);
55127
+ } catch (e) {
55128
+ this.fsw._emitReady();
55129
+ return true;
55130
+ }
55131
+ if (this.fsw.closed)
55132
+ return;
55133
+ if (dir.has(item)) {
55134
+ if (this.fsw._symlinkPaths.get(full) !== linkPath) {
55135
+ this.fsw._symlinkPaths.set(full, linkPath);
55136
+ this.fsw._emit(EV.CHANGE, path, entry.stats);
55137
+ }
55138
+ } else {
55139
+ dir.add(item);
55140
+ this.fsw._symlinkPaths.set(full, linkPath);
55141
+ this.fsw._emit(EV.ADD, path, entry.stats);
55142
+ }
55143
+ this.fsw._emitReady();
55144
+ return true;
55145
+ }
55146
+ if (this.fsw._symlinkPaths.has(full)) {
55147
+ return true;
55148
+ }
55149
+ this.fsw._symlinkPaths.set(full, true);
55150
+ }
55151
+ _handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
55152
+ directory = sysPath.join(directory, "");
55153
+ throttler = this.fsw._throttle("readdir", directory, 1e3);
55154
+ if (!throttler)
55155
+ return;
55156
+ const previous = this.fsw._getWatchedDir(wh.path);
55157
+ const current = /* @__PURE__ */ new Set();
55158
+ let stream = this.fsw._readdirp(directory, {
55159
+ fileFilter: (entry) => wh.filterPath(entry),
55160
+ directoryFilter: (entry) => wh.filterDir(entry)
55161
+ });
55162
+ if (!stream)
55163
+ return;
55164
+ stream.on(STR_DATA, async (entry) => {
55165
+ if (this.fsw.closed) {
55166
+ stream = void 0;
55167
+ return;
55168
+ }
55169
+ const item = entry.path;
55170
+ let path = sysPath.join(directory, item);
55171
+ current.add(item);
55172
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) {
55173
+ return;
55174
+ }
55175
+ if (this.fsw.closed) {
55176
+ stream = void 0;
55177
+ return;
55178
+ }
55179
+ if (item === target || !target && !previous.has(item)) {
55180
+ this.fsw._incrReadyCount();
55181
+ path = sysPath.join(dir, sysPath.relative(dir, path));
55182
+ this._addToNodeFs(path, initialAdd, wh, depth + 1);
55183
+ }
55184
+ }).on(EV.ERROR, this._boundHandleError);
55185
+ return new Promise((resolve3, reject) => {
55186
+ if (!stream)
55187
+ return reject();
55188
+ stream.once(STR_END, () => {
55189
+ if (this.fsw.closed) {
55190
+ stream = void 0;
55191
+ return;
55192
+ }
55193
+ const wasThrottled = throttler ? throttler.clear() : false;
55194
+ resolve3(void 0);
55195
+ previous.getChildren().filter((item) => {
55196
+ return item !== directory && !current.has(item);
55197
+ }).forEach((item) => {
55198
+ this.fsw._remove(directory, item);
55199
+ });
55200
+ stream = void 0;
55201
+ if (wasThrottled)
55202
+ this._handleRead(directory, false, wh, target, dir, depth, throttler);
55203
+ });
55204
+ });
55205
+ }
55206
+ /**
55207
+ * Read directory to add / remove files from `@watched` list and re-read it on change.
55208
+ * @param dir fs path
55209
+ * @param stats
55210
+ * @param initialAdd
55211
+ * @param depth relative to user-supplied path
55212
+ * @param target child path targeted for watch
55213
+ * @param wh Common watch helpers for this path
55214
+ * @param realpath
55215
+ * @returns closer for the watcher instance.
55216
+ */
55217
+ async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath2) {
55218
+ const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
55219
+ const tracked = parentDir.has(sysPath.basename(dir));
55220
+ if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
55221
+ this.fsw._emit(EV.ADD_DIR, dir, stats);
55222
+ }
55223
+ parentDir.add(sysPath.basename(dir));
55224
+ this.fsw._getWatchedDir(dir);
55225
+ let throttler;
55226
+ let closer;
55227
+ const oDepth = this.fsw.options.depth;
55228
+ if ((oDepth == null || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath2)) {
55229
+ if (!target) {
55230
+ await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
55231
+ if (this.fsw.closed)
55232
+ return;
55233
+ }
55234
+ closer = this._watchWithNodeFs(dir, (dirPath, stats2) => {
55235
+ if (stats2 && stats2.mtimeMs === 0)
55236
+ return;
55237
+ this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
55238
+ });
55239
+ }
55240
+ return closer;
55241
+ }
55242
+ /**
55243
+ * Handle added file, directory, or glob pattern.
55244
+ * Delegates call to _handleFile / _handleDir after checks.
55245
+ * @param path to file or ir
55246
+ * @param initialAdd was the file added at watch instantiation?
55247
+ * @param priorWh depth relative to user-supplied path
55248
+ * @param depth Child path actually targeted for watch
55249
+ * @param target Child path actually targeted for watch
55250
+ */
55251
+ async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
55252
+ const ready = this.fsw._emitReady;
55253
+ if (this.fsw._isIgnored(path) || this.fsw.closed) {
55254
+ ready();
55255
+ return false;
55256
+ }
55257
+ const wh = this.fsw._getWatchHelpers(path);
55258
+ if (priorWh) {
55259
+ wh.filterPath = (entry) => priorWh.filterPath(entry);
55260
+ wh.filterDir = (entry) => priorWh.filterDir(entry);
55261
+ }
55262
+ try {
55263
+ const stats = await statMethods[wh.statMethod](wh.watchPath);
55264
+ if (this.fsw.closed)
55265
+ return;
55266
+ if (this.fsw._isIgnored(wh.watchPath, stats)) {
55267
+ ready();
55268
+ return false;
55269
+ }
55270
+ const follow = this.fsw.options.followSymlinks;
55271
+ let closer;
55272
+ if (stats.isDirectory()) {
55273
+ const absPath = sysPath.resolve(path);
55274
+ const targetPath = follow ? await fsrealpath(path) : path;
55275
+ if (this.fsw.closed)
55276
+ return;
55277
+ closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
55278
+ if (this.fsw.closed)
55279
+ return;
55280
+ if (absPath !== targetPath && targetPath !== void 0) {
55281
+ this.fsw._symlinkPaths.set(absPath, targetPath);
55282
+ }
55283
+ } else if (stats.isSymbolicLink()) {
55284
+ const targetPath = follow ? await fsrealpath(path) : path;
55285
+ if (this.fsw.closed)
55286
+ return;
55287
+ const parent = sysPath.dirname(wh.watchPath);
55288
+ this.fsw._getWatchedDir(parent).add(wh.watchPath);
55289
+ this.fsw._emit(EV.ADD, wh.watchPath, stats);
55290
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
55291
+ if (this.fsw.closed)
55292
+ return;
55293
+ if (targetPath !== void 0) {
55294
+ this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath);
55295
+ }
55296
+ } else {
55297
+ closer = this._handleFile(wh.watchPath, stats, initialAdd);
55298
+ }
55299
+ ready();
55300
+ if (closer)
55301
+ this.fsw._addPathCloser(path, closer);
55302
+ return false;
55303
+ } catch (error) {
55304
+ if (this.fsw._handleError(error)) {
55305
+ ready();
55306
+ return path;
55307
+ }
55308
+ }
55309
+ }
55310
+ };
55311
+
55312
+ // node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js
55313
+ var SLASH = "/";
55314
+ var SLASH_SLASH = "//";
55315
+ var ONE_DOT = ".";
55316
+ var TWO_DOTS = "..";
55317
+ var STRING_TYPE = "string";
55318
+ var BACK_SLASH_RE = /\\/g;
55319
+ var DOUBLE_SLASH_RE = /\/\//;
55320
+ var DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
55321
+ var REPLACER_RE = /^\.[/\\]/;
55322
+ function arrify(item) {
55323
+ return Array.isArray(item) ? item : [item];
55324
+ }
55325
+ var isMatcherObject = (matcher) => typeof matcher === "object" && matcher !== null && !(matcher instanceof RegExp);
55326
+ function createPattern(matcher) {
55327
+ if (typeof matcher === "function")
55328
+ return matcher;
55329
+ if (typeof matcher === "string")
55330
+ return (string) => matcher === string;
55331
+ if (matcher instanceof RegExp)
55332
+ return (string) => matcher.test(string);
55333
+ if (typeof matcher === "object" && matcher !== null) {
55334
+ return (string) => {
55335
+ if (matcher.path === string)
55336
+ return true;
55337
+ if (matcher.recursive) {
55338
+ const relative3 = sysPath2.relative(matcher.path, string);
55339
+ if (!relative3) {
55340
+ return false;
55341
+ }
55342
+ return !relative3.startsWith("..") && !sysPath2.isAbsolute(relative3);
55343
+ }
55344
+ return false;
55345
+ };
55346
+ }
55347
+ return () => false;
55348
+ }
55349
+ function normalizePath(path) {
55350
+ if (typeof path !== "string")
55351
+ throw new Error("string expected");
55352
+ path = sysPath2.normalize(path);
55353
+ path = path.replace(/\\/g, "/");
55354
+ let prepend = false;
55355
+ if (path.startsWith("//"))
55356
+ prepend = true;
55357
+ const DOUBLE_SLASH_RE2 = /\/\//;
55358
+ while (path.match(DOUBLE_SLASH_RE2))
55359
+ path = path.replace(DOUBLE_SLASH_RE2, "/");
55360
+ if (prepend)
55361
+ path = "/" + path;
55362
+ return path;
55363
+ }
55364
+ function matchPatterns(patterns, testString, stats) {
55365
+ const path = normalizePath(testString);
55366
+ for (let index = 0; index < patterns.length; index++) {
55367
+ const pattern = patterns[index];
55368
+ if (pattern(path, stats)) {
55369
+ return true;
55370
+ }
55371
+ }
55372
+ return false;
55373
+ }
55374
+ function anymatch(matchers, testString) {
55375
+ if (matchers == null) {
55376
+ throw new TypeError("anymatch: specify first argument");
55377
+ }
55378
+ const matchersArray = arrify(matchers);
55379
+ const patterns = matchersArray.map((matcher) => createPattern(matcher));
55380
+ if (testString == null) {
55381
+ return (testString2, stats) => {
55382
+ return matchPatterns(patterns, testString2, stats);
55383
+ };
55384
+ }
55385
+ return matchPatterns(patterns, testString);
55386
+ }
55387
+ var unifyPaths = (paths_) => {
55388
+ const paths = arrify(paths_).flat();
55389
+ if (!paths.every((p) => typeof p === STRING_TYPE)) {
55390
+ throw new TypeError(`Non-string provided as watch path: ${paths}`);
55391
+ }
55392
+ return paths.map(normalizePathToUnix);
55393
+ };
55394
+ var toUnix = (string) => {
55395
+ let str = string.replace(BACK_SLASH_RE, SLASH);
55396
+ let prepend = false;
55397
+ if (str.startsWith(SLASH_SLASH)) {
55398
+ prepend = true;
55399
+ }
55400
+ while (str.match(DOUBLE_SLASH_RE)) {
55401
+ str = str.replace(DOUBLE_SLASH_RE, SLASH);
55402
+ }
55403
+ if (prepend) {
55404
+ str = SLASH + str;
55405
+ }
55406
+ return str;
55407
+ };
55408
+ var normalizePathToUnix = (path) => toUnix(sysPath2.normalize(toUnix(path)));
55409
+ var normalizeIgnored = (cwd2 = "") => (path) => {
55410
+ if (typeof path === "string") {
55411
+ return normalizePathToUnix(sysPath2.isAbsolute(path) ? path : sysPath2.join(cwd2, path));
55412
+ } else {
55413
+ return path;
55414
+ }
55415
+ };
55416
+ var getAbsolutePath = (path, cwd2) => {
55417
+ if (sysPath2.isAbsolute(path)) {
55418
+ return path;
55419
+ }
55420
+ return sysPath2.join(cwd2, path);
55421
+ };
55422
+ var EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
55423
+ var DirEntry = class {
55424
+ constructor(dir, removeWatcher) {
55425
+ this.path = dir;
55426
+ this._removeWatcher = removeWatcher;
55427
+ this.items = /* @__PURE__ */ new Set();
55428
+ }
55429
+ add(item) {
55430
+ const { items } = this;
55431
+ if (!items)
55432
+ return;
55433
+ if (item !== ONE_DOT && item !== TWO_DOTS)
55434
+ items.add(item);
55435
+ }
55436
+ async remove(item) {
55437
+ const { items } = this;
55438
+ if (!items)
55439
+ return;
55440
+ items.delete(item);
55441
+ if (items.size > 0)
55442
+ return;
55443
+ const dir = this.path;
55444
+ try {
55445
+ await readdir2(dir);
55446
+ } catch (err) {
55447
+ if (this._removeWatcher) {
55448
+ this._removeWatcher(sysPath2.dirname(dir), sysPath2.basename(dir));
55449
+ }
55450
+ }
55451
+ }
55452
+ has(item) {
55453
+ const { items } = this;
55454
+ if (!items)
55455
+ return;
55456
+ return items.has(item);
55457
+ }
55458
+ getChildren() {
55459
+ const { items } = this;
55460
+ if (!items)
55461
+ return [];
55462
+ return [...items.values()];
55463
+ }
55464
+ dispose() {
55465
+ this.items.clear();
55466
+ this.path = "";
55467
+ this._removeWatcher = EMPTY_FN;
55468
+ this.items = EMPTY_SET;
55469
+ Object.freeze(this);
55470
+ }
55471
+ };
55472
+ var STAT_METHOD_F = "stat";
55473
+ var STAT_METHOD_L = "lstat";
55474
+ var WatchHelper = class {
55475
+ constructor(path, follow, fsw) {
55476
+ this.fsw = fsw;
55477
+ const watchPath = path;
55478
+ this.path = path = path.replace(REPLACER_RE, "");
55479
+ this.watchPath = watchPath;
55480
+ this.fullWatchPath = sysPath2.resolve(watchPath);
55481
+ this.dirParts = [];
55482
+ this.dirParts.forEach((parts) => {
55483
+ if (parts.length > 1)
55484
+ parts.pop();
55485
+ });
55486
+ this.followSymlinks = follow;
55487
+ this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
55488
+ }
55489
+ entryPath(entry) {
55490
+ return sysPath2.join(this.watchPath, sysPath2.relative(this.watchPath, entry.fullPath));
55491
+ }
55492
+ filterPath(entry) {
55493
+ const { stats } = entry;
55494
+ if (stats && stats.isSymbolicLink())
55495
+ return this.filterDir(entry);
55496
+ const resolvedPath = this.entryPath(entry);
55497
+ return this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
55498
+ }
55499
+ filterDir(entry) {
55500
+ return this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
55501
+ }
55502
+ };
55503
+ var FSWatcher = class extends EventEmitter3 {
55504
+ // Not indenting methods for history sake; for now.
55505
+ constructor(_opts = {}) {
55506
+ super();
55507
+ this.closed = false;
55508
+ this._closers = /* @__PURE__ */ new Map();
55509
+ this._ignoredPaths = /* @__PURE__ */ new Set();
55510
+ this._throttled = /* @__PURE__ */ new Map();
55511
+ this._streams = /* @__PURE__ */ new Set();
55512
+ this._symlinkPaths = /* @__PURE__ */ new Map();
55513
+ this._watched = /* @__PURE__ */ new Map();
55514
+ this._pendingWrites = /* @__PURE__ */ new Map();
55515
+ this._pendingUnlinks = /* @__PURE__ */ new Map();
55516
+ this._readyCount = 0;
55517
+ this._readyEmitted = false;
55518
+ const awf = _opts.awaitWriteFinish;
55519
+ const DEF_AWF = { stabilityThreshold: 2e3, pollInterval: 100 };
55520
+ const opts = {
55521
+ // Defaults
55522
+ persistent: true,
55523
+ ignoreInitial: false,
55524
+ ignorePermissionErrors: false,
55525
+ interval: 100,
55526
+ binaryInterval: 300,
55527
+ followSymlinks: true,
55528
+ usePolling: false,
55529
+ // useAsync: false,
55530
+ atomic: true,
55531
+ // NOTE: overwritten later (depends on usePolling)
55532
+ ..._opts,
55533
+ // Change format
55534
+ ignored: _opts.ignored ? arrify(_opts.ignored) : arrify([]),
55535
+ awaitWriteFinish: awf === true ? DEF_AWF : typeof awf === "object" ? { ...DEF_AWF, ...awf } : false
55536
+ };
55537
+ if (isIBMi)
55538
+ opts.usePolling = true;
55539
+ if (opts.atomic === void 0)
55540
+ opts.atomic = !opts.usePolling;
55541
+ const envPoll = process.env.CHOKIDAR_USEPOLLING;
55542
+ if (envPoll !== void 0) {
55543
+ const envLower = envPoll.toLowerCase();
55544
+ if (envLower === "false" || envLower === "0")
55545
+ opts.usePolling = false;
55546
+ else if (envLower === "true" || envLower === "1")
55547
+ opts.usePolling = true;
55548
+ else
55549
+ opts.usePolling = !!envLower;
55550
+ }
55551
+ const envInterval = process.env.CHOKIDAR_INTERVAL;
55552
+ if (envInterval)
55553
+ opts.interval = Number.parseInt(envInterval, 10);
55554
+ let readyCalls = 0;
55555
+ this._emitReady = () => {
55556
+ readyCalls++;
55557
+ if (readyCalls >= this._readyCount) {
55558
+ this._emitReady = EMPTY_FN;
55559
+ this._readyEmitted = true;
55560
+ process.nextTick(() => this.emit(EVENTS.READY));
55561
+ }
55562
+ };
55563
+ this._emitRaw = (...args) => this.emit(EVENTS.RAW, ...args);
55564
+ this._boundRemove = this._remove.bind(this);
55565
+ this.options = opts;
55566
+ this._nodeFsHandler = new NodeFsHandler(this);
55567
+ Object.freeze(opts);
55568
+ }
55569
+ _addIgnoredPath(matcher) {
55570
+ if (isMatcherObject(matcher)) {
55571
+ for (const ignored of this._ignoredPaths) {
55572
+ if (isMatcherObject(ignored) && ignored.path === matcher.path && ignored.recursive === matcher.recursive) {
55573
+ return;
55574
+ }
55575
+ }
55576
+ }
55577
+ this._ignoredPaths.add(matcher);
55578
+ }
55579
+ _removeIgnoredPath(matcher) {
55580
+ this._ignoredPaths.delete(matcher);
55581
+ if (typeof matcher === "string") {
55582
+ for (const ignored of this._ignoredPaths) {
55583
+ if (isMatcherObject(ignored) && ignored.path === matcher) {
55584
+ this._ignoredPaths.delete(ignored);
55585
+ }
55586
+ }
55587
+ }
55588
+ }
55589
+ // Public methods
55590
+ /**
55591
+ * Adds paths to be watched on an existing FSWatcher instance.
55592
+ * @param paths_ file or file list. Other arguments are unused
55593
+ */
55594
+ add(paths_, _origAdd, _internal) {
55595
+ const { cwd: cwd2 } = this.options;
55596
+ this.closed = false;
55597
+ this._closePromise = void 0;
55598
+ let paths = unifyPaths(paths_);
55599
+ if (cwd2) {
55600
+ paths = paths.map((path) => {
55601
+ const absPath = getAbsolutePath(path, cwd2);
55602
+ return absPath;
55603
+ });
55604
+ }
55605
+ paths.forEach((path) => {
55606
+ this._removeIgnoredPath(path);
55607
+ });
55608
+ this._userIgnored = void 0;
55609
+ if (!this._readyCount)
55610
+ this._readyCount = 0;
55611
+ this._readyCount += paths.length;
55612
+ Promise.all(paths.map(async (path) => {
55613
+ const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, void 0, 0, _origAdd);
55614
+ if (res)
55615
+ this._emitReady();
55616
+ return res;
55617
+ })).then((results) => {
55618
+ if (this.closed)
55619
+ return;
55620
+ results.forEach((item) => {
55621
+ if (item)
55622
+ this.add(sysPath2.dirname(item), sysPath2.basename(_origAdd || item));
55623
+ });
55624
+ });
55625
+ return this;
55626
+ }
55627
+ /**
55628
+ * Close watchers or start ignoring events from specified paths.
55629
+ */
55630
+ unwatch(paths_) {
55631
+ if (this.closed)
55632
+ return this;
55633
+ const paths = unifyPaths(paths_);
55634
+ const { cwd: cwd2 } = this.options;
55635
+ paths.forEach((path) => {
55636
+ if (!sysPath2.isAbsolute(path) && !this._closers.has(path)) {
55637
+ if (cwd2)
55638
+ path = sysPath2.join(cwd2, path);
55639
+ path = sysPath2.resolve(path);
55640
+ }
55641
+ this._closePath(path);
55642
+ this._addIgnoredPath(path);
55643
+ if (this._watched.has(path)) {
55644
+ this._addIgnoredPath({
55645
+ path,
55646
+ recursive: true
55647
+ });
55648
+ }
55649
+ this._userIgnored = void 0;
55650
+ });
55651
+ return this;
55652
+ }
55653
+ /**
55654
+ * Close watchers and remove all listeners from watched paths.
55655
+ */
55656
+ close() {
55657
+ if (this._closePromise) {
55658
+ return this._closePromise;
55659
+ }
55660
+ this.closed = true;
55661
+ this.removeAllListeners();
55662
+ const closers = [];
55663
+ this._closers.forEach((closerList) => closerList.forEach((closer) => {
55664
+ const promise = closer();
55665
+ if (promise instanceof Promise)
55666
+ closers.push(promise);
55667
+ }));
55668
+ this._streams.forEach((stream) => stream.destroy());
55669
+ this._userIgnored = void 0;
55670
+ this._readyCount = 0;
55671
+ this._readyEmitted = false;
55672
+ this._watched.forEach((dirent) => dirent.dispose());
55673
+ this._closers.clear();
55674
+ this._watched.clear();
55675
+ this._streams.clear();
55676
+ this._symlinkPaths.clear();
55677
+ this._throttled.clear();
55678
+ this._closePromise = closers.length ? Promise.all(closers).then(() => void 0) : Promise.resolve();
55679
+ return this._closePromise;
55680
+ }
55681
+ /**
55682
+ * Expose list of watched paths
55683
+ * @returns for chaining
55684
+ */
55685
+ getWatched() {
55686
+ const watchList = {};
55687
+ this._watched.forEach((entry, dir) => {
55688
+ const key = this.options.cwd ? sysPath2.relative(this.options.cwd, dir) : dir;
55689
+ const index = key || ONE_DOT;
55690
+ watchList[index] = entry.getChildren().sort();
55691
+ });
55692
+ return watchList;
55693
+ }
55694
+ emitWithAll(event, args) {
55695
+ this.emit(event, ...args);
55696
+ if (event !== EVENTS.ERROR)
55697
+ this.emit(EVENTS.ALL, event, ...args);
55698
+ }
55699
+ // Common helpers
55700
+ // --------------
55701
+ /**
55702
+ * Normalize and emit events.
55703
+ * Calling _emit DOES NOT MEAN emit() would be called!
55704
+ * @param event Type of event
55705
+ * @param path File or directory path
55706
+ * @param stats arguments to be passed with event
55707
+ * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
55708
+ */
55709
+ async _emit(event, path, stats) {
55710
+ if (this.closed)
55711
+ return;
55712
+ const opts = this.options;
55713
+ if (isWindows3)
55714
+ path = sysPath2.normalize(path);
55715
+ if (opts.cwd)
55716
+ path = sysPath2.relative(opts.cwd, path);
55717
+ const args = [path];
55718
+ if (stats != null)
55719
+ args.push(stats);
55720
+ const awf = opts.awaitWriteFinish;
55721
+ let pw;
55722
+ if (awf && (pw = this._pendingWrites.get(path))) {
55723
+ pw.lastChange = /* @__PURE__ */ new Date();
55724
+ return this;
55725
+ }
55726
+ if (opts.atomic) {
55727
+ if (event === EVENTS.UNLINK) {
55728
+ this._pendingUnlinks.set(path, [event, ...args]);
55729
+ setTimeout(() => {
55730
+ this._pendingUnlinks.forEach((entry, path2) => {
55731
+ this.emit(...entry);
55732
+ this.emit(EVENTS.ALL, ...entry);
55733
+ this._pendingUnlinks.delete(path2);
55734
+ });
55735
+ }, typeof opts.atomic === "number" ? opts.atomic : 100);
55736
+ return this;
55737
+ }
55738
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path)) {
55739
+ event = EVENTS.CHANGE;
55740
+ this._pendingUnlinks.delete(path);
55741
+ }
55742
+ }
55743
+ if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
55744
+ const awfEmit = (err, stats2) => {
55745
+ if (err) {
55746
+ event = EVENTS.ERROR;
55747
+ args[0] = err;
55748
+ this.emitWithAll(event, args);
55749
+ } else if (stats2) {
55750
+ if (args.length > 1) {
55751
+ args[1] = stats2;
55752
+ } else {
55753
+ args.push(stats2);
55754
+ }
55755
+ this.emitWithAll(event, args);
55756
+ }
55757
+ };
55758
+ this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
55759
+ return this;
55760
+ }
55761
+ if (event === EVENTS.CHANGE) {
55762
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path, 50);
55763
+ if (isThrottled)
55764
+ return this;
55765
+ }
55766
+ if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
55767
+ const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path) : path;
55768
+ let stats2;
55769
+ try {
55770
+ stats2 = await stat3(fullPath);
55771
+ } catch (err) {
55772
+ }
55773
+ if (!stats2 || this.closed)
55774
+ return;
55775
+ args.push(stats2);
55776
+ }
55777
+ this.emitWithAll(event, args);
55778
+ return this;
55779
+ }
55780
+ /**
55781
+ * Common handler for errors
55782
+ * @returns The error if defined, otherwise the value of the FSWatcher instance's `closed` flag
55783
+ */
55784
+ _handleError(error) {
55785
+ const code = error && error.code;
55786
+ if (error && code !== "ENOENT" && code !== "ENOTDIR" && (!this.options.ignorePermissionErrors || code !== "EPERM" && code !== "EACCES")) {
55787
+ this.emit(EVENTS.ERROR, error);
55788
+ }
55789
+ return error || this.closed;
55790
+ }
55791
+ /**
55792
+ * Helper utility for throttling
55793
+ * @param actionType type being throttled
55794
+ * @param path being acted upon
55795
+ * @param timeout duration of time to suppress duplicate actions
55796
+ * @returns tracking object or false if action should be suppressed
55797
+ */
55798
+ _throttle(actionType, path, timeout) {
55799
+ if (!this._throttled.has(actionType)) {
55800
+ this._throttled.set(actionType, /* @__PURE__ */ new Map());
55801
+ }
55802
+ const action = this._throttled.get(actionType);
55803
+ if (!action)
55804
+ throw new Error("invalid throttle");
55805
+ const actionPath = action.get(path);
55806
+ if (actionPath) {
55807
+ actionPath.count++;
55808
+ return false;
55809
+ }
55810
+ let timeoutObject;
55811
+ const clear = () => {
55812
+ const item = action.get(path);
55813
+ const count = item ? item.count : 0;
55814
+ action.delete(path);
55815
+ clearTimeout(timeoutObject);
55816
+ if (item)
55817
+ clearTimeout(item.timeoutObject);
55818
+ return count;
55819
+ };
55820
+ timeoutObject = setTimeout(clear, timeout);
55821
+ const thr = { timeoutObject, clear, count: 0 };
55822
+ action.set(path, thr);
55823
+ return thr;
55824
+ }
55825
+ _incrReadyCount() {
55826
+ return this._readyCount++;
55827
+ }
55828
+ /**
55829
+ * Awaits write operation to finish.
55830
+ * Polls a newly created file for size variations. When files size does not change for 'threshold' milliseconds calls callback.
55831
+ * @param path being acted upon
55832
+ * @param threshold Time in milliseconds a file size must be fixed before acknowledging write OP is finished
55833
+ * @param event
55834
+ * @param awfEmit Callback to be called when ready for event to be emitted.
55835
+ */
55836
+ _awaitWriteFinish(path, threshold, event, awfEmit) {
55837
+ const awf = this.options.awaitWriteFinish;
55838
+ if (typeof awf !== "object")
55839
+ return;
55840
+ const pollInterval = awf.pollInterval;
55841
+ let timeoutHandler;
55842
+ let fullPath = path;
55843
+ if (this.options.cwd && !sysPath2.isAbsolute(path)) {
55844
+ fullPath = sysPath2.join(this.options.cwd, path);
55845
+ }
55846
+ const now = /* @__PURE__ */ new Date();
55847
+ const writes = this._pendingWrites;
55848
+ function awaitWriteFinishFn(prevStat) {
55849
+ statcb(fullPath, (err, curStat) => {
55850
+ if (err || !writes.has(path)) {
55851
+ if (err && err.code !== "ENOENT")
55852
+ awfEmit(err);
55853
+ return;
55854
+ }
55855
+ const now2 = Number(/* @__PURE__ */ new Date());
55856
+ if (prevStat && curStat.size !== prevStat.size) {
55857
+ writes.get(path).lastChange = now2;
55858
+ }
55859
+ const pw = writes.get(path);
55860
+ const df = now2 - pw.lastChange;
55861
+ if (df >= threshold) {
55862
+ writes.delete(path);
55863
+ awfEmit(void 0, curStat);
55864
+ } else {
55865
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
55866
+ }
55867
+ });
55868
+ }
55869
+ if (!writes.has(path)) {
55870
+ writes.set(path, {
55871
+ lastChange: now,
55872
+ cancelWait: () => {
55873
+ writes.delete(path);
55874
+ clearTimeout(timeoutHandler);
55875
+ return event;
55876
+ }
55877
+ });
55878
+ timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
55879
+ }
55880
+ }
55881
+ /**
55882
+ * Determines whether user has asked to ignore this path.
55883
+ */
55884
+ _isIgnored(path, stats) {
55885
+ if (this.options.atomic && DOT_RE.test(path))
55886
+ return true;
55887
+ if (!this._userIgnored) {
55888
+ const { cwd: cwd2 } = this.options;
55889
+ const ign = this.options.ignored;
55890
+ const ignored = (ign || []).map(normalizeIgnored(cwd2));
55891
+ const ignoredPaths = [...this._ignoredPaths];
55892
+ const list = [...ignoredPaths.map(normalizeIgnored(cwd2)), ...ignored];
55893
+ this._userIgnored = anymatch(list, void 0);
55894
+ }
55895
+ return this._userIgnored(path, stats);
55896
+ }
55897
+ _isntIgnored(path, stat4) {
55898
+ return !this._isIgnored(path, stat4);
55899
+ }
55900
+ /**
55901
+ * Provides a set of common helpers and properties relating to symlink handling.
55902
+ * @param path file or directory pattern being watched
55903
+ */
55904
+ _getWatchHelpers(path) {
55905
+ return new WatchHelper(path, this.options.followSymlinks, this);
55906
+ }
55907
+ // Directory helpers
55908
+ // -----------------
55909
+ /**
55910
+ * Provides directory tracking objects
55911
+ * @param directory path of the directory
55912
+ */
55913
+ _getWatchedDir(directory) {
55914
+ const dir = sysPath2.resolve(directory);
55915
+ if (!this._watched.has(dir))
55916
+ this._watched.set(dir, new DirEntry(dir, this._boundRemove));
55917
+ return this._watched.get(dir);
55918
+ }
55919
+ // File helpers
55920
+ // ------------
55921
+ /**
55922
+ * Check for read permissions: https://stackoverflow.com/a/11781404/1358405
55923
+ */
55924
+ _hasReadPermissions(stats) {
55925
+ if (this.options.ignorePermissionErrors)
55926
+ return true;
55927
+ return Boolean(Number(stats.mode) & 256);
55928
+ }
55929
+ /**
55930
+ * Handles emitting unlink events for
55931
+ * files and directories, and via recursion, for
55932
+ * files and directories within directories that are unlinked
55933
+ * @param directory within which the following item is located
55934
+ * @param item base path of item/directory
55935
+ */
55936
+ _remove(directory, item, isDirectory) {
55937
+ const path = sysPath2.join(directory, item);
55938
+ const fullPath = sysPath2.resolve(path);
55939
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
55940
+ if (!this._throttle("remove", path, 100))
55941
+ return;
55942
+ if (!isDirectory && this._watched.size === 1) {
55943
+ this.add(directory, item, true);
55944
+ }
55945
+ const wp = this._getWatchedDir(path);
55946
+ const nestedDirectoryChildren = wp.getChildren();
55947
+ nestedDirectoryChildren.forEach((nested) => this._remove(path, nested));
55948
+ const parent = this._getWatchedDir(directory);
55949
+ const wasTracked = parent.has(item);
55950
+ parent.remove(item);
55951
+ if (this._symlinkPaths.has(fullPath)) {
55952
+ this._symlinkPaths.delete(fullPath);
55953
+ }
55954
+ let relPath = path;
55955
+ if (this.options.cwd)
55956
+ relPath = sysPath2.relative(this.options.cwd, path);
55957
+ if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
55958
+ const event = this._pendingWrites.get(relPath).cancelWait();
55959
+ if (event === EVENTS.ADD)
55960
+ return;
55961
+ }
55962
+ this._watched.delete(path);
55963
+ this._watched.delete(fullPath);
55964
+ const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
55965
+ if (wasTracked && !this._isIgnored(path))
55966
+ this._emit(eventName, path);
55967
+ this._closePath(path);
55968
+ }
55969
+ /**
55970
+ * Closes all watchers for a path
55971
+ */
55972
+ _closePath(path) {
55973
+ this._closeFile(path);
55974
+ const dir = sysPath2.dirname(path);
55975
+ this._getWatchedDir(dir).remove(sysPath2.basename(path));
55976
+ }
55977
+ /**
55978
+ * Closes only file-specific watchers
55979
+ */
55980
+ _closeFile(path) {
55981
+ const closers = this._closers.get(path);
55982
+ if (!closers)
55983
+ return;
55984
+ closers.forEach((closer) => closer());
55985
+ this._closers.delete(path);
55986
+ }
55987
+ _addPathCloser(path, closer) {
55988
+ if (!closer)
55989
+ return;
55990
+ let list = this._closers.get(path);
55991
+ if (!list) {
55992
+ list = [];
55993
+ this._closers.set(path, list);
55994
+ }
55995
+ list.push(closer);
55996
+ }
55997
+ _readdirp(root, opts) {
55998
+ if (this.closed)
55999
+ return;
56000
+ const options = { type: EVENTS.ALL, alwaysStat: true, lstat: true, ...opts, depth: 0 };
56001
+ let stream = readdirp(root, options);
56002
+ this._streams.add(stream);
56003
+ stream.once(STR_CLOSE, () => {
56004
+ stream = void 0;
56005
+ });
56006
+ stream.once(STR_END, () => {
56007
+ if (stream) {
56008
+ this._streams.delete(stream);
56009
+ stream = void 0;
56010
+ }
56011
+ });
56012
+ return stream;
56013
+ }
56014
+ };
56015
+ function watch(paths, options = {}) {
56016
+ const watcher = new FSWatcher(options);
56017
+ watcher.add(paths);
56018
+ return watcher;
56019
+ }
56020
+
56021
+ // src/cli/screens/board.tsx
56022
+ import { join as join6 } from "path";
56023
+
54320
56024
  // src/cli/lib/board-reader.ts
54321
56025
  import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
54322
- import { dirname, join as join2 } from "path";
56026
+ import { dirname as dirname3, join as join4 } from "path";
54323
56027
 
54324
56028
  // src/lib/types.ts
54325
56029
  var DEFAULT_COLUMNS = ["Backlog", "Todo", "In Progress", "Review", "Done"];
@@ -54503,10 +56207,10 @@ function serializeTaskFile(frontmatter, body) {
54503
56207
 
54504
56208
  // src/cli/lib/board-reader.ts
54505
56209
  function getProjectRoot(kandownDir) {
54506
- return dirname(kandownDir);
56210
+ return dirname3(kandownDir);
54507
56211
  }
54508
56212
  function listTaskIds(kandownDir) {
54509
- const tasksDir = join2(kandownDir, "tasks");
56213
+ const tasksDir = join4(kandownDir, "tasks");
54510
56214
  if (!existsSync3(tasksDir)) return [];
54511
56215
  return readdirSync(tasksDir).filter((name) => name.endsWith(".md")).map((name) => name.slice(0, -3)).sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
54512
56216
  }
@@ -54530,7 +56234,7 @@ function readBoard(kandownDir) {
54530
56234
  };
54531
56235
  }
54532
56236
  function readTask(kandownDir, taskId) {
54533
- const taskPath = join2(kandownDir, "tasks", `${taskId}.md`);
56237
+ const taskPath = join4(kandownDir, "tasks", `${taskId}.md`);
54534
56238
  if (!existsSync3(taskPath)) {
54535
56239
  return {
54536
56240
  frontmatter: { id: taskId, title: `Task ${taskId}`, status: "Backlog" },
@@ -54551,9 +56255,9 @@ function readTask(kandownDir, taskId) {
54551
56255
  function readAgentDoc(kandownDir) {
54552
56256
  const root = getProjectRoot(kandownDir);
54553
56257
  const candidates = [
54554
- join2(root, "AGENT_KANDOWN_COMPACT.md"),
54555
- join2(root, "AGENT_KANDOWN.md"),
54556
- join2(kandownDir, "AGENT.md")
56258
+ join4(root, "AGENT_KANDOWN_COMPACT.md"),
56259
+ join4(root, "AGENT_KANDOWN.md"),
56260
+ join4(kandownDir, "AGENT.md")
54557
56261
  ];
54558
56262
  for (const candidate of candidates) {
54559
56263
  if (existsSync3(candidate)) {
@@ -54563,7 +56267,7 @@ function readAgentDoc(kandownDir) {
54563
56267
  return "";
54564
56268
  }
54565
56269
  function moveTaskToColumn(kandownDir, taskId, targetColumn) {
54566
- const taskPath = join2(kandownDir, "tasks", `${taskId}.md`);
56270
+ const taskPath = join4(kandownDir, "tasks", `${taskId}.md`);
54567
56271
  if (!existsSync3(taskPath)) return false;
54568
56272
  const parsed = readTask(kandownDir, taskId);
54569
56273
  writeFileSync2(taskPath, serializeTaskFile({
@@ -54705,7 +56409,7 @@ function buildPrompt(agentDoc, taskContent, taskId, kandownDir) {
54705
56409
  // src/cli/lib/launcher.ts
54706
56410
  import { execSync, spawn } from "child_process";
54707
56411
  import { writeFileSync as writeFileSync3 } from "fs";
54708
- import { join as join3 } from "path";
56412
+ import { join as join5 } from "path";
54709
56413
  import { tmpdir } from "os";
54710
56414
  function isInTmux() {
54711
56415
  return !!process.env.TMUX;
@@ -54729,7 +56433,7 @@ function launchAgent(opts) {
54729
56433
  ].join("\n");
54730
56434
  const { systemPrompt, taskPrompt } = buildPrompt(agentDoc, taskFileContent, taskId, kandownDir);
54731
56435
  moveTaskToColumn(kandownDir, taskId, "In Progress");
54732
- const contextFile = join3(tmpdir(), `kandown-${taskId}-context.md`);
56436
+ const contextFile = join5(tmpdir(), `kandown-${taskId}-context.md`);
54733
56437
  writeFileSync3(contextFile, `${systemPrompt}
54734
56438
 
54735
56439
  ---
@@ -54863,6 +56567,7 @@ function calcColWidth(numCols) {
54863
56567
  var RE_HEADER = /^#{1,3}\s/;
54864
56568
  var RE_SUBTASK = /^\s*-\s+\[([ xX])\]/;
54865
56569
  var RE_DONE_SUBTASK = /^\s*-\s+\[x\]/i;
56570
+ var RE_BRACKET_TAG = /^\[([^\]]+)\]\s*/;
54866
56571
  function TaskRow({
54867
56572
  task,
54868
56573
  focused,
@@ -54871,8 +56576,13 @@ function TaskRow({
54871
56576
  const cursor = focused ? "\u25B8" : " ";
54872
56577
  const check2 = task.checked ? "\u2713" : "\u25CB";
54873
56578
  const idStr = task.id;
54874
- const available = colWidth - 4 - idStr.length - 1;
54875
- const titleStr = truncate(task.title, Math.max(4, available));
56579
+ const tagMatch = task.title.match(RE_BRACKET_TAG);
56580
+ const tag = tagMatch ? `[${tagMatch[1]}]` : "";
56581
+ const titleWithoutTag = tagMatch ? task.title.slice(tagMatch[0].length) : task.title;
56582
+ const fixedChars = 4 + idStr.length + 1;
56583
+ const tagChars = tag ? tag.length + 1 : 0;
56584
+ const available = colWidth - fixedChars - tagChars;
56585
+ const titleStr = truncate(titleWithoutTag, Math.max(4, available));
54876
56586
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Box_default, { children: [
54877
56587
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: focused ? "cyan" : void 0, bold: focused, children: [
54878
56588
  cursor,
@@ -54883,6 +56593,10 @@ function TaskRow({
54883
56593
  " "
54884
56594
  ] }),
54885
56595
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Text, { color: focused ? "cyan" : "yellow", bold: focused, children: idStr }),
56596
+ tag && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: focused ? "white" : "magenta", bold: true, children: [
56597
+ " ",
56598
+ tag
56599
+ ] }),
54886
56600
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(Text, { color: focused ? "white" : "gray", children: [
54887
56601
  " ",
54888
56602
  titleStr
@@ -55010,6 +56724,29 @@ function Board({ kandownDir }) {
55010
56724
  setBoard(loaded);
55011
56725
  setInstalledAgents(detectInstalledAgents());
55012
56726
  }, [kandownDir]);
56727
+ (0, import_react36.useEffect)(() => {
56728
+ const tasksDir = join6(kandownDir, "tasks");
56729
+ const configPath = join6(kandownDir, "kandown.json");
56730
+ let debounceTimer = null;
56731
+ const watcher = watch([join6(tasksDir, "*.md"), configPath], {
56732
+ persistent: true,
56733
+ ignoreInitial: true,
56734
+ awaitWriteFinish: { stabilityThreshold: 200, pollInterval: 50 }
56735
+ });
56736
+ watcher.on("all", (event) => {
56737
+ if (debounceTimer) clearTimeout(debounceTimer);
56738
+ debounceTimer = setTimeout(() => {
56739
+ const loaded = readBoard(kandownDir);
56740
+ setBoard(loaded);
56741
+ setStatusMsg(`Reloaded (${event})`);
56742
+ setTimeout(() => setStatusMsg(""), 1500);
56743
+ }, 100);
56744
+ });
56745
+ return () => {
56746
+ watcher.close();
56747
+ if (debounceTimer) clearTimeout(debounceTimer);
56748
+ };
56749
+ }, [kandownDir]);
55013
56750
  const reloadBoard = (0, import_react36.useCallback)(() => {
55014
56751
  const loaded = readBoard(kandownDir);
55015
56752
  setBoard(loaded);
@@ -55189,10 +56926,10 @@ function Board({ kandownDir }) {
55189
56926
 
55190
56927
  // src/cli/app.tsx
55191
56928
  var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
55192
- function App2({ screen, kandownDir }) {
56929
+ function App2({ screen, kandownDir, version }) {
55193
56930
  switch (screen) {
55194
56931
  case "settings":
55195
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Settings, { kandownDir });
56932
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Settings, { kandownDir, version });
55196
56933
  case "board":
55197
56934
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Board, { kandownDir });
55198
56935
  default:
@@ -55205,14 +56942,14 @@ function App2({ screen, kandownDir }) {
55205
56942
 
55206
56943
  // src/cli/tui.tsx
55207
56944
  var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
55208
- async function run(screen, kandownDir) {
56945
+ async function run(screen, kandownDir, version) {
55209
56946
  if (!process.stdin.isTTY) {
55210
56947
  throw new Error(
55211
56948
  "kandown TUI requires an interactive terminal. Run this command directly in your terminal."
55212
56949
  );
55213
56950
  }
55214
56951
  process.stdout.write("\x1B[?1049h\x1B[H");
55215
- const instance = render_default(/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(App2, { screen, kandownDir }), {
56952
+ const instance = render_default(/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(App2, { screen, kandownDir, version }), {
55216
56953
  exitOnCtrlC: true
55217
56954
  });
55218
56955
  try {
@@ -55338,4 +57075,7 @@ react/cjs/react-jsx-runtime.development.js:
55338
57075
  * This source code is licensed under the MIT license found in the
55339
57076
  * LICENSE file in the root directory of this source tree.
55340
57077
  *)
57078
+
57079
+ chokidar/esm/index.js:
57080
+ (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
55341
57081
  */