@modern-js/runtime 2.63.7-alpha.0 → 2.64.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.
Files changed (72) hide show
  1. package/dist/cjs/core/browser/hydrate.js +1 -10
  2. package/dist/cjs/core/browser/index.js +6 -4
  3. package/dist/cjs/core/compat/hooks.js +80 -0
  4. package/dist/cjs/core/{plugin/runner.js → compat/index.js} +19 -19
  5. package/dist/cjs/core/compatible.js +16 -16
  6. package/dist/cjs/core/context/index.js +12 -2
  7. package/dist/cjs/core/context/runtime.js +1 -2
  8. package/dist/cjs/core/index.js +1 -4
  9. package/dist/cjs/core/plugin/base.js +0 -35
  10. package/dist/cjs/core/plugin/index.js +17 -17
  11. package/dist/cjs/core/plugin/types.js +16 -0
  12. package/dist/cjs/core/react/index.js +3 -3
  13. package/dist/cjs/core/server/requestHandler.js +4 -4
  14. package/dist/cjs/core/server/stream/createReadableStream.js +6 -3
  15. package/dist/cjs/router/runtime/hooks.js +7 -7
  16. package/dist/cjs/router/runtime/plugin.js +109 -98
  17. package/dist/cjs/router/runtime/plugin.node.js +89 -91
  18. package/dist/esm/core/browser/hydrate.js +1 -10
  19. package/dist/esm/core/browser/index.js +9 -7
  20. package/dist/esm/core/compat/hooks.js +88 -0
  21. package/dist/esm/core/compat/index.js +20 -0
  22. package/dist/esm/core/compatible.js +18 -18
  23. package/dist/esm/core/context/index.js +9 -1
  24. package/dist/esm/core/context/runtime.js +2 -3
  25. package/dist/esm/core/index.js +1 -3
  26. package/dist/esm/core/plugin/base.js +0 -28
  27. package/dist/esm/core/plugin/index.js +14 -17
  28. package/dist/esm/core/plugin/types.js +0 -0
  29. package/dist/esm/core/react/index.js +4 -4
  30. package/dist/esm/core/server/requestHandler.js +6 -6
  31. package/dist/esm/core/server/stream/createReadableStream.js +8 -5
  32. package/dist/esm/router/runtime/hooks.js +5 -5
  33. package/dist/esm/router/runtime/plugin.js +116 -105
  34. package/dist/esm/router/runtime/plugin.node.js +112 -111
  35. package/dist/esm-node/core/browser/hydrate.js +1 -10
  36. package/dist/esm-node/core/browser/index.js +7 -5
  37. package/dist/esm-node/core/compat/hooks.js +54 -0
  38. package/dist/esm-node/core/compat/index.js +18 -0
  39. package/dist/esm-node/core/compatible.js +17 -17
  40. package/dist/esm-node/core/context/index.js +9 -1
  41. package/dist/esm-node/core/context/runtime.js +1 -2
  42. package/dist/esm-node/core/index.js +1 -3
  43. package/dist/esm-node/core/plugin/base.js +0 -24
  44. package/dist/esm-node/core/plugin/index.js +16 -14
  45. package/dist/esm-node/core/plugin/types.js +0 -0
  46. package/dist/esm-node/core/react/index.js +4 -4
  47. package/dist/esm-node/core/server/requestHandler.js +5 -5
  48. package/dist/esm-node/core/server/stream/createReadableStream.js +7 -4
  49. package/dist/esm-node/router/runtime/hooks.js +5 -5
  50. package/dist/esm-node/router/runtime/plugin.js +110 -99
  51. package/dist/esm-node/router/runtime/plugin.node.js +90 -92
  52. package/dist/types/core/browser/hydrate.d.ts +1 -1
  53. package/dist/types/core/compat/hooks.d.ts +4 -0
  54. package/dist/types/core/compat/index.d.ts +2 -0
  55. package/dist/types/core/compatible.d.ts +7 -6
  56. package/dist/types/core/context/index.d.ts +7 -2
  57. package/dist/types/core/context/runtime.d.ts +1 -3
  58. package/dist/types/core/index.d.ts +1 -2
  59. package/dist/types/core/plugin/base.d.ts +9 -33
  60. package/dist/types/core/plugin/index.d.ts +19 -12
  61. package/dist/types/core/plugin/types.d.ts +10 -0
  62. package/dist/types/core/types.d.ts +0 -1
  63. package/dist/types/index.d.ts +1 -1
  64. package/dist/types/router/runtime/hooks.d.ts +7 -3
  65. package/dist/types/router/runtime/index.d.ts +1 -0
  66. package/dist/types/router/runtime/plugin.d.ts +5 -2
  67. package/dist/types/router/runtime/plugin.node.d.ts +5 -2
  68. package/dist/types/router/runtime/types.d.ts +4 -0
  69. package/package.json +12 -11
  70. package/dist/esm/core/plugin/runner.js +0 -17
  71. package/dist/esm-node/core/plugin/runner.js +0 -17
  72. package/dist/types/core/plugin/runner.d.ts +0 -9
