nitro-nightly 3.0.1-alpha.1 → 3.0.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/_build/common.mjs +24924 -52
- package/dist/_build/rolldown.mjs +29 -63
- package/dist/_build/rollup.mjs +22 -110
- package/dist/_build/vite.build.mjs +3 -43
- package/dist/{_dev.mjs → _chunks/dev.mjs} +45 -43
- package/dist/_chunks/{B-D1JOIz.mjs → nitro.mjs} +144 -308
- package/dist/_chunks/nitro2.mjs +101 -0
- package/dist/_chunks/utils.mjs +254 -0
- package/dist/{_chunks/Bqks5huO.mjs → _common.mjs} +24 -10
- package/dist/_libs/c12+giget+readdirp+chokidar.d.mts +214 -0
- package/dist/_libs/citty.mjs +140 -110
- package/dist/_libs/{plugin-commonjs.mjs → commondir+is-reference.mjs} +59 -250
- package/dist/_libs/compatx.d.mts +47 -0
- package/dist/_libs/confbox.mjs +388 -799
- package/dist/_libs/esbuild.d.mts +20 -0
- package/dist/_libs/estree-walker.mjs +1 -144
- package/dist/_libs/{plugin-node-resolve.mjs → hasown+resolve+deepmerge.mjs} +497 -78
- package/dist/_libs/httpxy.d.mts +79 -0
- package/dist/_libs/httpxy.mjs +6 -1
- package/dist/_libs/magic-string.d.mts +220 -0
- package/dist/_libs/mlly.d.mts +57 -0
- package/dist/_libs/nypm+giget+tinyexec.mjs +3603 -0
- package/dist/_libs/pkg-types.d.mts +23 -0
- package/dist/_libs/plugin-alias.mjs +4 -2
- package/dist/_libs/plugin-inject.mjs +5 -5
- package/dist/_libs/plugin-json.mjs +2 -2
- package/dist/_libs/pluginutils+plugin-commonjs.d.mts +241 -0
- package/dist/_libs/{vite-plugin-fullstack.mjs → pluginutils.mjs} +244 -153
- package/dist/_libs/rc9+c12+dotenv.mjs +972 -0
- package/dist/_libs/{chokidar.mjs → readdirp+chokidar.mjs} +237 -187
- package/dist/_libs/remapping.mjs +1 -1
- package/dist/_libs/{gen-mapping.mjs → resolve-uri+gen-mapping.mjs} +2 -166
- package/dist/_libs/rou3.d.mts +43 -0
- package/dist/_libs/rou3.mjs +9 -6
- package/dist/_libs/std-env.d.mts +4 -0
- package/dist/_libs/tsconfck.mjs +3 -3
- package/dist/_libs/{unimport.mjs → unimport+unplugin.mjs} +226 -1961
- package/dist/_libs/unplugin+unimport.d.mts +426 -0
- package/dist/_libs/unwasm.d.mts +29 -0
- package/dist/_presets.mjs +130 -80
- package/dist/builder.d.mts +4 -4
- package/dist/builder.mjs +6 -30
- package/dist/cli/_chunks/build.mjs +1 -1
- package/dist/cli/_chunks/dev.mjs +5 -11
- 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/node_modules/@poppinss/colors/build/index.js +130 -160
- package/dist/node_modules/@poppinss/colors/package.json +20 -18
- package/dist/node_modules/@poppinss/exception/build/index.js +36 -55
- package/dist/node_modules/@poppinss/exception/package.json +19 -16
- package/dist/node_modules/@sindresorhus/is/distribution/index.js +46 -5
- package/dist/node_modules/@sindresorhus/is/package.json +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/index.js +1 -1
- package/dist/node_modules/@speed-highlight/core/dist/terminal.js +1 -1
- package/dist/node_modules/@speed-highlight/core/package.json +2 -2
- package/dist/node_modules/hookable/dist/index.mjs +5 -6
- package/dist/node_modules/hookable/package.json +13 -13
- package/dist/node_modules/ufo/dist/index.mjs +16 -9
- package/dist/node_modules/ufo/package.json +15 -14
- package/dist/node_modules/unctx/package.json +16 -16
- package/dist/node_modules/youch/build/{chunk-4XB2BYKC.js → chunk-7QV3D5YX.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-PUHGL6HA.js → chunk-AUGPHE32.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-F4I6KX4R.js → chunk-CM7DWJNZ.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-YYEJ3AGB.js → chunk-EJH674NB.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-EUJBVOYB.js → chunk-OIJ3WD7L.js} +2 -4
- package/dist/node_modules/youch/build/{chunk-HFSXRSKS.js → chunk-P36L72PL.js} +5 -3
- package/dist/node_modules/youch/build/{chunk-4YEN7HVQ.js → chunk-PE3GG3TN.js} +5 -1
- package/dist/node_modules/youch/build/{chunk-PINJDICN.js → chunk-X53OIOJH.js} +2 -4
- package/dist/node_modules/youch/build/index.js +8 -9
- package/dist/node_modules/youch/build/public/error_info/style.css +1 -0
- package/dist/node_modules/youch/build/public/error_metadata/style.css +3 -0
- package/dist/node_modules/youch/build/public/error_stack/style.css +2 -3
- package/dist/node_modules/youch/package.json +1 -1
- package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -1
- package/dist/presets/_nitro/runtime/nitro-dev.mjs +5 -6
- package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +1 -1
- package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +1 -1
- package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -1
- package/dist/presets/_nitro/runtime/service-worker.mjs +2 -2
- package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -1
- package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +1 -1
- package/dist/presets/aws-lambda/runtime/_utils.d.mts +0 -5
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +9 -11
- package/dist/presets/aws-lambda/runtime/aws-lambda.d.mts +1 -1
- package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +1 -1
- package/dist/presets/azure/runtime/azure-swa.d.mts +1 -1
- package/dist/presets/azure/runtime/azure-swa.mjs +1 -1
- package/dist/presets/bun/runtime/bun.d.mts +1 -1
- package/dist/presets/bun/runtime/bun.mjs +7 -8
- package/dist/presets/cloudflare/runtime/_module-handler.d.mts +3 -3
- package/dist/presets/cloudflare/runtime/_module-handler.mjs +19 -17
- package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +17 -16
- package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +8 -9
- package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +1 -1
- package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +12 -18
- package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -1
- package/dist/presets/deno/runtime/deno-deploy.mjs +4 -5
- package/dist/presets/deno/runtime/deno-server.d.mts +1 -1
- package/dist/presets/deno/runtime/deno-server.mjs +5 -6
- package/dist/presets/netlify/runtime/netlify-edge.d.mts +1 -2
- package/dist/presets/netlify/runtime/netlify-edge.mjs +3 -2
- package/dist/presets/netlify/runtime/netlify.d.mts +3 -2
- package/dist/presets/netlify/runtime/netlify.mjs +3 -1
- package/dist/presets/node/runtime/node-cluster.d.mts +1 -1
- package/dist/presets/node/runtime/node-cluster.mjs +5 -6
- package/dist/presets/node/runtime/node-middleware.d.mts +1 -1
- package/dist/presets/node/runtime/node-middleware.mjs +4 -5
- package/dist/presets/node/runtime/node-server.d.mts +1 -1
- package/dist/presets/node/runtime/node-server.mjs +5 -6
- package/dist/presets/standard/runtime/server.d.mts +1 -1
- package/dist/presets/standard/runtime/server.mjs +1 -1
- package/dist/presets/stormkit/runtime/stormkit.d.mts +1 -1
- package/dist/presets/stormkit/runtime/stormkit.mjs +1 -1
- package/dist/presets/vercel/runtime/isr.d.mts +2 -0
- package/dist/presets/vercel/runtime/isr.mjs +19 -0
- package/dist/presets/vercel/runtime/vercel.node.d.mts +1 -1
- package/dist/presets/vercel/runtime/vercel.node.mjs +16 -7
- package/dist/presets/vercel/runtime/vercel.web.d.mts +1 -1
- package/dist/presets/vercel/runtime/vercel.web.mjs +18 -13
- package/dist/presets/winterjs/runtime/winterjs.d.mts +1 -2
- package/dist/presets/winterjs/runtime/winterjs.mjs +1 -1
- package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
- package/dist/presets/zeabur/runtime/zeabur.mjs +1 -1
- package/dist/runtime/app.d.mts +1 -1
- package/dist/runtime/app.mjs +1 -1
- package/dist/runtime/internal/app.d.mts +7 -3
- package/dist/runtime/internal/app.mjs +29 -22
- package/dist/runtime/internal/database.mjs +1 -1
- package/dist/runtime/internal/error/dev.d.mts +0 -1
- package/dist/runtime/internal/error/dev.mjs +1 -1
- package/dist/runtime/internal/route-rules.d.mts +0 -4
- package/dist/runtime/internal/routes/dev-tasks.mjs +1 -1
- package/dist/runtime/internal/routes/openapi.d.mts +0 -1
- package/dist/runtime/internal/routes/openapi.mjs +3 -3
- package/dist/runtime/internal/routes/renderer-template.dev.mjs +1 -1
- package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
- package/dist/runtime/internal/routes/scalar.d.mts +0 -1
- package/dist/runtime/internal/routes/scalar.mjs +4 -4
- package/dist/runtime/internal/routes/swagger.d.mts +0 -1
- package/dist/runtime/internal/routes/swagger.mjs +3 -3
- package/dist/runtime/internal/runtime-config.mjs +8 -8
- package/dist/runtime/internal/static.mjs +1 -1
- package/dist/runtime/internal/storage.mjs +1 -1
- package/dist/runtime/internal/task.mjs +1 -1
- package/dist/runtime/internal/vite/dev-entry.mjs +3 -4
- package/dist/runtime/internal/vite/{dev-worker.mjs → node-runner.mjs} +51 -6
- package/dist/runtime/meta.d.mts +1 -1
- package/dist/runtime/meta.mjs +1 -1
- package/dist/runtime/nitro.d.mts +0 -3
- package/dist/runtime/nitro.mjs +1 -1
- package/dist/runtime/virtual/_runtime_warn.d.mts +1 -0
- package/dist/runtime/virtual/_runtime_warn.mjs +5 -0
- package/dist/runtime/virtual/database.d.mts +8 -0
- package/dist/runtime/virtual/database.mjs +2 -0
- package/dist/runtime/virtual/error-handler.d.mts +6 -0
- package/dist/runtime/virtual/error-handler.mjs +9 -0
- package/dist/runtime/virtual/feature-flags.d.mts +7 -0
- package/dist/runtime/virtual/feature-flags.mjs +7 -0
- package/dist/runtime/virtual/plugins.d.mts +3 -0
- package/dist/runtime/virtual/plugins.mjs +2 -0
- package/dist/runtime/virtual/polyfills.d.mts +3 -0
- package/dist/runtime/virtual/polyfills.mjs +2 -0
- package/dist/runtime/virtual/public-assets.d.mts +9 -0
- package/dist/runtime/virtual/public-assets.mjs +8 -0
- package/dist/runtime/virtual/renderer-template.d.mts +4 -0
- package/dist/runtime/virtual/renderer-template.mjs +7 -0
- package/dist/runtime/virtual/routing-meta.d.mts +7 -0
- package/dist/runtime/virtual/routing-meta.mjs +2 -0
- package/dist/runtime/virtual/routing.d.mts +8 -0
- package/dist/runtime/virtual/routing.mjs +11 -0
- package/dist/runtime/virtual/runtime-config.d.mts +3 -0
- package/dist/runtime/virtual/runtime-config.mjs +5 -0
- package/dist/runtime/virtual/server-assets.d.mts +6 -0
- package/dist/runtime/virtual/server-assets.mjs +12 -0
- package/dist/runtime/virtual/storage.d.mts +3 -0
- package/dist/runtime/virtual/storage.mjs +5 -0
- package/dist/runtime/virtual/tasks.d.mts +10 -0
- package/dist/runtime/virtual/tasks.mjs +3 -0
- package/dist/types/index.d.mts +292 -371
- package/dist/types/index.mjs +10 -0
- package/dist/vite.d.mts +7 -12
- package/dist/vite.mjs +734 -41
- package/lib/vite.types.d.mts +26 -0
- package/lib/vite.types.mjs +2 -0
- package/package.json +82 -53
- package/dist/_build/common2.mjs +0 -772
- package/dist/_build/vite.plugin.mjs +0 -768
- package/dist/_chunks/ANM1K1bE.mjs +0 -304
- package/dist/_chunks/BX9-zVkM.mjs +0 -59
- package/dist/_chunks/C7CbzoI1.mjs +0 -39
- package/dist/_libs/acorn.mjs +0 -5034
- package/dist/_libs/c12.mjs +0 -2858
- package/dist/_libs/commondir.mjs +0 -22
- package/dist/_libs/deepmerge.mjs +0 -86
- package/dist/_libs/dot-prop.mjs +0 -138
- package/dist/_libs/duplexer.mjs +0 -71
- package/dist/_libs/etag.mjs +0 -80
- package/dist/_libs/fdir.mjs +0 -514
- package/dist/_libs/function-bind.mjs +0 -63
- package/dist/_libs/giget.mjs +0 -19289
- package/dist/_libs/gzip-size.mjs +0 -21
- package/dist/_libs/hasown.mjs +0 -14
- package/dist/_libs/is-core-module.mjs +0 -220
- package/dist/_libs/is-module.mjs +0 -13
- package/dist/_libs/is-reference.mjs +0 -32
- package/dist/_libs/js-tokens.mjs +0 -382
- package/dist/_libs/knitwork.mjs +0 -124
- package/dist/_libs/local-pkg.mjs +0 -1686
- package/dist/_libs/magic-string.mjs +0 -939
- package/dist/_libs/mime.mjs +0 -1391
- package/dist/_libs/node-fetch-native.mjs +0 -173
- package/dist/_libs/path-parse.mjs +0 -47
- package/dist/_libs/pathe.mjs +0 -41
- package/dist/_libs/picomatch.mjs +0 -1673
- package/dist/_libs/plugin-replace.mjs +0 -104
- package/dist/_libs/pretty-bytes.mjs +0 -116
- package/dist/_libs/std-env.mjs +0 -158
- package/dist/_libs/strip-literal.mjs +0 -51
- package/dist/_libs/tinyglobby.mjs +0 -292
- package/dist/_libs/untyped.mjs +0 -271
- package/dist/_libs/unwasm.mjs +0 -5836
- package/dist/cli/_chunks/detect-acorn.mjs +0 -12
- package/dist/cli/_chunks/dist.mjs +0 -3
- package/dist/cli/_chunks/dist2.mjs +0 -3
- package/dist/cli/_chunks/dist3.mjs +0 -3
- package/dist/cli/_chunks/dist4.mjs +0 -4
- package/dist/cli/_chunks/dist5.mjs +0 -4
- package/dist/cli/_chunks/esm.mjs +0 -3
- package/dist/cli/_chunks/json5.mjs +0 -4
- package/dist/cli/_chunks/jsonc.mjs +0 -4
- package/dist/cli/_chunks/multipart-parser.mjs +0 -6
- package/dist/cli/_chunks/toml.mjs +0 -4
- package/dist/cli/_chunks/yaml.mjs +0 -4
- package/dist/node_modules/kleur/index.js +0 -110
- package/dist/node_modules/youch/build/chunk-OSUFJZHZ.js +0 -6
- package/lib/deps/ofetch.mjs +0 -1
- package/lib/deps/ofetch.mts +0 -1
- /package/dist/runtime/{vite-runtime.d.mts → vite.d.mts} +0 -0
- /package/dist/runtime/{vite-runtime.mjs → vite.mjs} +0 -0
- /package/lib/{deps/h3.d.mts → h3.d.mts} +0 -0
- /package/lib/{deps/h3.mjs → h3.mjs} +0 -0
|
@@ -0,0 +1,972 @@
|
|
|
1
|
+
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "../_common.mjs";
|
|
2
|
+
import { $ as resolveModulePath, Y as readPackageJSON, at as join$1, ct as resolve$1, nt as dirname$1, ot as normalize$1, q as findWorkspaceDir, rt as extname$1, tt as basename$1 } from "../_build/common.mjs";
|
|
3
|
+
import { existsSync, promises, readFileSync, statSync } from "node:fs";
|
|
4
|
+
import { readFile, rm } from "node:fs/promises";
|
|
5
|
+
import { pathToFileURL } from "node:url";
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { resolve } from "node:path";
|
|
8
|
+
import { createJiti } from "jiti";
|
|
9
|
+
import destr from "destr";
|
|
10
|
+
import { defu } from "defu";
|
|
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
|
|
571
|
+
//#region node_modules/.pnpm/c12@3.3.3_magicast@0.5.1/node_modules/c12/dist/index.mjs
|
|
572
|
+
var dist_exports = /* @__PURE__ */ __exportAll({
|
|
573
|
+
SUPPORTED_EXTENSIONS: () => SUPPORTED_EXTENSIONS,
|
|
574
|
+
loadConfig: () => loadConfig,
|
|
575
|
+
loadDotenv: () => loadDotenv,
|
|
576
|
+
setupDotenv: () => setupDotenv,
|
|
577
|
+
watchConfig: () => watchConfig
|
|
578
|
+
});
|
|
579
|
+
var import_main = /* @__PURE__ */ __toESM(require_main(), 1);
|
|
580
|
+
/**
|
|
581
|
+
* Load and interpolate environment variables into `process.env`.
|
|
582
|
+
* If you need more control (or access to the values), consider using `loadDotenv` instead
|
|
583
|
+
*
|
|
584
|
+
*/
|
|
585
|
+
async function setupDotenv(options) {
|
|
586
|
+
const targetEnvironment = options.env ?? process.env;
|
|
587
|
+
const environment = await loadDotenv({
|
|
588
|
+
cwd: options.cwd,
|
|
589
|
+
fileName: options.fileName ?? ".env",
|
|
590
|
+
env: targetEnvironment,
|
|
591
|
+
interpolate: options.interpolate ?? true
|
|
592
|
+
});
|
|
593
|
+
const dotenvVars = getDotEnvVars(targetEnvironment);
|
|
594
|
+
for (const key in environment) {
|
|
595
|
+
if (key.startsWith("_")) continue;
|
|
596
|
+
if (targetEnvironment[key] === void 0 || dotenvVars.has(key)) targetEnvironment[key] = environment[key];
|
|
597
|
+
}
|
|
598
|
+
return environment;
|
|
599
|
+
}
|
|
600
|
+
/** Load environment variables into an object. */
|
|
601
|
+
async function loadDotenv(options) {
|
|
602
|
+
const environment = Object.create(null);
|
|
603
|
+
const cwd = resolve$1(options.cwd || ".");
|
|
604
|
+
const _fileName = options.fileName || ".env";
|
|
605
|
+
const dotenvFiles = typeof _fileName === "string" ? [_fileName] : _fileName;
|
|
606
|
+
const dotenvVars = getDotEnvVars(options.env || {});
|
|
607
|
+
Object.assign(environment, options.env);
|
|
608
|
+
for (const file of dotenvFiles) {
|
|
609
|
+
const dotenvFile = resolve$1(cwd, file);
|
|
610
|
+
if (!statSync(dotenvFile, { throwIfNoEntry: false })?.isFile()) continue;
|
|
611
|
+
const parsed = import_main.parse(await promises.readFile(dotenvFile, "utf8"));
|
|
612
|
+
for (const key in parsed) {
|
|
613
|
+
if (key in environment && !dotenvVars.has(key)) continue;
|
|
614
|
+
environment[key] = parsed[key];
|
|
615
|
+
dotenvVars.add(key);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
if (options.interpolate) interpolate(environment);
|
|
619
|
+
return environment;
|
|
620
|
+
}
|
|
621
|
+
function interpolate(target, source = {}, parse$1 = (v) => v) {
|
|
622
|
+
function getValue(key) {
|
|
623
|
+
return source[key] === void 0 ? target[key] : source[key];
|
|
624
|
+
}
|
|
625
|
+
function interpolate$1(value, parents = []) {
|
|
626
|
+
if (typeof value !== "string") return value;
|
|
627
|
+
return parse$1((value.match(/(.?\${?(?:[\w:]+)?}?)/g) || []).reduce((newValue, match) => {
|
|
628
|
+
const parts = /(.?)\${?([\w:]+)?}?/g.exec(match) || [];
|
|
629
|
+
const prefix = parts[1];
|
|
630
|
+
let value$1, replacePart;
|
|
631
|
+
if (prefix === "\\") {
|
|
632
|
+
replacePart = parts[0] || "";
|
|
633
|
+
value$1 = replacePart.replace(String.raw`\$`, "$");
|
|
634
|
+
} else {
|
|
635
|
+
const key = parts[2];
|
|
636
|
+
replacePart = (parts[0] || "").slice(prefix.length);
|
|
637
|
+
if (parents.includes(key)) {
|
|
638
|
+
console.warn(`Please avoid recursive environment variables ( loop: ${parents.join(" > ")} > ${key} )`);
|
|
639
|
+
return "";
|
|
640
|
+
}
|
|
641
|
+
value$1 = getValue(key);
|
|
642
|
+
value$1 = interpolate$1(value$1, [...parents, key]);
|
|
643
|
+
}
|
|
644
|
+
return value$1 === void 0 ? newValue : newValue.replace(replacePart, value$1);
|
|
645
|
+
}, value));
|
|
646
|
+
}
|
|
647
|
+
for (const key in target) target[key] = interpolate$1(getValue(key));
|
|
648
|
+
}
|
|
649
|
+
function getDotEnvVars(targetEnvironment) {
|
|
650
|
+
const globalRegistry = globalThis.__c12_dotenv_vars__ ||= /* @__PURE__ */ new Map();
|
|
651
|
+
if (!globalRegistry.has(targetEnvironment)) globalRegistry.set(targetEnvironment, /* @__PURE__ */ new Set());
|
|
652
|
+
return globalRegistry.get(targetEnvironment);
|
|
653
|
+
}
|
|
654
|
+
const _normalize = (p) => p?.replace(/\\/g, "/");
|
|
655
|
+
const ASYNC_LOADERS = {
|
|
656
|
+
".yaml": () => import("./confbox.mjs").then((n) => n.a).then((r) => r.parseYAML),
|
|
657
|
+
".yml": () => import("./confbox.mjs").then((n) => n.a).then((r) => r.parseYAML),
|
|
658
|
+
".jsonc": () => import("./confbox.mjs").then((n) => n.t).then((r) => r.parseJSONC),
|
|
659
|
+
".json5": () => import("./confbox.mjs").then((n) => n.o).then((r) => r.parseJSON5),
|
|
660
|
+
".toml": () => import("./confbox.mjs").then((n) => n.r).then((r) => r.parseTOML)
|
|
661
|
+
};
|
|
662
|
+
const SUPPORTED_EXTENSIONS = Object.freeze([
|
|
663
|
+
".js",
|
|
664
|
+
".ts",
|
|
665
|
+
".mjs",
|
|
666
|
+
".cjs",
|
|
667
|
+
".mts",
|
|
668
|
+
".cts",
|
|
669
|
+
".json",
|
|
670
|
+
".jsonc",
|
|
671
|
+
".json5",
|
|
672
|
+
".yaml",
|
|
673
|
+
".yml",
|
|
674
|
+
".toml"
|
|
675
|
+
]);
|
|
676
|
+
async function loadConfig(options) {
|
|
677
|
+
options.cwd = resolve$1(process.cwd(), options.cwd || ".");
|
|
678
|
+
options.name = options.name || "config";
|
|
679
|
+
options.envName = options.envName ?? process.env.NODE_ENV;
|
|
680
|
+
options.configFile = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
|
|
681
|
+
options.rcFile = options.rcFile ?? `.${options.name}rc`;
|
|
682
|
+
if (options.extend !== false) options.extend = {
|
|
683
|
+
extendKey: "extends",
|
|
684
|
+
...options.extend
|
|
685
|
+
};
|
|
686
|
+
const _merger = options.merger || defu;
|
|
687
|
+
options.jiti = options.jiti || createJiti(join$1(options.cwd, options.configFile), {
|
|
688
|
+
interopDefault: true,
|
|
689
|
+
moduleCache: false,
|
|
690
|
+
extensions: [...SUPPORTED_EXTENSIONS],
|
|
691
|
+
...options.jitiOptions
|
|
692
|
+
});
|
|
693
|
+
const r = {
|
|
694
|
+
config: {},
|
|
695
|
+
cwd: options.cwd,
|
|
696
|
+
configFile: resolve$1(options.cwd, options.configFile),
|
|
697
|
+
layers: [],
|
|
698
|
+
_configFile: void 0
|
|
699
|
+
};
|
|
700
|
+
const rawConfigs = {
|
|
701
|
+
overrides: options.overrides,
|
|
702
|
+
main: void 0,
|
|
703
|
+
rc: void 0,
|
|
704
|
+
packageJson: void 0,
|
|
705
|
+
defaultConfig: options.defaultConfig
|
|
706
|
+
};
|
|
707
|
+
if (options.dotenv) await setupDotenv({
|
|
708
|
+
cwd: options.cwd,
|
|
709
|
+
...options.dotenv === true ? {} : options.dotenv
|
|
710
|
+
});
|
|
711
|
+
const _mainConfig = await resolveConfig(".", options);
|
|
712
|
+
if (_mainConfig.configFile) {
|
|
713
|
+
rawConfigs.main = _mainConfig.config;
|
|
714
|
+
r.configFile = _mainConfig.configFile;
|
|
715
|
+
r._configFile = _mainConfig._configFile;
|
|
716
|
+
}
|
|
717
|
+
if (_mainConfig.meta) r.meta = _mainConfig.meta;
|
|
718
|
+
if (options.rcFile) {
|
|
719
|
+
const rcSources = [];
|
|
720
|
+
rcSources.push(read({
|
|
721
|
+
name: options.rcFile,
|
|
722
|
+
dir: options.cwd
|
|
723
|
+
}));
|
|
724
|
+
if (options.globalRc) {
|
|
725
|
+
const workspaceDir = await findWorkspaceDir(options.cwd).catch(() => {});
|
|
726
|
+
if (workspaceDir) rcSources.push(read({
|
|
727
|
+
name: options.rcFile,
|
|
728
|
+
dir: workspaceDir
|
|
729
|
+
}));
|
|
730
|
+
rcSources.push(readUser({
|
|
731
|
+
name: options.rcFile,
|
|
732
|
+
dir: options.cwd
|
|
733
|
+
}));
|
|
734
|
+
}
|
|
735
|
+
rawConfigs.rc = _merger({}, ...rcSources);
|
|
736
|
+
}
|
|
737
|
+
if (options.packageJson) {
|
|
738
|
+
const keys = (Array.isArray(options.packageJson) ? options.packageJson : [typeof options.packageJson === "string" ? options.packageJson : options.name]).filter((t) => t && typeof t === "string");
|
|
739
|
+
const pkgJsonFile = await readPackageJSON(options.cwd).catch(() => {});
|
|
740
|
+
rawConfigs.packageJson = _merger({}, ...keys.map((key) => pkgJsonFile?.[key]));
|
|
741
|
+
}
|
|
742
|
+
const configs = {};
|
|
743
|
+
for (const key in rawConfigs) {
|
|
744
|
+
const value = rawConfigs[key];
|
|
745
|
+
configs[key] = await (typeof value === "function" ? value({
|
|
746
|
+
configs,
|
|
747
|
+
rawConfigs
|
|
748
|
+
}) : value);
|
|
749
|
+
}
|
|
750
|
+
if (Array.isArray(configs.main)) r.config = configs.main;
|
|
751
|
+
else {
|
|
752
|
+
r.config = _merger(configs.overrides, configs.main, configs.rc, configs.packageJson, configs.defaultConfig);
|
|
753
|
+
if (options.extend) {
|
|
754
|
+
await extendConfig(r.config, options);
|
|
755
|
+
r.layers = r.config._layers;
|
|
756
|
+
delete r.config._layers;
|
|
757
|
+
r.config = _merger(r.config, ...r.layers.map((e) => e.config));
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
r.layers = [...[
|
|
761
|
+
configs.overrides && {
|
|
762
|
+
config: configs.overrides,
|
|
763
|
+
configFile: void 0,
|
|
764
|
+
cwd: void 0
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
config: configs.main,
|
|
768
|
+
configFile: options.configFile,
|
|
769
|
+
cwd: options.cwd
|
|
770
|
+
},
|
|
771
|
+
configs.rc && {
|
|
772
|
+
config: configs.rc,
|
|
773
|
+
configFile: options.rcFile
|
|
774
|
+
},
|
|
775
|
+
configs.packageJson && {
|
|
776
|
+
config: configs.packageJson,
|
|
777
|
+
configFile: "package.json"
|
|
778
|
+
}
|
|
779
|
+
].filter((l) => l && l.config), ...r.layers];
|
|
780
|
+
if (options.defaults) r.config = _merger(r.config, options.defaults);
|
|
781
|
+
if (options.omit$Keys) {
|
|
782
|
+
for (const key in r.config) if (key.startsWith("$")) delete r.config[key];
|
|
783
|
+
}
|
|
784
|
+
if (options.configFileRequired && !r._configFile) throw new Error(`Required config (${r.configFile}) cannot be resolved.`);
|
|
785
|
+
return r;
|
|
786
|
+
}
|
|
787
|
+
async function extendConfig(config, options) {
|
|
788
|
+
config._layers = config._layers || [];
|
|
789
|
+
if (!options.extend) return;
|
|
790
|
+
let keys = options.extend.extendKey;
|
|
791
|
+
if (typeof keys === "string") keys = [keys];
|
|
792
|
+
const extendSources = [];
|
|
793
|
+
for (const key of keys) {
|
|
794
|
+
extendSources.push(...(Array.isArray(config[key]) ? config[key] : [config[key]]).filter(Boolean));
|
|
795
|
+
delete config[key];
|
|
796
|
+
}
|
|
797
|
+
for (let extendSource of extendSources) {
|
|
798
|
+
const originalExtendSource = extendSource;
|
|
799
|
+
let sourceOptions = {};
|
|
800
|
+
if (extendSource.source) {
|
|
801
|
+
sourceOptions = extendSource.options || {};
|
|
802
|
+
extendSource = extendSource.source;
|
|
803
|
+
}
|
|
804
|
+
if (Array.isArray(extendSource)) {
|
|
805
|
+
sourceOptions = extendSource[1] || {};
|
|
806
|
+
extendSource = extendSource[0];
|
|
807
|
+
}
|
|
808
|
+
if (typeof extendSource !== "string") {
|
|
809
|
+
console.warn(`Cannot extend config from \`${JSON.stringify(originalExtendSource)}\` in ${options.cwd}`);
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
const _config = await resolveConfig(extendSource, options, sourceOptions);
|
|
813
|
+
if (!_config.config) {
|
|
814
|
+
console.warn(`Cannot extend config from \`${extendSource}\` in ${options.cwd}`);
|
|
815
|
+
continue;
|
|
816
|
+
}
|
|
817
|
+
await extendConfig(_config.config, {
|
|
818
|
+
...options,
|
|
819
|
+
cwd: _config.cwd
|
|
820
|
+
});
|
|
821
|
+
config._layers.push(_config);
|
|
822
|
+
if (_config.config._layers) {
|
|
823
|
+
config._layers.push(..._config.config._layers);
|
|
824
|
+
delete _config.config._layers;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
const GIGET_PREFIXES = [
|
|
829
|
+
"gh:",
|
|
830
|
+
"github:",
|
|
831
|
+
"gitlab:",
|
|
832
|
+
"bitbucket:",
|
|
833
|
+
"https://",
|
|
834
|
+
"http://"
|
|
835
|
+
];
|
|
836
|
+
const NPM_PACKAGE_RE = /^(@[\da-z~-][\d._a-z~-]*\/)?[\da-z~-][\d._a-z~-]*($|\/.*)/;
|
|
837
|
+
async function resolveConfig(source, options, sourceOptions = {}) {
|
|
838
|
+
if (options.resolve) {
|
|
839
|
+
const res$1 = await options.resolve(source, options);
|
|
840
|
+
if (res$1) return res$1;
|
|
841
|
+
}
|
|
842
|
+
const _merger = options.merger || defu;
|
|
843
|
+
const customProviderKeys = Object.keys(sourceOptions.giget?.providers || {}).map((key) => `${key}:`);
|
|
844
|
+
const gigetPrefixes = customProviderKeys.length > 0 ? [...new Set([...customProviderKeys, ...GIGET_PREFIXES])] : GIGET_PREFIXES;
|
|
845
|
+
if (options.giget !== false && gigetPrefixes.some((prefix) => source.startsWith(prefix))) {
|
|
846
|
+
const { downloadTemplate } = await import("./nypm+giget+tinyexec.mjs").then((n) => n.t);
|
|
847
|
+
const { digest } = await import("ohash");
|
|
848
|
+
const cloneName = source.replace(/\W+/g, "_").split("_").splice(0, 3).join("_") + "_" + digest(source).slice(0, 10).replace(/[-_]/g, "");
|
|
849
|
+
let cloneDir;
|
|
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);
|
|
855
|
+
if (existsSync(cloneDir) && !sourceOptions.install) await rm(cloneDir, { recursive: true });
|
|
856
|
+
source = (await downloadTemplate(source, {
|
|
857
|
+
dir: cloneDir,
|
|
858
|
+
install: sourceOptions.install,
|
|
859
|
+
force: sourceOptions.install,
|
|
860
|
+
auth: sourceOptions.auth,
|
|
861
|
+
...options.giget,
|
|
862
|
+
...sourceOptions.giget
|
|
863
|
+
})).dir;
|
|
864
|
+
}
|
|
865
|
+
if (NPM_PACKAGE_RE.test(source)) source = tryResolve(source, options) || 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));
|
|
869
|
+
if (isDir) source = options.configFile;
|
|
870
|
+
const res = {
|
|
871
|
+
config: void 0,
|
|
872
|
+
configFile: void 0,
|
|
873
|
+
cwd,
|
|
874
|
+
source,
|
|
875
|
+
sourceOptions
|
|
876
|
+
};
|
|
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;
|
|
878
|
+
if (!existsSync(res.configFile)) return res;
|
|
879
|
+
res._configFile = res.configFile;
|
|
880
|
+
const configFileExt = extname$1(res.configFile) || "";
|
|
881
|
+
if (configFileExt in ASYNC_LOADERS) res.config = (await ASYNC_LOADERS[configFileExt]())(await readFile(res.configFile, "utf8"));
|
|
882
|
+
else res.config = await options.jiti.import(res.configFile, { default: true });
|
|
883
|
+
if (typeof res.config === "function") res.config = await res.config(options.context);
|
|
884
|
+
if (options.envName) {
|
|
885
|
+
const envConfig = {
|
|
886
|
+
...res.config["$" + options.envName],
|
|
887
|
+
...res.config.$env?.[options.envName]
|
|
888
|
+
};
|
|
889
|
+
if (Object.keys(envConfig).length > 0) res.config = _merger(envConfig, res.config);
|
|
890
|
+
}
|
|
891
|
+
res.meta = defu(res.sourceOptions.meta, res.config.$meta);
|
|
892
|
+
delete res.config.$meta;
|
|
893
|
+
if (res.sourceOptions.overrides) res.config = _merger(res.sourceOptions.overrides, res.config);
|
|
894
|
+
res.configFile = _normalize(res.configFile);
|
|
895
|
+
res.source = _normalize(res.source);
|
|
896
|
+
return res;
|
|
897
|
+
}
|
|
898
|
+
function tryResolve(id, options) {
|
|
899
|
+
const res = resolveModulePath(id, {
|
|
900
|
+
try: true,
|
|
901
|
+
from: pathToFileURL(join$1(options.cwd || ".", options.configFile || "/")),
|
|
902
|
+
suffixes: ["", "/index"],
|
|
903
|
+
extensions: SUPPORTED_EXTENSIONS,
|
|
904
|
+
cache: false
|
|
905
|
+
});
|
|
906
|
+
return res ? normalize$1(res) : void 0;
|
|
907
|
+
}
|
|
908
|
+
const eventMap = {
|
|
909
|
+
add: "created",
|
|
910
|
+
change: "updated",
|
|
911
|
+
unlink: "removed"
|
|
912
|
+
};
|
|
913
|
+
async function watchConfig(options) {
|
|
914
|
+
let config = await loadConfig(options);
|
|
915
|
+
const configName = options.name || "config";
|
|
916
|
+
const configFileName = options.configFile ?? (options.name === "config" ? "config" : `${options.name}.config`);
|
|
917
|
+
const watchingFiles = [...new Set((config.layers || []).filter((l) => l.cwd).flatMap((l) => [
|
|
918
|
+
...SUPPORTED_EXTENSIONS.flatMap((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)
|
|
922
|
+
]),
|
|
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")
|
|
926
|
+
]).filter(Boolean))];
|
|
927
|
+
const watch$1 = await import("./readdirp+chokidar.mjs").then((n) => n.t).then((r) => r.watch || r.default || r);
|
|
928
|
+
const { diff } = await import("ohash/utils");
|
|
929
|
+
const _fswatcher = watch$1(watchingFiles, {
|
|
930
|
+
ignoreInitial: true,
|
|
931
|
+
...options.chokidarOptions
|
|
932
|
+
});
|
|
933
|
+
const onChange = async (event, path$2) => {
|
|
934
|
+
const type$1 = eventMap[event];
|
|
935
|
+
if (!type$1) return;
|
|
936
|
+
if (options.onWatch) await options.onWatch({
|
|
937
|
+
type: type$1,
|
|
938
|
+
path: path$2
|
|
939
|
+
});
|
|
940
|
+
const oldConfig = config;
|
|
941
|
+
try {
|
|
942
|
+
config = await loadConfig(options);
|
|
943
|
+
} catch (error) {
|
|
944
|
+
console.warn(`Failed to load config ${path$2}\n${error}`);
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
const changeCtx = {
|
|
948
|
+
newConfig: config,
|
|
949
|
+
oldConfig,
|
|
950
|
+
getDiff: () => diff(oldConfig.config, config.config)
|
|
951
|
+
};
|
|
952
|
+
if (options.acceptHMR) {
|
|
953
|
+
if (await options.acceptHMR(changeCtx)) return;
|
|
954
|
+
}
|
|
955
|
+
if (options.onUpdate) await options.onUpdate(changeCtx);
|
|
956
|
+
};
|
|
957
|
+
if (options.debounce === false) _fswatcher.on("all", onChange);
|
|
958
|
+
else _fswatcher.on("all", debounce(onChange, options.debounce ?? 100));
|
|
959
|
+
const utils = {
|
|
960
|
+
watchingFiles,
|
|
961
|
+
unwatch: async () => {
|
|
962
|
+
await _fswatcher.close();
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
return new Proxy(utils, { get(_, prop) {
|
|
966
|
+
if (prop in utils) return utils[prop];
|
|
967
|
+
return config[prop];
|
|
968
|
+
} });
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
//#endregion
|
|
972
|
+
export { debounce as i, loadConfig as n, watchConfig as r, dist_exports as t };
|