@rsbuild/core 0.7.8 → 0.7.9

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.
@@ -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 = /^\s*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.2","types":"index.d.ts","type":"commonjs"}
@@ -1,7 +1,7 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 2854:
4
+ /***/ 6325:
5
5
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
6
6
 
7
7
  "use strict";
@@ -105,7 +105,7 @@ exports.transformFiles = transformFiles;
105
105
 
106
106
  /***/ }),
107
107
 
108
- /***/ 2131:
108
+ /***/ 4917:
109
109
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
110
110
 
111
111
  "use strict";
@@ -116,7 +116,7 @@ const fs_1 = __nccwpck_require__(7147);
116
116
  const path_1 = __nccwpck_require__(1017);
117
117
  const tapable_1 = __nccwpck_require__(4260);
118
118
  const webpack_sources_1 = __nccwpck_require__(5433);
119
- const helpers_1 = __nccwpck_require__(2854);
119
+ const helpers_1 = __nccwpck_require__(6325);
120
120
  const compilerHookMap = new WeakMap();
121
121
  const getCompilerHooks = (compiler) => {
122
122
  let hooks = compilerHookMap.get(compiler);
@@ -7751,7 +7751,7 @@ var exports = __webpack_exports__;
7751
7751
  Object.defineProperty(exports, "__esModule", ({ value: true }));
7752
7752
  exports.RspackManifestPlugin = exports.WebpackManifestPlugin = exports.getCompilerHooks = void 0;
7753
7753
  const path_1 = __nccwpck_require__(1017);
7754
- const hooks_1 = __nccwpck_require__(2131);
7754
+ const hooks_1 = __nccwpck_require__(4917);
7755
7755
  Object.defineProperty(exports, "getCompilerHooks", ({ enumerable: true, get: function () { return hooks_1.getCompilerHooks; } }));
7756
7756
  const emitCountMap = new Map();
7757
7757
  const defaults = {