@shuvi/platform-shared 1.0.0-rc.1 → 1.0.0-rc.12
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/helper/getPublicPath.js +1 -2
- package/esm/shared/index.d.ts +3 -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 +28 -15
- package/esm/shared/{lifecycle.d.ts → runtimPlugin.d.ts} +2 -4
- package/esm/shared/{lifecycle.js → runtimPlugin.js} +2 -1
- package/esm/shared/runtimeConfigTypes.d.ts +1 -0
- package/esm/shared/runtimeConfigTypes.js +1 -0
- package/esm/shared/shuvi-singleton-runtimeConfig.d.ts +1 -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 -13
- package/lib/node/platform/plugins/main/hooks.d.ts +1 -1
- package/lib/node/platform/plugins/main/index.d.ts +1 -13
- package/lib/node/platform/plugins/main/index.js +1 -2
- package/lib/node/platform/runtimeFiles.d.ts +1 -1
- package/lib/node/platform/runtimeFiles.js +2 -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 +3 -0
- package/lib/node/project/file-presets/files/app/user/server.js.js +15 -0
- package/lib/node/project/file-presets/index.d.ts +3 -3
- package/lib/node/project/projectContext.d.ts +2 -1
- package/lib/node/project/projectContext.js +2 -1
- package/lib/node/route/helpers.d.ts +5 -6
- package/lib/node/route/helpers.js +32 -47
- package/lib/node/route/index.d.ts +1 -1
- package/lib/node/route/index.js +2 -1
- package/lib/node/route/matchSpec.d.ts +8 -0
- package/lib/node/route/matchSpec.js +138 -0
- package/lib/node/route/route.d.ts +9 -12
- package/lib/node/route/route.js +88 -78
- 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/helper/getPublicPath.js +1 -2
- package/lib/shared/index.d.ts +3 -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 +28 -15
- package/lib/shared/{lifecycle.d.ts → runtimPlugin.d.ts} +2 -4
- package/lib/shared/{lifecycle.js → runtimPlugin.js} +4 -2
- package/lib/shared/runtimeConfigTypes.d.ts +1 -0
- package/lib/{node/platform/plugins/main/shuvi-app.js → shared/runtimeConfigTypes.js} +0 -0
- package/lib/shared/shuvi-singleton-runtimeConfig.d.ts +1 -1
- package/package.json +31 -20
- package/shuvi-type-extensions-node.js +1 -0
- package/{shuvi-app-extensions.d.ts → 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/node/platform/plugins/main/shuvi-app.d.ts +0 -8
- package/lib/shared/loader/loaderManager.d.ts +0 -16
- package/lib/shared/loader/loaderManager.js +0 -53
|
@@ -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;
|
|
@@ -15,7 +15,7 @@ exports.errorModel = (0, redox_1.defineModel)({
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
actions: {
|
|
18
|
-
|
|
18
|
+
set(payload) {
|
|
19
19
|
this.setError(payload || constants_1.SHUVI_ERROR.APP_ERROR);
|
|
20
20
|
},
|
|
21
21
|
clear() {
|
|
@@ -25,7 +25,7 @@ exports.errorModel = (0, redox_1.defineModel)({
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
views: {
|
|
28
|
-
|
|
28
|
+
errorObject() {
|
|
29
29
|
return this.error;
|
|
30
30
|
},
|
|
31
31
|
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,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loaderModel = void 0;
|
|
4
|
+
const redox_1 = require("@shuvi/redox");
|
|
5
|
+
const initState = {
|
|
6
|
+
dataByRouteId: {}
|
|
7
|
+
};
|
|
8
|
+
exports.loaderModel = (0, redox_1.defineModel)({
|
|
9
|
+
name: 'loader',
|
|
10
|
+
state: initState,
|
|
11
|
+
reducers: {
|
|
12
|
+
setDatas(state, newData) {
|
|
13
|
+
return Object.assign(Object.assign({}, state), { dataByRouteId: Object.assign(Object.assign({}, state.dataByRouteId), newData) });
|
|
14
|
+
}
|
|
15
|
+
// clearDatas(state) {
|
|
16
|
+
// return {
|
|
17
|
+
// ...state,
|
|
18
|
+
// dataByRouteId: {}
|
|
19
|
+
// };
|
|
20
|
+
// }
|
|
21
|
+
},
|
|
22
|
+
views: {
|
|
23
|
+
getAllData() {
|
|
24
|
+
return this.dataByRouteId;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
@@ -4,25 +4,38 @@ export declare type IURLQuery = ParsedQuery;
|
|
|
4
4
|
export declare type IURLParams = IParams;
|
|
5
5
|
export interface IPageRouteRecord extends IRouteRecord {
|
|
6
6
|
id: string;
|
|
7
|
+
path: string;
|
|
7
8
|
component?: any;
|
|
8
9
|
children?: IPageRouteRecord[];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
__componentSource__?:
|
|
12
|
-
|
|
13
|
-
__import__?: never;
|
|
14
|
-
__resolveWeak__?: () => any;
|
|
10
|
+
__import__?: () => Promise<any>;
|
|
11
|
+
__resolveWeak__?: () => string[];
|
|
12
|
+
__componentSource__?: string;
|
|
13
|
+
__componentRawRequest__?: string;
|
|
15
14
|
[x: string]: any;
|
|
16
15
|
}
|
|
17
|
-
export interface
|
|
16
|
+
export interface IPlatformConfig {
|
|
17
|
+
name: string;
|
|
18
|
+
framework?: string;
|
|
19
|
+
target?: string;
|
|
20
|
+
[index: string]: any;
|
|
21
|
+
}
|
|
22
|
+
export declare type IRouterHistoryMode = 'browser' | 'hash' | 'memory';
|
|
23
|
+
export interface IPageRouteConfig {
|
|
24
|
+
children?: IPageRouteConfig[];
|
|
25
|
+
name?: string;
|
|
26
|
+
component?: string;
|
|
27
|
+
redirect?: string;
|
|
28
|
+
path: string;
|
|
29
|
+
}
|
|
30
|
+
export interface IPageRouteConfigWithId extends IPageRouteConfig {
|
|
18
31
|
id: string;
|
|
19
|
-
|
|
20
|
-
|
|
32
|
+
children?: IPageRouteConfigWithId[];
|
|
33
|
+
}
|
|
34
|
+
export interface IMiddlewareRouteConfig {
|
|
21
35
|
path: string;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
[x: string]: any;
|
|
36
|
+
middleware: string;
|
|
37
|
+
}
|
|
38
|
+
export interface IApiRouteConfig {
|
|
39
|
+
path: string;
|
|
40
|
+
api: string;
|
|
28
41
|
}
|
|
@@ -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,9 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var _a;
|
|
11
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.initPlugins = exports.createRuntimePlugin = exports.getManager = void 0;
|
|
13
|
+
exports.initPlugins = exports.createRuntimePluginAfter = exports.createRuntimePlugin = exports.createRuntimePluginBefore = exports.getManager = void 0;
|
|
13
14
|
const hook_1 = require("@shuvi/hook");
|
|
15
|
+
const plugins_1 = require("@shuvi/shared/lib/plugins");
|
|
14
16
|
const init = (0, hook_1.createAsyncParallelHook)();
|
|
15
17
|
const appContext = (0, hook_1.createAsyncSeriesWaterfallHook)();
|
|
16
18
|
const appComponent = (0, hook_1.createAsyncSeriesWaterfallHook)();
|
|
@@ -23,7 +25,7 @@ const builtinRuntimePluginHooks = {
|
|
|
23
25
|
};
|
|
24
26
|
const getManager = () => (0, hook_1.createHookManager)(builtinRuntimePluginHooks, false);
|
|
25
27
|
exports.getManager = getManager;
|
|
26
|
-
|
|
28
|
+
_a = (0, plugins_1.createPluginCreator)((0, exports.getManager)()), exports.createRuntimePluginBefore = _a.createPluginBefore, exports.createRuntimePlugin = _a.createPlugin, exports.createRuntimePluginAfter = _a.createPluginAfter;
|
|
27
29
|
const initPlugins = (pluginManager, plugins) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
30
|
// clear plugin at development mode every time
|
|
29
31
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type IRuntimeConfig = Record<string, string>;
|
|
File without changes
|
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.12",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"sideEffects": false,
|
|
12
12
|
"files": [
|
|
13
|
-
"lib",
|
|
14
13
|
"esm",
|
|
15
|
-
"
|
|
14
|
+
"lib",
|
|
16
15
|
"template",
|
|
17
|
-
"shuvi-
|
|
16
|
+
"shuvi-type-extensions-node.d.js",
|
|
17
|
+
"shuvi-type-extensions-node.js",
|
|
18
|
+
"shuvi-type-extensions-runtime.d.ts"
|
|
18
19
|
],
|
|
19
20
|
"exports": {
|
|
20
21
|
"./shared": {
|
|
@@ -62,21 +63,11 @@
|
|
|
62
63
|
"default": "./esm/shuvi-app/*.js"
|
|
63
64
|
},
|
|
64
65
|
"./template/*": "./template/*",
|
|
65
|
-
"./shuvi-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
"dependencies": {
|
|
71
|
-
"redux": "4.1.2",
|
|
72
|
-
"@shuvi/redox": "0.0.3",
|
|
73
|
-
"@shuvi/hook": "1.0.0-rc.1",
|
|
74
|
-
"@shuvi/service": "1.0.0-rc.1",
|
|
75
|
-
"@shuvi/toolpack": "1.0.0-rc.1",
|
|
76
|
-
"@shuvi/router": "1.0.0-rc.1",
|
|
77
|
-
"@shuvi/runtime": "1.0.0-rc.1",
|
|
78
|
-
"@shuvi/shared": "1.0.0-rc.1",
|
|
79
|
-
"@shuvi/utils": "1.0.0-rc.1"
|
|
66
|
+
"./shuvi-type-extensions-node": {
|
|
67
|
+
"types": "./shuvi-type-extensions-node.d.js",
|
|
68
|
+
"default": "./shuvi-type-extensions-node.js"
|
|
69
|
+
},
|
|
70
|
+
"./shuvi-type-extensions-runtime": "./shuvi-type-extensions-runtime.d.ts"
|
|
80
71
|
},
|
|
81
72
|
"scripts": {
|
|
82
73
|
"dev": "run-p watch:*",
|
|
@@ -86,5 +77,25 @@
|
|
|
86
77
|
"build": "run-p build:*",
|
|
87
78
|
"build:esm": "tsc -p tsconfig.build.browser.json",
|
|
88
79
|
"build:cjs": "tsc -p tsconfig.build.node.json"
|
|
80
|
+
},
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">= 12.0.0"
|
|
83
|
+
},
|
|
84
|
+
"dependencies": {
|
|
85
|
+
"@shuvi/hook": "1.0.0-rc.12",
|
|
86
|
+
"@shuvi/redox": "0.0.6",
|
|
87
|
+
"@shuvi/router": "1.0.0-rc.12",
|
|
88
|
+
"@shuvi/runtime": "1.0.0-rc.12",
|
|
89
|
+
"@shuvi/service": "1.0.0-rc.12",
|
|
90
|
+
"@shuvi/shared": "1.0.0-rc.12",
|
|
91
|
+
"@shuvi/toolpack": "1.0.0-rc.12",
|
|
92
|
+
"@shuvi/utils": "1.0.0-rc.12",
|
|
93
|
+
"redux": "4.1.2"
|
|
94
|
+
},
|
|
95
|
+
"peerDependencies": {
|
|
96
|
+
"@shuvi/service": "1.0.0-rc.12"
|
|
97
|
+
},
|
|
98
|
+
"devDependencies": {
|
|
99
|
+
"@types/minimatch": "3.0.5"
|
|
89
100
|
}
|
|
90
|
-
}
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {};
|
|
@@ -8,14 +8,10 @@ declare module '@shuvi/app/core/error' {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
declare module '@shuvi/app/core/platform' {
|
|
11
|
-
import {
|
|
12
|
-
IPageRouteRecord,
|
|
13
|
-
IRawPageRouteRecord,
|
|
14
|
-
IViewClient
|
|
15
|
-
} from '@shuvi/platform-shared/shared';
|
|
11
|
+
import { IPageRouteRecord, IViewClient } from '@shuvi/platform-shared/shared';
|
|
16
12
|
|
|
17
13
|
export interface IGetRoutes {
|
|
18
|
-
(routes:
|
|
14
|
+
(routes: IPageRouteRecord[]): IPageRouteRecord[];
|
|
19
15
|
}
|
|
20
16
|
|
|
21
17
|
export const getRoutes: IGetRoutes;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
declare function createLoaderManager(): {
|
|
2
|
-
getAllData(): Record<string, any>;
|
|
3
|
-
getData(id: string): any;
|
|
4
|
-
setDatas(obj: Record<string, any>): void;
|
|
5
|
-
subscribe(cb: Function): () => void;
|
|
6
|
-
clearAllData(): void;
|
|
7
|
-
};
|
|
8
|
-
export declare const getLoaderManager: () => {
|
|
9
|
-
getAllData(): Record<string, any>;
|
|
10
|
-
getData(id: string): any;
|
|
11
|
-
setDatas(obj: Record<string, any>): void;
|
|
12
|
-
subscribe(cb: Function): () => void;
|
|
13
|
-
clearAllData(): void;
|
|
14
|
-
};
|
|
15
|
-
export declare type LoaderManager = ReturnType<typeof createLoaderManager>;
|
|
16
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
let loaderManager;
|
|
2
|
-
function createLoaderManager() {
|
|
3
|
-
const datas = new Map();
|
|
4
|
-
const subscribers = [];
|
|
5
|
-
return {
|
|
6
|
-
getAllData() {
|
|
7
|
-
let res = {};
|
|
8
|
-
for (const [id, data] of datas.entries()) {
|
|
9
|
-
res[id] = data;
|
|
10
|
-
}
|
|
11
|
-
return res;
|
|
12
|
-
},
|
|
13
|
-
getData(id) {
|
|
14
|
-
if (!datas.has(id)) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return datas.get(id);
|
|
18
|
-
},
|
|
19
|
-
setDatas(obj) {
|
|
20
|
-
for (const [id, data] of Object.entries(obj)) {
|
|
21
|
-
datas.set(id, data);
|
|
22
|
-
}
|
|
23
|
-
subscribers.forEach(fn => fn());
|
|
24
|
-
},
|
|
25
|
-
// setData(id: string, data: any) {
|
|
26
|
-
// datas.set(id, data);
|
|
27
|
-
// subscribers.forEach(fn => fn());
|
|
28
|
-
// },
|
|
29
|
-
subscribe(cb) {
|
|
30
|
-
subscribers.push(cb);
|
|
31
|
-
return () => {
|
|
32
|
-
const index = subscribers.indexOf(cb);
|
|
33
|
-
if (index >= 0) {
|
|
34
|
-
subscribers.splice(index, 1);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
clearAllData() {
|
|
39
|
-
datas.clear();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
export const getLoaderManager = () => {
|
|
44
|
-
if (loaderManager) {
|
|
45
|
-
return loaderManager;
|
|
46
|
-
}
|
|
47
|
-
loaderManager = createLoaderManager();
|
|
48
|
-
return loaderManager;
|
|
49
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { extendedHooks } from './hooks';
|
|
2
|
-
declare module '@shuvi/runtime' {
|
|
3
|
-
interface CustomCorePluginHooks {
|
|
4
|
-
addEntryCode: typeof extendedHooks.addEntryCode;
|
|
5
|
-
addPolyfill: typeof extendedHooks.addPolyfill;
|
|
6
|
-
modifyRuntimeConfig: typeof extendedHooks.modifyRuntimeConfig;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
declare function createLoaderManager(): {
|
|
2
|
-
getAllData(): Record<string, any>;
|
|
3
|
-
getData(id: string): any;
|
|
4
|
-
setDatas(obj: Record<string, any>): void;
|
|
5
|
-
subscribe(cb: Function): () => void;
|
|
6
|
-
clearAllData(): void;
|
|
7
|
-
};
|
|
8
|
-
export declare const getLoaderManager: () => {
|
|
9
|
-
getAllData(): Record<string, any>;
|
|
10
|
-
getData(id: string): any;
|
|
11
|
-
setDatas(obj: Record<string, any>): void;
|
|
12
|
-
subscribe(cb: Function): () => void;
|
|
13
|
-
clearAllData(): void;
|
|
14
|
-
};
|
|
15
|
-
export declare type LoaderManager = ReturnType<typeof createLoaderManager>;
|
|
16
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLoaderManager = void 0;
|
|
4
|
-
let loaderManager;
|
|
5
|
-
function createLoaderManager() {
|
|
6
|
-
const datas = new Map();
|
|
7
|
-
const subscribers = [];
|
|
8
|
-
return {
|
|
9
|
-
getAllData() {
|
|
10
|
-
let res = {};
|
|
11
|
-
for (const [id, data] of datas.entries()) {
|
|
12
|
-
res[id] = data;
|
|
13
|
-
}
|
|
14
|
-
return res;
|
|
15
|
-
},
|
|
16
|
-
getData(id) {
|
|
17
|
-
if (!datas.has(id)) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return datas.get(id);
|
|
21
|
-
},
|
|
22
|
-
setDatas(obj) {
|
|
23
|
-
for (const [id, data] of Object.entries(obj)) {
|
|
24
|
-
datas.set(id, data);
|
|
25
|
-
}
|
|
26
|
-
subscribers.forEach(fn => fn());
|
|
27
|
-
},
|
|
28
|
-
// setData(id: string, data: any) {
|
|
29
|
-
// datas.set(id, data);
|
|
30
|
-
// subscribers.forEach(fn => fn());
|
|
31
|
-
// },
|
|
32
|
-
subscribe(cb) {
|
|
33
|
-
subscribers.push(cb);
|
|
34
|
-
return () => {
|
|
35
|
-
const index = subscribers.indexOf(cb);
|
|
36
|
-
if (index >= 0) {
|
|
37
|
-
subscribers.splice(index, 1);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
clearAllData() {
|
|
42
|
-
datas.clear();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
const getLoaderManager = () => {
|
|
47
|
-
if (loaderManager) {
|
|
48
|
-
return loaderManager;
|
|
49
|
-
}
|
|
50
|
-
loaderManager = createLoaderManager();
|
|
51
|
-
return loaderManager;
|
|
52
|
-
};
|
|
53
|
-
exports.getLoaderManager = getLoaderManager;
|