@angular/localize 15.1.1 → 15.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/index.mjs +1 -1
- package/esm2020/src/utils/src/messages.mjs +5 -3
- package/fesm2015/init.mjs +1 -1
- package/fesm2015/localize.mjs +525 -5
- package/fesm2015/localize.mjs.map +1 -1
- package/fesm2020/init.mjs +1 -1
- package/fesm2020/localize.mjs +525 -5
- package/fesm2020/localize.mjs.map +1 -1
- package/index.d.ts +2 -2
- package/init/index.d.ts +1 -1
- package/localize/index.d.ts +478 -0
- package/package.json +3 -3
- package/schematics/ng-add/ng_add_bundle.js +2 -2
- package/schematics/ng-add/ng_add_bundle.js.map +1 -1
- package/tools/bundles/{chunk-SOWE44E4.js → chunk-A3TI3KQN.js} +3 -3
- package/tools/bundles/{chunk-SOWE44E4.js.map → chunk-A3TI3KQN.js.map} +0 -0
- package/tools/bundles/{chunk-3TQ7D6V2.js → chunk-C7OQSZAG.js} +18 -18
- package/tools/bundles/{chunk-3TQ7D6V2.js.map → chunk-C7OQSZAG.js.map} +0 -0
- package/tools/bundles/{chunk-IHTOM4VK.js → chunk-P6R7GDWT.js} +18 -18
- package/tools/bundles/{chunk-IHTOM4VK.js.map → chunk-P6R7GDWT.js.map} +0 -0
- package/tools/bundles/index.js +4 -4
- package/tools/bundles/src/extract/cli.js +5 -5
- package/tools/bundles/src/migrate/cli.js +5 -5
- package/tools/bundles/src/translate/cli.js +11 -11
- package/tools/bundles_metadata.json +1 -1
- package/localize.d.ts +0 -10
- package/private.d.ts +0 -9
- package/src/localize/index.d.ts +0 -9
- package/src/localize/src/global.d.ts +0 -16
- package/src/localize/src/localize.d.ts +0 -138
- package/src/translate.d.ts +0 -61
- package/src/utils/index.d.ts +0 -10
- package/src/utils/src/constants.d.ts +0 -57
- package/src/utils/src/messages.d.ts +0 -239
- package/src/utils/src/translations.d.ts +0 -58
package/fesm2020/localize.mjs
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v15.1.
|
|
2
|
+
* @license Angular v15.1.3
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { computeMsgId } from '@angular/compiler';
|
|
8
|
-
export { computeMsgId as ɵcomputeMsgId } from '@angular/compiler';
|
|
9
|
-
|
|
10
7
|
/**
|
|
11
8
|
* The character used to mark the start and end of a "block" in a `$localize` tagged string.
|
|
12
9
|
* A block can indicate metadata about the message or specify a name of a placeholder for a
|
|
@@ -58,6 +55,529 @@ const ID_SEPARATOR = '@@';
|
|
|
58
55
|
*/
|
|
59
56
|
const LEGACY_ID_INDICATOR = '\u241F';
|
|
60
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Represents a big integer using a buffer of its individual digits, with the least significant
|
|
60
|
+
* digit stored at the beginning of the array (little endian).
|
|
61
|
+
*
|
|
62
|
+
* For performance reasons, each instance is mutable. The addition operation can be done in-place
|
|
63
|
+
* to reduce memory pressure of allocation for the digits array.
|
|
64
|
+
*/
|
|
65
|
+
class BigInteger {
|
|
66
|
+
static zero() {
|
|
67
|
+
return new BigInteger([0]);
|
|
68
|
+
}
|
|
69
|
+
static one() {
|
|
70
|
+
return new BigInteger([1]);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Creates a big integer using its individual digits in little endian storage.
|
|
74
|
+
*/
|
|
75
|
+
constructor(digits) {
|
|
76
|
+
this.digits = digits;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates a clone of this instance.
|
|
80
|
+
*/
|
|
81
|
+
clone() {
|
|
82
|
+
return new BigInteger(this.digits.slice());
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns a new big integer with the sum of `this` and `other` as its value. This does not mutate
|
|
86
|
+
* `this` but instead returns a new instance, unlike `addToSelf`.
|
|
87
|
+
*/
|
|
88
|
+
add(other) {
|
|
89
|
+
const result = this.clone();
|
|
90
|
+
result.addToSelf(other);
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Adds `other` to the instance itself, thereby mutating its value.
|
|
95
|
+
*/
|
|
96
|
+
addToSelf(other) {
|
|
97
|
+
const maxNrOfDigits = Math.max(this.digits.length, other.digits.length);
|
|
98
|
+
let carry = 0;
|
|
99
|
+
for (let i = 0; i < maxNrOfDigits; i++) {
|
|
100
|
+
let digitSum = carry;
|
|
101
|
+
if (i < this.digits.length) {
|
|
102
|
+
digitSum += this.digits[i];
|
|
103
|
+
}
|
|
104
|
+
if (i < other.digits.length) {
|
|
105
|
+
digitSum += other.digits[i];
|
|
106
|
+
}
|
|
107
|
+
if (digitSum >= 10) {
|
|
108
|
+
this.digits[i] = digitSum - 10;
|
|
109
|
+
carry = 1;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.digits[i] = digitSum;
|
|
113
|
+
carry = 0;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Apply a remaining carry if needed.
|
|
117
|
+
if (carry > 0) {
|
|
118
|
+
this.digits[maxNrOfDigits] = 1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Builds the decimal string representation of the big integer. As this is stored in
|
|
123
|
+
* little endian, the digits are concatenated in reverse order.
|
|
124
|
+
*/
|
|
125
|
+
toString() {
|
|
126
|
+
let res = '';
|
|
127
|
+
for (let i = this.digits.length - 1; i >= 0; i--) {
|
|
128
|
+
res += this.digits[i];
|
|
129
|
+
}
|
|
130
|
+
return res;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Represents a big integer which is optimized for multiplication operations, as its power-of-twos
|
|
135
|
+
* are memoized. See `multiplyBy()` for details on the multiplication algorithm.
|
|
136
|
+
*/
|
|
137
|
+
class BigIntForMultiplication {
|
|
138
|
+
constructor(value) {
|
|
139
|
+
this.powerOfTwos = [value];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Returns the big integer itself.
|
|
143
|
+
*/
|
|
144
|
+
getValue() {
|
|
145
|
+
return this.powerOfTwos[0];
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Computes the value for `num * b`, where `num` is a JS number and `b` is a big integer. The
|
|
149
|
+
* value for `b` is represented by a storage model that is optimized for this computation.
|
|
150
|
+
*
|
|
151
|
+
* This operation is implemented in N(log2(num)) by continuous halving of the number, where the
|
|
152
|
+
* least-significant bit (LSB) is tested in each iteration. If the bit is set, the bit's index is
|
|
153
|
+
* used as exponent into the power-of-two multiplication of `b`.
|
|
154
|
+
*
|
|
155
|
+
* As an example, consider the multiplication num=42, b=1337. In binary 42 is 0b00101010 and the
|
|
156
|
+
* algorithm unrolls into the following iterations:
|
|
157
|
+
*
|
|
158
|
+
* Iteration | num | LSB | b * 2^iter | Add? | product
|
|
159
|
+
* -----------|------------|------|------------|------|--------
|
|
160
|
+
* 0 | 0b00101010 | 0 | 1337 | No | 0
|
|
161
|
+
* 1 | 0b00010101 | 1 | 2674 | Yes | 2674
|
|
162
|
+
* 2 | 0b00001010 | 0 | 5348 | No | 2674
|
|
163
|
+
* 3 | 0b00000101 | 1 | 10696 | Yes | 13370
|
|
164
|
+
* 4 | 0b00000010 | 0 | 21392 | No | 13370
|
|
165
|
+
* 5 | 0b00000001 | 1 | 42784 | Yes | 56154
|
|
166
|
+
* 6 | 0b00000000 | 0 | 85568 | No | 56154
|
|
167
|
+
*
|
|
168
|
+
* The computed product of 56154 is indeed the correct result.
|
|
169
|
+
*
|
|
170
|
+
* The `BigIntForMultiplication` representation for a big integer provides memoized access to the
|
|
171
|
+
* power-of-two values to reduce the workload in computing those values.
|
|
172
|
+
*/
|
|
173
|
+
multiplyBy(num) {
|
|
174
|
+
const product = BigInteger.zero();
|
|
175
|
+
this.multiplyByAndAddTo(num, product);
|
|
176
|
+
return product;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* See `multiplyBy()` for details. This function allows for the computed product to be added
|
|
180
|
+
* directly to the provided result big integer.
|
|
181
|
+
*/
|
|
182
|
+
multiplyByAndAddTo(num, result) {
|
|
183
|
+
for (let exponent = 0; num !== 0; num = num >>> 1, exponent++) {
|
|
184
|
+
if (num & 1) {
|
|
185
|
+
const value = this.getMultipliedByPowerOfTwo(exponent);
|
|
186
|
+
result.addToSelf(value);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Computes and memoizes the big integer value for `this.number * 2^exponent`.
|
|
192
|
+
*/
|
|
193
|
+
getMultipliedByPowerOfTwo(exponent) {
|
|
194
|
+
// Compute the powers up until the requested exponent, where each value is computed from its
|
|
195
|
+
// predecessor. This is simple as `this.number * 2^(exponent - 1)` only has to be doubled (i.e.
|
|
196
|
+
// added to itself) to reach `this.number * 2^exponent`.
|
|
197
|
+
for (let i = this.powerOfTwos.length; i <= exponent; i++) {
|
|
198
|
+
const previousPower = this.powerOfTwos[i - 1];
|
|
199
|
+
this.powerOfTwos[i] = previousPower.add(previousPower);
|
|
200
|
+
}
|
|
201
|
+
return this.powerOfTwos[exponent];
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Represents an exponentiation operation for the provided base, of which exponents are computed and
|
|
206
|
+
* memoized. The results are represented by a `BigIntForMultiplication` which is tailored for
|
|
207
|
+
* multiplication operations by memoizing the power-of-twos. This effectively results in a matrix
|
|
208
|
+
* representation that is lazily computed upon request.
|
|
209
|
+
*/
|
|
210
|
+
class BigIntExponentiation {
|
|
211
|
+
constructor(base) {
|
|
212
|
+
this.base = base;
|
|
213
|
+
this.exponents = [new BigIntForMultiplication(BigInteger.one())];
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Compute the value for `this.base^exponent`, resulting in a big integer that is optimized for
|
|
217
|
+
* further multiplication operations.
|
|
218
|
+
*/
|
|
219
|
+
toThePowerOf(exponent) {
|
|
220
|
+
// Compute the results up until the requested exponent, where every value is computed from its
|
|
221
|
+
// predecessor. This is because `this.base^(exponent - 1)` only has to be multiplied by `base`
|
|
222
|
+
// to reach `this.base^exponent`.
|
|
223
|
+
for (let i = this.exponents.length; i <= exponent; i++) {
|
|
224
|
+
const value = this.exponents[i - 1].multiplyBy(this.base);
|
|
225
|
+
this.exponents[i] = new BigIntForMultiplication(value);
|
|
226
|
+
}
|
|
227
|
+
return this.exponents[exponent];
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* A lazily created TextEncoder instance for converting strings into UTF-8 bytes
|
|
233
|
+
*/
|
|
234
|
+
let textEncoder;
|
|
235
|
+
/**
|
|
236
|
+
* Return the message id or compute it using the XLIFF1 digest.
|
|
237
|
+
*/
|
|
238
|
+
function digest(message) {
|
|
239
|
+
return message.id || computeDigest(message);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Compute the message id using the XLIFF1 digest.
|
|
243
|
+
*/
|
|
244
|
+
function computeDigest(message) {
|
|
245
|
+
return sha1(serializeNodes(message.nodes).join('') + `[${message.meaning}]`);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Return the message id or compute it using the XLIFF2/XMB/$localize digest.
|
|
249
|
+
*/
|
|
250
|
+
function decimalDigest(message) {
|
|
251
|
+
return message.id || computeDecimalDigest(message);
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Compute the message id using the XLIFF2/XMB/$localize digest.
|
|
255
|
+
*/
|
|
256
|
+
function computeDecimalDigest(message) {
|
|
257
|
+
const visitor = new _SerializerIgnoreIcuExpVisitor();
|
|
258
|
+
const parts = message.nodes.map(a => a.visit(visitor, null));
|
|
259
|
+
return computeMsgId(parts.join(''), message.meaning);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Serialize the i18n ast to something xml-like in order to generate an UID.
|
|
263
|
+
*
|
|
264
|
+
* The visitor is also used in the i18n parser tests
|
|
265
|
+
*
|
|
266
|
+
* @internal
|
|
267
|
+
*/
|
|
268
|
+
class _SerializerVisitor {
|
|
269
|
+
visitText(text, context) {
|
|
270
|
+
return text.value;
|
|
271
|
+
}
|
|
272
|
+
visitContainer(container, context) {
|
|
273
|
+
return `[${container.children.map(child => child.visit(this)).join(', ')}]`;
|
|
274
|
+
}
|
|
275
|
+
visitIcu(icu, context) {
|
|
276
|
+
const strCases = Object.keys(icu.cases).map((k) => `${k} {${icu.cases[k].visit(this)}}`);
|
|
277
|
+
return `{${icu.expression}, ${icu.type}, ${strCases.join(', ')}}`;
|
|
278
|
+
}
|
|
279
|
+
visitTagPlaceholder(ph, context) {
|
|
280
|
+
return ph.isVoid ?
|
|
281
|
+
`<ph tag name="${ph.startName}"/>` :
|
|
282
|
+
`<ph tag name="${ph.startName}">${ph.children.map(child => child.visit(this)).join(', ')}</ph name="${ph.closeName}">`;
|
|
283
|
+
}
|
|
284
|
+
visitPlaceholder(ph, context) {
|
|
285
|
+
return ph.value ? `<ph name="${ph.name}">${ph.value}</ph>` : `<ph name="${ph.name}"/>`;
|
|
286
|
+
}
|
|
287
|
+
visitIcuPlaceholder(ph, context) {
|
|
288
|
+
return `<ph icu name="${ph.name}">${ph.value.visit(this)}</ph>`;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const serializerVisitor = new _SerializerVisitor();
|
|
292
|
+
function serializeNodes(nodes) {
|
|
293
|
+
return nodes.map(a => a.visit(serializerVisitor, null));
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Serialize the i18n ast to something xml-like in order to generate an UID.
|
|
297
|
+
*
|
|
298
|
+
* Ignore the ICU expressions so that message IDs stays identical if only the expression changes.
|
|
299
|
+
*
|
|
300
|
+
* @internal
|
|
301
|
+
*/
|
|
302
|
+
class _SerializerIgnoreIcuExpVisitor extends _SerializerVisitor {
|
|
303
|
+
visitIcu(icu, context) {
|
|
304
|
+
let strCases = Object.keys(icu.cases).map((k) => `${k} {${icu.cases[k].visit(this)}}`);
|
|
305
|
+
// Do not take the expression into account
|
|
306
|
+
return `{${icu.type}, ${strCases.join(', ')}}`;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Compute the SHA1 of the given string
|
|
311
|
+
*
|
|
312
|
+
* see https://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
|
|
313
|
+
*
|
|
314
|
+
* WARNING: this function has not been designed not tested with security in mind.
|
|
315
|
+
* DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.
|
|
316
|
+
*/
|
|
317
|
+
function sha1(str) {
|
|
318
|
+
textEncoder ?? (textEncoder = new TextEncoder());
|
|
319
|
+
const utf8 = [...textEncoder.encode(str)];
|
|
320
|
+
const words32 = bytesToWords32(utf8, Endian.Big);
|
|
321
|
+
const len = utf8.length * 8;
|
|
322
|
+
const w = new Uint32Array(80);
|
|
323
|
+
let a = 0x67452301, b = 0xefcdab89, c = 0x98badcfe, d = 0x10325476, e = 0xc3d2e1f0;
|
|
324
|
+
words32[len >> 5] |= 0x80 << (24 - len % 32);
|
|
325
|
+
words32[((len + 64 >> 9) << 4) + 15] = len;
|
|
326
|
+
for (let i = 0; i < words32.length; i += 16) {
|
|
327
|
+
const h0 = a, h1 = b, h2 = c, h3 = d, h4 = e;
|
|
328
|
+
for (let j = 0; j < 80; j++) {
|
|
329
|
+
if (j < 16) {
|
|
330
|
+
w[j] = words32[i + j];
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
|
|
334
|
+
}
|
|
335
|
+
const fkVal = fk(j, b, c, d);
|
|
336
|
+
const f = fkVal[0];
|
|
337
|
+
const k = fkVal[1];
|
|
338
|
+
const temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
|
|
339
|
+
e = d;
|
|
340
|
+
d = c;
|
|
341
|
+
c = rol32(b, 30);
|
|
342
|
+
b = a;
|
|
343
|
+
a = temp;
|
|
344
|
+
}
|
|
345
|
+
a = add32(a, h0);
|
|
346
|
+
b = add32(b, h1);
|
|
347
|
+
c = add32(c, h2);
|
|
348
|
+
d = add32(d, h3);
|
|
349
|
+
e = add32(e, h4);
|
|
350
|
+
}
|
|
351
|
+
// Convert the output parts to a 160-bit hexadecimal string
|
|
352
|
+
return toHexU32(a) + toHexU32(b) + toHexU32(c) + toHexU32(d) + toHexU32(e);
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Convert and format a number as a string representing a 32-bit unsigned hexadecimal number.
|
|
356
|
+
* @param value The value to format as a string.
|
|
357
|
+
* @returns A hexadecimal string representing the value.
|
|
358
|
+
*/
|
|
359
|
+
function toHexU32(value) {
|
|
360
|
+
// unsigned right shift of zero ensures an unsigned 32-bit number
|
|
361
|
+
return (value >>> 0).toString(16).padStart(8, '0');
|
|
362
|
+
}
|
|
363
|
+
function fk(index, b, c, d) {
|
|
364
|
+
if (index < 20) {
|
|
365
|
+
return [(b & c) | (~b & d), 0x5a827999];
|
|
366
|
+
}
|
|
367
|
+
if (index < 40) {
|
|
368
|
+
return [b ^ c ^ d, 0x6ed9eba1];
|
|
369
|
+
}
|
|
370
|
+
if (index < 60) {
|
|
371
|
+
return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];
|
|
372
|
+
}
|
|
373
|
+
return [b ^ c ^ d, 0xca62c1d6];
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Compute the fingerprint of the given string
|
|
377
|
+
*
|
|
378
|
+
* The output is 64 bit number encoded as a decimal string
|
|
379
|
+
*
|
|
380
|
+
* based on:
|
|
381
|
+
* https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
|
|
382
|
+
*/
|
|
383
|
+
function fingerprint(str) {
|
|
384
|
+
textEncoder ?? (textEncoder = new TextEncoder());
|
|
385
|
+
const utf8 = textEncoder.encode(str);
|
|
386
|
+
const view = new DataView(utf8.buffer, utf8.byteOffset, utf8.byteLength);
|
|
387
|
+
let hi = hash32(view, utf8.length, 0);
|
|
388
|
+
let lo = hash32(view, utf8.length, 102072);
|
|
389
|
+
if (hi == 0 && (lo == 0 || lo == 1)) {
|
|
390
|
+
hi = hi ^ 0x130f9bef;
|
|
391
|
+
lo = lo ^ -0x6b5f56d8;
|
|
392
|
+
}
|
|
393
|
+
return [hi, lo];
|
|
394
|
+
}
|
|
395
|
+
function computeMsgId(msg, meaning = '') {
|
|
396
|
+
let msgFingerprint = fingerprint(msg);
|
|
397
|
+
if (meaning) {
|
|
398
|
+
const meaningFingerprint = fingerprint(meaning);
|
|
399
|
+
msgFingerprint = add64(rol64(msgFingerprint, 1), meaningFingerprint);
|
|
400
|
+
}
|
|
401
|
+
const hi = msgFingerprint[0];
|
|
402
|
+
const lo = msgFingerprint[1];
|
|
403
|
+
return wordsToDecimalString(hi & 0x7fffffff, lo);
|
|
404
|
+
}
|
|
405
|
+
function hash32(view, length, c) {
|
|
406
|
+
let a = 0x9e3779b9, b = 0x9e3779b9;
|
|
407
|
+
let index = 0;
|
|
408
|
+
const end = length - 12;
|
|
409
|
+
for (; index <= end; index += 12) {
|
|
410
|
+
a += view.getUint32(index, true);
|
|
411
|
+
b += view.getUint32(index + 4, true);
|
|
412
|
+
c += view.getUint32(index + 8, true);
|
|
413
|
+
const res = mix(a, b, c);
|
|
414
|
+
a = res[0], b = res[1], c = res[2];
|
|
415
|
+
}
|
|
416
|
+
const remainder = length - index;
|
|
417
|
+
// the first byte of c is reserved for the length
|
|
418
|
+
c += length;
|
|
419
|
+
if (remainder >= 4) {
|
|
420
|
+
a += view.getUint32(index, true);
|
|
421
|
+
index += 4;
|
|
422
|
+
if (remainder >= 8) {
|
|
423
|
+
b += view.getUint32(index, true);
|
|
424
|
+
index += 4;
|
|
425
|
+
// Partial 32-bit word for c
|
|
426
|
+
if (remainder >= 9) {
|
|
427
|
+
c += view.getUint8(index++) << 8;
|
|
428
|
+
}
|
|
429
|
+
if (remainder >= 10) {
|
|
430
|
+
c += view.getUint8(index++) << 16;
|
|
431
|
+
}
|
|
432
|
+
if (remainder === 11) {
|
|
433
|
+
c += view.getUint8(index++) << 24;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
// Partial 32-bit word for b
|
|
438
|
+
if (remainder >= 5) {
|
|
439
|
+
b += view.getUint8(index++);
|
|
440
|
+
}
|
|
441
|
+
if (remainder >= 6) {
|
|
442
|
+
b += view.getUint8(index++) << 8;
|
|
443
|
+
}
|
|
444
|
+
if (remainder === 7) {
|
|
445
|
+
b += view.getUint8(index++) << 16;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
// Partial 32-bit word for a
|
|
451
|
+
if (remainder >= 1) {
|
|
452
|
+
a += view.getUint8(index++);
|
|
453
|
+
}
|
|
454
|
+
if (remainder >= 2) {
|
|
455
|
+
a += view.getUint8(index++) << 8;
|
|
456
|
+
}
|
|
457
|
+
if (remainder === 3) {
|
|
458
|
+
a += view.getUint8(index++) << 16;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
return mix(a, b, c)[2];
|
|
462
|
+
}
|
|
463
|
+
// clang-format off
|
|
464
|
+
function mix(a, b, c) {
|
|
465
|
+
a -= b;
|
|
466
|
+
a -= c;
|
|
467
|
+
a ^= c >>> 13;
|
|
468
|
+
b -= c;
|
|
469
|
+
b -= a;
|
|
470
|
+
b ^= a << 8;
|
|
471
|
+
c -= a;
|
|
472
|
+
c -= b;
|
|
473
|
+
c ^= b >>> 13;
|
|
474
|
+
a -= b;
|
|
475
|
+
a -= c;
|
|
476
|
+
a ^= c >>> 12;
|
|
477
|
+
b -= c;
|
|
478
|
+
b -= a;
|
|
479
|
+
b ^= a << 16;
|
|
480
|
+
c -= a;
|
|
481
|
+
c -= b;
|
|
482
|
+
c ^= b >>> 5;
|
|
483
|
+
a -= b;
|
|
484
|
+
a -= c;
|
|
485
|
+
a ^= c >>> 3;
|
|
486
|
+
b -= c;
|
|
487
|
+
b -= a;
|
|
488
|
+
b ^= a << 10;
|
|
489
|
+
c -= a;
|
|
490
|
+
c -= b;
|
|
491
|
+
c ^= b >>> 15;
|
|
492
|
+
return [a, b, c];
|
|
493
|
+
}
|
|
494
|
+
// clang-format on
|
|
495
|
+
// Utils
|
|
496
|
+
var Endian;
|
|
497
|
+
(function (Endian) {
|
|
498
|
+
Endian[Endian["Little"] = 0] = "Little";
|
|
499
|
+
Endian[Endian["Big"] = 1] = "Big";
|
|
500
|
+
})(Endian || (Endian = {}));
|
|
501
|
+
function add32(a, b) {
|
|
502
|
+
return add32to64(a, b)[1];
|
|
503
|
+
}
|
|
504
|
+
function add32to64(a, b) {
|
|
505
|
+
const low = (a & 0xffff) + (b & 0xffff);
|
|
506
|
+
const high = (a >>> 16) + (b >>> 16) + (low >>> 16);
|
|
507
|
+
return [high >>> 16, (high << 16) | (low & 0xffff)];
|
|
508
|
+
}
|
|
509
|
+
function add64(a, b) {
|
|
510
|
+
const ah = a[0], al = a[1];
|
|
511
|
+
const bh = b[0], bl = b[1];
|
|
512
|
+
const result = add32to64(al, bl);
|
|
513
|
+
const carry = result[0];
|
|
514
|
+
const l = result[1];
|
|
515
|
+
const h = add32(add32(ah, bh), carry);
|
|
516
|
+
return [h, l];
|
|
517
|
+
}
|
|
518
|
+
// Rotate a 32b number left `count` position
|
|
519
|
+
function rol32(a, count) {
|
|
520
|
+
return (a << count) | (a >>> (32 - count));
|
|
521
|
+
}
|
|
522
|
+
// Rotate a 64b number left `count` position
|
|
523
|
+
function rol64(num, count) {
|
|
524
|
+
const hi = num[0], lo = num[1];
|
|
525
|
+
const h = (hi << count) | (lo >>> (32 - count));
|
|
526
|
+
const l = (lo << count) | (hi >>> (32 - count));
|
|
527
|
+
return [h, l];
|
|
528
|
+
}
|
|
529
|
+
function bytesToWords32(bytes, endian) {
|
|
530
|
+
const size = (bytes.length + 3) >>> 2;
|
|
531
|
+
const words32 = [];
|
|
532
|
+
for (let i = 0; i < size; i++) {
|
|
533
|
+
words32[i] = wordAt(bytes, i * 4, endian);
|
|
534
|
+
}
|
|
535
|
+
return words32;
|
|
536
|
+
}
|
|
537
|
+
function byteAt(bytes, index) {
|
|
538
|
+
return index >= bytes.length ? 0 : bytes[index];
|
|
539
|
+
}
|
|
540
|
+
function wordAt(bytes, index, endian) {
|
|
541
|
+
let word = 0;
|
|
542
|
+
if (endian === Endian.Big) {
|
|
543
|
+
for (let i = 0; i < 4; i++) {
|
|
544
|
+
word += byteAt(bytes, index + i) << (24 - 8 * i);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
for (let i = 0; i < 4; i++) {
|
|
549
|
+
word += byteAt(bytes, index + i) << 8 * i;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return word;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Create a shared exponentiation pool for base-256 computations. This shared pool provides memoized
|
|
556
|
+
* power-of-256 results with memoized power-of-two computations for efficient multiplication.
|
|
557
|
+
*
|
|
558
|
+
* For our purposes, this can be safely stored as a global without memory concerns. The reason is
|
|
559
|
+
* that we encode two words, so only need the 0th (for the low word) and 4th (for the high word)
|
|
560
|
+
* exponent.
|
|
561
|
+
*/
|
|
562
|
+
const base256 = new BigIntExponentiation(256);
|
|
563
|
+
/**
|
|
564
|
+
* Represents two 32-bit words as a single decimal number. This requires a big integer storage
|
|
565
|
+
* model as JS numbers are not accurate enough to represent the 64-bit number.
|
|
566
|
+
*
|
|
567
|
+
* Based on https://www.danvk.org/hex2dec.html
|
|
568
|
+
*/
|
|
569
|
+
function wordsToDecimalString(hi, lo) {
|
|
570
|
+
// Encode the four bytes in lo in the lower digits of the decimal number.
|
|
571
|
+
// Note: the multiplication results in lo itself but represented by a big integer using its
|
|
572
|
+
// decimal digits.
|
|
573
|
+
const decimal = base256.toThePowerOf(0).multiplyBy(lo);
|
|
574
|
+
// Encode the four bytes in hi above the four lo bytes. lo is a maximum of (2^8)^4, which is why
|
|
575
|
+
// this multiplication factor is applied.
|
|
576
|
+
base256.toThePowerOf(4).multiplyByAndAddTo(hi, decimal);
|
|
577
|
+
return decimal.toString();
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// This module specifier is intentionally a relative path to allow bundling the code directly
|
|
61
581
|
/**
|
|
62
582
|
* Parse a `$localize` tagged string into a structure that can be used for translation or
|
|
63
583
|
* extraction.
|
|
@@ -567,5 +1087,5 @@ function stripBlock(messagePart, rawMessagePart) {
|
|
|
567
1087
|
|
|
568
1088
|
// DO NOT ADD public exports to this file.
|
|
569
1089
|
|
|
570
|
-
export { clearTranslations, loadTranslations, $localize$1 as ɵ$localize, MissingTranslationError as ɵMissingTranslationError, _global as ɵ_global, findEndOfBlock as ɵfindEndOfBlock, isMissingTranslationError as ɵisMissingTranslationError, makeParsedTranslation as ɵmakeParsedTranslation, makeTemplateObject as ɵmakeTemplateObject, parseMessage as ɵparseMessage, parseMetadata as ɵparseMetadata, parseTranslation as ɵparseTranslation, splitBlock as ɵsplitBlock, translate$1 as ɵtranslate };
|
|
1090
|
+
export { clearTranslations, loadTranslations, $localize$1 as ɵ$localize, MissingTranslationError as ɵMissingTranslationError, _global as ɵ_global, computeMsgId as ɵcomputeMsgId, findEndOfBlock as ɵfindEndOfBlock, isMissingTranslationError as ɵisMissingTranslationError, makeParsedTranslation as ɵmakeParsedTranslation, makeTemplateObject as ɵmakeTemplateObject, parseMessage as ɵparseMessage, parseMetadata as ɵparseMetadata, parseTranslation as ɵparseTranslation, splitBlock as ɵsplitBlock, translate$1 as ɵtranslate };
|
|
571
1091
|
//# sourceMappingURL=localize.mjs.map
|