@modern-js/runtime 2.66.0 → 2.67.0
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/dist/cjs/cli/index.js +2 -7
- package/dist/cjs/router/cli/code/index.js +3 -4
- package/dist/cjs/router/cli/code/templates.js +3 -0
- package/dist/cjs/router/cli/entry.js +2 -2
- package/dist/cjs/router/cli/handler.js +6 -7
- package/dist/cjs/router/cli/index.js +12 -10
- package/dist/esm/cli/index.js +1 -5
- package/dist/esm/router/cli/code/index.js +6 -7
- package/dist/esm/router/cli/code/templates.js +13 -6
- package/dist/esm/router/cli/entry.js +3 -4
- package/dist/esm/router/cli/handler.js +9 -11
- package/dist/esm/router/cli/index.js +13 -11
- package/dist/esm-node/cli/index.js +1 -5
- package/dist/esm-node/router/cli/code/index.js +4 -5
- package/dist/esm-node/router/cli/code/templates.js +3 -0
- package/dist/esm-node/router/cli/entry.js +3 -3
- package/dist/esm-node/router/cli/handler.js +6 -7
- package/dist/esm-node/router/cli/index.js +13 -11
- package/dist/types/cli/index.d.ts +1 -2
- package/dist/types/common.d.ts +0 -6
- package/dist/types/config.d.ts +0 -2
- package/dist/types/core/context/runtime.d.ts +0 -3
- package/dist/types/index.d.ts +1 -2
- package/dist/types/router/cli/code/index.d.ts +1 -1
- package/dist/types/router/cli/entry.d.ts +1 -1
- package/dist/types/router/cli/handler.d.ts +3 -3
- package/package.json +12 -27
- package/types/index.d.ts +1 -13
- package/types/router.d.ts +0 -1
- package/dist/cjs/state/cli/index.js +0 -62
- package/dist/cjs/state/index.js +0 -43
- package/dist/cjs/state/plugins.js +0 -50
- package/dist/cjs/state/runtime/index.js +0 -42
- package/dist/cjs/state/runtime/plugin.js +0 -95
- package/dist/esm/state/cli/index.js +0 -41
- package/dist/esm/state/index.js +0 -7
- package/dist/esm/state/plugins.js +0 -19
- package/dist/esm/state/runtime/index.js +0 -6
- package/dist/esm/state/runtime/plugin.js +0 -93
- package/dist/esm-node/state/cli/index.js +0 -38
- package/dist/esm-node/state/index.js +0 -7
- package/dist/esm-node/state/plugins.js +0 -13
- package/dist/esm-node/state/runtime/index.js +0 -6
- package/dist/esm-node/state/runtime/plugin.js +0 -69
- package/dist/types/state/cli/index.d.ts +0 -3
- package/dist/types/state/index.d.ts +0 -3
- package/dist/types/state/plugins.d.ts +0 -4
- package/dist/types/state/runtime/index.d.ts +0 -3
- package/dist/types/state/runtime/plugin.d.ts +0 -11
- package/types/model.d.ts +0 -7
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
-
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import { Provider } from "@modern-js-reduck/react";
|
|
5
|
-
import { createStore } from "@modern-js-reduck/store";
|
|
6
|
-
import { merge } from "@modern-js/runtime-utils/merge";
|
|
7
|
-
import { useContext } from "react";
|
|
8
|
-
import { isBrowser } from "../../common";
|
|
9
|
-
import { RuntimeReactContext } from "../../core";
|
|
10
|
-
import { autoActions, devtools, effects, immer } from "../plugins";
|
|
11
|
-
var StatePluginHandleMap = {
|
|
12
|
-
immer,
|
|
13
|
-
effects,
|
|
14
|
-
autoActions,
|
|
15
|
-
devtools
|
|
16
|
-
};
|
|
17
|
-
var getStoreConfig = function(config) {
|
|
18
|
-
var internalPlugins = [
|
|
19
|
-
"immer",
|
|
20
|
-
"effects",
|
|
21
|
-
"autoActions",
|
|
22
|
-
"devtools"
|
|
23
|
-
];
|
|
24
|
-
var plugins = [];
|
|
25
|
-
internalPlugins.filter(function(plugin) {
|
|
26
|
-
return config[plugin] !== false;
|
|
27
|
-
}).forEach(function(plugin) {
|
|
28
|
-
return plugins.push(StatePluginHandleMap[plugin](config[plugin]));
|
|
29
|
-
});
|
|
30
|
-
var storeConfig = {};
|
|
31
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
32
|
-
try {
|
|
33
|
-
for (var _iterator = Object.entries(config)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
34
|
-
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
35
|
-
if (!internalPlugins.includes(key)) {
|
|
36
|
-
storeConfig[key] = value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
} catch (err) {
|
|
40
|
-
_didIteratorError = true;
|
|
41
|
-
_iteratorError = err;
|
|
42
|
-
} finally {
|
|
43
|
-
try {
|
|
44
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
45
|
-
_iterator.return();
|
|
46
|
-
}
|
|
47
|
-
} finally {
|
|
48
|
-
if (_didIteratorError) {
|
|
49
|
-
throw _iteratorError;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
storeConfig.plugins = plugins;
|
|
54
|
-
return storeConfig;
|
|
55
|
-
};
|
|
56
|
-
var statePlugin = function() {
|
|
57
|
-
var userConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
58
|
-
return {
|
|
59
|
-
name: "@modern-js/plugin-state",
|
|
60
|
-
setup: function(api) {
|
|
61
|
-
var storeConfig;
|
|
62
|
-
return {
|
|
63
|
-
wrapRoot: function wrapRoot(App) {
|
|
64
|
-
var getStateApp = function(props) {
|
|
65
|
-
var context = useContext(RuntimeReactContext);
|
|
66
|
-
return /* @__PURE__ */ _jsx(Provider, {
|
|
67
|
-
store: context.store,
|
|
68
|
-
config: storeConfig,
|
|
69
|
-
children: /* @__PURE__ */ _jsx(App, _object_spread({}, props))
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
return getStateApp;
|
|
73
|
-
},
|
|
74
|
-
beforeRender: function beforeRender(context) {
|
|
75
|
-
var pluginConfig = api.useRuntimeConfigContext();
|
|
76
|
-
var config = merge(pluginConfig.state || {}, userConfig);
|
|
77
|
-
storeConfig = getStoreConfig(config);
|
|
78
|
-
if (isBrowser()) {
|
|
79
|
-
var _window__SSR_DATA_data, _window__SSR_DATA, _window;
|
|
80
|
-
storeConfig.initialState = storeConfig.initialState || ((_window = window) === null || _window === void 0 ? void 0 : (_window__SSR_DATA = _window._SSR_DATA) === null || _window__SSR_DATA === void 0 ? void 0 : (_window__SSR_DATA_data = _window__SSR_DATA.data) === null || _window__SSR_DATA_data === void 0 ? void 0 : _window__SSR_DATA_data.storeState) || {};
|
|
81
|
-
}
|
|
82
|
-
context.store = createStore(storeConfig);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
var plugin_default = statePlugin;
|
|
89
|
-
export * from "../plugins";
|
|
90
|
-
export {
|
|
91
|
-
plugin_default as default,
|
|
92
|
-
statePlugin
|
|
93
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { createRuntimeExportsUtils, getEntryOptions } from "@modern-js/utils";
|
|
2
|
-
const PLUGIN_IDENTIFIER = "state";
|
|
3
|
-
const statePlugin = () => ({
|
|
4
|
-
name: "@modern-js/plugin-state",
|
|
5
|
-
required: [
|
|
6
|
-
"@modern-js/runtime"
|
|
7
|
-
],
|
|
8
|
-
setup: (api) => {
|
|
9
|
-
api._internalRuntimePlugins(({ entrypoint, plugins }) => {
|
|
10
|
-
var _getEntryOptions;
|
|
11
|
-
const { entryName, isMainEntry } = entrypoint;
|
|
12
|
-
const userConfig = api.getNormalizedConfig();
|
|
13
|
-
const { packageName, metaName } = api.getAppContext();
|
|
14
|
-
const stateConfig = (_getEntryOptions = getEntryOptions(entryName, isMainEntry, userConfig.runtime, userConfig.runtimeByEntries, packageName)) === null || _getEntryOptions === void 0 ? void 0 : _getEntryOptions.state;
|
|
15
|
-
if (stateConfig) {
|
|
16
|
-
plugins.push({
|
|
17
|
-
name: PLUGIN_IDENTIFIER,
|
|
18
|
-
path: `@${metaName}/runtime/model`,
|
|
19
|
-
config: typeof stateConfig === "boolean" ? {} : stateConfig
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
entrypoint,
|
|
24
|
-
plugins
|
|
25
|
-
};
|
|
26
|
-
});
|
|
27
|
-
api.addRuntimeExports(() => {
|
|
28
|
-
const { internalDirectory, metaName } = api.useAppContext();
|
|
29
|
-
const pluginsExportsUtils = createRuntimeExportsUtils(internalDirectory, "plugins");
|
|
30
|
-
pluginsExportsUtils.addExport(`export { default as state } from '@${metaName}/runtime/model'`);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
var cli_default = statePlugin;
|
|
35
|
-
export {
|
|
36
|
-
cli_default as default,
|
|
37
|
-
statePlugin
|
|
38
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import autoActionsPlugin from "@modern-js-reduck/plugin-auto-actions";
|
|
2
|
-
import { plugin as effectsPlugin } from "@modern-js-reduck/plugin-effects";
|
|
3
|
-
import immerPlugin from "@modern-js-reduck/plugin-immutable";
|
|
4
|
-
import { default as default2 } from "@modern-js-reduck/plugin-devtools";
|
|
5
|
-
const effects = () => effectsPlugin;
|
|
6
|
-
const immer = () => immerPlugin;
|
|
7
|
-
const autoActions = () => autoActionsPlugin;
|
|
8
|
-
export {
|
|
9
|
-
autoActions,
|
|
10
|
-
default2 as devtools,
|
|
11
|
-
effects,
|
|
12
|
-
immer
|
|
13
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Provider } from "@modern-js-reduck/react";
|
|
3
|
-
import { createStore } from "@modern-js-reduck/store";
|
|
4
|
-
import { merge } from "@modern-js/runtime-utils/merge";
|
|
5
|
-
import { useContext } from "react";
|
|
6
|
-
import { isBrowser } from "../../common";
|
|
7
|
-
import { RuntimeReactContext } from "../../core";
|
|
8
|
-
import { autoActions, devtools, effects, immer } from "../plugins";
|
|
9
|
-
const StatePluginHandleMap = {
|
|
10
|
-
immer,
|
|
11
|
-
effects,
|
|
12
|
-
autoActions,
|
|
13
|
-
devtools
|
|
14
|
-
};
|
|
15
|
-
const getStoreConfig = (config) => {
|
|
16
|
-
const internalPlugins = [
|
|
17
|
-
"immer",
|
|
18
|
-
"effects",
|
|
19
|
-
"autoActions",
|
|
20
|
-
"devtools"
|
|
21
|
-
];
|
|
22
|
-
const plugins = [];
|
|
23
|
-
internalPlugins.filter((plugin) => config[plugin] !== false).forEach((plugin) => plugins.push(StatePluginHandleMap[plugin](config[plugin])));
|
|
24
|
-
const storeConfig = {};
|
|
25
|
-
for (const [key, value] of Object.entries(config)) {
|
|
26
|
-
if (!internalPlugins.includes(key)) {
|
|
27
|
-
storeConfig[key] = value;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
storeConfig.plugins = plugins;
|
|
31
|
-
return storeConfig;
|
|
32
|
-
};
|
|
33
|
-
const statePlugin = (userConfig = {}) => ({
|
|
34
|
-
name: "@modern-js/plugin-state",
|
|
35
|
-
setup: (api) => {
|
|
36
|
-
let storeConfig;
|
|
37
|
-
return {
|
|
38
|
-
wrapRoot(App) {
|
|
39
|
-
const getStateApp = (props) => {
|
|
40
|
-
const context = useContext(RuntimeReactContext);
|
|
41
|
-
return /* @__PURE__ */ _jsx(Provider, {
|
|
42
|
-
store: context.store,
|
|
43
|
-
config: storeConfig,
|
|
44
|
-
children: /* @__PURE__ */ _jsx(App, {
|
|
45
|
-
...props
|
|
46
|
-
})
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
return getStateApp;
|
|
50
|
-
},
|
|
51
|
-
beforeRender(context) {
|
|
52
|
-
const pluginConfig = api.useRuntimeConfigContext();
|
|
53
|
-
const config = merge(pluginConfig.state || {}, userConfig);
|
|
54
|
-
storeConfig = getStoreConfig(config);
|
|
55
|
-
if (isBrowser()) {
|
|
56
|
-
var _window__SSR_DATA_data, _window__SSR_DATA, _window;
|
|
57
|
-
storeConfig.initialState = storeConfig.initialState || ((_window = window) === null || _window === void 0 ? void 0 : (_window__SSR_DATA = _window._SSR_DATA) === null || _window__SSR_DATA === void 0 ? void 0 : (_window__SSR_DATA_data = _window__SSR_DATA.data) === null || _window__SSR_DATA_data === void 0 ? void 0 : _window__SSR_DATA_data.storeState) || {};
|
|
58
|
-
}
|
|
59
|
-
context.store = createStore(storeConfig);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
var plugin_default = statePlugin;
|
|
65
|
-
export * from "../plugins";
|
|
66
|
-
export {
|
|
67
|
-
plugin_default as default,
|
|
68
|
-
statePlugin
|
|
69
|
-
};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { default as devtools } from '@modern-js-reduck/plugin-devtools';
|
|
2
|
-
export declare const effects: () => (context: import("@modern-js-reduck/store/dist/types/types/plugin").PluginContext) => import("@modern-js-reduck/store/dist/types/types/plugin").PluginLifeCycle;
|
|
3
|
-
export declare const immer: () => (context: import("@modern-js-reduck/store/dist/types/types/plugin").PluginContext) => import("@modern-js-reduck/store/dist/types/types/plugin").PluginLifeCycle;
|
|
4
|
-
export declare const autoActions: () => (context: import("@modern-js-reduck/store/dist/types/types/plugin").PluginContext) => import("@modern-js-reduck/store/dist/types/types/plugin").PluginLifeCycle;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { type Model } from '@modern-js-reduck/store';
|
|
2
|
-
import type { Plugin } from '../../core';
|
|
3
|
-
type StatePluginType = 'immer' | 'effects' | 'autoActions' | 'devtools';
|
|
4
|
-
type StateExtraType = {
|
|
5
|
-
initialState: any;
|
|
6
|
-
models: Array<Model>;
|
|
7
|
-
};
|
|
8
|
-
export type StateConfig = Partial<Record<StatePluginType, boolean> & StateExtraType>;
|
|
9
|
-
export declare const statePlugin: (userConfig?: StateConfig) => Plugin;
|
|
10
|
-
export default statePlugin;
|
|
11
|
-
export * from '../plugins';
|
package/types/model.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import '@modern-js-reduck/plugin-auto-actions';
|
|
2
|
-
import '@modern-js-reduck/plugin-devtools';
|
|
3
|
-
import '@modern-js-reduck/plugin-effects';
|
|
4
|
-
import '@modern-js-reduck/plugin-immutable';
|
|
5
|
-
|
|
6
|
-
export { default } from '../dist/types/state';
|
|
7
|
-
export * from '../dist/types/state';
|