@forsakringskassan/docs-generator 3.8.0 → 3.9.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.
- package/dist/index.d.mts +27 -0
- package/dist/index.mjs +75 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -22
package/dist/index.d.mts
CHANGED
|
@@ -298,6 +298,24 @@ declare class Generator_2 {
|
|
|
298
298
|
format?: "iife" | "cjs" | "esm";
|
|
299
299
|
define?: Record<string, string>;
|
|
300
300
|
}): void;
|
|
301
|
+
/**
|
|
302
|
+
* Compile a worker script.
|
|
303
|
+
*
|
|
304
|
+
* This is mostly the same as {@link Generator.compileScript} with some differences:
|
|
305
|
+
*
|
|
306
|
+
* - The script is written directly to `outputFolder` instead of `assetFolder` (i.e. to the web root).
|
|
307
|
+
* - The output filename does not include a hash.
|
|
308
|
+
*
|
|
309
|
+
* @public
|
|
310
|
+
* @since %version%
|
|
311
|
+
* @param name - Asset name.
|
|
312
|
+
* @param src - Asset entrypoint.
|
|
313
|
+
* @param buildOptions - Options passed to `esbuild`.
|
|
314
|
+
*/
|
|
315
|
+
compileWorker(name: string, src: string | URL, buildOptions?: {
|
|
316
|
+
format?: "iife" | "cjs" | "esm";
|
|
317
|
+
define?: Record<string, string>;
|
|
318
|
+
}): void;
|
|
301
319
|
compileStyle(name: string, src: string | URL, options?: Partial<CompileOptions>): void;
|
|
302
320
|
/**
|
|
303
321
|
* @param dst - Destination directory relative to asset folder.
|
|
@@ -616,6 +634,15 @@ export declare interface PackageJson {
|
|
|
616
634
|
};
|
|
617
635
|
}
|
|
618
636
|
|
|
637
|
+
/* Excluded from this release type: PartialFile */
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Read partial documents for insertion in other markdown documents.
|
|
641
|
+
*
|
|
642
|
+
* @public
|
|
643
|
+
*/
|
|
644
|
+
export declare function partialFileReader(filePath: string): Promise<DocumentPartial[]>;
|
|
645
|
+
|
|
619
646
|
/**
|
|
620
647
|
* Generates links to code playgrounds.
|
|
621
648
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1776,7 +1776,7 @@ function getComponent(attrs) {
|
|
|
1776
1776
|
}
|
|
1777
1777
|
return toArray$1(attrs.component).map(normalizeComponent);
|
|
1778
1778
|
}
|
|
1779
|
-
function parseFile$
|
|
1779
|
+
function parseFile$2(filePath, basePath, content) {
|
|
1780
1780
|
const relative = basePath ? path__default.relative(basePath, normalizePath(filePath)) : normalizePath(filePath);
|
|
1781
1781
|
const parsed = path__default.parse(relative);
|
|
1782
1782
|
const blocks = fm(content);
|
|
@@ -1822,7 +1822,7 @@ function parseFile$1(filePath, basePath, content) {
|
|
|
1822
1822
|
}
|
|
1823
1823
|
async function frontMatterFileReader(filePath, basePath) {
|
|
1824
1824
|
const content = await fs.readFile(filePath, "utf8");
|
|
1825
|
-
const doc = parseFile$
|
|
1825
|
+
const doc = parseFile$2(filePath, basePath, content);
|
|
1826
1826
|
return [doc];
|
|
1827
1827
|
}
|
|
1828
1828
|
|
|
@@ -2589,7 +2589,7 @@ function fileReaderProcessor(sourceFiles) {
|
|
|
2589
2589
|
};
|
|
2590
2590
|
}
|
|
2591
2591
|
|
|
2592
|
-
function parseFile(filePath, basePath, content) {
|
|
2592
|
+
function parseFile$1(filePath, basePath, content) {
|
|
2593
2593
|
const attributes = JSON.parse(content);
|
|
2594
2594
|
const { title, href } = attributes;
|
|
2595
2595
|
if (!title) {
|
|
@@ -2628,10 +2628,31 @@ function parseFile(filePath, basePath, content) {
|
|
|
2628
2628
|
}
|
|
2629
2629
|
async function navigationFileReader(filePath, basePath) {
|
|
2630
2630
|
const content = await fs.readFile(filePath, "utf8");
|
|
2631
|
-
const doc = parseFile(filePath, basePath, content);
|
|
2631
|
+
const doc = parseFile$1(filePath, basePath, content);
|
|
2632
2632
|
return [doc];
|
|
2633
2633
|
}
|
|
2634
2634
|
|
|
2635
|
+
function parseFile(filePath, content) {
|
|
2636
|
+
const parsed = JSON.parse(content);
|
|
2637
|
+
return parsed.map((it) => {
|
|
2638
|
+
return {
|
|
2639
|
+
kind: "partial",
|
|
2640
|
+
id: it.id,
|
|
2641
|
+
name: it.id,
|
|
2642
|
+
alias: [],
|
|
2643
|
+
body: it.body,
|
|
2644
|
+
format: it.format,
|
|
2645
|
+
fileInfo: {
|
|
2646
|
+
fullPath: filePath
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
});
|
|
2650
|
+
}
|
|
2651
|
+
async function partialFileReader(filePath) {
|
|
2652
|
+
const content = await fs.readFile(filePath, "utf8");
|
|
2653
|
+
return parseFile(filePath, content);
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2635
2656
|
async function compileSassString(dst, style) {
|
|
2636
2657
|
const result = await compileStringAsync(style, {
|
|
2637
2658
|
style: "expanded",
|
|
@@ -2716,9 +2737,11 @@ function toExternalVendor(vendor) {
|
|
|
2716
2737
|
}
|
|
2717
2738
|
async function compileScript(options) {
|
|
2718
2739
|
const {
|
|
2719
|
-
assetFolder,
|
|
2720
2740
|
name,
|
|
2721
2741
|
src,
|
|
2742
|
+
rootDir,
|
|
2743
|
+
outputFolder,
|
|
2744
|
+
outputName,
|
|
2722
2745
|
assets,
|
|
2723
2746
|
vendor,
|
|
2724
2747
|
buildOptions,
|
|
@@ -2747,15 +2770,19 @@ async function compileScript(options) {
|
|
|
2747
2770
|
const content = await fs$1.readFile(outfile, "utf8");
|
|
2748
2771
|
const fingerprint = getFingerprint(content);
|
|
2749
2772
|
const integrity = getIntegrity(content);
|
|
2750
|
-
const filename = `${
|
|
2751
|
-
const dst = path__default.join(
|
|
2773
|
+
const filename = `${outputName}.js`.replaceAll("[name]", () => name).replaceAll("[hash]", () => fingerprint);
|
|
2774
|
+
const dst = path__default.join(outputFolder, filename);
|
|
2775
|
+
const publicPath = path__default.posix.join(
|
|
2776
|
+
path__default.posix.relative(rootDir, outputFolder),
|
|
2777
|
+
filename
|
|
2778
|
+
);
|
|
2752
2779
|
await fs$1.mkdir(path__default.dirname(dst), { recursive: true });
|
|
2753
2780
|
await fs$1.rename(outfile, dst);
|
|
2754
2781
|
const stat = await fs$1.stat(dst);
|
|
2755
2782
|
return {
|
|
2756
2783
|
name,
|
|
2757
2784
|
filename,
|
|
2758
|
-
publicPath:
|
|
2785
|
+
publicPath: `./${publicPath}`,
|
|
2759
2786
|
integrity,
|
|
2760
2787
|
format,
|
|
2761
2788
|
size: stat.size,
|
|
@@ -2775,7 +2802,7 @@ function byPriority({ options: a }, { options: b }) {
|
|
|
2775
2802
|
function isExternal(asset) {
|
|
2776
2803
|
return asset.options.appendTo === "none";
|
|
2777
2804
|
}
|
|
2778
|
-
function jsAssetProcessor(
|
|
2805
|
+
function jsAssetProcessor(rootDir, assets, vendor) {
|
|
2779
2806
|
const externalAssets = assets.filter(isExternal).map((it) => it.name);
|
|
2780
2807
|
return {
|
|
2781
2808
|
name: "js-asset-processor",
|
|
@@ -2786,9 +2813,11 @@ function jsAssetProcessor(assetFolder, assets, vendor) {
|
|
|
2786
2813
|
const body = context.getTemplateData("injectBody", []);
|
|
2787
2814
|
for (const asset of assets.toSorted(byPriority)) {
|
|
2788
2815
|
const info = await compileScript({
|
|
2789
|
-
assetFolder,
|
|
2790
2816
|
name: asset.name,
|
|
2791
2817
|
src: asset.src,
|
|
2818
|
+
rootDir,
|
|
2819
|
+
outputFolder: asset.outputFolder,
|
|
2820
|
+
outputName: asset.outputName,
|
|
2792
2821
|
assets: externalAssets,
|
|
2793
2822
|
vendor,
|
|
2794
2823
|
buildOptions: asset.buildOptions
|
|
@@ -3900,9 +3929,12 @@ class Generator {
|
|
|
3900
3929
|
});
|
|
3901
3930
|
}
|
|
3902
3931
|
compileScript(name, src, options, buildOptions) {
|
|
3932
|
+
const { assetFolder } = this;
|
|
3903
3933
|
this.scripts.push({
|
|
3904
3934
|
name,
|
|
3905
3935
|
src,
|
|
3936
|
+
outputFolder: assetFolder,
|
|
3937
|
+
outputName: "[name]-[hash]",
|
|
3906
3938
|
options: {
|
|
3907
3939
|
appendTo: "none",
|
|
3908
3940
|
attributes: {},
|
|
@@ -3914,6 +3946,37 @@ class Generator {
|
|
|
3914
3946
|
}
|
|
3915
3947
|
});
|
|
3916
3948
|
}
|
|
3949
|
+
/**
|
|
3950
|
+
* Compile a worker script.
|
|
3951
|
+
*
|
|
3952
|
+
* This is mostly the same as {@link Generator.compileScript} with some differences:
|
|
3953
|
+
*
|
|
3954
|
+
* - The script is written directly to `outputFolder` instead of `assetFolder` (i.e. to the web root).
|
|
3955
|
+
* - The output filename does not include a hash.
|
|
3956
|
+
*
|
|
3957
|
+
* @public
|
|
3958
|
+
* @since %version%
|
|
3959
|
+
* @param name - Asset name.
|
|
3960
|
+
* @param src - Asset entrypoint.
|
|
3961
|
+
* @param buildOptions - Options passed to `esbuild`.
|
|
3962
|
+
*/
|
|
3963
|
+
compileWorker(name, src, buildOptions) {
|
|
3964
|
+
const { outputFolder } = this;
|
|
3965
|
+
this.scripts.push({
|
|
3966
|
+
name,
|
|
3967
|
+
src,
|
|
3968
|
+
outputFolder,
|
|
3969
|
+
outputName: "[name]",
|
|
3970
|
+
options: {
|
|
3971
|
+
appendTo: "none",
|
|
3972
|
+
attributes: {},
|
|
3973
|
+
priority: 0
|
|
3974
|
+
},
|
|
3975
|
+
buildOptions: {
|
|
3976
|
+
...buildOptions
|
|
3977
|
+
}
|
|
3978
|
+
});
|
|
3979
|
+
}
|
|
3917
3980
|
compileStyle(name, src, options) {
|
|
3918
3981
|
this.styles.push({
|
|
3919
3982
|
name,
|
|
@@ -3996,7 +4059,7 @@ class Generator {
|
|
|
3996
4059
|
redirectProcessor(),
|
|
3997
4060
|
vendorProcessor(assetFolder, this.vendor),
|
|
3998
4061
|
cssAssetProcessor(assetFolder, this.styles),
|
|
3999
|
-
jsAssetProcessor(
|
|
4062
|
+
jsAssetProcessor(outputFolder, this.scripts, this.vendor),
|
|
4000
4063
|
staticResourcesProcessor(assetFolder, this.resources),
|
|
4001
4064
|
navigationProcessor(),
|
|
4002
4065
|
nunjucksProcessor({
|
|
@@ -4072,5 +4135,5 @@ class Generator {
|
|
|
4072
4135
|
}
|
|
4073
4136
|
}
|
|
4074
4137
|
|
|
4075
|
-
export { Generator, apiExtractorProcessor, availableProcessors, cookieProcessor, defineSources, extractExamplesProcessor, frontMatterFileReader, htmlRedirectProcessor, isRelease, livereloadProcessor, manifestProcessor, matomoProcessor, motdProcessor, navigationFileReader, playgroundProcessor, processorRuntimeName, redirectFileProcessor, searchProcessor, selectableVersionProcessor, sourceUrlProcessor, topnavProcessor, versionBannerProcessor, versionProcessor, vueFileReader };
|
|
4138
|
+
export { Generator, apiExtractorProcessor, availableProcessors, cookieProcessor, defineSources, extractExamplesProcessor, frontMatterFileReader, htmlRedirectProcessor, isRelease, livereloadProcessor, manifestProcessor, matomoProcessor, motdProcessor, navigationFileReader, partialFileReader, playgroundProcessor, processorRuntimeName, redirectFileProcessor, searchProcessor, selectableVersionProcessor, sourceUrlProcessor, topnavProcessor, versionBannerProcessor, versionProcessor, vueFileReader };
|
|
4076
4139
|
//# sourceMappingURL=index.mjs.map
|