@json-to-office/core-pptx 6.2.0 → 6.6.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.js
CHANGED
|
@@ -1895,6 +1895,7 @@ __export(office_open_exports, {
|
|
|
1895
1895
|
createOfficeOpenPptxRenderer: () => createOfficeOpenPptxRenderer
|
|
1896
1896
|
});
|
|
1897
1897
|
import { readFile } from "fs/promises";
|
|
1898
|
+
import { assetUnreadableError } from "@json-to-office/shared/rendering";
|
|
1898
1899
|
async function createOfficeOpenPptxRenderer() {
|
|
1899
1900
|
const backend = await import(
|
|
1900
1901
|
/* @vite-ignore */
|
|
@@ -1993,32 +1994,28 @@ function colorSchemeOptions(palette) {
|
|
|
1993
1994
|
}
|
|
1994
1995
|
async function loadResourceBytes(resources) {
|
|
1995
1996
|
const entries = await Promise.all(
|
|
1996
|
-
resources.map(
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
return [resource.id, resource.origin.bytes];
|
|
2000
|
-
case "file":
|
|
2001
|
-
return [
|
|
2002
|
-
resource.id,
|
|
2003
|
-
new Uint8Array(await readFile(resource.origin.path))
|
|
2004
|
-
];
|
|
2005
|
-
case "remote": {
|
|
2006
|
-
const response = await fetch(resource.origin.url);
|
|
2007
|
-
if (!response.ok) {
|
|
2008
|
-
throw new Error(
|
|
2009
|
-
`failed to fetch image ${resource.origin.url}: ${response.status} ${response.statusText}`
|
|
2010
|
-
);
|
|
2011
|
-
}
|
|
2012
|
-
return [
|
|
2013
|
-
resource.id,
|
|
2014
|
-
new Uint8Array(await response.arrayBuffer())
|
|
2015
|
-
];
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
})
|
|
1997
|
+
resources.map(
|
|
1998
|
+
async (resource) => [resource.id, await resourceBytes(resource.origin)]
|
|
1999
|
+
)
|
|
2019
2000
|
);
|
|
2020
2001
|
return new Map(entries);
|
|
2021
2002
|
}
|
|
2003
|
+
async function resourceBytes(origin) {
|
|
2004
|
+
if (origin.kind === "inline") return origin.bytes;
|
|
2005
|
+
const location = origin.kind === "file" ? origin.path : origin.url;
|
|
2006
|
+
try {
|
|
2007
|
+
if (origin.kind === "file") {
|
|
2008
|
+
return new Uint8Array(await readFile(origin.path));
|
|
2009
|
+
}
|
|
2010
|
+
const response = await fetch(origin.url);
|
|
2011
|
+
if (!response.ok) {
|
|
2012
|
+
throw new Error(`HTTP ${response.status} ${response.statusText}`);
|
|
2013
|
+
}
|
|
2014
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
2015
|
+
} catch (error) {
|
|
2016
|
+
throw assetUnreadableError(location, error);
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2022
2019
|
var OFFICE_OPEN_PPTX_RENDERER_ID, OFFICE_OPEN_PPTX, OFFICE_OPEN_CAPABILITIES, SCHEME_SLOTS;
|
|
2023
2020
|
var init_office_open = __esm({
|
|
2024
2021
|
"src/renderers/office-open/index.ts"() {
|
|
@@ -6585,7 +6582,9 @@ function preparePptxQualityDocument(document, options = {}) {
|
|
|
6585
6582
|
excerpt: occurrence.match.excerpt
|
|
6586
6583
|
});
|
|
6587
6584
|
});
|
|
6588
|
-
|
|
6585
|
+
const content = { ...document, props: { ...props } };
|
|
6586
|
+
delete content.props.theme;
|
|
6587
|
+
collectColorLiterals(content).forEach((literal, index) => {
|
|
6589
6588
|
addFact({
|
|
6590
6589
|
id: `pptx:color:${index}:${literal.path}`,
|
|
6591
6590
|
kind: "pptx/color",
|
|
@@ -6594,7 +6593,7 @@ function preparePptxQualityDocument(document, options = {}) {
|
|
|
6594
6593
|
hex: literal.hex
|
|
6595
6594
|
});
|
|
6596
6595
|
});
|
|
6597
|
-
collectFontFamilies(
|
|
6596
|
+
collectFontFamilies(content).forEach((use, index) => {
|
|
6598
6597
|
addFact({
|
|
6599
6598
|
id: `pptx:font:${index}:${use.path}`,
|
|
6600
6599
|
kind: "pptx/font-family",
|