@public-ui/hydrate 1.7.28 → 1.7.29
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/dist/index.js +219 -205
- package/dist/index.mjs +219 -205
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -4354,7 +4354,7 @@ class EventEmitter {
|
|
|
4354
4354
|
}
|
|
4355
4355
|
}
|
|
4356
4356
|
|
|
4357
|
-
|
|
4357
|
+
const defer = () => {
|
|
4358
4358
|
let res;
|
|
4359
4359
|
let rej;
|
|
4360
4360
|
const promise = new Promise((resolve, reject) => {
|
|
@@ -4364,28 +4364,24 @@ function defer() {
|
|
|
4364
4364
|
promise.resolve = res;
|
|
4365
4365
|
promise.reject = rej;
|
|
4366
4366
|
return promise;
|
|
4367
|
-
}
|
|
4368
|
-
|
|
4367
|
+
};
|
|
4368
|
+
const makeString = object => {
|
|
4369
4369
|
if (object == null) return '';
|
|
4370
4370
|
return '' + object;
|
|
4371
|
-
}
|
|
4372
|
-
|
|
4371
|
+
};
|
|
4372
|
+
const copy = (a, s, t) => {
|
|
4373
4373
|
a.forEach(m => {
|
|
4374
4374
|
if (s[m]) t[m] = s[m];
|
|
4375
4375
|
});
|
|
4376
|
-
}
|
|
4376
|
+
};
|
|
4377
4377
|
const lastOfPathSeparatorRegExp = /###/g;
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
}
|
|
4382
|
-
function canNotTraverseDeeper() {
|
|
4383
|
-
return !object || typeof object === 'string';
|
|
4384
|
-
}
|
|
4378
|
+
const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
|
|
4379
|
+
const canNotTraverseDeeper = object => !object || typeof object === 'string';
|
|
4380
|
+
const getLastOfPath = (object, path, Empty) => {
|
|
4385
4381
|
const stack = typeof path !== 'string' ? path : path.split('.');
|
|
4386
4382
|
let stackIndex = 0;
|
|
4387
4383
|
while (stackIndex < stack.length - 1) {
|
|
4388
|
-
if (canNotTraverseDeeper()) return {};
|
|
4384
|
+
if (canNotTraverseDeeper(object)) return {};
|
|
4389
4385
|
const key = cleanKey(stack[stackIndex]);
|
|
4390
4386
|
if (!object[key] && Empty) object[key] = new Empty();
|
|
4391
4387
|
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
@@ -4395,13 +4391,13 @@ function getLastOfPath(object, path, Empty) {
|
|
|
4395
4391
|
}
|
|
4396
4392
|
++stackIndex;
|
|
4397
4393
|
}
|
|
4398
|
-
if (canNotTraverseDeeper()) return {};
|
|
4394
|
+
if (canNotTraverseDeeper(object)) return {};
|
|
4399
4395
|
return {
|
|
4400
4396
|
obj: object,
|
|
4401
4397
|
k: cleanKey(stack[stackIndex])
|
|
4402
4398
|
};
|
|
4403
|
-
}
|
|
4404
|
-
|
|
4399
|
+
};
|
|
4400
|
+
const setPath = (object, path, newValue) => {
|
|
4405
4401
|
const {
|
|
4406
4402
|
obj,
|
|
4407
4403
|
k
|
|
@@ -4422,31 +4418,31 @@ function setPath(object, path, newValue) {
|
|
|
4422
4418
|
}
|
|
4423
4419
|
}
|
|
4424
4420
|
last.obj[`${last.k}.${e}`] = newValue;
|
|
4425
|
-
}
|
|
4426
|
-
|
|
4421
|
+
};
|
|
4422
|
+
const pushPath = (object, path, newValue, concat) => {
|
|
4427
4423
|
const {
|
|
4428
4424
|
obj,
|
|
4429
4425
|
k
|
|
4430
4426
|
} = getLastOfPath(object, path, Object);
|
|
4431
4427
|
obj[k] = obj[k] || [];
|
|
4432
4428
|
obj[k].push(newValue);
|
|
4433
|
-
}
|
|
4434
|
-
|
|
4429
|
+
};
|
|
4430
|
+
const getPath = (object, path) => {
|
|
4435
4431
|
const {
|
|
4436
4432
|
obj,
|
|
4437
4433
|
k
|
|
4438
4434
|
} = getLastOfPath(object, path);
|
|
4439
4435
|
if (!obj) return undefined;
|
|
4440
4436
|
return obj[k];
|
|
4441
|
-
}
|
|
4442
|
-
|
|
4437
|
+
};
|
|
4438
|
+
const getPathWithDefaults = (data, defaultData, key) => {
|
|
4443
4439
|
const value = getPath(data, key);
|
|
4444
4440
|
if (value !== undefined) {
|
|
4445
4441
|
return value;
|
|
4446
4442
|
}
|
|
4447
4443
|
return getPath(defaultData, key);
|
|
4448
|
-
}
|
|
4449
|
-
|
|
4444
|
+
};
|
|
4445
|
+
const deepExtend = (target, source, overwrite) => {
|
|
4450
4446
|
for (const prop in source) {
|
|
4451
4447
|
if (prop !== '__proto__' && prop !== 'constructor') {
|
|
4452
4448
|
if (prop in target) {
|
|
@@ -4461,10 +4457,8 @@ function deepExtend(target, source, overwrite) {
|
|
|
4461
4457
|
}
|
|
4462
4458
|
}
|
|
4463
4459
|
return target;
|
|
4464
|
-
}
|
|
4465
|
-
|
|
4466
|
-
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
4467
|
-
}
|
|
4460
|
+
};
|
|
4461
|
+
const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
4468
4462
|
var _entityMap = {
|
|
4469
4463
|
'&': '&',
|
|
4470
4464
|
'<': '<',
|
|
@@ -4473,12 +4467,12 @@ var _entityMap = {
|
|
|
4473
4467
|
"'": ''',
|
|
4474
4468
|
'/': '/'
|
|
4475
4469
|
};
|
|
4476
|
-
|
|
4470
|
+
const escape$1 = data => {
|
|
4477
4471
|
if (typeof data === 'string') {
|
|
4478
4472
|
return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
|
|
4479
4473
|
}
|
|
4480
4474
|
return data;
|
|
4481
|
-
}
|
|
4475
|
+
};
|
|
4482
4476
|
class RegExpCache {
|
|
4483
4477
|
constructor(capacity) {
|
|
4484
4478
|
this.capacity = capacity;
|
|
@@ -4501,7 +4495,7 @@ class RegExpCache {
|
|
|
4501
4495
|
}
|
|
4502
4496
|
const chars = [' ', ',', '?', '!', ';'];
|
|
4503
4497
|
const looksLikeObjectPathRegExpCache = new RegExpCache(20);
|
|
4504
|
-
|
|
4498
|
+
const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
|
|
4505
4499
|
nsSeparator = nsSeparator || '';
|
|
4506
4500
|
keySeparator = keySeparator || '';
|
|
4507
4501
|
const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
|
|
@@ -4515,8 +4509,8 @@ function looksLikeObjectPath(key, nsSeparator, keySeparator) {
|
|
|
4515
4509
|
}
|
|
4516
4510
|
}
|
|
4517
4511
|
return matched;
|
|
4518
|
-
}
|
|
4519
|
-
function
|
|
4512
|
+
};
|
|
4513
|
+
const deepFind = function (obj, path) {
|
|
4520
4514
|
let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
|
|
4521
4515
|
if (!obj) return undefined;
|
|
4522
4516
|
if (obj[path]) return obj[path];
|
|
@@ -4545,11 +4539,11 @@ function deepFind(obj, path) {
|
|
|
4545
4539
|
current = next;
|
|
4546
4540
|
}
|
|
4547
4541
|
return current;
|
|
4548
|
-
}
|
|
4549
|
-
|
|
4542
|
+
};
|
|
4543
|
+
const getCleanedCode = code => {
|
|
4550
4544
|
if (code && code.indexOf('_') > 0) return code.replace('_', '-');
|
|
4551
4545
|
return code;
|
|
4552
|
-
}
|
|
4546
|
+
};
|
|
4553
4547
|
|
|
4554
4548
|
class ResourceStore extends EventEmitter {
|
|
4555
4549
|
constructor(data) {
|
|
@@ -5113,9 +5107,7 @@ class Translator extends EventEmitter {
|
|
|
5113
5107
|
}
|
|
5114
5108
|
}
|
|
5115
5109
|
|
|
5116
|
-
|
|
5117
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
5118
|
-
}
|
|
5110
|
+
const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1);
|
|
5119
5111
|
class LanguageUtil {
|
|
5120
5112
|
constructor(options) {
|
|
5121
5113
|
this.options = options;
|
|
@@ -5320,72 +5312,28 @@ let sets = [{
|
|
|
5320
5312
|
fc: 22
|
|
5321
5313
|
}];
|
|
5322
5314
|
let _rulesPluralsTypes = {
|
|
5323
|
-
1:
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
|
|
5346
|
-
},
|
|
5347
|
-
9: function (n) {
|
|
5348
|
-
return Number(n >= 2);
|
|
5349
|
-
},
|
|
5350
|
-
10: function (n) {
|
|
5351
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
|
|
5352
|
-
},
|
|
5353
|
-
11: function (n) {
|
|
5354
|
-
return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
|
|
5355
|
-
},
|
|
5356
|
-
12: function (n) {
|
|
5357
|
-
return Number(n % 10 != 1 || n % 100 == 11);
|
|
5358
|
-
},
|
|
5359
|
-
13: function (n) {
|
|
5360
|
-
return Number(n !== 0);
|
|
5361
|
-
},
|
|
5362
|
-
14: function (n) {
|
|
5363
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
|
|
5364
|
-
},
|
|
5365
|
-
15: function (n) {
|
|
5366
|
-
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
|
|
5367
|
-
},
|
|
5368
|
-
16: function (n) {
|
|
5369
|
-
return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
|
|
5370
|
-
},
|
|
5371
|
-
17: function (n) {
|
|
5372
|
-
return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
|
|
5373
|
-
},
|
|
5374
|
-
18: function (n) {
|
|
5375
|
-
return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
|
|
5376
|
-
},
|
|
5377
|
-
19: function (n) {
|
|
5378
|
-
return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
|
|
5379
|
-
},
|
|
5380
|
-
20: function (n) {
|
|
5381
|
-
return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
|
|
5382
|
-
},
|
|
5383
|
-
21: function (n) {
|
|
5384
|
-
return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
|
|
5385
|
-
},
|
|
5386
|
-
22: function (n) {
|
|
5387
|
-
return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
|
|
5388
|
-
}
|
|
5315
|
+
1: n => Number(n > 1),
|
|
5316
|
+
2: n => Number(n != 1),
|
|
5317
|
+
3: n => 0,
|
|
5318
|
+
4: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
|
|
5319
|
+
5: n => Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5),
|
|
5320
|
+
6: n => Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2),
|
|
5321
|
+
7: n => Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
|
|
5322
|
+
8: n => Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3),
|
|
5323
|
+
9: n => Number(n >= 2),
|
|
5324
|
+
10: n => Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4),
|
|
5325
|
+
11: n => Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3),
|
|
5326
|
+
12: n => Number(n % 10 != 1 || n % 100 == 11),
|
|
5327
|
+
13: n => Number(n !== 0),
|
|
5328
|
+
14: n => Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3),
|
|
5329
|
+
15: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
|
|
5330
|
+
16: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2),
|
|
5331
|
+
17: n => Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1),
|
|
5332
|
+
18: n => Number(n == 0 ? 0 : n == 1 ? 1 : 2),
|
|
5333
|
+
19: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3),
|
|
5334
|
+
20: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2),
|
|
5335
|
+
21: n => Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0),
|
|
5336
|
+
22: n => Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3)
|
|
5389
5337
|
};
|
|
5390
5338
|
const nonIntlVersions = ['v1', 'v2', 'v3'];
|
|
5391
5339
|
const intlVersions = ['v4'];
|
|
@@ -5397,7 +5345,7 @@ const suffixesOrder = {
|
|
|
5397
5345
|
many: 4,
|
|
5398
5346
|
other: 5
|
|
5399
5347
|
};
|
|
5400
|
-
|
|
5348
|
+
const createRules = () => {
|
|
5401
5349
|
const rules = {};
|
|
5402
5350
|
sets.forEach(set => {
|
|
5403
5351
|
set.lngs.forEach(l => {
|
|
@@ -5408,7 +5356,7 @@ function createRules() {
|
|
|
5408
5356
|
});
|
|
5409
5357
|
});
|
|
5410
5358
|
return rules;
|
|
5411
|
-
}
|
|
5359
|
+
};
|
|
5412
5360
|
class PluralResolver {
|
|
5413
5361
|
constructor(languageUtils) {
|
|
5414
5362
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -5420,17 +5368,32 @@ class PluralResolver {
|
|
|
5420
5368
|
this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
|
|
5421
5369
|
}
|
|
5422
5370
|
this.rules = createRules();
|
|
5371
|
+
this.pluralRulesCache = {};
|
|
5423
5372
|
}
|
|
5424
5373
|
addRule(lng, obj) {
|
|
5425
5374
|
this.rules[lng] = obj;
|
|
5426
5375
|
}
|
|
5376
|
+
clearCache() {
|
|
5377
|
+
this.pluralRulesCache = {};
|
|
5378
|
+
}
|
|
5427
5379
|
getRule(code) {
|
|
5428
5380
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
5429
5381
|
if (this.shouldUseIntlApi()) {
|
|
5430
5382
|
try {
|
|
5431
|
-
|
|
5432
|
-
|
|
5383
|
+
const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
|
|
5384
|
+
const type = options.ordinal ? 'ordinal' : 'cardinal';
|
|
5385
|
+
const cacheKey = JSON.stringify({
|
|
5386
|
+
cleanedCode,
|
|
5387
|
+
type
|
|
5388
|
+
});
|
|
5389
|
+
if (cacheKey in this.pluralRulesCache) {
|
|
5390
|
+
return this.pluralRulesCache[cacheKey];
|
|
5391
|
+
}
|
|
5392
|
+
const rule = new Intl.PluralRules(cleanedCode, {
|
|
5393
|
+
type
|
|
5433
5394
|
});
|
|
5395
|
+
this.pluralRulesCache[cacheKey] = rule;
|
|
5396
|
+
return rule;
|
|
5434
5397
|
} catch (err) {
|
|
5435
5398
|
return;
|
|
5436
5399
|
}
|
|
@@ -5499,7 +5462,7 @@ class PluralResolver {
|
|
|
5499
5462
|
}
|
|
5500
5463
|
}
|
|
5501
5464
|
|
|
5502
|
-
function
|
|
5465
|
+
const deepFindWithDefaults = function (data, defaultData, key) {
|
|
5503
5466
|
let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
|
|
5504
5467
|
let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
5505
5468
|
let path = getPathWithDefaults(data, defaultData, key);
|
|
@@ -5508,7 +5471,8 @@ function deepFindWithDefaults(data, defaultData, key) {
|
|
|
5508
5471
|
if (path === undefined) path = deepFind(defaultData, key, keySeparator);
|
|
5509
5472
|
}
|
|
5510
5473
|
return path;
|
|
5511
|
-
}
|
|
5474
|
+
};
|
|
5475
|
+
const regexSafe = val => val.replace(/\$/g, '$$$$');
|
|
5512
5476
|
class Interpolator {
|
|
5513
5477
|
constructor() {
|
|
5514
5478
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -5576,9 +5540,6 @@ class Interpolator {
|
|
|
5576
5540
|
let value;
|
|
5577
5541
|
let replaces;
|
|
5578
5542
|
const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
5579
|
-
function regexSafe(val) {
|
|
5580
|
-
return val.replace(/\$/g, '$$$$');
|
|
5581
|
-
}
|
|
5582
5543
|
const handleFormat = key => {
|
|
5583
5544
|
if (key.indexOf(this.formatSeparator) < 0) {
|
|
5584
5545
|
const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
@@ -5649,7 +5610,7 @@ class Interpolator {
|
|
|
5649
5610
|
let match;
|
|
5650
5611
|
let value;
|
|
5651
5612
|
let clonedOptions;
|
|
5652
|
-
|
|
5613
|
+
const handleHasOptions = (key, inheritedOptions) => {
|
|
5653
5614
|
const sep = this.nestingOptionsSeparator;
|
|
5654
5615
|
if (key.indexOf(sep) < 0) return key;
|
|
5655
5616
|
const c = key.split(new RegExp(`${sep}[ ]*{`));
|
|
@@ -5673,7 +5634,7 @@ class Interpolator {
|
|
|
5673
5634
|
}
|
|
5674
5635
|
if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
|
|
5675
5636
|
return key;
|
|
5676
|
-
}
|
|
5637
|
+
};
|
|
5677
5638
|
while (match = this.nestingRegexp.exec(str)) {
|
|
5678
5639
|
let formatters = [];
|
|
5679
5640
|
clonedOptions = {
|
|
@@ -5709,7 +5670,7 @@ class Interpolator {
|
|
|
5709
5670
|
}
|
|
5710
5671
|
}
|
|
5711
5672
|
|
|
5712
|
-
|
|
5673
|
+
const parseFormatStr = formatStr => {
|
|
5713
5674
|
let formatName = formatStr.toLowerCase().trim();
|
|
5714
5675
|
const formatOptions = {};
|
|
5715
5676
|
if (formatStr.indexOf('(') > -1) {
|
|
@@ -5739,11 +5700,18 @@ function parseFormatStr(formatStr) {
|
|
|
5739
5700
|
formatName,
|
|
5740
5701
|
formatOptions
|
|
5741
5702
|
};
|
|
5742
|
-
}
|
|
5743
|
-
|
|
5703
|
+
};
|
|
5704
|
+
const createCachedFormatter = fn => {
|
|
5744
5705
|
const cache = {};
|
|
5745
|
-
return
|
|
5746
|
-
|
|
5706
|
+
return (val, lng, options) => {
|
|
5707
|
+
let optForCache = options;
|
|
5708
|
+
if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
|
|
5709
|
+
optForCache = {
|
|
5710
|
+
...optForCache,
|
|
5711
|
+
[options.interpolationkey]: undefined
|
|
5712
|
+
};
|
|
5713
|
+
}
|
|
5714
|
+
const key = lng + JSON.stringify(optForCache);
|
|
5747
5715
|
let formatter = cache[key];
|
|
5748
5716
|
if (!formatter) {
|
|
5749
5717
|
formatter = fn(getCleanedCode(lng), options);
|
|
@@ -5751,7 +5719,7 @@ function createCachedFormatter(fn) {
|
|
|
5751
5719
|
}
|
|
5752
5720
|
return formatter(val);
|
|
5753
5721
|
};
|
|
5754
|
-
}
|
|
5722
|
+
};
|
|
5755
5723
|
class Formatter {
|
|
5756
5724
|
constructor() {
|
|
5757
5725
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -5808,6 +5776,10 @@ class Formatter {
|
|
|
5808
5776
|
format(value, format, lng) {
|
|
5809
5777
|
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
5810
5778
|
const formats = format.split(this.formatSeparator);
|
|
5779
|
+
if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
|
|
5780
|
+
const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
|
|
5781
|
+
formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
|
|
5782
|
+
}
|
|
5811
5783
|
const result = formats.reduce((mem, f) => {
|
|
5812
5784
|
const {
|
|
5813
5785
|
formatName,
|
|
@@ -5836,12 +5808,12 @@ class Formatter {
|
|
|
5836
5808
|
}
|
|
5837
5809
|
}
|
|
5838
5810
|
|
|
5839
|
-
|
|
5811
|
+
const removePending = (q, name) => {
|
|
5840
5812
|
if (q.pending[name] !== undefined) {
|
|
5841
5813
|
delete q.pending[name];
|
|
5842
5814
|
q.pendingCount--;
|
|
5843
5815
|
}
|
|
5844
|
-
}
|
|
5816
|
+
};
|
|
5845
5817
|
class Connector extends EventEmitter {
|
|
5846
5818
|
constructor(backend, store, services) {
|
|
5847
5819
|
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
@@ -5907,12 +5879,13 @@ class Connector extends EventEmitter {
|
|
|
5907
5879
|
const lng = s[0];
|
|
5908
5880
|
const ns = s[1];
|
|
5909
5881
|
if (err) this.emit('failedLoading', lng, ns, err);
|
|
5910
|
-
if (data) {
|
|
5882
|
+
if (!err && data) {
|
|
5911
5883
|
this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
|
|
5912
5884
|
skipCopy: true
|
|
5913
5885
|
});
|
|
5914
5886
|
}
|
|
5915
5887
|
this.state[name] = err ? -1 : 2;
|
|
5888
|
+
if (err && data) this.state[name] = 0;
|
|
5916
5889
|
const loaded = {};
|
|
5917
5890
|
this.queue.forEach(q => {
|
|
5918
5891
|
pushPath(q.loaded, [lng], ns);
|
|
@@ -6062,69 +6035,67 @@ class Connector extends EventEmitter {
|
|
|
6062
6035
|
}
|
|
6063
6036
|
}
|
|
6064
6037
|
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
});
|
|
6109
|
-
}
|
|
6110
|
-
return ret;
|
|
6111
|
-
},
|
|
6112
|
-
interpolation: {
|
|
6113
|
-
escapeValue: true,
|
|
6114
|
-
format: value => value,
|
|
6115
|
-
prefix: '{{',
|
|
6116
|
-
suffix: '}}',
|
|
6117
|
-
formatSeparator: ',',
|
|
6118
|
-
unescapePrefix: '-',
|
|
6119
|
-
nestingPrefix: '$t(',
|
|
6120
|
-
nestingSuffix: ')',
|
|
6121
|
-
nestingOptionsSeparator: ',',
|
|
6122
|
-
maxReplaces: 1000,
|
|
6123
|
-
skipOnVariables: true
|
|
6038
|
+
const get = () => ({
|
|
6039
|
+
debug: false,
|
|
6040
|
+
initImmediate: true,
|
|
6041
|
+
ns: ['translation'],
|
|
6042
|
+
defaultNS: ['translation'],
|
|
6043
|
+
fallbackLng: ['dev'],
|
|
6044
|
+
fallbackNS: false,
|
|
6045
|
+
supportedLngs: false,
|
|
6046
|
+
nonExplicitSupportedLngs: false,
|
|
6047
|
+
load: 'all',
|
|
6048
|
+
preload: false,
|
|
6049
|
+
simplifyPluralSuffix: true,
|
|
6050
|
+
keySeparator: '.',
|
|
6051
|
+
nsSeparator: ':',
|
|
6052
|
+
pluralSeparator: '_',
|
|
6053
|
+
contextSeparator: '_',
|
|
6054
|
+
partialBundledLanguages: false,
|
|
6055
|
+
saveMissing: false,
|
|
6056
|
+
updateMissing: false,
|
|
6057
|
+
saveMissingTo: 'fallback',
|
|
6058
|
+
saveMissingPlurals: true,
|
|
6059
|
+
missingKeyHandler: false,
|
|
6060
|
+
missingInterpolationHandler: false,
|
|
6061
|
+
postProcess: false,
|
|
6062
|
+
postProcessPassResolved: false,
|
|
6063
|
+
returnNull: false,
|
|
6064
|
+
returnEmptyString: true,
|
|
6065
|
+
returnObjects: false,
|
|
6066
|
+
joinArrays: false,
|
|
6067
|
+
returnedObjectHandler: false,
|
|
6068
|
+
parseMissingKeyHandler: false,
|
|
6069
|
+
appendNamespaceToMissingKey: false,
|
|
6070
|
+
appendNamespaceToCIMode: false,
|
|
6071
|
+
overloadTranslationOptionHandler: args => {
|
|
6072
|
+
let ret = {};
|
|
6073
|
+
if (typeof args[1] === 'object') ret = args[1];
|
|
6074
|
+
if (typeof args[1] === 'string') ret.defaultValue = args[1];
|
|
6075
|
+
if (typeof args[2] === 'string') ret.tDescription = args[2];
|
|
6076
|
+
if (typeof args[2] === 'object' || typeof args[3] === 'object') {
|
|
6077
|
+
const options = args[3] || args[2];
|
|
6078
|
+
Object.keys(options).forEach(key => {
|
|
6079
|
+
ret[key] = options[key];
|
|
6080
|
+
});
|
|
6124
6081
|
}
|
|
6125
|
-
|
|
6126
|
-
}
|
|
6127
|
-
|
|
6082
|
+
return ret;
|
|
6083
|
+
},
|
|
6084
|
+
interpolation: {
|
|
6085
|
+
escapeValue: true,
|
|
6086
|
+
format: value => value,
|
|
6087
|
+
prefix: '{{',
|
|
6088
|
+
suffix: '}}',
|
|
6089
|
+
formatSeparator: ',',
|
|
6090
|
+
unescapePrefix: '-',
|
|
6091
|
+
nestingPrefix: '$t(',
|
|
6092
|
+
nestingSuffix: ')',
|
|
6093
|
+
nestingOptionsSeparator: ',',
|
|
6094
|
+
maxReplaces: 1000,
|
|
6095
|
+
skipOnVariables: true
|
|
6096
|
+
}
|
|
6097
|
+
});
|
|
6098
|
+
const transformOptions = options => {
|
|
6128
6099
|
if (typeof options.ns === 'string') options.ns = [options.ns];
|
|
6129
6100
|
if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
|
|
6130
6101
|
if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
|
|
@@ -6132,17 +6103,17 @@ function transformOptions(options) {
|
|
|
6132
6103
|
options.supportedLngs = options.supportedLngs.concat(['cimode']);
|
|
6133
6104
|
}
|
|
6134
6105
|
return options;
|
|
6135
|
-
}
|
|
6106
|
+
};
|
|
6136
6107
|
|
|
6137
|
-
|
|
6138
|
-
|
|
6108
|
+
const noop = () => {};
|
|
6109
|
+
const bindMemberFunctions = inst => {
|
|
6139
6110
|
const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
6140
6111
|
mems.forEach(mem => {
|
|
6141
6112
|
if (typeof inst[mem] === 'function') {
|
|
6142
6113
|
inst[mem] = inst[mem].bind(inst);
|
|
6143
6114
|
}
|
|
6144
6115
|
});
|
|
6145
|
-
}
|
|
6116
|
+
};
|
|
6146
6117
|
class I18n extends EventEmitter {
|
|
6147
6118
|
constructor() {
|
|
6148
6119
|
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -6199,11 +6170,11 @@ class I18n extends EventEmitter {
|
|
|
6199
6170
|
if (options.nsSeparator !== undefined) {
|
|
6200
6171
|
this.options.userDefinedNsSeparator = options.nsSeparator;
|
|
6201
6172
|
}
|
|
6202
|
-
|
|
6173
|
+
const createClassOnDemand = ClassOrObject => {
|
|
6203
6174
|
if (!ClassOrObject) return null;
|
|
6204
6175
|
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
|
6205
6176
|
return ClassOrObject;
|
|
6206
|
-
}
|
|
6177
|
+
};
|
|
6207
6178
|
if (!this.options.isClone) {
|
|
6208
6179
|
if (this.modules.logger) {
|
|
6209
6180
|
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
@@ -6341,6 +6312,14 @@ class I18n extends EventEmitter {
|
|
|
6341
6312
|
}
|
|
6342
6313
|
reloadResources(lngs, ns, callback) {
|
|
6343
6314
|
const deferred = defer();
|
|
6315
|
+
if (typeof lngs === 'function') {
|
|
6316
|
+
callback = lngs;
|
|
6317
|
+
lngs = undefined;
|
|
6318
|
+
}
|
|
6319
|
+
if (typeof ns === 'function') {
|
|
6320
|
+
callback = ns;
|
|
6321
|
+
ns = undefined;
|
|
6322
|
+
}
|
|
6344
6323
|
if (!lngs) lngs = this.languages;
|
|
6345
6324
|
if (!ns) ns = this.options.ns;
|
|
6346
6325
|
if (!callback) callback = noop;
|
|
@@ -6504,7 +6483,7 @@ class I18n extends EventEmitter {
|
|
|
6504
6483
|
if (lng.toLowerCase() === 'cimode') return true;
|
|
6505
6484
|
const loadNotPending = (l, n) => {
|
|
6506
6485
|
const loadState = this.services.backendConnector.state[`${l}|${n}`];
|
|
6507
|
-
return loadState === -1 || loadState === 2;
|
|
6486
|
+
return loadState === -1 || loadState === 0 || loadState === 2;
|
|
6508
6487
|
};
|
|
6509
6488
|
if (options.precheck) {
|
|
6510
6489
|
const preResult = options.precheck(this, loadNotPending);
|
|
@@ -15348,6 +15327,9 @@ const size = function (options) {
|
|
|
15348
15327
|
};
|
|
15349
15328
|
};
|
|
15350
15329
|
|
|
15330
|
+
function hasWindow() {
|
|
15331
|
+
return typeof window !== 'undefined';
|
|
15332
|
+
}
|
|
15351
15333
|
function getNodeName(node) {
|
|
15352
15334
|
if (isNode(node)) {
|
|
15353
15335
|
return (node.nodeName || '').toLowerCase();
|
|
@@ -15366,17 +15348,25 @@ function getDocumentElement(node) {
|
|
|
15366
15348
|
return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
|
|
15367
15349
|
}
|
|
15368
15350
|
function isNode(value) {
|
|
15351
|
+
if (!hasWindow()) {
|
|
15352
|
+
return false;
|
|
15353
|
+
}
|
|
15369
15354
|
return value instanceof Node || value instanceof getWindow(value).Node;
|
|
15370
15355
|
}
|
|
15371
15356
|
function isElement(value) {
|
|
15357
|
+
if (!hasWindow()) {
|
|
15358
|
+
return false;
|
|
15359
|
+
}
|
|
15372
15360
|
return value instanceof Element || value instanceof getWindow(value).Element;
|
|
15373
15361
|
}
|
|
15374
15362
|
function isHTMLElement(value) {
|
|
15363
|
+
if (!hasWindow()) {
|
|
15364
|
+
return false;
|
|
15365
|
+
}
|
|
15375
15366
|
return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
|
|
15376
15367
|
}
|
|
15377
15368
|
function isShadowRoot(value) {
|
|
15378
|
-
|
|
15379
|
-
if (typeof ShadowRoot === 'undefined') {
|
|
15369
|
+
if (!hasWindow() || typeof ShadowRoot === 'undefined') {
|
|
15380
15370
|
return false;
|
|
15381
15371
|
}
|
|
15382
15372
|
return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
|
|
@@ -15486,7 +15476,7 @@ function getOverflowAncestors(node, list, traverseIframes) {
|
|
|
15486
15476
|
return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
|
|
15487
15477
|
}
|
|
15488
15478
|
function getFrameElement(win) {
|
|
15489
|
-
return Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
15479
|
+
return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
|
|
15490
15480
|
}
|
|
15491
15481
|
|
|
15492
15482
|
function getCssDimensions(element) {
|
|
@@ -15659,10 +15649,14 @@ function getClientRects(element) {
|
|
|
15659
15649
|
return Array.from(element.getClientRects());
|
|
15660
15650
|
}
|
|
15661
15651
|
|
|
15662
|
-
|
|
15663
|
-
|
|
15664
|
-
|
|
15665
|
-
|
|
15652
|
+
// If <html> has a CSS width greater than the viewport, then this will be
|
|
15653
|
+
// incorrect for RTL.
|
|
15654
|
+
function getWindowScrollBarX(element, rect) {
|
|
15655
|
+
const leftScroll = getNodeScroll(element).scrollLeft;
|
|
15656
|
+
if (!rect) {
|
|
15657
|
+
return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
|
|
15658
|
+
}
|
|
15659
|
+
return rect.left + leftScroll;
|
|
15666
15660
|
}
|
|
15667
15661
|
|
|
15668
15662
|
// Gets the entire size of the scrollable document area, even extending outside
|
|
@@ -15846,11 +15840,22 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
|
15846
15840
|
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
15847
15841
|
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
15848
15842
|
} else if (documentElement) {
|
|
15843
|
+
// If the <body> scrollbar appears on the left (e.g. RTL systems). Use
|
|
15844
|
+
// Firefox with layout.scrollbar.side = 3 in about:config to test this.
|
|
15849
15845
|
offsets.x = getWindowScrollBarX(documentElement);
|
|
15850
15846
|
}
|
|
15851
15847
|
}
|
|
15852
|
-
|
|
15853
|
-
|
|
15848
|
+
let htmlX = 0;
|
|
15849
|
+
let htmlY = 0;
|
|
15850
|
+
if (documentElement && !isOffsetParentAnElement && !isFixed) {
|
|
15851
|
+
const htmlRect = documentElement.getBoundingClientRect();
|
|
15852
|
+
htmlY = htmlRect.top + scroll.scrollTop;
|
|
15853
|
+
htmlX = htmlRect.left + scroll.scrollLeft -
|
|
15854
|
+
// RTL <body> scrollbar.
|
|
15855
|
+
getWindowScrollBarX(documentElement, htmlRect);
|
|
15856
|
+
}
|
|
15857
|
+
const x = rect.left + scroll.scrollLeft - offsets.x - htmlX;
|
|
15858
|
+
const y = rect.top + scroll.scrollTop - offsets.y - htmlY;
|
|
15854
15859
|
return {
|
|
15855
15860
|
x,
|
|
15856
15861
|
y,
|
|
@@ -15870,7 +15875,16 @@ function getTrueOffsetParent(element, polyfill) {
|
|
|
15870
15875
|
if (polyfill) {
|
|
15871
15876
|
return polyfill(element);
|
|
15872
15877
|
}
|
|
15873
|
-
|
|
15878
|
+
let rawOffsetParent = element.offsetParent;
|
|
15879
|
+
|
|
15880
|
+
// Firefox returns the <html> element as the offsetParent if it's non-static,
|
|
15881
|
+
// while Chrome and Safari return the <body> element. The <body> element must
|
|
15882
|
+
// be used to perform the correct calculations even if the <html> element is
|
|
15883
|
+
// non-static.
|
|
15884
|
+
if (getDocumentElement(element) === rawOffsetParent) {
|
|
15885
|
+
rawOffsetParent = rawOffsetParent.ownerDocument.body;
|
|
15886
|
+
}
|
|
15887
|
+
return rawOffsetParent;
|
|
15874
15888
|
}
|
|
15875
15889
|
|
|
15876
15890
|
// Gets the closest ancestor positioned element. Handles some edge cases,
|