Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
fix: wip
Marc Seitzec813c35191b
diff --git a/package.json b/package.jsonindex 18b34a26..c922e543 100644--- a/package.json+++ b/package.json@@ -11,8 +11,9 @@"start": "next start","lint": "next lint","postinstall": "prisma generate",- "vercel-build": "prisma migrate deploy && next build",- "email": "email dev --dir ./components/emails --port 3001"+ "vercel-build": "prisma migrate deploy && npm run copy:mupdf && next build",+ "email": "email dev --dir ./components/emails --port 3001",+ "copy:mupdf": "node ./scripts/copy-mupdf.cjs"},"dependencies": {"@chronark/zod-bird": "^0.2.2",diff --git a/pages/api/mupdf/get-pages.ts b/pages/api/mupdf/get-pages.tsindex 1fbf6fa7..a9a7c878 100644--- a/pages/api/mupdf/get-pages.ts+++ b/pages/api/mupdf/get-pages.ts@@ -1,7 +1,27 @@import { NextApiRequest, NextApiResponse } from "next";+// import fs from "fs";+// import path from "path";++// // 1. Synchronously load the wasm binary+// const wasmFilePath = path.join(process.cwd(), "public", "mupdf/mupdf-wasm.wasm");+// const wasmBinary = fs.readFileSync(wasmFilePath);++// // 2. Ensure the wasm module uses this binary for its initialization.+// globalThis.Module = {+// wasmBinary: wasmBinary,+// locateFile: (filename: string) => {+// if (filename.endsWith(".wasm")) {+// return wasmFilePath;+// }+// return filename;+// },+// };++// Load mupdf from the local directory.+// @ts-ignore+// import mupdf from "mupdf";const mupdf = require("mupdf");-// setWasmPath("/public/mupdf-wasm.wasm");export default async (req: NextApiRequest, res: NextApiResponse) => {diff --git a/scripts/copy-mupdf.cjs b/scripts/copy-mupdf.cjsnew file mode 100644index 00000000..501023e3--- /dev/null+++ b/scripts/copy-mupdf.cjs@@ -0,0 +1,19 @@+#!/usr/bin/env node++const path = require("path");+const fs = require("fs");++// Resolve main entry of mupdf first+const mupdfMainPath = path.dirname(require.resolve("mupdf"));+// Construct the path to package.json from there+const mupdfPackageJsonPath = path.join(mupdfMainPath, "package.json");++// You probably don't directly need the package.json for the operations that follow,+// so I'm leaving the rest of the script unchanged:++const wasmPath = path.join(mupdfMainPath, "mupdf-wasm.wasm");+const jsPath = path.join(mupdfMainPath, "mupdf-wasm.js");++// Copy files to public directory+fs.copyFileSync(wasmPath, "./public/mupdf-wasm.wasm");+fs.copyFileSync(jsPath, "./public/mupdf-wasm.js");