@modern-js/runtime-utils 0.0.0-nightly-20230918160602 → 2.35.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.
- package/dist/cjs/browser/nestedRoutes.js +6 -11
- package/dist/cjs/browser/parsed.js +1 -2
- package/dist/esm/browser/nestedRoutes.js +7 -12
- package/dist/esm/browser/parsed.js +1 -2
- package/dist/esm-node/browser/nestedRoutes.js +6 -11
- package/dist/esm-node/browser/parsed.js +1 -2
- package/package.json +5 -5
|
@@ -34,7 +34,6 @@ const transformNestedRoutes = (routes, reporter) => {
|
|
|
34
34
|
return (0, _reactrouterdom.createRoutesFromElements)(routeElements);
|
|
35
35
|
};
|
|
36
36
|
const renderNestedRoute = (nestedRoute, options = {}) => {
|
|
37
|
-
var _config, _children;
|
|
38
37
|
const { children, index, id, component, isRoot, lazyImport, config, handle } = nestedRoute;
|
|
39
38
|
const Component = component;
|
|
40
39
|
const { parent, DeferredDataComponent, props = {}, reporter } = options;
|
|
@@ -48,7 +47,7 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
|
|
|
48
47
|
shouldRevalidate: nestedRoute.shouldRevalidate,
|
|
49
48
|
handle: {
|
|
50
49
|
...handle,
|
|
51
|
-
...typeof config === "object" ?
|
|
50
|
+
...typeof config === "object" ? config === null || config === void 0 ? void 0 : config.handle : {}
|
|
52
51
|
},
|
|
53
52
|
index: nestedRoute.index,
|
|
54
53
|
element: nestedRoute.element,
|
|
@@ -60,8 +59,7 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
|
|
|
60
59
|
}
|
|
61
60
|
let element;
|
|
62
61
|
if (Component) {
|
|
63
|
-
|
|
64
|
-
if (((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.loading) && lazyImport) {
|
|
62
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.loading) && lazyImport) {
|
|
65
63
|
const Loading = parent.loading;
|
|
66
64
|
if (isLoadableComponent(Component)) {
|
|
67
65
|
element = /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {
|
|
@@ -76,14 +74,13 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
|
|
|
76
74
|
} else if (isLoadableComponent(Component) && lazyImport) {
|
|
77
75
|
element = /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {});
|
|
78
76
|
} else if (isRoot) {
|
|
79
|
-
var _props;
|
|
80
77
|
element = /* @__PURE__ */ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
81
78
|
children: [
|
|
82
79
|
/* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {
|
|
83
80
|
...props
|
|
84
81
|
}),
|
|
85
82
|
typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, _jsxruntime.jsx)(DeferredDataComponent, {
|
|
86
|
-
nonce:
|
|
83
|
+
nonce: props === null || props === void 0 ? void 0 : props.nonce
|
|
87
84
|
})
|
|
88
85
|
]
|
|
89
86
|
});
|
|
@@ -96,14 +93,13 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
|
|
|
96
93
|
element = /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {});
|
|
97
94
|
}
|
|
98
95
|
} else {
|
|
99
|
-
|
|
100
|
-
nestedRoute.loading = (_parent1 = parent) === null || _parent1 === void 0 ? void 0 : _parent1.loading;
|
|
96
|
+
nestedRoute.loading = parent === null || parent === void 0 ? void 0 : parent.loading;
|
|
101
97
|
routeProps.element = /* @__PURE__ */ (0, _jsxruntime.jsx)(_reactrouterdom.Outlet, {});
|
|
102
98
|
}
|
|
103
99
|
if (element) {
|
|
104
100
|
routeProps.element = element;
|
|
105
101
|
}
|
|
106
|
-
const childElements =
|
|
102
|
+
const childElements = children === null || children === void 0 ? void 0 : children.map((childRoute) => {
|
|
107
103
|
return renderNestedRoute(childRoute, {
|
|
108
104
|
parent: nestedRoute,
|
|
109
105
|
reporter
|
|
@@ -130,8 +126,7 @@ function createLoader(route, reporter) {
|
|
|
130
126
|
const res = await loader(args);
|
|
131
127
|
const cost = end();
|
|
132
128
|
if (typeof document === "undefined" && reporter) {
|
|
133
|
-
|
|
134
|
-
(_reporter = reporter) === null || _reporter === void 0 ? void 0 : _reporter.reportTiming(`${_constants.LOADER_REPORTER_NAME}-${route.id}`, cost);
|
|
129
|
+
reporter === null || reporter === void 0 ? void 0 : reporter.reportTiming(`${_constants.LOADER_REPORTER_NAME}-${route.id}`, cost);
|
|
135
130
|
}
|
|
136
131
|
return res;
|
|
137
132
|
};
|
|
@@ -16,8 +16,7 @@ const parsedJSONFromElement = (id) => {
|
|
|
16
16
|
const element = elements[elements.length - 1];
|
|
17
17
|
if (element) {
|
|
18
18
|
try {
|
|
19
|
-
|
|
20
|
-
const parsed = JSON.parse(((_element = element) === null || _element === void 0 ? void 0 : _element.textContent) || "");
|
|
19
|
+
const parsed = JSON.parse((element === null || element === void 0 ? void 0 : element.textContent) || "");
|
|
21
20
|
return parsed;
|
|
22
21
|
} catch (e) {
|
|
23
22
|
console.error(`parse ${id} error`, e);
|
|
@@ -36,7 +36,6 @@ export var transformNestedRoutes = function(routes, reporter) {
|
|
|
36
36
|
};
|
|
37
37
|
export 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 @@ export 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" ?
|
|
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 @@ export var renderNestedRoute = function(nestedRoute) {
|
|
|
59
58
|
}
|
|
60
59
|
var element;
|
|
61
60
|
if (Component) {
|
|
62
|
-
|
|
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 @@ export 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:
|
|
80
|
+
nonce: props === null || props === void 0 ? void 0 : props.nonce
|
|
84
81
|
})
|
|
85
82
|
]
|
|
86
83
|
});
|
|
@@ -93,14 +90,13 @@ export var renderNestedRoute = function(nestedRoute) {
|
|
|
93
90
|
element = /* @__PURE__ */ _jsx(Component, {});
|
|
94
91
|
}
|
|
95
92
|
} else {
|
|
96
|
-
|
|
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 =
|
|
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: 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
|
|
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 @@ export var parsedJSONFromElement = function(id) {
|
|
|
6
6
|
var element = elements[elements.length - 1];
|
|
7
7
|
if (element) {
|
|
8
8
|
try {
|
|
9
|
-
var
|
|
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 @@ export const transformNestedRoutes = (routes, reporter) => {
|
|
|
14
14
|
return createRoutesFromElements(routeElements);
|
|
15
15
|
};
|
|
16
16
|
export 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 @@ export const renderNestedRoute = (nestedRoute, options = {}) => {
|
|
|
28
27
|
shouldRevalidate: nestedRoute.shouldRevalidate,
|
|
29
28
|
handle: {
|
|
30
29
|
...handle,
|
|
31
|
-
...typeof config === "object" ?
|
|
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 @@ export const renderNestedRoute = (nestedRoute, options = {}) => {
|
|
|
40
39
|
}
|
|
41
40
|
let element;
|
|
42
41
|
if (Component) {
|
|
43
|
-
|
|
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 @@ export 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:
|
|
63
|
+
nonce: props === null || props === void 0 ? void 0 : props.nonce
|
|
67
64
|
})
|
|
68
65
|
]
|
|
69
66
|
});
|
|
@@ -76,14 +73,13 @@ export const renderNestedRoute = (nestedRoute, options = {}) => {
|
|
|
76
73
|
element = /* @__PURE__ */ _jsx(Component, {});
|
|
77
74
|
}
|
|
78
75
|
} else {
|
|
79
|
-
|
|
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 =
|
|
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
|
-
|
|
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 @@ export const parsedJSONFromElement = (id) => {
|
|
|
6
6
|
const element = elements[elements.length - 1];
|
|
7
7
|
if (element) {
|
|
8
8
|
try {
|
|
9
|
-
|
|
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": "
|
|
18
|
+
"version": "2.35.1",
|
|
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": "
|
|
84
|
+
"@modern-js/utils": "2.35.1"
|
|
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": "
|
|
107
|
-
"@scripts/
|
|
108
|
-
"@scripts/
|
|
106
|
+
"@modern-js/types": "2.35.1",
|
|
107
|
+
"@scripts/jest-config": "2.35.1",
|
|
108
|
+
"@scripts/build": "2.35.1"
|
|
109
109
|
},
|
|
110
110
|
"sideEffects": false,
|
|
111
111
|
"scripts": {
|