@evolu/common 8.9.0 → 8.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 (233) hide show
  1. package/dist/src/Bytes.d.ts +647 -0
  2. package/dist/src/Bytes.d.ts.map +1 -0
  3. package/dist/src/{Binary.js → Bytes.js} +266 -16
  4. package/dist/src/Config.d.ts +142 -0
  5. package/dist/src/Config.d.ts.map +1 -0
  6. package/dist/src/Config.js +181 -0
  7. package/dist/src/Fs.d.ts +302 -0
  8. package/dist/src/Fs.d.ts.map +1 -0
  9. package/dist/src/Fs.js +111 -0
  10. package/dist/src/Number.d.ts +50 -7
  11. package/dist/src/Number.d.ts.map +1 -1
  12. package/dist/src/Number.js +47 -8
  13. package/dist/src/Object.d.ts +32 -0
  14. package/dist/src/Object.d.ts.map +1 -1
  15. package/dist/src/Object.js +41 -0
  16. package/dist/src/Sqlite.js +1 -1
  17. package/dist/src/Time.d.ts +74 -12
  18. package/dist/src/Time.d.ts.map +1 -1
  19. package/dist/src/Time.js +40 -2
  20. package/dist/src/Type.d.ts +1451 -79
  21. package/dist/src/Type.d.ts.map +1 -1
  22. package/dist/src/Type.js +1303 -96
  23. package/dist/src/index.d.ts +3 -1
  24. package/dist/src/index.d.ts.map +1 -1
  25. package/dist/src/index.js +3 -1
  26. package/dist/src/intl/_en.d.ts +24 -1
  27. package/dist/src/intl/_en.d.ts.map +1 -1
  28. package/dist/src/intl/_en.js +20 -0
  29. package/dist/src/intl/ar.d.ts +24 -1
  30. package/dist/src/intl/ar.d.ts.map +1 -1
  31. package/dist/src/intl/ar.js +20 -0
  32. package/dist/src/intl/bn.d.ts +24 -1
  33. package/dist/src/intl/bn.d.ts.map +1 -1
  34. package/dist/src/intl/bn.js +20 -0
  35. package/dist/src/intl/ca.d.ts +24 -1
  36. package/dist/src/intl/ca.d.ts.map +1 -1
  37. package/dist/src/intl/ca.js +20 -0
  38. package/dist/src/intl/cs.d.ts +24 -1
  39. package/dist/src/intl/cs.d.ts.map +1 -1
  40. package/dist/src/intl/cs.js +20 -0
  41. package/dist/src/intl/da.d.ts +24 -1
  42. package/dist/src/intl/da.d.ts.map +1 -1
  43. package/dist/src/intl/da.js +20 -0
  44. package/dist/src/intl/de.d.ts +24 -1
  45. package/dist/src/intl/de.d.ts.map +1 -1
  46. package/dist/src/intl/de.js +20 -0
  47. package/dist/src/intl/el.d.ts +24 -1
  48. package/dist/src/intl/el.d.ts.map +1 -1
  49. package/dist/src/intl/el.js +20 -0
  50. package/dist/src/intl/es.d.ts +24 -1
  51. package/dist/src/intl/es.d.ts.map +1 -1
  52. package/dist/src/intl/es.js +20 -0
  53. package/dist/src/intl/fa.d.ts +24 -1
  54. package/dist/src/intl/fa.d.ts.map +1 -1
  55. package/dist/src/intl/fa.js +20 -0
  56. package/dist/src/intl/fi.d.ts +24 -1
  57. package/dist/src/intl/fi.d.ts.map +1 -1
  58. package/dist/src/intl/fi.js +20 -0
  59. package/dist/src/intl/fil.d.ts +24 -1
  60. package/dist/src/intl/fil.d.ts.map +1 -1
  61. package/dist/src/intl/fil.js +20 -0
  62. package/dist/src/intl/fr.d.ts +24 -1
  63. package/dist/src/intl/fr.d.ts.map +1 -1
  64. package/dist/src/intl/fr.js +20 -0
  65. package/dist/src/intl/he.d.ts +24 -1
  66. package/dist/src/intl/he.d.ts.map +1 -1
  67. package/dist/src/intl/he.js +20 -0
  68. package/dist/src/intl/hi.d.ts +24 -1
  69. package/dist/src/intl/hi.d.ts.map +1 -1
  70. package/dist/src/intl/hi.js +20 -0
  71. package/dist/src/intl/hr.d.ts +24 -1
  72. package/dist/src/intl/hr.d.ts.map +1 -1
  73. package/dist/src/intl/hr.js +20 -0
  74. package/dist/src/intl/hu.d.ts +22 -1
  75. package/dist/src/intl/hu.d.ts.map +1 -1
  76. package/dist/src/intl/hu.js +18 -0
  77. package/dist/src/intl/id.d.ts +24 -1
  78. package/dist/src/intl/id.d.ts.map +1 -1
  79. package/dist/src/intl/id.js +20 -0
  80. package/dist/src/intl/it.d.ts +24 -1
  81. package/dist/src/intl/it.d.ts.map +1 -1
  82. package/dist/src/intl/it.js +20 -0
  83. package/dist/src/intl/ja.d.ts +24 -1
  84. package/dist/src/intl/ja.d.ts.map +1 -1
  85. package/dist/src/intl/ja.js +20 -0
  86. package/dist/src/intl/ko.d.ts +24 -1
  87. package/dist/src/intl/ko.d.ts.map +1 -1
  88. package/dist/src/intl/ko.js +20 -0
  89. package/dist/src/intl/ml.d.ts +24 -1
  90. package/dist/src/intl/ml.d.ts.map +1 -1
  91. package/dist/src/intl/ml.js +20 -0
  92. package/dist/src/intl/mr.d.ts +24 -1
  93. package/dist/src/intl/mr.d.ts.map +1 -1
  94. package/dist/src/intl/mr.js +20 -0
  95. package/dist/src/intl/ms.d.ts +24 -1
  96. package/dist/src/intl/ms.d.ts.map +1 -1
  97. package/dist/src/intl/ms.js +20 -0
  98. package/dist/src/intl/nb.d.ts +22 -1
  99. package/dist/src/intl/nb.d.ts.map +1 -1
  100. package/dist/src/intl/nb.js +18 -0
  101. package/dist/src/intl/nl.d.ts +24 -1
  102. package/dist/src/intl/nl.d.ts.map +1 -1
  103. package/dist/src/intl/nl.js +20 -0
  104. package/dist/src/intl/pa.d.ts +24 -1
  105. package/dist/src/intl/pa.d.ts.map +1 -1
  106. package/dist/src/intl/pa.js +20 -0
  107. package/dist/src/intl/pl.d.ts +23 -0
  108. package/dist/src/intl/pl.d.ts.map +1 -1
  109. package/dist/src/intl/pl.js +20 -0
  110. package/dist/src/intl/pt-BR.d.ts +24 -1
  111. package/dist/src/intl/pt-BR.d.ts.map +1 -1
  112. package/dist/src/intl/pt-BR.js +20 -0
  113. package/dist/src/intl/pt.d.ts +24 -1
  114. package/dist/src/intl/pt.d.ts.map +1 -1
  115. package/dist/src/intl/pt.js +20 -0
  116. package/dist/src/intl/ro.d.ts +24 -1
  117. package/dist/src/intl/ro.d.ts.map +1 -1
  118. package/dist/src/intl/ro.js +20 -0
  119. package/dist/src/intl/sk.d.ts +24 -1
  120. package/dist/src/intl/sk.d.ts.map +1 -1
  121. package/dist/src/intl/sk.js +20 -0
  122. package/dist/src/intl/sl.d.ts +24 -1
  123. package/dist/src/intl/sl.d.ts.map +1 -1
  124. package/dist/src/intl/sl.js +20 -0
  125. package/dist/src/intl/sv.d.ts +24 -1
  126. package/dist/src/intl/sv.d.ts.map +1 -1
  127. package/dist/src/intl/sv.js +20 -0
  128. package/dist/src/intl/sw.d.ts +21 -0
  129. package/dist/src/intl/sw.d.ts.map +1 -1
  130. package/dist/src/intl/sw.js +18 -0
  131. package/dist/src/intl/ta.d.ts +24 -1
  132. package/dist/src/intl/ta.d.ts.map +1 -1
  133. package/dist/src/intl/ta.js +20 -0
  134. package/dist/src/intl/te.d.ts +24 -1
  135. package/dist/src/intl/te.d.ts.map +1 -1
  136. package/dist/src/intl/te.js +20 -0
  137. package/dist/src/intl/th.d.ts +24 -1
  138. package/dist/src/intl/th.d.ts.map +1 -1
  139. package/dist/src/intl/th.js +20 -0
  140. package/dist/src/intl/tr.d.ts +24 -1
  141. package/dist/src/intl/tr.d.ts.map +1 -1
  142. package/dist/src/intl/tr.js +20 -0
  143. package/dist/src/intl/uk.d.ts +80 -57
  144. package/dist/src/intl/uk.d.ts.map +1 -1
  145. package/dist/src/intl/uk.js +174 -149
  146. package/dist/src/intl/ur.d.ts +24 -1
  147. package/dist/src/intl/ur.d.ts.map +1 -1
  148. package/dist/src/intl/ur.js +20 -0
  149. package/dist/src/intl/vi.d.ts +24 -1
  150. package/dist/src/intl/vi.d.ts.map +1 -1
  151. package/dist/src/intl/vi.js +20 -0
  152. package/dist/src/intl/zh-CN.d.ts +24 -1
  153. package/dist/src/intl/zh-CN.d.ts.map +1 -1
  154. package/dist/src/intl/zh-CN.js +20 -0
  155. package/dist/src/intl/zh-TW.d.ts +24 -1
  156. package/dist/src/intl/zh-TW.d.ts.map +1 -1
  157. package/dist/src/intl/zh-TW.js +20 -0
  158. package/dist/src/local-first/Protocol.d.ts +1 -1
  159. package/dist/src/local-first/Protocol.d.ts.map +1 -1
  160. package/dist/src/local-first/Protocol.js +1 -1
  161. package/dist/src/local-first/Schema.d.ts +10 -0
  162. package/dist/src/local-first/Schema.d.ts.map +1 -1
  163. package/dist/src/local-first/Storage.js +1 -1
  164. package/dist/src/local-first/Timestamp.js +1 -1
  165. package/package.json +1 -1
  166. package/src/{Binary.test.ts → Bytes.test.ts} +286 -1
  167. package/src/{Binary.ts → Bytes.ts} +652 -21
  168. package/src/Config.test.ts +672 -0
  169. package/src/Config.ts +410 -0
  170. package/src/Fs.test.ts +105 -0
  171. package/src/Fs.ts +414 -0
  172. package/src/Number.test.ts +82 -18
  173. package/src/Number.ts +76 -8
  174. package/src/Object.test.ts +115 -1
  175. package/src/Object.ts +44 -0
  176. package/src/Sqlite.ts +1 -1
  177. package/src/Time.test.ts +82 -11
  178. package/src/Time.ts +141 -16
  179. package/src/Type.test.ts +3114 -157
  180. package/src/Type.ts +2553 -196
  181. package/src/index.ts +3 -1
  182. package/src/intl/_en.ts +70 -0
  183. package/src/intl/ar.ts +71 -0
  184. package/src/intl/bn.ts +70 -0
  185. package/src/intl/ca.ts +70 -0
  186. package/src/intl/cs.ts +70 -0
  187. package/src/intl/da.ts +70 -0
  188. package/src/intl/de.ts +70 -0
  189. package/src/intl/el.ts +70 -0
  190. package/src/intl/es.ts +70 -0
  191. package/src/intl/fa.ts +70 -0
  192. package/src/intl/fi.ts +70 -0
  193. package/src/intl/fil.ts +70 -0
  194. package/src/intl/fr.ts +70 -0
  195. package/src/intl/he.ts +70 -0
  196. package/src/intl/hi.ts +70 -0
  197. package/src/intl/hr.ts +70 -0
  198. package/src/intl/hu.ts +69 -0
  199. package/src/intl/id.ts +70 -0
  200. package/src/intl/intl.test.ts +819 -1
  201. package/src/intl/it.ts +70 -0
  202. package/src/intl/ja.ts +70 -0
  203. package/src/intl/ko.ts +68 -0
  204. package/src/intl/ml.ts +70 -0
  205. package/src/intl/mr.ts +70 -0
  206. package/src/intl/ms.ts +71 -0
  207. package/src/intl/nb.ts +69 -0
  208. package/src/intl/nl.ts +70 -0
  209. package/src/intl/pa.ts +70 -0
  210. package/src/intl/pl.ts +63 -0
  211. package/src/intl/pt-BR.ts +70 -0
  212. package/src/intl/pt.ts +71 -0
  213. package/src/intl/ro.ts +70 -0
  214. package/src/intl/sk.ts +71 -0
  215. package/src/intl/sl.ts +70 -0
  216. package/src/intl/sv.ts +70 -0
  217. package/src/intl/sw.ts +62 -0
  218. package/src/intl/ta.ts +70 -0
  219. package/src/intl/te.ts +70 -0
  220. package/src/intl/th.ts +68 -0
  221. package/src/intl/tr.ts +70 -0
  222. package/src/intl/uk.ts +228 -155
  223. package/src/intl/ur.ts +70 -0
  224. package/src/intl/vi.ts +70 -0
  225. package/src/intl/zh-CN.ts +68 -0
  226. package/src/intl/zh-TW.ts +68 -0
  227. package/src/local-first/Protocol.test.ts +1 -1
  228. package/src/local-first/Protocol.ts +1 -1
  229. package/src/local-first/Schema.ts +11 -0
  230. package/src/local-first/Storage.ts +1 -1
  231. package/src/local-first/Timestamp.ts +1 -1
  232. package/dist/src/Binary.d.ts +0 -254
  233. package/dist/src/Binary.d.ts.map +0 -1
