@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,28 @@
|
|
|
1
|
+
export { buildHtml } from './main/buildHtml';
|
|
2
|
+
export { getMiddlewares, getMiddlewaresBeforeDevMiddlewares } from './middlewares';
|
|
3
|
+
export { getPlugin as getMainPlugin } from './main';
|
|
4
|
+
export declare const featurePlugins: (import("@shuvi/hook").IPluginInstance<{
|
|
5
|
+
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
6
|
+
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
7
|
+
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
8
|
+
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
9
|
+
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
10
|
+
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
11
|
+
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
12
|
+
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
13
|
+
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>[]>;
|
|
14
|
+
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
15
|
+
} & import("@shuvi/runtime").CustomCorePluginHooks, import("@shuvi/service").IPluginContext> | {
|
|
16
|
+
core: import("@shuvi/hook").IPluginInstance<{
|
|
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/runtime").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
28
|
+
})[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.featurePlugins = exports.getMainPlugin = exports.getMiddlewaresBeforeDevMiddlewares = exports.getMiddlewares = exports.buildHtml = void 0;
|
|
7
|
+
const on_demand_compile_page_1 = __importDefault(require("./on-demand-compile-page"));
|
|
8
|
+
const html_render_1 = __importDefault(require("./html-render"));
|
|
9
|
+
const custom_server_1 = __importDefault(require("./custom-server"));
|
|
10
|
+
const model_1 = __importDefault(require("./model"));
|
|
11
|
+
const filesystem_routes_1 = __importDefault(require("./filesystem-routes"));
|
|
12
|
+
var buildHtml_1 = require("./main/buildHtml");
|
|
13
|
+
Object.defineProperty(exports, "buildHtml", { enumerable: true, get: function () { return buildHtml_1.buildHtml; } });
|
|
14
|
+
var middlewares_1 = require("./middlewares");
|
|
15
|
+
Object.defineProperty(exports, "getMiddlewares", { enumerable: true, get: function () { return middlewares_1.getMiddlewares; } });
|
|
16
|
+
Object.defineProperty(exports, "getMiddlewaresBeforeDevMiddlewares", { enumerable: true, get: function () { return middlewares_1.getMiddlewaresBeforeDevMiddlewares; } });
|
|
17
|
+
var main_1 = require("./main");
|
|
18
|
+
Object.defineProperty(exports, "getMainPlugin", { enumerable: true, get: function () { return main_1.getPlugin; } });
|
|
19
|
+
exports.featurePlugins = [
|
|
20
|
+
on_demand_compile_page_1.default,
|
|
21
|
+
filesystem_routes_1.default,
|
|
22
|
+
html_render_1.default,
|
|
23
|
+
custom_server_1.default,
|
|
24
|
+
model_1.default
|
|
25
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IPlatformContent, IPluginContext, ServerPluginInstance } from '@shuvi/service';
|
|
2
|
+
export declare const buildHtml: ({ context, serverPlugins, getMiddlewares, pathname, filename }: {
|
|
3
|
+
context: IPluginContext;
|
|
4
|
+
serverPlugins: ServerPluginInstance[];
|
|
5
|
+
getMiddlewares: IPlatformContent['getMiddlewares'];
|
|
6
|
+
pathname: string;
|
|
7
|
+
filename: string;
|
|
8
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.buildHtml = void 0;
|
|
36
|
+
const events_1 = require("events");
|
|
37
|
+
const fse = __importStar(require("fs-extra"));
|
|
38
|
+
const node_mocks_http_1 = require("node-mocks-http");
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const service_1 = require("@shuvi/service");
|
|
41
|
+
const buildHtml = ({ context, serverPlugins, getMiddlewares, pathname, filename }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
return new Promise(resolve => {
|
|
43
|
+
const request = (0, node_mocks_http_1.createRequest)({
|
|
44
|
+
url: pathname
|
|
45
|
+
});
|
|
46
|
+
const response = (0, node_mocks_http_1.createResponse)({
|
|
47
|
+
eventEmitter: events_1.EventEmitter
|
|
48
|
+
});
|
|
49
|
+
response.on('end', () => {
|
|
50
|
+
const html = response._getBuffer();
|
|
51
|
+
fse.writeFileSync(path.resolve(context.paths.buildDir, service_1.BUILD_DEFAULT_DIR, filename), html);
|
|
52
|
+
resolve();
|
|
53
|
+
});
|
|
54
|
+
(0, service_1.createShuviServer)({
|
|
55
|
+
context,
|
|
56
|
+
serverPlugins,
|
|
57
|
+
getMiddlewares
|
|
58
|
+
}).then(server => {
|
|
59
|
+
const requestHandler = server.getRequestHandler();
|
|
60
|
+
requestHandler(request, response);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
exports.buildHtml = buildHtml;
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
const path = __importStar(require("path"));
|
|
27
|
+
const fse = __importStar(require("fs-extra"));
|
|
28
|
+
const service_1 = require("@shuvi/service");
|
|
29
|
+
const generateResources = (context) => {
|
|
30
|
+
const { resolveUserFile } = context;
|
|
31
|
+
const { buildDir } = context.paths;
|
|
32
|
+
const serverManifestPath = path.join(buildDir, service_1.BUILD_SERVER_DIR, service_1.SERVER_BUILD_MANIFEST_PATH);
|
|
33
|
+
const result = [];
|
|
34
|
+
result.push([
|
|
35
|
+
'clientManifest',
|
|
36
|
+
path.join(buildDir, service_1.BUILD_DEFAULT_DIR, service_1.CLIENT_BUILD_MANIFEST_PATH)
|
|
37
|
+
]);
|
|
38
|
+
result.push(['serverManifest', serverManifestPath]);
|
|
39
|
+
result.push([
|
|
40
|
+
`server = function() {
|
|
41
|
+
var path = require('path');
|
|
42
|
+
return require(path.join(
|
|
43
|
+
'${buildDir}',
|
|
44
|
+
'${service_1.BUILD_SERVER_DIR}',
|
|
45
|
+
require('${serverManifestPath}')['bundles']['${service_1.BUILD_SERVER_FILE_SERVER}']
|
|
46
|
+
))
|
|
47
|
+
}`,
|
|
48
|
+
undefined
|
|
49
|
+
]);
|
|
50
|
+
const customDoc = resolveUserFile('document.ejs');
|
|
51
|
+
let documentPath = require.resolve('@shuvi/platform-shared/template/document.ejs');
|
|
52
|
+
if (fse.existsSync(customDoc)) {
|
|
53
|
+
documentPath = customDoc;
|
|
54
|
+
}
|
|
55
|
+
result.push([`documentPath = "${documentPath}"`, undefined]);
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
exports.default = generateResources;
|
|
@@ -0,0 +1,103 @@
|
|
|
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 shuvi_singleton_runtimeConfig_1 = require("@shuvi/platform-shared/shared/shuvi-singleton-runtimeConfig");
|
|
19
|
+
const config_1 = require("@shuvi/toolpack/lib/webpack/config");
|
|
20
|
+
const node_1 = require("@shuvi/platform-shared/node");
|
|
21
|
+
const generateResource_1 = __importDefault(require("./generateResource"));
|
|
22
|
+
const paths_1 = require("../../paths");
|
|
23
|
+
const buildHtml_1 = require("./buildHtml");
|
|
24
|
+
const middlewares_1 = require("../middlewares");
|
|
25
|
+
function getServerEntry() {
|
|
26
|
+
return {
|
|
27
|
+
[service_1.BUILD_SERVER_FILE_SERVER]: [(0, paths_1.resolvePkgFile)('esm/shuvi-app/entry/server')]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** This main plugin uses `platformContext` so that it is set to a plugin getter */
|
|
31
|
+
const getPlugin = (platformContext) => {
|
|
32
|
+
const core = (0, service_1.createPlugin)({
|
|
33
|
+
afterInit: (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const { public: publicRuntimeConfig, server: serverRuntimeConfig } = yield (0, node_1.getRuntimeConfigFromConfig)(context);
|
|
35
|
+
const serverKeys = Object.keys(serverRuntimeConfig);
|
|
36
|
+
const publicKeys = Object.keys(publicRuntimeConfig);
|
|
37
|
+
for (let index = 0; index < serverKeys.length; index++) {
|
|
38
|
+
const key = serverKeys[index];
|
|
39
|
+
const hasSameKey = publicKeys.includes(key);
|
|
40
|
+
if (hasSameKey) {
|
|
41
|
+
console.warn(`Warning: key "${key}" exist in both "runtimeConfig" and "publicRuntimeConfig". Please rename the key, or the value from "publicRuntimeConfig" will be applied.\n`);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (serverKeys) {
|
|
46
|
+
(0, shuvi_singleton_runtimeConfig_1.setRuntimeConfig)(serverRuntimeConfig);
|
|
47
|
+
}
|
|
48
|
+
if (publicKeys) {
|
|
49
|
+
(0, shuvi_singleton_runtimeConfig_1.setPublicRuntimeConfig)(publicRuntimeConfig);
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
addExtraTarget: ({ createConfig }, context) => {
|
|
53
|
+
const serverWebpackHelpers = (0, config_1.webpackHelpers)();
|
|
54
|
+
const serverChain = createConfig({
|
|
55
|
+
name: constants_1.BUNDLER_TARGET_SERVER,
|
|
56
|
+
node: true,
|
|
57
|
+
entry: getServerEntry(),
|
|
58
|
+
outputDir: service_1.BUILD_SERVER_DIR,
|
|
59
|
+
webpackHelpers: serverWebpackHelpers
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
name: constants_1.BUNDLER_TARGET_SERVER,
|
|
63
|
+
chain: serverChain
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
configWebpack: chain => {
|
|
67
|
+
chain.merge({
|
|
68
|
+
entry: {
|
|
69
|
+
[service_1.BUILD_CLIENT_RUNTIME_POLYFILL]: ['@shuvi/app/core/polyfill'],
|
|
70
|
+
[service_1.BUILD_CLIENT_RUNTIME_MAIN]: [
|
|
71
|
+
(0, paths_1.resolvePkgFile)('esm/shuvi-app/entry/client')
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return chain;
|
|
76
|
+
},
|
|
77
|
+
addRuntimeService: () => [
|
|
78
|
+
{
|
|
79
|
+
source: (0, paths_1.resolvePkgFile)('esm/shuvi-app/shuvi-runtime-index'),
|
|
80
|
+
exported: '*'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
source: (0, paths_1.resolvePkgFile)('esm/shuvi-app/shuvi-runtime-server'),
|
|
84
|
+
filepath: 'server.ts',
|
|
85
|
+
exported: '*'
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
addResource: context => (0, generateResource_1.default)(context),
|
|
89
|
+
afterBuild: (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
yield (0, buildHtml_1.buildHtml)({
|
|
91
|
+
context,
|
|
92
|
+
serverPlugins: platformContext.serverPlugins,
|
|
93
|
+
getMiddlewares: middlewares_1.getMiddlewares,
|
|
94
|
+
pathname: '/',
|
|
95
|
+
filename: 'index.html'
|
|
96
|
+
});
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
core
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
exports.getPlugin = getPlugin;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IServerPluginContext, IServerMiddleware } from '@shuvi/service';
|
|
2
|
+
import { DevMiddleware } from '@shuvi/service/lib/server/middlewares/dev/devMiddleware';
|
|
3
|
+
export declare const getMiddlewares: (context: IServerPluginContext) => IServerMiddleware[];
|
|
4
|
+
export declare const getMiddlewaresBeforeDevMiddlewares: (devMiddleware: DevMiddleware, context: IServerPluginContext) => IServerMiddleware;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMiddlewaresBeforeDevMiddlewares = exports.getMiddlewares = void 0;
|
|
4
|
+
const on_demand_compile_page_1 = require("./on-demand-compile-page");
|
|
5
|
+
const filesystem_routes_1 = require("./filesystem-routes");
|
|
6
|
+
const html_render_1 = require("./html-render");
|
|
7
|
+
let onDemandRouteManager;
|
|
8
|
+
const getMiddlewares = (context) => {
|
|
9
|
+
return [
|
|
10
|
+
onDemandRouteManager && onDemandRouteManager.ensureRoutesMiddleware(),
|
|
11
|
+
(0, filesystem_routes_1.getMiddlewareMiddleware)(context),
|
|
12
|
+
(0, filesystem_routes_1.getApiMiddleware)(context),
|
|
13
|
+
(0, html_render_1.getPageMiddleware)(context)
|
|
14
|
+
].filter(Boolean);
|
|
15
|
+
};
|
|
16
|
+
exports.getMiddlewares = getMiddlewares;
|
|
17
|
+
const getMiddlewaresBeforeDevMiddlewares = (devMiddleware, context) => {
|
|
18
|
+
onDemandRouteManager = new on_demand_compile_page_1.OnDemandRouteManager(context);
|
|
19
|
+
onDemandRouteManager.devMiddleware = devMiddleware;
|
|
20
|
+
return onDemandRouteManager.getServerMiddleware();
|
|
21
|
+
};
|
|
22
|
+
exports.getMiddlewaresBeforeDevMiddlewares = getMiddlewaresBeforeDevMiddlewares;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
core: import("@shuvi/hook").IPluginInstance<{
|
|
3
|
+
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
4
|
+
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
5
|
+
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
6
|
+
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
7
|
+
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
8
|
+
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
9
|
+
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
10
|
+
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").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
|
|
12
|
+
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
13
|
+
} & import("@shuvi/runtime").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
14
|
+
runtime: {
|
|
15
|
+
plugin: string;
|
|
16
|
+
};
|
|
17
|
+
server: import("@shuvi/service").ServerPluginInstance;
|
|
18
|
+
types: string;
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const path = __importStar(require("path"));
|
|
30
|
+
const service_1 = require("@shuvi/service");
|
|
31
|
+
const paths_1 = require("../../paths");
|
|
32
|
+
const server_1 = __importDefault(require("./server"));
|
|
33
|
+
const resolveLib = (module) => path.dirname(require.resolve(path.join(module, 'package.json')));
|
|
34
|
+
const core = (0, service_1.createPlugin)({
|
|
35
|
+
addRuntimeService: () => [
|
|
36
|
+
{
|
|
37
|
+
source: resolveLib('@shuvi/redox'),
|
|
38
|
+
exported: '*',
|
|
39
|
+
filepath: 'model.ts'
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
configWebpack: config => {
|
|
43
|
+
config.resolve.alias.set('@shuvi/redox', resolveLib('@shuvi/redox'));
|
|
44
|
+
return config;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
exports.default = {
|
|
48
|
+
core,
|
|
49
|
+
runtime: {
|
|
50
|
+
plugin: (0, paths_1.resolvePkgFile)('lib/node/features/model/runtime.js')
|
|
51
|
+
},
|
|
52
|
+
server: server_1.default,
|
|
53
|
+
types: (0, paths_1.resolvePkgFile)('lib/node/features/model/shuvi-app.d.ts')
|
|
54
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IStoreManager } from '@shuvi/redox';
|
|
2
|
+
import { IAppContext } from '@shuvi/platform-shared/shared';
|
|
3
|
+
export declare type InitRedox = (params: {
|
|
4
|
+
initialState: any;
|
|
5
|
+
ctx: IAppContext;
|
|
6
|
+
}) => IStoreManager;
|
|
7
|
+
declare const _default: import("@shuvi/platform-shared/shared").IPluginInstance<import("@shuvi/platform-shared/shared").BuiltInRuntimePluginHooks & import("@shuvi/runtime").CustomRuntimePluginHooks, void>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const redox_1 = require("@shuvi/redox");
|
|
4
|
+
const shared_1 = require("@shuvi/platform-shared/shared");
|
|
5
|
+
let currentStoreManager;
|
|
6
|
+
const isServer = typeof window === 'undefined';
|
|
7
|
+
// for client, singleton mode
|
|
8
|
+
// for server, return new store
|
|
9
|
+
const initStore = ({ initialState, ctx }) => {
|
|
10
|
+
const createStoreInstance = () => {
|
|
11
|
+
// return createRedox(initialState, {
|
|
12
|
+
// ...ctx,
|
|
13
|
+
// isServer
|
|
14
|
+
// });
|
|
15
|
+
return (0, redox_1.redox)({
|
|
16
|
+
initialState
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
// for server
|
|
20
|
+
if (isServer) {
|
|
21
|
+
return createStoreInstance();
|
|
22
|
+
}
|
|
23
|
+
// for client is singleton, just init once
|
|
24
|
+
if (currentStoreManager) {
|
|
25
|
+
return createStoreInstance();
|
|
26
|
+
}
|
|
27
|
+
currentStoreManager = createStoreInstance();
|
|
28
|
+
return currentStoreManager;
|
|
29
|
+
};
|
|
30
|
+
exports.default = (0, shared_1.createRuntimePlugin)({
|
|
31
|
+
appContext: ctx => {
|
|
32
|
+
if (!ctx.storeManager) {
|
|
33
|
+
let initialState = {};
|
|
34
|
+
if (!isServer) {
|
|
35
|
+
initialState = (0, shared_1.getPageData)('redox');
|
|
36
|
+
}
|
|
37
|
+
if (ctx.pageData && ctx.pageData.redox) {
|
|
38
|
+
initialState = ctx.pageData.redox;
|
|
39
|
+
}
|
|
40
|
+
ctx.storeManager = initStore({
|
|
41
|
+
ctx,
|
|
42
|
+
initialState
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return ctx;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const service_1 = require("@shuvi/service");
|
|
4
|
+
exports.default = (0, service_1.createServerPlugin)({
|
|
5
|
+
getPageData: appContext => {
|
|
6
|
+
const { storeManager } = appContext;
|
|
7
|
+
delete appContext.storeManager;
|
|
8
|
+
return {
|
|
9
|
+
redox: storeManager === null || storeManager === void 0 ? void 0 : storeManager.getState()
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: import("@shuvi/hook").IPluginInstance<{
|
|
2
|
+
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
3
|
+
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
4
|
+
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
5
|
+
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
6
|
+
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
7
|
+
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
8
|
+
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
9
|
+
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
10
|
+
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>[]>;
|
|
11
|
+
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
12
|
+
} & import("@shuvi/runtime").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
13
|
+
export default _default;
|
|
14
|
+
export { default as OnDemandRouteManager } from './onDemandRouteManager';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OnDemandRouteManager = void 0;
|
|
7
|
+
const service_1 = require("@shuvi/service");
|
|
8
|
+
const escapeRegExp_1 = require("@shuvi/utils/lib/escapeRegExp");
|
|
9
|
+
const module_replace_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/webpack/plugins/module-replace-plugin"));
|
|
10
|
+
const require_cache_hot_reloader_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/webpack/plugins/require-cache-hot-reloader-plugin"));
|
|
11
|
+
const constants_1 = require("@shuvi/shared/lib/constants");
|
|
12
|
+
const dumbRouteComponent = require.resolve('./emptyComponent');
|
|
13
|
+
exports.default = (0, service_1.createPlugin)({
|
|
14
|
+
configWebpack(config, _, ctx) {
|
|
15
|
+
if (ctx.mode === 'development') {
|
|
16
|
+
config.plugin('private/module-replace-plugin').use(module_replace_plugin_1.default, [
|
|
17
|
+
{
|
|
18
|
+
modules: [
|
|
19
|
+
{
|
|
20
|
+
resourceQuery: RegExp((0, escapeRegExp_1.escapeRegExp)(`?${constants_1.ROUTE_RESOURCE_QUERYSTRING}`)),
|
|
21
|
+
module: dumbRouteComponent
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
]);
|
|
26
|
+
// Even though require.cache is server only we have to clear assets from both compilations
|
|
27
|
+
// This is because the client compilation generates the build manifest that's used on the server side
|
|
28
|
+
config
|
|
29
|
+
.plugin('private/require-cache-hot-reloader')
|
|
30
|
+
.use(require_cache_hot_reloader_plugin_1.default);
|
|
31
|
+
}
|
|
32
|
+
return config;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
var onDemandRouteManager_1 = require("./onDemandRouteManager");
|
|
36
|
+
Object.defineProperty(exports, "OnDemandRouteManager", { enumerable: true, get: function () { return __importDefault(onDemandRouteManager_1).default; } });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IRequestHandlerWithNext, IServerPluginContext } from '@shuvi/service';
|
|
2
|
+
import { DevMiddleware } from '@shuvi/service/lib/server/middlewares/dev';
|
|
3
|
+
export default class OnDemandRouteManager {
|
|
4
|
+
devMiddleware: DevMiddleware | null;
|
|
5
|
+
_serverPluginContext: IServerPluginContext;
|
|
6
|
+
constructor(serverPluginContext: IServerPluginContext);
|
|
7
|
+
getServerMiddleware(): IRequestHandlerWithNext;
|
|
8
|
+
ensureRoutesMiddleware(): IRequestHandlerWithNext;
|
|
9
|
+
ensureRoutes(pathname: string): Promise<void>;
|
|
10
|
+
private _activateModules;
|
|
11
|
+
}
|