@shuvi/platform-web 1.0.0-rc.3 → 1.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/shared/appTypes.d.ts +2 -2
- package/esm/shuvi-app/app/client.d.ts +2 -0
- package/esm/shuvi-app/app/client.js +2 -1
- package/esm/shuvi-app/dev/eventsource.d.ts +1 -0
- package/esm/shuvi-app/dev/eventsource.js +60 -0
- package/esm/shuvi-app/dev/hotDevClient.d.ts +33 -0
- package/esm/shuvi-app/dev/hotDevClient.js +348 -0
- package/esm/shuvi-app/dev/index.d.ts +3 -0
- package/esm/shuvi-app/dev/index.js +27 -0
- package/esm/shuvi-app/dev/websocket.d.ts +17 -0
- package/esm/shuvi-app/dev/websocket.js +61 -0
- package/esm/shuvi-app/entry/client/app.d.ts +2 -1
- package/esm/shuvi-app/entry/client/app.js +2 -2
- package/esm/shuvi-app/entry/client/run.dev.js +4 -4
- package/esm/shuvi-app/entry/server/index.d.ts +5 -4
- package/esm/shuvi-app/entry/server/index.js +5 -4
- package/esm/shuvi-app/react/getRoutes.d.ts +2 -2
- package/esm/shuvi-app/react/getRoutes.js +6 -7
- package/esm/shuvi-app/react/redox-react/runtime.d.ts +7 -1
- package/esm/shuvi-app/react/redox-react/runtime.js +3 -1
- package/esm/shuvi-app/shuvi-runtime-index.js +1 -1
- package/lib/node/features/filesystem-routes/index.d.ts +1 -1
- package/lib/node/features/filesystem-routes/index.js +17 -7
- package/lib/node/features/filesystem-routes/page/routes.d.ts +2 -2
- package/lib/node/features/filesystem-routes/page/routes.js +29 -11
- package/lib/node/features/html-render/index.d.ts +3 -18
- package/lib/node/features/html-render/index.js +87 -16
- package/lib/node/features/{main → html-render/lib}/buildHtml.d.ts +0 -0
- package/lib/node/features/{main → html-render/lib}/buildHtml.js +0 -0
- package/lib/node/features/html-render/lib/generateFilesByRoutId.d.ts +2 -2
- package/lib/node/features/html-render/lib/generateFilesByRoutId.js +3 -3
- package/lib/node/features/{main → html-render/lib}/generateResource.d.ts +0 -0
- package/lib/node/features/{main → html-render/lib}/generateResource.js +0 -0
- package/lib/node/features/index.d.ts +3 -31
- package/lib/node/features/index.js +9 -8
- package/lib/node/features/model/index.d.ts +1 -1
- package/lib/node/features/model/runtime.d.ts +0 -5
- package/lib/node/features/model/runtime.js +11 -17
- package/lib/node/features/model/server.js +2 -3
- package/lib/node/features/model/shuvi-app.d.ts +1 -1
- package/lib/node/features/on-demand-compile-page/index.d.ts +15 -13
- package/lib/node/features/on-demand-compile-page/index.js +4 -1
- package/lib/node/features/on-demand-compile-page/onDemandRouteManager.js +2 -4
- package/lib/node/features/webpack-watch-wait-for-file-builder/index.d.ts +16 -0
- package/lib/node/features/webpack-watch-wait-for-file-builder/index.js +25 -0
- package/lib/node/features/webpack-watch-wait-for-file-builder/webpack-watch-wait-for-file-builder-plugin.d.ts +12 -0
- package/lib/node/features/webpack-watch-wait-for-file-builder/webpack-watch-wait-for-file-builder-plugin.js +32 -0
- package/lib/node/index.js +1 -3
- package/lib/node/shuvi-type-extensions-node.d.ts +2 -0
- package/lib/node/targets/react/bundler/index.d.ts +1 -1
- package/lib/node/targets/react/bundler/index.js +5 -0
- package/lib/node/targets/react/index.d.ts +2 -2
- package/lib/node/targets/react/redox-react/index.d.ts +1 -1
- package/lib/shared/appTypes.d.ts +2 -2
- package/package.json +17 -12
- package/shuvi-env.d.ts +10 -0
- package/shuvi-image.d.ts +54 -0
- package/shuvi-type-extensions-node.js +1 -0
- package/shuvi-type-extensions-runtime.d.ts +2 -2
- package/esm/shuvi-app/dev/webpackHotDevClient.d.ts +0 -5
- package/esm/shuvi-app/dev/webpackHotDevClient.js +0 -34
- package/lib/node/features/main/index.d.ts +0 -3
- package/lib/node/features/main/index.js +0 -82
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
declare const _default:
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
declare const _default: {
|
|
2
|
+
core: import("@shuvi/hook").IPluginInstance<{
|
|
3
|
+
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
4
|
+
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
5
|
+
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
6
|
+
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
7
|
+
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
8
|
+
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
9
|
+
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
10
|
+
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
11
|
+
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
12
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOption<any, any> | import("@shuvi/service/lib/project/index").FileOption<any, any>[]>;
|
|
13
|
+
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
14
|
+
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
15
|
+
};
|
|
14
16
|
export default _default;
|
|
15
17
|
export { default as OnDemandRouteManager } from './onDemandRouteManager';
|
|
@@ -10,7 +10,7 @@ const module_replace_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/web
|
|
|
10
10
|
const require_cache_hot_reloader_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/webpack/plugins/require-cache-hot-reloader-plugin"));
|
|
11
11
|
const constants_1 = require("@shuvi/shared/lib/constants");
|
|
12
12
|
const dumbRouteComponent = require.resolve('./emptyComponent');
|
|
13
|
-
|
|
13
|
+
const plugin = (0, service_1.createPlugin)({
|
|
14
14
|
configWebpack(config, _, ctx) {
|
|
15
15
|
if (ctx.mode === 'development') {
|
|
16
16
|
config.plugin('private/module-replace-plugin').use(module_replace_plugin_1.default, [
|
|
@@ -32,5 +32,8 @@ exports.default = (0, service_1.createPlugin)({
|
|
|
32
32
|
return config;
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
|
+
exports.default = {
|
|
36
|
+
core: plugin
|
|
37
|
+
};
|
|
35
38
|
var onDemandRouteManager_1 = require("./onDemandRouteManager");
|
|
36
39
|
Object.defineProperty(exports, "OnDemandRouteManager", { enumerable: true, get: function () { return __importDefault(onDemandRouteManager_1).default; } });
|
|
@@ -13,10 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const router_1 = require("@shuvi/router");
|
|
16
|
-
const constants_1 = require("@shuvi/shared/lib/constants");
|
|
17
16
|
const resources_1 = require("@shuvi/service/lib/resources");
|
|
18
17
|
const module_replace_plugin_1 = __importDefault(require("@shuvi/toolpack/lib/webpack/plugins/module-replace-plugin"));
|
|
19
|
-
const index_1 = require("../filesystem-routes/index");
|
|
20
18
|
function acceptsHtml(header, { htmlAcceptHeaders = ['text/html', '*/*'] } = {}) {
|
|
21
19
|
for (var i = 0; i < htmlAcceptHeaders.length; i++) {
|
|
22
20
|
if (header.indexOf(htmlAcceptHeaders[i]) !== -1) {
|
|
@@ -79,9 +77,9 @@ class OnDemandRouteManager {
|
|
|
79
77
|
}
|
|
80
78
|
ensureRoutes(pathname) {
|
|
81
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
-
const matchedRoutes = (0, router_1.matchRoutes)(
|
|
80
|
+
const matchedRoutes = (0, router_1.matchRoutes)(resources_1.server.pageRoutes, pathname) || [];
|
|
83
81
|
const modulesToActivate = matchedRoutes
|
|
84
|
-
.map(({ route: {
|
|
82
|
+
.map(({ route: { __componentRawRequest__ } }) => __componentRawRequest__)
|
|
85
83
|
.filter(Boolean);
|
|
86
84
|
return this._activateModules(modulesToActivate);
|
|
87
85
|
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
core: import("@shuvi/hook").IPluginInstance<{
|
|
3
|
+
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
4
|
+
afterInit: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
5
|
+
afterBuild: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
6
|
+
afterDestroy: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
7
|
+
afterBundlerDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerDoneExtra, void, void>;
|
|
8
|
+
afterBundlerTargetDone: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").BundlerTargetDoneExtra, void, void>;
|
|
9
|
+
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
10
|
+
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
11
|
+
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
12
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOption<any, any> | import("@shuvi/service/lib/project/index").FileOption<any, any>[]>;
|
|
13
|
+
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
14
|
+
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
@@ -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
|
+
const service_1 = require("@shuvi/service");
|
|
7
|
+
const webpack_watch_wait_for_file_builder_plugin_1 = __importDefault(require("./webpack-watch-wait-for-file-builder-plugin"));
|
|
8
|
+
const plugin = (0, service_1.createPlugin)({
|
|
9
|
+
configWebpack(config, _, ctx) {
|
|
10
|
+
if (ctx.mode === 'development') {
|
|
11
|
+
config
|
|
12
|
+
.plugin('webpack-watch-wait-for-file-builder-plugin')
|
|
13
|
+
.use(webpack_watch_wait_for_file_builder_plugin_1.default, [
|
|
14
|
+
{
|
|
15
|
+
onBuildStart: ctx.onBuildStart,
|
|
16
|
+
onBuildEnd: ctx.onBuildEnd
|
|
17
|
+
}
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
exports.default = {
|
|
24
|
+
core: plugin
|
|
25
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IPluginContext } from '@shuvi/service';
|
|
2
|
+
import { Compiler, Plugin } from '@shuvi/toolpack/lib/webpack';
|
|
3
|
+
declare type Options = {
|
|
4
|
+
onBuildStart: IPluginContext['onBuildStart'];
|
|
5
|
+
onBuildEnd: IPluginContext['onBuildEnd'];
|
|
6
|
+
};
|
|
7
|
+
export default class WebpackWatchWaitForFileBuilderPlugin implements Plugin {
|
|
8
|
+
options: Options;
|
|
9
|
+
constructor(options: Options);
|
|
10
|
+
apply(compiler: Compiler): void;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class WebpackWatchWaitForFileBuilderPlugin {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
this.options = options;
|
|
6
|
+
}
|
|
7
|
+
apply(compiler) {
|
|
8
|
+
const { onBuildEnd, onBuildStart } = this.options;
|
|
9
|
+
/**
|
|
10
|
+
* watching.suspend will pause the real action in the watcher handler but still collecting changed files.
|
|
11
|
+
* watching.resume will resume its action
|
|
12
|
+
*
|
|
13
|
+
* We make sure onBuildStart is faster than webpack's watcher and make it suspend.
|
|
14
|
+
*
|
|
15
|
+
* And resume when onBuildEnd.
|
|
16
|
+
*
|
|
17
|
+
* In this way, during build of fileBuilder, webpack will not trigger any watchRun event but keep watching changed files.
|
|
18
|
+
*/
|
|
19
|
+
onBuildStart(() => {
|
|
20
|
+
compiler.watching.suspend();
|
|
21
|
+
});
|
|
22
|
+
onBuildEnd(({ buildStatus }) => {
|
|
23
|
+
if (buildStatus === 'fulfilled') {
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
compiler.watching.resume();
|
|
26
|
+
// FIXME: timeout for resuming need further investigation
|
|
27
|
+
}, 100);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.default = WebpackWatchWaitForFileBuilderPlugin;
|
package/lib/node/index.js
CHANGED
|
@@ -13,7 +13,6 @@ const node_1 = require("@shuvi/platform-shared/node");
|
|
|
13
13
|
const features_1 = require("./features");
|
|
14
14
|
const paths_1 = require("./paths");
|
|
15
15
|
const platform = ({ framework = 'react' } = {}) => (platformContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
const mainPlugin = (0, features_1.getMainPlugin)(platformContext);
|
|
17
16
|
const platformFramework = require(`./targets/${framework}`).default;
|
|
18
17
|
const platformFrameworkContent = yield platformFramework();
|
|
19
18
|
const platformModule = platformFrameworkContent.platformModule;
|
|
@@ -26,8 +25,7 @@ const platform = ({ framework = 'react' } = {}) => (platformContext) => __awaite
|
|
|
26
25
|
],
|
|
27
26
|
plugins: [
|
|
28
27
|
...node_1.SharedPlugins,
|
|
29
|
-
|
|
30
|
-
...features_1.featurePlugins,
|
|
28
|
+
...(0, features_1.getPlugins)(platformContext),
|
|
31
29
|
...platformFrameworkContent.plugins
|
|
32
30
|
],
|
|
33
31
|
getPresetRuntimeFiles,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import '@shuvi/platform-shared/shuvi-type-extensions-node';
|
|
2
|
+
import { IPageRouteRecord } from '@shuvi/platform-shared/shared';
|
|
2
3
|
import { IManifest } from '@shuvi/toolpack/lib/webpack/types';
|
|
3
4
|
import { IMiddlewareRoutes, CreateAppServer, IApiRoutes, IServerModule, PlatformWebCustomConfig } from '../shared/index';
|
|
4
5
|
import { IViewServer } from './features/html-render/index';
|
|
@@ -8,6 +9,7 @@ export {};
|
|
|
8
9
|
declare module '@shuvi/service/lib/resources' {
|
|
9
10
|
const server: {
|
|
10
11
|
server: IServerModule;
|
|
12
|
+
pageRoutes: IPageRouteRecord[];
|
|
11
13
|
apiRoutes: IApiRoutes;
|
|
12
14
|
middlewareRoutes: IMiddlewareRoutes;
|
|
13
15
|
application: {
|
|
@@ -9,7 +9,7 @@ declare const _default: {
|
|
|
9
9
|
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
10
10
|
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
11
11
|
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
12
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").
|
|
12
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOption<any, any> | import("@shuvi/service/lib/project/index").FileOption<any, any>[]>;
|
|
13
13
|
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
14
14
|
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
15
15
|
};
|
|
@@ -64,6 +64,11 @@ const configWebpack = (config, { name, webpack }, context) => {
|
|
|
64
64
|
resolveLocal('react', 'jsx-runtime')
|
|
65
65
|
]);
|
|
66
66
|
// @ts-ignore
|
|
67
|
+
config.resolve.alias.set('react/jsx-dev-runtime$', [
|
|
68
|
+
resolveUser('react/jsx-dev-runtime'),
|
|
69
|
+
resolveLocal('react', 'jsx-dev-runtime')
|
|
70
|
+
]);
|
|
71
|
+
// @ts-ignore
|
|
67
72
|
config.resolve.alias.set('react-dom$', [
|
|
68
73
|
resolveUser('react-dom'),
|
|
69
74
|
resolveLocal('react-dom')
|
|
@@ -9,7 +9,7 @@ declare const platformWebReact: () => {
|
|
|
9
9
|
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
10
10
|
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
11
11
|
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
12
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").
|
|
12
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOption<any, any> | import("@shuvi/service/lib/project/index").FileOption<any, any>[]>;
|
|
13
13
|
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
14
14
|
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext> | {
|
|
15
15
|
core: import("@shuvi/hook").IPluginInstance<{
|
|
@@ -22,7 +22,7 @@ declare const platformWebReact: () => {
|
|
|
22
22
|
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
23
23
|
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
24
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").
|
|
25
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOption<any, any> | import("@shuvi/service/lib/project/index").FileOption<any, any>[]>;
|
|
26
26
|
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
27
27
|
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
28
28
|
})[];
|
|
@@ -9,7 +9,7 @@ export declare const RedoxReactPlugin: {
|
|
|
9
9
|
configWebpack: import("@shuvi/hook").AsyncSeriesWaterfallHook<import("@shuvi/service/lib/core/lifecycleTypes").WebpackChainType, import("@shuvi/service/lib/core/lifecycleTypes").ConfigWebpackAssistant>;
|
|
10
10
|
addExtraTarget: import("@shuvi/hook").AsyncParallelHook<import("@shuvi/service/lib/core/lifecycleTypes").ExtraTargetAssistant, void, import("@shuvi/service/lib/core/lifecycleTypes").TargetChain>;
|
|
11
11
|
addResource: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").Resources | import("@shuvi/service/lib/core/lifecycleTypes").Resources[]>;
|
|
12
|
-
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").
|
|
12
|
+
addRuntimeFile: import("@shuvi/hook").AsyncParallelHook<void, import("@shuvi/service/lib/core/lifecycleTypes").AddRuntimeFileUtils, import("@shuvi/service/lib/project/index").FileOption<any, any> | import("@shuvi/service/lib/project/index").FileOption<any, any>[]>;
|
|
13
13
|
addRuntimeService: import("@shuvi/hook").AsyncParallelHook<void, void, import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService | import("@shuvi/service/lib/core/lifecycleTypes").RuntimeService[]>;
|
|
14
14
|
} & import("@shuvi/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
15
15
|
runtime: {
|
package/lib/shared/appTypes.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IRequest,
|
|
1
|
+
import { IRequest, IPageRouteRecord, IAppData, IAppState } from '@shuvi/platform-shared/shared';
|
|
2
2
|
import { Application } from '@shuvi/platform-shared/shuvi-app/application';
|
|
3
3
|
export interface CreateAppServer {
|
|
4
4
|
(options: {
|
|
@@ -8,7 +8,7 @@ export interface CreateAppServer {
|
|
|
8
8
|
}
|
|
9
9
|
export interface CreateAppClient {
|
|
10
10
|
(options: {
|
|
11
|
-
routes:
|
|
11
|
+
routes: IPageRouteRecord[];
|
|
12
12
|
appComponent: any;
|
|
13
13
|
appData: IAppData<any, IAppState>;
|
|
14
14
|
}): Application;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-web",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
"**/shuvi-app/entry/client/**"
|
|
13
13
|
],
|
|
14
14
|
"files": [
|
|
15
|
-
"lib",
|
|
16
15
|
"esm",
|
|
16
|
+
"lib",
|
|
17
|
+
"shuvi-env.d.ts",
|
|
18
|
+
"shuvi-image.d.ts",
|
|
17
19
|
"shuvi-type-extensions-node.d.ts",
|
|
20
|
+
"shuvi-type-extensions-node.js",
|
|
18
21
|
"shuvi-type-extensions-runtime.d.ts"
|
|
19
22
|
],
|
|
20
23
|
"exports": {
|
|
@@ -62,17 +65,17 @@
|
|
|
62
65
|
},
|
|
63
66
|
"dependencies": {
|
|
64
67
|
"@next/react-refresh-utils": "12.1.6",
|
|
65
|
-
"@shuvi/hook": "1.0.0-rc.
|
|
66
|
-
"@shuvi/platform-shared": "1.0.0-rc.
|
|
68
|
+
"@shuvi/hook": "1.0.0-rc.4",
|
|
69
|
+
"@shuvi/platform-shared": "1.0.0-rc.4",
|
|
67
70
|
"@shuvi/redox": "0.0.3",
|
|
68
71
|
"@shuvi/redox-react": "0.0.3",
|
|
69
|
-
"@shuvi/router": "1.0.0-rc.
|
|
70
|
-
"@shuvi/router-react": "1.0.0-rc.
|
|
71
|
-
"@shuvi/runtime": "1.0.0-rc.
|
|
72
|
-
"@shuvi/service": "1.0.0-rc.
|
|
73
|
-
"@shuvi/shared": "1.0.0-rc.
|
|
74
|
-
"@shuvi/toolpack": "1.0.0-rc.
|
|
75
|
-
"@shuvi/utils": "1.0.0-rc.
|
|
72
|
+
"@shuvi/router": "1.0.0-rc.4",
|
|
73
|
+
"@shuvi/router-react": "1.0.0-rc.4",
|
|
74
|
+
"@shuvi/runtime": "1.0.0-rc.4",
|
|
75
|
+
"@shuvi/service": "1.0.0-rc.4",
|
|
76
|
+
"@shuvi/shared": "1.0.0-rc.4",
|
|
77
|
+
"@shuvi/toolpack": "1.0.0-rc.4",
|
|
78
|
+
"@shuvi/utils": "1.0.0-rc.4",
|
|
76
79
|
"content-type": "1.0.4",
|
|
77
80
|
"cookie": "0.4.1",
|
|
78
81
|
"ejs": "3.1.5",
|
|
@@ -82,11 +85,13 @@
|
|
|
82
85
|
"react": "18.1.0",
|
|
83
86
|
"react-app-polyfill": "2.0.0",
|
|
84
87
|
"react-dom": "18.1.0",
|
|
88
|
+
"react-error-overlay": "6.0.8",
|
|
85
89
|
"react-refresh": "0.12.0",
|
|
90
|
+
"strip-ansi": "6.0.0",
|
|
86
91
|
"use-sync-external-store": "1.1.0"
|
|
87
92
|
},
|
|
88
93
|
"peerDependencies": {
|
|
89
|
-
"@shuvi/service": "1.0.0-rc.
|
|
94
|
+
"@shuvi/service": "1.0.0-rc.4"
|
|
90
95
|
},
|
|
91
96
|
"devDependencies": {
|
|
92
97
|
"@types/react": "18.0.9",
|
package/shuvi-env.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
/// <reference types="react-dom" />
|
|
4
|
+
|
|
5
|
+
// Extend the NodeJS namespace with Next.js-defined properties
|
|
6
|
+
declare namespace NodeJS {
|
|
7
|
+
interface ProcessEnv {
|
|
8
|
+
readonly NODE_ENV: 'development' | 'production' | 'test';
|
|
9
|
+
}
|
|
10
|
+
}
|
package/shuvi-image.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare module '*.bmp' {
|
|
2
|
+
const src: string;
|
|
3
|
+
export default src;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module '*.gif' {
|
|
7
|
+
const src: string;
|
|
8
|
+
export default src;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module '*.jpg' {
|
|
12
|
+
const src: string;
|
|
13
|
+
export default src;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare module '*.jpeg' {
|
|
17
|
+
const src: string;
|
|
18
|
+
export default src;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module '*.png' {
|
|
22
|
+
const src: string;
|
|
23
|
+
export default src;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare module '*.webp' {
|
|
27
|
+
const src: string;
|
|
28
|
+
export default src;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module '*.svg' {
|
|
32
|
+
/**
|
|
33
|
+
* Use `any` to avoid conflicts with
|
|
34
|
+
* `@svgr/webpack` plugin or
|
|
35
|
+
* `babel-plugin-inline-react-svg` plugin.
|
|
36
|
+
*/
|
|
37
|
+
const content: any;
|
|
38
|
+
export default content;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare module '*.css' {
|
|
42
|
+
const classes: { readonly [key: string]: string };
|
|
43
|
+
export default classes;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare module '*.sass' {
|
|
47
|
+
const classes: { readonly [key: string]: string };
|
|
48
|
+
export default classes;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare module '*.scss' {
|
|
52
|
+
const classes: { readonly [key: string]: string };
|
|
53
|
+
export default classes;
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="@shuvi/platform-shared/shuvi-type-extensions-runtime" />
|
|
2
2
|
|
|
3
3
|
declare module '@shuvi/app/files/routes' {
|
|
4
|
-
import {
|
|
5
|
-
declare const routes:
|
|
4
|
+
import { IPageRouteRecord } from '@shuvi/platform-shared/shared';
|
|
5
|
+
declare const routes: IPageRouteRecord[];
|
|
6
6
|
export default routes;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import connect from '@shuvi/toolpack/lib/utils/hotDevClient';
|
|
2
|
-
import { DEV_HOT_MIDDLEWARE_PATH, DEV_HOT_LAUNCH_EDITOR_ENDPOINT } from '@shuvi/shared/lib/constants';
|
|
3
|
-
let devClient;
|
|
4
|
-
export default (options = {}) => {
|
|
5
|
-
if (devClient) {
|
|
6
|
-
return devClient;
|
|
7
|
-
}
|
|
8
|
-
devClient = connect(Object.assign(Object.assign({}, options), { launchEditorEndpoint: DEV_HOT_LAUNCH_EDITOR_ENDPOINT, path: DEV_HOT_MIDDLEWARE_PATH, location,
|
|
9
|
-
WebSocket }));
|
|
10
|
-
devClient.subscribeToHmrEvent((event) => {
|
|
11
|
-
// if (obj.action === "reloadPage") {
|
|
12
|
-
// return window.location.reload();
|
|
13
|
-
// }
|
|
14
|
-
// if (obj.action === "removedPage") {
|
|
15
|
-
// const [page] = obj.data;
|
|
16
|
-
// if (page === window.next.router.pathname) {
|
|
17
|
-
// return window.location.reload();
|
|
18
|
-
// }
|
|
19
|
-
// return;
|
|
20
|
-
// }
|
|
21
|
-
// if (obj.action === "addedPage") {
|
|
22
|
-
// const [page] = obj.data;
|
|
23
|
-
// if (
|
|
24
|
-
// page === window.next.router.pathname &&
|
|
25
|
-
// typeof window.next.router.components[page] === "undefined"
|
|
26
|
-
// ) {
|
|
27
|
-
// return window.location.reload();
|
|
28
|
-
// }
|
|
29
|
-
// return;
|
|
30
|
-
// }
|
|
31
|
-
// throw new Error("Unexpected action " + obj.action);
|
|
32
|
-
});
|
|
33
|
-
return devClient;
|
|
34
|
-
};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getPlugin = void 0;
|
|
16
|
-
const service_1 = require("@shuvi/service");
|
|
17
|
-
const constants_1 = require("@shuvi/shared/lib/constants");
|
|
18
|
-
const config_1 = require("@shuvi/toolpack/lib/webpack/config");
|
|
19
|
-
const generateResource_1 = __importDefault(require("./generateResource"));
|
|
20
|
-
const paths_1 = require("../../paths");
|
|
21
|
-
const buildHtml_1 = require("./buildHtml");
|
|
22
|
-
const middlewares_1 = require("../middlewares");
|
|
23
|
-
function getServerEntry() {
|
|
24
|
-
return {
|
|
25
|
-
[service_1.BUILD_SERVER_FILE_SERVER]: [(0, paths_1.resolvePkgFile)('esm/shuvi-app/entry/server')]
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/** This main plugin uses `platformContext` so that it is set to a plugin getter */
|
|
29
|
-
const getPlugin = (platformContext) => {
|
|
30
|
-
const core = (0, service_1.createPlugin)({
|
|
31
|
-
addExtraTarget: ({ createConfig }, context) => {
|
|
32
|
-
const serverWebpackHelpers = (0, config_1.webpackHelpers)();
|
|
33
|
-
const serverChain = createConfig({
|
|
34
|
-
name: constants_1.BUNDLER_TARGET_SERVER,
|
|
35
|
-
node: true,
|
|
36
|
-
entry: getServerEntry(),
|
|
37
|
-
outputDir: service_1.BUILD_SERVER_DIR,
|
|
38
|
-
webpackHelpers: serverWebpackHelpers
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
name: constants_1.BUNDLER_TARGET_SERVER,
|
|
42
|
-
chain: serverChain
|
|
43
|
-
};
|
|
44
|
-
},
|
|
45
|
-
configWebpack: chain => {
|
|
46
|
-
chain.merge({
|
|
47
|
-
entry: {
|
|
48
|
-
[service_1.BUILD_CLIENT_RUNTIME_POLYFILL]: ['@shuvi/app/core/polyfill'],
|
|
49
|
-
[service_1.BUILD_CLIENT_RUNTIME_MAIN]: [
|
|
50
|
-
(0, paths_1.resolvePkgFile)('esm/shuvi-app/entry/client')
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
return chain;
|
|
55
|
-
},
|
|
56
|
-
addRuntimeService: () => [
|
|
57
|
-
{
|
|
58
|
-
source: (0, paths_1.resolvePkgFile)('esm/shuvi-app/shuvi-runtime-index'),
|
|
59
|
-
exported: '*'
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
source: (0, paths_1.resolvePkgFile)('esm/shuvi-app/shuvi-runtime-server'),
|
|
63
|
-
filepath: 'server.ts',
|
|
64
|
-
exported: '*'
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
addResource: context => (0, generateResource_1.default)(context),
|
|
68
|
-
afterBuild: (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
-
yield (0, buildHtml_1.buildHtml)({
|
|
70
|
-
context,
|
|
71
|
-
serverPlugins: platformContext.serverPlugins,
|
|
72
|
-
getMiddlewares: middlewares_1.getMiddlewares,
|
|
73
|
-
pathname: '/',
|
|
74
|
-
filename: 'index.html'
|
|
75
|
-
});
|
|
76
|
-
})
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
core
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
exports.getPlugin = getPlugin;
|