Update SingleFile to the latest version
This commit is contained in:
parent
32a5826a1f
commit
d03c495563
5 changed files with 37 additions and 70 deletions
|
@ -49,34 +49,17 @@ async function babelWorker(ev) {
|
|||
}
|
||||
|
||||
// Patch single-file
|
||||
else if (sourcefile === 'resource/SingleFile/lib/single-file/single-file.js') {
|
||||
// We need to add this bit that is done for the cli implementation of singleFile
|
||||
// See resource/SingleFile/cli/back-ends/common/scripts.js
|
||||
const WEB_SCRIPTS = [
|
||||
"lib/single-file/processors/hooks/content/content-hooks-web.js",
|
||||
"lib/single-file/processors/hooks/content/content-hooks-frames-web.js"
|
||||
];
|
||||
let basePath = 'resource/SingleFile/';
|
||||
|
||||
function readScriptFile(path, basePath) {
|
||||
return new Promise((resolve, reject) =>
|
||||
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 (sourcefile === 'resource/SingleFile/dist/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
|
||||
// doesn't properly support iterating over and throws an error. The normal
|
||||
// `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
|
||||
// manifest its own issues. Setting the globalThis to sandbox produced
|
||||
// issues with monkey-patching that singleFile does for default interfaces.
|
||||
transformed = contents.replace('globalThis.Set', 'Set')
|
||||
.replace('globalThis.Map', 'Map');
|
||||
}
|
||||
|
||||
else if ('ignore' in options && options.ignore.some(ignoreGlob => multimatch(sourcefile, ignoreGlob).length)) {
|
||||
|
|
|
@ -33,12 +33,11 @@ const symlinkFiles = [
|
|||
'!resource/react.js',
|
||||
'!resource/react-dom.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
|
||||
'!resource/SingleFile/**/*',
|
||||
'resource/SingleFile/lib/**/*',
|
||||
'resource/SingleFile/extension/lib/single-file/fetch/content/content-fetch.js',
|
||||
'!resource/SingleFile/lib/single-file/single-file.js',
|
||||
'resource/SingleFile/dist/**/*',
|
||||
'!resource/SingleFile/dist/single-file.js',
|
||||
// We only need a couple Ace Editor files
|
||||
'!resource/ace/**/*',
|
||||
'resource/ace/ace.js',
|
||||
|
@ -109,7 +108,7 @@ const jsFiles = [
|
|||
'resource/react.js',
|
||||
'resource/react-dom.js',
|
||||
'resource/react-virtualized.js',
|
||||
'resource/SingleFile/lib/single-file/single-file.js'
|
||||
'resource/SingleFile/dist/single-file.js'
|
||||
];
|
||||
|
||||
const scssFiles = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue