@fern-api/typescript-dynamic-snippets 0.0.5 → 0.0.7
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/cjs/DynamicSnippetsGenerator.cjs +17 -5456
- package/cjs/EndpointSnippetGenerator.cjs +17 -3487
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +17 -4811
- package/cjs/context/DynamicTypeLiteralMapper.cjs +17 -3441
- package/cjs/context/FilePropertyMapper.cjs +17 -3021
- package/cjs/index.cjs +29 -8759
- package/esm/DynamicSnippetsGenerator.js +1 -12
- package/esm/EndpointSnippetGenerator.js +1 -8
- package/esm/chunk-25TNFA5L.js +14 -0
- package/esm/chunk-736FTN3M.js +1 -0
- package/esm/chunk-CQ55KPJT.js +1 -0
- package/esm/chunk-LX5O4JB7.js +1 -0
- package/esm/chunk-SQLJANKO.js +1 -0
- package/esm/chunk-V6G7NZKW.js +1 -0
- package/esm/chunk-YD6EIACZ.js +27 -0
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -10
- package/esm/context/DynamicTypeLiteralMapper.js +1 -8
- package/esm/context/FilePropertyMapper.js +1 -7
- package/esm/index.js +13 -3311
- package/package.json +2 -2
- package/esm/chunk-5AHCFZX2.js +0 -819
- package/esm/chunk-APAANCUR.js +0 -86
- package/esm/chunk-K6P3GMIJ.js +0 -551
- package/esm/chunk-QMEM6UIZ.js +0 -538
- package/esm/chunk-SGEN5HN3.js +0 -3008
- package/esm/chunk-VZ6REHK2.js +0 -90
- package/esm/chunk-ZHKZ5MWW.js +0 -501
|
@@ -1,3490 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
-
__defProp(to, key, { get: () => from2[key], enumerable: !(desc = __getOwnPropDesc(from2, key)) || desc.enumerable });
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
-
|
|
25
|
-
// ../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/process.js
|
|
26
|
-
function defaultSetTimout() {
|
|
27
|
-
throw new Error("setTimeout has not been defined");
|
|
28
|
-
}
|
|
29
|
-
function defaultClearTimeout() {
|
|
30
|
-
throw new Error("clearTimeout has not been defined");
|
|
31
|
-
}
|
|
32
|
-
function runTimeout(fun) {
|
|
33
|
-
if (cachedSetTimeout === setTimeout) {
|
|
34
|
-
return setTimeout(fun, 0);
|
|
35
|
-
}
|
|
36
|
-
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
|
|
37
|
-
cachedSetTimeout = setTimeout;
|
|
38
|
-
return setTimeout(fun, 0);
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
return cachedSetTimeout(fun, 0);
|
|
42
|
-
} catch (e) {
|
|
43
|
-
try {
|
|
44
|
-
return cachedSetTimeout.call(null, fun, 0);
|
|
45
|
-
} catch (e2) {
|
|
46
|
-
return cachedSetTimeout.call(this, fun, 0);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function runClearTimeout(marker) {
|
|
51
|
-
if (cachedClearTimeout === clearTimeout) {
|
|
52
|
-
return clearTimeout(marker);
|
|
53
|
-
}
|
|
54
|
-
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
|
|
55
|
-
cachedClearTimeout = clearTimeout;
|
|
56
|
-
return clearTimeout(marker);
|
|
57
|
-
}
|
|
58
|
-
try {
|
|
59
|
-
return cachedClearTimeout(marker);
|
|
60
|
-
} catch (e) {
|
|
61
|
-
try {
|
|
62
|
-
return cachedClearTimeout.call(null, marker);
|
|
63
|
-
} catch (e2) {
|
|
64
|
-
return cachedClearTimeout.call(this, marker);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function cleanUpNextTick() {
|
|
69
|
-
if (!draining || !currentQueue) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
draining = false;
|
|
73
|
-
if (currentQueue.length) {
|
|
74
|
-
queue = currentQueue.concat(queue);
|
|
75
|
-
} else {
|
|
76
|
-
queueIndex = -1;
|
|
77
|
-
}
|
|
78
|
-
if (queue.length) {
|
|
79
|
-
drainQueue();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function drainQueue() {
|
|
83
|
-
if (draining) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
var timeout = runTimeout(cleanUpNextTick);
|
|
87
|
-
draining = true;
|
|
88
|
-
var len = queue.length;
|
|
89
|
-
while (len) {
|
|
90
|
-
currentQueue = queue;
|
|
91
|
-
queue = [];
|
|
92
|
-
while (++queueIndex < len) {
|
|
93
|
-
if (currentQueue) {
|
|
94
|
-
currentQueue[queueIndex].run();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
queueIndex = -1;
|
|
98
|
-
len = queue.length;
|
|
99
|
-
}
|
|
100
|
-
currentQueue = null;
|
|
101
|
-
draining = false;
|
|
102
|
-
runClearTimeout(timeout);
|
|
103
|
-
}
|
|
104
|
-
function nextTick(fun) {
|
|
105
|
-
var args = new Array(arguments.length - 1);
|
|
106
|
-
if (arguments.length > 1) {
|
|
107
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
108
|
-
args[i - 1] = arguments[i];
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
queue.push(new Item(fun, args));
|
|
112
|
-
if (queue.length === 1 && !draining) {
|
|
113
|
-
runTimeout(drainQueue);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function Item(fun, array) {
|
|
117
|
-
this.fun = fun;
|
|
118
|
-
this.array = array;
|
|
119
|
-
}
|
|
120
|
-
function noop() {
|
|
121
|
-
}
|
|
122
|
-
function binding(name) {
|
|
123
|
-
throw new Error("process.binding is not supported");
|
|
124
|
-
}
|
|
125
|
-
function cwd() {
|
|
126
|
-
return "/";
|
|
127
|
-
}
|
|
128
|
-
function chdir(dir) {
|
|
129
|
-
throw new Error("process.chdir is not supported");
|
|
130
|
-
}
|
|
131
|
-
function umask() {
|
|
132
|
-
return 0;
|
|
133
|
-
}
|
|
134
|
-
function hrtime(previousTimestamp) {
|
|
135
|
-
var clocktime = performanceNow.call(performance) * 1e-3;
|
|
136
|
-
var seconds = Math.floor(clocktime);
|
|
137
|
-
var nanoseconds = Math.floor(clocktime % 1 * 1e9);
|
|
138
|
-
if (previousTimestamp) {
|
|
139
|
-
seconds = seconds - previousTimestamp[0];
|
|
140
|
-
nanoseconds = nanoseconds - previousTimestamp[1];
|
|
141
|
-
if (nanoseconds < 0) {
|
|
142
|
-
seconds--;
|
|
143
|
-
nanoseconds += 1e9;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return [seconds, nanoseconds];
|
|
147
|
-
}
|
|
148
|
-
function uptime() {
|
|
149
|
-
var currentTime = /* @__PURE__ */ new Date();
|
|
150
|
-
var dif = currentTime - startTime;
|
|
151
|
-
return dif / 1e3;
|
|
152
|
-
}
|
|
153
|
-
var cachedSetTimeout, cachedClearTimeout, queue, draining, currentQueue, queueIndex, title, platform, browser, env, argv, version, versions, release, config, on, addListener, once, off, removeListener, removeAllListeners, emit, performance, performanceNow, startTime, process, defines;
|
|
154
|
-
var init_process = __esm({
|
|
155
|
-
"../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/process.js"() {
|
|
156
|
-
"use strict";
|
|
157
|
-
cachedSetTimeout = defaultSetTimout;
|
|
158
|
-
cachedClearTimeout = defaultClearTimeout;
|
|
159
|
-
if (typeof globalThis.setTimeout === "function") {
|
|
160
|
-
cachedSetTimeout = setTimeout;
|
|
161
|
-
}
|
|
162
|
-
if (typeof globalThis.clearTimeout === "function") {
|
|
163
|
-
cachedClearTimeout = clearTimeout;
|
|
164
|
-
}
|
|
165
|
-
queue = [];
|
|
166
|
-
draining = false;
|
|
167
|
-
queueIndex = -1;
|
|
168
|
-
Item.prototype.run = function() {
|
|
169
|
-
this.fun.apply(null, this.array);
|
|
170
|
-
};
|
|
171
|
-
title = "browser";
|
|
172
|
-
platform = "browser";
|
|
173
|
-
browser = true;
|
|
174
|
-
env = {};
|
|
175
|
-
argv = [];
|
|
176
|
-
version = "";
|
|
177
|
-
versions = {};
|
|
178
|
-
release = {};
|
|
179
|
-
config = {};
|
|
180
|
-
on = noop;
|
|
181
|
-
addListener = noop;
|
|
182
|
-
once = noop;
|
|
183
|
-
off = noop;
|
|
184
|
-
removeListener = noop;
|
|
185
|
-
removeAllListeners = noop;
|
|
186
|
-
emit = noop;
|
|
187
|
-
performance = globalThis.performance || {};
|
|
188
|
-
performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function() {
|
|
189
|
-
return (/* @__PURE__ */ new Date()).getTime();
|
|
190
|
-
};
|
|
191
|
-
startTime = /* @__PURE__ */ new Date();
|
|
192
|
-
process = {
|
|
193
|
-
nextTick,
|
|
194
|
-
title,
|
|
195
|
-
browser,
|
|
196
|
-
env,
|
|
197
|
-
argv,
|
|
198
|
-
version,
|
|
199
|
-
versions,
|
|
200
|
-
on,
|
|
201
|
-
addListener,
|
|
202
|
-
once,
|
|
203
|
-
off,
|
|
204
|
-
removeListener,
|
|
205
|
-
removeAllListeners,
|
|
206
|
-
emit,
|
|
207
|
-
binding,
|
|
208
|
-
cwd,
|
|
209
|
-
chdir,
|
|
210
|
-
umask,
|
|
211
|
-
hrtime,
|
|
212
|
-
platform,
|
|
213
|
-
release,
|
|
214
|
-
config,
|
|
215
|
-
uptime
|
|
216
|
-
};
|
|
217
|
-
defines = {};
|
|
218
|
-
Object.keys(defines).forEach((key) => {
|
|
219
|
-
const segs = key.split(".");
|
|
220
|
-
let target = process;
|
|
221
|
-
for (let i = 0; i < segs.length; i++) {
|
|
222
|
-
const seg = segs[i];
|
|
223
|
-
if (i === segs.length - 1) {
|
|
224
|
-
target[seg] = defines[key];
|
|
225
|
-
} else {
|
|
226
|
-
target = target[seg] || (target[seg] = {});
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
// ../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/Buffer.js
|
|
234
|
-
function init() {
|
|
235
|
-
inited = true;
|
|
236
|
-
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
237
|
-
for (var i = 0, len = code.length; i < len; ++i) {
|
|
238
|
-
lookup[i] = code[i];
|
|
239
|
-
revLookup[code.charCodeAt(i)] = i;
|
|
240
|
-
}
|
|
241
|
-
revLookup["-".charCodeAt(0)] = 62;
|
|
242
|
-
revLookup["_".charCodeAt(0)] = 63;
|
|
243
|
-
}
|
|
244
|
-
function base64toByteArray(b64) {
|
|
245
|
-
if (!inited) {
|
|
246
|
-
init();
|
|
247
|
-
}
|
|
248
|
-
var i, j, l, tmp, placeHolders, arr;
|
|
249
|
-
var len = b64.length;
|
|
250
|
-
if (len % 4 > 0) {
|
|
251
|
-
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
252
|
-
}
|
|
253
|
-
placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
|
|
254
|
-
arr = new Arr(len * 3 / 4 - placeHolders);
|
|
255
|
-
l = placeHolders > 0 ? len - 4 : len;
|
|
256
|
-
var L = 0;
|
|
257
|
-
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
|
258
|
-
tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
|
|
259
|
-
arr[L++] = tmp >> 16 & 255;
|
|
260
|
-
arr[L++] = tmp >> 8 & 255;
|
|
261
|
-
arr[L++] = tmp & 255;
|
|
262
|
-
}
|
|
263
|
-
if (placeHolders === 2) {
|
|
264
|
-
tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
|
|
265
|
-
arr[L++] = tmp & 255;
|
|
266
|
-
} else if (placeHolders === 1) {
|
|
267
|
-
tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
|
|
268
|
-
arr[L++] = tmp >> 8 & 255;
|
|
269
|
-
arr[L++] = tmp & 255;
|
|
270
|
-
}
|
|
271
|
-
return arr;
|
|
272
|
-
}
|
|
273
|
-
function tripletToBase64(num) {
|
|
274
|
-
return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
|
|
275
|
-
}
|
|
276
|
-
function encodeChunk(uint8, start, end) {
|
|
277
|
-
var tmp;
|
|
278
|
-
var output = [];
|
|
279
|
-
for (var i = start; i < end; i += 3) {
|
|
280
|
-
tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
|
|
281
|
-
output.push(tripletToBase64(tmp));
|
|
282
|
-
}
|
|
283
|
-
return output.join("");
|
|
284
|
-
}
|
|
285
|
-
function base64fromByteArray(uint8) {
|
|
286
|
-
if (!inited) {
|
|
287
|
-
init();
|
|
288
|
-
}
|
|
289
|
-
var tmp;
|
|
290
|
-
var len = uint8.length;
|
|
291
|
-
var extraBytes = len % 3;
|
|
292
|
-
var output = "";
|
|
293
|
-
var parts = [];
|
|
294
|
-
var maxChunkLength = 16383;
|
|
295
|
-
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
|
|
296
|
-
parts.push(
|
|
297
|
-
encodeChunk(
|
|
298
|
-
uint8,
|
|
299
|
-
i,
|
|
300
|
-
i + maxChunkLength > len2 ? len2 : i + maxChunkLength
|
|
301
|
-
)
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
if (extraBytes === 1) {
|
|
305
|
-
tmp = uint8[len - 1];
|
|
306
|
-
output += lookup[tmp >> 2];
|
|
307
|
-
output += lookup[tmp << 4 & 63];
|
|
308
|
-
output += "==";
|
|
309
|
-
} else if (extraBytes === 2) {
|
|
310
|
-
tmp = (uint8[len - 2] << 8) + uint8[len - 1];
|
|
311
|
-
output += lookup[tmp >> 10];
|
|
312
|
-
output += lookup[tmp >> 4 & 63];
|
|
313
|
-
output += lookup[tmp << 2 & 63];
|
|
314
|
-
output += "=";
|
|
315
|
-
}
|
|
316
|
-
parts.push(output);
|
|
317
|
-
return parts.join("");
|
|
318
|
-
}
|
|
319
|
-
function kMaxLength() {
|
|
320
|
-
return Buffer2.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
|
|
321
|
-
}
|
|
322
|
-
function createBuffer(that, length) {
|
|
323
|
-
if (kMaxLength() < length) {
|
|
324
|
-
throw new RangeError("Invalid typed array length");
|
|
325
|
-
}
|
|
326
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
327
|
-
that = new Uint8Array(length);
|
|
328
|
-
that.__proto__ = Buffer2.prototype;
|
|
329
|
-
} else {
|
|
330
|
-
if (that === null) {
|
|
331
|
-
that = new Buffer2(length);
|
|
332
|
-
}
|
|
333
|
-
that.length = length;
|
|
334
|
-
}
|
|
335
|
-
return that;
|
|
336
|
-
}
|
|
337
|
-
function Buffer2(arg, encodingOrOffset, length) {
|
|
338
|
-
if (!Buffer2.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer2)) {
|
|
339
|
-
return new Buffer2(arg, encodingOrOffset, length);
|
|
340
|
-
}
|
|
341
|
-
if (typeof arg === "number") {
|
|
342
|
-
if (typeof encodingOrOffset === "string") {
|
|
343
|
-
throw new Error(
|
|
344
|
-
"If encoding is specified then the first argument must be a string"
|
|
345
|
-
);
|
|
346
|
-
}
|
|
347
|
-
return allocUnsafe(this, arg);
|
|
348
|
-
}
|
|
349
|
-
return from(this, arg, encodingOrOffset, length);
|
|
350
|
-
}
|
|
351
|
-
function from(that, value, encodingOrOffset, length) {
|
|
352
|
-
if (typeof value === "number") {
|
|
353
|
-
throw new TypeError('"value" argument must not be a number');
|
|
354
|
-
}
|
|
355
|
-
if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) {
|
|
356
|
-
return fromArrayBuffer(that, value, encodingOrOffset, length);
|
|
357
|
-
}
|
|
358
|
-
if (typeof value === "string") {
|
|
359
|
-
return fromString(that, value, encodingOrOffset);
|
|
360
|
-
}
|
|
361
|
-
return fromObject(that, value);
|
|
362
|
-
}
|
|
363
|
-
function assertSize(size) {
|
|
364
|
-
if (typeof size !== "number") {
|
|
365
|
-
throw new TypeError('"size" argument must be a number');
|
|
366
|
-
} else if (size < 0) {
|
|
367
|
-
throw new RangeError('"size" argument must not be negative');
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
function alloc(that, size, fill2, encoding) {
|
|
371
|
-
assertSize(size);
|
|
372
|
-
if (size <= 0) {
|
|
373
|
-
return createBuffer(that, size);
|
|
374
|
-
}
|
|
375
|
-
if (fill2 !== void 0) {
|
|
376
|
-
return typeof encoding === "string" ? createBuffer(that, size).fill(fill2, encoding) : createBuffer(that, size).fill(fill2);
|
|
377
|
-
}
|
|
378
|
-
return createBuffer(that, size);
|
|
379
|
-
}
|
|
380
|
-
function allocUnsafe(that, size) {
|
|
381
|
-
assertSize(size);
|
|
382
|
-
that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
|
|
383
|
-
if (!Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
384
|
-
for (var i = 0; i < size; ++i) {
|
|
385
|
-
that[i] = 0;
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return that;
|
|
389
|
-
}
|
|
390
|
-
function fromString(that, string, encoding) {
|
|
391
|
-
if (typeof encoding !== "string" || encoding === "") {
|
|
392
|
-
encoding = "utf8";
|
|
393
|
-
}
|
|
394
|
-
if (!Buffer2.isEncoding(encoding)) {
|
|
395
|
-
throw new TypeError('"encoding" must be a valid string encoding');
|
|
396
|
-
}
|
|
397
|
-
var length = byteLength(string, encoding) | 0;
|
|
398
|
-
that = createBuffer(that, length);
|
|
399
|
-
var actual = that.write(string, encoding);
|
|
400
|
-
if (actual !== length) {
|
|
401
|
-
that = that.slice(0, actual);
|
|
402
|
-
}
|
|
403
|
-
return that;
|
|
404
|
-
}
|
|
405
|
-
function fromArrayLike(that, array) {
|
|
406
|
-
var length = array.length < 0 ? 0 : checked(array.length) | 0;
|
|
407
|
-
that = createBuffer(that, length);
|
|
408
|
-
for (var i = 0; i < length; i += 1) {
|
|
409
|
-
that[i] = array[i] & 255;
|
|
410
|
-
}
|
|
411
|
-
return that;
|
|
412
|
-
}
|
|
413
|
-
function fromArrayBuffer(that, array, byteOffset, length) {
|
|
414
|
-
array.byteLength;
|
|
415
|
-
if (byteOffset < 0 || array.byteLength < byteOffset) {
|
|
416
|
-
throw new RangeError("'offset' is out of bounds");
|
|
417
|
-
}
|
|
418
|
-
if (array.byteLength < byteOffset + (length || 0)) {
|
|
419
|
-
throw new RangeError("'length' is out of bounds");
|
|
420
|
-
}
|
|
421
|
-
if (byteOffset === void 0 && length === void 0) {
|
|
422
|
-
array = new Uint8Array(array);
|
|
423
|
-
} else if (length === void 0) {
|
|
424
|
-
array = new Uint8Array(array, byteOffset);
|
|
425
|
-
} else {
|
|
426
|
-
array = new Uint8Array(array, byteOffset, length);
|
|
427
|
-
}
|
|
428
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
429
|
-
that = array;
|
|
430
|
-
that.__proto__ = Buffer2.prototype;
|
|
431
|
-
} else {
|
|
432
|
-
that = fromArrayLike(that, array);
|
|
433
|
-
}
|
|
434
|
-
return that;
|
|
435
|
-
}
|
|
436
|
-
function fromObject(that, obj) {
|
|
437
|
-
if (internalIsBuffer(obj)) {
|
|
438
|
-
var len = checked(obj.length) | 0;
|
|
439
|
-
that = createBuffer(that, len);
|
|
440
|
-
if (that.length === 0) {
|
|
441
|
-
return that;
|
|
442
|
-
}
|
|
443
|
-
obj.copy(that, 0, 0, len);
|
|
444
|
-
return that;
|
|
445
|
-
}
|
|
446
|
-
if (obj) {
|
|
447
|
-
if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
|
|
448
|
-
if (typeof obj.length !== "number" || isnan(obj.length)) {
|
|
449
|
-
return createBuffer(that, 0);
|
|
450
|
-
}
|
|
451
|
-
return fromArrayLike(that, obj);
|
|
452
|
-
}
|
|
453
|
-
if (obj.type === "Buffer" && Array.isArray(obj.data)) {
|
|
454
|
-
return fromArrayLike(that, obj.data);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
throw new TypeError(
|
|
458
|
-
"First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object."
|
|
459
|
-
);
|
|
460
|
-
}
|
|
461
|
-
function checked(length) {
|
|
462
|
-
if (length >= kMaxLength()) {
|
|
463
|
-
throw new RangeError(
|
|
464
|
-
"Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes"
|
|
465
|
-
);
|
|
466
|
-
}
|
|
467
|
-
return length | 0;
|
|
468
|
-
}
|
|
469
|
-
function internalIsBuffer(b) {
|
|
470
|
-
return !!(b != null && b._isBuffer);
|
|
471
|
-
}
|
|
472
|
-
function byteLength(string, encoding) {
|
|
473
|
-
if (internalIsBuffer(string)) {
|
|
474
|
-
return string.length;
|
|
475
|
-
}
|
|
476
|
-
if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
|
|
477
|
-
return string.byteLength;
|
|
478
|
-
}
|
|
479
|
-
if (typeof string !== "string") {
|
|
480
|
-
string = "" + string;
|
|
481
|
-
}
|
|
482
|
-
var len = string.length;
|
|
483
|
-
if (len === 0) return 0;
|
|
484
|
-
var loweredCase = false;
|
|
485
|
-
for (; ; ) {
|
|
486
|
-
switch (encoding) {
|
|
487
|
-
case "ascii":
|
|
488
|
-
case "latin1":
|
|
489
|
-
case "binary":
|
|
490
|
-
return len;
|
|
491
|
-
case "utf8":
|
|
492
|
-
case "utf-8":
|
|
493
|
-
case void 0:
|
|
494
|
-
return utf8ToBytes(string).length;
|
|
495
|
-
case "ucs2":
|
|
496
|
-
case "ucs-2":
|
|
497
|
-
case "utf16le":
|
|
498
|
-
case "utf-16le":
|
|
499
|
-
return len * 2;
|
|
500
|
-
case "hex":
|
|
501
|
-
return len >>> 1;
|
|
502
|
-
case "base64":
|
|
503
|
-
return base64ToBytes(string).length;
|
|
504
|
-
default:
|
|
505
|
-
if (loweredCase) return utf8ToBytes(string).length;
|
|
506
|
-
encoding = ("" + encoding).toLowerCase();
|
|
507
|
-
loweredCase = true;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
function slowToString(encoding, start, end) {
|
|
512
|
-
var loweredCase = false;
|
|
513
|
-
if (start === void 0 || start < 0) {
|
|
514
|
-
start = 0;
|
|
515
|
-
}
|
|
516
|
-
if (start > this.length) {
|
|
517
|
-
return "";
|
|
518
|
-
}
|
|
519
|
-
if (end === void 0 || end > this.length) {
|
|
520
|
-
end = this.length;
|
|
521
|
-
}
|
|
522
|
-
if (end <= 0) {
|
|
523
|
-
return "";
|
|
524
|
-
}
|
|
525
|
-
end >>>= 0;
|
|
526
|
-
start >>>= 0;
|
|
527
|
-
if (end <= start) {
|
|
528
|
-
return "";
|
|
529
|
-
}
|
|
530
|
-
if (!encoding) encoding = "utf8";
|
|
531
|
-
while (true) {
|
|
532
|
-
switch (encoding) {
|
|
533
|
-
case "hex":
|
|
534
|
-
return hexSlice(this, start, end);
|
|
535
|
-
case "utf8":
|
|
536
|
-
case "utf-8":
|
|
537
|
-
return utf8Slice(this, start, end);
|
|
538
|
-
case "ascii":
|
|
539
|
-
return asciiSlice(this, start, end);
|
|
540
|
-
case "latin1":
|
|
541
|
-
case "binary":
|
|
542
|
-
return latin1Slice(this, start, end);
|
|
543
|
-
case "base64":
|
|
544
|
-
return base64Slice(this, start, end);
|
|
545
|
-
case "ucs2":
|
|
546
|
-
case "ucs-2":
|
|
547
|
-
case "utf16le":
|
|
548
|
-
case "utf-16le":
|
|
549
|
-
return utf16leSlice(this, start, end);
|
|
550
|
-
default:
|
|
551
|
-
if (loweredCase)
|
|
552
|
-
throw new TypeError("Unknown encoding: " + encoding);
|
|
553
|
-
encoding = (encoding + "").toLowerCase();
|
|
554
|
-
loweredCase = true;
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
function swap(b, n, m) {
|
|
559
|
-
var i = b[n];
|
|
560
|
-
b[n] = b[m];
|
|
561
|
-
b[m] = i;
|
|
562
|
-
}
|
|
563
|
-
function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
|
|
564
|
-
if (buffer.length === 0) return -1;
|
|
565
|
-
if (typeof byteOffset === "string") {
|
|
566
|
-
encoding = byteOffset;
|
|
567
|
-
byteOffset = 0;
|
|
568
|
-
} else if (byteOffset > 2147483647) {
|
|
569
|
-
byteOffset = 2147483647;
|
|
570
|
-
} else if (byteOffset < -2147483648) {
|
|
571
|
-
byteOffset = -2147483648;
|
|
572
|
-
}
|
|
573
|
-
byteOffset = +byteOffset;
|
|
574
|
-
if (isNaN(byteOffset)) {
|
|
575
|
-
byteOffset = dir ? 0 : buffer.length - 1;
|
|
576
|
-
}
|
|
577
|
-
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
578
|
-
if (byteOffset >= buffer.length) {
|
|
579
|
-
if (dir) return -1;
|
|
580
|
-
else byteOffset = buffer.length - 1;
|
|
581
|
-
} else if (byteOffset < 0) {
|
|
582
|
-
if (dir) byteOffset = 0;
|
|
583
|
-
else return -1;
|
|
584
|
-
}
|
|
585
|
-
if (typeof val === "string") {
|
|
586
|
-
val = Buffer2.from(val, encoding);
|
|
587
|
-
}
|
|
588
|
-
if (internalIsBuffer(val)) {
|
|
589
|
-
if (val.length === 0) {
|
|
590
|
-
return -1;
|
|
591
|
-
}
|
|
592
|
-
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
|
|
593
|
-
} else if (typeof val === "number") {
|
|
594
|
-
val = val & 255;
|
|
595
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") {
|
|
596
|
-
if (dir) {
|
|
597
|
-
return Uint8Array.prototype.indexOf.call(
|
|
598
|
-
buffer,
|
|
599
|
-
val,
|
|
600
|
-
byteOffset
|
|
601
|
-
);
|
|
602
|
-
} else {
|
|
603
|
-
return Uint8Array.prototype.lastIndexOf.call(
|
|
604
|
-
buffer,
|
|
605
|
-
val,
|
|
606
|
-
byteOffset
|
|
607
|
-
);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
|
|
611
|
-
}
|
|
612
|
-
throw new TypeError("val must be string, number or Buffer");
|
|
613
|
-
}
|
|
614
|
-
function arrayIndexOf(arr, val, byteOffset, encoding, dir) {
|
|
615
|
-
var indexSize = 1;
|
|
616
|
-
var arrLength = arr.length;
|
|
617
|
-
var valLength = val.length;
|
|
618
|
-
if (encoding !== void 0) {
|
|
619
|
-
encoding = String(encoding).toLowerCase();
|
|
620
|
-
if (encoding === "ucs2" || encoding === "ucs-2" || encoding === "utf16le" || encoding === "utf-16le") {
|
|
621
|
-
if (arr.length < 2 || val.length < 2) {
|
|
622
|
-
return -1;
|
|
623
|
-
}
|
|
624
|
-
indexSize = 2;
|
|
625
|
-
arrLength /= 2;
|
|
626
|
-
valLength /= 2;
|
|
627
|
-
byteOffset /= 2;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
function read(buf, i2) {
|
|
631
|
-
if (indexSize === 1) {
|
|
632
|
-
return buf[i2];
|
|
633
|
-
} else {
|
|
634
|
-
return buf.readUInt16BE(i2 * indexSize);
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
var i;
|
|
638
|
-
if (dir) {
|
|
639
|
-
var foundIndex = -1;
|
|
640
|
-
for (i = byteOffset; i < arrLength; i++) {
|
|
641
|
-
if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
|
|
642
|
-
if (foundIndex === -1) foundIndex = i;
|
|
643
|
-
if (i - foundIndex + 1 === valLength)
|
|
644
|
-
return foundIndex * indexSize;
|
|
645
|
-
} else {
|
|
646
|
-
if (foundIndex !== -1) i -= i - foundIndex;
|
|
647
|
-
foundIndex = -1;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
} else {
|
|
651
|
-
if (byteOffset + valLength > arrLength)
|
|
652
|
-
byteOffset = arrLength - valLength;
|
|
653
|
-
for (i = byteOffset; i >= 0; i--) {
|
|
654
|
-
var found = true;
|
|
655
|
-
for (var j = 0; j < valLength; j++) {
|
|
656
|
-
if (read(arr, i + j) !== read(val, j)) {
|
|
657
|
-
found = false;
|
|
658
|
-
break;
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
if (found) return i;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
return -1;
|
|
665
|
-
}
|
|
666
|
-
function hexWrite(buf, string, offset, length) {
|
|
667
|
-
offset = Number(offset) || 0;
|
|
668
|
-
var remaining = buf.length - offset;
|
|
669
|
-
if (!length) {
|
|
670
|
-
length = remaining;
|
|
671
|
-
} else {
|
|
672
|
-
length = Number(length);
|
|
673
|
-
if (length > remaining) {
|
|
674
|
-
length = remaining;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
var strLen = string.length;
|
|
678
|
-
if (strLen % 2 !== 0) throw new TypeError("Invalid hex string");
|
|
679
|
-
if (length > strLen / 2) {
|
|
680
|
-
length = strLen / 2;
|
|
681
|
-
}
|
|
682
|
-
for (var i = 0; i < length; ++i) {
|
|
683
|
-
var parsed = parseInt(string.substr(i * 2, 2), 16);
|
|
684
|
-
if (isNaN(parsed)) return i;
|
|
685
|
-
buf[offset + i] = parsed;
|
|
686
|
-
}
|
|
687
|
-
return i;
|
|
688
|
-
}
|
|
689
|
-
function utf8Write(buf, string, offset, length) {
|
|
690
|
-
return blitBuffer(
|
|
691
|
-
utf8ToBytes(string, buf.length - offset),
|
|
692
|
-
buf,
|
|
693
|
-
offset,
|
|
694
|
-
length
|
|
695
|
-
);
|
|
696
|
-
}
|
|
697
|
-
function asciiWrite(buf, string, offset, length) {
|
|
698
|
-
return blitBuffer(asciiToBytes(string), buf, offset, length);
|
|
699
|
-
}
|
|
700
|
-
function latin1Write(buf, string, offset, length) {
|
|
701
|
-
return asciiWrite(buf, string, offset, length);
|
|
702
|
-
}
|
|
703
|
-
function base64Write(buf, string, offset, length) {
|
|
704
|
-
return blitBuffer(base64ToBytes(string), buf, offset, length);
|
|
705
|
-
}
|
|
706
|
-
function ucs2Write(buf, string, offset, length) {
|
|
707
|
-
return blitBuffer(
|
|
708
|
-
utf16leToBytes(string, buf.length - offset),
|
|
709
|
-
buf,
|
|
710
|
-
offset,
|
|
711
|
-
length
|
|
712
|
-
);
|
|
713
|
-
}
|
|
714
|
-
function base64Slice(buf, start, end) {
|
|
715
|
-
if (start === 0 && end === buf.length) {
|
|
716
|
-
return base64fromByteArray(buf);
|
|
717
|
-
} else {
|
|
718
|
-
return base64fromByteArray(buf.slice(start, end));
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
function utf8Slice(buf, start, end) {
|
|
722
|
-
end = Math.min(buf.length, end);
|
|
723
|
-
var res = [];
|
|
724
|
-
var i = start;
|
|
725
|
-
while (i < end) {
|
|
726
|
-
var firstByte = buf[i];
|
|
727
|
-
var codePoint = null;
|
|
728
|
-
var bytesPerSequence = firstByte > 239 ? 4 : firstByte > 223 ? 3 : firstByte > 191 ? 2 : 1;
|
|
729
|
-
if (i + bytesPerSequence <= end) {
|
|
730
|
-
var secondByte, thirdByte, fourthByte, tempCodePoint;
|
|
731
|
-
switch (bytesPerSequence) {
|
|
732
|
-
case 1:
|
|
733
|
-
if (firstByte < 128) {
|
|
734
|
-
codePoint = firstByte;
|
|
735
|
-
}
|
|
736
|
-
break;
|
|
737
|
-
case 2:
|
|
738
|
-
secondByte = buf[i + 1];
|
|
739
|
-
if ((secondByte & 192) === 128) {
|
|
740
|
-
tempCodePoint = (firstByte & 31) << 6 | secondByte & 63;
|
|
741
|
-
if (tempCodePoint > 127) {
|
|
742
|
-
codePoint = tempCodePoint;
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
break;
|
|
746
|
-
case 3:
|
|
747
|
-
secondByte = buf[i + 1];
|
|
748
|
-
thirdByte = buf[i + 2];
|
|
749
|
-
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128) {
|
|
750
|
-
tempCodePoint = (firstByte & 15) << 12 | (secondByte & 63) << 6 | thirdByte & 63;
|
|
751
|
-
if (tempCodePoint > 2047 && (tempCodePoint < 55296 || tempCodePoint > 57343)) {
|
|
752
|
-
codePoint = tempCodePoint;
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
break;
|
|
756
|
-
case 4:
|
|
757
|
-
secondByte = buf[i + 1];
|
|
758
|
-
thirdByte = buf[i + 2];
|
|
759
|
-
fourthByte = buf[i + 3];
|
|
760
|
-
if ((secondByte & 192) === 128 && (thirdByte & 192) === 128 && (fourthByte & 192) === 128) {
|
|
761
|
-
tempCodePoint = (firstByte & 15) << 18 | (secondByte & 63) << 12 | (thirdByte & 63) << 6 | fourthByte & 63;
|
|
762
|
-
if (tempCodePoint > 65535 && tempCodePoint < 1114112) {
|
|
763
|
-
codePoint = tempCodePoint;
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
if (codePoint === null) {
|
|
769
|
-
codePoint = 65533;
|
|
770
|
-
bytesPerSequence = 1;
|
|
771
|
-
} else if (codePoint > 65535) {
|
|
772
|
-
codePoint -= 65536;
|
|
773
|
-
res.push(codePoint >>> 10 & 1023 | 55296);
|
|
774
|
-
codePoint = 56320 | codePoint & 1023;
|
|
775
|
-
}
|
|
776
|
-
res.push(codePoint);
|
|
777
|
-
i += bytesPerSequence;
|
|
778
|
-
}
|
|
779
|
-
return decodeCodePointsArray(res);
|
|
780
|
-
}
|
|
781
|
-
function decodeCodePointsArray(codePoints) {
|
|
782
|
-
var len = codePoints.length;
|
|
783
|
-
if (len <= MAX_ARGUMENTS_LENGTH) {
|
|
784
|
-
return String.fromCharCode.apply(String, codePoints);
|
|
785
|
-
}
|
|
786
|
-
var res = "";
|
|
787
|
-
var i = 0;
|
|
788
|
-
while (i < len) {
|
|
789
|
-
res += String.fromCharCode.apply(
|
|
790
|
-
String,
|
|
791
|
-
codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
|
|
792
|
-
);
|
|
793
|
-
}
|
|
794
|
-
return res;
|
|
795
|
-
}
|
|
796
|
-
function asciiSlice(buf, start, end) {
|
|
797
|
-
var ret = "";
|
|
798
|
-
end = Math.min(buf.length, end);
|
|
799
|
-
for (var i = start; i < end; ++i) {
|
|
800
|
-
ret += String.fromCharCode(buf[i] & 127);
|
|
801
|
-
}
|
|
802
|
-
return ret;
|
|
803
|
-
}
|
|
804
|
-
function latin1Slice(buf, start, end) {
|
|
805
|
-
var ret = "";
|
|
806
|
-
end = Math.min(buf.length, end);
|
|
807
|
-
for (var i = start; i < end; ++i) {
|
|
808
|
-
ret += String.fromCharCode(buf[i]);
|
|
809
|
-
}
|
|
810
|
-
return ret;
|
|
811
|
-
}
|
|
812
|
-
function hexSlice(buf, start, end) {
|
|
813
|
-
var len = buf.length;
|
|
814
|
-
if (!start || start < 0) start = 0;
|
|
815
|
-
if (!end || end < 0 || end > len) end = len;
|
|
816
|
-
var out = "";
|
|
817
|
-
for (var i = start; i < end; ++i) {
|
|
818
|
-
out += toHex(buf[i]);
|
|
819
|
-
}
|
|
820
|
-
return out;
|
|
821
|
-
}
|
|
822
|
-
function utf16leSlice(buf, start, end) {
|
|
823
|
-
var bytes = buf.slice(start, end);
|
|
824
|
-
var res = "";
|
|
825
|
-
for (var i = 0; i < bytes.length; i += 2) {
|
|
826
|
-
res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256);
|
|
827
|
-
}
|
|
828
|
-
return res;
|
|
829
|
-
}
|
|
830
|
-
function checkOffset(offset, ext, length) {
|
|
831
|
-
if (offset % 1 !== 0 || offset < 0)
|
|
832
|
-
throw new RangeError("offset is not uint");
|
|
833
|
-
if (offset + ext > length)
|
|
834
|
-
throw new RangeError("Trying to access beyond buffer length");
|
|
835
|
-
}
|
|
836
|
-
function checkInt(buf, value, offset, ext, max, min) {
|
|
837
|
-
if (!internalIsBuffer(buf))
|
|
838
|
-
throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
839
|
-
if (value > max || value < min)
|
|
840
|
-
throw new RangeError('"value" argument is out of bounds');
|
|
841
|
-
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
842
|
-
}
|
|
843
|
-
function objectWriteUInt16(buf, value, offset, littleEndian) {
|
|
844
|
-
if (value < 0) value = 65535 + value + 1;
|
|
845
|
-
for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
|
|
846
|
-
buf[offset + i] = (value & 255 << 8 * (littleEndian ? i : 1 - i)) >>> (littleEndian ? i : 1 - i) * 8;
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
function objectWriteUInt32(buf, value, offset, littleEndian) {
|
|
850
|
-
if (value < 0) value = 4294967295 + value + 1;
|
|
851
|
-
for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
|
|
852
|
-
buf[offset + i] = value >>> (littleEndian ? i : 3 - i) * 8 & 255;
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
function checkIEEE754(buf, value, offset, ext, max, min) {
|
|
856
|
-
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
857
|
-
if (offset < 0) throw new RangeError("Index out of range");
|
|
858
|
-
}
|
|
859
|
-
function writeFloat(buf, value, offset, littleEndian, noAssert) {
|
|
860
|
-
if (!noAssert) {
|
|
861
|
-
checkIEEE754(
|
|
862
|
-
buf,
|
|
863
|
-
value,
|
|
864
|
-
offset,
|
|
865
|
-
4,
|
|
866
|
-
34028234663852886e22,
|
|
867
|
-
-34028234663852886e22
|
|
868
|
-
);
|
|
869
|
-
}
|
|
870
|
-
ieee754write(buf, value, offset, littleEndian, 23, 4);
|
|
871
|
-
return offset + 4;
|
|
872
|
-
}
|
|
873
|
-
function writeDouble(buf, value, offset, littleEndian, noAssert) {
|
|
874
|
-
if (!noAssert) {
|
|
875
|
-
checkIEEE754(
|
|
876
|
-
buf,
|
|
877
|
-
value,
|
|
878
|
-
offset,
|
|
879
|
-
8,
|
|
880
|
-
17976931348623157e292,
|
|
881
|
-
-17976931348623157e292
|
|
882
|
-
);
|
|
883
|
-
}
|
|
884
|
-
ieee754write(buf, value, offset, littleEndian, 52, 8);
|
|
885
|
-
return offset + 8;
|
|
886
|
-
}
|
|
887
|
-
function base64clean(str) {
|
|
888
|
-
str = stringtrim(str).replace(INVALID_BASE64_RE, "");
|
|
889
|
-
if (str.length < 2) return "";
|
|
890
|
-
while (str.length % 4 !== 0) {
|
|
891
|
-
str = str + "=";
|
|
892
|
-
}
|
|
893
|
-
return str;
|
|
894
|
-
}
|
|
895
|
-
function stringtrim(str) {
|
|
896
|
-
if (str.trim) return str.trim();
|
|
897
|
-
return str.replace(/^\s+|\s+$/g, "");
|
|
898
|
-
}
|
|
899
|
-
function toHex(n) {
|
|
900
|
-
if (n < 16) return "0" + n.toString(16);
|
|
901
|
-
return n.toString(16);
|
|
902
|
-
}
|
|
903
|
-
function utf8ToBytes(string, units) {
|
|
904
|
-
units = units || Infinity;
|
|
905
|
-
var codePoint;
|
|
906
|
-
var length = string.length;
|
|
907
|
-
var leadSurrogate = null;
|
|
908
|
-
var bytes = [];
|
|
909
|
-
for (var i = 0; i < length; ++i) {
|
|
910
|
-
codePoint = string.charCodeAt(i);
|
|
911
|
-
if (codePoint > 55295 && codePoint < 57344) {
|
|
912
|
-
if (!leadSurrogate) {
|
|
913
|
-
if (codePoint > 56319) {
|
|
914
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
915
|
-
continue;
|
|
916
|
-
} else if (i + 1 === length) {
|
|
917
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
918
|
-
continue;
|
|
919
|
-
}
|
|
920
|
-
leadSurrogate = codePoint;
|
|
921
|
-
continue;
|
|
922
|
-
}
|
|
923
|
-
if (codePoint < 56320) {
|
|
924
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
925
|
-
leadSurrogate = codePoint;
|
|
926
|
-
continue;
|
|
927
|
-
}
|
|
928
|
-
codePoint = (leadSurrogate - 55296 << 10 | codePoint - 56320) + 65536;
|
|
929
|
-
} else if (leadSurrogate) {
|
|
930
|
-
if ((units -= 3) > -1) bytes.push(239, 191, 189);
|
|
931
|
-
}
|
|
932
|
-
leadSurrogate = null;
|
|
933
|
-
if (codePoint < 128) {
|
|
934
|
-
if ((units -= 1) < 0) break;
|
|
935
|
-
bytes.push(codePoint);
|
|
936
|
-
} else if (codePoint < 2048) {
|
|
937
|
-
if ((units -= 2) < 0) break;
|
|
938
|
-
bytes.push(codePoint >> 6 | 192, codePoint & 63 | 128);
|
|
939
|
-
} else if (codePoint < 65536) {
|
|
940
|
-
if ((units -= 3) < 0) break;
|
|
941
|
-
bytes.push(
|
|
942
|
-
codePoint >> 12 | 224,
|
|
943
|
-
codePoint >> 6 & 63 | 128,
|
|
944
|
-
codePoint & 63 | 128
|
|
945
|
-
);
|
|
946
|
-
} else if (codePoint < 1114112) {
|
|
947
|
-
if ((units -= 4) < 0) break;
|
|
948
|
-
bytes.push(
|
|
949
|
-
codePoint >> 18 | 240,
|
|
950
|
-
codePoint >> 12 & 63 | 128,
|
|
951
|
-
codePoint >> 6 & 63 | 128,
|
|
952
|
-
codePoint & 63 | 128
|
|
953
|
-
);
|
|
954
|
-
} else {
|
|
955
|
-
throw new Error("Invalid code point");
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
return bytes;
|
|
959
|
-
}
|
|
960
|
-
function asciiToBytes(str) {
|
|
961
|
-
var byteArray = [];
|
|
962
|
-
for (var i = 0; i < str.length; ++i) {
|
|
963
|
-
byteArray.push(str.charCodeAt(i) & 255);
|
|
964
|
-
}
|
|
965
|
-
return byteArray;
|
|
966
|
-
}
|
|
967
|
-
function utf16leToBytes(str, units) {
|
|
968
|
-
var c, hi, lo;
|
|
969
|
-
var byteArray = [];
|
|
970
|
-
for (var i = 0; i < str.length; ++i) {
|
|
971
|
-
if ((units -= 2) < 0) break;
|
|
972
|
-
c = str.charCodeAt(i);
|
|
973
|
-
hi = c >> 8;
|
|
974
|
-
lo = c % 256;
|
|
975
|
-
byteArray.push(lo);
|
|
976
|
-
byteArray.push(hi);
|
|
977
|
-
}
|
|
978
|
-
return byteArray;
|
|
979
|
-
}
|
|
980
|
-
function base64ToBytes(str) {
|
|
981
|
-
return base64toByteArray(base64clean(str));
|
|
982
|
-
}
|
|
983
|
-
function blitBuffer(src, dst, offset, length) {
|
|
984
|
-
for (var i = 0; i < length; ++i) {
|
|
985
|
-
if (i + offset >= dst.length || i >= src.length) break;
|
|
986
|
-
dst[i + offset] = src[i];
|
|
987
|
-
}
|
|
988
|
-
return i;
|
|
989
|
-
}
|
|
990
|
-
function isnan(val) {
|
|
991
|
-
return val !== val;
|
|
992
|
-
}
|
|
993
|
-
function isBuffer(obj) {
|
|
994
|
-
return obj != null && (!!obj._isBuffer || isFastBuffer(obj) || isSlowBuffer(obj));
|
|
995
|
-
}
|
|
996
|
-
function isFastBuffer(obj) {
|
|
997
|
-
return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
|
|
998
|
-
}
|
|
999
|
-
function isSlowBuffer(obj) {
|
|
1000
|
-
return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isFastBuffer(obj.slice(0, 0));
|
|
1001
|
-
}
|
|
1002
|
-
function ieee754read(buffer, offset, isLE, mLen, nBytes) {
|
|
1003
|
-
var e, m;
|
|
1004
|
-
var eLen = nBytes * 8 - mLen - 1;
|
|
1005
|
-
var eMax = (1 << eLen) - 1;
|
|
1006
|
-
var eBias = eMax >> 1;
|
|
1007
|
-
var nBits = -7;
|
|
1008
|
-
var i = isLE ? nBytes - 1 : 0;
|
|
1009
|
-
var d = isLE ? -1 : 1;
|
|
1010
|
-
var s = buffer[offset + i];
|
|
1011
|
-
i += d;
|
|
1012
|
-
e = s & (1 << -nBits) - 1;
|
|
1013
|
-
s >>= -nBits;
|
|
1014
|
-
nBits += eLen;
|
|
1015
|
-
for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
1016
|
-
}
|
|
1017
|
-
m = e & (1 << -nBits) - 1;
|
|
1018
|
-
e >>= -nBits;
|
|
1019
|
-
nBits += mLen;
|
|
1020
|
-
for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
|
|
1021
|
-
}
|
|
1022
|
-
if (e === 0) {
|
|
1023
|
-
e = 1 - eBias;
|
|
1024
|
-
} else if (e === eMax) {
|
|
1025
|
-
return m ? NaN : (s ? -1 : 1) * Infinity;
|
|
1026
|
-
} else {
|
|
1027
|
-
m = m + Math.pow(2, mLen);
|
|
1028
|
-
e = e - eBias;
|
|
1029
|
-
}
|
|
1030
|
-
return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
|
|
1031
|
-
}
|
|
1032
|
-
function ieee754write(buffer, value, offset, isLE, mLen, nBytes) {
|
|
1033
|
-
var e, m, c;
|
|
1034
|
-
var eLen = nBytes * 8 - mLen - 1;
|
|
1035
|
-
var eMax = (1 << eLen) - 1;
|
|
1036
|
-
var eBias = eMax >> 1;
|
|
1037
|
-
var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
|
|
1038
|
-
var i = isLE ? 0 : nBytes - 1;
|
|
1039
|
-
var d = isLE ? 1 : -1;
|
|
1040
|
-
var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
|
|
1041
|
-
value = Math.abs(value);
|
|
1042
|
-
if (isNaN(value) || value === Infinity) {
|
|
1043
|
-
m = isNaN(value) ? 1 : 0;
|
|
1044
|
-
e = eMax;
|
|
1045
|
-
} else {
|
|
1046
|
-
e = Math.floor(Math.log(value) / Math.LN2);
|
|
1047
|
-
if (value * (c = Math.pow(2, -e)) < 1) {
|
|
1048
|
-
e--;
|
|
1049
|
-
c *= 2;
|
|
1050
|
-
}
|
|
1051
|
-
if (e + eBias >= 1) {
|
|
1052
|
-
value += rt / c;
|
|
1053
|
-
} else {
|
|
1054
|
-
value += rt * Math.pow(2, 1 - eBias);
|
|
1055
|
-
}
|
|
1056
|
-
if (value * c >= 2) {
|
|
1057
|
-
e++;
|
|
1058
|
-
c /= 2;
|
|
1059
|
-
}
|
|
1060
|
-
if (e + eBias >= eMax) {
|
|
1061
|
-
m = 0;
|
|
1062
|
-
e = eMax;
|
|
1063
|
-
} else if (e + eBias >= 1) {
|
|
1064
|
-
m = (value * c - 1) * Math.pow(2, mLen);
|
|
1065
|
-
e = e + eBias;
|
|
1066
|
-
} else {
|
|
1067
|
-
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
|
|
1068
|
-
e = 0;
|
|
1069
|
-
}
|
|
1070
|
-
}
|
|
1071
|
-
for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
|
|
1072
|
-
}
|
|
1073
|
-
e = e << mLen | m;
|
|
1074
|
-
eLen += mLen;
|
|
1075
|
-
for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
|
|
1076
|
-
}
|
|
1077
|
-
buffer[offset + i - d] |= s * 128;
|
|
1078
|
-
}
|
|
1079
|
-
var lookup, revLookup, Arr, inited, MAX_ARGUMENTS_LENGTH, INVALID_BASE64_RE;
|
|
1080
|
-
var init_Buffer = __esm({
|
|
1081
|
-
"../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/Buffer.js"() {
|
|
1082
|
-
"use strict";
|
|
1083
|
-
init_process();
|
|
1084
|
-
init_buffer();
|
|
1085
|
-
lookup = [];
|
|
1086
|
-
revLookup = [];
|
|
1087
|
-
Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
1088
|
-
inited = false;
|
|
1089
|
-
Buffer2.TYPED_ARRAY_SUPPORT = globalThis.TYPED_ARRAY_SUPPORT !== void 0 ? globalThis.TYPED_ARRAY_SUPPORT : true;
|
|
1090
|
-
Buffer2.poolSize = 8192;
|
|
1091
|
-
Buffer2._augment = function(arr) {
|
|
1092
|
-
arr.__proto__ = Buffer2.prototype;
|
|
1093
|
-
return arr;
|
|
1094
|
-
};
|
|
1095
|
-
Buffer2.from = function(value, encodingOrOffset, length) {
|
|
1096
|
-
return from(null, value, encodingOrOffset, length);
|
|
1097
|
-
};
|
|
1098
|
-
Buffer2.kMaxLength = kMaxLength();
|
|
1099
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1100
|
-
Buffer2.prototype.__proto__ = Uint8Array.prototype;
|
|
1101
|
-
Buffer2.__proto__ = Uint8Array;
|
|
1102
|
-
if (typeof Symbol !== "undefined" && Symbol.species && Buffer2[Symbol.species] === Buffer2) {
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
Buffer2.alloc = function(size, fill2, encoding) {
|
|
1106
|
-
return alloc(null, size, fill2, encoding);
|
|
1107
|
-
};
|
|
1108
|
-
Buffer2.allocUnsafe = function(size) {
|
|
1109
|
-
return allocUnsafe(null, size);
|
|
1110
|
-
};
|
|
1111
|
-
Buffer2.allocUnsafeSlow = function(size) {
|
|
1112
|
-
return allocUnsafe(null, size);
|
|
1113
|
-
};
|
|
1114
|
-
Buffer2.isBuffer = isBuffer;
|
|
1115
|
-
Buffer2.compare = function compare(a, b) {
|
|
1116
|
-
if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
|
|
1117
|
-
throw new TypeError("Arguments must be Buffers");
|
|
1118
|
-
}
|
|
1119
|
-
if (a === b) return 0;
|
|
1120
|
-
var x = a.length;
|
|
1121
|
-
var y = b.length;
|
|
1122
|
-
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
|
|
1123
|
-
if (a[i] !== b[i]) {
|
|
1124
|
-
x = a[i];
|
|
1125
|
-
y = b[i];
|
|
1126
|
-
break;
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
if (x < y) return -1;
|
|
1130
|
-
if (y < x) return 1;
|
|
1131
|
-
return 0;
|
|
1132
|
-
};
|
|
1133
|
-
Buffer2.isEncoding = function isEncoding(encoding) {
|
|
1134
|
-
switch (String(encoding).toLowerCase()) {
|
|
1135
|
-
case "hex":
|
|
1136
|
-
case "utf8":
|
|
1137
|
-
case "utf-8":
|
|
1138
|
-
case "ascii":
|
|
1139
|
-
case "latin1":
|
|
1140
|
-
case "binary":
|
|
1141
|
-
case "base64":
|
|
1142
|
-
case "ucs2":
|
|
1143
|
-
case "ucs-2":
|
|
1144
|
-
case "utf16le":
|
|
1145
|
-
case "utf-16le":
|
|
1146
|
-
return true;
|
|
1147
|
-
default:
|
|
1148
|
-
return false;
|
|
1149
|
-
}
|
|
1150
|
-
};
|
|
1151
|
-
Buffer2.concat = function concat(list, length) {
|
|
1152
|
-
if (!Array.isArray(list)) {
|
|
1153
|
-
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
1154
|
-
}
|
|
1155
|
-
if (list.length === 0) {
|
|
1156
|
-
return Buffer2.alloc(0);
|
|
1157
|
-
}
|
|
1158
|
-
var i;
|
|
1159
|
-
if (length === void 0) {
|
|
1160
|
-
length = 0;
|
|
1161
|
-
for (i = 0; i < list.length; ++i) {
|
|
1162
|
-
length += list[i].length;
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
var buffer = Buffer2.allocUnsafe(length);
|
|
1166
|
-
var pos = 0;
|
|
1167
|
-
for (i = 0; i < list.length; ++i) {
|
|
1168
|
-
var buf = list[i];
|
|
1169
|
-
if (!internalIsBuffer(buf)) {
|
|
1170
|
-
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
1171
|
-
}
|
|
1172
|
-
buf.copy(buffer, pos);
|
|
1173
|
-
pos += buf.length;
|
|
1174
|
-
}
|
|
1175
|
-
return buffer;
|
|
1176
|
-
};
|
|
1177
|
-
Buffer2.byteLength = byteLength;
|
|
1178
|
-
Buffer2.prototype._isBuffer = true;
|
|
1179
|
-
Buffer2.prototype.swap16 = function swap16() {
|
|
1180
|
-
var len = this.length;
|
|
1181
|
-
if (len % 2 !== 0) {
|
|
1182
|
-
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
1183
|
-
}
|
|
1184
|
-
for (var i = 0; i < len; i += 2) {
|
|
1185
|
-
swap(this, i, i + 1);
|
|
1186
|
-
}
|
|
1187
|
-
return this;
|
|
1188
|
-
};
|
|
1189
|
-
Buffer2.prototype.swap32 = function swap32() {
|
|
1190
|
-
var len = this.length;
|
|
1191
|
-
if (len % 4 !== 0) {
|
|
1192
|
-
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
1193
|
-
}
|
|
1194
|
-
for (var i = 0; i < len; i += 4) {
|
|
1195
|
-
swap(this, i, i + 3);
|
|
1196
|
-
swap(this, i + 1, i + 2);
|
|
1197
|
-
}
|
|
1198
|
-
return this;
|
|
1199
|
-
};
|
|
1200
|
-
Buffer2.prototype.swap64 = function swap64() {
|
|
1201
|
-
var len = this.length;
|
|
1202
|
-
if (len % 8 !== 0) {
|
|
1203
|
-
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
1204
|
-
}
|
|
1205
|
-
for (var i = 0; i < len; i += 8) {
|
|
1206
|
-
swap(this, i, i + 7);
|
|
1207
|
-
swap(this, i + 1, i + 6);
|
|
1208
|
-
swap(this, i + 2, i + 5);
|
|
1209
|
-
swap(this, i + 3, i + 4);
|
|
1210
|
-
}
|
|
1211
|
-
return this;
|
|
1212
|
-
};
|
|
1213
|
-
Buffer2.prototype.toString = function toString() {
|
|
1214
|
-
var length = this.length | 0;
|
|
1215
|
-
if (length === 0) return "";
|
|
1216
|
-
if (arguments.length === 0) return utf8Slice(this, 0, length);
|
|
1217
|
-
return slowToString.apply(this, arguments);
|
|
1218
|
-
};
|
|
1219
|
-
Buffer2.prototype.equals = function equals(b) {
|
|
1220
|
-
if (!internalIsBuffer(b)) throw new TypeError("Argument must be a Buffer");
|
|
1221
|
-
if (this === b) return true;
|
|
1222
|
-
return Buffer2.compare(this, b) === 0;
|
|
1223
|
-
};
|
|
1224
|
-
Buffer2.prototype.compare = function compare2(target, start, end, thisStart, thisEnd) {
|
|
1225
|
-
if (!internalIsBuffer(target)) {
|
|
1226
|
-
throw new TypeError("Argument must be a Buffer");
|
|
1227
|
-
}
|
|
1228
|
-
if (start === void 0) {
|
|
1229
|
-
start = 0;
|
|
1230
|
-
}
|
|
1231
|
-
if (end === void 0) {
|
|
1232
|
-
end = target ? target.length : 0;
|
|
1233
|
-
}
|
|
1234
|
-
if (thisStart === void 0) {
|
|
1235
|
-
thisStart = 0;
|
|
1236
|
-
}
|
|
1237
|
-
if (thisEnd === void 0) {
|
|
1238
|
-
thisEnd = this.length;
|
|
1239
|
-
}
|
|
1240
|
-
if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
|
|
1241
|
-
throw new RangeError("out of range index");
|
|
1242
|
-
}
|
|
1243
|
-
if (thisStart >= thisEnd && start >= end) {
|
|
1244
|
-
return 0;
|
|
1245
|
-
}
|
|
1246
|
-
if (thisStart >= thisEnd) {
|
|
1247
|
-
return -1;
|
|
1248
|
-
}
|
|
1249
|
-
if (start >= end) {
|
|
1250
|
-
return 1;
|
|
1251
|
-
}
|
|
1252
|
-
start >>>= 0;
|
|
1253
|
-
end >>>= 0;
|
|
1254
|
-
thisStart >>>= 0;
|
|
1255
|
-
thisEnd >>>= 0;
|
|
1256
|
-
if (this === target) return 0;
|
|
1257
|
-
var x = thisEnd - thisStart;
|
|
1258
|
-
var y = end - start;
|
|
1259
|
-
var len = Math.min(x, y);
|
|
1260
|
-
var thisCopy = this.slice(thisStart, thisEnd);
|
|
1261
|
-
var targetCopy = target.slice(start, end);
|
|
1262
|
-
for (var i = 0; i < len; ++i) {
|
|
1263
|
-
if (thisCopy[i] !== targetCopy[i]) {
|
|
1264
|
-
x = thisCopy[i];
|
|
1265
|
-
y = targetCopy[i];
|
|
1266
|
-
break;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
if (x < y) return -1;
|
|
1270
|
-
if (y < x) return 1;
|
|
1271
|
-
return 0;
|
|
1272
|
-
};
|
|
1273
|
-
Buffer2.prototype.includes = function includes(val, byteOffset, encoding) {
|
|
1274
|
-
return this.indexOf(val, byteOffset, encoding) !== -1;
|
|
1275
|
-
};
|
|
1276
|
-
Buffer2.prototype.indexOf = function indexOf(val, byteOffset, encoding) {
|
|
1277
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, true);
|
|
1278
|
-
};
|
|
1279
|
-
Buffer2.prototype.lastIndexOf = function lastIndexOf(val, byteOffset, encoding) {
|
|
1280
|
-
return bidirectionalIndexOf(this, val, byteOffset, encoding, false);
|
|
1281
|
-
};
|
|
1282
|
-
Buffer2.prototype.write = function write(string, offset, length, encoding) {
|
|
1283
|
-
if (offset === void 0) {
|
|
1284
|
-
encoding = "utf8";
|
|
1285
|
-
length = this.length;
|
|
1286
|
-
offset = 0;
|
|
1287
|
-
} else if (length === void 0 && typeof offset === "string") {
|
|
1288
|
-
encoding = offset;
|
|
1289
|
-
length = this.length;
|
|
1290
|
-
offset = 0;
|
|
1291
|
-
} else if (isFinite(offset)) {
|
|
1292
|
-
offset = offset | 0;
|
|
1293
|
-
if (isFinite(length)) {
|
|
1294
|
-
length = length | 0;
|
|
1295
|
-
if (encoding === void 0) encoding = "utf8";
|
|
1296
|
-
} else {
|
|
1297
|
-
encoding = length;
|
|
1298
|
-
length = void 0;
|
|
1299
|
-
}
|
|
1300
|
-
} else {
|
|
1301
|
-
throw new Error(
|
|
1302
|
-
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
|
|
1303
|
-
);
|
|
1304
|
-
}
|
|
1305
|
-
var remaining = this.length - offset;
|
|
1306
|
-
if (length === void 0 || length > remaining) length = remaining;
|
|
1307
|
-
if (string.length > 0 && (length < 0 || offset < 0) || offset > this.length) {
|
|
1308
|
-
throw new RangeError("Attempt to write outside buffer bounds");
|
|
1309
|
-
}
|
|
1310
|
-
if (!encoding) encoding = "utf8";
|
|
1311
|
-
var loweredCase = false;
|
|
1312
|
-
for (; ; ) {
|
|
1313
|
-
switch (encoding) {
|
|
1314
|
-
case "hex":
|
|
1315
|
-
return hexWrite(this, string, offset, length);
|
|
1316
|
-
case "utf8":
|
|
1317
|
-
case "utf-8":
|
|
1318
|
-
return utf8Write(this, string, offset, length);
|
|
1319
|
-
case "ascii":
|
|
1320
|
-
return asciiWrite(this, string, offset, length);
|
|
1321
|
-
case "latin1":
|
|
1322
|
-
case "binary":
|
|
1323
|
-
return latin1Write(this, string, offset, length);
|
|
1324
|
-
case "base64":
|
|
1325
|
-
return base64Write(this, string, offset, length);
|
|
1326
|
-
case "ucs2":
|
|
1327
|
-
case "ucs-2":
|
|
1328
|
-
case "utf16le":
|
|
1329
|
-
case "utf-16le":
|
|
1330
|
-
return ucs2Write(this, string, offset, length);
|
|
1331
|
-
default:
|
|
1332
|
-
if (loweredCase)
|
|
1333
|
-
throw new TypeError("Unknown encoding: " + encoding);
|
|
1334
|
-
encoding = ("" + encoding).toLowerCase();
|
|
1335
|
-
loweredCase = true;
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
};
|
|
1339
|
-
Buffer2.prototype.toJSON = function toJSON() {
|
|
1340
|
-
return {
|
|
1341
|
-
type: "Buffer",
|
|
1342
|
-
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
1343
|
-
};
|
|
1344
|
-
};
|
|
1345
|
-
MAX_ARGUMENTS_LENGTH = 4096;
|
|
1346
|
-
Buffer2.prototype.slice = function slice(start, end) {
|
|
1347
|
-
var len = this.length;
|
|
1348
|
-
start = ~~start;
|
|
1349
|
-
end = end === void 0 ? len : ~~end;
|
|
1350
|
-
if (start < 0) {
|
|
1351
|
-
start += len;
|
|
1352
|
-
if (start < 0) start = 0;
|
|
1353
|
-
} else if (start > len) {
|
|
1354
|
-
start = len;
|
|
1355
|
-
}
|
|
1356
|
-
if (end < 0) {
|
|
1357
|
-
end += len;
|
|
1358
|
-
if (end < 0) end = 0;
|
|
1359
|
-
} else if (end > len) {
|
|
1360
|
-
end = len;
|
|
1361
|
-
}
|
|
1362
|
-
if (end < start) end = start;
|
|
1363
|
-
var newBuf;
|
|
1364
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1365
|
-
newBuf = this.subarray(start, end);
|
|
1366
|
-
newBuf.__proto__ = Buffer2.prototype;
|
|
1367
|
-
} else {
|
|
1368
|
-
var sliceLen = end - start;
|
|
1369
|
-
newBuf = new Buffer2(sliceLen, void 0);
|
|
1370
|
-
for (var i = 0; i < sliceLen; ++i) {
|
|
1371
|
-
newBuf[i] = this[i + start];
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
return newBuf;
|
|
1375
|
-
};
|
|
1376
|
-
Buffer2.prototype.readUIntLE = function readUIntLE(offset, byteLength2, noAssert) {
|
|
1377
|
-
offset = offset | 0;
|
|
1378
|
-
byteLength2 = byteLength2 | 0;
|
|
1379
|
-
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1380
|
-
var val = this[offset];
|
|
1381
|
-
var mul = 1;
|
|
1382
|
-
var i = 0;
|
|
1383
|
-
while (++i < byteLength2 && (mul *= 256)) {
|
|
1384
|
-
val += this[offset + i] * mul;
|
|
1385
|
-
}
|
|
1386
|
-
return val;
|
|
1387
|
-
};
|
|
1388
|
-
Buffer2.prototype.readUIntBE = function readUIntBE(offset, byteLength2, noAssert) {
|
|
1389
|
-
offset = offset | 0;
|
|
1390
|
-
byteLength2 = byteLength2 | 0;
|
|
1391
|
-
if (!noAssert) {
|
|
1392
|
-
checkOffset(offset, byteLength2, this.length);
|
|
1393
|
-
}
|
|
1394
|
-
var val = this[offset + --byteLength2];
|
|
1395
|
-
var mul = 1;
|
|
1396
|
-
while (byteLength2 > 0 && (mul *= 256)) {
|
|
1397
|
-
val += this[offset + --byteLength2] * mul;
|
|
1398
|
-
}
|
|
1399
|
-
return val;
|
|
1400
|
-
};
|
|
1401
|
-
Buffer2.prototype.readUInt8 = function readUInt8(offset, noAssert) {
|
|
1402
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1403
|
-
return this[offset];
|
|
1404
|
-
};
|
|
1405
|
-
Buffer2.prototype.readUInt16LE = function readUInt16LE(offset, noAssert) {
|
|
1406
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1407
|
-
return this[offset] | this[offset + 1] << 8;
|
|
1408
|
-
};
|
|
1409
|
-
Buffer2.prototype.readUInt16BE = function readUInt16BE(offset, noAssert) {
|
|
1410
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1411
|
-
return this[offset] << 8 | this[offset + 1];
|
|
1412
|
-
};
|
|
1413
|
-
Buffer2.prototype.readUInt32LE = function readUInt32LE(offset, noAssert) {
|
|
1414
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1415
|
-
return (this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16) + this[offset + 3] * 16777216;
|
|
1416
|
-
};
|
|
1417
|
-
Buffer2.prototype.readUInt32BE = function readUInt32BE(offset, noAssert) {
|
|
1418
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1419
|
-
return this[offset] * 16777216 + (this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3]);
|
|
1420
|
-
};
|
|
1421
|
-
Buffer2.prototype.readIntLE = function readIntLE(offset, byteLength2, noAssert) {
|
|
1422
|
-
offset = offset | 0;
|
|
1423
|
-
byteLength2 = byteLength2 | 0;
|
|
1424
|
-
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1425
|
-
var val = this[offset];
|
|
1426
|
-
var mul = 1;
|
|
1427
|
-
var i = 0;
|
|
1428
|
-
while (++i < byteLength2 && (mul *= 256)) {
|
|
1429
|
-
val += this[offset + i] * mul;
|
|
1430
|
-
}
|
|
1431
|
-
mul *= 128;
|
|
1432
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1433
|
-
return val;
|
|
1434
|
-
};
|
|
1435
|
-
Buffer2.prototype.readIntBE = function readIntBE(offset, byteLength2, noAssert) {
|
|
1436
|
-
offset = offset | 0;
|
|
1437
|
-
byteLength2 = byteLength2 | 0;
|
|
1438
|
-
if (!noAssert) checkOffset(offset, byteLength2, this.length);
|
|
1439
|
-
var i = byteLength2;
|
|
1440
|
-
var mul = 1;
|
|
1441
|
-
var val = this[offset + --i];
|
|
1442
|
-
while (i > 0 && (mul *= 256)) {
|
|
1443
|
-
val += this[offset + --i] * mul;
|
|
1444
|
-
}
|
|
1445
|
-
mul *= 128;
|
|
1446
|
-
if (val >= mul) val -= Math.pow(2, 8 * byteLength2);
|
|
1447
|
-
return val;
|
|
1448
|
-
};
|
|
1449
|
-
Buffer2.prototype.readInt8 = function readInt8(offset, noAssert) {
|
|
1450
|
-
if (!noAssert) checkOffset(offset, 1, this.length);
|
|
1451
|
-
if (!(this[offset] & 128)) return this[offset];
|
|
1452
|
-
return (255 - this[offset] + 1) * -1;
|
|
1453
|
-
};
|
|
1454
|
-
Buffer2.prototype.readInt16LE = function readInt16LE(offset, noAssert) {
|
|
1455
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1456
|
-
var val = this[offset] | this[offset + 1] << 8;
|
|
1457
|
-
return val & 32768 ? val | 4294901760 : val;
|
|
1458
|
-
};
|
|
1459
|
-
Buffer2.prototype.readInt16BE = function readInt16BE(offset, noAssert) {
|
|
1460
|
-
if (!noAssert) checkOffset(offset, 2, this.length);
|
|
1461
|
-
var val = this[offset + 1] | this[offset] << 8;
|
|
1462
|
-
return val & 32768 ? val | 4294901760 : val;
|
|
1463
|
-
};
|
|
1464
|
-
Buffer2.prototype.readInt32LE = function readInt32LE(offset, noAssert) {
|
|
1465
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1466
|
-
return this[offset] | this[offset + 1] << 8 | this[offset + 2] << 16 | this[offset + 3] << 24;
|
|
1467
|
-
};
|
|
1468
|
-
Buffer2.prototype.readInt32BE = function readInt32BE(offset, noAssert) {
|
|
1469
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1470
|
-
return this[offset] << 24 | this[offset + 1] << 16 | this[offset + 2] << 8 | this[offset + 3];
|
|
1471
|
-
};
|
|
1472
|
-
Buffer2.prototype.readFloatLE = function readFloatLE(offset, noAssert) {
|
|
1473
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1474
|
-
return ieee754read(this, offset, true, 23, 4);
|
|
1475
|
-
};
|
|
1476
|
-
Buffer2.prototype.readFloatBE = function readFloatBE(offset, noAssert) {
|
|
1477
|
-
if (!noAssert) checkOffset(offset, 4, this.length);
|
|
1478
|
-
return ieee754read(this, offset, false, 23, 4);
|
|
1479
|
-
};
|
|
1480
|
-
Buffer2.prototype.readDoubleLE = function readDoubleLE(offset, noAssert) {
|
|
1481
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1482
|
-
return ieee754read(this, offset, true, 52, 8);
|
|
1483
|
-
};
|
|
1484
|
-
Buffer2.prototype.readDoubleBE = function readDoubleBE(offset, noAssert) {
|
|
1485
|
-
if (!noAssert) checkOffset(offset, 8, this.length);
|
|
1486
|
-
return ieee754read(this, offset, false, 52, 8);
|
|
1487
|
-
};
|
|
1488
|
-
Buffer2.prototype.writeUIntLE = function writeUIntLE(value, offset, byteLength2, noAssert) {
|
|
1489
|
-
value = +value;
|
|
1490
|
-
offset = offset | 0;
|
|
1491
|
-
byteLength2 = byteLength2 | 0;
|
|
1492
|
-
if (!noAssert) {
|
|
1493
|
-
var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1494
|
-
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1495
|
-
}
|
|
1496
|
-
var mul = 1;
|
|
1497
|
-
var i = 0;
|
|
1498
|
-
this[offset] = value & 255;
|
|
1499
|
-
while (++i < byteLength2 && (mul *= 256)) {
|
|
1500
|
-
this[offset + i] = value / mul & 255;
|
|
1501
|
-
}
|
|
1502
|
-
return offset + byteLength2;
|
|
1503
|
-
};
|
|
1504
|
-
Buffer2.prototype.writeUIntBE = function writeUIntBE(value, offset, byteLength2, noAssert) {
|
|
1505
|
-
value = +value;
|
|
1506
|
-
offset = offset | 0;
|
|
1507
|
-
byteLength2 = byteLength2 | 0;
|
|
1508
|
-
if (!noAssert) {
|
|
1509
|
-
var maxBytes = Math.pow(2, 8 * byteLength2) - 1;
|
|
1510
|
-
checkInt(this, value, offset, byteLength2, maxBytes, 0);
|
|
1511
|
-
}
|
|
1512
|
-
var i = byteLength2 - 1;
|
|
1513
|
-
var mul = 1;
|
|
1514
|
-
this[offset + i] = value & 255;
|
|
1515
|
-
while (--i >= 0 && (mul *= 256)) {
|
|
1516
|
-
this[offset + i] = value / mul & 255;
|
|
1517
|
-
}
|
|
1518
|
-
return offset + byteLength2;
|
|
1519
|
-
};
|
|
1520
|
-
Buffer2.prototype.writeUInt8 = function writeUInt8(value, offset, noAssert) {
|
|
1521
|
-
value = +value;
|
|
1522
|
-
offset = offset | 0;
|
|
1523
|
-
if (!noAssert) checkInt(this, value, offset, 1, 255, 0);
|
|
1524
|
-
if (!Buffer2.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
|
|
1525
|
-
this[offset] = value & 255;
|
|
1526
|
-
return offset + 1;
|
|
1527
|
-
};
|
|
1528
|
-
Buffer2.prototype.writeUInt16LE = function writeUInt16LE(value, offset, noAssert) {
|
|
1529
|
-
value = +value;
|
|
1530
|
-
offset = offset | 0;
|
|
1531
|
-
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1532
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1533
|
-
this[offset] = value & 255;
|
|
1534
|
-
this[offset + 1] = value >>> 8;
|
|
1535
|
-
} else {
|
|
1536
|
-
objectWriteUInt16(this, value, offset, true);
|
|
1537
|
-
}
|
|
1538
|
-
return offset + 2;
|
|
1539
|
-
};
|
|
1540
|
-
Buffer2.prototype.writeUInt16BE = function writeUInt16BE(value, offset, noAssert) {
|
|
1541
|
-
value = +value;
|
|
1542
|
-
offset = offset | 0;
|
|
1543
|
-
if (!noAssert) checkInt(this, value, offset, 2, 65535, 0);
|
|
1544
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1545
|
-
this[offset] = value >>> 8;
|
|
1546
|
-
this[offset + 1] = value & 255;
|
|
1547
|
-
} else {
|
|
1548
|
-
objectWriteUInt16(this, value, offset, false);
|
|
1549
|
-
}
|
|
1550
|
-
return offset + 2;
|
|
1551
|
-
};
|
|
1552
|
-
Buffer2.prototype.writeUInt32LE = function writeUInt32LE(value, offset, noAssert) {
|
|
1553
|
-
value = +value;
|
|
1554
|
-
offset = offset | 0;
|
|
1555
|
-
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1556
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1557
|
-
this[offset + 3] = value >>> 24;
|
|
1558
|
-
this[offset + 2] = value >>> 16;
|
|
1559
|
-
this[offset + 1] = value >>> 8;
|
|
1560
|
-
this[offset] = value & 255;
|
|
1561
|
-
} else {
|
|
1562
|
-
objectWriteUInt32(this, value, offset, true);
|
|
1563
|
-
}
|
|
1564
|
-
return offset + 4;
|
|
1565
|
-
};
|
|
1566
|
-
Buffer2.prototype.writeUInt32BE = function writeUInt32BE(value, offset, noAssert) {
|
|
1567
|
-
value = +value;
|
|
1568
|
-
offset = offset | 0;
|
|
1569
|
-
if (!noAssert) checkInt(this, value, offset, 4, 4294967295, 0);
|
|
1570
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1571
|
-
this[offset] = value >>> 24;
|
|
1572
|
-
this[offset + 1] = value >>> 16;
|
|
1573
|
-
this[offset + 2] = value >>> 8;
|
|
1574
|
-
this[offset + 3] = value & 255;
|
|
1575
|
-
} else {
|
|
1576
|
-
objectWriteUInt32(this, value, offset, false);
|
|
1577
|
-
}
|
|
1578
|
-
return offset + 4;
|
|
1579
|
-
};
|
|
1580
|
-
Buffer2.prototype.writeIntLE = function writeIntLE(value, offset, byteLength2, noAssert) {
|
|
1581
|
-
value = +value;
|
|
1582
|
-
offset = offset | 0;
|
|
1583
|
-
if (!noAssert) {
|
|
1584
|
-
var limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1585
|
-
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1586
|
-
}
|
|
1587
|
-
var i = 0;
|
|
1588
|
-
var mul = 1;
|
|
1589
|
-
var sub = 0;
|
|
1590
|
-
this[offset] = value & 255;
|
|
1591
|
-
while (++i < byteLength2 && (mul *= 256)) {
|
|
1592
|
-
if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
|
|
1593
|
-
sub = 1;
|
|
1594
|
-
}
|
|
1595
|
-
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1596
|
-
}
|
|
1597
|
-
return offset + byteLength2;
|
|
1598
|
-
};
|
|
1599
|
-
Buffer2.prototype.writeIntBE = function writeIntBE(value, offset, byteLength2, noAssert) {
|
|
1600
|
-
value = +value;
|
|
1601
|
-
offset = offset | 0;
|
|
1602
|
-
if (!noAssert) {
|
|
1603
|
-
var limit = Math.pow(2, 8 * byteLength2 - 1);
|
|
1604
|
-
checkInt(this, value, offset, byteLength2, limit - 1, -limit);
|
|
1605
|
-
}
|
|
1606
|
-
var i = byteLength2 - 1;
|
|
1607
|
-
var mul = 1;
|
|
1608
|
-
var sub = 0;
|
|
1609
|
-
this[offset + i] = value & 255;
|
|
1610
|
-
while (--i >= 0 && (mul *= 256)) {
|
|
1611
|
-
if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
|
|
1612
|
-
sub = 1;
|
|
1613
|
-
}
|
|
1614
|
-
this[offset + i] = (value / mul >> 0) - sub & 255;
|
|
1615
|
-
}
|
|
1616
|
-
return offset + byteLength2;
|
|
1617
|
-
};
|
|
1618
|
-
Buffer2.prototype.writeInt8 = function writeInt8(value, offset, noAssert) {
|
|
1619
|
-
value = +value;
|
|
1620
|
-
offset = offset | 0;
|
|
1621
|
-
if (!noAssert) checkInt(this, value, offset, 1, 127, -128);
|
|
1622
|
-
if (!Buffer2.TYPED_ARRAY_SUPPORT) value = Math.floor(value);
|
|
1623
|
-
if (value < 0) value = 255 + value + 1;
|
|
1624
|
-
this[offset] = value & 255;
|
|
1625
|
-
return offset + 1;
|
|
1626
|
-
};
|
|
1627
|
-
Buffer2.prototype.writeInt16LE = function writeInt16LE(value, offset, noAssert) {
|
|
1628
|
-
value = +value;
|
|
1629
|
-
offset = offset | 0;
|
|
1630
|
-
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1631
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1632
|
-
this[offset] = value & 255;
|
|
1633
|
-
this[offset + 1] = value >>> 8;
|
|
1634
|
-
} else {
|
|
1635
|
-
objectWriteUInt16(this, value, offset, true);
|
|
1636
|
-
}
|
|
1637
|
-
return offset + 2;
|
|
1638
|
-
};
|
|
1639
|
-
Buffer2.prototype.writeInt16BE = function writeInt16BE(value, offset, noAssert) {
|
|
1640
|
-
value = +value;
|
|
1641
|
-
offset = offset | 0;
|
|
1642
|
-
if (!noAssert) checkInt(this, value, offset, 2, 32767, -32768);
|
|
1643
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1644
|
-
this[offset] = value >>> 8;
|
|
1645
|
-
this[offset + 1] = value & 255;
|
|
1646
|
-
} else {
|
|
1647
|
-
objectWriteUInt16(this, value, offset, false);
|
|
1648
|
-
}
|
|
1649
|
-
return offset + 2;
|
|
1650
|
-
};
|
|
1651
|
-
Buffer2.prototype.writeInt32LE = function writeInt32LE(value, offset, noAssert) {
|
|
1652
|
-
value = +value;
|
|
1653
|
-
offset = offset | 0;
|
|
1654
|
-
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1655
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1656
|
-
this[offset] = value & 255;
|
|
1657
|
-
this[offset + 1] = value >>> 8;
|
|
1658
|
-
this[offset + 2] = value >>> 16;
|
|
1659
|
-
this[offset + 3] = value >>> 24;
|
|
1660
|
-
} else {
|
|
1661
|
-
objectWriteUInt32(this, value, offset, true);
|
|
1662
|
-
}
|
|
1663
|
-
return offset + 4;
|
|
1664
|
-
};
|
|
1665
|
-
Buffer2.prototype.writeInt32BE = function writeInt32BE(value, offset, noAssert) {
|
|
1666
|
-
value = +value;
|
|
1667
|
-
offset = offset | 0;
|
|
1668
|
-
if (!noAssert) checkInt(this, value, offset, 4, 2147483647, -2147483648);
|
|
1669
|
-
if (value < 0) value = 4294967295 + value + 1;
|
|
1670
|
-
if (Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1671
|
-
this[offset] = value >>> 24;
|
|
1672
|
-
this[offset + 1] = value >>> 16;
|
|
1673
|
-
this[offset + 2] = value >>> 8;
|
|
1674
|
-
this[offset + 3] = value & 255;
|
|
1675
|
-
} else {
|
|
1676
|
-
objectWriteUInt32(this, value, offset, false);
|
|
1677
|
-
}
|
|
1678
|
-
return offset + 4;
|
|
1679
|
-
};
|
|
1680
|
-
Buffer2.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
1681
|
-
return writeFloat(this, value, offset, true, noAssert);
|
|
1682
|
-
};
|
|
1683
|
-
Buffer2.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
1684
|
-
return writeFloat(this, value, offset, false, noAssert);
|
|
1685
|
-
};
|
|
1686
|
-
Buffer2.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
1687
|
-
return writeDouble(this, value, offset, true, noAssert);
|
|
1688
|
-
};
|
|
1689
|
-
Buffer2.prototype.writeDoubleBE = function writeDoubleBE(value, offset, noAssert) {
|
|
1690
|
-
return writeDouble(this, value, offset, false, noAssert);
|
|
1691
|
-
};
|
|
1692
|
-
Buffer2.prototype.copy = function copy(target, targetStart, start, end) {
|
|
1693
|
-
if (!start) start = 0;
|
|
1694
|
-
if (!end && end !== 0) end = this.length;
|
|
1695
|
-
if (targetStart >= target.length) targetStart = target.length;
|
|
1696
|
-
if (!targetStart) targetStart = 0;
|
|
1697
|
-
if (end > 0 && end < start) end = start;
|
|
1698
|
-
if (end === start) return 0;
|
|
1699
|
-
if (target.length === 0 || this.length === 0) return 0;
|
|
1700
|
-
if (targetStart < 0) {
|
|
1701
|
-
throw new RangeError("targetStart out of bounds");
|
|
1702
|
-
}
|
|
1703
|
-
if (start < 0 || start >= this.length)
|
|
1704
|
-
throw new RangeError("sourceStart out of bounds");
|
|
1705
|
-
if (end < 0) throw new RangeError("sourceEnd out of bounds");
|
|
1706
|
-
if (end > this.length) end = this.length;
|
|
1707
|
-
if (target.length - targetStart < end - start) {
|
|
1708
|
-
end = target.length - targetStart + start;
|
|
1709
|
-
}
|
|
1710
|
-
var len = end - start;
|
|
1711
|
-
var i;
|
|
1712
|
-
if (this === target && start < targetStart && targetStart < end) {
|
|
1713
|
-
for (i = len - 1; i >= 0; --i) {
|
|
1714
|
-
target[i + targetStart] = this[i + start];
|
|
1715
|
-
}
|
|
1716
|
-
} else if (len < 1e3 || !Buffer2.TYPED_ARRAY_SUPPORT) {
|
|
1717
|
-
for (i = 0; i < len; ++i) {
|
|
1718
|
-
target[i + targetStart] = this[i + start];
|
|
1719
|
-
}
|
|
1720
|
-
} else {
|
|
1721
|
-
Uint8Array.prototype.set.call(
|
|
1722
|
-
target,
|
|
1723
|
-
this.subarray(start, start + len),
|
|
1724
|
-
targetStart
|
|
1725
|
-
);
|
|
1726
|
-
}
|
|
1727
|
-
return len;
|
|
1728
|
-
};
|
|
1729
|
-
Buffer2.prototype.fill = function fill(val, start, end, encoding) {
|
|
1730
|
-
if (typeof val === "string") {
|
|
1731
|
-
if (typeof start === "string") {
|
|
1732
|
-
encoding = start;
|
|
1733
|
-
start = 0;
|
|
1734
|
-
end = this.length;
|
|
1735
|
-
} else if (typeof end === "string") {
|
|
1736
|
-
encoding = end;
|
|
1737
|
-
end = this.length;
|
|
1738
|
-
}
|
|
1739
|
-
if (val.length === 1) {
|
|
1740
|
-
var code = val.charCodeAt(0);
|
|
1741
|
-
if (code < 256) {
|
|
1742
|
-
val = code;
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
if (encoding !== void 0 && typeof encoding !== "string") {
|
|
1746
|
-
throw new TypeError("encoding must be a string");
|
|
1747
|
-
}
|
|
1748
|
-
if (typeof encoding === "string" && !Buffer2.isEncoding(encoding)) {
|
|
1749
|
-
throw new TypeError("Unknown encoding: " + encoding);
|
|
1750
|
-
}
|
|
1751
|
-
} else if (typeof val === "number") {
|
|
1752
|
-
val = val & 255;
|
|
1753
|
-
}
|
|
1754
|
-
if (start < 0 || this.length < start || this.length < end) {
|
|
1755
|
-
throw new RangeError("Out of range index");
|
|
1756
|
-
}
|
|
1757
|
-
if (end <= start) {
|
|
1758
|
-
return this;
|
|
1759
|
-
}
|
|
1760
|
-
start = start >>> 0;
|
|
1761
|
-
end = end === void 0 ? this.length : end >>> 0;
|
|
1762
|
-
if (!val) val = 0;
|
|
1763
|
-
var i;
|
|
1764
|
-
if (typeof val === "number") {
|
|
1765
|
-
for (i = start; i < end; ++i) {
|
|
1766
|
-
this[i] = val;
|
|
1767
|
-
}
|
|
1768
|
-
} else {
|
|
1769
|
-
var bytes = internalIsBuffer(val) ? val : utf8ToBytes(new Buffer2(val, encoding).toString());
|
|
1770
|
-
var len = bytes.length;
|
|
1771
|
-
for (i = 0; i < end - start; ++i) {
|
|
1772
|
-
this[i + start] = bytes[i % len];
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
return this;
|
|
1776
|
-
};
|
|
1777
|
-
INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g;
|
|
1778
|
-
}
|
|
1779
|
-
});
|
|
1780
|
-
|
|
1781
|
-
// ../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/_buffer.js
|
|
1782
|
-
var init_buffer = __esm({
|
|
1783
|
-
"../../../node_modules/.pnpm/@esbuild-plugins+node-globals-polyfill@0.2.3_esbuild@0.24.0/node_modules/@esbuild-plugins/node-globals-polyfill/_buffer.js"() {
|
|
1784
|
-
"use strict";
|
|
1785
|
-
init_Buffer();
|
|
1786
|
-
}
|
|
1787
|
-
});
|
|
1788
|
-
|
|
1789
|
-
// src/EndpointSnippetGenerator.ts
|
|
1790
|
-
var EndpointSnippetGenerator_exports = {};
|
|
1791
|
-
__export(EndpointSnippetGenerator_exports, {
|
|
1792
|
-
EndpointSnippetGenerator: () => EndpointSnippetGenerator
|
|
1793
|
-
});
|
|
1794
|
-
module.exports = __toCommonJS(EndpointSnippetGenerator_exports);
|
|
1795
|
-
init_process();
|
|
1796
|
-
init_buffer();
|
|
1797
|
-
|
|
1798
|
-
// ../../../packages/commons/core-utils/lib/index.js
|
|
1799
|
-
init_process();
|
|
1800
|
-
init_buffer();
|
|
1801
|
-
|
|
1802
|
-
// ../../../packages/commons/core-utils/lib/assertNever.js
|
|
1803
|
-
init_process();
|
|
1804
|
-
init_buffer();
|
|
1805
|
-
function assertNever(x) {
|
|
1806
|
-
throw new Error("Unexpected value: " + JSON.stringify(x));
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
// ../../browser-compatible-base/lib/ast/index.js
|
|
1810
|
-
init_process();
|
|
1811
|
-
init_buffer();
|
|
1812
|
-
|
|
1813
|
-
// ../../browser-compatible-base/lib/ast/AbstractAstNode.js
|
|
1814
|
-
init_process();
|
|
1815
|
-
init_buffer();
|
|
1816
|
-
var AbstractAstNode = class {
|
|
1817
|
-
};
|
|
1818
|
-
|
|
1819
|
-
// ../../browser-compatible-base/lib/ast/AbstractWriter.js
|
|
1820
|
-
init_process();
|
|
1821
|
-
init_buffer();
|
|
1822
|
-
|
|
1823
|
-
// ../../browser-compatible-base/lib/ast/CodeBlock.js
|
|
1824
|
-
init_process();
|
|
1825
|
-
init_buffer();
|
|
1826
|
-
var CodeBlock = class extends AbstractAstNode {
|
|
1827
|
-
constructor(value) {
|
|
1828
|
-
super();
|
|
1829
|
-
__publicField(this, "value");
|
|
1830
|
-
this.value = value;
|
|
1831
|
-
}
|
|
1832
|
-
write(writer) {
|
|
1833
|
-
if (typeof this.value === "string") {
|
|
1834
|
-
writer.write(this.value);
|
|
1835
|
-
} else {
|
|
1836
|
-
this.value(writer);
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
};
|
|
1840
|
-
|
|
1841
|
-
// ../../browser-compatible-base/lib/ast/AbstractWriter.js
|
|
1842
|
-
var TAB_SIZE = 4;
|
|
1843
|
-
var AbstractWriter = class {
|
|
1844
|
-
constructor() {
|
|
1845
|
-
/* The contents being written */
|
|
1846
|
-
__publicField(this, "buffer", "");
|
|
1847
|
-
/* Indentation level (multiple of 4) */
|
|
1848
|
-
__publicField(this, "indentLevel", 0);
|
|
1849
|
-
/* Whether anything has been written to the buffer */
|
|
1850
|
-
__publicField(this, "hasWrittenAnything", false);
|
|
1851
|
-
/* Whether the last character written was a newline */
|
|
1852
|
-
__publicField(this, "lastCharacterIsNewline", false);
|
|
1853
|
-
}
|
|
1854
|
-
/**
|
|
1855
|
-
* Writes arbitrary text
|
|
1856
|
-
* @param text
|
|
1857
|
-
*/
|
|
1858
|
-
write(text) {
|
|
1859
|
-
const textEndsInNewline = text.length > 0 && text.endsWith("\n");
|
|
1860
|
-
const textWithoutNewline = textEndsInNewline ? text.substring(0, text.length - 1) : text;
|
|
1861
|
-
const indent = this.getIndentString();
|
|
1862
|
-
let indentedText = textWithoutNewline.replaceAll("\n", `
|
|
1863
|
-
${indent}`);
|
|
1864
|
-
if (this.isAtStartOfLine()) {
|
|
1865
|
-
indentedText = indent + indentedText;
|
|
1866
|
-
}
|
|
1867
|
-
if (textEndsInNewline) {
|
|
1868
|
-
indentedText += "\n";
|
|
1869
|
-
}
|
|
1870
|
-
this.writeInternal(indentedText);
|
|
1871
|
-
}
|
|
1872
|
-
/**
|
|
1873
|
-
* Writes arbitrary text without indentation
|
|
1874
|
-
* @param text
|
|
1875
|
-
*/
|
|
1876
|
-
writeNoIndent(text) {
|
|
1877
|
-
const currIndentLevel = this.indentLevel;
|
|
1878
|
-
this.indentLevel = 0;
|
|
1879
|
-
this.write(text);
|
|
1880
|
-
this.indentLevel = currIndentLevel;
|
|
1881
|
-
}
|
|
1882
|
-
/**
|
|
1883
|
-
* Writes a node
|
|
1884
|
-
* @param node
|
|
1885
|
-
*/
|
|
1886
|
-
writeNode(node) {
|
|
1887
|
-
node.write(this);
|
|
1888
|
-
}
|
|
1889
|
-
/**
|
|
1890
|
-
* Writes a node but then suffixes with a `;` and new line
|
|
1891
|
-
* @param node
|
|
1892
|
-
*/
|
|
1893
|
-
writeNodeStatement(node) {
|
|
1894
|
-
node.write(this);
|
|
1895
|
-
this.write(";");
|
|
1896
|
-
this.writeNewLineIfLastLineNot();
|
|
1897
|
-
}
|
|
1898
|
-
/**
|
|
1899
|
-
* Writes text but then suffixes with a `;`
|
|
1900
|
-
* @param node
|
|
1901
|
-
*/
|
|
1902
|
-
writeTextStatement(text) {
|
|
1903
|
-
const codeBlock = new CodeBlock(text);
|
|
1904
|
-
codeBlock.write(this);
|
|
1905
|
-
this.write(";");
|
|
1906
|
-
this.writeNewLineIfLastLineNot();
|
|
1907
|
-
}
|
|
1908
|
-
/**
|
|
1909
|
-
* Writes text but then suffixes with a `;`
|
|
1910
|
-
* @param node
|
|
1911
|
-
*/
|
|
1912
|
-
controlFlow(prefix, statement) {
|
|
1913
|
-
const codeBlock = new CodeBlock(prefix);
|
|
1914
|
-
codeBlock.write(this);
|
|
1915
|
-
this.write(" (");
|
|
1916
|
-
this.writeNode(statement);
|
|
1917
|
-
this.write(") {");
|
|
1918
|
-
this.writeNewLineIfLastLineNot();
|
|
1919
|
-
this.indent();
|
|
1920
|
-
}
|
|
1921
|
-
/**
|
|
1922
|
-
* Writes text but then suffixes with a `;`
|
|
1923
|
-
* @param node
|
|
1924
|
-
*/
|
|
1925
|
-
endControlFlow() {
|
|
1926
|
-
this.dedent();
|
|
1927
|
-
this.writeLine("}");
|
|
1928
|
-
}
|
|
1929
|
-
/**
|
|
1930
|
-
* Please try to not use this. It is here for swift.
|
|
1931
|
-
* @param titles
|
|
1932
|
-
* @param openingCharacter
|
|
1933
|
-
* @param callback
|
|
1934
|
-
* @param closingCharacter
|
|
1935
|
-
*/
|
|
1936
|
-
openBlock(titles, openingCharacter = "{", callback, closingCharacter = "}") {
|
|
1937
|
-
const filteredTitles = titles.filter((title2) => title2 !== void 0).join(" ");
|
|
1938
|
-
if (filteredTitles) {
|
|
1939
|
-
this.write(`${filteredTitles} ${openingCharacter != null ? openingCharacter : ""}`);
|
|
1940
|
-
} else {
|
|
1941
|
-
this.write(openingCharacter != null ? openingCharacter : "");
|
|
1942
|
-
}
|
|
1943
|
-
try {
|
|
1944
|
-
this.indent();
|
|
1945
|
-
callback();
|
|
1946
|
-
this.dedent();
|
|
1947
|
-
} finally {
|
|
1948
|
-
this.write(closingCharacter != null ? closingCharacter : "");
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
/* Only writes a newline if last line in the buffer is not a newline */
|
|
1952
|
-
writeLine(text = "") {
|
|
1953
|
-
this.write(text);
|
|
1954
|
-
this.writeNewLineIfLastLineNot();
|
|
1955
|
-
}
|
|
1956
|
-
/* Always writes newline */
|
|
1957
|
-
newLine() {
|
|
1958
|
-
this.writeInternal("\n");
|
|
1959
|
-
}
|
|
1960
|
-
writeNewLineIfLastLineNot() {
|
|
1961
|
-
if (!this.lastCharacterIsNewline) {
|
|
1962
|
-
this.writeInternal("\n");
|
|
1963
|
-
}
|
|
1964
|
-
}
|
|
1965
|
-
indent() {
|
|
1966
|
-
this.indentLevel++;
|
|
1967
|
-
}
|
|
1968
|
-
dedent() {
|
|
1969
|
-
this.indentLevel--;
|
|
1970
|
-
}
|
|
1971
|
-
delimit({ nodes, delimiter, writeFunction }) {
|
|
1972
|
-
if (nodes.length > 0) {
|
|
1973
|
-
const firstNode = nodes[0];
|
|
1974
|
-
if (firstNode != null) {
|
|
1975
|
-
writeFunction(firstNode);
|
|
1976
|
-
}
|
|
1977
|
-
for (let i = 1; i < nodes.length; i++) {
|
|
1978
|
-
this.write(delimiter);
|
|
1979
|
-
const node = nodes[i];
|
|
1980
|
-
if (node != null) {
|
|
1981
|
-
writeFunction(node);
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
}
|
|
1985
|
-
}
|
|
1986
|
-
/*******************************
|
|
1987
|
-
* Helper Methods
|
|
1988
|
-
*******************************/
|
|
1989
|
-
writeInternal(text) {
|
|
1990
|
-
if (text.length > 0) {
|
|
1991
|
-
this.hasWrittenAnything = true;
|
|
1992
|
-
this.lastCharacterIsNewline = text.endsWith("\n");
|
|
1993
|
-
}
|
|
1994
|
-
return this.buffer += text;
|
|
1995
|
-
}
|
|
1996
|
-
isAtStartOfLine() {
|
|
1997
|
-
return this.lastCharacterIsNewline || !this.hasWrittenAnything;
|
|
1998
|
-
}
|
|
1999
|
-
getIndentString() {
|
|
2000
|
-
return " ".repeat(this.indentLevel * TAB_SIZE);
|
|
2001
|
-
}
|
|
2002
|
-
};
|
|
2003
|
-
|
|
2004
|
-
// ../../browser-compatible-base/lib/dynamic-snippets/index.js
|
|
2005
|
-
init_process();
|
|
2006
|
-
init_buffer();
|
|
2007
|
-
|
|
2008
|
-
// ../../browser-compatible-base/lib/dynamic-snippets/ErrorReporter.js
|
|
2009
|
-
init_process();
|
|
2010
|
-
init_buffer();
|
|
2011
|
-
var Severity = {
|
|
2012
|
-
Critical: "CRITICAL",
|
|
2013
|
-
Warning: "WARNING"
|
|
2014
|
-
};
|
|
2015
|
-
|
|
2016
|
-
// ../../browser-compatible-base/lib/dynamic-snippets/Scope.js
|
|
2017
|
-
init_process();
|
|
2018
|
-
init_buffer();
|
|
2019
|
-
var Scope = {
|
|
2020
|
-
PathParameters: "pathParameters",
|
|
2021
|
-
QueryParameters: "queryParameters",
|
|
2022
|
-
Headers: "headers",
|
|
2023
|
-
RequestBody: "requestBody"
|
|
2024
|
-
};
|
|
2025
|
-
|
|
2026
|
-
// ../ast/lib/index.js
|
|
2027
|
-
init_process();
|
|
2028
|
-
init_buffer();
|
|
2029
|
-
|
|
2030
|
-
// ../ast/lib/typescript.js
|
|
2031
|
-
var typescript_exports = {};
|
|
2032
|
-
__export(typescript_exports, {
|
|
2033
|
-
AstNode: () => AstNode,
|
|
2034
|
-
ClassInstantiation: () => ClassInstantiation,
|
|
2035
|
-
CodeBlock: () => CodeBlock2,
|
|
2036
|
-
Comment: () => Comment,
|
|
2037
|
-
Function: () => Function,
|
|
2038
|
-
FunctionInvocation: () => FunctionInvocation,
|
|
2039
|
-
MethodInvocation: () => MethodInvocation,
|
|
2040
|
-
Parameter: () => Parameter,
|
|
2041
|
-
Reference: () => Reference,
|
|
2042
|
-
Type: () => Type,
|
|
2043
|
-
TypeLiteral: () => TypeLiteral,
|
|
2044
|
-
Types: () => Type,
|
|
2045
|
-
Variable: () => Variable,
|
|
2046
|
-
Writer: () => Writer,
|
|
2047
|
-
codeblock: () => codeblock,
|
|
2048
|
-
function_: () => function_,
|
|
2049
|
-
instantiateClass: () => instantiateClass,
|
|
2050
|
-
invokeFunction: () => invokeFunction,
|
|
2051
|
-
invokeMethod: () => invokeMethod,
|
|
2052
|
-
parameter: () => parameter,
|
|
2053
|
-
reference: () => reference,
|
|
2054
|
-
variable: () => variable
|
|
2055
|
-
});
|
|
2056
|
-
init_process();
|
|
2057
|
-
init_buffer();
|
|
2058
|
-
|
|
2059
|
-
// ../ast/lib/ast/index.js
|
|
2060
|
-
init_process();
|
|
2061
|
-
init_buffer();
|
|
2062
|
-
|
|
2063
|
-
// ../ast/lib/ast/core/index.js
|
|
2064
|
-
init_process();
|
|
2065
|
-
init_buffer();
|
|
2066
|
-
|
|
2067
|
-
// ../ast/lib/ast/core/AstNode.js
|
|
2068
|
-
init_process();
|
|
2069
|
-
init_buffer();
|
|
2070
|
-
|
|
2071
|
-
// ../ast/lib/ast/core/Writer.js
|
|
2072
|
-
init_process();
|
|
2073
|
-
init_buffer();
|
|
2074
|
-
var Writer = class extends AbstractWriter {
|
|
2075
|
-
constructor({ customConfig }) {
|
|
2076
|
-
super();
|
|
2077
|
-
__publicField(this, "customConfig");
|
|
2078
|
-
__publicField(this, "imports", {});
|
|
2079
|
-
__publicField(this, "defaultImports", {});
|
|
2080
|
-
__publicField(this, "starImportAliases", {});
|
|
2081
|
-
__publicField(this, "starImportAliasesInverse", {});
|
|
2082
|
-
this.customConfig = customConfig;
|
|
2083
|
-
}
|
|
2084
|
-
/**
|
|
2085
|
-
* Adds the given import under its module name.
|
|
2086
|
-
*/
|
|
2087
|
-
addImport(reference2) {
|
|
2088
|
-
var _a, _b, _c;
|
|
2089
|
-
if (reference2.importFrom != null) {
|
|
2090
|
-
switch (reference2.importFrom.type) {
|
|
2091
|
-
case "default": {
|
|
2092
|
-
this.validateDefault(reference2);
|
|
2093
|
-
break;
|
|
2094
|
-
}
|
|
2095
|
-
case "named": {
|
|
2096
|
-
this.validateNamed(reference2);
|
|
2097
|
-
break;
|
|
2098
|
-
}
|
|
2099
|
-
case "star": {
|
|
2100
|
-
this.validateStar(reference2);
|
|
2101
|
-
break;
|
|
2102
|
-
}
|
|
2103
|
-
}
|
|
2104
|
-
const moduleImports = (_c = (_a = this.imports)[_b = reference2.importFrom.moduleName]) != null ? _c : _a[_b] = [];
|
|
2105
|
-
const names = moduleImports.map((import_) => import_.name);
|
|
2106
|
-
if (!names.includes(reference2.name)) {
|
|
2107
|
-
moduleImports.push(reference2);
|
|
2108
|
-
}
|
|
2109
|
-
}
|
|
2110
|
-
}
|
|
2111
|
-
validateDefault(reference2) {
|
|
2112
|
-
var _a, _b, _c, _d;
|
|
2113
|
-
if (((_a = reference2.importFrom) == null ? void 0 : _a.type) !== "default") {
|
|
2114
|
-
return;
|
|
2115
|
-
}
|
|
2116
|
-
const moduleDefault = (_d = (_b = this.defaultImports)[_c = reference2.importFrom.moduleName]) != null ? _d : _b[_c] = reference2;
|
|
2117
|
-
if (moduleDefault.name !== reference2.name) {
|
|
2118
|
-
throw new Error(`Cannot have multiple default imports for module ${reference2.importFrom.moduleName}: got ${reference2.name} but already had ${moduleDefault.name}`);
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
validateNamed(reference2) {
|
|
2122
|
-
var _a, _b, _c, _d, _e;
|
|
2123
|
-
if (((_a = reference2.importFrom) == null ? void 0 : _a.type) !== "named") {
|
|
2124
|
-
return;
|
|
2125
|
-
}
|
|
2126
|
-
const existing = (_b = this.imports[reference2.importFrom.moduleName]) != null ? _b : [];
|
|
2127
|
-
const existingStar = existing.filter((e) => {
|
|
2128
|
-
var _a2;
|
|
2129
|
-
return ((_a2 = e.importFrom) == null ? void 0 : _a2.type) === "star";
|
|
2130
|
-
});
|
|
2131
|
-
if (existingStar.length > 0) {
|
|
2132
|
-
throw new Error(`Cannot add named import ${reference2.name} because non-named imports ${existingStar.map((e) => e.name)} already exist`);
|
|
2133
|
-
}
|
|
2134
|
-
const duplicates = [];
|
|
2135
|
-
for (const references of Object.values(this.imports)) {
|
|
2136
|
-
for (const ref of references) {
|
|
2137
|
-
if (((_c = ref.importFrom) == null ? void 0 : _c.type) === "named" && ref.importFrom.moduleName !== reference2.importFrom.moduleName && ref.name === reference2.name) {
|
|
2138
|
-
duplicates.push(ref);
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
if (duplicates.length > 0) {
|
|
2143
|
-
throw new Error(`Cannot add named import from module ${reference2.importFrom.moduleName} because it is already imported from ${(_e = (_d = duplicates[0]) == null ? void 0 : _d.importFrom) == null ? void 0 : _e.moduleName}`);
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
validateStar(reference2) {
|
|
2147
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2148
|
-
if (((_a = reference2.importFrom) == null ? void 0 : _a.type) !== "star") {
|
|
2149
|
-
return;
|
|
2150
|
-
}
|
|
2151
|
-
const moduleAlias = (_d = (_b = this.starImportAliases)[_c = reference2.importFrom.moduleName]) != null ? _d : _b[_c] = reference2.importFrom.starImportAlias;
|
|
2152
|
-
if (moduleAlias !== reference2.importFrom.starImportAlias) {
|
|
2153
|
-
throw new Error(`Cannot have more than one alias for non-named imports from a module: got ${reference2.importFrom.starImportAlias} but already have ${moduleAlias}.`);
|
|
2154
|
-
}
|
|
2155
|
-
const aliasModule = (_g = (_e = this.starImportAliasesInverse)[_f = reference2.importFrom.starImportAlias]) != null ? _g : _e[_f] = reference2.importFrom.moduleName;
|
|
2156
|
-
if (aliasModule !== reference2.importFrom.moduleName) {
|
|
2157
|
-
throw new Error(`Attempted to use alias ${reference2.importFrom.starImportAlias} for more than one module in the same file`);
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
toString() {
|
|
2161
|
-
const imports = this.stringifyImports();
|
|
2162
|
-
if (imports.length > 0) {
|
|
2163
|
-
return imports + "\n" + this.buffer;
|
|
2164
|
-
}
|
|
2165
|
-
return this.buffer;
|
|
2166
|
-
}
|
|
2167
|
-
stringifyImports() {
|
|
2168
|
-
let result = "";
|
|
2169
|
-
for (const [module2, references] of Object.entries(this.imports)) {
|
|
2170
|
-
const defaultImport = this.defaultImports[module2];
|
|
2171
|
-
let stringifiedNonDefault = "";
|
|
2172
|
-
const named = references.filter((r) => {
|
|
2173
|
-
var _a;
|
|
2174
|
-
return ((_a = r.importFrom) == null ? void 0 : _a.type) === "named";
|
|
2175
|
-
});
|
|
2176
|
-
const starImportAlias = this.starImportAliases[module2];
|
|
2177
|
-
if (named.length > 0 || defaultImport != null || starImportAlias != null) {
|
|
2178
|
-
result += "import";
|
|
2179
|
-
if (defaultImport != null) {
|
|
2180
|
-
result += ` ${defaultImport.name}`;
|
|
2181
|
-
}
|
|
2182
|
-
if (named.length > 0) {
|
|
2183
|
-
for (const ref of named.slice(0, -1)) {
|
|
2184
|
-
stringifiedNonDefault += `${ref.name}, `;
|
|
2185
|
-
}
|
|
2186
|
-
const lastRef = named[named.length - 1];
|
|
2187
|
-
if (lastRef != null) {
|
|
2188
|
-
stringifiedNonDefault += `${lastRef.name}`;
|
|
2189
|
-
}
|
|
2190
|
-
if (defaultImport != null) {
|
|
2191
|
-
result += ",";
|
|
2192
|
-
}
|
|
2193
|
-
result += ` { ${stringifiedNonDefault} }`;
|
|
2194
|
-
}
|
|
2195
|
-
if (starImportAlias != null) {
|
|
2196
|
-
if (defaultImport != null || named.length > 0) {
|
|
2197
|
-
result += ", ";
|
|
2198
|
-
}
|
|
2199
|
-
result += ` * as ${starImportAlias}`;
|
|
2200
|
-
}
|
|
2201
|
-
result += ` from "${module2}";
|
|
2202
|
-
`;
|
|
2203
|
-
}
|
|
2204
|
-
}
|
|
2205
|
-
return result;
|
|
2206
|
-
}
|
|
2207
|
-
};
|
|
2208
|
-
|
|
2209
|
-
// ../ast/lib/ast/core/AstNode.js
|
|
2210
|
-
var AstNode = class extends AbstractAstNode {
|
|
2211
|
-
/**
|
|
2212
|
-
* Writes the node to a string.
|
|
2213
|
-
*/
|
|
2214
|
-
async toString({ customConfig }) {
|
|
2215
|
-
const writer = new Writer({ customConfig });
|
|
2216
|
-
this.write(writer);
|
|
2217
|
-
return writer.toString();
|
|
2218
|
-
}
|
|
2219
|
-
toStringSync({ customConfig }) {
|
|
2220
|
-
const writer = new Writer({ customConfig });
|
|
2221
|
-
this.write(writer);
|
|
2222
|
-
return writer.toString();
|
|
2223
|
-
}
|
|
2224
|
-
};
|
|
2225
|
-
|
|
2226
|
-
// ../ast/lib/ast/CodeBlock.js
|
|
2227
|
-
init_process();
|
|
2228
|
-
init_buffer();
|
|
2229
|
-
var CodeBlock2 = class extends AstNode {
|
|
2230
|
-
constructor(args) {
|
|
2231
|
-
super();
|
|
2232
|
-
__publicField(this, "args");
|
|
2233
|
-
this.args = args;
|
|
2234
|
-
}
|
|
2235
|
-
write(writer) {
|
|
2236
|
-
const commonCodeBlock = new CodeBlock(this.args);
|
|
2237
|
-
return commonCodeBlock.write(writer);
|
|
2238
|
-
}
|
|
2239
|
-
};
|
|
2240
|
-
|
|
2241
|
-
// ../ast/lib/ast/Type.js
|
|
2242
|
-
init_process();
|
|
2243
|
-
init_buffer();
|
|
2244
|
-
var Type = class extends AstNode {
|
|
2245
|
-
constructor(internalType) {
|
|
2246
|
-
super();
|
|
2247
|
-
__publicField(this, "internalType");
|
|
2248
|
-
this.internalType = internalType;
|
|
2249
|
-
}
|
|
2250
|
-
write(writer) {
|
|
2251
|
-
switch (this.internalType.type) {
|
|
2252
|
-
case "string":
|
|
2253
|
-
writer.write("string");
|
|
2254
|
-
break;
|
|
2255
|
-
case "number":
|
|
2256
|
-
writer.write("number");
|
|
2257
|
-
break;
|
|
2258
|
-
case "bigint":
|
|
2259
|
-
writer.write("bigint");
|
|
2260
|
-
break;
|
|
2261
|
-
case "boolean":
|
|
2262
|
-
writer.write("boolean");
|
|
2263
|
-
break;
|
|
2264
|
-
case "array":
|
|
2265
|
-
this.internalType.valueType.write(writer);
|
|
2266
|
-
writer.write("[]");
|
|
2267
|
-
break;
|
|
2268
|
-
case "map":
|
|
2269
|
-
writer.write("Record<");
|
|
2270
|
-
this.internalType.keyType.write(writer);
|
|
2271
|
-
writer.write(", ");
|
|
2272
|
-
this.internalType.valueType.write(writer);
|
|
2273
|
-
writer.write(">");
|
|
2274
|
-
break;
|
|
2275
|
-
case "object":
|
|
2276
|
-
writer.write("{");
|
|
2277
|
-
writer.indent();
|
|
2278
|
-
for (const [key, value] of Object.entries(this.internalType.fields)) {
|
|
2279
|
-
writer.write(`${key}: `);
|
|
2280
|
-
value.write(writer);
|
|
2281
|
-
writer.writeLine(",");
|
|
2282
|
-
}
|
|
2283
|
-
writer.dedent();
|
|
2284
|
-
writer.write("}");
|
|
2285
|
-
break;
|
|
2286
|
-
case "enum":
|
|
2287
|
-
writer.write("enum");
|
|
2288
|
-
break;
|
|
2289
|
-
case "any":
|
|
2290
|
-
writer.write("any");
|
|
2291
|
-
break;
|
|
2292
|
-
case "promise":
|
|
2293
|
-
writer.write("Promise<");
|
|
2294
|
-
this.internalType.value.write(writer);
|
|
2295
|
-
writer.write(">");
|
|
2296
|
-
break;
|
|
2297
|
-
case "unknown":
|
|
2298
|
-
writer.write("unknown");
|
|
2299
|
-
break;
|
|
2300
|
-
case "void":
|
|
2301
|
-
writer.write("void");
|
|
2302
|
-
break;
|
|
2303
|
-
case "undefined":
|
|
2304
|
-
writer.write("undefined");
|
|
2305
|
-
break;
|
|
2306
|
-
case "null":
|
|
2307
|
-
writer.write("null");
|
|
2308
|
-
break;
|
|
2309
|
-
case "never":
|
|
2310
|
-
writer.write("never");
|
|
2311
|
-
break;
|
|
2312
|
-
case "nop":
|
|
2313
|
-
break;
|
|
2314
|
-
default:
|
|
2315
|
-
assertNever(this.internalType);
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
/* Static factory methods for creating a Type */
|
|
2319
|
-
static string() {
|
|
2320
|
-
return new this({
|
|
2321
|
-
type: "string"
|
|
2322
|
-
});
|
|
2323
|
-
}
|
|
2324
|
-
static number() {
|
|
2325
|
-
return new this({
|
|
2326
|
-
type: "number"
|
|
2327
|
-
});
|
|
2328
|
-
}
|
|
2329
|
-
static bigint() {
|
|
2330
|
-
return new this({
|
|
2331
|
-
type: "bigint"
|
|
2332
|
-
});
|
|
2333
|
-
}
|
|
2334
|
-
static boolean() {
|
|
2335
|
-
return new this({
|
|
2336
|
-
type: "boolean"
|
|
2337
|
-
});
|
|
2338
|
-
}
|
|
2339
|
-
static array(valueType) {
|
|
2340
|
-
return new this({
|
|
2341
|
-
type: "array",
|
|
2342
|
-
valueType
|
|
2343
|
-
});
|
|
2344
|
-
}
|
|
2345
|
-
static object(fields) {
|
|
2346
|
-
return new this({
|
|
2347
|
-
type: "object",
|
|
2348
|
-
fields
|
|
2349
|
-
});
|
|
2350
|
-
}
|
|
2351
|
-
static enum(values) {
|
|
2352
|
-
return new this({
|
|
2353
|
-
type: "enum",
|
|
2354
|
-
values
|
|
2355
|
-
});
|
|
2356
|
-
}
|
|
2357
|
-
static any() {
|
|
2358
|
-
return new this({
|
|
2359
|
-
type: "any"
|
|
2360
|
-
});
|
|
2361
|
-
}
|
|
2362
|
-
static promise(value) {
|
|
2363
|
-
if (value.internalType.type === "promise") {
|
|
2364
|
-
return value;
|
|
2365
|
-
}
|
|
2366
|
-
return new this({
|
|
2367
|
-
type: "promise",
|
|
2368
|
-
value
|
|
2369
|
-
});
|
|
2370
|
-
}
|
|
2371
|
-
static unknown() {
|
|
2372
|
-
return new this({
|
|
2373
|
-
type: "unknown"
|
|
2374
|
-
});
|
|
2375
|
-
}
|
|
2376
|
-
static void() {
|
|
2377
|
-
return new this({
|
|
2378
|
-
type: "void"
|
|
2379
|
-
});
|
|
2380
|
-
}
|
|
2381
|
-
static undefined() {
|
|
2382
|
-
return new this({
|
|
2383
|
-
type: "undefined"
|
|
2384
|
-
});
|
|
2385
|
-
}
|
|
2386
|
-
static null() {
|
|
2387
|
-
return new this({
|
|
2388
|
-
type: "null"
|
|
2389
|
-
});
|
|
2390
|
-
}
|
|
2391
|
-
static never() {
|
|
2392
|
-
return new this({
|
|
2393
|
-
type: "never"
|
|
2394
|
-
});
|
|
2395
|
-
}
|
|
2396
|
-
static nop() {
|
|
2397
|
-
return new this({
|
|
2398
|
-
type: "nop"
|
|
2399
|
-
});
|
|
2400
|
-
}
|
|
2401
|
-
};
|
|
2402
|
-
|
|
2403
|
-
// ../ast/lib/ast/TypeLiteral.js
|
|
2404
|
-
init_process();
|
|
2405
|
-
init_buffer();
|
|
2406
|
-
var TypeLiteral = class _TypeLiteral extends AstNode {
|
|
2407
|
-
constructor(internalType) {
|
|
2408
|
-
super();
|
|
2409
|
-
__publicField(this, "internalType");
|
|
2410
|
-
this.internalType = internalType;
|
|
2411
|
-
}
|
|
2412
|
-
write(writer) {
|
|
2413
|
-
var _a, _b, _c, _d;
|
|
2414
|
-
switch (this.internalType.type) {
|
|
2415
|
-
case "array": {
|
|
2416
|
-
this.writeIterable({ writer, iterable: this.internalType });
|
|
2417
|
-
break;
|
|
2418
|
-
}
|
|
2419
|
-
case "blob": {
|
|
2420
|
-
if ((_a = writer.customConfig) == null ? void 0 : _a.noSerdeLayer) {
|
|
2421
|
-
writer.writeNode(_TypeLiteral.string(this.internalType.value));
|
|
2422
|
-
return;
|
|
2423
|
-
}
|
|
2424
|
-
writer.write("new Blob([");
|
|
2425
|
-
writer.writeNode(_TypeLiteral.string(this.internalType.value));
|
|
2426
|
-
writer.write("])");
|
|
2427
|
-
break;
|
|
2428
|
-
}
|
|
2429
|
-
case "boolean": {
|
|
2430
|
-
writer.write(this.internalType.value.toString());
|
|
2431
|
-
break;
|
|
2432
|
-
}
|
|
2433
|
-
case "bigint": {
|
|
2434
|
-
if ((_b = writer.customConfig) == null ? void 0 : _b.noSerdeLayer) {
|
|
2435
|
-
writer.writeNode(_TypeLiteral.string(this.internalType.value.toString()));
|
|
2436
|
-
return;
|
|
2437
|
-
}
|
|
2438
|
-
writer.write(`BigInt(${this.internalType.value.toString()})`);
|
|
2439
|
-
break;
|
|
2440
|
-
}
|
|
2441
|
-
case "datetime": {
|
|
2442
|
-
if ((_c = writer.customConfig) == null ? void 0 : _c.noSerdeLayer) {
|
|
2443
|
-
writer.writeNode(_TypeLiteral.string(this.internalType.value));
|
|
2444
|
-
return;
|
|
2445
|
-
}
|
|
2446
|
-
writer.write("new Date(");
|
|
2447
|
-
writer.writeNode(_TypeLiteral.string(this.internalType.value));
|
|
2448
|
-
writer.write(")");
|
|
2449
|
-
break;
|
|
2450
|
-
}
|
|
2451
|
-
case "number": {
|
|
2452
|
-
writer.write(this.internalType.value.toString());
|
|
2453
|
-
break;
|
|
2454
|
-
}
|
|
2455
|
-
case "object": {
|
|
2456
|
-
this.writeObject({ writer, object: this.internalType });
|
|
2457
|
-
break;
|
|
2458
|
-
}
|
|
2459
|
-
case "record": {
|
|
2460
|
-
this.writeRecord({ writer, record: this.internalType });
|
|
2461
|
-
break;
|
|
2462
|
-
}
|
|
2463
|
-
case "reference": {
|
|
2464
|
-
writer.writeNode(this.internalType.value);
|
|
2465
|
-
break;
|
|
2466
|
-
}
|
|
2467
|
-
case "set": {
|
|
2468
|
-
if (((_d = writer.customConfig) == null ? void 0 : _d.noSerdeLayer) || this.isSetOfObjects()) {
|
|
2469
|
-
writer.writeNode(_TypeLiteral.array({ values: this.internalType.values }));
|
|
2470
|
-
return;
|
|
2471
|
-
}
|
|
2472
|
-
writer.write("new Set(");
|
|
2473
|
-
this.writeIterable({ writer, iterable: this.internalType });
|
|
2474
|
-
writer.write(")");
|
|
2475
|
-
break;
|
|
2476
|
-
}
|
|
2477
|
-
case "string": {
|
|
2478
|
-
if (this.internalType.value.includes("\n")) {
|
|
2479
|
-
this.writeStringWithBackticks({ writer, value: this.internalType.value });
|
|
2480
|
-
} else {
|
|
2481
|
-
writer.write(`"${this.internalType.value.replaceAll('"', '\\"')}"`);
|
|
2482
|
-
}
|
|
2483
|
-
break;
|
|
2484
|
-
}
|
|
2485
|
-
case "tuple": {
|
|
2486
|
-
this.writeIterable({ writer, iterable: this.internalType });
|
|
2487
|
-
break;
|
|
2488
|
-
}
|
|
2489
|
-
case "unknown": {
|
|
2490
|
-
this.writeUnknown({ writer, value: this.internalType.value });
|
|
2491
|
-
break;
|
|
2492
|
-
}
|
|
2493
|
-
case "nop":
|
|
2494
|
-
break;
|
|
2495
|
-
default:
|
|
2496
|
-
assertNever(this.internalType);
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
isObject() {
|
|
2500
|
-
return this.internalType.type === "object";
|
|
2501
|
-
}
|
|
2502
|
-
asObjectOrThrow() {
|
|
2503
|
-
if (this.isObject()) {
|
|
2504
|
-
return this.internalType;
|
|
2505
|
-
}
|
|
2506
|
-
throw new Error("Internal error; ts.TypeLiteral is not an object");
|
|
2507
|
-
}
|
|
2508
|
-
isSet() {
|
|
2509
|
-
return this.internalType.type === "set";
|
|
2510
|
-
}
|
|
2511
|
-
asSetOrThrow() {
|
|
2512
|
-
if (this.isSet()) {
|
|
2513
|
-
return this.internalType;
|
|
2514
|
-
}
|
|
2515
|
-
throw new Error("Internal error; ts.TypeLiteral is not a set");
|
|
2516
|
-
}
|
|
2517
|
-
isSetOfObjects() {
|
|
2518
|
-
return this.isSet() && this.asSetOrThrow().values.every((value) => value.isObject());
|
|
2519
|
-
}
|
|
2520
|
-
writeStringWithBackticks({ writer, value }) {
|
|
2521
|
-
writer.write("`");
|
|
2522
|
-
const parts = value.split("\n");
|
|
2523
|
-
const head = parts[0] + "\n";
|
|
2524
|
-
const tail = parts.slice(1).join("\n");
|
|
2525
|
-
writer.write(head.replaceAll("`", "\\`"));
|
|
2526
|
-
writer.writeNoIndent(tail.replaceAll("`", "\\`"));
|
|
2527
|
-
writer.write("`");
|
|
2528
|
-
}
|
|
2529
|
-
writeIterable({ writer, iterable }) {
|
|
2530
|
-
const values = filterNopValues({ values: iterable.values });
|
|
2531
|
-
if (values.length === 0) {
|
|
2532
|
-
writer.write("[]");
|
|
2533
|
-
return;
|
|
2534
|
-
}
|
|
2535
|
-
writer.writeLine("[");
|
|
2536
|
-
writer.indent();
|
|
2537
|
-
for (const value of values) {
|
|
2538
|
-
value.write(writer);
|
|
2539
|
-
writer.writeLine(",");
|
|
2540
|
-
}
|
|
2541
|
-
writer.dedent();
|
|
2542
|
-
writer.write("]");
|
|
2543
|
-
}
|
|
2544
|
-
writeRecord({ writer, record }) {
|
|
2545
|
-
const entries = filterNopRecordEntries({ entries: record.entries });
|
|
2546
|
-
if (entries.length === 0) {
|
|
2547
|
-
writer.write("{}");
|
|
2548
|
-
return;
|
|
2549
|
-
}
|
|
2550
|
-
writer.writeLine("{");
|
|
2551
|
-
writer.indent();
|
|
2552
|
-
for (const entry of entries) {
|
|
2553
|
-
entry.key.write(writer);
|
|
2554
|
-
writer.write(": ");
|
|
2555
|
-
entry.value.write(writer);
|
|
2556
|
-
writer.writeLine(",");
|
|
2557
|
-
}
|
|
2558
|
-
writer.dedent();
|
|
2559
|
-
writer.write("}");
|
|
2560
|
-
}
|
|
2561
|
-
writeObject({ writer, object }) {
|
|
2562
|
-
const fields = filterNopObjectFields({ fields: object.fields });
|
|
2563
|
-
if (fields.length === 0) {
|
|
2564
|
-
writer.write("{}");
|
|
2565
|
-
return;
|
|
2566
|
-
}
|
|
2567
|
-
writer.writeLine("{");
|
|
2568
|
-
writer.indent();
|
|
2569
|
-
for (const field of fields) {
|
|
2570
|
-
writer.write(`${field.name}: `);
|
|
2571
|
-
field.value.write(writer);
|
|
2572
|
-
writer.writeLine(",");
|
|
2573
|
-
}
|
|
2574
|
-
writer.dedent();
|
|
2575
|
-
writer.write("}");
|
|
2576
|
-
}
|
|
2577
|
-
/* Static factory methods for creating a TypeLiteral */
|
|
2578
|
-
static array({ values }) {
|
|
2579
|
-
return new this({
|
|
2580
|
-
type: "array",
|
|
2581
|
-
values
|
|
2582
|
-
});
|
|
2583
|
-
}
|
|
2584
|
-
static bigint(value) {
|
|
2585
|
-
return new this({ type: "bigint", value });
|
|
2586
|
-
}
|
|
2587
|
-
static blob(value) {
|
|
2588
|
-
return new this({ type: "blob", value });
|
|
2589
|
-
}
|
|
2590
|
-
static boolean(value) {
|
|
2591
|
-
return new this({ type: "boolean", value });
|
|
2592
|
-
}
|
|
2593
|
-
static datetime(value) {
|
|
2594
|
-
return new this({ type: "datetime", value });
|
|
2595
|
-
}
|
|
2596
|
-
static number(value) {
|
|
2597
|
-
return new this({ type: "number", value });
|
|
2598
|
-
}
|
|
2599
|
-
static object({ fields }) {
|
|
2600
|
-
return new this({
|
|
2601
|
-
type: "object",
|
|
2602
|
-
fields
|
|
2603
|
-
});
|
|
2604
|
-
}
|
|
2605
|
-
static record({ entries }) {
|
|
2606
|
-
return new this({
|
|
2607
|
-
type: "record",
|
|
2608
|
-
entries
|
|
2609
|
-
});
|
|
2610
|
-
}
|
|
2611
|
-
static reference(value) {
|
|
2612
|
-
return new this({
|
|
2613
|
-
type: "reference",
|
|
2614
|
-
value
|
|
2615
|
-
});
|
|
2616
|
-
}
|
|
2617
|
-
static set({ values }) {
|
|
2618
|
-
return new this({
|
|
2619
|
-
type: "set",
|
|
2620
|
-
values
|
|
2621
|
-
});
|
|
2622
|
-
}
|
|
2623
|
-
static string(value) {
|
|
2624
|
-
return new this({
|
|
2625
|
-
type: "string",
|
|
2626
|
-
value
|
|
2627
|
-
});
|
|
2628
|
-
}
|
|
2629
|
-
static tuple({ values }) {
|
|
2630
|
-
return new this({
|
|
2631
|
-
type: "tuple",
|
|
2632
|
-
values
|
|
2633
|
-
});
|
|
2634
|
-
}
|
|
2635
|
-
static unknown(value) {
|
|
2636
|
-
return new this({ type: "unknown", value });
|
|
2637
|
-
}
|
|
2638
|
-
static nop() {
|
|
2639
|
-
return new this({ type: "nop" });
|
|
2640
|
-
}
|
|
2641
|
-
static isNop(typeLiteral) {
|
|
2642
|
-
return typeLiteral.internalType.type === "nop";
|
|
2643
|
-
}
|
|
2644
|
-
writeUnknown({ writer, value }) {
|
|
2645
|
-
switch (typeof value) {
|
|
2646
|
-
case "boolean":
|
|
2647
|
-
writer.write(value.toString());
|
|
2648
|
-
return;
|
|
2649
|
-
case "string":
|
|
2650
|
-
writer.write(value.includes('"') ? `\`${value}\`` : `"${value}"`);
|
|
2651
|
-
return;
|
|
2652
|
-
case "number":
|
|
2653
|
-
writer.write(value.toString());
|
|
2654
|
-
return;
|
|
2655
|
-
case "object":
|
|
2656
|
-
if (value == null) {
|
|
2657
|
-
writer.write("null");
|
|
2658
|
-
return;
|
|
2659
|
-
}
|
|
2660
|
-
if (Array.isArray(value)) {
|
|
2661
|
-
this.writeUnknownArray({ writer, value });
|
|
2662
|
-
return;
|
|
2663
|
-
}
|
|
2664
|
-
this.writeUnknownObject({ writer, value });
|
|
2665
|
-
return;
|
|
2666
|
-
default:
|
|
2667
|
-
throw new Error(`Internal error; unsupported unknown type: ${typeof value}`);
|
|
2668
|
-
}
|
|
2669
|
-
}
|
|
2670
|
-
writeUnknownArray({ writer, value }) {
|
|
2671
|
-
if (value.length === 0) {
|
|
2672
|
-
writer.write("[]");
|
|
2673
|
-
return;
|
|
2674
|
-
}
|
|
2675
|
-
writer.writeLine("[");
|
|
2676
|
-
writer.indent();
|
|
2677
|
-
for (const element of value) {
|
|
2678
|
-
writer.writeNode(_TypeLiteral.unknown(element));
|
|
2679
|
-
writer.writeLine(",");
|
|
2680
|
-
}
|
|
2681
|
-
writer.dedent();
|
|
2682
|
-
writer.write("]");
|
|
2683
|
-
}
|
|
2684
|
-
writeUnknownObject({ writer, value }) {
|
|
2685
|
-
const entries = Object.entries(value);
|
|
2686
|
-
if (entries.length === 0) {
|
|
2687
|
-
writer.write("{}");
|
|
2688
|
-
return;
|
|
2689
|
-
}
|
|
2690
|
-
writer.writeLine("{");
|
|
2691
|
-
writer.indent();
|
|
2692
|
-
for (const [key, val] of entries) {
|
|
2693
|
-
writer.write(`${key}: `);
|
|
2694
|
-
writer.writeNode(_TypeLiteral.unknown(val));
|
|
2695
|
-
writer.writeLine(",");
|
|
2696
|
-
}
|
|
2697
|
-
writer.dedent();
|
|
2698
|
-
writer.write("}");
|
|
2699
|
-
}
|
|
2700
|
-
};
|
|
2701
|
-
function filterNopObjectFields({ fields }) {
|
|
2702
|
-
return fields.filter((field) => !TypeLiteral.isNop(field.value));
|
|
2703
|
-
}
|
|
2704
|
-
function filterNopRecordEntries({ entries }) {
|
|
2705
|
-
return entries.filter((entry) => !TypeLiteral.isNop(entry.key) && !TypeLiteral.isNop(entry.value));
|
|
2706
|
-
}
|
|
2707
|
-
function filterNopValues({ values }) {
|
|
2708
|
-
return values.filter((value) => !TypeLiteral.isNop(value));
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
// ../ast/lib/ast/Reference.js
|
|
2712
|
-
init_process();
|
|
2713
|
-
init_buffer();
|
|
2714
|
-
var Reference = class extends AstNode {
|
|
2715
|
-
constructor({ name, importFrom, memberName }) {
|
|
2716
|
-
super();
|
|
2717
|
-
__publicField(this, "name");
|
|
2718
|
-
__publicField(this, "importFrom");
|
|
2719
|
-
__publicField(this, "memberName");
|
|
2720
|
-
this.name = name;
|
|
2721
|
-
this.importFrom = importFrom;
|
|
2722
|
-
this.memberName = memberName;
|
|
2723
|
-
}
|
|
2724
|
-
write(writer) {
|
|
2725
|
-
var _a;
|
|
2726
|
-
if (this.importFrom != null) {
|
|
2727
|
-
writer.addImport(this);
|
|
2728
|
-
}
|
|
2729
|
-
const prefix = ((_a = this.importFrom) == null ? void 0 : _a.type) === "star" ? `${this.importFrom.starImportAlias}.` : "";
|
|
2730
|
-
const suffix = this.memberName != null ? `.${this.memberName}` : "";
|
|
2731
|
-
writer.write(`${prefix}${this.name}${suffix}`);
|
|
2732
|
-
}
|
|
2733
|
-
};
|
|
2734
|
-
|
|
2735
|
-
// ../ast/lib/ast/Variable.js
|
|
2736
|
-
init_process();
|
|
2737
|
-
init_buffer();
|
|
2738
|
-
var Variable = class extends AstNode {
|
|
2739
|
-
constructor(args) {
|
|
2740
|
-
super();
|
|
2741
|
-
__publicField(this, "args");
|
|
2742
|
-
this.args = args;
|
|
2743
|
-
}
|
|
2744
|
-
write(writer) {
|
|
2745
|
-
if (this.args.export) {
|
|
2746
|
-
writer.write("export ");
|
|
2747
|
-
}
|
|
2748
|
-
if (this.args.const) {
|
|
2749
|
-
writer.write("const ");
|
|
2750
|
-
} else {
|
|
2751
|
-
writer.write("let ");
|
|
2752
|
-
}
|
|
2753
|
-
writer.write(`${this.args.name} = `);
|
|
2754
|
-
writer.writeNode(this.args.initializer);
|
|
2755
|
-
}
|
|
2756
|
-
};
|
|
2757
|
-
|
|
2758
|
-
// ../ast/lib/ast/Parameter.js
|
|
2759
|
-
init_process();
|
|
2760
|
-
init_buffer();
|
|
2761
|
-
|
|
2762
|
-
// ../ast/lib/ast/Comment.js
|
|
2763
|
-
init_process();
|
|
2764
|
-
init_buffer();
|
|
2765
|
-
var Comment = class extends AstNode {
|
|
2766
|
-
constructor({ docs } = { docs: void 0 }) {
|
|
2767
|
-
super();
|
|
2768
|
-
__publicField(this, "docs");
|
|
2769
|
-
this.docs = docs;
|
|
2770
|
-
}
|
|
2771
|
-
write(writer) {
|
|
2772
|
-
if (this.docs != null) {
|
|
2773
|
-
writer.writeLine("/**");
|
|
2774
|
-
this.docs.split("\n").forEach((line) => {
|
|
2775
|
-
writer.writeLine(` * ${line}`);
|
|
2776
|
-
});
|
|
2777
|
-
writer.writeLine("*/");
|
|
2778
|
-
}
|
|
2779
|
-
}
|
|
2780
|
-
};
|
|
2781
|
-
|
|
2782
|
-
// ../ast/lib/ast/Parameter.js
|
|
2783
|
-
var Parameter = class extends AstNode {
|
|
2784
|
-
constructor({ name, type, docs }) {
|
|
2785
|
-
super();
|
|
2786
|
-
__publicField(this, "name");
|
|
2787
|
-
__publicField(this, "type");
|
|
2788
|
-
__publicField(this, "docs");
|
|
2789
|
-
this.name = name;
|
|
2790
|
-
this.type = type;
|
|
2791
|
-
this.docs = docs;
|
|
2792
|
-
}
|
|
2793
|
-
write(writer) {
|
|
2794
|
-
writer.write(`${this.name}`);
|
|
2795
|
-
}
|
|
2796
|
-
writeWithType(writer) {
|
|
2797
|
-
if (this.docs != null) {
|
|
2798
|
-
writer.writeNode(new Comment({ docs: this.docs }));
|
|
2799
|
-
}
|
|
2800
|
-
writer.write(`${this.name}: `);
|
|
2801
|
-
this.type.write(writer);
|
|
2802
|
-
}
|
|
2803
|
-
};
|
|
2804
|
-
|
|
2805
|
-
// ../ast/lib/ast/Function.js
|
|
2806
|
-
init_process();
|
|
2807
|
-
init_buffer();
|
|
2808
|
-
var Function = class extends AstNode {
|
|
2809
|
-
constructor({ name, parameters, async, body, return_, docs }) {
|
|
2810
|
-
super();
|
|
2811
|
-
__publicField(this, "name");
|
|
2812
|
-
__publicField(this, "parameters");
|
|
2813
|
-
__publicField(this, "async");
|
|
2814
|
-
__publicField(this, "body");
|
|
2815
|
-
__publicField(this, "return_");
|
|
2816
|
-
__publicField(this, "docs");
|
|
2817
|
-
this.name = name;
|
|
2818
|
-
this.parameters = parameters;
|
|
2819
|
-
this.async = async != null ? async : false;
|
|
2820
|
-
this.body = body;
|
|
2821
|
-
this.return_ = return_;
|
|
2822
|
-
this.docs = docs;
|
|
2823
|
-
}
|
|
2824
|
-
write(writer) {
|
|
2825
|
-
var _a;
|
|
2826
|
-
writer.writeNode(new Comment({ docs: this.docs }));
|
|
2827
|
-
if (this.async) {
|
|
2828
|
-
writer.write("async ");
|
|
2829
|
-
}
|
|
2830
|
-
writer.write("function ");
|
|
2831
|
-
writer.write(`${this.name}`);
|
|
2832
|
-
this.writeParameters(writer);
|
|
2833
|
-
if (this.return_ != null) {
|
|
2834
|
-
writer.write(": ");
|
|
2835
|
-
writer.writeNode(this.async ? Type.promise(this.return_) : this.return_);
|
|
2836
|
-
}
|
|
2837
|
-
writer.writeLine(" {");
|
|
2838
|
-
writer.indent();
|
|
2839
|
-
(_a = this.body) == null ? void 0 : _a.write(writer);
|
|
2840
|
-
writer.dedent();
|
|
2841
|
-
writer.writeNewLineIfLastLineNot();
|
|
2842
|
-
writer.writeLine("}");
|
|
2843
|
-
}
|
|
2844
|
-
writeParameters(writer) {
|
|
2845
|
-
if (this.parameters.length === 0) {
|
|
2846
|
-
writer.write("()");
|
|
2847
|
-
return;
|
|
2848
|
-
}
|
|
2849
|
-
writer.writeLine("(");
|
|
2850
|
-
writer.delimit({
|
|
2851
|
-
nodes: this.parameters,
|
|
2852
|
-
delimiter: ",\n",
|
|
2853
|
-
writeFunction: (parameter2) => parameter2.writeWithType(writer)
|
|
2854
|
-
});
|
|
2855
|
-
writer.write(")");
|
|
2856
|
-
}
|
|
2857
|
-
};
|
|
2858
|
-
|
|
2859
|
-
// ../ast/lib/ast/FunctionInvocation.js
|
|
2860
|
-
init_process();
|
|
2861
|
-
init_buffer();
|
|
2862
|
-
var FunctionInvocation = class extends AstNode {
|
|
2863
|
-
constructor({ function_: function_2, arguments_ }) {
|
|
2864
|
-
super();
|
|
2865
|
-
__publicField(this, "function_");
|
|
2866
|
-
__publicField(this, "arguments_");
|
|
2867
|
-
this.function_ = function_2;
|
|
2868
|
-
this.arguments_ = arguments_;
|
|
2869
|
-
}
|
|
2870
|
-
write(writer) {
|
|
2871
|
-
writer.writeNode(this.function_);
|
|
2872
|
-
writer.write("(");
|
|
2873
|
-
writer.delimit({
|
|
2874
|
-
nodes: this.arguments_,
|
|
2875
|
-
delimiter: ", ",
|
|
2876
|
-
writeFunction: (argument) => argument.write(writer)
|
|
2877
|
-
});
|
|
2878
|
-
writer.write(")");
|
|
2879
|
-
}
|
|
2880
|
-
};
|
|
2881
|
-
|
|
2882
|
-
// ../ast/lib/ast/MethodInvocation.js
|
|
2883
|
-
init_process();
|
|
2884
|
-
init_buffer();
|
|
2885
|
-
var MethodInvocation = class extends AstNode {
|
|
2886
|
-
constructor({ on: on2, method, arguments_, async }) {
|
|
2887
|
-
super();
|
|
2888
|
-
__publicField(this, "on");
|
|
2889
|
-
__publicField(this, "method");
|
|
2890
|
-
__publicField(this, "arguments_");
|
|
2891
|
-
__publicField(this, "async");
|
|
2892
|
-
this.on = on2;
|
|
2893
|
-
this.method = method;
|
|
2894
|
-
this.arguments_ = arguments_;
|
|
2895
|
-
this.async = async;
|
|
2896
|
-
}
|
|
2897
|
-
write(writer) {
|
|
2898
|
-
if (this.async) {
|
|
2899
|
-
writer.write("await ");
|
|
2900
|
-
}
|
|
2901
|
-
this.on.write(writer);
|
|
2902
|
-
writer.write(".");
|
|
2903
|
-
writer.write(this.method);
|
|
2904
|
-
writer.write("(");
|
|
2905
|
-
writer.delimit({
|
|
2906
|
-
nodes: this.arguments_,
|
|
2907
|
-
delimiter: ", ",
|
|
2908
|
-
writeFunction: (argument) => argument.write(writer)
|
|
2909
|
-
});
|
|
2910
|
-
writer.write(")");
|
|
2911
|
-
}
|
|
2912
|
-
};
|
|
2913
|
-
|
|
2914
|
-
// ../ast/lib/ast/ClassInstantiation.js
|
|
2915
|
-
init_process();
|
|
2916
|
-
init_buffer();
|
|
2917
|
-
var ClassInstantiation = class extends AstNode {
|
|
2918
|
-
constructor({ class_, arguments_ }) {
|
|
2919
|
-
super();
|
|
2920
|
-
__publicField(this, "class_");
|
|
2921
|
-
__publicField(this, "arguments_");
|
|
2922
|
-
this.class_ = class_;
|
|
2923
|
-
this.arguments_ = arguments_;
|
|
2924
|
-
}
|
|
2925
|
-
write(writer) {
|
|
2926
|
-
writer.write("new ");
|
|
2927
|
-
writer.writeNode(this.class_);
|
|
2928
|
-
writer.write("(");
|
|
2929
|
-
writer.delimit({
|
|
2930
|
-
nodes: this.arguments_,
|
|
2931
|
-
delimiter: ", ",
|
|
2932
|
-
writeFunction: (argument) => argument.write(writer)
|
|
2933
|
-
});
|
|
2934
|
-
writer.write(")");
|
|
2935
|
-
}
|
|
2936
|
-
};
|
|
2937
|
-
|
|
2938
|
-
// ../ast/lib/typescript.js
|
|
2939
|
-
function codeblock(arg) {
|
|
2940
|
-
return new CodeBlock2(arg);
|
|
2941
|
-
}
|
|
2942
|
-
function function_(args) {
|
|
2943
|
-
return new Function(args);
|
|
2944
|
-
}
|
|
2945
|
-
function instantiateClass(args) {
|
|
2946
|
-
return new ClassInstantiation(args);
|
|
2947
|
-
}
|
|
2948
|
-
function invokeFunction(args) {
|
|
2949
|
-
return new FunctionInvocation(args);
|
|
2950
|
-
}
|
|
2951
|
-
function invokeMethod(args) {
|
|
2952
|
-
return new MethodInvocation(args);
|
|
2953
|
-
}
|
|
2954
|
-
function parameter(args) {
|
|
2955
|
-
return new Parameter(args);
|
|
2956
|
-
}
|
|
2957
|
-
function reference(arg) {
|
|
2958
|
-
return new Reference(arg);
|
|
2959
|
-
}
|
|
2960
|
-
function variable(arg) {
|
|
2961
|
-
return new Variable(arg);
|
|
2962
|
-
}
|
|
2963
|
-
|
|
2964
|
-
// src/EndpointSnippetGenerator.ts
|
|
2965
|
-
var CLIENT_VAR_NAME = "client";
|
|
2966
|
-
var MAIN_FUNCTION_NAME = "main";
|
|
2967
|
-
var STRING_TYPE_REFERENCE = {
|
|
2968
|
-
type: "primitive",
|
|
2969
|
-
value: "STRING"
|
|
2970
|
-
};
|
|
2971
|
-
var EndpointSnippetGenerator = class {
|
|
2972
|
-
constructor({ context }) {
|
|
2973
|
-
__publicField(this, "context");
|
|
2974
|
-
this.context = context;
|
|
2975
|
-
}
|
|
2976
|
-
async generateSnippet({
|
|
2977
|
-
endpoint,
|
|
2978
|
-
request
|
|
2979
|
-
}) {
|
|
2980
|
-
const code = this.buildCodeBlock({ endpoint, snippet: request });
|
|
2981
|
-
return await code.toString({ customConfig: this.context.customConfig });
|
|
2982
|
-
}
|
|
2983
|
-
generateSnippetSync({
|
|
2984
|
-
endpoint,
|
|
2985
|
-
request
|
|
2986
|
-
}) {
|
|
2987
|
-
const code = this.buildCodeBlock({ endpoint, snippet: request });
|
|
2988
|
-
return code.toStringSync({ customConfig: this.context.customConfig });
|
|
2989
|
-
}
|
|
2990
|
-
buildCodeBlock({
|
|
2991
|
-
endpoint,
|
|
2992
|
-
snippet
|
|
2993
|
-
}) {
|
|
2994
|
-
return typescript_exports.codeblock((writer) => {
|
|
2995
|
-
writer.writeNode(
|
|
2996
|
-
typescript_exports.function_({
|
|
2997
|
-
name: MAIN_FUNCTION_NAME,
|
|
2998
|
-
async: true,
|
|
2999
|
-
parameters: [],
|
|
3000
|
-
body: typescript_exports.codeblock((writer2) => {
|
|
3001
|
-
writer2.writeNodeStatement(this.constructClient({ endpoint, snippet }));
|
|
3002
|
-
writer2.writeNodeStatement(this.callMethod({ endpoint, snippet }));
|
|
3003
|
-
})
|
|
3004
|
-
})
|
|
3005
|
-
);
|
|
3006
|
-
writer.writeNodeStatement(
|
|
3007
|
-
typescript_exports.invokeFunction({
|
|
3008
|
-
function_: typescript_exports.reference({
|
|
3009
|
-
name: MAIN_FUNCTION_NAME
|
|
3010
|
-
}),
|
|
3011
|
-
arguments_: []
|
|
3012
|
-
})
|
|
3013
|
-
);
|
|
3014
|
-
});
|
|
3015
|
-
}
|
|
3016
|
-
constructClient({
|
|
3017
|
-
endpoint,
|
|
3018
|
-
snippet
|
|
3019
|
-
}) {
|
|
3020
|
-
return typescript_exports.variable({
|
|
3021
|
-
name: CLIENT_VAR_NAME,
|
|
3022
|
-
const: true,
|
|
3023
|
-
initializer: typescript_exports.instantiateClass({
|
|
3024
|
-
class_: typescript_exports.reference({
|
|
3025
|
-
name: this.context.getRootClientName(),
|
|
3026
|
-
importFrom: this.context.getModuleImport()
|
|
3027
|
-
}),
|
|
3028
|
-
arguments_: [this.getConstructorArgs({ endpoint, snippet })]
|
|
3029
|
-
})
|
|
3030
|
-
});
|
|
3031
|
-
}
|
|
3032
|
-
getConstructorArgs({
|
|
3033
|
-
endpoint,
|
|
3034
|
-
snippet
|
|
3035
|
-
}) {
|
|
3036
|
-
const fields = [];
|
|
3037
|
-
const environmentArgs = this.getConstructorEnvironmentArgs({
|
|
3038
|
-
baseUrl: snippet.baseURL,
|
|
3039
|
-
environment: snippet.environment
|
|
3040
|
-
});
|
|
3041
|
-
if (environmentArgs.length > 0) {
|
|
3042
|
-
fields.push(...environmentArgs);
|
|
3043
|
-
}
|
|
3044
|
-
if (endpoint.auth != null) {
|
|
3045
|
-
if (snippet.auth != null) {
|
|
3046
|
-
fields.push(...this.getConstructorAuthArgs({ auth: endpoint.auth, values: snippet.auth }));
|
|
3047
|
-
} else {
|
|
3048
|
-
this.context.errors.add({
|
|
3049
|
-
severity: Severity.Warning,
|
|
3050
|
-
message: `Auth with ${endpoint.auth.type} configuration is required for this endpoint`
|
|
3051
|
-
});
|
|
3052
|
-
}
|
|
3053
|
-
}
|
|
3054
|
-
this.context.errors.scope(Scope.Headers);
|
|
3055
|
-
if (this.context.ir.headers != null && snippet.headers != null) {
|
|
3056
|
-
fields.push(
|
|
3057
|
-
...this.getConstructorHeaderArgs({ headers: this.context.ir.headers, values: snippet.headers })
|
|
3058
|
-
);
|
|
3059
|
-
}
|
|
3060
|
-
this.context.errors.unscope();
|
|
3061
|
-
if (fields.length === 0) {
|
|
3062
|
-
return typescript_exports.TypeLiteral.nop();
|
|
3063
|
-
}
|
|
3064
|
-
return typescript_exports.TypeLiteral.object({ fields });
|
|
3065
|
-
}
|
|
3066
|
-
getConstructorEnvironmentArgs({
|
|
3067
|
-
baseUrl,
|
|
3068
|
-
environment
|
|
3069
|
-
}) {
|
|
3070
|
-
const environmentValue = this.getEnvironmentValue({ baseUrl, environment });
|
|
3071
|
-
if (environmentValue == null) {
|
|
3072
|
-
return [];
|
|
3073
|
-
}
|
|
3074
|
-
return [
|
|
3075
|
-
{
|
|
3076
|
-
name: "environment",
|
|
3077
|
-
value: environmentValue
|
|
3078
|
-
}
|
|
3079
|
-
];
|
|
3080
|
-
}
|
|
3081
|
-
getEnvironmentValue({
|
|
3082
|
-
baseUrl,
|
|
3083
|
-
environment
|
|
3084
|
-
}) {
|
|
3085
|
-
if (baseUrl != null && environment != null) {
|
|
3086
|
-
this.context.errors.add({
|
|
3087
|
-
severity: Severity.Critical,
|
|
3088
|
-
message: "Cannot specify both baseUrl and environment options"
|
|
3089
|
-
});
|
|
3090
|
-
return void 0;
|
|
3091
|
-
}
|
|
3092
|
-
if (baseUrl != null) {
|
|
3093
|
-
return typescript_exports.TypeLiteral.string(baseUrl);
|
|
3094
|
-
}
|
|
3095
|
-
if (environment != null) {
|
|
3096
|
-
if (this.context.isSingleEnvironmentID(environment)) {
|
|
3097
|
-
const environmentTypeReference = this.context.getEnvironmentTypeReferenceFromID(environment);
|
|
3098
|
-
if (environmentTypeReference == null) {
|
|
3099
|
-
this.context.errors.add({
|
|
3100
|
-
severity: Severity.Warning,
|
|
3101
|
-
message: `Environment ${JSON.stringify(environment)} was not found`
|
|
3102
|
-
});
|
|
3103
|
-
return void 0;
|
|
3104
|
-
}
|
|
3105
|
-
return typescript_exports.TypeLiteral.reference(environmentTypeReference);
|
|
3106
|
-
}
|
|
3107
|
-
if (this.context.isMultiEnvironmentValues(environment)) {
|
|
3108
|
-
if (!this.context.validateMultiEnvironmentUrlValues(environment)) {
|
|
3109
|
-
return void 0;
|
|
3110
|
-
}
|
|
3111
|
-
return typescript_exports.TypeLiteral.object({
|
|
3112
|
-
fields: Object.entries(environment).map(([key, value]) => ({
|
|
3113
|
-
name: key,
|
|
3114
|
-
value: this.context.dynamicTypeLiteralMapper.convert({
|
|
3115
|
-
typeReference: STRING_TYPE_REFERENCE,
|
|
3116
|
-
value
|
|
3117
|
-
})
|
|
3118
|
-
}))
|
|
3119
|
-
});
|
|
3120
|
-
}
|
|
3121
|
-
}
|
|
3122
|
-
return void 0;
|
|
3123
|
-
}
|
|
3124
|
-
getConstructorAuthArgs({
|
|
3125
|
-
auth,
|
|
3126
|
-
values
|
|
3127
|
-
}) {
|
|
3128
|
-
switch (auth.type) {
|
|
3129
|
-
case "basic":
|
|
3130
|
-
if (values.type !== "basic") {
|
|
3131
|
-
this.context.errors.add({
|
|
3132
|
-
severity: Severity.Critical,
|
|
3133
|
-
message: this.context.newAuthMismatchError({ auth, values }).message
|
|
3134
|
-
});
|
|
3135
|
-
return [];
|
|
3136
|
-
}
|
|
3137
|
-
return this.getConstructorBasicAuthArg({ auth, values });
|
|
3138
|
-
case "bearer":
|
|
3139
|
-
if (values.type !== "bearer") {
|
|
3140
|
-
this.context.errors.add({
|
|
3141
|
-
severity: Severity.Critical,
|
|
3142
|
-
message: this.context.newAuthMismatchError({ auth, values }).message
|
|
3143
|
-
});
|
|
3144
|
-
return [];
|
|
3145
|
-
}
|
|
3146
|
-
return this.getConstructorBearerAuthArgs({ auth, values });
|
|
3147
|
-
case "header":
|
|
3148
|
-
if (values.type !== "header") {
|
|
3149
|
-
this.context.errors.add({
|
|
3150
|
-
severity: Severity.Critical,
|
|
3151
|
-
message: this.context.newAuthMismatchError({ auth, values }).message
|
|
3152
|
-
});
|
|
3153
|
-
return [];
|
|
3154
|
-
}
|
|
3155
|
-
return this.getConstructorHeaderAuthArgs({ auth, values });
|
|
3156
|
-
default:
|
|
3157
|
-
assertNever(auth);
|
|
3158
|
-
}
|
|
3159
|
-
}
|
|
3160
|
-
getConstructorBasicAuthArg({
|
|
3161
|
-
auth,
|
|
3162
|
-
values
|
|
3163
|
-
}) {
|
|
3164
|
-
return [
|
|
3165
|
-
{
|
|
3166
|
-
name: this.context.getPropertyName(auth.username),
|
|
3167
|
-
value: typescript_exports.TypeLiteral.string(values.username)
|
|
3168
|
-
},
|
|
3169
|
-
{
|
|
3170
|
-
name: this.context.getPropertyName(auth.password),
|
|
3171
|
-
value: typescript_exports.TypeLiteral.string(values.password)
|
|
3172
|
-
}
|
|
3173
|
-
];
|
|
3174
|
-
}
|
|
3175
|
-
getConstructorBearerAuthArgs({
|
|
3176
|
-
auth,
|
|
3177
|
-
values
|
|
3178
|
-
}) {
|
|
3179
|
-
return [
|
|
3180
|
-
{
|
|
3181
|
-
name: this.context.getPropertyName(auth.token),
|
|
3182
|
-
value: typescript_exports.TypeLiteral.string(values.token)
|
|
3183
|
-
}
|
|
3184
|
-
];
|
|
3185
|
-
}
|
|
3186
|
-
getConstructorHeaderAuthArgs({
|
|
3187
|
-
auth,
|
|
3188
|
-
values
|
|
3189
|
-
}) {
|
|
3190
|
-
return [
|
|
3191
|
-
{
|
|
3192
|
-
name: this.context.getPropertyName(auth.header.name.name),
|
|
3193
|
-
value: this.context.dynamicTypeLiteralMapper.convert({
|
|
3194
|
-
typeReference: auth.header.typeReference,
|
|
3195
|
-
value: values.value
|
|
3196
|
-
})
|
|
3197
|
-
}
|
|
3198
|
-
];
|
|
3199
|
-
}
|
|
3200
|
-
getConstructorHeaderArgs({
|
|
3201
|
-
headers,
|
|
3202
|
-
values
|
|
3203
|
-
}) {
|
|
3204
|
-
const fields = [];
|
|
3205
|
-
for (const header of headers) {
|
|
3206
|
-
const field = this.getConstructorHeaderArg({ header, value: values.value });
|
|
3207
|
-
if (field != null) {
|
|
3208
|
-
fields.push(field);
|
|
3209
|
-
}
|
|
3210
|
-
}
|
|
3211
|
-
return fields;
|
|
3212
|
-
}
|
|
3213
|
-
getConstructorHeaderArg({
|
|
3214
|
-
header,
|
|
3215
|
-
value
|
|
3216
|
-
}) {
|
|
3217
|
-
const typeLiteral = this.context.dynamicTypeLiteralMapper.convert({
|
|
3218
|
-
typeReference: header.typeReference,
|
|
3219
|
-
value
|
|
3220
|
-
});
|
|
3221
|
-
if (typescript_exports.TypeLiteral.isNop(typeLiteral)) {
|
|
3222
|
-
return void 0;
|
|
3223
|
-
}
|
|
3224
|
-
return {
|
|
3225
|
-
name: this.context.getPropertyName(header.name.name),
|
|
3226
|
-
value: typeLiteral
|
|
3227
|
-
};
|
|
3228
|
-
}
|
|
3229
|
-
callMethod({
|
|
3230
|
-
endpoint,
|
|
3231
|
-
snippet
|
|
3232
|
-
}) {
|
|
3233
|
-
return typescript_exports.invokeMethod({
|
|
3234
|
-
on: typescript_exports.reference({ name: CLIENT_VAR_NAME }),
|
|
3235
|
-
method: this.getMethod({ endpoint }),
|
|
3236
|
-
async: true,
|
|
3237
|
-
arguments_: this.getMethodArgs({ endpoint, snippet })
|
|
3238
|
-
});
|
|
3239
|
-
}
|
|
3240
|
-
getMethodArgs({
|
|
3241
|
-
endpoint,
|
|
3242
|
-
snippet
|
|
3243
|
-
}) {
|
|
3244
|
-
switch (endpoint.request.type) {
|
|
3245
|
-
case "inlined":
|
|
3246
|
-
return this.getMethodArgsForInlinedRequest({ request: endpoint.request, snippet });
|
|
3247
|
-
case "body":
|
|
3248
|
-
return this.getMethodArgsForBodyRequest({ request: endpoint.request, snippet });
|
|
3249
|
-
default:
|
|
3250
|
-
assertNever(endpoint.request);
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
getMethodArgsForBodyRequest({
|
|
3254
|
-
request,
|
|
3255
|
-
snippet
|
|
3256
|
-
}) {
|
|
3257
|
-
const args = [];
|
|
3258
|
-
this.context.errors.scope(Scope.PathParameters);
|
|
3259
|
-
if (request.pathParameters != null) {
|
|
3260
|
-
const pathParameterFields = this.getPathParameters({ namedParameters: request.pathParameters, snippet });
|
|
3261
|
-
args.push(...pathParameterFields.map((field) => field.value));
|
|
3262
|
-
}
|
|
3263
|
-
this.context.errors.unscope();
|
|
3264
|
-
this.context.errors.scope(Scope.RequestBody);
|
|
3265
|
-
if (request.body != null) {
|
|
3266
|
-
args.push(this.getBodyRequestArg({ body: request.body, value: snippet.requestBody }));
|
|
3267
|
-
}
|
|
3268
|
-
this.context.errors.unscope();
|
|
3269
|
-
return args;
|
|
3270
|
-
}
|
|
3271
|
-
getBodyRequestArg({
|
|
3272
|
-
body,
|
|
3273
|
-
value
|
|
3274
|
-
}) {
|
|
3275
|
-
switch (body.type) {
|
|
3276
|
-
case "bytes":
|
|
3277
|
-
return this.getBytesBodyRequestArg({ value });
|
|
3278
|
-
case "typeReference":
|
|
3279
|
-
return this.context.dynamicTypeLiteralMapper.convert({ typeReference: body.value, value });
|
|
3280
|
-
default:
|
|
3281
|
-
assertNever(body);
|
|
3282
|
-
}
|
|
3283
|
-
}
|
|
3284
|
-
getBytesBodyRequestArg({ value }) {
|
|
3285
|
-
if (typeof value !== "string") {
|
|
3286
|
-
this.context.errors.add({
|
|
3287
|
-
severity: Severity.Critical,
|
|
3288
|
-
message: `Expected bytes value to be a string, got ${typeof value}`
|
|
3289
|
-
});
|
|
3290
|
-
return typescript_exports.TypeLiteral.nop();
|
|
3291
|
-
}
|
|
3292
|
-
return typescript_exports.TypeLiteral.blob(value);
|
|
3293
|
-
}
|
|
3294
|
-
getMethodArgsForInlinedRequest({
|
|
3295
|
-
request,
|
|
3296
|
-
snippet
|
|
3297
|
-
}) {
|
|
3298
|
-
var _a, _b, _c, _d;
|
|
3299
|
-
const args = [];
|
|
3300
|
-
const { inlinePathParameters, inlineFileProperties } = {
|
|
3301
|
-
inlinePathParameters: (_b = (_a = this.context.customConfig) == null ? void 0 : _a.inlinePathParameters) != null ? _b : false,
|
|
3302
|
-
inlineFileProperties: (_d = (_c = this.context.customConfig) == null ? void 0 : _c.inlineFileProperties) != null ? _d : false
|
|
3303
|
-
};
|
|
3304
|
-
this.context.errors.scope(Scope.PathParameters);
|
|
3305
|
-
const pathParameterFields = [];
|
|
3306
|
-
if (request.pathParameters != null) {
|
|
3307
|
-
pathParameterFields.push(...this.getPathParameters({ namedParameters: request.pathParameters, snippet }));
|
|
3308
|
-
}
|
|
3309
|
-
this.context.errors.unscope();
|
|
3310
|
-
this.context.errors.scope(Scope.RequestBody);
|
|
3311
|
-
const filePropertyInfo = this.getFilePropertyInfo({ request, snippet });
|
|
3312
|
-
this.context.errors.unscope();
|
|
3313
|
-
if (!this.context.includePathParametersInWrappedRequest({
|
|
3314
|
-
request,
|
|
3315
|
-
inlinePathParameters
|
|
3316
|
-
})) {
|
|
3317
|
-
args.push(...pathParameterFields.map((field) => field.value));
|
|
3318
|
-
}
|
|
3319
|
-
if (!inlineFileProperties) {
|
|
3320
|
-
args.push(...filePropertyInfo.fileFields.map((field) => field.value));
|
|
3321
|
-
}
|
|
3322
|
-
if (this.context.needsRequestParameter({
|
|
3323
|
-
request,
|
|
3324
|
-
inlinePathParameters,
|
|
3325
|
-
inlineFileProperties
|
|
3326
|
-
})) {
|
|
3327
|
-
args.push(
|
|
3328
|
-
this.getInlinedRequestArg({
|
|
3329
|
-
request,
|
|
3330
|
-
snippet,
|
|
3331
|
-
pathParameterFields: this.context.includePathParametersInWrappedRequest({
|
|
3332
|
-
request,
|
|
3333
|
-
inlinePathParameters
|
|
3334
|
-
}) ? pathParameterFields : [],
|
|
3335
|
-
filePropertyInfo
|
|
3336
|
-
})
|
|
3337
|
-
);
|
|
3338
|
-
}
|
|
3339
|
-
return args;
|
|
3340
|
-
}
|
|
3341
|
-
getFilePropertyInfo({
|
|
3342
|
-
request,
|
|
3343
|
-
snippet
|
|
3344
|
-
}) {
|
|
3345
|
-
if (request.body == null || !this.context.isFileUploadRequestBody(request.body)) {
|
|
3346
|
-
return {
|
|
3347
|
-
fileFields: [],
|
|
3348
|
-
bodyPropertyFields: []
|
|
3349
|
-
};
|
|
3350
|
-
}
|
|
3351
|
-
return this.context.filePropertyMapper.getFilePropertyInfo({
|
|
3352
|
-
body: request.body,
|
|
3353
|
-
value: snippet.requestBody
|
|
3354
|
-
});
|
|
3355
|
-
}
|
|
3356
|
-
getInlinedRequestArg({
|
|
3357
|
-
request,
|
|
3358
|
-
snippet,
|
|
3359
|
-
pathParameterFields,
|
|
3360
|
-
filePropertyInfo
|
|
3361
|
-
}) {
|
|
3362
|
-
var _a, _b, _c, _d;
|
|
3363
|
-
this.context.errors.scope(Scope.QueryParameters);
|
|
3364
|
-
const queryParameters = this.context.associateQueryParametersByWireValue({
|
|
3365
|
-
parameters: (_a = request.queryParameters) != null ? _a : [],
|
|
3366
|
-
values: (_b = snippet.queryParameters) != null ? _b : {}
|
|
3367
|
-
});
|
|
3368
|
-
const queryParameterFields = queryParameters.map((queryParameter) => ({
|
|
3369
|
-
name: this.context.getPropertyName(queryParameter.name.name),
|
|
3370
|
-
value: this.context.dynamicTypeLiteralMapper.convert(queryParameter)
|
|
3371
|
-
}));
|
|
3372
|
-
this.context.errors.unscope();
|
|
3373
|
-
this.context.errors.scope(Scope.Headers);
|
|
3374
|
-
const headers = this.context.associateByWireValue({
|
|
3375
|
-
parameters: (_c = request.headers) != null ? _c : [],
|
|
3376
|
-
values: (_d = snippet.headers) != null ? _d : {}
|
|
3377
|
-
});
|
|
3378
|
-
const headerFields = headers.map((header) => ({
|
|
3379
|
-
name: this.context.getPropertyName(header.name.name),
|
|
3380
|
-
value: this.context.dynamicTypeLiteralMapper.convert(header)
|
|
3381
|
-
}));
|
|
3382
|
-
this.context.errors.unscope();
|
|
3383
|
-
this.context.errors.scope(Scope.RequestBody);
|
|
3384
|
-
const requestBodyFields = request.body != null ? this.getInlinedRequestBodyObjectFields({
|
|
3385
|
-
body: request.body,
|
|
3386
|
-
value: snippet.requestBody,
|
|
3387
|
-
filePropertyInfo
|
|
3388
|
-
}) : [];
|
|
3389
|
-
this.context.errors.unscope();
|
|
3390
|
-
return typescript_exports.TypeLiteral.object({
|
|
3391
|
-
fields: [...pathParameterFields, ...queryParameterFields, ...headerFields, ...requestBodyFields]
|
|
3392
|
-
});
|
|
3393
|
-
}
|
|
3394
|
-
getInlinedRequestBodyObjectFields({
|
|
3395
|
-
body,
|
|
3396
|
-
value,
|
|
3397
|
-
filePropertyInfo
|
|
3398
|
-
}) {
|
|
3399
|
-
switch (body.type) {
|
|
3400
|
-
case "properties":
|
|
3401
|
-
return this.getInlinedRequestBodyPropertyObjectFields({ parameters: body.value, value });
|
|
3402
|
-
case "referenced":
|
|
3403
|
-
return [this.getReferencedRequestBodyPropertyObjectField({ body, value })];
|
|
3404
|
-
case "fileUpload":
|
|
3405
|
-
return this.getFileUploadRequestBodyObjectFields({ filePropertyInfo });
|
|
3406
|
-
default:
|
|
3407
|
-
assertNever(body);
|
|
3408
|
-
}
|
|
3409
|
-
}
|
|
3410
|
-
getFileUploadRequestBodyObjectFields({
|
|
3411
|
-
filePropertyInfo
|
|
3412
|
-
}) {
|
|
3413
|
-
var _a;
|
|
3414
|
-
if ((_a = this.context.customConfig) == null ? void 0 : _a.inlineFileProperties) {
|
|
3415
|
-
return [...filePropertyInfo.fileFields, ...filePropertyInfo.bodyPropertyFields];
|
|
3416
|
-
}
|
|
3417
|
-
return filePropertyInfo.bodyPropertyFields;
|
|
3418
|
-
}
|
|
3419
|
-
getReferencedRequestBodyPropertyObjectField({
|
|
3420
|
-
body,
|
|
3421
|
-
value
|
|
3422
|
-
}) {
|
|
3423
|
-
return {
|
|
3424
|
-
name: this.context.getPropertyName(body.bodyKey),
|
|
3425
|
-
value: this.getReferencedRequestBodyPropertyTypeLiteral({ body: body.bodyType, value })
|
|
3426
|
-
};
|
|
3427
|
-
}
|
|
3428
|
-
getReferencedRequestBodyPropertyTypeLiteral({
|
|
3429
|
-
body,
|
|
3430
|
-
value
|
|
3431
|
-
}) {
|
|
3432
|
-
switch (body.type) {
|
|
3433
|
-
case "bytes":
|
|
3434
|
-
return this.getBytesBodyRequestArg({ value });
|
|
3435
|
-
case "typeReference":
|
|
3436
|
-
return this.context.dynamicTypeLiteralMapper.convert({ typeReference: body.value, value });
|
|
3437
|
-
default:
|
|
3438
|
-
assertNever(body);
|
|
3439
|
-
}
|
|
3440
|
-
}
|
|
3441
|
-
getInlinedRequestBodyPropertyObjectFields({
|
|
3442
|
-
parameters,
|
|
3443
|
-
value
|
|
3444
|
-
}) {
|
|
3445
|
-
var _a;
|
|
3446
|
-
const fields = [];
|
|
3447
|
-
const bodyProperties = this.context.associateByWireValue({
|
|
3448
|
-
parameters,
|
|
3449
|
-
values: (_a = this.context.getRecord(value)) != null ? _a : {}
|
|
3450
|
-
});
|
|
3451
|
-
for (const parameter2 of bodyProperties) {
|
|
3452
|
-
fields.push({
|
|
3453
|
-
name: this.context.getPropertyName(parameter2.name.name),
|
|
3454
|
-
value: this.context.dynamicTypeLiteralMapper.convert(parameter2)
|
|
3455
|
-
});
|
|
3456
|
-
}
|
|
3457
|
-
return fields;
|
|
3458
|
-
}
|
|
3459
|
-
getPathParameters({
|
|
3460
|
-
namedParameters,
|
|
3461
|
-
snippet
|
|
3462
|
-
}) {
|
|
3463
|
-
var _a;
|
|
3464
|
-
const args = [];
|
|
3465
|
-
const pathParameters = this.context.associateByWireValue({
|
|
3466
|
-
parameters: namedParameters,
|
|
3467
|
-
values: (_a = snippet.pathParameters) != null ? _a : {}
|
|
3468
|
-
});
|
|
3469
|
-
for (const parameter2 of pathParameters) {
|
|
3470
|
-
args.push({
|
|
3471
|
-
name: this.context.getPropertyName(parameter2.name.name),
|
|
3472
|
-
value: this.context.dynamicTypeLiteralMapper.convert(parameter2)
|
|
3473
|
-
});
|
|
3474
|
-
}
|
|
3475
|
-
return args;
|
|
3476
|
-
}
|
|
3477
|
-
getMethod({ endpoint }) {
|
|
3478
|
-
if (endpoint.declaration.fernFilepath.allParts.length > 0) {
|
|
3479
|
-
return `${endpoint.declaration.fernFilepath.allParts.map((val) => this.context.getMethodName(val)).join(".")}.${this.context.getMethodName(endpoint.declaration.name)}`;
|
|
3480
|
-
}
|
|
3481
|
-
return this.context.getMethodName(endpoint.declaration.name);
|
|
3482
|
-
}
|
|
3483
|
-
};
|
|
3484
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
3485
|
-
0 && (module.exports = {
|
|
3486
|
-
EndpointSnippetGenerator
|
|
3487
|
-
});
|
|
1
|
+
"use strict";var re=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var He=Object.prototype.hasOwnProperty;var Ge=(n,t,e)=>t in n?re(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var le=(n,t)=>()=>(n&&(t=n(n=0)),t);var we=(n,t)=>{for(var e in t)re(n,e,{get:t[e],enumerable:!0})},Je=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ve(t))!He.call(n,i)&&i!==e&&re(n,i,{get:()=>t[i],enumerable:!(r=We(t,i))||r.enumerable});return n};var ze=n=>Je(re({},"__esModule",{value:!0}),n);var f=(n,t,e)=>Ge(n,typeof t!="symbol"?t+"":t,e);function ge(){throw new Error("setTimeout has not been defined")}function ve(){throw new Error("clearTimeout has not been defined")}function Ae(n){if(L===setTimeout)return setTimeout(n,0);if((L===ge||!L)&&setTimeout)return L=setTimeout,setTimeout(n,0);try{return L(n,0)}catch(t){try{return L.call(null,n,0)}catch(e){return L.call(this,n,0)}}}function Qe(n){if(_===clearTimeout)return clearTimeout(n);if((_===ve||!_)&&clearTimeout)return _=clearTimeout,clearTimeout(n);try{return _(n)}catch(t){try{return _.call(null,n)}catch(e){return _.call(this,n)}}}function Xe(){!V||!M||(V=!1,M.length?P=M.concat(P):ne=-1,P.length&&Te())}function Te(){if(!V){var n=Ae(Xe);V=!0;for(var t=P.length;t;){for(M=P,P=[];++ne<t;)M&&M[ne].run();ne=-1,t=P.length}M=null,V=!1,Qe(n)}}function Ze(n){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];P.push(new Ie(n,t)),P.length===1&&!V&&Ae(Te)}function Ie(n,t){this.fun=n,this.array=t}function O(){}function dt(n){throw new Error("process.binding is not supported")}function yt(){return"/"}function wt(n){throw new Error("process.chdir is not supported")}function xt(){return 0}function vt(n){var t=gt.call(W)*.001,e=Math.floor(t),r=Math.floor(t%1*1e9);return n&&(e=e-n[0],r=r-n[1],r<0&&(e--,r+=1e9)),[e,r]}function Tt(){var n=new Date,t=n-At;return t/1e3}var L,_,P,V,M,ne,Ke,et,tt,rt,nt,it,ot,st,at,ut,ct,pt,lt,ft,ht,mt,W,gt,At,y,xe,p=le(()=>{"use strict";L=ge,_=ve;typeof globalThis.setTimeout=="function"&&(L=setTimeout);typeof globalThis.clearTimeout=="function"&&(_=clearTimeout);P=[],V=!1,ne=-1;Ie.prototype.run=function(){this.fun.apply(null,this.array)};Ke="browser",et="browser",tt=!0,rt={},nt=[],it="",ot={},st={},at={};ut=O,ct=O,pt=O,lt=O,ft=O,ht=O,mt=O;W=globalThis.performance||{},gt=W.now||W.mozNow||W.msNow||W.oNow||W.webkitNow||function(){return new Date().getTime()};At=new Date;y={nextTick:Ze,title:Ke,browser:tt,env:rt,argv:nt,version:it,versions:ot,on:ut,addListener:ct,once:pt,off:lt,removeListener:ft,removeAllListeners:ht,emit:mt,binding:dt,cwd:yt,chdir:wt,umask:xt,hrtime:vt,platform:et,release:st,config:at,uptime:Tt},xe={};Object.keys(xe).forEach(n=>{let t=n.split("."),e=y;for(let r=0;r<t.length;r++){let i=t[r];r===t.length-1?e[i]=xe[n]:e=e[i]||(e[i]={})}})});function Fe(){he=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=n.length;t<e;++t)R[t]=n[t],E[n.charCodeAt(t)]=t;E[45]=62,E[95]=63}function Et(n){he||Fe();var t,e,r,i,o,s,u=n.length;if(u%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=n[u-2]==="="?2:n[u-1]==="="?1:0,s=new It(u*3/4-o),r=o>0?u-4:u;var c=0;for(t=0,e=0;t<r;t+=4,e+=3)i=E[n.charCodeAt(t)]<<18|E[n.charCodeAt(t+1)]<<12|E[n.charCodeAt(t+2)]<<6|E[n.charCodeAt(t+3)],s[c++]=i>>16&255,s[c++]=i>>8&255,s[c++]=i&255;return o===2?(i=E[n.charCodeAt(t)]<<2|E[n.charCodeAt(t+1)]>>4,s[c++]=i&255):o===1&&(i=E[n.charCodeAt(t)]<<10|E[n.charCodeAt(t+1)]<<4|E[n.charCodeAt(t+2)]>>2,s[c++]=i>>8&255,s[c++]=i&255),s}function bt(n){return R[n>>18&63]+R[n>>12&63]+R[n>>6&63]+R[n&63]}function Rt(n,t,e){for(var r,i=[],o=t;o<e;o+=3)r=(n[o]<<16)+(n[o+1]<<8)+n[o+2],i.push(bt(r));return i.join("")}function Ee(n){he||Fe();for(var t,e=n.length,r=e%3,i="",o=[],s=16383,u=0,c=e-r;u<c;u+=s)o.push(Rt(n,u,u+s>c?c:u+s));return r===1?(t=n[e-1],i+=R[t>>2],i+=R[t<<4&63],i+="=="):r===2&&(t=(n[e-2]<<8)+n[e-1],i+=R[t>>10],i+=R[t>>4&63],i+=R[t<<2&63],i+="="),o.push(i),o.join("")}function ie(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function S(n,t){if(ie()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(n=new Uint8Array(t),n.__proto__=a.prototype):(n===null&&(n=new a(t)),n.length=t),n}function a(n,t,e){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(n,t,e);if(typeof n=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return me(this,n)}return Ne(this,n,t,e)}function Ne(n,t,e,r){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer?Pt(n,t,e,r):typeof t=="string"?Nt(n,t,e):St(n,t)}function Pe(n){if(typeof n!="number")throw new TypeError('"size" argument must be a number');if(n<0)throw new RangeError('"size" argument must not be negative')}function Ft(n,t,e,r){return Pe(t),t<=0?S(n,t):e!==void 0?typeof r=="string"?S(n,t).fill(e,r):S(n,t).fill(e):S(n,t)}function me(n,t){if(Pe(t),n=S(n,t<0?0:de(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)n[e]=0;return n}function Nt(n,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var r=Se(t,e)|0;n=S(n,r);var i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}function fe(n,t){var e=t.length<0?0:de(t.length)|0;n=S(n,e);for(var r=0;r<e;r+=1)n[r]=t[r]&255;return n}function Pt(n,t,e,r){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(r||0))throw new RangeError("'length' is out of bounds");return e===void 0&&r===void 0?t=new Uint8Array(t):r===void 0?t=new Uint8Array(t,e):t=new Uint8Array(t,e,r),a.TYPED_ARRAY_SUPPORT?(n=t,n.__proto__=a.prototype):n=fe(n,t),n}function St(n,t){if(F(t)){var e=de(t.length)|0;return n=S(n,e),n.length===0||t.copy(n,0,0,e),n}if(t){if(typeof ArrayBuffer!="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||zt(t.length)?S(n,0):fe(n,t);if(t.type==="Buffer"&&Array.isArray(t.data))return fe(n,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function de(n){if(n>=ie())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ie().toString(16)+" bytes");return n|0}function F(n){return!!(n!=null&&n._isBuffer)}function Se(n,t){if(F(n))return n.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(n)||n instanceof ArrayBuffer))return n.byteLength;typeof n!="string"&&(n=""+n);var e=n.length;if(e===0)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return oe(n).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return Me(n).length;default:if(r)return oe(n).length;t=(""+t).toLowerCase(),r=!0}}function Bt(n,t,e){var r=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(n||(n="utf8");;)switch(n){case"hex":return Yt(this,t,e);case"utf8":case"utf-8":return Le(this,t,e);case"ascii":return qt(this,t,e);case"latin1":case"binary":return Dt(this,t,e);case"base64":return Mt(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return jt(this,t,e);default:if(r)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),r=!0}}function q(n,t,e){var r=n[t];n[t]=n[e],n[e]=r}function Be(n,t,e,r,i){if(n.length===0)return-1;if(typeof e=="string"?(r=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:n.length-1),e<0&&(e=n.length+e),e>=n.length){if(i)return-1;e=n.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,r)),F(t))return t.length===0?-1:be(n,t,e,r,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(n,t,e):Uint8Array.prototype.lastIndexOf.call(n,t,e):be(n,[t],e,r,i);throw new TypeError("val must be string, number or Buffer")}function be(n,t,e,r,i){var o=1,s=n.length,u=t.length;if(r!==void 0&&(r=String(r).toLowerCase(),r==="ucs2"||r==="ucs-2"||r==="utf16le"||r==="utf-16le")){if(n.length<2||t.length<2)return-1;o=2,s/=2,u/=2,e/=2}function c(A,I){return o===1?A[I]:A.readUInt16BE(I*o)}var m;if(i){var d=-1;for(m=e;m<s;m++)if(c(n,m)===c(t,d===-1?0:m-d)){if(d===-1&&(d=m),m-d+1===u)return d*o}else d!==-1&&(m-=m-d),d=-1}else for(e+u>s&&(e=s-u),m=e;m>=0;m--){for(var h=!0,x=0;x<u;x++)if(c(n,m+x)!==c(t,x)){h=!1;break}if(h)return m}return-1}function kt(n,t,e,r){e=Number(e)||0;var i=n.length-e;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var u=parseInt(t.substr(s*2,2),16);if(isNaN(u))return s;n[e+s]=u}return s}function Lt(n,t,e,r){return ue(oe(t,n.length-e),n,e,r)}function ke(n,t,e,r){return ue(Gt(t),n,e,r)}function _t(n,t,e,r){return ke(n,t,e,r)}function Ct(n,t,e,r){return ue(Me(t),n,e,r)}function Ut(n,t,e,r){return ue(Jt(t,n.length-e),n,e,r)}function Mt(n,t,e){return t===0&&e===n.length?Ee(n):Ee(n.slice(t,e))}function Le(n,t,e){e=Math.min(n.length,e);for(var r=[],i=t;i<e;){var o=n[i],s=null,u=o>239?4:o>223?3:o>191?2:1;if(i+u<=e){var c,m,d,h;switch(u){case 1:o<128&&(s=o);break;case 2:c=n[i+1],(c&192)===128&&(h=(o&31)<<6|c&63,h>127&&(s=h));break;case 3:c=n[i+1],m=n[i+2],(c&192)===128&&(m&192)===128&&(h=(o&15)<<12|(c&63)<<6|m&63,h>2047&&(h<55296||h>57343)&&(s=h));break;case 4:c=n[i+1],m=n[i+2],d=n[i+3],(c&192)===128&&(m&192)===128&&(d&192)===128&&(h=(o&15)<<18|(c&63)<<12|(m&63)<<6|d&63,h>65535&&h<1114112&&(s=h))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,r.push(s>>>10&1023|55296),s=56320|s&1023),r.push(s),i+=u}return Ot(r)}function Ot(n){var t=n.length;if(t<=Re)return String.fromCharCode.apply(String,n);for(var e="",r=0;r<t;)e+=String.fromCharCode.apply(String,n.slice(r,r+=Re));return e}function qt(n,t,e){var r="";e=Math.min(n.length,e);for(var i=t;i<e;++i)r+=String.fromCharCode(n[i]&127);return r}function Dt(n,t,e){var r="";e=Math.min(n.length,e);for(var i=t;i<e;++i)r+=String.fromCharCode(n[i]);return r}function Yt(n,t,e){var r=n.length;(!t||t<0)&&(t=0),(!e||e<0||e>r)&&(e=r);for(var i="",o=t;o<e;++o)i+=Ht(n[o]);return i}function jt(n,t,e){for(var r=n.slice(t,e),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+r[o+1]*256);return i}function v(n,t,e){if(n%1!==0||n<0)throw new RangeError("offset is not uint");if(n+t>e)throw new RangeError("Trying to access beyond buffer length")}function T(n,t,e,r,i,o){if(!F(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+r>n.length)throw new RangeError("Index out of range")}function se(n,t,e,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(n.length-e,2);i<o;++i)n[e+i]=(t&255<<8*(r?i:1-i))>>>(r?i:1-i)*8}function ae(n,t,e,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(n.length-e,4);i<o;++i)n[e+i]=t>>>(r?i:3-i)*8&255}function _e(n,t,e,r,i,o){if(e+r>n.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Ce(n,t,e,r,i){return i||_e(n,t,e,4,34028234663852886e22,-34028234663852886e22),qe(n,t,e,r,23,4),e+4}function Ue(n,t,e,r,i){return i||_e(n,t,e,8,17976931348623157e292,-17976931348623157e292),qe(n,t,e,r,52,8),e+8}function Wt(n){if(n=Vt(n).replace($t,""),n.length<2)return"";for(;n.length%4!==0;)n=n+"=";return n}function Vt(n){return n.trim?n.trim():n.replace(/^\s+|\s+$/g,"")}function Ht(n){return n<16?"0"+n.toString(16):n.toString(16)}function oe(n,t){t=t||1/0;for(var e,r=n.length,i=null,o=[],s=0;s<r;++s){if(e=n.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function Gt(n){for(var t=[],e=0;e<n.length;++e)t.push(n.charCodeAt(e)&255);return t}function Jt(n,t){for(var e,r,i,o=[],s=0;s<n.length&&!((t-=2)<0);++s)e=n.charCodeAt(s),r=e>>8,i=e%256,o.push(i),o.push(r);return o}function Me(n){return Et(Wt(n))}function ue(n,t,e,r){for(var i=0;i<r&&!(i+e>=t.length||i>=n.length);++i)t[i+e]=n[i];return i}function zt(n){return n!==n}function Qt(n){return n!=null&&(!!n._isBuffer||Oe(n)||Xt(n))}function Oe(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function Xt(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&Oe(n.slice(0,0))}function ce(n,t,e,r,i){var o,s,u=i*8-r-1,c=(1<<u)-1,m=c>>1,d=-7,h=e?i-1:0,x=e?-1:1,A=n[t+h];for(h+=x,o=A&(1<<-d)-1,A>>=-d,d+=u;d>0;o=o*256+n[t+h],h+=x,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=s*256+n[t+h],h+=x,d-=8);if(o===0)o=1-m;else{if(o===c)return s?NaN:(A?-1:1)*(1/0);s=s+Math.pow(2,r),o=o-m}return(A?-1:1)*s*Math.pow(2,o-r)}function qe(n,t,e,r,i,o){var s,u,c,m=o*8-i-1,d=(1<<m)-1,h=d>>1,x=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,A=r?0:o-1,I=r?1:-1,$e=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),s+h>=1?t+=x/c:t+=x*Math.pow(2,1-h),t*c>=2&&(s++,c/=2),s+h>=d?(u=0,s=d):s+h>=1?(u=(t*c-1)*Math.pow(2,i),s=s+h):(u=t*Math.pow(2,h-1)*Math.pow(2,i),s=0));i>=8;n[e+A]=u&255,A+=I,u/=256,i-=8);for(s=s<<i|u,m+=i;m>0;n[e+A]=s&255,A+=I,s/=256,m-=8);n[e+A-I]|=$e*128}var R,E,It,he,Re,$t,De=le(()=>{"use strict";p();l();R=[],E=[],It=typeof Uint8Array!="undefined"?Uint8Array:Array,he=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(n){return n.__proto__=a.prototype,n};a.from=function(n,t,e){return Ne(null,n,t,e)};a.kMaxLength=ie();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(n,t,e){return Ft(null,n,t,e)};a.allocUnsafe=function(n){return me(null,n)};a.allocUnsafeSlow=function(n){return me(null,n)};a.isBuffer=Qt;a.compare=function(t,e){if(!F(t)||!F(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,i=e.length,o=0,s=Math.min(r,i);o<s;++o)if(t[o]!==e[o]){r=t[o],i=e[o];break}return r<i?-1:i<r?1:0};a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var r;if(e===void 0)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var i=a.allocUnsafe(e),o=0;for(r=0;r<t.length;++r){var s=t[r];if(!F(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=Se;a.prototype._isBuffer=!0;a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)q(this,e,e+1);return this};a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)q(this,e,e+3),q(this,e+1,e+2);return this};a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)q(this,e,e+7),q(this,e+1,e+6),q(this,e+2,e+5),q(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Le(this,0,t):Bt.apply(this,arguments)};a.prototype.equals=function(t){if(!F(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,r,i,o){if(!F(t))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),r===void 0&&(r=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||r>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=r)return 0;if(i>=o)return-1;if(e>=r)return 1;if(e>>>=0,r>>>=0,i>>>=0,o>>>=0,this===t)return 0;for(var s=o-i,u=r-e,c=Math.min(s,u),m=this.slice(i,o),d=t.slice(e,r),h=0;h<c;++h)if(m[h]!==d[h]){s=m[h],u=d[h];break}return s<u?-1:u<s?1:0};a.prototype.includes=function(t,e,r){return this.indexOf(t,e,r)!==-1};a.prototype.indexOf=function(t,e,r){return Be(this,t,e,r,!0)};a.prototype.lastIndexOf=function(t,e,r){return Be(this,t,e,r,!1)};a.prototype.write=function(t,e,r,i){if(e===void 0)i="utf8",r=this.length,e=0;else if(r===void 0&&typeof e=="string")i=e,r=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(r)?(r=r|0,i===void 0&&(i="utf8")):(i=r,r=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((r===void 0||r>o)&&(r=o),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return kt(this,t,e,r);case"utf8":case"utf-8":return Lt(this,t,e,r);case"ascii":return ke(this,t,e,r);case"latin1":case"binary":return _t(this,t,e,r);case"base64":return Ct(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ut(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};Re=4096;a.prototype.slice=function(t,e){var r=this.length;t=~~t,e=e===void 0?r:~~e,t<0?(t+=r,t<0&&(t=0)):t>r&&(t=r),e<0?(e+=r,e<0&&(e=0)):e>r&&(e=r),e<t&&(e=t);var i;if(a.TYPED_ARRAY_SUPPORT)i=this.subarray(t,e),i.__proto__=a.prototype;else{var o=e-t;i=new a(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};a.prototype.readUIntLE=function(t,e,r){t=t|0,e=e|0,r||v(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return i};a.prototype.readUIntBE=function(t,e,r){t=t|0,e=e|0,r||v(t,e,this.length);for(var i=this[t+--e],o=1;e>0&&(o*=256);)i+=this[t+--e]*o;return i};a.prototype.readUInt8=function(t,e){return e||v(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||v(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||v(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||v(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};a.prototype.readUInt32BE=function(t,e){return e||v(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,e,r){t=t|0,e=e|0,r||v(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};a.prototype.readIntBE=function(t,e,r){t=t|0,e=e|0,r||v(t,e,this.length);for(var i=e,o=1,s=this[t+--i];i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};a.prototype.readInt8=function(t,e){return e||v(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||v(t,2,this.length);var r=this[t]|this[t+1]<<8;return r&32768?r|4294901760:r};a.prototype.readInt16BE=function(t,e){e||v(t,2,this.length);var r=this[t+1]|this[t]<<8;return r&32768?r|4294901760:r};a.prototype.readInt32LE=function(t,e){return e||v(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};a.prototype.readInt32BE=function(t,e){return e||v(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};a.prototype.readFloatLE=function(t,e){return e||v(t,4,this.length),ce(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||v(t,4,this.length),ce(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||v(t,8,this.length),ce(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||v(t,8,this.length),ce(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;T(this,t,e,r,o,0)}var s=1,u=0;for(this[e]=t&255;++u<r&&(s*=256);)this[e+u]=t/s&255;return e+r};a.prototype.writeUIntBE=function(t,e,r,i){if(t=+t,e=e|0,r=r|0,!i){var o=Math.pow(2,8*r)-1;T(this,t,e,r,o,0)}var s=r-1,u=1;for(this[e+s]=t&255;--s>=0&&(u*=256);)this[e+s]=t/u&255;return e+r};a.prototype.writeUInt8=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};a.prototype.writeUInt16LE=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):se(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):se(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):ae(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):ae(this,t,e,!1),e+4};a.prototype.writeIntLE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);T(this,t,e,r,o-1,-o)}var s=0,u=1,c=0;for(this[e]=t&255;++s<r&&(u*=256);)t<0&&c===0&&this[e+s-1]!==0&&(c=1),this[e+s]=(t/u>>0)-c&255;return e+r};a.prototype.writeIntBE=function(t,e,r,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*r-1);T(this,t,e,r,o-1,-o)}var s=r-1,u=1,c=0;for(this[e+s]=t&255;--s>=0&&(u*=256);)t<0&&c===0&&this[e+s+1]!==0&&(c=1),this[e+s]=(t/u>>0)-c&255;return e+r};a.prototype.writeInt8=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};a.prototype.writeInt16LE=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):se(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):se(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):ae(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,r){return t=+t,e=e|0,r||T(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):ae(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,r){return Ce(this,t,e,!0,r)};a.prototype.writeFloatBE=function(t,e,r){return Ce(this,t,e,!1,r)};a.prototype.writeDoubleLE=function(t,e,r){return Ue(this,t,e,!0,r)};a.prototype.writeDoubleBE=function(t,e,r){return Ue(this,t,e,!1,r)};a.prototype.copy=function(t,e,r,i){if(r||(r=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<r&&(i=r),i===r||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-r&&(i=t.length-e+r);var o=i-r,s;if(this===t&&r<e&&e<i)for(s=o-1;s>=0;--s)t[s+e]=this[s+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+e]=this[s+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o};a.prototype.fill=function(t,e,r,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,r=this.length):typeof r=="string"&&(i=r,r=this.length),t.length===1){var o=t.charCodeAt(0);o<256&&(t=o)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;e=e>>>0,r=r===void 0?this.length:r>>>0,t||(t=0);var s;if(typeof t=="number")for(s=e;s<r;++s)this[s]=t;else{var u=F(t)?t:oe(new a(t,i).toString()),c=u.length;for(s=0;s<r-e;++s)this[s+e]=u[s%c]}return this};$t=/[^+\/0-9A-Za-z-_]/g});var l=le(()=>{"use strict";De()});var fr={};we(fr,{EndpointSnippetGenerator:()=>ye});module.exports=ze(fr);p();l();p();l();p();l();function b(n){throw new Error("Unexpected value: "+JSON.stringify(n))}p();l();p();l();var D=class{};p();l();p();l();var C=class extends D{constructor(e){super();f(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):this.value(e)}};var Zt=4,K=class{constructor(){f(this,"buffer","");f(this,"indentLevel",0);f(this,"hasWrittenAnything",!1);f(this,"lastCharacterIsNewline",!1)}write(t){let e=t.length>0&&t.endsWith(`
|
|
2
|
+
`),r=e?t.substring(0,t.length-1):t,i=this.getIndentString(),o=r.replaceAll(`
|
|
3
|
+
`,`
|
|
4
|
+
${i}`);this.isAtStartOfLine()&&(o=i+o),e&&(o+=`
|
|
5
|
+
`),this.writeInternal(o)}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){t.write(this)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new C(t).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new C(t).write(this),this.write(" ("),this.writeNode(e),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}endControlFlow(){this.dedent(),this.writeLine("}")}openBlock(t,e="{",r,i="}"){let o=t.filter(s=>s!==void 0).join(" ");o?this.write(`${o} ${e!=null?e:""}`):this.write(e!=null?e:"");try{this.indent(),r(),this.dedent()}finally{this.write(i!=null?i:"")}}writeLine(t=""){this.write(t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
6
|
+
`)}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
7
|
+
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:r}){if(t.length>0){let i=t[0];i!=null&&r(i);for(let o=1;o<t.length;o++){this.write(e);let s=t[o];s!=null&&r(s)}}}toString(){return this.buffer}writeInternal(t){return t.length>0&&(this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
8
|
+
`)),this.buffer+=t}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*Zt)}};p();l();var pe=class{},ee=class extends pe{async format(t){return t}formatSync(t){return t}};p();l();p();l();var B={Critical:"CRITICAL",Warning:"WARNING"};p();l();var N={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};p();l();var g={};we(g,{AstNode:()=>w,ClassInstantiation:()=>Z,CodeBlock:()=>H,Comment:()=>U,Function:()=>z,FunctionInvocation:()=>Q,MethodInvocation:()=>X,Parameter:()=>J,Reference:()=>$,Type:()=>j,TypeLiteral:()=>k,Types:()=>j,Variable:()=>G,Writer:()=>Y,codeblock:()=>nr,function_:()=>ir,instantiateClass:()=>or,invokeFunction:()=>sr,invokeMethod:()=>ar,parameter:()=>ur,reference:()=>cr,variable:()=>pr});p();l();p();l();p();l();p();l();p();l();p();l();var Y=class extends K{constructor({customConfig:e,formatter:r}){super();f(this,"customConfig");f(this,"formatter");f(this,"imports",{});f(this,"defaultImports",{});f(this,"starImportAliases",{});f(this,"starImportAliasesInverse",{});this.customConfig=e,this.formatter=r!=null?r:new ee}addImport(e){var r,i,o;if(e.importFrom!=null){switch(e.importFrom.type){case"default":{this.validateDefault(e);break}case"named":{this.validateNamed(e);break}case"star":{this.validateStar(e);break}}let s=(o=(r=this.imports)[i=e.importFrom.moduleName])!=null?o:r[i]=[];s.map(c=>c.name).includes(e.name)||s.push(e)}}validateDefault(e){var i,o,s,u;if(((i=e.importFrom)==null?void 0:i.type)!=="default")return;let r=(u=(o=this.defaultImports)[s=e.importFrom.moduleName])!=null?u:o[s]=e;if(r.name!==e.name)throw new Error(`Cannot have multiple default imports for module ${e.importFrom.moduleName}: got ${e.name} but already had ${r.name}`)}validateNamed(e){var s,u,c,m,d;if(((s=e.importFrom)==null?void 0:s.type)!=="named")return;let i=((u=this.imports[e.importFrom.moduleName])!=null?u:[]).filter(h=>{var x;return((x=h.importFrom)==null?void 0:x.type)==="star"});if(i.length>0)throw new Error(`Cannot add named import ${e.name} because non-named imports ${i.map(h=>h.name)} already exist`);let o=[];for(let h of Object.values(this.imports))for(let x of h)((c=x.importFrom)==null?void 0:c.type)==="named"&&x.importFrom.moduleName!==e.importFrom.moduleName&&x.name===e.name&&o.push(x);if(o.length>0)throw new Error(`Cannot add named import from module ${e.importFrom.moduleName} because it is already imported from ${(d=(m=o[0])==null?void 0:m.importFrom)==null?void 0:d.moduleName}`)}validateStar(e){var o,s,u,c,m,d,h;if(((o=e.importFrom)==null?void 0:o.type)!=="star")return;let r=(c=(s=this.starImportAliases)[u=e.importFrom.moduleName])!=null?c:s[u]=e.importFrom.starImportAlias;if(r!==e.importFrom.starImportAlias)throw new Error(`Cannot have more than one alias for non-named imports from a module: got ${e.importFrom.starImportAlias} but already have ${r}.`);if(((h=(m=this.starImportAliasesInverse)[d=e.importFrom.starImportAlias])!=null?h:m[d]=e.importFrom.moduleName)!==e.importFrom.moduleName)throw new Error(`Attempted to use alias ${e.importFrom.starImportAlias} for more than one module in the same file`)}};var te=class extends Y{constructor({customConfig:t,formatter:e}){super({customConfig:t,formatter:e})}async toStringAsync(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.format(t)}catch(e){throw new Error(`Failed to format TypeScript file: ${e}
|
|
9
|
+
${t}`)}return t}toString(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(t)}catch(e){throw new Error(`Failed to format TypeScript file: ${e}
|
|
10
|
+
${t}`)}return t}getContent(){let t=this.stringifyImports();return t.length>0?t+`
|
|
11
|
+
`+this.buffer:this.buffer}stringifyImports(){let t="";for(let[e,r]of Object.entries(this.imports)){let i=this.defaultImports[e],o="",s=r.filter(c=>{var m;return((m=c.importFrom)==null?void 0:m.type)==="named"}),u=this.starImportAliases[e];if(s.length>0||i!=null||u!=null){if(t+="import",i!=null&&(t+=` ${i.name}`),s.length>0){for(let m of s.slice(0,-1))o+=`${m.name}, `;let c=s[s.length-1];c!=null&&(o+=`${c.name}`),i!=null&&(t+=","),t+=` { ${o} }`}u!=null&&((i!=null||s.length>0)&&(t+=", "),t+=` * as ${u}`),t+=` from "${e}";
|
|
12
|
+
`}}return t}};var w=class extends D{async toStringAsync({customConfig:t,formatter:e}){let r=new te({customConfig:t,formatter:e});return this.write(r),await r.toStringAsync()}toString({customConfig:t,formatter:e}){let r=new te({customConfig:t,formatter:e});return this.write(r),r.toString()}};p();l();var H=class extends w{constructor(e){super();f(this,"args");this.args=e}write(e){return new C(this.args).write(e)}};p();l();var j=class extends w{constructor(e){super();f(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"string":e.write("string");break;case"number":e.write("number");break;case"bigint":e.write("bigint");break;case"boolean":e.write("boolean");break;case"array":this.internalType.valueType.write(e),e.write("[]");break;case"map":e.write("Record<"),this.internalType.keyType.write(e),e.write(", "),this.internalType.valueType.write(e),e.write(">");break;case"object":e.write("{"),e.indent();for(let[r,i]of Object.entries(this.internalType.fields))e.write(`${r}: `),i.write(e),e.writeLine(",");e.dedent(),e.write("}");break;case"enum":e.write("enum");break;case"any":e.write("any");break;case"promise":e.write("Promise<"),this.internalType.value.write(e),e.write(">");break;case"unknown":e.write("unknown");break;case"void":e.write("void");break;case"undefined":e.write("undefined");break;case"null":e.write("null");break;case"never":e.write("never");break;case"nop":break;default:b(this.internalType)}}static string(){return new this({type:"string"})}static number(){return new this({type:"number"})}static bigint(){return new this({type:"bigint"})}static boolean(){return new this({type:"boolean"})}static array(e){return new this({type:"array",valueType:e})}static object(e){return new this({type:"object",fields:e})}static enum(e){return new this({type:"enum",values:e})}static any(){return new this({type:"any"})}static promise(e){return e.internalType.type==="promise"?e:new this({type:"promise",value:e})}static unknown(){return new this({type:"unknown"})}static void(){return new this({type:"void"})}static undefined(){return new this({type:"undefined"})}static null(){return new this({type:"null"})}static never(){return new this({type:"never"})}static nop(){return new this({type:"nop"})}};p();l();var k=class n extends w{constructor(e){super();f(this,"internalType");this.internalType=e}write(e){var o,s;let r=!!((o=e.customConfig)!=null&&o.noSerdeLayer),i=!!((s=e.customConfig)!=null&&s.useBigInt);switch(this.internalType.type){case"array":{this.writeIterable({writer:e,iterable:this.internalType});break}case"blob":{if(r){e.writeNode(n.string(this.internalType.value));return}e.write("new Blob(["),e.writeNode(n.string(this.internalType.value)),e.write("])");break}case"boolean":{e.write(this.internalType.value.toString());break}case"bigint":{if(i){e.write(`BigInt(${this.internalType.value.toString()})`);return}e.write(`"${this.internalType.value.toString()}"`);return}case"datetime":{if(r){e.writeNode(n.string(this.internalType.value));return}e.write("new Date("),e.writeNode(n.string(this.internalType.value)),e.write(")");break}case"number":{e.write(this.internalType.value.toString());break}case"object":{this.writeObject({writer:e,object:this.internalType});break}case"record":{this.writeRecord({writer:e,record:this.internalType});break}case"reference":{e.writeNode(this.internalType.value);break}case"set":{if(r||this.isSetOfObjects()){e.writeNode(n.array({values:this.internalType.values}));return}e.write("new Set("),this.writeIterable({writer:e,iterable:this.internalType}),e.write(")");break}case"string":{this.internalType.value.includes(`
|
|
13
|
+
`)?this.writeStringWithBackticks({writer:e,value:this.internalType.value}):e.write(`"${this.internalType.value.replaceAll('"','\\"')}"`);break}case"tuple":{this.writeIterable({writer:e,iterable:this.internalType});break}case"unknown":{this.writeUnknown({writer:e,value:this.internalType.value});break}case"null":{e.write("null");break}case"nop":break;default:b(this.internalType)}}isObject(){return this.internalType.type==="object"}asObjectOrThrow(){if(this.isObject())return this.internalType;throw new Error("Internal error; ts.TypeLiteral is not an object")}isSet(){return this.internalType.type==="set"}asSetOrThrow(){if(this.isSet())return this.internalType;throw new Error("Internal error; ts.TypeLiteral is not a set")}isSetOfObjects(){return this.isSet()&&this.asSetOrThrow().values.every(e=>e.isObject())}writeStringWithBackticks({writer:e,value:r}){e.write("`");let i=r.split(`
|
|
14
|
+
`),o=i[0]+`
|
|
15
|
+
`,s=i.slice(1).join(`
|
|
16
|
+
`);e.write(o.replaceAll("`","\\`")),e.writeNoIndent(s.replaceAll("`","\\`")),e.write("`")}writeIterable({writer:e,iterable:r}){let i=tr({values:r.values});if(i.length===0){e.write("[]");return}e.writeLine("["),e.indent();for(let o of i)o.write(e),e.writeLine(",");e.dedent(),e.write("]")}writeRecord({writer:e,record:r}){let i=er({entries:r.entries});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.key.write(e),e.write(": "),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeObject({writer:e,object:r}){let i=Kt({fields:r.fields});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)e.write(`${o.name}: `),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}static array({values:e}){return new this({type:"array",values:e})}static bigint(e){return new this({type:"bigint",value:e})}static blob(e){return new this({type:"blob",value:e})}static boolean(e){return new this({type:"boolean",value:e})}static datetime(e){return new this({type:"datetime",value:e})}static number(e){return new this({type:"number",value:e})}static object({fields:e}){return new this({type:"object",fields:e})}static record({entries:e}){return new this({type:"record",entries:e})}static reference(e){return new this({type:"reference",value:e})}static set({values:e}){return new this({type:"set",values:e})}static string(e){return new this({type:"string",value:e})}static tuple({values:e}){return new this({type:"tuple",values:e})}static unknown(e){return new this({type:"unknown",value:e})}static null(){return new this({type:"null"})}static nop(){return new this({type:"nop"})}static isNop(e){return e.internalType.type==="nop"}writeUnknown({writer:e,value:r}){switch(typeof r){case"boolean":e.write(r.toString());return;case"string":e.write(r.includes('"')?`\`${r}\``:`"${r}"`);return;case"number":e.write(r.toString());return;case"object":if(r==null){e.write("null");return}if(Array.isArray(r)){this.writeUnknownArray({writer:e,value:r});return}this.writeUnknownObject({writer:e,value:r});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof r}`)}}writeUnknownArray({writer:e,value:r}){if(r.length===0){e.write("[]");return}e.writeLine("["),e.indent();for(let i of r)e.writeNode(n.unknown(i)),e.writeLine(",");e.dedent(),e.write("]")}writeUnknownObject({writer:e,value:r}){let i=Object.entries(r);if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[o,s]of i)e.write(`${o}: `),e.writeNode(n.unknown(s)),e.writeLine(",");e.dedent(),e.write("}")}};function Kt({fields:n}){return n.filter(t=>!k.isNop(t.value))}function er({entries:n}){return n.filter(t=>!k.isNop(t.key)&&!k.isNop(t.value))}function tr({values:n}){return n.filter(t=>!k.isNop(t))}p();l();var $=class extends w{constructor({name:e,importFrom:r,memberName:i}){super();f(this,"name");f(this,"importFrom");f(this,"memberName");this.name=e,this.importFrom=r,this.memberName=i}write(e){var o;this.importFrom!=null&&e.addImport(this);let r=((o=this.importFrom)==null?void 0:o.type)==="star"?`${this.importFrom.starImportAlias}.`:"",i=this.memberName!=null?`.${this.memberName}`:"";e.write(`${r}${this.name}${i}`)}};p();l();var G=class extends w{constructor(e){super();f(this,"args");this.args=e}write(e){this.args.export&&e.write("export "),this.args.const?e.write("const "):e.write("let "),e.write(`${this.args.name} = `),e.writeNode(this.args.initializer)}};p();l();p();l();var U=class extends w{constructor({docs:e}={docs:void 0}){super();f(this,"docs");this.docs=e}write(e){this.docs!=null&&(e.writeLine("/**"),this.docs.split(`
|
|
17
|
+
`).forEach(r=>{e.writeLine(` * ${r}`)}),e.writeLine("*/"))}};var J=class extends w{constructor({name:e,type:r,docs:i}){super();f(this,"name");f(this,"type");f(this,"docs");this.name=e,this.type=r,this.docs=i}write(e){this.docs!=null&&e.writeNode(new U({docs:this.docs})),e.write(`${this.name}: `),this.type.write(e)}};p();l();var z=class extends w{constructor({name:e,parameters:r,async:i,body:o,return_:s,docs:u}){super();f(this,"name");f(this,"parameters");f(this,"async");f(this,"body");f(this,"return_");f(this,"docs");this.name=e,this.parameters=r,this.async=i!=null?i:!1,this.body=o,this.return_=s,this.docs=u}write(e){var r;e.writeNode(new U({docs:this.docs})),this.async&&e.write("async "),e.write("function "),e.write(`${this.name}`),this.writeParameters(e),this.return_!=null&&(e.write(": "),e.writeNode(this.async?j.promise(this.return_):this.return_)),e.writeLine(" {"),e.indent(),(r=this.body)==null||r.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.writeLine("}")}writeParameters(e){if(this.parameters.length===0){e.write("()");return}e.indent(),e.writeLine("(");for(let r of this.parameters)e.writeNode(r),e.writeLine(",");e.dedent(),e.write(")")}};p();l();var Q=class extends w{constructor({function_:e,arguments_:r}){super();f(this,"function_");f(this,"arguments_");this.function_=e,this.arguments_=r}write(e){e.writeNode(this.function_),e.write("("),e.delimit({nodes:this.arguments_,delimiter:", ",writeFunction:r=>r.write(e)}),e.write(")")}};p();l();var X=class extends w{constructor({on:e,method:r,arguments_:i,async:o}){super();f(this,"on");f(this,"method");f(this,"arguments_");f(this,"async");this.on=e,this.method=r,this.arguments_=i,this.async=o}write(e){this.async&&e.write("await "),this.on.write(e),e.write("."),e.write(this.method),e.write("("),e.delimit({nodes:this.arguments_,delimiter:", ",writeFunction:r=>r.write(e)}),e.write(")")}};p();l();var Z=class extends w{constructor({class_:e,arguments_:r}){super();f(this,"class_");f(this,"arguments_");this.class_=e,this.arguments_=r}write(e){e.write("new "),e.writeNode(this.class_),e.write("("),e.delimit({nodes:this.arguments_,delimiter:", ",writeFunction:r=>r.write(e)}),e.write(")")}};function nr(n){return new H(n)}function ir(n){return new z(n)}function or(n){return new Z(n)}function sr(n){return new Q(n)}function ar(n){return new X(n)}function ur(n){return new J(n)}function cr(n){return new $(n)}function pr(n){return new G(n)}var Ye="client",je="main",lr={type:"primitive",value:"STRING"},ye=class{constructor({context:t}){f(this,"context");this.context=t}async generateSnippet({endpoint:t,request:e}){return await this.buildCodeBlock({endpoint:t,snippet:e}).toStringAsync({customConfig:this.context.customConfig})}generateSnippetSync({endpoint:t,request:e}){return this.buildCodeBlock({endpoint:t,snippet:e}).toString({customConfig:this.context.customConfig})}buildCodeBlock({endpoint:t,snippet:e}){return g.codeblock(r=>{r.writeNode(g.function_({name:je,async:!0,parameters:[],body:g.codeblock(i=>{i.writeNodeStatement(this.constructClient({endpoint:t,snippet:e})),i.writeNodeStatement(this.callMethod({endpoint:t,snippet:e}))})})),r.writeNodeStatement(g.invokeFunction({function_:g.reference({name:je}),arguments_:[]}))})}constructClient({endpoint:t,snippet:e}){return g.variable({name:Ye,const:!0,initializer:g.instantiateClass({class_:g.reference({name:this.context.getRootClientName(),importFrom:this.context.getModuleImport()}),arguments_:[this.getConstructorArgs({endpoint:t,snippet:e})]})})}getConstructorArgs({endpoint:t,snippet:e}){let r=[],i=this.getConstructorEnvironmentArgs({baseUrl:e.baseURL,environment:e.environment});return i.length>0&&r.push(...i),t.auth!=null&&(e.auth!=null?r.push(...this.getConstructorAuthArgs({auth:t.auth,values:e.auth})):this.context.errors.add({severity:B.Warning,message:`Auth with ${t.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(N.Headers),this.context.ir.headers!=null&&e.headers!=null&&r.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:e.headers})),this.context.errors.unscope(),r.length===0?g.TypeLiteral.nop():g.TypeLiteral.object({fields:r})}getConstructorEnvironmentArgs({baseUrl:t,environment:e}){let r=this.getEnvironmentValue({baseUrl:t,environment:e});return r==null?[]:[{name:"environment",value:r}]}getEnvironmentValue({baseUrl:t,environment:e}){if(t!=null&&e!=null){this.context.errors.add({severity:B.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(t!=null)return g.TypeLiteral.string(t);if(e!=null){if(this.context.isSingleEnvironmentID(e)){let r=this.context.getEnvironmentTypeReferenceFromID(e);if(r==null){this.context.errors.add({severity:B.Warning,message:`Environment ${JSON.stringify(e)} was not found`});return}return g.TypeLiteral.reference(r)}if(this.context.isMultiEnvironmentValues(e))return this.context.validateMultiEnvironmentUrlValues(e)?g.TypeLiteral.object({fields:Object.entries(e).map(([r,i])=>({name:r,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:lr,value:i})}))}):void 0}}getConstructorAuthArgs({auth:t,values:e}){switch(t.type){case"basic":return e.type!=="basic"?(this.context.errors.add({severity:B.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getConstructorBasicAuthArg({auth:t,values:e});case"bearer":return e.type!=="bearer"?(this.context.errors.add({severity:B.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getConstructorBearerAuthArgs({auth:t,values:e});case"header":return e.type!=="header"?(this.context.errors.add({severity:B.Critical,message:this.context.newAuthMismatchError({auth:t,values:e}).message}),[]):this.getConstructorHeaderAuthArgs({auth:t,values:e});default:b(t)}}getConstructorBasicAuthArg({auth:t,values:e}){return[{name:this.context.getPropertyName(t.username),value:g.TypeLiteral.string(e.username)},{name:this.context.getPropertyName(t.password),value:g.TypeLiteral.string(e.password)}]}getConstructorBearerAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.token),value:g.TypeLiteral.string(e.token)}]}getConstructorHeaderAuthArgs({auth:t,values:e}){return[{name:this.context.getPropertyName(t.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:t.header.typeReference,value:e.value})}]}getConstructorHeaderArgs({headers:t,values:e}){let r=[];for(let i of t){let o=this.getConstructorHeaderArg({header:i,value:e.value});o!=null&&r.push(o)}return r}getConstructorHeaderArg({header:t,value:e}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:e});if(!g.TypeLiteral.isNop(r))return{name:this.context.getPropertyName(t.name.name),value:r}}callMethod({endpoint:t,snippet:e}){return g.invokeMethod({on:g.reference({name:Ye}),method:this.getMethod({endpoint:t}),async:!0,arguments_:this.getMethodArgs({endpoint:t,snippet:e})})}getMethodArgs({endpoint:t,snippet:e}){switch(t.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:t.request,snippet:e});case"body":return this.getMethodArgsForBodyRequest({request:t.request,snippet:e});default:b(t.request)}}getMethodArgsForBodyRequest({request:t,snippet:e}){let r=[];if(this.context.errors.scope(N.PathParameters),t.pathParameters!=null){let i=this.getPathParameters({namedParameters:t.pathParameters,snippet:e});r.push(...i.map(o=>o.value))}return this.context.errors.unscope(),this.context.errors.scope(N.RequestBody),t.body!=null&&r.push(this.getBodyRequestArg({body:t.body,value:e.requestBody})),this.context.errors.unscope(),r}getBodyRequestArg({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:t.value,value:e});default:b(t)}}getBytesBodyRequestArg({value:t}){return typeof t!="string"?(this.context.errors.add({severity:B.Critical,message:`Expected bytes value to be a string, got ${typeof t}`}),g.TypeLiteral.nop()):g.TypeLiteral.blob(t)}getMethodArgsForInlinedRequest({request:t,snippet:e}){var c,m,d,h;let r=[],{inlinePathParameters:i,inlineFileProperties:o}={inlinePathParameters:(m=(c=this.context.customConfig)==null?void 0:c.inlinePathParameters)!=null?m:!1,inlineFileProperties:(h=(d=this.context.customConfig)==null?void 0:d.inlineFileProperties)!=null?h:!1};this.context.errors.scope(N.PathParameters);let s=[];t.pathParameters!=null&&s.push(...this.getPathParameters({namedParameters:t.pathParameters,snippet:e})),this.context.errors.unscope(),this.context.errors.scope(N.RequestBody);let u=this.getFilePropertyInfo({request:t,snippet:e});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})||r.push(...s.map(x=>x.value)),o||r.push(...u.fileFields.map(x=>x.value)),this.context.needsRequestParameter({request:t,inlinePathParameters:i,inlineFileProperties:o})&&r.push(this.getInlinedRequestArg({request:t,snippet:e,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:t,inlinePathParameters:i})?s:[],filePropertyInfo:u})),r}getFilePropertyInfo({request:t,snippet:e}){return t.body==null||!this.context.isFileUploadRequestBody(t.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:t.body,value:e.requestBody})}getInlinedRequestArg({request:t,snippet:e,pathParameterFields:r,filePropertyInfo:i}){var d,h,x,A;this.context.errors.scope(N.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(d=t.queryParameters)!=null?d:[],values:(h=e.queryParameters)!=null?h:{}}).map(I=>({name:this.context.getPropertyName(I.name.name),value:this.context.dynamicTypeLiteralMapper.convert(I)}));this.context.errors.unscope(),this.context.errors.scope(N.Headers);let c=this.context.associateByWireValue({parameters:(x=t.headers)!=null?x:[],values:(A=e.headers)!=null?A:{}}).map(I=>({name:this.context.getPropertyName(I.name.name),value:this.context.dynamicTypeLiteralMapper.convert(I)}));this.context.errors.unscope(),this.context.errors.scope(N.RequestBody);let m=t.body!=null?this.getInlinedRequestBodyObjectFields({body:t.body,value:e.requestBody,filePropertyInfo:i}):[];return this.context.errors.unscope(),g.TypeLiteral.object({fields:[...r,...s,...c,...m]})}getInlinedRequestBodyObjectFields({body:t,value:e,filePropertyInfo:r}){switch(t.type){case"properties":return this.getInlinedRequestBodyPropertyObjectFields({parameters:t.value,value:e});case"referenced":return[this.getReferencedRequestBodyPropertyObjectField({body:t,value:e})];case"fileUpload":return this.getFileUploadRequestBodyObjectFields({filePropertyInfo:r});default:b(t)}}getFileUploadRequestBodyObjectFields({filePropertyInfo:t}){var e;return(e=this.context.customConfig)!=null&&e.inlineFileProperties?[...t.fileFields,...t.bodyPropertyFields]:t.bodyPropertyFields}getReferencedRequestBodyPropertyObjectField({body:t,value:e}){return{name:this.context.getPropertyName(t.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:t.bodyType,value:e})}}getReferencedRequestBodyPropertyTypeLiteral({body:t,value:e}){switch(t.type){case"bytes":return this.getBytesBodyRequestArg({value:e});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:t.value,value:e});default:b(t)}}getInlinedRequestBodyPropertyObjectFields({parameters:t,value:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t,values:(o=this.context.getRecord(e))!=null?o:{}});for(let s of i)r.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return r}getPathParameters({namedParameters:t,snippet:e}){var o;let r=[],i=this.context.associateByWireValue({parameters:t,values:(o=e.pathParameters)!=null?o:{}});for(let s of i)r.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return r}getMethod({endpoint:t}){return t.declaration.fernFilepath.allParts.length>0?`${t.declaration.fernFilepath.allParts.map(e=>this.context.getMethodName(e)).join(".")}.${this.context.getMethodName(t.declaration.name)}`:this.context.getMethodName(t.declaration.name)}};0&&(module.exports={EndpointSnippetGenerator});
|
|
3488
18
|
/*! Bundled license information:
|
|
3489
19
|
|
|
3490
20
|
@esbuild-plugins/node-globals-polyfill/Buffer.js:
|