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,141 +0,0 @@
1
- import { t as decode } from "./sourcemap-codec.mjs";
2
- import { t as resolve } from "./resolve-uri.mjs";
3
-
4
- //#region node_modules/.pnpm/@jridgewell+trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
5
- function stripFilename(path) {
6
- if (!path) return "";
7
- const index = path.lastIndexOf("/");
8
- return path.slice(0, index + 1);
9
- }
10
- function resolver(mapUrl, sourceRoot) {
11
- const from = stripFilename(mapUrl);
12
- const prefix = sourceRoot ? sourceRoot + "/" : "";
13
- return (source) => resolve(prefix + (source || ""), from);
14
- }
15
- var COLUMN = 0;
16
- function maybeSort(mappings, owned) {
17
- const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
18
- if (unsortedIndex === mappings.length) return mappings;
19
- if (!owned) mappings = mappings.slice();
20
- for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) mappings[i] = sortSegments(mappings[i], owned);
21
- return mappings;
22
- }
23
- function nextUnsortedSegmentLine(mappings, start) {
24
- for (let i = start; i < mappings.length; i++) if (!isSorted(mappings[i])) return i;
25
- return mappings.length;
26
- }
27
- function isSorted(line) {
28
- for (let j = 1; j < line.length; j++) if (line[j][COLUMN] < line[j - 1][COLUMN]) return false;
29
- return true;
30
- }
31
- function sortSegments(line, owned) {
32
- if (!owned) line = line.slice();
33
- return line.sort(sortComparator);
34
- }
35
- function sortComparator(a, b) {
36
- return a[COLUMN] - b[COLUMN];
37
- }
38
- var found = false;
39
- function binarySearch(haystack, needle, low, high) {
40
- while (low <= high) {
41
- const mid = low + (high - low >> 1);
42
- const cmp = haystack[mid][COLUMN] - needle;
43
- if (cmp === 0) {
44
- found = true;
45
- return mid;
46
- }
47
- if (cmp < 0) low = mid + 1;
48
- else high = mid - 1;
49
- }
50
- found = false;
51
- return low - 1;
52
- }
53
- function upperBound(haystack, needle, index) {
54
- for (let i = index + 1; i < haystack.length; index = i++) if (haystack[i][COLUMN] !== needle) break;
55
- return index;
56
- }
57
- function lowerBound(haystack, needle, index) {
58
- for (let i = index - 1; i >= 0; index = i--) if (haystack[i][COLUMN] !== needle) break;
59
- return index;
60
- }
61
- function memoizedState() {
62
- return {
63
- lastKey: -1,
64
- lastNeedle: -1,
65
- lastIndex: -1
66
- };
67
- }
68
- function memoizedBinarySearch(haystack, needle, state, key) {
69
- const { lastKey, lastNeedle, lastIndex } = state;
70
- let low = 0;
71
- let high = haystack.length - 1;
72
- if (key === lastKey) {
73
- if (needle === lastNeedle) {
74
- found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
75
- return lastIndex;
76
- }
77
- if (needle >= lastNeedle) low = lastIndex === -1 ? 0 : lastIndex;
78
- else high = lastIndex;
79
- }
80
- state.lastKey = key;
81
- state.lastNeedle = needle;
82
- return state.lastIndex = binarySearch(haystack, needle, low, high);
83
- }
84
- function parse(map) {
85
- return typeof map === "string" ? JSON.parse(map) : map;
86
- }
87
- var LEAST_UPPER_BOUND = -1;
88
- var GREATEST_LOWER_BOUND = 1;
89
- var TraceMap = class {
90
- constructor(map, mapUrl) {
91
- const isString = typeof map === "string";
92
- if (!isString && map._decodedMemo) return map;
93
- const parsed = parse(map);
94
- const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
95
- this.version = version;
96
- this.file = file;
97
- this.names = names || [];
98
- this.sourceRoot = sourceRoot;
99
- this.sources = sources;
100
- this.sourcesContent = sourcesContent;
101
- this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
102
- const resolve$1 = resolver(mapUrl, sourceRoot);
103
- this.resolvedSources = sources.map(resolve$1);
104
- const { mappings } = parsed;
105
- if (typeof mappings === "string") {
106
- this._encoded = mappings;
107
- this._decoded = void 0;
108
- } else if (Array.isArray(mappings)) {
109
- this._encoded = void 0;
110
- this._decoded = maybeSort(mappings, isString);
111
- } else if (parsed.sections) throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
112
- else throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
113
- this._decodedMemo = memoizedState();
114
- this._bySources = void 0;
115
- this._bySourceMemos = void 0;
116
- }
117
- };
118
- function cast(map) {
119
- return map;
120
- }
121
- function decodedMappings(map) {
122
- var _a;
123
- return (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));
124
- }
125
- function traceSegment(map, line, column) {
126
- const decoded = decodedMappings(map);
127
- if (line >= decoded.length) return null;
128
- const segments = decoded[line];
129
- const index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
130
- return index === -1 ? null : segments[index];
131
- }
132
- function traceSegmentInternal(segments, memo, line, column, bias) {
133
- let index = memoizedBinarySearch(segments, column, memo, line);
134
- if (found) index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index);
135
- else if (bias === LEAST_UPPER_BOUND) index++;
136
- if (index === -1 || index === segments.length) return -1;
137
- return index;
138
- }
139
-
140
- //#endregion
141
- export { decodedMappings as n, traceSegment as r, TraceMap as t };
@@ -1,31 +0,0 @@
1
- //#region node_modules/.pnpm/@rolldown+pluginutils@1.0.0-beta.55/node_modules/@rolldown/pluginutils/dist/simple-filters.js
2
- /**
3
- * Constructs a RegExp that matches the exact string specified.
4
- *
5
- * This is useful for plugin hook filters.
6
- *
7
- * @param str the string to match.
8
- * @param flags flags for the RegExp.
9
- *
10
- * @example
11
- * ```ts
12
- * import { exactRegex } from '@rolldown/pluginutils';
13
- * const plugin = {
14
- * name: 'plugin',
15
- * resolveId: {
16
- * filter: { id: exactRegex('foo') },
17
- * handler(id) {} // will only be called for `foo`
18
- * }
19
- * }
20
- * ```
21
- */
22
- function exactRegex(str, flags) {
23
- return new RegExp(`^${escapeRegex(str)}$`, flags);
24
- }
25
- const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
26
- function escapeRegex(str) {
27
- return str.replace(escapeRegexRE, "\\$&");
28
- }
29
-
30
- //#endregion
31
- export { exactRegex as t };
@@ -1,104 +0,0 @@
1
- import { t as MagicString } from "../magic-string.mjs";
2
- import { n as createFilter } from "./pluginutils.mjs";
3
-
4
- //#region node_modules/.pnpm/@rollup+plugin-replace@6.0.3_rollup@4.55.1/node_modules/@rollup/plugin-replace/dist/es/index.js
5
- function escape(str) {
6
- return str.replace(/[-[\]/{}()*+?.\\^$|]/g, "\\$&");
7
- }
8
- function ensureFunction(functionOrValue) {
9
- if (typeof functionOrValue === "function") return functionOrValue;
10
- return function() {
11
- return functionOrValue;
12
- };
13
- }
14
- function longest(a, b) {
15
- return b.length - a.length;
16
- }
17
- function getReplacements(options) {
18
- if (options.values) return Object.assign({}, options.values);
19
- var values = Object.assign({}, options);
20
- delete values.delimiters;
21
- delete values.include;
22
- delete values.exclude;
23
- delete values.sourcemap;
24
- delete values.sourceMap;
25
- delete values.objectGuards;
26
- delete values.preventAssignment;
27
- return values;
28
- }
29
- function mapToFunctions(object) {
30
- return Object.keys(object).reduce(function(fns, key) {
31
- var functions = Object.assign({}, fns);
32
- functions[key] = ensureFunction(object[key]);
33
- return functions;
34
- }, {});
35
- }
36
- var objKeyRegEx = /^([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)(\.([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*))+$/;
37
- function expandTypeofReplacements(replacements) {
38
- Object.keys(replacements).forEach(function(key) {
39
- var objMatch = key.match(objKeyRegEx);
40
- if (!objMatch) return;
41
- var dotIndex = objMatch[1].length;
42
- do {
43
- replacements["typeof " + key.slice(0, dotIndex)] = "\"object\"";
44
- dotIndex = key.indexOf(".", dotIndex + 1);
45
- } while (dotIndex !== -1);
46
- });
47
- }
48
- function replace(options) {
49
- if (options === void 0) options = {};
50
- var filter = createFilter(options.include, options.exclude);
51
- var delimiters = options.delimiters;
52
- if (delimiters === void 0) delimiters = ["(?<![_$a-zA-Z0-9\\xA0-\\uFFFF])", "(?![_$a-zA-Z0-9\\xA0-\\uFFFF])(?!\\.)"];
53
- var preventAssignment = options.preventAssignment;
54
- var objectGuards = options.objectGuards;
55
- var replacements = getReplacements(options);
56
- if (objectGuards) expandTypeofReplacements(replacements);
57
- var functionValues = mapToFunctions(replacements);
58
- var keys = Object.keys(functionValues).sort(longest).map(escape);
59
- var lookbehind = preventAssignment ? "(?<!\\b(?:const|let|var)\\s*)" : "";
60
- var lookahead = preventAssignment ? "(?!\\s*=[^=])" : "";
61
- var pattern = new RegExp("" + lookbehind + delimiters[0] + "(" + keys.join("|") + ")" + delimiters[1] + lookahead, "g");
62
- return {
63
- name: "replace",
64
- buildStart: function buildStart() {
65
- if (![true, false].includes(preventAssignment)) this.warn({ message: "@rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`." });
66
- },
67
- renderChunk: function renderChunk(code, chunk) {
68
- var id = chunk.fileName;
69
- if (!keys.length) return null;
70
- if (!filter(id)) return null;
71
- return executeReplacement(code, id);
72
- },
73
- transform: function transform(code, id) {
74
- if (!keys.length) return null;
75
- if (!filter(id)) return null;
76
- return executeReplacement(code, id);
77
- }
78
- };
79
- function executeReplacement(code, id) {
80
- var magicString = new MagicString(code);
81
- if (!codeHasReplacements(code, id, magicString)) return null;
82
- var result = { code: magicString.toString() };
83
- if (isSourceMapEnabled()) result.map = magicString.generateMap({ hires: true });
84
- return result;
85
- }
86
- function codeHasReplacements(code, id, magicString) {
87
- var result = false;
88
- var match;
89
- while (match = pattern.exec(code)) {
90
- result = true;
91
- var start = match.index;
92
- var end = start + match[0].length;
93
- var replacement = String(functionValues[match[1]](id));
94
- magicString.overwrite(start, end, replacement);
95
- }
96
- return result;
97
- }
98
- function isSourceMapEnabled() {
99
- return options.sourceMap !== false && options.sourcemap !== false;
100
- }
101
- }
102
-
103
- //#endregion
104
- export { replace as t };
@@ -1,241 +0,0 @@
1
- import { i as __toESM } from "../../_rolldown.mjs";
2
- import { t as require_picomatch } from "../picomatch.mjs";
3
- import { n as walk } from "../estree-walker.mjs";
4
- import { extname, isAbsolute, posix, resolve, win32 } from "path";
5
-
6
- //#region node_modules/.pnpm/@rollup+pluginutils@5.3.0_rollup@4.55.1/node_modules/@rollup/pluginutils/dist/es/index.js
7
- var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
8
- const extractors = {
9
- ArrayPattern(names, param) {
10
- for (const element of param.elements) if (element) extractors[element.type](names, element);
11
- },
12
- AssignmentPattern(names, param) {
13
- extractors[param.left.type](names, param.left);
14
- },
15
- Identifier(names, param) {
16
- names.push(param.name);
17
- },
18
- MemberExpression() {},
19
- ObjectPattern(names, param) {
20
- for (const prop of param.properties) if (prop.type === "RestElement") extractors.RestElement(names, prop);
21
- else extractors[prop.value.type](names, prop.value);
22
- },
23
- RestElement(names, param) {
24
- extractors[param.argument.type](names, param.argument);
25
- }
26
- };
27
- const extractAssignedNames = function extractAssignedNames$1(param) {
28
- const names = [];
29
- extractors[param.type](names, param);
30
- return names;
31
- };
32
- const blockDeclarations = {
33
- const: true,
34
- let: true
35
- };
36
- var Scope = class {
37
- constructor(options = {}) {
38
- this.parent = options.parent;
39
- this.isBlockScope = !!options.block;
40
- this.declarations = Object.create(null);
41
- if (options.params) options.params.forEach((param) => {
42
- extractAssignedNames(param).forEach((name) => {
43
- this.declarations[name] = true;
44
- });
45
- });
46
- }
47
- addDeclaration(node, isBlockDeclaration, isVar) {
48
- if (!isBlockDeclaration && this.isBlockScope) this.parent.addDeclaration(node, isBlockDeclaration, isVar);
49
- else if (node.id) extractAssignedNames(node.id).forEach((name) => {
50
- this.declarations[name] = true;
51
- });
52
- }
53
- contains(name) {
54
- return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
55
- }
56
- };
57
- const attachScopes = function attachScopes$1(ast, propertyName = "scope") {
58
- let scope = new Scope();
59
- walk(ast, {
60
- enter(n, parent) {
61
- const node = n;
62
- if (/(?:Function|Class)Declaration/.test(node.type)) scope.addDeclaration(node, false, false);
63
- if (node.type === "VariableDeclaration") {
64
- const { kind } = node;
65
- const isBlockDeclaration = blockDeclarations[kind];
66
- node.declarations.forEach((declaration) => {
67
- scope.addDeclaration(declaration, isBlockDeclaration, true);
68
- });
69
- }
70
- let newScope;
71
- if (node.type.includes("Function")) {
72
- const func = node;
73
- newScope = new Scope({
74
- parent: scope,
75
- block: false,
76
- params: func.params
77
- });
78
- if (func.type === "FunctionExpression" && func.id) newScope.addDeclaration(func, false, false);
79
- }
80
- if (/For(?:In|Of)?Statement/.test(node.type)) newScope = new Scope({
81
- parent: scope,
82
- block: true
83
- });
84
- if (node.type === "BlockStatement" && !parent.type.includes("Function")) newScope = new Scope({
85
- parent: scope,
86
- block: true
87
- });
88
- if (node.type === "CatchClause") newScope = new Scope({
89
- parent: scope,
90
- params: node.param ? [node.param] : [],
91
- block: true
92
- });
93
- if (newScope) {
94
- Object.defineProperty(node, propertyName, {
95
- value: newScope,
96
- configurable: true
97
- });
98
- scope = newScope;
99
- }
100
- },
101
- leave(n) {
102
- if (n[propertyName]) scope = scope.parent;
103
- }
104
- });
105
- return scope;
106
- };
107
- function isArray(arg) {
108
- return Array.isArray(arg);
109
- }
110
- function ensureArray(thing) {
111
- if (isArray(thing)) return thing;
112
- if (thing == null) return [];
113
- return [thing];
114
- }
115
- const normalizePathRegExp = new RegExp(`\\${win32.sep}`, "g");
116
- const normalizePath = function normalizePath$1(filename) {
117
- return filename.replace(normalizePathRegExp, posix.sep);
118
- };
119
- function getMatcherString(id, resolutionBase) {
120
- if (resolutionBase === false || isAbsolute(id) || id.startsWith("**")) return normalizePath(id);
121
- const basePath = normalizePath(resolve(resolutionBase || "")).replace(/[-^$*+?.()|[\]{}]/g, "\\$&");
122
- return posix.join(basePath, normalizePath(id));
123
- }
124
- const createFilter = function createFilter$1(include, exclude, options) {
125
- const resolutionBase = options && options.resolve;
126
- const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
127
- return (0, import_picomatch.default)(getMatcherString(id, resolutionBase), { dot: true })(what);
128
- } };
129
- const includeMatchers = ensureArray(include).map(getMatcher);
130
- const excludeMatchers = ensureArray(exclude).map(getMatcher);
131
- if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
132
- return function result(id) {
133
- if (typeof id !== "string") return false;
134
- if (id.includes("\0")) return false;
135
- const pathId = normalizePath(id);
136
- for (let i = 0; i < excludeMatchers.length; ++i) {
137
- const matcher = excludeMatchers[i];
138
- if (matcher instanceof RegExp) matcher.lastIndex = 0;
139
- if (matcher.test(pathId)) return false;
140
- }
141
- for (let i = 0; i < includeMatchers.length; ++i) {
142
- const matcher = includeMatchers[i];
143
- if (matcher instanceof RegExp) matcher.lastIndex = 0;
144
- if (matcher.test(pathId)) return true;
145
- }
146
- return !includeMatchers.length;
147
- };
148
- };
149
- const forbiddenIdentifiers = new Set(`break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl`.split(" "));
150
- forbiddenIdentifiers.add("");
151
- const makeLegalIdentifier = function makeLegalIdentifier$1(str) {
152
- let identifier = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, "_");
153
- if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) identifier = `_${identifier}`;
154
- return identifier || "_";
155
- };
156
- function stringify(obj) {
157
- return (JSON.stringify(obj) || "undefined").replace(/[\u2028\u2029]/g, (char) => `\\u${`000${char.charCodeAt(0).toString(16)}`.slice(-4)}`);
158
- }
159
- function serializeArray(arr, indent, baseIndent) {
160
- let output = "[";
161
- const separator = indent ? `\n${baseIndent}${indent}` : "";
162
- for (let i = 0; i < arr.length; i++) {
163
- const key = arr[i];
164
- output += `${i > 0 ? "," : ""}${separator}${serialize(key, indent, baseIndent + indent)}`;
165
- }
166
- return `${output}${indent ? `\n${baseIndent}` : ""}]`;
167
- }
168
- function serializeObject(obj, indent, baseIndent) {
169
- let output = "{";
170
- const separator = indent ? `\n${baseIndent}${indent}` : "";
171
- const entries = Object.entries(obj);
172
- for (let i = 0; i < entries.length; i++) {
173
- const [key, value] = entries[i];
174
- const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
175
- output += `${i > 0 ? "," : ""}${separator}${stringKey}:${indent ? " " : ""}${serialize(value, indent, baseIndent + indent)}`;
176
- }
177
- return `${output}${indent ? `\n${baseIndent}` : ""}}`;
178
- }
179
- function serialize(obj, indent, baseIndent) {
180
- if (typeof obj === "object" && obj !== null) {
181
- if (Array.isArray(obj)) return serializeArray(obj, indent, baseIndent);
182
- if (obj instanceof Date) return `new Date(${obj.getTime()})`;
183
- if (obj instanceof RegExp) return obj.toString();
184
- return serializeObject(obj, indent, baseIndent);
185
- }
186
- if (typeof obj === "number") {
187
- if (obj === Infinity) return "Infinity";
188
- if (obj === -Infinity) return "-Infinity";
189
- if (obj === 0) return 1 / obj === Infinity ? "0" : "-0";
190
- if (obj !== obj) return "NaN";
191
- }
192
- if (typeof obj === "symbol") {
193
- const key = Symbol.keyFor(obj);
194
- if (key !== void 0) return `Symbol.for(${stringify(key)})`;
195
- }
196
- if (typeof obj === "bigint") return `${obj}n`;
197
- return stringify(obj);
198
- }
199
- const hasStringIsWellFormed = "isWellFormed" in String.prototype;
200
- function isWellFormedString(input) {
201
- if (hasStringIsWellFormed) return input.isWellFormed();
202
- return !/\p{Surrogate}/u.test(input);
203
- }
204
- const dataToEsm = function dataToEsm$1(data, options = {}) {
205
- var _a, _b;
206
- const t = options.compact ? "" : "indent" in options ? options.indent : " ";
207
- const _ = options.compact ? "" : " ";
208
- const n = options.compact ? "" : "\n";
209
- const declarationType = options.preferConst ? "const" : "var";
210
- if (options.namedExports === false || typeof data !== "object" || Array.isArray(data) || data instanceof Date || data instanceof RegExp || data === null) {
211
- const code = serialize(data, options.compact ? null : t, "");
212
- return `export default${_ || (/^[{[\-\/]/.test(code) ? "" : " ")}${code};`;
213
- }
214
- let maxUnderbarPrefixLength = 0;
215
- for (const key of Object.keys(data)) {
216
- const underbarPrefixLength = (_b = (_a = /^(_+)/.exec(key)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
217
- if (underbarPrefixLength > maxUnderbarPrefixLength) maxUnderbarPrefixLength = underbarPrefixLength;
218
- }
219
- const arbitraryNamePrefix = `${"_".repeat(maxUnderbarPrefixLength + 1)}arbitrary`;
220
- let namedExportCode = "";
221
- const defaultExportRows = [];
222
- const arbitraryNameExportRows = [];
223
- for (const [key, value] of Object.entries(data)) if (key === makeLegalIdentifier(key)) {
224
- if (options.objectShorthand) defaultExportRows.push(key);
225
- else defaultExportRows.push(`${key}:${_}${key}`);
226
- namedExportCode += `export ${declarationType} ${key}${_}=${_}${serialize(value, options.compact ? null : t, "")};${n}`;
227
- } else {
228
- defaultExportRows.push(`${stringify(key)}:${_}${serialize(value, options.compact ? null : t, "")}`);
229
- if (options.includeArbitraryNames && isWellFormedString(key)) {
230
- const variableName = `${arbitraryNamePrefix}${arbitraryNameExportRows.length}`;
231
- namedExportCode += `${declarationType} ${variableName}${_}=${_}${serialize(value, options.compact ? null : t, "")};${n}`;
232
- arbitraryNameExportRows.push(`${variableName} as ${JSON.stringify(key)}`);
233
- }
234
- }
235
- const arbitraryExportCode = arbitraryNameExportRows.length > 0 ? `export${_}{${n}${t}${arbitraryNameExportRows.join(`,${n}${t}`)}${n}};${n}` : "";
236
- const defaultExportCode = `export default${_}{${n}${t}${defaultExportRows.join(`,${n}${t}`)}${n}};${n}`;
237
- return `${namedExportCode}${arbitraryExportCode}${defaultExportCode}`;
238
- };
239
-
240
- //#endregion
241
- export { makeLegalIdentifier as a, extractAssignedNames as i, createFilter as n, dataToEsm as r, attachScopes as t };