@modern-js/utils 2.15.1-alpha.0 → 2.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/FileSizeReporter.js +69 -92
  3. package/dist/cjs/alias.js +34 -58
  4. package/dist/cjs/analyzeProject.js +58 -41
  5. package/dist/cjs/applyOptionsChain.js +15 -42
  6. package/dist/cjs/babel.js +28 -39
  7. package/dist/cjs/chainId.js +7 -25
  8. package/dist/cjs/clearConsole.js +7 -25
  9. package/dist/cjs/commands.js +14 -29
  10. package/dist/cjs/compatRequire.js +22 -38
  11. package/dist/cjs/compiled.js +120 -139
  12. package/dist/cjs/constants.js +143 -98
  13. package/dist/cjs/debug.js +8 -26
  14. package/dist/cjs/emptyDir.js +10 -28
  15. package/dist/cjs/ensureAbsolutePath.js +13 -36
  16. package/dist/cjs/ensureArray.js +10 -26
  17. package/dist/cjs/findExists.js +14 -37
  18. package/dist/cjs/generateMetaTags.js +12 -31
  19. package/dist/cjs/getBrowserslist.js +20 -27
  20. package/dist/cjs/getCoreJsVersion.js +49 -37
  21. package/dist/cjs/getEntryOptions.js +14 -29
  22. package/dist/cjs/getPackageManager.js +23 -46
  23. package/dist/cjs/getPort.js +26 -61
  24. package/dist/cjs/getServerConfig.js +51 -43
  25. package/dist/cjs/getTargetDir.js +50 -38
  26. package/dist/cjs/import.js +16 -27
  27. package/dist/cjs/index.js +61 -60
  28. package/dist/cjs/is/index.js +53 -68
  29. package/dist/cjs/is/nodeEnv.js +13 -29
  30. package/dist/cjs/is/platform.js +13 -26
  31. package/dist/cjs/is/type.js +14 -33
  32. package/dist/cjs/logger.js +54 -50
  33. package/dist/cjs/monorepo.js +47 -78
  34. package/dist/cjs/nodeEnv.js +29 -31
  35. package/dist/cjs/path.js +42 -63
  36. package/dist/cjs/pathSerializer.js +43 -51
  37. package/dist/cjs/plugin.js +11 -29
  38. package/dist/cjs/prettyInstructions.js +35 -68
  39. package/dist/cjs/printBuildError.js +15 -37
  40. package/dist/cjs/react.js +18 -41
  41. package/dist/cjs/readTsConfig.js +21 -39
  42. package/dist/cjs/removeSlash.js +13 -27
  43. package/dist/cjs/resolve.js +25 -31
  44. package/dist/cjs/routes.js +22 -42
  45. package/dist/cjs/runtime/index.js +18 -17
  46. package/dist/cjs/runtime/parsed.js +8 -26
  47. package/dist/cjs/runtimeExports.js +31 -56
  48. package/dist/cjs/ssr.js +13 -26
  49. package/dist/cjs/storage.js +51 -41
  50. package/dist/cjs/testUtils.js +8 -29
  51. package/dist/cjs/types.js +4 -15
  52. package/dist/cjs/universal/constants.js +13 -26
  53. package/dist/cjs/universal/formatWebpack.js +16 -44
  54. package/dist/cjs/universal/nestedRoutes.js +94 -46
  55. package/dist/cjs/universal/pluginDagSort.js +58 -0
  56. package/dist/cjs/universal/remixRouter.js +18 -17
  57. package/dist/cjs/universal/serialize.js +16 -37
  58. package/dist/cjs/version.js +25 -41
  59. package/dist/cjs/wait.js +7 -25
  60. package/dist/cjs/watch.js +69 -43
  61. package/dist/esm/FileSizeReporter.js +40 -52
  62. package/dist/esm/alias.js +9 -19
  63. package/dist/esm/analyzeProject.js +3 -7
  64. package/dist/esm/applyOptionsChain.js +5 -17
  65. package/dist/esm/babel.js +6 -8
  66. package/dist/esm/chainId.js +1 -4
  67. package/dist/esm/clearConsole.js +1 -4
  68. package/dist/esm/commands.js +6 -12
  69. package/dist/esm/compatRequire.js +10 -17
  70. package/dist/esm/compiled.js +32 -76
  71. package/dist/esm/constants.js +143 -89
  72. package/dist/esm/debug.js +1 -4
  73. package/dist/esm/emptyDir.js +1 -4
  74. package/dist/esm/ensureAbsolutePath.js +1 -4
  75. package/dist/esm/ensureArray.js +4 -5
  76. package/dist/esm/findExists.js +1 -4
  77. package/dist/esm/generateMetaTags.js +6 -10
  78. package/dist/esm/getBrowserslist.js +8 -6
  79. package/dist/esm/getCoreJsVersion.js +1 -4
  80. package/dist/esm/getEntryOptions.js +5 -5
  81. package/dist/esm/getPackageManager.js +1 -4
  82. package/dist/esm/getPort.js +10 -25
  83. package/dist/esm/getServerConfig.js +2 -9
  84. package/dist/esm/getTargetDir.js +1 -4
  85. package/dist/esm/import.js +3 -4
  86. package/dist/esm/is/index.js +18 -30
  87. package/dist/esm/is/nodeEnv.js +5 -12
  88. package/dist/esm/is/platform.js +2 -6
  89. package/dist/esm/is/type.js +8 -18
  90. package/dist/esm/logger.js +37 -17
  91. package/dist/esm/monorepo.js +21 -38
  92. package/dist/esm/nodeEnv.js +18 -11
  93. package/dist/esm/path.js +16 -23
  94. package/dist/esm/pathSerializer.js +21 -21
  95. package/dist/esm/plugin.js +1 -4
  96. package/dist/esm/prettyInstructions.js +13 -32
  97. package/dist/esm/printBuildError.js +4 -11
  98. package/dist/esm/react.js +1 -4
  99. package/dist/esm/readTsConfig.js +2 -6
  100. package/dist/esm/removeSlash.js +3 -8
  101. package/dist/esm/resolve.js +14 -11
  102. package/dist/esm/routes.js +3 -9
  103. package/dist/esm/runtime/parsed.js +2 -5
  104. package/dist/esm/runtimeExports.js +17 -22
  105. package/dist/esm/ssr.js +1 -4
  106. package/dist/esm/storage.js +2 -6
  107. package/dist/esm/testUtils.js +2 -8
  108. package/dist/esm/types.js +1 -0
  109. package/dist/esm/universal/constants.js +2 -6
  110. package/dist/esm/universal/formatWebpack.js +10 -22
  111. package/dist/esm/universal/nestedRoutes.js +41 -27
  112. package/dist/esm/universal/pluginDagSort.js +50 -0
  113. package/dist/esm/universal/serialize.js +4 -5
  114. package/dist/esm/version.js +5 -7
  115. package/dist/esm/wait.js +1 -3
  116. package/dist/esm/watch.js +14 -9
  117. package/dist/types/universal/pluginDagSort.d.ts +1 -0
  118. package/package.json +17 -5
