@modern-js/plugin-router-v5 2.14.0 → 2.16.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @modern-js/plugin-router-v5
2
2
 
3
+ ## 2.16.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 4e876ab: chore: package.json include the monorepo-relative directory
8
+
9
+ chore: 在 package.json 中声明 monorepo 的子路径
10
+
11
+ - Updated dependencies [5954330]
12
+ - Updated dependencies [7596520]
13
+ - Updated dependencies [4e876ab]
14
+ - @modern-js/utils@2.16.0
15
+ - @modern-js/types@2.16.0
16
+
17
+ ## 2.15.0
18
+
19
+ ### Patch Changes
20
+
21
+ - 09a3e57: chore(runtime): remove unused @testing-library/react-hooks
22
+
23
+ chore(runtime): 移除多余的 @testing-library/react-hooks
24
+
25
+ - @modern-js/types@2.15.0
26
+ - @modern-js/utils@2.15.0
27
+
3
28
  ## 2.14.0
4
29
 
5
30
  ### Patch Changes
@@ -1,122 +1,94 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var cli_exports = {};
19
- __export(cli_exports, {
20
- default: () => cli_default
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: () => _default
21
8
  });
22
- module.exports = __toCommonJS(cli_exports);
23
- var import_utils = require("@modern-js/utils");
24
- var import_types2 = require("./types");
9
+ const _utils = require("@modern-js/utils");
10
+ require("./types");
25
11
  const PLUGIN_IDENTIFIER = "router";
26
12
  const ROUTES_IDENTIFIER = "routes";
