@rslib/core 0.0.0-next-20240927040621

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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/bin/rslib.js +14 -0
  4. package/compiled/commander/index.d.ts +971 -0
  5. package/compiled/commander/index.js +3805 -0
  6. package/compiled/commander/license +22 -0
  7. package/compiled/commander/package.json +1 -0
  8. package/compiled/fast-glob/index.d.ts +237 -0
  9. package/compiled/fast-glob/index.js +7309 -0
  10. package/compiled/fast-glob/license +21 -0
  11. package/compiled/fast-glob/package.json +1 -0
  12. package/compiled/picocolors/index.d.ts +56 -0
  13. package/compiled/picocolors/index.js +150 -0
  14. package/compiled/picocolors/license +15 -0
  15. package/compiled/picocolors/package.json +1 -0
  16. package/compiled/rslog/index.d.ts +66 -0
  17. package/compiled/rslog/index.js +334 -0
  18. package/compiled/rslog/license +21 -0
  19. package/compiled/rslog/package.json +1 -0
  20. package/dist/index.js +1894 -0
  21. package/dist-types/build.d.ts +4 -0
  22. package/dist-types/cli/commands.d.ts +14 -0
  23. package/dist-types/cli/prepare.d.ts +1 -0
  24. package/dist-types/config.d.ts +30 -0
  25. package/dist-types/constant.d.ts +8 -0
  26. package/dist-types/index.d.ts +7 -0
  27. package/dist-types/plugins/cjsShim.d.ts +2 -0
  28. package/dist-types/types/config/index.d.ts +45 -0
  29. package/dist-types/types/index.d.ts +2 -0
  30. package/dist-types/types/utils.d.ts +6 -0
  31. package/dist-types/utils/extension.d.ts +10 -0
  32. package/dist-types/utils/helper.d.ts +14 -0
  33. package/dist-types/utils/logger.d.ts +5 -0
  34. package/dist-types/utils/syntax.d.ts +13 -0
  35. package/dist-types/utils/tsconfig.d.ts +3 -0
  36. package/package.json +77 -0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Denis Malinochkin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"fast-glob","author":{"name":"Denis Malinochkin","url":"https://mrmlnc.com"},"version":"3.3.2","license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -0,0 +1,56 @@