package/dist/cjs/index.js CHANGED
@@ -1,60 +1,61 @@
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 src_exports = {};
16
- module.exports = __toCommonJS(src_exports);
17
- __reExport(src_exports, require("./compiled"), module.exports);
18
- __reExport(src_exports, require("./commands"), module.exports);
19
- __reExport(src_exports, require("./FileSizeReporter"), module.exports);
20
- __reExport(src_exports, require("./printBuildError"), module.exports);
21
- __reExport(src_exports, require("./debug"), module.exports);
22
- __reExport(src_exports, require("./findExists"), module.exports);
23
- __reExport(src_exports, require("./is"), module.exports);
24
- __reExport(src_exports, require("./compatRequire"), module.exports);
25
- __reExport(src_exports, require("./logger"), module.exports);
26
- __reExport(src_exports, require("./constants"), module.exports);
27
- __reExport(src_exports, require("./ensureArray"), module.exports);
28
- __reExport(src_exports, require("./ensureAbsolutePath"), module.exports);
29
- __reExport(src_exports, require("./clearConsole"), module.exports);
30
- __reExport(src_exports, require("./applyOptionsChain"), module.exports);
31
- __reExport(src_exports, require("./getBrowserslist"), module.exports);
32
- __reExport(src_exports, require("./removeSlash"), module.exports);
33
- __reExport(src_exports, require("./getEntryOptions"), module.exports);
34
- __reExport(src_exports, require("./getPort"), module.exports);
35
- __reExport(src_exports, require("./monorepo"), module.exports);
36
- __reExport(src_exports, require("./getPackageManager"), module.exports);
37
- __reExport(src_exports, require("./runtimeExports"), module.exports);
38
- __reExport(src_exports, require("./readTsConfig"), module.exports);
39
- __reExport(src_exports, require("./path"), module.exports);
40
- __reExport(src_exports, require("./pathSerializer"), module.exports);
41
- __reExport(src_exports, require("./generateMetaTags"), module.exports);
42
- __reExport(src_exports, require("./prettyInstructions"), module.exports);
43
- __reExport(src_exports, require("./alias"), module.exports);
44
- __reExport(src_exports, require("./import"), module.exports);
45
- __reExport(src_exports, require("./watch"), module.exports);
46
- __reExport(src_exports, require("./nodeEnv"), module.exports);
47
- __reExport(src_exports, require("./wait"), module.exports);
48
- __reExport(src_exports, require("./emptyDir"), module.exports);
49
- __reExport(src_exports, require("./getServerConfig"), module.exports);
50
- __reExport(src_exports, require("./resolve"), module.exports);
51
- __reExport(src_exports, require("./analyzeProject"), module.exports);
52
- __reExport(src_exports, require("./chainId"), module.exports);
53
- __reExport(src_exports, require("./version"), module.exports);
54
- __reExport(src_exports, require("./plugin"), module.exports);
55
- __reExport(src_exports, require("./routes"), module.exports);
56
- __reExport(src_exports, require("./testUtils"), module.exports);
57
- __reExport(src_exports, require("./getCoreJsVersion"), module.exports);
58
- __reExport(src_exports, require("./react"), module.exports);
59
- __reExport(src_exports, require("./getTargetDir"), module.exports);
60
- __reExport(src_exports, require("./babel"), module.exports);
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
+ }
@@ -1,56 +1,54 @@
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) => {
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
- __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 __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
- isSSR: () => isSSR,
37
- isServiceWorker: () => isServiceWorker,
38
- isSingleEntry: () => isSingleEntry,
39
- isTypescript: () => isTypescript,
40
- isUseSSRBundle: () => isUseSSRBundle
22
+ isSingleEntry: () => isSingleEntry
41
23
  });
