likec4 1.48.0 → 1.49.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.
Files changed (113) hide show
  1. package/README.md +11 -1
  2. package/__app__/src/likec4.js +5595 -4127
  3. package/__app__/src/routes/index.js +3 -153
  4. package/__app__/src/routes/projects.js +21 -1087
  5. package/__app__/src/routes/single.js +1221 -16
  6. package/__app__/src/style.css +1 -1
  7. package/__app__/src/vendors.js +3507 -894
  8. package/__app__/src/webcomponent.js +1 -1
  9. package/config/schema.json +155 -143
  10. package/dist/THIRD-PARTY-LICENSES.md +1739 -0
  11. package/dist/_chunks/GraphvizBinaryAdapter.mjs +72 -0
  12. package/dist/_chunks/filenames.mjs +14 -0
  13. package/dist/_chunks/index.d.mts +224 -129
  14. package/dist/_chunks/index2.d.mts +2033 -1908
  15. package/dist/_chunks/libs/@chevrotain/gast.mjs +1 -3969
  16. package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -785
  17. package/dist/_chunks/libs/@chevrotain/utils.mjs +1 -37
  18. package/dist/_chunks/libs/@hono/mcp.mjs +34 -0
  19. package/dist/_chunks/libs/@hono/node-server.mjs +1 -436
  20. package/dist/_chunks/libs/@logtape/logtape.d.mts +741 -0
  21. package/dist/_chunks/libs/@logtape/logtape.mjs +6 -1354
  22. package/dist/_chunks/libs/@lume/kiwi.mjs +1 -1355
  23. package/dist/_chunks/libs/@modelcontextprotocol/sdk.d.mts +14 -14
  24. package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +12 -25105
  25. package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -1503
  26. package/dist/_chunks/libs/@nanostores/react.mjs +1 -30
  27. package/dist/_chunks/libs/@smithy/util-base64.mjs +1 -100
  28. package/dist/_chunks/libs/ajv.mjs +1 -777
  29. package/dist/_chunks/libs/atomically.mjs +1 -362
  30. package/dist/_chunks/libs/birpc.mjs +1 -201
  31. package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -850
  32. package/dist/_chunks/libs/chevrotain.mjs +55 -6229
  33. package/dist/_chunks/libs/conf.mjs +1 -2258
  34. package/dist/_chunks/libs/defu.mjs +1 -42
  35. package/dist/_chunks/libs/esm-env.mjs +1 -5
  36. package/dist/_chunks/libs/eventemitter3.mjs +1 -243
  37. package/dist/_chunks/libs/fast-equals.mjs +1 -446
  38. package/dist/_chunks/libs/find-up-simple.mjs +1 -24
  39. package/dist/_chunks/libs/get-port.mjs +1 -107
  40. package/dist/_chunks/libs/is-docker.mjs +1 -26
  41. package/dist/_chunks/libs/is-error-instance.mjs +1 -26
  42. package/dist/_chunks/libs/is-inside-container.mjs +1 -20
  43. package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
  44. package/dist/_chunks/libs/isexe.mjs +1 -127
  45. package/dist/_chunks/libs/json5.mjs +14 -959
  46. package/dist/_chunks/libs/khroma.mjs +1 -605
  47. package/dist/_chunks/libs/ky.mjs +2 -807
  48. package/dist/_chunks/libs/langium.d.mts +2880 -2844
  49. package/dist/_chunks/libs/langium.mjs +32 -20351
  50. package/dist/_chunks/libs/merge-error-cause.mjs +2 -746
  51. package/dist/_chunks/libs/nanostores.mjs +1 -198
  52. package/dist/_chunks/libs/p-limit.mjs +1 -120
  53. package/dist/_chunks/libs/p-queue.mjs +1 -449
  54. package/dist/_chunks/libs/package-manager-detector.mjs +1 -559
  55. package/dist/_chunks/libs/package-up.mjs +1 -10
  56. package/dist/_chunks/libs/parse-ms.mjs +1 -36
  57. package/dist/_chunks/libs/pathe.mjs +1 -0
  58. package/dist/_chunks/libs/picomatch.mjs +1 -1673
  59. package/dist/_chunks/libs/pretty-ms.mjs +1 -80
  60. package/dist/_chunks/libs/remeda.mjs +1 -690
  61. package/dist/_chunks/libs/safe-stringify.mjs +1 -21
  62. package/dist/_chunks/libs/strip-indent.mjs +1 -15
  63. package/dist/_chunks/libs/tinyrainbow.mjs +1 -88
  64. package/dist/_chunks/libs/ts-graphviz.mjs +4 -725
  65. package/dist/_chunks/libs/ufo.mjs +1 -240
  66. package/dist/_chunks/libs/which.mjs +1 -84
  67. package/dist/_chunks/libs/word-wrap.mjs +12 -43
  68. package/dist/_chunks/node.mjs +481 -0
  69. package/dist/_chunks/plugin.mjs +98 -772
  70. package/dist/_chunks/rolldown-runtime.mjs +1 -48
  71. package/dist/_chunks/sequence-view.mjs +1 -575
  72. package/dist/cli/index.mjs +127 -1846
  73. package/dist/config/index.d.mts +2 -2
  74. package/dist/config/index.mjs +1 -6
  75. package/dist/index.d.mts +148 -7
  76. package/dist/index.mjs +1 -21
  77. package/dist/model/builder.mjs +1 -3
  78. package/dist/model/index.d.mts +57 -3
  79. package/dist/model/index.mjs +1 -5
  80. package/dist/vite-plugin/index.d.mts +4 -3
  81. package/dist/vite-plugin/index.mjs +1 -22
  82. package/dist/vite-plugin/internal.d.mts +5 -5
  83. package/dist/vite-plugin/internal.mjs +1 -68
  84. package/package.json +60 -41
  85. package/react/{index.d.ts → index.d.mts} +112 -70
  86. package/react/{index.js → index.mjs} +21361 -22064
  87. package/react/package.json +2 -5
  88. package/vite-plugin-modules.d.ts +5 -5
  89. package/dist/_chunks/LikeC4.d.mts +0 -121
  90. package/dist/_chunks/LikeC4.mjs +0 -202
  91. package/dist/_chunks/config-app.prod.d.mts +0 -18
  92. package/dist/_chunks/config-app.prod.mjs +0 -188
  93. package/dist/_chunks/config-webcomponent.prod.mjs +0 -71
  94. package/dist/_chunks/define-config.mjs +0 -409
  95. package/dist/_chunks/index3.d.mts +0 -60
  96. package/dist/_chunks/index4.d.mts +0 -1
  97. package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +0 -10
  98. package/dist/_chunks/libs/hono.mjs +0 -1829
  99. package/dist/_chunks/libs/nanoid.mjs +0 -29
  100. package/dist/_chunks/model.mjs +0 -12
  101. package/dist/_chunks/module.d.mts +0 -71
  102. package/dist/_chunks/module.mjs +0 -18657
  103. package/dist/_chunks/vite-build.mjs +0 -69
  104. package/dist/_chunks/vite-dev.mjs +0 -79
  105. package/dist/_chunks/vite-preview.mjs +0 -27
  106. package/dist/language/module.d.mts +0 -5
  107. package/dist/language/module.mjs +0 -20
  108. package/dist/vite/vite-build.d.mts +0 -26
  109. package/dist/vite/vite-build.mjs +0 -27
  110. package/dist/vite/vite-dev.d.mts +0 -34
  111. package/dist/vite/vite-dev.mjs +0 -29
  112. package/dist/vite/vite-preview.d.mts +0 -20
  113. package/dist/vite/vite-preview.mjs +0 -26
