@jixo/cli 0.23.3 → 0.23.5

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/bundle/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createRequire } from "node:module";
3
3
  import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
4
4
  import path, { dirname, join } from "node:path";
5
- import fs, { existsSync, mkdirSync, promises, readFileSync, readdirSync, realpathSync, statSync, watch, writeFileSync } from "node:fs";
5
+ import fs, { existsSync, mkdirSync, promises, readFileSync, readdirSync, realpathSync, statSync, watchFile, writeFileSync } from "node:fs";
6
6
  import assert3, { notStrictEqual, strictEqual } from "assert";
7
7
  import * as path$1 from "path";
8
8
  import path10, { basename, dirname as dirname$1, extname, join as join$1, normalize, relative, resolve } from "path";
@@ -32,7 +32,7 @@ import { createHash } from "node:crypto";
32
32
 
33
33
  //#region rolldown:runtime
34
34
  var __create$1 = Object.create;
35
- var __defProp$4 = Object.defineProperty;
35
+ var __defProp$3 = Object.defineProperty;
36
36
  var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
37
37
  var __getOwnPropNames$2 = Object.getOwnPropertyNames;
38
38
  var __getProtoOf$1 = Object.getPrototypeOf;
@@ -41,7 +41,7 @@ var __commonJS$2 = (cb, mod) => function() {
41
41
  return mod || (0, cb[__getOwnPropNames$2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
42
42
  };
43
43
  var __export$4 = (target, all$1) => {
44
- for (var name$1 in all$1) __defProp$4(target, name$1, {
44
+ for (var name$1 in all$1) __defProp$3(target, name$1, {
45
45
  get: all$1[name$1],
46
46
  enumerable: true
47
47
  });
@@ -49,14 +49,14 @@ var __export$4 = (target, all$1) => {
49
49
  var __copyProps$2 = (to, from, except, desc) => {
50
50
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames$2(from), i$2 = 0, n$1 = keys.length, key$1; i$2 < n$1; i$2++) {
51
51
  key$1 = keys[i$2];
52
- if (!__hasOwnProp$2.call(to, key$1) && key$1 !== except) __defProp$4(to, key$1, {
52
+ if (!__hasOwnProp$2.call(to, key$1) && key$1 !== except) __defProp$3(to, key$1, {
53
53
  get: ((k$1) => from[k$1]).bind(null, key$1),
54
54
  enumerable: !(desc = __getOwnPropDesc$2(from, key$1)) || desc.enumerable
55
55
  });
56
56
  }
57
57
  return to;
58
58
  };
59
- var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(__getProtoOf$1(mod)) : {}, __copyProps$2(isNodeMode || !mod || !mod.__esModule ? __defProp$4(target, "default", {
59
+ var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(__getProtoOf$1(mod)) : {}, __copyProps$2(isNodeMode || !mod || !mod.__esModule ? __defProp$3(target, "default", {
60
60
  value: mod,
61
61
  enumerable: true
62
62
  }) : target, mod));
@@ -4688,7 +4688,7 @@ var yargs_default = Yargs;
4688
4688
  //#endregion
4689
4689
  //#region package.json
4690
4690
  var name = "@jixo/cli";
4691
- var version$1 = "0.23.3";
4691
+ var version$1 = "0.23.5";
4692
4692
  var type = "module";
4693
4693
  var bin = { "jixo": "./bundle/index.js" };
4694
4694
  var files = [
@@ -5084,10 +5084,33 @@ const createAcontext = (name$1, default_fn) => {
5084
5084
  };
5085
5085
  return handle;
5086
5086
  };
5087
+ const useAcontexts = (ctxs) => {
5088
+ return (values, run$1) => {
5089
+ const runner = async (index$1) => {
5090
+ if (index$1 >= ctxs.length) return run$1();
5091
+ const context = ctxs[index$1];
5092
+ const value = values[index$1];
5093
+ return context.run(value, () => runner(index$1 + 1));
5094
+ };
5095
+ return runner(0);
5096
+ };
5097
+ };
5087
5098
 
5088
5099
  //#endregion
5089
5100
  //#region ../../node_modules/.pnpm/@gaubee+util@0.34.2/node_modules/@gaubee/util/esm/map.js
5090
5101
  /**
5102
+ * 读取一个map中的值,如果没有,就创建它
5103
+ */
5104
+ const map_get_or_put = (map$1, key$1, put) => {
5105
+ let value;
5106
+ if (map$1.has(key$1)) value = map$1.get(key$1);
5107
+ else {
5108
+ value = put(key$1, map$1);
5109
+ map$1.set(key$1, value);
5110
+ }
5111
+ return value;
5112
+ };
5113
+ /**
5091
5114
  * 读取一个map中的值,如果没有,就异步地创建它
5092
5115
  * 使用该函数进行异步创建是会互斥上锁的(如果外部修改了map,写入了值,那么最终会以外部修改为准)
5093
5116
  */
@@ -5113,6 +5136,22 @@ const map_get_or_put_async = async (map$1, key$1, put) => {
5113
5136
  };
5114
5137
  const locks_keys = /* @__PURE__ */ Symbol.for("map_get_or_put_async-locks");
5115
5138
 
5139
+ //#endregion
5140
+ //#region ../../node_modules/.pnpm/@gaubee+util@0.34.2/node_modules/@gaubee/util/esm/event_target.js
5141
+ /**
5142
+ * 一个更加易用的 eventTarget.addEventListener 附加监听函数,返回一个 off 函数,用于 removeEventListener 移除监听
5143
+ * @example
5144
+ * ```ts
5145
+ * event_target_on(abort_signal, 'abort', ()=>{})
5146
+ * ```
5147
+ */
5148
+ const event_target_on = (target, type$1, handler, options$1) => {
5149
+ target.addEventListener(type$1, handler, options$1);
5150
+ return () => {
5151
+ target.removeEventListener(type$1, handler);
5152
+ };
5153
+ };
5154
+
5116
5155
  //#endregion
5117
5156
  //#region ../../node_modules/.pnpm/@gaubee+util@0.34.2/node_modules/@gaubee/util/esm/object.js
5118
5157
  /**
@@ -5460,9 +5499,9 @@ var PureEvent = class {
5460
5499
  };
5461
5500
  const pureEvent = () => {
5462
5501
  const pe = new PureEvent();
5463
- const watch$1 = pe.watch;
5464
- Object.setPrototypeOf(watch$1, pe);
5465
- return watch$1;
5502
+ const watch = pe.watch;
5503
+ Object.setPrototypeOf(watch, pe);
5504
+ return watch;
5466
5505
  };
5467
5506
  /**
5468
5507
  * PureEvent 的委托类,基于委托,可以实现更新委托内核
@@ -5552,6 +5591,22 @@ const func_remember = /* @__NO_SIDE_EFFECTS__ */ (func, key$1) => {
5552
5591
  });
5553
5592
  return once_fn_mix;
5554
5593
  };
5594
+ /**
5595
+ * 包裹一个“目标函数”,将它的执行权交给“包裹函数”。
5596
+ * 包裹函数可以在目标函数执行之前或者执行之后做一些工作,比如参数检查,比如返回值修改
5597
+ * @param func 目标函数
5598
+ * @param wrapper 包裹函数,第一个参数是 context,可以获得详细的上下文;第二个参数是 next,可以用于快速执行“目标函数”
5599
+ */
5600
+ const func_wrap = /* @__NO_SIDE_EFFECTS__ */ (func, wrapper) => {
5601
+ return function(...args) {
5602
+ const context = {
5603
+ target: func,
5604
+ this: this,
5605
+ arguments: args
5606
+ };
5607
+ return wrapper(context, () => Reflect.apply(func, context.this, context.arguments));
5608
+ };
5609
+ };
5555
5610
  const wrapSuccess = (result) => {
5556
5611
  return Object.defineProperties([void 0, result], {
5557
5612
  success: {
@@ -5696,6 +5751,54 @@ const timmers = {
5696
5751
  return typeof ms === "number" ? ms <= 0 ? timmers.microtask : timmers.timeout(ms) : ms;
5697
5752
  }
5698
5753
  };
5754
+ /**
5755
+ * setTimeout/clearTimeout 的 promise 版本
5756
+ * @example
5757
+ * ```ts
5758
+ * const d = delay(1000)
5759
+ *
5760
+ * await d; // is promise
5761
+ *
5762
+ * d.cancel(); // clearTimeout
5763
+ *
5764
+ * d.cancel('some reason'); // clearTimeout and reject promise
5765
+ *
5766
+ * const ac = new AbortController()
5767
+ * const d = delay(1000, { signal: ac.signal }) // with AbortSignal
5768
+ * ac.abort('some reason'); // clearTimeout and reject promise
5769
+ * ```
5770
+ *
5771
+ * 如果 ms = 0,那么会使用 queueMicrotask 而不是setTimeot,当然cancel仍然是可以工作的
5772
+ */
5773
+ const delay = (ms, options$1) => {
5774
+ const signal = options$1?.signal;
5775
+ signal?.throwIfAborted();
5776
+ const job = Promise.withResolvers();
5777
+ let resolve$1 = job.resolve;
5778
+ let reject = job.reject;
5779
+ const timmer = timmers.from(ms);
5780
+ const clear = timmer(resolve$1, reject);
5781
+ const result = Object.assign(job.promise, { cancel(cause) {
5782
+ clear();
5783
+ reject(cause);
5784
+ } });
5785
+ if (signal != null) {
5786
+ const off = event_target_on(signal, "abort", () => {
5787
+ result.cancel(signal.reason);
5788
+ }, { once: true });
5789
+ resolve$1 = func_wrap(resolve$1, (_$1, next) => {
5790
+ off();
5791
+ next();
5792
+ });
5793
+ reject = func_wrap(reject, (_$1, next) => {
5794
+ off();
5795
+ next();
5796
+ });
5797
+ }
5798
+ const disposer = options$1?.disposer;
5799
+ if (disposer != null) disposer.watch(result.cancel);
5800
+ return result;
5801
+ };
5699
5802
  const promise_try = async (fn) => {
5700
5803
  try {
5701
5804
  const value = await fn();
@@ -5710,6 +5813,120 @@ const promise_try = async (fn) => {
5710
5813
  };
5711
5814
  }
5712
5815
  };
5816
+ const _pot = /* @__PURE__ */ new WeakMap();
5817
+ /**
5818
+ * 一个内存安全的、只专注于执行回调 promise then 方法。
5819
+ * 因为 promise.then 是会创建一个新的 promise 的,在某些场景下,这会带来严重的内存问题,比如说,如果你将一个 promise 作为一个锁
5820
+ * 而如果你只是想进行回调注册,使用这个方法。
5821
+ *
5822
+ * @param promise
5823
+ * @param onfulfilled
5824
+ * @param onrejected
5825
+ * @returns
5826
+ */
5827
+ const promise_once_then = (promise$2, task) => {
5828
+ const state = map_get_or_put(_pot, promise$2, () => {
5829
+ const pending_state = {
5830
+ state: "pending",
5831
+ tasks: /* @__PURE__ */ new Map()
5832
+ };
5833
+ promise$2.then((value) => {
5834
+ _pot.set(promise$2, {
5835
+ state: "resolved",
5836
+ value
5837
+ });
5838
+ _promise_once_then_onfulfilled(value, pending_state.tasks.values());
5839
+ }, (err) => {
5840
+ _pot.set(promise$2, {
5841
+ state: "rejected",
5842
+ err
5843
+ });
5844
+ _promise_once_then_onrejected(err, pending_state.tasks.values());
5845
+ });
5846
+ return pending_state;
5847
+ });
5848
+ if (state.state === "pending") {
5849
+ state.tasks.set(task.key ?? task.resolve ?? task.reject, task);
5850
+ return () => promise_once_then_cancel(promise$2, task);
5851
+ } else if (state.state === "resolved") _promise_once_then_onfulfilled(state.value, [task]);
5852
+ else if (state.state === "rejected") _promise_once_then_onrejected(state.err, [task]);
5853
+ return () => {};
5854
+ };
5855
+ const promise_once_then_cancel = (promise$2, task) => {
5856
+ const state = _pot.get(promise$2);
5857
+ if (state?.state === "pending") state.tasks.delete(task.key ?? task.resolve ?? task.reject);
5858
+ };
5859
+ const _promise_once_then_onfulfilled = (value, tasks) => {
5860
+ for (const task of tasks) {
5861
+ if (task.resolve == null) continue;
5862
+ try {
5863
+ const res = task.resolve(value);
5864
+ if (isPromiseLike(res) && task.reject) res.then(null, task.reject);
5865
+ } catch (err) {
5866
+ task.reject?.(err, value);
5867
+ }
5868
+ }
5869
+ };
5870
+ const _promise_once_then_onrejected = (err, tasks) => {
5871
+ for (const task of tasks) {
5872
+ if (task.reject == null) continue;
5873
+ task.reject(err);
5874
+ }
5875
+ };
5876
+ const promise_safe_race = (values, options$1 = {}) => {
5877
+ const promises$1 = Array.isArray(values) ? values : [];
5878
+ for (const item of values) {
5879
+ if (!isPromiseLike(item)) return item;
5880
+ if (promises$1 !== values) promises$1.push(item);
5881
+ }
5882
+ const { promise: promise$2, resolve: resolve$1, reject } = Promise.withResolvers();
5883
+ const registeredTasks = /* @__PURE__ */ new Map();
5884
+ let settled = false;
5885
+ const cleanup = () => {
5886
+ settled = true;
5887
+ for (const cancel of registeredTasks.values()) cancel();
5888
+ registeredTasks.clear();
5889
+ };
5890
+ const settle = (result, isError$1) => {
5891
+ if (settled) return;
5892
+ cleanup();
5893
+ isError$1 ? reject(result) : resolve$1(result);
5894
+ };
5895
+ for (const value of promises$1) {
5896
+ if (settled) break;
5897
+ registeredTasks.set(value, promise_once_then(value, {
5898
+ resolve: (val) => settle(val, false),
5899
+ reject: (err) => settle(err, true)
5900
+ }));
5901
+ }
5902
+ if (!settled && registeredTasks.size === 0) {
5903
+ const { ifEmpty = () => {
5904
+ reject(/* @__PURE__ */ new TypeError("Argument is empty iterable"));
5905
+ return promise$2;
5906
+ } } = options$1;
5907
+ return ifEmpty();
5908
+ }
5909
+ return promise$2;
5910
+ };
5911
+
5912
+ //#endregion
5913
+ //#region ../../node_modules/.pnpm/@gaubee+util@0.34.2/node_modules/@gaubee/util/esm/abort.js
5914
+ const signal_promise_cache = /* @__PURE__ */ new Map();
5915
+ const abort_signal_promisify = (input) => {
5916
+ const signal = input instanceof AbortSignal ? input : input.signal;
5917
+ return map_get_or_put(signal_promise_cache, signal, () => {
5918
+ const job = Promise.withResolvers();
5919
+ signal.addEventListener("abort", (reason) => {
5920
+ job.reject(reason);
5921
+ }, { once: true });
5922
+ return job.promise;
5923
+ });
5924
+ };
5925
+ const abort_signal_race = (signal, fn_or_promise) => {
5926
+ signal.throwIfAborted();
5927
+ fn_or_promise = typeof fn_or_promise === "function" ? fn_or_promise() : fn_or_promise;
5928
+ return promise_safe_race([abort_signal_promisify(signal), fn_or_promise]);
5929
+ };
5713
5930
 
5714
5931
  //#endregion
5715
5932
  //#region ../../node_modules/.pnpm/@gaubee+util@0.34.2/node_modules/@gaubee/util/esm/debounce.js
@@ -9288,8 +9505,8 @@ const effectScheduler = {
9288
9505
  run() {
9289
9506
  const store = getStore();
9290
9507
  withUpdates(() => {
9291
- store.hooksEffect.forEach((effect$1) => {
9292
- effect$1();
9508
+ store.hooksEffect.forEach((effect) => {
9509
+ effect();
9293
9510
  });
9294
9511
  store.hooksEffect.length = 0;
9295
9512
  })();
@@ -16868,15 +17085,15 @@ var require_run_parallel$1 = __commonJS$2({ "../../node_modules/.pnpm/run-parall
16868
17085
  module.exports = runParallel;
16869
17086
  const queueMicrotask$1 = require_queue_microtask$1();
16870
17087
  function runParallel(tasks, cb) {
16871
- let results, pending$1, keys;
17088
+ let results, pending, keys;
16872
17089
  let isSync = true;
16873
17090
  if (Array.isArray(tasks)) {
16874
17091
  results = [];
16875
- pending$1 = tasks.length;
17092
+ pending = tasks.length;
16876
17093
  } else {
16877
17094
  keys = Object.keys(tasks);
16878
17095
  results = {};
16879
- pending$1 = keys.length;
17096
+ pending = keys.length;
16880
17097
  }
16881
17098
  function done(err) {
16882
17099
  function end() {
@@ -16888,9 +17105,9 @@ var require_run_parallel$1 = __commonJS$2({ "../../node_modules/.pnpm/run-parall
16888
17105
  }
16889
17106
  function each(i$2, err, result) {
16890
17107
  results[i$2] = result;
16891
- if (--pending$1 === 0 || err) done(err);
17108
+ if (--pending === 0 || err) done(err);
16892
17109
  }
16893
- if (!pending$1) done(null);
17110
+ if (!pending) done(null);
16894
17111
  else if (keys) keys.forEach(function(key$1) {
16895
17112
  tasks[key$1](function(err, result) {
16896
17113
  each(key$1, err, result);
@@ -18963,9 +19180,9 @@ var require_common$1 = __commonJS$2({ "../../node_modules/.pnpm/debug@4.4.1/node
18963
19180
  let enableOverride = null;
18964
19181
  let namespacesCache;
18965
19182
  let enabledCache;
18966
- function debug$2(...args) {
18967
- if (!debug$2.enabled) return;
18968
- const self = debug$2;
19183
+ function debug$5(...args) {
19184
+ if (!debug$5.enabled) return;
19185
+ const self = debug$5;
18969
19186
  const curr = Number(/* @__PURE__ */ new Date());
18970
19187
  const ms = curr - (prevTime || curr);
18971
19188
  self.diff = ms;
@@ -18991,12 +19208,12 @@ var require_common$1 = __commonJS$2({ "../../node_modules/.pnpm/debug@4.4.1/node
18991
19208
  const logFn = self.log || createDebug.log;
18992
19209
  logFn.apply(self, args);
18993
19210
  }
18994
- debug$2.namespace = namespace;
18995
- debug$2.useColors = createDebug.useColors();
18996
- debug$2.color = createDebug.selectColor(namespace);
18997
- debug$2.extend = extend$3;
18998
- debug$2.destroy = createDebug.destroy;
18999
- Object.defineProperty(debug$2, "enabled", {
19211
+ debug$5.namespace = namespace;
19212
+ debug$5.useColors = createDebug.useColors();
19213
+ debug$5.color = createDebug.selectColor(namespace);
19214
+ debug$5.extend = extend$3;
19215
+ debug$5.destroy = createDebug.destroy;
19216
+ Object.defineProperty(debug$5, "enabled", {
19000
19217
  enumerable: true,
19001
19218
  configurable: false,
19002
19219
  get: () => {
@@ -19011,8 +19228,8 @@ var require_common$1 = __commonJS$2({ "../../node_modules/.pnpm/debug@4.4.1/node
19011
19228
  enableOverride = v$1;
19012
19229
  }
19013
19230
  });
19014
- if (typeof createDebug.init === "function") createDebug.init(debug$2);
19015
- return debug$2;
19231
+ if (typeof createDebug.init === "function") createDebug.init(debug$5);
19232
+ return debug$5;
19016
19233
  }
19017
19234
  function extend$3(namespace, delimiter) {
19018
19235
  const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
@@ -19574,10 +19791,10 @@ var require_node = __commonJS$2({ "../../node_modules/.pnpm/debug@4.4.1/node_mod
19574
19791
  * Create a new `inspectOpts` object in case `useColors` is set
19575
19792
  * differently for a particular `debug` instance.
19576
19793
  */
19577
- function init(debug$2) {
19578
- debug$2.inspectOpts = {};
19794
+ function init(debug$5) {
19795
+ debug$5.inspectOpts = {};
19579
19796
  const keys = Object.keys(exports.inspectOpts);
19580
- for (let i$2 = 0; i$2 < keys.length; i$2++) debug$2.inspectOpts[keys[i$2]] = exports.inspectOpts[keys[i$2]];
19797
+ for (let i$2 = 0; i$2 < keys.length; i$2++) debug$5.inspectOpts[keys[i$2]] = exports.inspectOpts[keys[i$2]];
19581
19798
  }
19582
19799
  module.exports = require_common$1()(exports);
19583
19800
  const { formatters } = module.exports;
@@ -19740,10 +19957,10 @@ var require_dist = __commonJS$2({ "../../node_modules/.pnpm/@kwsites+promise-def
19740
19957
  //#endregion
19741
19958
  //#region ../../node_modules/.pnpm/simple-git@3.28.0/node_modules/simple-git/dist/esm/index.js
19742
19959
  var import_dist = __toESM$1(require_dist$1(), 1);
19743
- var import_src$1 = __toESM$1(require_src$2(), 1);
19960
+ var import_src$4 = __toESM$1(require_src$2(), 1);
19744
19961
  var import_dist$1 = __toESM$1(require_dist(), 1);
19745
19962
  var import_dist$2 = __toESM$1(require_dist(), 1);
19746
- var __defProp$3 = Object.defineProperty;
19963
+ var __defProp$2 = Object.defineProperty;
19747
19964
  var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
19748
19965
  var __getOwnPropNames$1 = Object.getOwnPropertyNames;
19749
19966
  var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
@@ -19754,21 +19971,21 @@ var __commonJS$1 = (cb, mod) => function __require$2() {
19754
19971
  return mod || (0, cb[__getOwnPropNames$1(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19755
19972
  };
19756
19973
  var __export$2 = (target, all$1) => {
19757
- for (var name$1 in all$1) __defProp$3(target, name$1, {
19974
+ for (var name$1 in all$1) __defProp$2(target, name$1, {
19758
19975
  get: all$1[name$1],
19759
19976
  enumerable: true
19760
19977
  });
19761
19978
  };
19762
19979
  var __copyProps$1 = (to, from, except, desc) => {
19763
19980
  if (from && typeof from === "object" || typeof from === "function") {
19764
- for (let key$1 of __getOwnPropNames$1(from)) if (!__hasOwnProp$1.call(to, key$1) && key$1 !== except) __defProp$3(to, key$1, {
19981
+ for (let key$1 of __getOwnPropNames$1(from)) if (!__hasOwnProp$1.call(to, key$1) && key$1 !== except) __defProp$2(to, key$1, {
19765
19982
  get: () => from[key$1],
19766
19983
  enumerable: !(desc = __getOwnPropDesc$1(from, key$1)) || desc.enumerable
19767
19984
  });
19768
19985
  }
19769
19986
  return to;
19770
19987
  };
19771
- var __toCommonJS = (mod) => __copyProps$1(__defProp$3({}, "__esModule", { value: true }), mod);
19988
+ var __toCommonJS = (mod) => __copyProps$1(__defProp$2({}, "__esModule", { value: true }), mod);
19772
19989
  function pathspec(...paths) {
19773
19990
  const key$1 = new String(paths);
19774
19991
  cache$1.set(key$1, paths);
@@ -19895,7 +20112,7 @@ function bufferToString(input) {
19895
20112
  function pick$1(source$1, properties) {
19896
20113
  return Object.assign({}, ...properties.map((property) => property in source$1 ? { [property]: source$1[property] } : {}));
19897
20114
  }
19898
- function delay(duration$2 = 0) {
20115
+ function delay$1(duration$2 = 0) {
19899
20116
  return new Promise((done) => setTimeout(done, duration$2));
19900
20117
  }
19901
20118
  function orVoid(input) {
@@ -20104,7 +20321,7 @@ __export$2(utils_exports, {
20104
20321
  bufferToString: () => bufferToString,
20105
20322
  callTaskParser: () => callTaskParser,
20106
20323
  createInstanceConfig: () => createInstanceConfig,
20107
- delay: () => delay,
20324
+ delay: () => delay$1,
20108
20325
  filterArray: () => filterArray,
20109
20326
  filterFunction: () => filterFunction,
20110
20327
  filterHasLength: () => filterHasLength,
@@ -20647,7 +20864,7 @@ var init_reset = __esm({ "src/lib/tasks/reset.ts"() {
20647
20864
  ResetModes = Array.from(Object.values(ResetMode));
20648
20865
  } });
20649
20866
  function createLog() {
20650
- return (0, import_src$1.default)("simple-git");
20867
+ return (0, import_src$4.default)("simple-git");
20651
20868
  }
20652
20869
  function prefixedLogger(to, prefix, forward) {
20653
20870
  if (!prefix || !String(prefix).replace(/\s*/, "")) return !forward ? to : (message, ...args) => {
@@ -20689,8 +20906,8 @@ function createLogger(label$1, verbose, initialStep, infoDebugger = createLog())
20689
20906
  var init_git_logger = __esm({ "src/lib/git-logger.ts"() {
20690
20907
  "use strict";
20691
20908
  init_utils();
20692
- import_src$1.default.formatters.L = (value) => String(filterHasLength(value) ? value.length : "-");
20693
- import_src$1.default.formatters.B = (value) => {
20909
+ import_src$4.default.formatters.L = (value) => String(filterHasLength(value) ? value.length : "-");
20910
+ import_src$4.default.formatters.B = (value) => {
20694
20911
  if (Buffer.isBuffer(value)) return value.toString("utf8");
20695
20912
  return objectToString(value);
20696
20913
  };
@@ -23082,7 +23299,7 @@ function completionDetectionPlugin({ onClose = true, onExit: onExit$1 = 50 } = {
23082
23299
  }
23083
23300
  function configureTimeout(flag, event, timeout) {
23084
23301
  if (flag === false) return;
23085
- (flag === true ? event.promise : event.promise.then(() => delay(flag))).then(timeout.done);
23302
+ (flag === true ? event.promise : event.promise.then(() => delay$1(flag))).then(timeout.done);
23086
23303
  }
23087
23304
  return {
23088
23305
  type: "spawn.after",
@@ -23097,7 +23314,7 @@ function completionDetectionPlugin({ onClose = true, onExit: onExit$1 = 50 } = {
23097
23314
  spawned.on("exit", (code$1) => events.exit(code$1));
23098
23315
  try {
23099
23316
  await events.result;
23100
- if (deferClose) await delay(50);
23317
+ if (deferClose) await delay$1(50);
23101
23318
  close(events.exitCode);
23102
23319
  } catch (err) {
23103
23320
  close(events.exitCode, err);
@@ -23335,9 +23552,9 @@ __export$4(doc_exports, {
23335
23552
  printer: () => printer,
23336
23553
  utils: () => utils
23337
23554
  });
23338
- var __defProp$2 = Object.defineProperty;
23555
+ var __defProp$1 = Object.defineProperty;
23339
23556
  var __export$1 = (target, all$1) => {
23340
- for (var name$1 in all$1) __defProp$2(target, name$1, {
23557
+ for (var name$1 in all$1) __defProp$1(target, name$1, {
23341
23558
  get: all$1[name$1],
23342
23559
  enumerable: true
23343
23560
  });
@@ -24338,7 +24555,7 @@ const require$1 = createRequire$1(import.meta.url);
24338
24555
  const __filename = fileURLToPath$1(import.meta.url);
24339
24556
  const __dirname = dirname$1(__filename);
24340
24557
  var __create = Object.create;
24341
- var __defProp$1 = Object.defineProperty;
24558
+ var __defProp = Object.defineProperty;
24342
24559
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
24343
24560
  var __getOwnPropNames = Object.getOwnPropertyNames;
24344
24561
  var __getProtoOf = Object.getPrototypeOf;
@@ -24346,7 +24563,7 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
24346
24563
  var __typeError = (msg) => {
24347
24564
  throw TypeError(msg);
24348
24565
  };
24349
- var __defNormalProp$1 = (obj, key2, value) => key2 in obj ? __defProp$1(obj, key2, {
24566
+ var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, {
24350
24567
  enumerable: true,
24351
24568
  configurable: true,
24352
24569
  writable: true,
@@ -24360,30 +24577,30 @@ var __commonJS = (cb, mod) => function __require2() {
24360
24577
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
24361
24578
  };
24362
24579
  var __export = (target, all$1) => {
24363
- for (var name$1 in all$1) __defProp$1(target, name$1, {
24580
+ for (var name$1 in all$1) __defProp(target, name$1, {
24364
24581
  get: all$1[name$1],
24365
24582
  enumerable: true
24366
24583
  });
24367
24584
  };
24368
24585
  var __copyProps = (to, from, except, desc) => {
24369
24586
  if (from && typeof from === "object" || typeof from === "function") {
24370
- for (let key2 of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key2) && key2 !== except) __defProp$1(to, key2, {
24587
+ for (let key2 of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key2) && key2 !== except) __defProp(to, key2, {
24371
24588
  get: () => from[key2],
24372
24589
  enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable
24373
24590
  });
24374
24591
  }
24375
24592
  return to;
24376
24593
  };
24377
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target, "default", {
24594
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24378
24595
  value: mod,
24379
24596
  enumerable: true
24380
24597
  }) : target, mod));
24381
- var __publicField$1 = (obj, key2, value) => __defNormalProp$1(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
24382
- var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
24383
- var __privateGet = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
24384
- var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
24385
- var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
24386
- var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
24598
+ var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
24599
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
24600
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
24601
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
24602
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
24603
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
24387
24604
  var require_array = __commonJS({ "node_modules/fast-glob/out/utils/array.js"(exports$2) {
24388
24605
  "use strict";
24389
24606
  Object.defineProperty(exports$2, "__esModule", { value: true });
@@ -27488,15 +27705,15 @@ var require_run_parallel = __commonJS({ "node_modules/run-parallel/index.js"(exp
27488
27705
  module$1.exports = runParallel$1;
27489
27706
  var queueMicrotask2 = require_queue_microtask();
27490
27707
  function runParallel$1(tasks, cb) {
27491
- let results, pending$1, keys;
27708
+ let results, pending, keys;
27492
27709
  let isSync = true;
27493
27710
  if (Array.isArray(tasks)) {
27494
27711
  results = [];
27495
- pending$1 = tasks.length;
27712
+ pending = tasks.length;
27496
27713
  } else {
27497
27714
  keys = Object.keys(tasks);
27498
27715
  results = {};
27499
- pending$1 = keys.length;
27716
+ pending = keys.length;
27500
27717
  }
27501
27718
  function done(err) {
27502
27719
  function end() {
@@ -27508,9 +27725,9 @@ var require_run_parallel = __commonJS({ "node_modules/run-parallel/index.js"(exp
27508
27725
  }
27509
27726
  function each(i$2, err, result) {
27510
27727
  results[i$2] = result;
27511
- if (--pending$1 === 0 || err) done(err);
27728
+ if (--pending === 0 || err) done(err);
27512
27729
  }
27513
- if (!pending$1) done(null);
27730
+ if (!pending) done(null);
27514
27731
  else if (keys) keys.forEach(function(key2) {
27515
27732
  tasks[key2](function(err, result) {
27516
27733
  each(key2, err, result);
@@ -29095,8 +29312,8 @@ var require_picocolors = __commonJS({ "node_modules/picocolors/picocolors.js"(ex
29095
29312
  } });
29096
29313
  var require_debug = __commonJS({ "node_modules/semver/internal/debug.js"(exports$2, module$1) {
29097
29314
  "use strict";
29098
- var debug$2 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
29099
- module$1.exports = debug$2;
29315
+ var debug$5 = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
29316
+ module$1.exports = debug$5;
29100
29317
  } });
29101
29318
  var require_constants4 = __commonJS({ "node_modules/semver/internal/constants.js"(exports$2, module$1) {
29102
29319
  "use strict";
@@ -29128,7 +29345,7 @@ var require_constants4 = __commonJS({ "node_modules/semver/internal/constants.js
29128
29345
  var require_re = __commonJS({ "node_modules/semver/internal/re.js"(exports$2, module$1) {
29129
29346
  "use strict";
29130
29347
  var { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH: MAX_LENGTH$2 } = require_constants4();
29131
- var debug$2 = require_debug();
29348
+ var debug$5 = require_debug();
29132
29349
  exports$2 = module$1.exports = {};
29133
29350
  var re = exports$2.re = [];
29134
29351
  var safeRe = exports$2.safeRe = [];
@@ -29149,7 +29366,7 @@ var require_re = __commonJS({ "node_modules/semver/internal/re.js"(exports$2, mo
29149
29366
  var createToken = (name$1, value, isGlobal) => {
29150
29367
  const safe = makeSafeRegex(value);
29151
29368
  const index$1 = R++;
29152
- debug$2(name$1, index$1, value);
29369
+ debug$5(name$1, index$1, value);
29153
29370
  t$1[name$1] = index$1;
29154
29371
  src[index$1] = value;
29155
29372
  safeSrc[index$1] = safe;
@@ -29234,7 +29451,7 @@ var require_identifiers = __commonJS({ "node_modules/semver/internal/identifiers
29234
29451
  } });
29235
29452
  var require_semver = __commonJS({ "node_modules/semver/classes/semver.js"(exports$2, module$1) {
29236
29453
  "use strict";
29237
- var debug$2 = require_debug();
29454
+ var debug$5 = require_debug();
29238
29455
  var { MAX_LENGTH: MAX_LENGTH$2, MAX_SAFE_INTEGER } = require_constants4();
29239
29456
  var { safeRe: re, t: t$1 } = require_re();
29240
29457
  var parseOptions = require_parse_options();
@@ -29246,7 +29463,7 @@ var require_semver = __commonJS({ "node_modules/semver/classes/semver.js"(export
29246
29463
  else version$2 = version$2.version;
29247
29464
  else if (typeof version$2 !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version$2}".`);
29248
29465
  if (version$2.length > MAX_LENGTH$2) throw new TypeError(`version is longer than ${MAX_LENGTH$2} characters`);
29249
- debug$2("SemVer", version$2, options8);
29466
+ debug$5("SemVer", version$2, options8);
29250
29467
  this.options = options8;
29251
29468
  this.loose = !!options8.loose;
29252
29469
  this.includePrerelease = !!options8.includePrerelease;
@@ -29279,7 +29496,7 @@ var require_semver = __commonJS({ "node_modules/semver/classes/semver.js"(export
29279
29496
  return this.version;
29280
29497
  }
29281
29498
  compare(other) {
29282
- debug$2("SemVer.compare", this.version, this.options, other);
29499
+ debug$5("SemVer.compare", this.version, this.options, other);
29283
29500
  if (!(other instanceof _SemVer)) {
29284
29501
  if (typeof other === "string" && other === this.version) return 0;
29285
29502
  other = new _SemVer(other, this.options);
@@ -29300,7 +29517,7 @@ var require_semver = __commonJS({ "node_modules/semver/classes/semver.js"(export
29300
29517
  do {
29301
29518
  const a$1 = this.prerelease[i$2];
29302
29519
  const b$1 = other.prerelease[i$2];
29303
- debug$2("prerelease compare", i$2, a$1, b$1);
29520
+ debug$5("prerelease compare", i$2, a$1, b$1);
29304
29521
  if (a$1 === void 0 && b$1 === void 0) return 0;
29305
29522
  else if (b$1 === void 0) return 1;
29306
29523
  else if (a$1 === void 0) return -1;
@@ -29314,7 +29531,7 @@ var require_semver = __commonJS({ "node_modules/semver/classes/semver.js"(export
29314
29531
  do {
29315
29532
  const a$1 = this.build[i$2];
29316
29533
  const b$1 = other.build[i$2];
29317
- debug$2("build compare", i$2, a$1, b$1);
29534
+ debug$5("build compare", i$2, a$1, b$1);
29318
29535
  if (a$1 === void 0 && b$1 === void 0) return 0;
29319
29536
  else if (b$1 === void 0) return 1;
29320
29537
  else if (a$1 === void 0) return -1;
@@ -33783,16 +34000,16 @@ var Searcher = class {
33783
34000
  @param {SearcherOptions} [options]
33784
34001
  */
33785
34002
  constructor(nameOrNames, { allowSymlinks, filter: filter2, stopDirectory, cache: cache3 } = {}) {
33786
- __privateAdd$1(this, _Searcher_instances);
33787
- __privateAdd$1(this, _stopDirectory);
33788
- __privateAdd$1(this, _cache);
33789
- __privateAdd$1(this, _resultCache, /* @__PURE__ */ new Map());
33790
- __privateAdd$1(this, _searchWithoutCache);
34003
+ __privateAdd(this, _Searcher_instances);
34004
+ __privateAdd(this, _stopDirectory);
34005
+ __privateAdd(this, _cache);
34006
+ __privateAdd(this, _resultCache, /* @__PURE__ */ new Map());
34007
+ __privateAdd(this, _searchWithoutCache);
33791
34008
  /**
33792
34009
  @protected
33793
34010
  @type {typeof findFile | typeof findDirectory}
33794
34011
  */
33795
- __publicField$1(this, "findInDirectory");
34012
+ __publicField(this, "findInDirectory");
33796
34013
  __privateSet(this, _stopDirectory, stopDirectory);
33797
34014
  __privateSet(this, _cache, cache3 ?? true);
33798
34015
  __privateSet(this, _searchWithoutCache, (directory) => this.findInDirectory(nameOrNames, {
@@ -33810,7 +34027,7 @@ var Searcher = class {
33810
34027
  */
33811
34028
  async search(startDirectory, options8) {
33812
34029
  for (const directory of iterate_directory_up_default(startDirectory, __privateGet(this, _stopDirectory))) {
33813
- const result = await __privateMethod$1(this, _Searcher_instances, search_fn).call(this, directory, (options8 == null ? void 0 : options8.cache) ?? __privateGet(this, _cache));
34030
+ const result = await __privateMethod(this, _Searcher_instances, search_fn).call(this, directory, (options8 == null ? void 0 : options8.cache) ?? __privateGet(this, _cache));
33814
34031
  if (result) return result;
33815
34032
  }
33816
34033
  }
@@ -34694,14 +34911,14 @@ var _JSONError = class _JSONError$1 extends Error {
34694
34911
  constructor(messageOrOptions) {
34695
34912
  var __super = (...args) => {
34696
34913
  super(...args);
34697
- __privateAdd$1(this, _JSONError_instances);
34698
- __publicField$1(this, "name", "JSONError");
34699
- __publicField$1(this, "fileName");
34700
- __privateAdd$1(this, _input);
34701
- __privateAdd$1(this, _jsonParseError);
34702
- __privateAdd$1(this, _message);
34703
- __privateAdd$1(this, _codeFrame);
34704
- __privateAdd$1(this, _rawCodeFrame);
34914
+ __privateAdd(this, _JSONError_instances);
34915
+ __publicField(this, "name", "JSONError");
34916
+ __publicField(this, "fileName");
34917
+ __privateAdd(this, _input);
34918
+ __privateAdd(this, _jsonParseError);
34919
+ __privateAdd(this, _message);
34920
+ __privateAdd(this, _codeFrame);
34921
+ __privateAdd(this, _rawCodeFrame);
34705
34922
  return this;
34706
34923
  };
34707
34924
  var _a$2;
@@ -34729,11 +34946,11 @@ ${codeFrame}
34729
34946
  __privateSet(this, _message, message);
34730
34947
  }
34731
34948
  get codeFrame() {
34732
- __privateGet(this, _codeFrame) ?? __privateSet(this, _codeFrame, __privateMethod$1(this, _JSONError_instances, getCodeFrame_fn).call(this, true));
34949
+ __privateGet(this, _codeFrame) ?? __privateSet(this, _codeFrame, __privateMethod(this, _JSONError_instances, getCodeFrame_fn).call(this, true));
34733
34950
  return __privateGet(this, _codeFrame);
34734
34951
  }
34735
34952
  get rawCodeFrame() {
34736
- __privateGet(this, _rawCodeFrame) ?? __privateSet(this, _rawCodeFrame, __privateMethod$1(this, _JSONError_instances, getCodeFrame_fn).call(this, false));
34953
+ __privateGet(this, _rawCodeFrame) ?? __privateSet(this, _rawCodeFrame, __privateMethod(this, _JSONError_instances, getCodeFrame_fn).call(this, false));
34737
34954
  return __privateGet(this, _rawCodeFrame);
34738
34955
  }
34739
34956
  };
@@ -34893,9 +35110,9 @@ var _TomlDate = class _TomlDate$1 extends Date {
34893
35110
  } else date$4 = "";
34894
35111
  }
34895
35112
  super(date$4);
34896
- __privateAdd$1(this, _hasDate, false);
34897
- __privateAdd$1(this, _hasTime, false);
34898
- __privateAdd$1(this, _offset, null);
35113
+ __privateAdd(this, _hasDate, false);
35114
+ __privateAdd(this, _hasTime, false);
35115
+ __privateAdd(this, _offset, null);
34899
35116
  if (!isNaN(this.getTime())) {
34900
35117
  __privateSet(this, _hasDate, hasDate);
34901
35118
  __privateSet(this, _hasTime, hasTime);
@@ -35359,7 +35576,7 @@ function parse4(toml, opts) {
35359
35576
  }
35360
35577
  return res;
35361
35578
  }
35362
- async function readFile(file$1) {
35579
+ async function readFile$1(file$1) {
35363
35580
  if (isUrlString(file$1)) file$1 = new URL(file$1);
35364
35581
  try {
35365
35582
  return await fs2.readFile(file$1, "utf8");
@@ -35368,7 +35585,7 @@ async function readFile(file$1) {
35368
35585
  throw new Error(`Unable to read '${file$1}': ${error$41.message}`);
35369
35586
  }
35370
35587
  }
35371
- var read_file_default = readFile;
35588
+ var read_file_default = readFile$1;
35372
35589
  async function readJson$1(file$1) {
35373
35590
  const content$2 = await read_file_default(file$1);
35374
35591
  try {
@@ -37468,7 +37685,7 @@ var get_alignment_size_default = getAlignmentSize;
37468
37685
  var _AstPath_instances, getNodeStackIndex_fn, getAncestors_fn;
37469
37686
  var AstPath = class {
37470
37687
  constructor(value) {
37471
- __privateAdd$1(this, _AstPath_instances);
37688
+ __privateAdd(this, _AstPath_instances);
37472
37689
  this.stack = [value];
37473
37690
  }
37474
37691
  /** @type {string | null} */
@@ -37531,7 +37748,7 @@ var AstPath = class {
37531
37748
  }
37532
37749
  /** @type {object[]} */
37533
37750
  get ancestors() {
37534
- return [...__privateMethod$1(this, _AstPath_instances, getAncestors_fn).call(this)];
37751
+ return [...__privateMethod(this, _AstPath_instances, getAncestors_fn).call(this)];
37535
37752
  }
37536
37753
  getName() {
37537
37754
  const { stack: stack2 } = this;
@@ -37543,7 +37760,7 @@ var AstPath = class {
37543
37760
  return at_default(false, this.stack, -1);
37544
37761
  }
37545
37762
  getNode(count = 0) {
37546
- const stackIndex = __privateMethod$1(this, _AstPath_instances, getNodeStackIndex_fn).call(this, count);
37763
+ const stackIndex = __privateMethod(this, _AstPath_instances, getNodeStackIndex_fn).call(this, count);
37547
37764
  return stackIndex === -1 ? null : this.stack[stackIndex];
37548
37765
  }
37549
37766
  getParentNode(count = 0) {
@@ -37570,7 +37787,7 @@ var AstPath = class {
37570
37787
  * @returns {ReturnType<T>}
37571
37788
  */
37572
37789
  callParent(callback, count = 0) {
37573
- const stackIndex = __privateMethod$1(this, _AstPath_instances, getNodeStackIndex_fn).call(this, count + 1);
37790
+ const stackIndex = __privateMethod(this, _AstPath_instances, getNodeStackIndex_fn).call(this, count + 1);
37574
37791
  const parentValues = this.stack.splice(stackIndex + 1);
37575
37792
  try {
37576
37793
  return callback(this);
@@ -37635,7 +37852,7 @@ var AstPath = class {
37635
37852
  * @internal Unstable API. Don't use in plugins for now.
37636
37853
  */
37637
37854
  findAncestor(predicate) {
37638
- for (const node$1 of __privateMethod$1(this, _AstPath_instances, getAncestors_fn).call(this)) if (predicate(node$1)) return node$1;
37855
+ for (const node$1 of __privateMethod(this, _AstPath_instances, getAncestors_fn).call(this)) if (predicate(node$1)) return node$1;
37639
37856
  }
37640
37857
  /**
37641
37858
  * Traverses the ancestors of the current node heading toward the tree root
@@ -37646,7 +37863,7 @@ var AstPath = class {
37646
37863
  * @internal Unstable API. Don't use in plugins for now.
37647
37864
  */
37648
37865
  hasAncestor(predicate) {
37649
- for (const node$1 of __privateMethod$1(this, _AstPath_instances, getAncestors_fn).call(this)) if (predicate(node$1)) return true;
37866
+ for (const node$1 of __privateMethod(this, _AstPath_instances, getAncestors_fn).call(this)) if (predicate(node$1)) return true;
37650
37867
  return false;
37651
37868
  }
37652
37869
  };
@@ -41080,582 +41297,181 @@ function stringifySearchWith(stringify$6, parser$2) {
41080
41297
  }
41081
41298
 
41082
41299
  //#endregion
41083
- //#region ../../node_modules/.pnpm/signal-polyfill@0.2.2/node_modules/signal-polyfill/dist/index.js
41084
- var __defProp = Object.defineProperty;
41085
- var __defNormalProp = (obj, key$1, value) => key$1 in obj ? __defProp(obj, key$1, {
41086
- enumerable: true,
41087
- configurable: true,
41088
- writable: true,
41089
- value
41090
- }) : obj[key$1] = value;
41091
- var __publicField = (obj, key$1, value) => {
41092
- __defNormalProp(obj, typeof key$1 !== "symbol" ? key$1 + "" : key$1, value);
41093
- return value;
41094
- };
41095
- var __accessCheck = (obj, member, msg) => {
41096
- if (!member.has(obj)) throw TypeError("Cannot " + msg);
41097
- };
41098
- var __privateIn = (member, obj) => {
41099
- if (Object(obj) !== obj) throw TypeError("Cannot use the \"in\" operator on this value");
41100
- return member.has(obj);
41101
- };
41102
- var __privateAdd = (obj, member, value) => {
41103
- if (member.has(obj)) throw TypeError("Cannot add the same private member more than once");
41104
- member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
41105
- };
41106
- var __privateMethod = (obj, member, method) => {
41107
- __accessCheck(obj, member, "access private method");
41108
- return method;
41109
- };
41300
+ //#region ../dev/dist/reactive-fs/reactive-context.js
41301
+ var import_src$3 = __toESM$1(require_src$2(), 1);
41302
+ const debug$3 = (0, import_src$3.default)("jixo:reactive-fs-v2");
41303
+ const contextStorage = new AsyncLocalStorage();
41110
41304
  /**
41111
- * @license
41112
- * Copyright Google LLC All Rights Reserved.
41113
- *
41114
- * Use of this source code is governed by an MIT-style license that can be
41115
- * found in the LICENSE file at https://angular.io/license
41305
+ * Represents a single piece of reactive state that can be tracked by a ReactiveContext.
41306
+ * It's analogous to Signal.State.
41116
41307
  */
41117
- function defaultEquals(a$1, b$1) {
41118
- return Object.is(a$1, b$1);
41119
- }
41308
+ var ReactiveState = class {
41309
+ currentValue;
41310
+ equals;
41311
+ constructor(initialValue, options$1) {
41312
+ this.currentValue = initialValue;
41313
+ this.equals = options$1?.equals ?? ((a$1, b$1) => a$1 === b$1);
41314
+ }
41315
+ /**
41316
+ * Retrieves the current value of the state.
41317
+ * If called within a ReactiveContext task, it enables tracking.
41318
+ * @returns The current value.
41319
+ */
41320
+ get() {
41321
+ const context = contextStorage.getStore();
41322
+ if (context) return context.getOrPushCache(this, this.currentValue);
41323
+ return this.currentValue;
41324
+ }
41325
+ /**
41326
+ * Updates the value of the state.
41327
+ * If the new value is different from the old one, it notifies any active
41328
+ * ReactiveContext that it has become dirty.
41329
+ * @param newValue The new value.
41330
+ */
41331
+ set(newValue) {
41332
+ if (this.equals(this.currentValue, newValue)) return false;
41333
+ this.currentValue = newValue;
41334
+ const context = contextStorage.getStore();
41335
+ context?.notifyChange();
41336
+ return true;
41337
+ }
41338
+ };
41120
41339
  /**
41121
- * @license
41122
- * Copyright Google LLC All Rights Reserved.
41123
- *
41124
- * Use of this source code is governed by an MIT-style license that can be
41125
- * found in the LICENSE file at https://angular.io/license
41340
+ * Manages the execution of an asynchronous, reactive task.
41341
+ * It now works by tracking changes on ReactiveState instances used within its task.
41126
41342
  */
41127
- let activeConsumer = null;
41128
- let inNotificationPhase = false;
41129
- let epoch = 1;
41130
- const SIGNAL = /* @__PURE__ */ Symbol("SIGNAL");
41131
- function setActiveConsumer(consumer) {
41132
- const prev = activeConsumer;
41133
- activeConsumer = consumer;
41134
- return prev;
41135
- }
41136
- function getActiveConsumer() {
41137
- return activeConsumer;
41138
- }
41139
- function isInNotificationPhase() {
41140
- return inNotificationPhase;
41141
- }
41142
- const REACTIVE_NODE = {
41143
- version: 0,
41144
- lastCleanEpoch: 0,
41145
- dirty: false,
41146
- producerNode: void 0,
41147
- producerLastReadVersion: void 0,
41148
- producerIndexOfThis: void 0,
41149
- nextProducerIndex: 0,
41150
- liveConsumerNode: void 0,
41151
- liveConsumerIndexOfThis: void 0,
41152
- consumerAllowSignalWrites: false,
41153
- consumerIsAlwaysLive: false,
41154
- producerMustRecompute: () => false,
41155
- producerRecomputeValue: () => {},
41156
- consumerMarkedDirty: () => {},
41157
- consumerOnSignalRead: () => {}
41158
- };
41159
- function producerAccessed(node$1) {
41160
- if (inNotificationPhase) throw new Error(typeof ngDevMode !== "undefined" && ngDevMode ? `Assertion error: signal read during notification phase` : "");
41161
- if (activeConsumer === null) return;
41162
- activeConsumer.consumerOnSignalRead(node$1);
41163
- const idx = activeConsumer.nextProducerIndex++;
41164
- assertConsumerNode(activeConsumer);
41165
- if (idx < activeConsumer.producerNode.length && activeConsumer.producerNode[idx] !== node$1) {
41166
- if (consumerIsLive(activeConsumer)) {
41167
- const staleProducer = activeConsumer.producerNode[idx];
41168
- producerRemoveLiveConsumerAtIndex(staleProducer, activeConsumer.producerIndexOfThis[idx]);
41169
- }
41170
- }
41171
- if (activeConsumer.producerNode[idx] !== node$1) {
41172
- activeConsumer.producerNode[idx] = node$1;
41173
- activeConsumer.producerIndexOfThis[idx] = consumerIsLive(activeConsumer) ? producerAddLiveConsumer(node$1, activeConsumer, idx) : 0;
41174
- }
41175
- activeConsumer.producerLastReadVersion[idx] = node$1.version;
41176
- }
41177
- function producerIncrementEpoch() {
41178
- epoch++;
41179
- }
41180
- function producerUpdateValueVersion(node$1) {
41181
- if (!node$1.dirty && node$1.lastCleanEpoch === epoch) return;
41182
- if (!node$1.producerMustRecompute(node$1) && !consumerPollProducersForChange(node$1)) {
41183
- node$1.dirty = false;
41184
- node$1.lastCleanEpoch = epoch;
41185
- return;
41186
- }
41187
- node$1.producerRecomputeValue(node$1);
41188
- node$1.dirty = false;
41189
- node$1.lastCleanEpoch = epoch;
41190
- }
41191
- function producerNotifyConsumers(node$1) {
41192
- if (node$1.liveConsumerNode === void 0) return;
41193
- const prev = inNotificationPhase;
41194
- inNotificationPhase = true;
41195
- try {
41196
- for (const consumer of node$1.liveConsumerNode) if (!consumer.dirty) consumerMarkDirty(consumer);
41197
- } finally {
41198
- inNotificationPhase = prev;
41343
+ var ReactiveContext = class {
41344
+ watch;
41345
+ isRunning = false;
41346
+ hasChanged;
41347
+ caches = /* @__PURE__ */ new Map();
41348
+ task;
41349
+ constructor(task, watch = false) {
41350
+ this.watch = watch;
41351
+ if (typeof task !== "function") throw new TypeError("Task must be a function.");
41352
+ this.task = task;
41199
41353
  }
41200
- }
41201
- function producerUpdatesAllowed() {
41202
- return (activeConsumer == null ? void 0 : activeConsumer.consumerAllowSignalWrites) !== false;
41203
- }
41204
- function consumerMarkDirty(node$1) {
41205
- var _a$2;
41206
- node$1.dirty = true;
41207
- producerNotifyConsumers(node$1);
41208
- (_a$2 = node$1.consumerMarkedDirty) == null || _a$2.call(node$1.wrapper ?? node$1);
41209
- }
41210
- function consumerBeforeComputation(node$1) {
41211
- node$1 && (node$1.nextProducerIndex = 0);
41212
- return setActiveConsumer(node$1);
41213
- }
41214
- function consumerAfterComputation(node$1, prevConsumer) {
41215
- setActiveConsumer(prevConsumer);
41216
- if (!node$1 || node$1.producerNode === void 0 || node$1.producerIndexOfThis === void 0 || node$1.producerLastReadVersion === void 0) return;
41217
- if (consumerIsLive(node$1)) for (let i$2 = node$1.nextProducerIndex; i$2 < node$1.producerNode.length; i$2++) producerRemoveLiveConsumerAtIndex(node$1.producerNode[i$2], node$1.producerIndexOfThis[i$2]);
41218
- while (node$1.producerNode.length > node$1.nextProducerIndex) {
41219
- node$1.producerNode.pop();
41220
- node$1.producerLastReadVersion.pop();
41221
- node$1.producerIndexOfThis.pop();
41222
- }
41223
- }
41224
- function consumerPollProducersForChange(node$1) {
41225
- assertConsumerNode(node$1);
41226
- for (let i$2 = 0; i$2 < node$1.producerNode.length; i$2++) {
41227
- const producer = node$1.producerNode[i$2];
41228
- const seenVersion = node$1.producerLastReadVersion[i$2];
41229
- if (seenVersion !== producer.version) return true;
41230
- producerUpdateValueVersion(producer);
41231
- if (seenVersion !== producer.version) return true;
41354
+ /** @internal */
41355
+ getOrPushCache(state, value) {
41356
+ if (this.caches.has(state)) return this.caches.get(state);
41357
+ this.caches.set(state, value);
41358
+ return value;
41232
41359
  }
41233
- return false;
41234
- }
41235
- function producerAddLiveConsumer(node$1, consumer, indexOfThis) {
41236
- var _a$2;
41237
- assertProducerNode(node$1);
41238
- assertConsumerNode(node$1);
41239
- if (node$1.liveConsumerNode.length === 0) {
41240
- (_a$2 = node$1.watched) == null || _a$2.call(node$1.wrapper);
41241
- for (let i$2 = 0; i$2 < node$1.producerNode.length; i$2++) node$1.producerIndexOfThis[i$2] = producerAddLiveConsumer(node$1.producerNode[i$2], node$1, i$2);
41360
+ /** @internal */
41361
+ notifyChange() {
41362
+ debug$3("notifyChange", this.hasChanged);
41363
+ this.hasChanged?.resolve();
41242
41364
  }
41243
- node$1.liveConsumerIndexOfThis.push(indexOfThis);
41244
- return node$1.liveConsumerNode.push(consumer) - 1;
41245
- }
41246
- function producerRemoveLiveConsumerAtIndex(node$1, idx) {
41247
- var _a$2;
41248
- assertProducerNode(node$1);
41249
- assertConsumerNode(node$1);
41250
- if (typeof ngDevMode !== "undefined" && ngDevMode && idx >= node$1.liveConsumerNode.length) throw new Error(`Assertion error: active consumer index ${idx} is out of bounds of ${node$1.liveConsumerNode.length} consumers)`);
41251
- if (node$1.liveConsumerNode.length === 1) {
41252
- (_a$2 = node$1.unwatched) == null || _a$2.call(node$1.wrapper);
41253
- for (let i$2 = 0; i$2 < node$1.producerNode.length; i$2++) producerRemoveLiveConsumerAtIndex(node$1.producerNode[i$2], node$1.producerIndexOfThis[i$2]);
41254
- }
41255
- const lastIdx = node$1.liveConsumerNode.length - 1;
41256
- node$1.liveConsumerNode[idx] = node$1.liveConsumerNode[lastIdx];
41257
- node$1.liveConsumerIndexOfThis[idx] = node$1.liveConsumerIndexOfThis[lastIdx];
41258
- node$1.liveConsumerNode.length--;
41259
- node$1.liveConsumerIndexOfThis.length--;
41260
- if (idx < node$1.liveConsumerNode.length) {
41261
- const idxProducer = node$1.liveConsumerIndexOfThis[idx];
41262
- const consumer = node$1.liveConsumerNode[idx];
41263
- assertConsumerNode(consumer);
41264
- consumer.producerIndexOfThis[idxProducer] = idx;
41265
- }
41266
- }
41267
- function consumerIsLive(node$1) {
41268
- var _a$2;
41269
- return node$1.consumerIsAlwaysLive || (((_a$2 = node$1 == null ? void 0 : node$1.liveConsumerNode) == null ? void 0 : _a$2.length) ?? 0) > 0;
41270
- }
41271
- function assertConsumerNode(node$1) {
41272
- node$1.producerNode ?? (node$1.producerNode = []);
41273
- node$1.producerIndexOfThis ?? (node$1.producerIndexOfThis = []);
41274
- node$1.producerLastReadVersion ?? (node$1.producerLastReadVersion = []);
41275
- }
41276
- function assertProducerNode(node$1) {
41277
- node$1.liveConsumerNode ?? (node$1.liveConsumerNode = []);
41278
- node$1.liveConsumerIndexOfThis ?? (node$1.liveConsumerIndexOfThis = []);
41279
- }
41280
- /**
41281
- * @license
41282
- * Copyright Google LLC All Rights Reserved.
41283
- *
41284
- * Use of this source code is governed by an MIT-style license that can be
41285
- * found in the LICENSE file at https://angular.io/license
41286
- */
41287
- function computedGet(node$1) {
41288
- producerUpdateValueVersion(node$1);
41289
- producerAccessed(node$1);
41290
- if (node$1.value === ERRORED) throw node$1.error;
41291
- return node$1.value;
41292
- }
41293
- function createComputed(computation) {
41294
- const node$1 = Object.create(COMPUTED_NODE);
41295
- node$1.computation = computation;
41296
- const computed = () => computedGet(node$1);
41297
- computed[SIGNAL] = node$1;
41298
- return computed;
41299
- }
41300
- const UNSET = /* @__PURE__ */ Symbol("UNSET");
41301
- const COMPUTING = /* @__PURE__ */ Symbol("COMPUTING");
41302
- const ERRORED = /* @__PURE__ */ Symbol("ERRORED");
41303
- const COMPUTED_NODE = /* @__PURE__ */ (() => {
41304
- return {
41305
- ...REACTIVE_NODE,
41306
- value: UNSET,
41307
- dirty: true,
41308
- error: null,
41309
- equal: defaultEquals,
41310
- producerMustRecompute(node$1) {
41311
- return node$1.value === UNSET || node$1.value === COMPUTING;
41312
- },
41313
- producerRecomputeValue(node$1) {
41314
- if (node$1.value === COMPUTING) throw new Error("Detected cycle in computations.");
41315
- const oldValue = node$1.value;
41316
- node$1.value = COMPUTING;
41317
- const prevConsumer = consumerBeforeComputation(node$1);
41318
- let newValue;
41319
- let wasEqual = false;
41320
- try {
41321
- newValue = node$1.computation.call(node$1.wrapper);
41322
- const oldOk = oldValue !== UNSET && oldValue !== ERRORED;
41323
- wasEqual = oldOk && node$1.equal.call(node$1.wrapper, oldValue, newValue);
41324
- } catch (err) {
41325
- newValue = ERRORED;
41326
- node$1.error = err;
41327
- } finally {
41328
- consumerAfterComputation(node$1, prevConsumer);
41329
- }
41330
- if (wasEqual) {
41331
- node$1.value = oldValue;
41332
- return;
41333
- }
41334
- node$1.value = newValue;
41335
- node$1.version++;
41336
- }
41337
- };
41338
- })();
41339
- /**
41340
- * @license
41341
- * Copyright Google LLC All Rights Reserved.
41342
- *
41343
- * Use of this source code is governed by an MIT-style license that can be
41344
- * found in the LICENSE file at https://angular.io/license
41345
- */
41346
- function defaultThrowError() {
41347
- throw new Error();
41348
- }
41349
- let throwInvalidWriteToSignalErrorFn = defaultThrowError;
41350
- function throwInvalidWriteToSignalError() {
41351
- throwInvalidWriteToSignalErrorFn();
41352
- }
41353
- /**
41354
- * @license
41355
- * Copyright Google LLC All Rights Reserved.
41356
- *
41357
- * Use of this source code is governed by an MIT-style license that can be
41358
- * found in the LICENSE file at https://angular.io/license
41359
- */
41360
- function createSignal(initialValue) {
41361
- const node$1 = Object.create(SIGNAL_NODE);
41362
- node$1.value = initialValue;
41363
- const getter = () => {
41364
- producerAccessed(node$1);
41365
- return node$1.value;
41366
- };
41367
- getter[SIGNAL] = node$1;
41368
- return getter;
41369
- }
41370
- function signalGetFn() {
41371
- producerAccessed(this);
41372
- return this.value;
41373
- }
41374
- function signalSetFn(node$1, newValue) {
41375
- if (!producerUpdatesAllowed()) throwInvalidWriteToSignalError();
41376
- if (!node$1.equal.call(node$1.wrapper, node$1.value, newValue)) {
41377
- node$1.value = newValue;
41378
- signalValueChanged(node$1);
41379
- }
41380
- }
41381
- const SIGNAL_NODE = /* @__PURE__ */ (() => {
41382
- return {
41383
- ...REACTIVE_NODE,
41384
- equal: defaultEquals,
41385
- value: void 0
41386
- };
41387
- })();
41388
- function signalValueChanged(node$1) {
41389
- node$1.version++;
41390
- producerIncrementEpoch();
41391
- producerNotifyConsumers(node$1);
41392
- }
41393
- /**
41394
- * @license
41395
- * Copyright 2024 Bloomberg Finance L.P.
41396
- *
41397
- * Licensed under the Apache License, Version 2.0 (the "License");
41398
- * you may not use this file except in compliance with the License.
41399
- * You may obtain a copy of the License at
41400
- *
41401
- * http://www.apache.org/licenses/LICENSE-2.0
41402
- *
41403
- * Unless required by applicable law or agreed to in writing, software
41404
- * distributed under the License is distributed on an "AS IS" BASIS,
41405
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41406
- * See the License for the specific language governing permissions and
41407
- * limitations under the License.
41408
- */
41409
- const NODE = Symbol("node");
41410
- var Signal;
41411
- ((Signal2) => {
41412
- var _a$2, _brand, brand_fn, _b$1, _brand2, brand_fn2;
41413
- class State$2 {
41414
- constructor(initialValue, options$1 = {}) {
41415
- __privateAdd(this, _brand);
41416
- __publicField(this, _a$2);
41417
- const ref = createSignal(initialValue);
41418
- const node$1 = ref[SIGNAL];
41419
- this[NODE] = node$1;
41420
- node$1.wrapper = this;
41421
- if (options$1) {
41422
- const equals = options$1.equals;
41423
- if (equals) node$1.equal = equals;
41424
- node$1.watched = options$1[Signal2.subtle.watched];
41425
- node$1.unwatched = options$1[Signal2.subtle.unwatched];
41426
- }
41427
- }
41428
- get() {
41429
- if (!(0, Signal2.isState)(this)) throw new TypeError("Wrong receiver type for Signal.State.prototype.get");
41430
- return signalGetFn.call(this[NODE]);
41431
- }
41432
- set(newValue) {
41433
- if (!(0, Signal2.isState)(this)) throw new TypeError("Wrong receiver type for Signal.State.prototype.set");
41434
- if (isInNotificationPhase()) throw new Error("Writes to signals not permitted during Watcher callback");
41435
- const ref = this[NODE];
41436
- signalSetFn(ref, newValue);
41437
- }
41438
- }
41439
- _a$2 = NODE;
41440
- _brand = /* @__PURE__ */ new WeakSet();
41441
- brand_fn = function() {};
41442
- Signal2.isState = (s$2) => typeof s$2 === "object" && __privateIn(_brand, s$2);
41443
- Signal2.State = State$2;
41444
- class Computed {
41445
- constructor(computation, options$1) {
41446
- __privateAdd(this, _brand2);
41447
- __publicField(this, _b$1);
41448
- const ref = createComputed(computation);
41449
- const node$1 = ref[SIGNAL];
41450
- node$1.consumerAllowSignalWrites = true;
41451
- this[NODE] = node$1;
41452
- node$1.wrapper = this;
41453
- if (options$1) {
41454
- const equals = options$1.equals;
41455
- if (equals) node$1.equal = equals;
41456
- node$1.watched = options$1[Signal2.subtle.watched];
41457
- node$1.unwatched = options$1[Signal2.subtle.unwatched];
41458
- }
41459
- }
41460
- get() {
41461
- if (!(0, Signal2.isComputed)(this)) throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");
41462
- return computedGet(this[NODE]);
41463
- }
41464
- }
41465
- _b$1 = NODE;
41466
- _brand2 = /* @__PURE__ */ new WeakSet();
41467
- brand_fn2 = function() {};
41468
- Signal2.isComputed = (c$2) => typeof c$2 === "object" && __privateIn(_brand2, c$2);
41469
- Signal2.Computed = Computed;
41470
- ((subtle2) => {
41471
- var _a2, _brand3, brand_fn3, _assertSignals, assertSignals_fn;
41472
- function untrack(cb) {
41473
- let output;
41474
- let prevActiveConsumer = null;
41475
- try {
41476
- prevActiveConsumer = setActiveConsumer(null);
41477
- output = cb();
41478
- } finally {
41479
- setActiveConsumer(prevActiveConsumer);
41480
- }
41481
- return output;
41365
+ /**
41366
+ * TODO 实现off
41367
+ * @param watch
41368
+ * @returns
41369
+ */
41370
+ async run({ signal } = {}) {
41371
+ if (this.isRunning) {
41372
+ console.warn("ReactiveContext.run() called while already running. Ignoring call.");
41373
+ return;
41482
41374
  }
41483
- subtle2.untrack = untrack;
41484
- function introspectSources(sink) {
41485
- var _a3;
41486
- if (!(0, Signal2.isComputed)(sink) && !(0, Signal2.isWatcher)(sink)) throw new TypeError("Called introspectSources without a Computed or Watcher argument");
41487
- return ((_a3 = sink[NODE].producerNode) == null ? void 0 : _a3.map((n$1) => n$1.wrapper)) ?? [];
41488
- }
41489
- subtle2.introspectSources = introspectSources;
41490
- function introspectSinks(signal) {
41491
- var _a3;
41492
- if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) throw new TypeError("Called introspectSinks without a Signal argument");
41493
- return ((_a3 = signal[NODE].liveConsumerNode) == null ? void 0 : _a3.map((n$1) => n$1.wrapper)) ?? [];
41494
- }
41495
- subtle2.introspectSinks = introspectSinks;
41496
- function hasSinks(signal) {
41497
- if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) throw new TypeError("Called hasSinks without a Signal argument");
41498
- const liveConsumerNode = signal[NODE].liveConsumerNode;
41499
- if (!liveConsumerNode) return false;
41500
- return liveConsumerNode.length > 0;
41501
- }
41502
- subtle2.hasSinks = hasSinks;
41503
- function hasSources(signal) {
41504
- if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isWatcher)(signal)) throw new TypeError("Called hasSources without a Computed or Watcher argument");
41505
- const producerNode = signal[NODE].producerNode;
41506
- if (!producerNode) return false;
41507
- return producerNode.length > 0;
41508
- }
41509
- subtle2.hasSources = hasSources;
41510
- class Watcher {
41511
- constructor(notify) {
41512
- __privateAdd(this, _brand3);
41513
- __privateAdd(this, _assertSignals);
41514
- __publicField(this, _a2);
41515
- let node$1 = Object.create(REACTIVE_NODE);
41516
- node$1.wrapper = this;
41517
- node$1.consumerMarkedDirty = notify;
41518
- node$1.consumerIsAlwaysLive = true;
41519
- node$1.consumerAllowSignalWrites = false;
41520
- node$1.producerNode = [];
41521
- this[NODE] = node$1;
41522
- }
41523
- watch(...signals$1) {
41524
- if (!(0, Signal2.isWatcher)(this)) throw new TypeError("Called unwatch without Watcher receiver");
41525
- __privateMethod(this, _assertSignals, assertSignals_fn).call(this, signals$1);
41526
- const node$1 = this[NODE];
41527
- node$1.dirty = false;
41528
- const prev = setActiveConsumer(node$1);
41529
- for (const signal of signals$1) producerAccessed(signal[NODE]);
41530
- setActiveConsumer(prev);
41531
- }
41532
- unwatch(...signals$1) {
41533
- if (!(0, Signal2.isWatcher)(this)) throw new TypeError("Called unwatch without Watcher receiver");
41534
- __privateMethod(this, _assertSignals, assertSignals_fn).call(this, signals$1);
41535
- const node$1 = this[NODE];
41536
- assertConsumerNode(node$1);
41537
- for (let i$2 = node$1.producerNode.length - 1; i$2 >= 0; i$2--) if (signals$1.includes(node$1.producerNode[i$2].wrapper)) {
41538
- producerRemoveLiveConsumerAtIndex(node$1.producerNode[i$2], node$1.producerIndexOfThis[i$2]);
41539
- const lastIdx = node$1.producerNode.length - 1;
41540
- node$1.producerNode[i$2] = node$1.producerNode[lastIdx];
41541
- node$1.producerIndexOfThis[i$2] = node$1.producerIndexOfThis[lastIdx];
41542
- node$1.producerNode.length--;
41543
- node$1.producerIndexOfThis.length--;
41544
- node$1.nextProducerIndex--;
41545
- if (i$2 < node$1.producerNode.length) {
41546
- const idxConsumer = node$1.producerIndexOfThis[i$2];
41547
- const producer = node$1.producerNode[i$2];
41548
- assertProducerNode(producer);
41549
- producer.liveConsumerIndexOfThis[idxConsumer] = i$2;
41550
- }
41551
- }
41552
- }
41553
- getPending() {
41554
- if (!(0, Signal2.isWatcher)(this)) throw new TypeError("Called getPending without Watcher receiver");
41555
- const node$1 = this[NODE];
41556
- return node$1.producerNode.filter((n$1) => n$1.dirty).map((n$1) => n$1.wrapper);
41375
+ this.isRunning = true;
41376
+ try {
41377
+ if (this.watch) while (!signal?.aborted) {
41378
+ const hasChanged = this.hasChanged = Promise.withResolvers();
41379
+ this.caches.clear();
41380
+ const runOnce = async () => {
41381
+ await contextStorage.run(this, this.task);
41382
+ await hasChanged.promise;
41383
+ };
41384
+ await (signal ? abort_signal_race(signal, runOnce) : runOnce());
41557
41385
  }
41386
+ else await contextStorage.run(this, this.task);
41387
+ } finally {
41388
+ this.hasChanged?.reject(/* @__PURE__ */ new Error("Context ended"));
41389
+ this.hasChanged = void 0;
41390
+ this.isRunning = false;
41558
41391
  }
41559
- _a2 = NODE;
41560
- _brand3 = /* @__PURE__ */ new WeakSet();
41561
- brand_fn3 = function() {};
41562
- _assertSignals = /* @__PURE__ */ new WeakSet();
41563
- assertSignals_fn = function(signals$1) {
41564
- for (const signal of signals$1) if (!(0, Signal2.isComputed)(signal) && !(0, Signal2.isState)(signal)) throw new TypeError("Called watch/unwatch without a Computed or State argument");
41565
- };
41566
- Signal2.isWatcher = (w$2) => __privateIn(_brand3, w$2);
41567
- subtle2.Watcher = Watcher;
41568
- function currentComputed() {
41569
- var _a3;
41570
- return (_a3 = getActiveConsumer()) == null ? void 0 : _a3.wrapper;
41571
- }
41572
- subtle2.currentComputed = currentComputed;
41573
- subtle2.watched = Symbol("watched");
41574
- subtle2.unwatched = Symbol("unwatched");
41575
- })(Signal2.subtle || (Signal2.subtle = {}));
41576
- })(Signal || (Signal = {}));
41577
-
41578
- //#endregion
41579
- //#region ../../node_modules/.pnpm/signal-utils@0.21.1_signal-polyfill@0.2.2/node_modules/signal-utils/dist/subtle/microtask-effect.ts.js
41580
- let pending = false;
41581
- let watcher = new Signal.subtle.Watcher(() => {
41582
- if (!pending) {
41583
- pending = true;
41584
- queueMicrotask(() => {
41585
- pending = false;
41586
- flushPending();
41587
- });
41588
41392
  }
41589
- });
41590
- function flushPending() {
41591
- for (const signal of watcher.getPending()) signal.get();
41592
- watcher.watch();
41593
- }
41594
- /**
41595
- * ⚠️ WARNING: Nothing unwatches ⚠️
41596
- * This will produce a memory leak.
41597
- */
41598
- function effect(cb) {
41599
- let c$2 = new Signal.Computed(() => cb());
41600
- watcher.watch(c$2);
41601
- c$2.get();
41602
- return () => {
41603
- watcher.unwatch(c$2);
41604
- };
41605
- }
41393
+ };
41606
41394
 
41607
41395
  //#endregion
41608
41396
  //#region ../dev/dist/reactive-fs/reactive-fs.js
41397
+ var import_src$2 = __toESM$1(require_src$2(), 1);
41609
41398
  const ONCE_AC = createAcontext("ONCE", () => false);
41610
- const getFileState = (filepath, once$1 = ONCE_AC.get()) => {
41611
- const fileState = new Signal.State(readFileSync(filepath, "utf-8"));
41612
- if (!once$1) {
41613
- const off = effect(() => {
41614
- const watcher$1 = watch(filepath, () => {
41615
- try {
41616
- fileState.set(readFileSync(filepath, "utf-8"));
41617
- } catch {
41618
- console.log(`File ${filepath} not found, stopping watcher.`);
41619
- watcher$1.close();
41620
- off();
41621
- }
41622
- });
41399
+ const FILE_WATCH_OPTIONS_AC = createAcontext("FILE_WATCH_OPTIONS", () => ({}));
41400
+ const DIR_WATCH_OPTIONS_AC = createAcontext("DIR_WATCH_OPTIONS", () => ({}));
41401
+ const stateCache = /* @__PURE__ */ new Map();
41402
+ const debug$2 = (0, import_src$2.default)("jixo:reactive-fs-v2");
41403
+ const readFile = (filepath) => {
41404
+ filepath = path.resolve(filepath);
41405
+ const key$1 = `file:${filepath}`;
41406
+ const getValue = () => existsSync(filepath) ? readFileSync(filepath, "utf-8") : "";
41407
+ const fileState = map_get_or_put(stateCache, key$1, () => new ReactiveState(getValue()));
41408
+ if (!ONCE_AC.get()) {
41409
+ debug$2("watch file", filepath);
41410
+ const fileWatchOptions = FILE_WATCH_OPTIONS_AC.get();
41411
+ const watcher = watchFile(filepath, {
41412
+ ...fileWatchOptions,
41413
+ bigint: false
41414
+ }, () => {
41415
+ try {
41416
+ const changed = fileState.set(getValue());
41417
+ if (changed) debug$2("file changed", filepath);
41418
+ } catch {
41419
+ console.log(`File ${filepath} not found, stopping watcher.`);
41420
+ watcher.unref();
41421
+ }
41623
41422
  });
41624
41423
  }
41625
- return fileState;
41424
+ return fileState.get();
41626
41425
  };
41627
- const dirGlobState = (dirname$2, glob, once$1 = ONCE_AC.get()) => {
41628
- const dirState = new Signal.State(globbySync(glob, { cwd: dirname$2 }), { equals(t$1, t2) {
41629
- return t$1.length === t2.length && t$1.every((file$1, i$2) => file$1 === t2[i$2]);
41630
- } });
41631
- if (!once$1) {
41632
- const off = effect(async () => {
41633
- const sub = await parcelWatcher.subscribe(dirname$2, (err, events) => {
41634
- if (events.some((event) => event.type === "create" || event.type === "delete")) try {
41635
- dirState.set(globbySync(glob, { cwd: dirname$2 }));
41636
- } catch {
41637
- sub.unsubscribe();
41638
- off();
41639
- }
41640
- });
41426
+ const readDirByGlob = (dirname$2, glob = "*", globbyOptions) => {
41427
+ dirname$2 = path.resolve(dirname$2);
41428
+ const getValue = () => {
41429
+ return globbySync(glob, {
41430
+ cwd: dirname$2,
41431
+ ...globbyOptions
41432
+ });
41433
+ };
41434
+ const key$1 = `glob:${dirname$2}:${JSON.stringify(Array.isArray(glob) ? glob : [glob])}`;
41435
+ const globState = map_get_or_put(stateCache, key$1, () => new ReactiveState(getValue(), { equals: (a$1, b$1) => a$1.length === b$1.length && a$1.every((v$1, i$2) => v$1 === b$1[i$2]) }));
41436
+ if (!ONCE_AC.get()) {
41437
+ const dirWatchOptions = DIR_WATCH_OPTIONS_AC.get();
41438
+ debug$2("watch dir", dirname$2);
41439
+ const subp = parcelWatcher.subscribe(dirname$2, (err, events) => {
41440
+ if (events.some((event) => event.type === "create" || event.type === "delete")) try {
41441
+ const changed = globState.set(getValue());
41442
+ if (changed) debug$2("dir changed", dirname$2);
41443
+ } catch {
41444
+ subp.then((sub) => sub.unsubscribe());
41445
+ }
41446
+ }, dirWatchOptions);
41447
+ const freshList = globbySync(glob, {
41448
+ cwd: dirname$2,
41449
+ ...globbyOptions
41641
41450
  });
41451
+ globState.set(freshList);
41642
41452
  }
41643
- return dirState;
41453
+ return globState.get();
41644
41454
  };
41645
- const useReactiveFs = (run$1, opts) => {
41455
+ const useReactiveFs = (run$1, opts = {}) => {
41646
41456
  const once$1 = opts?.once ?? ONCE_AC.get();
41647
- const off = effect(() => {
41648
- ONCE_AC.run(once$1, run$1);
41457
+ const fileWatchOptions = opts?.fileWatchOptions ?? FILE_WATCH_OPTIONS_AC.get();
41458
+ const dirWatchOptions = opts?.dirWatchOptions ?? DIR_WATCH_OPTIONS_AC.get();
41459
+ const context = new ReactiveContext(run$1, !once$1);
41460
+ return useAcontexts([
41461
+ ONCE_AC,
41462
+ FILE_WATCH_OPTIONS_AC,
41463
+ DIR_WATCH_OPTIONS_AC
41464
+ ])([
41465
+ once$1,
41466
+ fileWatchOptions,
41467
+ dirWatchOptions
41468
+ ], () => {
41469
+ return context.run();
41649
41470
  });
41650
- if (once$1) {
41651
- off();
41652
- return () => {};
41653
- }
41654
- return off;
41655
41471
  };
41656
41472
  const reactiveFs = {
41657
- getFile: getFileState,
41658
- readDir: dirGlobState,
41473
+ readFile,
41474
+ readDirByGlob,
41659
41475
  use: useReactiveFs
41660
41476
  };
41661
41477
 
@@ -41787,7 +41603,7 @@ function useFileOrInject$1(mode, filepath, filecontent, opts = {}) {
41787
41603
  /**
41788
41604
  * Handles replacements for file-based sources like local file system, URLs, and internal jixo protocol.
41789
41605
  */
41790
- const handleFileReplacement = async ({ globOrFilepath, mode, params, once: once$1, rootResolver, baseDir }) => {
41606
+ const handleFileReplacement = async ({ globOrFilepath, mode, params, rootResolver, baseDir }) => {
41791
41607
  if (globOrFilepath.startsWith("jixo:")) {
41792
41608
  const jixo_url = new URL(globOrFilepath);
41793
41609
  const filepath = (jixo_url.pathname || jixo_url.hostname).replace(/^\//, "");
@@ -41828,7 +41644,7 @@ const handleFileReplacement = async ({ globOrFilepath, mode, params, once: once$
41828
41644
  } else for (const filepath of files$1) {
41829
41645
  const fullFilepath = rootResolver(filepath);
41830
41646
  if (!fs.statSync(fullFilepath).isFile()) continue;
41831
- const fileContent = getFileState(fullFilepath, once$1).get();
41647
+ const fileContent = reactiveFs.readFile(fullFilepath);
41832
41648
  const ext = path.parse(filepath).ext.slice(1);
41833
41649
  lines.push(useFileOrInject$1(mode, filepath, fileContent, {
41834
41650
  prefix: params.prefix,
@@ -52960,10 +52776,10 @@ function removeMarkdownComments(markdownContent) {
52960
52776
 
52961
52777
  //#endregion
52962
52778
  //#region ../dev/dist/gen-prompt.js
52963
- var import_src = __toESM$1(require_src$2(), 1);
52779
+ var import_src$1 = __toESM$1(require_src$2(), 1);
52964
52780
  process.removeAllListeners("warning");
52965
- const debug = (0, import_src.default)("gen-prompt");
52966
- async function processReplacement(globOrFilepath, mode, paramString, once$1, rootResolver, baseDir) {
52781
+ const debug$1 = (0, import_src$1.default)("gen-prompt");
52782
+ async function processReplacement(globOrFilepath, mode, paramString, rootResolver, baseDir) {
52967
52783
  if (globOrFilepath.startsWith("`") && globOrFilepath.endsWith("`")) globOrFilepath = globOrFilepath.replace(/^`+(.*)`+$/, "$1");
52968
52784
  globOrFilepath = normalizeFilePath(globOrFilepath);
52969
52785
  const normalizedMode = mode.toUpperCase().replaceAll("-", "_").trim();
@@ -52972,11 +52788,10 @@ async function processReplacement(globOrFilepath, mode, paramString, once$1, roo
52972
52788
  globOrFilepath,
52973
52789
  mode: normalizedMode,
52974
52790
  params,
52975
- once: once$1,
52976
52791
  rootResolver,
52977
52792
  baseDir
52978
52793
  };
52979
- debug("Dispatching replacement for:", {
52794
+ debug$1("Dispatching replacement for:", {
52980
52795
  globOrFilepath,
52981
52796
  mode: normalizedMode,
52982
52797
  params
@@ -52984,9 +52799,9 @@ async function processReplacement(globOrFilepath, mode, paramString, once$1, roo
52984
52799
  if (mode.startsWith("GIT")) return handleGitReplacement(options$1);
52985
52800
  return handleFileReplacement(options$1);
52986
52801
  }
52987
- async function gen_prompt(input, once$1, _output, cwd) {
52802
+ async function gen_prompt(input, _output, cwd) {
52988
52803
  console.log(blue("gen_prompt"), input);
52989
- const inputSource = getFileState(input, once$1).get();
52804
+ const inputSource = reactiveFs.readFile(input);
52990
52805
  let { data: inputData, content: inputContent } = (0, import_gray_matter.default)(inputSource);
52991
52806
  inputContent = removeMarkdownComments(inputContent).trim();
52992
52807
  const currentRootResolver = z(cwd).with(N.string, (c$2) => createResolver(c$2)).otherwise(() => z(inputData.cwd).with(N.when((p$1) => p$1 && path.isAbsolute(p$1)), (p$1) => createResolver(p$1)).with(N.string, (p$1) => createResolver(path.resolve(path.dirname(input), p$1))).otherwise(() => createResolverByRootFile(input, ".git", () => path.dirname(input))));
@@ -52995,7 +52810,7 @@ async function gen_prompt(input, once$1, _output, cwd) {
52995
52810
  const matches = [...inputContent.matchAll(regex$1)];
52996
52811
  const replacementPromises = matches.map((match) => {
52997
52812
  const [_$1, globOrFilepath, mode, paramString] = match;
52998
- return processReplacement(globOrFilepath, mode, paramString, once$1, currentRootResolver, currentRootResolver.dirname);
52813
+ return processReplacement(globOrFilepath, mode, paramString, currentRootResolver, currentRootResolver.dirname);
52999
52814
  });
53000
52815
  const replacements$1 = await Promise.all(replacementPromises);
53001
52816
  let outputContent = inputContent;
@@ -53011,34 +52826,29 @@ async function gen_prompt(input, once$1, _output, cwd) {
53011
52826
  const doGenPrompts = async (argv) => {
53012
52827
  const once$1 = !argv.watch;
53013
52828
  const CWD = argv.cwd || process.cwd();
53014
- for (const input of argv.inputs) {
53015
- const resolvedInput = path.resolve(CWD, input);
53016
- if (isDynamicPattern(input)) {
53017
- const files$1 = globbySync(input, { cwd: CWD });
53018
- console.log(`Glob pattern '${input}' matched ${files$1.length} files.`);
53019
- for (const file$1 of files$1) await gen_prompt(file$1, once$1, void 0, CWD);
53020
- } else if (fs.existsSync(resolvedInput)) {
53021
- const stat$1 = fs.statSync(resolvedInput);
53022
- if (stat$1.isFile()) {
53023
- const off = effect(() => {
53024
- gen_prompt(resolvedInput, once$1, argv.outFile, CWD);
53025
- });
53026
- if (once$1) off();
53027
- } else if (stat$1.isDirectory()) {
53028
- console.log(`Processing directory '${input}' with glob '${argv.glob}'...`);
53029
- const off = effect(() => {
53030
- for (const filename of dirGlobState(resolvedInput, argv.glob, once$1).get()) gen_prompt(path.join(resolvedInput, filename), once$1, void 0, CWD);
53031
- });
53032
- if (once$1) off();
52829
+ if (argv.watch) console.log(gray("\nWatching for file changes... Press Ctrl+C to exit."));
52830
+ await reactiveFs.use(async () => {
52831
+ for (const input of argv.inputs) {
52832
+ const resolvedInput = path.resolve(CWD, input);
52833
+ if (isDynamicPattern(input)) {
52834
+ const files$1 = globbySync(input, { cwd: CWD });
52835
+ console.log(`Glob pattern '${input}' matched ${files$1.length} files.`);
52836
+ for (const file$1 of files$1) await gen_prompt(file$1, void 0, CWD);
52837
+ } else if (fs.existsSync(resolvedInput)) {
52838
+ const stat$1 = fs.statSync(resolvedInput);
52839
+ if (stat$1.isFile()) gen_prompt(resolvedInput, argv.outFile, CWD);
52840
+ else if (stat$1.isDirectory()) {
52841
+ console.log(`Processing directory '${input}' with glob '${argv.glob}'...`);
52842
+ for (const filename of reactiveFs.readDirByGlob(resolvedInput, argv.glob)) gen_prompt(path.join(resolvedInput, filename), void 0, CWD);
52843
+ }
52844
+ } else {
52845
+ console.warn(`Warning: Input path does not exist, but treating as a potential glob: ${input}`);
52846
+ const files$1 = reactiveFs.readDirByGlob(CWD, input);
52847
+ if (files$1.length > 0) for (const file$1 of files$1) await gen_prompt(file$1, void 0, CWD);
52848
+ else console.error(`Error: Input '${input}' not found and did not match any files.`);
53033
52849
  }
53034
- } else {
53035
- console.warn(`Warning: Input path does not exist, but treating as a potential glob: ${input}`);
53036
- const files$1 = globbySync(input, { cwd: CWD });
53037
- if (files$1.length > 0) for (const file$1 of files$1) await gen_prompt(file$1, once$1, void 0, CWD);
53038
- else console.error(`Error: Input '${input}' not found and did not match any files.`);
53039
52850
  }
53040
- }
53041
- if (argv.watch) console.log(gray("\nWatching for file changes... Press Ctrl+C to exit."));
52851
+ }, { once: once$1 });
53042
52852
  };
53043
52853
 
53044
52854
  //#endregion
@@ -62371,7 +62181,6 @@ const zContentSchema = looseObject$1({
62371
62181
  contents: array$1(object$1({
62372
62182
  role: string$2(),
62373
62183
  parts: array$1(union$1([
62374
- object$1({ isLast: boolean$2() }),
62375
62184
  object$1({
62376
62185
  isLast: boolean$2(),
62377
62186
  text: string$2()
@@ -62402,7 +62211,8 @@ const zContentSchema = looseObject$1({
62402
62211
  fileIndex: number$2(),
62403
62212
  fileName: string$2()
62404
62213
  })
62405
- })
62214
+ }),
62215
+ object$1({ isLast: boolean$2() })
62406
62216
  ])),
62407
62217
  isLast: optional$1(boolean$2())
62408
62218
  })),
@@ -62429,7 +62239,7 @@ const zContentSchema = looseObject$1({
62429
62239
  //#endregion
62430
62240
  //#region ../dev/dist/google-aistudio/node/index.js
62431
62241
  const doGoogleAiStudioAutomation = (dir = process.cwd()) => {
62432
- const watcher$1 = fs.watch(dir);
62242
+ const watcher = fs.watch(dir);
62433
62243
  const handle = func_debounce(async () => {
62434
62244
  const names = fs.readdirSync(dir);
62435
62245
  const contentNames = names.filter((name$1) => name$1.endsWith(".contents.json"));
@@ -62482,7 +62292,7 @@ const doGoogleAiStudioAutomation = (dir = process.cwd()) => {
62482
62292
  }
62483
62293
  }
62484
62294
  };
62485
- watcher$1.on("change", (eventType) => {
62295
+ watcher.on("change", (eventType) => {
62486
62296
  if (eventType === "delete" || eventType === "unlink") return;
62487
62297
  handle();
62488
62298
  });
@@ -63780,13 +63590,16 @@ var zod_default = external_exports;
63780
63590
 
63781
63591
  //#endregion
63782
63592
  //#region ../dev/dist/google-aistudio/jixo/sync.js
63593
+ var import_src = __toESM$1(require_src$2(), 1);
63594
+ const debug = (0, import_src.default)("jixo:go-sync");
63783
63595
  const sync = async (basePath, outDir) => {
63784
63596
  const s$2 = statSync(basePath);
63785
63597
  if (s$2.isDirectory()) {
63786
- for (const contentsJsonFile of reactiveFs.readDir(basePath, "*.contents.json").get()) sync(path.join(basePath, contentsJsonFile), outDir);
63598
+ for (const contentsJsonFile of reactiveFs.readDirByGlob(basePath, "*.contents.json")) await sync(path.join(basePath, contentsJsonFile), outDir);
63787
63599
  return;
63788
63600
  }
63789
- const rawContents = reactiveFs.getFile(basePath).get();
63601
+ debug("发现contents.json文件", basePath);
63602
+ const rawContents = reactiveFs.readFile(basePath);
63790
63603
  const safeContents = await zContentSchema.safeParseAsync((() => {
63791
63604
  try {
63792
63605
  return JSON.parse(rawContents);
@@ -63796,10 +63609,11 @@ const sync = async (basePath, outDir) => {
63796
63609
  console.error(safeContents.error.message);
63797
63610
  return;
63798
63611
  }
63799
- const contents = safeContents.data;
63612
+ const contentsData = safeContents.data;
63613
+ const { contents } = contentsData.generateContentParameters;
63800
63614
  let first_index = 0;
63801
63615
  let second_index = -1;
63802
- const modelHistory = iter_map_not_null(contents.generateContentParameters.contents, (content$2) => {
63616
+ const modelHistory = iter_map_not_null(contents, (content$2) => {
63803
63617
  if (content$2.role === "model") {
63804
63618
  const textParts = content$2.parts.filter((p$1) => "text" in p$1);
63805
63619
  return textParts.at(-1)?.text;
@@ -63835,10 +63649,19 @@ const sync = async (basePath, outDir) => {
63835
63649
  * @param args - 命令行参数,符合 yargs 解析后的结构
63836
63650
  */
63837
63651
  const doSync = (args) => {
63652
+ const targetPath = zod_default.string().safeParse(args._[0]).data ?? process.cwd();
63838
63653
  reactiveFs.use(async () => {
63839
- const targetPath = zod_default.string().safeParse(args._[0]).data ?? process.cwd();
63654
+ console.log(red("start"));
63655
+ await (async () => {
63656
+ await delay(100);
63657
+ console.log(reactiveFs.readFile(path.resolve(targetPath, "../package.json")).length);
63658
+ })();
63840
63659
  await sync(targetPath, args.outDir);
63841
- }, { once: !args.watch });
63660
+ console.log(red("end"));
63661
+ }, {
63662
+ once: !args.watch,
63663
+ fileWatchOptions: { interval: 500 }
63664
+ });
63842
63665
  if (args.watch) console.log(gray("\nWatching for file changes... Press Ctrl+C to exit."));
63843
63666
  };
63844
63667