@shuvi/platform-web 1.0.13 → 1.0.14
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/esm/shared/configTypes.d.ts +1 -0
- package/esm/shuvi-app/dev/hotDevClient.d.ts +1 -1
- package/esm/shuvi-app/dev/index.js +2 -1
- package/esm/shuvi-app/dev/websocket.d.ts +1 -5
- package/esm/shuvi-app/dev/websocket.js +14 -4
- package/lib/node/features/filesystem-routes/index.js +16 -4
- package/lib/shared/configTypes.d.ts +1 -0
- package/package.json +11 -11
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DEV_SOCKET_TIMEOUT_MS, DEV_HOT_MIDDLEWARE_PATH, DEV_HOT_LAUNCH_EDITOR_ENDPOINT } from '@shuvi/shared/constants';
|
|
2
|
+
import { getPublicPath } from '@shuvi/platform-shared/shared/helper/getPublicPath';
|
|
2
3
|
import connect from './hotDevClient';
|
|
3
4
|
let devClient;
|
|
4
5
|
export const initHMRAndDevClient = (app) => {
|
|
@@ -8,7 +9,7 @@ export const initHMRAndDevClient = (app) => {
|
|
|
8
9
|
devClient = connect({
|
|
9
10
|
launchEditorEndpoint: DEV_HOT_LAUNCH_EDITOR_ENDPOINT,
|
|
10
11
|
path: DEV_HOT_MIDDLEWARE_PATH,
|
|
11
|
-
|
|
12
|
+
assetPublicPath: getPublicPath()
|
|
12
13
|
});
|
|
13
14
|
setInterval(() => {
|
|
14
15
|
devClient.sendMessage(JSON.stringify({
|
|
@@ -2,7 +2,13 @@ let source;
|
|
|
2
2
|
const eventCallbacks = [];
|
|
3
3
|
let lastActivity = Date.now();
|
|
4
4
|
let initDataBeforeWsOnline = [];
|
|
5
|
-
function getSocketProtocol(
|
|
5
|
+
function getSocketProtocol(assetPublicPath) {
|
|
6
|
+
let protocol = window.location.protocol;
|
|
7
|
+
try {
|
|
8
|
+
// assetPublicPath is a url
|
|
9
|
+
protocol = new URL(assetPublicPath).protocol;
|
|
10
|
+
}
|
|
11
|
+
catch (_) { }
|
|
6
12
|
return protocol === 'http:' ? 'ws' : 'wss';
|
|
7
13
|
}
|
|
8
14
|
export function addMessageListener(cb) {
|
|
@@ -28,9 +34,13 @@ export function connectHMR(options) {
|
|
|
28
34
|
function init() {
|
|
29
35
|
if (source)
|
|
30
36
|
source.close();
|
|
31
|
-
|
|
32
|
-
protocol = getSocketProtocol(
|
|
33
|
-
|
|
37
|
+
const { hostname, port } = window.location;
|
|
38
|
+
const protocol = getSocketProtocol(options.assetPublicPath);
|
|
39
|
+
const assetPublicPath = options.assetPublicPath.replace(/^\/+/, '');
|
|
40
|
+
let url = `${protocol}://${hostname}:${port}${assetPublicPath ? `/${assetPublicPath}` : ''}`;
|
|
41
|
+
if (assetPublicPath.startsWith('http')) {
|
|
42
|
+
url = `${protocol}://${assetPublicPath.split('://')[1]}`;
|
|
43
|
+
}
|
|
34
44
|
source = new WebSocket(`${url}${options.path}`);
|
|
35
45
|
source.onopen = handleOnline;
|
|
36
46
|
source.onerror = handleDisconnect;
|
|
@@ -37,7 +37,10 @@ const plugin = (0, service_1.createPlugin)({
|
|
|
37
37
|
name: 'virtual-raw-routes.js',
|
|
38
38
|
virtual: true,
|
|
39
39
|
content: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
-
const rawRoutes = yield (0, node_1.getRawRoutesFromDir)(paths.routesDir,
|
|
40
|
+
const rawRoutes = yield (0, node_1.getRawRoutesFromDir)(paths.routesDir, {
|
|
41
|
+
includes: conventionRoutes.include,
|
|
42
|
+
excludes: conventionRoutes.exclude
|
|
43
|
+
});
|
|
41
44
|
return rawRoutes;
|
|
42
45
|
}),
|
|
43
46
|
dependencies: [paths.routesDir],
|
|
@@ -54,7 +57,10 @@ const plugin = (0, service_1.createPlugin)({
|
|
|
54
57
|
routes = pageRoutes;
|
|
55
58
|
}
|
|
56
59
|
else {
|
|
57
|
-
const { routes: _routes, warnings } = yield (0, node_1.getPageRoutes)(getContent(rawRoutes),
|
|
60
|
+
const { routes: _routes, warnings } = yield (0, node_1.getPageRoutes)(getContent(rawRoutes), {
|
|
61
|
+
includes: conventionRoutes.include,
|
|
62
|
+
excludes: conventionRoutes.exclude
|
|
63
|
+
});
|
|
58
64
|
if (isBuildPhase) {
|
|
59
65
|
warnings.forEach(warning => {
|
|
60
66
|
logger_1.default.warn(warning.msg);
|
|
@@ -77,7 +83,10 @@ const plugin = (0, service_1.createPlugin)({
|
|
|
77
83
|
const apiRoutesFile = defineFile({
|
|
78
84
|
name: 'apiRoutes.js',
|
|
79
85
|
content: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
-
const { routes: fsRoutes, warnings } = yield (0, node_1.getApiRoutes)(getContent(rawRoutes),
|
|
86
|
+
const { routes: fsRoutes, warnings } = yield (0, node_1.getApiRoutes)(getContent(rawRoutes), {
|
|
87
|
+
includes: conventionRoutes.include,
|
|
88
|
+
excludes: conventionRoutes.exclude
|
|
89
|
+
});
|
|
81
90
|
if (isBuildPhase) {
|
|
82
91
|
warnings.forEach(warning => {
|
|
83
92
|
logger_1.default.warn(warning);
|
|
@@ -94,7 +103,10 @@ const plugin = (0, service_1.createPlugin)({
|
|
|
94
103
|
// Remove the 'middleware' file convention first, and deal with it in a future major update.
|
|
95
104
|
// const { routes: _routes, warnings } = await getMiddlewareRoutes(
|
|
96
105
|
// getContent(rawRoutes),
|
|
97
|
-
//
|
|
106
|
+
// {
|
|
107
|
+
// includes: conventionRoutes.include,
|
|
108
|
+
// excludes: conventionRoutes.exclude
|
|
109
|
+
// }
|
|
98
110
|
// );
|
|
99
111
|
// if (isBuildPhase) {
|
|
100
112
|
// warnings.forEach(warning => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-web",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -72,17 +72,17 @@
|
|
|
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.
|
|
75
|
+
"@shuvi/error-overlay": "1.0.14",
|
|
76
|
+
"@shuvi/hook": "1.0.14",
|
|
77
|
+
"@shuvi/platform-shared": "1.0.14",
|
|
78
78
|
"doura": "0.0.7",
|
|
79
79
|
"react-doura": "0.0.7",
|
|
80
|
-
"@shuvi/router": "1.0.
|
|
81
|
-
"@shuvi/router-react": "1.0.
|
|
82
|
-
"@shuvi/runtime": "1.0.
|
|
83
|
-
"@shuvi/shared": "1.0.
|
|
84
|
-
"@shuvi/toolpack": "1.0.
|
|
85
|
-
"@shuvi/utils": "1.0.
|
|
80
|
+
"@shuvi/router": "1.0.14",
|
|
81
|
+
"@shuvi/router-react": "1.0.14",
|
|
82
|
+
"@shuvi/runtime": "1.0.14",
|
|
83
|
+
"@shuvi/shared": "1.0.14",
|
|
84
|
+
"@shuvi/toolpack": "1.0.14",
|
|
85
|
+
"@shuvi/utils": "1.0.14",
|
|
86
86
|
"content-type": "1.0.4",
|
|
87
87
|
"core-js": "3.6.5",
|
|
88
88
|
"ejs": "3.1.5",
|
|
@@ -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.14"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@shuvi/service": "workspace:*",
|