@modern-js/plugin-router-v5 2.4.1-beta.0 → 2.5.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.
@@ -1,24 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
- var __spreadValues = (a, b) => {
11
- for (var prop in b || (b = {}))
12
- if (__hasOwnProp.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- if (__getOwnPropSymbols)
15
- for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop))
17
- __defNormalProp(a, prop, b[prop]);
18
- }
19
- return a;
20
- };
21
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
5
  var __export = (target, all) => {
23
6
  for (var name in all)
24
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -110,11 +93,11 @@ var cli_default = () => ({
110
93
  const serverBase = serverRoutes.filter((route) => route.entryName === entryName).map((route) => route.urlPath).sort((a, b) => a.length - b.length > 0 ? -1 : 1);
111
94
  plugins.push({
112
95
  name: PLUGIN_IDENTIFIER,
113
- options: JSON.stringify(__spreadProps(__spreadValues({
114
- serverBase
115
- }, runtimeConfig.router), {
96
+ options: JSON.stringify({
97
+ serverBase,
98
+ ...runtimeConfig.router,
116
99
  routesConfig: fileSystemRoutes ? `{ ${ROUTES_IDENTIFIER}, globalApp: App }` : void 0
117
- })).replace(
100
+ }).replace(
118
101
  /"routesConfig"\s*:\s*"((\S|\s)+)"/g,
119
102
  '"routesConfig": $1,'
120
103
  )
File without changes
File without changes
File without changes
File without changes
@@ -1,26 +1,9 @@
1
1
  var __create = Object.create;
2
2
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
5
  var __getProtoOf = Object.getPrototypeOf;
9
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
- var __spreadValues = (a, b) => {
13
- for (var prop in b || (b = {}))
14
- if (__hasOwnProp.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- if (__getOwnPropSymbols)
17
- for (var prop of __getOwnPropSymbols(b)) {
18
- if (__propIsEnum.call(b, prop))
19
- __defNormalProp(a, prop, b[prop]);
20
- }
21
- return a;
22
- };
23
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
7
  var __export = (target, all) => {
25
8
  for (var name in all)
26
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -80,9 +63,13 @@ const routerPlugin = ({
80
63
  const history = customHistory || (supportHtml5History ? (0, import_history.createBrowserHistory)(historyOptions) : (0, import_history.createHashHistory)(historyOptions));
81
64
  return (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Router, {
82
65
  history,
83
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadProps(__spreadValues({}, props), {
84
- children: createRoutes ? createRoutes() : (0, import_utils.renderRoutes)(routesConfig, props)
85
- }))
66
+ children: createRoutes ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
67
+ ...props,
68
+ Component: createRoutes()
69
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
70
+ ...props,
71
+ children: (0, import_utils.renderRoutes)(routesConfig, props)
72
+ })
86
73
  });
87
74
  }
88
75
  return (props) => {
@@ -97,9 +84,13 @@ const routerPlugin = ({
97
84
  basename: basename === "/" ? "" : basename,
98
85
  location: location2,
99
86
  context: routerContext,
100
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, __spreadProps(__spreadValues({}, props), {
101
- children: createRoutes ? createRoutes() : (0, import_utils.renderRoutes)(routesConfig, props)
102
- }))
87
+ children: createRoutes ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
88
+ ...props,
89
+ Component: createRoutes()
90
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
91
+ ...props,
92
+ children: (0, import_utils.renderRoutes)(routesConfig, props)
93
+ })
103
94
  });
104
95
  };
105
96
  };
@@ -1,33 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __objRest = (source, exclude) => {
20
- var target = {};
21
- for (var prop in source)
22
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
23
- target[prop] = source[prop];
24
- if (source != null && __getOwnPropSymbols)
25
- for (var prop of __getOwnPropSymbols(source)) {
26
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
27
- target[prop] = source[prop];
28
- }
29
- return target;
30
- };
31
5
  var __export = (target, all) => {
32
6
  for (var name in all)
33
7
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -56,15 +30,17 @@ function renderRoutes(routesConfig, extraProps = {}) {
56
30
  if (!routesConfig) {
57
31
  return null;
58
32
  }
59
- const Layout = (_a) => {
60
- var _b = _a, { Component } = _b, props = __objRest(_b, ["Component"]);
33
+ const Layout = ({ Component, ...props }) => {
61
34
  const GlobalLayout = routesConfig == null ? void 0 : routesConfig.globalApp;
62
35
  if (!GlobalLayout) {
63
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadValues({}, props));
36
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
37
+ ...props
38
+ });
64
39
  }
65
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlobalLayout, __spreadValues({
66
- Component
67
- }, props));
40
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GlobalLayout, {
41
+ Component,
42
+ ...props
43
+ });
68
44
  };
