@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
@@ -35,7 +35,6 @@ var import_cookie = __toESM(require("cookie"));
35
35
  var import_context = require("../context");
36
36
  var import_runtime = require("../context/runtime");
37
37
  var import_loaderManager = require("../loader/loaderManager");
38
- var import_runner = require("../plugin/runner");
39
38
  var import_wrapper = require("../react/wrapper");
40
39
  var import_hydrate = require("./hydrate");
41
40
  const IS_REACT18 = process.env.IS_REACT18 === "true";
@@ -81,10 +80,13 @@ function isClientArgs(id) {
81
80
  return typeof id === "undefined" || typeof id === "string" || typeof HTMLElement !== "undefined" && id instanceof HTMLElement;
82
81
  }
83
82
  async function render(App, id) {
84
- const runner = (0, import_runner.getGlobalRunner)();
85
- const context = (0, import_runtime.getInitialContext)(runner);
83
+ const context = (0, import_runtime.getInitialContext)();
86
84
  const runBeforeRender = async (context2) => {
87
- await runner.beforeRender(context2);
85
+ const internalRuntimeContext = (0, import_context.getGlobalInternalRuntimeContext)();
86
+ const api = internalRuntimeContext.pluginAPI;
87
+ api.updateRuntimeContext(context2);
88
+ const hooks = internalRuntimeContext.hooks;
89
+ await hooks.onBeforeRender.call(context2);
88
90
  const init = (0, import_context.getGlobalAppInit)();
89
91
  return init === null || init === void 0 ? void 0 : init(context2);
90
92
  };
@@ -0,0 +1,80 @@
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 hooks_exports = {};
20
+ __export(hooks_exports, {
21
+ getHookRunners: () => getHookRunners,
22
+ handleSetupResult: () => handleSetupResult,
23
+ transformHookRunner: () => transformHookRunner
24
+ });
25
+ module.exports = __toCommonJS(hooks_exports);
26
+ function transformHookRunner(hookRunnerName) {
27
+ switch (hookRunnerName) {
28
+ case "beforeRender":
29
+ return "onBeforeRender";
30
+ default:
31
+ return hookRunnerName;
32
+ }
33
+ }
34
+ function handleSetupResult(setupResult, api) {
35
+ if (!setupResult) {
36
+ return;
37
+ }
38
+ Object.keys(setupResult).forEach((key) => {
39
+ const fn = setupResult[key];
40
+ if (typeof fn === "function") {
41
+ const newAPI = transformHookRunner(key);
42
+ if (api[newAPI]) {
43
+ if (key === "beforeRender") {
44
+ api[newAPI](async (...params) => {
45
+ await fn(...params);
46
+ });
47
+ } else {
48
+ api[newAPI]((...params) => {
49
+ const res = fn(...params);
50
+ return res;
51
+ });
52
+ }
53
+ }
54
+ }
55
+ });
56
+ }
57
+ function getHookRunners(runtimeContext) {
58
+ const { _internalContext } = runtimeContext;
59
+ const { hooks } = _internalContext;
60
+ return {
61
+ beforeRender: async (context) => {
62
+ return hooks.onBeforeRender.call(context);
63
+ },
64
+ wrapRoot: (App) => {
65
+ return hooks.wrapRoot.call(App);
66
+ },
67
+ pickContext: (context) => {
68
+ return hooks.pickContext.call(context);
69
+ },
70
+ modifyRuntimeConfig: (config) => {
71
+ return hooks.modifyRuntimeConfig.call(config);
72
+ }
73
+ };
74
+ }
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ getHookRunners,
78
+ handleSetupResult,
79
+ transformHookRunner
80
+ });
@@ -16,27 +16,27 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var runner_exports = {};
20
- __export(runner_exports, {
21
- getGlobalRunner: () => getGlobalRunner,
22
- setGlobalRunner: () => setGlobalRunner
19
+ var compat_exports = {};
20
+ __export(compat_exports, {
21
+ compatPlugin: () => compatPlugin
23
22
  });
24
- module.exports = __toCommonJS(runner_exports);
25
- var import_base = require("./base");
26
- let globalRunner;
27
- function setGlobalRunner(runner) {
28
- globalRunner = runner;
29
- }
30
- function getGlobalRunner() {
31
- if (globalRunner) {
32
- return globalRunner;
23
+ module.exports = __toCommonJS(compat_exports);
24
+ var import_hooks = require("./hooks");
25
+ const compatPlugin = () => ({
26
+ name: "@modern-js/runtime-plugin-compat",
27
+ _registryApi: (getRuntimeContext) => {
28
+ return {
29
+ useRuntimeConfigContext: () => {
30
+ const { _internalContext } = getRuntimeContext();
31
+ return _internalContext.config;
32
+ },
33
+ useHookRunners: () => {
34
+ return (0, import_hooks.getHookRunners)(getRuntimeContext());
35
+ }
36
+ };
33
37
  }
34
- const runner = import_base.runtime.init();
35
- setGlobalRunner(runner);
36
- return runner;
37
- }
38
+ });
38
39
  // Annotate the CommonJS export names for ESM import in node:
39
40
  0 && (module.exports = {
40
- getGlobalRunner,
41
- setGlobalRunner
41
+ compatPlugin
42
42
  });
@@ -41,22 +41,21 @@ var import_context = require("./context");
41
41
  var import_runtime = require("./context/runtime");
42
42
  var import_loaderManager = require("./loader/loaderManager");
43
43
  var import_plugin = require("./plugin");
44
- var import_runner = require("./plugin/runner");
45
44
  var import_wrapper = require("./react/wrapper");
46
45
  const IS_REACT18 = process.env.IS_REACT18 === "true";
47
46
  function isClientArgs(id) {
48
47
  return typeof id === "string" || typeof HTMLElement !== "undefined" && id instanceof HTMLElement;
49
48
  }
50
- const getInitialContext = (runner) => ({
49
+ const getInitialContext = () => ({
51
50
  loaderManager: (0, import_loaderManager.createLoaderManager)({}),
52
- runner,
53
51
  isBrowser: true,
54
52
  routeManifest: typeof window !== "undefined" && window[import_constants.ROUTE_MANIFEST]
55
53
  });
56
- const createApp = ({ plugins, runtime, props: globalProps }) => {
57
- const runner = (0, import_plugin.registerPlugin)(plugins, {
54
+ const createApp = ({ plugins, props: globalProps }) => {
55
+ const context = (0, import_plugin.registerPlugin)(plugins, {
58
56
  plugins: []
59
- }, runtime);
57
+ });
58
+ const hooks = context.hooks;
60
59
  return (App) => {
61
60
  const WrapperComponent = (props) => {
62
61
  return /* @__PURE__ */ import_react.default.createElement(App || import_react.default.Fragment, App ? {
@@ -66,7 +65,7 @@ const createApp = ({ plugins, runtime, props: globalProps }) => {
66
65
  ...props
67
66
  }) : child));
68
67
  };
69
- const WrapperApp = runner.wrapRoot(WrapperComponent);
68
+ const WrapperApp = hooks.wrapRoot.call(WrapperComponent);
70
69
  const WrapComponent = (props) => {
71
70
  const mergedProps = {
72
71
  ...props,
@@ -81,10 +80,13 @@ const createApp = ({ plugins, runtime, props: globalProps }) => {
81
80
  };
82
81
  const bootstrap = async (BootApp, id, root, ReactDOM) => {
83
82
  const App = BootApp;
84
- const runner = (0, import_runner.getGlobalRunner)();
85
- const context = getInitialContext(runner);
83
+ const internalRuntimeContext = (0, import_context.getGlobalInternalRuntimeContext)();
84
+ const api = internalRuntimeContext.pluginAPI;
85
+ const hooks = internalRuntimeContext.hooks;
86
+ const context = getInitialContext();
87
+ api.updateRuntimeContext(context);
86
88
  const runBeforeRender = async (context2) => {
87
- await runner.beforeRender(context2);
89
+ await hooks.onBeforeRender.call(context2);
88
90
  const init = (0, import_context.getGlobalAppInit)();
89
91
  return init === null || init === void 0 ? void 0 : init(context2);
90
92
  };
@@ -187,7 +189,9 @@ const useRuntimeContext = () => {
187
189
  request: (_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.request,
188
190
  response: (_context_ssrContext1 = context.ssrContext) === null || _context_ssrContext1 === void 0 ? void 0 : _context_ssrContext1.response
189
191
  };
190
- const memoizedContext = (0, import_react.useMemo)(() => context.runner.pickContext(pickedContext), [
192
+ const internalRuntimeContext = (0, import_context.getGlobalInternalRuntimeContext)();
193
+ const hooks = internalRuntimeContext.hooks;
194
+ const memoizedContext = (0, import_react.useMemo)(() => hooks.pickContext.call(pickedContext), [
191
195
  context
192
196
  ]);
193
197
  return memoizedContext;
@@ -22,10 +22,12 @@ __export(context_exports, {
22
22
  getGlobalApp: () => getGlobalApp,
23
23
  getGlobalAppConfig: () => getGlobalAppConfig,
24
24
  getGlobalAppInit: () => getGlobalAppInit,
25
+ getGlobalInternalRuntimeContext: () => getGlobalInternalRuntimeContext,
25
26
  getGlobalLayoutApp: () => getGlobalLayoutApp,
26
27
  getGlobalRoutes: () => getGlobalRoutes,
27
28
  getInitialContext: () => import_runtime.getInitialContext,
28
- setGlobalContext: () => setGlobalContext
29
+ setGlobalContext: () => setGlobalContext,
30
+ setGlobalInternalRuntimeContext: () => setGlobalInternalRuntimeContext
29
31
  });
30
32
  module.exports = __toCommonJS(context_exports);
31
33
  var import_runtime = require("./runtime");
@@ -37,6 +39,12 @@ function setGlobalContext(context) {
37
39
  globalContext.appConfig = typeof context.appConfig === "function" ? context.appConfig() : context.appConfig;
38
40
  globalContext.layoutApp = context.layoutApp;
39
41
  }
42
+ function setGlobalInternalRuntimeContext(context) {
43
+ globalContext.internalRuntimeContext = context;
44
+ }
45
+ function getGlobalInternalRuntimeContext() {
46
+ return globalContext.internalRuntimeContext;
47
+ }
40
48
  function getGlobalApp() {
41
49
  return globalContext.App;
42
50
  }
@@ -60,8 +68,10 @@ function getGlobalLayoutApp() {
60
68
  getGlobalApp,
61
69
  getGlobalAppConfig,
62
70
  getGlobalAppInit,
71
+ getGlobalInternalRuntimeContext,
63
72
  getGlobalLayoutApp,
64
73
  getGlobalRoutes,
65
74
  getInitialContext,
66
- setGlobalContext
75
+ setGlobalContext,
76
+ setGlobalInternalRuntimeContext
67
77
  });
@@ -28,9 +28,8 @@ var import_react = require("react");
28
28
  var import_loaderManager = require("../loader/loaderManager");
29
29
  const RuntimeReactContext = (0, import_react.createContext)({});
30
30
  const ServerRouterContext = (0, import_react.createContext)({});
31
- const getInitialContext = (runner, isBrowser = true, routeManifest) => ({
31
+ const getInitialContext = (isBrowser = true, routeManifest) => ({
32
32
  loaderManager: (0, import_loaderManager.createLoaderManager)({}),
33
- runner,
34
33
  isBrowser,
35
34
  routeManifest: routeManifest || typeof window !== "undefined" && window[import_constants.ROUTE_MANIFEST]
36
35
  });
@@ -23,11 +23,9 @@ __export(core_exports, {
23
23
  ServerRouterContext: () => import_runtime.ServerRouterContext,
24
24
  defineConfig: () => import_config.defineConfig,
25
25
  defineRuntimeConfig: () => import_config.defineRuntimeConfig,
26
- getConfig: () => import_config.getConfig,
27
- runtime: () => import_plugin.runtime
26
+ getConfig: () => import_config.getConfig
28
27
  });
29
28
  module.exports = __toCommonJS(core_exports);
30
- var import_plugin = require("./plugin");
31
29
  var import_config = require("./config");
32
30
  __reExport(core_exports, require("./compatible"), module.exports);
33
31
  var import_runtime = require("./context/runtime");
@@ -40,7 +38,6 @@ __reExport(core_exports, require("@modern-js/plugin"), module.exports);
40
38
  defineConfig,
41
39
  defineRuntimeConfig,
42
40
  getConfig,
43
- runtime,
44
41
  ...require("./compatible"),
45
42
  ...require("./loader"),
46
43
  ...require("@modern-js/plugin")
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
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
6
  var __copyProps = (to, from, except, desc) => {
11
7
  if (from && typeof from === "object" || typeof from === "function") {
12
8
  for (let key of __getOwnPropNames(from))
@@ -17,35 +13,4 @@ var __copyProps = (to, from, except, desc) => {
17
13
  };
18
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
15
  var base_exports = {};
20
- __export(base_exports, {
21
- RuntimeConfigContext: () => RuntimeConfigContext,
22
- createRuntime: () => createRuntime,
23
- runtime: () => runtime,
24
- useRuntimeConfigContext: () => useRuntimeConfigContext
25
- });
26
16
  module.exports = __toCommonJS(base_exports);
27
- var import_plugin = require("@modern-js/plugin");
28
- const RuntimeConfigContext = (0, import_plugin.createContext)({});
29
- const useRuntimeConfigContext = () => RuntimeConfigContext.use().value;
30
- const wrapRoot = (0, import_plugin.createWaterfall)();
31
- const beforeRender = (0, import_plugin.createAsyncInterruptWorkflow)();
32
- const pickContext = (0, import_plugin.createWaterfall)();
33
- const modifyRuntimeConfig = (0, import_plugin.createSyncParallelWorkflow)();
34
- const runtimeHooks = {
35
- beforeRender,
36
- wrapRoot,
37
- pickContext,
38
- modifyRuntimeConfig
39
- };
40
- const runtimePluginAPI = {
41
- useRuntimeConfigContext
42
- };
43
- const createRuntime = () => (0, import_plugin.createManager)(runtimeHooks, runtimePluginAPI);
44
- const runtime = createRuntime();
45
- // Annotate the CommonJS export names for ESM import in node:
46
- 0 && (module.exports = {
47
- RuntimeConfigContext,
48
- createRuntime,
49
- runtime,
50
- useRuntimeConfigContext
51
- });
@@ -15,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
19
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
19
  var plugin_exports = {};
21
20
  __export(plugin_exports, {
@@ -23,22 +22,24 @@ __export(plugin_exports, {
23
22
  registerPlugin: () => registerPlugin
24
23
  });
25
24
  module.exports = __toCommonJS(plugin_exports);
25
+ var import_runtime = require("@modern-js/plugin-v2/runtime");
26
26
  var import_merge = require("@modern-js/runtime-utils/merge");
27
- var import_base = require("./base");
28
- var import_runner = require("./runner");
29
- __reExport(plugin_exports, require("./base"), module.exports);
30
- function setupConfigContext() {
31
- const runner = (0, import_runner.getGlobalRunner)();
32
- const configs = runner.modifyRuntimeConfig();
33
- import_base.RuntimeConfigContext.set((0, import_merge.merge)({}, ...configs));
34
- }
35
- function registerPlugin(internalPlugins, runtimeConfig, customRuntime) {
27
+ var import_compat = require("../compat");
28
+ var import_hooks = require("../compat/hooks");
29
+ var import_context = require("../context");
30
+ function registerPlugin(internalPlugins, runtimeConfig) {
36
31
  const { plugins = [] } = runtimeConfig || {};
37
- (customRuntime || import_base.runtime).usePlugin(...internalPlugins, ...plugins);
38
- const runner = (customRuntime || import_base.runtime).init();
39
- (0, import_runner.setGlobalRunner)(runner);
40
- setupConfigContext();
41
- return runner;
32
+ const { runtimeContext } = import_runtime.runtime.run({
33
+ plugins: [
34
+ (0, import_compat.compatPlugin)(),
35
+ ...internalPlugins,
36
+ ...plugins
37
+ ],
38
+ config: runtimeConfig || {},
39
+ handleSetupResult: import_hooks.handleSetupResult
40
+ });
41
+ (0, import_context.setGlobalInternalRuntimeContext)(runtimeContext);
42
+ return runtimeContext;
42
43
  }
43
44
  function mergeConfig(config, ...otherConfig) {
44
45
  return (0, import_merge.merge)({}, config, ...otherConfig);
@@ -46,6 +47,5 @@ function mergeConfig(config, ...otherConfig) {
46
47
  // Annotate the CommonJS export names for ESM import in node:
47
48
  0 && (module.exports = {
48
49
  mergeConfig,
49
- registerPlugin,
50
- ...require("./base")
50
+ registerPlugin
51
51
  });
@@ -0,0 +1,16 @@
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 __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var types_exports = {};
16
+ module.exports = __toCommonJS(types_exports);
@@ -25,15 +25,15 @@ var import_parsed = require("@modern-js/runtime-utils/parsed");
25
25
  var import_common = require("../../common");
26
26
  var import_constants = require("../constants");
27
27
  var import_context = require("../context");
28
- var import_runner = require("../plugin/runner");
29
28
  function createRoot(UserApp) {
30
29
  const App = UserApp || (0, import_context.getGlobalApp)();
31
30
  if ((0, import_common.isBrowser)()) {
32
31
  window._SSR_DATA = window._SSR_DATA || (0, import_parsed.parsedJSONFromElement)(import_constants.SSR_DATA_JSON_ID);
33
32
  window._ROUTER_DATA = window._ROUTER_DATA || (0, import_parsed.parsedJSONFromElement)(import_constants.ROUTER_DATA_JSON_ID);
34
33
  }
35
- const runner = (0, import_runner.getGlobalRunner)();
36
- const WrapperApp = runner.wrapRoot(App);
34
+ const internalRuntimeContext = (0, import_context.getGlobalInternalRuntimeContext)();
35
+ const hooks = internalRuntimeContext.hooks;
36
+ const WrapperApp = hooks.wrapRoot.call(App);
37
37
  return WrapperApp;
38
38
  }
39
39
  // Annotate the CommonJS export names for ESM import in node:
@@ -25,7 +25,6 @@ var import_request = require("@modern-js/runtime-utils/universal/request");
25
25
  var import_context = require("../context");
26
26
  var import_runtime = require("../context/runtime");
27
27
  var import_loaderManager = require("../loader/loaderManager");
28
- var import_runner = require("../plugin/runner");
29
28
  var import_react = require("../react");
30
29
  var import_constants = require("./constants");
31
30
  var import_utils = require("./utils");
@@ -89,11 +88,12 @@ const createRequestHandler = async (handleRequest) => {
89
88
  const requestHandler = async (request, options) => {
90
89
  var _context_routerContext, _context_routerContext1;
91
90
  const Root = (0, import_react.createRoot)();
92
- const runner = (0, import_runner.getGlobalRunner)();
91
+ const internalRuntimeContext = (0, import_context.getGlobalInternalRuntimeContext)();
92
+ const hooks = internalRuntimeContext.hooks;
93
93
  const { routeManifest } = options.resource;
94
- const context = (0, import_runtime.getInitialContext)(runner, false, routeManifest);
94
+ const context = (0, import_runtime.getInitialContext)(false, routeManifest);
95
95
  const runBeforeRender = async (context2) => {
96
- const result = await runner.beforeRender(context2);
96
+ const result = await hooks.onBeforeRender.call(context2);
97
97
  if (typeof Response !== "undefined" && result instanceof Response) {
98
98
  return result;
99
99
  }
@@ -18,15 +18,15 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var hooks_exports = {};
20
20
  __export(hooks_exports, {
21
- beforeCreateRoutes: () => beforeCreateRoutes,
22
- modifyRoutes: () => modifyRoutes
21
+ modifyRoutes: () => modifyRoutes,
22
+ onBeforeCreateRoutes: () => onBeforeCreateRoutes
23
23
  });
24
24
  module.exports = __toCommonJS(hooks_exports);
25
- var import_plugin = require("@modern-js/plugin");
26
- const modifyRoutes = (0, import_plugin.createWaterfall)();
27
- const beforeCreateRoutes = (0, import_plugin.createAsyncInterruptWorkflow)();
25
+ var import_plugin_v2 = require("@modern-js/plugin-v2");
26
+ const modifyRoutes = (0, import_plugin_v2.createSyncHook)();
27
+ const onBeforeCreateRoutes = (0, import_plugin_v2.createSyncHook)();
28
28
  // Annotate the CommonJS export names for ESM import in node:
29
29
  0 && (module.exports = {
30
- beforeCreateRoutes,
31
- modifyRoutes
30
+ modifyRoutes,
31
+ onBeforeCreateRoutes
32
32
  });