@jsenv/core 30.0.6 → 30.1.0
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/dist/js/ws.js +36 -23
- package/dist/main.js +152 -378
- package/package.json +10 -9
- package/src/plugins/transpilation/css/jsenv_plugin_css_transpilation.js +54 -0
- package/src/plugins/transpilation/jsenv_plugin_transpilation.js +2 -2
- package/src/plugins/transpilation/css_parcel/jsenv_plugin_css_parcel.js +0 -18
package/dist/js/ws.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import require$$0 from "stream";
|
|
2
|
-
import require$$0$
|
|
2
|
+
import require$$0$3 from "events";
|
|
3
3
|
import require$$2 from "http";
|
|
4
4
|
import require$$1 from "https";
|
|
5
5
|
import require$$3 from "net";
|
|
6
6
|
import require$$4 from "tls";
|
|
7
7
|
import require$$5 from "crypto";
|
|
8
8
|
import require$$0$1 from "zlib";
|
|
9
|
+
import require$$0$2 from "buffer";
|
|
9
10
|
import require$$7 from "url";
|
|
10
11
|
|
|
11
12
|
const {
|
|
@@ -172,6 +173,7 @@ var mask;
|
|
|
172
173
|
const {
|
|
173
174
|
EMPTY_BUFFER: EMPTY_BUFFER$3
|
|
174
175
|
} = constants;
|
|
176
|
+
const FastBuffer$2 = Buffer[Symbol.species];
|
|
175
177
|
|
|
176
178
|
/**
|
|
177
179
|
* Merges an array of buffers into a new buffer.
|
|
@@ -191,7 +193,9 @@ function concat$1(list, totalLength) {
|
|
|
191
193
|
target.set(buf, offset);
|
|
192
194
|
offset += buf.length;
|
|
193
195
|
}
|
|
194
|
-
if (offset < totalLength)
|
|
196
|
+
if (offset < totalLength) {
|
|
197
|
+
return new FastBuffer$2(target.buffer, target.byteOffset, offset);
|
|
198
|
+
}
|
|
195
199
|
return target;
|
|
196
200
|
}
|
|
197
201
|
|
|
@@ -232,10 +236,10 @@ function _unmask(buffer, mask) {
|
|
|
232
236
|
* @public
|
|
233
237
|
*/
|
|
234
238
|
function toArrayBuffer$1(buf) {
|
|
235
|
-
if (buf.
|
|
239
|
+
if (buf.length === buf.buffer.byteLength) {
|
|
236
240
|
return buf.buffer;
|
|
237
241
|
}
|
|
238
|
-
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.
|
|
242
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
|
|
239
243
|
}
|
|
240
244
|
|
|
241
245
|
/**
|
|
@@ -251,9 +255,9 @@ function toBuffer$2(data) {
|
|
|
251
255
|
if (Buffer.isBuffer(data)) return data;
|
|
252
256
|
let buf;
|
|
253
257
|
if (data instanceof ArrayBuffer) {
|
|
254
|
-
buf =
|
|
258
|
+
buf = new FastBuffer$2(data);
|
|
255
259
|
} else if (ArrayBuffer.isView(data)) {
|
|
256
|
-
buf =
|
|
260
|
+
buf = new FastBuffer$2(data.buffer, data.byteOffset, data.byteLength);
|
|
257
261
|
} else {
|
|
258
262
|
buf = Buffer.from(data);
|
|
259
263
|
toBuffer$2.readOnly = false;
|
|
@@ -338,6 +342,7 @@ const Limiter = limiter;
|
|
|
338
342
|
const {
|
|
339
343
|
kStatusCode: kStatusCode$2
|
|
340
344
|
} = constants;
|
|
345
|
+
const FastBuffer$1 = Buffer[Symbol.species];
|
|
341
346
|
const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]);
|
|
342
347
|
const kPerMessageDeflate = Symbol('permessage-deflate');
|
|
343
348
|
const kTotalLength = Symbol('total-length');
|
|
@@ -676,7 +681,9 @@ let PerMessageDeflate$4 = class PerMessageDeflate {
|
|
|
676
681
|
return;
|
|
677
682
|
}
|
|
678
683
|
let data = bufferUtil.concat(this._deflate[kBuffers], this._deflate[kTotalLength]);
|
|
679
|
-
if (fin)
|
|
684
|
+
if (fin) {
|
|
685
|
+
data = new FastBuffer$1(data.buffer, data.byteOffset, data.length - 4);
|
|
686
|
+
}
|
|
680
687
|
|
|
681
688
|
//
|
|
682
689
|
// Ensure that the callback will not be called again in
|
|
@@ -749,6 +756,9 @@ var validation = {
|
|
|
749
756
|
}
|
|
750
757
|
};
|
|
751
758
|
var isValidUTF8_1;
|
|
759
|
+
const {
|
|
760
|
+
isUtf8
|
|
761
|
+
} = require$$0$2;
|
|
752
762
|
|
|
753
763
|
//
|
|
754
764
|
// Allowed token characters:
|
|
@@ -842,13 +852,15 @@ validation.exports = {
|
|
|
842
852
|
isValidUTF8: _isValidUTF8,
|
|
843
853
|
tokenChars: tokenChars$2
|
|
844
854
|
};
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
855
|
+
if (isUtf8) {
|
|
856
|
+
isValidUTF8_1 = validationExports.isValidUTF8 = function (buf) {
|
|
857
|
+
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
858
|
+
};
|
|
859
|
+
} /* istanbul ignore else */else if (!process.env.WS_NO_UTF_8_VALIDATE) {
|
|
848
860
|
try {
|
|
849
861
|
const isValidUTF8 = require('utf-8-validate');
|
|
850
862
|
isValidUTF8_1 = validationExports.isValidUTF8 = function (buf) {
|
|
851
|
-
return buf.length <
|
|
863
|
+
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
852
864
|
};
|
|
853
865
|
} catch (e) {
|
|
854
866
|
// Continue regardless of the error.
|
|
@@ -873,6 +885,7 @@ const {
|
|
|
873
885
|
isValidStatusCode: isValidStatusCode$1,
|
|
874
886
|
isValidUTF8
|
|
875
887
|
} = validationExports;
|
|
888
|
+
const FastBuffer = Buffer[Symbol.species];
|
|
876
889
|
const GET_INFO = 0;
|
|
877
890
|
const GET_PAYLOAD_LENGTH_16 = 1;
|
|
878
891
|
const GET_PAYLOAD_LENGTH_64 = 2;
|
|
@@ -950,8 +963,8 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
950
963
|
if (n === this._buffers[0].length) return this._buffers.shift();
|
|
951
964
|
if (n < this._buffers[0].length) {
|
|
952
965
|
const buf = this._buffers[0];
|
|
953
|
-
this._buffers[0] = buf.
|
|
954
|
-
return buf.
|
|
966
|
+
this._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n);
|
|
967
|
+
return new FastBuffer(buf.buffer, buf.byteOffset, n);
|
|
955
968
|
}
|
|
956
969
|
const dst = Buffer.allocUnsafe(n);
|
|
957
970
|
do {
|
|
@@ -961,7 +974,7 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
961
974
|
dst.set(this._buffers.shift(), offset);
|
|
962
975
|
} else {
|
|
963
976
|
dst.set(new Uint8Array(buf.buffer, buf.byteOffset, n), offset);
|
|
964
|
-
this._buffers[0] = buf.
|
|
977
|
+
this._buffers[0] = new FastBuffer(buf.buffer, buf.byteOffset + n, buf.length - n);
|
|
965
978
|
}
|
|
966
979
|
n -= buf.length;
|
|
967
980
|
} while (n > 0);
|
|
@@ -1052,7 +1065,7 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
1052
1065
|
this._loop = false;
|
|
1053
1066
|
return error(RangeError, 'RSV1 must be clear', true, 1002, 'WS_ERR_UNEXPECTED_RSV_1');
|
|
1054
1067
|
}
|
|
1055
|
-
if (this._payloadLength > 0x7d) {
|
|
1068
|
+
if (this._payloadLength > 0x7d || this._opcode === 0x08 && this._payloadLength === 1) {
|
|
1056
1069
|
this._loop = false;
|
|
1057
1070
|
return error(RangeError, `invalid payload length ${this._payloadLength}`, true, 1002, 'WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH');
|
|
1058
1071
|
}
|
|
@@ -1255,14 +1268,12 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
1255
1268
|
if (data.length === 0) {
|
|
1256
1269
|
this.emit('conclude', 1005, EMPTY_BUFFER$2);
|
|
1257
1270
|
this.end();
|
|
1258
|
-
} else if (data.length === 1) {
|
|
1259
|
-
return error(RangeError, 'invalid payload length 1', true, 1002, 'WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH');
|
|
1260
1271
|
} else {
|
|
1261
1272
|
const code = data.readUInt16BE(0);
|
|
1262
1273
|
if (!isValidStatusCode$1(code)) {
|
|
1263
1274
|
return error(RangeError, `invalid status code ${code}`, true, 1002, 'WS_ERR_INVALID_CLOSE_CODE');
|
|
1264
1275
|
}
|
|
1265
|
-
const buf = data.
|
|
1276
|
+
const buf = new FastBuffer(data.buffer, data.byteOffset + 2, data.length - 2);
|
|
1266
1277
|
if (!this._skipUTF8Validation && !isValidUTF8(buf)) {
|
|
1267
1278
|
return error(Error, 'invalid UTF-8 sequence', true, 1007, 'WS_ERR_INVALID_UTF8');
|
|
1268
1279
|
}
|
|
@@ -2183,7 +2194,7 @@ var extension$1 = {
|
|
|
2183
2194
|
|
|
2184
2195
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Readable$" }] */
|
|
2185
2196
|
|
|
2186
|
-
const EventEmitter$1 = require$$0$
|
|
2197
|
+
const EventEmitter$1 = require$$0$3;
|
|
2187
2198
|
const https = require$$1;
|
|
2188
2199
|
const http$1 = require$$2;
|
|
2189
2200
|
const net = require$$3;
|
|
@@ -2457,7 +2468,8 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
2457
2468
|
if (this.readyState === WebSocket$1.CLOSED) return;
|
|
2458
2469
|
if (this.readyState === WebSocket$1.CONNECTING) {
|
|
2459
2470
|
const msg = 'WebSocket was closed before the connection was established';
|
|
2460
|
-
|
|
2471
|
+
abortHandshake$1(this, this._req, msg);
|
|
2472
|
+
return;
|
|
2461
2473
|
}
|
|
2462
2474
|
if (this.readyState === WebSocket$1.CLOSING) {
|
|
2463
2475
|
if (this._closeFrameSent && (this._closeFrameReceived || this._receiver._writableState.errorEmitted)) {
|
|
@@ -2616,7 +2628,8 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
2616
2628
|
if (this.readyState === WebSocket$1.CLOSED) return;
|
|
2617
2629
|
if (this.readyState === WebSocket$1.CONNECTING) {
|
|
2618
2630
|
const msg = 'WebSocket was closed before the connection was established';
|
|
2619
|
-
|
|
2631
|
+
abortHandshake$1(this, this._req, msg);
|
|
2632
|
+
return;
|
|
2620
2633
|
}
|
|
2621
2634
|
if (this._socket) {
|
|
2622
2635
|
this._readyState = WebSocket$1.CLOSING;
|
|
@@ -3120,7 +3133,7 @@ function sendAfterClose(websocket, data, cb) {
|
|
|
3120
3133
|
}
|
|
3121
3134
|
if (cb) {
|
|
3122
3135
|
const err = new Error(`WebSocket is not open: readyState ${websocket.readyState} ` + `(${readyStates[websocket.readyState]})`);
|
|
3123
|
-
cb
|
|
3136
|
+
process.nextTick(cb, err);
|
|
3124
3137
|
}
|
|
3125
3138
|
}
|
|
3126
3139
|
|
|
@@ -3352,7 +3365,7 @@ var subprotocol$1 = {
|
|
|
3352
3365
|
|
|
3353
3366
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^net|tls|https$" }] */
|
|
3354
3367
|
|
|
3355
|
-
const EventEmitter = require$$0$
|
|
3368
|
+
const EventEmitter = require$$0$3;
|
|
3356
3369
|
const http = require$$2;
|
|
3357
3370
|
const {
|
|
3358
3371
|
createHash
|
package/dist/main.js
CHANGED
|
@@ -16,7 +16,7 @@ import { Readable, Stream, Writable } from "node:stream";
|
|
|
16
16
|
import { Http2ServerResponse } from "node:http2";
|
|
17
17
|
import { lookup } from "node:dns";
|
|
18
18
|
import { SOURCEMAP, generateSourcemapFileUrl, composeTwoSourcemaps, generateSourcemapDataUrl, createMagicSource, getOriginalPosition } from "@jsenv/sourcemap";
|
|
19
|
-
import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes, analyzeScriptNode, setHtmlNodeAttributes, parseSrcSet, getHtmlNodePosition, getHtmlNodeAttributePosition, applyPostCss, postCssPluginUrlVisitor, parseJsUrls, getHtmlNodeText, setHtmlNodeText, applyBabelPlugins, injectScriptNodeAsEarlyAsPossible, createHtmlNode, findHtmlNode, removeHtmlNode, removeHtmlNodeText,
|
|
19
|
+
import { parseHtmlString, stringifyHtmlAst, getHtmlNodeAttribute, visitHtmlNodes, analyzeScriptNode, setHtmlNodeAttributes, parseSrcSet, getHtmlNodePosition, getHtmlNodeAttributePosition, applyPostCss, postCssPluginUrlVisitor, parseJsUrls, getHtmlNodeText, setHtmlNodeText, applyBabelPlugins, injectScriptNodeAsEarlyAsPossible, createHtmlNode, findHtmlNode, removeHtmlNode, removeHtmlNodeText, injectJsImport, analyzeLinkNode, injectHtmlNode, insertHtmlNodeAfter } from "@jsenv/ast";
|
|
20
20
|
import { createRequire } from "node:module";
|
|
21
21
|
import babelParser from "@babel/parser";
|
|
22
22
|
import { bundleJsModules } from "@jsenv/plugin-bundling";
|
|
@@ -2264,16 +2264,16 @@ const writeFileSync = (destination, content = "") => {
|
|
|
2264
2264
|
}
|
|
2265
2265
|
};
|
|
2266
2266
|
|
|
2267
|
-
const LOG_LEVEL_OFF
|
|
2268
|
-
const LOG_LEVEL_DEBUG
|
|
2269
|
-
const LOG_LEVEL_INFO
|
|
2270
|
-
const LOG_LEVEL_WARN
|
|
2271
|
-
const LOG_LEVEL_ERROR
|
|
2267
|
+
const LOG_LEVEL_OFF = "off";
|
|
2268
|
+
const LOG_LEVEL_DEBUG = "debug";
|
|
2269
|
+
const LOG_LEVEL_INFO = "info";
|
|
2270
|
+
const LOG_LEVEL_WARN = "warn";
|
|
2271
|
+
const LOG_LEVEL_ERROR = "error";
|
|
2272
2272
|
|
|
2273
|
-
const createLogger
|
|
2274
|
-
logLevel = LOG_LEVEL_INFO
|
|
2273
|
+
const createLogger = ({
|
|
2274
|
+
logLevel = LOG_LEVEL_INFO
|
|
2275
2275
|
} = {}) => {
|
|
2276
|
-
if (logLevel === LOG_LEVEL_DEBUG
|
|
2276
|
+
if (logLevel === LOG_LEVEL_DEBUG) {
|
|
2277
2277
|
return {
|
|
2278
2278
|
level: "debug",
|
|
2279
2279
|
levels: {
|
|
@@ -2282,13 +2282,13 @@ const createLogger$1 = ({
|
|
|
2282
2282
|
warn: true,
|
|
2283
2283
|
error: true
|
|
2284
2284
|
},
|
|
2285
|
-
debug
|
|
2286
|
-
info
|
|
2287
|
-
warn
|
|
2288
|
-
error
|
|
2285
|
+
debug,
|
|
2286
|
+
info,
|
|
2287
|
+
warn,
|
|
2288
|
+
error
|
|
2289
2289
|
};
|
|
2290
2290
|
}
|
|
2291
|
-
if (logLevel === LOG_LEVEL_INFO
|
|
2291
|
+
if (logLevel === LOG_LEVEL_INFO) {
|
|
2292
2292
|
return {
|
|
2293
2293
|
level: "info",
|
|
2294
2294
|
levels: {
|
|
@@ -2297,13 +2297,13 @@ const createLogger$1 = ({
|
|
|
2297
2297
|
warn: true,
|
|
2298
2298
|
error: true
|
|
2299
2299
|
},
|
|
2300
|
-
debug: debugDisabled
|
|
2301
|
-
info
|
|
2302
|
-
warn
|
|
2303
|
-
error
|
|
2300
|
+
debug: debugDisabled,
|
|
2301
|
+
info,
|
|
2302
|
+
warn,
|
|
2303
|
+
error
|
|
2304
2304
|
};
|
|
2305
2305
|
}
|
|
2306
|
-
if (logLevel === LOG_LEVEL_WARN
|
|
2306
|
+
if (logLevel === LOG_LEVEL_WARN) {
|
|
2307
2307
|
return {
|
|
2308
2308
|
level: "warn",
|
|
2309
2309
|
levels: {
|
|
@@ -2312,13 +2312,13 @@ const createLogger$1 = ({
|
|
|
2312
2312
|
warn: true,
|
|
2313
2313
|
error: true
|
|
2314
2314
|
},
|
|
2315
|
-
debug: debugDisabled
|
|
2316
|
-
info: infoDisabled
|
|
2317
|
-
warn
|
|
2318
|
-
error
|
|
2315
|
+
debug: debugDisabled,
|
|
2316
|
+
info: infoDisabled,
|
|
2317
|
+
warn,
|
|
2318
|
+
error
|
|
2319
2319
|
};
|
|
2320
2320
|
}
|
|
2321
|
-
if (logLevel === LOG_LEVEL_ERROR
|
|
2321
|
+
if (logLevel === LOG_LEVEL_ERROR) {
|
|
2322
2322
|
return {
|
|
2323
2323
|
level: "error",
|
|
2324
2324
|
levels: {
|
|
@@ -2327,13 +2327,13 @@ const createLogger$1 = ({
|
|
|
2327
2327
|
warn: false,
|
|
2328
2328
|
error: true
|
|
2329
2329
|
},
|
|
2330
|
-
debug: debugDisabled
|
|
2331
|
-
info: infoDisabled
|
|
2332
|
-
warn: warnDisabled
|
|
2333
|
-
error
|
|
2330
|
+
debug: debugDisabled,
|
|
2331
|
+
info: infoDisabled,
|
|
2332
|
+
warn: warnDisabled,
|
|
2333
|
+
error
|
|
2334
2334
|
};
|
|
2335
2335
|
}
|
|
2336
|
-
if (logLevel === LOG_LEVEL_OFF
|
|
2336
|
+
if (logLevel === LOG_LEVEL_OFF) {
|
|
2337
2337
|
return {
|
|
2338
2338
|
level: "off",
|
|
2339
2339
|
levels: {
|
|
@@ -2342,60 +2342,60 @@ const createLogger$1 = ({
|
|
|
2342
2342
|
warn: false,
|
|
2343
2343
|
error: false
|
|
2344
2344
|
},
|
|
2345
|
-
debug: debugDisabled
|
|
2346
|
-
info: infoDisabled
|
|
2347
|
-
warn: warnDisabled
|
|
2348
|
-
error: errorDisabled
|
|
2345
|
+
debug: debugDisabled,
|
|
2346
|
+
info: infoDisabled,
|
|
2347
|
+
warn: warnDisabled,
|
|
2348
|
+
error: errorDisabled
|
|
2349
2349
|
};
|
|
2350
2350
|
}
|
|
2351
2351
|
throw new Error(`unexpected logLevel.
|
|
2352
2352
|
--- logLevel ---
|
|
2353
2353
|
${logLevel}
|
|
2354
2354
|
--- allowed log levels ---
|
|
2355
|
-
${LOG_LEVEL_OFF
|
|
2356
|
-
${LOG_LEVEL_ERROR
|
|
2357
|
-
${LOG_LEVEL_WARN
|
|
2358
|
-
${LOG_LEVEL_INFO
|
|
2359
|
-
${LOG_LEVEL_DEBUG
|
|
2360
|
-
};
|
|
2361
|
-
const debug
|
|
2362
|
-
const debugDisabled
|
|
2363
|
-
const info
|
|
2364
|
-
const infoDisabled
|
|
2365
|
-
const warn
|
|
2366
|
-
const warnDisabled
|
|
2367
|
-
const error
|
|
2368
|
-
const errorDisabled
|
|
2355
|
+
${LOG_LEVEL_OFF}
|
|
2356
|
+
${LOG_LEVEL_ERROR}
|
|
2357
|
+
${LOG_LEVEL_WARN}
|
|
2358
|
+
${LOG_LEVEL_INFO}
|
|
2359
|
+
${LOG_LEVEL_DEBUG}`);
|
|
2360
|
+
};
|
|
2361
|
+
const debug = (...args) => console.debug(...args);
|
|
2362
|
+
const debugDisabled = () => {};
|
|
2363
|
+
const info = (...args) => console.info(...args);
|
|
2364
|
+
const infoDisabled = () => {};
|
|
2365
|
+
const warn = (...args) => console.warn(...args);
|
|
2366
|
+
const warnDisabled = () => {};
|
|
2367
|
+
const error = (...args) => console.error(...args);
|
|
2368
|
+
const errorDisabled = () => {};
|
|
2369
2369
|
|
|
2370
2370
|
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
2371
2371
|
/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) {
|
|
2372
|
-
function hasFlag
|
|
2372
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
|
|
2373
2373
|
const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
|
|
2374
2374
|
const position = argv.indexOf(prefix + flag);
|
|
2375
2375
|
const terminatorPosition = argv.indexOf('--');
|
|
2376
2376
|
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
2377
2377
|
}
|
|
2378
2378
|
const {
|
|
2379
|
-
env
|
|
2379
|
+
env
|
|
2380
2380
|
} = process$1;
|
|
2381
|
-
let flagForceColor
|
|
2382
|
-
if (hasFlag
|
|
2383
|
-
flagForceColor
|
|
2384
|
-
} else if (hasFlag
|
|
2385
|
-
flagForceColor
|
|
2381
|
+
let flagForceColor;
|
|
2382
|
+
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
|
|
2383
|
+
flagForceColor = 0;
|
|
2384
|
+
} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
|
|
2385
|
+
flagForceColor = 1;
|
|
2386
2386
|
}
|
|
2387
|
-
function envForceColor
|
|
2388
|
-
if ('FORCE_COLOR' in env
|
|
2389
|
-
if (env
|
|
2387
|
+
function envForceColor() {
|
|
2388
|
+
if ('FORCE_COLOR' in env) {
|
|
2389
|
+
if (env.FORCE_COLOR === 'true') {
|
|
2390
2390
|
return 1;
|
|
2391
2391
|
}
|
|
2392
|
-
if (env
|
|
2392
|
+
if (env.FORCE_COLOR === 'false') {
|
|
2393
2393
|
return 0;
|
|
2394
2394
|
}
|
|
2395
|
-
return env
|
|
2395
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
2396
2396
|
}
|
|
2397
2397
|
}
|
|
2398
|
-
function translateLevel
|
|
2398
|
+
function translateLevel(level) {
|
|
2399
2399
|
if (level === 0) {
|
|
2400
2400
|
return false;
|
|
2401
2401
|
}
|
|
@@ -2406,37 +2406,37 @@ function translateLevel$1(level) {
|
|
|
2406
2406
|
has16m: level >= 3
|
|
2407
2407
|
};
|
|
2408
2408
|
}
|
|
2409
|
-
function _supportsColor
|
|
2409
|
+
function _supportsColor(haveStream, {
|
|
2410
2410
|
streamIsTTY,
|
|
2411
2411
|
sniffFlags = true
|
|
2412
2412
|
} = {}) {
|
|
2413
|
-
const noFlagForceColor = envForceColor
|
|
2413
|
+
const noFlagForceColor = envForceColor();
|
|
2414
2414
|
if (noFlagForceColor !== undefined) {
|
|
2415
|
-
flagForceColor
|
|
2415
|
+
flagForceColor = noFlagForceColor;
|
|
2416
2416
|
}
|
|
2417
|
-
const forceColor = sniffFlags ? flagForceColor
|
|
2417
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
2418
2418
|
if (forceColor === 0) {
|
|
2419
2419
|
return 0;
|
|
2420
2420
|
}
|
|
2421
2421
|
if (sniffFlags) {
|
|
2422
|
-
if (hasFlag
|
|
2422
|
+
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
|
|
2423
2423
|
return 3;
|
|
2424
2424
|
}
|
|
2425
|
-
if (hasFlag
|
|
2425
|
+
if (hasFlag('color=256')) {
|
|
2426
2426
|
return 2;
|
|
2427
2427
|
}
|
|
2428
2428
|
}
|
|
2429
2429
|
|
|
2430
2430
|
// Check for Azure DevOps pipelines.
|
|
2431
2431
|
// Has to be above the `!streamIsTTY` check.
|
|
2432
|
-
if ('TF_BUILD' in env
|
|
2432
|
+
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
2433
2433
|
return 1;
|
|
2434
2434
|
}
|
|
2435
2435
|
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
2436
2436
|
return 0;
|
|
2437
2437
|
}
|
|
2438
2438
|
const min = forceColor || 0;
|
|
2439
|
-
if (env
|
|
2439
|
+
if (env.TERM === 'dumb') {
|
|
2440
2440
|
return min;
|
|
2441
2441
|
}
|
|
2442
2442
|
if (process$1.platform === 'win32') {
|
|
@@ -2448,27 +2448,27 @@ function _supportsColor$1(haveStream, {
|
|
|
2448
2448
|
}
|
|
2449
2449
|
return 1;
|
|
2450
2450
|
}
|
|
2451
|
-
if ('CI' in env
|
|
2452
|
-
if ('GITHUB_ACTIONS' in env
|
|
2451
|
+
if ('CI' in env) {
|
|
2452
|
+
if ('GITHUB_ACTIONS' in env) {
|
|
2453
2453
|
return 3;
|
|
2454
2454
|
}
|
|
2455
|
-
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env
|
|
2455
|
+
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
2456
2456
|
return 1;
|
|
2457
2457
|
}
|
|
2458
2458
|
return min;
|
|
2459
2459
|
}
|
|
2460
|
-
if ('TEAMCITY_VERSION' in env
|
|
2461
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env
|
|
2460
|
+
if ('TEAMCITY_VERSION' in env) {
|
|
2461
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
2462
2462
|
}
|
|
2463
|
-
if (env
|
|
2463
|
+
if (env.COLORTERM === 'truecolor') {
|
|
2464
2464
|
return 3;
|
|
2465
2465
|
}
|
|
2466
|
-
if (env
|
|
2466
|
+
if (env.TERM === 'xterm-kitty') {
|
|
2467
2467
|
return 3;
|
|
2468
2468
|
}
|
|
2469
|
-
if ('TERM_PROGRAM' in env
|
|
2470
|
-
const version = Number.parseInt((env
|
|
2471
|
-
switch (env
|
|
2469
|
+
if ('TERM_PROGRAM' in env) {
|
|
2470
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
2471
|
+
switch (env.TERM_PROGRAM) {
|
|
2472
2472
|
case 'iTerm.app':
|
|
2473
2473
|
{
|
|
2474
2474
|
return version >= 3 ? 3 : 2;
|
|
@@ -2481,34 +2481,34 @@ function _supportsColor$1(haveStream, {
|
|
|
2481
2481
|
}
|
|
2482
2482
|
}
|
|
2483
2483
|
|
|
2484
|
-
if (/-256(color)?$/i.test(env
|
|
2484
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
2485
2485
|
return 2;
|
|
2486
2486
|
}
|
|
2487
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env
|
|
2487
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
2488
2488
|
return 1;
|
|
2489
2489
|
}
|
|
2490
|
-
if ('COLORTERM' in env
|
|
2490
|
+
if ('COLORTERM' in env) {
|
|
2491
2491
|
return 1;
|
|
2492
2492
|
}
|
|
2493
2493
|
return min;
|
|
2494
2494
|
}
|
|
2495
|
-
function createSupportsColor
|
|
2496
|
-
const level = _supportsColor
|
|
2495
|
+
function createSupportsColor(stream, options = {}) {
|
|
2496
|
+
const level = _supportsColor(stream, {
|
|
2497
2497
|
streamIsTTY: stream && stream.isTTY,
|
|
2498
2498
|
...options
|
|
2499
2499
|
});
|
|
2500
|
-
return translateLevel
|
|
2500
|
+
return translateLevel(level);
|
|
2501
2501
|
}
|
|
2502
2502
|
({
|
|
2503
|
-
stdout: createSupportsColor
|
|
2503
|
+
stdout: createSupportsColor({
|
|
2504
2504
|
isTTY: tty.isatty(1)
|
|
2505
2505
|
}),
|
|
2506
|
-
stderr: createSupportsColor
|
|
2506
|
+
stderr: createSupportsColor({
|
|
2507
2507
|
isTTY: tty.isatty(2)
|
|
2508
2508
|
})
|
|
2509
2509
|
});
|
|
2510
2510
|
|
|
2511
|
-
const processSupportsBasicColor = createSupportsColor
|
|
2511
|
+
const processSupportsBasicColor = createSupportsColor(process.stdout).hasBasic;
|
|
2512
2512
|
let canUseColors = processSupportsBasicColor;
|
|
2513
2513
|
|
|
2514
2514
|
// GitHub workflow does support ANSI but "supports-color" returns false
|
|
@@ -2588,7 +2588,7 @@ const UNICODE = {
|
|
|
2588
2588
|
supported: canUseUnicode
|
|
2589
2589
|
};
|
|
2590
2590
|
|
|
2591
|
-
const createDetailedMessage$
|
|
2591
|
+
const createDetailedMessage$1 = (message, details = {}) => {
|
|
2592
2592
|
let string = `${message}`;
|
|
2593
2593
|
Object.keys(details).forEach(key => {
|
|
2594
2594
|
const value = details[key];
|
|
@@ -3210,269 +3210,6 @@ const createTaskLog = (label, {
|
|
|
3210
3210
|
};
|
|
3211
3211
|
};
|
|
3212
3212
|
|
|
3213
|
-
const LOG_LEVEL_OFF = "off";
|
|
3214
|
-
const LOG_LEVEL_DEBUG = "debug";
|
|
3215
|
-
const LOG_LEVEL_INFO = "info";
|
|
3216
|
-
const LOG_LEVEL_WARN = "warn";
|
|
3217
|
-
const LOG_LEVEL_ERROR = "error";
|
|
3218
|
-
|
|
3219
|
-
const createLogger = ({
|
|
3220
|
-
logLevel = LOG_LEVEL_INFO
|
|
3221
|
-
} = {}) => {
|
|
3222
|
-
if (logLevel === LOG_LEVEL_DEBUG) {
|
|
3223
|
-
return {
|
|
3224
|
-
level: "debug",
|
|
3225
|
-
levels: {
|
|
3226
|
-
debug: true,
|
|
3227
|
-
info: true,
|
|
3228
|
-
warn: true,
|
|
3229
|
-
error: true
|
|
3230
|
-
},
|
|
3231
|
-
debug,
|
|
3232
|
-
info,
|
|
3233
|
-
warn,
|
|
3234
|
-
error
|
|
3235
|
-
};
|
|
3236
|
-
}
|
|
3237
|
-
if (logLevel === LOG_LEVEL_INFO) {
|
|
3238
|
-
return {
|
|
3239
|
-
level: "info",
|
|
3240
|
-
levels: {
|
|
3241
|
-
debug: false,
|
|
3242
|
-
info: true,
|
|
3243
|
-
warn: true,
|
|
3244
|
-
error: true
|
|
3245
|
-
},
|
|
3246
|
-
debug: debugDisabled,
|
|
3247
|
-
info,
|
|
3248
|
-
warn,
|
|
3249
|
-
error
|
|
3250
|
-
};
|
|
3251
|
-
}
|
|
3252
|
-
if (logLevel === LOG_LEVEL_WARN) {
|
|
3253
|
-
return {
|
|
3254
|
-
level: "warn",
|
|
3255
|
-
levels: {
|
|
3256
|
-
debug: false,
|
|
3257
|
-
info: false,
|
|
3258
|
-
warn: true,
|
|
3259
|
-
error: true
|
|
3260
|
-
},
|
|
3261
|
-
debug: debugDisabled,
|
|
3262
|
-
info: infoDisabled,
|
|
3263
|
-
warn,
|
|
3264
|
-
error
|
|
3265
|
-
};
|
|
3266
|
-
}
|
|
3267
|
-
if (logLevel === LOG_LEVEL_ERROR) {
|
|
3268
|
-
return {
|
|
3269
|
-
level: "error",
|
|
3270
|
-
levels: {
|
|
3271
|
-
debug: false,
|
|
3272
|
-
info: false,
|
|
3273
|
-
warn: false,
|
|
3274
|
-
error: true
|
|
3275
|
-
},
|
|
3276
|
-
debug: debugDisabled,
|
|
3277
|
-
info: infoDisabled,
|
|
3278
|
-
warn: warnDisabled,
|
|
3279
|
-
error
|
|
3280
|
-
};
|
|
3281
|
-
}
|
|
3282
|
-
if (logLevel === LOG_LEVEL_OFF) {
|
|
3283
|
-
return {
|
|
3284
|
-
level: "off",
|
|
3285
|
-
levels: {
|
|
3286
|
-
debug: false,
|
|
3287
|
-
info: false,
|
|
3288
|
-
warn: false,
|
|
3289
|
-
error: false
|
|
3290
|
-
},
|
|
3291
|
-
debug: debugDisabled,
|
|
3292
|
-
info: infoDisabled,
|
|
3293
|
-
warn: warnDisabled,
|
|
3294
|
-
error: errorDisabled
|
|
3295
|
-
};
|
|
3296
|
-
}
|
|
3297
|
-
throw new Error(`unexpected logLevel.
|
|
3298
|
-
--- logLevel ---
|
|
3299
|
-
${logLevel}
|
|
3300
|
-
--- allowed log levels ---
|
|
3301
|
-
${LOG_LEVEL_OFF}
|
|
3302
|
-
${LOG_LEVEL_ERROR}
|
|
3303
|
-
${LOG_LEVEL_WARN}
|
|
3304
|
-
${LOG_LEVEL_INFO}
|
|
3305
|
-
${LOG_LEVEL_DEBUG}`);
|
|
3306
|
-
};
|
|
3307
|
-
const debug = (...args) => console.debug(...args);
|
|
3308
|
-
const debugDisabled = () => {};
|
|
3309
|
-
const info = (...args) => console.info(...args);
|
|
3310
|
-
const infoDisabled = () => {};
|
|
3311
|
-
const warn = (...args) => console.warn(...args);
|
|
3312
|
-
const warnDisabled = () => {};
|
|
3313
|
-
const error = (...args) => console.error(...args);
|
|
3314
|
-
const errorDisabled = () => {};
|
|
3315
|
-
|
|
3316
|
-
// From: https://github.com/sindresorhus/has-flag/blob/main/index.js
|
|
3317
|
-
function hasFlag(flag, argv = globalThis.Deno?.args ?? process$1.argv) {
|
|
3318
|
-
const prefix = flag.startsWith('-') ? '' : flag.length === 1 ? '-' : '--';
|
|
3319
|
-
const position = argv.indexOf(prefix + flag);
|
|
3320
|
-
const terminatorPosition = argv.indexOf('--');
|
|
3321
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
3322
|
-
}
|
|
3323
|
-
const {
|
|
3324
|
-
env
|
|
3325
|
-
} = process$1;
|
|
3326
|
-
let flagForceColor;
|
|
3327
|
-
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) {
|
|
3328
|
-
flagForceColor = 0;
|
|
3329
|
-
} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) {
|
|
3330
|
-
flagForceColor = 1;
|
|
3331
|
-
}
|
|
3332
|
-
function envForceColor() {
|
|
3333
|
-
if ('FORCE_COLOR' in env) {
|
|
3334
|
-
if (env.FORCE_COLOR === 'true') {
|
|
3335
|
-
return 1;
|
|
3336
|
-
}
|
|
3337
|
-
if (env.FORCE_COLOR === 'false') {
|
|
3338
|
-
return 0;
|
|
3339
|
-
}
|
|
3340
|
-
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
3341
|
-
}
|
|
3342
|
-
}
|
|
3343
|
-
function translateLevel(level) {
|
|
3344
|
-
if (level === 0) {
|
|
3345
|
-
return false;
|
|
3346
|
-
}
|
|
3347
|
-
return {
|
|
3348
|
-
level,
|
|
3349
|
-
hasBasic: true,
|
|
3350
|
-
has256: level >= 2,
|
|
3351
|
-
has16m: level >= 3
|
|
3352
|
-
};
|
|
3353
|
-
}
|
|
3354
|
-
function _supportsColor(haveStream, {
|
|
3355
|
-
streamIsTTY,
|
|
3356
|
-
sniffFlags = true
|
|
3357
|
-
} = {}) {
|
|
3358
|
-
const noFlagForceColor = envForceColor();
|
|
3359
|
-
if (noFlagForceColor !== undefined) {
|
|
3360
|
-
flagForceColor = noFlagForceColor;
|
|
3361
|
-
}
|
|
3362
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
3363
|
-
if (forceColor === 0) {
|
|
3364
|
-
return 0;
|
|
3365
|
-
}
|
|
3366
|
-
if (sniffFlags) {
|
|
3367
|
-
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) {
|
|
3368
|
-
return 3;
|
|
3369
|
-
}
|
|
3370
|
-
if (hasFlag('color=256')) {
|
|
3371
|
-
return 2;
|
|
3372
|
-
}
|
|
3373
|
-
}
|
|
3374
|
-
|
|
3375
|
-
// Check for Azure DevOps pipelines.
|
|
3376
|
-
// Has to be above the `!streamIsTTY` check.
|
|
3377
|
-
if ('TF_BUILD' in env && 'AGENT_NAME' in env) {
|
|
3378
|
-
return 1;
|
|
3379
|
-
}
|
|
3380
|
-
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
3381
|
-
return 0;
|
|
3382
|
-
}
|
|
3383
|
-
const min = forceColor || 0;
|
|
3384
|
-
if (env.TERM === 'dumb') {
|
|
3385
|
-
return min;
|
|
3386
|
-
}
|
|
3387
|
-
if (process$1.platform === 'win32') {
|
|
3388
|
-
// Windows 10 build 10586 is the first Windows release that supports 256 colors.
|
|
3389
|
-
// Windows 10 build 14931 is the first release that supports 16m/TrueColor.
|
|
3390
|
-
const osRelease = os.release().split('.');
|
|
3391
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) {
|
|
3392
|
-
return Number(osRelease[2]) >= 14_931 ? 3 : 2;
|
|
3393
|
-
}
|
|
3394
|
-
return 1;
|
|
3395
|
-
}
|
|
3396
|
-
if ('CI' in env) {
|
|
3397
|
-
if ('GITHUB_ACTIONS' in env) {
|
|
3398
|
-
return 3;
|
|
3399
|
-
}
|
|
3400
|
-
if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
|
|
3401
|
-
return 1;
|
|
3402
|
-
}
|
|
3403
|
-
return min;
|
|
3404
|
-
}
|
|
3405
|
-
if ('TEAMCITY_VERSION' in env) {
|
|
3406
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
3407
|
-
}
|
|
3408
|
-
if (env.COLORTERM === 'truecolor') {
|
|
3409
|
-
return 3;
|
|
3410
|
-
}
|
|
3411
|
-
if (env.TERM === 'xterm-kitty') {
|
|
3412
|
-
return 3;
|
|
3413
|
-
}
|
|
3414
|
-
if ('TERM_PROGRAM' in env) {
|
|
3415
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
3416
|
-
switch (env.TERM_PROGRAM) {
|
|
3417
|
-
case 'iTerm.app':
|
|
3418
|
-
return version >= 3 ? 3 : 2;
|
|
3419
|
-
case 'Apple_Terminal':
|
|
3420
|
-
return 2;
|
|
3421
|
-
// No default
|
|
3422
|
-
}
|
|
3423
|
-
}
|
|
3424
|
-
|
|
3425
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
3426
|
-
return 2;
|
|
3427
|
-
}
|
|
3428
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
3429
|
-
return 1;
|
|
3430
|
-
}
|
|
3431
|
-
if ('COLORTERM' in env) {
|
|
3432
|
-
return 1;
|
|
3433
|
-
}
|
|
3434
|
-
return min;
|
|
3435
|
-
}
|
|
3436
|
-
function createSupportsColor(stream, options = {}) {
|
|
3437
|
-
const level = _supportsColor(stream, {
|
|
3438
|
-
streamIsTTY: stream && stream.isTTY,
|
|
3439
|
-
...options
|
|
3440
|
-
});
|
|
3441
|
-
return translateLevel(level);
|
|
3442
|
-
}
|
|
3443
|
-
({
|
|
3444
|
-
stdout: createSupportsColor({
|
|
3445
|
-
isTTY: tty.isatty(1)
|
|
3446
|
-
}),
|
|
3447
|
-
stderr: createSupportsColor({
|
|
3448
|
-
isTTY: tty.isatty(2)
|
|
3449
|
-
})
|
|
3450
|
-
});
|
|
3451
|
-
|
|
3452
|
-
createSupportsColor(process.stdout).hasBasic;
|
|
3453
|
-
|
|
3454
|
-
// GitHub workflow does support ANSI but "supports-color" returns false
|
|
3455
|
-
// because stream.isTTY returns false, see https://github.com/actions/runner/issues/241
|
|
3456
|
-
if (process.env.GITHUB_WORKFLOW) {
|
|
3457
|
-
// Check on FORCE_COLOR is to ensure it is prio over GitHub workflow check
|
|
3458
|
-
if (process.env.FORCE_COLOR !== "false") ;
|
|
3459
|
-
}
|
|
3460
|
-
|
|
3461
|
-
// see also https://github.com/sindresorhus/figures
|
|
3462
|
-
isUnicodeSupported();
|
|
3463
|
-
|
|
3464
|
-
const createDetailedMessage$1 = (message, details = {}) => {
|
|
3465
|
-
let string = `${message}`;
|
|
3466
|
-
Object.keys(details).forEach(key => {
|
|
3467
|
-
const value = details[key];
|
|
3468
|
-
string += `
|
|
3469
|
-
--- ${key} ---
|
|
3470
|
-
${Array.isArray(value) ? value.join(`
|
|
3471
|
-
`) : value}`;
|
|
3472
|
-
});
|
|
3473
|
-
return string;
|
|
3474
|
-
};
|
|
3475
|
-
|
|
3476
3213
|
const memoize = compute => {
|
|
3477
3214
|
let memoized = false;
|
|
3478
3215
|
let memoizedValue;
|
|
@@ -8374,7 +8111,7 @@ const createResolveUrlError = ({
|
|
|
8374
8111
|
reason,
|
|
8375
8112
|
...details
|
|
8376
8113
|
}) => {
|
|
8377
|
-
const resolveError = new Error(createDetailedMessage$
|
|
8114
|
+
const resolveError = new Error(createDetailedMessage$1(`Failed to resolve url reference`, {
|
|
8378
8115
|
reason,
|
|
8379
8116
|
...details,
|
|
8380
8117
|
"specifier": `"${reference.specifier}"`,
|
|
@@ -8408,7 +8145,7 @@ const createFetchUrlContentError = ({
|
|
|
8408
8145
|
reason,
|
|
8409
8146
|
...details
|
|
8410
8147
|
}) => {
|
|
8411
|
-
const fetchError = new Error(createDetailedMessage$
|
|
8148
|
+
const fetchError = new Error(createDetailedMessage$1(`Failed to fetch url content`, {
|
|
8412
8149
|
reason,
|
|
8413
8150
|
...details,
|
|
8414
8151
|
"url": urlInfo.url,
|
|
@@ -8475,7 +8212,7 @@ const createTransformUrlContentError = ({
|
|
|
8475
8212
|
reason,
|
|
8476
8213
|
...details
|
|
8477
8214
|
}) => {
|
|
8478
|
-
const transformError = new Error(createDetailedMessage$
|
|
8215
|
+
const transformError = new Error(createDetailedMessage$1(`"transformUrlContent" error on "${urlInfo.type}"`, {
|
|
8479
8216
|
reason,
|
|
8480
8217
|
...details,
|
|
8481
8218
|
"url": urlInfo.url,
|
|
@@ -8528,7 +8265,7 @@ const createFinalizeUrlContentError = ({
|
|
|
8528
8265
|
urlInfo,
|
|
8529
8266
|
error
|
|
8530
8267
|
}) => {
|
|
8531
|
-
const finalizeError = new Error(createDetailedMessage$
|
|
8268
|
+
const finalizeError = new Error(createDetailedMessage$1(`"finalizeUrlContent" error on "${urlInfo.type}"`, {
|
|
8532
8269
|
...detailsFromValueThrown(error),
|
|
8533
8270
|
"url": urlInfo.url,
|
|
8534
8271
|
"url reference trace": reference.trace.message,
|
|
@@ -8770,7 +8507,7 @@ const createKitchen = ({
|
|
|
8770
8507
|
writeGeneratedFiles,
|
|
8771
8508
|
outDirectoryUrl
|
|
8772
8509
|
}) => {
|
|
8773
|
-
const logger = createLogger
|
|
8510
|
+
const logger = createLogger({
|
|
8774
8511
|
logLevel
|
|
8775
8512
|
});
|
|
8776
8513
|
const kitchenContext = {
|
|
@@ -9030,7 +8767,7 @@ ${ANSI.color(normalizedReturnValue, ANSI.YELLOW)}
|
|
|
9030
8767
|
try {
|
|
9031
8768
|
const fetchUrlContentReturnValue = await pluginController.callAsyncHooksUntil("fetchUrlContent", urlInfo, contextDuringFetch);
|
|
9032
8769
|
if (!fetchUrlContentReturnValue) {
|
|
9033
|
-
logger.warn(createDetailedMessage$
|
|
8770
|
+
logger.warn(createDetailedMessage$1(`no plugin has handled url during "fetchUrlContent" hook -> url will be ignored`, {
|
|
9034
8771
|
"url": urlInfo.url,
|
|
9035
8772
|
"url reference trace": reference.trace.message
|
|
9036
8773
|
}));
|
|
@@ -18013,17 +17750,16 @@ const babelPluginMetadataImportMetaScenarios = () => {
|
|
|
18013
17750
|
};
|
|
18014
17751
|
};
|
|
18015
17752
|
|
|
18016
|
-
|
|
18017
|
-
const jsenvPluginCssParcel = () => {
|
|
17753
|
+
const jsenvPluginCssTranspilation = () => {
|
|
18018
17754
|
return {
|
|
18019
|
-
name: "jsenv:
|
|
17755
|
+
name: "jsenv:css_transpilation",
|
|
18020
17756
|
appliesDuring: "*",
|
|
18021
17757
|
transformUrlContent: {
|
|
18022
|
-
css: (urlInfo, context) => {
|
|
17758
|
+
css: async (urlInfo, context) => {
|
|
18023
17759
|
const {
|
|
18024
17760
|
code,
|
|
18025
17761
|
map
|
|
18026
|
-
} =
|
|
17762
|
+
} = await transpileCss(urlInfo, context);
|
|
18027
17763
|
return {
|
|
18028
17764
|
content: String(code),
|
|
18029
17765
|
sourcemap: map
|
|
@@ -18032,6 +17768,44 @@ const jsenvPluginCssParcel = () => {
|
|
|
18032
17768
|
}
|
|
18033
17769
|
};
|
|
18034
17770
|
};
|
|
17771
|
+
const transpileCss = async (urlInfo, context) => {
|
|
17772
|
+
// https://lightningcss.dev/docs.html
|
|
17773
|
+
const {
|
|
17774
|
+
transform
|
|
17775
|
+
} = await import("lightningcss");
|
|
17776
|
+
const targets = runtimeCompatToTargets(context.runtimeCompat);
|
|
17777
|
+
const {
|
|
17778
|
+
code,
|
|
17779
|
+
map
|
|
17780
|
+
} = transform({
|
|
17781
|
+
filename: fileURLToPath(urlInfo.originalUrl),
|
|
17782
|
+
code: Buffer.from(urlInfo.content),
|
|
17783
|
+
targets,
|
|
17784
|
+
minify: false,
|
|
17785
|
+
drafts: {
|
|
17786
|
+
nesting: true,
|
|
17787
|
+
customMedia: true
|
|
17788
|
+
}
|
|
17789
|
+
});
|
|
17790
|
+
return {
|
|
17791
|
+
code,
|
|
17792
|
+
map
|
|
17793
|
+
};
|
|
17794
|
+
};
|
|
17795
|
+
const runtimeCompatToTargets = runtimeCompat => {
|
|
17796
|
+
const targets = {};
|
|
17797
|
+
["chrome", "firefox", "ie", "opera", "safari"].forEach(runtimeName => {
|
|
17798
|
+
const version = runtimeCompat[runtimeName];
|
|
17799
|
+
if (version) {
|
|
17800
|
+
targets[runtimeName] = versionToBits(version);
|
|
17801
|
+
}
|
|
17802
|
+
});
|
|
17803
|
+
return targets;
|
|
17804
|
+
};
|
|
17805
|
+
const versionToBits = version => {
|
|
17806
|
+
const [major, minor = 0, patch = 0] = version.split("-")[0].split(".").map(v => parseInt(v, 10));
|
|
17807
|
+
return major << 16 | minor << 8 | patch;
|
|
17808
|
+
};
|
|
18035
17809
|
|
|
18036
17810
|
/*
|
|
18037
17811
|
* Jsenv wont touch code where "specifier" or "type" is dynamic (see code below)
|
|
@@ -19469,7 +19243,7 @@ const jsenvPluginTranspilation = ({
|
|
|
19469
19243
|
}), jsenvPluginAsJsModule(),
|
|
19470
19244
|
// topLevelAwait must come after jsenvPluginAsJsClassic because it's related to the module format
|
|
19471
19245
|
// so we want to wait to know the module format before transforming things related to top level await
|
|
19472
|
-
...(topLevelAwait ? [jsenvPluginTopLevelAwait()] : []), ...(css ? [
|
|
19246
|
+
...(topLevelAwait ? [jsenvPluginTopLevelAwait()] : []), ...(css ? [jsenvPluginCssTranspilation()] : [])];
|
|
19473
19247
|
};
|
|
19474
19248
|
|
|
19475
19249
|
const jsenvPluginNodeRuntime = ({
|
|
@@ -20769,7 +20543,7 @@ const build = async ({
|
|
|
20769
20543
|
signal,
|
|
20770
20544
|
logLevel
|
|
20771
20545
|
}) => {
|
|
20772
|
-
const logger = createLogger
|
|
20546
|
+
const logger = createLogger({
|
|
20773
20547
|
logLevel
|
|
20774
20548
|
});
|
|
20775
20549
|
const buildOperation = Abort.startOperation();
|
|
@@ -21040,7 +20814,7 @@ ${ANSI.color(buildUrl, ANSI.MAGENTA)}
|
|
|
21040
20814
|
const rawUrl = buildDirectoryRedirections.get(url) || url;
|
|
21041
20815
|
const rawUrlInfo = rawGraph.getUrlInfo(rawUrl);
|
|
21042
20816
|
if (!rawUrlInfo) {
|
|
21043
|
-
throw new Error(createDetailedMessage$
|
|
20817
|
+
throw new Error(createDetailedMessage$1(`Cannot find url`, {
|
|
21044
20818
|
url,
|
|
21045
20819
|
"raw urls": Array.from(buildDirectoryRedirections.values()),
|
|
21046
20820
|
"build urls": Array.from(buildDirectoryRedirections.keys())
|
|
@@ -22627,7 +22401,7 @@ const startDevServer = async ({
|
|
|
22627
22401
|
// and mitigates https://github.com/actions/runner-images/issues/3885
|
|
22628
22402
|
writeGeneratedFiles = !process.env.CI
|
|
22629
22403
|
}) => {
|
|
22630
|
-
const logger = createLogger
|
|
22404
|
+
const logger = createLogger({
|
|
22631
22405
|
logLevel
|
|
22632
22406
|
});
|
|
22633
22407
|
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
|
@@ -22949,7 +22723,7 @@ const readNodeV8CoverageDirectory = async ({
|
|
|
22949
22723
|
timeSpentTrying += 200;
|
|
22950
22724
|
return tryReadJsonFile();
|
|
22951
22725
|
}
|
|
22952
|
-
console.warn(createDetailedMessage$
|
|
22726
|
+
console.warn(createDetailedMessage$1(`Error while reading coverage file`, {
|
|
22953
22727
|
"error stack": e.stack,
|
|
22954
22728
|
"file": dirEntryUrl
|
|
22955
22729
|
}));
|
|
@@ -23110,7 +22884,7 @@ const composeV8AndIstanbul = (v8FileByFileCoverage, istanbulFileByFileCoverage,
|
|
|
23110
22884
|
const v8Coverage = v8FileByFileCoverage[key];
|
|
23111
22885
|
if (v8Coverage) {
|
|
23112
22886
|
if (coverageV8ConflictWarning) {
|
|
23113
|
-
console.warn(createDetailedMessage$
|
|
22887
|
+
console.warn(createDetailedMessage$1(`Coverage conflict on "${key}", found two coverage that cannot be merged together: v8 and istanbul. The istanbul coverage will be ignored.`, {
|
|
23114
22888
|
details: `This happens when a file is executed on a runtime using v8 coverage (node or chromium) and on runtime using istanbul coverage (firefox or webkit)`,
|
|
23115
22889
|
suggestion: "You can disable this warning with coverageV8ConflictWarning: false"
|
|
23116
22890
|
}));
|
|
@@ -23612,7 +23386,7 @@ const generateFileExecutionSteps = ({
|
|
|
23612
23386
|
return;
|
|
23613
23387
|
}
|
|
23614
23388
|
if (typeof stepConfig !== "object") {
|
|
23615
|
-
throw new TypeError(createDetailedMessage$
|
|
23389
|
+
throw new TypeError(createDetailedMessage$1(`found unexpected value in plan, they must be object`, {
|
|
23616
23390
|
["file relative path"]: fileRelativeUrl,
|
|
23617
23391
|
["execution name"]: executionName,
|
|
23618
23392
|
["value"]: stepConfig
|
|
@@ -24025,7 +23799,7 @@ const executePlan = async (plan, {
|
|
|
24025
23799
|
}
|
|
24026
23800
|
});
|
|
24027
23801
|
});
|
|
24028
|
-
logger.debug(createDetailedMessage$
|
|
23802
|
+
logger.debug(createDetailedMessage$1(`Prepare executing plan`, {
|
|
24029
23803
|
runtimes: JSON.stringify(runtimes, null, " ")
|
|
24030
23804
|
}));
|
|
24031
23805
|
const multipleExecutionsOperation = Abort.startOperation();
|
|
@@ -24052,7 +23826,7 @@ const executePlan = async (plan, {
|
|
|
24052
23826
|
await ensureEmptyDirectory(process.env.NODE_V8_COVERAGE);
|
|
24053
23827
|
} else {
|
|
24054
23828
|
coverageMethodForNodeJs = "Profiler";
|
|
24055
|
-
logger.warn(createDetailedMessage$
|
|
23829
|
+
logger.warn(createDetailedMessage$1(`process.env.NODE_V8_COVERAGE is required to generate coverage for Node.js subprocesses`, {
|
|
24056
23830
|
"suggestion": `set process.env.NODE_V8_COVERAGE`,
|
|
24057
23831
|
"suggestion 2": `use coverageMethodForNodeJs: "Profiler". But it means coverage for child_process and worker_thread cannot be collected`
|
|
24058
23832
|
}));
|
|
@@ -24485,7 +24259,7 @@ const executeTestPlan = async ({
|
|
|
24485
24259
|
coverageReportJsonFile = process.env.CI ? null : "./.coverage/coverage.json",
|
|
24486
24260
|
coverageReportHtmlDirectory = process.env.CI ? "./.coverage/" : null
|
|
24487
24261
|
}) => {
|
|
24488
|
-
const logger = createLogger
|
|
24262
|
+
const logger = createLogger({
|
|
24489
24263
|
logLevel
|
|
24490
24264
|
});
|
|
24491
24265
|
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
|
@@ -24517,7 +24291,7 @@ const executeTestPlan = async ({
|
|
|
24517
24291
|
});
|
|
24518
24292
|
if (patternsMatchingCoverAndExecute.length) {
|
|
24519
24293
|
// It would be strange, for a given file to be both covered and executed
|
|
24520
|
-
throw new Error(createDetailedMessage$
|
|
24294
|
+
throw new Error(createDetailedMessage$1(`some file will be both covered and executed`, {
|
|
24521
24295
|
patterns: patternsMatchingCoverAndExecute
|
|
24522
24296
|
}));
|
|
24523
24297
|
}
|
|
@@ -25017,7 +24791,7 @@ const importPlaywright = async ({
|
|
|
25017
24791
|
return namespace;
|
|
25018
24792
|
} catch (e) {
|
|
25019
24793
|
if (e.code === "ERR_MODULE_NOT_FOUND") {
|
|
25020
|
-
throw new Error(createDetailedMessage$
|
|
24794
|
+
throw new Error(createDetailedMessage$1(`"playwright" not found. You need playwright in your dependencies to use "${browserName}"`, {
|
|
25021
24795
|
suggestion: `npm install --save-dev playwright`
|
|
25022
24796
|
}), {
|
|
25023
24797
|
cause: e
|
|
@@ -25172,7 +24946,7 @@ const createChildExecOptions = async ({
|
|
|
25172
24946
|
debugModeInheritBreak = true
|
|
25173
24947
|
} = {}) => {
|
|
25174
24948
|
if (typeof debugMode === "string" && AVAILABLE_DEBUG_MODE.indexOf(debugMode) === -1) {
|
|
25175
|
-
throw new TypeError(createDetailedMessage$
|
|
24949
|
+
throw new TypeError(createDetailedMessage$1(`unexpected debug mode.`, {
|
|
25176
24950
|
["debug mode"]: debugMode,
|
|
25177
24951
|
["allowed debug mode"]: AVAILABLE_DEBUG_MODE
|
|
25178
24952
|
}));
|
|
@@ -25438,7 +25212,7 @@ nodeChildProcess.run = async ({
|
|
|
25438
25212
|
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
25439
25213
|
env: envForChildProcess
|
|
25440
25214
|
});
|
|
25441
|
-
logger.debug(createDetailedMessage$
|
|
25215
|
+
logger.debug(createDetailedMessage$1(`child process forked (pid ${childProcess.pid})`, {
|
|
25442
25216
|
"execArgv": execArgv.join(`\n`),
|
|
25443
25217
|
"custom env": JSON.stringify(env, null, " ")
|
|
25444
25218
|
}));
|
|
@@ -25991,7 +25765,7 @@ const startBuildServer = async ({
|
|
|
25991
25765
|
buildServerMainFile = getCallerPosition().url,
|
|
25992
25766
|
cooldownBetweenFileEvents
|
|
25993
25767
|
}) => {
|
|
25994
|
-
const logger = createLogger
|
|
25768
|
+
const logger = createLogger({
|
|
25995
25769
|
logLevel
|
|
25996
25770
|
});
|
|
25997
25771
|
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
|
@@ -26189,7 +25963,7 @@ const execute = async ({
|
|
|
26189
25963
|
runtimeParams,
|
|
26190
25964
|
ignoreError = false
|
|
26191
25965
|
}) => {
|
|
26192
|
-
const logger = createLogger
|
|
25966
|
+
const logger = createLogger({
|
|
26193
25967
|
logLevel
|
|
26194
25968
|
});
|
|
26195
25969
|
rootDirectoryUrl = assertAndNormalizeDirectoryUrl(rootDirectoryUrl);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "30.0
|
|
3
|
+
"version": "30.1.0",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -62,20 +62,20 @@
|
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@babel/plugin-proposal-dynamic-import": "7.18.6",
|
|
65
|
-
"@babel/plugin-transform-modules-systemjs": "7.
|
|
65
|
+
"@babel/plugin-transform-modules-systemjs": "7.20.11",
|
|
66
66
|
"@babel/plugin-transform-modules-umd": "7.18.6",
|
|
67
67
|
"@c88/v8-coverage": "0.1.1",
|
|
68
68
|
"@financial-times/polyfill-useragent-normaliser": "1.10.2",
|
|
69
69
|
"@jsenv/abort": "4.2.4",
|
|
70
|
-
"@jsenv/ast": "
|
|
71
|
-
"@jsenv/babel-plugins": "1.1.
|
|
72
|
-
"@jsenv/plugin-bundling": "1.0.
|
|
70
|
+
"@jsenv/ast": "2.0.0",
|
|
71
|
+
"@jsenv/babel-plugins": "1.1.2",
|
|
72
|
+
"@jsenv/plugin-bundling": "1.0.5",
|
|
73
73
|
"@jsenv/filesystem": "4.1.9",
|
|
74
74
|
"@jsenv/importmap": "1.2.1",
|
|
75
75
|
"@jsenv/integrity": "0.0.1",
|
|
76
76
|
"@jsenv/log": "3.3.3",
|
|
77
77
|
"@jsenv/node-esm-resolution": "1.0.1",
|
|
78
|
-
"@jsenv/server": "14.1.
|
|
78
|
+
"@jsenv/server": "14.1.15",
|
|
79
79
|
"@jsenv/sourcemap": "1.0.8",
|
|
80
80
|
"@jsenv/uneval": "1.6.0",
|
|
81
81
|
"@jsenv/url-meta": "7.0.2",
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"istanbul-lib-report": "3.0.0",
|
|
89
89
|
"istanbul-reports": "3.1.5",
|
|
90
90
|
"launch-editor": "2.6.0",
|
|
91
|
+
"lightningcss": "1.18.0",
|
|
91
92
|
"pidtree": "0.6.0",
|
|
92
93
|
"string-width": "5.1.2",
|
|
93
94
|
"strip-ansi": "7.0.1",
|
|
@@ -106,11 +107,11 @@
|
|
|
106
107
|
"@jsenv/plugin-globals": "./packages/jsenv-plugin-globals/",
|
|
107
108
|
"@jsenv/plugin-placeholders": "./packages/jsenv-plugin-placeholders/",
|
|
108
109
|
"@jsenv/performance-impact": "4.1.0",
|
|
109
|
-
"eslint": "8.
|
|
110
|
+
"eslint": "8.31.0",
|
|
110
111
|
"eslint-plugin-html": "7.1.0",
|
|
111
112
|
"eslint-plugin-import": "2.26.0",
|
|
112
113
|
"eslint-plugin-react": "7.31.11",
|
|
113
|
-
"playwright": "1.29.
|
|
114
|
-
"prettier": "2.8.
|
|
114
|
+
"playwright": "1.29.2",
|
|
115
|
+
"prettier": "2.8.2"
|
|
115
116
|
}
|
|
116
117
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url"
|
|
2
|
+
|
|
3
|
+
export const jsenvPluginCssTranspilation = () => {
|
|
4
|
+
return {
|
|
5
|
+
name: "jsenv:css_transpilation",
|
|
6
|
+
appliesDuring: "*",
|
|
7
|
+
transformUrlContent: {
|
|
8
|
+
css: async (urlInfo, context) => {
|
|
9
|
+
const { code, map } = await transpileCss(urlInfo, context)
|
|
10
|
+
return {
|
|
11
|
+
content: String(code),
|
|
12
|
+
sourcemap: map,
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const transpileCss = async (urlInfo, context) => {
|
|
20
|
+
// https://lightningcss.dev/docs.html
|
|
21
|
+
const { transform } = await import("lightningcss")
|
|
22
|
+
|
|
23
|
+
const targets = runtimeCompatToTargets(context.runtimeCompat)
|
|
24
|
+
const { code, map } = transform({
|
|
25
|
+
filename: fileURLToPath(urlInfo.originalUrl),
|
|
26
|
+
code: Buffer.from(urlInfo.content),
|
|
27
|
+
targets,
|
|
28
|
+
minify: false,
|
|
29
|
+
drafts: {
|
|
30
|
+
nesting: true,
|
|
31
|
+
customMedia: true,
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
return { code, map }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const runtimeCompatToTargets = (runtimeCompat) => {
|
|
38
|
+
const targets = {}
|
|
39
|
+
;["chrome", "firefox", "ie", "opera", "safari"].forEach((runtimeName) => {
|
|
40
|
+
const version = runtimeCompat[runtimeName]
|
|
41
|
+
if (version) {
|
|
42
|
+
targets[runtimeName] = versionToBits(version)
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
return targets
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const versionToBits = (version) => {
|
|
49
|
+
const [major, minor = 0, patch = 0] = version
|
|
50
|
+
.split("-")[0]
|
|
51
|
+
.split(".")
|
|
52
|
+
.map((v) => parseInt(v, 10))
|
|
53
|
+
return (major << 16) | (minor << 8) | patch
|
|
54
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* of this plugin
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { jsenvPluginCssTranspilation } from "./css/jsenv_plugin_css_transpilation.js"
|
|
11
11
|
import { jsenvPluginImportAssertions } from "./import_assertions/jsenv_plugin_import_assertions.js"
|
|
12
12
|
import { jsenvPluginAsJsClassic } from "./as_js_classic/jsenv_plugin_as_js_classic.js"
|
|
13
13
|
import { jsenvPluginAsJsModule } from "./as_js_module/jsenv_plugin_as_js_module.js"
|
|
@@ -52,6 +52,6 @@ export const jsenvPluginTranspilation = ({
|
|
|
52
52
|
// topLevelAwait must come after jsenvPluginAsJsClassic because it's related to the module format
|
|
53
53
|
// so we want to wait to know the module format before transforming things related to top level await
|
|
54
54
|
...(topLevelAwait ? [jsenvPluginTopLevelAwait(topLevelAwait)] : []),
|
|
55
|
-
...(css ? [
|
|
55
|
+
...(css ? [jsenvPluginCssTranspilation()] : []),
|
|
56
56
|
]
|
|
57
57
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { transpileWithParcel } from "@jsenv/ast"
|
|
2
|
-
|
|
3
|
-
// https://github.com/parcel-bundler/parcel-css
|
|
4
|
-
export const jsenvPluginCssParcel = () => {
|
|
5
|
-
return {
|
|
6
|
-
name: "jsenv:css_parcel",
|
|
7
|
-
appliesDuring: "*",
|
|
8
|
-
transformUrlContent: {
|
|
9
|
-
css: (urlInfo, context) => {
|
|
10
|
-
const { code, map } = transpileWithParcel(urlInfo, context)
|
|
11
|
-
return {
|
|
12
|
-
content: String(code),
|
|
13
|
-
sourcemap: map,
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
}
|
|
18
|
-
}
|