1
+ type Formatter = (input: string | number | null | undefined) => string
2
+
3
+ interface Colors {
4
+ isColorSupported: boolean
5
+
6
+ reset: Formatter
7
+ bold: Formatter
8
+ dim: Formatter
9
+ italic: Formatter
10
+ underline: Formatter
11
+ inverse: Formatter
12
+ hidden: Formatter
13
+ strikethrough: Formatter
14
+
15
+ black: Formatter
16
+ red: Formatter
17
+ green: Formatter
18
+ yellow: Formatter
19
+ blue: Formatter
20
+ magenta: Formatter
21
+ cyan: Formatter
22
+ white: Formatter
23
+ gray: Formatter
24
+
25
+ bgBlack: Formatter
26
+ bgRed: Formatter
27
+ bgGreen: Formatter
28
+ bgYellow: Formatter
29
+ bgBlue: Formatter
30
+ bgMagenta: Formatter
31
+ bgCyan: Formatter
32
+ bgWhite: Formatter
33
+
34
+ blackBright: Formatter
35
+ redBright: Formatter
36
+ greenBright: Formatter
37
+ yellowBright: Formatter
38
+ blueBright: Formatter
39
+ magentaBright: Formatter
40
+ cyanBright: Formatter
41
+ whiteBright: Formatter
42
+
43
+ bgBlackBright: Formatter
44
+ bgRedBright: Formatter
45
+ bgGreenBright: Formatter
46
+ bgYellowBright: Formatter
47
+ bgBlueBright: Formatter
48
+ bgMagentaBright: Formatter
49
+ bgCyanBright: Formatter
50
+ bgWhiteBright: Formatter
51
+
52
+ }
53
+
54
+ declare const picocolors: Colors & { createColors: (enabled?: boolean) => Colors }
55
+
56
+ export { picocolors as default };
@@ -0,0 +1,150 @@
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ var __webpack_modules__ = ({
3
+
4
+ /***/ 78:
5
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
6
+
7
+ let argv = process.argv || [],
8
+ env = process.env
9
+ let isColorSupported =
10
+ !("NO_COLOR" in env || argv.includes("--no-color")) &&
11
+ ("FORCE_COLOR" in env ||
12
+ argv.includes("--color") ||
13
+ process.platform === "win32" ||
14
+ (require != null && (__nccwpck_require__(224).isatty)(1) && env.TERM !== "dumb") ||
15
+ "CI" in env)
16
+
17
+ let formatter =
18
+ (open, close, replace = open) =>
19
+ input => {
20
+ let string = "" + input
21
+ let index = string.indexOf(close, open.length)
22
+ return ~index
23
+ ? open + replaceClose(string, close, replace, index) + close
24
+ : open + string + close
25
+ }
26
+
27
+ let replaceClose = (string, close, replace, index) => {
28
+ let result = ""
29
+ let cursor = 0
30
+ do {
31
+ result += string.substring(cursor, index) + replace
32
+ cursor = index + close.length
33
+ index = string.indexOf(close, cursor)
34
+ } while (~index)
35
+ return result + string.substring(cursor)
36
+ }
37
+
38
+ let createColors = (enabled = isColorSupported) => {
39
+ let init = enabled ? formatter : () => String
40
+ return {
41
+ isColorSupported: enabled,
42
+ reset: init("\x1b[0m", "\x1b[0m"),
43
+ bold: init("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
44
+ dim: init("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
45
+ italic: init("\x1b[3m", "\x1b[23m"),
46
+ underline: init("\x1b[4m", "\x1b[24m"),
47
+ inverse: init("\x1b[7m", "\x1b[27m"),
48
+ hidden: init("\x1b[8m", "\x1b[28m"),
49
+ strikethrough: init("\x1b[9m", "\x1b[29m"),
50
+
51
+ black: init("\x1b[30m", "\x1b[39m"),
52
+ red: init("\x1b[31m", "\x1b[39m"),
53
+ green: init("\x1b[32m", "\x1b[39m"),
54
+ yellow: init("\x1b[33m", "\x1b[39m"),
55
+ blue: init("\x1b[34m", "\x1b[39m"),
56
+ magenta: init("\x1b[35m", "\x1b[39m"),
57
+ cyan: init("\x1b[36m", "\x1b[39m"),
58
+ white: init("\x1b[37m", "\x1b[39m"),
59
+ gray: init("\x1b[90m", "\x1b[39m"),
60
+
61
+ bgBlack: init("\x1b[40m", "\x1b[49m"),
62
+ bgRed: init("\x1b[41m", "\x1b[49m"),
63
+ bgGreen: init("\x1b[42m", "\x1b[49m"),
64
+ bgYellow: init("\x1b[43m", "\x1b[49m"),
65
+ bgBlue: init("\x1b[44m", "\x1b[49m"),
66
+ bgMagenta: init("\x1b[45m", "\x1b[49m"),
67
+ bgCyan: init("\x1b[46m", "\x1b[49m"),
68
+ bgWhite: init("\x1b[47m", "\x1b[49m"),
69
+
70
+ blackBright: init("\x1b[90m", "\x1b[39m"),
71
+ redBright: init("\x1b[91m", "\x1b[39m"),
72
+ greenBright: init("\x1b[92m", "\x1b[39m"),
73
+ yellowBright: init("\x1b[93m", "\x1b[39m"),
74
+ blueBright: init("\x1b[94m", "\x1b[39m"),
75
+ magentaBright: init("\x1b[95m", "\x1b[39m"),
76
+ cyanBright: init("\x1b[96m", "\x1b[39m"),
77
+ whiteBright: init("\x1b[97m", "\x1b[39m"),
78
+
79
+ bgBlackBright: init("\x1b[100m","\x1b[49m"),
80
+ bgRedBright: init("\x1b[101m","\x1b[49m"),
81
+ bgGreenBright: init("\x1b[102m","\x1b[49m"),
82
+ bgYellowBright: init("\x1b[103m","\x1b[49m"),
83
+ bgBlueBright: init("\x1b[104m","\x1b[49m"),
84
+ bgMagentaBright: init("\x1b[105m","\x1b[49m"),
85
+ bgCyanBright: init("\x1b[106m","\x1b[49m"),
86
+ bgWhiteBright: init("\x1b[107m","\x1b[49m"),
87
+ }
88
+ }
89
+
90
+ module.exports = createColors()
91
+ module.exports.createColors = createColors
92
+
93
+
94
+ /***/ }),
95
+
96
+ /***/ 224:
97
+ /***/ ((module) => {
98
+
99
+ "use strict";
100
+ module.exports = require("tty");
101
+
102
+ /***/ })
103
+
104
+ /******/ });
105
+ /************************************************************************/
106
+ /******/ // The module cache
107
+ /******/ var __webpack_module_cache__ = {};
108
+ /******/
109
+ /******/ // The require function
110
+ /******/ function __nccwpck_require__(moduleId) {
111
+ /******/ // Check if module is in cache
112
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
113
+ /******/ if (cachedModule !== undefined) {
114
+ /******/ return cachedModule.exports;
115
+ /******/ }
116
+ /******/ // Create a new module (and put it into the cache)
117
+ /******/ var module = __webpack_module_cache__[moduleId] = {
118
+ /******/ // no module.id needed
119
+ /******/ // no module.loaded needed
120
+ /******/ exports: {}
121
+ /******/ };
122
+ /******/
123
+ /******/ // Execute the module function
124
+ /******/ var threw = true;
125
+ /******/ try {
126
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
127
+ /******/ threw = false;
128
+ /******/ } finally {
129
+ /******/ if(threw) delete __webpack_module_cache__[moduleId];
130
+ /******/ }
131
+ /******/
132
+ /******/ // Return the exports of the module
133
+ /******/ return module.exports;
134
+ /******/ }
135
+ /******/
136
+ /************************************************************************/
137
+ /******/ /* webpack/runtime/compat */
138
+ /******/
139
+ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
140
+ /******/
141
+ /************************************************************************/
142
+ /******/
143
+ /******/ // startup
144
+ /******/ // Load entry module and return exports
145
+ /******/ // This entry module is referenced by other modules so it can't be inlined
146
+ /******/ var __webpack_exports__ = __nccwpck_require__(78);
147
+ /******/ module.exports = __webpack_exports__;
148
+ /******/
149
+ /******/ })()
150
+ ;
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2021-2024 Oleksii Raspopov, Kostiantyn Denysov, Anton Verinov
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"picocolors","author":"Alexey Raspopov","version":"1.1.0","license":"ISC","types":"index.d.ts","type":"commonjs"}
@@ -0,0 +1,66 @@
1
+ type ColorFn = (input: string | number | null | undefined) => string;
2
+
3
+ declare let LOG_TYPES: {
4
+ error: {
5
+ label: string;
6
+ level: "error";
7
+ color: ColorFn;
8
+ };
9
+ warn: {
10
+ label: string;
11
+ level: "warn";
12
+ color: ColorFn;
13
+ };
14
+ info: {
15
+ label: string;
16
+ level: "info";
17
+ color: ColorFn;
18
+ };
19
+ start: {
20
+ label: string;
21
+ level: "info";
22
+ color: ColorFn;
23
+ };
24
+ ready: {
25
+ label: string;
26
+ level: "info";
27
+ color: ColorFn;
28
+ };
29
+ success: {
30
+ label: string;
31
+ level: "info";
32
+ color: ColorFn;
33
+ };
34
+ log: {
35
+ level: "log";
36
+ };
37
+ debug: {
38
+ label: string;
39
+ level: "verbose";
40
+ color: ColorFn;
41
+ };
42
+ };
43
+
44
+ type LogLevel = 'error' | 'warn' | 'info' | 'log' | 'verbose';
45
+ type LogMessage = unknown;
46
+ interface LogType {
47
+ label?: string;
48
+ level: LogLevel;
49
+ color?: ColorFn;
50
+ }
51
+ type LogFunction = (message?: LogMessage, ...args: any[]) => void;
52
+ interface Options {
53
+ level?: LogLevel;
54
+ }
55
+ type LogMethods = keyof typeof LOG_TYPES;
56
+ type Logger = Record<LogMethods, LogFunction> & {
57
+ greet: (message: string) => void;
58
+ level: LogLevel;
59
+ override: (customLogger: Partial<Record<LogMethods, LogFunction>>) => void;
60
+ };
61
+
62
+ declare let createLogger: (options?: Options) => Logger;
63
+
64
+ declare let logger: Logger;
65
+
66
+ export { type LogFunction, type LogLevel, type LogMessage, type LogType, type Logger, type Options, createLogger, logger };
@@ -0,0 +1,334 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
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
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ createLogger: () => createLogger,
34
+ logger: () => logger
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+
38
+ // node_modules/.pnpm/supports-color@9.4.0/node_modules/supports-color/index.js
39
+ var import_node_process = __toESM(require("process"));
40
+ var import_node_os = __toESM(require("os"));
41
+ var import_node_tty = __toESM(require("tty"));
42
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
43
+ const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
44
+ const position = argv.indexOf(prefix + flag);
45
+ const terminatorPosition = argv.indexOf("--");
46
+ return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
47
+ }
48
+ var { env } = import_node_process.default;
49
+ var flagForceColor;
50
+ if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
51
+ flagForceColor = 0;
52
+ } else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
53
+ flagForceColor = 1;
54
+ }
55
+ function envForceColor() {
56
+ if ("FORCE_COLOR" in env) {
57
+ if (env.FORCE_COLOR === "true") {
58
+ return 1;
59
+ }
60
+ if (env.FORCE_COLOR === "false") {
61
+ return 0;
62
+ }
63
+ return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
64
+ }
65
+ }
66
+ function translateLevel(level) {
67
+ if (level === 0) {
68
+ return false;
69
+ }
70
+ return {
71
+ level,
72
+ hasBasic: true,
73
+ has256: level >= 2,
74
+ has16m: level >= 3
75
+ };
76
+ }
77
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
78
+ const noFlagForceColor = envForceColor();
79
+ if (noFlagForceColor !== void 0) {
80
+ flagForceColor = noFlagForceColor;
81
+ }
82
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
83
+ if (forceColor === 0) {
84
+ return 0;
85
+ }
86
+ if (sniffFlags) {
87
+ if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
88
+ return 3;
89
+ }
90
+ if (hasFlag("color=256")) {
91
+ return 2;
92
+ }
93
+ }
94
+ if ("TF_BUILD" in env && "AGENT_NAME" in env) {
95
+ return 1;
96
+ }
97
+ if (haveStream && !streamIsTTY && forceColor === void 0) {
98
+ return 0;
99
+ }
100
+ const min = forceColor || 0;
101
+ if (env.TERM === "dumb") {
102
+ return min;
103
+ }
104
+ if (import_node_process.default.platform === "win32") {
105
+ const osRelease = import_node_os.default.release().split(".");
106
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
107
+ return Number(osRelease[2]) >= 14931 ? 3 : 2;
108
+ }
109
+ return 1;
110
+ }
111
+ if ("CI" in env) {
112
+ if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
113
+ return 3;
114
+ }
115
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
116
+ return 1;
117
+ }
118
+ return min;
119
+ }
120
+ if ("TEAMCITY_VERSION" in env) {
121
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
122
+ }
123
+ if (env.COLORTERM === "truecolor") {
124
+ return 3;
125
+ }
126
+ if (env.TERM === "xterm-kitty") {
127
+ return 3;
128
+ }
129
+ if ("TERM_PROGRAM" in env) {
130
+ const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
131
+ switch (env.TERM_PROGRAM) {
132
+ case "iTerm.app": {
133
+ return version >= 3 ? 3 : 2;
134
+ }
135
+ case "Apple_Terminal": {
136
+ return 2;
137
+ }
138
+ }
139
+ }
140
+ if (/-256(color)?$/i.test(env.TERM)) {
141
+ return 2;
142
+ }
143
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
144
+ return 1;
145
+ }
146
+ if ("COLORTERM" in env) {
147
+ return 1;
148
+ }
149
+ return min;
150
+ }
151
+ function createSupportsColor(stream, options = {}) {
152
+ const level = _supportsColor(stream, {
153
+ streamIsTTY: stream && stream.isTTY,
154
+ ...options
155
+ });
156
+ return translateLevel(level);
157
+ }
158
+ var supportsColor = {
159
+ stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
160
+ stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
161
+ };
162
+ var supports_color_default = supportsColor;
163
+
164
+ // src/utils.ts
165
+ var colorLevel = supports_color_default.stdout ? supports_color_default.stdout.level : 0;
166
+ var errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/;
167
+ var anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/;
168
+ var isErrorStackMessage = (message) => errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
169
+
170
+ // src/color.ts
171
+ var formatter = (open, close, replace = open) => colorLevel >= 2 ? (input) => {
172
+ let string = "" + input;
173
+ let index = string.indexOf(close, open.length);
174
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
175
+ } : String;
176
+ var replaceClose = (string, close, replace, index) => {
177
+ let start = string.substring(0, index) + replace;
178
+ let end = string.substring(index + close.length);
179
+ let nextIndex = end.indexOf(close);
180
+ return ~nextIndex ? start + replaceClose(end, close, replace, nextIndex) : start + end;
181
+ };
182
+ var bold = formatter("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m");
183
+ var red = formatter("\x1B[31m", "\x1B[39m");
184
+ var green = formatter("\x1B[32m", "\x1B[39m");
185
+ var yellow = formatter("\x1B[33m", "\x1B[39m");
186
+ var magenta = formatter("\x1B[35m", "\x1B[39m");
187
+ var cyan = formatter("\x1B[36m", "\x1B[39m");
188
+ var gray = formatter("\x1B[90m", "\x1B[39m");
189
+
190
+ // src/gradient.ts
191
+ var startColor = [189, 255, 243];
192
+ var endColor = [74, 194, 154];
193
+ var isWord = (char) => !/[\s\n]/.test(char);
194
+ var gradient = (message) => {
195
+ if (colorLevel < 3) {
196
+ return colorLevel === 2 ? bold(cyan(message)) : message;
197
+ }
198
+ let chars = [...message];
199
+ let steps = chars.filter(isWord).length;
200
+ let r = startColor[0];
201
+ let g = startColor[1];
202
+ let b = startColor[2];
203
+ let rStep = (endColor[0] - r) / steps;
204
+ let gStep = (endColor[1] - g) / steps;
205
+ let bStep = (endColor[2] - b) / steps;
206
+ let output = "";
207
+ for (let char of chars) {
208
+ if (isWord(char)) {
209
+ r += rStep;
210
+ g += gStep;
211
+ b += bStep;
212
+ }
213
+ output += `\x1B[38;2;${Math.round(r)};${Math.round(g)};${Math.round(
214
+ b
215
+ )}m${char}\x1B[39m`;
216
+ }
217
+ return bold(output);
218
+ };
219
+
220
+ // src/constants.ts
221
+ var LOG_LEVEL = {
222
+ error: 0,
223
+ warn: 1,
224
+ info: 2,
225
+ log: 3,
226
+ verbose: 4
227
+ };
228
+ var LOG_TYPES = {
229
+ // Level error
230
+ error: {
231
+ label: "error",
232
+ level: "error",
233
+ color: red
234
+ },
235
+ // Level warn
236
+ warn: {
237
+ label: "warn",
238
+ level: "warn",
239
+ color: yellow
240
+ },
241
+ // Level info
242
+ info: {
243
+ label: "info",
244
+ level: "info",
245
+ color: cyan
246
+ },
247
+ start: {
248
+ label: "start",
249
+ level: "info",
250
+ color: cyan
251
+ },
252
+ ready: {
253
+ label: "ready",
254
+ level: "info",
255
+ color: green
256
+ },
257
+ success: {
258
+ label: "success",
259
+ level: "info",
260
+ color: green
261
+ },
262
+ // Level log
263
+ log: {
264
+ level: "log"
265
+ },
266
+ // Level debug
267
+ debug: {
268
+ label: "debug",
269
+ level: "verbose",
270
+ color: magenta
271
+ }
272
+ };
273
+
274
+ // src/createLogger.ts
275
+ var createLogger = (options = {}) => {
276
+ let maxLevel = options.level || "log";
277
+ let log = (type, message, ...args) => {
278
+ if (LOG_LEVEL[LOG_TYPES[type].level] > LOG_LEVEL[maxLevel]) {
279
+ return;
280
+ }
281
+ if (message === void 0 || message === null) {
282
+ return console.log();
283
+ }
284
+ let logType = LOG_TYPES[type];
285
+ let label = "";
286
+ let text = "";
287
+ if ("label" in logType) {
288
+ label = (logType.label || "").padEnd(7);
289
+ label = bold(logType.color ? logType.color(label) : label);
290
+ }
291
+ if (message instanceof Error) {
292
+ if (message.stack) {
293
+ let [name, ...rest] = message.stack.split("\n");
294
+ if (name.startsWith("Error: ")) {
295
+ name = name.slice(7);
296
+ }
297
+ text = `${name}
298
+ ${gray(rest.join("\n"))}`;
299
+ } else {
300
+ text = message.message;
301
+ }
302
+ } else if (logType.level === "error" && typeof message === "string") {
303
+ let lines = message.split("\n");
304
+ text = lines.map((line) => isErrorStackMessage(line) ? gray(line) : line).join("\n");
305
+ } else {
306
+ text = `${message}`;
307
+ }
308
+ console.log(label.length ? `${label} ${text}` : text, ...args);
309
+ };
310
+ let logger2 = {
311
+ greet: (message) => log("log", gradient(message))
312
+ };
313
+ Object.keys(LOG_TYPES).forEach((key) => {
314
+ logger2[key] = (...args) => log(key, ...args);
315
+ });
316
+ Object.defineProperty(logger2, "level", {
317
+ get: () => maxLevel,
318
+ set(val) {
319
+ maxLevel = val;
320
+ }
321
+ });
322
+ logger2.override = (customLogger) => {
323
+ Object.assign(logger2, customLogger);
324
+ };
325
+ return logger2;
326
+ };
327
+
328
+ // src/index.ts
329
+ var logger = createLogger();
330
+ // Annotate the CommonJS export names for ESM import in node:
331
+ 0 && (module.exports = {
332
+ createLogger,
333
+ logger
334
+ });
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Bytedance, Inc. and its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"rslog","version":"1.2.3","types":"index.d.ts","type":"commonjs"}