@modern-js/utils 2.22.0 → 2.22.1-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/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/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 +3 -3
@@ -0,0 +1,112 @@
|
|
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 prettyInstructions_exports = {};
|
29
|
+
__export(prettyInstructions_exports, {
|
30
|
+
getAddressUrls: () => getAddressUrls,
|
31
|
+
getIpv4Interfaces: () => getIpv4Interfaces,
|
32
|
+
prettyInstructions: () => prettyInstructions
|
33
|
+
});
|
34
|
+
module.exports = __toCommonJS(prettyInstructions_exports);
|
35
|
+
var import_os = __toESM(require("os"));
|
36
|
+
var import_compiled = require("./compiled");
|
37
|
+
var import_is = require("./is");
|
38
|
+
const normalizeUrl = (url) => url.replace(/([^:]\/)\/+/g, "$1");
|
39
|
+
const getIpv4Interfaces = () => {
|
40
|
+
const interfaces = import_os.default.networkInterfaces();
|
41
|
+
const ipv4Interfaces = [];
|
42
|
+
Object.keys(interfaces).forEach((key) => {
|
43
|
+
interfaces[key].forEach((detail) => {
|
44
|
+
const familyV4Value = typeof detail.family === "string" ? "IPv4" : 4;
|
45
|
+
if (detail.family === familyV4Value) {
|
46
|
+
ipv4Interfaces.push(detail);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
});
|
50
|
+
return ipv4Interfaces;
|
51
|
+
};
|
52
|
+
const getAddressUrls = (protocol = "http", port) => {
|
53
|
+
const ipv4Interfaces = getIpv4Interfaces();
|
54
|
+
return ipv4Interfaces.reduce((memo, detail) => {
|
55
|
+
let label = "Network: ";
|
56
|
+
let url = `${protocol}://${detail.address}:${port}`;
|
57
|
+
if (detail.address.includes(`localhost`) || detail.internal) {
|
58
|
+
label = "Local: ";
|
59
|
+
url = `${protocol}://localhost:${port}`;
|
60
|
+
}
|
61
|
+
memo.push({ label, url });
|
62
|
+
return memo;
|
63
|
+
}, []);
|
64
|
+
};
|
65
|
+
const prettyInstructions = (appContext, config) => {
|
66
|
+
const { entrypoints, serverRoutes, port, apiOnly, checkedEntries } = appContext;
|
67
|
+
const urls = getAddressUrls(
|
68
|
+
config.dev.https && (0, import_is.isDev)() ? "https" : "http",
|
69
|
+
port
|
70
|
+
);
|
71
|
+
const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
|
72
|
+
let message = "App running at:\n\n";
|
73
|
+
if ((0, import_is.isSingleEntry)(entrypoints) || apiOnly) {
|
74
|
+
message += urls.map(
|
75
|
+
({ label, url }) => ` ${import_compiled.chalk.bold(`> ${label.padEnd(10)}`)}${import_compiled.chalk.cyanBright(
|
76
|
+
normalizeUrl(`${url}/${routes[0].urlPath}`)
|
77
|
+
)}
|
78
|
+
`
|
79
|
+
).join("");
|
80
|
+
} else {
|
81
|
+
const maxNameLength = Math.max(...routes.map((r) => r.entryName.length));
|
82
|
+
urls.forEach(({ label, url }) => {
|
83
|
+
message += ` ${import_compiled.chalk.bold(`> ${label}`)}
|
84
|
+
`;
|
85
|
+
routes.forEach(({ entryName, urlPath, isSSR }) => {
|
86
|
+
if (!checkedEntries.includes(entryName)) {
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
message += ` ${import_compiled.chalk.yellowBright(
|
90
|
+
isSSR ? "λ" : "○"
|
91
|
+
)} ${import_compiled.chalk.yellowBright(
|
92
|
+
entryName.padEnd(maxNameLength + 8)
|
93
|
+
)}${import_compiled.chalk.cyanBright(normalizeUrl(`${url}/${urlPath}`))}
|
94
|
+
`;
|
95
|
+
});
|
96
|
+
});
|
97
|
+
message += "\n";
|
98
|
+
message += import_compiled.chalk.cyanBright(
|
99
|
+
" λ (Server) server-side renders at runtime\n"
|
100
|
+
);
|
101
|
+
message += import_compiled.chalk.cyanBright(
|
102
|
+
" ○ (Static) client-side renders as static HTML\n"
|
103
|
+
);
|
104
|
+
}
|
105
|
+
return message;
|
106
|
+
};
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
108
|
+
0 && (module.exports = {
|
109
|
+
getAddressUrls,
|
110
|
+
getIpv4Interfaces,
|
111
|
+
prettyInstructions
|
112
|
+
});
|
@@ -0,0 +1,8 @@
|
|
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
|
+
export declare function printBuildError(err: Error): void;
|
@@ -0,0 +1,57 @@
|
|
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 printBuildError_exports = {};
|
19
|
+
__export(printBuildError_exports, {
|
20
|
+
printBuildError: () => printBuildError
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(printBuildError_exports);
|
23
|
+
var import_compiled = require("./compiled");
|
24
|
+
var import_logger = require("./logger");
|
25
|
+
function printBuildError(err) {
|
26
|
+
const message = err != null && err.message;
|
27
|
+
const stack = err != null && err.stack;
|
28
|
+
if (stack && typeof message === "string" && message.indexOf("from Terser") !== -1) {
|
29
|
+
try {
|
30
|
+
const matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack);
|
31
|
+
if (!matched) {
|
32
|
+
throw new Error("Using errors for control flow is bad.");
|
33
|
+
}
|
34
|
+
const problemPath = matched[2];
|
35
|
+
const line = matched[3];
|
36
|
+
const column = matched[4];
|
37
|
+
import_logger.logger.error(
|
38
|
+
`Failed to minify the code from this file:
|
39
|
+
|
40
|
+
${import_compiled.chalk.yellow(
|
41
|
+
` ${problemPath}:${line}${column !== "0" ? ":" + column : ""}`
|
42
|
+
)}
|
43
|
+
`
|
44
|
+
);
|
45
|
+
} catch (ignored) {
|
46
|
+
import_logger.logger.error(`Failed to minify the bundle. ${err}
|
47
|
+
`);
|
48
|
+
}
|
49
|
+
} else {
|
50
|
+
import_logger.logger.error((message || err) + "\n");
|
51
|
+
}
|
52
|
+
import_logger.logger.log();
|
53
|
+
}
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
55
|
+
0 && (module.exports = {
|
56
|
+
printBuildError
|
57
|
+
});
|
package/dist/react.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isBeyondReact17: (cwd: string) => boolean;
|
package/dist/react.js
ADDED
@@ -0,0 +1,64 @@
|
|
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 react_exports = {};
|
43
|
+
__export(react_exports, {
|
44
|
+
isBeyondReact17: () => isBeyondReact17
|
45
|
+
});
|
46
|
+
module.exports = __toCommonJS(react_exports);
|
47
|
+
var import_path = __toESM(require("path"));
|
48
|
+
var import__ = require(".");
|
49
|
+
const isBeyondReact17 = (cwd) => {
|
50
|
+
const pkgPath = import_path.default.join(cwd, "package.json");
|
51
|
+
if (!import__.fs.existsSync(pkgPath)) {
|
52
|
+
return false;
|
53
|
+
}
|
54
|
+
const pkgInfo = JSON.parse(import__.fs.readFileSync(pkgPath, "utf8"));
|
55
|
+
const deps = __spreadValues(__spreadValues({}, pkgInfo.devDependencies), pkgInfo.dependencies);
|
56
|
+
if (typeof deps.react !== "string") {
|
57
|
+
return false;
|
58
|
+
}
|
59
|
+
return import__.semver.satisfies(import__.semver.minVersion(deps.react), ">=17.0.0");
|
60
|
+
};
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
62
|
+
0 && (module.exports = {
|
63
|
+
isBeyondReact17
|
64
|
+
});
|
@@ -0,0 +1,47 @@
|
|
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 readTsConfig_exports = {};
|
29
|
+
__export(readTsConfig_exports, {
|
30
|
+
readTsConfig: () => readTsConfig,
|
31
|
+
readTsConfigByFile: () => readTsConfigByFile
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(readTsConfig_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_compiled = require("./compiled");
|
36
|
+
const readTsConfig = (root) => {
|
37
|
+
return readTsConfigByFile(import_path.default.resolve(root, "./tsconfig.json"));
|
38
|
+
};
|
39
|
+
const readTsConfigByFile = (filename) => {
|
40
|
+
const content = import_compiled.fs.readFileSync(import_path.default.resolve(filename), "utf-8");
|
41
|
+
return import_compiled.json5.parse(content);
|
42
|
+
};
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
44
|
+
0 && (module.exports = {
|
45
|
+
readTsConfig,
|
46
|
+
readTsConfigByFile
|
47
|
+
});
|
@@ -0,0 +1,33 @@
|
|
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 removeSlash_exports = {};
|
19
|
+
__export(removeSlash_exports, {
|
20
|
+
removeLeadingSlash: () => removeLeadingSlash,
|
21
|
+
removeSlash: () => removeSlash,
|
22
|
+
removeTailSlash: () => removeTailSlash
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(removeSlash_exports);
|
25
|
+
const removeLeadingSlash = (s) => s.replace(/^\/+/, "");
|
26
|
+
const removeTailSlash = (s) => s.replace(/\/+$/, "");
|
27
|
+
const removeSlash = (s) => removeLeadingSlash(removeTailSlash(s));
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
29
|
+
0 && (module.exports = {
|
30
|
+
removeLeadingSlash,
|
31
|
+
removeSlash,
|
32
|
+
removeTailSlash
|
33
|
+
});
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Try to resolve npm package entry file path.
|
3
|
+
* @param name - Package name.
|
4
|
+
* @param resolvePath - Path to resolve dependencies.
|
5
|
+
* @returns Resolved file path.
|
6
|
+
*/
|
7
|
+
export declare const tryResolve: (name: string, resolvePath: string) => string;
|
8
|
+
/**
|
9
|
+
* Try to resolve npm package, return true if package is installed.
|
10
|
+
*/
|
11
|
+
|
12
|
+
export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
|
13
|
+
export declare const getAntdMajorVersion: (appDirectory: string) => number | null;
|
package/dist/resolve.js
ADDED
@@ -0,0 +1,63 @@
|
|
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 resolve_exports = {};
|
19
|
+
__export(resolve_exports, {
|
20
|
+
getAntdMajorVersion: () => getAntdMajorVersion,
|
21
|
+
isPackageInstalled: () => isPackageInstalled,
|
22
|
+
tryResolve: () => tryResolve
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(resolve_exports);
|
25
|
+
var import_ensureArray = require("./ensureArray");
|
26
|
+
const tryResolve = (name, resolvePath) => {
|
27
|
+
let filePath = "";
|
28
|
+
try {
|
29
|
+
filePath = require.resolve(name, { paths: [resolvePath] });
|
30
|
+
delete require.cache[filePath];
|
31
|
+
} catch (err) {
|
32
|
+
if (err.code === "MODULE_NOT_FOUND") {
|
33
|
+
throw new Error(`Can not find module ${name}.`);
|
34
|
+
}
|
35
|
+
throw err;
|
36
|
+
}
|
37
|
+
return filePath;
|
38
|
+
};
|
39
|
+
const isPackageInstalled = (name, resolvePaths) => {
|
40
|
+
try {
|
41
|
+
require.resolve(name, { paths: (0, import_ensureArray.ensureArray)(resolvePaths) });
|
42
|
+
return true;
|
43
|
+
} catch (err) {
|
44
|
+
return false;
|
45
|
+
}
|
46
|
+
};
|
47
|
+
const getAntdMajorVersion = (appDirectory) => {
|
48
|
+
try {
|
49
|
+
const pkgJsonPath = require.resolve("antd/package.json", {
|
50
|
+
paths: [appDirectory]
|
51
|
+
});
|
52
|
+
const { version } = require(pkgJsonPath);
|
53
|
+
return Number(version.split(".")[0]);
|
54
|
+
} catch (err) {
|
55
|
+
return null;
|
56
|
+
}
|
57
|
+
};
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
59
|
+
0 && (module.exports = {
|
60
|
+
getAntdMajorVersion,
|
61
|
+
isPackageInstalled,
|
62
|
+
tryResolve
|
63
|
+
});
|
package/dist/routes.d.ts
ADDED
package/dist/routes.js
ADDED
@@ -0,0 +1,58 @@
|
|
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 routes_exports = {};
|
29
|
+
__export(routes_exports, {
|
30
|
+
getPathWithoutExt: () => getPathWithoutExt,
|
31
|
+
getRouteId: () => getRouteId
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(routes_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_path2 = require("./path");
|
36
|
+
var import_constants = require("./constants");
|
37
|
+
const getPathWithoutExt = (filename) => {
|
38
|
+
const extname = import_path.default.extname(filename);
|
39
|
+
return filename.slice(0, -extname.length);
|
40
|
+
};
|
41
|
+
const getRouteId = (componentPath, routesDir, entryName) => {
|
42
|
+
const relativePath = (0, import_path2.normalizeToPosixPath)(
|
43
|
+
import_path.default.relative(routesDir, componentPath)
|
44
|
+
);
|
45
|
+
const pathWithoutExt = getPathWithoutExt(relativePath);
|
46
|
+
let id = ``;
|
47
|
+
if (entryName === import_constants.MAIN_ENTRY_NAME) {
|
48
|
+
id = pathWithoutExt;
|
49
|
+
} else {
|
50
|
+
id = `${entryName}_${pathWithoutExt}`;
|
51
|
+
}
|
52
|
+
return id;
|
53
|
+
};
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
55
|
+
0 && (module.exports = {
|
56
|
+
getPathWithoutExt,
|
57
|
+
getRouteId
|
58
|
+
});
|
@@ -0,0 +1,73 @@
|
|
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 runtimeExports_exports = {};
|
29
|
+
__export(runtimeExports_exports, {
|
30
|
+
createRuntimeExportsUtils: () => createRuntimeExportsUtils
|
31
|
+
});
|
32
|
+
module.exports = __toCommonJS(runtimeExports_exports);
|
33
|
+
var import_path = __toESM(require("path"));
|
34
|
+
var import_compiled = require("./compiled");
|
35
|
+
var import_path2 = require("./path");
|
36
|
+
const memo = (fn) => {
|
37
|
+
const cache = /* @__PURE__ */ new Map();
|
38
|
+
return (...params) => {
|
39
|
+
const stringifiedParams = JSON.stringify(params);
|
40
|
+
const cachedResult = cache.get(stringifiedParams);
|
41
|
+
if (cachedResult) {
|
42
|
+
return cachedResult;
|
43
|
+
}
|
44
|
+
const res = fn(...params);
|
45
|
+
cache.set(stringifiedParams, res);
|
46
|
+
return res;
|
47
|
+
};
|
48
|
+
};
|
49
|
+
const createRuntimeExportsUtils = memo(
|
50
|
+
(pwd = "", namespace = "index") => {
|
51
|
+
const entryExportFile = import_path.default.join(pwd, `.runtime-exports/${namespace}.js`);
|
52
|
+
const addExport = (statement) => {
|
53
|
+
statement = (0, import_path2.normalizeOutputPath)(statement);
|
54
|
+
try {
|
55
|
+
import_compiled.fs.ensureFileSync(entryExportFile);
|
56
|
+
if (!import_compiled.fs.readFileSync(entryExportFile, "utf8").includes(statement)) {
|
57
|
+
import_compiled.fs.appendFileSync(entryExportFile, `${statement}
|
58
|
+
`);
|
59
|
+
}
|
60
|
+
} catch (e) {
|
61
|
+
}
|
62
|
+
};
|
63
|
+
const getPath = () => entryExportFile;
|
64
|
+
return {
|
65
|
+
addExport,
|
66
|
+
getPath
|
67
|
+
};
|
68
|
+
}
|
69
|
+
);
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
71
|
+
0 && (module.exports = {
|
72
|
+
createRuntimeExportsUtils
|
73
|
+
});
|
package/dist/ssr.d.ts
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
|
3
|
+
/**
|
4
|
+
* ssr helpers
|
5
|
+
*/
|
6
|
+
import type { IncomingHttpHeaders } from 'http';
|
7
|
+
declare const run: <O>(context: IncomingHttpHeaders, cb: () => O | Promise<O>) => Promise<O>, useHeaders: () => IncomingHttpHeaders;
|
8
|
+
export { run, useHeaders };
|
package/dist/ssr.js
ADDED
@@ -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 ssr_exports = {};
|
19
|
+
__export(ssr_exports, {
|
20
|
+
run: () => run,
|
21
|
+
useHeaders: () => useHeaders
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(ssr_exports);
|
24
|
+
var import_storage = require("./storage");
|
25
|
+
const { run, useContext: useHeaders } = (0, import_storage.createStorage)();
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
27
|
+
0 && (module.exports = {
|
28
|
+
run,
|
29
|
+
useHeaders
|
30
|
+
});
|