@codeworksh/cli 0.0.1-dev.20260918040208 → 0.0.1-dev.20260918042316

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.
@@ -17,32 +17,10 @@ import { Bash } from "just-bash";
17
17
  import { fileURLToPath, pathToFileURL } from "node:url";
18
18
  import path from "node:path";
19
19
  import { Script, constants } from "node:vm";
20
+ import npa from "npm-package-arg";
20
21
  import * as AikitFailure from "@codeworksh/aikit/failure";
22
+ import { parse, printParseErrorCode } from "jsonc-parser";
21
23
  import { Rpc, RpcClient, RpcGroup, RpcSerialization } from "effect/unstable/rpc";
22
- //#region \0rolldown/runtime.js
23
- var __create = Object.create;
24
- var __defProp = Object.defineProperty;
25
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
26
- var __getOwnPropNames = Object.getOwnPropertyNames;
27
- var __getProtoOf = Object.getPrototypeOf;
28
- var __hasOwnProp = Object.prototype.hasOwnProperty;
29
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
30
- var __copyProps = (to, from, except, desc) => {
31
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
32
- key = keys[i];
33
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
34
- get: ((k) => from[k]).bind(null, key),
35
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
36
- });
37
- }
38
- return to;
39
- };
40
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
41
- value: mod,
42
- enumerable: true
43
- }) : target, mod));
44
- var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
45
- //#endregion
46
24
  //#region ../harness/src/schema.ts
47
25
  const aikitValidators = /* @__PURE__ */ new WeakMap();
