@modern-js/utils 2.15.0 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/FileSizeReporter.js +69 -92
- package/dist/cjs/alias.js +34 -58
- package/dist/cjs/analyzeProject.js +58 -41
- package/dist/cjs/applyOptionsChain.js +15 -42
- package/dist/cjs/babel.js +28 -39
- package/dist/cjs/chainId.js +7 -25
- package/dist/cjs/clearConsole.js +7 -25
- package/dist/cjs/commands.js +14 -29
- package/dist/cjs/compatRequire.js +22 -38
- package/dist/cjs/compiled.js +120 -139
- package/dist/cjs/constants.js +143 -98
- package/dist/cjs/debug.js +8 -26
- package/dist/cjs/emptyDir.js +10 -28
- package/dist/cjs/ensureAbsolutePath.js +13 -36
- package/dist/cjs/ensureArray.js +10 -26
- package/dist/cjs/findExists.js +14 -37
- package/dist/cjs/generateMetaTags.js +12 -31
- package/dist/cjs/getBrowserslist.js +20 -27
- package/dist/cjs/getCoreJsVersion.js +49 -37
- package/dist/cjs/getEntryOptions.js +14 -29
- package/dist/cjs/getPackageManager.js +23 -46
- package/dist/cjs/getPort.js +26 -61
- package/dist/cjs/getServerConfig.js +51 -43
- package/dist/cjs/getTargetDir.js +50 -38
- package/dist/cjs/import.js +16 -27
- package/dist/cjs/index.js +61 -60
- package/dist/cjs/is/index.js +53 -68
- package/dist/cjs/is/nodeEnv.js +13 -29
- package/dist/cjs/is/platform.js +13 -26
- package/dist/cjs/is/type.js +14 -33
- package/dist/cjs/logger.js +54 -50
- package/dist/cjs/monorepo.js +47 -78
- package/dist/cjs/nodeEnv.js +29 -31
- package/dist/cjs/path.js +42 -63
- package/dist/cjs/pathSerializer.js +43 -51
- package/dist/cjs/plugin.js +11 -29
- package/dist/cjs/prettyInstructions.js +35 -68
- package/dist/cjs/printBuildError.js +15 -37
- package/dist/cjs/react.js +18 -41
- package/dist/cjs/readTsConfig.js +21 -39
- package/dist/cjs/removeSlash.js +13 -27
- package/dist/cjs/resolve.js +25 -31
- package/dist/cjs/routes.js +23 -43
- package/dist/cjs/runtime/index.js +18 -17
- package/dist/cjs/runtime/parsed.js +8 -26
- package/dist/cjs/runtimeExports.js +31 -56
- package/dist/cjs/ssr.js +13 -26
- package/dist/cjs/storage.js +51 -41
- package/dist/cjs/testUtils.js +8 -29
- package/dist/cjs/types.js +4 -15
- package/dist/cjs/universal/constants.js +13 -26
- package/dist/cjs/universal/formatWebpack.js +16 -44
- package/dist/cjs/universal/nestedRoutes.js +94 -46
- package/dist/cjs/universal/pluginDagSort.js +58 -0
- package/dist/cjs/universal/remixRouter.js +18 -17
- package/dist/cjs/universal/serialize.js +16 -37
- package/dist/cjs/version.js +25 -41
- package/dist/cjs/wait.js +7 -25
- package/dist/cjs/watch.js +69 -43
- package/dist/esm/FileSizeReporter.js +40 -52
- package/dist/esm/alias.js +9 -19
- package/dist/esm/analyzeProject.js +3 -7
- package/dist/esm/applyOptionsChain.js +5 -17
- package/dist/esm/babel.js +6 -8
- package/dist/esm/chainId.js +1 -4
- package/dist/esm/clearConsole.js +1 -4
- package/dist/esm/commands.js +6 -12
- package/dist/esm/compatRequire.js +10 -17
- package/dist/esm/compiled.js +32 -76
- package/dist/esm/constants.js +143 -89
- package/dist/esm/debug.js +1 -4
- package/dist/esm/emptyDir.js +1 -4
- package/dist/esm/ensureAbsolutePath.js +1 -4
- package/dist/esm/ensureArray.js +4 -5
- package/dist/esm/findExists.js +1 -4
- package/dist/esm/generateMetaTags.js +6 -10
- package/dist/esm/getBrowserslist.js +8 -6
- package/dist/esm/getCoreJsVersion.js +1 -4
- package/dist/esm/getEntryOptions.js +5 -5
- package/dist/esm/getPackageManager.js +1 -4
- package/dist/esm/getPort.js +10 -25
- package/dist/esm/getServerConfig.js +2 -9
- package/dist/esm/getTargetDir.js +1 -4
- package/dist/esm/import.js +3 -4
- package/dist/esm/is/index.js +18 -30
- package/dist/esm/is/nodeEnv.js +5 -12
- package/dist/esm/is/platform.js +2 -6
- package/dist/esm/is/type.js +8 -18
- package/dist/esm/logger.js +37 -17
- package/dist/esm/monorepo.js +21 -38
- package/dist/esm/nodeEnv.js +18 -11
- package/dist/esm/path.js +16 -23
- package/dist/esm/pathSerializer.js +21 -21
- package/dist/esm/plugin.js +1 -4
- package/dist/esm/prettyInstructions.js +13 -32
- package/dist/esm/printBuildError.js +4 -11
- package/dist/esm/react.js +1 -4
- package/dist/esm/readTsConfig.js +2 -6
- package/dist/esm/removeSlash.js +3 -8
- package/dist/esm/resolve.js +14 -11
- package/dist/esm/routes.js +4 -10
- package/dist/esm/runtime/parsed.js +2 -5
- package/dist/esm/runtimeExports.js +17 -22
- package/dist/esm/ssr.js +1 -4
- package/dist/esm/storage.js +2 -6
- package/dist/esm/testUtils.js +2 -8
- package/dist/esm/types.js +1 -0
- package/dist/esm/universal/constants.js +2 -6
- package/dist/esm/universal/formatWebpack.js +10 -22
- package/dist/esm/universal/nestedRoutes.js +41 -27
- package/dist/esm/universal/pluginDagSort.js +50 -0
- package/dist/esm/universal/serialize.js +4 -5
- package/dist/esm/version.js +5 -7
- package/dist/esm/wait.js +1 -3
- package/dist/esm/watch.js +14 -9
- package/dist/types/universal/pluginDagSort.d.ts +1 -0
- package/package.json +17 -5
package/dist/cjs/index.js
CHANGED
|
@@ -1,60 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./compiled"), exports);
|
|
6
|
+
_export_star(require("./commands"), exports);
|
|
7
|
+
_export_star(require("./FileSizeReporter"), exports);
|
|
8
|
+
_export_star(require("./printBuildError"), exports);
|
|
9
|
+
_export_star(require("./debug"), exports);
|
|
10
|
+
_export_star(require("./findExists"), exports);
|
|
11
|
+
_export_star(require("./is"), exports);
|
|
12
|
+
_export_star(require("./compatRequire"), exports);
|
|
13
|
+
_export_star(require("./logger"), exports);
|
|
14
|
+
_export_star(require("./constants"), exports);
|
|
15
|
+
_export_star(require("./ensureArray"), exports);
|
|
16
|
+
_export_star(require("./ensureAbsolutePath"), exports);
|
|
17
|
+
_export_star(require("./clearConsole"), exports);
|
|
18
|
+
_export_star(require("./applyOptionsChain"), exports);
|
|
19
|
+
_export_star(require("./getBrowserslist"), exports);
|
|
20
|
+
_export_star(require("./removeSlash"), exports);
|
|
21
|
+
_export_star(require("./getEntryOptions"), exports);
|
|
22
|
+
_export_star(require("./getPort"), exports);
|
|
23
|
+
_export_star(require("./monorepo"), exports);
|
|
24
|
+
_export_star(require("./getPackageManager"), exports);
|
|
25
|
+
_export_star(require("./runtimeExports"), exports);
|
|
26
|
+
_export_star(require("./readTsConfig"), exports);
|
|
27
|
+
_export_star(require("./path"), exports);
|
|
28
|
+
_export_star(require("./pathSerializer"), exports);
|
|
29
|
+
_export_star(require("./generateMetaTags"), exports);
|
|
30
|
+
_export_star(require("./prettyInstructions"), exports);
|
|
31
|
+
_export_star(require("./alias"), exports);
|
|
32
|
+
_export_star(require("./import"), exports);
|
|
33
|
+
_export_star(require("./watch"), exports);
|
|
34
|
+
_export_star(require("./nodeEnv"), exports);
|
|
35
|
+
_export_star(require("./wait"), exports);
|
|
36
|
+
_export_star(require("./emptyDir"), exports);
|
|
37
|
+
_export_star(require("./getServerConfig"), exports);
|
|
38
|
+
_export_star(require("./resolve"), exports);
|
|
39
|
+
_export_star(require("./analyzeProject"), exports);
|
|
40
|
+
_export_star(require("./chainId"), exports);
|
|
41
|
+
_export_star(require("./version"), exports);
|
|
42
|
+
_export_star(require("./plugin"), exports);
|
|
43
|
+
_export_star(require("./routes"), exports);
|
|
44
|
+
_export_star(require("./testUtils"), exports);
|
|
45
|
+
_export_star(require("./getCoreJsVersion"), exports);
|
|
46
|
+
_export_star(require("./react"), exports);
|
|
47
|
+
_export_star(require("./getTargetDir"), exports);
|
|
48
|
+
_export_star(require("./babel"), exports);
|
|
49
|
+
function _export_star(from, to) {
|
|
50
|
+
Object.keys(from).forEach(function(k) {
|
|
51
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
52
|
+
Object.defineProperty(to, k, {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
get: function() {
|
|
55
|
+
return from[k];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return from;
|
|
61
|
+
}
|
package/dist/cjs/is/index.js
CHANGED
|
@@ -1,56 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var is_exports = {};
|
|
30
|
-
__export(is_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
31
13
|
isDepExists: () => isDepExists,
|
|
14
|
+
isTypescript: () => isTypescript,
|
|
32
15
|
isEmpty: () => isEmpty,
|
|
16
|
+
isSSR: () => isSSR,
|
|
17
|
+
isUseSSRBundle: () => isUseSSRBundle,
|
|
18
|
+
isServiceWorker: () => isServiceWorker,
|
|
33
19
|
isFastRefresh: () => isFastRefresh,
|
|
34
20
|
isRouterV5: () => isRouterV5,
|
|
35
21
|
isSSGEntry: () => isSSGEntry,
|
|
36
|
-
|
|
37
|
-
isServiceWorker: () => isServiceWorker,
|
|
38
|
-
isSingleEntry: () => isSingleEntry,
|
|
39
|
-
isTypescript: () => isTypescript,
|
|
40
|
-
isUseSSRBundle: () => isUseSSRBundle
|
|
22
|
+
isSingleEntry: () => isSingleEntry
|
|
41
23
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
24
|
+
const _fs = /* @__PURE__ */ _interop_require_default(require("fs"));
|
|
25
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
26
|
+
const _debug = require("../debug");
|
|
27
|
+
const _nodeEnv = _export_star(require("./nodeEnv"), exports);
|
|
28
|
+
_export_star(require("./platform"), exports);
|
|
29
|
+
_export_star(require("./type"), exports);
|
|
30
|
+
function _export_star(from, to) {
|
|
31
|
+
Object.keys(from).forEach(function(k) {
|
|
32
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
33
|
+
Object.defineProperty(to, k, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function() {
|
|
36
|
+
return from[k];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return from;
|
|
42
|
+
}
|
|
43
|
+
function _interop_require_default(obj) {
|
|
44
|
+
return obj && obj.__esModule ? obj : {
|
|
45
|
+
default: obj
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const debug = (0, _debug.createDebugger)("judge-depExists");
|
|
51
49
|
const isDepExists = (appDirectory, name) => {
|
|
52
|
-
const pkgPath =
|
|
53
|
-
if (!
|
|
50
|
+
const pkgPath = _path.default.resolve(appDirectory, "./package.json");
|
|
51
|
+
if (!_fs.default.existsSync(pkgPath)) {
|
|
54
52
|
debug(`can't find package.json under: %s`, appDirectory);
|
|
55
53
|
return false;
|
|
56
54
|
}
|
|
@@ -58,14 +56,14 @@ const isDepExists = (appDirectory, name) => {
|
|
|
58
56
|
const { dependencies = {}, devDependencies = {} } = json;
|
|
59
57
|
return dependencies.hasOwnProperty(name) || devDependencies.hasOwnProperty(name);
|
|
60
58
|
};
|
|
61
|
-
const isTypescript = (root) =>
|
|
59
|
+
const isTypescript = (root) => _fs.default.existsSync(_path.default.resolve(root, "./tsconfig.json"));
|
|
62
60
|
const isEmpty = (o) => Object.entries(o).length === 0 && o.constructor === Object;
|
|
63
61
|
const isSSR = (config) => {
|
|
64
62
|
const { server } = config;
|
|
65
|
-
if (server
|
|
63
|
+
if (server === null || server === void 0 ? void 0 : server.ssr) {
|
|
66
64
|
return true;
|
|
67
65
|
}
|
|
68
|
-
if ((server
|
|
66
|
+
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
|
|
69
67
|
for (const name of Object.keys(server.ssrByEntries)) {
|
|
70
68
|
if (server.ssrByEntries[name]) {
|
|
71
69
|
return true;
|
|
@@ -76,40 +74,27 @@ const isSSR = (config) => {
|
|
|
76
74
|
};
|
|
77
75
|
const isUseSSRBundle = (config) => {
|
|
78
76
|
const { output } = config;
|
|
79
|
-
if (output
|
|
77
|
+
if (output === null || output === void 0 ? void 0 : output.ssg) {
|
|
80
78
|
return true;
|
|
81
79
|
}
|
|
82
80
|
return isSSR(config);
|
|
83
81
|
};
|
|
84
82
|
const isServiceWorker = (config) => {
|
|
85
|
-
var
|
|
83
|
+
var _deploy_worker;
|
|
86
84
|
const { output, deploy } = config;
|
|
87
|
-
if ((
|
|
85
|
+
if ((deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && ((output === null || output === void 0 ? void 0 : output.ssg) || isSSR(config))) {
|
|
88
86
|
return true;
|
|
89
87
|
}
|
|
90
88
|
return false;
|
|
91
89
|
};
|
|
92
|
-
const isFastRefresh = () => (0,
|
|
90
|
+
const isFastRefresh = () => (0, _nodeEnv.isDev)() && process.env.FAST_REFRESH !== "false";
|
|
93
91
|
const isRouterV5 = (config) => {
|
|
94
|
-
var
|
|
95
|
-
return typeof ((
|
|
92
|
+
var _config_runtime, _config_runtime1, _config_runtime_router;
|
|
93
|
+
return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
|
|
96
94
|
};
|
|
97
95
|
const isSSGEntry = (config, entryName, entrypoints) => {
|
|
98
96
|
const ssgConfig = config.output.ssg;
|
|
99
|
-
const useSSG = isSingleEntry(entrypoints) ? Boolean(ssgConfig) : ssgConfig === true || typeof (ssgConfig
|
|
97
|
+
const useSSG = isSingleEntry(entrypoints) ? Boolean(ssgConfig) : ssgConfig === true || typeof (ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[0]) === "function" || Boolean(ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[entryName]);
|
|
100
98
|
return useSSG;
|
|
101
99
|
};
|
|
102
100
|
const isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
|
|
103
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
-
0 && (module.exports = {
|
|
105
|
-
isDepExists,
|
|
106
|
-
isEmpty,
|
|
107
|
-
isFastRefresh,
|
|
108
|
-
isRouterV5,
|
|
109
|
-
isSSGEntry,
|
|
110
|
-
isSSR,
|
|
111
|
-
isServiceWorker,
|
|
112
|
-
isSingleEntry,
|
|
113
|
-
isTypescript,
|
|
114
|
-
isUseSSRBundle
|
|
115
|
-
});
|
package/dist/cjs/is/nodeEnv.js
CHANGED
|
@@ -1,39 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
6
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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 nodeEnv_exports = {};
|
|
19
|
-
__export(nodeEnv_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
20
13
|
getNodeEnv: () => getNodeEnv,
|
|
21
14
|
isDev: () => isDev,
|
|
22
15
|
isProd: () => isProd,
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
isTest: () => isTest,
|
|
17
|
+
isProdProfile: () => isProdProfile
|
|
25
18
|
});
|
|
26
|
-
module.exports = __toCommonJS(nodeEnv_exports);
|
|
27
19
|
const getNodeEnv = () => process.env.NODE_ENV || "development";
|
|
28
20
|
const isDev = () => getNodeEnv() === "development";
|
|
29
21
|
const isProd = () => getNodeEnv() === "production";
|
|
30
22
|
const isTest = () => getNodeEnv() === "test";
|
|
31
23
|
const isProdProfile = () => isProd() && process.argv.includes("--profile");
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
getNodeEnv,
|
|
35
|
-
isDev,
|
|
36
|
-
isProd,
|
|
37
|
-
isProdProfile,
|
|
38
|
-
isTest
|
|
39
|
-
});
|
package/dist/cjs/is/platform.js
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
6
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var platform_exports = {};
|
|
19
|
-
__export(platform_exports, {
|
|
20
|
-
isBrowser: () => isBrowser,
|
|
21
|
-
isNodeJS: () => isNodeJS
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
isNodeJS: () => isNodeJS,
|
|
14
|
+
isBrowser: () => isBrowser
|
|
22
15
|
});
|
|
23
|
-
module.exports = __toCommonJS(platform_exports);
|
|
24
16
|
const isNodeJS = () => typeof process !== "undefined" && process.versions != null && process.versions.node != null && process.versions.electron == null;
|
|
25
17
|
const isBrowser = () => typeof window !== "undefined";
|
|
26
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
-
0 && (module.exports = {
|
|
28
|
-
isBrowser,
|
|
29
|
-
isNodeJS
|
|
30
|
-
});
|
package/dist/cjs/is/type.js
CHANGED
|
@@ -1,32 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
6
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var type_exports = {};
|
|
19
|
-
__export(type_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
isString: () => isString,
|
|
14
|
+
isUndefined: () => isUndefined,
|
|
20
15
|
isArray: () => isArray,
|
|
21
16
|
isFunction: () => isFunction,
|
|
22
17
|
isObject: () => isObject,
|
|
23
18
|
isPlainObject: () => isPlainObject,
|
|
24
19
|
isPromise: () => isPromise,
|
|
25
|
-
isRegExp: () => isRegExp
|
|
26
|
-
isString: () => isString,
|
|
27
|
-
isUndefined: () => isUndefined
|
|
20
|
+
isRegExp: () => isRegExp
|
|
28
21
|
});
|
|
29
|
-
module.exports = __toCommonJS(type_exports);
|
|
30
22
|
function isString(str) {
|
|
31
23
|
return typeof str === "string";
|
|
32
24
|
}
|
|
@@ -51,14 +43,3 @@ function isPromise(obj) {
|
|
|
51
43
|
function isRegExp(obj) {
|
|
52
44
|
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
|
53
45
|
}
|
|
54
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
-
0 && (module.exports = {
|
|
56
|
-
isArray,
|
|
57
|
-
isFunction,
|
|
58
|
-
isObject,
|
|
59
|
-
isPlainObject,
|
|
60
|
-
isPromise,
|
|
61
|
-
isRegExp,
|
|
62
|
-
isString,
|
|
63
|
-
isUndefined
|
|
64
|
-
});
|
package/dist/cjs/logger.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
8
6
|
for (var name in all)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 logger_exports = {};
|
|
29
|
-
__export(logger_exports, {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
30
13
|
Logger: () => Logger,
|
|
31
14
|
logger: () => logger
|
|
32
15
|
});
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
const _chalk = /* @__PURE__ */ _interop_require_default(require("../compiled/chalk"));
|
|
17
|
+
function _define_property(obj, key, value) {
|
|
18
|
+
if (key in obj) {
|
|
19
|
+
Object.defineProperty(obj, key, {
|
|
20
|
+
value,
|
|
21
|
+
enumerable: true,
|
|
22
|
+
configurable: true,
|
|
23
|
+
writable: true
|
|
24
|
+
});
|
|
25
|
+
} else {
|
|
26
|
+
obj[key] = value;
|
|
27
|
+
}
|
|
28
|
+
return obj;
|
|
29
|
+
}
|
|
30
|
+
function _interop_require_default(obj) {
|
|
31
|
+
return obj && obj.__esModule ? obj : {
|
|
32
|
+
default: obj
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
35
|
const LOG_LEVEL = {
|
|
36
36
|
error: 0,
|
|
37
37
|
warn: 1,
|
|
@@ -65,25 +65,15 @@ const LOG_TYPES = {
|
|
|
65
65
|
label: "debug",
|
|
66
66
|
level: "debug"
|
|
67
67
|
},
|
|
68
|
-
log: {
|
|
68
|
+
log: {
|
|
69
|
+
level: "log"
|
|
70
|
+
}
|
|
69
71
|
};
|
|
70
72
|
const DEFAULT_CONFIG = {
|
|
71
73
|
displayLabel: true,
|
|
72
74
|
uppercaseLabel: false
|
|
73
75
|
};
|
|
74
76
|
class Logger {
|
|
75
|
-
constructor(options = {}) {
|
|
76
|
-
this.level = options.level || LOG_TYPES.log.level;
|
|
77
|
-
this.config = { ...DEFAULT_CONFIG, ...options.config || {} };
|
|
78
|
-
this.types = {
|
|
79
|
-
...LOG_TYPES,
|
|
80
|
-
...options.types || {}
|
|
81
|
-
};
|
|
82
|
-
this.longestLabel = this.getLongestLabel();
|
|
83
|
-
Object.keys(this.types).forEach((type) => {
|
|
84
|
-
this[type] = this._log.bind(this, type);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
77
|
_log(type, message, ...args) {
|
|
88
78
|
if (message === void 0 || message === null) {
|
|
89
79
|
console.log();
|
|
@@ -98,13 +88,13 @@ class Logger {
|
|
|
98
88
|
if (this.config.displayLabel && logType.label) {
|
|
99
89
|
label = this.config.uppercaseLabel ? logType.label.toUpperCase() : logType.label;
|
|
100
90
|
label = label.padEnd(this.longestLabel.length);
|
|
101
|
-
label =
|
|
91
|
+
label = _chalk.default.bold(logType.color ? _chalk.default[logType.color](label) : label);
|
|
102
92
|
}
|
|
103
93
|
if (message instanceof Error) {
|
|
104
94
|
if (message.stack) {
|
|
105
95
|
const [name, ...rest] = message.stack.split("\n");
|
|
106
96
|
text = `${name}
|
|
107
|
-
${
|
|
97
|
+
${_chalk.default.grey(rest.join("\n"))}`;
|
|
108
98
|
} else {
|
|
109
99
|
text = message.message;
|
|
110
100
|
}
|
|
@@ -124,11 +114,25 @@ ${import_chalk.default.grey(rest.join("\n"))}`;
|
|
|
124
114
|
});
|
|
125
115
|
return longestLabel;
|
|
126
116
|
}
|
|
117
|
+
constructor(options = {}) {
|
|
118
|
+
_define_property(this, "level", void 0);
|
|
119
|
+
_define_property(this, "config", void 0);
|
|
120
|
+
_define_property(this, "types", void 0);
|
|
121
|
+
_define_property(this, "longestLabel", void 0);
|
|
122
|
+
this.level = options.level || LOG_TYPES.log.level;
|
|
123
|
+
this.config = {
|
|
124
|
+
...DEFAULT_CONFIG,
|
|
125
|
+
...options.config || {}
|
|
126
|
+
};
|
|
127
|
+
this.types = {
|
|
128
|
+
...LOG_TYPES,
|
|
129
|
+
...options.types || {}
|
|
130
|
+
};
|
|
131
|
+
this.longestLabel = this.getLongestLabel();
|
|
132
|
+
Object.keys(this.types).forEach((type) => {
|
|
133
|
+
this[type] = this._log.bind(this, type);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
127
136
|
}
|
|
128
137
|
const logger = new Logger();
|
|
129
138
|
logger.Logger = Logger;
|
|
130
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
131
|
-
0 && (module.exports = {
|
|
132
|
-
Logger,
|
|
133
|
-
logger
|
|
134
|
-
});
|