27
- var cli_default = () => ({
28
- name: "@modern-js/plugin-router-v5",
29
- required: ["@modern-js/runtime"],
30
- setup: (api) => {
31
- const runtimeConfigMap = /* @__PURE__ */ new Map();
32
- let pluginsExportsUtils;
33
- let routerExportsUtils;
34
- return {
35
- config() {
36
- const appContext = api.useAppContext();
37
- pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
38
- appContext.internalDirectory,
39
- "plugins"
40
- );
41
- routerExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
42
- appContext.internalDirectory,
43
- "router"
44
- );
45
- return {
46
- source: {
47
- alias: {
48
- "@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
49
- "@modern-js/runtime/router-v5": routerExportsUtils.getPath()
13
+ const _default = () => {
14
+ return {
15
+ name: "@modern-js/plugin-router-v5",
16
+ required: [
17
+ "@modern-js/runtime"
18
+ ],
19
+ setup: (api) => {
20
+ const runtimeConfigMap = /* @__PURE__ */ new Map();
21
+ let pluginsExportsUtils;
22
+ let routerExportsUtils;
23
+ return {
24
+ config() {
25
+ const appContext = api.useAppContext();
26
+ pluginsExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, "plugins");
27
+ routerExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, "router");
28
+ return {
29
+ source: {
30
+ alias: {
31
+ "@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
32
+ "@modern-js/runtime/router-v5": routerExportsUtils.getPath()
33
+ }
50
34
  }
35
+ };
36
+ },
37
+ validateSchema() {
38
+ return _utils.PLUGIN_SCHEMAS["@modern-js/plugin-router"];
39
+ },
40
+ modifyEntryImports({ entrypoint, imports }) {
41
+ const { entryName } = entrypoint;
42
+ const userConfig = api.useResolvedConfigContext();
43
+ const { packageName } = api.useAppContext();
44
+ const runtimeConfig = (0, _utils.getEntryOptions)(entryName, userConfig.runtime, userConfig.runtimeByEntries, packageName);
45
+ runtimeConfigMap.set(entryName, runtimeConfig);
46
+ if ((0, _utils.isRouterV5)(userConfig)) {
47
+ imports.push({
48
+ value: "@modern-js/runtime/plugins",
49
+ specifiers: [
50
+ {
51
+ imported: PLUGIN_IDENTIFIER
52
+ }
53
+ ]
54
+ });
55
+ } else {
56
+ throw new Error(`should enable runtime.router.mode for entry ${entryName}`);
57
+ }
58
+ return {
59
+ entrypoint,
60
+ imports
61
+ };
62
+ },
63
+ modifyEntryRuntimePlugins({ entrypoint, plugins }) {
64
+ const { entryName, fileSystemRoutes } = entrypoint;
65
+ const { serverRoutes } = api.useAppContext();
66
+ const runtimeConfig = runtimeConfigMap.get(entryName);
67
+ const userConfig = api.useResolvedConfigContext();
68
+ if ((0, _utils.isRouterV5)(userConfig)) {
69
+ const serverBase = serverRoutes.filter((route) => route.entryName === entryName).map((route) => route.urlPath).sort((a, b) => a.length - b.length > 0 ? -1 : 1);
70
+ plugins.push({
71
+ name: PLUGIN_IDENTIFIER,
72
+ options: JSON.stringify({
73
+ serverBase,
74
+ ...runtimeConfig.router,
75
+ routesConfig: fileSystemRoutes ? `{ ${ROUTES_IDENTIFIER}, globalApp: App }` : void 0
76
+ }).replace(/"routesConfig"\s*:\s*"((\S|\s)+)"/g, '"routesConfig": $1,')
77
+ });
78
+ }
79
+ return {
80
+ entrypoint,
81
+ plugins
82
+ };
83
+ },
84
+ addRuntimeExports() {
85
+ const userConfig = api.useResolvedConfigContext();
86
+ if ((0, _utils.isRouterV5)(userConfig)) {
87
+ pluginsExportsUtils.addExport(`export { default as router } from '@modern-js/plugin-router-v5/runtime'`);
88
+ routerExportsUtils === null || routerExportsUtils === void 0 ? void 0 : routerExportsUtils.addExport(`export * from '@modern-js/plugin-router-v5/runtime'`);
51
89
  }
52
- };
53
- },
54
- validateSchema() {
55
- return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-router"];
56
- },
57
- modifyEntryImports({ entrypoint, imports }) {
58
- const { entryName } = entrypoint;
59
- const userConfig = api.useResolvedConfigContext();
60
- const { packageName } = api.useAppContext();
61
- const runtimeConfig = (0, import_utils.getEntryOptions)(
62
- entryName,
63
- userConfig.runtime,
64
- userConfig.runtimeByEntries,
65
- packageName
66
- );
67
- runtimeConfigMap.set(entryName, runtimeConfig);
68
- if ((0, import_utils.isRouterV5)(userConfig)) {
69
- imports.push({
70
- value: "@modern-js/runtime/plugins",
71
- specifiers: [{ imported: PLUGIN_IDENTIFIER }]
72
- });
73
- } else {
74
- throw new Error(
75
- `should enable runtime.router.mode for entry ${entryName}`
76
- );
77
- }
78
- return {
79
- entrypoint,
80
- imports
81
- };
82
- },
83
- modifyEntryRuntimePlugins({ entrypoint, plugins }) {
84
- const { entryName, fileSystemRoutes } = entrypoint;
85
- const { serverRoutes } = api.useAppContext();
86
- const runtimeConfig = runtimeConfigMap.get(entryName);
87
- const userConfig = api.useResolvedConfigContext();
88
- if ((0, import_utils.isRouterV5)(userConfig)) {
89
- const serverBase = serverRoutes.filter((route) => route.entryName === entryName).map((route) => route.urlPath).sort((a, b) => a.length - b.length > 0 ? -1 : 1);
90
- plugins.push({
91
- name: PLUGIN_IDENTIFIER,
92
- options: JSON.stringify({
93
- serverBase,
94
- ...runtimeConfig.router,
95
- routesConfig: fileSystemRoutes ? `{ ${ROUTES_IDENTIFIER}, globalApp: App }` : void 0
96
- }).replace(
97
- /"routesConfig"\s*:\s*"((\S|\s)+)"/g,
98
- '"routesConfig": $1,'
99
- )
100
- });
101
- }
102
- return {
103
- entrypoint,
104
- plugins
105
- };
106
- },
107
- addRuntimeExports() {
108
- const userConfig = api.useResolvedConfigContext();
109
- if ((0, import_utils.isRouterV5)(userConfig)) {
110
- pluginsExportsUtils.addExport(
111
- `export { default as router } from '@modern-js/plugin-router-v5/runtime'`
112
- );
113
- routerExportsUtils == null ? void 0 : routerExportsUtils.addExport(
114
- `export * from '@modern-js/plugin-router-v5/runtime'`
115
- );
116
90
  }
117
- }
118
- };
119
- }
120
- });
121
- // Annotate the CommonJS export names for ESM import in node:
122
- 0 && (module.exports = {});
91
+ };
92
+ }
93
+ };
94
+ };
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
package/dist/cjs/index.js CHANGED
@@ -1,37 +1,27 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var src_exports = {};
30
- __export(src_exports, {
31
- default: () => import_runtime.default
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
32
4
  });
