@forsakringskassan/docs-generator 3.22.2 → 3.22.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/markdown.mjs CHANGED
@@ -2,8 +2,8 @@ import { createRequire as $createRequire } from "node:module";
2
2
 
3
3
  const require = $createRequire(import.meta.url);
4
4
 
5
- export { S as SoftError, c as createMarkdownRenderer } from './create-markdown-renderer-Bdz-A22S.mjs';
6
- import './vendor-D1q9wBug.mjs';
5
+ export { S as SoftError, c as createMarkdownRenderer } from './create-markdown-renderer-DtRTTcqZ.mjs';
6
+ import './vendor-DDcR0yPO.mjs';
7
7
  import 'node:url';
8
8
  import 'node:path';
9
9
  import 'fs';
@@ -15572,6 +15572,9 @@ const deepFind = (obj, path, keySeparator = '.') => {
15572
15572
  }
15573
15573
  nextPath += tokens[j];
15574
15574
  next = current[nextPath];
15575
+ if ((typeof next === 'function' || nextPath === '__proto__') && !Object.prototype.hasOwnProperty.call(current, nextPath)) {
15576
+ next = undefined;
15577
+ }
15575
15578
  if (next !== undefined) {
15576
15579
  if (['string', 'number', 'boolean'].includes(typeof next) && j < tokens.length - 1) {
15577
15580
  continue;
@@ -15739,12 +15742,12 @@ class ResourceStore extends EventEmitter {
15739
15742
  }
15740
15743
  }
15741
15744
  const result = getPath(this.data, path);
15742
- if (!result && !ns && !key && lng.includes('.')) {
15745
+ if (result == null && !ns && !key && lng.includes('.')) {
15743
15746
  lng = path[0];
15744
15747
  ns = path[1];
15745
15748
  key = path.slice(2).join('.');
15746
15749
  }
15747
- if (result || !ignoreJSONStructure || !isString(key)) return result;
15750
+ if (result != null || !ignoreJSONStructure || !isString(key)) return result;
15748
15751
  return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
15749
15752
  }
15750
15753
  addResource(lng, ns, key, value, options = {
@@ -16058,7 +16061,7 @@ class Translator extends EventEmitter {
16058
16061
  }
16059
16062
  } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
16060
16063
  res = res.join(joinArrays);
16061
- if (res) res = this.extendTranslation(res, keys, opt, lastKey);
16064
+ if (res) res = this.extendTranslation(res, keys, opt, resolved, lastKey);
16062
16065
  } else {
16063
16066
  let usedDefault = false;
16064
16067
  let usedKey = false;
@@ -16383,7 +16386,6 @@ class LanguageUtil {
16383
16386
  if (supportedLng === lngOnly) return true;
16384
16387
  if (!supportedLng.includes('-') && !lngOnly.includes('-')) return false;
16385
16388
  if (supportedLng.includes('-') && !lngOnly.includes('-') && supportedLng.slice(0, supportedLng.indexOf('-')) === lngOnly) return true;
16386
- if (supportedLng.startsWith(lngOnly) && lngOnly.length > 1) return true;
16387
16389
  return false;
16388
16390
  });
16389
16391
  });
@@ -16536,7 +16538,6 @@ const deepFindWithDefaults = (data, defaultData, key, keySeparator = '.', ignore
16536
16538
  }
16537
16539
  return path;
16538
16540
  };