69
45
  const findMatchedRoute = (pathname) => {
70
46
  var _a;
@@ -88,9 +64,11 @@ function renderRoutes(routesConfig, extraProps = {}) {
88
64
  path: matchedRoute.path,
89
65
  exact: matchedRoute.exact,
90
66
  sensitive: matchedRoute.sensitive,
91
- render: (routeProps) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Layout, __spreadValues(__spreadValues({
92
- Component: matchedRoute.component
93
- }, routeProps), extraProps))
67
+ render: (routeProps) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Layout, {
68
+ Component: matchedRoute.component,
69
+ ...routeProps,
70
+ ...extraProps
71
+ })
94
72
  });
95
73
  }
96
74
  });
File without changes
File without changes
File without changes
File without changes
@@ -90,8 +90,10 @@ var routerPlugin = function(param) {
90
90
  return function(props) {
91
91
  return /* @__PURE__ */ jsx(Router, {
92
92
  history: history,
93
- children: /* @__PURE__ */ jsx(App, _objectSpreadProps(_objectSpread({}, props), {
94
- children: createRoutes ? createRoutes() : renderRoutes(routesConfig, props)
93
+ children: createRoutes ? /* @__PURE__ */ jsx(App, _objectSpreadProps(_objectSpread({}, props), {
94
+ Component: createRoutes()
95
+ })) : /* @__PURE__ */ jsx(App, _objectSpreadProps(_objectSpread({}, props), {
96
+ children: renderRoutes(routesConfig, props)
95
97
  }))
96
98
  });
97
99
  };
@@ -108,8 +110,10 @@ var routerPlugin = function(param) {
108
110
  basename: basename === "/" ? "" : basename,
109
111
  location: location2,
110
112
  context: routerContext,
111
- children: /* @__PURE__ */ jsx(App, _objectSpreadProps(_objectSpread({}, props), {
112
- children: createRoutes ? createRoutes() : renderRoutes(routesConfig, props)
113
+ children: createRoutes ? /* @__PURE__ */ jsx(App, _objectSpreadProps(_objectSpread({}, props), {
114
+ Component: createRoutes()
115
+ })) : /* @__PURE__ */ jsx(App, _objectSpreadProps(_objectSpread({}, props), {
116
+ children: renderRoutes(routesConfig, props)
113
117
  }))
114
118
  });
115
119
  };
File without changes
@@ -1,22 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
1
  import {
21
2
  getEntryOptions,
22
3
  createRuntimeExportsUtils,
@@ -94,11 +75,11 @@ var cli_default = () => ({
94
75
  const serverBase = serverRoutes.filter((route) => route.entryName === entryName).map((route) => route.urlPath).sort((a, b) => a.length - b.length > 0 ? -1 : 1);
95
76
  plugins.push({
96
77
  name: PLUGIN_IDENTIFIER,
97
- options: JSON.stringify(__spreadProps(__spreadValues({
98
- serverBase
99
- }, runtimeConfig.router), {
78
+ options: JSON.stringify({
79
+ serverBase,
80
+ ...runtimeConfig.router,
100
81
  routesConfig: fileSystemRoutes ? `{ ${ROUTES_IDENTIFIER}, globalApp: App }` : void 0
101
- })).replace(
82
+ }).replace(
102
83
  /"routesConfig"\s*:\s*"((\S|\s)+)"/g,
103
84
  '"routesConfig": $1,'
104
85
  )
File without changes
File without changes
File without changes
@@ -1,22 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
1
  import { jsx } from "react/jsx-runtime";
21
2
  import { useContext } from "react";
22
3
  import {
@@ -62,9 +43,13 @@ const routerPlugin = ({
62
43
  const history = customHistory || (supportHtml5History ? createBrowserHistory(historyOptions) : createHashHistory(historyOptions));
63
44
  return (props) => /* @__PURE__ */ jsx(Router, {
64
45
  history,
65
- children: /* @__PURE__ */ jsx(App, __spreadProps(__spreadValues({}, props), {
66
- children: createRoutes ? createRoutes() : renderRoutes(routesConfig, props)
67
- }))
46
+ children: createRoutes ? /* @__PURE__ */ jsx(App, {
47
+ ...props,
48
+ Component: createRoutes()
49
+ }) : /* @__PURE__ */ jsx(App, {
50
+ ...props,
51
+ children: renderRoutes(routesConfig, props)
52
+ })
68
53
  });
69
54
  }
70
55
  return (props) => {
@@ -79,9 +64,13 @@ const routerPlugin = ({
79
64
  basename: basename === "/" ? "" : basename,
80
65
  location: location2,
81
66
  context: routerContext,
82
- children: /* @__PURE__ */ jsx(App, __spreadProps(__spreadValues({}, props), {
83
- children: createRoutes ? createRoutes() : renderRoutes(routesConfig, props)
84
- }))
67
+ children: createRoutes ? /* @__PURE__ */ jsx(App, {
68
+ ...props,
69
+ Component: createRoutes()
70
+ }) : /* @__PURE__ */ jsx(App, {
71
+ ...props,
72
+ children: renderRoutes(routesConfig, props)
73
+ })
85
74
  });
86
75
  };
87
76
  };
@@ -1,31 +1,3 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
- var __objRest = (source, exclude) => {
18
- var target = {};
19
- for (var prop in source)
20
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
21
- target[prop] = source[prop];
22
- if (source != null && __getOwnPropSymbols)
23
- for (var prop of __getOwnPropSymbols(source)) {
24
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
25
- target[prop] = source[prop];
26
- }
27
- return target;
28
- };
29
1
  import { jsx } from "react/jsx-runtime";
30
2
  import { Route, matchPath } from "react-router-dom";
31
3
  import { DefaultNotFound } from "./DefaultNotFound";
@@ -33,15 +5,17 @@ function renderRoutes(routesConfig, extraProps = {}) {
33
5
  if (!routesConfig) {
34
6
  return null;
35
7
  }
36
- const Layout = (_a) => {
37
- var _b = _a, { Component } = _b, props = __objRest(_b, ["Component"]);
8
+ const Layout = ({ Component, ...props }) => {
38
9
  const GlobalLayout = routesConfig == null ? void 0 : routesConfig.globalApp;
39
10
  if (!GlobalLayout) {
40
- return /* @__PURE__ */ jsx(Component, __spreadValues({}, props));
11
+ return /* @__PURE__ */ jsx(Component, {
12
+ ...props
13
+ });
41
14
  }
42
- return /* @__PURE__ */ jsx(GlobalLayout, __spreadValues({
43
- Component
44
- }, props));
15
+ return /* @__PURE__ */ jsx(GlobalLayout, {
16
+ Component,
17
+ ...props
18
+ });
45
19
  };
46
20
  const findMatchedRoute = (pathname) => {
47
21
  var _a;
@@ -65,9 +39,11 @@ function renderRoutes(routesConfig, extraProps = {}) {
65
39
  path: matchedRoute.path,
66
40
  exact: matchedRoute.exact,
67
41
  sensitive: matchedRoute.sensitive,
68
- render: (routeProps) => /* @__PURE__ */ jsx(Layout, __spreadValues(__spreadValues({
69
- Component: matchedRoute.component
70
- }, routeProps), extraProps))
42
+ render: (routeProps) => /* @__PURE__ */ jsx(Layout, {
43
+ Component: matchedRoute.component,
44
+ ...routeProps,
45
+ ...extraProps
46
+ })
71
47
  });
72
48
  }
73
49
  });
@@ -40,7 +40,7 @@ export type RouterConfig = Partial<HistoryConfig> & {
40
40
  globalApp?: React.ComponentType<any>;
41
41
  routes?: SingleRouteConfig[];
42
42
  };
43
- createRoutes?: () => JSX.Element;
43
+ createRoutes?: () => React.ComponentType<any> | null;
44
44
  history?: History;
45
45
  serverBase?: string[];
46
46
  };
package/package.json CHANGED
@@ -11,24 +11,23 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.4.1-beta.0",
14
+ "version": "2.5.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/cli/index.d.ts",
17
- "main": "./dist/js/node/cli/index.js",
18
- "module": "./dist/js/treeshaking/index.js",
19
- "jsnext:modern": "./dist/js/modern/cli/index.js",
17
+ "main": "./dist/cjs/cli/index.js",
18
+ "module": "./dist/esm/index.js",
20
19
  "exports": {
21
20
  ".": {
22
21
  "jsnext:source": "./src/cli/index.ts",
23
- "default": "./dist/js/node/cli/index.js"
22
+ "default": "./dist/cjs/cli/index.js"
24
23
  },
25
24
  "./runtime": {
26
25
  "jsnext:source": "./src/runtime/index.ts",
27
- "default": "./dist/js/treeshaking/runtime/index.js"
26
+ "default": "./dist/esm/runtime/index.js"
28
27
  },
29
28
  "./cli": {
30
29
  "jsnext:source": "./src/cli/index.ts",
31
- "default": "./dist/js/node/cli/index.js"
30
+ "default": "./dist/cjs/cli/index.js"
32
31
  }
33
32
  },
34
33
  "typesVersions": {
@@ -53,8 +52,8 @@
53
52
  "hoist-non-react-statics": "^3.3.2",
54
53
  "@types/history": "^4.7.9",
55
54
  "@types/react-router-dom": "^5.1.8",
56
- "@modern-js/utils": "2.4.1-beta.0",
57
- "@modern-js/types": "2.4.0"
55
+ "@modern-js/utils": "2.5.0",
56
+ "@modern-js/types": "2.5.0"
58
57
  },
59
58
  "peerDependencies": {
60
59
  "react": ">=17",
@@ -73,12 +72,12 @@
73
72
  "@testing-library/react": "^13.4.0",
74
73
  "@testing-library/react-hooks": "^8.0.1",
75
74
  "@types/invariant": "^2.2.30",
76
- "@modern-js/runtime": "2.4.1-beta.0",
77
- "@modern-js/core": "2.4.1-beta.0",
78
- "@modern-js/utils": "2.4.1-beta.0",
79
- "@scripts/build": "2.4.0",
80
- "@modern-js/app-tools": "3.0.0-beta.0",
81
- "@scripts/jest-config": "2.4.0"
75
+ "@modern-js/runtime": "2.5.0",
76
+ "@modern-js/core": "2.5.0",
77
+ "@modern-js/utils": "2.5.0",
78
+ "@scripts/build": "2.5.0",
79
+ "@modern-js/app-tools": "2.5.0",
80
+ "@scripts/jest-config": "2.5.0"
82
81
  },
83
82
  "sideEffects": false,
84
83
  "modernConfig": {},