@angular/language-service 13.0.1 → 13.1.0-next.2
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.
|
|
2
|
+
* @license Angular v13.1.0-next.2
|
|
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.
|
|
@@ -3923,6 +4439,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
3923
4439
|
this.id = this.customId;
|
|
3924
4440
|
/** The ids to use if there are no custom id and if `i18nLegacyMessageIdFormat` is not empty */
|
|
3925
4441
|
this.legacyIds = [];
|
|
4442
|
+
this.messageString = serializeMessage(this.nodes);
|
|
3926
4443
|
if (nodes.length) {
|
|
3927
4444
|
this.sources = [{
|
|
3928
4445
|
filePath: nodes[0].sourceSpan.start.file.url,
|
|
@@ -4005,501 +4522,35 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
4005
4522
|
return visitor.visitIcuPlaceholder(this, context);
|
|
4006
4523
|
}
|
|
4007
4524
|
}
|
|
4008
|
-
|
|
4009
|
-
/**
|
|
4010
|
-
* @license
|
|
4011
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4012
|
-
*
|
|
4013
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
4014
|
-
* found in the LICENSE file at https://angular.io/license
|
|
4015
|
-
*/
|
|
4016
4525
|
/**
|
|
4017
|
-
*
|
|
4018
|
-
* digit stored at the beginning of the array (little endian).
|
|
4019
|
-
*
|
|
4020
|
-
* For performance reasons, each instance is mutable. The addition operation can be done in-place
|
|
4021
|
-
* to reduce memory pressure of allocation for the digits array.
|
|
4526
|
+
* Serialize the message to the Localize backtick string format that would appear in compiled code.
|
|
4022
4527
|
*/
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
constructor(digits) {
|
|
4028
|
-
this.digits = digits;
|
|
4029
|
-
}
|
|
4030
|
-
static zero() {
|
|
4031
|
-
return new BigInteger([0]);
|
|
4032
|
-
}
|
|
4033
|
-
static one() {
|
|
4034
|
-
return new BigInteger([1]);
|
|
4035
|
-
}
|
|
4036
|
-
/**
|
|
4037
|
-
* Creates a clone of this instance.
|
|
4038
|
-
*/
|
|
4039
|
-
clone() {
|
|
4040
|
-
return new BigInteger(this.digits.slice());
|
|
4041
|
-
}
|
|
4042
|
-
/**
|
|
4043
|
-
* Returns a new big integer with the sum of `this` and `other` as its value. This does not mutate
|
|
4044
|
-
* `this` but instead returns a new instance, unlike `addToSelf`.
|
|
4045
|
-
*/
|
|
4046
|
-
add(other) {
|
|
4047
|
-
const result = this.clone();
|
|
4048
|
-
result.addToSelf(other);
|
|
4049
|
-
return result;
|
|
4050
|
-
}
|
|
4051
|
-
/**
|
|
4052
|
-
* Adds `other` to the instance itself, thereby mutating its value.
|
|
4053
|
-
*/
|
|
4054
|
-
addToSelf(other) {
|
|
4055
|
-
const maxNrOfDigits = Math.max(this.digits.length, other.digits.length);
|
|
4056
|
-
let carry = 0;
|
|
4057
|
-
for (let i = 0; i < maxNrOfDigits; i++) {
|
|
4058
|
-
let digitSum = carry;
|
|
4059
|
-
if (i < this.digits.length) {
|
|
4060
|
-
digitSum += this.digits[i];
|
|
4061
|
-
}
|
|
4062
|
-
if (i < other.digits.length) {
|
|
4063
|
-
digitSum += other.digits[i];
|
|
4064
|
-
}
|
|
4065
|
-
if (digitSum >= 10) {
|
|
4066
|
-
this.digits[i] = digitSum - 10;
|
|
4067
|
-
carry = 1;
|
|
4068
|
-
}
|
|
4069
|
-
else {
|
|
4070
|
-
this.digits[i] = digitSum;
|
|
4071
|
-
carry = 0;
|
|
4072
|
-
}
|
|
4073
|
-
}
|
|
4074
|
-
// Apply a remaining carry if needed.
|
|
4075
|
-
if (carry > 0) {
|
|
4076
|
-
this.digits[maxNrOfDigits] = 1;
|
|
4077
|
-
}
|
|
4078
|
-
}
|
|
4079
|
-
/**
|
|
4080
|
-
* Builds the decimal string representation of the big integer. As this is stored in
|
|
4081
|
-
* little endian, the digits are concatenated in reverse order.
|
|
4082
|
-
*/
|
|
4083
|
-
toString() {
|
|
4084
|
-
let res = '';
|
|
4085
|
-
for (let i = this.digits.length - 1; i >= 0; i--) {
|
|
4086
|
-
res += this.digits[i];
|
|
4087
|
-
}
|
|
4088
|
-
return res;
|
|
4089
|
-
}
|
|
4528
|
+
function serializeMessage(messageNodes) {
|
|
4529
|
+
const visitor = new LocalizeMessageStringVisitor();
|
|
4530
|
+
const str = messageNodes.map(n => n.visit(visitor)).join('');
|
|
4531
|
+
return str;
|
|
4090
4532
|
}
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
* are memoized. See `multiplyBy()` for details on the multiplication algorithm.
|
|
4094
|
-
*/
|
|
4095
|
-
class BigIntForMultiplication {
|
|
4096
|
-
constructor(value) {
|
|
4097
|
-
this.powerOfTwos = [value];
|
|
4098
|
-
}
|
|
4099
|
-
/**
|
|
4100
|
-
* Returns the big integer itself.
|
|
4101
|
-
*/
|
|
4102
|
-
getValue() {
|
|
4103
|
-
return this.powerOfTwos[0];
|
|
4104
|
-
}
|
|
4105
|
-
/**
|
|
4106
|
-
* Computes the value for `num * b`, where `num` is a JS number and `b` is a big integer. The
|
|
4107
|
-
* value for `b` is represented by a storage model that is optimized for this computation.
|
|
4108
|
-
*
|
|
4109
|
-
* This operation is implemented in N(log2(num)) by continuous halving of the number, where the
|
|
4110
|
-
* least-significant bit (LSB) is tested in each iteration. If the bit is set, the bit's index is
|
|
4111
|
-
* used as exponent into the power-of-two multiplication of `b`.
|
|
4112
|
-
*
|
|
4113
|
-
* As an example, consider the multiplication num=42, b=1337. In binary 42 is 0b00101010 and the
|
|
4114
|
-
* algorithm unrolls into the following iterations:
|
|
4115
|
-
*
|
|
4116
|
-
* Iteration | num | LSB | b * 2^iter | Add? | product
|
|
4117
|
-
* -----------|------------|------|------------|------|--------
|
|
4118
|
-
* 0 | 0b00101010 | 0 | 1337 | No | 0
|
|
4119
|
-
* 1 | 0b00010101 | 1 | 2674 | Yes | 2674
|
|
4120
|
-
* 2 | 0b00001010 | 0 | 5348 | No | 2674
|
|
4121
|
-
* 3 | 0b00000101 | 1 | 10696 | Yes | 13370
|
|
4122
|
-
* 4 | 0b00000010 | 0 | 21392 | No | 13370
|
|
4123
|
-
* 5 | 0b00000001 | 1 | 42784 | Yes | 56154
|
|
4124
|
-
* 6 | 0b00000000 | 0 | 85568 | No | 56154
|
|
4125
|
-
*
|
|
4126
|
-
* The computed product of 56154 is indeed the correct result.
|
|
4127
|
-
*
|
|
4128
|
-
* The `BigIntForMultiplication` representation for a big integer provides memoized access to the
|
|
4129
|
-
* power-of-two values to reduce the workload in computing those values.
|
|
4130
|
-
*/
|
|
4131
|
-
multiplyBy(num) {
|
|
4132
|
-
const product = BigInteger.zero();
|
|
4133
|
-
this.multiplyByAndAddTo(num, product);
|
|
4134
|
-
return product;
|
|
4135
|
-
}
|
|
4136
|
-
/**
|
|
4137
|
-
* See `multiplyBy()` for details. This function allows for the computed product to be added
|
|
4138
|
-
* directly to the provided result big integer.
|
|
4139
|
-
*/
|
|
4140
|
-
multiplyByAndAddTo(num, result) {
|
|
4141
|
-
for (let exponent = 0; num !== 0; num = num >>> 1, exponent++) {
|
|
4142
|
-
if (num & 1) {
|
|
4143
|
-
const value = this.getMultipliedByPowerOfTwo(exponent);
|
|
4144
|
-
result.addToSelf(value);
|
|
4145
|
-
}
|
|
4146
|
-
}
|
|
4147
|
-
}
|
|
4148
|
-
/**
|
|
4149
|
-
* Computes and memoizes the big integer value for `this.number * 2^exponent`.
|
|
4150
|
-
*/
|
|
4151
|
-
getMultipliedByPowerOfTwo(exponent) {
|
|
4152
|
-
// Compute the powers up until the requested exponent, where each value is computed from its
|
|
4153
|
-
// predecessor. This is simple as `this.number * 2^(exponent - 1)` only has to be doubled (i.e.
|
|
4154
|
-
// added to itself) to reach `this.number * 2^exponent`.
|
|
4155
|
-
for (let i = this.powerOfTwos.length; i <= exponent; i++) {
|
|
4156
|
-
const previousPower = this.powerOfTwos[i - 1];
|
|
4157
|
-
this.powerOfTwos[i] = previousPower.add(previousPower);
|
|
4158
|
-
}
|
|
4159
|
-
return this.powerOfTwos[exponent];
|
|
4160
|
-
}
|
|
4161
|
-
}
|
|
4162
|
-
/**
|
|
4163
|
-
* Represents an exponentiation operation for the provided base, of which exponents are computed and
|
|
4164
|
-
* memoized. The results are represented by a `BigIntForMultiplication` which is tailored for
|
|
4165
|
-
* multiplication operations by memoizing the power-of-twos. This effectively results in a matrix
|
|
4166
|
-
* representation that is lazily computed upon request.
|
|
4167
|
-
*/
|
|
4168
|
-
class BigIntExponentiation {
|
|
4169
|
-
constructor(base) {
|
|
4170
|
-
this.base = base;
|
|
4171
|
-
this.exponents = [new BigIntForMultiplication(BigInteger.one())];
|
|
4172
|
-
}
|
|
4173
|
-
/**
|
|
4174
|
-
* Compute the value for `this.base^exponent`, resulting in a big integer that is optimized for
|
|
4175
|
-
* further multiplication operations.
|
|
4176
|
-
*/
|
|
4177
|
-
toThePowerOf(exponent) {
|
|
4178
|
-
// Compute the results up until the requested exponent, where every value is computed from its
|
|
4179
|
-
// predecessor. This is because `this.base^(exponent - 1)` only has to be multiplied by `base`
|
|
4180
|
-
// to reach `this.base^exponent`.
|
|
4181
|
-
for (let i = this.exponents.length; i <= exponent; i++) {
|
|
4182
|
-
const value = this.exponents[i - 1].multiplyBy(this.base);
|
|
4183
|
-
this.exponents[i] = new BigIntForMultiplication(value);
|
|
4184
|
-
}
|
|
4185
|
-
return this.exponents[exponent];
|
|
4186
|
-
}
|
|
4187
|
-
}
|
|
4188
|
-
|
|
4189
|
-
/**
|
|
4190
|
-
* @license
|
|
4191
|
-
* Copyright Google LLC All Rights Reserved.
|
|
4192
|
-
*
|
|
4193
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
4194
|
-
* found in the LICENSE file at https://angular.io/license
|
|
4195
|
-
*/
|
|
4196
|
-
/**
|
|
4197
|
-
* Compute the message id using the XLIFF1 digest.
|
|
4198
|
-
*/
|
|
4199
|
-
function computeDigest(message) {
|
|
4200
|
-
return sha1(serializeNodes(message.nodes).join('') + `[${message.meaning}]`);
|
|
4201
|
-
}
|
|
4202
|
-
/**
|
|
4203
|
-
* Return the message id or compute it using the XLIFF2/XMB/$localize digest.
|
|
4204
|
-
*/
|
|
4205
|
-
function decimalDigest(message) {
|
|
4206
|
-
return message.id || computeDecimalDigest(message);
|
|
4207
|
-
}
|
|
4208
|
-
/**
|
|
4209
|
-
* Compute the message id using the XLIFF2/XMB/$localize digest.
|
|
4210
|
-
*/
|
|
4211
|
-
function computeDecimalDigest(message) {
|
|
4212
|
-
const visitor = new _SerializerIgnoreIcuExpVisitor();
|
|
4213
|
-
const parts = message.nodes.map(a => a.visit(visitor, null));
|
|
4214
|
-
return computeMsgId(parts.join(''), message.meaning);
|
|
4215
|
-
}
|
|
4216
|
-
/**
|
|
4217
|
-
* Serialize the i18n ast to something xml-like in order to generate an UID.
|
|
4218
|
-
*
|
|
4219
|
-
* The visitor is also used in the i18n parser tests
|
|
4220
|
-
*
|
|
4221
|
-
* @internal
|
|
4222
|
-
*/
|
|
4223
|
-
class _SerializerVisitor {
|
|
4224
|
-
visitText(text, context) {
|
|
4533
|
+
class LocalizeMessageStringVisitor {
|
|
4534
|
+
visitText(text) {
|
|
4225
4535
|
return text.value;
|
|
4226
4536
|
}
|
|
4227
|
-
visitContainer(container
|
|
4228
|
-
return
|
|
4537
|
+
visitContainer(container) {
|
|
4538
|
+
return container.children.map(child => child.visit(this)).join('');
|
|
4229
4539
|
}
|
|
4230
|
-
visitIcu(icu
|
|
4540
|
+
visitIcu(icu) {
|
|
4231
4541
|
const strCases = Object.keys(icu.cases).map((k) => `${k} {${icu.cases[k].visit(this)}}`);
|
|
4232
|
-
return `{${icu.
|
|
4233
|
-
}
|
|
4234
|
-
visitTagPlaceholder(ph, context) {
|
|
4235
|
-
return ph.isVoid ?
|
|
4236
|
-
`<ph tag name="${ph.startName}"/>` :
|
|
4237
|
-
`<ph tag name="${ph.startName}">${ph.children.map(child => child.visit(this)).join(', ')}</ph name="${ph.closeName}">`;
|
|
4238
|
-
}
|
|
4239
|
-
visitPlaceholder(ph, context) {
|
|
4240
|
-
return ph.value ? `<ph name="${ph.name}">${ph.value}</ph>` : `<ph name="${ph.name}"/>`;
|
|
4241
|
-
}
|
|
4242
|
-
visitIcuPlaceholder(ph, context) {
|
|
4243
|
-
return `<ph icu name="${ph.name}">${ph.value.visit(this)}</ph>`;
|
|
4244
|
-
}
|
|
4245
|
-
}
|
|
4246
|
-
const serializerVisitor$2 = new _SerializerVisitor();
|
|
4247
|
-
function serializeNodes(nodes) {
|
|
4248
|
-
return nodes.map(a => a.visit(serializerVisitor$2, null));
|
|
4249
|
-
}
|
|
4250
|
-
/**
|
|
4251
|
-
* Serialize the i18n ast to something xml-like in order to generate an UID.
|
|
4252
|
-
*
|
|
4253
|
-
* Ignore the ICU expressions so that message IDs stays identical if only the expression changes.
|
|
4254
|
-
*
|
|
4255
|
-
* @internal
|
|
4256
|
-
*/
|
|
4257
|
-
class _SerializerIgnoreIcuExpVisitor extends _SerializerVisitor {
|
|
4258
|
-
visitIcu(icu, context) {
|
|
4259
|
-
let strCases = Object.keys(icu.cases).map((k) => `${k} {${icu.cases[k].visit(this)}}`);
|
|
4260
|
-
// Do not take the expression into account
|
|
4261
|
-
return `{${icu.type}, ${strCases.join(', ')}}`;
|
|
4262
|
-
}
|
|
4263
|
-
}
|
|
4264
|
-
/**
|
|
4265
|
-
* Compute the SHA1 of the given string
|
|
4266
|
-
*
|
|
4267
|
-
* see https://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
|
|
4268
|
-
*
|
|
4269
|
-
* WARNING: this function has not been designed not tested with security in mind.
|
|
4270
|
-
* DO NOT USE IT IN A SECURITY SENSITIVE CONTEXT.
|
|
4271
|
-
*/
|
|
4272
|
-
function sha1(str) {
|
|
4273
|
-
const utf8 = utf8Encode(str);
|
|
4274
|
-
const words32 = bytesToWords32(utf8, Endian.Big);
|
|
4275
|
-
const len = utf8.length * 8;
|
|
4276
|
-
const w = newArray(80);
|
|
4277
|
-
let a = 0x67452301, b = 0xefcdab89, c = 0x98badcfe, d = 0x10325476, e = 0xc3d2e1f0;
|
|
4278
|
-
words32[len >> 5] |= 0x80 << (24 - len % 32);
|
|
4279
|
-
words32[((len + 64 >> 9) << 4) + 15] = len;
|
|
4280
|
-
for (let i = 0; i < words32.length; i += 16) {
|
|
4281
|
-
const h0 = a, h1 = b, h2 = c, h3 = d, h4 = e;
|
|
4282
|
-
for (let j = 0; j < 80; j++) {
|
|
4283
|
-
if (j < 16) {
|
|
4284
|
-
w[j] = words32[i + j];
|
|
4285
|
-
}
|
|
4286
|
-
else {
|
|
4287
|
-
w[j] = rol32(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1);
|
|
4288
|
-
}
|
|
4289
|
-
const fkVal = fk(j, b, c, d);
|
|
4290
|
-
const f = fkVal[0];
|
|
4291
|
-
const k = fkVal[1];
|
|
4292
|
-
const temp = [rol32(a, 5), f, e, k, w[j]].reduce(add32);
|
|
4293
|
-
e = d;
|
|
4294
|
-
d = c;
|
|
4295
|
-
c = rol32(b, 30);
|
|
4296
|
-
b = a;
|
|
4297
|
-
a = temp;
|
|
4298
|
-
}
|
|
4299
|
-
a = add32(a, h0);
|
|
4300
|
-
b = add32(b, h1);
|
|
4301
|
-
c = add32(c, h2);
|
|
4302
|
-
d = add32(d, h3);
|
|
4303
|
-
e = add32(e, h4);
|
|
4304
|
-
}
|
|
4305
|
-
return bytesToHexString(words32ToByteString([a, b, c, d, e]));
|
|
4306
|
-
}
|
|
4307
|
-
function fk(index, b, c, d) {
|
|
4308
|
-
if (index < 20) {
|
|
4309
|
-
return [(b & c) | (~b & d), 0x5a827999];
|
|
4310
|
-
}
|
|
4311
|
-
if (index < 40) {
|
|
4312
|
-
return [b ^ c ^ d, 0x6ed9eba1];
|
|
4313
|
-
}
|
|
4314
|
-
if (index < 60) {
|
|
4315
|
-
return [(b & c) | (b & d) | (c & d), 0x8f1bbcdc];
|
|
4316
|
-
}
|
|
4317
|
-
return [b ^ c ^ d, 0xca62c1d6];
|
|
4318
|
-
}
|
|
4319
|
-
/**
|
|
4320
|
-
* Compute the fingerprint of the given string
|
|
4321
|
-
*
|
|
4322
|
-
* The output is 64 bit number encoded as a decimal string
|
|
4323
|
-
*
|
|
4324
|
-
* based on:
|
|
4325
|
-
* https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/GoogleJsMessageIdGenerator.java
|
|
4326
|
-
*/
|
|
4327
|
-
function fingerprint(str) {
|
|
4328
|
-
const utf8 = utf8Encode(str);
|
|
4329
|
-
let hi = hash32(utf8, 0);
|
|
4330
|
-
let lo = hash32(utf8, 102072);
|
|
4331
|
-
if (hi == 0 && (lo == 0 || lo == 1)) {
|
|
4332
|
-
hi = hi ^ 0x130f9bef;
|
|
4333
|
-
lo = lo ^ -0x6b5f56d8;
|
|
4334
|
-
}
|
|
4335
|
-
return [hi, lo];
|
|
4336
|
-
}
|
|
4337
|
-
function computeMsgId(msg, meaning = '') {
|
|
4338
|
-
let msgFingerprint = fingerprint(msg);
|
|
4339
|
-
if (meaning) {
|
|
4340
|
-
const meaningFingerprint = fingerprint(meaning);
|
|
4341
|
-
msgFingerprint = add64(rol64(msgFingerprint, 1), meaningFingerprint);
|
|
4342
|
-
}
|
|
4343
|
-
const hi = msgFingerprint[0];
|
|
4344
|
-
const lo = msgFingerprint[1];
|
|
4345
|
-
return wordsToDecimalString(hi & 0x7fffffff, lo);
|
|
4346
|
-
}
|
|
4347
|
-
function hash32(bytes, c) {
|
|
4348
|
-
let a = 0x9e3779b9, b = 0x9e3779b9;
|
|
4349
|
-
let i;
|
|
4350
|
-
const len = bytes.length;
|
|
4351
|
-
for (i = 0; i + 12 <= len; i += 12) {
|
|
4352
|
-
a = add32(a, wordAt(bytes, i, Endian.Little));
|
|
4353
|
-
b = add32(b, wordAt(bytes, i + 4, Endian.Little));
|
|
4354
|
-
c = add32(c, wordAt(bytes, i + 8, Endian.Little));
|
|
4355
|
-
const res = mix(a, b, c);
|
|
4356
|
-
a = res[0], b = res[1], c = res[2];
|
|
4542
|
+
return `{${icu.expressionPlaceholder}, ${icu.type}, ${strCases.join(' ')}}`;
|
|
4357
4543
|
}
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
c = add32(c, len);
|
|
4362
|
-
c = add32(c, wordAt(bytes, i + 8, Endian.Little) << 8);
|
|
4363
|
-
return mix(a, b, c)[2];
|
|
4364
|
-
}
|
|
4365
|
-
// clang-format off
|
|
4366
|
-
function mix(a, b, c) {
|
|
4367
|
-
a = sub32(a, b);
|
|
4368
|
-
a = sub32(a, c);
|
|
4369
|
-
a ^= c >>> 13;
|
|
4370
|
-
b = sub32(b, c);
|
|
4371
|
-
b = sub32(b, a);
|
|
4372
|
-
b ^= a << 8;
|
|
4373
|
-
c = sub32(c, a);
|
|
4374
|
-
c = sub32(c, b);
|
|
4375
|
-
c ^= b >>> 13;
|
|
4376
|
-
a = sub32(a, b);
|
|
4377
|
-
a = sub32(a, c);
|
|
4378
|
-
a ^= c >>> 12;
|
|
4379
|
-
b = sub32(b, c);
|
|
4380
|
-
b = sub32(b, a);
|
|
4381
|
-
b ^= a << 16;
|
|
4382
|
-
c = sub32(c, a);
|
|
4383
|
-
c = sub32(c, b);
|
|
4384
|
-
c ^= b >>> 5;
|
|
4385
|
-
a = sub32(a, b);
|
|
4386
|
-
a = sub32(a, c);
|
|
4387
|
-
a ^= c >>> 3;
|
|
4388
|
-
b = sub32(b, c);
|
|
4389
|
-
b = sub32(b, a);
|
|
4390
|
-
b ^= a << 10;
|
|
4391
|
-
c = sub32(c, a);
|
|
4392
|
-
c = sub32(c, b);
|
|
4393
|
-
c ^= b >>> 15;
|
|
4394
|
-
return [a, b, c];
|
|
4395
|
-
}
|
|
4396
|
-
// clang-format on
|
|
4397
|
-
// Utils
|
|
4398
|
-
var Endian;
|
|
4399
|
-
(function (Endian) {
|
|
4400
|
-
Endian[Endian["Little"] = 0] = "Little";
|
|
4401
|
-
Endian[Endian["Big"] = 1] = "Big";
|
|
4402
|
-
})(Endian || (Endian = {}));
|
|
4403
|
-
function add32(a, b) {
|
|
4404
|
-
return add32to64(a, b)[1];
|
|
4405
|
-
}
|
|
4406
|
-
function add32to64(a, b) {
|
|
4407
|
-
const low = (a & 0xffff) + (b & 0xffff);
|
|
4408
|
-
const high = (a >>> 16) + (b >>> 16) + (low >>> 16);
|
|
4409
|
-
return [high >>> 16, (high << 16) | (low & 0xffff)];
|
|
4410
|
-
}
|
|
4411
|
-
function add64(a, b) {
|
|
4412
|
-
const ah = a[0], al = a[1];
|
|
4413
|
-
const bh = b[0], bl = b[1];
|
|
4414
|
-
const result = add32to64(al, bl);
|
|
4415
|
-
const carry = result[0];
|
|
4416
|
-
const l = result[1];
|
|
4417
|
-
const h = add32(add32(ah, bh), carry);
|
|
4418
|
-
return [h, l];
|
|
4419
|
-
}
|
|
4420
|
-
function sub32(a, b) {
|
|
4421
|
-
const low = (a & 0xffff) - (b & 0xffff);
|
|
4422
|
-
const high = (a >> 16) - (b >> 16) + (low >> 16);
|
|
4423
|
-
return (high << 16) | (low & 0xffff);
|
|
4424
|
-
}
|
|
4425
|
-
// Rotate a 32b number left `count` position
|
|
4426
|
-
function rol32(a, count) {
|
|
4427
|
-
return (a << count) | (a >>> (32 - count));
|
|
4428
|
-
}
|
|
4429
|
-
// Rotate a 64b number left `count` position
|
|
4430
|
-
function rol64(num, count) {
|
|
4431
|
-
const hi = num[0], lo = num[1];
|
|
4432
|
-
const h = (hi << count) | (lo >>> (32 - count));
|
|
4433
|
-
const l = (lo << count) | (hi >>> (32 - count));
|
|
4434
|
-
return [h, l];
|
|
4435
|
-
}
|
|
4436
|
-
function bytesToWords32(bytes, endian) {
|
|
4437
|
-
const size = (bytes.length + 3) >>> 2;
|
|
4438
|
-
const words32 = [];
|
|
4439
|
-
for (let i = 0; i < size; i++) {
|
|
4440
|
-
words32[i] = wordAt(bytes, i * 4, endian);
|
|
4441
|
-
}
|
|
4442
|
-
return words32;
|
|
4443
|
-
}
|
|
4444
|
-
function byteAt(bytes, index) {
|
|
4445
|
-
return index >= bytes.length ? 0 : bytes[index];
|
|
4446
|
-
}
|
|
4447
|
-
function wordAt(bytes, index, endian) {
|
|
4448
|
-
let word = 0;
|
|
4449
|
-
if (endian === Endian.Big) {
|
|
4450
|
-
for (let i = 0; i < 4; i++) {
|
|
4451
|
-
word += byteAt(bytes, index + i) << (24 - 8 * i);
|
|
4452
|
-
}
|
|
4453
|
-
}
|
|
4454
|
-
else {
|
|
4455
|
-
for (let i = 0; i < 4; i++) {
|
|
4456
|
-
word += byteAt(bytes, index + i) << 8 * i;
|
|
4457
|
-
}
|
|
4544
|
+
visitTagPlaceholder(ph) {
|
|
4545
|
+
const children = ph.children.map(child => child.visit(this)).join('');
|
|
4546
|
+
return `{$${ph.startName}}${children}{$${ph.closeName}}`;
|
|
4458
4547
|
}
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
function words32ToByteString(words32) {
|
|
4462
|
-
return words32.reduce((bytes, word) => bytes.concat(word32ToByteString(word)), []);
|
|
4463
|
-
}
|
|
4464
|
-
function word32ToByteString(word) {
|
|
4465
|
-
let bytes = [];
|
|
4466
|
-
for (let i = 0; i < 4; i++) {
|
|
4467
|
-
bytes.push((word >>> 8 * (3 - i)) & 0xff);
|
|
4548
|
+
visitPlaceholder(ph) {
|
|
4549
|
+
return `{$${ph.name}}`;
|
|
4468
4550
|
}
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
function bytesToHexString(bytes) {
|
|
4472
|
-
let hex = '';
|
|
4473
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
4474
|
-
const b = byteAt(bytes, i);
|
|
4475
|
-
hex += (b >>> 4).toString(16) + (b & 0x0f).toString(16);
|
|
4551
|
+
visitIcuPlaceholder(ph) {
|
|
4552
|
+
return `{$${ph.name}}`;
|
|
4476
4553
|
}
|
|
4477
|
-
return hex.toLowerCase();
|
|
4478
|
-
}
|
|
4479
|
-
/**
|
|
4480
|
-
* Create a shared exponentiation pool for base-256 computations. This shared pool provides memoized
|
|
4481
|
-
* power-of-256 results with memoized power-of-two computations for efficient multiplication.
|
|
4482
|
-
*
|
|
4483
|
-
* For our purposes, this can be safely stored as a global without memory concerns. The reason is
|
|
4484
|
-
* that we encode two words, so only need the 0th (for the low word) and 4th (for the high word)
|
|
4485
|
-
* exponent.
|
|
4486
|
-
*/
|
|
4487
|
-
const base256 = new BigIntExponentiation(256);
|
|
4488
|
-
/**
|
|
4489
|
-
* Represents two 32-bit words as a single decimal number. This requires a big integer storage
|
|
4490
|
-
* model as JS numbers are not accurate enough to represent the 64-bit number.
|
|
4491
|
-
*
|
|
4492
|
-
* Based on https://www.danvk.org/hex2dec.html
|
|
4493
|
-
*/
|
|
4494
|
-
function wordsToDecimalString(hi, lo) {
|
|
4495
|
-
// Encode the four bytes in lo in the lower digits of the decimal number.
|
|
4496
|
-
// Note: the multiplication results in lo itself but represented by a big integer using its
|
|
4497
|
-
// decimal digits.
|
|
4498
|
-
const decimal = base256.toThePowerOf(0).multiplyBy(lo);
|
|
4499
|
-
// Encode the four bytes in hi above the four lo bytes. lo is a maximum of (2^8)^4, which is why
|
|
4500
|
-
// this multiplication factor is applied.
|
|
4501
|
-
base256.toThePowerOf(4).multiplyByAndAddTo(hi, decimal);
|
|
4502
|
-
return decimal.toString();
|
|
4503
4554
|
}
|
|
4504
4555
|
|
|
4505
4556
|
/**
|
|
@@ -16773,6 +16824,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
16773
16824
|
return new ParseTreeResult(result, this._errors);
|
|
16774
16825
|
}
|
|
16775
16826
|
visitElement(element) {
|
|
16827
|
+
let message = undefined;
|
|
16776
16828
|
if (hasI18nAttrs(element)) {
|
|
16777
16829
|
this.hasI18nMeta = true;
|
|
16778
16830
|
const attrs = [];
|
|
@@ -16781,11 +16833,13 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
16781
16833
|
if (attr.name === I18N_ATTR) {
|
|
16782
16834
|
// root 'i18n' node attribute
|
|
16783
16835
|
const i18n = element.i18n || attr.value;
|
|
16784
|
-
|
|
16785
|
-
|
|
16786
|
-
|
|
16787
|
-
|
|
16836
|
+
message = this._generateI18nMessage(element.children, i18n, setI18nRefs);
|
|
16837
|
+
if (message.nodes.length === 0) {
|
|
16838
|
+
// Ignore the message if it is empty.
|
|
16839
|
+
message = undefined;
|
|
16788
16840
|
}
|
|
16841
|
+
// Store the message on the element
|
|
16842
|
+
element.i18n = message;
|
|
16789
16843
|
}
|
|
16790
16844
|
else if (attr.name.startsWith(I18N_ATTR_PREFIX)) {
|
|
16791
16845
|
// 'i18n-*' attributes
|
|
@@ -16818,7 +16872,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
16818
16872
|
element.attrs = attrs;
|
|
16819
16873
|
}
|
|
16820
16874
|
}
|
|
16821
|
-
visitAll(this, element.children,
|
|
16875
|
+
visitAll(this, element.children, message);
|
|
16822
16876
|
return element;
|
|
16823
16877
|
}
|
|
16824
16878
|
visitExpansion(expansion, currentMessage) {
|
|
@@ -16833,6 +16887,10 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
16833
16887
|
message = this._generateI18nMessage([expansion], meta);
|
|
16834
16888
|
const icu = icuFromI18nMessage(message);
|
|
16835
16889
|
icu.name = name;
|
|
16890
|
+
if (currentMessage !== null) {
|
|
16891
|
+
// Also update the placeholderToMessage map with this new message
|
|
16892
|
+
currentMessage.placeholderToMessage[name] = message;
|
|
16893
|
+
}
|
|
16836
16894
|
}
|
|
16837
16895
|
else {
|
|
16838
16896
|
// ICU is a top level message, try to use metadata from container element if provided via
|
|
@@ -16998,9 +17056,9 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
16998
17056
|
return this.formatPh(ph.name);
|
|
16999
17057
|
}
|
|
17000
17058
|
}
|
|
17001
|
-
const serializerVisitor
|
|
17059
|
+
const serializerVisitor = new GetMsgSerializerVisitor();
|
|
17002
17060
|
function serializeI18nMessageForGetMsg(message) {
|
|
17003
|
-
return message.nodes.map(node => node.visit(serializerVisitor
|
|
17061
|
+
return message.nodes.map(node => node.visit(serializerVisitor, null)).join('');
|
|
17004
17062
|
}
|
|
17005
17063
|
|
|
17006
17064
|
function createLocalizeStatements(variable, message, params) {
|
|
@@ -17017,40 +17075,43 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
17017
17075
|
* The result can be used for generating the `$localize` tagged template literals.
|
|
17018
17076
|
*/
|
|
17019
17077
|
class LocalizeSerializerVisitor {
|
|
17020
|
-
|
|
17021
|
-
|
|
17078
|
+
constructor(placeholderToMessage, pieces) {
|
|
17079
|
+
this.placeholderToMessage = placeholderToMessage;
|
|
17080
|
+
this.pieces = pieces;
|
|
17081
|
+
}
|
|
17082
|
+
visitText(text) {
|
|
17083
|
+
if (this.pieces[this.pieces.length - 1] instanceof LiteralPiece) {
|
|
17022
17084
|
// Two literal pieces in a row means that there was some comment node in-between.
|
|
17023
|
-
|
|
17085
|
+
this.pieces[this.pieces.length - 1].text += text.value;
|
|
17024
17086
|
}
|
|
17025
17087
|
else {
|
|
17026
17088
|
const sourceSpan = new ParseSourceSpan(text.sourceSpan.fullStart, text.sourceSpan.end, text.sourceSpan.fullStart, text.sourceSpan.details);
|
|
17027
|
-
|
|
17089
|
+
this.pieces.push(new LiteralPiece(text.value, sourceSpan));
|
|
17028
17090
|
}
|
|
17029
17091
|
}
|
|
17030
|
-
visitContainer(container
|
|
17031
|
-
container.children.forEach(child => child.visit(this
|
|
17092
|
+
visitContainer(container) {
|
|
17093
|
+
container.children.forEach(child => child.visit(this));
|
|
17032
17094
|
}
|
|
17033
|
-
visitIcu(icu
|
|
17034
|
-
|
|
17095
|
+
visitIcu(icu) {
|
|
17096
|
+
this.pieces.push(new LiteralPiece(serializeIcuNode(icu), icu.sourceSpan));
|
|
17035
17097
|
}
|
|
17036
|
-
visitTagPlaceholder(ph
|
|
17037
|
-
|
|
17098
|
+
visitTagPlaceholder(ph) {
|
|
17099
|
+
this.pieces.push(this.createPlaceholderPiece(ph.startName, ph.startSourceSpan ?? ph.sourceSpan));
|
|
17038
17100
|
if (!ph.isVoid) {
|
|
17039
|
-
ph.children.forEach(child => child.visit(this
|
|
17040
|
-
|
|
17101
|
+
ph.children.forEach(child => child.visit(this));
|
|
17102
|
+
this.pieces.push(this.createPlaceholderPiece(ph.closeName, ph.endSourceSpan ?? ph.sourceSpan));
|
|
17041
17103
|
}
|
|
17042
17104
|
}
|
|
17043
|
-
visitPlaceholder(ph
|
|
17044
|
-
|
|
17105
|
+
visitPlaceholder(ph) {
|
|
17106
|
+
this.pieces.push(this.createPlaceholderPiece(ph.name, ph.sourceSpan));
|
|
17045
17107
|
}
|
|
17046
|
-
visitIcuPlaceholder(ph
|
|
17047
|
-
|
|
17108
|
+
visitIcuPlaceholder(ph) {
|
|
17109
|
+
this.pieces.push(this.createPlaceholderPiece(ph.name, ph.sourceSpan, this.placeholderToMessage[ph.name]));
|
|
17048
17110
|
}
|
|
17049
|
-
createPlaceholderPiece(name, sourceSpan) {
|
|
17050
|
-
return new PlaceholderPiece(formatI18nPlaceholderName(name, /* useCamelCase */ false), sourceSpan);
|
|
17111
|
+
createPlaceholderPiece(name, sourceSpan, associatedMessage) {
|
|
17112
|
+
return new PlaceholderPiece(formatI18nPlaceholderName(name, /* useCamelCase */ false), sourceSpan, associatedMessage);
|
|
17051
17113
|
}
|
|
17052
17114
|
}
|
|
17053
|
-
const serializerVisitor = new LocalizeSerializerVisitor();
|
|
17054
17115
|
/**
|
|
17055
17116
|
* Serialize an i18n message into two arrays: messageParts and placeholders.
|
|
17056
17117
|
*
|
|
@@ -17061,7 +17122,8 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
17061
17122
|
*/
|
|
17062
17123
|
function serializeI18nMessageForLocalize(message) {
|
|
17063
17124
|
const pieces = [];
|
|
17064
|
-
|
|
17125
|
+
const serializerVisitor = new LocalizeSerializerVisitor(message.placeholderToMessage, pieces);
|
|
17126
|
+
message.nodes.forEach(node => node.visit(serializerVisitor));
|
|
17065
17127
|
return processMessagePieces(pieces);
|
|
17066
17128
|
}
|
|
17067
17129
|
function getSourceSpan(message) {
|
|
@@ -20015,7 +20077,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20015
20077
|
* Use of this source code is governed by an MIT-style license that can be
|
|
20016
20078
|
* found in the LICENSE file at https://angular.io/license
|
|
20017
20079
|
*/
|
|
20018
|
-
new Version('13.0.
|
|
20080
|
+
new Version('13.1.0-next.2');
|
|
20019
20081
|
|
|
20020
20082
|
/**
|
|
20021
20083
|
* @license
|
|
@@ -20644,7 +20706,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20644
20706
|
function compileDeclareClassMetadata(metadata) {
|
|
20645
20707
|
const definitionMap = new DefinitionMap();
|
|
20646
20708
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$6));
|
|
20647
|
-
definitionMap.set('version', literal$1('13.0.
|
|
20709
|
+
definitionMap.set('version', literal$1('13.1.0-next.2'));
|
|
20648
20710
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
20649
20711
|
definitionMap.set('type', metadata.type);
|
|
20650
20712
|
definitionMap.set('decorators', metadata.decorators);
|
|
@@ -20761,7 +20823,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20761
20823
|
function createDirectiveDefinitionMap(meta) {
|
|
20762
20824
|
const definitionMap = new DefinitionMap();
|
|
20763
20825
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$5));
|
|
20764
|
-
definitionMap.set('version', literal$1('13.0.
|
|
20826
|
+
definitionMap.set('version', literal$1('13.1.0-next.2'));
|
|
20765
20827
|
// e.g. `type: MyDirective`
|
|
20766
20828
|
definitionMap.set('type', meta.internalType);
|
|
20767
20829
|
// e.g. `selector: 'some-dir'`
|
|
@@ -20979,7 +21041,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
20979
21041
|
function compileDeclareFactoryFunction(meta) {
|
|
20980
21042
|
const definitionMap = new DefinitionMap();
|
|
20981
21043
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$4));
|
|
20982
|
-
definitionMap.set('version', literal$1('13.0.
|
|
21044
|
+
definitionMap.set('version', literal$1('13.1.0-next.2'));
|
|
20983
21045
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
20984
21046
|
definitionMap.set('type', meta.internalType);
|
|
20985
21047
|
definitionMap.set('deps', compileDependencies(meta.deps));
|
|
@@ -21021,7 +21083,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21021
21083
|
function createInjectableDefinitionMap(meta) {
|
|
21022
21084
|
const definitionMap = new DefinitionMap();
|
|
21023
21085
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$3));
|
|
21024
|
-
definitionMap.set('version', literal$1('13.0.
|
|
21086
|
+
definitionMap.set('version', literal$1('13.1.0-next.2'));
|
|
21025
21087
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
21026
21088
|
definitionMap.set('type', meta.internalType);
|
|
21027
21089
|
// Only generate providedIn property if it has a non-null value
|
|
@@ -21079,7 +21141,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21079
21141
|
function createInjectorDefinitionMap(meta) {
|
|
21080
21142
|
const definitionMap = new DefinitionMap();
|
|
21081
21143
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$2));
|
|
21082
|
-
definitionMap.set('version', literal$1('13.0.
|
|
21144
|
+
definitionMap.set('version', literal$1('13.1.0-next.2'));
|
|
21083
21145
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
21084
21146
|
definitionMap.set('type', meta.internalType);
|
|
21085
21147
|
definitionMap.set('providers', meta.providers);
|
|
@@ -21116,7 +21178,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21116
21178
|
function createNgModuleDefinitionMap(meta) {
|
|
21117
21179
|
const definitionMap = new DefinitionMap();
|
|
21118
21180
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION$1));
|
|
21119
|
-
definitionMap.set('version', literal$1('13.0.
|
|
21181
|
+
definitionMap.set('version', literal$1('13.1.0-next.2'));
|
|
21120
21182
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
21121
21183
|
definitionMap.set('type', meta.internalType);
|
|
21122
21184
|
// We only generate the keys in the metadata if the arrays contain values.
|
|
@@ -21174,7 +21236,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21174
21236
|
function createPipeDefinitionMap(meta) {
|
|
21175
21237
|
const definitionMap = new DefinitionMap();
|
|
21176
21238
|
definitionMap.set('minVersion', literal$1(MINIMUM_PARTIAL_LINKER_VERSION));
|
|
21177
|
-
definitionMap.set('version', literal$1('13.0.
|
|
21239
|
+
definitionMap.set('version', literal$1('13.1.0-next.2'));
|
|
21178
21240
|
definitionMap.set('ngImport', importExpr(Identifiers$1.core));
|
|
21179
21241
|
// e.g. `type: MyPipe`
|
|
21180
21242
|
definitionMap.set('type', meta.internalType);
|
|
@@ -21206,7 +21268,7 @@ define(['exports', 'typescript/lib/tsserverlibrary', 'os', 'typescript', 'fs', '
|
|
|
21206
21268
|
* Use of this source code is governed by an MIT-style license that can be
|
|
21207
21269
|
* found in the LICENSE file at https://angular.io/license
|
|
21208
21270
|
*/
|
|
21209
|
-
new Version('13.0.
|
|
21271
|
+
new Version('13.1.0-next.2');
|
|
21210
21272
|
|
|
21211
21273
|
/**
|
|
21212
21274
|
* @license
|
|
@@ -45105,6 +45167,7 @@ https://angular.io/guide/ivy for more information.
|
|
|
45105
45167
|
// regardless of its value in tsconfig.json.
|
|
45106
45168
|
if (config.forceStrictTemplates === true) {
|
|
45107
45169
|
options.strictTemplates = true;
|
|
45170
|
+
options._extendedTemplateDiagnostics = true;
|
|
45108
45171
|
}
|
|
45109
45172
|
return options;
|
|
45110
45173
|
}
|