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