16539
- const regexSafe = val => val.replace(/\$/g, '$$$$');
16540
16541
  class Interpolator {
16541
16542
  constructor(options = {}) {
16542
16543
  this.logger = baseLogger.create('interpolator');
@@ -16633,9 +16634,17 @@ class Interpolator {
16633
16634
  regex: this.regexp,
16634
16635
  safeValue: val => this.escapeValue ? this.escape(val) : val
16635
16636
  }];
16637
+ const unescapedValues = [];
16638
+ let shift = 0;
16636
16639
  todos.forEach(todo => {
16637
16640
  replaces = 0;
16638
16641
  while (match = todo.regex.exec(str)) {
16642
+ const at = match.index - shift;
16643
+ const written = unescapedValues.find(([start, end]) => at >= start && at < end);
16644
+ if (written) {
16645
+ todo.regex.lastIndex = written[1] + shift;
16646
+ continue;
16647
+ }
16639
16648
  const matchedVar = match[1].trim();
16640
16649
  value = handleFormat(matchedVar);
16641
16650
  if (value === undefined) {
@@ -16654,9 +16663,14 @@ class Interpolator {
16654
16663
  } else if (!isString(value) && !this.useRawValueToEscape) {
16655
16664
  value = makeString$1(value);
16656
16665
  }
16657
- const safeValue = todo.safeValue(value);
16658
- str = str.replace(match[0], regexSafe(safeValue));
16666
+ const safeValue = makeString$1(todo.safeValue(value));
16667
+ str = str.slice(0, match.index) + safeValue + str.slice(match.index + match[0].length);
16659
16668
  if (skipOnVariables) {
16669
+ if (todo.regex === this.regexpUnescape) {
16670
+ unescapedValues.push([match.index, match.index + safeValue.length]);
16671
+ } else {
16672
+ shift += safeValue.length - match[0].length;
16673
+ }
16660
16674
  todo.regex.lastIndex += safeValue.length;
16661
16675
  todo.regex.lastIndex -= match[0].length;
16662
16676
  } else {
@@ -16777,7 +16791,12 @@ const createCachedFormatter = fn => {
16777
16791
  [o.interpolationkey]: undefined
16778
16792
  };
16779
16793
  }
16780
- const key = l + JSON.stringify(optForCache);
16794
+ let key;
16795
+ try {
16796
+ key = l + JSON.stringify(optForCache);
16797
+ } catch (e) {
16798
+ return fn(getCleanedCode(l), o)(v);
16799
+ }
16781
16800
  let frm = cache[key];
16782
16801
  if (!frm) {
16783
16802
  frm = fn(getCleanedCode(l), o);
@@ -17627,18 +17646,16 @@ class I18n extends EventEmitter {
17627
17646
  hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
17628
17647
  };
17629
17648
  if (forkResourceStore) {
17630
- const clonedData = Object.keys(this.store.data).reduce((prev, l) => {
17631
- prev[l] = {
17632
- ...this.store.data[l]
17649
+ const copyData = obj => {
17650
+ const copied = Array.isArray(obj) ? [...obj] : {
17651
+ ...obj
17633
17652
  };
17634
- prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
17635
- acc[n] = {
17636
- ...prev[l][n]
17637
- };
17638
- return acc;
17639
- }, prev[l]);
17640
- return prev;
17641
- }, {});
17653
+ Object.keys(copied).forEach(k => {
17654
+ if (copied[k] && typeof copied[k] === 'object') copied[k] = copyData(copied[k]);
17655
+ });
17656
+ return copied;
17657
+ };
17658
+ const clonedData = copyData(this.store.data);
17642
17659
  clone.store = new ResourceStore(clonedData, mergedOptions);
17643
17660
  clone.services.resourceStore = clone.store;
17644
17661
  }
@@ -69512,4 +69529,4 @@ var yaml = /*#__PURE__*/Object.freeze({
69512
69529
  });
69513
69530
 
69514
69531
  export { HighlightJS as H, MarkdownItCallable as M, Ze$b as Z, resolveConfig as a, createTwoFilesPatch$1 as b, createSyncFn as c, dedent$1 as d, deflist_plugin as e, format2 as f, fm$3 as g, strFromU8 as h, closest as i, distance as j, isCI as k, cliProgress as l, moduleImporter as m, createInstance as n, fse as o, inter as p, runAsWorker as r, strToU8 as s, tinylr as t, watch$1 as w, zlibSync as z };
69515
- //# sourceMappingURL=vendor-D1q9wBug.mjs.map
69532
+ //# sourceMappingURL=vendor-DDcR0yPO.mjs.map