@modern-js/runtime-utils 0.0.0-nightly-20230926160605 → 0.0.0-nightly-20230928160554

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.
@@ -38,7 +38,6 @@ const transformNestedRoutes = (routes, reporter) => {
38
38
  return (0, import_react_router_dom.createRoutesFromElements)(routeElements);
39
39
  };
40
40
  const renderNestedRoute = (nestedRoute, options = {}) => {
41
- var _config, _children;
42
41
  const { children, index, id, component, isRoot, lazyImport, config, handle } = nestedRoute;
43
42
  const Component = component;
44
43
  const { parent, DeferredDataComponent, props = {}, reporter } = options;
@@ -52,7 +51,7 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
52
51
  shouldRevalidate: nestedRoute.shouldRevalidate,
53
52
  handle: {
54
53
  ...handle,
55
- ...typeof config === "object" ? (_config = config) === null || _config === void 0 ? void 0 : _config.handle : {}
54
+ ...typeof config === "object" ? config === null || config === void 0 ? void 0 : config.handle : {}
56
55
  },
57
56
  index: nestedRoute.index,
58
57
  element: nestedRoute.element,
@@ -64,8 +63,7 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
64
63
  }
65
64
  let element;
66
65
  if (Component) {
67
- var _parent;
68
- if (((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.loading) && lazyImport) {
66
+ if ((parent === null || parent === void 0 ? void 0 : parent.loading) && lazyImport) {
69
67
  const Loading = parent.loading;
70
68
  if (isLoadableComponent(Component)) {
71
69
  element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
@@ -80,14 +78,13 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
80
78
  } else if (isLoadableComponent(Component) && lazyImport) {
81
79
  element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
82
80
  } else if (isRoot) {
83
- var _props;
84
81
  element = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
85
82
  children: [
86
83
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
87
84
  ...props
88
85
  }),
89
86
  typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeferredDataComponent, {
90
- nonce: (_props = props) === null || _props === void 0 ? void 0 : _props.nonce
87
+ nonce: props === null || props === void 0 ? void 0 : props.nonce
91
88
  })
92
89
  ]
93
90
  });
@@ -100,14 +97,13 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
100
97
  element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
101
98
  }
102
99
  } else {
103
- var _parent1;
104
- nestedRoute.loading = (_parent1 = parent) === null || _parent1 === void 0 ? void 0 : _parent1.loading;
100
+ nestedRoute.loading = parent === null || parent === void 0 ? void 0 : parent.loading;
105
101
  routeProps.element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Outlet, {});
106
102
  }
107
103
  if (element) {
108
104
  routeProps.element = element;
109
105
  }
