@mtkruto/node 0.0.831 → 0.0.834
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/esm/client/client.js +24 -8
- package/esm/client/client_abstract.d.ts +1 -1
- package/esm/client/client_abstract.js +3 -8
- package/esm/client/client_plain.js +8 -7
- package/esm/connection/connection.d.ts +1 -0
- package/esm/connection/connection_web_socket.d.ts +1 -0
- package/esm/connection/connection_web_socket.js +3 -0
- package/esm/deps/deno.land/std@0.69.0/fmt/colors.d.ts +77 -0
- package/esm/deps/deno.land/std@0.69.0/fmt/colors.js +224 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.d.ts +3 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.js +71 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.d.ts +22 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.js +112 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.d.ts +2 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.js +2 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/format.d.ts +1 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/format.js +39 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.d.ts +1 -0
- package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js +1 -0
- package/esm/deps.d.ts +3 -1
- package/esm/deps.js +3 -1
- package/package.json +8 -6
- package/script/client/client.js +23 -7
- package/script/client/client_abstract.d.ts +1 -1
- package/script/client/client_abstract.js +3 -8
- package/script/client/client_plain.js +7 -6
- package/script/connection/connection.d.ts +1 -0
- package/script/connection/connection_web_socket.d.ts +1 -0
- package/script/connection/connection_web_socket.js +3 -0
- package/script/deps/deno.land/std@0.69.0/fmt/colors.d.ts +77 -0
- package/script/deps/deno.land/std@0.69.0/fmt/colors.js +298 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.d.ts +3 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.js +98 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.d.ts +22 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.js +141 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.d.ts +2 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.js +32 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/format.d.ts +1 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/format.js +43 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.d.ts +1 -0
- package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js +17 -0
- package/script/deps.d.ts +3 -1
- package/script/deps.js +5 -2
- /package/esm/deps/deno.land/{std@0.186.0 → std@0.190.0}/fmt/colors.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.186.0 → std@0.190.0}/fmt/colors.js +0 -0
- /package/esm/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/_diff.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/_diff.js +0 -0
- /package/esm/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/_format.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/_format.js +0 -0
- /package/esm/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/asserts.d.ts +0 -0
- /package/esm/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/asserts.js +0 -0
- /package/script/deps/deno.land/{std@0.186.0 → std@0.190.0}/fmt/colors.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.186.0 → std@0.190.0}/fmt/colors.js +0 -0
- /package/script/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/_diff.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/_diff.js +0 -0
- /package/script/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/_format.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/_format.js +0 -0
- /package/script/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/asserts.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.186.0 → std@0.190.0}/testing/asserts.js +0 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.stripColor = exports.bgRgb24 = exports.rgb24 = exports.bgRgb8 = exports.rgb8 = exports.bgBrightWhite = exports.bgBrightCyan = exports.bgBrightMagenta = exports.bgBrightBlue = exports.bgBrightYellow = exports.bgBrightGreen = exports.bgBrightRed = exports.bgBrightBlack = exports.bgWhite = exports.bgCyan = exports.bgMagenta = exports.bgBlue = exports.bgYellow = exports.bgGreen = exports.bgRed = exports.bgBlack = exports.brightWhite = exports.brightCyan = exports.brightMagenta = exports.brightBlue = exports.brightYellow = exports.brightGreen = exports.brightRed = exports.brightBlack = exports.gray = exports.white = exports.cyan = exports.magenta = exports.blue = exports.yellow = exports.green = exports.red = exports.black = exports.strikethrough = exports.hidden = exports.inverse = exports.underline = exports.italic = exports.dim = exports.bold = exports.reset = exports.getColorEnabled = exports.setColorEnabled = void 0;
|
|
27
|
+
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
|
28
|
+
/** A module to print ANSI terminal colors. Inspired by chalk, kleur, and colors
|
|
29
|
+
* on npm.
|
|
30
|
+
*
|
|
31
|
+
* ```
|
|
32
|
+
* import { bgBlue, red, bold } from "https://deno.land/std/fmt/colors.ts";
|
|
33
|
+
* console.log(bgBlue(red(bold("Hello world!"))));
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* This module supports `NO_COLOR` environmental variable disabling any coloring
|
|
37
|
+
* if `NO_COLOR` is set.
|
|
38
|
+
*
|
|
39
|
+
* This module is browser compatible. */
|
|
40
|
+
const dntShim = __importStar(require("../../../../_dnt.shims.js"));
|
|
41
|
+
const noColor = dntShim.dntGlobalThis.Deno?.noColor ?? true;
|
|
42
|
+
let enabled = !noColor;
|
|
43
|
+
function setColorEnabled(value) {
|
|
44
|
+
if (noColor) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
enabled = value;
|
|
48
|
+
}
|
|
49
|
+
exports.setColorEnabled = setColorEnabled;
|
|
50
|
+
function getColorEnabled() {
|
|
51
|
+
return enabled;
|
|
52
|
+
}
|
|
53
|
+
exports.getColorEnabled = getColorEnabled;
|
|
54
|
+
function code(open, close) {
|
|
55
|
+
return {
|
|
56
|
+
open: `\x1b[${open.join(";")}m`,
|
|
57
|
+
close: `\x1b[${close}m`,
|
|
58
|
+
regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function run(str, code) {
|
|
62
|
+
return enabled
|
|
63
|
+
? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
|
|
64
|
+
: str;
|
|
65
|
+
}
|
|
66
|
+
function reset(str) {
|
|
67
|
+
return run(str, code([0], 0));
|
|
68
|
+
}
|
|
69
|
+
exports.reset = reset;
|
|
70
|
+
function bold(str) {
|
|
71
|
+
return run(str, code([1], 22));
|
|
72
|
+
}
|
|
73
|
+
exports.bold = bold;
|
|
74
|
+
function dim(str) {
|
|
75
|
+
return run(str, code([2], 22));
|
|
76
|
+
}
|
|
77
|
+
exports.dim = dim;
|
|
78
|
+
function italic(str) {
|
|
79
|
+
return run(str, code([3], 23));
|
|
80
|
+
}
|
|
81
|
+
exports.italic = italic;
|
|
82
|
+
function underline(str) {
|
|
83
|
+
return run(str, code([4], 24));
|
|
84
|
+
}
|
|
85
|
+
exports.underline = underline;
|
|
86
|
+
function inverse(str) {
|
|
87
|
+
return run(str, code([7], 27));
|
|
88
|
+
}
|
|
89
|
+
exports.inverse = inverse;
|
|
90
|
+
function hidden(str) {
|
|
91
|
+
return run(str, code([8], 28));
|
|
92
|
+
}
|
|
93
|
+
exports.hidden = hidden;
|
|
94
|
+
function strikethrough(str) {
|
|
95
|
+
return run(str, code([9], 29));
|
|
96
|
+
}
|
|
97
|
+
exports.strikethrough = strikethrough;
|
|
98
|
+
function black(str) {
|
|
99
|
+
return run(str, code([30], 39));
|
|
100
|
+
}
|
|
101
|
+
exports.black = black;
|
|
102
|
+
function red(str) {
|
|
103
|
+
return run(str, code([31], 39));
|
|
104
|
+
}
|
|
105
|
+
exports.red = red;
|
|
106
|
+
function green(str) {
|
|
107
|
+
return run(str, code([32], 39));
|
|
108
|
+
}
|
|
109
|
+
exports.green = green;
|
|
110
|
+
function yellow(str) {
|
|
111
|
+
return run(str, code([33], 39));
|
|
112
|
+
}
|
|
113
|
+
exports.yellow = yellow;
|
|
114
|
+
function blue(str) {
|
|
115
|
+
return run(str, code([34], 39));
|
|
116
|
+
}
|
|
117
|
+
exports.blue = blue;
|
|
118
|
+
function magenta(str) {
|
|
119
|
+
return run(str, code([35], 39));
|
|
120
|
+
}
|
|
121
|
+
exports.magenta = magenta;
|
|
122
|
+
function cyan(str) {
|
|
123
|
+
return run(str, code([36], 39));
|
|
124
|
+
}
|
|
125
|
+
exports.cyan = cyan;
|
|
126
|
+
function white(str) {
|
|
127
|
+
return run(str, code([37], 39));
|
|
128
|
+
}
|
|
129
|
+
exports.white = white;
|
|
130
|
+
function gray(str) {
|
|
131
|
+
return brightBlack(str);
|
|
132
|
+
}
|
|
133
|
+
exports.gray = gray;
|
|
134
|
+
function brightBlack(str) {
|
|
135
|
+
return run(str, code([90], 39));
|
|
136
|
+
}
|
|
137
|
+
exports.brightBlack = brightBlack;
|
|
138
|
+
function brightRed(str) {
|
|
139
|
+
return run(str, code([91], 39));
|
|
140
|
+
}
|
|
141
|
+
exports.brightRed = brightRed;
|
|
142
|
+
function brightGreen(str) {
|
|
143
|
+
return run(str, code([92], 39));
|
|
144
|
+
}
|
|
145
|
+
exports.brightGreen = brightGreen;
|
|
146
|
+
function brightYellow(str) {
|
|
147
|
+
return run(str, code([93], 39));
|
|
148
|
+
}
|
|
149
|
+
exports.brightYellow = brightYellow;
|
|
150
|
+
function brightBlue(str) {
|
|
151
|
+
return run(str, code([94], 39));
|
|
152
|
+
}
|
|
153
|
+
exports.brightBlue = brightBlue;
|
|
154
|
+
function brightMagenta(str) {
|
|
155
|
+
return run(str, code([95], 39));
|
|
156
|
+
}
|
|
157
|
+
exports.brightMagenta = brightMagenta;
|
|
158
|
+
function brightCyan(str) {
|
|
159
|
+
return run(str, code([96], 39));
|
|
160
|
+
}
|
|
161
|
+
exports.brightCyan = brightCyan;
|
|
162
|
+
function brightWhite(str) {
|
|
163
|
+
return run(str, code([97], 39));
|
|
164
|
+
}
|
|
165
|
+
exports.brightWhite = brightWhite;
|
|
166
|
+
function bgBlack(str) {
|
|
167
|
+
return run(str, code([40], 49));
|
|
168
|
+
}
|
|
169
|
+
exports.bgBlack = bgBlack;
|
|
170
|
+
function bgRed(str) {
|
|
171
|
+
return run(str, code([41], 49));
|
|
172
|
+
}
|
|
173
|
+
exports.bgRed = bgRed;
|
|
174
|
+
function bgGreen(str) {
|
|
175
|
+
return run(str, code([42], 49));
|
|
176
|
+
}
|
|
177
|
+
exports.bgGreen = bgGreen;
|
|
178
|
+
function bgYellow(str) {
|
|
179
|
+
return run(str, code([43], 49));
|
|
180
|
+
}
|
|
181
|
+
exports.bgYellow = bgYellow;
|
|
182
|
+
function bgBlue(str) {
|
|
183
|
+
return run(str, code([44], 49));
|
|
184
|
+
}
|
|
185
|
+
exports.bgBlue = bgBlue;
|
|
186
|
+
function bgMagenta(str) {
|
|
187
|
+
return run(str, code([45], 49));
|
|
188
|
+
}
|
|
189
|
+
exports.bgMagenta = bgMagenta;
|
|
190
|
+
function bgCyan(str) {
|
|
191
|
+
return run(str, code([46], 49));
|
|
192
|
+
}
|
|
193
|
+
exports.bgCyan = bgCyan;
|
|
194
|
+
function bgWhite(str) {
|
|
195
|
+
return run(str, code([47], 49));
|
|
196
|
+
}
|
|
197
|
+
exports.bgWhite = bgWhite;
|
|
198
|
+
function bgBrightBlack(str) {
|
|
199
|
+
return run(str, code([100], 49));
|
|
200
|
+
}
|
|
201
|
+
exports.bgBrightBlack = bgBrightBlack;
|
|
202
|
+
function bgBrightRed(str) {
|
|
203
|
+
return run(str, code([101], 49));
|
|
204
|
+
}
|
|
205
|
+
exports.bgBrightRed = bgBrightRed;
|
|
206
|
+
function bgBrightGreen(str) {
|
|
207
|
+
return run(str, code([102], 49));
|
|
208
|
+
}
|
|
209
|
+
exports.bgBrightGreen = bgBrightGreen;
|
|
210
|
+
function bgBrightYellow(str) {
|
|
211
|
+
return run(str, code([103], 49));
|
|
212
|
+
}
|
|
213
|
+
exports.bgBrightYellow = bgBrightYellow;
|
|
214
|
+
function bgBrightBlue(str) {
|
|
215
|
+
return run(str, code([104], 49));
|
|
216
|
+
}
|
|
217
|
+
exports.bgBrightBlue = bgBrightBlue;
|
|
218
|
+
function bgBrightMagenta(str) {
|
|
219
|
+
return run(str, code([105], 49));
|
|
220
|
+
}
|
|
221
|
+
exports.bgBrightMagenta = bgBrightMagenta;
|
|
222
|
+
function bgBrightCyan(str) {
|
|
223
|
+
return run(str, code([106], 49));
|
|
224
|
+
}
|
|
225
|
+
exports.bgBrightCyan = bgBrightCyan;
|
|
226
|
+
function bgBrightWhite(str) {
|
|
227
|
+
return run(str, code([107], 49));
|
|
228
|
+
}
|
|
229
|
+
exports.bgBrightWhite = bgBrightWhite;
|
|
230
|
+
/* Special Color Sequences */
|
|
231
|
+
function clampAndTruncate(n, max = 255, min = 0) {
|
|
232
|
+
return Math.trunc(Math.max(Math.min(n, max), min));
|
|
233
|
+
}
|
|
234
|
+
/** Set text color using paletted 8bit colors.
|
|
235
|
+
* https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit */
|
|
236
|
+
function rgb8(str, color) {
|
|
237
|
+
return run(str, code([38, 5, clampAndTruncate(color)], 39));
|
|
238
|
+
}
|
|
239
|
+
exports.rgb8 = rgb8;
|
|
240
|
+
/** Set background color using paletted 8bit colors.
|
|
241
|
+
* https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit */
|
|
242
|
+
function bgRgb8(str, color) {
|
|
243
|
+
return run(str, code([48, 5, clampAndTruncate(color)], 49));
|
|
244
|
+
}
|
|
245
|
+
exports.bgRgb8 = bgRgb8;
|
|
246
|
+
/** Set text color using 24bit rgb.
|
|
247
|
+
* `color` can be a number in range `0x000000` to `0xffffff` or
|
|
248
|
+
* an `Rgb`.
|
|
249
|
+
*
|
|
250
|
+
* To produce the color magenta:
|
|
251
|
+
*
|
|
252
|
+
* rgba24("foo", 0xff00ff);
|
|
253
|
+
* rgba24("foo", {r: 255, g: 0, b: 255});
|
|
254
|
+
*/
|
|
255
|
+
function rgb24(str, color) {
|
|
256
|
+
if (typeof color === "number") {
|
|
257
|
+
return run(str, code([38, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 39));
|
|
258
|
+
}
|
|
259
|
+
return run(str, code([
|
|
260
|
+
38,
|
|
261
|
+
2,
|
|
262
|
+
clampAndTruncate(color.r),
|
|
263
|
+
clampAndTruncate(color.g),
|
|
264
|
+
clampAndTruncate(color.b),
|
|
265
|
+
], 39));
|
|
266
|
+
}
|
|
267
|
+
exports.rgb24 = rgb24;
|
|
268
|
+
/** Set background color using 24bit rgb.
|
|
269
|
+
* `color` can be a number in range `0x000000` to `0xffffff` or
|
|
270
|
+
* an `Rgb`.
|
|
271
|
+
*
|
|
272
|
+
* To produce the color magenta:
|
|
273
|
+
*
|
|
274
|
+
* bgRgba24("foo", 0xff00ff);
|
|
275
|
+
* bgRgba24("foo", {r: 255, g: 0, b: 255});
|
|
276
|
+
*/
|
|
277
|
+
function bgRgb24(str, color) {
|
|
278
|
+
if (typeof color === "number") {
|
|
279
|
+
return run(str, code([48, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 49));
|
|
280
|
+
}
|
|
281
|
+
return run(str, code([
|
|
282
|
+
48,
|
|
283
|
+
2,
|
|
284
|
+
clampAndTruncate(color.r),
|
|
285
|
+
clampAndTruncate(color.g),
|
|
286
|
+
clampAndTruncate(color.b),
|
|
287
|
+
], 49));
|
|
288
|
+
}
|
|
289
|
+
exports.bgRgb24 = bgRgb24;
|
|
290
|
+
// https://github.com/chalk/ansi-regex/blob/2b56fb0c7a07108e5b54241e8faec160d393aedb/index.js
|
|
291
|
+
const ANSI_PATTERN = new RegExp([
|
|
292
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
293
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))",
|
|
294
|
+
].join("|"), "g");
|
|
295
|
+
function stripColor(string) {
|
|
296
|
+
return string.replace(ANSI_PATTERN, "");
|
|
297
|
+
}
|
|
298
|
+
exports.stripColor = stripColor;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.generateColor = exports.colorFunctions = void 0;
|
|
27
|
+
const dntShim = __importStar(require("../../../../../_dnt.shims.js"));
|
|
28
|
+
const deps_js_1 = require("./deps.js");
|
|
29
|
+
// @ts-ignore: lib
|
|
30
|
+
const isBrowser = typeof dntShim.Deno === "undefined" &&
|
|
31
|
+
// @ts-ignore: lib
|
|
32
|
+
typeof process === "undefined" && typeof dntShim.dntGlobalThis !== "undefined" &&
|
|
33
|
+
// @ts-ignore: lib
|
|
34
|
+
typeof document !== "undefined";
|
|
35
|
+
exports.colorFunctions = [
|
|
36
|
+
(v) => {
|
|
37
|
+
if (isBrowser) {
|
|
38
|
+
return [`%c${v}`, "color: red"];
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return [deps_js_1.colors.red(v)];
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
(v) => {
|
|
45
|
+
if (isBrowser) {
|
|
46
|
+
return [`%c${v}`, "color: green"];
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return [deps_js_1.colors.green(v)];
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
(v) => {
|
|
53
|
+
if (isBrowser) {
|
|
54
|
+
return [`%c${v}`, "color: yellow"];
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
return [deps_js_1.colors.yellow(v)];
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
(v) => {
|
|
61
|
+
if (isBrowser) {
|
|
62
|
+
return [`%c${v}`, "color: blue"];
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return [deps_js_1.colors.blue(v)];
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
(v) => {
|
|
69
|
+
if (isBrowser) {
|
|
70
|
+
return [`%c${v}`, "color: magenta"];
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return [deps_js_1.colors.magenta(v)];
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
(v) => {
|
|
77
|
+
if (isBrowser) {
|
|
78
|
+
return [`%c${v}`, "color: cyan"];
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return [deps_js_1.colors.cyan(v)];
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
];
|
|
85
|
+
function hashCode(s) {
|
|
86
|
+
let h = 0;
|
|
87
|
+
const l = s.length;
|
|
88
|
+
let i = 0;
|
|
89
|
+
if (l > 0)
|
|
90
|
+
while (i < l)
|
|
91
|
+
h = ((h << 5) - h + s.charCodeAt(i++)) | 0;
|
|
92
|
+
return h;
|
|
93
|
+
}
|
|
94
|
+
function generateColor(message) {
|
|
95
|
+
const hash = Math.abs(hashCode(message));
|
|
96
|
+
return exports.colorFunctions[hash % exports.colorFunctions.length];
|
|
97
|
+
}
|
|
98
|
+
exports.generateColor = generateColor;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ColorFunction } from "./colors.js";
|
|
2
|
+
export interface Debug {
|
|
3
|
+
(fmt: string, ...args: unknown[]): void;
|
|
4
|
+
self: Debugger;
|
|
5
|
+
}
|
|
6
|
+
export declare class Debugger {
|
|
7
|
+
manager: DebugManager;
|
|
8
|
+
ns: string;
|
|
9
|
+
color: ColorFunction;
|
|
10
|
+
last: number;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
constructor(manager: DebugManager, namespace: string);
|
|
13
|
+
log(fmt: string, ...args: unknown[]): void;
|
|
14
|
+
}
|
|
15
|
+
declare class DebugManager {
|
|
16
|
+
debuggers: Map<string, Debugger>;
|
|
17
|
+
enabled: RegExp[];
|
|
18
|
+
constructor(enabled?: RegExp[]);
|
|
19
|
+
}
|
|
20
|
+
export declare function withoutEnv(enabled?: RegExp[] | string): void;
|
|
21
|
+
export declare function debug(namespace: string): Debug;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.debug = exports.withoutEnv = exports.Debugger = void 0;
|
|
27
|
+
const dntShim = __importStar(require("../../../../../_dnt.shims.js"));
|
|
28
|
+
const colors_js_1 = require("./colors.js");
|
|
29
|
+
const format_js_1 = require("./format.js");
|
|
30
|
+
class Debugger {
|
|
31
|
+
constructor(manager, namespace) {
|
|
32
|
+
Object.defineProperty(this, "manager", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(this, "ns", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
configurable: true,
|
|
41
|
+
writable: true,
|
|
42
|
+
value: void 0
|
|
43
|
+
});
|
|
44
|
+
Object.defineProperty(this, "color", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: void 0
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(this, "last", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: void 0
|
|
55
|
+
});
|
|
56
|
+
Object.defineProperty(this, "enabled", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
configurable: true,
|
|
59
|
+
writable: true,
|
|
60
|
+
value: void 0
|
|
61
|
+
});
|
|
62
|
+
this.manager = manager;
|
|
63
|
+
this.ns = namespace;
|
|
64
|
+
this.color = (0, colors_js_1.generateColor)(namespace);
|
|
65
|
+
this.last = 0;
|
|
66
|
+
this.enabled = manager.enabled.some((r) => r.test(namespace));
|
|
67
|
+
}
|
|
68
|
+
log(fmt, ...args) {
|
|
69
|
+
if (!this.enabled)
|
|
70
|
+
return;
|
|
71
|
+
const diff = Date.now() - (this.last || Date.now());
|
|
72
|
+
fmt = (0, format_js_1.format)(fmt, ...args);
|
|
73
|
+
console.debug(...this.color(this.ns), fmt, ...this.color(`+${diff}ms`));
|
|
74
|
+
this.last = Date.now();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.Debugger = Debugger;
|
|
78
|
+
class DebugManager {
|
|
79
|
+
constructor(enabled) {
|
|
80
|
+
Object.defineProperty(this, "debuggers", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: void 0
|
|
85
|
+
});
|
|
86
|
+
Object.defineProperty(this, "enabled", {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
configurable: true,
|
|
89
|
+
writable: true,
|
|
90
|
+
value: void 0
|
|
91
|
+
});
|
|
92
|
+
this.debuggers = new Map();
|
|
93
|
+
this.enabled = enabled ?? [];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function extract(opts) {
|
|
97
|
+
if (!opts || opts.length === 0)
|
|
98
|
+
return [];
|
|
99
|
+
opts = opts.replace(/\s/g, "").replace(/\*/g, ".+");
|
|
100
|
+
return opts.split(",").map((rule) => new RegExp(`^${rule}$`));
|
|
101
|
+
}
|
|
102
|
+
let manager;
|
|
103
|
+
function withoutEnv(enabled) {
|
|
104
|
+
if (!enabled)
|
|
105
|
+
enabled = [];
|
|
106
|
+
if (typeof enabled === "string")
|
|
107
|
+
enabled = extract(enabled);
|
|
108
|
+
manager = new DebugManager(enabled);
|
|
109
|
+
}
|
|
110
|
+
exports.withoutEnv = withoutEnv;
|
|
111
|
+
// @ts-ignore: lib
|
|
112
|
+
const isDeno = typeof dntShim.Deno !== "undefined" &&
|
|
113
|
+
typeof dntShim.dntGlobalThis !== "undefined";
|
|
114
|
+
// @ts-ignore: lib
|
|
115
|
+
const isNode = typeof process !== "undefined" &&
|
|
116
|
+
typeof dntShim.dntGlobalThis === "undefined";
|
|
117
|
+
function getOpts() {
|
|
118
|
+
if (isDeno) {
|
|
119
|
+
// @ts-ignore: lib
|
|
120
|
+
return dntShim.Deno.env.get("DEBUG");
|
|
121
|
+
}
|
|
122
|
+
else if (isNode) {
|
|
123
|
+
// @ts-ignore: lib
|
|
124
|
+
return process.env.DEBUG;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
// @ts-ignore: lib
|
|
128
|
+
return globalThis.DEBUG;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function debug(namespace) {
|
|
132
|
+
if (!manager)
|
|
133
|
+
manager = new DebugManager(extract(getOpts()));
|
|
134
|
+
const dbg = new Debugger(manager, namespace);
|
|
135
|
+
manager.debuggers.set(namespace, dbg);
|
|
136
|
+
const de = Object.assign(dbg.log.bind(dbg), {
|
|
137
|
+
self: dbg,
|
|
138
|
+
});
|
|
139
|
+
return de;
|
|
140
|
+
}
|
|
141
|
+
exports.debug = debug;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.inspect = exports.colors = void 0;
|
|
30
|
+
exports.colors = __importStar(require("../../../../deno.land/std@0.69.0/fmt/colors.js"));
|
|
31
|
+
var object_inspect_1 = require("object-inspect");
|
|
32
|
+
Object.defineProperty(exports, "inspect", { enumerable: true, get: function () { return __importDefault(object_inspect_1).default; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function format(f: string, ...args: unknown[]): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.format = void 0;
|
|
4
|
+
const deps_js_1 = require("./deps.js");
|
|
5
|
+
function format(f, ...args) {
|
|
6
|
+
let i = 0;
|
|
7
|
+
const len = args.length;
|
|
8
|
+
let str = String(f).replace(/%[sdjoO%]/g, (x) => {
|
|
9
|
+
if (x === "%%")
|
|
10
|
+
return "%";
|
|
11
|
+
if (i >= len)
|
|
12
|
+
return x;
|
|
13
|
+
switch (x) {
|
|
14
|
+
case "%s":
|
|
15
|
+
return String(args[i++]);
|
|
16
|
+
case "%d":
|
|
17
|
+
return Number(args[i++]).toString();
|
|
18
|
+
case "%o":
|
|
19
|
+
return (0, deps_js_1.inspect)(args[i++]).split("\n").map((_) => _.trim()).join(" ");
|
|
20
|
+
case "%O":
|
|
21
|
+
return (0, deps_js_1.inspect)(args[i++]);
|
|
22
|
+
case "%j":
|
|
23
|
+
try {
|
|
24
|
+
return JSON.stringify(args[i++]);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return "[Circular]";
|
|
28
|
+
}
|
|
29
|
+
default:
|
|
30
|
+
return x;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
for (const x of args.splice(i)) {
|
|
34
|
+
if (x === null || !(typeof x === "object" && x !== null)) {
|
|
35
|
+
str += " " + x;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
str += " " + (0, deps_js_1.inspect)(x);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return str;
|
|
42
|
+
}
|
|
43
|
+
exports.format = format;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./debug.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./debug.js"), exports);
|
package/script/deps.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export * from "./deps/deno.land/std@0.
|
|
1
|
+
export * from "./deps/deno.land/std@0.190.0/testing/asserts.js";
|
|
2
2
|
export { ctr256Decrypt, ctr256Encrypt, factorize, ige256Decrypt, ige256Encrypt, init as initTgCrypto } from "./deps/deno.land/x/tgcrypto@0.1.3/mod.js";
|
|
3
3
|
export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js";
|
|
4
4
|
export { Mutex } from "async-mutex";
|
|
5
5
|
export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
|
|
6
|
+
import { debug as debug_ } from "./deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js";
|
|
7
|
+
export declare const debug: typeof debug_;
|