@@ -1,13 +1,20 @@
1
- /// <reference types="react" />
2
- import { type Plugin, runtime } from './base';
3
- export * from './base';
4
- export interface RuntimeConfig {
5
- plugins?: Plugin[];
6
- }
7
- export declare function registerPlugin(internalPlugins: Plugin[], runtimeConfig?: RuntimeConfig, customRuntime?: typeof runtime): import("@modern-js/plugin").ToRunners<{
8
- beforeRender: import("@modern-js/plugin").AsyncInterruptWorkflow<import("..").RuntimeContext, void>;
9
- wrapRoot: import("@modern-js/plugin").Waterfall<import("react").ComponentType<any>>;
10
- pickContext: import("@modern-js/plugin").Waterfall<import("../context/runtime").TRuntimeContext>;
11
- modifyRuntimeConfig: import("@modern-js/plugin").SyncParallelWorkflow<void, Record<string, any>>;
12
- }>;
1
+ import type { Plugin as RuntimePlugin } from './base';
2
+ import type { RuntimeConfig, RuntimePluginFuture } from './types';
3
+ export type { Plugin } from './base';
4
+ export type { RuntimePluginFuture };
5
+ export declare function registerPlugin(internalPlugins: (RuntimePlugin | RuntimePluginFuture)[], runtimeConfig?: RuntimeConfig): {
6
+ hooks: import("@modern-js/plugin-v2/runtime").Hooks<{} | undefined, import("@modern-js/plugin-v2/runtime").RuntimeContext>;
7
+ extendsHooks: {} | undefined;
8
+ config: {} | undefined;
9
+ pluginAPI?: Readonly<{
10
+ updateRuntimeContext: (updateContext: import("@modern-js/plugin-v2/dist/types/types/utils").DeepPartial<import("@modern-js/plugin-v2/runtime").RuntimeContext>) => void;
11
+ getHooks: () => Readonly<import("@modern-js/plugin-v2/runtime").Hooks<{} | undefined, import("@modern-js/plugin-v2/runtime").RuntimeContext>>;
12
+ getRuntimeConfig: () => Readonly<{} | undefined>;
13
+ onBeforeRender: import("@modern-js/plugin-v2/dist/types").PluginHookTap<import("@modern-js/plugin-v2/dist/types/types/runtime/hooks").OnBeforeRenderFn<{} | undefined>>;
14
+ wrapRoot: import("@modern-js/plugin-v2/dist/types").PluginHookTap<import("@modern-js/plugin-v2/dist/types/types/runtime/hooks").WrapRootFn>;
15
+ pickContext: import("@modern-js/plugin-v2/dist/types").PluginHookTap<import("@modern-js/plugin-v2/dist/types/types/runtime/hooks").PickContextFn<import("@modern-js/plugin-v2/runtime").RuntimeContext>>;
16
+ modifyRuntimeConfig: import("@modern-js/plugin-v2/dist/types").PluginHookTap<import("@modern-js/plugin-v2/dist/types/types/runtime/hooks").ModifyRuntimeConfigFn<{} | undefined>>;
17
+ } & {}> | undefined;
18
+ _internalContext?: any | undefined;
19
+ };
13
20
  export declare function mergeConfig(config: Record<string, any>, ...otherConfig: Record<string, any>[]): Record<string, any>;
