@shuvi/platform-shared 1.0.41 → 1.0.43
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 +1 -0
- package/esm/shared/application.js +3 -1
- package/esm/shared/applicationTypes.d.ts +2 -0
- package/esm/shared/loader/loader.js +2 -7
- package/esm/shared/runtimPlugin.d.ts +2 -0
- package/lib/shared/application.d.ts +1 -0
- package/lib/shared/application.js +3 -1
- package/lib/shared/applicationTypes.d.ts +2 -0
- package/lib/shared/loader/loader.js +2 -7
- package/lib/shared/runtimPlugin.d.ts +2 -0
- package/package.json +8 -8
|
@@ -16,6 +16,7 @@ export class ApplicationImpl {
|
|
|
16
16
|
constructor(options) {
|
|
17
17
|
this._config = options.config;
|
|
18
18
|
this._router = options.router;
|
|
19
|
+
this._request = options.request;
|
|
19
20
|
this._context = {};
|
|
20
21
|
this._store = doura({ initialState: options.initialState });
|
|
21
22
|
this._error = this._store.getModel(errorModelName, errorModel);
|
|
@@ -90,7 +91,8 @@ export class ApplicationImpl {
|
|
|
90
91
|
_initAppContext() {
|
|
91
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
93
|
yield this._pluginManager.runner.appContext(this._context, {
|
|
93
|
-
router: this._router
|
|
94
|
+
router: this._router,
|
|
95
|
+
request: this._request
|
|
94
96
|
});
|
|
95
97
|
});
|
|
96
98
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Doura } from 'doura';
|
|
2
2
|
import { CustomAppContext } from '@shuvi/runtime';
|
|
3
|
+
import type { ShuviRequest } from '@shuvi/service';
|
|
3
4
|
import { IRouter } from './routerTypes';
|
|
4
5
|
import { IPluginList } from './runtimPlugin';
|
|
5
6
|
import { Loader } from './loader';
|
|
@@ -46,5 +47,6 @@ export interface ApplicationInternalOptions<C extends {}> {
|
|
|
46
47
|
getLoaders: GetLoadersFn;
|
|
47
48
|
initialState?: IAppState;
|
|
48
49
|
plugins?: IPluginList;
|
|
50
|
+
request?: ShuviRequest;
|
|
49
51
|
}
|
|
50
52
|
export declare type ApplicationlOptions<C extends {}> = Omit<ApplicationInternalOptions<C>, 'getLoaders' | 'plugins'>;
|
|
@@ -118,13 +118,8 @@ export function runLoaders(matches, loadersByRouteId, loaderContext) {
|
|
|
118
118
|
throw item.error;
|
|
119
119
|
}
|
|
120
120
|
const routeId = matches[index].route.id;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
// allow return undefined
|
|
126
|
-
loaderDatas[routeId] = undefined;
|
|
127
|
-
}
|
|
121
|
+
invariant(item.result, `loader function of route "${matches[index].route.path}" should return a value`);
|
|
122
|
+
loaderDatas[routeId] = item.result.data;
|
|
128
123
|
}
|
|
129
124
|
return loaderDatas;
|
|
130
125
|
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { IPluginInstance, IPluginHandlers, HookMap } from '@shuvi/hook';
|
|
2
|
+
import type { ShuviRequest } from '@shuvi/service';
|
|
2
3
|
import { CustomRuntimePluginHooks } from '@shuvi/runtime';
|
|
3
4
|
import { IAppContext } from './applicationTypes';
|
|
4
5
|
import { IRouter } from './routerTypes';
|
|
5
6
|
export declare type AppComponent = unknown;
|
|
6
7
|
export declare type AppContextCtx = {
|
|
7
8
|
router: IRouter;
|
|
9
|
+
request?: ShuviRequest;
|
|
8
10
|
};
|
|
9
11
|
declare const init: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
10
12
|
declare const appContext: import("@shuvi/hook").AsyncSeriesHook<IAppContext, AppContextCtx, void>;
|
|
@@ -19,6 +19,7 @@ class ApplicationImpl {
|
|
|
19
19
|
constructor(options) {
|
|
20
20
|
this._config = options.config;
|
|
21
21
|
this._router = options.router;
|
|
22
|
+
this._request = options.request;
|
|
22
23
|
this._context = {};
|
|
23
24
|
this._store = (0, doura_1.doura)({ initialState: options.initialState });
|
|
24
25
|
this._error = this._store.getModel(error_1.errorModelName, error_1.errorModel);
|
|
@@ -93,7 +94,8 @@ class ApplicationImpl {
|
|
|
93
94
|
_initAppContext() {
|
|
94
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
95
96
|
yield this._pluginManager.runner.appContext(this._context, {
|
|
96
|
-
router: this._router
|
|
97
|
+
router: this._router,
|
|
98
|
+
request: this._request
|
|
97
99
|
});
|
|
98
100
|
});
|
|
99
101
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Doura } from 'doura';
|
|
2
2
|
import { CustomAppContext } from '@shuvi/runtime';
|
|
3
|
+
import type { ShuviRequest } from '@shuvi/service';
|
|
3
4
|
import { IRouter } from './routerTypes';
|
|
4
5
|
import { IPluginList } from './runtimPlugin';
|
|
5
6
|
import { Loader } from './loader';
|
|
@@ -46,5 +47,6 @@ export interface ApplicationInternalOptions<C extends {}> {
|
|
|
46
47
|
getLoaders: GetLoadersFn;
|
|
47
48
|
initialState?: IAppState;
|
|
48
49
|
plugins?: IPluginList;
|
|
50
|
+
request?: ShuviRequest;
|
|
49
51
|
}
|
|
50
52
|
export declare type ApplicationlOptions<C extends {}> = Omit<ApplicationInternalOptions<C>, 'getLoaders' | 'plugins'>;
|
|
@@ -126,13 +126,8 @@ function runLoaders(matches, loadersByRouteId, loaderContext) {
|
|
|
126
126
|
throw item.error;
|
|
127
127
|
}
|
|
128
128
|
const routeId = matches[index].route.id;
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
// allow return undefined
|
|
134
|
-
loaderDatas[routeId] = undefined;
|
|
135
|
-
}
|
|
129
|
+
(0, invariant_1.default)(item.result, `loader function of route "${matches[index].route.path}" should return a value`);
|
|
130
|
+
loaderDatas[routeId] = item.result.data;
|
|
136
131
|
}
|
|
137
132
|
return loaderDatas;
|
|
138
133
|
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { IPluginInstance, IPluginHandlers, HookMap } from '@shuvi/hook';
|
|
2
|
+
import type { ShuviRequest } from '@shuvi/service';
|
|
2
3
|
import { CustomRuntimePluginHooks } from '@shuvi/runtime';
|
|
3
4
|
import { IAppContext } from './applicationTypes';
|
|
4
5
|
import { IRouter } from './routerTypes';
|
|
5
6
|
export declare type AppComponent = unknown;
|
|
6
7
|
export declare type AppContextCtx = {
|
|
7
8
|
router: IRouter;
|
|
9
|
+
request?: ShuviRequest;
|
|
8
10
|
};
|
|
9
11
|
declare const init: import("@shuvi/hook").AsyncParallelHook<void, void, void>;
|
|
10
12
|
declare const appContext: import("@shuvi/hook").AsyncSeriesHook<IAppContext, AppContextCtx, void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shuvi/platform-shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.43",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/shuvijs/shuvi.git",
|
|
@@ -83,16 +83,16 @@
|
|
|
83
83
|
"node": ">= 16.0.0"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@shuvi/hook": "1.0.
|
|
86
|
+
"@shuvi/hook": "1.0.43",
|
|
87
87
|
"doura": "0.0.13",
|
|
88
|
-
"@shuvi/router": "1.0.
|
|
89
|
-
"@shuvi/runtime": "1.0.
|
|
90
|
-
"@shuvi/shared": "1.0.
|
|
91
|
-
"@shuvi/toolpack": "1.0.
|
|
92
|
-
"@shuvi/utils": "1.0.
|
|
88
|
+
"@shuvi/router": "1.0.43",
|
|
89
|
+
"@shuvi/runtime": "1.0.43",
|
|
90
|
+
"@shuvi/shared": "1.0.43",
|
|
91
|
+
"@shuvi/toolpack": "1.0.43",
|
|
92
|
+
"@shuvi/utils": "1.0.43"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
95
|
-
"@shuvi/service": "1.0.
|
|
95
|
+
"@shuvi/service": "1.0.43"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@shuvi/service": "workspace:*",
|