generaltranslation 8.2.6 → 8.2.8

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 (162) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/ApiError-4zIP-twr.cjs +24 -0
  3. package/dist/ApiError-4zIP-twr.cjs.map +1 -0
  4. package/dist/ApiError-Bv7vlzyQ.mjs +19 -0
  5. package/dist/ApiError-Bv7vlzyQ.mjs.map +1 -0
  6. package/dist/errors.cjs +3 -0
  7. package/dist/errors.d.cts +11 -0
  8. package/dist/errors.d.mts +11 -0
  9. package/dist/errors.mjs +2 -0
  10. package/dist/id-CPbVYREY.mjs +74 -0
  11. package/dist/id-CPbVYREY.mjs.map +1 -0
  12. package/dist/id-VXBgyXu2.cjs +89 -0
  13. package/dist/id-VXBgyXu2.cjs.map +1 -0
  14. package/dist/id.cjs +5 -0
  15. package/dist/{id/hashSource.d.ts → id.d.cts} +20 -5
  16. package/dist/id.d.mts +40 -0
  17. package/dist/id.mjs +2 -0
  18. package/dist/index.cjs +3491 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.cts +1219 -0
  21. package/dist/index.d.mts +1219 -0
  22. package/dist/index.mjs +3441 -0
  23. package/dist/index.mjs.map +1 -0
  24. package/dist/internal-B3QbyI_5.mjs +820 -0
  25. package/dist/internal-B3QbyI_5.mjs.map +1 -0
  26. package/dist/internal-DIHQF9gs.cjs +1070 -0
  27. package/dist/internal-DIHQF9gs.cjs.map +1 -0
  28. package/dist/internal.cjs +45 -0
  29. package/dist/{internal.d.ts → internal.d.cts} +82 -113
  30. package/dist/internal.d.mts +263 -0
  31. package/dist/internal.mjs +3 -0
  32. package/dist/sha2-DKowBr6H.cjs +747 -0
  33. package/dist/sha2-DKowBr6H.cjs.map +1 -0
  34. package/dist/stableStringify-DgDlE_pD.mjs +53 -0
  35. package/dist/stableStringify-DgDlE_pD.mjs.map +1 -0
  36. package/dist/types-BJdoI1d1.d.cts +741 -0
  37. package/dist/types-DazaDJbs.d.mts +741 -0
  38. package/dist/types.cjs +17 -0
  39. package/dist/types.cjs.map +1 -0
  40. package/dist/types.d.cts +2 -0
  41. package/dist/types.d.mts +2 -0
  42. package/dist/types.mjs +16 -0
  43. package/dist/types.mjs.map +1 -0
  44. package/package.json +52 -32
  45. package/dist/backwards-compatability/dataConversion.d.ts +0 -23
  46. package/dist/backwards-compatability/oldHashJsxChildren.d.ts +0 -23
  47. package/dist/backwards-compatability/oldTypes.d.ts +0 -21
  48. package/dist/backwards-compatability/typeChecking.d.ts +0 -21
  49. package/dist/cache/IntlCache.d.ts +0 -26
  50. package/dist/cache/types.d.ts +0 -32
  51. package/dist/derive/condenseVars.d.ts +0 -7
  52. package/dist/derive/declareVar.d.ts +0 -26
  53. package/dist/derive/decodeVars.d.ts +0 -9
  54. package/dist/derive/derive.d.ts +0 -38
  55. package/dist/derive/extractVars.d.ts +0 -9
  56. package/dist/derive/index.d.ts +0 -7
  57. package/dist/derive/indexVars.d.ts +0 -6
  58. package/dist/derive/utils/constants.d.ts +0 -2
  59. package/dist/derive/utils/regex.d.ts +0 -2
  60. package/dist/derive/utils/sanitizeVar.d.ts +0 -12
  61. package/dist/derive/utils/traverseHelpers.d.ts +0 -4
  62. package/dist/derive/utils/traverseIcu.d.ts +0 -20
  63. package/dist/derive/utils/types.d.ts +0 -23
  64. package/dist/errors/ApiError.d.ts +0 -7
  65. package/dist/errors/formattingErrors.d.ts +0 -1
  66. package/dist/errors.cjs.min.cjs +0 -2
  67. package/dist/errors.cjs.min.cjs.map +0 -1
  68. package/dist/errors.d.ts +0 -9
  69. package/dist/errors.esm.min.mjs +0 -2
  70. package/dist/errors.esm.min.mjs.map +0 -1
  71. package/dist/formatting/custom-formats/CutoffFormat/CutoffFormat.d.ts +0 -59
  72. package/dist/formatting/custom-formats/CutoffFormat/constants.d.ts +0 -4
  73. package/dist/formatting/custom-formats/CutoffFormat/types.d.ts +0 -48
  74. package/dist/formatting/format.d.ts +0 -1
  75. package/dist/id/hashTemplate.d.ts +0 -4
  76. package/dist/id/types.d.ts +0 -7
  77. package/dist/id.cjs.min.cjs +0 -2
  78. package/dist/id.cjs.min.cjs.map +0 -1
  79. package/dist/id.d.ts +0 -86
  80. package/dist/id.esm.min.mjs +0 -2
  81. package/dist/id.esm.min.mjs.map +0 -1
  82. package/dist/index.cjs.min.cjs +0 -2
  83. package/dist/index.cjs.min.cjs.map +0 -1
  84. package/dist/index.d.ts +0 -1627
  85. package/dist/index.esm.min.mjs +0 -2
  86. package/dist/index.esm.min.mjs.map +0 -1
  87. package/dist/internal.cjs.min.cjs +0 -2
  88. package/dist/internal.cjs.min.cjs.map +0 -1
  89. package/dist/internal.esm.min.mjs +0 -2
  90. package/dist/internal.esm.min.mjs.map +0 -1
  91. package/dist/locales/customLocaleMapping.d.ts +0 -11
  92. package/dist/locales/determineLocale.d.ts +0 -1
  93. package/dist/locales/getLocaleDirection.d.ts +0 -1
  94. package/dist/locales/getLocaleEmoji.d.ts +0 -2
  95. package/dist/locales/getLocaleName.d.ts +0 -1
  96. package/dist/locales/getLocaleProperties.d.ts +0 -32
  97. package/dist/locales/getPluralForm.d.ts +0 -9
  98. package/dist/locales/getRegionProperties.d.ts +0 -7
  99. package/dist/locales/isSameDialect.d.ts +0 -1
  100. package/dist/locales/isSameLanguage.d.ts +0 -1
  101. package/dist/locales/isSupersetLocale.d.ts +0 -1
  102. package/dist/locales/isValidLocale.d.ts +0 -1
  103. package/dist/locales/requiresTranslation.d.ts +0 -1
  104. package/dist/locales/resolveAliasLocale.d.ts +0 -8
  105. package/dist/locales/resolveCanonicalLocale.d.ts +0 -8
  106. package/dist/logging/errors.d.ts +0 -10
  107. package/dist/logging/logger.d.ts +0 -117
  108. package/dist/logging/warnings.d.ts +0 -2
  109. package/dist/projects/getProjectData.d.ts +0 -1
  110. package/dist/settings/plurals.d.ts +0 -3
  111. package/dist/settings/settings.d.ts +0 -2
  112. package/dist/settings/settingsUrls.d.ts +0 -3
  113. package/dist/translate/api.d.ts +0 -1
  114. package/dist/translate/awaitJobs.d.ts +0 -19
  115. package/dist/translate/checkJobStatus.d.ts +0 -8
  116. package/dist/translate/createBranch.d.ts +0 -10
  117. package/dist/translate/createTag.d.ts +0 -19
  118. package/dist/translate/downloadFileBatch.d.ts +0 -1
  119. package/dist/translate/enqueueFiles.d.ts +0 -8
  120. package/dist/translate/getOrphanedFiles.d.ts +0 -8
  121. package/dist/translate/processFileMoves.d.ts +0 -25
  122. package/dist/translate/publishFiles.d.ts +0 -17
  123. package/dist/translate/queryBranchData.d.ts +0 -3
  124. package/dist/translate/queryFileData.d.ts +0 -42
  125. package/dist/translate/querySourceFile.d.ts +0 -1
  126. package/dist/translate/setupProject.d.ts +0 -11
  127. package/dist/translate/submitUserEditDiffs.d.ts +0 -12
  128. package/dist/translate/translateMany.d.ts +0 -1
  129. package/dist/translate/uploadSourceFiles.d.ts +0 -1
  130. package/dist/translate/uploadTranslations.d.ts +0 -1
  131. package/dist/translate/utils/apiRequest.d.ts +0 -1
  132. package/dist/translate/utils/batch.d.ts +0 -52
  133. package/dist/translate/utils/fetchWithTimeout.d.ts +0 -1
  134. package/dist/translate/utils/generateRequestHeaders.d.ts +0 -2
  135. package/dist/translate/utils/handleFetchError.d.ts +0 -1
  136. package/dist/translate/utils/validateResponse.d.ts +0 -1
  137. package/dist/types-dir/api/branch.d.ts +0 -10
  138. package/dist/types-dir/api/checkFileTranslations.d.ts +0 -37
  139. package/dist/types-dir/api/downloadFile.d.ts +0 -3
  140. package/dist/types-dir/api/downloadFileBatch.d.ts +0 -34
  141. package/dist/types-dir/api/enqueueEntries.d.ts +0 -21
  142. package/dist/types-dir/api/enqueueFiles.d.ts +0 -56
  143. package/dist/types-dir/api/entry.d.ts +0 -36
  144. package/dist/types-dir/api/fetchTranslations.d.ts +0 -11
  145. package/dist/types-dir/api/file.d.ts +0 -54
  146. package/dist/types-dir/api/project.d.ts +0 -7
  147. package/dist/types-dir/api/translate.d.ts +0 -34
  148. package/dist/types-dir/api/translateMany.d.ts +0 -5
  149. package/dist/types-dir/api/translationStatus.d.ts +0 -9
  150. package/dist/types-dir/api/uploadFiles.d.ts +0 -43
  151. package/dist/types-dir/jsx/content.d.ts +0 -61
  152. package/dist/types-dir/jsx/variables.d.ts +0 -9
  153. package/dist/types-dir/transformations.d.ts +0 -8
  154. package/dist/types.cjs.min.cjs +0 -2
  155. package/dist/types.cjs.min.cjs.map +0 -1
  156. package/dist/types.d.ts +0 -652
  157. package/dist/types.esm.min.mjs +0 -2
  158. package/dist/types.esm.min.mjs.map +0 -1
  159. package/dist/utils/base64.d.ts +0 -2
  160. package/dist/utils/isVariable.d.ts +0 -2
  161. package/dist/utils/minify.d.ts +0 -2
  162. package/dist/utils/stableStringify.d.ts +0 -1
