Skip to content

Commit 084aa69

Browse files
authored
Merge pull request #845 from OpenSignLabs/main
Safari issue patch
2 parents 45a96ec + 5976358 commit 084aa69

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

apps/OpenSign/src/App.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ const Opensigndrive = lazy(() => import("./pages/Opensigndrive"));
3030
const ManageSign = lazy(() => import("./pages/Managesign"));
3131
const GenerateToken = lazy(() => import("./pages/GenerateToken"));
3232
const Webhook = lazy(() => import("./pages/Webhook"));
33-
pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.min.mjs`;
33+
34+
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
35+
"pdfjs-dist/legacy/build/pdf.worker.min.mjs",
36+
import.meta.url
37+
).toString();
3438
const AppLoader = () => {
3539
return (
3640
<div className="flex justify-center items-center h-[100vh]">

apps/OpenSign/src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import DragElement from "./components/pdf/DragElement";
1717
import TagManager from "react-gtm-module";
1818
import Parse from "parse";
19+
import './polyfills'
1920
const appId = process.env.REACT_APP_APPID
2021
? process.env.REACT_APP_APPID
2122
: "opensign";

apps/OpenSign/src/polyfills.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// below code is used to handle undefined Promise.withResolvers for safari
2+
if (typeof Promise.withResolvers === "undefined") {
3+
Promise.withResolvers = function () {
4+
let resolve, reject;
5+
const promise = new Promise((res, rej) => {
6+
resolve = res;
7+
reject = rej;
8+
});
9+
return { promise, resolve, reject };
10+
};
11+
}
12+
13+
// Usage:
14+
// const { promise, resolve, reject } = Promise.withResolvers()
15+
// console.log(promise, resolve, reject) // Promise { <pending> } [Function (anonymous)] [Function (anonymous)]
16+
// ... Do something async and then call resolve or reject!

0 commit comments

Comments
 (0)