Update SingleFile to the latest version
This commit is contained in:
parent
32a5826a1f
commit
d03c495563
5 changed files with 37 additions and 70 deletions
|
@ -67,22 +67,32 @@ Zotero.SingleFile = {
|
||||||
autoSaveLoad: false,
|
autoSaveLoad: false,
|
||||||
autoSaveUnload: false,
|
autoSaveUnload: false,
|
||||||
autoSaveLoadOrUnload: true,
|
autoSaveLoadOrUnload: true,
|
||||||
|
autoSaveDiscard: false,
|
||||||
|
autoSaveRemove: false,
|
||||||
autoSaveRepeat: false,
|
autoSaveRepeat: false,
|
||||||
autoSaveRepeatDelay: 10,
|
autoSaveRepeatDelay: 10,
|
||||||
removeAlternativeFonts: true,
|
removeAlternativeFonts: true,
|
||||||
removeAlternativeMedias: true,
|
removeAlternativeMedias: true,
|
||||||
removeAlternativeImages: true,
|
removeAlternativeImages: true,
|
||||||
|
groupDuplicateImages: true,
|
||||||
saveRawPage: false,
|
saveRawPage: false,
|
||||||
saveToGDrive: false,
|
saveToClipboard: false,
|
||||||
|
addProof: false,
|
||||||
forceWebAuthFlow: false,
|
forceWebAuthFlow: false,
|
||||||
extractAuthCode: true,
|
extractAuthCode: true,
|
||||||
insertTextBody: true,
|
|
||||||
resolveFragmentIdentifierURLs: false,
|
resolveFragmentIdentifierURLs: false,
|
||||||
userScriptEnabled: true,
|
userScriptEnabled: true,
|
||||||
saveCreatedBookmarks: false,
|
saveCreatedBookmarks: false,
|
||||||
|
allowedBookmarkFolders: [],
|
||||||
ignoredBookmarkFolders: [],
|
ignoredBookmarkFolders: [],
|
||||||
replaceBookmarkURL: true,
|
replaceBookmarkURL: true,
|
||||||
saveFavicon: true,
|
saveFavicon: true,
|
||||||
includeBOM: false
|
includeBOM: false,
|
||||||
|
warnUnsavedPage: true,
|
||||||
|
insertMetaNoIndex: false,
|
||||||
|
insertMetaCSP: true,
|
||||||
|
passReferrerOnError: false,
|
||||||
|
insertSingleFileComment: true,
|
||||||
|
blockMixedContent: false,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -564,35 +564,11 @@ 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
|
||||||
"lib/single-file/index.js",
|
"dist/single-file.js",
|
||||||
|
|
||||||
// Rest of the scripts (does not include WEB_SCRIPTS, those are handled in build process)
|
|
||||||
"lib/single-file/processors/hooks/content/content-hooks.js",
|
|
||||||
"lib/single-file/processors/hooks/content/content-hooks-frames.js",
|
|
||||||
"lib/single-file/processors/frame-tree/content/content-frame-tree.js",
|
|
||||||
"lib/single-file/processors/lazy/content/content-lazy-loader.js",
|
|
||||||
"lib/single-file/single-file-util.js",
|
|
||||||
"lib/single-file/single-file-helper.js",
|
|
||||||
"lib/single-file/vendor/css-tree.js",
|
|
||||||
"lib/single-file/vendor/html-srcset-parser.js",
|
|
||||||
"lib/single-file/vendor/css-minifier.js",
|
|
||||||
"lib/single-file/vendor/css-font-property-parser.js",
|
|
||||||
"lib/single-file/vendor/css-unescape.js",
|
|
||||||
"lib/single-file/vendor/css-media-query-parser.js",
|
|
||||||
"lib/single-file/modules/html-minifier.js",
|
|
||||||
"lib/single-file/modules/css-fonts-minifier.js",
|
|
||||||
"lib/single-file/modules/css-fonts-alt-minifier.js",
|
|
||||||
"lib/single-file/modules/css-matched-rules.js",
|
|
||||||
"lib/single-file/modules/css-medias-alt-minifier.js",
|
|
||||||
"lib/single-file/modules/css-rules-minifier.js",
|
|
||||||
"lib/single-file/modules/html-images-alt-minifier.js",
|
|
||||||
"lib/single-file/modules/html-serializer.js",
|
|
||||||
"lib/single-file/single-file-core.js",
|
|
||||||
"lib/single-file/single-file.js",
|
|
||||||
|
|
||||||
// Web SCRIPTS
|
// Web SCRIPTS
|
||||||
"lib/single-file/processors/hooks/content/content-hooks-frames-web.js",
|
"dist/web/hooks/hooks-frames-web.js",
|
||||||
"lib/single-file/processors/hooks/content/content-hooks-web.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']
|
||||||
|
@ -618,11 +594,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 = [
|
||||||
"lib/single-file/index.js",
|
"dist/web/hooks/hooks-frames-web.js",
|
||||||
"lib/single-file/single-file-helper.js",
|
"dist/single-file-frames.js",
|
||||||
"lib/single-file/vendor/css-unescape.js",
|
|
||||||
"lib/single-file/processors/hooks/content/content-hooks-frames.js",
|
|
||||||
"lib/single-file/processors/frame-tree/content/content-frame-tree.js",
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Create sandboxes for all the frames we find
|
// Create sandboxes for all the frames we find
|
||||||
|
@ -640,7 +613,7 @@ Zotero.Utilities.Internal = {
|
||||||
|
|
||||||
// Use SingleFile to retrieve the html
|
// Use SingleFile to retrieve the html
|
||||||
const pageData = await Components.utils.evalInSandbox(
|
const pageData = await Components.utils.evalInSandbox(
|
||||||
`this.singlefile.lib.getPageData(
|
`this.singlefile.getPageData(
|
||||||
Zotero.SingleFile.CONFIG,
|
Zotero.SingleFile.CONFIG,
|
||||||
{ fetch: ZoteroFetch }
|
{ fetch: ZoteroFetch }
|
||||||
);`,
|
);`,
|
||||||
|
@ -666,6 +639,8 @@ Zotero.Utilities.Internal = {
|
||||||
sandbox.window = view.window;
|
sandbox.window = view.window;
|
||||||
sandbox.document = sandbox.window.document;
|
sandbox.document = sandbox.window.document;
|
||||||
sandbox.browser = false;
|
sandbox.browser = false;
|
||||||
|
// See comment in babel-worker.js
|
||||||
|
sandbox.globalThis = view.window;
|
||||||
|
|
||||||
sandbox.Zotero = Components.utils.cloneInto({ HTTP: {} }, sandbox);
|
sandbox.Zotero = Components.utils.cloneInto({ HTTP: {} }, sandbox);
|
||||||
sandbox.Zotero.debug = Components.utils.exportFunction(Zotero.debug, sandbox);
|
sandbox.Zotero.debug = Components.utils.exportFunction(Zotero.debug, sandbox);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit da6994a142c12aab6fd6966f48f48307d53fdedd
|
Subproject commit 832898055f2d8df8254aeb46f9dccfe7f74d4768
|
|
@ -49,34 +49,17 @@ async function babelWorker(ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch single-file
|
// Patch single-file
|
||||||
else if (sourcefile === 'resource/SingleFile/lib/single-file/single-file.js') {
|
else if (sourcefile === 'resource/SingleFile/dist/single-file.js') {
|
||||||
// We need to add this bit that is done for the cli implementation of singleFile
|
// Change for what I assume is a bug in Firefox. We create a singlefile
|
||||||
// See resource/SingleFile/cli/back-ends/common/scripts.js
|
// sandbox which is based on a document.defaultView of a hidden browser.
|
||||||
const WEB_SCRIPTS = [
|
// The minified single-file then uses globalThis.Set which for some reason
|
||||||
"lib/single-file/processors/hooks/content/content-hooks-web.js",
|
// doesn't properly support iterating over and throws an error. The normal
|
||||||
"lib/single-file/processors/hooks/content/content-hooks-frames-web.js"
|
// `Set` object accessible in the sandbox does not have this problem.
|
||||||
];
|
// I've tried using a proxy for globalThis with a custom Set, but that
|
||||||
let basePath = 'resource/SingleFile/';
|
// manifest its own issues. Setting the globalThis to sandbox produced
|
||||||
|
// issues with monkey-patching that singleFile does for default interfaces.
|
||||||
function readScriptFile(path, basePath) {
|
transformed = contents.replace('globalThis.Set', 'Set')
|
||||||
return new Promise((resolve, reject) =>
|
.replace('globalThis.Map', 'Map');
|
||||||
fs.readFile(basePath + path, (err, data) => {
|
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
} else {
|
|
||||||
resolve(data.toString() + "\n");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const webScripts = {};
|
|
||||||
await Promise.all(
|
|
||||||
WEB_SCRIPTS.map(async path => webScripts[path] = await readScriptFile(path, basePath))
|
|
||||||
);
|
|
||||||
|
|
||||||
transformed = contents + '\n\n'
|
|
||||||
+ "this.singlefile.lib.getFileContent = filename => (" + JSON.stringify(webScripts) + ")[filename];\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ('ignore' in options && options.ignore.some(ignoreGlob => multimatch(sourcefile, ignoreGlob).length)) {
|
else if ('ignore' in options && options.ignore.some(ignoreGlob => multimatch(sourcefile, ignoreGlob).length)) {
|
||||||
|
|
|
@ -33,12 +33,11 @@ const symlinkFiles = [
|
||||||
'!resource/react.js',
|
'!resource/react.js',
|
||||||
'!resource/react-dom.js',
|
'!resource/react-dom.js',
|
||||||
'!resource/react-virtualized.js',
|
'!resource/react-virtualized.js',
|
||||||
// Only include lib 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/lib/**/*',
|
'resource/SingleFile/dist/**/*',
|
||||||
'resource/SingleFile/extension/lib/single-file/fetch/content/content-fetch.js',
|
'!resource/SingleFile/dist/single-file.js',
|
||||||
'!resource/SingleFile/lib/single-file/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',
|
||||||
|
@ -109,7 +108,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/lib/single-file/single-file.js'
|
'resource/SingleFile/dist/single-file.js'
|
||||||
];
|
];
|
||||||
|
|
||||||
const scssFiles = [
|
const scssFiles = [
|
||||||
|
|
Loading…
Reference in a new issue