@shuvi/platform-web 1.0.0-rc.1 → 1.0.0-rc.4
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/appTypes.d.ts +2 -2
- package/esm/shared/configTypes.d.ts +14 -0
- package/esm/shared/configTypes.js +1 -0
- package/esm/shared/index.d.ts +1 -0
- package/esm/shared/index.js +1 -0
- package/esm/shared/routeTypes.d.ts +1 -1
- package/esm/shuvi-app/app/client.d.ts +2 -0
- package/esm/shuvi-app/app/client.js +2 -1
- package/esm/shuvi-app/dev/eventsource.d.ts +1 -0
- package/esm/shuvi-app/dev/eventsource.js +60 -0
- package/esm/shuvi-app/dev/hotDevClient.d.ts +33 -0
- package/esm/shuvi-app/dev/hotDevClient.js +348 -0
- package/esm/shuvi-app/dev/index.d.ts +3 -0
- package/esm/shuvi-app/dev/index.js +27 -0
- package/esm/shuvi-app/dev/websocket.d.ts +17 -0
- package/esm/shuvi-app/dev/websocket.js +61 -0
- package/esm/shuvi-app/entry/client/app.d.ts +2 -1
- package/esm/shuvi-app/entry/client/app.js +2 -2
- package/esm/shuvi-app/entry/client/run.dev.js +4 -4
- package/esm/shuvi-app/entry/server/index.d.ts +5 -4
- package/esm/shuvi-app/entry/server/index.js +5 -4
- package/esm/shuvi-app/react/getRoutes.d.ts +2 -2
- package/esm/shuvi-app/react/getRoutes.js +6 -7
- package/{lib/node/targets → esm/shuvi-app}/react/redox-react/RedoxWrapper.d.ts +0 -0
- package/esm/shuvi-app/react/redox-react/RedoxWrapper.jsx +11 -0
- package/{lib/node/targets → esm/shuvi-app}/react/redox-react/runtime.d.ts +6 -0
- package/{lib/node/targets → esm/shuvi-app}/react/redox-react/runtime.js +6 -6
- package/esm/shuvi-app/shuvi-runtime-index.js +1 -1
- package/lib/node/features/custom-server/index.d.ts +1 -13
- package/lib/node/features/custom-server/index.js +0 -17
- package/lib/node/features/custom-server/server.d.ts +1 -1
- package/lib/node/features/filesystem-routes/api/apiRouteHandler.d.ts +1 -0
- package/lib/node/features/filesystem-routes/api/middleware.d.ts +1 -1
- package/lib/node/features/filesystem-routes/api/middleware.js +3 -5
- package/lib/node/features/filesystem-routes/hooks.d.ts +2 -2
- package/lib/node/features/filesystem-routes/index.d.ts +4 -4
- package/lib/node/features/filesystem-routes/index.js +20 -12
- package/lib/node/features/filesystem-routes/page/index.d.ts +1 -1
- package/lib/node/features/filesystem-routes/page/routes.d.ts +6 -6
- package/lib/node/features/filesystem-routes/page/routes.js +29 -11
- package/lib/node/features/filesystem-routes/page/store.d.ts +3 -3
- package/lib/node/features/html-render/index.d.ts +3 -17
- package/lib/node/features/html-render/index.js +87 -16
- package/lib/node/features/{main → html-render/lib}/buildHtml.d.ts +0 -0
- package/lib/node/features/{main → html-render/lib}/buildHtml.js +0 -0
- package/lib/node/features/html-render/lib/generateFilesByRoutId.d.ts +2 -2
- package/lib/node/features/html-render/lib/generateFilesByRoutId.js +3 -3
- package/lib/node/features/{main → html-render/lib}/generateResource.d.ts +0 -0
- package/lib/node/features/{main → html-render/lib}/generateResource.js +10 -12
- package/lib/node/features/html-render/server.d.ts +1 -1
- package/lib/node/features/html-render/serverHooks.d.ts +1 -0
- package/lib/node/features/html-render/shuvi-app.d.ts +1 -6
- package/lib/node/features/index.d.ts +3 -42
- package/lib/node/features/index.js +9 -8
- package/lib/node/features/middlewares.d.ts +1 -1
- package/lib/node/features/middlewares.js +5 -4
- package/lib/node/features/model/index.d.ts +3 -2
- package/lib/node/features/model/runtime.js +11 -17
- package/lib/node/features/model/server.js +2 -3
- package/lib/node/features/model/shuvi-app.d.ts +1 -1
- package/lib/node/features/on-demand-compile-page/index.d.ts +15 -12
- package/lib/node/features/on-demand-compile-page/index.js +4 -1
- package/lib/node/features/on-demand-compile-page/onDemandRouteManager.js +2 -4
- package/lib/node/features/webpack-watch-wait-for-file-builder/index.d.ts +16 -0
- package/lib/node/features/webpack-watch-wait-for-file-builder/index.js +25 -0
- package/lib/node/features/webpack-watch-wait-for-file-builder/webpack-watch-wait-for-file-builder-plugin.d.ts +12 -0
- package/lib/node/features/webpack-watch-wait-for-file-builder/webpack-watch-wait-for-file-builder-plugin.js +32 -0
- package/lib/node/index.d.ts +4 -2
- package/lib/node/index.js +2 -5
- package/lib/node/paths.js +26 -6
- package/lib/node/shuvi-type-extensions-node.d.ts +44 -0
- package/lib/node/{shuvi-node-extensions.js → shuvi-type-extensions-node.js} +1 -0
- package/lib/node/targets/react/bundler/index.d.ts +3 -2
- package/lib/node/targets/react/bundler/index.js +5 -0
- package/lib/node/targets/react/index.d.ts +6 -4
- package/lib/node/targets/react/redox-react/index.d.ts +3 -2
- package/lib/node/targets/react/redox-react/index.js +1 -1
- package/lib/shared/appTypes.d.ts +2 -2
- package/lib/shared/configTypes.d.ts +14 -0
- package/lib/{node/features/filesystem-routes/shuvi-app.js → shared/configTypes.js} +0 -0
- package/lib/shared/index.d.ts +1 -0
- package/lib/shared/index.js +1 -0
- package/lib/shared/routeTypes.d.ts +1 -1
- package/package.json +40 -25
- package/shuvi-env.d.ts +10 -0
- package/shuvi-image.d.ts +54 -0
- package/shuvi-type-extensions-node.d.ts +2 -0
- package/shuvi-type-extensions-node.js +1 -0
- package/{shuvi-app-extensions.d.ts → shuvi-type-extensions-runtime.d.ts} +7 -7
- package/esm/shuvi-app/dev/webpackHotDevClient.d.ts +0 -5
- package/esm/shuvi-app/dev/webpackHotDevClient.js +0 -33
- package/lib/node/features/filesystem-routes/shuvi-app.d.ts +0 -7
- package/lib/node/features/main/index.d.ts +0 -3
- package/lib/node/features/main/index.js +0 -82
- package/lib/node/shuvi-node-extensions.d.ts +0 -17
- package/lib/node/targets/react/redox-react/RedoxWrapper.js +0 -37
|
@@ -64,6 +64,11 @@ const configWebpack = (config, { name, webpack }, context) => {
|
|
|
64
64
|
resolveLocal('react', 'jsx-runtime')
|
|
65
65
|
]);
|
|
66
66
|
// @ts-ignore
|
|
67
|
+
config.resolve.alias.set('react/jsx-dev-runtime$', [
|
|
68
|
+
resolveUser('react/jsx-dev-runtime'),
|
|
69
|
+
resolveLocal('react', 'jsx-dev-runtime')
|
|
70
|
+
]);
|
|
71
|
+
// @ts-ignore
|
|
67
72
|
config.resolve.alias.set('react-dom$', [
|
|
68
73
|
resolveUser('react-dom'),
|
|
69
74
|
resolveLocal('react-dom')
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const platformWebReact: () => {
|
|
2
2
|
plugins: (import("@shuvi/hook").IPluginInstance<{
|
|
3
|
+
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
3
4
|
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
4
5
|
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
5
6
|
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
@@ -8,10 +9,11 @@ declare const platformWebReact: () => {
|
|
|
8
9
|
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
9
10
|
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
10
11
|
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
11
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").
|
|
12
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOption<any, any> | import("@shuvi/service/lib/project/index").FileOption<any, any>[]>;
|
|
12
13
|
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
13
|
-
} & import("@shuvi/
|
|
14
|
+
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext> | {
|
|
14
15
|
core: import("@shuvi/hook").IPluginInstance<{
|
|
16
|
+
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
15
17
|
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
16
18
|
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
17
19
|
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
@@ -20,9 +22,9 @@ declare const platformWebReact: () => {
|
|
|
20
22
|
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
21
23
|
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
22
24
|
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
23
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").
|
|
25
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOption<any, any> | import("@shuvi/service/lib/project/index").FileOption<any, any>[]>;
|
|
24
26
|
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
25
|
-
} & import("@shuvi/
|
|
27
|
+
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
26
28
|
})[];
|
|
27
29
|
platformModule: string;
|
|
28
30
|
polyfills: string[];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const RedoxReactPlugin: {
|
|
2
2
|
core: import("@shuvi/hook").IPluginInstance<{
|
|
3
|
+
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
3
4
|
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
4
5
|
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
5
6
|
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
@@ -8,9 +9,9 @@ export declare const RedoxReactPlugin: {
|
|
|
8
9
|
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
9
10
|
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
10
11
|
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
11
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").
|
|
12
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOption<any, any> | import("@shuvi/service/lib/project/index").FileOption<any, any>[]>;
|
|
12
13
|
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
13
|
-
} & import("@shuvi/
|
|
14
|
+
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
14
15
|
runtime: {
|
|
15
16
|
plugin: string;
|
|
16
17
|
};
|
|
@@ -28,7 +28,7 @@ const path = __importStar(require("path"));
|
|
|
28
28
|
const service_1 = require("@shuvi/service");
|
|
29
29
|
const paths_1 = require("../../../paths");
|
|
30
30
|
// todo: optimize this
|
|
31
|
-
const runtimePath = require.resolve(path.join(__dirname, '../../../../../
|
|
31
|
+
const runtimePath = require.resolve(path.join(__dirname, '../../../../../esm/shuvi-app/react/redox-react/runtime'));
|
|
32
32
|
const core = (0, service_1.createPlugin)({
|
|
33
33
|
addRuntimeService: () => [
|
|
34
34
|
{
|
package/lib/shared/appTypes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IRequest,
|
|
1
|
+
import { IRequest, IPageRouteRecord, IAppData, IAppState } from '@shuvi/platform-shared/shared';
|
|
2
2
|
import { Application } from '@shuvi/platform-shared/shuvi-app/application';
|
|
3
3
|
export interface CreateAppServer {
|
|
4
4
|
(options: {
|
|
@@ -8,7 +8,7 @@ export interface CreateAppServer {
|
|
|
8
8
|
}
|
|
9
9
|
export interface CreateAppClient {
|
|
10
10
|
(options: {
|
|
11
|
-
routes:
|
|
11
|
+
routes: IPageRouteRecord[];
|
|
12
12
|
appComponent: any;
|
|
13
13
|
appData: IAppData<any, IAppState>;
|
|
14
14
|
}): Application;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IRouterHistoryMode, IPageRouteConfig, IMiddlewareRouteConfig, IApiRouteConfig } from '@shuvi/platform-shared/shared';
|
|
2
|
+
export interface IRouterConfig {
|
|
3
|
+
history: IRouterHistoryMode | 'auto';
|
|
4
|
+
}
|
|
5
|
+
export interface PlatformWebCustomConfig {
|
|
6
|
+
ssr: boolean;
|
|
7
|
+
router: IRouterConfig;
|
|
8
|
+
routes?: IPageRouteConfig[];
|
|
9
|
+
middlewareRoutes?: IMiddlewareRouteConfig[];
|
|
10
|
+
apiRoutes?: IApiRouteConfig[];
|
|
11
|
+
conventionRoutes: {
|
|
12
|
+
exclude?: string[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
File without changes
|
package/lib/shared/index.d.ts
CHANGED
package/lib/shared/index.js
CHANGED
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./appTypes"), exports);
|
|
18
|
+
__exportStar(require("./configTypes"), exports);
|
|
18
19
|
__exportStar(require("./renderTypes"), exports);
|
|
19
20
|
__exportStar(require("./routeTypes"), exports);
|
|
20
21
|
__exportStar(require("./serverTypes"), exports);
|
|
@@ -24,7 +24,7 @@ export declare type IApiRes<T = any> = {
|
|
|
24
24
|
export declare type IApiResponse<T = any> = IResponse & IApiRes<T>;
|
|
25
25
|
export declare type IApiRequestHandler<T = any> = (req: IApiRequest, res: IApiResponse<T>) => void | Promise<void>;
|
|
26
26
|
export interface IApiConfig {
|
|
27
|
-
|
|
27
|
+
api?: {
|
|
28
28
|
bodyParser?: {
|
|
29
29
|
sizeLimit: number | string;
|
|
30
30
|
} | boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-web",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -12,10 +12,13 @@
|
|
|
12
12
|
"**/shuvi-app/entry/client/**"
|
|
13
13
|
],
|
|
14
14
|
"files": [
|
|
15
|
-
"lib",
|
|
16
15
|
"esm",
|
|
17
|
-
"
|
|
18
|
-
"shuvi-
|
|
16
|
+
"lib",
|
|
17
|
+
"shuvi-env.d.ts",
|
|
18
|
+
"shuvi-image.d.ts",
|
|
19
|
+
"shuvi-type-extensions-node.d.ts",
|
|
20
|
+
"shuvi-type-extensions-node.js",
|
|
21
|
+
"shuvi-type-extensions-runtime.d.ts"
|
|
19
22
|
],
|
|
20
23
|
"exports": {
|
|
21
24
|
".": {
|
|
@@ -42,24 +45,37 @@
|
|
|
42
45
|
"./esm/shuvi-app/*.jsx"
|
|
43
46
|
]
|
|
44
47
|
},
|
|
45
|
-
"./shuvi-
|
|
48
|
+
"./shuvi-type-extensions-node": {
|
|
49
|
+
"types": "./shuvi-type-extensions-node.d.js",
|
|
50
|
+
"default": "./shuvi-type-extensions-node.js"
|
|
51
|
+
},
|
|
52
|
+
"./shuvi-type-extensions-runtime": "./shuvi-type-extensions-runtime.d.ts"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"dev": "run-p watch:*",
|
|
56
|
+
"watch:esm": "tsc -p tsconfig.build.browser.json -w",
|
|
57
|
+
"watch:cjs": "tsc -p tsconfig.build.node.json -w",
|
|
58
|
+
"prebuild": "rimraf lib esm types",
|
|
59
|
+
"build": "run-p build:*",
|
|
60
|
+
"build:esm": "tsc -p tsconfig.build.browser.json",
|
|
61
|
+
"build:cjs": "tsc -p tsconfig.build.node.json"
|
|
46
62
|
},
|
|
47
63
|
"engines": {
|
|
48
64
|
"node": ">= 12.0.0"
|
|
49
65
|
},
|
|
50
66
|
"dependencies": {
|
|
51
67
|
"@next/react-refresh-utils": "12.1.6",
|
|
52
|
-
"@shuvi/hook": "1.0.0-rc.
|
|
53
|
-
"@shuvi/platform-shared": "1.0.0-rc.
|
|
68
|
+
"@shuvi/hook": "1.0.0-rc.4",
|
|
69
|
+
"@shuvi/platform-shared": "1.0.0-rc.4",
|
|
54
70
|
"@shuvi/redox": "0.0.3",
|
|
55
71
|
"@shuvi/redox-react": "0.0.3",
|
|
56
|
-
"@shuvi/router": "1.0.0-rc.
|
|
57
|
-
"@shuvi/router-react": "1.0.0-rc.
|
|
58
|
-
"@shuvi/runtime": "1.0.0-rc.
|
|
59
|
-
"@shuvi/service": "1.0.0-rc.
|
|
60
|
-
"@shuvi/shared": "1.0.0-rc.
|
|
61
|
-
"@shuvi/toolpack": "1.0.0-rc.
|
|
62
|
-
"@shuvi/utils": "1.0.0-rc.
|
|
72
|
+
"@shuvi/router": "1.0.0-rc.4",
|
|
73
|
+
"@shuvi/router-react": "1.0.0-rc.4",
|
|
74
|
+
"@shuvi/runtime": "1.0.0-rc.4",
|
|
75
|
+
"@shuvi/service": "1.0.0-rc.4",
|
|
76
|
+
"@shuvi/shared": "1.0.0-rc.4",
|
|
77
|
+
"@shuvi/toolpack": "1.0.0-rc.4",
|
|
78
|
+
"@shuvi/utils": "1.0.0-rc.4",
|
|
63
79
|
"content-type": "1.0.4",
|
|
64
80
|
"cookie": "0.4.1",
|
|
65
81
|
"ejs": "3.1.5",
|
|
@@ -69,25 +85,24 @@
|
|
|
69
85
|
"react": "18.1.0",
|
|
70
86
|
"react-app-polyfill": "2.0.0",
|
|
71
87
|
"react-dom": "18.1.0",
|
|
88
|
+
"react-error-overlay": "6.0.8",
|
|
72
89
|
"react-refresh": "0.12.0",
|
|
90
|
+
"strip-ansi": "6.0.0",
|
|
73
91
|
"use-sync-external-store": "1.1.0"
|
|
74
92
|
},
|
|
93
|
+
"peerDependencies": {
|
|
94
|
+
"@shuvi/service": "1.0.0-rc.4"
|
|
95
|
+
},
|
|
75
96
|
"devDependencies": {
|
|
97
|
+
"@types/react": "18.0.9",
|
|
98
|
+
"@types/react-dom": "18.0.6",
|
|
99
|
+
"@types/react-test-renderer": "18.0.0",
|
|
76
100
|
"@shuvi/redox": "0.0.3",
|
|
77
|
-
"@testing-library/react": "^
|
|
101
|
+
"@testing-library/react": "^13.2.0",
|
|
78
102
|
"@types/content-type": "^1.1.5",
|
|
79
103
|
"@types/cookie": "^0.4.1",
|
|
80
104
|
"@types/ejs": "^3.1.0",
|
|
81
105
|
"@types/raw-body": "^2.3.0",
|
|
82
106
|
"webpack": "5.73.0"
|
|
83
|
-
},
|
|
84
|
-
"scripts": {
|
|
85
|
-
"dev": "run-p watch:*",
|
|
86
|
-
"watch:esm": "tsc -p tsconfig.build.browser.json -w",
|
|
87
|
-
"watch:cjs": "tsc -p tsconfig.build.node.json -w",
|
|
88
|
-
"prebuild": "rimraf lib esm types",
|
|
89
|
-
"build": "run-p build:*",
|
|
90
|
-
"build:esm": "tsc -p tsconfig.build.browser.json",
|
|
91
|
-
"build:cjs": "tsc -p tsconfig.build.node.json"
|
|
92
107
|
}
|
|
93
|
-
}
|
|
108
|
+
}
|
package/shuvi-env.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
/// <reference types="react-dom" />
|
|
4
|
+
|
|
5
|
+
// Extend the NodeJS namespace with Next.js-defined properties
|
|
6
|
+
declare namespace NodeJS {
|
|
7
|
+
interface ProcessEnv {
|
|
8
|
+
readonly NODE_ENV: 'development' | 'production' | 'test';
|
|
9
|
+
}
|
|
10
|
+
}
|
package/shuvi-image.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare module '*.bmp' {
|
|
2
|
+
const src: string;
|
|
3
|
+
export default src;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module '*.gif' {
|
|
7
|
+
const src: string;
|
|
8
|
+
export default src;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module '*.jpg' {
|
|
12
|
+
const src: string;
|
|
13
|
+
export default src;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare module '*.jpeg' {
|
|
17
|
+
const src: string;
|
|
18
|
+
export default src;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module '*.png' {
|
|
22
|
+
const src: string;
|
|
23
|
+
export default src;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare module '*.webp' {
|
|
27
|
+
const src: string;
|
|
28
|
+
export default src;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module '*.svg' {
|
|
32
|
+
/**
|
|
33
|
+
* Use `any` to avoid conflicts with
|
|
34
|
+
* `@svgr/webpack` plugin or
|
|
35
|
+
* `babel-plugin-inline-react-svg` plugin.
|
|
36
|
+
*/
|
|
37
|
+
const content: any;
|
|
38
|
+
export default content;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare module '*.css' {
|
|
42
|
+
const classes: { readonly [key: string]: string };
|
|
43
|
+
export default classes;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare module '*.sass' {
|
|
47
|
+
const classes: { readonly [key: string]: string };
|
|
48
|
+
export default classes;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare module '*.scss' {
|
|
52
|
+
const classes: { readonly [key: string]: string };
|
|
53
|
+
export default classes;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
/// <reference types="@shuvi/platform-shared/shuvi-
|
|
1
|
+
/// <reference types="@shuvi/platform-shared/shuvi-type-extensions-runtime" />
|
|
2
2
|
|
|
3
3
|
declare module '@shuvi/app/files/routes' {
|
|
4
|
-
import {
|
|
5
|
-
declare const routes:
|
|
4
|
+
import { IPageRouteRecord } from '@shuvi/platform-shared/shared';
|
|
5
|
+
declare const routes: IPageRouteRecord[];
|
|
6
6
|
export default routes;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
declare module '@shuvi/app/files/routerConfig' {
|
|
10
|
-
import { ILoaderOptions } from '@shuvi/platform-shared/shared/loader';
|
|
11
10
|
export const historyMode: 'browser' | 'hash';
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
declare module '@shuvi/app/files/page-loaders' {
|
|
15
|
-
import { IRouteLoaderContext } from '@shuvi/platform-shared/shared';
|
|
16
|
-
import { Loader } from '@shuvi/platform-shared/shared';
|
|
14
|
+
import { IRouteLoaderContext, Loader } from '@shuvi/platform-shared/shared';
|
|
17
15
|
|
|
18
16
|
const loaders: Record<string, Loader>;
|
|
19
17
|
export default loaders;
|
|
@@ -21,16 +19,18 @@ declare module '@shuvi/app/files/page-loaders' {
|
|
|
21
19
|
|
|
22
20
|
declare module '@shuvi/app/files/apiRoutes' {
|
|
23
21
|
import { IApiRoutes } from '@shuvi/platform-web/shared';
|
|
22
|
+
|
|
24
23
|
declare const apiRoutes: IApiRoutes[];
|
|
25
24
|
export default apiRoutes;
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
declare module '@shuvi/app/files/middlewareRoutes' {
|
|
29
28
|
import { IMiddlewareRoutes } from '@shuvi/platform-web/shared';
|
|
29
|
+
|
|
30
30
|
declare const middlewareRoutes: IMiddlewareRoutes[];
|
|
31
31
|
export default middlewareRoutes;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
declare module '@shuvi/app/
|
|
34
|
+
declare module '@shuvi/app/user/server' {
|
|
35
35
|
export {};
|
|
36
36
|
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import connect from '@shuvi/toolpack/lib/utils/hotDevClient';
|
|
2
|
-
import { DEV_HOT_MIDDLEWARE_PATH, DEV_HOT_LAUNCH_EDITOR_ENDPOINT } from '@shuvi/shared/lib/constants';
|
|
3
|
-
let devClient;
|
|
4
|
-
export default (options = {}) => {
|
|
5
|
-
if (devClient) {
|
|
6
|
-
return devClient;
|
|
7
|
-
}
|
|
8
|
-
devClient = connect(Object.assign(Object.assign({}, options), { launchEditorEndpoint: DEV_HOT_LAUNCH_EDITOR_ENDPOINT, path: DEV_HOT_MIDDLEWARE_PATH }));
|
|
9
|
-
devClient.subscribeToHmrEvent((event) => {
|
|
10
|
-
// if (obj.action === "reloadPage") {
|
|
11
|
-
// return window.location.reload();
|
|
12
|
-
// }
|
|
13
|
-
// if (obj.action === "removedPage") {
|
|
14
|
-
// const [page] = obj.data;
|
|
15
|
-
// if (page === window.next.router.pathname) {
|
|
16
|
-
// return window.location.reload();
|
|
17
|
-
// }
|
|
18
|
-
// return;
|
|
19
|
-
// }
|
|
20
|
-
// if (obj.action === "addedPage") {
|
|
21
|
-
// const [page] = obj.data;
|
|
22
|
-
// if (
|
|
23
|
-
// page === window.next.router.pathname &&
|
|
24
|
-
// typeof window.next.router.components[page] === "undefined"
|
|
25
|
-
// ) {
|
|
26
|
-
// return window.location.reload();
|
|
27
|
-
// }
|
|
28
|
-
// return;
|
|
29
|
-
// }
|
|
30
|
-
// throw new Error("Unexpected action " + obj.action);
|
|
31
|
-
});
|
|
32
|
-
return devClient;
|
|
33
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getPlugin = void 0;
|
|
16
|
-
const service_1 = require("@shuvi/service");
|
|
17
|
-
const constants_1 = require("@shuvi/shared/lib/constants");
|
|
18
|
-
const config_1 = require("@shuvi/toolpack/lib/webpack/config");
|
|
19
|
-
const generateResource_1 = __importDefault(require("./generateResource"));
|
|
20
|
-
const paths_1 = require("../../paths");
|
|
21
|
-
const buildHtml_1 = require("./buildHtml");
|
|
22
|
-
const middlewares_1 = require("../middlewares");
|
|
23
|
-
function getServerEntry() {
|
|
24
|
-
return {
|
|
25
|
-
[service_1.BUILD_SERVER_FILE_SERVER]: [(0, paths_1.resolvePkgFile)('esm/shuvi-app/entry/server')]
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/** This main plugin uses `platformContext` so that it is set to a plugin getter */
|
|
29
|
-
const getPlugin = (platformContext) => {
|
|
30
|
-
const core = (0, service_1.createPlugin)({
|
|
31
|
-
addExtraTarget: ({ createConfig }, context) => {
|
|
32
|
-
const serverWebpackHelpers = (0, config_1.webpackHelpers)();
|
|
33
|
-
const serverChain = createConfig({
|
|
34
|
-
name: constants_1.BUNDLER_TARGET_SERVER,
|
|
35
|
-
node: true,
|
|
36
|
-
entry: getServerEntry(),
|
|
37
|
-
outputDir: service_1.BUILD_SERVER_DIR,
|
|
38
|
-
webpackHelpers: serverWebpackHelpers
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
name: constants_1.BUNDLER_TARGET_SERVER,
|
|
42
|
-
chain: serverChain
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
configWebpack: chain => {
|
|
46
|
-
chain.merge({
|
|
47
|
-
entry: {
|
|
48
|
-
[service_1.BUILD_CLIENT_RUNTIME_POLYFILL]: ['@shuvi/app/core/polyfill'],
|
|
49
|
-
[service_1.BUILD_CLIENT_RUNTIME_MAIN]: [
|
|
50
|
-
(0, paths_1.resolvePkgFile)('esm/shuvi-app/entry/client')
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
return chain;
|
|
55
|
-
},
|
|
56
|
-
addRuntimeService: () => [
|
|
57
|
-
{
|
|
58
|
-
source: (0, paths_1.resolvePkgFile)('esm/shuvi-app/shuvi-runtime-index'),
|
|
59
|
-
exported: '*'
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
source: (0, paths_1.resolvePkgFile)('esm/shuvi-app/shuvi-runtime-server'),
|
|
63
|
-
filepath: 'server.ts',
|
|
64
|
-
exported: '*'
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
addResource: context => (0, generateResource_1.default)(context),
|
|
68
|
-
afterBuild: (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
yield (0, buildHtml_1.buildHtml)({
|
|
70
|
-
context,
|
|
71
|
-
serverPlugins: platformContext.serverPlugins,
|
|
72
|
-
getMiddlewares: middlewares_1.getMiddlewares,
|
|
73
|
-
pathname: '/',
|
|
74
|
-
filename: 'index.html'
|
|
75
|
-
});
|
|
76
|
-
})
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
core
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
exports.getPlugin = getPlugin;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CreateAppServer, IServerModule, IApiRoutes, IMiddlewareRoutes } from '../shared';
|
|
2
|
-
import { IManifest } from '@shuvi/toolpack/lib/webpack/types';
|
|
3
|
-
import { IViewServer } from './features/html-render';
|
|
4
|
-
declare module '@shuvi/service/lib/resources' {
|
|
5
|
-
const server: {
|
|
6
|
-
server: IServerModule;
|
|
7
|
-
apiRoutes: IApiRoutes;
|
|
8
|
-
middlewareRoutes: IMiddlewareRoutes;
|
|
9
|
-
application: {
|
|
10
|
-
createApp: CreateAppServer;
|
|
11
|
-
};
|
|
12
|
-
view: IViewServer;
|
|
13
|
-
};
|
|
14
|
-
const documentPath: string;
|
|
15
|
-
const clientManifest: IManifest;
|
|
16
|
-
const serverManifest: IManifest;
|
|
17
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.RedoxWrapper = void 0;
|
|
27
|
-
const React = __importStar(require("react"));
|
|
28
|
-
const redox_react_1 = require("@shuvi/redox-react");
|
|
29
|
-
const RedoxWrapper = (App, appContext) => {
|
|
30
|
-
function RedoxAppWrapper(appProps) {
|
|
31
|
-
return (React.createElement(redox_react_1.RedoxRoot, { storeManager: appContext.storeManager },
|
|
32
|
-
React.createElement(App, Object.assign({}, appProps))));
|
|
33
|
-
}
|
|
34
|
-
RedoxAppWrapper.displayName = 'RedoxAppWrapper';
|
|
35
|
-
return RedoxAppWrapper;
|
|
36
|
-
};
|
|
37
|
-
exports.RedoxWrapper = RedoxWrapper;
|