@forsakringskassan/docs-generator 2.37.1 → 2.38.1

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.
@@ -2,16 +2,15 @@ import { createRequire as $createRequire } from "node:module";
2
2
 
3
3
  const require = $createRequire(import.meta.url);
4
4
 
5
- import { c as createSyncFn, d as dedent, H as HighlightJS, b as createTwoFilesPatch, M as MarkdownIt, e as deflist_plugin } from './vendor-Bk5vSW_n.mjs';
5
+ import { c as createSyncFn, d as dedent, H as HighlightJS, b as createTwoFilesPatch, M as MarkdownIt, e as deflist_plugin } from './vendor-BK-uA6Uv.mjs';
6
6
  import path from 'node:path/posix';
7
7
  import path__default from 'node:path';
8
- import 'crypto';
9
8
  import crypto from 'node:crypto';
10
9
  import 'node:child_process';
11
10
  import { fileURLToPath } from 'node:url';
12
11
  import fs__default from 'node:fs';
13
12
  import { version } from 'vue';
14
- import { g as generateCode } from './vue3-DtTC1eal.mjs';
13
+ import { g as generateCode } from './vue3-fRI2JWNs.mjs';
15
14
 
16
15
  function isDocumentPage(doc) {
17
16
  return doc.kind === "page";
@@ -54,9 +53,9 @@ function findVersion(text) {
54
53
  const match = /(\d+)\.(\d+)\.(\d+) \(\d+-\d+-\d+\)/.exec(text);
55
54
  if (match) {
56
55
  return [
57
- parseInt(match[1], 10),
58
- parseInt(match[2], 10),
59
- parseInt(match[3], 10)
56
+ Number.parseInt(match[1], 10),
57
+ Number.parseInt(match[2], 10),
58
+ Number.parseInt(match[3], 10)
60
59
  ];
61
60
  } else {
62
61
  return null;
@@ -67,7 +66,10 @@ function generateId(text) {
67
66
  if (version) {
68
67
  return `v${version.join("-")}`;
69
68
  }
70
- return text.toLowerCase().trim().replace(/[åäö]/g, (m) => replacements[m]).replace(/[^a-z0-9]+/g, "_").replace(/^_+/, "").replace(/_+$/, "");
69
+ return text.toLowerCase().trim().replaceAll(
70
+ /[äåö]/g,
71
+ (m) => replacements[m]
72
+ ).replaceAll(/[^\da-z]+/g, "_").replace(/^_+/, "").replace(/_+$/, "");
71
73
  }
72
74
 
73
75
  function getFingerprint(source) {
@@ -76,7 +78,7 @@ function getFingerprint(source) {
76
78
 
77
79
  function normalizePath(...pathSegments) {
78
80
  const filePath = path.join(...pathSegments);
79
- return path.normalize(filePath).replace(/^([A-Z]):\\/, "/").replace(/\\/g, "/");
81
+ return path.normalize(filePath).replace(/^([A-Z]):\\/, "/").replaceAll("\\", "/");
80
82
  }
81
83
 
82
84
  function getOutputFilePath(outputFolder, fileInfo) {
@@ -87,7 +89,7 @@ function getOutputFilePath(outputFolder, fileInfo) {
87
89
  return normalizePath(outputFolder, path, outputName);
88
90
  }
89
91
 
90
- const url$1 = new URL("./format-code.worker-CRcs4_Zl.mjs", import.meta.url);
92
+ const url$1 = new URL("./format-code.worker-DH_m5cgv.mjs", import.meta.url);
91
93
  const filePath$1 = fileURLToPath(url$1);
92
94
 
93
95
  createSyncFn(filePath$1);
@@ -105,7 +107,7 @@ const replacement = {
105
107
  "'": `'`
106
108
  };
107
109
  function htmlencode(text) {
108
- return text.replace(/[<>&"']/g, (m) => {
110
+ return text.replaceAll(/["&'<>]/g, (m) => {
109
111
  return replacement[m];
110
112
  });
111
113
  }
@@ -116,7 +118,7 @@ function parseImport(raw) {
116
118
  let previous;
117
119
  do {
118
120
  previous = stripped;
119
- stripped = stripped.replace(/<!--.*?-->/gms, (match) => {
121
+ stripped = stripped.replaceAll(/<!--.*?-->/gms, (match) => {
120
122
  comments.push(match);
121
123
  return "";
122
124
  });
@@ -134,7 +136,7 @@ function getExampleName(filename) {
134
136
  return path__default.parse(filename).name;
135
137
  }
136
138
 
137
- const vueMajor = parseInt(version.split(".", 2)[0], 10);
139
+ const vueMajor = Number.parseInt(version.split(".", 2)[0], 10);
138
140
  function vueGenerator() {
139
141
  switch (vueMajor) {
140
142
  case 2:
@@ -152,7 +154,7 @@ function generateExample(options) {
152
154
  const filename = fileMatcher(parsed.filename, "when importing example");
153
155
  const language2 = parsed.extension;
154
156
  const comments = parsed.comments;
155
- const content = fs__default.readFileSync(filename, "utf-8");
157
+ const content = fs__default.readFileSync(filename, "utf8");
156
158
  const example = generateExample({
157
159
  ...options,
158
160
  source: content,
@@ -269,15 +271,15 @@ function cutSnippets(code) {
269
271
  ` : it);
270
272
  const directive = (
271
273
  /* eslint-disable-next-line sonarjs/regex-complexity -- not to bad for a regexp */
272
- /(?:\/\* +--- +cut (?<js>above|below|begin|end) +--- +\*\/|<!---? +cut (?<html>above|below|begin|end) +---?>)/
274
+ /\/\* +--- +cut (?<js>above|below|begin|end) +--- +\*\/|<!---? +cut (?<html>above|below|begin|end) +---?>/
273
275
  );
274
276
  let buffer = -1;
275
- lines.forEach((line, index) => {
277
+ for (const [index, line] of lines.entries()) {
276
278
  const match = directive.exec(line);
277
279
  const { js, html } = match?.groups ?? { js: null, html: null };
278
280
  const instruction = js ?? html;
279
281
  if (!instruction) {
280
- return;
282
+ continue;
281
283
  }
282
284
  switch (instruction) {
283
285
  /* --- cut above --- */
@@ -309,7 +311,7 @@ function cutSnippets(code) {
309
311
  buffer = -1;
310
312
  break;
311
313
  }
312
- });
314
+ }
313
315
  if (buffer >= 0) {
314
316
  removeLinesInline(lines, {
315
317
  begin: buffer,
@@ -319,14 +321,17 @@ function cutSnippets(code) {
319
321
  return lines.join("");
320
322
  }
321
323
  function stripEslintComments(code) {
322
- const matchLine = /^[ \t]*(\/\* eslint-disable[^*]*\*\/|\/\/ eslint-disable.*)\n/gm;
323
- const matchEmbedded = /[ \t]*(\/\* eslint-disable[^*]*\*\/|\/\/ eslint-disable.*)/g;
324
- return code.replace(matchLine, "").replace(matchEmbedded, "");
324
+ const matchLine = /^[\t ]*(\/\* eslint-disable[^*]*\*\/|\/\/ eslint-disable.*)\n/gm;
325
+ const matchEmbedded = (
326
+ /* eslint-disable-next-line sonarjs/slow-regex -- technical debt */
327
+ /[\t ]*(\/\* eslint-disable[^*]*\*\/|\/\/ eslint-disable.*)/g
328
+ );
329
+ return code.replaceAll(matchLine, "").replaceAll(matchEmbedded, "");
325
330
  }
326
331
  function stripHtmlValidateComments(code) {
327
- const matchLine = /^[ \t]*(<!--\s*\[html-validate-[^\]]+]\s*-->)\n/gm;
328
- const matchEmbedded = /[ \t]*(<!--\s*\[html-validate-[^\]]+]\s*-->)/g;
329
- return code.replace(matchLine, "").replace(matchEmbedded, "");
332
+ const matchLine = /^[\t ]*(<!--\s*\[html-validate-[^\]]+]\s*-->)\n/gm;
333
+ const matchEmbedded = /[\t ]*(<!--\s*\[html-validate-[^\]]+]\s*-->)/g;
334
+ return code.replaceAll(matchLine, "").replaceAll(matchEmbedded, "");
330
335
  }
331
336
  function maybeDedent(value) {
332
337
  if (/^\s*$/.test(value)) {
@@ -358,7 +363,7 @@ function transformCode(code, lang) {
358
363
  return code;
359
364
  }
360
365
 
361
- const url = new URL("./worker-DUs54YZx.mjs", import.meta.url);
366
+ const url = new URL("./worker-DEFReXeu.mjs", import.meta.url);
362
367
  const filePath = fileURLToPath(url);
363
368
 
364
369
  class SoftError extends Error {
@@ -369,7 +374,7 @@ class SoftError extends Error {
369
374
  */
370
375
  constructor(code, message, ...args) {
371
376
  super(message);
372
- this.name = this.constructor.name;
377
+ this.name = "SoftError";
373
378
  this.code = code;
374
379
  const [details] = args;
375
380
  this.details = details;
@@ -466,14 +471,14 @@ function findTestId(tags) {
466
471
  const tag = tags.find((it) => {
467
472
  return it.startsWith(prefix);
468
473
  });
469
- const match = tag?.match(/^test-id=(?:"([^"]+)"|'([^']+)'|([^'"]+))$/);
474
+ const match = tag?.match(/^test-id=(?:"([^"]+)"|'([^']+)'|([^"']+))$/);
470
475
  if (!match) {
471
476
  return null;
472
477
  }
473
478
  return match.slice(1).find(Boolean) ?? null;
474
479
  }
475
480
 
476
- const HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
481
+ const HTML_ESCAPE_REPLACE_RE = /["&<>]/g;
477
482
  const HTML_REPLACEMENTS = {
478
483
  "&": "&amp;",
479
484
  "<": "&lt;",
@@ -481,7 +486,10 @@ const HTML_REPLACEMENTS = {
481
486
  '"': "&quot;"
482
487
  };
483
488
  function escapeHtml(str) {
484
- return str.replace(HTML_ESCAPE_REPLACE_RE, (ch) => HTML_REPLACEMENTS[ch]);
489
+ return str.replaceAll(
490
+ HTML_ESCAPE_REPLACE_RE,
491
+ (ch) => HTML_REPLACEMENTS[ch]
492
+ );
485
493
  }
486
494
  function wrap(content, language) {
487
495
  const markup = (
@@ -514,7 +522,7 @@ function highlight({
514
522
  }
515
523
 
516
524
  function replaceAtLink(text) {
517
- return text.replace(
525
+ return text.replaceAll(
518
526
  /{@link [^}]+[$}]/g,
519
527
  (match) => match.replace(/^{/, "&lcub;").replace(/}$/, "&rcub;")
520
528
  );
@@ -567,7 +575,7 @@ function codePreview(options) {
567
575
  );
568
576
  const b = ensureTrailingNewline(transformCode(content, language));
569
577
  const diff = createTwoFilesPatch("a", "b", a, b, "", "", {
570
- context: context ? parseInt(context, 10) : 3,
578
+ context: context ? Number.parseInt(context, 10) : 3,
571
579
  ignoreWhitespace: true
572
580
  }).split("\n").slice(4).join("\n");
573
581
  return {
@@ -762,7 +770,7 @@ function headingLevel(options) {
762
770
  }
763
771
  ids.add(id);
764
772
  return tag.replace(/h(\d)/, (_, n) => {
765
- const level = parseInt(n, 10) + offset;
773
+ const level = Number.parseInt(n, 10) + offset;
766
774
  env.currentHeading = level;
767
775
  return `<h${String(level)} id="${id}"><a class="header-anchor" href="#${id}">`;
768
776
  });
@@ -770,7 +778,7 @@ function headingLevel(options) {
770
778
  md.renderer.rules.heading_close = function(tokens, idx) {
771
779
  const { tag } = tokens[idx];
772
780
  return tag.replace(/h(\d)/, (_, n) => {
773
- const level = parseInt(n, 10) + offset;
781
+ const level = Number.parseInt(n, 10) + offset;
774
782
  return `</a></h${String(level)}>`;
775
783
  });
776
784
  };
@@ -857,7 +865,7 @@ function apiContainer(context) {
857
865
  included.set(key, context.doc.id);
858
866
  const body = typeof doc.body === "string" ? doc.body : doc.body(tags);
859
867
  if (doc.format === "html") {
860
- return body.replace(
868
+ return body.replaceAll(
861
869
  /* replace `<next-heading-level>` and `</next-heading-level>` with actual h-tags */
862
870
  /(?<=<\/?)next-heading-level/g,
863
871
  `h${String(env.currentHeading + 1)}`
@@ -945,7 +953,7 @@ function messageboxContainer(context, options, alias) {
945
953
  }
946
954
 
947
955
  const markerStr = ":";
948
- const markerChar = markerStr.charCodeAt(0);
956
+ const markerChar = markerStr.codePointAt(0);
949
957
  function containerParser(md, options) {
950
958
  function container(state, startLine, endLine, silent) {
951
959
  let pos = state.bMarks[startLine] + state.tShift[startLine];
@@ -956,7 +964,7 @@ function containerParser(md, options) {
956
964
  if (pos + 3 > max) {
957
965
  return false;
958
966
  }
959
- const marker = state.src.charCodeAt(pos);
967
+ const marker = state.src.codePointAt(pos);
960
968
  if (marker !== markerChar) {
961
969
  return false;
962
970
  }
@@ -985,7 +993,7 @@ function containerParser(md, options) {
985
993
  if (pos < max && state.sCount[nextLine] < state.blkIndent) {
986
994
  break;
987
995
  }
988
- if (state.src.charCodeAt(pos) !== marker) {
996
+ if (state.src.codePointAt(pos) !== marker) {
989
997
  continue;
990
998
  }
991
999
  if (state.sCount[nextLine] - state.blkIndent >= 4) {
@@ -1048,11 +1056,11 @@ function containerRenderer(doc, docs, env, included, handleSoftError, options) {
1048
1056
  };
1049
1057
  }
1050
1058
 
1059
+ const renderToken = (...args) => {
1060
+ const [tokens, idx, options, , self] = args;
1061
+ return self.renderToken(tokens, idx, options);
1062
+ };
1051
1063
  function paragraph() {
1052
- const renderToken = (...args) => {
1053
- const [tokens, idx, options, , self] = args;
1054
- return self.renderToken(tokens, idx, options);
1055
- };
1056
1064
  return function(md) {
1057
1065
  const renderRule = md.renderer.rules.paragraph_open ?? renderToken;
1058
1066
  md.renderer.rules.paragraph_open = (tokens, idx, index, env, self) => {
@@ -1084,7 +1092,7 @@ function codeInline() {
1084
1092
  }
1085
1093
 
1086
1094
  function processInlineTags(tags, doc, docs, text, handleSoftError) {
1087
- return text.replace(
1095
+ return text.replaceAll(
1088
1096
  /{@(@?)([^{}]+)}/g,
1089
1097
  (_, escape, content) => {
1090
1098
  if (escape) {
@@ -1191,4 +1199,4 @@ function createMarkdownRenderer(options) {
1191
1199
  }
1192
1200
 
1193
1201
  export { SoftError as S, getFingerprint as a, getOutputFilePath as b, createMarkdownRenderer as c, htmlencode as d, filePath as e, findTag as f, generateId as g, hasTag as h, isDocumentPage as i, generateExample as j, normalizePath as n, parseInfostring as p };
1194
- //# sourceMappingURL=create-markdown-renderer-BO8ZE3IZ.mjs.map
1202
+ //# sourceMappingURL=create-markdown-renderer-1_yCrnbT.mjs.map