nitro-nightly 3.0.1-20260106-182834-5019d347 → 3.0.1-20260106-205209-b085a480

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.
Files changed (85) hide show
  1. package/dist/_build/common.mjs +24899 -0
  2. package/dist/_build/rolldown.mjs +5 -18
  3. package/dist/_build/rollup.mjs +5 -52
  4. package/dist/_build/vite.build.mjs +2 -21
  5. package/dist/{_dev.mjs → _chunks/dev.mjs} +4 -7
  6. package/dist/{_nitro.mjs → _chunks/nitro.mjs} +16 -195
  7. package/dist/_chunks/nitro2.mjs +101 -0
  8. package/dist/_chunks/utils.mjs +278 -0
  9. package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +32 -4
  10. package/dist/_libs/@jridgewell/gen-mapping.mjs +304 -2
  11. package/dist/_libs/@jridgewell/remapping.mjs +1 -2
  12. package/dist/_libs/@rollup/plugin-commonjs.mjs +75 -31
  13. package/dist/_libs/@rollup/plugin-inject.mjs +1 -3
  14. package/dist/_libs/@rollup/plugin-json.mjs +1 -1
  15. package/dist/_libs/@rollup/plugin-node-resolve.mjs +1111 -7
  16. package/dist/_libs/c12.mjs +597 -41
  17. package/dist/_libs/chokidar.mjs +235 -2
  18. package/dist/_libs/confbox.mjs +454 -1476
  19. package/dist/_libs/estree-walker.mjs +1 -144
  20. package/dist/_libs/giget.mjs +2235 -1377
  21. package/dist/_libs/httpxy.mjs +1 -1
  22. package/dist/_libs/unimport.mjs +1547 -1772
  23. package/dist/_presets.mjs +3 -9
  24. package/dist/builder.mjs +7 -12
  25. package/dist/cli/_chunks/build.mjs +1 -1
  26. package/dist/cli/_chunks/dev.mjs +3 -5
  27. package/dist/cli/_chunks/list.mjs +1 -1
  28. package/dist/cli/_chunks/prepare.mjs +1 -1
  29. package/dist/cli/_chunks/run.mjs +1 -1
  30. package/dist/types/index.d.mts +4 -4
  31. package/dist/vite.mjs +14 -1128
  32. package/package.json +2 -2
  33. package/dist/_build/shared.mjs +0 -60
  34. package/dist/_build/shared2.mjs +0 -40
  35. package/dist/_build/shared3.mjs +0 -68
  36. package/dist/_libs/@jridgewell/resolve-uri.mjs +0 -166
  37. package/dist/_libs/@jridgewell/sourcemap-codec.mjs +0 -167
  38. package/dist/_libs/@jridgewell/trace-mapping.mjs +0 -141
  39. package/dist/_libs/@rolldown/pluginutils.mjs +0 -31
  40. package/dist/_libs/@rollup/plugin-replace.mjs +0 -104
  41. package/dist/_libs/@rollup/pluginutils.mjs +0 -241
  42. package/dist/_libs/acorn.mjs +0 -5034
  43. package/dist/_libs/commondir.mjs +0 -22
  44. package/dist/_libs/deepmerge.mjs +0 -86
  45. package/dist/_libs/dot-prop.mjs +0 -138
  46. package/dist/_libs/dotenv.mjs +0 -345
  47. package/dist/_libs/duplexer.mjs +0 -71
  48. package/dist/_libs/etag.mjs +0 -80
  49. package/dist/_libs/exsolve.mjs +0 -1007
  50. package/dist/_libs/fdir.mjs +0 -514
  51. package/dist/_libs/function-bind.mjs +0 -63
  52. package/dist/_libs/gzip-size.mjs +0 -21
  53. package/dist/_libs/hasown.mjs +0 -14
  54. package/dist/_libs/is-core-module.mjs +0 -220
  55. package/dist/_libs/is-module.mjs +0 -13
  56. package/dist/_libs/is-reference.mjs +0 -33
  57. package/dist/_libs/js-tokens.mjs +0 -382
  58. package/dist/_libs/knitwork.mjs +0 -124
  59. package/dist/_libs/local-pkg.mjs +0 -125
  60. package/dist/_libs/magic-string.mjs +0 -939
  61. package/dist/_libs/mime.mjs +0 -1391
  62. package/dist/_libs/mlly.mjs +0 -1415
  63. package/dist/_libs/node-fetch-native.mjs +0 -7
  64. package/dist/_libs/nypm.mjs +0 -239
  65. package/dist/_libs/path-parse.mjs +0 -47
  66. package/dist/_libs/pathe.mjs +0 -202
  67. package/dist/_libs/perfect-debounce.mjs +0 -89
  68. package/dist/_libs/picomatch.mjs +0 -1673
  69. package/dist/_libs/pkg-types.mjs +0 -197
  70. package/dist/_libs/pretty-bytes.mjs +0 -116
  71. package/dist/_libs/quansync.mjs +0 -90
  72. package/dist/_libs/rc9.mjs +0 -136
  73. package/dist/_libs/readdirp.mjs +0 -237
  74. package/dist/_libs/resolve.mjs +0 -689
  75. package/dist/_libs/std-env.mjs +0 -158
  76. package/dist/_libs/strip-literal.mjs +0 -51
  77. package/dist/_libs/tinyexec.mjs +0 -627
  78. package/dist/_libs/tinyglobby.mjs +0 -292
  79. package/dist/_libs/unplugin-utils.mjs +0 -61
  80. package/dist/_libs/unplugin.mjs +0 -1225
  81. package/dist/_libs/untyped.mjs +0 -271
  82. package/dist/_libs/unwasm.mjs +0 -5895
  83. package/dist/_libs/webpack-virtual-modules.mjs +0 -272
  84. package/dist/_nitro2.mjs +0 -303
  85. /package/dist/{_rolldown.mjs → _common.mjs} +0 -0
