@rsbuild/core 0.7.7 → 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.
- package/bin/rsbuild.js +1 -2
- package/compiled/css-loader/index.js +23 -23
- package/compiled/jiti/index.d.ts +1 -0
- package/compiled/jiti/index.js +391 -0
- package/compiled/jiti/license +21 -0
- package/compiled/jiti/package.json +1 -0
- package/compiled/launch-editor-middleware/index.js +21 -15
- package/compiled/launch-editor-middleware/package.json +1 -1
- package/compiled/postcss-load-config/index.js +1 -1
- package/compiled/postcss-loader/index.js +14 -14
- package/compiled/rslog/index.d.ts +66 -0
- package/compiled/rslog/index.js +334 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-manifest-plugin/index.js +4 -4
- package/compiled/semver/index.d.ts +1 -0
- package/compiled/semver/index.js +2585 -0
- package/compiled/semver/license +15 -0
- package/compiled/semver/package.json +1 -0
- package/compiled/webpack-dev-middleware/index.js +280 -10
- package/compiled/ws/index.js +80 -57
- package/compiled/ws/package.json +1 -1
- package/dist/index.cjs +1082 -762
- package/dist/index.js +866 -601
- package/dist-types/configChain.d.ts +10 -0
- package/dist-types/constants.d.ts +2 -0
- package/dist-types/createContext.d.ts +1 -1
- package/dist-types/helpers.d.ts +22 -3
- package/dist-types/index.d.ts +2 -1
- package/dist-types/initPlugins.d.ts +1 -1
- package/dist-types/internal.d.ts +4 -2
- package/dist-types/logger.d.ts +4 -0
- package/dist-types/provider/initConfigs.d.ts +1 -1
- package/dist-types/server/devMiddleware.d.ts +11 -1
- package/dist-types/server/helper.d.ts +1 -0
- package/dist-types/server/proxy.d.ts +1 -1
- package/dist-types/server/socketServer.d.ts +1 -1
- package/dist-types/types.d.ts +1 -2
- package/package.json +8 -5
- package/dist-types/server/index.d.ts +0 -2
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Pooya Parsa <pooya@pi0.io>
|
|
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":"jiti","version":"1.21.6","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/******/ (() => { // webpackBootstrap
|
|
2
2
|
/******/ var __webpack_modules__ = ({
|
|
3
3
|
|
|
4
|
-
/***/
|
|
4
|
+
/***/ 648:
|
|
5
5
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
6
6
|
|
|
7
7
|
const url = __nccwpck_require__(310)
|
|
8
8
|
const path = __nccwpck_require__(17)
|
|
9
|
-
const launch = __nccwpck_require__(
|
|
9
|
+
const launch = __nccwpck_require__(309)
|
|
10
10
|
|
|
11
11
|
module.exports = (specifiedEditor, srcRoot, onErrorCallback) => {
|
|
12
12
|
if (typeof specifiedEditor === 'function') {
|
|
@@ -36,7 +36,7 @@ module.exports = (specifiedEditor, srcRoot, onErrorCallback) => {
|
|
|
36
36
|
|
|
37
37
|
/***/ }),
|
|
38
38
|
|
|
39
|
-
/***/
|
|
39
|
+
/***/ 330:
|
|
40
40
|
/***/ ((module) => {
|
|
41
41
|
|
|
42
42
|
module.exports = {
|
|
@@ -62,7 +62,7 @@ module.exports = {
|
|
|
62
62
|
|
|
63
63
|
/***/ }),
|
|
64
64
|
|
|
65
|
-
/***/
|
|
65
|
+
/***/ 723:
|
|
66
66
|
/***/ ((module) => {
|
|
67
67
|
|
|
68
68
|
module.exports = {
|
|
@@ -82,12 +82,17 @@ module.exports = {
|
|
|
82
82
|
'/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron':
|
|
83
83
|
'code-insiders',
|
|
84
84
|
'/Applications/VSCodium.app/Contents/MacOS/Electron': 'codium',
|
|
85
|
+
'/Applications/Cursor.app/Contents/MacOS/Cursor': 'cursor',
|
|
85
86
|
'/Applications/AppCode.app/Contents/MacOS/appcode':
|
|
86
87
|
'/Applications/AppCode.app/Contents/MacOS/appcode',
|
|
87
88
|
'/Applications/CLion.app/Contents/MacOS/clion':
|
|
88
89
|
'/Applications/CLion.app/Contents/MacOS/clion',
|
|
89
90
|
'/Applications/IntelliJ IDEA.app/Contents/MacOS/idea':
|
|
90
91
|
'/Applications/IntelliJ IDEA.app/Contents/MacOS/idea',
|
|
92
|
+
'/Applications/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea':
|
|
93
|
+
'/Applications/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea',
|
|
94
|
+
'/Applications/IntelliJ IDEA Community Edition.app/Contents/MacOS/idea':
|
|
95
|
+
'/Applications/IntelliJ IDEA Community Edition.app/Contents/MacOS/idea',
|
|
91
96
|
'/Applications/PhpStorm.app/Contents/MacOS/phpstorm':
|
|
92
97
|
'/Applications/PhpStorm.app/Contents/MacOS/phpstorm',
|
|
93
98
|
'/Applications/PyCharm.app/Contents/MacOS/pycharm':
|
|
@@ -108,7 +113,7 @@ module.exports = {
|
|
|
108
113
|
|
|
109
114
|
/***/ }),
|
|
110
115
|
|
|
111
|
-
/***/
|
|
116
|
+
/***/ 957:
|
|
112
117
|
/***/ ((module) => {
|
|
113
118
|
|
|
114
119
|
module.exports = [
|
|
@@ -140,7 +145,7 @@ module.exports = [
|
|
|
140
145
|
|
|
141
146
|
/***/ }),
|
|
142
147
|
|
|
143
|
-
/***/
|
|
148
|
+
/***/ 714:
|
|
144
149
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
145
150
|
|
|
146
151
|
const path = __nccwpck_require__(17)
|
|
@@ -183,6 +188,7 @@ module.exports = function getArgumentsForPosition (
|
|
|
183
188
|
case 'code-insiders':
|
|
184
189
|
case 'Code - Insiders':
|
|
185
190
|
case 'codium':
|
|
191
|
+
case 'cursor':
|
|
186
192
|
case 'vscodium':
|
|
187
193
|
case 'VSCodium':
|
|
188
194
|
return ['-r', '-g', `${fileName}:${lineNumber}:${columnNumber}`]
|
|
@@ -219,7 +225,7 @@ module.exports = function getArgumentsForPosition (
|
|
|
219
225
|
|
|
220
226
|
/***/ }),
|
|
221
227
|
|
|
222
|
-
/***/
|
|
228
|
+
/***/ 962:
|
|
223
229
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
224
230
|
|
|
225
231
|
const path = __nccwpck_require__(17)
|
|
@@ -229,9 +235,9 @@ const childProcess = __nccwpck_require__(81)
|
|
|
229
235
|
// Map from full process name to binary that starts the process
|
|
230
236
|
// We can't just re-use full process name, because it will spawn a new instance
|
|
231
237
|
// of the app every time
|
|
232
|
-
const COMMON_EDITORS_OSX = __nccwpck_require__(
|
|
233
|
-
const COMMON_EDITORS_LINUX = __nccwpck_require__(
|
|
234
|
-
const COMMON_EDITORS_WIN = __nccwpck_require__(
|
|
238
|
+
const COMMON_EDITORS_OSX = __nccwpck_require__(723)
|
|
239
|
+
const COMMON_EDITORS_LINUX = __nccwpck_require__(330)
|
|
240
|
+
const COMMON_EDITORS_WIN = __nccwpck_require__(957)
|
|
235
241
|
|
|
236
242
|
module.exports = function guessEditor (specifiedEditor) {
|
|
237
243
|
if (specifiedEditor) {
|
|
@@ -261,7 +267,7 @@ module.exports = function guessEditor (specifiedEditor) {
|
|
|
261
267
|
for (let i = 0; i < processNames.length; i++) {
|
|
262
268
|
const processName = processNames[i]
|
|
263
269
|
// Find editor by exact match.
|
|
264
|
-
if (
|
|
270
|
+
if (processList.includes(processName)) {
|
|
265
271
|
return [COMMON_EDITORS_OSX[processName]]
|
|
266
272
|
}
|
|
267
273
|
const processNameWithoutApplications = processName.replace('/Applications', '')
|
|
@@ -331,7 +337,7 @@ module.exports = function guessEditor (specifiedEditor) {
|
|
|
331
337
|
|
|
332
338
|
/***/ }),
|
|
333
339
|
|
|
334
|
-
/***/
|
|
340
|
+
/***/ 309:
|
|
335
341
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
336
342
|
|
|
337
343
|
/**
|
|
@@ -350,8 +356,8 @@ const path = __nccwpck_require__(17)
|
|
|
350
356
|
const colors = __nccwpck_require__(802)
|
|
351
357
|
const childProcess = __nccwpck_require__(81)
|
|
352
358
|
|
|
353
|
-
const guessEditor = __nccwpck_require__(
|
|
354
|
-
const getArgumentsForPosition = __nccwpck_require__(
|
|
359
|
+
const guessEditor = __nccwpck_require__(962)
|
|
360
|
+
const getArgumentsForPosition = __nccwpck_require__(714)
|
|
355
361
|
|
|
356
362
|
function wrapErrorCallback (cb) {
|
|
357
363
|
return (fileName, errorMessage) => {
|
|
@@ -836,7 +842,7 @@ module.exports = require("url");
|
|
|
836
842
|
/******/ // startup
|
|
837
843
|
/******/ // Load entry module and return exports
|
|
838
844
|
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
839
|
-
/******/ var __webpack_exports__ = __nccwpck_require__(
|
|
845
|
+
/******/ var __webpack_exports__ = __nccwpck_require__(648);
|
|
840
846
|
/******/ module.exports = __webpack_exports__;
|
|
841
847
|
/******/
|
|
842
848
|
/******/ })()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"launch-editor-middleware","author":"Evan You","version":"2.
|
|
1
|
+
{"name":"launch-editor-middleware","author":"Evan You","version":"2.7.0","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
|
@@ -846,7 +846,7 @@ async function req(name, rootFile = __filename) {
|
|
|
846
846
|
|
|
847
847
|
if (jiti === undefined) {
|
|
848
848
|
try {
|
|
849
|
-
jiti = (await import('
|
|
849
|
+
jiti = (await import('../jiti/index.js')).default
|
|
850
850
|
} catch (error) {
|
|
851
851
|
importError.push(error)
|
|
852
852
|
}
|
|
@@ -7709,17 +7709,17 @@ module.exports.createColors = createColors
|
|
|
7709
7709
|
|
|
7710
7710
|
/***/ }),
|
|
7711
7711
|
|
|
7712
|
-
/***/
|
|
7712
|
+
/***/ 7377:
|
|
7713
7713
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
7714
7714
|
|
|
7715
7715
|
"use strict";
|
|
7716
7716
|
|
|
7717
7717
|
|
|
7718
|
-
module.exports = __nccwpck_require__(
|
|
7718
|
+
module.exports = __nccwpck_require__(5106)["default"];
|
|
7719
7719
|
|
|
7720
7720
|
/***/ }),
|
|
7721
7721
|
|
|
7722
|
-
/***/
|
|
7722
|
+
/***/ 5106:
|
|
7723
7723
|
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
7724
7724
|
|
|
7725
7725
|
"use strict";
|
|
@@ -7732,8 +7732,8 @@ __webpack_unused_export__ = ({
|
|
|
7732
7732
|
exports["default"] = loader;
|
|
7733
7733
|
var _path = _interopRequireDefault(__nccwpck_require__(1017));
|
|
7734
7734
|
var _package = _interopRequireDefault(__nccwpck_require__(5446));
|
|
7735
|
-
var _options = _interopRequireDefault(__nccwpck_require__(
|
|
7736
|
-
var _utils = __nccwpck_require__(
|
|
7735
|
+
var _options = _interopRequireDefault(__nccwpck_require__(2739));
|
|
7736
|
+
var _utils = __nccwpck_require__(7741);
|
|
7737
7737
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
7738
7738
|
let hasExplicitDependencyOnPostCSS = false;
|
|
7739
7739
|
|
|
@@ -7794,7 +7794,7 @@ async function loader(content, sourceMap, meta) {
|
|
|
7794
7794
|
// Reuse PostCSS AST from other loaders
|
|
7795
7795
|
if (meta && meta.ast && meta.ast.type === "postcss" &&
|
|
7796
7796
|
// eslint-disable-next-line global-require
|
|
7797
|
-
(__nccwpck_require__(
|
|
7797
|
+
(__nccwpck_require__(5204).satisfies)(meta.ast.version, `^${_package.default.version}`)) {
|
|
7798
7798
|
({
|
|
7799
7799
|
root
|
|
7800
7800
|
} = meta.ast);
|
|
@@ -7899,7 +7899,7 @@ async function loader(content, sourceMap, meta) {
|
|
|
7899
7899
|
|
|
7900
7900
|
/***/ }),
|
|
7901
7901
|
|
|
7902
|
-
/***/
|
|
7902
|
+
/***/ 7741:
|
|
7903
7903
|
/***/ ((module, exports, __nccwpck_require__) => {
|
|
7904
7904
|
|
|
7905
7905
|
"use strict";
|
|
@@ -8012,7 +8012,7 @@ async function loadConfig(loaderContext, config, postcssOptions) {
|
|
|
8012
8012
|
interopDefault: true
|
|
8013
8013
|
};
|
|
8014
8014
|
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
|
|
8015
|
-
const jiti = __nccwpck_require__(
|
|
8015
|
+
const jiti = __nccwpck_require__(9993)(__filename, opts);
|
|
8016
8016
|
tsLoader = filepath => jiti(filepath);
|
|
8017
8017
|
}
|
|
8018
8018
|
loaders[".cts"] = tsLoader;
|
|
@@ -8585,19 +8585,19 @@ module.exports = webpackEmptyAsyncContext;
|
|
|
8585
8585
|
|
|
8586
8586
|
/***/ }),
|
|
8587
8587
|
|
|
8588
|
-
/***/
|
|
8588
|
+
/***/ 9993:
|
|
8589
8589
|
/***/ ((module) => {
|
|
8590
8590
|
|
|
8591
8591
|
"use strict";
|
|
8592
|
-
module.exports = require("
|
|
8592
|
+
module.exports = require("../jiti");
|
|
8593
8593
|
|
|
8594
8594
|
/***/ }),
|
|
8595
8595
|
|
|
8596
|
-
/***/
|
|
8596
|
+
/***/ 5204:
|
|
8597
8597
|
/***/ ((module) => {
|
|
8598
8598
|
|
|
8599
8599
|
"use strict";
|
|
8600
|
-
module.exports = require("
|
|
8600
|
+
module.exports = require("../semver");
|
|
8601
8601
|
|
|
8602
8602
|
/***/ }),
|
|
8603
8603
|
|
|
@@ -9150,7 +9150,7 @@ function highlight(code, options = {}) {
|
|
|
9150
9150
|
|
|
9151
9151
|
/***/ }),
|
|
9152
9152
|
|
|
9153
|
-
/***/
|
|
9153
|
+
/***/ 2739:
|
|
9154
9154
|
/***/ ((module) => {
|
|
9155
9155
|
|
|
9156
9156
|
"use strict";
|
|
@@ -9278,7 +9278,7 @@ module.exports = JSON.parse('{"name":"postcss","version":"8.4.38","description":
|
|
|
9278
9278
|
/******/ // startup
|
|
9279
9279
|
/******/ // Load entry module and return exports
|
|
9280
9280
|
/******/ // This entry module used 'module' so it can't be inlined
|
|
9281
|
-
/******/ var __webpack_exports__ = __nccwpck_require__(
|
|
9281
|
+
/******/ var __webpack_exports__ = __nccwpck_require__(7377);
|
|
9282
9282
|
/******/ module.exports = __webpack_exports__;
|
|
9283
9283
|
/******/
|
|
9284
9284
|
/******/ })()
|
|
@@ -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 = /^\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.
|