@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,104 @@
|
|
|
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
|
+
const router_1 = require("@shuvi/router");
|
|
16
|
+
const constants_1 = require("@shuvi/shared/lib/constants");
|
|
17
|
+
const resources_1 = require("@shuvi/service/lib/resources");
|
|
18
|
+
const module_replace_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/webpack/plugins/module-replace-plugin"));
|
|
19
|
+
const index_1 = require("../filesystem-routes/index");
|
|
20
|
+
function acceptsHtml(header, { htmlAcceptHeaders = ['text/html', '*/*'] } = {}) {
|
|
21
|
+
for (var i = 0; i < htmlAcceptHeaders.length; i++) {
|
|
22
|
+
if (header.indexOf(htmlAcceptHeaders[i]) !== -1) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
class OnDemandRouteManager {
|
|
29
|
+
constructor(serverPluginContext) {
|
|
30
|
+
this.devMiddleware = null;
|
|
31
|
+
this._serverPluginContext = serverPluginContext;
|
|
32
|
+
}
|
|
33
|
+
getServerMiddleware() {
|
|
34
|
+
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
const pathname = req.pathname;
|
|
36
|
+
if (!pathname.startsWith(this._serverPluginContext.assetPublicPath)) {
|
|
37
|
+
return next();
|
|
38
|
+
}
|
|
39
|
+
if (!this.devMiddleware) {
|
|
40
|
+
return next();
|
|
41
|
+
}
|
|
42
|
+
const chunkName = pathname.replace(this._serverPluginContext.assetPublicPath, '');
|
|
43
|
+
const chunkInitiatorModule = resources_1.clientManifest.chunkRequest[chunkName];
|
|
44
|
+
if (!chunkInitiatorModule) {
|
|
45
|
+
return next();
|
|
46
|
+
}
|
|
47
|
+
const task = module_replace_plugin_1.default.restoreModule(chunkInitiatorModule);
|
|
48
|
+
if (task) {
|
|
49
|
+
yield this.devMiddleware.invalidate();
|
|
50
|
+
yield task;
|
|
51
|
+
}
|
|
52
|
+
next();
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
ensureRoutesMiddleware() {
|
|
56
|
+
return (req, _res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const accept = req.headers['accept'];
|
|
58
|
+
if (req.method !== 'GET') {
|
|
59
|
+
return next();
|
|
60
|
+
}
|
|
61
|
+
else if (!accept) {
|
|
62
|
+
return next();
|
|
63
|
+
}
|
|
64
|
+
else if (accept.indexOf('application/json') === 0) {
|
|
65
|
+
return next();
|
|
66
|
+
}
|
|
67
|
+
else if (!acceptsHtml(accept, { htmlAcceptHeaders: ['text/html'] })) {
|
|
68
|
+
return next();
|
|
69
|
+
}
|
|
70
|
+
let err = null;
|
|
71
|
+
try {
|
|
72
|
+
yield this.ensureRoutes(req.pathname || '/');
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
err = error;
|
|
76
|
+
}
|
|
77
|
+
next(err);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
ensureRoutes(pathname) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const matchedRoutes = (0, router_1.matchRoutes)((0, index_1.getRoutes)(), pathname) || [];
|
|
83
|
+
const modulesToActivate = matchedRoutes
|
|
84
|
+
.map(({ route: { component } }) => component ? `${component}?${constants_1.ROUTE_RESOURCE_QUERYSTRING}` : '')
|
|
85
|
+
.filter(Boolean);
|
|
86
|
+
return this._activateModules(modulesToActivate);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
_activateModules(modules) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
if (!this.devMiddleware) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const tasks = modules
|
|
95
|
+
.map(m => module_replace_plugin_1.default.restoreModule(m))
|
|
96
|
+
.filter(Boolean);
|
|
97
|
+
if (tasks.length) {
|
|
98
|
+
this.devMiddleware.invalidate();
|
|
99
|
+
yield Promise.all(tasks);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
exports.default = OnDemandRouteManager;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 node_1 = require("@shuvi/platform-shared/node");
|
|
13
|
+
const features_1 = require("./features");
|
|
14
|
+
require("./shuvi-node-extensions");
|
|
15
|
+
const paths_1 = require("./paths");
|
|
16
|
+
const platform = ({ framework = 'react' } = {}, platformContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const mainPlugin = (0, features_1.getMainPlugin)(platformContext);
|
|
18
|
+
const platformFramework = require(`./targets/${framework}`).default;
|
|
19
|
+
const platformFrameworkContent = yield platformFramework();
|
|
20
|
+
const platformModule = platformFrameworkContent.platformModule;
|
|
21
|
+
const polyfills = platformFrameworkContent.polyfills;
|
|
22
|
+
const getPresetRuntimeFiles = (0, node_1.getPresetRuntimeFilesCreator)(platformModule, polyfills);
|
|
23
|
+
return {
|
|
24
|
+
types: [
|
|
25
|
+
(0, paths_1.resolvePkgFile)('shuvi-env.d.ts'),
|
|
26
|
+
(0, paths_1.resolvePkgFile)('shuvi-image.d.ts')
|
|
27
|
+
],
|
|
28
|
+
plugins: [
|
|
29
|
+
...node_1.SharedPlugins,
|
|
30
|
+
mainPlugin,
|
|
31
|
+
...features_1.featurePlugins,
|
|
32
|
+
...platformFrameworkContent.plugins
|
|
33
|
+
],
|
|
34
|
+
getPresetRuntimeFiles,
|
|
35
|
+
getMiddlewares: features_1.getMiddlewares,
|
|
36
|
+
getMiddlewaresBeforeDevMiddlewares: features_1.getMiddlewaresBeforeDevMiddlewares
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
exports.default = platform;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const PACKAGE_DIR: string;
|
|
2
|
-
export declare const resolveAppFile: (...paths: string[]) => string;
|
|
3
1
|
export declare const resolveDep: (module: string) => string;
|
|
4
2
|
export declare const resolveLib: (module: string) => string;
|
|
3
|
+
export declare const resolvePkgFile: (...paths: string[]) => string;
|
|
@@ -0,0 +1,16 @@
|
|
|
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.resolvePkgFile = exports.resolveLib = exports.resolveDep = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const PACKAGE_DIR = path_1.default.resolve(__dirname, '..', '..');
|
|
9
|
+
// export const resolveToModulePath = (...paths: string[]) =>
|
|
10
|
+
// `@shuvi/platform-web/${paths.join('/')}`;
|
|
11
|
+
const resolveDep = (module) => require.resolve(module);
|
|
12
|
+
exports.resolveDep = resolveDep;
|
|
13
|
+
const resolveLib = (module) => path_1.default.dirname((0, exports.resolveDep)(path_1.default.join(module, 'package.json')));
|
|
14
|
+
exports.resolveLib = resolveLib;
|
|
15
|
+
const resolvePkgFile = (...paths) => path_1.default.join(PACKAGE_DIR, ...paths);
|
|
16
|
+
exports.resolvePkgFile = resolvePkgFile;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CreateAppServer, IServerModule, IApiRoutes, IMiddlewareRoutes } from '../shared';
|
|
2
|
+
import { IManifest } from '@shuvi/toolpack/lib/webpack/types';
|
|
3
|
+
import { IViewServer } from './features/html-render';
|
|
4
|
+
declare module '@shuvi/service/lib/resources' {
|
|
5
|
+
const server: {
|
|
6
|
+
server: IServerModule;
|
|
7
|
+
apiRoutes: IApiRoutes;
|
|
8
|
+
middlewareRoutes: IMiddlewareRoutes;
|
|
9
|
+
application: {
|
|
10
|
+
createApp: CreateAppServer;
|
|
11
|
+
};
|
|
12
|
+
view: IViewServer;
|
|
13
|
+
};
|
|
14
|
+
const documentPath: string;
|
|
15
|
+
const clientManifest: IManifest;
|
|
16
|
+
const serverManifest: IManifest;
|
|
17
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,102 @@
|
|
|
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 ReactRefreshWebpackPlugin_1 = __importDefault(require("@next/react-refresh-utils/ReactRefreshWebpackPlugin"));
|
|
32
|
+
const constants_1 = require("@shuvi/shared/lib/constants");
|
|
33
|
+
const webpack_1 = require("webpack");
|
|
34
|
+
const configWebpack = (config, { name, webpack }, context) => {
|
|
35
|
+
const resolveLocal = (m, sub) => {
|
|
36
|
+
const pck = path.dirname(require.resolve(`${m}/package.json`));
|
|
37
|
+
return sub ? `${pck}/${sub}` : pck;
|
|
38
|
+
};
|
|
39
|
+
const resolveUser = (m) => path.join(context.paths.rootDir, 'node_modules', m);
|
|
40
|
+
const isReactVersionAfter18 = () => {
|
|
41
|
+
let version = '';
|
|
42
|
+
try {
|
|
43
|
+
version = require(resolveUser('react-dom')).version;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
version = require(resolveLocal('react-dom')).version;
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
}
|
|
50
|
+
const majorVersion = parseInt(version.split('.')[0] || '', 10);
|
|
51
|
+
return majorVersion >= 18;
|
|
52
|
+
};
|
|
53
|
+
config.resolve.alias.set('@shuvi/service', resolveLocal('@shuvi/service'));
|
|
54
|
+
config.resolve.alias.set('@shuvi/router$', resolveLocal('@shuvi/router'));
|
|
55
|
+
config.resolve.alias.set('@shuvi/router-react$', resolveLocal('@shuvi/router-react'));
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
config.resolve.alias.set('react$', [
|
|
58
|
+
resolveUser('react'),
|
|
59
|
+
resolveLocal('react')
|
|
60
|
+
]);
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
config.resolve.alias.set('react/jsx-runtime$', [
|
|
63
|
+
resolveUser('react/jsx-runtime'),
|
|
64
|
+
resolveLocal('react', 'jsx-runtime')
|
|
65
|
+
]);
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
config.resolve.alias.set('react-dom$', [
|
|
68
|
+
resolveUser('react-dom'),
|
|
69
|
+
resolveLocal('react-dom')
|
|
70
|
+
]);
|
|
71
|
+
if (name === constants_1.BUNDLER_DEFAULT_TARGET && context.mode === 'development') {
|
|
72
|
+
config.module
|
|
73
|
+
.rule('main')
|
|
74
|
+
.oneOf('js')
|
|
75
|
+
.use('react-refresh-loader')
|
|
76
|
+
.loader(require.resolve('@next/react-refresh-utils/loader'))
|
|
77
|
+
.before('shuvi-swc-loader');
|
|
78
|
+
config
|
|
79
|
+
.plugin('react-refresh-plugin')
|
|
80
|
+
.use(ReactRefreshWebpackPlugin_1.default, [webpack]);
|
|
81
|
+
config.plugin('version-env-plugin').use(webpack_1.DefinePlugin, [
|
|
82
|
+
{
|
|
83
|
+
'process.env.__SHUVI__AFTER__REACT__18__': JSON.stringify(isReactVersionAfter18())
|
|
84
|
+
}
|
|
85
|
+
]);
|
|
86
|
+
}
|
|
87
|
+
return config;
|
|
88
|
+
};
|
|
89
|
+
exports.default = {
|
|
90
|
+
core: (0, service_1.createPlugin)({
|
|
91
|
+
configWebpack,
|
|
92
|
+
addEntryCode(context) {
|
|
93
|
+
if (context.mode === 'development') {
|
|
94
|
+
const fastRefreshRuntime = require.resolve(`@next/react-refresh-utils/runtime`);
|
|
95
|
+
return `import "${fastRefreshRuntime}"`;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return '';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare const platformWebReact: () => {
|
|
2
|
+
plugins: (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
|
+
core: import("@shuvi/hook").IPluginInstance<{
|
|
15
|
+
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
16
|
+
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
17
|
+
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
18
|
+
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
19
|
+
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
20
|
+
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
21
|
+
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
22
|
+
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
23
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<any, any>[]>;
|
|
24
|
+
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
25
|
+
} & import("@shuvi/runtime").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
26
|
+
})[];
|
|
27
|
+
platformModule: string;
|
|
28
|
+
polyfills: string[];
|
|
29
|
+
};
|
|
30
|
+
export default platformWebReact;
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
const service_1 = require("@shuvi/service");
|
|
7
|
+
const bundler_1 = __importDefault(require("./bundler"));
|
|
8
|
+
const redox_react_1 = require("./redox-react");
|
|
9
|
+
const paths_1 = require("../../paths");
|
|
10
|
+
const webReactMainPlugin = (0, service_1.createPlugin)({
|
|
11
|
+
addRuntimeService: () => [
|
|
12
|
+
{
|
|
13
|
+
source: (0, paths_1.resolvePkgFile)('esm/shuvi-app/react/shuvi-runtime-api'),
|
|
14
|
+
exported: '*'
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
const platformWebReact = () => {
|
|
19
|
+
return {
|
|
20
|
+
plugins: [webReactMainPlugin, bundler_1.default, redox_react_1.RedoxReactPlugin],
|
|
21
|
+
platformModule: (0, paths_1.resolvePkgFile)('esm/shuvi-app/react/index'),
|
|
22
|
+
polyfills: [
|
|
23
|
+
(0, paths_1.resolveDep)('react-app-polyfill/ie11'),
|
|
24
|
+
(0, paths_1.resolveDep)('react-app-polyfill/stable')
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.default = platformWebReact;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.RedoxWrapper = void 0;
|
|
27
|
+
const React = __importStar(require("react"));
|
|
28
|
+
const redox_react_1 = require("@shuvi/redox-react");
|
|
29
|
+
const RedoxWrapper = (App, appContext) => {
|
|
30
|
+
function RedoxAppWrapper(appProps) {
|
|
31
|
+
return (React.createElement(redox_react_1.RedoxRoot, { storeManager: appContext.storeManager },
|
|
32
|
+
React.createElement(App, Object.assign({}, appProps))));
|
|
33
|
+
}
|
|
34
|
+
RedoxAppWrapper.displayName = 'RedoxAppWrapper';
|
|
35
|
+
return RedoxAppWrapper;
|
|
36
|
+
};
|
|
37
|
+
exports.RedoxWrapper = RedoxWrapper;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const RedoxReactPlugin: {
|
|
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
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.RedoxReactPlugin = void 0;
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const service_1 = require("@shuvi/service");
|
|
29
|
+
const paths_1 = require("../../../paths");
|
|
30
|
+
// todo: optimize this
|
|
31
|
+
const runtimePath = require.resolve(path.join(__dirname, '../../../../../lib/node/targets/react/redox-react/runtime'));
|
|
32
|
+
const core = (0, service_1.createPlugin)({
|
|
33
|
+
addRuntimeService: () => [
|
|
34
|
+
{
|
|
35
|
+
source: path.dirname(require.resolve('@shuvi/redox-react/package.json')),
|
|
36
|
+
exported: '*',
|
|
37
|
+
filepath: 'model.ts'
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
configWebpack: config => {
|
|
41
|
+
config.resolve.alias.set('@shuvi/redox', (0, paths_1.resolveLib)('@shuvi/redox'));
|
|
42
|
+
return config;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
exports.RedoxReactPlugin = {
|
|
46
|
+
core,
|
|
47
|
+
runtime: {
|
|
48
|
+
plugin: runtimePath
|
|
49
|
+
}
|
|
50
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
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 shared_1 = require("@shuvi/platform-shared/shared");
|
|
13
|
+
const RedoxWrapper_1 = require("./RedoxWrapper");
|
|
14
|
+
exports.default = (0, shared_1.createRuntimePlugin)({
|
|
15
|
+
appComponent: (App, appContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
return (0, RedoxWrapper_1.RedoxWrapper)(App, appContext);
|
|
17
|
+
})
|
|
18
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IRequest, IRawPageRouteRecord, IAppData, IAppState } from '@shuvi/platform-shared/shared';
|
|
2
|
+
import { Application } from '@shuvi/platform-shared/shuvi-app/application';
|
|
3
|
+
export interface CreateAppServer {
|
|
4
|
+
(options: {
|
|
5
|
+
req: IRequest;
|
|
6
|
+
ssr: boolean;
|
|
7
|
+
}): Application;
|
|
8
|
+
}
|
|
9
|
+
export interface CreateAppClient {
|
|
10
|
+
(options: {
|
|
11
|
+
routes: IRawPageRouteRecord[];
|
|
12
|
+
appComponent: any;
|
|
13
|
+
appData: IAppData<any, IAppState>;
|
|
14
|
+
}): Application;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./appTypes"), exports);
|
|
18
|
+
__exportStar(require("./renderTypes"), exports);
|
|
19
|
+
__exportStar(require("./routeTypes"), exports);
|
|
20
|
+
__exportStar(require("./serverTypes"), exports);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IManifest } from '@shuvi/toolpack/lib/webpack/types';
|
|
2
|
+
import { Response, IApplication, IRequest, IAppData } from '@shuvi/platform-shared/shared';
|
|
3
|
+
export declare type IRenderDocumentOptions = {
|
|
4
|
+
app: IApplication;
|
|
5
|
+
req?: IRequest;
|
|
6
|
+
};
|
|
7
|
+
export interface IRenderOptions extends IRenderDocumentOptions {
|
|
8
|
+
}
|
|
9
|
+
export interface IView<RenderOption extends IRenderOptions = any, RenderResult = void> {
|
|
10
|
+
renderApp(options: RenderOption): RenderResult;
|
|
11
|
+
}
|
|
12
|
+
export declare type IHtmlAttrs = {
|
|
13
|
+
textContent?: string;
|
|
14
|
+
} & {
|
|
15
|
+
[x: string]: string | number | undefined | boolean;
|
|
16
|
+
};
|
|
17
|
+
export interface IHtmlTag<TagNames = string> {
|
|
18
|
+
tagName: TagNames;
|
|
19
|
+
attrs: IHtmlAttrs;
|
|
20
|
+
innerHTML?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare type IRenderAppServerResult<ExtraAppData = {}> = {
|
|
23
|
+
htmlAttrs?: IHtmlAttrs;
|
|
24
|
+
headBeginTags?: IHtmlTag[];
|
|
25
|
+
headEndTags?: IHtmlTag[];
|
|
26
|
+
mainBeginTags?: IHtmlTag[];
|
|
27
|
+
mainEndTags?: IHtmlTag[];
|
|
28
|
+
scriptBeginTags?: IHtmlTag[];
|
|
29
|
+
scriptEndTags?: IHtmlTag[];
|
|
30
|
+
appData?: ExtraAppData;
|
|
31
|
+
content?: string;
|
|
32
|
+
};
|
|
33
|
+
export interface IClientRendererOptions<ExtraAppData = {}> extends IRenderOptions {
|
|
34
|
+
appContainer: HTMLElement;
|
|
35
|
+
appData: IAppData<ExtraAppData>;
|
|
36
|
+
}
|
|
37
|
+
export interface IServerRendererOptions extends IRenderOptions {
|
|
38
|
+
manifest: IManifest;
|
|
39
|
+
getAssetPublicUrl(path: string): string;
|
|
40
|
+
}
|
|
41
|
+
export interface IViewClient<ExtraAppData = {}> extends IView<IClientRendererOptions<ExtraAppData>> {
|
|
42
|
+
}
|
|
43
|
+
export interface IViewServer<ExtraAppData = {}> extends IView<IServerRendererOptions, Promise<IRenderAppServerResult<ExtraAppData> | Response>> {
|
|
44
|
+
}
|