@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,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, getEntryOptions
|
|
2
|
+
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, getEntryOptions } from "@modern-js/utils";
|
|
3
3
|
import { filterRoutesForServer } from "@modern-js/utils";
|
|
4
4
|
import { isRouteEntry } from "./entry";
|
|
5
5
|
import { handleFileChange, handleGeneratorEntryCode, handleModifyEntrypoints } from "./handler";
|
|
@@ -13,16 +13,19 @@ const routerPlugin = () => ({
|
|
|
13
13
|
setup: (api) => {
|
|
14
14
|
const nestedRoutes = {};
|
|
15
15
|
const nestedRoutesForServer = {};
|
|
16
|
+
const { metaName } = api.getAppContext();
|
|
17
|
+
const isRouterV5 = api.isPluginExists(`@${metaName}/plugin-router-v5`);
|
|
16
18
|
api._internalRuntimePlugins(({ entrypoint, plugins }) => {
|
|
17
19
|
var _getEntryOptions;
|
|
18
|
-
const {
|
|
20
|
+
const { nestedRoutesEntry, pageRoutesEntry } = entrypoint;
|
|
21
|
+
const { packageName, serverRoutes, metaName: metaName2 } = api.getAppContext();
|
|
19
22
|
const serverBase = serverRoutes.filter((route) => route.entryName === entrypoint.entryName).map((route) => route.urlPath).sort((a, b) => a.length - b.length > 0 ? -1 : 1);
|
|
20
23
|
const userConfig = api.getNormalizedConfig();
|
|
21
24
|
const routerConfig = (_getEntryOptions = getEntryOptions(entrypoint.entryName, entrypoint.isMainEntry, userConfig.runtime, userConfig.runtimeByEntries, packageName)) === null || _getEntryOptions === void 0 ? void 0 : _getEntryOptions.router;
|
|
22
|
-
if (
|
|
25
|
+
if ((nestedRoutesEntry || pageRoutesEntry) && !isRouterV5) {
|
|
23
26
|
plugins.push({
|
|
24
27
|
name: "router",
|
|
25
|
-
path: `@${
|
|
28
|
+
path: `@${metaName2}/runtime/router`,
|
|
26
29
|
config: typeof routerConfig === "boolean" ? {
|
|
27
30
|
serverBase
|
|
28
31
|
} : {
|
|
@@ -57,24 +60,23 @@ const routerPlugin = () => ({
|
|
|
57
60
|
};
|
|
58
61
|
});
|
|
59
62
|
api.modifyEntrypoints(async ({ entrypoints }) => {
|
|
60
|
-
const newEntryPoints = await handleModifyEntrypoints(
|
|
63
|
+
const newEntryPoints = await handleModifyEntrypoints(isRouterV5, entrypoints);
|
|
61
64
|
return {
|
|
62
65
|
entrypoints: newEntryPoints
|
|
63
66
|
};
|
|
64
67
|
});
|
|
65
68
|
api.generateEntryCode(async ({ entrypoints }) => {
|
|
66
|
-
await handleGeneratorEntryCode(api, entrypoints);
|
|
69
|
+
await handleGeneratorEntryCode(api, entrypoints, isRouterV5);
|
|
67
70
|
});
|
|
68
71
|
api.addRuntimeExports(() => {
|
|
69
|
-
const
|
|
70
|
-
const { internalDirectory, metaName } = api.useAppContext();
|
|
72
|
+
const { internalDirectory, metaName: metaName2 } = api.useAppContext();
|
|
71
73
|
const pluginsExportsUtils = createRuntimeExportsUtils(internalDirectory, "plugins");
|
|
72
|
-
if (!
|
|
73
|
-
pluginsExportsUtils.addExport(`export { default as router } from '@${
|
|
74
|
+
if (!isRouterV5) {
|
|
75
|
+
pluginsExportsUtils.addExport(`export { default as router } from '@${metaName2}/runtime/router'`);
|
|
74
76
|
}
|
|
75
77
|
});
|
|
76
78
|
api.onFileChanged(async (e) => {
|
|
77
|
-
await handleFileChange(api, e);
|
|
79
|
+
await handleFileChange(api, isRouterV5, e);
|
|
78
80
|
});
|
|
79
81
|
api.modifyFileSystemRoutes(({ entrypoint, routes }) => {
|
|
80
82
|
nestedRoutes[entrypoint.entryName] = routes;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { AppTools, CliPluginFuture } from '@modern-js/app-tools';
|
|
2
2
|
import { documentPlugin } from '../document/cli';
|
|
3
3
|
import { routerPlugin } from '../router/cli';
|
|
4
|
-
import { statePlugin } from '../state/cli';
|
|
5
4
|
import { ssrPlugin } from './ssr';
|
|
6
5
|
export { isRuntimeEntry } from './entry';
|
|
7
|
-
export {
|
|
6
|
+
export { ssrPlugin, routerPlugin, documentPlugin };
|
|
8
7
|
export declare const runtimePlugin: (params?: {
|
|
9
8
|
plugins?: CliPluginFuture<AppTools<"shared">>[];
|
|
10
9
|
}) => CliPluginFuture<AppTools<"shared">>;
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import type { Plugin, RuntimePluginFuture } from './core/plugin';
|
|
2
2
|
import type { RouterConfig } from './router';
|
|
3
|
-
import type { StateConfig } from './state';
|
|
4
3
|
export declare const isBrowser: () => boolean;
|
|
5
4
|
export interface AppConfig {
|
|
6
|
-
state?: StateConfig | boolean;
|
|
7
5
|
router?: Pick<RouterConfig, 'future' | 'basename'>;
|
|
8
6
|
[key: string]: any;
|
|
9
7
|
}
|
|
10
8
|
export interface RuntimeConfig {
|
|
11
|
-
state?: StateConfig;
|
|
12
|
-
stateByEntries?: {
|
|
13
|
-
[name: string]: StateConfig;
|
|
14
|
-
};
|
|
15
9
|
plugins?: (Plugin | RuntimePluginFuture)[];
|
|
16
10
|
[key: string]: any;
|
|
17
11
|
}
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Store } from '@modern-js-reduck/store';
|
|
2
1
|
import type { StaticHandlerContext } from '@modern-js/runtime-utils/remix-router';
|
|
3
2
|
import type { RouteManifest } from '../../router/runtime/types';
|
|
4
3
|
import { createLoaderManager } from '../loader/loaderManager';
|
|
@@ -8,7 +7,6 @@ interface BaseRuntimeContext {
|
|
|
8
7
|
loaderManager: ReturnType<typeof createLoaderManager>;
|
|
9
8
|
isBrowser: boolean;
|
|
10
9
|
ssrContext?: SSRServerContext;
|
|
11
|
-
store?: Store;
|
|
12
10
|
routeManifest: RouteManifest;
|
|
13
11
|
routerContext?: StaticHandlerContext;
|
|
14
12
|
context?: TSSRContext;
|
|
@@ -30,7 +28,6 @@ export interface TRuntimeContext extends Partial<BaseRuntimeContext> {
|
|
|
30
28
|
request?: SSRServerContext['request'];
|
|
31
29
|
/** @deprecated use context.response field instead */
|
|
32
30
|
response?: SSRServerContext['response'];
|
|
33
|
-
store?: Store;
|
|
34
31
|
[key: string]: any;
|
|
35
32
|
}
|
|
36
33
|
export declare const getInitialContext: (isBrowser?: boolean, routeManifest?: RouteManifest) => RuntimeContext;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { RouterConfig } from './router';
|
|
2
|
-
import type { StateConfig } from './state';
|
|
3
2
|
export type { Plugin, RuntimePluginFuture } from './core';
|
|
4
3
|
export type { AppConfig, RuntimeConfig } from './common';
|
|
5
4
|
export { isBrowser } from './common';
|
|
@@ -9,4 +8,4 @@ export { getMonitors } from './core/context/monitors';
|
|
|
9
8
|
export { getRequest } from './core/context/request';
|
|
10
9
|
export { setHeaders, setStatus, redirect } from './core/context/response';
|
|
11
10
|
export { createApp, useLoader, bootstrap, RuntimeReactContext, defineConfig, defineRuntimeConfig, useRuntimeContext, } from './core';
|
|
12
|
-
export type {
|
|
11
|
+
export type { RouterConfig };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AppNormalizedConfig, AppTools, AppToolsContext } from '@modern-js/app-tools';
|
|
2
2
|
import type { CLIPluginAPI } from '@modern-js/plugin-v2';
|
|
3
3
|
import type { Entrypoint } from '@modern-js/types';
|
|
4
|
-
export declare const generateCode: (appContext: AppToolsContext<"shared">, config: AppNormalizedConfig<"shared">, entrypoints: Entrypoint[], api: CLIPluginAPI<AppTools<"shared"
|
|
4
|
+
export declare const generateCode: (appContext: AppToolsContext<"shared">, config: AppNormalizedConfig<"shared">, entrypoints: Entrypoint[], api: CLIPluginAPI<AppTools<"shared">>, isRouterV5: boolean) => Promise<void>;
|
|
5
5
|
export declare function generatorRegisterCode(internalDirectory: string, entryName: string, code: string): void;
|
|
@@ -2,4 +2,4 @@ import type { Entrypoint } from '@modern-js/types';
|
|
|
2
2
|
export declare const hasPages: (dir: string) => boolean;
|
|
3
3
|
export declare const hasNestedRoutes: (dir: string) => boolean;
|
|
4
4
|
export declare const isRouteEntry: (dir: string) => string | false;
|
|
5
|
-
export declare const modifyEntrypoints: (entrypoints: Entrypoint[],
|
|
5
|
+
export declare const modifyEntrypoints: (entrypoints: Entrypoint[], isRouterV5: boolean) => Entrypoint[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AppTools } from '@modern-js/app-tools';
|
|
2
2
|
import type { CLIPluginAPI } from '@modern-js/plugin-v2';
|
|
3
3
|
import type { Entrypoint } from '@modern-js/types';
|
|
4
|
-
export declare function handleModifyEntrypoints(
|
|
5
|
-
export declare function handleGeneratorEntryCode(api: CLIPluginAPI<AppTools<'shared'>>, entrypoints: Entrypoint[]): Promise<Entrypoint[]>;
|
|
6
|
-
export declare function handleFileChange(api: CLIPluginAPI<AppTools<'shared'>>, e: any): Promise<void>;
|
|
4
|
+
export declare function handleModifyEntrypoints(isRouterV5: boolean, entrypoints: Entrypoint[]): Promise<Entrypoint[]>;
|
|
5
|
+
export declare function handleGeneratorEntryCode(api: CLIPluginAPI<AppTools<'shared'>>, entrypoints: Entrypoint[], isRouterV5: boolean): Promise<Entrypoint[]>;
|
|
6
|
+
export declare function handleFileChange(api: CLIPluginAPI<AppTools<'shared'>>, isRouterV5: boolean, e: any): Promise<void>;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.67.0",
|
|
19
19
|
"engines": {
|
|
20
20
|
"node": ">=14.17.6"
|
|
21
21
|
},
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"./types": "./types/index.d.ts",
|
|
35
35
|
"./types/index": "./types/index.d.ts",
|
|
36
36
|
"./types/router": "./types/router.d.ts",
|
|
37
|
-
"./types/model": "./types/model.d.ts",
|
|
38
37
|
"./context": {
|
|
39
38
|
"types": "./dist/types/core/context/index.d.ts",
|
|
40
39
|
"jsnext:source": "./src/core/context/index.ts",
|
|
@@ -92,11 +91,6 @@
|
|
|
92
91
|
"node": "./dist/cjs/document/index.js",
|
|
93
92
|
"default": "./dist/esm/document/index.js"
|
|
94
93
|
},
|
|
95
|
-
"./model": {
|
|
96
|
-
"types": "./types/model.d.ts",
|
|
97
|
-
"jsnext:source": "./src/state/index.ts",
|
|
98
|
-
"default": "./dist/esm/state/index.js"
|
|
99
|
-
},
|
|
100
94
|
"./cli": {
|
|
101
95
|
"types": "./dist/types/cli/index.d.ts",
|
|
102
96
|
"jsnext:source": "./src/cli/index.ts",
|
|
@@ -178,9 +172,6 @@
|
|
|
178
172
|
"ssr/server": [
|
|
179
173
|
"./dist/types/core/server/server.d.ts"
|
|
180
174
|
],
|
|
181
|
-
"model": [
|
|
182
|
-
"./types/model.d.ts"
|
|
183
|
-
],
|
|
184
175
|
"router": [
|
|
185
176
|
"./dist/types/router/index.d.ts"
|
|
186
177
|
],
|
|
@@ -207,12 +198,6 @@
|
|
|
207
198
|
"@loadable/babel-plugin": "5.15.3",
|
|
208
199
|
"@loadable/component": "5.15.3",
|
|
209
200
|
"@loadable/server": "5.15.3",
|
|
210
|
-
"@modern-js-reduck/plugin-auto-actions": "^1.1.10",
|
|
211
|
-
"@modern-js-reduck/plugin-devtools": "^1.1.10",
|
|
212
|
-
"@modern-js-reduck/plugin-effects": "^1.1.10",
|
|
213
|
-
"@modern-js-reduck/plugin-immutable": "^1.1.10",
|
|
214
|
-
"@modern-js-reduck/react": "^1.1.10",
|
|
215
|
-
"@modern-js-reduck/store": "^1.1.10",
|
|
216
201
|
"@swc/helpers": "0.5.13",
|
|
217
202
|
"@types/loadable__component": "^5.13.4",
|
|
218
203
|
"@types/react-helmet": "^6.1.2",
|
|
@@ -226,13 +211,13 @@
|
|
|
226
211
|
"react-is": "^18",
|
|
227
212
|
"react-side-effect": "^2.1.1",
|
|
228
213
|
"styled-components": "^5.3.1",
|
|
229
|
-
"@modern-js/plugin": "2.
|
|
230
|
-
"@modern-js/plugin-
|
|
231
|
-
"@modern-js/plugin-
|
|
232
|
-
"@modern-js/
|
|
233
|
-
"@modern-js/
|
|
234
|
-
"@modern-js/types": "2.
|
|
235
|
-
"@modern-js/utils": "2.
|
|
214
|
+
"@modern-js/plugin": "2.67.0",
|
|
215
|
+
"@modern-js/plugin-data-loader": "2.67.0",
|
|
216
|
+
"@modern-js/plugin-v2": "2.67.0",
|
|
217
|
+
"@modern-js/runtime-utils": "2.67.0",
|
|
218
|
+
"@modern-js/render": "2.67.0",
|
|
219
|
+
"@modern-js/types": "2.67.0",
|
|
220
|
+
"@modern-js/utils": "2.67.0"
|
|
236
221
|
},
|
|
237
222
|
"peerDependencies": {
|
|
238
223
|
"react": ">=17",
|
|
@@ -240,7 +225,7 @@
|
|
|
240
225
|
},
|
|
241
226
|
"devDependencies": {
|
|
242
227
|
"@remix-run/web-fetch": "^4.1.3",
|
|
243
|
-
"@rsbuild/core": "1.2
|
|
228
|
+
"@rsbuild/core": "1.3.2",
|
|
244
229
|
"@testing-library/react": "^13.4.0",
|
|
245
230
|
"@types/cookie": "0.6.0",
|
|
246
231
|
"@types/invariant": "^2.2.30",
|
|
@@ -256,9 +241,9 @@
|
|
|
256
241
|
"ts-node": "^10.9.1",
|
|
257
242
|
"typescript": "^5",
|
|
258
243
|
"webpack": "^5.98.0",
|
|
259
|
-
"@modern-js/app-tools": "2.
|
|
260
|
-
"@scripts/
|
|
261
|
-
"@scripts/
|
|
244
|
+
"@modern-js/app-tools": "2.67.0",
|
|
245
|
+
"@scripts/build": "2.66.0",
|
|
246
|
+
"@scripts/jest-config": "2.66.0"
|
|
262
247
|
},
|
|
263
248
|
"sideEffects": false,
|
|
264
249
|
"publishConfig": {
|
package/types/index.d.ts
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
declare module '@modern-js/app-tools' {
|
|
4
|
-
interface RuntimeUserConfig {
|
|
5
|
-
state?: StateConfig | boolean;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare module '@modern-js/module-tools' {
|
|
10
|
-
interface RuntimeUserConfig {
|
|
11
|
-
state?: StateConfig | boolean;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
/// <reference types='@modern-js/plugin-state/types' />
|
|
14
2
|
|
|
15
3
|
declare module 'http' {
|
|
16
4
|
interface ServerResponse {
|
package/types/router.d.ts
CHANGED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var cli_exports = {};
|
|
20
|
-
__export(cli_exports, {
|
|
21
|
-
default: () => cli_default,
|
|
22
|
-
statePlugin: () => statePlugin
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(cli_exports);
|
|
25
|
-
var import_utils = require("@modern-js/utils");
|
|
26
|
-
const PLUGIN_IDENTIFIER = "state";
|
|
27
|
-
const statePlugin = () => ({
|
|
28
|
-
name: "@modern-js/plugin-state",
|
|
29
|
-
required: [
|
|
30
|
-
"@modern-js/runtime"
|
|
31
|
-
],
|
|
32
|
-
setup: (api) => {
|
|
33
|
-
api._internalRuntimePlugins(({ entrypoint, plugins }) => {
|
|
34
|
-
var _getEntryOptions;
|
|
35
|
-
const { entryName, isMainEntry } = entrypoint;
|
|
36
|
-
const userConfig = api.getNormalizedConfig();
|
|
37
|
-
const { packageName, metaName } = api.getAppContext();
|
|
38
|
-
const stateConfig = (_getEntryOptions = (0, import_utils.getEntryOptions)(entryName, isMainEntry, userConfig.runtime, userConfig.runtimeByEntries, packageName)) === null || _getEntryOptions === void 0 ? void 0 : _getEntryOptions.state;
|
|
39
|
-
if (stateConfig) {
|
|
40
|
-
plugins.push({
|
|
41
|
-
name: PLUGIN_IDENTIFIER,
|
|
42
|
-
path: `@${metaName}/runtime/model`,
|
|
43
|
-
config: typeof stateConfig === "boolean" ? {} : stateConfig
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
entrypoint,
|
|
48
|
-
plugins
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
api.addRuntimeExports(() => {
|
|
52
|
-
const { internalDirectory, metaName } = api.useAppContext();
|
|
53
|
-
const pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(internalDirectory, "plugins");
|
|
54
|
-
pluginsExportsUtils.addExport(`export { default as state } from '@${metaName}/runtime/model'`);
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
var cli_default = statePlugin;
|
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
-
0 && (module.exports = {
|
|
61
|
-
statePlugin
|
|
62
|
-
});
|
package/dist/cjs/state/index.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var state_exports = {};
|
|
31
|
-
__export(state_exports, {
|
|
32
|
-
default: () => import_runtime2.default,
|
|
33
|
-
state: () => import_runtime.default
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(state_exports);
|
|
36
|
-
var import_runtime = __toESM(require("./runtime"));
|
|
37
|
-
var import_runtime2 = __toESM(require("./runtime"));
|
|
38
|
-
__reExport(state_exports, require("./runtime"), module.exports);
|
|
39
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
-
0 && (module.exports = {
|
|
41
|
-
state,
|
|
42
|
-
...require("./runtime")
|
|
43
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var plugins_exports = {};
|
|
30
|
-
__export(plugins_exports, {
|
|
31
|
-
autoActions: () => autoActions,
|
|
32
|
-
devtools: () => import_plugin_devtools.default,
|
|
33
|
-
effects: () => effects,
|
|
34
|
-
immer: () => immer
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(plugins_exports);
|
|
37
|
-
var import_plugin_auto_actions = __toESM(require("@modern-js-reduck/plugin-auto-actions"));
|
|
38
|
-
var import_plugin_effects = require("@modern-js-reduck/plugin-effects");
|
|
39
|
-
var import_plugin_immutable = __toESM(require("@modern-js-reduck/plugin-immutable"));
|
|
40
|
-
var import_plugin_devtools = __toESM(require("@modern-js-reduck/plugin-devtools"));
|
|
41
|
-
const effects = () => import_plugin_effects.plugin;
|
|
42
|
-
const immer = () => import_plugin_immutable.default;
|
|
43
|
-
const autoActions = () => import_plugin_auto_actions.default;
|
|
44
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
-
0 && (module.exports = {
|
|
46
|
-
autoActions,
|
|
47
|
-
devtools,
|
|
48
|
-
effects,
|
|
49
|
-
immer
|
|
50
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
var runtime_exports = {};
|
|
31
|
-
__export(runtime_exports, {
|
|
32
|
-
default: () => import_plugin.default
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(runtime_exports);
|
|
35
|
-
__reExport(runtime_exports, require("@modern-js-reduck/react"), module.exports);
|
|
36
|
-
var import_plugin = __toESM(require("./plugin"));
|
|
37
|
-
__reExport(runtime_exports, require("./plugin"), module.exports);
|
|
38
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
-
0 && (module.exports = {
|
|
40
|
-
...require("@modern-js-reduck/react"),
|
|
41
|
-
...require("./plugin")
|
|
42
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
var plugin_exports = {};
|
|
21
|
-
__export(plugin_exports, {
|
|
22
|
-
default: () => plugin_default,
|
|
23
|
-
statePlugin: () => statePlugin
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(plugin_exports);
|
|
26
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
27
|
-
var import_react = require("@modern-js-reduck/react");
|
|
28
|
-
var import_store = require("@modern-js-reduck/store");
|
|
29
|
-
var import_merge = require("@modern-js/runtime-utils/merge");
|
|
30
|
-
var import_react2 = require("react");
|
|
31
|
-
var import_common = require("../../common");
|
|
32
|
-
var import_core = require("../../core");
|
|
33
|
-
var import_plugins = require("../plugins");
|
|
34
|
-
__reExport(plugin_exports, require("../plugins"), module.exports);
|
|
35
|
-
const StatePluginHandleMap = {
|
|
36
|
-
immer: import_plugins.immer,
|
|
37
|
-
effects: import_plugins.effects,
|
|
38
|
-
autoActions: import_plugins.autoActions,
|
|
39
|
-
devtools: import_plugins.devtools
|
|
40
|
-
};
|
|
41
|
-
const getStoreConfig = (config) => {
|
|
42
|
-
const internalPlugins = [
|
|
43
|
-
"immer",
|
|
44
|
-
"effects",
|
|
45
|
-
"autoActions",
|
|
46
|
-
"devtools"
|
|
47
|
-
];
|
|
48
|
-
const plugins = [];
|
|
49
|
-
internalPlugins.filter((plugin) => config[plugin] !== false).forEach((plugin) => plugins.push(StatePluginHandleMap[plugin](config[plugin])));
|
|
50
|
-
const storeConfig = {};
|
|
51
|
-
for (const [key, value] of Object.entries(config)) {
|
|
52
|
-
if (!internalPlugins.includes(key)) {
|
|
53
|
-
storeConfig[key] = value;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
storeConfig.plugins = plugins;
|
|
57
|
-
return storeConfig;
|
|
58
|
-
};
|
|
59
|
-
const statePlugin = (userConfig = {}) => ({
|
|
60
|
-
name: "@modern-js/plugin-state",
|
|
61
|
-
setup: (api) => {
|
|
62
|
-
let storeConfig;
|
|
63
|
-
return {
|
|
64
|
-
wrapRoot(App) {
|
|
65
|
-
const getStateApp = (props) => {
|
|
66
|
-
const context = (0, import_react2.useContext)(import_core.RuntimeReactContext);
|
|
67
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Provider, {
|
|
68
|
-
store: context.store,
|
|
69
|
-
config: storeConfig,
|
|
70
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
|
|
71
|
-
...props
|
|
72
|
-
})
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
return getStateApp;
|
|
76
|
-
},
|
|
77
|
-
beforeRender(context) {
|
|
78
|
-
const pluginConfig = api.useRuntimeConfigContext();
|
|
79
|
-
const config = (0, import_merge.merge)(pluginConfig.state || {}, userConfig);
|
|
80
|
-
storeConfig = getStoreConfig(config);
|
|
81
|
-
if ((0, import_common.isBrowser)()) {
|
|
82
|
-
var _window__SSR_DATA_data, _window__SSR_DATA, _window;
|
|
83
|
-
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) || {};
|
|
84
|
-
}
|
|
85
|
-
context.store = (0, import_store.createStore)(storeConfig);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
var plugin_default = statePlugin;
|
|
91
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
-
0 && (module.exports = {
|
|
93
|
-
statePlugin,
|
|
94
|
-
...require("../plugins")
|
|
95
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { createRuntimeExportsUtils, getEntryOptions } from "@modern-js/utils";
|
|
2
|
-
var PLUGIN_IDENTIFIER = "state";
|
|
3
|
-
var statePlugin = function() {
|
|
4
|
-
return {
|
|
5
|
-
name: "@modern-js/plugin-state",
|
|
6
|
-
required: [
|
|
7
|
-
"@modern-js/runtime"
|
|
8
|
-
],
|
|
9
|
-
setup: function(api) {
|
|
10
|
-
api._internalRuntimePlugins(function(param) {
|
|
11
|
-
var entrypoint = param.entrypoint, plugins = param.plugins;
|
|
12
|
-
var _getEntryOptions;
|
|
13
|
-
var entryName = entrypoint.entryName, isMainEntry = entrypoint.isMainEntry;
|
|
14
|
-
var userConfig = api.getNormalizedConfig();
|
|
15
|
-
var _api_getAppContext = api.getAppContext(), packageName = _api_getAppContext.packageName, metaName = _api_getAppContext.metaName;
|
|
16
|
-
var stateConfig = (_getEntryOptions = getEntryOptions(entryName, isMainEntry, userConfig.runtime, userConfig.runtimeByEntries, packageName)) === null || _getEntryOptions === void 0 ? void 0 : _getEntryOptions.state;
|
|
17
|
-
if (stateConfig) {
|
|
18
|
-
plugins.push({
|
|
19
|
-
name: PLUGIN_IDENTIFIER,
|
|
20
|
-
path: "@".concat(metaName, "/runtime/model"),
|
|
21
|
-
config: typeof stateConfig === "boolean" ? {} : stateConfig
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
entrypoint,
|
|
26
|
-
plugins
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
api.addRuntimeExports(function() {
|
|
30
|
-
var _api_useAppContext = api.useAppContext(), internalDirectory = _api_useAppContext.internalDirectory, metaName = _api_useAppContext.metaName;
|
|
31
|
-
var pluginsExportsUtils = createRuntimeExportsUtils(internalDirectory, "plugins");
|
|
32
|
-
pluginsExportsUtils.addExport("export { default as state } from '@".concat(metaName, "/runtime/model'"));
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
var cli_default = statePlugin;
|
|
38
|
-
export {
|
|
39
|
-
cli_default as default,
|
|
40
|
-
statePlugin
|
|
41
|
-
};
|
package/dist/esm/state/index.js
DELETED
|
@@ -1,19 +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
|
-
var effects = function() {
|
|
6
|
-
return effectsPlugin;
|
|
7
|
-
};
|
|
8
|
-
var immer = function() {
|
|
9
|
-
return immerPlugin;
|
|
10
|
-
};
|
|
11
|
-
var autoActions = function() {
|
|
12
|
-
return autoActionsPlugin;
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
autoActions,
|
|
16
|
-
default2 as devtools,
|
|
17
|
-
effects,
|
|
18
|
-
immer
|
|
19
|
-
};
|