@@ -0,0 +1,747 @@
1
+ //#region src/utils/isVariable.ts
2
+ function isVariable(obj) {
3
+ const variableObj = obj;
4
+ if (variableObj && typeof variableObj === "object" && typeof variableObj.k === "string") {
5
+ const k = Object.keys(variableObj);
6
+ if (k.length === 1) return true;
7
+ if (k.length === 2) {
8
+ if (typeof variableObj.i === "number") return true;
9
+ if (typeof variableObj.v === "string") return true;
10
+ }
11
+ if (k.length === 3) {
12
+ if (typeof variableObj.v === "string" && typeof variableObj.i === "number") return true;
13
+ }
14
+ }
15
+ return false;
16
+ }
17
+ //#endregion
18
+ //#region src/utils/stableStringify.ts
19
+ /**
20
+ * Deterministic JSON stringification with sorted object keys.
21
+ * Drop-in replacement for `fast-json-stable-stringify` for plain
22
+ * JSON-compatible data (no toJSON, no circular references).
23
+ */
24
+ function _stringify(node) {
25
+ if (node === void 0) return void 0;
26
+ if (node === null) return "null";
27
+ if (typeof node === "number") return isFinite(node) ? "" + node : "null";
28
+ if (typeof node !== "object") return JSON.stringify(node);
29
+ if (Array.isArray(node)) {
30
+ let out = "[";
31
+ for (let i = 0; i < node.length; i++) {
32
+ if (i) out += ",";
33
+ out += _stringify(node[i]) || "null";
34
+ }
35
+ return out + "]";
36
+ }
37
+ const keys = Object.keys(node).sort();
38
+ let out = "";
39
+ for (const key of keys) {
40
+ const value = _stringify(node[key]);
41
+ if (!value) continue;
42
+ if (out) out += ",";
43
+ out += JSON.stringify(key) + ":" + value;
44
+ }
45
+ return "{" + out + "}";
46
+ }
47
+ function stableStringify(data) {
48
+ return _stringify(data) ?? "";
49
+ }
50
+ //#endregion
51
+ //#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/utils.js
52
+ /**
53
+ * Checks if something is Uint8Array. Be careful: nodejs Buffer will return true.
54
+ * @param a - value to test
55
+ * @returns `true` when the value is a Uint8Array-compatible view.
56
+ * @example
57
+ * Check whether a value is a Uint8Array-compatible view.
58
+ * ```ts
59
+ * isBytes(new Uint8Array([1, 2, 3]));
60
+ * ```
61
+ */
62
+ function isBytes(a) {
63
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
64
+ }
65
+ /**
66
+ * Asserts something is Uint8Array.
67
+ * @param value - value to validate
68
+ * @param length - optional exact length constraint
69
+ * @param title - label included in thrown errors
70
+ * @returns The validated byte array.
71
+ * @throws On wrong argument types. {@link TypeError}
72
+ * @throws On wrong argument ranges or values. {@link RangeError}
73
+ * @example
74
+ * Validate that a value is a byte array.
75
+ * ```ts
76
+ * abytes(new Uint8Array([1, 2, 3]));
77
+ * ```
78
+ */
79
+ function abytes(value, length, title = "") {
80
+ const bytes = isBytes(value);
81
+ const len = value?.length;
82
+ const needsLen = length !== void 0;
83
+ if (!bytes || needsLen && len !== length) {
84
+ const prefix = title && `"${title}" `;
85
+ const ofLen = needsLen ? ` of length ${length}` : "";
86
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
87
+ const message = prefix + "expected Uint8Array" + ofLen + ", got " + got;
88
+ if (!bytes) throw new TypeError(message);
89
+ throw new RangeError(message);
90
+ }
91
+ return value;
92
+ }
93
+ /**
94
+ * Asserts a hash instance has not been destroyed or finished.
95
+ * @param instance - hash instance to validate
96
+ * @param checkFinished - whether to reject finalized instances
97
+ * @throws If the hash instance has already been destroyed or finalized. {@link Error}
98
+ * @example
99
+ * Validate that a hash instance is still usable.
100
+ * ```ts
101
+ * import { aexists } from '@noble/hashes/utils.js';
102
+ * import { sha256 } from '@noble/hashes/sha2.js';
103
+ * const hash = sha256.create();
104
+ * aexists(hash);
105
+ * ```
106
+ */
107
+ function aexists(instance, checkFinished = true) {
108
+ if (instance.destroyed) throw new Error("Hash instance has been destroyed");
109
+ if (checkFinished && instance.finished) throw new Error("Hash#digest() has already been called");
110
+ }
111
+ /**
112
+ * Asserts output is a sufficiently-sized byte array.
113
+ * @param out - destination buffer
114
+ * @param instance - hash instance providing output length
115
+ * Oversized buffers are allowed; downstream code only promises to fill the first `outputLen` bytes.
116
+ * @throws On wrong argument types. {@link TypeError}
117
+ * @throws On wrong argument ranges or values. {@link RangeError}
118
+ * @example
119
+ * Validate a caller-provided digest buffer.
120
+ * ```ts
121
+ * import { aoutput } from '@noble/hashes/utils.js';
122
+ * import { sha256 } from '@noble/hashes/sha2.js';
123
+ * const hash = sha256.create();
124
+ * aoutput(new Uint8Array(hash.outputLen), hash);
125
+ * ```
126
+ */
127
+ function aoutput(out, instance) {
128
+ abytes(out, void 0, "digestInto() output");
129
+ const min = instance.outputLen;
130
+ if (out.length < min) throw new RangeError("\"digestInto() output\" expected to be of length >=" + min);
131
+ }
132
+ /**
133
+ * Zeroizes typed arrays in place. Warning: JS provides no guarantees.
134
+ * @param arrays - arrays to overwrite with zeros
135
+ * @example
136
+ * Zeroize sensitive buffers in place.
137
+ * ```ts
138
+ * clean(new Uint8Array([1, 2, 3]));
139
+ * ```
140
+ */
141
+ function clean(...arrays) {
142
+ for (let i = 0; i < arrays.length; i++) arrays[i].fill(0);
143
+ }
144
+ /**
145
+ * Creates a DataView for byte-level manipulation.
146
+ * @param arr - source typed array
147
+ * @returns DataView over the same buffer region.
148
+ * @example
149
+ * Create a DataView over an existing buffer.
150
+ * ```ts
151
+ * createView(new Uint8Array(4));
152
+ * ```
153
+ */
154
+ function createView(arr) {
155
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
156
+ }
157
+ /**
158
+ * Rotate-right operation for uint32 values.
159
+ * @param word - source word
160
+ * @param shift - shift amount in bits
161
+ * @returns Rotated word.
162
+ * @example
163
+ * Rotate a 32-bit word to the right.
164
+ * ```ts
165
+ * rotr(0x12345678, 8);
166
+ * ```
167
+ */
168
+ function rotr(word, shift) {
169
+ return word << 32 - shift | word >>> shift;
170
+ }
171
+ new Uint8Array(new Uint32Array([287454020]).buffer)[0];
172
+ const hasHexBuiltin = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
173
+ const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
174
+ /**
175
+ * Convert byte array to hex string.
176
+ * Uses the built-in function when available and assumes it matches the tested
177
+ * fallback semantics.
178
+ * @param bytes - bytes to encode
179
+ * @returns Lowercase hexadecimal string.
180
+ * @throws On wrong argument types. {@link TypeError}
181
+ * @example
182
+ * Convert bytes to lowercase hexadecimal.
183
+ * ```ts
184
+ * bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])); // 'cafe0123'
185
+ * ```
186
+ */
187
+ function bytesToHex(bytes) {
188
+ abytes(bytes);
189
+ if (hasHexBuiltin) return bytes.toHex();
190
+ let hex = "";
191
+ for (let i = 0; i < bytes.length; i++) hex += hexes[bytes[i]];
192
+ return hex;
193
+ }
194
+ /**
195
+ * Converts string to bytes using UTF8 encoding.
196
+ * Built-in doesn't validate input to be string: we do the check.
197
+ * Non-ASCII details are delegated to the platform `TextEncoder`.
198
+ * @param str - string to encode
199
+ * @returns UTF-8 encoded bytes.
200
+ * @throws On wrong argument types. {@link TypeError}
201
+ * @example
202
+ * Encode a string as UTF-8 bytes.
203
+ * ```ts
204
+ * utf8ToBytes('abc'); // Uint8Array.from([97, 98, 99])
205
+ * ```
206
+ */
207
+ function utf8ToBytes(str) {
208
+ if (typeof str !== "string") throw new TypeError("string expected");
209
+ return new Uint8Array(new TextEncoder().encode(str));
210
+ }
211
+ /**
212
+ * Creates a callable hash function from a stateful class constructor.
213
+ * @param hashCons - hash constructor or factory
214
+ * @param info - optional metadata such as DER OID
215
+ * @returns Frozen callable hash wrapper with `.create()`.
216
+ * Wrapper construction eagerly calls `hashCons(undefined)` once to read
217
+ * `outputLen` / `blockLen`, so constructor side effects happen at module
218
+ * init time.
219
+ * @example
220
+ * Wrap a stateful hash constructor into a callable helper.
221
+ * ```ts
222
+ * import { createHasher } from '@noble/hashes/utils.js';
223
+ * import { sha256 } from '@noble/hashes/sha2.js';
224
+ * const wrapped = createHasher(sha256.create, { oid: sha256.oid });
225
+ * wrapped(new Uint8Array([1]));
226
+ * ```
227
+ */
228
+ function createHasher(hashCons, info = {}) {
229
+ const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
230
+ const tmp = hashCons(void 0);
231
+ hashC.outputLen = tmp.outputLen;
232
+ hashC.blockLen = tmp.blockLen;
233
+ hashC.canXOF = tmp.canXOF;
234
+ hashC.create = (opts) => hashCons(opts);
235
+ Object.assign(hashC, info);
236
+ return Object.freeze(hashC);
237
+ }
238
+ /**
239
+ * Creates OID metadata for NIST hashes with prefix `06 09 60 86 48 01 65 03 04 02`.
240
+ * @param suffix - final OID byte for the selected hash.
241
+ * The helper accepts any byte even though only the documented NIST hash
242
+ * suffixes are meaningful downstream.
243
+ * @returns Object containing the DER-encoded OID.
244
+ * @example
245
+ * Build OID metadata for a NIST hash.
246
+ * ```ts
247
+ * oidNist(0x01);
248
+ * ```
249
+ */
250
+ const oidNist = (suffix) => ({ oid: Uint8Array.from([
251
+ 6,
252
+ 9,
253
+ 96,
254
+ 134,
255
+ 72,
256
+ 1,
257
+ 101,
258
+ 3,
259
+ 4,
260
+ 2,
261
+ suffix
262
+ ]) });
263
+ //#endregion
264
+ //#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/_md.js
265
+ /**
266
+ * Internal Merkle-Damgard hash utils.
267
+ * @module
268
+ */
269
+ /**
270
+ * Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.
271
+ * Returns bits from `b` when `a` is set, otherwise from `c`.
272
+ * The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never
273
+ * set the same bit.
274
+ * @param a - selector word
275
+ * @param b - word chosen when selector bit is set
276
+ * @param c - word chosen when selector bit is clear
277
+ * @returns Mixed 32-bit word.
278
+ * @example
279
+ * Combine three words with the shared 32-bit choice primitive.
280
+ * ```ts
281
+ * Chi(0xffffffff, 0x12345678, 0x87654321);
282
+ * ```
283
+ */
284
+ function Chi(a, b, c) {
285
+ return a & b ^ ~a & c;
286
+ }
287
+ /**
288
+ * Shared 32-bit majority primitive reused by SHA-256 and SHA-1.
289
+ * Returns bits shared by at least two inputs.
290
+ * @param a - first input word
291
+ * @param b - second input word
292
+ * @param c - third input word
293
+ * @returns Mixed 32-bit word.
294
+ * @example
295
+ * Combine three words with the shared 32-bit majority primitive.
296
+ * ```ts
297
+ * Maj(0xffffffff, 0x12345678, 0x87654321);
298
+ * ```
299
+ */
300
+ function Maj(a, b, c) {
301
+ return a & b ^ a & c ^ b & c;
302
+ }
303
+ /**
304
+ * Merkle-Damgard hash construction base class.
305
+ * Could be used to create MD5, RIPEMD, SHA1, SHA2.
306
+ * Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit
307
+ * strings with partial-byte tails.
308
+ * @param blockLen - internal block size in bytes
309
+ * @param outputLen - digest size in bytes
310
+ * @param padOffset - trailing length field size in bytes
311
+ * @param isLE - whether length and state words are encoded in little-endian
312
+ * @example
313
+ * Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.
314
+ * ```ts
315
+ * import { _SHA1 } from '@noble/hashes/legacy.js';
316
+ * const hash = new _SHA1();
317
+ * hash.update(new Uint8Array([97, 98, 99]));
318
+ * hash.digest();
319
+ * ```
320
+ */
321
+ var HashMD = class {
322
+ blockLen;
323
+ outputLen;
324
+ canXOF = false;
325
+ padOffset;
326
+ isLE;
327
+ buffer;
328
+ view;
329
+ finished = false;
330
+ length = 0;
331
+ pos = 0;
332
+ destroyed = false;
333
+ constructor(blockLen, outputLen, padOffset, isLE) {
334
+ this.blockLen = blockLen;
335
+ this.outputLen = outputLen;
336
+ this.padOffset = padOffset;
337
+ this.isLE = isLE;
338
+ this.buffer = new Uint8Array(blockLen);
339
+ this.view = createView(this.buffer);
340
+ }
341
+ update(data) {
342
+ aexists(this);
343
+ abytes(data);
344
+ const { view, buffer, blockLen } = this;
345
+ const len = data.length;
346
+ for (let pos = 0; pos < len;) {
347
+ const take = Math.min(blockLen - this.pos, len - pos);
348
+ if (take === blockLen) {
349
+ const dataView = createView(data);
350
+ for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);
351
+ continue;
352
+ }
353
+ buffer.set(data.subarray(pos, pos + take), this.pos);
354
+ this.pos += take;
355
+ pos += take;
356
+ if (this.pos === blockLen) {
357
+ this.process(view, 0);
358
+ this.pos = 0;
359
+ }
360
+ }
361
+ this.length += data.length;
362
+ this.roundClean();
363
+ return this;
364
+ }
365
+ digestInto(out) {
366
+ aexists(this);
367
+ aoutput(out, this);
368
+ this.finished = true;
369
+ const { buffer, view, blockLen, isLE } = this;
370
+ let { pos } = this;
371
+ buffer[pos++] = 128;
372
+ clean(this.buffer.subarray(pos));
373
+ if (this.padOffset > blockLen - pos) {
374
+ this.process(view, 0);
375
+ pos = 0;
376
+ }
377
+ for (let i = pos; i < blockLen; i++) buffer[i] = 0;
378
+ view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE);
379
+ this.process(view, 0);
380
+ const oview = createView(out);
381
+ const len = this.outputLen;
382
+ if (len % 4) throw new Error("_sha2: outputLen must be aligned to 32bit");
383
+ const outLen = len / 4;
384
+ const state = this.get();
385
+ if (outLen > state.length) throw new Error("_sha2: outputLen bigger than state");
386
+ for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);
387
+ }
388
+ digest() {
389
+ const { buffer, outputLen } = this;
390
+ this.digestInto(buffer);
391
+ const res = buffer.slice(0, outputLen);
392
+ this.destroy();
393
+ return res;
394
+ }
395
+ _cloneInto(to) {
396
+ to ||= new this.constructor();
397
+ to.set(...this.get());
398
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
399
+ to.destroyed = destroyed;
400
+ to.finished = finished;
401
+ to.length = length;
402
+ to.pos = pos;
403
+ if (length % blockLen) to.buffer.set(buffer);
404
+ return to;
405
+ }
406
+ clone() {
407
+ return this._cloneInto();
408
+ }
409
+ };
410
+ /**
411
+ * Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
412
+ * Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
413
+ */
414
+ /** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the
415
+ * square roots of the first eight prime numbers. Exported as a shared table; callers must treat
416
+ * it as read-only because constructors copy words from it by index. */
417
+ const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
418
+ 1779033703,
419
+ 3144134277,
420
+ 1013904242,
421
+ 2773480762,
422
+ 1359893119,
423
+ 2600822924,
424
+ 528734635,
425
+ 1541459225
426
+ ]);
427
+ //#endregion
428
+ //#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/_u64.js
429
+ const U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
430
+ const _32n = /* @__PURE__ */ BigInt(32);
431
+ function fromBig(n, le = false) {
432
+ if (le) return {
433
+ h: Number(n & U32_MASK64),
434
+ l: Number(n >> _32n & U32_MASK64)
435
+ };
436
+ return {
437
+ h: Number(n >> _32n & U32_MASK64) | 0,
438
+ l: Number(n & U32_MASK64) | 0
439
+ };
440
+ }
441
+ function split(lst, le = false) {
442
+ const len = lst.length;
443
+ let Ah = new Uint32Array(len);
444
+ let Al = new Uint32Array(len);
445
+ for (let i = 0; i < len; i++) {
446
+ const { h, l } = fromBig(lst[i], le);
447
+ [Ah[i], Al[i]] = [h, l];
448
+ }
449
+ return [Ah, Al];
450
+ }
451
+ //#endregion
452
+ //#region ../../node_modules/.pnpm/@noble+hashes@2.2.0/node_modules/@noble/hashes/sha2.js
453
+ /**
454
+ * SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
455
+ * SHA256 is the fastest hash implementable in JS, even faster than Blake3.
456
+ * Check out {@link https://www.rfc-editor.org/rfc/rfc4634 | RFC 4634} and
457
+ * {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf | FIPS 180-4}.
458
+ * @module
459
+ */
460
+ /**
461
+ * SHA-224 / SHA-256 round constants from RFC 6234 §5.1: the first 32 bits
462
+ * of the cube roots of the first 64 primes (2..311).
463
+ */
464
+ const SHA256_K = /* @__PURE__ */ Uint32Array.from([
465
+ 1116352408,
466
+ 1899447441,
467
+ 3049323471,
468
+ 3921009573,
469
+ 961987163,
470
+ 1508970993,
471
+ 2453635748,
472
+ 2870763221,
473
+ 3624381080,
474
+ 310598401,
475
+ 607225278,
476
+ 1426881987,
477
+ 1925078388,
478
+ 2162078206,
479
+ 2614888103,
480
+ 3248222580,
481
+ 3835390401,
482
+ 4022224774,
483
+ 264347078,
484
+ 604807628,
485
+ 770255983,
486
+ 1249150122,
487
+ 1555081692,
488
+ 1996064986,
489
+ 2554220882,
490
+ 2821834349,
491
+ 2952996808,
492
+ 3210313671,
493
+ 3336571891,
494
+ 3584528711,
495
+ 113926993,
496
+ 338241895,
497
+ 666307205,
498
+ 773529912,
499
+ 1294757372,
500
+ 1396182291,
501
+ 1695183700,
502
+ 1986661051,
503
+ 2177026350,
504
+ 2456956037,
505
+ 2730485921,
506
+ 2820302411,
507
+ 3259730800,
508
+ 3345764771,
509
+ 3516065817,
510
+ 3600352804,
511
+ 4094571909,
512
+ 275423344,
513
+ 430227734,
514
+ 506948616,
515
+ 659060556,
516
+ 883997877,
517
+ 958139571,
518
+ 1322822218,
519
+ 1537002063,
520
+ 1747873779,
521
+ 1955562222,
522
+ 2024104815,
523
+ 2227730452,
524
+ 2361852424,
525
+ 2428436474,
526
+ 2756734187,
527
+ 3204031479,
528
+ 3329325298
529
+ ]);
530
+ /** Reusable SHA-224 / SHA-256 message schedule buffer `W_t` from RFC 6234 §6.2 step 1. */
531
+ const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
532
+ /** Internal SHA-224 / SHA-256 compression engine from RFC 6234 §6.2. */
533
+ var SHA2_32B = class extends HashMD {
534
+ constructor(outputLen) {
535
+ super(64, outputLen, 8, false);
536
+ }
537
+ get() {
538
+ const { A, B, C, D, E, F, G, H } = this;
539
+ return [
540
+ A,
541
+ B,
542
+ C,
543
+ D,
544
+ E,
545
+ F,
546
+ G,
547
+ H
548
+ ];
549
+ }
550
+ set(A, B, C, D, E, F, G, H) {
551
+ this.A = A | 0;
552
+ this.B = B | 0;
553
+ this.C = C | 0;
554
+ this.D = D | 0;
555
+ this.E = E | 0;
556
+ this.F = F | 0;
557
+ this.G = G | 0;
558
+ this.H = H | 0;
559
+ }
560
+ process(view, offset) {
561
+ for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);
562
+ for (let i = 16; i < 64; i++) {
563
+ const W15 = SHA256_W[i - 15];
564
+ const W2 = SHA256_W[i - 2];
565
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
566
+ SHA256_W[i] = (rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10) + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
567
+ }
568
+ let { A, B, C, D, E, F, G, H } = this;
569
+ for (let i = 0; i < 64; i++) {
570
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
571
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
572
+ const T2 = (rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22)) + Maj(A, B, C) | 0;
573
+ H = G;
574
+ G = F;
575
+ F = E;
576
+ E = D + T1 | 0;
577
+ D = C;
578
+ C = B;
579
+ B = A;
580
+ A = T1 + T2 | 0;
581
+ }
582
+ A = A + this.A | 0;
583
+ B = B + this.B | 0;
584
+ C = C + this.C | 0;
585
+ D = D + this.D | 0;
586
+ E = E + this.E | 0;
587
+ F = F + this.F | 0;
588
+ G = G + this.G | 0;
589
+ H = H + this.H | 0;
590
+ this.set(A, B, C, D, E, F, G, H);
591
+ }
592
+ roundClean() {
593
+ clean(SHA256_W);
594
+ }
595
+ destroy() {
596
+ this.destroyed = true;
597
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
598
+ clean(this.buffer);
599
+ }
600
+ };
601
+ /** Internal SHA-256 hash class grounded in RFC 6234 §6.2. */
602
+ var _SHA256 = class extends SHA2_32B {
603
+ A = SHA256_IV[0] | 0;
604
+ B = SHA256_IV[1] | 0;
605
+ C = SHA256_IV[2] | 0;
606
+ D = SHA256_IV[3] | 0;
607
+ E = SHA256_IV[4] | 0;
608
+ F = SHA256_IV[5] | 0;
609
+ G = SHA256_IV[6] | 0;
610
+ H = SHA256_IV[7] | 0;
611
+ constructor() {
612
+ super(32);
613
+ }
614
+ };
615
+ const K512 = split([
616
+ "0x428a2f98d728ae22",
617
+ "0x7137449123ef65cd",
618
+ "0xb5c0fbcfec4d3b2f",
619
+ "0xe9b5dba58189dbbc",
620
+ "0x3956c25bf348b538",
621
+ "0x59f111f1b605d019",
622
+ "0x923f82a4af194f9b",
623
+ "0xab1c5ed5da6d8118",
624
+ "0xd807aa98a3030242",
625
+ "0x12835b0145706fbe",
626
+ "0x243185be4ee4b28c",
627
+ "0x550c7dc3d5ffb4e2",
628
+ "0x72be5d74f27b896f",
629
+ "0x80deb1fe3b1696b1",
630
+ "0x9bdc06a725c71235",
631
+ "0xc19bf174cf692694",
632
+ "0xe49b69c19ef14ad2",
633
+ "0xefbe4786384f25e3",
634
+ "0x0fc19dc68b8cd5b5",
635
+ "0x240ca1cc77ac9c65",
636
+ "0x2de92c6f592b0275",
637
+ "0x4a7484aa6ea6e483",
638
+ "0x5cb0a9dcbd41fbd4",
639
+ "0x76f988da831153b5",
640
+ "0x983e5152ee66dfab",
641
+ "0xa831c66d2db43210",
642
+ "0xb00327c898fb213f",
643
+ "0xbf597fc7beef0ee4",
644
+ "0xc6e00bf33da88fc2",
645
+ "0xd5a79147930aa725",
646
+ "0x06ca6351e003826f",
647
+ "0x142929670a0e6e70",
648
+ "0x27b70a8546d22ffc",
649
+ "0x2e1b21385c26c926",
650
+ "0x4d2c6dfc5ac42aed",
651
+ "0x53380d139d95b3df",
652
+ "0x650a73548baf63de",
653
+ "0x766a0abb3c77b2a8",
654
+ "0x81c2c92e47edaee6",
655
+ "0x92722c851482353b",
656
+ "0xa2bfe8a14cf10364",
657
+ "0xa81a664bbc423001",
658
+ "0xc24b8b70d0f89791",
659
+ "0xc76c51a30654be30",
660
+ "0xd192e819d6ef5218",
661
+ "0xd69906245565a910",
662
+ "0xf40e35855771202a",
663
+ "0x106aa07032bbd1b8",
664
+ "0x19a4c116b8d2d0c8",
665
+ "0x1e376c085141ab53",
666
+ "0x2748774cdf8eeb99",
667
+ "0x34b0bcb5e19b48a8",
668
+ "0x391c0cb3c5c95a63",
669
+ "0x4ed8aa4ae3418acb",
670
+ "0x5b9cca4f7763e373",
671
+ "0x682e6ff3d6b2b8a3",
672
+ "0x748f82ee5defb2fc",
673
+ "0x78a5636f43172f60",
674
+ "0x84c87814a1f0ab72",
675
+ "0x8cc702081a6439ec",
676
+ "0x90befffa23631e28",
677
+ "0xa4506cebde82bde9",
678
+ "0xbef9a3f7b2c67915",
679
+ "0xc67178f2e372532b",
680
+ "0xca273eceea26619c",
681
+ "0xd186b8c721c0c207",
682
+ "0xeada7dd6cde0eb1e",
683
+ "0xf57d4f7fee6ed178",
684
+ "0x06f067aa72176fba",
685
+ "0x0a637dc5a2c898a6",
686
+ "0x113f9804bef90dae",
687
+ "0x1b710b35131c471b",
688
+ "0x28db77f523047d84",
689
+ "0x32caab7b40c72493",
690
+ "0x3c9ebe0a15c9bebc",
691
+ "0x431d67c49c100d4c",
692
+ "0x4cc5d4becb3e42b6",
693
+ "0x597f299cfc657e2a",
694
+ "0x5fcb6fab3ad6faec",
695
+ "0x6c44198c4a475817"
696
+ ].map((n) => BigInt(n)));
697
+ K512[0];
698
+ K512[1];
699
+ /**
700
+ * SHA2-256 hash function from RFC 4634. In JS it's the fastest: even faster than Blake3. Some info:
701
+ *
702
+ * - Trying 2^128 hashes would get 50% chance of collision, using birthday attack.
703
+ * - BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
704
+ * - Each sha256 hash is executing 2^18 bit operations.
705
+ * - Good 2024 ASICs can do 200Th/sec with 3500 watts of power, corresponding to 2^36 hashes/joule.
706
+ * @param msg - message bytes to hash
707
+ * @returns Digest bytes.
708
+ * @example
709
+ * Hash a message with SHA2-256.
710
+ * ```ts
711
+ * sha256(new Uint8Array([97, 98, 99]));
712
+ * ```
713
+ */
714
+ const sha256 = /* @__PURE__ */ createHasher(() => new _SHA256(), /* @__PURE__ */ oidNist(1));
715
+ //#endregion
716
+ Object.defineProperty(exports, "bytesToHex", {
717
+ enumerable: true,
718
+ get: function() {
719
+ return bytesToHex;
720
+ }
721
+ });
722
+ Object.defineProperty(exports, "isVariable", {
723
+ enumerable: true,
724
+ get: function() {
725
+ return isVariable;
726
+ }
727
+ });
728
+ Object.defineProperty(exports, "sha256", {
729
+ enumerable: true,
730
+ get: function() {
731
+ return sha256;
732
+ }
733
+ });
734
+ Object.defineProperty(exports, "stableStringify", {
735
+ enumerable: true,
736
+ get: function() {
737
+ return stableStringify;
738
+ }
739
+ });
740
+ Object.defineProperty(exports, "utf8ToBytes", {
741
+ enumerable: true,
742
+ get: function() {
743
+ return utf8ToBytes;
744
+ }
745
+ });
746
+
747
+ //# sourceMappingURL=sha2-DKowBr6H.cjs.map