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