@shuvi/platform-shared 1.0.0-rc.13 → 1.0.0-rc.16
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/application.d.ts +6 -4
- package/esm/shared/application.js +20 -5
- package/esm/shared/applicationTypes.d.ts +4 -2
- package/esm/shared/index.d.ts +1 -1
- package/esm/shuvi-app/application.d.ts +4 -4
- package/esm/shuvi-app/application.js +3 -3
- package/lib/node/platform/plugins/main/hooks.d.ts +2 -2
- package/lib/node/platform/runtimeFiles.js +3 -3
- package/lib/shared/application.d.ts +6 -4
- package/lib/shared/application.js +22 -7
- package/lib/shared/applicationTypes.d.ts +4 -2
- package/lib/shared/index.d.ts +1 -1
- package/package.json +9 -9
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { IRouter, IPageRouteRecord } from './routerTypes';
|
|
2
|
-
import { RedoxStore,
|
|
3
|
-
export declare class
|
|
2
|
+
import { RedoxStore, Application, IAppContext, ApplicationOptions, IRerenderConfig, IError } from './applicationTypes';
|
|
3
|
+
export declare class ApplicationImpl<Config extends {} = {}> {
|
|
4
4
|
private _router;
|
|
5
5
|
private _appComponent;
|
|
6
6
|
private _pluginManager;
|
|
7
7
|
private _context;
|
|
8
|
+
private _config;
|
|
8
9
|
private _store;
|
|
9
10
|
private _error;
|
|
10
11
|
private _loader;
|
|
11
|
-
constructor(options:
|
|
12
|
+
constructor(options: ApplicationOptions<Config>);
|
|
12
13
|
get router(): IRouter<IPageRouteRecord>;
|
|
14
|
+
get config(): Config;
|
|
13
15
|
get context(): IAppContext;
|
|
14
16
|
get pluginManager(): import("@shuvi/hook").HookManager<import("./runtimPlugin").RuntimePluginHooks, void>;
|
|
15
17
|
get appComponent(): any;
|
|
@@ -25,5 +27,5 @@ export declare class Application {
|
|
|
25
27
|
private _initPlugin;
|
|
26
28
|
private _initAppContext;
|
|
27
29
|
private _initAppComponent;
|
|
28
|
-
getPublicAPI():
|
|
30
|
+
getPublicAPI(): Application<Config>;
|
|
29
31
|
}
|
|
@@ -12,8 +12,9 @@ import { initPlugins } from './runtimPlugin';
|
|
|
12
12
|
import { redox } from '@shuvi/redox';
|
|
13
13
|
import { errorModel } from './models/error';
|
|
14
14
|
import { loaderModel } from './models/loader';
|
|
15
|
-
export class
|
|
15
|
+
export class ApplicationImpl {
|
|
16
16
|
constructor(options) {
|
|
17
|
+
this._config = options.config;
|
|
17
18
|
this._router = options.router;
|
|
18
19
|
this._context = {};
|
|
19
20
|
this._store = redox({ initialState: options.initialState });
|
|
@@ -26,6 +27,9 @@ export class Application {
|
|
|
26
27
|
get router() {
|
|
27
28
|
return this._router;
|
|
28
29
|
}
|
|
30
|
+
get config() {
|
|
31
|
+
return this._config;
|
|
32
|
+
}
|
|
29
33
|
get context() {
|
|
30
34
|
return this._context;
|
|
31
35
|
}
|
|
@@ -92,10 +96,21 @@ export class Application {
|
|
|
92
96
|
getPublicAPI() {
|
|
93
97
|
const self = this;
|
|
94
98
|
return {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
get config() {
|
|
100
|
+
return self._config;
|
|
101
|
+
},
|
|
102
|
+
get context() {
|
|
103
|
+
return self._context;
|
|
104
|
+
},
|
|
105
|
+
get router() {
|
|
106
|
+
return self._router;
|
|
107
|
+
},
|
|
108
|
+
get appComponent() {
|
|
109
|
+
return self._appComponent;
|
|
110
|
+
},
|
|
111
|
+
get store() {
|
|
112
|
+
return self._store;
|
|
113
|
+
},
|
|
99
114
|
get error() {
|
|
100
115
|
return self.error;
|
|
101
116
|
},
|
|
@@ -23,7 +23,8 @@ export interface IErrorState {
|
|
|
23
23
|
export declare type IAppState = {
|
|
24
24
|
error?: IErrorState;
|
|
25
25
|
};
|
|
26
|
-
export interface
|
|
26
|
+
export interface Application<Config extends {} = {}> {
|
|
27
|
+
readonly config: Config;
|
|
27
28
|
readonly context: IAppContext;
|
|
28
29
|
readonly router: IRouter<IPageRouteRecord>;
|
|
29
30
|
readonly appComponent: any;
|
|
@@ -34,7 +35,8 @@ export interface IApplication {
|
|
|
34
35
|
getLoadersData(): Record<string, any>;
|
|
35
36
|
setLoadersData(datas: Record<string, any>): void;
|
|
36
37
|
}
|
|
37
|
-
export interface
|
|
38
|
+
export interface ApplicationOptions<C extends {}> {
|
|
39
|
+
config: C;
|
|
38
40
|
router: IRouter;
|
|
39
41
|
AppComponent: any;
|
|
40
42
|
initialState?: IAppState;
|
package/esm/shared/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ export * from './loader';
|
|
|
6
6
|
export { errorModel } from './models/error';
|
|
7
7
|
export { loaderModel } from './models/loader';
|
|
8
8
|
export * from './applicationTypes';
|
|
9
|
-
export type {
|
|
9
|
+
export type { ApplicationImpl } from './application';
|
|
10
10
|
export type { IRuntimeConfig } from './runtimeConfigTypes';
|
|
11
11
|
export { IAppModule, IPluginInstance, BuiltInRuntimePluginHooks, CustomRuntimePluginHooks, RuntimePluginHooks, createRuntimePlugin, createRuntimePluginBefore, createRuntimePluginAfter, RuntimePluginInstance } from './runtimPlugin';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
export default function application(options:
|
|
1
|
+
import { ApplicationImpl } from '../shared/application';
|
|
2
|
+
import { ApplicationOptions } from './shared';
|
|
3
|
+
export { ApplicationImpl };
|
|
4
|
+
export default function application<C extends {}>(options: ApplicationOptions<C>): ApplicationImpl<C>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as customApp from '@shuvi/app/user/app';
|
|
2
2
|
import { pluginRecord } from '@shuvi/app/core/plugins';
|
|
3
|
-
import {
|
|
3
|
+
import { ApplicationImpl } from '../shared/application';
|
|
4
4
|
import { createRuntimePlugin } from './shared';
|
|
5
|
-
export {
|
|
5
|
+
export { ApplicationImpl };
|
|
6
6
|
function getPlugins(runtime, pluginRecords) {
|
|
7
7
|
const plugins = [];
|
|
8
8
|
const keys = Object.keys(pluginRecords);
|
|
@@ -29,6 +29,6 @@ function getPlugins(runtime, pluginRecords) {
|
|
|
29
29
|
return plugins;
|
|
30
30
|
}
|
|
31
31
|
export default function application(options) {
|
|
32
|
-
const application = new
|
|
32
|
+
const application = new ApplicationImpl(Object.assign(Object.assign({}, options), { plugins: getPlugins(customApp, pluginRecord) }));
|
|
33
33
|
return application;
|
|
34
34
|
}
|
|
@@ -2,7 +2,7 @@ import { IRuntimeConfig } from '../../../../shared';
|
|
|
2
2
|
export declare const extendedHooks: {
|
|
3
3
|
addEntryCode: import("@shuvi/hook").AsyncParallelHook<void, void, string | string[]>;
|
|
4
4
|
modifyRuntimeConfig: import("@shuvi/hook").AsyncSeriesWaterfallHook<{
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
publicRuntimeConfig: IRuntimeConfig;
|
|
6
|
+
serverRuntimeConfig: IRuntimeConfig;
|
|
7
7
|
}, void>;
|
|
8
8
|
};
|
|
@@ -22,9 +22,9 @@ const file_presets_1 = require("../project/file-presets");
|
|
|
22
22
|
const getPresetRuntimeFilesCreator = (platformModule) => (pluginContext) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
23
|
const { pluginRunner, config } = pluginContext;
|
|
24
24
|
const getCandidates = (fileName, fallbackType) => project_1.fileUtils.getUserCustomFileCandidates(pluginContext.paths.rootDir, fileName, fallbackType);
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
const { publicRuntimeConfig, serverRuntimeConfig } = yield pluginRunner.modifyRuntimeConfig({
|
|
26
|
+
publicRuntimeConfig: config.publicRuntimeConfig || {},
|
|
27
|
+
serverRuntimeConfig: config.serverRuntimeConfig || {}
|
|
28
28
|
});
|
|
29
29
|
const serverKeys = Object.keys(serverRuntimeConfig);
|
|
30
30
|
const publicKeys = Object.keys(publicRuntimeConfig);
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { IRouter, IPageRouteRecord } from './routerTypes';
|
|
2
|
-
import { RedoxStore,
|
|
3
|
-
export declare class
|
|
2
|
+
import { RedoxStore, Application, IAppContext, ApplicationOptions, IRerenderConfig, IError } from './applicationTypes';
|
|
3
|
+
export declare class ApplicationImpl<Config extends {} = {}> {
|
|
4
4
|
private _router;
|
|
5
5
|
private _appComponent;
|
|
6
6
|
private _pluginManager;
|
|
7
7
|
private _context;
|
|
8
|
+
private _config;
|
|
8
9
|
private _store;
|
|
9
10
|
private _error;
|
|
10
11
|
private _loader;
|
|
11
|
-
constructor(options:
|
|
12
|
+
constructor(options: ApplicationOptions<Config>);
|
|
12
13
|
get router(): IRouter<IPageRouteRecord>;
|
|
14
|
+
get config(): Config;
|
|
13
15
|
get context(): IAppContext;
|
|
14
16
|
get pluginManager(): import("@shuvi/hook").HookManager<import("./runtimPlugin").RuntimePluginHooks, void>;
|
|
15
17
|
get appComponent(): any;
|
|
@@ -25,5 +27,5 @@ export declare class Application {
|
|
|
25
27
|
private _initPlugin;
|
|
26
28
|
private _initAppContext;
|
|
27
29
|
private _initAppComponent;
|
|
28
|
-
getPublicAPI():
|
|
30
|
+
getPublicAPI(): Application<Config>;
|
|
29
31
|
}
|
|
@@ -9,14 +9,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.ApplicationImpl = void 0;
|
|
13
13
|
const runtimPlugin_1 = require("./runtimPlugin");
|
|
14
14
|
const runtimPlugin_2 = require("./runtimPlugin");
|
|
15
15
|
const redox_1 = require("@shuvi/redox");
|
|
16
16
|
const error_1 = require("./models/error");
|
|
17
17
|
const loader_1 = require("./models/loader");
|
|
18
|
-
class
|
|
18
|
+
class ApplicationImpl {
|
|
19
19
|
constructor(options) {
|
|
20
|
+
this._config = options.config;
|
|
20
21
|
this._router = options.router;
|
|
21
22
|
this._context = {};
|
|
22
23
|
this._store = (0, redox_1.redox)({ initialState: options.initialState });
|
|
@@ -29,6 +30,9 @@ class Application {
|
|
|
29
30
|
get router() {
|
|
30
31
|
return this._router;
|
|
31
32
|
}
|
|
33
|
+
get config() {
|
|
34
|
+
return this._config;
|
|
35
|
+
}
|
|
32
36
|
get context() {
|
|
33
37
|
return this._context;
|
|
34
38
|
}
|
|
@@ -95,10 +99,21 @@ class Application {
|
|
|
95
99
|
getPublicAPI() {
|
|
96
100
|
const self = this;
|
|
97
101
|
return {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
get config() {
|
|
103
|
+
return self._config;
|
|
104
|
+
},
|
|
105
|
+
get context() {
|
|
106
|
+
return self._context;
|
|
107
|
+
},
|
|
108
|
+
get router() {
|
|
109
|
+
return self._router;
|
|
110
|
+
},
|
|
111
|
+
get appComponent() {
|
|
112
|
+
return self._appComponent;
|
|
113
|
+
},
|
|
114
|
+
get store() {
|
|
115
|
+
return self._store;
|
|
116
|
+
},
|
|
102
117
|
get error() {
|
|
103
118
|
return self.error;
|
|
104
119
|
},
|
|
@@ -117,4 +132,4 @@ class Application {
|
|
|
117
132
|
};
|
|
118
133
|
}
|
|
119
134
|
}
|
|
120
|
-
exports.
|
|
135
|
+
exports.ApplicationImpl = ApplicationImpl;
|
|
@@ -23,7 +23,8 @@ export interface IErrorState {
|
|
|
23
23
|
export declare type IAppState = {
|
|
24
24
|
error?: IErrorState;
|
|
25
25
|
};
|
|
26
|
-
export interface
|
|
26
|
+
export interface Application<Config extends {} = {}> {
|
|
27
|
+
readonly config: Config;
|
|
27
28
|
readonly context: IAppContext;
|
|
28
29
|
readonly router: IRouter<IPageRouteRecord>;
|
|
29
30
|
readonly appComponent: any;
|
|
@@ -34,7 +35,8 @@ export interface IApplication {
|
|
|
34
35
|
getLoadersData(): Record<string, any>;
|
|
35
36
|
setLoadersData(datas: Record<string, any>): void;
|
|
36
37
|
}
|
|
37
|
-
export interface
|
|
38
|
+
export interface ApplicationOptions<C extends {}> {
|
|
39
|
+
config: C;
|
|
38
40
|
router: IRouter;
|
|
39
41
|
AppComponent: any;
|
|
40
42
|
initialState?: IAppState;
|
package/lib/shared/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ export * from './loader';
|
|
|
6
6
|
export { errorModel } from './models/error';
|
|
7
7
|
export { loaderModel } from './models/loader';
|
|
8
8
|
export * from './applicationTypes';
|
|
9
|
-
export type {
|
|
9
|
+
export type { ApplicationImpl } from './application';
|
|
10
10
|
export type { IRuntimeConfig } from './runtimeConfigTypes';
|
|
11
11
|
export { IAppModule, IPluginInstance, BuiltInRuntimePluginHooks, CustomRuntimePluginHooks, RuntimePluginHooks, createRuntimePlugin, createRuntimePluginBefore, createRuntimePluginAfter, RuntimePluginInstance } from './runtimPlugin';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-shared",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.16",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -83,18 +83,18 @@
|
|
|
83
83
|
"node": ">= 12.0.0"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@shuvi/hook": "1.0.0-rc.
|
|
86
|
+
"@shuvi/hook": "1.0.0-rc.16",
|
|
87
87
|
"@shuvi/redox": "0.0.6",
|
|
88
|
-
"@shuvi/router": "1.0.0-rc.
|
|
89
|
-
"@shuvi/runtime": "1.0.0-rc.
|
|
90
|
-
"@shuvi/service": "1.0.0-rc.
|
|
91
|
-
"@shuvi/shared": "1.0.0-rc.
|
|
92
|
-
"@shuvi/toolpack": "1.0.0-rc.
|
|
93
|
-
"@shuvi/utils": "1.0.0-rc.
|
|
88
|
+
"@shuvi/router": "1.0.0-rc.16",
|
|
89
|
+
"@shuvi/runtime": "1.0.0-rc.16",
|
|
90
|
+
"@shuvi/service": "1.0.0-rc.16",
|
|
91
|
+
"@shuvi/shared": "1.0.0-rc.16",
|
|
92
|
+
"@shuvi/toolpack": "1.0.0-rc.16",
|
|
93
|
+
"@shuvi/utils": "1.0.0-rc.16",
|
|
94
94
|
"redux": "4.1.2"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
|
-
"@shuvi/service": "1.0.0-rc.
|
|
97
|
+
"@shuvi/service": "1.0.0-rc.16"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@types/minimatch": "3.0.5"
|