@modern-js/runtime 2.65.5 → 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/code.d.ts +1 -1
- package/dist/types/cli/index.d.ts +3 -4
- package/dist/types/cli/ssr/index.d.ts +1 -1
- package/dist/types/cli/template.d.ts +8 -8
- package/dist/types/common.d.ts +2 -8
- package/dist/types/config.d.ts +0 -2
- package/dist/types/core/compat/requestContext.d.ts +4 -7
- package/dist/types/core/context/index.d.ts +0 -1
- package/dist/types/core/context/monitors/index.server.d.ts +1 -1
- package/dist/types/core/context/runtime.d.ts +0 -4
- package/dist/types/core/loader/useLoader.d.ts +2 -2
- package/dist/types/core/plugin/base.d.ts +0 -1
- package/dist/types/core/server/shared.d.ts +0 -1
- package/dist/types/core/server/utils.d.ts +9 -1
- package/dist/types/document/Script.d.ts +0 -1
- package/dist/types/document/Title.d.ts +0 -1
- package/dist/types/document/cli/index.d.ts +1 -1
- package/dist/types/index.d.ts +1 -2
- package/dist/types/router/cli/code/index.d.ts +1 -1
- package/dist/types/router/cli/code/templates.d.ts +5 -5
- package/dist/types/router/cli/code/utils.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/dist/types/router/cli/index.d.ts +1 -1
- package/dist/types/router/runtime/DeferredDataScripts.node.d.ts +0 -1
- package/dist/types/router/runtime/hooks.d.ts +2 -2
- package/dist/types/router/runtime/routeModule.d.ts +0 -1
- package/dist/types/router/runtime/types.d.ts +0 -1
- package/dist/types/router/runtime/withRouter.d.ts +1 -1
- 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;
|
package/dist/types/cli/code.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { AppToolsContext, AppToolsFeatureHooks, AppToolsNormalizedConfig } from '@modern-js/app-tools';
|
|
2
2
|
import type { Entrypoint } from '@modern-js/types';
|
|
3
|
-
export declare const generateCode: (entrypoints: Entrypoint[], appContext: AppToolsContext<
|
|
3
|
+
export declare const generateCode: (entrypoints: Entrypoint[], appContext: AppToolsContext<"shared">, config: AppToolsNormalizedConfig, hooks: AppToolsFeatureHooks<"shared">) => Promise<void>;
|
|
@@ -1,11 +1,10 @@
|
|
|
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
|
-
plugins?: CliPluginFuture<AppTools<
|
|
10
|
-
}) => CliPluginFuture<AppTools<
|
|
8
|
+
plugins?: CliPluginFuture<AppTools<"shared">>[];
|
|
9
|
+
}) => CliPluginFuture<AppTools<"shared">>;
|
|
11
10
|
export default runtimePlugin;
|
|
@@ -2,8 +2,8 @@ import type { RuntimePluginConfig } from '@modern-js/app-tools';
|
|
|
2
2
|
export declare const entryForCSRWithRSC: ({ metaName, entryName, urlPath, mountId, }: {
|
|
3
3
|
metaName: string;
|
|
4
4
|
entryName: string;
|
|
5
|
-
urlPath?: string
|
|
6
|
-
mountId?: string
|
|
5
|
+
urlPath?: string;
|
|
6
|
+
mountId?: string;
|
|
7
7
|
}) => string;
|
|
8
8
|
export declare const index: ({ srcDirectory, internalSrcAlias, metaName, entry, entryName, customEntry, customBootstrap, mountId, enableRsc, }: {
|
|
9
9
|
srcDirectory: string;
|
|
@@ -11,10 +11,10 @@ export declare const index: ({ srcDirectory, internalSrcAlias, metaName, entry,
|
|
|
11
11
|
metaName: string;
|
|
12
12
|
entry: string;
|
|
13
13
|
entryName: string;
|
|
14
|
-
customEntry?: boolean
|
|
15
|
-
customBootstrap?: string | false
|
|
16
|
-
mountId?: string
|
|
17
|
-
enableRsc?: boolean
|
|
14
|
+
customEntry?: boolean;
|
|
15
|
+
customBootstrap?: string | false;
|
|
16
|
+
mountId?: string;
|
|
17
|
+
enableRsc?: boolean;
|
|
18
18
|
}) => string;
|
|
19
19
|
export declare const register: () => string;
|
|
20
20
|
export declare const runtimeRegister: ({ entryName, srcDirectory, internalSrcAlias, metaName, runtimeConfigFile, runtimePlugins, }: {
|
|
@@ -31,7 +31,7 @@ export declare const runtimeGlobalContext: ({ entryName, srcDirectory, internalS
|
|
|
31
31
|
internalSrcAlias: string;
|
|
32
32
|
metaName: string;
|
|
33
33
|
entry: string;
|
|
34
|
-
customEntry?: boolean
|
|
34
|
+
customEntry?: boolean;
|
|
35
35
|
}) => string;
|
|
36
36
|
export declare const runtimeGlobalContextForRSCServer: ({ metaName, }: {
|
|
37
37
|
metaName: string;
|
|
@@ -43,5 +43,5 @@ export declare const AppProxyForRSC: ({ srcDirectory, internalSrcAlias, entry, c
|
|
|
43
43
|
srcDirectory: string;
|
|
44
44
|
internalSrcAlias: string;
|
|
45
45
|
entry: string;
|
|
46
|
-
customEntry?: boolean
|
|
46
|
+
customEntry?: boolean;
|
|
47
47
|
}) => string;
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import type { Plugin } from './core/plugin';
|
|
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
|
-
|
|
12
|
-
stateByEntries?: {
|
|
13
|
-
[name: string]: StateConfig;
|
|
14
|
-
};
|
|
15
|
-
plugins?: Plugin[];
|
|
9
|
+
plugins?: (Plugin | RuntimePluginFuture)[];
|
|
16
10
|
[key: string]: any;
|
|
17
11
|
}
|
|
18
12
|
export declare const JSX_SHELL_STREAM_END_MARK = "<!--<?- SHELL_STREAM_END ?>-->";
|
package/dist/types/config.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node/http" />
|
|
3
|
-
/// <reference types="types" />
|
|
4
1
|
import type { RuntimeContext } from '../context';
|
|
5
2
|
import type { RuntimePluginFuture } from '../plugin/types';
|
|
6
3
|
export declare const makeRequestContext: (context: RuntimeContext) => import("../types").ServerContext | import("../types").ClientContext | {
|
|
@@ -13,10 +10,10 @@ export declare const makeRequestContext: (context: RuntimeContext) => import("..
|
|
|
13
10
|
headers: import("http").IncomingHttpHeaders;
|
|
14
11
|
host: string;
|
|
15
12
|
url: string;
|
|
16
|
-
referer?: string
|
|
17
|
-
userAgent?: string
|
|
18
|
-
cookie?: string
|
|
19
|
-
cookieMap?: Record<string, string
|
|
13
|
+
referer?: string;
|
|
14
|
+
userAgent?: string;
|
|
15
|
+
cookie?: string;
|
|
16
|
+
cookieMap?: Record<string, string>;
|
|
20
17
|
} & {
|
|
21
18
|
baseUrl: string;
|
|
22
19
|
raw: Request;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Monitors } from '@modern-js/types';
|
|
2
|
-
export declare const getMonitors: () => Omit<Monitors,
|
|
2
|
+
export declare const getMonitors: () => Omit<Monitors, "push">;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { Store } from '@modern-js-reduck/store';
|
|
3
1
|
import type { StaticHandlerContext } from '@modern-js/runtime-utils/remix-router';
|
|
4
2
|
import type { RouteManifest } from '../../router/runtime/types';
|
|
5
3
|
import { createLoaderManager } from '../loader/loaderManager';
|
|
@@ -9,7 +7,6 @@ interface BaseRuntimeContext {
|
|
|
9
7
|
loaderManager: ReturnType<typeof createLoaderManager>;
|
|
10
8
|
isBrowser: boolean;
|
|
11
9
|
ssrContext?: SSRServerContext;
|
|
12
|
-
store?: Store;
|
|
13
10
|
routeManifest: RouteManifest;
|
|
14
11
|
routerContext?: StaticHandlerContext;
|
|
15
12
|
context?: TSSRContext;
|
|
@@ -31,7 +28,6 @@ export interface TRuntimeContext extends Partial<BaseRuntimeContext> {
|
|
|
31
28
|
request?: SSRServerContext['request'];
|
|
32
29
|
/** @deprecated use context.response field instead */
|
|
33
30
|
response?: SSRServerContext['response'];
|
|
34
|
-
store?: Store;
|
|
35
31
|
[key: string]: any;
|
|
36
32
|
}
|
|
37
33
|
export declare const getInitialContext: (isBrowser?: boolean, routeManifest?: RouteManifest) => RuntimeContext;
|
|
@@ -26,8 +26,8 @@ export interface LoaderOptions<Params = any, TData = any, TError extends Error =
|
|
|
26
26
|
*/
|
|
27
27
|
static?: boolean;
|
|
28
28
|
}
|
|
29
|
-
declare const useLoader: <TData = any, Params = any, E = any>(loaderFn: LoaderFn<Params, TData>, options?: LoaderOptions<Params
|
|
30
|
-
reload: (params?: Params
|
|
29
|
+
declare const useLoader: <TData = any, Params = any, E = any>(loaderFn: LoaderFn<Params, TData>, options?: LoaderOptions<Params>) => {
|
|
30
|
+
reload: (params?: Params) => Promise<any> | undefined;
|
|
31
31
|
loading: boolean;
|
|
32
32
|
reloading: boolean;
|
|
33
33
|
data: TData;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { AsyncInterruptWorkflow, PluginOptions, Setup, SyncParallelWorkflow, Waterfall } from '@modern-js/plugin';
|
|
3
2
|
import type { RuntimeContext, TRuntimeContext } from '../context/runtime';
|
|
4
3
|
import type { RuntimeConfig } from './types';
|
|
@@ -15,5 +15,13 @@ export declare function checkIsNode(): boolean;
|
|
|
15
15
|
* license at https://github.com/remix-run/remix/blob/main/LICENSE.md
|
|
16
16
|
*/
|
|
17
17
|
export declare function serializeErrors(errors: StaticHandlerContext['errors']): StaticHandlerContext['errors'];
|
|
18
|
-
export declare function getSSRConfigByEntry(entryName: string, ssr?: ServerUserConfig['ssr'], ssrByEntries?: ServerUserConfig['ssrByEntries']):
|
|
18
|
+
export declare function getSSRConfigByEntry(entryName: string, ssr?: ServerUserConfig['ssr'], ssrByEntries?: ServerUserConfig['ssrByEntries']): true | {
|
|
19
|
+
forceCSR?: boolean;
|
|
20
|
+
mode?: import("@modern-js/types").SSRMode;
|
|
21
|
+
inlineScript?: boolean;
|
|
22
|
+
disablePrerender?: boolean;
|
|
23
|
+
unsafeHeaders?: string[];
|
|
24
|
+
scriptLoading?: "defer" | "blocking" | "module" | "async";
|
|
25
|
+
loaderFailureMode?: "clientRender" | "errorBoundary";
|
|
26
|
+
};
|
|
19
27
|
export declare function getSSRMode(ssrConfig?: SSRConfig): 'string' | 'stream' | false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AppTools, CliPluginFuture } from '@modern-js/app-tools';
|
|
2
2
|
import type { Entrypoint } from '@modern-js/types/cli';
|
|
3
3
|
export declare const getDocumenByEntryName: (entrypoints: Entrypoint[], entryName: string, fallbackDir?: string) => string | undefined;
|
|
4
|
-
export declare const documentPlugin: () => CliPluginFuture<AppTools<
|
|
4
|
+
export declare const documentPlugin: () => CliPluginFuture<AppTools<"shared">>;
|
|
5
5
|
export default documentPlugin;
|
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<
|
|
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;
|
|
@@ -6,18 +6,18 @@ export declare const routesForServer: ({ routesForServerLoaderMatches, }: {
|
|
|
6
6
|
export declare const fileSystemRoutes: ({ metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks, }: {
|
|
7
7
|
metaName: string;
|
|
8
8
|
routes: RouteLegacy[] | (NestedRouteForCli | PageRoute)[];
|
|
9
|
-
ssrMode?: SSRMode
|
|
10
|
-
nestedRoutesEntry?: string
|
|
9
|
+
ssrMode?: SSRMode;
|
|
10
|
+
nestedRoutesEntry?: string;
|
|
11
11
|
entryName: string;
|
|
12
12
|
internalDirectory: string;
|
|
13
|
-
splitRouteChunks?: boolean
|
|
13
|
+
splitRouteChunks?: boolean;
|
|
14
14
|
}) => Promise<string>;
|
|
15
15
|
export declare function ssrLoaderCombinedModule(entrypoints: Entrypoint[], entrypoint: Entrypoint, config: AppNormalizedConfig<'shared'>, appContext: AppToolsContext<'shared'>): string | null;
|
|
16
16
|
export declare const runtimeGlobalContext: ({ entryName, metaName, srcDirectory, nestedRoutesEntry, internalSrcAlias, globalApp, }: {
|
|
17
17
|
entryName: string;
|
|
18
18
|
metaName: string;
|
|
19
19
|
srcDirectory: string;
|
|
20
|
-
nestedRoutesEntry?: string
|
|
20
|
+
nestedRoutesEntry?: string;
|
|
21
21
|
internalSrcAlias: string;
|
|
22
|
-
globalApp?: string | false
|
|
22
|
+
globalApp?: string | false;
|
|
23
23
|
}) => Promise<string>;
|
|
@@ -4,7 +4,7 @@ export declare const replaceWithAlias: (base: string, filePath: string, alias: s
|
|
|
4
4
|
export declare const parseModule: ({ source, filename, }: {
|
|
5
5
|
source: string;
|
|
6
6
|
filename: string;
|
|
7
|
-
}) => Promise<readonly [imports: readonly import("es-module-lexer").ImportSpecifier[], exports: readonly import("es-module-lexer").ExportSpecifier[], facade: boolean]>;
|
|
7
|
+
}) => Promise<readonly [imports: readonly import("es-module-lexer").ImportSpecifier[], exports: readonly import("es-module-lexer").ExportSpecifier[], facade: boolean, hasModuleSyntax: boolean]>;
|
|
8
8
|
export declare const hasLoader: (filename: string, source?: string) => Promise<boolean>;
|
|
9
9
|
export declare const hasAction: (filename: string, source?: string) => Promise<boolean>;
|
|
10
10
|
export declare const getServerLoadersFile: (internalDirectory: string, entryName: string) => string;
|
|
@@ -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>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AppTools, CliPluginFuture } from '@modern-js/app-tools';
|
|
2
2
|
export { isRouteEntry } from './entry';
|
|
3
3
|
export { handleFileChange, handleModifyEntrypoints } from './handler';
|
|
4
|
-
export declare const routerPlugin: () => CliPluginFuture<AppTools<
|
|
4
|
+
export declare const routerPlugin: () => CliPluginFuture<AppTools<"shared">>;
|
|
5
5
|
export default routerPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
2
2
|
import type { RuntimeContext } from '../../core';
|
|
3
|
-
declare const modifyRoutes: import("@modern-js/plugin-v2
|
|
4
|
-
declare const onBeforeCreateRoutes: import("@modern-js/plugin-v2
|
|
3
|
+
declare const modifyRoutes: import("@modern-js/plugin-v2").SyncHook<(routes: RouteObject[]) => RouteObject[]>;
|
|
4
|
+
declare const onBeforeCreateRoutes: import("@modern-js/plugin-v2").SyncHook<(context: RuntimeContext) => void>;
|
|
5
5
|
export { modifyRoutes, onBeforeCreateRoutes };
|
|
6
6
|
export type RouterExtendsHooks = {
|
|
7
7
|
modifyRoutes: typeof modifyRoutes;
|
|
@@ -7,4 +7,4 @@ export interface WithRouterProps<Params extends {
|
|
|
7
7
|
params: Params;
|
|
8
8
|
navigate: ReturnType<typeof useNavigate>;
|
|
9
9
|
}
|
|
10
|
-
export declare const withRouter: <Props extends WithRouterProps
|
|
10
|
+
export declare const withRouter: <Props extends WithRouterProps>(Component: React.ComponentType<Props>) => (props: Omit<Props, keyof WithRouterProps>) => React.JSX.Element;
|
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/
|
|
230
|
-
"@modern-js/
|
|
231
|
-
"@modern-js/plugin-v2": "2.
|
|
232
|
-
"@modern-js/
|
|
233
|
-
"@modern-js/
|
|
234
|
-
"@modern-js/
|
|
235
|
-
"@modern-js/
|
|
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
|
-
"@
|
|
260
|
-
"@scripts/
|
|
261
|
-
"@
|
|
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
|
-
});
|