|
|
@@ -37,9 +37,14 @@ this.singlefile.lib.util = this.singlefile.lib.util || (() => {
|
|
|
const crypto = window.crypto;
|
|
|
const TextDecoder = window.TextDecoder;
|
|
|
const TextEncoder = window.TextEncoder;
|
|
|
+ const singlefile = this.singlefile;
|
|
|
|
|
|
return {
|
|
|
- getInstance: (modules, utilOptions) => {
|
|
|
+ getInstance(utilOptions) {
|
|
|
+ const modules = singlefile.lib.modules;
|
|
|
+ const vendor = singlefile.lib.vendor;
|
|
|
+ const helper = singlefile.lib.helper;
|
|
|
+
|
|
|
if (modules.serializer === undefined) {
|
|
|
modules.serializer = {
|
|
|
process(doc) {
|
|
|
@@ -152,7 +157,7 @@ this.singlefile.lib.util = this.singlefile.lib.util || (() => {
|
|
|
return modules.matchedRules.getMediaAllInfo(doc, stylesheets, styles);
|
|
|
},
|
|
|
compressCSS(content, options) {
|
|
|
- return modules.cssMinifier.processString(content, options);
|
|
|
+ return vendor.cssMinifier.processString(content, options);
|
|
|
},
|
|
|
minifyMedias(stylesheets) {
|
|
|
return modules.mediasAltMinifier.process(stylesheets);
|
|
|
@@ -161,30 +166,31 @@ this.singlefile.lib.util = this.singlefile.lib.util || (() => {
|
|
|
return modules.imagesAltMinifier.process(doc);
|
|
|
},
|
|
|
parseSrcset(srcset) {
|
|
|
- return modules.srcsetParser.process(srcset);
|
|
|
+ return vendor.srcsetParser.process(srcset);
|
|
|
},
|
|
|
preProcessDoc(doc, win, options) {
|
|
|
- return modules.helper.preProcessDoc(doc, win, options);
|
|
|
+ return helper.preProcessDoc(doc, win, options);
|
|
|
},
|
|
|
postProcessDoc(doc, markedElements) {
|
|
|
- modules.helper.postProcessDoc(doc, markedElements);
|
|
|
+ helper.postProcessDoc(doc, markedElements);
|
|
|
},
|
|
|
serialize(doc, compressHTML) {
|
|
|
return modules.serializer.process(doc, compressHTML);
|
|
|
},
|
|
|
removeQuotes(string) {
|
|
|
- return modules.helper.removeQuotes(string);
|
|
|
+ return helper.removeQuotes(string);
|
|
|
},
|
|
|
- WIN_ID_ATTRIBUTE_NAME: modules.helper.WIN_ID_ATTRIBUTE_NAME,
|
|
|
- REMOVED_CONTENT_ATTRIBUTE_NAME: modules.helper.REMOVED_CONTENT_ATTRIBUTE_NAME,
|
|
|
- IMAGE_ATTRIBUTE_NAME: modules.helper.IMAGE_ATTRIBUTE_NAME,
|
|
|
- POSTER_ATTRIBUTE_NAME: modules.helper.POSTER_ATTRIBUTE_NAME,
|
|
|
- CANVAS_ATTRIBUTE_NAME: modules.helper.CANVAS_ATTRIBUTE_NAME,
|
|
|
- HTML_IMPORT_ATTRIBUTE_NAME: modules.helper.HTML_IMPORT_ATTRIBUTE_NAME,
|
|
|
- INPUT_VALUE_ATTRIBUTE_NAME: modules.helper.INPUT_VALUE_ATTRIBUTE_NAME,
|
|
|
- SHADOW_ROOT_ATTRIBUTE_NAME: modules.helper.SHADOW_ROOT_ATTRIBUTE_NAME,
|
|
|
- PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME: modules.helper.PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME,
|
|
|
- STYLESHEET_ATTRIBUTE_NAME: modules.helper.STYLESHEET_ATTRIBUTE_NAME
|
|
|
+ WIN_ID_ATTRIBUTE_NAME: helper.WIN_ID_ATTRIBUTE_NAME,
|
|
|
+ REMOVED_CONTENT_ATTRIBUTE_NAME: helper.REMOVED_CONTENT_ATTRIBUTE_NAME,
|
|
|
+ IMAGE_ATTRIBUTE_NAME: helper.IMAGE_ATTRIBUTE_NAME,
|
|
|
+ POSTER_ATTRIBUTE_NAME: helper.POSTER_ATTRIBUTE_NAME,
|
|
|
+ CANVAS_ATTRIBUTE_NAME: helper.CANVAS_ATTRIBUTE_NAME,
|
|
|
+ HTML_IMPORT_ATTRIBUTE_NAME: helper.HTML_IMPORT_ATTRIBUTE_NAME,
|
|
|
+ INPUT_VALUE_ATTRIBUTE_NAME: helper.INPUT_VALUE_ATTRIBUTE_NAME,
|
|
|
+ SHADOW_ROOT_ATTRIBUTE_NAME: helper.SHADOW_ROOT_ATTRIBUTE_NAME,
|
|
|
+ PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME: helper.PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME,
|
|
|
+ STYLESHEET_ATTRIBUTE_NAME: helper.STYLESHEET_ATTRIBUTE_NAME,
|
|
|
+ SELECTED_CONTENT_ATTRIBUTE_NAME: helper.SELECTED_CONTENT_ATTRIBUTE_NAME
|
|
|
};
|
|
|
|
|
|
async function getContent(resourceURL, options) {
|
|
|
@@ -213,7 +219,7 @@ this.singlefile.lib.util = this.singlefile.lib.util || (() => {
|
|
|
if (charsetValue) {
|
|
|
const matchCharset = charsetValue.match(/^charset=(.*)/);
|
|
|
if (matchCharset && matchCharset[1]) {
|
|
|
- charset = modules.helper.removeQuotes(matchCharset[1].trim());
|
|
|
+ charset = helper.removeQuotes(matchCharset[1].trim());
|
|
|
}
|
|
|
}
|
|
|
}
|