@json-to-office/core-pptx 0.16.0 → 0.18.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/components/highcharts.d.ts.map +1 -1
- package/dist/components/image.d.ts +1 -0
- package/dist/components/image.d.ts.map +1 -1
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/index.js +33 -6
- package/dist/index.js.map +1 -1
- package/dist/plugin/validation.d.ts +5 -1
- package/dist/plugin/validation.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/imageSource.d.ts +6 -0
- package/dist/utils/imageSource.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"highcharts.d.ts","sourceRoot":"","sources":["../../src/components/highcharts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AA6EtE,wBAAsB,yBAAyB,CAC7C,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,KAAK,EAAE,mBAAmB,EAC1B,MAAM,EAAE,eAAe,EACvB,SAAS,CAAC,EAAE,eAAe,EAAE,EAC7B,cAAc,CAAC,EAAE,uBAAuB,GACvC,OAAO,CAAC,IAAI,CAAC,CAaf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/components/image.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../src/components/image.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,KAAK,SAAS,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AA+BjE,UAAU,mBAAmB;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAAC,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,SAAS,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA2DD,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,CAAC,KAAK,EACtB,KAAK,EAAE,mBAAmB,EAC1B,KAAK,EAAE,eAAe,EACtB,QAAQ,CAAC,EAAE,eAAe,EAAE,EAC5B,UAAU,SAAK,EACf,WAAW,SAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAgKf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,OAAO,KAAK,EACV,+BAA+B,EAC/B,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,OAAO,KAAK,EACV,+BAA+B,EAC/B,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAQ9E;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/C,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,KAAK,CAAC,EAA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
|
|
|
551
551
|
// src/components/image.ts
|
|
552
552
|
import path from "path";
|
|
553
553
|
import probe from "probe-image-size";
|
|
554
|
+
|
|
555
|
+
// src/utils/imageSource.ts
|
|
556
|
+
var hasValue = (v) => typeof v === "string" && v.trim().length > 0;
|
|
557
|
+
function resolveImageSource(props) {
|
|
558
|
+
if (hasValue(props.svg)) {
|
|
559
|
+
const encoded = Buffer.from(props.svg, "utf-8").toString("base64");
|
|
560
|
+
return `data:image/svg+xml;base64,${encoded}`;
|
|
561
|
+
}
|
|
562
|
+
if (hasValue(props.base64)) return props.base64;
|
|
563
|
+
if (hasValue(props.path)) return props.path;
|
|
564
|
+
return void 0;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// src/components/image.ts
|
|
554
568
|
function isPrivateUrl(urlStr) {
|
|
555
569
|
try {
|
|
556
570
|
const { hostname } = new URL(urlStr);
|
|
@@ -605,20 +619,20 @@ function resolveDimension(value, axisLength) {
|
|
|
605
619
|
}
|
|
606
620
|
async function renderImageComponent(slide, props, theme, warnings, slideWidth = 10, slideHeight = 7.5) {
|
|
607
621
|
const opts = {};
|
|
608
|
-
const source = props
|
|
622
|
+
const source = resolveImageSource(props);
|
|
609
623
|
if (!source) {
|
|
610
624
|
warn(
|
|
611
625
|
warnings,
|
|
612
626
|
W.IMAGE_NO_SOURCE,
|
|
613
|
-
"Image component missing
|
|
627
|
+
"Image component missing path, base64, and svg",
|
|
614
628
|
{ component: "image" }
|
|
615
629
|
);
|
|
616
630
|
return;
|
|
617
631
|
}
|
|
618
|
-
if (
|
|
619
|
-
opts.
|
|
632
|
+
if (source.startsWith("data:")) {
|
|
633
|
+
opts.data = source;
|
|
620
634
|
} else {
|
|
621
|
-
opts.
|
|
635
|
+
opts.path = source;
|
|
622
636
|
}
|
|
623
637
|
if (props.x !== void 0) opts.x = props.x;
|
|
624
638
|
if (props.y !== void 0) opts.y = props.y;
|
|
@@ -1064,7 +1078,10 @@ async function generateChart(config, servicesConfig) {
|
|
|
1064
1078
|
infile: config.options,
|
|
1065
1079
|
type: "png",
|
|
1066
1080
|
b64: true,
|
|
1067
|
-
scale: config.scale
|
|
1081
|
+
scale: config.scale,
|
|
1082
|
+
// Forward resources verbatim only when present so the payload stays
|
|
1083
|
+
// byte-identical to before for callers that omit it.
|
|
1084
|
+
...config.resources ? { resources: config.resources } : {}
|
|
1068
1085
|
};
|
|
1069
1086
|
const resolvedHeaders = typeof servicesConfig?.headers === "function" ? await servicesConfig.headers(requestBody) : servicesConfig?.headers;
|
|
1070
1087
|
const headers = {
|
|
@@ -1529,6 +1546,7 @@ async function resolveDocumentFonts(document, theme, warnings, fonts) {
|
|
|
1529
1546
|
|
|
1530
1547
|
// src/core/generator.ts
|
|
1531
1548
|
import { applyExportMode, scopedThemeName } from "@json-to-office/shared";
|
|
1549
|
+
import { collectImageSourceConflicts } from "@json-to-office/shared-pptx";
|
|
1532
1550
|
function isPresentationComponentDefinition(definition) {
|
|
1533
1551
|
if (typeof definition !== "object" || definition === null) return false;
|
|
1534
1552
|
const def = definition;
|
|
@@ -1538,6 +1556,13 @@ async function generatePresentation(document, options, warnings) {
|
|
|
1538
1556
|
if (!document || document.name !== "pptx") {
|
|
1539
1557
|
throw new Error("Top-level component must be a pptx component");
|
|
1540
1558
|
}
|
|
1559
|
+
const sourceConflicts = collectImageSourceConflicts(document);
|
|
1560
|
+
if (sourceConflicts.length > 0) {
|
|
1561
|
+
throw new Error(
|
|
1562
|
+
`Document validation failed:
|
|
1563
|
+
${sourceConflicts.map((e) => ` - ${e.path}: ${e.message}`).join("\n")}`
|
|
1564
|
+
);
|
|
1565
|
+
}
|
|
1541
1566
|
const processed = processPresentation(document, options);
|
|
1542
1567
|
return await renderPresentation(processed, warnings);
|
|
1543
1568
|
}
|
|
@@ -1661,6 +1686,7 @@ import {
|
|
|
1661
1686
|
validateCustomComponentProps,
|
|
1662
1687
|
ComponentValidationError
|
|
1663
1688
|
} from "@json-to-office/shared/plugin";
|
|
1689
|
+
import { collectImageSourceConflicts as collectImageSourceConflicts2 } from "@json-to-office/shared-pptx";
|
|
1664
1690
|
import {
|
|
1665
1691
|
DuplicateComponentError,
|
|
1666
1692
|
ComponentValidationError as ComponentValidationError2
|
|
@@ -1674,6 +1700,7 @@ function validateComponentProps(schema, props, componentName) {
|
|
|
1674
1700
|
}
|
|
1675
1701
|
function validatePresentation(document, customComponents) {
|
|
1676
1702
|
const errors = [];
|
|
1703
|
+
errors.push(...collectImageSourceConflicts2(document));
|
|
1677
1704
|
function validateComponents(components, pathPrefix = "children") {
|
|
1678
1705
|
components.forEach((componentData, index) => {
|
|
1679
1706
|
const customComponent = customComponents.find(
|