@modern-js/utils 2.35.0 → 2.36.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/cli/alias.js +48 -49
- package/dist/cjs/cli/applyOptionsChain.js +30 -13
- package/dist/cjs/cli/babel.js +36 -26
- package/dist/cjs/cli/commands.js +29 -21
- package/dist/cjs/cli/common.js +29 -20
- package/dist/cjs/cli/config.js +24 -7
- package/dist/cjs/cli/constants/chainId.js +27 -10
- package/dist/cjs/cli/constants/index.js +86 -104
- package/dist/cjs/cli/ensure.js +37 -18
- package/dist/cjs/cli/fs.js +29 -19
- package/dist/cjs/cli/get/config.js +26 -9
- package/dist/cjs/cli/get/data.js +67 -54
- package/dist/cjs/cli/get/index.js +46 -25
- package/dist/cjs/cli/index.js +58 -23
- package/dist/cjs/cli/is/config.js +45 -41
- package/dist/cjs/cli/is/env.js +32 -29
- package/dist/cjs/cli/is/index.js +26 -8
- package/dist/cjs/cli/is/project.js +67 -53
- package/dist/cjs/cli/is/type.js +39 -36
- package/dist/cjs/cli/logger.js +25 -125
- package/dist/cjs/cli/monorepo.js +58 -58
- package/dist/cjs/cli/package.js +34 -26
- package/dist/cjs/cli/path.js +64 -54
- package/dist/cjs/cli/port.js +39 -13
- package/dist/cjs/cli/prettyInstructions.js +50 -34
- package/dist/cjs/cli/require.js +36 -31
- package/dist/cjs/cli/runtimeExports.js +42 -16
- package/dist/cjs/cli/watch.js +41 -22
- package/dist/cjs/compiled.js +127 -138
- package/dist/cjs/import.js +25 -15
- package/dist/cjs/index.js +24 -6
- package/dist/cjs/universal/constants.js +29 -21
- package/dist/cjs/universal/formatWebpack.js +28 -18
- package/dist/cjs/universal/pluginDagSort.js +25 -8
- package/dist/esm/cli/alias.js +13 -25
- package/dist/esm/cli/applyOptionsChain.js +4 -1
- package/dist/esm/cli/babel.js +6 -2
- package/dist/esm/cli/commands.js +10 -4
- package/dist/esm/cli/common.js +8 -3
- package/dist/esm/cli/config.js +4 -1
- package/dist/esm/cli/constants/chainId.js +7 -4
- package/dist/esm/cli/constants/index.js +64 -31
- package/dist/esm/cli/ensure.js +6 -2
- package/dist/esm/cli/fs.js +6 -2
- package/dist/esm/cli/get/config.js +4 -1
- package/dist/esm/cli/get/data.js +18 -8
- package/dist/esm/cli/get/index.js +6 -2
- package/dist/esm/cli/is/config.js +23 -17
- package/dist/esm/cli/is/env.js +12 -8
- package/dist/esm/cli/is/index.js +0 -1
- package/dist/esm/cli/is/project.js +17 -8
- package/dist/esm/cli/is/type.js +20 -9
- package/dist/esm/cli/logger.js +4 -123
- package/dist/esm/cli/monorepo.js +14 -16
- package/dist/esm/cli/package.js +10 -4
- package/dist/esm/cli/path.js +24 -11
- package/dist/esm/cli/port.js +6 -3
- package/dist/esm/cli/prettyInstructions.js +8 -5
- package/dist/esm/cli/require.js +15 -8
- package/dist/esm/cli/runtimeExports.js +6 -3
- package/dist/esm/cli/watch.js +10 -6
- package/dist/esm/compiled.js +65 -31
- package/dist/esm/import.js +6 -3
- package/dist/esm/universal/constants.js +10 -4
- package/dist/esm/universal/formatWebpack.js +8 -5
- package/dist/esm/universal/pluginDagSort.js +5 -2
- package/dist/esm-node/cli/alias.js +11 -22
- package/dist/esm-node/cli/applyOptionsChain.js +4 -1
- package/dist/esm-node/cli/babel.js +6 -2
- package/dist/esm-node/cli/commands.js +10 -4
- package/dist/esm-node/cli/common.js +8 -3
- package/dist/esm-node/cli/config.js +4 -1
- package/dist/esm-node/cli/constants/chainId.js +7 -4
- package/dist/esm-node/cli/constants/index.js +64 -31
- package/dist/esm-node/cli/ensure.js +6 -2
- package/dist/esm-node/cli/fs.js +6 -2
- package/dist/esm-node/cli/get/config.js +4 -1
- package/dist/esm-node/cli/get/data.js +18 -8
- package/dist/esm-node/cli/get/index.js +6 -2
- package/dist/esm-node/cli/is/config.js +23 -17
- package/dist/esm-node/cli/is/env.js +12 -6
- package/dist/esm-node/cli/is/index.js +0 -1
- package/dist/esm-node/cli/is/project.js +16 -7
- package/dist/esm-node/cli/is/type.js +20 -9
- package/dist/esm-node/cli/logger.js +4 -108
- package/dist/esm-node/cli/monorepo.js +14 -18
- package/dist/esm-node/cli/package.js +10 -4
- package/dist/esm-node/cli/path.js +24 -11
- package/dist/esm-node/cli/port.js +5 -2
- package/dist/esm-node/cli/prettyInstructions.js +8 -7
- package/dist/esm-node/cli/require.js +15 -8
- package/dist/esm-node/cli/runtimeExports.js +4 -1
- package/dist/esm-node/cli/watch.js +6 -2
- package/dist/esm-node/compiled.js +65 -31
- package/dist/esm-node/import.js +5 -2
- package/dist/esm-node/universal/constants.js +10 -4
- package/dist/esm-node/universal/formatWebpack.js +8 -5
- package/dist/esm-node/universal/pluginDagSort.js +5 -2
- package/dist/types/cli/alias.d.ts +0 -5
- package/dist/types/cli/constants/chainId.d.ts +2 -2
- package/dist/types/cli/is/env.d.ts +1 -2
- package/dist/types/cli/is/index.d.ts +0 -1
- package/dist/types/cli/logger.d.ts +1 -64
- package/dist/types/cli/monorepo.d.ts +0 -1
- package/package.json +6 -84
- package/dist/cjs/cli/is/platform.js +0 -21
- package/dist/cjs/runtime/nestedRoutes.js +0 -149
- package/dist/cjs/runtime/remixRouter.js +0 -6
- package/dist/cjs/runtime/router.js +0 -6
- package/dist/cjs/runtime-browser/index.js +0 -6
- package/dist/cjs/runtime-browser/parsed.js +0 -28
- package/dist/cjs/runtime-node/index.js +0 -28
- package/dist/cjs/runtime-node/loaderContext/createLoaderCtx.js +0 -34
- package/dist/cjs/runtime-node/loaderContext/createRequestCtx.js +0 -38
- package/dist/cjs/runtime-node/loaderContext/index.js +0 -22
- package/dist/cjs/runtime-node/nestedRoutes.js +0 -28
- package/dist/cjs/runtime-node/router.js +0 -6
- package/dist/cjs/runtime-node/serialize.js +0 -17
- package/dist/cjs/runtime-node/storage.js +0 -48
- package/dist/cjs/universal/time.js +0 -38
- package/dist/compiled/gradient-string/index.d.ts +0 -1
- package/dist/compiled/gradient-string/index.js +0 -1
- package/dist/compiled/gradient-string/license +0 -21
- package/dist/compiled/gradient-string/package.json +0 -1
- package/dist/compiled/webpack-dev-middleware/index.js +0 -7
- package/dist/compiled/webpack-dev-middleware/license +0 -20
- package/dist/compiled/webpack-dev-middleware/package.json +0 -1
- package/dist/compiled/webpack-dev-middleware/types/index.d.ts +0 -262
- package/dist/esm/cli/is/platform.js +0 -6
- package/dist/esm/runtime/nestedRoutes.js +0 -163
- package/dist/esm/runtime/remixRouter.js +0 -1
- package/dist/esm/runtime/router.js +0 -1
- package/dist/esm/runtime-browser/index.js +0 -1
- package/dist/esm/runtime-browser/parsed.js +0 -18
- package/dist/esm/runtime-node/index.js +0 -6
- package/dist/esm/runtime-node/loaderContext/createLoaderCtx.js +0 -20
- package/dist/esm/runtime-node/loaderContext/createRequestCtx.js +0 -24
- package/dist/esm/runtime-node/loaderContext/index.js +0 -3
- package/dist/esm/runtime-node/nestedRoutes.js +0 -20
- package/dist/esm/runtime-node/router.js +0 -1
- package/dist/esm/runtime-node/serialize.js +0 -6
- package/dist/esm/runtime-node/storage.js +0 -36
- package/dist/esm/universal/time.js +0 -29
- package/dist/esm-node/cli/is/platform.js +0 -2
- package/dist/esm-node/runtime/nestedRoutes.js +0 -129
- package/dist/esm-node/runtime/remixRouter.js +0 -1
- package/dist/esm-node/runtime/router.js +0 -1
- package/dist/esm-node/runtime-browser/index.js +0 -1
- package/dist/esm-node/runtime-browser/parsed.js +0 -18
- package/dist/esm-node/runtime-node/index.js +0 -6
- package/dist/esm-node/runtime-node/loaderContext/createLoaderCtx.js +0 -15
- package/dist/esm-node/runtime-node/loaderContext/createRequestCtx.js +0 -19
- package/dist/esm-node/runtime-node/loaderContext/index.js +0 -3
- package/dist/esm-node/runtime-node/nestedRoutes.js +0 -18
- package/dist/esm-node/runtime-node/router.js +0 -1
- package/dist/esm-node/runtime-node/serialize.js +0 -6
- package/dist/esm-node/runtime-node/storage.js +0 -38
- package/dist/esm-node/universal/time.js +0 -28
- package/dist/types/cli/is/platform.d.ts +0 -2
- package/dist/types/runtime/nestedRoutes.d.ts +0 -13
- package/dist/types/runtime/remixRouter.d.ts +0 -1
- package/dist/types/runtime/router.d.ts +0 -1
- package/dist/types/runtime-browser/index.d.ts +0 -1
- package/dist/types/runtime-browser/parsed.d.ts +0 -1
- package/dist/types/runtime-node/index.d.ts +0 -10
- package/dist/types/runtime-node/loaderContext/createLoaderCtx.d.ts +0 -7
- package/dist/types/runtime-node/loaderContext/createRequestCtx.d.ts +0 -7
- package/dist/types/runtime-node/loaderContext/index.d.ts +0 -4
- package/dist/types/runtime-node/nestedRoutes.d.ts +0 -3
- package/dist/types/runtime-node/router.d.ts +0 -1
- package/dist/types/runtime-node/serialize.d.ts +0 -1
- package/dist/types/runtime-node/storage.d.ts +0 -5
- package/dist/types/universal/time.d.ts +0 -1
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.36.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -34,33 +34,6 @@
|
|
34
34
|
"types": "./dist/types/cli/constants/chainId.d.ts",
|
35
35
|
"default": "./dist/cjs/cli/constants/chainId.js"
|
36
36
|
},
|
37
|
-
"./runtime/router": {
|
38
|
-
"types": "./dist/types/runtime/router.d.ts",
|
39
|
-
"default": "./dist/esm/runtime/router.js"
|
40
|
-
},
|
41
|
-
"./runtime/remix-router": {
|
42
|
-
"types": "./dist/types/runtime/remixRouter.d.ts",
|
43
|
-
"require": "./dist/cjs/runtime/remixRouter.js",
|
44
|
-
"default": "./dist/esm/runtime/remixRouter.js"
|
45
|
-
},
|
46
|
-
"./runtime/nested-routes": {
|
47
|
-
"types": "./dist/types/runtime/nestedRoutes.d.ts",
|
48
|
-
"default": "./dist/esm/runtime/nestedRoutes.js"
|
49
|
-
},
|
50
|
-
"./runtime-browser": {
|
51
|
-
"jsnext:source": "./src/runtime-browser/index.d.ts",
|
52
|
-
"default": "./dist/esm/runtime-browser/index.js"
|
53
|
-
},
|
54
|
-
"./runtime-node": {
|
55
|
-
"types": "./dist/types/runtime-node/index.d.ts",
|
56
|
-
"require": "./dist/cjs/runtime-node/index.js",
|
57
|
-
"default": "./dist/esm/runtime-node/index.js"
|
58
|
-
},
|
59
|
-
"./runtime-node/router": {
|
60
|
-
"types": "./dist/types/runtime-node/router.d.ts",
|
61
|
-
"require": "./dist/cjs/runtime-node/router.js",
|
62
|
-
"default": "./dist/esm/runtime-node/router.js"
|
63
|
-
},
|
64
37
|
"./universal/constants": {
|
65
38
|
"types": "./dist/types/universal/constants.d.ts",
|
66
39
|
"import": "./dist/esm/universal/constants.js",
|
@@ -76,11 +49,6 @@
|
|
76
49
|
"import": "./dist/esm/universal/pluginDagSort.js",
|
77
50
|
"default": "./dist/cjs/universal/pluginDagSort.js"
|
78
51
|
},
|
79
|
-
"./universal/time": {
|
80
|
-
"types": "./dist/types/universal/time.d.ts",
|
81
|
-
"import": "./dist/esm/universal/time.js",
|
82
|
-
"default": "./dist/cjs/universal/time.js"
|
83
|
-
},
|
84
52
|
"./ajv": "./dist/compiled/ajv/index.js",
|
85
53
|
"./commander": "./dist/compiled/commander/index.js",
|
86
54
|
"./ora": "./dist/compiled/ora/index.js",
|
@@ -100,9 +68,7 @@
|
|
100
68
|
"./browserslist": "./dist/compiled/browserslist/index.js",
|
101
69
|
"./webpack-chain": "./dist/compiled/webpack-chain/index.js",
|
102
70
|
"./tsconfig-paths": "./dist/compiled/tsconfig-paths/index.js",
|
103
|
-
"./
|
104
|
-
"./better-ajv-errors": "./dist/compiled/better-ajv-errors/index.js",
|
105
|
-
"./webpack-dev-middleware": "./dist/compiled/webpack-dev-middleware/index.js"
|
71
|
+
"./better-ajv-errors": "./dist/compiled/better-ajv-errors/index.js"
|
106
72
|
},
|
107
73
|
"publishConfig": {
|
108
74
|
"registry": "https://registry.npmjs.org/",
|
@@ -117,24 +83,6 @@
|
|
117
83
|
"chain-id": [
|
118
84
|
"./dist/types/cli/constants/chainId.d.ts"
|
119
85
|
],
|
120
|
-
"runtime/router": [
|
121
|
-
"./dist/types/runtime/router.d.ts"
|
122
|
-
],
|
123
|
-
"runtime/remix-router": [
|
124
|
-
"./dist/types/runtime/remixRouter.d.ts"
|
125
|
-
],
|
126
|
-
"runtime/nested-routes": [
|
127
|
-
"./dist/types/runtime/nestedRoutes.d.ts"
|
128
|
-
],
|
129
|
-
"runtime-browser": [
|
130
|
-
"./dist/types/runtime-browser/index.d.ts"
|
131
|
-
],
|
132
|
-
"runtime-node": [
|
133
|
-
"./dist/types/runtime-node/index.d.ts"
|
134
|
-
],
|
135
|
-
"runtime-node/router": [
|
136
|
-
"./dist/types/runtime-node/router.d.ts"
|
137
|
-
],
|
138
86
|
"universal/constants": [
|
139
87
|
"./dist/types/universal/constants.d.ts"
|
140
88
|
],
|
@@ -144,9 +92,6 @@
|
|
144
92
|
"universal/plugin-dag-sort": [
|
145
93
|
"./dist/types/universal/pluginDagSort.d.ts"
|
146
94
|
],
|
147
|
-
"universal/time": [
|
148
|
-
"./dist/types/universal/time.d.ts"
|
149
|
-
],
|
150
95
|
"ajv": [
|
151
96
|
"./dist/compiled/ajv/types/ajv.d.ts"
|
152
97
|
],
|
@@ -201,15 +146,9 @@
|
|
201
146
|
"tsconfig-paths": [
|
202
147
|
"./dist/compiled/tsconfig-paths/lib/index.d.ts"
|
203
148
|
],
|
204
|
-
"gradient-string": [
|
205
|
-
"./dist/compiled/gradient-string/index.d.ts"
|
206
|
-
],
|
207
149
|
"better-ajv-errors": [
|
208
150
|
"./dist/compiled/better-ajv-errors/index.d.ts"
|
209
151
|
],
|
210
|
-
"webpack-dev-middleware": [
|
211
|
-
"./dist/compiled/webpack-dev-middleware/types/index.d.ts"
|
212
|
-
],
|
213
152
|
"commander": [
|
214
153
|
"./dist/compiled/commander/typings/index.d.ts"
|
215
154
|
],
|
@@ -221,35 +160,18 @@
|
|
221
160
|
"dependencies": {
|
222
161
|
"caniuse-lite": "^1.0.30001520",
|
223
162
|
"lodash": "^4.17.21",
|
224
|
-
"
|
225
|
-
"react-router-dom": "6.15.0",
|
226
|
-
"@remix-run/router": "1.8.0",
|
163
|
+
"rslog": "^1.0.0",
|
227
164
|
"@swc/helpers": "0.5.1"
|
228
165
|
},
|
229
|
-
"peerDependencies": {
|
230
|
-
"react": ">=17.0.0",
|
231
|
-
"react-dom": ">=17.0.0"
|
232
|
-
},
|
233
|
-
"peerDependenciesMeta": {
|
234
|
-
"react": {
|
235
|
-
"optional": true
|
236
|
-
},
|
237
|
-
"react-dom": {
|
238
|
-
"optional": true
|
239
|
-
}
|
240
|
-
},
|
241
166
|
"devDependencies": {
|
242
|
-
"react": "^18.2.0",
|
243
|
-
"react-dom": "^18.2.0",
|
244
167
|
"@types/jest": "^29",
|
245
168
|
"@types/node": "^14",
|
246
169
|
"jest": "^29",
|
247
170
|
"typescript": "^5",
|
248
171
|
"webpack": "^5.88.1",
|
249
|
-
"@types
|
250
|
-
"@
|
251
|
-
"@scripts/jest-config": "2.
|
252
|
-
"@scripts/build": "2.35.0"
|
172
|
+
"@modern-js/types": "2.36.0",
|
173
|
+
"@scripts/build": "2.36.0",
|
174
|
+
"@scripts/jest-config": "2.36.0"
|
253
175
|
},
|
254
176
|
"sideEffects": false,
|
255
177
|
"scripts": {
|
@@ -1,21 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
function _export(target, all) {
|
6
|
-
for (var name in all)
|
7
|
-
Object.defineProperty(target, name, {
|
8
|
-
enumerable: true,
|
9
|
-
get: all[name]
|
10
|
-
});
|
11
|
-
}
|
12
|
-
_export(exports, {
|
13
|
-
isNodeJS: function() {
|
14
|
-
return isNodeJS;
|
15
|
-
},
|
16
|
-
isBrowser: function() {
|
17
|
-
return isBrowser;
|
18
|
-
}
|
19
|
-
});
|
20
|
-
const isNodeJS = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null && process.versions.electron == null;
|
21
|
-
const isBrowser = () => typeof window !== "undefined";
|
@@ -1,149 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
function _export(target, all) {
|
6
|
-
for (var name in all)
|
7
|
-
Object.defineProperty(target, name, {
|
8
|
-
enumerable: true,
|
9
|
-
get: all[name]
|
10
|
-
});
|
11
|
-
}
|
12
|
-
_export(exports, {
|
13
|
-
transformNestedRoutes: function() {
|
14
|
-
return transformNestedRoutes;
|
15
|
-
},
|
16
|
-
renderNestedRoute: function() {
|
17
|
-
return renderNestedRoute;
|
18
|
-
}
|
19
|
-
});
|
20
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
21
|
-
const _jsxruntime = require("react/jsx-runtime");
|
22
|
-
const _react = /* @__PURE__ */ _interop_require_wildcard._(require("react"));
|
23
|
-
const _reactrouterdom = require("react-router-dom");
|
24
|
-
const _constants = require("../universal/constants");
|
25
|
-
const _time = require("../universal/time");
|
26
|
-
const transformNestedRoutes = (routes, reporter) => {
|
27
|
-
const routeElements = [];
|
28
|
-
for (const route of routes) {
|
29
|
-
const routeElement = renderNestedRoute(route, {
|
30
|
-
reporter
|
31
|
-
});
|
32
|
-
routeElements.push(routeElement);
|
33
|
-
}
|
34
|
-
return (0, _reactrouterdom.createRoutesFromElements)(routeElements);
|
35
|
-
};
|
36
|
-
const renderNestedRoute = (nestedRoute, options = {}) => {
|
37
|
-
var _config, _children;
|
38
|
-
const { children, index, id, component, isRoot, lazyImport, config, handle } = nestedRoute;
|
39
|
-
const Component = component;
|
40
|
-
const { parent, DeferredDataComponent, props = {}, reporter } = options;
|
41
|
-
const routeProps = {
|
42
|
-
caseSensitive: nestedRoute.caseSensitive,
|
43
|
-
path: nestedRoute.path,
|
44
|
-
id: nestedRoute.id,
|
45
|
-
loader: createLoader(nestedRoute, reporter),
|
46
|
-
action: nestedRoute.action,
|
47
|
-
hasErrorBoundary: nestedRoute.hasErrorBoundary,
|
48
|
-
shouldRevalidate: nestedRoute.shouldRevalidate,
|
49
|
-
handle: {
|
50
|
-
...handle,
|
51
|
-
...typeof config === "object" ? (_config = config) === null || _config === void 0 ? void 0 : _config.handle : {}
|
52
|
-
},
|
53
|
-
index: nestedRoute.index,
|
54
|
-
element: nestedRoute.element,
|
55
|
-
errorElement: nestedRoute.errorElement
|
56
|
-
};
|
57
|
-
if (nestedRoute.error) {
|
58
|
-
const errorElement = /* @__PURE__ */ (0, _jsxruntime.jsx)(nestedRoute.error, {});
|
59
|
-
routeProps.errorElement = errorElement;
|
60
|
-
}
|
61
|
-
let element;
|
62
|
-
if (Component) {
|
63
|
-
var _parent;
|
64
|
-
if (((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.loading) && lazyImport) {
|
65
|
-
const Loading = parent.loading;
|
66
|
-
if (isLoadableComponent(Component)) {
|
67
|
-
element = /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {
|
68
|
-
fallback: /* @__PURE__ */ (0, _jsxruntime.jsx)(Loading, {})
|
69
|
-
});
|
70
|
-
} else {
|
71
|
-
element = /* @__PURE__ */ (0, _jsxruntime.jsx)(_react.Suspense, {
|
72
|
-
fallback: /* @__PURE__ */ (0, _jsxruntime.jsx)(Loading, {}),
|
73
|
-
children: /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {})
|
74
|
-
});
|
75
|
-
}
|
76
|
-
} else if (isLoadableComponent(Component) && lazyImport) {
|
77
|
-
element = /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {});
|
78
|
-
} else if (isRoot) {
|
79
|
-
var _props;
|
80
|
-
element = /* @__PURE__ */ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
81
|
-
children: [
|
82
|
-
/* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {
|
83
|
-
...props
|
84
|
-
}),
|
85
|
-
typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, _jsxruntime.jsx)(DeferredDataComponent, {
|
86
|
-
nonce: (_props = props) === null || _props === void 0 ? void 0 : _props.nonce
|
87
|
-
})
|
88
|
-
]
|
89
|
-
});
|
90
|
-
} else if (lazyImport) {
|
91
|
-
element = /* @__PURE__ */ (0, _jsxruntime.jsx)(_react.Suspense, {
|
92
|
-
fallback: null,
|
93
|
-
children: /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {})
|
94
|
-
});
|
95
|
-
} else {
|
96
|
-
element = /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {});
|
97
|
-
}
|
98
|
-
} else {
|
99
|
-
var _parent1;
|
100
|
-
nestedRoute.loading = (_parent1 = parent) === null || _parent1 === void 0 ? void 0 : _parent1.loading;
|
101
|
-
routeProps.element = /* @__PURE__ */ (0, _jsxruntime.jsx)(_reactrouterdom.Outlet, {});
|
102
|
-
}
|
103
|
-
if (element) {
|
104
|
-
routeProps.element = element;
|
105
|
-
}
|
106
|
-
const childElements = (_children = children) === null || _children === void 0 ? void 0 : _children.map((childRoute) => {
|
107
|
-
return renderNestedRoute(childRoute, {
|
108
|
-
parent: nestedRoute,
|
109
|
-
reporter
|
110
|
-
});
|
111
|
-
});
|
112
|
-
const routeElement = index ? /* @__PURE__ */ (0, _jsxruntime.jsx)(_reactrouterdom.Route, {
|
113
|
-
...routeProps,
|
114
|
-
index: true
|
115
|
-
}, id) : /* @__PURE__ */ (0, _jsxruntime.jsx)(_reactrouterdom.Route, {
|
116
|
-
...routeProps,
|
117
|
-
index: false,
|
118
|
-
children: childElements
|
119
|
-
}, id);
|
120
|
-
return routeElement;
|
121
|
-
};
|
122
|
-
function createLoader(route, reporter) {
|
123
|
-
const { loader } = route;
|
124
|
-
if (loader) {
|
125
|
-
return async (args) => {
|
126
|
-
if (typeof route.lazyImport === "function") {
|
127
|
-
route.lazyImport();
|
128
|
-
}
|
129
|
-
const end = (0, _time.time)();
|
130
|
-
const res = await loader(args);
|
131
|
-
const cost = end();
|
132
|
-
if (typeof document === "undefined" && reporter) {
|
133
|
-
var _reporter;
|
134
|
-
(_reporter = reporter) === null || _reporter === void 0 ? void 0 : _reporter.reportTiming(`${_constants.LOADER_REPORTER_NAME}-${route.id}`, cost);
|
135
|
-
}
|
136
|
-
return res;
|
137
|
-
};
|
138
|
-
} else {
|
139
|
-
return () => {
|
140
|
-
if (typeof route.lazyImport === "function") {
|
141
|
-
route.lazyImport();
|
142
|
-
}
|
143
|
-
return null;
|
144
|
-
};
|
145
|
-
}
|
146
|
-
}
|
147
|
-
function isLoadableComponent(component) {
|
148
|
-
return component && component.displayName === "Loadable" && component.preload && typeof component.preload === "function";
|
149
|
-
}
|
@@ -1,28 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "parsedJSONFromElement", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return parsedJSONFromElement;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
const parsedJSONFromElement = (id) => {
|
12
|
-
const elements = document.querySelectorAll(`#${id}`);
|
13
|
-
if (elements.length === 0) {
|
14
|
-
return void 0;
|
15
|
-
}
|
16
|
-
const element = elements[elements.length - 1];
|
17
|
-
if (element) {
|
18
|
-
try {
|
19
|
-
var _element;
|
20
|
-
const parsed = JSON.parse(((_element = element) === null || _element === void 0 ? void 0 : _element.textContent) || "");
|
21
|
-
return parsed;
|
22
|
-
} catch (e) {
|
23
|
-
console.error(`parse ${id} error`, e);
|
24
|
-
return void 0;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
return void 0;
|
28
|
-
};
|
@@ -1,28 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
function _export(target, all) {
|
6
|
-
for (var name in all)
|
7
|
-
Object.defineProperty(target, name, {
|
8
|
-
enumerable: true,
|
9
|
-
get: all[name]
|
10
|
-
});
|
11
|
-
}
|
12
|
-
_export(exports, {
|
13
|
-
run: function() {
|
14
|
-
return run;
|
15
|
-
},
|
16
|
-
useHeaders: function() {
|
17
|
-
return useHeaders;
|
18
|
-
},
|
19
|
-
serializeJson: function() {
|
20
|
-
return _serialize.serializeJson;
|
21
|
-
}
|
22
|
-
});
|
23
|
-
const _export_star = require("@swc/helpers/_/_export_star");
|
24
|
-
const _storage = require("./storage");
|
25
|
-
const _serialize = require("./serialize");
|
26
|
-
_export_star._(require("./nestedRoutes"), exports);
|
27
|
-
_export_star._(require("./loaderContext"), exports);
|
28
|
-
const { run, useContext: useHeaders } = (0, _storage.createStorage)();
|
@@ -1,34 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
function _export(target, all) {
|
6
|
-
for (var name in all)
|
7
|
-
Object.defineProperty(target, name, {
|
8
|
-
enumerable: true,
|
9
|
-
get: all[name]
|
10
|
-
});
|
11
|
-
}
|
12
|
-
_export(exports, {
|
13
|
-
LoaderContext: function() {
|
14
|
-
return LoaderContext;
|
15
|
-
},
|
16
|
-
createLoaderContext: function() {
|
17
|
-
return createLoaderContext;
|
18
|
-
}
|
19
|
-
});
|
20
|
-
class LoaderContext {
|
21
|
-
getDefaultValue() {
|
22
|
-
if (!this.defaultValue) {
|
23
|
-
throw new Error("Can't get defaultValue before initialed");
|
24
|
-
}
|
25
|
-
return this.defaultValue;
|
26
|
-
}
|
27
|
-
constructor(defaultValue) {
|
28
|
-
this.defaultValue = defaultValue;
|
29
|
-
this.symbol = Symbol("loaderContext");
|
30
|
-
}
|
31
|
-
}
|
32
|
-
function createLoaderContext(defaultValue) {
|
33
|
-
return new LoaderContext(defaultValue);
|
34
|
-
}
|
@@ -1,38 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
function _export(target, all) {
|
6
|
-
for (var name in all)
|
7
|
-
Object.defineProperty(target, name, {
|
8
|
-
enumerable: true,
|
9
|
-
get: all[name]
|
10
|
-
});
|
11
|
-
}
|
12
|
-
_export(exports, {
|
13
|
-
RequestContext: function() {
|
14
|
-
return RequestContext;
|
15
|
-
},
|
16
|
-
createRequestContext: function() {
|
17
|
-
return createRequestContext;
|
18
|
-
}
|
19
|
-
});
|
20
|
-
class RequestContext {
|
21
|
-
get(loaderCtx) {
|
22
|
-
const { symbol } = loaderCtx;
|
23
|
-
if (this.store.get(symbol)) {
|
24
|
-
return this.store.get(symbol);
|
25
|
-
}
|
26
|
-
return loaderCtx.getDefaultValue();
|
27
|
-
}
|
28
|
-
set(loaderCtx, value) {
|
29
|
-
const { symbol } = loaderCtx;
|
30
|
-
this.store.set(symbol, value);
|
31
|
-
}
|
32
|
-
constructor() {
|
33
|
-
this.store = /* @__PURE__ */ new Map();
|
34
|
-
}
|
35
|
-
}
|
36
|
-
function createRequestContext() {
|
37
|
-
return new RequestContext();
|
38
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
function _export(target, all) {
|
6
|
-
for (var name in all)
|
7
|
-
Object.defineProperty(target, name, {
|
8
|
-
enumerable: true,
|
9
|
-
get: all[name]
|
10
|
-
});
|
11
|
-
}
|
12
|
-
_export(exports, {
|
13
|
-
createRequestContext: function() {
|
14
|
-
return _createRequestCtx.createRequestContext;
|
15
|
-
},
|
16
|
-
reporterCtx: function() {
|
17
|
-
return reporterCtx;
|
18
|
-
}
|
19
|
-
});
|
20
|
-
const _createLoaderCtx = require("./createLoaderCtx");
|
21
|
-
const _createRequestCtx = require("./createRequestCtx");
|
22
|
-
const reporterCtx = (0, _createLoaderCtx.createLoaderContext)();
|
@@ -1,28 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "matchEntry", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return matchEntry;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
function sortByUrlPath(entries) {
|
12
|
-
entries.sort(function(a, b) {
|
13
|
-
const length1 = a.urlPath.length;
|
14
|
-
const length2 = b.urlPath.length;
|
15
|
-
if (length1 < length2) {
|
16
|
-
return 1;
|
17
|
-
}
|
18
|
-
if (length1 > length2) {
|
19
|
-
return -1;
|
20
|
-
}
|
21
|
-
return 0;
|
22
|
-
});
|
23
|
-
return entries;
|
24
|
-
}
|
25
|
-
const matchEntry = (pathname, entries) => {
|
26
|
-
sortByUrlPath(entries);
|
27
|
-
return entries.find((entry) => pathname.startsWith(entry.urlPath));
|
28
|
-
};
|
@@ -1,17 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "serializeJson", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return serializeJson;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
12
|
-
const _serializejavascript = /* @__PURE__ */ _interop_require_default._(require("serialize-javascript"));
|
13
|
-
const serializeJson = (data) => {
|
14
|
-
return (0, _serializejavascript.default)(data, {
|
15
|
-
isJSON: true
|
16
|
-
});
|
17
|
-
};
|
@@ -1,48 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "createStorage", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return createStorage;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
|
-
const _async_hooks = /* @__PURE__ */ _interop_require_wildcard._(require("async_hooks"));
|
13
|
-
const createStorage = () => {
|
14
|
-
let storage;
|
15
|
-
if (typeof _async_hooks.AsyncLocalStorage !== "undefined") {
|
16
|
-
storage = new _async_hooks.AsyncLocalStorage();
|
17
|
-
}
|
18
|
-
const run = (context, cb) => {
|
19
|
-
if (!storage) {
|
20
|
-
throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
21
|
-
`);
|
22
|
-
}
|
23
|
-
return new Promise((resolve, reject) => {
|
24
|
-
storage.run(context, () => {
|
25
|
-
try {
|
26
|
-
return resolve(cb());
|
27
|
-
} catch (error) {
|
28
|
-
return reject(error);
|
29
|
-
}
|
30
|
-
});
|
31
|
-
});
|
32
|
-
};
|
33
|
-
const useContext = () => {
|
34
|
-
if (!storage) {
|
35
|
-
throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
36
|
-
`);
|
37
|
-
}
|
38
|
-
const context = storage.getStore();
|
39
|
-
if (!context) {
|
40
|
-
throw new Error(`Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules`);
|
41
|
-
}
|
42
|
-
return context;
|
43
|
-
};
|
44
|
-
return {
|
45
|
-
run,
|
46
|
-
useContext
|
47
|
-
};
|
48
|
-
};
|
@@ -1,38 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "time", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return time;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
function processHrtime(previousTimestamp) {
|
12
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
13
|
-
const clocktime = now * 1e-3;
|
14
|
-
let seconds = Math.floor(clocktime);
|
15
|
-
let nanoseconds = Math.floor(clocktime % 1 * 1e9);
|
16
|
-
if (previousTimestamp) {
|
17
|
-
seconds -= previousTimestamp[0];
|
18
|
-
nanoseconds -= previousTimestamp[1];
|
19
|
-
if (nanoseconds < 0) {
|
20
|
-
seconds--;
|
21
|
-
nanoseconds += 1e9;
|
22
|
-
}
|
23
|
-
}
|
24
|
-
return [
|
25
|
-
seconds,
|
26
|
-
nanoseconds
|
27
|
-
];
|
28
|
-
}
|
29
|
-
const getLatency = (hrtime) => {
|
30
|
-
const [s, ns] = processHrtime(hrtime);
|
31
|
-
return s * 1e3 + ns / 1e6;
|
32
|
-
};
|
33
|
-
const time = () => {
|
34
|
-
const hrtime = processHrtime();
|
35
|
-
return () => {
|
36
|
-
return getLatency(hrtime);
|
37
|
-
};
|
38
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export = any;
|