@vite-hub/kv 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{batch--v0ri69O.js → batch-D-ib5_0P.js} +0 -1
- package/dist/{cli-CLomw9ml.d.ts → cli-BvVInMht.d.ts} +0 -6
- package/dist/cli.d.ts +2 -4
- package/dist/cli.js +5 -6
- package/dist/{cloudflare-env-Dl349h_9.js → cloudflare-env-Bm6huR35.js} +2 -3
- package/dist/{cloudflare-env-lookup-Bs0VDpU5.js → cloudflare-env-lookup-Dgq5n1Aq.js} +1 -2
- package/dist/{cloudflare-kv-DQJhmGof.js → cloudflare-kv-K2MzfP6D.js} +8 -10
- package/dist/{cloudflare-kv-local-COjgHweC.js → cloudflare-kv-local-lov9LLhU.js} +5 -6
- package/dist/{config-pfyPiPrI.js → config-B8FRGmX_.js} +7 -11
- package/dist/{create-storage-DQ1BbFqH.js → create-storage-BMvkkYdM.js} +9 -15
- package/dist/{cursor-history-CAT4mpP1.js → cursor-history-C6oG12QO.js} +3 -4
- package/dist/{deno-kv-Cf0ZveeN.js → deno-kv-MnqlNH1e.js} +4 -5
- package/dist/{dev-peer-CHafxbtj.js → dev-peer-D0vOxmrD.js} +1 -2
- package/dist/{driver-Du6Eh9p2.d.ts → driver-bLMl-wMO.d.ts} +2 -6
- package/dist/durability.d.ts +1 -3
- package/dist/durability.js +1 -2
- package/dist/{error-diagnostics-C4VTHInS.js → error-diagnostics-DUIp6FhO.js} +1 -2
- package/dist/{errors-BpiM-Vmh.js → errors-IaVOqzAs.js} +4 -7
- package/dist/errors.d.ts +2 -6
- package/dist/errors.js +1 -2
- package/dist/fs-lite-DhXLUL-H.js +1 -0
- package/dist/{fs-lite-BTcBUP6B.js → fs-lite-fvNdBEr9.js} +3 -5
- package/dist/index.d.ts +1 -3
- package/dist/index.js +16 -20
- package/dist/{inspect-BIKQsqX4.js → inspect-BWMcVWD8.js} +2 -4
- package/dist/{invariant-DolT9EEx.js → invariant-Dj2R1eMr.js} +1 -2
- package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
- package/dist/{operation-definition-CI2PJGqu.d.ts → operation-definition-CqZkx1Rm.d.ts} +0 -4
- package/dist/{operations-nAaONxzh.js → operations-CGAX5ASA.js} +15 -20
- package/dist/{operations-CqKs7Ykc.js → operations-FgS_sJ3M.js} +7 -10
- package/dist/operations.d.ts +2 -8
- package/dist/operations.js +8 -12
- package/dist/{out-BbXG-yVX.js → out-By90R-Bo.js} +3345 -2394
- package/dist/{redis-shared-1M0IaguQ.js → redis-shared-DO7Ib1Sz.js} +2 -3
- package/dist/{request-log-Dj9Vw7qG.js → request-log-DllKQXj7.js} +1 -2
- package/dist/{results-D6jfPtCk.js → results-emgN7uDS.js} +1 -2
- package/dist/{rolldown-runtime-CMFfr-1z.js → rolldown-runtime-DegdyBIC.js} +2 -3
- package/dist/runtime/cloudflare-kv.d.ts +1 -3
- package/dist/runtime/cloudflare-kv.js +1 -2
- package/dist/runtime/cloudflare-request-env.d.ts +1 -3
- package/dist/runtime/cloudflare-request-env.js +2 -3
- package/dist/runtime/database.d.ts +1 -1
- package/dist/runtime/database.js +5 -6
- package/dist/runtime/nitro-plugin.d.ts +1 -2
- package/dist/runtime/nitro-plugin.js +3 -4
- package/dist/runtime/redis-driver.d.ts +3 -5
- package/dist/runtime/redis-driver.js +6 -7
- package/dist/runtime/unstorage-driver.d.ts +2 -4
- package/dist/runtime/unstorage-driver.js +2 -3
- package/dist/runtime/upstash-driver.d.ts +3 -5
- package/dist/runtime/upstash-driver.js +6 -7
- package/dist/{types-Bj3EQoRg.d.ts → types-BUb0FcjM.d.ts} +0 -2
- package/dist/{types-Cp6IBhSN.d.ts → types-C397WKyf.d.ts} +1 -3
- package/dist/{upstash-5sTbIR35.js → upstash-DQVo1zbz.js} +3 -4
- package/dist/{utils2-FozcTsmb.js → utils2-By8eee1x.js} +1 -2
- package/dist/vite.d.ts +3 -17
- package/dist/vite.js +1429 -913
- package/package.json +10 -10
- package/dist/fs-lite-C8yXCVDM.js +0 -2
package/dist/vite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { r as __toESM } from "./rolldown-runtime-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as
|
|
6
|
-
import {
|
|
7
|
-
import { a as upstashUrlEnvNames, i as upstashTokenEnvNames, n as kvRedisEnvHint, o as resolveHostPreset, r as normalizeKVOptions } from "./config-
|
|
8
|
-
import { n as
|
|
9
|
-
import {
|
|
1
|
+
import { r as __toESM } from "./rolldown-runtime-DegdyBIC.js";
|
|
2
|
+
import { n as invariantError, t as invariant } from "./invariant-Dj2R1eMr.js";
|
|
3
|
+
import { a as resolve$1, i as relative$1, n as relativeDefinitionFile, r as dirname$1 } from "./inspect-BWMcVWD8.js";
|
|
4
|
+
import { t as addViteHubDevPeerDevHandler } from "./dev-peer-D0vOxmrD.js";
|
|
5
|
+
import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
|
|
6
|
+
import { C as resolveViteHubProjectRoot, N as writeViteHubDevServerFile, P as internalErrorDiagnostics, S as markViteConfigPlugin, b as hasNitroConfigContext, j as removeViteHubDevServerFile, k as readViteHubDevServerFile, p as operationRpcPath, r as collectOperationContributions, v as VITEHUB_PROJECT_ROOT, w as shouldSkipViteProviderBuild, x as isServerEnvironment, y as createNoExternalAddition } from "./operations-CGAX5ASA.js";
|
|
7
|
+
import { a as upstashUrlEnvNames, i as upstashTokenEnvNames, n as kvRedisEnvHint, o as resolveHostPreset, r as normalizeKVOptions } from "./config-B8FRGmX_.js";
|
|
8
|
+
import { n as kvErrorDiagnostics } from "./error-diagnostics-DUIp6FhO.js";
|
|
9
|
+
import { n as resolveUpstashRuntimeValues } from "./upstash-DQVo1zbz.js";
|
|
10
10
|
import { createRequire, isBuiltin } from "node:module";
|
|
11
11
|
import { access, copyFile, cp, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
12
12
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
@@ -15,7 +15,7 @@ import { formatDiagnostic } from "nostics";
|
|
|
15
15
|
import { tmpdir } from "node:os";
|
|
16
16
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
17
17
|
import { createHash } from "node:crypto";
|
|
18
|
-
|
|
18
|
+
// ../internal/src/build/paths.ts
|
|
19
19
|
function resolveRuntimeModule(packageDir, modulePath) {
|
|
20
20
|
const distFile = resolve$1(packageDir, "dist", `${modulePath}.js`);
|
|
21
21
|
return existsSync(distFile) ? distFile : resolve$1(packageDir, "src", `${modulePath}.ts`);
|
|
@@ -42,8 +42,7 @@ function findPackageDir(file) {
|
|
|
42
42
|
function ownModule(importMetaUrl, modulePath) {
|
|
43
43
|
return resolveRuntimeModule(findPackageDir(fileURLToPath(importMetaUrl)), modulePath);
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
//#region ../internal/src/definition-catalog.ts
|
|
45
|
+
// ../internal/src/definition-catalog.ts
|
|
47
46
|
/** `writeFileIfChangedSync` for async callers. */
|
|
48
47
|
async function writeFileIfChanged(file, contents) {
|
|
49
48
|
if (await readFile(file, "utf8").catch(() => void 0) === contents) return;
|
|
@@ -86,8 +85,7 @@ function createNitroServerKit(value = {}) {
|
|
|
86
85
|
}
|
|
87
86
|
};
|
|
88
87
|
}
|
|
89
|
-
|
|
90
|
-
//#region ../internal/src/contributions.ts
|
|
88
|
+
// ../internal/src/contributions.ts
|
|
91
89
|
function isThenable(value) {
|
|
92
90
|
return typeof value.then === "function";
|
|
93
91
|
}
|
|
@@ -114,8 +112,7 @@ async function flattenPluginOptions(plugins) {
|
|
|
114
112
|
await flattenPlugins(plugins ?? [], flattened, /* @__PURE__ */ new Set());
|
|
115
113
|
return flattened;
|
|
116
114
|
}
|
|
117
|
-
|
|
118
|
-
//#region ../internal/src/operations-vite.ts
|
|
115
|
+
// ../internal/src/operations-vite.ts
|
|
119
116
|
const owners$1 = /* @__PURE__ */ new Set([
|
|
120
117
|
"@vite-hub/kv/vite",
|
|
121
118
|
"@vite-hub/blob/vite",
|
|
@@ -183,14 +180,12 @@ async function installStandaloneOperationRpc(config, command, module) {
|
|
|
183
180
|
kit.config.devHandlers = signed;
|
|
184
181
|
Reflect.set(config, "nitro", kit.config);
|
|
185
182
|
}
|
|
186
|
-
|
|
187
|
-
//#region ../internal/src/durability.ts
|
|
183
|
+
// ../internal/src/durability.ts
|
|
188
184
|
/** The `durability` module next to the Vite plugin module at `importMetaUrl`, in source and in `dist`. */
|
|
189
185
|
function durabilityModuleFile(importMetaUrl) {
|
|
190
186
|
return fileURLToPath(new URL(importMetaUrl.endsWith(".ts") ? "./durability.ts" : "./durability.js", importMetaUrl));
|
|
191
187
|
}
|
|
192
|
-
|
|
193
|
-
//#region src/vite-config.ts
|
|
188
|
+
// src/vite-config.ts
|
|
194
189
|
const KV_VITE_PLUGIN_NAME = "@vite-hub/kv/vite";
|
|
195
190
|
const KV_VIRTUAL_CONFIG_ID = "#vitehub/kv/config";
|
|
196
191
|
function resolveKVViteConfig(kv, input = {}) {
|
|
@@ -208,8 +203,7 @@ function resolveKVViteConfig(kv, input = {}) {
|
|
|
208
203
|
}) ?? false
|
|
209
204
|
};
|
|
210
205
|
}
|
|
211
|
-
|
|
212
|
-
//#region ../internal/src/build/client-output.ts
|
|
206
|
+
// ../internal/src/build/client-output.ts
|
|
213
207
|
function hasStaticIndex(clientDir) {
|
|
214
208
|
return existsSync(resolve$1(clientDir, "index.html"));
|
|
215
209
|
}
|
|
@@ -246,8 +240,7 @@ async function copyClientOutput(clientDir, targetDir, excludedDirs = []) {
|
|
|
246
240
|
filter
|
|
247
241
|
});
|
|
248
242
|
}
|
|
249
|
-
|
|
250
|
-
//#region ../internal/src/build/provider-output-config.ts
|
|
243
|
+
// ../internal/src/build/provider-output-config.ts
|
|
251
244
|
function isProviderJsonArray(value, ancestors) {
|
|
252
245
|
if (Object.getPrototypeOf(value) !== Array.prototype || ancestors.has(value)) return false;
|
|
253
246
|
if (Reflect.ownKeys(value).length !== value.length + 1) return false;
|
|
@@ -385,13 +378,11 @@ async function cleanProviderOutputConfig(file, ownership) {
|
|
|
385
378
|
if (!changed) return;
|
|
386
379
|
await persistProviderJsonRecord(file, next, true);
|
|
387
380
|
}
|
|
388
|
-
|
|
389
|
-
//#region ../internal/src/build/user-entry.ts
|
|
381
|
+
// ../internal/src/build/user-entry.ts
|
|
390
382
|
function toSafeAppName(rootDir) {
|
|
391
383
|
return basename(rootDir).replace(/[^a-z0-9-]+/gi, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
|
|
392
384
|
}
|
|
393
|
-
|
|
394
|
-
//#region ../internal/src/build/cloudflare.ts
|
|
385
|
+
// ../internal/src/build/cloudflare.ts
|
|
395
386
|
function createDefaultCloudflareOutputRoot(rootDir) {
|
|
396
387
|
return resolve(rootDir, "dist", toSafeAppName(rootDir));
|
|
397
388
|
}
|
|
@@ -408,8 +399,7 @@ async function writeCloudflareWranglerConfig(options) {
|
|
|
408
399
|
removeIfEmpty: true
|
|
409
400
|
});
|
|
410
401
|
}
|
|
411
|
-
|
|
412
|
-
//#region ../internal/src/build/bundle-options.ts
|
|
402
|
+
// ../internal/src/build/bundle-options.ts
|
|
413
403
|
const encodedAliasPrefixMarker = "\0vitehub-prefix:";
|
|
414
404
|
const encodedAliasExactMarker = "\0vitehub-exact:";
|
|
415
405
|
/** Select the runtime constants from one resolved Vite configuration. */
|
|
@@ -421,8 +411,7 @@ function resolveViteHubBundleDefines(config) {
|
|
|
421
411
|
}
|
|
422
412
|
return defines;
|
|
423
413
|
}
|
|
424
|
-
|
|
425
|
-
//#region ../internal/src/build/ast-walk.ts
|
|
414
|
+
// ../internal/src/build/ast-walk.ts
|
|
426
415
|
/** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
|
|
427
416
|
function moduleLanguage(file) {
|
|
428
417
|
if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
|
|
@@ -445,8 +434,7 @@ function walk(node, visit, parent) {
|
|
|
445
434
|
} else if (isNode(child)) walk(child, visit, node);
|
|
446
435
|
}
|
|
447
436
|
}
|
|
448
|
-
|
|
449
|
-
//#region ../internal/src/build/rolldown.ts
|
|
437
|
+
// ../internal/src/build/rolldown.ts
|
|
450
438
|
const viteRawPrefix = "\0vitehub-vite-raw:";
|
|
451
439
|
const markdownTemplatePrefix = "\0vitehub-markdown-template:";
|
|
452
440
|
const markdownTemplateFileSuffix = ".template.md";
|
|
@@ -1043,8 +1031,7 @@ async function bundleEsmEntry(entryFile, outfile, options = {}) {
|
|
|
1043
1031
|
await writeFile(outfile, chunk.code, { signal: options.signal });
|
|
1044
1032
|
options.signal?.throwIfAborted();
|
|
1045
1033
|
}
|
|
1046
|
-
|
|
1047
|
-
//#region ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
|
|
1034
|
+
// ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
|
|
1048
1035
|
const balanced = (a, b, str) => {
|
|
1049
1036
|
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
1050
1037
|
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
@@ -1091,8 +1078,7 @@ const range = (a, b, str) => {
|
|
|
1091
1078
|
}
|
|
1092
1079
|
return result;
|
|
1093
1080
|
};
|
|
1094
|
-
|
|
1095
|
-
//#region ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
|
|
1081
|
+
// ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
|
|
1096
1082
|
const escSlash = "\0SLASH" + Math.random() + "\0";
|
|
1097
1083
|
const escOpen = "\0OPEN" + Math.random() + "\0";
|
|
1098
1084
|
const escClose = "\0CLOSE" + Math.random() + "\0";
|
|
@@ -1292,39 +1278,94 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|
|
1292
1278
|
}
|
|
1293
1279
|
return acc;
|
|
1294
1280
|
}
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1281
|
+
// ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/numeric-range.js
|
|
1282
|
+
const digit = (a, b) => a === b ? {
|
|
1283
|
+
t: "lit",
|
|
1284
|
+
ch: String(a)
|
|
1285
|
+
} : {
|
|
1286
|
+
t: "class",
|
|
1287
|
+
re: new RegExp(`^[${a}-${b}]$`)
|
|
1288
|
+
};
|
|
1289
|
+
const prefix = (d, alts) => alts.map((s) => [digit(d, d), ...s]);
|
|
1290
|
+
const fixed = (a, b) => {
|
|
1291
|
+
if (!a) return [[]];
|
|
1292
|
+
let lo = +a[0];
|
|
1293
|
+
let hi = +b[0];
|
|
1294
|
+
const ra = a.slice(1);
|
|
1295
|
+
const rb = b.slice(1);
|
|
1296
|
+
if (lo === hi) return prefix(lo, fixed(ra, rb));
|
|
1297
|
+
const zeros = "0".repeat(ra.length);
|
|
1298
|
+
const nines = "9".repeat(ra.length);
|
|
1299
|
+
const out = [];
|
|
1300
|
+
if (ra !== zeros) out.push(...prefix(lo++, fixed(ra, nines)));
|
|
1301
|
+
const last = rb === nines ? [] : prefix(hi--, fixed(zeros, rb));
|
|
1302
|
+
if (lo <= hi) out.push([digit(lo, hi), ...Array.from(ra, () => digit(0, 9))]);
|
|
1303
|
+
out.push(...last);
|
|
1304
|
+
return out;
|
|
1305
|
+
};
|
|
1306
|
+
const nonneg = (a, b, width) => {
|
|
1307
|
+
if (width) return fixed(String(a).padStart(width, "0"), String(b).padStart(width, "0"));
|
|
1308
|
+
const out = [];
|
|
1309
|
+
for (let len = String(a).length; len <= String(b).length; len++) {
|
|
1310
|
+
const lo = Math.max(a, len === 1 ? 0 : 10 ** (len - 1));
|
|
1311
|
+
const hi = Math.min(b, 10 ** len - 1);
|
|
1312
|
+
out.push(...fixed(String(lo), String(hi)));
|
|
1313
|
+
}
|
|
1314
|
+
return out;
|
|
1301
1315
|
};
|
|
1302
|
-
|
|
1303
|
-
|
|
1316
|
+
/**
|
|
1317
|
+
* The strings that the bash brace expansion `{lo..hi}` makes, as
|
|
1318
|
+
* the alternatives of an `@(...)` extglob. Each one is a sequence of
|
|
1319
|
+
* digits and digit classes, so there are only a few of them, even for
|
|
1320
|
+
* a large range.
|
|
1321
|
+
*
|
|
1322
|
+
* If either end has a leading zero, such as `{01..10}`, each number
|
|
1323
|
+
* has leading zeros to make it as long as the longer end, counting a
|
|
1324
|
+
* `-` sign. So `{-05..3}` makes `-05` to `-01`, then `000` to `003`.
|
|
1325
|
+
*
|
|
1326
|
+
* Returns undefined if either end is not a safe integer.
|
|
1327
|
+
*/
|
|
1328
|
+
const numericRange = (loStr, hiStr) => {
|
|
1329
|
+
let lo = Number(loStr);
|
|
1330
|
+
let hi = Number(hiStr);
|
|
1331
|
+
if (!Number.isSafeInteger(lo) || !Number.isSafeInteger(hi)) return;
|
|
1332
|
+
if (lo > hi) [lo, hi] = [hi, lo];
|
|
1333
|
+
const width = /^-?0\d/.test(loStr) || /^-?0\d/.test(hiStr) ? Math.max(loStr.length, hiStr.length) : 0;
|
|
1334
|
+
const out = [];
|
|
1335
|
+
if (lo < 0) {
|
|
1336
|
+
const neg = nonneg(Math.max(-hi, 1), -lo, width && width - 1);
|
|
1337
|
+
out.push(...neg.map((s) => [{
|
|
1338
|
+
t: "lit",
|
|
1339
|
+
ch: "-"
|
|
1340
|
+
}, ...s]));
|
|
1341
|
+
}
|
|
1342
|
+
if (hi >= 0) out.push(...nonneg(Math.max(lo, 0), hi, width));
|
|
1343
|
+
return out;
|
|
1344
|
+
};
|
|
1345
|
+
// ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js
|
|
1304
1346
|
const posixClasses = {
|
|
1305
|
-
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"
|
|
1306
|
-
"[:alpha:]": ["\\p{L}\\p{Nl}"
|
|
1307
|
-
"[:ascii:]": ["\\x00-\\x7f"
|
|
1308
|
-
"[:blank:]": ["\\p{Zs}\\t"
|
|
1309
|
-
"[:cntrl:]": ["\\p{Cc}"
|
|
1310
|
-
"[:digit:]": ["\\p{Nd}"
|
|
1311
|
-
"[:graph:]": [
|
|
1312
|
-
|
|
1313
|
-
true,
|
|
1314
|
-
true
|
|
1315
|
-
],
|
|
1316
|
-
"[:lower:]": ["\\p{Ll}", true],
|
|
1347
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
|
|
1348
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}"],
|
|
1349
|
+
"[:ascii:]": ["\\x00-\\x7f"],
|
|
1350
|
+
"[:blank:]": ["\\p{Zs}\\t"],
|
|
1351
|
+
"[:cntrl:]": ["\\p{Cc}"],
|
|
1352
|
+
"[:digit:]": ["\\p{Nd}"],
|
|
1353
|
+
"[:graph:]": ["\\p{Z}\\p{C}", true],
|
|
1354
|
+
"[:lower:]": ["\\p{Ll}"],
|
|
1317
1355
|
"[:print:]": ["\\p{C}", true],
|
|
1318
|
-
"[:punct:]": ["\\p{P}"
|
|
1319
|
-
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"
|
|
1320
|
-
"[:upper:]": ["\\p{Lu}"
|
|
1321
|
-
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"
|
|
1322
|
-
"[:xdigit:]": ["A-Fa-f0-9"
|
|
1356
|
+
"[:punct:]": ["\\p{P}\\p{S}"],
|
|
1357
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"],
|
|
1358
|
+
"[:upper:]": ["\\p{Lu}"],
|
|
1359
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],
|
|
1360
|
+
"[:xdigit:]": ["A-Fa-f0-9"]
|
|
1323
1361
|
};
|
|
1324
1362
|
const braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
|
|
1325
|
-
const
|
|
1326
|
-
const
|
|
1327
|
-
const
|
|
1363
|
+
const noMatch = /$./;
|
|
1364
|
+
const parseClass = (glob, position, nocase = false, form) => {
|
|
1365
|
+
const norm = (c) => {
|
|
1366
|
+
const n = form ? c.normalize(form) : c;
|
|
1367
|
+
return [...n].length === 1 ? n : c;
|
|
1368
|
+
};
|
|
1328
1369
|
const pos = position;
|
|
1329
1370
|
/* c8 ignore start */
|
|
1330
1371
|
if (glob.charAt(pos) !== "[") throw new Error("not in a brace expression");
|
|
@@ -1333,13 +1374,12 @@ const parseClass = (glob, position) => {
|
|
|
1333
1374
|
const negs = [];
|
|
1334
1375
|
let i = pos + 1;
|
|
1335
1376
|
let sawStart = false;
|
|
1336
|
-
let uflag = false;
|
|
1337
1377
|
let escaping = false;
|
|
1338
1378
|
let negate = false;
|
|
1339
1379
|
let endPos = pos;
|
|
1340
1380
|
let rangeStart = "";
|
|
1341
1381
|
WHILE: while (i < glob.length) {
|
|
1342
|
-
const c = glob.
|
|
1382
|
+
const c = String.fromCodePoint(glob.codePointAt(i));
|
|
1343
1383
|
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
1344
1384
|
negate = true;
|
|
1345
1385
|
i++;
|
|
@@ -1358,607 +1398,659 @@ const parseClass = (glob, position) => {
|
|
|
1358
1398
|
}
|
|
1359
1399
|
}
|
|
1360
1400
|
if (c === "[" && !escaping) {
|
|
1361
|
-
for (const [cls, [unip,
|
|
1362
|
-
if (rangeStart) return [
|
|
1363
|
-
"$.",
|
|
1364
|
-
false,
|
|
1365
|
-
glob.length - pos,
|
|
1366
|
-
true
|
|
1367
|
-
];
|
|
1401
|
+
for (const [cls, [unip, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
|
|
1402
|
+
if (rangeStart) return [noMatch, glob.length - pos];
|
|
1368
1403
|
i += cls.length;
|
|
1369
1404
|
if (neg) negs.push(unip);
|
|
1370
1405
|
else ranges.push(unip);
|
|
1371
|
-
uflag = uflag || u;
|
|
1372
1406
|
continue WHILE;
|
|
1373
1407
|
}
|
|
1374
1408
|
}
|
|
1375
1409
|
escaping = false;
|
|
1410
|
+
const n = norm(c);
|
|
1376
1411
|
if (rangeStart) {
|
|
1377
|
-
if (
|
|
1378
|
-
else if (
|
|
1412
|
+
if (n.codePointAt(0) > rangeStart.codePointAt(0)) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(n));
|
|
1413
|
+
else if (n === rangeStart) ranges.push(braceEscape(n));
|
|
1379
1414
|
rangeStart = "";
|
|
1380
|
-
i
|
|
1415
|
+
i += c.length;
|
|
1381
1416
|
continue;
|
|
1382
1417
|
}
|
|
1383
|
-
if (glob.startsWith("-]", i +
|
|
1384
|
-
ranges.push(braceEscape(
|
|
1385
|
-
i +=
|
|
1418
|
+
if (glob.startsWith("-]", i + c.length)) {
|
|
1419
|
+
ranges.push(braceEscape(n + "-"));
|
|
1420
|
+
i += c.length + 1;
|
|
1421
|
+
continue;
|
|
1422
|
+
}
|
|
1423
|
+
if (glob.startsWith("-", i + c.length)) {
|
|
1424
|
+
rangeStart = n;
|
|
1425
|
+
i += c.length + 1;
|
|
1426
|
+
continue;
|
|
1427
|
+
}
|
|
1428
|
+
ranges.push(braceEscape(n));
|
|
1429
|
+
i += c.length;
|
|
1430
|
+
}
|
|
1431
|
+
if (endPos < i) return [noMatch, 0];
|
|
1432
|
+
if (!ranges.length && !negs.length) return [noMatch, glob.length - pos];
|
|
1433
|
+
const sranges = "[" + (negate ? "^" : "") + ranges.join("") + "]";
|
|
1434
|
+
const snegs = "[" + (negate ? "" : "^") + negs.join("") + "]";
|
|
1435
|
+
const comb = "^" + (ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs);
|
|
1436
|
+
return [new RegExp(comb, nocase ? "iu" : "u"), endPos - pos];
|
|
1437
|
+
};
|
|
1438
|
+
// ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js
|
|
1439
|
+
const MATCH = {
|
|
1440
|
+
t: "match",
|
|
1441
|
+
id: 0
|
|
1442
|
+
};
|
|
1443
|
+
const extTypes = "!?+*@";
|
|
1444
|
+
const lit = (ch) => ({
|
|
1445
|
+
t: "lit",
|
|
1446
|
+
ch
|
|
1447
|
+
});
|
|
1448
|
+
const reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
|
|
1449
|
+
const newFoldRe = (s) => new RegExp(`^${reEscape(s)}$`, "iu");
|
|
1450
|
+
const foldCache = /* @__PURE__ */ new Map();
|
|
1451
|
+
const foldRe = (ch) => {
|
|
1452
|
+
let re = foldCache.get(ch);
|
|
1453
|
+
if (!re) {
|
|
1454
|
+
re = newFoldRe(ch);
|
|
1455
|
+
if (foldCache.size >= 1e3) foldCache.clear();
|
|
1456
|
+
foldCache.set(ch, re);
|
|
1457
|
+
}
|
|
1458
|
+
return re;
|
|
1459
|
+
};
|
|
1460
|
+
const litMatch = (l, c) => {
|
|
1461
|
+
if (c === l.ch) return true;
|
|
1462
|
+
if (!l.re) return false;
|
|
1463
|
+
const code = c.charCodeAt(0);
|
|
1464
|
+
if (code >= 128) return l.re.test(c);
|
|
1465
|
+
const ascii = l.ascii ??= /* @__PURE__ */ new Uint8Array(128);
|
|
1466
|
+
ascii[code] ||= l.re.test(c) ? 1 : 2;
|
|
1467
|
+
return ascii[code] === 1;
|
|
1468
|
+
};
|
|
1469
|
+
const tokenize = (p, nocase, noext, form, mark) => {
|
|
1470
|
+
const toks = [];
|
|
1471
|
+
for (let i = 0; i < p.length;) {
|
|
1472
|
+
const c = String.fromCodePoint(p.codePointAt(i));
|
|
1473
|
+
if (mark) {
|
|
1474
|
+
const m = c === "\\" && p.startsWith(mark, i + 1) ? 1 : 0;
|
|
1475
|
+
if (m || c === mark) {
|
|
1476
|
+
const start = i + m + mark.length;
|
|
1477
|
+
const end = p.indexOf(mark, start);
|
|
1478
|
+
const r = /^(-?\d+)\.\.(-?\d+)$/.exec(p.slice(start, end));
|
|
1479
|
+
const alts = end !== -1 && r && numericRange(r[1], r[2]);
|
|
1480
|
+
if (alts) {
|
|
1481
|
+
toks.push({
|
|
1482
|
+
t: "ext",
|
|
1483
|
+
type: "@",
|
|
1484
|
+
alts
|
|
1485
|
+
});
|
|
1486
|
+
i = end + mark.length;
|
|
1487
|
+
continue;
|
|
1488
|
+
}
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
if (c === "\\") {
|
|
1492
|
+
const e = p.codePointAt(i + 1);
|
|
1493
|
+
const ch = e === void 0 ? c : String.fromCodePoint(e);
|
|
1494
|
+
toks.push(lit(ch));
|
|
1495
|
+
i += 1 + ch.length;
|
|
1386
1496
|
continue;
|
|
1387
1497
|
}
|
|
1388
|
-
if (
|
|
1389
|
-
|
|
1498
|
+
if (c === "[") {
|
|
1499
|
+
const [re, consumed] = parseClass(p, i, nocase, form);
|
|
1500
|
+
if (consumed) {
|
|
1501
|
+
toks.push({
|
|
1502
|
+
t: "class",
|
|
1503
|
+
re
|
|
1504
|
+
});
|
|
1505
|
+
i += consumed;
|
|
1506
|
+
continue;
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
if (!noext && extTypes.includes(c) && p[i + 1] === "(") {
|
|
1510
|
+
toks.push({
|
|
1511
|
+
t: "open",
|
|
1512
|
+
type: c
|
|
1513
|
+
});
|
|
1390
1514
|
i += 2;
|
|
1391
1515
|
continue;
|
|
1392
1516
|
}
|
|
1393
|
-
|
|
1394
|
-
i
|
|
1517
|
+
toks.push(!noext && c === "|" ? { t: "bar" } : !noext && c === ")" ? { t: "close" } : c === "*" ? { t: "star" } : c === "?" ? { t: "any" } : lit(c));
|
|
1518
|
+
i += c.length;
|
|
1395
1519
|
}
|
|
1396
|
-
|
|
1397
|
-
"",
|
|
1398
|
-
false,
|
|
1399
|
-
0,
|
|
1400
|
-
false
|
|
1401
|
-
];
|
|
1402
|
-
if (!ranges.length && !negs.length) return [
|
|
1403
|
-
"$.",
|
|
1404
|
-
false,
|
|
1405
|
-
glob.length - pos,
|
|
1406
|
-
true
|
|
1407
|
-
];
|
|
1408
|
-
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
1409
|
-
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
1410
|
-
return [
|
|
1411
|
-
regexpEscape(r),
|
|
1412
|
-
false,
|
|
1413
|
-
endPos - pos,
|
|
1414
|
-
false
|
|
1415
|
-
];
|
|
1416
|
-
}
|
|
1417
|
-
const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
|
|
1418
|
-
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
1419
|
-
return [
|
|
1420
|
-
ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs,
|
|
1421
|
-
uflag,
|
|
1422
|
-
endPos - pos,
|
|
1423
|
-
true
|
|
1424
|
-
];
|
|
1520
|
+
return toks;
|
|
1425
1521
|
};
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
* For example, it will turn the string `'[*]'` into `*`, but it will not
|
|
1435
|
-
* turn `'\\*'` into `'*'`, because `\` is a path separator in
|
|
1436
|
-
* `windowsPathsNoEscape` mode.
|
|
1437
|
-
*
|
|
1438
|
-
* When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
|
|
1439
|
-
* backslash escapes are removed.
|
|
1440
|
-
*
|
|
1441
|
-
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
|
|
1442
|
-
* or unescaped.
|
|
1443
|
-
*
|
|
1444
|
-
* When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
|
|
1445
|
-
* unescaped.
|
|
1446
|
-
*/
|
|
1447
|
-
const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
|
|
1448
|
-
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
|
|
1449
|
-
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
|
|
1522
|
+
const pair = (toks) => {
|
|
1523
|
+
const pairs = /* @__PURE__ */ new Map();
|
|
1524
|
+
const stack = [];
|
|
1525
|
+
toks.forEach((tok, i) => {
|
|
1526
|
+
if (tok.t === "open") stack.push(i);
|
|
1527
|
+
else if (tok.t === "close" && stack.length) pairs.set(stack.pop(), i);
|
|
1528
|
+
});
|
|
1529
|
+
return pairs;
|
|
1450
1530
|
};
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
"
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
]
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
const
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
"
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
["+", [
|
|
1491
|
-
"+",
|
|
1492
|
-
"@",
|
|
1493
|
-
"?",
|
|
1494
|
-
"*"
|
|
1495
|
-
]]
|
|
1496
|
-
]);
|
|
1497
|
-
const usurpMap = /* @__PURE__ */ new Map([
|
|
1498
|
-
["!", /* @__PURE__ */ new Map([["!", "@"]])],
|
|
1499
|
-
["?", /* @__PURE__ */ new Map([["*", "*"], ["+", "*"]])],
|
|
1500
|
-
["@", /* @__PURE__ */ new Map([
|
|
1501
|
-
["!", "!"],
|
|
1502
|
-
["?", "?"],
|
|
1503
|
-
["@", "@"],
|
|
1504
|
-
["*", "*"],
|
|
1505
|
-
["+", "+"]
|
|
1506
|
-
])],
|
|
1507
|
-
["+", /* @__PURE__ */ new Map([["?", "*"], ["*", "*"]])]
|
|
1508
|
-
]);
|
|
1509
|
-
const startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
1510
|
-
const startNoDot = "(?!\\.)";
|
|
1511
|
-
const addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
|
|
1512
|
-
const justDots = /* @__PURE__ */ new Set(["..", "."]);
|
|
1513
|
-
const reSpecials = /* @__PURE__ */ new Set("().*{}+?[]^$\\!");
|
|
1514
|
-
const regExpEscape$1 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1515
|
-
const qmark = "[^/]";
|
|
1516
|
-
const star$1 = "[^/]*?";
|
|
1517
|
-
const starNoEmpty = "[^/]+?";
|
|
1518
|
-
let ID = 0;
|
|
1519
|
-
var AST = class {
|
|
1520
|
-
type;
|
|
1521
|
-
#root;
|
|
1522
|
-
#hasMagic;
|
|
1523
|
-
#uflag = false;
|
|
1524
|
-
#parts = [];
|
|
1525
|
-
#parent;
|
|
1526
|
-
#parentIndex;
|
|
1527
|
-
#negs;
|
|
1528
|
-
#filledNegs = false;
|
|
1529
|
-
#options;
|
|
1530
|
-
#toString;
|
|
1531
|
-
#emptyExt = false;
|
|
1532
|
-
id = ++ID;
|
|
1533
|
-
get depth() {
|
|
1534
|
-
return (this.#parent?.depth ?? -1) + 1;
|
|
1535
|
-
}
|
|
1536
|
-
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
1537
|
-
return {
|
|
1538
|
-
"@@type": "AST",
|
|
1539
|
-
id: this.id,
|
|
1540
|
-
type: this.type,
|
|
1541
|
-
root: this.#root.id,
|
|
1542
|
-
parent: this.#parent?.id,
|
|
1543
|
-
depth: this.depth,
|
|
1544
|
-
partsLength: this.#parts.length,
|
|
1545
|
-
parts: this.#parts
|
|
1546
|
-
};
|
|
1531
|
+
const build = (toks, pairs, start, end, top) => {
|
|
1532
|
+
let seq = [];
|
|
1533
|
+
const alts = [seq];
|
|
1534
|
+
for (let i = start; i < end; i++) {
|
|
1535
|
+
const tok = toks[i];
|
|
1536
|
+
const close = pairs.get(i);
|
|
1537
|
+
if (tok.t === "open" && close !== void 0) {
|
|
1538
|
+
const sub = build(toks, pairs, i + 1, close, false);
|
|
1539
|
+
seq.push({
|
|
1540
|
+
t: "ext",
|
|
1541
|
+
type: tok.type,
|
|
1542
|
+
alts: sub
|
|
1543
|
+
});
|
|
1544
|
+
i = close;
|
|
1545
|
+
} else if (tok.t === "bar" && !top) alts.push(seq = []);
|
|
1546
|
+
else if (tok.t === "open") seq.push(lit(tok.type), lit("("));
|
|
1547
|
+
else if (tok.t === "bar") seq.push(lit("|"));
|
|
1548
|
+
else if (tok.t === "close") seq.push(lit(")"));
|
|
1549
|
+
else seq.push(tok);
|
|
1550
|
+
}
|
|
1551
|
+
return alts;
|
|
1552
|
+
};
|
|
1553
|
+
const normalize = (items, form) => {
|
|
1554
|
+
const out = [];
|
|
1555
|
+
let run = "";
|
|
1556
|
+
const flush = () => {
|
|
1557
|
+
for (const ch of run.normalize(form)) out.push(lit(ch));
|
|
1558
|
+
run = "";
|
|
1559
|
+
};
|
|
1560
|
+
for (const it of items) {
|
|
1561
|
+
if (it.t === "lit") {
|
|
1562
|
+
run += it.ch;
|
|
1563
|
+
continue;
|
|
1564
|
+
}
|
|
1565
|
+
flush();
|
|
1566
|
+
out.push(it.t === "ext" ? {
|
|
1567
|
+
...it,
|
|
1568
|
+
alts: it.alts.map((a) => normalize(a, form))
|
|
1569
|
+
} : it);
|
|
1547
1570
|
}
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
}
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1571
|
+
flush();
|
|
1572
|
+
return out;
|
|
1573
|
+
};
|
|
1574
|
+
const compile = (items, nocase) => {
|
|
1575
|
+
let id = 1;
|
|
1576
|
+
const split = (out) => ({
|
|
1577
|
+
t: "split",
|
|
1578
|
+
id: id++,
|
|
1579
|
+
out
|
|
1580
|
+
});
|
|
1581
|
+
const seq = (items, next) => items.reduceRight((next, it) => item(it, next), next);
|
|
1582
|
+
const item = (it, next) => {
|
|
1583
|
+
switch (it.t) {
|
|
1584
|
+
case "lit":
|
|
1585
|
+
const re = nocase ? foldRe(it.ch) : void 0;
|
|
1586
|
+
return {
|
|
1587
|
+
t: "lit",
|
|
1588
|
+
id: id++,
|
|
1589
|
+
ch: it.ch,
|
|
1590
|
+
re,
|
|
1591
|
+
next
|
|
1592
|
+
};
|
|
1593
|
+
case "any":
|
|
1594
|
+
case "star": return {
|
|
1595
|
+
t: it.t,
|
|
1596
|
+
id: id++,
|
|
1597
|
+
next
|
|
1598
|
+
};
|
|
1599
|
+
case "class": return {
|
|
1600
|
+
t: "class",
|
|
1601
|
+
id: id++,
|
|
1602
|
+
re: it.re,
|
|
1603
|
+
next
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
const alts = (next) => it.alts.map((a) => seq(a, next));
|
|
1607
|
+
switch (it.type) {
|
|
1608
|
+
case "@": return split(alts(next));
|
|
1609
|
+
case "?": return split([next, ...alts(next)]);
|
|
1610
|
+
case "!": return {
|
|
1611
|
+
t: "neg",
|
|
1612
|
+
id: id++,
|
|
1613
|
+
sub: split(alts(MATCH)),
|
|
1614
|
+
next
|
|
1615
|
+
};
|
|
1616
|
+
}
|
|
1617
|
+
const after = split([]);
|
|
1618
|
+
const entry = split(alts(after));
|
|
1619
|
+
after.out.push(next, entry);
|
|
1620
|
+
return it.type === "*" ? after : entry;
|
|
1621
|
+
};
|
|
1622
|
+
return [seq(items, MATCH), id];
|
|
1623
|
+
};
|
|
1624
|
+
const show = (start) => {
|
|
1625
|
+
const lines = [];
|
|
1626
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1627
|
+
const ref = (n) => n.t === "match" ? "match" : String(n.id);
|
|
1628
|
+
const walk = (n, indent) => {
|
|
1629
|
+
if (n.t === "match" || seen.has(n)) return;
|
|
1630
|
+
seen.add(n);
|
|
1631
|
+
const line = (desc) => lines.push(`${indent}${n.id}: ${desc}`);
|
|
1632
|
+
switch (n.t) {
|
|
1633
|
+
case "split":
|
|
1634
|
+
line(`split -> ${n.out.map(ref).join(", ")}`);
|
|
1635
|
+
for (const o of n.out) walk(o, indent);
|
|
1636
|
+
return;
|
|
1637
|
+
case "neg":
|
|
1638
|
+
line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
|
|
1639
|
+
walk(n.sub, indent + " ");
|
|
1640
|
+
return walk(n.next, indent);
|
|
1641
|
+
case "lit":
|
|
1642
|
+
line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
|
|
1643
|
+
break;
|
|
1644
|
+
case "class":
|
|
1645
|
+
line(`${n.re} -> ${ref(n.next)}`);
|
|
1646
|
+
break;
|
|
1647
|
+
default: line(`${n.t === "any" ? "?" : "*"} -> ${ref(n.next)}`);
|
|
1565
1648
|
}
|
|
1566
|
-
|
|
1649
|
+
walk(n.next, indent);
|
|
1650
|
+
};
|
|
1651
|
+
walk(start, "");
|
|
1652
|
+
return [`start -> ${ref(start)}`, ...lines].join("\n");
|
|
1653
|
+
};
|
|
1654
|
+
var State = class {
|
|
1655
|
+
gen;
|
|
1656
|
+
threads = [];
|
|
1657
|
+
match = false;
|
|
1658
|
+
runs = [];
|
|
1659
|
+
ids = [];
|
|
1660
|
+
constructor(gen) {
|
|
1661
|
+
this.gen = gen;
|
|
1662
|
+
}
|
|
1663
|
+
get dead() {
|
|
1664
|
+
return !this.threads.length && !this.match && !this.runs.length;
|
|
1567
1665
|
}
|
|
1568
|
-
|
|
1569
|
-
|
|
1666
|
+
};
|
|
1667
|
+
const sameState = (a, b) => {
|
|
1668
|
+
if (a.ids.length !== b.ids.length) return false;
|
|
1669
|
+
if (a.runs.length !== b.runs.length) return false;
|
|
1670
|
+
if (a.ids.some((id, i) => id !== b.ids[i])) return false;
|
|
1671
|
+
return a.runs.every((r) => b.runs.some((o) => o.neg === r.neg && sameState(o.state, r.state)));
|
|
1672
|
+
};
|
|
1673
|
+
const marks = (size) => ({
|
|
1674
|
+
has: new Float64Array(size),
|
|
1675
|
+
seen: new Float64Array(size),
|
|
1676
|
+
gen: 0
|
|
1677
|
+
});
|
|
1678
|
+
var Sim = class {
|
|
1679
|
+
dots;
|
|
1680
|
+
dotStart;
|
|
1681
|
+
#marks;
|
|
1682
|
+
constructor(dots, dotStart, marks) {
|
|
1683
|
+
this.dots = dots;
|
|
1684
|
+
this.dotStart = dotStart;
|
|
1685
|
+
this.#marks = marks;
|
|
1686
|
+
}
|
|
1687
|
+
state() {
|
|
1688
|
+
return new State(++this.#marks.gen);
|
|
1689
|
+
}
|
|
1690
|
+
done(state) {
|
|
1691
|
+
state.ids = state.threads.map((n) => n.id).sort((a, b) => a - b);
|
|
1692
|
+
if (state.match) state.ids.unshift(MATCH.id);
|
|
1693
|
+
return state;
|
|
1694
|
+
}
|
|
1695
|
+
#visit(state, node) {
|
|
1696
|
+
const { seen } = this.#marks;
|
|
1697
|
+
if (seen[node.id] === state.gen) return false;
|
|
1698
|
+
seen[node.id] = state.gen;
|
|
1699
|
+
return true;
|
|
1570
1700
|
}
|
|
1571
|
-
#
|
|
1572
|
-
|
|
1573
|
-
if (
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
this.#filledNegs = true;
|
|
1578
|
-
let n;
|
|
1579
|
-
while (n = this.#negs.pop()) {
|
|
1580
|
-
if (n.type !== "!") continue;
|
|
1581
|
-
let p = n;
|
|
1582
|
-
let pp = p.#parent;
|
|
1583
|
-
while (pp) {
|
|
1584
|
-
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) for (const part of n.#parts) {
|
|
1585
|
-
/* c8 ignore start */
|
|
1586
|
-
if (typeof part === "string") throw new Error("string part in extglob AST??");
|
|
1587
|
-
/* c8 ignore stop */
|
|
1588
|
-
part.copyIn(pp.#parts[i]);
|
|
1589
|
-
}
|
|
1590
|
-
p = pp;
|
|
1591
|
-
pp = p.#parent;
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
return this;
|
|
1701
|
+
#addThread(state, node) {
|
|
1702
|
+
const { has } = this.#marks;
|
|
1703
|
+
if (has[node.id] === state.gen) return false;
|
|
1704
|
+
has[node.id] = state.gen;
|
|
1705
|
+
state.threads.push(node);
|
|
1706
|
+
return true;
|
|
1595
1707
|
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1708
|
+
restricted(i, top) {
|
|
1709
|
+
return top && (this.dots || this.dotStart && i === 0);
|
|
1710
|
+
}
|
|
1711
|
+
add(state, node, i, top) {
|
|
1712
|
+
switch (node.t) {
|
|
1713
|
+
case "split":
|
|
1714
|
+
if (!this.#visit(state, node)) return;
|
|
1715
|
+
for (const o of node.out) this.add(state, o, i, top);
|
|
1716
|
+
return;
|
|
1717
|
+
case "neg":
|
|
1718
|
+
if (!this.#visit(state, node)) return;
|
|
1719
|
+
const sub = this.state();
|
|
1720
|
+
this.add(sub, node.sub, i, false);
|
|
1721
|
+
this.done(sub);
|
|
1722
|
+
return this.addRun(state, {
|
|
1723
|
+
t: "run",
|
|
1724
|
+
neg: node,
|
|
1725
|
+
state: sub
|
|
1726
|
+
}, i, top);
|
|
1727
|
+
case "star":
|
|
1728
|
+
if (this.restricted(i, top)) return;
|
|
1729
|
+
if (this.#addThread(state, node)) this.add(state, node.next, i, top);
|
|
1730
|
+
return;
|
|
1731
|
+
case "match":
|
|
1732
|
+
state.match = true;
|
|
1733
|
+
return;
|
|
1734
|
+
default: this.#addThread(state, node);
|
|
1603
1735
|
}
|
|
1604
1736
|
}
|
|
1605
|
-
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
if (
|
|
1609
|
-
return ret;
|
|
1737
|
+
addRun(state, run, i, top) {
|
|
1738
|
+
for (const r of state.runs) if (r.neg === run.neg && sameState(r.state, run.state)) return;
|
|
1739
|
+
state.runs.push(run);
|
|
1740
|
+
if (!run.state.match) this.add(state, run.neg.next, i, top);
|
|
1610
1741
|
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1742
|
+
step(state, c, i, top) {
|
|
1743
|
+
const next = this.state();
|
|
1744
|
+
for (const th of state.threads) switch (th.t) {
|
|
1745
|
+
case "lit":
|
|
1746
|
+
if (litMatch(th, c)) this.add(next, th.next, i + 1, top);
|
|
1747
|
+
break;
|
|
1748
|
+
case "any":
|
|
1749
|
+
if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top);
|
|
1750
|
+
break;
|
|
1751
|
+
case "class":
|
|
1752
|
+
if (!this.restricted(i, top) && th.re.test(c)) this.add(next, th.next, i + 1, top);
|
|
1753
|
+
break;
|
|
1754
|
+
case "star": if (!this.restricted(i, top)) this.add(next, th, i + 1, top);
|
|
1619
1755
|
}
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
if (this.#root === this) return true;
|
|
1624
|
-
if (this.#parent?.type === "!") return true;
|
|
1625
|
-
if (!this.#parent?.isEnd()) return false;
|
|
1626
|
-
if (!this.type) return this.#parent?.isEnd();
|
|
1627
|
-
/* c8 ignore start */
|
|
1628
|
-
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
1629
|
-
/* c8 ignore stop */
|
|
1630
|
-
return this.#parentIndex === pl - 1;
|
|
1631
|
-
}
|
|
1632
|
-
copyIn(part) {
|
|
1633
|
-
if (typeof part === "string") this.push(part);
|
|
1634
|
-
else this.push(part.clone(this));
|
|
1635
|
-
}
|
|
1636
|
-
clone(parent) {
|
|
1637
|
-
const c = new _a(this.type, parent);
|
|
1638
|
-
for (const p of this.#parts) c.copyIn(p);
|
|
1639
|
-
return c;
|
|
1640
|
-
}
|
|
1641
|
-
static #parseAST(str, ast, pos, opt, extDepth) {
|
|
1642
|
-
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
1643
|
-
let escaping = false;
|
|
1644
|
-
let inBrace = false;
|
|
1645
|
-
let braceStart = -1;
|
|
1646
|
-
let braceNeg = false;
|
|
1647
|
-
if (ast.type === null) {
|
|
1648
|
-
let i = pos;
|
|
1649
|
-
let acc = "";
|
|
1650
|
-
while (i < str.length) {
|
|
1651
|
-
const c = str.charAt(i++);
|
|
1652
|
-
if (escaping || c === "\\") {
|
|
1653
|
-
escaping = !escaping;
|
|
1654
|
-
acc += c;
|
|
1655
|
-
continue;
|
|
1656
|
-
}
|
|
1657
|
-
if (inBrace) {
|
|
1658
|
-
if (i === braceStart + 1) {
|
|
1659
|
-
if (c === "^" || c === "!") braceNeg = true;
|
|
1660
|
-
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
|
|
1661
|
-
acc += c;
|
|
1662
|
-
continue;
|
|
1663
|
-
} else if (c === "[") {
|
|
1664
|
-
inBrace = true;
|
|
1665
|
-
braceStart = i;
|
|
1666
|
-
braceNeg = false;
|
|
1667
|
-
acc += c;
|
|
1668
|
-
continue;
|
|
1669
|
-
}
|
|
1670
|
-
if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && extDepth <= maxDepth) {
|
|
1671
|
-
ast.push(acc);
|
|
1672
|
-
acc = "";
|
|
1673
|
-
const ext = new _a(c, ast);
|
|
1674
|
-
i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
|
|
1675
|
-
ast.push(ext);
|
|
1676
|
-
continue;
|
|
1677
|
-
}
|
|
1678
|
-
acc += c;
|
|
1679
|
-
}
|
|
1680
|
-
ast.push(acc);
|
|
1681
|
-
return i;
|
|
1682
|
-
}
|
|
1683
|
-
let i = pos + 1;
|
|
1684
|
-
let part = new _a(null, ast);
|
|
1685
|
-
const parts = [];
|
|
1686
|
-
let acc = "";
|
|
1687
|
-
while (i < str.length) {
|
|
1688
|
-
const c = str.charAt(i++);
|
|
1689
|
-
if (escaping || c === "\\") {
|
|
1690
|
-
escaping = !escaping;
|
|
1691
|
-
acc += c;
|
|
1756
|
+
if (!this.restricted(i, top)) for (const run of state.runs) {
|
|
1757
|
+
if (run.state.dead) {
|
|
1758
|
+
this.addRun(next, run, i + 1, top);
|
|
1692
1759
|
continue;
|
|
1693
1760
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
braceStart = i;
|
|
1703
|
-
braceNeg = false;
|
|
1704
|
-
acc += c;
|
|
1705
|
-
continue;
|
|
1706
|
-
}
|
|
1707
|
-
/* c8 ignore stop */
|
|
1708
|
-
if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && (extDepth <= maxDepth || ast && ast.#canAdoptType(c))) {
|
|
1709
|
-
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
1710
|
-
part.push(acc);
|
|
1711
|
-
acc = "";
|
|
1712
|
-
const ext = new _a(c, part);
|
|
1713
|
-
part.push(ext);
|
|
1714
|
-
i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
|
|
1715
|
-
continue;
|
|
1716
|
-
}
|
|
1717
|
-
if (c === "|") {
|
|
1718
|
-
part.push(acc);
|
|
1719
|
-
acc = "";
|
|
1720
|
-
parts.push(part);
|
|
1721
|
-
part = new _a(null, ast);
|
|
1722
|
-
continue;
|
|
1723
|
-
}
|
|
1724
|
-
if (c === ")") {
|
|
1725
|
-
if (acc === "" && ast.#parts.length === 0) ast.#emptyExt = true;
|
|
1726
|
-
part.push(acc);
|
|
1727
|
-
acc = "";
|
|
1728
|
-
ast.push(...parts, part);
|
|
1729
|
-
return i;
|
|
1730
|
-
}
|
|
1731
|
-
acc += c;
|
|
1732
|
-
}
|
|
1733
|
-
ast.type = null;
|
|
1734
|
-
ast.#hasMagic = void 0;
|
|
1735
|
-
ast.#parts = [str.substring(pos - 1)];
|
|
1736
|
-
return i;
|
|
1737
|
-
}
|
|
1738
|
-
#canAdoptWithSpace(child) {
|
|
1739
|
-
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
1740
|
-
}
|
|
1741
|
-
#canAdopt(child, map = adoptionMap) {
|
|
1742
|
-
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null) return false;
|
|
1743
|
-
const gc = child.#parts[0];
|
|
1744
|
-
if (!gc || typeof gc !== "object" || gc.type === null) return false;
|
|
1745
|
-
return this.#canAdoptType(gc.type, map);
|
|
1746
|
-
}
|
|
1747
|
-
#canAdoptType(c, map = adoptionAnyMap) {
|
|
1748
|
-
return !!map.get(this.type)?.includes(c);
|
|
1749
|
-
}
|
|
1750
|
-
#adoptWithSpace(child, index) {
|
|
1751
|
-
const gc = child.#parts[0];
|
|
1752
|
-
const blank = new _a(null, gc, this.options);
|
|
1753
|
-
blank.#parts.push("");
|
|
1754
|
-
gc.push(blank);
|
|
1755
|
-
this.#adopt(child, index);
|
|
1756
|
-
}
|
|
1757
|
-
#adopt(child, index) {
|
|
1758
|
-
const gc = child.#parts[0];
|
|
1759
|
-
this.#parts.splice(index, 1, ...gc.#parts);
|
|
1760
|
-
for (const p of gc.#parts) if (typeof p === "object") p.#parent = this;
|
|
1761
|
-
this.#toString = void 0;
|
|
1762
|
-
}
|
|
1763
|
-
#canUsurpType(c) {
|
|
1764
|
-
return !!usurpMap.get(this.type)?.has(c);
|
|
1765
|
-
}
|
|
1766
|
-
#canUsurp(child) {
|
|
1767
|
-
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) return false;
|
|
1768
|
-
const gc = child.#parts[0];
|
|
1769
|
-
if (!gc || typeof gc !== "object" || gc.type === null) return false;
|
|
1770
|
-
return this.#canUsurpType(gc.type);
|
|
1771
|
-
}
|
|
1772
|
-
#usurp(child) {
|
|
1773
|
-
const m = usurpMap.get(this.type);
|
|
1774
|
-
const gc = child.#parts[0];
|
|
1775
|
-
const nt = m?.get(gc.type);
|
|
1776
|
-
/* c8 ignore start - impossible */
|
|
1777
|
-
if (!nt) return false;
|
|
1778
|
-
/* c8 ignore stop */
|
|
1779
|
-
this.#parts = gc.#parts;
|
|
1780
|
-
for (const p of this.#parts) if (typeof p === "object") p.#parent = this;
|
|
1781
|
-
this.type = nt;
|
|
1782
|
-
this.#toString = void 0;
|
|
1783
|
-
this.#emptyExt = false;
|
|
1784
|
-
}
|
|
1785
|
-
static fromGlob(pattern, options = {}) {
|
|
1786
|
-
const ast = new _a(null, void 0, options);
|
|
1787
|
-
_a.#parseAST(pattern, ast, 0, options, 0);
|
|
1788
|
-
return ast;
|
|
1789
|
-
}
|
|
1790
|
-
toMMPattern() {
|
|
1791
|
-
/* c8 ignore start */
|
|
1792
|
-
if (this !== this.#root) return this.#root.toMMPattern();
|
|
1793
|
-
/* c8 ignore stop */
|
|
1794
|
-
const glob = this.toString();
|
|
1795
|
-
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
1796
|
-
if (!(hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase())) return body;
|
|
1797
|
-
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
1798
|
-
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
1799
|
-
_src: re,
|
|
1800
|
-
_glob: glob
|
|
1801
|
-
});
|
|
1761
|
+
const sub = this.step(run.state, c, i, false);
|
|
1762
|
+
this.addRun(next, {
|
|
1763
|
+
t: "run",
|
|
1764
|
+
neg: run.neg,
|
|
1765
|
+
state: sub
|
|
1766
|
+
}, i + 1, top);
|
|
1767
|
+
}
|
|
1768
|
+
return this.done(next);
|
|
1802
1769
|
}
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1770
|
+
};
|
|
1771
|
+
const stateKey = (state) => {
|
|
1772
|
+
const ids = state.ids.join();
|
|
1773
|
+
if (!state.runs.length) return ids;
|
|
1774
|
+
return `${ids}|${state.runs.map((r) => `${r.neg.id}(${stateKey(r.state)})`).sort().join("|")}`;
|
|
1775
|
+
};
|
|
1776
|
+
const DFA_BUDGET = 1 << 18;
|
|
1777
|
+
var Dfa = class {
|
|
1778
|
+
#start;
|
|
1779
|
+
#states = /* @__PURE__ */ new Map();
|
|
1780
|
+
#size = 0;
|
|
1781
|
+
#plain;
|
|
1782
|
+
#dotStart;
|
|
1783
|
+
#sim;
|
|
1784
|
+
#dotSim;
|
|
1785
|
+
constructor(start, marks) {
|
|
1786
|
+
this.#start = start;
|
|
1787
|
+
this.#sim = new Sim(false, false, marks);
|
|
1788
|
+
this.#dotSim = new Sim(false, true, marks);
|
|
1789
|
+
}
|
|
1790
|
+
#make(state) {
|
|
1791
|
+
return {
|
|
1792
|
+
state,
|
|
1793
|
+
match: state.match,
|
|
1794
|
+
dead: state.dead,
|
|
1795
|
+
next: /* @__PURE__ */ new Map()
|
|
1796
|
+
};
|
|
1797
|
+
}
|
|
1798
|
+
#intern(state) {
|
|
1799
|
+
const key = stateKey(state);
|
|
1800
|
+
const found = this.#states.get(key);
|
|
1801
|
+
if (found) return found;
|
|
1802
|
+
if (this.#size > DFA_BUDGET) this.#clear();
|
|
1803
|
+
const d = this.#make(state);
|
|
1804
|
+
this.#states.set(key, d);
|
|
1805
|
+
this.#size += key.length + 1;
|
|
1806
|
+
return d;
|
|
1807
|
+
}
|
|
1808
|
+
#clear() {
|
|
1809
|
+
this.#states.clear();
|
|
1810
|
+
this.#size = 0;
|
|
1811
|
+
this.#plain = void 0;
|
|
1812
|
+
this.#dotStart = void 0;
|
|
1813
|
+
}
|
|
1814
|
+
start(dotStart) {
|
|
1815
|
+
if (dotStart) {
|
|
1816
|
+
if (this.#dotStart) return this.#dotStart;
|
|
1817
|
+
const state = this.#dotSim.state();
|
|
1818
|
+
this.#dotSim.add(state, this.#start, 0, true);
|
|
1819
|
+
return this.#dotStart = this.#make(this.#dotSim.done(state));
|
|
1820
|
+
}
|
|
1821
|
+
if (this.#plain) return this.#plain;
|
|
1822
|
+
const state = this.#sim.state();
|
|
1823
|
+
this.#sim.add(state, this.#start, 0, true);
|
|
1824
|
+
return this.#plain = this.#intern(this.#sim.done(state));
|
|
1825
|
+
}
|
|
1826
|
+
next(d, c) {
|
|
1827
|
+
const code = c.charCodeAt(0);
|
|
1828
|
+
const found = code < 128 ? void 0 : d.next.get(c);
|
|
1829
|
+
if (found) return found;
|
|
1830
|
+
const n = d === this.#dotStart ? this.#intern(this.#dotSim.step(d.state, c, 0, true)) : this.#intern(this.#sim.step(d.state, c, 1, true));
|
|
1831
|
+
if (code < 128) {
|
|
1832
|
+
if (!d.ascii) {
|
|
1833
|
+
d.ascii = new Array(128);
|
|
1834
|
+
this.#size += 128;
|
|
1830
1835
|
}
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
unescape(src),
|
|
1836
|
-
this.#hasMagic = !!this.#hasMagic,
|
|
1837
|
-
this.#uflag
|
|
1838
|
-
];
|
|
1839
|
-
}
|
|
1840
|
-
const repeated = this.type === "*" || this.type === "+";
|
|
1841
|
-
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
1842
|
-
let body = this.#partsToRegExp(dot);
|
|
1843
|
-
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
1844
|
-
const s = this.toString();
|
|
1845
|
-
const me = this;
|
|
1846
|
-
me.#parts = [s];
|
|
1847
|
-
me.type = null;
|
|
1848
|
-
me.#hasMagic = void 0;
|
|
1849
|
-
return [
|
|
1850
|
-
s,
|
|
1851
|
-
unescape(this.toString()),
|
|
1852
|
-
false,
|
|
1853
|
-
false
|
|
1854
|
-
];
|
|
1855
|
-
}
|
|
1856
|
-
let bodyDotAllowed = !repeated || allowDot || dot || false ? "" : this.#partsToRegExp(true);
|
|
1857
|
-
if (bodyDotAllowed === body) bodyDotAllowed = "";
|
|
1858
|
-
if (bodyDotAllowed) body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
1859
|
-
let final = "";
|
|
1860
|
-
if (this.type === "!" && this.#emptyExt) final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
|
1861
|
-
else {
|
|
1862
|
-
const close = this.type === "!" ? "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + "[^/]*?)" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
|
|
1863
|
-
final = start + body + close;
|
|
1864
|
-
}
|
|
1865
|
-
return [
|
|
1866
|
-
final,
|
|
1867
|
-
unescape(body),
|
|
1868
|
-
this.#hasMagic = !!this.#hasMagic,
|
|
1869
|
-
this.#uflag
|
|
1870
|
-
];
|
|
1836
|
+
d.ascii[code] = n;
|
|
1837
|
+
} else d.next.set(c, n);
|
|
1838
|
+
this.#size++;
|
|
1839
|
+
return n;
|
|
1871
1840
|
}
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
this.#usurp(c);
|
|
1893
|
-
}
|
|
1894
|
-
}
|
|
1895
|
-
}
|
|
1896
|
-
} while (!done && ++iterations < 10);
|
|
1841
|
+
};
|
|
1842
|
+
const linear = (start) => {
|
|
1843
|
+
const nodes = [];
|
|
1844
|
+
for (let n = start; n.t !== "match"; n = n.next) {
|
|
1845
|
+
if (n.t === "split" || n.t === "neg") return void 0;
|
|
1846
|
+
nodes.push(n);
|
|
1847
|
+
}
|
|
1848
|
+
return nodes;
|
|
1849
|
+
};
|
|
1850
|
+
const testLinear = (nodes, chars, start, end) => {
|
|
1851
|
+
let ni = 0;
|
|
1852
|
+
let ci = start;
|
|
1853
|
+
let starNi = -1;
|
|
1854
|
+
let starCi = 0;
|
|
1855
|
+
while (ci < end) {
|
|
1856
|
+
const n = nodes[ni];
|
|
1857
|
+
if (n?.t === "star") {
|
|
1858
|
+
starNi = ni++;
|
|
1859
|
+
starCi = ci;
|
|
1860
|
+
continue;
|
|
1897
1861
|
}
|
|
1898
|
-
|
|
1862
|
+
const c = chars[ci];
|
|
1863
|
+
if (n && (n.t === "any" || n.t === "lit" && litMatch(n, c) || n.t === "class" && n.re.test(c))) {
|
|
1864
|
+
ni++;
|
|
1865
|
+
ci++;
|
|
1866
|
+
continue;
|
|
1867
|
+
}
|
|
1868
|
+
if (starNi === -1) return false;
|
|
1869
|
+
ni = starNi + 1;
|
|
1870
|
+
ci = ++starCi;
|
|
1899
1871
|
}
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1872
|
+
while (nodes[ni]?.t === "star") ni++;
|
|
1873
|
+
return ni === nodes.length;
|
|
1874
|
+
};
|
|
1875
|
+
const lengths = (items) => {
|
|
1876
|
+
let min = 0;
|
|
1877
|
+
let max = 0;
|
|
1878
|
+
for (const it of items) {
|
|
1879
|
+
const [lo, hi] = itemLengths(it);
|
|
1880
|
+
min += lo;
|
|
1881
|
+
max += hi;
|
|
1882
|
+
}
|
|
1883
|
+
return [min, max];
|
|
1884
|
+
};
|
|
1885
|
+
const itemLengths = (it) => {
|
|
1886
|
+
if (it.t === "star") return [0, Infinity];
|
|
1887
|
+
if (it.t !== "ext") return [1, 1];
|
|
1888
|
+
if (it.type === "!") return [0, Infinity];
|
|
1889
|
+
const alts = it.alts.map(lengths);
|
|
1890
|
+
const min = Math.min(...alts.map((a) => a[0]));
|
|
1891
|
+
const max = Math.max(...alts.map((a) => a[1]));
|
|
1892
|
+
const loop = max === 0 ? 0 : Infinity;
|
|
1893
|
+
return it.type === "@" ? [min, max] : it.type === "?" ? [0, max] : it.type === "*" ? [0, loop] : [min, loop];
|
|
1894
|
+
};
|
|
1895
|
+
const hasAffix = (lits, chars, start) => {
|
|
1896
|
+
for (let j = 0; j < lits.length; j++) if (!litMatch(lits[j], chars[start + j])) return false;
|
|
1897
|
+
return true;
|
|
1898
|
+
};
|
|
1899
|
+
const slashOrSurrogate = /[/\ud800-\udfff]/;
|
|
1900
|
+
const surrogate = /[\ud800-\udfff]/;
|
|
1901
|
+
const codePoints = (s) => surrogate.test(s) ? [...s] : s;
|
|
1902
|
+
const noSlash = (s) => {
|
|
1903
|
+
if (s.includes("/")) throw new Error("can only match a single path portion, got: " + s);
|
|
1904
|
+
};
|
|
1905
|
+
var Matcher = class {
|
|
1906
|
+
pattern;
|
|
1907
|
+
options;
|
|
1908
|
+
#start;
|
|
1909
|
+
#size;
|
|
1910
|
+
#marks;
|
|
1911
|
+
#dotsSim;
|
|
1912
|
+
#literal;
|
|
1913
|
+
#literalFold = false;
|
|
1914
|
+
#literalRe;
|
|
1915
|
+
#linear;
|
|
1916
|
+
#wild = false;
|
|
1917
|
+
#min = 0;
|
|
1918
|
+
#max = Infinity;
|
|
1919
|
+
#prefix = [];
|
|
1920
|
+
#suffix = [];
|
|
1921
|
+
#prefixStr;
|
|
1922
|
+
#suffixStr;
|
|
1923
|
+
#affix = false;
|
|
1924
|
+
#dfa;
|
|
1925
|
+
#form;
|
|
1926
|
+
constructor(pattern, options = {}) {
|
|
1927
|
+
if (pattern.includes("/")) throw new Error("can only match a single path portion, got pattern: " + pattern);
|
|
1928
|
+
this.pattern = pattern;
|
|
1929
|
+
this.options = options;
|
|
1930
|
+
const { nocase = false, noext = false, normalize: n } = options;
|
|
1931
|
+
this.#form = n === true ? "NFC" : n || void 0;
|
|
1932
|
+
const literal = /^[?*+@]\(\)$/.test(pattern);
|
|
1933
|
+
const toks = tokenize(pattern, nocase, noext || literal, this.#form, options.rangeMark);
|
|
1934
|
+
let [items] = build(toks, pair(toks), 0, toks.length, true);
|
|
1935
|
+
if (this.#form) items = normalize(items, this.#form);
|
|
1936
|
+
const [start, size] = compile(items, nocase);
|
|
1937
|
+
this.#start = start;
|
|
1938
|
+
this.#size = size;
|
|
1939
|
+
if (items.every((it) => it.t === "lit")) {
|
|
1940
|
+
this.#literal = items.map((it) => it.ch).join("");
|
|
1941
|
+
this.#literalFold = nocase;
|
|
1942
|
+
} else {
|
|
1943
|
+
const lit = (it) => it.t !== "lit" ? void 0 : nocase ? {
|
|
1944
|
+
ch: it.ch,
|
|
1945
|
+
re: foldRe(it.ch)
|
|
1946
|
+
} : { ch: it.ch };
|
|
1947
|
+
for (const it of items) {
|
|
1948
|
+
const l = lit(it);
|
|
1949
|
+
if (!l) break;
|
|
1950
|
+
this.#prefix.push(l);
|
|
1921
1951
|
}
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
hasMagic = true;
|
|
1927
|
-
continue;
|
|
1928
|
-
} else inStar = false;
|
|
1929
|
-
if (c === "\\") {
|
|
1930
|
-
if (i === glob.length - 1) re += "\\\\";
|
|
1931
|
-
else escaping = true;
|
|
1932
|
-
continue;
|
|
1952
|
+
for (let j = items.length - 1; j >= 0; j--) {
|
|
1953
|
+
const l = lit(items[j]);
|
|
1954
|
+
if (!l) break;
|
|
1955
|
+
this.#suffix.unshift(l);
|
|
1933
1956
|
}
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
uflag = uflag || needUflag;
|
|
1939
|
-
i += consumed - 1;
|
|
1940
|
-
hasMagic = hasMagic || magic;
|
|
1941
|
-
continue;
|
|
1942
|
-
}
|
|
1957
|
+
this.#affix = !!(this.#prefix.length || this.#suffix.length);
|
|
1958
|
+
if (!nocase) {
|
|
1959
|
+
this.#prefixStr = this.#prefix.map((l) => l.ch).join("");
|
|
1960
|
+
this.#suffixStr = this.#suffix.map((l) => l.ch).join("");
|
|
1943
1961
|
}
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1962
|
+
this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || void 0);
|
|
1963
|
+
this.#wild = !!this.#linear?.every((n) => n.t === "star" || n.t === "any");
|
|
1964
|
+
const [min, max] = lengths(items);
|
|
1965
|
+
this.#min = min;
|
|
1966
|
+
this.#max = max;
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
test(s) {
|
|
1970
|
+
if (this.#form) {
|
|
1971
|
+
noSlash(s);
|
|
1972
|
+
return this.#test(s.normalize(this.#form));
|
|
1973
|
+
}
|
|
1974
|
+
if (slashOrSurrogate.test(s)) {
|
|
1975
|
+
noSlash(s);
|
|
1976
|
+
return this.#test(s, [...s]);
|
|
1977
|
+
}
|
|
1978
|
+
return this.#test(s, s);
|
|
1979
|
+
}
|
|
1980
|
+
/**
|
|
1981
|
+
* The same as {@link Matcher#test}, but the string is not checked
|
|
1982
|
+
* for `/` chars, so the result for a string that has one is not
|
|
1983
|
+
* defined. Only use it for a string that is known to be one path
|
|
1984
|
+
* portion, such as a part of a path that was split on `/`. It can
|
|
1985
|
+
* be faster, because some patterns do not need to look at each char
|
|
1986
|
+
* of the string.
|
|
1987
|
+
*/
|
|
1988
|
+
testUnchecked(s) {
|
|
1989
|
+
return this.#test(this.#form ? s.normalize(this.#form) : s);
|
|
1990
|
+
}
|
|
1991
|
+
#test(s, chars) {
|
|
1992
|
+
if (this.#literal !== void 0) return this.#literalFold ? (this.#literalRe ??= newFoldRe(this.#literal)).test(s) : s === this.#literal;
|
|
1993
|
+
const min = this.#min;
|
|
1994
|
+
const max = this.#max;
|
|
1995
|
+
if (chars === void 0) {
|
|
1996
|
+
const most = s.length;
|
|
1997
|
+
const least = most + 1 >> 1;
|
|
1998
|
+
if (most < min || least > max) return false;
|
|
1999
|
+
if (least < min || most > max) chars = codePoints(s);
|
|
2000
|
+
}
|
|
2001
|
+
if (chars !== void 0 && (chars.length < min || chars.length > max)) return false;
|
|
2002
|
+
const prefix = this.#prefix.length;
|
|
2003
|
+
if (this.#affix) {
|
|
2004
|
+
if (this.#prefixStr !== void 0 && this.#suffixStr !== void 0) {
|
|
2005
|
+
if (!s.startsWith(this.#prefixStr) || !s.endsWith(this.#suffixStr)) return false;
|
|
2006
|
+
} else {
|
|
2007
|
+
chars ??= codePoints(s);
|
|
2008
|
+
const end = chars.length - this.#suffix.length;
|
|
2009
|
+
if (!hasAffix(this.#prefix, chars, 0) || !hasAffix(this.#suffix, chars, end)) return false;
|
|
1948
2010
|
}
|
|
1949
|
-
re += regExpEscape$1(c);
|
|
1950
2011
|
}
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
2012
|
+
const dotStart = !this.options.dot && s.startsWith(".");
|
|
2013
|
+
if (this.#linear) {
|
|
2014
|
+
if (s === "." || s === "..") return false;
|
|
2015
|
+
if (dotStart && !prefix) return false;
|
|
2016
|
+
if (this.#wild) return true;
|
|
2017
|
+
chars ??= codePoints(s);
|
|
2018
|
+
const end = chars.length - this.#suffix.length;
|
|
2019
|
+
return testLinear(this.#linear, chars, prefix, end);
|
|
2020
|
+
}
|
|
2021
|
+
chars ??= codePoints(s);
|
|
2022
|
+
if (s === "." || s === "..") {
|
|
2023
|
+
this.#marks ??= marks(this.#size);
|
|
2024
|
+
const sim = this.#dotsSim ??= new Sim(true, false, this.#marks);
|
|
2025
|
+
const start = sim.state();
|
|
2026
|
+
sim.add(start, this.#start, 0, true);
|
|
2027
|
+
let state = sim.done(start);
|
|
2028
|
+
for (let i = 0; i < chars.length; i++) state = sim.step(state, chars[i], i, true);
|
|
2029
|
+
return state.match;
|
|
2030
|
+
}
|
|
2031
|
+
this.#marks ??= marks(this.#size);
|
|
2032
|
+
const dfa = this.#dfa ??= new Dfa(this.#start, this.#marks);
|
|
2033
|
+
let d = dfa.start(dotStart);
|
|
2034
|
+
const str = chars === s;
|
|
2035
|
+
for (let i = 0; i < chars.length; i++) {
|
|
2036
|
+
if (d.dead) return false;
|
|
2037
|
+
const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
|
|
2038
|
+
d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
|
|
2039
|
+
}
|
|
2040
|
+
return d.match;
|
|
1957
2041
|
}
|
|
2042
|
+
/** a readable listing of the state machine */
|
|
2043
|
+
toString() {
|
|
2044
|
+
return show(this.#start);
|
|
2045
|
+
}
|
|
2046
|
+
};
|
|
2047
|
+
// ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
2048
|
+
const MAX_PATTERN_LENGTH = 65536;
|
|
2049
|
+
const assertValidPattern = (pattern) => {
|
|
2050
|
+
if (typeof pattern !== "string") throw new TypeError("invalid pattern");
|
|
2051
|
+
if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
|
|
1958
2052
|
};
|
|
1959
|
-
|
|
1960
|
-
//#endregion
|
|
1961
|
-
//#region ../../node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js
|
|
2053
|
+
// ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/escape.js
|
|
1962
2054
|
/**
|
|
1963
2055
|
* Escape all magic characters in a glob pattern.
|
|
1964
2056
|
*
|
|
@@ -1970,68 +2062,154 @@ _a = AST;
|
|
|
1970
2062
|
*
|
|
1971
2063
|
* If the {@link MinimatchOptions.magicalBraces} option is used,
|
|
1972
2064
|
* then braces (`{` and `}`) will be escaped.
|
|
2065
|
+
*
|
|
2066
|
+
* A leading `#` or `!` is escaped as well, so that the result is never a
|
|
2067
|
+
* comment or a negated pattern. In `windowsPathsNoEscape` mode, a leading
|
|
2068
|
+
* `!` is written as `@(!)`, because `[!` starts a negated class.
|
|
1973
2069
|
*/
|
|
1974
2070
|
const escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
|
|
1975
|
-
|
|
1976
|
-
|
|
2071
|
+
const e = magicalBraces ? windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&") : windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
2072
|
+
const c = e.charAt(0);
|
|
2073
|
+
if (c === "#") return (windowsPathsNoEscape ? "[#]" : "\\#") + e.slice(1);
|
|
2074
|
+
if (c === "!") return (windowsPathsNoEscape ? "@(!)" : "\\!") + e.slice(1);
|
|
2075
|
+
return e;
|
|
1977
2076
|
};
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
const
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
const qmarksTestNocase = ([$0, ext = ""]) => {
|
|
2006
|
-
const noext = qmarksTestNoExt([$0]);
|
|
2007
|
-
if (!ext) return noext;
|
|
2008
|
-
ext = ext.toLowerCase();
|
|
2009
|
-
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
2077
|
+
// ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/unescape.js
|
|
2078
|
+
/**
|
|
2079
|
+
* Un-escape a string that has been escaped with {@link escape}.
|
|
2080
|
+
*
|
|
2081
|
+
* If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
|
|
2082
|
+
* square-bracket escapes are removed, but not backslash escapes.
|
|
2083
|
+
*
|
|
2084
|
+
* For example, it will turn the string `'[*]'` into `*`, but it will not
|
|
2085
|
+
* turn `'\\*'` into `'*'`, because `\` is a path separator in
|
|
2086
|
+
* `windowsPathsNoEscape` mode.
|
|
2087
|
+
*
|
|
2088
|
+
* When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
|
|
2089
|
+
* backslash escapes are removed.
|
|
2090
|
+
*
|
|
2091
|
+
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
|
|
2092
|
+
* or unescaped.
|
|
2093
|
+
*
|
|
2094
|
+
* When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
|
|
2095
|
+
* unescaped.
|
|
2096
|
+
*/
|
|
2097
|
+
const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
|
|
2098
|
+
if (windowsPathsNoEscape && s.startsWith("@(!)")) return "!" + unescape(s.slice(4), {
|
|
2099
|
+
windowsPathsNoEscape,
|
|
2100
|
+
magicalBraces
|
|
2101
|
+
});
|
|
2102
|
+
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
|
|
2103
|
+
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
|
|
2010
2104
|
};
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2105
|
+
// ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/index.js
|
|
2106
|
+
const DEFAULT_BRACE_EXPAND_MAX = 1e5;
|
|
2107
|
+
const DEFAULT_GLOB_STAR_RECURSION_MAX = 200;
|
|
2108
|
+
const AWE_KEY = "allowWindowsEscape";
|
|
2109
|
+
const minimatch = (p, pattern, options) => {
|
|
2110
|
+
assertValidPattern(pattern);
|
|
2111
|
+
if (!options?.nocomment && pattern.charAt(0) === "#") return false;
|
|
2112
|
+
return cachedMinimatch(pattern, options).match(p);
|
|
2016
2113
|
};
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2114
|
+
let cache = /* @__PURE__ */ new Map();
|
|
2115
|
+
let oldCache = /* @__PURE__ */ new Map();
|
|
2116
|
+
let cacheSize = 0;
|
|
2117
|
+
let cacheTotalWeight = 0;
|
|
2118
|
+
const cacheMax = 256;
|
|
2119
|
+
const cacheMaxWeight = 32768;
|
|
2120
|
+
const cacheMaxEntryWeight = 4096;
|
|
2121
|
+
const cacheWeight = (mm) => {
|
|
2122
|
+
let w = mm.pattern.length;
|
|
2123
|
+
for (const s of mm.globSet) {
|
|
2124
|
+
w += s.length + 1;
|
|
2125
|
+
if (w > cacheMaxEntryWeight) break;
|
|
2126
|
+
}
|
|
2127
|
+
return w;
|
|
2020
2128
|
};
|
|
2021
|
-
const
|
|
2022
|
-
|
|
2023
|
-
|
|
2129
|
+
const tri = (v) => v === void 0 ? 0 : v ? 2 : 1;
|
|
2130
|
+
const booleanWeights = new Map(Object.keys({
|
|
2131
|
+
nobrace: 0,
|
|
2132
|
+
nocomment: 0,
|
|
2133
|
+
nonegate: 0,
|
|
2134
|
+
noglobstar: 0,
|
|
2135
|
+
noext: 0,
|
|
2136
|
+
nonull: 0,
|
|
2137
|
+
partial: 0,
|
|
2138
|
+
dot: 0,
|
|
2139
|
+
nocase: 0,
|
|
2140
|
+
nocaseMagicOnly: 0,
|
|
2141
|
+
magicalBraces: 0,
|
|
2142
|
+
matchBase: 0,
|
|
2143
|
+
flipNegate: 0,
|
|
2144
|
+
preserveMultipleSlashes: 0,
|
|
2145
|
+
windowsNoMagicRoot: 0
|
|
2146
|
+
}).map((k, i) => [k, 24 * 3 ** i]));
|
|
2147
|
+
const optionsKey = (o) => {
|
|
2148
|
+
let n = 0;
|
|
2149
|
+
let wpe = false;
|
|
2150
|
+
for (const k in o) {
|
|
2151
|
+
const v = o[k];
|
|
2152
|
+
switch (k) {
|
|
2153
|
+
case "windowsPathsNoEscape":
|
|
2154
|
+
if (v) wpe = true;
|
|
2155
|
+
break;
|
|
2156
|
+
case AWE_KEY:
|
|
2157
|
+
if (v === false) wpe = true;
|
|
2158
|
+
break;
|
|
2159
|
+
case "platform": {
|
|
2160
|
+
const p = v || defaultPlatform;
|
|
2161
|
+
if (p === defaultPlatform) break;
|
|
2162
|
+
if (p === "darwin") n += 3;
|
|
2163
|
+
else if (p === "win32") n += 6;
|
|
2164
|
+
else if (p === "linux") n += 9;
|
|
2165
|
+
else return JSON.stringify(o);
|
|
2166
|
+
break;
|
|
2167
|
+
}
|
|
2168
|
+
case "optimizationLevel":
|
|
2169
|
+
if (v === void 0) break;
|
|
2170
|
+
n += v >= 2 ? 1 : v >= 1 ? 0 : 2;
|
|
2171
|
+
break;
|
|
2172
|
+
case "braceExpandMax":
|
|
2173
|
+
if (v !== void 0 && v !== DEFAULT_BRACE_EXPAND_MAX) return JSON.stringify(o);
|
|
2174
|
+
break;
|
|
2175
|
+
case "maxGlobstarRecursion":
|
|
2176
|
+
if (v !== void 0 && v !== DEFAULT_GLOB_STAR_RECURSION_MAX) return JSON.stringify(o);
|
|
2177
|
+
break;
|
|
2178
|
+
case "normalize":
|
|
2179
|
+
if (v !== void 0) return JSON.stringify(o);
|
|
2180
|
+
break;
|
|
2181
|
+
default: n += (booleanWeights.get(k) ?? 0) * tri(v);
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
return wpe ? n + 12 : n;
|
|
2024
2185
|
};
|
|
2025
|
-
const
|
|
2026
|
-
const
|
|
2027
|
-
|
|
2186
|
+
const copyOptions = (o) => {
|
|
2187
|
+
const copy = {};
|
|
2188
|
+
for (const k in o) copy[k] = o[k];
|
|
2189
|
+
return copy;
|
|
2028
2190
|
};
|
|
2029
|
-
const
|
|
2030
|
-
const
|
|
2031
|
-
|
|
2191
|
+
const cachedMinimatch = (pattern, options) => {
|
|
2192
|
+
const key = options ? optionsKey(options) : 0;
|
|
2193
|
+
let mm = cache.get(key)?.get(pattern);
|
|
2194
|
+
if (mm) return mm;
|
|
2195
|
+
mm = oldCache.get(key)?.get(pattern) ?? new Minimatch(pattern, copyOptions(options));
|
|
2196
|
+
const weight = cacheWeight(mm);
|
|
2197
|
+
if (weight > cacheMaxEntryWeight) return mm;
|
|
2198
|
+
if (cacheSize >= cacheMax || cacheTotalWeight + weight > cacheMaxWeight) {
|
|
2199
|
+
oldCache = cache;
|
|
2200
|
+
cache = /* @__PURE__ */ new Map();
|
|
2201
|
+
cacheSize = 0;
|
|
2202
|
+
cacheTotalWeight = 0;
|
|
2203
|
+
}
|
|
2204
|
+
let byPattern = cache.get(key);
|
|
2205
|
+
if (!byPattern) cache.set(key, byPattern = /* @__PURE__ */ new Map());
|
|
2206
|
+
byPattern.set(pattern, mm);
|
|
2207
|
+
cacheSize++;
|
|
2208
|
+
cacheTotalWeight += weight;
|
|
2209
|
+
return mm;
|
|
2032
2210
|
};
|
|
2033
2211
|
/* c8 ignore start */
|
|
2034
|
-
const defaultPlatform = typeof process === "object" && process ?
|
|
2212
|
+
const defaultPlatform = typeof process === "object" && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
2035
2213
|
const path = {
|
|
2036
2214
|
win32: { sep: "\\" },
|
|
2037
2215
|
posix: { sep: "/" }
|
|
@@ -2039,10 +2217,10 @@ const path = {
|
|
|
2039
2217
|
minimatch.sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
2040
2218
|
const GLOBSTAR = Symbol("globstar **");
|
|
2041
2219
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
2042
|
-
const
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2220
|
+
const filter = (pattern, options) => {
|
|
2221
|
+
let mm;
|
|
2222
|
+
return (p) => (mm ??= cachedMinimatch(pattern, options)).match(p);
|
|
2223
|
+
};
|
|
2046
2224
|
minimatch.filter = filter;
|
|
2047
2225
|
const ext = (a, b = {}) => Object.assign({}, a, b);
|
|
2048
2226
|
const defaults = (def) => {
|
|
@@ -2058,21 +2236,10 @@ const defaults = (def) => {
|
|
|
2058
2236
|
return orig.defaults(ext(def, options)).Minimatch;
|
|
2059
2237
|
}
|
|
2060
2238
|
},
|
|
2061
|
-
AST: class AST extends orig.AST {
|
|
2062
|
-
/* c8 ignore start */
|
|
2063
|
-
constructor(type, parent, options = {}) {
|
|
2064
|
-
super(type, parent, ext(def, options));
|
|
2065
|
-
}
|
|
2066
|
-
/* c8 ignore stop */
|
|
2067
|
-
static fromGlob(pattern, options = {}) {
|
|
2068
|
-
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
2069
|
-
}
|
|
2070
|
-
},
|
|
2071
2239
|
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
2072
2240
|
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
2073
2241
|
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
2074
2242
|
defaults: (options) => orig.defaults(ext(def, options)),
|
|
2075
|
-
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
2076
2243
|
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
2077
2244
|
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
2078
2245
|
sep: orig.sep,
|
|
@@ -2083,11 +2250,27 @@ minimatch.defaults = defaults;
|
|
|
2083
2250
|
const braceExpand = (pattern, options = {}) => {
|
|
2084
2251
|
assertValidPattern(pattern);
|
|
2085
2252
|
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [pattern];
|
|
2086
|
-
|
|
2253
|
+
let p = pattern.replace(/\\\\/g, "\\\\\\\\");
|
|
2254
|
+
if (options.windowsPathsNoEscape || options[AWE_KEY] === false) p = p.replace(/\[([{}])\]/g, "[\\$1]");
|
|
2255
|
+
return expand(p, { max: options.braceExpandMax });
|
|
2087
2256
|
};
|
|
2088
2257
|
minimatch.braceExpand = braceExpand;
|
|
2089
|
-
const
|
|
2090
|
-
|
|
2258
|
+
const RANGE_MIN = 100;
|
|
2259
|
+
const rangeRe = /(?<![\\$])\{(-?\d+)\.\.(-?\d+)\}/g;
|
|
2260
|
+
const inRepeatOrNegExt = (portion, mark) => {
|
|
2261
|
+
const stack = [];
|
|
2262
|
+
for (let i = 0; i < portion.length; i++) {
|
|
2263
|
+
const c = portion.charAt(i);
|
|
2264
|
+
if (c === "\\") i++;
|
|
2265
|
+
else if (c === mark) {
|
|
2266
|
+
if (stack.some((t) => t !== "@" && t !== "?")) return true;
|
|
2267
|
+
} else if (portion.charAt(i + 1) === "(" && "!?+*@".includes(c)) {
|
|
2268
|
+
stack.push(c);
|
|
2269
|
+
i++;
|
|
2270
|
+
} else if (c === ")") stack.pop();
|
|
2271
|
+
}
|
|
2272
|
+
return false;
|
|
2273
|
+
};
|
|
2091
2274
|
const match = (list, pattern, options = {}) => {
|
|
2092
2275
|
const mm = new Minimatch(pattern, options);
|
|
2093
2276
|
list = list.filter((f) => mm.match(f));
|
|
@@ -2096,7 +2279,114 @@ const match = (list, pattern, options = {}) => {
|
|
|
2096
2279
|
};
|
|
2097
2280
|
minimatch.match = match;
|
|
2098
2281
|
const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
2099
|
-
const
|
|
2282
|
+
const classEnd = (pattern, start) => {
|
|
2283
|
+
let i = start + 1;
|
|
2284
|
+
if (pattern.charAt(i) === "!" || pattern.charAt(i) === "^") i++;
|
|
2285
|
+
let sawStart = false;
|
|
2286
|
+
for (; i < pattern.length; i++) {
|
|
2287
|
+
const c = pattern.charAt(i);
|
|
2288
|
+
if (c === "]" && sawStart) return i;
|
|
2289
|
+
sawStart = true;
|
|
2290
|
+
if (c === "\\") i++;
|
|
2291
|
+
}
|
|
2292
|
+
return -1;
|
|
2293
|
+
};
|
|
2294
|
+
const literal = (pattern, noext) => {
|
|
2295
|
+
if (!noext && (pattern === "+()" || pattern === "@()")) return pattern;
|
|
2296
|
+
let lit = "";
|
|
2297
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
2298
|
+
const c = pattern.charAt(i);
|
|
2299
|
+
if (c === "\\") lit += pattern.charAt(++i) || c;
|
|
2300
|
+
else if (c === "*" || c === "?") return;
|
|
2301
|
+
else if (c === "[") {
|
|
2302
|
+
const close = classEnd(pattern, i);
|
|
2303
|
+
if (close === -1) {
|
|
2304
|
+
lit += c;
|
|
2305
|
+
continue;
|
|
2306
|
+
}
|
|
2307
|
+
let body = pattern.slice(i + 1, close);
|
|
2308
|
+
if (body.startsWith("\\")) body = body.slice(1);
|
|
2309
|
+
if ([...body].length !== 1 || "!^".includes(pattern.charAt(i + 1))) return;
|
|
2310
|
+
lit += body;
|
|
2311
|
+
i = close;
|
|
2312
|
+
} else if (!noext && "+@!".includes(c) && pattern.charAt(i + 1) === "(" && pattern.includes(")", i + 2)) return;
|
|
2313
|
+
else lit += c;
|
|
2314
|
+
}
|
|
2315
|
+
return lit;
|
|
2316
|
+
};
|
|
2317
|
+
const MAX_EXTGLOBS = 256;
|
|
2318
|
+
const extglobCount = (pattern) => {
|
|
2319
|
+
let n = 0;
|
|
2320
|
+
for (let i = 0; i < pattern.length - 1; i++) {
|
|
2321
|
+
const c = pattern.charAt(i);
|
|
2322
|
+
if (c === "\\") i++;
|
|
2323
|
+
else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
|
|
2324
|
+
n++;
|
|
2325
|
+
i++;
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
return n;
|
|
2329
|
+
};
|
|
2330
|
+
const assertValidExtglobs = (pattern) => {
|
|
2331
|
+
if (extglobCount(pattern) > MAX_EXTGLOBS) throw new TypeError("pattern has too many extglobs");
|
|
2332
|
+
};
|
|
2333
|
+
const extSafe = (pattern) => {
|
|
2334
|
+
if (/^[?*+@]\(\)$/.test(pattern) || pattern.includes("[:")) return false;
|
|
2335
|
+
let depth = 0;
|
|
2336
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
2337
|
+
const c = pattern.charAt(i);
|
|
2338
|
+
if (c === "\\") {
|
|
2339
|
+
if (++i === pattern.length) return false;
|
|
2340
|
+
} else if (c === "[") {
|
|
2341
|
+
const close = classEnd(pattern, i);
|
|
2342
|
+
if (close !== -1) i = close;
|
|
2343
|
+
} else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
|
|
2344
|
+
depth++;
|
|
2345
|
+
i++;
|
|
2346
|
+
} else if (c === ")") {
|
|
2347
|
+
if (!depth--) return false;
|
|
2348
|
+
} else if (c === "|" && !depth) return false;
|
|
2349
|
+
}
|
|
2350
|
+
return !depth;
|
|
2351
|
+
};
|
|
2352
|
+
let lastSplit;
|
|
2353
|
+
let lastChecked;
|
|
2354
|
+
const portionMatch = (p, f) => typeof p === "string" ? f === p : f !== "" && p.testUnchecked(f);
|
|
2355
|
+
const endIndex = (p, last, lastStart, prev, prevStart) => portionMatch(p, last) ? lastStart : prev !== void 0 && portionMatch(p, prev) ? prevStart : -1;
|
|
2356
|
+
const isDots = (p) => p === "." || p === "..";
|
|
2357
|
+
const isDrive = (p) => typeof p === "string" && /^[a-z]:$/i.test(p);
|
|
2358
|
+
const isLongUNC = (p) => typeof p === "string" && /^unc$/i.test(p);
|
|
2359
|
+
const uncHost = (p) => {
|
|
2360
|
+
if (p[0] !== "" || p[1] !== "") return -1;
|
|
2361
|
+
const h = p[2] !== "?" ? 2 : isLongUNC(p[3]) ? 4 : -1;
|
|
2362
|
+
const host = p[h];
|
|
2363
|
+
const share = p[h + 1];
|
|
2364
|
+
return h !== -1 && host !== void 0 && host !== "" && host !== GLOBSTAR && share !== void 0 && share !== "" && share !== GLOBSTAR ? h : -1;
|
|
2365
|
+
};
|
|
2366
|
+
const walkable = (p, dot) => !isDots(p) && (dot || !p.startsWith("."));
|
|
2367
|
+
const dotPortion = (f, start, end, dot, sep) => {
|
|
2368
|
+
for (let k = start; k < end;) {
|
|
2369
|
+
if (f.charCodeAt(k) === 46) {
|
|
2370
|
+
if (!dot) return true;
|
|
2371
|
+
const n = f.charCodeAt(k + 1) === 46 ? k + 2 : k + 1;
|
|
2372
|
+
if (n >= end || isSep(f.charCodeAt(n), sep)) return true;
|
|
2373
|
+
}
|
|
2374
|
+
const s = nextSep(f, k, sep);
|
|
2375
|
+
if (s === -1) return false;
|
|
2376
|
+
k = s + 1;
|
|
2377
|
+
while (k < end && isSep(f.charCodeAt(k), sep)) k++;
|
|
2378
|
+
}
|
|
2379
|
+
return false;
|
|
2380
|
+
};
|
|
2381
|
+
const isSep = (c, sep) => sep === "/" ? c === 47 : sep === "\\" ? c === 92 : c === 47 || c === 92;
|
|
2382
|
+
const nextSep = (f, from, sep) => {
|
|
2383
|
+
if (sep !== "both") return f.indexOf(sep, from);
|
|
2384
|
+
const s = f.indexOf("/", from);
|
|
2385
|
+
const b = f.indexOf("\\", from);
|
|
2386
|
+
return s === -1 ? b : b === -1 ? s : Math.min(s, b);
|
|
2387
|
+
};
|
|
2388
|
+
const lastSep = (f, from, sep) => sep !== "both" ? f.lastIndexOf(sep, from) : Math.max(f.lastIndexOf("/", from), f.lastIndexOf("\\", from));
|
|
2389
|
+
const PENDING = {};
|
|
2100
2390
|
var Minimatch = class {
|
|
2101
2391
|
options;
|
|
2102
2392
|
set;
|
|
@@ -2115,20 +2405,28 @@ var Minimatch = class {
|
|
|
2115
2405
|
platform;
|
|
2116
2406
|
windowsNoMagicRoot;
|
|
2117
2407
|
maxGlobstarRecursion;
|
|
2118
|
-
|
|
2408
|
+
#endCheck;
|
|
2409
|
+
#literalCheck;
|
|
2410
|
+
#level2;
|
|
2411
|
+
#form;
|
|
2412
|
+
#literals = [];
|
|
2413
|
+
#shapes = [];
|
|
2414
|
+
#endRows = [];
|
|
2415
|
+
#matchers = /* @__PURE__ */ new Map();
|
|
2416
|
+
#pending = false;
|
|
2417
|
+
#rangeMark;
|
|
2418
|
+
#globstarParts = /* @__PURE__ */ new WeakMap();
|
|
2119
2419
|
constructor(pattern, options = {}) {
|
|
2120
2420
|
assertValidPattern(pattern);
|
|
2121
2421
|
options = options || {};
|
|
2122
2422
|
this.options = options;
|
|
2123
|
-
this.maxGlobstarRecursion = options.maxGlobstarRecursion ??
|
|
2423
|
+
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? DEFAULT_GLOB_STAR_RECURSION_MAX;
|
|
2124
2424
|
this.pattern = pattern;
|
|
2125
2425
|
this.platform = options.platform || defaultPlatform;
|
|
2126
2426
|
this.isWindows = this.platform === "win32";
|
|
2127
|
-
|
|
2128
|
-
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
|
|
2427
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[AWE_KEY] === false;
|
|
2129
2428
|
if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, "/");
|
|
2130
2429
|
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
2131
|
-
this.regexp = null;
|
|
2132
2430
|
this.negate = false;
|
|
2133
2431
|
this.nonegate = !!options.nonegate;
|
|
2134
2432
|
this.comment = false;
|
|
@@ -2139,14 +2437,45 @@ var Minimatch = class {
|
|
|
2139
2437
|
this.globSet = [];
|
|
2140
2438
|
this.globParts = [];
|
|
2141
2439
|
this.set = [];
|
|
2440
|
+
this.#endCheck = !this.preserveMultipleSlashes;
|
|
2441
|
+
this.#level2 = (options.optimizationLevel ?? 1) >= 2;
|
|
2442
|
+
const n = options.normalize;
|
|
2443
|
+
this.#form = n === true ? "NFC" : n || void 0;
|
|
2142
2444
|
this.make();
|
|
2445
|
+
const drives = this.set.map((row) => this.#rootIndex(row));
|
|
2446
|
+
this.#endRows = this.set.map((row, r) => this.#endCheck && row.length - 1 > drives[r]);
|
|
2447
|
+
this.#literals = this.set.map((row, r) => {
|
|
2448
|
+
const end = this.#endRows[r] ? row.length - 1 : row.length;
|
|
2449
|
+
const lits = row.slice(drives[r] + 1, end).filter((p) => typeof p === "string" && !!p);
|
|
2450
|
+
return [...new Set(lits)];
|
|
2451
|
+
});
|
|
2452
|
+
this.#literalCheck = this.#literals.some((l) => l.length);
|
|
2453
|
+
this.#shapes = this.set.map((row, r) => {
|
|
2454
|
+
const [p0, p1, p2] = row;
|
|
2455
|
+
if (this.#endRows[r] && row.length === 2) {
|
|
2456
|
+
if (p0 === GLOBSTAR && p1 !== GLOBSTAR) return "tail";
|
|
2457
|
+
}
|
|
2458
|
+
if (this.#endRows[r] && options.matchBase && row.length === 1 && p0 !== GLOBSTAR && p0 !== "") return "base";
|
|
2459
|
+
if (!this.#endCheck || drives[r] !== -1) return void 0;
|
|
2460
|
+
if (row.length === 3 && p0 === GLOBSTAR && p2 === GLOBSTAR && p1 !== GLOBSTAR && p1 !== "" && this.maxGlobstarRecursion > 0) return "mid";
|
|
2461
|
+
if (row.length === 2 && p1 === GLOBSTAR && p0 !== GLOBSTAR && p0 !== "") return "head";
|
|
2462
|
+
});
|
|
2463
|
+
}
|
|
2464
|
+
#norm(p) {
|
|
2465
|
+
return this.#form ? p.normalize(this.#form) : p;
|
|
2466
|
+
}
|
|
2467
|
+
#rootIndex(row) {
|
|
2468
|
+
if (!this.isWindows) return -1;
|
|
2469
|
+
if (isDrive(row[0])) return 0;
|
|
2470
|
+
if (row[0] === "" && row[1] === "" && row[2] === "?" && isDrive(row[3])) return 3;
|
|
2471
|
+
const h = uncHost(row);
|
|
2472
|
+
return h === -1 ? -1 : h + 1;
|
|
2143
2473
|
}
|
|
2144
2474
|
hasMagic() {
|
|
2145
2475
|
if (this.options.magicalBraces && this.set.length > 1) return true;
|
|
2146
2476
|
for (const pattern of this.set) for (const part of pattern) if (typeof part !== "string") return true;
|
|
2147
2477
|
return false;
|
|
2148
2478
|
}
|
|
2149
|
-
debug(..._) {}
|
|
2150
2479
|
make() {
|
|
2151
2480
|
const pattern = this.pattern;
|
|
2152
2481
|
const options = this.options;
|
|
@@ -2159,28 +2488,108 @@ var Minimatch = class {
|
|
|
2159
2488
|
return;
|
|
2160
2489
|
}
|
|
2161
2490
|
this.parseNegate();
|
|
2162
|
-
this.globSet = [...new Set(this
|
|
2163
|
-
|
|
2164
|
-
this.debug(this.pattern, this.globSet);
|
|
2165
|
-
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
2491
|
+
this.globSet = [...new Set(this.#expandBraces())];
|
|
2492
|
+
const rawGlobParts = this.globSet.map((s) => this.#slashSplit(s));
|
|
2166
2493
|
this.globParts = this.preprocess(rawGlobParts);
|
|
2167
|
-
this
|
|
2494
|
+
this.#pending = true;
|
|
2168
2495
|
let set = this.globParts.map((s, _, __) => {
|
|
2169
2496
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
2170
|
-
const
|
|
2497
|
+
const n = s[2] === "?" && isLongUNC(s[3]) ? 6 : 4;
|
|
2498
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && s.slice(3, n).every((p) => !globMagic.test(p));
|
|
2171
2499
|
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
2172
|
-
if (isUNC) return [...s.slice(0,
|
|
2173
|
-
else if (isDrive) return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
2500
|
+
if (isUNC) return [...s.slice(0, n).map((p) => this.#norm(p)), ...s.slice(n).map((ss) => this.parse(ss))];
|
|
2501
|
+
else if (isDrive) return [this.#norm(s[0]), ...s.slice(1).map((ss) => this.parse(ss))];
|
|
2174
2502
|
}
|
|
2175
2503
|
return s.map((ss) => this.parse(ss));
|
|
2176
2504
|
});
|
|
2177
|
-
this.debug(this.pattern, set);
|
|
2178
2505
|
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
2179
2506
|
if (this.isWindows) for (let i = 0; i < this.set.length; i++) {
|
|
2180
2507
|
const p = this.set[i];
|
|
2181
|
-
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" &&
|
|
2508
|
+
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && (isDrive(p[3]) || isLongUNC(this.globParts[i][3]))) {
|
|
2509
|
+
if (isLongUNC(this.globParts[i][3])) p[3] = "UNC";
|
|
2510
|
+
p[2] = "?";
|
|
2511
|
+
}
|
|
2512
|
+
}
|
|
2513
|
+
if (!options.noext) this.mergeRows();
|
|
2514
|
+
this.#pending = false;
|
|
2515
|
+
this.set.forEach((row, i) => {
|
|
2516
|
+
for (let k = 0; k < row.length; k++) if (row[k] === PENDING) row[k] = this.parse(this.globParts[i][k]);
|
|
2517
|
+
});
|
|
2518
|
+
}
|
|
2519
|
+
mergeRows() {
|
|
2520
|
+
let merged = true;
|
|
2521
|
+
while (merged) {
|
|
2522
|
+
merged = false;
|
|
2523
|
+
if (this.set.length < 2) return;
|
|
2524
|
+
let keys = this.#mergeKeys();
|
|
2525
|
+
const len = Math.max(0, ...this.set.map((r) => r.length));
|
|
2526
|
+
for (let k = 0; k < len; k++) {
|
|
2527
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2528
|
+
const R = this.set.length + 1;
|
|
2529
|
+
this.set.forEach((row, i) => {
|
|
2530
|
+
if (!(row[k] instanceof Matcher || row[k] === PENDING) || !extSafe(this.globParts[i][k])) return;
|
|
2531
|
+
const { pre, suf } = keys[i];
|
|
2532
|
+
const key = pre[k] * R + suf[k + 1];
|
|
2533
|
+
const g = groups.get(key);
|
|
2534
|
+
if (g) g.push(i);
|
|
2535
|
+
else groups.set(key, [i]);
|
|
2536
|
+
});
|
|
2537
|
+
const drop = /* @__PURE__ */ new Set();
|
|
2538
|
+
for (const g of groups.values()) {
|
|
2539
|
+
if (g.length < 2) continue;
|
|
2540
|
+
const [first, ...rest] = g;
|
|
2541
|
+
const glob = `@(${g.map((i) => this.globParts[i][k]).join("|")})`;
|
|
2542
|
+
if (extglobCount(glob) > MAX_EXTGLOBS) continue;
|
|
2543
|
+
this.globParts[first][k] = glob;
|
|
2544
|
+
this.set[first][k] = this.parse(glob);
|
|
2545
|
+
for (const i of rest) drop.add(i);
|
|
2546
|
+
}
|
|
2547
|
+
if (drop.size) {
|
|
2548
|
+
merged = true;
|
|
2549
|
+
this.set = this.set.filter((_, i) => !drop.has(i));
|
|
2550
|
+
this.globParts = this.globParts.filter((_, i) => !drop.has(i));
|
|
2551
|
+
if (this.set.length < 2) return;
|
|
2552
|
+
keys = this.#mergeKeys();
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2182
2555
|
}
|
|
2183
|
-
|
|
2556
|
+
}
|
|
2557
|
+
#mergeKeys() {
|
|
2558
|
+
const partIds = /* @__PURE__ */ new Map();
|
|
2559
|
+
const ids = this.globParts.map((parts) => parts.map((s) => {
|
|
2560
|
+
let id = partIds.get(s);
|
|
2561
|
+
if (id === void 0) partIds.set(s, id = partIds.size);
|
|
2562
|
+
return id;
|
|
2563
|
+
}));
|
|
2564
|
+
const P = partIds.size;
|
|
2565
|
+
const len = Math.max(0, ...ids.map((r) => r.length));
|
|
2566
|
+
const keys = ids.map((r) => ({
|
|
2567
|
+
pre: [0],
|
|
2568
|
+
suf: new Array(r.length + 1).fill(0)
|
|
2569
|
+
}));
|
|
2570
|
+
for (let k = 0; k < len; k++) {
|
|
2571
|
+
const m = /* @__PURE__ */ new Map();
|
|
2572
|
+
ids.forEach((r, i) => {
|
|
2573
|
+
if (k >= r.length) return;
|
|
2574
|
+
const { pre } = keys[i];
|
|
2575
|
+
const key = pre[k] * P + r[k];
|
|
2576
|
+
let id = m.get(key);
|
|
2577
|
+
if (id === void 0) m.set(key, id = m.size + 1);
|
|
2578
|
+
pre.push(id);
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
for (let k = len - 1; k >= 0; k--) {
|
|
2582
|
+
const m = /* @__PURE__ */ new Map();
|
|
2583
|
+
ids.forEach((r, i) => {
|
|
2584
|
+
if (k >= r.length) return;
|
|
2585
|
+
const { suf } = keys[i];
|
|
2586
|
+
const key = suf[k + 1] * P + r[k];
|
|
2587
|
+
let id = m.get(key);
|
|
2588
|
+
if (id === void 0) m.set(key, id = m.size + 1);
|
|
2589
|
+
suf[k] = id;
|
|
2590
|
+
});
|
|
2591
|
+
}
|
|
2592
|
+
return keys;
|
|
2184
2593
|
}
|
|
2185
2594
|
preprocess(globParts) {
|
|
2186
2595
|
if (this.options.noglobstar) {
|
|
@@ -2207,11 +2616,12 @@ var Minimatch = class {
|
|
|
2207
2616
|
}
|
|
2208
2617
|
levelOneOptimize(globParts) {
|
|
2209
2618
|
return globParts.map((parts) => {
|
|
2619
|
+
const root = this.#rootIndex(parts) + 1;
|
|
2210
2620
|
parts = parts.reduce((set, part) => {
|
|
2211
2621
|
const prev = set[set.length - 1];
|
|
2212
2622
|
if (part === "**" && prev === "**") return set;
|
|
2213
2623
|
if (part === "..") {
|
|
2214
|
-
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
2624
|
+
if (set.length > root && prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
2215
2625
|
set.pop();
|
|
2216
2626
|
return set;
|
|
2217
2627
|
}
|
|
@@ -2222,8 +2632,120 @@ var Minimatch = class {
|
|
|
2222
2632
|
return parts.length === 0 ? [""] : parts;
|
|
2223
2633
|
});
|
|
2224
2634
|
}
|
|
2225
|
-
|
|
2226
|
-
|
|
2635
|
+
#canMatch(f) {
|
|
2636
|
+
const sep = !this.isWindows || !f.includes("\\") ? "/" : f.includes("/") ? "both" : "\\";
|
|
2637
|
+
let ends = this.#endCheck ? 0 : -1;
|
|
2638
|
+
let last = "";
|
|
2639
|
+
let lastStart = 0;
|
|
2640
|
+
let prev;
|
|
2641
|
+
let prevStart = 0;
|
|
2642
|
+
const dot = !!this.options.dot;
|
|
2643
|
+
ROWS: for (let r = 0; r < this.set.length; r++) {
|
|
2644
|
+
const row = this.set[r];
|
|
2645
|
+
const p = row[row.length - 1];
|
|
2646
|
+
let end = ends !== -1 && this.#endRows[r] && p !== GLOBSTAR;
|
|
2647
|
+
if (end && ends === 0) {
|
|
2648
|
+
const i = lastSep(f, f.length, sep);
|
|
2649
|
+
lastStart = i + 1;
|
|
2650
|
+
last = f.slice(lastStart);
|
|
2651
|
+
if (last === "" && i >= 0) {
|
|
2652
|
+
let j = i;
|
|
2653
|
+
while (j > 0 && isSep(f.charCodeAt(j - 1), sep)) j--;
|
|
2654
|
+
prevStart = j === 0 ? 0 : lastSep(f, j - 1, sep) + 1;
|
|
2655
|
+
prev = f.slice(prevStart, j);
|
|
2656
|
+
}
|
|
2657
|
+
const resolves = this.#level2 && (isDots(last) || last === "" && prev !== void 0 && isDots(prev));
|
|
2658
|
+
ends = resolves ? -1 : 1;
|
|
2659
|
+
end = !resolves;
|
|
2660
|
+
}
|
|
2661
|
+
let tailStart = -1;
|
|
2662
|
+
if (end && typeof p === "string") {
|
|
2663
|
+
tailStart = endIndex(p, last, lastStart, prev, prevStart);
|
|
2664
|
+
if (tailStart === -1) continue;
|
|
2665
|
+
}
|
|
2666
|
+
if (this.#literalCheck) {
|
|
2667
|
+
for (const l of this.#literals[r]) if (!f.includes(l)) continue ROWS;
|
|
2668
|
+
}
|
|
2669
|
+
if (end && typeof p === "object") {
|
|
2670
|
+
tailStart = endIndex(p, last, lastStart, prev, prevStart);
|
|
2671
|
+
if (tailStart === -1) continue;
|
|
2672
|
+
}
|
|
2673
|
+
const shape = this.#shapes[r];
|
|
2674
|
+
if (shape === "base" && end) return "yes";
|
|
2675
|
+
if (shape === "tail" && end) {
|
|
2676
|
+
if (this.#level2 && dotPortion(f, 0, tailStart, true, sep)) return "maybe";
|
|
2677
|
+
if (!dotPortion(f, 0, tailStart, dot, sep)) return "yes";
|
|
2678
|
+
continue;
|
|
2679
|
+
}
|
|
2680
|
+
if (shape === "mid" || shape === "head") {
|
|
2681
|
+
const m = this.#walk(f, row, shape === "head", dot, sep);
|
|
2682
|
+
if (m !== "no") return m;
|
|
2683
|
+
continue;
|
|
2684
|
+
}
|
|
2685
|
+
return "maybe";
|
|
2686
|
+
}
|
|
2687
|
+
return "no";
|
|
2688
|
+
}
|
|
2689
|
+
#matchShape(file, row, shape) {
|
|
2690
|
+
const dot = !!this.options.dot;
|
|
2691
|
+
const n = file.length;
|
|
2692
|
+
if (shape === "head") {
|
|
2693
|
+
if (n < 2 || !portionMatch(row[0], file[0])) return false;
|
|
2694
|
+
for (let i = 1; i < n; i++) if (!walkable(file[i], dot)) return false;
|
|
2695
|
+
return true;
|
|
2696
|
+
}
|
|
2697
|
+
const x = row[1];
|
|
2698
|
+
if (shape === "tail") {
|
|
2699
|
+
let t = n - 1;
|
|
2700
|
+
if (!portionMatch(x, file[t])) {
|
|
2701
|
+
if (file[t] !== "" || n === 1 || !portionMatch(x, file[--t])) return false;
|
|
2702
|
+
}
|
|
2703
|
+
for (let i = 0; i < t; i++) if (!walkable(file[i], dot)) return false;
|
|
2704
|
+
return true;
|
|
2705
|
+
}
|
|
2706
|
+
for (let k = 0; k < n; k++) {
|
|
2707
|
+
if (portionMatch(x, file[k]) && k + 1 < n) {
|
|
2708
|
+
let i = k + 1;
|
|
2709
|
+
while (i < n && walkable(file[i], dot)) i++;
|
|
2710
|
+
if (i === n) return true;
|
|
2711
|
+
}
|
|
2712
|
+
if (!walkable(file[k], dot)) return false;
|
|
2713
|
+
}
|
|
2714
|
+
return false;
|
|
2715
|
+
}
|
|
2716
|
+
#walk(f, row, head, dot, sep) {
|
|
2717
|
+
if (this.#level2 && dotPortion(f, 0, f.length, true, sep)) return "maybe";
|
|
2718
|
+
const x = row[head ? 0 : 1];
|
|
2719
|
+
let s = 0;
|
|
2720
|
+
for (let e = nextSep(f, s, sep); e !== -1; e = nextSep(f, s, sep)) {
|
|
2721
|
+
let next = e + 1;
|
|
2722
|
+
while (next < f.length && isSep(f.charCodeAt(next), sep)) next++;
|
|
2723
|
+
if ((typeof x === "string" ? e - s === x.length && f.startsWith(x, s) : e > s && x.testUnchecked(f.slice(s, e))) && !dotPortion(f, next, f.length, dot, sep)) return "yes";
|
|
2724
|
+
if (head || dotPortion(f, s, next, dot, sep)) return "no";
|
|
2725
|
+
s = next;
|
|
2726
|
+
}
|
|
2727
|
+
return "no";
|
|
2728
|
+
}
|
|
2729
|
+
#cachedSplit(f) {
|
|
2730
|
+
const last = lastSplit;
|
|
2731
|
+
return last?.f === f && last.isWindows === this.isWindows && last.preserveMultipleSlashes === this.preserveMultipleSlashes && last.normalize === this.#form ? last : void 0;
|
|
2732
|
+
}
|
|
2733
|
+
#split(f) {
|
|
2734
|
+
const { isWindows, preserveMultipleSlashes } = this;
|
|
2735
|
+
let parts = this.#slashSplit(isWindows ? f.split("\\").join("/") : f);
|
|
2736
|
+
const normalize = this.#form;
|
|
2737
|
+
if (normalize) parts = parts.map((p) => p.normalize(normalize));
|
|
2738
|
+
lastSplit = {
|
|
2739
|
+
f,
|
|
2740
|
+
isWindows,
|
|
2741
|
+
preserveMultipleSlashes,
|
|
2742
|
+
normalize,
|
|
2743
|
+
parts
|
|
2744
|
+
};
|
|
2745
|
+
return lastSplit;
|
|
2746
|
+
}
|
|
2747
|
+
#levelTwoFileOptimize(file) {
|
|
2748
|
+
const parts = [...file];
|
|
2227
2749
|
let didSomething = false;
|
|
2228
2750
|
do {
|
|
2229
2751
|
didSomething = false;
|
|
@@ -2242,19 +2764,23 @@ var Minimatch = class {
|
|
|
2242
2764
|
parts.pop();
|
|
2243
2765
|
}
|
|
2244
2766
|
}
|
|
2245
|
-
|
|
2767
|
+
const root = this.#rootIndex(parts) + 1;
|
|
2768
|
+
let dd = root;
|
|
2246
2769
|
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
2247
2770
|
const p = parts[dd - 1];
|
|
2248
|
-
if (p && p !== "." && p !== ".." && p !== "**"
|
|
2771
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
2249
2772
|
didSomething = true;
|
|
2250
2773
|
parts.splice(dd - 1, 2);
|
|
2251
|
-
dd
|
|
2774
|
+
dd = Math.max(dd - 2, root);
|
|
2252
2775
|
}
|
|
2253
2776
|
}
|
|
2254
2777
|
} while (didSomething);
|
|
2255
2778
|
return parts.length === 0 ? [""] : parts;
|
|
2256
2779
|
}
|
|
2257
2780
|
firstPhasePreProcess(globParts) {
|
|
2781
|
+
const { braceExpandMax = DEFAULT_BRACE_EXPAND_MAX } = this.options;
|
|
2782
|
+
let splitCells = 0;
|
|
2783
|
+
const maxSplitCells = 1e6;
|
|
2258
2784
|
let didSomething = false;
|
|
2259
2785
|
do {
|
|
2260
2786
|
didSomething = false;
|
|
@@ -2269,10 +2795,13 @@ var Minimatch = class {
|
|
|
2269
2795
|
const p2 = parts[gs + 3];
|
|
2270
2796
|
if (next !== "..") continue;
|
|
2271
2797
|
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") continue;
|
|
2798
|
+
const addedCells = parts.length - 1;
|
|
2799
|
+
if (globParts.length >= braceExpandMax || splitCells + addedCells > maxSplitCells) throw new RangeError(`optimizationLevel 2: too many patterns from '**/..'`);
|
|
2272
2800
|
didSomething = true;
|
|
2273
2801
|
parts.splice(gs, 1);
|
|
2274
2802
|
const other = parts.slice(0);
|
|
2275
2803
|
other[gs] = "**";
|
|
2804
|
+
splitCells += addedCells;
|
|
2276
2805
|
globParts.push(other);
|
|
2277
2806
|
gs--;
|
|
2278
2807
|
}
|
|
@@ -2291,7 +2820,8 @@ var Minimatch = class {
|
|
|
2291
2820
|
parts.pop();
|
|
2292
2821
|
}
|
|
2293
2822
|
}
|
|
2294
|
-
|
|
2823
|
+
const root = this.#rootIndex(parts) + 1;
|
|
2824
|
+
let dd = root;
|
|
2295
2825
|
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
2296
2826
|
const p = parts[dd - 1];
|
|
2297
2827
|
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
@@ -2299,7 +2829,7 @@ var Minimatch = class {
|
|
|
2299
2829
|
const splin = dd === 1 && parts[dd + 1] === "**" ? ["."] : [];
|
|
2300
2830
|
parts.splice(dd - 1, 2, ...splin);
|
|
2301
2831
|
if (parts.length === 0) parts.push("");
|
|
2302
|
-
dd
|
|
2832
|
+
dd = Math.max(dd - 2, root);
|
|
2303
2833
|
}
|
|
2304
2834
|
}
|
|
2305
2835
|
}
|
|
@@ -2307,45 +2837,41 @@ var Minimatch = class {
|
|
|
2307
2837
|
return globParts;
|
|
2308
2838
|
}
|
|
2309
2839
|
secondPhasePreProcess(globParts) {
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2840
|
+
const keys = /* @__PURE__ */ new Set();
|
|
2841
|
+
const rows = globParts.filter((parts) => {
|
|
2842
|
+
const key = parts.join("/");
|
|
2843
|
+
if (keys.has(key)) return false;
|
|
2844
|
+
keys.add(key);
|
|
2845
|
+
return true;
|
|
2846
|
+
});
|
|
2847
|
+
const stars = /* @__PURE__ */ new Map();
|
|
2848
|
+
for (const parts of rows) {
|
|
2849
|
+
const s = [];
|
|
2850
|
+
for (let i = 0; i < parts.length; i++) if (parts[i] === "*") s.push(i);
|
|
2851
|
+
if (s.length) stars.set(s.join(","), s);
|
|
2317
2852
|
}
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
bi++;
|
|
2341
|
-
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
2342
|
-
if (which === "a") return false;
|
|
2343
|
-
which = "b";
|
|
2344
|
-
result.push(b[bi]);
|
|
2345
|
-
ai++;
|
|
2346
|
-
bi++;
|
|
2347
|
-
} else return false;
|
|
2348
|
-
return a.length === b.length && result;
|
|
2853
|
+
if (!stars.size || rows.length * stars.size > 1e5) return rows;
|
|
2854
|
+
const { dot } = this.options;
|
|
2855
|
+
return rows.filter((parts) => {
|
|
2856
|
+
for (const s of stars.values()) {
|
|
2857
|
+
if (s[s.length - 1] >= parts.length) continue;
|
|
2858
|
+
const c = [...parts];
|
|
2859
|
+
let ok = true;
|
|
2860
|
+
let changed = false;
|
|
2861
|
+
for (const i of s) {
|
|
2862
|
+
const p = parts[i];
|
|
2863
|
+
if (p === "*") continue;
|
|
2864
|
+
if (!p || p === "**" || !dot && p.startsWith(".")) {
|
|
2865
|
+
ok = false;
|
|
2866
|
+
break;
|
|
2867
|
+
}
|
|
2868
|
+
c[i] = "*";
|
|
2869
|
+
changed = true;
|
|
2870
|
+
}
|
|
2871
|
+
if (ok && changed && keys.has(c.join("/"))) return false;
|
|
2872
|
+
}
|
|
2873
|
+
return true;
|
|
2874
|
+
});
|
|
2349
2875
|
}
|
|
2350
2876
|
parseNegate() {
|
|
2351
2877
|
if (this.nonegate) return;
|
|
@@ -2359,10 +2885,22 @@ var Minimatch = class {
|
|
|
2359
2885
|
if (negateOffset) this.pattern = pattern.slice(negateOffset);
|
|
2360
2886
|
this.negate = negate;
|
|
2361
2887
|
}
|
|
2362
|
-
|
|
2888
|
+
#matchRow(file, resolved, pattern, partial) {
|
|
2363
2889
|
let fileStartIndex = 0;
|
|
2364
2890
|
let patternStartIndex = 0;
|
|
2365
|
-
|
|
2891
|
+
const fh = this.isWindows ? uncHost(resolved) : -1;
|
|
2892
|
+
const ph = fh === -1 ? -1 : uncHost(pattern);
|
|
2893
|
+
if (ph !== -1) {
|
|
2894
|
+
const host = pattern[ph];
|
|
2895
|
+
const share = pattern[ph + 1];
|
|
2896
|
+
if (typeof host !== "string" || typeof share !== "string") {
|
|
2897
|
+
fileStartIndex = fh;
|
|
2898
|
+
patternStartIndex = ph;
|
|
2899
|
+
} else if (resolved[fh].toLowerCase() === host.toLowerCase() && resolved[fh + 1].toLowerCase() === share.toLowerCase()) {
|
|
2900
|
+
fileStartIndex = fh + 2;
|
|
2901
|
+
patternStartIndex = ph + 2;
|
|
2902
|
+
}
|
|
2903
|
+
} else if (this.isWindows) {
|
|
2366
2904
|
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
2367
2905
|
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
2368
2906
|
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
@@ -2372,32 +2910,20 @@ var Minimatch = class {
|
|
|
2372
2910
|
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
2373
2911
|
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
2374
2912
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
fileStartIndex = fdi;
|
|
2913
|
+
patternStartIndex = pdi + 1;
|
|
2914
|
+
fileStartIndex = fdi + 1;
|
|
2378
2915
|
}
|
|
2379
2916
|
}
|
|
2380
2917
|
}
|
|
2381
|
-
|
|
2382
|
-
if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
|
|
2918
|
+
file = resolved;
|
|
2383
2919
|
if (pattern.includes(GLOBSTAR)) return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
2384
2920
|
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
2385
2921
|
}
|
|
2386
2922
|
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
|
2387
|
-
const
|
|
2388
|
-
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
2389
|
-
const [head, body, tail] = partial ? [
|
|
2390
|
-
pattern.slice(patternIndex, firstgs),
|
|
2391
|
-
pattern.slice(firstgs + 1),
|
|
2392
|
-
[]
|
|
2393
|
-
] : [
|
|
2394
|
-
pattern.slice(patternIndex, firstgs),
|
|
2395
|
-
pattern.slice(firstgs + 1, lastgs),
|
|
2396
|
-
pattern.slice(lastgs + 1)
|
|
2397
|
-
];
|
|
2923
|
+
const { head, body, tail, segments } = this.#getGlobstarParts(pattern, partial, patternIndex);
|
|
2398
2924
|
if (head.length) {
|
|
2399
|
-
const
|
|
2400
|
-
if (!this.#matchOne(
|
|
2925
|
+
const headEnd = fileIndex + head.length;
|
|
2926
|
+
if (!this.#matchOne(file, head, partial, fileIndex, 0, headEnd)) return false;
|
|
2401
2927
|
fileIndex += head.length;
|
|
2402
2928
|
patternIndex += head.length;
|
|
2403
2929
|
}
|
|
@@ -2422,67 +2948,86 @@ var Minimatch = class {
|
|
|
2422
2948
|
}
|
|
2423
2949
|
return partial || sawSome;
|
|
2424
2950
|
}
|
|
2425
|
-
|
|
2426
|
-
|
|
2951
|
+
return !!this.#matchGlobStarBodySections(file, segments, file.length - fileTailMatch, fileIndex, 0, partial, 0, !!fileTailMatch, /* @__PURE__ */ new Set());
|
|
2952
|
+
}
|
|
2953
|
+
#getGlobstarParts(pattern, partial, patternIndex) {
|
|
2954
|
+
let byStart = this.#globstarParts.get(pattern);
|
|
2955
|
+
if (!byStart) {
|
|
2956
|
+
byStart = [];
|
|
2957
|
+
this.#globstarParts.set(pattern, byStart);
|
|
2958
|
+
}
|
|
2959
|
+
const key = patternIndex * 2 + (partial ? 1 : 0);
|
|
2960
|
+
const found = byStart[key];
|
|
2961
|
+
if (found) return found;
|
|
2962
|
+
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
|
|
2963
|
+
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
2964
|
+
const head = pattern.slice(patternIndex, firstgs);
|
|
2965
|
+
const body = pattern.slice(firstgs + 1, partial ? void 0 : lastgs);
|
|
2966
|
+
const tail = partial ? [] : pattern.slice(lastgs + 1);
|
|
2967
|
+
const segments = [[[], 0]];
|
|
2968
|
+
let current = segments[0];
|
|
2427
2969
|
let nonGsParts = 0;
|
|
2428
2970
|
const nonGsPartsSums = [0];
|
|
2429
2971
|
for (const b of body) if (b === GLOBSTAR) {
|
|
2430
2972
|
nonGsPartsSums.push(nonGsParts);
|
|
2431
|
-
|
|
2432
|
-
|
|
2973
|
+
current = [[], 0];
|
|
2974
|
+
segments.push(current);
|
|
2433
2975
|
} else {
|
|
2434
|
-
|
|
2976
|
+
current[0].push(b);
|
|
2435
2977
|
nonGsParts++;
|
|
2436
2978
|
}
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2979
|
+
segments.forEach((b, i) => {
|
|
2980
|
+
b[1] = nonGsParts - nonGsPartsSums[i];
|
|
2981
|
+
});
|
|
2982
|
+
const parts = {
|
|
2983
|
+
head,
|
|
2984
|
+
body,
|
|
2985
|
+
tail,
|
|
2986
|
+
segments
|
|
2987
|
+
};
|
|
2988
|
+
byStart[key] = parts;
|
|
2989
|
+
return parts;
|
|
2441
2990
|
}
|
|
2442
|
-
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
2991
|
+
#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex, bodyIndex, partial, globStarDepth, sawTail, tried) {
|
|
2443
2992
|
const bs = bodySegments[bodyIndex];
|
|
2444
2993
|
if (!bs) {
|
|
2445
|
-
|
|
2994
|
+
if (partial) return fileIndex >= fileLength || fileIndex === fileLength - 1 && file[fileIndex] === "";
|
|
2995
|
+
for (let i = fileIndex; i < fileLength; i++) {
|
|
2446
2996
|
sawTail = true;
|
|
2447
2997
|
const f = file[i];
|
|
2448
2998
|
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
|
|
2449
2999
|
}
|
|
2450
3000
|
return sawTail;
|
|
2451
3001
|
}
|
|
2452
|
-
const [body,
|
|
3002
|
+
const [body, need] = bs;
|
|
3003
|
+
const after = partial ? fileLength : fileLength - need;
|
|
2453
3004
|
while (fileIndex <= after) {
|
|
2454
|
-
|
|
2455
|
-
|
|
3005
|
+
const key = bodyIndex * (file.length + 1) + fileIndex;
|
|
3006
|
+
if (tried.has(key)) return false;
|
|
3007
|
+
tried.add(key);
|
|
3008
|
+
if (this.#matchOne(file, body, partial, fileIndex, 0, fileIndex + body.length) && globStarDepth < this.maxGlobstarRecursion) {
|
|
3009
|
+
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail, tried);
|
|
2456
3010
|
if (sub !== false) return sub;
|
|
2457
3011
|
}
|
|
3012
|
+
if (fileIndex === after) break;
|
|
2458
3013
|
const f = file[fileIndex];
|
|
2459
3014
|
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
|
|
2460
3015
|
fileIndex++;
|
|
2461
3016
|
}
|
|
2462
3017
|
return partial || null;
|
|
2463
3018
|
}
|
|
2464
|
-
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
3019
|
+
#matchOne(file, pattern, partial, fileIndex, patternIndex, fileEnd = file.length) {
|
|
2465
3020
|
let fi;
|
|
2466
3021
|
let pi;
|
|
2467
3022
|
let pl;
|
|
2468
3023
|
let fl;
|
|
2469
|
-
for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
2470
|
-
this.debug("matchOne loop");
|
|
3024
|
+
for (fi = fileIndex, pi = patternIndex, fl = Math.min(fileEnd, file.length), pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
2471
3025
|
let p = pattern[pi];
|
|
2472
3026
|
let f = file[fi];
|
|
2473
|
-
this.debug(pattern, p, f);
|
|
2474
3027
|
/* c8 ignore start */
|
|
2475
3028
|
if (p === false || p === GLOBSTAR) return false;
|
|
2476
3029
|
/* c8 ignore stop */
|
|
2477
|
-
|
|
2478
|
-
if (typeof p === "string") {
|
|
2479
|
-
hit = f === p;
|
|
2480
|
-
this.debug("string match", p, f, hit);
|
|
2481
|
-
} else {
|
|
2482
|
-
hit = p.test(f);
|
|
2483
|
-
this.debug("pattern match", p, f, hit);
|
|
2484
|
-
}
|
|
2485
|
-
if (!hit) return false;
|
|
3030
|
+
if (!portionMatch(p, f)) return false;
|
|
2486
3031
|
}
|
|
2487
3032
|
if (fi === fl && pi === pl) return true;
|
|
2488
3033
|
else if (fi === fl) return partial;
|
|
@@ -2493,92 +3038,83 @@ var Minimatch = class {
|
|
|
2493
3038
|
braceExpand() {
|
|
2494
3039
|
return braceExpand(this.pattern, this.options);
|
|
2495
3040
|
}
|
|
3041
|
+
#expandBraces() {
|
|
3042
|
+
const { pattern } = this;
|
|
3043
|
+
if (this.options.nobrace) return this.braceExpand();
|
|
3044
|
+
let code = 57344;
|
|
3045
|
+
while (pattern.includes(String.fromCharCode(code))) if (++code > 63743) return this.braceExpand();
|
|
3046
|
+
const mark = String.fromCharCode(code);
|
|
3047
|
+
let found = false;
|
|
3048
|
+
const marked = pattern.replace(rangeRe, (m, lo, hi) => {
|
|
3049
|
+
const a = Number(lo);
|
|
3050
|
+
const b = Number(hi);
|
|
3051
|
+
if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b) || Math.abs(a - b) + 1 < RANGE_MIN) return m;
|
|
3052
|
+
found = true;
|
|
3053
|
+
return `${mark}${lo}..${hi}${mark}`;
|
|
3054
|
+
});
|
|
3055
|
+
if (!found) return this.braceExpand();
|
|
3056
|
+
const set = braceExpand(marked, this.options);
|
|
3057
|
+
for (const p of set) for (const portion of p.split("/")) {
|
|
3058
|
+
const c = portion.indexOf("[");
|
|
3059
|
+
if (c !== -1 && c < portion.lastIndexOf(mark)) return this.braceExpand();
|
|
3060
|
+
if (!this.options.noext && inRepeatOrNegExt(portion, mark)) return this.braceExpand();
|
|
3061
|
+
}
|
|
3062
|
+
this.#rangeMark = mark;
|
|
3063
|
+
return set;
|
|
3064
|
+
}
|
|
2496
3065
|
parse(pattern) {
|
|
2497
3066
|
assertValidPattern(pattern);
|
|
2498
3067
|
const options = this.options;
|
|
2499
3068
|
if (pattern === "**") return GLOBSTAR;
|
|
2500
3069
|
if (pattern === "") return "";
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
if (!set.length) {
|
|
2516
|
-
this.regexp = false;
|
|
2517
|
-
return this.regexp;
|
|
2518
|
-
}
|
|
2519
|
-
const options = this.options;
|
|
2520
|
-
const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
|
|
2521
|
-
const flags = new Set(options.nocase ? ["i"] : []);
|
|
2522
|
-
let re = set.map((pattern) => {
|
|
2523
|
-
const pp = pattern.map((p) => {
|
|
2524
|
-
if (p instanceof RegExp) for (const f of p.flags.split("")) flags.add(f);
|
|
2525
|
-
return typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
2526
|
-
});
|
|
2527
|
-
pp.forEach((p, i) => {
|
|
2528
|
-
const next = pp[i + 1];
|
|
2529
|
-
const prev = pp[i - 1];
|
|
2530
|
-
if (p !== GLOBSTAR || prev === GLOBSTAR) return;
|
|
2531
|
-
if (prev === void 0) {
|
|
2532
|
-
if (next !== void 0 && next !== GLOBSTAR) pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
2533
|
-
else pp[i] = twoStar;
|
|
2534
|
-
} else if (next === void 0) pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
|
|
2535
|
-
else if (next !== GLOBSTAR) {
|
|
2536
|
-
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
2537
|
-
pp[i + 1] = GLOBSTAR;
|
|
2538
|
-
}
|
|
3070
|
+
const { nocase, nocaseMagicOnly, noext = false, dot, normalize } = options;
|
|
3071
|
+
const rangeMark = this.#rangeMark;
|
|
3072
|
+
const lit = rangeMark && pattern.includes(rangeMark) ? void 0 : literal(pattern, noext);
|
|
3073
|
+
if (lit !== void 0 && !(nocase && !nocaseMagicOnly && pattern.toUpperCase() !== pattern.toLowerCase())) return this.#norm(lit);
|
|
3074
|
+
if (this.#pending) return PENDING;
|
|
3075
|
+
let m = this.#matchers.get(pattern);
|
|
3076
|
+
if (!m) {
|
|
3077
|
+
if (!noext) assertValidExtglobs(pattern);
|
|
3078
|
+
m = new Matcher(pattern, {
|
|
3079
|
+
nocase,
|
|
3080
|
+
noext,
|
|
3081
|
+
dot,
|
|
3082
|
+
normalize,
|
|
3083
|
+
...rangeMark && { rangeMark }
|
|
2539
3084
|
});
|
|
2540
|
-
|
|
2541
|
-
if (this.partial && filtered.length >= 1) {
|
|
2542
|
-
const prefixes = [];
|
|
2543
|
-
for (let i = 1; i <= filtered.length; i++) prefixes.push(filtered.slice(0, i).join("/"));
|
|
2544
|
-
return "(?:" + prefixes.join("|") + ")";
|
|
2545
|
-
}
|
|
2546
|
-
return filtered.join("/");
|
|
2547
|
-
}).join("|");
|
|
2548
|
-
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
2549
|
-
re = "^" + open + re + close + "$";
|
|
2550
|
-
if (this.partial) re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
|
|
2551
|
-
if (this.negate) re = "^(?!" + re + ").+$";
|
|
2552
|
-
try {
|
|
2553
|
-
this.regexp = new RegExp(re, [...flags].join(""));
|
|
2554
|
-
} catch {
|
|
2555
|
-
this.regexp = false;
|
|
3085
|
+
this.#matchers.set(pattern, m);
|
|
2556
3086
|
}
|
|
2557
|
-
|
|
2558
|
-
return this.regexp;
|
|
3087
|
+
return m;
|
|
2559
3088
|
}
|
|
2560
|
-
slashSplit(p) {
|
|
3089
|
+
#slashSplit(p) {
|
|
2561
3090
|
if (this.preserveMultipleSlashes) return p.split("/");
|
|
2562
3091
|
else if (this.isWindows && /^\/\/[^/]+/.test(p)) return ["", ...p.split(/\/+/)];
|
|
2563
3092
|
else return p.split(/\/+/);
|
|
2564
3093
|
}
|
|
2565
3094
|
match(f, partial = this.partial) {
|
|
2566
|
-
this.debug("match", f, this.pattern);
|
|
2567
3095
|
if (this.comment) return false;
|
|
2568
3096
|
if (this.empty) return f === "";
|
|
2569
3097
|
if (f === "/" && partial) return true;
|
|
2570
3098
|
const options = this.options;
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
3099
|
+
let split = this.#cachedSplit(f);
|
|
3100
|
+
if (!split) {
|
|
3101
|
+
if (!partial && !this.#form && (this.#endCheck || this.#literalCheck) && lastChecked !== f) {
|
|
3102
|
+
lastChecked = f;
|
|
3103
|
+
const can = this.#canMatch(f);
|
|
3104
|
+
if (can === "no") return options.flipNegate ? false : this.negate;
|
|
3105
|
+
if (can === "yes") return options.flipNegate ? true : !this.negate;
|
|
3106
|
+
}
|
|
3107
|
+
split = this.#split(f);
|
|
3108
|
+
}
|
|
3109
|
+
const ff = split.parts;
|
|
3110
|
+
const resolved = this.#level2 ? split.resolved ??= this.#levelTwoFileOptimize(ff) : ff;
|
|
2574
3111
|
const set = this.set;
|
|
2575
|
-
this.debug(this.pattern, "set", set);
|
|
2576
3112
|
let filename = ff[ff.length - 1];
|
|
2577
3113
|
if (!filename) for (let i = ff.length - 2; !filename && i >= 0; i--) filename = ff[i];
|
|
2578
|
-
for (
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
if (this.
|
|
3114
|
+
for (let r = 0; r < set.length; r++) {
|
|
3115
|
+
const pattern = set[r];
|
|
3116
|
+
const shape = partial ? void 0 : this.#shapes[r];
|
|
3117
|
+
if (shape === "base" ? portionMatch(pattern[0], filename) : shape ? this.#matchShape(resolved, pattern, shape) : options.matchBase && pattern.length === 1 ? this.#matchRow([filename], [filename], pattern, partial) : this.#matchRow(ff, resolved, pattern, partial)) {
|
|
2582
3118
|
if (options.flipNegate) return true;
|
|
2583
3119
|
return !this.negate;
|
|
2584
3120
|
}
|
|
@@ -2591,12 +3127,10 @@ var Minimatch = class {
|
|
|
2591
3127
|
}
|
|
2592
3128
|
};
|
|
2593
3129
|
/* c8 ignore stop */
|
|
2594
|
-
minimatch.AST = AST;
|
|
2595
3130
|
minimatch.Minimatch = Minimatch;
|
|
2596
3131
|
minimatch.escape = escape;
|
|
2597
3132
|
minimatch.unescape = unescape;
|
|
2598
|
-
|
|
2599
|
-
//#region ../internal/src/build/runtime-package-files.ts
|
|
3133
|
+
// ../internal/src/build/runtime-package-files.ts
|
|
2600
3134
|
const alwaysPublishedFile = /^(?:package\.json|(?:readme|copying|licen[cs]e)(?:\..*[^~$])?)$/i;
|
|
2601
3135
|
const rootExcluded = /* @__PURE__ */ new Set([
|
|
2602
3136
|
"package-lock.json",
|
|
@@ -2754,8 +3288,7 @@ async function copyRuntimePackageFiles(packageDir, targetDir) {
|
|
|
2754
3288
|
await unlessGone(() => copyFile(join(packageDir, path), target));
|
|
2755
3289
|
}
|
|
2756
3290
|
}
|
|
2757
|
-
|
|
2758
|
-
//#region ../internal/src/build/provider-output-sources.ts
|
|
3291
|
+
// ../internal/src/build/provider-output-sources.ts
|
|
2759
3292
|
/** Removes retained provider output after readers release it, tolerating transient filesystem contention. */
|
|
2760
3293
|
async function removeProviderOutputArtifactDir(path) {
|
|
2761
3294
|
await rm(path, {
|
|
@@ -2765,8 +3298,7 @@ async function removeProviderOutputArtifactDir(path) {
|
|
|
2765
3298
|
retryDelay: 50
|
|
2766
3299
|
});
|
|
2767
3300
|
}
|
|
2768
|
-
|
|
2769
|
-
//#region ../internal/src/build/vercel-config.ts
|
|
3301
|
+
// ../internal/src/build/vercel-config.ts
|
|
2770
3302
|
function createDefaultVercelOutputRoot(rootDir) {
|
|
2771
3303
|
return resolve(rootDir, ".vercel", "output");
|
|
2772
3304
|
}
|
|
@@ -2789,8 +3321,7 @@ function createNodeFunctionConfig(extra = {}) {
|
|
|
2789
3321
|
...extra
|
|
2790
3322
|
};
|
|
2791
3323
|
}
|
|
2792
|
-
|
|
2793
|
-
//#region ../internal/src/build/runtime-package-resolution.ts
|
|
3324
|
+
// ../internal/src/build/runtime-package-resolution.ts
|
|
2794
3325
|
/** Locates package metadata through exports, an entry's ancestors, or the project's dependency roots. */
|
|
2795
3326
|
function createRuntimePackageResolver(readPackageName) {
|
|
2796
3327
|
return async (name, resolver, fromDir) => {
|
|
@@ -2831,8 +3362,7 @@ function isPackageResolutionMiss(error) {
|
|
|
2831
3362
|
const code = error?.code;
|
|
2832
3363
|
return code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
|
|
2833
3364
|
}
|
|
2834
|
-
|
|
2835
|
-
//#region ../internal/src/build/runtime-package-directory.ts
|
|
3365
|
+
// ../internal/src/build/runtime-package-directory.ts
|
|
2836
3366
|
/** Update a staged copy, then publish it with rollback on failure or cancellation. */
|
|
2837
3367
|
async function updateRuntimePackageDirectory(options) {
|
|
2838
3368
|
const stagingRoot = await mkdtemp(join(dirname(options.directory), ".vitehub-runtime-packages-"));
|
|
@@ -2879,8 +3409,7 @@ async function updateRuntimePackageDirectory(options) {
|
|
|
2879
3409
|
});
|
|
2880
3410
|
}
|
|
2881
3411
|
}
|
|
2882
|
-
|
|
2883
|
-
//#region ../internal/src/build/vercel-runtime-packages.ts
|
|
3412
|
+
// ../internal/src/build/vercel-runtime-packages.ts
|
|
2884
3413
|
const runtimeExportConditions = /* @__PURE__ */ new Set([
|
|
2885
3414
|
"default",
|
|
2886
3415
|
"import",
|
|
@@ -3028,7 +3557,7 @@ async function copyTracedPackageFiles(name, resolver, packageDir, packageJsonPat
|
|
|
3028
3557
|
return true;
|
|
3029
3558
|
}
|
|
3030
3559
|
async function loadNodeFileTrace() {
|
|
3031
|
-
nodeFileTracePromise ??= import("./out-
|
|
3560
|
+
nodeFileTracePromise ??= import("./out-By90R-Bo.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then(({ nodeFileTrace }) => nodeFileTrace);
|
|
3032
3561
|
return nodeFileTracePromise;
|
|
3033
3562
|
}
|
|
3034
3563
|
async function resolvePackageTraceEntries(name, resolver, packageDir, packageJson) {
|
|
@@ -3094,8 +3623,7 @@ function parsePackageJson(value, path) {
|
|
|
3094
3623
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw internalErrorDiagnostics.INTERNAL_B0047({ message: `Expected ${path} to contain a JSON object.` });
|
|
3095
3624
|
return value;
|
|
3096
3625
|
}
|
|
3097
|
-
|
|
3098
|
-
//#region ../internal/src/build/provider-output-catalog.ts
|
|
3626
|
+
// ../internal/src/build/provider-output-catalog.ts
|
|
3099
3627
|
var ProviderOutputCatalog = class {
|
|
3100
3628
|
bundleDefines = {};
|
|
3101
3629
|
#appliedCloudflareContributions = /* @__PURE__ */ new Map();
|
|
@@ -3323,8 +3851,7 @@ function useProviderOutputCatalog(config) {
|
|
|
3323
3851
|
providerOutputCatalogs.set(config, catalog);
|
|
3324
3852
|
return catalog;
|
|
3325
3853
|
}
|
|
3326
|
-
|
|
3327
|
-
//#region ../internal/src/build/deployment-output.ts
|
|
3854
|
+
// ../internal/src/build/deployment-output.ts
|
|
3328
3855
|
const providerDeploymentOutputRegistry = globalThis;
|
|
3329
3856
|
const providerDeploymentOutputWrites = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputWrites ??= /* @__PURE__ */ new Map();
|
|
3330
3857
|
const providerDeploymentOutputFinalizations = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputFinalizations ??= /* @__PURE__ */ new WeakMap();
|
|
@@ -4336,8 +4863,7 @@ async function finalizeProviderDeploymentOutputs(catalog, options = {}) {
|
|
|
4336
4863
|
if (providerDeploymentOutputFinalizations.get(catalog) === active) providerDeploymentOutputFinalizations.delete(catalog);
|
|
4337
4864
|
}
|
|
4338
4865
|
}
|
|
4339
|
-
|
|
4340
|
-
//#region ../internal/src/hints.ts
|
|
4866
|
+
// ../internal/src/hints.ts
|
|
4341
4867
|
/**
|
|
4342
4868
|
* The file that lists the hints of the last build or dev server, relative to the project root. A hint is a warning
|
|
4343
4869
|
* about something that works now and fails later, such as counts that stay in one server's memory. Agents and CI read
|
|
@@ -4415,8 +4941,7 @@ function startViteHubHints(config, owner = config) {
|
|
|
4415
4941
|
started.add(owner);
|
|
4416
4942
|
write(startRun(config));
|
|
4417
4943
|
}
|
|
4418
|
-
|
|
4419
|
-
//#region ../internal/src/provision-state.ts
|
|
4944
|
+
// ../internal/src/provision-state.ts
|
|
4420
4945
|
const PROVISION_STATE_FILE = ".vitehub/provision.json";
|
|
4421
4946
|
function getProvisionStatePath(rootDir) {
|
|
4422
4947
|
return resolve$1(rootDir, PROVISION_STATE_FILE);
|
|
@@ -4467,8 +4992,7 @@ function setOwn(target, key, value) {
|
|
|
4467
4992
|
writable: true
|
|
4468
4993
|
});
|
|
4469
4994
|
}
|
|
4470
|
-
|
|
4471
|
-
//#region ../internal/src/vite-stage.ts
|
|
4995
|
+
// ../internal/src/vite-stage.ts
|
|
4472
4996
|
/**
|
|
4473
4997
|
* Vite's `loadEnv(mode, envDir, "")`: every `.env` value of the mode and the whole shell. With `DEBUG=vite:env`, Vite
|
|
4474
4998
|
* logs that result to stderr, secrets included. loadEnv is synchronous, so this drops only the writes of this call.
|
|
@@ -4505,8 +5029,7 @@ function configureCloudflareKV(target, config, provisionState = {}) {
|
|
|
4505
5029
|
});
|
|
4506
5030
|
}
|
|
4507
5031
|
}
|
|
4508
|
-
|
|
4509
|
-
//#region src/inspect.ts
|
|
5032
|
+
// src/inspect.ts
|
|
4510
5033
|
function describeDevelopment(store) {
|
|
4511
5034
|
switch (store.driver) {
|
|
4512
5035
|
case "upstash": return "Remote. `vite dev` uses the real Upstash database, so writes change real data.";
|
|
@@ -4574,8 +5097,7 @@ function inspectKVResources(options, provisionRoot, env = process.env, hosting)
|
|
|
4574
5097
|
};
|
|
4575
5098
|
});
|
|
4576
5099
|
}
|
|
4577
|
-
|
|
4578
|
-
//#region ../internal/src/host-credentials.ts
|
|
5100
|
+
// ../internal/src/host-credentials.ts
|
|
4579
5101
|
/** Reads host credentials from environment variables only. Returns undefined when the token is not set. */
|
|
4580
5102
|
function readHostCredentialsFromEnv(host, env) {
|
|
4581
5103
|
switch (host) {
|
|
@@ -4609,8 +5131,7 @@ function trimmed(value) {
|
|
|
4609
5131
|
const result = value?.trim();
|
|
4610
5132
|
return result ? result : void 0;
|
|
4611
5133
|
}
|
|
4612
|
-
|
|
4613
|
-
//#region ../internal/src/provider-failure.ts
|
|
5134
|
+
// ../internal/src/provider-failure.ts
|
|
4614
5135
|
const cloudflareCodes = {
|
|
4615
5136
|
d1: {},
|
|
4616
5137
|
kv: { 10014: "conflict" },
|
|
@@ -4712,8 +5233,7 @@ function readProviderErrorCodes(body) {
|
|
|
4712
5233
|
const errors = Reflect.get(body, "errors");
|
|
4713
5234
|
return [error && typeof error === "object" ? Reflect.get(error, "code") : void 0, ...Array.isArray(errors) ? errors.map((entry) => entry && typeof entry === "object" ? Reflect.get(entry, "code") : void 0) : []].filter((code) => typeof code === "number" && Number.isFinite(code) || typeof code === "string" && /^[\w.-]{1,128}$/.test(code));
|
|
4714
5235
|
}
|
|
4715
|
-
|
|
4716
|
-
//#region ../internal/src/provision.ts
|
|
5236
|
+
// ../internal/src/provision.ts
|
|
4717
5237
|
/**
|
|
4718
5238
|
* Whether a value from Provision State can appear in a copyable shell command as is.
|
|
4719
5239
|
* The file is editable, so a hint shows a command only for plain names and ids.
|
|
@@ -4835,8 +5355,7 @@ async function listCloudflarePages(request, path, options) {
|
|
|
4835
5355
|
} else if (options.perPage === void 0 || pageItems.length < options.perPage) return items;
|
|
4836
5356
|
}
|
|
4837
5357
|
}
|
|
4838
|
-
|
|
4839
|
-
//#region src/provision.ts
|
|
5358
|
+
// src/provision.ts
|
|
4840
5359
|
const CLOUDFLARE_KV_NAMESPACE_LIST_PER_PAGE = 100;
|
|
4841
5360
|
function parseNamespaces(value) {
|
|
4842
5361
|
if (!Array.isArray(value)) throw kvErrorDiagnostics.KV_PROVISION_FAILED({ problem: "Cloudflare returned an invalid KV namespace list." });
|
|
@@ -4935,8 +5454,7 @@ function createKVCloudflareProvisionStep(resolveOptions) {
|
|
|
4935
5454
|
}
|
|
4936
5455
|
};
|
|
4937
5456
|
}
|
|
4938
|
-
|
|
4939
|
-
//#region src/deployment-env.ts
|
|
5457
|
+
// src/deployment-env.ts
|
|
4940
5458
|
const owners = ["kv"];
|
|
4941
5459
|
const maskedRuntimeValue = "********";
|
|
4942
5460
|
function entry(names) {
|
|
@@ -4961,8 +5479,7 @@ function kvDeploymentEnv(config) {
|
|
|
4961
5479
|
if (!config) return [];
|
|
4962
5480
|
return Object.values(config.stores ?? { default: config.store }).flatMap(storeEntries);
|
|
4963
5481
|
}
|
|
4964
|
-
|
|
4965
|
-
//#region src/vite.ts
|
|
5482
|
+
// src/vite.ts
|
|
4966
5483
|
const operationsModule = ownModule(import.meta.url, "operations");
|
|
4967
5484
|
const RESOLVED_KV_VIRTUAL_CONFIG_ID = `\0${KV_VIRTUAL_CONFIG_ID}`;
|
|
4968
5485
|
const RESOLVED_KV_RUNTIME_ID = `\0#vitehub/kv/runtime`;
|
|
@@ -5478,5 +5995,4 @@ function hubKV(options, input = {}) {
|
|
|
5478
5995
|
}
|
|
5479
5996
|
};
|
|
5480
5997
|
}
|
|
5481
|
-
//#endregion
|
|
5482
5998
|
export { KV_VIRTUAL_CONFIG_ID, KV_VITE_PLUGIN_NAME, hubKV, hubKVOptionalPeerResolver, kvStorageDriver, resolveKVViteConfig };
|