@ohos-ports/rsbuild-core 1.1.14-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 +28 -0
- package/bin/rsbuild.js +20 -0
- package/compiled/chokidar/index.d.ts +345 -0
- package/compiled/chokidar/index.js +1778 -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/connect-history-api-fallback/index.d.ts +1 -0
- package/compiled/connect-history-api-fallback/index.js +149 -0
- package/compiled/connect-history-api-fallback/license +21 -0
- package/compiled/connect-history-api-fallback/package.json +1 -0
- package/compiled/cors/index.d.ts +1 -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 +8008 -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 +289 -0
- package/compiled/html-rspack-plugin/index.js +1583 -0
- package/compiled/html-rspack-plugin/license +20 -0
- package/compiled/html-rspack-plugin/loader.js +162 -0
- package/compiled/html-rspack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +318 -0
- package/compiled/http-proxy-middleware/index.js +5280 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/jiti/index.d.ts +1 -0
- package/compiled/jiti/index.js +416 -0
- package/compiled/jiti/license +21 -0
- package/compiled/jiti/package.json +1 -0
- package/compiled/launch-editor-middleware/index.d.ts +1 -0
- package/compiled/launch-editor-middleware/index.js +694 -0
- package/compiled/launch-editor-middleware/license +21 -0
- package/compiled/launch-editor-middleware/package.json +1 -0
- package/compiled/mrmime/index.d.ts +4 -0
- package/compiled/mrmime/index.js +452 -0
- package/compiled/mrmime/package.json +1 -0
- package/compiled/on-finished/index.d.ts +13 -0
- package/compiled/on-finished/index.js +197 -0
- package/compiled/on-finished/license +23 -0
- package/compiled/on-finished/package.json +1 -0
- package/compiled/open/index.d.ts +153 -0
- package/compiled/open/index.js +409 -0
- package/compiled/open/package.json +1 -0
- package/compiled/open/xdg-open +1066 -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.d.ts +1 -0
- package/compiled/postcss/index.js +5997 -0
- package/compiled/postcss/license +20 -0
- package/compiled/postcss/package.json +1 -0
- package/compiled/postcss-load-config/index.d.ts +1 -0
- package/compiled/postcss-load-config/index.js +739 -0
- package/compiled/postcss-load-config/license +20 -0
- package/compiled/postcss-load-config/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +741 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/rsbuild-dev-middleware/index.d.ts +1 -0
- package/compiled/rsbuild-dev-middleware/index.js +6158 -0
- package/compiled/rsbuild-dev-middleware/license +20 -0
- package/compiled/rsbuild-dev-middleware/package.json +1 -0
- package/compiled/rslog/index.d.ts +66 -0
- package/compiled/rslog/index.js +334 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-chain/index.d.ts +611 -0
- package/compiled/rspack-chain/index.js +1740 -0
- package/compiled/rspack-chain/license +373 -0
- package/compiled/rspack-chain/package.json +1 -0
- package/compiled/rspack-manifest-plugin/index.d.ts +44 -0
- package/compiled/rspack-manifest-plugin/index.js +394 -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 +709 -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 +25 -0
- package/compiled/tinyglobby/index.js +2749 -0
- package/compiled/tinyglobby/index1.js +17 -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 +13480 -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 +401 -0
- package/compiled/ws/index.js +3153 -0
- package/compiled/ws/license +20 -0
- package/compiled/ws/package.json +1 -0
- package/dist/client/hmr.js +143 -0
- package/dist/client/overlay.js +210 -0
- package/dist/ignoreCssLoader.mjs +4 -0
- package/dist/index.cjs +7251 -0
- package/dist/index.js +7118 -0
- package/dist/transformLoader.mjs +22 -0
- package/dist/transformRawLoader.mjs +22 -0
- package/dist-types/cli/commands.d.ts +23 -0
- package/dist-types/cli/index.d.ts +1 -0
- package/dist-types/cli/init.d.ts +7 -0
- package/dist-types/cli/prepare.d.ts +1 -0
- package/dist-types/client/hmr.d.ts +1 -0
- package/dist-types/client/overlay.d.ts +1 -0
- package/dist-types/config.d.ts +90 -0
- package/dist-types/configChain.d.ts +139 -0
- package/dist-types/constants.d.ts +37 -0
- package/dist-types/createContext.d.ts +11 -0
- package/dist-types/createRsbuild.d.ts +2 -0
- package/dist-types/helpers/format.d.ts +5 -0
- package/dist-types/helpers/fs.d.ts +13 -0
- package/dist-types/helpers/index.d.ts +47 -0
- package/dist-types/helpers/path.d.ts +11 -0
- package/dist-types/helpers/stats.d.ts +9 -0
- package/dist-types/hooks.d.ts +48 -0
- package/dist-types/index.d.ts +26 -0
- package/dist-types/initPlugins.d.ts +6 -0
- package/dist-types/internal.d.ts +6 -0
- package/dist-types/loadEnv.d.ts +50 -0
- package/dist-types/loader/ignoreCssLoader.d.ts +2 -0
- package/dist-types/loader/transformLoader.d.ts +7 -0
- package/dist-types/loader/transformRawLoader.d.ts +3 -0
- package/dist-types/logger.d.ts +4 -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 +9 -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 +3 -0
- package/dist-types/plugins/css.d.ts +3 -0
- package/dist-types/plugins/define.d.ts +2 -0
- package/dist-types/plugins/entry.d.ts +2 -0
- package/dist-types/plugins/externals.d.ts +2 -0
- package/dist-types/plugins/fileSize.d.ts +4 -0
- package/dist-types/plugins/html.d.ts +9 -0
- package/dist-types/plugins/inlineChunk.d.ts +2 -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/splitChunks.d.ts +4 -0
- package/dist-types/plugins/sri.d.ts +2 -0
- package/dist-types/plugins/swc.d.ts +7 -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 +3 -0
- package/dist-types/provider/createCompiler.d.ts +27 -0
- package/dist-types/provider/helpers.d.ts +12 -0
- package/dist-types/provider/initConfigs.d.ts +10 -0
- package/dist-types/provider/inspectConfig.d.ts +6 -0
- package/dist-types/provider/provider.d.ts +2 -0
- package/dist-types/provider/rspackConfig.d.ts +8 -0
- package/dist-types/rspack/RsbuildHtmlPlugin.d.ts +37 -0
- package/dist-types/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +29 -0
- package/dist-types/rspack/preload/helpers/determineAsValue.d.ts +22 -0
- package/dist-types/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +29 -0
- package/dist-types/rspack/preload/helpers/extractChunks.d.ts +28 -0
- package/dist-types/rspack/preload/helpers/index.d.ts +4 -0
- package/dist-types/rspack/preload/helpers/type.d.ts +13 -0
- package/dist-types/server/ansiHTML.d.ts +12 -0
- package/dist-types/server/cliShortcuts.d.ts +10 -0
- package/dist-types/server/compilerDevMiddleware.d.ts +31 -0
- package/dist-types/server/devMiddleware.d.ts +27 -0
- package/dist-types/server/devServer.d.ts +60 -0
- package/dist-types/server/environment.d.ts +8 -0
- package/dist-types/server/getDevMiddlewares.d.ts +25 -0
- package/dist-types/server/gzipMiddleware.d.ts +4 -0
- package/dist-types/server/helper.d.ts +71 -0
- package/dist-types/server/httpServer.d.ts +8 -0
- package/dist-types/server/middlewares.d.ts +34 -0
- package/dist-types/server/open.d.ts +10 -0
- package/dist-types/server/prodServer.d.ts +25 -0
- package/dist-types/server/proxy.d.ts +6 -0
- package/dist-types/server/restart.d.ts +14 -0
- package/dist-types/server/runner/asModule.d.ts +2 -0
- package/dist-types/server/runner/basic.d.ts +25 -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 +8 -0
- package/dist-types/server/runner/type.d.ts +36 -0
- package/dist-types/server/socketServer.d.ts +26 -0
- package/dist-types/server/watchFiles.d.ts +14 -0
- package/dist-types/types/config.d.ts +1309 -0
- package/dist-types/types/context.d.ts +52 -0
- package/dist-types/types/hooks.d.ts +146 -0
- package/dist-types/types/index.d.ts +8 -0
- package/dist-types/types/plugin.d.ts +329 -0
- package/dist-types/types/rsbuild.d.ts +156 -0
- package/dist-types/types/rspack.d.ts +16 -0
- package/dist-types/types/thirdParty.d.ts +176 -0
- package/dist-types/types/utils.d.ts +12 -0
- package/package.json +61 -0
- package/static/openChrome.applescript +95 -0
- package/types.d.ts +221 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>
|
|
2
|
+
Copyright (c) 2013 Arnout Kazemier and contributors
|
|
3
|
+
Copyright (c) 2016 Luigi Pinca and contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"ws","author":"Einar Otto Stangvik <einaros@gmail.com> (http://2x.io)","version":"8.18.0","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
const compilationId = RSBUILD_COMPILATION_NAME;
|
|
2
|
+
const config = RSBUILD_CLIENT_CONFIG;
|
|
3
|
+
function formatURL(param) {
|
|
4
|
+
let { port, protocol, hostname, pathname } = param;
|
|
5
|
+
if ('undefined' != typeof URL) {
|
|
6
|
+
const url = new URL('http://localhost');
|
|
7
|
+
url.port = String(port);
|
|
8
|
+
url.hostname = hostname;
|
|
9
|
+
url.protocol = protocol;
|
|
10
|
+
url.pathname = pathname;
|
|
11
|
+
url.searchParams.append('compilationId', compilationId);
|
|
12
|
+
return url.toString();
|
|
13
|
+
}
|
|
14
|
+
const colon = -1 === protocol.indexOf(':') ? ':' : '';
|
|
15
|
+
return `${protocol}${colon}//${hostname}:${port}${pathname}`;
|
|
16
|
+
}
|
|
17
|
+
let isFirstCompilation = true;
|
|
18
|
+
let lastCompilationHash = null;
|
|
19
|
+
let hasCompileErrors = false;
|
|
20
|
+
function clearOutdatedErrors() {
|
|
21
|
+
if (console.clear && hasCompileErrors) console.clear();
|
|
22
|
+
}
|
|
23
|
+
let createOverlay;
|
|
24
|
+
let clearOverlay;
|
|
25
|
+
const registerOverlay = (createFn, clearFn)=>{
|
|
26
|
+
createOverlay = createFn;
|
|
27
|
+
clearOverlay = clearFn;
|
|
28
|
+
};
|
|
29
|
+
function handleSuccess() {
|
|
30
|
+
clearOutdatedErrors();
|
|
31
|
+
const isHotUpdate = !isFirstCompilation;
|
|
32
|
+
isFirstCompilation = false;
|
|
33
|
+
hasCompileErrors = false;
|
|
34
|
+
if (isHotUpdate) tryApplyUpdates();
|
|
35
|
+
}
|
|
36
|
+
function handleWarnings(param) {
|
|
37
|
+
let { text } = param;
|
|
38
|
+
clearOutdatedErrors();
|
|
39
|
+
const isHotUpdate = !isFirstCompilation;
|
|
40
|
+
isFirstCompilation = false;
|
|
41
|
+
hasCompileErrors = false;
|
|
42
|
+
for(let i = 0; i < text.length; i++){
|
|
43
|
+
if (5 === i) {
|
|
44
|
+
console.warn('There were more warnings in other files, you can find a complete log in the terminal.');
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
console.warn(text[i]);
|
|
48
|
+
}
|
|
49
|
+
if (isHotUpdate) tryApplyUpdates();
|
|
50
|
+
}
|
|
51
|
+
function handleErrors(param) {
|
|
52
|
+
let { text, html } = param;
|
|
53
|
+
clearOutdatedErrors();
|
|
54
|
+
isFirstCompilation = false;
|
|
55
|
+
hasCompileErrors = true;
|
|
56
|
+
for (const error of text)console.error(error);
|
|
57
|
+
if (createOverlay) createOverlay(html);
|
|
58
|
+
}
|
|
59
|
+
const isUpdateAvailable = ()=>lastCompilationHash !== __webpack_hash__;
|
|
60
|
+
function tryApplyUpdates() {
|
|
61
|
+
if (!isUpdateAvailable()) return;
|
|
62
|
+
if (!import.meta.webpackHot) {
|
|
63
|
+
reloadPage();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if ('idle' !== import.meta.webpackHot.status()) return;
|
|
67
|
+
const handleApplyUpdates = (err, updatedModules)=>{
|
|
68
|
+
const forcedReload = err || !updatedModules;
|
|
69
|
+
if (forcedReload) {
|
|
70
|
+
if (err) console.error('[HMR] Forced reload caused by: ', err);
|
|
71
|
+
reloadPage();
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (isUpdateAvailable()) tryApplyUpdates();
|
|
75
|
+
};
|
|
76
|
+
import.meta.webpackHot.check(true).then((updatedModules)=>handleApplyUpdates(null, updatedModules), (err)=>handleApplyUpdates(err, null));
|
|
77
|
+
}
|
|
78
|
+
let connection = null;
|
|
79
|
+
let reconnectCount = 0;
|
|
80
|
+
function onOpen() {
|
|
81
|
+
console.info('[HMR] connected.');
|
|
82
|
+
}
|
|
83
|
+
function onMessage(e) {
|
|
84
|
+
const message = JSON.parse(e.data);
|
|
85
|
+
if (message.compilationId && message.compilationId !== compilationId) return;
|
|
86
|
+
switch(message.type){
|
|
87
|
+
case 'hash':
|
|
88
|
+
lastCompilationHash = message.data;
|
|
89
|
+
if (clearOverlay && isUpdateAvailable()) clearOverlay();
|
|
90
|
+
break;
|
|
91
|
+
case 'still-ok':
|
|
92
|
+
case 'ok':
|
|
93
|
+
handleSuccess();
|
|
94
|
+
break;
|
|
95
|
+
case 'static-changed':
|
|
96
|
+
case 'content-changed':
|
|
97
|
+
reloadPage();
|
|
98
|
+
break;
|
|
99
|
+
case 'warnings':
|
|
100
|
+
handleWarnings(message.data);
|
|
101
|
+
break;
|
|
102
|
+
case 'errors':
|
|
103
|
+
handleErrors(message.data);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function onClose() {
|
|
108
|
+
if (reconnectCount >= config.reconnect) {
|
|
109
|
+
if (config.reconnect > 0) console.info('[HMR] Connection failure after maximum reconnect limit exceeded.');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
console.info('[HMR] disconnected. Attempting to reconnect.');
|
|
113
|
+
removeListeners();
|
|
114
|
+
connection = null;
|
|
115
|
+
reconnectCount++;
|
|
116
|
+
setTimeout(connect, 1000 * 1.5 ** reconnectCount);
|
|
117
|
+
}
|
|
118
|
+
function connect() {
|
|
119
|
+
const { location } = self;
|
|
120
|
+
const { host, port, path, protocol } = config;
|
|
121
|
+
const socketUrl = formatURL({
|
|
122
|
+
protocol: protocol || ('https:' === location.protocol ? 'wss' : 'ws'),
|
|
123
|
+
hostname: host || location.hostname,
|
|
124
|
+
port: port || location.port,
|
|
125
|
+
pathname: path || '/rsbuild-hmr'
|
|
126
|
+
});
|
|
127
|
+
connection = new WebSocket(socketUrl);
|
|
128
|
+
connection.addEventListener('open', onOpen);
|
|
129
|
+
connection.addEventListener('close', onClose);
|
|
130
|
+
connection.addEventListener('message', onMessage);
|
|
131
|
+
}
|
|
132
|
+
function removeListeners() {
|
|
133
|
+
if (connection) {
|
|
134
|
+
connection.removeEventListener('open', onOpen);
|
|
135
|
+
connection.removeEventListener('close', onClose);
|
|
136
|
+
connection.removeEventListener('message', onMessage);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function reloadPage() {
|
|
140
|
+
if (RSBUILD_DEV_LIVE_RELOAD) window.location.reload();
|
|
141
|
+
}
|
|
142
|
+
connect();
|
|
143
|
+
export { registerOverlay };
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import * as __WEBPACK_EXTERNAL_MODULE__hmr__ from "./hmr";
|
|
2
|
+
function _define_property(obj, key, value) {
|
|
3
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
else obj[key] = value;
|
|
10
|
+
return obj;
|
|
11
|
+
}
|
|
12
|
+
function linkedText(root, selector, text) {
|
|
13
|
+
const el = root.querySelector(selector);
|
|
14
|
+
const fileRegex = /(?:[a-zA-Z]:\\|\/).*?:\d+:\d+/g;
|
|
15
|
+
let curIndex = 0;
|
|
16
|
+
let match = fileRegex.exec(text);
|
|
17
|
+
while(null !== match){
|
|
18
|
+
const { 0: file, index } = match;
|
|
19
|
+
if (null != index) {
|
|
20
|
+
const frag = text.slice(curIndex, index);
|
|
21
|
+
el.insertAdjacentHTML('beforeend', frag);
|
|
22
|
+
const link = document.createElement('a');
|
|
23
|
+
link.textContent = file;
|
|
24
|
+
link.className = 'file-link';
|
|
25
|
+
link.onclick = ()=>{
|
|
26
|
+
fetch(`/__open-in-editor?file=${encodeURIComponent(file)}`);
|
|
27
|
+
};
|
|
28
|
+
el.appendChild(link);
|
|
29
|
+
curIndex += frag.length + file.length;
|
|
30
|
+
}
|
|
31
|
+
match = fileRegex.exec(text);
|
|
32
|
+
}
|
|
33
|
+
const frag = text.slice(curIndex);
|
|
34
|
+
el.insertAdjacentHTML('beforeend', frag);
|
|
35
|
+
}
|
|
36
|
+
const overlayTemplate = `
|
|
37
|
+
<style>
|
|
38
|
+
.root {
|
|
39
|
+
position: fixed;
|
|
40
|
+
z-index: 9999;
|
|
41
|
+
top: 0;
|
|
42
|
+
left: 0;
|
|
43
|
+
width: 100%;
|
|
44
|
+
height: 100%;
|
|
45
|
+
overflow-y: scroll;
|
|
46
|
+
margin: 0;
|
|
47
|
+
background: rgba(0, 0, 0, 0.66);
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
}
|
|
50
|
+
.container {
|
|
51
|
+
font-family: Menlo, Consolas, monospace;
|
|
52
|
+
line-height: 1.6;
|
|
53
|
+
width: 960px;
|
|
54
|
+
max-width: 85%;
|
|
55
|
+
color: #d8d8d8;
|
|
56
|
+
margin: 32px auto;
|
|
57
|
+
padding: 32px 40px;
|
|
58
|
+
position: relative;
|
|
59
|
+
background: #181818;
|
|
60
|
+
border-radius: 24px;
|
|
61
|
+
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
direction: ltr;
|
|
64
|
+
text-align: left;
|
|
65
|
+
box-sizing: border-box;
|
|
66
|
+
cursor: default;
|
|
67
|
+
}
|
|
68
|
+
.title {
|
|
69
|
+
margin: 0 0 20px;
|
|
70
|
+
padding-bottom: 12px;
|
|
71
|
+
font-size: 17px;
|
|
72
|
+
font-weight: 600;
|
|
73
|
+
color: #fb6a6a;
|
|
74
|
+
border-bottom: 2px solid rgba(252,94,94,.66);
|
|
75
|
+
}
|
|
76
|
+
.content {
|
|
77
|
+
margin: 0;
|
|
78
|
+
font-size: 14px;
|
|
79
|
+
font-family: inherit;
|
|
80
|
+
overflow-x: scroll;
|
|
81
|
+
scrollbar-width: none;
|
|
82
|
+
}
|
|
83
|
+
.content::-webkit-scrollbar {
|
|
84
|
+
display: none;
|
|
85
|
+
}
|
|
86
|
+
.file-link {
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
color: #6eecf7;
|
|
89
|
+
text-decoration: underline;
|
|
90
|
+
text-underline-offset: 3px;
|
|
91
|
+
&:hover {
|
|
92
|
+
opacity: 0.8;
|
|
93
|
+
}
|
|
94
|
+
&:active {
|
|
95
|
+
opacity: 0.6;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
.close {
|
|
99
|
+
position: absolute;
|
|
100
|
+
top: 27px;
|
|
101
|
+
right: 32px;
|
|
102
|
+
width: 32px;
|
|
103
|
+
height: 32px;
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
}
|
|
106
|
+
.close:hover {
|
|
107
|
+
opacity: 0.8;
|
|
108
|
+
}
|
|
109
|
+
.close:active {
|
|
110
|
+
opacity: 0.6;
|
|
111
|
+
}
|
|
112
|
+
.close:before,
|
|
113
|
+
.close:after {
|
|
114
|
+
position: absolute;
|
|
115
|
+
left: 16px;
|
|
116
|
+
top: 8px;
|
|
117
|
+
content: ' ';
|
|
118
|
+
height: 18px;
|
|
119
|
+
width: 2px;
|
|
120
|
+
border-radius: 4px;
|
|
121
|
+
background-color: #b8b8b8;
|
|
122
|
+
}
|
|
123
|
+
.close:before {
|
|
124
|
+
transform: rotate(45deg);
|
|
125
|
+
}
|
|
126
|
+
.close:after {
|
|
127
|
+
transform: rotate(-45deg);
|
|
128
|
+
}
|
|
129
|
+
.footer {
|
|
130
|
+
font-size: 12px;
|
|
131
|
+
color: #7e6a92;
|
|
132
|
+
margin-top: 20px;
|
|
133
|
+
padding-top: 12px;
|
|
134
|
+
border-top: 2px solid rgba(126,106,146,.6);
|
|
135
|
+
}
|
|
136
|
+
.footer p {
|
|
137
|
+
margin: 4px 0 0;
|
|
138
|
+
}
|
|
139
|
+
.footer span {
|
|
140
|
+
color: #a88dc3;
|
|
141
|
+
}
|
|
142
|
+
</style>
|
|
143
|
+
|
|
144
|
+
<div class="root">
|
|
145
|
+
<div class="container">
|
|
146
|
+
<div class="close"></div>
|
|
147
|
+
<p class="title">Build failed</p>
|
|
148
|
+
<pre class="content"></pre>
|
|
149
|
+
<footer class="footer">
|
|
150
|
+
<p><span>Fix error</span>, click outside, or press Esc to close the overlay.</p>
|
|
151
|
+
<p>Disable overlay by setting Rsbuild's <span>dev.client.overlay</span> config to false.<p>
|
|
152
|
+
</footer>
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
`;
|
|
156
|
+
const { HTMLElement = class {
|
|
157
|
+
}, customElements } = 'undefined' != typeof window ? window : globalThis;
|
|
158
|
+
class ErrorOverlay extends HTMLElement {
|
|
159
|
+
constructor(message){
|
|
160
|
+
var _root_querySelector;
|
|
161
|
+
super(), _define_property(this, "close", ()=>{
|
|
162
|
+
const remove = ()=>{
|
|
163
|
+
var _this_parentNode;
|
|
164
|
+
return null === (_this_parentNode = this.parentNode) || void 0 === _this_parentNode ? void 0 : _this_parentNode.removeChild(this);
|
|
165
|
+
};
|
|
166
|
+
if (this.animate) this.animate([
|
|
167
|
+
{
|
|
168
|
+
opacity: 1
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
opacity: 0
|
|
172
|
+
}
|
|
173
|
+
], {
|
|
174
|
+
duration: 300,
|
|
175
|
+
easing: 'ease-out'
|
|
176
|
+
}).addEventListener('finish', remove);
|
|
177
|
+
else remove();
|
|
178
|
+
});
|
|
179
|
+
if (!this.attachShadow) {
|
|
180
|
+
console.warn('[Rsbuild] Current browser version does not support displaying error overlay');
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const root = this.attachShadow({
|
|
184
|
+
mode: 'open'
|
|
185
|
+
});
|
|
186
|
+
root.innerHTML = overlayTemplate;
|
|
187
|
+
linkedText(root, '.content', message.join('\n\n').trim());
|
|
188
|
+
null === (_root_querySelector = root.querySelector('.close')) || void 0 === _root_querySelector || _root_querySelector.addEventListener('click', this.close);
|
|
189
|
+
this.addEventListener('click', this.close);
|
|
190
|
+
root.querySelector('.container').addEventListener('click', (e)=>{
|
|
191
|
+
e.stopPropagation();
|
|
192
|
+
});
|
|
193
|
+
const onEscKeydown = (e)=>{
|
|
194
|
+
if ('Escape' === e.key || 'Escape' === e.code) this.close();
|
|
195
|
+
document.removeEventListener('keydown', onEscKeydown);
|
|
196
|
+
};
|
|
197
|
+
document.addEventListener('keydown', onEscKeydown);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
const overlayId = 'rsbuild-error-overlay';
|
|
201
|
+
if (customElements && !customElements.get(overlayId)) customElements.define(overlayId, ErrorOverlay);
|
|
202
|
+
function createOverlay(err) {
|
|
203
|
+
clearOverlay();
|
|
204
|
+
document.body.appendChild(new ErrorOverlay(err));
|
|
205
|
+
}
|
|
206
|
+
function clearOverlay() {
|
|
207
|
+
document.querySelectorAll(overlayId).forEach((n)=>n.close());
|
|
208
|
+
}
|
|
209
|
+
if ('undefined' != typeof document) (0, __WEBPACK_EXTERNAL_MODULE__hmr__.registerOverlay)(createOverlay, clearOverlay);
|
|
210
|
+
else console.info('[Rsbuild] Failed to display error overlay as document is not available, you can disable the `dev.client.overlay` option.');
|