nitro-nightly 3.0.1-20260106-130706-e20c92d9 → 3.0.1-20260106-202835-5325b208
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/_build/rolldown.mjs +6 -14
- package/dist/_build/rollup.mjs +6 -41
- package/dist/_build/rollup2.mjs +56 -0
- package/dist/_build/shared.mjs +2 -1
- package/dist/_build/shared2.mjs +1 -1
- package/dist/_build/shared3.mjs +1 -1
- package/dist/_build/vite.build.mjs +1 -19
- package/dist/_dev.mjs +2 -1
- package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +5 -1560
- package/dist/_libs/@jridgewell/gen-mapping.mjs +2 -304
- package/dist/_libs/@jridgewell/remapping.mjs +2 -1
- package/dist/_libs/@jridgewell/resolve-uri.mjs +166 -0
- package/dist/_libs/@jridgewell/sourcemap-codec.mjs +167 -0
- package/dist/_libs/@jridgewell/trace-mapping.mjs +141 -0
- package/dist/_libs/@rolldown/pluginutils.mjs +31 -0
- package/dist/_libs/@rollup/plugin-commonjs.mjs +33 -2636
- package/dist/_libs/@rollup/plugin-inject.mjs +3 -2
- package/dist/_libs/@rollup/plugin-json.mjs +1 -1
- package/dist/_libs/@rollup/plugin-node-resolve.mjs +7 -1111
- package/dist/_libs/@rollup/plugin-replace.mjs +2 -2
- package/dist/_libs/@rollup/pluginutils.mjs +241 -0
- package/dist/_libs/c12.mjs +63 -2513
- package/dist/_libs/chokidar.mjs +1 -234
- package/dist/_libs/commondir.mjs +22 -0
- package/dist/_libs/confbox.mjs +1102 -502
- package/dist/_libs/deepmerge.mjs +86 -0
- package/dist/_libs/dotenv.mjs +345 -0
- package/dist/_libs/estree-walker.mjs +144 -1
- package/dist/_libs/exsolve.mjs +1007 -0
- package/dist/_libs/fdir.mjs +514 -0
- package/dist/_libs/function-bind.mjs +63 -0
- package/dist/_libs/giget.mjs +1376 -2234
- package/dist/_libs/hasown.mjs +14 -0
- package/dist/_libs/is-core-module.mjs +220 -0
- package/dist/_libs/is-module.mjs +13 -0
- package/dist/_libs/is-reference.mjs +33 -0
- package/dist/_libs/js-tokens.mjs +382 -0
- package/dist/_libs/local-pkg.mjs +6 -1560
- package/dist/_libs/magic-string.mjs +939 -0
- package/dist/_libs/mlly.mjs +1415 -0
- package/dist/_libs/node-fetch-native.mjs +7 -0
- package/dist/_libs/nypm.mjs +239 -0
- package/dist/_libs/path-parse.mjs +47 -0
- package/dist/_libs/pathe.mjs +163 -2
- package/dist/_libs/perfect-debounce.mjs +89 -0
- package/dist/_libs/picomatch.mjs +1673 -0
- package/dist/_libs/pkg-types.mjs +197 -0
- package/dist/_libs/quansync.mjs +90 -0
- package/dist/_libs/rc9.mjs +136 -0
- package/dist/_libs/readdirp.mjs +237 -0
- package/dist/_libs/resolve.mjs +689 -0
- package/dist/_libs/strip-literal.mjs +51 -0
- package/dist/_libs/tinyexec.mjs +627 -0
- package/dist/_libs/tinyglobby.mjs +2 -1
- package/dist/_libs/unimport.mjs +42 -1575
- package/dist/_libs/unplugin-utils.mjs +61 -0
- package/dist/_libs/unplugin.mjs +1225 -0
- package/dist/_libs/unwasm.mjs +3 -2
- package/dist/_libs/webpack-virtual-modules.mjs +272 -0
- package/dist/_nitro.mjs +7 -4
- package/dist/_nitro2.mjs +3 -3
- package/dist/_presets.mjs +5 -3
- package/dist/builder.mjs +4 -4
- package/dist/cli/_chunks/{build.mjs → build2.mjs} +1 -1
- package/dist/cli/_chunks/dev.mjs +1 -1
- package/dist/cli/_chunks/list.mjs +1 -1
- package/dist/cli/_chunks/prepare.mjs +1 -1
- package/dist/cli/_chunks/run.mjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/types/index.d.mts +4 -4
- package/dist/vite.mjs +1824 -19
- package/package.json +2 -2
- package/dist/_build/shared4.mjs +0 -1114
- package/dist/_build/vite.plugin.mjs +0 -712
package/dist/_libs/c12.mjs
CHANGED
|
@@ -1,2467 +1,17 @@
|
|
|
1
|
-
import { i as __toESM, n as __exportAll
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { i as __toESM, n as __exportAll } from "../_rolldown.mjs";
|
|
2
|
+
import { i as extname, n as basename, o as join, r as dirname, s as normalize, u as resolve } from "./pathe.mjs";
|
|
3
|
+
import { t as require_main } from "./dotenv.mjs";
|
|
4
|
+
import { t as resolveModulePath } from "./exsolve.mjs";
|
|
5
|
+
import { n as readUser, t as read } from "./rc9.mjs";
|
|
6
|
+
import { i as findWorkspaceDir, s as readPackageJSON } from "./pkg-types.mjs";
|
|
7
|
+
import { t as debounce } from "./perfect-debounce.mjs";
|
|
8
|
+
import { existsSync, promises, statSync } from "node:fs";
|
|
9
|
+
import { readFile, rm } from "node:fs/promises";
|
|
10
|
+
import { pathToFileURL } from "node:url";
|
|
5
11
|
import { homedir } from "node:os";
|
|
6
|
-
import path, { isAbsolute, resolve } from "node:path";
|
|
7
|
-
import assert from "node:assert";
|
|
8
|
-
import process$1 from "node:process";
|
|
9
|
-
import v8 from "node:v8";
|
|
10
|
-
import { format, inspect } from "node:util";
|
|
11
12
|
import { createJiti } from "jiti";
|
|
12
|
-
import destr from "destr";
|
|
13
13
|
import { defu } from "defu";
|
|
14
14
|
|
|
15
|
-
//#region node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
|
|
16
|
-
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
17
|
-
function normalizeWindowsPath(input = "") {
|
|
18
|
-
if (!input) return input;
|
|
19
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r$1) => r$1.toUpperCase());
|
|
20
|
-
}
|
|
21
|
-
const _UNC_REGEX = /^[/\\]{2}/;
|
|
22
|
-
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
23
|
-
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
24
|
-
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
25
|
-
const _EXTNAME_RE = /.(\.[^./]+|\.)$/;
|
|
26
|
-
const _PATH_ROOT_RE = /^[/\\]|^[a-zA-Z]:[/\\]/;
|
|
27
|
-
const normalize$1 = function(path$2) {
|
|
28
|
-
if (path$2.length === 0) return ".";
|
|
29
|
-
path$2 = normalizeWindowsPath(path$2);
|
|
30
|
-
const isUNCPath = path$2.match(_UNC_REGEX);
|
|
31
|
-
const isPathAbsolute = isAbsolute$1(path$2);
|
|
32
|
-
const trailingSeparator = path$2[path$2.length - 1] === "/";
|
|
33
|
-
path$2 = normalizeString(path$2, !isPathAbsolute);
|
|
34
|
-
if (path$2.length === 0) {
|
|
35
|
-
if (isPathAbsolute) return "/";
|
|
36
|
-
return trailingSeparator ? "./" : ".";
|
|
37
|
-
}
|
|
38
|
-
if (trailingSeparator) path$2 += "/";
|
|
39
|
-
if (_DRIVE_LETTER_RE.test(path$2)) path$2 += "/";
|
|
40
|
-
if (isUNCPath) {
|
|
41
|
-
if (!isPathAbsolute) return `//./${path$2}`;
|
|
42
|
-
return `//${path$2}`;
|
|
43
|
-
}
|
|
44
|
-
return isPathAbsolute && !isAbsolute$1(path$2) ? `/${path$2}` : path$2;
|
|
45
|
-
};
|
|
46
|
-
const join$1 = function(...segments) {
|
|
47
|
-
let path$2 = "";
|
|
48
|
-
for (const seg of segments) {
|
|
49
|
-
if (!seg) continue;
|
|
50
|
-
if (path$2.length > 0) {
|
|
51
|
-
const pathTrailing = path$2[path$2.length - 1] === "/";
|
|
52
|
-
const segLeading = seg[0] === "/";
|
|
53
|
-
if (pathTrailing && segLeading) path$2 += seg.slice(1);
|
|
54
|
-
else path$2 += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
55
|
-
} else path$2 += seg;
|
|
56
|
-
}
|
|
57
|
-
return normalize$1(path$2);
|
|
58
|
-
};
|
|
59
|
-
function cwd$1() {
|
|
60
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
|
|
61
|
-
return "/";
|
|
62
|
-
}
|
|
63
|
-
const resolve$1 = function(...arguments_) {
|
|
64
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
65
|
-
let resolvedPath = "";
|
|
66
|
-
let resolvedAbsolute = false;
|
|
67
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
68
|
-
const path$2 = index >= 0 ? arguments_[index] : cwd$1();
|
|
69
|
-
if (!path$2 || path$2.length === 0) continue;
|
|
70
|
-
resolvedPath = `${path$2}/${resolvedPath}`;
|
|
71
|
-
resolvedAbsolute = isAbsolute$1(path$2);
|
|
72
|
-
}
|
|
73
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
74
|
-
if (resolvedAbsolute && !isAbsolute$1(resolvedPath)) return `/${resolvedPath}`;
|
|
75
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
76
|
-
};
|
|
77
|
-
function normalizeString(path$2, allowAboveRoot) {
|
|
78
|
-
let res = "";
|
|
79
|
-
let lastSegmentLength = 0;
|
|
80
|
-
let lastSlash = -1;
|
|
81
|
-
let dots = 0;
|
|
82
|
-
let char = null;
|
|
83
|
-
for (let index = 0; index <= path$2.length; ++index) {
|
|
84
|
-
if (index < path$2.length) char = path$2[index];
|
|
85
|
-
else if (char === "/") break;
|
|
86
|
-
else char = "/";
|
|
87
|
-
if (char === "/") {
|
|
88
|
-
if (lastSlash === index - 1 || dots === 1);
|
|
89
|
-
else if (dots === 2) {
|
|
90
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
91
|
-
if (res.length > 2) {
|
|
92
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
93
|
-
if (lastSlashIndex === -1) {
|
|
94
|
-
res = "";
|
|
95
|
-
lastSegmentLength = 0;
|
|
96
|
-
} else {
|
|
97
|
-
res = res.slice(0, lastSlashIndex);
|
|
98
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
99
|
-
}
|
|
100
|
-
lastSlash = index;
|
|
101
|
-
dots = 0;
|
|
102
|
-
continue;
|
|
103
|
-
} else if (res.length > 0) {
|
|
104
|
-
res = "";
|
|
105
|
-
lastSegmentLength = 0;
|
|
106
|
-
lastSlash = index;
|
|
107
|
-
dots = 0;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (allowAboveRoot) {
|
|
112
|
-
res += res.length > 0 ? "/.." : "..";
|
|
113
|
-
lastSegmentLength = 2;
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
if (res.length > 0) res += `/${path$2.slice(lastSlash + 1, index)}`;
|
|
117
|
-
else res = path$2.slice(lastSlash + 1, index);
|
|
118
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
119
|
-
}
|
|
120
|
-
lastSlash = index;
|
|
121
|
-
dots = 0;
|
|
122
|
-
} else if (char === "." && dots !== -1) ++dots;
|
|
123
|
-
else dots = -1;
|
|
124
|
-
}
|
|
125
|
-
return res;
|
|
126
|
-
}
|
|
127
|
-
const isAbsolute$1 = function(p) {
|
|
128
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
129
|
-
};
|
|
130
|
-
const extname$2 = function(p) {
|
|
131
|
-
if (p === "..") return "";
|
|
132
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
133
|
-
return match && match[1] || "";
|
|
134
|
-
};
|
|
135
|
-
const relative$1 = function(from, to) {
|
|
136
|
-
const _from = resolve$1(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
137
|
-
const _to = resolve$1(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
138
|
-
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) return _to.join("/");
|
|
139
|
-
const _fromCopy = [..._from];
|
|
140
|
-
for (const segment of _fromCopy) {
|
|
141
|
-
if (_to[0] !== segment) break;
|
|
142
|
-
_from.shift();
|
|
143
|
-
_to.shift();
|
|
144
|
-
}
|
|
145
|
-
return [..._from.map(() => ".."), ..._to].join("/");
|
|
146
|
-
};
|
|
147
|
-
const dirname$1 = function(p) {
|
|
148
|
-
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
149
|
-
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) segments[0] += "/";
|
|
150
|
-
return segments.join("/") || (isAbsolute$1(p) ? "/" : ".");
|
|
151
|
-
};
|
|
152
|
-
const basename$1 = function(p, extension) {
|
|
153
|
-
const segments = normalizeWindowsPath(p).split("/");
|
|
154
|
-
let lastSegment = "";
|
|
155
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
156
|
-
const val = segments[i];
|
|
157
|
-
if (val) {
|
|
158
|
-
lastSegment = val;
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
|
|
163
|
-
};
|
|
164
|
-
const parse$1 = function(p) {
|
|
165
|
-
const root = _PATH_ROOT_RE.exec(p)?.[0]?.replace(/\\/g, "/") || "";
|
|
166
|
-
const base = basename$1(p);
|
|
167
|
-
const extension = extname$2(base);
|
|
168
|
-
return {
|
|
169
|
-
root,
|
|
170
|
-
dir: dirname$1(p),
|
|
171
|
-
base,
|
|
172
|
-
ext: extension,
|
|
173
|
-
name: base.slice(0, base.length - extension.length)
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
//#endregion
|
|
178
|
-
//#region node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
|
|
179
|
-
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
180
|
-
module.exports = {
|
|
181
|
-
"name": "dotenv",
|
|
182
|
-
"version": "17.2.3",
|
|
183
|
-
"description": "Loads environment variables from .env file",
|
|
184
|
-
"main": "lib/main.js",
|
|
185
|
-
"types": "lib/main.d.ts",
|
|
186
|
-
"exports": {
|
|
187
|
-
".": {
|
|
188
|
-
"types": "./lib/main.d.ts",
|
|
189
|
-
"require": "./lib/main.js",
|
|
190
|
-
"default": "./lib/main.js"
|
|
191
|
-
},
|
|
192
|
-
"./config": "./config.js",
|
|
193
|
-
"./config.js": "./config.js",
|
|
194
|
-
"./lib/env-options": "./lib/env-options.js",
|
|
195
|
-
"./lib/env-options.js": "./lib/env-options.js",
|
|
196
|
-
"./lib/cli-options": "./lib/cli-options.js",
|
|
197
|
-
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
198
|
-
"./package.json": "./package.json"
|
|
199
|
-
},
|
|
200
|
-
"scripts": {
|
|
201
|
-
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
202
|
-
"lint": "standard",
|
|
203
|
-
"pretest": "npm run lint && npm run dts-check",
|
|
204
|
-
"test": "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
205
|
-
"test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
206
|
-
"prerelease": "npm test",
|
|
207
|
-
"release": "standard-version"
|
|
208
|
-
},
|
|
209
|
-
"repository": {
|
|
210
|
-
"type": "git",
|
|
211
|
-
"url": "git://github.com/motdotla/dotenv.git"
|
|
212
|
-
},
|
|
213
|
-
"homepage": "https://github.com/motdotla/dotenv#readme",
|
|
214
|
-
"funding": "https://dotenvx.com",
|
|
215
|
-
"keywords": [
|
|
216
|
-
"dotenv",
|
|
217
|
-
"env",
|
|
218
|
-
".env",
|
|
219
|
-
"environment",
|
|
220
|
-
"variables",
|
|
221
|
-
"config",
|
|
222
|
-
"settings"
|
|
223
|
-
],
|
|
224
|
-
"readmeFilename": "README.md",
|
|
225
|
-
"license": "BSD-2-Clause",
|
|
226
|
-
"devDependencies": {
|
|
227
|
-
"@types/node": "^18.11.3",
|
|
228
|
-
"decache": "^4.6.2",
|
|
229
|
-
"sinon": "^14.0.1",
|
|
230
|
-
"standard": "^17.0.0",
|
|
231
|
-
"standard-version": "^9.5.0",
|
|
232
|
-
"tap": "^19.2.0",
|
|
233
|
-
"typescript": "^4.8.4"
|
|
234
|
-
},
|
|
235
|
-
"engines": { "node": ">=12" },
|
|
236
|
-
"browser": { "fs": false }
|
|
237
|
-
};
|
|
238
|
-
}));
|
|
239
|
-
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js
|
|
242
|
-
var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
243
|
-
const fs$1 = __require("fs");
|
|
244
|
-
const path$1 = __require("path");
|
|
245
|
-
const os$1 = __require("os");
|
|
246
|
-
const crypto = __require("crypto");
|
|
247
|
-
const version = require_package().version;
|
|
248
|
-
const TIPS = [
|
|
249
|
-
"🔐 encrypt with Dotenvx: https://dotenvx.com",
|
|
250
|
-
"🔐 prevent committing .env to code: https://dotenvx.com/precommit",
|
|
251
|
-
"🔐 prevent building .env in docker: https://dotenvx.com/prebuild",
|
|
252
|
-
"📡 add observability to secrets: https://dotenvx.com/ops",
|
|
253
|
-
"👥 sync secrets across teammates & machines: https://dotenvx.com/ops",
|
|
254
|
-
"🗂️ backup and recover secrets: https://dotenvx.com/ops",
|
|
255
|
-
"✅ audit secrets and track compliance: https://dotenvx.com/ops",
|
|
256
|
-
"🔄 add secrets lifecycle management: https://dotenvx.com/ops",
|
|
257
|
-
"🔑 add access controls to secrets: https://dotenvx.com/ops",
|
|
258
|
-
"🛠️ run anywhere with `dotenvx run -- yourcommand`",
|
|
259
|
-
"⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
|
|
260
|
-
"⚙️ enable debug logging with { debug: true }",
|
|
261
|
-
"⚙️ override existing env vars with { override: true }",
|
|
262
|
-
"⚙️ suppress all logs with { quiet: true }",
|
|
263
|
-
"⚙️ write to custom object with { processEnv: myObject }",
|
|
264
|
-
"⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
|
|
265
|
-
];
|
|
266
|
-
function _getRandomTip() {
|
|
267
|
-
return TIPS[Math.floor(Math.random() * TIPS.length)];
|
|
268
|
-
}
|
|
269
|
-
function parseBoolean(value) {
|
|
270
|
-
if (typeof value === "string") return ![
|
|
271
|
-
"false",
|
|
272
|
-
"0",
|
|
273
|
-
"no",
|
|
274
|
-
"off",
|
|
275
|
-
""
|
|
276
|
-
].includes(value.toLowerCase());
|
|
277
|
-
return Boolean(value);
|
|
278
|
-
}
|
|
279
|
-
function supportsAnsi() {
|
|
280
|
-
return process.stdout.isTTY;
|
|
281
|
-
}
|
|
282
|
-
function dim(text) {
|
|
283
|
-
return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text;
|
|
284
|
-
}
|
|
285
|
-
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
286
|
-
function parse(src) {
|
|
287
|
-
const obj = {};
|
|
288
|
-
let lines = src.toString();
|
|
289
|
-
lines = lines.replace(/\r\n?/gm, "\n");
|
|
290
|
-
let match;
|
|
291
|
-
while ((match = LINE.exec(lines)) != null) {
|
|
292
|
-
const key = match[1];
|
|
293
|
-
let value = match[2] || "";
|
|
294
|
-
value = value.trim();
|
|
295
|
-
const maybeQuote = value[0];
|
|
296
|
-
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
|
|
297
|
-
if (maybeQuote === "\"") {
|
|
298
|
-
value = value.replace(/\\n/g, "\n");
|
|
299
|
-
value = value.replace(/\\r/g, "\r");
|
|
300
|
-
}
|
|
301
|
-
obj[key] = value;
|
|
302
|
-
}
|
|
303
|
-
return obj;
|
|
304
|
-
}
|
|
305
|
-
function _parseVault(options) {
|
|
306
|
-
options = options || {};
|
|
307
|
-
const vaultPath = _vaultPath(options);
|
|
308
|
-
options.path = vaultPath;
|
|
309
|
-
const result = DotenvModule.configDotenv(options);
|
|
310
|
-
if (!result.parsed) {
|
|
311
|
-
const err = /* @__PURE__ */ new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
312
|
-
err.code = "MISSING_DATA";
|
|
313
|
-
throw err;
|
|
314
|
-
}
|
|
315
|
-
const keys = _dotenvKey(options).split(",");
|
|
316
|
-
const length = keys.length;
|
|
317
|
-
let decrypted;
|
|
318
|
-
for (let i = 0; i < length; i++) try {
|
|
319
|
-
const attrs = _instructions(result, keys[i].trim());
|
|
320
|
-
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
321
|
-
break;
|
|
322
|
-
} catch (error) {
|
|
323
|
-
if (i + 1 >= length) throw error;
|
|
324
|
-
}
|
|
325
|
-
return DotenvModule.parse(decrypted);
|
|
326
|
-
}
|
|
327
|
-
function _warn(message) {
|
|
328
|
-
console.error(`[dotenv@${version}][WARN] ${message}`);
|
|
329
|
-
}
|
|
330
|
-
function _debug(message) {
|
|
331
|
-
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
332
|
-
}
|
|
333
|
-
function _log(message) {
|
|
334
|
-
console.log(`[dotenv@${version}] ${message}`);
|
|
335
|
-
}
|
|
336
|
-
function _dotenvKey(options) {
|
|
337
|
-
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) return options.DOTENV_KEY;
|
|
338
|
-
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) return process.env.DOTENV_KEY;
|
|
339
|
-
return "";
|
|
340
|
-
}
|
|
341
|
-
function _instructions(result, dotenvKey) {
|
|
342
|
-
let uri;
|
|
343
|
-
try {
|
|
344
|
-
uri = new URL(dotenvKey);
|
|
345
|
-
} catch (error) {
|
|
346
|
-
if (error.code === "ERR_INVALID_URL") {
|
|
347
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
348
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
349
|
-
throw err;
|
|
350
|
-
}
|
|
351
|
-
throw error;
|
|
352
|
-
}
|
|
353
|
-
const key = uri.password;
|
|
354
|
-
if (!key) {
|
|
355
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
356
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
357
|
-
throw err;
|
|
358
|
-
}
|
|
359
|
-
const environment = uri.searchParams.get("environment");
|
|
360
|
-
if (!environment) {
|
|
361
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
362
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
363
|
-
throw err;
|
|
364
|
-
}
|
|
365
|
-
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
366
|
-
const ciphertext = result.parsed[environmentKey];
|
|
367
|
-
if (!ciphertext) {
|
|
368
|
-
const err = /* @__PURE__ */ new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
369
|
-
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
370
|
-
throw err;
|
|
371
|
-
}
|
|
372
|
-
return {
|
|
373
|
-
ciphertext,
|
|
374
|
-
key
|
|
375
|
-
};
|
|
376
|
-
}
|
|
377
|
-
function _vaultPath(options) {
|
|
378
|
-
let possibleVaultPath = null;
|
|
379
|
-
if (options && options.path && options.path.length > 0) if (Array.isArray(options.path)) {
|
|
380
|
-
for (const filepath of options.path) if (fs$1.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
381
|
-
} else possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
382
|
-
else possibleVaultPath = path$1.resolve(process.cwd(), ".env.vault");
|
|
383
|
-
if (fs$1.existsSync(possibleVaultPath)) return possibleVaultPath;
|
|
384
|
-
return null;
|
|
385
|
-
}
|
|
386
|
-
function _resolveHome(envPath) {
|
|
387
|
-
return envPath[0] === "~" ? path$1.join(os$1.homedir(), envPath.slice(1)) : envPath;
|
|
388
|
-
}
|
|
389
|
-
function _configVault(options) {
|
|
390
|
-
const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
391
|
-
const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
392
|
-
if (debug || !quiet) _log("Loading env from encrypted .env.vault");
|
|
393
|
-
const parsed = DotenvModule._parseVault(options);
|
|
394
|
-
let processEnv = process.env;
|
|
395
|
-
if (options && options.processEnv != null) processEnv = options.processEnv;
|
|
396
|
-
DotenvModule.populate(processEnv, parsed, options);
|
|
397
|
-
return { parsed };
|
|
398
|
-
}
|
|
399
|
-
function configDotenv(options) {
|
|
400
|
-
const dotenvPath = path$1.resolve(process.cwd(), ".env");
|
|
401
|
-
let encoding = "utf8";
|
|
402
|
-
let processEnv = process.env;
|
|
403
|
-
if (options && options.processEnv != null) processEnv = options.processEnv;
|
|
404
|
-
let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
|
|
405
|
-
let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
|
|
406
|
-
if (options && options.encoding) encoding = options.encoding;
|
|
407
|
-
else if (debug) _debug("No encoding is specified. UTF-8 is used by default");
|
|
408
|
-
let optionPaths = [dotenvPath];
|
|
409
|
-
if (options && options.path) if (!Array.isArray(options.path)) optionPaths = [_resolveHome(options.path)];
|
|
410
|
-
else {
|
|
411
|
-
optionPaths = [];
|
|
412
|
-
for (const filepath of options.path) optionPaths.push(_resolveHome(filepath));
|
|
413
|
-
}
|
|
414
|
-
let lastError;
|
|
415
|
-
const parsedAll = {};
|
|
416
|
-
for (const path$2 of optionPaths) try {
|
|
417
|
-
const parsed = DotenvModule.parse(fs$1.readFileSync(path$2, { encoding }));
|
|
418
|
-
DotenvModule.populate(parsedAll, parsed, options);
|
|
419
|
-
} catch (e) {
|
|
420
|
-
if (debug) _debug(`Failed to load ${path$2} ${e.message}`);
|
|
421
|
-
lastError = e;
|
|
422
|
-
}
|
|
423
|
-
const populated = DotenvModule.populate(processEnv, parsedAll, options);
|
|
424
|
-
debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
|
|
425
|
-
quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
|
|
426
|
-
if (debug || !quiet) {
|
|
427
|
-
const keysCount = Object.keys(populated).length;
|
|
428
|
-
const shortPaths = [];
|
|
429
|
-
for (const filePath of optionPaths) try {
|
|
430
|
-
const relative$2 = path$1.relative(process.cwd(), filePath);
|
|
431
|
-
shortPaths.push(relative$2);
|
|
432
|
-
} catch (e) {
|
|
433
|
-
if (debug) _debug(`Failed to load ${filePath} ${e.message}`);
|
|
434
|
-
lastError = e;
|
|
435
|
-
}
|
|
436
|
-
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
|
|
437
|
-
}
|
|
438
|
-
if (lastError) return {
|
|
439
|
-
parsed: parsedAll,
|
|
440
|
-
error: lastError
|
|
441
|
-
};
|
|
442
|
-
else return { parsed: parsedAll };
|
|
443
|
-
}
|
|
444
|
-
function config(options) {
|
|
445
|
-
if (_dotenvKey(options).length === 0) return DotenvModule.configDotenv(options);
|
|
446
|
-
const vaultPath = _vaultPath(options);
|
|
447
|
-
if (!vaultPath) {
|
|
448
|
-
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
449
|
-
return DotenvModule.configDotenv(options);
|
|
450
|
-
}
|
|
451
|
-
return DotenvModule._configVault(options);
|
|
452
|
-
}
|
|
453
|
-
function decrypt(encrypted, keyStr) {
|
|
454
|
-
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
455
|
-
let ciphertext = Buffer.from(encrypted, "base64");
|
|
456
|
-
const nonce = ciphertext.subarray(0, 12);
|
|
457
|
-
const authTag = ciphertext.subarray(-16);
|
|
458
|
-
ciphertext = ciphertext.subarray(12, -16);
|
|
459
|
-
try {
|
|
460
|
-
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
461
|
-
aesgcm.setAuthTag(authTag);
|
|
462
|
-
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
463
|
-
} catch (error) {
|
|
464
|
-
const isRange = error instanceof RangeError;
|
|
465
|
-
const invalidKeyLength = error.message === "Invalid key length";
|
|
466
|
-
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
467
|
-
if (isRange || invalidKeyLength) {
|
|
468
|
-
const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
469
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
470
|
-
throw err;
|
|
471
|
-
} else if (decryptionFailed) {
|
|
472
|
-
const err = /* @__PURE__ */ new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
473
|
-
err.code = "DECRYPTION_FAILED";
|
|
474
|
-
throw err;
|
|
475
|
-
} else throw error;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
function populate(processEnv, parsed, options = {}) {
|
|
479
|
-
const debug = Boolean(options && options.debug);
|
|
480
|
-
const override = Boolean(options && options.override);
|
|
481
|
-
const populated = {};
|
|
482
|
-
if (typeof parsed !== "object") {
|
|
483
|
-
const err = /* @__PURE__ */ new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
484
|
-
err.code = "OBJECT_REQUIRED";
|
|
485
|
-
throw err;
|
|
486
|
-
}
|
|
487
|
-
for (const key of Object.keys(parsed)) if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
488
|
-
if (override === true) {
|
|
489
|
-
processEnv[key] = parsed[key];
|
|
490
|
-
populated[key] = parsed[key];
|
|
491
|
-
}
|
|
492
|
-
if (debug) if (override === true) _debug(`"${key}" is already defined and WAS overwritten`);
|
|
493
|
-
else _debug(`"${key}" is already defined and was NOT overwritten`);
|
|
494
|
-
} else {
|
|
495
|
-
processEnv[key] = parsed[key];
|
|
496
|
-
populated[key] = parsed[key];
|
|
497
|
-
}
|
|
498
|
-
return populated;
|
|
499
|
-
}
|
|
500
|
-
const DotenvModule = {
|
|
501
|
-
configDotenv,
|
|
502
|
-
_configVault,
|
|
503
|
-
_parseVault,
|
|
504
|
-
config,
|
|
505
|
-
decrypt,
|
|
506
|
-
parse,
|
|
507
|
-
populate
|
|
508
|
-
};
|
|
509
|
-
module.exports.configDotenv = DotenvModule.configDotenv;
|
|
510
|
-
module.exports._configVault = DotenvModule._configVault;
|
|
511
|
-
module.exports._parseVault = DotenvModule._parseVault;
|
|
512
|
-
module.exports.config = DotenvModule.config;
|
|
513
|
-
module.exports.decrypt = DotenvModule.decrypt;
|
|
514
|
-
module.exports.parse = DotenvModule.parse;
|
|
515
|
-
module.exports.populate = DotenvModule.populate;
|
|
516
|
-
module.exports = DotenvModule;
|
|
517
|
-
}));
|
|
518
|
-
|
|
519
|
-
//#endregion
|
|
520
|
-
//#region node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs
|
|
521
|
-
const nodeBuiltins = [
|
|
522
|
-
"_http_agent",
|
|
523
|
-
"_http_client",
|
|
524
|
-
"_http_common",
|
|
525
|
-
"_http_incoming",
|
|
526
|
-
"_http_outgoing",
|
|
527
|
-
"_http_server",
|
|
528
|
-
"_stream_duplex",
|
|
529
|
-
"_stream_passthrough",
|
|
530
|
-
"_stream_readable",
|
|
531
|
-
"_stream_transform",
|
|
532
|
-
"_stream_wrap",
|
|
533
|
-
"_stream_writable",
|
|
534
|
-
"_tls_common",
|
|
535
|
-
"_tls_wrap",
|
|
536
|
-
"assert",
|
|
537
|
-
"assert/strict",
|
|
538
|
-
"async_hooks",
|
|
539
|
-
"buffer",
|
|
540
|
-
"child_process",
|
|
541
|
-
"cluster",
|
|
542
|
-
"console",
|
|
543
|
-
"constants",
|
|
544
|
-
"crypto",
|
|
545
|
-
"dgram",
|
|
546
|
-
"diagnostics_channel",
|
|
547
|
-
"dns",
|
|
548
|
-
"dns/promises",
|
|
549
|
-
"domain",
|
|
550
|
-
"events",
|
|
551
|
-
"fs",
|
|
552
|
-
"fs/promises",
|
|
553
|
-
"http",
|
|
554
|
-
"http2",
|
|
555
|
-
"https",
|
|
556
|
-
"inspector",
|
|
557
|
-
"inspector/promises",
|
|
558
|
-
"module",
|
|
559
|
-
"net",
|
|
560
|
-
"os",
|
|
561
|
-
"path",
|
|
562
|
-
"path/posix",
|
|
563
|
-
"path/win32",
|
|
564
|
-
"perf_hooks",
|
|
565
|
-
"process",
|
|
566
|
-
"punycode",
|
|
567
|
-
"querystring",
|
|
568
|
-
"readline",
|
|
569
|
-
"readline/promises",
|
|
570
|
-
"repl",
|
|
571
|
-
"stream",
|
|
572
|
-
"stream/consumers",
|
|
573
|
-
"stream/promises",
|
|
574
|
-
"stream/web",
|
|
575
|
-
"string_decoder",
|
|
576
|
-
"sys",
|
|
577
|
-
"timers",
|
|
578
|
-
"timers/promises",
|
|
579
|
-
"tls",
|
|
580
|
-
"trace_events",
|
|
581
|
-
"tty",
|
|
582
|
-
"url",
|
|
583
|
-
"util",
|
|
584
|
-
"util/types",
|
|
585
|
-
"v8",
|
|
586
|
-
"vm",
|
|
587
|
-
"wasi",
|
|
588
|
-
"worker_threads",
|
|
589
|
-
"zlib"
|
|
590
|
-
];
|
|
591
|
-
const own$1 = {}.hasOwnProperty;
|
|
592
|
-
const classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
593
|
-
const kTypes = new Set([
|
|
594
|
-
"string",
|
|
595
|
-
"function",
|
|
596
|
-
"number",
|
|
597
|
-
"object",
|
|
598
|
-
"Function",
|
|
599
|
-
"Object",
|
|
600
|
-
"boolean",
|
|
601
|
-
"bigint",
|
|
602
|
-
"symbol"
|
|
603
|
-
]);
|
|
604
|
-
const messages = /* @__PURE__ */ new Map();
|
|
605
|
-
const nodeInternalPrefix = "__node_internal_";
|
|
606
|
-
let userStackTraceLimit;
|
|
607
|
-
/**
|
|
608
|
-
* Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
|
|
609
|
-
* We cannot use Intl.ListFormat because it's not available in
|
|
610
|
-
* --without-intl builds.
|
|
611
|
-
*
|
|
612
|
-
* @param {Array<string>} array
|
|
613
|
-
* An array of strings.
|
|
614
|
-
* @param {string} [type]
|
|
615
|
-
* The list type to be inserted before the last element.
|
|
616
|
-
* @returns {string}
|
|
617
|
-
*/
|
|
618
|
-
function formatList(array, type$1 = "and") {
|
|
619
|
-
return array.length < 3 ? array.join(` ${type$1} `) : `${array.slice(0, -1).join(", ")}, ${type$1} ${array.at(-1)}`;
|
|
620
|
-
}
|
|
621
|
-
/**
|
|
622
|
-
* Utility function for registering the error codes.
|
|
623
|
-
*/
|
|
624
|
-
function createError(sym, value, constructor) {
|
|
625
|
-
messages.set(sym, value);
|
|
626
|
-
return makeNodeErrorWithCode(constructor, sym);
|
|
627
|
-
}
|
|
628
|
-
function makeNodeErrorWithCode(Base, key) {
|
|
629
|
-
return function NodeError(...parameters) {
|
|
630
|
-
const limit = Error.stackTraceLimit;
|
|
631
|
-
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
|
|
632
|
-
const error = new Base();
|
|
633
|
-
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
|
|
634
|
-
const message = getMessage(key, parameters, error);
|
|
635
|
-
Object.defineProperties(error, {
|
|
636
|
-
message: {
|
|
637
|
-
value: message,
|
|
638
|
-
enumerable: false,
|
|
639
|
-
writable: true,
|
|
640
|
-
configurable: true
|
|
641
|
-
},
|
|
642
|
-
toString: {
|
|
643
|
-
value() {
|
|
644
|
-
return `${this.name} [${key}]: ${this.message}`;
|
|
645
|
-
},
|
|
646
|
-
enumerable: false,
|
|
647
|
-
writable: true,
|
|
648
|
-
configurable: true
|
|
649
|
-
}
|
|
650
|
-
});
|
|
651
|
-
captureLargerStackTrace(error);
|
|
652
|
-
error.code = key;
|
|
653
|
-
return error;
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
function isErrorStackTraceLimitWritable() {
|
|
657
|
-
try {
|
|
658
|
-
if (v8.startupSnapshot.isBuildingSnapshot()) return false;
|
|
659
|
-
} catch {}
|
|
660
|
-
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
661
|
-
if (desc === void 0) return Object.isExtensible(Error);
|
|
662
|
-
return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
|
|
663
|
-
}
|
|
664
|
-
/**
|
|
665
|
-
* This function removes unnecessary frames from Node.js core errors.
|
|
666
|
-
*/
|
|
667
|
-
function hideStackFrames(wrappedFunction) {
|
|
668
|
-
const hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
669
|
-
Object.defineProperty(wrappedFunction, "name", { value: hidden });
|
|
670
|
-
return wrappedFunction;
|
|
671
|
-
}
|
|
672
|
-
const captureLargerStackTrace = hideStackFrames(function(error) {
|
|
673
|
-
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
674
|
-
if (stackTraceLimitIsWritable) {
|
|
675
|
-
userStackTraceLimit = Error.stackTraceLimit;
|
|
676
|
-
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
677
|
-
}
|
|
678
|
-
Error.captureStackTrace(error);
|
|
679
|
-
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
|
|
680
|
-
return error;
|
|
681
|
-
});
|
|
682
|
-
function getMessage(key, parameters, self) {
|
|
683
|
-
const message = messages.get(key);
|
|
684
|
-
assert.ok(message !== void 0, "expected `message` to be found");
|
|
685
|
-
if (typeof message === "function") {
|
|
686
|
-
assert.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
|
|
687
|
-
return Reflect.apply(message, self, parameters);
|
|
688
|
-
}
|
|
689
|
-
const regex = /%[dfijoOs]/g;
|
|
690
|
-
let expectedLength = 0;
|
|
691
|
-
while (regex.exec(message) !== null) expectedLength++;
|
|
692
|
-
assert.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
|
|
693
|
-
if (parameters.length === 0) return message;
|
|
694
|
-
parameters.unshift(message);
|
|
695
|
-
return Reflect.apply(format, null, parameters);
|
|
696
|
-
}
|
|
697
|
-
/**
|
|
698
|
-
* Determine the specific type of a value for type-mismatch errors.
|
|
699
|
-
*/
|
|
700
|
-
function determineSpecificType(value) {
|
|
701
|
-
if (value === null || value === void 0) return String(value);
|
|
702
|
-
if (typeof value === "function" && value.name) return `function ${value.name}`;
|
|
703
|
-
if (typeof value === "object") {
|
|
704
|
-
if (value.constructor && value.constructor.name) return `an instance of ${value.constructor.name}`;
|
|
705
|
-
return `${inspect(value, { depth: -1 })}`;
|
|
706
|
-
}
|
|
707
|
-
let inspected = inspect(value, { colors: false });
|
|
708
|
-
if (inspected.length > 28) inspected = `${inspected.slice(0, 25)}...`;
|
|
709
|
-
return `type ${typeof value} (${inspected})`;
|
|
710
|
-
}
|
|
711
|
-
createError("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
|
|
712
|
-
assert.ok(typeof name === "string", "'name' must be a string");
|
|
713
|
-
if (!Array.isArray(expected)) expected = [expected];
|
|
714
|
-
let message = "The ";
|
|
715
|
-
if (name.endsWith(" argument")) message += `${name} `;
|
|
716
|
-
else {
|
|
717
|
-
const type$1 = name.includes(".") ? "property" : "argument";
|
|
718
|
-
message += `"${name}" ${type$1} `;
|
|
719
|
-
}
|
|
720
|
-
message += "must be ";
|
|
721
|
-
const types = [];
|
|
722
|
-
const instances = [];
|
|
723
|
-
const other = [];
|
|
724
|
-
for (const value of expected) {
|
|
725
|
-
assert.ok(typeof value === "string", "All expected entries have to be of type string");
|
|
726
|
-
if (kTypes.has(value)) types.push(value.toLowerCase());
|
|
727
|
-
else if (classRegExp.exec(value) === null) {
|
|
728
|
-
assert.ok(value !== "object", "The value \"object\" should be written as \"Object\"");
|
|
729
|
-
other.push(value);
|
|
730
|
-
} else instances.push(value);
|
|
731
|
-
}
|
|
732
|
-
if (instances.length > 0) {
|
|
733
|
-
const pos = types.indexOf("object");
|
|
734
|
-
if (pos !== -1) {
|
|
735
|
-
types.slice(pos, 1);
|
|
736
|
-
instances.push("Object");
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
if (types.length > 0) {
|
|
740
|
-
message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
|
|
741
|
-
if (instances.length > 0 || other.length > 0) message += " or ";
|
|
742
|
-
}
|
|
743
|
-
if (instances.length > 0) {
|
|
744
|
-
message += `an instance of ${formatList(instances, "or")}`;
|
|
745
|
-
if (other.length > 0) message += " or ";
|
|
746
|
-
}
|
|
747
|
-
if (other.length > 0) if (other.length > 1) message += `one of ${formatList(other, "or")}`;
|
|
748
|
-
else {
|
|
749
|
-
if (other[0]?.toLowerCase() !== other[0]) message += "an ";
|
|
750
|
-
message += `${other[0]}`;
|
|
751
|
-
}
|
|
752
|
-
message += `. Received ${determineSpecificType(actual)}`;
|
|
753
|
-
return message;
|
|
754
|
-
}, TypeError);
|
|
755
|
-
const ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
756
|
-
"ERR_INVALID_MODULE_SPECIFIER",
|
|
757
|
-
/**
|
|
758
|
-
* @param {string} request
|
|
759
|
-
* @param {string} reason
|
|
760
|
-
* @param {string} [base]
|
|
761
|
-
*/
|
|
762
|
-
(request, reason, base) => {
|
|
763
|
-
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
764
|
-
},
|
|
765
|
-
TypeError
|
|
766
|
-
);
|
|
767
|
-
const ERR_INVALID_PACKAGE_CONFIG = createError("ERR_INVALID_PACKAGE_CONFIG", (path$1$1, base, message) => {
|
|
768
|
-
return `Invalid package config ${path$1$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
769
|
-
}, Error);
|
|
770
|
-
const ERR_INVALID_PACKAGE_TARGET = createError("ERR_INVALID_PACKAGE_TARGET", (packagePath, key, target, isImport = false, base) => {
|
|
771
|
-
const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
772
|
-
if (key === ".") {
|
|
773
|
-
assert.ok(isImport === false);
|
|
774
|
-
return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
|
|
775
|
-
}
|
|
776
|
-
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
|
|
777
|
-
}, Error);
|
|
778
|
-
const ERR_MODULE_NOT_FOUND = createError("ERR_MODULE_NOT_FOUND", (path$1$1, base, exactUrl = false) => {
|
|
779
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${path$1$1}' imported from ${base}`;
|
|
780
|
-
}, Error);
|
|
781
|
-
createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
|
|
782
|
-
const ERR_PACKAGE_IMPORT_NOT_DEFINED = createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => {
|
|
783
|
-
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
|
|
784
|
-
}, TypeError);
|
|
785
|
-
const ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
|
|
786
|
-
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
787
|
-
/**
|
|
788
|
-
* @param {string} packagePath
|
|
789
|
-
* @param {string} subpath
|
|
790
|
-
* @param {string} [base]
|
|
791
|
-
*/
|
|
792
|
-
(packagePath, subpath, base) => {
|
|
793
|
-
if (subpath === ".") return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
794
|
-
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
795
|
-
},
|
|
796
|
-
Error
|
|
797
|
-
);
|
|
798
|
-
const ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported resolving ES modules imported from %s", Error);
|
|
799
|
-
const ERR_UNSUPPORTED_RESOLVE_REQUEST = createError("ERR_UNSUPPORTED_RESOLVE_REQUEST", "Failed to resolve module specifier \"%s\" from \"%s\": Invalid relative URL or base scheme is not hierarchical.", TypeError);
|
|
800
|
-
const ERR_UNKNOWN_FILE_EXTENSION = createError("ERR_UNKNOWN_FILE_EXTENSION", (extension, path$1$1) => {
|
|
801
|
-
return `Unknown file extension "${extension}" for ${path$1$1}`;
|
|
802
|
-
}, TypeError);
|
|
803
|
-
createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
|
|
804
|
-
let inspected = inspect(value);
|
|
805
|
-
if (inspected.length > 128) inspected = `${inspected.slice(0, 128)}...`;
|
|
806
|
-
return `The ${name.includes(".") ? "property" : "argument"} '${name}' ${reason}. Received ${inspected}`;
|
|
807
|
-
}, TypeError);
|
|
808
|
-
const hasOwnProperty$1 = {}.hasOwnProperty;
|
|
809
|
-
const cache = /* @__PURE__ */ new Map();
|
|
810
|
-
function read$1(jsonPath, { base, specifier }) {
|
|
811
|
-
const existing = cache.get(jsonPath);
|
|
812
|
-
if (existing) return existing;
|
|
813
|
-
let string;
|
|
814
|
-
try {
|
|
815
|
-
string = fs.readFileSync(path.toNamespacedPath(jsonPath), "utf8");
|
|
816
|
-
} catch (error) {
|
|
817
|
-
const exception = error;
|
|
818
|
-
if (exception.code !== "ENOENT") throw exception;
|
|
819
|
-
}
|
|
820
|
-
const result = {
|
|
821
|
-
exists: false,
|
|
822
|
-
pjsonPath: jsonPath,
|
|
823
|
-
main: void 0,
|
|
824
|
-
name: void 0,
|
|
825
|
-
type: "none",
|
|
826
|
-
exports: void 0,
|
|
827
|
-
imports: void 0
|
|
828
|
-
};
|
|
829
|
-
if (string !== void 0) {
|
|
830
|
-
let parsed;
|
|
831
|
-
try {
|
|
832
|
-
parsed = JSON.parse(string);
|
|
833
|
-
} catch (error_) {
|
|
834
|
-
const error = new ERR_INVALID_PACKAGE_CONFIG(jsonPath, (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), error_.message);
|
|
835
|
-
error.cause = error_;
|
|
836
|
-
throw error;
|
|
837
|
-
}
|
|
838
|
-
result.exists = true;
|
|
839
|
-
if (hasOwnProperty$1.call(parsed, "name") && typeof parsed.name === "string") result.name = parsed.name;
|
|
840
|
-
if (hasOwnProperty$1.call(parsed, "main") && typeof parsed.main === "string") result.main = parsed.main;
|
|
841
|
-
if (hasOwnProperty$1.call(parsed, "exports")) result.exports = parsed.exports;
|
|
842
|
-
if (hasOwnProperty$1.call(parsed, "imports")) result.imports = parsed.imports;
|
|
843
|
-
if (hasOwnProperty$1.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) result.type = parsed.type;
|
|
844
|
-
}
|
|
845
|
-
cache.set(jsonPath, result);
|
|
846
|
-
return result;
|
|
847
|
-
}
|
|
848
|
-
function getPackageScopeConfig(resolved) {
|
|
849
|
-
let packageJSONUrl = new URL("package.json", resolved);
|
|
850
|
-
while (true) {
|
|
851
|
-
if (packageJSONUrl.pathname.endsWith("node_modules/package.json")) break;
|
|
852
|
-
const packageConfig = read$1(fileURLToPath(packageJSONUrl), { specifier: resolved });
|
|
853
|
-
if (packageConfig.exists) return packageConfig;
|
|
854
|
-
const lastPackageJSONUrl = packageJSONUrl;
|
|
855
|
-
packageJSONUrl = new URL("../package.json", packageJSONUrl);
|
|
856
|
-
if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) break;
|
|
857
|
-
}
|
|
858
|
-
return {
|
|
859
|
-
pjsonPath: fileURLToPath(packageJSONUrl),
|
|
860
|
-
exists: false,
|
|
861
|
-
type: "none"
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
const hasOwnProperty = {}.hasOwnProperty;
|
|
865
|
-
const extensionFormatMap = {
|
|
866
|
-
__proto__: null,
|
|
867
|
-
".json": "json",
|
|
868
|
-
".cjs": "commonjs",
|
|
869
|
-
".cts": "commonjs",
|
|
870
|
-
".js": "module",
|
|
871
|
-
".ts": "module",
|
|
872
|
-
".mts": "module",
|
|
873
|
-
".mjs": "module"
|
|
874
|
-
};
|
|
875
|
-
const protocolHandlers = {
|
|
876
|
-
__proto__: null,
|
|
877
|
-
"data:": getDataProtocolModuleFormat,
|
|
878
|
-
"file:": getFileProtocolModuleFormat,
|
|
879
|
-
"node:": () => "builtin"
|
|
880
|
-
};
|
|
881
|
-
function mimeToFormat(mime) {
|
|
882
|
-
if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)) return "module";
|
|
883
|
-
if (mime === "application/json") return "json";
|
|
884
|
-
return null;
|
|
885
|
-
}
|
|
886
|
-
function getDataProtocolModuleFormat(parsed) {
|
|
887
|
-
const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [
|
|
888
|
-
null,
|
|
889
|
-
null,
|
|
890
|
-
null
|
|
891
|
-
];
|
|
892
|
-
return mimeToFormat(mime);
|
|
893
|
-
}
|
|
894
|
-
/**
|
|
895
|
-
* Returns the file extension from a URL.
|
|
896
|
-
*
|
|
897
|
-
* Should give similar result to
|
|
898
|
-
* `require('node:path').extname(require('node:url').fileURLToPath(url))`
|
|
899
|
-
* when used with a `file:` URL.
|
|
900
|
-
*
|
|
901
|
-
*/
|
|
902
|
-
function extname$1(url) {
|
|
903
|
-
const pathname = url.pathname;
|
|
904
|
-
let index = pathname.length;
|
|
905
|
-
while (index--) {
|
|
906
|
-
const code = pathname.codePointAt(index);
|
|
907
|
-
if (code === 47) return "";
|
|
908
|
-
if (code === 46) return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
|
|
909
|
-
}
|
|
910
|
-
return "";
|
|
911
|
-
}
|
|
912
|
-
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
913
|
-
const ext = extname$1(url);
|
|
914
|
-
if (ext === ".js") {
|
|
915
|
-
const { type: packageType } = getPackageScopeConfig(url);
|
|
916
|
-
if (packageType !== "none") return packageType;
|
|
917
|
-
return "commonjs";
|
|
918
|
-
}
|
|
919
|
-
if (ext === "") {
|
|
920
|
-
const { type: packageType } = getPackageScopeConfig(url);
|
|
921
|
-
if (packageType === "none" || packageType === "commonjs") return "commonjs";
|
|
922
|
-
return "module";
|
|
923
|
-
}
|
|
924
|
-
const format$1 = extensionFormatMap[ext];
|
|
925
|
-
if (format$1) return format$1;
|
|
926
|
-
if (ignoreErrors) return;
|
|
927
|
-
throw new ERR_UNKNOWN_FILE_EXTENSION(ext, fileURLToPath(url));
|
|
928
|
-
}
|
|
929
|
-
function defaultGetFormatWithoutErrors(url, context) {
|
|
930
|
-
const protocol = url.protocol;
|
|
931
|
-
if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
|
|
932
|
-
return protocolHandlers[protocol](url, context, true) || null;
|
|
933
|
-
}
|
|
934
|
-
const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
|
|
935
|
-
const own = {}.hasOwnProperty;
|
|
936
|
-
const invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
|
|
937
|
-
const deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
|
|
938
|
-
const invalidPackageNameRegEx = /^\.|%|\\/;
|
|
939
|
-
const patternRegEx = /\*/g;
|
|
940
|
-
const encodedSeparatorRegEx = /%2f|%5c/i;
|
|
941
|
-
const emittedPackageWarnings = /* @__PURE__ */ new Set();
|
|
942
|
-
const doubleSlashRegEx = /[/\\]{2}/;
|
|
943
|
-
function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
|
|
944
|
-
if (process$1.noDeprecation) return;
|
|
945
|
-
const pjsonPath = fileURLToPath(packageJsonUrl);
|
|
946
|
-
const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
|
|
947
|
-
process$1.emitWarning(`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
|
|
948
|
-
}
|
|
949
|
-
function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
950
|
-
if (process$1.noDeprecation) return;
|
|
951
|
-
if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
|
|
952
|
-
const urlPath = fileURLToPath(url.href);
|
|
953
|
-
const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
|
|
954
|
-
const basePath = fileURLToPath(base);
|
|
955
|
-
if (!main) process$1.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
956
|
-
else if (path.resolve(packagePath, main) !== urlPath) process$1.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
957
|
-
}
|
|
958
|
-
function tryStatSync(path$1$1) {
|
|
959
|
-
try {
|
|
960
|
-
return statSync(path$1$1);
|
|
961
|
-
} catch {}
|
|
962
|
-
}
|
|
963
|
-
/**
|
|
964
|
-
* Legacy CommonJS main resolution:
|
|
965
|
-
* 1. let M = pkg_url + (json main field)
|
|
966
|
-
* 2. TRY(M, M.js, M.json, M.node)
|
|
967
|
-
* 3. TRY(M/index.js, M/index.json, M/index.node)
|
|
968
|
-
* 4. TRY(pkg_url/index.js, pkg_url/index.json, pkg_url/index.node)
|
|
969
|
-
* 5. NOT_FOUND
|
|
970
|
-
*/
|
|
971
|
-
function fileExists(url) {
|
|
972
|
-
const stats = statSync(url, { throwIfNoEntry: false });
|
|
973
|
-
const isFile = stats ? stats.isFile() : void 0;
|
|
974
|
-
return isFile === null || isFile === void 0 ? false : isFile;
|
|
975
|
-
}
|
|
976
|
-
function legacyMainResolve(packageJsonUrl, packageConfig, base) {
|
|
977
|
-
let guess;
|
|
978
|
-
if (packageConfig.main !== void 0) {
|
|
979
|
-
guess = new URL$1(packageConfig.main, packageJsonUrl);
|
|
980
|
-
if (fileExists(guess)) return guess;
|
|
981
|
-
const tries$1 = [
|
|
982
|
-
`./${packageConfig.main}.js`,
|
|
983
|
-
`./${packageConfig.main}.json`,
|
|
984
|
-
`./${packageConfig.main}.node`,
|
|
985
|
-
`./${packageConfig.main}/index.js`,
|
|
986
|
-
`./${packageConfig.main}/index.json`,
|
|
987
|
-
`./${packageConfig.main}/index.node`
|
|
988
|
-
];
|
|
989
|
-
let i$1 = -1;
|
|
990
|
-
while (++i$1 < tries$1.length) {
|
|
991
|
-
guess = new URL$1(tries$1[i$1], packageJsonUrl);
|
|
992
|
-
if (fileExists(guess)) break;
|
|
993
|
-
guess = void 0;
|
|
994
|
-
}
|
|
995
|
-
if (guess) {
|
|
996
|
-
emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
|
|
997
|
-
return guess;
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
const tries = [
|
|
1001
|
-
"./index.js",
|
|
1002
|
-
"./index.json",
|
|
1003
|
-
"./index.node"
|
|
1004
|
-
];
|
|
1005
|
-
let i = -1;
|
|
1006
|
-
while (++i < tries.length) {
|
|
1007
|
-
guess = new URL$1(tries[i], packageJsonUrl);
|
|
1008
|
-
if (fileExists(guess)) break;
|
|
1009
|
-
guess = void 0;
|
|
1010
|
-
}
|
|
1011
|
-
if (guess) {
|
|
1012
|
-
emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
|
|
1013
|
-
return guess;
|
|
1014
|
-
}
|
|
1015
|
-
throw new ERR_MODULE_NOT_FOUND(fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
|
|
1016
|
-
}
|
|
1017
|
-
function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
1018
|
-
if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, String.raw`must not include encoded "/" or "\" characters`, fileURLToPath(base));
|
|
1019
|
-
let filePath;
|
|
1020
|
-
try {
|
|
1021
|
-
filePath = fileURLToPath(resolved);
|
|
1022
|
-
} catch (error) {
|
|
1023
|
-
Object.defineProperty(error, "input", { value: String(resolved) });
|
|
1024
|
-
Object.defineProperty(error, "module", { value: String(base) });
|
|
1025
|
-
throw error;
|
|
1026
|
-
}
|
|
1027
|
-
const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
|
|
1028
|
-
if (stats && stats.isDirectory()) {
|
|
1029
|
-
const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath(base));
|
|
1030
|
-
error.url = String(resolved);
|
|
1031
|
-
throw error;
|
|
1032
|
-
}
|
|
1033
|
-
if (!stats || !stats.isFile()) {
|
|
1034
|
-
const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath(base), true);
|
|
1035
|
-
error.url = String(resolved);
|
|
1036
|
-
throw error;
|
|
1037
|
-
}
|
|
1038
|
-
if (!preserveSymlinks) {
|
|
1039
|
-
const real = realpathSync(filePath);
|
|
1040
|
-
const { search, hash } = resolved;
|
|
1041
|
-
resolved = pathToFileURL(real + (filePath.endsWith(path.sep) ? "/" : ""));
|
|
1042
|
-
resolved.search = search;
|
|
1043
|
-
resolved.hash = hash;
|
|
1044
|
-
}
|
|
1045
|
-
return resolved;
|
|
1046
|
-
}
|
|
1047
|
-
function importNotDefined(specifier, packageJsonUrl, base) {
|
|
1048
|
-
return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && fileURLToPath(new URL$1(".", packageJsonUrl)), fileURLToPath(base));
|
|
1049
|
-
}
|
|
1050
|
-
function exportsNotFound(subpath, packageJsonUrl, base) {
|
|
1051
|
-
return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, base && fileURLToPath(base));
|
|
1052
|
-
}
|
|
1053
|
-
function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
|
|
1054
|
-
throw new ERR_INVALID_MODULE_SPECIFIER(request, `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath(packageJsonUrl)}`, base && fileURLToPath(base));
|
|
1055
|
-
}
|
|
1056
|
-
function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
|
|
1057
|
-
target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
|
|
1058
|
-
return new ERR_INVALID_PACKAGE_TARGET(fileURLToPath(new URL$1(".", packageJsonUrl)), subpath, target, internal, base && fileURLToPath(base));
|
|
1059
|
-
}
|
|
1060
|
-
function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
|
|
1061
|
-
if (subpath !== "" && !pattern && target.at(-1) !== "/") throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
1062
|
-
if (!target.startsWith("./")) {
|
|
1063
|
-
if (internal && !target.startsWith("../") && !target.startsWith("/")) {
|
|
1064
|
-
let isURL = false;
|
|
1065
|
-
try {
|
|
1066
|
-
new URL$1(target);
|
|
1067
|
-
isURL = true;
|
|
1068
|
-
} catch {}
|
|
1069
|
-
if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
|
|
1070
|
-
}
|
|
1071
|
-
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
1072
|
-
}
|
|
1073
|
-
if (invalidSegmentRegEx.exec(target.slice(2)) !== null) if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
|
|
1074
|
-
if (!isPathMap) {
|
|
1075
|
-
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
1076
|
-
emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, true);
|
|
1077
|
-
}
|
|
1078
|
-
} else throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
1079
|
-
const resolved = new URL$1(target, packageJsonUrl);
|
|
1080
|
-
const resolvedPath = resolved.pathname;
|
|
1081
|
-
const packagePath = new URL$1(".", packageJsonUrl).pathname;
|
|
1082
|
-
if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
1083
|
-
if (subpath === "") return resolved;
|
|
1084
|
-
if (invalidSegmentRegEx.exec(subpath) !== null) {
|
|
1085
|
-
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
1086
|
-
if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
|
|
1087
|
-
if (!isPathMap) emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, false);
|
|
1088
|
-
} else throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
|
|
1089
|
-
}
|
|
1090
|
-
if (pattern) return new URL$1(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
|
|
1091
|
-
return new URL$1(subpath, resolved);
|
|
1092
|
-
}
|
|
1093
|
-
function isArrayIndex(key) {
|
|
1094
|
-
const keyNumber = Number(key);
|
|
1095
|
-
if (`${keyNumber}` !== key) return false;
|
|
1096
|
-
return keyNumber >= 0 && keyNumber < 4294967295;
|
|
1097
|
-
}
|
|
1098
|
-
function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
|
|
1099
|
-
if (typeof target === "string") return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
|
|
1100
|
-
if (Array.isArray(target)) {
|
|
1101
|
-
const targetList = target;
|
|
1102
|
-
if (targetList.length === 0) return null;
|
|
1103
|
-
let lastException;
|
|
1104
|
-
let i = -1;
|
|
1105
|
-
while (++i < targetList.length) {
|
|
1106
|
-
const targetItem = targetList[i];
|
|
1107
|
-
let resolveResult;
|
|
1108
|
-
try {
|
|
1109
|
-
resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
|
|
1110
|
-
} catch (error) {
|
|
1111
|
-
const exception = error;
|
|
1112
|
-
lastException = exception;
|
|
1113
|
-
if (exception.code === "ERR_INVALID_PACKAGE_TARGET") continue;
|
|
1114
|
-
throw error;
|
|
1115
|
-
}
|
|
1116
|
-
if (resolveResult === void 0) continue;
|
|
1117
|
-
if (resolveResult === null) {
|
|
1118
|
-
lastException = null;
|
|
1119
|
-
continue;
|
|
1120
|
-
}
|
|
1121
|
-
return resolveResult;
|
|
1122
|
-
}
|
|
1123
|
-
if (lastException === void 0 || lastException === null) return null;
|
|
1124
|
-
throw lastException;
|
|
1125
|
-
}
|
|
1126
|
-
if (typeof target === "object" && target !== null) {
|
|
1127
|
-
const keys = Object.getOwnPropertyNames(target);
|
|
1128
|
-
let i = -1;
|
|
1129
|
-
while (++i < keys.length) {
|
|
1130
|
-
const key = keys[i];
|
|
1131
|
-
if (isArrayIndex(key)) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), fileURLToPath(base), "\"exports\" cannot contain numeric property keys.");
|
|
1132
|
-
}
|
|
1133
|
-
i = -1;
|
|
1134
|
-
while (++i < keys.length) {
|
|
1135
|
-
const key = keys[i];
|
|
1136
|
-
if (key === "default" || conditions && conditions.has(key)) {
|
|
1137
|
-
const conditionalTarget = target[key];
|
|
1138
|
-
const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
|
|
1139
|
-
if (resolveResult === void 0) continue;
|
|
1140
|
-
return resolveResult;
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
return null;
|
|
1144
|
-
}
|
|
1145
|
-
if (target === null) return null;
|
|
1146
|
-
throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
|
|
1147
|
-
}
|
|
1148
|
-
function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
|
|
1149
|
-
if (typeof exports === "string" || Array.isArray(exports)) return true;
|
|
1150
|
-
if (typeof exports !== "object" || exports === null) return false;
|
|
1151
|
-
const keys = Object.getOwnPropertyNames(exports);
|
|
1152
|
-
let isConditionalSugar = false;
|
|
1153
|
-
let i = 0;
|
|
1154
|
-
let keyIndex = -1;
|
|
1155
|
-
while (++keyIndex < keys.length) {
|
|
1156
|
-
const key = keys[keyIndex];
|
|
1157
|
-
const currentIsConditionalSugar = key === "" || key[0] !== ".";
|
|
1158
|
-
if (i++ === 0) isConditionalSugar = currentIsConditionalSugar;
|
|
1159
|
-
else if (isConditionalSugar !== currentIsConditionalSugar) throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(packageJsonUrl), fileURLToPath(base), "\"exports\" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.");
|
|
1160
|
-
}
|
|
1161
|
-
return isConditionalSugar;
|
|
1162
|
-
}
|
|
1163
|
-
function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
|
|
1164
|
-
if (process$1.noDeprecation) return;
|
|
1165
|
-
const pjsonPath = fileURLToPath(pjsonUrl);
|
|
1166
|
-
if (emittedPackageWarnings.has(pjsonPath + "|" + match)) return;
|
|
1167
|
-
emittedPackageWarnings.add(pjsonPath + "|" + match);
|
|
1168
|
-
process$1.emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the "exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
|
|
1169
|
-
}
|
|
1170
|
-
function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
|
|
1171
|
-
let exports = packageConfig.exports;
|
|
1172
|
-
if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) exports = { ".": exports };
|
|
1173
|
-
if (own.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
|
|
1174
|
-
const target = exports[packageSubpath];
|
|
1175
|
-
const resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, false, false, false, conditions);
|
|
1176
|
-
if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
1177
|
-
return resolveResult;
|
|
1178
|
-
}
|
|
1179
|
-
let bestMatch = "";
|
|
1180
|
-
let bestMatchSubpath = "";
|
|
1181
|
-
const keys = Object.getOwnPropertyNames(exports);
|
|
1182
|
-
let i = -1;
|
|
1183
|
-
while (++i < keys.length) {
|
|
1184
|
-
const key = keys[i];
|
|
1185
|
-
const patternIndex = key.indexOf("*");
|
|
1186
|
-
if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
|
|
1187
|
-
if (packageSubpath.endsWith("/")) emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
|
|
1188
|
-
const patternTrailer = key.slice(patternIndex + 1);
|
|
1189
|
-
if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
1190
|
-
bestMatch = key;
|
|
1191
|
-
bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
if (bestMatch) {
|
|
1196
|
-
const target = exports[bestMatch];
|
|
1197
|
-
const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith("/"), conditions);
|
|
1198
|
-
if (resolveResult === null || resolveResult === void 0) throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
1199
|
-
return resolveResult;
|
|
1200
|
-
}
|
|
1201
|
-
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
1202
|
-
}
|
|
1203
|
-
function patternKeyCompare(a, b$1) {
|
|
1204
|
-
const aPatternIndex = a.indexOf("*");
|
|
1205
|
-
const bPatternIndex = b$1.indexOf("*");
|
|
1206
|
-
const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
|
1207
|
-
const baseLengthB = bPatternIndex === -1 ? b$1.length : bPatternIndex + 1;
|
|
1208
|
-
if (baseLengthA > baseLengthB) return -1;
|
|
1209
|
-
if (baseLengthB > baseLengthA) return 1;
|
|
1210
|
-
if (aPatternIndex === -1) return 1;
|
|
1211
|
-
if (bPatternIndex === -1) return -1;
|
|
1212
|
-
if (a.length > b$1.length) return -1;
|
|
1213
|
-
if (b$1.length > a.length) return 1;
|
|
1214
|
-
return 0;
|
|
1215
|
-
}
|
|
1216
|
-
function packageImportsResolve(name, base, conditions) {
|
|
1217
|
-
if (name === "#" || name.startsWith("#/") || name.endsWith("/")) throw new ERR_INVALID_MODULE_SPECIFIER(name, "is not a valid internal imports specifier name", fileURLToPath(base));
|
|
1218
|
-
let packageJsonUrl;
|
|
1219
|
-
const packageConfig = getPackageScopeConfig(base);
|
|
1220
|
-
if (packageConfig.exists) {
|
|
1221
|
-
packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
|
|
1222
|
-
const imports = packageConfig.imports;
|
|
1223
|
-
if (imports) if (own.call(imports, name) && !name.includes("*")) {
|
|
1224
|
-
const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, false, true, false, conditions);
|
|
1225
|
-
if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
|
|
1226
|
-
} else {
|
|
1227
|
-
let bestMatch = "";
|
|
1228
|
-
let bestMatchSubpath = "";
|
|
1229
|
-
const keys = Object.getOwnPropertyNames(imports);
|
|
1230
|
-
let i = -1;
|
|
1231
|
-
while (++i < keys.length) {
|
|
1232
|
-
const key = keys[i];
|
|
1233
|
-
const patternIndex = key.indexOf("*");
|
|
1234
|
-
if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
|
|
1235
|
-
const patternTrailer = key.slice(patternIndex + 1);
|
|
1236
|
-
if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
1237
|
-
bestMatch = key;
|
|
1238
|
-
bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
if (bestMatch) {
|
|
1243
|
-
const target = imports[bestMatch];
|
|
1244
|
-
const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
|
|
1245
|
-
if (resolveResult !== null && resolveResult !== void 0) return resolveResult;
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
throw importNotDefined(name, packageJsonUrl, base);
|
|
1250
|
-
}
|
|
1251
|
-
/**
|
|
1252
|
-
* @param {string} specifier
|
|
1253
|
-
* @param {URL} base
|
|
1254
|
-
*/
|
|
1255
|
-
function parsePackageName(specifier, base) {
|
|
1256
|
-
let separatorIndex = specifier.indexOf("/");
|
|
1257
|
-
let validPackageName = true;
|
|
1258
|
-
let isScoped = false;
|
|
1259
|
-
if (specifier[0] === "@") {
|
|
1260
|
-
isScoped = true;
|
|
1261
|
-
if (separatorIndex === -1 || specifier.length === 0) validPackageName = false;
|
|
1262
|
-
else separatorIndex = specifier.indexOf("/", separatorIndex + 1);
|
|
1263
|
-
}
|
|
1264
|
-
const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
|
|
1265
|
-
if (invalidPackageNameRegEx.exec(packageName) !== null) validPackageName = false;
|
|
1266
|
-
if (!validPackageName) throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath(base));
|
|
1267
|
-
return {
|
|
1268
|
-
packageName,
|
|
1269
|
-
packageSubpath: "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex)),
|
|
1270
|
-
isScoped
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
function packageResolve(specifier, base, conditions) {
|
|
1274
|
-
if (nodeBuiltins.includes(specifier)) return new URL$1("node:" + specifier);
|
|
1275
|
-
const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
|
|
1276
|
-
const packageConfig = getPackageScopeConfig(base);
|
|
1277
|
-
if (packageConfig.exists && packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(pathToFileURL(packageConfig.pjsonPath), packageSubpath, packageConfig, base, conditions);
|
|
1278
|
-
let packageJsonUrl = new URL$1("./node_modules/" + packageName + "/package.json", base);
|
|
1279
|
-
let packageJsonPath = fileURLToPath(packageJsonUrl);
|
|
1280
|
-
let lastPath;
|
|
1281
|
-
do {
|
|
1282
|
-
const stat$2 = tryStatSync(packageJsonPath.slice(0, -13));
|
|
1283
|
-
if (!stat$2 || !stat$2.isDirectory()) {
|
|
1284
|
-
lastPath = packageJsonPath;
|
|
1285
|
-
packageJsonUrl = new URL$1((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
|
|
1286
|
-
packageJsonPath = fileURLToPath(packageJsonUrl);
|
|
1287
|
-
continue;
|
|
1288
|
-
}
|
|
1289
|
-
const packageConfig$1 = read$1(packageJsonPath, {
|
|
1290
|
-
base,
|
|
1291
|
-
specifier
|
|
1292
|
-
});
|
|
1293
|
-
if (packageConfig$1.exports !== void 0 && packageConfig$1.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig$1, base, conditions);
|
|
1294
|
-
if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig$1, base);
|
|
1295
|
-
return new URL$1(packageSubpath, packageJsonUrl);
|
|
1296
|
-
} while (packageJsonPath.length !== lastPath.length);
|
|
1297
|
-
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), false);
|
|
1298
|
-
}
|
|
1299
|
-
function isRelativeSpecifier(specifier) {
|
|
1300
|
-
if (specifier[0] === ".") {
|
|
1301
|
-
if (specifier.length === 1 || specifier[1] === "/") return true;
|
|
1302
|
-
if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) return true;
|
|
1303
|
-
}
|
|
1304
|
-
return false;
|
|
1305
|
-
}
|
|
1306
|
-
function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
|
|
1307
|
-
if (specifier === "") return false;
|
|
1308
|
-
if (specifier[0] === "/") return true;
|
|
1309
|
-
return isRelativeSpecifier(specifier);
|
|
1310
|
-
}
|
|
1311
|
-
/**
|
|
1312
|
-
* The “Resolver Algorithm Specification” as detailed in the Node docs (which is
|
|
1313
|
-
* sync and slightly lower-level than `resolve`).
|
|
1314
|
-
*
|
|
1315
|
-
* @param {string} specifier
|
|
1316
|
-
* `/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`, etc.
|
|
1317
|
-
* @param {URL} base
|
|
1318
|
-
* Full URL (to a file) that `specifier` is resolved relative from.
|
|
1319
|
-
* @param {Set<string>} [conditions]
|
|
1320
|
-
* Conditions.
|
|
1321
|
-
* @param {boolean} [preserveSymlinks]
|
|
1322
|
-
* Keep symlinks instead of resolving them.
|
|
1323
|
-
* @returns {URL}
|
|
1324
|
-
* A URL object to the found thing.
|
|
1325
|
-
*/
|
|
1326
|
-
function moduleResolve(specifier, base, conditions, preserveSymlinks) {
|
|
1327
|
-
const protocol = base.protocol;
|
|
1328
|
-
const isData = protocol === "data:";
|
|
1329
|
-
let resolved;
|
|
1330
|
-
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) try {
|
|
1331
|
-
resolved = new URL$1(specifier, base);
|
|
1332
|
-
} catch (error_) {
|
|
1333
|
-
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
1334
|
-
error.cause = error_;
|
|
1335
|
-
throw error;
|
|
1336
|
-
}
|
|
1337
|
-
else if (protocol === "file:" && specifier[0] === "#") resolved = packageImportsResolve(specifier, base, conditions);
|
|
1338
|
-
else try {
|
|
1339
|
-
resolved = new URL$1(specifier);
|
|
1340
|
-
} catch (error_) {
|
|
1341
|
-
if (isData && !nodeBuiltins.includes(specifier)) {
|
|
1342
|
-
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
1343
|
-
error.cause = error_;
|
|
1344
|
-
throw error;
|
|
1345
|
-
}
|
|
1346
|
-
resolved = packageResolve(specifier, base, conditions);
|
|
1347
|
-
}
|
|
1348
|
-
assert.ok(resolved !== void 0, "expected to be defined");
|
|
1349
|
-
if (resolved.protocol !== "file:") return resolved;
|
|
1350
|
-
return finalizeResolution(resolved, base, preserveSymlinks);
|
|
1351
|
-
}
|
|
1352
|
-
const DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
|
|
1353
|
-
const isWindows = process.platform === "win32";
|
|
1354
|
-
const globalCache = globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map();
|
|
1355
|
-
/**
|
|
1356
|
-
* Synchronously resolves a module url based on the options provided.
|
|
1357
|
-
*
|
|
1358
|
-
* @param {string} input - The identifier or path of the module to resolve.
|
|
1359
|
-
* @param {ResolveOptions} [options] - Options to resolve the module. See {@link ResolveOptions}.
|
|
1360
|
-
* @returns {string} The resolved URL as a string.
|
|
1361
|
-
*/
|
|
1362
|
-
function resolveModuleURL(input, options) {
|
|
1363
|
-
const parsedInput = _parseInput(input);
|
|
1364
|
-
if ("external" in parsedInput) return parsedInput.external;
|
|
1365
|
-
const specifier = parsedInput.specifier;
|
|
1366
|
-
let url = parsedInput.url;
|
|
1367
|
-
let absolutePath = parsedInput.absolutePath;
|
|
1368
|
-
let cacheKey;
|
|
1369
|
-
let cacheObj;
|
|
1370
|
-
if (options?.cache !== false) {
|
|
1371
|
-
cacheKey = _cacheKey(absolutePath || specifier, options);
|
|
1372
|
-
cacheObj = options?.cache && typeof options?.cache === "object" ? options.cache : globalCache;
|
|
1373
|
-
}
|
|
1374
|
-
if (cacheObj) {
|
|
1375
|
-
const cached = cacheObj.get(cacheKey);
|
|
1376
|
-
if (typeof cached === "string") return cached;
|
|
1377
|
-
if (cached instanceof Error) {
|
|
1378
|
-
if (options?.try) return;
|
|
1379
|
-
throw cached;
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
if (absolutePath) try {
|
|
1383
|
-
const stat$2 = lstatSync(absolutePath);
|
|
1384
|
-
if (stat$2.isSymbolicLink()) {
|
|
1385
|
-
absolutePath = realpathSync(absolutePath);
|
|
1386
|
-
url = pathToFileURL(absolutePath);
|
|
1387
|
-
}
|
|
1388
|
-
if (stat$2.isFile()) {
|
|
1389
|
-
if (cacheObj) cacheObj.set(cacheKey, url.href);
|
|
1390
|
-
return url.href;
|
|
1391
|
-
}
|
|
1392
|
-
} catch (error) {
|
|
1393
|
-
if (error?.code !== "ENOENT") {
|
|
1394
|
-
if (cacheObj) cacheObj.set(cacheKey, error);
|
|
1395
|
-
throw error;
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
const conditionsSet = options?.conditions ? new Set(options.conditions) : DEFAULT_CONDITIONS_SET;
|
|
1399
|
-
const target = specifier || url.href;
|
|
1400
|
-
const bases = _normalizeBases(options?.from);
|
|
1401
|
-
const suffixes = options?.suffixes || [""];
|
|
1402
|
-
const extensions = options?.extensions ? ["", ...options.extensions] : [""];
|
|
1403
|
-
let resolved;
|
|
1404
|
-
for (const base of bases) {
|
|
1405
|
-
for (const suffix of suffixes) {
|
|
1406
|
-
let name = _join(target, suffix);
|
|
1407
|
-
if (name === ".") name += "/.";
|
|
1408
|
-
for (const extension of extensions) {
|
|
1409
|
-
resolved = _tryModuleResolve(name + extension, base, conditionsSet);
|
|
1410
|
-
if (resolved) break;
|
|
1411
|
-
}
|
|
1412
|
-
if (resolved) break;
|
|
1413
|
-
}
|
|
1414
|
-
if (resolved) break;
|
|
1415
|
-
}
|
|
1416
|
-
if (!resolved) {
|
|
1417
|
-
const error = /* @__PURE__ */ new Error(`Cannot resolve module "${input}" (from: ${bases.map((u) => _fmtPath(u)).join(", ")})`);
|
|
1418
|
-
error.code = "ERR_MODULE_NOT_FOUND";
|
|
1419
|
-
if (cacheObj) cacheObj.set(cacheKey, error);
|
|
1420
|
-
if (options?.try) return;
|
|
1421
|
-
throw error;
|
|
1422
|
-
}
|
|
1423
|
-
if (cacheObj) cacheObj.set(cacheKey, resolved.href);
|
|
1424
|
-
return resolved.href;
|
|
1425
|
-
}
|
|
1426
|
-
/**
|
|
1427
|
-
* Synchronously resolves a module then converts it to a file path
|
|
1428
|
-
*
|
|
1429
|
-
* (throws error if reolved path is not file:// scheme)
|
|
1430
|
-
*
|
|
1431
|
-
* @param {string} id - The identifier or path of the module to resolve.
|
|
1432
|
-
* @param {ResolveOptions} [options] - Options to resolve the module. See {@link ResolveOptions}.
|
|
1433
|
-
* @returns {string} The resolved URL as a string.
|
|
1434
|
-
*/
|
|
1435
|
-
function resolveModulePath(id, options) {
|
|
1436
|
-
const resolved = resolveModuleURL(id, options);
|
|
1437
|
-
if (!resolved) return;
|
|
1438
|
-
if (!resolved.startsWith("file://") && options?.try) return;
|
|
1439
|
-
const absolutePath = fileURLToPath(resolved);
|
|
1440
|
-
return isWindows ? _normalizeWinPath(absolutePath) : absolutePath;
|
|
1441
|
-
}
|
|
1442
|
-
function _tryModuleResolve(specifier, base, conditions) {
|
|
1443
|
-
try {
|
|
1444
|
-
return moduleResolve(specifier, base, conditions);
|
|
1445
|
-
} catch {}
|
|
1446
|
-
}
|
|
1447
|
-
function _normalizeBases(inputs) {
|
|
1448
|
-
const urls = (Array.isArray(inputs) ? inputs : [inputs]).flatMap((input) => _normalizeBase(input));
|
|
1449
|
-
if (urls.length === 0) return [pathToFileURL("./")];
|
|
1450
|
-
return urls;
|
|
1451
|
-
}
|
|
1452
|
-
function _normalizeBase(input) {
|
|
1453
|
-
if (!input) return [];
|
|
1454
|
-
if (_isURL(input)) return [input];
|
|
1455
|
-
if (typeof input !== "string") return [];
|
|
1456
|
-
if (/^(?:node|data|http|https|file):/.test(input)) return new URL(input);
|
|
1457
|
-
try {
|
|
1458
|
-
if (input.endsWith("/") || statSync(input).isDirectory()) return pathToFileURL(input + "/");
|
|
1459
|
-
return pathToFileURL(input);
|
|
1460
|
-
} catch {
|
|
1461
|
-
return [pathToFileURL(input + "/"), pathToFileURL(input)];
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
function _fmtPath(input) {
|
|
1465
|
-
try {
|
|
1466
|
-
return fileURLToPath(input);
|
|
1467
|
-
} catch {
|
|
1468
|
-
return input;
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
function _cacheKey(id, opts) {
|
|
1472
|
-
return JSON.stringify([
|
|
1473
|
-
id,
|
|
1474
|
-
(opts?.conditions || ["node", "import"]).sort(),
|
|
1475
|
-
opts?.extensions,
|
|
1476
|
-
opts?.from,
|
|
1477
|
-
opts?.suffixes
|
|
1478
|
-
]);
|
|
1479
|
-
}
|
|
1480
|
-
function _join(a, b$1) {
|
|
1481
|
-
if (!a || !b$1 || b$1 === "/") return a;
|
|
1482
|
-
return (a.endsWith("/") ? a : a + "/") + (b$1.startsWith("/") ? b$1.slice(1) : b$1);
|
|
1483
|
-
}
|
|
1484
|
-
function _normalizeWinPath(path$1$1) {
|
|
1485
|
-
return path$1$1.replace(/\\/g, "/").replace(/^[a-z]:\//, (r$1) => r$1.toUpperCase());
|
|
1486
|
-
}
|
|
1487
|
-
function _isURL(input) {
|
|
1488
|
-
return input instanceof URL || input?.constructor?.name === "URL";
|
|
1489
|
-
}
|
|
1490
|
-
function _parseInput(input) {
|
|
1491
|
-
if (typeof input === "string") {
|
|
1492
|
-
if (input.startsWith("file:")) {
|
|
1493
|
-
const url = new URL(input);
|
|
1494
|
-
return {
|
|
1495
|
-
url,
|
|
1496
|
-
absolutePath: fileURLToPath(url)
|
|
1497
|
-
};
|
|
1498
|
-
}
|
|
1499
|
-
if (isAbsolute(input)) return {
|
|
1500
|
-
url: pathToFileURL(input),
|
|
1501
|
-
absolutePath: input
|
|
1502
|
-
};
|
|
1503
|
-
if (/^(?:node|data|http|https):/.test(input)) return { external: input };
|
|
1504
|
-
if (nodeBuiltins.includes(input) && !input.includes(":")) return { external: `node:${input}` };
|
|
1505
|
-
return { specifier: input };
|
|
1506
|
-
}
|
|
1507
|
-
if (_isURL(input)) {
|
|
1508
|
-
if (input.protocol === "file:") return {
|
|
1509
|
-
url: input,
|
|
1510
|
-
absolutePath: fileURLToPath(input)
|
|
1511
|
-
};
|
|
1512
|
-
return { external: input.href };
|
|
1513
|
-
}
|
|
1514
|
-
throw new TypeError("id must be a `string` or `URL`");
|
|
1515
|
-
}
|
|
1516
|
-
|
|
1517
|
-
//#endregion
|
|
1518
|
-
//#region node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs
|
|
1519
|
-
function isBuffer(obj) {
|
|
1520
|
-
return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
1521
|
-
}
|
|
1522
|
-
function keyIdentity(key) {
|
|
1523
|
-
return key;
|
|
1524
|
-
}
|
|
1525
|
-
function flatten(target, opts) {
|
|
1526
|
-
opts = opts || {};
|
|
1527
|
-
const delimiter$1 = opts.delimiter || ".";
|
|
1528
|
-
const maxDepth = opts.maxDepth;
|
|
1529
|
-
const transformKey = opts.transformKey || keyIdentity;
|
|
1530
|
-
const output = {};
|
|
1531
|
-
function step(object, prev, currentDepth) {
|
|
1532
|
-
currentDepth = currentDepth || 1;
|
|
1533
|
-
Object.keys(object).forEach(function(key) {
|
|
1534
|
-
const value = object[key];
|
|
1535
|
-
const isarray = opts.safe && Array.isArray(value);
|
|
1536
|
-
const type$1 = Object.prototype.toString.call(value);
|
|
1537
|
-
const isbuffer = isBuffer(value);
|
|
1538
|
-
const isobject = type$1 === "[object Object]" || type$1 === "[object Array]";
|
|
1539
|
-
const newKey = prev ? prev + delimiter$1 + transformKey(key) : transformKey(key);
|
|
1540
|
-
if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) return step(value, newKey, currentDepth + 1);
|
|
1541
|
-
output[newKey] = value;
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1544
|
-
step(target);
|
|
1545
|
-
return output;
|
|
1546
|
-
}
|
|
1547
|
-
function unflatten(target, opts) {
|
|
1548
|
-
opts = opts || {};
|
|
1549
|
-
const delimiter$1 = opts.delimiter || ".";
|
|
1550
|
-
const overwrite = opts.overwrite || false;
|
|
1551
|
-
const transformKey = opts.transformKey || keyIdentity;
|
|
1552
|
-
const result = {};
|
|
1553
|
-
if (isBuffer(target) || Object.prototype.toString.call(target) !== "[object Object]") return target;
|
|
1554
|
-
function getkey(key) {
|
|
1555
|
-
const parsedKey = Number(key);
|
|
1556
|
-
return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
|
|
1557
|
-
}
|
|
1558
|
-
function addKeys(keyPrefix, recipient, target$1) {
|
|
1559
|
-
return Object.keys(target$1).reduce(function(result$1, key) {
|
|
1560
|
-
result$1[keyPrefix + delimiter$1 + key] = target$1[key];
|
|
1561
|
-
return result$1;
|
|
1562
|
-
}, recipient);
|
|
1563
|
-
}
|
|
1564
|
-
function isEmpty(val) {
|
|
1565
|
-
const type$1 = Object.prototype.toString.call(val);
|
|
1566
|
-
const isArray = type$1 === "[object Array]";
|
|
1567
|
-
const isObject = type$1 === "[object Object]";
|
|
1568
|
-
if (!val) return true;
|
|
1569
|
-
else if (isArray) return !val.length;
|
|
1570
|
-
else if (isObject) return !Object.keys(val).length;
|
|
1571
|
-
}
|
|
1572
|
-
target = Object.keys(target).reduce(function(result$1, key) {
|
|
1573
|
-
const type$1 = Object.prototype.toString.call(target[key]);
|
|
1574
|
-
if (!(type$1 === "[object Object]" || type$1 === "[object Array]") || isEmpty(target[key])) {
|
|
1575
|
-
result$1[key] = target[key];
|
|
1576
|
-
return result$1;
|
|
1577
|
-
} else return addKeys(key, result$1, flatten(target[key], opts));
|
|
1578
|
-
}, {});
|
|
1579
|
-
Object.keys(target).forEach(function(key) {
|
|
1580
|
-
const split = key.split(delimiter$1).map(transformKey);
|
|
1581
|
-
let key1 = getkey(split.shift());
|
|
1582
|
-
let key2 = getkey(split[0]);
|
|
1583
|
-
let recipient = result;
|
|
1584
|
-
while (key2 !== void 0) {
|
|
1585
|
-
if (key1 === "__proto__") return;
|
|
1586
|
-
const type$1 = Object.prototype.toString.call(recipient[key1]);
|
|
1587
|
-
const isobject = type$1 === "[object Object]" || type$1 === "[object Array]";
|
|
1588
|
-
if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") return;
|
|
1589
|
-
if (overwrite && !isobject || !overwrite && recipient[key1] == null) recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
|
|
1590
|
-
recipient = recipient[key1];
|
|
1591
|
-
if (split.length > 0) {
|
|
1592
|
-
key1 = getkey(split.shift());
|
|
1593
|
-
key2 = getkey(split[0]);
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
recipient[key1] = unflatten(target[key], opts);
|
|
1597
|
-
});
|
|
1598
|
-
return result;
|
|
1599
|
-
}
|
|
1600
|
-
const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
|
|
1601
|
-
const RE_LINES = /\n|\r|\r\n/;
|
|
1602
|
-
const defaults = {
|
|
1603
|
-
name: ".conf",
|
|
1604
|
-
dir: process.cwd(),
|
|
1605
|
-
flat: false
|
|
1606
|
-
};
|
|
1607
|
-
function withDefaults(options) {
|
|
1608
|
-
if (typeof options === "string") options = { name: options };
|
|
1609
|
-
return {
|
|
1610
|
-
...defaults,
|
|
1611
|
-
...options
|
|
1612
|
-
};
|
|
1613
|
-
}
|
|
1614
|
-
function parse(contents, options = {}) {
|
|
1615
|
-
const config = {};
|
|
1616
|
-
const lines = contents.split(RE_LINES);
|
|
1617
|
-
for (const line of lines) {
|
|
1618
|
-
const match = line.match(RE_KEY_VAL);
|
|
1619
|
-
if (!match) continue;
|
|
1620
|
-
const key = match[1];
|
|
1621
|
-
if (!key || key === "__proto__" || key === "constructor") continue;
|
|
1622
|
-
const value = destr((match[2] || "").trim());
|
|
1623
|
-
if (key.endsWith("[]")) {
|
|
1624
|
-
const nkey = key.slice(0, Math.max(0, key.length - 2));
|
|
1625
|
-
config[nkey] = (config[nkey] || []).concat(value);
|
|
1626
|
-
continue;
|
|
1627
|
-
}
|
|
1628
|
-
config[key] = value;
|
|
1629
|
-
}
|
|
1630
|
-
return options.flat ? config : unflatten(config, { overwrite: true });
|
|
1631
|
-
}
|
|
1632
|
-
function parseFile(path$2, options) {
|
|
1633
|
-
if (!existsSync(path$2)) return {};
|
|
1634
|
-
return parse(readFileSync(path$2, "utf8"), options);
|
|
1635
|
-
}
|
|
1636
|
-
function read(options) {
|
|
1637
|
-
options = withDefaults(options);
|
|
1638
|
-
return parseFile(resolve(options.dir, options.name), options);
|
|
1639
|
-
}
|
|
1640
|
-
function readUser(options) {
|
|
1641
|
-
options = withDefaults(options);
|
|
1642
|
-
options.dir = process.env.XDG_CONFIG_HOME || homedir();
|
|
1643
|
-
return read(options);
|
|
1644
|
-
}
|
|
1645
|
-
|
|
1646
|
-
//#endregion
|
|
1647
|
-
//#region node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.mjs
|
|
1648
|
-
const b = /^(?:( )+|\t+)/, d = "space", h$1 = "tab";
|
|
1649
|
-
function g(e, t) {
|
|
1650
|
-
const n = /* @__PURE__ */ new Map();
|
|
1651
|
-
let s = 0, o, i;
|
|
1652
|
-
for (const c of e.split(/\n/g)) {
|
|
1653
|
-
if (!c) continue;
|
|
1654
|
-
let f, a, l, p, r$1;
|
|
1655
|
-
const y = c.match(b);
|
|
1656
|
-
if (y === null) s = 0, o = "";
|
|
1657
|
-
else {
|
|
1658
|
-
if (f = y[0].length, a = y[1] ? d : h$1, t && a === d && f === 1) continue;
|
|
1659
|
-
a !== o && (s = 0), o = a, l = 1, p = 0;
|
|
1660
|
-
const u = f - s;
|
|
1661
|
-
if (s = f, u === 0) l = 0, p = 1;
|
|
1662
|
-
else {
|
|
1663
|
-
const I$1 = u > 0 ? u : -u;
|
|
1664
|
-
i = T(a, I$1);
|
|
1665
|
-
}
|
|
1666
|
-
r$1 = n.get(i), r$1 = r$1 === void 0 ? [1, 0] : [r$1[0] + l, r$1[1] + p], n.set(i, r$1);
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
return n;
|
|
1670
|
-
}
|
|
1671
|
-
function T(e, t) {
|
|
1672
|
-
return (e === d ? "s" : "t") + String(t);
|
|
1673
|
-
}
|
|
1674
|
-
function w(e) {
|
|
1675
|
-
return {
|
|
1676
|
-
type: e[0] === "s" ? d : h$1,
|
|
1677
|
-
amount: Number(e.slice(1))
|
|
1678
|
-
};
|
|
1679
|
-
}
|
|
1680
|
-
function E(e) {
|
|
1681
|
-
let t, n = 0, s = 0;
|
|
1682
|
-
for (const [o, [i, c]] of e) (i > n || i === n && c > s) && (n = i, s = c, t = o);
|
|
1683
|
-
return t;
|
|
1684
|
-
}
|
|
1685
|
-
function S$2(e, t) {
|
|
1686
|
-
return (e === d ? " " : " ").repeat(t);
|
|
1687
|
-
}
|
|
1688
|
-
function _(e) {
|
|
1689
|
-
if (typeof e != "string") throw new TypeError("Expected a string");
|
|
1690
|
-
let t = g(e, !0);
|
|
1691
|
-
t.size === 0 && (t = g(e, !1));
|
|
1692
|
-
const n = E(t);
|
|
1693
|
-
let s, o = 0, i = "";
|
|
1694
|
-
return n !== void 0 && ({type: s, amount: o} = w(n), i = S$2(s, o)), {
|
|
1695
|
-
amount: o,
|
|
1696
|
-
type: s,
|
|
1697
|
-
indent: i
|
|
1698
|
-
};
|
|
1699
|
-
}
|
|
1700
|
-
const m = Symbol.for("__confbox_fmt__"), k = /^(\s+)/, v = /(\s+)$/;
|
|
1701
|
-
function x$2(e, t = {}) {
|
|
1702
|
-
return {
|
|
1703
|
-
sample: t.indent === void 0 && t.preserveIndentation !== !1 && e.slice(0, t?.sampleSize || 1024),
|
|
1704
|
-
whiteSpace: t.preserveWhitespace === !1 ? void 0 : {
|
|
1705
|
-
start: k.exec(e)?.[0] || "",
|
|
1706
|
-
end: v.exec(e)?.[0] || ""
|
|
1707
|
-
}
|
|
1708
|
-
};
|
|
1709
|
-
}
|
|
1710
|
-
function N$1(e, t, n) {
|
|
1711
|
-
!t || typeof t != "object" || Object.defineProperty(t, m, {
|
|
1712
|
-
enumerable: !1,
|
|
1713
|
-
configurable: !0,
|
|
1714
|
-
writable: !0,
|
|
1715
|
-
value: x$2(e, n)
|
|
1716
|
-
});
|
|
1717
|
-
}
|
|
1718
|
-
function C(e, t) {
|
|
1719
|
-
if (!e || typeof e != "object" || !(m in e)) return {
|
|
1720
|
-
indent: t?.indent ?? 2,
|
|
1721
|
-
whitespace: {
|
|
1722
|
-
start: "",
|
|
1723
|
-
end: ""
|
|
1724
|
-
}
|
|
1725
|
-
};
|
|
1726
|
-
const n = e[m];
|
|
1727
|
-
return {
|
|
1728
|
-
indent: t?.indent || _(n.sample || "").indent,
|
|
1729
|
-
whitespace: n.whiteSpace || {
|
|
1730
|
-
start: "",
|
|
1731
|
-
end: ""
|
|
1732
|
-
}
|
|
1733
|
-
};
|
|
1734
|
-
}
|
|
1735
|
-
|
|
1736
|
-
//#endregion
|
|
1737
|
-
//#region node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.mjs
|
|
1738
|
-
function $(n, l = !1) {
|
|
1739
|
-
const g$1 = n.length;
|
|
1740
|
-
let e = 0, u = "", p = 0, k$1 = 16, A = 0, o = 0, O$1 = 0, B = 0, b$1 = 0;
|
|
1741
|
-
function I$1(i, T$1) {
|
|
1742
|
-
let s = 0, c = 0;
|
|
1743
|
-
for (; s < i;) {
|
|
1744
|
-
let t = n.charCodeAt(e);
|
|
1745
|
-
if (t >= 48 && t <= 57) c = c * 16 + t - 48;
|
|
1746
|
-
else if (t >= 65 && t <= 70) c = c * 16 + t - 65 + 10;
|
|
1747
|
-
else if (t >= 97 && t <= 102) c = c * 16 + t - 97 + 10;
|
|
1748
|
-
else break;
|
|
1749
|
-
e++, s++;
|
|
1750
|
-
}
|
|
1751
|
-
return s < i && (c = -1), c;
|
|
1752
|
-
}
|
|
1753
|
-
function V(i) {
|
|
1754
|
-
e = i, u = "", p = 0, k$1 = 16, b$1 = 0;
|
|
1755
|
-
}
|
|
1756
|
-
function F() {
|
|
1757
|
-
let i = e;
|
|
1758
|
-
if (n.charCodeAt(e) === 48) e++;
|
|
1759
|
-
else for (e++; e < n.length && L(n.charCodeAt(e));) e++;
|
|
1760
|
-
if (e < n.length && n.charCodeAt(e) === 46) if (e++, e < n.length && L(n.charCodeAt(e))) for (e++; e < n.length && L(n.charCodeAt(e));) e++;
|
|
1761
|
-
else return b$1 = 3, n.substring(i, e);
|
|
1762
|
-
let T$1 = e;
|
|
1763
|
-
if (e < n.length && (n.charCodeAt(e) === 69 || n.charCodeAt(e) === 101)) if (e++, (e < n.length && n.charCodeAt(e) === 43 || n.charCodeAt(e) === 45) && e++, e < n.length && L(n.charCodeAt(e))) {
|
|
1764
|
-
for (e++; e < n.length && L(n.charCodeAt(e));) e++;
|
|
1765
|
-
T$1 = e;
|
|
1766
|
-
} else b$1 = 3;
|
|
1767
|
-
return n.substring(i, T$1);
|
|
1768
|
-
}
|
|
1769
|
-
function a() {
|
|
1770
|
-
let i = "", T$1 = e;
|
|
1771
|
-
for (;;) {
|
|
1772
|
-
if (e >= g$1) {
|
|
1773
|
-
i += n.substring(T$1, e), b$1 = 2;
|
|
1774
|
-
break;
|
|
1775
|
-
}
|
|
1776
|
-
const s = n.charCodeAt(e);
|
|
1777
|
-
if (s === 34) {
|
|
1778
|
-
i += n.substring(T$1, e), e++;
|
|
1779
|
-
break;
|
|
1780
|
-
}
|
|
1781
|
-
if (s === 92) {
|
|
1782
|
-
if (i += n.substring(T$1, e), e++, e >= g$1) {
|
|
1783
|
-
b$1 = 2;
|
|
1784
|
-
break;
|
|
1785
|
-
}
|
|
1786
|
-
switch (n.charCodeAt(e++)) {
|
|
1787
|
-
case 34:
|
|
1788
|
-
i += "\"";
|
|
1789
|
-
break;
|
|
1790
|
-
case 92:
|
|
1791
|
-
i += "\\";
|
|
1792
|
-
break;
|
|
1793
|
-
case 47:
|
|
1794
|
-
i += "/";
|
|
1795
|
-
break;
|
|
1796
|
-
case 98:
|
|
1797
|
-
i += "\b";
|
|
1798
|
-
break;
|
|
1799
|
-
case 102:
|
|
1800
|
-
i += "\f";
|
|
1801
|
-
break;
|
|
1802
|
-
case 110:
|
|
1803
|
-
i += `
|
|
1804
|
-
`;
|
|
1805
|
-
break;
|
|
1806
|
-
case 114:
|
|
1807
|
-
i += "\r";
|
|
1808
|
-
break;
|
|
1809
|
-
case 116:
|
|
1810
|
-
i += " ";
|
|
1811
|
-
break;
|
|
1812
|
-
case 117:
|
|
1813
|
-
const t = I$1(4);
|
|
1814
|
-
t >= 0 ? i += String.fromCharCode(t) : b$1 = 4;
|
|
1815
|
-
break;
|
|
1816
|
-
default: b$1 = 5;
|
|
1817
|
-
}
|
|
1818
|
-
T$1 = e;
|
|
1819
|
-
continue;
|
|
1820
|
-
}
|
|
1821
|
-
if (s >= 0 && s <= 31) if (r(s)) {
|
|
1822
|
-
i += n.substring(T$1, e), b$1 = 2;
|
|
1823
|
-
break;
|
|
1824
|
-
} else b$1 = 6;
|
|
1825
|
-
e++;
|
|
1826
|
-
}
|
|
1827
|
-
return i;
|
|
1828
|
-
}
|
|
1829
|
-
function w$1() {
|
|
1830
|
-
if (u = "", b$1 = 0, p = e, o = A, B = O$1, e >= g$1) return p = g$1, k$1 = 17;
|
|
1831
|
-
let i = n.charCodeAt(e);
|
|
1832
|
-
if (J(i)) {
|
|
1833
|
-
do
|
|
1834
|
-
e++, u += String.fromCharCode(i), i = n.charCodeAt(e);
|
|
1835
|
-
while (J(i));
|
|
1836
|
-
return k$1 = 15;
|
|
1837
|
-
}
|
|
1838
|
-
if (r(i)) return e++, u += String.fromCharCode(i), i === 13 && n.charCodeAt(e) === 10 && (e++, u += `
|
|
1839
|
-
`), A++, O$1 = e, k$1 = 14;
|
|
1840
|
-
switch (i) {
|
|
1841
|
-
case 123: return e++, k$1 = 1;
|
|
1842
|
-
case 125: return e++, k$1 = 2;
|
|
1843
|
-
case 91: return e++, k$1 = 3;
|
|
1844
|
-
case 93: return e++, k$1 = 4;
|
|
1845
|
-
case 58: return e++, k$1 = 6;
|
|
1846
|
-
case 44: return e++, k$1 = 5;
|
|
1847
|
-
case 34: return e++, u = a(), k$1 = 10;
|
|
1848
|
-
case 47:
|
|
1849
|
-
const T$1 = e - 1;
|
|
1850
|
-
if (n.charCodeAt(e + 1) === 47) {
|
|
1851
|
-
for (e += 2; e < g$1 && !r(n.charCodeAt(e));) e++;
|
|
1852
|
-
return u = n.substring(T$1, e), k$1 = 12;
|
|
1853
|
-
}
|
|
1854
|
-
if (n.charCodeAt(e + 1) === 42) {
|
|
1855
|
-
e += 2;
|
|
1856
|
-
const s = g$1 - 1;
|
|
1857
|
-
let c = !1;
|
|
1858
|
-
for (; e < s;) {
|
|
1859
|
-
const t = n.charCodeAt(e);
|
|
1860
|
-
if (t === 42 && n.charCodeAt(e + 1) === 47) {
|
|
1861
|
-
e += 2, c = !0;
|
|
1862
|
-
break;
|
|
1863
|
-
}
|
|
1864
|
-
e++, r(t) && (t === 13 && n.charCodeAt(e) === 10 && e++, A++, O$1 = e);
|
|
1865
|
-
}
|
|
1866
|
-
return c || (e++, b$1 = 1), u = n.substring(T$1, e), k$1 = 13;
|
|
1867
|
-
}
|
|
1868
|
-
return u += String.fromCharCode(i), e++, k$1 = 16;
|
|
1869
|
-
case 45: if (u += String.fromCharCode(i), e++, e === g$1 || !L(n.charCodeAt(e))) return k$1 = 16;
|
|
1870
|
-
case 48:
|
|
1871
|
-
case 49:
|
|
1872
|
-
case 50:
|
|
1873
|
-
case 51:
|
|
1874
|
-
case 52:
|
|
1875
|
-
case 53:
|
|
1876
|
-
case 54:
|
|
1877
|
-
case 55:
|
|
1878
|
-
case 56:
|
|
1879
|
-
case 57: return u += F(), k$1 = 11;
|
|
1880
|
-
default:
|
|
1881
|
-
for (; e < g$1 && v$1(i);) e++, i = n.charCodeAt(e);
|
|
1882
|
-
if (p !== e) {
|
|
1883
|
-
switch (u = n.substring(p, e), u) {
|
|
1884
|
-
case "true": return k$1 = 8;
|
|
1885
|
-
case "false": return k$1 = 9;
|
|
1886
|
-
case "null": return k$1 = 7;
|
|
1887
|
-
}
|
|
1888
|
-
return k$1 = 16;
|
|
1889
|
-
}
|
|
1890
|
-
return u += String.fromCharCode(i), e++, k$1 = 16;
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
function v$1(i) {
|
|
1894
|
-
if (J(i) || r(i)) return !1;
|
|
1895
|
-
switch (i) {
|
|
1896
|
-
case 125:
|
|
1897
|
-
case 93:
|
|
1898
|
-
case 123:
|
|
1899
|
-
case 91:
|
|
1900
|
-
case 34:
|
|
1901
|
-
case 58:
|
|
1902
|
-
case 44:
|
|
1903
|
-
case 47: return !1;
|
|
1904
|
-
}
|
|
1905
|
-
return !0;
|
|
1906
|
-
}
|
|
1907
|
-
function j$1() {
|
|
1908
|
-
let i;
|
|
1909
|
-
do
|
|
1910
|
-
i = w$1();
|
|
1911
|
-
while (i >= 12 && i <= 15);
|
|
1912
|
-
return i;
|
|
1913
|
-
}
|
|
1914
|
-
return {
|
|
1915
|
-
setPosition: V,
|
|
1916
|
-
getPosition: () => e,
|
|
1917
|
-
scan: l ? j$1 : w$1,
|
|
1918
|
-
getToken: () => k$1,
|
|
1919
|
-
getTokenValue: () => u,
|
|
1920
|
-
getTokenOffset: () => p,
|
|
1921
|
-
getTokenLength: () => e - p,
|
|
1922
|
-
getTokenStartLine: () => o,
|
|
1923
|
-
getTokenStartCharacter: () => p - B,
|
|
1924
|
-
getTokenError: () => b$1
|
|
1925
|
-
};
|
|
1926
|
-
}
|
|
1927
|
-
function J(n) {
|
|
1928
|
-
return n === 32 || n === 9;
|
|
1929
|
-
}
|
|
1930
|
-
function r(n) {
|
|
1931
|
-
return n === 10 || n === 13;
|
|
1932
|
-
}
|
|
1933
|
-
function L(n) {
|
|
1934
|
-
return n >= 48 && n <= 57;
|
|
1935
|
-
}
|
|
1936
|
-
var Q;
|
|
1937
|
-
(function(n) {
|
|
1938
|
-
n[n.lineFeed = 10] = "lineFeed", n[n.carriageReturn = 13] = "carriageReturn", n[n.space = 32] = "space", n[n._0 = 48] = "_0", n[n._1 = 49] = "_1", n[n._2 = 50] = "_2", n[n._3 = 51] = "_3", n[n._4 = 52] = "_4", n[n._5 = 53] = "_5", n[n._6 = 54] = "_6", n[n._7 = 55] = "_7", n[n._8 = 56] = "_8", n[n._9 = 57] = "_9", n[n.a = 97] = "a", n[n.b = 98] = "b", n[n.c = 99] = "c", n[n.d = 100] = "d", n[n.e = 101] = "e", n[n.f = 102] = "f", n[n.g = 103] = "g", n[n.h = 104] = "h", n[n.i = 105] = "i", n[n.j = 106] = "j", n[n.k = 107] = "k", n[n.l = 108] = "l", n[n.m = 109] = "m", n[n.n = 110] = "n", n[n.o = 111] = "o", n[n.p = 112] = "p", n[n.q = 113] = "q", n[n.r = 114] = "r", n[n.s = 115] = "s", n[n.t = 116] = "t", n[n.u = 117] = "u", n[n.v = 118] = "v", n[n.w = 119] = "w", n[n.x = 120] = "x", n[n.y = 121] = "y", n[n.z = 122] = "z", n[n.A = 65] = "A", n[n.B = 66] = "B", n[n.C = 67] = "C", n[n.D = 68] = "D", n[n.E = 69] = "E", n[n.F = 70] = "F", n[n.G = 71] = "G", n[n.H = 72] = "H", n[n.I = 73] = "I", n[n.J = 74] = "J", n[n.K = 75] = "K", n[n.L = 76] = "L", n[n.M = 77] = "M", n[n.N = 78] = "N", n[n.O = 79] = "O", n[n.P = 80] = "P", n[n.Q = 81] = "Q", n[n.R = 82] = "R", n[n.S = 83] = "S", n[n.T = 84] = "T", n[n.U = 85] = "U", n[n.V = 86] = "V", n[n.W = 87] = "W", n[n.X = 88] = "X", n[n.Y = 89] = "Y", n[n.Z = 90] = "Z", n[n.asterisk = 42] = "asterisk", n[n.backslash = 92] = "backslash", n[n.closeBrace = 125] = "closeBrace", n[n.closeBracket = 93] = "closeBracket", n[n.colon = 58] = "colon", n[n.comma = 44] = "comma", n[n.dot = 46] = "dot", n[n.doubleQuote = 34] = "doubleQuote", n[n.minus = 45] = "minus", n[n.openBrace = 123] = "openBrace", n[n.openBracket = 91] = "openBracket", n[n.plus = 43] = "plus", n[n.slash = 47] = "slash", n[n.formFeed = 12] = "formFeed", n[n.tab = 9] = "tab";
|
|
1939
|
-
})(Q || (Q = {})), new Array(20).fill(0).map((n, l) => " ".repeat(l));
|
|
1940
|
-
const N = 200;
|
|
1941
|
-
new Array(N).fill(0).map((n, l) => `
|
|
1942
|
-
` + " ".repeat(l)), new Array(N).fill(0).map((n, l) => "\r" + " ".repeat(l)), new Array(N).fill(0).map((n, l) => `\r
|
|
1943
|
-
` + " ".repeat(l)), new Array(N).fill(0).map((n, l) => `
|
|
1944
|
-
` + " ".repeat(l)), new Array(N).fill(0).map((n, l) => "\r" + " ".repeat(l)), new Array(N).fill(0).map((n, l) => `\r
|
|
1945
|
-
` + " ".repeat(l));
|
|
1946
|
-
var U;
|
|
1947
|
-
(function(n) {
|
|
1948
|
-
n.DEFAULT = { allowTrailingComma: !1 };
|
|
1949
|
-
})(U || (U = {}));
|
|
1950
|
-
function S$1(n, l = [], g$1 = U.DEFAULT) {
|
|
1951
|
-
let e = null, u = [];
|
|
1952
|
-
const p = [];
|
|
1953
|
-
function k$1(o) {
|
|
1954
|
-
Array.isArray(u) ? u.push(o) : e !== null && (u[e] = o);
|
|
1955
|
-
}
|
|
1956
|
-
return P(n, {
|
|
1957
|
-
onObjectBegin: () => {
|
|
1958
|
-
const o = {};
|
|
1959
|
-
k$1(o), p.push(u), u = o, e = null;
|
|
1960
|
-
},
|
|
1961
|
-
onObjectProperty: (o) => {
|
|
1962
|
-
e = o;
|
|
1963
|
-
},
|
|
1964
|
-
onObjectEnd: () => {
|
|
1965
|
-
u = p.pop();
|
|
1966
|
-
},
|
|
1967
|
-
onArrayBegin: () => {
|
|
1968
|
-
const o = [];
|
|
1969
|
-
k$1(o), p.push(u), u = o, e = null;
|
|
1970
|
-
},
|
|
1971
|
-
onArrayEnd: () => {
|
|
1972
|
-
u = p.pop();
|
|
1973
|
-
},
|
|
1974
|
-
onLiteralValue: k$1,
|
|
1975
|
-
onError: (o, O$1, B) => {
|
|
1976
|
-
l.push({
|
|
1977
|
-
error: o,
|
|
1978
|
-
offset: O$1,
|
|
1979
|
-
length: B
|
|
1980
|
-
});
|
|
1981
|
-
}
|
|
1982
|
-
}, g$1), u[0];
|
|
1983
|
-
}
|
|
1984
|
-
function P(n, l, g$1 = U.DEFAULT) {
|
|
1985
|
-
const e = $(n, !1), u = [];
|
|
1986
|
-
let p = 0;
|
|
1987
|
-
function k$1(f) {
|
|
1988
|
-
return f ? () => p === 0 && f(e.getTokenOffset(), e.getTokenLength(), e.getTokenStartLine(), e.getTokenStartCharacter()) : () => !0;
|
|
1989
|
-
}
|
|
1990
|
-
function A(f) {
|
|
1991
|
-
return f ? (m$1) => p === 0 && f(m$1, e.getTokenOffset(), e.getTokenLength(), e.getTokenStartLine(), e.getTokenStartCharacter()) : () => !0;
|
|
1992
|
-
}
|
|
1993
|
-
function o(f) {
|
|
1994
|
-
return f ? (m$1) => p === 0 && f(m$1, e.getTokenOffset(), e.getTokenLength(), e.getTokenStartLine(), e.getTokenStartCharacter(), () => u.slice()) : () => !0;
|
|
1995
|
-
}
|
|
1996
|
-
function O$1(f) {
|
|
1997
|
-
return f ? () => {
|
|
1998
|
-
p > 0 ? p++ : f(e.getTokenOffset(), e.getTokenLength(), e.getTokenStartLine(), e.getTokenStartCharacter(), () => u.slice()) === !1 && (p = 1);
|
|
1999
|
-
} : () => !0;
|
|
2000
|
-
}
|
|
2001
|
-
function B(f) {
|
|
2002
|
-
return f ? () => {
|
|
2003
|
-
p > 0 && p--, p === 0 && f(e.getTokenOffset(), e.getTokenLength(), e.getTokenStartLine(), e.getTokenStartCharacter());
|
|
2004
|
-
} : () => !0;
|
|
2005
|
-
}
|
|
2006
|
-
const b$1 = O$1(l.onObjectBegin), I$1 = o(l.onObjectProperty), V = B(l.onObjectEnd), F = O$1(l.onArrayBegin), a = B(l.onArrayEnd), w$1 = o(l.onLiteralValue), v$1 = A(l.onSeparator), j$1 = k$1(l.onComment), i = A(l.onError), T$1 = g$1 && g$1.disallowComments, s = g$1 && g$1.allowTrailingComma;
|
|
2007
|
-
function c() {
|
|
2008
|
-
for (;;) {
|
|
2009
|
-
const f = e.scan();
|
|
2010
|
-
switch (e.getTokenError()) {
|
|
2011
|
-
case 4:
|
|
2012
|
-
t(14);
|
|
2013
|
-
break;
|
|
2014
|
-
case 5:
|
|
2015
|
-
t(15);
|
|
2016
|
-
break;
|
|
2017
|
-
case 3:
|
|
2018
|
-
t(13);
|
|
2019
|
-
break;
|
|
2020
|
-
case 1:
|
|
2021
|
-
T$1 || t(11);
|
|
2022
|
-
break;
|
|
2023
|
-
case 2:
|
|
2024
|
-
t(12);
|
|
2025
|
-
break;
|
|
2026
|
-
case 6:
|
|
2027
|
-
t(16);
|
|
2028
|
-
break;
|
|
2029
|
-
}
|
|
2030
|
-
switch (f) {
|
|
2031
|
-
case 12:
|
|
2032
|
-
case 13:
|
|
2033
|
-
T$1 ? t(10) : j$1();
|
|
2034
|
-
break;
|
|
2035
|
-
case 16:
|
|
2036
|
-
t(1);
|
|
2037
|
-
break;
|
|
2038
|
-
case 15:
|
|
2039
|
-
case 14: break;
|
|
2040
|
-
default: return f;
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
|
-
}
|
|
2044
|
-
function t(f, m$1 = [], y = []) {
|
|
2045
|
-
if (i(f), m$1.length + y.length > 0) {
|
|
2046
|
-
let _$1 = e.getToken();
|
|
2047
|
-
for (; _$1 !== 17;) {
|
|
2048
|
-
if (m$1.indexOf(_$1) !== -1) {
|
|
2049
|
-
c();
|
|
2050
|
-
break;
|
|
2051
|
-
} else if (y.indexOf(_$1) !== -1) break;
|
|
2052
|
-
_$1 = c();
|
|
2053
|
-
}
|
|
2054
|
-
}
|
|
2055
|
-
}
|
|
2056
|
-
function D(f) {
|
|
2057
|
-
const m$1 = e.getTokenValue();
|
|
2058
|
-
return f ? w$1(m$1) : (I$1(m$1), u.push(m$1)), c(), !0;
|
|
2059
|
-
}
|
|
2060
|
-
function G() {
|
|
2061
|
-
switch (e.getToken()) {
|
|
2062
|
-
case 11:
|
|
2063
|
-
const f = e.getTokenValue();
|
|
2064
|
-
let m$1 = Number(f);
|
|
2065
|
-
isNaN(m$1) && (t(2), m$1 = 0), w$1(m$1);
|
|
2066
|
-
break;
|
|
2067
|
-
case 7:
|
|
2068
|
-
w$1(null);
|
|
2069
|
-
break;
|
|
2070
|
-
case 8:
|
|
2071
|
-
w$1(!0);
|
|
2072
|
-
break;
|
|
2073
|
-
case 9:
|
|
2074
|
-
w$1(!1);
|
|
2075
|
-
break;
|
|
2076
|
-
default: return !1;
|
|
2077
|
-
}
|
|
2078
|
-
return c(), !0;
|
|
2079
|
-
}
|
|
2080
|
-
function M() {
|
|
2081
|
-
return e.getToken() !== 10 ? (t(3, [], [2, 5]), !1) : (D(!1), e.getToken() === 6 ? (v$1(":"), c(), E$1() || t(4, [], [2, 5])) : t(5, [], [2, 5]), u.pop(), !0);
|
|
2082
|
-
}
|
|
2083
|
-
function X() {
|
|
2084
|
-
b$1(), c();
|
|
2085
|
-
let f = !1;
|
|
2086
|
-
for (; e.getToken() !== 2 && e.getToken() !== 17;) {
|
|
2087
|
-
if (e.getToken() === 5) {
|
|
2088
|
-
if (f || t(4, [], []), v$1(","), c(), e.getToken() === 2 && s) break;
|
|
2089
|
-
} else f && t(6, [], []);
|
|
2090
|
-
M() || t(4, [], [2, 5]), f = !0;
|
|
2091
|
-
}
|
|
2092
|
-
return V(), e.getToken() !== 2 ? t(7, [2], []) : c(), !0;
|
|
2093
|
-
}
|
|
2094
|
-
function Y() {
|
|
2095
|
-
F(), c();
|
|
2096
|
-
let f = !0, m$1 = !1;
|
|
2097
|
-
for (; e.getToken() !== 4 && e.getToken() !== 17;) {
|
|
2098
|
-
if (e.getToken() === 5) {
|
|
2099
|
-
if (m$1 || t(4, [], []), v$1(","), c(), e.getToken() === 4 && s) break;
|
|
2100
|
-
} else m$1 && t(6, [], []);
|
|
2101
|
-
f ? (u.push(0), f = !1) : u[u.length - 1]++, E$1() || t(4, [], [4, 5]), m$1 = !0;
|
|
2102
|
-
}
|
|
2103
|
-
return a(), f || u.pop(), e.getToken() !== 4 ? t(8, [4], []) : c(), !0;
|
|
2104
|
-
}
|
|
2105
|
-
function E$1() {
|
|
2106
|
-
switch (e.getToken()) {
|
|
2107
|
-
case 3: return Y();
|
|
2108
|
-
case 1: return X();
|
|
2109
|
-
case 10: return D(!0);
|
|
2110
|
-
default: return G();
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
return c(), e.getToken() === 17 ? g$1.allowEmptyContent ? !0 : (t(4, [], []), !1) : E$1() ? (e.getToken() !== 17 && t(9, [], []), !0) : (t(4, [], []), !1);
|
|
2114
|
-
}
|
|
2115
|
-
var W;
|
|
2116
|
-
(function(n) {
|
|
2117
|
-
n[n.None = 0] = "None", n[n.UnexpectedEndOfComment = 1] = "UnexpectedEndOfComment", n[n.UnexpectedEndOfString = 2] = "UnexpectedEndOfString", n[n.UnexpectedEndOfNumber = 3] = "UnexpectedEndOfNumber", n[n.InvalidUnicode = 4] = "InvalidUnicode", n[n.InvalidEscapeCharacter = 5] = "InvalidEscapeCharacter", n[n.InvalidCharacter = 6] = "InvalidCharacter";
|
|
2118
|
-
})(W || (W = {}));
|
|
2119
|
-
var H;
|
|
2120
|
-
(function(n) {
|
|
2121
|
-
n[n.OpenBraceToken = 1] = "OpenBraceToken", n[n.CloseBraceToken = 2] = "CloseBraceToken", n[n.OpenBracketToken = 3] = "OpenBracketToken", n[n.CloseBracketToken = 4] = "CloseBracketToken", n[n.CommaToken = 5] = "CommaToken", n[n.ColonToken = 6] = "ColonToken", n[n.NullKeyword = 7] = "NullKeyword", n[n.TrueKeyword = 8] = "TrueKeyword", n[n.FalseKeyword = 9] = "FalseKeyword", n[n.StringLiteral = 10] = "StringLiteral", n[n.NumericLiteral = 11] = "NumericLiteral", n[n.LineCommentTrivia = 12] = "LineCommentTrivia", n[n.BlockCommentTrivia = 13] = "BlockCommentTrivia", n[n.LineBreakTrivia = 14] = "LineBreakTrivia", n[n.Trivia = 15] = "Trivia", n[n.Unknown = 16] = "Unknown", n[n.EOF = 17] = "EOF";
|
|
2122
|
-
})(H || (H = {}));
|
|
2123
|
-
const K = S$1;
|
|
2124
|
-
var q;
|
|
2125
|
-
(function(n) {
|
|
2126
|
-
n[n.InvalidSymbol = 1] = "InvalidSymbol", n[n.InvalidNumberFormat = 2] = "InvalidNumberFormat", n[n.PropertyNameExpected = 3] = "PropertyNameExpected", n[n.ValueExpected = 4] = "ValueExpected", n[n.ColonExpected = 5] = "ColonExpected", n[n.CommaExpected = 6] = "CommaExpected", n[n.CloseBraceExpected = 7] = "CloseBraceExpected", n[n.CloseBracketExpected = 8] = "CloseBracketExpected", n[n.EndOfFileExpected = 9] = "EndOfFileExpected", n[n.InvalidCommentToken = 10] = "InvalidCommentToken", n[n.UnexpectedEndOfComment = 11] = "UnexpectedEndOfComment", n[n.UnexpectedEndOfString = 12] = "UnexpectedEndOfString", n[n.UnexpectedEndOfNumber = 13] = "UnexpectedEndOfNumber", n[n.InvalidUnicode = 14] = "InvalidUnicode", n[n.InvalidEscapeCharacter = 15] = "InvalidEscapeCharacter", n[n.InvalidCharacter = 16] = "InvalidCharacter";
|
|
2127
|
-
})(q || (q = {}));
|
|
2128
|
-
function x$1(n, l) {
|
|
2129
|
-
const g$1 = JSON.parse(n, l?.reviver);
|
|
2130
|
-
return N$1(n, g$1, l), g$1;
|
|
2131
|
-
}
|
|
2132
|
-
function h(n, l) {
|
|
2133
|
-
const g$1 = K(n, l?.errors, l);
|
|
2134
|
-
return N$1(n, g$1, l), g$1;
|
|
2135
|
-
}
|
|
2136
|
-
|
|
2137
|
-
//#endregion
|
|
2138
|
-
//#region node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/ini.mjs
|
|
2139
|
-
var O, x;
|
|
2140
|
-
function j() {
|
|
2141
|
-
if (x) return O;
|
|
2142
|
-
x = 1;
|
|
2143
|
-
const { hasOwnProperty: y } = Object.prototype, d$1 = (e, t = {}) => {
|
|
2144
|
-
typeof t == "string" && (t = { section: t }), t.align = t.align === !0, t.newline = t.newline === !0, t.sort = t.sort === !0, t.whitespace = t.whitespace === !0 || t.align === !0, t.platform = t.platform || typeof process < "u" && process.platform, t.bracketedArray = t.bracketedArray !== !1;
|
|
2145
|
-
const s = t.platform === "win32" ? `\r
|
|
2146
|
-
` : `
|
|
2147
|
-
`, r$1 = t.whitespace ? " = " : "=", c = [], o = t.sort ? Object.keys(e).sort() : Object.keys(e);
|
|
2148
|
-
let g$1 = 0;
|
|
2149
|
-
t.align && (g$1 = h$2(o.filter((n) => e[n] === null || Array.isArray(e[n]) || typeof e[n] != "object").map((n) => Array.isArray(e[n]) ? `${n}[]` : n).concat([""]).reduce((n, i) => h$2(n).length >= h$2(i).length ? n : i)).length);
|
|
2150
|
-
let l = "";
|
|
2151
|
-
const m$1 = t.bracketedArray ? "[]" : "";
|
|
2152
|
-
for (const n of o) {
|
|
2153
|
-
const i = e[n];
|
|
2154
|
-
if (i && Array.isArray(i)) for (const f of i) l += h$2(`${n}${m$1}`).padEnd(g$1, " ") + r$1 + h$2(f) + s;
|
|
2155
|
-
else i && typeof i == "object" ? c.push(n) : l += h$2(n).padEnd(g$1, " ") + r$1 + h$2(i) + s;
|
|
2156
|
-
}
|
|
2157
|
-
t.section && l.length && (l = "[" + h$2(t.section) + "]" + (t.newline ? s + s : s) + l);
|
|
2158
|
-
for (const n of c) {
|
|
2159
|
-
const i = k$1(n, ".").join("\\."), f = (t.section ? t.section + "." : "") + i, u = d$1(e[n], {
|
|
2160
|
-
...t,
|
|
2161
|
-
section: f
|
|
2162
|
-
});
|
|
2163
|
-
l.length && u.length && (l += s), l += u;
|
|
2164
|
-
}
|
|
2165
|
-
return l;
|
|
2166
|
-
};
|
|
2167
|
-
function k$1(e, t) {
|
|
2168
|
-
var s = 0, r$1 = 0, c = 0, o = [];
|
|
2169
|
-
do
|
|
2170
|
-
if (c = e.indexOf(t, s), c !== -1) {
|
|
2171
|
-
if (s = c + t.length, c > 0 && e[c - 1] === "\\") continue;
|
|
2172
|
-
o.push(e.slice(r$1, c)), r$1 = c + t.length;
|
|
2173
|
-
}
|
|
2174
|
-
while (c !== -1);
|
|
2175
|
-
return o.push(e.slice(r$1)), o;
|
|
2176
|
-
}
|
|
2177
|
-
const w$1 = (e, t = {}) => {
|
|
2178
|
-
t.bracketedArray = t.bracketedArray !== !1;
|
|
2179
|
-
const s = Object.create(null);
|
|
2180
|
-
let r$1 = s, c = null;
|
|
2181
|
-
const o = /^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i, g$1 = e.split(/[\r\n]+/g), l = {};
|
|
2182
|
-
for (const n of g$1) {
|
|
2183
|
-
if (!n || n.match(/^\s*[;#]/) || n.match(/^\s*$/)) continue;
|
|
2184
|
-
const i = n.match(o);
|
|
2185
|
-
if (!i) continue;
|
|
2186
|
-
if (i[1] !== void 0) {
|
|
2187
|
-
if (c = A(i[1]), c === "__proto__") {
|
|
2188
|
-
r$1 = Object.create(null);
|
|
2189
|
-
continue;
|
|
2190
|
-
}
|
|
2191
|
-
r$1 = s[c] = s[c] || Object.create(null);
|
|
2192
|
-
continue;
|
|
2193
|
-
}
|
|
2194
|
-
const f = A(i[2]);
|
|
2195
|
-
let u;
|
|
2196
|
-
t.bracketedArray ? u = f.length > 2 && f.slice(-2) === "[]" : (l[f] = (l?.[f] || 0) + 1, u = l[f] > 1);
|
|
2197
|
-
const a = u && f.endsWith("[]") ? f.slice(0, -2) : f;
|
|
2198
|
-
if (a === "__proto__") continue;
|
|
2199
|
-
const p = i[3] ? A(i[4]) : !0, b$1 = p === "true" || p === "false" || p === "null" ? JSON.parse(p) : p;
|
|
2200
|
-
u && (y.call(r$1, a) ? Array.isArray(r$1[a]) || (r$1[a] = [r$1[a]]) : r$1[a] = []), Array.isArray(r$1[a]) ? r$1[a].push(b$1) : r$1[a] = b$1;
|
|
2201
|
-
}
|
|
2202
|
-
const m$1 = [];
|
|
2203
|
-
for (const n of Object.keys(s)) {
|
|
2204
|
-
if (!y.call(s, n) || typeof s[n] != "object" || Array.isArray(s[n])) continue;
|
|
2205
|
-
const i = k$1(n, ".");
|
|
2206
|
-
r$1 = s;
|
|
2207
|
-
const f = i.pop(), u = f.replace(/\\\./g, ".");
|
|
2208
|
-
for (const a of i) a !== "__proto__" && ((!y.call(r$1, a) || typeof r$1[a] != "object") && (r$1[a] = Object.create(null)), r$1 = r$1[a]);
|
|
2209
|
-
r$1 === s && u === f || (r$1[u] = s[n], m$1.push(n));
|
|
2210
|
-
}
|
|
2211
|
-
for (const n of m$1) delete s[n];
|
|
2212
|
-
return s;
|
|
2213
|
-
}, _$1 = (e) => e.startsWith("\"") && e.endsWith("\"") || e.startsWith("'") && e.endsWith("'"), h$2 = (e) => typeof e != "string" || e.match(/[=\r\n]/) || e.match(/^\[/) || e.length > 1 && _$1(e) || e !== e.trim() ? JSON.stringify(e) : e.split(";").join("\\;").split("#").join("\\#"), A = (e) => {
|
|
2214
|
-
if (e = (e || "").trim(), _$1(e)) {
|
|
2215
|
-
e.charAt(0) === "'" && (e = e.slice(1, -1));
|
|
2216
|
-
try {
|
|
2217
|
-
e = JSON.parse(e);
|
|
2218
|
-
} catch {}
|
|
2219
|
-
} else {
|
|
2220
|
-
let t = !1, s = "";
|
|
2221
|
-
for (let r$1 = 0, c = e.length; r$1 < c; r$1++) {
|
|
2222
|
-
const o = e.charAt(r$1);
|
|
2223
|
-
if (t) "\\;#".indexOf(o) !== -1 ? s += o : s += "\\" + o, t = !1;
|
|
2224
|
-
else {
|
|
2225
|
-
if (";#".indexOf(o) !== -1) break;
|
|
2226
|
-
o === "\\" ? t = !0 : s += o;
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
|
-
return t && (s += "\\"), s.trim();
|
|
2230
|
-
}
|
|
2231
|
-
return e;
|
|
2232
|
-
};
|
|
2233
|
-
return O = {
|
|
2234
|
-
parse: w$1,
|
|
2235
|
-
decode: w$1,
|
|
2236
|
-
stringify: d$1,
|
|
2237
|
-
encode: d$1,
|
|
2238
|
-
safe: h$2,
|
|
2239
|
-
unsafe: A
|
|
2240
|
-
}, O;
|
|
2241
|
-
}
|
|
2242
|
-
var I = j();
|
|
2243
|
-
function S(y, d$1) {
|
|
2244
|
-
return I.parse(y, d$1);
|
|
2245
|
-
}
|
|
2246
|
-
|
|
2247
|
-
//#endregion
|
|
2248
|
-
//#region node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs
|
|
2249
|
-
const defaultFindOptions = {
|
|
2250
|
-
startingFrom: ".",
|
|
2251
|
-
rootPattern: /^node_modules$/,
|
|
2252
|
-
reverse: false,
|
|
2253
|
-
test: (filePath) => {
|
|
2254
|
-
try {
|
|
2255
|
-
if (statSync(filePath).isFile()) return true;
|
|
2256
|
-
} catch {}
|
|
2257
|
-
}
|
|
2258
|
-
};
|
|
2259
|
-
async function findFile(filename, _options = {}) {
|
|
2260
|
-
const filenames = Array.isArray(filename) ? filename : [filename];
|
|
2261
|
-
const options = {
|
|
2262
|
-
...defaultFindOptions,
|
|
2263
|
-
..._options
|
|
2264
|
-
};
|
|
2265
|
-
const basePath = resolve$1(options.startingFrom);
|
|
2266
|
-
const leadingSlash = basePath[0] === "/";
|
|
2267
|
-
const segments = basePath.split("/").filter(Boolean);
|
|
2268
|
-
if (filenames.includes(segments.at(-1)) && await options.test(basePath)) return basePath;
|
|
2269
|
-
if (leadingSlash) segments[0] = "/" + segments[0];
|
|
2270
|
-
let root = segments.findIndex((r$1) => r$1.match(options.rootPattern));
|
|
2271
|
-
if (root === -1) root = 0;
|
|
2272
|
-
if (options.reverse) for (let index = root + 1; index <= segments.length; index++) for (const filename2 of filenames) {
|
|
2273
|
-
const filePath = join$1(...segments.slice(0, index), filename2);
|
|
2274
|
-
if (await options.test(filePath)) return filePath;
|
|
2275
|
-
}
|
|
2276
|
-
else for (let index = segments.length; index > root; index--) for (const filename2 of filenames) {
|
|
2277
|
-
const filePath = join$1(...segments.slice(0, index), filename2);
|
|
2278
|
-
if (await options.test(filePath)) return filePath;
|
|
2279
|
-
}
|
|
2280
|
-
throw new Error(`Cannot find matching ${filename} in ${options.startingFrom} or parent directories`);
|
|
2281
|
-
}
|
|
2282
|
-
function findNearestFile(filename, options = {}) {
|
|
2283
|
-
return findFile(filename, options);
|
|
2284
|
-
}
|
|
2285
|
-
function _resolvePath(id, opts = {}) {
|
|
2286
|
-
if (id instanceof URL || id.startsWith("file://")) return normalize$1(fileURLToPath(id));
|
|
2287
|
-
if (isAbsolute$1(id)) return normalize$1(id);
|
|
2288
|
-
return resolveModulePath(id, {
|
|
2289
|
-
...opts,
|
|
2290
|
-
from: opts.from || opts.parent || opts.url
|
|
2291
|
-
});
|
|
2292
|
-
}
|
|
2293
|
-
const lockFiles = [
|
|
2294
|
-
"yarn.lock",
|
|
2295
|
-
"package-lock.json",
|
|
2296
|
-
"pnpm-lock.yaml",
|
|
2297
|
-
"npm-shrinkwrap.json",
|
|
2298
|
-
"bun.lockb",
|
|
2299
|
-
"bun.lock",
|
|
2300
|
-
"deno.lock"
|
|
2301
|
-
];
|
|
2302
|
-
const packageFiles = [
|
|
2303
|
-
"package.json",
|
|
2304
|
-
"package.json5",
|
|
2305
|
-
"package.yaml"
|
|
2306
|
-
];
|
|
2307
|
-
const workspaceFiles = [
|
|
2308
|
-
"pnpm-workspace.yaml",
|
|
2309
|
-
"lerna.json",
|
|
2310
|
-
"turbo.json",
|
|
2311
|
-
"rush.json",
|
|
2312
|
-
"deno.json",
|
|
2313
|
-
"deno.jsonc"
|
|
2314
|
-
];
|
|
2315
|
-
const FileCache = /* @__PURE__ */ new Map();
|
|
2316
|
-
async function readPackageJSON(id, options = {}) {
|
|
2317
|
-
const resolvedPath = await resolvePackageJSON(id, options);
|
|
2318
|
-
const cache$1 = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache;
|
|
2319
|
-
if (options.cache && cache$1.has(resolvedPath)) return cache$1.get(resolvedPath);
|
|
2320
|
-
const blob = await promises.readFile(resolvedPath, "utf8");
|
|
2321
|
-
let parsed;
|
|
2322
|
-
try {
|
|
2323
|
-
parsed = x$1(blob);
|
|
2324
|
-
} catch {
|
|
2325
|
-
parsed = h(blob);
|
|
2326
|
-
}
|
|
2327
|
-
cache$1.set(resolvedPath, parsed);
|
|
2328
|
-
return parsed;
|
|
2329
|
-
}
|
|
2330
|
-
async function resolvePackageJSON(id = process.cwd(), options = {}) {
|
|
2331
|
-
return findNearestFile("package.json", {
|
|
2332
|
-
...options,
|
|
2333
|
-
startingFrom: _resolvePath(id, options)
|
|
2334
|
-
});
|
|
2335
|
-
}
|
|
2336
|
-
const workspaceTests = {
|
|
2337
|
-
workspaceFile: (opts) => findFile(workspaceFiles, opts).then((r$1) => dirname$1(r$1)),
|
|
2338
|
-
gitConfig: (opts) => findFile(".git/config", opts).then((r$1) => resolve$1(r$1, "../..")),
|
|
2339
|
-
lockFile: (opts) => findFile(lockFiles, opts).then((r$1) => dirname$1(r$1)),
|
|
2340
|
-
packageJson: (opts) => findFile(packageFiles, opts).then((r$1) => dirname$1(r$1))
|
|
2341
|
-
};
|
|
2342
|
-
async function findWorkspaceDir(id = process.cwd(), options = {}) {
|
|
2343
|
-
const startingFrom = _resolvePath(id, options);
|
|
2344
|
-
const tests = options.tests || [
|
|
2345
|
-
"workspaceFile",
|
|
2346
|
-
"gitConfig",
|
|
2347
|
-
"lockFile",
|
|
2348
|
-
"packageJson"
|
|
2349
|
-
];
|
|
2350
|
-
for (const testName of tests) {
|
|
2351
|
-
const test = workspaceTests[testName];
|
|
2352
|
-
if (options[testName] === false || !test) continue;
|
|
2353
|
-
const direction = options[testName] || (testName === "gitConfig" ? "closest" : "furthest");
|
|
2354
|
-
const detected = await test({
|
|
2355
|
-
...options,
|
|
2356
|
-
startingFrom,
|
|
2357
|
-
reverse: direction === "furthest"
|
|
2358
|
-
}).catch(() => {});
|
|
2359
|
-
if (detected) return detected;
|
|
2360
|
-
}
|
|
2361
|
-
throw new Error(`Cannot detect workspace root from ${id}`);
|
|
2362
|
-
}
|
|
2363
|
-
async function resolveGitConfig(dir, opts) {
|
|
2364
|
-
return findNearestFile(".git/config", {
|
|
2365
|
-
...opts,
|
|
2366
|
-
startingFrom: dir
|
|
2367
|
-
});
|
|
2368
|
-
}
|
|
2369
|
-
async function readGitConfig(dir, opts) {
|
|
2370
|
-
return parseGitConfig(await readFile(await resolveGitConfig(dir, opts), "utf8"));
|
|
2371
|
-
}
|
|
2372
|
-
function parseGitConfig(ini) {
|
|
2373
|
-
return S(ini.replaceAll(/^\[(\w+) "(.+)"\]$/gm, "[$1.$2]"));
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
//#endregion
|
|
2377
|
-
//#region node_modules/.pnpm/perfect-debounce@2.0.0/node_modules/perfect-debounce/dist/index.mjs
|
|
2378
|
-
const DEBOUNCE_DEFAULTS = { trailing: true };
|
|
2379
|
-
/**
|
|
2380
|
-
Debounce functions
|
|
2381
|
-
@param fn - Promise-returning/async function to debounce.
|
|
2382
|
-
@param wait - Milliseconds to wait before calling `fn`. Default value is 25ms
|
|
2383
|
-
@returns A function that delays calling `fn` until after `wait` milliseconds have elapsed since the last time it was called.
|
|
2384
|
-
@example
|
|
2385
|
-
```
|
|
2386
|
-
import { debounce } from 'perfect-debounce';
|
|
2387
|
-
const expensiveCall = async input => input;
|
|
2388
|
-
const debouncedFn = debounce(expensiveCall, 200);
|
|
2389
|
-
for (const number of [1, 2, 3]) {
|
|
2390
|
-
console.log(await debouncedFn(number));
|
|
2391
|
-
}
|
|
2392
|
-
//=> 1
|
|
2393
|
-
//=> 2
|
|
2394
|
-
//=> 3
|
|
2395
|
-
```
|
|
2396
|
-
*/
|
|
2397
|
-
function debounce(fn, wait = 25, options = {}) {
|
|
2398
|
-
options = {
|
|
2399
|
-
...DEBOUNCE_DEFAULTS,
|
|
2400
|
-
...options
|
|
2401
|
-
};
|
|
2402
|
-
if (!Number.isFinite(wait)) throw new TypeError("Expected `wait` to be a finite number");
|
|
2403
|
-
let leadingValue;
|
|
2404
|
-
let timeout;
|
|
2405
|
-
let resolveList = [];
|
|
2406
|
-
let currentPromise;
|
|
2407
|
-
let trailingArgs;
|
|
2408
|
-
const applyFn = (_this, args) => {
|
|
2409
|
-
currentPromise = _applyPromised(fn, _this, args);
|
|
2410
|
-
currentPromise.finally(() => {
|
|
2411
|
-
currentPromise = null;
|
|
2412
|
-
if (options.trailing && trailingArgs && !timeout) {
|
|
2413
|
-
const promise = applyFn(_this, trailingArgs);
|
|
2414
|
-
trailingArgs = null;
|
|
2415
|
-
return promise;
|
|
2416
|
-
}
|
|
2417
|
-
});
|
|
2418
|
-
return currentPromise;
|
|
2419
|
-
};
|
|
2420
|
-
const debounced = function(...args) {
|
|
2421
|
-
if (options.trailing) trailingArgs = args;
|
|
2422
|
-
if (currentPromise) return currentPromise;
|
|
2423
|
-
return new Promise((resolve$2) => {
|
|
2424
|
-
const shouldCallNow = !timeout && options.leading;
|
|
2425
|
-
clearTimeout(timeout);
|
|
2426
|
-
timeout = setTimeout(() => {
|
|
2427
|
-
timeout = null;
|
|
2428
|
-
const promise = options.leading ? leadingValue : applyFn(this, args);
|
|
2429
|
-
trailingArgs = null;
|
|
2430
|
-
for (const _resolve of resolveList) _resolve(promise);
|
|
2431
|
-
resolveList = [];
|
|
2432
|
-
}, wait);
|
|
2433
|
-
if (shouldCallNow) {
|
|
2434
|
-
leadingValue = applyFn(this, args);
|
|
2435
|
-
resolve$2(leadingValue);
|
|
2436
|
-
} else resolveList.push(resolve$2);
|
|
2437
|
-
});
|
|
2438
|
-
};
|
|
2439
|
-
const _clearTimeout = (timer) => {
|
|
2440
|
-
if (timer) {
|
|
2441
|
-
clearTimeout(timer);
|
|
2442
|
-
timeout = null;
|
|
2443
|
-
}
|
|
2444
|
-
};
|
|
2445
|
-
debounced.isPending = () => !!timeout;
|
|
2446
|
-
debounced.cancel = () => {
|
|
2447
|
-
_clearTimeout(timeout);
|
|
2448
|
-
resolveList = [];
|
|
2449
|
-
trailingArgs = null;
|
|
2450
|
-
};
|
|
2451
|
-
debounced.flush = () => {
|
|
2452
|
-
_clearTimeout(timeout);
|
|
2453
|
-
if (!trailingArgs || currentPromise) return;
|
|
2454
|
-
const args = trailingArgs;
|
|
2455
|
-
trailingArgs = null;
|
|
2456
|
-
return applyFn(this, args);
|
|
2457
|
-
};
|
|
2458
|
-
return debounced;
|
|
2459
|
-
}
|
|
2460
|
-
async function _applyPromised(fn, _this, args) {
|
|
2461
|
-
return await fn.apply(_this, args);
|
|
2462
|
-
}
|
|
2463
|
-
|
|
2464
|
-
//#endregion
|
|
2465
15
|
//#region node_modules/.pnpm/c12@3.3.3_magicast@0.5.1/node_modules/c12/dist/index.mjs
|
|
2466
16
|
var dist_exports = /* @__PURE__ */ __exportAll({
|
|
2467
17
|
SUPPORTED_EXTENSIONS: () => SUPPORTED_EXTENSIONS,
|
|
@@ -2494,13 +44,13 @@ async function setupDotenv(options) {
|
|
|
2494
44
|
/** Load environment variables into an object. */
|
|
2495
45
|
async function loadDotenv(options) {
|
|
2496
46
|
const environment = Object.create(null);
|
|
2497
|
-
const cwd
|
|
47
|
+
const cwd = resolve(options.cwd || ".");
|
|
2498
48
|
const _fileName = options.fileName || ".env";
|
|
2499
49
|
const dotenvFiles = typeof _fileName === "string" ? [_fileName] : _fileName;
|
|
2500
50
|
const dotenvVars = getDotEnvVars(options.env || {});
|
|
2501
51
|
Object.assign(environment, options.env);
|
|
2502
52
|
for (const file of dotenvFiles) {
|
|
2503
|
-
const dotenvFile = resolve
|
|
53
|
+
const dotenvFile = resolve(cwd, file);
|
|
2504
54
|
if (!statSync(dotenvFile, { throwIfNoEntry: false })?.isFile()) continue;
|
|
2505
55
|
const parsed = import_main.parse(await promises.readFile(dotenvFile, "utf8"));
|
|
2506
56
|
for (const key in parsed) {
|
|
@@ -2512,13 +62,13 @@ async function loadDotenv(options) {
|
|
|
2512
62
|
if (options.interpolate) interpolate(environment);
|
|
2513
63
|
return environment;
|
|
2514
64
|
}
|
|
2515
|
-
function interpolate(target, source = {}, parse
|
|
65
|
+
function interpolate(target, source = {}, parse = (v) => v) {
|
|
2516
66
|
function getValue(key) {
|
|
2517
67
|
return source[key] === void 0 ? target[key] : source[key];
|
|
2518
68
|
}
|
|
2519
69
|
function interpolate$1(value, parents = []) {
|
|
2520
70
|
if (typeof value !== "string") return value;
|
|
2521
|
-
return parse
|
|
71
|
+
return parse((value.match(/(.?\${?(?:[\w:]+)?}?)/g) || []).reduce((newValue, match) => {
|
|
2522
72
|
const parts = /(.?)\${?([\w:]+)?}?/g.exec(match) || [];
|
|
2523
73
|
const prefix = parts[1];
|
|
2524
74
|
let value$1, replacePart;
|
|
@@ -2547,11 +97,11 @@ function getDotEnvVars(targetEnvironment) {
|
|
|
2547
97
|
}
|
|
2548
98
|
const _normalize = (p) => p?.replace(/\\/g, "/");
|
|
2549
99
|
const ASYNC_LOADERS = {
|
|
2550
|
-
".yaml": () => import("./confbox.mjs").then((n) => n.
|
|
2551
|
-
".yml": () => import("./confbox.mjs").then((n) => n.
|
|
2552
|
-
".jsonc": () => import("./confbox.mjs").then((n) => n.t).then((r
|
|
2553
|
-
".json5": () => import("./confbox.mjs").then((n) => n.
|
|
2554
|
-
".toml": () => import("./confbox.mjs").then((n) => n.
|
|
100
|
+
".yaml": () => import("./confbox.mjs").then((n) => n.l).then((r) => r.parseYAML),
|
|
101
|
+
".yml": () => import("./confbox.mjs").then((n) => n.l).then((r) => r.parseYAML),
|
|
102
|
+
".jsonc": () => import("./confbox.mjs").then((n) => n.t).then((r) => r.parseJSONC),
|
|
103
|
+
".json5": () => import("./confbox.mjs").then((n) => n.p).then((r) => r.parseJSON5),
|
|
104
|
+
".toml": () => import("./confbox.mjs").then((n) => n.o).then((r) => r.parseTOML)
|
|
2555
105
|
};
|
|
2556
106
|
const SUPPORTED_EXTENSIONS = Object.freeze([
|
|
2557
107
|
".js",
|
|
@@ -2568,7 +118,7 @@ const SUPPORTED_EXTENSIONS = Object.freeze([
|
|
|
2568
118
|
".toml"
|
|
2569
119
|
]);
|
|
2570
120
|
async function loadConfig(options) {
|
|
2571
|
-
options.cwd = resolve
|
|
121
|
+
options.cwd = resolve(process.cwd(), options.cwd || ".");
|
|
2572
122
|
options.name = options.name || "config";
|
|
2573
123
|
options.envName = options.envName ?? process.env.NODE_ENV;
|
|
2574
124
|
options.configFile = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
|
|
@@ -2578,16 +128,16 @@ async function loadConfig(options) {
|
|
|
2578
128
|
...options.extend
|
|
2579
129
|
};
|
|
2580
130
|
const _merger = options.merger || defu;
|
|
2581
|
-
options.jiti = options.jiti || createJiti(join
|
|
131
|
+
options.jiti = options.jiti || createJiti(join(options.cwd, options.configFile), {
|
|
2582
132
|
interopDefault: true,
|
|
2583
133
|
moduleCache: false,
|
|
2584
134
|
extensions: [...SUPPORTED_EXTENSIONS],
|
|
2585
135
|
...options.jitiOptions
|
|
2586
136
|
});
|
|
2587
|
-
const r
|
|
137
|
+
const r = {
|
|
2588
138
|
config: {},
|
|
2589
139
|
cwd: options.cwd,
|
|
2590
|
-
configFile: resolve
|
|
140
|
+
configFile: resolve(options.cwd, options.configFile),
|
|
2591
141
|
layers: [],
|
|
2592
142
|
_configFile: void 0
|
|
2593
143
|
};
|
|
@@ -2605,10 +155,10 @@ async function loadConfig(options) {
|
|
|
2605
155
|
const _mainConfig = await resolveConfig(".", options);
|
|
2606
156
|
if (_mainConfig.configFile) {
|
|
2607
157
|
rawConfigs.main = _mainConfig.config;
|
|
2608
|
-
r
|
|
2609
|
-
r
|
|
158
|
+
r.configFile = _mainConfig.configFile;
|
|
159
|
+
r._configFile = _mainConfig._configFile;
|
|
2610
160
|
}
|
|
2611
|
-
if (_mainConfig.meta) r
|
|
161
|
+
if (_mainConfig.meta) r.meta = _mainConfig.meta;
|
|
2612
162
|
if (options.rcFile) {
|
|
2613
163
|
const rcSources = [];
|
|
2614
164
|
rcSources.push(read({
|
|
@@ -2641,17 +191,17 @@ async function loadConfig(options) {
|
|
|
2641
191
|
rawConfigs
|
|
2642
192
|
}) : value);
|
|
2643
193
|
}
|
|
2644
|
-
if (Array.isArray(configs.main)) r
|
|
194
|
+
if (Array.isArray(configs.main)) r.config = configs.main;
|
|
2645
195
|
else {
|
|
2646
|
-
r
|
|
196
|
+
r.config = _merger(configs.overrides, configs.main, configs.rc, configs.packageJson, configs.defaultConfig);
|
|
2647
197
|
if (options.extend) {
|
|
2648
|
-
await extendConfig(r
|
|
2649
|
-
r
|
|
2650
|
-
delete r
|
|
2651
|
-
r
|
|
198
|
+
await extendConfig(r.config, options);
|
|
199
|
+
r.layers = r.config._layers;
|
|
200
|
+
delete r.config._layers;
|
|
201
|
+
r.config = _merger(r.config, ...r.layers.map((e) => e.config));
|
|
2652
202
|
}
|
|
2653
203
|
}
|
|
2654
|
-
r
|
|
204
|
+
r.layers = [...[
|
|
2655
205
|
configs.overrides && {
|
|
2656
206
|
config: configs.overrides,
|
|
2657
207
|
configFile: void 0,
|
|
@@ -2670,13 +220,13 @@ async function loadConfig(options) {
|
|
|
2670
220
|
config: configs.packageJson,
|
|
2671
221
|
configFile: "package.json"
|
|
2672
222
|
}
|
|
2673
|
-
].filter((l) => l && l.config), ...r
|
|
2674
|
-
if (options.defaults) r
|
|
223
|
+
].filter((l) => l && l.config), ...r.layers];
|
|
224
|
+
if (options.defaults) r.config = _merger(r.config, options.defaults);
|
|
2675
225
|
if (options.omit$Keys) {
|
|
2676
|
-
for (const key in r
|
|
226
|
+
for (const key in r.config) if (key.startsWith("$")) delete r.config[key];
|
|
2677
227
|
}
|
|
2678
|
-
if (options.configFileRequired && !r
|
|
2679
|
-
return r
|
|
228
|
+
if (options.configFileRequired && !r._configFile) throw new Error(`Required config (${r.configFile}) cannot be resolved.`);
|
|
229
|
+
return r;
|
|
2680
230
|
}
|
|
2681
231
|
async function extendConfig(config, options) {
|
|
2682
232
|
config._layers = config._layers || [];
|
|
@@ -2741,11 +291,11 @@ async function resolveConfig(source, options, sourceOptions = {}) {
|
|
|
2741
291
|
const { digest } = await import("ohash");
|
|
2742
292
|
const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
|
|
2743
293
|
let cloneDir;
|
|
2744
|
-
const localNodeModules = resolve
|
|
2745
|
-
const parentDir = dirname
|
|
2746
|
-
if (basename
|
|
2747
|
-
else if (existsSync(localNodeModules)) cloneDir = join
|
|
2748
|
-
else cloneDir = process.env.XDG_CACHE_HOME ? resolve
|
|
294
|
+
const localNodeModules = resolve(options.cwd, "node_modules");
|
|
295
|
+
const parentDir = dirname(options.cwd);
|
|
296
|
+
if (basename(parentDir) === ".c12") cloneDir = join(parentDir, cloneName);
|
|
297
|
+
else if (existsSync(localNodeModules)) cloneDir = join(localNodeModules, ".c12", cloneName);
|
|
298
|
+
else cloneDir = process.env.XDG_CACHE_HOME ? resolve(process.env.XDG_CACHE_HOME, "c12", cloneName) : resolve(homedir(), ".cache/c12", cloneName);
|
|
2749
299
|
if (existsSync(cloneDir) && !sourceOptions.install) await rm(cloneDir, { recursive: true });
|
|
2750
300
|
source = (await downloadTemplate(source, {
|
|
2751
301
|
dir: cloneDir,
|
|
@@ -2757,21 +307,21 @@ async function resolveConfig(source, options, sourceOptions = {}) {
|
|
|
2757
307
|
})).dir;
|
|
2758
308
|
}
|
|
2759
309
|
if (NPM_PACKAGE_RE.test(source)) source = tryResolve(source, options) || source;
|
|
2760
|
-
const ext = extname
|
|
2761
|
-
const isDir = !ext || ext === basename
|
|
2762
|
-
const cwd
|
|
310
|
+
const ext = extname(source);
|
|
311
|
+
const isDir = !ext || ext === basename(source);
|
|
312
|
+
const cwd = resolve(options.cwd, isDir ? source : dirname(source));
|
|
2763
313
|
if (isDir) source = options.configFile;
|
|
2764
314
|
const res = {
|
|
2765
315
|
config: void 0,
|
|
2766
316
|
configFile: void 0,
|
|
2767
|
-
cwd
|
|
317
|
+
cwd,
|
|
2768
318
|
source,
|
|
2769
319
|
sourceOptions
|
|
2770
320
|
};
|
|
2771
|
-
res.configFile = tryResolve(resolve
|
|
321
|
+
res.configFile = tryResolve(resolve(cwd, source), options) || tryResolve(resolve(cwd, ".config", source.replace(/\.config$/, "")), options) || tryResolve(resolve(cwd, ".config", source), options) || source;
|
|
2772
322
|
if (!existsSync(res.configFile)) return res;
|
|
2773
323
|
res._configFile = res.configFile;
|
|
2774
|
-
const configFileExt = extname
|
|
324
|
+
const configFileExt = extname(res.configFile) || "";
|
|
2775
325
|
if (configFileExt in ASYNC_LOADERS) res.config = (await ASYNC_LOADERS[configFileExt]())(await readFile(res.configFile, "utf8"));
|
|
2776
326
|
else res.config = await options.jiti.import(res.configFile, { default: true });
|
|
2777
327
|
if (typeof res.config === "function") res.config = await res.config(options.context);
|
|
@@ -2792,12 +342,12 @@ async function resolveConfig(source, options, sourceOptions = {}) {
|
|
|
2792
342
|
function tryResolve(id, options) {
|
|
2793
343
|
const res = resolveModulePath(id, {
|
|
2794
344
|
try: true,
|
|
2795
|
-
from: pathToFileURL(join
|
|
345
|
+
from: pathToFileURL(join(options.cwd || ".", options.configFile || "/")),
|
|
2796
346
|
suffixes: ["", "/index"],
|
|
2797
347
|
extensions: SUPPORTED_EXTENSIONS,
|
|
2798
348
|
cache: false
|
|
2799
349
|
});
|
|
2800
|
-
return res ? normalize
|
|
350
|
+
return res ? normalize(res) : void 0;
|
|
2801
351
|
}
|
|
2802
352
|
const eventMap = {
|
|
2803
353
|
add: "created",
|
|
@@ -2810,32 +360,32 @@ async function watchConfig(options) {
|
|
|
2810
360
|
const configFileName = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
|
|
2811
361
|
const watchingFiles = [...new Set((config.layers || []).filter((l) => l.cwd).flatMap((l) => [
|
|
2812
362
|
...SUPPORTED_EXTENSIONS.flatMap((ext) => [
|
|
2813
|
-
resolve
|
|
2814
|
-
resolve
|
|
2815
|
-
resolve
|
|
363
|
+
resolve(l.cwd, configFileName + ext),
|
|
364
|
+
resolve(l.cwd, ".config", configFileName + ext),
|
|
365
|
+
resolve(l.cwd, ".config", configFileName.replace(/\.config$/, "") + ext)
|
|
2816
366
|
]),
|
|
2817
|
-
l.source && resolve
|
|
2818
|
-
options.rcFile && resolve
|
|
2819
|
-
options.packageJson && resolve
|
|
367
|
+
l.source && resolve(l.cwd, l.source),
|
|
368
|
+
options.rcFile && resolve(l.cwd, typeof options.rcFile === "string" ? options.rcFile : `.${configName}rc`),
|
|
369
|
+
options.packageJson && resolve(l.cwd, "package.json")
|
|
2820
370
|
]).filter(Boolean))];
|
|
2821
|
-
const watch$1 = await import("./chokidar.mjs").then((n) => n.i).then((r
|
|
371
|
+
const watch$1 = await import("./chokidar.mjs").then((n) => n.i).then((r) => r.watch || r.default || r);
|
|
2822
372
|
const { diff } = await import("ohash/utils");
|
|
2823
373
|
const _fswatcher = watch$1(watchingFiles, {
|
|
2824
374
|
ignoreInitial: true,
|
|
2825
375
|
...options.chokidarOptions
|
|
2826
376
|
});
|
|
2827
|
-
const onChange = async (event, path
|
|
377
|
+
const onChange = async (event, path) => {
|
|
2828
378
|
const type$1 = eventMap[event];
|
|
2829
379
|
if (!type$1) return;
|
|
2830
380
|
if (options.onWatch) await options.onWatch({
|
|
2831
381
|
type: type$1,
|
|
2832
|
-
path
|
|
382
|
+
path
|
|
2833
383
|
});
|
|
2834
384
|
const oldConfig = config;
|
|
2835
385
|
try {
|
|
2836
386
|
config = await loadConfig(options);
|
|
2837
387
|
} catch (error) {
|
|
2838
|
-
console.warn(`Failed to load config ${path
|
|
388
|
+
console.warn(`Failed to load config ${path}\n${error}`);
|
|
2839
389
|
return;
|
|
2840
390
|
}
|
|
2841
391
|
const changeCtx = {
|
|
@@ -2856,11 +406,11 @@ async function watchConfig(options) {
|
|
|
2856
406
|
await _fswatcher.close();
|
|
2857
407
|
}
|
|
2858
408
|
};
|
|
2859
|
-
return new Proxy(utils, { get(_
|
|
409
|
+
return new Proxy(utils, { get(_, prop) {
|
|
2860
410
|
if (prop in utils) return utils[prop];
|
|
2861
411
|
return config[prop];
|
|
2862
412
|
} });
|
|
2863
413
|
}
|
|
2864
414
|
|
|
2865
415
|
//#endregion
|
|
2866
|
-
export {
|
|
416
|
+
export { setupDotenv as a, loadDotenv as i, dist_exports as n, watchConfig as o, loadConfig as r, SUPPORTED_EXTENSIONS as t };
|