@modern-js/utils 2.21.1 → 2.22.1-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +11 -0
- package/dist/FileSizeReporter.d.ts +16 -0
- package/dist/FileSizeReporter.js +162 -0
- package/dist/alias.d.ts +25 -0
- package/dist/alias.js +108 -0
- package/dist/analyzeProject.d.ts +2 -0
- package/dist/analyzeProject.js +71 -0
- package/dist/applyOptionsChain.d.ts +3 -0
- package/dist/applyOptionsChain.js +58 -0
- package/dist/babel.d.ts +3 -0
- package/dist/babel.js +136 -0
- package/dist/chainId.d.ts +244 -0
- package/dist/chainId.js +196 -0
- package/dist/cjs/cli/alias.js +12 -4
- package/dist/cjs/cli/applyOptionsChain.js +3 -1
- package/dist/cjs/cli/babel.js +6 -2
- package/dist/cjs/cli/commands.js +12 -4
- package/dist/cjs/cli/common.js +9 -3
- package/dist/cjs/cli/constants/chainId.js +3 -1
- package/dist/cjs/cli/constants/index.js +93 -31
- package/dist/cjs/cli/ensure.js +6 -2
- package/dist/cjs/cli/fs.js +6 -2
- package/dist/cjs/cli/get/config.js +3 -1
- package/dist/cjs/cli/get/data.js +24 -8
- package/dist/cjs/cli/get/index.js +6 -2
- package/dist/cjs/cli/is/config.js +18 -6
- package/dist/cjs/cli/is/env.js +18 -6
- package/dist/cjs/cli/is/platform.js +6 -2
- package/dist/cjs/cli/is/project.js +21 -7
- package/dist/cjs/cli/is/type.js +27 -9
- package/dist/cjs/cli/logger.js +6 -2
- package/dist/cjs/cli/monorepo.js +21 -7
- package/dist/cjs/cli/package.js +12 -4
- package/dist/cjs/cli/path.js +39 -13
- package/dist/cjs/cli/pathSerializer.js +12 -4
- package/dist/cjs/cli/port.js +3 -1
- package/dist/cjs/cli/prettyInstructions.js +6 -2
- package/dist/cjs/cli/print.js +3 -1
- package/dist/cjs/cli/require.js +18 -6
- package/dist/cjs/cli/routes.js +3 -1
- package/dist/cjs/cli/runtimeExports.js +3 -1
- package/dist/cjs/cli/test.js +3 -1
- package/dist/cjs/cli/watch.js +6 -2
- package/dist/cjs/compiled.js +99 -33
- package/dist/cjs/import.js +6 -2
- package/dist/cjs/runtime/nestedRoutes.js +6 -2
- package/dist/cjs/runtime-browser/parsed.js +8 -2
- package/dist/cjs/runtime-node/index.js +9 -3
- package/dist/cjs/runtime-node/serialize.js +3 -1
- package/dist/cjs/runtime-node/storage.js +3 -1
- package/dist/cjs/universal/constants.js +6 -2
- package/dist/cjs/universal/formatWebpack.js +3 -1
- package/dist/cjs/universal/pluginDagSort.js +3 -1
- package/dist/clearConsole.d.ts +1 -0
- package/dist/clearConsole.js +31 -0
- package/dist/commands.d.ts +4 -0
- package/dist/commands.js +48 -0
- package/dist/compatRequire.d.ts +13 -0
- package/dist/compatRequire.js +82 -0
- package/dist/compiled.d.ts +43 -0
- package/dist/compiled.js +142 -0
- package/dist/constants.d.ts +244 -0
- package/dist/constants.js +320 -0
- package/dist/debug.d.ts +6 -0
- package/dist/debug.js +28 -0
- package/dist/emptyDir.d.ts +1 -0
- package/dist/emptyDir.js +52 -0
- package/dist/ensureAbsolutePath.d.ts +7 -0
- package/dist/ensureAbsolutePath.js +38 -0
- package/dist/ensureArray.d.ts +1 -0
- package/dist/ensureArray.js +32 -0
- package/dist/esm/runtime-browser/parsed.js +5 -1
- package/dist/findExists.d.ts +6 -0
- package/dist/findExists.js +45 -0
- package/dist/generateMetaTags.d.ts +16 -0
- package/dist/generateMetaTags.js +61 -0
- package/dist/getBrowserslist.d.ts +2 -0
- package/dist/getBrowserslist.js +31 -0
- package/dist/getCoreJsVersion.d.ts +1 -0
- package/dist/getCoreJsVersion.js +46 -0
- package/dist/getEntryOptions.d.ts +1 -0
- package/dist/getEntryOptions.js +54 -0
- package/dist/getPackageManager.d.ts +1 -0
- package/dist/getPackageManager.js +87 -0
- package/dist/getPort.d.ts +14 -0
- package/dist/getPort.js +112 -0
- package/dist/getServerConfig.d.ts +1 -0
- package/dist/getServerConfig.js +67 -0
- package/dist/getTargetDir.d.ts +1 -0
- package/dist/getTargetDir.js +41 -0
- package/dist/import.d.ts +5 -0
- package/dist/import.js +33 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +60 -0
- package/dist/is/index.d.ts +58 -0
- package/dist/is/index.js +114 -0
- package/dist/is/nodeEnv.d.ts +8 -0
- package/dist/is/nodeEnv.js +39 -0
- package/dist/is/platform.d.ts +2 -0
- package/dist/is/platform.js +30 -0
- package/dist/is/type.d.ts +8 -0
- package/dist/is/type.js +64 -0
- package/dist/logger.d.ts +65 -0
- package/dist/logger.js +145 -0
- package/dist/monorepo.d.ts +11 -0
- package/dist/monorepo.js +137 -0
- package/dist/nodeEnv.d.ts +3 -0
- package/dist/nodeEnv.js +81 -0
- package/dist/path.d.ts +18 -0
- package/dist/path.js +92 -0
- package/dist/pathSerializer.d.ts +16 -0
- package/dist/pathSerializer.js +76 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +46 -0
- package/dist/prettyInstructions.d.ts +9 -0
- package/dist/prettyInstructions.js +112 -0
- package/dist/printBuildError.d.ts +8 -0
- package/dist/printBuildError.js +57 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +64 -0
- package/dist/readTsConfig.d.ts +2 -0
- package/dist/readTsConfig.js +47 -0
- package/dist/removeSlash.d.ts +3 -0
- package/dist/removeSlash.js +33 -0
- package/dist/resolve.d.ts +13 -0
- package/dist/resolve.js +63 -0
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +58 -0
- package/dist/runtimeExports.d.ts +4 -0
- package/dist/runtimeExports.js +73 -0
- package/dist/ssr.d.ts +8 -0
- package/dist/ssr.js +30 -0
- package/dist/storage.d.ts +5 -0
- package/dist/storage.js +75 -0
- package/dist/testUtils.d.ts +5 -0
- package/dist/testUtils.js +38 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +15 -0
- package/dist/universal/constants.d.ts +9 -0
- package/dist/universal/constants.js +30 -0
- package/dist/universal/formatWebpack.d.ts +13 -0
- package/dist/universal/formatWebpack.js +100 -0
- package/dist/universal/nestedRoutes.d.ts +8 -0
- package/dist/universal/nestedRoutes.js +131 -0
- package/dist/universal/remixRouter.d.ts +1 -0
- package/dist/universal/remixRouter.js +17 -0
- package/dist/universal/serialize.d.ts +1 -0
- package/dist/universal/serialize.js +40 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +92 -0
- package/dist/wait.d.ts +2 -0
- package/dist/wait.js +29 -0
- package/dist/watch.d.ts +8 -0
- package/dist/watch.js +90 -0
- package/package.json +5 -5
package/dist/storage.js
ADDED
@@ -0,0 +1,75 @@
|
|
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 storage_exports = {};
|
29
|
+
__export(storage_exports, {
|
30
|
+
createStorage: () => createStorage
|
31
|
+
});
|
32
|
+
module.exports = __toCommonJS(storage_exports);
|
33
|
+
var ah = __toESM(require("async_hooks"));
|
34
|
+
const createStorage = () => {
|
35
|
+
let storage;
|
36
|
+
if (typeof ah.AsyncLocalStorage !== "undefined") {
|
37
|
+
storage = new ah.AsyncLocalStorage();
|
38
|
+
}
|
39
|
+
const run = (context, cb) => {
|
40
|
+
if (!storage) {
|
41
|
+
throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
42
|
+
`);
|
43
|
+
}
|
44
|
+
return new Promise((resolve, reject) => {
|
45
|
+
storage.run(context, () => {
|
46
|
+
try {
|
47
|
+
return resolve(cb());
|
48
|
+
} catch (error) {
|
49
|
+
return reject(error);
|
50
|
+
}
|
51
|
+
});
|
52
|
+
});
|
53
|
+
};
|
54
|
+
const useContext = () => {
|
55
|
+
if (!storage) {
|
56
|
+
throw new Error(`Unable to use async_hook, please confirm the node version >= 12.17
|
57
|
+
`);
|
58
|
+
}
|
59
|
+
const context = storage.getStore();
|
60
|
+
if (!context) {
|
61
|
+
throw new Error(
|
62
|
+
`Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules`
|
63
|
+
);
|
64
|
+
}
|
65
|
+
return context;
|
66
|
+
};
|
67
|
+
return {
|
68
|
+
run,
|
69
|
+
useContext
|
70
|
+
};
|
71
|
+
};
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
73
|
+
0 && (module.exports = {
|
74
|
+
createStorage
|
75
|
+
});
|
@@ -0,0 +1,38 @@
|
|
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 testUtils_exports = {};
|
19
|
+
__export(testUtils_exports, {
|
20
|
+
initSnapshotSerializer: () => initSnapshotSerializer
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(testUtils_exports);
|
23
|
+
const initSnapshotSerializer = (root) => {
|
24
|
+
expect.addSnapshotSerializer({
|
25
|
+
test: (val) => typeof val === "string" && (val.includes("modern.js") || val.includes("node_modules") || val.includes(root)),
|
26
|
+
print: (val) => (
|
27
|
+
// eslint-disable-next-line no-nested-ternary
|
28
|
+
typeof val === "string" ? (
|
29
|
+
// eslint-disable-next-line no-nested-ternary
|
30
|
+
val.includes("node_modules") ? `"${val.replace(/.+node_modules/, ``).replace(/\\/g, "/")}"` : val.includes("modern.js") ? `"${val.replace(/.+modern\.js/, ``).replace(/\\/g, "/")}"` : `"${val.replace(root, "").replace(/\\/g, "/")}"`
|
31
|
+
) : val
|
32
|
+
)
|
33
|
+
});
|
34
|
+
};
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
36
|
+
0 && (module.exports = {
|
37
|
+
initSnapshotSerializer
|
38
|
+
});
|
package/dist/types.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export type Falsy = false | null | undefined | 0 | '';
|
package/dist/types.js
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
7
|
+
for (let key of __getOwnPropNames(from))
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
10
|
+
}
|
11
|
+
return to;
|
12
|
+
};
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
14
|
+
var types_exports = {};
|
15
|
+
module.exports = __toCommonJS(types_exports);
|
@@ -0,0 +1,30 @@
|
|
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 constants_exports = {};
|
19
|
+
__export(constants_exports, {
|
20
|
+
HMR_SOCK_PATH: () => HMR_SOCK_PATH,
|
21
|
+
ROUTE_MANIFEST: () => ROUTE_MANIFEST
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(constants_exports);
|
24
|
+
const ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
|
25
|
+
const HMR_SOCK_PATH = "/webpack-hmr";
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
27
|
+
0 && (module.exports = {
|
28
|
+
HMR_SOCK_PATH,
|
29
|
+
ROUTE_MANIFEST
|
30
|
+
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file at
|
6
|
+
* https://github.com/facebook/create-react-app/blob/master/LICENSE
|
7
|
+
*/
|
8
|
+
import type { StatsCompilation } from 'webpack';
|
9
|
+
declare function formatWebpackMessages(json?: Pick<StatsCompilation, 'errors' | 'warnings'>): {
|
10
|
+
errors: string[];
|
11
|
+
warnings: string[];
|
12
|
+
};
|
13
|
+
export { formatWebpackMessages };
|
@@ -0,0 +1,100 @@
|
|
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 formatWebpack_exports = {};
|
19
|
+
__export(formatWebpack_exports, {
|
20
|
+
formatWebpackMessages: () => formatWebpackMessages
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(formatWebpack_exports);
|
23
|
+
const friendlySyntaxErrorLabel = "SyntaxError:";
|
24
|
+
function isLikelyASyntaxError(message) {
|
25
|
+
return message.includes(friendlySyntaxErrorLabel);
|
26
|
+
}
|
27
|
+
function formatMessage(stats) {
|
28
|
+
let lines = [];
|
29
|
+
let message;
|
30
|
+
if (typeof stats === "object") {
|
31
|
+
const fileName = stats.moduleName ? `File: ${stats.moduleName}
|
32
|
+
` : "";
|
33
|
+
const mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
|
34
|
+
const details = stats.details ? `
|
35
|
+
Details: ${stats.details}
|
36
|
+
` : "";
|
37
|
+
const stack = stats.stack ? `
|
38
|
+
${stats.stack}` : "";
|
39
|
+
message = `${fileName}${mainMessage}${details}${stack}`;
|
40
|
+
} else {
|
41
|
+
message = stats;
|
42
|
+
}
|
43
|
+
lines = message.split("\n");
|
44
|
+
lines = lines.map((line) => {
|
45
|
+
const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
|
46
|
+
line
|
47
|
+
);
|
48
|
+
if (!parsingError) {
|
49
|
+
return line;
|
50
|
+
}
|
51
|
+
const [, errorLine, errorColumn, errorMessage] = parsingError;
|
52
|
+
return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
|
53
|
+
});
|
54
|
+
message = lines.join("\n");
|
55
|
+
message = message.replace(
|
56
|
+
/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
|
57
|
+
`${friendlySyntaxErrorLabel} $3 ($1:$2)
|
58
|
+
`
|
59
|
+
);
|
60
|
+
lines = message.split("\n");
|
61
|
+
if (lines.length > 2 && lines[1].trim() === "") {
|
62
|
+
lines.splice(1, 1);
|
63
|
+
}
|
64
|
+
lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, "$1");
|
65
|
+
if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
|
66
|
+
lines[1] = lines[1].replace("Error: ", "");
|
67
|
+
}
|
68
|
+
message = lines.join("\n");
|
69
|
+
message = message.replace(
|
70
|
+
/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
|
71
|
+
""
|
72
|
+
);
|
73
|
+
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
|
74
|
+
lines = message.split("\n");
|
75
|
+
lines = lines.filter(
|
76
|
+
(line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
|
77
|
+
);
|
78
|
+
message = lines.join("\n");
|
79
|
+
return message.trim();
|
80
|
+
}
|
81
|
+
function formatWebpackMessages(json) {
|
82
|
+
var _a, _b, _c;
|
83
|
+
const formattedErrors = (_a = json == null ? void 0 : json.errors) == null ? void 0 : _a.map(formatMessage);
|
84
|
+
const formattedWarnings = (_b = json == null ? void 0 : json.warnings) == null ? void 0 : _b.map(formatMessage);
|
85
|
+
const result = {
|
86
|
+
errors: formattedErrors || [],
|
87
|
+
warnings: formattedWarnings || []
|
88
|
+
};
|
89
|
+
if ((_c = result.errors) == null ? void 0 : _c.some(isLikelyASyntaxError)) {
|
90
|
+
result.errors = result.errors.filter(isLikelyASyntaxError);
|
91
|
+
}
|
92
|
+
if (result.errors.length > 1) {
|
93
|
+
result.errors.length = 1;
|
94
|
+
}
|
95
|
+
return result;
|
96
|
+
}
|
97
|
+
// Annotate the CommonJS export names for ESM import in node:
|
98
|
+
0 && (module.exports = {
|
99
|
+
formatWebpackMessages
|
100
|
+
});
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import type { NestedRoute } from '@modern-js/types';
|
3
|
+
export declare const transformNestedRoutes: (routes: NestedRoute[]) => import("react-router-dom").RouteObject[];
|
4
|
+
export declare const renderNestedRoute: (nestedRoute: NestedRoute, options?: {
|
5
|
+
parent?: NestedRoute;
|
6
|
+
DeferredDataComponent?: () => JSX.Element | null;
|
7
|
+
props?: Record<string, any>;
|
8
|
+
}) => JSX.Element;
|
@@ -0,0 +1,131 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
7
|
+
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
|
+
var __export = (target, all) => {
|
23
|
+
for (var name in all)
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
25
|
+
};
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
28
|
+
for (let key of __getOwnPropNames(from))
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
31
|
+
}
|
32
|
+
return to;
|
33
|
+
};
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
35
|
+
var nestedRoutes_exports = {};
|
36
|
+
__export(nestedRoutes_exports, {
|
37
|
+
renderNestedRoute: () => renderNestedRoute,
|
38
|
+
transformNestedRoutes: () => transformNestedRoutes
|
39
|
+
});
|
40
|
+
module.exports = __toCommonJS(nestedRoutes_exports);
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
42
|
+
var import_react = require("react");
|
43
|
+
var import_react_router_dom = require("react-router-dom");
|
44
|
+
const transformNestedRoutes = (routes) => {
|
45
|
+
const routeElements = [];
|
46
|
+
for (const route of routes) {
|
47
|
+
const routeElement = renderNestedRoute(route);
|
48
|
+
routeElements.push(routeElement);
|
49
|
+
}
|
50
|
+
return (0, import_react_router_dom.createRoutesFromElements)(routeElements);
|
51
|
+
};
|
52
|
+
const renderNestedRoute = (nestedRoute, options = {}) => {
|
53
|
+
const { children, index, id, component, isRoot, lazyImport } = nestedRoute;
|
54
|
+
const Component = component;
|
55
|
+
const { parent, DeferredDataComponent, props = {} } = options;
|
56
|
+
const routeProps = {
|
57
|
+
caseSensitive: nestedRoute.caseSensitive,
|
58
|
+
path: nestedRoute.path,
|
59
|
+
id: nestedRoute.id,
|
60
|
+
loader: createLoader(nestedRoute),
|
61
|
+
action: nestedRoute.action,
|
62
|
+
hasErrorBoundary: nestedRoute.hasErrorBoundary,
|
63
|
+
shouldRevalidate: nestedRoute.shouldRevalidate,
|
64
|
+
handle: nestedRoute.handle,
|
65
|
+
index: nestedRoute.index,
|
66
|
+
element: nestedRoute.element,
|
67
|
+
errorElement: nestedRoute.errorElement
|
68
|
+
};
|
69
|
+
if (nestedRoute.error) {
|
70
|
+
const errorElement = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(nestedRoute.error, {});
|
71
|
+
routeProps.errorElement = errorElement;
|
72
|
+
}
|
73
|
+
let element;
|
74
|
+
if (Component) {
|
75
|
+
if ((parent == null ? void 0 : parent.loading) && lazyImport) {
|
76
|
+
const Loading = parent.loading;
|
77
|
+
if (isLoadableComponent(Component)) {
|
78
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}) });
|
79
|
+
} else {
|
80
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
|
81
|
+
}
|
82
|
+
} else if (isLoadableComponent(Component) && lazyImport) {
|
83
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
|
84
|
+
} else if (isRoot) {
|
85
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, __spreadValues({}, props)),
|
87
|
+
typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeferredDataComponent, {})
|
88
|
+
] });
|
89
|
+
} else if (lazyImport) {
|
90
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
|
91
|
+
} else {
|
92
|
+
element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
|
93
|
+
}
|
94
|
+
} else {
|
95
|
+
nestedRoute.loading = parent == null ? void 0 : parent.loading;
|
96
|
+
}
|
97
|
+
if (element) {
|
98
|
+
routeProps.element = element;
|
99
|
+
}
|
100
|
+
const childElements = children == null ? void 0 : children.map((childRoute) => {
|
101
|
+
return renderNestedRoute(childRoute, { parent: nestedRoute });
|
102
|
+
});
|
103
|
+
const routeElement = index ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, __spreadProps(__spreadValues({}, routeProps), { index: true }), id) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, __spreadProps(__spreadValues({}, routeProps), { index: false, children: childElements }), id);
|
104
|
+
return routeElement;
|
105
|
+
};
|
106
|
+
function createLoader(route) {
|
107
|
+
const { loader } = route;
|
108
|
+
if (loader) {
|
109
|
+
return (args) => {
|
110
|
+
if (typeof route.lazyImport === "function") {
|
111
|
+
route.lazyImport();
|
112
|
+
}
|
113
|
+
return loader(args);
|
114
|
+
};
|
115
|
+
} else {
|
116
|
+
return () => {
|
117
|
+
if (typeof route.lazyImport === "function") {
|
118
|
+
route.lazyImport();
|
119
|
+
}
|
120
|
+
return null;
|
121
|
+
};
|
122
|
+
}
|
123
|
+
}
|
124
|
+
function isLoadableComponent(component) {
|
125
|
+
return component && component.displayName === "Loadable" && component.preload && typeof component.preload === "function";
|
126
|
+
}
|
127
|
+
// Annotate the CommonJS export names for ESM import in node:
|
128
|
+
0 && (module.exports = {
|
129
|
+
renderNestedRoute,
|
130
|
+
transformNestedRoutes
|
131
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from '@remix-run/router';
|
@@ -0,0 +1,17 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
7
|
+
for (let key of __getOwnPropNames(from))
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
10
|
+
}
|
11
|
+
return to;
|
12
|
+
};
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
15
|
+
var remixRouter_exports = {};
|
16
|
+
module.exports = __toCommonJS(remixRouter_exports);
|
17
|
+
__reExport(remixRouter_exports, require("@remix-run/router"), module.exports);
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const serializeJson: (data: any) => string;
|
@@ -0,0 +1,40 @@
|
|
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 serialize_exports = {};
|
29
|
+
__export(serialize_exports, {
|
30
|
+
serializeJson: () => serializeJson
|
31
|
+
});
|
32
|
+
module.exports = __toCommonJS(serialize_exports);
|
33
|
+
var import_serialize_javascript = __toESM(require("serialize-javascript"));
|
34
|
+
const serializeJson = (data) => {
|
35
|
+
return (0, import_serialize_javascript.default)(data, { isJSON: true });
|
36
|
+
};
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
38
|
+
0 && (module.exports = {
|
39
|
+
serializeJson
|
40
|
+
});
|
package/dist/version.js
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
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 __export = (target, all) => {
|
22
|
+
for (var name in all)
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
24
|
+
};
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
27
|
+
for (let key of __getOwnPropNames(from))
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
30
|
+
}
|
31
|
+
return to;
|
32
|
+
};
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
34
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
35
|
+
// file that has been converted to a CommonJS file using a Babel-
|
36
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
37
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
38
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
39
|
+
mod
|
40
|
+
));
|
41
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
42
|
+
var __async = (__this, __arguments, generator) => {
|
43
|
+
return new Promise((resolve, reject) => {
|
44
|
+
var fulfilled = (value) => {
|
45
|
+
try {
|
46
|
+
step(generator.next(value));
|
47
|
+
} catch (e) {
|
48
|
+
reject(e);
|
49
|
+
}
|
50
|
+
};
|
51
|
+
var rejected = (value) => {
|
52
|
+
try {
|
53
|
+
step(generator.throw(value));
|
54
|
+
} catch (e) {
|
55
|
+
reject(e);
|
56
|
+
}
|
57
|
+
};
|
58
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
59
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
60
|
+
});
|
61
|
+
};
|
62
|
+
var version_exports = {};
|
63
|
+
__export(version_exports, {
|
64
|
+
getPnpmVersion: () => getPnpmVersion,
|
65
|
+
isReact18: () => isReact18
|
66
|
+
});
|
67
|
+
module.exports = __toCommonJS(version_exports);
|
68
|
+
var import_path = __toESM(require("path"));
|
69
|
+
var import_compiled = require("./compiled");
|
70
|
+
function getPnpmVersion() {
|
71
|
+
return __async(this, null, function* () {
|
72
|
+
const { stdout } = yield (0, import_compiled.execa)("pnpm", ["--version"]);
|
73
|
+
return stdout;
|
74
|
+
});
|
75
|
+
}
|
76
|
+
const isReact18 = (cwd) => {
|
77
|
+
const pkgPath = import_path.default.join(cwd, "package.json");
|
78
|
+
if (!import_compiled.fs.existsSync(pkgPath)) {
|
79
|
+
return false;
|
80
|
+
}
|
81
|
+
const pkgInfo = JSON.parse(import_compiled.fs.readFileSync(pkgPath, "utf8"));
|
82
|
+
const deps = __spreadValues(__spreadValues({}, pkgInfo.devDependencies), pkgInfo.dependencies);
|
83
|
+
if (typeof deps.react !== "string") {
|
84
|
+
return false;
|
85
|
+
}
|
86
|
+
return import_compiled.semver.satisfies(import_compiled.semver.minVersion(deps.react), ">=18.0.0");
|
87
|
+
};
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
89
|
+
0 && (module.exports = {
|
90
|
+
getPnpmVersion,
|
91
|
+
isReact18
|
92
|
+
});
|
package/dist/wait.d.ts
ADDED
package/dist/wait.js
ADDED
@@ -0,0 +1,29 @@
|
|
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 wait_exports = {};
|
19
|
+
__export(wait_exports, {
|
20
|
+
wait: () => wait
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(wait_exports);
|
23
|
+
const wait = (time = 0) => new Promise((resolve) => {
|
24
|
+
setTimeout(resolve, time);
|
25
|
+
});
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
27
|
+
0 && (module.exports = {
|
28
|
+
wait
|
29
|
+
});
|
package/dist/watch.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
export type WatchChangeTypeValueT = 'add' | 'unlink' | 'change';
|
2
|
+
export declare const WatchChangeType: Record<'ADD' | 'UNLINK' | 'CHANGE', WatchChangeTypeValueT>;
|
3
|
+
type RunTaskType = (option: {
|
4
|
+
changedFilePath: string;
|
5
|
+
changeType: WatchChangeTypeValueT;
|
6
|
+
}) => void | Promise<void>;
|
7
|
+
export declare const watch: (watchDir: string | string[], runTask: RunTaskType, ignored?: string[]) => import("./compiled").FSWatcher;
|
8
|
+
export {};
|