docgen-utils 1.0.15 → 1.0.16
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/bundle.js +126 -48
- package/dist/bundle.min.js +2 -2
- package/dist/cli.js +330 -24017
- package/dist/packages/cli/commands/export-docs.d.ts +3 -4
- package/dist/packages/cli/commands/export-docs.d.ts.map +1 -1
- package/dist/packages/cli/commands/export-docs.js +245 -299
- package/dist/packages/cli/commands/export-docs.js.map +1 -1
- package/dist/packages/docs/create-document.d.ts.map +1 -1
- package/dist/packages/docs/create-document.js +39 -22
- package/dist/packages/docs/create-document.js.map +1 -1
- package/dist/packages/docs/export.d.ts.map +1 -1
- package/dist/packages/docs/export.js +25 -89
- package/dist/packages/docs/export.js.map +1 -1
- package/dist/packages/docs/parse-colors.d.ts.map +1 -1
- package/dist/packages/docs/parse-colors.js +85 -10
- package/dist/packages/docs/parse-colors.js.map +1 -1
- package/package.json +1 -1
package/dist/bundle.js
CHANGED
|
@@ -46780,7 +46780,7 @@ var docgen = (() => {
|
|
|
46780
46780
|
const trimmed = current.trim().replace(/^['"]|['"]$/g, "");
|
|
46781
46781
|
if (trimmed)
|
|
46782
46782
|
fonts.push(trimmed);
|
|
46783
|
-
const
|
|
46783
|
+
const cssGenericFamilies = /* @__PURE__ */ new Set([
|
|
46784
46784
|
"sans-serif",
|
|
46785
46785
|
"serif",
|
|
46786
46786
|
"monospace",
|
|
@@ -46788,27 +46788,81 @@ var docgen = (() => {
|
|
|
46788
46788
|
"fantasy",
|
|
46789
46789
|
"system-ui",
|
|
46790
46790
|
"-apple-system",
|
|
46791
|
-
"BlinkMacSystemFont"
|
|
46792
|
-
|
|
46793
|
-
|
|
46794
|
-
"Helvetica Neue",
|
|
46791
|
+
"BlinkMacSystemFont"
|
|
46792
|
+
]);
|
|
46793
|
+
const systemFonts = /* @__PURE__ */ new Set([
|
|
46795
46794
|
"Arial",
|
|
46796
46795
|
"Helvetica",
|
|
46797
|
-
"
|
|
46798
|
-
"
|
|
46799
|
-
"
|
|
46800
|
-
"
|
|
46801
|
-
"
|
|
46802
|
-
|
|
46803
|
-
|
|
46804
|
-
|
|
46796
|
+
"Helvetica Neue",
|
|
46797
|
+
"Segoe UI",
|
|
46798
|
+
"Times New Roman",
|
|
46799
|
+
"Georgia",
|
|
46800
|
+
"Courier New"
|
|
46801
|
+
]);
|
|
46802
|
+
const webFontMap = /* @__PURE__ */ new Map([
|
|
46803
|
+
// Sans-serif Google Fonts → Arial
|
|
46804
|
+
["Inter", "Arial"],
|
|
46805
|
+
["Roboto", "Arial"],
|
|
46806
|
+
["Open Sans", "Arial"],
|
|
46807
|
+
["Lato", "Arial"],
|
|
46808
|
+
["Montserrat", "Arial"],
|
|
46809
|
+
["Poppins", "Arial"],
|
|
46810
|
+
["Nunito", "Arial"],
|
|
46811
|
+
["Raleway", "Arial"],
|
|
46812
|
+
["Ubuntu", "Arial"],
|
|
46813
|
+
["Cantarell", "Arial"],
|
|
46814
|
+
["Fira Sans", "Arial"],
|
|
46815
|
+
["Droid Sans", "Arial"],
|
|
46816
|
+
["Noto Sans", "Arial"],
|
|
46817
|
+
["Oxygen", "Arial"],
|
|
46818
|
+
["Source Sans Pro", "Arial"],
|
|
46819
|
+
["Source Sans 3", "Arial"],
|
|
46820
|
+
["Work Sans", "Arial"],
|
|
46821
|
+
["DM Sans", "Arial"],
|
|
46822
|
+
["IBM Plex Sans", "Arial"],
|
|
46823
|
+
["Mulish", "Arial"],
|
|
46824
|
+
["Quicksand", "Arial"],
|
|
46825
|
+
["Manrope", "Arial"],
|
|
46826
|
+
["Outfit", "Arial"],
|
|
46827
|
+
["Plus Jakarta Sans", "Arial"],
|
|
46828
|
+
["Figtree", "Arial"],
|
|
46829
|
+
["Geist", "Arial"],
|
|
46830
|
+
// Serif Google Fonts → Times New Roman
|
|
46831
|
+
["Playfair Display", "Times New Roman"],
|
|
46832
|
+
["Merriweather", "Times New Roman"],
|
|
46833
|
+
["Lora", "Times New Roman"],
|
|
46834
|
+
["PT Serif", "Times New Roman"],
|
|
46835
|
+
["Noto Serif", "Times New Roman"],
|
|
46836
|
+
["Source Serif Pro", "Times New Roman"],
|
|
46837
|
+
["Source Serif 4", "Times New Roman"],
|
|
46838
|
+
["Libre Baskerville", "Times New Roman"],
|
|
46839
|
+
["Crimson Text", "Times New Roman"],
|
|
46840
|
+
["EB Garamond", "Times New Roman"],
|
|
46841
|
+
["Cormorant Garamond", "Times New Roman"],
|
|
46842
|
+
["DM Serif Display", "Times New Roman"],
|
|
46843
|
+
// Display/heading fonts (mostly sans-serif) → Arial
|
|
46844
|
+
["Oswald", "Arial"],
|
|
46845
|
+
["Abril Fatface", "Times New Roman"],
|
|
46846
|
+
["Bebas Neue", "Arial"]
|
|
46805
46847
|
]);
|
|
46848
|
+
let webFontFallback;
|
|
46806
46849
|
for (const font of fonts) {
|
|
46807
|
-
if (
|
|
46808
|
-
|
|
46850
|
+
if (cssGenericFamilies.has(font) || font.startsWith("-")) {
|
|
46851
|
+
continue;
|
|
46852
|
+
}
|
|
46853
|
+
if (systemFonts.has(font)) {
|
|
46854
|
+
continue;
|
|
46809
46855
|
}
|
|
46856
|
+
const mapped = webFontMap.get(font);
|
|
46857
|
+
if (mapped) {
|
|
46858
|
+
if (!webFontFallback) {
|
|
46859
|
+
webFontFallback = mapped;
|
|
46860
|
+
}
|
|
46861
|
+
continue;
|
|
46862
|
+
}
|
|
46863
|
+
return font;
|
|
46810
46864
|
}
|
|
46811
|
-
return
|
|
46865
|
+
return webFontFallback;
|
|
46812
46866
|
}
|
|
46813
46867
|
function extractHexColor(value) {
|
|
46814
46868
|
const namedColors = {
|
|
@@ -52293,31 +52347,44 @@ var docgen = (() => {
|
|
|
52293
52347
|
// packages/docs/create-document.js
|
|
52294
52348
|
function replaceChartPlaceholders(elements, chartImages) {
|
|
52295
52349
|
let chartIndex = 0;
|
|
52296
|
-
|
|
52297
|
-
|
|
52298
|
-
|
|
52299
|
-
|
|
52300
|
-
|
|
52301
|
-
|
|
52302
|
-
|
|
52303
|
-
|
|
52304
|
-
|
|
52350
|
+
function replaceInElements(els) {
|
|
52351
|
+
return els.map((element) => {
|
|
52352
|
+
if (element.type === "chart-placeholder" && element.chartId) {
|
|
52353
|
+
const imageData = chartImages.get(element.chartId);
|
|
52354
|
+
if (imageData) {
|
|
52355
|
+
return {
|
|
52356
|
+
type: "chart-image",
|
|
52357
|
+
title: element.title,
|
|
52358
|
+
imageData
|
|
52359
|
+
};
|
|
52360
|
+
}
|
|
52305
52361
|
}
|
|
52306
|
-
|
|
52307
|
-
|
|
52308
|
-
|
|
52309
|
-
|
|
52310
|
-
|
|
52311
|
-
|
|
52362
|
+
if (element.type === "svg-chart") {
|
|
52363
|
+
const key2 = `svg-chart-${chartIndex}`;
|
|
52364
|
+
const imageData = chartImages.get(key2);
|
|
52365
|
+
chartIndex++;
|
|
52366
|
+
if (imageData) {
|
|
52367
|
+
return {
|
|
52368
|
+
type: "chart-image",
|
|
52369
|
+
title: element.title,
|
|
52370
|
+
imageData
|
|
52371
|
+
};
|
|
52372
|
+
}
|
|
52373
|
+
}
|
|
52374
|
+
if (element.type === "blockquote" && element.content) {
|
|
52375
|
+
return { ...element, content: replaceInElements(element.content) };
|
|
52376
|
+
}
|
|
52377
|
+
if (element.type === "two-column-layout") {
|
|
52312
52378
|
return {
|
|
52313
|
-
|
|
52314
|
-
|
|
52315
|
-
|
|
52379
|
+
...element,
|
|
52380
|
+
sidebar: { ...element.sidebar, content: replaceInElements(element.sidebar.content) },
|
|
52381
|
+
main: { ...element.main, content: replaceInElements(element.main.content) }
|
|
52316
52382
|
};
|
|
52317
52383
|
}
|
|
52318
|
-
|
|
52319
|
-
|
|
52320
|
-
}
|
|
52384
|
+
return element;
|
|
52385
|
+
});
|
|
52386
|
+
}
|
|
52387
|
+
return replaceInElements(elements);
|
|
52321
52388
|
}
|
|
52322
52389
|
function createDocxDocument(html, options = {}) {
|
|
52323
52390
|
const { title, author, description, chartImages, imageMap, pageless, pageHeightTwips, elements: preElements } = options;
|
|
@@ -52559,18 +52626,29 @@ var docgen = (() => {
|
|
|
52559
52626
|
}
|
|
52560
52627
|
async function renderSvgChartsFromElements(elements) {
|
|
52561
52628
|
const chartImages = /* @__PURE__ */ new Map();
|
|
52562
|
-
|
|
52563
|
-
|
|
52564
|
-
|
|
52565
|
-
|
|
52566
|
-
|
|
52567
|
-
|
|
52568
|
-
|
|
52569
|
-
|
|
52570
|
-
|
|
52571
|
-
|
|
52629
|
+
const svgChartElements = [];
|
|
52630
|
+
function collectSvgCharts(els) {
|
|
52631
|
+
for (const el of els) {
|
|
52632
|
+
if (el.type === "svg-chart") {
|
|
52633
|
+
svgChartElements.push(el);
|
|
52634
|
+
} else if (el.type === "blockquote" && el.content) {
|
|
52635
|
+
collectSvgCharts(el.content);
|
|
52636
|
+
} else if (el.type === "two-column-layout") {
|
|
52637
|
+
collectSvgCharts(el.sidebar.content);
|
|
52638
|
+
collectSvgCharts(el.main.content);
|
|
52639
|
+
}
|
|
52640
|
+
}
|
|
52641
|
+
}
|
|
52642
|
+
collectSvgCharts(elements);
|
|
52643
|
+
for (let svgIndex = 0; svgIndex < svgChartElements.length; svgIndex++) {
|
|
52644
|
+
const element = svgChartElements[svgIndex];
|
|
52645
|
+
try {
|
|
52646
|
+
const imageData = await renderSvgToPng(element.svgContent, element.width, element.height, element.backgroundColor);
|
|
52647
|
+
if (imageData) {
|
|
52648
|
+
chartImages.set(`svg-chart-${svgIndex}`, imageData);
|
|
52572
52649
|
}
|
|
52573
|
-
|
|
52650
|
+
} catch (err) {
|
|
52651
|
+
console.warn(`Failed to render SVG chart ${svgIndex}:`, err);
|
|
52574
52652
|
}
|
|
52575
52653
|
}
|
|
52576
52654
|
return chartImages;
|