@@ -1,17 +1,573 @@
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";
1
+ import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "../_common.mjs";
2
+ import { At as extname$1, Et as resolveModulePath, Ft as resolve$1, Mt as join$1, Nt as normalize$1, Ot as basename$1, _t as findWorkspaceDir, bt as readPackageJSON, kt as dirname$1 } from "../_build/common.mjs";
3
+ import { existsSync, promises, readFileSync, statSync } from "node:fs";
9
4
  import { readFile, rm } from "node:fs/promises";
10
5
  import { pathToFileURL } from "node:url";
11
6
  import { homedir } from "node:os";
7
+ import { resolve } from "node:path";
12
8
  import { createJiti } from "jiti";
9
+ import destr from "destr";
13
10
  import { defu } from "defu";
14
11
 
12
+ //#region node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/package.json
13
+ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14
+ module.exports = {
15
+ "name": "dotenv",
16
+ "version": "17.2.3",
17
+ "description": "Loads environment variables from .env file",
18
+ "main": "lib/main.js",
19
+ "types": "lib/main.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./lib/main.d.ts",
23
+ "require": "./lib/main.js",
24
+ "default": "./lib/main.js"
25
+ },
26
+ "./config": "./config.js",
27
+ "./config.js": "./config.js",
28
+ "./lib/env-options": "./lib/env-options.js",
29
+ "./lib/env-options.js": "./lib/env-options.js",
30
+ "./lib/cli-options": "./lib/cli-options.js",
31
+ "./lib/cli-options.js": "./lib/cli-options.js",
32
+ "./package.json": "./package.json"
33
+ },
34
+ "scripts": {
35
+ "dts-check": "tsc --project tests/types/tsconfig.json",
36
+ "lint": "standard",
37
+ "pretest": "npm run lint && npm run dts-check",
38
+ "test": "tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000",
39
+ "test:coverage": "tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
40
+ "prerelease": "npm test",
41
+ "release": "standard-version"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git://github.com/motdotla/dotenv.git"
46
+ },
47
+ "homepage": "https://github.com/motdotla/dotenv#readme",
48
+ "funding": "https://dotenvx.com",
49
+ "keywords": [
50
+ "dotenv",
51
+ "env",
52
+ ".env",
53
+ "environment",
54
+ "variables",
55
+ "config",
56
+ "settings"
57
+ ],
58
+ "readmeFilename": "README.md",
59
+ "license": "BSD-2-Clause",
60
+ "devDependencies": {
61
+ "@types/node": "^18.11.3",
62
+ "decache": "^4.6.2",
63
+ "sinon": "^14.0.1",
64
+ "standard": "^17.0.0",
65
+ "standard-version": "^9.5.0",
66
+ "tap": "^19.2.0",
67
+ "typescript": "^4.8.4"
68
+ },
69
+ "engines": { "node": ">=12" },
70
+ "browser": { "fs": false }
71
+ };
72
+ }));
73
+
74
+ //#endregion
75
+ //#region node_modules/.pnpm/dotenv@17.2.3/node_modules/dotenv/lib/main.js
76
+ var require_main = /* @__PURE__ */ __commonJSMin(((exports, module) => {
77
+ const fs$1 = __require("fs");
78
+ const path$1 = __require("path");
79
+ const os$1 = __require("os");
80
+ const crypto = __require("crypto");
81
+ const version = require_package().version;
82
+ const TIPS = [
83
+ "🔐 encrypt with Dotenvx: https://dotenvx.com",
84
+ "🔐 prevent committing .env to code: https://dotenvx.com/precommit",
85
+ "🔐 prevent building .env in docker: https://dotenvx.com/prebuild",
86
+ "📡 add observability to secrets: https://dotenvx.com/ops",
87
+ "👥 sync secrets across teammates & machines: https://dotenvx.com/ops",
88
+ "🗂️ backup and recover secrets: https://dotenvx.com/ops",
89
+ "✅ audit secrets and track compliance: https://dotenvx.com/ops",
90
+ "🔄 add secrets lifecycle management: https://dotenvx.com/ops",
91
+ "🔑 add access controls to secrets: https://dotenvx.com/ops",
92
+ "🛠️ run anywhere with `dotenvx run -- yourcommand`",
93
+ "⚙️ specify custom .env file path with { path: '/custom/path/.env' }",
94
+ "⚙️ enable debug logging with { debug: true }",
95
+ "⚙️ override existing env vars with { override: true }",
96
+ "⚙️ suppress all logs with { quiet: true }",
97
+ "⚙️ write to custom object with { processEnv: myObject }",
98
+ "⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"
99
+ ];
100
+ function _getRandomTip() {
101
+ return TIPS[Math.floor(Math.random() * TIPS.length)];
102
+ }
103
+ function parseBoolean(value) {
104
+ if (typeof value === "string") return ![
105
+ "false",
106
+ "0",
107
+ "no",
108
+ "off",
109
+ ""
110
+ ].includes(value.toLowerCase());
111
+ return Boolean(value);
112
+ }
113
+ function supportsAnsi() {
114
+ return process.stdout.isTTY;
115
+ }
116
+ function dim(text) {
117
+ return supportsAnsi() ? `\x1b[2m${text}\x1b[0m` : text;
118
+ }
119
+ const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
120
+ function parse(src) {
121
+ const obj = {};
122
+ let lines = src.toString();
123
+ lines = lines.replace(/\r\n?/gm, "\n");
124
+ let match;
125
+ while ((match = LINE.exec(lines)) != null) {
126
+ const key = match[1];
127
+ let value = match[2] || "";
128
+ value = value.trim();
129
+ const maybeQuote = value[0];
130
+ value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
131
+ if (maybeQuote === "\"") {
132
+ value = value.replace(/\\n/g, "\n");
133
+ value = value.replace(/\\r/g, "\r");
134
+ }
135
+ obj[key] = value;
136
+ }
137
+ return obj;
138
+ }
139
+ function _parseVault(options) {
140
+ options = options || {};
141
+ const vaultPath = _vaultPath(options);
142
+ options.path = vaultPath;
143
+ const result = DotenvModule.configDotenv(options);
144
+ if (!result.parsed) {
145
+ const err = /* @__PURE__ */ new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
146
+ err.code = "MISSING_DATA";
147
+ throw err;
148
+ }
149
+ const keys = _dotenvKey(options).split(",");
150
+ const length = keys.length;
151
+ let decrypted;
152
+ for (let i = 0; i < length; i++) try {
153
+ const attrs = _instructions(result, keys[i].trim());
154
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
155
+ break;
156
+ } catch (error) {
157
+ if (i + 1 >= length) throw error;
158
+ }
159
+ return DotenvModule.parse(decrypted);
160
+ }
161
+ function _warn(message) {
162
+ console.error(`[dotenv@${version}][WARN] ${message}`);
163
+ }
164
+ function _debug(message) {
165
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
166
+ }
167
+ function _log(message) {
168
+ console.log(`[dotenv@${version}] ${message}`);
169
+ }
170
+ function _dotenvKey(options) {
171
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) return options.DOTENV_KEY;
172
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) return process.env.DOTENV_KEY;
173
+ return "";
174
+ }
175
+ function _instructions(result, dotenvKey) {
176
+ let uri;
177
+ try {
178
+ uri = new URL(dotenvKey);
179
+ } catch (error) {
180
+ if (error.code === "ERR_INVALID_URL") {
181
+ 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");
182
+ err.code = "INVALID_DOTENV_KEY";
183
+ throw err;
184
+ }
185
+ throw error;
186
+ }
187
+ const key = uri.password;
188
+ if (!key) {
189
+ const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing key part");
190
+ err.code = "INVALID_DOTENV_KEY";
191
+ throw err;
192
+ }
193
+ const environment = uri.searchParams.get("environment");
194
+ if (!environment) {
195
+ const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: Missing environment part");
196
+ err.code = "INVALID_DOTENV_KEY";
197
+ throw err;
198
+ }
199
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
200
+ const ciphertext = result.parsed[environmentKey];
201
+ if (!ciphertext) {
202
+ const err = /* @__PURE__ */ new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
203
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
204
+ throw err;
205
+ }
206
+ return {
207
+ ciphertext,
208
+ key
209
+ };
210
+ }
211
+ function _vaultPath(options) {
212
+ let possibleVaultPath = null;
213
+ if (options && options.path && options.path.length > 0) if (Array.isArray(options.path)) {
214
+ for (const filepath of options.path) if (fs$1.existsSync(filepath)) possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
215
+ } else possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
216
+ else possibleVaultPath = path$1.resolve(process.cwd(), ".env.vault");
217
+ if (fs$1.existsSync(possibleVaultPath)) return possibleVaultPath;
218
+ return null;
219
+ }
220
+ function _resolveHome(envPath) {
221
+ return envPath[0] === "~" ? path$1.join(os$1.homedir(), envPath.slice(1)) : envPath;
222
+ }
223
+ function _configVault(options) {
224
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
225
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
226
+ if (debug || !quiet) _log("Loading env from encrypted .env.vault");
227
+ const parsed = DotenvModule._parseVault(options);
228
+ let processEnv = process.env;
229
+ if (options && options.processEnv != null) processEnv = options.processEnv;
230
+ DotenvModule.populate(processEnv, parsed, options);
231
+ return { parsed };
232
+ }
233
+ function configDotenv(options) {
234
+ const dotenvPath = path$1.resolve(process.cwd(), ".env");
235
+ let encoding = "utf8";
236
+ let processEnv = process.env;
237
+ if (options && options.processEnv != null) processEnv = options.processEnv;
238
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
239
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
240
+ if (options && options.encoding) encoding = options.encoding;
241
+ else if (debug) _debug("No encoding is specified. UTF-8 is used by default");
242
+ let optionPaths = [dotenvPath];
243
+ if (options && options.path) if (!Array.isArray(options.path)) optionPaths = [_resolveHome(options.path)];
244
+ else {
245
+ optionPaths = [];
246
+ for (const filepath of options.path) optionPaths.push(_resolveHome(filepath));
247
+ }
248
+ let lastError;
249
+ const parsedAll = {};
250
+ for (const path$2 of optionPaths) try {
251
+ const parsed = DotenvModule.parse(fs$1.readFileSync(path$2, { encoding }));
252
+ DotenvModule.populate(parsedAll, parsed, options);
253
+ } catch (e) {
254
+ if (debug) _debug(`Failed to load ${path$2} ${e.message}`);
255
+ lastError = e;
256
+ }
257
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
258
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
259
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
260
+ if (debug || !quiet) {
261
+ const keysCount = Object.keys(populated).length;
262
+ const shortPaths = [];
263
+ for (const filePath of optionPaths) try {
264
+ const relative$1 = path$1.relative(process.cwd(), filePath);
265
+ shortPaths.push(relative$1);
266
+ } catch (e) {
267
+ if (debug) _debug(`Failed to load ${filePath} ${e.message}`);
268
+ lastError = e;
269
+ }
270
+ _log(`injecting env (${keysCount}) from ${shortPaths.join(",")} ${dim(`-- tip: ${_getRandomTip()}`)}`);
271
+ }
272
+ if (lastError) return {
273
+ parsed: parsedAll,
274
+ error: lastError
275
+ };
276
+ else return { parsed: parsedAll };
277
+ }
278
+ function config(options) {
279
+ if (_dotenvKey(options).length === 0) return DotenvModule.configDotenv(options);
280
+ const vaultPath = _vaultPath(options);
281
+ if (!vaultPath) {
282
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
283
+ return DotenvModule.configDotenv(options);
284
+ }
285
+ return DotenvModule._configVault(options);
286
+ }
287
+ function decrypt(encrypted, keyStr) {
288
+ const key = Buffer.from(keyStr.slice(-64), "hex");
289
+ let ciphertext = Buffer.from(encrypted, "base64");
290
+ const nonce = ciphertext.subarray(0, 12);
291
+ const authTag = ciphertext.subarray(-16);
292
+ ciphertext = ciphertext.subarray(12, -16);
293
+ try {
294
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
295
+ aesgcm.setAuthTag(authTag);
296
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
297
+ } catch (error) {
298
+ const isRange = error instanceof RangeError;
299
+ const invalidKeyLength = error.message === "Invalid key length";
300
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
301
+ if (isRange || invalidKeyLength) {
302
+ const err = /* @__PURE__ */ new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
303
+ err.code = "INVALID_DOTENV_KEY";
304
+ throw err;
305
+ } else if (decryptionFailed) {
306
+ const err = /* @__PURE__ */ new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
307
+ err.code = "DECRYPTION_FAILED";
308
+ throw err;
309
+ } else throw error;
310
+ }
311
+ }
312
+ function populate(processEnv, parsed, options = {}) {
313
+ const debug = Boolean(options && options.debug);
314
+ const override = Boolean(options && options.override);
315
+ const populated = {};
316
+ if (typeof parsed !== "object") {
317
+ const err = /* @__PURE__ */ new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
318
+ err.code = "OBJECT_REQUIRED";
319
+ throw err;
320
+ }
321
+ for (const key of Object.keys(parsed)) if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
322
+ if (override === true) {
323
+ processEnv[key] = parsed[key];
324
+ populated[key] = parsed[key];
325
+ }
326
+ if (debug) if (override === true) _debug(`"${key}" is already defined and WAS overwritten`);
327
+ else _debug(`"${key}" is already defined and was NOT overwritten`);
328
+ } else {
329
+ processEnv[key] = parsed[key];
330
+ populated[key] = parsed[key];
331
+ }
332
+ return populated;
333
+ }
334
+ const DotenvModule = {
335
+ configDotenv,
336
+ _configVault,
337
+ _parseVault,
338
+ config,
339
+ decrypt,
340
+ parse,
341
+ populate
342
+ };
343
+ module.exports.configDotenv = DotenvModule.configDotenv;
344
+ module.exports._configVault = DotenvModule._configVault;
345
+ module.exports._parseVault = DotenvModule._parseVault;
346
+ module.exports.config = DotenvModule.config;
347
+ module.exports.decrypt = DotenvModule.decrypt;
348
+ module.exports.parse = DotenvModule.parse;
349
+ module.exports.populate = DotenvModule.populate;
350
+ module.exports = DotenvModule;
351
+ }));
352
+
353
+ //#endregion
354
+ //#region node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs
355
+ function isBuffer(obj) {
356
+ return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
357
+ }
358
+ function keyIdentity(key) {
359
+ return key;
360
+ }
361
+ function flatten(target, opts) {
362
+ opts = opts || {};
363
+ const delimiter$1 = opts.delimiter || ".";
364
+ const maxDepth = opts.maxDepth;
365
+ const transformKey = opts.transformKey || keyIdentity;
366
+ const output = {};
367
+ function step(object, prev, currentDepth) {
368
+ currentDepth = currentDepth || 1;
369
+ Object.keys(object).forEach(function(key) {
370
+ const value = object[key];
371
+ const isarray = opts.safe && Array.isArray(value);
372
+ const type$1 = Object.prototype.toString.call(value);
373
+ const isbuffer = isBuffer(value);
374
+ const isobject = type$1 === "[object Object]" || type$1 === "[object Array]";
375
+ const newKey = prev ? prev + delimiter$1 + transformKey(key) : transformKey(key);
376
+ if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) return step(value, newKey, currentDepth + 1);
377
+ output[newKey] = value;
378
+ });
379
+ }
380
+ step(target);
381
+ return output;
382
+ }
383
+ function unflatten(target, opts) {
384
+ opts = opts || {};
385
+ const delimiter$1 = opts.delimiter || ".";
386
+ const overwrite = opts.overwrite || false;
387
+ const transformKey = opts.transformKey || keyIdentity;
388
+ const result = {};
389
+ if (isBuffer(target) || Object.prototype.toString.call(target) !== "[object Object]") return target;
390
+ function getkey(key) {
391
+ const parsedKey = Number(key);
392
+ return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
393
+ }
394
+ function addKeys(keyPrefix, recipient, target$1) {
395
+ return Object.keys(target$1).reduce(function(result$1, key) {
396
+ result$1[keyPrefix + delimiter$1 + key] = target$1[key];
397
+ return result$1;
398
+ }, recipient);
399
+ }
400
+ function isEmpty(val) {
401
+ const type$1 = Object.prototype.toString.call(val);
402
+ const isArray = type$1 === "[object Array]";
403
+ const isObject = type$1 === "[object Object]";
404
+ if (!val) return true;
405
+ else if (isArray) return !val.length;
406
+ else if (isObject) return !Object.keys(val).length;
407
+ }
408
+ target = Object.keys(target).reduce(function(result$1, key) {
409
+ const type$1 = Object.prototype.toString.call(target[key]);
410
+ if (!(type$1 === "[object Object]" || type$1 === "[object Array]") || isEmpty(target[key])) {
411
+ result$1[key] = target[key];
412
+ return result$1;
413
+ } else return addKeys(key, result$1, flatten(target[key], opts));
414
+ }, {});
415
+ Object.keys(target).forEach(function(key) {
416
+ const split = key.split(delimiter$1).map(transformKey);
417
+ let key1 = getkey(split.shift());
418
+ let key2 = getkey(split[0]);
419
+ let recipient = result;
420
+ while (key2 !== void 0) {
421
+ if (key1 === "__proto__") return;
422
+ const type$1 = Object.prototype.toString.call(recipient[key1]);
423
+ const isobject = type$1 === "[object Object]" || type$1 === "[object Array]";
424
+ if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") return;
425
+ if (overwrite && !isobject || !overwrite && recipient[key1] == null) recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
426
+ recipient = recipient[key1];
427
+ if (split.length > 0) {
428
+ key1 = getkey(split.shift());
429
+ key2 = getkey(split[0]);
430
+ }
431
+ }
432
+ recipient[key1] = unflatten(target[key], opts);
433
+ });
434
+ return result;
435
+ }
436
+ const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
437
+ const RE_LINES = /\n|\r|\r\n/;
438
+ const defaults = {
439
+ name: ".conf",
440
+ dir: process.cwd(),
441
+ flat: false
442
+ };
443
+ function withDefaults(options) {
444
+ if (typeof options === "string") options = { name: options };
445
+ return {
446
+ ...defaults,
447
+ ...options
448
+ };
449
+ }
450
+ function parse(contents, options = {}) {
451
+ const config = {};
452
+ const lines = contents.split(RE_LINES);
453
+ for (const line of lines) {
454
+ const match = line.match(RE_KEY_VAL);
455
+ if (!match) continue;
456
+ const key = match[1];
457
+ if (!key || key === "__proto__" || key === "constructor") continue;
458
+ const value = destr((match[2] || "").trim());
459
+ if (key.endsWith("[]")) {
460
+ const nkey = key.slice(0, Math.max(0, key.length - 2));
461
+ config[nkey] = (config[nkey] || []).concat(value);
462
+ continue;
463
+ }
464
+ config[key] = value;
465
+ }
466
+ return options.flat ? config : unflatten(config, { overwrite: true });
467
+ }
468
+ function parseFile(path$2, options) {
469
+ if (!existsSync(path$2)) return {};
470
+ return parse(readFileSync(path$2, "utf8"), options);
471
+ }
472
+ function read(options) {
473
+ options = withDefaults(options);
474
+ return parseFile(resolve(options.dir, options.name), options);
475
+ }
476
+ function readUser(options) {
477
+ options = withDefaults(options);
478
+ options.dir = process.env.XDG_CONFIG_HOME || homedir();
479
+ return read(options);
480
+ }
481
+
482
+ //#endregion
483
+ //#region node_modules/.pnpm/perfect-debounce@2.0.0/node_modules/perfect-debounce/dist/index.mjs
484
+ const DEBOUNCE_DEFAULTS = { trailing: true };
485
+ /**
486
+ Debounce functions
487
+ @param fn - Promise-returning/async function to debounce.
488
+ @param wait - Milliseconds to wait before calling `fn`. Default value is 25ms
489
+ @returns A function that delays calling `fn` until after `wait` milliseconds have elapsed since the last time it was called.
490
+ @example
491
+ ```
492
+ import { debounce } from 'perfect-debounce';
493
+ const expensiveCall = async input => input;
494
+ const debouncedFn = debounce(expensiveCall, 200);
495
+ for (const number of [1, 2, 3]) {
496
+ console.log(await debouncedFn(number));
497
+ }
498
+ //=> 1
499
+ //=> 2
500
+ //=> 3
501
+ ```
502
+ */
503
+ function debounce(fn, wait = 25, options = {}) {
504
+ options = {
505
+ ...DEBOUNCE_DEFAULTS,
506
+ ...options
507
+ };
508
+ if (!Number.isFinite(wait)) throw new TypeError("Expected `wait` to be a finite number");
509
+ let leadingValue;
510
+ let timeout;
511
+ let resolveList = [];
512
+ let currentPromise;
513
+ let trailingArgs;
514
+ const applyFn = (_this, args) => {
515
+ currentPromise = _applyPromised(fn, _this, args);
516
+ currentPromise.finally(() => {
517
+ currentPromise = null;
518
+ if (options.trailing && trailingArgs && !timeout) {
519
+ const promise = applyFn(_this, trailingArgs);
520
+ trailingArgs = null;
521
+ return promise;
522
+ }
523
+ });
524
+ return currentPromise;
525
+ };
526
+ const debounced = function(...args) {
527
+ if (options.trailing) trailingArgs = args;
528
+ if (currentPromise) return currentPromise;
529
+ return new Promise((resolve$2) => {
530
+ const shouldCallNow = !timeout && options.leading;
531
+ clearTimeout(timeout);
532
+ timeout = setTimeout(() => {
533
+ timeout = null;
534
+ const promise = options.leading ? leadingValue : applyFn(this, args);
535
+ trailingArgs = null;
536
+ for (const _resolve of resolveList) _resolve(promise);
537
+ resolveList = [];
538
+ }, wait);
539
+ if (shouldCallNow) {
540
+ leadingValue = applyFn(this, args);
541
+ resolve$2(leadingValue);
542
+ } else resolveList.push(resolve$2);
543
+ });
544
+ };
545
+ const _clearTimeout = (timer) => {
546
+ if (timer) {
547
+ clearTimeout(timer);
548
+ timeout = null;
549
+ }
550
+ };
551
+ debounced.isPending = () => !!timeout;
552
+ debounced.cancel = () => {
553
+ _clearTimeout(timeout);
554
+ resolveList = [];
555
+ trailingArgs = null;
556
+ };
557
+ debounced.flush = () => {
558
+ _clearTimeout(timeout);
559
+ if (!trailingArgs || currentPromise) return;
560
+ const args = trailingArgs;
561
+ trailingArgs = null;
562
+ return applyFn(this, args);
563
+ };
564
+ return debounced;
565
+ }
566
+ async function _applyPromised(fn, _this, args) {
567
+ return await fn.apply(_this, args);
568
+ }
569
+
570
+ //#endregion
15
571
  //#region node_modules/.pnpm/c12@3.3.3_magicast@0.5.1/node_modules/c12/dist/index.mjs
