@gjsify/example-dom-canvas2d-fireworks 0.2.0 → 0.3.1
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/gjs.js +2157 -9
- package/package.json +4 -4
package/dist/gjs.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
if(typeof globalThis.process==="undefined"){const _s=imports.system,_G=imports.gi.GLib;globalThis.process={platform:"linux",arch:"x64",version:"v20.0.0",env:new Proxy({},{get(_,p){return typeof p==="string"?(_G.getenv(p)??undefined):undefined},set(_,p,v){if(typeof p==="string")_G.setenv(p,String(v),true);return true},has(_,p){return typeof p==="string"&&_G.getenv(p)!==null},deleteProperty(_,p){if(typeof p==="string")_G.unsetenv(p);return true},ownKeys(){return _G.listenv()??[]},getOwnPropertyDescriptor(_,p){const v=_G.getenv(p);return v!==null?{value:v,writable:true,enumerable:true,configurable:true}:undefined}}),argv:_s?.programArgs?["gjs",_s.programInvocationName||"",..._s.programArgs]:["gjs"],versions:{},config:{},cwd(){return _G.get_current_dir()||"/"},exit(c){_s.exit(c??0)},stderr:{write(s){printerr(s)}},stdout:{write(s){print(s)}},stdin:null,exitCode:undefined,nextTick(fn,...a){Promise.resolve().then(()=>fn(...a))},hrtime(t){return t?[0,0]:[0,0]},};}
|
|
2
|
+
|
|
1
3
|
// ../../../packages/infra/esbuild-plugin-gjsify/dist/shims/console-gjs.js
|
|
2
4
|
var _isGJS = typeof print === "function" && typeof printerr === "function";
|
|
3
5
|
function _formatArgs(...args) {
|
|
@@ -39,10 +41,10 @@ var Console = class {
|
|
|
39
41
|
_groupIndentation;
|
|
40
42
|
_timers = /* @__PURE__ */ new Map();
|
|
41
43
|
_counters = /* @__PURE__ */ new Map();
|
|
42
|
-
constructor(stdoutOrOptions,
|
|
44
|
+
constructor(stdoutOrOptions, stderr2) {
|
|
43
45
|
if (stdoutOrOptions && typeof stdoutOrOptions.write === "function") {
|
|
44
46
|
this._stdout = stdoutOrOptions;
|
|
45
|
-
this._stderr =
|
|
47
|
+
this._stderr = stderr2 || this._stdout;
|
|
46
48
|
} else if (stdoutOrOptions && typeof stdoutOrOptions === "object") {
|
|
47
49
|
const opts = stdoutOrOptions;
|
|
48
50
|
this._stdout = opts.stdout;
|
|
@@ -218,10 +220,57 @@ var console = {
|
|
|
218
220
|
timeStamp
|
|
219
221
|
};
|
|
220
222
|
|
|
223
|
+
// ../../../packages/gjs/utils/lib/esm/callable.js
|
|
224
|
+
function makeCallable(Cls) {
|
|
225
|
+
return new Proxy(Cls, {
|
|
226
|
+
apply(target, thisArg, args) {
|
|
227
|
+
const tmp = Reflect.construct(target, args, target);
|
|
228
|
+
for (const key of Reflect.ownKeys(tmp)) {
|
|
229
|
+
const desc = Object.getOwnPropertyDescriptor(tmp, key);
|
|
230
|
+
if (desc) Object.defineProperty(thisArg, key, desc);
|
|
231
|
+
}
|
|
232
|
+
return thisArg;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
221
237
|
// ../../../packages/gjs/utils/lib/esm/base64.js
|
|
222
238
|
var B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
223
239
|
var B64_LOOKUP = new Uint8Array(256);
|
|
224
240
|
for (let i = 0; i < B64_CHARS.length; i++) B64_LOOKUP[B64_CHARS.charCodeAt(i)] = i;
|
|
241
|
+
function btoaPolyfill(str) {
|
|
242
|
+
if (typeof globalThis.btoa === "function") return globalThis.btoa(str);
|
|
243
|
+
let result = "";
|
|
244
|
+
let i = 0;
|
|
245
|
+
for (; i + 2 < str.length; i += 3) {
|
|
246
|
+
const n = str.charCodeAt(i) << 16 | str.charCodeAt(i + 1) << 8 | str.charCodeAt(i + 2);
|
|
247
|
+
result += B64_CHARS[n >> 18 & 63] + B64_CHARS[n >> 12 & 63] + B64_CHARS[n >> 6 & 63] + B64_CHARS[n & 63];
|
|
248
|
+
}
|
|
249
|
+
if (i + 1 === str.length) {
|
|
250
|
+
const n = str.charCodeAt(i) << 16;
|
|
251
|
+
result += B64_CHARS[n >> 18 & 63] + B64_CHARS[n >> 12 & 63] + "==";
|
|
252
|
+
} else if (i + 2 === str.length) {
|
|
253
|
+
const n = str.charCodeAt(i) << 16 | str.charCodeAt(i + 1) << 8;
|
|
254
|
+
result += B64_CHARS[n >> 18 & 63] + B64_CHARS[n >> 12 & 63] + B64_CHARS[n >> 6 & 63] + "=";
|
|
255
|
+
}
|
|
256
|
+
return result;
|
|
257
|
+
}
|
|
258
|
+
function base64Decode(str) {
|
|
259
|
+
const cleaned = str.replace(/[=\s]/g, "");
|
|
260
|
+
const bytes = new Uint8Array(cleaned.length * 3 >> 2);
|
|
261
|
+
let bits = 0;
|
|
262
|
+
let collected = 0;
|
|
263
|
+
let pos = 0;
|
|
264
|
+
for (let i = 0; i < cleaned.length; i++) {
|
|
265
|
+
bits = bits << 6 | B64_LOOKUP[cleaned.charCodeAt(i)];
|
|
266
|
+
collected += 6;
|
|
267
|
+
if (collected >= 8) {
|
|
268
|
+
collected -= 8;
|
|
269
|
+
bytes[pos++] = bits >> collected & 255;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return bytes.subarray(0, pos);
|
|
273
|
+
}
|
|
225
274
|
|
|
226
275
|
// ../../../node_modules/@girs/glib-2.0/glib-2.0.js
|
|
227
276
|
import GLib from "gi://GLib?version=2.0";
|
|
@@ -233,6 +282,39 @@ var glib_2_default = glib_2_0_default;
|
|
|
233
282
|
// ../../../packages/gjs/utils/lib/esm/cli.js
|
|
234
283
|
var byteArray = imports.byteArray;
|
|
235
284
|
|
|
285
|
+
// ../../../packages/gjs/utils/lib/esm/encoding.js
|
|
286
|
+
var VALID_ENCODINGS = ["utf8", "ascii", "latin1", "binary", "base64", "base64url", "hex", "ucs2", "utf16le"];
|
|
287
|
+
function normalizeEncoding(enc) {
|
|
288
|
+
if (!enc || enc === "utf8" || enc === "utf-8") return "utf8";
|
|
289
|
+
const lower = ("" + enc).toLowerCase().replace(/-/g, "");
|
|
290
|
+
switch (lower) {
|
|
291
|
+
case "utf8":
|
|
292
|
+
return "utf8";
|
|
293
|
+
case "ascii":
|
|
294
|
+
return "ascii";
|
|
295
|
+
case "latin1":
|
|
296
|
+
case "binary":
|
|
297
|
+
return "latin1";
|
|
298
|
+
case "base64":
|
|
299
|
+
return "base64";
|
|
300
|
+
case "base64url":
|
|
301
|
+
return "base64url";
|
|
302
|
+
case "hex":
|
|
303
|
+
return "hex";
|
|
304
|
+
case "ucs2":
|
|
305
|
+
case "utf16le":
|
|
306
|
+
return "utf16le";
|
|
307
|
+
default:
|
|
308
|
+
return "utf8";
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
function checkEncoding(encoding) {
|
|
312
|
+
const lower = ("" + encoding).toLowerCase().replace(/-/g, "");
|
|
313
|
+
if (!VALID_ENCODINGS.includes(lower)) {
|
|
314
|
+
throw new TypeError(`Unknown encoding: ${encoding}`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
236
318
|
// ../../../packages/gjs/utils/lib/esm/globals.js
|
|
237
319
|
function registerGlobal(name2, value2) {
|
|
238
320
|
if (typeof globalThis[name2] === "undefined") {
|
|
@@ -240,6 +322,26 @@ function registerGlobal(name2, value2) {
|
|
|
240
322
|
}
|
|
241
323
|
}
|
|
242
324
|
|
|
325
|
+
// ../../../packages/gjs/utils/lib/esm/error.js
|
|
326
|
+
var initErrorV8Methods = (ErrorConstructor) => {
|
|
327
|
+
if (!Error.captureStackTrace) {
|
|
328
|
+
Error.captureStackTrace = function(targetObject, constructorOpt) {
|
|
329
|
+
const container = new Error();
|
|
330
|
+
const target = constructorOpt || targetObject;
|
|
331
|
+
Object.defineProperty(target, "stack", {
|
|
332
|
+
configurable: true,
|
|
333
|
+
get: function getStack() {
|
|
334
|
+
var stack = container.stack;
|
|
335
|
+
Object.defineProperty(this, "stack", {
|
|
336
|
+
value: stack
|
|
337
|
+
});
|
|
338
|
+
return stack;
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
243
345
|
// ../../../packages/gjs/utils/lib/esm/file.js
|
|
244
346
|
var byteArray2 = imports.byteArray;
|
|
245
347
|
|
|
@@ -256,12 +358,43 @@ import GioUnix from "gi://GioUnix?version=2.0";
|
|
|
256
358
|
// ../../../packages/gjs/utils/lib/esm/gio.js
|
|
257
359
|
var byteArray3 = imports.byteArray;
|
|
258
360
|
|
|
361
|
+
// ../../../packages/gjs/utils/lib/esm/microtask.js
|
|
362
|
+
var queueMicrotask2 = (fn) => {
|
|
363
|
+
Promise.resolve().then(fn);
|
|
364
|
+
};
|
|
365
|
+
|
|
259
366
|
// ../../../packages/gjs/utils/lib/esm/path.js
|
|
260
367
|
var { File } = gio_2_default;
|
|
261
368
|
|
|
262
369
|
// ../../../packages/gjs/utils/lib/esm/structured-clone.js
|
|
263
370
|
var { toString } = Object.prototype;
|
|
264
371
|
|
|
372
|
+
// ../../../packages/gjs/utils/lib/esm/main-loop.js
|
|
373
|
+
var _started = false;
|
|
374
|
+
var _loop = null;
|
|
375
|
+
function ensureMainLoop() {
|
|
376
|
+
const gjsImports = globalThis.imports;
|
|
377
|
+
if (!gjsImports) return void 0;
|
|
378
|
+
if (_started) return _loop;
|
|
379
|
+
const GLibModule = gjsImports.gi.GLib;
|
|
380
|
+
_loop = new GLibModule.MainLoop(null, false);
|
|
381
|
+
_started = true;
|
|
382
|
+
if (GLibModule.main_depth() === 0) {
|
|
383
|
+
try {
|
|
384
|
+
_loop.runAsync();
|
|
385
|
+
} catch {
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return _loop;
|
|
389
|
+
}
|
|
390
|
+
function quitMainLoop() {
|
|
391
|
+
if (_loop) {
|
|
392
|
+
_loop.quit();
|
|
393
|
+
_started = false;
|
|
394
|
+
_loop = null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
265
398
|
// ../../../packages/node/buffer/lib/esm/blob.js
|
|
266
399
|
var _encoder = new TextEncoder();
|
|
267
400
|
var BlobPolyfill = class _BlobPolyfill {
|
|
@@ -485,7 +618,7 @@ var EventTarget = class {
|
|
|
485
618
|
addEventListener(type, callback, options) {
|
|
486
619
|
if (callback === null) return;
|
|
487
620
|
const capture = typeof options === "boolean" ? options : options?.capture ?? false;
|
|
488
|
-
const
|
|
621
|
+
const once2 = typeof options === "object" ? options?.once ?? false : false;
|
|
489
622
|
const passive = typeof options === "object" ? options?.passive ?? false : false;
|
|
490
623
|
let list = this._listeners.get(type);
|
|
491
624
|
if (!list) {
|
|
@@ -495,7 +628,7 @@ var EventTarget = class {
|
|
|
495
628
|
for (const entry2 of list) {
|
|
496
629
|
if (entry2.listener === callback && entry2.capture === capture) return;
|
|
497
630
|
}
|
|
498
|
-
const entry = { listener: callback, capture, once, passive, removed: false };
|
|
631
|
+
const entry = { listener: callback, capture, once: once2, passive, removed: false };
|
|
499
632
|
list.push(entry);
|
|
500
633
|
if (typeof options === "object" && options?.signal) {
|
|
501
634
|
options.signal.addEventListener("abort", () => {
|
|
@@ -2864,10 +2997,672 @@ if (typeof globalThis.top === "undefined") {
|
|
|
2864
2997
|
});
|
|
2865
2998
|
}
|
|
2866
2999
|
|
|
3000
|
+
// ../../../packages/node/buffer/lib/esm/buffer.js
|
|
3001
|
+
var textEncoder = new TextEncoder();
|
|
3002
|
+
var textDecoder = new TextDecoder();
|
|
3003
|
+
var hasSharedArrayBuffer = typeof SharedArrayBuffer !== "undefined";
|
|
3004
|
+
function encodeString(str, encoding) {
|
|
3005
|
+
switch (encoding) {
|
|
3006
|
+
case "utf8":
|
|
3007
|
+
return textEncoder.encode(str);
|
|
3008
|
+
case "ascii": {
|
|
3009
|
+
const buf = new Uint8Array(str.length);
|
|
3010
|
+
for (let i = 0; i < str.length; i++) {
|
|
3011
|
+
buf[i] = str.charCodeAt(i) & 127;
|
|
3012
|
+
}
|
|
3013
|
+
return buf;
|
|
3014
|
+
}
|
|
3015
|
+
case "latin1": {
|
|
3016
|
+
const buf = new Uint8Array(str.length);
|
|
3017
|
+
for (let i = 0; i < str.length; i++) {
|
|
3018
|
+
buf[i] = str.charCodeAt(i) & 255;
|
|
3019
|
+
}
|
|
3020
|
+
return buf;
|
|
3021
|
+
}
|
|
3022
|
+
case "base64": {
|
|
3023
|
+
const standard = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
3024
|
+
return base64Decode(standard);
|
|
3025
|
+
}
|
|
3026
|
+
case "base64url": {
|
|
3027
|
+
const base64 = str.replace(/-/g, "+").replace(/_/g, "/");
|
|
3028
|
+
return encodeString(base64, "base64");
|
|
3029
|
+
}
|
|
3030
|
+
case "hex": {
|
|
3031
|
+
const bytes = str.length >>> 1;
|
|
3032
|
+
const buf = new Uint8Array(bytes);
|
|
3033
|
+
for (let i = 0; i < bytes; i++) {
|
|
3034
|
+
const hi = parseInt(str[i * 2], 16);
|
|
3035
|
+
const lo = parseInt(str[i * 2 + 1], 16);
|
|
3036
|
+
if (Number.isNaN(hi) || Number.isNaN(lo)) break;
|
|
3037
|
+
buf[i] = hi << 4 | lo;
|
|
3038
|
+
}
|
|
3039
|
+
return buf;
|
|
3040
|
+
}
|
|
3041
|
+
case "utf16le": {
|
|
3042
|
+
const buf = new Uint8Array(str.length * 2);
|
|
3043
|
+
for (let i = 0; i < str.length; i++) {
|
|
3044
|
+
const code = str.charCodeAt(i);
|
|
3045
|
+
buf[i * 2] = code & 255;
|
|
3046
|
+
buf[i * 2 + 1] = code >> 8 & 255;
|
|
3047
|
+
}
|
|
3048
|
+
return buf;
|
|
3049
|
+
}
|
|
3050
|
+
default:
|
|
3051
|
+
return textEncoder.encode(str);
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
function decodeString(buf, encoding, start2, end) {
|
|
3055
|
+
const slice = start2 !== void 0 || end !== void 0 ? buf.subarray(start2 ?? 0, end ?? buf.length) : buf;
|
|
3056
|
+
switch (encoding) {
|
|
3057
|
+
case "utf8":
|
|
3058
|
+
return textDecoder.decode(slice);
|
|
3059
|
+
case "ascii": {
|
|
3060
|
+
let result = "";
|
|
3061
|
+
for (let i = 0; i < slice.length; i++) {
|
|
3062
|
+
result += String.fromCharCode(slice[i] & 127);
|
|
3063
|
+
}
|
|
3064
|
+
return result;
|
|
3065
|
+
}
|
|
3066
|
+
case "latin1": {
|
|
3067
|
+
let result = "";
|
|
3068
|
+
for (let i = 0; i < slice.length; i++) {
|
|
3069
|
+
result += String.fromCharCode(slice[i]);
|
|
3070
|
+
}
|
|
3071
|
+
return result;
|
|
3072
|
+
}
|
|
3073
|
+
case "base64": {
|
|
3074
|
+
let binary = "";
|
|
3075
|
+
for (let i = 0; i < slice.length; i++) {
|
|
3076
|
+
binary += String.fromCharCode(slice[i]);
|
|
3077
|
+
}
|
|
3078
|
+
return btoaPolyfill(binary);
|
|
3079
|
+
}
|
|
3080
|
+
case "base64url": {
|
|
3081
|
+
const base64 = decodeString(slice, "base64");
|
|
3082
|
+
return base64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
3083
|
+
}
|
|
3084
|
+
case "hex": {
|
|
3085
|
+
let result = "";
|
|
3086
|
+
for (let i = 0; i < slice.length; i++) {
|
|
3087
|
+
result += slice[i].toString(16).padStart(2, "0");
|
|
3088
|
+
}
|
|
3089
|
+
return result;
|
|
3090
|
+
}
|
|
3091
|
+
case "utf16le": {
|
|
3092
|
+
let result = "";
|
|
3093
|
+
for (let i = 0; i + 1 < slice.length; i += 2) {
|
|
3094
|
+
result += String.fromCharCode(slice[i] | slice[i + 1] << 8);
|
|
3095
|
+
}
|
|
3096
|
+
return result;
|
|
3097
|
+
}
|
|
3098
|
+
default:
|
|
3099
|
+
return textDecoder.decode(slice);
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
function checkOffset(offset, ext, length) {
|
|
3103
|
+
if (offset + ext > length) {
|
|
3104
|
+
throw new RangeError("Attempt to access memory outside buffer bounds");
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
3107
|
+
var Buffer2 = class _Buffer extends Uint8Array {
|
|
3108
|
+
// Marker to identify Buffer instances
|
|
3109
|
+
static _isBuffer = true;
|
|
3110
|
+
// ---- Static constructors ----
|
|
3111
|
+
static alloc(size, fill, encoding) {
|
|
3112
|
+
if (typeof size !== "number") {
|
|
3113
|
+
throw new TypeError(`The "size" argument must be of type number. Received type ${typeof size}`);
|
|
3114
|
+
}
|
|
3115
|
+
if (size < 0) {
|
|
3116
|
+
throw new RangeError(`The value "${size}" is invalid for option "size"`);
|
|
3117
|
+
}
|
|
3118
|
+
const buf = new _Buffer(size);
|
|
3119
|
+
if (fill !== void 0 && fill !== 0) {
|
|
3120
|
+
buf.fill(fill, 0, size, encoding);
|
|
3121
|
+
}
|
|
3122
|
+
return buf;
|
|
3123
|
+
}
|
|
3124
|
+
static allocUnsafe(size) {
|
|
3125
|
+
if (typeof size !== "number") {
|
|
3126
|
+
throw new TypeError(`The "size" argument must be of type number. Received type ${typeof size}`);
|
|
3127
|
+
}
|
|
3128
|
+
return new _Buffer(size);
|
|
3129
|
+
}
|
|
3130
|
+
static allocUnsafeSlow(size) {
|
|
3131
|
+
return _Buffer.allocUnsafe(size);
|
|
3132
|
+
}
|
|
3133
|
+
static from(value2, encodingOrOffset, length) {
|
|
3134
|
+
if (typeof value2 === "string") {
|
|
3135
|
+
const encoding = normalizeEncoding(encodingOrOffset);
|
|
3136
|
+
if (encodingOrOffset && typeof encodingOrOffset === "string") {
|
|
3137
|
+
const lower = ("" + encodingOrOffset).toLowerCase().replace(/-/g, "");
|
|
3138
|
+
const valid = ["utf8", "ascii", "latin1", "binary", "base64", "base64url", "hex", "ucs2", "utf16le", ""];
|
|
3139
|
+
if (!valid.includes(lower)) {
|
|
3140
|
+
checkEncoding(encodingOrOffset);
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
const encoded = encodeString(value2, encoding);
|
|
3144
|
+
const buf = new _Buffer(encoded.buffer, encoded.byteOffset, encoded.byteLength);
|
|
3145
|
+
return buf;
|
|
3146
|
+
}
|
|
3147
|
+
if (ArrayBuffer.isView(value2)) {
|
|
3148
|
+
const buf = new _Buffer(value2.buffer, value2.byteOffset, value2.byteLength);
|
|
3149
|
+
const copy = new _Buffer(buf.length);
|
|
3150
|
+
copy.set(buf);
|
|
3151
|
+
return copy;
|
|
3152
|
+
}
|
|
3153
|
+
if (value2 instanceof ArrayBuffer) {
|
|
3154
|
+
const offset = encodingOrOffset || 0;
|
|
3155
|
+
const len = length !== void 0 ? length : value2.byteLength - offset;
|
|
3156
|
+
return new _Buffer(value2, offset, len);
|
|
3157
|
+
}
|
|
3158
|
+
if (hasSharedArrayBuffer && value2 instanceof SharedArrayBuffer) {
|
|
3159
|
+
const offset = encodingOrOffset || 0;
|
|
3160
|
+
const len = length !== void 0 ? length : value2.byteLength - offset;
|
|
3161
|
+
return new _Buffer(new Uint8Array(value2, offset, len));
|
|
3162
|
+
}
|
|
3163
|
+
if (Array.isArray(value2)) {
|
|
3164
|
+
const buf = new _Buffer(value2.length);
|
|
3165
|
+
for (let i = 0; i < value2.length; i++) {
|
|
3166
|
+
buf[i] = value2[i] & 255;
|
|
3167
|
+
}
|
|
3168
|
+
return buf;
|
|
3169
|
+
}
|
|
3170
|
+
throw new TypeError("The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array");
|
|
3171
|
+
}
|
|
3172
|
+
// ---- Static methods ----
|
|
3173
|
+
static isBuffer(obj) {
|
|
3174
|
+
return obj instanceof _Buffer;
|
|
3175
|
+
}
|
|
3176
|
+
static isEncoding(encoding) {
|
|
3177
|
+
if (typeof encoding !== "string") return false;
|
|
3178
|
+
const lower = encoding.toLowerCase().replace(/-/g, "");
|
|
3179
|
+
return ["utf8", "ascii", "latin1", "binary", "base64", "base64url", "hex", "ucs2", "utf16le"].includes(lower);
|
|
3180
|
+
}
|
|
3181
|
+
static byteLength(string, encoding) {
|
|
3182
|
+
if (typeof string !== "string") {
|
|
3183
|
+
if (ArrayBuffer.isView(string)) return string.byteLength;
|
|
3184
|
+
if (string instanceof ArrayBuffer) return string.byteLength;
|
|
3185
|
+
if (hasSharedArrayBuffer && string instanceof SharedArrayBuffer) return string.byteLength;
|
|
3186
|
+
throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer');
|
|
3187
|
+
}
|
|
3188
|
+
const enc = normalizeEncoding(encoding);
|
|
3189
|
+
switch (enc) {
|
|
3190
|
+
case "utf8":
|
|
3191
|
+
return textEncoder.encode(string).byteLength;
|
|
3192
|
+
case "ascii":
|
|
3193
|
+
case "latin1":
|
|
3194
|
+
return string.length;
|
|
3195
|
+
case "base64":
|
|
3196
|
+
case "base64url": {
|
|
3197
|
+
let len = string.length;
|
|
3198
|
+
while (len > 0 && (string[len - 1] === "=" || string[len - 1] === " ")) len--;
|
|
3199
|
+
return len * 3 >>> 2;
|
|
3200
|
+
}
|
|
3201
|
+
case "hex":
|
|
3202
|
+
return string.length >>> 1;
|
|
3203
|
+
case "utf16le":
|
|
3204
|
+
return string.length * 2;
|
|
3205
|
+
default:
|
|
3206
|
+
return textEncoder.encode(string).byteLength;
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
static compare(buf1, buf2) {
|
|
3210
|
+
if (!(buf1 instanceof Uint8Array) || !(buf2 instanceof Uint8Array)) {
|
|
3211
|
+
throw new TypeError("Arguments must be Buffers or Uint8Arrays");
|
|
3212
|
+
}
|
|
3213
|
+
const len = Math.min(buf1.length, buf2.length);
|
|
3214
|
+
for (let i = 0; i < len; i++) {
|
|
3215
|
+
if (buf1[i] < buf2[i]) return -1;
|
|
3216
|
+
if (buf1[i] > buf2[i]) return 1;
|
|
3217
|
+
}
|
|
3218
|
+
if (buf1.length < buf2.length) return -1;
|
|
3219
|
+
if (buf1.length > buf2.length) return 1;
|
|
3220
|
+
return 0;
|
|
3221
|
+
}
|
|
3222
|
+
static concat(list, totalLength) {
|
|
3223
|
+
if (list.length === 0) return _Buffer.alloc(0);
|
|
3224
|
+
if (totalLength === void 0) {
|
|
3225
|
+
totalLength = 0;
|
|
3226
|
+
for (let i = 0; i < list.length; i++) {
|
|
3227
|
+
totalLength += list[i].length;
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
const result = _Buffer.alloc(totalLength);
|
|
3231
|
+
let offset = 0;
|
|
3232
|
+
for (let i = 0; i < list.length; i++) {
|
|
3233
|
+
const buf = list[i];
|
|
3234
|
+
const toCopy = Math.min(buf.length, totalLength - offset);
|
|
3235
|
+
if (toCopy <= 0) continue;
|
|
3236
|
+
result.set(buf.subarray(0, toCopy), offset);
|
|
3237
|
+
offset += toCopy;
|
|
3238
|
+
}
|
|
3239
|
+
return result;
|
|
3240
|
+
}
|
|
3241
|
+
static poolSize = 8192;
|
|
3242
|
+
// ---- Instance methods ----
|
|
3243
|
+
toString(encoding, start2, end) {
|
|
3244
|
+
const enc = normalizeEncoding(encoding);
|
|
3245
|
+
return decodeString(this, enc, start2, end);
|
|
3246
|
+
}
|
|
3247
|
+
toJSON() {
|
|
3248
|
+
return {
|
|
3249
|
+
type: "Buffer",
|
|
3250
|
+
data: Array.from(this)
|
|
3251
|
+
};
|
|
3252
|
+
}
|
|
3253
|
+
equals(otherBuffer) {
|
|
3254
|
+
if (!(otherBuffer instanceof Uint8Array)) {
|
|
3255
|
+
throw new TypeError("Argument must be a Buffer or Uint8Array");
|
|
3256
|
+
}
|
|
3257
|
+
if (this.length !== otherBuffer.length) return false;
|
|
3258
|
+
for (let i = 0; i < this.length; i++) {
|
|
3259
|
+
if (this[i] !== otherBuffer[i]) return false;
|
|
3260
|
+
}
|
|
3261
|
+
return true;
|
|
3262
|
+
}
|
|
3263
|
+
compare(target, targetStart, targetEnd, sourceStart, sourceEnd) {
|
|
3264
|
+
if (!(target instanceof Uint8Array)) {
|
|
3265
|
+
throw new TypeError("Argument must be a Buffer or Uint8Array");
|
|
3266
|
+
}
|
|
3267
|
+
const src = sourceStart !== void 0 || sourceEnd !== void 0 ? this.subarray(sourceStart ?? 0, sourceEnd ?? this.length) : this;
|
|
3268
|
+
const tgt = targetStart !== void 0 || targetEnd !== void 0 ? target.subarray(targetStart ?? 0, targetEnd ?? target.length) : target;
|
|
3269
|
+
return _Buffer.compare(src, tgt);
|
|
3270
|
+
}
|
|
3271
|
+
copy(target, targetStart = 0, sourceStart = 0, sourceEnd) {
|
|
3272
|
+
const end = sourceEnd ?? this.length;
|
|
3273
|
+
const toCopy = Math.min(end - sourceStart, target.length - targetStart);
|
|
3274
|
+
if (toCopy <= 0) return 0;
|
|
3275
|
+
target.set(this.subarray(sourceStart, sourceStart + toCopy), targetStart);
|
|
3276
|
+
return toCopy;
|
|
3277
|
+
}
|
|
3278
|
+
// slice returns a Buffer (not Uint8Array) that shares memory
|
|
3279
|
+
slice(start2, end) {
|
|
3280
|
+
const s = start2 ?? 0;
|
|
3281
|
+
const e = end ?? this.length;
|
|
3282
|
+
const sub = super.subarray(s, e);
|
|
3283
|
+
return new _Buffer(sub.buffer, sub.byteOffset, sub.byteLength);
|
|
3284
|
+
}
|
|
3285
|
+
// subarray also returns a Buffer
|
|
3286
|
+
subarray(start2, end) {
|
|
3287
|
+
const sub = super.subarray(start2, end);
|
|
3288
|
+
return new _Buffer(sub.buffer, sub.byteOffset, sub.byteLength);
|
|
3289
|
+
}
|
|
3290
|
+
write(string, offset, length, encoding) {
|
|
3291
|
+
offset = offset ?? 0;
|
|
3292
|
+
const enc = normalizeEncoding(encoding || (typeof length === "string" ? length : void 0));
|
|
3293
|
+
const encoded = encodeString(string, enc);
|
|
3294
|
+
const maxLen = length !== void 0 && typeof length === "number" ? Math.min(length, this.length - offset) : this.length - offset;
|
|
3295
|
+
const toCopy = Math.min(encoded.length, maxLen);
|
|
3296
|
+
this.set(encoded.subarray(0, toCopy), offset);
|
|
3297
|
+
return toCopy;
|
|
3298
|
+
}
|
|
3299
|
+
fill(value2, offset, end, encoding) {
|
|
3300
|
+
const start2 = offset ?? 0;
|
|
3301
|
+
const stop = end ?? this.length;
|
|
3302
|
+
if (typeof value2 === "number") {
|
|
3303
|
+
super.fill(value2 & 255, start2, stop);
|
|
3304
|
+
} else if (typeof value2 === "string") {
|
|
3305
|
+
const enc = normalizeEncoding(encoding);
|
|
3306
|
+
const encoded = encodeString(value2, enc);
|
|
3307
|
+
if (encoded.length === 0) {
|
|
3308
|
+
super.fill(0, start2, stop);
|
|
3309
|
+
} else if (encoded.length === 1) {
|
|
3310
|
+
super.fill(encoded[0], start2, stop);
|
|
3311
|
+
} else {
|
|
3312
|
+
for (let i = start2; i < stop; i++) {
|
|
3313
|
+
this[i] = encoded[(i - start2) % encoded.length];
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
} else if (value2 instanceof Uint8Array) {
|
|
3317
|
+
if (value2.length === 0) {
|
|
3318
|
+
super.fill(0, start2, stop);
|
|
3319
|
+
} else {
|
|
3320
|
+
for (let i = start2; i < stop; i++) {
|
|
3321
|
+
this[i] = value2[(i - start2) % value2.length];
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3325
|
+
return this;
|
|
3326
|
+
}
|
|
3327
|
+
indexOf(value2, byteOffset, encoding) {
|
|
3328
|
+
if (typeof value2 === "number") {
|
|
3329
|
+
return super.indexOf(value2 & 255, byteOffset);
|
|
3330
|
+
}
|
|
3331
|
+
const needle = typeof value2 === "string" ? encodeString(value2, normalizeEncoding(encoding)) : value2;
|
|
3332
|
+
const start2 = byteOffset ?? 0;
|
|
3333
|
+
outer:
|
|
3334
|
+
for (let i = start2; i <= this.length - needle.length; i++) {
|
|
3335
|
+
for (let j = 0; j < needle.length; j++) {
|
|
3336
|
+
if (this[i + j] !== needle[j]) continue outer;
|
|
3337
|
+
}
|
|
3338
|
+
return i;
|
|
3339
|
+
}
|
|
3340
|
+
return -1;
|
|
3341
|
+
}
|
|
3342
|
+
lastIndexOf(value2, byteOffset, encoding) {
|
|
3343
|
+
if (typeof value2 === "number") {
|
|
3344
|
+
return byteOffset !== void 0 ? super.lastIndexOf(value2 & 255, byteOffset) : super.lastIndexOf(value2 & 255);
|
|
3345
|
+
}
|
|
3346
|
+
const needle = typeof value2 === "string" ? encodeString(value2, normalizeEncoding(encoding)) : value2;
|
|
3347
|
+
const start2 = byteOffset !== void 0 ? Math.min(byteOffset, this.length - needle.length) : this.length - needle.length;
|
|
3348
|
+
outer:
|
|
3349
|
+
for (let i = start2; i >= 0; i--) {
|
|
3350
|
+
for (let j = 0; j < needle.length; j++) {
|
|
3351
|
+
if (this[i + j] !== needle[j]) continue outer;
|
|
3352
|
+
}
|
|
3353
|
+
return i;
|
|
3354
|
+
}
|
|
3355
|
+
return -1;
|
|
3356
|
+
}
|
|
3357
|
+
includes(value2, byteOffset, encoding) {
|
|
3358
|
+
return this.indexOf(value2, byteOffset, encoding) !== -1;
|
|
3359
|
+
}
|
|
3360
|
+
// ---- Read methods ----
|
|
3361
|
+
readUInt8(offset = 0) {
|
|
3362
|
+
checkOffset(offset, 1, this.length);
|
|
3363
|
+
return this[offset];
|
|
3364
|
+
}
|
|
3365
|
+
readUInt16BE(offset = 0) {
|
|
3366
|
+
checkOffset(offset, 2, this.length);
|
|
3367
|
+
return this[offset] << 8 | this[offset + 1];
|
|
3368
|
+
}
|
|
3369
|
+
readUInt16LE(offset = 0) {
|
|
3370
|
+
checkOffset(offset, 2, this.length);
|
|
3371
|
+
return this[offset] | this[offset + 1] << 8;
|
|
3372
|
+
}
|
|
3373
|
+
readUInt32BE(offset = 0) {
|
|
3374
|
+
checkOffset(offset, 4, this.length);
|
|
3375
|
+
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
3376
|
+
}
|
|
3377
|
+
readUInt32LE(offset = 0) {
|
|
3378
|
+
checkOffset(offset, 4, this.length);
|
|
3379
|
+
return this[offset + 3] * 16777216 + (this[offset + 2] << 16 | this[offset + 1] << 8 | this[offset]) >>> 0;
|
|
3380
|
+
}
|
|
3381
|
+
readInt8(offset = 0) {
|
|
3382
|
+
checkOffset(offset, 1, this.length);
|
|
3383
|
+
return this[offset] | (this[offset] & 128 ? 4294967040 : 0);
|
|
3384
|
+
}
|
|
3385
|
+
readInt16BE(offset = 0) {
|
|
3386
|
+
checkOffset(offset, 2, this.length);
|
|
3387
|
+
const val = this[offset] << 8 | this[offset + 1];
|
|
3388
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
3389
|
+
}
|
|
3390
|
+
readInt16LE(offset = 0) {
|
|
3391
|
+
checkOffset(offset, 2, this.length);
|
|
3392
|
+
const val = this[offset] | this[offset + 1] << 8;
|
|
3393
|
+
return val & 32768 ? val | 4294901760 : val;
|
|
3394
|
+
}
|
|
3395
|
+
readInt32BE(offset = 0) {
|
|
3396
|
+
checkOffset(offset, 4, this.length);
|
|
3397
|
+
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
3398
|
+
}
|
|
3399
|
+
readInt32LE(offset = 0) {
|
|
3400
|
+
checkOffset(offset, 4, this.length);
|
|
3401
|
+
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
3402
|
+
}
|
|
3403
|
+
readFloatBE(offset = 0) {
|
|
3404
|
+
checkOffset(offset, 4, this.length);
|
|
3405
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 4);
|
|
3406
|
+
return view.getFloat32(0, false);
|
|
3407
|
+
}
|
|
3408
|
+
readFloatLE(offset = 0) {
|
|
3409
|
+
checkOffset(offset, 4, this.length);
|
|
3410
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 4);
|
|
3411
|
+
return view.getFloat32(0, true);
|
|
3412
|
+
}
|
|
3413
|
+
readDoubleBE(offset = 0) {
|
|
3414
|
+
checkOffset(offset, 8, this.length);
|
|
3415
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3416
|
+
return view.getFloat64(0, false);
|
|
3417
|
+
}
|
|
3418
|
+
readDoubleLE(offset = 0) {
|
|
3419
|
+
checkOffset(offset, 8, this.length);
|
|
3420
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3421
|
+
return view.getFloat64(0, true);
|
|
3422
|
+
}
|
|
3423
|
+
readBigInt64BE(offset = 0) {
|
|
3424
|
+
checkOffset(offset, 8, this.length);
|
|
3425
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3426
|
+
return view.getBigInt64(0, false);
|
|
3427
|
+
}
|
|
3428
|
+
readBigInt64LE(offset = 0) {
|
|
3429
|
+
checkOffset(offset, 8, this.length);
|
|
3430
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3431
|
+
return view.getBigInt64(0, true);
|
|
3432
|
+
}
|
|
3433
|
+
readBigUInt64BE(offset = 0) {
|
|
3434
|
+
checkOffset(offset, 8, this.length);
|
|
3435
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3436
|
+
return view.getBigUint64(0, false);
|
|
3437
|
+
}
|
|
3438
|
+
readBigUInt64LE(offset = 0) {
|
|
3439
|
+
checkOffset(offset, 8, this.length);
|
|
3440
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3441
|
+
return view.getBigUint64(0, true);
|
|
3442
|
+
}
|
|
3443
|
+
readUIntBE(offset, byteLength) {
|
|
3444
|
+
checkOffset(offset, byteLength, this.length);
|
|
3445
|
+
let val = 0;
|
|
3446
|
+
for (let i = 0; i < byteLength; i++) {
|
|
3447
|
+
val = val * 256 + this[offset + i];
|
|
3448
|
+
}
|
|
3449
|
+
return val;
|
|
3450
|
+
}
|
|
3451
|
+
readUIntLE(offset, byteLength) {
|
|
3452
|
+
checkOffset(offset, byteLength, this.length);
|
|
3453
|
+
let val = 0;
|
|
3454
|
+
let mul = 1;
|
|
3455
|
+
for (let i = 0; i < byteLength; i++) {
|
|
3456
|
+
val += this[offset + i] * mul;
|
|
3457
|
+
mul *= 256;
|
|
3458
|
+
}
|
|
3459
|
+
return val;
|
|
3460
|
+
}
|
|
3461
|
+
readIntBE(offset, byteLength) {
|
|
3462
|
+
checkOffset(offset, byteLength, this.length);
|
|
3463
|
+
let val = 0;
|
|
3464
|
+
for (let i = 0; i < byteLength; i++) {
|
|
3465
|
+
val = val * 256 + this[offset + i];
|
|
3466
|
+
}
|
|
3467
|
+
if (val >= Math.pow(2, 8 * byteLength - 1)) {
|
|
3468
|
+
val -= Math.pow(2, 8 * byteLength);
|
|
3469
|
+
}
|
|
3470
|
+
return val;
|
|
3471
|
+
}
|
|
3472
|
+
readIntLE(offset, byteLength) {
|
|
3473
|
+
checkOffset(offset, byteLength, this.length);
|
|
3474
|
+
let val = 0;
|
|
3475
|
+
let mul = 1;
|
|
3476
|
+
for (let i = 0; i < byteLength; i++) {
|
|
3477
|
+
val += this[offset + i] * mul;
|
|
3478
|
+
mul *= 256;
|
|
3479
|
+
}
|
|
3480
|
+
if (val >= Math.pow(2, 8 * byteLength - 1)) {
|
|
3481
|
+
val -= Math.pow(2, 8 * byteLength);
|
|
3482
|
+
}
|
|
3483
|
+
return val;
|
|
3484
|
+
}
|
|
3485
|
+
// ---- Write methods ----
|
|
3486
|
+
writeUInt8(value2, offset = 0) {
|
|
3487
|
+
checkOffset(offset, 1, this.length);
|
|
3488
|
+
this[offset] = value2 & 255;
|
|
3489
|
+
return offset + 1;
|
|
3490
|
+
}
|
|
3491
|
+
writeUInt16BE(value2, offset = 0) {
|
|
3492
|
+
checkOffset(offset, 2, this.length);
|
|
3493
|
+
this[offset] = value2 >>> 8 & 255;
|
|
3494
|
+
this[offset + 1] = value2 & 255;
|
|
3495
|
+
return offset + 2;
|
|
3496
|
+
}
|
|
3497
|
+
writeUInt16LE(value2, offset = 0) {
|
|
3498
|
+
checkOffset(offset, 2, this.length);
|
|
3499
|
+
this[offset] = value2 & 255;
|
|
3500
|
+
this[offset + 1] = value2 >>> 8 & 255;
|
|
3501
|
+
return offset + 2;
|
|
3502
|
+
}
|
|
3503
|
+
writeUInt32BE(value2, offset = 0) {
|
|
3504
|
+
checkOffset(offset, 4, this.length);
|
|
3505
|
+
this[offset] = value2 >>> 24 & 255;
|
|
3506
|
+
this[offset + 1] = value2 >>> 16 & 255;
|
|
3507
|
+
this[offset + 2] = value2 >>> 8 & 255;
|
|
3508
|
+
this[offset + 3] = value2 & 255;
|
|
3509
|
+
return offset + 4;
|
|
3510
|
+
}
|
|
3511
|
+
writeUInt32LE(value2, offset = 0) {
|
|
3512
|
+
checkOffset(offset, 4, this.length);
|
|
3513
|
+
this[offset] = value2 & 255;
|
|
3514
|
+
this[offset + 1] = value2 >>> 8 & 255;
|
|
3515
|
+
this[offset + 2] = value2 >>> 16 & 255;
|
|
3516
|
+
this[offset + 3] = value2 >>> 24 & 255;
|
|
3517
|
+
return offset + 4;
|
|
3518
|
+
}
|
|
3519
|
+
writeInt8(value2, offset = 0) {
|
|
3520
|
+
checkOffset(offset, 1, this.length);
|
|
3521
|
+
if (value2 < 0) value2 = 255 + value2 + 1;
|
|
3522
|
+
this[offset] = value2 & 255;
|
|
3523
|
+
return offset + 1;
|
|
3524
|
+
}
|
|
3525
|
+
writeInt16BE(value2, offset = 0) {
|
|
3526
|
+
checkOffset(offset, 2, this.length);
|
|
3527
|
+
this[offset] = value2 >>> 8 & 255;
|
|
3528
|
+
this[offset + 1] = value2 & 255;
|
|
3529
|
+
return offset + 2;
|
|
3530
|
+
}
|
|
3531
|
+
writeInt16LE(value2, offset = 0) {
|
|
3532
|
+
checkOffset(offset, 2, this.length);
|
|
3533
|
+
this[offset] = value2 & 255;
|
|
3534
|
+
this[offset + 1] = value2 >>> 8 & 255;
|
|
3535
|
+
return offset + 2;
|
|
3536
|
+
}
|
|
3537
|
+
writeInt32BE(value2, offset = 0) {
|
|
3538
|
+
checkOffset(offset, 4, this.length);
|
|
3539
|
+
this[offset] = value2 >>> 24 & 255;
|
|
3540
|
+
this[offset + 1] = value2 >>> 16 & 255;
|
|
3541
|
+
this[offset + 2] = value2 >>> 8 & 255;
|
|
3542
|
+
this[offset + 3] = value2 & 255;
|
|
3543
|
+
return offset + 4;
|
|
3544
|
+
}
|
|
3545
|
+
writeInt32LE(value2, offset = 0) {
|
|
3546
|
+
checkOffset(offset, 4, this.length);
|
|
3547
|
+
this[offset] = value2 & 255;
|
|
3548
|
+
this[offset + 1] = value2 >>> 8 & 255;
|
|
3549
|
+
this[offset + 2] = value2 >>> 16 & 255;
|
|
3550
|
+
this[offset + 3] = value2 >>> 24 & 255;
|
|
3551
|
+
return offset + 4;
|
|
3552
|
+
}
|
|
3553
|
+
writeFloatBE(value2, offset = 0) {
|
|
3554
|
+
checkOffset(offset, 4, this.length);
|
|
3555
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 4);
|
|
3556
|
+
view.setFloat32(0, value2, false);
|
|
3557
|
+
return offset + 4;
|
|
3558
|
+
}
|
|
3559
|
+
writeFloatLE(value2, offset = 0) {
|
|
3560
|
+
checkOffset(offset, 4, this.length);
|
|
3561
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 4);
|
|
3562
|
+
view.setFloat32(0, value2, true);
|
|
3563
|
+
return offset + 4;
|
|
3564
|
+
}
|
|
3565
|
+
writeDoubleBE(value2, offset = 0) {
|
|
3566
|
+
checkOffset(offset, 8, this.length);
|
|
3567
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3568
|
+
view.setFloat64(0, value2, false);
|
|
3569
|
+
return offset + 8;
|
|
3570
|
+
}
|
|
3571
|
+
writeDoubleLE(value2, offset = 0) {
|
|
3572
|
+
checkOffset(offset, 8, this.length);
|
|
3573
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3574
|
+
view.setFloat64(0, value2, true);
|
|
3575
|
+
return offset + 8;
|
|
3576
|
+
}
|
|
3577
|
+
writeBigInt64BE(value2, offset = 0) {
|
|
3578
|
+
checkOffset(offset, 8, this.length);
|
|
3579
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3580
|
+
view.setBigInt64(0, value2, false);
|
|
3581
|
+
return offset + 8;
|
|
3582
|
+
}
|
|
3583
|
+
writeBigInt64LE(value2, offset = 0) {
|
|
3584
|
+
checkOffset(offset, 8, this.length);
|
|
3585
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3586
|
+
view.setBigInt64(0, value2, true);
|
|
3587
|
+
return offset + 8;
|
|
3588
|
+
}
|
|
3589
|
+
writeBigUInt64BE(value2, offset = 0) {
|
|
3590
|
+
checkOffset(offset, 8, this.length);
|
|
3591
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3592
|
+
view.setBigUint64(0, value2, false);
|
|
3593
|
+
return offset + 8;
|
|
3594
|
+
}
|
|
3595
|
+
writeBigUInt64LE(value2, offset = 0) {
|
|
3596
|
+
checkOffset(offset, 8, this.length);
|
|
3597
|
+
const view = new DataView(this.buffer, this.byteOffset + offset, 8);
|
|
3598
|
+
view.setBigUint64(0, value2, true);
|
|
3599
|
+
return offset + 8;
|
|
3600
|
+
}
|
|
3601
|
+
// ---- Swap methods ----
|
|
3602
|
+
swap16() {
|
|
3603
|
+
const len = this.length;
|
|
3604
|
+
if (len % 2 !== 0) throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
3605
|
+
for (let i = 0; i < len; i += 2) {
|
|
3606
|
+
const a = this[i];
|
|
3607
|
+
this[i] = this[i + 1];
|
|
3608
|
+
this[i + 1] = a;
|
|
3609
|
+
}
|
|
3610
|
+
return this;
|
|
3611
|
+
}
|
|
3612
|
+
swap32() {
|
|
3613
|
+
const len = this.length;
|
|
3614
|
+
if (len % 4 !== 0) throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
3615
|
+
for (let i = 0; i < len; i += 4) {
|
|
3616
|
+
const a = this[i];
|
|
3617
|
+
const b = this[i + 1];
|
|
3618
|
+
this[i] = this[i + 3];
|
|
3619
|
+
this[i + 1] = this[i + 2];
|
|
3620
|
+
this[i + 2] = b;
|
|
3621
|
+
this[i + 3] = a;
|
|
3622
|
+
}
|
|
3623
|
+
return this;
|
|
3624
|
+
}
|
|
3625
|
+
swap64() {
|
|
3626
|
+
const len = this.length;
|
|
3627
|
+
if (len % 8 !== 0) throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
3628
|
+
for (let i = 0; i < len; i += 8) {
|
|
3629
|
+
const a = this[i];
|
|
3630
|
+
const b = this[i + 1];
|
|
3631
|
+
const c = this[i + 2];
|
|
3632
|
+
const d = this[i + 3];
|
|
3633
|
+
this[i] = this[i + 7];
|
|
3634
|
+
this[i + 1] = this[i + 6];
|
|
3635
|
+
this[i + 2] = this[i + 5];
|
|
3636
|
+
this[i + 3] = this[i + 4];
|
|
3637
|
+
this[i + 4] = d;
|
|
3638
|
+
this[i + 5] = c;
|
|
3639
|
+
this[i + 6] = b;
|
|
3640
|
+
this[i + 7] = a;
|
|
3641
|
+
}
|
|
3642
|
+
return this;
|
|
3643
|
+
}
|
|
3644
|
+
};
|
|
3645
|
+
var kMaxLength = 2 ** 31 - 1;
|
|
3646
|
+
var kStringMaxLength = 2 ** 28 - 16;
|
|
3647
|
+
|
|
3648
|
+
// ../../../packages/node/buffer/lib/esm/index.js
|
|
3649
|
+
var atob2 = globalThis.atob;
|
|
3650
|
+
var btoa = globalThis.btoa;
|
|
3651
|
+
|
|
3652
|
+
// ../../../packages/node/globals/lib/esm/register/buffer.js
|
|
3653
|
+
if (!("Buffer" in globalThis)) {
|
|
3654
|
+
Object.defineProperty(globalThis, "Buffer", {
|
|
3655
|
+
value: Buffer2,
|
|
3656
|
+
enumerable: false,
|
|
3657
|
+
writable: true,
|
|
3658
|
+
configurable: true
|
|
3659
|
+
});
|
|
3660
|
+
}
|
|
3661
|
+
|
|
2867
3662
|
// ../../../packages/node/globals/lib/esm/register/encoding.js
|
|
2868
3663
|
if (typeof globalThis.btoa !== "function") {
|
|
2869
3664
|
Object.defineProperty(globalThis, "btoa", {
|
|
2870
|
-
value: function
|
|
3665
|
+
value: function btoa2(data) {
|
|
2871
3666
|
const bytes = new Uint8Array(data.length);
|
|
2872
3667
|
for (let i = 0; i < data.length; i++) {
|
|
2873
3668
|
bytes[i] = data.charCodeAt(i) & 255;
|
|
@@ -2881,7 +3676,7 @@ if (typeof globalThis.btoa !== "function") {
|
|
|
2881
3676
|
}
|
|
2882
3677
|
if (typeof globalThis.atob !== "function") {
|
|
2883
3678
|
Object.defineProperty(globalThis, "atob", {
|
|
2884
|
-
value: function
|
|
3679
|
+
value: function atob3(data) {
|
|
2885
3680
|
const bytes = glib_2_default.base64_decode(data);
|
|
2886
3681
|
let result = "";
|
|
2887
3682
|
for (let i = 0; i < bytes.length; i++) {
|
|
@@ -2895,6 +3690,1359 @@ if (typeof globalThis.atob !== "function") {
|
|
|
2895
3690
|
});
|
|
2896
3691
|
}
|
|
2897
3692
|
|
|
3693
|
+
// ../../../packages/node/globals/lib/esm/register/microtask.js
|
|
3694
|
+
if (typeof queueMicrotask !== "function") {
|
|
3695
|
+
Object.defineProperty(globalThis, "queueMicrotask", {
|
|
3696
|
+
value: queueMicrotask2,
|
|
3697
|
+
enumerable: true,
|
|
3698
|
+
writable: true,
|
|
3699
|
+
configurable: true
|
|
3700
|
+
});
|
|
3701
|
+
}
|
|
3702
|
+
|
|
3703
|
+
// ../../../packages/node/events/lib/esm/event-emitter.js
|
|
3704
|
+
var kCapture = /* @__PURE__ */ Symbol("kCapture");
|
|
3705
|
+
var kRejection = /* @__PURE__ */ Symbol.for("nodejs.rejection");
|
|
3706
|
+
function onceWrapper() {
|
|
3707
|
+
const { target, type, listener } = this;
|
|
3708
|
+
if (this.wrapperFn) target.removeListener(type, this.wrapperFn);
|
|
3709
|
+
const result = listener.apply(target, arguments);
|
|
3710
|
+
return result;
|
|
3711
|
+
}
|
|
3712
|
+
function _onceWrap(target, type, listener) {
|
|
3713
|
+
const state = { target, type, listener, wrapperFn: void 0 };
|
|
3714
|
+
const wrapped = onceWrapper.bind(state);
|
|
3715
|
+
state.wrapperFn = wrapped;
|
|
3716
|
+
wrapped.listener = listener;
|
|
3717
|
+
return wrapped;
|
|
3718
|
+
}
|
|
3719
|
+
function arrayClone(arr) {
|
|
3720
|
+
switch (arr.length) {
|
|
3721
|
+
case 0:
|
|
3722
|
+
return [];
|
|
3723
|
+
case 1:
|
|
3724
|
+
return [arr[0]];
|
|
3725
|
+
case 2:
|
|
3726
|
+
return [arr[0], arr[1]];
|
|
3727
|
+
case 3:
|
|
3728
|
+
return [arr[0], arr[1], arr[2]];
|
|
3729
|
+
default:
|
|
3730
|
+
return arr.slice();
|
|
3731
|
+
}
|
|
3732
|
+
}
|
|
3733
|
+
function checkListener(listener) {
|
|
3734
|
+
if (typeof listener !== "function") {
|
|
3735
|
+
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
|
|
3736
|
+
}
|
|
3737
|
+
}
|
|
3738
|
+
function validateNumber(value2, name2) {
|
|
3739
|
+
if (typeof value2 !== "number" || value2 !== value2) {
|
|
3740
|
+
throw new TypeError(`The "${name2}" argument must be of type number. Received type ${typeof value2}`);
|
|
3741
|
+
}
|
|
3742
|
+
}
|
|
3743
|
+
function spliceOne(list, index) {
|
|
3744
|
+
for (; index + 1 < list.length; index++) {
|
|
3745
|
+
list[index] = list[index + 1];
|
|
3746
|
+
}
|
|
3747
|
+
list.pop();
|
|
3748
|
+
}
|
|
3749
|
+
var EventEmitter = class _EventEmitter {
|
|
3750
|
+
static defaultMaxListeners = 10;
|
|
3751
|
+
static errorMonitor = /* @__PURE__ */ Symbol("events.errorMonitor");
|
|
3752
|
+
static captureRejectionSymbol = kRejection;
|
|
3753
|
+
static _captureRejections = false;
|
|
3754
|
+
static get captureRejections() {
|
|
3755
|
+
return _EventEmitter._captureRejections;
|
|
3756
|
+
}
|
|
3757
|
+
static set captureRejections(value2) {
|
|
3758
|
+
if (typeof value2 !== "boolean") {
|
|
3759
|
+
throw new TypeError('The "captureRejections" argument must be of type boolean.');
|
|
3760
|
+
}
|
|
3761
|
+
_EventEmitter._captureRejections = value2;
|
|
3762
|
+
}
|
|
3763
|
+
_events;
|
|
3764
|
+
_eventsCount;
|
|
3765
|
+
_maxListeners;
|
|
3766
|
+
[kCapture];
|
|
3767
|
+
constructor(opts) {
|
|
3768
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
3769
|
+
this._eventsCount = 0;
|
|
3770
|
+
this._maxListeners = void 0;
|
|
3771
|
+
this[kCapture] = opts?.captureRejections ?? _EventEmitter._captureRejections;
|
|
3772
|
+
}
|
|
3773
|
+
setMaxListeners(n) {
|
|
3774
|
+
validateNumber(n, "n");
|
|
3775
|
+
if (n < 0) {
|
|
3776
|
+
throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n);
|
|
3777
|
+
}
|
|
3778
|
+
this._maxListeners = n;
|
|
3779
|
+
return this;
|
|
3780
|
+
}
|
|
3781
|
+
getMaxListeners() {
|
|
3782
|
+
return this._maxListeners ?? _EventEmitter.defaultMaxListeners;
|
|
3783
|
+
}
|
|
3784
|
+
emit(type, ...args) {
|
|
3785
|
+
const events = this._events;
|
|
3786
|
+
let doError = type === "error";
|
|
3787
|
+
if (events !== void 0) {
|
|
3788
|
+
if (doError && events[_EventEmitter.errorMonitor] !== void 0) {
|
|
3789
|
+
this.emit(_EventEmitter.errorMonitor, ...args);
|
|
3790
|
+
}
|
|
3791
|
+
doError = doError && events.error === void 0;
|
|
3792
|
+
} else if (!doError) {
|
|
3793
|
+
return false;
|
|
3794
|
+
}
|
|
3795
|
+
if (doError) {
|
|
3796
|
+
let er;
|
|
3797
|
+
if (args.length > 0) {
|
|
3798
|
+
er = args[0];
|
|
3799
|
+
} else {
|
|
3800
|
+
er = new Error("Unhandled error.");
|
|
3801
|
+
}
|
|
3802
|
+
if (er instanceof Error) {
|
|
3803
|
+
throw er;
|
|
3804
|
+
}
|
|
3805
|
+
const err = new Error("Unhandled error. (" + er + ")");
|
|
3806
|
+
err.context = er;
|
|
3807
|
+
throw err;
|
|
3808
|
+
}
|
|
3809
|
+
const handler = events[type];
|
|
3810
|
+
if (handler === void 0) {
|
|
3811
|
+
return false;
|
|
3812
|
+
}
|
|
3813
|
+
if (typeof handler === "function") {
|
|
3814
|
+
const result = handler.apply(this, args);
|
|
3815
|
+
if (result !== void 0 && result !== null && this[kCapture]) {
|
|
3816
|
+
this._addCatch(result, type, args);
|
|
3817
|
+
}
|
|
3818
|
+
} else {
|
|
3819
|
+
const listeners = arrayClone(handler);
|
|
3820
|
+
const len = listeners.length;
|
|
3821
|
+
for (let i = 0; i < len; ++i) {
|
|
3822
|
+
const result = listeners[i].apply(this, args);
|
|
3823
|
+
if (result !== void 0 && result !== null && this[kCapture]) {
|
|
3824
|
+
this._addCatch(result, type, args);
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
return true;
|
|
3829
|
+
}
|
|
3830
|
+
_addCatch(result, type, args) {
|
|
3831
|
+
if (typeof result?.then === "function") {
|
|
3832
|
+
result.then(void 0, (err) => {
|
|
3833
|
+
const handler = this[kRejection];
|
|
3834
|
+
if (typeof handler === "function") {
|
|
3835
|
+
handler.call(this, err, type, ...args);
|
|
3836
|
+
} else {
|
|
3837
|
+
const prev = this[kCapture];
|
|
3838
|
+
try {
|
|
3839
|
+
this[kCapture] = false;
|
|
3840
|
+
this.emit("error", err);
|
|
3841
|
+
} finally {
|
|
3842
|
+
this[kCapture] = prev;
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3845
|
+
});
|
|
3846
|
+
}
|
|
3847
|
+
}
|
|
3848
|
+
addListener(type, listener) {
|
|
3849
|
+
return this._addListener(type, listener, false);
|
|
3850
|
+
}
|
|
3851
|
+
on(type, listener) {
|
|
3852
|
+
return this._addListener(type, listener, false);
|
|
3853
|
+
}
|
|
3854
|
+
prependListener(type, listener) {
|
|
3855
|
+
return this._addListener(type, listener, true);
|
|
3856
|
+
}
|
|
3857
|
+
_addListener(type, listener, prepend) {
|
|
3858
|
+
checkListener(listener);
|
|
3859
|
+
let events = this._events;
|
|
3860
|
+
if (events === void 0) {
|
|
3861
|
+
events = this._events = /* @__PURE__ */ Object.create(null);
|
|
3862
|
+
this._eventsCount = 0;
|
|
3863
|
+
} else if (events.newListener !== void 0) {
|
|
3864
|
+
this.emit("newListener", type, listener.listener ?? listener);
|
|
3865
|
+
events = this._events;
|
|
3866
|
+
}
|
|
3867
|
+
let existing = events[type];
|
|
3868
|
+
if (existing === void 0) {
|
|
3869
|
+
events[type] = listener;
|
|
3870
|
+
++this._eventsCount;
|
|
3871
|
+
} else if (typeof existing === "function") {
|
|
3872
|
+
events[type] = prepend ? [listener, existing] : [existing, listener];
|
|
3873
|
+
} else {
|
|
3874
|
+
if (prepend) {
|
|
3875
|
+
existing.unshift(listener);
|
|
3876
|
+
} else {
|
|
3877
|
+
existing.push(listener);
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
const m = this.getMaxListeners();
|
|
3881
|
+
if (m > 0) {
|
|
3882
|
+
const count2 = typeof events[type] === "function" ? 1 : events[type].length;
|
|
3883
|
+
if (count2 > m && !events[type].warned) {
|
|
3884
|
+
if (typeof events[type] !== "function") {
|
|
3885
|
+
events[type].warned = true;
|
|
3886
|
+
}
|
|
3887
|
+
const w = new Error(
|
|
3888
|
+
`Possible EventEmitter memory leak detected. ${count2} ${String(type)} listeners added to [${this.constructor.name}]. Use emitter.setMaxListeners() to increase limit`
|
|
3889
|
+
);
|
|
3890
|
+
w.name = "MaxListenersExceededWarning";
|
|
3891
|
+
console.warn(w.message);
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
return this;
|
|
3895
|
+
}
|
|
3896
|
+
once(type, listener) {
|
|
3897
|
+
checkListener(listener);
|
|
3898
|
+
this.on(type, _onceWrap(this, type, listener));
|
|
3899
|
+
return this;
|
|
3900
|
+
}
|
|
3901
|
+
prependOnceListener(type, listener) {
|
|
3902
|
+
checkListener(listener);
|
|
3903
|
+
this.prependListener(type, _onceWrap(this, type, listener));
|
|
3904
|
+
return this;
|
|
3905
|
+
}
|
|
3906
|
+
removeListener(type, listener) {
|
|
3907
|
+
checkListener(listener);
|
|
3908
|
+
const events = this._events;
|
|
3909
|
+
if (events === void 0) {
|
|
3910
|
+
return this;
|
|
3911
|
+
}
|
|
3912
|
+
const list = events[type];
|
|
3913
|
+
if (list === void 0) {
|
|
3914
|
+
return this;
|
|
3915
|
+
}
|
|
3916
|
+
if (list === listener || list.listener === listener) {
|
|
3917
|
+
if (--this._eventsCount === 0) {
|
|
3918
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
3919
|
+
} else {
|
|
3920
|
+
delete events[type];
|
|
3921
|
+
if (events.removeListener) {
|
|
3922
|
+
this.emit("removeListener", type, list.listener ?? listener);
|
|
3923
|
+
}
|
|
3924
|
+
}
|
|
3925
|
+
} else if (typeof list !== "function") {
|
|
3926
|
+
let position = -1;
|
|
3927
|
+
for (let i = list.length - 1; i >= 0; i--) {
|
|
3928
|
+
if (list[i] === listener || list[i].listener === listener) {
|
|
3929
|
+
position = i;
|
|
3930
|
+
break;
|
|
3931
|
+
}
|
|
3932
|
+
}
|
|
3933
|
+
if (position < 0) {
|
|
3934
|
+
return this;
|
|
3935
|
+
}
|
|
3936
|
+
if (position === 0) {
|
|
3937
|
+
list.shift();
|
|
3938
|
+
} else {
|
|
3939
|
+
spliceOne(list, position);
|
|
3940
|
+
}
|
|
3941
|
+
if (list.length === 1) {
|
|
3942
|
+
events[type] = list[0];
|
|
3943
|
+
}
|
|
3944
|
+
if (events.removeListener !== void 0) {
|
|
3945
|
+
this.emit("removeListener", type, listener.listener ?? listener);
|
|
3946
|
+
}
|
|
3947
|
+
}
|
|
3948
|
+
return this;
|
|
3949
|
+
}
|
|
3950
|
+
off(type, listener) {
|
|
3951
|
+
return this.removeListener(type, listener);
|
|
3952
|
+
}
|
|
3953
|
+
removeAllListeners(type) {
|
|
3954
|
+
const events = this._events;
|
|
3955
|
+
if (events === void 0) {
|
|
3956
|
+
return this;
|
|
3957
|
+
}
|
|
3958
|
+
if (events.removeListener === void 0) {
|
|
3959
|
+
if (arguments.length === 0) {
|
|
3960
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
3961
|
+
this._eventsCount = 0;
|
|
3962
|
+
} else if (events[type] !== void 0) {
|
|
3963
|
+
if (--this._eventsCount === 0) {
|
|
3964
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
3965
|
+
} else {
|
|
3966
|
+
delete events[type];
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
return this;
|
|
3970
|
+
}
|
|
3971
|
+
if (arguments.length === 0) {
|
|
3972
|
+
const keys = Object.keys(events);
|
|
3973
|
+
for (let i = 0; i < keys.length; ++i) {
|
|
3974
|
+
const key = keys[i];
|
|
3975
|
+
if (key === "removeListener") continue;
|
|
3976
|
+
this.removeAllListeners(key);
|
|
3977
|
+
}
|
|
3978
|
+
this.removeAllListeners("removeListener");
|
|
3979
|
+
this._events = /* @__PURE__ */ Object.create(null);
|
|
3980
|
+
this._eventsCount = 0;
|
|
3981
|
+
return this;
|
|
3982
|
+
}
|
|
3983
|
+
const listeners = events[type];
|
|
3984
|
+
if (typeof listeners === "function") {
|
|
3985
|
+
this.removeListener(type, listeners);
|
|
3986
|
+
} else if (listeners !== void 0) {
|
|
3987
|
+
for (let i = listeners.length - 1; i >= 0; i--) {
|
|
3988
|
+
this.removeListener(type, listeners[i]);
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
return this;
|
|
3992
|
+
}
|
|
3993
|
+
listeners(type) {
|
|
3994
|
+
const events = this._events;
|
|
3995
|
+
if (events === void 0) {
|
|
3996
|
+
return [];
|
|
3997
|
+
}
|
|
3998
|
+
const evlistener = events[type];
|
|
3999
|
+
if (evlistener === void 0) {
|
|
4000
|
+
return [];
|
|
4001
|
+
}
|
|
4002
|
+
if (typeof evlistener === "function") {
|
|
4003
|
+
return [evlistener.listener ?? evlistener];
|
|
4004
|
+
}
|
|
4005
|
+
return unwrapListeners(evlistener);
|
|
4006
|
+
}
|
|
4007
|
+
rawListeners(type) {
|
|
4008
|
+
const events = this._events;
|
|
4009
|
+
if (events === void 0) {
|
|
4010
|
+
return [];
|
|
4011
|
+
}
|
|
4012
|
+
const evlistener = events[type];
|
|
4013
|
+
if (evlistener === void 0) {
|
|
4014
|
+
return [];
|
|
4015
|
+
}
|
|
4016
|
+
if (typeof evlistener === "function") {
|
|
4017
|
+
return [evlistener];
|
|
4018
|
+
}
|
|
4019
|
+
return arrayClone(evlistener);
|
|
4020
|
+
}
|
|
4021
|
+
listenerCount(type) {
|
|
4022
|
+
const events = this._events;
|
|
4023
|
+
if (events === void 0) {
|
|
4024
|
+
return 0;
|
|
4025
|
+
}
|
|
4026
|
+
const evlistener = events[type];
|
|
4027
|
+
if (evlistener === void 0) {
|
|
4028
|
+
return 0;
|
|
4029
|
+
}
|
|
4030
|
+
if (typeof evlistener === "function") {
|
|
4031
|
+
return 1;
|
|
4032
|
+
}
|
|
4033
|
+
return evlistener.length;
|
|
4034
|
+
}
|
|
4035
|
+
eventNames() {
|
|
4036
|
+
return (this._eventsCount ?? 0) > 0 ? Reflect.ownKeys(this._events) : [];
|
|
4037
|
+
}
|
|
4038
|
+
// -- Static methods --
|
|
4039
|
+
/**
|
|
4040
|
+
* Returns a promise that resolves when the emitter emits the given event,
|
|
4041
|
+
* or rejects if the emitter emits 'error' while waiting.
|
|
4042
|
+
*/
|
|
4043
|
+
static once(emitter, name2, options) {
|
|
4044
|
+
return new Promise((resolve, reject) => {
|
|
4045
|
+
const signal = options?.signal;
|
|
4046
|
+
if (signal?.aborted) {
|
|
4047
|
+
reject(createAbortError(signal));
|
|
4048
|
+
return;
|
|
4049
|
+
}
|
|
4050
|
+
if (typeof emitter.addEventListener === "function") {
|
|
4051
|
+
const eventTarget = emitter;
|
|
4052
|
+
const handler = (...args) => {
|
|
4053
|
+
if (signal) {
|
|
4054
|
+
signal.removeEventListener("abort", abortHandler2);
|
|
4055
|
+
}
|
|
4056
|
+
resolve(args);
|
|
4057
|
+
};
|
|
4058
|
+
const errorHandler2 = (err) => {
|
|
4059
|
+
if (signal) {
|
|
4060
|
+
signal.removeEventListener("abort", abortHandler2);
|
|
4061
|
+
}
|
|
4062
|
+
eventTarget.removeEventListener("error", errorHandler2);
|
|
4063
|
+
reject(err);
|
|
4064
|
+
};
|
|
4065
|
+
const abortHandler2 = () => {
|
|
4066
|
+
eventTarget.removeEventListener(name2, handler);
|
|
4067
|
+
eventTarget.removeEventListener("error", errorHandler2);
|
|
4068
|
+
reject(createAbortError(signal));
|
|
4069
|
+
};
|
|
4070
|
+
eventTarget.addEventListener(name2, handler, { once: true });
|
|
4071
|
+
if (name2 !== "error") {
|
|
4072
|
+
eventTarget.addEventListener("error", errorHandler2, { once: true });
|
|
4073
|
+
}
|
|
4074
|
+
if (signal) {
|
|
4075
|
+
signal.addEventListener("abort", abortHandler2, { once: true });
|
|
4076
|
+
}
|
|
4077
|
+
return;
|
|
4078
|
+
}
|
|
4079
|
+
const ee = emitter;
|
|
4080
|
+
const eventHandler = (...args) => {
|
|
4081
|
+
if (signal) {
|
|
4082
|
+
signal.removeEventListener("abort", abortHandler);
|
|
4083
|
+
}
|
|
4084
|
+
if (errorHandler !== void 0) {
|
|
4085
|
+
ee.removeListener("error", errorHandler);
|
|
4086
|
+
}
|
|
4087
|
+
resolve(args);
|
|
4088
|
+
};
|
|
4089
|
+
let errorHandler;
|
|
4090
|
+
if (name2 !== "error") {
|
|
4091
|
+
errorHandler = (err) => {
|
|
4092
|
+
ee.removeListener(name2, eventHandler);
|
|
4093
|
+
if (signal) {
|
|
4094
|
+
signal.removeEventListener("abort", abortHandler);
|
|
4095
|
+
}
|
|
4096
|
+
reject(err);
|
|
4097
|
+
};
|
|
4098
|
+
ee.once("error", errorHandler);
|
|
4099
|
+
}
|
|
4100
|
+
ee.once(name2, eventHandler);
|
|
4101
|
+
const abortHandler = () => {
|
|
4102
|
+
ee.removeListener(name2, eventHandler);
|
|
4103
|
+
if (errorHandler) {
|
|
4104
|
+
ee.removeListener("error", errorHandler);
|
|
4105
|
+
}
|
|
4106
|
+
reject(createAbortError(signal));
|
|
4107
|
+
};
|
|
4108
|
+
if (signal) {
|
|
4109
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
4110
|
+
}
|
|
4111
|
+
});
|
|
4112
|
+
}
|
|
4113
|
+
/**
|
|
4114
|
+
* Returns an async iterator that yields event arguments each time the emitter emits.
|
|
4115
|
+
*/
|
|
4116
|
+
static on(emitter, event, options) {
|
|
4117
|
+
const signal = options?.signal;
|
|
4118
|
+
if (signal?.aborted) {
|
|
4119
|
+
throw createAbortError(signal);
|
|
4120
|
+
}
|
|
4121
|
+
const highWaterMark = options?.highWaterMark ?? Number.MAX_SAFE_INTEGER;
|
|
4122
|
+
const lowWaterMark = options?.lowWaterMark ?? 1;
|
|
4123
|
+
validateNumber(highWaterMark, "highWaterMark");
|
|
4124
|
+
validateNumber(lowWaterMark, "lowWaterMark");
|
|
4125
|
+
const unconsumedEvents = [];
|
|
4126
|
+
const unconsumedPromises = [];
|
|
4127
|
+
let error2 = null;
|
|
4128
|
+
let finished = false;
|
|
4129
|
+
let paused = false;
|
|
4130
|
+
const eventHandler = (...args) => {
|
|
4131
|
+
if (unconsumedPromises.length > 0) {
|
|
4132
|
+
const { resolve } = unconsumedPromises.shift();
|
|
4133
|
+
resolve({ value: args, done: false });
|
|
4134
|
+
} else {
|
|
4135
|
+
unconsumedEvents.push(args);
|
|
4136
|
+
if (unconsumedEvents.length >= highWaterMark && !paused) {
|
|
4137
|
+
paused = true;
|
|
4138
|
+
if (typeof emitter.pause === "function") {
|
|
4139
|
+
emitter.pause();
|
|
4140
|
+
}
|
|
4141
|
+
}
|
|
4142
|
+
}
|
|
4143
|
+
};
|
|
4144
|
+
const errorHandler = (err) => {
|
|
4145
|
+
error2 = err;
|
|
4146
|
+
if (unconsumedPromises.length > 0) {
|
|
4147
|
+
const { reject } = unconsumedPromises.shift();
|
|
4148
|
+
reject(err);
|
|
4149
|
+
}
|
|
4150
|
+
iterator.return();
|
|
4151
|
+
};
|
|
4152
|
+
const abortHandler = () => {
|
|
4153
|
+
errorHandler(createAbortError(signal));
|
|
4154
|
+
};
|
|
4155
|
+
emitter.on(event, eventHandler);
|
|
4156
|
+
if (event !== "error") {
|
|
4157
|
+
emitter.on("error", errorHandler);
|
|
4158
|
+
}
|
|
4159
|
+
if (signal) {
|
|
4160
|
+
signal.addEventListener("abort", abortHandler, { once: true });
|
|
4161
|
+
}
|
|
4162
|
+
const cleanup = () => {
|
|
4163
|
+
emitter.removeListener(event, eventHandler);
|
|
4164
|
+
emitter.removeListener("error", errorHandler);
|
|
4165
|
+
if (signal) {
|
|
4166
|
+
signal.removeEventListener("abort", abortHandler);
|
|
4167
|
+
}
|
|
4168
|
+
finished = true;
|
|
4169
|
+
for (const { resolve } of unconsumedPromises) {
|
|
4170
|
+
resolve({ value: void 0, done: true });
|
|
4171
|
+
}
|
|
4172
|
+
unconsumedPromises.length = 0;
|
|
4173
|
+
unconsumedEvents.length = 0;
|
|
4174
|
+
};
|
|
4175
|
+
const iterator = {
|
|
4176
|
+
next() {
|
|
4177
|
+
if (unconsumedEvents.length > 0) {
|
|
4178
|
+
const value2 = unconsumedEvents.shift();
|
|
4179
|
+
if (paused && unconsumedEvents.length < lowWaterMark) {
|
|
4180
|
+
paused = false;
|
|
4181
|
+
if (typeof emitter.resume === "function") {
|
|
4182
|
+
emitter.resume();
|
|
4183
|
+
}
|
|
4184
|
+
}
|
|
4185
|
+
return Promise.resolve({ value: value2, done: false });
|
|
4186
|
+
}
|
|
4187
|
+
if (error2) {
|
|
4188
|
+
const p = Promise.reject(error2);
|
|
4189
|
+
error2 = null;
|
|
4190
|
+
return p;
|
|
4191
|
+
}
|
|
4192
|
+
if (finished) {
|
|
4193
|
+
return Promise.resolve({ value: void 0, done: true });
|
|
4194
|
+
}
|
|
4195
|
+
return new Promise((resolve, reject) => {
|
|
4196
|
+
unconsumedPromises.push({ resolve, reject });
|
|
4197
|
+
});
|
|
4198
|
+
},
|
|
4199
|
+
return() {
|
|
4200
|
+
cleanup();
|
|
4201
|
+
return Promise.resolve({ value: void 0, done: true });
|
|
4202
|
+
},
|
|
4203
|
+
throw(err) {
|
|
4204
|
+
if (!finished) {
|
|
4205
|
+
error2 = err;
|
|
4206
|
+
cleanup();
|
|
4207
|
+
}
|
|
4208
|
+
return Promise.reject(err);
|
|
4209
|
+
},
|
|
4210
|
+
[Symbol.asyncIterator]() {
|
|
4211
|
+
return this;
|
|
4212
|
+
}
|
|
4213
|
+
};
|
|
4214
|
+
return iterator;
|
|
4215
|
+
}
|
|
4216
|
+
/**
|
|
4217
|
+
* Returns the number of listeners listening to the event name.
|
|
4218
|
+
* @deprecated Use emitter.listenerCount() instead.
|
|
4219
|
+
*/
|
|
4220
|
+
static listenerCount(emitter, type) {
|
|
4221
|
+
return emitter.listenerCount(type);
|
|
4222
|
+
}
|
|
4223
|
+
/**
|
|
4224
|
+
* Returns a copy of the array of listeners for the event named eventName.
|
|
4225
|
+
*/
|
|
4226
|
+
static getEventListeners(emitter, name2) {
|
|
4227
|
+
if (typeof emitter.listeners === "function") {
|
|
4228
|
+
return emitter.listeners(name2);
|
|
4229
|
+
}
|
|
4230
|
+
return [];
|
|
4231
|
+
}
|
|
4232
|
+
/**
|
|
4233
|
+
* Set max listeners on one or more emitters.
|
|
4234
|
+
*/
|
|
4235
|
+
static setMaxListeners(n, ...emitters) {
|
|
4236
|
+
validateNumber(n, "n");
|
|
4237
|
+
if (n < 0) {
|
|
4238
|
+
throw new RangeError('The value of "n" is out of range.');
|
|
4239
|
+
}
|
|
4240
|
+
if (emitters.length === 0) {
|
|
4241
|
+
_EventEmitter.defaultMaxListeners = n;
|
|
4242
|
+
} else {
|
|
4243
|
+
for (const emitter of emitters) {
|
|
4244
|
+
if (typeof emitter.setMaxListeners === "function") {
|
|
4245
|
+
emitter.setMaxListeners(n);
|
|
4246
|
+
}
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
}
|
|
4250
|
+
/**
|
|
4251
|
+
* Returns the currently set max listeners on the emitter.
|
|
4252
|
+
*/
|
|
4253
|
+
static getMaxListeners(emitter) {
|
|
4254
|
+
if (typeof emitter.getMaxListeners === "function") {
|
|
4255
|
+
return emitter.getMaxListeners();
|
|
4256
|
+
}
|
|
4257
|
+
return _EventEmitter.defaultMaxListeners;
|
|
4258
|
+
}
|
|
4259
|
+
/**
|
|
4260
|
+
* Listens once to an abort event on the provided signal and returns a disposable.
|
|
4261
|
+
*/
|
|
4262
|
+
static addAbortListener(signal, listener) {
|
|
4263
|
+
if (signal.aborted) {
|
|
4264
|
+
Promise.resolve().then(() => listener());
|
|
4265
|
+
}
|
|
4266
|
+
const handler = () => listener();
|
|
4267
|
+
signal.addEventListener("abort", handler, { once: true });
|
|
4268
|
+
return {
|
|
4269
|
+
[Symbol.dispose]() {
|
|
4270
|
+
signal.removeEventListener("abort", handler);
|
|
4271
|
+
}
|
|
4272
|
+
};
|
|
4273
|
+
}
|
|
4274
|
+
};
|
|
4275
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
4276
|
+
{
|
|
4277
|
+
const methods = [
|
|
4278
|
+
"setMaxListeners",
|
|
4279
|
+
"getMaxListeners",
|
|
4280
|
+
"emit",
|
|
4281
|
+
"addListener",
|
|
4282
|
+
"on",
|
|
4283
|
+
"prependListener",
|
|
4284
|
+
"once",
|
|
4285
|
+
"prependOnceListener",
|
|
4286
|
+
"removeListener",
|
|
4287
|
+
"off",
|
|
4288
|
+
"removeAllListeners",
|
|
4289
|
+
"listeners",
|
|
4290
|
+
"rawListeners",
|
|
4291
|
+
"listenerCount",
|
|
4292
|
+
"eventNames"
|
|
4293
|
+
];
|
|
4294
|
+
for (const m of methods) {
|
|
4295
|
+
const fn = EventEmitter.prototype[m];
|
|
4296
|
+
if (typeof fn === "function") {
|
|
4297
|
+
Object.defineProperty(EventEmitter.prototype, m, {
|
|
4298
|
+
enumerable: true,
|
|
4299
|
+
configurable: true,
|
|
4300
|
+
writable: true,
|
|
4301
|
+
value: fn
|
|
4302
|
+
});
|
|
4303
|
+
}
|
|
4304
|
+
}
|
|
4305
|
+
Object.defineProperty(EventEmitter.prototype, "_events", { enumerable: true, configurable: true, writable: true, value: void 0 });
|
|
4306
|
+
Object.defineProperty(EventEmitter.prototype, "_eventsCount", { enumerable: true, configurable: true, writable: true, value: 0 });
|
|
4307
|
+
Object.defineProperty(EventEmitter.prototype, "_maxListeners", { enumerable: true, configurable: true, writable: true, value: void 0 });
|
|
4308
|
+
}
|
|
4309
|
+
function unwrapListeners(arr) {
|
|
4310
|
+
const ret = new Array(arr.length);
|
|
4311
|
+
for (let i = 0; i < ret.length; ++i) {
|
|
4312
|
+
ret[i] = arr[i].listener ?? arr[i];
|
|
4313
|
+
}
|
|
4314
|
+
return ret;
|
|
4315
|
+
}
|
|
4316
|
+
function createAbortError(signal) {
|
|
4317
|
+
const err = new Error("The operation was aborted");
|
|
4318
|
+
err.name = "AbortError";
|
|
4319
|
+
err.code = "ABORT_ERR";
|
|
4320
|
+
if (signal?.reason) {
|
|
4321
|
+
err.cause = signal.reason;
|
|
4322
|
+
}
|
|
4323
|
+
return err;
|
|
4324
|
+
}
|
|
4325
|
+
|
|
4326
|
+
// ../../../packages/node/events/lib/esm/index.js
|
|
4327
|
+
var EventEmitter2 = makeCallable(EventEmitter);
|
|
4328
|
+
EventEmitter2.EventEmitter = EventEmitter2;
|
|
4329
|
+
var captureRejectionSymbol = EventEmitter2.captureRejectionSymbol;
|
|
4330
|
+
var errorMonitor = EventEmitter2.errorMonitor;
|
|
4331
|
+
var defaultMaxListeners = EventEmitter2.defaultMaxListeners;
|
|
4332
|
+
var setMaxListeners = EventEmitter2.setMaxListeners;
|
|
4333
|
+
var getMaxListeners = EventEmitter2.getMaxListeners;
|
|
4334
|
+
var once = EventEmitter2.once;
|
|
4335
|
+
var on = EventEmitter2.on;
|
|
4336
|
+
var getEventListeners = EventEmitter2.getEventListeners;
|
|
4337
|
+
var listenerCount = EventEmitter2.listenerCount;
|
|
4338
|
+
var addAbortListener = EventEmitter2.addAbortListener;
|
|
4339
|
+
|
|
4340
|
+
// ../../../packages/node/terminal-native/lib/esm/index.js
|
|
4341
|
+
var _mod = null;
|
|
4342
|
+
var _gi = globalThis.imports?.gi;
|
|
4343
|
+
if (_gi) {
|
|
4344
|
+
try {
|
|
4345
|
+
_mod = _gi["GjsifyTerminal"];
|
|
4346
|
+
} catch {
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4349
|
+
var nativeTerminal = _mod;
|
|
4350
|
+
|
|
4351
|
+
// ../../../packages/node/process/lib/esm/index.js
|
|
4352
|
+
var _encoder2 = new TextEncoder();
|
|
4353
|
+
function getGjsGlobal() {
|
|
4354
|
+
return globalThis;
|
|
4355
|
+
}
|
|
4356
|
+
function detectGjsVersion() {
|
|
4357
|
+
try {
|
|
4358
|
+
const system = getGjsGlobal().imports?.system;
|
|
4359
|
+
if (system?.version !== void 0) {
|
|
4360
|
+
const v = Number(system.version);
|
|
4361
|
+
const major = Math.floor(v / 1e4);
|
|
4362
|
+
const minor = Math.floor(v % 1e4 / 100);
|
|
4363
|
+
const patch = v % 100;
|
|
4364
|
+
return `${major}.${minor}.${patch}`;
|
|
4365
|
+
}
|
|
4366
|
+
} catch {
|
|
4367
|
+
}
|
|
4368
|
+
return void 0;
|
|
4369
|
+
}
|
|
4370
|
+
function detectNodeVersion() {
|
|
4371
|
+
if (typeof globalThis.process?.versions?.node === "string") {
|
|
4372
|
+
return globalThis.process.versions.node;
|
|
4373
|
+
}
|
|
4374
|
+
return void 0;
|
|
4375
|
+
}
|
|
4376
|
+
function detectVersionInfo() {
|
|
4377
|
+
const nodeVersion = detectNodeVersion();
|
|
4378
|
+
if (nodeVersion) {
|
|
4379
|
+
return {
|
|
4380
|
+
version: globalThis.process.version,
|
|
4381
|
+
versions: { ...globalThis.process.versions },
|
|
4382
|
+
title: globalThis.process?.title || "node"
|
|
4383
|
+
};
|
|
4384
|
+
}
|
|
4385
|
+
const gjsVersion = detectGjsVersion();
|
|
4386
|
+
const versions2 = {
|
|
4387
|
+
node: "20.0.0"
|
|
4388
|
+
// Compatibility version — many npm packages check process.versions.node
|
|
4389
|
+
};
|
|
4390
|
+
if (gjsVersion) versions2.gjs = gjsVersion;
|
|
4391
|
+
return {
|
|
4392
|
+
version: "v20.0.0",
|
|
4393
|
+
// Compatibility version for Node.js API level checks
|
|
4394
|
+
versions: versions2,
|
|
4395
|
+
title: "gjs"
|
|
4396
|
+
};
|
|
4397
|
+
}
|
|
4398
|
+
function detectPpid() {
|
|
4399
|
+
if (typeof globalThis.process?.ppid === "number") {
|
|
4400
|
+
return globalThis.process.ppid;
|
|
4401
|
+
}
|
|
4402
|
+
try {
|
|
4403
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4404
|
+
if (GLib3) {
|
|
4405
|
+
const [, contents] = GLib3.file_get_contents("/proc/self/status");
|
|
4406
|
+
if (contents) {
|
|
4407
|
+
const str = new TextDecoder().decode(contents);
|
|
4408
|
+
const match = str.match(/PPid:\s+(\d+)/);
|
|
4409
|
+
if (match) return parseInt(match[1], 10);
|
|
4410
|
+
}
|
|
4411
|
+
}
|
|
4412
|
+
} catch {
|
|
4413
|
+
}
|
|
4414
|
+
return 0;
|
|
4415
|
+
}
|
|
4416
|
+
function detectPlatform() {
|
|
4417
|
+
try {
|
|
4418
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4419
|
+
if (GLib3) {
|
|
4420
|
+
const osInfo = GLib3.get_os_info("ID");
|
|
4421
|
+
if (osInfo) return "linux";
|
|
4422
|
+
}
|
|
4423
|
+
} catch {
|
|
4424
|
+
}
|
|
4425
|
+
if (typeof getGjsGlobal().imports?.system !== "undefined") {
|
|
4426
|
+
return "linux";
|
|
4427
|
+
}
|
|
4428
|
+
if (typeof globalThis.process?.platform === "string") {
|
|
4429
|
+
return globalThis.process.platform;
|
|
4430
|
+
}
|
|
4431
|
+
return "linux";
|
|
4432
|
+
}
|
|
4433
|
+
function detectArch() {
|
|
4434
|
+
if (typeof globalThis.process?.arch === "string") {
|
|
4435
|
+
return globalThis.process.arch;
|
|
4436
|
+
}
|
|
4437
|
+
return "x64";
|
|
4438
|
+
}
|
|
4439
|
+
function getCwd() {
|
|
4440
|
+
try {
|
|
4441
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4442
|
+
if (GLib3?.get_current_dir) return GLib3.get_current_dir();
|
|
4443
|
+
} catch {
|
|
4444
|
+
}
|
|
4445
|
+
return "/";
|
|
4446
|
+
}
|
|
4447
|
+
function getEnvProxy() {
|
|
4448
|
+
if (typeof globalThis.process?.env === "object") {
|
|
4449
|
+
return globalThis.process.env;
|
|
4450
|
+
}
|
|
4451
|
+
try {
|
|
4452
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4453
|
+
if (GLib3) {
|
|
4454
|
+
return new Proxy({}, {
|
|
4455
|
+
get(_target, prop) {
|
|
4456
|
+
if (typeof prop !== "string") return void 0;
|
|
4457
|
+
return GLib3.getenv(prop) ?? void 0;
|
|
4458
|
+
},
|
|
4459
|
+
set(_target, prop, value2) {
|
|
4460
|
+
if (typeof prop !== "string") return false;
|
|
4461
|
+
GLib3.setenv(prop, String(value2), true);
|
|
4462
|
+
return true;
|
|
4463
|
+
},
|
|
4464
|
+
deleteProperty(_target, prop) {
|
|
4465
|
+
if (typeof prop !== "string") return false;
|
|
4466
|
+
GLib3.unsetenv(prop);
|
|
4467
|
+
return true;
|
|
4468
|
+
},
|
|
4469
|
+
has(_target, prop) {
|
|
4470
|
+
if (typeof prop !== "string") return false;
|
|
4471
|
+
return GLib3.getenv(prop) !== null;
|
|
4472
|
+
},
|
|
4473
|
+
ownKeys(_target) {
|
|
4474
|
+
const envp = GLib3.listenv();
|
|
4475
|
+
return envp;
|
|
4476
|
+
},
|
|
4477
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
4478
|
+
if (typeof prop !== "string") return void 0;
|
|
4479
|
+
const val = GLib3.getenv(prop);
|
|
4480
|
+
if (val === null) return void 0;
|
|
4481
|
+
return { configurable: true, enumerable: true, writable: true, value: val };
|
|
4482
|
+
}
|
|
4483
|
+
});
|
|
4484
|
+
}
|
|
4485
|
+
} catch {
|
|
4486
|
+
}
|
|
4487
|
+
return {};
|
|
4488
|
+
}
|
|
4489
|
+
function getArgv() {
|
|
4490
|
+
if (typeof globalThis.process?.argv !== "undefined") {
|
|
4491
|
+
return globalThis.process.argv;
|
|
4492
|
+
}
|
|
4493
|
+
try {
|
|
4494
|
+
const system = getGjsGlobal().imports?.system;
|
|
4495
|
+
if (system?.programArgs) {
|
|
4496
|
+
return ["gjs", system.programInvocationName || "", ...system.programArgs];
|
|
4497
|
+
}
|
|
4498
|
+
} catch {
|
|
4499
|
+
}
|
|
4500
|
+
return ["gjs"];
|
|
4501
|
+
}
|
|
4502
|
+
function getExecPath() {
|
|
4503
|
+
if (typeof globalThis.process?.execPath === "string") {
|
|
4504
|
+
return globalThis.process.execPath;
|
|
4505
|
+
}
|
|
4506
|
+
try {
|
|
4507
|
+
const system = getGjsGlobal().imports?.system;
|
|
4508
|
+
if (system?.programInvocationName) return system.programInvocationName;
|
|
4509
|
+
} catch {
|
|
4510
|
+
}
|
|
4511
|
+
return "/usr/bin/gjs";
|
|
4512
|
+
}
|
|
4513
|
+
function getPid() {
|
|
4514
|
+
if (typeof globalThis.process?.pid === "number") {
|
|
4515
|
+
return globalThis.process.pid;
|
|
4516
|
+
}
|
|
4517
|
+
try {
|
|
4518
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4519
|
+
if (GLib3) {
|
|
4520
|
+
const [, contents] = GLib3.file_get_contents("/proc/self/stat");
|
|
4521
|
+
if (contents) {
|
|
4522
|
+
const str = new TextDecoder().decode(contents);
|
|
4523
|
+
const pid2 = parseInt(str, 10);
|
|
4524
|
+
if (!isNaN(pid2)) return pid2;
|
|
4525
|
+
}
|
|
4526
|
+
}
|
|
4527
|
+
} catch {
|
|
4528
|
+
}
|
|
4529
|
+
return 0;
|
|
4530
|
+
}
|
|
4531
|
+
var startTime = Date.now();
|
|
4532
|
+
function getGioNamespace() {
|
|
4533
|
+
const _gi2 = globalThis.imports?.gi;
|
|
4534
|
+
if (!_gi2) return null;
|
|
4535
|
+
let gio = null;
|
|
4536
|
+
try {
|
|
4537
|
+
gio = _gi2["GioUnix"];
|
|
4538
|
+
} catch {
|
|
4539
|
+
}
|
|
4540
|
+
if (!gio) {
|
|
4541
|
+
try {
|
|
4542
|
+
gio = _gi2["Gio"];
|
|
4543
|
+
} catch {
|
|
4544
|
+
}
|
|
4545
|
+
}
|
|
4546
|
+
return gio;
|
|
4547
|
+
}
|
|
4548
|
+
var ProcessWriteStream = class extends EventEmitter2 {
|
|
4549
|
+
fd;
|
|
4550
|
+
// Required by Stream.pipe(): without this, pipe skips dest.write() entirely.
|
|
4551
|
+
writable = true;
|
|
4552
|
+
_outGio = null;
|
|
4553
|
+
constructor(fd) {
|
|
4554
|
+
super();
|
|
4555
|
+
this.fd = fd;
|
|
4556
|
+
const gio = getGioNamespace();
|
|
4557
|
+
if (gio) {
|
|
4558
|
+
const Cls = gio.UnixOutputStream ?? gio.OutputStream;
|
|
4559
|
+
if (Cls) {
|
|
4560
|
+
try {
|
|
4561
|
+
this._outGio = Cls.new(this.fd, false);
|
|
4562
|
+
} catch {
|
|
4563
|
+
}
|
|
4564
|
+
}
|
|
4565
|
+
}
|
|
4566
|
+
}
|
|
4567
|
+
write(data) {
|
|
4568
|
+
if (this._outGio) {
|
|
4569
|
+
try {
|
|
4570
|
+
const bytes = typeof data === "string" ? _encoder2.encode(data) : data;
|
|
4571
|
+
this._outGio.write_all(bytes, null);
|
|
4572
|
+
return true;
|
|
4573
|
+
} catch {
|
|
4574
|
+
}
|
|
4575
|
+
}
|
|
4576
|
+
if (this.fd === 2) {
|
|
4577
|
+
console.error(data);
|
|
4578
|
+
} else {
|
|
4579
|
+
console.log(data);
|
|
4580
|
+
}
|
|
4581
|
+
return true;
|
|
4582
|
+
}
|
|
4583
|
+
get isTTY() {
|
|
4584
|
+
if (nativeTerminal) return nativeTerminal.Terminal.is_tty(this.fd);
|
|
4585
|
+
try {
|
|
4586
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4587
|
+
if (GLib3) return !!GLib3.log_writer_supports_color(this.fd);
|
|
4588
|
+
} catch {
|
|
4589
|
+
}
|
|
4590
|
+
return false;
|
|
4591
|
+
}
|
|
4592
|
+
get columns() {
|
|
4593
|
+
if (nativeTerminal) {
|
|
4594
|
+
const [ok, , cols] = nativeTerminal.Terminal.get_size(this.fd);
|
|
4595
|
+
if (ok && cols > 0) return cols;
|
|
4596
|
+
}
|
|
4597
|
+
try {
|
|
4598
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4599
|
+
if (GLib3) {
|
|
4600
|
+
const c = parseInt(GLib3.getenv("COLUMNS") ?? "0", 10);
|
|
4601
|
+
if (c > 0) return c;
|
|
4602
|
+
}
|
|
4603
|
+
} catch {
|
|
4604
|
+
}
|
|
4605
|
+
return 80;
|
|
4606
|
+
}
|
|
4607
|
+
// stdout/stderr must never be closed — the process owns the fds.
|
|
4608
|
+
// pipe() calls end() when its source emits 'end' (e.g. MuteStream); no-op here.
|
|
4609
|
+
end() {
|
|
4610
|
+
}
|
|
4611
|
+
destroy() {
|
|
4612
|
+
}
|
|
4613
|
+
get rows() {
|
|
4614
|
+
if (nativeTerminal) {
|
|
4615
|
+
const [ok, rows] = nativeTerminal.Terminal.get_size(this.fd);
|
|
4616
|
+
if (ok && rows > 0) return rows;
|
|
4617
|
+
}
|
|
4618
|
+
try {
|
|
4619
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4620
|
+
if (GLib3) {
|
|
4621
|
+
const r = parseInt(GLib3.getenv("LINES") ?? "0", 10);
|
|
4622
|
+
if (r > 0) return r;
|
|
4623
|
+
}
|
|
4624
|
+
} catch {
|
|
4625
|
+
}
|
|
4626
|
+
return 24;
|
|
4627
|
+
}
|
|
4628
|
+
};
|
|
4629
|
+
var ProcessReadStream = class extends EventEmitter2 {
|
|
4630
|
+
fd;
|
|
4631
|
+
isRaw = false;
|
|
4632
|
+
// Do NOT expose `readableFlowing` as an instance property: @inquirer/core uses
|
|
4633
|
+
// `'readableFlowing' in input` to defer startCycle() via setImmediate. In GJS,
|
|
4634
|
+
// setImmediate fires as a microtask — the property must stay absent so
|
|
4635
|
+
// @inquirer/core calls startCycle() synchronously on its own schedule.
|
|
4636
|
+
_gio = null;
|
|
4637
|
+
_stdinGio = null;
|
|
4638
|
+
_reading = false;
|
|
4639
|
+
_flowing = false;
|
|
4640
|
+
_sttyCleanupRegistered = false;
|
|
4641
|
+
_mainLoopHeld = false;
|
|
4642
|
+
// True while a read_bytes_async is in-flight. Prevents a second concurrent
|
|
4643
|
+
// read from starting when pause()+resume() fires between GLib iterations.
|
|
4644
|
+
_pendingRead = false;
|
|
4645
|
+
constructor(fd) {
|
|
4646
|
+
super();
|
|
4647
|
+
this.fd = fd;
|
|
4648
|
+
this._gio = getGioNamespace();
|
|
4649
|
+
}
|
|
4650
|
+
get isTTY() {
|
|
4651
|
+
if (nativeTerminal) return nativeTerminal.Terminal.is_tty(this.fd);
|
|
4652
|
+
return false;
|
|
4653
|
+
}
|
|
4654
|
+
setRawMode(mode) {
|
|
4655
|
+
if (nativeTerminal) {
|
|
4656
|
+
const ok = nativeTerminal.Terminal.set_raw_mode(this.fd, mode);
|
|
4657
|
+
if (ok) {
|
|
4658
|
+
this.isRaw = mode;
|
|
4659
|
+
return this;
|
|
4660
|
+
}
|
|
4661
|
+
}
|
|
4662
|
+
this._setRawModeViaStty(mode);
|
|
4663
|
+
this.isRaw = mode;
|
|
4664
|
+
return this;
|
|
4665
|
+
}
|
|
4666
|
+
_setRawModeViaStty(mode) {
|
|
4667
|
+
try {
|
|
4668
|
+
const _gi2 = globalThis.imports?.gi;
|
|
4669
|
+
const Gio3 = _gi2?.Gio ?? _gi2?.["Gio"];
|
|
4670
|
+
if (!Gio3) return;
|
|
4671
|
+
const STDIN_INHERIT = Gio3.SubprocessFlags?.STDIN_INHERIT ?? 2;
|
|
4672
|
+
const argv2 = mode ? ["stty", "-icanon", "-echo", "-icrnl", "min", "1", "time", "0"] : ["stty", "icanon", "echo", "icrnl"];
|
|
4673
|
+
const launcher = new Gio3.SubprocessLauncher({ flags: STDIN_INHERIT });
|
|
4674
|
+
const proc = launcher.spawnv(argv2);
|
|
4675
|
+
proc.wait(null);
|
|
4676
|
+
if (mode && !this._sttyCleanupRegistered) {
|
|
4677
|
+
this._sttyCleanupRegistered = true;
|
|
4678
|
+
const proc_ = globalThis.process;
|
|
4679
|
+
if (proc_?.once && typeof proc_.once === "function") {
|
|
4680
|
+
proc_.once("exit", () => this._setRawModeViaStty(false));
|
|
4681
|
+
}
|
|
4682
|
+
}
|
|
4683
|
+
} catch {
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4686
|
+
setEncoding(_enc) {
|
|
4687
|
+
return this;
|
|
4688
|
+
}
|
|
4689
|
+
resume() {
|
|
4690
|
+
this._flowing = true;
|
|
4691
|
+
if (this._gio && this.fd === 0 && !this._reading) {
|
|
4692
|
+
this._startReading();
|
|
4693
|
+
}
|
|
4694
|
+
return this;
|
|
4695
|
+
}
|
|
4696
|
+
pause() {
|
|
4697
|
+
this._flowing = false;
|
|
4698
|
+
this._reading = false;
|
|
4699
|
+
if (this._mainLoopHeld) {
|
|
4700
|
+
this._mainLoopHeld = false;
|
|
4701
|
+
const _gi2 = globalThis.imports?.gi;
|
|
4702
|
+
const GLib3 = _gi2?.GLib ?? _gi2?.["GLib"];
|
|
4703
|
+
if (GLib3?.idle_add) {
|
|
4704
|
+
GLib3.idle_add(300, () => {
|
|
4705
|
+
if (!this._mainLoopHeld) quitMainLoop();
|
|
4706
|
+
return false;
|
|
4707
|
+
});
|
|
4708
|
+
} else {
|
|
4709
|
+
quitMainLoop();
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
return this;
|
|
4713
|
+
}
|
|
4714
|
+
read() {
|
|
4715
|
+
return null;
|
|
4716
|
+
}
|
|
4717
|
+
_startReading() {
|
|
4718
|
+
if (!this._gio || this._reading) return;
|
|
4719
|
+
if (this._pendingRead) {
|
|
4720
|
+
this._reading = true;
|
|
4721
|
+
if (!this._mainLoopHeld) {
|
|
4722
|
+
this._mainLoopHeld = true;
|
|
4723
|
+
ensureMainLoop();
|
|
4724
|
+
}
|
|
4725
|
+
return;
|
|
4726
|
+
}
|
|
4727
|
+
this._reading = true;
|
|
4728
|
+
if (!this._mainLoopHeld) {
|
|
4729
|
+
this._mainLoopHeld = true;
|
|
4730
|
+
ensureMainLoop();
|
|
4731
|
+
}
|
|
4732
|
+
if (!this._stdinGio) {
|
|
4733
|
+
const Cls = this._gio.UnixInputStream ?? this._gio.InputStream;
|
|
4734
|
+
if (!Cls) {
|
|
4735
|
+
this._reading = false;
|
|
4736
|
+
return;
|
|
4737
|
+
}
|
|
4738
|
+
try {
|
|
4739
|
+
this._stdinGio = Cls.new(this.fd, false);
|
|
4740
|
+
} catch {
|
|
4741
|
+
this._reading = false;
|
|
4742
|
+
return;
|
|
4743
|
+
}
|
|
4744
|
+
}
|
|
4745
|
+
const loop = () => {
|
|
4746
|
+
if (!this._reading) {
|
|
4747
|
+
this._pendingRead = false;
|
|
4748
|
+
return;
|
|
4749
|
+
}
|
|
4750
|
+
this._pendingRead = true;
|
|
4751
|
+
this._stdinGio.read_bytes_async(
|
|
4752
|
+
4096,
|
|
4753
|
+
0,
|
|
4754
|
+
null,
|
|
4755
|
+
(src, res) => {
|
|
4756
|
+
this._pendingRead = false;
|
|
4757
|
+
try {
|
|
4758
|
+
const bytes = src.read_bytes_finish(res);
|
|
4759
|
+
const data = bytes?.get_data?.() ?? null;
|
|
4760
|
+
if (data && data.byteLength > 0) {
|
|
4761
|
+
this.emit("data", Buffer.from(data));
|
|
4762
|
+
} else if (data !== null && data.byteLength === 0) {
|
|
4763
|
+
this._reading = false;
|
|
4764
|
+
this.emit("end");
|
|
4765
|
+
return;
|
|
4766
|
+
}
|
|
4767
|
+
} catch {
|
|
4768
|
+
this._reading = false;
|
|
4769
|
+
return;
|
|
4770
|
+
}
|
|
4771
|
+
if (this._reading) loop();
|
|
4772
|
+
}
|
|
4773
|
+
);
|
|
4774
|
+
};
|
|
4775
|
+
loop();
|
|
4776
|
+
}
|
|
4777
|
+
};
|
|
4778
|
+
function getMonotonicTime() {
|
|
4779
|
+
try {
|
|
4780
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4781
|
+
if (GLib3?.get_monotonic_time) {
|
|
4782
|
+
return BigInt(GLib3.get_monotonic_time()) * 1000n;
|
|
4783
|
+
}
|
|
4784
|
+
} catch {
|
|
4785
|
+
}
|
|
4786
|
+
if (typeof performance?.now === "function") {
|
|
4787
|
+
return BigInt(Math.round(performance.now() * 1e6));
|
|
4788
|
+
}
|
|
4789
|
+
return BigInt(Date.now()) * 1000000n;
|
|
4790
|
+
}
|
|
4791
|
+
var hrtimeBase = getMonotonicTime();
|
|
4792
|
+
var Process = class extends EventEmitter2 {
|
|
4793
|
+
platform;
|
|
4794
|
+
arch;
|
|
4795
|
+
env;
|
|
4796
|
+
argv;
|
|
4797
|
+
argv0;
|
|
4798
|
+
execPath;
|
|
4799
|
+
pid;
|
|
4800
|
+
ppid;
|
|
4801
|
+
version;
|
|
4802
|
+
versions;
|
|
4803
|
+
title;
|
|
4804
|
+
execArgv;
|
|
4805
|
+
config;
|
|
4806
|
+
exitCode;
|
|
4807
|
+
constructor() {
|
|
4808
|
+
super();
|
|
4809
|
+
this.platform = detectPlatform();
|
|
4810
|
+
this.arch = detectArch();
|
|
4811
|
+
this.env = getEnvProxy();
|
|
4812
|
+
this.argv = getArgv();
|
|
4813
|
+
this.argv0 = this.argv[0] || "gjs";
|
|
4814
|
+
this.execPath = getExecPath();
|
|
4815
|
+
this.execArgv = globalThis.process?.execArgv ?? [];
|
|
4816
|
+
this.config = globalThis.process?.config ?? { target_defaults: {}, variables: {} };
|
|
4817
|
+
this.pid = getPid();
|
|
4818
|
+
this.ppid = detectPpid();
|
|
4819
|
+
const versionInfo = detectVersionInfo();
|
|
4820
|
+
this.version = versionInfo.version;
|
|
4821
|
+
this.versions = versionInfo.versions;
|
|
4822
|
+
this.title = versionInfo.title;
|
|
4823
|
+
}
|
|
4824
|
+
cwd() {
|
|
4825
|
+
return getCwd();
|
|
4826
|
+
}
|
|
4827
|
+
chdir(directory) {
|
|
4828
|
+
try {
|
|
4829
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4830
|
+
if (GLib3?.chdir) {
|
|
4831
|
+
if (!GLib3.file_test(
|
|
4832
|
+
directory,
|
|
4833
|
+
16
|
|
4834
|
+
/* G_FILE_TEST_EXISTS */
|
|
4835
|
+
)) {
|
|
4836
|
+
const err = new Error(`ENOENT: no such file or directory, chdir '${directory}'`);
|
|
4837
|
+
err.code = "ENOENT";
|
|
4838
|
+
err.syscall = "chdir";
|
|
4839
|
+
err.path = directory;
|
|
4840
|
+
throw err;
|
|
4841
|
+
}
|
|
4842
|
+
GLib3.chdir(directory);
|
|
4843
|
+
return;
|
|
4844
|
+
}
|
|
4845
|
+
} catch (e) {
|
|
4846
|
+
if (e && typeof e === "object" && e.code === "ENOENT") throw e;
|
|
4847
|
+
}
|
|
4848
|
+
const nativeProcess = globalThis.process;
|
|
4849
|
+
if (nativeProcess && nativeProcess !== this && typeof nativeProcess.chdir === "function") {
|
|
4850
|
+
nativeProcess.chdir(directory);
|
|
4851
|
+
return;
|
|
4852
|
+
}
|
|
4853
|
+
throw new Error("process.chdir() is not supported in this environment");
|
|
4854
|
+
}
|
|
4855
|
+
kill(pid2, signal) {
|
|
4856
|
+
const nativeProcess = globalThis.process;
|
|
4857
|
+
if (nativeProcess && nativeProcess !== this && typeof nativeProcess.kill === "function") {
|
|
4858
|
+
return nativeProcess.kill(pid2, signal);
|
|
4859
|
+
}
|
|
4860
|
+
try {
|
|
4861
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4862
|
+
if (GLib3) {
|
|
4863
|
+
const sig = typeof signal === "number" ? String(signal) : signal || "SIGTERM";
|
|
4864
|
+
const sigArg = sig.startsWith("SIG") ? `-${sig.slice(3)}` : `-${sig}`;
|
|
4865
|
+
GLib3.spawn_command_line_sync(`kill ${sigArg} ${pid2}`);
|
|
4866
|
+
return true;
|
|
4867
|
+
}
|
|
4868
|
+
} catch {
|
|
4869
|
+
}
|
|
4870
|
+
throw new Error("process.kill() is not supported in this environment");
|
|
4871
|
+
}
|
|
4872
|
+
exit(code) {
|
|
4873
|
+
this.exitCode = code ?? this.exitCode ?? 0;
|
|
4874
|
+
this.emit("exit", this.exitCode);
|
|
4875
|
+
const gjsImports = getGjsGlobal().imports;
|
|
4876
|
+
const GLib3 = gjsImports?.gi?.GLib;
|
|
4877
|
+
const system = gjsImports?.system;
|
|
4878
|
+
const idleAdd = GLib3?.idle_add;
|
|
4879
|
+
const sourceRemove = GLib3?.SOURCE_REMOVE;
|
|
4880
|
+
const priorityDefault = GLib3?.PRIORITY_DEFAULT;
|
|
4881
|
+
if (system?.exit && idleAdd && typeof priorityDefault === "number" && typeof sourceRemove === "boolean") {
|
|
4882
|
+
const exitCodeNow = this.exitCode;
|
|
4883
|
+
ensureMainLoop();
|
|
4884
|
+
idleAdd(priorityDefault, () => {
|
|
4885
|
+
quitMainLoop();
|
|
4886
|
+
system.exit(exitCodeNow);
|
|
4887
|
+
return sourceRemove;
|
|
4888
|
+
});
|
|
4889
|
+
return new Promise(() => {
|
|
4890
|
+
});
|
|
4891
|
+
}
|
|
4892
|
+
try {
|
|
4893
|
+
if (system?.exit) system.exit(this.exitCode);
|
|
4894
|
+
} catch {
|
|
4895
|
+
}
|
|
4896
|
+
const nativeProcess = globalThis.process;
|
|
4897
|
+
if (nativeProcess && nativeProcess !== this && typeof nativeProcess.exit === "function") {
|
|
4898
|
+
nativeProcess.exit(this.exitCode);
|
|
4899
|
+
}
|
|
4900
|
+
throw new Error(`process.exit(${this.exitCode})`);
|
|
4901
|
+
}
|
|
4902
|
+
nextTick(callback, ...args) {
|
|
4903
|
+
if (typeof queueMicrotask === "function") {
|
|
4904
|
+
queueMicrotask(() => callback(...args));
|
|
4905
|
+
} else {
|
|
4906
|
+
Promise.resolve().then(() => callback(...args));
|
|
4907
|
+
}
|
|
4908
|
+
}
|
|
4909
|
+
hrtime(time2) {
|
|
4910
|
+
const now = getMonotonicTime() - hrtimeBase;
|
|
4911
|
+
const seconds = Number(now / 1000000000n);
|
|
4912
|
+
const nanoseconds = Number(now % 1000000000n);
|
|
4913
|
+
if (time2) {
|
|
4914
|
+
let diffSec = seconds - time2[0];
|
|
4915
|
+
let diffNano = nanoseconds - time2[1];
|
|
4916
|
+
if (diffNano < 0) {
|
|
4917
|
+
diffSec--;
|
|
4918
|
+
diffNano += 1e9;
|
|
4919
|
+
}
|
|
4920
|
+
return [diffSec, diffNano];
|
|
4921
|
+
}
|
|
4922
|
+
return [seconds, nanoseconds];
|
|
4923
|
+
}
|
|
4924
|
+
uptime() {
|
|
4925
|
+
return (Date.now() - startTime) / 1e3;
|
|
4926
|
+
}
|
|
4927
|
+
memoryUsage() {
|
|
4928
|
+
try {
|
|
4929
|
+
const GLib3 = getGjsGlobal().imports?.gi?.GLib;
|
|
4930
|
+
if (GLib3) {
|
|
4931
|
+
const [, contents] = GLib3.file_get_contents("/proc/self/status");
|
|
4932
|
+
if (contents) {
|
|
4933
|
+
const str = new TextDecoder().decode(contents);
|
|
4934
|
+
const vmRSS = str.match(/VmRSS:\s+(\d+)/);
|
|
4935
|
+
const rss = vmRSS ? parseInt(vmRSS[1], 10) * 1024 : 0;
|
|
4936
|
+
return { rss, heapTotal: rss, heapUsed: rss, external: 0, arrayBuffers: 0 };
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
} catch {
|
|
4940
|
+
}
|
|
4941
|
+
const nativeProcess = globalThis.process;
|
|
4942
|
+
if (nativeProcess && nativeProcess !== this && typeof nativeProcess.memoryUsage === "function") {
|
|
4943
|
+
return nativeProcess.memoryUsage();
|
|
4944
|
+
}
|
|
4945
|
+
return { rss: 0, heapTotal: 0, heapUsed: 0, external: 0, arrayBuffers: 0 };
|
|
4946
|
+
}
|
|
4947
|
+
cpuUsage(previousValue) {
|
|
4948
|
+
const nativeProcess = globalThis.process;
|
|
4949
|
+
if (nativeProcess && nativeProcess !== this && typeof nativeProcess.cpuUsage === "function") {
|
|
4950
|
+
return nativeProcess.cpuUsage(previousValue);
|
|
4951
|
+
}
|
|
4952
|
+
return { user: 0, system: 0 };
|
|
4953
|
+
}
|
|
4954
|
+
// Note: Cannot check globalThis.process.stdout here — on GJS globalThis.process
|
|
4955
|
+
// IS this instance, so that would cause infinite recursion.
|
|
4956
|
+
stdout = new ProcessWriteStream(1);
|
|
4957
|
+
stderr = new ProcessWriteStream(2);
|
|
4958
|
+
stdin = new ProcessReadStream(0);
|
|
4959
|
+
abort() {
|
|
4960
|
+
this.exit(1);
|
|
4961
|
+
}
|
|
4962
|
+
// no-op stubs for compatibility
|
|
4963
|
+
umask(mask) {
|
|
4964
|
+
return 18;
|
|
4965
|
+
}
|
|
4966
|
+
emitWarning(warning, name2) {
|
|
4967
|
+
if (typeof warning === "string") {
|
|
4968
|
+
console.warn(`(${name2 || "Warning"}): ${warning}`);
|
|
4969
|
+
} else {
|
|
4970
|
+
console.warn(warning.message);
|
|
4971
|
+
}
|
|
4972
|
+
}
|
|
4973
|
+
};
|
|
4974
|
+
Process.prototype.hrtime.bigint = function() {
|
|
4975
|
+
return getMonotonicTime() - hrtimeBase;
|
|
4976
|
+
};
|
|
4977
|
+
var process = new Process();
|
|
4978
|
+
if (nativeTerminal) {
|
|
4979
|
+
try {
|
|
4980
|
+
const watcher = new nativeTerminal.ResizeWatcher();
|
|
4981
|
+
watcher.connect("resized", (_obj, _rows, _cols) => {
|
|
4982
|
+
process.stdout.emit("resize");
|
|
4983
|
+
process.stderr.emit("resize");
|
|
4984
|
+
});
|
|
4985
|
+
watcher.start();
|
|
4986
|
+
} catch {
|
|
4987
|
+
}
|
|
4988
|
+
}
|
|
4989
|
+
var platform = process.platform;
|
|
4990
|
+
var arch = process.arch;
|
|
4991
|
+
var env = process.env;
|
|
4992
|
+
var argv = process.argv;
|
|
4993
|
+
var argv0 = process.argv0;
|
|
4994
|
+
var execPath = process.execPath;
|
|
4995
|
+
var pid = process.pid;
|
|
4996
|
+
var ppid = process.ppid;
|
|
4997
|
+
var version = process.version;
|
|
4998
|
+
var versions = process.versions;
|
|
4999
|
+
var cwd = process.cwd.bind(process);
|
|
5000
|
+
var chdir = process.chdir.bind(process);
|
|
5001
|
+
var exit = process.exit.bind(process);
|
|
5002
|
+
var nextTick = process.nextTick.bind(process);
|
|
5003
|
+
var hrtime = process.hrtime.bind(process);
|
|
5004
|
+
var uptime = process.uptime.bind(process);
|
|
5005
|
+
var memoryUsage = process.memoryUsage.bind(process);
|
|
5006
|
+
var cpuUsage = process.cpuUsage.bind(process);
|
|
5007
|
+
var kill = process.kill.bind(process);
|
|
5008
|
+
var abort = process.abort.bind(process);
|
|
5009
|
+
var umask = process.umask.bind(process);
|
|
5010
|
+
var emitWarning = process.emitWarning.bind(process);
|
|
5011
|
+
var execArgv = process.execArgv;
|
|
5012
|
+
var config = process.config;
|
|
5013
|
+
var stdout = process.stdout;
|
|
5014
|
+
var stderr = process.stderr;
|
|
5015
|
+
var stdin = process.stdin;
|
|
5016
|
+
var index_default = process;
|
|
5017
|
+
|
|
5018
|
+
// ../../../packages/node/globals/lib/esm/register/process.js
|
|
5019
|
+
if (typeof Promise.withResolvers !== "function") {
|
|
5020
|
+
Promise.withResolvers = function() {
|
|
5021
|
+
let resolve;
|
|
5022
|
+
let reject;
|
|
5023
|
+
const promise = new Promise((res, rej) => {
|
|
5024
|
+
resolve = res;
|
|
5025
|
+
reject = rej;
|
|
5026
|
+
});
|
|
5027
|
+
return { promise, resolve, reject };
|
|
5028
|
+
};
|
|
5029
|
+
}
|
|
5030
|
+
initErrorV8Methods(Error);
|
|
5031
|
+
if (!("global" in globalThis)) {
|
|
5032
|
+
Object.defineProperty(globalThis, "global", {
|
|
5033
|
+
value: globalThis,
|
|
5034
|
+
writable: false,
|
|
5035
|
+
enumerable: false,
|
|
5036
|
+
configurable: true
|
|
5037
|
+
});
|
|
5038
|
+
}
|
|
5039
|
+
Object.defineProperty(globalThis, "process", {
|
|
5040
|
+
value: index_default,
|
|
5041
|
+
enumerable: false,
|
|
5042
|
+
writable: true,
|
|
5043
|
+
configurable: true
|
|
5044
|
+
});
|
|
5045
|
+
|
|
2898
5046
|
// ../../../packages/node/perf_hooks/lib/esm/index.js
|
|
2899
5047
|
var performance2;
|
|
2900
5048
|
if (globalThis.performance) {
|
|
@@ -2922,17 +5070,17 @@ if (globalThis.performance) {
|
|
|
2922
5070
|
return entry;
|
|
2923
5071
|
},
|
|
2924
5072
|
measure(name2, startMark, endMark) {
|
|
2925
|
-
let
|
|
5073
|
+
let startTime2 = 0;
|
|
2926
5074
|
let endTime = _now();
|
|
2927
5075
|
if (startMark) {
|
|
2928
5076
|
const s = _entries.find((e) => e.entryType === "mark" && e.name === startMark);
|
|
2929
|
-
if (s)
|
|
5077
|
+
if (s) startTime2 = s.startTime;
|
|
2930
5078
|
}
|
|
2931
5079
|
if (endMark) {
|
|
2932
5080
|
const e = _entries.find((e2) => e2.entryType === "mark" && e2.name === endMark);
|
|
2933
5081
|
if (e) endTime = e.startTime;
|
|
2934
5082
|
}
|
|
2935
|
-
const entry = { name: name2, entryType: "measure", startTime, duration: endTime -
|
|
5083
|
+
const entry = { name: name2, entryType: "measure", startTime: startTime2, duration: endTime - startTime2 };
|
|
2936
5084
|
_entries.push(entry);
|
|
2937
5085
|
return entry;
|
|
2938
5086
|
},
|