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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitro-nightly",
3
- "version": "3.0.1-20260106-202835-5325b208",
3
+ "version": "3.0.1-20260106-205209-b085a480",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "homepage": "https://nitro.build",
6
6
  "repository": "nitrojs/nitro",
@@ -1,56 +0,0 @@
1
- import "../_rolldown.mjs";
2
- import "./shared2.mjs";
3
- import "../_libs/fdir.mjs";
4
- import "../_nitro2.mjs";
5
- import "../_libs/mime.mjs";
6
- import "../_libs/acorn.mjs";
7
- import "../_libs/@jridgewell/sourcemap-codec.mjs";
8
- import "../_libs/js-tokens.mjs";
9
- import "./shared3.mjs";
10
- import "../_libs/@rollup/plugin-alias.mjs";
11
- import "../_libs/@rollup/pluginutils.mjs";
12
- import "../_libs/@rollup/plugin-inject.mjs";
13
- import "../_libs/etag.mjs";
14
- import "../_libs/@rollup/plugin-replace.mjs";
15
- import "../_libs/duplexer.mjs";
16
- import "../_libs/gzip-size.mjs";
17
- import "../_libs/commondir.mjs";
18
- import "../_libs/is-reference.mjs";
19
- import "../_libs/@rollup/plugin-commonjs.mjs";
20
- import "../_libs/@rollup/plugin-json.mjs";
21
- import "../_libs/deepmerge.mjs";
22
- import "../_libs/is-module.mjs";
23
- import "../_libs/resolve.mjs";
24
- import "../_libs/path-parse.mjs";
25
- import "../_libs/function-bind.mjs";
26
- import "../_libs/@rollup/plugin-node-resolve.mjs";
27
- import { t as rollupBuild } from "./rollup.mjs";
28
- import { transformSync } from "oxc-transform";
29
- import { minifySync } from "oxc-minify";
30
-
31
- //#region src/build/plugins/oxc.ts
32
- function oxc(options) {
33
- return {
34
- name: "nitro:oxc",
35
- transform: {
36
- filter: { id: /^(?!.*\/node_modules\/).*\.m?[jt]sx?$/ },
37
- handler(code, id) {
38
- const res = transformSync(id, code, {
39
- sourcemap: options.sourcemap,
40
- ...options.transform
41
- });
42
- if (res.errors?.length > 0) this.error(res.errors.join("\n"));
43
- return res;
44
- }
45
- },
46
- renderChunk(code, chunk) {
47
- if (options.minify) return minifySync(chunk.fileName, code, {
48
- sourcemap: options.sourcemap,
49
- ...typeof options.minify === "object" ? options.minify : {}
50
- });
51
- }
52
- };
53
- }
54
-
55
- //#endregion
56
- export { rollupBuild, oxc as t };
@@ -1,60 +0,0 @@
1
- import { l as relative, r as dirname, u as resolve } from "../_libs/pathe.mjs";
2
- import { a as parseGitConfig, c as resolveGitConfig, i as findWorkspaceDir, l as resolvePackageJSON, n as findFile, o as readGitConfig, r as findNearestFile, s as readPackageJSON } from "../_libs/pkg-types.mjs";
3
- import { i as a } from "../_libs/std-env.mjs";
4
- import { t as glob } from "../_libs/tinyglobby.mjs";
5
- import { t as runParallel } from "../_nitro2.mjs";
6
- import { t as gzipSize } from "../_libs/gzip-size.mjs";
7
- import { t as prettyBytes } from "../_libs/pretty-bytes.mjs";
8
- import { promises } from "node:fs";
9
- import { colors } from "consola/utils";
10
-
11
- //#region src/utils/fs-tree.ts
12
- async function generateFSTree(dir, options = {}) {
13
- if (a) return;
14
- const files = await glob("**/*.*", {
15
- cwd: dir,
16
- ignore: ["*.map"]
17
- });
18
- const items = [];
19
- await runParallel(new Set(files), async (file) => {
20
- const path = resolve(dir, file);
21
- const src = await promises.readFile(path);
22
- const size = src.byteLength;
23
- const gzip = options.compressedSizes ? await gzipSize(src) : 0;
24
- items.push({
25
- file,
26
- path,
27
- size,
28
- gzip
29
- });
30
- }, { concurrency: 10 });
31
- items.sort((a$1, b) => a$1.path.localeCompare(b.path));
32
- let totalSize = 0;
33
- let totalGzip = 0;
34
- let totalNodeModulesSize = 0;
35
- let totalNodeModulesGzip = 0;
36
- let treeText = "";
37
- for (const [index, item] of items.entries()) {
38
- let dir$1 = dirname(item.file);
39
- if (dir$1 === ".") dir$1 = "";
40
- const rpath = relative(process.cwd(), item.path);
41
- const treeChar = index === items.length - 1 ? "└─" : "├─";
42
- if (item.file.includes("node_modules")) {
43
- totalNodeModulesSize += item.size;
44
- totalNodeModulesGzip += item.gzip;
45
- continue;
46
- }
47
- treeText += colors.gray(` ${treeChar} ${rpath} (${prettyBytes(item.size)})`);
48
- if (options.compressedSizes) treeText += colors.gray(` (${prettyBytes(item.gzip)} gzip)`);
49
- treeText += "\n";
50
- totalSize += item.size;
51
- totalGzip += item.gzip;
52
- }
53
- treeText += `${colors.cyan("Σ Total size:")} ${prettyBytes(totalSize + totalNodeModulesSize)}`;
54
- if (options.compressedSizes) treeText += ` (${prettyBytes(totalGzip + totalNodeModulesGzip)} gzip)`;
55
- treeText += "\n";
56
- return treeText;
57
- }
58
-
59
- //#endregion
60
- export { readPackageJSON, generateFSTree as t };
@@ -1,40 +0,0 @@
1
- import { l as relative, r as dirname, u as resolve } from "../_libs/pathe.mjs";
2
- import { t as getProperty } from "../_libs/dot-prop.mjs";
3
- import consola$1 from "consola";
4
- import { mkdir, stat, writeFile } from "node:fs/promises";
5
- import { colors } from "consola/utils";
6
-
7
- //#region src/utils/fs.ts
8
- function prettyPath(p, highlight = true) {
9
- p = relative(process.cwd(), p);
10
- return highlight ? colors.cyan(p) : p;
11
- }
12
- function resolveNitroPath(path, nitroOptions, base) {
13
- if (typeof path !== "string") throw new TypeError("Invalid path: " + path);
14
- path = _compilePathTemplate(path)(nitroOptions);
15
- for (const base$1 in nitroOptions.alias) if (path.startsWith(base$1)) path = nitroOptions.alias[base$1] + path.slice(base$1.length);
16
- if (/^[#\u0000]/.test(path)) return path;
17
- return resolve(base || nitroOptions.rootDir, path);
18
- }
19
- function _compilePathTemplate(contents) {
20
- return (params) => contents.replace(/{{ ?([\w.]+) ?}}/g, (_, match) => {
21
- const val = getProperty(params, match);
22
- if (!val) consola$1.warn(`cannot resolve template param '${match}' in ${contents.slice(0, 20)}`);
23
- return val || `${match}`;
24
- });
25
- }
26
- async function writeFile$1(file, contents, log = false) {
27
- await mkdir(dirname(file), { recursive: true });
28
- await writeFile(file, contents, typeof contents === "string" ? "utf8" : void 0);
29
- if (log) consola$1.info("Generated", prettyPath(file));
30
- }
31
- async function isDirectory(path) {
32
- try {
33
- return (await stat(path)).isDirectory();
34
- } catch {
35
- return false;
36
- }
37
- }
38
-
39
- //#endregion
40
- export { writeFile$1 as i, prettyPath as n, resolveNitroPath as r, isDirectory as t };
@@ -1,68 +0,0 @@
1
- import { l as relative$1, o as join$1, u as resolve$1 } from "../_libs/pathe.mjs";
2
- import { i as writeFile$1 } from "./shared2.mjs";
3
- import { mkdir, readFile, stat } from "node:fs/promises";
4
- import { dirname } from "node:path";
5
- import { version } from "nitro/meta";
6
-
7
- //#region src/presets/_types.gen.ts
8
- const presetsWithConfig = [
9
- "awsAmplify",
10
- "awsLambda",
11
- "azure",
12
- "cloudflare",
13
- "firebase",
14
- "netlify",
15
- "vercel"
16
- ];
17
-
18
- //#endregion
19
- //#region src/build/info.ts
20
- const NITRO_WELLKNOWN_DIR = "node_modules/.nitro";
21
- async function getBuildInfo(root) {
22
- const outputDir = await findLastBuildDir(root);
23
- if (!await stat(outputDir).then((s) => s.isDirectory()).catch(() => false)) return {};
24
- return {
25
- outputDir,
26
- buildInfo: await readFile(resolve$1(outputDir, "nitro.json"), "utf8").then(JSON.parse).catch(() => void 0)
27
- };
28
- }
29
- async function findLastBuildDir(root) {
30
- const lastBuildLink = join$1(root, NITRO_WELLKNOWN_DIR, "last-build.json");
31
- return await readFile(lastBuildLink, "utf8").then(JSON.parse).then((data) => resolve$1(lastBuildLink, data.outputDir || "../../../.output")).catch(() => resolve$1(root, ".output"));
32
- }
33
- async function writeBuildInfo(nitro) {
34
- const buildInfoPath = resolve$1(nitro.options.output.dir, "nitro.json");
35
- const buildInfo = {
36
- date: (/* @__PURE__ */ new Date()).toJSON(),
37
- preset: nitro.options.preset,
38
- framework: nitro.options.framework,
39
- versions: { nitro: version },
40
- commands: {
41
- preview: nitro.options.commands.preview,
42
- deploy: nitro.options.commands.deploy
43
- },
44
- config: { ...Object.fromEntries(presetsWithConfig.map((key) => [key, nitro.options[key]])) }
45
- };
46
- await writeFile$1(buildInfoPath, JSON.stringify(buildInfo, null, 2), true);
47
- const lastBuild = join$1(nitro.options.rootDir, NITRO_WELLKNOWN_DIR, "last-build.json");
48
- await mkdir(dirname(lastBuild), { recursive: true });
49
- await writeFile$1(lastBuild, JSON.stringify({ outputDir: relative$1(lastBuild, nitro.options.output.dir) }));
50
- return buildInfo;
51
- }
52
- async function writeDevBuildInfo(nitro, addr) {
53
- const buildInfoPath = join$1(nitro.options.rootDir, NITRO_WELLKNOWN_DIR, "nitro.dev.json");
54
- const buildInfo = {
55
- date: (/* @__PURE__ */ new Date()).toJSON(),
56
- preset: nitro.options.preset,
57
- framework: nitro.options.framework,
58
- versions: { nitro: version },
59
- dev: {
60
- pid: process.pid,
61
- workerAddress: addr
62
- }
63
- };
64
- await writeFile$1(buildInfoPath, JSON.stringify(buildInfo, null, 2));
65
- }
66
-
67
- //#endregion
68
- export { writeBuildInfo as n, writeDevBuildInfo as r, getBuildInfo as t };
@@ -1,166 +0,0 @@
1
- //#region node_modules/.pnpm/@jridgewell+resolve-uri@3.1.2/node_modules/@jridgewell/resolve-uri/dist/resolve-uri.mjs
2
- const schemeRegex = /^[\w+.-]+:\/\//;
3
- /**
4
- * Matches the parts of a URL:
5
- * 1. Scheme, including ":", guaranteed.
6
- * 2. User/password, including "@", optional.
7
- * 3. Host, guaranteed.
8
- * 4. Port, including ":", optional.
9
- * 5. Path, including "/", optional.
10
- * 6. Query, including "?", optional.
11
- * 7. Hash, including "#", optional.
12
- */
13
- const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
14
- /**
15
- * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
16
- * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
17
- *
18
- * 1. Host, optional.
19
- * 2. Path, which may include "/", guaranteed.
20
- * 3. Query, including "?", optional.
21
- * 4. Hash, including "#", optional.
22
- */
23
- const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
24
- function isAbsoluteUrl(input) {
25
- return schemeRegex.test(input);
26
- }
27
- function isSchemeRelativeUrl(input) {
28
- return input.startsWith("//");
29
- }
30
- function isAbsolutePath(input) {
31
- return input.startsWith("/");
32
- }
33
- function isFileUrl(input) {
34
- return input.startsWith("file:");
35
- }
36
- function isRelative(input) {
37
- return /^[.?#]/.test(input);
38
- }
39
- function parseAbsoluteUrl(input) {
40
- const match = urlRegex.exec(input);
41
- return makeUrl(match[1], match[2] || "", match[3], match[4] || "", match[5] || "/", match[6] || "", match[7] || "");
42
- }
43
- function parseFileUrl(input) {
44
- const match = fileRegex.exec(input);
45
- const path = match[2];
46
- return makeUrl("file:", "", match[1] || "", "", isAbsolutePath(path) ? path : "/" + path, match[3] || "", match[4] || "");
47
- }
48
- function makeUrl(scheme, user, host, port, path, query, hash) {
49
- return {
50
- scheme,
51
- user,
52
- host,
53
- port,
54
- path,
55
- query,
56
- hash,
57
- type: 7
58
- };
59
- }
60
- function parseUrl(input) {
61
- if (isSchemeRelativeUrl(input)) {
62
- const url$1 = parseAbsoluteUrl("http:" + input);
63
- url$1.scheme = "";
64
- url$1.type = 6;
65
- return url$1;
66
- }
67
- if (isAbsolutePath(input)) {
68
- const url$1 = parseAbsoluteUrl("http://foo.com" + input);
69
- url$1.scheme = "";
70
- url$1.host = "";
71
- url$1.type = 5;
72
- return url$1;
73
- }
74
- if (isFileUrl(input)) return parseFileUrl(input);
75
- if (isAbsoluteUrl(input)) return parseAbsoluteUrl(input);
76
- const url = parseAbsoluteUrl("http://foo.com/" + input);
77
- url.scheme = "";
78
- url.host = "";
79
- url.type = input ? input.startsWith("?") ? 3 : input.startsWith("#") ? 2 : 4 : 1;
80
- return url;
81
- }
82
- function stripPathFilename(path) {
83
- if (path.endsWith("/..")) return path;
84
- const index = path.lastIndexOf("/");
85
- return path.slice(0, index + 1);
86
- }
87
- function mergePaths(url, base) {
88
- normalizePath(base, base.type);
89
- if (url.path === "/") url.path = base.path;
90
- else url.path = stripPathFilename(base.path) + url.path;
91
- }
92
- /**
93
- * The path can have empty directories "//", unneeded parents "foo/..", or current directory
94
- * "foo/.". We need to normalize to a standard representation.
95
- */
96
- function normalizePath(url, type) {
97
- const rel = type <= 4;
98
- const pieces = url.path.split("/");
99
- let pointer = 1;
100
- let positive = 0;
101
- let addTrailingSlash = false;
102
- for (let i = 1; i < pieces.length; i++) {
103
- const piece = pieces[i];
104
- if (!piece) {
105
- addTrailingSlash = true;
106
- continue;
107
- }
108
- addTrailingSlash = false;
109
- if (piece === ".") continue;
110
- if (piece === "..") {
111
- if (positive) {
112
- addTrailingSlash = true;
113
- positive--;
114
- pointer--;
115
- } else if (rel) pieces[pointer++] = piece;
116
- continue;
117
- }
118
- pieces[pointer++] = piece;
119
- positive++;
120
- }
121
- let path = "";
122
- for (let i = 1; i < pointer; i++) path += "/" + pieces[i];
123
- if (!path || addTrailingSlash && !path.endsWith("/..")) path += "/";
124
- url.path = path;
125
- }
126
- /**
127
- * Attempts to resolve `input` URL/path relative to `base`.
128
- */
129
- function resolve(input, base) {
130
- if (!input && !base) return "";
131
- const url = parseUrl(input);
132
- let inputType = url.type;
133
- if (base && inputType !== 7) {
134
- const baseUrl = parseUrl(base);
135
- const baseType = baseUrl.type;
136
- switch (inputType) {
137
- case 1: url.hash = baseUrl.hash;
138
- case 2: url.query = baseUrl.query;
139
- case 3:
140
- case 4: mergePaths(url, baseUrl);
141
- case 5:
142
- url.user = baseUrl.user;
143
- url.host = baseUrl.host;
144
- url.port = baseUrl.port;
145
- case 6: url.scheme = baseUrl.scheme;
146
- }
147
- if (baseType > inputType) inputType = baseType;
148
- }
149
- normalizePath(url, inputType);
150
- const queryHash = url.query + url.hash;
151
- switch (inputType) {
152
- case 2:
153
- case 3: return queryHash;
154
- case 4: {
155
- const path = url.path.slice(1);
156
- if (!path) return queryHash || ".";
157
- if (isRelative(base || input) && !isRelative(path)) return "./" + path + queryHash;
158
- return path + queryHash;
159
- }
160
- case 5: return url.path + queryHash;
161
- default: return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
162
- }
163
- }
164
-
165
- //#endregion
166
- export { resolve as t };
@@ -1,167 +0,0 @@
1
- //#region node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
2
- var comma = ",".charCodeAt(0);
3
- var semicolon = ";".charCodeAt(0);
4
- var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
5
- var intToChar = new Uint8Array(64);
6
- var charToInt = new Uint8Array(128);
7
- for (let i = 0; i < chars.length; i++) {
8
- const c = chars.charCodeAt(i);
9
- intToChar[i] = c;
10
- charToInt[c] = i;
11
- }
12
- function decodeInteger(reader, relative) {
13
- let value = 0;
14
- let shift = 0;
15
- let integer = 0;
16
- do {
17
- integer = charToInt[reader.next()];
18
- value |= (integer & 31) << shift;
19
- shift += 5;
20
- } while (integer & 32);
21
- const shouldNegate = value & 1;
22
- value >>>= 1;
23
- if (shouldNegate) value = -2147483648 | -value;
24
- return relative + value;
25
- }
26
- function encodeInteger(builder, num, relative) {
27
- let delta = num - relative;
28
- delta = delta < 0 ? -delta << 1 | 1 : delta << 1;
29
- do {
30
- let clamped = delta & 31;
31
- delta >>>= 5;
32
- if (delta > 0) clamped |= 32;
33
- builder.write(intToChar[clamped]);
34
- } while (delta > 0);
35
- return num;
36
- }
37
- function hasMoreVlq(reader, max) {
38
- if (reader.pos >= max) return false;
39
- return reader.peek() !== comma;
40
- }
41
- var bufLength = 1024 * 16;
42
- var td = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer !== "undefined" ? { decode(buf) {
43
- return Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength).toString();
44
- } } : { decode(buf) {
45
- let out = "";
46
- for (let i = 0; i < buf.length; i++) out += String.fromCharCode(buf[i]);
47
- return out;
48
- } };
49
- var StringWriter = class {
50
- constructor() {
51
- this.pos = 0;
52
- this.out = "";
53
- this.buffer = new Uint8Array(bufLength);
54
- }
55
- write(v) {
56
- const { buffer } = this;
57
- buffer[this.pos++] = v;
58
- if (this.pos === bufLength) {
59
- this.out += td.decode(buffer);
60
- this.pos = 0;
61
- }
62
- }
63
- flush() {
64
- const { buffer, out, pos } = this;
65
- return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
66
- }
67
- };
68
- var StringReader = class {
69
- constructor(buffer) {
70
- this.pos = 0;
71
- this.buffer = buffer;
72
- }
73
- next() {
74
- return this.buffer.charCodeAt(this.pos++);
75
- }
76
- peek() {
77
- return this.buffer.charCodeAt(this.pos);
78
- }
79
- indexOf(char) {
80
- const { buffer, pos } = this;
81
- const idx = buffer.indexOf(char, pos);
82
- return idx === -1 ? buffer.length : idx;
83
- }
84
- };
85
- function decode(mappings) {
86
- const { length } = mappings;
87
- const reader = new StringReader(mappings);
88
- const decoded = [];
89
- let genColumn = 0;
90
- let sourcesIndex = 0;
91
- let sourceLine = 0;
92
- let sourceColumn = 0;
93
- let namesIndex = 0;
94
- do {
95
- const semi = reader.indexOf(";");
96
- const line = [];
97
- let sorted = true;
98
- let lastCol = 0;
99
- genColumn = 0;
100
- while (reader.pos < semi) {
101
- let seg;
102
- genColumn = decodeInteger(reader, genColumn);
103
- if (genColumn < lastCol) sorted = false;
104
- lastCol = genColumn;
105
- if (hasMoreVlq(reader, semi)) {
106
- sourcesIndex = decodeInteger(reader, sourcesIndex);
107
- sourceLine = decodeInteger(reader, sourceLine);
108
- sourceColumn = decodeInteger(reader, sourceColumn);
109
- if (hasMoreVlq(reader, semi)) {
110
- namesIndex = decodeInteger(reader, namesIndex);
111
- seg = [
112
- genColumn,
113
- sourcesIndex,
114
- sourceLine,
115
- sourceColumn,
116
- namesIndex
117
- ];
118
- } else seg = [
119
- genColumn,
120
- sourcesIndex,
121
- sourceLine,
122
- sourceColumn
123
- ];
124
- } else seg = [genColumn];
125
- line.push(seg);
126
- reader.pos++;
127
- }
128
- if (!sorted) sort(line);
129
- decoded.push(line);
130
- reader.pos = semi + 1;
131
- } while (reader.pos <= length);
132
- return decoded;
133
- }
134
- function sort(line) {
135
- line.sort(sortComparator);
136
- }
137
- function sortComparator(a, b) {
138
- return a[0] - b[0];
139
- }
140
- function encode(decoded) {
141
- const writer = new StringWriter();
142
- let sourcesIndex = 0;
143
- let sourceLine = 0;
144
- let sourceColumn = 0;
145
- let namesIndex = 0;
146
- for (let i = 0; i < decoded.length; i++) {
147
- const line = decoded[i];
148
- if (i > 0) writer.write(semicolon);
149
- if (line.length === 0) continue;
150
- let genColumn = 0;
151
- for (let j = 0; j < line.length; j++) {
152
- const segment = line[j];
153
- if (j > 0) writer.write(comma);
154
- genColumn = encodeInteger(writer, segment[0], genColumn);
155
- if (segment.length === 1) continue;
156
- sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
157
- sourceLine = encodeInteger(writer, segment[2], sourceLine);
158
- sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
159
- if (segment.length === 4) continue;
160
- namesIndex = encodeInteger(writer, segment[4], namesIndex);
161
- }
162
- }
163
- return writer.flush();
164
- }
165
-
166
- //#endregion
167
- export { encode as n, decode as t };