16
572
  var dist_exports = /* @__PURE__ */ __exportAll({
17
573
  SUPPORTED_EXTENSIONS: () => SUPPORTED_EXTENSIONS,
@@ -44,13 +600,13 @@ async function setupDotenv(options) {
44
600
  /** Load environment variables into an object. */
45
601
  async function loadDotenv(options) {
46
602
  const environment = Object.create(null);
47
- const cwd = resolve(options.cwd || ".");
603
+ const cwd = resolve$1(options.cwd || ".");
48
604
  const _fileName = options.fileName || ".env";
49
605
  const dotenvFiles = typeof _fileName === "string" ? [_fileName] : _fileName;
50
606
  const dotenvVars = getDotEnvVars(options.env || {});
51
607
  Object.assign(environment, options.env);
52
608
  for (const file of dotenvFiles) {
53
- const dotenvFile = resolve(cwd, file);
609
+ const dotenvFile = resolve$1(cwd, file);
54
610
  if (!statSync(dotenvFile, { throwIfNoEntry: false })?.isFile()) continue;
55
611
  const parsed = import_main.parse(await promises.readFile(dotenvFile, "utf8"));
56
612
  for (const key in parsed) {
@@ -62,13 +618,13 @@ async function loadDotenv(options) {
62
618
  if (options.interpolate) interpolate(environment);
63
619
  return environment;
64
620
  }
65
- function interpolate(target, source = {}, parse = (v) => v) {
621
+ function interpolate(target, source = {}, parse$1 = (v) => v) {
66
622
  function getValue(key) {
67
623
  return source[key] === void 0 ? target[key] : source[key];
68
624
  }
69
625
  function interpolate$1(value, parents = []) {
70
626
  if (typeof value !== "string") return value;
71
- return parse((value.match(/(.?\${?(?:[\w:]+)?}?)/g) || []).reduce((newValue, match) => {
627
+ return parse$1((value.match(/(.?\${?(?:[\w:]+)?}?)/g) || []).reduce((newValue, match) => {
72
628
  const parts = /(.?)\${?([\w:]+)?}?/g.exec(match) || [];
73
629
  const prefix = parts[1];
74
630
  let value$1, replacePart;
@@ -97,11 +653,11 @@ function getDotEnvVars(targetEnvironment) {
97
653
  }
98
654
  const _normalize = (p) => p?.replace(/\\/g, "/");
99
655
  const ASYNC_LOADERS = {
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),
656
+ ".yaml": () => import("./confbox.mjs").then((n) => n.o).then((r) => r.parseYAML),
657
+ ".yml": () => import("./confbox.mjs").then((n) => n.o).then((r) => r.parseYAML),
102
658
  ".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)
659
+ ".json5": () => import("./confbox.mjs").then((n) => n.c).then((r) => r.parseJSON5),
660
+ ".toml": () => import("./confbox.mjs").then((n) => n.r).then((r) => r.parseTOML)
105
661
  };
106
662
  const SUPPORTED_EXTENSIONS = Object.freeze([
107
663
  ".js",
@@ -118,7 +674,7 @@ const SUPPORTED_EXTENSIONS = Object.freeze([
118
674
  ".toml"
119
675
  ]);
120
676
  async function loadConfig(options) {
121
- options.cwd = resolve(process.cwd(), options.cwd || ".");
677
+ options.cwd = resolve$1(process.cwd(), options.cwd || ".");
122
678
  options.name = options.name || "config";
123
679
  options.envName = options.envName ?? process.env.NODE_ENV;
124
680
  options.configFile = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
@@ -128,7 +684,7 @@ async function loadConfig(options) {
128
684
  ...options.extend
129
685
  };
130
686
  const _merger = options.merger || defu;
131
- options.jiti = options.jiti || createJiti(join(options.cwd, options.configFile), {
687
+ options.jiti = options.jiti || createJiti(join$1(options.cwd, options.configFile), {
132
688
  interopDefault: true,
133
689
  moduleCache: false,
134
690
  extensions: [...SUPPORTED_EXTENSIONS],
@@ -137,7 +693,7 @@ async function loadConfig(options) {
137
693
  const r = {
138
694
  config: {},
139
695
  cwd: options.cwd,
140
- configFile: resolve(options.cwd, options.configFile),
696
+ configFile: resolve$1(options.cwd, options.configFile),
141
697
  layers: [],
142
698
  _configFile: void 0
143
699
  };
@@ -291,11 +847,11 @@ async function resolveConfig(source, options, sourceOptions = {}) {
291
847
  const { digest } = await import("ohash");
292
848
  const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
293
849
  let cloneDir;
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);
850
+ const localNodeModules = resolve$1(options.cwd, "node_modules");
851
+ const parentDir = dirname$1(options.cwd);
852
+ if (basename$1(parentDir) === ".c12") cloneDir = join$1(parentDir, cloneName);
853
+ else if (existsSync(localNodeModules)) cloneDir = join$1(localNodeModules, ".c12", cloneName);
854
+ else cloneDir = process.env.XDG_CACHE_HOME ? resolve$1(process.env.XDG_CACHE_HOME, "c12", cloneName) : resolve$1(homedir(), ".cache/c12", cloneName);
299
855
  if (existsSync(cloneDir) && !sourceOptions.install) await rm(cloneDir, { recursive: true });
300
856
  source = (await downloadTemplate(source, {
301
857
  dir: cloneDir,
@@ -307,9 +863,9 @@ async function resolveConfig(source, options, sourceOptions = {}) {
307
863
  })).dir;
308
864
  }
309
865
  if (NPM_PACKAGE_RE.test(source)) source = tryResolve(source, options) || source;
310
- const ext = extname(source);
311
- const isDir = !ext || ext === basename(source);
312
- const cwd = resolve(options.cwd, isDir ? source : dirname(source));
866
+ const ext = extname$1(source);
867
+ const isDir = !ext || ext === basename$1(source);
868
+ const cwd = resolve$1(options.cwd, isDir ? source : dirname$1(source));
313
869
  if (isDir) source = options.configFile;
314
870
  const res = {
315
871
  config: void 0,
@@ -318,10 +874,10 @@ async function resolveConfig(source, options, sourceOptions = {}) {
318
874
  source,
319
875
  sourceOptions
320
876
  };
321
- res.configFile = tryResolve(resolve(cwd, source), options) || tryResolve(resolve(cwd, ".config", source.replace(/\.config$/, "")), options) || tryResolve(resolve(cwd, ".config", source), options) || source;
877
+ res.configFile = tryResolve(resolve$1(cwd, source), options) || tryResolve(resolve$1(cwd, ".config", source.replace(/\.config$/, "")), options) || tryResolve(resolve$1(cwd, ".config", source), options) || source;
322
878
  if (!existsSync(res.configFile)) return res;
323
879
  res._configFile = res.configFile;
324
- const configFileExt = extname(res.configFile) || "";
880
+ const configFileExt = extname$1(res.configFile) || "";
325
881
  if (configFileExt in ASYNC_LOADERS) res.config = (await ASYNC_LOADERS[configFileExt]())(await readFile(res.configFile, "utf8"));
326
882
  else res.config = await options.jiti.import(res.configFile, { default: true });
327
883
  if (typeof res.config === "function") res.config = await res.config(options.context);
@@ -342,12 +898,12 @@ async function resolveConfig(source, options, sourceOptions = {}) {
342
898
  function tryResolve(id, options) {
343
899
  const res = resolveModulePath(id, {
344
900
  try: true,
345
- from: pathToFileURL(join(options.cwd || ".", options.configFile || "/")),
901
+ from: pathToFileURL(join$1(options.cwd || ".", options.configFile || "/")),
346
902
  suffixes: ["", "/index"],
347
903
  extensions: SUPPORTED_EXTENSIONS,
348
904
  cache: false
349
905
  });
350
- return res ? normalize(res) : void 0;
906
+ return res ? normalize$1(res) : void 0;
351
907
  }
352
908
  const eventMap = {
353
909
  add: "created",
@@ -360,13 +916,13 @@ async function watchConfig(options) {
360
916
  const configFileName = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
361
917
  const watchingFiles = [...new Set((config.layers || []).filter((l) => l.cwd).flatMap((l) => [
362
918
  ...SUPPORTED_EXTENSIONS.flatMap((ext) => [
363
- resolve(l.cwd, configFileName + ext),
364
- resolve(l.cwd, ".config", configFileName + ext),
365
- resolve(l.cwd, ".config", configFileName.replace(/\.config$/, "") + ext)
919
+ resolve$1(l.cwd, configFileName + ext),
920
+ resolve$1(l.cwd, ".config", configFileName + ext),
921
+ resolve$1(l.cwd, ".config", configFileName.replace(/\.config$/, "") + ext)
366
922
  ]),
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")
923
+ l.source && resolve$1(l.cwd, l.source),
924
+ options.rcFile && resolve$1(l.cwd, typeof options.rcFile === "string" ? options.rcFile : `.${configName}rc`),
925
+ options.packageJson && resolve$1(l.cwd, "package.json")
370
926
  ]).filter(Boolean))];
371
927
  const watch$1 = await import("./chokidar.mjs").then((n) => n.i).then((r) => r.watch || r.default || r);
372
928
  const { diff } = await import("ohash/utils");
@@ -374,18 +930,18 @@ async function watchConfig(options) {
374
930
  ignoreInitial: true,
375
931
  ...options.chokidarOptions
376
932
  });
377
- const onChange = async (event, path) => {
933
+ const onChange = async (event, path$2) => {
378
934
  const type$1 = eventMap[event];
379
935
  if (!type$1) return;
380
936
  if (options.onWatch) await options.onWatch({
381
937
  type: type$1,
382
- path
938
+ path: path$2
383
939
  });
384
940
  const oldConfig = config;
385
941
  try {
386
942
  config = await loadConfig(options);
387
943
  } catch (error) {
388
- console.warn(`Failed to load config ${path}\n${error}`);
944
+ console.warn(`Failed to load config ${path$2}\n${error}`);
389
945
  return;
390
946
  }
391
947
  const changeCtx = {
@@ -413,4 +969,4 @@ async function watchConfig(options) {
413
969
  }
414
970
 
415
971
  //#endregion
416
- export { setupDotenv as a, loadDotenv as i, dist_exports as n, watchConfig as o, loadConfig as r, SUPPORTED_EXTENSIONS as t };
972
+ export { setupDotenv as a, loadDotenv as i, dist_exports as n, watchConfig as o, loadConfig as r, debounce as s, SUPPORTED_EXTENSIONS as t };