@rsbuild/core 1.7.2 → 2.0.0-alpha.0

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 (119) hide show
  1. package/compiled/css-loader/index.js +2 -2
  2. package/compiled/html-rspack-plugin/index.js +14 -14
  3. package/compiled/http-proxy-middleware/index.d.ts +2 -2
  4. package/compiled/postcss/index.js +1 -1
  5. package/compiled/postcss-loader/index.js +6 -6
  6. package/compiled/ws/index.js +59 -54
  7. package/compiled/ws/package.json +1 -1
  8. package/dist/131.js +1000 -1065
  9. package/dist/31.js +336 -0
  10. package/dist/710.js +445 -0
  11. package/dist/743.js +7 -0
  12. package/dist/{136.mjs → 88.js} +11 -13
  13. package/dist/client/hmr.js +0 -1
  14. package/dist/client/overlay.js +32 -21
  15. package/dist/connect.js +581 -0
  16. package/dist/connect.js.LICENSE.txt +54 -0
  17. package/dist/cors.js +188 -0
  18. package/dist/cors.js.LICENSE.txt +11 -0
  19. package/dist/launch-editor-middleware.js +439 -0
  20. package/dist/manifest-plugin.js +177 -0
  21. package/dist/memfs.js +3644 -0
  22. package/dist/{0~open.js → open.js} +21 -13
  23. package/dist/{0~range-parser.js → range-parser.js} +1 -1
  24. package/dist/remapping.js +196 -0
  25. package/dist/sirv.js +122 -0
  26. package/dist/tinyglobby.js +1463 -0
  27. package/dist/transformLoader.mjs +1 -1
  28. package/dist/transformRawLoader.mjs +1 -1
  29. package/dist-types/{provider/build.d.ts → build.d.ts} +2 -2
  30. package/dist-types/cli/commands.d.ts +1 -1
  31. package/dist-types/configChain.d.ts +0 -2
  32. package/dist-types/constants.d.ts +2 -3
  33. package/dist-types/{provider/createCompiler.d.ts → createCompiler.d.ts} +1 -1
  34. package/dist-types/defaultConfig.d.ts +1 -1
  35. package/dist-types/helpers/index.d.ts +1 -1
  36. package/dist-types/helpers/url.d.ts +0 -1
  37. package/dist-types/helpers/vendors.d.ts +0 -13
  38. package/dist-types/hooks.d.ts +3 -5
  39. package/dist-types/index.d.ts +1 -1
  40. package/dist-types/{provider/initConfigs.d.ts → initConfigs.d.ts} +1 -1
  41. package/dist-types/inspectConfig.d.ts +5 -33
  42. package/dist-types/pluginHelper.d.ts +1 -1
  43. package/dist-types/plugins/css.d.ts +1 -1
  44. package/dist-types/plugins/inlineChunk.d.ts +1 -1
  45. package/dist-types/plugins/minimize.d.ts +2 -2
  46. package/dist-types/{provider/rspackConfig.d.ts → rspackConfig.d.ts} +1 -1
  47. package/dist-types/server/assets-middleware/setupOutputFileSystem.d.ts +1 -1
  48. package/dist-types/server/browserLogs.d.ts +1 -1
  49. package/dist-types/server/devMiddlewares.d.ts +1 -1
  50. package/dist-types/server/devServer.d.ts +1 -1
  51. package/dist-types/server/gzipMiddleware.d.ts +1 -1
  52. package/dist-types/server/helper.d.ts +3 -2
  53. package/dist-types/server/proxy.d.ts +1 -1
  54. package/dist-types/server/socketServer.d.ts +1 -1
  55. package/dist-types/types/config.d.ts +7 -51
  56. package/dist-types/types/context.d.ts +3 -2
  57. package/dist-types/types/hooks.d.ts +9 -9
  58. package/dist-types/types/plugin.d.ts +3 -40
  59. package/dist-types/types/rsbuild.d.ts +6 -31
  60. package/dist-types/types/thirdParty.d.ts +1 -4
  61. package/package.json +14 -19
  62. package/compiled/@jridgewell/remapping/index.d.ts +0 -1
  63. package/compiled/@jridgewell/remapping/index.js +0 -1222
  64. package/compiled/@jridgewell/remapping/license +0 -19
  65. package/compiled/@jridgewell/remapping/package.json +0 -1
  66. package/compiled/@jridgewell/trace-mapping/index.d.ts +0 -194
  67. package/compiled/@jridgewell/trace-mapping/index.js +0 -1408
  68. package/compiled/@jridgewell/trace-mapping/license +0 -19
  69. package/compiled/@jridgewell/trace-mapping/package.json +0 -1
  70. package/compiled/connect/index.d.ts +0 -90
  71. package/compiled/connect/index.js +0 -1240
  72. package/compiled/connect/license +0 -25
  73. package/compiled/connect/package.json +0 -1
  74. package/compiled/cors/index.d.ts +0 -56
  75. package/compiled/cors/index.js +0 -371
  76. package/compiled/cors/license +0 -22
  77. package/compiled/cors/package.json +0 -1
  78. package/compiled/launch-editor-middleware/index.d.ts +0 -1
  79. package/compiled/launch-editor-middleware/index.js +0 -719
  80. package/compiled/launch-editor-middleware/license +0 -21
  81. package/compiled/launch-editor-middleware/package.json +0 -1
  82. package/compiled/memfs/index.d.ts +0 -1462
  83. package/compiled/memfs/index.js +0 -1
  84. package/compiled/memfs/license +0 -201
  85. package/compiled/memfs/package.json +0 -1
  86. package/compiled/mrmime/index.d.ts +0 -4
  87. package/compiled/mrmime/index.js +0 -456
  88. package/compiled/mrmime/package.json +0 -1
  89. package/compiled/picocolors/index.d.ts +0 -55
  90. package/compiled/picocolors/index.js +0 -108
  91. package/compiled/picocolors/license +0 -15
  92. package/compiled/picocolors/package.json +0 -1
  93. package/compiled/rspack-manifest-plugin/index.d.ts +0 -48
  94. package/compiled/rspack-manifest-plugin/index.js +0 -409
  95. package/compiled/rspack-manifest-plugin/license +0 -21
  96. package/compiled/rspack-manifest-plugin/package.json +0 -1
  97. package/compiled/sirv/index.d.ts +0 -1
  98. package/compiled/sirv/index.js +0 -274
  99. package/compiled/sirv/package.json +0 -1
  100. package/compiled/tinyglobby/index.d.ts +0 -46
  101. package/compiled/tinyglobby/index.js +0 -2664
  102. package/compiled/tinyglobby/license +0 -21
  103. package/compiled/tinyglobby/package.json +0 -1
  104. package/compiled/webpack-bundle-analyzer/index.d.ts +0 -160
  105. package/compiled/webpack-bundle-analyzer/index.js +0 -23
  106. package/compiled/webpack-bundle-analyzer/license +0 -20
  107. package/compiled/webpack-bundle-analyzer/package.json +0 -1
  108. package/compiled/webpack-bundle-analyzer/public/viewer.js +0 -16
  109. package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +0 -10
  110. package/dist/2~open.cjs +0 -436
  111. package/dist/2~range-parser.cjs +0 -52
  112. package/dist/2~range-parser.cjs.LICENSE.txt +0 -6
  113. package/dist/index.cjs +0 -9456
  114. package/dist/index.cjs.LICENSE.txt +0 -26
  115. package/dist-types/plugins/bundleAnalyzer.d.ts +0 -2
  116. package/dist-types/plugins/performance.d.ts +0 -5
  117. package/dist-types/provider/helpers.d.ts +0 -12
  118. package/dist-types/provider/provider.d.ts +0 -2
  119. /package/dist/{0~range-parser.js.LICENSE.txt → range-parser.js.LICENSE.txt} +0 -0
