@modern-js/plugin-router-v5 2.29.0 → 2.29.1-alpha.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.
@@ -24,6 +24,7 @@ const routerPlugin = ({ serverBase = [], history: customHistory, supportHtml5His
24
24
  const originRoutes = ((_routesConfig = routesConfig) === null || _routesConfig === void 0 ? void 0 : _routesConfig.routes) || [];
25
25
  const isBrow = (0, _runtime.isBrowser)();
26
26
  const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
27
+ let routes = [];
27
28
  if (isBrow) {
28
29
  window._SERVER_DATA = (0, _runtimebrowser.parsedJSONFromElement)("__MODERN_SERVER_DATA__");
29
30
  }
@@ -39,6 +40,11 @@ const routerPlugin = ({ serverBase = [], history: customHistory, supportHtml5His
39
40
  useRouteMatch: _reactrouterdom.useRouteMatch,
40
41
  useLocation: _reactrouterdom.useLocation
41
42
  };
43
+ Object.defineProperty(context, "routes", {
44
+ get() {
45
+ return routes;
46
+ }
47
+ });
42
48
  return next({
43
49
  context
44
50
  });
@@ -53,7 +59,7 @@ const routerPlugin = ({ serverBase = [], history: customHistory, supportHtml5His
53
59
  const history = customHistory || (supportHtml5History ? (0, _history.createBrowserHistory)(historyOptions) : (0, _history.createHashHistory)(historyOptions));
54
60
  return (props) => {
55
61
  const runner = api.useHookRunners();
56
- const routes = runner.modifyRoutes(originRoutes);
62
+ routes = runner.modifyRoutes(originRoutes);
57
63
  routesConfig && (routesConfig.routes = routes);
58
64
  return /* @__PURE__ */ (0, _jsxruntime.jsx)(_reactrouterdom.Router, {
59
65
  history,
@@ -77,8 +83,8 @@ const routerPlugin = ({ serverBase = [], history: customHistory, supportHtml5His
77
83
  const baseUrl = (_request = request) === null || _request === void 0 ? void 0 : _request.baseUrl;
78
84
  const basename = baseUrl === "/" ? (0, _utils.urlJoin)(baseUrl, historyOptions.basename) : baseUrl;
79
85
  const runner = api.useHookRunners();
80
- const routes = runner.modifyRoutes(originRoutes);
81
- routesConfig && (routesConfig.routes = routes);
86
+ const routes2 = runner.modifyRoutes(originRoutes);
87
+ routesConfig && (routesConfig.routes = routes2);
82
88
  return /* @__PURE__ */ (0, _jsxruntime.jsx)(_reactrouterdom.StaticRouter, {
83
89
  basename: basename === "/" ? "" : basename,
84
90
  location: location1,
@@ -19,6 +19,7 @@ export var routerPlugin = function(param) {
19
19
  return pathname.search(baseUrl) === 0;
20
20
  }) || "/";
21
21
  };
22
+ var routes = [];
22
23
  if (isBrow) {
23
24
  window._SERVER_DATA = parsedJSONFromElement("__MODERN_SERVER_DATA__");
24
25
  }
@@ -35,6 +36,11 @@ export var routerPlugin = function(param) {
35
36
  useRouteMatch: useRouteMatch,
36
37
  useLocation: useLocation
37
38
  };
39
+ Object.defineProperty(context, "routes", {
40
+ get: function get() {
41
+ return routes;
42
+ }
43
+ });
38
44
  return next({
39
45
  context: context
40
46
  });
@@ -50,7 +56,7 @@ export var routerPlugin = function(param) {
50
56
  var history = customHistory || (supportHtml5History ? createBrowserHistory(historyOptions) : createHashHistory(historyOptions));
51
57
  return function(props) {
52
58
  var runner = api.useHookRunners();
53
- var routes = runner.modifyRoutes(originRoutes);
59
+ routes = runner.modifyRoutes(originRoutes);
54
60
  routesConfig && (routesConfig.routes = routes);
55
61
  return /* @__PURE__ */ _jsx(Router, {
56
62
  history: history,
@@ -72,8 +78,8 @@ export var routerPlugin = function(param) {
72
78
  var baseUrl2 = (_request = request) === null || _request === void 0 ? void 0 : _request.baseUrl;
73
79
  var basename = baseUrl2 === "/" ? urlJoin(baseUrl2, historyOptions.basename) : baseUrl2;
74
80
  var runner = api.useHookRunners();
75
- var routes = runner.modifyRoutes(originRoutes);
76
- routesConfig && (routesConfig.routes = routes);
81
+ var routes2 = runner.modifyRoutes(originRoutes);
82
+ routesConfig && (routesConfig.routes = routes2);
77
83
  return /* @__PURE__ */ _jsx(StaticRouter, {
78
84
  basename: basename === "/" ? "" : basename,
79
85
  location: _$location,
@@ -12,6 +12,7 @@ export const routerPlugin = ({ serverBase = [], history: customHistory, supportH
12
12
  const originRoutes = ((_routesConfig = routesConfig) === null || _routesConfig === void 0 ? void 0 : _routesConfig.routes) || [];
13
13
  const isBrow = isBrowser();
14
14
  const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
15
+ let routes = [];
15
16
  if (isBrow) {
16
17
  window._SERVER_DATA = parsedJSONFromElement("__MODERN_SERVER_DATA__");
17
18
  }
@@ -27,6 +28,11 @@ export const routerPlugin = ({ serverBase = [], history: customHistory, supportH
27
28
  useRouteMatch,
28
29
  useLocation
29
30
  };
31
+ Object.defineProperty(context, "routes", {
32
+ get() {
33
+ return routes;
34
+ }
35
+ });
30
36
  return next({
31
37
  context
32
38
  });
@@ -41,7 +47,7 @@ export const routerPlugin = ({ serverBase = [], history: customHistory, supportH
41
47
  const history = customHistory || (supportHtml5History ? createBrowserHistory(historyOptions) : createHashHistory(historyOptions));
42
48
  return (props) => {
43
49
  const runner = api.useHookRunners();
44
- const routes = runner.modifyRoutes(originRoutes);
50
+ routes = runner.modifyRoutes(originRoutes);
45
51
  routesConfig && (routesConfig.routes = routes);
46
52
  return /* @__PURE__ */ _jsx(Router, {
47
53
  history,
@@ -65,8 +71,8 @@ export const routerPlugin = ({ serverBase = [], history: customHistory, supportH
65
71
  const baseUrl = (_request = request) === null || _request === void 0 ? void 0 : _request.baseUrl;
66
72
  const basename = baseUrl === "/" ? urlJoin(baseUrl, historyOptions.basename) : baseUrl;
67
73
  const runner = api.useHookRunners();
68
- const routes = runner.modifyRoutes(originRoutes);
69
- routesConfig && (routesConfig.routes = routes);
74
+ const routes2 = runner.modifyRoutes(originRoutes);
75
+ routesConfig && (routesConfig.routes = routes2);
70
76
  return /* @__PURE__ */ _jsx(StaticRouter, {
71
77
  basename: basename === "/" ? "" : basename,
72
78
  location: location1,
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare const DefaultNotFound: () => JSX.Element;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.29.0",
18
+ "version": "2.29.1-alpha.0",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/cli/index.d.ts",
21
21
  "main": "./dist/cjs/cli/index.js",
@@ -60,8 +60,8 @@
60
60
  "hoist-non-react-statics": "^3.3.2",
61
61
  "react-router-dom": "^5.3.4",
62
62
  "@swc/helpers": "0.5.1",
63
- "@modern-js/plugin": "2.29.0",
64
63
  "@modern-js/types": "2.29.0",
64
+ "@modern-js/plugin": "2.29.0",
65
65
  "@modern-js/utils": "2.29.0"
66
66
  },
67
67
  "peerDependencies": {
@@ -79,11 +79,11 @@
79
79
  "ts-jest": "^29.1.0",
80
80
  "typescript": "^5",
81
81
  "@modern-js/app-tools": "2.29.0",
82
- "@modern-js/core": "2.29.0",
83
82
  "@modern-js/runtime": "2.29.0",
84
83
  "@modern-js/utils": "2.29.0",
85
84
  "@scripts/build": "2.29.0",
86
- "@scripts/jest-config": "2.29.0"
85
+ "@scripts/jest-config": "2.29.0",
86
+ "@modern-js/core": "2.29.0"
87
87
  },
88
88
  "sideEffects": false,
89
89
  "publishConfig": {