@rslib/core 0.0.4 → 0.0.6

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/README.md CHANGED
@@ -6,9 +6,9 @@
6
6
 
7
7
  Rslib is a library build tool powered by [Rsbuild](https://rsbuild.dev). It allows library developers to leverage the knowledge and ecosystem of webpack and Rspack.
8
8
 
9
- <!-- ## Documentation
9
+ ## Documentation
10
10
 
11
- https://rslib.dev/ -->
11
+ https://lib.rsbuild.dev/
12
12
 
13
13
  ## Contributing
14
14
 
@@ -2,6 +2,7 @@ type Formatter = (input: string | number | null | undefined) => string
2
2
 
3
3
  interface Colors {
4
4
  isColorSupported: boolean
5
+
5
6
  reset: Formatter
6
7
  bold: Formatter
7
8
  dim: Formatter
@@ -10,6 +11,7 @@ interface Colors {
10
11
  inverse: Formatter
11
12
  hidden: Formatter
12
13
  strikethrough: Formatter
14
+
13
15
  black: Formatter
14
16
  red: Formatter
15
17
  green: Formatter
@@ -19,6 +21,7 @@ interface Colors {
19
21
  cyan: Formatter
20
22
  white: Formatter
21
23
  gray: Formatter
24
+
22
25
  bgBlack: Formatter
23
26
  bgRed: Formatter
24
27
  bgGreen: Formatter
@@ -27,6 +30,25 @@ interface Colors {
27
30
  bgMagenta: Formatter
28
31
  bgCyan: Formatter
29
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
+
30
52
  }
31
53
 
32
54
  declare const picocolors: Colors & { createColors: (enabled?: boolean) => Colors }
@@ -1,7 +1,7 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 701:
4
+ /***/ 78:
5
5
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
6
6
 
7
7
  let argv = process.argv || [],
@@ -47,6 +47,7 @@ let createColors = (enabled = isColorSupported) => {
47
47
  inverse: init("\x1b[7m", "\x1b[27m"),
48
48
  hidden: init("\x1b[8m", "\x1b[28m"),
49
49
  strikethrough: init("\x1b[9m", "\x1b[29m"),
50
+
50
51
  black: init("\x1b[30m", "\x1b[39m"),
51
52
  red: init("\x1b[31m", "\x1b[39m"),
52
53
  green: init("\x1b[32m", "\x1b[39m"),
@@ -56,6 +57,7 @@ let createColors = (enabled = isColorSupported) => {
56
57
  cyan: init("\x1b[36m", "\x1b[39m"),
57
58
  white: init("\x1b[37m", "\x1b[39m"),
58
59
  gray: init("\x1b[90m", "\x1b[39m"),
60
+
59
61
  bgBlack: init("\x1b[40m", "\x1b[49m"),
60
62
  bgRed: init("\x1b[41m", "\x1b[49m"),
61
63
  bgGreen: init("\x1b[42m", "\x1b[49m"),
@@ -64,6 +66,24 @@ let createColors = (enabled = isColorSupported) => {
64
66
  bgMagenta: init("\x1b[45m", "\x1b[49m"),
65
67
  bgCyan: init("\x1b[46m", "\x1b[49m"),
66
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"),
67
87
  }
68
88
  }
69
89
 
@@ -123,7 +143,7 @@ module.exports = require("tty");
123
143
  /******/ // startup
124
144
  /******/ // Load entry module and return exports
125
145
  /******/ // This entry module is referenced by other modules so it can't be inlined
126
- /******/ var __webpack_exports__ = __nccwpck_require__(701);
146
+ /******/ var __webpack_exports__ = __nccwpck_require__(78);
127
147
  /******/ module.exports = __webpack_exports__;
128
148
  /******/
129
149
  /******/ })()
@@ -1,6 +1,6 @@
1
1
  ISC License
2
2
 
3
- Copyright (c) 2021 Alexey Raspopov, Kostiantyn Denysov, Anton Verinov
3
+ Copyright (c) 2021-2024 Oleksii Raspopov, Kostiantyn Denysov, Anton Verinov
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
6
6
  purpose with or without fee is hereby granted, provided that the above
@@ -1 +1 @@
1
- {"name":"picocolors","author":"Alexey Raspopov","version":"1.0.1","license":"ISC","types":"index.d.ts","type":"commonjs"}
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"}