@forsakringskassan/docs-generator 3.10.0 → 3.11.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-DPuGyhL4.mjs';
5
+ import { r as runAsWorker, f as format2, a as resolveConfig } from './vendor-DIj4mOXS.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-BsG38cNK.mjs.map
57
+ //# sourceMappingURL=format-code.worker-DJSjofVE.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"format-code.worker-BsG38cNK.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\n/* eslint-disable-next-line unicorn/no-top-level-side-effects -- required for worker to function */\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;AAGA,WAAA,CAAY,UAAU,CAAA;;"}
1
+ {"version":3,"file":"format-code.worker-DJSjofVE.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\n/* eslint-disable-next-line unicorn/no-top-level-side-effects -- required for worker to function */\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;AAGA,WAAA,CAAY,UAAU,CAAA;;"}
package/dist/index.mjs CHANGED
@@ -3,12 +3,12 @@ import { createRequire as $createRequire } from "node:module";
3
3
  const require = $createRequire(import.meta.url);
4
4
 
5
5
  import { ApiItemKind, ApiModel } from '@microsoft/api-extractor-model';
6
- import { t as ts, Z as Ze, M as MarkdownItCallable, g as fm, s as strToU8, z as zlibSync, h as strFromU8, d as dedent, i as closest, j as distance, k as isCI, m as moduleImporter, l as cliProgress, n as tinylr, w as watch, o as createInstance, p as fse, q as inter } from './vendor-DPuGyhL4.mjs';
6
+ import { t as ts, Z as Ze, M as MarkdownItCallable, g as fm, s as strToU8, z as zlibSync, h as strFromU8, d as dedent, i as closest, j as distance, k as isCI, m as moduleImporter, l as cliProgress, n as tinylr, w as watch, o as createInstance, p as fse, q as inter } from './vendor-DIj4mOXS.mjs';
7
7
  import path__default from 'node:path';
8
8
  import crypto from 'node:crypto';
9
9
  import path from 'node:path/posix';
10
10
  import { exec, execSync } from 'node:child_process';
11
- import { g as generateId, f as formatCode, p as parseInfostring, a as getFingerprint, h as hasTag, b as parseImport, d as findTag, e as getOutputFilePath, i as isDocumentPage, j as findDocument, k as getDocumentBody, n as normalizePath, l as htmlencode, m as filePath, c as createMarkdownRenderer, o as generateExample } from './create-markdown-renderer-CXtEyRCU.mjs';
11
+ import { g as generateId, f as formatCode, p as parseInfostring, a as getFingerprint, h as hasTag, b as parseImport, d as findTag, e as getOutputFilePath, i as isDocumentPage, j as findDocument, k as getDocumentBody, n as normalizePath, l as htmlencode, m as filePath, c as createMarkdownRenderer, o as generateExample } from './create-markdown-renderer--UwmwaiQ.mjs';
12
12
  import { DocExcerpt } from '@microsoft/tsdoc';
13
13
  import fs from 'node:fs/promises';
14
14
  import util, { promisify, styleText } from 'node:util';
@@ -19,7 +19,7 @@ import { parse, compileScript as compileScript$1, compileTemplate } from 'vue/co
19
19
  import { parse as parse$2 } from 'vue-docgen-api';
20
20
  import fs__default, { existsSync, readFileSync, copyFileSync } from 'node:fs';
21
21
  import { fileURLToPath } from 'node:url';
22
- import { compileStringAsync, NodePackageImporter } from 'sass';
22
+ import { compileAsync, NodePackageImporter } from 'sass';
23
23
  import { t as tsconfigPath } from './tsconfig-path-bG7G_cK8.mjs';
24
24
  import esbuild$1, { build } from 'esbuild';
25
25
  import { Worker } from 'node:worker_threads';
@@ -898,18 +898,26 @@ async function writeIndex(options) {
898
898
  `import { frontMatterFileReader, partialFileReader } from "@forsakringskassan/docs-generator";`,
899
899
  ``,
900
900
  `export const basename = import.meta.dirname;`,
901
- `export const sourceFiles = [`,
902
- ` { `,
903
- ` include: path.join(basename, "files/**/*.md"),`,
904
- ` basename,`,
905
- ` fileReader: frontMatterFileReader,`,
906
- ` }`,
907
- ` { `,
908
- ` include: path.join(basename, "partials.json"),`,
909
- ` basename,`,
910
- ` fileReader: partialFileReader,`,
911
- ` }`,
912
- `];`
901
+ `export const exampleFolders = [path.join(basename, "files")];`,
902
+ `export const filesPath = path.join(basename, "files");`,
903
+ `export const partialsPath = [path.join(basename, "partials.json")];`,
904
+ `export const linksPath = [path.join(basename, "links.json")];`,
905
+ ``,
906
+ `export function sourceFiles(src) {`,
907
+ ` return [`,
908
+ ` { `,
909
+ ` include: path.join(basename, "files/**/*.md"),`,
910
+ ` basename,`,
911
+ ` fileReader: frontMatterFileReader,`,
912
+ ` ...src`,
913
+ ` },`,
914
+ ` { `,
915
+ ` include: path.join(basename, "partials.json"),`,
916
+ ` basename,`,
917
+ ` fileReader: partialFileReader,`,
918
+ ` }`,
919
+ ` ];`,
920
+ `}`
913
921
  ];
914
922
  await fs.writeFile(dst, lines.join("\n"), "utf8");
915
923
  }
@@ -920,7 +928,12 @@ async function writeDts(options) {
920
928
  `import { SourceFiles } from "@forsakringskassan/docs-generator";`,
921
929
  ``,
922
930
  `export declare const basename: string;`,
923
- `export declare const sourceFiles: SourceFiles[];`
931
+ `export declare const exampleFolders: string[];`,
932
+ `export declare const filesPath: string;`,
933
+ `export declare const partialsPath: string;`,
934
+ `export declare const linksPath: string;`,
935
+ ``,
936
+ `export declare function sourceFiles(src: Partial<SourceFiles>): SourceFiles[];`
924
937
  ];
925
938
  await fs.writeFile(dst, lines.join("\n"), "utf8");
926
939
  }
@@ -2871,8 +2884,8 @@ async function partialFileReader(filePath) {
2871
2884
  return parseFile(filePath, content);
2872
2885
  }
2873
2886
 
2874
- async function compileSassString(dst, style) {
2875
- const result = await compileStringAsync(style, {
2887
+ async function compileSassString(dst, filePath) {
2888
+ const result = await compileAsync(filePath, {
2876
2889
  style: "expanded",
2877
2890
  importers: [new NodePackageImporter(), moduleImporter()]
2878
2891
  });
@@ -2883,8 +2896,8 @@ async function compileSassString(dst, style) {
2883
2896
  async function compileStyle(assetFolder, name, src) {
2884
2897
  try {
2885
2898
  const outfile = path.join("temp", `asset-${name}.css`);
2886
- const source = await fs.readFile(src, "utf8");
2887
- await compileSassString(outfile, source);
2899
+ const filePath = typeof src === "string" ? src : fileURLToPath(src);
2900
+ await compileSassString(outfile, filePath);
2888
2901
  const content = await fs.readFile(outfile, "utf8");
2889
2902
  const fingerprint = getFingerprint(content);
2890
2903
  const integrity = getIntegrity(content);