@json-to-office/core-pptx 6.4.1 → 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"() {
|