From cbc0195d05796beb41b09a159db68b1b2b1dc353 Mon Sep 17 00:00:00 2001 From: Panagiotis Georgakopoulos Date: Mon, 19 Feb 2024 14:57:42 +0200 Subject: [PATCH 1/4] fix: make sure mathjax will be bundled --- frontend/common/SetupMathJax.js | 9 +++++++-- frontend/editor.html | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/common/SetupMathJax.js b/frontend/common/SetupMathJax.js index c927fdc13d..76d695c4cd 100644 --- a/frontend/common/SetupMathJax.js +++ b/frontend/common/SetupMathJax.js @@ -75,14 +75,19 @@ export const setup_mathjax = () => { requestIdleCallback( () => { console.log("Loading mathjax!!") + const src = new URL("https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg-full.js", import.meta.url) + const integrity = "sha384-4kE/rQ11E8xT9QgrCBTyvenkuPfQo8rXYQvJZuMgxyPOoUfpatjQPlgdv6V5yhUK" const script = document.head.querySelector("#MathJax-script") - script?.addEventListener("load", () => { + if (!script) return + script.addEventListener("load", () => { console.log("MathJax loaded!") if (window["MathJax"]?.version !== "3.2.2") { twowasloaded() } }) - script.setAttribute("src", script.getAttribute("not-the-src-yet")) + script.setAttribute("crossorigin", "anonymous") + script.setAttribute("integrity", integrity) + script.setAttribute("src", src.toString()) }, { timeout: 2000 } ) diff --git a/frontend/editor.html b/frontend/editor.html index d1009de57f..5d47bd5a76 100644 --- a/frontend/editor.html +++ b/frontend/editor.html @@ -43,8 +43,8 @@ - - + + From 9e4b7f0a81573d617318207e45d21d1766f1c7a5 Mon Sep 17 00:00:00 2001 From: Panagiotis Georgakopoulos Date: Tue, 20 Feb 2024 11:36:10 +0200 Subject: [PATCH 2/4] fix: remove integrity for the bundled asset --- frontend/common/SetupMathJax.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/common/SetupMathJax.js b/frontend/common/SetupMathJax.js index 76d695c4cd..12227d5bdf 100644 --- a/frontend/common/SetupMathJax.js +++ b/frontend/common/SetupMathJax.js @@ -76,7 +76,6 @@ export const setup_mathjax = () => { () => { console.log("Loading mathjax!!") const src = new URL("https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg-full.js", import.meta.url) - const integrity = "sha384-4kE/rQ11E8xT9QgrCBTyvenkuPfQo8rXYQvJZuMgxyPOoUfpatjQPlgdv6V5yhUK" const script = document.head.querySelector("#MathJax-script") if (!script) return script.addEventListener("load", () => { @@ -86,7 +85,6 @@ export const setup_mathjax = () => { } }) script.setAttribute("crossorigin", "anonymous") - script.setAttribute("integrity", integrity) script.setAttribute("src", src.toString()) }, { timeout: 2000 } From 9887d83617b48ba1a4a55c1e32ca7377b796c0bf Mon Sep 17 00:00:00 2001 From: Panagiotis Georgakopoulos Date: Tue, 20 Feb 2024 12:16:36 +0200 Subject: [PATCH 3/4] import.meta.url will be file:/// if bundled, I think --- frontend/common/SetupMathJax.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/common/SetupMathJax.js b/frontend/common/SetupMathJax.js index 12227d5bdf..7e17af7b97 100644 --- a/frontend/common/SetupMathJax.js +++ b/frontend/common/SetupMathJax.js @@ -76,6 +76,7 @@ export const setup_mathjax = () => { () => { console.log("Loading mathjax!!") const src = new URL("https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg-full.js", import.meta.url) + const integrity = "sha384-4kE/rQ11E8xT9QgrCBTyvenkuPfQo8rXYQvJZuMgxyPOoUfpatjQPlgdv6V5yhUK" const script = document.head.querySelector("#MathJax-script") if (!script) return script.addEventListener("load", () => { @@ -85,6 +86,7 @@ export const setup_mathjax = () => { } }) script.setAttribute("crossorigin", "anonymous") + if (!import.meta.url.startsWith("file:///")) script.setAttribute("integrity", integrity) script.setAttribute("src", src.toString()) }, { timeout: 2000 } From f5696e235a1af3dfad35fd8a1091e37e17294b4d Mon Sep 17 00:00:00 2001 From: Panagiotis Georgakopoulos Date: Tue, 20 Feb 2024 12:30:14 +0200 Subject: [PATCH 4/4] fix: add clean command --- frontend-bundler/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend-bundler/package.json b/frontend-bundler/package.json index c05068d4c9..85cda4b5a3 100644 --- a/frontend-bundler/package.json +++ b/frontend-bundler/package.json @@ -8,6 +8,7 @@ "scripts": { "start": "cd ../frontend && parcel --dist-dir ../frontend-dist --config ../frontend-bundler/.parcelrc editor.html index.html error.jl.html", "build": "cd ../frontend && parcel build --no-source-maps --public-url . --dist-dir ../frontend-dist --config ../frontend-bundler/.parcelrc editor.html index.html error.jl.html && node ../frontend-bundler/add_sri.js ../frontend-dist/editor.html", + "clean": "rm -rf ../frontend/.parcel-cache/", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "",