@forsakringskassan/docs-generator 2.40.3 → 2.41.0

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,7 +2,7 @@ import { createRequire as $createRequire } from "node:module";
2
2
 
3
3
  const require = $createRequire(import.meta.url);
4
4
 
5
- import { r as runAsWorker, f as format2, a as resolveConfig } from './vendor-tIJeYoyt.mjs';
5
+ import { r as runAsWorker, f as format2, a as resolveConfig } from './vendor-BhMQq6vU.mjs';
6
6
  import 'node:url';
7
7
  import 'node:path';
8
8
  import 'fs';
@@ -54,4 +54,4 @@ async function formatCode(source, filepath) {
54
54
  runAsWorker(formatCode);
55
55
 
56
56
  export { formatCode };
57
- //# sourceMappingURL=format-code.worker-hU0IS7DM.mjs.map
57
+ //# sourceMappingURL=format-code.worker-D9HbtonD.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-code.worker-hU0IS7DM.mjs","sources":["../src/utils/format-code.worker.ts"],"sourcesContent":["import { type Options, format as prettier, resolveConfig } from \"prettier\";\nimport { runAsWorker } from \"synckit\";\n\nconst configCache = new Map<string, Options | null>();\n\nasync function getConfig(filepath: string): Promise<Options | null> {\n const cached = configCache.get(filepath);\n if (cached !== undefined) {\n return cached;\n }\n const options = await resolveConfig(filepath);\n configCache.set(filepath, options);\n return options;\n}\n\n/**\n * @internal\n */\nexport async function formatCode(\n source: string,\n filepath: string,\n): Promise<string> {\n const options = await getConfig(filepath);\n const formatted = await prettier(source, { ...options, filepath });\n return formatted.trim();\n}\n\nrunAsWorker(formatCode);\n"],"names":["prettier"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,WAAA,uBAAkB,GAAA,EAA4B;AAEpD,eAAe,UAAU,QAAA,EAA2C;AAChE,EAAA,MAAM,MAAA,GAAS,WAAA,CAAY,GAAA,CAAI,QAAQ,CAAA;AACvC,EAAA,IAAI,WAAW,MAAA,EAAW;AACtB,IAAA,OAAO,MAAA;AAAA,EACX;AACA,EAAA,MAAM,OAAA,GAAU,MAAM,aAAA,CAAc,QAAQ,CAAA;AAC5C,EAAA,WAAA,CAAY,GAAA,CAAI,UAAU,OAAO,CAAA;AACjC,EAAA,OAAO,OAAA;AACX;AAKA,eAAsB,UAAA,CAClB,QACA,QAAA,EACe;AACf,EAAA,MAAM,OAAA,GAAU,MAAM,SAAA,CAAU,QAAQ,CAAA;AACxC,EAAA,MAAM,SAAA,GAAY,MAAMA,OAAA,CAAS,MAAA,EAAQ,EAAE,GAAG,OAAA,EAAS,UAAU,CAAA;AACjE,EAAA,OAAO,UAAU,IAAA,EAAK;AAC1B;AAEA,WAAA,CAAY,UAAU,CAAA;;;;"}
1
+ {"version":3,"file":"format-code.worker-D9HbtonD.mjs","sources":["../src/utils/format-code.worker.ts"],"sourcesContent":["import { type Options, format as prettier, resolveConfig } from \"prettier\";\nimport { runAsWorker } from \"synckit\";\n\nconst configCache = new Map<string, Options | null>();\n\nasync function getConfig(filepath: string): Promise<Options | null> {\n const cached = configCache.get(filepath);\n if (cached !== undefined) {\n return cached;\n }\n const options = await resolveConfig(filepath);\n configCache.set(filepath, options);\n return options;\n}\n\n/**\n * @internal\n */\nexport async function formatCode(\n source: string,\n filepath: string,\n): Promise<string> {\n const options = await getConfig(filepath);\n const formatted = await prettier(source, { ...options, filepath });\n return formatted.trim();\n}\n\nrunAsWorker(formatCode);\n"],"names":["prettier"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,WAAA,uBAAkB,GAAA,EAA4B;AAEpD,eAAe,UAAU,QAAA,EAA2C;AAChE,EAAA,MAAM,MAAA,GAAS,WAAA,CAAY,GAAA,CAAI,QAAQ,CAAA;AACvC,EAAA,IAAI,WAAW,MAAA,EAAW;AACtB,IAAA,OAAO,MAAA;AAAA,EACX;AACA,EAAA,MAAM,OAAA,GAAU,MAAM,aAAA,CAAc,QAAQ,CAAA;AAC5C,EAAA,WAAA,CAAY,GAAA,CAAI,UAAU,OAAO,CAAA;AACjC,EAAA,OAAO,OAAA;AACX;AAKA,eAAsB,UAAA,CAClB,QACA,QAAA,EACe;AACf,EAAA,MAAM,OAAA,GAAU,MAAM,SAAA,CAAU,QAAQ,CAAA;AACxC,EAAA,MAAM,SAAA,GAAY,MAAMA,OAAA,CAAS,MAAA,EAAQ,EAAE,GAAG,OAAA,EAAS,UAAU,CAAA;AACjE,EAAA,OAAO,UAAU,IAAA,EAAK;AAC1B;AAEA,WAAA,CAAY,UAAU,CAAA;;;;"}
package/dist/index.mjs CHANGED
@@ -4,8 +4,8 @@ const require = $createRequire(import.meta.url);
4
4
 
5
5
  import fs from 'node:fs/promises';
6
6
  import path from 'node:path/posix';
7
- import { t as ts, M as MarkdownIt, d as dedent, g as closest, h as distance, i as fm, j as isCI, Z as Ze, m as moduleImporter, k as cliProgress, l as tinylr, w as watch, n as createInstance, o as fse, p as inter } from './vendor-tIJeYoyt.mjs';
8
- import { g as generateId, p as parseInfostring, i as isDocumentPage, n as normalizePath, a as getFingerprint, h as hasTag, f as findTag, b as getOutputFilePath, d as htmlencode, e as filePath, c as createMarkdownRenderer, j as generateExample } from './create-markdown-renderer-aMNI8hLC.mjs';
7
+ import { t as ts, M as MarkdownIt, d as dedent, g as closest, h as distance, i as fm, j as isCI, Z as Ze, m as moduleImporter, k as cliProgress, l as tinylr, w as watch, n as createInstance, o as fse, p as inter } from './vendor-BhMQq6vU.mjs';
8
+ import { g as generateId, p as parseInfostring, i as isDocumentPage, n as normalizePath, a as getFingerprint, h as hasTag, f as findTag, b as getOutputFilePath, d as htmlencode, e as filePath, c as createMarkdownRenderer, j as generateExample } from './create-markdown-renderer-0pOJyVF_.mjs';
9
9
  import path__default from 'node:path';
10
10
  import crypto from 'node:crypto';
11
11
  import { exec, execSync } from 'node:child_process';
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-aMNI8hLC.mjs';
6
- import './vendor-tIJeYoyt.mjs';
5
+ export { S as SoftError, c as createMarkdownRenderer } from './create-markdown-renderer-0pOJyVF_.mjs';
6
+ import './vendor-BhMQq6vU.mjs';
7
7
  import 'node:url';
8
8
  import 'node:path';
9
9
  import 'fs';
@@ -21839,6 +21839,82 @@ function canonicalize(obj, stack, replacementStack, replacer, key) {
21839
21839
  return canonicalizedObj;
21840
21840
  }
21841
21841
 
21842
+ /**
21843
+ * Returns true if the filename contains characters that require C-style
21844
+ * quoting (as used by Git and GNU diffutils in diff output).
21845
+ */
21846
+ function needsQuoting(s) {
21847
+ for (let i = 0; i < s.length; i++) {
21848
+ if (s[i] < '\x20' || s[i] > '\x7e' || s[i] === '"' || s[i] === '\\') {
21849
+ return true;
21850
+ }
21851
+ }
21852
+ return false;
21853
+ }
21854
+ /**
21855
+ * C-style quotes a filename, encoding special characters as escape sequences
21856
+ * and non-ASCII bytes as octal escapes. This is the inverse of
21857
+ * `parseQuotedFileName` in parse.ts.
21858
+ *
21859
+ * Non-ASCII bytes are encoded as UTF-8 before being emitted as octal escapes.
21860
+ * This matches the behaviour of both Git and GNU diffutils, which always emit
21861
+ * UTF-8 octal escapes regardless of the underlying filesystem encoding (e.g.
21862
+ * Git for Windows converts from NTFS's UTF-16 to UTF-8 internally).
21863
+ *
21864
+ * If the filename doesn't need quoting, returns it as-is.
21865
+ */
21866
+ function quoteFileNameIfNeeded(s) {
21867
+ if (!needsQuoting(s)) {
21868
+ return s;
21869
+ }
21870
+ let result = '"';
21871
+ const bytes = new TextEncoder().encode(s);
21872
+ let i = 0;
21873
+ while (i < bytes.length) {
21874
+ const b = bytes[i];
21875
+ // See https://en.wikipedia.org/wiki/Escape_sequences_in_C#Escape_sequences
21876
+ if (b === 0x07) {
21877
+ result += '\\a';
21878
+ }
21879
+ else if (b === 0x08) {
21880
+ result += '\\b';
21881
+ }
21882
+ else if (b === 0x09) {
21883
+ result += '\\t';
21884
+ }
21885
+ else if (b === 0x0a) {
21886
+ result += '\\n';
21887
+ }
21888
+ else if (b === 0x0b) {
21889
+ result += '\\v';
21890
+ }
21891
+ else if (b === 0x0c) {
21892
+ result += '\\f';
21893
+ }
21894
+ else if (b === 0x0d) {
21895
+ result += '\\r';
21896
+ }
21897
+ else if (b === 0x22) {
21898
+ result += '\\"';
21899
+ }
21900
+ else if (b === 0x5c) {
21901
+ result += '\\\\';
21902
+ }
21903
+ else if (b >= 0x20 && b <= 0x7e) {
21904
+ // Just a printable ASCII character that is neither a double quote nor a
21905
+ // backslash; no need to escape it.
21906
+ result += String.fromCharCode(b);
21907
+ }
21908
+ else {
21909
+ // Either part of a non-ASCII character or a control character without a
21910
+ // special escape sequence; needs escaping as a 3-digit octal escape
21911
+ result += '\\' + b.toString(8).padStart(3, '0');
21912
+ }
21913
+ i++;
21914
+ }
21915
+ result += '"';
21916
+ return result;
21917
+ }
21842
21918
  const INCLUDE_HEADERS = {
21843
21919
  includeIndex: true,
21844
21920
  includeUnderline: true,
@@ -21971,14 +22047,24 @@ function structuredPatch$1(oldFileName, newFileName, oldStr, newStr, oldHeader,
21971
22047
  }
21972
22048
  /**
21973
22049
  * creates a unified diff patch.
21974
- * @param patch either a single structured patch object (as returned by `structuredPatch`) or an array of them (as returned by `parsePatch`)
22050
+ *
22051
+ * @param patch either a single structured patch object (as returned by `structuredPatch`) or an
22052
+ * array of them (as returned by `parsePatch`).
22053
+ * @param headerOptions behaves the same as the `headerOptions` option of `createTwoFilesPatch`.
22054
+ * Ignored for patches where `isGit` is `true`.
22055
+ *
22056
+ * When a patch has `isGit: true`, `formatPatch` output is changed to more closely match Git's
22057
+ * output: it emits a `diff --git` header, emits Git extended headers as appropriate based on
22058
+ * properties like `isRename`, `isCreate`, `newMode`, etc, and will omit `---`/`+++` file
22059
+ * headers for patches with no hunks (e.g. renames without content changes).
21975
22060
  */
21976
22061
  function formatPatch$1(patch, headerOptions) {
22062
+ var _a, _b, _c, _d, _e, _f;
21977
22063
  if (!headerOptions) {
21978
22064
  headerOptions = INCLUDE_HEADERS;
21979
22065
  }
21980
22066
  if (Array.isArray(patch)) {
21981
- if (patch.length > 1 && !headerOptions.includeFileHeaders) {
22067
+ if (patch.length > 1 && !headerOptions.includeFileHeaders && !patch.every(p => p.isGit)) {
21982
22068
  throw new Error('Cannot omit file headers on a multi-file patch. '
21983
22069
  + '(The result would be unparseable; how would a tool trying to apply '
21984
22070
  + 'the patch know which changes are to which file?)');
@@ -21986,29 +22072,72 @@ function formatPatch$1(patch, headerOptions) {
21986
22072
  return patch.map(p => formatPatch$1(p, headerOptions)).join('\n');
21987
22073
  }
21988
22074
  const ret = [];
21989
- if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName) {
21990
- ret.push('Index: ' + patch.oldFileName);
22075
+ // Git patches have a fixed header format (diff --git, extended headers,
22076
+ // and ---/+++ when hunks are present), so headerOptions is ignored.
22077
+ if (patch.isGit) {
22078
+ headerOptions = INCLUDE_HEADERS;
22079
+ // Emit Git-style diff --git header and extended headers.
22080
+ // Git never puts /dev/null in the "diff --git" line; for file
22081
+ // creations/deletions it uses the real filename on both sides.
22082
+ if (!patch.oldFileName) {
22083
+ throw new Error('oldFileName must be specified for Git patches');
22084
+ }
22085
+ if (!patch.newFileName) {
22086
+ throw new Error('newFileName must be specified for Git patches');
22087
+ }
22088
+ let gitOldName = patch.oldFileName;
22089
+ let gitNewName = patch.newFileName;
22090
+ if (patch.isCreate && gitOldName === '/dev/null') {
22091
+ gitOldName = gitNewName.replace(/^b\//, 'a/');
22092
+ }
22093
+ else if (patch.isDelete && gitNewName === '/dev/null') {
22094
+ gitNewName = gitOldName.replace(/^a\//, 'b/');
22095
+ }
22096
+ ret.push('diff --git ' + quoteFileNameIfNeeded(gitOldName) + ' ' + quoteFileNameIfNeeded(gitNewName));
22097
+ if (patch.isDelete) {
22098
+ ret.push('deleted file mode ' + ((_a = patch.oldMode) !== null && _a !== void 0 ? _a : '100644'));
22099
+ }
22100
+ if (patch.isCreate) {
22101
+ ret.push('new file mode ' + ((_b = patch.newMode) !== null && _b !== void 0 ? _b : '100644'));
22102
+ }
22103
+ if (patch.oldMode && patch.newMode && !patch.isDelete && !patch.isCreate) {
22104
+ ret.push('old mode ' + patch.oldMode);
22105
+ ret.push('new mode ' + patch.newMode);
22106
+ }
22107
+ if (patch.isRename) {
22108
+ ret.push('rename from ' + quoteFileNameIfNeeded(((_c = patch.oldFileName) !== null && _c !== void 0 ? _c : '').replace(/^a\//, '')));
22109
+ ret.push('rename to ' + quoteFileNameIfNeeded(((_d = patch.newFileName) !== null && _d !== void 0 ? _d : '').replace(/^b\//, '')));
22110
+ }
22111
+ if (patch.isCopy) {
22112
+ ret.push('copy from ' + quoteFileNameIfNeeded(((_e = patch.oldFileName) !== null && _e !== void 0 ? _e : '').replace(/^a\//, '')));
22113
+ ret.push('copy to ' + quoteFileNameIfNeeded(((_f = patch.newFileName) !== null && _f !== void 0 ? _f : '').replace(/^b\//, '')));
22114
+ }
21991
22115
  }
21992
- if (headerOptions.includeUnderline) {
21993
- ret.push('===================================================================');
22116
+ else {
22117
+ if (headerOptions.includeIndex && patch.oldFileName == patch.newFileName && patch.oldFileName !== undefined) {
22118
+ ret.push('Index: ' + patch.oldFileName);
22119
+ }
22120
+ if (headerOptions.includeUnderline) {
22121
+ ret.push('===================================================================');
22122
+ }
21994
22123
  }
21995
- if (headerOptions.includeFileHeaders) {
21996
- ret.push('--- ' + patch.oldFileName + (typeof patch.oldHeader === 'undefined' ? '' : '\t' + patch.oldHeader));
21997
- ret.push('+++ ' + patch.newFileName + (typeof patch.newHeader === 'undefined' ? '' : '\t' + patch.newHeader));
22124
+ // Emit --- / +++ file headers. For Git patches with no hunks (e.g.
22125
+ // pure renames, mode-only changes), Git omits these, so we do too.
22126
+ const hasHunks = patch.hunks.length > 0;
22127
+ if (headerOptions.includeFileHeaders && patch.oldFileName !== undefined && patch.newFileName !== undefined
22128
+ && (!patch.isGit || hasHunks)) {
22129
+ ret.push('--- ' + quoteFileNameIfNeeded(patch.oldFileName) + (patch.oldHeader ? '\t' + patch.oldHeader : ''));
22130
+ ret.push('+++ ' + quoteFileNameIfNeeded(patch.newFileName) + (patch.newHeader ? '\t' + patch.newHeader : ''));
21998
22131
  }
21999
22132
  for (let i = 0; i < patch.hunks.length; i++) {
22000
22133
  const hunk = patch.hunks[i];
22001
22134
  // Unified Diff Format quirk: If the chunk size is 0,
22002
22135
  // the first number is one lower than one would expect.
22003
22136
  // https://www.artima.com/weblogs/viewpost.jsp?thread=164293
22004
- if (hunk.oldLines === 0) {
22005
- hunk.oldStart -= 1;
22006
- }
22007
- if (hunk.newLines === 0) {
22008
- hunk.newStart -= 1;
22009
- }
22010
- ret.push('@@ -' + hunk.oldStart + ',' + hunk.oldLines
22011
- + ' +' + hunk.newStart + ',' + hunk.newLines
22137
+ const oldStart = hunk.oldLines === 0 ? hunk.oldStart - 1 : hunk.oldStart;
22138
+ const newStart = hunk.newLines === 0 ? hunk.newStart - 1 : hunk.newStart;
22139
+ ret.push('@@ -' + oldStart + ',' + hunk.oldLines
22140
+ + ' +' + newStart + ',' + hunk.newLines
22012
22141
  + ' @@');
22013
22142
  for (const line of hunk.lines) {
22014
22143
  ret.push(line);
@@ -69766,4 +69895,4 @@ var typescript = /*#__PURE__*/Object.freeze({
69766
69895
  });
69767
69896
 
69768
69897
  export { HighlightJS as H, MarkdownIt as M, Ze$a as Z, resolveConfig as a, createTwoFilesPatch$1 as b, createSyncFn as c, dedent$1 as d, deflist_plugin as e, format2 as f, closest as g, distance as h, fm$2 as i, isCI as j, cliProgress as k, tinylr as l, moduleImporter as m, createInstance as n, fse as o, inter as p, runAsWorker as r, ts$6 as t, watch$1 as w };
69769
- //# sourceMappingURL=vendor-tIJeYoyt.mjs.map
69898
+ //# sourceMappingURL=vendor-BhMQq6vU.mjs.map