Skip to content

Commit

Permalink
fixing PR review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Gokul K authored and Gokul K committed Sep 22, 2024
1 parent 922810d commit 9832c17
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
4 changes: 2 additions & 2 deletions esbuild-helper/copy-file-plugin.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import fs from "fs";

const copyFilePlugin = (fileSrcPath, fileDestPAth) => ({
const copyFilePlugin = (fileSrcPath, fileDestPath) => ({
name: "copy-file-plugin",
setup(build) {
build.onEnd(async () => {
try {
fs.copyFileSync(fileSrcPath, fileDestPAth);
fs.copyFileSync(fileSrcPath, fileDestPath);
} catch (e) {
console.error(`Failed to copy file: ${fileSrcPath}`, e);
}
Expand Down
1 change: 1 addition & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
href="./assets/images/favicon/favicon-48.png"
/>
<link rel="manifest" href="manifest.json">
<script src="https://cdn.jsdelivr.net/npm/pwacompat/pwacompat.min.js" integrity="sha256-QmifG9ty2co3761lBWJwL5KdDOdJ4sFjQ/ULE4aD18U=" crossorigin="anonymous"></script>
</head>
<body>
<h1 class="no-show">
Expand Down
38 changes: 22 additions & 16 deletions js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -759,29 +759,36 @@ export async function initSentry() {
});
}

export function registerSW() {
export async function registerSW() {
try {
if ("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker
.register("../sw.js")
.then((registration) => {
console.log(
"Service Worker registered with scope:",
registration.scope
);
})
.catch((error) => {
console.error("Service Worker registration failed:", error);
});
});
if (!("serviceWorker" in navigator)) {
console.error("Service Workers are not supported by this browser");
return;
}
console.log("Registering Service Worker - - - -");

window.addEventListener("load", () => {
console.log("trying load - - - ");

navigator.serviceWorker
.register("../sw.js")
.then((registration) => {
console.log(
"Service Worker registered with scope:",
registration.scope
);
})
.catch((error) => {
console.error("Service Worker registration failed:", error);
});
});
} catch (error) {
console.error("Service Worker registration failed:", error);
}
}

export async function init() {
registerSW();
initSentry();
setupDocument();
await loadSettings();
Expand All @@ -792,5 +799,4 @@ export async function init() {
setupListeners();
evaluate(editor.innerText);
updateOutputDisplay(output);
registerSW();
}

0 comments on commit 9832c17

Please sign in to comment.