@angular/language-service 13.0.0 → 13.1.0-next.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.
- package/bundles/language-service.js +717 -654
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v13.0.0
|
|
2
|
+
* @license Angular v13.1.0-next.0
|
|
3
3
|
* Copyright Google LLC All Rights Reserved.
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -1112,6 +1112,624 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
1112
1112
|
return selector ? CssSelector.parse(selector).map(parserSelectorToR3Selector) : [];
|
|
1113
1113
|
}
|
|
1114
1114
|
|
|
1115
|
+
/**
|
|
1116
|
+
* @license
|
|
1117
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1118
|
+
*
|
|
1119
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1120
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1121
|
+
*/
|
|
1122
|
+
const DASH_CASE_REGEXP = /-+([a-z0-9])/g;
|
|
1123
|
+
function dashCaseToCamelCase(input) {
|
|
1124
|
+
return input.replace(DASH_CASE_REGEXP, (...m) => m[1].toUpperCase());
|
|
1125
|
+
}
|
|
1126
|
+
function splitAtColon(input, defaultValues) {
|
|
1127
|
+
return _splitAt(input, ':', defaultValues);
|
|
1128
|
+
}
|
|
1129
|
+
function splitAtPeriod(input, defaultValues) {
|
|
1130
|
+
return _splitAt(input, '.', defaultValues);
|
|
1131
|
+
}
|
|
1132
|
+
function _splitAt(input, character, defaultValues) {
|
|
1133
|
+
const characterIndex = input.indexOf(character);
|
|
1134
|
+
if (characterIndex == -1)
|
|
1135
|
+
return defaultValues;
|
|
1136
|
+
return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];
|
|
1137
|
+
}
|
|
1138
|
+
function error(msg) {
|
|
1139
|
+
throw new Error(`Internal Error: ${msg}`);
|
|
1140
|
+
}
|
|
1141
|
+
function utf8Encode(str) {
|
|
1142
|
+
let encoded = [];
|
|
1143
|
+
for (let index = 0; index < str.length; index++) {
|
|
1144
|
+
let codePoint = str.charCodeAt(index);
|
|
1145
|
+
// decode surrogate
|
|
1146
|
+
// see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
|
1147
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > (index + 1)) {
|
|
1148
|
+
const low = str.charCodeAt(index + 1);
|
|
1149
|
+
if (low >= 0xdc00 && low <= 0xdfff) {
|
|
1150
|
+
index++;
|
|
1151
|
+
codePoint = ((codePoint - 0xd800) << 10) + low - 0xdc00 + 0x10000;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
if (codePoint <= 0x7f) {
|
|
1155
|
+
encoded.push(codePoint);
|
|
1156
|
+
}
|
|
1157
|
+
else if (codePoint <= 0x7ff) {
|
|
1158
|
+
encoded.push(((codePoint >> 6) & 0x1F) | 0xc0, (codePoint & 0x3f) | 0x80);
|
|
1159
|
+
}
|
|
1160
|
+
else if (codePoint <= 0xffff) {
|
|
1161
|
+
encoded.push((codePoint >> 12) | 0xe0, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
|
|
1162
|
+
}
|
|
1163
|
+
else if (codePoint <= 0x1fffff) {
|
|
1164
|
+
encoded.push(((codePoint >> 18) & 0x07) | 0xf0, ((codePoint >> 12) & 0x3f) | 0x80, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
return encoded;
|
|
1168
|
+
}
|
|
1169
|
+
function stringify(token) {
|
|
1170
|
+
if (typeof token === 'string') {
|
|
1171
|
+
return token;
|
|
1172
|
+
}
|
|
1173
|
+
if (Array.isArray(token)) {
|
|
1174
|
+
return '[' + token.map(stringify).join(', ') + ']';
|
|
1175
|
+
}
|
|
1176
|
+
if (token == null) {
|
|
1177
|
+
return '' + token;
|
|
1178
|
+
}
|
|
1179
|
+
if (token.overriddenName) {
|
|
1180
|
+
return `${token.overriddenName}`;
|
|
1181
|
+
}
|
|
1182
|
+
if (token.name) {
|
|
1183
|
+
return `${token.name}`;
|
|
1184
|
+
}
|
|
1185
|
+
if (!token.toString) {
|
|
1186
|
+
return 'object';
|
|
1187
|
+
}
|
|
1188
|
+
// WARNING: do not try to `JSON.stringify(token)` here
|
|
1189
|
+
// see https://github.com/angular/angular/issues/23440
|
|
1190
|
+
const res = token.toString();
|
|
1191
|
+
if (res == null) {
|
|
1192
|
+
return '' + res;
|
|
1193
|
+
}
|
|
1194
|
+
const newLineIndex = res.indexOf('\n');
|
|
1195
|
+
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
|
1196
|
+
}
|
|
1197
|
+
class Version {
|
|
1198
|
+
constructor(full) {
|
|
1199
|
+
this.full = full;
|
|
1200
|
+
const splits = full.split('.');
|
|
1201
|
+
this.major = splits[0];
|
|
1202
|
+
this.minor = splits[1];
|
|
1203
|
+
this.patch = splits.slice(2).join('.');
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
const __window = typeof window !== 'undefined' && window;
|
|
1207
|
+
const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
|
|
1208
|
+
self instanceof WorkerGlobalScope && self;
|
|
1209
|
+
const __global = typeof global !== 'undefined' && global;
|
|
1210
|
+
// Check __global first, because in Node tests both __global and __window may be defined and _global
|
|
1211
|
+
// should be __global in that case.
|
|
1212
|
+
const _global = __global || __window || __self;
|
|
1213
|
+
function newArray(size, value) {
|
|
1214
|
+
const list = [];
|
|
1215
|
+
for (let i = 0; i < size; i++) {
|
|
1216
|
+
list.push(value);
|
|
1217
|
+
}
|
|
1218
|
+
return list;
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Partitions a given array into 2 arrays, based on a boolean value returned by the condition
|
|
1222
|
+
* function.
|
|
1223
|
+
*
|
|
1224
|
+
* @param arr Input array that should be partitioned
|
|
1225
|
+
* @param conditionFn Condition function that is called for each item in a given array and returns a
|
|
1226
|
+
* boolean value.
|
|
1227
|
+
*/
|
|
1228
|
+
function partitionArray(arr, conditionFn) {
|
|
1229
|
+
const truthy = [];
|
|
1230
|
+
const falsy = [];
|
|
1231
|
+
for (const item of arr) {
|
|
1232
|
+
(conditionFn(item) ? truthy : falsy).push(item);
|
|
1233
|
+
}
|
|
1234
|
+
return [truthy, falsy];
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* @license
|
|
1239
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1240
|
+
*
|
|
1241
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1242
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1243
|
+
*/
|
|
1244
|
+
/**
|
|
1245
|
+
* Represents a big integer using a buffer of its individual digits, with the least significant
|
|
1246
|
+
* digit stored at the beginning of the array (little endian).
|
|
1247
|
+
*
|
|
1248
|
+
* For performance reasons, each instance is mutable. The addition operation can be done in-place
|
|
1249
|
+
* to reduce memory pressure of allocation for the digits array.
|
|
1250
|
+
*/
|
|
1251
|
+
class BigInteger {
|
|
1252
|
+
/**
|
|
1253
|
+
* Creates a big integer using its individual digits in little endian storage.
|
|
1254
|
+
*/
|
|
1255
|
+
constructor(digits) {
|
|
1256
|
+
this.digits = digits;
|
|
1257
|
+
}
|
|
1258
|
+
static zero() {
|
|
1259
|
+
return new BigInteger([0]);
|
|
1260
|
+
}
|
|
1261
|
+
static one() {
|
|
1262
|
+
return new BigInteger([1]);
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Creates a clone of this instance.
|
|
1266
|
+
*/
|
|
1267
|
+
clone() {
|
|
1268
|
+
return new BigInteger(this.digits.slice());
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Returns a new big integer with the sum of `this` and `other` as its value. This does not mutate
|
|
1272
|
+
* `this` but instead returns a new instance, unlike `addToSelf`.
|
|
1273
|
+
*/
|
|
1274
|
+
add(other) {
|
|
1275
|
+
const result = this.clone();
|
|
1276
|
+
result.addToSelf(other);
|
|
1277
|
+
return result;
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Adds `other` to the instance itself, thereby mutating its value.
|
|
1281
|
+
*/
|
|
1282
|
+
addToSelf(other) {
|
|
1283
|
+
const maxNrOfDigits = Math.max(this.digits.length, other.digits.length);
|
|
1284
|
+
let carry = 0;
|
|
1285
|
+
for (let i = 0; i < maxNrOfDigits; i++) {
|
|
1286
|
+
let digitSum = carry;
|
|
1287
|
+
if (i < this.digits.length) {
|
|
1288
|
+
digitSum += this.digits[i];
|
|
1289
|
+
}
|
|
1290
|
+
if (i < other.digits.length) {
|
|
1291
|
+
digitSum += other.digits[i];
|
|
1292
|
+
}
|
|
1293
|
+
if (digitSum >= 10) {
|
|
1294
|
+
this.digits[i] = digitSum - 10;
|
|
1295
|
+
carry = 1;
|
|
1296
|
+
}
|
|
1297
|
+
else {
|
|
1298
|
+
this.digits[i] = digitSum;
|
|
1299
|
+
carry = 0;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
// Apply a remaining carry if needed.
|
|
1303
|
+
if (carry > 0) {
|
|
1304
|
+
this.digits[maxNrOfDigits] = 1;
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Builds the decimal string representation of the big integer. As this is stored in
|
|
1309
|
+
* little endian, the digits are concatenated in reverse order.
|
|
1310
|
+
*/
|
|
1311
|
+
toString() {
|
|
1312
|
+
let res = '';
|
|
1313
|
+
for (let i = this.digits.length - 1; i >= 0; i--) {
|
|
1314
|
+
res += this.digits[i];
|
|
1315
|
+
}
|
|
1316
|
+
return res;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
/**
|
|
1320
|
+
* Represents a big integer which is optimized for multiplication operations, as its power-of-twos
|
|
1321
|
+
* are memoized. See `multiplyBy()` for details on the multiplication algorithm.
|
|
1322
|
+
*/
|
|
1323
|
+
class BigIntForMultiplication {
|
|
1324
|
+
constructor(value) {
|
|
1325
|
+
this.powerOfTwos = [value];
|
|
1326
|
+
}
|
|
1327
|
+
/**
|
|
1328
|
+
* Returns the big integer itself.
|
|
1329
|
+
*/
|
|
1330
|
+
getValue() {
|
|
1331
|
+
return this.powerOfTwos[0];
|
|
1332
|
+
}
|
|
1333
|
+
/**
|
|
1334
|
+
* Computes the value for `num * b`, where `num` is a JS number and `b` is a big integer. The
|
|
1335
|
+
* value for `b` is represented by a storage model that is optimized for this computation.
|
|
1336
|
+
*
|
|
1337
|
+
* This operation is implemented in N(log2(num)) by continuous halving of the number, where the
|
|
1338
|
+
* least-significant bit (LSB) is tested in each iteration. If the bit is set, the bit's index is
|
|
1339
|
+
* used as exponent into the power-of-two multiplication of `b`.
|
|
1340
|
+
*
|
|
1341
|
+
* As an example, consider the multiplication num=42, b=1337. In binary 42 is 0b00101010 and the
|
|
1342
|
+
* algorithm unrolls into the following iterations:
|
|
1343
|
+
*
|
|
1344
|
+
* Iteration | num | LSB | b * 2^iter | Add? | product
|
|
1345
|
+
* -----------|------------|------|------------|------|--------
|
|
1346
|
+
* 0 | 0b00101010 | 0 | 1337 | No | 0
|
|
1347
|
+
* 1 | 0b00010101 | 1 | 2674 | Yes | 2674
|
|
1348
|
+
* 2 | 0b00001010 | 0 | 5348 | No | 2674
|
|
1349
|
+
* 3 | 0b00000101 | 1 | 10696 | Yes | 13370
|
|
1350
|
+
* 4 | 0b00000010 | 0 | 21392 | No | 13370
|
|
1351
|
+
* 5 | 0b00000001 | 1 | 42784 | Yes | 56154
|
|
1352
|
+
* 6 | 0b00000000 | 0 | 85568 | No | 56154
|
|
1353
|
+
*
|
|
1354
|
+
* The computed product of 56154 is indeed the correct result.
|
|
1355
|
+
*
|
|
1356
|
+
* The `BigIntForMultiplication` representation for a big integer provides memoized access to the
|
|
1357
|
+
* power-of-two values to reduce the workload in computing those values.
|
|
1358
|
+
*/
|
|
1359
|
+
multiplyBy(num) {
|
|
1360
|
+
const product = BigInteger.zero();
|
|
1361
|
+
this.multiplyByAndAddTo(num, product);
|
|
1362
|
+
return product;
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* See `multiplyBy()` for details. This function allows for the computed product to be added
|
|
1366
|
+
* directly to the provided result big integer.
|
|
1367
|
+
*/
|
|
1368
|
+
multiplyByAndAddTo(num, result) {
|
|
1369
|
+
for (let exponent = 0; num !== 0; num = num >>> 1, exponent++) {
|
|
1370
|
+
if (num & 1) {
|
|
1371
|
+
const value = this.getMultipliedByPowerOfTwo(exponent);
|
|
1372
|
+
result.addToSelf(value);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
/**
|
|
1377
|
+
* Computes and memoizes the big integer value for `this.number * 2^exponent`.
|
|
1378
|
+
*/
|
|
1379
|
+
getMultipliedByPowerOfTwo(exponent) {
|
|
1380
|
+
// Compute the powers up until the requested exponent, where each value is computed from its
|
|
1381
|
+
// predecessor. This is simple as `this.number * 2^(exponent - 1)` only has to be doubled (i.e.
|
|
1382
|
+
// added to itself) to reach `this.number * 2^exponent`.
|
|
1383
|
+
for (let i = this.powerOfTwos.length; i <= exponent; i++) {
|
|
1384
|
+
const previousPower = this.powerOfTwos[i - 1];
|
|
1385
|
+
this.powerOfTwos[i] = previousPower.add(previousPower);
|
|
1386
|
+
}
|
|
1387
|
+
return this.powerOfTwos[exponent];
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
/**
|
|
1391
|
+
* Represents an exponentiation operation for the provided base, of which exponents are computed and
|
|
1392
|
+
* memoized. The results are represented by a `BigIntForMultiplication` which is tailored for
|
|
1393
|
+
* multiplication operations by memoizing the power-of-twos. This effectively results in a matrix
|
|
1394
|
+
* representation that is lazily computed upon request.
|
|
1395
|
+
*/
|
|
1396
|
+
class BigIntExponentiation {
|
|
1397
|
+
constructor(base) {
|
|
1398
|
+
this.base = base;
|
|
1399
|
+
this.exponents = [new BigIntForMultiplication(BigInteger.one())];
|
|
1400
|
+
}
|
|
1401
|
+
/**
|
|
1402
|
+
* Compute the value for `this.base^exponent`, resulting in a big integer that is optimized for
|
|
1403
|
+
* further multiplication operations.
|
|
1404
|
+
*/
|
|
1405
|
+
toThePowerOf(exponent) {
|
|
1406
|
+
// Compute the results up until the requested exponent, where every value is computed from its
|
|
1407
|
+
// predecessor. This is because `this.base^(exponent - 1)` only has to be multiplied by `base`
|
|
1408
|
+
// to reach `this.base^exponent`.
|
|
1409
|
+
for (let i = this.exponents.length; i <= exponent; i++) {
|
|
1410
|
+
const value = this.exponents[i - 1].multiplyBy(this.base);
|
|
1411
|
+
this.exponents[i] = new BigIntForMultiplication(value);
|
|
1412
|
+
}
|
|
1413
|
+
return this.exponents[exponent];
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
/**
|
|
1418
|
+
* @license
|
|
1419
|
+
* Copyright Google LLC All Rights Reserved.
|
|
1420
|
+
*
|
|
1421
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1422
|
+
* found in the LICENSE file at https://angular.io/license
|
|
1423
|
+
*/
|
|
1424
|
+
/**
|
|
1425
|
+
* Compute the message id using the XLIFF1 digest.
|
|
1426
|
+
*/
|
|
1427
|
+
function computeDigest(message) {
|
|
1428
|
+
return sha1(serializeNodes(message.nodes).join('') + `[${message.meaning}]`);
|
|
1429
|
+
}
|
|
1430
|
+
/**
|
|
1431
|
+
* Return the message id or compute it using the XLIFF2/XMB/$localize digest.
|
|
1432
|
+
*/
|
|
1433
|
+
function decimalDigest(message) {
|
|
1434
|
+
return message.id || computeDecimalDigest(message);
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Compute the message id using the XLIFF2/XMB/$localize digest.
|
|
1438
|
+
*/
|
|
1439
|
+
function computeDecimalDigest(message) {
|
|
1440
|
+
const visitor = new _SerializerIgnoreIcuExpVisitor();
|
|
1441
|
+
const parts = message.nodes.map(a => a.visit(visitor, null));
|
|
1442
|
+
return computeMsgId(parts.join(''), message.meaning);
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Serialize the i18n ast to something xml-like in order to generate an UID.
|
|
1446
|
+
*
|
|
1447
|
+
* The visitor is also used in the i18n parser tests
|
|
1448
|
+
*
|
|
1449
|
+
* @internal
|
|
1450
|
+
*/
|
|
1451
|
+
class _SerializerVisitor {
|
|
1452
|
+
visitText(text, context) {
|
|
1453
|
+
return text.value;
|
|
1454
|
+
}
|
|
1455
|
+
visitContainer(container, context) {
|
|
1456
|
+
return `[${container.children.map(child => child.visit(this)).join(', ')}]`;
|
|
1457
|
+
}
|
|
1458
|
+
visitIcu(icu, context) {
|
|
1459
|
+
const strCases = Object.keys(icu.cases).map((k) => `${k} {${icu.cases[k].visit(this)}}`);
|
|
1460
|
+
return `{${icu.expression}, ${icu.type}, ${strCases.join(', ')}}`;
|
|
1461
|
+
}
|
|
1462
|
+
visitTagPlaceholder(ph, context) {
|
|
1463
|
+
return ph.isVoid ?
|
|
1464
|
+
`<ph tag name="${ph.startName}"/>` :
|
|
1465
|
+
`<ph tag name="${ph.startName}">${ph.children.map(child => child.visit(this)).join(', ')}</ph name="${ph.closeName}">`;
|
|
1466
|
+
}
|
|
1467
|
+
visitPlaceholder(ph, context) {
|
|
1468
|
+
return ph.value ? `<ph name="${ph.name}">${ph.value}</ph>` : `<ph name="${ph.name}"/>`;
|
|
1469
|
+
}
|
|
1470
|
+
visitIcuPlaceholder(ph, context) {
|
|
1471
|
+
return `<ph icu name="${ph.name}">${ph.value.visit(this)}</ph>`;
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
const serializerVisitor$1 = new _SerializerVisitor();
|
|
1475
|
+
function serializeNodes(nodes) {
|
|
1476
|
+
return nodes.map(a => a.visit(serializerVisitor$1, null));
|
|
1477
|
+
}
|
|
1478
|
+
/**
|
|
1479
|
+
* Serialize the i18n ast to something xml-like in order to generate an UID.
|
|
1480
|
+
*
|
|
1481
|
+
* Ignore the ICU expressions so that message IDs stays identical if only the expression changes.
|
|
1482
|
+
*
|
|
1483
|
+
* @internal
|
|
1484
|
+
*/
|
|
1485
|
+
class _SerializerIgnoreIcuExpVisitor extends _SerializerVisitor {
|
|
1486
|
+
visitIcu(icu, context) {
|
|
1487
|
+
let strCases = Object.keys(icu.cases).map((k) => `${k} {${icu.cases[k].visit(this)}}`);
|
|
1488
|
+
// Do not take the expression into account
|
|
1489
|
+
return `{${icu.type}, ${strCases.join(', ')}}`;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Compute the SHA1 of the given string
|
|
1494
|
+
*
|
|
1495
|
+
* see https://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
|
|
1496
|
+
*
|
|
1497
|
+
* WARNING: this function has not been designed not tested with security in mind.
|
|
1498
|
+
* DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.
|
|
1499
|
+
*/
|
|
1500
|
+
function sha1(str) {
|
|
1501
|
+
const utf8 = utf8Encode(str);
|
|
1502
|
+
const words32 = bytesToWords32(utf8, Endian.Big);
|
|
1503
|
+
const len = utf8.length * 8;
|
|
1504
|
+
const w = newArray(80);
|
|
1505
|
+
let a = 0x67452301, b = 0xefcdab89, c = 0x98badcfe, d = 0x10325476, e = 0xc3d2e1f0;
|
|
1506
|
+
words32[len >> 5] |= 0x80 << (24 - len % 32);
|
|
1507
|
+
words32[((len + 64 >> 9) << 4) + 15] = len;
|
|
1508
|
+
for (let i = 0; i < words32.length; i += 16) {
|
|
1509
|
+
const h0 = a, h1 = b, h2 = c, h3 = d, h4 = e;
|
|
1510
|
+
for (let j = 0; j < 80; j++) {
|
|
1511
|
+
if (j < 16) {
|
|
1512
|
+
w[j] = words32[i + j];
|
|
1513
|
+
}
|
|
1514
|
+
else {
|
|
1515
|
+
w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
|
|
1516
|
+
}
|
|
1517
|
+
const fkVal = fk(j, b, c, d);
|
|
1518
|
+
const f = fkVal[0];
|
|
1519
|
+
const k = fkVal[1];
|
|
1520
|
+
const temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
|
|
1521
|
+
e = d;
|
|
1522
|
+
d = c;
|
|
1523
|
+
c = rol32(b, 30);
|
|
1524
|
+
b = a;
|
|
1525
|
+
a = temp;
|
|
1526
|
+
}
|
|
1527
|
+
a = add32(a, h0);
|
|
1528
|
+
b = add32(b, h1);
|
|
1529
|
+
c = add32(c, h2);
|
|
1530
|
+
d = add32(d, h3);
|
|
1531
|
+
e = add32(e, h4);
|
|
1532
|
+
}
|
|
1533
|
+
return bytesToHexString(words32ToByteString([a, b, c, d, e]));
|
|
1534
|
+
}
|
|
1535
|
+
function fk(index, b, c, d) {
|
|
1536
|
+
if (index < 20) {
|
|
1537
|
+
return [(b & c) | (~b & d), 0x5a827999];
|
|
1538
|
+
}
|
|
1539
|
+
if (index < 40) {
|
|
1540
|
+
return [b ^ c ^ d, 0x6ed9eba1];
|
|
1541
|
+
}
|
|
1542
|
+
if (index < 60) {
|
|
1543
|
+
return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];
|
|
1544
|
+
}
|
|
1545
|
+
return [b ^ c ^ d, 0xca62c1d6];
|
|
1546
|
+
}
|
|
1547
|
+
/**
|
|
1548
|
+
* Compute the fingerprint of the given string
|
|
1549
|
+
*
|
|
1550
|
+
* The output is 64 bit number encoded as a decimal string
|
|
1551
|
+
*
|
|
1552
|
+
* based on:
|
|
1553
|
+
* https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
|
|
1554
|
+
*/
|
|
1555
|
+
function fingerprint(str) {
|
|
1556
|
+
const utf8 = utf8Encode(str);
|
|
1557
|
+
let hi = hash32(utf8, 0);
|
|
1558
|
+
let lo = hash32(utf8, 102072);
|
|
1559
|
+
if (hi == 0 && (lo == 0 || lo == 1)) {
|
|
1560
|
+
hi = hi ^ 0x130f9bef;
|
|
1561
|
+
lo = lo ^ -0x6b5f56d8;
|
|
1562
|
+
}
|
|
1563
|
+
return [hi, lo];
|
|
1564
|
+
}
|
|
1565
|
+
function computeMsgId(msg, meaning = '') {
|
|
1566
|
+
let msgFingerprint = fingerprint(msg);
|
|
1567
|
+
if (meaning) {
|
|
1568
|
+
const meaningFingerprint = fingerprint(meaning);
|
|
1569
|
+
msgFingerprint = add64(rol64(msgFingerprint, 1), meaningFingerprint);
|
|
1570
|
+
}
|
|
1571
|
+
const hi = msgFingerprint[0];
|
|
1572
|
+
const lo = msgFingerprint[1];
|
|
1573
|
+
return wordsToDecimalString(hi & 0x7fffffff, lo);
|
|
1574
|
+
}
|
|
1575
|
+
function hash32(bytes, c) {
|
|
1576
|
+
let a = 0x9e3779b9, b = 0x9e3779b9;
|
|
1577
|
+
let i;
|
|
1578
|
+
const len = bytes.length;
|
|
1579
|
+
for (i = 0; i + 12 <= len; i += 12) {
|
|
1580
|
+
a = add32(a, wordAt(bytes, i, Endian.Little));
|
|
1581
|
+
b = add32(b, wordAt(bytes, i + 4, Endian.Little));
|
|
1582
|
+
c = add32(c, wordAt(bytes, i + 8, Endian.Little));
|
|
1583
|
+
const res = mix(a, b, c);
|
|
1584
|
+
a = res[0], b = res[1], c = res[2];
|
|
1585
|
+
}
|
|
1586
|
+
a = add32(a, wordAt(bytes, i, Endian.Little));
|
|
1587
|
+
b = add32(b, wordAt(bytes, i + 4, Endian.Little));
|
|
1588
|
+
// the first byte of c is reserved for the length
|
|
1589
|
+
c = add32(c, len);
|
|
1590
|
+
c = add32(c, wordAt(bytes, i + 8, Endian.Little) << 8);
|
|
1591
|
+
return mix(a, b, c)[2];
|
|
1592
|
+
}
|
|
1593
|
+
// clang-format off
|
|
1594
|
+
function mix(a, b, c) {
|
|
1595
|
+
a = sub32(a, b);
|
|
1596
|
+
a = sub32(a, c);
|
|
1597
|
+
a ^= c >>> 13;
|
|
1598
|
+
b = sub32(b, c);
|
|
1599
|
+
b = sub32(b, a);
|
|
1600
|
+
b ^= a << 8;
|
|
1601
|
+
c = sub32(c, a);
|
|
1602
|
+
c = sub32(c, b);
|
|
1603
|
+
c ^= b >>> 13;
|
|
1604
|
+
a = sub32(a, b);
|
|
1605
|
+
a = sub32(a, c);
|
|
1606
|
+
a ^= c >>> 12;
|
|
1607
|
+
b = sub32(b, c);
|
|
1608
|
+
b = sub32(b, a);
|
|
1609
|
+
b ^= a << 16;
|
|
1610
|
+
c = sub32(c, a);
|
|
1611
|
+
c = sub32(c, b);
|
|
1612
|
+
c ^= b >>> 5;
|
|
1613
|
+
a = sub32(a, b);
|
|
1614
|
+
a = sub32(a, c);
|
|
1615
|
+
a ^= c >>> 3;
|
|
1616
|
+
b = sub32(b, c);
|
|
1617
|
+
b = sub32(b, a);
|
|
1618
|
+
b ^= a << 10;
|
|
1619
|
+
c = sub32(c, a);
|
|
1620
|
+
c = sub32(c, b);
|
|
1621
|
+
c ^= b >>> 15;
|
|
1622
|
+
return [a, b, c];
|
|
1623
|
+
}
|
|
1624
|
+
// clang-format on
|
|
1625
|
+
// Utils
|
|
1626
|
+
var Endian;
|
|
1627
|
+
(function (Endian) {
|
|
1628
|
+
Endian[Endian["Little"] = 0] = "Little";
|
|
1629
|
+
Endian[Endian["Big"] = 1] = "Big";
|
|
1630
|
+
})(Endian || (Endian = {}));
|
|
1631
|
+
function add32(a, b) {
|
|
1632
|
+
return add32to64(a, b)[1];
|
|
1633
|
+
}
|
|
1634
|
+
function add32to64(a, b) {
|
|
1635
|
+
const low = (a & 0xffff) + (b & 0xffff);
|
|
1636
|
+
const high = (a >>> 16) + (b >>> 16) + (low >>> 16);
|
|
1637
|
+
return [high >>> 16, (high << 16) | (low & 0xffff)];
|
|
1638
|
+
}
|
|
1639
|
+
function add64(a, b) {
|
|
1640
|
+
const ah = a[0], al = a[1];
|
|
1641
|
+
const bh = b[0], bl = b[1];
|
|
1642
|
+
const result = add32to64(al, bl);
|
|
1643
|
+
const carry = result[0];
|
|
1644
|
+
const l = result[1];
|
|
1645
|
+
const h = add32(add32(ah, bh), carry);
|
|
1646
|
+
return [h, l];
|
|
1647
|
+
}
|
|
1648
|
+
function sub32(a, b) {
|
|
1649
|
+
const low = (a & 0xffff) - (b & 0xffff);
|
|
1650
|
+
const high = (a >> 16) - (b >> 16) + (low >> 16);
|
|
1651
|
+
return (high << 16) | (low & 0xffff);
|
|
1652
|
+
}
|
|
1653
|
+
// Rotate a 32b number left `count` position
|
|
1654
|
+
function rol32(a, count) {
|
|
1655
|
+
return (a << count) | (a >>> (32 - count));
|
|
1656
|
+
}
|
|
1657
|
+
// Rotate a 64b number left `count` position
|
|
1658
|
+
function rol64(num, count) {
|
|
1659
|
+
const hi = num[0], lo = num[1];
|
|
1660
|
+
const h = (hi << count) | (lo >>> (32 - count));
|
|
1661
|
+
const l = (lo << count) | (hi >>> (32 - count));
|
|
1662
|
+
return [h, l];
|
|
1663
|
+
}
|
|
1664
|
+
function bytesToWords32(bytes, endian) {
|
|
1665
|
+
const size = (bytes.length + 3) >>> 2;
|
|
1666
|
+
const words32 = [];
|
|
1667
|
+
for (let i = 0; i < size; i++) {
|
|
1668
|
+
words32[i] = wordAt(bytes, i * 4, endian);
|
|
1669
|
+
}
|
|
1670
|
+
return words32;
|
|
1671
|
+
}
|
|
1672
|
+
function byteAt(bytes, index) {
|
|
1673
|
+
return index >= bytes.length ? 0 : bytes[index];
|
|
1674
|
+
}
|
|
1675
|
+
function wordAt(bytes, index, endian) {
|
|
1676
|
+
let word = 0;
|
|
1677
|
+
if (endian === Endian.Big) {
|
|
1678
|
+
for (let i = 0; i < 4; i++) {
|
|
1679
|
+
word += byteAt(bytes, index + i) << (24 - 8 * i);
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
else {
|
|
1683
|
+
for (let i = 0; i < 4; i++) {
|
|
1684
|
+
word += byteAt(bytes, index + i) << 8 * i;
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
return word;
|
|
1688
|
+
}
|
|
1689
|
+
function words32ToByteString(words32) {
|
|
1690
|
+
return words32.reduce((bytes, word) => bytes.concat(word32ToByteString(word)), []);
|
|
1691
|
+
}
|
|
1692
|
+
function word32ToByteString(word) {
|
|
1693
|
+
let bytes = [];
|
|
1694
|
+
for (let i = 0; i < 4; i++) {
|
|
1695
|
+
bytes.push((word >>> 8 * (3 - i)) & 0xff);
|
|
1696
|
+
}
|
|
1697
|
+
return bytes;
|
|
1698
|
+
}
|
|
1699
|
+
function bytesToHexString(bytes) {
|
|
1700
|
+
let hex = '';
|
|
1701
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
1702
|
+
const b = byteAt(bytes, i);
|
|
1703
|
+
hex += (b >>> 4).toString(16) + (b & 0x0f).toString(16);
|
|
1704
|
+
}
|
|
1705
|
+
return hex.toLowerCase();
|
|
1706
|
+
}
|
|
1707
|
+
/**
|
|
1708
|
+
* Create a shared exponentiation pool for base-256 computations. This shared pool provides memoized
|
|
1709
|
+
* power-of-256 results with memoized power-of-two computations for efficient multiplication.
|
|
1710
|
+
*
|
|
1711
|
+
* For our purposes, this can be safely stored as a global without memory concerns. The reason is
|
|
1712
|
+
* that we encode two words, so only need the 0th (for the low word) and 4th (for the high word)
|
|
1713
|
+
* exponent.
|
|
1714
|
+
*/
|
|
1715
|
+
const base256 = new BigIntExponentiation(256);
|
|
1716
|
+
/**
|
|
1717
|
+
* Represents two 32-bit words as a single decimal number. This requires a big integer storage
|
|
1718
|
+
* model as JS numbers are not accurate enough to represent the 64-bit number.
|
|
1719
|
+
*
|
|
1720
|
+
* Based on https://www.danvk.org/hex2dec.html
|
|
1721
|
+
*/
|
|
1722
|
+
function wordsToDecimalString(hi, lo) {
|
|
1723
|
+
// Encode the four bytes in lo in the lower digits of the decimal number.
|
|
1724
|
+
// Note: the multiplication results in lo itself but represented by a big integer using its
|
|
1725
|
+
// decimal digits.
|
|
1726
|
+
const decimal = base256.toThePowerOf(0).multiplyBy(lo);
|
|
1727
|
+
// Encode the four bytes in hi above the four lo bytes. lo is a maximum of (2^8)^4, which is why
|
|
1728
|
+
// this multiplication factor is applied.
|
|
1729
|
+
base256.toThePowerOf(4).multiplyByAndAddTo(hi, decimal);
|
|
1730
|
+
return decimal.toString();
|
|
1731
|
+
}
|
|
1732
|
+
|
|
1115
1733
|
/**
|
|
1116
1734
|
* @license
|
|
1117
1735
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -1517,16 +2135,31 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
1517
2135
|
rawText ?? sourceSpan?.toString() ?? escapeForTemplateLiteral(escapeSlashes(text));
|
|
1518
2136
|
}
|
|
1519
2137
|
}
|
|
1520
|
-
class
|
|
2138
|
+
class LiteralPiece {
|
|
1521
2139
|
constructor(text, sourceSpan) {
|
|
1522
2140
|
this.text = text;
|
|
1523
2141
|
this.sourceSpan = sourceSpan;
|
|
1524
2142
|
}
|
|
1525
2143
|
}
|
|
1526
|
-
class
|
|
1527
|
-
|
|
1528
|
-
|
|
2144
|
+
class PlaceholderPiece {
|
|
2145
|
+
/**
|
|
2146
|
+
* Create a new instance of a `PlaceholderPiece`.
|
|
2147
|
+
*
|
|
2148
|
+
* @param text the name of this placeholder (e.g. `PH_1`).
|
|
2149
|
+
* @param sourceSpan the location of this placeholder in its localized message the source code.
|
|
2150
|
+
* @param associatedMessage reference to another message that this placeholder is associated with.
|
|
2151
|
+
* The `associatedMessage` is mainly used to provide a relationship to an ICU message that has
|
|
2152
|
+
* been extracted out from the message containing the placeholder.
|
|
2153
|
+
*/
|
|
2154
|
+
constructor(text, sourceSpan, associatedMessage) {
|
|
2155
|
+
this.text = text;
|
|
2156
|
+
this.sourceSpan = sourceSpan;
|
|
2157
|
+
this.associatedMessage = associatedMessage;
|
|
2158
|
+
}
|
|
1529
2159
|
}
|
|
2160
|
+
const MEANING_SEPARATOR = '|';
|
|
2161
|
+
const ID_SEPARATOR = '@@';
|
|
2162
|
+
const LEGACY_ID_INDICATOR = '␟';
|
|
1530
2163
|
class LocalizedString extends Expression {
|
|
1531
2164
|
constructor(metaBlock, messageParts, placeHolderNames, expressions, sourceSpan) {
|
|
1532
2165
|
super(STRING_TYPE, sourceSpan);
|
|
@@ -1554,9 +2187,6 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
1554
2187
|
* @param messagePart The first part of the tagged string
|
|
1555
2188
|
*/
|
|
1556
2189
|
serializeI18nHead() {
|
|
1557
|
-
const MEANING_SEPARATOR = '|';
|
|
1558
|
-
const ID_SEPARATOR = '@@';
|
|
1559
|
-
const LEGACY_ID_INDICATOR = '␟';
|
|
1560
2190
|
let metaBlock = this.metaBlock.description || '';
|
|
1561
2191
|
if (this.metaBlock.meaning) {
|
|
1562
2192
|
metaBlock = `${this.metaBlock.meaning}${MEANING_SEPARATOR}${metaBlock}`;
|
|
@@ -1582,13 +2212,21 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
1582
2212
|
* Serialize the given `placeholderName` and `messagePart` into "cooked" and "raw" strings that
|
|
1583
2213
|
* can be used in a `$localize` tagged string.
|
|
1584
2214
|
*
|
|
1585
|
-
*
|
|
1586
|
-
*
|
|
2215
|
+
* The format is `:<placeholder-name>[@@<associated-id>]:`.
|
|
2216
|
+
*
|
|
2217
|
+
* The `associated-id` is the message id of the (usually an ICU) message to which this placeholder
|
|
2218
|
+
* refers.
|
|
2219
|
+
*
|
|
2220
|
+
* @param partIndex The index of the message part to serialize.
|
|
1587
2221
|
*/
|
|
1588
2222
|
serializeI18nTemplatePart(partIndex) {
|
|
1589
|
-
const
|
|
2223
|
+
const placeholder = this.placeHolderNames[partIndex - 1];
|
|
1590
2224
|
const messagePart = this.messageParts[partIndex];
|
|
1591
|
-
|
|
2225
|
+
let metaBlock = placeholder.text;
|
|
2226
|
+
if (placeholder.associatedMessage?.legacyIds.length === 0) {
|
|
2227
|
+
metaBlock += `${ID_SEPARATOR}${computeMsgId(placeholder.associatedMessage.messageString, placeholder.associatedMessage.meaning)}`;
|
|
2228
|
+
}
|
|
2229
|
+
return createCookedRawString(metaBlock, messagePart.text, this.getMessagePartSourceSpan(partIndex));
|
|
1592
2230
|
}
|
|
1593
2231
|
}
|
|
1594
2232
|
const escapeSlashes = (str) => str.replace(/\\/g, '\\\\');
|
|
@@ -2561,128 +3199,6 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
2561
3199
|
Identifiers$1.trustConstantHtml = { name: 'ɵɵtrustConstantHtml', moduleName: CORE$1 };
|
|
2562
3200
|
Identifiers$1.trustConstantResourceUrl = { name: 'ɵɵtrustConstantResourceUrl', moduleName: CORE$1 };
|
|
2563
3201
|
|
|
2564
|
-
/**
|
|
2565
|
-
* @license
|
|
2566
|
-
* Copyright Google LLC All Rights Reserved.
|
|
2567
|
-
*
|
|
2568
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
2569
|
-
* found in the LICENSE file at https://angular.io/license
|
|
2570
|
-
*/
|
|
2571
|
-
const DASH_CASE_REGEXP = /-+([a-z0-9])/g;
|
|
2572
|
-
function dashCaseToCamelCase(input) {
|
|
2573
|
-
return input.replace(DASH_CASE_REGEXP, (...m) => m[1].toUpperCase());
|
|
2574
|
-
}
|
|
2575
|
-
function splitAtColon(input, defaultValues) {
|
|
2576
|
-
return _splitAt(input, ':', defaultValues);
|
|
2577
|
-
}
|
|
2578
|
-
function splitAtPeriod(input, defaultValues) {
|
|
2579
|
-
return _splitAt(input, '.', defaultValues);
|
|
2580
|
-
}
|
|
2581
|
-
function _splitAt(input, character, defaultValues) {
|
|
2582
|
-
const characterIndex = input.indexOf(character);
|
|
2583
|
-
if (characterIndex == -1)
|
|
2584
|
-
return defaultValues;
|
|
2585
|
-
return [input.slice(0, characterIndex).trim(), input.slice(characterIndex + 1).trim()];
|
|
2586
|
-
}
|
|
2587
|
-
function error(msg) {
|
|
2588
|
-
throw new Error(`Internal Error: ${msg}`);
|
|
2589
|
-
}
|
|
2590
|
-
function utf8Encode(str) {
|
|
2591
|
-
let encoded = [];
|
|
2592
|
-
for (let index = 0; index < str.length; index++) {
|
|
2593
|
-
let codePoint = str.charCodeAt(index);
|
|
2594
|
-
// decode surrogate
|
|
2595
|
-
// see https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
|
|
2596
|
-
if (codePoint >= 0xd800 && codePoint <= 0xdbff && str.length > (index + 1)) {
|
|
2597
|
-
const low = str.charCodeAt(index + 1);
|
|
2598
|
-
if (low >= 0xdc00 && low <= 0xdfff) {
|
|
2599
|
-
index++;
|
|
2600
|
-
codePoint = ((codePoint - 0xd800) << 10) + low - 0xdc00 + 0x10000;
|
|
2601
|
-
}
|
|
2602
|
-
}
|
|
2603
|
-
if (codePoint <= 0x7f) {
|
|
2604
|
-
encoded.push(codePoint);
|
|
2605
|
-
}
|
|
2606
|
-
else if (codePoint <= 0x7ff) {
|
|
2607
|
-
encoded.push(((codePoint >> 6) & 0x1F) | 0xc0, (codePoint & 0x3f) | 0x80);
|
|
2608
|
-
}
|
|
2609
|
-
else if (codePoint <= 0xffff) {
|
|
2610
|
-
encoded.push((codePoint >> 12) | 0xe0, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
|
|
2611
|
-
}
|
|
2612
|
-
else if (codePoint <= 0x1fffff) {
|
|
2613
|
-
encoded.push(((codePoint >> 18) & 0x07) | 0xf0, ((codePoint >> 12) & 0x3f) | 0x80, ((codePoint >> 6) & 0x3f) | 0x80, (codePoint & 0x3f) | 0x80);
|
|
2614
|
-
}
|
|
2615
|
-
}
|
|
2616
|
-
return encoded;
|
|
2617
|
-
}
|
|
2618
|
-
function stringify(token) {
|
|
2619
|
-
if (typeof token === 'string') {
|
|
2620
|
-
return token;
|
|
2621
|
-
}
|
|
2622
|
-
if (Array.isArray(token)) {
|
|
2623
|
-
return '[' + token.map(stringify).join(', ') + ']';
|
|
2624
|
-
}
|
|
2625
|
-
if (token == null) {
|
|
2626
|
-
return '' + token;
|
|
2627
|
-
}
|
|
2628
|
-
if (token.overriddenName) {
|
|
2629
|
-
return `${token.overriddenName}`;
|
|
2630
|
-
}
|
|
2631
|
-
if (token.name) {
|
|
2632
|
-
return `${token.name}`;
|
|
2633
|
-
}
|
|
2634
|
-
if (!token.toString) {
|
|
2635
|
-
return 'object';
|
|
2636
|
-
}
|
|
2637
|
-
// WARNING: do not try to `JSON.stringify(token)` here
|
|
2638
|
-
// see https://github.com/angular/angular/issues/23440
|
|
2639
|
-
const res = token.toString();
|
|
2640
|
-
if (res == null) {
|
|
2641
|
-
return '' + res;
|
|
2642
|
-
}
|
|
2643
|
-
const newLineIndex = res.indexOf('\n');
|
|
2644
|
-
return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
|
|
2645
|
-
}
|
|
2646
|
-
class Version {
|
|
2647
|
-
constructor(full) {
|
|
2648
|
-
this.full = full;
|
|
2649
|
-
const splits = full.split('.');
|
|
2650
|
-
this.major = splits[0];
|
|
2651
|
-
this.minor = splits[1];
|
|
2652
|
-
this.patch = splits.slice(2).join('.');
|
|
2653
|
-
}
|
|
2654
|
-
}
|
|
2655
|
-
const __window = typeof window !== 'undefined' && window;
|
|
2656
|
-
const __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
|
|
2657
|
-
self instanceof WorkerGlobalScope && self;
|
|
2658
|
-
const __global = typeof global !== 'undefined' && global;
|
|
2659
|
-
// Check __global first, because in Node tests both __global and __window may be defined and _global
|
|
2660
|
-
// should be __global in that case.
|
|
2661
|
-
const _global = __global || __window || __self;
|
|
2662
|
-
function newArray(size, value) {
|
|
2663
|
-
const list = [];
|
|
2664
|
-
for (let i = 0; i < size; i++) {
|
|
2665
|
-
list.push(value);
|
|
2666
|
-
}
|
|
2667
|
-
return list;
|
|
2668
|
-
}
|
|
2669
|
-
/**
|
|
2670
|
-
* Partitions a given array into 2 arrays, based on a boolean value returned by the condition
|
|
2671
|
-
* function.
|
|
2672
|
-
*
|
|
2673
|
-
* @param arr Input array that should be partitioned
|
|
2674
|
-
* @param conditionFn Condition function that is called for each item in a given array and returns a
|
|
2675
|
-
* boolean value.
|
|
2676
|
-
*/
|
|
2677
|
-
function partitionArray(arr, conditionFn) {
|
|
2678
|
-
const truthy = [];
|
|
2679
|
-
const falsy = [];
|
|
2680
|
-
for (const item of arr) {
|
|
2681
|
-
(conditionFn(item) ? truthy : falsy).push(item);
|
|
2682
|
-
}
|
|
2683
|
-
return [truthy, falsy];
|
|
2684
|
-
}
|
|
2685
|
-
|
|
2686
3202
|
/**
|
|
2687
3203
|
* @license
|
|
2688
3204
|
* Copyright Google LLC All Rights Reserved.
|
|
@@ -2941,6 +3457,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
2941
3457
|
this.id = this.customId;
|
|
2942
3458
|
/** The ids to use if there are no custom id and if `i18nLegacyMessageIdFormat` is not empty */
|
|
2943
3459
|
this.legacyIds = [];
|
|
3460
|
+
this.messageString = serializeMessage(this.nodes);
|
|
2944
3461
|
if (nodes.length) {
|
|
2945
3462
|
this.sources = [{
|
|
2946
3463
|
filePath: nodes[0].sourceSpan.start.file.url,
|
|
@@ -3023,501 +3540,35 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
3023
3540
|
return visitor.visitIcuPlaceholder(this, context);
|
|
3024
3541
|
}
|
|
3025
3542
|
}
|
|
3026
|
-
|
|
3027
|
-
/**
|
|
3028
|
-
* @license
|
|
3029
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3030
|
-
*
|
|
3031
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3032
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3033
|
-
*/
|
|
3034
3543
|
/**
|
|
3035
|
-
*
|
|
3036
|
-
* digit stored at the beginning of the array (little endian).
|
|
3037
|
-
*
|
|
3038
|
-
* For performance reasons, each instance is mutable. The addition operation can be done in-place
|
|
3039
|
-
* to reduce memory pressure of allocation for the digits array.
|
|
3544
|
+
* Serialize the message to the Localize backtick string format that would appear in compiled code.
|
|
3040
3545
|
*/
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
constructor(digits) {
|
|
3046
|
-
this.digits = digits;
|
|
3047
|
-
}
|
|
3048
|
-
static zero() {
|
|
3049
|
-
return new BigInteger([0]);
|
|
3050
|
-
}
|
|
3051
|
-
static one() {
|
|
3052
|
-
return new BigInteger([1]);
|
|
3053
|
-
}
|
|
3054
|
-
/**
|
|
3055
|
-
* Creates a clone of this instance.
|
|
3056
|
-
*/
|
|
3057
|
-
clone() {
|
|
3058
|
-
return new BigInteger(this.digits.slice());
|
|
3059
|
-
}
|
|
3060
|
-
/**
|
|
3061
|
-
* Returns a new big integer with the sum of `this` and `other` as its value. This does not mutate
|
|
3062
|
-
* `this` but instead returns a new instance, unlike `addToSelf`.
|
|
3063
|
-
*/
|
|
3064
|
-
add(other) {
|
|
3065
|
-
const result = this.clone();
|
|
3066
|
-
result.addToSelf(other);
|
|
3067
|
-
return result;
|
|
3068
|
-
}
|
|
3069
|
-
/**
|
|
3070
|
-
* Adds `other` to the instance itself, thereby mutating its value.
|
|
3071
|
-
*/
|
|
3072
|
-
addToSelf(other) {
|
|
3073
|
-
const maxNrOfDigits = Math.max(this.digits.length, other.digits.length);
|
|
3074
|
-
let carry = 0;
|
|
3075
|
-
for (let i = 0; i < maxNrOfDigits; i++) {
|
|
3076
|
-
let digitSum = carry;
|
|
3077
|
-
if (i < this.digits.length) {
|
|
3078
|
-
digitSum += this.digits[i];
|
|
3079
|
-
}
|
|
3080
|
-
if (i < other.digits.length) {
|
|
3081
|
-
digitSum += other.digits[i];
|
|
3082
|
-
}
|
|
3083
|
-
if (digitSum >= 10) {
|
|
3084
|
-
this.digits[i] = digitSum - 10;
|
|
3085
|
-
carry = 1;
|
|
3086
|
-
}
|
|
3087
|
-
else {
|
|
3088
|
-
this.digits[i] = digitSum;
|
|
3089
|
-
carry = 0;
|
|
3090
|
-
}
|
|
3091
|
-
}
|
|
3092
|
-
// Apply a remaining carry if needed.
|
|
3093
|
-
if (carry > 0) {
|
|
3094
|
-
this.digits[maxNrOfDigits] = 1;
|
|
3095
|
-
}
|
|
3096
|
-
}
|
|
3097
|
-
/**
|
|
3098
|
-
* Builds the decimal string representation of the big integer. As this is stored in
|
|
3099
|
-
* little endian, the digits are concatenated in reverse order.
|
|
3100
|
-
*/
|
|
3101
|
-
toString() {
|
|
3102
|
-
let res = '';
|
|
3103
|
-
for (let i = this.digits.length - 1; i >= 0; i--) {
|
|
3104
|
-
res += this.digits[i];
|
|
3105
|
-
}
|
|
3106
|
-
return res;
|
|
3107
|
-
}
|
|
3546
|
+
function serializeMessage(messageNodes) {
|
|
3547
|
+
const visitor = new LocalizeMessageStringVisitor();
|
|
3548
|
+
const str = messageNodes.map(n => n.visit(visitor)).join('');
|
|
3549
|
+
return str;
|
|
3108
3550
|
}
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
* are memoized. See `multiplyBy()` for details on the multiplication algorithm.
|
|
3112
|
-
*/
|
|
3113
|
-
class BigIntForMultiplication {
|
|
3114
|
-
constructor(value) {
|
|
3115
|
-
this.powerOfTwos = [value];
|
|
3116
|
-
}
|
|
3117
|
-
/**
|
|
3118
|
-
* Returns the big integer itself.
|
|
3119
|
-
*/
|
|
3120
|
-
getValue() {
|
|
3121
|
-
return this.powerOfTwos[0];
|
|
3122
|
-
}
|
|
3123
|
-
/**
|
|
3124
|
-
* Computes the value for `num * b`, where `num` is a JS number and `b` is a big integer. The
|
|
3125
|
-
* value for `b` is represented by a storage model that is optimized for this computation.
|
|
3126
|
-
*
|
|
3127
|
-
* This operation is implemented in N(log2(num)) by continuous halving of the number, where the
|
|
3128
|
-
* least-significant bit (LSB) is tested in each iteration. If the bit is set, the bit's index is
|
|
3129
|
-
* used as exponent into the power-of-two multiplication of `b`.
|
|
3130
|
-
*
|
|
3131
|
-
* As an example, consider the multiplication num=42, b=1337. In binary 42 is 0b00101010 and the
|
|
3132
|
-
* algorithm unrolls into the following iterations:
|
|
3133
|
-
*
|
|
3134
|
-
* Iteration | num | LSB | b * 2^iter | Add? | product
|
|
3135
|
-
* -----------|------------|------|------------|------|--------
|
|
3136
|
-
* 0 | 0b00101010 | 0 | 1337 | No | 0
|
|
3137
|
-
* 1 | 0b00010101 | 1 | 2674 | Yes | 2674
|
|
3138
|
-
* 2 | 0b00001010 | 0 | 5348 | No | 2674
|
|
3139
|
-
* 3 | 0b00000101 | 1 | 10696 | Yes | 13370
|
|
3140
|
-
* 4 | 0b00000010 | 0 | 21392 | No | 13370
|
|
3141
|
-
* 5 | 0b00000001 | 1 | 42784 | Yes | 56154
|
|
3142
|
-
* 6 | 0b00000000 | 0 | 85568 | No | 56154
|
|
3143
|
-
*
|
|
3144
|
-
* The computed product of 56154 is indeed the correct result.
|
|
3145
|
-
*
|
|
3146
|
-
* The `BigIntForMultiplication` representation for a big integer provides memoized access to the
|
|
3147
|
-
* power-of-two values to reduce the workload in computing those values.
|
|
3148
|
-
*/
|
|
3149
|
-
multiplyBy(num) {
|
|
3150
|
-
const product = BigInteger.zero();
|
|
3151
|
-
this.multiplyByAndAddTo(num, product);
|
|
3152
|
-
return product;
|
|
3153
|
-
}
|
|
3154
|
-
/**
|
|
3155
|
-
* See `multiplyBy()` for details. This function allows for the computed product to be added
|
|
3156
|
-
* directly to the provided result big integer.
|
|
3157
|
-
*/
|
|
3158
|
-
multiplyByAndAddTo(num, result) {
|
|
3159
|
-
for (let exponent = 0; num !== 0; num = num >>> 1, exponent++) {
|
|
3160
|
-
if (num & 1) {
|
|
3161
|
-
const value = this.getMultipliedByPowerOfTwo(exponent);
|
|
3162
|
-
result.addToSelf(value);
|
|
3163
|
-
}
|
|
3164
|
-
}
|
|
3165
|
-
}
|
|
3166
|
-
/**
|
|
3167
|
-
* Computes and memoizes the big integer value for `this.number * 2^exponent`.
|
|
3168
|
-
*/
|
|
3169
|
-
getMultipliedByPowerOfTwo(exponent) {
|
|
3170
|
-
// Compute the powers up until the requested exponent, where each value is computed from its
|
|
3171
|
-
// predecessor. This is simple as `this.number * 2^(exponent - 1)` only has to be doubled (i.e.
|
|
3172
|
-
// added to itself) to reach `this.number * 2^exponent`.
|
|
3173
|
-
for (let i = this.powerOfTwos.length; i <= exponent; i++) {
|
|
3174
|
-
const previousPower = this.powerOfTwos[i - 1];
|
|
3175
|
-
this.powerOfTwos[i] = previousPower.add(previousPower);
|
|
3176
|
-
}
|
|
3177
|
-
return this.powerOfTwos[exponent];
|
|
3178
|
-
}
|
|
3179
|
-
}
|
|
3180
|
-
/**
|
|
3181
|
-
* Represents an exponentiation operation for the provided base, of which exponents are computed and
|
|
3182
|
-
* memoized. The results are represented by a `BigIntForMultiplication` which is tailored for
|
|
3183
|
-
* multiplication operations by memoizing the power-of-twos. This effectively results in a matrix
|
|
3184
|
-
* representation that is lazily computed upon request.
|
|
3185
|
-
*/
|
|
3186
|
-
class BigIntExponentiation {
|
|
3187
|
-
constructor(base) {
|
|
3188
|
-
this.base = base;
|
|
3189
|
-
this.exponents = [new BigIntForMultiplication(BigInteger.one())];
|
|
3190
|
-
}
|
|
3191
|
-
/**
|
|
3192
|
-
* Compute the value for `this.base^exponent`, resulting in a big integer that is optimized for
|
|
3193
|
-
* further multiplication operations.
|
|
3194
|
-
*/
|
|
3195
|
-
toThePowerOf(exponent) {
|
|
3196
|
-
// Compute the results up until the requested exponent, where every value is computed from its
|
|
3197
|
-
// predecessor. This is because `this.base^(exponent - 1)` only has to be multiplied by `base`
|
|
3198
|
-
// to reach `this.base^exponent`.
|
|
3199
|
-
for (let i = this.exponents.length; i <= exponent; i++) {
|
|
3200
|
-
const value = this.exponents[i - 1].multiplyBy(this.base);
|
|
3201
|
-
this.exponents[i] = new BigIntForMultiplication(value);
|
|
3202
|
-
}
|
|
3203
|
-
return this.exponents[exponent];
|
|
3204
|
-
}
|
|
3205
|
-
}
|
|
3206
|
-
|
|
3207
|
-
/**
|
|
3208
|
-
* @license
|
|
3209
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3210
|
-
*
|
|
3211
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3212
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3213
|
-
*/
|
|
3214
|
-
/**
|
|
3215
|
-
* Compute the message id using the XLIFF1 digest.
|
|
3216
|
-
*/
|
|
3217
|
-
function computeDigest(message) {
|
|
3218
|
-
return sha1(serializeNodes(message.nodes).join('') + `[${message.meaning}]`);
|
|
3219
|
-
}
|
|
3220
|
-
/**
|
|
3221
|
-
* Return the message id or compute it using the XLIFF2/XMB/$localize digest.
|
|
3222
|
-
*/
|
|
3223
|
-
function decimalDigest(message) {
|
|
3224
|
-
return message.id || computeDecimalDigest(message);
|
|
3225
|
-
}
|
|
3226
|
-
/**
|
|
3227
|
-
* Compute the message id using the XLIFF2/XMB/$localize digest.
|
|
3228
|
-
*/
|
|
3229
|
-
function computeDecimalDigest(message) {
|
|
3230
|
-
const visitor = new _SerializerIgnoreIcuExpVisitor();
|
|
3231
|
-
const parts = message.nodes.map(a => a.visit(visitor, null));
|
|
3232
|
-
return computeMsgId(parts.join(''), message.meaning);
|
|
3233
|
-
}
|
|
3234
|
-
/**
|
|
3235
|
-
* Serialize the i18n ast to something xml-like in order to generate an UID.
|
|
3236
|
-
*
|
|
3237
|
-
* The visitor is also used in the i18n parser tests
|
|
3238
|
-
*
|
|
3239
|
-
* @internal
|
|
3240
|
-
*/
|
|
3241
|
-
class _SerializerVisitor {
|
|
3242
|
-
visitText(text, context) {
|
|
3551
|
+
class LocalizeMessageStringVisitor {
|
|
3552
|
+
visitText(text) {
|
|
3243
3553
|
return text.value;
|
|
3244
3554
|
}
|
|
3245
|
-
visitContainer(container
|
|
3246
|
-
return
|
|
3555
|
+
visitContainer(container) {
|
|
3556
|
+
return container.children.map(child => child.visit(this)).join('');
|
|
3247
3557
|
}
|
|
3248
|
-
visitIcu(icu
|
|
3558
|
+
visitIcu(icu) {
|
|
3249
3559
|
const strCases = Object.keys(icu.cases).map((k) => `${k} {${icu.cases[k].visit(this)}}`);
|
|
3250
|
-
return `{${icu.
|
|
3251
|
-
}
|
|
3252
|
-
visitTagPlaceholder(ph, context) {
|
|
3253
|
-
return ph.isVoid ?
|
|
3254
|
-
`<ph tag name="${ph.startName}"/>` :
|
|
3255
|
-
`<ph tag name="${ph.startName}">${ph.children.map(child => child.visit(this)).join(', ')}</ph name="${ph.closeName}">`;
|
|
3256
|
-
}
|
|
3257
|
-
visitPlaceholder(ph, context) {
|
|
3258
|
-
return ph.value ? `<ph name="${ph.name}">${ph.value}</ph>` : `<ph name="${ph.name}"/>`;
|
|
3259
|
-
}
|
|
3260
|
-
visitIcuPlaceholder(ph, context) {
|
|
3261
|
-
return `<ph icu name="${ph.name}">${ph.value.visit(this)}</ph>`;
|
|
3262
|
-
}
|
|
3263
|
-
}
|
|
3264
|
-
const serializerVisitor$2 = new _SerializerVisitor();
|
|
3265
|
-
function serializeNodes(nodes) {
|
|
3266
|
-
return nodes.map(a => a.visit(serializerVisitor$2, null));
|
|
3267
|
-
}
|
|
3268
|
-
/**
|
|
3269
|
-
* Serialize the i18n ast to something xml-like in order to generate an UID.
|
|
3270
|
-
*
|
|
3271
|
-
* Ignore the ICU expressions so that message IDs stays identical if only the expression changes.
|
|
3272
|
-
*
|
|
3273
|
-
* @internal
|
|
3274
|
-
*/
|
|
3275
|
-
class _SerializerIgnoreIcuExpVisitor extends _SerializerVisitor {
|
|
3276
|
-
visitIcu(icu, context) {
|
|
3277
|
-
let strCases = Object.keys(icu.cases).map((k) => `${k} {${icu.cases[k].visit(this)}}`);
|
|
3278
|
-
// Do not take the expression into account
|
|
3279
|
-
return `{${icu.type}, ${strCases.join(', ')}}`;
|
|
3280
|
-
}
|
|
3281
|
-
}
|
|
3282
|
-
/**
|
|
3283
|
-
* Compute the SHA1 of the given string
|
|
3284
|
-
*
|
|
3285
|
-
* see https://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
|
|
3286
|
-
*
|
|
3287
|
-
* WARNING: this function has not been designed not tested with security in mind.
|
|
3288
|
-
* DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.
|
|
3289
|
-
*/
|
|
3290
|
-
function sha1(str) {
|
|
3291
|
-
const utf8 = utf8Encode(str);
|
|
3292
|
-
const words32 = bytesToWords32(utf8, Endian.Big);
|
|
3293
|
-
const len = utf8.length * 8;
|
|
3294
|
-
const w = newArray(80);
|
|
3295
|
-
let a = 0x67452301, b = 0xefcdab89, c = 0x98badcfe, d = 0x10325476, e = 0xc3d2e1f0;
|
|
3296
|
-
words32[len >> 5] |= 0x80 << (24 - len % 32);
|
|
3297
|
-
words32[((len + 64 >> 9) << 4) + 15] = len;
|
|
3298
|
-
for (let i = 0; i < words32.length; i += 16) {
|
|
3299
|
-
const h0 = a, h1 = b, h2 = c, h3 = d, h4 = e;
|
|
3300
|
-
for (let j = 0; j < 80; j++) {
|
|
3301
|
-
if (j < 16) {
|
|
3302
|
-
w[j] = words32[i + j];
|
|
3303
|
-
}
|
|
3304
|
-
else {
|
|
3305
|
-
w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
|
|
3306
|
-
}
|
|
3307
|
-
const fkVal = fk(j, b, c, d);
|
|
3308
|
-
const f = fkVal[0];
|
|
3309
|
-
const k = fkVal[1];
|
|
3310
|
-
const temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
|
|
3311
|
-
e = d;
|
|
3312
|
-
d = c;
|
|
3313
|
-
c = rol32(b, 30);
|
|
3314
|
-
b = a;
|
|
3315
|
-
a = temp;
|
|
3316
|
-
}
|
|
3317
|
-
a = add32(a, h0);
|
|
3318
|
-
b = add32(b, h1);
|
|
3319
|
-
c = add32(c, h2);
|
|
3320
|
-
d = add32(d, h3);
|
|
3321
|
-
e = add32(e, h4);
|
|
3322
|
-
}
|
|
3323
|
-
return bytesToHexString(words32ToByteString([a, b, c, d, e]));
|
|
3324
|
-
}
|
|
3325
|
-
function fk(index, b, c, d) {
|
|
3326
|
-
if (index < 20) {
|
|
3327
|
-
return [(b & c) | (~b & d), 0x5a827999];
|
|
3328
|
-
}
|
|
3329
|
-
if (index < 40) {
|
|
3330
|
-
return [b ^ c ^ d, 0x6ed9eba1];
|
|
3331
|
-
}
|
|
3332
|
-
if (index < 60) {
|
|
3333
|
-
return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];
|
|
3334
|
-
}
|
|
3335
|
-
return [b ^ c ^ d, 0xca62c1d6];
|
|
3336
|
-
}
|
|
3337
|
-
/**
|
|
3338
|
-
* Compute the fingerprint of the given string
|
|
3339
|
-
*
|
|
3340
|
-
* The output is 64 bit number encoded as a decimal string
|
|
3341
|
-
*
|
|
3342
|
-
* based on:
|
|
3343
|
-
* https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
|
|
3344
|
-
*/
|
|
3345
|
-
function fingerprint(str) {
|
|
3346
|
-
const utf8 = utf8Encode(str);
|
|
3347
|
-
let hi = hash32(utf8, 0);
|
|
3348
|
-
let lo = hash32(utf8, 102072);
|
|
3349
|
-
if (hi == 0 && (lo == 0 || lo == 1)) {
|
|
3350
|
-
hi = hi ^ 0x130f9bef;
|
|
3351
|
-
lo = lo ^ -0x6b5f56d8;
|
|
3352
|
-
}
|
|
3353
|
-
return [hi, lo];
|
|
3354
|
-
}
|
|
3355
|
-
function computeMsgId(msg, meaning = '') {
|
|
3356
|
-
let msgFingerprint = fingerprint(msg);
|
|
3357
|
-
if (meaning) {
|
|
3358
|
-
const meaningFingerprint = fingerprint(meaning);
|
|
3359
|
-
msgFingerprint = add64(rol64(msgFingerprint, 1), meaningFingerprint);
|
|
3360
|
-
}
|
|
3361
|
-
const hi = msgFingerprint[0];
|
|
3362
|
-
const lo = msgFingerprint[1];
|
|
3363
|
-
return wordsToDecimalString(hi & 0x7fffffff, lo);
|
|
3364
|
-
}
|
|
3365
|
-
function hash32(bytes, c) {
|
|
3366
|
-
let a = 0x9e3779b9, b = 0x9e3779b9;
|
|
3367
|
-
let i;
|
|
3368
|
-
const len = bytes.length;
|
|
3369
|
-
for (i = 0; i + 12 <= len; i += 12) {
|
|
3370
|
-
a = add32(a, wordAt(bytes, i, Endian.Little));
|
|
3371
|
-
b = add32(b, wordAt(bytes, i + 4, Endian.Little));
|
|
3372
|
-
c = add32(c, wordAt(bytes, i + 8, Endian.Little));
|
|
3373
|
-
const res = mix(a, b, c);
|
|
3374
|
-
a = res[0], b = res[1], c = res[2];
|
|
3560
|
+
return `{${icu.expressionPlaceholder}, ${icu.type}, ${strCases.join(' ')}}`;
|
|
3375
3561
|
}
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
c = add32(c, len);
|
|
3380
|
-
c = add32(c, wordAt(bytes, i + 8, Endian.Little) << 8);
|
|
3381
|
-
return mix(a, b, c)[2];
|
|
3382
|
-
}
|
|
3383
|
-
// clang-format off
|
|
3384
|
-
function mix(a, b, c) {
|
|
3385
|
-
a = sub32(a, b);
|
|
3386
|
-
a = sub32(a, c);
|
|
3387
|
-
a ^= c >>> 13;
|
|
3388
|
-
b = sub32(b, c);
|
|
3389
|
-
b = sub32(b, a);
|
|
3390
|
-
b ^= a << 8;
|
|
3391
|
-
c = sub32(c, a);
|
|
3392
|
-
c = sub32(c, b);
|
|
3393
|
-
c ^= b >>> 13;
|
|
3394
|
-
a = sub32(a, b);
|
|
3395
|
-
a = sub32(a, c);
|
|
3396
|
-
a ^= c >>> 12;
|
|
3397
|
-
b = sub32(b, c);
|
|
3398
|
-
b = sub32(b, a);
|
|
3399
|
-
b ^= a << 16;
|
|
3400
|
-
c = sub32(c, a);
|
|
3401
|
-
c = sub32(c, b);
|
|
3402
|
-
c ^= b >>> 5;
|
|
3403
|
-
a = sub32(a, b);
|
|
3404
|
-
a = sub32(a, c);
|
|
3405
|
-
a ^= c >>> 3;
|
|
3406
|
-
b = sub32(b, c);
|
|
3407
|
-
b = sub32(b, a);
|
|
3408
|
-
b ^= a << 10;
|
|
3409
|
-
c = sub32(c, a);
|
|
3410
|
-
c = sub32(c, b);
|
|
3411
|
-
c ^= b >>> 15;
|
|
3412
|
-
return [a, b, c];
|
|
3413
|
-
}
|
|
3414
|
-
// clang-format on
|
|
3415
|
-
// Utils
|
|
3416
|
-
var Endian;
|
|
3417
|
-
(function (Endian) {
|
|
3418
|
-
Endian[Endian["Little"] = 0] = "Little";
|
|
3419
|
-
Endian[Endian["Big"] = 1] = "Big";
|
|
3420
|
-
})(Endian || (Endian = {}));
|
|
3421
|
-
function add32(a, b) {
|
|
3422
|
-
return add32to64(a, b)[1];
|
|
3423
|
-
}
|
|
3424
|
-
function add32to64(a, b) {
|
|
3425
|
-
const low = (a & 0xffff) + (b & 0xffff);
|
|
3426
|
-
const high = (a >>> 16) + (b >>> 16) + (low >>> 16);
|
|
3427
|
-
return [high >>> 16, (high << 16) | (low & 0xffff)];
|
|
3428
|
-
}
|
|
3429
|
-
function add64(a, b) {
|
|
3430
|
-
const ah = a[0], al = a[1];
|
|
3431
|
-
const bh = b[0], bl = b[1];
|
|
3432
|
-
const result = add32to64(al, bl);
|
|
3433
|
-
const carry = result[0];
|
|
3434
|
-
const l = result[1];
|
|
3435
|
-
const h = add32(add32(ah, bh), carry);
|
|
3436
|
-
return [h, l];
|
|
3437
|
-
}
|
|
3438
|
-
function sub32(a, b) {
|
|
3439
|
-
const low = (a & 0xffff) - (b & 0xffff);
|
|
3440
|
-
const high = (a >> 16) - (b >> 16) + (low >> 16);
|
|
3441
|
-
return (high << 16) | (low & 0xffff);
|
|
3442
|
-
}
|
|
3443
|
-
// Rotate a 32b number left `count` position
|
|
3444
|
-
function rol32(a, count) {
|
|
3445
|
-
return (a << count) | (a >>> (32 - count));
|
|
3446
|
-
}
|
|
3447
|
-
// Rotate a 64b number left `count` position
|
|
3448
|
-
function rol64(num, count) {
|
|
3449
|
-
const hi = num[0], lo = num[1];
|
|
3450
|
-
const h = (hi << count) | (lo >>> (32 - count));
|
|
3451
|
-
const l = (lo << count) | (hi >>> (32 - count));
|
|
3452
|
-
return [h, l];
|
|
3453
|
-
}
|
|
3454
|
-
function bytesToWords32(bytes, endian) {
|
|
3455
|
-
const size = (bytes.length + 3) >>> 2;
|
|
3456
|
-
const words32 = [];
|
|
3457
|
-
for (let i = 0; i < size; i++) {
|
|
3458
|
-
words32[i] = wordAt(bytes, i * 4, endian);
|
|
3459
|
-
}
|
|
3460
|
-
return words32;
|
|
3461
|
-
}
|
|
3462
|
-
function byteAt(bytes, index) {
|
|
3463
|
-
return index >= bytes.length ? 0 : bytes[index];
|
|
3464
|
-
}
|
|
3465
|
-
function wordAt(bytes, index, endian) {
|
|
3466
|
-
let word = 0;
|
|
3467
|
-
if (endian === Endian.Big) {
|
|
3468
|
-
for (let i = 0; i < 4; i++) {
|
|
3469
|
-
word += byteAt(bytes, index + i) << (24 - 8 * i);
|
|
3470
|
-
}
|
|
3471
|
-
}
|
|
3472
|
-
else {
|
|
3473
|
-
for (let i = 0; i < 4; i++) {
|
|
3474
|
-
word += byteAt(bytes, index + i) << 8 * i;
|
|
3475
|
-
}
|
|
3562
|
+
visitTagPlaceholder(ph) {
|
|
3563
|
+
const children = ph.children.map(child => child.visit(this)).join('');
|
|
3564
|
+
return `{$${ph.startName}}${children}{$${ph.closeName}}`;
|
|
3476
3565
|
}
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
function words32ToByteString(words32) {
|
|
3480
|
-
return words32.reduce((bytes, word) => bytes.concat(word32ToByteString(word)), []);
|
|
3481
|
-
}
|
|
3482
|
-
function word32ToByteString(word) {
|
|
3483
|
-
let bytes = [];
|
|
3484
|
-
for (let i = 0; i < 4; i++) {
|
|
3485
|
-
bytes.push((word >>> 8 * (3 - i)) & 0xff);
|
|
3566
|
+
visitPlaceholder(ph) {
|
|
3567
|
+
return `{$${ph.name}}`;
|
|
3486
3568
|
}
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
function bytesToHexString(bytes) {
|
|
3490
|
-
let hex = '';
|
|
3491
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
3492
|
-
const b = byteAt(bytes, i);
|
|
3493
|
-
hex += (b >>> 4).toString(16) + (b & 0x0f).toString(16);
|
|
3569
|
+
visitIcuPlaceholder(ph) {
|
|
3570
|
+
return `{$${ph.name}}`;
|
|
3494
3571
|
}
|
|
3495
|
-
return hex.toLowerCase();
|
|
3496
|
-
}
|
|
3497
|
-
/**
|
|
3498
|
-
* Create a shared exponentiation pool for base-256 computations. This shared pool provides memoized
|
|
3499
|
-
* power-of-256 results with memoized power-of-two computations for efficient multiplication.
|
|
3500
|
-
*
|
|
3501
|
-
* For our purposes, this can be safely stored as a global without memory concerns. The reason is
|
|
3502
|
-
* that we encode two words, so only need the 0th (for the low word) and 4th (for the high word)
|
|
3503
|
-
* exponent.
|
|
3504
|
-
*/
|
|
3505
|
-
const base256 = new BigIntExponentiation(256);
|
|
3506
|
-
/**
|
|
3507
|
-
* Represents two 32-bit words as a single decimal number. This requires a big integer storage
|
|
3508
|
-
* model as JS numbers are not accurate enough to represent the 64-bit number.
|
|
3509
|
-
*
|
|
3510
|
-
* Based on https://www.danvk.org/hex2dec.html
|
|
3511
|
-
*/
|
|
3512
|
-
function wordsToDecimalString(hi, lo) {
|
|
3513
|
-
// Encode the four bytes in lo in the lower digits of the decimal number.
|
|
3514
|
-
// Note: the multiplication results in lo itself but represented by a big integer using its
|
|
3515
|
-
// decimal digits.
|
|
3516
|
-
const decimal = base256.toThePowerOf(0).multiplyBy(lo);
|
|
3517
|
-
// Encode the four bytes in hi above the four lo bytes. lo is a maximum of (2^8)^4, which is why
|
|
3518
|
-
// this multiplication factor is applied.
|
|
3519
|
-
base256.toThePowerOf(4).multiplyByAndAddTo(hi, decimal);
|
|
3520
|
-
return decimal.toString();
|
|
3521
3572
|
}
|
|
3522
3573
|
|
|
3523
3574
|
/**
|
|
@@ -16824,6 +16875,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
16824
16875
|
return new ParseTreeResult(result, this._errors);
|
|
16825
16876
|
}
|
|
16826
16877
|
visitElement(element) {
|
|
16878
|
+
let message = undefined;
|
|
16827
16879
|
if (hasI18nAttrs(element)) {
|
|
16828
16880
|
this.hasI18nMeta = true;
|
|
16829
16881
|
const attrs = [];
|
|
@@ -16832,11 +16884,13 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
16832
16884
|
if (attr.name === I18N_ATTR) {
|
|
16833
16885
|
// root 'i18n' node attribute
|
|
16834
16886
|
const i18n = element.i18n || attr.value;
|
|
16835
|
-
|
|
16836
|
-
|
|
16837
|
-
|
|
16838
|
-
|
|
16887
|
+
message = this._generateI18nMessage(element.children, i18n, setI18nRefs);
|
|
16888
|
+
if (message.nodes.length === 0) {
|
|
16889
|
+
// Ignore the message if it is empty.
|
|
16890
|
+
message = undefined;
|
|
16839
16891
|
}
|
|
16892
|
+
// Store the message on the element
|
|
16893
|
+
element.i18n = message;
|
|
16840
16894
|
}
|
|
16841
16895
|
else if (attr.name.startsWith(I18N_ATTR_PREFIX)) {
|
|
16842
16896
|
// 'i18n-*' attributes
|
|
@@ -16869,7 +16923,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
16869
16923
|
element.attrs = attrs;
|
|
16870
16924
|
}
|
|
16871
16925
|
}
|
|
16872
|
-
visitAll(this, element.children,
|
|
16926
|
+
visitAll(this, element.children, message);
|
|
16873
16927
|
return element;
|
|
16874
16928
|
}
|
|
16875
16929
|
visitExpansion(expansion, currentMessage) {
|
|
@@ -16884,6 +16938,10 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
16884
16938
|
message = this._generateI18nMessage([expansion], meta);
|
|
16885
16939
|
const icu = icuFromI18nMessage(message);
|
|
16886
16940
|
icu.name = name;
|
|
16941
|
+
if (currentMessage !== null) {
|
|
16942
|
+
// Also update the placeholderToMessage map with this new message
|
|
16943
|
+
currentMessage.placeholderToMessage[name] = message;
|
|
16944
|
+
}
|
|
16887
16945
|
}
|
|
16888
16946
|
else {
|
|
16889
16947
|
// ICU is a top level message, try to use metadata from container element if provided via
|
|
@@ -17049,9 +17107,9 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
17049
17107
|
return this.formatPh(ph.name);
|
|
17050
17108
|
}
|
|
17051
17109
|
}
|
|
17052
|
-
const serializerVisitor
|
|
17110
|
+
const serializerVisitor = new GetMsgSerializerVisitor();
|
|
17053
17111
|
function serializeI18nMessageForGetMsg(message) {
|
|
17054
|
-
return message.nodes.map(node => node.visit(serializerVisitor
|
|
17112
|
+
return message.nodes.map(node => node.visit(serializerVisitor, null)).join('');
|
|
17055
17113
|
}
|
|
17056
17114
|
|
|
17057
17115
|
function createLocalizeStatements(variable, message, params) {
|
|
@@ -17068,40 +17126,43 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
17068
17126
|
* The result can be used for generating the `$localize` tagged template literals.
|
|
17069
17127
|
*/
|
|
17070
17128
|
class LocalizeSerializerVisitor {
|
|
17071
|
-
|
|
17072
|
-
|
|
17129
|
+
constructor(placeholderToMessage, pieces) {
|
|
17130
|
+
this.placeholderToMessage = placeholderToMessage;
|
|
17131
|
+
this.pieces = pieces;
|
|
17132
|
+
}
|
|
17133
|
+
visitText(text) {
|
|
17134
|
+
if (this.pieces[this.pieces.length - 1] instanceof LiteralPiece) {
|
|
17073
17135
|
// Two literal pieces in a row means that there was some comment node in-between.
|
|
17074
|
-
|
|
17136
|
+
this.pieces[this.pieces.length - 1].text += text.value;
|
|
17075
17137
|
}
|
|
17076
17138
|
else {
|
|
17077
17139
|
const sourceSpan = new ParseSourceSpan(text.sourceSpan.fullStart, text.sourceSpan.end, text.sourceSpan.fullStart, text.sourceSpan.details);
|
|
17078
|
-
|
|
17140
|
+
this.pieces.push(new LiteralPiece(text.value, sourceSpan));
|
|
17079
17141
|
}
|
|
17080
17142
|
}
|
|
17081
|
-
visitContainer(container
|
|
17082
|
-
container.children.forEach(child => child.visit(this
|
|
17143
|
+
visitContainer(container) {
|
|
17144
|
+
container.children.forEach(child => child.visit(this));
|
|
17083
17145
|
}
|
|
17084
|
-
visitIcu(icu
|
|
17085
|
-
|
|
17146
|
+
visitIcu(icu) {
|
|
17147
|
+
this.pieces.push(new LiteralPiece(serializeIcuNode(icu), icu.sourceSpan));
|
|
17086
17148
|
}
|
|
17087
|
-
visitTagPlaceholder(ph
|
|
17088
|
-
|
|
17149
|
+
visitTagPlaceholder(ph) {
|
|
17150
|
+
this.pieces.push(this.createPlaceholderPiece(ph.startName, ph.startSourceSpan ?? ph.sourceSpan));
|
|
17089
17151
|
if (!ph.isVoid) {
|
|
17090
|
-
ph.children.forEach(child => child.visit(this
|
|
17091
|
-
|
|
17152
|
+
ph.children.forEach(child => child.visit(this));
|
|
17153
|
+
this.pieces.push(this.createPlaceholderPiece(ph.closeName, ph.endSourceSpan ?? ph.sourceSpan));
|
|
17092
17154
|
}
|
|
17093
17155
|
}
|
|
17094
|
-
visitPlaceholder(ph
|
|
17095
|
-
|
|
17156
|
+
visitPlaceholder(ph) {
|
|
17157
|
+
this.pieces.push(this.createPlaceholderPiece(ph.name, ph.sourceSpan));
|
|
17096
17158
|
}
|
|
17097
|
-
visitIcuPlaceholder(ph
|
|
17098
|
-
|
|
17159
|
+
visitIcuPlaceholder(ph) {
|
|
17160
|
+
this.pieces.push(this.createPlaceholderPiece(ph.name, ph.sourceSpan, this.placeholderToMessage[ph.name]));
|
|
17099
17161
|
}
|
|
17100
|
-
createPlaceholderPiece(name, sourceSpan) {
|
|
17101
|
-
return new PlaceholderPiece(formatI18nPlaceholderName(name, /* useCamelCase */ false), sourceSpan);
|
|
17162
|
+
createPlaceholderPiece(name, sourceSpan, associatedMessage) {
|
|
17163
|
+
return new PlaceholderPiece(formatI18nPlaceholderName(name, /* useCamelCase */ false), sourceSpan, associatedMessage);
|
|
17102
17164
|
}
|
|
17103
17165
|
}
|
|
17104
|
-
const serializerVisitor = new LocalizeSerializerVisitor();
|
|
17105
17166
|
/**
|
|
17106
17167
|
* Serialize an i18n message into two arrays: messageParts and placeholders.
|
|
17107
17168
|
*
|
|
@@ -17112,7 +17173,8 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
17112
17173
|
*/
|
|
17113
17174
|
function serializeI18nMessageForLocalize(message) {
|
|
17114
17175
|
const pieces = [];
|
|
17115
|
-
|
|
17176
|
+
const serializerVisitor = new LocalizeSerializerVisitor(message.placeholderToMessage, pieces);
|
|
17177
|
+
message.nodes.forEach(node => node.visit(serializerVisitor));
|
|
17116
17178
|
return processMessagePieces(pieces);
|
|
17117
17179
|
}
|
|
17118
17180
|
function getSourceSpan(message) {
|
|
@@ -20062,7 +20124,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20062
20124
|
* Use of this source code is governed by an MIT-style license that can be
|
|
20063
20125
|
* found in the LICENSE file at https://angular.io/license
|
|
20064
20126
|
*/
|
|
20065
|
-
new Version('13.0.0');
|
|
20127
|
+
new Version('13.1.0-next.0');
|
|
20066
20128
|
|
|
20067
20129
|
/**
|
|
20068
20130
|
* @license
|
|
@@ -20691,7 +20753,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20691
20753
|
function compileDeclareClassMetadata(metadata) {
|
|
20692
20754
|
const definitionMap = new DefinitionMap();
|
|
20693
20755
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
20694
|
-
definitionMap.set('version', literal$1('13.0.0'));
|
|
20756
|
+
definitionMap.set('version', literal$1('13.1.0-next.0'));
|
|
20695
20757
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
20696
20758
|
definitionMap.set('type', metadata.type);
|
|
20697
20759
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -20731,7 +20793,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20731
20793
|
function createDirectiveDefinitionMap(meta) {
|
|
20732
20794
|
const definitionMap = new DefinitionMap();
|
|
20733
20795
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
20734
|
-
definitionMap.set('version', literal$1('13.0.0'));
|
|
20796
|
+
definitionMap.set('version', literal$1('13.1.0-next.0'));
|
|
20735
20797
|
// e.g. `type: MyDirective`
|
|
20736
20798
|
definitionMap.set('type', meta.internalType);
|
|
20737
20799
|
// e.g. `selector: 'some-dir'`
|
|
@@ -20948,7 +21010,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20948
21010
|
function compileDeclareFactoryFunction(meta) {
|
|
20949
21011
|
const definitionMap = new DefinitionMap();
|
|
20950
21012
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
20951
|
-
definitionMap.set('version', literal$1('13.0.0'));
|
|
21013
|
+
definitionMap.set('version', literal$1('13.1.0-next.0'));
|
|
20952
21014
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
20953
21015
|
definitionMap.set('type', meta.internalType);
|
|
20954
21016
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -20990,7 +21052,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20990
21052
|
function createInjectableDefinitionMap(meta) {
|
|
20991
21053
|
const definitionMap = new DefinitionMap();
|
|
20992
21054
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
20993
|
-
definitionMap.set('version', literal$1('13.0.0'));
|
|
21055
|
+
definitionMap.set('version', literal$1('13.1.0-next.0'));
|
|
20994
21056
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
20995
21057
|
definitionMap.set('type', meta.internalType);
|
|
20996
21058
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -21069,7 +21131,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21069
21131
|
function createInjectorDefinitionMap(meta) {
|
|
21070
21132
|
const definitionMap = new DefinitionMap();
|
|
21071
21133
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
21072
|
-
definitionMap.set('version', literal$1('13.0.0'));
|
|
21134
|
+
definitionMap.set('version', literal$1('13.1.0-next.0'));
|
|
21073
21135
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
21074
21136
|
definitionMap.set('type', meta.internalType);
|
|
21075
21137
|
definitionMap.set('providers', meta.providers);
|
|
@@ -21106,7 +21168,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21106
21168
|
function createNgModuleDefinitionMap(meta) {
|
|
21107
21169
|
const definitionMap = new DefinitionMap();
|
|
21108
21170
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
21109
|
-
definitionMap.set('version', literal$1('13.0.0'));
|
|
21171
|
+
definitionMap.set('version', literal$1('13.1.0-next.0'));
|
|
21110
21172
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
21111
21173
|
definitionMap.set('type', meta.internalType);
|
|
21112
21174
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -21164,7 +21226,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21164
21226
|
function createPipeDefinitionMap(meta) {
|
|
21165
21227
|
const definitionMap = new DefinitionMap();
|
|
21166
21228
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
21167
|
-
definitionMap.set('version', literal$1('13.0.0'));
|
|
21229
|
+
definitionMap.set('version', literal$1('13.1.0-next.0'));
|
|
21168
21230
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
21169
21231
|
// e.g. `type: MyPipe`
|
|
21170
21232
|
definitionMap.set('type', meta.internalType);
|
|
@@ -21196,7 +21258,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21196
21258
|
* Use of this source code is governed by an MIT-style license that can be
|
|
21197
21259
|
* found in the LICENSE file at https://angular.io/license
|
|
21198
21260
|
*/
|
|
21199
|
-
new Version('13.0.0');
|
|
21261
|
+
new Version('13.1.0-next.0');
|
|
21200
21262
|
|
|
21201
21263
|
/**
|
|
21202
21264
|
* @license
|
|
@@ -45097,6 +45159,7 @@ https://angular.io/guide/ivy for more information.
|
|
|
45097
45159
|
// regardless of its value in tsconfig.json.
|
|
45098
45160
|
if (config.forceStrictTemplates === true) {
|
|
45099
45161
|
options.strictTemplates = true;
|
|
45162
|
+
options._extendedTemplateDiagnostics = true;
|
|
45100
45163
|
}
|
|
45101
45164
|
return options;
|
|
45102
45165
|
}
|