@forsakringskassan/docs-generator 2.28.0 → 2.28.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.
@@ -24151,8 +24151,7 @@ const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
24151
24151
  }
24152
24152
  return matched;
24153
24153
  };
24154
- const deepFind = function (obj, path) {
24155
- let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
24154
+ const deepFind = (obj, path, keySeparator = '.') => {
24156
24155
  if (!obj) return undefined;
24157
24156
  if (obj[path]) {
24158
24157
  if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined;
@@ -24202,39 +24201,25 @@ const consoleLogger = {
24202
24201
  }
24203
24202
  };
24204
24203
  class Logger {
24205
- constructor(concreteLogger) {
24206
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24204
+ constructor(concreteLogger, options = {}) {
24207
24205
  this.init(concreteLogger, options);
24208
24206
  }
24209
- init(concreteLogger) {
24210
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24207
+ init(concreteLogger, options = {}) {
24211
24208
  this.prefix = options.prefix || 'i18next:';
24212
24209
  this.logger = concreteLogger || consoleLogger;
24213
24210
  this.options = options;
24214
24211
  this.debug = options.debug;
24215
24212
  }
24216
- log() {
24217
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24218
- args[_key] = arguments[_key];
24219
- }
24213
+ log(...args) {
24220
24214
  return this.forward(args, 'log', '', true);
24221
24215
  }
24222
- warn() {
24223
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
24224
- args[_key2] = arguments[_key2];
24225
- }
24216
+ warn(...args) {
24226
24217
  return this.forward(args, 'warn', '', true);
24227
24218
  }
24228
- error() {
24229
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
24230
- args[_key3] = arguments[_key3];
24231
- }
24219
+ error(...args) {
24232
24220
  return this.forward(args, 'error', '');
24233
24221
  }
24234
- deprecate() {
24235
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
24236
- args[_key4] = arguments[_key4];
24237
- }
24222
+ deprecate(...args) {
24238
24223
  return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
24239
24224
  }
24240
24225
  forward(args, lvl, prefix, debugOnly) {
@@ -24278,14 +24263,10 @@ class EventEmitter {
24278
24263
  }
24279
24264
  this.observers[event].delete(listener);
24280
24265
  }
24281
- emit(event) {
24282
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
24283
- args[_key - 1] = arguments[_key];
24284
- }
24266
+ emit(event, ...args) {
24285
24267
  if (this.observers[event]) {
24286
24268
  const cloned = Array.from(this.observers[event].entries());
24287
- cloned.forEach(_ref => {
24288
- let [observer, numTimesAdded] = _ref;
24269
+ cloned.forEach(([observer, numTimesAdded]) => {
24289
24270
  for (let i = 0; i < numTimesAdded; i++) {
24290
24271
  observer(...args);
24291
24272
  }
@@ -24293,8 +24274,7 @@ class EventEmitter {
24293
24274
  }
24294
24275
  if (this.observers['*']) {
24295
24276
  const cloned = Array.from(this.observers['*'].entries());
24296
- cloned.forEach(_ref2 => {
24297
- let [observer, numTimesAdded] = _ref2;
24277
+ cloned.forEach(([observer, numTimesAdded]) => {
24298
24278
  for (let i = 0; i < numTimesAdded; i++) {
24299
24279
  observer.apply(observer, [event, ...args]);
24300
24280
  }
@@ -24304,11 +24284,10 @@ class EventEmitter {
24304
24284
  }
24305
24285
 
24306
24286
  class ResourceStore extends EventEmitter {
24307
- constructor(data) {
24308
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
24309
- ns: ['translation'],
24310
- defaultNS: 'translation'
24311
- };
24287
+ constructor(data, options = {
24288
+ ns: ['translation'],
24289
+ defaultNS: 'translation'
24290
+ }) {
24312
24291
  super();
24313
24292
  this.data = data || {};
24314
24293
  this.options = options;
@@ -24330,8 +24309,7 @@ class ResourceStore extends EventEmitter {
24330
24309
  this.options.ns.splice(index, 1);
24331
24310
  }
24332
24311
  }
24333
- getResource(lng, ns, key) {
24334
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
24312
+ getResource(lng, ns, key, options = {}) {
24335
24313
  const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
24336
24314
  const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
24337
24315
  let path;
@@ -24358,10 +24336,9 @@ class ResourceStore extends EventEmitter {
24358
24336
  if (result || !ignoreJSONStructure || !isString(key)) return result;
24359
24337
  return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
24360
24338
  }
24361
- addResource(lng, ns, key, value) {
24362
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
24363
- silent: false
24364
- };
24339
+ addResource(lng, ns, key, value, options = {
24340
+ silent: false
24341
+ }) {
24365
24342
  const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
24366
24343
  let path = [lng, ns];
24367
24344
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
@@ -24374,10 +24351,9 @@ class ResourceStore extends EventEmitter {
24374
24351
  setPath(this.data, path, value);
24375
24352
  if (!options.silent) this.emit('added', lng, ns, key, value);
24376
24353
  }
24377
- addResources(lng, ns, resources) {
24378
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
24379
- silent: false
24380
- };
24354
+ addResources(lng, ns, resources, options = {
24355
+ silent: false
24356
+ }) {
24381
24357
  for (const m in resources) {
24382
24358
  if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
24383
24359
  silent: true
@@ -24385,11 +24361,10 @@ class ResourceStore extends EventEmitter {
24385
24361
  }
24386
24362
  if (!options.silent) this.emit('added', lng, ns, resources);
24387
24363
  }
24388
- addResourceBundle(lng, ns, resources, deep, overwrite) {
24389
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
24390
- silent: false,
24391
- skipCopy: false
24392
- };
24364
+ addResourceBundle(lng, ns, resources, deep, overwrite, options = {
24365
+ silent: false,
24366
+ skipCopy: false
24367
+ }) {
24393
24368
  let path = [lng, ns];
24394
24369
  if (lng.indexOf('.') > -1) {
24395
24370
  path = lng.split('.');
@@ -24454,8 +24429,7 @@ var postProcessor = {
24454
24429
  const checkedLoadedFor = {};
24455
24430
  const shouldHandleAsObject = res => !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
24456
24431
  class Translator extends EventEmitter {
24457
- constructor(services) {
24458
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24432
+ constructor(services, options = {}) {
24459
24433
  super();
24460
24434
  copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
24461
24435
  this.options = options;
@@ -24467,10 +24441,9 @@ class Translator extends EventEmitter {
24467
24441
  changeLanguage(lng) {
24468
24442
  if (lng) this.language = lng;
24469
24443
  }
24470
- exists(key) {
24471
- let o = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
24472
- interpolation: {}
24473
- };
24444
+ exists(key, o = {
24445
+ interpolation: {}
24446
+ }) {
24474
24447
  const opt = {
24475
24448
  ...o
24476
24449
  };
@@ -24522,11 +24495,12 @@ class Translator extends EventEmitter {
24522
24495
  namespaces
24523
24496
  } = this.extractFromKey(keys[keys.length - 1], opt);
24524
24497
  const namespace = namespaces[namespaces.length - 1];
24498
+ let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
24499
+ if (nsSeparator === undefined) nsSeparator = ':';
24525
24500
  const lng = opt.lng || this.language;
24526
24501
  const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
24527
24502
  if (lng?.toLowerCase() === 'cimode') {
24528
24503
  if (appendNamespaceToCIMode) {
24529
- const nsSeparator = opt.nsSeparator || this.options.nsSeparator;
24530
24504
  if (returnDetails) {
24531
24505
  return {
24532
24506
  res: `${namespace}${nsSeparator}${key}`,
@@ -24681,9 +24655,11 @@ class Translator extends EventEmitter {
24681
24655
  }
24682
24656
  }
24683
24657
  res = this.extendTranslation(res, keys, opt, resolved, lastKey);
24684
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
24658
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
24659
+ res = `${namespace}${nsSeparator}${key}`;
24660
+ }
24685
24661
  if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
24686
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined, opt);
24662
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : undefined, opt);
24687
24663
  }
24688
24664
  }
24689
24665
  if (returnDetails) {
@@ -24694,7 +24670,6 @@ class Translator extends EventEmitter {
24694
24670
  return res;
24695
24671
  }
24696
24672
  extendTranslation(res, key, opt, resolved, lastKey) {
24697
- var _this = this;
24698
24673
  if (this.i18nFormat?.parse) {
24699
24674
  res = this.i18nFormat.parse(res, {
24700
24675
  ...this.options.interpolation.defaultVariables,
@@ -24730,15 +24705,12 @@ class Translator extends EventEmitter {
24730
24705
  if (nestBef < nestAft) opt.nest = false;
24731
24706
  }
24732
24707
  if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
24733
- if (opt.nest !== false) res = this.interpolator.nest(res, function () {
24734
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
24735
- args[_key] = arguments[_key];
24736
- }
24708
+ if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
24737
24709
  if (lastKey?.[0] === args[0] && !opt.context) {
24738
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
24710
+ this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
24739
24711
  return null;
24740
24712
  }
24741
- return _this.translate(...args, key);
24713
+ return this.translate(...args, key);
24742
24714
  }, opt);
24743
24715
  if (opt.interpolation) this.interpolator.reset();
24744
24716
  }
@@ -24755,8 +24727,7 @@ class Translator extends EventEmitter {
24755
24727
  }
24756
24728
  return res;
24757
24729
  }
24758
- resolve(keys) {
24759
- let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24730
+ resolve(keys, opt = {}) {
24760
24731
  let found;
24761
24732
  let usedKey;
24762
24733
  let exactUsedKey;
@@ -24836,13 +24807,11 @@ class Translator extends EventEmitter {
24836
24807
  isValidLookup(res) {
24837
24808
  return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
24838
24809
  }
24839
- getResource(code, ns, key) {
24840
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
24810
+ getResource(code, ns, key, options = {}) {
24841
24811
  if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
24842
24812
  return this.resourceStore.getResource(code, ns, key, options);
24843
24813
  }
24844
- getUsedParamsDetails() {
24845
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
24814
+ getUsedParamsDetails(options = {}) {
24846
24815
  const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
24847
24816
  const useOptionsReplaceForData = options.replace && !isString(options.replace);
24848
24817
  let data = useOptionsReplaceForData ? options.replace : options;
@@ -24999,8 +24968,7 @@ const dummyRule = {
24999
24968
  })
25000
24969
  };
25001
24970
  class PluralResolver {
25002
- constructor(languageUtils) {
25003
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24971
+ constructor(languageUtils, options = {}) {
25004
24972
  this.languageUtils = languageUtils;
25005
24973
  this.options = options;
25006
24974
  this.logger = baseLogger.create('pluralResolver');
@@ -25012,8 +24980,7 @@ class PluralResolver {
25012
24980
  clearCache() {
25013
24981
  this.pluralRulesCache = {};
25014
24982
  }
25015
- getRule(code) {
25016
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
24983
+ getRule(code, options = {}) {
25017
24984
  const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
25018
24985
  const type = options.ordinal ? 'ordinal' : 'cardinal';
25019
24986
  const cacheKey = JSON.stringify({
@@ -25040,25 +25007,21 @@ class PluralResolver {
25040
25007
  this.pluralRulesCache[cacheKey] = rule;
25041
25008
  return rule;
25042
25009
  }
25043
- needsPlural(code) {
25044
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25010
+ needsPlural(code, options = {}) {
25045
25011
  let rule = this.getRule(code, options);
25046
25012
  if (!rule) rule = this.getRule('dev', options);
25047
25013
  return rule?.resolvedOptions().pluralCategories.length > 1;
25048
25014
  }
25049
- getPluralFormsOfKey(code, key) {
25050
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
25015
+ getPluralFormsOfKey(code, key, options = {}) {
25051
25016
  return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
25052
25017
  }
25053
- getSuffixes(code) {
25054
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
25018
+ getSuffixes(code, options = {}) {
25055
25019
  let rule = this.getRule(code, options);
25056
25020
  if (!rule) rule = this.getRule('dev', options);
25057
25021
  if (!rule) return [];
25058
25022
  return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
25059
25023
  }
25060
- getSuffix(code, count) {
25061
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
25024
+ getSuffix(code, count, options = {}) {
25062
25025
  const rule = this.getRule(code, options);
25063
25026
  if (rule) {
25064
25027
  return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
@@ -25068,9 +25031,7 @@ class PluralResolver {
25068
25031
  }
25069
25032
  }
25070
25033
 
25071
- const deepFindWithDefaults = function (data, defaultData, key) {
25072
- let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
25073
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
25034
+ const deepFindWithDefaults = (data, defaultData, key, keySeparator = '.', ignoreJSONStructure = true) => {
25074
25035
  let path = getPathWithDefaults(data, defaultData, key);
25075
25036
  if (!path && ignoreJSONStructure && isString(key)) {
25076
25037
  path = deepFind(data, key, keySeparator);
@@ -25080,15 +25041,13 @@ const deepFindWithDefaults = function (data, defaultData, key) {
25080
25041
  };
25081
25042
  const regexSafe = val => val.replace(/\$/g, '$$$$');
25082
25043
  class Interpolator {
25083
- constructor() {
25084
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25044
+ constructor(options = {}) {
25085
25045
  this.logger = baseLogger.create('interpolator');
25086
25046
  this.options = options;
25087
25047
  this.format = options?.interpolation?.format || (value => value);
25088
25048
  this.init(options);
25089
25049
  }
25090
- init() {
25091
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25050
+ init(options = {}) {
25092
25051
  if (!options.interpolation) options.interpolation = {
25093
25052
  escapeValue: true
25094
25053
  };
@@ -25211,8 +25170,7 @@ class Interpolator {
25211
25170
  });
25212
25171
  return str;
25213
25172
  }
25214
- nest(str, fc) {
25215
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
25173
+ nest(str, fc, options = {}) {
25216
25174
  let match;
25217
25175
  let value;
25218
25176
  let clonedOptions;
@@ -25309,68 +25267,68 @@ const parseFormatStr = formatStr => {
25309
25267
  };
25310
25268
  const createCachedFormatter = fn => {
25311
25269
  const cache = {};
25312
- return (val, lng, options) => {
25313
- let optForCache = options;
25314
- if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
25270
+ return (v, l, o) => {
25271
+ let optForCache = o;
25272
+ if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
25315
25273
  optForCache = {
25316
25274
  ...optForCache,
25317
- [options.interpolationkey]: undefined
25275
+ [o.interpolationkey]: undefined
25318
25276
  };
25319
25277
  }
25320
- const key = lng + JSON.stringify(optForCache);
25321
- let formatter = cache[key];
25322
- if (!formatter) {
25323
- formatter = fn(getCleanedCode(lng), options);
25324
- cache[key] = formatter;
25278
+ const key = l + JSON.stringify(optForCache);
25279
+ let frm = cache[key];
25280
+ if (!frm) {
25281
+ frm = fn(getCleanedCode(l), o);
25282
+ cache[key] = frm;
25325
25283
  }
25326
- return formatter(val);
25284
+ return frm(v);
25327
25285
  };
25328
25286
  };
25287
+ const createNonCachedFormatter = fn => (v, l, o) => fn(getCleanedCode(l), o)(v);
25329
25288
  class Formatter {
25330
- constructor() {
25331
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25289
+ constructor(options = {}) {
25332
25290
  this.logger = baseLogger.create('formatter');
25333
25291
  this.options = options;
25292
+ this.init(options);
25293
+ }
25294
+ init(services, options = {
25295
+ interpolation: {}
25296
+ }) {
25297
+ this.formatSeparator = options.interpolation.formatSeparator || ',';
25298
+ const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
25334
25299
  this.formats = {
25335
- number: createCachedFormatter((lng, opt) => {
25300
+ number: cf((lng, opt) => {
25336
25301
  const formatter = new Intl.NumberFormat(lng, {
25337
25302
  ...opt
25338
25303
  });
25339
25304
  return val => formatter.format(val);
25340
25305
  }),
25341
- currency: createCachedFormatter((lng, opt) => {
25306
+ currency: cf((lng, opt) => {
25342
25307
  const formatter = new Intl.NumberFormat(lng, {
25343
25308
  ...opt,
25344
25309
  style: 'currency'
25345
25310
  });
25346
25311
  return val => formatter.format(val);
25347
25312
  }),
25348
- datetime: createCachedFormatter((lng, opt) => {
25313
+ datetime: cf((lng, opt) => {
25349
25314
  const formatter = new Intl.DateTimeFormat(lng, {
25350
25315
  ...opt
25351
25316
  });
25352
25317
  return val => formatter.format(val);
25353
25318
  }),
25354
- relativetime: createCachedFormatter((lng, opt) => {
25319
+ relativetime: cf((lng, opt) => {
25355
25320
  const formatter = new Intl.RelativeTimeFormat(lng, {
25356
25321
  ...opt
25357
25322
  });
25358
25323
  return val => formatter.format(val, opt.range || 'day');
25359
25324
  }),
25360
- list: createCachedFormatter((lng, opt) => {
25325
+ list: cf((lng, opt) => {
25361
25326
  const formatter = new Intl.ListFormat(lng, {
25362
25327
  ...opt
25363
25328
  });
25364
25329
  return val => formatter.format(val);
25365
25330
  })
25366
25331
  };
25367
- this.init(options);
25368
- }
25369
- init(services) {
25370
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
25371
- interpolation: {}
25372
- };
25373
- this.formatSeparator = options.interpolation.formatSeparator || ',';
25374
25332
  }
25375
25333
  add(name, fc) {
25376
25334
  this.formats[name.toLowerCase().trim()] = fc;
@@ -25378,8 +25336,7 @@ class Formatter {
25378
25336
  addCached(name, fc) {
25379
25337
  this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
25380
25338
  }
25381
- format(value, format, lng) {
25382
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
25339
+ format(value, format, lng, options = {}) {
25383
25340
  const formats = format.split(this.formatSeparator);
25384
25341
  if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
25385
25342
  const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
@@ -25420,8 +25377,7 @@ const removePending = (q, name) => {
25420
25377
  }
25421
25378
  };
25422
25379
  class Connector extends EventEmitter {
25423
- constructor(backend, store, services) {
25424
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
25380
+ constructor(backend, store, services, options = {}) {
25425
25381
  super();
25426
25382
  this.backend = backend;
25427
25383
  this.store = store;
@@ -25515,10 +25471,7 @@ class Connector extends EventEmitter {
25515
25471
  this.emit('loaded', loaded);
25516
25472
  this.queue = this.queue.filter(q => !q.done);
25517
25473
  }
25518
- read(lng, ns, fcName) {
25519
- let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
25520
- let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
25521
- let callback = arguments.length > 5 ? arguments[5] : undefined;
25474
+ read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
25522
25475
  if (!lng.length) return callback(null, {});
25523
25476
  if (this.readingCalls >= this.maxParallelReads) {
25524
25477
  this.waitingReads.push({
@@ -25562,9 +25515,7 @@ class Connector extends EventEmitter {
25562
25515
  }
25563
25516
  return fc(lng, ns, resolver);
25564
25517
  }
25565
- prepareLoading(languages, namespaces) {
25566
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
25567
- let callback = arguments.length > 3 ? arguments[3] : undefined;
25518
+ prepareLoading(languages, namespaces, options = {}, callback) {
25568
25519
  if (!this.backend) {
25569
25520
  this.logger.warn('No backend was added via i18next.use. Will not load resources.');
25570
25521
  return callback && callback();
@@ -25588,8 +25539,7 @@ class Connector extends EventEmitter {
25588
25539
  reload: true
25589
25540
  }, callback);
25590
25541
  }
25591
- loadOne(name) {
25592
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
25542
+ loadOne(name, prefix = '') {
25593
25543
  const s = name.split('|');
25594
25544
  const lng = s[0];
25595
25545
  const ns = s[1];
@@ -25599,9 +25549,7 @@ class Connector extends EventEmitter {
25599
25549
  this.loaded(name, err, data);
25600
25550
  });
25601
25551
  }
25602
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
25603
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
25604
- let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
25552
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}) {
25605
25553
  if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
25606
25554
  this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
25607
25555
  return;
@@ -25696,7 +25644,8 @@ const get$1 = () => ({
25696
25644
  nestingOptionsSeparator: ',',
25697
25645
  maxReplaces: 1000,
25698
25646
  skipOnVariables: true
25699
- }
25647
+ },
25648
+ cacheInBuiltFormats: true
25700
25649
  });
25701
25650
  const transformOptions = options => {
25702
25651
  if (isString(options.ns)) options.ns = [options.ns];
@@ -25719,9 +25668,7 @@ const bindMemberFunctions = inst => {
25719
25668
  });
25720
25669
  };
25721
25670
  class I18n extends EventEmitter {
25722
- constructor() {
25723
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25724
- let callback = arguments.length > 1 ? arguments[1] : undefined;
25671
+ constructor(options = {}, callback) {
25725
25672
  super();
25726
25673
  this.options = transformOptions(options);
25727
25674
  this.services = {};
@@ -25740,10 +25687,7 @@ class I18n extends EventEmitter {
25740
25687
  }, 0);
25741
25688
  }
25742
25689
  }
25743
- init() {
25744
- var _this = this;
25745
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25746
- let callback = arguments.length > 1 ? arguments[1] : undefined;
25690
+ init(options = {}, callback) {
25747
25691
  this.isInitializing = true;
25748
25692
  if (typeof options === 'function') {
25749
25693
  callback = options;
@@ -25809,11 +25753,8 @@ class I18n extends EventEmitter {
25809
25753
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
25810
25754
  };
25811
25755
  s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
25812
- s.backendConnector.on('*', function (event) {
25813
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
25814
- args[_key - 1] = arguments[_key];
25815
- }
25816
- _this.emit(event, ...args);
25756
+ s.backendConnector.on('*', (event, ...args) => {
25757
+ this.emit(event, ...args);
25817
25758
  });
25818
25759
  if (this.modules.languageDetector) {
25819
25760
  s.languageDetector = createClassOnDemand(this.modules.languageDetector);
@@ -25824,11 +25765,8 @@ class I18n extends EventEmitter {
25824
25765
  if (s.i18nFormat.init) s.i18nFormat.init(this);
25825
25766
  }
25826
25767
  this.translator = new Translator(this.services, this.options);
25827
- this.translator.on('*', function (event) {
25828
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
25829
- args[_key2 - 1] = arguments[_key2];
25830
- }
25831
- _this.emit(event, ...args);
25768
+ this.translator.on('*', (event, ...args) => {
25769
+ this.emit(event, ...args);
25832
25770
  });
25833
25771
  this.modules.external.forEach(m => {
25834
25772
  if (m.init) m.init(this);
@@ -25845,15 +25783,13 @@ class I18n extends EventEmitter {
25845
25783
  }
25846
25784
  const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
25847
25785
  storeApi.forEach(fcName => {
25848
- this[fcName] = function () {
25849
- return _this.store[fcName](...arguments);
25850
- };
25786
+ this[fcName] = (...args) => this.store[fcName](...args);
25851
25787
  });
25852
25788
  const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
25853
25789
  storeApiChained.forEach(fcName => {
25854
- this[fcName] = function () {
25855
- _this.store[fcName](...arguments);
25856
- return _this;
25790
+ this[fcName] = (...args) => {
25791
+ this.store[fcName](...args);
25792
+ return this;
25857
25793
  };
25858
25794
  });
25859
25795
  const deferred = defer();
@@ -25877,8 +25813,7 @@ class I18n extends EventEmitter {
25877
25813
  }
25878
25814
  return deferred;
25879
25815
  }
25880
- loadResources(language) {
25881
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
25816
+ loadResources(language, callback = noop) {
25882
25817
  let usedCallback = callback;
25883
25818
  const usedLng = isString(language) ? language : this.language;
25884
25819
  if (typeof language === 'function') usedCallback = language;
@@ -25971,7 +25906,6 @@ class I18n extends EventEmitter {
25971
25906
  }
25972
25907
  }
25973
25908
  changeLanguage(lng, callback) {
25974
- var _this2 = this;
25975
25909
  this.isLanguageChangingTo = lng;
25976
25910
  const deferred = defer();
25977
25911
  this.emit('languageChanging', lng);
@@ -25993,12 +25927,8 @@ class I18n extends EventEmitter {
25993
25927
  } else {
25994
25928
  this.isLanguageChangingTo = undefined;
25995
25929
  }
25996
- deferred.resolve(function () {
25997
- return _this2.t(...arguments);
25998
- });
25999
- if (callback) callback(err, function () {
26000
- return _this2.t(...arguments);
26001
- });
25930
+ deferred.resolve((...args) => this.t(...args));
25931
+ if (callback) callback(err, (...args) => this.t(...args));
26002
25932
  };
26003
25933
  const setLng = lngs => {
26004
25934
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
@@ -26029,14 +25959,10 @@ class I18n extends EventEmitter {
26029
25959
  return deferred;
26030
25960
  }
26031
25961
  getFixedT(lng, ns, keyPrefix) {
26032
- var _this3 = this;
26033
- const fixedT = function (key, opts) {
25962
+ const fixedT = (key, opts, ...rest) => {
26034
25963
  let o;
26035
25964
  if (typeof opts !== 'object') {
26036
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
26037
- rest[_key3 - 2] = arguments[_key3];
26038
- }
26039
- o = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
25965
+ o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
26040
25966
  } else {
26041
25967
  o = {
26042
25968
  ...opts
@@ -26046,14 +25972,14 @@ class I18n extends EventEmitter {
26046
25972
  o.lngs = o.lngs || fixedT.lngs;
26047
25973
  o.ns = o.ns || fixedT.ns;
26048
25974
  if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
26049
- const keySeparator = _this3.options.keySeparator || '.';
25975
+ const keySeparator = this.options.keySeparator || '.';
26050
25976
  let resultKey;
26051
25977
  if (o.keyPrefix && Array.isArray(key)) {
26052
25978
  resultKey = key.map(k => `${o.keyPrefix}${keySeparator}${k}`);
26053
25979
  } else {
26054
25980
  resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
26055
25981
  }
26056
- return _this3.t(resultKey, o);
25982
+ return this.t(resultKey, o);
26057
25983
  };
26058
25984
  if (isString(lng)) {
26059
25985
  fixedT.lng = lng;
@@ -26064,23 +25990,16 @@ class I18n extends EventEmitter {
26064
25990
  fixedT.keyPrefix = keyPrefix;
26065
25991
  return fixedT;
26066
25992
  }
26067
- t() {
26068
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
26069
- args[_key4] = arguments[_key4];
26070
- }
25993
+ t(...args) {
26071
25994
  return this.translator?.translate(...args);
26072
25995
  }
26073
- exists() {
26074
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
26075
- args[_key5] = arguments[_key5];
26076
- }
25996
+ exists(...args) {
26077
25997
  return this.translator?.exists(...args);
26078
25998
  }
26079
25999
  setDefaultNamespace(ns) {
26080
26000
  this.options.defaultNS = ns;
26081
26001
  }
26082
- hasLoadedNamespace(ns) {
26083
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
26002
+ hasLoadedNamespace(ns, options = {}) {
26084
26003
  if (!this.isInitialized) {
26085
26004
  this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
26086
26005
  return false;
@@ -26145,14 +26064,10 @@ class I18n extends EventEmitter {
26145
26064
  const languageUtils = this.services?.languageUtils || new LanguageUtil(get$1());
26146
26065
  return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
26147
26066
  }
26148
- static createInstance() {
26149
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26150
- let callback = arguments.length > 1 ? arguments[1] : undefined;
26067
+ static createInstance(options = {}, callback) {
26151
26068
  return new I18n(options, callback);
26152
26069
  }
26153
- cloneInstance() {
26154
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
26155
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
26070
+ cloneInstance(options = {}, callback = noop) {
26156
26071
  const forkResourceStore = options.forkResourceStore;
26157
26072
  if (forkResourceStore) delete options.forkResourceStore;
26158
26073
  const mergedOptions = {
@@ -26193,10 +26108,7 @@ class I18n extends EventEmitter {
26193
26108
  clone.services.resourceStore = clone.store;
26194
26109
  }
26195
26110
  clone.translator = new Translator(clone.services, mergedOptions);
26196
- clone.translator.on('*', function (event) {
26197
- for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
26198
- args[_key6 - 1] = arguments[_key6];
26199
- }
26111
+ clone.translator.on('*', (event, ...args) => {
26200
26112
  clone.emit(event, ...args);
26201
26113
  });
26202
26114
  clone.init(mergedOptions, callback);
@@ -28558,14 +28470,11 @@ function deflist_plugin (md) {
28558
28470
  md.block.ruler.before('paragraph', 'deflist', deflist, { alt: ['paragraph', 'reference', 'blockquote'] });
28559
28471
  }
28560
28472
 
28561
- var Diff = /** @class */ (function () {
28562
- function Diff() {
28563
- }
28564
- Diff.prototype.diff = function (oldString, newString,
28473
+ class Diff {
28474
+ diff(oldStr, newStr,
28565
28475
  // Type below is not accurate/complete - see above for full possibilities - but it compiles
28566
- options) {
28567
- if (options === void 0) { options = {}; }
28568
- var callback;
28476
+ options = {}) {
28477
+ let callback;
28569
28478
  if (typeof options === 'function') {
28570
28479
  callback = options;
28571
28480
  options = {};
@@ -28574,17 +28483,16 @@ var Diff = /** @class */ (function () {
28574
28483
  callback = options.callback;
28575
28484
  }
28576
28485
  // Allow subclasses to massage the input prior to running
28577
- oldString = this.castInput(oldString, options);
28578
- newString = this.castInput(newString, options);
28579
- var oldTokens = this.removeEmpty(this.tokenize(oldString, options));
28580
- var newTokens = this.removeEmpty(this.tokenize(newString, options));
28486
+ const oldString = this.castInput(oldStr, options);
28487
+ const newString = this.castInput(newStr, options);
28488
+ const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
28489
+ const newTokens = this.removeEmpty(this.tokenize(newString, options));
28581
28490
  return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
28582
- };
28583
- Diff.prototype.diffWithOptionsObj = function (oldTokens, newTokens, options, callback) {
28584
- var _this = this;
28491
+ }
28492
+ diffWithOptionsObj(oldTokens, newTokens, options, callback) {
28585
28493
  var _a;
28586
- var done = function (value) {
28587
- value = _this.postProcess(value, options);
28494
+ const done = (value) => {
28495
+ value = this.postProcess(value, options);
28588
28496
  if (callback) {
28589
28497
  setTimeout(function () { callback(value); }, 0);
28590
28498
  return undefined;
@@ -28593,17 +28501,17 @@ var Diff = /** @class */ (function () {
28593
28501
  return value;
28594
28502
  }
28595
28503
  };
28596
- var newLen = newTokens.length, oldLen = oldTokens.length;
28597
- var editLength = 1;
28598
- var maxEditLength = newLen + oldLen;
28504
+ const newLen = newTokens.length, oldLen = oldTokens.length;
28505
+ let editLength = 1;
28506
+ let maxEditLength = newLen + oldLen;
28599
28507
  if (options.maxEditLength != null) {
28600
28508
  maxEditLength = Math.min(maxEditLength, options.maxEditLength);
28601
28509
  }
28602
- var maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
28603
- var abortAfterTimestamp = Date.now() + maxExecutionTime;
28604
- var bestPath = [{ oldPos: -1, lastComponent: undefined }];
28510
+ const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
28511
+ const abortAfterTimestamp = Date.now() + maxExecutionTime;
28512
+ const bestPath = [{ oldPos: -1, lastComponent: undefined }];
28605
28513
  // Seed editLength = 0, i.e. the content starts with the same values
28606
- var newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
28514
+ let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
28607
28515
  if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
28608
28516
  // Identity per the equality and tokenizer
28609
28517
  return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
@@ -28625,24 +28533,24 @@ var Diff = /** @class */ (function () {
28625
28533
  // where the new text simply appends d characters on the end of the
28626
28534
  // original text of length n, the true Myers algorithm will take O(n+d^2)
28627
28535
  // time while this optimization needs only O(n+d) time.
28628
- var minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
28536
+ let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
28629
28537
  // Main worker method. checks all permutations of a given edit length for acceptance.
28630
- var execEditLength = function () {
28631
- for (var diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
28632
- var basePath = void 0;
28633
- var removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
28538
+ const execEditLength = () => {
28539
+ for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
28540
+ let basePath;
28541
+ const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
28634
28542
  if (removePath) {
28635
28543
  // No one else is going to attempt to use this value, clear it
28636
28544
  // @ts-expect-error - perf optimisation. This type-violating value will never be read.
28637
28545
  bestPath[diagonalPath - 1] = undefined;
28638
28546
  }
28639
- var canAdd = false;
28547
+ let canAdd = false;
28640
28548
  if (addPath) {
28641
28549
  // what newPos will be after we do an insertion:
28642
- var addPathNewPos = addPath.oldPos - diagonalPath;
28550
+ const addPathNewPos = addPath.oldPos - diagonalPath;
28643
28551
  canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
28644
28552
  }
28645
- var canRemove = removePath && removePath.oldPos + 1 < oldLen;
28553
+ const canRemove = removePath && removePath.oldPos + 1 < oldLen;
28646
28554
  if (!canAdd && !canRemove) {
28647
28555
  // If this path is a terminal then prune
28648
28556
  // @ts-expect-error - perf optimisation. This type-violating value will never be read.
@@ -28653,15 +28561,15 @@ var Diff = /** @class */ (function () {
28653
28561
  // path whose position in the old string is the farthest from the origin
28654
28562
  // and does not pass the bounds of the diff graph
28655
28563
  if (!canRemove || (canAdd && removePath.oldPos < addPath.oldPos)) {
28656
- basePath = _this.addToPath(addPath, true, false, 0, options);
28564
+ basePath = this.addToPath(addPath, true, false, 0, options);
28657
28565
  }
28658
28566
  else {
28659
- basePath = _this.addToPath(removePath, false, true, 1, options);
28567
+ basePath = this.addToPath(removePath, false, true, 1, options);
28660
28568
  }
28661
- newPos = _this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
28569
+ newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
28662
28570
  if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
28663
28571
  // If we have hit the end of both strings, then we are done
28664
- return done(_this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
28572
+ return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
28665
28573
  }
28666
28574
  else {
28667
28575
  bestPath[diagonalPath] = basePath;
@@ -28693,15 +28601,15 @@ var Diff = /** @class */ (function () {
28693
28601
  }
28694
28602
  else {
28695
28603
  while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
28696
- var ret = execEditLength();
28604
+ const ret = execEditLength();
28697
28605
  if (ret) {
28698
28606
  return ret;
28699
28607
  }
28700
28608
  }
28701
28609
  }
28702
- };
28703
- Diff.prototype.addToPath = function (path, added, removed, oldPosInc, options) {
28704
- var last = path.lastComponent;
28610
+ }
28611
+ addToPath(path, added, removed, oldPosInc, options) {
28612
+ const last = path.lastComponent;
28705
28613
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
28706
28614
  return {
28707
28615
  oldPos: path.oldPos + oldPosInc,
@@ -28714,10 +28622,10 @@ var Diff = /** @class */ (function () {
28714
28622
  lastComponent: { count: 1, added: added, removed: removed, previousComponent: last }
28715
28623
  };
28716
28624
  }
28717
- };
28718
- Diff.prototype.extractCommon = function (basePath, newTokens, oldTokens, diagonalPath, options) {
28719
- var newLen = newTokens.length, oldLen = oldTokens.length;
28720
- var oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
28625
+ }
28626
+ extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
28627
+ const newLen = newTokens.length, oldLen = oldTokens.length;
28628
+ let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
28721
28629
  while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
28722
28630
  newPos++;
28723
28631
  oldPos++;
@@ -28731,8 +28639,8 @@ var Diff = /** @class */ (function () {
28731
28639
  }
28732
28640
  basePath.oldPos = oldPos;
28733
28641
  return newPos;
28734
- };
28735
- Diff.prototype.equals = function (left, right, options) {
28642
+ }
28643
+ equals(left, right, options) {
28736
28644
  if (options.comparator) {
28737
28645
  return options.comparator(left, right);
28738
28646
  }
@@ -28740,48 +28648,44 @@ var Diff = /** @class */ (function () {
28740
28648
  return left === right
28741
28649
  || (!!options.ignoreCase && left.toLowerCase() === right.toLowerCase());
28742
28650
  }
28743
- };
28744
- Diff.prototype.removeEmpty = function (array) {
28745
- var ret = [];
28746
- for (var i = 0; i < array.length; i++) {
28651
+ }
28652
+ removeEmpty(array) {
28653
+ const ret = [];
28654
+ for (let i = 0; i < array.length; i++) {
28747
28655
  if (array[i]) {
28748
28656
  ret.push(array[i]);
28749
28657
  }
28750
28658
  }
28751
28659
  return ret;
28752
- };
28660
+ }
28753
28661
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
28754
- Diff.prototype.castInput = function (value, options) {
28662
+ castInput(value, options) {
28755
28663
  return value;
28756
- };
28664
+ }
28757
28665
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
28758
- Diff.prototype.tokenize = function (value, options) {
28666
+ tokenize(value, options) {
28759
28667
  return Array.from(value);
28760
- };
28761
- Diff.prototype.join = function (chars) {
28668
+ }
28669
+ join(chars) {
28762
28670
  // Assumes ValueT is string, which is the case for most subclasses.
28763
28671
  // When it's false, e.g. in diffArrays, this method needs to be overridden (e.g. with a no-op)
28764
28672
  // Yes, the casts are verbose and ugly, because this pattern - of having the base class SORT OF
28765
28673
  // assume tokens and values are strings, but not completely - is weird and janky.
28766
28674
  return chars.join('');
28767
- };
28768
- Diff.prototype.postProcess = function (changeObjects,
28675
+ }
28676
+ postProcess(changeObjects,
28769
28677
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
28770
28678
  options) {
28771
28679
  return changeObjects;
28772
- };
28773
- Object.defineProperty(Diff.prototype, "useLongestToken", {
28774
- get: function () {
28775
- return false;
28776
- },
28777
- enumerable: false,
28778
- configurable: true
28779
- });
28780
- Diff.prototype.buildValues = function (lastComponent, newTokens, oldTokens) {
28680
+ }
28681
+ get useLongestToken() {
28682
+ return false;
28683
+ }
28684
+ buildValues(lastComponent, newTokens, oldTokens) {
28781
28685
  // First we convert our linked list of components in reverse order to an
28782
28686
  // array in the right order:
28783
- var components = [];
28784
- var nextComponent;
28687
+ const components = [];
28688
+ let nextComponent;
28785
28689
  while (lastComponent) {
28786
28690
  components.push(lastComponent);
28787
28691
  nextComponent = lastComponent.previousComponent;
@@ -28789,15 +28693,15 @@ var Diff = /** @class */ (function () {
28789
28693
  lastComponent = nextComponent;
28790
28694
  }
28791
28695
  components.reverse();
28792
- var componentLen = components.length;
28793
- var componentPos = 0, newPos = 0, oldPos = 0;
28696
+ const componentLen = components.length;
28697
+ let componentPos = 0, newPos = 0, oldPos = 0;
28794
28698
  for (; componentPos < componentLen; componentPos++) {
28795
- var component = components[componentPos];
28699
+ const component = components[componentPos];
28796
28700
  if (!component.removed) {
28797
28701
  if (!component.added && this.useLongestToken) {
28798
- var value = newTokens.slice(newPos, newPos + component.count);
28702
+ let value = newTokens.slice(newPos, newPos + component.count);
28799
28703
  value = value.map(function (value, i) {
28800
- var oldValue = oldTokens[oldPos + i];
28704
+ const oldValue = oldTokens[oldPos + i];
28801
28705
  return oldValue.length > value.length ? oldValue : value;
28802
28706
  });
28803
28707
  component.value = this.join(value);
@@ -28817,462 +28721,15 @@ var Diff = /** @class */ (function () {
28817
28721
  }
28818
28722
  }
28819
28723
  return components;
28820
- };
28821
- return Diff;
28822
- }());
28823
-
28824
- var __extends$6 = (undefined && undefined.__extends) || (function () {
28825
- var extendStatics = function (d, b) {
28826
- extendStatics = Object.setPrototypeOf ||
28827
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28828
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
28829
- return extendStatics(d, b);
28830
- };
28831
- return function (d, b) {
28832
- if (typeof b !== "function" && b !== null)
28833
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
28834
- extendStatics(d, b);
28835
- function __() { this.constructor = d; }
28836
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28837
- };
28838
- })();
28839
- var CharacterDiff = /** @class */ (function (_super) {
28840
- __extends$6(CharacterDiff, _super);
28841
- function CharacterDiff() {
28842
- return _super !== null && _super.apply(this, arguments) || this;
28843
- }
28844
- return CharacterDiff;
28845
- }(Diff));
28846
- new CharacterDiff();
28847
-
28848
- function longestCommonPrefix(str1, str2) {
28849
- var i;
28850
- for (i = 0; i < str1.length && i < str2.length; i++) {
28851
- if (str1[i] != str2[i]) {
28852
- return str1.slice(0, i);
28853
- }
28854
- }
28855
- return str1.slice(0, i);
28856
- }
28857
- function longestCommonSuffix(str1, str2) {
28858
- var i;
28859
- // Unlike longestCommonPrefix, we need a special case to handle all scenarios
28860
- // where we return the empty string since str1.slice(-0) will return the
28861
- // entire string.
28862
- if (!str1 || !str2 || str1[str1.length - 1] != str2[str2.length - 1]) {
28863
- return '';
28864
- }
28865
- for (i = 0; i < str1.length && i < str2.length; i++) {
28866
- if (str1[str1.length - (i + 1)] != str2[str2.length - (i + 1)]) {
28867
- return str1.slice(-i);
28868
- }
28869
- }
28870
- return str1.slice(-i);
28871
- }
28872
- function replacePrefix(string, oldPrefix, newPrefix) {
28873
- if (string.slice(0, oldPrefix.length) != oldPrefix) {
28874
- throw Error("string ".concat(JSON.stringify(string), " doesn't start with prefix ").concat(JSON.stringify(oldPrefix), "; this is a bug"));
28875
28724
  }
28876
- return newPrefix + string.slice(oldPrefix.length);
28877
- }
28878
- function replaceSuffix(string, oldSuffix, newSuffix) {
28879
- if (!oldSuffix) {
28880
- return string + newSuffix;
28881
- }
28882
- if (string.slice(-oldSuffix.length) != oldSuffix) {
28883
- throw Error("string ".concat(JSON.stringify(string), " doesn't end with suffix ").concat(JSON.stringify(oldSuffix), "; this is a bug"));
28884
- }
28885
- return string.slice(0, -oldSuffix.length) + newSuffix;
28886
- }
28887
- function removePrefix(string, oldPrefix) {
28888
- return replacePrefix(string, oldPrefix, '');
28889
- }
28890
- function removeSuffix(string, oldSuffix) {
28891
- return replaceSuffix(string, oldSuffix, '');
28892
- }
28893
- function maximumOverlap(string1, string2) {
28894
- return string2.slice(0, overlapCount(string1, string2));
28895
- }
28896
- // Nicked from https://stackoverflow.com/a/60422853/1709587
28897
- function overlapCount(a, b) {
28898
- // Deal with cases where the strings differ in length
28899
- var startA = 0;
28900
- if (a.length > b.length) {
28901
- startA = a.length - b.length;
28902
- }
28903
- var endB = b.length;
28904
- if (a.length < b.length) {
28905
- endB = a.length;
28906
- }
28907
- // Create a back-reference for each index
28908
- // that should be followed in case of a mismatch.
28909
- // We only need B to make these references:
28910
- var map = Array(endB);
28911
- var k = 0; // Index that lags behind j
28912
- map[0] = 0;
28913
- for (var j = 1; j < endB; j++) {
28914
- if (b[j] == b[k]) {
28915
- map[j] = map[k]; // skip over the same character (optional optimisation)
28916
- }
28917
- else {
28918
- map[j] = k;
28919
- }
28920
- while (k > 0 && b[j] != b[k]) {
28921
- k = map[k];
28922
- }
28923
- if (b[j] == b[k]) {
28924
- k++;
28925
- }
28926
- }
28927
- // Phase 2: use these references while iterating over A
28928
- k = 0;
28929
- for (var i = startA; i < a.length; i++) {
28930
- while (k > 0 && a[i] != b[k]) {
28931
- k = map[k];
28932
- }
28933
- if (a[i] == b[k]) {
28934
- k++;
28935
- }
28936
- }
28937
- return k;
28938
- }
28939
- function trailingWs(string) {
28940
- // Yes, this looks overcomplicated and dumb - why not replace the whole function with
28941
- // return string match(/\s*$/)[0]
28942
- // you ask? Because:
28943
- // 1. the trap described at https://markamery.com/blog/quadratic-time-regexes/ would mean doing
28944
- // this would cause this function to take O(n²) time in the worst case (specifically when
28945
- // there is a massive run of NON-TRAILING whitespace in `string`), and
28946
- // 2. the fix proposed in the same blog post, of using a negative lookbehind, is incompatible
28947
- // with old Safari versions that we'd like to not break if possible (see
28948
- // https://github.com/kpdecker/jsdiff/pull/550)
28949
- // It feels absurd to do this with an explicit loop instead of a regex, but I really can't see a
28950
- // better way that doesn't result in broken behaviour.
28951
- var i;
28952
- for (i = string.length - 1; i >= 0; i--) {
28953
- if (!string[i].match(/\s/)) {
28954
- break;
28955
- }
28956
- }
28957
- return string.substring(i + 1);
28958
- }
28959
- function leadingWs(string) {
28960
- // Thankfully the annoying considerations described in trailingWs don't apply here:
28961
- var match = string.match(/^\s*/);
28962
- return match ? match[0] : '';
28963
28725
  }
28964
28726
 
28965
- var __extends$5 = (undefined && undefined.__extends) || (function () {
28966
- var extendStatics = function (d, b) {
28967
- extendStatics = Object.setPrototypeOf ||
28968
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
28969
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
28970
- return extendStatics(d, b);
28971
- };
28972
- return function (d, b) {
28973
- if (typeof b !== "function" && b !== null)
28974
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
28975
- extendStatics(d, b);
28976
- function __() { this.constructor = d; }
28977
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28978
- };
28979
- })();
28980
- // Based on https://en.wikipedia.org/wiki/Latin_script_in_Unicode
28981
- //
28982
- // Ranges and exceptions:
28983
- // Latin-1 Supplement, 0080–00FF
28984
- // - U+00D7 × Multiplication sign
28985
- // - U+00F7 ÷ Division sign
28986
- // Latin Extended-A, 0100–017F
28987
- // Latin Extended-B, 0180–024F
28988
- // IPA Extensions, 0250–02AF
28989
- // Spacing Modifier Letters, 02B0–02FF
28990
- // - U+02C7 ˇ &#711; Caron
28991
- // - U+02D8 ˘ &#728; Breve
28992
- // - U+02D9 ˙ &#729; Dot Above
28993
- // - U+02DA ˚ &#730; Ring Above
28994
- // - U+02DB ˛ &#731; Ogonek
28995
- // - U+02DC ˜ &#732; Small Tilde
28996
- // - U+02DD ˝ &#733; Double Acute Accent
28997
- // Latin Extended Additional, 1E00–1EFF
28998
- var extendedWordChars = 'a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}';
28999
- // Each token is one of the following:
29000
- // - A punctuation mark plus the surrounding whitespace
29001
- // - A word plus the surrounding whitespace
29002
- // - Pure whitespace (but only in the special case where this the entire text
29003
- // is just whitespace)
29004
- //
29005
- // We have to include surrounding whitespace in the tokens because the two
29006
- // alternative approaches produce horribly broken results:
29007
- // * If we just discard the whitespace, we can't fully reproduce the original
29008
- // text from the sequence of tokens and any attempt to render the diff will
29009
- // get the whitespace wrong.
29010
- // * If we have separate tokens for whitespace, then in a typical text every
29011
- // second token will be a single space character. But this often results in
29012
- // the optimal diff between two texts being a perverse one that preserves
29013
- // the spaces between words but deletes and reinserts actual common words.
29014
- // See https://github.com/kpdecker/jsdiff/issues/160#issuecomment-1866099640
29015
- // for an example.
29016
- //
29017
- // Keeping the surrounding whitespace of course has implications for .equals
29018
- // and .join, not just .tokenize.
29019
- // This regex does NOT fully implement the tokenization rules described above.
29020
- // Instead, it gives runs of whitespace their own "token". The tokenize method
29021
- // then handles stitching whitespace tokens onto adjacent word or punctuation
29022
- // tokens.
29023
- var tokenizeIncludingWhitespace = new RegExp("[".concat(extendedWordChars, "]+|\\s+|[^").concat(extendedWordChars, "]"), 'ug');
29024
- var WordDiff = /** @class */ (function (_super) {
29025
- __extends$5(WordDiff, _super);
29026
- function WordDiff() {
29027
- return _super !== null && _super.apply(this, arguments) || this;
29028
- }
29029
- WordDiff.prototype.equals = function (left, right, options) {
29030
- if (options.ignoreCase) {
29031
- left = left.toLowerCase();
29032
- right = right.toLowerCase();
29033
- }
29034
- return left.trim() === right.trim();
29035
- };
29036
- WordDiff.prototype.tokenize = function (value, options) {
29037
- if (options === void 0) { options = {}; }
29038
- var parts;
29039
- if (options.intlSegmenter) {
29040
- var segmenter = options.intlSegmenter;
29041
- if (segmenter.resolvedOptions().granularity != 'word') {
29042
- throw new Error('The segmenter passed must have a granularity of "word"');
29043
- }
29044
- parts = Array.from(segmenter.segment(value), function (segment) { return segment.segment; });
29045
- }
29046
- else {
29047
- parts = value.match(tokenizeIncludingWhitespace) || [];
29048
- }
29049
- var tokens = [];
29050
- var prevPart = null;
29051
- parts.forEach(function (part) {
29052
- if ((/\s/).test(part)) {
29053
- if (prevPart == null) {
29054
- tokens.push(part);
29055
- }
29056
- else {
29057
- tokens.push(tokens.pop() + part);
29058
- }
29059
- }
29060
- else if (prevPart != null && (/\s/).test(prevPart)) {
29061
- if (tokens[tokens.length - 1] == prevPart) {
29062
- tokens.push(tokens.pop() + part);
29063
- }
29064
- else {
29065
- tokens.push(prevPart + part);
29066
- }
29067
- }
29068
- else {
29069
- tokens.push(part);
29070
- }
29071
- prevPart = part;
29072
- });
29073
- return tokens;
29074
- };
29075
- WordDiff.prototype.join = function (tokens) {
29076
- // Tokens being joined here will always have appeared consecutively in the
29077
- // same text, so we can simply strip off the leading whitespace from all the
29078
- // tokens except the first (and except any whitespace-only tokens - but such
29079
- // a token will always be the first and only token anyway) and then join them
29080
- // and the whitespace around words and punctuation will end up correct.
29081
- return tokens.map(function (token, i) {
29082
- if (i == 0) {
29083
- return token;
29084
- }
29085
- else {
29086
- return token.replace((/^\s+/), '');
29087
- }
29088
- }).join('');
29089
- };
29090
- WordDiff.prototype.postProcess = function (changes, options) {
29091
- if (!changes || options.oneChangePerToken) {
29092
- return changes;
29093
- }
29094
- var lastKeep = null;
29095
- // Change objects representing any insertion or deletion since the last
29096
- // "keep" change object. There can be at most one of each.
29097
- var insertion = null;
29098
- var deletion = null;
29099
- changes.forEach(function (change) {
29100
- if (change.added) {
29101
- insertion = change;
29102
- }
29103
- else if (change.removed) {
29104
- deletion = change;
29105
- }
29106
- else {
29107
- if (insertion || deletion) { // May be false at start of text
29108
- dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, change);
29109
- }
29110
- lastKeep = change;
29111
- insertion = null;
29112
- deletion = null;
29113
- }
29114
- });
29115
- if (insertion || deletion) {
29116
- dedupeWhitespaceInChangeObjects(lastKeep, deletion, insertion, null);
29117
- }
29118
- return changes;
29119
- };
29120
- return WordDiff;
29121
- }(Diff));
29122
- new WordDiff();
29123
- function dedupeWhitespaceInChangeObjects(startKeep, deletion, insertion, endKeep) {
29124
- // Before returning, we tidy up the leading and trailing whitespace of the
29125
- // change objects to eliminate cases where trailing whitespace in one object
29126
- // is repeated as leading whitespace in the next.
29127
- // Below are examples of the outcomes we want here to explain the code.
29128
- // I=insert, K=keep, D=delete
29129
- // 1. diffing 'foo bar baz' vs 'foo baz'
29130
- // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'
29131
- // After cleanup, we want: K:'foo ' D:'bar ' K:'baz'
29132
- //
29133
- // 2. Diffing 'foo bar baz' vs 'foo qux baz'
29134
- // Prior to cleanup, we have K:'foo ' D:' bar ' I:' qux ' K:' baz'
29135
- // After cleanup, we want K:'foo ' D:'bar' I:'qux' K:' baz'
29136
- //
29137
- // 3. Diffing 'foo\nbar baz' vs 'foo baz'
29138
- // Prior to cleanup, we have K:'foo ' D:'\nbar ' K:' baz'
29139
- // After cleanup, we want K'foo' D:'\nbar' K:' baz'
29140
- //
29141
- // 4. Diffing 'foo baz' vs 'foo\nbar baz'
29142
- // Prior to cleanup, we have K:'foo\n' I:'\nbar ' K:' baz'
29143
- // After cleanup, we ideally want K'foo' I:'\nbar' K:' baz'
29144
- // but don't actually manage this currently (the pre-cleanup change
29145
- // objects don't contain enough information to make it possible).
29146
- //
29147
- // 5. Diffing 'foo bar baz' vs 'foo baz'
29148
- // Prior to cleanup, we have K:'foo ' D:' bar ' K:' baz'
29149
- // After cleanup, we want K:'foo ' D:' bar ' K:'baz'
29150
- //
29151
- // Our handling is unavoidably imperfect in the case where there's a single
29152
- // indel between keeps and the whitespace has changed. For instance, consider
29153
- // diffing 'foo\tbar\nbaz' vs 'foo baz'. Unless we create an extra change
29154
- // object to represent the insertion of the space character (which isn't even
29155
- // a token), we have no way to avoid losing information about the texts'
29156
- // original whitespace in the result we return. Still, we do our best to
29157
- // output something that will look sensible if we e.g. print it with
29158
- // insertions in green and deletions in red.
29159
- // Between two "keep" change objects (or before the first or after the last
29160
- // change object), we can have either:
29161
- // * A "delete" followed by an "insert"
29162
- // * Just an "insert"
29163
- // * Just a "delete"
29164
- // We handle the three cases separately.
29165
- if (deletion && insertion) {
29166
- var oldWsPrefix = leadingWs(deletion.value);
29167
- var oldWsSuffix = trailingWs(deletion.value);
29168
- var newWsPrefix = leadingWs(insertion.value);
29169
- var newWsSuffix = trailingWs(insertion.value);
29170
- if (startKeep) {
29171
- var commonWsPrefix = longestCommonPrefix(oldWsPrefix, newWsPrefix);
29172
- startKeep.value = replaceSuffix(startKeep.value, newWsPrefix, commonWsPrefix);
29173
- deletion.value = removePrefix(deletion.value, commonWsPrefix);
29174
- insertion.value = removePrefix(insertion.value, commonWsPrefix);
29175
- }
29176
- if (endKeep) {
29177
- var commonWsSuffix = longestCommonSuffix(oldWsSuffix, newWsSuffix);
29178
- endKeep.value = replacePrefix(endKeep.value, newWsSuffix, commonWsSuffix);
29179
- deletion.value = removeSuffix(deletion.value, commonWsSuffix);
29180
- insertion.value = removeSuffix(insertion.value, commonWsSuffix);
29181
- }
29182
- }
29183
- else if (insertion) {
29184
- // The whitespaces all reflect what was in the new text rather than
29185
- // the old, so we essentially have no information about whitespace
29186
- // insertion or deletion. We just want to dedupe the whitespace.
29187
- // We do that by having each change object keep its trailing
29188
- // whitespace and deleting duplicate leading whitespace where
29189
- // present.
29190
- if (startKeep) {
29191
- var ws = leadingWs(insertion.value);
29192
- insertion.value = insertion.value.substring(ws.length);
29193
- }
29194
- if (endKeep) {
29195
- var ws = leadingWs(endKeep.value);
29196
- endKeep.value = endKeep.value.substring(ws.length);
29197
- }
29198
- // otherwise we've got a deletion and no insertion
29199
- }
29200
- else if (startKeep && endKeep) {
29201
- var newWsFull = leadingWs(endKeep.value), delWsStart = leadingWs(deletion.value), delWsEnd = trailingWs(deletion.value);
29202
- // Any whitespace that comes straight after startKeep in both the old and
29203
- // new texts, assign to startKeep and remove from the deletion.
29204
- var newWsStart = longestCommonPrefix(newWsFull, delWsStart);
29205
- deletion.value = removePrefix(deletion.value, newWsStart);
29206
- // Any whitespace that comes straight before endKeep in both the old and
29207
- // new texts, and hasn't already been assigned to startKeep, assign to
29208
- // endKeep and remove from the deletion.
29209
- var newWsEnd = longestCommonSuffix(removePrefix(newWsFull, newWsStart), delWsEnd);
29210
- deletion.value = removeSuffix(deletion.value, newWsEnd);
29211
- endKeep.value = replacePrefix(endKeep.value, newWsFull, newWsEnd);
29212
- // If there's any whitespace from the new text that HASN'T already been
29213
- // assigned, assign it to the start:
29214
- startKeep.value = replaceSuffix(startKeep.value, newWsFull, newWsFull.slice(0, newWsFull.length - newWsEnd.length));
29215
- }
29216
- else if (endKeep) {
29217
- // We are at the start of the text. Preserve all the whitespace on
29218
- // endKeep, and just remove whitespace from the end of deletion to the
29219
- // extent that it overlaps with the start of endKeep.
29220
- var endKeepWsPrefix = leadingWs(endKeep.value);
29221
- var deletionWsSuffix = trailingWs(deletion.value);
29222
- var overlap = maximumOverlap(deletionWsSuffix, endKeepWsPrefix);
29223
- deletion.value = removeSuffix(deletion.value, overlap);
29224
- }
29225
- else if (startKeep) {
29226
- // We are at the END of the text. Preserve all the whitespace on
29227
- // startKeep, and just remove whitespace from the start of deletion to
29228
- // the extent that it overlaps with the end of startKeep.
29229
- var startKeepWsSuffix = trailingWs(startKeep.value);
29230
- var deletionWsPrefix = leadingWs(deletion.value);
29231
- var overlap = maximumOverlap(startKeepWsSuffix, deletionWsPrefix);
29232
- deletion.value = removePrefix(deletion.value, overlap);
29233
- }
29234
- }
29235
- var WordsWithSpaceDiff = /** @class */ (function (_super) {
29236
- __extends$5(WordsWithSpaceDiff, _super);
29237
- function WordsWithSpaceDiff() {
29238
- return _super !== null && _super.apply(this, arguments) || this;
29239
- }
29240
- WordsWithSpaceDiff.prototype.tokenize = function (value) {
29241
- // Slightly different to the tokenizeIncludingWhitespace regex used above in
29242
- // that this one treats each individual newline as a distinct tokens, rather
29243
- // than merging them into other surrounding whitespace. This was requested
29244
- // in https://github.com/kpdecker/jsdiff/issues/180 &
29245
- // https://github.com/kpdecker/jsdiff/issues/211
29246
- var regex = new RegExp("(\\r?\\n)|[".concat(extendedWordChars, "]+|[^\\S\\n\\r]+|[^").concat(extendedWordChars, "]"), 'ug');
29247
- return value.match(regex) || [];
29248
- };
29249
- return WordsWithSpaceDiff;
29250
- }(Diff));
29251
- new WordsWithSpaceDiff();
29252
-
29253
- var __extends$4 = (undefined && undefined.__extends) || (function () {
29254
- var extendStatics = function (d, b) {
29255
- extendStatics = Object.setPrototypeOf ||
29256
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29257
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
29258
- return extendStatics(d, b);
29259
- };
29260
- return function (d, b) {
29261
- if (typeof b !== "function" && b !== null)
29262
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
29263
- extendStatics(d, b);
29264
- function __() { this.constructor = d; }
29265
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29266
- };
29267
- })();
29268
- var LineDiff = /** @class */ (function (_super) {
29269
- __extends$4(LineDiff, _super);
29270
- function LineDiff() {
29271
- var _this = _super !== null && _super.apply(this, arguments) || this;
29272
- _this.tokenize = tokenize;
29273
- return _this;
29274
- }
29275
- LineDiff.prototype.equals = function (left, right, options) {
28727
+ class LineDiff extends Diff {
28728
+ constructor() {
28729
+ super(...arguments);
28730
+ this.tokenize = tokenize;
28731
+ }
28732
+ equals(left, right, options) {
29276
28733
  // If we're ignoring whitespace, we need to normalise lines by stripping
29277
28734
  // whitespace before checking equality. (This has an annoying interaction
29278
28735
  // with newlineIsToken that requires special handling: if newlines get their
@@ -29296,11 +28753,10 @@ var LineDiff = /** @class */ (function (_super) {
29296
28753
  right = right.slice(0, -1);
29297
28754
  }
29298
28755
  }
29299
- return _super.prototype.equals.call(this, left, right, options);
29300
- };
29301
- return LineDiff;
29302
- }(Diff));
29303
- var lineDiff = new LineDiff();
28756
+ return super.equals(left, right, options);
28757
+ }
28758
+ }
28759
+ const lineDiff = new LineDiff();
29304
28760
  function diffLines(oldStr, newStr, options) {
29305
28761
  return lineDiff.diff(oldStr, newStr, options);
29306
28762
  }
@@ -29310,14 +28766,14 @@ function tokenize(value, options) {
29310
28766
  // remove one \r before \n to match GNU diff's --strip-trailing-cr behavior
29311
28767
  value = value.replace(/\r\n/g, '\n');
29312
28768
  }
29313
- var retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
28769
+ const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
29314
28770
  // Ignore the final empty token that occurs if the string ends with a new line
29315
28771
  if (!linesAndNewlines[linesAndNewlines.length - 1]) {
29316
28772
  linesAndNewlines.pop();
29317
28773
  }
29318
28774
  // Merge the content and line separators into single tokens
29319
- for (var i = 0; i < linesAndNewlines.length; i++) {
29320
- var line = linesAndNewlines[i];
28775
+ for (let i = 0; i < linesAndNewlines.length; i++) {
28776
+ const line = linesAndNewlines[i];
29321
28777
  if (i % 2 && !options.newlineIsToken) {
29322
28778
  retLines[retLines.length - 1] += line;
29323
28779
  }
@@ -29328,100 +28784,24 @@ function tokenize(value, options) {
29328
28784
  return retLines;
29329
28785
  }
29330
28786
 
29331
- var __extends$3 = (undefined && undefined.__extends) || (function () {
29332
- var extendStatics = function (d, b) {
29333
- extendStatics = Object.setPrototypeOf ||
29334
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29335
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
29336
- return extendStatics(d, b);
29337
- };
29338
- return function (d, b) {
29339
- if (typeof b !== "function" && b !== null)
29340
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
29341
- extendStatics(d, b);
29342
- function __() { this.constructor = d; }
29343
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29344
- };
29345
- })();
29346
- var SentenceDiff = /** @class */ (function (_super) {
29347
- __extends$3(SentenceDiff, _super);
29348
- function SentenceDiff() {
29349
- return _super !== null && _super.apply(this, arguments) || this;
29350
- }
29351
- SentenceDiff.prototype.tokenize = function (value) {
29352
- return value.split(/(?<=[.!?])(\s+|$)/);
29353
- };
29354
- return SentenceDiff;
29355
- }(Diff));
29356
- new SentenceDiff();
29357
-
29358
- var __extends$2 = (undefined && undefined.__extends) || (function () {
29359
- var extendStatics = function (d, b) {
29360
- extendStatics = Object.setPrototypeOf ||
29361
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29362
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
29363
- return extendStatics(d, b);
29364
- };
29365
- return function (d, b) {
29366
- if (typeof b !== "function" && b !== null)
29367
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
29368
- extendStatics(d, b);
29369
- function __() { this.constructor = d; }
29370
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29371
- };
29372
- })();
29373
- var CssDiff = /** @class */ (function (_super) {
29374
- __extends$2(CssDiff, _super);
29375
- function CssDiff() {
29376
- return _super !== null && _super.apply(this, arguments) || this;
29377
- }
29378
- CssDiff.prototype.tokenize = function (value) {
29379
- return value.split(/([{}:;,]|\s+)/);
29380
- };
29381
- return CssDiff;
29382
- }(Diff));
29383
- new CssDiff();
29384
-
29385
- var __extends$1 = (undefined && undefined.__extends) || (function () {
29386
- var extendStatics = function (d, b) {
29387
- extendStatics = Object.setPrototypeOf ||
29388
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29389
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
29390
- return extendStatics(d, b);
29391
- };
29392
- return function (d, b) {
29393
- if (typeof b !== "function" && b !== null)
29394
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
29395
- extendStatics(d, b);
29396
- function __() { this.constructor = d; }
29397
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29398
- };
29399
- })();
29400
- var JsonDiff = /** @class */ (function (_super) {
29401
- __extends$1(JsonDiff, _super);
29402
- function JsonDiff() {
29403
- var _this = _super !== null && _super.apply(this, arguments) || this;
29404
- _this.tokenize = tokenize;
29405
- return _this;
29406
- }
29407
- Object.defineProperty(JsonDiff.prototype, "useLongestToken", {
29408
- get: function () {
29409
- // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
29410
- // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
29411
- return true;
29412
- },
29413
- enumerable: false,
29414
- configurable: true
29415
- });
29416
- JsonDiff.prototype.castInput = function (value, options) {
29417
- var undefinedReplacement = options.undefinedReplacement, _a = options.stringifyReplacer, stringifyReplacer = _a === void 0 ? function (k, v) { return typeof v === 'undefined' ? undefinedReplacement : v; } : _a;
28787
+ class JsonDiff extends Diff {
28788
+ constructor() {
28789
+ super(...arguments);
28790
+ this.tokenize = tokenize;
28791
+ }
28792
+ get useLongestToken() {
28793
+ // Discriminate between two lines of pretty-printed, serialized JSON where one of them has a
28794
+ // dangling comma and the other doesn't. Turns out including the dangling comma yields the nicest output:
28795
+ return true;
28796
+ }
28797
+ castInput(value, options) {
28798
+ const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === 'undefined' ? undefinedReplacement : v } = options;
29418
28799
  return typeof value === 'string' ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, ' ');
29419
- };
29420
- JsonDiff.prototype.equals = function (left, right, options) {
29421
- return _super.prototype.equals.call(this, left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'), options);
29422
- };
29423
- return JsonDiff;
29424
- }(Diff));
28800
+ }
28801
+ equals(left, right, options) {
28802
+ return super.equals(left.replace(/,([\r\n])/g, '$1'), right.replace(/,([\r\n])/g, '$1'), options);
28803
+ }
28804
+ }
29425
28805
  new JsonDiff();
29426
28806
  // This function handles the presence of circular references by bailing out when encountering an
29427
28807
  // object that is already on the "stack" of items being processed. Accepts an optional replacer
@@ -29431,13 +28811,13 @@ function canonicalize(obj, stack, replacementStack, replacer, key) {
29431
28811
  if (replacer) {
29432
28812
  obj = replacer(key === undefined ? '' : key, obj);
29433
28813
  }
29434
- var i;
28814
+ let i;
29435
28815
  for (i = 0; i < stack.length; i += 1) {
29436
28816
  if (stack[i] === obj) {
29437
28817
  return replacementStack[i];
29438
28818
  }
29439
28819
  }
29440
- var canonicalizedObj;
28820
+ let canonicalizedObj;
29441
28821
  if ('[object Array]' === Object.prototype.toString.call(obj)) {
29442
28822
  stack.push(obj);
29443
28823
  canonicalizedObj = new Array(obj.length);
@@ -29456,18 +28836,18 @@ function canonicalize(obj, stack, replacementStack, replacer, key) {
29456
28836
  stack.push(obj);
29457
28837
  canonicalizedObj = {};
29458
28838
  replacementStack.push(canonicalizedObj);
29459
- var sortedKeys = [];
29460
- var key_1;
29461
- for (key_1 in obj) {
28839
+ const sortedKeys = [];
28840
+ let key;
28841
+ for (key in obj) {
29462
28842
  /* istanbul ignore else */
29463
- if (Object.prototype.hasOwnProperty.call(obj, key_1)) {
29464
- sortedKeys.push(key_1);
28843
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
28844
+ sortedKeys.push(key);
29465
28845
  }
29466
28846
  }
29467
28847
  sortedKeys.sort();
29468
28848
  for (i = 0; i < sortedKeys.length; i += 1) {
29469
- key_1 = sortedKeys[i];
29470
- canonicalizedObj[key_1] = canonicalize(obj[key_1], stack, replacementStack, replacer, key_1);
28849
+ key = sortedKeys[i];
28850
+ canonicalizedObj[key] = canonicalize(obj[key], stack, replacementStack, replacer, key);
29471
28851
  }
29472
28852
  stack.pop();
29473
28853
  replacementStack.pop();
@@ -29478,76 +28858,8 @@ function canonicalize(obj, stack, replacementStack, replacer, key) {
29478
28858
  return canonicalizedObj;
29479
28859
  }
29480
28860
 
29481
- var __extends = (undefined && undefined.__extends) || (function () {
29482
- var extendStatics = function (d, b) {
29483
- extendStatics = Object.setPrototypeOf ||
29484
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
29485
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
29486
- return extendStatics(d, b);
29487
- };
29488
- return function (d, b) {
29489
- if (typeof b !== "function" && b !== null)
29490
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
29491
- extendStatics(d, b);
29492
- function __() { this.constructor = d; }
29493
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29494
- };
29495
- })();
29496
- var ArrayDiff = /** @class */ (function (_super) {
29497
- __extends(ArrayDiff, _super);
29498
- function ArrayDiff() {
29499
- return _super !== null && _super.apply(this, arguments) || this;
29500
- }
29501
- ArrayDiff.prototype.tokenize = function (value) {
29502
- return value.slice();
29503
- };
29504
- ArrayDiff.prototype.join = function (value) {
29505
- return value;
29506
- };
29507
- ArrayDiff.prototype.removeEmpty = function (value) {
29508
- return value;
29509
- };
29510
- return ArrayDiff;
29511
- }(Diff));
29512
- new ArrayDiff();
29513
-
29514
- var __assign$2 = (undefined && undefined.__assign) || function () {
29515
- __assign$2 = Object.assign || function(t) {
29516
- for (var s, i = 1, n = arguments.length; i < n; i++) {
29517
- s = arguments[i];
29518
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29519
- t[p] = s[p];
29520
- }
29521
- return t;
29522
- };
29523
- return __assign$2.apply(this, arguments);
29524
- };
29525
-
29526
- var __assign$1 = (undefined && undefined.__assign) || function () {
29527
- __assign$1 = Object.assign || function(t) {
29528
- for (var s, i = 1, n = arguments.length; i < n; i++) {
29529
- s = arguments[i];
29530
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29531
- t[p] = s[p];
29532
- }
29533
- return t;
29534
- };
29535
- return __assign$1.apply(this, arguments);
29536
- };
29537
-
29538
- var __assign = (undefined && undefined.__assign) || function () {
29539
- __assign = Object.assign || function(t) {
29540
- for (var s, i = 1, n = arguments.length; i < n; i++) {
29541
- s = arguments[i];
29542
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
29543
- t[p] = s[p];
29544
- }
29545
- return t;
29546
- };
29547
- return __assign.apply(this, arguments);
29548
- };
29549
28861
  function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
29550
- var optionsObj;
28862
+ let optionsObj;
29551
28863
  if (!options) {
29552
28864
  optionsObj = {};
29553
28865
  }
@@ -29562,7 +28874,7 @@ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, ne
29562
28874
  }
29563
28875
  // We copy this into its own variable to placate TypeScript, which thinks
29564
28876
  // optionsObj.context might be undefined in the callbacks below.
29565
- var context = optionsObj.context;
28877
+ const context = optionsObj.context;
29566
28878
  // @ts-expect-error (runtime check for something that is correctly a static type error)
29567
28879
  if (optionsObj.newlineIsToken) {
29568
28880
  throw new Error('newlineIsToken may not be used with patch-generation functions, only with diffing functions');
@@ -29571,12 +28883,12 @@ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, ne
29571
28883
  return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
29572
28884
  }
29573
28885
  else {
29574
- var callback_1 = optionsObj.callback;
29575
- diffLines(oldStr, newStr, __assign(__assign({}, optionsObj), { callback: function (diff) {
29576
- var patch = diffLinesResultToPatch(diff);
28886
+ const { callback } = optionsObj;
28887
+ diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
28888
+ const patch = diffLinesResultToPatch(diff);
29577
28889
  // TypeScript is unhappy without the cast because it does not understand that `patch` may
29578
28890
  // be undefined here only if `callback` is StructuredPatchCallbackAbortable:
29579
- callback_1(patch);
28891
+ callback(patch);
29580
28892
  } }));
29581
28893
  }
29582
28894
  function diffLinesResultToPatch(diff) {
@@ -29589,15 +28901,15 @@ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, ne
29589
28901
  function contextLines(lines) {
29590
28902
  return lines.map(function (entry) { return ' ' + entry; });
29591
28903
  }
29592
- var hunks = [];
29593
- var oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
29594
- for (var i = 0; i < diff.length; i++) {
29595
- var current = diff[i], lines = current.lines || splitLines(current.value);
28904
+ const hunks = [];
28905
+ let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
28906
+ for (let i = 0; i < diff.length; i++) {
28907
+ const current = diff[i], lines = current.lines || splitLines(current.value);
29596
28908
  current.lines = lines;
29597
28909
  if (current.added || current.removed) {
29598
28910
  // If we have previous context, start with that
29599
28911
  if (!oldRangeStart) {
29600
- var prev = diff[i - 1];
28912
+ const prev = diff[i - 1];
29601
28913
  oldRangeStart = oldLine;
29602
28914
  newRangeStart = newLine;
29603
28915
  if (prev) {
@@ -29607,8 +28919,7 @@ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, ne
29607
28919
  }
29608
28920
  }
29609
28921
  // Output our changes
29610
- for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
29611
- var line = lines_1[_i];
28922
+ for (const line of lines) {
29612
28923
  curRange.push((current.added ? '+' : '-') + line);
29613
28924
  }
29614
28925
  // Track the updated file position
@@ -29625,19 +28936,17 @@ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, ne
29625
28936
  // Close out any changes that have been output (or join overlapping)
29626
28937
  if (lines.length <= context * 2 && i < diff.length - 2) {
29627
28938
  // Overlapping
29628
- for (var _a = 0, _b = contextLines(lines); _a < _b.length; _a++) {
29629
- var line = _b[_a];
28939
+ for (const line of contextLines(lines)) {
29630
28940
  curRange.push(line);
29631
28941
  }
29632
28942
  }
29633
28943
  else {
29634
28944
  // end the range and output
29635
- var contextSize = Math.min(lines.length, context);
29636
- for (var _c = 0, _d = contextLines(lines.slice(0, contextSize)); _c < _d.length; _c++) {
29637
- var line = _d[_c];
28945
+ const contextSize = Math.min(lines.length, context);
28946
+ for (const line of contextLines(lines.slice(0, contextSize))) {
29638
28947
  curRange.push(line);
29639
28948
  }
29640
- var hunk = {
28949
+ const hunk = {
29641
28950
  oldStart: oldRangeStart,
29642
28951
  oldLines: (oldLine - oldRangeStart + contextSize),
29643
28952
  newStart: newRangeStart,
@@ -29656,9 +28965,8 @@ function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, ne
29656
28965
  }
29657
28966
  // Step 2: eliminate the trailing `\n` from each line of each hunk, and, where needed, add
29658
28967
  // "".
29659
- for (var _e = 0, hunks_1 = hunks; _e < hunks_1.length; _e++) {
29660
- var hunk = hunks_1[_e];
29661
- for (var i = 0; i < hunk.lines.length; i++) {
28968
+ for (const hunk of hunks) {
28969
+ for (let i = 0; i < hunk.lines.length; i++) {
29662
28970
  if (hunk.lines[i].endsWith('\n')) {
29663
28971
  hunk.lines[i] = hunk.lines[i].slice(0, -1);
29664
28972
  }
@@ -29683,15 +28991,15 @@ function formatPatch(patch) {
29683
28991
  if (Array.isArray(patch)) {
29684
28992
  return patch.map(formatPatch).join('\n');
29685
28993
  }
29686
- var ret = [];
28994
+ const ret = [];
29687
28995
  if (patch.oldFileName == patch.newFileName) {
29688
28996
  ret.push('Index: ' + patch.oldFileName);
29689
28997
  }
29690
28998
  ret.push('===================================================================');
29691
28999
  ret.push('--- ' + patch.oldFileName + (typeof patch.oldHeader === 'undefined' ? '' : '\t' + patch.oldHeader));
29692
29000
  ret.push('+++ ' + patch.newFileName + (typeof patch.newHeader === 'undefined' ? '' : '\t' + patch.newHeader));
29693
- for (var i = 0; i < patch.hunks.length; i++) {
29694
- var hunk = patch.hunks[i];
29001
+ for (let i = 0; i < patch.hunks.length; i++) {
29002
+ const hunk = patch.hunks[i];
29695
29003
  // Unified Diff Format quirk: If the chunk size is 0,
29696
29004
  // the first number is one lower than one would expect.
29697
29005
  // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
@@ -29704,8 +29012,7 @@ function formatPatch(patch) {
29704
29012
  ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines
29705
29013
  + ' +' + hunk.newStart + ',' + hunk.newLines
29706
29014
  + ' @@');
29707
- for (var _i = 0, _a = hunk.lines; _i < _a.length; _i++) {
29708
- var line = _a[_i];
29015
+ for (const line of hunk.lines) {
29709
29016
  ret.push(line);
29710
29017
  }
29711
29018
  }
@@ -29716,20 +29023,20 @@ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader
29716
29023
  options = { callback: options };
29717
29024
  }
29718
29025
  if (!(options === null || options === void 0 ? void 0 : options.callback)) {
29719
- var patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
29026
+ const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
29720
29027
  if (!patchObj) {
29721
29028
  return;
29722
29029
  }
29723
29030
  return formatPatch(patchObj);
29724
29031
  }
29725
29032
  else {
29726
- var callback_2 = options.callback;
29727
- structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, __assign(__assign({}, options), { callback: function (patchObj) {
29033
+ const { callback } = options;
29034
+ structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: patchObj => {
29728
29035
  if (!patchObj) {
29729
- callback_2(undefined);
29036
+ callback(undefined);
29730
29037
  }
29731
29038
  else {
29732
- callback_2(formatPatch(patchObj));
29039
+ callback(formatPatch(patchObj));
29733
29040
  }
29734
29041
  } }));
29735
29042
  }
@@ -29738,8 +29045,8 @@ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader
29738
29045
  * Split `text` into an array of lines, including the trailing newline character (where present)
29739
29046
  */
29740
29047
  function splitLines(text) {
29741
- var hasTrailingNl = text.endsWith('\n');
29742
- var result = text.split('\n').map(function (line) { return line + '\n'; });
29048
+ const hasTrailingNl = text.endsWith('\n');
29049
+ const result = text.split('\n').map(line => line + '\n');
29743
29050
  if (hasTrailingNl) {
29744
29051
  result.pop();
29745
29052
  }
@@ -56853,4 +56160,4 @@ var srcExports = requireSrc();
56853
56160
  var tinylr = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
56854
56161
 
56855
56162
  export { HighlightJS as H, MarkdownIt as M, deflist_plugin as a, closest as b, createTwoFilesPatch as c, dedent as d, distance as e, fm as f, globSync as g, glob as h, isCI as i, moduleImporter as j, cliProgress as k, createInstance as l, minimatch as m, fse as n, tinylr as t, watch$1 as w };
56856
- //# sourceMappingURL=vendor-DxEOke6B.mjs.map
56163
+ //# sourceMappingURL=vendor-FPCgg4HV.mjs.map