@@ -1,1503 +1 @@
1
- import { t as __commonJSMin } from "../../rolldown-runtime.mjs";
2
-
3
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/utils/utf8.cjs
4
- var require_utf8 = /* @__PURE__ */ __commonJSMin(((exports) => {
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.utf8Count = utf8Count;
7
- exports.utf8EncodeJs = utf8EncodeJs;
8
- exports.utf8EncodeTE = utf8EncodeTE;
9
- exports.utf8Encode = utf8Encode;
10
- exports.utf8DecodeJs = utf8DecodeJs;
11
- exports.utf8DecodeTD = utf8DecodeTD;
12
- exports.utf8Decode = utf8Decode;
13
- function utf8Count(str) {
14
- const strLength = str.length;
15
- let byteLength = 0;
16
- let pos = 0;
17
- while (pos < strLength) {
18
- let value = str.charCodeAt(pos++);
19
- if ((value & 4294967168) === 0) {
20
- byteLength++;
21
- continue;
22
- } else if ((value & 4294965248) === 0) byteLength += 2;
23
- else {
24
- if (value >= 55296 && value <= 56319) {
25
- if (pos < strLength) {
26
- const extra = str.charCodeAt(pos);
27
- if ((extra & 64512) === 56320) {
28
- ++pos;
29
- value = ((value & 1023) << 10) + (extra & 1023) + 65536;
30
- }
31
- }
32
- }
33
- if ((value & 4294901760) === 0) byteLength += 3;
34
- else byteLength += 4;
35
- }
36
- }
37
- return byteLength;
38
- }
39
- function utf8EncodeJs(str, output, outputOffset) {
40
- const strLength = str.length;
41
- let offset = outputOffset;
42
- let pos = 0;
43
- while (pos < strLength) {
44
- let value = str.charCodeAt(pos++);
45
- if ((value & 4294967168) === 0) {
46
- output[offset++] = value;
47
- continue;
48
- } else if ((value & 4294965248) === 0) output[offset++] = value >> 6 & 31 | 192;
49
- else {
50
- if (value >= 55296 && value <= 56319) {
51
- if (pos < strLength) {
52
- const extra = str.charCodeAt(pos);
53
- if ((extra & 64512) === 56320) {
54
- ++pos;
55
- value = ((value & 1023) << 10) + (extra & 1023) + 65536;
56
- }
57
- }
58
- }
59
- if ((value & 4294901760) === 0) {
60
- output[offset++] = value >> 12 & 15 | 224;
61
- output[offset++] = value >> 6 & 63 | 128;
62
- } else {
63
- output[offset++] = value >> 18 & 7 | 240;
64
- output[offset++] = value >> 12 & 63 | 128;
65
- output[offset++] = value >> 6 & 63 | 128;
66
- }
67
- }
68
- output[offset++] = value & 63 | 128;
69
- }
70
- }
71
- const sharedTextEncoder = new TextEncoder();
72
- const TEXT_ENCODER_THRESHOLD = 50;
73
- function utf8EncodeTE(str, output, outputOffset) {
74
- sharedTextEncoder.encodeInto(str, output.subarray(outputOffset));
75
- }
76
- function utf8Encode(str, output, outputOffset) {
77
- if (str.length > TEXT_ENCODER_THRESHOLD) utf8EncodeTE(str, output, outputOffset);
78
- else utf8EncodeJs(str, output, outputOffset);
79
- }
80
- const CHUNK_SIZE = 4096;
81
- function utf8DecodeJs(bytes, inputOffset, byteLength) {
82
- let offset = inputOffset;
83
- const end = offset + byteLength;
84
- const units = [];
85
- let result = "";
86
- while (offset < end) {
87
- const byte1 = bytes[offset++];
88
- if ((byte1 & 128) === 0) units.push(byte1);
89
- else if ((byte1 & 224) === 192) {
90
- const byte2 = bytes[offset++] & 63;
91
- units.push((byte1 & 31) << 6 | byte2);
92
- } else if ((byte1 & 240) === 224) {
93
- const byte2 = bytes[offset++] & 63;
94
- const byte3 = bytes[offset++] & 63;
95
- units.push((byte1 & 31) << 12 | byte2 << 6 | byte3);
96
- } else if ((byte1 & 248) === 240) {
97
- const byte2 = bytes[offset++] & 63;
98
- const byte3 = bytes[offset++] & 63;
99
- const byte4 = bytes[offset++] & 63;
100
- let unit = (byte1 & 7) << 18 | byte2 << 12 | byte3 << 6 | byte4;
101
- if (unit > 65535) {
102
- unit -= 65536;
103
- units.push(unit >>> 10 & 1023 | 55296);
104
- unit = 56320 | unit & 1023;
105
- }
106
- units.push(unit);
107
- } else units.push(byte1);
108
- if (units.length >= CHUNK_SIZE) {
109
- result += String.fromCharCode(...units);
110
- units.length = 0;
111
- }
112
- }
113
- if (units.length > 0) result += String.fromCharCode(...units);
114
- return result;
115
- }
116
- const sharedTextDecoder = new TextDecoder();
117
- const TEXT_DECODER_THRESHOLD = 200;
118
- function utf8DecodeTD(bytes, inputOffset, byteLength) {
119
- const stringBytes = bytes.subarray(inputOffset, inputOffset + byteLength);
120
- return sharedTextDecoder.decode(stringBytes);
121
- }
122
- function utf8Decode(bytes, inputOffset, byteLength) {
123
- if (byteLength > TEXT_DECODER_THRESHOLD) return utf8DecodeTD(bytes, inputOffset, byteLength);
124
- else return utf8DecodeJs(bytes, inputOffset, byteLength);
125
- }
126
- }));
127
-
128
- //#endregion
129
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/ExtData.cjs
130
- var require_ExtData = /* @__PURE__ */ __commonJSMin(((exports) => {
131
- Object.defineProperty(exports, "__esModule", { value: true });
132
- exports.ExtData = void 0;
133
- /**
134
- * ExtData is used to handle Extension Types that are not registered to ExtensionCodec.
135
- */
136
- var ExtData = class {
137
- constructor(type, data) {
138
- this.type = type;
139
- this.data = data;
140
- }
141
- };
142
- exports.ExtData = ExtData;
143
- }));
144
-
145
- //#endregion
146
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/DecodeError.cjs
147
- var require_DecodeError = /* @__PURE__ */ __commonJSMin(((exports) => {
148
- Object.defineProperty(exports, "__esModule", { value: true });
149
- exports.DecodeError = void 0;
150
- var DecodeError = class DecodeError extends Error {
151
- constructor(message) {
152
- super(message);
153
- const proto = Object.create(DecodeError.prototype);
154
- Object.setPrototypeOf(this, proto);
155
- Object.defineProperty(this, "name", {
156
- configurable: true,
157
- enumerable: false,
158
- value: DecodeError.name
159
- });
160
- }
161
- };
162
- exports.DecodeError = DecodeError;
163
- }));
164
-
165
- //#endregion
166
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/utils/int.cjs
167
- var require_int = /* @__PURE__ */ __commonJSMin(((exports) => {
168
- Object.defineProperty(exports, "__esModule", { value: true });
169
- exports.UINT32_MAX = void 0;
170
- exports.setUint64 = setUint64;
171
- exports.setInt64 = setInt64;
172
- exports.getInt64 = getInt64;
173
- exports.getUint64 = getUint64;
174
- exports.UINT32_MAX = 4294967295;
175
- function setUint64(view, offset, value) {
176
- const high = value / 4294967296;
177
- const low = value;
178
- view.setUint32(offset, high);
179
- view.setUint32(offset + 4, low);
180
- }
181
- function setInt64(view, offset, value) {
182
- const high = Math.floor(value / 4294967296);
183
- const low = value;
184
- view.setUint32(offset, high);
185
- view.setUint32(offset + 4, low);
186
- }
187
- function getInt64(view, offset) {
188
- const high = view.getInt32(offset);
189
- const low = view.getUint32(offset + 4);
190
- return high * 4294967296 + low;
191
- }
192
- function getUint64(view, offset) {
193
- const high = view.getUint32(offset);
194
- const low = view.getUint32(offset + 4);
195
- return high * 4294967296 + low;
196
- }
197
- }));
198
-
199
- //#endregion
200
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/timestamp.cjs
201
- var require_timestamp = /* @__PURE__ */ __commonJSMin(((exports) => {
202
- Object.defineProperty(exports, "__esModule", { value: true });
203
- exports.timestampExtension = exports.EXT_TIMESTAMP = void 0;
204
- exports.encodeTimeSpecToTimestamp = encodeTimeSpecToTimestamp;
205
- exports.encodeDateToTimeSpec = encodeDateToTimeSpec;
206
- exports.encodeTimestampExtension = encodeTimestampExtension;
207
- exports.decodeTimestampToTimeSpec = decodeTimestampToTimeSpec;
208
- exports.decodeTimestampExtension = decodeTimestampExtension;
209
- const DecodeError_ts_1 = require_DecodeError();
210
- const int_ts_1 = require_int();
211
- exports.EXT_TIMESTAMP = -1;
212
- const TIMESTAMP32_MAX_SEC = 4294967295;
213
- const TIMESTAMP64_MAX_SEC = 17179869183;
214
- function encodeTimeSpecToTimestamp({ sec, nsec }) {
215
- if (sec >= 0 && nsec >= 0 && sec <= TIMESTAMP64_MAX_SEC) if (nsec === 0 && sec <= TIMESTAMP32_MAX_SEC) {
216
- const rv = new Uint8Array(4);
217
- new DataView(rv.buffer).setUint32(0, sec);
218
- return rv;
219
- } else {
220
- const secHigh = sec / 4294967296;
221
- const secLow = sec & 4294967295;
222
- const rv = new Uint8Array(8);
223
- const view = new DataView(rv.buffer);
224
- view.setUint32(0, nsec << 2 | secHigh & 3);
225
- view.setUint32(4, secLow);
226
- return rv;
227
- }
228
- else {
229
- const rv = new Uint8Array(12);
230
- const view = new DataView(rv.buffer);
231
- view.setUint32(0, nsec);
232
- (0, int_ts_1.setInt64)(view, 4, sec);
233
- return rv;
234
- }
235
- }
236
- function encodeDateToTimeSpec(date) {
237
- const msec = date.getTime();
238
- const sec = Math.floor(msec / 1e3);
239
- const nsec = (msec - sec * 1e3) * 1e6;
240
- const nsecInSec = Math.floor(nsec / 1e9);
241
- return {
242
- sec: sec + nsecInSec,
243
- nsec: nsec - nsecInSec * 1e9
244
- };
245
- }
246
- function encodeTimestampExtension(object) {
247
- if (object instanceof Date) return encodeTimeSpecToTimestamp(encodeDateToTimeSpec(object));
248
- else return null;
249
- }
250
- function decodeTimestampToTimeSpec(data) {
251
- const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
252
- switch (data.byteLength) {
253
- case 4: return {
254
- sec: view.getUint32(0),
255
- nsec: 0
256
- };
257
- case 8: {
258
- const nsec30AndSecHigh2 = view.getUint32(0);
259
- const secLow32 = view.getUint32(4);
260
- return {
261
- sec: (nsec30AndSecHigh2 & 3) * 4294967296 + secLow32,
262
- nsec: nsec30AndSecHigh2 >>> 2
263
- };
264
- }
265
- case 12: return {
266
- sec: (0, int_ts_1.getInt64)(view, 4),
267
- nsec: view.getUint32(0)
268
- };
269
- default: throw new DecodeError_ts_1.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${data.length}`);
270
- }
271
- }
272
- function decodeTimestampExtension(data) {
273
- const timeSpec = decodeTimestampToTimeSpec(data);
274
- return /* @__PURE__ */ new Date(timeSpec.sec * 1e3 + timeSpec.nsec / 1e6);
275
- }
276
- exports.timestampExtension = {
277
- type: exports.EXT_TIMESTAMP,
278
- encode: encodeTimestampExtension,
279
- decode: decodeTimestampExtension
280
- };
281
- }));
282
-
283
- //#endregion
284
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/ExtensionCodec.cjs
285
- var require_ExtensionCodec = /* @__PURE__ */ __commonJSMin(((exports) => {
286
- Object.defineProperty(exports, "__esModule", { value: true });
287
- exports.ExtensionCodec = void 0;
288
- const ExtData_ts_1 = require_ExtData();
289
- const timestamp_ts_1 = require_timestamp();
290
- var ExtensionCodec = class {
291
- constructor() {
292
- this.builtInEncoders = [];
293
- this.builtInDecoders = [];
294
- this.encoders = [];
295
- this.decoders = [];
296
- this.register(timestamp_ts_1.timestampExtension);
297
- }
298
- register({ type, encode, decode }) {
299
- if (type >= 0) {
300
- this.encoders[type] = encode;
301
- this.decoders[type] = decode;
302
- } else {
303
- const index = -1 - type;
304
- this.builtInEncoders[index] = encode;
305
- this.builtInDecoders[index] = decode;
306
- }
307
- }
308
- tryToEncode(object, context) {
309
- for (let i = 0; i < this.builtInEncoders.length; i++) {
310
- const encodeExt = this.builtInEncoders[i];
311
- if (encodeExt != null) {
312
- const data = encodeExt(object, context);
313
- if (data != null) {
314
- const type = -1 - i;
315
- return new ExtData_ts_1.ExtData(type, data);
316
- }
317
- }
318
- }
319
- for (let i = 0; i < this.encoders.length; i++) {
320
- const encodeExt = this.encoders[i];
321
- if (encodeExt != null) {
322
- const data = encodeExt(object, context);
323
- if (data != null) {
324
- const type = i;
325
- return new ExtData_ts_1.ExtData(type, data);
326
- }
327
- }
328
- }
329
- if (object instanceof ExtData_ts_1.ExtData) return object;
330
- return null;
331
- }
332
- decode(data, type, context) {
333
- const decodeExt = type < 0 ? this.builtInDecoders[-1 - type] : this.decoders[type];
334
- if (decodeExt) return decodeExt(data, type, context);
335
- else return new ExtData_ts_1.ExtData(type, data);
336
- }
337
- };
338
- exports.ExtensionCodec = ExtensionCodec;
339
- ExtensionCodec.defaultCodec = new ExtensionCodec();
340
- }));
341
-
342
- //#endregion
343
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/utils/typedArrays.cjs
344
- var require_typedArrays = /* @__PURE__ */ __commonJSMin(((exports) => {
345
- Object.defineProperty(exports, "__esModule", { value: true });
346
- exports.ensureUint8Array = ensureUint8Array;
347
- function isArrayBufferLike(buffer) {
348
- return buffer instanceof ArrayBuffer || typeof SharedArrayBuffer !== "undefined" && buffer instanceof SharedArrayBuffer;
349
- }
350
- function ensureUint8Array(buffer) {
351
- if (buffer instanceof Uint8Array) return buffer;
352
- else if (ArrayBuffer.isView(buffer)) return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
353
- else if (isArrayBufferLike(buffer)) return new Uint8Array(buffer);
354
- else return Uint8Array.from(buffer);
355
- }
356
- }));
357
-
358
- //#endregion
359
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/Encoder.cjs
360
- var require_Encoder = /* @__PURE__ */ __commonJSMin(((exports) => {
361
- Object.defineProperty(exports, "__esModule", { value: true });
362
- exports.Encoder = exports.DEFAULT_INITIAL_BUFFER_SIZE = exports.DEFAULT_MAX_DEPTH = void 0;
363
- const utf8_ts_1 = require_utf8();
364
- const ExtensionCodec_ts_1 = require_ExtensionCodec();
365
- const int_ts_1 = require_int();
366
- const typedArrays_ts_1 = require_typedArrays();
367
- exports.DEFAULT_MAX_DEPTH = 100;
368
- exports.DEFAULT_INITIAL_BUFFER_SIZE = 2048;
369
- var Encoder = class Encoder {
370
- constructor(options) {
371
- this.entered = false;
372
- this.extensionCodec = options?.extensionCodec ?? ExtensionCodec_ts_1.ExtensionCodec.defaultCodec;
373
- this.context = options?.context;
374
- this.useBigInt64 = options?.useBigInt64 ?? false;
375
- this.maxDepth = options?.maxDepth ?? exports.DEFAULT_MAX_DEPTH;
376
- this.initialBufferSize = options?.initialBufferSize ?? exports.DEFAULT_INITIAL_BUFFER_SIZE;
377
- this.sortKeys = options?.sortKeys ?? false;
378
- this.forceFloat32 = options?.forceFloat32 ?? false;
379
- this.ignoreUndefined = options?.ignoreUndefined ?? false;
380
- this.forceIntegerToFloat = options?.forceIntegerToFloat ?? false;
381
- this.pos = 0;
382
- this.view = new DataView(new ArrayBuffer(this.initialBufferSize));
383
- this.bytes = new Uint8Array(this.view.buffer);
384
- }
385
- clone() {
386
- return new Encoder({
387
- extensionCodec: this.extensionCodec,
388
- context: this.context,
389
- useBigInt64: this.useBigInt64,
390
- maxDepth: this.maxDepth,
391
- initialBufferSize: this.initialBufferSize,
392
- sortKeys: this.sortKeys,
393
- forceFloat32: this.forceFloat32,
394
- ignoreUndefined: this.ignoreUndefined,
395
- forceIntegerToFloat: this.forceIntegerToFloat
396
- });
397
- }
398
- reinitializeState() {
399
- this.pos = 0;
400
- }
401
- /**
402
- * 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}.
403
- *
404
- * @returns Encodes the object and returns a shared reference the encoder's internal buffer.
405
- */
406
- encodeSharedRef(object) {
407
- if (this.entered) return this.clone().encodeSharedRef(object);
408
- try {
409
- this.entered = true;
410
- this.reinitializeState();
411
- this.doEncode(object, 1);
412
- return this.bytes.subarray(0, this.pos);
413
- } finally {
414
- this.entered = false;
415
- }
416
- }
417
- /**
418
- * @returns Encodes the object and returns a copy of the encoder's internal buffer.
419
- */
420
- encode(object) {
421
- if (this.entered) return this.clone().encode(object);
422
- try {
423
- this.entered = true;
424
- this.reinitializeState();
425
- this.doEncode(object, 1);
426
- return this.bytes.slice(0, this.pos);
427
- } finally {
428
- this.entered = false;
429
- }
430
- }
431
- doEncode(object, depth) {
432
- if (depth > this.maxDepth) throw new Error(`Too deep objects in depth ${depth}`);
433
- if (object == null) this.encodeNil();
434
- else if (typeof object === "boolean") this.encodeBoolean(object);
435
- else if (typeof object === "number") if (!this.forceIntegerToFloat) this.encodeNumber(object);
436
- else this.encodeNumberAsFloat(object);
437
- else if (typeof object === "string") this.encodeString(object);
438
- else if (this.useBigInt64 && typeof object === "bigint") this.encodeBigInt64(object);
439
- else this.encodeObject(object, depth);
440
- }
441
- ensureBufferSizeToWrite(sizeToWrite) {
442
- const requiredSize = this.pos + sizeToWrite;
443
- if (this.view.byteLength < requiredSize) this.resizeBuffer(requiredSize * 2);
444
- }
445
- resizeBuffer(newSize) {
446
- const newBuffer = new ArrayBuffer(newSize);
447
- const newBytes = new Uint8Array(newBuffer);
448
- const newView = new DataView(newBuffer);
449
- newBytes.set(this.bytes);
450
- this.view = newView;
451
- this.bytes = newBytes;
452
- }
453
- encodeNil() {
454
- this.writeU8(192);
455
- }
456
- encodeBoolean(object) {
457
- if (object === false) this.writeU8(194);
458
- else this.writeU8(195);
459
- }
460
- encodeNumber(object) {
461
- if (!this.forceIntegerToFloat && Number.isSafeInteger(object)) if (object >= 0) if (object < 128) this.writeU8(object);
462
- else if (object < 256) {
463
- this.writeU8(204);
464
- this.writeU8(object);
465
- } else if (object < 65536) {
466
- this.writeU8(205);
467
- this.writeU16(object);
468
- } else if (object < 4294967296) {
469
- this.writeU8(206);
470
- this.writeU32(object);
471
- } else if (!this.useBigInt64) {
472
- this.writeU8(207);
473
- this.writeU64(object);
474
- } else this.encodeNumberAsFloat(object);
475
- else if (object >= -32) this.writeU8(224 | object + 32);
476
- else if (object >= -128) {
477
- this.writeU8(208);
478
- this.writeI8(object);
479
- } else if (object >= -32768) {
480
- this.writeU8(209);
481
- this.writeI16(object);
482
- } else if (object >= -2147483648) {
483
- this.writeU8(210);
484
- this.writeI32(object);
485
- } else if (!this.useBigInt64) {
486
- this.writeU8(211);
487
- this.writeI64(object);
488
- } else this.encodeNumberAsFloat(object);
489
- else this.encodeNumberAsFloat(object);
490
- }
491
- encodeNumberAsFloat(object) {
492
- if (this.forceFloat32) {
493
- this.writeU8(202);
494
- this.writeF32(object);
495
- } else {
496
- this.writeU8(203);
497
- this.writeF64(object);
498
- }
499
- }
500
- encodeBigInt64(object) {
501
- if (object >= BigInt(0)) {
502
- this.writeU8(207);
503
- this.writeBigUint64(object);
504
- } else {
505
- this.writeU8(211);
506
- this.writeBigInt64(object);
507
- }
508
- }
509
- writeStringHeader(byteLength) {
510
- if (byteLength < 32) this.writeU8(160 + byteLength);
511
- else if (byteLength < 256) {
512
- this.writeU8(217);
513
- this.writeU8(byteLength);
514
- } else if (byteLength < 65536) {
515
- this.writeU8(218);
516
- this.writeU16(byteLength);
517
- } else if (byteLength < 4294967296) {
518
- this.writeU8(219);
519
- this.writeU32(byteLength);
520
- } else throw new Error(`Too long string: ${byteLength} bytes in UTF-8`);
521
- }
522
- encodeString(object) {
523
- const maxHeaderSize = 5;
524
- const byteLength = (0, utf8_ts_1.utf8Count)(object);
525
- this.ensureBufferSizeToWrite(maxHeaderSize + byteLength);
526
- this.writeStringHeader(byteLength);
527
- (0, utf8_ts_1.utf8Encode)(object, this.bytes, this.pos);
528
- this.pos += byteLength;
529
- }
530
- encodeObject(object, depth) {
531
- const ext = this.extensionCodec.tryToEncode(object, this.context);
532
- if (ext != null) this.encodeExtension(ext);
533
- else if (Array.isArray(object)) this.encodeArray(object, depth);
534
- else if (ArrayBuffer.isView(object)) this.encodeBinary(object);
535
- else if (typeof object === "object") this.encodeMap(object, depth);
536
- else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(object)}`);
537
- }
538
- encodeBinary(object) {
539
- const size = object.byteLength;
540
- if (size < 256) {
541
- this.writeU8(196);
542
- this.writeU8(size);
543
- } else if (size < 65536) {
544
- this.writeU8(197);
545
- this.writeU16(size);
546
- } else if (size < 4294967296) {
547
- this.writeU8(198);
548
- this.writeU32(size);
549
- } else throw new Error(`Too large binary: ${size}`);
550
- const bytes = (0, typedArrays_ts_1.ensureUint8Array)(object);
551
- this.writeU8a(bytes);
552
- }
553
- encodeArray(object, depth) {
554
- const size = object.length;
555
- if (size < 16) this.writeU8(144 + size);
556
- else if (size < 65536) {
557
- this.writeU8(220);
558
- this.writeU16(size);
559
- } else if (size < 4294967296) {
560
- this.writeU8(221);
561
- this.writeU32(size);
562
- } else throw new Error(`Too large array: ${size}`);
563
- for (const item of object) this.doEncode(item, depth + 1);
564
- }
565
- countWithoutUndefined(object, keys) {
566
- let count = 0;
567
- for (const key of keys) if (object[key] !== void 0) count++;
568
- return count;
569
- }
570
- encodeMap(object, depth) {
571
- const keys = Object.keys(object);
572
- if (this.sortKeys) keys.sort();
573
- const size = this.ignoreUndefined ? this.countWithoutUndefined(object, keys) : keys.length;
574
- if (size < 16) this.writeU8(128 + size);
575
- else if (size < 65536) {
576
- this.writeU8(222);
577
- this.writeU16(size);
578
- } else if (size < 4294967296) {
579
- this.writeU8(223);
580
- this.writeU32(size);
581
- } else throw new Error(`Too large map object: ${size}`);
582
- for (const key of keys) {
583
- const value = object[key];
584
- if (!(this.ignoreUndefined && value === void 0)) {
585
- this.encodeString(key);
586
- this.doEncode(value, depth + 1);
587
- }
588
- }
589
- }
590
- encodeExtension(ext) {
591
- if (typeof ext.data === "function") {
592
- const data = ext.data(this.pos + 6);
593
- const size = data.length;
594
- if (size >= 4294967296) throw new Error(`Too large extension object: ${size}`);
595
- this.writeU8(201);
596
- this.writeU32(size);
597
- this.writeI8(ext.type);
598
- this.writeU8a(data);
599
- return;
600
- }
601
- const size = ext.data.length;
602
- if (size === 1) this.writeU8(212);
603
- else if (size === 2) this.writeU8(213);
604
- else if (size === 4) this.writeU8(214);
605
- else if (size === 8) this.writeU8(215);
606
- else if (size === 16) this.writeU8(216);
607
- else if (size < 256) {
608
- this.writeU8(199);
609
- this.writeU8(size);
610
- } else if (size < 65536) {
611
- this.writeU8(200);
612
- this.writeU16(size);
613
- } else if (size < 4294967296) {
614
- this.writeU8(201);
615
- this.writeU32(size);
616
- } else throw new Error(`Too large extension object: ${size}`);
617
- this.writeI8(ext.type);
618
- this.writeU8a(ext.data);
619
- }
620
- writeU8(value) {
621
- this.ensureBufferSizeToWrite(1);
622
- this.view.setUint8(this.pos, value);
623
- this.pos++;
624
- }
625
- writeU8a(values) {
626
- const size = values.length;
627
- this.ensureBufferSizeToWrite(size);
628
- this.bytes.set(values, this.pos);
629
- this.pos += size;
630
- }
631
- writeI8(value) {
632
- this.ensureBufferSizeToWrite(1);
633
- this.view.setInt8(this.pos, value);
634
- this.pos++;
635
- }
636
- writeU16(value) {
637
- this.ensureBufferSizeToWrite(2);
638
- this.view.setUint16(this.pos, value);
639
- this.pos += 2;
640
- }
641
- writeI16(value) {
642
- this.ensureBufferSizeToWrite(2);
643
- this.view.setInt16(this.pos, value);
644
- this.pos += 2;
645
- }
646
- writeU32(value) {
647
- this.ensureBufferSizeToWrite(4);
648
- this.view.setUint32(this.pos, value);
649
- this.pos += 4;
650
- }
651
- writeI32(value) {
652
- this.ensureBufferSizeToWrite(4);
653
- this.view.setInt32(this.pos, value);
654
- this.pos += 4;
655
- }
656
- writeF32(value) {
657
- this.ensureBufferSizeToWrite(4);
658
- this.view.setFloat32(this.pos, value);
659
- this.pos += 4;
660
- }
661
- writeF64(value) {
662
- this.ensureBufferSizeToWrite(8);
663
- this.view.setFloat64(this.pos, value);
664
- this.pos += 8;
665
- }
666
- writeU64(value) {
667
- this.ensureBufferSizeToWrite(8);
668
- (0, int_ts_1.setUint64)(this.view, this.pos, value);
669
- this.pos += 8;
670
- }
671
- writeI64(value) {
672
- this.ensureBufferSizeToWrite(8);
673
- (0, int_ts_1.setInt64)(this.view, this.pos, value);
674
- this.pos += 8;
675
- }
676
- writeBigUint64(value) {
677
- this.ensureBufferSizeToWrite(8);
678
- this.view.setBigUint64(this.pos, value);
679
- this.pos += 8;
680
- }
681
- writeBigInt64(value) {
682
- this.ensureBufferSizeToWrite(8);
683
- this.view.setBigInt64(this.pos, value);
684
- this.pos += 8;
685
- }
686
- };
687
- exports.Encoder = Encoder;
688
- }));
689
-
690
- //#endregion
691
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/encode.cjs
692
- var require_encode = /* @__PURE__ */ __commonJSMin(((exports) => {
693
- Object.defineProperty(exports, "__esModule", { value: true });
694
- exports.encode = encode;
695
- const Encoder_ts_1 = require_Encoder();
696
- /**
697
- * It encodes `value` in the MessagePack format and
698
- * returns a byte buffer.
699
- *
700
- * 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`.
701
- */
702
- function encode(value, options) {
703
- return new Encoder_ts_1.Encoder(options).encodeSharedRef(value);
704
- }
705
- }));
706
-
707
- //#endregion
708
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/utils/prettyByte.cjs
709
- var require_prettyByte = /* @__PURE__ */ __commonJSMin(((exports) => {
710
- Object.defineProperty(exports, "__esModule", { value: true });
711
- exports.prettyByte = prettyByte;
712
- function prettyByte(byte) {
713
- return `${byte < 0 ? "-" : ""}0x${Math.abs(byte).toString(16).padStart(2, "0")}`;
714
- }
715
- }));
716
-
717
- //#endregion
718
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/CachedKeyDecoder.cjs
719
- var require_CachedKeyDecoder = /* @__PURE__ */ __commonJSMin(((exports) => {
720
- Object.defineProperty(exports, "__esModule", { value: true });
721
- exports.CachedKeyDecoder = void 0;
722
- const utf8_ts_1 = require_utf8();
723
- const DEFAULT_MAX_KEY_LENGTH = 16;
724
- const DEFAULT_MAX_LENGTH_PER_KEY = 16;
725
- var CachedKeyDecoder = class {
726
- constructor(maxKeyLength = DEFAULT_MAX_KEY_LENGTH, maxLengthPerKey = DEFAULT_MAX_LENGTH_PER_KEY) {
727
- this.hit = 0;
728
- this.miss = 0;
729
- this.maxKeyLength = maxKeyLength;
730
- this.maxLengthPerKey = maxLengthPerKey;
731
- this.caches = [];
732
- for (let i = 0; i < this.maxKeyLength; i++) this.caches.push([]);
733
- }
734
- canBeCached(byteLength) {
735
- return byteLength > 0 && byteLength <= this.maxKeyLength;
736
- }
737
- find(bytes, inputOffset, byteLength) {
738
- const records = this.caches[byteLength - 1];
739
- FIND_CHUNK: for (const record of records) {
740
- const recordBytes = record.bytes;
741
- for (let j = 0; j < byteLength; j++) if (recordBytes[j] !== bytes[inputOffset + j]) continue FIND_CHUNK;
742
- return record.str;
743
- }
744
- return null;
745
- }
746
- store(bytes, value) {
747
- const records = this.caches[bytes.length - 1];
748
- const record = {
749
- bytes,
750
- str: value
751
- };
752
- if (records.length >= this.maxLengthPerKey) records[Math.random() * records.length | 0] = record;
753
- else records.push(record);
754
- }
755
- decode(bytes, inputOffset, byteLength) {
756
- const cachedValue = this.find(bytes, inputOffset, byteLength);
757
- if (cachedValue != null) {
758
- this.hit++;
759
- return cachedValue;
760
- }
761
- this.miss++;
762
- const str = (0, utf8_ts_1.utf8DecodeJs)(bytes, inputOffset, byteLength);
763
- const slicedCopyOfBytes = Uint8Array.prototype.slice.call(bytes, inputOffset, inputOffset + byteLength);
764
- this.store(slicedCopyOfBytes, str);
765
- return str;
766
- }
767
- };
768
- exports.CachedKeyDecoder = CachedKeyDecoder;
769
- }));
770
-
771
- //#endregion
772
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/Decoder.cjs
773
- var require_Decoder = /* @__PURE__ */ __commonJSMin(((exports) => {
774
- Object.defineProperty(exports, "__esModule", { value: true });
775
- exports.Decoder = void 0;
776
- const prettyByte_ts_1 = require_prettyByte();
777
- const ExtensionCodec_ts_1 = require_ExtensionCodec();
778
- const int_ts_1 = require_int();
779
- const utf8_ts_1 = require_utf8();
780
- const typedArrays_ts_1 = require_typedArrays();
781
- const CachedKeyDecoder_ts_1 = require_CachedKeyDecoder();
782
- const DecodeError_ts_1 = require_DecodeError();
783
- const STATE_ARRAY = "array";
784
- const STATE_MAP_KEY = "map_key";
785
- const STATE_MAP_VALUE = "map_value";
786
- const mapKeyConverter = (key) => {
787
- if (typeof key === "string" || typeof key === "number") return key;
788
- throw new DecodeError_ts_1.DecodeError("The type of key must be string or number but " + typeof key);
789
- };
790
- var StackPool = class {
791
- constructor() {
792
- this.stack = [];
793
- this.stackHeadPosition = -1;
794
- }
795
- get length() {
796
- return this.stackHeadPosition + 1;
797
- }
798
- top() {
799
- return this.stack[this.stackHeadPosition];
800
- }
801
- pushArrayState(size) {
802
- const state = this.getUninitializedStateFromPool();
803
- state.type = STATE_ARRAY;
804
- state.position = 0;
805
- state.size = size;
806
- state.array = new Array(size);
807
- }
808
- pushMapState(size) {
809
- const state = this.getUninitializedStateFromPool();
810
- state.type = STATE_MAP_KEY;
811
- state.readCount = 0;
812
- state.size = size;
813
- state.map = {};
814
- }
815
- getUninitializedStateFromPool() {
816
- this.stackHeadPosition++;
817
- if (this.stackHeadPosition === this.stack.length) this.stack.push({
818
- type: void 0,
819
- size: 0,
820
- array: void 0,
821
- position: 0,
822
- readCount: 0,
823
- map: void 0,
824
- key: null
825
- });
826
- return this.stack[this.stackHeadPosition];
827
- }
828
- release(state) {
829
- if (this.stack[this.stackHeadPosition] !== state) throw new Error("Invalid stack state. Released state is not on top of the stack.");
830
- if (state.type === STATE_ARRAY) {
831
- const partialState = state;
832
- partialState.size = 0;
833
- partialState.array = void 0;
834
- partialState.position = 0;
835
- partialState.type = void 0;
836
- }
837
- if (state.type === STATE_MAP_KEY || state.type === STATE_MAP_VALUE) {
838
- const partialState = state;
839
- partialState.size = 0;
840
- partialState.map = void 0;
841
- partialState.readCount = 0;
842
- partialState.type = void 0;
843
- }
844
- this.stackHeadPosition--;
845
- }
846
- reset() {
847
- this.stack.length = 0;
848
- this.stackHeadPosition = -1;
849
- }
850
- };
851
- const HEAD_BYTE_REQUIRED = -1;
852
- const EMPTY_VIEW = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(0));
853
- const EMPTY_BYTES = new Uint8Array(EMPTY_VIEW.buffer);
854
- try {
855
- EMPTY_VIEW.getInt8(0);
856
- } catch (e) {
857
- if (!(e instanceof RangeError)) throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
858
- }
859
- const MORE_DATA = /* @__PURE__ */ new RangeError("Insufficient data");
860
- const sharedCachedKeyDecoder = new CachedKeyDecoder_ts_1.CachedKeyDecoder();
861
- var Decoder = class Decoder {
862
- constructor(options) {
863
- this.totalPos = 0;
864
- this.pos = 0;
865
- this.view = EMPTY_VIEW;
866
- this.bytes = EMPTY_BYTES;
867
- this.headByte = HEAD_BYTE_REQUIRED;
868
- this.stack = new StackPool();
869
- this.entered = false;
870
- this.extensionCodec = options?.extensionCodec ?? ExtensionCodec_ts_1.ExtensionCodec.defaultCodec;
871
- this.context = options?.context;
872
- this.useBigInt64 = options?.useBigInt64 ?? false;
873
- this.rawStrings = options?.rawStrings ?? false;
874
- this.maxStrLength = options?.maxStrLength ?? int_ts_1.UINT32_MAX;
875
- this.maxBinLength = options?.maxBinLength ?? int_ts_1.UINT32_MAX;
876
- this.maxArrayLength = options?.maxArrayLength ?? int_ts_1.UINT32_MAX;
877
- this.maxMapLength = options?.maxMapLength ?? int_ts_1.UINT32_MAX;
878
- this.maxExtLength = options?.maxExtLength ?? int_ts_1.UINT32_MAX;
879
- this.keyDecoder = options?.keyDecoder !== void 0 ? options.keyDecoder : sharedCachedKeyDecoder;
880
- this.mapKeyConverter = options?.mapKeyConverter ?? mapKeyConverter;
881
- }
882
- clone() {
883
- return new Decoder({
884
- extensionCodec: this.extensionCodec,
885
- context: this.context,
886
- useBigInt64: this.useBigInt64,
887
- rawStrings: this.rawStrings,
888
- maxStrLength: this.maxStrLength,
889
- maxBinLength: this.maxBinLength,
890
- maxArrayLength: this.maxArrayLength,
891
- maxMapLength: this.maxMapLength,
892
- maxExtLength: this.maxExtLength,
893
- keyDecoder: this.keyDecoder
894
- });
895
- }
896
- reinitializeState() {
897
- this.totalPos = 0;
898
- this.headByte = HEAD_BYTE_REQUIRED;
899
- this.stack.reset();
900
- }
901
- setBuffer(buffer) {
902
- const bytes = (0, typedArrays_ts_1.ensureUint8Array)(buffer);
903
- this.bytes = bytes;
904
- this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
905
- this.pos = 0;
906
- }
907
- appendBuffer(buffer) {
908
- if (this.headByte === HEAD_BYTE_REQUIRED && !this.hasRemaining(1)) this.setBuffer(buffer);
909
- else {
910
- const remainingData = this.bytes.subarray(this.pos);
911
- const newData = (0, typedArrays_ts_1.ensureUint8Array)(buffer);
912
- const newBuffer = new Uint8Array(remainingData.length + newData.length);
913
- newBuffer.set(remainingData);
914
- newBuffer.set(newData, remainingData.length);
915
- this.setBuffer(newBuffer);
916
- }
917
- }
918
- hasRemaining(size) {
919
- return this.view.byteLength - this.pos >= size;
920
- }
921
- createExtraByteError(posToShow) {
922
- const { view, pos } = this;
923
- return /* @__PURE__ */ new RangeError(`Extra ${view.byteLength - pos} of ${view.byteLength} byte(s) found at buffer[${posToShow}]`);
924
- }
925
- /**
926
- * @throws {@link DecodeError}
927
- * @throws {@link RangeError}
928
- */
929
- decode(buffer) {
930
- if (this.entered) return this.clone().decode(buffer);
931
- try {
932
- this.entered = true;
933
- this.reinitializeState();
934
- this.setBuffer(buffer);
935
- const object = this.doDecodeSync();
936
- if (this.hasRemaining(1)) throw this.createExtraByteError(this.pos);
937
- return object;
938
- } finally {
939
- this.entered = false;
940
- }
941
- }
942
- *decodeMulti(buffer) {
943
- if (this.entered) {
944
- yield* this.clone().decodeMulti(buffer);
945
- return;
946
- }
947
- try {
948
- this.entered = true;
949
- this.reinitializeState();
950
- this.setBuffer(buffer);
951
- while (this.hasRemaining(1)) yield this.doDecodeSync();
952
- } finally {
953
- this.entered = false;
954
- }
955
- }
956
- async decodeAsync(stream) {
957
- if (this.entered) return this.clone().decodeAsync(stream);
958
- try {
959
- this.entered = true;
960
- let decoded = false;
961
- let object;
962
- for await (const buffer of stream) {
963
- if (decoded) {
964
- this.entered = false;
965
- throw this.createExtraByteError(this.totalPos);
966
- }
967
- this.appendBuffer(buffer);
968
- try {
969
- object = this.doDecodeSync();
970
- decoded = true;
971
- } catch (e) {
972
- if (!(e instanceof RangeError)) throw e;
973
- }
974
- this.totalPos += this.pos;
975
- }
976
- if (decoded) {
977
- if (this.hasRemaining(1)) throw this.createExtraByteError(this.totalPos);
978
- return object;
979
- }
980
- const { headByte, pos, totalPos } = this;
981
- throw new RangeError(`Insufficient data in parsing ${(0, prettyByte_ts_1.prettyByte)(headByte)} at ${totalPos} (${pos} in the current buffer)`);
982
- } finally {
983
- this.entered = false;
984
- }
985
- }
986
- decodeArrayStream(stream) {
987
- return this.decodeMultiAsync(stream, true);
988
- }
989
- decodeStream(stream) {
990
- return this.decodeMultiAsync(stream, false);
991
- }
992
- async *decodeMultiAsync(stream, isArray) {
993
- if (this.entered) {
994
- yield* this.clone().decodeMultiAsync(stream, isArray);
995
- return;
996
- }
997
- try {
998
- this.entered = true;
999
- let isArrayHeaderRequired = isArray;
1000
- let arrayItemsLeft = -1;
1001
- for await (const buffer of stream) {
1002
- if (isArray && arrayItemsLeft === 0) throw this.createExtraByteError(this.totalPos);
1003
- this.appendBuffer(buffer);
1004
- if (isArrayHeaderRequired) {
1005
- arrayItemsLeft = this.readArraySize();
1006
- isArrayHeaderRequired = false;
1007
- this.complete();
1008
- }
1009
- try {
1010
- while (true) {
1011
- yield this.doDecodeSync();
1012
- if (--arrayItemsLeft === 0) break;
1013
- }
1014
- } catch (e) {
1015
- if (!(e instanceof RangeError)) throw e;
1016
- }
1017
- this.totalPos += this.pos;
1018
- }
1019
- } finally {
1020
- this.entered = false;
1021
- }
1022
- }
1023
- doDecodeSync() {
1024
- DECODE: while (true) {
1025
- const headByte = this.readHeadByte();
1026
- let object;
1027
- if (headByte >= 224) object = headByte - 256;
1028
- else if (headByte < 192) if (headByte < 128) object = headByte;
1029
- else if (headByte < 144) {
1030
- const size = headByte - 128;
1031
- if (size !== 0) {
1032
- this.pushMapState(size);
1033
- this.complete();
1034
- continue DECODE;
1035
- } else object = {};
1036
- } else if (headByte < 160) {
1037
- const size = headByte - 144;
1038
- if (size !== 0) {
1039
- this.pushArrayState(size);
1040
- this.complete();
1041
- continue DECODE;
1042
- } else object = [];
1043
- } else {
1044
- const byteLength = headByte - 160;
1045
- object = this.decodeString(byteLength, 0);
1046
- }
1047
- else if (headByte === 192) object = null;
1048
- else if (headByte === 194) object = false;
1049
- else if (headByte === 195) object = true;
1050
- else if (headByte === 202) object = this.readF32();
1051
- else if (headByte === 203) object = this.readF64();
1052
- else if (headByte === 204) object = this.readU8();
1053
- else if (headByte === 205) object = this.readU16();
1054
- else if (headByte === 206) object = this.readU32();
1055
- else if (headByte === 207) if (this.useBigInt64) object = this.readU64AsBigInt();
1056
- else object = this.readU64();
1057
- else if (headByte === 208) object = this.readI8();
1058
- else if (headByte === 209) object = this.readI16();
1059
- else if (headByte === 210) object = this.readI32();
1060
- else if (headByte === 211) if (this.useBigInt64) object = this.readI64AsBigInt();
1061
- else object = this.readI64();
1062
- else if (headByte === 217) {
1063
- const byteLength = this.lookU8();
1064
- object = this.decodeString(byteLength, 1);
1065
- } else if (headByte === 218) {
1066
- const byteLength = this.lookU16();
1067
- object = this.decodeString(byteLength, 2);
1068
- } else if (headByte === 219) {
1069
- const byteLength = this.lookU32();
1070
- object = this.decodeString(byteLength, 4);
1071
- } else if (headByte === 220) {
1072
- const size = this.readU16();
1073
- if (size !== 0) {
1074
- this.pushArrayState(size);
1075
- this.complete();
1076
- continue DECODE;
1077
- } else object = [];
1078
- } else if (headByte === 221) {
1079
- const size = this.readU32();
1080
- if (size !== 0) {
1081
- this.pushArrayState(size);
1082
- this.complete();
1083
- continue DECODE;
1084
- } else object = [];
1085
- } else if (headByte === 222) {
1086
- const size = this.readU16();
1087
- if (size !== 0) {
1088
- this.pushMapState(size);
1089
- this.complete();
1090
- continue DECODE;
1091
- } else object = {};
1092
- } else if (headByte === 223) {
1093
- const size = this.readU32();
1094
- if (size !== 0) {
1095
- this.pushMapState(size);
1096
- this.complete();
1097
- continue DECODE;
1098
- } else object = {};
1099
- } else if (headByte === 196) {
1100
- const size = this.lookU8();
1101
- object = this.decodeBinary(size, 1);
1102
- } else if (headByte === 197) {
1103
- const size = this.lookU16();
1104
- object = this.decodeBinary(size, 2);
1105
- } else if (headByte === 198) {
1106
- const size = this.lookU32();
1107
- object = this.decodeBinary(size, 4);
1108
- } else if (headByte === 212) object = this.decodeExtension(1, 0);
1109
- else if (headByte === 213) object = this.decodeExtension(2, 0);
1110
- else if (headByte === 214) object = this.decodeExtension(4, 0);
1111
- else if (headByte === 215) object = this.decodeExtension(8, 0);
1112
- else if (headByte === 216) object = this.decodeExtension(16, 0);
1113
- else if (headByte === 199) {
1114
- const size = this.lookU8();
1115
- object = this.decodeExtension(size, 1);
1116
- } else if (headByte === 200) {
1117
- const size = this.lookU16();
1118
- object = this.decodeExtension(size, 2);
1119
- } else if (headByte === 201) {
1120
- const size = this.lookU32();
1121
- object = this.decodeExtension(size, 4);
1122
- } else throw new DecodeError_ts_1.DecodeError(`Unrecognized type byte: ${(0, prettyByte_ts_1.prettyByte)(headByte)}`);
1123
- this.complete();
1124
- const stack = this.stack;
1125
- while (stack.length > 0) {
1126
- const state = stack.top();
1127
- if (state.type === STATE_ARRAY) {
1128
- state.array[state.position] = object;
1129
- state.position++;
1130
- if (state.position === state.size) {
1131
- object = state.array;
1132
- stack.release(state);
1133
- } else continue DECODE;
1134
- } else if (state.type === STATE_MAP_KEY) {
1135
- if (object === "__proto__") throw new DecodeError_ts_1.DecodeError("The key __proto__ is not allowed");
1136
- state.key = this.mapKeyConverter(object);
1137
- state.type = STATE_MAP_VALUE;
1138
- continue DECODE;
1139
- } else {
1140
- state.map[state.key] = object;
1141
- state.readCount++;
1142
- if (state.readCount === state.size) {
1143
- object = state.map;
1144
- stack.release(state);
1145
- } else {
1146
- state.key = null;
1147
- state.type = STATE_MAP_KEY;
1148
- continue DECODE;
1149
- }
1150
- }
1151
- }
1152
- return object;
1153
- }
1154
- }
1155
- readHeadByte() {
1156
- if (this.headByte === HEAD_BYTE_REQUIRED) this.headByte = this.readU8();
1157
- return this.headByte;
1158
- }
1159
- complete() {
1160
- this.headByte = HEAD_BYTE_REQUIRED;
1161
- }
1162
- readArraySize() {
1163
- const headByte = this.readHeadByte();
1164
- switch (headByte) {
1165
- case 220: return this.readU16();
1166
- case 221: return this.readU32();
1167
- default: if (headByte < 160) return headByte - 144;
1168
- else throw new DecodeError_ts_1.DecodeError(`Unrecognized array type byte: ${(0, prettyByte_ts_1.prettyByte)(headByte)}`);
1169
- }
1170
- }
1171
- pushMapState(size) {
1172
- if (size > this.maxMapLength) throw new DecodeError_ts_1.DecodeError(`Max length exceeded: map length (${size}) > maxMapLengthLength (${this.maxMapLength})`);
1173
- this.stack.pushMapState(size);
1174
- }
1175
- pushArrayState(size) {
1176
- if (size > this.maxArrayLength) throw new DecodeError_ts_1.DecodeError(`Max length exceeded: array length (${size}) > maxArrayLength (${this.maxArrayLength})`);
1177
- this.stack.pushArrayState(size);
1178
- }
1179
- decodeString(byteLength, headerOffset) {
1180
- if (!this.rawStrings || this.stateIsMapKey()) return this.decodeUtf8String(byteLength, headerOffset);
1181
- return this.decodeBinary(byteLength, headerOffset);
1182
- }
1183
- /**
1184
- * @throws {@link RangeError}
1185
- */
1186
- decodeUtf8String(byteLength, headerOffset) {
1187
- if (byteLength > this.maxStrLength) throw new DecodeError_ts_1.DecodeError(`Max length exceeded: UTF-8 byte length (${byteLength}) > maxStrLength (${this.maxStrLength})`);
1188
- if (this.bytes.byteLength < this.pos + headerOffset + byteLength) throw MORE_DATA;
1189
- const offset = this.pos + headerOffset;
1190
- let object;
1191
- if (this.stateIsMapKey() && this.keyDecoder?.canBeCached(byteLength)) object = this.keyDecoder.decode(this.bytes, offset, byteLength);
1192
- else object = (0, utf8_ts_1.utf8Decode)(this.bytes, offset, byteLength);
1193
- this.pos += headerOffset + byteLength;
1194
- return object;
1195
- }
1196
- stateIsMapKey() {
1197
- if (this.stack.length > 0) return this.stack.top().type === STATE_MAP_KEY;
1198
- return false;
1199
- }
1200
- /**
1201
- * @throws {@link RangeError}
1202
- */
1203
- decodeBinary(byteLength, headOffset) {
1204
- if (byteLength > this.maxBinLength) throw new DecodeError_ts_1.DecodeError(`Max length exceeded: bin length (${byteLength}) > maxBinLength (${this.maxBinLength})`);
1205
- if (!this.hasRemaining(byteLength + headOffset)) throw MORE_DATA;
1206
- const offset = this.pos + headOffset;
1207
- const object = this.bytes.subarray(offset, offset + byteLength);
1208
- this.pos += headOffset + byteLength;
1209
- return object;
1210
- }
1211
- decodeExtension(size, headOffset) {
1212
- if (size > this.maxExtLength) throw new DecodeError_ts_1.DecodeError(`Max length exceeded: ext length (${size}) > maxExtLength (${this.maxExtLength})`);
1213
- const extType = this.view.getInt8(this.pos + headOffset);
1214
- const data = this.decodeBinary(size, headOffset + 1);
1215
- return this.extensionCodec.decode(data, extType, this.context);
1216
- }
1217
- lookU8() {
1218
- return this.view.getUint8(this.pos);
1219
- }
1220
- lookU16() {
1221
- return this.view.getUint16(this.pos);
1222
- }
1223
- lookU32() {
1224
- return this.view.getUint32(this.pos);
1225
- }
1226
- readU8() {
1227
- const value = this.view.getUint8(this.pos);
1228
- this.pos++;
1229
- return value;
1230
- }
1231
- readI8() {
1232
- const value = this.view.getInt8(this.pos);
1233
- this.pos++;
1234
- return value;
1235
- }
1236
- readU16() {
1237
- const value = this.view.getUint16(this.pos);
1238
- this.pos += 2;
1239
- return value;
1240
- }
1241
- readI16() {
1242
- const value = this.view.getInt16(this.pos);
1243
- this.pos += 2;
1244
- return value;
1245
- }
1246
- readU32() {
1247
- const value = this.view.getUint32(this.pos);
1248
- this.pos += 4;
1249
- return value;
1250
- }
1251
- readI32() {
1252
- const value = this.view.getInt32(this.pos);
1253
- this.pos += 4;
1254
- return value;
1255
- }
1256
- readU64() {
1257
- const value = (0, int_ts_1.getUint64)(this.view, this.pos);
1258
- this.pos += 8;
1259
- return value;
1260
- }
1261
- readI64() {
1262
- const value = (0, int_ts_1.getInt64)(this.view, this.pos);
1263
- this.pos += 8;
1264
- return value;
1265
- }
1266
- readU64AsBigInt() {
1267
- const value = this.view.getBigUint64(this.pos);
1268
- this.pos += 8;
1269
- return value;
1270
- }
1271
- readI64AsBigInt() {
1272
- const value = this.view.getBigInt64(this.pos);
1273
- this.pos += 8;
1274
- return value;
1275
- }
1276
- readF32() {
1277
- const value = this.view.getFloat32(this.pos);
1278
- this.pos += 4;
1279
- return value;
1280
- }
1281
- readF64() {
1282
- const value = this.view.getFloat64(this.pos);
1283
- this.pos += 8;
1284
- return value;
1285
- }
1286
- };
1287
- exports.Decoder = Decoder;
1288
- }));
1289
-
1290
- //#endregion
1291
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/decode.cjs
1292
- var require_decode = /* @__PURE__ */ __commonJSMin(((exports) => {
1293
- Object.defineProperty(exports, "__esModule", { value: true });
1294
- exports.decode = decode;
1295
- exports.decodeMulti = decodeMulti;
1296
- const Decoder_ts_1 = require_Decoder();
1297
- /**
1298
- * It decodes a single MessagePack object in a buffer.
1299
- *
1300
- * This is a synchronous decoding function.
1301
- * See other variants for asynchronous decoding: {@link decodeAsync}, {@link decodeMultiStream}, or {@link decodeArrayStream}.
1302
- *
1303
- * @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
1304
- * @throws {@link DecodeError} if the buffer contains invalid data.
1305
- */
1306
- function decode(buffer, options) {
1307
- return new Decoder_ts_1.Decoder(options).decode(buffer);
1308
- }
1309
- /**
1310
- * It decodes multiple MessagePack objects in a buffer.
1311
- * This is corresponding to {@link decodeMultiStream}.
1312
- *
1313
- * @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
1314
- * @throws {@link DecodeError} if the buffer contains invalid data.
1315
- */
1316
- function decodeMulti(buffer, options) {
1317
- return new Decoder_ts_1.Decoder(options).decodeMulti(buffer);
1318
- }
1319
- }));
1320
-
1321
- //#endregion
1322
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/utils/stream.cjs
1323
- var require_stream = /* @__PURE__ */ __commonJSMin(((exports) => {
1324
- Object.defineProperty(exports, "__esModule", { value: true });
1325
- exports.isAsyncIterable = isAsyncIterable;
1326
- exports.asyncIterableFromStream = asyncIterableFromStream;
1327
- exports.ensureAsyncIterable = ensureAsyncIterable;
1328
- function isAsyncIterable(object) {
1329
- return object[Symbol.asyncIterator] != null;
1330
- }
1331
- async function* asyncIterableFromStream(stream) {
1332
- const reader = stream.getReader();
1333
- try {
1334
- while (true) {
1335
- const { done, value } = await reader.read();
1336
- if (done) return;
1337
- yield value;
1338
- }
1339
- } finally {
1340
- reader.releaseLock();
1341
- }
1342
- }
1343
- function ensureAsyncIterable(streamLike) {
1344
- if (isAsyncIterable(streamLike)) return streamLike;
1345
- else return asyncIterableFromStream(streamLike);
1346
- }
1347
- }));
1348
-
1349
- //#endregion
1350
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/decodeAsync.cjs
1351
- var require_decodeAsync = /* @__PURE__ */ __commonJSMin(((exports) => {
1352
- Object.defineProperty(exports, "__esModule", { value: true });
1353
- exports.decodeAsync = decodeAsync;
1354
- exports.decodeArrayStream = decodeArrayStream;
1355
- exports.decodeMultiStream = decodeMultiStream;
1356
- const Decoder_ts_1 = require_Decoder();
1357
- const stream_ts_1 = require_stream();
1358
- /**
1359
- * @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
1360
- * @throws {@link DecodeError} if the buffer contains invalid data.
1361
- */
1362
- async function decodeAsync(streamLike, options) {
1363
- const stream = (0, stream_ts_1.ensureAsyncIterable)(streamLike);
1364
- return new Decoder_ts_1.Decoder(options).decodeAsync(stream);
1365
- }
1366
- /**
1367
- * @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
1368
- * @throws {@link DecodeError} if the buffer contains invalid data.
1369
- */
1370
- function decodeArrayStream(streamLike, options) {
1371
- const stream = (0, stream_ts_1.ensureAsyncIterable)(streamLike);
1372
- return new Decoder_ts_1.Decoder(options).decodeArrayStream(stream);
1373
- }
1374
- /**
1375
- * @throws {@link RangeError} if the buffer is incomplete, including the case where the buffer is empty.
1376
- * @throws {@link DecodeError} if the buffer contains invalid data.
1377
- */
1378
- function decodeMultiStream(streamLike, options) {
1379
- const stream = (0, stream_ts_1.ensureAsyncIterable)(streamLike);
1380
- return new Decoder_ts_1.Decoder(options).decodeStream(stream);
1381
- }
1382
- }));
1383
-
1384
- //#endregion
1385
- //#region ../../node_modules/.pnpm/@msgpack+msgpack@3.1.2/node_modules/@msgpack/msgpack/dist.cjs/index.cjs
1386
- var require_dist = /* @__PURE__ */ __commonJSMin(((exports) => {
1387
- Object.defineProperty(exports, "__esModule", { value: true });
1388
- exports.decodeTimestampExtension = exports.encodeTimestampExtension = exports.decodeTimestampToTimeSpec = exports.encodeTimeSpecToTimestamp = exports.encodeDateToTimeSpec = exports.EXT_TIMESTAMP = exports.ExtData = exports.ExtensionCodec = exports.Encoder = exports.DecodeError = exports.Decoder = exports.decodeMultiStream = exports.decodeArrayStream = exports.decodeAsync = exports.decodeMulti = exports.decode = exports.encode = void 0;
1389
- const encode_ts_1 = require_encode();
1390
- Object.defineProperty(exports, "encode", {
1391
- enumerable: true,
1392
- get: function() {
1393
- return encode_ts_1.encode;
1394
- }
1395
- });
1396
- const decode_ts_1 = require_decode();
1397
- Object.defineProperty(exports, "decode", {
1398
- enumerable: true,
1399
- get: function() {
1400
- return decode_ts_1.decode;
1401
- }
1402
- });
1403
- Object.defineProperty(exports, "decodeMulti", {
1404
- enumerable: true,
1405
- get: function() {
1406
- return decode_ts_1.decodeMulti;
1407
- }
1408
- });
1409
- const decodeAsync_ts_1 = require_decodeAsync();
1410
- Object.defineProperty(exports, "decodeAsync", {
1411
- enumerable: true,
1412
- get: function() {
1413
- return decodeAsync_ts_1.decodeAsync;
1414
- }
1415
- });
1416
- Object.defineProperty(exports, "decodeArrayStream", {
1417
- enumerable: true,
1418
- get: function() {
1419
- return decodeAsync_ts_1.decodeArrayStream;
1420
- }
1421
- });
1422
- Object.defineProperty(exports, "decodeMultiStream", {
1423
- enumerable: true,
1424
- get: function() {
1425
- return decodeAsync_ts_1.decodeMultiStream;
1426
- }
1427
- });
1428
- const Decoder_ts_1 = require_Decoder();
1429
- Object.defineProperty(exports, "Decoder", {
1430
- enumerable: true,
1431
- get: function() {
1432
- return Decoder_ts_1.Decoder;
1433
- }
1434
- });
1435
- const DecodeError_ts_1 = require_DecodeError();
1436
- Object.defineProperty(exports, "DecodeError", {
1437
- enumerable: true,
1438
- get: function() {
1439
- return DecodeError_ts_1.DecodeError;
1440
- }
1441
- });
1442
- const Encoder_ts_1 = require_Encoder();
1443
- Object.defineProperty(exports, "Encoder", {
1444
- enumerable: true,
1445
- get: function() {
1446
- return Encoder_ts_1.Encoder;
1447
- }
1448
- });
1449
- const ExtensionCodec_ts_1 = require_ExtensionCodec();
1450
- Object.defineProperty(exports, "ExtensionCodec", {
1451
- enumerable: true,
1452
- get: function() {
1453
- return ExtensionCodec_ts_1.ExtensionCodec;
1454
- }
1455
- });
1456
- const ExtData_ts_1 = require_ExtData();
1457
- Object.defineProperty(exports, "ExtData", {
1458
- enumerable: true,
1459
- get: function() {
1460
- return ExtData_ts_1.ExtData;
1461
- }
1462
- });
1463
- const timestamp_ts_1 = require_timestamp();
1464
- Object.defineProperty(exports, "EXT_TIMESTAMP", {
1465
- enumerable: true,
1466
- get: function() {
1467
- return timestamp_ts_1.EXT_TIMESTAMP;
1468
- }
1469
- });
1470
- Object.defineProperty(exports, "encodeDateToTimeSpec", {
1471
- enumerable: true,
1472
- get: function() {
1473
- return timestamp_ts_1.encodeDateToTimeSpec;
1474
- }
1475
- });
1476
- Object.defineProperty(exports, "encodeTimeSpecToTimestamp", {
1477
- enumerable: true,
1478
- get: function() {
1479
- return timestamp_ts_1.encodeTimeSpecToTimestamp;
1480
- }
1481
- });
1482
- Object.defineProperty(exports, "decodeTimestampToTimeSpec", {
1483
- enumerable: true,
1484
- get: function() {
1485
- return timestamp_ts_1.decodeTimestampToTimeSpec;
1486
- }
1487
- });
1488
- Object.defineProperty(exports, "encodeTimestampExtension", {
1489
- enumerable: true,
1490
- get: function() {
1491
- return timestamp_ts_1.encodeTimestampExtension;
1492
- }
1493
- });
1494
- Object.defineProperty(exports, "decodeTimestampExtension", {
1495
- enumerable: true,
1496
- get: function() {
1497
- return timestamp_ts_1.decodeTimestampExtension;
1498
- }
1499
- });
1500
- }));
1501
-
1502
- //#endregion
1503
- export { require_dist as t };
1
+ new TextEncoder;function utf8DecodeJs(e,t,n){let r=t,i=r+n,a=[],o=``;for(;r<i;){let t=e[r++];if(!(t&128))a.push(t);else if((t&224)==192){let n=e[r++]&63;a.push((t&31)<<6|n)}else if((t&240)==224){let n=e[r++]&63,i=e[r++]&63;a.push((t&31)<<12|n<<6|i)}else if((t&248)==240){let n=e[r++]&63,i=e[r++]&63,o=e[r++]&63,s=(t&7)<<18|n<<12|i<<6|o;s>65535&&(s-=65536,a.push(s>>>10&1023|55296),s=56320|s&1023),a.push(s)}else a.push(t);a.length>=4096&&(o+=String.fromCharCode(...a),a.length=0)}return a.length>0&&(o+=String.fromCharCode(...a)),o}const sharedTextDecoder=new TextDecoder;function utf8DecodeTD(e,n,r){let i=e.subarray(n,n+r);return sharedTextDecoder.decode(i)}function utf8Decode(t,r,i){return i>200?utf8DecodeTD(t,r,i):utf8DecodeJs(t,r,i)}var ExtData=class{constructor(e,t){this.type=e,this.data=t}},DecodeError=class e extends Error{constructor(t){super(t);let n=Object.create(e.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,`name`,{configurable:!0,enumerable:!1,value:e.name})}};const UINT32_MAX=4294967295;function setInt64(e,t,n){let r=Math.floor(n/4294967296),i=n;e.setUint32(t,r),e.setUint32(t+4,i)}function getInt64(e,t){let n=e.getInt32(t),r=e.getUint32(t+4);return n*4294967296+r}function getUint64(e,t){let n=e.getUint32(t),r=e.getUint32(t+4);return n*4294967296+r}function encodeTimeSpecToTimestamp({sec:e,nsec:t}){if(e>=0&&t>=0&&e<=17179869183)if(t===0&&e<=4294967295){let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e),t}else{let n=e/4294967296,r=e&4294967295,i=new Uint8Array(8),a=new DataView(i.buffer);return a.setUint32(0,t<<2|n&3),a.setUint32(4,r),i}else{let n=new Uint8Array(12),r=new DataView(n.buffer);return r.setUint32(0,t),setInt64(r,4,e),n}}function encodeDateToTimeSpec(e){let t=e.getTime(),n=Math.floor(t/1e3),r=(t-n*1e3)*1e6,i=Math.floor(r/1e9);return{sec:n+i,nsec:r-i*1e9}}function encodeTimestampExtension(e){return e instanceof Date?encodeTimeSpecToTimestamp(encodeDateToTimeSpec(e)):null}function decodeTimestampToTimeSpec(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:{let e=t.getUint32(0),n=t.getUint32(4);return{sec:(e&3)*4294967296+n,nsec:e>>>2}}case 12:return{sec:getInt64(t,4),nsec:t.getUint32(0)};default:throw new DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${e.length}`)}}function decodeTimestampExtension(e){let t=decodeTimestampToTimeSpec(e);return new Date(t.sec*1e3+t.nsec/1e6)}const timestampExtension={type:-1,encode:encodeTimestampExtension,decode:decodeTimestampExtension};var ExtensionCodec=class{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(timestampExtension)}register({type:e,encode:t,decode:n}){if(e>=0)this.encoders[e]=t,this.decoders[e]=n;else{let r=-1-e;this.builtInEncoders[r]=t,this.builtInDecoders[r]=n}}tryToEncode(e,t){for(let n=0;n<this.builtInEncoders.length;n++){let r=this.builtInEncoders[n];if(r!=null){let a=r(e,t);if(a!=null)return new ExtData(-1-n,a)}}for(let n=0;n<this.encoders.length;n++){let r=this.encoders[n];if(r!=null){let a=r(e,t);if(a!=null)return new ExtData(n,a)}}return e instanceof ExtData?e:null}decode(e,t,n){let r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new ExtData(t,e)}};ExtensionCodec.defaultCodec=new ExtensionCodec;function isArrayBufferLike(e){return e instanceof ArrayBuffer||typeof SharedArrayBuffer<`u`&&e instanceof SharedArrayBuffer}function ensureUint8Array(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):isArrayBufferLike(e)?new Uint8Array(e):Uint8Array.from(e)}function prettyByte(e){return`${e<0?`-`:``}0x${Math.abs(e).toString(16).padStart(2,`0`)}`}var CachedKeyDecoder=class{constructor(e=16,t=16){this.hit=0,this.miss=0,this.maxKeyLength=e,this.maxLengthPerKey=t,this.caches=[];for(let e=0;e<this.maxKeyLength;e++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,t,n){let r=this.caches[n-1];FIND_CHUNK:for(let i of r){let r=i.bytes;for(let i=0;i<n;i++)if(r[i]!==e[t+i])continue FIND_CHUNK;return i.str}return null}store(e,t){let n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)}decode(t,n,r){let i=this.find(t,n,r);if(i!=null)return this.hit++,i;this.miss++;let a=utf8DecodeJs(t,n,r),o=Uint8Array.prototype.slice.call(t,n,n+r);return this.store(o,a),a}};const STATE_ARRAY=`array`,STATE_MAP_KEY=`map_key`,STATE_MAP_VALUE=`map_value`,mapKeyConverter=e=>{if(typeof e==`string`||typeof e==`number`)return e;throw new DecodeError(`The type of key must be string or number but `+typeof e)};var StackPool=class{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){let t=this.getUninitializedStateFromPool();t.type=STATE_ARRAY,t.position=0,t.size=e,t.array=Array(e)}pushMapState(e){let t=this.getUninitializedStateFromPool();t.type=STATE_MAP_KEY,t.readCount=0,t.size=e,t.map={}}getUninitializedStateFromPool(){return this.stackHeadPosition++,this.stackHeadPosition===this.stack.length&&this.stack.push({type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null}),this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw Error(`Invalid stack state. Released state is not on top of the stack.`);if(e.type===STATE_ARRAY){let t=e;t.size=0,t.array=void 0,t.position=0,t.type=void 0}if(e.type===STATE_MAP_KEY||e.type===STATE_MAP_VALUE){let t=e;t.size=0,t.map=void 0,t.readCount=0,t.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}};const EMPTY_VIEW=new DataView(new ArrayBuffer(0)),EMPTY_BYTES=new Uint8Array(EMPTY_VIEW.buffer);try{EMPTY_VIEW.getInt8(0)}catch(e){if(!(e instanceof RangeError))throw Error(`This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access`)}const MORE_DATA=RangeError(`Insufficient data`),sharedCachedKeyDecoder=new CachedKeyDecoder;var Decoder=class e{constructor(e){this.totalPos=0,this.pos=0,this.view=EMPTY_VIEW,this.bytes=EMPTY_BYTES,this.headByte=-1,this.stack=new StackPool,this.entered=!1,this.extensionCodec=e?.extensionCodec??ExtensionCodec.defaultCodec,this.context=e?.context,this.useBigInt64=e?.useBigInt64??!1,this.rawStrings=e?.rawStrings??!1,this.maxStrLength=e?.maxStrLength??UINT32_MAX,this.maxBinLength=e?.maxBinLength??UINT32_MAX,this.maxArrayLength=e?.maxArrayLength??UINT32_MAX,this.maxMapLength=e?.maxMapLength??UINT32_MAX,this.maxExtLength=e?.maxExtLength??UINT32_MAX,this.keyDecoder=e?.keyDecoder===void 0?sharedCachedKeyDecoder:e.keyDecoder,this.mapKeyConverter=e?.mapKeyConverter??mapKeyConverter}clone(){return new e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=-1,this.stack.reset()}setBuffer(e){let t=ensureUint8Array(e);this.bytes=t,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===-1&&!this.hasRemaining(1))this.setBuffer(e);else{let t=this.bytes.subarray(this.pos),n=ensureUint8Array(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){let{view:t,pos:n}=this;return RangeError(`Extra ${t.byteLength-n} of ${t.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);let t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let t=!1,n;for await(let r of e){if(t)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(r);try{n=this.doDecodeSync(),t=!0}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}if(t){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return n}let{headByte:r,pos:i,totalPos:a}=this;throw RangeError(`Insufficient data in parsing ${prettyByte(r)} at ${a} (${i} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,t){if(this.entered){yield*this.clone().decodeMultiAsync(e,t);return}try{this.entered=!0;let n=t,r=-1;for await(let i of e){if(t&&r===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(i),n&&(r=this.readArraySize(),n=!1,this.complete());try{for(;yield this.doDecodeSync(),--r!==0;);}catch(e){if(!(e instanceof RangeError))throw e}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){DECODE:for(;;){let e=this.readHeadByte(),t;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){let n=e-128;if(n!==0){this.pushMapState(n),this.complete();continue DECODE}else t={}}else if(e<160){let n=e-144;if(n!==0){this.pushArrayState(n),this.complete();continue DECODE}else t=[]}else{let n=e-160;t=this.decodeString(n,0)}else if(e===192)t=null;else if(e===194)t=!1;else if(e===195)t=!0;else if(e===202)t=this.readF32();else if(e===203)t=this.readF64();else if(e===204)t=this.readU8();else if(e===205)t=this.readU16();else if(e===206)t=this.readU32();else if(e===207)t=this.useBigInt64?this.readU64AsBigInt():this.readU64();else if(e===208)t=this.readI8();else if(e===209)t=this.readI16();else if(e===210)t=this.readI32();else if(e===211)t=this.useBigInt64?this.readI64AsBigInt():this.readI64();else if(e===217){let e=this.lookU8();t=this.decodeString(e,1)}else if(e===218){let e=this.lookU16();t=this.decodeString(e,2)}else if(e===219){let e=this.lookU32();t=this.decodeString(e,4)}else if(e===220){let e=this.readU16();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===221){let e=this.readU32();if(e!==0){this.pushArrayState(e),this.complete();continue DECODE}else t=[]}else if(e===222){let e=this.readU16();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===223){let e=this.readU32();if(e!==0){this.pushMapState(e),this.complete();continue DECODE}else t={}}else if(e===196){let e=this.lookU8();t=this.decodeBinary(e,1)}else if(e===197){let e=this.lookU16();t=this.decodeBinary(e,2)}else if(e===198){let e=this.lookU32();t=this.decodeBinary(e,4)}else if(e===212)t=this.decodeExtension(1,0);else if(e===213)t=this.decodeExtension(2,0);else if(e===214)t=this.decodeExtension(4,0);else if(e===215)t=this.decodeExtension(8,0);else if(e===216)t=this.decodeExtension(16,0);else if(e===199){let e=this.lookU8();t=this.decodeExtension(e,1)}else if(e===200){let e=this.lookU16();t=this.decodeExtension(e,2)}else if(e===201){let e=this.lookU32();t=this.decodeExtension(e,4)}else throw new DecodeError(`Unrecognized type byte: ${prettyByte(e)}`);this.complete();let n=this.stack;for(;n.length>0;){let e=n.top();if(e.type===STATE_ARRAY)if(e.array[e.position]=t,e.position++,e.position===e.size)t=e.array,n.release(e);else continue DECODE;else if(e.type===STATE_MAP_KEY){if(t===`__proto__`)throw new DecodeError(`The key __proto__ is not allowed`);e.key=this.mapKeyConverter(t),e.type=STATE_MAP_VALUE;continue DECODE}else if(e.map[e.key]=t,e.readCount++,e.readCount===e.size)t=e.map,n.release(e);else{e.key=null,e.type=STATE_MAP_KEY;continue DECODE}}return t}}readHeadByte(){return this.headByte===-1&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=-1}readArraySize(){let e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new DecodeError(`Unrecognized array type byte: ${prettyByte(e)}`)}}pushMapState(e){if(e>this.maxMapLength)throw new DecodeError(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new DecodeError(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,t){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,t):this.decodeBinary(e,t)}decodeUtf8String(e,t){if(e>this.maxStrLength)throw new DecodeError(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+t+e)throw MORE_DATA;let n=this.pos+t,i;return i=this.stateIsMapKey()&&this.keyDecoder?.canBeCached(e)?this.keyDecoder.decode(this.bytes,n,e):utf8Decode(this.bytes,n,e),this.pos+=t+e,i}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===STATE_MAP_KEY:!1}decodeBinary(e,t){if(e>this.maxBinLength)throw new DecodeError(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+t))throw MORE_DATA;let n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r}decodeExtension(e,t){if(e>this.maxExtLength)throw new DecodeError(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);let n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){let e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){let e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){let e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){let e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){let e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){let e=getUint64(this.view,this.pos);return this.pos+=8,e}readI64(){let e=getInt64(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){let e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){let e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){let e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){let e=this.view.getFloat64(this.pos);return this.pos+=8,e}};function decode(e,t){return new Decoder(t).decode(e)}export{decode as t};