1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-17 12:01:13 +02:00

add alternative to window.webkitRequestFileSystem

This commit is contained in:
Kushagra Gour
2017-11-19 01:35:24 +05:30
parent 51aac2e63b
commit d2458a7b8b
2 changed files with 30 additions and 17 deletions

View File

@@ -200,6 +200,7 @@
"escodegen": true, "escodegen": true,
"utils": true, "utils": true,
"Promise": true, "Promise": true,
"Inlet": true "Inlet": true,
"db": true
} }
} }

View File

@@ -994,7 +994,9 @@ globalConsoleContainerEl, externalLibrarySearchInput, keyboardShortcutsModal
if (!isForExport) { if (!isForExport) {
contents += contents +=
'<script src="' + '<script src="' +
chrome.extension.getURL('lib/screenlog.js') + (chrome.extension
? chrome.extension.getURL('lib/screenlog.js')
: `${location.origin}/lib/screenlog.js`) +
'"></script>'; '"></script>';
} }
@@ -1073,7 +1075,8 @@ globalConsoleContainerEl, externalLibrarySearchInput, keyboardShortcutsModal
} }
function createPreviewFile(html, css, js) { function createPreviewFile(html, css, js) {
var contents = getCompleteHtml(html, css); const shouldInlineJs = !window.webkitRequestFileSystem;
var contents = getCompleteHtml(html, css, shouldInlineJs ? js : '');
var blob = new Blob([contents], { type: 'text/plain;charset=UTF-8' }); var blob = new Blob([contents], { type: 'text/plain;charset=UTF-8' });
var blobjs = new Blob([js], { type: 'text/plain;charset=UTF-8' }); var blobjs = new Blob([js], { type: 'text/plain;charset=UTF-8' });
@@ -1083,6 +1086,14 @@ globalConsoleContainerEl, externalLibrarySearchInput, keyboardShortcutsModal
trackEvent.hasTrackedCode = true; trackEvent.hasTrackedCode = true;
} }
if (shouldInlineJs) {
frame.src = frame.src;
setTimeout(() => {
frame.contentDocument.open();
frame.contentDocument.write(contents);
frame.contentDocument.close();
}, 10);
} else {
// we need to store user script in external JS file to prevent inline-script // we need to store user script in external JS file to prevent inline-script
// CSP from affecting it. // CSP from affecting it.
writeFile('script.js', blobjs, function() { writeFile('script.js', blobjs, function() {
@@ -1099,6 +1110,7 @@ globalConsoleContainerEl, externalLibrarySearchInput, keyboardShortcutsModal
}); });
}); });
} }
}
scope.setPreviewContent = function(isForced) { scope.setPreviewContent = function(isForced) {
if (!prefs.preserveConsoleLogs) { if (!prefs.preserveConsoleLogs) {