@kubb/agent 4.29.1 → 4.31.0
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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +505 -339
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +3 -1
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +3 -1
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +6 -3
- package/.output/server/node_modules/@kubb/fabric-core/dist/{onProcessExit-CF200hsz.js → onProcessExit-B0rJqX4s.js} +7 -1
- package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +1 -1
- package/.output/server/node_modules/@kubb/fabric-core/package.json +1 -1
- package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +1 -1
- package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +1 -1
- package/.output/server/node_modules/@kubb/react-fabric/dist/{reactPlugin-BkDkx1cs.js → reactPlugin-tE73eBS_.js} +5 -1
- package/.output/server/node_modules/@kubb/react-fabric/package.json +2 -2
- package/.output/server/node_modules/@logtail/core/dist/cjs/base.js +339 -0
- package/.output/server/node_modules/@logtail/core/dist/cjs/index.js +9 -0
- package/.output/server/node_modules/@logtail/core/package.json +45 -0
- package/.output/server/node_modules/@logtail/node/dist/cjs/context.js +93 -0
- package/.output/server/node_modules/@logtail/node/dist/cjs/index.js +6 -0
- package/.output/server/node_modules/@logtail/node/dist/cjs/node.js +106 -0
- package/.output/server/node_modules/@logtail/node/package.json +53 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/batch.js +122 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/burstProtection.js +50 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/encode.js +12 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/index.js +41 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/queue.js +41 -0
- package/.output/server/node_modules/@logtail/tools/dist/cjs/throttle.js +67 -0
- package/.output/server/node_modules/@logtail/tools/package.json +39 -0
- package/.output/server/node_modules/@logtail/types/dist/cjs/types.js +21 -0
- package/.output/server/node_modules/@logtail/types/package.json +45 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/CachedKeyDecoder.js +63 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/DecodeError.js +18 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/Decoder.js +583 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/Encoder.js +408 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/ExtData.js +14 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/ExtensionCodec.js +72 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/decode.js +32 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/decodeAsync.js +44 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/encode.js +17 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/index.js +34 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/timestamp.js +104 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/utils/int.js +34 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/utils/prettyByte.js +8 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/utils/stream.js +40 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/utils/typedArrays.js +28 -0
- package/.output/server/node_modules/@msgpack/msgpack/dist/utils/utf8.js +167 -0
- package/.output/server/node_modules/@msgpack/msgpack/package.json +100 -0
- package/.output/server/node_modules/consola/dist/chunks/prompt.mjs +280 -0
- package/.output/server/node_modules/consola/dist/core.mjs +512 -0
- package/.output/server/node_modules/consola/dist/index.mjs +651 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/.output/server/node_modules/consola/package.json +136 -0
- package/.output/server/node_modules/serialize-error/index.js +154 -0
- package/.output/server/node_modules/serialize-error/package.json +41 -0
- package/.output/server/node_modules/stack-trace/lib/stack-trace.js +136 -0
- package/.output/server/node_modules/stack-trace/package.json +21 -0
- package/.output/server/package.json +11 -3
- package/README.md +3 -3
- package/package.json +23 -18
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Encoder = exports.DEFAULT_INITIAL_BUFFER_SIZE = exports.DEFAULT_MAX_DEPTH = void 0;
|
|
4
|
+
const utf8_1 = require("./utils/utf8");
|
|
5
|
+
const ExtensionCodec_1 = require("./ExtensionCodec");
|
|
6
|
+
const int_1 = require("./utils/int");
|
|
7
|
+
const typedArrays_1 = require("./utils/typedArrays");
|
|
8
|
+
exports.DEFAULT_MAX_DEPTH = 100;
|
|
9
|
+
exports.DEFAULT_INITIAL_BUFFER_SIZE = 2048;
|
|
10
|
+
class Encoder {
|
|
11
|
+
constructor(extensionCodec = ExtensionCodec_1.ExtensionCodec.defaultCodec, context = undefined, maxDepth = exports.DEFAULT_MAX_DEPTH, initialBufferSize = exports.DEFAULT_INITIAL_BUFFER_SIZE, sortKeys = false, forceFloat32 = false, ignoreUndefined = false, forceIntegerToFloat = false) {
|
|
12
|
+
this.extensionCodec = extensionCodec;
|
|
13
|
+
this.context = context;
|
|
14
|
+
this.maxDepth = maxDepth;
|
|
15
|
+
this.initialBufferSize = initialBufferSize;
|
|
16
|
+
this.sortKeys = sortKeys;
|
|
17
|
+
this.forceFloat32 = forceFloat32;
|
|
18
|
+
this.ignoreUndefined = ignoreUndefined;
|
|
19
|
+
this.forceIntegerToFloat = forceIntegerToFloat;
|
|
20
|
+
this.pos = 0;
|
|
21
|
+
this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
|
|
22
|
+
this.bytes = new Uint8Array(this.view.buffer);
|
|
23
|
+
}
|
|
24
|
+
reinitializeState() {
|
|
25
|
+
this.pos = 0;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* This is almost equivalent to {@link Encoder#encode}, but it returns an reference of the encoder's internal buffer and thus much faster than {@link Encoder#encode}.
|
|
29
|
+
*
|
|
30
|
+
* @returns Encodes the object and returns a shared reference the encoder's internal buffer.
|
|
31
|
+
*/
|
|
32
|
+
encodeSharedRef(object) {
|
|
33
|
+
this.reinitializeState();
|
|
34
|
+
this.doEncode(object, 1);
|
|
35
|
+
return this.bytes.subarray(0, this.pos);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @returns Encodes the object and returns a copy of the encoder's internal buffer.
|
|
39
|
+
*/
|
|
40
|
+
encode(object) {
|
|
41
|
+
this.reinitializeState();
|
|
42
|
+
this.doEncode(object, 1);
|
|
43
|
+
return this.bytes.slice(0, this.pos);
|
|
44
|
+
}
|
|
45
|
+
doEncode(object, depth) {
|
|
46
|
+
if (depth > this.maxDepth) {
|
|
47
|
+
throw new Error(`Too deep objects in depth ${depth}`);
|
|
48
|
+
}
|
|
49
|
+
if (object == null) {
|
|
50
|
+
this.encodeNil();
|
|
51
|
+
}
|
|
52
|
+
else if (typeof object === "boolean") {
|
|
53
|
+
this.encodeBoolean(object);
|
|
54
|
+
}
|
|
55
|
+
else if (typeof object === "number") {
|
|
56
|
+
this.encodeNumber(object);
|
|
57
|
+
}
|
|
58
|
+
else if (typeof object === "string") {
|
|
59
|
+
this.encodeString(object);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.encodeObject(object, depth);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
ensureBufferSizeToWrite(sizeToWrite) {
|
|
66
|
+
const requiredSize = this.pos + sizeToWrite;
|
|
67
|
+
if (this.view.byteLength < requiredSize) {
|
|
68
|
+
this.resizeBuffer(requiredSize * 2);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
resizeBuffer(newSize) {
|
|
72
|
+
const newBuffer = new ArrayBuffer(newSize);
|
|
73
|
+
const newBytes = new Uint8Array(newBuffer);
|
|
74
|
+
const newView = new DataView(newBuffer);
|
|
75
|
+
newBytes.set(this.bytes);
|
|
76
|
+
this.view = newView;
|
|
77
|
+
this.bytes = newBytes;
|
|
78
|
+
}
|
|
79
|
+
encodeNil() {
|
|
80
|
+
this.writeU8(0xc0);
|
|
81
|
+
}
|
|
82
|
+
encodeBoolean(object) {
|
|
83
|
+
if (object === false) {
|
|
84
|
+
this.writeU8(0xc2);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
this.writeU8(0xc3);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
encodeNumber(object) {
|
|
91
|
+
if (Number.isSafeInteger(object) && !this.forceIntegerToFloat) {
|
|
92
|
+
if (object >= 0) {
|
|
93
|
+
if (object < 0x80) {
|
|
94
|
+
// positive fixint
|
|
95
|
+
this.writeU8(object);
|
|
96
|
+
}
|
|
97
|
+
else if (object < 0x100) {
|
|
98
|
+
// uint 8
|
|
99
|
+
this.writeU8(0xcc);
|
|
100
|
+
this.writeU8(object);
|
|
101
|
+
}
|
|
102
|
+
else if (object < 0x10000) {
|
|
103
|
+
// uint 16
|
|
104
|
+
this.writeU8(0xcd);
|
|
105
|
+
this.writeU16(object);
|
|
106
|
+
}
|
|
107
|
+
else if (object < 0x100000000) {
|
|
108
|
+
// uint 32
|
|
109
|
+
this.writeU8(0xce);
|
|
110
|
+
this.writeU32(object);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// uint 64
|
|
114
|
+
this.writeU8(0xcf);
|
|
115
|
+
this.writeU64(object);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
if (object >= -0x20) {
|
|
120
|
+
// negative fixint
|
|
121
|
+
this.writeU8(0xe0 | (object + 0x20));
|
|
122
|
+
}
|
|
123
|
+
else if (object >= -0x80) {
|
|
124
|
+
// int 8
|
|
125
|
+
this.writeU8(0xd0);
|
|
126
|
+
this.writeI8(object);
|
|
127
|
+
}
|
|
128
|
+
else if (object >= -0x8000) {
|
|
129
|
+
// int 16
|
|
130
|
+
this.writeU8(0xd1);
|
|
131
|
+
this.writeI16(object);
|
|
132
|
+
}
|
|
133
|
+
else if (object >= -0x80000000) {
|
|
134
|
+
// int 32
|
|
135
|
+
this.writeU8(0xd2);
|
|
136
|
+
this.writeI32(object);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// int 64
|
|
140
|
+
this.writeU8(0xd3);
|
|
141
|
+
this.writeI64(object);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
// non-integer numbers
|
|
147
|
+
if (this.forceFloat32) {
|
|
148
|
+
// float 32
|
|
149
|
+
this.writeU8(0xca);
|
|
150
|
+
this.writeF32(object);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// float 64
|
|
154
|
+
this.writeU8(0xcb);
|
|
155
|
+
this.writeF64(object);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
writeStringHeader(byteLength) {
|
|
160
|
+
if (byteLength < 32) {
|
|
161
|
+
// fixstr
|
|
162
|
+
this.writeU8(0xa0 + byteLength);
|
|
163
|
+
}
|
|
164
|
+
else if (byteLength < 0x100) {
|
|
165
|
+
// str 8
|
|
166
|
+
this.writeU8(0xd9);
|
|
167
|
+
this.writeU8(byteLength);
|
|
168
|
+
}
|
|
169
|
+
else if (byteLength < 0x10000) {
|
|
170
|
+
// str 16
|
|
171
|
+
this.writeU8(0xda);
|
|
172
|
+
this.writeU16(byteLength);
|
|
173
|
+
}
|
|
174
|
+
else if (byteLength < 0x100000000) {
|
|
175
|
+
// str 32
|
|
176
|
+
this.writeU8(0xdb);
|
|
177
|
+
this.writeU32(byteLength);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
throw new Error(`Too long string: ${byteLength} bytes in UTF-8`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
encodeString(object) {
|
|
184
|
+
const maxHeaderSize = 1 + 4;
|
|
185
|
+
const strLength = object.length;
|
|
186
|
+
if (strLength > utf8_1.TEXT_ENCODER_THRESHOLD) {
|
|
187
|
+
const byteLength = (0, utf8_1.utf8Count)(object);
|
|
188
|
+
this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
|
|
189
|
+
this.writeStringHeader(byteLength);
|
|
190
|
+
(0, utf8_1.utf8EncodeTE)(object, this.bytes, this.pos);
|
|
191
|
+
this.pos += byteLength;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
const byteLength = (0, utf8_1.utf8Count)(object);
|
|
195
|
+
this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
|
|
196
|
+
this.writeStringHeader(byteLength);
|
|
197
|
+
(0, utf8_1.utf8EncodeJs)(object, this.bytes, this.pos);
|
|
198
|
+
this.pos += byteLength;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
encodeObject(object, depth) {
|
|
202
|
+
// try to encode objects with custom codec first of non-primitives
|
|
203
|
+
const ext = this.extensionCodec.tryToEncode(object, this.context);
|
|
204
|
+
if (ext != null) {
|
|
205
|
+
this.encodeExtension(ext);
|
|
206
|
+
}
|
|
207
|
+
else if (Array.isArray(object)) {
|
|
208
|
+
this.encodeArray(object, depth);
|
|
209
|
+
}
|
|
210
|
+
else if (ArrayBuffer.isView(object)) {
|
|
211
|
+
this.encodeBinary(object);
|
|
212
|
+
}
|
|
213
|
+
else if (typeof object === "object") {
|
|
214
|
+
this.encodeMap(object, depth);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// symbol, function and other special object come here unless extensionCodec handles them.
|
|
218
|
+
throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(object)}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
encodeBinary(object) {
|
|
222
|
+
const size = object.byteLength;
|
|
223
|
+
if (size < 0x100) {
|
|
224
|
+
// bin 8
|
|
225
|
+
this.writeU8(0xc4);
|
|
226
|
+
this.writeU8(size);
|
|
227
|
+
}
|
|
228
|
+
else if (size < 0x10000) {
|
|
229
|
+
// bin 16
|
|
230
|
+
this.writeU8(0xc5);
|
|
231
|
+
this.writeU16(size);
|
|
232
|
+
}
|
|
233
|
+
else if (size < 0x100000000) {
|
|
234
|
+
// bin 32
|
|
235
|
+
this.writeU8(0xc6);
|
|
236
|
+
this.writeU32(size);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
throw new Error(`Too large binary: ${size}`);
|
|
240
|
+
}
|
|
241
|
+
const bytes = (0, typedArrays_1.ensureUint8Array)(object);
|
|
242
|
+
this.writeU8a(bytes);
|
|
243
|
+
}
|
|
244
|
+
encodeArray(object, depth) {
|
|
245
|
+
const size = object.length;
|
|
246
|
+
if (size < 16) {
|
|
247
|
+
// fixarray
|
|
248
|
+
this.writeU8(0x90 + size);
|
|
249
|
+
}
|
|
250
|
+
else if (size < 0x10000) {
|
|
251
|
+
// array 16
|
|
252
|
+
this.writeU8(0xdc);
|
|
253
|
+
this.writeU16(size);
|
|
254
|
+
}
|
|
255
|
+
else if (size < 0x100000000) {
|
|
256
|
+
// array 32
|
|
257
|
+
this.writeU8(0xdd);
|
|
258
|
+
this.writeU32(size);
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
throw new Error(`Too large array: ${size}`);
|
|
262
|
+
}
|
|
263
|
+
for (const item of object) {
|
|
264
|
+
this.doEncode(item, depth + 1);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
countWithoutUndefined(object, keys) {
|
|
268
|
+
let count = 0;
|
|
269
|
+
for (const key of keys) {
|
|
270
|
+
if (object[key] !== undefined) {
|
|
271
|
+
count++;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return count;
|
|
275
|
+
}
|
|
276
|
+
encodeMap(object, depth) {
|
|
277
|
+
const keys = Object.keys(object);
|
|
278
|
+
if (this.sortKeys) {
|
|
279
|
+
keys.sort();
|
|
280
|
+
}
|
|
281
|
+
const size = this.ignoreUndefined ? this.countWithoutUndefined(object, keys) : keys.length;
|
|
282
|
+
if (size < 16) {
|
|
283
|
+
// fixmap
|
|
284
|
+
this.writeU8(0x80 + size);
|
|
285
|
+
}
|
|
286
|
+
else if (size < 0x10000) {
|
|
287
|
+
// map 16
|
|
288
|
+
this.writeU8(0xde);
|
|
289
|
+
this.writeU16(size);
|
|
290
|
+
}
|
|
291
|
+
else if (size < 0x100000000) {
|
|
292
|
+
// map 32
|
|
293
|
+
this.writeU8(0xdf);
|
|
294
|
+
this.writeU32(size);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
throw new Error(`Too large map object: ${size}`);
|
|
298
|
+
}
|
|
299
|
+
for (const key of keys) {
|
|
300
|
+
const value = object[key];
|
|
301
|
+
if (!(this.ignoreUndefined && value === undefined)) {
|
|
302
|
+
this.encodeString(key);
|
|
303
|
+
this.doEncode(value, depth + 1);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
encodeExtension(ext) {
|
|
308
|
+
const size = ext.data.length;
|
|
309
|
+
if (size === 1) {
|
|
310
|
+
// fixext 1
|
|
311
|
+
this.writeU8(0xd4);
|
|
312
|
+
}
|
|
313
|
+
else if (size === 2) {
|
|
314
|
+
// fixext 2
|
|
315
|
+
this.writeU8(0xd5);
|
|
316
|
+
}
|
|
317
|
+
else if (size === 4) {
|
|
318
|
+
// fixext 4
|
|
319
|
+
this.writeU8(0xd6);
|
|
320
|
+
}
|
|
321
|
+
else if (size === 8) {
|
|
322
|
+
// fixext 8
|
|
323
|
+
this.writeU8(0xd7);
|
|
324
|
+
}
|
|
325
|
+
else if (size === 16) {
|
|
326
|
+
// fixext 16
|
|
327
|
+
this.writeU8(0xd8);
|
|
328
|
+
}
|
|
329
|
+
else if (size < 0x100) {
|
|
330
|
+
// ext 8
|
|
331
|
+
this.writeU8(0xc7);
|
|
332
|
+
this.writeU8(size);
|
|
333
|
+
}
|
|
334
|
+
else if (size < 0x10000) {
|
|
335
|
+
// ext 16
|
|
336
|
+
this.writeU8(0xc8);
|
|
337
|
+
this.writeU16(size);
|
|
338
|
+
}
|
|
339
|
+
else if (size < 0x100000000) {
|
|
340
|
+
// ext 32
|
|
341
|
+
this.writeU8(0xc9);
|
|
342
|
+
this.writeU32(size);
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
throw new Error(`Too large extension object: ${size}`);
|
|
346
|
+
}
|
|
347
|
+
this.writeI8(ext.type);
|
|
348
|
+
this.writeU8a(ext.data);
|
|
349
|
+
}
|
|
350
|
+
writeU8(value) {
|
|
351
|
+
this.ensureBufferSizeToWrite(1);
|
|
352
|
+
this.view.setUint8(this.pos, value);
|
|
353
|
+
this.pos++;
|
|
354
|
+
}
|
|
355
|
+
writeU8a(values) {
|
|
356
|
+
const size = values.length;
|
|
357
|
+
this.ensureBufferSizeToWrite(size);
|
|
358
|
+
this.bytes.set(values, this.pos);
|
|
359
|
+
this.pos += size;
|
|
360
|
+
}
|
|
361
|
+
writeI8(value) {
|
|
362
|
+
this.ensureBufferSizeToWrite(1);
|
|
363
|
+
this.view.setInt8(this.pos, value);
|
|
364
|
+
this.pos++;
|
|
365
|
+
}
|
|
366
|
+
writeU16(value) {
|
|
367
|
+
this.ensureBufferSizeToWrite(2);
|
|
368
|
+
this.view.setUint16(this.pos, value);
|
|
369
|
+
this.pos += 2;
|
|
370
|
+
}
|
|
371
|
+
writeI16(value) {
|
|
372
|
+
this.ensureBufferSizeToWrite(2);
|
|
373
|
+
this.view.setInt16(this.pos, value);
|
|
374
|
+
this.pos += 2;
|
|
375
|
+
}
|
|
376
|
+
writeU32(value) {
|
|
377
|
+
this.ensureBufferSizeToWrite(4);
|
|
378
|
+
this.view.setUint32(this.pos, value);
|
|
379
|
+
this.pos += 4;
|
|
380
|
+
}
|
|
381
|
+
writeI32(value) {
|
|
382
|
+
this.ensureBufferSizeToWrite(4);
|
|
383
|
+
this.view.setInt32(this.pos, value);
|
|
384
|
+
this.pos += 4;
|
|
385
|
+
}
|
|
386
|
+
writeF32(value) {
|
|
387
|
+
this.ensureBufferSizeToWrite(4);
|
|
388
|
+
this.view.setFloat32(this.pos, value);
|
|
389
|
+
this.pos += 4;
|
|
390
|
+
}
|
|
391
|
+
writeF64(value) {
|
|
392
|
+
this.ensureBufferSizeToWrite(8);
|
|
393
|
+
this.view.setFloat64(this.pos, value);
|
|
394
|
+
this.pos += 8;
|
|
395
|
+
}
|
|
396
|
+
writeU64(value) {
|
|
397
|
+
this.ensureBufferSizeToWrite(8);
|
|
398
|
+
(0, int_1.setUint64)(this.view, this.pos, value);
|
|
399
|
+
this.pos += 8;
|
|
400
|
+
}
|
|
401
|
+
writeI64(value) {
|
|
402
|
+
this.ensureBufferSizeToWrite(8);
|
|
403
|
+
(0, int_1.setInt64)(this.view, this.pos, value);
|
|
404
|
+
this.pos += 8;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
exports.Encoder = Encoder;
|
|
408
|
+
//# sourceMappingURL=Encoder.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtData = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ExtData is used to handle Extension Types that are not registered to ExtensionCodec.
|
|
6
|
+
*/
|
|
7
|
+
class ExtData {
|
|
8
|
+
constructor(type, data) {
|
|
9
|
+
this.type = type;
|
|
10
|
+
this.data = data;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.ExtData = ExtData;
|
|
14
|
+
//# sourceMappingURL=ExtData.js.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ExtensionCodec to handle MessagePack extensions
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.ExtensionCodec = void 0;
|
|
5
|
+
const ExtData_1 = require("./ExtData");
|
|
6
|
+
const timestamp_1 = require("./timestamp");
|
|
7
|
+
class ExtensionCodec {
|
|
8
|
+
constructor() {
|
|
9
|
+
// built-in extensions
|
|
10
|
+
this.builtInEncoders = [];
|
|
11
|
+
this.builtInDecoders = [];
|
|
12
|
+
// custom extensions
|
|
13
|
+
this.encoders = [];
|
|
14
|
+
this.decoders = [];
|
|
15
|
+
this.register(timestamp_1.timestampExtension);
|
|
16
|
+
}
|
|
17
|
+
register({ type, encode, decode, }) {
|
|
18
|
+
if (type >= 0) {
|
|
19
|
+
// custom extensions
|
|
20
|
+
this.encoders[type] = encode;
|
|
21
|
+
this.decoders[type] = decode;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// built-in extensions
|
|
25
|
+
const index = 1 + type;
|
|
26
|
+
this.builtInEncoders[index] = encode;
|
|
27
|
+
this.builtInDecoders[index] = decode;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
tryToEncode(object, context) {
|
|
31
|
+
// built-in extensions
|
|
32
|
+
for (let i = 0; i < this.builtInEncoders.length; i++) {
|
|
33
|
+
const encodeExt = this.builtInEncoders[i];
|
|
34
|
+
if (encodeExt != null) {
|
|
35
|
+
const data = encodeExt(object, context);
|
|
36
|
+
if (data != null) {
|
|
37
|
+
const type = -1 - i;
|
|
38
|
+
return new ExtData_1.ExtData(type, data);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// custom extensions
|
|
43
|
+
for (let i = 0; i < this.encoders.length; i++) {
|
|
44
|
+
const encodeExt = this.encoders[i];
|
|
45
|
+
if (encodeExt != null) {
|
|
46
|
+
const data = encodeExt(object, context);
|
|
47
|
+
if (data != null) {
|
|
48
|
+
const type = i;
|
|
49
|
+
return new ExtData_1.ExtData(type, data);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (object instanceof ExtData_1.ExtData) {
|
|
54
|
+
// to keep ExtData as is
|
|
55
|
+
return object;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
decode(data, type, context) {
|
|
60
|
+
const decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
|
|
61
|
+
if (decodeExt) {
|
|
62
|
+
return decodeExt(data, type, context);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// decode() does not fail, returns ExtData instead.
|
|
66
|
+
return new ExtData_1.ExtData(type, data);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.ExtensionCodec = ExtensionCodec;
|
|
71
|
+
ExtensionCodec.defaultCodec = new ExtensionCodec();
|
|
72
|
+
//# sourceMappingURL=ExtensionCodec.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeMulti = exports.decode = exports.defaultDecodeOptions = void 0;
|
|
4
|
+
const Decoder_1 = require("./Decoder");
|
|
5
|
+
exports.defaultDecodeOptions = {};
|
|
6
|
+
/**
|
|
7
|
+
* It decodes a single MessagePack object in a buffer.
|
|
8
|
+
*
|
|
9
|
+
* This is a synchronous decoding function.
|
|
10
|
+
* See other variants for asynchronous decoding: {@link decodeAsync()}, {@link decodeStream()}, or {@link decodeArrayStream()}.
|
|
11
|
+
*
|
|
12
|
+
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
|
13
|
+
* @throws {@link DecodeError} if the buffer contains invalid data.
|
|
14
|
+
*/
|
|
15
|
+
function decode(buffer, options = exports.defaultDecodeOptions) {
|
|
16
|
+
const decoder = new Decoder_1.Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
|
|
17
|
+
return decoder.decode(buffer);
|
|
18
|
+
}
|
|
19
|
+
exports.decode = decode;
|
|
20
|
+
/**
|
|
21
|
+
* It decodes multiple MessagePack objects in a buffer.
|
|
22
|
+
* This is corresponding to {@link decodeMultiStream()}.
|
|
23
|
+
*
|
|
24
|
+
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
|
25
|
+
* @throws {@link DecodeError} if the buffer contains invalid data.
|
|
26
|
+
*/
|
|
27
|
+
function decodeMulti(buffer, options = exports.defaultDecodeOptions) {
|
|
28
|
+
const decoder = new Decoder_1.Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
|
|
29
|
+
return decoder.decodeMulti(buffer);
|
|
30
|
+
}
|
|
31
|
+
exports.decodeMulti = decodeMulti;
|
|
32
|
+
//# sourceMappingURL=decode.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeStream = exports.decodeMultiStream = exports.decodeArrayStream = exports.decodeAsync = void 0;
|
|
4
|
+
const Decoder_1 = require("./Decoder");
|
|
5
|
+
const stream_1 = require("./utils/stream");
|
|
6
|
+
const decode_1 = require("./decode");
|
|
7
|
+
/**
|
|
8
|
+
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
|
9
|
+
* @throws {@link DecodeError} if the buffer contains invalid data.
|
|
10
|
+
*/
|
|
11
|
+
async function decodeAsync(streamLike, options = decode_1.defaultDecodeOptions) {
|
|
12
|
+
const stream = (0, stream_1.ensureAsyncIterable)(streamLike);
|
|
13
|
+
const decoder = new Decoder_1.Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
|
|
14
|
+
return decoder.decodeAsync(stream);
|
|
15
|
+
}
|
|
16
|
+
exports.decodeAsync = decodeAsync;
|
|
17
|
+
/**
|
|
18
|
+
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
|
19
|
+
* @throws {@link DecodeError} if the buffer contains invalid data.
|
|
20
|
+
*/
|
|
21
|
+
function decodeArrayStream(streamLike, options = decode_1.defaultDecodeOptions) {
|
|
22
|
+
const stream = (0, stream_1.ensureAsyncIterable)(streamLike);
|
|
23
|
+
const decoder = new Decoder_1.Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
|
|
24
|
+
return decoder.decodeArrayStream(stream);
|
|
25
|
+
}
|
|
26
|
+
exports.decodeArrayStream = decodeArrayStream;
|
|
27
|
+
/**
|
|
28
|
+
* @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
|
|
29
|
+
* @throws {@link DecodeError} if the buffer contains invalid data.
|
|
30
|
+
*/
|
|
31
|
+
function decodeMultiStream(streamLike, options = decode_1.defaultDecodeOptions) {
|
|
32
|
+
const stream = (0, stream_1.ensureAsyncIterable)(streamLike);
|
|
33
|
+
const decoder = new Decoder_1.Decoder(options.extensionCodec, options.context, options.maxStrLength, options.maxBinLength, options.maxArrayLength, options.maxMapLength, options.maxExtLength);
|
|
34
|
+
return decoder.decodeStream(stream);
|
|
35
|
+
}
|
|
36
|
+
exports.decodeMultiStream = decodeMultiStream;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Use {@link decodeMultiStream()} instead.
|
|
39
|
+
*/
|
|
40
|
+
function decodeStream(streamLike, options = decode_1.defaultDecodeOptions) {
|
|
41
|
+
return decodeMultiStream(streamLike, options);
|
|
42
|
+
}
|
|
43
|
+
exports.decodeStream = decodeStream;
|
|
44
|
+
//# sourceMappingURL=decodeAsync.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encode = void 0;
|
|
4
|
+
const Encoder_1 = require("./Encoder");
|
|
5
|
+
const defaultEncodeOptions = {};
|
|
6
|
+
/**
|
|
7
|
+
* It encodes `value` in the MessagePack format and
|
|
8
|
+
* returns a byte buffer.
|
|
9
|
+
*
|
|
10
|
+
* The returned buffer is a slice of a larger `ArrayBuffer`, so you have to use its `#byteOffset` and `#byteLength` in order to convert it to another typed arrays including NodeJS `Buffer`.
|
|
11
|
+
*/
|
|
12
|
+
function encode(value, options = defaultEncodeOptions) {
|
|
13
|
+
const encoder = new Encoder_1.Encoder(options.extensionCodec, options.context, options.maxDepth, options.initialBufferSize, options.sortKeys, options.forceFloat32, options.ignoreUndefined, options.forceIntegerToFloat);
|
|
14
|
+
return encoder.encodeSharedRef(value);
|
|
15
|
+
}
|
|
16
|
+
exports.encode = encode;
|
|
17
|
+
//# sourceMappingURL=encode.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Main Functions:
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.decodeTimestampExtension = exports.encodeTimestampExtension = exports.decodeTimestampToTimeSpec = exports.encodeTimeSpecToTimestamp = exports.encodeDateToTimeSpec = exports.EXT_TIMESTAMP = exports.ExtData = exports.ExtensionCodec = exports.Encoder = exports.DataViewIndexOutOfBoundsError = exports.DecodeError = exports.Decoder = exports.decodeStream = exports.decodeMultiStream = exports.decodeArrayStream = exports.decodeAsync = exports.decodeMulti = exports.decode = exports.encode = void 0;
|
|
5
|
+
const encode_1 = require("./encode");
|
|
6
|
+
Object.defineProperty(exports, "encode", { enumerable: true, get: function () { return encode_1.encode; } });
|
|
7
|
+
const decode_1 = require("./decode");
|
|
8
|
+
Object.defineProperty(exports, "decode", { enumerable: true, get: function () { return decode_1.decode; } });
|
|
9
|
+
Object.defineProperty(exports, "decodeMulti", { enumerable: true, get: function () { return decode_1.decodeMulti; } });
|
|
10
|
+
const decodeAsync_1 = require("./decodeAsync");
|
|
11
|
+
Object.defineProperty(exports, "decodeAsync", { enumerable: true, get: function () { return decodeAsync_1.decodeAsync; } });
|
|
12
|
+
Object.defineProperty(exports, "decodeArrayStream", { enumerable: true, get: function () { return decodeAsync_1.decodeArrayStream; } });
|
|
13
|
+
Object.defineProperty(exports, "decodeMultiStream", { enumerable: true, get: function () { return decodeAsync_1.decodeMultiStream; } });
|
|
14
|
+
Object.defineProperty(exports, "decodeStream", { enumerable: true, get: function () { return decodeAsync_1.decodeStream; } });
|
|
15
|
+
const Decoder_1 = require("./Decoder");
|
|
16
|
+
Object.defineProperty(exports, "Decoder", { enumerable: true, get: function () { return Decoder_1.Decoder; } });
|
|
17
|
+
Object.defineProperty(exports, "DataViewIndexOutOfBoundsError", { enumerable: true, get: function () { return Decoder_1.DataViewIndexOutOfBoundsError; } });
|
|
18
|
+
const DecodeError_1 = require("./DecodeError");
|
|
19
|
+
Object.defineProperty(exports, "DecodeError", { enumerable: true, get: function () { return DecodeError_1.DecodeError; } });
|
|
20
|
+
const Encoder_1 = require("./Encoder");
|
|
21
|
+
Object.defineProperty(exports, "Encoder", { enumerable: true, get: function () { return Encoder_1.Encoder; } });
|
|
22
|
+
// Utilitiies for Extension Types:
|
|
23
|
+
const ExtensionCodec_1 = require("./ExtensionCodec");
|
|
24
|
+
Object.defineProperty(exports, "ExtensionCodec", { enumerable: true, get: function () { return ExtensionCodec_1.ExtensionCodec; } });
|
|
25
|
+
const ExtData_1 = require("./ExtData");
|
|
26
|
+
Object.defineProperty(exports, "ExtData", { enumerable: true, get: function () { return ExtData_1.ExtData; } });
|
|
27
|
+
const timestamp_1 = require("./timestamp");
|
|
28
|
+
Object.defineProperty(exports, "EXT_TIMESTAMP", { enumerable: true, get: function () { return timestamp_1.EXT_TIMESTAMP; } });
|
|
29
|
+
Object.defineProperty(exports, "encodeDateToTimeSpec", { enumerable: true, get: function () { return timestamp_1.encodeDateToTimeSpec; } });
|
|
30
|
+
Object.defineProperty(exports, "encodeTimeSpecToTimestamp", { enumerable: true, get: function () { return timestamp_1.encodeTimeSpecToTimestamp; } });
|
|
31
|
+
Object.defineProperty(exports, "decodeTimestampToTimeSpec", { enumerable: true, get: function () { return timestamp_1.decodeTimestampToTimeSpec; } });
|
|
32
|
+
Object.defineProperty(exports, "encodeTimestampExtension", { enumerable: true, get: function () { return timestamp_1.encodeTimestampExtension; } });
|
|
33
|
+
Object.defineProperty(exports, "decodeTimestampExtension", { enumerable: true, get: function () { return timestamp_1.decodeTimestampExtension; } });
|
|
34
|
+
//# sourceMappingURL=index.js.map
|