@modern-js/runtime 2.63.7 → 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 (64) hide show
  1. package/dist/cjs/core/browser/index.js +6 -4
  2. package/dist/cjs/core/compat/hooks.js +80 -0
  3. package/dist/cjs/core/{plugin/runner.js → compat/index.js} +19 -19
  4. package/dist/cjs/core/compatible.js +15 -11
  5. package/dist/cjs/core/context/index.js +12 -2
  6. package/dist/cjs/core/context/runtime.js +1 -2
  7. package/dist/cjs/core/index.js +1 -4
  8. package/dist/cjs/core/plugin/base.js +0 -35
  9. package/dist/cjs/core/plugin/index.js +17 -17
  10. package/dist/cjs/core/plugin/types.js +16 -0
  11. package/dist/cjs/core/react/index.js +3 -3
  12. package/dist/cjs/core/server/requestHandler.js +4 -4
  13. package/dist/cjs/router/runtime/hooks.js +7 -7
  14. package/dist/cjs/router/runtime/plugin.js +107 -108
  15. package/dist/cjs/router/runtime/plugin.node.js +89 -91
  16. package/dist/esm/core/browser/index.js +9 -7
  17. package/dist/esm/core/compat/hooks.js +88 -0
  18. package/dist/esm/core/compat/index.js +20 -0
  19. package/dist/esm/core/compatible.js +17 -13
  20. package/dist/esm/core/context/index.js +9 -1
  21. package/dist/esm/core/context/runtime.js +2 -3
  22. package/dist/esm/core/index.js +1 -3
  23. package/dist/esm/core/plugin/base.js +0 -28
  24. package/dist/esm/core/plugin/index.js +14 -17
  25. package/dist/esm/core/plugin/types.js +0 -0
  26. package/dist/esm/core/react/index.js +4 -4
  27. package/dist/esm/core/server/requestHandler.js +6 -6
  28. package/dist/esm/router/runtime/hooks.js +5 -5
  29. package/dist/esm/router/runtime/plugin.js +114 -115
  30. package/dist/esm/router/runtime/plugin.node.js +112 -111
  31. package/dist/esm-node/core/browser/index.js +7 -5
  32. package/dist/esm-node/core/compat/hooks.js +54 -0
  33. package/dist/esm-node/core/compat/index.js +18 -0
  34. package/dist/esm-node/core/compatible.js +16 -12
  35. package/dist/esm-node/core/context/index.js +9 -1
  36. package/dist/esm-node/core/context/runtime.js +1 -2
  37. package/dist/esm-node/core/index.js +1 -3
  38. package/dist/esm-node/core/plugin/base.js +0 -24
  39. package/dist/esm-node/core/plugin/index.js +16 -14
  40. package/dist/esm-node/core/plugin/types.js +0 -0
  41. package/dist/esm-node/core/react/index.js +4 -4
  42. package/dist/esm-node/core/server/requestHandler.js +5 -5
  43. package/dist/esm-node/router/runtime/hooks.js +5 -5
  44. package/dist/esm-node/router/runtime/plugin.js +108 -109
  45. package/dist/esm-node/router/runtime/plugin.node.js +90 -92
  46. package/dist/types/core/browser/hydrate.d.ts +1 -1
  47. package/dist/types/core/compat/hooks.d.ts +4 -0
  48. package/dist/types/core/compat/index.d.ts +2 -0
  49. package/dist/types/core/compatible.d.ts +7 -6
  50. package/dist/types/core/context/index.d.ts +7 -2
  51. package/dist/types/core/context/runtime.d.ts +1 -3
  52. package/dist/types/core/index.d.ts +1 -2
  53. package/dist/types/core/plugin/base.d.ts +9 -33
  54. package/dist/types/core/plugin/index.d.ts +19 -12
  55. package/dist/types/core/plugin/types.d.ts +10 -0
  56. package/dist/types/index.d.ts +1 -1
  57. package/dist/types/router/runtime/hooks.d.ts +7 -3
  58. package/dist/types/router/runtime/index.d.ts +1 -0
  59. package/dist/types/router/runtime/plugin.d.ts +5 -2
  60. package/dist/types/router/runtime/plugin.node.d.ts +5 -2
  61. package/package.json +10 -10
  62. package/dist/esm/core/plugin/runner.js +0 -17
  63. package/dist/esm-node/core/plugin/runner.js +0 -17
  64. package/dist/types/core/plugin/runner.d.ts +0 -9
@@ -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
+ }
@@ -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;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.63.7",
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.7",
204
- "@modern-js/plugin-v2": "2.63.7",
205
- "@modern-js/plugin-data-loader": "2.63.7",
206
- "@modern-js/runtime-utils": "2.63.7",
207
- "@modern-js/types": "2.63.7",
208
- "@modern-js/utils": "2.63.7"
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,9 +229,9 @@
229
229
  "ts-node": "^10.9.1",
230
230
  "typescript": "^5",
231
231
  "webpack": "^5.97.1",
232
- "@modern-js/app-tools": "2.63.7",
233
- "@scripts/build": "2.63.7",
234
- "@scripts/jest-config": "2.63.7"
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": {
@@ -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
- }>;