nitro-nightly 3.0.1-20260106-202835-5325b208 → 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 (86) hide show
  1. package/dist/_build/common.mjs +24899 -0
  2. package/dist/_build/rolldown.mjs +6 -9
  3. package/dist/_build/rollup.mjs +6 -8
  4. package/dist/_build/vite.build.mjs +1 -1
  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/{build2.mjs → 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/cli/index.mjs +1 -1
  31. package/dist/vite.mjs +14 -1128
  32. package/package.json +1 -1
  33. package/dist/_build/rollup2.mjs +0 -56
  34. package/dist/_build/shared.mjs +0 -60
  35. package/dist/_build/shared2.mjs +0 -40
  36. package/dist/_build/shared3.mjs +0 -68
  37. package/dist/_libs/@jridgewell/resolve-uri.mjs +0 -166
  38. package/dist/_libs/@jridgewell/sourcemap-codec.mjs +0 -167
  39. package/dist/_libs/@jridgewell/trace-mapping.mjs +0 -141
  40. package/dist/_libs/@rolldown/pluginutils.mjs +0 -31
  41. package/dist/_libs/@rollup/plugin-replace.mjs +0 -104
  42. package/dist/_libs/@rollup/pluginutils.mjs +0 -241
  43. package/dist/_libs/acorn.mjs +0 -5034
  44. package/dist/_libs/commondir.mjs +0 -22
  45. package/dist/_libs/deepmerge.mjs +0 -86
  46. package/dist/_libs/dot-prop.mjs +0 -138
  47. package/dist/_libs/dotenv.mjs +0 -345
  48. package/dist/_libs/duplexer.mjs +0 -71
  49. package/dist/_libs/etag.mjs +0 -80
  50. package/dist/_libs/exsolve.mjs +0 -1007
  51. package/dist/_libs/fdir.mjs +0 -514
  52. package/dist/_libs/function-bind.mjs +0 -63
  53. package/dist/_libs/gzip-size.mjs +0 -21
  54. package/dist/_libs/hasown.mjs +0 -14
  55. package/dist/_libs/is-core-module.mjs +0 -220
  56. package/dist/_libs/is-module.mjs +0 -13
  57. package/dist/_libs/is-reference.mjs +0 -33
  58. package/dist/_libs/js-tokens.mjs +0 -382
  59. package/dist/_libs/knitwork.mjs +0 -124
  60. package/dist/_libs/local-pkg.mjs +0 -125
  61. package/dist/_libs/magic-string.mjs +0 -939
  62. package/dist/_libs/mime.mjs +0 -1391
  63. package/dist/_libs/mlly.mjs +0 -1415
  64. package/dist/_libs/node-fetch-native.mjs +0 -7
  65. package/dist/_libs/nypm.mjs +0 -239
  66. package/dist/_libs/path-parse.mjs +0 -47
  67. package/dist/_libs/pathe.mjs +0 -202
  68. package/dist/_libs/perfect-debounce.mjs +0 -89
  69. package/dist/_libs/picomatch.mjs +0 -1673
  70. package/dist/_libs/pkg-types.mjs +0 -197
  71. package/dist/_libs/pretty-bytes.mjs +0 -116
  72. package/dist/_libs/quansync.mjs +0 -90
  73. package/dist/_libs/rc9.mjs +0 -136
  74. package/dist/_libs/readdirp.mjs +0 -237
  75. package/dist/_libs/resolve.mjs +0 -689
  76. package/dist/_libs/std-env.mjs +0 -158
  77. package/dist/_libs/strip-literal.mjs +0 -51
  78. package/dist/_libs/tinyexec.mjs +0 -627
  79. package/dist/_libs/tinyglobby.mjs +0 -292
  80. package/dist/_libs/unplugin-utils.mjs +0 -61
  81. package/dist/_libs/unplugin.mjs +0 -1225
  82. package/dist/_libs/untyped.mjs +0 -271
  83. package/dist/_libs/unwasm.mjs +0 -5895
  84. package/dist/_libs/webpack-virtual-modules.mjs +0 -272
  85. package/dist/_nitro2.mjs +0 -303
  86. /package/dist/{_rolldown.mjs → _common.mjs} +0 -0
@@ -1,197 +0,0 @@
1
- import { a as isAbsolute, o as join, r as dirname, s as normalize, u as resolve } from "./pathe.mjs";
2
- import { t as resolveModulePath } from "./exsolve.mjs";
3
- import { d as x, i as S, n as h$1, r as x$1, u as h } from "./confbox.mjs";
4
- import { u as resolvePath } from "./mlly.mjs";
5
- import { promises, statSync } from "node:fs";
6
- import { readFile, writeFile } from "node:fs/promises";
7
- import { fileURLToPath } from "node:url";
8
-
9
- //#region node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs
10
- const defaultFindOptions$1 = {
11
- startingFrom: ".",
12
- rootPattern: /^node_modules$/,
13
- reverse: false,
14
- test: (filePath) => {
15
- try {
16
- if (statSync(filePath).isFile()) return true;
17
- } catch {}
18
- }
19
- };
20
- async function findFile$1(filename, _options = {}) {
21
- const filenames = Array.isArray(filename) ? filename : [filename];
22
- const options = {
23
- ...defaultFindOptions$1,
24
- ..._options
25
- };
26
- const basePath = resolve(options.startingFrom);
27
- const leadingSlash = basePath[0] === "/";
28
- const segments = basePath.split("/").filter(Boolean);
29
- if (filenames.includes(segments.at(-1)) && await options.test(basePath)) return basePath;
30
- if (leadingSlash) segments[0] = "/" + segments[0];
31
- let root = segments.findIndex((r) => r.match(options.rootPattern));
32
- if (root === -1) root = 0;
33
- if (options.reverse) for (let index = root + 1; index <= segments.length; index++) for (const filename2 of filenames) {
34
- const filePath = join(...segments.slice(0, index), filename2);
35
- if (await options.test(filePath)) return filePath;
36
- }
37
- else for (let index = segments.length; index > root; index--) for (const filename2 of filenames) {
38
- const filePath = join(...segments.slice(0, index), filename2);
39
- if (await options.test(filePath)) return filePath;
40
- }
41
- throw new Error(`Cannot find matching ${filename} in ${options.startingFrom} or parent directories`);
42
- }
43
- function findNearestFile$1(filename, options = {}) {
44
- return findFile$1(filename, options);
45
- }
46
- function _resolvePath(id, opts = {}) {
47
- if (id instanceof URL || id.startsWith("file://")) return normalize(fileURLToPath(id));
48
- if (isAbsolute(id)) return normalize(id);
49
- return resolveModulePath(id, {
50
- ...opts,
51
- from: opts.from || opts.parent || opts.url
52
- });
53
- }
54
- const lockFiles = [
55
- "yarn.lock",
56
- "package-lock.json",
57
- "pnpm-lock.yaml",
58
- "npm-shrinkwrap.json",
59
- "bun.lockb",
60
- "bun.lock",
61
- "deno.lock"
62
- ];
63
- const packageFiles = [
64
- "package.json",
65
- "package.json5",
66
- "package.yaml"
67
- ];
68
- const workspaceFiles = [
69
- "pnpm-workspace.yaml",
70
- "lerna.json",
71
- "turbo.json",
72
- "rush.json",
73
- "deno.json",
74
- "deno.jsonc"
75
- ];
76
- const FileCache$1 = /* @__PURE__ */ new Map();
77
- async function readPackageJSON$1(id, options = {}) {
78
- const resolvedPath = await resolvePackageJSON$1(id, options);
79
- const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache$1;
80
- if (options.cache && cache.has(resolvedPath)) return cache.get(resolvedPath);
81
- const blob = await promises.readFile(resolvedPath, "utf8");
82
- let parsed;
83
- try {
84
- parsed = x(blob);
85
- } catch {
86
- parsed = h(blob);
87
- }
88
- cache.set(resolvedPath, parsed);
89
- return parsed;
90
- }
91
- async function resolvePackageJSON$1(id = process.cwd(), options = {}) {
92
- return findNearestFile$1("package.json", {
93
- ...options,
94
- startingFrom: _resolvePath(id, options)
95
- });
96
- }
97
- const workspaceTests = {
98
- workspaceFile: (opts) => findFile$1(workspaceFiles, opts).then((r) => dirname(r)),
99
- gitConfig: (opts) => findFile$1(".git/config", opts).then((r) => resolve(r, "../..")),
100
- lockFile: (opts) => findFile$1(lockFiles, opts).then((r) => dirname(r)),
101
- packageJson: (opts) => findFile$1(packageFiles, opts).then((r) => dirname(r))
102
- };
103
- async function findWorkspaceDir(id = process.cwd(), options = {}) {
104
- const startingFrom = _resolvePath(id, options);
105
- const tests = options.tests || [
106
- "workspaceFile",
107
- "gitConfig",
108
- "lockFile",
109
- "packageJson"
110
- ];
111
- for (const testName of tests) {
112
- const test = workspaceTests[testName];
113
- if (options[testName] === false || !test) continue;
114
- const direction = options[testName] || (testName === "gitConfig" ? "closest" : "furthest");
115
- const detected = await test({
116
- ...options,
117
- startingFrom,
118
- reverse: direction === "furthest"
119
- }).catch(() => {});
120
- if (detected) return detected;
121
- }
122
- throw new Error(`Cannot detect workspace root from ${id}`);
123
- }
124
- async function resolveGitConfig(dir, opts) {
125
- return findNearestFile$1(".git/config", {
126
- ...opts,
127
- startingFrom: dir
128
- });
129
- }
130
- async function readGitConfig(dir, opts) {
131
- return parseGitConfig(await readFile(await resolveGitConfig(dir, opts), "utf8"));
132
- }
133
- function parseGitConfig(ini) {
134
- return S(ini.replaceAll(/^\[(\w+) "(.+)"\]$/gm, "[$1.$2]"));
135
- }
136
-
137
- //#endregion
138
- //#region node_modules/.pnpm/pkg-types@1.3.1/node_modules/pkg-types/dist/index.mjs
139
- const defaultFindOptions = {
140
- startingFrom: ".",
141
- rootPattern: /^node_modules$/,
142
- reverse: false,
143
- test: (filePath) => {
144
- try {
145
- if (statSync(filePath).isFile()) return true;
146
- } catch {}
147
- }
148
- };
149
- async function findFile(filename, _options = {}) {
150
- const filenames = Array.isArray(filename) ? filename : [filename];
151
- const options = {
152
- ...defaultFindOptions,
153
- ..._options
154
- };
155
- const basePath = resolve(options.startingFrom);
156
- const leadingSlash = basePath[0] === "/";
157
- const segments = basePath.split("/").filter(Boolean);
158
- if (leadingSlash) segments[0] = "/" + segments[0];
159
- let root = segments.findIndex((r) => r.match(options.rootPattern));
160
- if (root === -1) root = 0;
161
- if (options.reverse) for (let index = root + 1; index <= segments.length; index++) for (const filename2 of filenames) {
162
- const filePath = join(...segments.slice(0, index), filename2);
163
- if (await options.test(filePath)) return filePath;
164
- }
165
- else for (let index = segments.length; index > root; index--) for (const filename2 of filenames) {
166
- const filePath = join(...segments.slice(0, index), filename2);
167
- if (await options.test(filePath)) return filePath;
168
- }
169
- throw new Error(`Cannot find matching ${filename} in ${options.startingFrom} or parent directories`);
170
- }
171
- function findNearestFile(filename, _options = {}) {
172
- return findFile(filename, _options);
173
- }
174
- const FileCache = /* @__PURE__ */ new Map();
175
- async function readPackageJSON(id, options = {}) {
176
- const resolvedPath = await resolvePackageJSON(id, options);
177
- const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache;
178
- if (options.cache && cache.has(resolvedPath)) return cache.get(resolvedPath);
179
- const blob = await promises.readFile(resolvedPath, "utf8");
180
- let parsed;
181
- try {
182
- parsed = x$1(blob);
183
- } catch {
184
- parsed = h$1(blob);
185
- }
186
- cache.set(resolvedPath, parsed);
187
- return parsed;
188
- }
189
- async function resolvePackageJSON(id = process.cwd(), options = {}) {
190
- return findNearestFile("package.json", {
191
- startingFrom: isAbsolute(id) ? id : await resolvePath(id, options),
192
- ...options
193
- });
194
- }
195
-
196
- //#endregion
197
- export { parseGitConfig as a, resolveGitConfig as c, findWorkspaceDir as i, resolvePackageJSON$1 as l, findFile$1 as n, readGitConfig as o, findNearestFile$1 as r, readPackageJSON$1 as s, readPackageJSON as t };
@@ -1,116 +0,0 @@
1
- //#region node_modules/.pnpm/pretty-bytes@7.1.0/node_modules/pretty-bytes/index.js
2
- const BYTE_UNITS = [
3
- "B",
4
- "kB",
5
- "MB",
6
- "GB",
7
- "TB",
8
- "PB",
9
- "EB",
10
- "ZB",
11
- "YB"
12
- ];
13
- const BIBYTE_UNITS = [
14
- "B",
15
- "KiB",
16
- "MiB",
17
- "GiB",
18
- "TiB",
19
- "PiB",
20
- "EiB",
21
- "ZiB",
22
- "YiB"
23
- ];
24
- const BIT_UNITS = [
25
- "b",
26
- "kbit",
27
- "Mbit",
28
- "Gbit",
29
- "Tbit",
30
- "Pbit",
31
- "Ebit",
32
- "Zbit",
33
- "Ybit"
34
- ];
35
- const BIBIT_UNITS = [
36
- "b",
37
- "kibit",
38
- "Mibit",
39
- "Gibit",
40
- "Tibit",
41
- "Pibit",
42
- "Eibit",
43
- "Zibit",
44
- "Yibit"
45
- ];
46
- const toLocaleString = (number, locale, options) => {
47
- let result = number;
48
- if (typeof locale === "string" || Array.isArray(locale)) result = number.toLocaleString(locale, options);
49
- else if (locale === true || options !== void 0) result = number.toLocaleString(void 0, options);
50
- return result;
51
- };
52
- const log10 = (numberOrBigInt) => {
53
- if (typeof numberOrBigInt === "number") return Math.log10(numberOrBigInt);
54
- const string = numberOrBigInt.toString(10);
55
- return string.length + Math.log10(`0.${string.slice(0, 15)}`);
56
- };
57
- const log = (numberOrBigInt) => {
58
- if (typeof numberOrBigInt === "number") return Math.log(numberOrBigInt);
59
- return log10(numberOrBigInt) * Math.log(10);
60
- };
61
- const divide = (numberOrBigInt, divisor) => {
62
- if (typeof numberOrBigInt === "number") return numberOrBigInt / divisor;
63
- const integerPart = numberOrBigInt / BigInt(divisor);
64
- const remainder = numberOrBigInt % BigInt(divisor);
65
- return Number(integerPart) + Number(remainder) / divisor;
66
- };
67
- const applyFixedWidth = (result, fixedWidth) => {
68
- if (fixedWidth === void 0) return result;
69
- if (typeof fixedWidth !== "number" || !Number.isSafeInteger(fixedWidth) || fixedWidth < 0) throw new TypeError(`Expected fixedWidth to be a non-negative integer, got ${typeof fixedWidth}: ${fixedWidth}`);
70
- if (fixedWidth === 0) return result;
71
- return result.length < fixedWidth ? result.padStart(fixedWidth, " ") : result;
72
- };
73
- const buildLocaleOptions = (options) => {
74
- const { minimumFractionDigits, maximumFractionDigits } = options;
75
- if (minimumFractionDigits === void 0 && maximumFractionDigits === void 0) return;
76
- return {
77
- ...minimumFractionDigits !== void 0 && { minimumFractionDigits },
78
- ...maximumFractionDigits !== void 0 && { maximumFractionDigits },
79
- roundingMode: "trunc"
80
- };
81
- };
82
- function prettyBytes(number, options) {
83
- if (typeof number !== "bigint" && !Number.isFinite(number)) throw new TypeError(`Expected a finite number, got ${typeof number}: ${number}`);
84
- options = {
85
- bits: false,
86
- binary: false,
87
- space: true,
88
- nonBreakingSpace: false,
89
- ...options
90
- };
91
- const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
92
- const separator = options.space ? options.nonBreakingSpace ? "\xA0" : " " : "";
93
- const isZero = typeof number === "number" ? number === 0 : number === 0n;
94
- if (options.signed && isZero) return applyFixedWidth(` 0${separator}${UNITS[0]}`, options.fixedWidth);
95
- const isNegative = number < 0;
96
- const prefix = isNegative ? "-" : options.signed ? "+" : "";
97
- if (isNegative) number = -number;
98
- const localeOptions = buildLocaleOptions(options);
99
- let result;
100
- if (number < 1) result = prefix + toLocaleString(number, options.locale, localeOptions) + separator + UNITS[0];
101
- else {
102
- const exponent = Math.min(Math.floor(options.binary ? log(number) / Math.log(1024) : log10(number) / 3), UNITS.length - 1);
103
- number = divide(number, (options.binary ? 1024 : 1e3) ** exponent);
104
- if (!localeOptions) {
105
- const minPrecision = Math.max(3, Math.floor(number).toString().length);
106
- number = number.toPrecision(minPrecision);
107
- }
108
- const numberString = toLocaleString(Number(number), options.locale, localeOptions);
109
- const unit = UNITS[exponent];
110
- result = prefix + numberString + separator + unit;
111
- }
112
- return applyFixedWidth(result, options.fixedWidth);
113
- }
114
-
115
- //#endregion
116
- export { prettyBytes as t };
@@ -1,90 +0,0 @@
1
- //#region node_modules/.pnpm/quansync@0.2.11/node_modules/quansync/dist/index.mjs
2
- const GET_IS_ASYNC = Symbol.for("quansync.getIsAsync");
3
- var QuansyncError = class extends Error {
4
- constructor(message = "Unexpected promise in sync context") {
5
- super(message);
6
- this.name = "QuansyncError";
7
- }
8
- };
9
- function isThenable(value) {
10
- return value && typeof value === "object" && typeof value.then === "function";
11
- }
12
- function isQuansyncGenerator(value) {
13
- return value && typeof value === "object" && typeof value[Symbol.iterator] === "function" && "__quansync" in value;
14
- }
15
- function fromObject(options) {
16
- const generator = function* (...args) {
17
- if (yield GET_IS_ASYNC) return yield options.async.apply(this, args);
18
- return options.sync.apply(this, args);
19
- };
20
- function fn(...args) {
21
- const iter = generator.apply(this, args);
22
- iter.then = (...thenArgs) => options.async.apply(this, args).then(...thenArgs);
23
- iter.__quansync = true;
24
- return iter;
25
- }
26
- fn.sync = options.sync;
27
- fn.async = options.async;
28
- return fn;
29
- }
30
- function fromPromise(promise) {
31
- return fromObject({
32
- async: () => Promise.resolve(promise),
33
- sync: () => {
34
- if (isThenable(promise)) throw new QuansyncError();
35
- return promise;
36
- }
37
- });
38
- }
39
- function unwrapYield(value, isAsync) {
40
- if (value === GET_IS_ASYNC) return isAsync;
41
- if (isQuansyncGenerator(value)) return isAsync ? iterateAsync(value) : iterateSync(value);
42
- if (!isAsync && isThenable(value)) throw new QuansyncError();
43
- return value;
44
- }
45
- const DEFAULT_ON_YIELD = (value) => value;
46
- function iterateSync(generator, onYield = DEFAULT_ON_YIELD) {
47
- let current = generator.next();
48
- while (!current.done) try {
49
- current = generator.next(unwrapYield(onYield(current.value, false)));
50
- } catch (err) {
51
- current = generator.throw(err);
52
- }
53
- return unwrapYield(current.value);
54
- }
55
- async function iterateAsync(generator, onYield = DEFAULT_ON_YIELD) {
56
- let current = generator.next();
57
- while (!current.done) try {
58
- current = generator.next(await unwrapYield(onYield(current.value, true), true));
59
- } catch (err) {
60
- current = generator.throw(err);
61
- }
62
- return current.value;
63
- }
64
- function fromGeneratorFn(generatorFn, options) {
65
- return fromObject({
66
- name: generatorFn.name,
67
- async(...args) {
68
- return iterateAsync(generatorFn.apply(this, args), options?.onYield);
69
- },
70
- sync(...args) {
71
- return iterateSync(generatorFn.apply(this, args), options?.onYield);
72
- }
73
- });
74
- }
75
- function quansync$1(input, options) {
76
- if (isThenable(input)) return fromPromise(input);
77
- if (typeof input === "function") return fromGeneratorFn(input, options);
78
- else return fromObject(input);
79
- }
80
- const getIsAsync = quansync$1({
81
- async: () => Promise.resolve(true),
82
- sync: () => false
83
- });
84
-
85
- //#endregion
86
- //#region node_modules/.pnpm/quansync@0.2.11/node_modules/quansync/dist/macro.mjs
87
- const quansync = quansync$1;
88
-
89
- //#endregion
90
- export { quansync as t };
@@ -1,136 +0,0 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { homedir } from "node:os";
3
- import { resolve } from "node:path";
4
- import destr from "destr";
5
- import { defu } from "defu";
6
-
7
- //#region node_modules/.pnpm/rc9@2.1.2/node_modules/rc9/dist/index.mjs
8
- function isBuffer(obj) {
9
- return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
10
- }
11
- function keyIdentity(key) {
12
- return key;
13
- }
14
- function flatten(target, opts) {
15
- opts = opts || {};
16
- const delimiter$1 = opts.delimiter || ".";
17
- const maxDepth = opts.maxDepth;
18
- const transformKey = opts.transformKey || keyIdentity;
19
- const output = {};
20
- function step(object, prev, currentDepth) {
21
- currentDepth = currentDepth || 1;
22
- Object.keys(object).forEach(function(key) {
23
- const value = object[key];
24
- const isarray = opts.safe && Array.isArray(value);
25
- const type$1 = Object.prototype.toString.call(value);
26
- const isbuffer = isBuffer(value);
27
- const isobject = type$1 === "[object Object]" || type$1 === "[object Array]";
28
- const newKey = prev ? prev + delimiter$1 + transformKey(key) : transformKey(key);
29
- if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) return step(value, newKey, currentDepth + 1);
30
- output[newKey] = value;
31
- });
32
- }
33
- step(target);
34
- return output;
35
- }
36
- function unflatten(target, opts) {
37
- opts = opts || {};
38
- const delimiter$1 = opts.delimiter || ".";
39
- const overwrite = opts.overwrite || false;
40
- const transformKey = opts.transformKey || keyIdentity;
41
- const result = {};
42
- if (isBuffer(target) || Object.prototype.toString.call(target) !== "[object Object]") return target;
43
- function getkey(key) {
44
- const parsedKey = Number(key);
45
- return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
46
- }
47
- function addKeys(keyPrefix, recipient, target$1) {
48
- return Object.keys(target$1).reduce(function(result$1, key) {
49
- result$1[keyPrefix + delimiter$1 + key] = target$1[key];
50
- return result$1;
51
- }, recipient);
52
- }
53
- function isEmpty(val) {
54
- const type$1 = Object.prototype.toString.call(val);
55
- const isArray = type$1 === "[object Array]";
56
- const isObject = type$1 === "[object Object]";
57
- if (!val) return true;
58
- else if (isArray) return !val.length;
59
- else if (isObject) return !Object.keys(val).length;
60
- }
61
- target = Object.keys(target).reduce(function(result$1, key) {
62
- const type$1 = Object.prototype.toString.call(target[key]);
63
- if (!(type$1 === "[object Object]" || type$1 === "[object Array]") || isEmpty(target[key])) {
64
- result$1[key] = target[key];
65
- return result$1;
66
- } else return addKeys(key, result$1, flatten(target[key], opts));
67
- }, {});
68
- Object.keys(target).forEach(function(key) {
69
- const split = key.split(delimiter$1).map(transformKey);
70
- let key1 = getkey(split.shift());
71
- let key2 = getkey(split[0]);
72
- let recipient = result;
73
- while (key2 !== void 0) {
74
- if (key1 === "__proto__") return;
75
- const type$1 = Object.prototype.toString.call(recipient[key1]);
76
- const isobject = type$1 === "[object Object]" || type$1 === "[object Array]";
77
- if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") return;
78
- if (overwrite && !isobject || !overwrite && recipient[key1] == null) recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
79
- recipient = recipient[key1];
80
- if (split.length > 0) {
81
- key1 = getkey(split.shift());
82
- key2 = getkey(split[0]);
83
- }
84
- }
85
- recipient[key1] = unflatten(target[key], opts);
86
- });
87
- return result;
88
- }
89
- const RE_KEY_VAL = /^\s*([^\s=]+)\s*=\s*(.*)?\s*$/;
90
- const RE_LINES = /\n|\r|\r\n/;
91
- const defaults = {
92
- name: ".conf",
93
- dir: process.cwd(),
94
- flat: false
95
- };
96
- function withDefaults(options) {
97
- if (typeof options === "string") options = { name: options };
98
- return {
99
- ...defaults,
100
- ...options
101
- };
102
- }
103
- function parse(contents, options = {}) {
104
- const config = {};
105
- const lines = contents.split(RE_LINES);
106
- for (const line of lines) {
107
- const match = line.match(RE_KEY_VAL);
108
- if (!match) continue;
109
- const key = match[1];
110
- if (!key || key === "__proto__" || key === "constructor") continue;
111
- const value = destr((match[2] || "").trim());
112
- if (key.endsWith("[]")) {
113
- const nkey = key.slice(0, Math.max(0, key.length - 2));
114
- config[nkey] = (config[nkey] || []).concat(value);
115
- continue;
116
- }
117
- config[key] = value;
118
- }
119
- return options.flat ? config : unflatten(config, { overwrite: true });
120
- }
121
- function parseFile(path$1, options) {
122
- if (!existsSync(path$1)) return {};
123
- return parse(readFileSync(path$1, "utf8"), options);
124
- }
125
- function read(options) {
126
- options = withDefaults(options);
127
- return parseFile(resolve(options.dir, options.name), options);
128
- }
129
- function readUser(options) {
130
- options = withDefaults(options);
131
- options.dir = process.env.XDG_CONFIG_HOME || homedir();
132
- return read(options);
133
- }
134
-
135
- //#endregion
136
- export { readUser as n, read as t };