@rsbuild/core 1.1.0 → 1.1.2
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/compiled/chokidar/index.d.ts +318 -189
- package/compiled/chokidar/index.js +1069 -4439
- package/compiled/chokidar/license +1 -1
- package/compiled/chokidar/package.json +1 -1
- package/compiled/css-loader/index.js +46 -46
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/http-proxy-middleware/index.d.ts +4 -3
- package/compiled/postcss/index.js +120 -114
- package/compiled/postcss/package.json +1 -1
- package/compiled/postcss-load-config/index.js +10 -10
- package/compiled/postcss-loader/index.js +11 -11
- package/compiled/rsbuild-dev-middleware/index.js +64 -101
- package/compiled/rsbuild-dev-middleware/package.json +1 -1
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- 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/dist/client/hmr.js +195 -213
- package/dist/client/overlay.js +88 -90
- package/dist/ignoreCssLoader.cjs +43 -29
- package/dist/index.cjs +6931 -13749
- package/dist/index.cjs.LICENSE.txt +13 -0
- package/dist/index.js +6754 -13826
- package/dist/index.js.LICENSE.txt +13 -0
- package/dist/transformLoader.cjs +59 -51
- package/dist/transformRawLoader.cjs +78 -60
- package/dist-types/cli/init.d.ts +2 -1
- package/dist-types/config.d.ts +2 -2
- package/dist-types/configChain.d.ts +1 -1
- package/dist-types/helpers/index.d.ts +3 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/internal.d.ts +1 -13
- package/dist-types/logger.d.ts +1 -1
- package/dist-types/plugins/css.d.ts +1 -2
- package/dist-types/plugins/lazyCompilation.d.ts +1 -1
- package/dist-types/provider/createCompiler.d.ts +1 -1
- package/dist-types/provider/helpers.d.ts +12 -0
- package/dist-types/server/compilerDevMiddleware.d.ts +4 -3
- package/dist-types/server/devServer.d.ts +1 -1
- package/dist-types/server/helper.d.ts +1 -0
- package/dist-types/server/httpServer.d.ts +1 -1
- package/dist-types/server/middlewares.d.ts +2 -2
- package/dist-types/server/prodServer.d.ts +1 -1
- package/dist-types/server/restart.d.ts +4 -0
- package/dist-types/server/watchFiles.d.ts +4 -1
- package/dist-types/types/config.d.ts +20 -12
- package/dist-types/types/hooks.d.ts +1 -1
- package/dist-types/types/plugin.d.ts +2 -2
- package/dist-types/types/rsbuild.d.ts +3 -1
- package/dist-types/types/rspack.d.ts +1 -1
- package/dist-types/types/thirdParty.d.ts +1 -1
- package/package.json +15 -14
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const pico = require('./lib/picomatch');
|
|
4
|
+
const utils = require('./lib/utils');
|
|
5
|
+
|
|
6
|
+
function picomatch(glob, options, returnState = false) {
|
|
7
|
+
// default to os.platform()
|
|
8
|
+
if (options && (options.windows === null || options.windows === undefined)) {
|
|
9
|
+
// don't mutate the original options object
|
|
10
|
+
options = { ...options, windows: utils.isWindows() };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return pico(glob, options, returnState);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
Object.assign(picomatch, pico);
|
|
17
|
+
module.exports = picomatch;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Madeline Gurriarán
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, 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,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"name":"tinyglobby","author":"Superchupu","version":"0.2.10","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
package/dist/client/hmr.js
CHANGED
|
@@ -1,245 +1,227 @@
|
|
|
1
|
-
// src/client/format.ts
|
|
2
1
|
function resolveFileName(stats) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
// Get the real source file path with stats.moduleIdentifier.
|
|
3
|
+
// e.g. moduleIdentifier is "builtin:react-refresh-loader!/Users/x/src/App.jsx"
|
|
4
|
+
if (stats.moduleIdentifier) {
|
|
5
|
+
const regex = /(?:\!|^)([^!]+)$/;
|
|
6
|
+
const matched = stats.moduleIdentifier.match(regex);
|
|
7
|
+
if (matched) {
|
|
8
|
+
const fileName = matched.pop();
|
|
9
|
+
if (fileName) // add default column add lines for linking
|
|
10
|
+
return `File: ${fileName}:1:1\n`;
|
|
11
|
+
}
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
` : "";
|
|
13
|
+
// fallback to file or moduleName if moduleIdentifier parse failed
|
|
14
|
+
const file = stats.file || stats.moduleName;
|
|
15
|
+
return file ? `File: ${file}\n` : '';
|
|
17
16
|
}
|
|
18
17
|
function hintUnknownFiles(message) {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const hint = 'You may need an appropriate loader to handle this file type.';
|
|
19
|
+
if (-1 === message.indexOf(hint)) return message;
|
|
20
|
+
if (/File: .+\.s(c|a)ss/.test(message)) return message.replace(hint, 'To enable support for Sass, use "@rsbuild/plugin-sass".');
|
|
21
|
+
if (/File: .+\.less/.test(message)) return message.replace(hint, 'To enable support for Less, use "@rsbuild/plugin-less".');
|
|
22
|
+
if (/File: .+\.styl(us)?/.test(message)) return message.replace(hint, 'To enable support for Stylus, use "@rsbuild/plugin-stylus".');
|
|
21
23
|
return message;
|
|
22
|
-
}
|
|
23
|
-
if (/File: .+\.s(c|a)ss/.test(message)) {
|
|
24
|
-
return message.replace(hint, `To enable support for Sass, use "@rsbuild/plugin-sass".`);
|
|
25
|
-
}
|
|
26
|
-
if (/File: .+\.less/.test(message)) {
|
|
27
|
-
return message.replace(hint, `To enable support for Less, use "@rsbuild/plugin-less".`);
|
|
28
|
-
}
|
|
29
|
-
if (/File: .+\.styl(us)?/.test(message)) {
|
|
30
|
-
return message.replace(hint, `To enable support for Stylus, use "@rsbuild/plugin-stylus".`);
|
|
31
|
-
}
|
|
32
|
-
return message;
|
|
33
24
|
}
|
|
25
|
+
// Cleans up Rspack error messages.
|
|
34
26
|
function formatMessage(stats, verbose) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
` :
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
message =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (!verbose && message.includes(innerError)) {
|
|
55
|
-
message = message.split(innerError)[0];
|
|
56
|
-
}
|
|
57
|
-
return message.trim();
|
|
27
|
+
let lines = [];
|
|
28
|
+
let message;
|
|
29
|
+
// Stats error object
|
|
30
|
+
if ('object' == typeof stats) {
|
|
31
|
+
const fileName = resolveFileName(stats);
|
|
32
|
+
const mainMessage = stats.message;
|
|
33
|
+
const details = verbose && stats.details ? `\nDetails: ${stats.details}\n` : '';
|
|
34
|
+
const stack = verbose && stats.stack ? `\n${stats.stack}` : '';
|
|
35
|
+
message = `${fileName}${mainMessage}${details}${stack}`;
|
|
36
|
+
} else message = stats;
|
|
37
|
+
message = hintUnknownFiles(message);
|
|
38
|
+
lines = message.split('\n');
|
|
39
|
+
// Remove duplicated newlines
|
|
40
|
+
lines = lines.filter((line, index, arr)=>0 === index || '' !== line.trim() || line.trim() !== arr[index - 1].trim());
|
|
41
|
+
// Reassemble the message
|
|
42
|
+
message = lines.join('\n');
|
|
43
|
+
const innerError = '-- inner error --';
|
|
44
|
+
if (!verbose && message.includes(innerError)) message = message.split(innerError)[0];
|
|
45
|
+
return message.trim();
|
|
58
46
|
}
|
|
59
47
|
function formatStatsMessages(stats, verbose) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
48
|
+
var _stats_errors, _stats_warnings;
|
|
49
|
+
const formattedErrors = (null === (_stats_errors = stats.errors) || void 0 === _stats_errors ? void 0 : _stats_errors.map((error)=>formatMessage(error, verbose))) || [];
|
|
50
|
+
const formattedWarnings = (null === (_stats_warnings = stats.warnings) || void 0 === _stats_warnings ? void 0 : _stats_warnings.map((warning)=>formatMessage(warning, verbose))) || [];
|
|
51
|
+
return {
|
|
52
|
+
errors: formattedErrors,
|
|
53
|
+
warnings: formattedWarnings
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const compilationId = RSBUILD_COMPILATION_NAME;
|
|
57
|
+
const config = RSBUILD_CLIENT_CONFIG;
|
|
58
|
+
function formatURL(param) {
|
|
59
|
+
let { port, protocol, hostname, pathname } = param;
|
|
60
|
+
if ('undefined' != typeof URL) {
|
|
61
|
+
const url = new URL('http://localhost');
|
|
62
|
+
url.port = String(port);
|
|
63
|
+
url.hostname = hostname;
|
|
64
|
+
url.protocol = protocol;
|
|
65
|
+
url.pathname = pathname;
|
|
66
|
+
url.searchParams.append('compilationId', compilationId);
|
|
67
|
+
return url.toString();
|
|
68
|
+
}
|
|
69
|
+
// compatible with IE11
|
|
70
|
+
const colon = -1 === protocol.indexOf(':') ? ':' : '';
|
|
71
|
+
return `${protocol}${colon}//${hostname}:${port}${pathname}`;
|
|
72
|
+
}
|
|
73
|
+
// Remember some state related to hot module replacement.
|
|
74
|
+
let isFirstCompilation = true;
|
|
75
|
+
let lastCompilationHash = null;
|
|
76
|
+
let hasCompileErrors = false;
|
|
88
77
|
function clearOutdatedErrors() {
|
|
89
|
-
|
|
90
|
-
console.clear();
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
clearOverlay = clearFn;
|
|
78
|
+
// Clean up outdated compile errors, if any.
|
|
79
|
+
if (console.clear && hasCompileErrors) console.clear();
|
|
80
|
+
}
|
|
81
|
+
let createOverlay;
|
|
82
|
+
let clearOverlay;
|
|
83
|
+
const registerOverlay = (createFn, clearFn)=>{
|
|
84
|
+
createOverlay = createFn;
|
|
85
|
+
clearOverlay = clearFn;
|
|
98
86
|
};
|
|
87
|
+
// Successful compilation.
|
|
99
88
|
function handleSuccess() {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
tryApplyUpdates();
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
clearOutdatedErrors();
|
|
90
|
+
const isHotUpdate = !isFirstCompilation;
|
|
91
|
+
isFirstCompilation = false;
|
|
92
|
+
hasCompileErrors = false;
|
|
93
|
+
// Attempt to apply hot updates or reload.
|
|
94
|
+
if (isHotUpdate) tryApplyUpdates();
|
|
95
|
+
}
|
|
96
|
+
// Compilation with warnings (e.g. ESLint).
|
|
108
97
|
function handleWarnings(warnings) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
98
|
+
clearOutdatedErrors();
|
|
99
|
+
const isHotUpdate = !isFirstCompilation;
|
|
100
|
+
isFirstCompilation = false;
|
|
101
|
+
hasCompileErrors = false;
|
|
102
|
+
const formatted = formatStatsMessages({
|
|
103
|
+
warnings,
|
|
104
|
+
errors: []
|
|
105
|
+
});
|
|
106
|
+
for(let i = 0; i < formatted.warnings.length; i++){
|
|
107
|
+
if (5 === i) {
|
|
108
|
+
console.warn('There were more warnings in other files, you can find a complete log in the terminal.');
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
console.warn(formatted.warnings[i]);
|
|
121
112
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (isHotUpdate) {
|
|
125
|
-
tryApplyUpdates();
|
|
126
|
-
}
|
|
113
|
+
// Attempt to apply hot updates or reload.
|
|
114
|
+
if (isHotUpdate) tryApplyUpdates();
|
|
127
115
|
}
|
|
116
|
+
// Compilation with errors (e.g. syntax error or missing modules).
|
|
128
117
|
function handleErrors(errors) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
console.error(error);
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
118
|
+
clearOutdatedErrors();
|
|
119
|
+
isFirstCompilation = false;
|
|
120
|
+
hasCompileErrors = true;
|
|
121
|
+
const formatted = formatStatsMessages({
|
|
122
|
+
errors,
|
|
123
|
+
warnings: []
|
|
124
|
+
});
|
|
125
|
+
// Also log them to the console.
|
|
126
|
+
for (const error of formatted.errors)console.error(error);
|
|
127
|
+
if (createOverlay) createOverlay(formatted.errors);
|
|
128
|
+
}
|
|
129
|
+
// __webpack_hash__ is the hash of the current compilation.
|
|
130
|
+
// It's a global variable injected by Rspack.
|
|
131
|
+
const isUpdateAvailable = ()=>lastCompilationHash !== __webpack_hash__;
|
|
132
|
+
// Attempt to update code on the fly, fall back to a hard reload.
|
|
144
133
|
function tryApplyUpdates() {
|
|
145
|
-
|
|
146
|
-
return;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
if (import.meta.webpackHot.status() !== "idle") {
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const handleApplyUpdates = (err, updatedModules) => {
|
|
156
|
-
const forcedReload = err || !updatedModules;
|
|
157
|
-
if (forcedReload) {
|
|
158
|
-
if (err) {
|
|
159
|
-
console.error("[HMR] Forced reload caused by: ", err);
|
|
160
|
-
}
|
|
161
|
-
reloadPage();
|
|
162
|
-
return;
|
|
134
|
+
// detect is there a newer version of this code available
|
|
135
|
+
if (!isUpdateAvailable()) return;
|
|
136
|
+
if (!import.meta.webpackHot) {
|
|
137
|
+
// HotModuleReplacementPlugin is not in Rspack configuration.
|
|
138
|
+
reloadPage();
|
|
139
|
+
return;
|
|
163
140
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
141
|
+
// Rspack disallows updates in other states.
|
|
142
|
+
if ('idle' !== import.meta.webpackHot.status()) return;
|
|
143
|
+
const handleApplyUpdates = (err, updatedModules)=>{
|
|
144
|
+
const forcedReload = err || !updatedModules;
|
|
145
|
+
if (forcedReload) {
|
|
146
|
+
if (err) console.error('[HMR] Forced reload caused by: ', err);
|
|
147
|
+
reloadPage();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (isUpdateAvailable()) // While we were updating, there was a new update! Do it again.
|
|
151
|
+
tryApplyUpdates();
|
|
152
|
+
};
|
|
153
|
+
// https://rspack.dev/api/runtime-api/module-variables#importmetawebpackhot
|
|
154
|
+
import.meta.webpackHot.check(true).then((updatedModules)=>handleApplyUpdates(null, updatedModules), (err)=>handleApplyUpdates(err, null));
|
|
155
|
+
}
|
|
156
|
+
let connection = null;
|
|
157
|
+
let reconnectCount = 0;
|
|
172
158
|
function onOpen() {
|
|
173
|
-
|
|
159
|
+
// Notify users that the HMR has successfully connected.
|
|
160
|
+
console.info('[HMR] connected.');
|
|
174
161
|
}
|
|
175
162
|
function onMessage(e) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
163
|
+
const message = JSON.parse(e.data);
|
|
164
|
+
if (message.compilationId && message.compilationId !== compilationId) return;
|
|
165
|
+
switch(message.type){
|
|
166
|
+
case 'hash':
|
|
167
|
+
// Update the last compilation hash
|
|
168
|
+
lastCompilationHash = message.data;
|
|
169
|
+
if (clearOverlay && isUpdateAvailable()) clearOverlay();
|
|
170
|
+
break;
|
|
171
|
+
case 'still-ok':
|
|
172
|
+
case 'ok':
|
|
173
|
+
handleSuccess();
|
|
174
|
+
break;
|
|
175
|
+
// Triggered when static files changed
|
|
176
|
+
case 'static-changed':
|
|
177
|
+
case 'content-changed':
|
|
178
|
+
reloadPage();
|
|
179
|
+
break;
|
|
180
|
+
case 'warnings':
|
|
181
|
+
handleWarnings(message.data);
|
|
182
|
+
break;
|
|
183
|
+
case 'errors':
|
|
184
|
+
handleErrors(message.data);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
202
187
|
}
|
|
203
188
|
function onClose() {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
189
|
+
if (reconnectCount >= config.reconnect) {
|
|
190
|
+
if (config.reconnect > 0) console.info('[HMR] Connection failure after maximum reconnect limit exceeded.');
|
|
191
|
+
return;
|
|
207
192
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
reconnectCount++;
|
|
214
|
-
setTimeout(connect, 1e3 * 1.5 ** reconnectCount);
|
|
193
|
+
console.info('[HMR] disconnected. Attempting to reconnect.');
|
|
194
|
+
removeListeners();
|
|
195
|
+
connection = null;
|
|
196
|
+
reconnectCount++;
|
|
197
|
+
setTimeout(connect, 1000 * 1.5 ** reconnectCount);
|
|
215
198
|
}
|
|
199
|
+
// Establishing a WebSocket connection with the server.
|
|
216
200
|
function connect() {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
201
|
+
const { location } = self;
|
|
202
|
+
const { host, port, path, protocol } = config;
|
|
203
|
+
const socketUrl = formatURL({
|
|
204
|
+
protocol: protocol || ('https:' === location.protocol ? 'wss' : 'ws'),
|
|
205
|
+
hostname: host || location.hostname,
|
|
206
|
+
port: port || location.port,
|
|
207
|
+
pathname: path || '/rsbuild-hmr'
|
|
208
|
+
});
|
|
209
|
+
connection = new WebSocket(socketUrl);
|
|
210
|
+
connection.addEventListener('open', onOpen);
|
|
211
|
+
// Attempt to reconnect after disconnection
|
|
212
|
+
connection.addEventListener('close', onClose);
|
|
213
|
+
// Handle messages from the server.
|
|
214
|
+
connection.addEventListener('message', onMessage);
|
|
229
215
|
}
|
|
230
216
|
function removeListeners() {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
217
|
+
if (connection) {
|
|
218
|
+
connection.removeEventListener('open', onOpen);
|
|
219
|
+
connection.removeEventListener('close', onClose);
|
|
220
|
+
connection.removeEventListener('message', onMessage);
|
|
221
|
+
}
|
|
236
222
|
}
|
|
237
223
|
function reloadPage() {
|
|
238
|
-
|
|
239
|
-
window.location.reload();
|
|
240
|
-
}
|
|
224
|
+
if (RSBUILD_DEV_LIVE_RELOAD) window.location.reload();
|
|
241
225
|
}
|
|
242
226
|
connect();
|
|
243
|
-
export {
|
|
244
|
-
registerOverlay
|
|
245
|
-
};
|
|
227
|
+
export { registerOverlay };
|