distillate 0.8.2 → 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.
Files changed (42) hide show
  1. package/README.md +53 -6
  2. package/dist/blocked/index.cjs +15 -10
  3. package/dist/blocked/index.d.cts +7 -6
  4. package/dist/blocked/index.d.ts +7 -6
  5. package/dist/blocked/index.js +13 -9
  6. package/dist/bloom/index.cjs +35 -34
  7. package/dist/bloom/index.d.cts +22 -17
  8. package/dist/bloom/index.d.ts +22 -17
  9. package/dist/bloom/index.js +32 -32
  10. package/dist/bytes-DCuYtUVS.d.cts +4 -0
  11. package/dist/bytes-DCuYtUVS.d.ts +4 -0
  12. package/dist/frame/index.cjs +9 -0
  13. package/dist/frame/index.d.cts +2 -0
  14. package/dist/frame/index.d.ts +2 -0
  15. package/dist/frame/index.js +2 -0
  16. package/dist/fuse/index.cjs +27 -23
  17. package/dist/fuse/index.d.cts +7 -6
  18. package/dist/fuse/index.d.ts +7 -6
  19. package/dist/fuse/index.js +15 -12
  20. package/dist/hasher-D8LCBTOM.cjs +276 -0
  21. package/dist/hasher-DVWXS_vJ.js +229 -0
  22. package/dist/hll/index.cjs +366 -0
  23. package/dist/hll/index.d.cts +120 -0
  24. package/dist/hll/index.d.ts +120 -0
  25. package/dist/hll/index.js +356 -0
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.d.cts +2 -3
  28. package/dist/index.d.ts +2 -3
  29. package/dist/index.js +1 -1
  30. package/dist/serialize--xR6vGSW.d.cts +112 -0
  31. package/dist/serialize--xR6vGSW.d.ts +112 -0
  32. package/dist/serialize-CHikZ4GH.cjs +296 -0
  33. package/dist/serialize-CMSYFym-.js +201 -0
  34. package/dist/sizing-BLzZk2zr.cjs +28 -0
  35. package/dist/sizing-BtUrtvF_.js +17 -0
  36. package/dist/sizing-wYOW27eY.d.cts +22 -0
  37. package/dist/sizing-wYOW27eY.d.ts +22 -0
  38. package/package.json +26 -10
  39. package/dist/serialize-BqIcsR2J.js +0 -388
  40. package/dist/serialize-CXnRWItH.cjs +0 -513
  41. package/dist/serialize-ChyWpB9F.d.cts +0 -73
  42. package/dist/serialize-ChyWpB9F.d.ts +0 -73