@@ -2,18 +2,19 @@ let isDockerCached, cachedResult, canAccessPowerShellPromise, mountPoint, defaul
2
2
  import { __webpack_require__ } from "./rslib-runtime.js";
3
3
  import node_child_process, { execFile } from "node:child_process";
4
4
  import promises, { constants } from "node:fs/promises";
5
- import { Buffer } from "node:buffer";
6
- import { node_fs, node_process, node_os, external_node_util_promisify } from "./131.js";
5
+ import { node_process, node_os, external_node_util_promisify } from "./131.js";
6
+ import "./743.js";
7
+ let external_node_fs_ = __webpack_require__("node:fs");
7
8
  function hasDockerEnv() {
8
9
  try {
9
- return node_fs.statSync('/.dockerenv'), !0;
10
+ return external_node_fs_.default.statSync('/.dockerenv'), !0;
10
11
  } catch {
11
12
  return !1;
12
13
  }
13
14
  }
14
15
  function hasDockerCGroup() {
15
16
  try {
16
- return node_fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
17
+ return external_node_fs_.default.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
17
18
  } catch {
18
19
  return !1;
19
20
  }
@@ -24,7 +25,7 @@ function isDocker() {
24
25
  function isInsideContainer() {
25
26
  return void 0 === cachedResult && (cachedResult = (()=>{
26
27
  try {
27
- return node_fs.statSync('/run/.containerenv'), !0;
28
+ return external_node_fs_.default.statSync('/run/.containerenv'), !0;
28
29
  } catch {
29
30
  return !1;
30
31
  }
@@ -34,11 +35,11 @@ let isWsl = ()=>{
34
35
  if ('linux' !== node_process.platform) return !1;
35
36
  if (node_os.release().toLowerCase().includes('microsoft')) return !isInsideContainer();
36
37
  try {
37
- return !!node_fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') && !isInsideContainer();
38
+ return !!external_node_fs_.default.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft') && !isInsideContainer();
38
39
  } catch {
39
40
  return !1;
40
41
  }
41
- }, is_wsl = node_process.env.__IS_WSL_TEST__ ? isWsl : isWsl(), powershell_utils_execFile = external_node_util_promisify(node_child_process.execFile), powerShellPath = ()=>`${node_process.env.SYSTEMROOT || node_process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {})=>{
42
+ }, is_wsl = node_process.env.__IS_WSL_TEST__ ? isWsl : isWsl(), external_node_buffer_ = __webpack_require__("node:buffer"), powershell_utils_execFile = external_node_util_promisify(node_child_process.execFile), powerShellPath = ()=>`${node_process.env.SYSTEMROOT || node_process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`, executePowerShell = async (command, options = {})=>{
42
43
  let { powerShellPath: psPath, ...execFileOptions } = options, encodedCommand = executePowerShell.encodeCommand(command);
43
44
  return powershell_utils_execFile(psPath ?? powerShellPath(), [
44
45
  ...executePowerShell.argumentsPrefix,
@@ -48,13 +49,20 @@ let isWsl = ()=>{
48
49
  ...execFileOptions
49
50
  });
50
51
  };
52
+ function parseMountPointFromConfig(content) {
53
+ for (let line of content.split('\n')){
54
+ if (/^\s*#/.test(line)) continue;
55
+ let match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
56
+ if (match) return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, '');
57
+ }
58
+ }
51
59
  executePowerShell.argumentsPrefix = [
52
60
  '-NoProfile',
53
61
  '-NonInteractive',
54
62
  '-ExecutionPolicy',
55
63
  'Bypass',
56
64
  '-EncodedCommand'
57
- ], executePowerShell.encodeCommand = (command)=>Buffer.from(command, 'utf16le').toString('base64'), executePowerShell.escapeArgument = (value)=>`'${String(value).replaceAll('\'', '\'\'')}'`;
65
+ ], executePowerShell.encodeCommand = (command)=>external_node_buffer_.Buffer.from(command, 'utf16le').toString('base64'), executePowerShell.escapeArgument = (value)=>`'${String(value).replaceAll('\'', '\'\'')}'`;
58
66
  let wsl_utils_execFile = external_node_util_promisify(node_child_process.execFile), wslDrivesMountPoint = (defaultMountPoint = '/mnt/', async function() {
59
67
  if (mountPoint) return mountPoint;
60
68
  let configFilePath = '/etc/wsl.conf', isConfigFileExists = !1;
@@ -62,10 +70,10 @@ let wsl_utils_execFile = external_node_util_promisify(node_child_process.execFil
62
70
  await promises.access(configFilePath, constants.F_OK), isConfigFileExists = !0;
63
71
  } catch {}
64
72
  if (!isConfigFileExists) return defaultMountPoint;
65
- let configContent = await promises.readFile(configFilePath, {
73
+ let parsedMountPoint = parseMountPointFromConfig(await promises.readFile(configFilePath, {
66
74
  encoding: 'utf8'
67
- }), configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
68
- return configMountPoint ? mountPoint = (mountPoint = configMountPoint.groups.mountPoint.trim()).endsWith('/') ? mountPoint : `${mountPoint}/` : defaultMountPoint;
75
+ }));
76
+ return void 0 === parsedMountPoint ? defaultMountPoint : mountPoint = (mountPoint = parsedMountPoint).endsWith('/') ? mountPoint : `${mountPoint}/`;
69
77
  }), powerShellPathFromWsl = async ()=>{
70
78
  let mountPoint = await wslDrivesMountPoint();
71
79
  return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
@@ -120,8 +128,8 @@ async function defaultBrowserId() {
120
128
  'read',
121
129
  'com.apple.LaunchServices/com.apple.launchservices.secure',
122
130
  'LSHandlers'
123
- ]), match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
124
- return match?.groups.id ?? 'com.apple.Safari';
131
+ ]), match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout), browserId = match?.groups.id ?? 'com.apple.Safari';
132
+ return 'com.apple.safari' === browserId ? 'com.apple.Safari' : browserId;
125
133
  }
