@shuvi/platform-web 1.0.0-rc.3 → 1.0.0-rc.6
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 +5 -3
- package/esm/shared/renderTypes.d.ts +6 -5
- package/esm/shared/routeTypes.d.ts +4 -9
- package/esm/shuvi-app/app/client.d.ts +2 -0
- package/esm/shuvi-app/app/client.js +13 -17
- package/esm/shuvi-app/app/server.js +10 -9
- 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 +32 -0
- package/esm/shuvi-app/dev/hotDevClient.js +327 -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 +16 -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/helper/serializeServerError.d.ts +2 -0
- package/esm/shuvi-app/helper/serializeServerError.js +21 -0
- package/esm/shuvi-app/react/AppContainer.d.ts +2 -3
- package/esm/shuvi-app/react/AppContainer.jsx +3 -4
- package/esm/shuvi-app/react/getRoutes.d.ts +2 -2
- package/esm/shuvi-app/react/getRoutes.js +9 -8
- package/esm/shuvi-app/react/{redox-react → model}/RedoxWrapper.d.ts +3 -3
- package/esm/shuvi-app/react/{redox-react → model}/RedoxWrapper.jsx +3 -3
- package/esm/shuvi-app/react/model/runtime.d.ts +8 -0
- package/esm/shuvi-app/react/{redox-react → model}/runtime.js +8 -3
- package/esm/shuvi-app/react/store.d.ts +5 -0
- package/esm/shuvi-app/react/store.js +3 -0
- package/esm/shuvi-app/react/types.d.ts +0 -7
- package/esm/shuvi-app/react/useLoaderData.js +9 -20
- package/esm/shuvi-app/react/view/ReactView.client.jsx +25 -4
- package/esm/shuvi-app/react/view/ReactView.server.jsx +17 -14
- package/esm/shuvi-app/shuvi-runtime-index.d.ts +3 -3
- package/esm/shuvi-app/shuvi-runtime-index.js +1 -1
- package/lib/node/features/custom-server/index.d.ts +1 -1
- package/lib/node/features/custom-server/server.d.ts +1 -1
- package/lib/node/features/filesystem-routes/api/apiRouteHandler.d.ts +7 -7
- package/lib/node/features/filesystem-routes/api/apiRouteHandler.js +0 -4
- package/lib/node/features/filesystem-routes/api/middleware.d.ts +2 -2
- package/lib/node/features/filesystem-routes/index.d.ts +1 -13
- package/lib/node/features/filesystem-routes/index.js +20 -48
- package/lib/node/features/filesystem-routes/middleware/middleware.d.ts +2 -2
- package/lib/node/features/filesystem-routes/page/routes.d.ts +2 -2
- package/lib/node/features/filesystem-routes/page/routes.js +29 -11
- package/lib/node/features/html-render/index.d.ts +3 -18
- 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 +0 -0
- package/lib/node/features/html-render/lib/getPageMiddleware.d.ts +2 -2
- package/lib/node/features/html-render/lib/index.d.ts +0 -1
- package/lib/node/features/html-render/lib/index.js +1 -3
- package/lib/node/features/html-render/lib/renderToHTML.d.ts +2 -2
- package/lib/node/features/html-render/lib/renderToHTML.js +7 -48
- package/lib/node/features/html-render/lib/renderer/base.d.ts +6 -6
- package/lib/node/features/html-render/lib/renderer/base.js +5 -5
- package/lib/node/features/html-render/lib/renderer/index.d.ts +5 -4
- package/lib/node/features/html-render/lib/renderer/index.js +69 -6
- package/lib/node/features/html-render/lib/renderer/spa.d.ts +2 -2
- package/lib/node/features/html-render/lib/renderer/spa.js +4 -6
- package/lib/node/features/html-render/lib/renderer/ssr.d.ts +2 -2
- package/lib/node/features/html-render/lib/renderer/ssr.js +5 -6
- package/lib/node/features/html-render/lib/renderer/types.d.ts +8 -5
- package/lib/node/features/html-render/server.d.ts +1 -1
- package/lib/node/features/index.d.ts +3 -31
- package/lib/node/features/index.js +6 -7
- package/lib/node/features/model/index.d.ts +1 -13
- package/lib/node/features/model/runtime.d.ts +3 -8
- package/lib/node/features/model/runtime.js +13 -17
- package/lib/node/features/model/server.js +2 -3
- package/lib/node/features/model/shuvi-app.d.ts +2 -2
- package/lib/node/features/on-demand-compile-page/index.d.ts +3 -13
- package/lib/node/features/on-demand-compile-page/index.js +4 -1
- package/lib/node/features/on-demand-compile-page/onDemandRouteManager.d.ts +3 -3
- package/lib/node/features/on-demand-compile-page/onDemandRouteManager.js +2 -4
- package/lib/node/index.js +1 -3
- package/lib/node/paths.js +0 -2
- package/lib/node/shuvi-runtime-server.d.ts +18 -0
- package/lib/node/shuvi-runtime-server.js +2 -0
- package/lib/node/shuvi-type-extensions-node.d.ts +2 -6
- package/lib/node/targets/react/bundler/index.d.ts +1 -13
- package/lib/node/targets/react/bundler/index.js +5 -0
- package/lib/node/targets/react/index.d.ts +2 -26
- package/lib/node/targets/react/index.js +2 -2
- package/lib/node/targets/react/model/index.d.ts +6 -0
- package/lib/node/targets/react/{redox-react → model}/index.js +7 -6
- package/lib/shared/appTypes.d.ts +5 -3
- package/lib/shared/renderTypes.d.ts +6 -5
- package/lib/shared/routeTypes.d.ts +4 -9
- package/package.json +20 -15
- package/shuvi-env.d.ts +10 -0
- package/shuvi-image.d.ts +54 -0
- package/shuvi-type-extensions-node.js +1 -0
- package/shuvi-type-extensions-runtime.d.ts +2 -2
- package/esm/shuvi-app/dev/webpackHotDevClient.d.ts +0 -5
- package/esm/shuvi-app/dev/webpackHotDevClient.js +0 -34
- package/esm/shuvi-app/react/redox-react/runtime.d.ts +0 -2
- package/esm/shuvi-app/shuvi-runtime-server.d.ts +0 -6
- package/esm/shuvi-app/shuvi-runtime-server.js +0 -1
- package/lib/node/features/main/index.d.ts +0 -3
- package/lib/node/features/main/index.js +0 -82
- package/lib/node/targets/react/redox-react/index.d.ts +0 -18
|
@@ -1,30 +1,6 @@
|
|
|
1
1
|
declare const platformWebReact: () => {
|
|
2
|
-
plugins: (import("@shuvi/hook").IPluginInstance<{
|
|
3
|
-
|
|
4
|
-
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
5
|
-
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
6
|
-
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
7
|
-
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
8
|
-
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
9
|
-
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
10
|
-
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
11
|
-
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
12
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
|
|
13
|
-
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
14
|
-
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext> | {
|
|
15
|
-
core: import("@shuvi/hook").IPluginInstance<{
|
|
16
|
-
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
17
|
-
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
18
|
-
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
19
|
-
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
20
|
-
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
21
|
-
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
22
|
-
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
23
|
-
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
24
|
-
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
25
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
|
|
26
|
-
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
27
|
-
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
2
|
+
plugins: (import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext> | {
|
|
3
|
+
core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
|
|
28
4
|
})[];
|
|
29
5
|
platformModule: string;
|
|
30
6
|
polyfills: string[];
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const service_1 = require("@shuvi/service");
|
|
7
7
|
const bundler_1 = __importDefault(require("./bundler"));
|
|
8
|
-
const
|
|
8
|
+
const model_1 = require("./model");
|
|
9
9
|
const paths_1 = require("../../paths");
|
|
10
10
|
const webReactMainPlugin = (0, service_1.createPlugin)({
|
|
11
11
|
addRuntimeService: () => [
|
|
@@ -17,7 +17,7 @@ const webReactMainPlugin = (0, service_1.createPlugin)({
|
|
|
17
17
|
});
|
|
18
18
|
const platformWebReact = () => {
|
|
19
19
|
return {
|
|
20
|
-
plugins: [webReactMainPlugin, bundler_1.default,
|
|
20
|
+
plugins: [webReactMainPlugin, bundler_1.default, model_1.ModelReactPlugin],
|
|
21
21
|
platformModule: (0, paths_1.resolvePkgFile)('esm/shuvi-app/react/index'),
|
|
22
22
|
polyfills: [
|
|
23
23
|
(0, paths_1.resolveDep)('react-app-polyfill/ie11'),
|
|
@@ -23,13 +23,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.ModelReactPlugin = void 0;
|
|
27
27
|
const path = __importStar(require("path"));
|
|
28
28
|
const service_1 = require("@shuvi/service");
|
|
29
29
|
const paths_1 = require("../../../paths");
|
|
30
|
-
|
|
31
|
-
const runtimePath = require.resolve(path.join(__dirname, '../../../../../esm/shuvi-app/react/redox-react/runtime'));
|
|
32
|
-
const core = (0, service_1.createPlugin)({
|
|
30
|
+
const core = (0, service_1.createPluginAfter)({
|
|
33
31
|
addRuntimeService: () => [
|
|
34
32
|
{
|
|
35
33
|
source: path.dirname(require.resolve('@shuvi/redox-react/package.json')),
|
|
@@ -41,10 +39,13 @@ const core = (0, service_1.createPlugin)({
|
|
|
41
39
|
config.resolve.alias.set('@shuvi/redox', (0, paths_1.resolveLib)('@shuvi/redox'));
|
|
42
40
|
return config;
|
|
43
41
|
}
|
|
42
|
+
}, {
|
|
43
|
+
name: 'model-react'
|
|
44
44
|
});
|
|
45
|
-
exports.
|
|
45
|
+
exports.ModelReactPlugin = {
|
|
46
46
|
core,
|
|
47
47
|
runtime: {
|
|
48
|
-
|
|
48
|
+
// this need
|
|
49
|
+
plugin: (0, paths_1.resolvePkgFile)('esm/shuvi-app/react/model/runtime')
|
|
49
50
|
}
|
|
50
51
|
};
|
package/lib/shared/appTypes.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPageRouteRecord, IAppData, IAppState } from '@shuvi/platform-shared/shared';
|
|
2
2
|
import { Application } from '@shuvi/platform-shared/shuvi-app/application';
|
|
3
|
+
import type { ShuviRequest } from '@shuvi/service';
|
|
3
4
|
export interface CreateAppServer {
|
|
4
5
|
(options: {
|
|
5
|
-
req:
|
|
6
|
+
req: ShuviRequest;
|
|
6
7
|
ssr: boolean;
|
|
8
|
+
isDev: boolean;
|
|
7
9
|
}): Application;
|
|
8
10
|
}
|
|
9
11
|
export interface CreateAppClient {
|
|
10
12
|
(options: {
|
|
11
|
-
routes:
|
|
13
|
+
routes: IPageRouteRecord[];
|
|
12
14
|
appComponent: any;
|
|
13
15
|
appData: IAppData<any, IAppState>;
|
|
14
16
|
}): Application;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { IManifest } from '@shuvi/toolpack/lib/webpack/types';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import type { ShuviRequest } from '@shuvi/service';
|
|
3
|
+
import { Response, IApplication, IAppData } from '@shuvi/platform-shared/shared';
|
|
4
|
+
export declare type IRenderViewOptions = {
|
|
4
5
|
app: IApplication;
|
|
5
|
-
req?: IRequest;
|
|
6
6
|
};
|
|
7
|
-
export interface IRenderOptions extends
|
|
7
|
+
export interface IRenderOptions extends IRenderViewOptions {
|
|
8
8
|
}
|
|
9
9
|
export interface IView<RenderOption extends IRenderOptions = any, RenderResult = void> {
|
|
10
10
|
renderApp(options: RenderOption): RenderResult;
|
|
@@ -35,8 +35,9 @@ export interface IClientRendererOptions<ExtraAppData = {}> extends IRenderOption
|
|
|
35
35
|
appData: IAppData<ExtraAppData>;
|
|
36
36
|
}
|
|
37
37
|
export interface IServerRendererOptions extends IRenderOptions {
|
|
38
|
+
req: ShuviRequest;
|
|
38
39
|
manifest: IManifest;
|
|
39
|
-
|
|
40
|
+
isDev?: boolean;
|
|
40
41
|
}
|
|
41
42
|
export interface IViewClient<ExtraAppData = {}> extends IView<IClientRendererOptions<ExtraAppData>> {
|
|
42
43
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IRequestHandlerWithNext } from '@shuvi/service';
|
|
3
|
-
import { IResponse, IRequest } from '@shuvi/service';
|
|
1
|
+
import { ShuviRequest, ShuviResponse, ShuviRequestHandler } from '@shuvi/service';
|
|
4
2
|
export interface IApiReq {
|
|
5
|
-
pathname: string;
|
|
6
|
-
query: IURLQuery;
|
|
7
|
-
params: IURLParams;
|
|
8
3
|
cookies: {
|
|
9
4
|
[key: string]: string;
|
|
10
5
|
};
|
|
@@ -12,7 +7,7 @@ export interface IApiReq {
|
|
|
12
7
|
[key: string]: any;
|
|
13
8
|
};
|
|
14
9
|
}
|
|
15
|
-
export declare type IApiRequest =
|
|
10
|
+
export declare type IApiRequest = ShuviRequest & IApiReq;
|
|
16
11
|
export declare type Send<T> = (body: T) => void;
|
|
17
12
|
export declare type IApiRes<T = any> = {
|
|
18
13
|
send: Send<T>;
|
|
@@ -21,7 +16,7 @@ export declare type IApiRes<T = any> = {
|
|
|
21
16
|
redirect(url: string): IApiRes<T>;
|
|
22
17
|
redirect(status: number, url: string): IApiRes<T>;
|
|
23
18
|
};
|
|
24
|
-
export declare type IApiResponse<T = any> =
|
|
19
|
+
export declare type IApiResponse<T = any> = ShuviResponse & IApiRes<T>;
|
|
25
20
|
export declare type IApiRequestHandler<T = any> = (req: IApiRequest, res: IApiResponse<T>) => void | Promise<void>;
|
|
26
21
|
export interface IApiConfig {
|
|
27
22
|
api?: {
|
|
@@ -35,7 +30,7 @@ export interface IApiHandler {
|
|
|
35
30
|
config?: IApiConfig;
|
|
36
31
|
}
|
|
37
32
|
export interface IMiddlewareConfig {
|
|
38
|
-
default:
|
|
33
|
+
default: ShuviRequestHandler;
|
|
39
34
|
}
|
|
40
35
|
export declare type IApiRoutes = {
|
|
41
36
|
path: string;
|
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.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
"**/shuvi-app/entry/client/**"
|
|
13
13
|
],
|
|
14
14
|
"files": [
|
|
15
|
-
"lib",
|
|
16
15
|
"esm",
|
|
16
|
+
"lib",
|
|
17
|
+
"shuvi-env.d.ts",
|
|
18
|
+
"shuvi-image.d.ts",
|
|
17
19
|
"shuvi-type-extensions-node.d.ts",
|
|
20
|
+
"shuvi-type-extensions-node.js",
|
|
18
21
|
"shuvi-type-extensions-runtime.d.ts"
|
|
19
22
|
],
|
|
20
23
|
"exports": {
|
|
@@ -62,17 +65,18 @@
|
|
|
62
65
|
},
|
|
63
66
|
"dependencies": {
|
|
64
67
|
"@next/react-refresh-utils": "12.1.6",
|
|
65
|
-
"@shuvi/hook": "1.0.0-rc.
|
|
66
|
-
"@shuvi/platform-shared": "1.0.0-rc.
|
|
67
|
-
"@shuvi/redox": "0.0.
|
|
68
|
-
"@shuvi/redox-react": "0.0.
|
|
69
|
-
"@shuvi/router": "1.0.0-rc.
|
|
70
|
-
"@shuvi/router-react": "1.0.0-rc.
|
|
71
|
-
"@shuvi/runtime": "1.0.0-rc.
|
|
72
|
-
"@shuvi/service": "1.0.0-rc.
|
|
73
|
-
"@shuvi/shared": "1.0.0-rc.
|
|
74
|
-
"@shuvi/toolpack": "1.0.0-rc.
|
|
75
|
-
"@shuvi/utils": "1.0.0-rc.
|
|
68
|
+
"@shuvi/hook": "1.0.0-rc.6",
|
|
69
|
+
"@shuvi/platform-shared": "1.0.0-rc.6",
|
|
70
|
+
"@shuvi/redox": "0.0.6",
|
|
71
|
+
"@shuvi/redox-react": "0.0.6",
|
|
72
|
+
"@shuvi/router": "1.0.0-rc.6",
|
|
73
|
+
"@shuvi/router-react": "1.0.0-rc.6",
|
|
74
|
+
"@shuvi/runtime": "1.0.0-rc.6",
|
|
75
|
+
"@shuvi/service": "1.0.0-rc.6",
|
|
76
|
+
"@shuvi/shared": "1.0.0-rc.6",
|
|
77
|
+
"@shuvi/toolpack": "1.0.0-rc.6",
|
|
78
|
+
"@shuvi/utils": "1.0.0-rc.6",
|
|
79
|
+
"@shuvi/error-overlay": "1.0.0-rc.6",
|
|
76
80
|
"content-type": "1.0.4",
|
|
77
81
|
"cookie": "0.4.1",
|
|
78
82
|
"ejs": "3.1.5",
|
|
@@ -82,17 +86,18 @@
|
|
|
82
86
|
"react": "18.1.0",
|
|
83
87
|
"react-app-polyfill": "2.0.0",
|
|
84
88
|
"react-dom": "18.1.0",
|
|
89
|
+
"react-error-overlay": "6.0.8",
|
|
85
90
|
"react-refresh": "0.12.0",
|
|
91
|
+
"strip-ansi": "6.0.0",
|
|
86
92
|
"use-sync-external-store": "1.1.0"
|
|
87
93
|
},
|
|
88
94
|
"peerDependencies": {
|
|
89
|
-
"@shuvi/service": "1.0.0-rc.
|
|
95
|
+
"@shuvi/service": "1.0.0-rc.6"
|
|
90
96
|
},
|
|
91
97
|
"devDependencies": {
|
|
92
98
|
"@types/react": "18.0.9",
|
|
93
99
|
"@types/react-dom": "18.0.6",
|
|
94
100
|
"@types/react-test-renderer": "18.0.0",
|
|
95
|
-
"@shuvi/redox": "0.0.3",
|
|
96
101
|
"@testing-library/react": "^13.2.0",
|
|
97
102
|
"@types/content-type": "^1.1.5",
|
|
98
103
|
"@types/cookie": "^0.4.1",
|
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,8 +1,8 @@
|
|
|
1
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
|
|
|
@@ -1,34 +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, location,
|
|
9
|
-
WebSocket }));
|
|
10
|
-
devClient.subscribeToHmrEvent((event) => {
|
|
11
|
-
// if (obj.action === "reloadPage") {
|
|
12
|
-
// return window.location.reload();
|
|
13
|
-
// }
|
|
14
|
-
// if (obj.action === "removedPage") {
|
|
15
|
-
// const [page] = obj.data;
|
|
16
|
-
// if (page === window.next.router.pathname) {
|
|
17
|
-
// return window.location.reload();
|
|
18
|
-
// }
|
|
19
|
-
// return;
|
|
20
|
-
// }
|
|
21
|
-
// if (obj.action === "addedPage") {
|
|
22
|
-
// const [page] = obj.data;
|
|
23
|
-
// if (
|
|
24
|
-
// page === window.next.router.pathname &&
|
|
25
|
-
// typeof window.next.router.components[page] === "undefined"
|
|
26
|
-
// ) {
|
|
27
|
-
// return window.location.reload();
|
|
28
|
-
// }
|
|
29
|
-
// return;
|
|
30
|
-
// }
|
|
31
|
-
// throw new Error("Unexpected action " + obj.action);
|
|
32
|
-
});
|
|
33
|
-
return devClient;
|
|
34
|
-
};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { IServerModule as _IServerModule } from '../shared';
|
|
2
|
-
declare type ServerModule = Required<_IServerModule>;
|
|
3
|
-
export declare type GetPageDataFunction = ServerModule['getPageData'];
|
|
4
|
-
export declare type HandlePageRequestFunction = ServerModule['handlePageRequest'];
|
|
5
|
-
export declare type ModifyHtmlFunction = ServerModule['modifyHtml'];
|
|
6
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -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,18 +0,0 @@
|
|
|
1
|
-
export declare const RedoxReactPlugin: {
|
|
2
|
-
core: import("@shuvi/hook").IPluginInstance<{
|
|
3
|
-
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
4
|
-
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
5
|
-
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
6
|
-
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
7
|
-
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
8
|
-
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
9
|
-
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
10
|
-
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
11
|
-
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
12
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
|
|
13
|
-
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
14
|
-
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
15
|
-
runtime: {
|
|
16
|
-
plugin: string;
|
|
17
|
-
};
|
|
18
|
-
};
|