@@ -0,0 +1,647 @@
1
+ /**
2
+ * Bytes: `Uint8Array` helpers, the {@link Buffer} codec, and byte sizes.
3
+ *
4
+ * Sizes follow the same pattern as durations in Time.ts:
5
+ *
6
+ * - {@link ByteLength} is the canonical unit, a validated number of bytes.
7
+ * - {@link ByteSizeLiteral} is the human-readable form, such as `"10MiB"`,
8
+ * validated at compile time and runtime.
9
+ * - {@link ByteSize} is what APIs accept: `ByteSizeLiteral | ByteLength`.
10
+ * - {@link byteSizeToByteLength} normalizes a `ByteSize` to a `ByteLength`.
11
+ * - {@link ByteLengthFromString} parses either form from text.
12
+ *
13
+ * Buffer-based decoding functions throw instead of returning {@link Result}.
14
+ * Result is not slow, but every successful decode would allocate one, and a
15
+ * protocol message decodes many values. Throwing is the safe bet for that hot
16
+ * path until benchmarks cover the alternatives. Callers convert a thrown error
17
+ * into a Result once, at the boundary, as `parseProtocolHeader` in Protocol.ts
18
+ * does.
19
+ *
20
+ * @module
21
+ */
22
+ import { bytesToUtf8, utf8ToBytes } from "@noble/ciphers/utils.js";
23
+ import { Digit, Digit1To9, type FiniteNumber, type JsonValue, NonNegativeInt, type PositiveInt, type TemplateLiteralType, type LiteralType, type UnionType, type Type, type TypeError, type UnionError } from "./Type.ts";
24
+ export { bytesToHex, concatBytes, hexToBytes } from "@noble/ciphers/utils.js";
25
+ export { bytesToUtf8, utf8ToBytes };
26
+ /**
27
+ * Custom error for {@link Buffer}-related failures like premature end of data.
28
+ * Provides better stack traces for debugging binary protocol issues.
29
+ */
30
+ export declare class BufferError extends Error {
31
+ constructor(message: string);
32
+ }
33
+ /**
34
+ * A Buffer is a dynamic, resizable container for binary data, optimized for
35
+ * scenarios where the final size is unknown. It grows exponentially (doubling
36
+ * its capacity) to minimize memory reallocations and uses `subarray` for
37
+ * efficient, copy-free data access in methods like `unwrap` and `shift`.
38
+ *
39
+ * ## Recommended Usage
40
+ *
41
+ * Create as few Buffers as possible—typically one main Buffer for the final
42
+ * output. Temporary Buffers are allowed when necessary (e.g., for
43
+ * variable-length headers), but avoid excessive allocations. Buffers can be
44
+ * reused within functions by leveraging `reset` to clear contents while
45
+ * preserving capacity, or `truncate` to adjust the length to a specific size,
46
+ * reducing the need for new allocations. Pass Buffers to `encode*` functions to
47
+ * append serialized data and use `decode*` functions to extract data.
48
+ *
49
+ * ### Example
50
+ *
51
+ * ```ts
52
+ * import {
53
+ * assertEqual,
54
+ * assertErr,
55
+ * assertInstanceOf,
56
+ * createBuffer,
57
+ * createIdFromString,
58
+ * IdBytes,
59
+ * idBytesToId,
60
+ * idBytesTypeValueLength,
61
+ * idToIdBytes,
62
+ * NonNegativeInt,
63
+ * trySync,
64
+ * decodeNonNegativeInt,
65
+ * encodeNonNegativeInt,
66
+ * } from "@evolu/common";
67
+ *
68
+ * const buffer = createBuffer();
69
+ * const id = createIdFromString("buffer-example");
70
+ * encodeNonNegativeInt(buffer, NonNegativeInt.orThrow(300));
71
+ * buffer.extend(idToIdBytes(id));
72
+ *
73
+ * const decoder = createBuffer(buffer.unwrap());
74
+ * assertEqual(decodeNonNegativeInt(decoder), 300);
75
+ * const decodedId = idBytesToId(
76
+ * IdBytes.orThrow(decoder.shiftN(idBytesTypeValueLength)),
77
+ * );
78
+ * assertEqual(decodedId, id);
79
+ * const result = trySync(() => decodeNonNegativeInt(decoder));
80
+ * assertErr(result);
81
+ * assertInstanceOf(result.error, Error);
82
+ * assertEqual(result.error.message, "Buffer parse ended prematurely");
83
+ * ```
84
+ *
85
+ * For more on exponential growth, see:
86
+ * https://blog.mozilla.org/nnethercote/2014/11/04/please-grow-your-buffers-exponentially
87
+ */
88
+ export interface Buffer {
89
+ /** Returns the current capacity of the buffer. */
90
+ getCapacity: () => NonNegativeInt;
91
+ /** Returns the current number of bytes stored in the buffer. */
92
+ getLength: () => NonNegativeInt;
93
+ /**
94
+ * Appends binary data to the buffer, resizing if necessary. Throws if
95
+ * `arg.length` is not a non-negative safe integer.
96
+ */
97
+ extend: (arg: Uint8Array | ArrayLike<number>) => void;
98
+ /**
99
+ * Removes and returns the first byte. Throws an `Error` with message "Buffer
100
+ * parse ended prematurely" if the buffer is empty.
101
+ */
102
+ shift: () => NonNegativeInt;
103
+ /**
104
+ * Removes and returns the first `n` bytes. Throws an `Error` with message
105
+ * "Buffer parse ended prematurely" if fewer than `n` bytes remain.
106
+ */
107
+ shiftN: (n: NonNegativeInt) => Uint8Array;
108
+ /**
109
+ * Truncates the buffer to the specified length, discarding data from the end.
110
+ * Throws if the new length is greater than the current length.
111
+ */
112
+ truncate: (length: NonNegativeInt) => void;
113
+ /**
114
+ * Resets the buffer to its initial empty state, preserving its capacity.
115
+ *
116
+ * This allows efficient buffer reuse without reallocating memory. Use this
117
+ * when you want to clear the buffer and write new data, avoiding unnecessary
118
+ * allocations.
119
+ */
120
+ reset: () => void;
121
+ /**
122
+ * Returns a view of the buffer’s current data. Do not modify this array, as
123
+ * it directly alters the buffer’s internal state, potentially breaking
124
+ * subsequent operations.
125
+ */
126
+ unwrap: () => Uint8Array;
127
+ }
128
+ /** Creates a {@link Buffer} for efficient byte operations. */
129
+ export declare const createBuffer: (arrayLike?: Uint8Array | ArrayLike<number>) => Buffer;
130
+ /**
131
+ * Evolu uses MessagePack to handle finite numbers except for NonNegativeInt.
132
+ * For NonNegativeInt, Evolu provides more efficient encoding.
133
+ */
134
+ export declare const encodeNumber: (buffer: Buffer, number: FiniteNumber) => void;
135
+ export declare const decodeNumber: (buffer: Buffer) => FiniteNumber;
136
+ /**
137
+ * Encodes an array of boolean flags into a single byte.
138
+ *
139
+ * Each element in the array corresponds to a bit (0-7). Array can have 0-8
140
+ * elements.
141
+ *
142
+ * ### Example
143
+ *
144
+ * ```ts
145
+ * import { assertEqual, createBuffer, encodeFlags } from "@evolu/common";
146
+ *
147
+ * const buffer = createBuffer();
148
+ * encodeFlags(buffer, [true, false, true]);
149
+ *
150
+ * assertEqual(buffer.unwrap(), new Uint8Array([0b101]));
151
+ * ```
152
+ */
153
+ export declare const encodeFlags: (buffer: Buffer, flags: ReadonlyArray<boolean>) => void;
154
+ /**
155
+ * Decodes a byte into an array of boolean flags.
156
+ *
157
+ * ### Example
158
+ *
159
+ * ```ts
160
+ * import {
161
+ * assertEqual,
162
+ * createBuffer,
163
+ * decodeFlags,
164
+ * PositiveInt,
165
+ * } from "@evolu/common";
166
+ *
167
+ * const buffer = createBuffer([0b101]);
168
+ * const flags = decodeFlags(buffer, PositiveInt.orThrow(3));
169
+ *
170
+ * assertEqual(flags, [true, false, true]);
171
+ * assertEqual(buffer.getLength(), 0);
172
+ * ```
173
+ */
174
+ export declare const decodeFlags: (buffer: Buffer, count: PositiveInt) => ReadonlyArray<boolean>;
175
+ /**
176
+ * Encodes a non-negative integer into a variable-length integer format. It's
177
+ * more efficient than encoding via {@link encodeNumber}.
178
+ *
179
+ * https://en.wikipedia.org/wiki/Variable-length_quantity
180
+ */
181
+ export declare const encodeNonNegativeInt: (buffer: Buffer, value: NonNegativeInt) => void;
182
+ /**
183
+ * Decodes a non-negative integer from a variable-length integer format.
184
+ *
185
+ * https://en.wikipedia.org/wiki/Variable-length_quantity
186
+ */
187
+ export declare const decodeNonNegativeInt: (buffer: Buffer) => NonNegativeInt;
188
+ /** Encodes the length of an array-like value. */
189
+ export declare const encodeLength: (buffer: Buffer, value: ArrayLike<unknown>) => void;
190
+ /** Decodes an array-like value length. */
191
+ export declare const decodeLength: typeof decodeNonNegativeInt;
192
+ /** Encodes a length-prefixed UTF-8 string. */
193
+ export declare const encodeString: (buffer: Buffer, value: string) => void;
194
+ /** Decodes a length-prefixed UTF-8 string. */
195
+ export declare const decodeString: (buffer: Buffer) => string;
196
+ /** Incrementally encodes consecutive equal values using run-length encoding. */
197
+ export interface RunLengthEncoder<T> {
198
+ readonly add: (value: T) => void;
199
+ readonly getLength: () => NonNegativeInt;
200
+ readonly unwrap: () => Uint8Array;
201
+ }
202
+ /** Creates an incremental run-length encoder. */
203
+ export declare const createRunLengthEncoder: <T>(encodeValue: (buffer: Buffer, value: T) => void) => RunLengthEncoder<T>;
204
+ /** Decodes a run-length encoded sequence. */
205
+ export declare const decodeRle: <T>(buffer: Buffer, length: NonNegativeInt, decodeValue: () => T) => ReadonlyArray<T>;
206
+ /**
207
+ * Encodes a {@link JsonValue} using the MessagePack format.
208
+ *
209
+ * ### Example
210
+ *
211
+ * ```ts
212
+ * import {
213
+ * assertEqual,
214
+ * createBuffer,
215
+ * encodeJsonValue,
216
+ * JsonValue,
217
+ * } from "@evolu/common";
218
+ *
219
+ * const buffer = createBuffer();
220
+ * const value = JsonValue.orThrow({ name: "Ada" });
221
+ *
222
+ * encodeJsonValue(buffer, value);
223
+ *
224
+ * assertEqual(
225
+ * buffer.unwrap(),
226
+ * new Uint8Array([
227
+ * 0x81, 0xa4, 0x6e, 0x61, 0x6d, 0x65, 0xa3, 0x41, 0x64, 0x61,
228
+ * ]),
229
+ * );
230
+ * ```
231
+ *
232
+ * Encoding is artificially limited to 1,000 nested arrays or objects to keep
233
+ * recursive encoding and decoding safe and symmetric. JSON data should not
234
+ * require such depth; flatten or split deeply nested data, or use a
235
+ * purpose-built serialization format.
236
+ */
237
+ export declare const encodeJsonValue: (buffer: Buffer, value: JsonValue) => void;
238
+ /**
239
+ * Decodes a {@link JsonValue} using the MessagePack format.
240
+ *
241
+ * Throws a {@link BufferError} without modifying the Buffer if the encoded value
242
+ * is malformed, truncated, unsupported, outside the JsonValue domain, or
243
+ * exceeds 1,000 nested arrays or objects.
244
+ *
245
+ * ### Example
246
+ *
247
+ * ```ts
248
+ * import {
249
+ * assertEqual,
250
+ * createBuffer,
251
+ * decodeJsonValue,
252
+ * } from "@evolu/common";
253
+ *
254
+ * const buffer = createBuffer([
255
+ * 0x81, 0xa4, 0x6e, 0x61, 0x6d, 0x65, 0xa3, 0x41, 0x64, 0x61,
256
+ * ]);
257
+ *
258
+ * assertEqual(decodeJsonValue(buffer), { name: "Ada" });
259
+ * assertEqual(buffer.unwrap(), new Uint8Array());
260
+ * ```
261
+ */
262
+ export declare const decodeJsonValue: (buffer: Buffer) => JsonValue;
263
+ /**
264
+ * Non-negative safe integer number of bytes.
265
+ *
266
+ * The canonical unit for sizes, as milliseconds are for time. APIs accept
267
+ * {@link ByteSize} and normalize it with {@link byteSizeToByteLength}. Parse text
268
+ * such as an environment variable with {@link ByteLengthFromString}. Negative
269
+ * zero is rejected so zero has one canonical representation.
270
+ *
271
+ * ### Example
272
+ *
273
+ * ```ts
274
+ * import { assertErr, assertOk, ByteLength } from "@evolu/common";
275
+ *
276
+ * assertOk(ByteLength.fromUnknown(0), 0);
277
+ * assertOk(ByteLength.fromUnknown(1024), 1024);
278
+ * assertErr(ByteLength.fromUnknown(-0));
279
+ * assertErr(ByteLength.fromUnknown(-1));
280
+ * assertErr(ByteLength.fromUnknown(1.5));
281
+ * ```
282
+ */
283
+ export declare const ByteLength: import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<Type<"Number", number, number, import("./Type.ts").TypeOfError<"Number">, null, import("./Type.ts").TypeOfError<"Number">, never, number, true>, "NonNaN", import("./Type.ts").NonNaNError>, "Finite", import("./Type.ts").FiniteError>, "Int", import("./Type.ts").IntError>, "NonNegative", import("./Type.ts").NonNegativeError>, "ByteLength", ByteLengthError>;
284
+ export type ByteLength = typeof ByteLength.Output;
285
+ /** Error returned when {@link ByteLength} rejects negative zero. */
286
+ export interface ByteLengthError extends TypeError<"ByteLength"> {
287
+ readonly value: number;
288
+ }
289
+ /** Bytes: `"0B"` to `"1023B"`. See {@link ByteSizeLiteral}. */
290
+ export declare const ByteSizeLiteralBytes: UnionType<readonly [
291
+ TemplateLiteralType<readonly [typeof Digit, "B"]>,
292
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, "B"]>,
293
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, typeof Digit, "B"]>,
294
+ TemplateLiteralType<readonly [
295
+ "10",
296
+ UnionType<readonly [LiteralType<"0">, LiteralType<"1">]>,
297
+ typeof Digit,
298
+ "B"
299
+ ]>,
300
+ TemplateLiteralType<readonly [
301
+ "102",
302
+ UnionType<readonly [
303
+ LiteralType<"0">,
304
+ LiteralType<"1">,
305
+ LiteralType<"2">,
306
+ LiteralType<"3">
307
+ ]>,
308
+ "B"
309
+ ]>
310
+ ]>;
311
+ export type ByteSizeLiteralBytes = typeof ByteSizeLiteralBytes.Output;
312
+ /**
313
+ * KiB: `"1KiB"` to `"1023KiB"` or `"1.5KiB"` to `"1023.5KiB"`. See
314
+ * {@link ByteSizeLiteral}.
315
+ */
316
+ export declare const ByteSizeLiteralKiB: UnionType<readonly [
317
+ TemplateLiteralType<readonly [typeof Digit1To9, "KiB"]>,
318
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, "KiB"]>,
319
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, typeof Digit, "KiB"]>,
320
+ TemplateLiteralType<readonly [
321
+ "10",
322
+ UnionType<readonly [LiteralType<"0">, LiteralType<"1">]>,
323
+ typeof Digit,
324
+ "KiB"
325
+ ]>,
326
+ TemplateLiteralType<readonly [
327
+ "102",
328
+ UnionType<readonly [
329
+ LiteralType<"0">,
330
+ LiteralType<"1">,
331
+ LiteralType<"2">,
332
+ LiteralType<"3">
333
+ ]>,
334
+ "KiB"
335
+ ]>,
336
+ TemplateLiteralType<readonly [typeof Digit1To9, ".5KiB"]>,
337
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, ".5KiB"]>,
338
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, typeof Digit, ".5KiB"]>,
339
+ TemplateLiteralType<readonly [
340
+ "10",
341
+ UnionType<readonly [LiteralType<"0">, LiteralType<"1">]>,
342
+ typeof Digit,
343
+ ".5KiB"
344
+ ]>,
345
+ TemplateLiteralType<readonly [
346
+ "102",
347
+ UnionType<readonly [
348
+ LiteralType<"0">,
349
+ LiteralType<"1">,
350
+ LiteralType<"2">,
351
+ LiteralType<"3">
352
+ ]>,
353
+ ".5KiB"
354
+ ]>
355
+ ]>;
356
+ export type ByteSizeLiteralKiB = typeof ByteSizeLiteralKiB.Output;
357
+ /**
358
+ * MiB: `"1MiB"` to `"1023MiB"` or `"1.5MiB"` to `"1023.5MiB"`. See
359
+ * {@link ByteSizeLiteral}.
360
+ */
361
+ export declare const ByteSizeLiteralMiB: UnionType<readonly [
362
+ TemplateLiteralType<readonly [typeof Digit1To9, "MiB"]>,
363
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, "MiB"]>,
364
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, typeof Digit, "MiB"]>,
365
+ TemplateLiteralType<readonly [
366
+ "10",
367
+ UnionType<readonly [LiteralType<"0">, LiteralType<"1">]>,
368
+ typeof Digit,
369
+ "MiB"
370
+ ]>,
371
+ TemplateLiteralType<readonly [
372
+ "102",
373
+ UnionType<readonly [
374
+ LiteralType<"0">,
375
+ LiteralType<"1">,
376
+ LiteralType<"2">,
377
+ LiteralType<"3">
378
+ ]>,
379
+ "MiB"
380
+ ]>,
381
+ TemplateLiteralType<readonly [typeof Digit1To9, ".5MiB"]>,
382
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, ".5MiB"]>,
383
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, typeof Digit, ".5MiB"]>,
384
+ TemplateLiteralType<readonly [
385
+ "10",
386
+ UnionType<readonly [LiteralType<"0">, LiteralType<"1">]>,
387
+ typeof Digit,
388
+ ".5MiB"
389
+ ]>,
390
+ TemplateLiteralType<readonly [
391
+ "102",
392
+ UnionType<readonly [
393
+ LiteralType<"0">,
394
+ LiteralType<"1">,
395
+ LiteralType<"2">,
396
+ LiteralType<"3">
397
+ ]>,
398
+ ".5MiB"
399
+ ]>
400
+ ]>;
401
+ export type ByteSizeLiteralMiB = typeof ByteSizeLiteralMiB.Output;
402
+ /**
403
+ * GiB: `"1GiB"` to `"1023GiB"` or `"1.5GiB"` to `"1023.5GiB"`. See
404
+ * {@link ByteSizeLiteral}.
405
+ */
406
+ export declare const ByteSizeLiteralGiB: UnionType<readonly [
407
+ TemplateLiteralType<readonly [typeof Digit1To9, "GiB"]>,
408
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, "GiB"]>,
409
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, typeof Digit, "GiB"]>,
410
+ TemplateLiteralType<readonly [
411
+ "10",
412
+ UnionType<readonly [LiteralType<"0">, LiteralType<"1">]>,
413
+ typeof Digit,
414
+ "GiB"
415
+ ]>,
416
+ TemplateLiteralType<readonly [
417
+ "102",
418
+ UnionType<readonly [
419
+ LiteralType<"0">,
420
+ LiteralType<"1">,
421
+ LiteralType<"2">,
422
+ LiteralType<"3">
423
+ ]>,
424
+ "GiB"
425
+ ]>,
426
+ TemplateLiteralType<readonly [typeof Digit1To9, ".5GiB"]>,
427
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, ".5GiB"]>,
428
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, typeof Digit, ".5GiB"]>,
429
+ TemplateLiteralType<readonly [
430
+ "10",
431
+ UnionType<readonly [LiteralType<"0">, LiteralType<"1">]>,
432
+ typeof Digit,
433
+ ".5GiB"
434
+ ]>,
435
+ TemplateLiteralType<readonly [
436
+ "102",
437
+ UnionType<readonly [
438
+ LiteralType<"0">,
439
+ LiteralType<"1">,
440
+ LiteralType<"2">,
441
+ LiteralType<"3">
442
+ ]>,
443
+ ".5GiB"
444
+ ]>
445
+ ]>;
446
+ export type ByteSizeLiteralGiB = typeof ByteSizeLiteralGiB.Output;
447
+ /**
448
+ * TiB: `"1TiB"` to `"1023TiB"` or `"1.5TiB"` to `"1023.5TiB"`. See
449
+ * {@link ByteSizeLiteral}.
450
+ */
451
+ export declare const ByteSizeLiteralTiB: UnionType<readonly [
452
+ TemplateLiteralType<readonly [typeof Digit1To9, "TiB"]>,
453
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, "TiB"]>,
454
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, typeof Digit, "TiB"]>,
455
+ TemplateLiteralType<readonly [
456
+ "10",
457
+ UnionType<readonly [LiteralType<"0">, LiteralType<"1">]>,
458
+ typeof Digit,
459
+ "TiB"
460
+ ]>,
461
+ TemplateLiteralType<readonly [
462
+ "102",
463
+ UnionType<readonly [
464
+ LiteralType<"0">,
465
+ LiteralType<"1">,
466
+ LiteralType<"2">,
467
+ LiteralType<"3">
468
+ ]>,
469
+ "TiB"
470
+ ]>,
471
+ TemplateLiteralType<readonly [typeof Digit1To9, ".5TiB"]>,
472
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, ".5TiB"]>,
473
+ TemplateLiteralType<readonly [typeof Digit1To9, typeof Digit, typeof Digit, ".5TiB"]>,
474
+ TemplateLiteralType<readonly [
475
+ "10",
476
+ UnionType<readonly [LiteralType<"0">, LiteralType<"1">]>,
477
+ typeof Digit,
478
+ ".5TiB"
479
+ ]>,
480
+ TemplateLiteralType<readonly [
481
+ "102",
482
+ UnionType<readonly [
483
+ LiteralType<"0">,
484
+ LiteralType<"1">,
485
+ LiteralType<"2">,
486
+ LiteralType<"3">
487
+ ]>,
488
+ ".5TiB"
489
+ ]>
490
+ ]>;
491
+ export type ByteSizeLiteralTiB = typeof ByteSizeLiteralTiB.Output;
492
+ export type ByteSizeLiteral = ByteSizeLiteralBytes | ByteSizeLiteralKiB | ByteSizeLiteralMiB | ByteSizeLiteralGiB | ByteSizeLiteralTiB;
493
+ /**
494
+ * Byte length literal Type with compile-time and runtime validation.
495
+ *
496
+ * Supported formats:
497
+ *
498
+ * - Bytes: `0B` to `1023B`
499
+ * - KiB: `1KiB` to `1023KiB` or `1.5KiB` to `1023.5KiB`
500
+ * - MiB: `1MiB` to `1023MiB` or `1.5MiB` to `1023.5MiB`
501
+ * - GiB: `1GiB` to `1023GiB` or `1.5GiB` to `1023.5GiB`
502
+ * - TiB: `1TiB` to `1023TiB` or `1.5TiB` to `1023.5TiB`
503
+ *
504
+ * Units are the binary ones defined by IEC, named kibibyte (`KiB`, 1024 bytes),
505
+ * mebibyte (`MiB`), gibibyte (`GiB`), and tebibyte (`TiB`), each 1024 times the
506
+ * previous. Memory, storage quotas, and caches are measured in them. The
507
+ * familiar `MB` is ambiguous: SI defines it as a million bytes, storage vendors
508
+ * use that meaning, and most software uses 1048576 instead, which is why a "1
509
+ * TB" drive shows as 931 "GB". `MiB` has only one meaning, so a literal never
510
+ * depends on a convention.
511
+ *
512
+ * Each unit is bounded below 1024, so equivalent representations are avoided:
513
+ * `1024KiB` must be written as `"1MiB"`. A half is the only decimal allowed,
514
+ * because it is the only single decimal digit that is exact in every binary
515
+ * unit; `1.1KiB` would be 1126.4 bytes. For other exact values, use
516
+ * {@link ByteLength} directly.
517
+ *
518
+ * See {@link ByteSize} for a type that also accepts {@link ByteLength}. Use
519
+ * {@link byteSizeToByteLength} to convert.
520
+ *
521
+ * Invalid values produce a {@link ByteSizeLiteralError}.
522
+ *
523
+ * ### Example
524
+ *
525
+ * ```ts
526
+ * import {
527
+ * assertEqual,
528
+ * assertErr,
529
+ * assertFalse,
530
+ * assertOk,
531
+ * assertType,
532
+ * ByteSizeLiteral,
533
+ * } from "@evolu/common";
534
+ *
535
+ * // The TypeScript type accepts valid spellings and rejects the rest.
536
+ * const literal: ByteSizeLiteral = "1023MiB";
537
+ * assertType<
538
+ * Extract<ByteSizeLiteral, "1024KiB" | "1.1KiB" | "1MB">,
539
+ * never
540
+ * >();
541
+ *
542
+ * // The runtime Type validates the same grammar.
543
+ * assertOk(ByteSizeLiteral.fromUnknown(literal), "1023MiB");
544
+ * assertFalse(ByteSizeLiteral.is("1024KiB"));
545
+ *
546
+ * const invalid = ByteSizeLiteral.fromUnknown("1MB");
547
+ * assertErr(invalid);
548
+ * assertEqual(invalid.error.type, "ByteSizeLiteral");
549
+ * assertEqual(
550
+ * ByteSizeLiteral.formatError(invalid.error),
551
+ * 'The value "1MB" is not a byte-size literal. Use a value such as "512KiB" or "1MiB".',
552
+ * );
553
+ * ```
554
+ */
555
+ export declare const ByteSizeLiteral: Type<"ByteSizeLiteral", ByteSizeLiteral, ByteSizeLiteral, ByteSizeLiteralError>;
556
+ /** Error returned when {@link ByteSizeLiteral} rejects a value. */
557
+ export interface ByteSizeLiteralError extends TypeError<"ByteSizeLiteral"> {
558
+ readonly value: unknown;
559
+ /**
560
+ * The underlying union failure, retained for diagnostics.
561
+ *
562
+ * With `{ errors: "all" }`, includes every failed alternative.
563
+ */
564
+ readonly cause: UnionError;
565
+ }
566
+ /**
567
+ * {@link ByteSizeLiteral} or {@link ByteLength}.
568
+ *
569
+ * Convenience input accepting a human-readable {@link ByteSizeLiteral} or a
570
+ * validated {@link ByteLength} for values that no literal expresses. APIs
571
+ * normalize it with {@link byteSizeToByteLength}.
572
+ *
573
+ * ### Example
574
+ *
575
+ * ```ts
576
+ * import {
577
+ * assertEqual,
578
+ * ByteLength,
579
+ * byteSizeToByteLength,
580
+ * type ByteSize,
581
+ * } from "@evolu/common";
582
+ *
583
+ * const literal: ByteSize = "1MiB";
584
+ * const validated: ByteSize = ByteLength.orThrow(1000000);
585
+ *
586
+ * assertEqual(byteSizeToByteLength(literal), 1048576);
587
+ * assertEqual(byteSizeToByteLength(validated), 1000000);
588
+ * ```
589
+ */
590
+ export type ByteSize = ByteSizeLiteral | ByteLength;
591
+ /**
592
+ * Converts a {@link ByteSize} to a {@link ByteLength}. A {@link ByteLength} is
593
+ * returned unchanged.
594
+ *
595
+ * ### Example
596
+ *
597
+ * ```ts
598
+ * import { assertEqual, byteSizeToByteLength } from "@evolu/common";
599
+ *
600
+ * assertEqual(byteSizeToByteLength("0B"), 0);
601
+ * assertEqual(byteSizeToByteLength("2KiB"), 2048);
602
+ * assertEqual(byteSizeToByteLength("1GiB"), 1073741824);
603
+ * ```
604
+ */
605
+ export declare const byteSizeToByteLength: (value: ByteSize) => ByteLength;
606
+ /**
607
+ * Error returned when a string is neither a number of bytes nor a
608
+ * {@link ByteSizeLiteral}.
609
+ */
610
+ export interface ByteLengthFromStringError extends TypeError<"ByteLengthFromString"> {
611
+ readonly value: string;
612
+ }
613
+ /**
614
+ * Transforms a number of bytes or a {@link ByteSizeLiteral} in text into a
615
+ * {@link ByteLength}.
616
+ *
617
+ * This is useful for inputs that carry sizes as text, such as environment
618
+ * variables and configuration files, where `"10MiB"` reads better than
619
+ * `"10485760"`. Encoding produces the number of bytes.
620
+ *
621
+ * ### Example
622
+ *
623
+ * ```ts
624
+ * import {
625
+ * assertEqual,
626
+ * assertErr,
627
+ * assertOk,
628
+ * ByteLengthFromString,
629
+ * } from "@evolu/common";
630
+ *
631
+ * assertOk(ByteLengthFromString.fromUnknown("10MiB"), 10485760);
632
+ * assertOk(ByteLengthFromString.fromUnknown("1048576"), 1048576);
633
+ * assertEqual(
634
+ * ByteLengthFromString.to(ByteLengthFromString.orThrow("1KiB")),
635
+ * "1024",
636
+ * );
637
+ *
638
+ * const invalid = ByteLengthFromString.fromUnknown("10MB");
639
+ * assertErr(invalid, { type: "ByteLengthFromString", value: "10MB" });
640
+ * assertEqual(
641
+ * ByteLengthFromString.formatError(invalid.error),
642
+ * 'The value "10MB" is not a byte length. Use a number of bytes or a literal such as 10MiB.',
643
+ * );
644
+ * ```
645
+ */
646
+ export declare const ByteLengthFromString: import("./Type.ts").TransformType<Type<"String", string, string, import("./Type.ts").TypeOfError<"String">, null, import("./Type.ts").TypeOfError<"String">, never, string, true>, import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<import("./Type.ts").BrandType<Type<"Number", number, number, import("./Type.ts").TypeOfError<"Number">, null, import("./Type.ts").TypeOfError<"Number">, never, number, true>, "NonNaN", import("./Type.ts").NonNaNError>, "Finite", import("./Type.ts").FiniteError>, "Int", import("./Type.ts").IntError>, "NonNegative", import("./Type.ts").NonNegativeError>, "ByteLength", ByteLengthError>, "ByteLengthFromString", ByteLengthFromStringError, string>;
647
+ //# sourceMappingURL=Bytes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Bytes.d.ts","sourceRoot":"","sources":["../../src/Bytes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAInE,OAAO,EAGL,KAAK,EACL,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,cAAc,EACd,KAAK,WAAW,EAGhB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,SAAS,EAEd,KAAK,IAAI,EACT,KAAK,SAAS,EAEd,KAAK,UAAU,EAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC9E,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