@@ -0,0 +1,10 @@
1
+ import type { RuntimePlugin as BaseRuntimePlugin, RuntimePluginExtends } from '@modern-js/plugin-v2';
2
+ import type { Hooks } from '@modern-js/plugin-v2/runtime';
3
+ import type { RuntimeContext } from '../context/runtime';
4
+ import type { Plugin } from './base';
5
+ export type RuntimeHooks = Hooks<RuntimeConfig, RuntimeContext>;
6
+ export type RuntimeExtends = Required<RuntimePluginExtends<RuntimeConfig, RuntimeContext, {}, {}>>;
7
+ export type RuntimePluginFuture<Extends extends RuntimePluginExtends = {}> = BaseRuntimePlugin<RuntimeExtends & Extends>;
8
+ export interface RuntimeConfig {
9
+ plugins?: (Plugin | RuntimePluginFuture)[];
10
+ }
@@ -59,7 +59,6 @@ interface TSSRBaseContext {
59
59
  userAgent: string;
60
60
  cookie: string;
61
61
  };
62
- getInitData: () => Readonly<Record<string, unknown> | undefined>;
63
62
  [propName: string]: any;
64
63
  }
65
64
  interface ServerContext extends TSSRBaseContext {
@@ -1,6 +1,6 @@
1
1
  import type { RouterConfig } from './router';
2
2
  import type { StateConfig } from './state';
3
- export type { Plugin } from './core';
3
+ export type { Plugin, RuntimePluginFuture } from './core';
4
4
  export type { AppConfig, RuntimeConfig } from './common';
5
5
  export { isBrowser } from './common';
6
6
  export type { RuntimeContext } from './core/context/runtime';
@@ -1,5 +1,9 @@
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").Waterfall<RouteObject[]>;
4
- declare const beforeCreateRoutes: import("@modern-js/plugin").AsyncInterruptWorkflow<RuntimeContext, void>;
5
- export { modifyRoutes, beforeCreateRoutes };
3
+ declare const modifyRoutes: import("@modern-js/plugin-v2/src/types/hooks").SyncHook<(routes: RouteObject[]) => RouteObject[]>;
4
+ declare const onBeforeCreateRoutes: import("@modern-js/plugin-v2/src/types/hooks").SyncHook<(context: RuntimeContext) => void>;
5
+ export { modifyRoutes, onBeforeCreateRoutes };
6
+ export type RouterExtendsHooks = {
7
+ modifyRoutes: typeof modifyRoutes;
8
+ onBeforeCreateRoutes: typeof onBeforeCreateRoutes;
9
+ };
@@ -7,6 +7,7 @@ export { renderRoutes } from './utils';
7
7
  export { routerPlugin };
8
8
  export default routerPlugin;
9
9
  export { modifyRoutes } from './plugin';
10
+ export type { RouterExtendsHooks } from './hooks';
10
11
  export * from './withRouter';
11
12
  export { Link, NavLink } from './PrefetchLink';
12
13
  export type { LinkProps, NavLinkProps } from './PrefetchLink';
@@ -1,6 +1,9 @@
1
- import { type Plugin } from '../../core';
1
+ import { type RuntimePluginFuture } from '../../core';
2
+ import { type RouterExtendsHooks } from './hooks';
2
3
  import type { RouterConfig, Routes } from './types';
3
4
  export declare let finalRouteConfig: RouterConfig['routesConfig'];
4
5
  export declare let beforeCreateRouter: boolean;
5
6
  export declare function modifyRoutes(modifyFunction: (routes: Routes) => Routes): void;
6
- export declare const routerPlugin: (userConfig?: Partial<RouterConfig>) => Plugin;
7
+ export declare const routerPlugin: (userConfig?: Partial<RouterConfig>) => RuntimePluginFuture<{
8
+ extendHooks: RouterExtendsHooks;
9
+ }>;
@@ -1,4 +1,7 @@
1
- import type { Plugin } from '../../core';
1
+ import type { RuntimePluginFuture } from '../../core';
2
+ import { type RouterExtendsHooks } from './hooks';
2
3
  import type { RouterConfig } from './types';
3
- export declare const routerPlugin: (userConfig?: Partial<RouterConfig>) => Plugin;
4
+ export declare const routerPlugin: (userConfig?: Partial<RouterConfig>) => RuntimePluginFuture<{
5
+ extendHooks: RouterExtendsHooks;
6
+ }>;
4
7
  export declare const modifyRoutes: () => void;
@@ -32,6 +32,10 @@ export type RouterConfig = {
32
32
  future?: Partial<{
33
33
  v7_startTransition: boolean;
34
34
  }>;
35
+ /**
36
+ * An unstable feature, which will reload the page when the current browser URL and the SSR Context URL do not match.
37
+ */
38
+ unstable_reloadOnURLMismatch?: boolean;
35
39
  };
36
40
  export type Routes = RouterConfig['routesConfig']['routes'];
37
41
  export interface RouteManifest {
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.63.7-alpha.0",
18
+ "version": "2.64.0",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -200,12 +200,12 @@
200
200
  "react-is": "^18",
201
201
  "react-side-effect": "^2.1.1",
202
202
  "styled-components": "^5.3.1",
203
- "@modern-js/plugin": "2.63.6",
204
- "@modern-js/plugin-v2": "2.63.6",
205
- "@modern-js/plugin-data-loader": "2.63.6",
206
- "@modern-js/runtime-utils": "2.63.6",
207
- "@modern-js/types": "2.63.6",
208
- "@modern-js/utils": "2.63.6"
203
+ "@modern-js/plugin": "2.64.0",
204
+ "@modern-js/plugin-data-loader": "2.64.0",
205
+ "@modern-js/plugin-v2": "2.64.0",
206
+ "@modern-js/runtime-utils": "2.64.0",
207
+ "@modern-js/utils": "2.64.0",
208
+ "@modern-js/types": "2.64.0"
209
209
  },
210
210
  "peerDependencies": {
211
211
  "react": ">=17",
@@ -229,14 +229,15 @@
229
229
  "ts-node": "^10.9.1",
230
230
  "typescript": "^5",
231
231
  "webpack": "^5.97.1",
232
- "@scripts/build": "2.63.6",
233
- "@modern-js/app-tools": "2.63.6",
234
- "@scripts/jest-config": "2.63.6"
232
+ "@modern-js/app-tools": "2.64.0",
233
+ "@scripts/build": "2.64.0",
234
+ "@scripts/jest-config": "2.64.0"
235
235
  },
236
236
  "sideEffects": false,
237
237
  "publishConfig": {
238
238
  "registry": "https://registry.npmjs.org/",
239
- "access": "public"
239
+ "access": "public",
240
+ "provenance": true
240
241
  },
241
242
  "scripts": {
242
243
  "dev": "modern-lib build --watch",
@@ -1,17 +0,0 @@
1
- import { runtime } from "./base";
2
- var globalRunner;
3
- function setGlobalRunner(runner) {
4
- globalRunner = runner;
5
- }
6
- function getGlobalRunner() {
7
- if (globalRunner) {
8
- return globalRunner;
9
- }
10
- var runner = runtime.init();
11
- setGlobalRunner(runner);
12
- return runner;
13
- }
14
- export {
15
- getGlobalRunner,
16
- setGlobalRunner
17
- };
@@ -1,17 +0,0 @@
1
- import { runtime } from "./base";
2
- let globalRunner;
3
- function setGlobalRunner(runner) {
4
- globalRunner = runner;
5
- }
6
- function getGlobalRunner() {
7
- if (globalRunner) {
8
- return globalRunner;
9
- }
10
- const runner = runtime.init();
11
- setGlobalRunner(runner);
12
- return runner;
13
- }
14
- export {
15
- getGlobalRunner,
16
- setGlobalRunner
17
- };
@@ -1,9 +0,0 @@
1
- /// <reference types="react" />
2
- import { type PluginRunner } from './base';
3
- export declare function setGlobalRunner(runner: PluginRunner): void;
4
- export declare function getGlobalRunner(): import("@modern-js/plugin").ToRunners<{
5
- beforeRender: import("@modern-js/plugin").AsyncInterruptWorkflow<import("..").RuntimeContext, void>;
6
- wrapRoot: import("@modern-js/plugin").Waterfall<import("react").ComponentType<any>>;
7
- pickContext: import("@modern-js/plugin").Waterfall<import("../context/runtime").TRuntimeContext>;
8
- modifyRuntimeConfig: import("@modern-js/plugin").SyncParallelWorkflow<void, Record<string, any>>;
9
- }>;