@ohos-ports/rsbuild-core 1.7.2-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/bin/rsbuild.js +20 -0
- package/compiled/@jridgewell/remapping/index.d.ts +1 -0
- package/compiled/@jridgewell/remapping/index.js +1222 -0
- package/compiled/@jridgewell/remapping/license +19 -0
- package/compiled/@jridgewell/remapping/package.json +1 -0
- package/compiled/@jridgewell/trace-mapping/index.d.ts +194 -0
- package/compiled/@jridgewell/trace-mapping/index.js +1408 -0
- package/compiled/@jridgewell/trace-mapping/license +19 -0
- package/compiled/@jridgewell/trace-mapping/package.json +1 -0
- package/compiled/chokidar/index.d.ts +384 -0
- package/compiled/chokidar/index.js +1793 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/connect/index.d.ts +90 -0
- package/compiled/connect/index.js +1240 -0
- package/compiled/connect/license +25 -0
- package/compiled/connect/package.json +1 -0
- package/compiled/cors/index.d.ts +56 -0
- package/compiled/cors/index.js +371 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/api.js +85 -0
- package/compiled/css-loader/getUrl.js +26 -0
- package/compiled/css-loader/index.d.ts +1 -0
- package/compiled/css-loader/index.js +2 -0
- package/compiled/css-loader/license +20 -0
- package/compiled/css-loader/noSourceMaps.js +5 -0
- package/compiled/css-loader/package.json +1 -0
- package/compiled/css-loader/sourceMaps.js +16 -0
- package/compiled/html-rspack-plugin/default_index.ejs +9 -0
- package/compiled/html-rspack-plugin/index.d.ts +290 -0
- package/compiled/html-rspack-plugin/index.js +1602 -0
- package/compiled/html-rspack-plugin/license +20 -0
- package/compiled/html-rspack-plugin/loader.js +166 -0
- package/compiled/html-rspack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +319 -0
- package/compiled/http-proxy-middleware/index.js +5284 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/launch-editor-middleware/index.d.ts +1 -0
- package/compiled/launch-editor-middleware/index.js +719 -0
- package/compiled/launch-editor-middleware/license +21 -0
- package/compiled/launch-editor-middleware/package.json +1 -0
- package/compiled/memfs/index.d.ts +1462 -0
- package/compiled/memfs/index.js +1 -0
- package/compiled/memfs/license +201 -0
- package/compiled/memfs/package.json +1 -0
- package/compiled/mrmime/index.d.ts +4 -0
- package/compiled/mrmime/index.js +456 -0
- package/compiled/mrmime/package.json +1 -0
- package/compiled/picocolors/index.d.ts +55 -0
- package/compiled/picocolors/index.js +108 -0
- package/compiled/picocolors/license +15 -0
- package/compiled/picocolors/package.json +1 -0
- package/compiled/postcss/index.js +1 -0
- package/compiled/postcss/lib/at-rule.d.ts +140 -0
- package/compiled/postcss/lib/comment.d.ts +68 -0
- package/compiled/postcss/lib/container.d.ts +483 -0
- package/compiled/postcss/lib/css-syntax-error.d.ts +248 -0
- package/compiled/postcss/lib/declaration.d.ts +151 -0
- package/compiled/postcss/lib/document.d.ts +69 -0
- package/compiled/postcss/lib/fromJSON.d.ts +9 -0
- package/compiled/postcss/lib/input.d.ts +227 -0
- package/compiled/postcss/lib/lazy-result.d.ts +190 -0
- package/compiled/postcss/lib/list.d.ts +60 -0
- package/compiled/postcss/lib/no-work-result.d.ts +46 -0
- package/compiled/postcss/lib/node.d.ts +556 -0
- package/compiled/postcss/lib/parse.d.ts +9 -0
- package/compiled/postcss/lib/postcss.d.ts +458 -0
- package/compiled/postcss/lib/previous-map.d.ts +81 -0
- package/compiled/postcss/lib/processor.d.ts +115 -0
- package/compiled/postcss/lib/result.d.ts +205 -0
- package/compiled/postcss/lib/root.d.ts +87 -0
- package/compiled/postcss/lib/rule.d.ts +126 -0
- package/compiled/postcss/lib/source-map-js.d.ts +4 -0
- package/compiled/postcss/lib/stringifier.d.ts +46 -0
- package/compiled/postcss/lib/stringify.d.ts +9 -0
- package/compiled/postcss/lib/warning.d.ts +147 -0
- package/compiled/postcss/license +20 -0
- package/compiled/postcss/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +720 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/rslog/index.d.ts +67 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-chain/license +22 -0
- package/compiled/rspack-chain/package.json +1 -0
- package/compiled/rspack-chain/types/index.d.ts +545 -0
- package/compiled/rspack-manifest-plugin/index.d.ts +48 -0
- package/compiled/rspack-manifest-plugin/index.js +409 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/sirv/index.d.ts +1 -0
- package/compiled/sirv/index.js +274 -0
- package/compiled/sirv/package.json +1 -0
- package/compiled/style-loader/index.d.ts +1 -0
- package/compiled/style-loader/index.js +427 -0
- package/compiled/style-loader/license +20 -0
- package/compiled/style-loader/package.json +1 -0
- package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
- package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
- package/compiled/style-loader/runtime/insertBySelector.js +34 -0
- package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
- package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
- package/compiled/style-loader/runtime/isOldIE.js +17 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
- package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
- package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
- package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
- package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
- package/compiled/tinyglobby/index.d.ts +46 -0
- package/compiled/tinyglobby/index.js +2664 -0
- package/compiled/tinyglobby/license +21 -0
- package/compiled/tinyglobby/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/index.d.ts +160 -0
- package/compiled/webpack-bundle-analyzer/index.js +23 -0
- package/compiled/webpack-bundle-analyzer/license +20 -0
- package/compiled/webpack-bundle-analyzer/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
- package/compiled/webpack-merge/index.d.ts +31 -0
- package/compiled/webpack-merge/index.js +1200 -0
- package/compiled/webpack-merge/license +20 -0
- package/compiled/webpack-merge/package.json +1 -0
- package/compiled/ws/index.d.ts +437 -0
- package/compiled/ws/index.js +3161 -0
- package/compiled/ws/license +20 -0
- package/compiled/ws/package.json +1 -0
- package/dist/0~open.js +427 -0
- package/dist/0~range-parser.js +49 -0
- package/dist/0~range-parser.js.LICENSE.txt +6 -0
- package/dist/131.js +9305 -0
- package/dist/131.js.LICENSE.txt +26 -0
- package/dist/136.mjs +42 -0
- package/dist/2~open.cjs +436 -0
- package/dist/2~range-parser.cjs +52 -0
- package/dist/2~range-parser.cjs.LICENSE.txt +6 -0
- package/dist/client/59.js +22 -0
- package/dist/client/hmr.js +206 -0
- package/dist/client/overlay.js +203 -0
- package/dist/ignoreCssLoader.mjs +3 -0
- package/dist/index.cjs +9456 -0
- package/dist/index.cjs.LICENSE.txt +26 -0
- package/dist/index.js +1 -0
- package/dist/rslib-runtime.js +44 -0
- package/dist/transformLoader.mjs +1 -0
- package/dist/transformRawLoader.mjs +4 -0
- package/dist-types/cli/commands.d.ts +28 -0
- package/dist-types/cli/index.d.ts +1 -0
- package/dist-types/cli/init.d.ts +7 -0
- package/dist-types/client/hmr.d.ts +3 -0
- package/dist-types/client/log.d.ts +13 -0
- package/dist-types/client/overlay.d.ts +1 -0
- package/dist-types/configChain.d.ts +154 -0
- package/dist-types/constants.d.ts +52 -0
- package/dist-types/createContext.d.ts +11 -0
- package/dist-types/createRsbuild.d.ts +5 -0
- package/dist-types/defaultConfig.d.ts +25 -0
- package/dist-types/helpers/compiler.d.ts +5 -0
- package/dist-types/helpers/exitHook.d.ts +3 -0
- package/dist-types/helpers/format.d.ts +2 -0
- package/dist-types/helpers/fs.d.ts +17 -0
- package/dist-types/helpers/index.d.ts +29 -0
- package/dist-types/helpers/path.d.ts +26 -0
- package/dist-types/helpers/stats.d.ts +18 -0
- package/dist-types/helpers/url.d.ts +11 -0
- package/dist-types/helpers/vendors.d.ts +29 -0
- package/dist-types/helpers/version.d.ts +7 -0
- package/dist-types/hooks.d.ts +44 -0
- package/dist-types/index.d.ts +22 -0
- package/dist-types/initPlugins.d.ts +6 -0
- package/dist-types/inspectConfig.d.ts +35 -0
- package/dist-types/loadConfig.d.ts +60 -0
- package/dist-types/loadEnv.d.ts +63 -0
- package/dist-types/loader/ignoreCssLoader.d.ts +3 -0
- package/dist-types/loader/transformLoader.d.ts +8 -0
- package/dist-types/loader/transformRawLoader.d.ts +3 -0
- package/dist-types/logger.d.ts +19 -0
- package/dist-types/mergeConfig.d.ts +2 -0
- package/dist-types/package.json +1 -0
- package/dist-types/pluginHelper.d.ts +12 -0
- package/dist-types/pluginManager.d.ts +21 -0
- package/dist-types/plugins/appIcon.d.ts +2 -0
- package/dist-types/plugins/asset.d.ts +3 -0
- package/dist-types/plugins/basic.d.ts +5 -0
- package/dist-types/plugins/bundleAnalyzer.d.ts +2 -0
- package/dist-types/plugins/cache.d.ts +2 -0
- package/dist-types/plugins/cleanOutput.d.ts +2 -0
- package/dist-types/plugins/css.d.ts +4 -0
- package/dist-types/plugins/define.d.ts +2 -0
- package/dist-types/plugins/entry.d.ts +2 -0
- package/dist-types/plugins/esm.d.ts +2 -0
- package/dist-types/plugins/externals.d.ts +2 -0
- package/dist-types/plugins/fileSize.d.ts +6 -0
- package/dist-types/plugins/html.d.ts +9 -0
- package/dist-types/plugins/inlineChunk.d.ts +6 -0
- package/dist-types/plugins/lazyCompilation.d.ts +2 -0
- package/dist-types/plugins/manifest.d.ts +2 -0
- package/dist-types/plugins/minimize.d.ts +10 -0
- package/dist-types/plugins/moduleFederation.d.ts +2 -0
- package/dist-types/plugins/moment.d.ts +2 -0
- package/dist-types/plugins/nodeAddons.d.ts +2 -0
- package/dist-types/plugins/nonce.d.ts +2 -0
- package/dist-types/plugins/output.d.ts +2 -0
- package/dist-types/plugins/performance.d.ts +5 -0
- package/dist-types/plugins/progress.d.ts +2 -0
- package/dist-types/plugins/resolve.d.ts +2 -0
- package/dist-types/plugins/resourceHints.d.ts +2 -0
- package/dist-types/plugins/rsdoctor.d.ts +2 -0
- package/dist-types/plugins/rspackProfile.d.ts +2 -0
- package/dist-types/plugins/server.d.ts +2 -0
- package/dist-types/plugins/sourceMap.d.ts +2 -0
- package/dist-types/plugins/splitChunks.d.ts +4 -0
- package/dist-types/plugins/sri.d.ts +2 -0
- package/dist-types/plugins/swc.d.ts +5 -0
- package/dist-types/plugins/target.d.ts +2 -0
- package/dist-types/plugins/wasm.d.ts +2 -0
- package/dist-types/provider/build.d.ts +4 -0
- package/dist-types/provider/createCompiler.d.ts +6 -0
- package/dist-types/provider/helpers.d.ts +12 -0
- package/dist-types/provider/initConfigs.d.ts +19 -0
- package/dist-types/provider/provider.d.ts +2 -0
- package/dist-types/provider/rspackConfig.d.ts +8 -0
- package/dist-types/restart.d.ts +18 -0
- package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +38 -0
- package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +32 -0
- package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +28 -0
- package/dist-types/rspack-plugins/resource-hints/extractChunks.d.ts +23 -0
- package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +22 -0
- package/dist-types/rspack.d.ts +2 -0
- package/dist-types/server/ansiHTML.d.ts +4 -0
- package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +12 -0
- package/dist-types/server/assets-middleware/index.d.ts +37 -0
- package/dist-types/server/assets-middleware/middleware.d.ts +2 -0
- package/dist-types/server/assets-middleware/parseTokenList.d.ts +1 -0
- package/dist-types/server/assets-middleware/setupOutputFileSystem.d.ts +3 -0
- package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
- package/dist-types/server/browserLogs.d.ts +9 -0
- package/dist-types/server/buildManager.d.ts +33 -0
- package/dist-types/server/cliShortcuts.d.ts +10 -0
- package/dist-types/server/devMiddlewares.d.ts +21 -0
- package/dist-types/server/devServer.d.ts +79 -0
- package/dist-types/server/environment.d.ts +8 -0
- package/dist-types/server/gracefulShutdown.d.ts +10 -0
- package/dist-types/server/gzipMiddleware.d.ts +2 -0
- package/dist-types/server/helper.d.ts +91 -0
- package/dist-types/server/historyApiFallback.d.ts +2 -0
- package/dist-types/server/hmrFallback.d.ts +1 -0
- package/dist-types/server/httpServer.d.ts +7 -0
- package/dist-types/server/middlewares.d.ts +33 -0
- package/dist-types/server/open.d.ts +10 -0
- package/dist-types/server/overlay.d.ts +3 -0
- package/dist-types/server/prodServer.d.ts +24 -0
- package/dist-types/server/proxy.d.ts +6 -0
- package/dist-types/server/runner/asModule.d.ts +2 -0
- package/dist-types/server/runner/basic.d.ts +29 -0
- package/dist-types/server/runner/cjs.d.ts +10 -0
- package/dist-types/server/runner/esm.d.ts +6 -0
- package/dist-types/server/runner/index.d.ts +4 -0
- package/dist-types/server/runner/type.d.ts +42 -0
- package/dist-types/server/socketServer.d.ts +81 -0
- package/dist-types/server/watchFiles.d.ts +14 -0
- package/dist-types/types/config.d.ts +1882 -0
- package/dist-types/types/context.d.ts +110 -0
- package/dist-types/types/hooks.d.ts +275 -0
- package/dist-types/types/index.d.ts +8 -0
- package/dist-types/types/plugin.d.ts +585 -0
- package/dist-types/types/rsbuild.d.ts +286 -0
- package/dist-types/types/rspack.d.ts +16 -0
- package/dist-types/types/thirdParty.d.ts +186 -0
- package/dist-types/types/utils.d.ts +19 -0
- package/package.json +114 -0
- package/static/openChrome.applescript +95 -0
- package/types.d.ts +349 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
917: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
4
|
+
const qs = __nccwpck_require__(480);
|
|
5
|
+
function parse(req) {
|
|
6
|
+
let raw = req.url;
|
|
7
|
+
if (raw == null) return;
|
|
8
|
+
let prev = req._parsedUrl;
|
|
9
|
+
if (prev && prev.raw === raw) return prev;
|
|
10
|
+
let pathname = raw,
|
|
11
|
+
search = "",
|
|
12
|
+
query,
|
|
13
|
+
hash;
|
|
14
|
+
if (raw.length > 1) {
|
|
15
|
+
let idx = raw.indexOf("#", 1);
|
|
16
|
+
if (idx !== -1) {
|
|
17
|
+
hash = raw.substring(idx);
|
|
18
|
+
pathname = raw.substring(0, idx);
|
|
19
|
+
}
|
|
20
|
+
idx = pathname.indexOf("?", 1);
|
|
21
|
+
if (idx !== -1) {
|
|
22
|
+
search = pathname.substring(idx);
|
|
23
|
+
pathname = pathname.substring(0, idx);
|
|
24
|
+
if (search.length > 1) {
|
|
25
|
+
query = qs.parse(search.substring(1));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return (req._parsedUrl = { pathname, search, query, hash, raw });
|
|
30
|
+
}
|
|
31
|
+
exports.parse = parse;
|
|
32
|
+
},
|
|
33
|
+
772: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
34
|
+
const fs = __nccwpck_require__(24);
|
|
35
|
+
const { join, normalize, resolve, sep } = __nccwpck_require__(760);
|
|
36
|
+
const { totalist } = __nccwpck_require__(481);
|
|
37
|
+
const { parse } = __nccwpck_require__(917);
|
|
38
|
+
const { lookup } = __nccwpck_require__(257);
|
|
39
|
+
const noop = () => {};
|
|
40
|
+
function isMatch(uri, arr) {
|
|
41
|
+
for (let i = 0; i < arr.length; i++) {
|
|
42
|
+
if (arr[i].test(uri)) return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function toAssume(uri, extns) {
|
|
46
|
+
let i = 0,
|
|
47
|
+
x,
|
|
48
|
+
len = uri.length - 1;
|
|
49
|
+
if (uri.charCodeAt(len) === 47) {
|
|
50
|
+
uri = uri.substring(0, len);
|
|
51
|
+
}
|
|
52
|
+
let arr = [],
|
|
53
|
+
tmp = `${uri}/index`;
|
|
54
|
+
for (; i < extns.length; i++) {
|
|
55
|
+
x = extns[i] ? `.${extns[i]}` : "";
|
|
56
|
+
if (uri) arr.push(uri + x);
|
|
57
|
+
arr.push(tmp + x);
|
|
58
|
+
}
|
|
59
|
+
return arr;
|
|
60
|
+
}
|
|
61
|
+
function viaCache(cache, uri, extns) {
|
|
62
|
+
let i = 0,
|
|
63
|
+
data,
|
|
64
|
+
arr = toAssume(uri, extns);
|
|
65
|
+
for (; i < arr.length; i++) {
|
|
66
|
+
if ((data = cache[arr[i]])) return data;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function viaLocal(dir, isEtag, uri, extns) {
|
|
70
|
+
let i = 0,
|
|
71
|
+
arr = toAssume(uri, extns);
|
|
72
|
+
let abs, stats, name, headers;
|
|
73
|
+
for (; i < arr.length; i++) {
|
|
74
|
+
abs = normalize(join(dir, (name = arr[i])));
|
|
75
|
+
if (abs.startsWith(dir) && fs.existsSync(abs)) {
|
|
76
|
+
stats = fs.statSync(abs);
|
|
77
|
+
if (stats.isDirectory()) continue;
|
|
78
|
+
headers = toHeaders(name, stats, isEtag);
|
|
79
|
+
headers["Cache-Control"] = isEtag ? "no-cache" : "no-store";
|
|
80
|
+
return { abs, stats, headers };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function is404(req, res) {
|
|
85
|
+
return ((res.statusCode = 404), res.end());
|
|
86
|
+
}
|
|
87
|
+
function send(req, res, file, stats, headers) {
|
|
88
|
+
let code = 200,
|
|
89
|
+
tmp,
|
|
90
|
+
opts = {};
|
|
91
|
+
headers = { ...headers };
|
|
92
|
+
for (let key in headers) {
|
|
93
|
+
tmp = res.getHeader(key);
|
|
94
|
+
if (tmp) headers[key] = tmp;
|
|
95
|
+
}
|
|
96
|
+
if ((tmp = res.getHeader("content-type"))) {
|
|
97
|
+
headers["Content-Type"] = tmp;
|
|
98
|
+
}
|
|
99
|
+
if (req.headers.range) {
|
|
100
|
+
code = 206;
|
|
101
|
+
let [x, y] = req.headers.range.replace("bytes=", "").split("-");
|
|
102
|
+
let end = (opts.end = parseInt(y, 10) || stats.size - 1);
|
|
103
|
+
let start = (opts.start = parseInt(x, 10) || 0);
|
|
104
|
+
if (end >= stats.size) {
|
|
105
|
+
end = stats.size - 1;
|
|
106
|
+
}
|
|
107
|
+
if (start >= stats.size) {
|
|
108
|
+
res.setHeader("Content-Range", `bytes */${stats.size}`);
|
|
109
|
+
res.statusCode = 416;
|
|
110
|
+
return res.end();
|
|
111
|
+
}
|
|
112
|
+
headers["Content-Range"] = `bytes ${start}-${end}/${stats.size}`;
|
|
113
|
+
headers["Content-Length"] = end - start + 1;
|
|
114
|
+
headers["Accept-Ranges"] = "bytes";
|
|
115
|
+
}
|
|
116
|
+
res.writeHead(code, headers);
|
|
117
|
+
fs.createReadStream(file, opts).pipe(res);
|
|
118
|
+
}
|
|
119
|
+
const ENCODING = { ".br": "br", ".gz": "gzip" };
|
|
120
|
+
function toHeaders(name, stats, isEtag) {
|
|
121
|
+
let enc = ENCODING[name.slice(-3)];
|
|
122
|
+
let ctype = lookup(name.slice(0, enc && -3)) || "";
|
|
123
|
+
if (ctype === "text/html") ctype += ";charset=utf-8";
|
|
124
|
+
let headers = {
|
|
125
|
+
"Content-Length": stats.size,
|
|
126
|
+
"Content-Type": ctype,
|
|
127
|
+
"Last-Modified": stats.mtime.toUTCString(),
|
|
128
|
+
};
|
|
129
|
+
if (enc) headers["Content-Encoding"] = enc;
|
|
130
|
+
if (isEtag)
|
|
131
|
+
headers["ETag"] = `W/"${stats.size}-${stats.mtime.getTime()}"`;
|
|
132
|
+
return headers;
|
|
133
|
+
}
|
|
134
|
+
module.exports = function (dir, opts = {}) {
|
|
135
|
+
dir = resolve(dir || ".");
|
|
136
|
+
let isNotFound = opts.onNoMatch || is404;
|
|
137
|
+
let setHeaders = opts.setHeaders || noop;
|
|
138
|
+
let extensions = opts.extensions || ["html", "htm"];
|
|
139
|
+
let gzips = opts.gzip && extensions.map((x) => `${x}.gz`).concat("gz");
|
|
140
|
+
let brots =
|
|
141
|
+
opts.brotli && extensions.map((x) => `${x}.br`).concat("br");
|
|
142
|
+
const FILES = {};
|
|
143
|
+
let fallback = "/";
|
|
144
|
+
let isEtag = !!opts.etag;
|
|
145
|
+
let isSPA = !!opts.single;
|
|
146
|
+
if (typeof opts.single === "string") {
|
|
147
|
+
let idx = opts.single.lastIndexOf(".");
|
|
148
|
+
fallback += !!~idx ? opts.single.substring(0, idx) : opts.single;
|
|
149
|
+
}
|
|
150
|
+
let ignores = [];
|
|
151
|
+
if (opts.ignores !== false) {
|
|
152
|
+
ignores.push(/[/]([A-Za-z\s\d~$._-]+\.\w+){1,}$/);
|
|
153
|
+
if (opts.dotfiles) ignores.push(/\/\.\w/);
|
|
154
|
+
else ignores.push(/\/\.well-known/);
|
|
155
|
+
[].concat(opts.ignores || []).forEach((x) => {
|
|
156
|
+
ignores.push(new RegExp(x, "i"));
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`;
|
|
160
|
+
if (cc && opts.immutable) cc += ",immutable";
|
|
161
|
+
else if (cc && opts.maxAge === 0) cc += ",must-revalidate";
|
|
162
|
+
if (!opts.dev) {
|
|
163
|
+
totalist(dir, (name, abs, stats) => {
|
|
164
|
+
if (/\.well-known[\\+\/]/.test(name)) {
|
|
165
|
+
} else if (!opts.dotfiles && /(^\.|[\\+|\/+]\.)/.test(name)) return;
|
|
166
|
+
let headers = toHeaders(name, stats, isEtag);
|
|
167
|
+
if (cc) headers["Cache-Control"] = cc;
|
|
168
|
+
FILES["/" + name.normalize().replace(/\\+/g, "/")] = {
|
|
169
|
+
abs,
|
|
170
|
+
stats,
|
|
171
|
+
headers,
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
let lookup = opts.dev
|
|
176
|
+
? viaLocal.bind(0, dir + sep, isEtag)
|
|
177
|
+
: viaCache.bind(0, FILES);
|
|
178
|
+
return function (req, res, next) {
|
|
179
|
+
let extns = [""];
|
|
180
|
+
let pathname = parse(req).pathname;
|
|
181
|
+
let val = req.headers["accept-encoding"] || "";
|
|
182
|
+
if (gzips && val.includes("gzip")) extns.unshift(...gzips);
|
|
183
|
+
if (brots && /(br|brotli)/i.test(val)) extns.unshift(...brots);
|
|
184
|
+
extns.push(...extensions);
|
|
185
|
+
if (pathname.indexOf("%") !== -1) {
|
|
186
|
+
try {
|
|
187
|
+
pathname = decodeURI(pathname);
|
|
188
|
+
} catch (err) {}
|
|
189
|
+
}
|
|
190
|
+
let data =
|
|
191
|
+
lookup(pathname, extns) ||
|
|
192
|
+
(isSPA && !isMatch(pathname, ignores) && lookup(fallback, extns));
|
|
193
|
+
if (!data) return next ? next() : isNotFound(req, res);
|
|
194
|
+
if (isEtag && req.headers["if-none-match"] === data.headers["ETag"]) {
|
|
195
|
+
res.writeHead(304);
|
|
196
|
+
return res.end();
|
|
197
|
+
}
|
|
198
|
+
if (gzips || brots) {
|
|
199
|
+
res.setHeader("Vary", "Accept-Encoding");
|
|
200
|
+
}
|
|
201
|
+
setHeaders(res, pathname, data.stats);
|
|
202
|
+
send(req, res, data.abs, data.stats, data.headers);
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
},
|
|
206
|
+
481: (__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
207
|
+
const { join, resolve } = __nccwpck_require__(928);
|
|
208
|
+
const { readdirSync, statSync } = __nccwpck_require__(896);
|
|
209
|
+
function totalist(dir, callback, pre = "") {
|
|
210
|
+
dir = resolve(".", dir);
|
|
211
|
+
let arr = readdirSync(dir);
|
|
212
|
+
let i = 0,
|
|
213
|
+
abs,
|
|
214
|
+
stats;
|
|
215
|
+
for (; i < arr.length; i++) {
|
|
216
|
+
abs = join(dir, arr[i]);
|
|
217
|
+
stats = statSync(abs);
|
|
218
|
+
stats.isDirectory()
|
|
219
|
+
? totalist(abs, callback, join(pre, arr[i]))
|
|
220
|
+
: callback(join(pre, arr[i]), abs, stats);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
exports.totalist = totalist;
|
|
224
|
+
},
|
|
225
|
+
257: (module) => {
|
|
226
|
+
"use strict";
|
|
227
|
+
module.exports = require("../mrmime/index.js");
|
|
228
|
+
},
|
|
229
|
+
896: (module) => {
|
|
230
|
+
"use strict";
|
|
231
|
+
module.exports = require("fs");
|
|
232
|
+
},
|
|
233
|
+
24: (module) => {
|
|
234
|
+
"use strict";
|
|
235
|
+
module.exports = require("node:fs");
|
|
236
|
+
},
|
|
237
|
+
760: (module) => {
|
|
238
|
+
"use strict";
|
|
239
|
+
module.exports = require("node:path");
|
|
240
|
+
},
|
|
241
|
+
928: (module) => {
|
|
242
|
+
"use strict";
|
|
243
|
+
module.exports = require("path");
|
|
244
|
+
},
|
|
245
|
+
480: (module) => {
|
|
246
|
+
"use strict";
|
|
247
|
+
module.exports = require("querystring");
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
var __webpack_module_cache__ = {};
|
|
251
|
+
function __nccwpck_require__(moduleId) {
|
|
252
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
253
|
+
if (cachedModule !== undefined) {
|
|
254
|
+
return cachedModule.exports;
|
|
255
|
+
}
|
|
256
|
+
var module = (__webpack_module_cache__[moduleId] = { exports: {} });
|
|
257
|
+
var threw = true;
|
|
258
|
+
try {
|
|
259
|
+
__webpack_modules__[moduleId](
|
|
260
|
+
module,
|
|
261
|
+
module.exports,
|
|
262
|
+
__nccwpck_require__,
|
|
263
|
+
);
|
|
264
|
+
threw = false;
|
|
265
|
+
} finally {
|
|
266
|
+
if (threw) delete __webpack_module_cache__[moduleId];
|
|
267
|
+
}
|
|
268
|
+
return module.exports;
|
|
269
|
+
}
|
|
270
|
+
if (typeof __nccwpck_require__ !== "undefined")
|
|
271
|
+
__nccwpck_require__.ab = __dirname + "/";
|
|
272
|
+
var __webpack_exports__ = __nccwpck_require__(772);
|
|
273
|
+
module.exports = __webpack_exports__;
|
|
274
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"sirv","author":{"name":"Luke Edwards","email":"luke@lukeed.com","url":"https://lukeed.com"},"version":"3.0.2","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export = any;
|