Changes for updated SingleFile submodule
This commit is contained in:
parent
66f5647069
commit
3ba78dec78
3 changed files with 17 additions and 13 deletions
|
@ -598,11 +598,10 @@ Zotero.Utilities.Internal = {
|
|||
|
||||
const SCRIPTS = [
|
||||
// This first script replace in the INDEX_SCRIPTS from the single file cli loader
|
||||
"dist/single-file.js",
|
||||
"lib/single-file.js",
|
||||
|
||||
// Web SCRIPTS
|
||||
"dist/web/hooks/hooks-frames-web.js",
|
||||
"dist/web/hooks/hooks-web.js",
|
||||
"lib/single-file-hooks-frames.js",
|
||||
];
|
||||
|
||||
const { loadSubScript } = Components.classes['@mozilla.org/moz/jssubscript-loader;1']
|
||||
|
@ -628,8 +627,8 @@ Zotero.Utilities.Internal = {
|
|||
// List of scripts from:
|
||||
// resource/SingleFile/extension/lib/single-file/core/bg/scripts.js
|
||||
const frameScripts = [
|
||||
"dist/web/hooks/hooks-frames-web.js",
|
||||
"dist/single-file-frames.js",
|
||||
"lib/single-file-hooks-frames.js",
|
||||
"lib/single-file-frames.js",
|
||||
];
|
||||
|
||||
// Create sandboxes for all the frames we find
|
||||
|
@ -681,7 +680,7 @@ Zotero.Utilities.Internal = {
|
|||
// Mostly copied from:
|
||||
// resources/SingleFile/extension/lib/single-file/fetch/bg/fetch.js::fetchResource
|
||||
sandbox.coFetch = Components.utils.exportFunction(
|
||||
function (url, onDone) {
|
||||
function (url, options, onDone) {
|
||||
const xhrRequest = new XMLHttpRequest();
|
||||
xhrRequest.withCredentials = true;
|
||||
xhrRequest.responseType = "arraybuffer";
|
||||
|
@ -707,6 +706,11 @@ Zotero.Utilities.Internal = {
|
|||
}
|
||||
};
|
||||
xhrRequest.open("GET", url, true);
|
||||
if (options && options.headers) {
|
||||
for (const entry of Object.entries(options.headers)) {
|
||||
xhrRequest.setRequestHeader(entry[0], entry[1]);
|
||||
}
|
||||
}
|
||||
xhrRequest.send();
|
||||
},
|
||||
sandbox
|
||||
|
@ -717,14 +721,14 @@ Zotero.Utilities.Internal = {
|
|||
// resources/SingleFile/extension/lib/single-file/fetch/content/content-fetch.js::fetch
|
||||
Components.utils.evalInSandbox(
|
||||
`
|
||||
ZoteroFetch = async function (url) {
|
||||
ZoteroFetch = async function (url, options) {
|
||||
try {
|
||||
let response = await fetch(url, { cache: "force-cache" });
|
||||
let response = await fetch(url, { cache: "force-cache", headers: options.headers });
|
||||
return response;
|
||||
}
|
||||
catch (error) {
|
||||
let response = await new Promise((resolve, reject) => {
|
||||
coFetch(url, (response) => {
|
||||
coFetch(url, { headers: options.headers }, (response) => {
|
||||
if (response.error) {
|
||||
Zotero.debug("Error retrieving url: " + url);
|
||||
Zotero.debug(response);
|
||||
|
|
|
@ -48,7 +48,7 @@ async function babelWorker(ev) {
|
|||
.replace('document.body.removeChild(scrollDiv)', 'document.documentElement.removeChild(scrollDiv)');
|
||||
}
|
||||
// Patch single-file
|
||||
else if (sourcefile === 'resource/SingleFile/dist/single-file.js') {
|
||||
else if (sourcefile === 'resource/SingleFile/lib/single-file.js') {
|
||||
// Change for what I assume is a bug in Firefox. We create a singlefile
|
||||
// sandbox which is based on a document.defaultView of a hidden browser.
|
||||
// The minified single-file then uses globalThis.Set which for some reason
|
||||
|
|
|
@ -37,8 +37,8 @@ const symlinkFiles = [
|
|||
// Only include dist directory of singleFile
|
||||
// Also do a little bit of manipulation similar to React
|
||||
'!resource/SingleFile/**/*',
|
||||
'resource/SingleFile/dist/**/*',
|
||||
'!resource/SingleFile/dist/single-file.js',
|
||||
'resource/SingleFile/lib/**/*',
|
||||
'!resource/SingleFile/lib/single-file.js',
|
||||
// We only need a couple Ace Editor files
|
||||
'!resource/ace/**/*',
|
||||
'resource/ace/ace.js',
|
||||
|
@ -112,7 +112,7 @@ const jsFiles = [
|
|||
'resource/react.js',
|
||||
'resource/react-dom.js',
|
||||
'resource/react-virtualized.js',
|
||||
'resource/SingleFile/dist/single-file.js',
|
||||
'resource/SingleFile/lib/single-file.js',
|
||||
'resource/citeproc_rs_wasm.js',
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in a new issue