@shuvi/platform-web 1.0.62 → 1.0.63
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getAppData } from '@shuvi/platform-shared/shared';
|
|
1
2
|
let source;
|
|
2
3
|
const eventCallbacks = [];
|
|
3
4
|
let lastActivity = Date.now();
|
|
@@ -9,7 +10,8 @@ function getSocketProtocol(assetPublicPath) {
|
|
|
9
10
|
protocol = new URL(assetPublicPath).protocol;
|
|
10
11
|
}
|
|
11
12
|
catch (_) { }
|
|
12
|
-
|
|
13
|
+
// use ws by default
|
|
14
|
+
return protocol === 'https:' ? 'wss' : 'ws';
|
|
13
15
|
}
|
|
14
16
|
export function addMessageListener(cb) {
|
|
15
17
|
eventCallbacks.push(cb);
|
|
@@ -34,12 +36,17 @@ export function connectHMR(options) {
|
|
|
34
36
|
function init() {
|
|
35
37
|
if (source)
|
|
36
38
|
source.close();
|
|
37
|
-
|
|
39
|
+
let { devServer } = getAppData();
|
|
40
|
+
if (!devServer) {
|
|
41
|
+
// fallback case
|
|
42
|
+
const { hostname, port } = window.location;
|
|
43
|
+
devServer = `${hostname}:${port}`;
|
|
44
|
+
}
|
|
38
45
|
const protocol = getSocketProtocol(options.assetPublicPath);
|
|
39
46
|
const assetPublicPath = options.assetPublicPath
|
|
40
47
|
.replace(/^\/+/, '')
|
|
41
48
|
.replace(/\/+$/, '');
|
|
42
|
-
let url = `${protocol}://${
|
|
49
|
+
let url = `${protocol}://${devServer}${assetPublicPath ? `/${assetPublicPath}` : ''}`;
|
|
43
50
|
if (assetPublicPath.startsWith('http')) {
|
|
44
51
|
url = `${protocol}://${assetPublicPath.split('://')[1]}`;
|
|
45
52
|
}
|
|
@@ -68,7 +68,9 @@ class BaseRenderer {
|
|
|
68
68
|
}
|
|
69
69
|
_getInlineAppData(app, appData) {
|
|
70
70
|
const routes = app.router.routes || [];
|
|
71
|
-
const data = JSON.stringify(Object.assign(Object.assign({}, appData), { filesByRoutId: (0, generateFilesByRoutId_1.default)(resources_1.default.clientManifest, routes), publicPath: this._serverPluginContext.assetPublicPath
|
|
71
|
+
const data = JSON.stringify(Object.assign(Object.assign({}, appData), { filesByRoutId: (0, generateFilesByRoutId_1.default)(resources_1.default.clientManifest, routes), publicPath: this._serverPluginContext.assetPublicPath,
|
|
72
|
+
// process.env.DEV_SERVER is undefined in production, and the key devServer will be removed
|
|
73
|
+
devServer: process.env.DEV_SERVER }));
|
|
72
74
|
return (0, htmlTag_1.tag)('script', {
|
|
73
75
|
id: constants_1.CLIENT_APPDATA_ID,
|
|
74
76
|
type: 'application/json'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.63",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -72,15 +72,15 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@next/react-refresh-utils": "12.1.6",
|
|
75
|
-
"@shuvi/error-overlay": "1.0.
|
|
76
|
-
"@shuvi/hook": "1.0.
|
|
77
|
-
"@shuvi/platform-shared": "1.0.
|
|
78
|
-
"@shuvi/router": "1.0.
|
|
79
|
-
"@shuvi/router-react": "1.0.
|
|
80
|
-
"@shuvi/runtime": "1.0.
|
|
81
|
-
"@shuvi/shared": "1.0.
|
|
82
|
-
"@shuvi/toolpack": "1.0.
|
|
83
|
-
"@shuvi/utils": "1.0.
|
|
75
|
+
"@shuvi/error-overlay": "1.0.63",
|
|
76
|
+
"@shuvi/hook": "1.0.63",
|
|
77
|
+
"@shuvi/platform-shared": "1.0.63",
|
|
78
|
+
"@shuvi/router": "1.0.63",
|
|
79
|
+
"@shuvi/router-react": "1.0.63",
|
|
80
|
+
"@shuvi/runtime": "1.0.63",
|
|
81
|
+
"@shuvi/shared": "1.0.63",
|
|
82
|
+
"@shuvi/toolpack": "1.0.63",
|
|
83
|
+
"@shuvi/utils": "1.0.63",
|
|
84
84
|
"content-type": "1.0.4",
|
|
85
85
|
"core-js": "3.6.5",
|
|
86
86
|
"doura": "0.0.13",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"whatwg-fetch": "3.0.0"
|
|
99
99
|
},
|
|
100
100
|
"peerDependencies": {
|
|
101
|
-
"@shuvi/service": "1.0.
|
|
101
|
+
"@shuvi/service": "1.0.63"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@shuvi/service": "workspace:*",
|