@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.
Files changed (3) hide show
  1. package/dist/index.js +219 -205
  2. package/dist/index.mjs +219 -205
  3. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -4350,7 +4350,7 @@ class EventEmitter {
4350
4350
  }
4351
4351
  }
4352
4352
 
4353
- function defer() {
4353
+ const defer = () => {
4354
4354
  let res;
4355
4355
  let rej;
4356
4356
  const promise = new Promise((resolve, reject) => {
@@ -4360,28 +4360,24 @@ function defer() {
4360
4360
  promise.resolve = res;
4361
4361
  promise.reject = rej;
4362
4362
  return promise;
4363
- }
4364
- function makeString(object) {
4363
+ };
4364
+ const makeString = object => {
4365
4365
  if (object == null) return '';
4366
4366
  return '' + object;
4367
- }
4368
- function copy(a, s, t) {
4367
+ };
4368
+ const copy = (a, s, t) => {
4369
4369
  a.forEach(m => {
4370
4370
  if (s[m]) t[m] = s[m];
4371
4371
  });
4372
- }
4372
+ };
4373
4373
  const lastOfPathSeparatorRegExp = /###/g;
4374
- function getLastOfPath(object, path, Empty) {
4375
- function cleanKey(key) {
4376
- return key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
4377
- }
4378
- function canNotTraverseDeeper() {
4379
- return !object || typeof object === 'string';
4380
- }
4374
+ const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
4375
+ const canNotTraverseDeeper = object => !object || typeof object === 'string';
4376
+ const getLastOfPath = (object, path, Empty) => {
4381
4377
  const stack = typeof path !== 'string' ? path : path.split('.');
4382
4378
  let stackIndex = 0;
4383
4379
  while (stackIndex < stack.length - 1) {
4384
- if (canNotTraverseDeeper()) return {};
4380
+ if (canNotTraverseDeeper(object)) return {};
4385
4381
  const key = cleanKey(stack[stackIndex]);
4386
4382
  if (!object[key] && Empty) object[key] = new Empty();
4387
4383
  if (Object.prototype.hasOwnProperty.call(object, key)) {
@@ -4391,13 +4387,13 @@ function getLastOfPath(object, path, Empty) {
4391
4387
  }
4392
4388
  ++stackIndex;
4393
4389
  }
4394
- if (canNotTraverseDeeper()) return {};
4390
+ if (canNotTraverseDeeper(object)) return {};
4395
4391
  return {
4396
4392
  obj: object,
4397
4393
  k: cleanKey(stack[stackIndex])
4398
4394
  };
4399
- }
4400
- function setPath(object, path, newValue) {
4395
+ };
4396
+ const setPath = (object, path, newValue) => {
4401
4397
  const {
4402
4398
  obj,
4403
4399
  k
@@ -4418,31 +4414,31 @@ function setPath(object, path, newValue) {
4418
4414
  }
4419
4415
  }
4420
4416
  last.obj[`${last.k}.${e}`] = newValue;
4421
- }
4422
- function pushPath(object, path, newValue, concat) {
4417
+ };
4418
+ const pushPath = (object, path, newValue, concat) => {
4423
4419
  const {
4424
4420
  obj,
4425
4421
  k
4426
4422
  } = getLastOfPath(object, path, Object);
4427
4423
  obj[k] = obj[k] || [];
4428
4424
  obj[k].push(newValue);
4429
- }
4430
- function getPath(object, path) {
4425
+ };
4426
+ const getPath = (object, path) => {
4431
4427
  const {
4432
4428
  obj,
4433
4429
  k
4434
4430
  } = getLastOfPath(object, path);
4435
4431
  if (!obj) return undefined;
4436
4432
  return obj[k];
4437
- }
4438
- function getPathWithDefaults(data, defaultData, key) {
4433
+ };
4434
+ const getPathWithDefaults = (data, defaultData, key) => {
4439
4435
  const value = getPath(data, key);
4440
4436
  if (value !== undefined) {
4441
4437
  return value;
4442
4438
  }
4443
4439
  return getPath(defaultData, key);
4444
- }
4445
- function deepExtend(target, source, overwrite) {
4440
+ };
4441
+ const deepExtend = (target, source, overwrite) => {
4446
4442
  for (const prop in source) {
4447
4443
  if (prop !== '__proto__' && prop !== 'constructor') {
4448
4444
  if (prop in target) {
@@ -4457,10 +4453,8 @@ function deepExtend(target, source, overwrite) {
4457
4453
  }
4458
4454
  }
4459
4455
  return target;
4460
- }
4461
- function regexEscape(str) {
4462
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
4463
- }
4456
+ };
4457
+ const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
4464
4458
  var _entityMap = {
4465
4459
  '&': '&amp;',
4466
4460
  '<': '&lt;',
@@ -4469,12 +4463,12 @@ var _entityMap = {
4469
4463
  "'": '&#39;',
4470
4464
  '/': '&#x2F;'
4471
4465
  };
4472
- function escape$1(data) {
4466
+ const escape$1 = data => {
4473
4467
  if (typeof data === 'string') {
4474
4468
  return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
4475
4469
  }
4476
4470
  return data;
4477
- }
4471
+ };
4478
4472
  class RegExpCache {
4479
4473
  constructor(capacity) {
4480
4474
  this.capacity = capacity;
@@ -4497,7 +4491,7 @@ class RegExpCache {
4497
4491
  }
4498
4492
  const chars = [' ', ',', '?', '!', ';'];
4499
4493
  const looksLikeObjectPathRegExpCache = new RegExpCache(20);
4500
- function looksLikeObjectPath(key, nsSeparator, keySeparator) {
4494
+ const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
4501
4495
  nsSeparator = nsSeparator || '';
4502
4496
  keySeparator = keySeparator || '';
4503
4497
  const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
@@ -4511,8 +4505,8 @@ function looksLikeObjectPath(key, nsSeparator, keySeparator) {
4511
4505
  }
4512
4506
  }
4513
4507
  return matched;
4514
- }
4515
- function deepFind(obj, path) {
4508
+ };
4509
+ const deepFind = function (obj, path) {
4516
4510
  let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
4517
4511
  if (!obj) return undefined;
4518
4512
  if (obj[path]) return obj[path];
@@ -4541,11 +4535,11 @@ function deepFind(obj, path) {
4541
4535
  current = next;
4542
4536
  }
4543
4537
  return current;
4544
- }
4545
- function getCleanedCode(code) {
4538
+ };
4539
+ const getCleanedCode = code => {
4546
4540
  if (code && code.indexOf('_') > 0) return code.replace('_', '-');
4547
4541
  return code;
4548
- }
4542
+ };
4549
4543
 
4550
4544
  class ResourceStore extends EventEmitter {
4551
4545
  constructor(data) {
@@ -5109,9 +5103,7 @@ class Translator extends EventEmitter {
5109
5103
  }
5110
5104
  }
5111
5105
 
5112
- function capitalize(string) {
5113
- return string.charAt(0).toUpperCase() + string.slice(1);
5114
- }
5106
+ const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1);
5115
5107
  class LanguageUtil {
5116
5108
  constructor(options) {
5117
5109
  this.options = options;
@@ -5316,72 +5308,28 @@ let sets = [{
5316
5308
  fc: 22
5317
5309
  }];
5318
5310
  let _rulesPluralsTypes = {
5319
- 1: function (n) {
5320
- return Number(n > 1);
5321
- },
5322
- 2: function (n) {
5323
- return Number(n != 1);
5324
- },
5325
- 3: function (n) {
5326
- return 0;
5327
- },
5328
- 4: function (n) {
5329
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
5330
- },
5331
- 5: function (n) {
5332
- return Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5);
5333
- },
5334
- 6: function (n) {
5335
- return Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2);
5336
- },
5337
- 7: function (n) {
5338
- return Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
5339
- },
5340
- 8: function (n) {
5341
- return Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3);
5342
- },
5343
- 9: function (n) {
5344
- return Number(n >= 2);
5345
- },
5346
- 10: function (n) {
5347
- return Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4);
5348
- },
5349
- 11: function (n) {
5350
- return Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3);
5351
- },
5352
- 12: function (n) {
5353
- return Number(n % 10 != 1 || n % 100 == 11);
5354
- },
5355
- 13: function (n) {
5356
- return Number(n !== 0);
5357
- },
5358
- 14: function (n) {
5359
- return Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3);
5360
- },
5361
- 15: function (n) {
5362
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2);
5363
- },
5364
- 16: function (n) {
5365
- return Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2);
5366
- },
5367
- 17: function (n) {
5368
- return Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1);
5369
- },
5370
- 18: function (n) {
5371
- return Number(n == 0 ? 0 : n == 1 ? 1 : 2);
5372
- },
5373
- 19: function (n) {
5374
- return Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3);
5375
- },
5376
- 20: function (n) {
5377
- return Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2);
5378
- },
5379
- 21: function (n) {
5380
- return Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0);
5381
- },
5382
- 22: function (n) {
5383
- return Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3);
5384
- }
5311
+ 1: n => Number(n > 1),
5312
+ 2: n => Number(n != 1),
5313
+ 3: n => 0,
5314
+ 4: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
5315
+ 5: n => Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5),
5316
+ 6: n => Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2),
5317
+ 7: n => Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
5318
+ 8: n => Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3),
5319
+ 9: n => Number(n >= 2),
5320
+ 10: n => Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4),
5321
+ 11: n => Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3),
5322
+ 12: n => Number(n % 10 != 1 || n % 100 == 11),
5323
+ 13: n => Number(n !== 0),
5324
+ 14: n => Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3),
5325
+ 15: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
5326
+ 16: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2),
5327
+ 17: n => Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1),
5328
+ 18: n => Number(n == 0 ? 0 : n == 1 ? 1 : 2),
5329
+ 19: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3),
5330
+ 20: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2),
5331
+ 21: n => Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0),
5332
+ 22: n => Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3)
5385
5333
  };