110
- const childElements = (_children = children) === null || _children === void 0 ? void 0 : _children.map((childRoute) => {
106
+ const childElements = children === null || children === void 0 ? void 0 : children.map((childRoute) => {
111
107
  return renderNestedRoute(childRoute, {
112
108
  parent: nestedRoute,
113
109
  reporter
@@ -134,8 +130,7 @@ function createLoader(route, reporter) {
134
130
  const res = await loader(args);
135
131
  const cost = end();
136
132
  if (typeof document === "undefined" && reporter) {
137
- var _reporter;
138
- (_reporter = reporter) === null || _reporter === void 0 ? void 0 : _reporter.reportTiming(`${import_constants.LOADER_REPORTER_NAME}-${route.id}`, cost);
133
+ reporter === null || reporter === void 0 ? void 0 : reporter.reportTiming(`${import_constants.LOADER_REPORTER_NAME}-${route.id}`, cost);
139
134
  }
140
135
  return res;
141
136
  };
@@ -29,8 +29,7 @@ const parsedJSONFromElement = (id) => {
29
29
  const element = elements[elements.length - 1];
30
30
  if (element) {
31
31
  try {
32
- var _element;
33
- const parsed = JSON.parse(((_element = element) === null || _element === void 0 ? void 0 : _element.textContent) || "");
32
+ const parsed = JSON.parse((element === null || element === void 0 ? void 0 : element.textContent) || "");
34
33
  return parsed;
35
34
  } catch (e) {
36
35
  console.error(`parse ${id} error`, e);
@@ -36,7 +36,6 @@ var transformNestedRoutes = function(routes, reporter) {
36
36
  };
37
37
  var renderNestedRoute = function(nestedRoute) {
38
38
  var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
39
- var _config, _children;
40
39
  var children = nestedRoute.children, index = nestedRoute.index, id = nestedRoute.id, component = nestedRoute.component, isRoot = nestedRoute.isRoot, lazyImport = nestedRoute.lazyImport, config = nestedRoute.config, handle = nestedRoute.handle;
41
40
  var Component = component;
42
41
  var parent = options.parent, DeferredDataComponent = options.DeferredDataComponent, _options_props = options.props, props = _options_props === void 0 ? {} : _options_props, reporter = options.reporter;
@@ -48,7 +47,7 @@ var renderNestedRoute = function(nestedRoute) {
48
47
  action: nestedRoute.action,
49
48
  hasErrorBoundary: nestedRoute.hasErrorBoundary,
50
49
  shouldRevalidate: nestedRoute.shouldRevalidate,
51
- handle: _object_spread({}, handle, typeof config === "object" ? (_config = config) === null || _config === void 0 ? void 0 : _config.handle : {}),
50
+ handle: _object_spread({}, handle, typeof config === "object" ? config === null || config === void 0 ? void 0 : config.handle : {}),
52
51
  index: nestedRoute.index,
53
52
  element: nestedRoute.element,
54
53
  errorElement: nestedRoute.errorElement
@@ -59,8 +58,7 @@ var renderNestedRoute = function(nestedRoute) {
59
58
  }
60
59
  var element;
61
60
  if (Component) {
62
- var _parent;
63
- if (((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.loading) && lazyImport) {
61
+ if ((parent === null || parent === void 0 ? void 0 : parent.loading) && lazyImport) {
64
62
  var Loading = parent.loading;
65
63
  if (isLoadableComponent(Component)) {
66
64
  element = /* @__PURE__ */ _jsx(Component, {
@@ -75,12 +73,11 @@ var renderNestedRoute = function(nestedRoute) {
75
73
  } else if (isLoadableComponent(Component) && lazyImport) {
76
74
  element = /* @__PURE__ */ _jsx(Component, {});
77
75
  } else if (isRoot) {
78
- var _props;
79
76
  element = /* @__PURE__ */ _jsxs(_Fragment, {
80
77
  children: [
81
78
  /* @__PURE__ */ _jsx(Component, _object_spread({}, props)),
82
79
  typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ _jsx(DeferredDataComponent, {
83
- nonce: (_props = props) === null || _props === void 0 ? void 0 : _props.nonce
80
+ nonce: props === null || props === void 0 ? void 0 : props.nonce
84
81
  })
85
82
  ]
86
83
  });
@@ -93,14 +90,13 @@ var renderNestedRoute = function(nestedRoute) {
93
90
  element = /* @__PURE__ */ _jsx(Component, {});
94
91
  }
95
92
  } else {
96
- var _parent1;
97
- nestedRoute.loading = (_parent1 = parent) === null || _parent1 === void 0 ? void 0 : _parent1.loading;
93
+ nestedRoute.loading = parent === null || parent === void 0 ? void 0 : parent.loading;
98
94
  routeProps.element = /* @__PURE__ */ _jsx(Outlet, {});
99
95
  }
100
96
  if (element) {
101
97
  routeProps.element = element;
102
98
  }
103
- var childElements = (_children = children) === null || _children === void 0 ? void 0 : _children.map(function(childRoute) {
99
+ var childElements = children === null || children === void 0 ? void 0 : children.map(function(childRoute) {
104
100
  return renderNestedRoute(childRoute, {
105
101
  parent: nestedRoute,
106
102
  reporter
@@ -119,7 +115,7 @@ function createLoader(route, reporter) {
119
115
  if (loader) {
120
116
  return function() {
121
117
  var _ref = _async_to_generator(function(args) {
122
- var end, res, cost, _reporter;
118
+ var end, res, cost;
123
119
  return _ts_generator(this, function(_state) {
124
120
  switch (_state.label) {
125
121
  case 0:
@@ -135,8 +131,7 @@ function createLoader(route, reporter) {
135
131
  res = _state.sent();
136
132
  cost = end();
137
133
  if (typeof document === "undefined" && reporter) {
138
- ;
139
- (_reporter = reporter) === null || _reporter === void 0 ? void 0 : _reporter.reportTiming("".concat(LOADER_REPORTER_NAME, "-").concat(route.id), cost);
134
+ reporter === null || reporter === void 0 ? void 0 : reporter.reportTiming("".concat(LOADER_REPORTER_NAME, "-").concat(route.id), cost);
140
135
  }
141
136
  return [
142
137
  2,
@@ -6,8 +6,7 @@ var parsedJSONFromElement = function(id) {
6
6
  var element = elements[elements.length - 1];
7
7
  if (element) {
8
8
  try {
9
- var _element;
10
- var parsed = JSON.parse(((_element = element) === null || _element === void 0 ? void 0 : _element.textContent) || "");
9
+ var parsed = JSON.parse((element === null || element === void 0 ? void 0 : element.textContent) || "");
11
10
  return parsed;
12
11
  } catch (e) {
13
12
  console.error("parse ".concat(id, " error"), e);
@@ -14,7 +14,6 @@ const transformNestedRoutes = (routes, reporter) => {
14
14
  return createRoutesFromElements(routeElements);
15
15
  };
16
16
  const renderNestedRoute = (nestedRoute, options = {}) => {
17
- var _config, _children;
18
17
  const { children, index, id, component, isRoot, lazyImport, config, handle } = nestedRoute;
19
18
  const Component = component;
20
19
  const { parent, DeferredDataComponent, props = {}, reporter } = options;
@@ -28,7 +27,7 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
28
27
  shouldRevalidate: nestedRoute.shouldRevalidate,
29
28
  handle: {
30
29
  ...handle,
31
- ...typeof config === "object" ? (_config = config) === null || _config === void 0 ? void 0 : _config.handle : {}
30
+ ...typeof config === "object" ? config === null || config === void 0 ? void 0 : config.handle : {}
32
31
  },
33
32
  index: nestedRoute.index,
34
33
  element: nestedRoute.element,
@@ -40,8 +39,7 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
40
39
  }
41
40
  let element;
42
41
  if (Component) {
43
- var _parent;
44
- if (((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.loading) && lazyImport) {
42
+ if ((parent === null || parent === void 0 ? void 0 : parent.loading) && lazyImport) {
45
43
  const Loading = parent.loading;
46
44
  if (isLoadableComponent(Component)) {
47
45
  element = /* @__PURE__ */ _jsx(Component, {
@@ -56,14 +54,13 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
56
54
  } else if (isLoadableComponent(Component) && lazyImport) {
57
55
  element = /* @__PURE__ */ _jsx(Component, {});
58
56
  } else if (isRoot) {
59
- var _props;
60
57
  element = /* @__PURE__ */ _jsxs(_Fragment, {
61
58
  children: [
62
59
  /* @__PURE__ */ _jsx(Component, {
63
60
  ...props
64
61
  }),
65
62
  typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ _jsx(DeferredDataComponent, {
66
- nonce: (_props = props) === null || _props === void 0 ? void 0 : _props.nonce
63
+ nonce: props === null || props === void 0 ? void 0 : props.nonce
67
64
  })
68
65
  ]
69
66
  });
@@ -76,14 +73,13 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
76
73
  element = /* @__PURE__ */ _jsx(Component, {});
77
74
  }
78
75
  } else {
79
- var _parent1;
80
- nestedRoute.loading = (_parent1 = parent) === null || _parent1 === void 0 ? void 0 : _parent1.loading;
76
+ nestedRoute.loading = parent === null || parent === void 0 ? void 0 : parent.loading;
81
77
  routeProps.element = /* @__PURE__ */ _jsx(Outlet, {});
82
78
  }
83
79
  if (element) {
84
80
  routeProps.element = element;
85
81
  }
86
- const childElements = (_children = children) === null || _children === void 0 ? void 0 : _children.map((childRoute) => {
82
+ const childElements = children === null || children === void 0 ? void 0 : children.map((childRoute) => {
87
83
  return renderNestedRoute(childRoute, {
88
84
  parent: nestedRoute,
89
85
  reporter
@@ -110,8 +106,7 @@ function createLoader(route, reporter) {
110
106
  const res = await loader(args);
111
107
  const cost = end();
112
108
  if (typeof document === "undefined" && reporter) {
113
- var _reporter;
114
- (_reporter = reporter) === null || _reporter === void 0 ? void 0 : _reporter.reportTiming(`${LOADER_REPORTER_NAME}-${route.id}`, cost);
109
+ reporter === null || reporter === void 0 ? void 0 : reporter.reportTiming(`${LOADER_REPORTER_NAME}-${route.id}`, cost);
115
110
  }
116
111
  return res;
117
112
  };
@@ -6,8 +6,7 @@ const parsedJSONFromElement = (id) => {
6
6
  const element = elements[elements.length - 1];
7
7
  if (element) {
8
8
  try {
9
- var _element;
10
- const parsed = JSON.parse(((_element = element) === null || _element === void 0 ? void 0 : _element.textContent) || "");
9
+ const parsed = JSON.parse((element === null || element === void 0 ? void 0 : element.textContent) || "");
11
10
  return parsed;
12
11
  } catch (e) {
13
12
  console.error(`parse ${id} error`, e);
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-nightly-20230926160605",
18
+ "version": "0.0.0-nightly-20230928160554",
19
19
  "_comment": "Provide ESM and CJS exports, ESM is used by runtime package, for treeshaking",
20
20
  "exports": {
21
21
  "./router": {
@@ -81,7 +81,7 @@
81
81
  "react-router-dom": "6.15.0",
82
82
  "@remix-run/router": "1.8.0",
83
83
  "@swc/helpers": "0.5.1",
84
- "@modern-js/utils": "0.0.0-nightly-20230926160605"
84
+ "@modern-js/utils": "0.0.0-nightly-20230928160554"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "react": ">=17.0.0",
@@ -103,9 +103,9 @@
103
103
  "jest": "^29",
104
104
  "typescript": "^5",
105
105
  "@types/serialize-javascript": "^5.0.1",
106
- "@modern-js/types": "0.0.0-nightly-20230926160605",
107
- "@scripts/build": "0.0.0-nightly-20230926160605",
108
- "@scripts/jest-config": "0.0.0-nightly-20230926160605"
106
+ "@modern-js/types": "0.0.0-nightly-20230928160554",
107
+ "@scripts/build": "0.0.0-nightly-20230928160554",
108
+ "@scripts/jest-config": "0.0.0-nightly-20230928160554"
109
109
  },
110
110
  "sideEffects": false,
111
111
  "scripts": {