33
- module.exports = __toCommonJS(src_exports);
34
- var import_runtime = __toESM(require("./runtime"));
35
- __reExport(src_exports, require("./runtime"), module.exports);
36
- // Annotate the CommonJS export names for ESM import in node:
37
- 0 && (module.exports = {});
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: () => _runtime.default
8
+ });
9
+ const _runtime = /* @__PURE__ */ _interop_require_default(_export_star(require("./runtime"), exports));
10
+ function _export_star(from, to) {
11
+ Object.keys(from).forEach(function(k) {
12
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
13
+ Object.defineProperty(to, k, {
14
+ enumerable: true,
15
+ get: function() {
16
+ return from[k];
17
+ }
18
+ });
19
+ }
20
+ });
21
+ return from;
22
+ }
23
+ function _interop_require_default(obj) {
24
+ return obj && obj.__esModule ? obj : {
25
+ default: obj
26
+ };
27
+ }
@@ -1,40 +1,25 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var DefaultNotFound_exports = {};
19
- __export(DefaultNotFound_exports, {
20
- DefaultNotFound: () => DefaultNotFound
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
21
4
  });
22
- module.exports = __toCommonJS(DefaultNotFound_exports);
23
- var import_jsx_runtime = require("react/jsx-runtime");
24
- const DefaultNotFound = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
25
- "div",
26
- {
27
- style: {
28
- margin: "150px auto",
29
- textAlign: "center",
30
- display: "flex",
31
- alignItems: "center",
32
- justifyContent: "center"
33
- },
34
- children: "404"
35
- }
36
- );
37
- // Annotate the CommonJS export names for ESM import in node:
38
- 0 && (module.exports = {
39
- DefaultNotFound
5
+ Object.defineProperty(exports, "DefaultNotFound", {
6
+ enumerable: true,
7
+ get: () => DefaultNotFound
8
+ });
9
+ const _jsxruntime = require("react/jsx-runtime");
10
+ const _react = /* @__PURE__ */ _interop_require_default(require("react"));
11
+ function _interop_require_default(obj) {
12
+ return obj && obj.__esModule ? obj : {
13
+ default: obj
14
+ };
15
+ }
16
+ const DefaultNotFound = () => /* @__PURE__ */ (0, _jsxruntime.jsx)("div", {
17
+ style: {
18
+ margin: "150px auto",
19
+ textAlign: "center",
20
+ display: "flex",
21
+ alignItems: "center",
22
+ justifyContent: "center"
23
+ },
24
+ children: "404"
40
25
  });
@@ -1,29 +1,25 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var runtime_exports = {};
20
- __export(runtime_exports, {
21
- default: () => runtime_default
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
22
4
  });
23
- module.exports = __toCommonJS(runtime_exports);
24
- var import_plugin = require("./plugin");
25
- __reExport(runtime_exports, require("react-router-dom"), module.exports);
26
- __reExport(runtime_exports, require("history"), module.exports);
27
- var runtime_default = import_plugin.routerPlugin;
28
- // Annotate the CommonJS export names for ESM import in node:
29
- 0 && (module.exports = {});
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: () => _default
8
+ });
9
+ const _plugin = require("./plugin");
10
+ _export_star(require("react-router-dom"), exports);
11
+ _export_star(require("history"), exports);
12
+ function _export_star(from, to) {
13
+ Object.keys(from).forEach(function(k) {
14
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
15
+ Object.defineProperty(to, k, {
16
+ enumerable: true,
17
+ get: function() {
18
+ return from[k];
19
+ }
20
+ });
21
+ }
22
+ });
23
+ return from;
24
+ }
25
+ const _default = _plugin.routerPlugin;
@@ -1,55 +1,69 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var plugin_exports = {};
29
- __export(plugin_exports, {
30
- routerPlugin: () => routerPlugin
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "routerPlugin", {
6
+ enumerable: true,
7
+ get: () => routerPlugin
31
8
  });
32
- module.exports = __toCommonJS(plugin_exports);
33
- var import_jsx_runtime = require("react/jsx-runtime");
34
- var import_react = require("react");
35
- var import_history = require("history");
36
- var import_react_router_dom = require("react-router-dom");
37
- var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
38
- var import_runtime = require("@modern-js/runtime");
39
- var import_runtime2 = require("@modern-js/utils/runtime");
40
- var import_utils = require("./utils");
41
- const routerPlugin = ({
42
- serverBase = [],
43
- history: customHistory,
44
- supportHtml5History = true,
45
- routesConfig,
46
- createRoutes,
47
- historyOptions = {}
48
- }) => {
49
- const isBrow = (0, import_runtime.isBrowser)();
9
+ const _jsxruntime = require("react/jsx-runtime");
10
+ const _react = /* @__PURE__ */ _interop_require_wildcard(require("react"));
11
+ const _history = require("history");
12
+ const _reactrouterdom = require("react-router-dom");
13
+ const _hoistnonreactstatics = /* @__PURE__ */ _interop_require_default(require("hoist-non-react-statics"));
14
+ const _runtime = require("@modern-js/runtime");
15
+ const _runtime1 = require("@modern-js/utils/runtime");
16
+ const _utils = require("./utils");
17
+ function _interop_require_default(obj) {
18
+ return obj && obj.__esModule ? obj : {
19
+ default: obj
20
+ };
21
+ }
22
+ function _getRequireWildcardCache(nodeInterop) {
23
+ if (typeof WeakMap !== "function")
24
+ return null;
25
+ var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
26
+ var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
27
+ return (_getRequireWildcardCache = function(nodeInterop2) {
28
+ return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
29
+ })(nodeInterop);
30
+ }
31
+ function _interop_require_wildcard(obj, nodeInterop) {
32
+ if (!nodeInterop && obj && obj.__esModule) {
33
+ return obj;
34
+ }
35
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
36
+ return {
37
+ default: obj
38
+ };
39
+ }
40
+ var cache = _getRequireWildcardCache(nodeInterop);
41
+ if (cache && cache.has(obj)) {
42
+ return cache.get(obj);
43
+ }
44
+ var newObj = {};
45
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
46
+ for (var key in obj) {
47
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
48
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
49
+ if (desc && (desc.get || desc.set)) {
50
+ Object.defineProperty(newObj, key, desc);
51
+ } else {
52
+ newObj[key] = obj[key];
53
+ }
54
+ }
55
+ }
56
+ newObj.default = obj;
57
+ if (cache) {
58
+ cache.set(obj, newObj);
59
+ }
60
+ return newObj;
61
+ }
62
+ const routerPlugin = ({ serverBase = [], history: customHistory, supportHtml5History = true, routesConfig, createRoutes, historyOptions = {} }) => {
63
+ const isBrow = (0, _runtime.isBrowser)();
50
64
  const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
51
65
  if (isBrow) {
52
- window._SERVER_DATA = (0, import_runtime2.parsedJSONFromElement)("__MODERN_SERVER_DATA__");
66
+ window._SERVER_DATA = (0, _runtime1.parsedJSONFromElement)("__MODERN_SERVER_DATA__");
53
67
  }
54
68
  return {
55
69
  name: "@modern-js/plugin-router",
@@ -57,46 +71,60 @@ const routerPlugin = ({
57
71
  return {
58
72
  init({ context }, next) {
59
73
  context.router = {
60
- useRouteMatch: import_react_router_dom.useRouteMatch,
61
- useLocation: import_react_router_dom.useLocation
74
+ useRouteMatch: _reactrouterdom.useRouteMatch,
75
+ useLocation: _reactrouterdom.useLocation
62
76
  };
63
- return next({ context });
77
+ return next({
78
+ context
79
+ });
64
80
  },
65
81
  hoc: ({ App }, next) => {
66
82
  const getRouteApp = () => {
67
- var _a;
68
83
  if (isBrow) {
69
- const baseUrl = ((_a = window._SERVER_DATA) == null ? void 0 : _a.router.baseUrl) || select(location.pathname);
70
- historyOptions.basename = baseUrl === "/" ? (0, import_utils.urlJoin)(baseUrl, historyOptions.basename) : baseUrl;
71
- const history = customHistory || (supportHtml5History ? (0, import_history.createBrowserHistory)(historyOptions) : (0, import_history.createHashHistory)(historyOptions));
72
- return (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Router, { history, children: createRoutes ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { ...props, Component: createRoutes() }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { ...props, children: (0, import_utils.renderRoutes)(routesConfig, props) }) });
84
+ var _window__SERVER_DATA;
85
+ const baseUrl = ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname);
86
+ historyOptions.basename = baseUrl === "/" ? (0, _utils.urlJoin)(baseUrl, historyOptions.basename) : baseUrl;
87
+ const history = customHistory || (supportHtml5History ? (0, _history.createBrowserHistory)(historyOptions) : (0, _history.createHashHistory)(historyOptions));
88
+ return (props) => /* @__PURE__ */ (0, _jsxruntime.jsx)(_reactrouterdom.Router, {
89
+ history,
90
+ children: createRoutes ? /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
91
+ ...props,
92
+ Component: createRoutes()
93
+ }) : /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
94
+ ...props,
95
+ children: (0, _utils.renderRoutes)(routesConfig, props)
96
+ })
97
+ });
73
98
  }
74
99
  return (props) => {
75
- const runtimeContext = (0, import_react.useContext)(import_runtime.RuntimeReactContext);
100
+ const runtimeContext = (0, _react.useContext)(_runtime.RuntimeReactContext);
76
101
  const { ssrContext } = runtimeContext;
77
- const location2 = (0, import_utils.getLocation)(ssrContext);
78
- const routerContext = (ssrContext == null ? void 0 : ssrContext.redirection) || {};
79
- const request = ssrContext == null ? void 0 : ssrContext.request;
80
- const baseUrl = request == null ? void 0 : request.baseUrl;
81
- const basename = baseUrl === "/" ? (0, import_utils.urlJoin)(baseUrl, historyOptions.basename) : baseUrl;
82
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
83
- import_react_router_dom.StaticRouter,
84
- {
85
- basename: basename === "/" ? "" : basename,
86
- location: location2,
87
- context: routerContext,
88
- children: createRoutes ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { ...props, Component: createRoutes() }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { ...props, children: (0, import_utils.renderRoutes)(routesConfig, props) })
89
- }
90
- );
102
+ const location1 = (0, _utils.getLocation)(ssrContext);
103
+ const routerContext = (ssrContext === null || ssrContext === void 0 ? void 0 : ssrContext.redirection) || {};
104
+ const request = ssrContext === null || ssrContext === void 0 ? void 0 : ssrContext.request;
105
+ const baseUrl = request === null || request === void 0 ? void 0 : request.baseUrl;
106
+ const basename = baseUrl === "/" ? (0, _utils.urlJoin)(baseUrl, historyOptions.basename) : baseUrl;
107
+ return /* @__PURE__ */ (0, _jsxruntime.jsx)(_reactrouterdom.StaticRouter, {
108
+ basename: basename === "/" ? "" : basename,
109
+ location: location1,
110
+ context: routerContext,
111
+ children: createRoutes ? /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
112
+ ...props,
113
+ Component: createRoutes()
114
+ }) : /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
115
+ ...props,
116
+ children: (0, _utils.renderRoutes)(routesConfig, props)
117
+ })
118
+ });
91
119
  };
92
120
  };
93
121
  let RouteApp = getRouteApp();
94
122
  if (App) {
95
- RouteApp = (0, import_hoist_non_react_statics.default)(RouteApp, App);
123
+ RouteApp = (0, _hoistnonreactstatics.default)(RouteApp, App);
96
124
  }
97
- if (routesConfig == null ? void 0 : routesConfig.globalApp) {
125
+ if (routesConfig === null || routesConfig === void 0 ? void 0 : routesConfig.globalApp) {
98
126
  return next({
99
- App: (0, import_hoist_non_react_statics.default)(RouteApp, routesConfig.globalApp)
127
+ App: (0, _hoistnonreactstatics.default)(RouteApp, routesConfig.globalApp)
100
128
  });
101
129
  }
102
130
  return next({
@@ -107,7 +135,3 @@ const routerPlugin = ({
107
135
  }
108
136
  };
109
137
  };
110
- // Annotate the CommonJS export names for ESM import in node:
111
- 0 && (module.exports = {
112
- routerPlugin
113
- });