@vite-hub/workflow 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-2Y7sBAG6.js → app-DXUHElAz.js} +2 -3
- package/dist/{app-BojnC_yf.d.ts → app-wkVFd7m-.d.ts} +0 -2
- package/dist/{client-CgBcDlGn.js → client-CbBg4HlH.js} +17 -22
- package/dist/{cloudflare-Datj_znU.js → cloudflare-Sgywkm1N.js} +3 -5
- package/dist/{cloudflare-env-CGLx7lUd.js → cloudflare-env-DHhzRZOs.js} +2 -4
- package/dist/cloudflare-env-lookup-BqomAHN5.d.ts +2 -0
- package/dist/{cloudflare-shared-CTqh_a2s.d.ts → cloudflare-shared-B9cY3-jD.d.ts} +1 -3
- package/dist/{config-z1651xc2.js → config-CizNRTMi.js} +4 -7
- package/dist/definition.d.ts +2 -4
- package/dist/definition.js +3 -4
- package/dist/{delay-CHN4tv3i.js → delay-CtT3442d.js} +2 -3
- package/dist/{dev-recorder-CTN5Fkao.js → dev-recorder-Dltdmlkv.js} +1 -2
- package/dist/durability.d.ts +2 -4
- package/dist/durability.js +2 -3
- package/dist/{error-diagnostics-DMeaFmQD.js → error-diagnostics--2cV_ER1.js} +1 -2
- package/dist/{error-diagnostics-C0KyI408.js → error-diagnostics-kKXseq8d.js} +5 -2
- package/dist/{errors-D-fNDVg0.d.ts → errors-CJZuvOcx.d.ts} +0 -2
- package/dist/{errors-BNxEeeCO.js → errors-CZf7oz4k.js} +1 -2
- package/dist/index.d.ts +2 -8
- package/dist/index.js +5 -6
- package/dist/{inspect-B72iFyj-.js → inspect-NBCAwsxi.js} +1 -2
- package/dist/{object-Da1zyPCR.js → object-CAK6UYR5.js} +1 -2
- package/dist/{openworkflow-BoaENgh9.d.ts → openworkflow-CdKbUGGa.d.ts} +1 -3
- package/dist/{openworkflow-defaults-DDig2M4s.js → openworkflow-defaults-DfQWtSRU.js} +2 -4
- package/dist/{openworkflow-storage-Dj9zUAsk.js → openworkflow-storage-Dde_f0es.js} +1 -2
- package/dist/openworkflow.js +1 -2
- package/dist/{operation-definition-CI2PJGqu.d.ts → operation-definition-CqZkx1Rm.d.ts} +0 -4
- package/dist/{operations-CYntpf-T.js → operations-BBTmDm2H.js} +8 -10
- package/dist/operations.d.ts +2 -6
- package/dist/operations.js +8 -13
- package/dist/{out-DxLKolA0.js → out-r9T3bhTE.js} +2933 -2301
- package/dist/{rolldown-runtime-B4iAMlE-.js → rolldown-runtime-DYf_mQCB.js} +2 -3
- package/dist/{run-error-Ctn50EYz.js → run-error-8p4BtTMv.js} +5 -7
- package/dist/{run-failed-gVGo1BaF.js → run-failed-BcSjSU2t.js} +1 -2
- package/dist/runtime/cloudflare-runner.d.ts +3 -5
- package/dist/runtime/cloudflare-runner.js +6 -7
- package/dist/runtime/cloudflare-shared.d.ts +2 -2
- package/dist/runtime/cloudflare-shared.js +1 -2
- package/dist/runtime/cloudflare-vite.d.ts +5 -7
- package/dist/runtime/cloudflare-vite.js +5 -7
- package/dist/runtime/dev-runs.d.ts +1 -3
- package/dist/runtime/dev-runs.js +2 -3
- package/dist/runtime/execute.d.ts +3 -5
- package/dist/runtime/execute.js +5 -6
- package/dist/runtime/openworkflow-worker.d.ts +3 -4
- package/dist/runtime/openworkflow-worker.js +5 -6
- package/dist/runtime/openworkflow.d.ts +1 -1
- package/dist/runtime/openworkflow.js +8 -9
- package/dist/runtime/state.d.ts +2 -4
- package/dist/runtime/state.js +4 -5
- package/dist/runtime/vercel-vite.d.ts +3 -6
- package/dist/runtime/vercel-vite.js +4 -6
- package/dist/{signals-C1iolifd.js → signals-BHQdxoJo.js} +2 -3
- package/dist/{types-BWPHeugk.d.ts → types-DvYcvbPG.d.ts} +0 -2
- package/dist/{vercel-BIkBFrQQ.js → vercel-Cw_Z9-j4.js} +5 -6
- package/dist/vite.d.ts +3 -25
- package/dist/vite.js +1448 -933
- package/package.json +13 -13
- package/dist/cloudflare-env-lookup-CfX6wZKb.d.ts +0 -4
package/dist/vite.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { i as __toESM, n as __exportAll } from "./rolldown-runtime-
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as workflowErrorDiagnostics } from "./error-diagnostics-DMeaFmQD.js";
|
|
1
|
+
import { i as __toESM, n as __exportAll } from "./rolldown-runtime-DYf_mQCB.js";
|
|
2
|
+
import { n as invariant, r as invariantError, t as defaultOpenWorkflowSqlitePath } from "./openworkflow-defaults-DfQWtSRU.js";
|
|
4
3
|
import { workflowDurabilityUrl } from "./durability.js";
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import { n as getHostingProvider, r as normalizeHosting, t as normalizeWorkflowOptions } from "./config-
|
|
8
|
-
import {
|
|
4
|
+
import { t as internalErrorDiagnostics } from "./error-diagnostics-kKXseq8d.js";
|
|
5
|
+
import { n as isRecordOrFunction, t as isRecord } from "./object-CAK6UYR5.js";
|
|
6
|
+
import { n as getHostingProvider, r as normalizeHosting, t as normalizeWorkflowOptions } from "./config-CizNRTMi.js";
|
|
7
|
+
import { r as relativeDefinitionFile } from "./inspect-NBCAwsxi.js";
|
|
8
|
+
import { i as getLegacyCloudflareWorkflowClassName, r as getCloudflareWorkflowClassName, t as createCloudflareWorkflowBindings } from "./cloudflare-Sgywkm1N.js";
|
|
9
|
+
import { t as workflowErrorDiagnostics } from "./error-diagnostics--2cV_ER1.js";
|
|
9
10
|
import { resolveWorkflowStepOptions, toStepPropertyName } from "./runtime/execute.js";
|
|
10
|
-
import {
|
|
11
|
-
import { r as relativeDefinitionFile } from "./inspect-B72iFyj-.js";
|
|
11
|
+
import { a as workflowStartAtKey, n as generatedNativeEntryKey } from "./delay-CtT3442d.js";
|
|
12
12
|
import { builtinModules, createRequire, isBuiltin } from "node:module";
|
|
13
13
|
import { dirname, normalize, relative, resolve } from "pathe";
|
|
14
14
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -19,13 +19,12 @@ import { access, chmod, copyFile, cp, lstat, mkdir, mkdtemp, readFile, readdir,
|
|
|
19
19
|
import { tmpdir } from "node:os";
|
|
20
20
|
import { parseSync } from "vite";
|
|
21
21
|
import { build, buildSync, transform } from "esbuild";
|
|
22
|
-
|
|
22
|
+
// ../internal/src/durability.ts
|
|
23
23
|
/** The `durability` module next to the Vite plugin module at `importMetaUrl`, in source and in `dist`. */
|
|
24
24
|
function durabilityModuleFile(importMetaUrl) {
|
|
25
25
|
return fileURLToPath(new URL(importMetaUrl.endsWith(".ts") ? "./durability.ts" : "./durability.js", importMetaUrl));
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
//#region ../internal/src/build/paths.ts
|
|
27
|
+
// ../internal/src/build/paths.ts
|
|
29
28
|
function generatedDirSegments(productName) {
|
|
30
29
|
return [".vitehub", productName];
|
|
31
30
|
}
|
|
@@ -71,8 +70,7 @@ function realpathIfExists(path) {
|
|
|
71
70
|
return resolve(path);
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
//#region src/internal/runtime-modules.ts
|
|
73
|
+
// src/internal/runtime-modules.ts
|
|
76
74
|
/**
|
|
77
75
|
* The file path of a Workflow runtime module. Generated code imports it by path, so it needs no package export.
|
|
78
76
|
* Schedule and Agent output receive these paths from the Workflow plugin.
|
|
@@ -80,8 +78,7 @@ function realpathIfExists(path) {
|
|
|
80
78
|
function workflowRuntimeModule(name) {
|
|
81
79
|
return ownModule(import.meta.url, `runtime/${name}`);
|
|
82
80
|
}
|
|
83
|
-
|
|
84
|
-
//#region ../internal/src/build/bundle-options.ts
|
|
81
|
+
// ../internal/src/build/bundle-options.ts
|
|
85
82
|
const encodedAliasPrefixMarker = "\0vitehub-prefix:";
|
|
86
83
|
const encodedAliasExactMarker = "\0vitehub-exact:";
|
|
87
84
|
function encodeProviderOutputAliases(configAliases) {
|
|
@@ -100,14 +97,17 @@ function encodeProviderOutputAliases(configAliases) {
|
|
|
100
97
|
/** Select the runtime constants from one resolved Vite configuration. */
|
|
101
98
|
function resolveViteHubBundleDefines(config) {
|
|
102
99
|
const defines = {};
|
|
103
|
-
for (const name of [
|
|
100
|
+
for (const name of [
|
|
101
|
+
"__VITEHUB_PUBLIC_URL__",
|
|
102
|
+
"__VITEHUB_APP_BASE_URL__",
|
|
103
|
+
"__VITEHUB_CONSOLE_URL__"
|
|
104
|
+
]) {
|
|
104
105
|
const value = config.define?.[name];
|
|
105
106
|
if (typeof value === "string") defines[name] = value;
|
|
106
107
|
}
|
|
107
108
|
return defines;
|
|
108
109
|
}
|
|
109
|
-
|
|
110
|
-
//#region ../internal/src/build/client-output.ts
|
|
110
|
+
// ../internal/src/build/client-output.ts
|
|
111
111
|
function hasStaticIndex(clientDir) {
|
|
112
112
|
return existsSync(resolve(clientDir, "index.html"));
|
|
113
113
|
}
|
|
@@ -144,8 +144,7 @@ async function copyClientOutput(clientDir, targetDir, excludedDirs = []) {
|
|
|
144
144
|
filter
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
//#region ../internal/src/build/provider-output-config.ts
|
|
147
|
+
// ../internal/src/build/provider-output-config.ts
|
|
149
148
|
function isProviderJsonArray(value, ancestors) {
|
|
150
149
|
if (Object.getPrototypeOf(value) !== Array.prototype || ancestors.has(value)) return false;
|
|
151
150
|
if (Reflect.ownKeys(value).length !== value.length + 1) return false;
|
|
@@ -283,8 +282,7 @@ async function cleanProviderOutputConfig(file, ownership) {
|
|
|
283
282
|
if (!changed) return;
|
|
284
283
|
await persistProviderJsonRecord(file, next, true);
|
|
285
284
|
}
|
|
286
|
-
|
|
287
|
-
//#region ../internal/src/build/user-entry.ts
|
|
285
|
+
// ../internal/src/build/user-entry.ts
|
|
288
286
|
function toSafeAppName(rootDir) {
|
|
289
287
|
return basename(rootDir).replace(/[^a-z0-9-]+/gi, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").toLowerCase();
|
|
290
288
|
}
|
|
@@ -303,8 +301,7 @@ function resolveUserAppEntry(rootDir, options = {}) {
|
|
|
303
301
|
const srcSubdir = options.srcSubdir ?? "src";
|
|
304
302
|
return names.map((name) => resolve$1(rootDir, srcSubdir, name)).find(existsSync);
|
|
305
303
|
}
|
|
306
|
-
|
|
307
|
-
//#region ../internal/src/build/cloudflare.ts
|
|
304
|
+
// ../internal/src/build/cloudflare.ts
|
|
308
305
|
const defaultCloudflareCompatibilityDate = "2026-04-20";
|
|
309
306
|
const cloudflareRuntimeExternal = "cloudflare:*";
|
|
310
307
|
function createDefaultCloudflareOutputRoot(rootDir) {
|
|
@@ -323,8 +320,7 @@ async function writeCloudflareWranglerConfig(options) {
|
|
|
323
320
|
removeIfEmpty: true
|
|
324
321
|
});
|
|
325
322
|
}
|
|
326
|
-
|
|
327
|
-
//#region ../internal/src/build/ast-walk.ts
|
|
323
|
+
// ../internal/src/build/ast-walk.ts
|
|
328
324
|
/** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
|
|
329
325
|
function moduleLanguage(file) {
|
|
330
326
|
if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
|
|
@@ -347,8 +343,7 @@ function walk(node, visit, parent) {
|
|
|
347
343
|
} else if (isNode(child)) walk(child, visit, node);
|
|
348
344
|
}
|
|
349
345
|
}
|
|
350
|
-
|
|
351
|
-
//#region ../internal/src/build/rolldown.ts
|
|
346
|
+
// ../internal/src/build/rolldown.ts
|
|
352
347
|
const viteRawPrefix = "\0vitehub-vite-raw:";
|
|
353
348
|
const markdownTemplatePrefix = "\0vitehub-markdown-template:";
|
|
354
349
|
const markdownTemplateFileSuffix$1 = ".template.md";
|
|
@@ -714,20 +709,20 @@ function createFileUrlPlugin$1() {
|
|
|
714
709
|
}
|
|
715
710
|
};
|
|
716
711
|
}
|
|
717
|
-
/**
|
|
718
|
-
* Copies a `.wasm?module` import next to the bundle and keeps it as a relative `.wasm` import. Wrangler and Nitro load
|
|
719
|
-
* such an import as a compiled WebAssembly module, which Workers need because they can't compile WebAssembly bytes.
|
|
720
|
-
* Node.js compiles WebAssembly bytes, so there the import becomes the bytes of the file.
|
|
721
|
-
*/
|
|
722
712
|
function createWasmModulePlugin(outdir, workingDir, copy) {
|
|
723
713
|
return {
|
|
724
714
|
name: "vitehub-wasm-module",
|
|
725
715
|
async resolveId(source, importer, extra) {
|
|
726
|
-
|
|
727
|
-
|
|
716
|
+
const explicitModule = source.endsWith(".wasm?module");
|
|
717
|
+
if (!explicitModule && (!copy || !source.endsWith(".wasm") || extra.custom?.[skipMarkdownTemplateResolve$1])) return;
|
|
718
|
+
const path = explicitModule ? source.slice(0, -7) : source;
|
|
719
|
+
const resolved = await this.resolve(path, importerFor(importer, workingDir), {
|
|
728
720
|
custom: extra.custom,
|
|
729
|
-
|
|
721
|
+
isEntry: extra.isEntry,
|
|
722
|
+
kind: extra.kind,
|
|
723
|
+
skipSelf: true
|
|
730
724
|
});
|
|
725
|
+
if (!explicitModule && (!isFileResolution(resolved) || !resolved.id.endsWith(".wasm"))) return resolved ?? void 0;
|
|
731
726
|
if (!isFileResolution(resolved)) this.error(`[vitehub] Could not resolve ${JSON.stringify(source)}.`);
|
|
732
727
|
if (!copy) return resolved.id;
|
|
733
728
|
const bytes = await readFile(resolved.id);
|
|
@@ -945,8 +940,7 @@ async function bundleEsmEntry(entryFile, outfile, options = {}) {
|
|
|
945
940
|
await writeFile(outfile, chunk.code, { signal: options.signal });
|
|
946
941
|
options.signal?.throwIfAborted();
|
|
947
942
|
}
|
|
948
|
-
|
|
949
|
-
//#region ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
|
|
943
|
+
// ../../node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
|
|
950
944
|
const balanced = (a, b, str) => {
|
|
951
945
|
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
952
946
|
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
@@ -993,8 +987,7 @@ const range = (a, b, str) => {
|
|
|
993
987
|
}
|
|
994
988
|
return result;
|
|
995
989
|
};
|
|
996
|
-
|
|
997
|
-
//#region ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
|
|
990
|
+
// ../../node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
|
|
998
991
|
const escSlash = "\0SLASH" + Math.random() + "\0";
|
|
999
992
|
const escOpen = "\0OPEN" + Math.random() + "\0";
|
|
1000
993
|
const escClose = "\0CLOSE" + Math.random() + "\0";
|
|
@@ -1194,39 +1187,94 @@ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
|
|
|
1194
1187
|
}
|
|
1195
1188
|
return acc;
|
|
1196
1189
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1190
|
+
// ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/numeric-range.js
|
|
1191
|
+
const digit = (a, b) => a === b ? {
|
|
1192
|
+
t: "lit",
|
|
1193
|
+
ch: String(a)
|
|
1194
|
+
} : {
|
|
1195
|
+
t: "class",
|
|
1196
|
+
re: new RegExp(`^[${a}-${b}]$`)
|
|
1197
|
+
};
|
|
1198
|
+
const prefix = (d, alts) => alts.map((s) => [digit(d, d), ...s]);
|
|
1199
|
+
const fixed = (a, b) => {
|
|
1200
|
+
if (!a) return [[]];
|
|
1201
|
+
let lo = +a[0];
|
|
1202
|
+
let hi = +b[0];
|
|
1203
|
+
const ra = a.slice(1);
|
|
1204
|
+
const rb = b.slice(1);
|
|
1205
|
+
if (lo === hi) return prefix(lo, fixed(ra, rb));
|
|
1206
|
+
const zeros = "0".repeat(ra.length);
|
|
1207
|
+
const nines = "9".repeat(ra.length);
|
|
1208
|
+
const out = [];
|
|
1209
|
+
if (ra !== zeros) out.push(...prefix(lo++, fixed(ra, nines)));
|
|
1210
|
+
const last = rb === nines ? [] : prefix(hi--, fixed(zeros, rb));
|
|
1211
|
+
if (lo <= hi) out.push([digit(lo, hi), ...Array.from(ra, () => digit(0, 9))]);
|
|
1212
|
+
out.push(...last);
|
|
1213
|
+
return out;
|
|
1203
1214
|
};
|
|
1204
|
-
|
|
1205
|
-
|
|
1215
|
+
const nonneg = (a, b, width) => {
|
|
1216
|
+
if (width) return fixed(String(a).padStart(width, "0"), String(b).padStart(width, "0"));
|
|
1217
|
+
const out = [];
|
|
1218
|
+
for (let len = String(a).length; len <= String(b).length; len++) {
|
|
1219
|
+
const lo = Math.max(a, len === 1 ? 0 : 10 ** (len - 1));
|
|
1220
|
+
const hi = Math.min(b, 10 ** len - 1);
|
|
1221
|
+
out.push(...fixed(String(lo), String(hi)));
|
|
1222
|
+
}
|
|
1223
|
+
return out;
|
|
1224
|
+
};
|
|
1225
|
+
/**
|
|
1226
|
+
* The strings that the bash brace expansion `{lo..hi}` makes, as
|
|
1227
|
+
* the alternatives of an `@(...)` extglob. Each one is a sequence of
|
|
1228
|
+
* digits and digit classes, so there are only a few of them, even for
|
|
1229
|
+
* a large range.
|
|
1230
|
+
*
|
|
1231
|
+
* If either end has a leading zero, such as `{01..10}`, each number
|
|
1232
|
+
* has leading zeros to make it as long as the longer end, counting a
|
|
1233
|
+
* `-` sign. So `{-05..3}` makes `-05` to `-01`, then `000` to `003`.
|
|
1234
|
+
*
|
|
1235
|
+
* Returns undefined if either end is not a safe integer.
|
|
1236
|
+
*/
|
|
1237
|
+
const numericRange = (loStr, hiStr) => {
|
|
1238
|
+
let lo = Number(loStr);
|
|
1239
|
+
let hi = Number(hiStr);
|
|
1240
|
+
if (!Number.isSafeInteger(lo) || !Number.isSafeInteger(hi)) return;
|
|
1241
|
+
if (lo > hi) [lo, hi] = [hi, lo];
|
|
1242
|
+
const width = /^-?0\d/.test(loStr) || /^-?0\d/.test(hiStr) ? Math.max(loStr.length, hiStr.length) : 0;
|
|
1243
|
+
const out = [];
|
|
1244
|
+
if (lo < 0) {
|
|
1245
|
+
const neg = nonneg(Math.max(-hi, 1), -lo, width && width - 1);
|
|
1246
|
+
out.push(...neg.map((s) => [{
|
|
1247
|
+
t: "lit",
|
|
1248
|
+
ch: "-"
|
|
1249
|
+
}, ...s]));
|
|
1250
|
+
}
|
|
1251
|
+
if (hi >= 0) out.push(...nonneg(Math.max(lo, 0), hi, width));
|
|
1252
|
+
return out;
|
|
1253
|
+
};
|
|
1254
|
+
// ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/parse-class.js
|
|
1206
1255
|
const posixClasses = {
|
|
1207
|
-
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"
|
|
1208
|
-
"[:alpha:]": ["\\p{L}\\p{Nl}"
|
|
1209
|
-
"[:ascii:]": ["\\x00-\\x7f"
|
|
1210
|
-
"[:blank:]": ["\\p{Zs}\\t"
|
|
1211
|
-
"[:cntrl:]": ["\\p{Cc}"
|
|
1212
|
-
"[:digit:]": ["\\p{Nd}"
|
|
1213
|
-
"[:graph:]": [
|
|
1214
|
-
|
|
1215
|
-
true,
|
|
1216
|
-
true
|
|
1217
|
-
],
|
|
1218
|
-
"[:lower:]": ["\\p{Ll}", true],
|
|
1256
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}"],
|
|
1257
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}"],
|
|
1258
|
+
"[:ascii:]": ["\\x00-\\x7f"],
|
|
1259
|
+
"[:blank:]": ["\\p{Zs}\\t"],
|
|
1260
|
+
"[:cntrl:]": ["\\p{Cc}"],
|
|
1261
|
+
"[:digit:]": ["\\p{Nd}"],
|
|
1262
|
+
"[:graph:]": ["\\p{Z}\\p{C}", true],
|
|
1263
|
+
"[:lower:]": ["\\p{Ll}"],
|
|
1219
1264
|
"[:print:]": ["\\p{C}", true],
|
|
1220
|
-
"[:punct:]": ["\\p{P}"
|
|
1221
|
-
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"
|
|
1222
|
-
"[:upper:]": ["\\p{Lu}"
|
|
1223
|
-
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"
|
|
1224
|
-
"[:xdigit:]": ["A-Fa-f0-9"
|
|
1265
|
+
"[:punct:]": ["\\p{P}\\p{S}"],
|
|
1266
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f"],
|
|
1267
|
+
"[:upper:]": ["\\p{Lu}"],
|
|
1268
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}"],
|
|
1269
|
+
"[:xdigit:]": ["A-Fa-f0-9"]
|
|
1225
1270
|
};
|
|
1226
1271
|
const braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
|
|
1227
|
-
const
|
|
1228
|
-
const
|
|
1229
|
-
const
|
|
1272
|
+
const noMatch = /$./;
|
|
1273
|
+
const parseClass = (glob, position, nocase = false, form) => {
|
|
1274
|
+
const norm = (c) => {
|
|
1275
|
+
const n = form ? c.normalize(form) : c;
|
|
1276
|
+
return [...n].length === 1 ? n : c;
|
|
1277
|
+
};
|
|
1230
1278
|
const pos = position;
|
|
1231
1279
|
/* c8 ignore start */
|
|
1232
1280
|
if (glob.charAt(pos) !== "[") throw new Error("not in a brace expression");
|
|
@@ -1235,13 +1283,12 @@ const parseClass = (glob, position) => {
|
|
|
1235
1283
|
const negs = [];
|
|
1236
1284
|
let i = pos + 1;
|
|
1237
1285
|
let sawStart = false;
|
|
1238
|
-
let uflag = false;
|
|
1239
1286
|
let escaping = false;
|
|
1240
1287
|
let negate = false;
|
|
1241
1288
|
let endPos = pos;
|
|
1242
1289
|
let rangeStart = "";
|
|
1243
1290
|
WHILE: while (i < glob.length) {
|
|
1244
|
-
const c = glob.
|
|
1291
|
+
const c = String.fromCodePoint(glob.codePointAt(i));
|
|
1245
1292
|
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
1246
1293
|
negate = true;
|
|
1247
1294
|
i++;
|
|
@@ -1260,607 +1307,659 @@ const parseClass = (glob, position) => {
|
|
|
1260
1307
|
}
|
|
1261
1308
|
}
|
|
1262
1309
|
if (c === "[" && !escaping) {
|
|
1263
|
-
for (const [cls, [unip,
|
|
1264
|
-
if (rangeStart) return [
|
|
1265
|
-
"$.",
|
|
1266
|
-
false,
|
|
1267
|
-
glob.length - pos,
|
|
1268
|
-
true
|
|
1269
|
-
];
|
|
1310
|
+
for (const [cls, [unip, neg]] of Object.entries(posixClasses)) if (glob.startsWith(cls, i)) {
|
|
1311
|
+
if (rangeStart) return [noMatch, glob.length - pos];
|
|
1270
1312
|
i += cls.length;
|
|
1271
1313
|
if (neg) negs.push(unip);
|
|
1272
1314
|
else ranges.push(unip);
|
|
1273
|
-
uflag = uflag || u;
|
|
1274
1315
|
continue WHILE;
|
|
1275
1316
|
}
|
|
1276
1317
|
}
|
|
1277
1318
|
escaping = false;
|
|
1319
|
+
const n = norm(c);
|
|
1278
1320
|
if (rangeStart) {
|
|
1279
|
-
if (
|
|
1280
|
-
else if (
|
|
1321
|
+
if (n.codePointAt(0) > rangeStart.codePointAt(0)) ranges.push(braceEscape(rangeStart) + "-" + braceEscape(n));
|
|
1322
|
+
else if (n === rangeStart) ranges.push(braceEscape(n));
|
|
1281
1323
|
rangeStart = "";
|
|
1282
|
-
i
|
|
1324
|
+
i += c.length;
|
|
1283
1325
|
continue;
|
|
1284
1326
|
}
|
|
1285
|
-
if (glob.startsWith("-]", i +
|
|
1286
|
-
ranges.push(braceEscape(
|
|
1287
|
-
i +=
|
|
1327
|
+
if (glob.startsWith("-]", i + c.length)) {
|
|
1328
|
+
ranges.push(braceEscape(n + "-"));
|
|
1329
|
+
i += c.length + 1;
|
|
1288
1330
|
continue;
|
|
1289
1331
|
}
|
|
1290
|
-
if (glob.startsWith("-", i +
|
|
1291
|
-
rangeStart =
|
|
1292
|
-
i +=
|
|
1332
|
+
if (glob.startsWith("-", i + c.length)) {
|
|
1333
|
+
rangeStart = n;
|
|
1334
|
+
i += c.length + 1;
|
|
1293
1335
|
continue;
|
|
1294
1336
|
}
|
|
1295
|
-
ranges.push(braceEscape(
|
|
1296
|
-
i
|
|
1337
|
+
ranges.push(braceEscape(n));
|
|
1338
|
+
i += c.length;
|
|
1297
1339
|
}
|
|
1298
|
-
if (endPos < i) return [
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
];
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1340
|
+
if (endPos < i) return [noMatch, 0];
|
|
1341
|
+
if (!ranges.length && !negs.length) return [noMatch, glob.length - pos];
|
|
1342
|
+
const sranges = "[" + (negate ? "^" : "") + ranges.join("") + "]";
|
|
1343
|
+
const snegs = "[" + (negate ? "" : "^") + negs.join("") + "]";
|
|
1344
|
+
const comb = "^" + (ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs);
|
|
1345
|
+
return [new RegExp(comb, nocase ? "iu" : "u"), endPos - pos];
|
|
1346
|
+
};
|
|
1347
|
+
// ../../node_modules/.pnpm/@isaacs+nonrecursive-glob-match@1.1.0/node_modules/@isaacs/nonrecursive-glob-match/dist/esm/index.js
|
|
1348
|
+
const MATCH = {
|
|
1349
|
+
t: "match",
|
|
1350
|
+
id: 0
|
|
1351
|
+
};
|
|
1352
|
+
const extTypes = "!?+*@";
|
|
1353
|
+
const lit = (ch) => ({
|
|
1354
|
+
t: "lit",
|
|
1355
|
+
ch
|
|
1356
|
+
});
|
|
1357
|
+
const reEscape = (s) => s.replace(/[\\^$.*+?()[\]{}|/]/g, "\\$&");
|
|
1358
|
+
const newFoldRe = (s) => new RegExp(`^${reEscape(s)}$`, "iu");
|
|
1359
|
+
const foldCache = /* @__PURE__ */ new Map();
|
|
1360
|
+
const foldRe = (ch) => {
|
|
1361
|
+
let re = foldCache.get(ch);
|
|
1362
|
+
if (!re) {
|
|
1363
|
+
re = newFoldRe(ch);
|
|
1364
|
+
if (foldCache.size >= 1e3) foldCache.clear();
|
|
1365
|
+
foldCache.set(ch, re);
|
|
1366
|
+
}
|
|
1367
|
+
return re;
|
|
1368
|
+
};
|
|
1369
|
+
const litMatch = (l, c) => {
|
|
1370
|
+
if (c === l.ch) return true;
|
|
1371
|
+
if (!l.re) return false;
|
|
1372
|
+
const code = c.charCodeAt(0);
|
|
1373
|
+
if (code >= 128) return l.re.test(c);
|
|
1374
|
+
const ascii = l.ascii ??= /* @__PURE__ */ new Uint8Array(128);
|
|
1375
|
+
ascii[code] ||= l.re.test(c) ? 1 : 2;
|
|
1376
|
+
return ascii[code] === 1;
|
|
1377
|
+
};
|
|
1378
|
+
const tokenize = (p, nocase, noext, form, mark) => {
|
|
1379
|
+
const toks = [];
|
|
1380
|
+
for (let i = 0; i < p.length;) {
|
|
1381
|
+
const c = String.fromCodePoint(p.codePointAt(i));
|
|
1382
|
+
if (mark) {
|
|
1383
|
+
const m = c === "\\" && p.startsWith(mark, i + 1) ? 1 : 0;
|
|
1384
|
+
if (m || c === mark) {
|
|
1385
|
+
const start = i + m + mark.length;
|
|
1386
|
+
const end = p.indexOf(mark, start);
|
|
1387
|
+
const r = /^(-?\d+)\.\.(-?\d+)$/.exec(p.slice(start, end));
|
|
1388
|
+
const alts = end !== -1 && r && numericRange(r[1], r[2]);
|
|
1389
|
+
if (alts) {
|
|
1390
|
+
toks.push({
|
|
1391
|
+
t: "ext",
|
|
1392
|
+
type: "@",
|
|
1393
|
+
alts
|
|
1394
|
+
});
|
|
1395
|
+
i = end + mark.length;
|
|
1396
|
+
continue;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
if (c === "\\") {
|
|
1401
|
+
const e = p.codePointAt(i + 1);
|
|
1402
|
+
const ch = e === void 0 ? c : String.fromCodePoint(e);
|
|
1403
|
+
toks.push(lit(ch));
|
|
1404
|
+
i += 1 + ch.length;
|
|
1405
|
+
continue;
|
|
1406
|
+
}
|
|
1407
|
+
if (c === "[") {
|
|
1408
|
+
const [re, consumed] = parseClass(p, i, nocase, form);
|
|
1409
|
+
if (consumed) {
|
|
1410
|
+
toks.push({
|
|
1411
|
+
t: "class",
|
|
1412
|
+
re
|
|
1413
|
+
});
|
|
1414
|
+
i += consumed;
|
|
1415
|
+
continue;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
if (!noext && extTypes.includes(c) && p[i + 1] === "(") {
|
|
1419
|
+
toks.push({
|
|
1420
|
+
t: "open",
|
|
1421
|
+
type: c
|
|
1422
|
+
});
|
|
1423
|
+
i += 2;
|
|
1424
|
+
continue;
|
|
1425
|
+
}
|
|
1426
|
+
toks.push(!noext && c === "|" ? { t: "bar" } : !noext && c === ")" ? { t: "close" } : c === "*" ? { t: "star" } : c === "?" ? { t: "any" } : lit(c));
|
|
1427
|
+
i += c.length;
|
|
1318
1428
|
}
|
|
1319
|
-
|
|
1320
|
-
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
1321
|
-
return [
|
|
1322
|
-
ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs,
|
|
1323
|
-
uflag,
|
|
1324
|
-
endPos - pos,
|
|
1325
|
-
true
|
|
1326
|
-
];
|
|
1429
|
+
return toks;
|
|
1327
1430
|
};
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
* For example, it will turn the string `'[*]'` into `*`, but it will not
|
|
1337
|
-
* turn `'\\*'` into `'*'`, because `\` is a path separator in
|
|
1338
|
-
* `windowsPathsNoEscape` mode.
|
|
1339
|
-
*
|
|
1340
|
-
* When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
|
|
1341
|
-
* backslash escapes are removed.
|
|
1342
|
-
*
|
|
1343
|
-
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
|
|
1344
|
-
* or unescaped.
|
|
1345
|
-
*
|
|
1346
|
-
* When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
|
|
1347
|
-
* unescaped.
|
|
1348
|
-
*/
|
|
1349
|
-
const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
|
|
1350
|
-
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
|
|
1351
|
-
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
|
|
1431
|
+
const pair = (toks) => {
|
|
1432
|
+
const pairs = /* @__PURE__ */ new Map();
|
|
1433
|
+
const stack = [];
|
|
1434
|
+
toks.forEach((tok, i) => {
|
|
1435
|
+
if (tok.t === "open") stack.push(i);
|
|
1436
|
+
else if (tok.t === "close" && stack.length) pairs.set(stack.pop(), i);
|
|
1437
|
+
});
|
|
1438
|
+
return pairs;
|
|
1352
1439
|
};
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
"
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
]
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
"
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
["+", [
|
|
1393
|
-
"+",
|
|
1394
|
-
"@",
|
|
1395
|
-
"?",
|
|
1396
|
-
"*"
|
|
1397
|
-
]]
|
|
1398
|
-
]);
|
|
1399
|
-
const usurpMap = /* @__PURE__ */ new Map([
|
|
1400
|
-
["!", /* @__PURE__ */ new Map([["!", "@"]])],
|
|
1401
|
-
["?", /* @__PURE__ */ new Map([["*", "*"], ["+", "*"]])],
|
|
1402
|
-
["@", /* @__PURE__ */ new Map([
|
|
1403
|
-
["!", "!"],
|
|
1404
|
-
["?", "?"],
|
|
1405
|
-
["@", "@"],
|
|
1406
|
-
["*", "*"],
|
|
1407
|
-
["+", "+"]
|
|
1408
|
-
])],
|
|
1409
|
-
["+", /* @__PURE__ */ new Map([["?", "*"], ["*", "*"]])]
|
|
1410
|
-
]);
|
|
1411
|
-
const startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
1412
|
-
const startNoDot = "(?!\\.)";
|
|
1413
|
-
const addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
|
|
1414
|
-
const justDots = /* @__PURE__ */ new Set(["..", "."]);
|
|
1415
|
-
const reSpecials = /* @__PURE__ */ new Set("().*{}+?[]^$\\!");
|
|
1416
|
-
const regExpEscape$1 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1417
|
-
const qmark = "[^/]";
|
|
1418
|
-
const star$1 = "[^/]*?";
|
|
1419
|
-
const starNoEmpty = "[^/]+?";
|
|
1420
|
-
let ID = 0;
|
|
1421
|
-
var AST = class {
|
|
1422
|
-
type;
|
|
1423
|
-
#root;
|
|
1424
|
-
#hasMagic;
|
|
1425
|
-
#uflag = false;
|
|
1426
|
-
#parts = [];
|
|
1427
|
-
#parent;
|
|
1428
|
-
#parentIndex;
|
|
1429
|
-
#negs;
|
|
1430
|
-
#filledNegs = false;
|
|
1431
|
-
#options;
|
|
1432
|
-
#toString;
|
|
1433
|
-
#emptyExt = false;
|
|
1434
|
-
id = ++ID;
|
|
1435
|
-
get depth() {
|
|
1436
|
-
return (this.#parent?.depth ?? -1) + 1;
|
|
1437
|
-
}
|
|
1438
|
-
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
1439
|
-
return {
|
|
1440
|
-
"@@type": "AST",
|
|
1441
|
-
id: this.id,
|
|
1442
|
-
type: this.type,
|
|
1443
|
-
root: this.#root.id,
|
|
1444
|
-
parent: this.#parent?.id,
|
|
1445
|
-
depth: this.depth,
|
|
1446
|
-
partsLength: this.#parts.length,
|
|
1447
|
-
parts: this.#parts
|
|
1448
|
-
};
|
|
1440
|
+
const build$1 = (toks, pairs, start, end, top) => {
|
|
1441
|
+
let seq = [];
|
|
1442
|
+
const alts = [seq];
|
|
1443
|
+
for (let i = start; i < end; i++) {
|
|
1444
|
+
const tok = toks[i];
|
|
1445
|
+
const close = pairs.get(i);
|
|
1446
|
+
if (tok.t === "open" && close !== void 0) {
|
|
1447
|
+
const sub = build$1(toks, pairs, i + 1, close, false);
|
|
1448
|
+
seq.push({
|
|
1449
|
+
t: "ext",
|
|
1450
|
+
type: tok.type,
|
|
1451
|
+
alts: sub
|
|
1452
|
+
});
|
|
1453
|
+
i = close;
|
|
1454
|
+
} else if (tok.t === "bar" && !top) alts.push(seq = []);
|
|
1455
|
+
else if (tok.t === "open") seq.push(lit(tok.type), lit("("));
|
|
1456
|
+
else if (tok.t === "bar") seq.push(lit("|"));
|
|
1457
|
+
else if (tok.t === "close") seq.push(lit(")"));
|
|
1458
|
+
else seq.push(tok);
|
|
1459
|
+
}
|
|
1460
|
+
return alts;
|
|
1461
|
+
};
|
|
1462
|
+
const normalize$1 = (items, form) => {
|
|
1463
|
+
const out = [];
|
|
1464
|
+
let run = "";
|
|
1465
|
+
const flush = () => {
|
|
1466
|
+
for (const ch of run.normalize(form)) out.push(lit(ch));
|
|
1467
|
+
run = "";
|
|
1468
|
+
};
|
|
1469
|
+
for (const it of items) {
|
|
1470
|
+
if (it.t === "lit") {
|
|
1471
|
+
run += it.ch;
|
|
1472
|
+
continue;
|
|
1473
|
+
}
|
|
1474
|
+
flush();
|
|
1475
|
+
out.push(it.t === "ext" ? {
|
|
1476
|
+
...it,
|
|
1477
|
+
alts: it.alts.map((a) => normalize$1(a, form))
|
|
1478
|
+
} : it);
|
|
1449
1479
|
}
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
}
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1480
|
+
flush();
|
|
1481
|
+
return out;
|
|
1482
|
+
};
|
|
1483
|
+
const compile = (items, nocase) => {
|
|
1484
|
+
let id = 1;
|
|
1485
|
+
const split = (out) => ({
|
|
1486
|
+
t: "split",
|
|
1487
|
+
id: id++,
|
|
1488
|
+
out
|
|
1489
|
+
});
|
|
1490
|
+
const seq = (items, next) => items.reduceRight((next, it) => item(it, next), next);
|
|
1491
|
+
const item = (it, next) => {
|
|
1492
|
+
switch (it.t) {
|
|
1493
|
+
case "lit":
|
|
1494
|
+
const re = nocase ? foldRe(it.ch) : void 0;
|
|
1495
|
+
return {
|
|
1496
|
+
t: "lit",
|
|
1497
|
+
id: id++,
|
|
1498
|
+
ch: it.ch,
|
|
1499
|
+
re,
|
|
1500
|
+
next
|
|
1501
|
+
};
|
|
1502
|
+
case "any":
|
|
1503
|
+
case "star": return {
|
|
1504
|
+
t: it.t,
|
|
1505
|
+
id: id++,
|
|
1506
|
+
next
|
|
1507
|
+
};
|
|
1508
|
+
case "class": return {
|
|
1509
|
+
t: "class",
|
|
1510
|
+
id: id++,
|
|
1511
|
+
re: it.re,
|
|
1512
|
+
next
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
const alts = (next) => it.alts.map((a) => seq(a, next));
|
|
1516
|
+
switch (it.type) {
|
|
1517
|
+
case "@": return split(alts(next));
|
|
1518
|
+
case "?": return split([next, ...alts(next)]);
|
|
1519
|
+
case "!": return {
|
|
1520
|
+
t: "neg",
|
|
1521
|
+
id: id++,
|
|
1522
|
+
sub: split(alts(MATCH)),
|
|
1523
|
+
next
|
|
1524
|
+
};
|
|
1467
1525
|
}
|
|
1468
|
-
|
|
1526
|
+
const after = split([]);
|
|
1527
|
+
const entry = split(alts(after));
|
|
1528
|
+
after.out.push(next, entry);
|
|
1529
|
+
return it.type === "*" ? after : entry;
|
|
1530
|
+
};
|
|
1531
|
+
return [seq(items, MATCH), id];
|
|
1532
|
+
};
|
|
1533
|
+
const show = (start) => {
|
|
1534
|
+
const lines = [];
|
|
1535
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1536
|
+
const ref = (n) => n.t === "match" ? "match" : String(n.id);
|
|
1537
|
+
const walk = (n, indent) => {
|
|
1538
|
+
if (n.t === "match" || seen.has(n)) return;
|
|
1539
|
+
seen.add(n);
|
|
1540
|
+
const line = (desc) => lines.push(`${indent}${n.id}: ${desc}`);
|
|
1541
|
+
switch (n.t) {
|
|
1542
|
+
case "split":
|
|
1543
|
+
line(`split -> ${n.out.map(ref).join(", ")}`);
|
|
1544
|
+
for (const o of n.out) walk(o, indent);
|
|
1545
|
+
return;
|
|
1546
|
+
case "neg":
|
|
1547
|
+
line(`!(${ref(n.sub)}) -> ${ref(n.next)}`);
|
|
1548
|
+
walk(n.sub, indent + " ");
|
|
1549
|
+
return walk(n.next, indent);
|
|
1550
|
+
case "lit":
|
|
1551
|
+
line(`${JSON.stringify(n.ch)} -> ${ref(n.next)}`);
|
|
1552
|
+
break;
|
|
1553
|
+
case "class":
|
|
1554
|
+
line(`${n.re} -> ${ref(n.next)}`);
|
|
1555
|
+
break;
|
|
1556
|
+
default: line(`${n.t === "any" ? "?" : "*"} -> ${ref(n.next)}`);
|
|
1557
|
+
}
|
|
1558
|
+
walk(n.next, indent);
|
|
1559
|
+
};
|
|
1560
|
+
walk(start, "");
|
|
1561
|
+
return [`start -> ${ref(start)}`, ...lines].join("\n");
|
|
1562
|
+
};
|
|
1563
|
+
var State = class {
|
|
1564
|
+
gen;
|
|
1565
|
+
threads = [];
|
|
1566
|
+
match = false;
|
|
1567
|
+
runs = [];
|
|
1568
|
+
ids = [];
|
|
1569
|
+
constructor(gen) {
|
|
1570
|
+
this.gen = gen;
|
|
1571
|
+
}
|
|
1572
|
+
get dead() {
|
|
1573
|
+
return !this.threads.length && !this.match && !this.runs.length;
|
|
1469
1574
|
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1575
|
+
};
|
|
1576
|
+
const sameState = (a, b) => {
|
|
1577
|
+
if (a.ids.length !== b.ids.length) return false;
|
|
1578
|
+
if (a.runs.length !== b.runs.length) return false;
|
|
1579
|
+
if (a.ids.some((id, i) => id !== b.ids[i])) return false;
|
|
1580
|
+
return a.runs.every((r) => b.runs.some((o) => o.neg === r.neg && sameState(o.state, r.state)));
|
|
1581
|
+
};
|
|
1582
|
+
const marks = (size) => ({
|
|
1583
|
+
has: new Float64Array(size),
|
|
1584
|
+
seen: new Float64Array(size),
|
|
1585
|
+
gen: 0
|
|
1586
|
+
});
|
|
1587
|
+
var Sim = class {
|
|
1588
|
+
dots;
|
|
1589
|
+
dotStart;
|
|
1590
|
+
#marks;
|
|
1591
|
+
constructor(dots, dotStart, marks) {
|
|
1592
|
+
this.dots = dots;
|
|
1593
|
+
this.dotStart = dotStart;
|
|
1594
|
+
this.#marks = marks;
|
|
1595
|
+
}
|
|
1596
|
+
state() {
|
|
1597
|
+
return new State(++this.#marks.gen);
|
|
1598
|
+
}
|
|
1599
|
+
done(state) {
|
|
1600
|
+
state.ids = state.threads.map((n) => n.id).sort((a, b) => a - b);
|
|
1601
|
+
if (state.match) state.ids.unshift(MATCH.id);
|
|
1602
|
+
return state;
|
|
1603
|
+
}
|
|
1604
|
+
#visit(state, node) {
|
|
1605
|
+
const { seen } = this.#marks;
|
|
1606
|
+
if (seen[node.id] === state.gen) return false;
|
|
1607
|
+
seen[node.id] = state.gen;
|
|
1608
|
+
return true;
|
|
1472
1609
|
}
|
|
1473
|
-
#
|
|
1474
|
-
|
|
1475
|
-
if (
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
this.#filledNegs = true;
|
|
1480
|
-
let n;
|
|
1481
|
-
while (n = this.#negs.pop()) {
|
|
1482
|
-
if (n.type !== "!") continue;
|
|
1483
|
-
let p = n;
|
|
1484
|
-
let pp = p.#parent;
|
|
1485
|
-
while (pp) {
|
|
1486
|
-
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) for (const part of n.#parts) {
|
|
1487
|
-
/* c8 ignore start */
|
|
1488
|
-
if (typeof part === "string") throw new Error("string part in extglob AST??");
|
|
1489
|
-
/* c8 ignore stop */
|
|
1490
|
-
part.copyIn(pp.#parts[i]);
|
|
1491
|
-
}
|
|
1492
|
-
p = pp;
|
|
1493
|
-
pp = p.#parent;
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
return this;
|
|
1610
|
+
#addThread(state, node) {
|
|
1611
|
+
const { has } = this.#marks;
|
|
1612
|
+
if (has[node.id] === state.gen) return false;
|
|
1613
|
+
has[node.id] = state.gen;
|
|
1614
|
+
state.threads.push(node);
|
|
1615
|
+
return true;
|
|
1497
1616
|
}
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1617
|
+
restricted(i, top) {
|
|
1618
|
+
return top && (this.dots || this.dotStart && i === 0);
|
|
1619
|
+
}
|
|
1620
|
+
add(state, node, i, top) {
|
|
1621
|
+
switch (node.t) {
|
|
1622
|
+
case "split":
|
|
1623
|
+
if (!this.#visit(state, node)) return;
|
|
1624
|
+
for (const o of node.out) this.add(state, o, i, top);
|
|
1625
|
+
return;
|
|
1626
|
+
case "neg":
|
|
1627
|
+
if (!this.#visit(state, node)) return;
|
|
1628
|
+
const sub = this.state();
|
|
1629
|
+
this.add(sub, node.sub, i, false);
|
|
1630
|
+
this.done(sub);
|
|
1631
|
+
return this.addRun(state, {
|
|
1632
|
+
t: "run",
|
|
1633
|
+
neg: node,
|
|
1634
|
+
state: sub
|
|
1635
|
+
}, i, top);
|
|
1636
|
+
case "star":
|
|
1637
|
+
if (this.restricted(i, top)) return;
|
|
1638
|
+
if (this.#addThread(state, node)) this.add(state, node.next, i, top);
|
|
1639
|
+
return;
|
|
1640
|
+
case "match":
|
|
1641
|
+
state.match = true;
|
|
1642
|
+
return;
|
|
1643
|
+
default: this.#addThread(state, node);
|
|
1505
1644
|
}
|
|
1506
1645
|
}
|
|
1507
|
-
|
|
1508
|
-
const
|
|
1509
|
-
|
|
1510
|
-
if (
|
|
1511
|
-
return ret;
|
|
1646
|
+
addRun(state, run, i, top) {
|
|
1647
|
+
for (const r of state.runs) if (r.neg === run.neg && sameState(r.state, run.state)) return;
|
|
1648
|
+
state.runs.push(run);
|
|
1649
|
+
if (!run.state.match) this.add(state, run.neg.next, i, top);
|
|
1512
1650
|
}
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1651
|
+
step(state, c, i, top) {
|
|
1652
|
+
const next = this.state();
|
|
1653
|
+
for (const th of state.threads) switch (th.t) {
|
|
1654
|
+
case "lit":
|
|
1655
|
+
if (litMatch(th, c)) this.add(next, th.next, i + 1, top);
|
|
1656
|
+
break;
|
|
1657
|
+
case "any":
|
|
1658
|
+
if (!this.restricted(i, top)) this.add(next, th.next, i + 1, top);
|
|
1659
|
+
break;
|
|
1660
|
+
case "class":
|
|
1661
|
+
if (!this.restricted(i, top) && th.re.test(c)) this.add(next, th.next, i + 1, top);
|
|
1662
|
+
break;
|
|
1663
|
+
case "star": if (!this.restricted(i, top)) this.add(next, th, i + 1, top);
|
|
1521
1664
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
if (this.#root === this) return true;
|
|
1526
|
-
if (this.#parent?.type === "!") return true;
|
|
1527
|
-
if (!this.#parent?.isEnd()) return false;
|
|
1528
|
-
if (!this.type) return this.#parent?.isEnd();
|
|
1529
|
-
/* c8 ignore start */
|
|
1530
|
-
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
1531
|
-
/* c8 ignore stop */
|
|
1532
|
-
return this.#parentIndex === pl - 1;
|
|
1533
|
-
}
|
|
1534
|
-
copyIn(part) {
|
|
1535
|
-
if (typeof part === "string") this.push(part);
|
|
1536
|
-
else this.push(part.clone(this));
|
|
1537
|
-
}
|
|
1538
|
-
clone(parent) {
|
|
1539
|
-
const c = new _a(this.type, parent);
|
|
1540
|
-
for (const p of this.#parts) c.copyIn(p);
|
|
1541
|
-
return c;
|
|
1542
|
-
}
|
|
1543
|
-
static #parseAST(str, ast, pos, opt, extDepth) {
|
|
1544
|
-
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
1545
|
-
let escaping = false;
|
|
1546
|
-
let inBrace = false;
|
|
1547
|
-
let braceStart = -1;
|
|
1548
|
-
let braceNeg = false;
|
|
1549
|
-
if (ast.type === null) {
|
|
1550
|
-
let i = pos;
|
|
1551
|
-
let acc = "";
|
|
1552
|
-
while (i < str.length) {
|
|
1553
|
-
const c = str.charAt(i++);
|
|
1554
|
-
if (escaping || c === "\\") {
|
|
1555
|
-
escaping = !escaping;
|
|
1556
|
-
acc += c;
|
|
1557
|
-
continue;
|
|
1558
|
-
}
|
|
1559
|
-
if (inBrace) {
|
|
1560
|
-
if (i === braceStart + 1) {
|
|
1561
|
-
if (c === "^" || c === "!") braceNeg = true;
|
|
1562
|
-
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
|
|
1563
|
-
acc += c;
|
|
1564
|
-
continue;
|
|
1565
|
-
} else if (c === "[") {
|
|
1566
|
-
inBrace = true;
|
|
1567
|
-
braceStart = i;
|
|
1568
|
-
braceNeg = false;
|
|
1569
|
-
acc += c;
|
|
1570
|
-
continue;
|
|
1571
|
-
}
|
|
1572
|
-
if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && extDepth <= maxDepth) {
|
|
1573
|
-
ast.push(acc);
|
|
1574
|
-
acc = "";
|
|
1575
|
-
const ext = new _a(c, ast);
|
|
1576
|
-
i = _a.#parseAST(str, ext, i, opt, extDepth + 1);
|
|
1577
|
-
ast.push(ext);
|
|
1578
|
-
continue;
|
|
1579
|
-
}
|
|
1580
|
-
acc += c;
|
|
1581
|
-
}
|
|
1582
|
-
ast.push(acc);
|
|
1583
|
-
return i;
|
|
1584
|
-
}
|
|
1585
|
-
let i = pos + 1;
|
|
1586
|
-
let part = new _a(null, ast);
|
|
1587
|
-
const parts = [];
|
|
1588
|
-
let acc = "";
|
|
1589
|
-
while (i < str.length) {
|
|
1590
|
-
const c = str.charAt(i++);
|
|
1591
|
-
if (escaping || c === "\\") {
|
|
1592
|
-
escaping = !escaping;
|
|
1593
|
-
acc += c;
|
|
1594
|
-
continue;
|
|
1595
|
-
}
|
|
1596
|
-
if (inBrace) {
|
|
1597
|
-
if (i === braceStart + 1) {
|
|
1598
|
-
if (c === "^" || c === "!") braceNeg = true;
|
|
1599
|
-
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) inBrace = false;
|
|
1600
|
-
acc += c;
|
|
1601
|
-
continue;
|
|
1602
|
-
} else if (c === "[") {
|
|
1603
|
-
inBrace = true;
|
|
1604
|
-
braceStart = i;
|
|
1605
|
-
braceNeg = false;
|
|
1606
|
-
acc += c;
|
|
1607
|
-
continue;
|
|
1608
|
-
}
|
|
1609
|
-
/* c8 ignore stop */
|
|
1610
|
-
if (!opt.noext && isExtglobType(c) && str.charAt(i) === "(" && (extDepth <= maxDepth || ast && ast.#canAdoptType(c))) {
|
|
1611
|
-
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
1612
|
-
part.push(acc);
|
|
1613
|
-
acc = "";
|
|
1614
|
-
const ext = new _a(c, part);
|
|
1615
|
-
part.push(ext);
|
|
1616
|
-
i = _a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
|
|
1617
|
-
continue;
|
|
1618
|
-
}
|
|
1619
|
-
if (c === "|") {
|
|
1620
|
-
part.push(acc);
|
|
1621
|
-
acc = "";
|
|
1622
|
-
parts.push(part);
|
|
1623
|
-
part = new _a(null, ast);
|
|
1665
|
+
if (!this.restricted(i, top)) for (const run of state.runs) {
|
|
1666
|
+
if (run.state.dead) {
|
|
1667
|
+
this.addRun(next, run, i + 1, top);
|
|
1624
1668
|
continue;
|
|
1625
1669
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
}
|
|
1635
|
-
ast.type = null;
|
|
1636
|
-
ast.#hasMagic = void 0;
|
|
1637
|
-
ast.#parts = [str.substring(pos - 1)];
|
|
1638
|
-
return i;
|
|
1639
|
-
}
|
|
1640
|
-
#canAdoptWithSpace(child) {
|
|
1641
|
-
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
1642
|
-
}
|
|
1643
|
-
#canAdopt(child, map = adoptionMap) {
|
|
1644
|
-
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null) return false;
|
|
1645
|
-
const gc = child.#parts[0];
|
|
1646
|
-
if (!gc || typeof gc !== "object" || gc.type === null) return false;
|
|
1647
|
-
return this.#canAdoptType(gc.type, map);
|
|
1648
|
-
}
|
|
1649
|
-
#canAdoptType(c, map = adoptionAnyMap) {
|
|
1650
|
-
return !!map.get(this.type)?.includes(c);
|
|
1651
|
-
}
|
|
1652
|
-
#adoptWithSpace(child, index) {
|
|
1653
|
-
const gc = child.#parts[0];
|
|
1654
|
-
const blank = new _a(null, gc, this.options);
|
|
1655
|
-
blank.#parts.push("");
|
|
1656
|
-
gc.push(blank);
|
|
1657
|
-
this.#adopt(child, index);
|
|
1658
|
-
}
|
|
1659
|
-
#adopt(child, index) {
|
|
1660
|
-
const gc = child.#parts[0];
|
|
1661
|
-
this.#parts.splice(index, 1, ...gc.#parts);
|
|
1662
|
-
for (const p of gc.#parts) if (typeof p === "object") p.#parent = this;
|
|
1663
|
-
this.#toString = void 0;
|
|
1664
|
-
}
|
|
1665
|
-
#canUsurpType(c) {
|
|
1666
|
-
return !!usurpMap.get(this.type)?.has(c);
|
|
1667
|
-
}
|
|
1668
|
-
#canUsurp(child) {
|
|
1669
|
-
if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) return false;
|
|
1670
|
-
const gc = child.#parts[0];
|
|
1671
|
-
if (!gc || typeof gc !== "object" || gc.type === null) return false;
|
|
1672
|
-
return this.#canUsurpType(gc.type);
|
|
1673
|
-
}
|
|
1674
|
-
#usurp(child) {
|
|
1675
|
-
const m = usurpMap.get(this.type);
|
|
1676
|
-
const gc = child.#parts[0];
|
|
1677
|
-
const nt = m?.get(gc.type);
|
|
1678
|
-
/* c8 ignore start - impossible */
|
|
1679
|
-
if (!nt) return false;
|
|
1680
|
-
/* c8 ignore stop */
|
|
1681
|
-
this.#parts = gc.#parts;
|
|
1682
|
-
for (const p of this.#parts) if (typeof p === "object") p.#parent = this;
|
|
1683
|
-
this.type = nt;
|
|
1684
|
-
this.#toString = void 0;
|
|
1685
|
-
this.#emptyExt = false;
|
|
1686
|
-
}
|
|
1687
|
-
static fromGlob(pattern, options = {}) {
|
|
1688
|
-
const ast = new _a(null, void 0, options);
|
|
1689
|
-
_a.#parseAST(pattern, ast, 0, options, 0);
|
|
1690
|
-
return ast;
|
|
1691
|
-
}
|
|
1692
|
-
toMMPattern() {
|
|
1693
|
-
/* c8 ignore start */
|
|
1694
|
-
if (this !== this.#root) return this.#root.toMMPattern();
|
|
1695
|
-
/* c8 ignore stop */
|
|
1696
|
-
const glob = this.toString();
|
|
1697
|
-
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
1698
|
-
if (!(hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase())) return body;
|
|
1699
|
-
const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
1700
|
-
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
1701
|
-
_src: re,
|
|
1702
|
-
_glob: glob
|
|
1703
|
-
});
|
|
1670
|
+
const sub = this.step(run.state, c, i, false);
|
|
1671
|
+
this.addRun(next, {
|
|
1672
|
+
t: "run",
|
|
1673
|
+
neg: run.neg,
|
|
1674
|
+
state: sub
|
|
1675
|
+
}, i + 1, top);
|
|
1676
|
+
}
|
|
1677
|
+
return this.done(next);
|
|
1704
1678
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1679
|
+
};
|
|
1680
|
+
const stateKey = (state) => {
|
|
1681
|
+
const ids = state.ids.join();
|
|
1682
|
+
if (!state.runs.length) return ids;
|
|
1683
|
+
return `${ids}|${state.runs.map((r) => `${r.neg.id}(${stateKey(r.state)})`).sort().join("|")}`;
|
|
1684
|
+
};
|
|
1685
|
+
const DFA_BUDGET = 1 << 18;
|
|
1686
|
+
var Dfa = class {
|
|
1687
|
+
#start;
|
|
1688
|
+
#states = /* @__PURE__ */ new Map();
|
|
1689
|
+
#size = 0;
|
|
1690
|
+
#plain;
|
|
1691
|
+
#dotStart;
|
|
1692
|
+
#sim;
|
|
1693
|
+
#dotSim;
|
|
1694
|
+
constructor(start, marks) {
|
|
1695
|
+
this.#start = start;
|
|
1696
|
+
this.#sim = new Sim(false, false, marks);
|
|
1697
|
+
this.#dotSim = new Sim(false, true, marks);
|
|
1698
|
+
}
|
|
1699
|
+
#make(state) {
|
|
1700
|
+
return {
|
|
1701
|
+
state,
|
|
1702
|
+
match: state.match,
|
|
1703
|
+
dead: state.dead,
|
|
1704
|
+
next: /* @__PURE__ */ new Map()
|
|
1705
|
+
};
|
|
1706
|
+
}
|
|
1707
|
+
#intern(state) {
|
|
1708
|
+
const key = stateKey(state);
|
|
1709
|
+
const found = this.#states.get(key);
|
|
1710
|
+
if (found) return found;
|
|
1711
|
+
if (this.#size > DFA_BUDGET) this.#clear();
|
|
1712
|
+
const d = this.#make(state);
|
|
1713
|
+
this.#states.set(key, d);
|
|
1714
|
+
this.#size += key.length + 1;
|
|
1715
|
+
return d;
|
|
1716
|
+
}
|
|
1717
|
+
#clear() {
|
|
1718
|
+
this.#states.clear();
|
|
1719
|
+
this.#size = 0;
|
|
1720
|
+
this.#plain = void 0;
|
|
1721
|
+
this.#dotStart = void 0;
|
|
1722
|
+
}
|
|
1723
|
+
start(dotStart) {
|
|
1724
|
+
if (dotStart) {
|
|
1725
|
+
if (this.#dotStart) return this.#dotStart;
|
|
1726
|
+
const state = this.#dotSim.state();
|
|
1727
|
+
this.#dotSim.add(state, this.#start, 0, true);
|
|
1728
|
+
return this.#dotStart = this.#make(this.#dotSim.done(state));
|
|
1729
|
+
}
|
|
1730
|
+
if (this.#plain) return this.#plain;
|
|
1731
|
+
const state = this.#sim.state();
|
|
1732
|
+
this.#sim.add(state, this.#start, 0, true);
|
|
1733
|
+
return this.#plain = this.#intern(this.#sim.done(state));
|
|
1734
|
+
}
|
|
1735
|
+
next(d, c) {
|
|
1736
|
+
const code = c.charCodeAt(0);
|
|
1737
|
+
const found = code < 128 ? void 0 : d.next.get(c);
|
|
1738
|
+
if (found) return found;
|
|
1739
|
+
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));
|
|
1740
|
+
if (code < 128) {
|
|
1741
|
+
if (!d.ascii) {
|
|
1742
|
+
d.ascii = new Array(128);
|
|
1743
|
+
this.#size += 128;
|
|
1732
1744
|
}
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1745
|
+
d.ascii[code] = n;
|
|
1746
|
+
} else d.next.set(c, n);
|
|
1747
|
+
this.#size++;
|
|
1748
|
+
return n;
|
|
1749
|
+
}
|
|
1750
|
+
};
|
|
1751
|
+
const linear = (start) => {
|
|
1752
|
+
const nodes = [];
|
|
1753
|
+
for (let n = start; n.t !== "match"; n = n.next) {
|
|
1754
|
+
if (n.t === "split" || n.t === "neg") return void 0;
|
|
1755
|
+
nodes.push(n);
|
|
1756
|
+
}
|
|
1757
|
+
return nodes;
|
|
1758
|
+
};
|
|
1759
|
+
const testLinear = (nodes, chars, start, end) => {
|
|
1760
|
+
let ni = 0;
|
|
1761
|
+
let ci = start;
|
|
1762
|
+
let starNi = -1;
|
|
1763
|
+
let starCi = 0;
|
|
1764
|
+
while (ci < end) {
|
|
1765
|
+
const n = nodes[ni];
|
|
1766
|
+
if (n?.t === "star") {
|
|
1767
|
+
starNi = ni++;
|
|
1768
|
+
starCi = ci;
|
|
1769
|
+
continue;
|
|
1757
1770
|
}
|
|
1758
|
-
|
|
1759
|
-
if (
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
else {
|
|
1764
|
-
const close = this.type === "!" ? "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + "[^/]*?)" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
|
|
1765
|
-
final = start + body + close;
|
|
1771
|
+
const c = chars[ci];
|
|
1772
|
+
if (n && (n.t === "any" || n.t === "lit" && litMatch(n, c) || n.t === "class" && n.re.test(c))) {
|
|
1773
|
+
ni++;
|
|
1774
|
+
ci++;
|
|
1775
|
+
continue;
|
|
1766
1776
|
}
|
|
1767
|
-
return
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
this.#hasMagic = !!this.#hasMagic,
|
|
1771
|
-
this.#uflag
|
|
1772
|
-
];
|
|
1777
|
+
if (starNi === -1) return false;
|
|
1778
|
+
ni = starNi + 1;
|
|
1779
|
+
ci = ++starCi;
|
|
1773
1780
|
}
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1781
|
+
while (nodes[ni]?.t === "star") ni++;
|
|
1782
|
+
return ni === nodes.length;
|
|
1783
|
+
};
|
|
1784
|
+
const lengths = (items) => {
|
|
1785
|
+
let min = 0;
|
|
1786
|
+
let max = 0;
|
|
1787
|
+
for (const it of items) {
|
|
1788
|
+
const [lo, hi] = itemLengths(it);
|
|
1789
|
+
min += lo;
|
|
1790
|
+
max += hi;
|
|
1791
|
+
}
|
|
1792
|
+
return [min, max];
|
|
1793
|
+
};
|
|
1794
|
+
const itemLengths = (it) => {
|
|
1795
|
+
if (it.t === "star") return [0, Infinity];
|
|
1796
|
+
if (it.t !== "ext") return [1, 1];
|
|
1797
|
+
if (it.type === "!") return [0, Infinity];
|
|
1798
|
+
const alts = it.alts.map(lengths);
|
|
1799
|
+
const min = Math.min(...alts.map((a) => a[0]));
|
|
1800
|
+
const max = Math.max(...alts.map((a) => a[1]));
|
|
1801
|
+
const loop = max === 0 ? 0 : Infinity;
|
|
1802
|
+
return it.type === "@" ? [min, max] : it.type === "?" ? [0, max] : it.type === "*" ? [0, loop] : [min, loop];
|
|
1803
|
+
};
|
|
1804
|
+
const hasAffix = (lits, chars, start) => {
|
|
1805
|
+
for (let j = 0; j < lits.length; j++) if (!litMatch(lits[j], chars[start + j])) return false;
|
|
1806
|
+
return true;
|
|
1807
|
+
};
|
|
1808
|
+
const slashOrSurrogate = /[/\ud800-\udfff]/;
|
|
1809
|
+
const surrogate = /[\ud800-\udfff]/;
|
|
1810
|
+
const codePoints = (s) => surrogate.test(s) ? [...s] : s;
|
|
1811
|
+
const noSlash = (s) => {
|
|
1812
|
+
if (s.includes("/")) throw new Error("can only match a single path portion, got: " + s);
|
|
1813
|
+
};
|
|
1814
|
+
var Matcher = class {
|
|
1815
|
+
pattern;
|
|
1816
|
+
options;
|
|
1817
|
+
#start;
|
|
1818
|
+
#size;
|
|
1819
|
+
#marks;
|
|
1820
|
+
#dotsSim;
|
|
1821
|
+
#literal;
|
|
1822
|
+
#literalFold = false;
|
|
1823
|
+
#literalRe;
|
|
1824
|
+
#linear;
|
|
1825
|
+
#wild = false;
|
|
1826
|
+
#min = 0;
|
|
1827
|
+
#max = Infinity;
|
|
1828
|
+
#prefix = [];
|
|
1829
|
+
#suffix = [];
|
|
1830
|
+
#prefixStr;
|
|
1831
|
+
#suffixStr;
|
|
1832
|
+
#affix = false;
|
|
1833
|
+
#dfa;
|
|
1834
|
+
#form;
|
|
1835
|
+
constructor(pattern, options = {}) {
|
|
1836
|
+
if (pattern.includes("/")) throw new Error("can only match a single path portion, got pattern: " + pattern);
|
|
1837
|
+
this.pattern = pattern;
|
|
1838
|
+
this.options = options;
|
|
1839
|
+
const { nocase = false, noext = false, normalize: n } = options;
|
|
1840
|
+
this.#form = n === true ? "NFC" : n || void 0;
|
|
1841
|
+
const literal = /^[?*+@]\(\)$/.test(pattern);
|
|
1842
|
+
const toks = tokenize(pattern, nocase, noext || literal, this.#form, options.rangeMark);
|
|
1843
|
+
let [items] = build$1(toks, pair(toks), 0, toks.length, true);
|
|
1844
|
+
if (this.#form) items = normalize$1(items, this.#form);
|
|
1845
|
+
const [start, size] = compile(items, nocase);
|
|
1846
|
+
this.#start = start;
|
|
1847
|
+
this.#size = size;
|
|
1848
|
+
if (items.every((it) => it.t === "lit")) {
|
|
1849
|
+
this.#literal = items.map((it) => it.ch).join("");
|
|
1850
|
+
this.#literalFold = nocase;
|
|
1777
1851
|
} else {
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
if (this.#canAdopt(c)) {
|
|
1787
|
-
done = false;
|
|
1788
|
-
this.#adopt(c, i);
|
|
1789
|
-
} else if (this.#canAdoptWithSpace(c)) {
|
|
1790
|
-
done = false;
|
|
1791
|
-
this.#adoptWithSpace(c, i);
|
|
1792
|
-
} else if (this.#canUsurp(c)) {
|
|
1793
|
-
done = false;
|
|
1794
|
-
this.#usurp(c);
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
} while (!done && ++iterations < 10);
|
|
1799
|
-
}
|
|
1800
|
-
this.#toString = void 0;
|
|
1801
|
-
}
|
|
1802
|
-
#partsToRegExp(dot) {
|
|
1803
|
-
return this.#parts.map((p) => {
|
|
1804
|
-
/* c8 ignore start */
|
|
1805
|
-
if (typeof p === "string") throw new Error("string type in extglob ast??");
|
|
1806
|
-
/* c8 ignore stop */
|
|
1807
|
-
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
1808
|
-
this.#uflag = this.#uflag || uflag;
|
|
1809
|
-
return re;
|
|
1810
|
-
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
1811
|
-
}
|
|
1812
|
-
static #parseGlob(glob, hasMagic, noEmpty = false) {
|
|
1813
|
-
let escaping = false;
|
|
1814
|
-
let re = "";
|
|
1815
|
-
let uflag = false;
|
|
1816
|
-
let inStar = false;
|
|
1817
|
-
for (let i = 0; i < glob.length; i++) {
|
|
1818
|
-
const c = glob.charAt(i);
|
|
1819
|
-
if (escaping) {
|
|
1820
|
-
escaping = false;
|
|
1821
|
-
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
1822
|
-
continue;
|
|
1852
|
+
const lit = (it) => it.t !== "lit" ? void 0 : nocase ? {
|
|
1853
|
+
ch: it.ch,
|
|
1854
|
+
re: foldRe(it.ch)
|
|
1855
|
+
} : { ch: it.ch };
|
|
1856
|
+
for (const it of items) {
|
|
1857
|
+
const l = lit(it);
|
|
1858
|
+
if (!l) break;
|
|
1859
|
+
this.#prefix.push(l);
|
|
1823
1860
|
}
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
hasMagic = true;
|
|
1829
|
-
continue;
|
|
1830
|
-
} else inStar = false;
|
|
1831
|
-
if (c === "\\") {
|
|
1832
|
-
if (i === glob.length - 1) re += "\\\\";
|
|
1833
|
-
else escaping = true;
|
|
1834
|
-
continue;
|
|
1861
|
+
for (let j = items.length - 1; j >= 0; j--) {
|
|
1862
|
+
const l = lit(items[j]);
|
|
1863
|
+
if (!l) break;
|
|
1864
|
+
this.#suffix.unshift(l);
|
|
1835
1865
|
}
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
uflag = uflag || needUflag;
|
|
1841
|
-
i += consumed - 1;
|
|
1842
|
-
hasMagic = hasMagic || magic;
|
|
1843
|
-
continue;
|
|
1844
|
-
}
|
|
1866
|
+
this.#affix = !!(this.#prefix.length || this.#suffix.length);
|
|
1867
|
+
if (!nocase) {
|
|
1868
|
+
this.#prefixStr = this.#prefix.map((l) => l.ch).join("");
|
|
1869
|
+
this.#suffixStr = this.#suffix.map((l) => l.ch).join("");
|
|
1845
1870
|
}
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1871
|
+
this.#linear = linear(this.#start)?.slice(this.#prefix.length, -this.#suffix.length || void 0);
|
|
1872
|
+
this.#wild = !!this.#linear?.every((n) => n.t === "star" || n.t === "any");
|
|
1873
|
+
const [min, max] = lengths(items);
|
|
1874
|
+
this.#min = min;
|
|
1875
|
+
this.#max = max;
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
test(s) {
|
|
1879
|
+
if (this.#form) {
|
|
1880
|
+
noSlash(s);
|
|
1881
|
+
return this.#test(s.normalize(this.#form));
|
|
1882
|
+
}
|
|
1883
|
+
if (slashOrSurrogate.test(s)) {
|
|
1884
|
+
noSlash(s);
|
|
1885
|
+
return this.#test(s, [...s]);
|
|
1886
|
+
}
|
|
1887
|
+
return this.#test(s, s);
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* The same as {@link Matcher#test}, but the string is not checked
|
|
1891
|
+
* for `/` chars, so the result for a string that has one is not
|
|
1892
|
+
* defined. Only use it for a string that is known to be one path
|
|
1893
|
+
* portion, such as a part of a path that was split on `/`. It can
|
|
1894
|
+
* be faster, because some patterns do not need to look at each char
|
|
1895
|
+
* of the string.
|
|
1896
|
+
*/
|
|
1897
|
+
testUnchecked(s) {
|
|
1898
|
+
return this.#test(this.#form ? s.normalize(this.#form) : s);
|
|
1899
|
+
}
|
|
1900
|
+
#test(s, chars) {
|
|
1901
|
+
if (this.#literal !== void 0) return this.#literalFold ? (this.#literalRe ??= newFoldRe(this.#literal)).test(s) : s === this.#literal;
|
|
1902
|
+
const min = this.#min;
|
|
1903
|
+
const max = this.#max;
|
|
1904
|
+
if (chars === void 0) {
|
|
1905
|
+
const most = s.length;
|
|
1906
|
+
const least = most + 1 >> 1;
|
|
1907
|
+
if (most < min || least > max) return false;
|
|
1908
|
+
if (least < min || most > max) chars = codePoints(s);
|
|
1909
|
+
}
|
|
1910
|
+
if (chars !== void 0 && (chars.length < min || chars.length > max)) return false;
|
|
1911
|
+
const prefix = this.#prefix.length;
|
|
1912
|
+
if (this.#affix) {
|
|
1913
|
+
if (this.#prefixStr !== void 0 && this.#suffixStr !== void 0) {
|
|
1914
|
+
if (!s.startsWith(this.#prefixStr) || !s.endsWith(this.#suffixStr)) return false;
|
|
1915
|
+
} else {
|
|
1916
|
+
chars ??= codePoints(s);
|
|
1917
|
+
const end = chars.length - this.#suffix.length;
|
|
1918
|
+
if (!hasAffix(this.#prefix, chars, 0) || !hasAffix(this.#suffix, chars, end)) return false;
|
|
1850
1919
|
}
|
|
1851
|
-
re += regExpEscape$1(c);
|
|
1852
1920
|
}
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1921
|
+
const dotStart = !this.options.dot && s.startsWith(".");
|
|
1922
|
+
if (this.#linear) {
|
|
1923
|
+
if (s === "." || s === "..") return false;
|
|
1924
|
+
if (dotStart && !prefix) return false;
|
|
1925
|
+
if (this.#wild) return true;
|
|
1926
|
+
chars ??= codePoints(s);
|
|
1927
|
+
const end = chars.length - this.#suffix.length;
|
|
1928
|
+
return testLinear(this.#linear, chars, prefix, end);
|
|
1929
|
+
}
|
|
1930
|
+
chars ??= codePoints(s);
|
|
1931
|
+
if (s === "." || s === "..") {
|
|
1932
|
+
this.#marks ??= marks(this.#size);
|
|
1933
|
+
const sim = this.#dotsSim ??= new Sim(true, false, this.#marks);
|
|
1934
|
+
const start = sim.state();
|
|
1935
|
+
sim.add(start, this.#start, 0, true);
|
|
1936
|
+
let state = sim.done(start);
|
|
1937
|
+
for (let i = 0; i < chars.length; i++) state = sim.step(state, chars[i], i, true);
|
|
1938
|
+
return state.match;
|
|
1939
|
+
}
|
|
1940
|
+
this.#marks ??= marks(this.#size);
|
|
1941
|
+
const dfa = this.#dfa ??= new Dfa(this.#start, this.#marks);
|
|
1942
|
+
let d = dfa.start(dotStart);
|
|
1943
|
+
const str = chars === s;
|
|
1944
|
+
for (let i = 0; i < chars.length; i++) {
|
|
1945
|
+
if (d.dead) return false;
|
|
1946
|
+
const code = str ? s.charCodeAt(i) : chars[i].charCodeAt(0);
|
|
1947
|
+
d = d.ascii?.[code] ?? dfa.next(d, chars[i]);
|
|
1948
|
+
}
|
|
1949
|
+
return d.match;
|
|
1950
|
+
}
|
|
1951
|
+
/** a readable listing of the state machine */
|
|
1952
|
+
toString() {
|
|
1953
|
+
return show(this.#start);
|
|
1859
1954
|
}
|
|
1860
1955
|
};
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1956
|
+
// ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
1957
|
+
const MAX_PATTERN_LENGTH = 65536;
|
|
1958
|
+
const assertValidPattern = (pattern) => {
|
|
1959
|
+
if (typeof pattern !== "string") throw new TypeError("invalid pattern");
|
|
1960
|
+
if (pattern.length > MAX_PATTERN_LENGTH) throw new TypeError("pattern is too long");
|
|
1961
|
+
};
|
|
1962
|
+
// ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/escape.js
|
|
1864
1963
|
/**
|
|
1865
1964
|
* Escape all magic characters in a glob pattern.
|
|
1866
1965
|
*
|
|
@@ -1872,68 +1971,154 @@ _a = AST;
|
|
|
1872
1971
|
*
|
|
1873
1972
|
* If the {@link MinimatchOptions.magicalBraces} option is used,
|
|
1874
1973
|
* then braces (`{` and `}`) will be escaped.
|
|
1974
|
+
*
|
|
1975
|
+
* A leading `#` or `!` is escaped as well, so that the result is never a
|
|
1976
|
+
* comment or a negated pattern. In `windowsPathsNoEscape` mode, a leading
|
|
1977
|
+
* `!` is written as `@(!)`, because `[!` starts a negated class.
|
|
1875
1978
|
*/
|
|
1876
1979
|
const escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
|
|
1877
|
-
|
|
1878
|
-
|
|
1980
|
+
const e = magicalBraces ? windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&") : windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
1981
|
+
const c = e.charAt(0);
|
|
1982
|
+
if (c === "#") return (windowsPathsNoEscape ? "[#]" : "\\#") + e.slice(1);
|
|
1983
|
+
if (c === "!") return (windowsPathsNoEscape ? "@(!)" : "\\!") + e.slice(1);
|
|
1984
|
+
return e;
|
|
1879
1985
|
};
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
}
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
const
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
const qmarksTestNocase = ([$0, ext = ""]) => {
|
|
1908
|
-
const noext = qmarksTestNoExt([$0]);
|
|
1909
|
-
if (!ext) return noext;
|
|
1910
|
-
ext = ext.toLowerCase();
|
|
1911
|
-
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
1986
|
+
// ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/unescape.js
|
|
1987
|
+
/**
|
|
1988
|
+
* Un-escape a string that has been escaped with {@link escape}.
|
|
1989
|
+
*
|
|
1990
|
+
* If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
|
|
1991
|
+
* square-bracket escapes are removed, but not backslash escapes.
|
|
1992
|
+
*
|
|
1993
|
+
* For example, it will turn the string `'[*]'` into `*`, but it will not
|
|
1994
|
+
* turn `'\\*'` into `'*'`, because `\` is a path separator in
|
|
1995
|
+
* `windowsPathsNoEscape` mode.
|
|
1996
|
+
*
|
|
1997
|
+
* When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
|
|
1998
|
+
* backslash escapes are removed.
|
|
1999
|
+
*
|
|
2000
|
+
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
|
|
2001
|
+
* or unescaped.
|
|
2002
|
+
*
|
|
2003
|
+
* When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
|
|
2004
|
+
* unescaped.
|
|
2005
|
+
*/
|
|
2006
|
+
const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
|
|
2007
|
+
if (windowsPathsNoEscape && s.startsWith("@(!)")) return "!" + unescape(s.slice(4), {
|
|
2008
|
+
windowsPathsNoEscape,
|
|
2009
|
+
magicalBraces
|
|
2010
|
+
});
|
|
2011
|
+
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
|
|
2012
|
+
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
|
|
1912
2013
|
};
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
2014
|
+
// ../../node_modules/.pnpm/minimatch@11.0.9/node_modules/minimatch/dist/esm/index.js
|
|
2015
|
+
const DEFAULT_BRACE_EXPAND_MAX = 1e5;
|
|
2016
|
+
const DEFAULT_GLOB_STAR_RECURSION_MAX = 200;
|
|
2017
|
+
const AWE_KEY = "allowWindowsEscape";
|
|
2018
|
+
const minimatch = (p, pattern, options) => {
|
|
2019
|
+
assertValidPattern(pattern);
|
|
2020
|
+
if (!options?.nocomment && pattern.charAt(0) === "#") return false;
|
|
2021
|
+
return cachedMinimatch(pattern, options).match(p);
|
|
1918
2022
|
};
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
2023
|
+
let cache = /* @__PURE__ */ new Map();
|
|
2024
|
+
let oldCache = /* @__PURE__ */ new Map();
|
|
2025
|
+
let cacheSize = 0;
|
|
2026
|
+
let cacheTotalWeight = 0;
|
|
2027
|
+
const cacheMax = 256;
|
|
2028
|
+
const cacheMaxWeight = 32768;
|
|
2029
|
+
const cacheMaxEntryWeight = 4096;
|
|
2030
|
+
const cacheWeight = (mm) => {
|
|
2031
|
+
let w = mm.pattern.length;
|
|
2032
|
+
for (const s of mm.globSet) {
|
|
2033
|
+
w += s.length + 1;
|
|
2034
|
+
if (w > cacheMaxEntryWeight) break;
|
|
2035
|
+
}
|
|
2036
|
+
return w;
|
|
1922
2037
|
};
|
|
1923
|
-
const
|
|
1924
|
-
|
|
1925
|
-
|
|
2038
|
+
const tri = (v) => v === void 0 ? 0 : v ? 2 : 1;
|
|
2039
|
+
const booleanWeights = new Map(Object.keys({
|
|
2040
|
+
nobrace: 0,
|
|
2041
|
+
nocomment: 0,
|
|
2042
|
+
nonegate: 0,
|
|
2043
|
+
noglobstar: 0,
|
|
2044
|
+
noext: 0,
|
|
2045
|
+
nonull: 0,
|
|
2046
|
+
partial: 0,
|
|
2047
|
+
dot: 0,
|
|
2048
|
+
nocase: 0,
|
|
2049
|
+
nocaseMagicOnly: 0,
|
|
2050
|
+
magicalBraces: 0,
|
|
2051
|
+
matchBase: 0,
|
|
2052
|
+
flipNegate: 0,
|
|
2053
|
+
preserveMultipleSlashes: 0,
|
|
2054
|
+
windowsNoMagicRoot: 0
|
|
2055
|
+
}).map((k, i) => [k, 24 * 3 ** i]));
|
|
2056
|
+
const optionsKey = (o) => {
|
|
2057
|
+
let n = 0;
|
|
2058
|
+
let wpe = false;
|
|
2059
|
+
for (const k in o) {
|
|
2060
|
+
const v = o[k];
|
|
2061
|
+
switch (k) {
|
|
2062
|
+
case "windowsPathsNoEscape":
|
|
2063
|
+
if (v) wpe = true;
|
|
2064
|
+
break;
|
|
2065
|
+
case AWE_KEY:
|
|
2066
|
+
if (v === false) wpe = true;
|
|
2067
|
+
break;
|
|
2068
|
+
case "platform": {
|
|
2069
|
+
const p = v || defaultPlatform;
|
|
2070
|
+
if (p === defaultPlatform) break;
|
|
2071
|
+
if (p === "darwin") n += 3;
|
|
2072
|
+
else if (p === "win32") n += 6;
|
|
2073
|
+
else if (p === "linux") n += 9;
|
|
2074
|
+
else return JSON.stringify(o);
|
|
2075
|
+
break;
|
|
2076
|
+
}
|
|
2077
|
+
case "optimizationLevel":
|
|
2078
|
+
if (v === void 0) break;
|
|
2079
|
+
n += v >= 2 ? 1 : v >= 1 ? 0 : 2;
|
|
2080
|
+
break;
|
|
2081
|
+
case "braceExpandMax":
|
|
2082
|
+
if (v !== void 0 && v !== DEFAULT_BRACE_EXPAND_MAX) return JSON.stringify(o);
|
|
2083
|
+
break;
|
|
2084
|
+
case "maxGlobstarRecursion":
|
|
2085
|
+
if (v !== void 0 && v !== DEFAULT_GLOB_STAR_RECURSION_MAX) return JSON.stringify(o);
|
|
2086
|
+
break;
|
|
2087
|
+
case "normalize":
|
|
2088
|
+
if (v !== void 0) return JSON.stringify(o);
|
|
2089
|
+
break;
|
|
2090
|
+
default: n += (booleanWeights.get(k) ?? 0) * tri(v);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
return wpe ? n + 12 : n;
|
|
1926
2094
|
};
|
|
1927
|
-
const
|
|
1928
|
-
const
|
|
1929
|
-
|
|
2095
|
+
const copyOptions = (o) => {
|
|
2096
|
+
const copy = {};
|
|
2097
|
+
for (const k in o) copy[k] = o[k];
|
|
2098
|
+
return copy;
|
|
1930
2099
|
};
|
|
1931
|
-
const
|
|
1932
|
-
const
|
|
1933
|
-
|
|
2100
|
+
const cachedMinimatch = (pattern, options) => {
|
|
2101
|
+
const key = options ? optionsKey(options) : 0;
|
|
2102
|
+
let mm = cache.get(key)?.get(pattern);
|
|
2103
|
+
if (mm) return mm;
|
|
2104
|
+
mm = oldCache.get(key)?.get(pattern) ?? new Minimatch(pattern, copyOptions(options));
|
|
2105
|
+
const weight = cacheWeight(mm);
|
|
2106
|
+
if (weight > cacheMaxEntryWeight) return mm;
|
|
2107
|
+
if (cacheSize >= cacheMax || cacheTotalWeight + weight > cacheMaxWeight) {
|
|
2108
|
+
oldCache = cache;
|
|
2109
|
+
cache = /* @__PURE__ */ new Map();
|
|
2110
|
+
cacheSize = 0;
|
|
2111
|
+
cacheTotalWeight = 0;
|
|
2112
|
+
}
|
|
2113
|
+
let byPattern = cache.get(key);
|
|
2114
|
+
if (!byPattern) cache.set(key, byPattern = /* @__PURE__ */ new Map());
|
|
2115
|
+
byPattern.set(pattern, mm);
|
|
2116
|
+
cacheSize++;
|
|
2117
|
+
cacheTotalWeight += weight;
|
|
2118
|
+
return mm;
|
|
1934
2119
|
};
|
|
1935
2120
|
/* c8 ignore start */
|
|
1936
|
-
const defaultPlatform = typeof process === "object" && process ?
|
|
2121
|
+
const defaultPlatform = typeof process === "object" && process ? process.env?.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
1937
2122
|
const path = {
|
|
1938
2123
|
win32: { sep: "\\" },
|
|
1939
2124
|
posix: { sep: "/" }
|
|
@@ -1941,10 +2126,10 @@ const path = {
|
|
|
1941
2126
|
minimatch.sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
1942
2127
|
const GLOBSTAR = Symbol("globstar **");
|
|
1943
2128
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
1944
|
-
const
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
2129
|
+
const filter = (pattern, options) => {
|
|
2130
|
+
let mm;
|
|
2131
|
+
return (p) => (mm ??= cachedMinimatch(pattern, options)).match(p);
|
|
2132
|
+
};
|
|
1948
2133
|
minimatch.filter = filter;
|
|
1949
2134
|
const ext = (a, b = {}) => Object.assign({}, a, b);
|
|
1950
2135
|
const defaults = (def) => {
|
|
@@ -1960,21 +2145,10 @@ const defaults = (def) => {
|
|
|
1960
2145
|
return orig.defaults(ext(def, options)).Minimatch;
|
|
1961
2146
|
}
|
|
1962
2147
|
},
|
|
1963
|
-
AST: class AST extends orig.AST {
|
|
1964
|
-
/* c8 ignore start */
|
|
1965
|
-
constructor(type, parent, options = {}) {
|
|
1966
|
-
super(type, parent, ext(def, options));
|
|
1967
|
-
}
|
|
1968
|
-
/* c8 ignore stop */
|
|
1969
|
-
static fromGlob(pattern, options = {}) {
|
|
1970
|
-
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
1971
|
-
}
|
|
1972
|
-
},
|
|
1973
2148
|
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
1974
2149
|
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
1975
2150
|
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
1976
2151
|
defaults: (options) => orig.defaults(ext(def, options)),
|
|
1977
|
-
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
1978
2152
|
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
1979
2153
|
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
1980
2154
|
sep: orig.sep,
|
|
@@ -1985,11 +2159,27 @@ minimatch.defaults = defaults;
|
|
|
1985
2159
|
const braceExpand = (pattern, options = {}) => {
|
|
1986
2160
|
assertValidPattern(pattern);
|
|
1987
2161
|
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [pattern];
|
|
1988
|
-
|
|
2162
|
+
let p = pattern.replace(/\\\\/g, "\\\\\\\\");
|
|
2163
|
+
if (options.windowsPathsNoEscape || options[AWE_KEY] === false) p = p.replace(/\[([{}])\]/g, "[\\$1]");
|
|
2164
|
+
return expand(p, { max: options.braceExpandMax });
|
|
1989
2165
|
};
|
|
1990
2166
|
minimatch.braceExpand = braceExpand;
|
|
1991
|
-
const
|
|
1992
|
-
|
|
2167
|
+
const RANGE_MIN = 100;
|
|
2168
|
+
const rangeRe = /(?<![\\$])\{(-?\d+)\.\.(-?\d+)\}/g;
|
|
2169
|
+
const inRepeatOrNegExt = (portion, mark) => {
|
|
2170
|
+
const stack = [];
|
|
2171
|
+
for (let i = 0; i < portion.length; i++) {
|
|
2172
|
+
const c = portion.charAt(i);
|
|
2173
|
+
if (c === "\\") i++;
|
|
2174
|
+
else if (c === mark) {
|
|
2175
|
+
if (stack.some((t) => t !== "@" && t !== "?")) return true;
|
|
2176
|
+
} else if (portion.charAt(i + 1) === "(" && "!?+*@".includes(c)) {
|
|
2177
|
+
stack.push(c);
|
|
2178
|
+
i++;
|
|
2179
|
+
} else if (c === ")") stack.pop();
|
|
2180
|
+
}
|
|
2181
|
+
return false;
|
|
2182
|
+
};
|
|
1993
2183
|
const match = (list, pattern, options = {}) => {
|
|
1994
2184
|
const mm = new Minimatch(pattern, options);
|
|
1995
2185
|
list = list.filter((f) => mm.match(f));
|
|
@@ -1998,7 +2188,114 @@ const match = (list, pattern, options = {}) => {
|
|
|
1998
2188
|
};
|
|
1999
2189
|
minimatch.match = match;
|
|
2000
2190
|
const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
2001
|
-
const
|
|
2191
|
+
const classEnd = (pattern, start) => {
|
|
2192
|
+
let i = start + 1;
|
|
2193
|
+
if (pattern.charAt(i) === "!" || pattern.charAt(i) === "^") i++;
|
|
2194
|
+
let sawStart = false;
|
|
2195
|
+
for (; i < pattern.length; i++) {
|
|
2196
|
+
const c = pattern.charAt(i);
|
|
2197
|
+
if (c === "]" && sawStart) return i;
|
|
2198
|
+
sawStart = true;
|
|
2199
|
+
if (c === "\\") i++;
|
|
2200
|
+
}
|
|
2201
|
+
return -1;
|
|
2202
|
+
};
|
|
2203
|
+
const literal = (pattern, noext) => {
|
|
2204
|
+
if (!noext && (pattern === "+()" || pattern === "@()")) return pattern;
|
|
2205
|
+
let lit = "";
|
|
2206
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
2207
|
+
const c = pattern.charAt(i);
|
|
2208
|
+
if (c === "\\") lit += pattern.charAt(++i) || c;
|
|
2209
|
+
else if (c === "*" || c === "?") return;
|
|
2210
|
+
else if (c === "[") {
|
|
2211
|
+
const close = classEnd(pattern, i);
|
|
2212
|
+
if (close === -1) {
|
|
2213
|
+
lit += c;
|
|
2214
|
+
continue;
|
|
2215
|
+
}
|
|
2216
|
+
let body = pattern.slice(i + 1, close);
|
|
2217
|
+
if (body.startsWith("\\")) body = body.slice(1);
|
|
2218
|
+
if ([...body].length !== 1 || "!^".includes(pattern.charAt(i + 1))) return;
|
|
2219
|
+
lit += body;
|
|
2220
|
+
i = close;
|
|
2221
|
+
} else if (!noext && "+@!".includes(c) && pattern.charAt(i + 1) === "(" && pattern.includes(")", i + 2)) return;
|
|
2222
|
+
else lit += c;
|
|
2223
|
+
}
|
|
2224
|
+
return lit;
|
|
2225
|
+
};
|
|
2226
|
+
const MAX_EXTGLOBS = 256;
|
|
2227
|
+
const extglobCount = (pattern) => {
|
|
2228
|
+
let n = 0;
|
|
2229
|
+
for (let i = 0; i < pattern.length - 1; i++) {
|
|
2230
|
+
const c = pattern.charAt(i);
|
|
2231
|
+
if (c === "\\") i++;
|
|
2232
|
+
else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
|
|
2233
|
+
n++;
|
|
2234
|
+
i++;
|
|
2235
|
+
}
|
|
2236
|
+
}
|
|
2237
|
+
return n;
|
|
2238
|
+
};
|
|
2239
|
+
const assertValidExtglobs = (pattern) => {
|
|
2240
|
+
if (extglobCount(pattern) > MAX_EXTGLOBS) throw new TypeError("pattern has too many extglobs");
|
|
2241
|
+
};
|
|
2242
|
+
const extSafe = (pattern) => {
|
|
2243
|
+
if (/^[?*+@]\(\)$/.test(pattern) || pattern.includes("[:")) return false;
|
|
2244
|
+
let depth = 0;
|
|
2245
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
2246
|
+
const c = pattern.charAt(i);
|
|
2247
|
+
if (c === "\\") {
|
|
2248
|
+
if (++i === pattern.length) return false;
|
|
2249
|
+
} else if (c === "[") {
|
|
2250
|
+
const close = classEnd(pattern, i);
|
|
2251
|
+
if (close !== -1) i = close;
|
|
2252
|
+
} else if ("+@!?*".includes(c) && pattern.charAt(i + 1) === "(") {
|
|
2253
|
+
depth++;
|
|
2254
|
+
i++;
|
|
2255
|
+
} else if (c === ")") {
|
|
2256
|
+
if (!depth--) return false;
|
|
2257
|
+
} else if (c === "|" && !depth) return false;
|
|
2258
|
+
}
|
|
2259
|
+
return !depth;
|
|
2260
|
+
};
|
|
2261
|
+
let lastSplit;
|
|
2262
|
+
let lastChecked;
|
|
2263
|
+
const portionMatch = (p, f) => typeof p === "string" ? f === p : f !== "" && p.testUnchecked(f);
|
|
2264
|
+
const endIndex = (p, last, lastStart, prev, prevStart) => portionMatch(p, last) ? lastStart : prev !== void 0 && portionMatch(p, prev) ? prevStart : -1;
|
|
2265
|
+
const isDots = (p) => p === "." || p === "..";
|
|
2266
|
+
const isDrive = (p) => typeof p === "string" && /^[a-z]:$/i.test(p);
|
|
2267
|
+
const isLongUNC = (p) => typeof p === "string" && /^unc$/i.test(p);
|
|
2268
|
+
const uncHost = (p) => {
|
|
2269
|
+
if (p[0] !== "" || p[1] !== "") return -1;
|
|
2270
|
+
const h = p[2] !== "?" ? 2 : isLongUNC(p[3]) ? 4 : -1;
|
|
2271
|
+
const host = p[h];
|
|
2272
|
+
const share = p[h + 1];
|
|
2273
|
+
return h !== -1 && host !== void 0 && host !== "" && host !== GLOBSTAR && share !== void 0 && share !== "" && share !== GLOBSTAR ? h : -1;
|
|
2274
|
+
};
|
|
2275
|
+
const walkable = (p, dot) => !isDots(p) && (dot || !p.startsWith("."));
|
|
2276
|
+
const dotPortion = (f, start, end, dot, sep) => {
|
|
2277
|
+
for (let k = start; k < end;) {
|
|
2278
|
+
if (f.charCodeAt(k) === 46) {
|
|
2279
|
+
if (!dot) return true;
|
|
2280
|
+
const n = f.charCodeAt(k + 1) === 46 ? k + 2 : k + 1;
|
|
2281
|
+
if (n >= end || isSep(f.charCodeAt(n), sep)) return true;
|
|
2282
|
+
}
|
|
2283
|
+
const s = nextSep(f, k, sep);
|
|
2284
|
+
if (s === -1) return false;
|
|
2285
|
+
k = s + 1;
|
|
2286
|
+
while (k < end && isSep(f.charCodeAt(k), sep)) k++;
|
|
2287
|
+
}
|
|
2288
|
+
return false;
|
|
2289
|
+
};
|
|
2290
|
+
const isSep = (c, sep) => sep === "/" ? c === 47 : sep === "\\" ? c === 92 : c === 47 || c === 92;
|
|
2291
|
+
const nextSep = (f, from, sep) => {
|
|
2292
|
+
if (sep !== "both") return f.indexOf(sep, from);
|
|
2293
|
+
const s = f.indexOf("/", from);
|
|
2294
|
+
const b = f.indexOf("\\", from);
|
|
2295
|
+
return s === -1 ? b : b === -1 ? s : Math.min(s, b);
|
|
2296
|
+
};
|
|
2297
|
+
const lastSep = (f, from, sep) => sep !== "both" ? f.lastIndexOf(sep, from) : Math.max(f.lastIndexOf("/", from), f.lastIndexOf("\\", from));
|
|
2298
|
+
const PENDING = {};
|
|
2002
2299
|
var Minimatch = class {
|
|
2003
2300
|
options;
|
|
2004
2301
|
set;
|
|
@@ -2017,20 +2314,28 @@ var Minimatch = class {
|
|
|
2017
2314
|
platform;
|
|
2018
2315
|
windowsNoMagicRoot;
|
|
2019
2316
|
maxGlobstarRecursion;
|
|
2020
|
-
|
|
2317
|
+
#endCheck;
|
|
2318
|
+
#literalCheck;
|
|
2319
|
+
#level2;
|
|
2320
|
+
#form;
|
|
2321
|
+
#literals = [];
|
|
2322
|
+
#shapes = [];
|
|
2323
|
+
#endRows = [];
|
|
2324
|
+
#matchers = /* @__PURE__ */ new Map();
|
|
2325
|
+
#pending = false;
|
|
2326
|
+
#rangeMark;
|
|
2327
|
+
#globstarParts = /* @__PURE__ */ new WeakMap();
|
|
2021
2328
|
constructor(pattern, options = {}) {
|
|
2022
2329
|
assertValidPattern(pattern);
|
|
2023
2330
|
options = options || {};
|
|
2024
2331
|
this.options = options;
|
|
2025
|
-
this.maxGlobstarRecursion = options.maxGlobstarRecursion ??
|
|
2332
|
+
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? DEFAULT_GLOB_STAR_RECURSION_MAX;
|
|
2026
2333
|
this.pattern = pattern;
|
|
2027
2334
|
this.platform = options.platform || defaultPlatform;
|
|
2028
2335
|
this.isWindows = this.platform === "win32";
|
|
2029
|
-
|
|
2030
|
-
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
|
|
2336
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[AWE_KEY] === false;
|
|
2031
2337
|
if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, "/");
|
|
2032
2338
|
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
2033
|
-
this.regexp = null;
|
|
2034
2339
|
this.negate = false;
|
|
2035
2340
|
this.nonegate = !!options.nonegate;
|
|
2036
2341
|
this.comment = false;
|
|
@@ -2041,14 +2346,45 @@ var Minimatch = class {
|
|
|
2041
2346
|
this.globSet = [];
|
|
2042
2347
|
this.globParts = [];
|
|
2043
2348
|
this.set = [];
|
|
2349
|
+
this.#endCheck = !this.preserveMultipleSlashes;
|
|
2350
|
+
this.#level2 = (options.optimizationLevel ?? 1) >= 2;
|
|
2351
|
+
const n = options.normalize;
|
|
2352
|
+
this.#form = n === true ? "NFC" : n || void 0;
|
|
2044
2353
|
this.make();
|
|
2354
|
+
const drives = this.set.map((row) => this.#rootIndex(row));
|
|
2355
|
+
this.#endRows = this.set.map((row, r) => this.#endCheck && row.length - 1 > drives[r]);
|
|
2356
|
+
this.#literals = this.set.map((row, r) => {
|
|
2357
|
+
const end = this.#endRows[r] ? row.length - 1 : row.length;
|
|
2358
|
+
const lits = row.slice(drives[r] + 1, end).filter((p) => typeof p === "string" && !!p);
|
|
2359
|
+
return [...new Set(lits)];
|
|
2360
|
+
});
|
|
2361
|
+
this.#literalCheck = this.#literals.some((l) => l.length);
|
|
2362
|
+
this.#shapes = this.set.map((row, r) => {
|
|
2363
|
+
const [p0, p1, p2] = row;
|
|
2364
|
+
if (this.#endRows[r] && row.length === 2) {
|
|
2365
|
+
if (p0 === GLOBSTAR && p1 !== GLOBSTAR) return "tail";
|
|
2366
|
+
}
|
|
2367
|
+
if (this.#endRows[r] && options.matchBase && row.length === 1 && p0 !== GLOBSTAR && p0 !== "") return "base";
|
|
2368
|
+
if (!this.#endCheck || drives[r] !== -1) return void 0;
|
|
2369
|
+
if (row.length === 3 && p0 === GLOBSTAR && p2 === GLOBSTAR && p1 !== GLOBSTAR && p1 !== "" && this.maxGlobstarRecursion > 0) return "mid";
|
|
2370
|
+
if (row.length === 2 && p1 === GLOBSTAR && p0 !== GLOBSTAR && p0 !== "") return "head";
|
|
2371
|
+
});
|
|
2372
|
+
}
|
|
2373
|
+
#norm(p) {
|
|
2374
|
+
return this.#form ? p.normalize(this.#form) : p;
|
|
2375
|
+
}
|
|
2376
|
+
#rootIndex(row) {
|
|
2377
|
+
if (!this.isWindows) return -1;
|
|
2378
|
+
if (isDrive(row[0])) return 0;
|
|
2379
|
+
if (row[0] === "" && row[1] === "" && row[2] === "?" && isDrive(row[3])) return 3;
|
|
2380
|
+
const h = uncHost(row);
|
|
2381
|
+
return h === -1 ? -1 : h + 1;
|
|
2045
2382
|
}
|
|
2046
2383
|
hasMagic() {
|
|
2047
2384
|
if (this.options.magicalBraces && this.set.length > 1) return true;
|
|
2048
2385
|
for (const pattern of this.set) for (const part of pattern) if (typeof part !== "string") return true;
|
|
2049
2386
|
return false;
|
|
2050
2387
|
}
|
|
2051
|
-
debug(..._) {}
|
|
2052
2388
|
make() {
|
|
2053
2389
|
const pattern = this.pattern;
|
|
2054
2390
|
const options = this.options;
|
|
@@ -2061,28 +2397,108 @@ var Minimatch = class {
|
|
|
2061
2397
|
return;
|
|
2062
2398
|
}
|
|
2063
2399
|
this.parseNegate();
|
|
2064
|
-
this.globSet = [...new Set(this
|
|
2065
|
-
|
|
2066
|
-
this.debug(this.pattern, this.globSet);
|
|
2067
|
-
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
2400
|
+
this.globSet = [...new Set(this.#expandBraces())];
|
|
2401
|
+
const rawGlobParts = this.globSet.map((s) => this.#slashSplit(s));
|
|
2068
2402
|
this.globParts = this.preprocess(rawGlobParts);
|
|
2069
|
-
this
|
|
2403
|
+
this.#pending = true;
|
|
2070
2404
|
let set = this.globParts.map((s, _, __) => {
|
|
2071
2405
|
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
2072
|
-
const
|
|
2406
|
+
const n = s[2] === "?" && isLongUNC(s[3]) ? 6 : 4;
|
|
2407
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && s.slice(3, n).every((p) => !globMagic.test(p));
|
|
2073
2408
|
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
2074
|
-
if (isUNC) return [...s.slice(0,
|
|
2075
|
-
else if (isDrive) return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
2409
|
+
if (isUNC) return [...s.slice(0, n).map((p) => this.#norm(p)), ...s.slice(n).map((ss) => this.parse(ss))];
|
|
2410
|
+
else if (isDrive) return [this.#norm(s[0]), ...s.slice(1).map((ss) => this.parse(ss))];
|
|
2076
2411
|
}
|
|
2077
2412
|
return s.map((ss) => this.parse(ss));
|
|
2078
2413
|
});
|
|
2079
|
-
this.debug(this.pattern, set);
|
|
2080
2414
|
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
2081
2415
|
if (this.isWindows) for (let i = 0; i < this.set.length; i++) {
|
|
2082
2416
|
const p = this.set[i];
|
|
2083
|
-
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" &&
|
|
2417
|
+
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && (isDrive(p[3]) || isLongUNC(this.globParts[i][3]))) {
|
|
2418
|
+
if (isLongUNC(this.globParts[i][3])) p[3] = "UNC";
|
|
2419
|
+
p[2] = "?";
|
|
2420
|
+
}
|
|
2084
2421
|
}
|
|
2085
|
-
|
|
2422
|
+
if (!options.noext) this.mergeRows();
|
|
2423
|
+
this.#pending = false;
|
|
2424
|
+
this.set.forEach((row, i) => {
|
|
2425
|
+
for (let k = 0; k < row.length; k++) if (row[k] === PENDING) row[k] = this.parse(this.globParts[i][k]);
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
mergeRows() {
|
|
2429
|
+
let merged = true;
|
|
2430
|
+
while (merged) {
|
|
2431
|
+
merged = false;
|
|
2432
|
+
if (this.set.length < 2) return;
|
|
2433
|
+
let keys = this.#mergeKeys();
|
|
2434
|
+
const len = Math.max(0, ...this.set.map((r) => r.length));
|
|
2435
|
+
for (let k = 0; k < len; k++) {
|
|
2436
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2437
|
+
const R = this.set.length + 1;
|
|
2438
|
+
this.set.forEach((row, i) => {
|
|
2439
|
+
if (!(row[k] instanceof Matcher || row[k] === PENDING) || !extSafe(this.globParts[i][k])) return;
|
|
2440
|
+
const { pre, suf } = keys[i];
|
|
2441
|
+
const key = pre[k] * R + suf[k + 1];
|
|
2442
|
+
const g = groups.get(key);
|
|
2443
|
+
if (g) g.push(i);
|
|
2444
|
+
else groups.set(key, [i]);
|
|
2445
|
+
});
|
|
2446
|
+
const drop = /* @__PURE__ */ new Set();
|
|
2447
|
+
for (const g of groups.values()) {
|
|
2448
|
+
if (g.length < 2) continue;
|
|
2449
|
+
const [first, ...rest] = g;
|
|
2450
|
+
const glob = `@(${g.map((i) => this.globParts[i][k]).join("|")})`;
|
|
2451
|
+
if (extglobCount(glob) > MAX_EXTGLOBS) continue;
|
|
2452
|
+
this.globParts[first][k] = glob;
|
|
2453
|
+
this.set[first][k] = this.parse(glob);
|
|
2454
|
+
for (const i of rest) drop.add(i);
|
|
2455
|
+
}
|
|
2456
|
+
if (drop.size) {
|
|
2457
|
+
merged = true;
|
|
2458
|
+
this.set = this.set.filter((_, i) => !drop.has(i));
|
|
2459
|
+
this.globParts = this.globParts.filter((_, i) => !drop.has(i));
|
|
2460
|
+
if (this.set.length < 2) return;
|
|
2461
|
+
keys = this.#mergeKeys();
|
|
2462
|
+
}
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
#mergeKeys() {
|
|
2467
|
+
const partIds = /* @__PURE__ */ new Map();
|
|
2468
|
+
const ids = this.globParts.map((parts) => parts.map((s) => {
|
|
2469
|
+
let id = partIds.get(s);
|
|
2470
|
+
if (id === void 0) partIds.set(s, id = partIds.size);
|
|
2471
|
+
return id;
|
|
2472
|
+
}));
|
|
2473
|
+
const P = partIds.size;
|
|
2474
|
+
const len = Math.max(0, ...ids.map((r) => r.length));
|
|
2475
|
+
const keys = ids.map((r) => ({
|
|
2476
|
+
pre: [0],
|
|
2477
|
+
suf: new Array(r.length + 1).fill(0)
|
|
2478
|
+
}));
|
|
2479
|
+
for (let k = 0; k < len; k++) {
|
|
2480
|
+
const m = /* @__PURE__ */ new Map();
|
|
2481
|
+
ids.forEach((r, i) => {
|
|
2482
|
+
if (k >= r.length) return;
|
|
2483
|
+
const { pre } = keys[i];
|
|
2484
|
+
const key = pre[k] * P + r[k];
|
|
2485
|
+
let id = m.get(key);
|
|
2486
|
+
if (id === void 0) m.set(key, id = m.size + 1);
|
|
2487
|
+
pre.push(id);
|
|
2488
|
+
});
|
|
2489
|
+
}
|
|
2490
|
+
for (let k = len - 1; k >= 0; k--) {
|
|
2491
|
+
const m = /* @__PURE__ */ new Map();
|
|
2492
|
+
ids.forEach((r, i) => {
|
|
2493
|
+
if (k >= r.length) return;
|
|
2494
|
+
const { suf } = keys[i];
|
|
2495
|
+
const key = suf[k + 1] * P + r[k];
|
|
2496
|
+
let id = m.get(key);
|
|
2497
|
+
if (id === void 0) m.set(key, id = m.size + 1);
|
|
2498
|
+
suf[k] = id;
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
return keys;
|
|
2086
2502
|
}
|
|
2087
2503
|
preprocess(globParts) {
|
|
2088
2504
|
if (this.options.noglobstar) {
|
|
@@ -2109,11 +2525,12 @@ var Minimatch = class {
|
|
|
2109
2525
|
}
|
|
2110
2526
|
levelOneOptimize(globParts) {
|
|
2111
2527
|
return globParts.map((parts) => {
|
|
2528
|
+
const root = this.#rootIndex(parts) + 1;
|
|
2112
2529
|
parts = parts.reduce((set, part) => {
|
|
2113
2530
|
const prev = set[set.length - 1];
|
|
2114
2531
|
if (part === "**" && prev === "**") return set;
|
|
2115
2532
|
if (part === "..") {
|
|
2116
|
-
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
2533
|
+
if (set.length > root && prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
2117
2534
|
set.pop();
|
|
2118
2535
|
return set;
|
|
2119
2536
|
}
|
|
@@ -2124,8 +2541,120 @@ var Minimatch = class {
|
|
|
2124
2541
|
return parts.length === 0 ? [""] : parts;
|
|
2125
2542
|
});
|
|
2126
2543
|
}
|
|
2127
|
-
|
|
2128
|
-
|
|
2544
|
+
#canMatch(f) {
|
|
2545
|
+
const sep = !this.isWindows || !f.includes("\\") ? "/" : f.includes("/") ? "both" : "\\";
|
|
2546
|
+
let ends = this.#endCheck ? 0 : -1;
|
|
2547
|
+
let last = "";
|
|
2548
|
+
let lastStart = 0;
|
|
2549
|
+
let prev;
|
|
2550
|
+
let prevStart = 0;
|
|
2551
|
+
const dot = !!this.options.dot;
|
|
2552
|
+
ROWS: for (let r = 0; r < this.set.length; r++) {
|
|
2553
|
+
const row = this.set[r];
|
|
2554
|
+
const p = row[row.length - 1];
|
|
2555
|
+
let end = ends !== -1 && this.#endRows[r] && p !== GLOBSTAR;
|
|
2556
|
+
if (end && ends === 0) {
|
|
2557
|
+
const i = lastSep(f, f.length, sep);
|
|
2558
|
+
lastStart = i + 1;
|
|
2559
|
+
last = f.slice(lastStart);
|
|
2560
|
+
if (last === "" && i >= 0) {
|
|
2561
|
+
let j = i;
|
|
2562
|
+
while (j > 0 && isSep(f.charCodeAt(j - 1), sep)) j--;
|
|
2563
|
+
prevStart = j === 0 ? 0 : lastSep(f, j - 1, sep) + 1;
|
|
2564
|
+
prev = f.slice(prevStart, j);
|
|
2565
|
+
}
|
|
2566
|
+
const resolves = this.#level2 && (isDots(last) || last === "" && prev !== void 0 && isDots(prev));
|
|
2567
|
+
ends = resolves ? -1 : 1;
|
|
2568
|
+
end = !resolves;
|
|
2569
|
+
}
|
|
2570
|
+
let tailStart = -1;
|
|
2571
|
+
if (end && typeof p === "string") {
|
|
2572
|
+
tailStart = endIndex(p, last, lastStart, prev, prevStart);
|
|
2573
|
+
if (tailStart === -1) continue;
|
|
2574
|
+
}
|
|
2575
|
+
if (this.#literalCheck) {
|
|
2576
|
+
for (const l of this.#literals[r]) if (!f.includes(l)) continue ROWS;
|
|
2577
|
+
}
|
|
2578
|
+
if (end && typeof p === "object") {
|
|
2579
|
+
tailStart = endIndex(p, last, lastStart, prev, prevStart);
|
|
2580
|
+
if (tailStart === -1) continue;
|
|
2581
|
+
}
|
|
2582
|
+
const shape = this.#shapes[r];
|
|
2583
|
+
if (shape === "base" && end) return "yes";
|
|
2584
|
+
if (shape === "tail" && end) {
|
|
2585
|
+
if (this.#level2 && dotPortion(f, 0, tailStart, true, sep)) return "maybe";
|
|
2586
|
+
if (!dotPortion(f, 0, tailStart, dot, sep)) return "yes";
|
|
2587
|
+
continue;
|
|
2588
|
+
}
|
|
2589
|
+
if (shape === "mid" || shape === "head") {
|
|
2590
|
+
const m = this.#walk(f, row, shape === "head", dot, sep);
|
|
2591
|
+
if (m !== "no") return m;
|
|
2592
|
+
continue;
|
|
2593
|
+
}
|
|
2594
|
+
return "maybe";
|
|
2595
|
+
}
|
|
2596
|
+
return "no";
|
|
2597
|
+
}
|
|
2598
|
+
#matchShape(file, row, shape) {
|
|
2599
|
+
const dot = !!this.options.dot;
|
|
2600
|
+
const n = file.length;
|
|
2601
|
+
if (shape === "head") {
|
|
2602
|
+
if (n < 2 || !portionMatch(row[0], file[0])) return false;
|
|
2603
|
+
for (let i = 1; i < n; i++) if (!walkable(file[i], dot)) return false;
|
|
2604
|
+
return true;
|
|
2605
|
+
}
|
|
2606
|
+
const x = row[1];
|
|
2607
|
+
if (shape === "tail") {
|
|
2608
|
+
let t = n - 1;
|
|
2609
|
+
if (!portionMatch(x, file[t])) {
|
|
2610
|
+
if (file[t] !== "" || n === 1 || !portionMatch(x, file[--t])) return false;
|
|
2611
|
+
}
|
|
2612
|
+
for (let i = 0; i < t; i++) if (!walkable(file[i], dot)) return false;
|
|
2613
|
+
return true;
|
|
2614
|
+
}
|
|
2615
|
+
for (let k = 0; k < n; k++) {
|
|
2616
|
+
if (portionMatch(x, file[k]) && k + 1 < n) {
|
|
2617
|
+
let i = k + 1;
|
|
2618
|
+
while (i < n && walkable(file[i], dot)) i++;
|
|
2619
|
+
if (i === n) return true;
|
|
2620
|
+
}
|
|
2621
|
+
if (!walkable(file[k], dot)) return false;
|
|
2622
|
+
}
|
|
2623
|
+
return false;
|
|
2624
|
+
}
|
|
2625
|
+
#walk(f, row, head, dot, sep) {
|
|
2626
|
+
if (this.#level2 && dotPortion(f, 0, f.length, true, sep)) return "maybe";
|
|
2627
|
+
const x = row[head ? 0 : 1];
|
|
2628
|
+
let s = 0;
|
|
2629
|
+
for (let e = nextSep(f, s, sep); e !== -1; e = nextSep(f, s, sep)) {
|
|
2630
|
+
let next = e + 1;
|
|
2631
|
+
while (next < f.length && isSep(f.charCodeAt(next), sep)) next++;
|
|
2632
|
+
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";
|
|
2633
|
+
if (head || dotPortion(f, s, next, dot, sep)) return "no";
|
|
2634
|
+
s = next;
|
|
2635
|
+
}
|
|
2636
|
+
return "no";
|
|
2637
|
+
}
|
|
2638
|
+
#cachedSplit(f) {
|
|
2639
|
+
const last = lastSplit;
|
|
2640
|
+
return last?.f === f && last.isWindows === this.isWindows && last.preserveMultipleSlashes === this.preserveMultipleSlashes && last.normalize === this.#form ? last : void 0;
|
|
2641
|
+
}
|
|
2642
|
+
#split(f) {
|
|
2643
|
+
const { isWindows, preserveMultipleSlashes } = this;
|
|
2644
|
+
let parts = this.#slashSplit(isWindows ? f.split("\\").join("/") : f);
|
|
2645
|
+
const normalize = this.#form;
|
|
2646
|
+
if (normalize) parts = parts.map((p) => p.normalize(normalize));
|
|
2647
|
+
lastSplit = {
|
|
2648
|
+
f,
|
|
2649
|
+
isWindows,
|
|
2650
|
+
preserveMultipleSlashes,
|
|
2651
|
+
normalize,
|
|
2652
|
+
parts
|
|
2653
|
+
};
|
|
2654
|
+
return lastSplit;
|
|
2655
|
+
}
|
|
2656
|
+
#levelTwoFileOptimize(file) {
|
|
2657
|
+
const parts = [...file];
|
|
2129
2658
|
let didSomething = false;
|
|
2130
2659
|
do {
|
|
2131
2660
|
didSomething = false;
|
|
@@ -2144,19 +2673,23 @@ var Minimatch = class {
|
|
|
2144
2673
|
parts.pop();
|
|
2145
2674
|
}
|
|
2146
2675
|
}
|
|
2147
|
-
|
|
2676
|
+
const root = this.#rootIndex(parts) + 1;
|
|
2677
|
+
let dd = root;
|
|
2148
2678
|
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
2149
2679
|
const p = parts[dd - 1];
|
|
2150
|
-
if (p && p !== "." && p !== ".." && p !== "**"
|
|
2680
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
2151
2681
|
didSomething = true;
|
|
2152
2682
|
parts.splice(dd - 1, 2);
|
|
2153
|
-
dd
|
|
2683
|
+
dd = Math.max(dd - 2, root);
|
|
2154
2684
|
}
|
|
2155
2685
|
}
|
|
2156
2686
|
} while (didSomething);
|
|
2157
2687
|
return parts.length === 0 ? [""] : parts;
|
|
2158
2688
|
}
|
|
2159
2689
|
firstPhasePreProcess(globParts) {
|
|
2690
|
+
const { braceExpandMax = DEFAULT_BRACE_EXPAND_MAX } = this.options;
|
|
2691
|
+
let splitCells = 0;
|
|
2692
|
+
const maxSplitCells = 1e6;
|
|
2160
2693
|
let didSomething = false;
|
|
2161
2694
|
do {
|
|
2162
2695
|
didSomething = false;
|
|
@@ -2171,10 +2704,13 @@ var Minimatch = class {
|
|
|
2171
2704
|
const p2 = parts[gs + 3];
|
|
2172
2705
|
if (next !== "..") continue;
|
|
2173
2706
|
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") continue;
|
|
2707
|
+
const addedCells = parts.length - 1;
|
|
2708
|
+
if (globParts.length >= braceExpandMax || splitCells + addedCells > maxSplitCells) throw new RangeError(`optimizationLevel 2: too many patterns from '**/..'`);
|
|
2174
2709
|
didSomething = true;
|
|
2175
2710
|
parts.splice(gs, 1);
|
|
2176
2711
|
const other = parts.slice(0);
|
|
2177
2712
|
other[gs] = "**";
|
|
2713
|
+
splitCells += addedCells;
|
|
2178
2714
|
globParts.push(other);
|
|
2179
2715
|
gs--;
|
|
2180
2716
|
}
|
|
@@ -2193,7 +2729,8 @@ var Minimatch = class {
|
|
|
2193
2729
|
parts.pop();
|
|
2194
2730
|
}
|
|
2195
2731
|
}
|
|
2196
|
-
|
|
2732
|
+
const root = this.#rootIndex(parts) + 1;
|
|
2733
|
+
let dd = root;
|
|
2197
2734
|
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
2198
2735
|
const p = parts[dd - 1];
|
|
2199
2736
|
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
@@ -2201,7 +2738,7 @@ var Minimatch = class {
|
|
|
2201
2738
|
const splin = dd === 1 && parts[dd + 1] === "**" ? ["."] : [];
|
|
2202
2739
|
parts.splice(dd - 1, 2, ...splin);
|
|
2203
2740
|
if (parts.length === 0) parts.push("");
|
|
2204
|
-
dd
|
|
2741
|
+
dd = Math.max(dd - 2, root);
|
|
2205
2742
|
}
|
|
2206
2743
|
}
|
|
2207
2744
|
}
|
|
@@ -2209,45 +2746,41 @@ var Minimatch = class {
|
|
|
2209
2746
|
return globParts;
|
|
2210
2747
|
}
|
|
2211
2748
|
secondPhasePreProcess(globParts) {
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2749
|
+
const keys = /* @__PURE__ */ new Set();
|
|
2750
|
+
const rows = globParts.filter((parts) => {
|
|
2751
|
+
const key = parts.join("/");
|
|
2752
|
+
if (keys.has(key)) return false;
|
|
2753
|
+
keys.add(key);
|
|
2754
|
+
return true;
|
|
2755
|
+
});
|
|
2756
|
+
const stars = /* @__PURE__ */ new Map();
|
|
2757
|
+
for (const parts of rows) {
|
|
2758
|
+
const s = [];
|
|
2759
|
+
for (let i = 0; i < parts.length; i++) if (parts[i] === "*") s.push(i);
|
|
2760
|
+
if (s.length) stars.set(s.join(","), s);
|
|
2761
|
+
}
|
|
2762
|
+
if (!stars.size || rows.length * stars.size > 1e5) return rows;
|
|
2763
|
+
const { dot } = this.options;
|
|
2764
|
+
return rows.filter((parts) => {
|
|
2765
|
+
for (const s of stars.values()) {
|
|
2766
|
+
if (s[s.length - 1] >= parts.length) continue;
|
|
2767
|
+
const c = [...parts];
|
|
2768
|
+
let ok = true;
|
|
2769
|
+
let changed = false;
|
|
2770
|
+
for (const i of s) {
|
|
2771
|
+
const p = parts[i];
|
|
2772
|
+
if (p === "*") continue;
|
|
2773
|
+
if (!p || p === "**" || !dot && p.startsWith(".")) {
|
|
2774
|
+
ok = false;
|
|
2775
|
+
break;
|
|
2776
|
+
}
|
|
2777
|
+
c[i] = "*";
|
|
2778
|
+
changed = true;
|
|
2779
|
+
}
|
|
2780
|
+
if (ok && changed && keys.has(c.join("/"))) return false;
|
|
2218
2781
|
}
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
}
|
|
2222
|
-
partsMatch(a, b, emptyGSMatch = false) {
|
|
2223
|
-
let ai = 0;
|
|
2224
|
-
let bi = 0;
|
|
2225
|
-
let result = [];
|
|
2226
|
-
let which = "";
|
|
2227
|
-
while (ai < a.length && bi < b.length) if (a[ai] === b[bi]) {
|
|
2228
|
-
result.push(which === "b" ? b[bi] : a[ai]);
|
|
2229
|
-
ai++;
|
|
2230
|
-
bi++;
|
|
2231
|
-
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
|
|
2232
|
-
result.push(a[ai]);
|
|
2233
|
-
ai++;
|
|
2234
|
-
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
|
|
2235
|
-
result.push(b[bi]);
|
|
2236
|
-
bi++;
|
|
2237
|
-
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
2238
|
-
if (which === "b") return false;
|
|
2239
|
-
which = "a";
|
|
2240
|
-
result.push(a[ai]);
|
|
2241
|
-
ai++;
|
|
2242
|
-
bi++;
|
|
2243
|
-
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
2244
|
-
if (which === "a") return false;
|
|
2245
|
-
which = "b";
|
|
2246
|
-
result.push(b[bi]);
|
|
2247
|
-
ai++;
|
|
2248
|
-
bi++;
|
|
2249
|
-
} else return false;
|
|
2250
|
-
return a.length === b.length && result;
|
|
2782
|
+
return true;
|
|
2783
|
+
});
|
|
2251
2784
|
}
|
|
2252
2785
|
parseNegate() {
|
|
2253
2786
|
if (this.nonegate) return;
|
|
@@ -2261,10 +2794,22 @@ var Minimatch = class {
|
|
|
2261
2794
|
if (negateOffset) this.pattern = pattern.slice(negateOffset);
|
|
2262
2795
|
this.negate = negate;
|
|
2263
2796
|
}
|
|
2264
|
-
|
|
2797
|
+
#matchRow(file, resolved, pattern, partial) {
|
|
2265
2798
|
let fileStartIndex = 0;
|
|
2266
2799
|
let patternStartIndex = 0;
|
|
2267
|
-
|
|
2800
|
+
const fh = this.isWindows ? uncHost(resolved) : -1;
|
|
2801
|
+
const ph = fh === -1 ? -1 : uncHost(pattern);
|
|
2802
|
+
if (ph !== -1) {
|
|
2803
|
+
const host = pattern[ph];
|
|
2804
|
+
const share = pattern[ph + 1];
|
|
2805
|
+
if (typeof host !== "string" || typeof share !== "string") {
|
|
2806
|
+
fileStartIndex = fh;
|
|
2807
|
+
patternStartIndex = ph;
|
|
2808
|
+
} else if (resolved[fh].toLowerCase() === host.toLowerCase() && resolved[fh + 1].toLowerCase() === share.toLowerCase()) {
|
|
2809
|
+
fileStartIndex = fh + 2;
|
|
2810
|
+
patternStartIndex = ph + 2;
|
|
2811
|
+
}
|
|
2812
|
+
} else if (this.isWindows) {
|
|
2268
2813
|
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
2269
2814
|
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
2270
2815
|
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
@@ -2274,32 +2819,20 @@ var Minimatch = class {
|
|
|
2274
2819
|
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
2275
2820
|
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
2276
2821
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
fileStartIndex = fdi;
|
|
2822
|
+
patternStartIndex = pdi + 1;
|
|
2823
|
+
fileStartIndex = fdi + 1;
|
|
2280
2824
|
}
|
|
2281
2825
|
}
|
|
2282
2826
|
}
|
|
2283
|
-
|
|
2284
|
-
if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
|
|
2827
|
+
file = resolved;
|
|
2285
2828
|
if (pattern.includes(GLOBSTAR)) return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
2286
2829
|
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
2287
2830
|
}
|
|
2288
2831
|
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
|
2289
|
-
const
|
|
2290
|
-
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
2291
|
-
const [head, body, tail] = partial ? [
|
|
2292
|
-
pattern.slice(patternIndex, firstgs),
|
|
2293
|
-
pattern.slice(firstgs + 1),
|
|
2294
|
-
[]
|
|
2295
|
-
] : [
|
|
2296
|
-
pattern.slice(patternIndex, firstgs),
|
|
2297
|
-
pattern.slice(firstgs + 1, lastgs),
|
|
2298
|
-
pattern.slice(lastgs + 1)
|
|
2299
|
-
];
|
|
2832
|
+
const { head, body, tail, segments } = this.#getGlobstarParts(pattern, partial, patternIndex);
|
|
2300
2833
|
if (head.length) {
|
|
2301
|
-
const
|
|
2302
|
-
if (!this.#matchOne(
|
|
2834
|
+
const headEnd = fileIndex + head.length;
|
|
2835
|
+
if (!this.#matchOne(file, head, partial, fileIndex, 0, headEnd)) return false;
|
|
2303
2836
|
fileIndex += head.length;
|
|
2304
2837
|
patternIndex += head.length;
|
|
2305
2838
|
}
|
|
@@ -2324,67 +2857,86 @@ var Minimatch = class {
|
|
|
2324
2857
|
}
|
|
2325
2858
|
return partial || sawSome;
|
|
2326
2859
|
}
|
|
2327
|
-
|
|
2328
|
-
|
|
2860
|
+
return !!this.#matchGlobStarBodySections(file, segments, file.length - fileTailMatch, fileIndex, 0, partial, 0, !!fileTailMatch, /* @__PURE__ */ new Set());
|
|
2861
|
+
}
|
|
2862
|
+
#getGlobstarParts(pattern, partial, patternIndex) {
|
|
2863
|
+
let byStart = this.#globstarParts.get(pattern);
|
|
2864
|
+
if (!byStart) {
|
|
2865
|
+
byStart = [];
|
|
2866
|
+
this.#globstarParts.set(pattern, byStart);
|
|
2867
|
+
}
|
|
2868
|
+
const key = patternIndex * 2 + (partial ? 1 : 0);
|
|
2869
|
+
const found = byStart[key];
|
|
2870
|
+
if (found) return found;
|
|
2871
|
+
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
|
|
2872
|
+
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
2873
|
+
const head = pattern.slice(patternIndex, firstgs);
|
|
2874
|
+
const body = pattern.slice(firstgs + 1, partial ? void 0 : lastgs);
|
|
2875
|
+
const tail = partial ? [] : pattern.slice(lastgs + 1);
|
|
2876
|
+
const segments = [[[], 0]];
|
|
2877
|
+
let current = segments[0];
|
|
2329
2878
|
let nonGsParts = 0;
|
|
2330
2879
|
const nonGsPartsSums = [0];
|
|
2331
2880
|
for (const b of body) if (b === GLOBSTAR) {
|
|
2332
2881
|
nonGsPartsSums.push(nonGsParts);
|
|
2333
|
-
|
|
2334
|
-
|
|
2882
|
+
current = [[], 0];
|
|
2883
|
+
segments.push(current);
|
|
2335
2884
|
} else {
|
|
2336
|
-
|
|
2885
|
+
current[0].push(b);
|
|
2337
2886
|
nonGsParts++;
|
|
2338
2887
|
}
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2888
|
+
segments.forEach((b, i) => {
|
|
2889
|
+
b[1] = nonGsParts - nonGsPartsSums[i];
|
|
2890
|
+
});
|
|
2891
|
+
const parts = {
|
|
2892
|
+
head,
|
|
2893
|
+
body,
|
|
2894
|
+
tail,
|
|
2895
|
+
segments
|
|
2896
|
+
};
|
|
2897
|
+
byStart[key] = parts;
|
|
2898
|
+
return parts;
|
|
2343
2899
|
}
|
|
2344
|
-
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
2900
|
+
#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex, bodyIndex, partial, globStarDepth, sawTail, tried) {
|
|
2345
2901
|
const bs = bodySegments[bodyIndex];
|
|
2346
2902
|
if (!bs) {
|
|
2347
|
-
|
|
2903
|
+
if (partial) return fileIndex >= fileLength || fileIndex === fileLength - 1 && file[fileIndex] === "";
|
|
2904
|
+
for (let i = fileIndex; i < fileLength; i++) {
|
|
2348
2905
|
sawTail = true;
|
|
2349
2906
|
const f = file[i];
|
|
2350
2907
|
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
|
|
2351
2908
|
}
|
|
2352
2909
|
return sawTail;
|
|
2353
2910
|
}
|
|
2354
|
-
const [body,
|
|
2911
|
+
const [body, need] = bs;
|
|
2912
|
+
const after = partial ? fileLength : fileLength - need;
|
|
2355
2913
|
while (fileIndex <= after) {
|
|
2356
|
-
|
|
2357
|
-
|
|
2914
|
+
const key = bodyIndex * (file.length + 1) + fileIndex;
|
|
2915
|
+
if (tried.has(key)) return false;
|
|
2916
|
+
tried.add(key);
|
|
2917
|
+
if (this.#matchOne(file, body, partial, fileIndex, 0, fileIndex + body.length) && globStarDepth < this.maxGlobstarRecursion) {
|
|
2918
|
+
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileLength, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail, tried);
|
|
2358
2919
|
if (sub !== false) return sub;
|
|
2359
2920
|
}
|
|
2921
|
+
if (fileIndex === after) break;
|
|
2360
2922
|
const f = file[fileIndex];
|
|
2361
2923
|
if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) return false;
|
|
2362
2924
|
fileIndex++;
|
|
2363
2925
|
}
|
|
2364
2926
|
return partial || null;
|
|
2365
2927
|
}
|
|
2366
|
-
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
2928
|
+
#matchOne(file, pattern, partial, fileIndex, patternIndex, fileEnd = file.length) {
|
|
2367
2929
|
let fi;
|
|
2368
2930
|
let pi;
|
|
2369
2931
|
let pl;
|
|
2370
2932
|
let fl;
|
|
2371
|
-
for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
2372
|
-
this.debug("matchOne loop");
|
|
2933
|
+
for (fi = fileIndex, pi = patternIndex, fl = Math.min(fileEnd, file.length), pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
2373
2934
|
let p = pattern[pi];
|
|
2374
2935
|
let f = file[fi];
|
|
2375
|
-
this.debug(pattern, p, f);
|
|
2376
2936
|
/* c8 ignore start */
|
|
2377
2937
|
if (p === false || p === GLOBSTAR) return false;
|
|
2378
2938
|
/* c8 ignore stop */
|
|
2379
|
-
|
|
2380
|
-
if (typeof p === "string") {
|
|
2381
|
-
hit = f === p;
|
|
2382
|
-
this.debug("string match", p, f, hit);
|
|
2383
|
-
} else {
|
|
2384
|
-
hit = p.test(f);
|
|
2385
|
-
this.debug("pattern match", p, f, hit);
|
|
2386
|
-
}
|
|
2387
|
-
if (!hit) return false;
|
|
2939
|
+
if (!portionMatch(p, f)) return false;
|
|
2388
2940
|
}
|
|
2389
2941
|
if (fi === fl && pi === pl) return true;
|
|
2390
2942
|
else if (fi === fl) return partial;
|
|
@@ -2395,92 +2947,83 @@ var Minimatch = class {
|
|
|
2395
2947
|
braceExpand() {
|
|
2396
2948
|
return braceExpand(this.pattern, this.options);
|
|
2397
2949
|
}
|
|
2950
|
+
#expandBraces() {
|
|
2951
|
+
const { pattern } = this;
|
|
2952
|
+
if (this.options.nobrace) return this.braceExpand();
|
|
2953
|
+
let code = 57344;
|
|
2954
|
+
while (pattern.includes(String.fromCharCode(code))) if (++code > 63743) return this.braceExpand();
|
|
2955
|
+
const mark = String.fromCharCode(code);
|
|
2956
|
+
let found = false;
|
|
2957
|
+
const marked = pattern.replace(rangeRe, (m, lo, hi) => {
|
|
2958
|
+
const a = Number(lo);
|
|
2959
|
+
const b = Number(hi);
|
|
2960
|
+
if (!Number.isSafeInteger(a) || !Number.isSafeInteger(b) || Math.abs(a - b) + 1 < RANGE_MIN) return m;
|
|
2961
|
+
found = true;
|
|
2962
|
+
return `${mark}${lo}..${hi}${mark}`;
|
|
2963
|
+
});
|
|
2964
|
+
if (!found) return this.braceExpand();
|
|
2965
|
+
const set = braceExpand(marked, this.options);
|
|
2966
|
+
for (const p of set) for (const portion of p.split("/")) {
|
|
2967
|
+
const c = portion.indexOf("[");
|
|
2968
|
+
if (c !== -1 && c < portion.lastIndexOf(mark)) return this.braceExpand();
|
|
2969
|
+
if (!this.options.noext && inRepeatOrNegExt(portion, mark)) return this.braceExpand();
|
|
2970
|
+
}
|
|
2971
|
+
this.#rangeMark = mark;
|
|
2972
|
+
return set;
|
|
2973
|
+
}
|
|
2398
2974
|
parse(pattern) {
|
|
2399
2975
|
assertValidPattern(pattern);
|
|
2400
2976
|
const options = this.options;
|
|
2401
2977
|
if (pattern === "**") return GLOBSTAR;
|
|
2402
2978
|
if (pattern === "") return "";
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
if (!set.length) {
|
|
2418
|
-
this.regexp = false;
|
|
2419
|
-
return this.regexp;
|
|
2420
|
-
}
|
|
2421
|
-
const options = this.options;
|
|
2422
|
-
const twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
|
|
2423
|
-
const flags = new Set(options.nocase ? ["i"] : []);
|
|
2424
|
-
let re = set.map((pattern) => {
|
|
2425
|
-
const pp = pattern.map((p) => {
|
|
2426
|
-
if (p instanceof RegExp) for (const f of p.flags.split("")) flags.add(f);
|
|
2427
|
-
return typeof p === "string" ? regExpEscape(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
2428
|
-
});
|
|
2429
|
-
pp.forEach((p, i) => {
|
|
2430
|
-
const next = pp[i + 1];
|
|
2431
|
-
const prev = pp[i - 1];
|
|
2432
|
-
if (p !== GLOBSTAR || prev === GLOBSTAR) return;
|
|
2433
|
-
if (prev === void 0) {
|
|
2434
|
-
if (next !== void 0 && next !== GLOBSTAR) pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
2435
|
-
else pp[i] = twoStar;
|
|
2436
|
-
} else if (next === void 0) pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
|
|
2437
|
-
else if (next !== GLOBSTAR) {
|
|
2438
|
-
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
2439
|
-
pp[i + 1] = GLOBSTAR;
|
|
2440
|
-
}
|
|
2979
|
+
const { nocase, nocaseMagicOnly, noext = false, dot, normalize } = options;
|
|
2980
|
+
const rangeMark = this.#rangeMark;
|
|
2981
|
+
const lit = rangeMark && pattern.includes(rangeMark) ? void 0 : literal(pattern, noext);
|
|
2982
|
+
if (lit !== void 0 && !(nocase && !nocaseMagicOnly && pattern.toUpperCase() !== pattern.toLowerCase())) return this.#norm(lit);
|
|
2983
|
+
if (this.#pending) return PENDING;
|
|
2984
|
+
let m = this.#matchers.get(pattern);
|
|
2985
|
+
if (!m) {
|
|
2986
|
+
if (!noext) assertValidExtglobs(pattern);
|
|
2987
|
+
m = new Matcher(pattern, {
|
|
2988
|
+
nocase,
|
|
2989
|
+
noext,
|
|
2990
|
+
dot,
|
|
2991
|
+
normalize,
|
|
2992
|
+
...rangeMark && { rangeMark }
|
|
2441
2993
|
});
|
|
2442
|
-
|
|
2443
|
-
if (this.partial && filtered.length >= 1) {
|
|
2444
|
-
const prefixes = [];
|
|
2445
|
-
for (let i = 1; i <= filtered.length; i++) prefixes.push(filtered.slice(0, i).join("/"));
|
|
2446
|
-
return "(?:" + prefixes.join("|") + ")";
|
|
2447
|
-
}
|
|
2448
|
-
return filtered.join("/");
|
|
2449
|
-
}).join("|");
|
|
2450
|
-
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
2451
|
-
re = "^" + open + re + close + "$";
|
|
2452
|
-
if (this.partial) re = "^(?:\\/|" + open + re.slice(1, -1) + close + ")$";
|
|
2453
|
-
if (this.negate) re = "^(?!" + re + ").+$";
|
|
2454
|
-
try {
|
|
2455
|
-
this.regexp = new RegExp(re, [...flags].join(""));
|
|
2456
|
-
} catch {
|
|
2457
|
-
this.regexp = false;
|
|
2994
|
+
this.#matchers.set(pattern, m);
|
|
2458
2995
|
}
|
|
2459
|
-
|
|
2460
|
-
return this.regexp;
|
|
2996
|
+
return m;
|
|
2461
2997
|
}
|
|
2462
|
-
slashSplit(p) {
|
|
2998
|
+
#slashSplit(p) {
|
|
2463
2999
|
if (this.preserveMultipleSlashes) return p.split("/");
|
|
2464
3000
|
else if (this.isWindows && /^\/\/[^/]+/.test(p)) return ["", ...p.split(/\/+/)];
|
|
2465
3001
|
else return p.split(/\/+/);
|
|
2466
3002
|
}
|
|
2467
3003
|
match(f, partial = this.partial) {
|
|
2468
|
-
this.debug("match", f, this.pattern);
|
|
2469
3004
|
if (this.comment) return false;
|
|
2470
3005
|
if (this.empty) return f === "";
|
|
2471
3006
|
if (f === "/" && partial) return true;
|
|
2472
3007
|
const options = this.options;
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
3008
|
+
let split = this.#cachedSplit(f);
|
|
3009
|
+
if (!split) {
|
|
3010
|
+
if (!partial && !this.#form && (this.#endCheck || this.#literalCheck) && lastChecked !== f) {
|
|
3011
|
+
lastChecked = f;
|
|
3012
|
+
const can = this.#canMatch(f);
|
|
3013
|
+
if (can === "no") return options.flipNegate ? false : this.negate;
|
|
3014
|
+
if (can === "yes") return options.flipNegate ? true : !this.negate;
|
|
3015
|
+
}
|
|
3016
|
+
split = this.#split(f);
|
|
3017
|
+
}
|
|
3018
|
+
const ff = split.parts;
|
|
3019
|
+
const resolved = this.#level2 ? split.resolved ??= this.#levelTwoFileOptimize(ff) : ff;
|
|
2476
3020
|
const set = this.set;
|
|
2477
|
-
this.debug(this.pattern, "set", set);
|
|
2478
3021
|
let filename = ff[ff.length - 1];
|
|
2479
3022
|
if (!filename) for (let i = ff.length - 2; !filename && i >= 0; i--) filename = ff[i];
|
|
2480
|
-
for (
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
if (this.
|
|
3023
|
+
for (let r = 0; r < set.length; r++) {
|
|
3024
|
+
const pattern = set[r];
|
|
3025
|
+
const shape = partial ? void 0 : this.#shapes[r];
|
|
3026
|
+
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)) {
|
|
2484
3027
|
if (options.flipNegate) return true;
|
|
2485
3028
|
return !this.negate;
|
|
2486
3029
|
}
|
|
@@ -2493,12 +3036,10 @@ var Minimatch = class {
|
|
|
2493
3036
|
}
|
|
2494
3037
|
};
|
|
2495
3038
|
/* c8 ignore stop */
|
|
2496
|
-
minimatch.AST = AST;
|
|
2497
3039
|
minimatch.Minimatch = Minimatch;
|
|
2498
3040
|
minimatch.escape = escape;
|
|
2499
3041
|
minimatch.unescape = unescape;
|
|
2500
|
-
|
|
2501
|
-
//#region ../internal/src/build/runtime-package-files.ts
|
|
3042
|
+
// ../internal/src/build/runtime-package-files.ts
|
|
2502
3043
|
const alwaysPublishedFile = /^(?:package\.json|(?:readme|copying|licen[cs]e)(?:\..*[^~$])?)$/i;
|
|
2503
3044
|
const rootExcluded = /* @__PURE__ */ new Set([
|
|
2504
3045
|
"package-lock.json",
|
|
@@ -2682,8 +3223,7 @@ async function copyRuntimePackageFiles(packageDir, targetDir) {
|
|
|
2682
3223
|
await unlessGone(() => copyFile(join(packageDir, path), target));
|
|
2683
3224
|
}
|
|
2684
3225
|
}
|
|
2685
|
-
|
|
2686
|
-
//#region ../internal/src/build/scan-module.ts
|
|
3226
|
+
// ../internal/src/build/scan-module.ts
|
|
2687
3227
|
/**
|
|
2688
3228
|
* Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
|
|
2689
3229
|
* the oxc parser that Vite ships through Rolldown, and never runs it. Values that are not static literals read as
|
|
@@ -2692,12 +3232,8 @@ async function copyRuntimePackageFiles(packageDir, targetDir) {
|
|
|
2692
3232
|
var scan_module_exports = /* @__PURE__ */ __exportAll({
|
|
2693
3233
|
dynamic: () => dynamic,
|
|
2694
3234
|
exportNames: () => exportNames,
|
|
2695
|
-
maskLiterals: () => maskLiterals,
|
|
2696
|
-
objectProperties: () => objectProperties,
|
|
2697
3235
|
scanModule: () => scanModule,
|
|
2698
|
-
staticValue: () => staticValue
|
|
2699
|
-
unwrapExpression: () => unwrapExpression,
|
|
2700
|
-
walk: () => walk
|
|
3236
|
+
staticValue: () => staticValue
|
|
2701
3237
|
});
|
|
2702
3238
|
/** The value of an expression that the scanner cannot read without running the module. */
|
|
2703
3239
|
const dynamic = Symbol("dynamic");
|
|
@@ -2857,8 +3393,7 @@ function maskLiterals(module) {
|
|
|
2857
3393
|
for (const span of literalSpans(module)) for (let index = span.start; index < span.end; index++) if (!isLineTerminator(output[index] ?? "")) output[index] = " ";
|
|
2858
3394
|
return output.join("");
|
|
2859
3395
|
}
|
|
2860
|
-
|
|
2861
|
-
//#region ../internal/src/build/provider-output-sources.ts
|
|
3396
|
+
// ../internal/src/build/provider-output-sources.ts
|
|
2862
3397
|
function escapeRegExp(value) {
|
|
2863
3398
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2864
3399
|
}
|
|
@@ -3940,8 +4475,7 @@ async function retainProviderOutputSources(options) {
|
|
|
3940
4475
|
return root ? resolve$1(retainedRoots.get(root), relative$1(root, resolvedPath)) : path;
|
|
3941
4476
|
} };
|
|
3942
4477
|
}
|
|
3943
|
-
|
|
3944
|
-
//#region ../internal/src/build/vercel-config.ts
|
|
4478
|
+
// ../internal/src/build/vercel-config.ts
|
|
3945
4479
|
function createDefaultVercelOutputRoot(rootDir) {
|
|
3946
4480
|
return resolve$1(rootDir, ".vercel", "output");
|
|
3947
4481
|
}
|
|
@@ -3964,8 +4498,7 @@ function createNodeFunctionConfig(extra = {}) {
|
|
|
3964
4498
|
...extra
|
|
3965
4499
|
};
|
|
3966
4500
|
}
|
|
3967
|
-
|
|
3968
|
-
//#region ../internal/src/build/runtime-package-resolution.ts
|
|
4501
|
+
// ../internal/src/build/runtime-package-resolution.ts
|
|
3969
4502
|
/** Locates package metadata through exports, an entry's ancestors, or the project's dependency roots. */
|
|
3970
4503
|
function createRuntimePackageResolver(readPackageName) {
|
|
3971
4504
|
return async (name, resolver, fromDir) => {
|
|
@@ -4006,8 +4539,7 @@ function isPackageResolutionMiss(error) {
|
|
|
4006
4539
|
const code = error?.code;
|
|
4007
4540
|
return code === "MODULE_NOT_FOUND" || code === "ERR_MODULE_NOT_FOUND" || code === "ERR_PACKAGE_PATH_NOT_EXPORTED";
|
|
4008
4541
|
}
|
|
4009
|
-
|
|
4010
|
-
//#region ../internal/src/build/runtime-package-directory.ts
|
|
4542
|
+
// ../internal/src/build/runtime-package-directory.ts
|
|
4011
4543
|
/** Update a staged copy, then publish it with rollback on failure or cancellation. */
|
|
4012
4544
|
async function updateRuntimePackageDirectory(options) {
|
|
4013
4545
|
const stagingRoot = await mkdtemp(join(dirname$1(options.directory), ".vitehub-runtime-packages-"));
|
|
@@ -4054,8 +4586,7 @@ async function updateRuntimePackageDirectory(options) {
|
|
|
4054
4586
|
});
|
|
4055
4587
|
}
|
|
4056
4588
|
}
|
|
4057
|
-
|
|
4058
|
-
//#region ../internal/src/build/vercel-runtime-packages.ts
|
|
4589
|
+
// ../internal/src/build/vercel-runtime-packages.ts
|
|
4059
4590
|
const runtimeExportConditions = /* @__PURE__ */ new Set([
|
|
4060
4591
|
"default",
|
|
4061
4592
|
"import",
|
|
@@ -4209,7 +4740,7 @@ async function copyTracedPackageFiles(name, resolver, packageDir, packageJsonPat
|
|
|
4209
4740
|
return true;
|
|
4210
4741
|
}
|
|
4211
4742
|
async function loadNodeFileTrace() {
|
|
4212
|
-
nodeFileTracePromise ??= import("./out-
|
|
4743
|
+
nodeFileTracePromise ??= import("./out-r9T3bhTE.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1)).then(({ nodeFileTrace }) => nodeFileTrace);
|
|
4213
4744
|
return nodeFileTracePromise;
|
|
4214
4745
|
}
|
|
4215
4746
|
async function resolvePackageTraceEntries(name, resolver, packageDir, packageJson) {
|
|
@@ -4275,8 +4806,7 @@ function parsePackageJson(value, path) {
|
|
|
4275
4806
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw internalErrorDiagnostics.INTERNAL_B0047({ message: `Expected ${path} to contain a JSON object.` });
|
|
4276
4807
|
return value;
|
|
4277
4808
|
}
|
|
4278
|
-
|
|
4279
|
-
//#region ../internal/src/build/provider-output-catalog.ts
|
|
4809
|
+
// ../internal/src/build/provider-output-catalog.ts
|
|
4280
4810
|
var ProviderOutputCatalog = class {
|
|
4281
4811
|
bundleDefines = {};
|
|
4282
4812
|
#appliedCloudflareContributions = /* @__PURE__ */ new Map();
|
|
@@ -4516,8 +5046,7 @@ function getVercelRuntimePackages(catalog, product, generation) {
|
|
|
4516
5046
|
const contribution = catalog?.runtimeContribution(product, generation);
|
|
4517
5047
|
return contribution?.owner === "blob" ? contribution.vercelRuntimePackages ?? [] : [];
|
|
4518
5048
|
}
|
|
4519
|
-
|
|
4520
|
-
//#region ../internal/src/build/vite.ts
|
|
5049
|
+
// ../internal/src/build/vite.ts
|
|
4521
5050
|
async function collectViteHubProviderImportAliases(plugins) {
|
|
4522
5051
|
return Object.assign({}, ...await Promise.all(plugins.map(async (plugin) => await plugin.vitehub?.providerOutput?.getImportAliases?.() ?? {})));
|
|
4523
5052
|
}
|
|
@@ -4646,8 +5175,7 @@ function isMissingProjectMarker(error) {
|
|
|
4646
5175
|
const code = error.code;
|
|
4647
5176
|
return code === "ENOENT" || code === "ENOTDIR";
|
|
4648
5177
|
}
|
|
4649
|
-
|
|
4650
|
-
//#region ../internal/src/build/deployment-output.ts
|
|
5178
|
+
// ../internal/src/build/deployment-output.ts
|
|
4651
5179
|
const providerDeploymentOutputRegistry = globalThis;
|
|
4652
5180
|
const providerDeploymentOutputWrites = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputWrites ??= /* @__PURE__ */ new Map();
|
|
4653
5181
|
const providerDeploymentOutputFinalizations = providerDeploymentOutputRegistry.__vitehubProviderDeploymentOutputFinalizations ??= /* @__PURE__ */ new WeakMap();
|
|
@@ -5691,8 +6219,7 @@ function createNitroServerKit(value = {}) {
|
|
|
5691
6219
|
}
|
|
5692
6220
|
};
|
|
5693
6221
|
}
|
|
5694
|
-
|
|
5695
|
-
//#region ../internal/src/runtime/request-log.ts
|
|
6222
|
+
// ../internal/src/runtime/request-log.ts
|
|
5696
6223
|
/**
|
|
5697
6224
|
* A short name for the cause of a failure, safe to put in a log field: the string `code` of the error, such as
|
|
5698
6225
|
* `ENOSPC` or a ViteHub diagnostic code, else its class name. Never the message, which can hold paths or values.
|
|
@@ -5704,8 +6231,7 @@ function errorCode(error) {
|
|
|
5704
6231
|
const name = Reflect.get(error, "name");
|
|
5705
6232
|
return typeof name === "string" && name && name !== "Error" ? name : void 0;
|
|
5706
6233
|
}
|
|
5707
|
-
|
|
5708
|
-
//#region src/deployment-env.ts
|
|
6234
|
+
// src/deployment-env.ts
|
|
5709
6235
|
const owners = ["workflow"];
|
|
5710
6236
|
function entry(names, required, secret, hasDefault) {
|
|
5711
6237
|
return {
|
|
@@ -5747,8 +6273,7 @@ function workflowDeploymentEnv(workflow) {
|
|
|
5747
6273
|
...schema
|
|
5748
6274
|
];
|
|
5749
6275
|
}
|
|
5750
|
-
|
|
5751
|
-
//#region ../internal/src/definition-catalog.ts
|
|
6276
|
+
// ../internal/src/definition-catalog.ts
|
|
5752
6277
|
const sourceFilePattern$2 = /\.(?:c|m)?[jt]sx?$/i;
|
|
5753
6278
|
const declarationFilePattern = /\.d\.(?:c|m)?[jt]sx?$/i;
|
|
5754
6279
|
const testFilePattern = /\.(?:test|spec)\.(?:c|m)?[jt]sx?$/i;
|
|
@@ -5883,8 +6408,7 @@ function scanDirectoryDefinitions(feature, source) {
|
|
|
5883
6408
|
function discoverDefinitions(feature, sources) {
|
|
5884
6409
|
return mergeDefinitions(feature, ...sources.map((source) => source.kind === "suffix" ? scanSuffixDefinitions(feature, source) : scanDirectoryDefinitions(feature, source)));
|
|
5885
6410
|
}
|
|
5886
|
-
|
|
5887
|
-
//#region src/discovery.ts
|
|
6411
|
+
// src/discovery.ts
|
|
5888
6412
|
const workflowSuffixPattern = /\.workflow\.(?:c|m)?[jt]s$/i;
|
|
5889
6413
|
const agentSuffixPattern = /\.agent\.(?:c|m)?[jt]s$/i;
|
|
5890
6414
|
const sourceFilePattern$1 = /\.(?:c|m)?[jt]s$/i;
|
|
@@ -6218,18 +6742,15 @@ function discoverWorkflowDefinitions(options) {
|
|
|
6218
6742
|
source: "vite-suffix"
|
|
6219
6743
|
}) })]), discoverFlatServerWorkflowDefinitions(serverScanDirs, "server-workflows"), folderDefinitions, options.mode === "standalone" ? [] : discoverAgentWorkflowDefinitions(roots, serverScanDirs));
|
|
6220
6744
|
}
|
|
6221
|
-
|
|
6222
|
-
//#region src/internal/runtime-type.ts
|
|
6745
|
+
// src/internal/runtime-type.ts
|
|
6223
6746
|
function isRuntimeRecord(value) {
|
|
6224
6747
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6225
6748
|
}
|
|
6226
|
-
|
|
6227
|
-
//#region ../internal/src/agent-workflow.ts
|
|
6749
|
+
// ../internal/src/agent-workflow.ts
|
|
6228
6750
|
function getAgentInvocationRecoveryWorkflowName(agentWorkflowName) {
|
|
6229
6751
|
return `vitehub-agent-invocation-recovery-${agentWorkflowName}`;
|
|
6230
6752
|
}
|
|
6231
|
-
|
|
6232
|
-
//#region ../internal/src/build/colocated-agent-files.ts
|
|
6753
|
+
// ../internal/src/build/colocated-agent-files.ts
|
|
6233
6754
|
function isFolderAgentEntry(file) {
|
|
6234
6755
|
if (!/^(?:agent|index)\.(?:c|m)?[jt]s$/i.test(basename(file))) return false;
|
|
6235
6756
|
return !(basename(file).toLowerCase().startsWith("agent.") && basename(dirname$1(file)) === "agents" && basename(dirname$1(dirname$1(file))) === "server");
|
|
@@ -6267,8 +6788,7 @@ function readColocatedAgentFiles(handler, directoryName) {
|
|
|
6267
6788
|
visit(root);
|
|
6268
6789
|
return Object.keys(files).length ? files : void 0;
|
|
6269
6790
|
}
|
|
6270
|
-
|
|
6271
|
-
//#region ../internal/src/build/esbuild.ts
|
|
6791
|
+
// ../internal/src/build/esbuild.ts
|
|
6272
6792
|
const viteRawNamespace = "vitehub-vite-raw";
|
|
6273
6793
|
const viteMarkdownTemplateNamespace = "vitehub-markdown-template";
|
|
6274
6794
|
const markdownTemplateFileSuffix = ".template.md";
|
|
@@ -6431,8 +6951,7 @@ async function bundleEsbuildEntry(bundle, entryFile, outfile, options = {}) {
|
|
|
6431
6951
|
tsconfigRaw: options.tsconfigRaw
|
|
6432
6952
|
});
|
|
6433
6953
|
}
|
|
6434
|
-
|
|
6435
|
-
//#region src/internal/step-options.ts
|
|
6954
|
+
// src/internal/step-options.ts
|
|
6436
6955
|
const optionNames = ["retries", "timeout"];
|
|
6437
6956
|
/**
|
|
6438
6957
|
* Reads the `retries` and `timeout` exports of a step file from its source, without running it. The build checks them,
|
|
@@ -6464,8 +6983,7 @@ async function readWorkflowStepOptions(file) {
|
|
|
6464
6983
|
resolveWorkflowStepOptions(file, options);
|
|
6465
6984
|
return options;
|
|
6466
6985
|
}
|
|
6467
|
-
|
|
6468
|
-
//#region src/internal/vite-build.ts
|
|
6986
|
+
// src/internal/vite-build.ts
|
|
6469
6987
|
function resolveVercelWorkflowWorld(workflowApi) {
|
|
6470
6988
|
const workflowCore = createRequire(workflowApi).resolve("@workflow/core");
|
|
6471
6989
|
return createRequire(workflowCore).resolve("@workflow/world-vercel");
|
|
@@ -7260,7 +7778,9 @@ async function createCloudflareWorkflowNitroConfig(options) {
|
|
|
7260
7778
|
}, options.serverDirs, options.includeUserAppEntry, options.transformRegistry);
|
|
7261
7779
|
if (!artifacts.providerDefinitions.length) return options.nitro;
|
|
7262
7780
|
const nitro = { ...options.nitro };
|
|
7263
|
-
const
|
|
7781
|
+
const middlewareDir = resolve$1(options.rootDir, ".vitehub", "nitro", productName);
|
|
7782
|
+
const middlewareFile = resolve$1(middlewareDir, "cloudflare-middleware.ts");
|
|
7783
|
+
await mkdir(middlewareDir, { recursive: true });
|
|
7264
7784
|
await writeFile(middlewareFile, [
|
|
7265
7785
|
"import { defineMiddleware } from \"nitro\"",
|
|
7266
7786
|
"import { env, waitUntil } from \"cloudflare:workers\"",
|
|
@@ -8025,8 +8545,7 @@ async function generateWorkflowProviderOutputs(options, write) {
|
|
|
8025
8545
|
if (write) return await generateProviderOutputsWithinLock(options, write);
|
|
8026
8546
|
return await withProviderDeploymentOutputLock(options.rootDir, async (lockedWrite) => await generateProviderOutputsWithinLock(options, lockedWrite));
|
|
8027
8547
|
}
|
|
8028
|
-
|
|
8029
|
-
//#region src/inspect.ts
|
|
8548
|
+
// src/inspect.ts
|
|
8030
8549
|
function summarizeWorkflowDefinition(projectRoot, definition) {
|
|
8031
8550
|
return {
|
|
8032
8551
|
fields: [...definition.agentIdentity ? [{
|
|
@@ -8083,8 +8602,7 @@ const workflowConsoleSection = {
|
|
|
8083
8602
|
notice: "Workflow run history is not exposed by ViteHub's provider-independent Workflow contract yet."
|
|
8084
8603
|
}
|
|
8085
8604
|
};
|
|
8086
|
-
|
|
8087
|
-
//#region src/internal/dev-registry.ts
|
|
8605
|
+
// src/internal/dev-registry.ts
|
|
8088
8606
|
const workflowDevGeneratedDir = ".vitehub/nitro/workflow";
|
|
8089
8607
|
const workflowTestSetupFile = "test-setup.mjs";
|
|
8090
8608
|
const generatedFilesSeparatePerCommand = {
|
|
@@ -8219,8 +8737,7 @@ async function writeWorkflowDevRegistryFiles(options) {
|
|
|
8219
8737
|
plugin: options.pluginPath ?? plugin
|
|
8220
8738
|
};
|
|
8221
8739
|
}
|
|
8222
|
-
|
|
8223
|
-
//#region src/internal/registry-types.ts
|
|
8740
|
+
// src/internal/registry-types.ts
|
|
8224
8741
|
const workflowTypesFile = ".vitehub/workflow.d.ts";
|
|
8225
8742
|
const sourceFilePattern = /\.(?:c|m)?[jt]s$/i;
|
|
8226
8743
|
const javaScriptFilePattern = /\.(?:c|m)?js$/i;
|
|
@@ -8271,8 +8788,7 @@ async function writeWorkflowTypes(root, definitions, importBase = "@vite-hub/wor
|
|
|
8271
8788
|
await mkdir(dirname(file), { recursive: true });
|
|
8272
8789
|
await writeFile(file, contents, "utf8");
|
|
8273
8790
|
}
|
|
8274
|
-
|
|
8275
|
-
//#region src/vite.ts
|
|
8791
|
+
// src/vite.ts
|
|
8276
8792
|
function agentWorkflowModules(plugins) {
|
|
8277
8793
|
for (const plugin of [plugins].flat(Infinity)) {
|
|
8278
8794
|
const modules = plugin?.vitehub?.agent?.workflowModules;
|
|
@@ -8913,5 +9429,4 @@ function hubWorkflow(workflow, internalOptions = {}) {
|
|
|
8913
9429
|
}
|
|
8914
9430
|
};
|
|
8915
9431
|
}
|
|
8916
|
-
//#endregion
|
|
8917
9432
|
export { createWorkflowTypes, discoverWorkflowDefinitions, hubWorkflow, inspectWorkflowDefinitions, inspectWorkflowResources, workflowConsoleSection, workflowRuntimeModule };
|