@sockethub/irc2as 4.0.0-alpha.10
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/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/index.js +1263 -0
- package/dist/index.js.map +18 -0
- package/package.json +53 -0
- package/src/as-emitter.js +277 -0
- package/src/index.js +308 -0
- package/src/index.test.data.irc.txt +86 -0
- package/src/index.test.data.js +492 -0
- package/src/index.test.js +96 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1263 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
8
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
|
+
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
|
+
for (let key of __getOwnPropNames(mod))
|
|
11
|
+
if (!__hasOwnProp.call(to, key))
|
|
12
|
+
__defProp(to, key, {
|
|
13
|
+
get: () => mod[key],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
19
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
20
|
+
|
|
21
|
+
// ../../node_modules/ms/index.js
|
|
22
|
+
var require_ms = __commonJS((exports, module) => {
|
|
23
|
+
var s = 1000;
|
|
24
|
+
var m = s * 60;
|
|
25
|
+
var h = m * 60;
|
|
26
|
+
var d = h * 24;
|
|
27
|
+
var w = d * 7;
|
|
28
|
+
var y = d * 365.25;
|
|
29
|
+
module.exports = function(val, options) {
|
|
30
|
+
options = options || {};
|
|
31
|
+
var type = typeof val;
|
|
32
|
+
if (type === "string" && val.length > 0) {
|
|
33
|
+
return parse(val);
|
|
34
|
+
} else if (type === "number" && isFinite(val)) {
|
|
35
|
+
return options.long ? fmtLong(val) : fmtShort(val);
|
|
36
|
+
}
|
|
37
|
+
throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(val));
|
|
38
|
+
};
|
|
39
|
+
function parse(str) {
|
|
40
|
+
str = String(str);
|
|
41
|
+
if (str.length > 100) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str);
|
|
45
|
+
if (!match) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
var n = parseFloat(match[1]);
|
|
49
|
+
var type = (match[2] || "ms").toLowerCase();
|
|
50
|
+
switch (type) {
|
|
51
|
+
case "years":
|
|
52
|
+
case "year":
|
|
53
|
+
case "yrs":
|
|
54
|
+
case "yr":
|
|
55
|
+
case "y":
|
|
56
|
+
return n * y;
|
|
57
|
+
case "weeks":
|
|
58
|
+
case "week":
|
|
59
|
+
case "w":
|
|
60
|
+
return n * w;
|
|
61
|
+
case "days":
|
|
62
|
+
case "day":
|
|
63
|
+
case "d":
|
|
64
|
+
return n * d;
|
|
65
|
+
case "hours":
|
|
66
|
+
case "hour":
|
|
67
|
+
case "hrs":
|
|
68
|
+
case "hr":
|
|
69
|
+
case "h":
|
|
70
|
+
return n * h;
|
|
71
|
+
case "minutes":
|
|
72
|
+
case "minute":
|
|
73
|
+
case "mins":
|
|
74
|
+
case "min":
|
|
75
|
+
case "m":
|
|
76
|
+
return n * m;
|
|
77
|
+
case "seconds":
|
|
78
|
+
case "second":
|
|
79
|
+
case "secs":
|
|
80
|
+
case "sec":
|
|
81
|
+
case "s":
|
|
82
|
+
return n * s;
|
|
83
|
+
case "milliseconds":
|
|
84
|
+
case "millisecond":
|
|
85
|
+
case "msecs":
|
|
86
|
+
case "msec":
|
|
87
|
+
case "ms":
|
|
88
|
+
return n;
|
|
89
|
+
default:
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function fmtShort(ms) {
|
|
94
|
+
var msAbs = Math.abs(ms);
|
|
95
|
+
if (msAbs >= d) {
|
|
96
|
+
return Math.round(ms / d) + "d";
|
|
97
|
+
}
|
|
98
|
+
if (msAbs >= h) {
|
|
99
|
+
return Math.round(ms / h) + "h";
|
|
100
|
+
}
|
|
101
|
+
if (msAbs >= m) {
|
|
102
|
+
return Math.round(ms / m) + "m";
|
|
103
|
+
}
|
|
104
|
+
if (msAbs >= s) {
|
|
105
|
+
return Math.round(ms / s) + "s";
|
|
106
|
+
}
|
|
107
|
+
return ms + "ms";
|
|
108
|
+
}
|
|
109
|
+
function fmtLong(ms) {
|
|
110
|
+
var msAbs = Math.abs(ms);
|
|
111
|
+
if (msAbs >= d) {
|
|
112
|
+
return plural(ms, msAbs, d, "day");
|
|
113
|
+
}
|
|
114
|
+
if (msAbs >= h) {
|
|
115
|
+
return plural(ms, msAbs, h, "hour");
|
|
116
|
+
}
|
|
117
|
+
if (msAbs >= m) {
|
|
118
|
+
return plural(ms, msAbs, m, "minute");
|
|
119
|
+
}
|
|
120
|
+
if (msAbs >= s) {
|
|
121
|
+
return plural(ms, msAbs, s, "second");
|
|
122
|
+
}
|
|
123
|
+
return ms + " ms";
|
|
124
|
+
}
|
|
125
|
+
function plural(ms, msAbs, n, name) {
|
|
126
|
+
var isPlural = msAbs >= n * 1.5;
|
|
127
|
+
return Math.round(ms / n) + " " + name + (isPlural ? "s" : "");
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// ../../node_modules/debug/src/common.js
|
|
132
|
+
var require_common = __commonJS((exports, module) => {
|
|
133
|
+
function setup(env) {
|
|
134
|
+
createDebug.debug = createDebug;
|
|
135
|
+
createDebug.default = createDebug;
|
|
136
|
+
createDebug.coerce = coerce;
|
|
137
|
+
createDebug.disable = disable;
|
|
138
|
+
createDebug.enable = enable;
|
|
139
|
+
createDebug.enabled = enabled;
|
|
140
|
+
createDebug.humanize = require_ms();
|
|
141
|
+
createDebug.destroy = destroy;
|
|
142
|
+
Object.keys(env).forEach((key) => {
|
|
143
|
+
createDebug[key] = env[key];
|
|
144
|
+
});
|
|
145
|
+
createDebug.names = [];
|
|
146
|
+
createDebug.skips = [];
|
|
147
|
+
createDebug.formatters = {};
|
|
148
|
+
function selectColor(namespace) {
|
|
149
|
+
let hash = 0;
|
|
150
|
+
for (let i = 0;i < namespace.length; i++) {
|
|
151
|
+
hash = (hash << 5) - hash + namespace.charCodeAt(i);
|
|
152
|
+
hash |= 0;
|
|
153
|
+
}
|
|
154
|
+
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
155
|
+
}
|
|
156
|
+
createDebug.selectColor = selectColor;
|
|
157
|
+
function createDebug(namespace) {
|
|
158
|
+
let prevTime;
|
|
159
|
+
let enableOverride = null;
|
|
160
|
+
let namespacesCache;
|
|
161
|
+
let enabledCache;
|
|
162
|
+
function debug(...args) {
|
|
163
|
+
if (!debug.enabled) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const self = debug;
|
|
167
|
+
const curr = Number(new Date);
|
|
168
|
+
const ms = curr - (prevTime || curr);
|
|
169
|
+
self.diff = ms;
|
|
170
|
+
self.prev = prevTime;
|
|
171
|
+
self.curr = curr;
|
|
172
|
+
prevTime = curr;
|
|
173
|
+
args[0] = createDebug.coerce(args[0]);
|
|
174
|
+
if (typeof args[0] !== "string") {
|
|
175
|
+
args.unshift("%O");
|
|
176
|
+
}
|
|
177
|
+
let index = 0;
|
|
178
|
+
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
179
|
+
if (match === "%%") {
|
|
180
|
+
return "%";
|
|
181
|
+
}
|
|
182
|
+
index++;
|
|
183
|
+
const formatter = createDebug.formatters[format];
|
|
184
|
+
if (typeof formatter === "function") {
|
|
185
|
+
const val = args[index];
|
|
186
|
+
match = formatter.call(self, val);
|
|
187
|
+
args.splice(index, 1);
|
|
188
|
+
index--;
|
|
189
|
+
}
|
|
190
|
+
return match;
|
|
191
|
+
});
|
|
192
|
+
createDebug.formatArgs.call(self, args);
|
|
193
|
+
const logFn = self.log || createDebug.log;
|
|
194
|
+
logFn.apply(self, args);
|
|
195
|
+
}
|
|
196
|
+
debug.namespace = namespace;
|
|
197
|
+
debug.useColors = createDebug.useColors();
|
|
198
|
+
debug.color = createDebug.selectColor(namespace);
|
|
199
|
+
debug.extend = extend;
|
|
200
|
+
debug.destroy = createDebug.destroy;
|
|
201
|
+
Object.defineProperty(debug, "enabled", {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
configurable: false,
|
|
204
|
+
get: () => {
|
|
205
|
+
if (enableOverride !== null) {
|
|
206
|
+
return enableOverride;
|
|
207
|
+
}
|
|
208
|
+
if (namespacesCache !== createDebug.namespaces) {
|
|
209
|
+
namespacesCache = createDebug.namespaces;
|
|
210
|
+
enabledCache = createDebug.enabled(namespace);
|
|
211
|
+
}
|
|
212
|
+
return enabledCache;
|
|
213
|
+
},
|
|
214
|
+
set: (v) => {
|
|
215
|
+
enableOverride = v;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
if (typeof createDebug.init === "function") {
|
|
219
|
+
createDebug.init(debug);
|
|
220
|
+
}
|
|
221
|
+
return debug;
|
|
222
|
+
}
|
|
223
|
+
function extend(namespace, delimiter) {
|
|
224
|
+
const newDebug = createDebug(this.namespace + (typeof delimiter === "undefined" ? ":" : delimiter) + namespace);
|
|
225
|
+
newDebug.log = this.log;
|
|
226
|
+
return newDebug;
|
|
227
|
+
}
|
|
228
|
+
function enable(namespaces) {
|
|
229
|
+
createDebug.save(namespaces);
|
|
230
|
+
createDebug.namespaces = namespaces;
|
|
231
|
+
createDebug.names = [];
|
|
232
|
+
createDebug.skips = [];
|
|
233
|
+
const split = (typeof namespaces === "string" ? namespaces : "").trim().replace(/\s+/g, ",").split(",").filter(Boolean);
|
|
234
|
+
for (const ns of split) {
|
|
235
|
+
if (ns[0] === "-") {
|
|
236
|
+
createDebug.skips.push(ns.slice(1));
|
|
237
|
+
} else {
|
|
238
|
+
createDebug.names.push(ns);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function matchesTemplate(search, template) {
|
|
243
|
+
let searchIndex = 0;
|
|
244
|
+
let templateIndex = 0;
|
|
245
|
+
let starIndex = -1;
|
|
246
|
+
let matchIndex = 0;
|
|
247
|
+
while (searchIndex < search.length) {
|
|
248
|
+
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
249
|
+
if (template[templateIndex] === "*") {
|
|
250
|
+
starIndex = templateIndex;
|
|
251
|
+
matchIndex = searchIndex;
|
|
252
|
+
templateIndex++;
|
|
253
|
+
} else {
|
|
254
|
+
searchIndex++;
|
|
255
|
+
templateIndex++;
|
|
256
|
+
}
|
|
257
|
+
} else if (starIndex !== -1) {
|
|
258
|
+
templateIndex = starIndex + 1;
|
|
259
|
+
matchIndex++;
|
|
260
|
+
searchIndex = matchIndex;
|
|
261
|
+
} else {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
while (templateIndex < template.length && template[templateIndex] === "*") {
|
|
266
|
+
templateIndex++;
|
|
267
|
+
}
|
|
268
|
+
return templateIndex === template.length;
|
|
269
|
+
}
|
|
270
|
+
function disable() {
|
|
271
|
+
const namespaces = [
|
|
272
|
+
...createDebug.names,
|
|
273
|
+
...createDebug.skips.map((namespace) => "-" + namespace)
|
|
274
|
+
].join(",");
|
|
275
|
+
createDebug.enable("");
|
|
276
|
+
return namespaces;
|
|
277
|
+
}
|
|
278
|
+
function enabled(name) {
|
|
279
|
+
for (const skip of createDebug.skips) {
|
|
280
|
+
if (matchesTemplate(name, skip)) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
for (const ns of createDebug.names) {
|
|
285
|
+
if (matchesTemplate(name, ns)) {
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
function coerce(val) {
|
|
292
|
+
if (val instanceof Error) {
|
|
293
|
+
return val.stack || val.message;
|
|
294
|
+
}
|
|
295
|
+
return val;
|
|
296
|
+
}
|
|
297
|
+
function destroy() {
|
|
298
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
299
|
+
}
|
|
300
|
+
createDebug.enable(createDebug.load());
|
|
301
|
+
return createDebug;
|
|
302
|
+
}
|
|
303
|
+
module.exports = setup;
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// ../../node_modules/debug/src/browser.js
|
|
307
|
+
var require_browser = __commonJS((exports, module) => {
|
|
308
|
+
exports.formatArgs = formatArgs;
|
|
309
|
+
exports.save = save;
|
|
310
|
+
exports.load = load;
|
|
311
|
+
exports.useColors = useColors;
|
|
312
|
+
exports.storage = localstorage();
|
|
313
|
+
exports.destroy = (() => {
|
|
314
|
+
let warned = false;
|
|
315
|
+
return () => {
|
|
316
|
+
if (!warned) {
|
|
317
|
+
warned = true;
|
|
318
|
+
console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
})();
|
|
322
|
+
exports.colors = [
|
|
323
|
+
"#0000CC",
|
|
324
|
+
"#0000FF",
|
|
325
|
+
"#0033CC",
|
|
326
|
+
"#0033FF",
|
|
327
|
+
"#0066CC",
|
|
328
|
+
"#0066FF",
|
|
329
|
+
"#0099CC",
|
|
330
|
+
"#0099FF",
|
|
331
|
+
"#00CC00",
|
|
332
|
+
"#00CC33",
|
|
333
|
+
"#00CC66",
|
|
334
|
+
"#00CC99",
|
|
335
|
+
"#00CCCC",
|
|
336
|
+
"#00CCFF",
|
|
337
|
+
"#3300CC",
|
|
338
|
+
"#3300FF",
|
|
339
|
+
"#3333CC",
|
|
340
|
+
"#3333FF",
|
|
341
|
+
"#3366CC",
|
|
342
|
+
"#3366FF",
|
|
343
|
+
"#3399CC",
|
|
344
|
+
"#3399FF",
|
|
345
|
+
"#33CC00",
|
|
346
|
+
"#33CC33",
|
|
347
|
+
"#33CC66",
|
|
348
|
+
"#33CC99",
|
|
349
|
+
"#33CCCC",
|
|
350
|
+
"#33CCFF",
|
|
351
|
+
"#6600CC",
|
|
352
|
+
"#6600FF",
|
|
353
|
+
"#6633CC",
|
|
354
|
+
"#6633FF",
|
|
355
|
+
"#66CC00",
|
|
356
|
+
"#66CC33",
|
|
357
|
+
"#9900CC",
|
|
358
|
+
"#9900FF",
|
|
359
|
+
"#9933CC",
|
|
360
|
+
"#9933FF",
|
|
361
|
+
"#99CC00",
|
|
362
|
+
"#99CC33",
|
|
363
|
+
"#CC0000",
|
|
364
|
+
"#CC0033",
|
|
365
|
+
"#CC0066",
|
|
366
|
+
"#CC0099",
|
|
367
|
+
"#CC00CC",
|
|
368
|
+
"#CC00FF",
|
|
369
|
+
"#CC3300",
|
|
370
|
+
"#CC3333",
|
|
371
|
+
"#CC3366",
|
|
372
|
+
"#CC3399",
|
|
373
|
+
"#CC33CC",
|
|
374
|
+
"#CC33FF",
|
|
375
|
+
"#CC6600",
|
|
376
|
+
"#CC6633",
|
|
377
|
+
"#CC9900",
|
|
378
|
+
"#CC9933",
|
|
379
|
+
"#CCCC00",
|
|
380
|
+
"#CCCC33",
|
|
381
|
+
"#FF0000",
|
|
382
|
+
"#FF0033",
|
|
383
|
+
"#FF0066",
|
|
384
|
+
"#FF0099",
|
|
385
|
+
"#FF00CC",
|
|
386
|
+
"#FF00FF",
|
|
387
|
+
"#FF3300",
|
|
388
|
+
"#FF3333",
|
|
389
|
+
"#FF3366",
|
|
390
|
+
"#FF3399",
|
|
391
|
+
"#FF33CC",
|
|
392
|
+
"#FF33FF",
|
|
393
|
+
"#FF6600",
|
|
394
|
+
"#FF6633",
|
|
395
|
+
"#FF9900",
|
|
396
|
+
"#FF9933",
|
|
397
|
+
"#FFCC00",
|
|
398
|
+
"#FFCC33"
|
|
399
|
+
];
|
|
400
|
+
function useColors() {
|
|
401
|
+
if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs)) {
|
|
402
|
+
return true;
|
|
403
|
+
}
|
|
404
|
+
if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
405
|
+
return false;
|
|
406
|
+
}
|
|
407
|
+
let m;
|
|
408
|
+
return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
|
|
409
|
+
}
|
|
410
|
+
function formatArgs(args) {
|
|
411
|
+
args[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + args[0] + (this.useColors ? "%c " : " ") + "+" + module.exports.humanize(this.diff);
|
|
412
|
+
if (!this.useColors) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
const c = "color: " + this.color;
|
|
416
|
+
args.splice(1, 0, c, "color: inherit");
|
|
417
|
+
let index = 0;
|
|
418
|
+
let lastC = 0;
|
|
419
|
+
args[0].replace(/%[a-zA-Z%]/g, (match) => {
|
|
420
|
+
if (match === "%%") {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
index++;
|
|
424
|
+
if (match === "%c") {
|
|
425
|
+
lastC = index;
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
args.splice(lastC, 0, c);
|
|
429
|
+
}
|
|
430
|
+
exports.log = console.debug || console.log || (() => {});
|
|
431
|
+
function save(namespaces) {
|
|
432
|
+
try {
|
|
433
|
+
if (namespaces) {
|
|
434
|
+
exports.storage.setItem("debug", namespaces);
|
|
435
|
+
} else {
|
|
436
|
+
exports.storage.removeItem("debug");
|
|
437
|
+
}
|
|
438
|
+
} catch (error) {}
|
|
439
|
+
}
|
|
440
|
+
function load() {
|
|
441
|
+
let r;
|
|
442
|
+
try {
|
|
443
|
+
r = exports.storage.getItem("debug") || exports.storage.getItem("DEBUG");
|
|
444
|
+
} catch (error) {}
|
|
445
|
+
if (!r && typeof process !== "undefined" && "env" in process) {
|
|
446
|
+
r = process.env.DEBUG;
|
|
447
|
+
}
|
|
448
|
+
return r;
|
|
449
|
+
}
|
|
450
|
+
function localstorage() {
|
|
451
|
+
try {
|
|
452
|
+
return localStorage;
|
|
453
|
+
} catch (error) {}
|
|
454
|
+
}
|
|
455
|
+
module.exports = require_common()(exports);
|
|
456
|
+
var { formatters } = module.exports;
|
|
457
|
+
formatters.j = function(v) {
|
|
458
|
+
try {
|
|
459
|
+
return JSON.stringify(v);
|
|
460
|
+
} catch (error) {
|
|
461
|
+
return "[UnexpectedJSONParseError]: " + error.message;
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
// ../../node_modules/has-flag/index.js
|
|
467
|
+
var require_has_flag = __commonJS((exports, module) => {
|
|
468
|
+
module.exports = (flag, argv = process.argv) => {
|
|
469
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
470
|
+
const position = argv.indexOf(prefix + flag);
|
|
471
|
+
const terminatorPosition = argv.indexOf("--");
|
|
472
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
473
|
+
};
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
// ../../node_modules/supports-color/index.js
|
|
477
|
+
var require_supports_color = __commonJS((exports, module) => {
|
|
478
|
+
var os = __require("os");
|
|
479
|
+
var tty = __require("tty");
|
|
480
|
+
var hasFlag = require_has_flag();
|
|
481
|
+
var { env } = process;
|
|
482
|
+
var flagForceColor;
|
|
483
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
484
|
+
flagForceColor = 0;
|
|
485
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
486
|
+
flagForceColor = 1;
|
|
487
|
+
}
|
|
488
|
+
function envForceColor() {
|
|
489
|
+
if ("FORCE_COLOR" in env) {
|
|
490
|
+
if (env.FORCE_COLOR === "true") {
|
|
491
|
+
return 1;
|
|
492
|
+
}
|
|
493
|
+
if (env.FORCE_COLOR === "false") {
|
|
494
|
+
return 0;
|
|
495
|
+
}
|
|
496
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
function translateLevel(level) {
|
|
500
|
+
if (level === 0) {
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
return {
|
|
504
|
+
level,
|
|
505
|
+
hasBasic: true,
|
|
506
|
+
has256: level >= 2,
|
|
507
|
+
has16m: level >= 3
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
function supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
511
|
+
const noFlagForceColor = envForceColor();
|
|
512
|
+
if (noFlagForceColor !== undefined) {
|
|
513
|
+
flagForceColor = noFlagForceColor;
|
|
514
|
+
}
|
|
515
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
516
|
+
if (forceColor === 0) {
|
|
517
|
+
return 0;
|
|
518
|
+
}
|
|
519
|
+
if (sniffFlags) {
|
|
520
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
521
|
+
return 3;
|
|
522
|
+
}
|
|
523
|
+
if (hasFlag("color=256")) {
|
|
524
|
+
return 2;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
if (haveStream && !streamIsTTY && forceColor === undefined) {
|
|
528
|
+
return 0;
|
|
529
|
+
}
|
|
530
|
+
const min = forceColor || 0;
|
|
531
|
+
if (env.TERM === "dumb") {
|
|
532
|
+
return min;
|
|
533
|
+
}
|
|
534
|
+
if (process.platform === "win32") {
|
|
535
|
+
const osRelease = os.release().split(".");
|
|
536
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
537
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
538
|
+
}
|
|
539
|
+
return 1;
|
|
540
|
+
}
|
|
541
|
+
if ("CI" in env) {
|
|
542
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") {
|
|
543
|
+
return 1;
|
|
544
|
+
}
|
|
545
|
+
return min;
|
|
546
|
+
}
|
|
547
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
548
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
549
|
+
}
|
|
550
|
+
if (env.COLORTERM === "truecolor") {
|
|
551
|
+
return 3;
|
|
552
|
+
}
|
|
553
|
+
if ("TERM_PROGRAM" in env) {
|
|
554
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
555
|
+
switch (env.TERM_PROGRAM) {
|
|
556
|
+
case "iTerm.app":
|
|
557
|
+
return version >= 3 ? 3 : 2;
|
|
558
|
+
case "Apple_Terminal":
|
|
559
|
+
return 2;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
563
|
+
return 2;
|
|
564
|
+
}
|
|
565
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
566
|
+
return 1;
|
|
567
|
+
}
|
|
568
|
+
if ("COLORTERM" in env) {
|
|
569
|
+
return 1;
|
|
570
|
+
}
|
|
571
|
+
return min;
|
|
572
|
+
}
|
|
573
|
+
function getSupportLevel(stream, options = {}) {
|
|
574
|
+
const level = supportsColor(stream, {
|
|
575
|
+
streamIsTTY: stream && stream.isTTY,
|
|
576
|
+
...options
|
|
577
|
+
});
|
|
578
|
+
return translateLevel(level);
|
|
579
|
+
}
|
|
580
|
+
module.exports = {
|
|
581
|
+
supportsColor: getSupportLevel,
|
|
582
|
+
stdout: getSupportLevel({ isTTY: tty.isatty(1) }),
|
|
583
|
+
stderr: getSupportLevel({ isTTY: tty.isatty(2) })
|
|
584
|
+
};
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
// ../../node_modules/debug/src/node.js
|
|
588
|
+
var require_node = __commonJS((exports, module) => {
|
|
589
|
+
var tty = __require("tty");
|
|
590
|
+
var util = __require("util");
|
|
591
|
+
exports.init = init;
|
|
592
|
+
exports.log = log;
|
|
593
|
+
exports.formatArgs = formatArgs;
|
|
594
|
+
exports.save = save;
|
|
595
|
+
exports.load = load;
|
|
596
|
+
exports.useColors = useColors;
|
|
597
|
+
exports.destroy = util.deprecate(() => {}, "Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
|
|
598
|
+
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
599
|
+
try {
|
|
600
|
+
const supportsColor = require_supports_color();
|
|
601
|
+
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
602
|
+
exports.colors = [
|
|
603
|
+
20,
|
|
604
|
+
21,
|
|
605
|
+
26,
|
|
606
|
+
27,
|
|
607
|
+
32,
|
|
608
|
+
33,
|
|
609
|
+
38,
|
|
610
|
+
39,
|
|
611
|
+
40,
|
|
612
|
+
41,
|
|
613
|
+
42,
|
|
614
|
+
43,
|
|
615
|
+
44,
|
|
616
|
+
45,
|
|
617
|
+
56,
|
|
618
|
+
57,
|
|
619
|
+
62,
|
|
620
|
+
63,
|
|
621
|
+
68,
|
|
622
|
+
69,
|
|
623
|
+
74,
|
|
624
|
+
75,
|
|
625
|
+
76,
|
|
626
|
+
77,
|
|
627
|
+
78,
|
|
628
|
+
79,
|
|
629
|
+
80,
|
|
630
|
+
81,
|
|
631
|
+
92,
|
|
632
|
+
93,
|
|
633
|
+
98,
|
|
634
|
+
99,
|
|
635
|
+
112,
|
|
636
|
+
113,
|
|
637
|
+
128,
|
|
638
|
+
129,
|
|
639
|
+
134,
|
|
640
|
+
135,
|
|
641
|
+
148,
|
|
642
|
+
149,
|
|
643
|
+
160,
|
|
644
|
+
161,
|
|
645
|
+
162,
|
|
646
|
+
163,
|
|
647
|
+
164,
|
|
648
|
+
165,
|
|
649
|
+
166,
|
|
650
|
+
167,
|
|
651
|
+
168,
|
|
652
|
+
169,
|
|
653
|
+
170,
|
|
654
|
+
171,
|
|
655
|
+
172,
|
|
656
|
+
173,
|
|
657
|
+
178,
|
|
658
|
+
179,
|
|
659
|
+
184,
|
|
660
|
+
185,
|
|
661
|
+
196,
|
|
662
|
+
197,
|
|
663
|
+
198,
|
|
664
|
+
199,
|
|
665
|
+
200,
|
|
666
|
+
201,
|
|
667
|
+
202,
|
|
668
|
+
203,
|
|
669
|
+
204,
|
|
670
|
+
205,
|
|
671
|
+
206,
|
|
672
|
+
207,
|
|
673
|
+
208,
|
|
674
|
+
209,
|
|
675
|
+
214,
|
|
676
|
+
215,
|
|
677
|
+
220,
|
|
678
|
+
221
|
|
679
|
+
];
|
|
680
|
+
}
|
|
681
|
+
} catch (error) {}
|
|
682
|
+
exports.inspectOpts = Object.keys(process.env).filter((key) => {
|
|
683
|
+
return /^debug_/i.test(key);
|
|
684
|
+
}).reduce((obj, key) => {
|
|
685
|
+
const prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, (_, k) => {
|
|
686
|
+
return k.toUpperCase();
|
|
687
|
+
});
|
|
688
|
+
let val = process.env[key];
|
|
689
|
+
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
690
|
+
val = true;
|
|
691
|
+
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
692
|
+
val = false;
|
|
693
|
+
} else if (val === "null") {
|
|
694
|
+
val = null;
|
|
695
|
+
} else {
|
|
696
|
+
val = Number(val);
|
|
697
|
+
}
|
|
698
|
+
obj[prop] = val;
|
|
699
|
+
return obj;
|
|
700
|
+
}, {});
|
|
701
|
+
function useColors() {
|
|
702
|
+
return "colors" in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
|
|
703
|
+
}
|
|
704
|
+
function formatArgs(args) {
|
|
705
|
+
const { namespace: name, useColors: useColors2 } = this;
|
|
706
|
+
if (useColors2) {
|
|
707
|
+
const c = this.color;
|
|
708
|
+
const colorCode = "\x1B[3" + (c < 8 ? c : "8;5;" + c);
|
|
709
|
+
const prefix = ` ${colorCode};1m${name} \x1B[0m`;
|
|
710
|
+
args[0] = prefix + args[0].split(`
|
|
711
|
+
`).join(`
|
|
712
|
+
` + prefix);
|
|
713
|
+
args.push(colorCode + "m+" + module.exports.humanize(this.diff) + "\x1B[0m");
|
|
714
|
+
} else {
|
|
715
|
+
args[0] = getDate() + name + " " + args[0];
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
function getDate() {
|
|
719
|
+
if (exports.inspectOpts.hideDate) {
|
|
720
|
+
return "";
|
|
721
|
+
}
|
|
722
|
+
return new Date().toISOString() + " ";
|
|
723
|
+
}
|
|
724
|
+
function log(...args) {
|
|
725
|
+
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + `
|
|
726
|
+
`);
|
|
727
|
+
}
|
|
728
|
+
function save(namespaces) {
|
|
729
|
+
if (namespaces) {
|
|
730
|
+
process.env.DEBUG = namespaces;
|
|
731
|
+
} else {
|
|
732
|
+
delete process.env.DEBUG;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
function load() {
|
|
736
|
+
return process.env.DEBUG;
|
|
737
|
+
}
|
|
738
|
+
function init(debug) {
|
|
739
|
+
debug.inspectOpts = {};
|
|
740
|
+
const keys = Object.keys(exports.inspectOpts);
|
|
741
|
+
for (let i = 0;i < keys.length; i++) {
|
|
742
|
+
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
module.exports = require_common()(exports);
|
|
746
|
+
var { formatters } = module.exports;
|
|
747
|
+
formatters.o = function(v) {
|
|
748
|
+
this.inspectOpts.colors = this.useColors;
|
|
749
|
+
return util.inspect(v, this.inspectOpts).split(`
|
|
750
|
+
`).map((str) => str.trim()).join(" ");
|
|
751
|
+
};
|
|
752
|
+
formatters.O = function(v) {
|
|
753
|
+
this.inspectOpts.colors = this.useColors;
|
|
754
|
+
return util.inspect(v, this.inspectOpts);
|
|
755
|
+
};
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
// ../../node_modules/debug/src/index.js
|
|
759
|
+
var require_src = __commonJS((exports, module) => {
|
|
760
|
+
if (typeof process === "undefined" || process.type === "renderer" || false || process.__nwjs) {
|
|
761
|
+
module.exports = require_browser();
|
|
762
|
+
} else {
|
|
763
|
+
module.exports = require_node();
|
|
764
|
+
}
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
// src/index.js
|
|
768
|
+
var import_debug = __toESM(require_src(), 1);
|
|
769
|
+
import events from "node:events";
|
|
770
|
+
|
|
771
|
+
// src/as-emitter.js
|
|
772
|
+
var EVENT_INCOMING = "incoming";
|
|
773
|
+
var EVENT_ERROR = "error";
|
|
774
|
+
|
|
775
|
+
class ASEmitter {
|
|
776
|
+
constructor(events, server) {
|
|
777
|
+
this.server = server;
|
|
778
|
+
this.events = events;
|
|
779
|
+
}
|
|
780
|
+
emitEvent(code, asObject) {
|
|
781
|
+
if (typeof asObject === "object" && !asObject.published) {
|
|
782
|
+
asObject.published = `${Date.now()}`;
|
|
783
|
+
}
|
|
784
|
+
this.events.emit(code, asObject);
|
|
785
|
+
}
|
|
786
|
+
__generalError(nick, content) {
|
|
787
|
+
return {
|
|
788
|
+
context: "irc",
|
|
789
|
+
type: "update",
|
|
790
|
+
actor: {
|
|
791
|
+
type: "person",
|
|
792
|
+
id: `${nick}@${this.server}`,
|
|
793
|
+
name: nick
|
|
794
|
+
},
|
|
795
|
+
target: {
|
|
796
|
+
type: "service",
|
|
797
|
+
id: this.server
|
|
798
|
+
},
|
|
799
|
+
error: content
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
presence(nick, role, channel) {
|
|
803
|
+
this.emitEvent(EVENT_INCOMING, {
|
|
804
|
+
context: "irc",
|
|
805
|
+
type: "update",
|
|
806
|
+
actor: {
|
|
807
|
+
type: "person",
|
|
808
|
+
id: `${nick}@${this.server}`,
|
|
809
|
+
name: nick
|
|
810
|
+
},
|
|
811
|
+
target: {
|
|
812
|
+
type: "room",
|
|
813
|
+
id: `${this.server}/${channel}`,
|
|
814
|
+
name: channel
|
|
815
|
+
},
|
|
816
|
+
object: {
|
|
817
|
+
type: "presence",
|
|
818
|
+
role
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
channelError(channel, nick, content) {
|
|
823
|
+
this.emitEvent(EVENT_ERROR, {
|
|
824
|
+
context: "irc",
|
|
825
|
+
type: "update",
|
|
826
|
+
actor: {
|
|
827
|
+
type: "person",
|
|
828
|
+
id: `${nick}@${this.server}`
|
|
829
|
+
},
|
|
830
|
+
target: {
|
|
831
|
+
type: "room",
|
|
832
|
+
id: `${this.server}/${channel}`
|
|
833
|
+
},
|
|
834
|
+
error: content
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
nickError(nick, content) {
|
|
838
|
+
this.emitEvent(EVENT_ERROR, this.__generalError(nick, content));
|
|
839
|
+
}
|
|
840
|
+
notice(nick, content) {
|
|
841
|
+
this.emitEvent(EVENT_INCOMING, {
|
|
842
|
+
context: "irc",
|
|
843
|
+
type: "send",
|
|
844
|
+
actor: {
|
|
845
|
+
type: "service",
|
|
846
|
+
id: this.server
|
|
847
|
+
},
|
|
848
|
+
object: {
|
|
849
|
+
type: "message",
|
|
850
|
+
content
|
|
851
|
+
},
|
|
852
|
+
target: {
|
|
853
|
+
type: "person",
|
|
854
|
+
id: `${nick}@${this.server}`,
|
|
855
|
+
name: nick
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
serviceError(nick, content) {
|
|
860
|
+
this.emitEvent(EVENT_ERROR, this.__generalError(nick, content));
|
|
861
|
+
}
|
|
862
|
+
joinError(nick) {
|
|
863
|
+
this.emitEvent(EVENT_ERROR, {
|
|
864
|
+
context: "irc",
|
|
865
|
+
type: "join",
|
|
866
|
+
actor: {
|
|
867
|
+
id: this.server,
|
|
868
|
+
type: "service"
|
|
869
|
+
},
|
|
870
|
+
error: `no such channel ${nick}`,
|
|
871
|
+
target: {
|
|
872
|
+
id: `${nick}@${this.server}`,
|
|
873
|
+
type: "person"
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
topicChange(channel, nick, content) {
|
|
878
|
+
this.emitEvent(EVENT_INCOMING, {
|
|
879
|
+
context: "irc",
|
|
880
|
+
type: "update",
|
|
881
|
+
actor: {
|
|
882
|
+
type: "person",
|
|
883
|
+
id: `${nick}@${this.server}`,
|
|
884
|
+
name: nick
|
|
885
|
+
},
|
|
886
|
+
target: {
|
|
887
|
+
type: "room",
|
|
888
|
+
id: `${this.server}/${channel}`,
|
|
889
|
+
name: channel
|
|
890
|
+
},
|
|
891
|
+
object: {
|
|
892
|
+
type: "topic",
|
|
893
|
+
content
|
|
894
|
+
}
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
joinRoom(channel, nick) {
|
|
898
|
+
this.emitEvent(EVENT_INCOMING, {
|
|
899
|
+
context: "irc",
|
|
900
|
+
type: "join",
|
|
901
|
+
actor: {
|
|
902
|
+
type: "person",
|
|
903
|
+
id: `${nick}@${this.server}`,
|
|
904
|
+
name: nick
|
|
905
|
+
},
|
|
906
|
+
target: {
|
|
907
|
+
type: "room",
|
|
908
|
+
id: `${this.server}/${channel}`,
|
|
909
|
+
name: channel
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
userQuit(nick) {
|
|
914
|
+
this.emitEvent(EVENT_INCOMING, {
|
|
915
|
+
context: "irc",
|
|
916
|
+
type: "leave",
|
|
917
|
+
actor: {
|
|
918
|
+
type: "person",
|
|
919
|
+
id: `${nick}@${this.server}`,
|
|
920
|
+
name: nick
|
|
921
|
+
},
|
|
922
|
+
target: {
|
|
923
|
+
type: "service",
|
|
924
|
+
id: this.server
|
|
925
|
+
},
|
|
926
|
+
object: {
|
|
927
|
+
type: "message",
|
|
928
|
+
content: "user has quit"
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
userPart(channel, nick) {
|
|
933
|
+
this.emitEvent(EVENT_INCOMING, {
|
|
934
|
+
context: "irc",
|
|
935
|
+
type: "leave",
|
|
936
|
+
actor: {
|
|
937
|
+
type: "person",
|
|
938
|
+
id: `${nick}@${this.server}`,
|
|
939
|
+
name: nick
|
|
940
|
+
},
|
|
941
|
+
target: {
|
|
942
|
+
type: "room",
|
|
943
|
+
id: `${this.server}/${channel}`,
|
|
944
|
+
name: channel
|
|
945
|
+
},
|
|
946
|
+
object: {
|
|
947
|
+
type: "message",
|
|
948
|
+
content: "user has left the channel"
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
privMsg(nick, target, content) {
|
|
953
|
+
let type;
|
|
954
|
+
let message;
|
|
955
|
+
if (content.startsWith("+\x01ACTION ")) {
|
|
956
|
+
type = "me";
|
|
957
|
+
message = content.split(/^\+\u0001ACTION\s+/)[1].split(/\u0001$/)[0];
|
|
958
|
+
} else {
|
|
959
|
+
type = "message";
|
|
960
|
+
message = content;
|
|
961
|
+
}
|
|
962
|
+
this.emitEvent(EVENT_INCOMING, {
|
|
963
|
+
context: "irc",
|
|
964
|
+
type: "send",
|
|
965
|
+
actor: {
|
|
966
|
+
type: "person",
|
|
967
|
+
id: `${nick}@${this.server}`,
|
|
968
|
+
name: nick
|
|
969
|
+
},
|
|
970
|
+
target: {
|
|
971
|
+
type: target.startsWith("#") ? "room" : "person",
|
|
972
|
+
id: `${this.server}/${target}`,
|
|
973
|
+
name: target
|
|
974
|
+
},
|
|
975
|
+
object: {
|
|
976
|
+
type,
|
|
977
|
+
content: message
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
role(type, nick, target, role, channel) {
|
|
982
|
+
this.emitEvent(EVENT_INCOMING, {
|
|
983
|
+
context: "irc",
|
|
984
|
+
type,
|
|
985
|
+
actor: {
|
|
986
|
+
type: "person",
|
|
987
|
+
id: `${nick}@${this.server}`,
|
|
988
|
+
name: nick
|
|
989
|
+
},
|
|
990
|
+
target: {
|
|
991
|
+
type: "person",
|
|
992
|
+
id: `${target}@${this.server}`,
|
|
993
|
+
name: target
|
|
994
|
+
},
|
|
995
|
+
object: {
|
|
996
|
+
type: "relationship",
|
|
997
|
+
relationship: "role",
|
|
998
|
+
subject: {
|
|
999
|
+
type: "presence",
|
|
1000
|
+
role
|
|
1001
|
+
},
|
|
1002
|
+
object: {
|
|
1003
|
+
type: "room",
|
|
1004
|
+
id: `${this.server}/${channel}`,
|
|
1005
|
+
name: channel
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
});
|
|
1009
|
+
}
|
|
1010
|
+
nickChange(nick, content) {
|
|
1011
|
+
this.emitEvent(EVENT_INCOMING, {
|
|
1012
|
+
context: "irc",
|
|
1013
|
+
type: "update",
|
|
1014
|
+
actor: {
|
|
1015
|
+
type: "person",
|
|
1016
|
+
id: `${nick}@${this.server}`,
|
|
1017
|
+
name: nick
|
|
1018
|
+
},
|
|
1019
|
+
target: {
|
|
1020
|
+
type: "person",
|
|
1021
|
+
id: `${content}@${this.server}`,
|
|
1022
|
+
name: content
|
|
1023
|
+
},
|
|
1024
|
+
object: {
|
|
1025
|
+
type: "address"
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
// src/index.js
|
|
1032
|
+
var log = import_debug.default("irc2as");
|
|
1033
|
+
var EVENT_INCOMING2 = "incoming";
|
|
1034
|
+
var EVENT_PONG = "pong";
|
|
1035
|
+
var EVENT_PING = "ping";
|
|
1036
|
+
var EVENT_UNPROCESSED = "unprocessed";
|
|
1037
|
+
var ERR_BAD_NICK = "432";
|
|
1038
|
+
var ERR_CHAN_PRIVS = "482";
|
|
1039
|
+
var ERR_NICK_IN_USE = "433";
|
|
1040
|
+
var ERR_TEMP_UNAVAIL = "437";
|
|
1041
|
+
var ERR_NO_CHANNEL = "403";
|
|
1042
|
+
var ERR_NOT_INVITED = "471";
|
|
1043
|
+
var ERR_BADMODE = "472";
|
|
1044
|
+
var ERR_INVITE_ONLY = "473";
|
|
1045
|
+
var ERR_BANNED = "474";
|
|
1046
|
+
var ERR_BADKEY = "475";
|
|
1047
|
+
var ERR_BADMASK = "476";
|
|
1048
|
+
var ERR_NOCHANMODES = "477";
|
|
1049
|
+
var ERR_BANLISTFULL = "478";
|
|
1050
|
+
var JOIN = "JOIN";
|
|
1051
|
+
var MODE = "MODE";
|
|
1052
|
+
var MOTD = "372";
|
|
1053
|
+
var MOTD_END = "376";
|
|
1054
|
+
var NAMES = "353";
|
|
1055
|
+
var NICK = "NICK";
|
|
1056
|
+
var NOTICE = "NOTICE";
|
|
1057
|
+
var PART = "PART";
|
|
1058
|
+
var PING = "PING";
|
|
1059
|
+
var PONG = "PONG";
|
|
1060
|
+
var PRIVMSG = "PRIVMSG";
|
|
1061
|
+
var QUIT = "QUIT";
|
|
1062
|
+
var TOPIC_CHANGE = "TOPIC";
|
|
1063
|
+
var TOPIC_IS = "332";
|
|
1064
|
+
var TOPIC_SET_BY = "333";
|
|
1065
|
+
var WHO = "352";
|
|
1066
|
+
var WHO_OLD = "354";
|
|
1067
|
+
var ROLE = {
|
|
1068
|
+
"@": "owner",
|
|
1069
|
+
"%": "admin",
|
|
1070
|
+
"*": "participant"
|
|
1071
|
+
};
|
|
1072
|
+
var MODES = {
|
|
1073
|
+
o: "owner",
|
|
1074
|
+
h: "admin",
|
|
1075
|
+
v: "participant"
|
|
1076
|
+
};
|
|
1077
|
+
function getNickFromServer(server) {
|
|
1078
|
+
return server.split(/^:/)[1].split("!")[0];
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
class IrcToActivityStreams {
|
|
1082
|
+
constructor(cfg) {
|
|
1083
|
+
const config = cfg || {};
|
|
1084
|
+
this.server = config.server;
|
|
1085
|
+
this.events = new events.EventEmitter;
|
|
1086
|
+
this.__buffer = {};
|
|
1087
|
+
this.__buffer[NAMES] = {};
|
|
1088
|
+
}
|
|
1089
|
+
input(payload) {
|
|
1090
|
+
log(payload);
|
|
1091
|
+
if (typeof payload !== "string") {
|
|
1092
|
+
log("unable to process incoming message as it was not a string.");
|
|
1093
|
+
return false;
|
|
1094
|
+
}
|
|
1095
|
+
if (payload.length < 3) {
|
|
1096
|
+
log("unable to process incoming string, length smaller than 3.");
|
|
1097
|
+
return false;
|
|
1098
|
+
}
|
|
1099
|
+
const incoming = payload.trim();
|
|
1100
|
+
const [metadata, content] = incoming.split(" :");
|
|
1101
|
+
const [server, code, pos1, pos2, pos3, ...msg] = metadata.split(" ");
|
|
1102
|
+
const channel = typeof pos1 === "string" && pos1.startsWith("#") ? pos1 : typeof pos2 === "string" && pos2.startsWith("#") ? pos2 : typeof pos3 === "string" && pos3.startsWith("#") ? pos3 : undefined;
|
|
1103
|
+
if (metadata === PING) {
|
|
1104
|
+
this.events.emit(EVENT_PING, `${Date.now()}`);
|
|
1105
|
+
return true;
|
|
1106
|
+
}
|
|
1107
|
+
log(`[${code}] server: ${server} channel: ${channel} 1: ${pos1}, 2: ${pos2}, 3: ${pos3}. content: `, content);
|
|
1108
|
+
this.__processIRCCodes(code, server, channel, pos1, pos2, pos3, content, msg, incoming);
|
|
1109
|
+
}
|
|
1110
|
+
__processIRCCodes(code, server, channel, pos1, pos2, pos3, content, msg, incoming) {
|
|
1111
|
+
const ase = new ASEmitter(this.events, this.server);
|
|
1112
|
+
let nick;
|
|
1113
|
+
let type;
|
|
1114
|
+
let role;
|
|
1115
|
+
switch (code) {
|
|
1116
|
+
case ERR_CHAN_PRIVS:
|
|
1117
|
+
case ERR_NOT_INVITED:
|
|
1118
|
+
case ERR_BADMODE:
|
|
1119
|
+
case ERR_INVITE_ONLY:
|
|
1120
|
+
case ERR_BANNED:
|
|
1121
|
+
case ERR_BADKEY:
|
|
1122
|
+
case ERR_BADMASK:
|
|
1123
|
+
case ERR_NOCHANMODES:
|
|
1124
|
+
case ERR_BANLISTFULL:
|
|
1125
|
+
ase.channelError(channel, pos1, content);
|
|
1126
|
+
break;
|
|
1127
|
+
case ERR_NICK_IN_USE:
|
|
1128
|
+
case ERR_BAD_NICK:
|
|
1129
|
+
ase.serviceError(pos2, content);
|
|
1130
|
+
break;
|
|
1131
|
+
case ERR_NO_CHANNEL:
|
|
1132
|
+
ase.joinError(pos2);
|
|
1133
|
+
break;
|
|
1134
|
+
case ERR_TEMP_UNAVAIL:
|
|
1135
|
+
ase.nickError(pos2, content);
|
|
1136
|
+
break;
|
|
1137
|
+
case JOIN:
|
|
1138
|
+
ase.joinRoom(channel, getNickFromServer(server));
|
|
1139
|
+
break;
|
|
1140
|
+
case MODE: {
|
|
1141
|
+
const user_mode = pos2 || content;
|
|
1142
|
+
if (!channel) {
|
|
1143
|
+
break;
|
|
1144
|
+
}
|
|
1145
|
+
if (!pos3) {
|
|
1146
|
+
break;
|
|
1147
|
+
}
|
|
1148
|
+
role = MODES[user_mode[1]] || "member";
|
|
1149
|
+
type = "add";
|
|
1150
|
+
if (user_mode[0] === "-") {
|
|
1151
|
+
type = "remove";
|
|
1152
|
+
}
|
|
1153
|
+
ase.role(type, getNickFromServer(server), pos3, role, channel);
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1156
|
+
case MOTD:
|
|
1157
|
+
if (!this.__buffer[MOTD]) {
|
|
1158
|
+
this.__buffer[MOTD] = {
|
|
1159
|
+
context: "irc",
|
|
1160
|
+
type: "update",
|
|
1161
|
+
actor: {
|
|
1162
|
+
type: "service",
|
|
1163
|
+
id: this.server,
|
|
1164
|
+
name: this.server
|
|
1165
|
+
},
|
|
1166
|
+
object: {
|
|
1167
|
+
type: "topic",
|
|
1168
|
+
content
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
} else {
|
|
1172
|
+
this.__buffer[MOTD].object.content += ` ${content}`;
|
|
1173
|
+
}
|
|
1174
|
+
break;
|
|
1175
|
+
case MOTD_END:
|
|
1176
|
+
if (!this.__buffer[MOTD]) {
|
|
1177
|
+
break;
|
|
1178
|
+
}
|
|
1179
|
+
ase.emitEvent(EVENT_INCOMING2, this.__buffer[MOTD]);
|
|
1180
|
+
delete this.__buffer[MOTD];
|
|
1181
|
+
break;
|
|
1182
|
+
case NAMES:
|
|
1183
|
+
for (const entry of content.split(" ")) {
|
|
1184
|
+
role = "member";
|
|
1185
|
+
let username = entry;
|
|
1186
|
+
if (ROLE[entry[0]]) {
|
|
1187
|
+
username = entry.substr(1);
|
|
1188
|
+
role = ROLE[entry[0]];
|
|
1189
|
+
}
|
|
1190
|
+
ase.presence(username, role, channel);
|
|
1191
|
+
}
|
|
1192
|
+
break;
|
|
1193
|
+
case NICK:
|
|
1194
|
+
ase.nickChange(getNickFromServer(server), content);
|
|
1195
|
+
break;
|
|
1196
|
+
case NOTICE:
|
|
1197
|
+
ase.notice(pos1, content);
|
|
1198
|
+
break;
|
|
1199
|
+
case PART:
|
|
1200
|
+
ase.userPart(channel, getNickFromServer(server));
|
|
1201
|
+
break;
|
|
1202
|
+
case PONG:
|
|
1203
|
+
this.events.emit(EVENT_PONG, `${Date.now()}`);
|
|
1204
|
+
break;
|
|
1205
|
+
case PRIVMSG:
|
|
1206
|
+
ase.privMsg(getNickFromServer(server), pos1, content);
|
|
1207
|
+
break;
|
|
1208
|
+
case QUIT:
|
|
1209
|
+
ase.userQuit(getNickFromServer(server));
|
|
1210
|
+
break;
|
|
1211
|
+
case TOPIC_CHANGE:
|
|
1212
|
+
ase.topicChange(channel, getNickFromServer(server), content);
|
|
1213
|
+
break;
|
|
1214
|
+
case TOPIC_IS:
|
|
1215
|
+
this.__buffer[TOPIC_IS] = {
|
|
1216
|
+
context: "irc",
|
|
1217
|
+
type: "update",
|
|
1218
|
+
actor: undefined,
|
|
1219
|
+
target: {
|
|
1220
|
+
type: "room",
|
|
1221
|
+
id: `${this.server}/${channel}`,
|
|
1222
|
+
name: channel
|
|
1223
|
+
},
|
|
1224
|
+
object: {
|
|
1225
|
+
type: "topic",
|
|
1226
|
+
content
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
break;
|
|
1230
|
+
case TOPIC_SET_BY:
|
|
1231
|
+
if (!this.__buffer[TOPIC_IS]) {
|
|
1232
|
+
break;
|
|
1233
|
+
}
|
|
1234
|
+
nick = pos3.split("!")[0];
|
|
1235
|
+
this.__buffer[TOPIC_IS].actor = {
|
|
1236
|
+
type: "person",
|
|
1237
|
+
id: `${nick}@${this.server}`,
|
|
1238
|
+
name: nick
|
|
1239
|
+
};
|
|
1240
|
+
this.__buffer[TOPIC_IS].published = msg[0];
|
|
1241
|
+
ase.emitEvent(EVENT_INCOMING2, this.__buffer[TOPIC_IS]);
|
|
1242
|
+
delete this.__buffer[TOPIC_IS];
|
|
1243
|
+
break;
|
|
1244
|
+
case WHO:
|
|
1245
|
+
case WHO_OLD:
|
|
1246
|
+
nick = msg[3].length <= 2 ? msg[2] : msg[3];
|
|
1247
|
+
if (nick === "undefined") {
|
|
1248
|
+
break;
|
|
1249
|
+
}
|
|
1250
|
+
role = MODES[pos2[1]] || "member";
|
|
1251
|
+
ase.presence(nick, role, channel);
|
|
1252
|
+
break;
|
|
1253
|
+
default:
|
|
1254
|
+
this.events.emit(EVENT_UNPROCESSED, incoming);
|
|
1255
|
+
break;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
export {
|
|
1260
|
+
IrcToActivityStreams
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1263
|
+
//# debugId=EF561318CD0E9A7D64756E2164756E21
|