@kartik.doda/openclaw-plugin-test 1.0.3 → 1.0.4
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/client/ddp.js +3405 -78
- package/dist/client/ddp.js.map +7 -1
- package/package.json +5 -7
package/dist/client/ddp.js
CHANGED
|
@@ -1,86 +1,3413 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
8
|
+
try {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
} catch (e) {
|
|
11
|
+
throw mod = 0, e;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
|
|
31
|
+
// node_modules/.pnpm/strict-uri-encode@2.0.0/node_modules/strict-uri-encode/index.js
|
|
32
|
+
var require_strict_uri_encode = __commonJS({
|
|
33
|
+
"node_modules/.pnpm/strict-uri-encode@2.0.0/node_modules/strict-uri-encode/index.js"(exports, module) {
|
|
34
|
+
"use strict";
|
|
35
|
+
module.exports = (str) => encodeURIComponent(str).replace(/[!'()*]/g, (x) => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// node_modules/.pnpm/decode-uri-component@0.2.2/node_modules/decode-uri-component/index.js
|
|
40
|
+
var require_decode_uri_component = __commonJS({
|
|
41
|
+
"node_modules/.pnpm/decode-uri-component@0.2.2/node_modules/decode-uri-component/index.js"(exports, module) {
|
|
42
|
+
"use strict";
|
|
43
|
+
var token = "%[a-f0-9]{2}";
|
|
44
|
+
var singleMatcher = new RegExp("(" + token + ")|([^%]+?)", "gi");
|
|
45
|
+
var multiMatcher = new RegExp("(" + token + ")+", "gi");
|
|
46
|
+
function decodeComponents(components, split) {
|
|
47
|
+
try {
|
|
48
|
+
return [decodeURIComponent(components.join(""))];
|
|
49
|
+
} catch (err) {
|
|
50
|
+
}
|
|
51
|
+
if (components.length === 1) {
|
|
52
|
+
return components;
|
|
53
|
+
}
|
|
54
|
+
split = split || 1;
|
|
55
|
+
var left = components.slice(0, split);
|
|
56
|
+
var right = components.slice(split);
|
|
57
|
+
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
|
|
58
|
+
}
|
|
59
|
+
function decode(input) {
|
|
60
|
+
try {
|
|
61
|
+
return decodeURIComponent(input);
|
|
62
|
+
} catch (err) {
|
|
63
|
+
var tokens = input.match(singleMatcher) || [];
|
|
64
|
+
for (var i = 1; i < tokens.length; i++) {
|
|
65
|
+
input = decodeComponents(tokens, i).join("");
|
|
66
|
+
tokens = input.match(singleMatcher) || [];
|
|
67
|
+
}
|
|
68
|
+
return input;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function customDecodeURIComponent(input) {
|
|
72
|
+
var replaceMap = {
|
|
73
|
+
"%FE%FF": "\uFFFD\uFFFD",
|
|
74
|
+
"%FF%FE": "\uFFFD\uFFFD"
|
|
75
|
+
};
|
|
76
|
+
var match = multiMatcher.exec(input);
|
|
77
|
+
while (match) {
|
|
48
78
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
79
|
+
replaceMap[match[0]] = decodeURIComponent(match[0]);
|
|
80
|
+
} catch (err) {
|
|
81
|
+
var result = decode(match[0]);
|
|
82
|
+
if (result !== match[0]) {
|
|
83
|
+
replaceMap[match[0]] = result;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
match = multiMatcher.exec(input);
|
|
87
|
+
}
|
|
88
|
+
replaceMap["%C2"] = "\uFFFD";
|
|
89
|
+
var entries = Object.keys(replaceMap);
|
|
90
|
+
for (var i = 0; i < entries.length; i++) {
|
|
91
|
+
var key = entries[i];
|
|
92
|
+
input = input.replace(new RegExp(key, "g"), replaceMap[key]);
|
|
93
|
+
}
|
|
94
|
+
return input;
|
|
95
|
+
}
|
|
96
|
+
module.exports = function(encodedURI) {
|
|
97
|
+
if (typeof encodedURI !== "string") {
|
|
98
|
+
throw new TypeError("Expected `encodedURI` to be of type `string`, got `" + typeof encodedURI + "`");
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
encodedURI = encodedURI.replace(/\+/g, " ");
|
|
102
|
+
return decodeURIComponent(encodedURI);
|
|
103
|
+
} catch (err) {
|
|
104
|
+
return customDecodeURIComponent(encodedURI);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
// node_modules/.pnpm/split-on-first@1.1.0/node_modules/split-on-first/index.js
|
|
111
|
+
var require_split_on_first = __commonJS({
|
|
112
|
+
"node_modules/.pnpm/split-on-first@1.1.0/node_modules/split-on-first/index.js"(exports, module) {
|
|
113
|
+
"use strict";
|
|
114
|
+
module.exports = (string, separator) => {
|
|
115
|
+
if (!(typeof string === "string" && typeof separator === "string")) {
|
|
116
|
+
throw new TypeError("Expected the arguments to be of type `string`");
|
|
117
|
+
}
|
|
118
|
+
if (separator === "") {
|
|
119
|
+
return [string];
|
|
120
|
+
}
|
|
121
|
+
const separatorIndex = string.indexOf(separator);
|
|
122
|
+
if (separatorIndex === -1) {
|
|
123
|
+
return [string];
|
|
124
|
+
}
|
|
125
|
+
return [
|
|
126
|
+
string.slice(0, separatorIndex),
|
|
127
|
+
string.slice(separatorIndex + separator.length)
|
|
128
|
+
];
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// node_modules/.pnpm/filter-obj@1.1.0/node_modules/filter-obj/index.js
|
|
134
|
+
var require_filter_obj = __commonJS({
|
|
135
|
+
"node_modules/.pnpm/filter-obj@1.1.0/node_modules/filter-obj/index.js"(exports, module) {
|
|
136
|
+
"use strict";
|
|
137
|
+
module.exports = function(obj, predicate) {
|
|
138
|
+
var ret = {};
|
|
139
|
+
var keys = Object.keys(obj);
|
|
140
|
+
var isArr = Array.isArray(predicate);
|
|
141
|
+
for (var i = 0; i < keys.length; i++) {
|
|
142
|
+
var key = keys[i];
|
|
143
|
+
var val = obj[key];
|
|
144
|
+
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) {
|
|
145
|
+
ret[key] = val;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return ret;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// node_modules/.pnpm/query-string@7.1.3/node_modules/query-string/index.js
|
|
154
|
+
var require_query_string = __commonJS({
|
|
155
|
+
"node_modules/.pnpm/query-string@7.1.3/node_modules/query-string/index.js"(exports) {
|
|
156
|
+
"use strict";
|
|
157
|
+
var strictUriEncode = require_strict_uri_encode();
|
|
158
|
+
var decodeComponent = require_decode_uri_component();
|
|
159
|
+
var splitOnFirst = require_split_on_first();
|
|
160
|
+
var filterObject = require_filter_obj();
|
|
161
|
+
var isNullOrUndefined = (value) => value === null || value === void 0;
|
|
162
|
+
var encodeFragmentIdentifier = /* @__PURE__ */ Symbol("encodeFragmentIdentifier");
|
|
163
|
+
function encoderForArrayFormat(options) {
|
|
164
|
+
switch (options.arrayFormat) {
|
|
165
|
+
case "index":
|
|
166
|
+
return (key) => (result, value) => {
|
|
167
|
+
const index = result.length;
|
|
168
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
if (value === null) {
|
|
172
|
+
return [...result, [encode(key, options), "[", index, "]"].join("")];
|
|
173
|
+
}
|
|
174
|
+
return [
|
|
175
|
+
...result,
|
|
176
|
+
[encode(key, options), "[", encode(index, options), "]=", encode(value, options)].join("")
|
|
177
|
+
];
|
|
178
|
+
};
|
|
179
|
+
case "bracket":
|
|
180
|
+
return (key) => (result, value) => {
|
|
181
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
if (value === null) {
|
|
185
|
+
return [...result, [encode(key, options), "[]"].join("")];
|
|
186
|
+
}
|
|
187
|
+
return [...result, [encode(key, options), "[]=", encode(value, options)].join("")];
|
|
188
|
+
};
|
|
189
|
+
case "colon-list-separator":
|
|
190
|
+
return (key) => (result, value) => {
|
|
191
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
if (value === null) {
|
|
195
|
+
return [...result, [encode(key, options), ":list="].join("")];
|
|
196
|
+
}
|
|
197
|
+
return [...result, [encode(key, options), ":list=", encode(value, options)].join("")];
|
|
198
|
+
};
|
|
199
|
+
case "comma":
|
|
200
|
+
case "separator":
|
|
201
|
+
case "bracket-separator": {
|
|
202
|
+
const keyValueSep = options.arrayFormat === "bracket-separator" ? "[]=" : "=";
|
|
203
|
+
return (key) => (result, value) => {
|
|
204
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
value = value === null ? "" : value;
|
|
208
|
+
if (result.length === 0) {
|
|
209
|
+
return [[encode(key, options), keyValueSep, encode(value, options)].join("")];
|
|
210
|
+
}
|
|
211
|
+
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
default:
|
|
215
|
+
return (key) => (result, value) => {
|
|
216
|
+
if (value === void 0 || options.skipNull && value === null || options.skipEmptyString && value === "") {
|
|
217
|
+
return result;
|
|
218
|
+
}
|
|
219
|
+
if (value === null) {
|
|
220
|
+
return [...result, encode(key, options)];
|
|
221
|
+
}
|
|
222
|
+
return [...result, [encode(key, options), "=", encode(value, options)].join("")];
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function parserForArrayFormat(options) {
|
|
227
|
+
let result;
|
|
228
|
+
switch (options.arrayFormat) {
|
|
229
|
+
case "index":
|
|
230
|
+
return (key, value, accumulator) => {
|
|
231
|
+
result = /\[(\d*)\]$/.exec(key);
|
|
232
|
+
key = key.replace(/\[\d*\]$/, "");
|
|
233
|
+
if (!result) {
|
|
234
|
+
accumulator[key] = value;
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (accumulator[key] === void 0) {
|
|
238
|
+
accumulator[key] = {};
|
|
239
|
+
}
|
|
240
|
+
accumulator[key][result[1]] = value;
|
|
241
|
+
};
|
|
242
|
+
case "bracket":
|
|
243
|
+
return (key, value, accumulator) => {
|
|
244
|
+
result = /(\[\])$/.exec(key);
|
|
245
|
+
key = key.replace(/\[\]$/, "");
|
|
246
|
+
if (!result) {
|
|
247
|
+
accumulator[key] = value;
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (accumulator[key] === void 0) {
|
|
251
|
+
accumulator[key] = [value];
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
255
|
+
};
|
|
256
|
+
case "colon-list-separator":
|
|
257
|
+
return (key, value, accumulator) => {
|
|
258
|
+
result = /(:list)$/.exec(key);
|
|
259
|
+
key = key.replace(/:list$/, "");
|
|
260
|
+
if (!result) {
|
|
261
|
+
accumulator[key] = value;
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
if (accumulator[key] === void 0) {
|
|
265
|
+
accumulator[key] = [value];
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
269
|
+
};
|
|
270
|
+
case "comma":
|
|
271
|
+
case "separator":
|
|
272
|
+
return (key, value, accumulator) => {
|
|
273
|
+
const isArray = typeof value === "string" && value.includes(options.arrayFormatSeparator);
|
|
274
|
+
const isEncodedArray = typeof value === "string" && !isArray && decode(value, options).includes(options.arrayFormatSeparator);
|
|
275
|
+
value = isEncodedArray ? decode(value, options) : value;
|
|
276
|
+
const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map((item) => decode(item, options)) : value === null ? value : decode(value, options);
|
|
277
|
+
accumulator[key] = newValue;
|
|
278
|
+
};
|
|
279
|
+
case "bracket-separator":
|
|
280
|
+
return (key, value, accumulator) => {
|
|
281
|
+
const isArray = /(\[\])$/.test(key);
|
|
282
|
+
key = key.replace(/\[\]$/, "");
|
|
283
|
+
if (!isArray) {
|
|
284
|
+
accumulator[key] = value ? decode(value, options) : value;
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const arrayValue = value === null ? [] : value.split(options.arrayFormatSeparator).map((item) => decode(item, options));
|
|
288
|
+
if (accumulator[key] === void 0) {
|
|
289
|
+
accumulator[key] = arrayValue;
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
accumulator[key] = [].concat(accumulator[key], arrayValue);
|
|
293
|
+
};
|
|
294
|
+
default:
|
|
295
|
+
return (key, value, accumulator) => {
|
|
296
|
+
if (accumulator[key] === void 0) {
|
|
297
|
+
accumulator[key] = value;
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
accumulator[key] = [].concat(accumulator[key], value);
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
function validateArrayFormatSeparator(value) {
|
|
305
|
+
if (typeof value !== "string" || value.length !== 1) {
|
|
306
|
+
throw new TypeError("arrayFormatSeparator must be single character string");
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
function encode(value, options) {
|
|
310
|
+
if (options.encode) {
|
|
311
|
+
return options.strict ? strictUriEncode(value) : encodeURIComponent(value);
|
|
312
|
+
}
|
|
313
|
+
return value;
|
|
314
|
+
}
|
|
315
|
+
function decode(value, options) {
|
|
316
|
+
if (options.decode) {
|
|
317
|
+
return decodeComponent(value);
|
|
318
|
+
}
|
|
319
|
+
return value;
|
|
320
|
+
}
|
|
321
|
+
function keysSorter(input) {
|
|
322
|
+
if (Array.isArray(input)) {
|
|
323
|
+
return input.sort();
|
|
324
|
+
}
|
|
325
|
+
if (typeof input === "object") {
|
|
326
|
+
return keysSorter(Object.keys(input)).sort((a, b) => Number(a) - Number(b)).map((key) => input[key]);
|
|
327
|
+
}
|
|
328
|
+
return input;
|
|
329
|
+
}
|
|
330
|
+
function removeHash(input) {
|
|
331
|
+
const hashStart = input.indexOf("#");
|
|
332
|
+
if (hashStart !== -1) {
|
|
333
|
+
input = input.slice(0, hashStart);
|
|
334
|
+
}
|
|
335
|
+
return input;
|
|
336
|
+
}
|
|
337
|
+
function getHash(url) {
|
|
338
|
+
let hash = "";
|
|
339
|
+
const hashStart = url.indexOf("#");
|
|
340
|
+
if (hashStart !== -1) {
|
|
341
|
+
hash = url.slice(hashStart);
|
|
342
|
+
}
|
|
343
|
+
return hash;
|
|
344
|
+
}
|
|
345
|
+
function extract(input) {
|
|
346
|
+
input = removeHash(input);
|
|
347
|
+
const queryStart = input.indexOf("?");
|
|
348
|
+
if (queryStart === -1) {
|
|
349
|
+
return "";
|
|
350
|
+
}
|
|
351
|
+
return input.slice(queryStart + 1);
|
|
352
|
+
}
|
|
353
|
+
function parseValue(value, options) {
|
|
354
|
+
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === "string" && value.trim() !== "")) {
|
|
355
|
+
value = Number(value);
|
|
356
|
+
} else if (options.parseBooleans && value !== null && (value.toLowerCase() === "true" || value.toLowerCase() === "false")) {
|
|
357
|
+
value = value.toLowerCase() === "true";
|
|
358
|
+
}
|
|
359
|
+
return value;
|
|
360
|
+
}
|
|
361
|
+
function parse(query, options) {
|
|
362
|
+
options = Object.assign({
|
|
363
|
+
decode: true,
|
|
364
|
+
sort: true,
|
|
365
|
+
arrayFormat: "none",
|
|
366
|
+
arrayFormatSeparator: ",",
|
|
367
|
+
parseNumbers: false,
|
|
368
|
+
parseBooleans: false
|
|
369
|
+
}, options);
|
|
370
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
371
|
+
const formatter = parserForArrayFormat(options);
|
|
372
|
+
const ret = /* @__PURE__ */ Object.create(null);
|
|
373
|
+
if (typeof query !== "string") {
|
|
374
|
+
return ret;
|
|
375
|
+
}
|
|
376
|
+
query = query.trim().replace(/^[?#&]/, "");
|
|
377
|
+
if (!query) {
|
|
378
|
+
return ret;
|
|
379
|
+
}
|
|
380
|
+
for (const param of query.split("&")) {
|
|
381
|
+
if (param === "") {
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
let [key, value] = splitOnFirst(options.decode ? param.replace(/\+/g, " ") : param, "=");
|
|
385
|
+
value = value === void 0 ? null : ["comma", "separator", "bracket-separator"].includes(options.arrayFormat) ? value : decode(value, options);
|
|
386
|
+
formatter(decode(key, options), value, ret);
|
|
387
|
+
}
|
|
388
|
+
for (const key of Object.keys(ret)) {
|
|
389
|
+
const value = ret[key];
|
|
390
|
+
if (typeof value === "object" && value !== null) {
|
|
391
|
+
for (const k of Object.keys(value)) {
|
|
392
|
+
value[k] = parseValue(value[k], options);
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
ret[key] = parseValue(value, options);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
if (options.sort === false) {
|
|
399
|
+
return ret;
|
|
400
|
+
}
|
|
401
|
+
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
|
|
402
|
+
const value = ret[key];
|
|
403
|
+
if (Boolean(value) && typeof value === "object" && !Array.isArray(value)) {
|
|
404
|
+
result[key] = keysSorter(value);
|
|
405
|
+
} else {
|
|
406
|
+
result[key] = value;
|
|
407
|
+
}
|
|
408
|
+
return result;
|
|
409
|
+
}, /* @__PURE__ */ Object.create(null));
|
|
410
|
+
}
|
|
411
|
+
exports.extract = extract;
|
|
412
|
+
exports.parse = parse;
|
|
413
|
+
exports.stringify = (object, options) => {
|
|
414
|
+
if (!object) {
|
|
415
|
+
return "";
|
|
416
|
+
}
|
|
417
|
+
options = Object.assign({
|
|
418
|
+
encode: true,
|
|
419
|
+
strict: true,
|
|
420
|
+
arrayFormat: "none",
|
|
421
|
+
arrayFormatSeparator: ","
|
|
422
|
+
}, options);
|
|
423
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
|
424
|
+
const shouldFilter = (key) => options.skipNull && isNullOrUndefined(object[key]) || options.skipEmptyString && object[key] === "";
|
|
425
|
+
const formatter = encoderForArrayFormat(options);
|
|
426
|
+
const objectCopy = {};
|
|
427
|
+
for (const key of Object.keys(object)) {
|
|
428
|
+
if (!shouldFilter(key)) {
|
|
429
|
+
objectCopy[key] = object[key];
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const keys = Object.keys(objectCopy);
|
|
433
|
+
if (options.sort !== false) {
|
|
434
|
+
keys.sort(options.sort);
|
|
435
|
+
}
|
|
436
|
+
return keys.map((key) => {
|
|
437
|
+
const value = object[key];
|
|
438
|
+
if (value === void 0) {
|
|
439
|
+
return "";
|
|
440
|
+
}
|
|
441
|
+
if (value === null) {
|
|
442
|
+
return encode(key, options);
|
|
443
|
+
}
|
|
444
|
+
if (Array.isArray(value)) {
|
|
445
|
+
if (value.length === 0 && options.arrayFormat === "bracket-separator") {
|
|
446
|
+
return encode(key, options) + "[]";
|
|
447
|
+
}
|
|
448
|
+
return value.reduce(formatter(key), []).join("&");
|
|
449
|
+
}
|
|
450
|
+
return encode(key, options) + "=" + encode(value, options);
|
|
451
|
+
}).filter((x) => x.length > 0).join("&");
|
|
452
|
+
};
|
|
453
|
+
exports.parseUrl = (url, options) => {
|
|
454
|
+
options = Object.assign({
|
|
455
|
+
decode: true
|
|
456
|
+
}, options);
|
|
457
|
+
const [url_, hash] = splitOnFirst(url, "#");
|
|
458
|
+
return Object.assign(
|
|
459
|
+
{
|
|
460
|
+
url: url_.split("?")[0] || "",
|
|
461
|
+
query: parse(extract(url), options)
|
|
462
|
+
},
|
|
463
|
+
options && options.parseFragmentIdentifier && hash ? { fragmentIdentifier: decode(hash, options) } : {}
|
|
464
|
+
);
|
|
465
|
+
};
|
|
466
|
+
exports.stringifyUrl = (object, options) => {
|
|
467
|
+
options = Object.assign({
|
|
468
|
+
encode: true,
|
|
469
|
+
strict: true,
|
|
470
|
+
[encodeFragmentIdentifier]: true
|
|
471
|
+
}, options);
|
|
472
|
+
const url = removeHash(object.url).split("?")[0] || "";
|
|
473
|
+
const queryFromUrl = exports.extract(object.url);
|
|
474
|
+
const parsedQueryFromUrl = exports.parse(queryFromUrl, { sort: false });
|
|
475
|
+
const query = Object.assign(parsedQueryFromUrl, object.query);
|
|
476
|
+
let queryString = exports.stringify(query, options);
|
|
477
|
+
if (queryString) {
|
|
478
|
+
queryString = `?${queryString}`;
|
|
479
|
+
}
|
|
480
|
+
let hash = getHash(object.url);
|
|
481
|
+
if (object.fragmentIdentifier) {
|
|
482
|
+
hash = `#${options[encodeFragmentIdentifier] ? encode(object.fragmentIdentifier, options) : object.fragmentIdentifier}`;
|
|
483
|
+
}
|
|
484
|
+
return `${url}${queryString}${hash}`;
|
|
485
|
+
};
|
|
486
|
+
exports.pick = (input, filter, options) => {
|
|
487
|
+
options = Object.assign({
|
|
488
|
+
parseFragmentIdentifier: true,
|
|
489
|
+
[encodeFragmentIdentifier]: false
|
|
490
|
+
}, options);
|
|
491
|
+
const { url, query, fragmentIdentifier } = exports.parseUrl(input, options);
|
|
492
|
+
return exports.stringifyUrl({
|
|
493
|
+
url,
|
|
494
|
+
query: filterObject(query, filter),
|
|
495
|
+
fragmentIdentifier
|
|
496
|
+
}, options);
|
|
497
|
+
};
|
|
498
|
+
exports.exclude = (input, filter, options) => {
|
|
499
|
+
const exclusionFilter = Array.isArray(filter) ? (key) => !filter.includes(key) : (key, value) => !filter(key, value);
|
|
500
|
+
return exports.pick(input, exclusionFilter, options);
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
// node_modules/.pnpm/@rocket.chat+api-client@0.2.56_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/api-client/dist/errors.js
|
|
506
|
+
var require_errors = __commonJS({
|
|
507
|
+
"node_modules/.pnpm/@rocket.chat+api-client@0.2.56_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/api-client/dist/errors.js"(exports) {
|
|
508
|
+
"use strict";
|
|
509
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
510
|
+
exports.hasRequiredTwoFactorMethod = exports.isTwoFactorMethod = exports.isTotpInvalidError = exports.isTotpRequiredError = void 0;
|
|
511
|
+
var twoFactorMethods = ["totp", "email", "password"];
|
|
512
|
+
var isTotpRequiredError = (error) => typeof error === "object" && ((error === null || error === void 0 ? void 0 : error.error) === "totp-required" || (error === null || error === void 0 ? void 0 : error.errorType) === "totp-required");
|
|
513
|
+
exports.isTotpRequiredError = isTotpRequiredError;
|
|
514
|
+
var isTotpInvalidError = (error) => (error === null || error === void 0 ? void 0 : error.error) === "totp-invalid" || (error === null || error === void 0 ? void 0 : error.errorType) === "totp-invalid";
|
|
515
|
+
exports.isTotpInvalidError = isTotpInvalidError;
|
|
516
|
+
var isTwoFactorMethod = (method) => twoFactorMethods.includes(method);
|
|
517
|
+
exports.isTwoFactorMethod = isTwoFactorMethod;
|
|
518
|
+
var hasRequiredTwoFactorMethod = (error) => {
|
|
519
|
+
const details = error && typeof error === "object" && "details" in error && error.details;
|
|
520
|
+
return typeof details === "object" && details !== null && typeof details.method === "string" && (0, exports.isTwoFactorMethod)(details.method);
|
|
521
|
+
};
|
|
522
|
+
exports.hasRequiredTwoFactorMethod = hasRequiredTwoFactorMethod;
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
|
|
526
|
+
// node_modules/.pnpm/@rocket.chat+api-client@0.2.56_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/api-client/dist/index.js
|
|
527
|
+
var require_dist = __commonJS({
|
|
528
|
+
"node_modules/.pnpm/@rocket.chat+api-client@0.2.56_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/api-client/dist/index.js"(exports) {
|
|
529
|
+
"use strict";
|
|
530
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
531
|
+
function adopt(value) {
|
|
532
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
533
|
+
resolve3(value);
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
537
|
+
function fulfilled(value) {
|
|
538
|
+
try {
|
|
539
|
+
step(generator.next(value));
|
|
540
|
+
} catch (e) {
|
|
541
|
+
reject(e);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
function rejected(value) {
|
|
545
|
+
try {
|
|
546
|
+
step(generator["throw"](value));
|
|
547
|
+
} catch (e) {
|
|
548
|
+
reject(e);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
function step(result) {
|
|
552
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
553
|
+
}
|
|
554
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
555
|
+
});
|
|
556
|
+
};
|
|
557
|
+
var __rest = exports && exports.__rest || function(s, e) {
|
|
558
|
+
var t = {};
|
|
559
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
560
|
+
t[p] = s[p];
|
|
561
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
562
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
563
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
564
|
+
t[p[i]] = s[p[i]];
|
|
565
|
+
}
|
|
566
|
+
return t;
|
|
567
|
+
};
|
|
568
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
569
|
+
exports.RestClient = void 0;
|
|
570
|
+
var query_string_1 = require_query_string();
|
|
571
|
+
var errors_1 = require_errors();
|
|
572
|
+
var pipe = (fn) => (...args) => fn(...args);
|
|
573
|
+
function buildFormData(data, formData = new FormData(), parentKey) {
|
|
574
|
+
if (data instanceof FormData) {
|
|
575
|
+
return data;
|
|
576
|
+
}
|
|
577
|
+
if (!data) {
|
|
578
|
+
return formData;
|
|
579
|
+
}
|
|
580
|
+
if (typeof data === "object" && !(data instanceof File)) {
|
|
581
|
+
Object.keys(data).forEach((key) => {
|
|
582
|
+
buildFormData(formData, data[key], parentKey ? `${parentKey}[${key}]` : key);
|
|
583
|
+
});
|
|
584
|
+
} else {
|
|
585
|
+
data && parentKey && formData.append(parentKey, data);
|
|
586
|
+
}
|
|
587
|
+
return formData;
|
|
588
|
+
}
|
|
589
|
+
var checkIfIsFormData = (data = {}) => {
|
|
590
|
+
if (data instanceof FormData) {
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
return Object.values(data).some((value) => {
|
|
594
|
+
if (value && typeof value === "object" && !(value instanceof File)) {
|
|
595
|
+
return checkIfIsFormData(value);
|
|
596
|
+
}
|
|
597
|
+
return value instanceof File;
|
|
598
|
+
});
|
|
599
|
+
};
|
|
600
|
+
var RestClient = class {
|
|
601
|
+
constructor({ baseUrl, credentials, headers = {} }) {
|
|
602
|
+
this.headers = {};
|
|
603
|
+
this.setCredentials = (credentials2) => {
|
|
604
|
+
this.credentials = credentials2;
|
|
605
|
+
};
|
|
606
|
+
this.upload = (endpoint, params, events, options = {}) => {
|
|
607
|
+
if (!params) {
|
|
608
|
+
throw new Error("Missing params");
|
|
609
|
+
}
|
|
610
|
+
const xhr = new XMLHttpRequest();
|
|
611
|
+
const data = new FormData();
|
|
612
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
613
|
+
if (value instanceof File) {
|
|
614
|
+
data.append(key, value, value.name);
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
value && data.append(key, value);
|
|
618
|
+
});
|
|
619
|
+
xhr.open("POST", `${this.baseUrl}${`/${endpoint}`.replace(/\/+/, "/")}`, true);
|
|
620
|
+
Object.entries(Object.assign(Object.assign({}, this.getCredentialsAsHeaders()), options.headers)).forEach(([key, value]) => {
|
|
621
|
+
xhr.setRequestHeader(key, value);
|
|
622
|
+
});
|
|
623
|
+
if (events === null || events === void 0 ? void 0 : events.load) {
|
|
624
|
+
xhr.upload.addEventListener("load", events.load);
|
|
625
|
+
}
|
|
626
|
+
if (events === null || events === void 0 ? void 0 : events.progress) {
|
|
627
|
+
xhr.upload.addEventListener("progress", events.progress);
|
|
628
|
+
}
|
|
629
|
+
if (events === null || events === void 0 ? void 0 : events.error) {
|
|
630
|
+
xhr.addEventListener("error", events.error);
|
|
631
|
+
}
|
|
632
|
+
if (events === null || events === void 0 ? void 0 : events.abort) {
|
|
633
|
+
xhr.addEventListener("abort", events.abort);
|
|
634
|
+
}
|
|
635
|
+
xhr.send(data);
|
|
636
|
+
return xhr;
|
|
637
|
+
};
|
|
638
|
+
this.baseUrl = `${baseUrl}/api`;
|
|
639
|
+
this.setCredentials(credentials);
|
|
640
|
+
this.headers = headers;
|
|
641
|
+
}
|
|
642
|
+
getCredentials() {
|
|
643
|
+
return this.credentials;
|
|
644
|
+
}
|
|
645
|
+
get(endpoint, params, options) {
|
|
646
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
647
|
+
if (/\?/.test(endpoint)) {
|
|
648
|
+
console.warn("Endpoint cannot contain query string", endpoint);
|
|
649
|
+
}
|
|
650
|
+
const queryParams = this.getParams(params);
|
|
651
|
+
const response = yield this.send(`${endpoint}${queryParams ? `?${queryParams}` : ""}`, "GET", options !== null && options !== void 0 ? options : {});
|
|
652
|
+
return response.json();
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
post(endpoint_1, params_1) {
|
|
656
|
+
return __awaiter(this, arguments, void 0, function* (endpoint, params, _a = {}) {
|
|
657
|
+
var { headers } = _a, options = __rest(_a, ["headers"]);
|
|
658
|
+
const isFormData = checkIfIsFormData(params);
|
|
659
|
+
const response = yield this.send(endpoint, "POST", Object.assign({ body: isFormData ? buildFormData(params) : JSON.stringify(params), headers: Object.assign(Object.assign({ Accept: "application/json" }, !isFormData && { "Content-Type": "application/json" }), headers) }, options));
|
|
660
|
+
if (response.status === 204) {
|
|
661
|
+
return {};
|
|
662
|
+
}
|
|
663
|
+
return response.json();
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
put(endpoint_1, params_1) {
|
|
667
|
+
return __awaiter(this, arguments, void 0, function* (endpoint, params, _a = {}) {
|
|
668
|
+
var { headers } = _a, options = __rest(_a, ["headers"]);
|
|
669
|
+
const isFormData = checkIfIsFormData(params);
|
|
670
|
+
const response = yield this.send(endpoint, "PUT", Object.assign({ body: isFormData ? buildFormData(params) : JSON.stringify(params), headers: Object.assign(Object.assign({ Accept: "application/json" }, !isFormData && { "Content-Type": "application/json" }), headers) }, options));
|
|
671
|
+
return response.json();
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
delete(endpoint_1, _params_1) {
|
|
675
|
+
return __awaiter(this, arguments, void 0, function* (endpoint, _params, options = {}) {
|
|
676
|
+
const response = yield this.send(endpoint, "DELETE", options !== null && options !== void 0 ? options : {});
|
|
677
|
+
return response.json();
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
getCredentialsAsHeaders() {
|
|
681
|
+
const credentials = this.getCredentials();
|
|
682
|
+
return credentials ? {
|
|
683
|
+
"X-User-Id": credentials["X-User-Id"],
|
|
684
|
+
"X-Auth-Token": credentials["X-Auth-Token"]
|
|
685
|
+
} : {};
|
|
686
|
+
}
|
|
687
|
+
send(endpoint, method, _a = {}) {
|
|
688
|
+
var { headers } = _a, options = __rest(_a, ["headers"]);
|
|
689
|
+
return fetch(`${this.baseUrl}${`/${endpoint}`.replace(/\/+/, "/")}`, Object.assign(Object.assign({}, options), { headers: Object.assign(Object.assign(Object.assign({}, this.getCredentialsAsHeaders()), this.headers), headers), method })).then((response) => __awaiter(this, void 0, void 0, function* () {
|
|
690
|
+
if (response.ok) {
|
|
691
|
+
return response;
|
|
692
|
+
}
|
|
693
|
+
if (response.status !== 400) {
|
|
694
|
+
return Promise.reject(response);
|
|
695
|
+
}
|
|
696
|
+
const clone = response.clone();
|
|
697
|
+
const error = yield clone.json();
|
|
698
|
+
if (((0, errors_1.isTotpRequiredError)(error) || (0, errors_1.isTotpInvalidError)(error)) && (0, errors_1.hasRequiredTwoFactorMethod)(error) && this.twoFactorHandler) {
|
|
699
|
+
const method2fa = "details" in error ? error.details.method : "password";
|
|
700
|
+
const code = yield this.twoFactorHandler({
|
|
701
|
+
method: method2fa,
|
|
702
|
+
emailOrUsername: error.details.emailOrUsername,
|
|
703
|
+
invalidAttempt: (0, errors_1.isTotpInvalidError)(error)
|
|
52
704
|
});
|
|
53
|
-
this.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
705
|
+
return this.send(endpoint, method, Object.assign(Object.assign({}, options), { headers: Object.assign(Object.assign(Object.assign(Object.assign({}, this.getCredentialsAsHeaders()), this.headers), headers), { "x-2fa-code": code, "x-2fa-method": method2fa }) }));
|
|
706
|
+
}
|
|
707
|
+
return Promise.reject(response);
|
|
708
|
+
}));
|
|
709
|
+
}
|
|
710
|
+
getParams(data) {
|
|
711
|
+
return data ? (0, query_string_1.stringify)(data, { arrayFormat: "bracket" }) : "";
|
|
712
|
+
}
|
|
713
|
+
use(middleware) {
|
|
714
|
+
const fn = this.send.bind(this);
|
|
715
|
+
this.send = function(...context) {
|
|
716
|
+
return middleware(context, pipe(fn));
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
handleTwoFactorChallenge(cb) {
|
|
720
|
+
this.twoFactorHandler = cb;
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
exports.RestClient = RestClient;
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
// node_modules/.pnpm/@rocket.chat+emitter@0.33.0/node_modules/@rocket.chat/emitter/dist/index.js
|
|
728
|
+
var require_dist2 = __commonJS({
|
|
729
|
+
"node_modules/.pnpm/@rocket.chat+emitter@0.33.0/node_modules/@rocket.chat/emitter/dist/index.js"(exports) {
|
|
730
|
+
var t = /* @__PURE__ */ Symbol("once");
|
|
731
|
+
var e = /* @__PURE__ */ Symbol("evts");
|
|
732
|
+
exports.Emitter = class {
|
|
733
|
+
[e] = /* @__PURE__ */ new Map();
|
|
734
|
+
[t] = /* @__PURE__ */ new WeakMap();
|
|
735
|
+
events() {
|
|
736
|
+
return Array.from(this[e].keys());
|
|
737
|
+
}
|
|
738
|
+
has(t2) {
|
|
739
|
+
return this[e].has(t2);
|
|
740
|
+
}
|
|
741
|
+
on(t2, s) {
|
|
742
|
+
const h = this[e].get(t2) ?? [];
|
|
743
|
+
return h.push(s), this[e].set(t2, h), () => this.off(t2, s);
|
|
744
|
+
}
|
|
745
|
+
once(e2, s) {
|
|
746
|
+
const h = this[t].get(s) || 0;
|
|
747
|
+
return this[t].set(s, h + 1), this.on(e2, s);
|
|
748
|
+
}
|
|
749
|
+
off(s, h) {
|
|
750
|
+
const i = this[e].get(s);
|
|
751
|
+
if (!i) return;
|
|
752
|
+
const n = this[t].get(h) ?? 0;
|
|
753
|
+
n > 1 ? this[t].set(h, n - 1) : this[t].delete(h), i.splice(i.findIndex(((t2) => t2 === h)) >>> 0, 1), 0 === i.length && this[e].delete(s);
|
|
754
|
+
}
|
|
755
|
+
emit(s, ...[h]) {
|
|
756
|
+
[...this[e].get(s) ?? []].forEach(((e2) => {
|
|
757
|
+
e2(h), this[t].get(e2) && this.off(s, e2);
|
|
758
|
+
}));
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
});
|
|
763
|
+
|
|
764
|
+
// node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/MinimalDDPClient.js
|
|
765
|
+
var require_MinimalDDPClient = __commonJS({
|
|
766
|
+
"node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/MinimalDDPClient.js"(exports) {
|
|
767
|
+
"use strict";
|
|
768
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
769
|
+
exports.MinimalDDPClient = void 0;
|
|
770
|
+
var emitter_1 = require_dist2();
|
|
771
|
+
var getUniqueId = /* @__PURE__ */ (() => {
|
|
772
|
+
let id = 0;
|
|
773
|
+
return () => `rc-ddp-client-${++id}`;
|
|
774
|
+
})();
|
|
775
|
+
var SUPPORTED_DDP_VERSIONS = ["1", "pre2", "pre1"];
|
|
776
|
+
var MinimalDDPClient = class extends emitter_1.Emitter {
|
|
777
|
+
constructor(send, encode = JSON.stringify, decode = JSON.parse) {
|
|
778
|
+
super();
|
|
779
|
+
this.encode = encode;
|
|
780
|
+
this.decode = decode;
|
|
781
|
+
if (send) {
|
|
782
|
+
this.onDispatchMessage(send);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* @remarks
|
|
787
|
+
* if the received message is a valid DDP message, it will be emitted as an event.
|
|
788
|
+
*
|
|
789
|
+
* @param payload - The incoming message as a string.
|
|
790
|
+
* @throws {Error} - If the message is not a string.
|
|
791
|
+
* @throws {Error} - If the message is not a valid JSON.
|
|
792
|
+
*/
|
|
793
|
+
handleMessage(payload) {
|
|
794
|
+
const data = this.decode(payload);
|
|
795
|
+
Object.freeze(data);
|
|
796
|
+
switch (data.msg) {
|
|
797
|
+
case "ping":
|
|
798
|
+
this.pong(data.id);
|
|
799
|
+
break;
|
|
800
|
+
case "pong":
|
|
801
|
+
this.emit("pong", data);
|
|
802
|
+
break;
|
|
803
|
+
// Streamer related messages
|
|
804
|
+
case "nosub":
|
|
805
|
+
this.emit(`publication/${data.id}`, data);
|
|
806
|
+
this.emit(`nosub/${data.id}`, data);
|
|
807
|
+
break;
|
|
808
|
+
case "ready":
|
|
809
|
+
data.subs.forEach((id) => {
|
|
810
|
+
this.emit(`publication/${id}`, { msg: "ready", subs: [id] });
|
|
58
811
|
});
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
812
|
+
break;
|
|
813
|
+
case "added":
|
|
814
|
+
case "changed":
|
|
815
|
+
case "removed":
|
|
816
|
+
this.emit(`collection/${data.collection}`, data);
|
|
817
|
+
break;
|
|
818
|
+
// DDP/RCP related messages
|
|
819
|
+
case "result":
|
|
820
|
+
this.emit(`result/${data.id}`, data);
|
|
821
|
+
break;
|
|
822
|
+
case "updated":
|
|
823
|
+
data.methods.forEach((id) => {
|
|
824
|
+
this.emit(`updated/${id}`, data);
|
|
69
825
|
});
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
826
|
+
break;
|
|
827
|
+
case "connected":
|
|
828
|
+
case "failed":
|
|
829
|
+
this.emit("connection", data);
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
832
|
+
this.emit("message", data);
|
|
833
|
+
}
|
|
834
|
+
onDispatchMessage(callback) {
|
|
835
|
+
return this.on("send", (payload) => {
|
|
836
|
+
callback(this.encode(payload));
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
dispatch(payload) {
|
|
840
|
+
this.emit("send", payload);
|
|
841
|
+
}
|
|
842
|
+
call(method, params = []) {
|
|
843
|
+
const id = getUniqueId();
|
|
844
|
+
const payload = {
|
|
845
|
+
msg: "method",
|
|
846
|
+
method,
|
|
847
|
+
params,
|
|
848
|
+
id
|
|
849
|
+
};
|
|
850
|
+
return payload;
|
|
851
|
+
}
|
|
852
|
+
subscribe(name, params) {
|
|
853
|
+
const id = getUniqueId();
|
|
854
|
+
return this.subscribeWithId(id, name, params);
|
|
855
|
+
}
|
|
856
|
+
subscribeWithId(id, name, params) {
|
|
857
|
+
const payload = {
|
|
858
|
+
msg: "sub",
|
|
859
|
+
id,
|
|
860
|
+
name,
|
|
861
|
+
params
|
|
862
|
+
};
|
|
863
|
+
this.dispatch(payload);
|
|
864
|
+
return id;
|
|
865
|
+
}
|
|
866
|
+
unsubscribe(id) {
|
|
867
|
+
const payload = {
|
|
868
|
+
msg: "unsub",
|
|
869
|
+
id
|
|
870
|
+
};
|
|
871
|
+
this.dispatch(payload);
|
|
872
|
+
}
|
|
873
|
+
connect() {
|
|
874
|
+
const payload = {
|
|
875
|
+
msg: "connect",
|
|
876
|
+
version: "1",
|
|
877
|
+
support: SUPPORTED_DDP_VERSIONS
|
|
878
|
+
};
|
|
879
|
+
this.dispatch(payload);
|
|
880
|
+
}
|
|
881
|
+
onPublish(name, callback) {
|
|
882
|
+
return this.once(`publication/${name}`, callback);
|
|
883
|
+
}
|
|
884
|
+
onResult(id, callback) {
|
|
885
|
+
return this.once(`result/${id}`, callback);
|
|
886
|
+
}
|
|
887
|
+
onUpdate(id, callback) {
|
|
888
|
+
return this.on(`updated/${id}`, callback);
|
|
889
|
+
}
|
|
890
|
+
onNoSub(id, callback) {
|
|
891
|
+
return this.once(`nosub/${id}`, callback);
|
|
892
|
+
}
|
|
893
|
+
onCollection(name, callback) {
|
|
894
|
+
return this.on(`collection/${name}`, callback);
|
|
895
|
+
}
|
|
896
|
+
onConnection(callback) {
|
|
897
|
+
return this.once("connection", callback);
|
|
898
|
+
}
|
|
899
|
+
onceMessage(callback) {
|
|
900
|
+
return this.once("message", callback);
|
|
901
|
+
}
|
|
902
|
+
onMessage(callback) {
|
|
903
|
+
return this.on("message", callback);
|
|
904
|
+
}
|
|
905
|
+
ping(id) {
|
|
906
|
+
this.dispatch(Object.assign({ msg: "ping" }, id && { id }));
|
|
907
|
+
}
|
|
908
|
+
pong(id) {
|
|
909
|
+
this.dispatch(Object.assign({ msg: "pong" }, id && { id }));
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
exports.MinimalDDPClient = MinimalDDPClient;
|
|
913
|
+
}
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
// node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/DDPDispatcher.js
|
|
917
|
+
var require_DDPDispatcher = __commonJS({
|
|
918
|
+
"node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/DDPDispatcher.js"(exports) {
|
|
919
|
+
"use strict";
|
|
920
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
921
|
+
exports.DDPDispatcher = void 0;
|
|
922
|
+
var MinimalDDPClient_1 = require_MinimalDDPClient();
|
|
923
|
+
var DDPDispatcher = class extends MinimalDDPClient_1.MinimalDDPClient {
|
|
924
|
+
constructor() {
|
|
925
|
+
super(...arguments);
|
|
926
|
+
this.queue = [];
|
|
927
|
+
}
|
|
928
|
+
dispatch(payload, options) {
|
|
929
|
+
if (payload.msg !== "method") {
|
|
930
|
+
this.emit("send", payload);
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
if (options === null || options === void 0 ? void 0 : options.wait) {
|
|
934
|
+
this.wait(payload);
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
this.pushItem(payload);
|
|
938
|
+
}
|
|
939
|
+
wait(block) {
|
|
940
|
+
this.queue.push({
|
|
941
|
+
wait: true,
|
|
942
|
+
items: [block]
|
|
943
|
+
});
|
|
944
|
+
if (this.queue.length === 1) {
|
|
945
|
+
this.sendOutstandingBlocks();
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
pushItem(item) {
|
|
949
|
+
const block = this.tail();
|
|
950
|
+
if (!block || block.wait) {
|
|
951
|
+
this.queue.push({
|
|
952
|
+
wait: false,
|
|
953
|
+
items: [item]
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
if (!block) {
|
|
957
|
+
this.sendOutstandingBlocks();
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
if (block.wait) {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
block.items.push(item);
|
|
964
|
+
}
|
|
965
|
+
tail() {
|
|
966
|
+
return this.queue[this.queue.length - 1];
|
|
967
|
+
}
|
|
968
|
+
sendOutstandingBlocks() {
|
|
969
|
+
const block = this.queue[0];
|
|
970
|
+
if (!block) {
|
|
971
|
+
return;
|
|
972
|
+
}
|
|
973
|
+
block.items.forEach((payload) => {
|
|
974
|
+
this.emit("send", payload);
|
|
975
|
+
});
|
|
976
|
+
if (block.wait) {
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
this.queue.shift();
|
|
980
|
+
this.sendOutstandingBlocks();
|
|
981
|
+
}
|
|
982
|
+
removeItem(item) {
|
|
983
|
+
const block = this.queue[0];
|
|
984
|
+
if (!block) {
|
|
985
|
+
return;
|
|
986
|
+
}
|
|
987
|
+
const index = block.items.indexOf(item);
|
|
988
|
+
if (index === -1) {
|
|
989
|
+
return;
|
|
990
|
+
}
|
|
991
|
+
block.items.splice(index, 1);
|
|
992
|
+
if (block.items.length === 0) {
|
|
993
|
+
this.queue.shift();
|
|
994
|
+
this.sendOutstandingBlocks();
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
};
|
|
998
|
+
exports.DDPDispatcher = DDPDispatcher;
|
|
999
|
+
}
|
|
1000
|
+
});
|
|
1001
|
+
|
|
1002
|
+
// node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/ClientStream.js
|
|
1003
|
+
var require_ClientStream = __commonJS({
|
|
1004
|
+
"node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/ClientStream.js"(exports) {
|
|
1005
|
+
"use strict";
|
|
1006
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1007
|
+
function adopt(value) {
|
|
1008
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
1009
|
+
resolve3(value);
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
1013
|
+
function fulfilled(value) {
|
|
1014
|
+
try {
|
|
1015
|
+
step(generator.next(value));
|
|
1016
|
+
} catch (e) {
|
|
1017
|
+
reject(e);
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
function rejected(value) {
|
|
1021
|
+
try {
|
|
1022
|
+
step(generator["throw"](value));
|
|
1023
|
+
} catch (e) {
|
|
1024
|
+
reject(e);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
function step(result) {
|
|
1028
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1029
|
+
}
|
|
1030
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1031
|
+
});
|
|
1032
|
+
};
|
|
1033
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1034
|
+
exports.ClientStreamImpl = void 0;
|
|
1035
|
+
var emitter_1 = require_dist2();
|
|
1036
|
+
var DDPDispatcher_1 = require_DDPDispatcher();
|
|
1037
|
+
var ClientStreamImpl = class extends emitter_1.Emitter {
|
|
1038
|
+
constructor(ddp, dispatcher = new DDPDispatcher_1.DDPDispatcher()) {
|
|
1039
|
+
ddp.onConnection(({ msg }) => {
|
|
1040
|
+
if (msg === "connected") {
|
|
1041
|
+
this.emit("connected");
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
super();
|
|
1045
|
+
this.ddp = ddp;
|
|
1046
|
+
this.dispatcher = dispatcher;
|
|
1047
|
+
this.subscriptions = /* @__PURE__ */ new Map();
|
|
1048
|
+
}
|
|
1049
|
+
apply({ payload: ddpCallPayload, options, callback }) {
|
|
1050
|
+
this.dispatcher.dispatch(ddpCallPayload, options);
|
|
1051
|
+
this.ddp.onResult(ddpCallPayload.id, (payload) => {
|
|
1052
|
+
this.dispatcher.removeItem(ddpCallPayload);
|
|
1053
|
+
if (typeof callback === "function") {
|
|
1054
|
+
if ("error" in payload) {
|
|
1055
|
+
callback(payload.error);
|
|
1056
|
+
} else {
|
|
1057
|
+
callback(null, payload.result);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
});
|
|
1061
|
+
return ddpCallPayload.id;
|
|
1062
|
+
}
|
|
1063
|
+
call(method, ...params) {
|
|
1064
|
+
return this.callWithOptions(method, {}, ...params);
|
|
1065
|
+
}
|
|
1066
|
+
callWithOptions(method, options, ...params) {
|
|
1067
|
+
const callback = params.pop();
|
|
1068
|
+
if (typeof callback !== "function") {
|
|
1069
|
+
params.push(callback);
|
|
1070
|
+
}
|
|
1071
|
+
const payload = this.ddp.call(method, params);
|
|
1072
|
+
this.apply({ payload, callback, options });
|
|
1073
|
+
return payload.id;
|
|
1074
|
+
}
|
|
1075
|
+
callAsync(method, ...params) {
|
|
1076
|
+
return this.callAsyncWithOptions(method, {}, ...params);
|
|
1077
|
+
}
|
|
1078
|
+
callAsyncWithOptions(method, options, ...params) {
|
|
1079
|
+
const payload = this.ddp.call(method, params);
|
|
1080
|
+
return Object.assign(new Promise((resolve3, reject) => {
|
|
1081
|
+
this.apply({
|
|
1082
|
+
payload,
|
|
1083
|
+
options,
|
|
1084
|
+
callback: (error, result) => {
|
|
1085
|
+
if (error) {
|
|
1086
|
+
reject(error);
|
|
1087
|
+
} else {
|
|
1088
|
+
resolve3(result);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
}), {
|
|
1093
|
+
id: payload.id
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
subscribe(name, ...params) {
|
|
1097
|
+
const id = this.ddp.subscribe(name, params);
|
|
1098
|
+
const self = this;
|
|
1099
|
+
const s = self.ddp.onPublish(id, (payload) => {
|
|
1100
|
+
if ("error" in payload) {
|
|
1101
|
+
result.error = payload.error;
|
|
1102
|
+
this.subscriptions.delete(id);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
result.isReady = true;
|
|
1106
|
+
this.subscriptions.set(id, Object.assign(Object.assign({}, result), { isReady: true }));
|
|
1107
|
+
});
|
|
1108
|
+
const stop = () => {
|
|
1109
|
+
s();
|
|
1110
|
+
void self.unsubscribe(id);
|
|
1111
|
+
};
|
|
1112
|
+
const result = {
|
|
1113
|
+
id,
|
|
1114
|
+
name,
|
|
1115
|
+
params,
|
|
1116
|
+
ready() {
|
|
1117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1118
|
+
const subscription = self.subscriptions.get(id);
|
|
1119
|
+
if (!subscription) {
|
|
1120
|
+
return Promise.reject(result.error);
|
|
1121
|
+
}
|
|
1122
|
+
if (subscription.isReady) {
|
|
1123
|
+
return Promise.resolve();
|
|
1124
|
+
}
|
|
1125
|
+
return new Promise((resolve3, reject) => {
|
|
1126
|
+
this.onChange((payload) => {
|
|
1127
|
+
if ("error" in payload) {
|
|
1128
|
+
reject(payload.error);
|
|
1129
|
+
return;
|
|
1130
|
+
}
|
|
1131
|
+
resolve3();
|
|
1132
|
+
});
|
|
1133
|
+
});
|
|
76
1134
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
1135
|
+
},
|
|
1136
|
+
isReady: false,
|
|
1137
|
+
onChange: (cb) => {
|
|
1138
|
+
self.ddp.onPublish(id, cb);
|
|
1139
|
+
},
|
|
1140
|
+
stop
|
|
1141
|
+
};
|
|
1142
|
+
this.subscriptions.set(id, result);
|
|
1143
|
+
return result;
|
|
1144
|
+
}
|
|
1145
|
+
unsubscribe(id) {
|
|
1146
|
+
return new Promise((resolve3, reject) => {
|
|
1147
|
+
this.subscriptions.delete(id);
|
|
1148
|
+
this.ddp.unsubscribe(id);
|
|
1149
|
+
this.ddp.onNoSub(id, (payload) => {
|
|
1150
|
+
if ("error" in payload) {
|
|
1151
|
+
reject(payload.error);
|
|
1152
|
+
} else {
|
|
1153
|
+
resolve3(payload);
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
});
|
|
1157
|
+
}
|
|
1158
|
+
connect() {
|
|
1159
|
+
this.ddp.connect();
|
|
1160
|
+
return new Promise((resolve3, reject) => {
|
|
1161
|
+
this.ddp.onConnection((data) => {
|
|
1162
|
+
if (data.msg === "failed")
|
|
1163
|
+
reject(data);
|
|
1164
|
+
else
|
|
1165
|
+
resolve3(data);
|
|
1166
|
+
});
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
onCollection(id, callback) {
|
|
1170
|
+
return this.ddp.onCollection(id, callback);
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
exports.ClientStreamImpl = ClientStreamImpl;
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1176
|
+
|
|
1177
|
+
// node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/Connection.js
|
|
1178
|
+
var require_Connection = __commonJS({
|
|
1179
|
+
"node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/Connection.js"(exports) {
|
|
1180
|
+
"use strict";
|
|
1181
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1182
|
+
exports.ConnectionImpl = void 0;
|
|
1183
|
+
var emitter_1 = require_dist2();
|
|
1184
|
+
var ConnectionImpl = class _ConnectionImpl extends emitter_1.Emitter {
|
|
1185
|
+
constructor(url, WS, client, retryOptions = { retryCount: 0, retryTime: 1e3 }) {
|
|
1186
|
+
super();
|
|
1187
|
+
this.WS = WS;
|
|
1188
|
+
this.client = client;
|
|
1189
|
+
this.retryOptions = retryOptions;
|
|
1190
|
+
this.status = "idle";
|
|
1191
|
+
this.retryCount = 0;
|
|
1192
|
+
this.queue = /* @__PURE__ */ new Set();
|
|
1193
|
+
this.ssl = url.startsWith("https") || url.startsWith("wss");
|
|
1194
|
+
this.url = url.replace(/^https?:\/\//, "").replace(/^wss?:\/\//, "");
|
|
1195
|
+
this.client.onDispatchMessage((message) => {
|
|
1196
|
+
if (this.ws && this.ws.readyState === this.ws.OPEN) {
|
|
1197
|
+
this.ws.send(message);
|
|
1198
|
+
return;
|
|
1199
|
+
}
|
|
1200
|
+
this.queue.add(message);
|
|
1201
|
+
});
|
|
1202
|
+
this.on("connected", () => {
|
|
1203
|
+
this.queue.forEach((message) => {
|
|
1204
|
+
var _a;
|
|
1205
|
+
(_a = this.ws) === null || _a === void 0 ? void 0 : _a.send(message);
|
|
1206
|
+
});
|
|
1207
|
+
this.queue.clear();
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
emitStatus() {
|
|
1211
|
+
this.emit("connection", this.status);
|
|
1212
|
+
}
|
|
1213
|
+
reconnect() {
|
|
1214
|
+
if (this.status === "connected") {
|
|
1215
|
+
clearTimeout(this.retryOptions.retryTimer);
|
|
1216
|
+
return Promise.resolve(true);
|
|
1217
|
+
}
|
|
1218
|
+
if (this.status === "connecting") {
|
|
1219
|
+
clearTimeout(this.retryOptions.retryTimer);
|
|
1220
|
+
return this.connectPromise;
|
|
1221
|
+
}
|
|
1222
|
+
clearTimeout(this.retryOptions.retryTimer);
|
|
1223
|
+
this.emit("reconnecting");
|
|
1224
|
+
this.emit("connection", "reconnecting");
|
|
1225
|
+
return this.connect();
|
|
1226
|
+
}
|
|
1227
|
+
connect() {
|
|
1228
|
+
if (this.status === "connected") {
|
|
1229
|
+
clearTimeout(this.retryOptions.retryTimer);
|
|
1230
|
+
return Promise.resolve(true);
|
|
1231
|
+
}
|
|
1232
|
+
if (this.status === "connecting") {
|
|
1233
|
+
clearTimeout(this.retryOptions.retryTimer);
|
|
1234
|
+
return this.connectPromise;
|
|
1235
|
+
}
|
|
1236
|
+
this.status = "connecting";
|
|
1237
|
+
const ws = new this.WS(`${this.ssl ? "wss://" : "ws://"}${this.url}/websocket`);
|
|
1238
|
+
this.ws = ws;
|
|
1239
|
+
const connectPromise = new Promise((resolve3, reject) => {
|
|
1240
|
+
ws.onopen = () => {
|
|
1241
|
+
ws.onmessage = (event) => {
|
|
1242
|
+
this.client.handleMessage(String(event.data));
|
|
1243
|
+
};
|
|
1244
|
+
this.client.connect();
|
|
1245
|
+
this.client.onConnection((payload) => {
|
|
1246
|
+
if (payload.msg === "connected") {
|
|
1247
|
+
this.status = "connected";
|
|
1248
|
+
this.retryCount = 0;
|
|
1249
|
+
this.emitStatus();
|
|
1250
|
+
this.emit("connected", payload.session);
|
|
1251
|
+
this.session = payload.session;
|
|
1252
|
+
return resolve3(true);
|
|
1253
|
+
}
|
|
1254
|
+
if (payload.msg === "failed") {
|
|
1255
|
+
this.status = "failed";
|
|
1256
|
+
this.emitStatus();
|
|
1257
|
+
this.emit("disconnected");
|
|
1258
|
+
return reject(payload.version);
|
|
1259
|
+
}
|
|
1260
|
+
reject(new Error("Unknown message type"));
|
|
1261
|
+
});
|
|
1262
|
+
};
|
|
1263
|
+
ws.onclose = () => {
|
|
1264
|
+
if (this.ws !== ws) {
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
clearTimeout(this.retryOptions.retryTimer);
|
|
1268
|
+
if (this.status === "closed") {
|
|
1269
|
+
return;
|
|
1270
|
+
}
|
|
1271
|
+
this.status = "disconnected";
|
|
1272
|
+
this.emitStatus();
|
|
1273
|
+
this.emit("disconnected");
|
|
1274
|
+
if (this.retryCount >= this.retryOptions.retryCount) {
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
this.retryCount += 1;
|
|
1278
|
+
this.retryOptions.retryTimer = setTimeout(() => {
|
|
1279
|
+
if (this.status === "connecting" || this.status === "connected" || this.status === "closed") {
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
void this.reconnect();
|
|
1283
|
+
}, this.retryOptions.retryTime * this.retryCount);
|
|
1284
|
+
};
|
|
1285
|
+
});
|
|
1286
|
+
this.connectPromise = connectPromise;
|
|
1287
|
+
this.emit("connecting");
|
|
1288
|
+
this.emitStatus();
|
|
1289
|
+
return connectPromise;
|
|
1290
|
+
}
|
|
1291
|
+
close() {
|
|
1292
|
+
var _a;
|
|
1293
|
+
this.status = "closed";
|
|
1294
|
+
(_a = this.ws) === null || _a === void 0 ? void 0 : _a.close();
|
|
1295
|
+
this.emitStatus();
|
|
1296
|
+
}
|
|
1297
|
+
static create(url, webSocketImpl, client, retryOptions = { retryCount: 0, retryTime: 1e3 }) {
|
|
1298
|
+
return new _ConnectionImpl(url, webSocketImpl, client, retryOptions);
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
exports.ConnectionImpl = ConnectionImpl;
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1304
|
+
|
|
1305
|
+
// node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/TimeoutControl.js
|
|
1306
|
+
var require_TimeoutControl = __commonJS({
|
|
1307
|
+
"node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/TimeoutControl.js"(exports) {
|
|
1308
|
+
"use strict";
|
|
1309
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1310
|
+
exports.TimeoutControl = void 0;
|
|
1311
|
+
var emitter_1 = require_dist2();
|
|
1312
|
+
var TimeoutControl = class _TimeoutControl extends emitter_1.Emitter {
|
|
1313
|
+
constructor(timeout = 6e4, heartbeat = timeout / 2) {
|
|
1314
|
+
super();
|
|
1315
|
+
this.timeout = timeout;
|
|
1316
|
+
this.heartbeat = heartbeat;
|
|
1317
|
+
if (this.heartbeat >= this.timeout) {
|
|
1318
|
+
throw new Error("Heartbeat must be less than timeout");
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
reset() {
|
|
1322
|
+
if (this.timeoutId) {
|
|
1323
|
+
clearTimeout(this.timeoutId);
|
|
1324
|
+
}
|
|
1325
|
+
if (this.heartbeatId) {
|
|
1326
|
+
clearTimeout(this.heartbeatId);
|
|
1327
|
+
}
|
|
1328
|
+
this.timeoutId = setTimeout(() => this.emit("timeout"), this.timeout);
|
|
1329
|
+
this.heartbeatId = setTimeout(() => this.emit("heartbeat"), this.heartbeat);
|
|
1330
|
+
}
|
|
1331
|
+
stop() {
|
|
1332
|
+
if (this.timeoutId) {
|
|
1333
|
+
clearTimeout(this.timeoutId);
|
|
1334
|
+
}
|
|
1335
|
+
if (this.heartbeatId) {
|
|
1336
|
+
clearTimeout(this.heartbeatId);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
static create(ddp, connection, timeout, heartbeat) {
|
|
1340
|
+
const timeoutControl = new _TimeoutControl(timeout, heartbeat);
|
|
1341
|
+
timeoutControl.on("heartbeat", () => {
|
|
1342
|
+
ddp.ping();
|
|
1343
|
+
});
|
|
1344
|
+
timeoutControl.on("timeout", () => {
|
|
1345
|
+
connection.close();
|
|
1346
|
+
});
|
|
1347
|
+
ddp.onMessage(() => timeoutControl.reset());
|
|
1348
|
+
connection.on("close", () => {
|
|
1349
|
+
timeoutControl.stop();
|
|
1350
|
+
});
|
|
1351
|
+
connection.on("disconnected", () => {
|
|
1352
|
+
timeoutControl.stop();
|
|
1353
|
+
});
|
|
1354
|
+
connection.on("connected", () => {
|
|
1355
|
+
timeoutControl.reset();
|
|
1356
|
+
});
|
|
1357
|
+
return timeoutControl;
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
exports.TimeoutControl = TimeoutControl;
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1363
|
+
|
|
1364
|
+
// node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/types/Account.js
|
|
1365
|
+
var require_Account = __commonJS({
|
|
1366
|
+
"node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/types/Account.js"(exports) {
|
|
1367
|
+
"use strict";
|
|
1368
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1369
|
+
function adopt(value) {
|
|
1370
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
1371
|
+
resolve3(value);
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
1375
|
+
function fulfilled(value) {
|
|
1376
|
+
try {
|
|
1377
|
+
step(generator.next(value));
|
|
1378
|
+
} catch (e) {
|
|
1379
|
+
reject(e);
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
function rejected(value) {
|
|
1383
|
+
try {
|
|
1384
|
+
step(generator["throw"](value));
|
|
1385
|
+
} catch (e) {
|
|
1386
|
+
reject(e);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
function step(result) {
|
|
1390
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1391
|
+
}
|
|
1392
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1393
|
+
});
|
|
1394
|
+
};
|
|
1395
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1396
|
+
exports.AccountImpl = void 0;
|
|
1397
|
+
var emitter_1 = require_dist2();
|
|
1398
|
+
var AccountImpl = class extends emitter_1.Emitter {
|
|
1399
|
+
get uid() {
|
|
1400
|
+
return this._uid;
|
|
1401
|
+
}
|
|
1402
|
+
// Setter emits only on transition so onLogin/onLogout fire once per login/logout,
|
|
1403
|
+
// not on every credential refresh. Direct writes from outside the SDK
|
|
1404
|
+
// (adoptAccountFromMeteorLoginResult, teardownAuthenticatedConnection) flow through
|
|
1405
|
+
// here and become the canonical login signal regardless of transport mode.
|
|
1406
|
+
set uid(value) {
|
|
1407
|
+
if (value === this._uid)
|
|
1408
|
+
return;
|
|
1409
|
+
this._uid = value;
|
|
1410
|
+
this.emit("uid", value);
|
|
1411
|
+
}
|
|
1412
|
+
constructor(client) {
|
|
1413
|
+
super();
|
|
1414
|
+
this.client = client;
|
|
1415
|
+
client.onCollection("users", (data) => {
|
|
1416
|
+
if (data.collection !== "users") {
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
if (!("fields" in data) || !(data.fields && "username" in data.fields)) {
|
|
1420
|
+
return;
|
|
1421
|
+
}
|
|
1422
|
+
this.user = Object.assign(Object.assign({}, this.user), { id: data.id, username: data.fields.username });
|
|
1423
|
+
this.emit("user", this.user);
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
saveCredentials(id, token, tokenExpires) {
|
|
1427
|
+
this.user = Object.assign(Object.assign({}, this.user), { token, tokenExpires: new Date(tokenExpires), id });
|
|
1428
|
+
this.uid = id;
|
|
1429
|
+
this.emit("user", this.user);
|
|
1430
|
+
}
|
|
1431
|
+
loginWithPassword(username, password) {
|
|
1432
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1433
|
+
const { id, token: resultToken, tokenExpires: { $date } } = yield this.client.callAsyncWithOptions("login", {
|
|
1434
|
+
wait: true
|
|
1435
|
+
}, {
|
|
1436
|
+
user: { username },
|
|
1437
|
+
password: { digest: password, algorithm: "sha-256" }
|
|
1438
|
+
});
|
|
1439
|
+
this.saveCredentials(id, resultToken, $date);
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
loginWithToken(token) {
|
|
1443
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1444
|
+
const result = yield this.client.callAsyncWithOptions("login", {
|
|
1445
|
+
wait: true
|
|
1446
|
+
}, {
|
|
1447
|
+
resume: token
|
|
1448
|
+
});
|
|
1449
|
+
const { id, token: resultToken, tokenExpires: { $date } } = result;
|
|
1450
|
+
this.saveCredentials(id, resultToken, $date);
|
|
1451
|
+
return result;
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
logout() {
|
|
1455
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1456
|
+
yield this.client.callAsyncWithOptions("logout", {
|
|
1457
|
+
wait: true
|
|
1458
|
+
});
|
|
1459
|
+
this.user = void 0;
|
|
1460
|
+
this.uid = void 0;
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
onLogin(fn) {
|
|
1464
|
+
return this.on("uid", (uid) => {
|
|
1465
|
+
if (uid !== void 0)
|
|
1466
|
+
fn();
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
onLogout(fn) {
|
|
1470
|
+
return this.on("uid", (uid) => {
|
|
1471
|
+
if (uid === void 0)
|
|
1472
|
+
fn();
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1475
|
+
// emailVerificationLink and pageLoadLogin have no native source in the SDK — the actual
|
|
1476
|
+
// events come from Meteor's accounts-base (URL hash routing for verification, pending
|
|
1477
|
+
// login attempts for OAuth). The bridge in apps/meteor/client/lib/sdk/ddpSdk.ts forwards
|
|
1478
|
+
// Meteor's events into this emitter; flag-OFF mode delegates directly via meteorBackedSdk.
|
|
1479
|
+
onEmailVerificationLink(fn) {
|
|
1480
|
+
return this.on("emailVerificationLink", fn);
|
|
1481
|
+
}
|
|
1482
|
+
onPageLoadLogin(fn) {
|
|
1483
|
+
return this.on("pageLoadLogin", fn);
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
exports.AccountImpl = AccountImpl;
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
|
|
1490
|
+
// node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/DDPSDK.js
|
|
1491
|
+
var require_DDPSDK = __commonJS({
|
|
1492
|
+
"node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/DDPSDK.js"(exports) {
|
|
1493
|
+
"use strict";
|
|
1494
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1495
|
+
function adopt(value) {
|
|
1496
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
1497
|
+
resolve3(value);
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
1501
|
+
function fulfilled(value) {
|
|
1502
|
+
try {
|
|
1503
|
+
step(generator.next(value));
|
|
1504
|
+
} catch (e) {
|
|
1505
|
+
reject(e);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
function rejected(value) {
|
|
1509
|
+
try {
|
|
1510
|
+
step(generator["throw"](value));
|
|
1511
|
+
} catch (e) {
|
|
1512
|
+
reject(e);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
function step(result) {
|
|
1516
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1517
|
+
}
|
|
1518
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1519
|
+
});
|
|
1520
|
+
};
|
|
1521
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1522
|
+
exports.DDPSDK = void 0;
|
|
1523
|
+
var api_client_1 = require_dist();
|
|
1524
|
+
var ClientStream_1 = require_ClientStream();
|
|
1525
|
+
var Connection_1 = require_Connection();
|
|
1526
|
+
var DDPDispatcher_1 = require_DDPDispatcher();
|
|
1527
|
+
var TimeoutControl_1 = require_TimeoutControl();
|
|
1528
|
+
var Account_1 = require_Account();
|
|
1529
|
+
var isValidPayload = (data) => {
|
|
1530
|
+
if (typeof data !== "object" && (data !== null || data !== void 0)) {
|
|
1531
|
+
return false;
|
|
1532
|
+
}
|
|
1533
|
+
return true;
|
|
1534
|
+
};
|
|
1535
|
+
var DDPSDK2 = class _DDPSDK {
|
|
1536
|
+
constructor(connection, client, account, timeoutControl, rest) {
|
|
1537
|
+
this.connection = connection;
|
|
1538
|
+
this.client = client;
|
|
1539
|
+
this.account = account;
|
|
1540
|
+
this.timeoutControl = timeoutControl;
|
|
1541
|
+
this.rest = rest;
|
|
1542
|
+
}
|
|
1543
|
+
call(method, ...params) {
|
|
1544
|
+
return this.client.callAsync(method, ...params);
|
|
1545
|
+
}
|
|
1546
|
+
stream(name, data, cb) {
|
|
1547
|
+
const [key, args] = Array.isArray(data) ? data : [data];
|
|
1548
|
+
const subscription = this.client.subscribe(`stream-${name}`, key, { useCollection: false, args: [args] });
|
|
1549
|
+
const stop = subscription.stop.bind(subscription);
|
|
1550
|
+
const cancel = [
|
|
1551
|
+
() => stop(),
|
|
1552
|
+
this.client.onCollection(`stream-${name}`, (data2) => {
|
|
1553
|
+
if (!isValidPayload(data2)) {
|
|
1554
|
+
return;
|
|
1555
|
+
}
|
|
1556
|
+
if (data2.collection !== `stream-${name}`) {
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
if (data2.msg !== "changed") {
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
if (data2.fields.eventName === key) {
|
|
1563
|
+
cb(...data2.fields.args);
|
|
1564
|
+
}
|
|
1565
|
+
})
|
|
1566
|
+
];
|
|
1567
|
+
return Object.assign(subscription, {
|
|
1568
|
+
stop: () => {
|
|
1569
|
+
cancel.forEach((fn) => fn());
|
|
1570
|
+
}
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Compounds the Objects responsible for the SDK and returns it through
|
|
1575
|
+
* SDK interface
|
|
1576
|
+
*
|
|
1577
|
+
* @param url - The URL of the server to connect to
|
|
1578
|
+
* @param retryOptions - The options for the retry strategy of the connection
|
|
1579
|
+
* @param retryOptions.retryCount - The number of times to retry the connection
|
|
1580
|
+
* @param retryOptions.retryTime - The time to wait between retries
|
|
1581
|
+
* @returns The SDK interface
|
|
1582
|
+
*
|
|
1583
|
+
* @example
|
|
1584
|
+
* ```ts
|
|
1585
|
+
* const sdk = DDPSDK.create('wss://open.rocket.chat/websocket');
|
|
1586
|
+
* sdk.connection.connect();
|
|
1587
|
+
* ```
|
|
1588
|
+
*/
|
|
1589
|
+
static create(url, retryOptions = { retryCount: 1, retryTime: 100 }) {
|
|
1590
|
+
const ddp = new DDPDispatcher_1.DDPDispatcher();
|
|
1591
|
+
const connection = Connection_1.ConnectionImpl.create(url, WebSocket, ddp, retryOptions);
|
|
1592
|
+
const stream = new ClientStream_1.ClientStreamImpl(ddp, ddp);
|
|
1593
|
+
const account = new Account_1.AccountImpl(stream);
|
|
1594
|
+
const timeoutControl = TimeoutControl_1.TimeoutControl.create(ddp, connection);
|
|
1595
|
+
const rest = new class RestApiClient extends api_client_1.RestClient {
|
|
1596
|
+
getCredentials() {
|
|
1597
|
+
var _a;
|
|
1598
|
+
if (!account.uid || !((_a = account.user) === null || _a === void 0 ? void 0 : _a.token)) {
|
|
1599
|
+
return;
|
|
1600
|
+
}
|
|
1601
|
+
return {
|
|
1602
|
+
"X-User-Id": account.uid,
|
|
1603
|
+
"X-Auth-Token": account.user.token
|
|
1604
|
+
};
|
|
1605
|
+
}
|
|
1606
|
+
}({ baseUrl: url });
|
|
1607
|
+
const sdk = new _DDPSDK(connection, stream, account, timeoutControl, rest);
|
|
1608
|
+
connection.on("connected", () => {
|
|
1609
|
+
var _a;
|
|
1610
|
+
if ((_a = account.user) === null || _a === void 0 ? void 0 : _a.token) {
|
|
1611
|
+
void account.loginWithToken(account.user.token);
|
|
1612
|
+
}
|
|
1613
|
+
[...stream.subscriptions.entries()].forEach(([, sub]) => {
|
|
1614
|
+
ddp.subscribeWithId(sub.id, sub.name, sub.params);
|
|
1615
|
+
});
|
|
1616
|
+
});
|
|
1617
|
+
return sdk;
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Same as `DDPSDK.create`, but also connects to the server and waits for the connection to be established
|
|
1621
|
+
* @param url - The URL of the server to connect to
|
|
1622
|
+
* @param retryOptions - The options for the retry strategy of the connection
|
|
1623
|
+
* @param retryOptions.retryCount - The number of times to retry the connection
|
|
1624
|
+
* @param retryOptions.retryTime - The time to wait between retries
|
|
1625
|
+
* @returns A promise that resolves to the SDK interface
|
|
1626
|
+
* @example
|
|
1627
|
+
* ```ts
|
|
1628
|
+
* const sdk = await DDPSDK.createAndConnect('wss://open.rocket.chat/websocket');
|
|
1629
|
+
* ```
|
|
1630
|
+
*/
|
|
1631
|
+
static createAndConnect(url_1) {
|
|
1632
|
+
return __awaiter(this, arguments, void 0, function* (url, retryOptions = { retryCount: 1, retryTime: 100 }) {
|
|
1633
|
+
const sdk = _DDPSDK.create(url, retryOptions);
|
|
1634
|
+
yield sdk.connection.connect();
|
|
1635
|
+
return sdk;
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
};
|
|
1639
|
+
exports.DDPSDK = DDPSDK2;
|
|
1640
|
+
}
|
|
1641
|
+
});
|
|
1642
|
+
|
|
1643
|
+
// node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/legacy/RocketchatSDKLegacy.js
|
|
1644
|
+
var require_RocketchatSDKLegacy = __commonJS({
|
|
1645
|
+
"node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/legacy/RocketchatSDKLegacy.js"(exports) {
|
|
1646
|
+
"use strict";
|
|
1647
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1648
|
+
function adopt(value) {
|
|
1649
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
1650
|
+
resolve3(value);
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
1654
|
+
function fulfilled(value) {
|
|
1655
|
+
try {
|
|
1656
|
+
step(generator.next(value));
|
|
1657
|
+
} catch (e) {
|
|
1658
|
+
reject(e);
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
function rejected(value) {
|
|
1662
|
+
try {
|
|
1663
|
+
step(generator["throw"](value));
|
|
1664
|
+
} catch (e) {
|
|
1665
|
+
reject(e);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
function step(result) {
|
|
1669
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1670
|
+
}
|
|
1671
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1672
|
+
});
|
|
1673
|
+
};
|
|
1674
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1675
|
+
exports.RocketchatSdkLegacyImpl = void 0;
|
|
1676
|
+
var api_client_1 = require_dist();
|
|
1677
|
+
var emitter_1 = require_dist2();
|
|
1678
|
+
var ClientStream_1 = require_ClientStream();
|
|
1679
|
+
var Connection_1 = require_Connection();
|
|
1680
|
+
var DDPDispatcher_1 = require_DDPDispatcher();
|
|
1681
|
+
var DDPSDK_1 = require_DDPSDK();
|
|
1682
|
+
var TimeoutControl_1 = require_TimeoutControl();
|
|
1683
|
+
var Account_1 = require_Account();
|
|
1684
|
+
var RocketchatSdkLegacyImpl = class _RocketchatSdkLegacyImpl extends DDPSDK_1.DDPSDK {
|
|
1685
|
+
constructor() {
|
|
1686
|
+
super(...arguments);
|
|
1687
|
+
this.ev = new emitter_1.Emitter();
|
|
1688
|
+
this.subscribeNotifyUser = () => {
|
|
1689
|
+
return Promise.all([
|
|
1690
|
+
this.stream("notify-user", `${this.account.uid}/message`, (...args) => this.ev.emit("user-message", args)),
|
|
1691
|
+
this.stream("notify-user", `${this.account.uid}/notification`, (...args) => this.ev.emit("notification", args)),
|
|
1692
|
+
this.stream("notify-user", `${this.account.uid}/rooms-changed`, (...args) => this.ev.emit("rooms-changed", args)),
|
|
1693
|
+
this.stream("notify-user", `${this.account.uid}/subscriptions-changed`, (...args) => this.ev.emit("subscriptions-changed", args)),
|
|
1694
|
+
this.stream("notify-user", `${this.account.uid}/uiInteraction`, (...args) => this.ev.emit("uiInteraction", args))
|
|
1695
|
+
]);
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
get url() {
|
|
1699
|
+
return this.connection.url;
|
|
1700
|
+
}
|
|
1701
|
+
get users() {
|
|
1702
|
+
const self = this;
|
|
1703
|
+
return {
|
|
1704
|
+
all(fields) {
|
|
1705
|
+
return self.rest.get("/v1/users.list", { fields: JSON.stringify(fields) });
|
|
1706
|
+
},
|
|
1707
|
+
allNames() {
|
|
1708
|
+
return self.rest.get("/v1/users.list", { fields: JSON.stringify({ name: 1 }) });
|
|
1709
|
+
},
|
|
1710
|
+
allIDs() {
|
|
1711
|
+
return self.rest.get("/v1/users.list", { fields: JSON.stringify({ _id: 1 }) });
|
|
1712
|
+
},
|
|
1713
|
+
online(fields) {
|
|
1714
|
+
return self.rest.get("/v1/users.list", { fields: JSON.stringify(fields), query: JSON.stringify({ status: { $ne: "offline" } }) });
|
|
1715
|
+
},
|
|
1716
|
+
onlineNames() {
|
|
1717
|
+
return self.rest.get("/v1/users.list", {
|
|
1718
|
+
fields: JSON.stringify({ name: 1 }),
|
|
1719
|
+
query: JSON.stringify({ status: { $ne: "offline" } })
|
|
1720
|
+
});
|
|
1721
|
+
},
|
|
1722
|
+
onlineIds() {
|
|
1723
|
+
return self.rest.get("/v1/users.list", {
|
|
1724
|
+
fields: JSON.stringify({ _id: 1 }),
|
|
1725
|
+
query: JSON.stringify({ status: { $ne: "offline" } })
|
|
1726
|
+
});
|
|
1727
|
+
},
|
|
1728
|
+
info(username) {
|
|
1729
|
+
return self.rest.get("/v1/users.info", { username });
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
get rooms() {
|
|
1734
|
+
const self = this;
|
|
1735
|
+
return {
|
|
1736
|
+
info: (args) => {
|
|
1737
|
+
return self.rest.get("/v1/rooms.info", args);
|
|
1738
|
+
},
|
|
1739
|
+
join: (rid) => {
|
|
1740
|
+
return self.rest.post("/v1/channels.join", { roomId: rid });
|
|
1741
|
+
},
|
|
1742
|
+
load: (rid, lastUpdate) => {
|
|
1743
|
+
return self.rest.get("/v1/chat.syncMessages", { roomId: rid, lastUpdate: lastUpdate.toISOString() });
|
|
1744
|
+
},
|
|
1745
|
+
leave: (rid) => {
|
|
1746
|
+
return self.rest.post("/v1/channels.leave", { roomId: rid });
|
|
1747
|
+
}
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
joinRoom(args) {
|
|
1751
|
+
return this.rest.post("/v1/channels.join", { roomId: args.rid });
|
|
1752
|
+
}
|
|
1753
|
+
loadHistory(rid, lastUpdate) {
|
|
1754
|
+
return this.rest.get("/v1/chat.syncMessages", { roomId: rid, lastUpdate: lastUpdate.toISOString() });
|
|
1755
|
+
}
|
|
1756
|
+
leaveRoom(rid) {
|
|
1757
|
+
return this.rest.post("/v1/channels.leave", { roomId: rid });
|
|
1758
|
+
}
|
|
1759
|
+
get dm() {
|
|
1760
|
+
const self = this;
|
|
1761
|
+
return {
|
|
1762
|
+
create(username) {
|
|
1763
|
+
return self.rest.post("/v1/im.create", { username });
|
|
1764
|
+
}
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1767
|
+
channelInfo(args) {
|
|
1768
|
+
return this.rest.get("/v1/channels.info", args);
|
|
1769
|
+
}
|
|
1770
|
+
privateInfo(args) {
|
|
1771
|
+
return this.rest.get("/v1/groups.info", args);
|
|
1772
|
+
}
|
|
1773
|
+
editMessage(args) {
|
|
1774
|
+
return this.rest.post("/v1/chat.update", args);
|
|
1775
|
+
}
|
|
1776
|
+
setReaction(emoji, messageId) {
|
|
1777
|
+
return this.rest.post("/v1/chat.react", { emoji, messageId });
|
|
1778
|
+
}
|
|
1779
|
+
createDirectMessage(username) {
|
|
1780
|
+
return this.rest.post("/v1/im.create", { username });
|
|
1781
|
+
}
|
|
1782
|
+
sendMessage(message, rid) {
|
|
1783
|
+
return this.rest.post("/v1/chat.sendMessage", {
|
|
1784
|
+
message: typeof message === "string" ? {
|
|
1785
|
+
msg: message,
|
|
1786
|
+
rid
|
|
1787
|
+
} : Object.assign(Object.assign({}, message), { rid })
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
resume({ token }) {
|
|
1791
|
+
return this.account.loginWithToken(token);
|
|
1792
|
+
}
|
|
1793
|
+
login(credentials) {
|
|
1794
|
+
return this.account.loginWithPassword(credentials.username, credentials.password);
|
|
1795
|
+
}
|
|
1796
|
+
onMessage(cb) {
|
|
1797
|
+
return this.ev.on("message", cb);
|
|
1798
|
+
}
|
|
1799
|
+
methodCall(method, ...args) {
|
|
1800
|
+
return this.client.callAsync(method, ...args);
|
|
1801
|
+
}
|
|
1802
|
+
subscribe(topic, ...args) {
|
|
1803
|
+
return this.client.subscribe(topic, ...args).ready();
|
|
1804
|
+
}
|
|
1805
|
+
subscribeRoom(rid) {
|
|
1806
|
+
return Promise.all([
|
|
1807
|
+
this.stream("room-messages", rid, (...args) => this.ev.emit("message", args)),
|
|
1808
|
+
this.stream("notify-room", `${rid}/typing`, (...args) => this.ev.emit("typing", args)),
|
|
1809
|
+
this.stream("notify-room", `${rid}/deleteMessage`, (...args) => this.ev.emit("deleteMessage", args))
|
|
1810
|
+
]);
|
|
1811
|
+
}
|
|
1812
|
+
subscribeNotifyAll() {
|
|
1813
|
+
return Promise.all([
|
|
1814
|
+
// this.stream('notify-all', 'roles-change', (...args) => this.ev.emit('roles-change', args)),
|
|
1815
|
+
// this.stream('notify-all', 'updateEmojiCustom', (...args) => this.ev.emit('updateEmojiCustom', args)),
|
|
1816
|
+
// this.stream('notify-all', 'deleteEmojiCustom', (...args) => this.ev.emit('deleteEmojiCustom', args)),
|
|
1817
|
+
// this.stream('notify-all', 'updateAvatar', (...args) => this.ev.emit('updateAvatar', args)),
|
|
1818
|
+
this.stream("notify-all", "public-settings-changed", (...args) => this.ev.emit("public-settings-changed", args))
|
|
1819
|
+
]);
|
|
1820
|
+
}
|
|
1821
|
+
subscribeLoggedNotify() {
|
|
1822
|
+
return Promise.all([
|
|
1823
|
+
this.stream("notify-logged", "Users:NameChanged", (...args) => this.ev.emit("Users:NameChanged", args)),
|
|
1824
|
+
this.stream("notify-logged", "Users:Deleted", (...args) => this.ev.emit("Users:Deleted", args)),
|
|
1825
|
+
this.stream("notify-logged", "updateAvatar", (...args) => this.ev.emit("updateAvatar", args)),
|
|
1826
|
+
this.stream("notify-logged", "updateEmojiCustom", (...args) => this.ev.emit("updateEmojiCustom", args)),
|
|
1827
|
+
this.stream("notify-logged", "deleteEmojiCustom", (...args) => this.ev.emit("deleteEmojiCustom", args)),
|
|
1828
|
+
this.stream("notify-logged", "roles-change", (...args) => this.ev.emit("roles-change", args)),
|
|
1829
|
+
this.stream("notify-logged", "permissions-changed", (...args) => this.ev.emit("permissions-changed", args))
|
|
1830
|
+
]);
|
|
1831
|
+
}
|
|
1832
|
+
onStreamData(event, cb) {
|
|
1833
|
+
return this.ev.on(event, cb);
|
|
1834
|
+
}
|
|
1835
|
+
disconnect() {
|
|
1836
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1837
|
+
return this.connection.close();
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
connect(_options) {
|
|
1841
|
+
return this.connection.connect();
|
|
1842
|
+
}
|
|
1843
|
+
unsubscribe(subscription) {
|
|
1844
|
+
return this.client.unsubscribe(subscription);
|
|
1845
|
+
}
|
|
1846
|
+
unsubscribeAll() {
|
|
1847
|
+
return Promise.all(Object.entries(this.client.subscriptions).map(([, subscription]) => this.client.unsubscribe(subscription)));
|
|
1848
|
+
}
|
|
1849
|
+
static create(url, retryOptions = { retryCount: 1, retryTime: 100 }) {
|
|
1850
|
+
const ddp = new DDPDispatcher_1.DDPDispatcher();
|
|
1851
|
+
const connection = Connection_1.ConnectionImpl.create(url, WebSocket, ddp, retryOptions);
|
|
1852
|
+
const stream = new ClientStream_1.ClientStreamImpl(ddp, ddp);
|
|
1853
|
+
const account = new Account_1.AccountImpl(stream);
|
|
1854
|
+
const timeoutControl = TimeoutControl_1.TimeoutControl.create(ddp, connection);
|
|
1855
|
+
const rest = new class RestApiClient extends api_client_1.RestClient {
|
|
1856
|
+
getCredentials() {
|
|
1857
|
+
var _a, _b;
|
|
1858
|
+
if (!account.uid || !((_a = account.user) === null || _a === void 0 ? void 0 : _a.token)) {
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
return {
|
|
1862
|
+
"X-User-Id": account.uid,
|
|
1863
|
+
"X-Auth-Token": (_b = account.user) === null || _b === void 0 ? void 0 : _b.token
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
}({ baseUrl: url });
|
|
1867
|
+
const sdk = new _RocketchatSdkLegacyImpl(connection, stream, account, timeoutControl, rest);
|
|
1868
|
+
connection.on("connected", () => {
|
|
1869
|
+
Object.entries(stream.subscriptions).forEach(([, sub]) => {
|
|
1870
|
+
ddp.subscribeWithId(sub.id, sub.name, sub.params);
|
|
1871
|
+
});
|
|
1872
|
+
});
|
|
1873
|
+
return sdk;
|
|
1874
|
+
}
|
|
1875
|
+
};
|
|
1876
|
+
exports.RocketchatSdkLegacyImpl = RocketchatSdkLegacyImpl;
|
|
1877
|
+
}
|
|
1878
|
+
});
|
|
1879
|
+
|
|
1880
|
+
// node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/livechat/LivechatClientImpl.js
|
|
1881
|
+
var require_LivechatClientImpl = __commonJS({
|
|
1882
|
+
"node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/livechat/LivechatClientImpl.js"(exports) {
|
|
1883
|
+
"use strict";
|
|
1884
|
+
var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
1885
|
+
function adopt(value) {
|
|
1886
|
+
return value instanceof P ? value : new P(function(resolve3) {
|
|
1887
|
+
resolve3(value);
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
return new (P || (P = Promise))(function(resolve3, reject) {
|
|
1891
|
+
function fulfilled(value) {
|
|
1892
|
+
try {
|
|
1893
|
+
step(generator.next(value));
|
|
1894
|
+
} catch (e) {
|
|
1895
|
+
reject(e);
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
function rejected(value) {
|
|
1899
|
+
try {
|
|
1900
|
+
step(generator["throw"](value));
|
|
1901
|
+
} catch (e) {
|
|
1902
|
+
reject(e);
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
function step(result) {
|
|
1906
|
+
result.done ? resolve3(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1907
|
+
}
|
|
1908
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1909
|
+
});
|
|
1910
|
+
};
|
|
1911
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1912
|
+
exports.LivechatClientImpl = void 0;
|
|
1913
|
+
var api_client_1 = require_dist();
|
|
1914
|
+
var emitter_1 = require_dist2();
|
|
1915
|
+
var ClientStream_1 = require_ClientStream();
|
|
1916
|
+
var Connection_1 = require_Connection();
|
|
1917
|
+
var DDPDispatcher_1 = require_DDPDispatcher();
|
|
1918
|
+
var DDPSDK_1 = require_DDPSDK();
|
|
1919
|
+
var TimeoutControl_1 = require_TimeoutControl();
|
|
1920
|
+
var Account_1 = require_Account();
|
|
1921
|
+
var LivechatClientImpl = class _LivechatClientImpl extends DDPSDK_1.DDPSDK {
|
|
1922
|
+
constructor() {
|
|
1923
|
+
super(...arguments);
|
|
1924
|
+
this.credentials = { token: this.token };
|
|
1925
|
+
this.ev = new emitter_1.Emitter();
|
|
1926
|
+
}
|
|
1927
|
+
subscribeRoom(rid) {
|
|
1928
|
+
return Promise.all([
|
|
1929
|
+
this.onRoomMessage(rid, (...args) => this.ev.emit("message", args)),
|
|
1930
|
+
this.onRoomUserActivity(rid, (...args) => this.ev.emit("userActivity", args)),
|
|
1931
|
+
this.onRoomDeleteMessage(rid, (...args) => this.ev.emit("delete", args))
|
|
1932
|
+
]);
|
|
1933
|
+
}
|
|
1934
|
+
onMessage(cb) {
|
|
1935
|
+
return this.ev.on("message", (args) => cb(...args));
|
|
1936
|
+
}
|
|
1937
|
+
onUserActivity(cb) {
|
|
1938
|
+
return this.ev.on("userActivity", (args) => args[1] && cb(args[0], args[1]));
|
|
1939
|
+
}
|
|
1940
|
+
onRoomMessage(rid, cb) {
|
|
1941
|
+
return this.stream("room-messages", [rid, { token: this.token, visitorToken: this.token }], cb).stop;
|
|
1942
|
+
}
|
|
1943
|
+
onRoomUserActivity(rid, cb) {
|
|
1944
|
+
return this.stream("notify-room", [`${rid}/user-activity`, { token: this.token, visitorToken: this.token }], cb).stop;
|
|
1945
|
+
}
|
|
1946
|
+
onRoomDeleteMessage(rid, cb) {
|
|
1947
|
+
return this.stream("notify-room", [`${rid}/deleteMessage`, { token: this.token, visitorToken: this.token }], cb).stop;
|
|
1948
|
+
}
|
|
1949
|
+
onAgentChange(rid, cb) {
|
|
1950
|
+
return this.stream("livechat-room", [rid, { token: this.token, visitorToken: this.token }], (data) => {
|
|
1951
|
+
if (data.type === "agentData") {
|
|
1952
|
+
cb(data.data);
|
|
1953
|
+
}
|
|
1954
|
+
}).stop;
|
|
1955
|
+
}
|
|
1956
|
+
onAgentStatusChange(rid, cb) {
|
|
1957
|
+
return this.stream("livechat-room", [rid, { token: this.token, visitorToken: this.token }], (data) => {
|
|
1958
|
+
if (data.type === "agentStatus") {
|
|
1959
|
+
cb(data.status);
|
|
1960
|
+
}
|
|
1961
|
+
}).stop;
|
|
1962
|
+
}
|
|
1963
|
+
onQueuePositionChange(rid, cb) {
|
|
1964
|
+
return this.stream("livechat-room", rid, (data) => {
|
|
1965
|
+
if (data.type === "queueData") {
|
|
1966
|
+
cb(data.data);
|
|
1967
|
+
}
|
|
1968
|
+
}).stop;
|
|
1969
|
+
}
|
|
1970
|
+
onVisitorChange(rid, cb) {
|
|
1971
|
+
return this.stream("livechat-room", [rid, { token: this.token, visitorToken: this.token }], (data) => {
|
|
1972
|
+
if (data.type === "visitorData") {
|
|
1973
|
+
cb(data.visitor);
|
|
1974
|
+
}
|
|
1975
|
+
}).stop;
|
|
1976
|
+
}
|
|
1977
|
+
notifyVisitorActivity(rid, username, activity) {
|
|
1978
|
+
return this.client.callAsync("stream-notify-room", `${rid}/user-activity`, username, activity, { token: this.token });
|
|
1979
|
+
}
|
|
1980
|
+
notifyCallDeclined(rid) {
|
|
1981
|
+
return this.client.callAsync("stream-notify-room", `${rid}/call`, "decline");
|
|
1982
|
+
}
|
|
1983
|
+
// API GETTERS
|
|
1984
|
+
config(params) {
|
|
1985
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1986
|
+
const { config } = yield this.rest.get("/v1/livechat/config", params);
|
|
1987
|
+
return config;
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
room(params) {
|
|
1991
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1992
|
+
if (!this.token) {
|
|
1993
|
+
throw new Error("Invalid token");
|
|
1994
|
+
}
|
|
1995
|
+
const result = yield this.rest.get("/v1/livechat/room", Object.assign(Object.assign({}, params), { token: this.token }));
|
|
1996
|
+
function isRoomObject(room) {
|
|
1997
|
+
return room.room !== void 0;
|
|
1998
|
+
}
|
|
1999
|
+
if (isRoomObject(result)) {
|
|
2000
|
+
return result.room;
|
|
2001
|
+
}
|
|
2002
|
+
return result;
|
|
2003
|
+
});
|
|
2004
|
+
}
|
|
2005
|
+
visitor(params) {
|
|
2006
|
+
if (!this.token) {
|
|
2007
|
+
throw new Error("Invalid token");
|
|
2008
|
+
}
|
|
2009
|
+
const endpoint = `/v1/livechat/visitor/${this.token}`;
|
|
2010
|
+
return this.rest.get(endpoint, params);
|
|
2011
|
+
}
|
|
2012
|
+
nextAgent(params) {
|
|
2013
|
+
if (!this.token) {
|
|
2014
|
+
throw new Error("Invalid token");
|
|
2015
|
+
}
|
|
2016
|
+
return this.rest.get(`/v1/livechat/agent.next/${this.token}`, params);
|
|
2017
|
+
}
|
|
2018
|
+
agent(rid) {
|
|
2019
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2020
|
+
if (!this.token) {
|
|
2021
|
+
throw new Error("Invalid token");
|
|
2022
|
+
}
|
|
2023
|
+
const { agent } = yield this.rest.get(`/v1/livechat/agent.info/${rid}/${this.token}`);
|
|
2024
|
+
return agent;
|
|
2025
|
+
});
|
|
2026
|
+
}
|
|
2027
|
+
message(id, params) {
|
|
2028
|
+
if (!this.token) {
|
|
2029
|
+
throw new Error("Invalid token");
|
|
2030
|
+
}
|
|
2031
|
+
return this.rest.get(`/v1/livechat/message/${id}`, Object.assign(Object.assign({}, params), { token: this.token }));
|
|
2032
|
+
}
|
|
2033
|
+
loadMessages(rid, params) {
|
|
2034
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2035
|
+
if (!this.token) {
|
|
2036
|
+
throw new Error("Invalid token");
|
|
2037
|
+
}
|
|
2038
|
+
const { messages } = yield this.rest.get(`/v1/livechat/messages.history/${rid}`, Object.assign(Object.assign({}, params), { token: this.token }));
|
|
2039
|
+
return messages;
|
|
2040
|
+
});
|
|
2041
|
+
}
|
|
2042
|
+
// API POST
|
|
2043
|
+
transferChat({ rid, department }) {
|
|
2044
|
+
if (!this.token) {
|
|
2045
|
+
throw new Error("Invalid token");
|
|
2046
|
+
}
|
|
2047
|
+
return this.rest.post("/v1/livechat/visitor/department.transfer", { rid, token: this.token, department });
|
|
2048
|
+
}
|
|
2049
|
+
grantVisitor(guest) {
|
|
2050
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2051
|
+
const result = yield this.rest.post("/v1/livechat/visitor", guest);
|
|
2052
|
+
this.token = result === null || result === void 0 ? void 0 : result.visitor.token;
|
|
2053
|
+
return result;
|
|
2054
|
+
});
|
|
2055
|
+
}
|
|
2056
|
+
login(guest) {
|
|
2057
|
+
return this.grantVisitor(guest);
|
|
2058
|
+
}
|
|
2059
|
+
closeChat({ rid }) {
|
|
2060
|
+
if (!this.token) {
|
|
2061
|
+
throw new Error("Invalid token");
|
|
2062
|
+
}
|
|
2063
|
+
return this.rest.post("/v1/livechat/room.close", { rid, token: this.token });
|
|
2064
|
+
}
|
|
2065
|
+
chatSurvey(params) {
|
|
2066
|
+
if (!this.token) {
|
|
2067
|
+
throw new Error("Invalid token");
|
|
2068
|
+
}
|
|
2069
|
+
return this.rest.post("/v1/livechat/room.survey", { rid: params.rid, token: this.token, data: params.data });
|
|
2070
|
+
}
|
|
2071
|
+
sendMessage(params) {
|
|
2072
|
+
if (!this.token) {
|
|
2073
|
+
throw new Error("Invalid token");
|
|
2074
|
+
}
|
|
2075
|
+
return this.rest.post("/v1/livechat/message", Object.assign(Object.assign({}, params), { token: this.token }));
|
|
2076
|
+
}
|
|
2077
|
+
sendOfflineMessage(params) {
|
|
2078
|
+
return this.rest.post("/v1/livechat/offline.message", params);
|
|
2079
|
+
}
|
|
2080
|
+
sendVisitorNavigation(params) {
|
|
2081
|
+
return this.rest.post("/v1/livechat/page.visited", params);
|
|
2082
|
+
}
|
|
2083
|
+
requestTranscript(email, { rid }) {
|
|
2084
|
+
if (!this.token) {
|
|
2085
|
+
throw new Error("Invalid token");
|
|
2086
|
+
}
|
|
2087
|
+
return this.rest.post("/v1/livechat/transcript", { token: this.token, rid, email });
|
|
2088
|
+
}
|
|
2089
|
+
sendCustomField(params) {
|
|
2090
|
+
return this.rest.post("/v1/livechat/custom.field", params);
|
|
2091
|
+
}
|
|
2092
|
+
sendCustomFields(params) {
|
|
2093
|
+
return this.rest.post("/v1/livechat/custom.fields", params);
|
|
2094
|
+
}
|
|
2095
|
+
updateVisitorStatus(newStatus) {
|
|
2096
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2097
|
+
if (!this.token) {
|
|
2098
|
+
throw new Error("Invalid token");
|
|
2099
|
+
}
|
|
2100
|
+
const { status } = yield this.rest.post("/v1/livechat/visitor.status", { token: this.token, status: newStatus });
|
|
2101
|
+
return status;
|
|
2102
|
+
});
|
|
2103
|
+
}
|
|
2104
|
+
uploadFile(rid, file) {
|
|
2105
|
+
if (!this.token) {
|
|
2106
|
+
throw new Error("Invalid token");
|
|
2107
|
+
}
|
|
2108
|
+
if (!file) {
|
|
2109
|
+
throw new Error("Invalid file");
|
|
2110
|
+
}
|
|
2111
|
+
return new Promise((resolve3, reject) => {
|
|
2112
|
+
if (!this.token) {
|
|
2113
|
+
return reject(new Error("Invalid token"));
|
|
2114
|
+
}
|
|
2115
|
+
return this.rest.upload(`/v1/livechat/upload/${rid}`, { file }, {
|
|
2116
|
+
load: resolve3,
|
|
2117
|
+
error: reject
|
|
2118
|
+
}, { headers: { "x-visitor-token": this.token } });
|
|
2119
|
+
});
|
|
2120
|
+
}
|
|
2121
|
+
sendUiInteraction(payload, appId) {
|
|
2122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2123
|
+
if (!this.token) {
|
|
2124
|
+
throw new Error("Invalid token");
|
|
2125
|
+
}
|
|
2126
|
+
return this.rest.post(`/apps/ui.interaction/${appId}`, payload, { headers: { "x-visitor-token": this.token } });
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
// API DELETE
|
|
2130
|
+
deleteMessage(id, { rid }) {
|
|
2131
|
+
if (!this.token) {
|
|
2132
|
+
throw new Error("Invalid token");
|
|
2133
|
+
}
|
|
2134
|
+
return this.rest.delete(`/v1/livechat/message/${id}`, { rid, token: this.token });
|
|
2135
|
+
}
|
|
2136
|
+
deleteVisitor() {
|
|
2137
|
+
if (!this.token) {
|
|
2138
|
+
throw new Error("Invalid token");
|
|
2139
|
+
}
|
|
2140
|
+
return this.rest.delete(`/v1/livechat/visitor/${this.token}`);
|
|
2141
|
+
}
|
|
2142
|
+
// API PUT
|
|
2143
|
+
editMessage(id, params) {
|
|
2144
|
+
return this.rest.put(`/v1/livechat/message/${id}`, params);
|
|
2145
|
+
}
|
|
2146
|
+
unsubscribeAll() {
|
|
2147
|
+
const subscriptions = Array.from(this.client.subscriptions.keys());
|
|
2148
|
+
return Promise.all(subscriptions.map((subscription) => this.client.unsubscribe(subscription)));
|
|
2149
|
+
}
|
|
2150
|
+
static create(url, retryOptions = { retryCount: 3, retryTime: 1e4 }) {
|
|
2151
|
+
const ddp = new DDPDispatcher_1.DDPDispatcher();
|
|
2152
|
+
const connection = Connection_1.ConnectionImpl.create(url, WebSocket, ddp, retryOptions);
|
|
2153
|
+
const stream = new ClientStream_1.ClientStreamImpl(ddp, ddp);
|
|
2154
|
+
const account = new Account_1.AccountImpl(stream);
|
|
2155
|
+
const timeoutControl = TimeoutControl_1.TimeoutControl.create(ddp, connection);
|
|
2156
|
+
const rest = new api_client_1.RestClient({ baseUrl: url.replace(/^ws/, "http") });
|
|
2157
|
+
const sdk = new _LivechatClientImpl(connection, stream, account, timeoutControl, rest);
|
|
2158
|
+
connection.on("connected", () => {
|
|
2159
|
+
for (const [, sub] of stream.subscriptions.entries()) {
|
|
2160
|
+
ddp.subscribeWithId(sub.id, sub.name, sub.params);
|
|
2161
|
+
}
|
|
2162
|
+
});
|
|
2163
|
+
return sdk;
|
|
2164
|
+
}
|
|
2165
|
+
};
|
|
2166
|
+
exports.LivechatClientImpl = LivechatClientImpl;
|
|
2167
|
+
}
|
|
2168
|
+
});
|
|
2169
|
+
|
|
2170
|
+
// node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/index.js
|
|
2171
|
+
var require_dist3 = __commonJS({
|
|
2172
|
+
"node_modules/.pnpm/@rocket.chat+ddp-client@1.1.1_@rocket.chat+emitter@0.33.0_@rocket.chat+icons@0.48.0/node_modules/@rocket.chat/ddp-client/dist/index.js"(exports) {
|
|
2173
|
+
"use strict";
|
|
2174
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
2175
|
+
if (k2 === void 0) k2 = k;
|
|
2176
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2177
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2178
|
+
desc = { enumerable: true, get: function() {
|
|
2179
|
+
return m[k];
|
|
2180
|
+
} };
|
|
2181
|
+
}
|
|
2182
|
+
Object.defineProperty(o, k2, desc);
|
|
2183
|
+
}) : (function(o, m, k, k2) {
|
|
2184
|
+
if (k2 === void 0) k2 = k;
|
|
2185
|
+
o[k2] = m[k];
|
|
2186
|
+
}));
|
|
2187
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
2188
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p)) __createBinding(exports2, m, p);
|
|
2189
|
+
};
|
|
2190
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2191
|
+
__exportStar(require_DDPSDK(), exports);
|
|
2192
|
+
__exportStar(require_RocketchatSDKLegacy(), exports);
|
|
2193
|
+
__exportStar(require_LivechatClientImpl(), exports);
|
|
2194
|
+
}
|
|
2195
|
+
});
|
|
2196
|
+
|
|
2197
|
+
// node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/unicode.js
|
|
2198
|
+
var require_unicode = __commonJS({
|
|
2199
|
+
"node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/unicode.js"(exports, module) {
|
|
2200
|
+
module.exports.Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
|
2201
|
+
module.exports.ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
|
|
2202
|
+
module.exports.ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
|
|
2203
|
+
}
|
|
2204
|
+
});
|
|
2205
|
+
|
|
2206
|
+
// node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/util.js
|
|
2207
|
+
var require_util = __commonJS({
|
|
2208
|
+
"node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/util.js"(exports, module) {
|
|
2209
|
+
var unicode = require_unicode();
|
|
2210
|
+
module.exports = {
|
|
2211
|
+
isSpaceSeparator(c) {
|
|
2212
|
+
return typeof c === "string" && unicode.Space_Separator.test(c);
|
|
2213
|
+
},
|
|
2214
|
+
isIdStartChar(c) {
|
|
2215
|
+
return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c === "$" || c === "_" || unicode.ID_Start.test(c));
|
|
2216
|
+
},
|
|
2217
|
+
isIdContinueChar(c) {
|
|
2218
|
+
return typeof c === "string" && (c >= "a" && c <= "z" || c >= "A" && c <= "Z" || c >= "0" && c <= "9" || c === "$" || c === "_" || c === "\u200C" || c === "\u200D" || unicode.ID_Continue.test(c));
|
|
2219
|
+
},
|
|
2220
|
+
isDigit(c) {
|
|
2221
|
+
return typeof c === "string" && /[0-9]/.test(c);
|
|
2222
|
+
},
|
|
2223
|
+
isHexDigit(c) {
|
|
2224
|
+
return typeof c === "string" && /[0-9A-Fa-f]/.test(c);
|
|
2225
|
+
}
|
|
2226
|
+
};
|
|
2227
|
+
}
|
|
2228
|
+
});
|
|
2229
|
+
|
|
2230
|
+
// node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/parse.js
|
|
2231
|
+
var require_parse = __commonJS({
|
|
2232
|
+
"node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/parse.js"(exports, module) {
|
|
2233
|
+
var util = require_util();
|
|
2234
|
+
var source;
|
|
2235
|
+
var parseState;
|
|
2236
|
+
var stack;
|
|
2237
|
+
var pos;
|
|
2238
|
+
var line;
|
|
2239
|
+
var column;
|
|
2240
|
+
var token;
|
|
2241
|
+
var key;
|
|
2242
|
+
var root;
|
|
2243
|
+
module.exports = function parse(text, reviver) {
|
|
2244
|
+
source = String(text);
|
|
2245
|
+
parseState = "start";
|
|
2246
|
+
stack = [];
|
|
2247
|
+
pos = 0;
|
|
2248
|
+
line = 1;
|
|
2249
|
+
column = 0;
|
|
2250
|
+
token = void 0;
|
|
2251
|
+
key = void 0;
|
|
2252
|
+
root = void 0;
|
|
2253
|
+
do {
|
|
2254
|
+
token = lex();
|
|
2255
|
+
parseStates[parseState]();
|
|
2256
|
+
} while (token.type !== "eof");
|
|
2257
|
+
if (typeof reviver === "function") {
|
|
2258
|
+
return internalize({ "": root }, "", reviver);
|
|
2259
|
+
}
|
|
2260
|
+
return root;
|
|
2261
|
+
};
|
|
2262
|
+
function internalize(holder, name, reviver) {
|
|
2263
|
+
const value = holder[name];
|
|
2264
|
+
if (value != null && typeof value === "object") {
|
|
2265
|
+
if (Array.isArray(value)) {
|
|
2266
|
+
for (let i = 0; i < value.length; i++) {
|
|
2267
|
+
const key2 = String(i);
|
|
2268
|
+
const replacement = internalize(value, key2, reviver);
|
|
2269
|
+
if (replacement === void 0) {
|
|
2270
|
+
delete value[key2];
|
|
2271
|
+
} else {
|
|
2272
|
+
Object.defineProperty(value, key2, {
|
|
2273
|
+
value: replacement,
|
|
2274
|
+
writable: true,
|
|
2275
|
+
enumerable: true,
|
|
2276
|
+
configurable: true
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
} else {
|
|
2281
|
+
for (const key2 in value) {
|
|
2282
|
+
const replacement = internalize(value, key2, reviver);
|
|
2283
|
+
if (replacement === void 0) {
|
|
2284
|
+
delete value[key2];
|
|
2285
|
+
} else {
|
|
2286
|
+
Object.defineProperty(value, key2, {
|
|
2287
|
+
value: replacement,
|
|
2288
|
+
writable: true,
|
|
2289
|
+
enumerable: true,
|
|
2290
|
+
configurable: true
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
return reviver.call(holder, name, value);
|
|
2297
|
+
}
|
|
2298
|
+
var lexState;
|
|
2299
|
+
var buffer;
|
|
2300
|
+
var doubleQuote;
|
|
2301
|
+
var sign;
|
|
2302
|
+
var c;
|
|
2303
|
+
function lex() {
|
|
2304
|
+
lexState = "default";
|
|
2305
|
+
buffer = "";
|
|
2306
|
+
doubleQuote = false;
|
|
2307
|
+
sign = 1;
|
|
2308
|
+
for (; ; ) {
|
|
2309
|
+
c = peek();
|
|
2310
|
+
const token2 = lexStates[lexState]();
|
|
2311
|
+
if (token2) {
|
|
2312
|
+
return token2;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
function peek() {
|
|
2317
|
+
if (source[pos]) {
|
|
2318
|
+
return String.fromCodePoint(source.codePointAt(pos));
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
function read() {
|
|
2322
|
+
const c2 = peek();
|
|
2323
|
+
if (c2 === "\n") {
|
|
2324
|
+
line++;
|
|
2325
|
+
column = 0;
|
|
2326
|
+
} else if (c2) {
|
|
2327
|
+
column += c2.length;
|
|
2328
|
+
} else {
|
|
2329
|
+
column++;
|
|
2330
|
+
}
|
|
2331
|
+
if (c2) {
|
|
2332
|
+
pos += c2.length;
|
|
2333
|
+
}
|
|
2334
|
+
return c2;
|
|
2335
|
+
}
|
|
2336
|
+
var lexStates = {
|
|
2337
|
+
default() {
|
|
2338
|
+
switch (c) {
|
|
2339
|
+
case " ":
|
|
2340
|
+
case "\v":
|
|
2341
|
+
case "\f":
|
|
2342
|
+
case " ":
|
|
2343
|
+
case "\xA0":
|
|
2344
|
+
case "\uFEFF":
|
|
2345
|
+
case "\n":
|
|
2346
|
+
case "\r":
|
|
2347
|
+
case "\u2028":
|
|
2348
|
+
case "\u2029":
|
|
2349
|
+
read();
|
|
2350
|
+
return;
|
|
2351
|
+
case "/":
|
|
2352
|
+
read();
|
|
2353
|
+
lexState = "comment";
|
|
2354
|
+
return;
|
|
2355
|
+
case void 0:
|
|
2356
|
+
read();
|
|
2357
|
+
return newToken("eof");
|
|
2358
|
+
}
|
|
2359
|
+
if (util.isSpaceSeparator(c)) {
|
|
2360
|
+
read();
|
|
2361
|
+
return;
|
|
2362
|
+
}
|
|
2363
|
+
return lexStates[parseState]();
|
|
2364
|
+
},
|
|
2365
|
+
comment() {
|
|
2366
|
+
switch (c) {
|
|
2367
|
+
case "*":
|
|
2368
|
+
read();
|
|
2369
|
+
lexState = "multiLineComment";
|
|
2370
|
+
return;
|
|
2371
|
+
case "/":
|
|
2372
|
+
read();
|
|
2373
|
+
lexState = "singleLineComment";
|
|
2374
|
+
return;
|
|
2375
|
+
}
|
|
2376
|
+
throw invalidChar(read());
|
|
2377
|
+
},
|
|
2378
|
+
multiLineComment() {
|
|
2379
|
+
switch (c) {
|
|
2380
|
+
case "*":
|
|
2381
|
+
read();
|
|
2382
|
+
lexState = "multiLineCommentAsterisk";
|
|
2383
|
+
return;
|
|
2384
|
+
case void 0:
|
|
2385
|
+
throw invalidChar(read());
|
|
2386
|
+
}
|
|
2387
|
+
read();
|
|
2388
|
+
},
|
|
2389
|
+
multiLineCommentAsterisk() {
|
|
2390
|
+
switch (c) {
|
|
2391
|
+
case "*":
|
|
2392
|
+
read();
|
|
2393
|
+
return;
|
|
2394
|
+
case "/":
|
|
2395
|
+
read();
|
|
2396
|
+
lexState = "default";
|
|
2397
|
+
return;
|
|
2398
|
+
case void 0:
|
|
2399
|
+
throw invalidChar(read());
|
|
2400
|
+
}
|
|
2401
|
+
read();
|
|
2402
|
+
lexState = "multiLineComment";
|
|
2403
|
+
},
|
|
2404
|
+
singleLineComment() {
|
|
2405
|
+
switch (c) {
|
|
2406
|
+
case "\n":
|
|
2407
|
+
case "\r":
|
|
2408
|
+
case "\u2028":
|
|
2409
|
+
case "\u2029":
|
|
2410
|
+
read();
|
|
2411
|
+
lexState = "default";
|
|
2412
|
+
return;
|
|
2413
|
+
case void 0:
|
|
2414
|
+
read();
|
|
2415
|
+
return newToken("eof");
|
|
80
2416
|
}
|
|
81
|
-
|
|
82
|
-
|
|
2417
|
+
read();
|
|
2418
|
+
},
|
|
2419
|
+
value() {
|
|
2420
|
+
switch (c) {
|
|
2421
|
+
case "{":
|
|
2422
|
+
case "[":
|
|
2423
|
+
return newToken("punctuator", read());
|
|
2424
|
+
case "n":
|
|
2425
|
+
read();
|
|
2426
|
+
literal("ull");
|
|
2427
|
+
return newToken("null", null);
|
|
2428
|
+
case "t":
|
|
2429
|
+
read();
|
|
2430
|
+
literal("rue");
|
|
2431
|
+
return newToken("boolean", true);
|
|
2432
|
+
case "f":
|
|
2433
|
+
read();
|
|
2434
|
+
literal("alse");
|
|
2435
|
+
return newToken("boolean", false);
|
|
2436
|
+
case "-":
|
|
2437
|
+
case "+":
|
|
2438
|
+
if (read() === "-") {
|
|
2439
|
+
sign = -1;
|
|
2440
|
+
}
|
|
2441
|
+
lexState = "sign";
|
|
2442
|
+
return;
|
|
2443
|
+
case ".":
|
|
2444
|
+
buffer = read();
|
|
2445
|
+
lexState = "decimalPointLeading";
|
|
2446
|
+
return;
|
|
2447
|
+
case "0":
|
|
2448
|
+
buffer = read();
|
|
2449
|
+
lexState = "zero";
|
|
2450
|
+
return;
|
|
2451
|
+
case "1":
|
|
2452
|
+
case "2":
|
|
2453
|
+
case "3":
|
|
2454
|
+
case "4":
|
|
2455
|
+
case "5":
|
|
2456
|
+
case "6":
|
|
2457
|
+
case "7":
|
|
2458
|
+
case "8":
|
|
2459
|
+
case "9":
|
|
2460
|
+
buffer = read();
|
|
2461
|
+
lexState = "decimalInteger";
|
|
2462
|
+
return;
|
|
2463
|
+
case "I":
|
|
2464
|
+
read();
|
|
2465
|
+
literal("nfinity");
|
|
2466
|
+
return newToken("numeric", Infinity);
|
|
2467
|
+
case "N":
|
|
2468
|
+
read();
|
|
2469
|
+
literal("aN");
|
|
2470
|
+
return newToken("numeric", NaN);
|
|
2471
|
+
case '"':
|
|
2472
|
+
case "'":
|
|
2473
|
+
doubleQuote = read() === '"';
|
|
2474
|
+
buffer = "";
|
|
2475
|
+
lexState = "string";
|
|
2476
|
+
return;
|
|
2477
|
+
}
|
|
2478
|
+
throw invalidChar(read());
|
|
2479
|
+
},
|
|
2480
|
+
identifierNameStartEscape() {
|
|
2481
|
+
if (c !== "u") {
|
|
2482
|
+
throw invalidChar(read());
|
|
2483
|
+
}
|
|
2484
|
+
read();
|
|
2485
|
+
const u = unicodeEscape();
|
|
2486
|
+
switch (u) {
|
|
2487
|
+
case "$":
|
|
2488
|
+
case "_":
|
|
2489
|
+
break;
|
|
2490
|
+
default:
|
|
2491
|
+
if (!util.isIdStartChar(u)) {
|
|
2492
|
+
throw invalidIdentifier();
|
|
2493
|
+
}
|
|
2494
|
+
break;
|
|
2495
|
+
}
|
|
2496
|
+
buffer += u;
|
|
2497
|
+
lexState = "identifierName";
|
|
2498
|
+
},
|
|
2499
|
+
identifierName() {
|
|
2500
|
+
switch (c) {
|
|
2501
|
+
case "$":
|
|
2502
|
+
case "_":
|
|
2503
|
+
case "\u200C":
|
|
2504
|
+
case "\u200D":
|
|
2505
|
+
buffer += read();
|
|
2506
|
+
return;
|
|
2507
|
+
case "\\":
|
|
2508
|
+
read();
|
|
2509
|
+
lexState = "identifierNameEscape";
|
|
2510
|
+
return;
|
|
2511
|
+
}
|
|
2512
|
+
if (util.isIdContinueChar(c)) {
|
|
2513
|
+
buffer += read();
|
|
2514
|
+
return;
|
|
2515
|
+
}
|
|
2516
|
+
return newToken("identifier", buffer);
|
|
2517
|
+
},
|
|
2518
|
+
identifierNameEscape() {
|
|
2519
|
+
if (c !== "u") {
|
|
2520
|
+
throw invalidChar(read());
|
|
2521
|
+
}
|
|
2522
|
+
read();
|
|
2523
|
+
const u = unicodeEscape();
|
|
2524
|
+
switch (u) {
|
|
2525
|
+
case "$":
|
|
2526
|
+
case "_":
|
|
2527
|
+
case "\u200C":
|
|
2528
|
+
case "\u200D":
|
|
2529
|
+
break;
|
|
2530
|
+
default:
|
|
2531
|
+
if (!util.isIdContinueChar(u)) {
|
|
2532
|
+
throw invalidIdentifier();
|
|
2533
|
+
}
|
|
2534
|
+
break;
|
|
2535
|
+
}
|
|
2536
|
+
buffer += u;
|
|
2537
|
+
lexState = "identifierName";
|
|
2538
|
+
},
|
|
2539
|
+
sign() {
|
|
2540
|
+
switch (c) {
|
|
2541
|
+
case ".":
|
|
2542
|
+
buffer = read();
|
|
2543
|
+
lexState = "decimalPointLeading";
|
|
2544
|
+
return;
|
|
2545
|
+
case "0":
|
|
2546
|
+
buffer = read();
|
|
2547
|
+
lexState = "zero";
|
|
2548
|
+
return;
|
|
2549
|
+
case "1":
|
|
2550
|
+
case "2":
|
|
2551
|
+
case "3":
|
|
2552
|
+
case "4":
|
|
2553
|
+
case "5":
|
|
2554
|
+
case "6":
|
|
2555
|
+
case "7":
|
|
2556
|
+
case "8":
|
|
2557
|
+
case "9":
|
|
2558
|
+
buffer = read();
|
|
2559
|
+
lexState = "decimalInteger";
|
|
2560
|
+
return;
|
|
2561
|
+
case "I":
|
|
2562
|
+
read();
|
|
2563
|
+
literal("nfinity");
|
|
2564
|
+
return newToken("numeric", sign * Infinity);
|
|
2565
|
+
case "N":
|
|
2566
|
+
read();
|
|
2567
|
+
literal("aN");
|
|
2568
|
+
return newToken("numeric", NaN);
|
|
2569
|
+
}
|
|
2570
|
+
throw invalidChar(read());
|
|
2571
|
+
},
|
|
2572
|
+
zero() {
|
|
2573
|
+
switch (c) {
|
|
2574
|
+
case ".":
|
|
2575
|
+
buffer += read();
|
|
2576
|
+
lexState = "decimalPoint";
|
|
2577
|
+
return;
|
|
2578
|
+
case "e":
|
|
2579
|
+
case "E":
|
|
2580
|
+
buffer += read();
|
|
2581
|
+
lexState = "decimalExponent";
|
|
2582
|
+
return;
|
|
2583
|
+
case "x":
|
|
2584
|
+
case "X":
|
|
2585
|
+
buffer += read();
|
|
2586
|
+
lexState = "hexadecimal";
|
|
2587
|
+
return;
|
|
2588
|
+
}
|
|
2589
|
+
return newToken("numeric", sign * 0);
|
|
2590
|
+
},
|
|
2591
|
+
decimalInteger() {
|
|
2592
|
+
switch (c) {
|
|
2593
|
+
case ".":
|
|
2594
|
+
buffer += read();
|
|
2595
|
+
lexState = "decimalPoint";
|
|
2596
|
+
return;
|
|
2597
|
+
case "e":
|
|
2598
|
+
case "E":
|
|
2599
|
+
buffer += read();
|
|
2600
|
+
lexState = "decimalExponent";
|
|
2601
|
+
return;
|
|
2602
|
+
}
|
|
2603
|
+
if (util.isDigit(c)) {
|
|
2604
|
+
buffer += read();
|
|
2605
|
+
return;
|
|
2606
|
+
}
|
|
2607
|
+
return newToken("numeric", sign * Number(buffer));
|
|
2608
|
+
},
|
|
2609
|
+
decimalPointLeading() {
|
|
2610
|
+
if (util.isDigit(c)) {
|
|
2611
|
+
buffer += read();
|
|
2612
|
+
lexState = "decimalFraction";
|
|
2613
|
+
return;
|
|
2614
|
+
}
|
|
2615
|
+
throw invalidChar(read());
|
|
2616
|
+
},
|
|
2617
|
+
decimalPoint() {
|
|
2618
|
+
switch (c) {
|
|
2619
|
+
case "e":
|
|
2620
|
+
case "E":
|
|
2621
|
+
buffer += read();
|
|
2622
|
+
lexState = "decimalExponent";
|
|
2623
|
+
return;
|
|
2624
|
+
}
|
|
2625
|
+
if (util.isDigit(c)) {
|
|
2626
|
+
buffer += read();
|
|
2627
|
+
lexState = "decimalFraction";
|
|
2628
|
+
return;
|
|
2629
|
+
}
|
|
2630
|
+
return newToken("numeric", sign * Number(buffer));
|
|
2631
|
+
},
|
|
2632
|
+
decimalFraction() {
|
|
2633
|
+
switch (c) {
|
|
2634
|
+
case "e":
|
|
2635
|
+
case "E":
|
|
2636
|
+
buffer += read();
|
|
2637
|
+
lexState = "decimalExponent";
|
|
2638
|
+
return;
|
|
2639
|
+
}
|
|
2640
|
+
if (util.isDigit(c)) {
|
|
2641
|
+
buffer += read();
|
|
2642
|
+
return;
|
|
2643
|
+
}
|
|
2644
|
+
return newToken("numeric", sign * Number(buffer));
|
|
2645
|
+
},
|
|
2646
|
+
decimalExponent() {
|
|
2647
|
+
switch (c) {
|
|
2648
|
+
case "+":
|
|
2649
|
+
case "-":
|
|
2650
|
+
buffer += read();
|
|
2651
|
+
lexState = "decimalExponentSign";
|
|
2652
|
+
return;
|
|
2653
|
+
}
|
|
2654
|
+
if (util.isDigit(c)) {
|
|
2655
|
+
buffer += read();
|
|
2656
|
+
lexState = "decimalExponentInteger";
|
|
2657
|
+
return;
|
|
2658
|
+
}
|
|
2659
|
+
throw invalidChar(read());
|
|
2660
|
+
},
|
|
2661
|
+
decimalExponentSign() {
|
|
2662
|
+
if (util.isDigit(c)) {
|
|
2663
|
+
buffer += read();
|
|
2664
|
+
lexState = "decimalExponentInteger";
|
|
2665
|
+
return;
|
|
2666
|
+
}
|
|
2667
|
+
throw invalidChar(read());
|
|
2668
|
+
},
|
|
2669
|
+
decimalExponentInteger() {
|
|
2670
|
+
if (util.isDigit(c)) {
|
|
2671
|
+
buffer += read();
|
|
2672
|
+
return;
|
|
2673
|
+
}
|
|
2674
|
+
return newToken("numeric", sign * Number(buffer));
|
|
2675
|
+
},
|
|
2676
|
+
hexadecimal() {
|
|
2677
|
+
if (util.isHexDigit(c)) {
|
|
2678
|
+
buffer += read();
|
|
2679
|
+
lexState = "hexadecimalInteger";
|
|
2680
|
+
return;
|
|
2681
|
+
}
|
|
2682
|
+
throw invalidChar(read());
|
|
2683
|
+
},
|
|
2684
|
+
hexadecimalInteger() {
|
|
2685
|
+
if (util.isHexDigit(c)) {
|
|
2686
|
+
buffer += read();
|
|
2687
|
+
return;
|
|
2688
|
+
}
|
|
2689
|
+
return newToken("numeric", sign * Number(buffer));
|
|
2690
|
+
},
|
|
2691
|
+
string() {
|
|
2692
|
+
switch (c) {
|
|
2693
|
+
case "\\":
|
|
2694
|
+
read();
|
|
2695
|
+
buffer += escape();
|
|
2696
|
+
return;
|
|
2697
|
+
case '"':
|
|
2698
|
+
if (doubleQuote) {
|
|
2699
|
+
read();
|
|
2700
|
+
return newToken("string", buffer);
|
|
2701
|
+
}
|
|
2702
|
+
buffer += read();
|
|
2703
|
+
return;
|
|
2704
|
+
case "'":
|
|
2705
|
+
if (!doubleQuote) {
|
|
2706
|
+
read();
|
|
2707
|
+
return newToken("string", buffer);
|
|
2708
|
+
}
|
|
2709
|
+
buffer += read();
|
|
2710
|
+
return;
|
|
2711
|
+
case "\n":
|
|
2712
|
+
case "\r":
|
|
2713
|
+
throw invalidChar(read());
|
|
2714
|
+
case "\u2028":
|
|
2715
|
+
case "\u2029":
|
|
2716
|
+
separatorChar(c);
|
|
2717
|
+
break;
|
|
2718
|
+
case void 0:
|
|
2719
|
+
throw invalidChar(read());
|
|
2720
|
+
}
|
|
2721
|
+
buffer += read();
|
|
2722
|
+
},
|
|
2723
|
+
start() {
|
|
2724
|
+
switch (c) {
|
|
2725
|
+
case "{":
|
|
2726
|
+
case "[":
|
|
2727
|
+
return newToken("punctuator", read());
|
|
2728
|
+
}
|
|
2729
|
+
lexState = "value";
|
|
2730
|
+
},
|
|
2731
|
+
beforePropertyName() {
|
|
2732
|
+
switch (c) {
|
|
2733
|
+
case "$":
|
|
2734
|
+
case "_":
|
|
2735
|
+
buffer = read();
|
|
2736
|
+
lexState = "identifierName";
|
|
2737
|
+
return;
|
|
2738
|
+
case "\\":
|
|
2739
|
+
read();
|
|
2740
|
+
lexState = "identifierNameStartEscape";
|
|
2741
|
+
return;
|
|
2742
|
+
case "}":
|
|
2743
|
+
return newToken("punctuator", read());
|
|
2744
|
+
case '"':
|
|
2745
|
+
case "'":
|
|
2746
|
+
doubleQuote = read() === '"';
|
|
2747
|
+
lexState = "string";
|
|
2748
|
+
return;
|
|
2749
|
+
}
|
|
2750
|
+
if (util.isIdStartChar(c)) {
|
|
2751
|
+
buffer += read();
|
|
2752
|
+
lexState = "identifierName";
|
|
2753
|
+
return;
|
|
2754
|
+
}
|
|
2755
|
+
throw invalidChar(read());
|
|
2756
|
+
},
|
|
2757
|
+
afterPropertyName() {
|
|
2758
|
+
if (c === ":") {
|
|
2759
|
+
return newToken("punctuator", read());
|
|
2760
|
+
}
|
|
2761
|
+
throw invalidChar(read());
|
|
2762
|
+
},
|
|
2763
|
+
beforePropertyValue() {
|
|
2764
|
+
lexState = "value";
|
|
2765
|
+
},
|
|
2766
|
+
afterPropertyValue() {
|
|
2767
|
+
switch (c) {
|
|
2768
|
+
case ",":
|
|
2769
|
+
case "}":
|
|
2770
|
+
return newToken("punctuator", read());
|
|
2771
|
+
}
|
|
2772
|
+
throw invalidChar(read());
|
|
2773
|
+
},
|
|
2774
|
+
beforeArrayValue() {
|
|
2775
|
+
if (c === "]") {
|
|
2776
|
+
return newToken("punctuator", read());
|
|
2777
|
+
}
|
|
2778
|
+
lexState = "value";
|
|
2779
|
+
},
|
|
2780
|
+
afterArrayValue() {
|
|
2781
|
+
switch (c) {
|
|
2782
|
+
case ",":
|
|
2783
|
+
case "]":
|
|
2784
|
+
return newToken("punctuator", read());
|
|
2785
|
+
}
|
|
2786
|
+
throw invalidChar(read());
|
|
2787
|
+
},
|
|
2788
|
+
end() {
|
|
2789
|
+
throw invalidChar(read());
|
|
2790
|
+
}
|
|
2791
|
+
};
|
|
2792
|
+
function newToken(type, value) {
|
|
2793
|
+
return {
|
|
2794
|
+
type,
|
|
2795
|
+
value,
|
|
2796
|
+
line,
|
|
2797
|
+
column
|
|
2798
|
+
};
|
|
2799
|
+
}
|
|
2800
|
+
function literal(s) {
|
|
2801
|
+
for (const c2 of s) {
|
|
2802
|
+
const p = peek();
|
|
2803
|
+
if (p !== c2) {
|
|
2804
|
+
throw invalidChar(read());
|
|
2805
|
+
}
|
|
2806
|
+
read();
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
function escape() {
|
|
2810
|
+
const c2 = peek();
|
|
2811
|
+
switch (c2) {
|
|
2812
|
+
case "b":
|
|
2813
|
+
read();
|
|
2814
|
+
return "\b";
|
|
2815
|
+
case "f":
|
|
2816
|
+
read();
|
|
2817
|
+
return "\f";
|
|
2818
|
+
case "n":
|
|
2819
|
+
read();
|
|
2820
|
+
return "\n";
|
|
2821
|
+
case "r":
|
|
2822
|
+
read();
|
|
2823
|
+
return "\r";
|
|
2824
|
+
case "t":
|
|
2825
|
+
read();
|
|
2826
|
+
return " ";
|
|
2827
|
+
case "v":
|
|
2828
|
+
read();
|
|
2829
|
+
return "\v";
|
|
2830
|
+
case "0":
|
|
2831
|
+
read();
|
|
2832
|
+
if (util.isDigit(peek())) {
|
|
2833
|
+
throw invalidChar(read());
|
|
2834
|
+
}
|
|
2835
|
+
return "\0";
|
|
2836
|
+
case "x":
|
|
2837
|
+
read();
|
|
2838
|
+
return hexEscape();
|
|
2839
|
+
case "u":
|
|
2840
|
+
read();
|
|
2841
|
+
return unicodeEscape();
|
|
2842
|
+
case "\n":
|
|
2843
|
+
case "\u2028":
|
|
2844
|
+
case "\u2029":
|
|
2845
|
+
read();
|
|
2846
|
+
return "";
|
|
2847
|
+
case "\r":
|
|
2848
|
+
read();
|
|
2849
|
+
if (peek() === "\n") {
|
|
2850
|
+
read();
|
|
2851
|
+
}
|
|
2852
|
+
return "";
|
|
2853
|
+
case "1":
|
|
2854
|
+
case "2":
|
|
2855
|
+
case "3":
|
|
2856
|
+
case "4":
|
|
2857
|
+
case "5":
|
|
2858
|
+
case "6":
|
|
2859
|
+
case "7":
|
|
2860
|
+
case "8":
|
|
2861
|
+
case "9":
|
|
2862
|
+
throw invalidChar(read());
|
|
2863
|
+
case void 0:
|
|
2864
|
+
throw invalidChar(read());
|
|
2865
|
+
}
|
|
2866
|
+
return read();
|
|
2867
|
+
}
|
|
2868
|
+
function hexEscape() {
|
|
2869
|
+
let buffer2 = "";
|
|
2870
|
+
let c2 = peek();
|
|
2871
|
+
if (!util.isHexDigit(c2)) {
|
|
2872
|
+
throw invalidChar(read());
|
|
2873
|
+
}
|
|
2874
|
+
buffer2 += read();
|
|
2875
|
+
c2 = peek();
|
|
2876
|
+
if (!util.isHexDigit(c2)) {
|
|
2877
|
+
throw invalidChar(read());
|
|
2878
|
+
}
|
|
2879
|
+
buffer2 += read();
|
|
2880
|
+
return String.fromCodePoint(parseInt(buffer2, 16));
|
|
2881
|
+
}
|
|
2882
|
+
function unicodeEscape() {
|
|
2883
|
+
let buffer2 = "";
|
|
2884
|
+
let count = 4;
|
|
2885
|
+
while (count-- > 0) {
|
|
2886
|
+
const c2 = peek();
|
|
2887
|
+
if (!util.isHexDigit(c2)) {
|
|
2888
|
+
throw invalidChar(read());
|
|
2889
|
+
}
|
|
2890
|
+
buffer2 += read();
|
|
2891
|
+
}
|
|
2892
|
+
return String.fromCodePoint(parseInt(buffer2, 16));
|
|
2893
|
+
}
|
|
2894
|
+
var parseStates = {
|
|
2895
|
+
start() {
|
|
2896
|
+
if (token.type === "eof") {
|
|
2897
|
+
throw invalidEOF();
|
|
2898
|
+
}
|
|
2899
|
+
push();
|
|
2900
|
+
},
|
|
2901
|
+
beforePropertyName() {
|
|
2902
|
+
switch (token.type) {
|
|
2903
|
+
case "identifier":
|
|
2904
|
+
case "string":
|
|
2905
|
+
key = token.value;
|
|
2906
|
+
parseState = "afterPropertyName";
|
|
2907
|
+
return;
|
|
2908
|
+
case "punctuator":
|
|
2909
|
+
pop();
|
|
2910
|
+
return;
|
|
2911
|
+
case "eof":
|
|
2912
|
+
throw invalidEOF();
|
|
2913
|
+
}
|
|
2914
|
+
},
|
|
2915
|
+
afterPropertyName() {
|
|
2916
|
+
if (token.type === "eof") {
|
|
2917
|
+
throw invalidEOF();
|
|
2918
|
+
}
|
|
2919
|
+
parseState = "beforePropertyValue";
|
|
2920
|
+
},
|
|
2921
|
+
beforePropertyValue() {
|
|
2922
|
+
if (token.type === "eof") {
|
|
2923
|
+
throw invalidEOF();
|
|
2924
|
+
}
|
|
2925
|
+
push();
|
|
2926
|
+
},
|
|
2927
|
+
beforeArrayValue() {
|
|
2928
|
+
if (token.type === "eof") {
|
|
2929
|
+
throw invalidEOF();
|
|
2930
|
+
}
|
|
2931
|
+
if (token.type === "punctuator" && token.value === "]") {
|
|
2932
|
+
pop();
|
|
2933
|
+
return;
|
|
2934
|
+
}
|
|
2935
|
+
push();
|
|
2936
|
+
},
|
|
2937
|
+
afterPropertyValue() {
|
|
2938
|
+
if (token.type === "eof") {
|
|
2939
|
+
throw invalidEOF();
|
|
2940
|
+
}
|
|
2941
|
+
switch (token.value) {
|
|
2942
|
+
case ",":
|
|
2943
|
+
parseState = "beforePropertyName";
|
|
2944
|
+
return;
|
|
2945
|
+
case "}":
|
|
2946
|
+
pop();
|
|
2947
|
+
}
|
|
2948
|
+
},
|
|
2949
|
+
afterArrayValue() {
|
|
2950
|
+
if (token.type === "eof") {
|
|
2951
|
+
throw invalidEOF();
|
|
2952
|
+
}
|
|
2953
|
+
switch (token.value) {
|
|
2954
|
+
case ",":
|
|
2955
|
+
parseState = "beforeArrayValue";
|
|
2956
|
+
return;
|
|
2957
|
+
case "]":
|
|
2958
|
+
pop();
|
|
2959
|
+
}
|
|
2960
|
+
},
|
|
2961
|
+
end() {
|
|
2962
|
+
}
|
|
2963
|
+
};
|
|
2964
|
+
function push() {
|
|
2965
|
+
let value;
|
|
2966
|
+
switch (token.type) {
|
|
2967
|
+
case "punctuator":
|
|
2968
|
+
switch (token.value) {
|
|
2969
|
+
case "{":
|
|
2970
|
+
value = {};
|
|
2971
|
+
break;
|
|
2972
|
+
case "[":
|
|
2973
|
+
value = [];
|
|
2974
|
+
break;
|
|
2975
|
+
}
|
|
2976
|
+
break;
|
|
2977
|
+
case "null":
|
|
2978
|
+
case "boolean":
|
|
2979
|
+
case "numeric":
|
|
2980
|
+
case "string":
|
|
2981
|
+
value = token.value;
|
|
2982
|
+
break;
|
|
2983
|
+
}
|
|
2984
|
+
if (root === void 0) {
|
|
2985
|
+
root = value;
|
|
2986
|
+
} else {
|
|
2987
|
+
const parent = stack[stack.length - 1];
|
|
2988
|
+
if (Array.isArray(parent)) {
|
|
2989
|
+
parent.push(value);
|
|
2990
|
+
} else {
|
|
2991
|
+
Object.defineProperty(parent, key, {
|
|
2992
|
+
value,
|
|
2993
|
+
writable: true,
|
|
2994
|
+
enumerable: true,
|
|
2995
|
+
configurable: true
|
|
2996
|
+
});
|
|
2997
|
+
}
|
|
2998
|
+
}
|
|
2999
|
+
if (value !== null && typeof value === "object") {
|
|
3000
|
+
stack.push(value);
|
|
3001
|
+
if (Array.isArray(value)) {
|
|
3002
|
+
parseState = "beforeArrayValue";
|
|
3003
|
+
} else {
|
|
3004
|
+
parseState = "beforePropertyName";
|
|
3005
|
+
}
|
|
3006
|
+
} else {
|
|
3007
|
+
const current = stack[stack.length - 1];
|
|
3008
|
+
if (current == null) {
|
|
3009
|
+
parseState = "end";
|
|
3010
|
+
} else if (Array.isArray(current)) {
|
|
3011
|
+
parseState = "afterArrayValue";
|
|
3012
|
+
} else {
|
|
3013
|
+
parseState = "afterPropertyValue";
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
function pop() {
|
|
3018
|
+
stack.pop();
|
|
3019
|
+
const current = stack[stack.length - 1];
|
|
3020
|
+
if (current == null) {
|
|
3021
|
+
parseState = "end";
|
|
3022
|
+
} else if (Array.isArray(current)) {
|
|
3023
|
+
parseState = "afterArrayValue";
|
|
3024
|
+
} else {
|
|
3025
|
+
parseState = "afterPropertyValue";
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
function invalidChar(c2) {
|
|
3029
|
+
if (c2 === void 0) {
|
|
3030
|
+
return syntaxError(`JSON5: invalid end of input at ${line}:${column}`);
|
|
3031
|
+
}
|
|
3032
|
+
return syntaxError(`JSON5: invalid character '${formatChar(c2)}' at ${line}:${column}`);
|
|
3033
|
+
}
|
|
3034
|
+
function invalidEOF() {
|
|
3035
|
+
return syntaxError(`JSON5: invalid end of input at ${line}:${column}`);
|
|
3036
|
+
}
|
|
3037
|
+
function invalidIdentifier() {
|
|
3038
|
+
column -= 5;
|
|
3039
|
+
return syntaxError(`JSON5: invalid identifier character at ${line}:${column}`);
|
|
3040
|
+
}
|
|
3041
|
+
function separatorChar(c2) {
|
|
3042
|
+
console.warn(`JSON5: '${formatChar(c2)}' in strings is not valid ECMAScript; consider escaping`);
|
|
3043
|
+
}
|
|
3044
|
+
function formatChar(c2) {
|
|
3045
|
+
const replacements = {
|
|
3046
|
+
"'": "\\'",
|
|
3047
|
+
'"': '\\"',
|
|
3048
|
+
"\\": "\\\\",
|
|
3049
|
+
"\b": "\\b",
|
|
3050
|
+
"\f": "\\f",
|
|
3051
|
+
"\n": "\\n",
|
|
3052
|
+
"\r": "\\r",
|
|
3053
|
+
" ": "\\t",
|
|
3054
|
+
"\v": "\\v",
|
|
3055
|
+
"\0": "\\0",
|
|
3056
|
+
"\u2028": "\\u2028",
|
|
3057
|
+
"\u2029": "\\u2029"
|
|
3058
|
+
};
|
|
3059
|
+
if (replacements[c2]) {
|
|
3060
|
+
return replacements[c2];
|
|
3061
|
+
}
|
|
3062
|
+
if (c2 < " ") {
|
|
3063
|
+
const hexString = c2.charCodeAt(0).toString(16);
|
|
3064
|
+
return "\\x" + ("00" + hexString).substring(hexString.length);
|
|
3065
|
+
}
|
|
3066
|
+
return c2;
|
|
3067
|
+
}
|
|
3068
|
+
function syntaxError(message) {
|
|
3069
|
+
const err = new SyntaxError(message);
|
|
3070
|
+
err.lineNumber = line;
|
|
3071
|
+
err.columnNumber = column;
|
|
3072
|
+
return err;
|
|
3073
|
+
}
|
|
3074
|
+
}
|
|
3075
|
+
});
|
|
3076
|
+
|
|
3077
|
+
// node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/stringify.js
|
|
3078
|
+
var require_stringify = __commonJS({
|
|
3079
|
+
"node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/stringify.js"(exports, module) {
|
|
3080
|
+
var util = require_util();
|
|
3081
|
+
module.exports = function stringify(value, replacer, space) {
|
|
3082
|
+
const stack = [];
|
|
3083
|
+
let indent = "";
|
|
3084
|
+
let propertyList;
|
|
3085
|
+
let replacerFunc;
|
|
3086
|
+
let gap = "";
|
|
3087
|
+
let quote;
|
|
3088
|
+
if (replacer != null && typeof replacer === "object" && !Array.isArray(replacer)) {
|
|
3089
|
+
space = replacer.space;
|
|
3090
|
+
quote = replacer.quote;
|
|
3091
|
+
replacer = replacer.replacer;
|
|
3092
|
+
}
|
|
3093
|
+
if (typeof replacer === "function") {
|
|
3094
|
+
replacerFunc = replacer;
|
|
3095
|
+
} else if (Array.isArray(replacer)) {
|
|
3096
|
+
propertyList = [];
|
|
3097
|
+
for (const v of replacer) {
|
|
3098
|
+
let item;
|
|
3099
|
+
if (typeof v === "string") {
|
|
3100
|
+
item = v;
|
|
3101
|
+
} else if (typeof v === "number" || v instanceof String || v instanceof Number) {
|
|
3102
|
+
item = String(v);
|
|
3103
|
+
}
|
|
3104
|
+
if (item !== void 0 && propertyList.indexOf(item) < 0) {
|
|
3105
|
+
propertyList.push(item);
|
|
3106
|
+
}
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
if (space instanceof Number) {
|
|
3110
|
+
space = Number(space);
|
|
3111
|
+
} else if (space instanceof String) {
|
|
3112
|
+
space = String(space);
|
|
3113
|
+
}
|
|
3114
|
+
if (typeof space === "number") {
|
|
3115
|
+
if (space > 0) {
|
|
3116
|
+
space = Math.min(10, Math.floor(space));
|
|
3117
|
+
gap = " ".substr(0, space);
|
|
3118
|
+
}
|
|
3119
|
+
} else if (typeof space === "string") {
|
|
3120
|
+
gap = space.substr(0, 10);
|
|
3121
|
+
}
|
|
3122
|
+
return serializeProperty("", { "": value });
|
|
3123
|
+
function serializeProperty(key, holder) {
|
|
3124
|
+
let value2 = holder[key];
|
|
3125
|
+
if (value2 != null) {
|
|
3126
|
+
if (typeof value2.toJSON5 === "function") {
|
|
3127
|
+
value2 = value2.toJSON5(key);
|
|
3128
|
+
} else if (typeof value2.toJSON === "function") {
|
|
3129
|
+
value2 = value2.toJSON(key);
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
if (replacerFunc) {
|
|
3133
|
+
value2 = replacerFunc.call(holder, key, value2);
|
|
3134
|
+
}
|
|
3135
|
+
if (value2 instanceof Number) {
|
|
3136
|
+
value2 = Number(value2);
|
|
3137
|
+
} else if (value2 instanceof String) {
|
|
3138
|
+
value2 = String(value2);
|
|
3139
|
+
} else if (value2 instanceof Boolean) {
|
|
3140
|
+
value2 = value2.valueOf();
|
|
3141
|
+
}
|
|
3142
|
+
switch (value2) {
|
|
3143
|
+
case null:
|
|
3144
|
+
return "null";
|
|
3145
|
+
case true:
|
|
3146
|
+
return "true";
|
|
3147
|
+
case false:
|
|
3148
|
+
return "false";
|
|
3149
|
+
}
|
|
3150
|
+
if (typeof value2 === "string") {
|
|
3151
|
+
return quoteString(value2, false);
|
|
3152
|
+
}
|
|
3153
|
+
if (typeof value2 === "number") {
|
|
3154
|
+
return String(value2);
|
|
3155
|
+
}
|
|
3156
|
+
if (typeof value2 === "object") {
|
|
3157
|
+
return Array.isArray(value2) ? serializeArray(value2) : serializeObject(value2);
|
|
3158
|
+
}
|
|
3159
|
+
return void 0;
|
|
3160
|
+
}
|
|
3161
|
+
function quoteString(value2) {
|
|
3162
|
+
const quotes = {
|
|
3163
|
+
"'": 0.1,
|
|
3164
|
+
'"': 0.2
|
|
3165
|
+
};
|
|
3166
|
+
const replacements = {
|
|
3167
|
+
"'": "\\'",
|
|
3168
|
+
'"': '\\"',
|
|
3169
|
+
"\\": "\\\\",
|
|
3170
|
+
"\b": "\\b",
|
|
3171
|
+
"\f": "\\f",
|
|
3172
|
+
"\n": "\\n",
|
|
3173
|
+
"\r": "\\r",
|
|
3174
|
+
" ": "\\t",
|
|
3175
|
+
"\v": "\\v",
|
|
3176
|
+
"\0": "\\0",
|
|
3177
|
+
"\u2028": "\\u2028",
|
|
3178
|
+
"\u2029": "\\u2029"
|
|
3179
|
+
};
|
|
3180
|
+
let product = "";
|
|
3181
|
+
for (let i = 0; i < value2.length; i++) {
|
|
3182
|
+
const c = value2[i];
|
|
3183
|
+
switch (c) {
|
|
3184
|
+
case "'":
|
|
3185
|
+
case '"':
|
|
3186
|
+
quotes[c]++;
|
|
3187
|
+
product += c;
|
|
3188
|
+
continue;
|
|
3189
|
+
case "\0":
|
|
3190
|
+
if (util.isDigit(value2[i + 1])) {
|
|
3191
|
+
product += "\\x00";
|
|
3192
|
+
continue;
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
if (replacements[c]) {
|
|
3196
|
+
product += replacements[c];
|
|
3197
|
+
continue;
|
|
3198
|
+
}
|
|
3199
|
+
if (c < " ") {
|
|
3200
|
+
let hexString = c.charCodeAt(0).toString(16);
|
|
3201
|
+
product += "\\x" + ("00" + hexString).substring(hexString.length);
|
|
3202
|
+
continue;
|
|
3203
|
+
}
|
|
3204
|
+
product += c;
|
|
3205
|
+
}
|
|
3206
|
+
const quoteChar = quote || Object.keys(quotes).reduce((a, b) => quotes[a] < quotes[b] ? a : b);
|
|
3207
|
+
product = product.replace(new RegExp(quoteChar, "g"), replacements[quoteChar]);
|
|
3208
|
+
return quoteChar + product + quoteChar;
|
|
3209
|
+
}
|
|
3210
|
+
function serializeObject(value2) {
|
|
3211
|
+
if (stack.indexOf(value2) >= 0) {
|
|
3212
|
+
throw TypeError("Converting circular structure to JSON5");
|
|
3213
|
+
}
|
|
3214
|
+
stack.push(value2);
|
|
3215
|
+
let stepback = indent;
|
|
3216
|
+
indent = indent + gap;
|
|
3217
|
+
let keys = propertyList || Object.keys(value2);
|
|
3218
|
+
let partial = [];
|
|
3219
|
+
for (const key of keys) {
|
|
3220
|
+
const propertyString = serializeProperty(key, value2);
|
|
3221
|
+
if (propertyString !== void 0) {
|
|
3222
|
+
let member = serializeKey(key) + ":";
|
|
3223
|
+
if (gap !== "") {
|
|
3224
|
+
member += " ";
|
|
3225
|
+
}
|
|
3226
|
+
member += propertyString;
|
|
3227
|
+
partial.push(member);
|
|
3228
|
+
}
|
|
3229
|
+
}
|
|
3230
|
+
let final;
|
|
3231
|
+
if (partial.length === 0) {
|
|
3232
|
+
final = "{}";
|
|
3233
|
+
} else {
|
|
3234
|
+
let properties;
|
|
3235
|
+
if (gap === "") {
|
|
3236
|
+
properties = partial.join(",");
|
|
3237
|
+
final = "{" + properties + "}";
|
|
3238
|
+
} else {
|
|
3239
|
+
let separator = ",\n" + indent;
|
|
3240
|
+
properties = partial.join(separator);
|
|
3241
|
+
final = "{\n" + indent + properties + ",\n" + stepback + "}";
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
stack.pop();
|
|
3245
|
+
indent = stepback;
|
|
3246
|
+
return final;
|
|
3247
|
+
}
|
|
3248
|
+
function serializeKey(key) {
|
|
3249
|
+
if (key.length === 0) {
|
|
3250
|
+
return quoteString(key, true);
|
|
3251
|
+
}
|
|
3252
|
+
const firstChar = String.fromCodePoint(key.codePointAt(0));
|
|
3253
|
+
if (!util.isIdStartChar(firstChar)) {
|
|
3254
|
+
return quoteString(key, true);
|
|
3255
|
+
}
|
|
3256
|
+
for (let i = firstChar.length; i < key.length; i++) {
|
|
3257
|
+
if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
|
|
3258
|
+
return quoteString(key, true);
|
|
3259
|
+
}
|
|
3260
|
+
}
|
|
3261
|
+
return key;
|
|
3262
|
+
}
|
|
3263
|
+
function serializeArray(value2) {
|
|
3264
|
+
if (stack.indexOf(value2) >= 0) {
|
|
3265
|
+
throw TypeError("Converting circular structure to JSON5");
|
|
3266
|
+
}
|
|
3267
|
+
stack.push(value2);
|
|
3268
|
+
let stepback = indent;
|
|
3269
|
+
indent = indent + gap;
|
|
3270
|
+
let partial = [];
|
|
3271
|
+
for (let i = 0; i < value2.length; i++) {
|
|
3272
|
+
const propertyString = serializeProperty(String(i), value2);
|
|
3273
|
+
partial.push(propertyString !== void 0 ? propertyString : "null");
|
|
3274
|
+
}
|
|
3275
|
+
let final;
|
|
3276
|
+
if (partial.length === 0) {
|
|
3277
|
+
final = "[]";
|
|
3278
|
+
} else {
|
|
3279
|
+
if (gap === "") {
|
|
3280
|
+
let properties = partial.join(",");
|
|
3281
|
+
final = "[" + properties + "]";
|
|
3282
|
+
} else {
|
|
3283
|
+
let separator = ",\n" + indent;
|
|
3284
|
+
let properties = partial.join(separator);
|
|
3285
|
+
final = "[\n" + indent + properties + ",\n" + stepback + "]";
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
stack.pop();
|
|
3289
|
+
indent = stepback;
|
|
3290
|
+
return final;
|
|
3291
|
+
}
|
|
3292
|
+
};
|
|
3293
|
+
}
|
|
3294
|
+
});
|
|
3295
|
+
|
|
3296
|
+
// node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/index.js
|
|
3297
|
+
var require_lib = __commonJS({
|
|
3298
|
+
"node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/index.js"(exports, module) {
|
|
3299
|
+
var parse = require_parse();
|
|
3300
|
+
var stringify = require_stringify();
|
|
3301
|
+
var JSON52 = {
|
|
3302
|
+
parse,
|
|
3303
|
+
stringify
|
|
3304
|
+
};
|
|
3305
|
+
module.exports = JSON52;
|
|
3306
|
+
}
|
|
3307
|
+
});
|
|
3308
|
+
|
|
3309
|
+
// src/client/ddp.ts
|
|
3310
|
+
var import_ddp_client = __toESM(require_dist3(), 1);
|
|
3311
|
+
|
|
3312
|
+
// src/cli/rate-limiter.ts
|
|
3313
|
+
import { resolve as resolve2, dirname } from "node:path";
|
|
3314
|
+
import { homedir as homedir2 } from "node:os";
|
|
3315
|
+
|
|
3316
|
+
// src/cli/config-updater.ts
|
|
3317
|
+
import { resolve } from "node:path";
|
|
3318
|
+
import { homedir } from "node:os";
|
|
3319
|
+
var import_json5 = __toESM(require_lib(), 1);
|
|
3320
|
+
var OC_CONFIG_PATH = resolve(homedir(), ".openclaw", "openclaw.json");
|
|
3321
|
+
|
|
3322
|
+
// src/cli/rate-limiter.ts
|
|
3323
|
+
var DEFAULT_MAX_RECONNECTS = 20;
|
|
3324
|
+
var STATE_DIR = resolve2(homedir2(), ".openclaw", "rocketchat");
|
|
3325
|
+
var STATE_FILE = resolve2(STATE_DIR, "rate-limit.json");
|
|
3326
|
+
|
|
3327
|
+
// src/client/ddp.ts
|
|
3328
|
+
var RocketChatDdpConnection = class {
|
|
3329
|
+
options;
|
|
3330
|
+
sdk = null;
|
|
3331
|
+
subscription = null;
|
|
3332
|
+
stopped = false;
|
|
3333
|
+
reconnectAttempts = 0;
|
|
3334
|
+
constructor(options) {
|
|
3335
|
+
this.options = options;
|
|
3336
|
+
}
|
|
3337
|
+
getSdk() {
|
|
3338
|
+
if (!this.sdk) throw new Error("DDP SDK not initialized; connection not started");
|
|
3339
|
+
return this.sdk;
|
|
3340
|
+
}
|
|
3341
|
+
async call(method, ...params) {
|
|
3342
|
+
return this.getSdk().call(method, ...params);
|
|
3343
|
+
}
|
|
3344
|
+
async sendMessage(roomId, text, options) {
|
|
3345
|
+
const message = { rid: roomId, msg: text };
|
|
3346
|
+
if (options?.tmid) message.tmid = options.tmid;
|
|
3347
|
+
const result = await this.call("sendMessage", message);
|
|
3348
|
+
return result._id ?? "";
|
|
3349
|
+
}
|
|
3350
|
+
async reactToMessage(messageId, reaction) {
|
|
3351
|
+
await this.call("setReaction", reaction, messageId);
|
|
3352
|
+
}
|
|
3353
|
+
async sendTyping(roomId, isTyping) {
|
|
3354
|
+
await this.call("stream-notify-room", `${roomId}/typing`, this.options.username, isTyping);
|
|
3355
|
+
}
|
|
3356
|
+
start() {
|
|
3357
|
+
this.stopped = false;
|
|
3358
|
+
this.connect();
|
|
3359
|
+
}
|
|
3360
|
+
stop() {
|
|
3361
|
+
this.stopped = true;
|
|
3362
|
+
this.subscription?.stop();
|
|
3363
|
+
this.sdk?.connection.close();
|
|
3364
|
+
this.sdk = null;
|
|
3365
|
+
}
|
|
3366
|
+
async connect() {
|
|
3367
|
+
if (this.stopped) return;
|
|
3368
|
+
const maxReconnects = this.options.maxReconnects ?? DEFAULT_MAX_RECONNECTS;
|
|
3369
|
+
this.options.onStatus?.("connecting");
|
|
3370
|
+
try {
|
|
3371
|
+
const sdk = import_ddp_client.DDPSDK.create(this.options.wsUrl, {
|
|
3372
|
+
retryCount: maxReconnects,
|
|
3373
|
+
retryTime: this.options.reconnectDelayMs ?? 2e3
|
|
3374
|
+
});
|
|
3375
|
+
this.sdk = sdk;
|
|
3376
|
+
sdk.connection.on("connecting", () => this.options.onStatus?.("connecting"));
|
|
3377
|
+
sdk.connection.on("connected", () => {
|
|
3378
|
+
this.reconnectAttempts = 0;
|
|
3379
|
+
this.options.onStatus?.("connected");
|
|
3380
|
+
});
|
|
3381
|
+
sdk.connection.on("close", () => {
|
|
3382
|
+
this.options.onStatus?.("closed");
|
|
3383
|
+
if (!this.stopped) {
|
|
3384
|
+
this.reconnectAttempts++;
|
|
3385
|
+
if (this.reconnectAttempts > maxReconnects) {
|
|
3386
|
+
this.options.onError?.(
|
|
3387
|
+
new Error(
|
|
3388
|
+
`Max reconnect attempts (${maxReconnects}) exceeded for ${this.options.wsUrl}`
|
|
3389
|
+
)
|
|
3390
|
+
);
|
|
3391
|
+
return;
|
|
3392
|
+
}
|
|
3393
|
+
this.connect();
|
|
83
3394
|
}
|
|
3395
|
+
});
|
|
3396
|
+
await sdk.connection.connect();
|
|
3397
|
+
await sdk.account.loginWithToken(this.options.authToken);
|
|
3398
|
+
const sub = sdk.stream("room-messages", "__my_messages__", (...args) => {
|
|
3399
|
+
const message = args[0];
|
|
3400
|
+
if (message) this.options.onMessage(message);
|
|
3401
|
+
});
|
|
3402
|
+
this.subscription = sub;
|
|
3403
|
+
await sub.ready();
|
|
3404
|
+
this.options.onStatus?.("ready");
|
|
3405
|
+
} catch (err) {
|
|
3406
|
+
this.options.onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
84
3407
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
3408
|
+
}
|
|
3409
|
+
};
|
|
3410
|
+
export {
|
|
3411
|
+
RocketChatDdpConnection
|
|
3412
|
+
};
|
|
3413
|
+
//# sourceMappingURL=ddp.js.map
|