@shuvi/platform-web 0.0.1-rc.32 → 1.0.0-rc.0
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 +15 -0
- package/esm/shared/appTypes.js +1 -0
- package/esm/shared/index.d.ts +4 -0
- package/esm/shared/index.js +4 -0
- package/esm/shared/renderTypes.d.ts +44 -0
- package/esm/shared/renderTypes.js +1 -0
- package/esm/shared/routeTypes.d.ts +47 -0
- package/esm/shared/routeTypes.js +1 -0
- package/esm/shared/serverTypes.d.ts +6 -0
- package/esm/shared/serverTypes.js +1 -0
- package/esm/shuvi-app/app/client.d.ts +2 -0
- package/esm/shuvi-app/app/client.js +125 -0
- package/esm/shuvi-app/app/server.d.ts +2 -0
- package/esm/shuvi-app/app/server.js +67 -0
- package/{shuvi-app → esm/shuvi-app}/dev/webpackHotDevClient.d.ts +0 -0
- package/{shuvi-app → esm/shuvi-app}/dev/webpackHotDevClient.js +0 -0
- package/esm/shuvi-app/entry/client/app.d.ts +2 -0
- package/esm/shuvi-app/entry/client/app.js +57 -0
- package/esm/shuvi-app/entry/client/index.d.ts +2 -0
- package/esm/shuvi-app/entry/client/index.js +12 -0
- package/{shuvi-app → esm/shuvi-app}/entry/client/run.dev.d.ts +0 -0
- package/{shuvi-app → esm/shuvi-app}/entry/client/run.dev.js +2 -2
- package/{shuvi-app → esm/shuvi-app}/entry/client/run.prod.d.ts +0 -0
- package/esm/shuvi-app/entry/client/run.prod.js +3 -0
- package/{shuvi-app → esm/shuvi-app}/entry/client/setup-env.d.ts +1 -1
- package/esm/shuvi-app/entry/client/setup-env.js +17 -0
- package/esm/shuvi-app/entry/server/index.d.ts +6 -0
- package/esm/shuvi-app/entry/server/index.js +7 -0
- package/esm/shuvi-app/react/AppComponent.d.ts +4 -0
- package/esm/shuvi-app/react/AppComponent.jsx +6 -0
- package/esm/shuvi-app/react/AppContainer.d.ts +6 -0
- package/esm/shuvi-app/react/AppContainer.jsx +23 -0
- package/esm/shuvi-app/react/Error.d.ts +5 -0
- package/esm/shuvi-app/react/Error.jsx +38 -0
- package/esm/shuvi-app/react/ErrorBoundary.d.ts +16 -0
- package/esm/shuvi-app/react/ErrorBoundary.jsx +25 -0
- package/esm/shuvi-app/react/ErrorPage.d.ts +5 -0
- package/esm/shuvi-app/react/ErrorPage.jsx +7 -0
- package/esm/shuvi-app/react/Link.d.ts +7 -0
- package/esm/shuvi-app/react/Link.jsx +115 -0
- package/esm/shuvi-app/react/applicationContext.d.ts +7 -0
- package/esm/shuvi-app/react/applicationContext.jsx +10 -0
- package/esm/shuvi-app/react/dynamic.d.ts +31 -0
- package/esm/shuvi-app/react/dynamic.jsx +62 -0
- package/esm/shuvi-app/react/getRoutes.d.ts +2 -0
- package/esm/shuvi-app/react/getRoutes.js +31 -0
- package/esm/shuvi-app/react/head/head-manager-context.d.ts +2 -0
- package/esm/shuvi-app/react/head/head-manager-context.js +2 -0
- package/esm/shuvi-app/react/head/head-manager.d.ts +10 -0
- package/esm/shuvi-app/react/head/head-manager.js +93 -0
- package/esm/shuvi-app/react/head/head.d.ts +33 -0
- package/esm/shuvi-app/react/head/head.jsx +178 -0
- package/esm/shuvi-app/react/head/index.d.ts +4 -0
- package/esm/shuvi-app/react/head/index.js +4 -0
- package/esm/shuvi-app/react/head/side-effect.d.ts +30 -0
- package/esm/shuvi-app/react/head/side-effect.jsx +44 -0
- package/esm/shuvi-app/react/head/types.d.ts +15 -0
- package/esm/shuvi-app/react/head/types.js +1 -0
- package/esm/shuvi-app/react/index.d.ts +4 -0
- package/esm/shuvi-app/react/index.js +4 -0
- package/esm/shuvi-app/react/loadRouteComponent.d.ts +4 -0
- package/esm/shuvi-app/react/loadRouteComponent.jsx +9 -0
- package/esm/shuvi-app/react/loadable/index.d.ts +2 -0
- package/esm/shuvi-app/react/loadable/index.js +2 -0
- package/esm/shuvi-app/react/loadable/loadable-context.d.ts +4 -0
- package/esm/shuvi-app/react/loadable/loadable-context.js +3 -0
- package/esm/shuvi-app/react/loadable/loadable.d.ts +30 -0
- package/esm/shuvi-app/react/loadable/loadable.js +277 -0
- package/esm/shuvi-app/react/shuvi-runtime-api.d.ts +5 -0
- package/esm/shuvi-app/react/shuvi-runtime-api.js +5 -0
- package/esm/shuvi-app/react/types.d.ts +14 -0
- package/esm/shuvi-app/react/types.js +1 -0
- package/esm/shuvi-app/react/useLoaderData.d.ts +2 -0
- package/esm/shuvi-app/react/useLoaderData.js +27 -0
- package/esm/shuvi-app/react/utils/getDisplayName.d.ts +2 -0
- package/esm/shuvi-app/react/utils/getDisplayName.js +3 -0
- package/esm/shuvi-app/react/utils/requestIdleCallback.d.ts +2 -0
- package/esm/shuvi-app/react/utils/requestIdleCallback.js +20 -0
- package/esm/shuvi-app/react/utils/useIntersection.d.ts +8 -0
- package/esm/shuvi-app/react/utils/useIntersection.jsx +91 -0
- package/esm/shuvi-app/react/view/ReactView.client.d.ts +5 -0
- package/esm/shuvi-app/react/view/ReactView.client.jsx +64 -0
- package/esm/shuvi-app/react/view/ReactView.server.d.ts +4 -0
- package/esm/shuvi-app/react/view/ReactView.server.jsx +109 -0
- package/esm/shuvi-app/react/view/clientView.d.ts +3 -0
- package/esm/shuvi-app/react/view/clientView.js +2 -0
- package/esm/shuvi-app/react/view/index.d.ts +2 -0
- package/esm/shuvi-app/react/view/index.js +7 -0
- package/esm/shuvi-app/react/view/render-action.d.ts +10 -0
- package/esm/shuvi-app/react/view/render-action.js +29 -0
- package/esm/shuvi-app/react/view/serverView.d.ts +3 -0
- package/esm/shuvi-app/react/view/serverView.js +2 -0
- package/esm/shuvi-app/react/view/transformRoutes.d.ts +2 -0
- package/esm/shuvi-app/react/view/transformRoutes.js +3 -0
- package/esm/shuvi-app/shuvi-runtime-index.d.ts +4 -0
- package/esm/shuvi-app/shuvi-runtime-index.js +2 -0
- package/esm/shuvi-app/shuvi-runtime-server.d.ts +6 -0
- package/esm/shuvi-app/shuvi-runtime-server.js +1 -0
- package/lib/node/features/custom-server/hooks.d.ts +9 -0
- package/lib/node/features/custom-server/hooks.js +13 -0
- package/lib/node/features/custom-server/index.d.ts +17 -0
- package/lib/node/features/custom-server/index.js +28 -0
- package/lib/node/features/custom-server/server.d.ts +2 -0
- package/lib/node/features/custom-server/server.js +32 -0
- package/lib/node/features/custom-server/shuvi-app.d.ts +11 -0
- package/lib/node/features/custom-server/shuvi-app.js +2 -0
- package/lib/node/features/filesystem-routes/api/apiRouteHandler.d.ts +50 -0
- package/lib/node/features/filesystem-routes/api/apiRouteHandler.js +237 -0
- package/lib/node/features/filesystem-routes/api/apiRoutes.d.ts +7 -0
- package/lib/node/features/filesystem-routes/api/apiRoutes.js +35 -0
- package/lib/node/features/filesystem-routes/api/index.d.ts +3 -0
- package/lib/node/features/filesystem-routes/api/index.js +7 -0
- package/lib/node/features/filesystem-routes/api/middleware.d.ts +2 -0
- package/lib/node/features/filesystem-routes/api/middleware.js +46 -0
- package/lib/node/features/filesystem-routes/hooks.d.ts +3 -0
- package/lib/node/features/filesystem-routes/hooks.js +6 -0
- package/lib/node/features/filesystem-routes/index.d.ts +20 -0
- package/lib/node/features/filesystem-routes/index.js +182 -0
- package/lib/node/features/filesystem-routes/middleware/index.d.ts +2 -0
- package/lib/node/features/filesystem-routes/middleware/index.js +7 -0
- package/lib/node/features/filesystem-routes/middleware/middleware.d.ts +2 -0
- package/lib/node/features/filesystem-routes/middleware/middleware.js +42 -0
- package/lib/node/features/filesystem-routes/middleware/routes.d.ts +9 -0
- package/lib/node/features/filesystem-routes/middleware/routes.js +34 -0
- package/lib/node/features/filesystem-routes/page/index.d.ts +2 -0
- package/lib/node/features/filesystem-routes/page/index.js +21 -0
- package/lib/node/features/filesystem-routes/page/routes.d.ts +8 -0
- package/lib/node/features/filesystem-routes/page/routes.js +83 -0
- package/lib/node/features/filesystem-routes/page/store.d.ts +3 -0
- package/lib/node/features/filesystem-routes/page/store.js +10 -0
- package/lib/node/features/filesystem-routes/shuvi-app.d.ts +7 -0
- package/lib/node/features/filesystem-routes/shuvi-app.js +2 -0
- package/lib/node/features/html-render/index.d.ts +16 -0
- package/lib/node/features/html-render/index.js +21 -0
- package/lib/node/features/html-render/lib/generateFilesByRoutId.d.ts +3 -0
- package/lib/node/features/html-render/lib/generateFilesByRoutId.js +13 -0
- package/lib/node/features/html-render/lib/getPageMiddleware.d.ts +2 -0
- package/lib/node/features/html-render/lib/getPageMiddleware.js +56 -0
- package/lib/node/features/html-render/lib/index.d.ts +4 -0
- package/lib/node/features/html-render/lib/index.js +23 -0
- package/lib/node/features/html-render/lib/pageLoader.d.ts +1 -0
- package/lib/node/features/html-render/lib/pageLoader.js +42 -0
- package/lib/node/features/html-render/lib/renderToHTML.d.ts +6 -0
- package/lib/node/features/html-render/lib/renderToHTML.js +81 -0
- package/lib/node/features/html-render/lib/renderer/base.d.ts +17 -0
- package/lib/node/features/html-render/lib/renderer/base.js +70 -0
- package/lib/node/features/html-render/lib/renderer/htmlTag.d.ts +4 -0
- package/lib/node/features/html-render/lib/renderer/htmlTag.js +70 -0
- package/lib/node/features/html-render/lib/renderer/index.d.ts +15 -0
- package/lib/node/features/html-render/lib/renderer/index.js +48 -0
- package/lib/node/features/html-render/lib/renderer/spa.d.ts +5 -0
- package/lib/node/features/html-render/lib/renderer/spa.js +26 -0
- package/lib/node/features/html-render/lib/renderer/ssr.d.ts +5 -0
- package/lib/node/features/html-render/lib/renderer/ssr.js +70 -0
- package/lib/node/features/html-render/lib/renderer/types.d.ts +20 -0
- package/lib/node/features/html-render/lib/renderer/types.js +2 -0
- package/lib/node/features/html-render/lib/viewTemplate.d.ts +5 -0
- package/lib/node/features/html-render/lib/viewTemplate.js +37 -0
- package/lib/node/features/index.d.ts +28 -0
- package/lib/node/features/index.js +25 -0
- package/lib/node/features/main/buildHtml.d.ts +8 -0
- package/lib/node/features/main/buildHtml.js +64 -0
- package/lib/node/features/main/generateResource.d.ts +3 -0
- package/lib/node/features/main/generateResource.js +58 -0
- package/lib/node/features/main/index.d.ts +3 -0
- package/lib/node/features/main/index.js +103 -0
- package/lib/node/features/middlewares.d.ts +4 -0
- package/lib/node/features/middlewares.js +22 -0
- package/lib/node/features/model/index.d.ts +20 -0
- package/lib/node/features/model/index.js +54 -0
- package/lib/node/features/model/runtime.d.ts +8 -0
- package/lib/node/features/model/runtime.js +47 -0
- package/lib/node/features/model/server.d.ts +3 -0
- package/lib/node/features/model/server.js +12 -0
- package/lib/node/features/model/shuvi-app.d.ts +6 -0
- package/lib/node/features/model/shuvi-app.js +2 -0
- package/lib/node/features/on-demand-compile-page/emptyComponent.d.ts +1 -0
- package/lib/node/features/on-demand-compile-page/emptyComponent.js +7 -0
- package/lib/node/features/on-demand-compile-page/index.d.ts +14 -0
- package/lib/node/features/on-demand-compile-page/index.js +36 -0
- package/lib/node/features/on-demand-compile-page/onDemandRouteManager.d.ts +11 -0
- package/lib/node/features/on-demand-compile-page/onDemandRouteManager.js +104 -0
- package/lib/node/index.d.ts +4 -0
- package/lib/node/index.js +39 -0
- package/lib/{paths.d.ts → node/paths.d.ts} +1 -2
- package/lib/node/paths.js +16 -0
- package/lib/node/shuvi-node-extensions.d.ts +17 -0
- package/lib/node/shuvi-node-extensions.js +2 -0
- package/lib/node/targets/react/bundler/index.d.ts +15 -0
- package/lib/node/targets/react/bundler/index.js +102 -0
- package/lib/node/targets/react/index.d.ts +30 -0
- package/lib/node/targets/react/index.js +28 -0
- package/lib/node/targets/react/redox-react/RedoxWrapper.d.ts +8 -0
- package/lib/node/targets/react/redox-react/RedoxWrapper.js +37 -0
- package/lib/node/targets/react/redox-react/index.d.ts +17 -0
- package/lib/node/targets/react/redox-react/index.js +50 -0
- package/lib/node/targets/react/redox-react/runtime.d.ts +2 -0
- package/lib/node/targets/react/redox-react/runtime.js +18 -0
- package/lib/shared/appTypes.d.ts +15 -0
- package/lib/shared/appTypes.js +2 -0
- package/lib/shared/index.d.ts +4 -0
- package/lib/shared/index.js +20 -0
- package/lib/shared/renderTypes.d.ts +44 -0
- package/lib/shared/renderTypes.js +2 -0
- package/lib/shared/routeTypes.d.ts +47 -0
- package/lib/shared/routeTypes.js +2 -0
- package/lib/shared/serverTypes.d.ts +6 -0
- package/lib/shared/serverTypes.js +2 -0
- package/package.json +71 -17
- package/shuvi-app-extensions.d.ts +36 -0
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -44
- package/lib/paths.js +0 -7
- package/shuvi-app/application/client/create-application-factory.d.ts +0 -3
- package/shuvi-app/application/client/create-application-factory.js +0 -70
- package/shuvi-app/application/client/create-application-history-browser.d.ts +0 -1
- package/shuvi-app/application/client/create-application-history-browser.js +0 -3
- package/shuvi-app/application/client/create-application-history-hash.d.ts +0 -1
- package/shuvi-app/application/client/create-application-history-hash.js +0 -3
- package/shuvi-app/application/client/create-application-history-memory.d.ts +0 -1
- package/shuvi-app/application/client/create-application-history-memory.js +0 -3
- package/shuvi-app/application/server/create-application-spa.d.ts +0 -2
- package/shuvi-app/application/server/create-application-spa.js +0 -8
- package/shuvi-app/application/server/create-application.d.ts +0 -2
- package/shuvi-app/application/server/create-application.js +0 -25
- package/shuvi-app/entry/client/index.d.ts +0 -1
- package/shuvi-app/entry/client/index.js +0 -11
- package/shuvi-app/entry/client/run.prod.js +0 -3
- package/shuvi-app/entry/client/setup-app.d.ts +0 -3
- package/shuvi-app/entry/client/setup-app.js +0 -38
- package/shuvi-app/entry/client/setup-env.js +0 -27
- package/shuvi-app/entry/server/index.d.ts +0 -6
- package/shuvi-app/entry/server/index.js +0 -7
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { IURLParams, IURLQuery } from '@shuvi/platform-shared/shared';
|
|
2
|
+
import { IRequestHandlerWithNext } from '@shuvi/service';
|
|
3
|
+
import { IResponse, IRequest } from '@shuvi/service';
|
|
4
|
+
export interface IApiReq {
|
|
5
|
+
pathname: string;
|
|
6
|
+
query: IURLQuery;
|
|
7
|
+
params: IURLParams;
|
|
8
|
+
cookies: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
body?: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare type IApiRequest = IRequest & IApiReq;
|
|
16
|
+
export declare type Send<T> = (body: T) => void;
|
|
17
|
+
export declare type IApiRes<T = any> = {
|
|
18
|
+
send: Send<T>;
|
|
19
|
+
json: Send<T>;
|
|
20
|
+
status: (statusCode: number) => IApiRes<T>;
|
|
21
|
+
redirect(url: string): IApiRes<T>;
|
|
22
|
+
redirect(status: number, url: string): IApiRes<T>;
|
|
23
|
+
};
|
|
24
|
+
export declare type IApiResponse<T = any> = IResponse & IApiRes<T>;
|
|
25
|
+
export declare type IApiRequestHandler<T = any> = (req: IApiRequest, res: IApiResponse<T>) => void | Promise<void>;
|
|
26
|
+
export interface IApiConfig {
|
|
27
|
+
apiConfig?: {
|
|
28
|
+
bodyParser?: {
|
|
29
|
+
sizeLimit: number | string;
|
|
30
|
+
} | boolean;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface IApiHandler {
|
|
34
|
+
default: IApiRequestHandler;
|
|
35
|
+
config?: IApiConfig;
|
|
36
|
+
}
|
|
37
|
+
export interface IMiddlewareConfig {
|
|
38
|
+
default: IRequestHandlerWithNext;
|
|
39
|
+
}
|
|
40
|
+
export declare type IApiRoutes = {
|
|
41
|
+
path: string;
|
|
42
|
+
api: IApiHandler;
|
|
43
|
+
}[];
|
|
44
|
+
export declare type IMiddlewareRoutes = {
|
|
45
|
+
path: string;
|
|
46
|
+
middleware: IMiddlewareConfig;
|
|
47
|
+
}[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ServerPluginConstructor } from '@shuvi/service';
|
|
2
|
+
export interface IServerModule {
|
|
3
|
+
getPageData?: ServerPluginConstructor['getPageData'];
|
|
4
|
+
handlePageRequest?: ServerPluginConstructor['handlePageRequest'];
|
|
5
|
+
modifyHtml?: ServerPluginConstructor['modifyHtml'];
|
|
6
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-web",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -11,28 +11,82 @@
|
|
|
11
11
|
"sideEffects": [
|
|
12
12
|
"**/shuvi-app/entry/client/**"
|
|
13
13
|
],
|
|
14
|
-
"main": "./lib/index.js",
|
|
15
|
-
"module": "./es/index.js",
|
|
16
14
|
"files": [
|
|
17
15
|
"lib",
|
|
18
|
-
"
|
|
16
|
+
"esm",
|
|
17
|
+
"types",
|
|
18
|
+
"shuvi-app-extensions.d.ts"
|
|
19
19
|
],
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"default": "./lib/node/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./node": {
|
|
25
|
+
"default": "./lib/node/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./node/*": {
|
|
28
|
+
"default": "./lib/node/*.js"
|
|
29
|
+
},
|
|
30
|
+
"./shared": {
|
|
31
|
+
"default": "./esm/shared/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./shared/*": {
|
|
34
|
+
"default": "./esm/shared/*.js"
|
|
35
|
+
},
|
|
36
|
+
"./shuvi-app": {
|
|
37
|
+
"default": "./esm/shuvi-app/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./shuvi-app/*": {
|
|
40
|
+
"default": [
|
|
41
|
+
"./esm/shuvi-app/*.js",
|
|
42
|
+
"./esm/shuvi-app/*.jsx"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
"./shuvi-app-extensions.d.ts": "./shuvi-app-extensions.d.ts"
|
|
28
46
|
},
|
|
29
47
|
"engines": {
|
|
30
48
|
"node": ">= 12.0.0"
|
|
31
49
|
},
|
|
32
50
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@shuvi/
|
|
35
|
-
"@shuvi/
|
|
36
|
-
"@shuvi/
|
|
51
|
+
"@next/react-refresh-utils": "12.1.6",
|
|
52
|
+
"@shuvi/hook": "1.0.0-rc.0",
|
|
53
|
+
"@shuvi/platform-shared": "1.0.0-rc.0",
|
|
54
|
+
"@shuvi/redox-react": "0.0.3",
|
|
55
|
+
"@shuvi/router": "1.0.0-rc.0",
|
|
56
|
+
"@shuvi/router-react": "1.0.0-rc.0",
|
|
57
|
+
"@shuvi/runtime": "1.0.0-rc.0",
|
|
58
|
+
"@shuvi/service": "1.0.0-rc.0",
|
|
59
|
+
"@shuvi/shared": "1.0.0-rc.0",
|
|
60
|
+
"@shuvi/toolpack": "1.0.0-rc.0",
|
|
61
|
+
"@shuvi/utils": "1.0.0-rc.0",
|
|
62
|
+
"content-type": "1.0.4",
|
|
63
|
+
"cookie": "0.4.1",
|
|
64
|
+
"ejs": "3.1.5",
|
|
65
|
+
"fs-extra": "9.0.1",
|
|
66
|
+
"node-mocks-http": "1.11.0",
|
|
67
|
+
"raw-body": "2.4.1",
|
|
68
|
+
"react": "18.1.0",
|
|
69
|
+
"react-app-polyfill": "2.0.0",
|
|
70
|
+
"react-dom": "18.1.0",
|
|
71
|
+
"react-refresh": "0.12.0",
|
|
72
|
+
"use-sync-external-store": "1.1.0"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@shuvi/redox": "0.0.3",
|
|
76
|
+
"@testing-library/react": "^10.0.2",
|
|
77
|
+
"@types/content-type": "^1.1.5",
|
|
78
|
+
"@types/cookie": "^0.4.1",
|
|
79
|
+
"@types/ejs": "^3.1.0",
|
|
80
|
+
"@types/raw-body": "^2.3.0",
|
|
81
|
+
"webpack": "5.73.0"
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"dev": "run-p watch:*",
|
|
85
|
+
"watch:esm": "tsc -p tsconfig.build.browser.json -w",
|
|
86
|
+
"watch:cjs": "tsc -p tsconfig.build.node.json -w",
|
|
87
|
+
"prebuild": "rimraf lib esm types",
|
|
88
|
+
"build": "run-p build:*",
|
|
89
|
+
"build:esm": "tsc -p tsconfig.build.browser.json",
|
|
90
|
+
"build:cjs": "tsc -p tsconfig.build.node.json"
|
|
37
91
|
}
|
|
38
|
-
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference types="@shuvi/platform-shared/shuvi-app-extensions.d.ts" />
|
|
2
|
+
|
|
3
|
+
declare module '@shuvi/app/files/routes' {
|
|
4
|
+
import { IRawPageRouteRecord } from '@shuvi/platform-shared/shared';
|
|
5
|
+
declare const routes: IRawPageRouteRecord[];
|
|
6
|
+
export default routes;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
declare module '@shuvi/app/files/routerConfig' {
|
|
10
|
+
import { ILoaderOptions } from '@shuvi/platform-shared/shared/loader';
|
|
11
|
+
export const historyMode: 'browser' | 'hash';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '@shuvi/app/files/page-loaders' {
|
|
15
|
+
import { IRouteLoaderContext } from '@shuvi/platform-shared/shared';
|
|
16
|
+
import { Loader } from '@shuvi/platform-shared/shared';
|
|
17
|
+
|
|
18
|
+
const loaders: Record<string, Loader>;
|
|
19
|
+
export default loaders;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare module '@shuvi/app/files/apiRoutes' {
|
|
23
|
+
import { IApiRoutes } from '@shuvi/platform-web/shared';
|
|
24
|
+
declare const apiRoutes: IApiRoutes[];
|
|
25
|
+
export default apiRoutes;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare module '@shuvi/app/files/middlewareRoutes' {
|
|
29
|
+
import { IMiddlewareRoutes } from '@shuvi/platform-web/shared';
|
|
30
|
+
declare const middlewareRoutes: IMiddlewareRoutes[];
|
|
31
|
+
export default middlewareRoutes;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '@shuvi/app/files/user/server' {
|
|
35
|
+
export {};
|
|
36
|
+
}
|
package/lib/index.d.ts
DELETED
package/lib/index.js
DELETED
|
@@ -1,44 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const paths_1 = require("./paths");
|
|
13
|
-
const platform = {
|
|
14
|
-
install(api) {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
// set application and entry
|
|
17
|
-
const { ssr, router: { history } } = api.config;
|
|
18
|
-
let ApplicationModule;
|
|
19
|
-
if (history === 'browser') {
|
|
20
|
-
ApplicationModule = 'create-application-history-browser';
|
|
21
|
-
}
|
|
22
|
-
else if (history === 'hash') {
|
|
23
|
-
ApplicationModule = 'create-application-history-hash';
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
ApplicationModule = 'create-application-history-memory';
|
|
27
|
-
}
|
|
28
|
-
api.setServerModule({
|
|
29
|
-
application: paths_1.resolveAppFile('application', 'server', ssr ? 'create-application' : 'create-application-spa'),
|
|
30
|
-
entry: paths_1.resolveAppFile('entry', 'server')
|
|
31
|
-
});
|
|
32
|
-
api.setClientModule({
|
|
33
|
-
application: paths_1.resolveAppFile('application', 'client', ApplicationModule),
|
|
34
|
-
entry: paths_1.resolveAppFile('entry', 'client')
|
|
35
|
-
});
|
|
36
|
-
// install framework
|
|
37
|
-
const { framework = 'react' } = api.config.platform || {};
|
|
38
|
-
const frameworkInstance = require(`@shuvi/platform-web-${framework}`)
|
|
39
|
-
.default;
|
|
40
|
-
frameworkInstance.install(api);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
exports.default = platform;
|
package/lib/paths.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const path_1 = require("path");
|
|
4
|
-
exports.PACKAGE_DIR = path_1.dirname(require.resolve('@shuvi/platform-web/package.json'));
|
|
5
|
-
exports.resolveAppFile = (...paths) => `${path_1.resolve(exports.PACKAGE_DIR, 'shuvi-app', ...paths)}`;
|
|
6
|
-
exports.resolveDep = (module) => require.resolve(module);
|
|
7
|
-
exports.resolveLib = (module) => path_1.dirname(exports.resolveDep(path_1.join(module, 'package.json')));
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import AppComponent from '@shuvi/app/core/app';
|
|
11
|
-
import routes from '@shuvi/app/core/routes';
|
|
12
|
-
import { getRoutes } from '@shuvi/app/core/platform';
|
|
13
|
-
import { Application } from '@shuvi/platform-core';
|
|
14
|
-
import runPlugins from '@shuvi/platform-core/lib/runPlugins';
|
|
15
|
-
import { createRouter } from '@shuvi/router';
|
|
16
|
-
let app;
|
|
17
|
-
let history;
|
|
18
|
-
let appContext;
|
|
19
|
-
export const createFactory = (historyCreater) => {
|
|
20
|
-
const create = function (context, options) {
|
|
21
|
-
appContext = context;
|
|
22
|
-
// app is a singleton in client side
|
|
23
|
-
if (app) {
|
|
24
|
-
return app;
|
|
25
|
-
}
|
|
26
|
-
history = historyCreater();
|
|
27
|
-
const router = createRouter({
|
|
28
|
-
history,
|
|
29
|
-
routes: getRoutes(routes, context)
|
|
30
|
-
});
|
|
31
|
-
app = new Application({
|
|
32
|
-
AppComponent,
|
|
33
|
-
router,
|
|
34
|
-
context,
|
|
35
|
-
render: options.render
|
|
36
|
-
});
|
|
37
|
-
runPlugins(app);
|
|
38
|
-
return app;
|
|
39
|
-
};
|
|
40
|
-
return create;
|
|
41
|
-
};
|
|
42
|
-
if (module.hot) {
|
|
43
|
-
module.hot.accept([
|
|
44
|
-
'@shuvi/app/entry.client',
|
|
45
|
-
'@shuvi/app/core/app',
|
|
46
|
-
'@shuvi/app/core/routes',
|
|
47
|
-
'@shuvi/app/user/plugin'
|
|
48
|
-
], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
const rerender = () => {
|
|
50
|
-
const AppComponent = require('@shuvi/app/core/app').default;
|
|
51
|
-
const routes = require('@shuvi/app/core/routes').default;
|
|
52
|
-
const router = createRouter({
|
|
53
|
-
history,
|
|
54
|
-
routes: getRoutes(routes, appContext)
|
|
55
|
-
});
|
|
56
|
-
app.rerender({ router, AppComponent });
|
|
57
|
-
};
|
|
58
|
-
// to solve routing problem, we need to rerender routes
|
|
59
|
-
// wait navigation complete only rerender to ensure getInitialProps is called
|
|
60
|
-
if (__SHUVI.router._pending) {
|
|
61
|
-
const removelistener = __SHUVI.router.afterEach(() => {
|
|
62
|
-
rerender();
|
|
63
|
-
removelistener();
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
rerender();
|
|
68
|
-
}
|
|
69
|
-
}));
|
|
70
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const create: import("@shuvi/service/lib/types/runtime").ApplicationCreater;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const create: import("@shuvi/service/lib/types/runtime").ApplicationCreater;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const create: import("@shuvi/service/lib/types/runtime").ApplicationCreater;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import AppComponent from '@shuvi/app/core/app';
|
|
2
|
-
import routes from '@shuvi/app/core/routes';
|
|
3
|
-
import { getRoutes } from '@shuvi/app/core/platform';
|
|
4
|
-
import { Application } from '@shuvi/platform-core';
|
|
5
|
-
import runPlugins from '@shuvi/platform-core/lib/runPlugins';
|
|
6
|
-
import { createRouter, createMemoryHistory } from '@shuvi/router';
|
|
7
|
-
export const create = function (context, options) {
|
|
8
|
-
const { req } = context;
|
|
9
|
-
const history = createMemoryHistory({
|
|
10
|
-
initialEntries: [(req && req.url) || '/'],
|
|
11
|
-
initialIndex: 0
|
|
12
|
-
});
|
|
13
|
-
const router = createRouter({
|
|
14
|
-
history,
|
|
15
|
-
routes: getRoutes(routes, context)
|
|
16
|
-
});
|
|
17
|
-
const app = new Application({
|
|
18
|
-
AppComponent,
|
|
19
|
-
router,
|
|
20
|
-
context,
|
|
21
|
-
render: options.render
|
|
22
|
-
});
|
|
23
|
-
runPlugins(app);
|
|
24
|
-
return app;
|
|
25
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './setup-env';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This is the shuvi client-side entry
|
|
2
|
-
// IMPORTANT: `setup-env` must be runned before any other codes
|
|
3
|
-
import './setup-env';
|
|
4
|
-
import { rerender } from './setup-app';
|
|
5
|
-
window.__SHUVI = Object.assign(Object.assign({}, (window.__SHUVI || {})), { rerender });
|
|
6
|
-
if (process.env.NODE_ENV === 'development') {
|
|
7
|
-
require('./run.dev');
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
require('./run.prod');
|
|
11
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { CLIENT_CONTAINER_ID } from '@shuvi/shared/lib/constants';
|
|
11
|
-
// renderer must be imported before application
|
|
12
|
-
// we need to init init renderer before import AppComponent
|
|
13
|
-
import { view } from '@shuvi/app/core/platform';
|
|
14
|
-
import { create } from '@shuvi/app/core/client/application';
|
|
15
|
-
import { getAppData } from '@shuvi/platform-core/lib/helper';
|
|
16
|
-
const appData = getAppData();
|
|
17
|
-
const { routeProps = {} } = appData;
|
|
18
|
-
const app = create({
|
|
19
|
-
pageData: appData.pageData || {},
|
|
20
|
-
routeProps
|
|
21
|
-
}, {
|
|
22
|
-
render({ appContext, AppComponent, router }) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const appContainer = document.getElementById(CLIENT_CONTAINER_ID);
|
|
25
|
-
view.renderApp({
|
|
26
|
-
AppComponent: AppComponent,
|
|
27
|
-
router: router,
|
|
28
|
-
appData,
|
|
29
|
-
appContainer,
|
|
30
|
-
appContext
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
const rerender = () => {
|
|
36
|
-
app.rerender();
|
|
37
|
-
};
|
|
38
|
-
export { app, rerender };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Following codes should be run beforen any other codes.
|
|
3
|
-
* Do not try to import any module from `@shuvi/app`.
|
|
4
|
-
*/
|
|
5
|
-
import { IDENTITY_RUNTIME_PUBLICPATH, IDENTITY_SSR_RUNTIME_PUBLICPATH } from '@shuvi/shared/lib/constants';
|
|
6
|
-
import setRuntimeConfig from '@shuvi/app/core/setRuntimeConfig';
|
|
7
|
-
import runtimeConfig from '@shuvi/app/core/runtimeConfig';
|
|
8
|
-
import { getAppData } from '@shuvi/platform-core/lib/helper';
|
|
9
|
-
const win = window;
|
|
10
|
-
// server runtime public path
|
|
11
|
-
if (win[IDENTITY_SSR_RUNTIME_PUBLICPATH]) {
|
|
12
|
-
__webpack_public_path__ = win[IDENTITY_SSR_RUNTIME_PUBLICPATH];
|
|
13
|
-
}
|
|
14
|
-
// client runtime public path
|
|
15
|
-
if (win[IDENTITY_RUNTIME_PUBLICPATH]) {
|
|
16
|
-
__webpack_public_path__ = win[IDENTITY_RUNTIME_PUBLICPATH];
|
|
17
|
-
}
|
|
18
|
-
// === set runtime config ===
|
|
19
|
-
const appData = getAppData();
|
|
20
|
-
// build-time config for none-ssr
|
|
21
|
-
if (runtimeConfig) {
|
|
22
|
-
setRuntimeConfig(runtimeConfig);
|
|
23
|
-
}
|
|
24
|
-
// runtime config from server
|
|
25
|
-
if (appData.runtimeConfig) {
|
|
26
|
-
setRuntimeConfig(appData.runtimeConfig);
|
|
27
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import * as server from '@shuvi/app/user/server';
|
|
2
|
-
import * as document from '@shuvi/app/user/document';
|
|
3
|
-
import * as application from '@shuvi/app/core/server/application';
|
|
4
|
-
import { default as apiRoutes } from '@shuvi/app/core/apiRoutes';
|
|
5
|
-
export { server, document, application, apiRoutes };
|
|
6
|
-
export { view } from '@shuvi/app/core/platform';
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// This is the shuvi server-side main module exports collection
|
|
2
|
-
import * as server from '@shuvi/app/user/server';
|
|
3
|
-
import * as document from '@shuvi/app/user/document';
|
|
4
|
-
import * as application from '@shuvi/app/core/server/application';
|
|
5
|
-
import { default as apiRoutes } from '@shuvi/app/core/apiRoutes';
|
|
6
|
-
export { server, document, application, apiRoutes };
|
|
7
|
-
export { view } from '@shuvi/app/core/platform';
|