5386
5334
  const nonIntlVersions = ['v1', 'v2', 'v3'];
5387
5335
  const intlVersions = ['v4'];
@@ -5393,7 +5341,7 @@ const suffixesOrder = {
5393
5341
  many: 4,
5394
5342
  other: 5
5395
5343
  };
5396
- function createRules() {
5344
+ const createRules = () => {
5397
5345
  const rules = {};
5398
5346
  sets.forEach(set => {
5399
5347
  set.lngs.forEach(l => {
@@ -5404,7 +5352,7 @@ function createRules() {
5404
5352
  });
5405
5353
  });
5406
5354
  return rules;
5407
- }
5355
+ };
5408
5356
  class PluralResolver {
5409
5357
  constructor(languageUtils) {
5410
5358
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -5416,17 +5364,32 @@ class PluralResolver {
5416
5364
  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.');
5417
5365
  }
5418
5366
  this.rules = createRules();
5367
+ this.pluralRulesCache = {};
5419
5368
  }
5420
5369
  addRule(lng, obj) {
5421
5370
  this.rules[lng] = obj;
5422
5371
  }
5372
+ clearCache() {
5373
+ this.pluralRulesCache = {};
5374
+ }
5423
5375
  getRule(code) {
5424
5376
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
5425
5377
  if (this.shouldUseIntlApi()) {
5426
5378
  try {
5427
- return new Intl.PluralRules(getCleanedCode(code === 'dev' ? 'en' : code), {
5428
- type: options.ordinal ? 'ordinal' : 'cardinal'
5379
+ const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
5380
+ const type = options.ordinal ? 'ordinal' : 'cardinal';
5381
+ const cacheKey = JSON.stringify({
5382
+ cleanedCode,
5383
+ type
5384
+ });
5385
+ if (cacheKey in this.pluralRulesCache) {
5386
+ return this.pluralRulesCache[cacheKey];
5387
+ }
5388
+ const rule = new Intl.PluralRules(cleanedCode, {
5389
+ type
5429
5390
  });
5391
+ this.pluralRulesCache[cacheKey] = rule;
5392
+ return rule;
5430
5393
  } catch (err) {
5431
5394
  return;
5432
5395
  }
@@ -5495,7 +5458,7 @@ class PluralResolver {
5495
5458
  }
5496
5459
  }
5497
5460
 
5498
- function deepFindWithDefaults(data, defaultData, key) {
5461
+ const deepFindWithDefaults = function (data, defaultData, key) {
5499
5462
  let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
5500
5463
  let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
5501
5464
  let path = getPathWithDefaults(data, defaultData, key);
@@ -5504,7 +5467,8 @@ function deepFindWithDefaults(data, defaultData, key) {
5504
5467
  if (path === undefined) path = deepFind(defaultData, key, keySeparator);
5505
5468
  }
5506
5469
  return path;
5507
- }
5470
+ };
5471
+ const regexSafe = val => val.replace(/\$/g, '$$$$');
5508
5472
  class Interpolator {
5509
5473
  constructor() {
5510
5474
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -5572,9 +5536,6 @@ class Interpolator {
5572
5536
  let value;
5573
5537
  let replaces;
5574
5538
  const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
5575
- function regexSafe(val) {
5576
- return val.replace(/\$/g, '$$$$');
5577
- }
5578
5539
  const handleFormat = key => {
5579
5540
  if (key.indexOf(this.formatSeparator) < 0) {
5580
5541
  const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
@@ -5645,7 +5606,7 @@ class Interpolator {
5645
5606
  let match;
5646
5607
  let value;
5647
5608
  let clonedOptions;
5648
- function handleHasOptions(key, inheritedOptions) {
5609
+ const handleHasOptions = (key, inheritedOptions) => {
5649
5610
  const sep = this.nestingOptionsSeparator;
5650
5611
  if (key.indexOf(sep) < 0) return key;
5651
5612
  const c = key.split(new RegExp(`${sep}[ ]*{`));
@@ -5669,7 +5630,7 @@ class Interpolator {
5669
5630
  }
5670
5631
  if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
5671
5632
  return key;
5672
- }
5633
+ };
5673
5634
  while (match = this.nestingRegexp.exec(str)) {
5674
5635
  let formatters = [];
5675
5636
  clonedOptions = {
@@ -5705,7 +5666,7 @@ class Interpolator {
5705
5666
  }
5706
5667
  }
5707
5668
 
5708
- function parseFormatStr(formatStr) {
5669
+ const parseFormatStr = formatStr => {
5709
5670
  let formatName = formatStr.toLowerCase().trim();
5710
5671
  const formatOptions = {};
5711
5672
  if (formatStr.indexOf('(') > -1) {
@@ -5735,11 +5696,18 @@ function parseFormatStr(formatStr) {
5735
5696
  formatName,
5736
5697
  formatOptions
5737
5698
  };
5738
- }
5739
- function createCachedFormatter(fn) {
5699
+ };
5700
+ const createCachedFormatter = fn => {
5740
5701
  const cache = {};
5741
- return function invokeFormatter(val, lng, options) {
5742
- const key = lng + JSON.stringify(options);
5702
+ return (val, lng, options) => {
5703
+ let optForCache = options;
5704
+ if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
5705
+ optForCache = {
5706
+ ...optForCache,
5707
+ [options.interpolationkey]: undefined
5708
+ };
5709
+ }
5710
+ const key = lng + JSON.stringify(optForCache);
5743
5711
  let formatter = cache[key];
5744
5712
  if (!formatter) {
5745
5713
  formatter = fn(getCleanedCode(lng), options);
@@ -5747,7 +5715,7 @@ function createCachedFormatter(fn) {
5747
5715
  }
5748
5716
  return formatter(val);
5749
5717
  };
5750
- }
5718
+ };
5751
5719
  class Formatter {
5752
5720
  constructor() {
5753
5721
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -5804,6 +5772,10 @@ class Formatter {
5804
5772
  format(value, format, lng) {
5805
5773
  let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
5806
5774
  const formats = format.split(this.formatSeparator);
5775
+ if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
5776
+ const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
5777
+ formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
5778
+ }
5807
5779
  const result = formats.reduce((mem, f) => {
5808
5780
  const {
5809
5781
  formatName,
@@ -5832,12 +5804,12 @@ class Formatter {
5832
5804
  }
5833
5805
  }
5834
5806
 
5835
- function removePending(q, name) {
5807
+ const removePending = (q, name) => {
5836
5808
  if (q.pending[name] !== undefined) {
5837
5809
  delete q.pending[name];
5838
5810
  q.pendingCount--;
5839
5811
  }
5840
- }
5812
+ };
5841
5813
  class Connector extends EventEmitter {
5842
5814
  constructor(backend, store, services) {
5843
5815
  let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
@@ -5903,12 +5875,13 @@ class Connector extends EventEmitter {
5903
5875
  const lng = s[0];
5904
5876
  const ns = s[1];
5905
5877
  if (err) this.emit('failedLoading', lng, ns, err);
5906
- if (data) {
5878
+ if (!err && data) {
5907
5879
  this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
5908
5880
  skipCopy: true
5909
5881
  });
5910
5882
  }
5911
5883
  this.state[name] = err ? -1 : 2;
5884
+ if (err && data) this.state[name] = 0;
5912
5885
  const loaded = {};
5913
5886
  this.queue.forEach(q => {
5914
5887
  pushPath(q.loaded, [lng], ns);
@@ -6058,69 +6031,67 @@ class Connector extends EventEmitter {
6058
6031
  }
6059
6032
  }
6060
6033
 
6061
- function get() {
6062
- return {
6063
- debug: false,
6064
- initImmediate: true,
6065
- ns: ['translation'],
6066
- defaultNS: ['translation'],
6067
- fallbackLng: ['dev'],
6068
- fallbackNS: false,
6069
- supportedLngs: false,
6070
- nonExplicitSupportedLngs: false,
6071
- load: 'all',
6072
- preload: false,
6073
- simplifyPluralSuffix: true,
6074
- keySeparator: '.',
6075
- nsSeparator: ':',
6076
- pluralSeparator: '_',
6077
- contextSeparator: '_',
6078
- partialBundledLanguages: false,
6079
- saveMissing: false,
6080
- updateMissing: false,
6081
- saveMissingTo: 'fallback',
6082
- saveMissingPlurals: true,
6083
- missingKeyHandler: false,
6084
- missingInterpolationHandler: false,
6085
- postProcess: false,
6086
- postProcessPassResolved: false,
6087
- returnNull: false,
6088
- returnEmptyString: true,
6089
- returnObjects: false,
6090
- joinArrays: false,
6091
- returnedObjectHandler: false,
6092
- parseMissingKeyHandler: false,
6093
- appendNamespaceToMissingKey: false,
6094
- appendNamespaceToCIMode: false,
6095
- overloadTranslationOptionHandler: function handle(args) {
6096
- let ret = {};
6097
- if (typeof args[1] === 'object') ret = args[1];
6098
- if (typeof args[1] === 'string') ret.defaultValue = args[1];
6099
- if (typeof args[2] === 'string') ret.tDescription = args[2];
6100
- if (typeof args[2] === 'object' || typeof args[3] === 'object') {
6101
- const options = args[3] || args[2];
6102
- Object.keys(options).forEach(key => {
6103
- ret[key] = options[key];
6104
- });
6105
- }
6106
- return ret;
6107
- },
6108
- interpolation: {
6109
- escapeValue: true,
6110
- format: value => value,
6111
- prefix: '{{',
6112
- suffix: '}}',
6113
- formatSeparator: ',',
6114
- unescapePrefix: '-',
6115
- nestingPrefix: '$t(',
6116
- nestingSuffix: ')',
6117
- nestingOptionsSeparator: ',',
6118
- maxReplaces: 1000,
6119
- skipOnVariables: true
6034
+ const get = () => ({
6035
+ debug: false,
6036
+ initImmediate: true,
6037
+ ns: ['translation'],
6038
+ defaultNS: ['translation'],
6039
+ fallbackLng: ['dev'],
6040
+ fallbackNS: false,
6041
+ supportedLngs: false,
6042
+ nonExplicitSupportedLngs: false,
6043
+ load: 'all',
6044
+ preload: false,
6045
+ simplifyPluralSuffix: true,
6046
+ keySeparator: '.',
6047
+ nsSeparator: ':',
6048
+ pluralSeparator: '_',
6049
+ contextSeparator: '_',
6050
+ partialBundledLanguages: false,
6051
+ saveMissing: false,
6052
+ updateMissing: false,
6053
+ saveMissingTo: 'fallback',
6054
+ saveMissingPlurals: true,
6055
+ missingKeyHandler: false,
6056
+ missingInterpolationHandler: false,
6057
+ postProcess: false,
6058
+ postProcessPassResolved: false,
6059
+ returnNull: false,
6060
+ returnEmptyString: true,
6061
+ returnObjects: false,
6062
+ joinArrays: false,
6063
+ returnedObjectHandler: false,
6064
+ parseMissingKeyHandler: false,
6065
+ appendNamespaceToMissingKey: false,
6066
+ appendNamespaceToCIMode: false,
6067
+ overloadTranslationOptionHandler: args => {
6068
+ let ret = {};
6069
+ if (typeof args[1] === 'object') ret = args[1];
6070
+ if (typeof args[1] === 'string') ret.defaultValue = args[1];
6071
+ if (typeof args[2] === 'string') ret.tDescription = args[2];
6072
+ if (typeof args[2] === 'object' || typeof args[3] === 'object') {
6073
+ const options = args[3] || args[2];
6074
+ Object.keys(options).forEach(key => {
6075
+ ret[key] = options[key];
6076
+ });
6120
6077
  }
6121
- };
6122
- }
6123
- function transformOptions(options) {
6078
+ return ret;
6079
+ },
6080
+ interpolation: {
6081
+ escapeValue: true,
6082
+ format: value => value,
6083
+ prefix: '{{',
6084
+ suffix: '}}',
6085
+ formatSeparator: ',',
6086
+ unescapePrefix: '-',
6087
+ nestingPrefix: '$t(',
6088
+ nestingSuffix: ')',
6089
+ nestingOptionsSeparator: ',',
6090
+ maxReplaces: 1000,
6091
+ skipOnVariables: true
6092
+ }
6093
+ });
6094
+ const transformOptions = options => {
6124
6095
  if (typeof options.ns === 'string') options.ns = [options.ns];
6125
6096
  if (typeof options.fallbackLng === 'string') options.fallbackLng = [options.fallbackLng];
6126
6097
  if (typeof options.fallbackNS === 'string') options.fallbackNS = [options.fallbackNS];
@@ -6128,17 +6099,17 @@ function transformOptions(options) {
6128
6099
  options.supportedLngs = options.supportedLngs.concat(['cimode']);
6129
6100
  }
6130
6101
  return options;
6131
- }
6102
+ };
6132
6103
 
6133
- function noop() {}
6134
- function bindMemberFunctions(inst) {
6104
+ const noop = () => {};
6105
+ const bindMemberFunctions = inst => {
6135
6106
  const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
6136
6107
  mems.forEach(mem => {
6137
6108
  if (typeof inst[mem] === 'function') {
6138
6109
  inst[mem] = inst[mem].bind(inst);
6139
6110
  }
6140
6111
  });
6141
- }
6112
+ };
6142
6113
  class I18n extends EventEmitter {
6143
6114
  constructor() {
6144
6115
  let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -6195,11 +6166,11 @@ class I18n extends EventEmitter {
6195
6166
  if (options.nsSeparator !== undefined) {
6196
6167
  this.options.userDefinedNsSeparator = options.nsSeparator;
6197
6168
  }
6198
- function createClassOnDemand(ClassOrObject) {
6169
+ const createClassOnDemand = ClassOrObject => {
6199
6170
  if (!ClassOrObject) return null;
6200
6171
  if (typeof ClassOrObject === 'function') return new ClassOrObject();
6201
6172
  return ClassOrObject;
6202
- }
6173
+ };
6203
6174
  if (!this.options.isClone) {
6204
6175
  if (this.modules.logger) {
6205
6176
  baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
@@ -6337,6 +6308,14 @@ class I18n extends EventEmitter {
6337
6308
  }
6338
6309
  reloadResources(lngs, ns, callback) {
6339
6310
  const deferred = defer();
6311
+ if (typeof lngs === 'function') {
6312
+ callback = lngs;
6313
+ lngs = undefined;
6314
+ }
6315
+ if (typeof ns === 'function') {
6316
+ callback = ns;
6317
+ ns = undefined;
6318
+ }
6340
6319
  if (!lngs) lngs = this.languages;
6341
6320
  if (!ns) ns = this.options.ns;
6342
6321
  if (!callback) callback = noop;
@@ -6500,7 +6479,7 @@ class I18n extends EventEmitter {
6500
6479
  if (lng.toLowerCase() === 'cimode') return true;
6501
6480
  const loadNotPending = (l, n) => {
6502
6481
  const loadState = this.services.backendConnector.state[`${l}|${n}`];
6503
- return loadState === -1 || loadState === 2;
6482
+ return loadState === -1 || loadState === 0 || loadState === 2;
6504
6483
  };
6505
6484
  if (options.precheck) {
6506
6485
  const preResult = options.precheck(this, loadNotPending);
@@ -15344,6 +15323,9 @@ const size = function (options) {
15344
15323
  };
15345
15324
  };
15346
15325
 
15326
+ function hasWindow() {
15327
+ return typeof window !== 'undefined';
15328
+ }
15347
15329
  function getNodeName(node) {
15348
15330
  if (isNode(node)) {
15349
15331
  return (node.nodeName || '').toLowerCase();
@@ -15362,17 +15344,25 @@ function getDocumentElement(node) {
15362
15344
  return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
15363
15345
  }
15364
15346
  function isNode(value) {
15347
+ if (!hasWindow()) {
15348
+ return false;
15349
+ }
15365
15350
  return value instanceof Node || value instanceof getWindow(value).Node;
15366
15351
  }
15367
15352
  function isElement(value) {
15353
+ if (!hasWindow()) {
15354
+ return false;
15355
+ }
15368
15356
  return value instanceof Element || value instanceof getWindow(value).Element;
15369
15357
  }
15370
15358
  function isHTMLElement(value) {
15359
+ if (!hasWindow()) {
15360
+ return false;
15361
+ }
15371
15362
  return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
15372
15363
  }
15373
15364
  function isShadowRoot(value) {
15374
- // Browsers without `ShadowRoot` support.
15375
- if (typeof ShadowRoot === 'undefined') {
15365
+ if (!hasWindow() || typeof ShadowRoot === 'undefined') {
15376
15366
  return false;
15377
15367
  }
15378
15368
  return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
@@ -15482,7 +15472,7 @@ function getOverflowAncestors(node, list, traverseIframes) {
15482
15472
  return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
15483
15473
  }
15484
15474
  function getFrameElement(win) {
15485
- return Object.getPrototypeOf(win.parent) ? win.frameElement : null;
15475
+ return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
15486
15476
  }
15487
15477
 
15488
15478
  function getCssDimensions(element) {
@@ -15655,10 +15645,14 @@ function getClientRects(element) {
15655
15645
  return Array.from(element.getClientRects());
15656
15646
  }
15657
15647
 
15658
- function getWindowScrollBarX(element) {
15659
- // If <html> has a CSS width greater than the viewport, then this will be
15660
- // incorrect for RTL.
15661
- return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
15648
+ // If <html> has a CSS width greater than the viewport, then this will be
15649
+ // incorrect for RTL.
15650
+ function getWindowScrollBarX(element, rect) {
15651
+ const leftScroll = getNodeScroll(element).scrollLeft;
15652
+ if (!rect) {
15653
+ return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
15654
+ }
15655
+ return rect.left + leftScroll;
15662
15656
  }
15663
15657
 
15664
15658
  // Gets the entire size of the scrollable document area, even extending outside
@@ -15842,11 +15836,22 @@ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
15842
15836
  offsets.x = offsetRect.x + offsetParent.clientLeft;
15843
15837
  offsets.y = offsetRect.y + offsetParent.clientTop;
15844
15838
  } else if (documentElement) {
15839
+ // If the <body> scrollbar appears on the left (e.g. RTL systems). Use
15840
+ // Firefox with layout.scrollbar.side = 3 in about:config to test this.
15845
15841
  offsets.x = getWindowScrollBarX(documentElement);
15846
15842
  }
15847
15843
  }
15848
- const x = rect.left + scroll.scrollLeft - offsets.x;
15849
- const y = rect.top + scroll.scrollTop - offsets.y;
15844
+ let htmlX = 0;
15845
+ let htmlY = 0;
15846
+ if (documentElement && !isOffsetParentAnElement && !isFixed) {
15847
+ const htmlRect = documentElement.getBoundingClientRect();
15848
+ htmlY = htmlRect.top + scroll.scrollTop;
15849
+ htmlX = htmlRect.left + scroll.scrollLeft -
15850
+ // RTL <body> scrollbar.
15851
+ getWindowScrollBarX(documentElement, htmlRect);
15852
+ }
15853
+ const x = rect.left + scroll.scrollLeft - offsets.x - htmlX;
15854
+ const y = rect.top + scroll.scrollTop - offsets.y - htmlY;
15850
15855
  return {
15851
15856
  x,
15852
15857
  y,
@@ -15866,7 +15871,16 @@ function getTrueOffsetParent(element, polyfill) {
15866
15871
  if (polyfill) {
15867
15872
  return polyfill(element);
15868
15873
  }
15869
- return element.offsetParent;
15874
+ let rawOffsetParent = element.offsetParent;
15875
+
15876
+ // Firefox returns the <html> element as the offsetParent if it's non-static,
15877
+ // while Chrome and Safari return the <body> element. The <body> element must
15878
+ // be used to perform the correct calculations even if the <html> element is
15879
+ // non-static.
15880
+ if (getDocumentElement(element) === rawOffsetParent) {
15881
+ rawOffsetParent = rawOffsetParent.ownerDocument.body;
15882
+ }
15883
+ return rawOffsetParent;
15870
15884
  }
15871
15885
 
15872
15886
  // Gets the closest ancestor positioned element. Handles some edge cases,