@forsakringskassan/docs-generator 2.21.0 → 2.21.2
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.ts +2 -0
- package/dist/index.js +25 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/base.template.html +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -222,6 +222,7 @@ declare class Generator_2 {
|
|
|
222
222
|
private markdownOptions;
|
|
223
223
|
constructor(options: GeneratorOptions);
|
|
224
224
|
compileScript(name: string, src: string | URL, options?: Partial<CompileOptions>, buildOptions?: {
|
|
225
|
+
format?: "iife" | "cjs" | "esm";
|
|
225
226
|
define?: Record<string, string>;
|
|
226
227
|
}): void;
|
|
227
228
|
compileStyle(name: string, src: string | URL, options?: Partial<CompileOptions>): void;
|
|
@@ -565,6 +566,7 @@ export declare interface ProcessorRuntime {
|
|
|
565
566
|
name?: string;
|
|
566
567
|
/** Build options (passed to compileScript) */
|
|
567
568
|
buildOptions?: {
|
|
569
|
+
format?: "iife" | "cjs" | "esm";
|
|
568
570
|
define?: Record<string, string>;
|
|
569
571
|
};
|
|
570
572
|
}
|
package/dist/index.js
CHANGED
|
@@ -1595,6 +1595,7 @@ async function compileStyle(assetFolder, name, src, options) {
|
|
|
1595
1595
|
filename,
|
|
1596
1596
|
publicPath: `./assets/${filename}`,
|
|
1597
1597
|
integrity,
|
|
1598
|
+
format: "stylesheet",
|
|
1598
1599
|
size: stat.size,
|
|
1599
1600
|
type: "css"
|
|
1600
1601
|
};
|
|
@@ -1670,11 +1671,12 @@ async function compileScript(options) {
|
|
|
1670
1671
|
const entryPoints = [src instanceof URL ? node_url.fileURLToPath(src) : src];
|
|
1671
1672
|
const outfile = path$1.join("temp", `asset-${name}.js`);
|
|
1672
1673
|
const external = [...assets, ...vendor.map(toExternalVendor)];
|
|
1674
|
+
const format = buildOptions.format ?? "esm";
|
|
1673
1675
|
await esbuild({
|
|
1674
1676
|
entryPoints,
|
|
1675
1677
|
outfile,
|
|
1676
1678
|
bundle: true,
|
|
1677
|
-
format
|
|
1679
|
+
format,
|
|
1678
1680
|
platform: "browser",
|
|
1679
1681
|
external,
|
|
1680
1682
|
tsconfig: path$1.join(__dirname, "../tsconfig-examples.json"),
|
|
@@ -1697,6 +1699,7 @@ async function compileScript(options) {
|
|
|
1697
1699
|
filename,
|
|
1698
1700
|
publicPath: `./assets/${filename}`,
|
|
1699
1701
|
integrity,
|
|
1702
|
+
format,
|
|
1700
1703
|
size: stat.size,
|
|
1701
1704
|
type: "js"
|
|
1702
1705
|
};
|
|
@@ -2195,10 +2198,14 @@ function cache(cacheFolder, outputFolder) {
|
|
|
2195
2198
|
};
|
|
2196
2199
|
}
|
|
2197
2200
|
async function compileExamples(options) {
|
|
2198
|
-
const { fileInfo, tasks, vendors } = options;
|
|
2201
|
+
const { fileInfo, tasks, assets, vendors } = options;
|
|
2199
2202
|
if (tasks.length === 0) {
|
|
2200
2203
|
return;
|
|
2201
2204
|
}
|
|
2205
|
+
const external = [
|
|
2206
|
+
...assets.map((it) => it.name),
|
|
2207
|
+
...vendors.map((it) => it.package)
|
|
2208
|
+
];
|
|
2202
2209
|
const cacheFolder = path$1.posix.join(options.cacheFolder, fileInfo.path);
|
|
2203
2210
|
const outputFolder = path$1.posix.join(options.outputFolder, fileInfo.path);
|
|
2204
2211
|
const cacheMiss = cache(cacheFolder, outputFolder);
|
|
@@ -2208,7 +2215,7 @@ async function compileExamples(options) {
|
|
|
2208
2215
|
}
|
|
2209
2216
|
const batch = {
|
|
2210
2217
|
outputFolder,
|
|
2211
|
-
external
|
|
2218
|
+
external,
|
|
2212
2219
|
tasks: dirtyTasks
|
|
2213
2220
|
};
|
|
2214
2221
|
const result = await vendor.spawn("node", [scriptPath], {
|
|
@@ -2392,11 +2399,15 @@ async function render(doc, docs, nav, vendors, options) {
|
|
|
2392
2399
|
});
|
|
2393
2400
|
const writeFile = fs.writeFile(expandedDst, content ?? "null", "utf-8");
|
|
2394
2401
|
try {
|
|
2402
|
+
const assets = Object.values(templateData.assets).filter(
|
|
2403
|
+
(it) => it.importmap
|
|
2404
|
+
);
|
|
2395
2405
|
await compileExamples({
|
|
2396
2406
|
fileInfo,
|
|
2397
2407
|
cacheFolder,
|
|
2398
2408
|
outputFolder,
|
|
2399
2409
|
tasks: generatedExamples,
|
|
2410
|
+
assets,
|
|
2400
2411
|
vendors
|
|
2401
2412
|
});
|
|
2402
2413
|
} catch (err) {
|
|
@@ -2842,10 +2853,17 @@ class Generator {
|
|
|
2842
2853
|
this.sourceFiles = [];
|
|
2843
2854
|
this.markdownOptions = options.markdown;
|
|
2844
2855
|
const bootstrapUrl = new URL("runtime-bootstrap.js", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.js', document.baseURI).href)));
|
|
2845
|
-
this.compileScript(
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2856
|
+
this.compileScript(
|
|
2857
|
+
"bootstrap",
|
|
2858
|
+
bootstrapUrl,
|
|
2859
|
+
{
|
|
2860
|
+
appendTo: "head",
|
|
2861
|
+
priority: 100
|
|
2862
|
+
},
|
|
2863
|
+
{
|
|
2864
|
+
format: "iife"
|
|
2865
|
+
}
|
|
2866
|
+
);
|
|
2849
2867
|
}
|
|
2850
2868
|
compileScript(name, src, options, buildOptions) {
|
|
2851
2869
|
this.scripts.push({
|