@@ -1,513 +0,0 @@
1
- //#region src/core/bytes.ts
2
- const encoder = new TextEncoder();
3
- function normalize(input) {
4
- if (typeof input === "string") return encoder.encode(input);
5
- if (input instanceof Uint8Array) return input;
6
- return new Uint8Array(input);
7
- }
8
- //#endregion
9
- //#region src/core/hasher.ts
10
- let RLO = 0;
11
- let RHI = 0;
12
- const LANES = {
13
- w0: 0,
14
- w1: 0,
15
- w2: 0,
16
- w3: 0
17
- };
18
- function mul64(alo, ahi, blo, bhi) {
19
- const a0 = alo & 65535;
20
- const a1 = alo >>> 16;
21
- const a2 = ahi & 65535;
22
- const a3 = ahi >>> 16;
23
- const b0 = blo & 65535;
24
- const b1 = blo >>> 16;
25
- const b2 = bhi & 65535;
26
- const b3 = bhi >>> 16;
27
- let c0 = a0 * b0;
28
- let c1 = c0 >>> 16;
29
- c0 &= 65535;
30
- c1 += a1 * b0;
31
- let c2 = c1 >>> 16;
32
- c1 &= 65535;
33
- c1 += a0 * b1;
34
- c2 += c1 >>> 16;
35
- c1 &= 65535;
36
- c2 += a2 * b0;
37
- let c3 = c2 >>> 16;
38
- c2 &= 65535;
39
- c2 += a1 * b1;
40
- c3 += c2 >>> 16;
41
- c2 &= 65535;
42
- c2 += a0 * b2;
43
- c3 += c2 >>> 16;
44
- c2 &= 65535;
45
- c3 += a3 * b0 + a2 * b1 + a1 * b2 + a0 * b3;
46
- c3 &= 65535;
47
- RLO = (c1 << 16 | c0) >>> 0;
48
- RHI = (c3 << 16 | c2) >>> 0;
49
- }
50
- function fmix64(lo, hi) {
51
- let l = lo;
52
- let h = hi;
53
- l = (l ^ h >>> 1) >>> 0;
54
- mul64(l, h, 3981806797, 4283543511);
55
- l = RLO;
56
- h = RHI;
57
- l = (l ^ h >>> 1) >>> 0;
58
- mul64(l, h, 444984403, 3301882366);
59
- l = RLO;
60
- h = RHI;
61
- l = (l ^ h >>> 1) >>> 0;
62
- RLO = l;
63
- RHI = h;
64
- }
65
- function rotl32(x, r) {
66
- return (x << r | x >>> 32 - r) >>> 0;
67
- }
68
- function fmix32(h) {
69
- let x = h;
70
- x ^= x >>> 16;
71
- x = Math.imul(x, 2246822507);
72
- x ^= x >>> 13;
73
- x = Math.imul(x, 3266489909);
74
- x ^= x >>> 16;
75
- return x >>> 0;
76
- }
77
- const K1 = 597399067;
78
- const K2 = 2869860233;
79
- const K3 = 951274213;
80
- const K4 = 2716044179;
81
- function computeLanes(bytes, seed, len) {
82
- const nblocks = len >>> 4;
83
- let h1 = seed >>> 0;
84
- let h2 = seed >>> 0;
85
- let h3 = seed >>> 0;
86
- let h4 = seed >>> 0;
87
- for (let i = 0; i < nblocks; i++) {
88
- const b = i * 16;
89
- let k1 = ((bytes[b] ?? 0) | (bytes[b + 1] ?? 0) << 8 | (bytes[b + 2] ?? 0) << 16 | (bytes[b + 3] ?? 0) << 24) >>> 0;
90
- let k2 = ((bytes[b + 4] ?? 0) | (bytes[b + 5] ?? 0) << 8 | (bytes[b + 6] ?? 0) << 16 | (bytes[b + 7] ?? 0) << 24) >>> 0;
91
- let k3 = ((bytes[b + 8] ?? 0) | (bytes[b + 9] ?? 0) << 8 | (bytes[b + 10] ?? 0) << 16 | (bytes[b + 11] ?? 0) << 24) >>> 0;
92
- let k4 = ((bytes[b + 12] ?? 0) | (bytes[b + 13] ?? 0) << 8 | (bytes[b + 14] ?? 0) << 16 | (bytes[b + 15] ?? 0) << 24) >>> 0;
93
- k1 = Math.imul(rotl32(Math.imul(k1, K1), 15), K2);
94
- h1 ^= k1;
95
- h1 = rotl32(h1, 19);
96
- h1 = h1 + h2 >>> 0;
97
- h1 = Math.imul(h1, 5) + 1444728091 >>> 0;
98
- k2 = Math.imul(rotl32(Math.imul(k2, K2), 16), K3);
99
- h2 ^= k2;
100
- h2 = rotl32(h2, 17);
101
- h2 = h2 + h3 >>> 0;
102
- h2 = Math.imul(h2, 5) + 197830471 >>> 0;
103
- k3 = Math.imul(rotl32(Math.imul(k3, K3), 17), K4);
104
- h3 ^= k3;
105
- h3 = rotl32(h3, 15);
106
- h3 = h3 + h4 >>> 0;
107
- h3 = Math.imul(h3, 5) + 2530024501 >>> 0;
108
- k4 = Math.imul(rotl32(Math.imul(k4, K4), 18), K1);
109
- h4 ^= k4;
110
- h4 = rotl32(h4, 13);
111
- h4 = h4 + h1 >>> 0;
112
- h4 = Math.imul(h4, 5) + 850148119 >>> 0;
113
- }
114
- let k1 = 0;
115
- let k2 = 0;
116
- let k3 = 0;
117
- let k4 = 0;
118
- const tail = nblocks * 16;
119
- const rem = len & 15;
120
- if (rem >= 15) k4 ^= (bytes[tail + 14] ?? 0) << 16;
121
- if (rem >= 14) k4 ^= (bytes[tail + 13] ?? 0) << 8;
122
- if (rem >= 13) {
123
- k4 ^= bytes[tail + 12] ?? 0;
124
- k4 = Math.imul(rotl32(Math.imul(k4, K4), 18), K1);
125
- h4 ^= k4;
126
- }
127
- if (rem >= 12) k3 ^= (bytes[tail + 11] ?? 0) << 24;
128
- if (rem >= 11) k3 ^= (bytes[tail + 10] ?? 0) << 16;
129
- if (rem >= 10) k3 ^= (bytes[tail + 9] ?? 0) << 8;
130
- if (rem >= 9) {
131
- k3 ^= bytes[tail + 8] ?? 0;
132
- k3 = Math.imul(rotl32(Math.imul(k3, K3), 17), K4);
133
- h3 ^= k3;
134
- }
135
- if (rem >= 8) k2 ^= (bytes[tail + 7] ?? 0) << 24;
136
- if (rem >= 7) k2 ^= (bytes[tail + 6] ?? 0) << 16;
137
- if (rem >= 6) k2 ^= (bytes[tail + 5] ?? 0) << 8;
138
- if (rem >= 5) {
139
- k2 ^= bytes[tail + 4] ?? 0;
140
- k2 = Math.imul(rotl32(Math.imul(k2, K2), 16), K3);
141
- h2 ^= k2;
142
- }
143
- if (rem >= 4) k1 ^= (bytes[tail + 3] ?? 0) << 24;
144
- if (rem >= 3) k1 ^= (bytes[tail + 2] ?? 0) << 16;
145
- if (rem >= 2) k1 ^= (bytes[tail + 1] ?? 0) << 8;
146
- if (rem >= 1) {
147
- k1 ^= bytes[tail] ?? 0;
148
- k1 = Math.imul(rotl32(Math.imul(k1, K1), 15), K2);
149
- h1 ^= k1;
150
- }
151
- h1 = (h1 ^ len) >>> 0;
152
- h2 = (h2 ^ len) >>> 0;
153
- h3 = (h3 ^ len) >>> 0;
154
- h4 = (h4 ^ len) >>> 0;
155
- h1 = h1 + h2 >>> 0;
156
- h1 = h1 + h3 >>> 0;
157
- h1 = h1 + h4 >>> 0;
158
- h2 = h2 + h1 >>> 0;
159
- h3 = h3 + h1 >>> 0;
160
- h4 = h4 + h1 >>> 0;
161
- h1 = fmix32(h1);
162
- h2 = fmix32(h2);
163
- h3 = fmix32(h3);
164
- h4 = fmix32(h4);
165
- h1 = h1 + h2 >>> 0;
166
- h1 = h1 + h3 >>> 0;
167
- h1 = h1 + h4 >>> 0;
168
- h2 = h2 + h1 >>> 0;
169
- h3 = h3 + h1 >>> 0;
170
- h4 = h4 + h1 >>> 0;
171
- LANES.w0 = h1;
172
- LANES.w1 = h2;
173
- LANES.w2 = h3;
174
- LANES.w3 = h4;
175
- }
176
- const keyEncoder = new TextEncoder();
177
- let keyBuf = new Uint8Array(256);
178
- let encBytes = keyBuf;
179
- let encLen = 0;
180
- function encodeKey(key) {
181
- if (typeof key === "string") {
182
- const cap = key.length * 3;
183
- if (keyBuf.length < cap) keyBuf = new Uint8Array(cap);
184
- encLen = keyEncoder.encodeInto(key, keyBuf).written;
185
- encBytes = keyBuf;
186
- return;
187
- }
188
- encBytes = normalize(key);
189
- encLen = encBytes.length;
190
- }
191
- function keyToLanes(key, seed) {
192
- encodeKey(key);
193
- computeLanes(encBytes, seed, encLen);
194
- }
195
- function hash128KeyInto(key, seed, out) {
196
- keyToLanes(key, seed);
197
- out.w0 = LANES.w0;
198
- out.w1 = LANES.w1;
199
- out.w2 = LANES.w2;
200
- out.w3 = LANES.w3;
201
- }
202
- function reduce(x, range) {
203
- const xlo = x & 65535;
204
- const xhi = x >>> 16;
205
- const rlo = range & 65535;
206
- const rhi = range >>> 16;
207
- const lolo = xlo * rlo;
208
- const lohi = xlo * rhi;
209
- const hilo = xhi * rlo;
210
- const hihi = xhi * rhi;
211
- const carry = (lolo >>> 16) + (lohi & 65535) + (hilo & 65535);
212
- return hihi + (lohi >>> 16) + (hilo >>> 16) + (carry >>> 16) >>> 0;
213
- }
214
- function hash32x2Into(key, seed, out) {
215
- keyToLanes(key, seed);
216
- out[0] = LANES.w0;
217
- out[1] = LANES.w1;
218
- }
219
- function probeInto(key, count, range, seed, out) {
220
- keyToLanes(key, seed);
221
- const a = LANES.w0;
222
- const b = LANES.w1;
223
- for (let i = 0; i < count; i++) out[i] = reduce(a + Math.imul(i, b) + i * i >>> 0, range);
224
- }
225
- //#endregion
226
- //#region src/core/base64.ts
227
- const ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
228
- const DECODE = new Int16Array(128).fill(-1);
229
- for (let i = 0; i < 64; i++) DECODE[ALPHABET.charCodeAt(i)] = i;
230
- const sym = (n) => ALPHABET.charAt(n & 63);
231
- function toBase64(bytes) {
232
- let out = "";
233
- let i = 0;
234
- for (; i + 3 <= bytes.length; i += 3) {
235
- const n = (bytes[i] ?? 0) << 16 | (bytes[i + 1] ?? 0) << 8 | (bytes[i + 2] ?? 0);
236
- out += sym(n >>> 18) + sym(n >>> 12) + sym(n >>> 6) + sym(n);
237
- }
238
- const rem = bytes.length - i;
239
- if (rem === 1) {
240
- const n = (bytes[i] ?? 0) << 16;
241
- out += sym(n >>> 18) + sym(n >>> 12) + "==";
242
- } else if (rem === 2) {
243
- const n = (bytes[i] ?? 0) << 16 | (bytes[i + 1] ?? 0) << 8;
244
- out += sym(n >>> 18) + sym(n >>> 12) + sym(n >>> 6) + "=";
245
- }
246
- return out;
247
- }
248
- function fromBase64(s) {
249
- let len = s.length;
250
- while (len > 0 && s.charCodeAt(len - 1) === 61) len--;
251
- if (len % 4 === 1) throw new RangeError(`invalid base64 length ${String(len)}`);
252
- const out = new Uint8Array(len * 3 >> 2);
253
- let acc = 0;
254
- let bits = 0;
255
- let o = 0;
256
- for (let i = 0; i < len; i++) {
257
- const v = DECODE[s.charCodeAt(i)] ?? -1;
258
- if (v < 0) throw new RangeError(`invalid base64 character at index ${String(i)}`);
259
- acc = acc << 6 | v;
260
- bits += 6;
261
- if (bits >= 8) {
262
- bits -= 8;
263
- out[o++] = acc >>> bits & 255;
264
- }
265
- }
266
- return out;
267
- }
268
- //#endregion
269
- //#region src/core/crc32.ts
270
- const T1 = 256;
271
- const T2 = 512;
272
- const T3 = 768;
273
- const T4 = 1024;
274
- const T5 = 1280;
275
- const T6 = 1536;
276
- const T7 = 1792;
277
- const at = (a, i) => a[i] ?? 0;
278
- let tables;
279
- function buildTables() {
280
- const t = new Uint32Array(8 * 256);
281
- for (let n = 0; n < 256; n++) {
282
- let c = n;
283
- for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
284
- t[n] = c >>> 0;
285
- }
286
- for (let k = 1; k < 8; k++) for (let n = 0; n < 256; n++) {
287
- const p = at(t, (k - 1) * 256 + n);
288
- t[k * 256 + n] = (at(t, p & 255) ^ p >>> 8) >>> 0;
289
- }
290
- return t;
291
- }
292
- function crc32(bytes) {
293
- const t = tables ??= buildTables();
294
- const len = bytes.length;
295
- const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
296
- let crc = 4294967295;
297
- let i = 0;
298
- const last = len - 8;
299
- while (i <= last) {
300
- const one = (dv.getUint32(i, true) ^ crc) >>> 0;
301
- const two = dv.getUint32(i + 4, true);
302
- crc = (at(t, T7 + (one & 255)) ^ at(t, T6 + (one >>> 8 & 255)) ^ at(t, T5 + (one >>> 16 & 255)) ^ at(t, T4 + (one >>> 24 & 255)) ^ at(t, T3 + (two & 255)) ^ at(t, T2 + (two >>> 8 & 255)) ^ at(t, T1 + (two >>> 16 & 255)) ^ at(t, two >>> 24 & 255)) >>> 0;
303
- i += 8;
304
- }
305
- for (; i < len; i++) crc = (at(t, (crc ^ dv.getUint8(i)) & 255) ^ crc >>> 8) >>> 0;
306
- return (crc ^ 4294967295) >>> 0;
307
- }
308
- const HEADER_SIZE = 8;
309
- const TRAILER_SIZE = 4;
310
- function writeFrame(header, bodyLength, fill) {
311
- const frame = new Uint8Array(HEADER_SIZE + bodyLength + TRAILER_SIZE);
312
- frame[0] = 65;
313
- frame[1] = 77;
314
- frame[2] = 81;
315
- frame[3] = 70;
316
- frame[4] = header.version;
317
- frame[5] = header.type;
318
- frame[6] = header.flags;
319
- frame[7] = 0;
320
- fill(frame.subarray(HEADER_SIZE, HEADER_SIZE + bodyLength), new DataView(frame.buffer, HEADER_SIZE, bodyLength));
321
- const crc = crc32(frame.subarray(0, HEADER_SIZE + bodyLength));
322
- new DataView(frame.buffer, frame.byteOffset, frame.byteLength).setUint32(HEADER_SIZE + bodyLength, crc, true);
323
- return frame;
324
- }
325
- var SerializationError = class extends Error {
326
- name = "SerializationError";
327
- };
328
- var TruncatedError = class extends SerializationError {
329
- name = "TruncatedError";
330
- };
331
- var BadMagicError = class extends SerializationError {
332
- name = "BadMagicError";
333
- };
334
- var UnknownVersionError = class extends SerializationError {
335
- name = "UnknownVersionError";
336
- };
337
- var UnknownHashVariantError = class extends SerializationError {
338
- name = "UnknownHashVariantError";
339
- };
340
- var ChecksumError = class extends SerializationError {
341
- name = "ChecksumError";
342
- };
343
- const JSON_TAG = "distillate";
344
- function toJSONEnvelope(bytes) {
345
- return {
346
- $: JSON_TAG,
347
- v: 3,
348
- data: toBase64(bytes)
349
- };
350
- }
351
- function fromJSONEnvelope(value) {
352
- if (value === null || typeof value !== "object") throw new SerializationError("not a distillate filter JSON object");
353
- const o = value;
354
- if (o.$ !== JSON_TAG) throw new SerializationError(`expected "$":"${JSON_TAG}"`);
355
- if (o.v !== 3) throw new UnknownVersionError(`unsupported JSON version ${String(o.v)}, expected ${String(3)}`);
356
- if (typeof o.data !== "string") throw new SerializationError("missing string \"data\"");
357
- try {
358
- return fromBase64(o.data);
359
- } catch {
360
- throw new SerializationError("envelope data is not valid base64");
361
- }
362
- }
363
- function bytesEqual(a, b) {
364
- if (a.length !== b.length) return false;
365
- for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
366
- return true;
367
- }
368
- function assertMinBodyLength(actual, min, context) {
369
- if (actual < min) throw new TruncatedError(`${context}: body of ${String(actual)} bytes is shorter than the ${String(min)}-byte params block`);
370
- }
371
- function assertBodyLength(actual, expected, context) {
372
- if (actual !== expected) throw new TruncatedError(`${context}: body of ${String(actual)} bytes does not match the declared params (expected ${String(expected)})`);
373
- }
374
- function readHeader(frame) {
375
- if (frame.length < 12) throw new TruncatedError(`frame of ${String(frame.length)} bytes is shorter than the minimum ${String(12)}`);
376
- if (frame[0] !== 65 || frame[1] !== 77 || frame[2] !== 81 || frame[3] !== 70) throw new BadMagicError("frame does not start with the AMQF magic");
377
- const version = frame[4] ?? 0;
378
- if (version !== 3) throw new UnknownVersionError(`unsupported format version ${String(version)}`);
379
- if (new DataView(frame.buffer, frame.byteOffset, frame.byteLength).getUint32(frame.length - TRAILER_SIZE, true) !== crc32(frame.subarray(0, frame.length - TRAILER_SIZE))) throw new ChecksumError("frame CRC32 does not match its contents");
380
- return {
381
- version,
382
- type: frame[5] ?? 0,
383
- flags: frame[6] ?? 0,
384
- body: frame.subarray(HEADER_SIZE, frame.length - TRAILER_SIZE)
385
- };
386
- }
387
- //#endregion
388
- Object.defineProperty(exports, "BadMagicError", {
389
- enumerable: true,
390
- get: function() {
391
- return BadMagicError;
392
- }
393
- });
394
- Object.defineProperty(exports, "ChecksumError", {
395
- enumerable: true,
396
- get: function() {
397
- return ChecksumError;
398
- }
399
- });
400
- Object.defineProperty(exports, "RHI", {
401
- enumerable: true,
402
- get: function() {
403
- return RHI;
404
- }
405
- });
406
- Object.defineProperty(exports, "RLO", {
407
- enumerable: true,
408
- get: function() {
409
- return RLO;
410
- }
411
- });
412
- Object.defineProperty(exports, "SerializationError", {
413
- enumerable: true,
414
- get: function() {
415
- return SerializationError;
416
- }
417
- });
418
- Object.defineProperty(exports, "TruncatedError", {
419
- enumerable: true,
420
- get: function() {
421
- return TruncatedError;
422
- }
423
- });
424
- Object.defineProperty(exports, "UnknownHashVariantError", {
425
- enumerable: true,
426
- get: function() {
427
- return UnknownHashVariantError;
428
- }
429
- });
430
- Object.defineProperty(exports, "UnknownVersionError", {
431
- enumerable: true,
432
- get: function() {
433
- return UnknownVersionError;
434
- }
435
- });
436
- Object.defineProperty(exports, "assertBodyLength", {
437
- enumerable: true,
438
- get: function() {
439
- return assertBodyLength;
440
- }
441
- });
442
- Object.defineProperty(exports, "assertMinBodyLength", {
443
- enumerable: true,
444
- get: function() {
445
- return assertMinBodyLength;
446
- }
447
- });
448
- Object.defineProperty(exports, "bytesEqual", {
449
- enumerable: true,
450
- get: function() {
451
- return bytesEqual;
452
- }
453
- });
454
- Object.defineProperty(exports, "fmix64", {
455
- enumerable: true,
456
- get: function() {
457
- return fmix64;
458
- }
459
- });
460
- Object.defineProperty(exports, "fromJSONEnvelope", {
461
- enumerable: true,
462
- get: function() {
463
- return fromJSONEnvelope;
464
- }
465
- });
466
- Object.defineProperty(exports, "hash128KeyInto", {
467
- enumerable: true,
468
- get: function() {
469
- return hash128KeyInto;
470
- }
471
- });
472
- Object.defineProperty(exports, "hash32x2Into", {
473
- enumerable: true,
474
- get: function() {
475
- return hash32x2Into;
476
- }
477
- });
478
- Object.defineProperty(exports, "mul64", {
479
- enumerable: true,
480
- get: function() {
481
- return mul64;
482
- }
483
- });
484
- Object.defineProperty(exports, "probeInto", {
485
- enumerable: true,
486
- get: function() {
487
- return probeInto;
488
- }
489
- });
490
- Object.defineProperty(exports, "readHeader", {
491
- enumerable: true,
492
- get: function() {
493
- return readHeader;
494
- }
495
- });
496
- Object.defineProperty(exports, "reduce", {
497
- enumerable: true,
498
- get: function() {
499
- return reduce;
500
- }
501
- });
502
- Object.defineProperty(exports, "toJSONEnvelope", {
503
- enumerable: true,
504
- get: function() {
505
- return toJSONEnvelope;
506
- }
507
- });
508
- Object.defineProperty(exports, "writeFrame", {
509
- enumerable: true,
510
- get: function() {
511
- return writeFrame;
512
- }
513
- });
@@ -1,73 +0,0 @@
1
- //#region src/core/bytes.d.ts
2
- type BytesLike = string | Uint8Array | ArrayBuffer;
3
- //#endregion
4
- //#region src/core/serialize.d.ts
5
- /**
6
- * Base class for every defect `fromBytes` and `fromJSON` reject. Thrown
7
- * directly when a JSON envelope is malformed: not an object, missing the
8
- * `"distillate"` tag, missing `data`, or `data` that is not valid base64.
9
- * Catch this to handle any decode failure at once, or a subclass to tell the
10
- * causes apart. The input is corrupt or foreign, so discard it; retrying the
11
- * same bytes cannot succeed.
12
- */
13
- declare class SerializationError extends Error {
14
- /** Discriminates this error from other `Error`s. */
15
- override readonly name: string;
16
- }
17
- /**
18
- * Thrown when a frame is shorter than its header plus trailer, or when its
19
- * body length does not match the length its declared params imply. The bytes
20
- * were cut short in transit or storage; re-fetch the whole frame.
21
- */
22
- declare class TruncatedError extends SerializationError {
23
- /** Discriminates this error from other `Error`s. */
24
- override readonly name = "TruncatedError";
25
- }
26
- /**
27
- * Thrown when a frame does not start with the four-byte `AMQF` magic, so it
28
- * was never produced by `toBytes`. Check that the bytes really are a
29
- * distillate frame and not another payload, a text encoding of one, or a
30
- * slice taken at the wrong offset.
31
- */
32
- declare class BadMagicError extends SerializationError {
33
- /** Discriminates this error from other `Error`s. */
34
- override readonly name = "BadMagicError";
35
- }
36
- /**
37
- * Thrown when a frame or JSON envelope declares a format version this release
38
- * does not read. A reader must be at least as new as the producer, so upgrade
39
- * `distillate` or re-serialize the data with the version you run.
40
- */
41
- declare class UnknownVersionError extends SerializationError {
42
- /** Discriminates this error from other `Error`s. */
43
- override readonly name = "UnknownVersionError";
44
- }
45
- /**
46
- * Thrown when a frame's flags nibble names a hash this release cannot
47
- * reproduce, so its stored bits are unreadable. Rebuild the filter from the
48
- * source keys with the version you run.
49
- */
50
- declare class UnknownHashVariantError extends SerializationError {
51
- /** Discriminates this error from other `Error`s. */
52
- override readonly name = "UnknownHashVariantError";
53
- }
54
- /**
55
- * Thrown when a frame's CRC32 trailer does not match its contents, so the
56
- * bytes were corrupted after they were written. Discard them and re-fetch;
57
- * the payload cannot be trusted even where it still parses.
58
- */
59
- declare class ChecksumError extends SerializationError {
60
- /** Discriminates this error from other `Error`s. */
61
- override readonly name = "ChecksumError";
62
- }
63
- /** JSON-friendly envelope for a filter: the binary frame, base64-encoded. */
64
- interface FilterJSON {
65
- /** Format tag; always `"distillate"`. */
66
- $: string;
67
- /** Binary format version. */
68
- v: number;
69
- /** Base64 of the `toBytes` frame. */
70
- data: string;
71
- }
72
- //#endregion
73
- export { TruncatedError as a, BytesLike as c, SerializationError as i, ChecksumError as n, UnknownHashVariantError as o, FilterJSON as r, UnknownVersionError as s, BadMagicError as t };
@@ -1,73 +0,0 @@
1
- //#region src/core/bytes.d.ts
2
- type BytesLike = string | Uint8Array | ArrayBuffer;
3
- //#endregion
4
- //#region src/core/serialize.d.ts
5
- /**
6
- * Base class for every defect `fromBytes` and `fromJSON` reject. Thrown
7
- * directly when a JSON envelope is malformed: not an object, missing the
8
- * `"distillate"` tag, missing `data`, or `data` that is not valid base64.
9
- * Catch this to handle any decode failure at once, or a subclass to tell the
10
- * causes apart. The input is corrupt or foreign, so discard it; retrying the
11
- * same bytes cannot succeed.
12
- */
13
- declare class SerializationError extends Error {
14
- /** Discriminates this error from other `Error`s. */
15
- override readonly name: string;
16
- }
17
- /**
18
- * Thrown when a frame is shorter than its header plus trailer, or when its
19
- * body length does not match the length its declared params imply. The bytes
20
- * were cut short in transit or storage; re-fetch the whole frame.
21
- */
22
- declare class TruncatedError extends SerializationError {
23
- /** Discriminates this error from other `Error`s. */
24
- override readonly name = "TruncatedError";
25
- }
26
- /**
27
- * Thrown when a frame does not start with the four-byte `AMQF` magic, so it
28
- * was never produced by `toBytes`. Check that the bytes really are a
29
- * distillate frame and not another payload, a text encoding of one, or a
30
- * slice taken at the wrong offset.
31
- */
32
- declare class BadMagicError extends SerializationError {
33
- /** Discriminates this error from other `Error`s. */
34
- override readonly name = "BadMagicError";
35
- }
36
- /**
37
- * Thrown when a frame or JSON envelope declares a format version this release
38
- * does not read. A reader must be at least as new as the producer, so upgrade
39
- * `distillate` or re-serialize the data with the version you run.
40
- */
41
- declare class UnknownVersionError extends SerializationError {
42
- /** Discriminates this error from other `Error`s. */
43
- override readonly name = "UnknownVersionError";
44
- }
45
- /**
46
- * Thrown when a frame's flags nibble names a hash this release cannot
47
- * reproduce, so its stored bits are unreadable. Rebuild the filter from the
48
- * source keys with the version you run.
49
- */
50
- declare class UnknownHashVariantError extends SerializationError {
51
- /** Discriminates this error from other `Error`s. */
52
- override readonly name = "UnknownHashVariantError";
53
- }
54
- /**
55
- * Thrown when a frame's CRC32 trailer does not match its contents, so the
56
- * bytes were corrupted after they were written. Discard them and re-fetch;
57
- * the payload cannot be trusted even where it still parses.
58
- */
59
- declare class ChecksumError extends SerializationError {
60
- /** Discriminates this error from other `Error`s. */
61
- override readonly name = "ChecksumError";
62
- }
63
- /** JSON-friendly envelope for a filter: the binary frame, base64-encoded. */
64
- interface FilterJSON {
65
- /** Format tag; always `"distillate"`. */
66
- $: string;
67
- /** Binary format version. */
68
- v: number;
69
- /** Base64 of the `toBytes` frame. */
70
- data: string;
71
- }
72
- //#endregion
73
- export { TruncatedError as a, BytesLike as c, SerializationError as i, ChecksumError as n, UnknownHashVariantError as o, FilterJSON as r, UnknownVersionError as s, BadMagicError as t };