@shuvi/platform-shared 1.0.0-rc.3 → 1.0.0-rc.6
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 +13 -66
- package/esm/shared/application.js +41 -12
- package/esm/shared/applicationTypes.d.ts +15 -18
- package/esm/shared/helper/getAppData.d.ts +1 -4
- package/esm/shared/helper/getAppData.js +0 -1
- package/esm/shared/index.d.ts +2 -1
- package/esm/shared/index.js +2 -3
- package/esm/shared/loader/index.d.ts +0 -1
- package/esm/shared/loader/index.js +0 -1
- package/esm/shared/loader/loader.d.ts +1 -1
- package/esm/shared/loader/loader.js +2 -2
- package/esm/shared/loader/types.d.ts +4 -8
- package/esm/shared/models/error.d.ts +4 -4
- package/esm/shared/models/error.js +2 -2
- package/esm/shared/models/loader.d.ts +13 -0
- package/esm/shared/models/loader.js +24 -0
- package/esm/shared/routerTypes.d.ts +4 -13
- package/esm/shared/{lifecycle.d.ts → runtimPlugin.d.ts} +2 -4
- package/esm/shared/{lifecycle.js → runtimPlugin.js} +2 -1
- package/esm/shuvi-app/shuvi-runtime-app.d.ts +1 -1
- package/esm/shuvi-app/shuvi-runtime-index.d.ts +1 -1
- package/esm/shuvi-app/shuvi-runtime-index.js +1 -1
- package/lib/node/platform/index.d.ts +1 -14
- package/lib/node/platform/plugins/main/index.d.ts +1 -14
- package/lib/node/platform/plugins/main/index.js +1 -2
- package/lib/node/platform/runtimeFiles.d.ts +1 -1
- package/lib/node/project/file-presets/files/app/core/entry.js.d.ts +1 -1
- package/lib/node/project/file-presets/files/app/core/error.js.d.ts +1 -1
- package/lib/node/project/file-presets/files/app/core/platform.js.d.ts +1 -1
- package/lib/node/project/file-presets/files/app/core/polyfill.js.d.ts +1 -1
- package/lib/node/project/file-presets/files/app/core/runtimeConfig.js.d.ts +1 -1
- package/lib/node/project/file-presets/files/app/core/setPublicRuntimeConfig.js.d.ts +1 -1
- package/lib/node/project/file-presets/files/app/core/setRuntimeConfig.js.d.ts +1 -1
- package/lib/node/project/file-presets/files/app/user/app.js.d.ts +1 -1
- package/lib/node/project/file-presets/files/app/user/error.js.d.ts +1 -1
- package/lib/node/project/file-presets/files/app/user/server.js.d.ts +1 -1
- package/lib/node/project/file-presets/index.d.ts +3 -3
- package/lib/node/route/helpers.js +6 -27
- package/lib/node/route/index.d.ts +1 -1
- package/lib/node/route/index.js +2 -1
- package/lib/node/route/route.d.ts +3 -3
- package/lib/node/route/route.js +26 -5
- package/lib/shared/application.d.ts +13 -66
- package/lib/shared/application.js +43 -14
- package/lib/shared/applicationTypes.d.ts +15 -18
- package/lib/shared/helper/getAppData.d.ts +1 -4
- package/lib/shared/helper/getAppData.js +0 -1
- package/lib/shared/index.d.ts +2 -1
- package/lib/shared/index.js +7 -4
- package/lib/shared/loader/index.d.ts +0 -1
- package/lib/shared/loader/index.js +0 -1
- package/lib/shared/loader/loader.d.ts +1 -1
- package/lib/shared/loader/loader.js +2 -2
- package/lib/shared/loader/types.d.ts +4 -8
- package/lib/shared/models/error.d.ts +4 -4
- package/lib/shared/models/error.js +2 -2
- package/lib/shared/models/loader.d.ts +13 -0
- package/lib/shared/models/loader.js +27 -0
- package/lib/shared/routerTypes.d.ts +4 -13
- package/lib/shared/{lifecycle.d.ts → runtimPlugin.d.ts} +2 -4
- package/lib/shared/{lifecycle.js → runtimPlugin.js} +4 -2
- package/package.json +12 -11
- package/shuvi-type-extensions-node.js +1 -0
- package/shuvi-type-extensions-runtime.d.ts +2 -6
- package/esm/shared/loader/loaderManager.d.ts +0 -16
- package/esm/shared/loader/loaderManager.js +0 -49
- package/lib/shared/loader/loaderManager.d.ts +0 -16
- package/lib/shared/loader/loaderManager.js +0 -53
|
@@ -1,78 +1,25 @@
|
|
|
1
|
-
import { IRouter } from './routerTypes';
|
|
2
|
-
import {
|
|
1
|
+
import { IRouter, IPageRouteRecord } from './routerTypes';
|
|
2
|
+
import { RedoxStore, IApplication, IAppContext, IApplicationOptions, IRerenderConfig, IError } from './applicationTypes';
|
|
3
3
|
export declare class Application {
|
|
4
|
-
private _error;
|
|
5
4
|
private _router;
|
|
6
5
|
private _appComponent;
|
|
7
6
|
private _pluginManager;
|
|
8
7
|
private _context;
|
|
9
|
-
private
|
|
8
|
+
private _store;
|
|
9
|
+
private _error;
|
|
10
|
+
private _loader;
|
|
10
11
|
constructor(options: IApplicationOptions);
|
|
11
|
-
get router(): IRouter<
|
|
12
|
+
get router(): IRouter<IPageRouteRecord>;
|
|
12
13
|
get context(): IAppContext;
|
|
13
|
-
get pluginManager(): import("@shuvi/hook").HookManager<import("./
|
|
14
|
+
get pluginManager(): import("@shuvi/hook").HookManager<import("./runtimPlugin").RuntimePluginHooks, void>;
|
|
14
15
|
get appComponent(): any;
|
|
15
|
-
get error():
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
$actions: {
|
|
21
|
-
setError: (payload?: import("./applicationTypes").IError | undefined) => import("@shuvi/redox").Action<import("./applicationTypes").IError | undefined>;
|
|
22
|
-
} & {
|
|
23
|
-
error: (payload?: import("./applicationTypes").IError | undefined) => void;
|
|
24
|
-
clear: () => void;
|
|
25
|
-
} & {
|
|
26
|
-
[X: string]: never;
|
|
27
|
-
[X: number]: never;
|
|
28
|
-
[X: symbol]: never;
|
|
29
|
-
};
|
|
30
|
-
$views: import("@shuvi/redox").RedoxViews<({
|
|
31
|
-
getError(): import("./applicationTypes").IError | undefined;
|
|
32
|
-
hasError(): boolean;
|
|
33
|
-
} & ThisType<import("./applicationTypes").IErrorState & {
|
|
34
|
-
$state: import("./applicationTypes").IErrorState;
|
|
35
|
-
} & import("@shuvi/redox").RedoxViews<{
|
|
36
|
-
getError(): import("./applicationTypes").IError | undefined;
|
|
37
|
-
hasError(): boolean;
|
|
38
|
-
}> & {
|
|
39
|
-
$dep: {} & {} & {};
|
|
40
|
-
}>) | undefined>;
|
|
41
|
-
$createSelector: <TReturn>(selector: import("@shuvi/redox").ISelector<import("@shuvi/redox").Model<"error", import("./applicationTypes").IErrorState, {}, {
|
|
42
|
-
setError(_state: import("./applicationTypes").IErrorState, error?: import("./applicationTypes").IError | undefined): {
|
|
43
|
-
error: import("./applicationTypes").IError | undefined;
|
|
44
|
-
};
|
|
45
|
-
}, {
|
|
46
|
-
error(payload?: import("./applicationTypes").IError | undefined): void;
|
|
47
|
-
clear(): void;
|
|
48
|
-
}, {
|
|
49
|
-
getError(): import("./applicationTypes").IError | undefined;
|
|
50
|
-
hasError(): boolean;
|
|
51
|
-
}>, TReturn>) => (() => TReturn) & {
|
|
52
|
-
clearCache: () => void;
|
|
53
|
-
};
|
|
54
|
-
} & import("@shuvi/redox").RedoxViews<{
|
|
55
|
-
getError(): import("./applicationTypes").IError | undefined;
|
|
56
|
-
hasError(): boolean;
|
|
57
|
-
} & ThisType<import("./applicationTypes").IErrorState & {
|
|
58
|
-
$state: import("./applicationTypes").IErrorState;
|
|
59
|
-
} & import("@shuvi/redox").RedoxViews<{
|
|
60
|
-
getError(): import("./applicationTypes").IError | undefined;
|
|
61
|
-
hasError(): boolean;
|
|
62
|
-
}> & {
|
|
63
|
-
$dep: {} & {} & {};
|
|
64
|
-
}>> & {
|
|
65
|
-
setError: (payload?: import("./applicationTypes").IError | undefined) => import("@shuvi/redox").Action<import("./applicationTypes").IError | undefined>;
|
|
66
|
-
} & {
|
|
67
|
-
error: (payload?: import("./applicationTypes").IError | undefined) => void;
|
|
68
|
-
clear: () => void;
|
|
69
|
-
} & {
|
|
70
|
-
[X: string]: never;
|
|
71
|
-
[X: number]: never;
|
|
72
|
-
[X: symbol]: never;
|
|
73
|
-
};
|
|
16
|
+
get error(): IError | undefined;
|
|
17
|
+
setError(err: IError): void;
|
|
18
|
+
clearError(): void;
|
|
19
|
+
getLoadersData(): Record<string, any>;
|
|
20
|
+
setLoadersData(datas: Record<string, any>): void;
|
|
74
21
|
init(): Promise<void>;
|
|
75
|
-
get
|
|
22
|
+
get store(): RedoxStore;
|
|
76
23
|
updateComponents({ AppComponent }?: IRerenderConfig): Promise<void>;
|
|
77
24
|
dispose(): Promise<void>;
|
|
78
25
|
private _initPlugin;
|
|
@@ -7,16 +7,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { getManager } from './
|
|
11
|
-
import { initPlugins } from './
|
|
10
|
+
import { getManager } from './runtimPlugin';
|
|
11
|
+
import { initPlugins } from './runtimPlugin';
|
|
12
12
|
import { redox } from '@shuvi/redox';
|
|
13
13
|
import { errorModel } from './models/error';
|
|
14
|
+
import { loaderModel } from './models/loader';
|
|
14
15
|
export class Application {
|
|
15
16
|
constructor(options) {
|
|
16
17
|
this._router = options.router;
|
|
17
18
|
this._context = {};
|
|
18
|
-
this.
|
|
19
|
-
this._error = this.
|
|
19
|
+
this._store = redox({ initialState: options.initialState });
|
|
20
|
+
this._error = this._store.getModel(errorModel);
|
|
21
|
+
this._loader = this._store.getModel(loaderModel);
|
|
20
22
|
this._appComponent = options.AppComponent;
|
|
21
23
|
this._pluginManager = getManager();
|
|
22
24
|
initPlugins(this._pluginManager, options.plugins || []);
|
|
@@ -34,7 +36,19 @@ export class Application {
|
|
|
34
36
|
return this._appComponent;
|
|
35
37
|
}
|
|
36
38
|
get error() {
|
|
37
|
-
return this._error;
|
|
39
|
+
return this._error.errorObject;
|
|
40
|
+
}
|
|
41
|
+
setError(err) {
|
|
42
|
+
this._error.set(err);
|
|
43
|
+
}
|
|
44
|
+
clearError() {
|
|
45
|
+
this._error.clear();
|
|
46
|
+
}
|
|
47
|
+
getLoadersData() {
|
|
48
|
+
return this._loader.getAllData;
|
|
49
|
+
}
|
|
50
|
+
setLoadersData(datas) {
|
|
51
|
+
this._loader.setDatas(datas);
|
|
38
52
|
}
|
|
39
53
|
init() {
|
|
40
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -44,8 +58,8 @@ export class Application {
|
|
|
44
58
|
this._router.init();
|
|
45
59
|
});
|
|
46
60
|
}
|
|
47
|
-
get
|
|
48
|
-
return this.
|
|
61
|
+
get store() {
|
|
62
|
+
return this._store;
|
|
49
63
|
}
|
|
50
64
|
updateComponents({ AppComponent } = {}) {
|
|
51
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -76,12 +90,27 @@ export class Application {
|
|
|
76
90
|
});
|
|
77
91
|
}
|
|
78
92
|
getPublicAPI() {
|
|
93
|
+
const self = this;
|
|
79
94
|
return {
|
|
80
|
-
context:
|
|
81
|
-
router:
|
|
82
|
-
appComponent:
|
|
83
|
-
|
|
84
|
-
error
|
|
95
|
+
context: self._context,
|
|
96
|
+
router: self._router,
|
|
97
|
+
appComponent: self._appComponent,
|
|
98
|
+
store: self._store,
|
|
99
|
+
get error() {
|
|
100
|
+
return self.error;
|
|
101
|
+
},
|
|
102
|
+
setError(err) {
|
|
103
|
+
self.setError(err);
|
|
104
|
+
},
|
|
105
|
+
clearError() {
|
|
106
|
+
self.clearError();
|
|
107
|
+
},
|
|
108
|
+
getLoadersData() {
|
|
109
|
+
return self.getLoadersData();
|
|
110
|
+
},
|
|
111
|
+
setLoadersData(datas) {
|
|
112
|
+
self.setLoadersData(datas);
|
|
113
|
+
}
|
|
85
114
|
};
|
|
86
115
|
}
|
|
87
116
|
}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import type { IncomingMessage } from 'http';
|
|
3
|
-
import { IStoreManager } from '@shuvi/redox';
|
|
1
|
+
import { RedoxStore } from '@shuvi/redox';
|
|
4
2
|
import { CustomAppContext } from '@shuvi/runtime';
|
|
5
|
-
import { IRouter } from './routerTypes';
|
|
6
|
-
import { IPluginList } from './
|
|
7
|
-
export declare type IRequest = IncomingMessage & {
|
|
8
|
-
[x: string]: any;
|
|
9
|
-
};
|
|
3
|
+
import { IRouter, IPageRouteRecord } from './routerTypes';
|
|
4
|
+
import { IPluginList } from './runtimPlugin';
|
|
10
5
|
export interface IAppContext extends CustomAppContext {
|
|
11
6
|
[x: string]: unknown;
|
|
12
7
|
}
|
|
13
8
|
export declare type IRerenderConfig = {
|
|
14
9
|
AppComponent?: any;
|
|
15
10
|
};
|
|
16
|
-
export type {
|
|
11
|
+
export type { RedoxStore };
|
|
12
|
+
export declare type ErrorSource = 'server';
|
|
17
13
|
export interface IError {
|
|
18
14
|
code?: number;
|
|
19
15
|
message?: string;
|
|
16
|
+
stack?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
source?: ErrorSource;
|
|
20
19
|
}
|
|
21
20
|
export interface IErrorState {
|
|
22
21
|
error?: IError;
|
|
@@ -24,18 +23,16 @@ export interface IErrorState {
|
|
|
24
23
|
export declare type IAppState = {
|
|
25
24
|
error?: IErrorState;
|
|
26
25
|
};
|
|
27
|
-
export interface IErrorManager {
|
|
28
|
-
getError: IError | undefined;
|
|
29
|
-
error: (err: IError) => void;
|
|
30
|
-
clear: () => void;
|
|
31
|
-
hasError: boolean;
|
|
32
|
-
}
|
|
33
26
|
export interface IApplication {
|
|
34
27
|
readonly context: IAppContext;
|
|
35
|
-
readonly router: IRouter
|
|
28
|
+
readonly router: IRouter<IPageRouteRecord>;
|
|
36
29
|
readonly appComponent: any;
|
|
37
|
-
readonly
|
|
38
|
-
readonly
|
|
30
|
+
readonly store: RedoxStore;
|
|
31
|
+
readonly error: IError | undefined;
|
|
32
|
+
setError(err: IError): void;
|
|
33
|
+
clearError(): void;
|
|
34
|
+
getLoadersData(): Record<string, any>;
|
|
35
|
+
setLoadersData(datas: Record<string, any>): void;
|
|
39
36
|
}
|
|
40
37
|
export interface IApplicationOptions {
|
|
41
38
|
router: IRouter;
|
|
@@ -5,13 +5,10 @@ export declare type IData = {
|
|
|
5
5
|
export declare type IAppData<Data = {}, appState = any> = {
|
|
6
6
|
ssr: boolean;
|
|
7
7
|
runtimeConfig?: Record<string, string>;
|
|
8
|
+
appState?: appState;
|
|
8
9
|
pageData?: {
|
|
9
10
|
[key: string]: any;
|
|
10
11
|
};
|
|
11
|
-
loadersData?: {
|
|
12
|
-
[x: string]: any;
|
|
13
|
-
};
|
|
14
|
-
appState?: appState;
|
|
15
12
|
filesByRoutId: Record<string, string[]>;
|
|
16
13
|
publicPath: string;
|
|
17
14
|
} & {
|
package/esm/shared/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export * from './router';
|
|
|
4
4
|
export * from './response';
|
|
5
5
|
export * from './loader';
|
|
6
6
|
export { errorModel } from './models/error';
|
|
7
|
+
export { loaderModel } from './models/loader';
|
|
7
8
|
export * from './applicationTypes';
|
|
8
9
|
export type { Application } from './application';
|
|
9
10
|
export type { IRuntimeConfig } from './runtimeConfigTypes';
|
|
10
|
-
export { IAppModule, IPluginInstance, BuiltInRuntimePluginHooks, CustomRuntimePluginHooks, RuntimePluginHooks, createRuntimePlugin, RuntimePluginInstance } from './
|
|
11
|
+
export { IAppModule, IPluginInstance, BuiltInRuntimePluginHooks, CustomRuntimePluginHooks, RuntimePluginHooks, createRuntimePlugin, createRuntimePluginBefore, createRuntimePluginAfter, RuntimePluginInstance } from './runtimPlugin';
|
package/esm/shared/index.js
CHANGED
|
@@ -4,7 +4,6 @@ export * from './router';
|
|
|
4
4
|
export * from './response';
|
|
5
5
|
export * from './loader';
|
|
6
6
|
export { errorModel } from './models/error';
|
|
7
|
+
export { loaderModel } from './models/loader';
|
|
7
8
|
export * from './applicationTypes';
|
|
8
|
-
export {
|
|
9
|
-
// fix createRuntimePlugin is not portable end
|
|
10
|
-
createRuntimePlugin } from './lifecycle';
|
|
9
|
+
export { createRuntimePlugin, createRuntimePluginBefore, createRuntimePluginAfter } from './runtimPlugin';
|
|
@@ -5,5 +5,5 @@ interface Result<T> {
|
|
|
5
5
|
result?: T;
|
|
6
6
|
}
|
|
7
7
|
export declare function runInParallerAndBail<T>(fns: Array<() => Promise<T> | T>): Promise<Result<T>[]>;
|
|
8
|
-
export declare function runLoaders(matches: IRouteMatch<IPageRouteRecord>[], loadersByRouteId: Record<string, Loader>, {
|
|
8
|
+
export declare function runLoaders(matches: IRouteMatch<IPageRouteRecord>[], loadersByRouteId: Record<string, Loader>, { query, req, getAppContext }: LoaderContextOptions): Promise<LoaderDataRecord>;
|
|
9
9
|
export {};
|
|
@@ -68,7 +68,7 @@ function errorHelper(msg, statusCode = 500) {
|
|
|
68
68
|
invariant(statusCode >= 400 && statusCode < 600, 'status code should be 4xx and 5xx');
|
|
69
69
|
throw response(msg, { status: statusCode });
|
|
70
70
|
}
|
|
71
|
-
export function runLoaders(matches, loadersByRouteId, {
|
|
71
|
+
export function runLoaders(matches, loadersByRouteId, { query, req, getAppContext }) {
|
|
72
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
73
|
if (!matches.length) {
|
|
74
74
|
return [];
|
|
@@ -78,7 +78,7 @@ export function runLoaders(matches, loadersByRouteId, { isServer, query, req, ge
|
|
|
78
78
|
const loaderFn = loadersByRouteId[match.route.id];
|
|
79
79
|
let res;
|
|
80
80
|
try {
|
|
81
|
-
const value = yield loaderFn(Object.assign({
|
|
81
|
+
const value = yield loaderFn(Object.assign({ pathname: match.pathname, params: match.params, query: query, redirect: redirectHelper, error: errorHelper, appContext }, (req ? { req } : {})));
|
|
82
82
|
if (value) {
|
|
83
83
|
res = createJson(value);
|
|
84
84
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { ShuviRequest } from '@shuvi/service';
|
|
1
2
|
import { IURLQuery, IURLParams } from '../routerTypes';
|
|
2
|
-
import { IAppContext
|
|
3
|
+
import { IAppContext } from '../applicationTypes';
|
|
3
4
|
import { Response } from '../response';
|
|
4
5
|
export interface LoaderContextOptions {
|
|
5
|
-
|
|
6
|
-
req?: IRequest;
|
|
6
|
+
req?: ShuviRequest;
|
|
7
7
|
query: IURLQuery;
|
|
8
8
|
getAppContext: () => IAppContext;
|
|
9
9
|
}
|
|
@@ -17,10 +17,6 @@ export interface ErrorFunction {
|
|
|
17
17
|
* route component getInitialProps params `context`
|
|
18
18
|
*/
|
|
19
19
|
export interface IRouteLoaderContext {
|
|
20
|
-
/**
|
|
21
|
-
* is running on server, if server is true, client will be false
|
|
22
|
-
*/
|
|
23
|
-
isServer: boolean;
|
|
24
20
|
/**
|
|
25
21
|
* current url path
|
|
26
22
|
*/
|
|
@@ -62,7 +58,7 @@ export interface IRouteLoaderContext {
|
|
|
62
58
|
/**
|
|
63
59
|
* server only
|
|
64
60
|
*/
|
|
65
|
-
req?:
|
|
61
|
+
req?: ShuviRequest;
|
|
66
62
|
/**
|
|
67
63
|
* Application context object, which is accessiable during the entire lifecycle of application
|
|
68
64
|
*/
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { IErrorState, IError } from '../applicationTypes';
|
|
2
|
-
export declare const errorModel: import("@shuvi/redox").
|
|
2
|
+
export declare const errorModel: import("@shuvi/redox/esm/core/defineModel").DefineModel<"error", IErrorState, {
|
|
3
3
|
setError(_state: IErrorState, error?: IError): {
|
|
4
4
|
error: IError | undefined;
|
|
5
5
|
};
|
|
6
6
|
}, {
|
|
7
|
-
|
|
7
|
+
set(payload?: IError): void;
|
|
8
8
|
clear(): void;
|
|
9
9
|
}, {
|
|
10
|
-
|
|
10
|
+
errorObject(): IError | undefined;
|
|
11
11
|
hasError(): boolean;
|
|
12
|
-
}>;
|
|
12
|
+
}, {}>;
|
|
13
13
|
export declare type ErrorModel = typeof errorModel;
|
|
@@ -12,7 +12,7 @@ export const errorModel = defineModel({
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
actions: {
|
|
15
|
-
|
|
15
|
+
set(payload) {
|
|
16
16
|
this.setError(payload || SHUVI_ERROR.APP_ERROR);
|
|
17
17
|
},
|
|
18
18
|
clear() {
|
|
@@ -22,7 +22,7 @@ export const errorModel = defineModel({
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
views: {
|
|
25
|
-
|
|
25
|
+
errorObject() {
|
|
26
26
|
return this.error;
|
|
27
27
|
},
|
|
28
28
|
hasError() {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface LoaderState {
|
|
2
|
+
dataByRouteId: Record<string, any>;
|
|
3
|
+
}
|
|
4
|
+
export declare const loaderModel: import("@shuvi/redox/esm/core/defineModel").DefineModel<"loader", LoaderState, {
|
|
5
|
+
setDatas(state: LoaderState, newData: Record<string, any>): {
|
|
6
|
+
dataByRouteId: {
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
}, import("@shuvi/redox/esm/core/defineModel").ActionOptions, {
|
|
11
|
+
getAllData(): Record<string, any>;
|
|
12
|
+
}, {}>;
|
|
13
|
+
export declare type LoaderModel = typeof loaderModel;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineModel } from '@shuvi/redox';
|
|
2
|
+
const initState = {
|
|
3
|
+
dataByRouteId: {}
|
|
4
|
+
};
|
|
5
|
+
export const loaderModel = defineModel({
|
|
6
|
+
name: 'loader',
|
|
7
|
+
state: initState,
|
|
8
|
+
reducers: {
|
|
9
|
+
setDatas(state, newData) {
|
|
10
|
+
return Object.assign(Object.assign({}, state), { dataByRouteId: Object.assign(Object.assign({}, state.dataByRouteId), newData) });
|
|
11
|
+
}
|
|
12
|
+
// clearDatas(state) {
|
|
13
|
+
// return {
|
|
14
|
+
// ...state,
|
|
15
|
+
// dataByRouteId: {}
|
|
16
|
+
// };
|
|
17
|
+
// }
|
|
18
|
+
},
|
|
19
|
+
views: {
|
|
20
|
+
getAllData() {
|
|
21
|
+
return this.dataByRouteId;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -7,18 +7,10 @@ export interface IPageRouteRecord extends IRouteRecord {
|
|
|
7
7
|
path: string;
|
|
8
8
|
component?: any;
|
|
9
9
|
children?: IPageRouteRecord[];
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
path: string;
|
|
15
|
-
component?: any;
|
|
16
|
-
children?: IRawPageRouteRecord[];
|
|
17
|
-
fullPath: string;
|
|
18
|
-
__componentSource__: string;
|
|
19
|
-
__componentSourceWithAffix__: string;
|
|
20
|
-
__import__: () => Promise<any>;
|
|
21
|
-
__resolveWeak__: () => any;
|
|
10
|
+
__import__?: () => Promise<any>;
|
|
11
|
+
__resolveWeak__?: () => string[];
|
|
12
|
+
__componentSource__?: string;
|
|
13
|
+
__componentRawRequest__?: string;
|
|
22
14
|
[x: string]: any;
|
|
23
15
|
}
|
|
24
16
|
export interface IPlatformConfig {
|
|
@@ -34,7 +26,6 @@ export interface IPageRouteConfig {
|
|
|
34
26
|
component?: string;
|
|
35
27
|
redirect?: string;
|
|
36
28
|
path: string;
|
|
37
|
-
fullPath?: string;
|
|
38
29
|
}
|
|
39
30
|
export interface IPageRouteConfigWithId extends IPageRouteConfig {
|
|
40
31
|
id: string;
|
|
@@ -14,10 +14,8 @@ export interface BuiltInRuntimePluginHooks extends HookMap {
|
|
|
14
14
|
}
|
|
15
15
|
export interface RuntimePluginHooks extends BuiltInRuntimePluginHooks, CustomRuntimePluginHooks {
|
|
16
16
|
}
|
|
17
|
-
export declare const getManager: () => import("@shuvi/hook").HookManager<
|
|
18
|
-
export declare const
|
|
19
|
-
setup?: import("@shuvi/hook").Setup<CustomRuntimePluginHooks> | undefined;
|
|
20
|
-
}, options?: import("@shuvi/hook").PluginOptions | undefined) => IPluginInstance<BuiltInRuntimePluginHooks & CustomRuntimePluginHooks, void>;
|
|
17
|
+
export declare const getManager: () => import("@shuvi/hook").HookManager<RuntimePluginHooks, void>;
|
|
18
|
+
export declare const createRuntimePluginBefore: import("@shuvi/shared/lib/plugins").PluginFunc<RuntimePluginHooks, void>, createRuntimePlugin: import("@shuvi/shared/lib/plugins").PluginFunc<RuntimePluginHooks, void>, createRuntimePluginAfter: import("@shuvi/shared/lib/plugins").PluginFunc<RuntimePluginHooks, void>;
|
|
21
19
|
export type { IPluginInstance, CustomRuntimePluginHooks };
|
|
22
20
|
export declare type PluginManager = ReturnType<typeof getManager>;
|
|
23
21
|
export declare type RuntimePluginInstance = IPluginInstance<RuntimePluginHooks, void>;
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { createAsyncParallelHook, createAsyncSeriesWaterfallHook, createHookManager, isPluginInstance } from '@shuvi/hook';
|
|
11
|
+
import { createPluginCreator } from '@shuvi/shared/lib/plugins';
|
|
11
12
|
const init = createAsyncParallelHook();
|
|
12
13
|
const appContext = createAsyncSeriesWaterfallHook();
|
|
13
14
|
const appComponent = createAsyncSeriesWaterfallHook();
|
|
@@ -19,7 +20,7 @@ const builtinRuntimePluginHooks = {
|
|
|
19
20
|
dispose
|
|
20
21
|
};
|
|
21
22
|
export const getManager = () => createHookManager(builtinRuntimePluginHooks, false);
|
|
22
|
-
export const { createPlugin: createRuntimePlugin } = getManager();
|
|
23
|
+
export const { createPluginBefore: createRuntimePluginBefore, createPlugin: createRuntimePlugin, createPluginAfter: createRuntimePluginAfter } = createPluginCreator(getManager());
|
|
23
24
|
export const initPlugins = (pluginManager, plugins) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
25
|
// clear plugin at development mode every time
|
|
25
26
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* import {} from '@shuvi/runtime/app'
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { IAppModule as _IAppModule } from '../shared/
|
|
8
|
+
import { IAppModule as _IAppModule } from '../shared/runtimPlugin';
|
|
9
9
|
declare type AppModule = Required<_IAppModule>;
|
|
10
10
|
export declare type InitFunction = AppModule['init'];
|
|
11
11
|
export declare type AppComponentFunction = AppModule['appComponent'];
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
* import {} from '@shuvi/runtime'
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
export { createRuntimePlugin } from '../shared/
|
|
8
|
+
export { createRuntimePlugin } from '../shared/runtimPlugin';
|
|
9
9
|
export { getPageData } from '../shared/helper/getPageData';
|
|
10
10
|
export type { Loader } from '../shared/loader';
|
|
@@ -1,17 +1,4 @@
|
|
|
1
1
|
export * from './runtimeFiles';
|
|
2
2
|
export declare const SharedPlugins: {
|
|
3
|
-
core: import("@shuvi/hook").IPluginInstance<
|
|
4
|
-
extendConfig: import("@shuvi/hook").SyncWaterfallHook<import("@shuvi/service").Config, void>;
|
|
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/service/lib/core/apiTypes").CustomCorePluginHooks, import("@shuvi/service").IPluginContext>;
|
|
16
|
-
types: string;
|
|
3
|
+
core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
|
|
17
4
|
}[];
|
|
@@ -1,17 +1,4 @@
|
|
|
1
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").FileOptions<any, any> | import("@shuvi/service/lib/project/index").FileOptions<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
|
-
types: string;
|
|
2
|
+
core: import("@shuvi/hook").IPluginInstance<import("@shuvi/service/lib/core/plugin").PluginHooks, import("@shuvi/service").IPluginContext>;
|
|
16
3
|
};
|
|
17
4
|
export default _default;
|
|
@@ -4,4 +4,4 @@ import { IPluginContext } from '@shuvi/service';
|
|
|
4
4
|
* `core/error`, `core/platform`, `core/plugins`, `core/polyfill`, `core/runtimeConfig`, `core/setRuntimeConfig`,
|
|
5
5
|
* `user/error`, `user/runtime` and `entry`
|
|
6
6
|
*/
|
|
7
|
-
export declare const getPresetRuntimeFilesCreator: (platformModule: string, polyfills: string[]) => (pluginContext: IPluginContext) => Promise<import("@shuvi/service/lib/project").
|
|
7
|
+
export declare const getPresetRuntimeFilesCreator: (platformModule: string, polyfills: string[]) => (pluginContext: IPluginContext) => Promise<import("@shuvi/service/lib/project").FileOption<any, any>[]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ProjectContext } from '../../../../projectContext';
|
|
2
|
-
declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").
|
|
2
|
+
declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").FileOptionWithoutId<string, any>, "name">;
|
|
3
3
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: () => Omit<import("@shuvi/service/lib/project/index").
|
|
1
|
+
declare const _default: () => Omit<import("@shuvi/service/lib/project/index").FileOptionWithoutId<string, any>, "name">;
|
|
2
2
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ProjectContext } from '../../../../projectContext';
|
|
2
|
-
declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").
|
|
2
|
+
declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").FileOptionWithoutId<string, any>, "name">;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ProjectContext } from '../../../../projectContext';
|
|
2
|
-
declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project/index").
|
|
2
|
+
declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project/index").FileOptionWithoutId<string, any>, "name">;
|
|
3
3
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ProjectContext } from '../../../../projectContext';
|
|
2
|
-
declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project/index").
|
|
2
|
+
declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project/index").FileOptionWithoutId<string, any>, "name">;
|
|
3
3
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: () => Omit<import("@shuvi/service/lib/project/index").
|
|
1
|
+
declare const _default: () => Omit<import("@shuvi/service/lib/project/index").FileOptionWithoutId<string, any>, "name">;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: () => Omit<import("@shuvi/service/lib/project/index").
|
|
1
|
+
declare const _default: () => Omit<import("@shuvi/service/lib/project/index").FileOptionWithoutId<string, any>, "name">;
|
|
2
2
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ProjectContext } from '../../../../projectContext';
|
|
2
|
-
declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").
|
|
2
|
+
declare const _default: (context: ProjectContext) => Omit<import("@shuvi/service/lib/project").FileOptionWithoutId<string, any>, "name">;
|
|
3
3
|
export default _default;
|