@modern-js/runtime 2.60.4 → 2.60.5-alpha.1

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.
@@ -18,12 +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,
21
22
  modifyRoutes: () => modifyRoutes
22
23
  });
23
24
  module.exports = __toCommonJS(hooks_exports);
24
25
  var import_plugin = require("@modern-js/plugin");
25
26
  const modifyRoutes = (0, import_plugin.createWaterfall)();
27
+ const beforeCreateRoutes = (0, import_plugin.createAsyncInterruptWorkflow)();
26
28
  // Annotate the CommonJS export names for ESM import in node:
27
29
  0 && (module.exports = {
30
+ beforeCreateRoutes,
28
31
  modifyRoutes
29
32
  });
@@ -61,7 +61,8 @@ const routerPlugin = (userConfig = {}) => {
61
61
  return {
62
62
  name: "@modern-js/plugin-router",
63
63
  registerHook: {
64
- modifyRoutes: import_hooks.modifyRoutes
64
+ modifyRoutes: import_hooks.modifyRoutes,
65
+ beforeCreateRoutes: import_hooks.beforeCreateRoutes
65
66
  },
66
67
  setup: (api) => {
67
68
  let finalRouteConfig = {};
@@ -84,6 +85,8 @@ const routerPlugin = (userConfig = {}) => {
84
85
  const { reporter } = context.ssrContext;
85
86
  const requestContext = (0, import_node.createRequestContext)((_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.loaderContext);
86
87
  requestContext.set(import_node.reporterCtx, reporter);
88
+ const runner = api.useHookRunners();
89
+ await runner.beforeCreateRouts(context);
87
90
  let routes = createRoutes ? createRoutes() : (0, import_router2.createRoutesFromElements)((0, import_utils.renderRoutes)({
88
91
  routesConfig: finalRouteConfig,
89
92
  ssrMode,
@@ -92,7 +95,6 @@ const routerPlugin = (userConfig = {}) => {
92
95
  },
93
96
  reporter
94
97
  }));
95
- const runner = api.useHookRunners();
96
98
  routes = runner.modifyRoutes(routes);
97
99
  const { query } = (0, import_remix_router.createStaticHandler)(routes, {
98
100
  basename: _basename
@@ -1,5 +1,7 @@
1
- import { createWaterfall } from "@modern-js/plugin";
1
+ import { createAsyncInterruptWorkflow, createWaterfall } from "@modern-js/plugin";
2
2
  var modifyRoutes = createWaterfall();
3
+ var beforeCreateRoutes = createAsyncInterruptWorkflow();
3
4
  export {
5
+ beforeCreateRoutes,
4
6
  modifyRoutes
5
7
  };
@@ -16,7 +16,7 @@ import { JSX_SHELL_STREAM_END_MARK } from "../../common";
16
16
  import { RuntimeReactContext } from "../../core";
17
17
  import { getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
18
18
  import DeferredDataScripts from "./DeferredDataScripts.node";
19
- import { modifyRoutes as modifyRoutesHook } from "./hooks";
19
+ import { beforeCreateRoutes as beforeCreateRoutesHook, modifyRoutes as modifyRoutesHook } from "./hooks";
20
20
  import { renderRoutes, urlJoin } from "./utils";
21
21
  function createRemixReuqest(request) {
22
22
  var method = "GET";
@@ -33,14 +33,15 @@ var routerPlugin = function() {
33
33
  return {
34
34
  name: "@modern-js/plugin-router",
35
35
  registerHook: {
36
- modifyRoutes: modifyRoutesHook
36
+ modifyRoutes: modifyRoutesHook,
37
+ beforeCreateRoutes: beforeCreateRoutesHook
37
38
  },
38
39
  setup: function(api) {
39
40
  var finalRouteConfig = {};
40
41
  return {
41
42
  beforeRender: function beforeRender(context, interrupt) {
42
43
  return _async_to_generator(function() {
43
- var _context_ssrContext, _context_ssrContext_onTiming, _context_ssrContext1, pluginConfig, _merge, _merge_basename, basename, routesConfig, createRoutes, _context_ssrContext2, request, ssrMode, nonce, _context_ssrContext_loaderFailureMode, loaderFailureMode, baseUrl, _basename, reporter, requestContext, routes, runner, query, remixRequest, end, routerContext, cost, router;
44
+ var _context_ssrContext, _context_ssrContext_onTiming, _context_ssrContext1, pluginConfig, _merge, _merge_basename, basename, routesConfig, createRoutes, _context_ssrContext2, request, ssrMode, nonce, _context_ssrContext_loaderFailureMode, loaderFailureMode, baseUrl, _basename, reporter, requestContext, runner, routes, query, remixRequest, end, routerContext, cost, router;
44
45
  return _ts_generator(this, function(_state) {
45
46
  switch (_state.label) {
46
47
  case 0:
@@ -61,6 +62,13 @@ var routerPlugin = function() {
61
62
  reporter = context.ssrContext.reporter;
62
63
  requestContext = createRequestContext((_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.loaderContext);
63
64
  requestContext.set(reporterCtx, reporter);
65
+ runner = api.useHookRunners();
66
+ return [
67
+ 4,
68
+ runner.beforeCreateRouts(context)
69
+ ];
70
+ case 1:
71
+ _state.sent();
64
72
  routes = createRoutes ? createRoutes() : createRoutesFromElements(renderRoutes({
65
73
  routesConfig: finalRouteConfig,
66
74
  ssrMode,
@@ -69,7 +77,6 @@ var routerPlugin = function() {
69
77
  },
70
78
  reporter
71
79
  }));
72
- runner = api.useHookRunners();
73
80
  routes = runner.modifyRoutes(routes);
74
81
  query = createStaticHandler(routes, {
75
82
  basename: _basename
@@ -82,7 +89,7 @@ var routerPlugin = function() {
82
89
  requestContext
83
90
  })
84
91
  ];
85
- case 1:
92
+ case 2:
86
93
  routerContext = _state.sent();
87
94
  cost = end();
88
95
  (_context_ssrContext1 = context.ssrContext) === null || _context_ssrContext1 === void 0 ? void 0 : (_context_ssrContext_onTiming = _context_ssrContext1.onTiming) === null || _context_ssrContext_onTiming === void 0 ? void 0 : _context_ssrContext_onTiming.call(_context_ssrContext1, LOADER_REPORTER_NAME, cost);
@@ -1,5 +1,7 @@
1
- import { createWaterfall } from "@modern-js/plugin";
1
+ import { createAsyncInterruptWorkflow, createWaterfall } from "@modern-js/plugin";
2
2
  const modifyRoutes = createWaterfall();
3
+ const beforeCreateRoutes = createAsyncInterruptWorkflow();
3
4
  export {
5
+ beforeCreateRoutes,
4
6
  modifyRoutes
5
7
  };
@@ -11,7 +11,7 @@ import { JSX_SHELL_STREAM_END_MARK } from "../../common";
11
11
  import { RuntimeReactContext } from "../../core";
12
12
  import { getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
13
13
  import DeferredDataScripts from "./DeferredDataScripts.node";
14
- import { modifyRoutes as modifyRoutesHook } from "./hooks";
14
+ import { beforeCreateRoutes as beforeCreateRoutesHook, modifyRoutes as modifyRoutesHook } from "./hooks";
15
15
  import { renderRoutes, urlJoin } from "./utils";
16
16
  function createRemixReuqest(request) {
17
17
  const method = "GET";
@@ -27,7 +27,8 @@ const routerPlugin = (userConfig = {}) => {
27
27
  return {
28
28
  name: "@modern-js/plugin-router",
29
29
  registerHook: {
30
- modifyRoutes: modifyRoutesHook
30
+ modifyRoutes: modifyRoutesHook,
31
+ beforeCreateRoutes: beforeCreateRoutesHook
31
32
  },
32
33
  setup: (api) => {
33
34
  let finalRouteConfig = {};
@@ -50,6 +51,8 @@ const routerPlugin = (userConfig = {}) => {
50
51
  const { reporter } = context.ssrContext;
51
52
  const requestContext = createRequestContext((_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.loaderContext);
52
53
  requestContext.set(reporterCtx, reporter);
54
+ const runner = api.useHookRunners();
55
+ await runner.beforeCreateRouts(context);
53
56
  let routes = createRoutes ? createRoutes() : createRoutesFromElements(renderRoutes({
54
57
  routesConfig: finalRouteConfig,
55
58
  ssrMode,
@@ -58,7 +61,6 @@ const routerPlugin = (userConfig = {}) => {
58
61
  },
59
62
  reporter
60
63
  }));
61
- const runner = api.useHookRunners();
62
64
  routes = runner.modifyRoutes(routes);
63
65
  const { query } = createStaticHandler(routes, {
64
66
  basename: _basename
@@ -1,3 +1,5 @@
1
1
  import type { RouteObject } from '@modern-js/runtime-utils/router';
2
+ import type { RuntimeContext } from '../../core';
2
3
  declare const modifyRoutes: import("@modern-js/plugin").Waterfall<RouteObject[]>;
3
- export { modifyRoutes };
4
+ declare const beforeCreateRoutes: import("@modern-js/plugin").AsyncInterruptWorkflow<RuntimeContext, void>;
5
+ export { modifyRoutes, beforeCreateRoutes };
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.60.4",
18
+ "version": "2.60.5-alpha.1",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -199,8 +199,8 @@
199
199
  "react-is": "^18",
200
200
  "react-side-effect": "^2.1.1",
201
201
  "styled-components": "^5.3.1",
202
- "@modern-js/plugin": "2.60.4",
203
202
  "@modern-js/plugin-data-loader": "2.60.4",
203
+ "@modern-js/plugin": "2.60.4",
204
204
  "@modern-js/runtime-utils": "2.60.4",
205
205
  "@modern-js/types": "2.60.4",
206
206
  "@modern-js/utils": "2.60.4"
@@ -221,8 +221,8 @@
221
221
  "@types/node": "^14",
222
222
  "@types/react-side-effect": "^1.1.1",
223
223
  "jest": "^29",
224
- "react": "^18",
225
- "react-dom": "^18",
224
+ "react": "^18.3.1",
225
+ "react-dom": "^18.3.1",
226
226
  "ts-jest": "^29.1.0",
227
227
  "typescript": "^5",
228
228
  "webpack": "^5.95.0",
@@ -234,8 +234,7 @@
234
234
  "sideEffects": false,
235
235
  "publishConfig": {
236
236
  "registry": "https://registry.npmjs.org/",
237
- "access": "public",
238
- "provenance": true
237
+ "access": "public"
239
238
  },
240
239
  "scripts": {
241
240
  "dev": "modern-lib build --watch",