@zlink-systems/framework-codec-msgpack 0.10.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/LICENSE +105 -0
- package/dist/browser/index.d.ts +8 -0
- package/dist/browser/index.mjs +1489 -0
- package/dist/framework.d.ts +6 -0
- package/dist/index.d.ts +8 -0
- package/dist/server/framework.cjs +1815 -0
- package/package.json +28 -0
|
@@ -0,0 +1,1815 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
9
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// node_modules/@msgpack/msgpack/dist.cjs/utils/utf8.cjs
|
|
34
|
+
var require_utf8 = __commonJS({
|
|
35
|
+
"node_modules/@msgpack/msgpack/dist.cjs/utils/utf8.cjs"(exports2) {
|
|
36
|
+
"use strict";
|
|
37
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
38
|
+
exports2.utf8Count = utf8Count;
|
|
39
|
+
exports2.utf8EncodeJs = utf8EncodeJs;
|
|
40
|
+
exports2.utf8EncodeTE = utf8EncodeTE;
|
|
41
|
+
exports2.utf8Encode = utf8Encode;
|
|
42
|
+
exports2.utf8DecodeJs = utf8DecodeJs;
|
|
43
|
+
exports2.utf8DecodeTD = utf8DecodeTD;
|
|
44
|
+
exports2.utf8Decode = utf8Decode;
|
|
45
|
+
function utf8Count(str) {
|
|
46
|
+
const strLength = str.length;
|
|
47
|
+
let byteLength = 0;
|
|
48
|
+
let pos = 0;
|
|
49
|
+
while (pos < strLength) {
|
|
50
|
+
let value = str.charCodeAt(pos++);
|
|
51
|
+
if ((value & 4294967168) === 0) {
|
|
52
|
+
byteLength++;
|
|
53
|
+
continue;
|
|
54
|
+
} else if ((value & 4294965248) === 0) {
|
|
55
|
+
byteLength += 2;
|
|
56
|
+
} else {
|
|
57
|
+
if (value >= 55296 && value <= 56319) {
|
|
58
|
+
if (pos < strLength) {
|
|
59
|
+
const extra = str.charCodeAt(pos);
|
|
60
|
+
if ((extra & 64512) === 56320) {
|
|
61
|
+
++pos;
|
|
62
|
+
value = ((value & 1023) << 10) + (extra & 1023) + 65536;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if ((value & 4294901760) === 0) {
|
|
67
|
+
byteLength += 3;
|
|
68
|
+
} else {
|
|
69
|
+
byteLength += 4;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return byteLength;
|
|
74
|
+
}
|
|
75
|
+
function utf8EncodeJs(str, output, outputOffset) {
|
|
76
|
+
const strLength = str.length;
|
|
77
|
+
let offset = outputOffset;
|
|
78
|
+
let pos = 0;
|
|
79
|
+
while (pos < strLength) {
|
|
80
|
+
let value = str.charCodeAt(pos++);
|
|
81
|
+
if ((value & 4294967168) === 0) {
|
|
82
|
+
output[offset++] = value;
|
|
83
|
+
continue;
|
|
84
|
+
} else if ((value & 4294965248) === 0) {
|
|
85
|
+
output[offset++] = value >> 6 & 31 | 192;
|
|
86
|
+
} else {
|
|
87
|
+
if (value >= 55296 && value <= 56319) {
|
|
88
|
+
if (pos < strLength) {
|
|
89
|
+
const extra = str.charCodeAt(pos);
|
|
90
|
+
if ((extra & 64512) === 56320) {
|
|
91
|
+
++pos;
|
|
92
|
+
value = ((value & 1023) << 10) + (extra & 1023) + 65536;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if ((value & 4294901760) === 0) {
|
|
97
|
+
output[offset++] = value >> 12 & 15 | 224;
|
|
98
|
+
output[offset++] = value >> 6 & 63 | 128;
|
|
99
|
+
} else {
|
|
100
|
+
output[offset++] = value >> 18 & 7 | 240;
|
|
101
|
+
output[offset++] = value >> 12 & 63 | 128;
|
|
102
|
+
output[offset++] = value >> 6 & 63 | 128;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
output[offset++] = value & 63 | 128;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
var sharedTextEncoder = new TextEncoder();
|
|
109
|
+
var TEXT_ENCODER_THRESHOLD = 50;
|
|
110
|
+
function utf8EncodeTE(str, output, outputOffset) {
|
|
111
|
+
sharedTextEncoder.encodeInto(str, output.subarray(outputOffset));
|
|
112
|
+
}
|
|
113
|
+
function utf8Encode(str, output, outputOffset) {
|
|
114
|
+
if (str.length > TEXT_ENCODER_THRESHOLD) {
|
|
115
|
+
utf8EncodeTE(str, output, outputOffset);
|
|
116
|
+
} else {
|
|
117
|
+
utf8EncodeJs(str, output, outputOffset);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
var CHUNK_SIZE = 4096;
|
|
121
|
+
function utf8DecodeJs(bytes, inputOffset, byteLength) {
|
|
122
|
+
let offset = inputOffset;
|
|
123
|
+
const end = offset + byteLength;
|
|
124
|
+
const units = [];
|
|
125
|
+
let result = "";
|
|
126
|
+
while (offset < end) {
|
|
127
|
+
const byte1 = bytes[offset++];
|
|
128
|
+
if ((byte1 & 128) === 0) {
|
|
129
|
+
units.push(byte1);
|
|
130
|
+
} else if ((byte1 & 224) === 192) {
|
|
131
|
+
const byte2 = bytes[offset++] & 63;
|
|
132
|
+
units.push((byte1 & 31) << 6 | byte2);
|
|
133
|
+
} else if ((byte1 & 240) === 224) {
|
|
134
|
+
const byte2 = bytes[offset++] & 63;
|
|
135
|
+
const byte3 = bytes[offset++] & 63;
|
|
136
|
+
units.push((byte1 & 31) << 12 | byte2 << 6 | byte3);
|
|
137
|
+
} else if ((byte1 & 248) === 240) {
|
|
138
|
+
const byte2 = bytes[offset++] & 63;
|
|
139
|
+
const byte3 = bytes[offset++] & 63;
|
|
140
|
+
const byte4 = bytes[offset++] & 63;
|
|
141
|
+
let unit = (byte1 & 7) << 18 | byte2 << 12 | byte3 << 6 | byte4;
|
|
142
|
+
if (unit > 65535) {
|
|
143
|
+
unit -= 65536;
|
|
144
|
+
units.push(unit >>> 10 & 1023 | 55296);
|
|
145
|
+
unit = 56320 | unit & 1023;
|
|
146
|
+
}
|
|
147
|
+
units.push(unit);
|
|
148
|
+
} else {
|
|
149
|
+
units.push(byte1);
|
|
150
|
+
}
|
|
151
|
+
if (units.length >= CHUNK_SIZE) {
|
|
152
|
+
result += String.fromCharCode(...units);
|
|
153
|
+
units.length = 0;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (units.length > 0) {
|
|
157
|
+
result += String.fromCharCode(...units);
|
|
158
|
+
}
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
var sharedTextDecoder = new TextDecoder();
|
|
162
|
+
var TEXT_DECODER_THRESHOLD = 200;
|
|
163
|
+
function utf8DecodeTD(bytes, inputOffset, byteLength) {
|
|
164
|
+
const stringBytes = bytes.subarray(inputOffset, inputOffset + byteLength);
|
|
165
|
+
return sharedTextDecoder.decode(stringBytes);
|
|
166
|
+
}
|
|
167
|
+
function utf8Decode(bytes, inputOffset, byteLength) {
|
|
168
|
+
if (byteLength > TEXT_DECODER_THRESHOLD) {
|
|
169
|
+
return utf8DecodeTD(bytes, inputOffset, byteLength);
|
|
170
|
+
} else {
|
|
171
|
+
return utf8DecodeJs(bytes, inputOffset, byteLength);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// node_modules/@msgpack/msgpack/dist.cjs/ExtData.cjs
|
|
178
|
+
var require_ExtData = __commonJS({
|
|
179
|
+
"node_modules/@msgpack/msgpack/dist.cjs/ExtData.cjs"(exports2) {
|
|
180
|
+
"use strict";
|
|
181
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
182
|
+
exports2.ExtData = void 0;
|
|
183
|
+
var ExtData = class {
|
|
184
|
+
type;
|
|
185
|
+
data;
|
|
186
|
+
constructor(type, data) {
|
|
187
|
+
this.type = type;
|
|
188
|
+
this.data = data;
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
exports2.ExtData = ExtData;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// node_modules/@msgpack/msgpack/dist.cjs/DecodeError.cjs
|
|
196
|
+
var require_DecodeError = __commonJS({
|
|
197
|
+
"node_modules/@msgpack/msgpack/dist.cjs/DecodeError.cjs"(exports2) {
|
|
198
|
+
"use strict";
|
|
199
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
200
|
+
exports2.DecodeError = void 0;
|
|
201
|
+
var DecodeError = class _DecodeError extends Error {
|
|
202
|
+
constructor(message) {
|
|
203
|
+
super(message);
|
|
204
|
+
const proto = Object.create(_DecodeError.prototype);
|
|
205
|
+
Object.setPrototypeOf(this, proto);
|
|
206
|
+
Object.defineProperty(this, "name", {
|
|
207
|
+
configurable: true,
|
|
208
|
+
enumerable: false,
|
|
209
|
+
value: _DecodeError.name
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
exports2.DecodeError = DecodeError;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// node_modules/@msgpack/msgpack/dist.cjs/utils/int.cjs
|
|
218
|
+
var require_int = __commonJS({
|
|
219
|
+
"node_modules/@msgpack/msgpack/dist.cjs/utils/int.cjs"(exports2) {
|
|
220
|
+
"use strict";
|
|
221
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
222
|
+
exports2.UINT32_MAX = void 0;
|
|
223
|
+
exports2.setUint64 = setUint64;
|
|
224
|
+
exports2.setInt64 = setInt64;
|
|
225
|
+
exports2.getInt64 = getInt64;
|
|
226
|
+
exports2.getUint64 = getUint64;
|
|
227
|
+
exports2.UINT32_MAX = 4294967295;
|
|
228
|
+
function setUint64(view, offset, value) {
|
|
229
|
+
const high = value / 4294967296;
|
|
230
|
+
const low = value;
|
|
231
|
+
view.setUint32(offset, high);
|
|
232
|
+
view.setUint32(offset + 4, low);
|
|
233
|
+
}
|
|
234
|
+
function setInt64(view, offset, value) {
|
|
235
|
+
const high = Math.floor(value / 4294967296);
|
|
236
|
+
const low = value;
|
|
237
|
+
view.setUint32(offset, high);
|
|
238
|
+
view.setUint32(offset + 4, low);
|
|
239
|
+
}
|
|
240
|
+
function getInt64(view, offset) {
|
|
241
|
+
const high = view.getInt32(offset);
|
|
242
|
+
const low = view.getUint32(offset + 4);
|
|
243
|
+
return high * 4294967296 + low;
|
|
244
|
+
}
|
|
245
|
+
function getUint64(view, offset) {
|
|
246
|
+
const high = view.getUint32(offset);
|
|
247
|
+
const low = view.getUint32(offset + 4);
|
|
248
|
+
return high * 4294967296 + low;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// node_modules/@msgpack/msgpack/dist.cjs/timestamp.cjs
|
|
254
|
+
var require_timestamp = __commonJS({
|
|
255
|
+
"node_modules/@msgpack/msgpack/dist.cjs/timestamp.cjs"(exports2) {
|
|
256
|
+
"use strict";
|
|
257
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
258
|
+
exports2.timestampExtension = exports2.EXT_TIMESTAMP = void 0;
|
|
259
|
+
exports2.encodeTimeSpecToTimestamp = encodeTimeSpecToTimestamp;
|
|
260
|
+
exports2.encodeDateToTimeSpec = encodeDateToTimeSpec;
|
|
261
|
+
exports2.encodeTimestampExtension = encodeTimestampExtension;
|
|
262
|
+
exports2.decodeTimestampToTimeSpec = decodeTimestampToTimeSpec;
|
|
263
|
+
exports2.decodeTimestampExtension = decodeTimestampExtension;
|
|
264
|
+
var DecodeError_ts_1 = require_DecodeError();
|
|
265
|
+
var int_ts_1 = require_int();
|
|
266
|
+
exports2.EXT_TIMESTAMP = -1;
|
|
267
|
+
var TIMESTAMP32_MAX_SEC = 4294967296 - 1;
|
|
268
|
+
var TIMESTAMP64_MAX_SEC = 17179869184 - 1;
|
|
269
|
+
function encodeTimeSpecToTimestamp({ sec, nsec }) {
|
|
270
|
+
if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) {
|
|
271
|
+
if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
|
|
272
|
+
const rv = new Uint8Array(4);
|
|
273
|
+
const view = new DataView(rv.buffer);
|
|
274
|
+
view.setUint32(0, sec);
|
|
275
|
+
return rv;
|
|
276
|
+
} else {
|
|
277
|
+
const secHigh = sec / 4294967296;
|
|
278
|
+
const secLow = sec & 4294967295;
|
|
279
|
+
const rv = new Uint8Array(8);
|
|
280
|
+
const view = new DataView(rv.buffer);
|
|
281
|
+
view.setUint32(0, nsec << 2 | secHigh & 3);
|
|
282
|
+
view.setUint32(4, secLow);
|
|
283
|
+
return rv;
|
|
284
|
+
}
|
|
285
|
+
} else {
|
|
286
|
+
const rv = new Uint8Array(12);
|
|
287
|
+
const view = new DataView(rv.buffer);
|
|
288
|
+
view.setUint32(0, nsec);
|
|
289
|
+
(0, int_ts_1.setInt64)(view, 4, sec);
|
|
290
|
+
return rv;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function encodeDateToTimeSpec(date) {
|
|
294
|
+
const msec = date.getTime();
|
|
295
|
+
const sec = Math.floor(msec / 1e3);
|
|
296
|
+
const nsec = (msec - sec * 1e3) * 1e6;
|
|
297
|
+
const nsecInSec = Math.floor(nsec / 1e9);
|
|
298
|
+
return {
|
|
299
|
+
sec: sec + nsecInSec,
|
|
300
|
+
nsec: nsec - nsecInSec * 1e9
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function encodeTimestampExtension(object) {
|
|
304
|
+
if (object instanceof Date) {
|
|
305
|
+
const timeSpec = encodeDateToTimeSpec(object);
|
|
306
|
+
return encodeTimeSpecToTimestamp(timeSpec);
|
|
307
|
+
} else {
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
function decodeTimestampToTimeSpec(data) {
|
|
312
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
313
|
+
switch (data.byteLength) {
|
|
314
|
+
case 4: {
|
|
315
|
+
const sec = view.getUint32(0);
|
|
316
|
+
const nsec = 0;
|
|
317
|
+
return { sec, nsec };
|
|
318
|
+
}
|
|
319
|
+
case 8: {
|
|
320
|
+
const nsec30AndSecHigh2 = view.getUint32(0);
|
|
321
|
+
const secLow32 = view.getUint32(4);
|
|
322
|
+
const sec = (nsec30AndSecHigh2 & 3) * 4294967296 + secLow32;
|
|
323
|
+
const nsec = nsec30AndSecHigh2 >>> 2;
|
|
324
|
+
return { sec, nsec };
|
|
325
|
+
}
|
|
326
|
+
case 12: {
|
|
327
|
+
const sec = (0, int_ts_1.getInt64)(view, 4);
|
|
328
|
+
const nsec = view.getUint32(0);
|
|
329
|
+
return { sec, nsec };
|
|
330
|
+
}
|
|
331
|
+
default:
|
|
332
|
+
throw new DecodeError_ts_1.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${data.length}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
function decodeTimestampExtension(data) {
|
|
336
|
+
const timeSpec = decodeTimestampToTimeSpec(data);
|
|
337
|
+
return new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);
|
|
338
|
+
}
|
|
339
|
+
exports2.timestampExtension = {
|
|
340
|
+
type: exports2.EXT_TIMESTAMP,
|
|
341
|
+
encode: encodeTimestampExtension,
|
|
342
|
+
decode: decodeTimestampExtension
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
// node_modules/@msgpack/msgpack/dist.cjs/ExtensionCodec.cjs
|
|
348
|
+
var require_ExtensionCodec = __commonJS({
|
|
349
|
+
"node_modules/@msgpack/msgpack/dist.cjs/ExtensionCodec.cjs"(exports2) {
|
|
350
|
+
"use strict";
|
|
351
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
352
|
+
exports2.ExtensionCodec = void 0;
|
|
353
|
+
var ExtData_ts_1 = require_ExtData();
|
|
354
|
+
var timestamp_ts_1 = require_timestamp();
|
|
355
|
+
var ExtensionCodec = class _ExtensionCodec {
|
|
356
|
+
static defaultCodec = new _ExtensionCodec();
|
|
357
|
+
// ensures ExtensionCodecType<X> matches ExtensionCodec<X>
|
|
358
|
+
// this will make type errors a lot more clear
|
|
359
|
+
__brand;
|
|
360
|
+
// built-in extensions
|
|
361
|
+
builtInEncoders = [];
|
|
362
|
+
builtInDecoders = [];
|
|
363
|
+
// custom extensions
|
|
364
|
+
encoders = [];
|
|
365
|
+
decoders = [];
|
|
366
|
+
constructor() {
|
|
367
|
+
this.register(timestamp_ts_1.timestampExtension);
|
|
368
|
+
}
|
|
369
|
+
register({ type, encode: encode2, decode: decode2 }) {
|
|
370
|
+
if (type >= 0) {
|
|
371
|
+
this.encoders[type] = encode2;
|
|
372
|
+
this.decoders[type] = decode2;
|
|
373
|
+
} else {
|
|
374
|
+
const index = -1 - type;
|
|
375
|
+
this.builtInEncoders[index] = encode2;
|
|
376
|
+
this.builtInDecoders[index] = decode2;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
tryToEncode(object, context) {
|
|
380
|
+
for (let i = 0; i < this.builtInEncoders.length; i++) {
|
|
381
|
+
const encodeExt = this.builtInEncoders[i];
|
|
382
|
+
if (encodeExt != null) {
|
|
383
|
+
const data = encodeExt(object, context);
|
|
384
|
+
if (data != null) {
|
|
385
|
+
const type = -1 - i;
|
|
386
|
+
return new ExtData_ts_1.ExtData(type, data);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
for (let i = 0; i < this.encoders.length; i++) {
|
|
391
|
+
const encodeExt = this.encoders[i];
|
|
392
|
+
if (encodeExt != null) {
|
|
393
|
+
const data = encodeExt(object, context);
|
|
394
|
+
if (data != null) {
|
|
395
|
+
const type = i;
|
|
396
|
+
return new ExtData_ts_1.ExtData(type, data);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
if (object instanceof ExtData_ts_1.ExtData) {
|
|
401
|
+
return object;
|
|
402
|
+
}
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
decode(data, type, context) {
|
|
406
|
+
const decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
|
|
407
|
+
if (decodeExt) {
|
|
408
|
+
return decodeExt(data, type, context);
|
|
409
|
+
} else {
|
|
410
|
+
return new ExtData_ts_1.ExtData(type, data);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
exports2.ExtensionCodec = ExtensionCodec;
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
// node_modules/@msgpack/msgpack/dist.cjs/utils/typedArrays.cjs
|
|
419
|
+
var require_typedArrays = __commonJS({
|
|
420
|
+
"node_modules/@msgpack/msgpack/dist.cjs/utils/typedArrays.cjs"(exports2) {
|
|
421
|
+
"use strict";
|
|
422
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
423
|
+
exports2.ensureUint8Array = ensureUint8Array;
|
|
424
|
+
function isArrayBufferLike(buffer) {
|
|
425
|
+
return buffer instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
|
|
426
|
+
}
|
|
427
|
+
function ensureUint8Array(buffer) {
|
|
428
|
+
if (buffer instanceof Uint8Array) {
|
|
429
|
+
return buffer;
|
|
430
|
+
} else if (ArrayBuffer.isView(buffer)) {
|
|
431
|
+
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
432
|
+
} else if (isArrayBufferLike(buffer)) {
|
|
433
|
+
return new Uint8Array(buffer);
|
|
434
|
+
} else {
|
|
435
|
+
return Uint8Array.from(buffer);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
// node_modules/@msgpack/msgpack/dist.cjs/Encoder.cjs
|
|
442
|
+
var require_Encoder = __commonJS({
|
|
443
|
+
"node_modules/@msgpack/msgpack/dist.cjs/Encoder.cjs"(exports2) {
|
|
444
|
+
"use strict";
|
|
445
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
446
|
+
exports2.Encoder = exports2.DEFAULT_INITIAL_BUFFER_SIZE = exports2.DEFAULT_MAX_DEPTH = void 0;
|
|
447
|
+
var utf8_ts_1 = require_utf8();
|
|
448
|
+
var ExtensionCodec_ts_1 = require_ExtensionCodec();
|
|
449
|
+
var int_ts_1 = require_int();
|
|
450
|
+
var typedArrays_ts_1 = require_typedArrays();
|
|
451
|
+
exports2.DEFAULT_MAX_DEPTH = 100;
|
|
452
|
+
exports2.DEFAULT_INITIAL_BUFFER_SIZE = 2048;
|
|
453
|
+
var Encoder = class _Encoder {
|
|
454
|
+
extensionCodec;
|
|
455
|
+
context;
|
|
456
|
+
useBigInt64;
|
|
457
|
+
maxDepth;
|
|
458
|
+
initialBufferSize;
|
|
459
|
+
sortKeys;
|
|
460
|
+
forceFloat32;
|
|
461
|
+
ignoreUndefined;
|
|
462
|
+
forceIntegerToFloat;
|
|
463
|
+
pos;
|
|
464
|
+
view;
|
|
465
|
+
bytes;
|
|
466
|
+
entered = false;
|
|
467
|
+
constructor(options) {
|
|
468
|
+
this.extensionCodec = options?.extensionCodec ?? ExtensionCodec_ts_1.ExtensionCodec.defaultCodec;
|
|
469
|
+
this.context = options?.context;
|
|
470
|
+
this.useBigInt64 = options?.useBigInt64 ?? false;
|
|
471
|
+
this.maxDepth = options?.maxDepth ?? exports2.DEFAULT_MAX_DEPTH;
|
|
472
|
+
this.initialBufferSize = options?.initialBufferSize ?? exports2.DEFAULT_INITIAL_BUFFER_SIZE;
|
|
473
|
+
this.sortKeys = options?.sortKeys ?? false;
|
|
474
|
+
this.forceFloat32 = options?.forceFloat32 ?? false;
|
|
475
|
+
this.ignoreUndefined = options?.ignoreUndefined ?? false;
|
|
476
|
+
this.forceIntegerToFloat = options?.forceIntegerToFloat ?? false;
|
|
477
|
+
this.pos = 0;
|
|
478
|
+
this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
|
|
479
|
+
this.bytes = new Uint8Array(this.view.buffer);
|
|
480
|
+
}
|
|
481
|
+
clone() {
|
|
482
|
+
return new _Encoder({
|
|
483
|
+
extensionCodec: this.extensionCodec,
|
|
484
|
+
context: this.context,
|
|
485
|
+
useBigInt64: this.useBigInt64,
|
|
486
|
+
maxDepth: this.maxDepth,
|
|
487
|
+
initialBufferSize: this.initialBufferSize,
|
|
488
|
+
sortKeys: this.sortKeys,
|
|
489
|
+
forceFloat32: this.forceFloat32,
|
|
490
|
+
ignoreUndefined: this.ignoreUndefined,
|
|
491
|
+
forceIntegerToFloat: this.forceIntegerToFloat
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
reinitializeState() {
|
|
495
|
+
this.pos = 0;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* 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}.
|
|
499
|
+
*
|
|
500
|
+
* @returns Encodes the object and returns a shared reference the encoder's internal buffer.
|
|
501
|
+
*/
|
|
502
|
+
encodeSharedRef(object) {
|
|
503
|
+
if (this.entered) {
|
|
504
|
+
const instance = this.clone();
|
|
505
|
+
return instance.encodeSharedRef(object);
|
|
506
|
+
}
|
|
507
|
+
try {
|
|
508
|
+
this.entered = true;
|
|
509
|
+
this.reinitializeState();
|
|
510
|
+
this.doEncode(object, 1);
|
|
511
|
+
return this.bytes.subarray(0, this.pos);
|
|
512
|
+
} finally {
|
|
513
|
+
this.entered = false;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* @returns Encodes the object and returns a copy of the encoder's internal buffer.
|
|
518
|
+
*/
|
|
519
|
+
encode(object) {
|
|
520
|
+
if (this.entered) {
|
|
521
|
+
const instance = this.clone();
|
|
522
|
+
return instance.encode(object);
|
|
523
|
+
}
|
|
524
|
+
try {
|
|
525
|
+
this.entered = true;
|
|
526
|
+
this.reinitializeState();
|
|
527
|
+
this.doEncode(object, 1);
|
|
528
|
+
return this.bytes.slice(0, this.pos);
|
|
529
|
+
} finally {
|
|
530
|
+
this.entered = false;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
doEncode(object, depth) {
|
|
534
|
+
if (depth > this.maxDepth) {
|
|
535
|
+
throw new Error(`Too deep objects in depth ${depth}`);
|
|
536
|
+
}
|
|
537
|
+
if (object == null) {
|
|
538
|
+
this.encodeNil();
|
|
539
|
+
} else if (typeof object === "boolean") {
|
|
540
|
+
this.encodeBoolean(object);
|
|
541
|
+
} else if (typeof object === "number") {
|
|
542
|
+
if (!this.forceIntegerToFloat) {
|
|
543
|
+
this.encodeNumber(object);
|
|
544
|
+
} else {
|
|
545
|
+
this.encodeNumberAsFloat(object);
|
|
546
|
+
}
|
|
547
|
+
} else if (typeof object === "string") {
|
|
548
|
+
this.encodeString(object);
|
|
549
|
+
} else if (this.useBigInt64 && typeof object === "bigint") {
|
|
550
|
+
this.encodeBigInt64(object);
|
|
551
|
+
} else {
|
|
552
|
+
this.encodeObject(object, depth);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
ensureBufferSizeToWrite(sizeToWrite) {
|
|
556
|
+
const requiredSize = this.pos + sizeToWrite;
|
|
557
|
+
if (this.view.byteLength < requiredSize) {
|
|
558
|
+
this.resizeBuffer(requiredSize * 2);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
resizeBuffer(newSize) {
|
|
562
|
+
const newBuffer = new ArrayBuffer(newSize);
|
|
563
|
+
const newBytes = new Uint8Array(newBuffer);
|
|
564
|
+
const newView = new DataView(newBuffer);
|
|
565
|
+
newBytes.set(this.bytes);
|
|
566
|
+
this.view = newView;
|
|
567
|
+
this.bytes = newBytes;
|
|
568
|
+
}
|
|
569
|
+
encodeNil() {
|
|
570
|
+
this.writeU8(192);
|
|
571
|
+
}
|
|
572
|
+
encodeBoolean(object) {
|
|
573
|
+
if (object === false) {
|
|
574
|
+
this.writeU8(194);
|
|
575
|
+
} else {
|
|
576
|
+
this.writeU8(195);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
encodeNumber(object) {
|
|
580
|
+
if (!this.forceIntegerToFloat && Number.isSafeInteger(object)) {
|
|
581
|
+
if (object >= 0) {
|
|
582
|
+
if (object < 128) {
|
|
583
|
+
this.writeU8(object);
|
|
584
|
+
} else if (object < 256) {
|
|
585
|
+
this.writeU8(204);
|
|
586
|
+
this.writeU8(object);
|
|
587
|
+
} else if (object < 65536) {
|
|
588
|
+
this.writeU8(205);
|
|
589
|
+
this.writeU16(object);
|
|
590
|
+
} else if (object < 4294967296) {
|
|
591
|
+
this.writeU8(206);
|
|
592
|
+
this.writeU32(object);
|
|
593
|
+
} else if (!this.useBigInt64) {
|
|
594
|
+
this.writeU8(207);
|
|
595
|
+
this.writeU64(object);
|
|
596
|
+
} else {
|
|
597
|
+
this.encodeNumberAsFloat(object);
|
|
598
|
+
}
|
|
599
|
+
} else {
|
|
600
|
+
if (object >= -32) {
|
|
601
|
+
this.writeU8(224 | object + 32);
|
|
602
|
+
} else if (object >= -128) {
|
|
603
|
+
this.writeU8(208);
|
|
604
|
+
this.writeI8(object);
|
|
605
|
+
} else if (object >= -32768) {
|
|
606
|
+
this.writeU8(209);
|
|
607
|
+
this.writeI16(object);
|
|
608
|
+
} else if (object >= -2147483648) {
|
|
609
|
+
this.writeU8(210);
|
|
610
|
+
this.writeI32(object);
|
|
611
|
+
} else if (!this.useBigInt64) {
|
|
612
|
+
this.writeU8(211);
|
|
613
|
+
this.writeI64(object);
|
|
614
|
+
} else {
|
|
615
|
+
this.encodeNumberAsFloat(object);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
} else {
|
|
619
|
+
this.encodeNumberAsFloat(object);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
encodeNumberAsFloat(object) {
|
|
623
|
+
if (this.forceFloat32) {
|
|
624
|
+
this.writeU8(202);
|
|
625
|
+
this.writeF32(object);
|
|
626
|
+
} else {
|
|
627
|
+
this.writeU8(203);
|
|
628
|
+
this.writeF64(object);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
encodeBigInt64(object) {
|
|
632
|
+
if (object >= BigInt(0)) {
|
|
633
|
+
this.writeU8(207);
|
|
634
|
+
this.writeBigUint64(object);
|
|
635
|
+
} else {
|
|
636
|
+
this.writeU8(211);
|
|
637
|
+
this.writeBigInt64(object);
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
writeStringHeader(byteLength) {
|
|
641
|
+
if (byteLength < 32) {
|
|
642
|
+
this.writeU8(160 + byteLength);
|
|
643
|
+
} else if (byteLength < 256) {
|
|
644
|
+
this.writeU8(217);
|
|
645
|
+
this.writeU8(byteLength);
|
|
646
|
+
} else if (byteLength < 65536) {
|
|
647
|
+
this.writeU8(218);
|
|
648
|
+
this.writeU16(byteLength);
|
|
649
|
+
} else if (byteLength < 4294967296) {
|
|
650
|
+
this.writeU8(219);
|
|
651
|
+
this.writeU32(byteLength);
|
|
652
|
+
} else {
|
|
653
|
+
throw new Error(`Too long string: ${byteLength} bytes in UTF-8`);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
encodeString(object) {
|
|
657
|
+
const maxHeaderSize = 1 + 4;
|
|
658
|
+
const byteLength = (0, utf8_ts_1.utf8Count)(object);
|
|
659
|
+
this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
|
|
660
|
+
this.writeStringHeader(byteLength);
|
|
661
|
+
(0, utf8_ts_1.utf8Encode)(object, this.bytes, this.pos);
|
|
662
|
+
this.pos += byteLength;
|
|
663
|
+
}
|
|
664
|
+
encodeObject(object, depth) {
|
|
665
|
+
const ext = this.extensionCodec.tryToEncode(object, this.context);
|
|
666
|
+
if (ext != null) {
|
|
667
|
+
this.encodeExtension(ext);
|
|
668
|
+
} else if (Array.isArray(object)) {
|
|
669
|
+
this.encodeArray(object, depth);
|
|
670
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
671
|
+
this.encodeBinary(object);
|
|
672
|
+
} else if (typeof object === "object") {
|
|
673
|
+
this.encodeMap(object, depth);
|
|
674
|
+
} else {
|
|
675
|
+
throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(object)}`);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
encodeBinary(object) {
|
|
679
|
+
const size = object.byteLength;
|
|
680
|
+
if (size < 256) {
|
|
681
|
+
this.writeU8(196);
|
|
682
|
+
this.writeU8(size);
|
|
683
|
+
} else if (size < 65536) {
|
|
684
|
+
this.writeU8(197);
|
|
685
|
+
this.writeU16(size);
|
|
686
|
+
} else if (size < 4294967296) {
|
|
687
|
+
this.writeU8(198);
|
|
688
|
+
this.writeU32(size);
|
|
689
|
+
} else {
|
|
690
|
+
throw new Error(`Too large binary: ${size}`);
|
|
691
|
+
}
|
|
692
|
+
const bytes = (0, typedArrays_ts_1.ensureUint8Array)(object);
|
|
693
|
+
this.writeU8a(bytes);
|
|
694
|
+
}
|
|
695
|
+
encodeArray(object, depth) {
|
|
696
|
+
const size = object.length;
|
|
697
|
+
if (size < 16) {
|
|
698
|
+
this.writeU8(144 + size);
|
|
699
|
+
} else if (size < 65536) {
|
|
700
|
+
this.writeU8(220);
|
|
701
|
+
this.writeU16(size);
|
|
702
|
+
} else if (size < 4294967296) {
|
|
703
|
+
this.writeU8(221);
|
|
704
|
+
this.writeU32(size);
|
|
705
|
+
} else {
|
|
706
|
+
throw new Error(`Too large array: ${size}`);
|
|
707
|
+
}
|
|
708
|
+
for (const item of object) {
|
|
709
|
+
this.doEncode(item, depth + 1);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
countWithoutUndefined(object, keys) {
|
|
713
|
+
let count = 0;
|
|
714
|
+
for (const key of keys) {
|
|
715
|
+
if (object[key] !== void 0) {
|
|
716
|
+
count++;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return count;
|
|
720
|
+
}
|
|
721
|
+
encodeMap(object, depth) {
|
|
722
|
+
const keys = Object.keys(object);
|
|
723
|
+
if (this.sortKeys) {
|
|
724
|
+
keys.sort();
|
|
725
|
+
}
|
|
726
|
+
const size = this.ignoreUndefined ? this.countWithoutUndefined(object, keys) : keys.length;
|
|
727
|
+
if (size < 16) {
|
|
728
|
+
this.writeU8(128 + size);
|
|
729
|
+
} else if (size < 65536) {
|
|
730
|
+
this.writeU8(222);
|
|
731
|
+
this.writeU16(size);
|
|
732
|
+
} else if (size < 4294967296) {
|
|
733
|
+
this.writeU8(223);
|
|
734
|
+
this.writeU32(size);
|
|
735
|
+
} else {
|
|
736
|
+
throw new Error(`Too large map object: ${size}`);
|
|
737
|
+
}
|
|
738
|
+
for (const key of keys) {
|
|
739
|
+
const value = object[key];
|
|
740
|
+
if (!(this.ignoreUndefined && value === void 0)) {
|
|
741
|
+
this.encodeString(key);
|
|
742
|
+
this.doEncode(value, depth + 1);
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
encodeExtension(ext) {
|
|
747
|
+
if (typeof ext.data === "function") {
|
|
748
|
+
const data = ext.data(this.pos + 6);
|
|
749
|
+
const size2 = data.length;
|
|
750
|
+
if (size2 >= 4294967296) {
|
|
751
|
+
throw new Error(`Too large extension object: ${size2}`);
|
|
752
|
+
}
|
|
753
|
+
this.writeU8(201);
|
|
754
|
+
this.writeU32(size2);
|
|
755
|
+
this.writeI8(ext.type);
|
|
756
|
+
this.writeU8a(data);
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
const size = ext.data.length;
|
|
760
|
+
if (size === 1) {
|
|
761
|
+
this.writeU8(212);
|
|
762
|
+
} else if (size === 2) {
|
|
763
|
+
this.writeU8(213);
|
|
764
|
+
} else if (size === 4) {
|
|
765
|
+
this.writeU8(214);
|
|
766
|
+
} else if (size === 8) {
|
|
767
|
+
this.writeU8(215);
|
|
768
|
+
} else if (size === 16) {
|
|
769
|
+
this.writeU8(216);
|
|
770
|
+
} else if (size < 256) {
|
|
771
|
+
this.writeU8(199);
|
|
772
|
+
this.writeU8(size);
|
|
773
|
+
} else if (size < 65536) {
|
|
774
|
+
this.writeU8(200);
|
|
775
|
+
this.writeU16(size);
|
|
776
|
+
} else if (size < 4294967296) {
|
|
777
|
+
this.writeU8(201);
|
|
778
|
+
this.writeU32(size);
|
|
779
|
+
} else {
|
|
780
|
+
throw new Error(`Too large extension object: ${size}`);
|
|
781
|
+
}
|
|
782
|
+
this.writeI8(ext.type);
|
|
783
|
+
this.writeU8a(ext.data);
|
|
784
|
+
}
|
|
785
|
+
writeU8(value) {
|
|
786
|
+
this.ensureBufferSizeToWrite(1);
|
|
787
|
+
this.view.setUint8(this.pos, value);
|
|
788
|
+
this.pos++;
|
|
789
|
+
}
|
|
790
|
+
writeU8a(values) {
|
|
791
|
+
const size = values.length;
|
|
792
|
+
this.ensureBufferSizeToWrite(size);
|
|
793
|
+
this.bytes.set(values, this.pos);
|
|
794
|
+
this.pos += size;
|
|
795
|
+
}
|
|
796
|
+
writeI8(value) {
|
|
797
|
+
this.ensureBufferSizeToWrite(1);
|
|
798
|
+
this.view.setInt8(this.pos, value);
|
|
799
|
+
this.pos++;
|
|
800
|
+
}
|
|
801
|
+
writeU16(value) {
|
|
802
|
+
this.ensureBufferSizeToWrite(2);
|
|
803
|
+
this.view.setUint16(this.pos, value);
|
|
804
|
+
this.pos += 2;
|
|
805
|
+
}
|
|
806
|
+
writeI16(value) {
|
|
807
|
+
this.ensureBufferSizeToWrite(2);
|
|
808
|
+
this.view.setInt16(this.pos, value);
|
|
809
|
+
this.pos += 2;
|
|
810
|
+
}
|
|
811
|
+
writeU32(value) {
|
|
812
|
+
this.ensureBufferSizeToWrite(4);
|
|
813
|
+
this.view.setUint32(this.pos, value);
|
|
814
|
+
this.pos += 4;
|
|
815
|
+
}
|
|
816
|
+
writeI32(value) {
|
|
817
|
+
this.ensureBufferSizeToWrite(4);
|
|
818
|
+
this.view.setInt32(this.pos, value);
|
|
819
|
+
this.pos += 4;
|
|
820
|
+
}
|
|
821
|
+
writeF32(value) {
|
|
822
|
+
this.ensureBufferSizeToWrite(4);
|
|
823
|
+
this.view.setFloat32(this.pos, value);
|
|
824
|
+
this.pos += 4;
|
|
825
|
+
}
|
|
826
|
+
writeF64(value) {
|
|
827
|
+
this.ensureBufferSizeToWrite(8);
|
|
828
|
+
this.view.setFloat64(this.pos, value);
|
|
829
|
+
this.pos += 8;
|
|
830
|
+
}
|
|
831
|
+
writeU64(value) {
|
|
832
|
+
this.ensureBufferSizeToWrite(8);
|
|
833
|
+
(0, int_ts_1.setUint64)(this.view, this.pos, value);
|
|
834
|
+
this.pos += 8;
|
|
835
|
+
}
|
|
836
|
+
writeI64(value) {
|
|
837
|
+
this.ensureBufferSizeToWrite(8);
|
|
838
|
+
(0, int_ts_1.setInt64)(this.view, this.pos, value);
|
|
839
|
+
this.pos += 8;
|
|
840
|
+
}
|
|
841
|
+
writeBigUint64(value) {
|
|
842
|
+
this.ensureBufferSizeToWrite(8);
|
|
843
|
+
this.view.setBigUint64(this.pos, value);
|
|
844
|
+
this.pos += 8;
|
|
845
|
+
}
|
|
846
|
+
writeBigInt64(value) {
|
|
847
|
+
this.ensureBufferSizeToWrite(8);
|
|
848
|
+
this.view.setBigInt64(this.pos, value);
|
|
849
|
+
this.pos += 8;
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
exports2.Encoder = Encoder;
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
// node_modules/@msgpack/msgpack/dist.cjs/encode.cjs
|
|
857
|
+
var require_encode = __commonJS({
|
|
858
|
+
"node_modules/@msgpack/msgpack/dist.cjs/encode.cjs"(exports2) {
|
|
859
|
+
"use strict";
|
|
860
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
861
|
+
exports2.encode = encode2;
|
|
862
|
+
var Encoder_ts_1 = require_Encoder();
|
|
863
|
+
function encode2(value, options) {
|
|
864
|
+
const encoder = new Encoder_ts_1.Encoder(options);
|
|
865
|
+
return encoder.encodeSharedRef(value);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
|
|
870
|
+
// node_modules/@msgpack/msgpack/dist.cjs/utils/prettyByte.cjs
|
|
871
|
+
var require_prettyByte = __commonJS({
|
|
872
|
+
"node_modules/@msgpack/msgpack/dist.cjs/utils/prettyByte.cjs"(exports2) {
|
|
873
|
+
"use strict";
|
|
874
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
875
|
+
exports2.prettyByte = prettyByte;
|
|
876
|
+
function prettyByte(byte) {
|
|
877
|
+
return `${byte < 0 ? "-" : ""}0x${Math.abs(byte).toString(16).padStart(2, "0")}`;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
});
|
|
881
|
+
|
|
882
|
+
// node_modules/@msgpack/msgpack/dist.cjs/CachedKeyDecoder.cjs
|
|
883
|
+
var require_CachedKeyDecoder = __commonJS({
|
|
884
|
+
"node_modules/@msgpack/msgpack/dist.cjs/CachedKeyDecoder.cjs"(exports2) {
|
|
885
|
+
"use strict";
|
|
886
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
887
|
+
exports2.CachedKeyDecoder = void 0;
|
|
888
|
+
var utf8_ts_1 = require_utf8();
|
|
889
|
+
var DEFAULT_MAX_KEY_LENGTH = 16;
|
|
890
|
+
var DEFAULT_MAX_LENGTH_PER_KEY = 16;
|
|
891
|
+
var CachedKeyDecoder = class {
|
|
892
|
+
hit = 0;
|
|
893
|
+
miss = 0;
|
|
894
|
+
caches;
|
|
895
|
+
maxKeyLength;
|
|
896
|
+
maxLengthPerKey;
|
|
897
|
+
constructor(maxKeyLength = DEFAULT_MAX_KEY_LENGTH, maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY) {
|
|
898
|
+
this.maxKeyLength = maxKeyLength;
|
|
899
|
+
this.maxLengthPerKey = maxLengthPerKey;
|
|
900
|
+
this.caches = [];
|
|
901
|
+
for (let i = 0; i < this.maxKeyLength; i++) {
|
|
902
|
+
this.caches.push([]);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
canBeCached(byteLength) {
|
|
906
|
+
return byteLength > 0 && byteLength <= this.maxKeyLength;
|
|
907
|
+
}
|
|
908
|
+
find(bytes, inputOffset, byteLength) {
|
|
909
|
+
const records = this.caches[byteLength - 1];
|
|
910
|
+
FIND_CHUNK: for (const record of records) {
|
|
911
|
+
const recordBytes = record.bytes;
|
|
912
|
+
for (let j = 0; j < byteLength; j++) {
|
|
913
|
+
if (recordBytes[j] !== bytes[inputOffset + j]) {
|
|
914
|
+
continue FIND_CHUNK;
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
return record.str;
|
|
918
|
+
}
|
|
919
|
+
return null;
|
|
920
|
+
}
|
|
921
|
+
store(bytes, value) {
|
|
922
|
+
const records = this.caches[bytes.length - 1];
|
|
923
|
+
const record = { bytes, str: value };
|
|
924
|
+
if (records.length >= this.maxLengthPerKey) {
|
|
925
|
+
records[Math.random() * records.length | 0] = record;
|
|
926
|
+
} else {
|
|
927
|
+
records.push(record);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
decode(bytes, inputOffset, byteLength) {
|
|
931
|
+
const cachedValue = this.find(bytes, inputOffset, byteLength);
|
|
932
|
+
if (cachedValue != null) {
|
|
933
|
+
this.hit++;
|
|
934
|
+
return cachedValue;
|
|
935
|
+
}
|
|
936
|
+
this.miss++;
|
|
937
|
+
const str = (0, utf8_ts_1.utf8DecodeJs)(bytes, inputOffset, byteLength);
|
|
938
|
+
const slicedCopyOfBytes = Uint8Array.prototype.slice.call(bytes, inputOffset, inputOffset + byteLength);
|
|
939
|
+
this.store(slicedCopyOfBytes, str);
|
|
940
|
+
return str;
|
|
941
|
+
}
|
|
942
|
+
};
|
|
943
|
+
exports2.CachedKeyDecoder = CachedKeyDecoder;
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
|
|
947
|
+
// node_modules/@msgpack/msgpack/dist.cjs/Decoder.cjs
|
|
948
|
+
var require_Decoder = __commonJS({
|
|
949
|
+
"node_modules/@msgpack/msgpack/dist.cjs/Decoder.cjs"(exports2) {
|
|
950
|
+
"use strict";
|
|
951
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
952
|
+
exports2.Decoder = void 0;
|
|
953
|
+
var prettyByte_ts_1 = require_prettyByte();
|
|
954
|
+
var ExtensionCodec_ts_1 = require_ExtensionCodec();
|
|
955
|
+
var int_ts_1 = require_int();
|
|
956
|
+
var utf8_ts_1 = require_utf8();
|
|
957
|
+
var typedArrays_ts_1 = require_typedArrays();
|
|
958
|
+
var CachedKeyDecoder_ts_1 = require_CachedKeyDecoder();
|
|
959
|
+
var DecodeError_ts_1 = require_DecodeError();
|
|
960
|
+
var STATE_ARRAY = "array";
|
|
961
|
+
var STATE_MAP_KEY = "map_key";
|
|
962
|
+
var STATE_MAP_VALUE = "map_value";
|
|
963
|
+
var mapKeyConverter = (key) => {
|
|
964
|
+
if (typeof key === "string" || typeof key === "number") {
|
|
965
|
+
return key;
|
|
966
|
+
}
|
|
967
|
+
throw new DecodeError_ts_1.DecodeError("The type of key must be string or number but " + typeof key);
|
|
968
|
+
};
|
|
969
|
+
var StackPool = class {
|
|
970
|
+
stack = [];
|
|
971
|
+
stackHeadPosition = -1;
|
|
972
|
+
get length() {
|
|
973
|
+
return this.stackHeadPosition + 1;
|
|
974
|
+
}
|
|
975
|
+
top() {
|
|
976
|
+
return this.stack[this.stackHeadPosition];
|
|
977
|
+
}
|
|
978
|
+
pushArrayState(size) {
|
|
979
|
+
const state = this.getUninitializedStateFromPool();
|
|
980
|
+
state.type = STATE_ARRAY;
|
|
981
|
+
state.position = 0;
|
|
982
|
+
state.size = size;
|
|
983
|
+
state.array = new Array(size);
|
|
984
|
+
}
|
|
985
|
+
pushMapState(size) {
|
|
986
|
+
const state = this.getUninitializedStateFromPool();
|
|
987
|
+
state.type = STATE_MAP_KEY;
|
|
988
|
+
state.readCount = 0;
|
|
989
|
+
state.size = size;
|
|
990
|
+
state.map = {};
|
|
991
|
+
}
|
|
992
|
+
getUninitializedStateFromPool() {
|
|
993
|
+
this.stackHeadPosition++;
|
|
994
|
+
if (this.stackHeadPosition === this.stack.length) {
|
|
995
|
+
const partialState = {
|
|
996
|
+
type: void 0,
|
|
997
|
+
size: 0,
|
|
998
|
+
array: void 0,
|
|
999
|
+
position: 0,
|
|
1000
|
+
readCount: 0,
|
|
1001
|
+
map: void 0,
|
|
1002
|
+
key: null
|
|
1003
|
+
};
|
|
1004
|
+
this.stack.push(partialState);
|
|
1005
|
+
}
|
|
1006
|
+
return this.stack[this.stackHeadPosition];
|
|
1007
|
+
}
|
|
1008
|
+
release(state) {
|
|
1009
|
+
const topStackState = this.stack[this.stackHeadPosition];
|
|
1010
|
+
if (topStackState !== state) {
|
|
1011
|
+
throw new Error("Invalid stack state. Released state is not on top of the stack.");
|
|
1012
|
+
}
|
|
1013
|
+
if (state.type === STATE_ARRAY) {
|
|
1014
|
+
const partialState = state;
|
|
1015
|
+
partialState.size = 0;
|
|
1016
|
+
partialState.array = void 0;
|
|
1017
|
+
partialState.position = 0;
|
|
1018
|
+
partialState.type = void 0;
|
|
1019
|
+
}
|
|
1020
|
+
if (state.type === STATE_MAP_KEY || state.type === STATE_MAP_VALUE) {
|
|
1021
|
+
const partialState = state;
|
|
1022
|
+
partialState.size = 0;
|
|
1023
|
+
partialState.map = void 0;
|
|
1024
|
+
partialState.readCount = 0;
|
|
1025
|
+
partialState.type = void 0;
|
|
1026
|
+
}
|
|
1027
|
+
this.stackHeadPosition--;
|
|
1028
|
+
}
|
|
1029
|
+
reset() {
|
|
1030
|
+
this.stack.length = 0;
|
|
1031
|
+
this.stackHeadPosition = -1;
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
var HEAD_BYTE_REQUIRED = -1;
|
|
1035
|
+
var EMPTY_VIEW = new DataView(new ArrayBuffer(0));
|
|
1036
|
+
var EMPTY_BYTES = new Uint8Array(EMPTY_VIEW.buffer);
|
|
1037
|
+
try {
|
|
1038
|
+
EMPTY_VIEW.getInt8(0);
|
|
1039
|
+
} catch (e) {
|
|
1040
|
+
if (!(e instanceof RangeError)) {
|
|
1041
|
+
throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
var MORE_DATA = new RangeError("Insufficient data");
|
|
1045
|
+
var sharedCachedKeyDecoder = new CachedKeyDecoder_ts_1.CachedKeyDecoder();
|
|
1046
|
+
var Decoder = class _Decoder {
|
|
1047
|
+
extensionCodec;
|
|
1048
|
+
context;
|
|
1049
|
+
useBigInt64;
|
|
1050
|
+
rawStrings;
|
|
1051
|
+
maxStrLength;
|
|
1052
|
+
maxBinLength;
|
|
1053
|
+
maxArrayLength;
|
|
1054
|
+
maxMapLength;
|
|
1055
|
+
maxExtLength;
|
|
1056
|
+
keyDecoder;
|
|
1057
|
+
mapKeyConverter;
|
|
1058
|
+
totalPos = 0;
|
|
1059
|
+
pos = 0;
|
|
1060
|
+
view = EMPTY_VIEW;
|
|
1061
|
+
bytes = EMPTY_BYTES;
|
|
1062
|
+
headByte = HEAD_BYTE_REQUIRED;
|
|
1063
|
+
stack = new StackPool();
|
|
1064
|
+
entered = false;
|
|
1065
|
+
constructor(options) {
|
|
1066
|
+
this.extensionCodec = options?.extensionCodec ?? ExtensionCodec_ts_1.ExtensionCodec.defaultCodec;
|
|
1067
|
+
this.context = options?.context;
|
|
1068
|
+
this.useBigInt64 = options?.useBigInt64 ?? false;
|
|
1069
|
+
this.rawStrings = options?.rawStrings ?? false;
|
|
1070
|
+
this.maxStrLength = options?.maxStrLength ?? int_ts_1.UINT32_MAX;
|
|
1071
|
+
this.maxBinLength = options?.maxBinLength ?? int_ts_1.UINT32_MAX;
|
|
1072
|
+
this.maxArrayLength = options?.maxArrayLength ?? int_ts_1.UINT32_MAX;
|
|
1073
|
+
this.maxMapLength = options?.maxMapLength ?? int_ts_1.UINT32_MAX;
|
|
1074
|
+
this.maxExtLength = options?.maxExtLength ?? int_ts_1.UINT32_MAX;
|
|
1075
|
+
this.keyDecoder = options?.keyDecoder !== void 0 ? options.keyDecoder : sharedCachedKeyDecoder;
|
|
1076
|
+
this.mapKeyConverter = options?.mapKeyConverter ?? mapKeyConverter;
|
|
1077
|
+
}
|
|
1078
|
+
clone() {
|
|
1079
|
+
return new _Decoder({
|
|
1080
|
+
extensionCodec: this.extensionCodec,
|
|
1081
|
+
context: this.context,
|
|
1082
|
+
useBigInt64: this.useBigInt64,
|
|
1083
|
+
rawStrings: this.rawStrings,
|
|
1084
|
+
maxStrLength: this.maxStrLength,
|
|
1085
|
+
maxBinLength: this.maxBinLength,
|
|
1086
|
+
maxArrayLength: this.maxArrayLength,
|
|
1087
|
+
maxMapLength: this.maxMapLength,
|
|
1088
|
+
maxExtLength: this.maxExtLength,
|
|
1089
|
+
keyDecoder: this.keyDecoder
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
reinitializeState() {
|
|
1093
|
+
this.totalPos = 0;
|
|
1094
|
+
this.headByte = HEAD_BYTE_REQUIRED;
|
|
1095
|
+
this.stack.reset();
|
|
1096
|
+
}
|
|
1097
|
+
setBuffer(buffer) {
|
|
1098
|
+
const bytes = (0, typedArrays_ts_1.ensureUint8Array)(buffer);
|
|
1099
|
+
this.bytes = bytes;
|
|
1100
|
+
this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
1101
|
+
this.pos = 0;
|
|
1102
|
+
}
|
|
1103
|
+
appendBuffer(buffer) {
|
|
1104
|
+
if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining(1)) {
|
|
1105
|
+
this.setBuffer(buffer);
|
|
1106
|
+
} else {
|
|
1107
|
+
const remainingData = this.bytes.subarray(this.pos);
|
|
1108
|
+
const newData = (0, typedArrays_ts_1.ensureUint8Array)(buffer);
|
|
1109
|
+
const newBuffer = new Uint8Array(remainingData.length + newData.length);
|
|
1110
|
+
newBuffer.set(remainingData);
|
|
1111
|
+
newBuffer.set(newData, remainingData.length);
|
|
1112
|
+
this.setBuffer(newBuffer);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
hasRemaining(size) {
|
|
1116
|
+
return this.view.byteLength - this.pos >= size;
|
|
1117
|
+
}
|
|
1118
|
+
createExtraByteError(posToShow) {
|
|
1119
|
+
const { view, pos } = this;
|
|
1120
|
+
return new RangeError(`Extra ${view.byteLength - pos} of ${view.byteLength} byte(s) found at buffer[${posToShow}]`);
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* @throws {@link DecodeError}
|
|
1124
|
+
* @throws {@link RangeError}
|
|
1125
|
+
*/
|
|
1126
|
+
decode(buffer) {
|
|
1127
|
+
if (this.entered) {
|
|
1128
|
+
const instance = this.clone();
|
|
1129
|
+
return instance.decode(buffer);
|
|
1130
|
+
}
|
|
1131
|
+
try {
|
|
1132
|
+
this.entered = true;
|
|
1133
|
+
this.reinitializeState();
|
|
1134
|
+
this.setBuffer(buffer);
|
|
1135
|
+
const object = this.doDecodeSync();
|
|
1136
|
+
if (this.hasRemaining(1)) {
|
|
1137
|
+
throw this.createExtraByteError(this.pos);
|
|
1138
|
+
}
|
|
1139
|
+
return object;
|
|
1140
|
+
} finally {
|
|
1141
|
+
this.entered = false;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
*decodeMulti(buffer) {
|
|
1145
|
+
if (this.entered) {
|
|
1146
|
+
const instance = this.clone();
|
|
1147
|
+
yield* instance.decodeMulti(buffer);
|
|
1148
|
+
return;
|
|
1149
|
+
}
|
|
1150
|
+
try {
|
|
1151
|
+
this.entered = true;
|
|
1152
|
+
this.reinitializeState();
|
|
1153
|
+
this.setBuffer(buffer);
|
|
1154
|
+
while (this.hasRemaining(1)) {
|
|
1155
|
+
yield this.doDecodeSync();
|
|
1156
|
+
}
|
|
1157
|
+
} finally {
|
|
1158
|
+
this.entered = false;
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
async decodeAsync(stream) {
|
|
1162
|
+
if (this.entered) {
|
|
1163
|
+
const instance = this.clone();
|
|
1164
|
+
return instance.decodeAsync(stream);
|
|
1165
|
+
}
|
|
1166
|
+
try {
|
|
1167
|
+
this.entered = true;
|
|
1168
|
+
let decoded = false;
|
|
1169
|
+
let object;
|
|
1170
|
+
for await (const buffer of stream) {
|
|
1171
|
+
if (decoded) {
|
|
1172
|
+
this.entered = false;
|
|
1173
|
+
throw this.createExtraByteError(this.totalPos);
|
|
1174
|
+
}
|
|
1175
|
+
this.appendBuffer(buffer);
|
|
1176
|
+
try {
|
|
1177
|
+
object = this.doDecodeSync();
|
|
1178
|
+
decoded = true;
|
|
1179
|
+
} catch (e) {
|
|
1180
|
+
if (!(e instanceof RangeError)) {
|
|
1181
|
+
throw e;
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
this.totalPos += this.pos;
|
|
1185
|
+
}
|
|
1186
|
+
if (decoded) {
|
|
1187
|
+
if (this.hasRemaining(1)) {
|
|
1188
|
+
throw this.createExtraByteError(this.totalPos);
|
|
1189
|
+
}
|
|
1190
|
+
return object;
|
|
1191
|
+
}
|
|
1192
|
+
const { headByte, pos, totalPos } = this;
|
|
1193
|
+
throw new RangeError(`Insufficient data in parsing ${(0, prettyByte_ts_1.prettyByte)(headByte)} at ${totalPos} (${pos} in the current buffer)`);
|
|
1194
|
+
} finally {
|
|
1195
|
+
this.entered = false;
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
decodeArrayStream(stream) {
|
|
1199
|
+
return this.decodeMultiAsync(stream, true);
|
|
1200
|
+
}
|
|
1201
|
+
decodeStream(stream) {
|
|
1202
|
+
return this.decodeMultiAsync(stream, false);
|
|
1203
|
+
}
|
|
1204
|
+
async *decodeMultiAsync(stream, isArray) {
|
|
1205
|
+
if (this.entered) {
|
|
1206
|
+
const instance = this.clone();
|
|
1207
|
+
yield* instance.decodeMultiAsync(stream, isArray);
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
try {
|
|
1211
|
+
this.entered = true;
|
|
1212
|
+
let isArrayHeaderRequired = isArray;
|
|
1213
|
+
let arrayItemsLeft = -1;
|
|
1214
|
+
for await (const buffer of stream) {
|
|
1215
|
+
if (isArray && arrayItemsLeft === 0) {
|
|
1216
|
+
throw this.createExtraByteError(this.totalPos);
|
|
1217
|
+
}
|
|
1218
|
+
this.appendBuffer(buffer);
|
|
1219
|
+
if (isArrayHeaderRequired) {
|
|
1220
|
+
arrayItemsLeft = this.readArraySize();
|
|
1221
|
+
isArrayHeaderRequired = false;
|
|
1222
|
+
this.complete();
|
|
1223
|
+
}
|
|
1224
|
+
try {
|
|
1225
|
+
while (true) {
|
|
1226
|
+
yield this.doDecodeSync();
|
|
1227
|
+
if (--arrayItemsLeft === 0) {
|
|
1228
|
+
break;
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
} catch (e) {
|
|
1232
|
+
if (!(e instanceof RangeError)) {
|
|
1233
|
+
throw e;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
this.totalPos += this.pos;
|
|
1237
|
+
}
|
|
1238
|
+
} finally {
|
|
1239
|
+
this.entered = false;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
doDecodeSync() {
|
|
1243
|
+
DECODE: while (true) {
|
|
1244
|
+
const headByte = this.readHeadByte();
|
|
1245
|
+
let object;
|
|
1246
|
+
if (headByte >= 224) {
|
|
1247
|
+
object = headByte - 256;
|
|
1248
|
+
} else if (headByte < 192) {
|
|
1249
|
+
if (headByte < 128) {
|
|
1250
|
+
object = headByte;
|
|
1251
|
+
} else if (headByte < 144) {
|
|
1252
|
+
const size = headByte - 128;
|
|
1253
|
+
if (size !== 0) {
|
|
1254
|
+
this.pushMapState(size);
|
|
1255
|
+
this.complete();
|
|
1256
|
+
continue DECODE;
|
|
1257
|
+
} else {
|
|
1258
|
+
object = {};
|
|
1259
|
+
}
|
|
1260
|
+
} else if (headByte < 160) {
|
|
1261
|
+
const size = headByte - 144;
|
|
1262
|
+
if (size !== 0) {
|
|
1263
|
+
this.pushArrayState(size);
|
|
1264
|
+
this.complete();
|
|
1265
|
+
continue DECODE;
|
|
1266
|
+
} else {
|
|
1267
|
+
object = [];
|
|
1268
|
+
}
|
|
1269
|
+
} else {
|
|
1270
|
+
const byteLength = headByte - 160;
|
|
1271
|
+
object = this.decodeString(byteLength, 0);
|
|
1272
|
+
}
|
|
1273
|
+
} else if (headByte === 192) {
|
|
1274
|
+
object = null;
|
|
1275
|
+
} else if (headByte === 194) {
|
|
1276
|
+
object = false;
|
|
1277
|
+
} else if (headByte === 195) {
|
|
1278
|
+
object = true;
|
|
1279
|
+
} else if (headByte === 202) {
|
|
1280
|
+
object = this.readF32();
|
|
1281
|
+
} else if (headByte === 203) {
|
|
1282
|
+
object = this.readF64();
|
|
1283
|
+
} else if (headByte === 204) {
|
|
1284
|
+
object = this.readU8();
|
|
1285
|
+
} else if (headByte === 205) {
|
|
1286
|
+
object = this.readU16();
|
|
1287
|
+
} else if (headByte === 206) {
|
|
1288
|
+
object = this.readU32();
|
|
1289
|
+
} else if (headByte === 207) {
|
|
1290
|
+
if (this.useBigInt64) {
|
|
1291
|
+
object = this.readU64AsBigInt();
|
|
1292
|
+
} else {
|
|
1293
|
+
object = this.readU64();
|
|
1294
|
+
}
|
|
1295
|
+
} else if (headByte === 208) {
|
|
1296
|
+
object = this.readI8();
|
|
1297
|
+
} else if (headByte === 209) {
|
|
1298
|
+
object = this.readI16();
|
|
1299
|
+
} else if (headByte === 210) {
|
|
1300
|
+
object = this.readI32();
|
|
1301
|
+
} else if (headByte === 211) {
|
|
1302
|
+
if (this.useBigInt64) {
|
|
1303
|
+
object = this.readI64AsBigInt();
|
|
1304
|
+
} else {
|
|
1305
|
+
object = this.readI64();
|
|
1306
|
+
}
|
|
1307
|
+
} else if (headByte === 217) {
|
|
1308
|
+
const byteLength = this.lookU8();
|
|
1309
|
+
object = this.decodeString(byteLength, 1);
|
|
1310
|
+
} else if (headByte === 218) {
|
|
1311
|
+
const byteLength = this.lookU16();
|
|
1312
|
+
object = this.decodeString(byteLength, 2);
|
|
1313
|
+
} else if (headByte === 219) {
|
|
1314
|
+
const byteLength = this.lookU32();
|
|
1315
|
+
object = this.decodeString(byteLength, 4);
|
|
1316
|
+
} else if (headByte === 220) {
|
|
1317
|
+
const size = this.readU16();
|
|
1318
|
+
if (size !== 0) {
|
|
1319
|
+
this.pushArrayState(size);
|
|
1320
|
+
this.complete();
|
|
1321
|
+
continue DECODE;
|
|
1322
|
+
} else {
|
|
1323
|
+
object = [];
|
|
1324
|
+
}
|
|
1325
|
+
} else if (headByte === 221) {
|
|
1326
|
+
const size = this.readU32();
|
|
1327
|
+
if (size !== 0) {
|
|
1328
|
+
this.pushArrayState(size);
|
|
1329
|
+
this.complete();
|
|
1330
|
+
continue DECODE;
|
|
1331
|
+
} else {
|
|
1332
|
+
object = [];
|
|
1333
|
+
}
|
|
1334
|
+
} else if (headByte === 222) {
|
|
1335
|
+
const size = this.readU16();
|
|
1336
|
+
if (size !== 0) {
|
|
1337
|
+
this.pushMapState(size);
|
|
1338
|
+
this.complete();
|
|
1339
|
+
continue DECODE;
|
|
1340
|
+
} else {
|
|
1341
|
+
object = {};
|
|
1342
|
+
}
|
|
1343
|
+
} else if (headByte === 223) {
|
|
1344
|
+
const size = this.readU32();
|
|
1345
|
+
if (size !== 0) {
|
|
1346
|
+
this.pushMapState(size);
|
|
1347
|
+
this.complete();
|
|
1348
|
+
continue DECODE;
|
|
1349
|
+
} else {
|
|
1350
|
+
object = {};
|
|
1351
|
+
}
|
|
1352
|
+
} else if (headByte === 196) {
|
|
1353
|
+
const size = this.lookU8();
|
|
1354
|
+
object = this.decodeBinary(size, 1);
|
|
1355
|
+
} else if (headByte === 197) {
|
|
1356
|
+
const size = this.lookU16();
|
|
1357
|
+
object = this.decodeBinary(size, 2);
|
|
1358
|
+
} else if (headByte === 198) {
|
|
1359
|
+
const size = this.lookU32();
|
|
1360
|
+
object = this.decodeBinary(size, 4);
|
|
1361
|
+
} else if (headByte === 212) {
|
|
1362
|
+
object = this.decodeExtension(1, 0);
|
|
1363
|
+
} else if (headByte === 213) {
|
|
1364
|
+
object = this.decodeExtension(2, 0);
|
|
1365
|
+
} else if (headByte === 214) {
|
|
1366
|
+
object = this.decodeExtension(4, 0);
|
|
1367
|
+
} else if (headByte === 215) {
|
|
1368
|
+
object = this.decodeExtension(8, 0);
|
|
1369
|
+
} else if (headByte === 216) {
|
|
1370
|
+
object = this.decodeExtension(16, 0);
|
|
1371
|
+
} else if (headByte === 199) {
|
|
1372
|
+
const size = this.lookU8();
|
|
1373
|
+
object = this.decodeExtension(size, 1);
|
|
1374
|
+
} else if (headByte === 200) {
|
|
1375
|
+
const size = this.lookU16();
|
|
1376
|
+
object = this.decodeExtension(size, 2);
|
|
1377
|
+
} else if (headByte === 201) {
|
|
1378
|
+
const size = this.lookU32();
|
|
1379
|
+
object = this.decodeExtension(size, 4);
|
|
1380
|
+
} else {
|
|
1381
|
+
throw new DecodeError_ts_1.DecodeError(`Unrecognized type byte: ${(0, prettyByte_ts_1.prettyByte)(headByte)}`);
|
|
1382
|
+
}
|
|
1383
|
+
this.complete();
|
|
1384
|
+
const stack = this.stack;
|
|
1385
|
+
while (stack.length > 0) {
|
|
1386
|
+
const state = stack.top();
|
|
1387
|
+
if (state.type === STATE_ARRAY) {
|
|
1388
|
+
state.array[state.position] = object;
|
|
1389
|
+
state.position++;
|
|
1390
|
+
if (state.position === state.size) {
|
|
1391
|
+
object = state.array;
|
|
1392
|
+
stack.release(state);
|
|
1393
|
+
} else {
|
|
1394
|
+
continue DECODE;
|
|
1395
|
+
}
|
|
1396
|
+
} else if (state.type === STATE_MAP_KEY) {
|
|
1397
|
+
if (object === "__proto__") {
|
|
1398
|
+
throw new DecodeError_ts_1.DecodeError("The key __proto__ is not allowed");
|
|
1399
|
+
}
|
|
1400
|
+
state.key = this.mapKeyConverter(object);
|
|
1401
|
+
state.type = STATE_MAP_VALUE;
|
|
1402
|
+
continue DECODE;
|
|
1403
|
+
} else {
|
|
1404
|
+
state.map[state.key] = object;
|
|
1405
|
+
state.readCount++;
|
|
1406
|
+
if (state.readCount === state.size) {
|
|
1407
|
+
object = state.map;
|
|
1408
|
+
stack.release(state);
|
|
1409
|
+
} else {
|
|
1410
|
+
state.key = null;
|
|
1411
|
+
state.type = STATE_MAP_KEY;
|
|
1412
|
+
continue DECODE;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
return object;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
readHeadByte() {
|
|
1420
|
+
if (this.headByte === HEAD_BYTE_REQUIRED) {
|
|
1421
|
+
this.headByte = this.readU8();
|
|
1422
|
+
}
|
|
1423
|
+
return this.headByte;
|
|
1424
|
+
}
|
|
1425
|
+
complete() {
|
|
1426
|
+
this.headByte = HEAD_BYTE_REQUIRED;
|
|
1427
|
+
}
|
|
1428
|
+
readArraySize() {
|
|
1429
|
+
const headByte = this.readHeadByte();
|
|
1430
|
+
switch (headByte) {
|
|
1431
|
+
case 220:
|
|
1432
|
+
return this.readU16();
|
|
1433
|
+
case 221:
|
|
1434
|
+
return this.readU32();
|
|
1435
|
+
default: {
|
|
1436
|
+
if (headByte < 160) {
|
|
1437
|
+
return headByte - 144;
|
|
1438
|
+
} else {
|
|
1439
|
+
throw new DecodeError_ts_1.DecodeError(`Unrecognized array type byte: ${(0, prettyByte_ts_1.prettyByte)(headByte)}`);
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
pushMapState(size) {
|
|
1445
|
+
if (size > this.maxMapLength) {
|
|
1446
|
+
throw new DecodeError_ts_1.DecodeError(`Max length exceeded: map length (${size}) > maxMapLengthLength (${this.maxMapLength})`);
|
|
1447
|
+
}
|
|
1448
|
+
this.stack.pushMapState(size);
|
|
1449
|
+
}
|
|
1450
|
+
pushArrayState(size) {
|
|
1451
|
+
if (size > this.maxArrayLength) {
|
|
1452
|
+
throw new DecodeError_ts_1.DecodeError(`Max length exceeded: array length (${size}) > maxArrayLength (${this.maxArrayLength})`);
|
|
1453
|
+
}
|
|
1454
|
+
this.stack.pushArrayState(size);
|
|
1455
|
+
}
|
|
1456
|
+
decodeString(byteLength, headerOffset) {
|
|
1457
|
+
if (!this.rawStrings || this.stateIsMapKey()) {
|
|
1458
|
+
return this.decodeUtf8String(byteLength, headerOffset);
|
|
1459
|
+
}
|
|
1460
|
+
return this.decodeBinary(byteLength, headerOffset);
|
|
1461
|
+
}
|
|
1462
|
+
/**
|
|
1463
|
+
* @throws {@link RangeError}
|
|
1464
|
+
*/
|
|
1465
|
+
decodeUtf8String(byteLength, headerOffset) {
|
|
1466
|
+
if (byteLength > this.maxStrLength) {
|
|
1467
|
+
throw new DecodeError_ts_1.DecodeError(`Max length exceeded: UTF-8 byte length (${byteLength}) > maxStrLength (${this.maxStrLength})`);
|
|
1468
|
+
}
|
|
1469
|
+
if (this.bytes.byteLength < this.pos + headerOffset + byteLength) {
|
|
1470
|
+
throw MORE_DATA;
|
|
1471
|
+
}
|
|
1472
|
+
const offset = this.pos + headerOffset;
|
|
1473
|
+
let object;
|
|
1474
|
+
if (this.stateIsMapKey() && this.keyDecoder?.canBeCached(byteLength)) {
|
|
1475
|
+
object = this.keyDecoder.decode(this.bytes, offset, byteLength);
|
|
1476
|
+
} else {
|
|
1477
|
+
object = (0, utf8_ts_1.utf8Decode)(this.bytes, offset, byteLength);
|
|
1478
|
+
}
|
|
1479
|
+
this.pos += headerOffset + byteLength;
|
|
1480
|
+
return object;
|
|
1481
|
+
}
|
|
1482
|
+
stateIsMapKey() {
|
|
1483
|
+
if (this.stack.length > 0) {
|
|
1484
|
+
const state = this.stack.top();
|
|
1485
|
+
return state.type === STATE_MAP_KEY;
|
|
1486
|
+
}
|
|
1487
|
+
return false;
|
|
1488
|
+
}
|
|
1489
|
+
/**
|
|
1490
|
+
* @throws {@link RangeError}
|
|
1491
|
+
*/
|
|
1492
|
+
decodeBinary(byteLength, headOffset) {
|
|
1493
|
+
if (byteLength > this.maxBinLength) {
|
|
1494
|
+
throw new DecodeError_ts_1.DecodeError(`Max length exceeded: bin length (${byteLength}) > maxBinLength (${this.maxBinLength})`);
|
|
1495
|
+
}
|
|
1496
|
+
if (!this.hasRemaining(byteLength + headOffset)) {
|
|
1497
|
+
throw MORE_DATA;
|
|
1498
|
+
}
|
|
1499
|
+
const offset = this.pos + headOffset;
|
|
1500
|
+
const object = this.bytes.subarray(offset, offset + byteLength);
|
|
1501
|
+
this.pos += headOffset + byteLength;
|
|
1502
|
+
return object;
|
|
1503
|
+
}
|
|
1504
|
+
decodeExtension(size, headOffset) {
|
|
1505
|
+
if (size > this.maxExtLength) {
|
|
1506
|
+
throw new DecodeError_ts_1.DecodeError(`Max length exceeded: ext length (${size}) > maxExtLength (${this.maxExtLength})`);
|
|
1507
|
+
}
|
|
1508
|
+
const extType = this.view.getInt8(this.pos + headOffset);
|
|
1509
|
+
const data = this.decodeBinary(
|
|
1510
|
+
size,
|
|
1511
|
+
headOffset + 1
|
|
1512
|
+
/* extType */
|
|
1513
|
+
);
|
|
1514
|
+
return this.extensionCodec.decode(data, extType, this.context);
|
|
1515
|
+
}
|
|
1516
|
+
lookU8() {
|
|
1517
|
+
return this.view.getUint8(this.pos);
|
|
1518
|
+
}
|
|
1519
|
+
lookU16() {
|
|
1520
|
+
return this.view.getUint16(this.pos);
|
|
1521
|
+
}
|
|
1522
|
+
lookU32() {
|
|
1523
|
+
return this.view.getUint32(this.pos);
|
|
1524
|
+
}
|
|
1525
|
+
readU8() {
|
|
1526
|
+
const value = this.view.getUint8(this.pos);
|
|
1527
|
+
this.pos++;
|
|
1528
|
+
return value;
|
|
1529
|
+
}
|
|
1530
|
+
readI8() {
|
|
1531
|
+
const value = this.view.getInt8(this.pos);
|
|
1532
|
+
this.pos++;
|
|
1533
|
+
return value;
|
|
1534
|
+
}
|
|
1535
|
+
readU16() {
|
|
1536
|
+
const value = this.view.getUint16(this.pos);
|
|
1537
|
+
this.pos += 2;
|
|
1538
|
+
return value;
|
|
1539
|
+
}
|
|
1540
|
+
readI16() {
|
|
1541
|
+
const value = this.view.getInt16(this.pos);
|
|
1542
|
+
this.pos += 2;
|
|
1543
|
+
return value;
|
|
1544
|
+
}
|
|
1545
|
+
readU32() {
|
|
1546
|
+
const value = this.view.getUint32(this.pos);
|
|
1547
|
+
this.pos += 4;
|
|
1548
|
+
return value;
|
|
1549
|
+
}
|
|
1550
|
+
readI32() {
|
|
1551
|
+
const value = this.view.getInt32(this.pos);
|
|
1552
|
+
this.pos += 4;
|
|
1553
|
+
return value;
|
|
1554
|
+
}
|
|
1555
|
+
readU64() {
|
|
1556
|
+
const value = (0, int_ts_1.getUint64)(this.view, this.pos);
|
|
1557
|
+
this.pos += 8;
|
|
1558
|
+
return value;
|
|
1559
|
+
}
|
|
1560
|
+
readI64() {
|
|
1561
|
+
const value = (0, int_ts_1.getInt64)(this.view, this.pos);
|
|
1562
|
+
this.pos += 8;
|
|
1563
|
+
return value;
|
|
1564
|
+
}
|
|
1565
|
+
readU64AsBigInt() {
|
|
1566
|
+
const value = this.view.getBigUint64(this.pos);
|
|
1567
|
+
this.pos += 8;
|
|
1568
|
+
return value;
|
|
1569
|
+
}
|
|
1570
|
+
readI64AsBigInt() {
|
|
1571
|
+
const value = this.view.getBigInt64(this.pos);
|
|
1572
|
+
this.pos += 8;
|
|
1573
|
+
return value;
|
|
1574
|
+
}
|
|
1575
|
+
readF32() {
|
|
1576
|
+
const value = this.view.getFloat32(this.pos);
|
|
1577
|
+
this.pos += 4;
|
|
1578
|
+
return value;
|
|
1579
|
+
}
|
|
1580
|
+
readF64() {
|
|
1581
|
+
const value = this.view.getFloat64(this.pos);
|
|
1582
|
+
this.pos += 8;
|
|
1583
|
+
return value;
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
exports2.Decoder = Decoder;
|
|
1587
|
+
}
|
|
1588
|
+
});
|
|
1589
|
+
|
|
1590
|
+
// node_modules/@msgpack/msgpack/dist.cjs/decode.cjs
|
|
1591
|
+
var require_decode = __commonJS({
|
|
1592
|
+
"node_modules/@msgpack/msgpack/dist.cjs/decode.cjs"(exports2) {
|
|
1593
|
+
"use strict";
|
|
1594
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1595
|
+
exports2.decode = decode2;
|
|
1596
|
+
exports2.decodeMulti = decodeMulti;
|
|
1597
|
+
var Decoder_ts_1 = require_Decoder();
|
|
1598
|
+
function decode2(buffer, options) {
|
|
1599
|
+
const decoder = new Decoder_ts_1.Decoder(options);
|
|
1600
|
+
return decoder.decode(buffer);
|
|
1601
|
+
}
|
|
1602
|
+
function decodeMulti(buffer, options) {
|
|
1603
|
+
const decoder = new Decoder_ts_1.Decoder(options);
|
|
1604
|
+
return decoder.decodeMulti(buffer);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
});
|
|
1608
|
+
|
|
1609
|
+
// node_modules/@msgpack/msgpack/dist.cjs/utils/stream.cjs
|
|
1610
|
+
var require_stream = __commonJS({
|
|
1611
|
+
"node_modules/@msgpack/msgpack/dist.cjs/utils/stream.cjs"(exports2) {
|
|
1612
|
+
"use strict";
|
|
1613
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1614
|
+
exports2.isAsyncIterable = isAsyncIterable;
|
|
1615
|
+
exports2.asyncIterableFromStream = asyncIterableFromStream;
|
|
1616
|
+
exports2.ensureAsyncIterable = ensureAsyncIterable;
|
|
1617
|
+
function isAsyncIterable(object) {
|
|
1618
|
+
return object[Symbol.asyncIterator] != null;
|
|
1619
|
+
}
|
|
1620
|
+
async function* asyncIterableFromStream(stream) {
|
|
1621
|
+
const reader = stream.getReader();
|
|
1622
|
+
try {
|
|
1623
|
+
while (true) {
|
|
1624
|
+
const { done, value } = await reader.read();
|
|
1625
|
+
if (done) {
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
yield value;
|
|
1629
|
+
}
|
|
1630
|
+
} finally {
|
|
1631
|
+
reader.releaseLock();
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
function ensureAsyncIterable(streamLike) {
|
|
1635
|
+
if (isAsyncIterable(streamLike)) {
|
|
1636
|
+
return streamLike;
|
|
1637
|
+
} else {
|
|
1638
|
+
return asyncIterableFromStream(streamLike);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
});
|
|
1643
|
+
|
|
1644
|
+
// node_modules/@msgpack/msgpack/dist.cjs/decodeAsync.cjs
|
|
1645
|
+
var require_decodeAsync = __commonJS({
|
|
1646
|
+
"node_modules/@msgpack/msgpack/dist.cjs/decodeAsync.cjs"(exports2) {
|
|
1647
|
+
"use strict";
|
|
1648
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1649
|
+
exports2.decodeAsync = decodeAsync;
|
|
1650
|
+
exports2.decodeArrayStream = decodeArrayStream;
|
|
1651
|
+
exports2.decodeMultiStream = decodeMultiStream;
|
|
1652
|
+
var Decoder_ts_1 = require_Decoder();
|
|
1653
|
+
var stream_ts_1 = require_stream();
|
|
1654
|
+
async function decodeAsync(streamLike, options) {
|
|
1655
|
+
const stream = (0, stream_ts_1.ensureAsyncIterable)(streamLike);
|
|
1656
|
+
const decoder = new Decoder_ts_1.Decoder(options);
|
|
1657
|
+
return decoder.decodeAsync(stream);
|
|
1658
|
+
}
|
|
1659
|
+
function decodeArrayStream(streamLike, options) {
|
|
1660
|
+
const stream = (0, stream_ts_1.ensureAsyncIterable)(streamLike);
|
|
1661
|
+
const decoder = new Decoder_ts_1.Decoder(options);
|
|
1662
|
+
return decoder.decodeArrayStream(stream);
|
|
1663
|
+
}
|
|
1664
|
+
function decodeMultiStream(streamLike, options) {
|
|
1665
|
+
const stream = (0, stream_ts_1.ensureAsyncIterable)(streamLike);
|
|
1666
|
+
const decoder = new Decoder_ts_1.Decoder(options);
|
|
1667
|
+
return decoder.decodeStream(stream);
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
|
|
1672
|
+
// node_modules/@msgpack/msgpack/dist.cjs/index.cjs
|
|
1673
|
+
var require_dist = __commonJS({
|
|
1674
|
+
"node_modules/@msgpack/msgpack/dist.cjs/index.cjs"(exports2) {
|
|
1675
|
+
"use strict";
|
|
1676
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
1677
|
+
exports2.decodeTimestampExtension = exports2.encodeTimestampExtension = exports2.decodeTimestampToTimeSpec = exports2.encodeTimeSpecToTimestamp = exports2.encodeDateToTimeSpec = exports2.EXT_TIMESTAMP = exports2.ExtData = exports2.ExtensionCodec = exports2.Encoder = exports2.DecodeError = exports2.Decoder = exports2.decodeMultiStream = exports2.decodeArrayStream = exports2.decodeAsync = exports2.decodeMulti = exports2.decode = exports2.encode = void 0;
|
|
1678
|
+
var encode_ts_1 = require_encode();
|
|
1679
|
+
Object.defineProperty(exports2, "encode", { enumerable: true, get: function() {
|
|
1680
|
+
return encode_ts_1.encode;
|
|
1681
|
+
} });
|
|
1682
|
+
var decode_ts_1 = require_decode();
|
|
1683
|
+
Object.defineProperty(exports2, "decode", { enumerable: true, get: function() {
|
|
1684
|
+
return decode_ts_1.decode;
|
|
1685
|
+
} });
|
|
1686
|
+
Object.defineProperty(exports2, "decodeMulti", { enumerable: true, get: function() {
|
|
1687
|
+
return decode_ts_1.decodeMulti;
|
|
1688
|
+
} });
|
|
1689
|
+
var decodeAsync_ts_1 = require_decodeAsync();
|
|
1690
|
+
Object.defineProperty(exports2, "decodeAsync", { enumerable: true, get: function() {
|
|
1691
|
+
return decodeAsync_ts_1.decodeAsync;
|
|
1692
|
+
} });
|
|
1693
|
+
Object.defineProperty(exports2, "decodeArrayStream", { enumerable: true, get: function() {
|
|
1694
|
+
return decodeAsync_ts_1.decodeArrayStream;
|
|
1695
|
+
} });
|
|
1696
|
+
Object.defineProperty(exports2, "decodeMultiStream", { enumerable: true, get: function() {
|
|
1697
|
+
return decodeAsync_ts_1.decodeMultiStream;
|
|
1698
|
+
} });
|
|
1699
|
+
var Decoder_ts_1 = require_Decoder();
|
|
1700
|
+
Object.defineProperty(exports2, "Decoder", { enumerable: true, get: function() {
|
|
1701
|
+
return Decoder_ts_1.Decoder;
|
|
1702
|
+
} });
|
|
1703
|
+
var DecodeError_ts_1 = require_DecodeError();
|
|
1704
|
+
Object.defineProperty(exports2, "DecodeError", { enumerable: true, get: function() {
|
|
1705
|
+
return DecodeError_ts_1.DecodeError;
|
|
1706
|
+
} });
|
|
1707
|
+
var Encoder_ts_1 = require_Encoder();
|
|
1708
|
+
Object.defineProperty(exports2, "Encoder", { enumerable: true, get: function() {
|
|
1709
|
+
return Encoder_ts_1.Encoder;
|
|
1710
|
+
} });
|
|
1711
|
+
var ExtensionCodec_ts_1 = require_ExtensionCodec();
|
|
1712
|
+
Object.defineProperty(exports2, "ExtensionCodec", { enumerable: true, get: function() {
|
|
1713
|
+
return ExtensionCodec_ts_1.ExtensionCodec;
|
|
1714
|
+
} });
|
|
1715
|
+
var ExtData_ts_1 = require_ExtData();
|
|
1716
|
+
Object.defineProperty(exports2, "ExtData", { enumerable: true, get: function() {
|
|
1717
|
+
return ExtData_ts_1.ExtData;
|
|
1718
|
+
} });
|
|
1719
|
+
var timestamp_ts_1 = require_timestamp();
|
|
1720
|
+
Object.defineProperty(exports2, "EXT_TIMESTAMP", { enumerable: true, get: function() {
|
|
1721
|
+
return timestamp_ts_1.EXT_TIMESTAMP;
|
|
1722
|
+
} });
|
|
1723
|
+
Object.defineProperty(exports2, "encodeDateToTimeSpec", { enumerable: true, get: function() {
|
|
1724
|
+
return timestamp_ts_1.encodeDateToTimeSpec;
|
|
1725
|
+
} });
|
|
1726
|
+
Object.defineProperty(exports2, "encodeTimeSpecToTimestamp", { enumerable: true, get: function() {
|
|
1727
|
+
return timestamp_ts_1.encodeTimeSpecToTimestamp;
|
|
1728
|
+
} });
|
|
1729
|
+
Object.defineProperty(exports2, "decodeTimestampToTimeSpec", { enumerable: true, get: function() {
|
|
1730
|
+
return timestamp_ts_1.decodeTimestampToTimeSpec;
|
|
1731
|
+
} });
|
|
1732
|
+
Object.defineProperty(exports2, "encodeTimestampExtension", { enumerable: true, get: function() {
|
|
1733
|
+
return timestamp_ts_1.encodeTimestampExtension;
|
|
1734
|
+
} });
|
|
1735
|
+
Object.defineProperty(exports2, "decodeTimestampExtension", { enumerable: true, get: function() {
|
|
1736
|
+
return timestamp_ts_1.decodeTimestampExtension;
|
|
1737
|
+
} });
|
|
1738
|
+
}
|
|
1739
|
+
});
|
|
1740
|
+
|
|
1741
|
+
// packages/framework-codec-msgpack/src/framework.ts
|
|
1742
|
+
var framework_exports = {};
|
|
1743
|
+
__export(framework_exports, {
|
|
1744
|
+
ZLINK_MESSAGEPACK_CONTENT_TYPE: () => ZLINK_MESSAGEPACK_CONTENT_TYPE,
|
|
1745
|
+
createMessagePackSerializer: () => createMessagePackSerializer,
|
|
1746
|
+
zlinkMessagePackCodec: () => zlinkMessagePackCodec
|
|
1747
|
+
});
|
|
1748
|
+
module.exports = __toCommonJS(framework_exports);
|
|
1749
|
+
var import_framework = require("@zlink-systems/framework");
|
|
1750
|
+
|
|
1751
|
+
// packages/framework-codec-msgpack/src/index.ts
|
|
1752
|
+
var msgpack = __toESM(require_dist());
|
|
1753
|
+
var import_stream_wire = require("@zlink-systems/stream-wire");
|
|
1754
|
+
var ZLINK_MESSAGEPACK_CONTENT_TYPE = "application/x-msgpack";
|
|
1755
|
+
var zlinkStreamMessagePackCodec = {
|
|
1756
|
+
encode: toMsgPack,
|
|
1757
|
+
decode: fromMsgPack
|
|
1758
|
+
};
|
|
1759
|
+
function toMsgPack(value, messageType) {
|
|
1760
|
+
return {
|
|
1761
|
+
codec: import_stream_wire.ZlinkStreamCodec.MessagePack,
|
|
1762
|
+
payload: encodeMessagePack(value),
|
|
1763
|
+
messageType: messageType ?? inferMessageType(value)
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
function fromMsgPack(payload) {
|
|
1767
|
+
ensureMessagePack(payload);
|
|
1768
|
+
return decodeMessagePack(payload.payload);
|
|
1769
|
+
}
|
|
1770
|
+
function encodeMessagePack(value) {
|
|
1771
|
+
return msgpack.encode(value);
|
|
1772
|
+
}
|
|
1773
|
+
function decodeMessagePack(value) {
|
|
1774
|
+
return msgpack.decode(value);
|
|
1775
|
+
}
|
|
1776
|
+
function ensureMessagePack(payload) {
|
|
1777
|
+
if (payload.codec !== import_stream_wire.ZlinkStreamCodec.MessagePack) {
|
|
1778
|
+
throw new Error(`Stream payload codec is ${payload.codec}, not MessagePack.`);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
function inferMessageType(value) {
|
|
1782
|
+
if (value === null || value === void 0) {
|
|
1783
|
+
return void 0;
|
|
1784
|
+
}
|
|
1785
|
+
const constructor = Object.getPrototypeOf(value)?.constructor;
|
|
1786
|
+
return constructor === Object ? void 0 : constructor;
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
// packages/framework-codec-msgpack/src/framework.ts
|
|
1790
|
+
function zlinkMessagePackCodec() {
|
|
1791
|
+
return {
|
|
1792
|
+
register(codecs) {
|
|
1793
|
+
codecs.addSerializer(ZLINK_MESSAGEPACK_CONTENT_TYPE, createMessagePackSerializer());
|
|
1794
|
+
codecs.addStreamCodec(ZLINK_MESSAGEPACK_CONTENT_TYPE, this);
|
|
1795
|
+
},
|
|
1796
|
+
encode: zlinkStreamMessagePackCodec.encode,
|
|
1797
|
+
decode: zlinkStreamMessagePackCodec.decode
|
|
1798
|
+
};
|
|
1799
|
+
}
|
|
1800
|
+
function createMessagePackSerializer() {
|
|
1801
|
+
return {
|
|
1802
|
+
serialize(value) {
|
|
1803
|
+
return import_framework.ZLinkEncodedPayload.from(encodeMessagePack(value));
|
|
1804
|
+
},
|
|
1805
|
+
deserialize(payload) {
|
|
1806
|
+
return decodeMessagePack(payload.data());
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
}
|
|
1810
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1811
|
+
0 && (module.exports = {
|
|
1812
|
+
ZLINK_MESSAGEPACK_CONTENT_TYPE,
|
|
1813
|
+
createMessagePackSerializer,
|
|
1814
|
+
zlinkMessagePackCodec
|
|
1815
|
+
});
|