126
134
  let run_applescript_execFileAsync = external_node_util_promisify(execFile);
127
135
  async function runAppleScript(script, { humanReadableOutput = !0, signal } = {}) {
@@ -1,4 +1,4 @@
1
- /*! For license information please see 0~range-parser.js.LICENSE.txt */
1
+ /*! For license information please see range-parser.js.LICENSE.txt */
2
2
  import { __webpack_require__ } from "./rslib-runtime.js";
3
3
  __webpack_require__.add({
4
4
  "../../node_modules/.pnpm/range-parser@1.2.1/node_modules/range-parser/index.js" (module) {
@@ -0,0 +1,196 @@
1
+ import { decodedMappings as trace_mapping_decodedMappings, sourcemap_codec_encode, traceSegment, TraceMap as trace_mapping_TraceMap } from "./31.js";
2
+ var SetArray = class {
3
+ constructor(){
4
+ this._indexes = {
5
+ __proto__: null
6
+ }, this.array = [];
7
+ }
8
+ };
9
+ function put(setarr, key) {
10
+ var setarr1, key1;
11
+ let index = (setarr1 = setarr, key1 = key, setarr1._indexes[key1]);
12
+ if (void 0 !== index) return index;
13
+ let { array, _indexes: indexes } = setarr, length = array.push(key);
14
+ return indexes[key] = length - 1;
15
+ }
16
+ function remove(setarr, key) {
17
+ var setarr1, key1;
18
+ let index = (setarr1 = setarr, key1 = key, setarr1._indexes[key1]);
19
+ if (void 0 === index) return;
20
+ let { array, _indexes: indexes } = setarr;
21
+ for(let i = index + 1; i < array.length; i++){
22
+ let k = array[i];
23
+ array[i - 1] = k, indexes[k]--;
24
+ }
25
+ indexes[key] = void 0, array.pop();
26
+ }
27
+ var GenMapping = class {
28
+ constructor({ file, sourceRoot } = {}){
29
+ this._names = new SetArray(), this._sources = new SetArray(), this._sourcesContent = [], this._mappings = [], this.file = file, this.sourceRoot = sourceRoot, this._ignoreList = new SetArray();
30
+ }
31
+ }, maybeAddSegment = (map, genLine, genColumn, source, sourceLine, sourceColumn, name, content)=>addSegmentInternal(!0, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content);
32
+ function setSourceContent(map, source, content) {
33
+ let { _sources: sources, _sourcesContent: sourcesContent } = map;
34
+ sourcesContent[put(sources, source)] = content;
35
+ }
36
+ function setIgnore(map, source, ignore = !0) {
37
+ let { _sources: sources, _sourcesContent: sourcesContent, _ignoreList: ignoreList } = map, index = put(sources, source);
38
+ index === sourcesContent.length && (sourcesContent[index] = null), ignore ? put(ignoreList, index) : remove(ignoreList, index);
39
+ }
40
+ function toDecodedMap(map) {
41
+ let { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, _ignoreList: ignoreList } = map;
42
+ return removeEmptyFinalLines(mappings), {
43
+ version: 3,
44
+ file: map.file || void 0,
45
+ names: names.array,
46
+ sourceRoot: map.sourceRoot || void 0,
47
+ sources: sources.array,
48
+ sourcesContent,
49
+ mappings,
50
+ ignoreList: ignoreList.array
51
+ };
52
+ }
53
+ function toEncodedMap(map) {
54
+ let decoded = toDecodedMap(map);
55
+ return Object.assign({}, decoded, {
56
+ mappings: sourcemap_codec_encode(decoded.mappings)
57
+ });
58
+ }
59
+ function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
60
+ let { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names } = map, line = getIndex(mappings, genLine), index = getColumnIndex(line, genColumn);
61
+ if (!source) {
62
+ if (skipable && skipSourceless(line, index)) return;
63
+ return insert(line, index, [
64
+ genColumn
65
+ ]);
66
+ }
67
+ let sourcesIndex = put(sources, source), namesIndex = name ? put(names, name) : -1;
68
+ if (sourcesIndex === sourcesContent.length && (sourcesContent[sourcesIndex] = null != content ? content : null), !(skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex))) return insert(line, index, name ? [
69
+ genColumn,
70
+ sourcesIndex,
71
+ sourceLine,
72
+ sourceColumn,
73
+ namesIndex
74
+ ] : [
75
+ genColumn,
76
+ sourcesIndex,
77
+ sourceLine,
78
+ sourceColumn
79
+ ]);
80
+ }
81
+ function getIndex(arr, index) {
82
+ for(let i = arr.length; i <= index; i++)arr[i] = [];
83
+ return arr[index];
84
+ }
85
+ function getColumnIndex(line, genColumn) {
86
+ let index = line.length;
87
+ for(let i = index - 1; i >= 0 && !(genColumn >= line[i][0]); index = i--);
88
+ return index;
89
+ }
90
+ function insert(array, index, value) {
91
+ for(let i = array.length; i > index; i--)array[i] = array[i - 1];
92
+ array[index] = value;
93
+ }
94
+ function removeEmptyFinalLines(mappings) {
95
+ let { length } = mappings, len = length;
96
+ for(let i = len - 1; i >= 0 && !(mappings[i].length > 0); len = i, i--);
97
+ len < length && (mappings.length = len);
98
+ }
99
+ function skipSourceless(line, index) {
100
+ return 0 === index || 1 === line[index - 1].length;
101
+ }
102
+ function skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex) {
103
+ if (0 === index) return !1;
104
+ let prev = line[index - 1];
105
+ return 1 !== prev.length && sourcesIndex === prev[1] && sourceLine === prev[2] && sourceColumn === prev[3] && namesIndex === (5 === prev.length ? prev[4] : -1);
106
+ }
107
+ var SOURCELESS_MAPPING = SegmentObject("", -1, -1, "", null, !1), EMPTY_SOURCES = [];
108
+ function SegmentObject(source, line, column, name, content, ignore) {
109
+ return {
110
+ source,
111
+ line,
112
+ column,
113
+ name,
114
+ content,
115
+ ignore
116
+ };
117
+ }
118
+ function Source(map, sources, source, content, ignore) {
119
+ return {
120
+ map,
121
+ sources,
122
+ source,
123
+ content,
124
+ ignore
125
+ };
126
+ }
127
+ function MapSource(map, sources) {
128
+ return Source(map, sources, "", null, !1);
129
+ }
130
+ function OriginalSource(source, content, ignore) {
131
+ return Source(null, EMPTY_SOURCES, source, content, ignore);
132
+ }
133
+ function traceMappings(tree) {
134
+ let gen = new GenMapping({
135
+ file: tree.map.file
136
+ }), { sources: rootSources, map } = tree, rootNames = map.names, rootMappings = trace_mapping_decodedMappings(map);
137
+ for(let i = 0; i < rootMappings.length; i++){
138
+ let segments = rootMappings[i];
139
+ for(let j = 0; j < segments.length; j++){
140
+ let segment = segments[j], genCol = segment[0], traced = SOURCELESS_MAPPING;
141
+ if (1 !== segment.length && null == (traced = originalPositionFor(rootSources[segment[1]], segment[2], segment[3], 5 === segment.length ? rootNames[segment[4]] : ""))) continue;
142
+ let { column, line, name, content, source, ignore } = traced;
143
+ maybeAddSegment(gen, i, genCol, source, line, column, name), source && null != content && setSourceContent(gen, source, content), ignore && setIgnore(gen, source, !0);
144
+ }
145
+ }
146
+ return gen;
147
+ }
148
+ function originalPositionFor(source, line, column, name) {
149
+ if (!source.map) return SegmentObject(source.source, line, column, name, source.content, source.ignore);
150
+ let segment = traceSegment(source.map, line, column);
151
+ return null == segment ? null : 1 === segment.length ? SOURCELESS_MAPPING : originalPositionFor(source.sources[segment[1]], segment[2], segment[3], 5 === segment.length ? source.map.names[segment[4]] : name);
152
+ }
153
+ function asArray(value) {
154
+ return Array.isArray(value) ? value : [
155
+ value
156
+ ];
157
+ }
158
+ function buildSourceMapTree(input, loader) {
159
+ let maps = asArray(input).map((m)=>new trace_mapping_TraceMap(m, "")), map = maps.pop();
160
+ for(let i = 0; i < maps.length; i++)if (maps[i].sources.length > 1) throw Error(`Transformation map ${i} must have exactly one source file.
161
+ Did you specify these with the most recent transformation maps first?`);
162
+ let tree = build(map, loader, "", 0);
163
+ for(let i = maps.length - 1; i >= 0; i--)tree = MapSource(maps[i], [
164
+ tree
165
+ ]);
166
+ return tree;
167
+ }
168
+ function build(map, loader, importer, importerDepth) {
169
+ let { resolvedSources, sourcesContent, ignoreList } = map, depth = importerDepth + 1;
170
+ return MapSource(map, resolvedSources.map((sourceFile, i)=>{
171
+ let ctx = {
172
+ importer,
173
+ depth,
174
+ source: sourceFile || "",
175
+ content: void 0,
176
+ ignore: void 0
177
+ }, sourceMap = loader(ctx.source, ctx), { source, content, ignore } = ctx;
178
+ return sourceMap ? build(new trace_mapping_TraceMap(sourceMap, source), loader, source, depth) : OriginalSource(source, void 0 !== content ? content : sourcesContent ? sourcesContent[i] : null, void 0 !== ignore ? ignore : !!ignoreList && ignoreList.includes(i));
179
+ }));
180
+ }
181
+ var SourceMap = class {
182
+ constructor(map, options){
183
+ let out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map);
184
+ this.version = out.version, this.file = out.file, this.mappings = out.mappings, this.names = out.names, this.ignoreList = out.ignoreList, this.sourceRoot = out.sourceRoot, this.sources = out.sources, options.excludeContent || (this.sourcesContent = out.sourcesContent);
185
+ }
186
+ toString() {
187
+ return JSON.stringify(this);
188
+ }
189
+ };
190
+ function remapping(input, loader, options) {
191
+ return new SourceMap(traceMappings(buildSourceMapTree(input, loader)), "object" == typeof options ? options : {
192
+ excludeContent: !!options,
193
+ decodedMappings: !1
194
+ });
195
+ }
196
+ export { remapping };
package/dist/sirv.js ADDED
@@ -0,0 +1,122 @@
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import { parse } from "node:querystring";
3
+ import "./131.js";
4
+ import { lookup as mrmime_lookup } from "./710.js";
5
+ let external_path_ = __webpack_require__("path"), external_fs_ = __webpack_require__("fs");
6
+ function totalist(dir, callback, pre = '') {
7
+ dir = (0, external_path_.resolve)('.', dir);
8
+ let arr = (0, external_fs_.readdirSync)(dir), i = 0, abs, stats;
9
+ for(; i < arr.length; i++)abs = (0, external_path_.join)(dir, arr[i]), (stats = (0, external_fs_.statSync)(abs)).isDirectory() ? totalist(abs, callback, (0, external_path_.join)(pre, arr[i])) : callback((0, external_path_.join)(pre, arr[i]), abs, stats);
10
+ }
11
+ function build_parse(req) {
12
+ let raw = req.url;
13
+ if (null == raw) return;
14
+ let prev = req._parsedUrl;
15
+ if (prev && prev.raw === raw) return prev;
16
+ let pathname = raw, search = '', query, hash;
17
+ if (raw.length > 1) {
18
+ let idx = raw.indexOf('#', 1);
19
+ -1 !== idx && (hash = raw.substring(idx), pathname = raw.substring(0, idx)), -1 !== (idx = pathname.indexOf('?', 1)) && (search = pathname.substring(idx), pathname = pathname.substring(0, idx), search.length > 1 && (query = parse(search.substring(1))));
20
+ }
21
+ return req._parsedUrl = {
22
+ pathname,
23
+ search,
24
+ query,
25
+ hash,
26
+ raw
27
+ };
28
+ }
29
+ let external_node_fs_ = __webpack_require__("node:fs"), external_node_path_ = __webpack_require__("node:path"), noop = ()=>{};
30
+ function isMatch(uri, arr) {
31
+ for(let i = 0; i < arr.length; i++)if (arr[i].test(uri)) return !0;
32
+ }
33
+ function toAssume(uri, extns) {
34
+ let i = 0, x, len = uri.length - 1;
35
+ 47 === uri.charCodeAt(len) && (uri = uri.substring(0, len));
36
+ let arr = [], tmp = `${uri}/index`;
37
+ for(; i < extns.length; i++)x = extns[i] ? `.${extns[i]}` : '', uri && arr.push(uri + x), arr.push(tmp + x);
38
+ return arr;
39
+ }
40
+ function viaCache(cache, uri, extns) {
41
+ let i = 0, data, arr = toAssume(uri, extns);
42
+ for(; i < arr.length; i++)if (data = cache[arr[i]]) return data;
43
+ }
44
+ function viaLocal(dir, isEtag, uri, extns) {
45
+ let abs, stats, name, headers, i = 0, arr = toAssume(uri, extns);
46
+ for(; i < arr.length; i++)if ((abs = (0, external_node_path_.normalize)((0, external_node_path_.join)(dir, name = arr[i]))).startsWith(dir) && external_node_fs_.existsSync(abs)) {
47
+ if ((stats = external_node_fs_.statSync(abs)).isDirectory()) continue;
48
+ return (headers = toHeaders(name, stats, isEtag))['Cache-Control'] = isEtag ? 'no-cache' : 'no-store', {
49
+ abs,
50
+ stats,
51
+ headers
52
+ };
53
+ }
54
+ }
55
+ function is404(req, res) {
56
+ return res.statusCode = 404, res.end();
57
+ }
58
+ function send(req, res, file, stats, headers) {
59
+ let code = 200, tmp, opts = {};
60
+ for(let key in headers = {
61
+ ...headers
62
+ })(tmp = res.getHeader(key)) && (headers[key] = tmp);
63
+ if ((tmp = res.getHeader('content-type')) && (headers['Content-Type'] = tmp), req.headers.range) {
64
+ code = 206;
65
+ let [x, y] = req.headers.range.replace('bytes=', '').split('-'), end = opts.end = parseInt(y, 10) || stats.size - 1, start = opts.start = parseInt(x, 10) || 0;
66
+ if (end >= stats.size && (end = stats.size - 1), start >= stats.size) return res.setHeader('Content-Range', `bytes */${stats.size}`), res.statusCode = 416, res.end();
67
+ headers['Content-Range'] = `bytes ${start}-${end}/${stats.size}`, headers['Content-Length'] = end - start + 1, headers['Accept-Ranges'] = 'bytes';
68
+ }
69
+ res.writeHead(code, headers), external_node_fs_.createReadStream(file, opts).pipe(res);
70
+ }
71
+ let ENCODING = {
72
+ '.br': 'br',
73
+ '.gz': 'gzip'
74
+ };
75
+ function toHeaders(name, stats, isEtag) {
76
+ let enc = ENCODING[name.slice(-3)], ctype = mrmime_lookup(name.slice(0, enc && -3)) || '';
77
+ 'text/html' === ctype && (ctype += ';charset=utf-8');
78
+ let headers = {
79
+ 'Content-Length': stats.size,
80
+ 'Content-Type': ctype,
81
+ 'Last-Modified': stats.mtime.toUTCString()
82
+ };
83
+ return enc && (headers['Content-Encoding'] = enc), isEtag && (headers.ETag = `W/"${stats.size}-${stats.mtime.getTime()}"`), headers;
84
+ }
85
+ function build(dir, opts = {}) {
86
+ dir = (0, external_node_path_.resolve)(dir || '.');
87
+ let isNotFound = opts.onNoMatch || is404, setHeaders = opts.setHeaders || noop, extensions = opts.extensions || [
88
+ 'html',
89
+ 'htm'
90
+ ], gzips = opts.gzip && extensions.map((x)=>`${x}.gz`).concat('gz'), brots = opts.brotli && extensions.map((x)=>`${x}.br`).concat('br'), FILES = {}, fallback = '/', isEtag = !!opts.etag, isSPA = !!opts.single;
91
+ if ('string' == typeof opts.single) {
92
+ let idx = opts.single.lastIndexOf('.');
93
+ fallback += ~idx ? opts.single.substring(0, idx) : opts.single;
94
+ }
95
+ let ignores = [];
96
+ !1 !== opts.ignores && (ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/), opts.dotfiles ? ignores.push(/\/\.\w/) : ignores.push(/\/\.well-known/), [].concat(opts.ignores || []).forEach((x)=>{
97
+ ignores.push(RegExp(x, 'i'));
98
+ }));
99
+ let cc = null != opts.maxAge && `public,max-age=${opts.maxAge}`;
100
+ cc && opts.immutable ? cc += ',immutable' : cc && 0 === opts.maxAge && (cc += ',must-revalidate'), opts.dev || totalist(dir, (name, abs, stats)=>{
101
+ if (/\.well-known[\\+\/]/.test(name)) ;
102
+ else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name)) return;
103
+ let headers = toHeaders(name, stats, isEtag);
104
+ cc && (headers['Cache-Control'] = cc), FILES['/' + name.normalize().replace(/\\+/g, '/')] = {
105
+ abs,
106
+ stats,
107
+ headers
108
+ };
109
+ });
110
+ let lookup = opts.dev ? viaLocal.bind(0, dir + external_node_path_.sep, isEtag) : viaCache.bind(0, FILES);
111
+ return function(req, res, next) {
112
+ let extns = [
113
+ ''
114
+ ], pathname = build_parse(req).pathname, val = req.headers['accept-encoding'] || '';
115
+ if (gzips && val.includes('gzip') && extns.unshift(...gzips), brots && /(br|brotli)/i.test(val) && extns.unshift(...brots), extns.push(...extensions), -1 !== pathname.indexOf('%')) try {
116
+ pathname = decodeURI(pathname);
117
+ } catch (err) {}
118
+ let data = lookup(pathname, extns) || isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns);
119
+ return data ? isEtag && req.headers['if-none-match'] === data.headers.ETag ? (res.writeHead(304), res.end()) : void ((gzips || brots) && res.setHeader('Vary', 'Accept-Encoding'), setHeaders(res, pathname, data.stats), send(req, res, data.abs, data.stats, data.headers)) : next ? next() : isNotFound(req, res);
120
+ };
121
+ }
122
+ export { build };