42
- module.exports = __toCommonJS(is_exports);
43
- var import_fs = __toESM(require("fs"));
44
- var import_path = __toESM(require("path"));
45
- var import_debug = require("../debug");
46
- var import_nodeEnv = require("./nodeEnv");
47
- __reExport(is_exports, require("./nodeEnv"), module.exports);
48
- __reExport(is_exports, require("./platform"), module.exports);
49
- __reExport(is_exports, require("./type"), module.exports);
50
- const debug = (0, import_debug.createDebugger)("judge-depExists");
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 = import_path.default.resolve(appDirectory, "./package.json");
53
- if (!import_fs.default.existsSync(pkgPath)) {
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) => import_fs.default.existsSync(import_path.default.resolve(root, "./tsconfig.json"));
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 == null ? void 0 : server.ssr) {
63
+ if (server === null || server === void 0 ? void 0 : server.ssr) {
66
64
  return true;
67
65
  }
68
- if ((server == null ? void 0 : server.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
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 == null ? void 0 : output.ssg) {
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 _a;
83
+ var _deploy_worker;
86
84
  const { output, deploy } = config;
87
- if (((_a = deploy == null ? void 0 : deploy.worker) == null ? void 0 : _a.ssr) && ((output == null ? void 0 : output.ssg) || isSSR(config))) {
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, import_nodeEnv.isDev)() && process.env.FAST_REFRESH !== "false";
90
+ const isFastRefresh = () => (0, _nodeEnv.isDev)() && process.env.FAST_REFRESH !== "false";
93
91
  const isRouterV5 = (config) => {
94
- var _a, _b, _c;
95
- return typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
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 == null ? void 0 : ssgConfig[0]) === "function" || Boolean(ssgConfig == null ? void 0 : ssgConfig[entryName]);
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
- });
@@ -1,39 +1,23 @@
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) => {
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
- __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 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
- isProdProfile: () => isProdProfile,
24
- isTest: () => isTest
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
- });
@@ -1,30 +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 __export = (target, all) => {
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
- __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 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
- });
@@ -1,32 +1,24 @@
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) => {
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
- __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 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
- });
@@ -1,37 +1,37 @@
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) => {
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
- __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 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
- module.exports = __toCommonJS(logger_exports);
34
- var import_chalk = __toESM(require("../compiled/chalk"));
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: { level: "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 = import_chalk.default.bold(logType.color ? import_chalk.default[logType.color](label) : 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
- ${import_chalk.default.grey(rest.join("\n"))}`;
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
- });