48
26
  const aikitValidatorFor = (schema) => {
@@ -403,11 +381,11 @@ function resolveDatabaseLocation(configured, data) {
403
381
  if (configured === ":memory:" || posix.isAbsolute(configured)) return configured;
404
382
  return posix.join(data, configured);
405
383
  }
406
- const path$2 = Effect.fn("Database.path")(function* (data) {
384
+ const path$1 = Effect.fn("Database.path")(function* (data) {
407
385
  const directory = data ?? (yield* resolve$2()).data;
408
386
  return resolveDatabaseLocation(yield* locationConfig, directory);
409
387
  });
410
- const defaultLayer$1 = Layer.unwrap(path$2().pipe(Effect.map(layer$26)));
388
+ const defaultLayer$1 = Layer.unwrap(path$1().pipe(Effect.map(layer$26)));
411
389
  //#endregion
412
390
  //#region ../harness/src/event/schema.ts
413
391
  /** Undeclared fields used only while aikit is assembling a streamed part. */
@@ -451,7 +429,7 @@ const AikitToolCallTerminalPart = Schema.Unknown.pipe(Schema.decodeTo(aikitToolC
451
429
  encode: SchemaGetter.transformEffect(decodeAikitToolCallTerminalPart)
452
430
  }));
453
431
  const ID$4 = Schema.String.pipe(Schema.brand("Event.ID"), withStatics((schema) => ({ create: () => schema.make(`evt_${uuidv7()}`) })));
454
- function define$3(input) {
432
+ function define$2(input) {
455
433
  const data = Schema.Struct(input.schema);
456
434
  return Schema.Struct({
457
435
  id: ID$4,
@@ -969,12 +947,12 @@ const PromptFields = {
969
947
  prompt: Prompt,
970
948
  delivery: Delivery
971
949
  };
972
- const PromptAdmitted = define$3({
950
+ const PromptAdmitted = define$2({
973
951
  type: "session.prompt.admitted",
974
952
  ...durableOptions,
975
953
  schema: PromptFields
976
954
  });
977
- const Prompted = define$3({
955
+ const Prompted = define$2({
978
956
  type: "session.prompt.promoted",
979
957
  ...durableOptions,
980
958
  schema: PromptFields
@@ -992,16 +970,16 @@ const TurnAbortCause = Schema.Union([
992
970
  Schema.TaggedStruct("error", { message: Schema.String }),
993
971
  Schema.TaggedStruct("deferred", { message: Schema.String })
994
972
  ]);
995
- const TurnStarted = define$3({
973
+ const TurnStarted = define$2({
996
974
  type: "session.turn.started",
997
975
  schema: baseOptions
998
976
  });
999
- const TurnEnded = define$3({
977
+ const TurnEnded = define$2({
1000
978
  type: "session.turn.ended",
1001
979
  ...durableOptions,
1002
980
  schema: LLMFields
1003
981
  });
1004
- const TurnAborted = define$3({
982
+ const TurnAborted = define$2({
1005
983
  type: "session.turn.aborted",
1006
984
  schema: {
1007
985
  ...baseOptions,
@@ -1009,7 +987,7 @@ const TurnAborted = define$3({
1009
987
  }
1010
988
  });
1011
989
  /** Durable insertion of the request's draft assistant placeholder. */
1012
- const LLMStarted = define$3({
990
+ const LLMStarted = define$2({
1013
991
  type: "session.llm.started",
1014
992
  ...durableOptions,
1015
993
  schema: {
@@ -1017,36 +995,36 @@ const LLMStarted = define$3({
1017
995
  message: AikitAssistantMessage
1018
996
  }
1019
997
  });
1020
- const LLMTextStart = define$3({
998
+ const LLMTextStart = define$2({
1021
999
  type: "session.llm.text.start",
1022
1000
  schema: LLMPartFields
1023
1001
  });
1024
- const LLMTextDelta = define$3({
1002
+ const LLMTextDelta = define$2({
1025
1003
  type: "session.llm.text.delta",
1026
1004
  schema: {
1027
1005
  ...LLMPartFields,
1028
1006
  delta: Schema.String
1029
1007
  }
1030
1008
  });
1031
- const LLMTextEnd = define$3({
1009
+ const LLMTextEnd = define$2({
1032
1010
  type: "session.llm.text.end",
1033
1011
  schema: {
1034
1012
  ...LLMPartFields,
1035
1013
  content: Schema.String
1036
1014
  }
1037
1015
  });
1038
- const LLMThinkingStart = define$3({
1016
+ const LLMThinkingStart = define$2({
1039
1017
  type: "session.llm.thinking.start",
1040
1018
  schema: LLMPartFields
1041
1019
  });
1042
- const LLMThinkingDelta = define$3({
1020
+ const LLMThinkingDelta = define$2({
1043
1021
  type: "session.llm.thinking.delta",
1044
1022
  schema: {
1045
1023
  ...LLMPartFields,
1046
1024
  delta: Schema.String
1047
1025
  }
1048
1026
  });
1049
- const LLMThinkingEnd = define$3({
1027
+ const LLMThinkingEnd = define$2({
1050
1028
  type: "session.llm.thinking.end",
1051
1029
  schema: {
1052
1030
  ...LLMPartFields,
@@ -1054,7 +1032,7 @@ const LLMThinkingEnd = define$3({
1054
1032
  }
1055
1033
  });
1056
1034
  /** aikit `done`: replace the LLMStarted payload in place; state stays draft. */
1057
- const LLMEnded = define$3({
1035
+ const LLMEnded = define$2({
1058
1036
  type: "session.llm.ended",
1059
1037
  ...durableOptions,
1060
1038
  schema: {
@@ -1068,7 +1046,7 @@ const LLMEnded = define$3({
1068
1046
  }
1069
1047
  });
1070
1048
  /** Abort the whole draft and discard every part. */
1071
- const LLMFailed = define$3({
1049
+ const LLMFailed = define$2({
1072
1050
  type: "session.llm.failed",
1073
1051
  ...durableOptions,
1074
1052
  schema: {
@@ -1077,7 +1055,7 @@ const LLMFailed = define$3({
1077
1055
  message: AikitAssistantMessage
1078
1056
  }
1079
1057
  });
1080
- const ToolStarted = define$3({
1058
+ const ToolStarted = define$2({
1081
1059
  type: "session.tool.started",
1082
1060
  schema: {
1083
1061
  ...LLMFields,
@@ -1085,7 +1063,7 @@ const ToolStarted = define$3({
1085
1063
  name: Schema.String
1086
1064
  }
1087
1065
  });
1088
- const ToolProgress$1 = define$3({
1066
+ const ToolProgress$1 = define$2({
1089
1067
  type: "session.tool.progress",
1090
1068
  schema: {
1091
1069
  ...LLMFields,
@@ -1093,7 +1071,7 @@ const ToolProgress$1 = define$3({
1093
1071
  partial: Schema.Unknown
1094
1072
  }
1095
1073
  });
1096
- const ToolSettled = define$3({
1074
+ const ToolSettled = define$2({
1097
1075
  type: "session.tool.settled",
1098
1076
  ...durableOptions,
1099
1077
  schema: {
@@ -1109,7 +1087,7 @@ const ToolSettled = define$3({
1109
1087
  * makes the seeded range auditable from the log itself, not only from
1110
1088
  * `session.parentId`.
1111
1089
  */
1112
- const SessionForked = define$3({
1090
+ const SessionForked = define$2({
1113
1091
  type: "session.next.forked",
1114
1092
  ...durableOptions,
1115
1093
  schema: {
@@ -1128,22 +1106,22 @@ const SessionForked = define$3({
1128
1106
  * what its outcome actually has: a failure has an error, an interruption has a
1129
1107
  * reason, and a success has neither.
1130
1108
  */
1131
- const ExecutionStarted = define$3({
1109
+ const ExecutionStarted = define$2({
1132
1110
  type: "session.execution.started",
1133
1111
  schema: baseOptions
1134
1112
  });
1135
- const ExecutionSucceeded = define$3({
1113
+ const ExecutionSucceeded = define$2({
1136
1114
  type: "session.execution.succeeded",
1137
1115
  schema: baseOptions
1138
1116
  });
1139
- const ExecutionFailed = define$3({
1117
+ const ExecutionFailed = define$2({
1140
1118
  type: "session.execution.failed",
1141
1119
  schema: {
1142
1120
  ...baseOptions,
1143
1121
  error: Error$1
1144
1122
  }
1145
1123
  });
1146
- const ExecutionInterrupted = define$3({
1124
+ const ExecutionInterrupted = define$2({
1147
1125
  type: "session.execution.interrupted",
1148
1126
  schema: {
1149
1127
  ...baseOptions,
@@ -6222,3298 +6200,191 @@ function missing(error) {
6222
6200
  ].includes(String(error.code));
6223
6201
  }
6224
6202
  //#endregion
6225
- //#region ../../node_modules/.pnpm/lru-cache@11.5.2/node_modules/lru-cache/dist/commonjs/node/index.min.js
6226
- var require_index_min = /* @__PURE__ */ __commonJSMin(((exports) => {
6227
- var j = (u, t) => () => (t || u((t = { exports: {} }).exports, t), t.exports);
6228
- var I = j((O) => {
6229
- "use strict";
6230
- Object.defineProperty(O, "__esModule", { value: !0 });
6231
- O.tracing = O.metrics = void 0;
6232
- var U = __require("node:diagnostics_channel");
6233
- O.metrics = (0, U.channel)("lru-cache:metrics");
6234
- O.tracing = (0, U.tracingChannel)("lru-cache");
6235
- });
6236
- var P = j((R) => {
6237
- "use strict";
6238
- Object.defineProperty(R, "__esModule", { value: !0 });
6239
- R.defaultPerf = void 0;
6240
- R.defaultPerf = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
6241
- });
6242
- Object.defineProperty(exports, "__esModule", { value: !0 });
6243
- exports.LRUCache = void 0;
6244
- var g = I();
6245
- var N = P();
6246
- var C = () => g.metrics.hasSubscribers || g.tracing.hasSubscribers;
6247
- var k = /* @__PURE__ */ new Set();
6248
- var G = typeof process == "object" && process ? process : {};
6249
- var V = (u, t, e, i) => {
6250
- typeof G.emitWarning == "function" ? G.emitWarning(u, t, e, i) : console.error(`[${e}] ${t}: ${u}`);
6203
+ //#region ../harness/src/plugin/package.ts
6204
+ const parse$2 = (source) => {
6205
+ const parsed = npa(source);
6206
+ if (!parsed.name || ![
6207
+ "version",
6208
+ "range",
6209
+ "tag"
6210
+ ].includes(parsed.type)) throw new Error(`Unsupported plugin package source: ${source}`);
6211
+ const omitted = parsed.raw === parsed.name || parsed.raw === `${parsed.name}@`;
6212
+ return {
6213
+ name: parsed.name,
6214
+ spec: `${parsed.name}@${omitted ? "latest" : parsed.rawSpec}`
6251
6215
  };
6252
- var q = (u) => !k.has(u);
6253
- var T = (u) => !!u && u === Math.floor(u) && u > 0 && isFinite(u);
6254
- var H = (u) => T(u) ? u <= Math.pow(2, 8) ? Uint8Array : u <= Math.pow(2, 16) ? Uint16Array : u <= Math.pow(2, 32) ? Uint32Array : u <= Number.MAX_SAFE_INTEGER ? W : null : null;
6255
- var W = class extends Array {
6256
- constructor(t) {
6257
- super(t), this.fill(0);
6258
- }
6216
+ };
6217
+ const Manifest$1 = Schema.Struct({ version: Schema.String });
6218
+ const Cached = Schema.Struct({
6219
+ version: Schema.String,
6220
+ spec: Schema.String,
6221
+ entrypoint: Schema.String
6222
+ });
6223
+ /** Runs inside the isolated staging directory. Override only for deterministic tests. */
6224
+ var InstallError = class extends Schema.TaggedError()("PluginInstallError", { cause: Schema.Defect() }) {};
6225
+ const run$3 = Effect.fn("PluginPackage.run")(function* (request, directory) {
6226
+ const code = yield* (yield* (yield* ChildProcessSpawner.ChildProcessSpawner).spawn(ChildProcess.make("pnpm", [
6227
+ "add",
6228
+ "--ignore-scripts",
6229
+ "--ignore-workspace",
6230
+ "--save-exact",
6231
+ request.spec
6232
+ ], {
6233
+ cwd: directory,
6234
+ stdout: "ignore",
6235
+ stderr: "inherit"
6236
+ }))).exitCode;
6237
+ if (code !== 0) return yield* new InstallError({ cause: /* @__PURE__ */ new Error(`pnpm installation failed with exit code ${code}`) });
6238
+ }, Effect.scoped, Effect.provide(NodeChildProcessSpawner.layer.pipe(Layer.provide(Layer.merge(NodeFileSystem.layer, NodePath.layer)))), Effect.mapError((cause) => Schema.is(InstallError)(cause) ? cause : new InstallError({ cause })));
6239
+ /** How long to wait for another installer of the same spec before giving up. */
6240
+ const LOCK_TIMEOUT = Duration.minutes(2);
6241
+ /** The holder refreshes the lock's mtime this often; a lock not refreshed for the timeout is abandoned. */
6242
+ const LOCK_HEARTBEAT = Duration.seconds(15);
6243
+ /**
6244
+ * A lock whose holder stopped refreshing it was left by a crashed installer. Staleness is
6245
+ * measured from the heartbeat, not the install's start, so a slow but live install is never
6246
+ * stolen from.
6247
+ */
6248
+ const abandoned = (directory) => Effect.gen(function* () {
6249
+ const info = yield* fileSystem.stat(directory);
6250
+ const now = yield* Effect.clockWith((clock) => clock.currentTimeMillis);
6251
+ return Option.exists(info.mtime, (mtime) => now - mtime.getTime() > Duration.toMillis(LOCK_TIMEOUT));
6252
+ }).pipe(Effect.orElseSucceed(() => false));
6253
+ const heartbeat = (directory) => Effect.clockWith((clock) => clock.currentTimeMillis).pipe(Effect.flatMap((now) => fileSystem.utimes(directory, now, now)), Effect.ignore, Effect.repeat(Schedule.spaced(LOCK_HEARTBEAT)));
6254
+ /**
6255
+ * Claims `directory` by creating it, polling while another process holds it.
6256
+ *
6257
+ * One finalizer for the whole wait, registered before the first attempt: retrying inside
6258
+ * `acquireRelease` would add a finalizer per poll. A crashed installer leaves its lock
6259
+ * behind; an abandoned one is reclaimed rather than waited on forever, and the wait itself
6260
+ * is bounded. While held, the lock is heartbeated so waiters can tell live from dead.
6261
+ */
6262
+ const lock = Effect.fn("PluginPackage.lock")(function* (directory) {
6263
+ const held = yield* Ref.make(false);
6264
+ yield* Effect.acquireRelease(Effect.void, () => Ref.get(held).pipe(Effect.flatMap((owned) => owned ? fileSystem.remove(directory, {
6265
+ recursive: true,
6266
+ force: true
6267
+ }) : Effect.void), Effect.orDie));
6268
+ if (!(yield* fileSystem.makeDirectory(directory).pipe(Effect.andThen(Ref.set(held, true)), Effect.as(true), Effect.catchIf((error) => error.reason._tag === "AlreadyExists", () => abandoned(directory).pipe(Effect.flatMap((stale) => stale ? fileSystem.remove(directory, {
6269
+ recursive: true,
6270
+ force: true
6271
+ }).pipe(Effect.as(false)) : Effect.succeed(false)))), Effect.uninterruptible).pipe(Effect.repeat({
6272
+ schedule: Schedule.spaced("50 millis"),
6273
+ until: (owned) => owned
6274
+ }), Effect.timeoutOrElse({
6275
+ duration: LOCK_TIMEOUT,
6276
+ orElse: () => Effect.succeed(false)
6277
+ })))) return yield* new InstallError({ cause: /* @__PURE__ */ new Error(`Timed out waiting for another plugin installation to release ${directory}`) });
6278
+ yield* Effect.forkScoped(heartbeat(directory));
6279
+ });
6280
+ const install = Effect.fn("PluginPackage.install")(function* (request, cache, runner = run$3) {
6281
+ const root = hostPath.join(cache, "plugins");
6282
+ const key = Encoding.encodeHex(yield* crypto.digest("SHA-256", new TextEncoder().encode(request.spec)));
6283
+ const directory = hostPath.join(root, key);
6284
+ const marker = hostPath.join(directory, ".complete.json");
6285
+ yield* fileSystem.makeDirectory(root, { recursive: true });
6286
+ if (!(yield* fileSystem.exists(marker))) yield* lock(`${directory}.lock`);
6287
+ if (!(yield* fileSystem.exists(marker))) {
6288
+ const staging = yield* Effect.acquireRelease(fileSystem.makeTempDirectory({
6289
+ directory: root,
6290
+ prefix: `${key}-`
6291
+ }), (staging) => fileSystem.remove(staging, {
6292
+ recursive: true,
6293
+ force: true
6294
+ }).pipe(Effect.orDie));
6295
+ yield* fileSystem.writeFileString(hostPath.join(staging, "package.json"), "{\"private\":true,\"type\":\"module\"}");
6296
+ yield* runner(request, staging);
6297
+ const manifest = yield* fileSystem.readFileString(hostPath.join(staging, "node_modules", request.name, "package.json"));
6298
+ const installed = yield* Schema.decodeEffect(Schema.fromJsonString(Manifest$1))(manifest);
6299
+ const entrypoint = yield* Effect.try(() => resolveModule(request.name, staging));
6300
+ const entry = hostPath.relative(yield* fileSystem.realPath(staging), fileURLToPath(entrypoint));
6301
+ if (entry.startsWith("..") || hostPath.isAbsolute(entry)) return yield* new InstallError({ cause: /* @__PURE__ */ new Error(`Plugin entrypoint escapes its installation: ${entry}`) });
6302
+ yield* fileSystem.writeFileString(hostPath.join(staging, ".complete.json"), yield* Schema.encodeEffect(Schema.fromJsonString(Cached))({
6303
+ spec: request.spec,
6304
+ version: installed.version,
6305
+ entrypoint: entry
6306
+ }));
6307
+ if (yield* fileSystem.exists(directory)) yield* fileSystem.remove(directory, { recursive: true });
6308
+ yield* fileSystem.rename(staging, directory);
6309
+ }
6310
+ const saved = yield* fileSystem.readFileString(marker).pipe(Effect.flatMap(Schema.decodeUnknownEffect(Schema.fromJsonString(Cached))));
6311
+ if (saved.spec !== request.spec) return yield* new InstallError({ cause: /* @__PURE__ */ new Error("Plugin package cache request mismatch") });
6312
+ return {
6313
+ url: pathToFileURL(hostPath.resolve(directory, saved.entrypoint)).href,
6314
+ version: saved.version
6259
6315
  };
6260
- var L = class u {
6261
- heap;
6262
- length;
6263
- static #o = !1;
6264
- static create(t) {
6265
- let e = H(t);
6266
- if (!e) return [];
6267
- u.#o = !0;
6268
- let i = new u(t, e);
6269
- return u.#o = !1, i;
6270
- }
6271
- constructor(t, e) {
6272
- if (!u.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
6273
- this.heap = new e(t), this.length = 0;
6274
- }
6275
- push(t) {
6276
- this.heap[this.length++] = t;
6277
- }
6278
- pop() {
6279
- return this.heap[--this.length];
6280
- }
6316
+ }, Effect.scoped, Effect.mapError((cause) => Schema.is(InstallError)(cause) ? cause : new InstallError({ cause })));
6317
+ const Id = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*){2}$/));
6318
+ const Definition = Schema.Struct({
6319
+ id: Id,
6320
+ events: Schema.optional(Schema.Array(Schema.declare((value) => Predicate.hasProperty(value, "type") && Predicate.isString(value.type)))),
6321
+ setup: Schema.declare((value) => Predicate.isFunction(value))
6322
+ });
6323
+ var PreparationError = class extends Schema.TaggedError()("PluginPreparationError", {
6324
+ phase: Schema.Literals([
6325
+ "source",
6326
+ "install",
6327
+ "import",
6328
+ "definition"
6329
+ ]),
6330
+ index: Schema.Finite,
6331
+ reference: Schema.String,
6332
+ id: Schema.optional(Schema.String),
6333
+ cause: Schema.Defect()
6334
+ }) {};
6335
+ const failure$1 = (origin, phase, cause, id) => new PreparationError({
6336
+ ...origin,
6337
+ phase,
6338
+ cause,
6339
+ ...id === void 0 ? {} : { id }
6340
+ });
6341
+ const validate = Effect.fn("PluginLoader.validate")(function* (input, origin, builtin = false) {
6342
+ yield* Schema.decodeUnknownEffect(Definition)(input).pipe(Effect.mapError((cause) => failure$1(origin, "definition", cause)));
6343
+ const plugin = input;
6344
+ if (!builtin && plugin.id.startsWith("codework.")) return yield* failure$1(origin, "definition", /* @__PURE__ */ new Error("codework namespace is reserved for builtins"), plugin.id);
6345
+ return plugin;
6346
+ });
6347
+ /**
6348
+ * A reference is a source and nothing else: a path, a `file:` URL, or a package spec. IDs are
6349
+ * not spelled here — a bare `acme.tool.proc` is a package name, and the plugin it names is
6350
+ * addressed by `{ plugin: "acme.tool.proc" }`, which resolves against what is already registered.
6351
+ */
6352
+ const classify = (source, hostCwd) => {
6353
+ if (source.startsWith("file:")) {
6354
+ if (!source.startsWith("file:///")) throw new Error(`not an absolute file URL: ${source}`);
6355
+ return {
6356
+ kind: "local",
6357
+ path: fileURLToPath(source)
6358
+ };
6359
+ }
6360
+ const expanded = expandTilde(source, hostPath);
6361
+ if (expanded.startsWith("./") || expanded.startsWith("../") || hostPath.isAbsolute(expanded)) return {
6362
+ kind: "local",
6363
+ path: hostPath.resolve(hostCwd, expanded)
6281
6364
  };
6282
- exports.LRUCache = class u {
6283
- #o;
6284
- #c;
6285
- #m;
6286
- #W;
6287
- #S;
6288
- #x;
6289
- #j;
6290
- #w;
6291
- get perf() {
6292
- return this.#w;
6293
- }
6294
- ttl;
6295
- ttlResolution;
6296
- ttlAutopurge;
6297
- updateAgeOnGet;
6298
- updateAgeOnHas;
6299
- allowStale;
6300
- noDisposeOnSet;
6301
- noUpdateTTL;
6302
- maxEntrySize;
6303
- sizeCalculation;
6304
- noDeleteOnFetchRejection;
6305
- noDeleteOnStaleGet;
6306
- allowStaleOnFetchAbort;
6307
- allowStaleOnFetchRejection;
6308
- ignoreFetchAbort;
6309
- backgroundFetchSize;
6310
- #n;
6311
- #b;
6312
- #s;
6313
- #i;
6314
- #t;
6315
- #l;
6316
- #u;
6317
- #a;
6318
- #h;
6319
- #_;
6320
- #r;
6321
- #y;
6322
- #F;
6323
- #d;
6324
- #g;
6325
- #T;
6326
- #U;
6327
- #f;
6328
- #R;
6329
- static unsafeExposeInternals(t) {
6330
- return {
6331
- starts: t.#F,
6332
- ttls: t.#d,
6333
- autopurgeTimers: t.#g,
6334
- sizes: t.#y,
6335
- keyMap: t.#s,
6336
- keyList: t.#i,
6337
- valList: t.#t,
6338
- next: t.#l,
6339
- prev: t.#u,
6340
- get head() {
6341
- return t.#a;
6342
- },
6343
- get tail() {
6344
- return t.#h;
6345
- },
6346
- free: t.#_,
6347
- isBackgroundFetch: (e) => t.#e(e),
6348
- backgroundFetch: (e, i, s, n) => t.#G(e, i, s, n),
6349
- moveToTail: (e) => t.#M(e),
6350
- indexes: (e) => t.#A(e),
6351
- rindexes: (e) => t.#z(e),
6352
- isStale: (e) => t.#p(e)
6353
- };
6354
- }
6355
- get max() {
6356
- return this.#o;
6357
- }
6358
- get maxSize() {
6359
- return this.#c;
6360
- }
6361
- get calculatedSize() {
6362
- return this.#b;
6363
- }
6364
- get size() {
6365
- return this.#n;
6366
- }
6367
- get fetchMethod() {
6368
- return this.#x;
6369
- }
6370
- get memoMethod() {
6371
- return this.#j;
6372
- }
6373
- get dispose() {
6374
- return this.#m;
6375
- }
6376
- get onInsert() {
6377
- return this.#W;
6378
- }
6379
- get disposeAfter() {
6380
- return this.#S;
6381
- }
6382
- constructor(t) {
6383
- let { max: e = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: l, allowStale: h, dispose: r, onInsert: c, disposeAfter: w, noDisposeOnSet: y, noUpdateTTL: d, maxSize: p = 0, maxEntrySize: f = 0, sizeCalculation: _, fetchMethod: a, memoMethod: S, noDeleteOnFetchRejection: F, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: m, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, backgroundFetchSize: x = 1, perf: v } = t;
6384
- if (this.backgroundFetchSize = x, v !== void 0 && typeof v?.now != "function") throw new TypeError("perf option must have a now() method if specified");
6385
- if (this.#w = v ?? N.defaultPerf, e !== 0 && !T(e)) throw new TypeError("max option must be a nonnegative integer");
6386
- let E = e ? H(e) : Array;
6387
- if (!E) throw new Error("invalid max value: " + e);
6388
- if (this.#o = e, this.#c = p, this.maxEntrySize = f || this.#c, this.sizeCalculation = _, this.sizeCalculation) {
6389
- if (!this.#c && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
6390
- if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
6391
- }
6392
- if (S !== void 0 && typeof S != "function") throw new TypeError("memoMethod must be a function if defined");
6393
- if (this.#j = S, a !== void 0 && typeof a != "function") throw new TypeError("fetchMethod must be a function if specified");
6394
- if (this.#x = a, this.#U = !!a, this.#s = /* @__PURE__ */ new Map(), this.#i = Array.from({ length: e }).fill(void 0), this.#t = Array.from({ length: e }).fill(void 0), this.#l = new E(e), this.#u = new E(e), this.#a = 0, this.#h = 0, this.#_ = L.create(e), this.#n = 0, this.#b = 0, typeof r == "function" && (this.#m = r), typeof c == "function" && (this.#W = c), typeof w == "function" ? (this.#S = w, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#m, this.#R = !!this.#W, this.#f = !!this.#S, this.noDisposeOnSet = !!y, this.noUpdateTTL = !!d, this.noDeleteOnFetchRejection = !!F, this.allowStaleOnFetchRejection = !!m, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, this.maxEntrySize !== 0) {
6395
- if (this.#c !== 0 && !T(this.#c)) throw new TypeError("maxSize must be a positive integer if specified");
6396
- if (!T(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
6397
- this.#X();
6398
- }
6399
- if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!l, this.ttlResolution = T(s) || s === 0 ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
6400
- if (!T(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
6401
- this.#k();
6402
- }
6403
- if (this.#o === 0 && this.ttl === 0 && this.#c === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
6404
- if (!this.ttlAutopurge && !this.#o && !this.#c) {
6405
- let D = "LRU_CACHE_UNBOUNDED";
6406
- q(D) && (k.add(D), V("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", D, u));
6407
- }
6408
- }
6409
- getRemainingTTL(t) {
6410
- return this.#s.has(t) ? 1 / 0 : 0;
6411
- }
6412
- #k() {
6413
- let t = new W(this.#o), e = new W(this.#o);
6414
- this.#d = t, this.#F = e;
6415
- let i = this.ttlAutopurge ? Array.from({ length: this.#o }) : void 0;
6416
- this.#g = i, this.#H = (h, r, c = this.#w.now()) => {
6417
- e[h] = r !== 0 ? c : 0, t[h] = r, s(h, r);
6418
- }, this.#D = (h) => {
6419
- e[h] = t[h] !== 0 ? this.#w.now() : 0, s(h, t[h]);
6420
- };
6421
- let s = this.ttlAutopurge ? (h, r) => {
6422
- if (i?.[h] && (clearTimeout(i[h]), i[h] = void 0), r && r !== 0 && i) {
6423
- let c = setTimeout(() => {
6424
- this.#p(h) ? (this.#v(this.#i[h], "expire"), i[h] = void 0) : s(h, l(h));
6425
- }, r + 1);
6426
- c.unref && c.unref(), i[h] = c;
6427
- }
6428
- } : () => {};
6429
- this.#E = (h, r) => {
6430
- if (t[r]) {
6431
- let c = t[r], w = e[r];
6432
- if (!c || !w) return;
6433
- h.ttl = c, h.start = w, h.now = n || o();
6434
- h.remainingTTL = c - (h.now - w);
6435
- }
6436
- };
6437
- let n = 0, o = () => {
6438
- let h = this.#w.now();
6439
- if (this.ttlResolution > 0) {
6440
- n = h;
6441
- let r = setTimeout(() => n = 0, this.ttlResolution);
6442
- r.unref && r.unref();
6443
- }
6444
- return h;
6445
- };
6446
- this.getRemainingTTL = (h) => {
6447
- let r = this.#s.get(h);
6448
- return r === void 0 ? 0 : l(r);
6449
- };
6450
- let l = (h) => {
6451
- let r = t[h], c = e[h];
6452
- if (!r || !c) return 1 / 0;
6453
- return r - ((n || o()) - c);
6454
- };
6455
- this.#p = (h) => {
6456
- let r = e[h], c = t[h];
6457
- return !!c && !!r && (n || o()) - r > c;
6458
- };
6459
- }
6460
- #D = () => {};
6461
- #E = () => {};
6462
- #H = () => {};
6463
- #p = () => !1;
6464
- #X() {
6465
- let t = new W(this.#o);
6466
- this.#b = 0, this.#y = t, this.#C = (e) => {
6467
- this.#b -= t[e], t[e] = 0;
6468
- }, this.#N = (e, i, s, n) => {
6469
- if (!T(s)) {
6470
- if (this.#e(i)) return this.backgroundFetchSize;
6471
- if (n) {
6472
- if (typeof n != "function") throw new TypeError("sizeCalculation must be a function");
6473
- if (s = n(i, e), !T(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
6474
- } else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
6475
- }
6476
- return s;
6477
- }, this.#I = (e, i, s) => {
6478
- if (t[e] = i, this.#c) {
6479
- let n = this.#c - t[e];
6480
- for (; this.#b > n;) this.#P(!0);
6481
- }
6482
- this.#b += t[e], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
6483
- };
6484
- }
6485
- #C = (t) => {};
6486
- #I = (t, e, i) => {};
6487
- #N = (t, e, i, s) => {
6488
- if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
6489
- return 0;
6490
- };
6491
- *#A({ allowStale: t = this.allowStale } = {}) {
6492
- if (this.#n) for (let e = this.#h; this.#V(e) && ((t || !this.#p(e)) && (yield e), e !== this.#a);) e = this.#u[e];
6493
- }
6494
- *#z({ allowStale: t = this.allowStale } = {}) {
6495
- if (this.#n) for (let e = this.#a; this.#V(e) && ((t || !this.#p(e)) && (yield e), e !== this.#h);) e = this.#l[e];
6496
- }
6497
- #V(t) {
6498
- return t !== void 0 && this.#s.get(this.#i[t]) === t;
6499
- }
6500
- *entries() {
6501
- for (let t of this.#A()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
6502
- }
6503
- *rentries() {
6504
- for (let t of this.#z()) this.#t[t] !== void 0 && this.#i[t] !== void 0 && !this.#e(this.#t[t]) && (yield [this.#i[t], this.#t[t]]);
6505
- }
6506
- *keys() {
6507
- for (let t of this.#A()) {
6508
- let e = this.#i[t];
6509
- e !== void 0 && !this.#e(this.#t[t]) && (yield e);
6510
- }
6511
- }
6512
- *rkeys() {
6513
- for (let t of this.#z()) {
6514
- let e = this.#i[t];
6515
- e !== void 0 && !this.#e(this.#t[t]) && (yield e);
6516
- }
6517
- }
6518
- *values() {
6519
- for (let t of this.#A()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
6520
- }
6521
- *rvalues() {
6522
- for (let t of this.#z()) this.#t[t] !== void 0 && !this.#e(this.#t[t]) && (yield this.#t[t]);
6523
- }
6524
- [Symbol.iterator]() {
6525
- return this.entries();
6526
- }
6527
- [Symbol.toStringTag] = "LRUCache";
6528
- find(t, e = {}) {
6529
- for (let i of this.#A()) {
6530
- let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
6531
- if (n !== void 0 && t(n, this.#i[i], this)) return this.#L(this.#i[i], e);
6532
- }
6533
- }
6534
- forEach(t, e = this) {
6535
- for (let i of this.#A()) {
6536
- let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
6537
- n !== void 0 && t.call(e, n, this.#i[i], this);
6538
- }
6539
- }
6540
- rforEach(t, e = this) {
6541
- for (let i of this.#z()) {
6542
- let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
6543
- n !== void 0 && t.call(e, n, this.#i[i], this);
6544
- }
6545
- }
6546
- purgeStale() {
6547
- let t = !1;
6548
- for (let e of this.#z({ allowStale: !0 })) this.#p(e) && (this.#v(this.#i[e], "expire"), t = !0);
6549
- return t;
6550
- }
6551
- info(t) {
6552
- let e = this.#s.get(t);
6553
- if (e === void 0) return;
6554
- let i = this.#t[e], s = this.#e(i) ? i.__staleWhileFetching : i;
6555
- if (s === void 0) return;
6556
- let n = { value: s };
6557
- if (this.#d && this.#F) {
6558
- let o = this.#d[e], l = this.#F[e];
6559
- if (o && l) n.ttl = o - (this.#w.now() - l), n.start = Date.now();
6560
- }
6561
- return this.#y && (n.size = this.#y[e]), n;
6562
- }
6563
- dump() {
6564
- let t = [];
6565
- for (let e of this.#A({ allowStale: !0 })) {
6566
- let i = this.#i[e], s = this.#t[e], n = this.#e(s) ? s.__staleWhileFetching : s;
6567
- if (n === void 0 || i === void 0) continue;
6568
- let o = { value: n };
6569
- if (this.#d && this.#F) {
6570
- o.ttl = this.#d[e];
6571
- let l = this.#w.now() - this.#F[e];
6572
- o.start = Math.floor(Date.now() - l);
6573
- }
6574
- this.#y && (o.size = this.#y[e]), t.unshift([i, o]);
6575
- }
6576
- return t;
6577
- }
6578
- load(t) {
6579
- this.clear();
6580
- for (let [e, i] of t) {
6581
- if (i.start) {
6582
- let s = Date.now() - i.start;
6583
- i.start = this.#w.now() - s;
6584
- }
6585
- this.#O(e, i.value, i);
6586
- }
6587
- }
6588
- set(t, e, i = {}) {
6589
- let { status: s = g.metrics.hasSubscribers ? {} : void 0 } = i;
6590
- i.status = s, s && (s.op = "set", s.key = t, e !== void 0 && (s.value = e), s.cache = this);
6591
- let n = this.#O(t, e, i);
6592
- return s && g.metrics.hasSubscribers && g.metrics.publish(s), n;
6593
- }
6594
- #O(t, e, i, s) {
6595
- let { ttl: n = this.ttl, start: o, noDisposeOnSet: l = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: r } = i, c = this.#e(e);
6596
- if (e === void 0) return r && (r.set = "deleted"), this.delete(t), this;
6597
- let { noUpdateTTL: w = this.noUpdateTTL } = i;
6598
- r && !c && (r.value = e);
6599
- let y = this.#N(t, e, i.size || 0, h, r);
6600
- if (this.maxEntrySize && y > this.maxEntrySize) return this.#v(t, "set"), r && (r.set = "miss", r.maxEntrySizeExceeded = !0), this;
6601
- let d = this.#n === 0 ? void 0 : this.#s.get(t);
6602
- if (d === void 0) d = this.#n === 0 ? this.#h : this.#_.length !== 0 ? this.#_.pop() : this.#n === this.#o ? this.#P(!1) : this.#n, this.#i[d] = t, this.#t[d] = e, this.#s.set(t, d), this.#l[this.#h] = d, this.#u[d] = this.#h, this.#h = d, this.#n++, this.#I(d, y, r), r && (r.set = "add"), w = !1, this.#R && !c && this.#W?.(e, t, "add");
6603
- else {
6604
- this.#M(d);
6605
- let p = this.#t[d];
6606
- if (e !== p) {
6607
- if (!l) if (this.#e(p)) {
6608
- p !== s && p.__abortController.abort(/* @__PURE__ */ new Error("replaced"));
6609
- let { __staleWhileFetching: f } = p;
6610
- f !== void 0 && f !== e && (this.#T && this.#m?.(f, t, "set"), this.#f && this.#r?.push([
6611
- f,
6612
- t,
6613
- "set"
6614
- ]));
6615
- } else this.#T && this.#m?.(p, t, "set"), this.#f && this.#r?.push([
6616
- p,
6617
- t,
6618
- "set"
6619
- ]);
6620
- if (this.#C(d), this.#I(d, y, r), this.#t[d] = e, !c) {
6621
- let f = p && this.#e(p) ? p.__staleWhileFetching : p, _ = f === void 0 ? "add" : e !== f ? "replace" : "update";
6622
- r && (r.set = _, f !== void 0 && (r.oldValue = f)), this.#R && this.onInsert?.(e, t, _);
6623
- }
6624
- } else c || (r && (r.set = "update"), this.#R && this.onInsert?.(e, t, "update"));
6625
- }
6626
- if (n !== 0 && !this.#d && this.#k(), this.#d && (w || this.#H(d, n, o), r && this.#E(r, d)), !l && this.#f && this.#r) {
6627
- let p = this.#r, f;
6628
- for (; f = p?.shift();) this.#S?.(...f);
6629
- }
6630
- return this;
6631
- }
6632
- pop() {
6633
- try {
6634
- for (; this.#n;) {
6635
- let t = this.#t[this.#a];
6636
- if (this.#P(!0), this.#e(t)) {
6637
- if (t.__staleWhileFetching) return t.__staleWhileFetching;
6638
- } else if (t !== void 0) return t;
6639
- }
6640
- } finally {
6641
- if (this.#f && this.#r) {
6642
- let t = this.#r, e;
6643
- for (; e = t?.shift();) this.#S?.(...e);
6644
- }
6645
- }
6646
- }
6647
- #P(t) {
6648
- let e = this.#a, i = this.#i[e], s = this.#t[e], n = this.#e(s);
6649
- n && s.__abortController.abort(/* @__PURE__ */ new Error("evicted"));
6650
- let o = n ? s.__staleWhileFetching : s;
6651
- return (this.#T || this.#f) && o !== void 0 && (this.#T && this.#m?.(o, i, "evict"), this.#f && this.#r?.push([
6652
- o,
6653
- i,
6654
- "evict"
6655
- ])), this.#C(e), this.#g?.[e] && (clearTimeout(this.#g[e]), this.#g[e] = void 0), t && (this.#i[e] = void 0, this.#t[e] = void 0, this.#_.push(e)), this.#n === 1 ? (this.#a = this.#h = 0, this.#_.length = 0) : this.#a = this.#l[e], this.#s.delete(i), this.#n--, e;
6656
- }
6657
- has(t, e = {}) {
6658
- let { status: i = g.metrics.hasSubscribers ? {} : void 0 } = e;
6659
- e.status = i, i && (i.op = "has", i.key = t, i.cache = this);
6660
- let s = this.#Y(t, e);
6661
- return g.metrics.hasSubscribers && g.metrics.publish(i), s;
6662
- }
6663
- #Y(t, e = {}) {
6664
- let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = e, n = this.#s.get(t);
6665
- if (n !== void 0) {
6666
- let o = this.#t[n];
6667
- if (this.#e(o) && o.__staleWhileFetching === void 0) return !1;
6668
- if (this.#p(n)) s && (s.has = "stale", this.#E(s, n));
6669
- else return i && this.#D(n), s && (s.has = "hit", this.#E(s, n)), !0;
6670
- } else s && (s.has = "miss");
6671
- return !1;
6672
- }
6673
- peek(t, e = {}) {
6674
- let { status: i = C() ? {} : void 0 } = e;
6675
- i && (i.op = "peek", i.key = t, i.cache = this), e.status = i;
6676
- let s = this.#J(t, e);
6677
- return g.metrics.hasSubscribers && g.metrics.publish(i), s;
6678
- }
6679
- #J(t, e) {
6680
- let { status: i, allowStale: s = this.allowStale } = e, n = this.#s.get(t);
6681
- if (n === void 0 || !s && this.#p(n)) {
6682
- i && (i.peek = n === void 0 ? "miss" : "stale");
6683
- return;
6684
- }
6685
- let o = this.#t[n], l = this.#e(o) ? o.__staleWhileFetching : o;
6686
- return i && (l !== void 0 ? (i.peek = "hit", i.value = l) : i.peek = "miss"), l;
6687
- }
6688
- #G(t, e, i, s) {
6689
- let n = e === void 0 ? void 0 : this.#t[e];
6690
- if (this.#e(n)) return n;
6691
- let o = new AbortController(), { signal: l } = i;
6692
- l?.addEventListener("abort", () => o.abort(l.reason), { signal: o.signal });
6693
- let h = {
6694
- signal: o.signal,
6695
- options: i,
6696
- context: s
6697
- }, r = (f, _ = !1) => {
6698
- let { aborted: a } = o.signal, S = i.ignoreFetchAbort && f !== void 0, F = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && f !== void 0);
6699
- if (i.status && (a && !_ ? (i.status.fetchAborted = !0, i.status.fetchError = o.signal.reason, S && (i.status.fetchAbortIgnored = !0)) : i.status.fetchResolved = !0), a && !S && !_) return w(o.signal.reason, F);
6700
- let b = d, m = this.#t[e];
6701
- return (m === d || m === void 0 && S && _) && (f === void 0 ? b.__staleWhileFetching !== void 0 ? this.#t[e] = b.__staleWhileFetching : this.#v(t, "fetch") : (i.status && (i.status.fetchUpdated = !0), this.#O(t, f, h.options, b))), f;
6702
- }, c = (f) => (i.status && (i.status.fetchRejected = !0, i.status.fetchError = f), w(f, !1)), w = (f, _) => {
6703
- let { aborted: a } = o.signal, S = a && i.allowStaleOnFetchAbort, F = S || i.allowStaleOnFetchRejection, b = F || i.noDeleteOnFetchRejection, m = d;
6704
- if (this.#t[e] === d && (!b || !_ && m.__staleWhileFetching === void 0 ? this.#v(t, "fetch") : S || (this.#t[e] = m.__staleWhileFetching)), F) return i.status && m.__staleWhileFetching !== void 0 && (i.status.returnedStale = !0), m.__staleWhileFetching;
6705
- if (m.__returned === m) throw f;
6706
- }, y = (f, _) => {
6707
- let a = this.#x?.(t, n, h);
6708
- o.signal.addEventListener("abort", () => {
6709
- (!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (f(void 0), i.allowStaleOnFetchAbort && (f = (S) => r(S, !0)));
6710
- }), a && a instanceof Promise ? a.then((S) => f(S === void 0 ? void 0 : S), _) : a !== void 0 && f(a);
6711
- };
6712
- i.status && (i.status.fetchDispatched = !0);
6713
- let d = new Promise(y).then(r, c), p = Object.assign(d, {
6714
- __abortController: o,
6715
- __staleWhileFetching: n,
6716
- __returned: void 0
6717
- });
6718
- return e === void 0 ? (this.#O(t, p, {
6719
- ...h.options,
6720
- status: void 0
6721
- }), e = this.#s.get(t)) : this.#t[e] = p, p;
6722
- }
6723
- #e(t) {
6724
- if (!this.#U) return !1;
6725
- let e = t;
6726
- return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof AbortController;
6727
- }
6728
- fetch(t, e = {}) {
6729
- let i = g.tracing.hasSubscribers, { status: s = C() ? {} : void 0 } = e;
6730
- e.status = s, s && e.context && (s.context = e.context);
6731
- let n = this.#q(t, e);
6732
- return s && i && (s.trace = !0, g.tracing.tracePromise(() => n, s).catch(() => {})), n;
6733
- }
6734
- async #q(t, e = {}) {
6735
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: l = this.noDisposeOnSet, size: h = 0, sizeCalculation: r = this.sizeCalculation, noUpdateTTL: c = this.noUpdateTTL, noDeleteOnFetchRejection: w = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: y = this.allowStaleOnFetchRejection, ignoreFetchAbort: d = this.ignoreFetchAbort, allowStaleOnFetchAbort: p = this.allowStaleOnFetchAbort, context: f, forceRefresh: _ = !1, status: a, signal: S } = e;
6736
- if (a && (a.op = "fetch", a.key = t, _ && (a.forceRefresh = !0), a.cache = this), !this.#U) return a && (a.fetch = "get"), this.#L(t, {
6737
- allowStale: i,
6738
- updateAgeOnGet: s,
6739
- noDeleteOnStaleGet: n,
6740
- status: a
6741
- });
6742
- let F = {
6743
- allowStale: i,
6744
- updateAgeOnGet: s,
6745
- noDeleteOnStaleGet: n,
6746
- ttl: o,
6747
- noDisposeOnSet: l,
6748
- size: h,
6749
- sizeCalculation: r,
6750
- noUpdateTTL: c,
6751
- noDeleteOnFetchRejection: w,
6752
- allowStaleOnFetchRejection: y,
6753
- allowStaleOnFetchAbort: p,
6754
- ignoreFetchAbort: d,
6755
- status: a,
6756
- signal: S
6757
- }, b = this.#s.get(t);
6758
- if (b === void 0) {
6759
- a && (a.fetch = "miss");
6760
- let m = this.#G(t, b, F, f);
6761
- return m.__returned = m;
6762
- } else {
6763
- let m = this.#t[b];
6764
- if (this.#e(m)) {
6765
- let E = i && m.__staleWhileFetching !== void 0;
6766
- return a && (a.fetch = "inflight", E && (a.returnedStale = !0)), E ? m.__staleWhileFetching : m.__returned = m;
6767
- }
6768
- let A = this.#p(b);
6769
- if (!_ && !A) return a && (a.fetch = "hit"), this.#M(b), s && this.#D(b), a && this.#E(a, b), m;
6770
- let z = this.#G(t, b, F, f), v = z.__staleWhileFetching !== void 0 && i;
6771
- return a && (a.fetch = A ? "stale" : "refresh", v && A && (a.returnedStale = !0)), v ? z.__staleWhileFetching : z.__returned = z;
6772
- }
6773
- }
6774
- forceFetch(t, e = {}) {
6775
- let i = g.tracing.hasSubscribers, { status: s = C() ? {} : void 0 } = e;
6776
- e.status = s, s && e.context && (s.context = e.context);
6777
- let n = this.#K(t, e);
6778
- return s && i && (s.trace = !0, g.tracing.tracePromise(() => n, s).catch(() => {})), n;
6779
- }
6780
- async #K(t, e = {}) {
6781
- let i = await this.#q(t, e);
6782
- if (i === void 0) throw new Error("fetch() returned undefined");
6783
- return i;
6784
- }
6785
- memo(t, e = {}) {
6786
- let { status: i = g.metrics.hasSubscribers ? {} : void 0 } = e;
6787
- e.status = i, i && (i.op = "memo", i.key = t, e.context && (i.context = e.context), i.cache = this);
6788
- let s = this.#Q(t, e);
6789
- return i && (i.value = s), g.metrics.hasSubscribers && g.metrics.publish(i), s;
6790
- }
6791
- #Q(t, e = {}) {
6792
- let i = this.#j;
6793
- if (!i) throw new Error("no memoMethod provided to constructor");
6794
- let { context: s, status: n, forceRefresh: o, ...l } = e;
6795
- n && o && (n.forceRefresh = !0);
6796
- let h = this.#L(t, l), r = o || h === void 0;
6797
- if (n && (n.memo = r ? "miss" : "hit", r || (n.value = h)), !r) return h;
6798
- let c = i(t, h, {
6799
- options: l,
6800
- context: s
6801
- });
6802
- return n && (n.value = c), this.#O(t, c, l), c;
6803
- }
6804
- get(t, e = {}) {
6805
- let { status: i = g.metrics.hasSubscribers ? {} : void 0 } = e;
6806
- e.status = i, i && (i.op = "get", i.key = t, i.cache = this);
6807
- let s = this.#L(t, e);
6808
- return i && (s !== void 0 && (i.value = s), g.metrics.hasSubscribers && g.metrics.publish(i)), s;
6809
- }
6810
- #L(t, e = {}) {
6811
- let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = e, l = this.#s.get(t);
6812
- if (l === void 0) {
6813
- o && (o.get = "miss");
6814
- return;
6815
- }
6816
- let h = this.#t[l], r = this.#e(h);
6817
- return o && this.#E(o, l), this.#p(l) ? r ? (o && (o.get = "stale-fetching"), i && h.__staleWhileFetching !== void 0 ? (o && (o.returnedStale = !0), h.__staleWhileFetching) : void 0) : (n || this.#v(t, "expire"), o && (o.get = "stale"), i ? (o && (o.returnedStale = !0), h) : void 0) : (o && (o.get = r ? "fetching" : "hit"), this.#M(l), s && this.#D(l), r ? h.__staleWhileFetching : h);
6818
- }
6819
- #B(t, e) {
6820
- this.#u[e] = t, this.#l[t] = e;
6821
- }
6822
- #M(t) {
6823
- t !== this.#h && (t === this.#a ? this.#a = this.#l[t] : this.#B(this.#u[t], this.#l[t]), this.#B(this.#h, t), this.#h = t);
6824
- }
6825
- delete(t) {
6826
- return this.#v(t, "delete");
6827
- }
6828
- #v(t, e) {
6829
- g.metrics.hasSubscribers && g.metrics.publish({
6830
- op: "delete",
6831
- delete: e,
6832
- key: t,
6833
- cache: this
6834
- });
6835
- let i = !1;
6836
- if (this.#n !== 0) {
6837
- let s = this.#s.get(t);
6838
- if (s !== void 0) if (this.#g?.[s] && (clearTimeout(this.#g[s]), this.#g[s] = void 0), i = !0, this.#n === 1) this.#$(e);
6839
- else {
6840
- this.#C(s);
6841
- let n = this.#t[s];
6842
- if (this.#e(n) ? n.__abortController.abort(/* @__PURE__ */ new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#m?.(n, t, e), this.#f && this.#r?.push([
6843
- n,
6844
- t,
6845
- e
6846
- ])), this.#s.delete(t), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#u[s];
6847
- else if (s === this.#a) this.#a = this.#l[s];
6848
- else {
6849
- let o = this.#u[s];
6850
- this.#l[o] = this.#l[s];
6851
- let l = this.#l[s];
6852
- this.#u[l] = this.#u[s];
6853
- }
6854
- this.#n--, this.#_.push(s);
6855
- }
6856
- }
6857
- if (this.#f && this.#r?.length) {
6858
- let s = this.#r, n;
6859
- for (; n = s?.shift();) this.#S?.(...n);
6860
- }
6861
- return i;
6862
- }
6863
- clear() {
6864
- return this.#$("delete");
6865
- }
6866
- #$(t) {
6867
- for (let e of this.#z({ allowStale: !0 })) {
6868
- let i = this.#t[e];
6869
- if (this.#e(i)) i.__abortController.abort(/* @__PURE__ */ new Error("deleted"));
6870
- else {
6871
- let s = this.#i[e];
6872
- this.#T && this.#m?.(i, s, t), this.#f && this.#r?.push([
6873
- i,
6874
- s,
6875
- t
6876
- ]);
6877
- }
6878
- }
6879
- if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#F) {
6880
- this.#d.fill(0), this.#F.fill(0);
6881
- for (let e of this.#g ?? []) e !== void 0 && clearTimeout(e);
6882
- this.#g?.fill(void 0);
6883
- }
6884
- if (this.#y && this.#y.fill(0), this.#a = 0, this.#h = 0, this.#_.length = 0, this.#b = 0, this.#n = 0, this.#f && this.#r) {
6885
- let e = this.#r, i;
6886
- for (; i = e?.shift();) this.#S?.(...i);
6887
- }
6888
- }
6889
- };
6890
- }));
6891
- //#endregion
6892
- //#region ../../node_modules/.pnpm/hosted-git-info@10.1.1/node_modules/hosted-git-info/lib/hosts.js
6893
- var require_hosts = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6894
- const maybeJoin = (...args) => args.every((arg) => arg) ? args.join("") : "";
6895
- const maybeEncode = (arg) => arg ? encodeURIComponent(arg) : "";
6896
- const formatHashFragment = (f) => f.toLowerCase().replace(/^\W+/g, "").replace(/(?<!\W)\W+$/, "").replace(/\//g, "").replace(/\W+/g, "-");
6897
- const defaults = {
6898
- sshtemplate: ({ domain, user, project, committish }) => `git@${domain}:${user}/${project}.git${maybeJoin("#", committish)}`,
6899
- sshurltemplate: ({ domain, user, project, committish }) => `git+ssh://git@${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
6900
- edittemplate: ({ domain, user, project, committish, editpath, path }) => `https://${domain}/${user}/${project}${maybeJoin("/", editpath, "/", maybeEncode(committish || "HEAD"), "/", path)}`,
6901
- browsetemplate: ({ domain, user, project, committish, treepath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish))}`,
6902
- browsetreetemplate: ({ domain, user, project, committish, treepath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${treepath}/${maybeEncode(committish || "HEAD")}/${path}${maybeJoin("#", hashformat(fragment || ""))}`,
6903
- browseblobtemplate: ({ domain, user, project, committish, blobpath, path, fragment, hashformat }) => `https://${domain}/${user}/${project}/${blobpath}/${maybeEncode(committish || "HEAD")}/${path}${maybeJoin("#", hashformat(fragment || ""))}`,
6904
- docstemplate: ({ domain, user, project, treepath, committish }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish))}#readme`,
6905
- httpstemplate: ({ auth, domain, user, project, committish }) => `git+https://${maybeJoin(auth, "@")}${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
6906
- filetemplate: ({ domain, user, project, committish, path }) => `https://${domain}/${user}/${project}/raw/${maybeEncode(committish || "HEAD")}/${path}`,
6907
- shortcuttemplate: ({ type, user, project, committish }) => `${type}:${user}/${project}${maybeJoin("#", committish)}`,
6908
- pathtemplate: ({ user, project, committish }) => `${user}/${project}${maybeJoin("#", committish)}`,
6909
- bugstemplate: ({ domain, user, project }) => `https://${domain}/${user}/${project}/issues`,
6910
- hashformat: formatHashFragment
6911
- };
6912
- const hosts = {};
6913
- hosts.github = {
6914
- protocols: [
6915
- "git:",
6916
- "http:",
6917
- "git+ssh:",
6918
- "git+https:",
6919
- "ssh:",
6920
- "https:"
6921
- ],
6922
- domain: "github.com",
6923
- treepath: "tree",
6924
- blobpath: "blob",
6925
- editpath: "edit",
6926
- filetemplate: ({ auth, user, project, committish, path }) => `https://${maybeJoin(auth, "@")}raw.githubusercontent.com/${user}/${project}/${maybeEncode(committish || "HEAD")}/${path}`,
6927
- gittemplate: ({ auth, domain, user, project, committish }) => `git://${maybeJoin(auth, "@")}${domain}/${user}/${project}.git${maybeJoin("#", committish)}`,
6928
- tarballtemplate: ({ domain, user, project, committish }) => `https://codeload.${domain}/${user}/${project}/tar.gz/${maybeEncode(committish || "HEAD")}`,
6929
- extract: (url) => {
6930
- let [, user, project, type, committish] = url.pathname.split("/", 5);
6931
- if (type && type !== "tree") return;
6932
- if (!type) committish = url.hash.slice(1);
6933
- if (project && project.endsWith(".git")) project = project.slice(0, -4);
6934
- if (!user || !project) return;
6935
- return {
6936
- user,
6937
- project,
6938
- committish
6939
- };
6940
- }
6941
- };
6942
- hosts.bitbucket = {
6943
- protocols: [
6944
- "git+ssh:",
6945
- "git+https:",
6946
- "ssh:",
6947
- "https:"
6948
- ],
6949
- domain: "bitbucket.org",
6950
- treepath: "src",
6951
- blobpath: "src",
6952
- editpath: "?mode=edit",
6953
- edittemplate: ({ domain, user, project, committish, treepath, path, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", treepath, "/", maybeEncode(committish || "HEAD"), "/", path, editpath)}`,
6954
- tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/get/${maybeEncode(committish || "HEAD")}.tar.gz`,
6955
- extract: (url) => {
6956
- let [, user, project, aux] = url.pathname.split("/", 4);
6957
- if (["get"].includes(aux)) return;
6958
- if (project && project.endsWith(".git")) project = project.slice(0, -4);
6959
- if (!user || !project) return;
6960
- return {
6961
- user,
6962
- project,
6963
- committish: url.hash.slice(1)
6964
- };
6965
- }
6966
- };
6967
- hosts.gitlab = {
6968
- protocols: [
6969
- "git+ssh:",
6970
- "git+https:",
6971
- "ssh:",
6972
- "https:"
6973
- ],
6974
- domain: "gitlab.com",
6975
- treepath: "tree",
6976
- blobpath: "tree",
6977
- editpath: "-/edit",
6978
- tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/api/v4/projects/${maybeEncode(user + "/" + project)}/repository/archive.tar.gz?sha=${maybeEncode(committish || "HEAD")}`,
6979
- extract: (url) => {
6980
- const path = url.pathname.slice(1);
6981
- if (path.includes("/-/") || path.includes("/archive.tar.gz")) return;
6982
- const segments = path.split("/");
6983
- let project = segments.pop();
6984
- if (project.endsWith(".git")) project = project.slice(0, -4);
6985
- const user = segments.join("/");
6986
- if (!user || !project) return;
6987
- return {
6988
- user,
6989
- project,
6990
- committish: url.hash.slice(1)
6991
- };
6992
- }
6993
- };
6994
- hosts.gist = {
6995
- protocols: [
6996
- "git:",
6997
- "git+ssh:",
6998
- "git+https:",
6999
- "ssh:",
7000
- "https:"
7001
- ],
7002
- domain: "gist.github.com",
7003
- editpath: "edit",
7004
- sshtemplate: ({ domain, project, committish }) => `git@${domain}:${project}.git${maybeJoin("#", committish)}`,
7005
- sshurltemplate: ({ domain, project, committish }) => `git+ssh://git@${domain}/${project}.git${maybeJoin("#", committish)}`,
7006
- edittemplate: ({ domain, user, project, committish, editpath }) => `https://${domain}/${user}/${project}${maybeJoin("/", maybeEncode(committish))}/${editpath}`,
7007
- browsetemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}`,
7008
- browsetreetemplate: ({ domain, project, committish, path, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path))}`,
7009
- browseblobtemplate: ({ domain, project, committish, path, hashformat }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}${maybeJoin("#", hashformat(path))}`,
7010
- docstemplate: ({ domain, project, committish }) => `https://${domain}/${project}${maybeJoin("/", maybeEncode(committish))}`,
7011
- httpstemplate: ({ domain, project, committish }) => `git+https://${domain}/${project}.git${maybeJoin("#", committish)}`,
7012
- filetemplate: ({ user, project, committish, path }) => `https://gist.githubusercontent.com/${user}/${project}/raw${maybeJoin("/", maybeEncode(committish))}/${path}`,
7013
- shortcuttemplate: ({ type, project, committish }) => `${type}:${project}${maybeJoin("#", committish)}`,
7014
- pathtemplate: ({ project, committish }) => `${project}${maybeJoin("#", committish)}`,
7015
- bugstemplate: ({ domain, project }) => `https://${domain}/${project}`,
7016
- gittemplate: ({ domain, project, committish }) => `git://${domain}/${project}.git${maybeJoin("#", committish)}`,
7017
- tarballtemplate: ({ project, committish }) => `https://codeload.github.com/gist/${project}/tar.gz/${maybeEncode(committish || "HEAD")}`,
7018
- extract: (url) => {
7019
- let [, user, project, aux] = url.pathname.split("/", 4);
7020
- if (aux === "raw") return;
7021
- if (!project) {
7022
- if (!user) return;
7023
- project = user;
7024
- user = null;
7025
- }
7026
- if (project.endsWith(".git")) project = project.slice(0, -4);
7027
- return {
7028
- user,
7029
- project,
7030
- committish: url.hash.slice(1)
7031
- };
7032
- },
7033
- hashformat: function(fragment) {
7034
- return fragment && "file-" + formatHashFragment(fragment);
7035
- }
7036
- };
7037
- hosts.sourcehut = {
7038
- protocols: ["git+ssh:", "https:"],
7039
- domain: "git.sr.ht",
7040
- treepath: "tree",
7041
- blobpath: "tree",
7042
- filetemplate: ({ domain, user, project, committish, path }) => `https://${domain}/${user}/${project}/blob/${maybeEncode(committish) || "HEAD"}/${path}`,
7043
- httpstemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}${maybeJoin("#", committish)}`,
7044
- tarballtemplate: ({ domain, user, project, committish }) => `https://${domain}/${user}/${project}/archive/${maybeEncode(committish) || "HEAD"}.tar.gz`,
7045
- bugstemplate: () => null,
7046
- extract: (url) => {
7047
- let [, user, project, aux] = url.pathname.split("/", 4);
7048
- if (["archive"].includes(aux)) return;
7049
- if (project && project.endsWith(".git")) project = project.slice(0, -4);
7050
- if (!user || !project) return;
7051
- return {
7052
- user,
7053
- project,
7054
- committish: url.hash.slice(1)
7055
- };
7056
- }
7057
- };
7058
- for (const [name, host] of Object.entries(hosts)) hosts[name] = Object.assign({}, defaults, host);
7059
- module.exports = hosts;
7060
- }));
7061
- //#endregion
7062
- //#region ../../node_modules/.pnpm/hosted-git-info@10.1.1/node_modules/hosted-git-info/lib/parse-url.js
7063
- var require_parse_url = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7064
- const lastIndexOfBefore = (str, char, beforeChar) => {
7065
- const startPosition = str.indexOf(beforeChar);
7066
- return str.lastIndexOf(char, startPosition > -1 ? startPosition : Infinity);
7067
- };
7068
- const safeUrl = (u) => {
7069
- try {
7070
- return new URL(u);
7071
- } catch {}
7072
- };
7073
- const correctProtocol = (arg, protocols) => {
7074
- const firstColon = arg.indexOf(":");
7075
- const proto = arg.slice(0, firstColon + 1);
7076
- if (Object.prototype.hasOwnProperty.call(protocols, proto)) return arg;
7077
- if (arg.substr(firstColon, 3) === "://") return arg;
7078
- const firstAt = arg.indexOf("@");
7079
- if (firstAt > -1) {
7080
- if (firstAt > firstColon) return `git+ssh://${arg}`;
7081
- else return arg;
7082
- }
7083
- return `${arg.slice(0, firstColon + 1)}//${arg.slice(firstColon + 1)}`;
7084
- };
7085
- const correctUrl = (giturl) => {
7086
- const firstAt = lastIndexOfBefore(giturl, "@", "#");
7087
- const lastColonBeforeHash = lastIndexOfBefore(giturl, ":", "#");
7088
- if (lastColonBeforeHash > firstAt) giturl = giturl.slice(0, lastColonBeforeHash) + "/" + giturl.slice(lastColonBeforeHash + 1);
7089
- if (lastIndexOfBefore(giturl, ":", "#") === -1 && giturl.indexOf("//") === -1) giturl = `git+ssh://${giturl}`;
7090
- return giturl;
7091
- };
7092
- module.exports = (giturl, protocols) => {
7093
- const withProtocol = protocols ? correctProtocol(giturl, protocols) : giturl;
7094
- return safeUrl(withProtocol) || safeUrl(correctUrl(withProtocol));
7095
- };
7096
- }));
7097
- //#endregion
7098
- //#region ../../node_modules/.pnpm/hosted-git-info@10.1.1/node_modules/hosted-git-info/lib/from-url.js
7099
- var require_from_url = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7100
- const parseUrl = require_parse_url();
7101
- const isGitHubShorthand = (arg) => {
7102
- const firstHash = arg.indexOf("#");
7103
- const firstSlash = arg.indexOf("/");
7104
- const secondSlash = arg.indexOf("/", firstSlash + 1);
7105
- const firstColon = arg.indexOf(":");
7106
- const firstSpace = /\s/.exec(arg);
7107
- const firstAt = arg.indexOf("@");
7108
- const spaceOnlyAfterHash = !firstSpace || firstHash > -1 && firstSpace.index > firstHash;
7109
- const atOnlyAfterHash = firstAt === -1 || firstHash > -1 && firstAt > firstHash;
7110
- const colonOnlyAfterHash = firstColon === -1 || firstHash > -1 && firstColon > firstHash;
7111
- const secondSlashOnlyAfterHash = secondSlash === -1 || firstHash > -1 && secondSlash > firstHash;
7112
- const hasSlash = firstSlash > 0;
7113
- const doesNotEndWithSlash = firstHash > -1 ? arg[firstHash - 1] !== "/" : !arg.endsWith("/");
7114
- const doesNotStartWithDot = !arg.startsWith(".");
7115
- return spaceOnlyAfterHash && hasSlash && doesNotEndWithSlash && doesNotStartWithDot && atOnlyAfterHash && colonOnlyAfterHash && secondSlashOnlyAfterHash;
7116
- };
7117
- module.exports = (giturl, opts, { gitHosts, protocols }) => {
7118
- if (!giturl) return;
7119
- const correctedUrl = isGitHubShorthand(giturl) ? `github:${giturl}` : giturl;
7120
- const parsed = parseUrl(correctedUrl, protocols);
7121
- if (!parsed) return;
7122
- const gitHostShortcut = gitHosts.byShortcut[parsed.protocol];
7123
- const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith("www.") ? parsed.hostname.slice(4) : parsed.hostname];
7124
- const gitHostName = gitHostShortcut || gitHostDomain;
7125
- if (!gitHostName) return;
7126
- const gitHostInfo = gitHosts[gitHostShortcut || gitHostDomain];
7127
- let auth = null;
7128
- if (protocols[parsed.protocol]?.auth && (parsed.username || parsed.password)) auth = `${parsed.username}${parsed.password ? ":" + parsed.password : ""}`;
7129
- let committish = null;
7130
- let user = null;
7131
- let project = null;
7132
- let defaultRepresentation = null;
7133
- try {
7134
- if (gitHostShortcut) {
7135
- let pathname = parsed.pathname.startsWith("/") ? parsed.pathname.slice(1) : parsed.pathname;
7136
- const firstAt = pathname.indexOf("@");
7137
- if (firstAt > -1) pathname = pathname.slice(firstAt + 1);
7138
- const lastSlash = pathname.lastIndexOf("/");
7139
- if (lastSlash > -1) {
7140
- user = decodeURIComponent(pathname.slice(0, lastSlash));
7141
- if (!user) user = null;
7142
- project = decodeURIComponent(pathname.slice(lastSlash + 1));
7143
- } else project = decodeURIComponent(pathname);
7144
- if (project.endsWith(".git")) project = project.slice(0, -4);
7145
- if (parsed.hash) committish = decodeURIComponent(parsed.hash.slice(1));
7146
- defaultRepresentation = "shortcut";
7147
- } else {
7148
- if (!gitHostInfo.protocols.includes(parsed.protocol)) return;
7149
- const segments = gitHostInfo.extract(parsed);
7150
- if (!segments) return;
7151
- user = segments.user && decodeURIComponent(segments.user);
7152
- project = decodeURIComponent(segments.project);
7153
- committish = decodeURIComponent(segments.committish);
7154
- defaultRepresentation = protocols[parsed.protocol]?.name || parsed.protocol.slice(0, -1);
7155
- }
7156
- } catch (err) {
7157
- /* istanbul ignore else */
7158
- if (err instanceof URIError) return;
7159
- else throw err;
7160
- }
7161
- return [
7162
- gitHostName,
7163
- user,
7164
- auth,
7165
- project,
7166
- committish,
7167
- defaultRepresentation,
7168
- opts
7169
- ];
7170
- };
7171
- }));
7172
- //#endregion
7173
- //#region ../../node_modules/.pnpm/hosted-git-info@10.1.1/node_modules/hosted-git-info/lib/index.js
7174
- var require_lib$2 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7175
- const { LRUCache } = require_index_min();
7176
- const hosts = require_hosts();
7177
- const fromUrl = require_from_url();
7178
- const parseUrl = require_parse_url();
7179
- const cache = new LRUCache({ max: 1e3 });
7180
- function unknownHostedUrl(url) {
7181
- try {
7182
- const { protocol, hostname, pathname } = new URL(url);
7183
- if (!hostname) return null;
7184
- return `${/(?:git\+)http:$/.test(protocol) ? "http:" : "https:"}//${hostname}${pathname.replace(/\.git$/, "")}`;
7185
- } catch {
7186
- return null;
7187
- }
7188
- }
7189
- var GitHost = class GitHost {
7190
- constructor(type, user, auth, project, committish, defaultRepresentation, opts = {}) {
7191
- Object.assign(this, GitHost.#gitHosts[type], {
7192
- type,
7193
- user,
7194
- auth,
7195
- project,
7196
- committish,
7197
- default: defaultRepresentation,
7198
- opts
7199
- });
7200
- }
7201
- static #gitHosts = {
7202
- byShortcut: {},
7203
- byDomain: {}
7204
- };
7205
- static #protocols = {
7206
- "git+ssh:": { name: "sshurl" },
7207
- "ssh:": { name: "sshurl" },
7208
- "git+https:": {
7209
- name: "https",
7210
- auth: true
7211
- },
7212
- "git:": { auth: true },
7213
- "http:": { auth: true },
7214
- "https:": { auth: true },
7215
- "git+http:": { auth: true }
7216
- };
7217
- static addHost(name, host) {
7218
- GitHost.#gitHosts[name] = host;
7219
- GitHost.#gitHosts.byDomain[host.domain] = name;
7220
- GitHost.#gitHosts.byShortcut[`${name}:`] = name;
7221
- GitHost.#protocols[`${name}:`] = { name };
7222
- }
7223
- static fromUrl(giturl, opts) {
7224
- if (typeof giturl !== "string") return;
7225
- const key = giturl + JSON.stringify(opts || {});
7226
- if (!cache.has(key)) {
7227
- const hostArgs = fromUrl(giturl, opts, {
7228
- gitHosts: GitHost.#gitHosts,
7229
- protocols: GitHost.#protocols
7230
- });
7231
- cache.set(key, hostArgs ? new GitHost(...hostArgs) : void 0);
7232
- }
7233
- return cache.get(key);
7234
- }
7235
- static fromManifest(manifest, opts = {}) {
7236
- if (!manifest || typeof manifest !== "object") return;
7237
- const r = manifest.repository;
7238
- const rurl = r && (typeof r === "string" ? r : typeof r === "object" && typeof r.url === "string" ? r.url : null);
7239
- if (!rurl) throw new Error("no repository");
7240
- const info = rurl && GitHost.fromUrl(rurl.replace(/^git\+/, ""), opts) || null;
7241
- if (info) return info;
7242
- const unk = unknownHostedUrl(rurl);
7243
- return GitHost.fromUrl(unk, opts) || unk;
7244
- }
7245
- static parseUrl(url) {
7246
- return parseUrl(url);
7247
- }
7248
- #fill(template, opts) {
7249
- if (typeof template !== "function") return null;
7250
- const options = {
7251
- ...this,
7252
- ...this.opts,
7253
- ...opts
7254
- };
7255
- if (!options.path) options.path = "";
7256
- if (options.path.startsWith("/")) options.path = options.path.slice(1);
7257
- if (options.noCommittish) options.committish = null;
7258
- const result = template(options);
7259
- return options.noGitPlus && result.startsWith("git+") ? result.slice(4) : result;
7260
- }
7261
- hash() {
7262
- return this.committish ? `#${this.committish}` : "";
7263
- }
7264
- ssh(opts) {
7265
- return this.#fill(this.sshtemplate, opts);
7266
- }
7267
- sshurl(opts) {
7268
- return this.#fill(this.sshurltemplate, opts);
7269
- }
7270
- browse(path, ...args) {
7271
- if (typeof path !== "string") return this.#fill(this.browsetemplate, path);
7272
- if (typeof args[0] !== "string") return this.#fill(this.browsetreetemplate, {
7273
- ...args[0],
7274
- path
7275
- });
7276
- return this.#fill(this.browsetreetemplate, {
7277
- ...args[1],
7278
- fragment: args[0],
7279
- path
7280
- });
7281
- }
7282
- browseFile(path, ...args) {
7283
- if (typeof args[0] !== "string") return this.#fill(this.browseblobtemplate, {
7284
- ...args[0],
7285
- path
7286
- });
7287
- return this.#fill(this.browseblobtemplate, {
7288
- ...args[1],
7289
- fragment: args[0],
7290
- path
7291
- });
7292
- }
7293
- docs(opts) {
7294
- return this.#fill(this.docstemplate, opts);
7295
- }
7296
- bugs(opts) {
7297
- return this.#fill(this.bugstemplate, opts);
7298
- }
7299
- https(opts) {
7300
- return this.#fill(this.httpstemplate, opts);
7301
- }
7302
- git(opts) {
7303
- return this.#fill(this.gittemplate, opts);
7304
- }
7305
- shortcut(opts) {
7306
- return this.#fill(this.shortcuttemplate, opts);
7307
- }
7308
- path(opts) {
7309
- return this.#fill(this.pathtemplate, opts);
7310
- }
7311
- tarball(opts) {
7312
- return this.#fill(this.tarballtemplate, {
7313
- ...opts,
7314
- noCommittish: false
7315
- });
7316
- }
7317
- file(path, opts) {
7318
- return this.#fill(this.filetemplate, {
7319
- ...opts,
7320
- path
7321
- });
7322
- }
7323
- edit(path, opts) {
7324
- return this.#fill(this.edittemplate, {
7325
- ...opts,
7326
- path
7327
- });
7328
- }
7329
- getDefaultRepresentation() {
7330
- return this.default;
7331
- }
7332
- toString(opts) {
7333
- if (this.default && typeof this[this.default] === "function") return this[this.default](opts);
7334
- return this.sshurl(opts);
7335
- }
7336
- };
7337
- for (const [name, host] of Object.entries(hosts)) GitHost.addHost(name, host);
7338
- module.exports = GitHost;
7339
- }));
7340
- //#endregion
7341
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/constants.js
7342
- var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7343
- module.exports = {
7344
- MAX_LENGTH: 256,
7345
- MAX_SAFE_COMPONENT_LENGTH: 16,
7346
- MAX_SAFE_BUILD_LENGTH: 250,
7347
- MAX_SAFE_INTEGER: Number.MAX_SAFE_INTEGER ||
7348
- /* istanbul ignore next */ 9007199254740991,
7349
- RELEASE_TYPES: [
7350
- "major",
7351
- "premajor",
7352
- "minor",
7353
- "preminor",
7354
- "patch",
7355
- "prepatch",
7356
- "prerelease"
7357
- ],
7358
- SEMVER_SPEC_VERSION: "2.0.0",
7359
- FLAG_INCLUDE_PRERELEASE: 1,
7360
- FLAG_LOOSE: 2
7361
- };
7362
- }));
7363
- //#endregion
7364
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/debug.js
7365
- var require_debug = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7366
- module.exports = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {};
7367
- }));
7368
- //#endregion
7369
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/re.js
7370
- var require_re = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7371
- const { MAX_SAFE_COMPONENT_LENGTH, MAX_SAFE_BUILD_LENGTH, MAX_LENGTH } = require_constants();
7372
- const debug = require_debug();
7373
- exports = module.exports = {};
7374
- const re = exports.re = [];
7375
- const safeRe = exports.safeRe = [];
7376
- const src = exports.src = [];
7377
- const safeSrc = exports.safeSrc = [];
7378
- const t = exports.t = {};
7379
- let R = 0;
7380
- const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
7381
- const safeRegexReplacements = [
7382
- ["\\s", 1],
7383
- ["\\d", MAX_LENGTH],
7384
- [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
7385
- ];
7386
- const makeSafeRegex = (value) => {
7387
- for (const [token, max] of safeRegexReplacements) value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
7388
- return value;
7389
- };
7390
- const createToken = (name, value, isGlobal) => {
7391
- const safe = makeSafeRegex(value);
7392
- const index = R++;
7393
- debug(name, index, value);
7394
- t[name] = index;
7395
- src[index] = value;
7396
- safeSrc[index] = safe;
7397
- re[index] = new RegExp(value, isGlobal ? "g" : void 0);
7398
- safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
7399
- };
7400
- createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
7401
- createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
7402
- createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
7403
- createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
7404
- createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
7405
- createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
7406
- createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
7407
- createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
7408
- createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
7409
- createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
7410
- createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
7411
- createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
7412
- createToken("FULL", `^${src[t.FULLPLAIN]}$`);
7413
- createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
7414
- createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
7415
- createToken("GTLT", "((?:<|>)?=?)");
7416
- createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
7417
- createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
7418
- createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
7419
- createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
7420
- createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
7421
- createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
7422
- createToken("COERCEPLAIN", `(^|[^\\d])(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
7423
- createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
7424
- createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
7425
- createToken("COERCERTL", src[t.COERCE], true);
7426
- createToken("COERCERTLFULL", src[t.COERCEFULL], true);
7427
- createToken("LONETILDE", "(?:~>?)");
7428
- createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
7429
- exports.tildeTrimReplace = "$1~";
7430
- createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
7431
- createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
7432
- createToken("LONECARET", "(?:\\^)");
7433
- createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
7434
- exports.caretTrimReplace = "$1^";
7435
- createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
7436
- createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
7437
- createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
7438
- createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
7439
- createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
7440
- exports.comparatorTrimReplace = "$1$2$3";
7441
- createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
7442
- createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
7443
- createToken("STAR", "(<|>)?=?\\s*\\*");
7444
- createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
7445
- createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
7446
- }));
7447
- //#endregion
7448
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/parse-options.js
7449
- var require_parse_options = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7450
- const looseOption = Object.freeze({ loose: true });
7451
- const emptyOpts = Object.freeze({});
7452
- const parseOptions = (options) => {
7453
- if (!options) return emptyOpts;
7454
- if (typeof options !== "object") return looseOption;
7455
- return options;
7456
- };
7457
- module.exports = parseOptions;
7458
- }));
7459
- //#endregion
7460
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/identifiers.js
7461
- var require_identifiers = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7462
- const numeric = /^[0-9]+$/;
7463
- const compareIdentifiers = (a, b) => {
7464
- if (typeof a === "number" && typeof b === "number") return a === b ? 0 : a < b ? -1 : 1;
7465
- const anum = numeric.test(a);
7466
- const bnum = numeric.test(b);
7467
- if (anum && bnum) {
7468
- a = +a;
7469
- b = +b;
7470
- }
7471
- return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
7472
- };
7473
- const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
7474
- module.exports = {
7475
- compareIdentifiers,
7476
- rcompareIdentifiers
7477
- };
7478
- }));
7479
- //#endregion
7480
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/semver.js
7481
- var require_semver$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7482
- const debug = require_debug();
7483
- const { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
7484
- const { safeRe: re, t } = require_re();
7485
- const parseOptions = require_parse_options();
7486
- const { compareIdentifiers } = require_identifiers();
7487
- const isPrereleaseIdentifier = (prerelease, identifier) => {
7488
- const identifiers = identifier.split(".");
7489
- if (identifiers.length > prerelease.length) return false;
7490
- for (let i = 0; i < identifiers.length; i++) if (compareIdentifiers(prerelease[i], identifiers[i]) !== 0) return false;
7491
- return true;
7492
- };
7493
- module.exports = class SemVer {
7494
- constructor(version, options) {
7495
- options = parseOptions(options);
7496
- if (version instanceof SemVer) {
7497
- if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) return version;
7498
- else version = version.version;
7499
- } else if (typeof version !== "string") throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
7500
- if (version.length > MAX_LENGTH) throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
7501
- debug("SemVer", version, options);
7502
- this.options = options;
7503
- this.loose = !!options.loose;
7504
- this.includePrerelease = !!options.includePrerelease;
7505
- const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
7506
- if (!m) throw new TypeError(`Invalid Version: ${version}`);
7507
- this.raw = version;
7508
- this.major = +m[1];
7509
- this.minor = +m[2];
7510
- this.patch = +m[3];
7511
- if (this.major > MAX_SAFE_INTEGER || this.major < 0) throw new TypeError("Invalid major version");
7512
- if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) throw new TypeError("Invalid minor version");
7513
- if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) throw new TypeError("Invalid patch version");
7514
- if (!m[4]) this.prerelease = [];
7515
- else this.prerelease = m[4].split(".").map((id) => {
7516
- if (/^[0-9]+$/.test(id)) {
7517
- const num = +id;
7518
- if (num >= 0 && num < MAX_SAFE_INTEGER) return num;
7519
- }
7520
- return id;
7521
- });
7522
- this.build = m[5] ? m[5].split(".") : [];
7523
- this.format();
7524
- }
7525
- format() {
7526
- this.version = `${this.major}.${this.minor}.${this.patch}`;
7527
- if (this.prerelease.length) this.version += `-${this.prerelease.join(".")}`;
7528
- return this.version;
7529
- }
7530
- toString() {
7531
- return this.version;
7532
- }
7533
- compare(other) {
7534
- debug("SemVer.compare", this.version, this.options, other);
7535
- if (!(other instanceof SemVer)) {
7536
- if (typeof other === "string" && other === this.version) return 0;
7537
- other = new SemVer(other, this.options);
7538
- }
7539
- if (other.version === this.version) return 0;
7540
- return this.compareMain(other) || this.comparePre(other);
7541
- }
7542
- compareMain(other) {
7543
- if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
7544
- if (this.major < other.major) return -1;
7545
- if (this.major > other.major) return 1;
7546
- if (this.minor < other.minor) return -1;
7547
- if (this.minor > other.minor) return 1;
7548
- if (this.patch < other.patch) return -1;
7549
- if (this.patch > other.patch) return 1;
7550
- return 0;
7551
- }
7552
- comparePre(other) {
7553
- if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
7554
- if (this.prerelease.length && !other.prerelease.length) return -1;
7555
- else if (!this.prerelease.length && other.prerelease.length) return 1;
7556
- else if (!this.prerelease.length && !other.prerelease.length) return 0;
7557
- let i = 0;
7558
- do {
7559
- const a = this.prerelease[i];
7560
- const b = other.prerelease[i];
7561
- debug("prerelease compare", i, a, b);
7562
- if (a === void 0 && b === void 0) return 0;
7563
- else if (b === void 0) return 1;
7564
- else if (a === void 0) return -1;
7565
- else if (a === b) continue;
7566
- else return compareIdentifiers(a, b);
7567
- } while (++i);
7568
- }
7569
- compareBuild(other) {
7570
- if (!(other instanceof SemVer)) other = new SemVer(other, this.options);
7571
- let i = 0;
7572
- do {
7573
- const a = this.build[i];
7574
- const b = other.build[i];
7575
- debug("build compare", i, a, b);
7576
- if (a === void 0 && b === void 0) return 0;
7577
- else if (b === void 0) return 1;
7578
- else if (a === void 0) return -1;
7579
- else if (a === b) continue;
7580
- else return compareIdentifiers(a, b);
7581
- } while (++i);
7582
- }
7583
- inc(release, identifier, identifierBase) {
7584
- if (release.startsWith("pre")) {
7585
- if (!identifier && identifierBase === false) throw new Error("invalid increment argument: identifier is empty");
7586
- if (identifier) {
7587
- const match = `-${identifier}`.match(this.options.loose ? re[t.PRERELEASELOOSE] : re[t.PRERELEASE]);
7588
- if (!match || match[1] !== identifier) throw new Error(`invalid identifier: ${identifier}`);
7589
- }
7590
- }
7591
- switch (release) {
7592
- case "premajor":
7593
- this.prerelease.length = 0;
7594
- this.patch = 0;
7595
- this.minor = 0;
7596
- this.major++;
7597
- this.inc("pre", identifier, identifierBase);
7598
- break;
7599
- case "preminor":
7600
- this.prerelease.length = 0;
7601
- this.patch = 0;
7602
- this.minor++;
7603
- this.inc("pre", identifier, identifierBase);
7604
- break;
7605
- case "prepatch":
7606
- this.prerelease.length = 0;
7607
- this.inc("patch", identifier, identifierBase);
7608
- this.inc("pre", identifier, identifierBase);
7609
- break;
7610
- case "prerelease":
7611
- if (this.prerelease.length === 0) this.inc("patch", identifier, identifierBase);
7612
- this.inc("pre", identifier, identifierBase);
7613
- break;
7614
- case "release":
7615
- if (this.prerelease.length === 0) throw new Error(`version ${this.raw} is not a prerelease`);
7616
- this.prerelease.length = 0;
7617
- break;
7618
- case "major":
7619
- if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) this.major++;
7620
- this.minor = 0;
7621
- this.patch = 0;
7622
- this.prerelease = [];
7623
- break;
7624
- case "minor":
7625
- if (this.patch !== 0 || this.prerelease.length === 0) this.minor++;
7626
- this.patch = 0;
7627
- this.prerelease = [];
7628
- break;
7629
- case "patch":
7630
- if (this.prerelease.length === 0) this.patch++;
7631
- this.prerelease = [];
7632
- break;
7633
- case "pre": {
7634
- const base = Number(identifierBase) ? 1 : 0;
7635
- if (this.prerelease.length === 0) this.prerelease = [base];
7636
- else {
7637
- let i = this.prerelease.length;
7638
- while (--i >= 0) if (typeof this.prerelease[i] === "number") {
7639
- this.prerelease[i]++;
7640
- i = -2;
7641
- }
7642
- if (i === -1) {
7643
- if (identifier === this.prerelease.join(".") && identifierBase === false) throw new Error("invalid increment argument: identifier already exists");
7644
- this.prerelease.push(base);
7645
- }
7646
- }
7647
- if (identifier) {
7648
- let prerelease = [identifier, base];
7649
- if (identifierBase === false) prerelease = [identifier];
7650
- if (isPrereleaseIdentifier(this.prerelease, identifier)) {
7651
- const prereleaseBase = this.prerelease[identifier.split(".").length];
7652
- if (isNaN(prereleaseBase)) this.prerelease = prerelease;
7653
- } else this.prerelease = prerelease;
7654
- }
7655
- break;
7656
- }
7657
- default: throw new Error(`invalid increment argument: ${release}`);
7658
- }
7659
- this.raw = this.format();
7660
- if (this.build.length) this.raw += `+${this.build.join(".")}`;
7661
- return this;
7662
- }
7663
- };
7664
- }));
7665
- //#endregion
7666
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/parse.js
7667
- var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7668
- const SemVer = require_semver$1();
7669
- const parse = (version, options, throwErrors = false) => {
7670
- if (version instanceof SemVer) return version;
7671
- try {
7672
- return new SemVer(version, options);
7673
- } catch (er) {
7674
- if (!throwErrors) return null;
7675
- throw er;
7676
- }
7677
- };
7678
- module.exports = parse;
7679
- }));
7680
- //#endregion
7681
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/valid.js
7682
- var require_valid$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7683
- const parse = require_parse();
7684
- const valid = (version, options) => {
7685
- const v = parse(version, options);
7686
- return v ? v.version : null;
7687
- };
7688
- module.exports = valid;
7689
- }));
7690
- //#endregion
7691
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/clean.js
7692
- var require_clean = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7693
- const parse = require_parse();
7694
- const clean = (version, options) => {
7695
- const s = parse(version.trim().replace(/^[=v]+/, ""), options);
7696
- return s ? s.version : null;
7697
- };
7698
- module.exports = clean;
7699
- }));
7700
- //#endregion
7701
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/inc.js
7702
- var require_inc = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7703
- const SemVer = require_semver$1();
7704
- const inc = (version, release, options, identifier, identifierBase) => {
7705
- if (typeof options === "string") {
7706
- identifierBase = identifier;
7707
- identifier = options;
7708
- options = void 0;
7709
- }
7710
- try {
7711
- return new SemVer(version instanceof SemVer ? version.version : version, options).inc(release, identifier, identifierBase).version;
7712
- } catch (er) {
7713
- return null;
7714
- }
7715
- };
7716
- module.exports = inc;
7717
- }));
7718
- //#endregion
7719
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/diff.js
7720
- var require_diff = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7721
- const parse = require_parse();
7722
- const diff = (version1, version2) => {
7723
- const v1 = parse(version1, null, true);
7724
- const v2 = parse(version2, null, true);
7725
- const comparison = v1.compare(v2);
7726
- if (comparison === 0) return null;
7727
- const v1Higher = comparison > 0;
7728
- const highVersion = v1Higher ? v1 : v2;
7729
- const lowVersion = v1Higher ? v2 : v1;
7730
- const highHasPre = !!highVersion.prerelease.length;
7731
- if (!!lowVersion.prerelease.length && !highHasPre) {
7732
- if (!lowVersion.patch && !lowVersion.minor) return "major";
7733
- if (lowVersion.compareMain(highVersion) === 0) {
7734
- if (lowVersion.minor && !lowVersion.patch) return "minor";
7735
- return "patch";
7736
- }
7737
- }
7738
- const prefix = highHasPre ? "pre" : "";
7739
- if (v1.major !== v2.major) return prefix + "major";
7740
- if (v1.minor !== v2.minor) return prefix + "minor";
7741
- if (v1.patch !== v2.patch) return prefix + "patch";
7742
- return "prerelease";
7743
- };
7744
- module.exports = diff;
7745
- }));
7746
- //#endregion
7747
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/major.js
7748
- var require_major = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7749
- const SemVer = require_semver$1();
7750
- const major = (a, loose) => new SemVer(a, loose).major;
7751
- module.exports = major;
7752
- }));
7753
- //#endregion
7754
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/minor.js
7755
- var require_minor = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7756
- const SemVer = require_semver$1();
7757
- const minor = (a, loose) => new SemVer(a, loose).minor;
7758
- module.exports = minor;
7759
- }));
7760
- //#endregion
7761
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/patch.js
7762
- var require_patch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7763
- const SemVer = require_semver$1();
7764
- const patch = (a, loose) => new SemVer(a, loose).patch;
7765
- module.exports = patch;
7766
- }));
7767
- //#endregion
7768
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/prerelease.js
7769
- var require_prerelease = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7770
- const parse = require_parse();
7771
- const prerelease = (version, options) => {
7772
- const parsed = parse(version, options);
7773
- return parsed && parsed.prerelease.length ? parsed.prerelease : null;
7774
- };
7775
- module.exports = prerelease;
7776
- }));
7777
- //#endregion
7778
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare.js
7779
- var require_compare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7780
- const SemVer = require_semver$1();
7781
- const compare = (a, b, loose) => new SemVer(a, loose).compare(new SemVer(b, loose));
7782
- module.exports = compare;
7783
- }));
7784
- //#endregion
7785
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rcompare.js
7786
- var require_rcompare = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7787
- const compare = require_compare();
7788
- const rcompare = (a, b, loose) => compare(b, a, loose);
7789
- module.exports = rcompare;
7790
- }));
7791
- //#endregion
7792
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-loose.js
7793
- var require_compare_loose = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7794
- const compare = require_compare();
7795
- const compareLoose = (a, b) => compare(a, b, true);
7796
- module.exports = compareLoose;
7797
- }));
7798
- //#endregion
7799
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/compare-build.js
7800
- var require_compare_build = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7801
- const SemVer = require_semver$1();
7802
- const compareBuild = (a, b, loose) => {
7803
- const versionA = new SemVer(a, loose);
7804
- const versionB = new SemVer(b, loose);
7805
- return versionA.compare(versionB) || versionA.compareBuild(versionB);
7806
- };
7807
- module.exports = compareBuild;
7808
- }));
7809
- //#endregion
7810
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/sort.js
7811
- var require_sort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7812
- const compareBuild = require_compare_build();
7813
- const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose));
7814
- module.exports = sort;
7815
- }));
7816
- //#endregion
7817
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/rsort.js
7818
- var require_rsort = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7819
- const compareBuild = require_compare_build();
7820
- const rsort = (list, loose) => list.sort((a, b) => compareBuild(b, a, loose));
7821
- module.exports = rsort;
7822
- }));
7823
- //#endregion
7824
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gt.js
7825
- var require_gt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7826
- const compare = require_compare();
7827
- const gt = (a, b, loose) => compare(a, b, loose) > 0;
7828
- module.exports = gt;
7829
- }));
7830
- //#endregion
7831
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lt.js
7832
- var require_lt = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7833
- const compare = require_compare();
7834
- const lt = (a, b, loose) => compare(a, b, loose) < 0;
7835
- module.exports = lt;
7836
- }));
7837
- //#endregion
7838
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/eq.js
7839
- var require_eq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7840
- const compare = require_compare();
7841
- const eq = (a, b, loose) => compare(a, b, loose) === 0;
7842
- module.exports = eq;
7843
- }));
7844
- //#endregion
7845
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/neq.js
7846
- var require_neq = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7847
- const compare = require_compare();
7848
- const neq = (a, b, loose) => compare(a, b, loose) !== 0;
7849
- module.exports = neq;
7850
- }));
7851
- //#endregion
7852
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/gte.js
7853
- var require_gte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7854
- const compare = require_compare();
7855
- const gte = (a, b, loose) => compare(a, b, loose) >= 0;
7856
- module.exports = gte;
7857
- }));
7858
- //#endregion
7859
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/lte.js
7860
- var require_lte = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7861
- const compare = require_compare();
7862
- const lte = (a, b, loose) => compare(a, b, loose) <= 0;
7863
- module.exports = lte;
7864
- }));
7865
- //#endregion
7866
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/cmp.js
7867
- var require_cmp = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7868
- const eq = require_eq();
7869
- const neq = require_neq();
7870
- const gt = require_gt();
7871
- const gte = require_gte();
7872
- const lt = require_lt();
7873
- const lte = require_lte();
7874
- const cmp = (a, op, b, loose) => {
7875
- switch (op) {
7876
- case "===":
7877
- if (typeof a === "object") a = a.version;
7878
- if (typeof b === "object") b = b.version;
7879
- return a === b;
7880
- case "!==":
7881
- if (typeof a === "object") a = a.version;
7882
- if (typeof b === "object") b = b.version;
7883
- return a !== b;
7884
- case "":
7885
- case "=":
7886
- case "==": return eq(a, b, loose);
7887
- case "!=": return neq(a, b, loose);
7888
- case ">": return gt(a, b, loose);
7889
- case ">=": return gte(a, b, loose);
7890
- case "<": return lt(a, b, loose);
7891
- case "<=": return lte(a, b, loose);
7892
- default: throw new TypeError(`Invalid operator: ${op}`);
7893
- }
7894
- };
7895
- module.exports = cmp;
7896
- }));
7897
- //#endregion
7898
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/coerce.js
7899
- var require_coerce = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7900
- const SemVer = require_semver$1();
7901
- const parse = require_parse();
7902
- const { safeRe: re, t } = require_re();
7903
- const coerce = (version, options) => {
7904
- if (version instanceof SemVer) return version;
7905
- if (typeof version === "number") version = String(version);
7906
- if (typeof version !== "string") return null;
7907
- options = options || {};
7908
- let match = null;
7909
- if (!options.rtl) match = version.match(options.includePrerelease ? re[t.COERCEFULL] : re[t.COERCE]);
7910
- else {
7911
- const coerceRtlRegex = options.includePrerelease ? re[t.COERCERTLFULL] : re[t.COERCERTL];
7912
- let next;
7913
- while ((next = coerceRtlRegex.exec(version)) && (!match || match.index + match[0].length !== version.length)) {
7914
- if (!match || next.index + next[0].length !== match.index + match[0].length) match = next;
7915
- coerceRtlRegex.lastIndex = next.index + next[1].length + next[2].length;
7916
- }
7917
- coerceRtlRegex.lastIndex = -1;
7918
- }
7919
- if (match === null) return null;
7920
- const major = match[2];
7921
- const minor = match[3] || "0";
7922
- const patch = match[4] || "0";
7923
- const prerelease = options.includePrerelease && match[5] ? `-${match[5]}` : "";
7924
- const build = options.includePrerelease && match[6] ? `+${match[6]}` : "";
7925
- return parse(`${major}.${minor}.${patch}${prerelease}${build}`, options);
7926
- };
7927
- module.exports = coerce;
7928
- }));
7929
- //#endregion
7930
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/truncate.js
7931
- var require_truncate = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7932
- const parse = require_parse();
7933
- const constants = require_constants();
7934
- const SemVer = require_semver$1();
7935
- const truncate = (version, truncation, options) => {
7936
- if (!constants.RELEASE_TYPES.includes(truncation)) return null;
7937
- const clonedVersion = cloneInputVersion(version, options);
7938
- return clonedVersion && doTruncation(clonedVersion, truncation);
7939
- };
7940
- const cloneInputVersion = (version, options) => {
7941
- const versionStringToParse = version instanceof SemVer ? version.version : version;
7942
- return parse(versionStringToParse, options);
7943
- };
7944
- const doTruncation = (version, truncation) => {
7945
- if (isPrerelease(truncation)) return version.version;
7946
- version.prerelease = [];
7947
- switch (truncation) {
7948
- case "major":
7949
- version.minor = 0;
7950
- version.patch = 0;
7951
- break;
7952
- case "minor": version.patch = 0;
7953
- }
7954
- return version.format();
7955
- };
7956
- const isPrerelease = (type) => {
7957
- return type.startsWith("pre");
7958
- };
7959
- module.exports = truncate;
7960
- }));
7961
- //#endregion
7962
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/internal/lrucache.js
7963
- var require_lrucache = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7964
- var LRUCache = class {
7965
- constructor() {
7966
- this.max = 1e3;
7967
- this.map = /* @__PURE__ */ new Map();
7968
- }
7969
- get(key) {
7970
- const value = this.map.get(key);
7971
- if (value === void 0) return;
7972
- else {
7973
- this.map.delete(key);
7974
- this.map.set(key, value);
7975
- return value;
7976
- }
7977
- }
7978
- delete(key) {
7979
- return this.map.delete(key);
7980
- }
7981
- set(key, value) {
7982
- if (!this.delete(key) && value !== void 0) {
7983
- if (this.map.size >= this.max) {
7984
- const firstKey = this.map.keys().next().value;
7985
- this.delete(firstKey);
7986
- }
7987
- this.map.set(key, value);
7988
- }
7989
- return this;
7990
- }
7991
- };
7992
- module.exports = LRUCache;
7993
- }));
7994
- //#endregion
7995
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/range.js
7996
- var require_range = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7997
- const SPACE_CHARACTERS = /\s+/g;
7998
- module.exports = class Range {
7999
- constructor(range, options) {
8000
- options = parseOptions(options);
8001
- if (range instanceof Range) {
8002
- if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) return range;
8003
- else return new Range(range.raw, options);
8004
- }
8005
- if (range instanceof Comparator) {
8006
- this.raw = range.value;
8007
- this.set = [[range]];
8008
- this.formatted = void 0;
8009
- return this;
8010
- }
8011
- this.options = options;
8012
- this.loose = !!options.loose;
8013
- this.includePrerelease = !!options.includePrerelease;
8014
- this.raw = range.trim().replace(SPACE_CHARACTERS, " ");
8015
- this.set = this.raw.split("||").map((r) => this.parseRange(r.trim())).filter((c) => c.length);
8016
- if (!this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`);
8017
- if (this.set.length > 1) {
8018
- const first = this.set[0];
8019
- this.set = this.set.filter((c) => !isNullSet(c[0]));
8020
- if (this.set.length === 0) this.set = [first];
8021
- else if (this.set.length > 1) {
8022
- for (const c of this.set) if (c.length === 1 && isAny(c[0])) {
8023
- this.set = [c];
8024
- break;
8025
- }
8026
- }
8027
- }
8028
- this.formatted = void 0;
8029
- }
8030
- get range() {
8031
- if (this.formatted === void 0) {
8032
- this.formatted = "";
8033
- for (let i = 0; i < this.set.length; i++) {
8034
- if (i > 0) this.formatted += "||";
8035
- const comps = this.set[i];
8036
- for (let k = 0; k < comps.length; k++) {
8037
- if (k > 0) this.formatted += " ";
8038
- this.formatted += comps[k].toString().trim();
8039
- }
8040
- }
8041
- }
8042
- return this.formatted;
8043
- }
8044
- format() {
8045
- return this.range;
8046
- }
8047
- toString() {
8048
- return this.range;
8049
- }
8050
- parseRange(range) {
8051
- range = range.replace(BUILDSTRIPRE, "");
8052
- const memoKey = ((this.options.includePrerelease && FLAG_INCLUDE_PRERELEASE) | (this.options.loose && FLAG_LOOSE)) + ":" + range;
8053
- const cached = cache.get(memoKey);
8054
- if (cached) return cached;
8055
- const loose = this.options.loose;
8056
- const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
8057
- range = range.replace(hr, hyphenReplace(this.options.includePrerelease));
8058
- debug("hyphen replace", range);
8059
- range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
8060
- debug("comparator trim", range);
8061
- range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
8062
- debug("tilde trim", range);
8063
- range = range.replace(re[t.CARETTRIM], caretTrimReplace);
8064
- debug("caret trim", range);
8065
- let rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options));
8066
- if (loose) rangeList = rangeList.filter((comp) => {
8067
- debug("loose invalid filter", comp, this.options);
8068
- return !!comp.match(re[t.COMPARATORLOOSE]);
8069
- });
8070
- debug("range list", rangeList);
8071
- const rangeMap = /* @__PURE__ */ new Map();
8072
- const comparators = rangeList.map((comp) => new Comparator(comp, this.options));
8073
- for (const comp of comparators) {
8074
- if (isNullSet(comp)) return [comp];
8075
- rangeMap.set(comp.value, comp);
8076
- }
8077
- if (rangeMap.size > 1 && rangeMap.has("")) rangeMap.delete("");
8078
- const result = [...rangeMap.values()];
8079
- cache.set(memoKey, result);
8080
- return result;
8081
- }
8082
- intersects(range, options) {
8083
- if (!(range instanceof Range)) throw new TypeError("a Range is required");
8084
- return this.set.some((thisComparators) => {
8085
- return isSatisfiable(thisComparators, options) && range.set.some((rangeComparators) => {
8086
- return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
8087
- return rangeComparators.every((rangeComparator) => {
8088
- return thisComparator.intersects(rangeComparator, options);
8089
- });
8090
- });
8091
- });
8092
- });
8093
- }
8094
- test(version) {
8095
- if (!version) return false;
8096
- if (typeof version === "string") try {
8097
- version = new SemVer(version, this.options);
8098
- } catch (er) {
8099
- return false;
8100
- }
8101
- for (let i = 0; i < this.set.length; i++) if (testSet(this.set[i], version, this.options)) return true;
8102
- return false;
8103
- }
8104
- };
8105
- const cache = new (require_lrucache())();
8106
- const parseOptions = require_parse_options();
8107
- const Comparator = require_comparator();
8108
- const debug = require_debug();
8109
- const SemVer = require_semver$1();
8110
- const { safeRe: re, src, t, comparatorTrimReplace, tildeTrimReplace, caretTrimReplace } = require_re();
8111
- const { FLAG_INCLUDE_PRERELEASE, FLAG_LOOSE } = require_constants();
8112
- const BUILDSTRIPRE = new RegExp(src[t.BUILD], "g");
8113
- const isNullSet = (c) => c.value === "<0.0.0-0";
8114
- const isAny = (c) => c.value === "";
8115
- const isSatisfiable = (comparators, options) => {
8116
- let result = true;
8117
- const remainingComparators = comparators.slice();
8118
- let testComparator = remainingComparators.pop();
8119
- while (result && remainingComparators.length) {
8120
- result = remainingComparators.every((otherComparator) => {
8121
- return testComparator.intersects(otherComparator, options);
8122
- });
8123
- testComparator = remainingComparators.pop();
8124
- }
8125
- return result;
8126
- };
8127
- const parseComparator = (comp, options) => {
8128
- comp = comp.replace(re[t.BUILD], "");
8129
- debug("comp", comp, options);
8130
- comp = replaceCarets(comp, options);
8131
- debug("caret", comp);
8132
- comp = replaceTildes(comp, options);
8133
- debug("tildes", comp);
8134
- comp = replaceXRanges(comp, options);
8135
- debug("xrange", comp);
8136
- comp = replaceStars(comp, options);
8137
- debug("stars", comp);
8138
- return comp;
8139
- };
8140
- const isX = (id) => !id || id.toLowerCase() === "x" || id === "*";
8141
- const invalidXRangeOrder = (M, m, p) => isX(M) && !isX(m) || isX(m) && p && !isX(p);
8142
- const replaceTildes = (comp, options) => {
8143
- return comp.trim().split(/\s+/).map((c) => replaceTilde(c, options)).join(" ");
8144
- };
8145
- const replaceTilde = (comp, options) => {
8146
- const r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
8147
- const z = options.includePrerelease ? "-0" : "";
8148
- return comp.replace(r, (_, M, m, p, pr) => {
8149
- debug("tilde", comp, _, M, m, p, pr);
8150
- let ret;
8151
- if (isX(M)) ret = "";
8152
- else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
8153
- else if (isX(p)) ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
8154
- else if (pr) {
8155
- debug("replaceTilde pr", pr);
8156
- ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
8157
- } else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
8158
- debug("tilde return", ret);
8159
- return ret;
8160
- });
8161
- };
8162
- const replaceCarets = (comp, options) => {
8163
- return comp.trim().split(/\s+/).map((c) => replaceCaret(c, options)).join(" ");
8164
- };
8165
- const replaceCaret = (comp, options) => {
8166
- debug("caret", comp, options);
8167
- const r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
8168
- const z = options.includePrerelease ? "-0" : "";
8169
- return comp.replace(r, (_, M, m, p, pr) => {
8170
- debug("caret", comp, _, M, m, p, pr);
8171
- let ret;
8172
- if (isX(M)) ret = "";
8173
- else if (isX(m)) ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
8174
- else if (isX(p)) {
8175
- if (M === "0") ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
8176
- else ret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`;
8177
- } else if (pr) {
8178
- debug("replaceCaret pr", pr);
8179
- if (M === "0") {
8180
- if (m === "0") ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
8181
- else ret = `>=${M}.${m}.${p}-${pr} <${M}.${+m + 1}.0-0`;
8182
- } else ret = `>=${M}.${m}.${p}-${pr} <${+M + 1}.0.0-0`;
8183
- } else {
8184
- debug("no pr");
8185
- if (M === "0") {
8186
- if (m === "0") ret = `>=${M}.${m}.${p} <${M}.${m}.${+p + 1}-0`;
8187
- else ret = `>=${M}.${m}.${p} <${M}.${+m + 1}.0-0`;
8188
- } else ret = `>=${M}.${m}.${p} <${+M + 1}.0.0-0`;
8189
- }
8190
- debug("caret return", ret);
8191
- return ret;
8192
- });
8193
- };
8194
- const replaceXRanges = (comp, options) => {
8195
- debug("replaceXRanges", comp, options);
8196
- return comp.split(/\s+/).map((c) => replaceXRange(c, options)).join(" ");
8197
- };
8198
- const replaceXRange = (comp, options) => {
8199
- comp = comp.trim();
8200
- const r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
8201
- return comp.replace(r, (ret, gtlt, M, m, p, pr) => {
8202
- debug("xRange", comp, ret, gtlt, M, m, p, pr);
8203
- if (invalidXRangeOrder(M, m, p)) return comp;
8204
- const xM = isX(M);
8205
- const xm = xM || isX(m);
8206
- const xp = xm || isX(p);
8207
- const anyX = xp;
8208
- if (gtlt === "=" && anyX) gtlt = "";
8209
- pr = options.includePrerelease ? "-0" : "";
8210
- if (xM) {
8211
- if (gtlt === ">" || gtlt === "<") ret = "<0.0.0-0";
8212
- else ret = "*";
8213
- } else if (gtlt && anyX) {
8214
- if (xm) m = 0;
8215
- p = 0;
8216
- if (gtlt === ">") {
8217
- gtlt = ">=";
8218
- if (xm) {
8219
- M = +M + 1;
8220
- m = 0;
8221
- p = 0;
8222
- } else {
8223
- m = +m + 1;
8224
- p = 0;
8225
- }
8226
- } else if (gtlt === "<=") {
8227
- gtlt = "<";
8228
- if (xm) M = +M + 1;
8229
- else m = +m + 1;
8230
- }
8231
- if (gtlt === "<") pr = "-0";
8232
- ret = `${gtlt + M}.${m}.${p}${pr}`;
8233
- } else if (xm) ret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`;
8234
- else if (xp) ret = `>=${M}.${m}.0${pr} <${M}.${+m + 1}.0-0`;
8235
- debug("xRange return", ret);
8236
- return ret;
8237
- });
8238
- };
8239
- const replaceStars = (comp, options) => {
8240
- debug("replaceStars", comp, options);
8241
- return comp.trim().replace(re[t.STAR], "");
8242
- };
8243
- const replaceGTE0 = (comp, options) => {
8244
- debug("replaceGTE0", comp, options);
8245
- return comp.trim().replace(re[options.includePrerelease ? t.GTE0PRE : t.GTE0], "");
8246
- };
8247
- const hyphenReplace = (incPr) => ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr) => {
8248
- if (isX(fM)) from = "";
8249
- else if (isX(fm)) from = `>=${fM}.0.0${incPr ? "-0" : ""}`;
8250
- else if (isX(fp)) from = `>=${fM}.${fm}.0${incPr ? "-0" : ""}`;
8251
- else if (fpr) from = `>=${from}`;
8252
- else from = `>=${from}${incPr ? "-0" : ""}`;
8253
- if (isX(tM)) to = "";
8254
- else if (isX(tm)) to = `<${+tM + 1}.0.0-0`;
8255
- else if (isX(tp)) to = `<${tM}.${+tm + 1}.0-0`;
8256
- else if (tpr) to = `<=${tM}.${tm}.${tp}-${tpr}`;
8257
- else if (incPr) to = `<${tM}.${tm}.${+tp + 1}-0`;
8258
- else to = `<=${to}`;
8259
- return `${from} ${to}`.trim();
8260
- };
8261
- const testSet = (set, version, options) => {
8262
- for (let i = 0; i < set.length; i++) if (!set[i].test(version)) return false;
8263
- if (version.prerelease.length && !options.includePrerelease) {
8264
- for (let i = 0; i < set.length; i++) {
8265
- debug(set[i].semver);
8266
- if (set[i].semver === Comparator.ANY) continue;
8267
- if (set[i].semver.prerelease.length > 0) {
8268
- const allowed = set[i].semver;
8269
- if (allowed.major === version.major && allowed.minor === version.minor && allowed.patch === version.patch) return true;
8270
- }
8271
- }
8272
- return false;
8273
- }
8274
- return true;
8275
- };
8276
- }));
8277
- //#endregion
8278
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/classes/comparator.js
8279
- var require_comparator = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8280
- const ANY = Symbol("SemVer ANY");
8281
- module.exports = class Comparator {
8282
- static get ANY() {
8283
- return ANY;
8284
- }
8285
- constructor(comp, options) {
8286
- options = parseOptions(options);
8287
- if (comp instanceof Comparator) {
8288
- if (comp.loose === !!options.loose) return comp;
8289
- else comp = comp.value;
8290
- }
8291
- comp = comp.trim().split(/\s+/).join(" ");
8292
- debug("comparator", comp, options);
8293
- this.options = options;
8294
- this.loose = !!options.loose;
8295
- this.parse(comp);
8296
- if (this.semver === ANY) this.value = "";
8297
- else this.value = this.operator + this.semver.version;
8298
- debug("comp", this);
8299
- }
8300
- parse(comp) {
8301
- const r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
8302
- const m = comp.match(r);
8303
- if (!m) throw new TypeError(`Invalid comparator: ${comp}`);
8304
- this.operator = m[1] !== void 0 ? m[1] : "";
8305
- if (this.operator === "=") this.operator = "";
8306
- if (!m[2]) this.semver = ANY;
8307
- else this.semver = new SemVer(m[2], this.options.loose);
8308
- }
8309
- toString() {
8310
- return this.value;
8311
- }
8312
- test(version) {
8313
- debug("Comparator.test", version, this.options.loose);
8314
- if (this.semver === ANY || version === ANY) return true;
8315
- if (typeof version === "string") try {
8316
- version = new SemVer(version, this.options);
8317
- } catch (er) {
8318
- return false;
8319
- }
8320
- return cmp(version, this.operator, this.semver, this.options);
8321
- }
8322
- intersects(comp, options) {
8323
- if (!(comp instanceof Comparator)) throw new TypeError("a Comparator is required");
8324
- if (this.operator === "") {
8325
- if (this.value === "") return true;
8326
- return new Range(comp.value, options).test(this.value);
8327
- } else if (comp.operator === "") {
8328
- if (comp.value === "") return true;
8329
- return new Range(this.value, options).test(comp.semver);
8330
- }
8331
- options = parseOptions(options);
8332
- if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) return false;
8333
- if (!options.includePrerelease && (this.value.startsWith("<0.0.0") || comp.value.startsWith("<0.0.0"))) return false;
8334
- if (this.operator.startsWith(">") && comp.operator.startsWith(">")) return true;
8335
- if (this.operator.startsWith("<") && comp.operator.startsWith("<")) return true;
8336
- if (this.semver.version === comp.semver.version && this.operator.includes("=") && comp.operator.includes("=")) return true;
8337
- if (cmp(this.semver, "<", comp.semver, options) && this.operator.startsWith(">") && comp.operator.startsWith("<")) return true;
8338
- if (cmp(this.semver, ">", comp.semver, options) && this.operator.startsWith("<") && comp.operator.startsWith(">")) return true;
8339
- return false;
8340
- }
8341
- };
8342
- const parseOptions = require_parse_options();
8343
- const { safeRe: re, t } = require_re();
8344
- const cmp = require_cmp();
8345
- const debug = require_debug();
8346
- const SemVer = require_semver$1();
8347
- const Range = require_range();
8348
- }));
8349
- //#endregion
8350
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/functions/satisfies.js
8351
- var require_satisfies = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8352
- const Range = require_range();
8353
- const satisfies = (version, range, options) => {
8354
- try {
8355
- range = new Range(range, options);
8356
- } catch (er) {
8357
- return false;
8358
- }
8359
- return range.test(version);
8360
- };
8361
- module.exports = satisfies;
8362
- }));
8363
- //#endregion
8364
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/to-comparators.js
8365
- var require_to_comparators = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8366
- const Range = require_range();
8367
- const toComparators = (range, options) => new Range(range, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
8368
- module.exports = toComparators;
8369
- }));
8370
- //#endregion
8371
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/max-satisfying.js
8372
- var require_max_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8373
- const SemVer = require_semver$1();
8374
- const Range = require_range();
8375
- const maxSatisfying = (versions, range, options) => {
8376
- let max = null;
8377
- let maxSV = null;
8378
- let rangeObj = null;
8379
- try {
8380
- rangeObj = new Range(range, options);
8381
- } catch (er) {
8382
- return null;
8383
- }
8384
- versions.forEach((v) => {
8385
- if (rangeObj.test(v)) {
8386
- if (!max || maxSV.compare(v) === -1) {
8387
- max = v;
8388
- maxSV = new SemVer(max, options);
8389
- }
8390
- }
8391
- });
8392
- return max;
8393
- };
8394
- module.exports = maxSatisfying;
8395
- }));
8396
- //#endregion
8397
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-satisfying.js
8398
- var require_min_satisfying = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8399
- const SemVer = require_semver$1();
8400
- const Range = require_range();
8401
- const minSatisfying = (versions, range, options) => {
8402
- let min = null;
8403
- let minSV = null;
8404
- let rangeObj = null;
8405
- try {
8406
- rangeObj = new Range(range, options);
8407
- } catch (er) {
8408
- return null;
8409
- }
8410
- versions.forEach((v) => {
8411
- if (rangeObj.test(v)) {
8412
- if (!min || minSV.compare(v) === 1) {
8413
- min = v;
8414
- minSV = new SemVer(min, options);
8415
- }
8416
- }
8417
- });
8418
- return min;
8419
- };
8420
- module.exports = minSatisfying;
8421
- }));
8422
- //#endregion
8423
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/min-version.js
8424
- var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8425
- const SemVer = require_semver$1();
8426
- const Range = require_range();
8427
- const gt = require_gt();
8428
- const minVersion = (range, loose) => {
8429
- range = new Range(range, loose);
8430
- let minver = new SemVer("0.0.0");
8431
- if (range.test(minver)) return minver;
8432
- minver = new SemVer("0.0.0-0");
8433
- if (range.test(minver)) return minver;
8434
- minver = null;
8435
- for (let i = 0; i < range.set.length; ++i) {
8436
- const comparators = range.set[i];
8437
- let setMin = null;
8438
- comparators.forEach((comparator) => {
8439
- const compver = new SemVer(comparator.semver.version);
8440
- switch (comparator.operator) {
8441
- case ">":
8442
- if (compver.prerelease.length === 0) compver.patch++;
8443
- else compver.prerelease.push(0);
8444
- compver.raw = compver.format();
8445
- case "":
8446
- case ">=":
8447
- if (!setMin || gt(compver, setMin)) setMin = compver;
8448
- break;
8449
- case "<":
8450
- case "<=": break;
8451
- /* istanbul ignore next */
8452
- default: throw new Error(`Unexpected operation: ${comparator.operator}`);
8453
- }
8454
- });
8455
- if (setMin && (!minver || gt(minver, setMin))) minver = setMin;
8456
- }
8457
- if (minver && range.test(minver)) return minver;
8458
- return null;
8459
- };
8460
- module.exports = minVersion;
8461
- }));
8462
- //#endregion
8463
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/valid.js
8464
- var require_valid = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8465
- const Range = require_range();
8466
- const validRange = (range, options) => {
8467
- try {
8468
- return new Range(range, options).range || "*";
8469
- } catch (er) {
8470
- return null;
8471
- }
8472
- };
8473
- module.exports = validRange;
8474
- }));
8475
- //#endregion
8476
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/outside.js
8477
- var require_outside = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8478
- const SemVer = require_semver$1();
8479
- const Comparator = require_comparator();
8480
- const { ANY } = Comparator;
8481
- const Range = require_range();
8482
- const satisfies = require_satisfies();
8483
- const gt = require_gt();
8484
- const lt = require_lt();
8485
- const lte = require_lte();
8486
- const gte = require_gte();
8487
- const outside = (version, range, hilo, options) => {
8488
- version = new SemVer(version, options);
8489
- range = new Range(range, options);
8490
- let gtfn, ltefn, ltfn, comp, ecomp;
8491
- switch (hilo) {
8492
- case ">":
8493
- gtfn = gt;
8494
- ltefn = lte;
8495
- ltfn = lt;
8496
- comp = ">";
8497
- ecomp = ">=";
8498
- break;
8499
- case "<":
8500
- gtfn = lt;
8501
- ltefn = gte;
8502
- ltfn = gt;
8503
- comp = "<";
8504
- ecomp = "<=";
8505
- break;
8506
- default: throw new TypeError("Must provide a hilo val of \"<\" or \">\"");
8507
- }
8508
- if (satisfies(version, range, options)) return false;
8509
- for (let i = 0; i < range.set.length; ++i) {
8510
- const comparators = range.set[i];
8511
- let high = null;
8512
- let low = null;
8513
- comparators.forEach((comparator) => {
8514
- if (comparator.semver === ANY) comparator = new Comparator(">=0.0.0");
8515
- high = high || comparator;
8516
- low = low || comparator;
8517
- if (gtfn(comparator.semver, high.semver, options)) high = comparator;
8518
- else if (ltfn(comparator.semver, low.semver, options)) low = comparator;
8519
- });
8520
- if (high.operator === comp || high.operator === ecomp) return false;
8521
- if ((!low.operator || low.operator === comp) && ltefn(version, low.semver)) return false;
8522
- else if (low.operator === ecomp && ltfn(version, low.semver)) return false;
8523
- }
8524
- return true;
8525
- };
8526
- module.exports = outside;
8527
- }));
8528
- //#endregion
8529
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/gtr.js
8530
- var require_gtr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8531
- const outside = require_outside();
8532
- const gtr = (version, range, options) => outside(version, range, ">", options);
8533
- module.exports = gtr;
8534
- }));
8535
- //#endregion
8536
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/ltr.js
8537
- var require_ltr = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8538
- const outside = require_outside();
8539
- const ltr = (version, range, options) => outside(version, range, "<", options);
8540
- module.exports = ltr;
8541
- }));
8542
- //#endregion
8543
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/intersects.js
8544
- var require_intersects = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8545
- const Range = require_range();
8546
- const intersects = (r1, r2, options) => {
8547
- r1 = new Range(r1, options);
8548
- r2 = new Range(r2, options);
8549
- return r1.intersects(r2, options);
8550
- };
8551
- module.exports = intersects;
8552
- }));
8553
- //#endregion
8554
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/simplify.js
8555
- var require_simplify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8556
- const satisfies = require_satisfies();
8557
- const compare = require_compare();
8558
- module.exports = (versions, range, options) => {
8559
- const set = [];
8560
- let first = null;
8561
- let prev = null;
8562
- const v = versions.sort((a, b) => compare(a, b, options));
8563
- for (const version of v) if (satisfies(version, range, options)) {
8564
- prev = version;
8565
- if (!first) first = version;
8566
- } else {
8567
- if (prev) set.push([first, prev]);
8568
- prev = null;
8569
- first = null;
8570
- }
8571
- if (first) set.push([first, null]);
8572
- const ranges = [];
8573
- for (const [min, max] of set) if (min === max) ranges.push(min);
8574
- else if (!max && min === v[0]) ranges.push("*");
8575
- else if (!max) ranges.push(`>=${min}`);
8576
- else if (min === v[0]) ranges.push(`<=${max}`);
8577
- else ranges.push(`${min} - ${max}`);
8578
- const simplified = ranges.join(" || ");
8579
- const original = typeof range.raw === "string" ? range.raw : String(range);
8580
- return simplified.length < original.length ? simplified : range;
8581
- };
8582
- }));
8583
- //#endregion
8584
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/ranges/subset.js
8585
- var require_subset = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8586
- const Range = require_range();
8587
- const Comparator = require_comparator();
8588
- const { ANY } = Comparator;
8589
- const satisfies = require_satisfies();
8590
- const compare = require_compare();
8591
- const subset = (sub, dom, options = {}) => {
8592
- if (sub === dom) return true;
8593
- sub = new Range(sub, options);
8594
- dom = new Range(dom, options);
8595
- let sawNonNull = false;
8596
- OUTER: for (const simpleSub of sub.set) {
8597
- for (const simpleDom of dom.set) {
8598
- const isSub = simpleSubset(simpleSub, simpleDom, options);
8599
- sawNonNull = sawNonNull || isSub !== null;
8600
- if (isSub) continue OUTER;
8601
- }
8602
- if (sawNonNull) return false;
8603
- }
8604
- return true;
8605
- };
8606
- const minimumVersionWithPreRelease = [new Comparator(">=0.0.0-0")];
8607
- const minimumVersion = [new Comparator(">=0.0.0")];
8608
- const simpleSubset = (sub, dom, options) => {
8609
- if (sub === dom) return true;
8610
- if (sub.length === 1 && sub[0].semver === ANY) {
8611
- if (dom.length === 1 && dom[0].semver === ANY) return true;
8612
- else if (options.includePrerelease) sub = minimumVersionWithPreRelease;
8613
- else sub = minimumVersion;
8614
- }
8615
- if (dom.length === 1 && dom[0].semver === ANY) {
8616
- if (options.includePrerelease) return true;
8617
- else dom = minimumVersion;
8618
- }
8619
- const eqSet = /* @__PURE__ */ new Set();
8620
- let gt, lt;
8621
- for (const c of sub) if (c.operator === ">" || c.operator === ">=") gt = higherGT(gt, c, options);
8622
- else if (c.operator === "<" || c.operator === "<=") lt = lowerLT(lt, c, options);
8623
- else eqSet.add(c.semver);
8624
- if (eqSet.size > 1) return null;
8625
- let gtltComp;
8626
- if (gt && lt) {
8627
- gtltComp = compare(gt.semver, lt.semver, options);
8628
- if (gtltComp > 0) return null;
8629
- else if (gtltComp === 0 && (gt.operator !== ">=" || lt.operator !== "<=")) return null;
8630
- }
8631
- for (const eq of eqSet) {
8632
- if (gt && !satisfies(eq, String(gt), options)) return null;
8633
- if (lt && !satisfies(eq, String(lt), options)) return null;
8634
- for (const c of dom) if (!satisfies(eq, String(c), options)) return false;
8635
- return true;
8636
- }
8637
- let higher, lower;
8638
- let hasDomLT, hasDomGT;
8639
- let needDomLTPre = lt && !options.includePrerelease && lt.semver.prerelease.length ? lt.semver : false;
8640
- let needDomGTPre = gt && !options.includePrerelease && gt.semver.prerelease.length ? gt.semver : false;
8641
- if (needDomLTPre && needDomLTPre.prerelease.length === 1 && lt.operator === "<" && needDomLTPre.prerelease[0] === 0) needDomLTPre = false;
8642
- for (const c of dom) {
8643
- hasDomGT = hasDomGT || c.operator === ">" || c.operator === ">=";
8644
- hasDomLT = hasDomLT || c.operator === "<" || c.operator === "<=";
8645
- if (gt) {
8646
- if (needDomGTPre) {
8647
- if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomGTPre.major && c.semver.minor === needDomGTPre.minor && c.semver.patch === needDomGTPre.patch) needDomGTPre = false;
8648
- }
8649
- if (c.operator === ">" || c.operator === ">=") {
8650
- higher = higherGT(gt, c, options);
8651
- if (higher === c && higher !== gt) return false;
8652
- } else if (gt.operator === ">=" && !c.test(gt.semver)) return false;
8653
- }
8654
- if (lt) {
8655
- if (needDomLTPre) {
8656
- if (c.semver.prerelease && c.semver.prerelease.length && c.semver.major === needDomLTPre.major && c.semver.minor === needDomLTPre.minor && c.semver.patch === needDomLTPre.patch) needDomLTPre = false;
8657
- }
8658
- if (c.operator === "<" || c.operator === "<=") {
8659
- lower = lowerLT(lt, c, options);
8660
- if (lower === c && lower !== lt) return false;
8661
- } else if (lt.operator === "<=" && !c.test(lt.semver)) return false;
8662
- }
8663
- if (!c.operator && (lt || gt) && gtltComp !== 0) return false;
8664
- }
8665
- if (gt && hasDomLT && !lt && gtltComp !== 0) return false;
8666
- if (lt && hasDomGT && !gt && gtltComp !== 0) return false;
8667
- if (needDomGTPre || needDomLTPre) return false;
8668
- return true;
8669
- };
8670
- const higherGT = (a, b, options) => {
8671
- if (!a) return b;
8672
- const comp = compare(a.semver, b.semver, options);
8673
- return comp > 0 ? a : comp < 0 ? b : b.operator === ">" && a.operator === ">=" ? b : a;
8674
- };
8675
- const lowerLT = (a, b, options) => {
8676
- if (!a) return b;
8677
- const comp = compare(a.semver, b.semver, options);
8678
- return comp < 0 ? a : comp > 0 ? b : b.operator === "<" && a.operator === "<=" ? b : a;
8679
- };
8680
- module.exports = subset;
8681
- }));
8682
- //#endregion
8683
- //#region ../../node_modules/.pnpm/semver@7.8.5/node_modules/semver/index.js
8684
- var require_semver = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8685
- const internalRe = require_re();
8686
- const constants = require_constants();
8687
- const SemVer = require_semver$1();
8688
- const identifiers = require_identifiers();
8689
- module.exports = {
8690
- parse: require_parse(),
8691
- valid: require_valid$1(),
8692
- clean: require_clean(),
8693
- inc: require_inc(),
8694
- diff: require_diff(),
8695
- major: require_major(),
8696
- minor: require_minor(),
8697
- patch: require_patch(),
8698
- prerelease: require_prerelease(),
8699
- compare: require_compare(),
8700
- rcompare: require_rcompare(),
8701
- compareLoose: require_compare_loose(),
8702
- compareBuild: require_compare_build(),
8703
- sort: require_sort(),
8704
- rsort: require_rsort(),
8705
- gt: require_gt(),
8706
- lt: require_lt(),
8707
- eq: require_eq(),
8708
- neq: require_neq(),
8709
- gte: require_gte(),
8710
- lte: require_lte(),
8711
- cmp: require_cmp(),
8712
- coerce: require_coerce(),
8713
- truncate: require_truncate(),
8714
- Comparator: require_comparator(),
8715
- Range: require_range(),
8716
- satisfies: require_satisfies(),
8717
- toComparators: require_to_comparators(),
8718
- maxSatisfying: require_max_satisfying(),
8719
- minSatisfying: require_min_satisfying(),
8720
- minVersion: require_min_version(),
8721
- validRange: require_valid(),
8722
- outside: require_outside(),
8723
- gtr: require_gtr(),
8724
- ltr: require_ltr(),
8725
- intersects: require_intersects(),
8726
- simplifyRange: require_simplify(),
8727
- subset: require_subset(),
8728
- SemVer,
8729
- re: internalRe.re,
8730
- src: internalRe.src,
8731
- tokens: internalRe.t,
8732
- SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
8733
- RELEASE_TYPES: constants.RELEASE_TYPES,
8734
- compareIdentifiers: identifiers.compareIdentifiers,
8735
- rcompareIdentifiers: identifiers.rcompareIdentifiers
8736
- };
8737
- }));
8738
- //#endregion
8739
- //#region ../../node_modules/.pnpm/validate-npm-package-name@8.0.0/node_modules/validate-npm-package-name/lib/builtin-modules.json
8740
- var require_builtin_modules = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8741
- module.exports = [
8742
- "_http_agent",
8743
- "_http_client",
8744
- "_http_common",
8745
- "_http_incoming",
8746
- "_http_outgoing",
8747
- "_http_server",
8748
- "_stream_duplex",
8749
- "_stream_passthrough",
8750
- "_stream_readable",
8751
- "_stream_transform",
8752
- "_stream_wrap",
8753
- "_stream_writable",
8754
- "_tls_common",
8755
- "_tls_wrap",
8756
- "assert",
8757
- "assert/strict",
8758
- "async_hooks",
8759
- "buffer",
8760
- "child_process",
8761
- "cluster",
8762
- "console",
8763
- "constants",
8764
- "crypto",
8765
- "dgram",
8766
- "diagnostics_channel",
8767
- "dns",
8768
- "dns/promises",
8769
- "domain",
8770
- "events",
8771
- "fs",
8772
- "fs/promises",
8773
- "http",
8774
- "http2",
8775
- "https",
8776
- "inspector",
8777
- "inspector/promises",
8778
- "module",
8779
- "net",
8780
- "os",
8781
- "path",
8782
- "path/posix",
8783
- "path/win32",
8784
- "perf_hooks",
8785
- "process",
8786
- "punycode",
8787
- "querystring",
8788
- "readline",
8789
- "readline/promises",
8790
- "repl",
8791
- "stream",
8792
- "stream/consumers",
8793
- "stream/promises",
8794
- "stream/web",
8795
- "string_decoder",
8796
- "sys",
8797
- "timers",
8798
- "timers/promises",
8799
- "tls",
8800
- "trace_events",
8801
- "tty",
8802
- "url",
8803
- "util",
8804
- "util/types",
8805
- "v8",
8806
- "vm",
8807
- "wasi",
8808
- "worker_threads",
8809
- "zlib",
8810
- "node:sea",
8811
- "node:sqlite",
8812
- "node:test",
8813
- "node:test/reporters"
8814
- ];
8815
- }));
8816
- //#endregion
8817
- //#region ../../node_modules/.pnpm/validate-npm-package-name@8.0.0/node_modules/validate-npm-package-name/lib/index.js
8818
- var require_lib$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8819
- const builtins = require_builtin_modules();
8820
- var scopedPackagePattern = /* @__PURE__ */ new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");
8821
- var exclusionList = ["node_modules", "favicon.ico"];
8822
- function validate(name) {
8823
- var warnings = [];
8824
- var errors = [];
8825
- if (name === null) {
8826
- errors.push("name cannot be null");
8827
- return done(warnings, errors);
8828
- }
8829
- if (name === void 0) {
8830
- errors.push("name cannot be undefined");
8831
- return done(warnings, errors);
8832
- }
8833
- if (typeof name !== "string") {
8834
- errors.push("name must be a string");
8835
- return done(warnings, errors);
8836
- }
8837
- if (!name.length) errors.push("name length must be greater than zero");
8838
- if (name.startsWith(".")) errors.push("name cannot start with a period");
8839
- if (name.startsWith("-")) errors.push("name cannot start with a hyphen");
8840
- if (name.match(/^_/)) errors.push("name cannot start with an underscore");
8841
- if (name.trim() !== name) errors.push("name cannot contain leading or trailing spaces");
8842
- exclusionList.forEach(function(excludedName) {
8843
- if (name.toLowerCase() === excludedName) errors.push(excludedName + " is not a valid package name");
8844
- });
8845
- if (builtins.includes(name.toLowerCase())) warnings.push(name + " is a core module name");
8846
- if (name.length > 214) warnings.push("name can no longer contain more than 214 characters");
8847
- if (name.toLowerCase() !== name) warnings.push("name can no longer contain capital letters");
8848
- if (/[~'!()*]/.test(name.split("/").slice(-1)[0])) warnings.push("name can no longer contain special characters (\"~'!()*\")");
8849
- if (encodeURIComponent(name) !== name) {
8850
- var nameMatch = name.match(scopedPackagePattern);
8851
- if (nameMatch) {
8852
- var user = nameMatch[1];
8853
- var pkg = nameMatch[2];
8854
- if (pkg.startsWith(".")) errors.push("name cannot start with a period");
8855
- if (encodeURIComponent(user) === user && encodeURIComponent(pkg) === pkg) return done(warnings, errors);
8856
- }
8857
- errors.push("name can only contain URL-friendly characters");
8858
- }
8859
- return done(warnings, errors);
8860
- }
8861
- var done = function(warnings, errors) {
8862
- var result = {
8863
- validForNewPackages: errors.length === 0 && warnings.length === 0,
8864
- validForOldPackages: errors.length === 0,
8865
- warnings,
8866
- errors
8867
- };
8868
- if (!result.warnings.length) delete result.warnings;
8869
- if (!result.errors.length) delete result.errors;
8870
- return result;
8871
- };
8872
- module.exports = validate;
8873
- }));
8874
- //#endregion
8875
- //#region ../../node_modules/.pnpm/proc-log@7.0.0/node_modules/proc-log/lib/index.js
8876
- var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8877
- module.exports = {
8878
- META: Symbol("proc-log.meta"),
8879
- output: {
8880
- LEVELS: [
8881
- "standard",
8882
- "error",
8883
- "buffer",
8884
- "flush"
8885
- ],
8886
- KEYS: {
8887
- standard: "standard",
8888
- error: "error",
8889
- buffer: "buffer",
8890
- flush: "flush"
8891
- },
8892
- standard: function(...args) {
8893
- return process.emit("output", "standard", ...args);
8894
- },
8895
- error: function(...args) {
8896
- return process.emit("output", "error", ...args);
8897
- },
8898
- buffer: function(...args) {
8899
- return process.emit("output", "buffer", ...args);
8900
- },
8901
- flush: function(...args) {
8902
- return process.emit("output", "flush", ...args);
8903
- }
8904
- },
8905
- log: {
8906
- LEVELS: [
8907
- "notice",
8908
- "error",
8909
- "warn",
8910
- "info",
8911
- "verbose",
8912
- "http",
8913
- "silly",
8914
- "timing",
8915
- "pause",
8916
- "resume"
8917
- ],
8918
- KEYS: {
8919
- notice: "notice",
8920
- error: "error",
8921
- warn: "warn",
8922
- info: "info",
8923
- verbose: "verbose",
8924
- http: "http",
8925
- silly: "silly",
8926
- timing: "timing",
8927
- pause: "pause",
8928
- resume: "resume"
8929
- },
8930
- error: function(...args) {
8931
- return process.emit("log", "error", ...args);
8932
- },
8933
- notice: function(...args) {
8934
- return process.emit("log", "notice", ...args);
8935
- },
8936
- warn: function(...args) {
8937
- return process.emit("log", "warn", ...args);
8938
- },
8939
- info: function(...args) {
8940
- return process.emit("log", "info", ...args);
8941
- },
8942
- verbose: function(...args) {
8943
- return process.emit("log", "verbose", ...args);
8944
- },
8945
- http: function(...args) {
8946
- return process.emit("log", "http", ...args);
8947
- },
8948
- silly: function(...args) {
8949
- return process.emit("log", "silly", ...args);
8950
- },
8951
- timing: function(...args) {
8952
- return process.emit("log", "timing", ...args);
8953
- },
8954
- pause: function() {
8955
- return process.emit("log", "pause");
8956
- },
8957
- resume: function() {
8958
- return process.emit("log", "resume");
8959
- }
8960
- },
8961
- time: {
8962
- LEVELS: ["start", "end"],
8963
- KEYS: {
8964
- start: "start",
8965
- end: "end"
8966
- },
8967
- start: function(name, fn) {
8968
- process.emit("time", "start", name);
8969
- function end() {
8970
- return process.emit("time", "end", name);
8971
- }
8972
- if (typeof fn === "function") {
8973
- const res = fn();
8974
- if (res && res.finally) return res.finally(end);
8975
- end();
8976
- return res;
8977
- }
8978
- return end;
8979
- },
8980
- end: function(name) {
8981
- return process.emit("time", "end", name);
8982
- }
8983
- },
8984
- input: {
8985
- LEVELS: [
8986
- "start",
8987
- "end",
8988
- "read"
8989
- ],
8990
- KEYS: {
8991
- start: "start",
8992
- end: "end",
8993
- read: "read"
8994
- },
8995
- start: function(...args) {
8996
- let fn;
8997
- if (typeof args[0] === "function") fn = args.shift();
8998
- process.emit("input", "start", ...args);
8999
- function end() {
9000
- return process.emit("input", "end", ...args);
9001
- }
9002
- if (typeof fn === "function") {
9003
- const res = fn();
9004
- if (res && res.finally) return res.finally(end);
9005
- end();
9006
- return res;
9007
- }
9008
- return end;
9009
- },
9010
- end: function(...args) {
9011
- return process.emit("input", "end", ...args);
9012
- },
9013
- read: function(...args) {
9014
- let resolve, reject;
9015
- const promise = new Promise((_resolve, _reject) => {
9016
- resolve = _resolve;
9017
- reject = _reject;
9018
- });
9019
- process.emit("input", "read", resolve, reject, ...args);
9020
- return promise;
9021
- }
9022
- }
9023
- };
9024
- }));
9025
- //#endregion
9026
- //#region ../harness/src/plugin/package.ts
9027
- var import_npa = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
9028
- const isWindows = process.platform === "win32";
9029
- const { URL: URL$1 } = __require("node:url");
9030
- const path$1 = isWindows ? __require("node:path/win32") : __require("node:path");
9031
- const { homedir: homedir$1 } = __require("node:os");
9032
- const HostedGit = require_lib$2();
9033
- const semver = require_semver();
9034
- const validatePackageName = require_lib$1();
9035
- const { log } = require_lib();
9036
- const hasSlashes = isWindows ? /\\|[/]/ : /[/]/;
9037
- const isURL = /^(?:git[+])?[a-z]+:/i;
9038
- const isGit = /^[^@]+@[^:.]+\.[^:]+:.+$/i;
9039
- const isFileType = /[.](?:tgz|tar\.gz|tar)$/i;
9040
- const isPortNumber = /:[0-9]+(\/|$)/i;
9041
- const isWindowsFile = /^(?:[.]|~[/]|[/\\]|[a-zA-Z]:)/;
9042
- const isPosixFile = /^(?:[.]|~[/]|[/]|[a-zA-Z]:)/;
9043
- const defaultRegistry = "https://registry.npmjs.org";
9044
- function npa(arg, where) {
9045
- let name;
9046
- let spec;
9047
- if (typeof arg === "object") {
9048
- if (arg instanceof Result && (!where || where === arg.where)) return arg;
9049
- else if (arg.name && arg.rawSpec) return npa.resolve(arg.name, arg.rawSpec, where || arg.where);
9050
- else return npa(arg.raw, where || arg.where);
9051
- }
9052
- const nameEndsAt = arg.indexOf("@", 1);
9053
- const namePart = nameEndsAt > 0 ? arg.slice(0, nameEndsAt) : arg;
9054
- if (isURL.test(arg)) spec = arg;
9055
- else if (isGit.test(arg)) spec = `git+ssh://${arg}`;
9056
- else if (!namePart.startsWith("@") && (hasSlashes.test(namePart) || isFileType.test(namePart))) spec = arg;
9057
- else if (nameEndsAt > 0) {
9058
- name = namePart;
9059
- spec = arg.slice(nameEndsAt + 1) || "*";
9060
- } else if (validatePackageName(arg).validForOldPackages) {
9061
- name = arg;
9062
- spec = "*";
9063
- } else spec = arg;
9064
- return resolve(name, spec, where, arg);
9065
- }
9066
- function isFileSpec(spec) {
9067
- if (!spec) return false;
9068
- if (spec.toLowerCase().startsWith("file:")) return true;
9069
- if (isWindows) return isWindowsFile.test(spec);
9070
- return isPosixFile.test(spec);
9071
- }
9072
- function isAliasSpec(spec) {
9073
- if (!spec) return false;
9074
- return spec.toLowerCase().startsWith("npm:");
9075
- }
9076
- function resolve(name, spec, where, arg) {
9077
- const res = new Result({
9078
- raw: arg,
9079
- name,
9080
- rawSpec: spec,
9081
- fromArgument: arg != null
9082
- });
9083
- if (name) res.name = name;
9084
- if (!where) where = process.cwd();
9085
- if (isFileSpec(spec)) return fromFile(res, where);
9086
- else if (isAliasSpec(spec)) return fromAlias(res, where);
9087
- const hosted = HostedGit.fromUrl(spec, {
9088
- noGitPlus: true,
9089
- noCommittish: true
9090
- });
9091
- if (hosted) return fromHostedGit(res, hosted);
9092
- else if (spec && isURL.test(spec)) return fromURL(res);
9093
- else if (spec && (hasSlashes.test(spec) || isFileType.test(spec))) return fromFile(res, where);
9094
- else return fromRegistry(res);
9095
- }
9096
- function toPurl(arg, reg = defaultRegistry) {
9097
- const res = npa(arg);
9098
- if (res.type !== "version") throw invalidPurlType(res.type, res.raw);
9099
- let purl = "pkg:npm/" + res.name.replace(/^@/, "%40") + "@" + res.rawSpec;
9100
- if (reg !== defaultRegistry) purl += "?repository_url=" + reg;
9101
- return purl;
9102
- }
9103
- function invalidPackageName(name, valid, raw) {
9104
- const err = /* @__PURE__ */ new Error(`Invalid package name "${name}" of package "${raw}": ${valid.errors.join("; ")}.`);
9105
- err.code = "EINVALIDPACKAGENAME";
9106
- return err;
9107
- }
9108
- function invalidTagName(name, raw) {
9109
- const err = /* @__PURE__ */ new Error(`Invalid tag name "${name}" of package "${raw}": Tags may not have any characters that encodeURIComponent encodes.`);
9110
- err.code = "EINVALIDTAGNAME";
9111
- return err;
9112
- }
9113
- function invalidPurlType(type, raw) {
9114
- const err = /* @__PURE__ */ new Error(`Invalid type "${type}" of package "${raw}": Purl can only be generated for "version" types.`);
9115
- err.code = "EINVALIDPURLTYPE";
9116
- return err;
9117
- }
9118
- var Result = class {
9119
- constructor(opts) {
9120
- this.type = opts.type;
9121
- this.registry = opts.registry;
9122
- this.where = opts.where;
9123
- if (opts.raw == null) this.raw = opts.name ? `${opts.name}@${opts.rawSpec}` : opts.rawSpec;
9124
- else this.raw = opts.raw;
9125
- this.name = void 0;
9126
- this.escapedName = void 0;
9127
- this.scope = void 0;
9128
- this.rawSpec = opts.rawSpec || "";
9129
- this.saveSpec = opts.saveSpec;
9130
- this.fetchSpec = opts.fetchSpec;
9131
- if (opts.name) this.setName(opts.name);
9132
- this.gitRange = opts.gitRange;
9133
- this.gitCommittish = opts.gitCommittish;
9134
- this.gitSubdir = opts.gitSubdir;
9135
- this.hosted = opts.hosted;
9136
- }
9137
- setName(name) {
9138
- const valid = validatePackageName(name);
9139
- if (!valid.validForOldPackages) throw invalidPackageName(name, valid, this.raw);
9140
- this.name = name;
9141
- this.scope = name[0] === "@" ? name.slice(0, name.indexOf("/")) : void 0;
9142
- this.escapedName = name.replace("/", "%2f");
9143
- return this;
9144
- }
9145
- toString() {
9146
- const full = [];
9147
- if (this.name != null && this.name !== "") full.push(this.name);
9148
- const spec = this.saveSpec || this.fetchSpec || this.rawSpec;
9149
- if (spec != null && spec !== "") full.push(spec);
9150
- return full.length ? full.join("@") : this.raw;
9151
- }
9152
- toJSON() {
9153
- const result = Object.assign({}, this);
9154
- delete result.hosted;
9155
- return result;
9156
- }
9157
- };
9158
- function setGitAttrs(res, committish) {
9159
- if (!committish) {
9160
- res.gitCommittish = null;
9161
- return;
9162
- }
9163
- for (const part of committish.split("::")) {
9164
- if (!part.includes(":")) {
9165
- if (res.gitRange) throw new Error("cannot override existing semver range with a committish");
9166
- if (res.gitCommittish) throw new Error("cannot override existing committish with a second committish");
9167
- res.gitCommittish = part;
9168
- continue;
9169
- }
9170
- const [name, value] = part.split(":");
9171
- if (name === "semver") {
9172
- if (res.gitCommittish) throw new Error("cannot override existing committish with a semver range");
9173
- if (res.gitRange) throw new Error("cannot override existing semver range with a second semver range");
9174
- res.gitRange = decodeURIComponent(value);
9175
- continue;
9176
- }
9177
- if (name === "path") {
9178
- if (res.gitSubdir) throw new Error("cannot override existing path with a second path");
9179
- res.gitSubdir = `/${value}`;
9180
- continue;
9181
- }
9182
- log.warn("npm-package-arg", `ignoring unknown key "${name}"`);
9183
- }
9184
- }
9185
- const encodedPathChars = /* @__PURE__ */ new Map([
9186
- ["\0", "%00"],
9187
- [" ", "%09"],
9188
- ["\n", "%0A"],
9189
- ["\r", "%0D"],
9190
- [" ", "%20"],
9191
- ["\"", "%22"],
9192
- ["#", "%23"],
9193
- ["%", "%25"],
9194
- ["?", "%3F"],
9195
- ["[", "%5B"],
9196
- ["\\", isWindows ? "/" : "%5C"],
9197
- ["]", "%5D"],
9198
- ["^", "%5E"],
9199
- ["|", "%7C"],
9200
- ["~", "%7E"]
9201
- ]);
9202
- function pathToFileURL(str) {
9203
- let result = "";
9204
- for (let i = 0; i < str.length; i++) result = `${result}${encodedPathChars.get(str[i]) ?? str[i]}`;
9205
- if (result.startsWith("file:")) return result;
9206
- return `file:${result}`;
9207
- }
9208
- function fromFile(res, where) {
9209
- res.type = isFileType.test(res.rawSpec) ? "file" : "directory";
9210
- res.where = where;
9211
- let rawSpec = pathToFileURL(res.rawSpec);
9212
- if (rawSpec.startsWith("file:/")) {
9213
- if (/^file:\/\/[^/]/.test(rawSpec)) rawSpec = `file:/${rawSpec.slice(5)}`;
9214
- if (/^\/{1,3}\.\.?(\/|$)/.test(rawSpec.slice(5))) rawSpec = rawSpec.replace(/^file:\/{1,3}/, "file:");
9215
- }
9216
- let resolvedUrl;
9217
- let specUrl;
9218
- try {
9219
- resolvedUrl = new URL$1(rawSpec, `${pathToFileURL(path$1.resolve(where))}/`);
9220
- specUrl = new URL$1(rawSpec);
9221
- } catch (originalError) {
9222
- throw Object.assign(/* @__PURE__ */ new Error("Invalid file: URL, must comply with RFC 8089"), {
9223
- raw: res.rawSpec,
9224
- spec: res,
9225
- where,
9226
- originalError
9227
- });
9228
- }
9229
- let specPath = decodeURIComponent(specUrl.pathname);
9230
- let resolvedPath = decodeURIComponent(resolvedUrl.pathname);
9231
- if (isWindows) {
9232
- specPath = specPath.replace(/^\/+([a-z]:\/)/i, "$1");
9233
- resolvedPath = resolvedPath.replace(/^\/+([a-z]:\/)/i, "$1");
9234
- }
9235
- if (/^\/~(\/|$)/.test(specPath)) {
9236
- res.saveSpec = `file:${specPath.substr(1)}`;
9237
- resolvedPath = path$1.resolve(homedir$1(), specPath.substr(3));
9238
- } else if (!path$1.isAbsolute(rawSpec.slice(5))) res.saveSpec = `file:${path$1.relative(where, resolvedPath)}`;
9239
- else res.saveSpec = `file:${path$1.resolve(resolvedPath)}`;
9240
- res.fetchSpec = path$1.resolve(where, resolvedPath);
9241
- res.saveSpec = res.saveSpec.split("\\").join("/");
9242
- /* istanbul ignore next */
9243
- if (res.saveSpec.startsWith("file://")) res.saveSpec = `file:/${res.saveSpec.slice(7)}`;
9244
- return res;
9245
- }
9246
- function fromHostedGit(res, hosted) {
9247
- res.type = "git";
9248
- res.hosted = hosted;
9249
- res.saveSpec = hosted.toString({
9250
- noGitPlus: false,
9251
- noCommittish: false
9252
- });
9253
- res.fetchSpec = hosted.getDefaultRepresentation() === "shortcut" ? null : hosted.toString();
9254
- setGitAttrs(res, hosted.committish);
9255
- return res;
9256
- }
9257
- function unsupportedURLType(protocol, spec) {
9258
- const err = /* @__PURE__ */ new Error(`Unsupported URL Type "${protocol}": ${spec}`);
9259
- err.code = "EUNSUPPORTEDPROTOCOL";
9260
- return err;
9261
- }
9262
- function fromURL(res) {
9263
- let rawSpec = res.rawSpec;
9264
- res.saveSpec = rawSpec;
9265
- if (rawSpec.startsWith("git+ssh:")) {
9266
- const matched = rawSpec.match(/^git\+ssh:\/\/([^:#]+:[^#]+(?:\.git)?)(?:#(.*))?$/i);
9267
- if (matched && !matched[1].match(isPortNumber)) {
9268
- res.type = "git";
9269
- setGitAttrs(res, matched[2]);
9270
- res.fetchSpec = matched[1];
9271
- return res;
9272
- }
9273
- } else if (rawSpec.startsWith("git+file://")) rawSpec = rawSpec.replace(/\\/g, "/");
9274
- const parsedUrl = new URL$1(rawSpec);
9275
- switch (parsedUrl.protocol) {
9276
- case "git:":
9277
- case "git+http:":
9278
- case "git+https:":
9279
- case "git+rsync:":
9280
- case "git+ftp:":
9281
- case "git+file:":
9282
- case "git+ssh:":
9283
- res.type = "git";
9284
- setGitAttrs(res, parsedUrl.hash.slice(1));
9285
- if (parsedUrl.protocol === "git+file:" && /^git\+file:\/\/[a-z]:/i.test(rawSpec)) res.fetchSpec = `git+file://${parsedUrl.host.toLowerCase()}:${parsedUrl.pathname}`;
9286
- else {
9287
- parsedUrl.hash = "";
9288
- res.fetchSpec = parsedUrl.toString();
9289
- }
9290
- if (res.fetchSpec.startsWith("git+")) res.fetchSpec = res.fetchSpec.slice(4);
9291
- break;
9292
- case "http:":
9293
- case "https:":
9294
- res.type = "remote";
9295
- res.fetchSpec = res.saveSpec;
9296
- break;
9297
- default: throw unsupportedURLType(parsedUrl.protocol, rawSpec);
9298
- }
9299
- return res;
9300
- }
9301
- function fromAlias(res, where) {
9302
- const subSpec = npa(res.rawSpec.substr(4), where);
9303
- if (subSpec.type === "alias") throw new Error("nested aliases not supported");
9304
- if (!subSpec.registry) throw new Error("aliases only work for registry deps");
9305
- if (!subSpec.name) throw new Error("aliases must have a name");
9306
- res.subSpec = subSpec;
9307
- res.registry = true;
9308
- res.type = "alias";
9309
- res.saveSpec = null;
9310
- res.fetchSpec = null;
9311
- return res;
9312
- }
9313
- function fromRegistry(res) {
9314
- res.registry = true;
9315
- const spec = res.rawSpec.trim();
9316
- res.saveSpec = null;
9317
- res.fetchSpec = spec;
9318
- const version = semver.valid(spec, true);
9319
- const range = semver.validRange(spec, true);
9320
- if (version) res.type = "version";
9321
- else if (range) res.type = "range";
9322
- else {
9323
- if (encodeURIComponent(spec) !== spec) throw invalidTagName(spec, res.raw);
9324
- res.type = "tag";
9325
- }
9326
- return res;
9327
- }
9328
- module.exports = npa;
9329
- module.exports.resolve = resolve;
9330
- module.exports.toPurl = toPurl;
9331
- module.exports.Result = Result;
9332
- })))(), 1);
9333
- const parse$1 = (source) => {
9334
- const parsed = (0, import_npa.default)(source);
9335
- if (!parsed.name || ![
9336
- "version",
9337
- "range",
9338
- "tag"
9339
- ].includes(parsed.type)) throw new Error(`Unsupported plugin package source: ${source}`);
9340
- const omitted = parsed.raw === parsed.name || parsed.raw === `${parsed.name}@`;
9341
- return {
9342
- name: parsed.name,
9343
- spec: `${parsed.name}@${omitted ? "latest" : parsed.rawSpec}`
9344
- };
9345
- };
9346
- const Manifest$1 = Schema.Struct({ version: Schema.String });
9347
- const Cached = Schema.Struct({
9348
- version: Schema.String,
9349
- spec: Schema.String,
9350
- entrypoint: Schema.String
9351
- });
9352
- /** Runs inside the isolated staging directory. Override only for deterministic tests. */
9353
- var InstallError = class extends Schema.TaggedError()("PluginInstallError", { cause: Schema.Defect() }) {};
9354
- const run$3 = Effect.fn("PluginPackage.run")(function* (request, directory) {
9355
- const code = yield* (yield* (yield* ChildProcessSpawner.ChildProcessSpawner).spawn(ChildProcess.make("pnpm", [
9356
- "add",
9357
- "--ignore-scripts",
9358
- "--ignore-workspace",
9359
- "--save-exact",
9360
- request.spec
9361
- ], {
9362
- cwd: directory,
9363
- stdout: "ignore",
9364
- stderr: "inherit"
9365
- }))).exitCode;
9366
- if (code !== 0) return yield* new InstallError({ cause: /* @__PURE__ */ new Error(`pnpm installation failed with exit code ${code}`) });
9367
- }, Effect.scoped, Effect.provide(NodeChildProcessSpawner.layer.pipe(Layer.provide(Layer.merge(NodeFileSystem.layer, NodePath.layer)))), Effect.mapError((cause) => Schema.is(InstallError)(cause) ? cause : new InstallError({ cause })));
9368
- /** How long to wait for another installer of the same spec before giving up. */
9369
- const LOCK_TIMEOUT = Duration.minutes(2);
9370
- /** The holder refreshes the lock's mtime this often; a lock not refreshed for the timeout is abandoned. */
9371
- const LOCK_HEARTBEAT = Duration.seconds(15);
9372
- /**
9373
- * A lock whose holder stopped refreshing it was left by a crashed installer. Staleness is
9374
- * measured from the heartbeat, not the install's start, so a slow but live install is never
9375
- * stolen from.
9376
- */
9377
- const abandoned = (directory) => Effect.gen(function* () {
9378
- const info = yield* fileSystem.stat(directory);
9379
- const now = yield* Effect.clockWith((clock) => clock.currentTimeMillis);
9380
- return Option.exists(info.mtime, (mtime) => now - mtime.getTime() > Duration.toMillis(LOCK_TIMEOUT));
9381
- }).pipe(Effect.orElseSucceed(() => false));
9382
- const heartbeat = (directory) => Effect.clockWith((clock) => clock.currentTimeMillis).pipe(Effect.flatMap((now) => fileSystem.utimes(directory, now, now)), Effect.ignore, Effect.repeat(Schedule.spaced(LOCK_HEARTBEAT)));
9383
- /**
9384
- * Claims `directory` by creating it, polling while another process holds it.
9385
- *
9386
- * One finalizer for the whole wait, registered before the first attempt: retrying inside
9387
- * `acquireRelease` would add a finalizer per poll. A crashed installer leaves its lock
9388
- * behind; an abandoned one is reclaimed rather than waited on forever, and the wait itself
9389
- * is bounded. While held, the lock is heartbeated so waiters can tell live from dead.
9390
- */
9391
- const lock = Effect.fn("PluginPackage.lock")(function* (directory) {
9392
- const held = yield* Ref.make(false);
9393
- yield* Effect.acquireRelease(Effect.void, () => Ref.get(held).pipe(Effect.flatMap((owned) => owned ? fileSystem.remove(directory, {
9394
- recursive: true,
9395
- force: true
9396
- }) : Effect.void), Effect.orDie));
9397
- if (!(yield* fileSystem.makeDirectory(directory).pipe(Effect.andThen(Ref.set(held, true)), Effect.as(true), Effect.catchIf((error) => error.reason._tag === "AlreadyExists", () => abandoned(directory).pipe(Effect.flatMap((stale) => stale ? fileSystem.remove(directory, {
9398
- recursive: true,
9399
- force: true
9400
- }).pipe(Effect.as(false)) : Effect.succeed(false)))), Effect.uninterruptible).pipe(Effect.repeat({
9401
- schedule: Schedule.spaced("50 millis"),
9402
- until: (owned) => owned
9403
- }), Effect.timeoutOrElse({
9404
- duration: LOCK_TIMEOUT,
9405
- orElse: () => Effect.succeed(false)
9406
- })))) return yield* new InstallError({ cause: /* @__PURE__ */ new Error(`Timed out waiting for another plugin installation to release ${directory}`) });
9407
- yield* Effect.forkScoped(heartbeat(directory));
9408
- });
9409
- const install = Effect.fn("PluginPackage.install")(function* (request, cache, runner = run$3) {
9410
- const root = hostPath.join(cache, "plugins");
9411
- const key = Encoding.encodeHex(yield* crypto.digest("SHA-256", new TextEncoder().encode(request.spec)));
9412
- const directory = hostPath.join(root, key);
9413
- const marker = hostPath.join(directory, ".complete.json");
9414
- yield* fileSystem.makeDirectory(root, { recursive: true });
9415
- if (!(yield* fileSystem.exists(marker))) yield* lock(`${directory}.lock`);
9416
- if (!(yield* fileSystem.exists(marker))) {
9417
- const staging = yield* Effect.acquireRelease(fileSystem.makeTempDirectory({
9418
- directory: root,
9419
- prefix: `${key}-`
9420
- }), (staging) => fileSystem.remove(staging, {
9421
- recursive: true,
9422
- force: true
9423
- }).pipe(Effect.orDie));
9424
- yield* fileSystem.writeFileString(hostPath.join(staging, "package.json"), "{\"private\":true,\"type\":\"module\"}");
9425
- yield* runner(request, staging);
9426
- const manifest = yield* fileSystem.readFileString(hostPath.join(staging, "node_modules", request.name, "package.json"));
9427
- const installed = yield* Schema.decodeEffect(Schema.fromJsonString(Manifest$1))(manifest);
9428
- const entrypoint = yield* Effect.try(() => resolveModule(request.name, staging));
9429
- const entry = hostPath.relative(yield* fileSystem.realPath(staging), fileURLToPath(entrypoint));
9430
- if (entry.startsWith("..") || hostPath.isAbsolute(entry)) return yield* new InstallError({ cause: /* @__PURE__ */ new Error(`Plugin entrypoint escapes its installation: ${entry}`) });
9431
- yield* fileSystem.writeFileString(hostPath.join(staging, ".complete.json"), yield* Schema.encodeEffect(Schema.fromJsonString(Cached))({
9432
- spec: request.spec,
9433
- version: installed.version,
9434
- entrypoint: entry
9435
- }));
9436
- if (yield* fileSystem.exists(directory)) yield* fileSystem.remove(directory, { recursive: true });
9437
- yield* fileSystem.rename(staging, directory);
9438
- }
9439
- const saved = yield* fileSystem.readFileString(marker).pipe(Effect.flatMap(Schema.decodeUnknownEffect(Schema.fromJsonString(Cached))));
9440
- if (saved.spec !== request.spec) return yield* new InstallError({ cause: /* @__PURE__ */ new Error("Plugin package cache request mismatch") });
9441
- return {
9442
- url: pathToFileURL(hostPath.resolve(directory, saved.entrypoint)).href,
9443
- version: saved.version
9444
- };
9445
- }, Effect.scoped, Effect.mapError((cause) => Schema.is(InstallError)(cause) ? cause : new InstallError({ cause })));
9446
- const Id = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9-]*(\.[a-z0-9][a-z0-9-]*){2}$/));
9447
- const Definition = Schema.Struct({
9448
- id: Id,
9449
- events: Schema.optional(Schema.Array(Schema.declare((value) => Predicate.hasProperty(value, "type") && Predicate.isString(value.type)))),
9450
- setup: Schema.declare((value) => Predicate.isFunction(value))
9451
- });
9452
- var PreparationError = class extends Schema.TaggedError()("PluginPreparationError", {
9453
- phase: Schema.Literals([
9454
- "source",
9455
- "install",
9456
- "import",
9457
- "definition"
9458
- ]),
9459
- index: Schema.Finite,
9460
- reference: Schema.String,
9461
- id: Schema.optional(Schema.String),
9462
- cause: Schema.Defect()
9463
- }) {};
9464
- const failure$1 = (origin, phase, cause, id) => new PreparationError({
9465
- ...origin,
9466
- phase,
9467
- cause,
9468
- ...id === void 0 ? {} : { id }
9469
- });
9470
- const validate = Effect.fn("PluginLoader.validate")(function* (input, origin, builtin = false) {
9471
- yield* Schema.decodeUnknownEffect(Definition)(input).pipe(Effect.mapError((cause) => failure$1(origin, "definition", cause)));
9472
- const plugin = input;
9473
- if (!builtin && plugin.id.startsWith("codework.")) return yield* failure$1(origin, "definition", /* @__PURE__ */ new Error("codework namespace is reserved for builtins"), plugin.id);
9474
- return plugin;
9475
- });
9476
- /**
9477
- * A reference is a source and nothing else: a path, a `file:` URL, or a package spec. IDs are
9478
- * not spelled here — a bare `acme.tool.proc` is a package name, and the plugin it names is
9479
- * addressed by `{ plugin: "acme.tool.proc" }`, which resolves against what is already registered.
9480
- */
9481
- const classify = (source, hostCwd) => {
9482
- if (source.startsWith("file:")) {
9483
- if (!source.startsWith("file:///")) throw new Error(`not an absolute file URL: ${source}`);
9484
- return {
9485
- kind: "local",
9486
- path: fileURLToPath(source)
9487
- };
9488
- }
9489
- const expanded = expandTilde(source, hostPath);
9490
- if (expanded.startsWith("./") || expanded.startsWith("../") || hostPath.isAbsolute(expanded)) return {
9491
- kind: "local",
9492
- path: hostPath.resolve(hostCwd, expanded)
9493
- };
9494
- return {
9495
- kind: "package",
9496
- request: parse$1(source)
9497
- };
9498
- };
9499
- const Manifest = Schema.Struct({
9500
- name: Schema.optional(Schema.String),
9501
- exports: Schema.optional(Schema.Unknown)
9502
- });
9503
- const localUrl = Effect.fn("PluginLoader.localUrl")(function* (location, origin) {
9504
- if ((yield* fileSystem.stat(location)).type !== "Directory") return { url: yield* Effect.try(() => resolveModule(location, hostPath.dirname(location))) };
9505
- const manifestPath = hostPath.join(location, "package.json");
9506
- if (!(yield* fileSystem.exists(manifestPath))) return { url: yield* Effect.try(() => resolveModule("./index", location)) };
9507
- const manifest = yield* fileSystem.readFileString(manifestPath).pipe(Effect.flatMap(Schema.decodeUnknownEffect(Schema.fromJsonString(Manifest))));
9508
- if (manifest.exports !== void 0) {
9509
- const name = manifest.name;
9510
- if (!name) return yield* failure$1(origin, "source", /* @__PURE__ */ new Error("A local package with exports must declare its name"));
9511
- const url = yield* Effect.try(() => resolveModule(name, location));
9512
- const resolved = yield* fileSystem.realPath(fileURLToPath(url));
9513
- if (hostPath.relative(yield* fileSystem.realPath(location), resolved).startsWith("..")) return yield* failure$1(origin, "source", /* @__PURE__ */ new Error("Package export escapes its root"));
9514
- return {
9515
- url: pathToFileURL(resolved).href,
9516
- name
6365
+ return {
6366
+ kind: "package",
6367
+ request: parse$2(source)
6368
+ };
6369
+ };
6370
+ const Manifest = Schema.Struct({
6371
+ name: Schema.optional(Schema.String),
6372
+ exports: Schema.optional(Schema.Unknown)
6373
+ });
6374
+ const localUrl = Effect.fn("PluginLoader.localUrl")(function* (location, origin) {
6375
+ if ((yield* fileSystem.stat(location)).type !== "Directory") return { url: yield* Effect.try(() => resolveModule(location, hostPath.dirname(location))) };
6376
+ const manifestPath = hostPath.join(location, "package.json");
6377
+ if (!(yield* fileSystem.exists(manifestPath))) return { url: yield* Effect.try(() => resolveModule("./index", location)) };
6378
+ const manifest = yield* fileSystem.readFileString(manifestPath).pipe(Effect.flatMap(Schema.decodeUnknownEffect(Schema.fromJsonString(Manifest))));
6379
+ if (manifest.exports !== void 0) {
6380
+ const name = manifest.name;
6381
+ if (!name) return yield* failure$1(origin, "source", /* @__PURE__ */ new Error("A local package with exports must declare its name"));
6382
+ const url = yield* Effect.try(() => resolveModule(name, location));
6383
+ const resolved = yield* fileSystem.realPath(fileURLToPath(url));
6384
+ if (hostPath.relative(yield* fileSystem.realPath(location), resolved).startsWith("..")) return yield* failure$1(origin, "source", /* @__PURE__ */ new Error("Package export escapes its root"));
6385
+ return {
6386
+ url: pathToFileURL(resolved).href,
6387
+ name
9517
6388
  };
9518
6389
  }
9519
6390
  const url = yield* Effect.try(() => resolveModule(createRequire(pathToFileURL(manifestPath)).resolve(location), location));
@@ -9661,7 +6532,7 @@ const prepare = Effect.fn("PluginCatalog.prepare")(function* (references, option
9661
6532
  });
9662
6533
  //#endregion
9663
6534
  //#region ../harness/src/plugin/plugin.ts
9664
- const define$2 = (plugin) => plugin;
6535
+ const define$1 = (plugin) => plugin;
9665
6536
  //#endregion
9666
6537
  //#region ../harness/src/plugin/builtin/prompt/default.ts
9667
6538
  /** The default coding-agent foundation, used unless `promptCustom` replaces it. */
@@ -9723,7 +6594,7 @@ const assemble = (input) => {
9723
6594
  * host attributes to this plugin's id.
9724
6595
  */
9725
6596
  const slot = (ctx, resolver) => Effect.tryPromise(() => Promise.resolve(resolver?.(ctx)));
9726
- const defaultPromptPlugin = define$2({
6597
+ const defaultPromptPlugin = define$1({
9727
6598
  id: "codework.prompt.default",
9728
6599
  setup: Effect.fn("DefaultPromptPlugin.setup")(function* (ctx) {
9729
6600
  const custom = yield* slot(ctx, ctx.config.promptCustom);
@@ -10075,7 +6946,7 @@ const ToolCallContext = Schema.Struct({
10075
6946
  rawArgs: Schema.Record(Schema.String, Schema.Unknown)
10076
6947
  });
10077
6948
  /** Define a pure tool (handler attached later via {@link implement} or a toolkit). */
10078
- const define$1 = (input) => ({ ...input });
6949
+ const define = (input) => ({ ...input });
10079
6950
  /** Attach a handler to an existing definition (the testable def/exec split). */
10080
6951
  const implement = (definition, handler) => ({
10081
6952
  definition,
@@ -10156,7 +7027,7 @@ var BashTimedOut = class extends Schema.TaggedError()("BashTimedOut", {
10156
7027
  timeoutSeconds: Schema.Finite
10157
7028
  }) {};
10158
7029
  const BashFailure = Schema.Union([BashFailed, BashTimedOut]);
10159
- const bashDef = define$1({
7030
+ const bashDef = define({
10160
7031
  name: "bash",
10161
7032
  label: "bash",
10162
7033
  promptSnippet: "Execute bash commands (ls, grep, find, etc.).",
@@ -10282,7 +7153,7 @@ const bashHandler = (params) => Effect.gen(function* () {
10282
7153
  });
10283
7154
  /** The bash tool: definition + handler, wired the testable (def/exec split) way. */
10284
7155
  const bashTool = implement(bashDef, bashHandler);
10285
- const bashPlugin = define$2({
7156
+ const bashPlugin = define$1({
10286
7157
  id: "codework.tool.bash",
10287
7158
  setup: Effect.fn("BashPlugin.setup")(function* (ctx) {
10288
7159
  const shell = yield* Shell;
@@ -11374,196 +8245,6 @@ const layer$7 = Layer.effect(Service$2, Effect.gen(function* () {
11374
8245
  }));
11375
8246
  //#endregion
11376
8247
  //#region ../harness/src/settings/settings.ts
11377
- var import_main = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
11378
- (function(factory) {
11379
- if (typeof module === "object" && typeof module.exports === "object") {
11380
- var v = factory(__require, exports);
11381
- if (v !== void 0) module.exports = v;
11382
- } else if (typeof define === "function" && define.amd) define([
11383
- "require",
11384
- "exports",
11385
- "./impl/format",
11386
- "./impl/edit",
11387
- "./impl/scanner",
11388
- "./impl/parser"
11389
- ], factory);
11390
- })(function(require, exports$1) {
11391
- "use strict";
11392
- Object.defineProperty(exports$1, "__esModule", { value: true });
11393
- exports$1.applyEdits = exports$1.modify = exports$1.format = exports$1.printParseErrorCode = exports$1.ParseErrorCode = exports$1.stripComments = exports$1.visit = exports$1.getNodeValue = exports$1.getNodePath = exports$1.findNodeAtOffset = exports$1.findNodeAtLocation = exports$1.parseTree = exports$1.parse = exports$1.getLocation = exports$1.SyntaxKind = exports$1.ScanError = exports$1.createScanner = void 0;
11394
- const formatter = require("./impl/format");
11395
- const edit = require("./impl/edit");
11396
- const scanner = require("./impl/scanner");
11397
- const parser = require("./impl/parser");
11398
- /**
11399
- * Creates a JSON scanner on the given text.
11400
- * If ignoreTrivia is set, whitespaces or comments are ignored.
11401
- */
11402
- exports$1.createScanner = scanner.createScanner;
11403
- var ScanError;
11404
- (function(ScanError) {
11405
- ScanError[ScanError["None"] = 0] = "None";
11406
- ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
11407
- ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
11408
- ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
11409
- ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
11410
- ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
11411
- ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
11412
- })(ScanError || (exports$1.ScanError = ScanError = {}));
11413
- var SyntaxKind;
11414
- (function(SyntaxKind) {
11415
- SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
11416
- SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
11417
- SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
11418
- SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
11419
- SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
11420
- SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
11421
- SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
11422
- SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
11423
- SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
11424
- SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
11425
- SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
11426
- SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
11427
- SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
11428
- SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
11429
- SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
11430
- SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
11431
- SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
11432
- })(SyntaxKind || (exports$1.SyntaxKind = SyntaxKind = {}));
11433
- /**
11434
- * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
11435
- */
11436
- exports$1.getLocation = parser.getLocation;
11437
- /**
11438
- * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
11439
- * Therefore, always check the errors list to find out if the input was valid.
11440
- */
11441
- exports$1.parse = parser.parse;
11442
- /**
11443
- * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
11444
- */
11445
- exports$1.parseTree = parser.parseTree;
11446
- /**
11447
- * Finds the node at the given path in a JSON DOM.
11448
- */
11449
- exports$1.findNodeAtLocation = parser.findNodeAtLocation;
11450
- /**
11451
- * Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
11452
- */
11453
- exports$1.findNodeAtOffset = parser.findNodeAtOffset;
11454
- /**
11455
- * Gets the JSON path of the given JSON DOM node
11456
- */
11457
- exports$1.getNodePath = parser.getNodePath;
11458
- /**
11459
- * Evaluates the JavaScript object of the given JSON DOM node
11460
- */
11461
- exports$1.getNodeValue = parser.getNodeValue;
11462
- /**
11463
- * Parses the given text and invokes the visitor functions for each object, array and literal reached.
11464
- */
11465
- exports$1.visit = parser.visit;
11466
- /**
11467
- * Takes JSON with JavaScript-style comments and remove
11468
- * them. Optionally replaces every none-newline character
11469
- * of comments with a replaceCharacter
11470
- */
11471
- exports$1.stripComments = parser.stripComments;
11472
- var ParseErrorCode;
11473
- (function(ParseErrorCode) {
11474
- ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
11475
- ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
11476
- ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
11477
- ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
11478
- ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
11479
- ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
11480
- ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
11481
- ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
11482
- ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
11483
- ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
11484
- ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
11485
- ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
11486
- ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
11487
- ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
11488
- ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
11489
- ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
11490
- })(ParseErrorCode || (exports$1.ParseErrorCode = ParseErrorCode = {}));
11491
- function printParseErrorCode(code) {
11492
- switch (code) {
11493
- case 1: return "InvalidSymbol";
11494
- case 2: return "InvalidNumberFormat";
11495
- case 3: return "PropertyNameExpected";
11496
- case 4: return "ValueExpected";
11497
- case 5: return "ColonExpected";
11498
- case 6: return "CommaExpected";
11499
- case 7: return "CloseBraceExpected";
11500
- case 8: return "CloseBracketExpected";
11501
- case 9: return "EndOfFileExpected";
11502
- case 10: return "InvalidCommentToken";
11503
- case 11: return "UnexpectedEndOfComment";
11504
- case 12: return "UnexpectedEndOfString";
11505
- case 13: return "UnexpectedEndOfNumber";
11506
- case 14: return "InvalidUnicode";
11507
- case 15: return "InvalidEscapeCharacter";
11508
- case 16: return "InvalidCharacter";
11509
- }
11510
- return "<unknown ParseErrorCode>";
11511
- }
11512
- exports$1.printParseErrorCode = printParseErrorCode;
11513
- /**
11514
- * Computes the edit operations needed to format a JSON document.
11515
- *
11516
- * @param documentText The input text
11517
- * @param range The range to format or `undefined` to format the full content
11518
- * @param options The formatting options
11519
- * @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.
11520
- * To apply the edit operations to the input, use {@linkcode applyEdits}.
11521
- */
11522
- function format(documentText, range, options) {
11523
- return formatter.format(documentText, range, options);
11524
- }
11525
- exports$1.format = format;
11526
- /**
11527
- * Computes the edit operations needed to modify a value in the JSON document.
11528
- *
11529
- * @param documentText The input text
11530
- * @param path The path of the value to change. The path represents either to the document root, a property or an array item.
11531
- * If the path points to an non-existing property or item, it will be created.
11532
- * @param value The new value for the specified property or item. If the value is undefined,
11533
- * the property or item will be removed.
11534
- * @param options Options
11535
- * @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
11536
- * To apply the edit operations to the input, use {@linkcode applyEdits}.
11537
- */
11538
- function modify(text, path, value, options) {
11539
- return edit.setProperty(text, path, value, options);
11540
- }
11541
- exports$1.modify = modify;
11542
- /**
11543
- * Applies edits to an input string.
11544
- * @param text The input text
11545
- * @param edits Edit operations following the format described in {@linkcode EditResult}.
11546
- * @returns The text with the applied edits.
11547
- * @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
11548
- */
11549
- function applyEdits(text, edits) {
11550
- let sortedEdits = edits.slice(0).sort((a, b) => {
11551
- const diff = a.offset - b.offset;
11552
- if (diff === 0) return a.length - b.length;
11553
- return diff;
11554
- });
11555
- let lastModifiedOffset = text.length;
11556
- for (let i = sortedEdits.length - 1; i >= 0; i--) {
11557
- let e = sortedEdits[i];
11558
- if (e.offset + e.length <= lastModifiedOffset) text = edit.applyEdit(text, e);
11559
- else throw new Error("Overlapping edit");
11560
- lastModifiedOffset = e.offset;
11561
- }
11562
- return text;
11563
- }
11564
- exports$1.applyEdits = applyEdits;
11565
- });
11566
- })))();
11567
8248
  /**
11568
8249
  * Ordered layers, each a group of candidates where the first file that exists is
11569
8250
  * selected -- a group never contributes more than one file. The project layer's
@@ -11596,9 +8277,9 @@ const at = (source, offset) => {
11596
8277
  const before = source.slice(0, offset).split("\n");
11597
8278
  return `${before.length}:${(before.at(-1)?.length ?? 0) + 1}`;
11598
8279
  };
11599
- const parse = Effect.fn("Settings.parse")(function* (path, source) {
8280
+ const parse$1 = Effect.fn("Settings.parse")(function* (path, source) {
11600
8281
  const errors = [];
11601
- const json = (0, import_main.parse)(source, errors, {
8282
+ const json = parse(source, errors, {
11602
8283
  allowTrailingComma: true,
11603
8284
  disallowComments: false
11604
8285
  });
@@ -11606,7 +8287,7 @@ const parse = Effect.fn("Settings.parse")(function* (path, source) {
11606
8287
  if (first !== void 0) return yield* new SettingsError({
11607
8288
  path,
11608
8289
  reason: "parse",
11609
- detail: `${(0, import_main.printParseErrorCode)(first.error)} at ${at(source, first.offset)}`
8290
+ detail: `${printParseErrorCode(first.error)} at ${at(source, first.offset)}`
11610
8291
  });
11611
8292
  const document = normalize$1(json);
11612
8293
  if (Predicate.isObject(document) && Predicate.isObject(json) && "plugins" in json) Object.assign(document, { plugins: json.plugins });
@@ -11646,7 +8327,7 @@ const attempt = (path) => fileSystem.readFileString(path).pipe(Effect.mapError((
11646
8327
  path,
11647
8328
  reason: "read",
11648
8329
  detail: error.reason._tag
11649
- })), Effect.flatMap((source) => parse(path, source)));
8330
+ })), Effect.flatMap((source) => parse$1(path, source)));
11650
8331
  /**
11651
8332
  * One read of every layer. Exported for the harness constructor, which needs the plugin
11652
8333
  * selection before any layer is built; everything else goes through `Service`.
@@ -12463,7 +9144,7 @@ const EventEnvelope = Schema.Struct({
12463
9144
  });
12464
9145
  var UnknownEventTypeError = class extends Schema.TaggedError()("UnknownEventTypeError", { type: Schema.String }) {};
12465
9146
  /** The transport's own readiness frame; it has no meaning inside the harness. */
12466
- const Connected = define$3({
9147
+ const Connected = define$2({
12467
9148
  type: "server.connected",
12468
9149
  schema: {}
12469
9150
  });
@@ -12925,4 +9606,4 @@ const reportFailure = (error) => writeError(renderError(error)).pipe(Effect.andT
12925
9606
  //#endregion
12926
9607
  export { Service$3 as A, LLMTextDelta as B, create$2 as C, resolve as D, register as E, Service$14 as F, ID$5 as G, Prompt as H, SessionNotFoundError as I, Service$17 as L, ModelCatalogError as M, sandbox as N, stop as O, sandbox$1 as P, SubscriptionOverflowError as R, relink as S, list as T, ID$2 as U, TurnEnded as V, ID$4 as W, Core as _, addUsage as a, create$1 as b, terminalColumns as c, writeOut as d, layer as f, Connected as g, Api as h, reportFailure as i, Service$4 as j, layer$1 as k, usage as l, run as m, ModelgenError as n, emptyUsage as o, make as p, renderError as r, header as s, InvalidInputError as t, writeError as u, encode as v, drivers as w, get as x, attach as y, LLMEnded as z };
12927
9608
 
12928
- //# sourceMappingURL=error-Cr8LvfEq.mjs.map
9609
+ //# sourceMappingURL=error-zJGKAF4a.mjs.map