@cyber-dash-tech/revela 0.4.1 → 0.4.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/lib/pptx/export.ts +15 -5
- package/package.json +1 -1
package/lib/pptx/export.ts
CHANGED
|
@@ -17,13 +17,15 @@ import puppeteer, { type Browser, type Page } from "puppeteer-core"
|
|
|
17
17
|
import { DOMParser, XMLSerializer } from "@xmldom/xmldom"
|
|
18
18
|
import { unzipSync, zipSync, strFromU8, strToU8 } from "fflate"
|
|
19
19
|
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs"
|
|
20
|
+
import { createRequire } from "module"
|
|
20
21
|
import { basename, dirname, extname, join, posix as pathPosix, resolve } from "path"
|
|
21
22
|
import { randomBytes } from "crypto"
|
|
22
|
-
import {
|
|
23
|
+
import { pathToFileURL } from "url"
|
|
23
24
|
|
|
24
25
|
const CANVAS_W = 1920
|
|
25
26
|
const CANVAS_H = 1080
|
|
26
27
|
const PPT_REL_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
28
|
+
const requireFromExportModule = createRequire(import.meta.url)
|
|
27
29
|
|
|
28
30
|
const CHROME_PATHS = [
|
|
29
31
|
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
@@ -151,6 +153,17 @@ export function derivePptxPath(htmlFilePath: string): string {
|
|
|
151
153
|
return join(dir, `${name}.pptx`)
|
|
152
154
|
}
|
|
153
155
|
|
|
156
|
+
export function resolveDomToPptxBundlePath(): string {
|
|
157
|
+
const entryPath = requireFromExportModule.resolve("dom-to-pptx")
|
|
158
|
+
const bundlePath = join(dirname(entryPath), "dom-to-pptx.bundle.js")
|
|
159
|
+
|
|
160
|
+
if (!existsSync(bundlePath)) {
|
|
161
|
+
throw new Error(`dom-to-pptx browser bundle not found: ${bundlePath}`)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return bundlePath
|
|
165
|
+
}
|
|
166
|
+
|
|
154
167
|
function isLocalImageRef(ref: string): boolean {
|
|
155
168
|
const pathPart = ref.split(/[?#]/)[0]
|
|
156
169
|
return IMAGE_EXTS.has(extname(pathPart).toLowerCase())
|
|
@@ -831,10 +844,7 @@ export async function exportToPptx(
|
|
|
831
844
|
): Promise<ExportPptxResult> {
|
|
832
845
|
const startMs = Date.now()
|
|
833
846
|
const abs = resolve(htmlFilePath)
|
|
834
|
-
const domToPptxBundlePath =
|
|
835
|
-
dirname(fileURLToPath(import.meta.url)),
|
|
836
|
-
"../../node_modules/dom-to-pptx/dist/dom-to-pptx.bundle.js"
|
|
837
|
-
)
|
|
847
|
+
const domToPptxBundlePath = resolveDomToPptxBundlePath()
|
|
838
848
|
|
|
839
849
|
if (!existsSync(abs)) {
|
|
840
850
|
throw new Error(`File not found: ${abs}`)
|