@shuvi/platform-shared 1.0.0-rc.14 → 1.0.0-rc.17
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/shared/shuvi-singleton-runtimeConfig.d.ts +5 -4
- package/esm/shared/shuvi-singleton-runtimeConfig.js +38 -8
- package/esm/shuvi-app/application.d.ts +4 -4
- package/esm/shuvi-app/application.js +3 -3
- package/lib/node/platform/plugins/main/index.js +0 -3
- package/lib/node/platform/runtimeFiles.js +2 -6
- package/lib/node/project/file-presets/files/app/core/setRuntimeConfig.js.js +1 -1
- 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/lib/shared/shuvi-singleton-runtimeConfig.d.ts +5 -4
- package/lib/shared/shuvi-singleton-runtimeConfig.js +41 -10
- package/package.json +9 -9
- package/shuvi-type-extensions-runtime.d.ts +0 -5
- package/lib/node/project/file-presets/files/app/core/setPublicRuntimeConfig.js.d.ts +0 -2
- package/lib/node/project/file-presets/files/app/core/setPublicRuntimeConfig.js.js +0 -7
|
@@ -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';
|
|
@@ -2,11 +2,12 @@ import { IRuntimeConfig } from './runtimeConfigTypes';
|
|
|
2
2
|
/**
|
|
3
3
|
* getRuntimeConfig function
|
|
4
4
|
*
|
|
5
|
-
* @returns
|
|
5
|
+
* @returns serverRuntimeConfig
|
|
6
6
|
*/
|
|
7
7
|
export declare function getRuntimeConfig(): {
|
|
8
8
|
[x: string]: string;
|
|
9
9
|
};
|
|
10
|
-
export declare function getPublicRuntimeConfig(): IRuntimeConfig | null;
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
10
|
+
export declare function getPublicRuntimeConfig(): IRuntimeConfig | undefined | null;
|
|
11
|
+
export declare function setPublicRuntimeConfig(config: IRuntimeConfig | null): void;
|
|
12
|
+
export declare function getServerRuntimeConfig(): IRuntimeConfig | undefined | null;
|
|
13
|
+
export declare function setServerRuntimeConfig(config: IRuntimeConfig | null): void;
|
|
@@ -1,19 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
const isServer = typeof window === 'undefined';
|
|
2
|
+
/**
|
|
3
|
+
* use global this to store runtime config, so we can safely bundle this module
|
|
4
|
+
* and get rid of the multiple-module-instance problem.
|
|
5
|
+
* */
|
|
6
|
+
const KEY_SERVER_RUNTIME_CONFIG = Symbol.for('shuvi_server_runtime_config');
|
|
7
|
+
const KEY_PUBLIC_RUNTIME_CONFIG = Symbol.for('shuvi_client_runtime_config');
|
|
2
8
|
let publicRuntimeConfig;
|
|
9
|
+
let serverRuntimeConfig;
|
|
3
10
|
/**
|
|
4
11
|
* getRuntimeConfig function
|
|
5
12
|
*
|
|
6
|
-
* @returns
|
|
13
|
+
* @returns serverRuntimeConfig
|
|
7
14
|
*/
|
|
8
15
|
export function getRuntimeConfig() {
|
|
9
|
-
return Object.assign(Object.assign({}, (
|
|
16
|
+
return Object.assign(Object.assign({}, (getServerRuntimeConfig() || {})), (getPublicRuntimeConfig() || {}));
|
|
10
17
|
}
|
|
11
18
|
export function getPublicRuntimeConfig() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
if (isServer) {
|
|
20
|
+
return globalThis[KEY_PUBLIC_RUNTIME_CONFIG];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return publicRuntimeConfig;
|
|
24
|
+
}
|
|
16
25
|
}
|
|
17
26
|
export function setPublicRuntimeConfig(config) {
|
|
18
|
-
|
|
27
|
+
if (isServer) {
|
|
28
|
+
globalThis[KEY_PUBLIC_RUNTIME_CONFIG] = config;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
publicRuntimeConfig = config;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function getServerRuntimeConfig() {
|
|
35
|
+
if (isServer) {
|
|
36
|
+
return globalThis[KEY_SERVER_RUNTIME_CONFIG];
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
return serverRuntimeConfig;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function setServerRuntimeConfig(config) {
|
|
43
|
+
if (isServer) {
|
|
44
|
+
globalThis[KEY_SERVER_RUNTIME_CONFIG] = config;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
serverRuntimeConfig = config;
|
|
48
|
+
}
|
|
19
49
|
}
|
|
@@ -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
|
}
|
|
@@ -9,9 +9,6 @@ const core = (0, service_1.createPlugin)({
|
|
|
9
9
|
},
|
|
10
10
|
addRuntimeService: () => [
|
|
11
11
|
{
|
|
12
|
-
// must be export separately, we need the module path to always be the
|
|
13
|
-
// same as what we've defined in
|
|
14
|
-
// "packages/toolpack/src/webpack/config/parts/external.ts"
|
|
15
12
|
source: (0, paths_1.resolvePkgFile)('lib/shared/shuvi-singleton-runtimeConfig'),
|
|
16
13
|
exported: '{ getRuntimeConfig }'
|
|
17
14
|
},
|
|
@@ -36,12 +36,8 @@ const getPresetRuntimeFilesCreator = (platformModule) => (pluginContext) => __aw
|
|
|
36
36
|
break;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
if (publicKeys) {
|
|
43
|
-
(0, shuvi_singleton_runtimeConfig_1.setPublicRuntimeConfig)(publicRuntimeConfig);
|
|
44
|
-
}
|
|
39
|
+
(0, shuvi_singleton_runtimeConfig_1.setServerRuntimeConfig)(serverKeys ? serverRuntimeConfig : null);
|
|
40
|
+
(0, shuvi_singleton_runtimeConfig_1.setPublicRuntimeConfig)(publicKeys ? publicRuntimeConfig : null);
|
|
45
41
|
const context = (0, projectContext_1.createProjectContext)();
|
|
46
42
|
context.userModule = {
|
|
47
43
|
error: getCandidates('error', 'nullish'),
|
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const __1 = require("../../..");
|
|
4
4
|
const paths_1 = require("../../../../../paths");
|
|
5
5
|
exports.default = () => (0, __1.defineFile)({
|
|
6
|
-
content: () => `export {
|
|
6
|
+
content: () => `export { setPublicRuntimeConfig as default } from '${(0, paths_1.resolvePkgFile)('lib/shared/shuvi-singleton-runtimeConfig')}'`
|
|
7
7
|
});
|
|
@@ -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';
|
|
@@ -2,11 +2,12 @@ import { IRuntimeConfig } from './runtimeConfigTypes';
|
|
|
2
2
|
/**
|
|
3
3
|
* getRuntimeConfig function
|
|
4
4
|
*
|
|
5
|
-
* @returns
|
|
5
|
+
* @returns serverRuntimeConfig
|
|
6
6
|
*/
|
|
7
7
|
export declare function getRuntimeConfig(): {
|
|
8
8
|
[x: string]: string;
|
|
9
9
|
};
|
|
10
|
-
export declare function getPublicRuntimeConfig(): IRuntimeConfig | null;
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
10
|
+
export declare function getPublicRuntimeConfig(): IRuntimeConfig | undefined | null;
|
|
11
|
+
export declare function setPublicRuntimeConfig(config: IRuntimeConfig | null): void;
|
|
12
|
+
export declare function getServerRuntimeConfig(): IRuntimeConfig | undefined | null;
|
|
13
|
+
export declare function setServerRuntimeConfig(config: IRuntimeConfig | null): void;
|
|
@@ -1,26 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.setServerRuntimeConfig = exports.getServerRuntimeConfig = exports.setPublicRuntimeConfig = exports.getPublicRuntimeConfig = exports.getRuntimeConfig = void 0;
|
|
4
|
+
const isServer = typeof window === 'undefined';
|
|
5
|
+
/**
|
|
6
|
+
* use global this to store runtime config, so we can safely bundle this module
|
|
7
|
+
* and get rid of the multiple-module-instance problem.
|
|
8
|
+
* */
|
|
9
|
+
const KEY_SERVER_RUNTIME_CONFIG = Symbol.for('shuvi_server_runtime_config');
|
|
10
|
+
const KEY_PUBLIC_RUNTIME_CONFIG = Symbol.for('shuvi_client_runtime_config');
|
|
5
11
|
let publicRuntimeConfig;
|
|
12
|
+
let serverRuntimeConfig;
|
|
6
13
|
/**
|
|
7
14
|
* getRuntimeConfig function
|
|
8
15
|
*
|
|
9
|
-
* @returns
|
|
16
|
+
* @returns serverRuntimeConfig
|
|
10
17
|
*/
|
|
11
18
|
function getRuntimeConfig() {
|
|
12
|
-
return Object.assign(Object.assign({}, (
|
|
19
|
+
return Object.assign(Object.assign({}, (getServerRuntimeConfig() || {})), (getPublicRuntimeConfig() || {}));
|
|
13
20
|
}
|
|
14
21
|
exports.getRuntimeConfig = getRuntimeConfig;
|
|
15
22
|
function getPublicRuntimeConfig() {
|
|
16
|
-
|
|
23
|
+
if (isServer) {
|
|
24
|
+
return globalThis[KEY_PUBLIC_RUNTIME_CONFIG];
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return publicRuntimeConfig;
|
|
28
|
+
}
|
|
17
29
|
}
|
|
18
30
|
exports.getPublicRuntimeConfig = getPublicRuntimeConfig;
|
|
19
|
-
function setRuntimeConfig(config) {
|
|
20
|
-
runtimeConfig = config;
|
|
21
|
-
}
|
|
22
|
-
exports.setRuntimeConfig = setRuntimeConfig;
|
|
23
31
|
function setPublicRuntimeConfig(config) {
|
|
24
|
-
|
|
32
|
+
if (isServer) {
|
|
33
|
+
globalThis[KEY_PUBLIC_RUNTIME_CONFIG] = config;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
publicRuntimeConfig = config;
|
|
37
|
+
}
|
|
25
38
|
}
|
|
26
39
|
exports.setPublicRuntimeConfig = setPublicRuntimeConfig;
|
|
40
|
+
function getServerRuntimeConfig() {
|
|
41
|
+
if (isServer) {
|
|
42
|
+
return globalThis[KEY_SERVER_RUNTIME_CONFIG];
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return serverRuntimeConfig;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.getServerRuntimeConfig = getServerRuntimeConfig;
|
|
49
|
+
function setServerRuntimeConfig(config) {
|
|
50
|
+
if (isServer) {
|
|
51
|
+
globalThis[KEY_SERVER_RUNTIME_CONFIG] = config;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
serverRuntimeConfig = config;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.setServerRuntimeConfig = setServerRuntimeConfig;
|
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.17",
|
|
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.17",
|
|
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.17",
|
|
89
|
+
"@shuvi/runtime": "1.0.0-rc.17",
|
|
90
|
+
"@shuvi/service": "1.0.0-rc.17",
|
|
91
|
+
"@shuvi/shared": "1.0.0-rc.17",
|
|
92
|
+
"@shuvi/toolpack": "1.0.0-rc.17",
|
|
93
|
+
"@shuvi/utils": "1.0.0-rc.17",
|
|
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.17"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@types/minimatch": "3.0.5"
|
|
@@ -35,11 +35,6 @@ declare module '@shuvi/app/core/setRuntimeConfig' {
|
|
|
35
35
|
export default function setRuntimeConfig(config: IRuntimeConfig): void;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
declare module '@shuvi/app/core/setPublicRuntimeConfig' {
|
|
39
|
-
import { IRuntimeConfig } from '@shuvi/platform-shared/shared';
|
|
40
|
-
export default function setPublicRuntimeConfig(config: IRuntimeConfig): void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
38
|
declare module '@shuvi/app/user/error' {
|
|
44
39
|
const Error: any;
|
|
45
40
|
export default Error;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const __1 = require("../../..");
|
|
4
|
-
const paths_1 = require("../../../../../paths");
|
|
5
|
-
exports.default = () => (0, __1.defineFile)({
|
|
6
|
-
content: () => `export { setPublicRuntimeConfig as default } from '${(0, paths_1.resolvePkgFile)('lib/shared/shuvi-singleton-runtimeConfig')}'`
|
|
7
|
-
});
|