Explorar o código

renamed docUtil to util

Gildas %!s(int64=6) %!d(string=hai) anos
pai
achega
fd03acccaa
Modificáronse 1 ficheiros con 64 adicións e 64 borrados
  1. 64 64
      lib/single-file/single-file-core.js

+ 64 - 64
lib/single-file/single-file-core.js

@@ -26,10 +26,10 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 	const SELECTED_CONTENT_ATTRIBUTE_NAME = "data-single-file-selected-content";
 	const DEBUG = false;
 
-	let docUtil, cssTree, sessionId = 0;
+	let util, cssTree, sessionId = 0;
 
 	function getClass(...args) {
-		[docUtil, cssTree] = args;
+		[util, cssTree] = args;
 		return SingleFileClass;
 	}
 
@@ -148,7 +148,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			this.batchRequest = new BatchRequest();
 			this.processor = new Processor(options, this.batchRequest);
 			if (this.options.doc) {
-				const docData = docUtil.preProcessDoc(this.options.doc, this.options.win, this.options);
+				const docData = util.preProcessDoc(this.options.doc, this.options.win, this.options);
 				this.options.canvasData = docData.canvasData;
 				this.options.fontsData = docData.fontsData;
 				this.options.stylesheetsData = docData.stylesheetsData;
@@ -161,7 +161,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			if (this.options.saveRawPage) {
 				this.options.removeFrames = true;
 			}
-			this.options.content = this.options.content || (this.options.doc ? docUtil.serialize(this.options.doc, false) : null);
+			this.options.content = this.options.content || (this.options.doc ? util.serialize(this.options.doc, false) : null);
 			this.onprogress = options.onprogress || (() => { });
 		}
 
@@ -176,7 +176,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			await this.executeStage(RESOLVE_URLS_STAGE);
 			this.pendingPromises = this.executeStage(REPLACE_DATA_STAGE);
 			if (this.options.doc) {
-				docUtil.postProcessDoc(this.options.doc, this.options);
+				util.postProcessDoc(this.options.doc, this.options);
 			}
 			this.options.doc = null;
 			this.options.win = null;
@@ -301,7 +301,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				const resourceRequests = this.requests.get(requestKey);
 				this.requests.delete(requestKey);
 				try {
-					const content = await docUtil.getContent(resourceURL, { asDataURI, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled });
+					const content = await util.getContent(resourceURL, { asDataURI, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled });
 					indexResource = indexResource + 1;
 					onloadListener({ index: indexResource, url: resourceURL });
 					resourceRequests.forEach(callbacks => {
@@ -343,7 +343,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			this.options.saveDate = new Date();
 			this.options.saveUrl = this.options.url;
 			if (this.options.enableMaff) {
-				this.maffMetaDataPromise = this.batchRequest.addURL(docUtil.resolveURL("index.rdf", this.options.baseURI || this.options.url), false);
+				this.maffMetaDataPromise = this.batchRequest.addURL(util.resolveURL("index.rdf", this.options.baseURI || this.options.url), false);
 			}
 			this.maxResources = this.batchRequest.getMaxResources();
 			if (!this.options.saveRawPage && !this.options.removeFrames && this.options.framesData) {
@@ -355,10 +355,10 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		async loadPage(pageContent, charset) {
 			let content;
 			if (!pageContent || this.options.saveRawPage) {
-				content = await docUtil.getContent(this.baseURI, { asDataURI: false, maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled, charset });
+				content = await util.getContent(this.baseURI, { asDataURI: false, maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled, charset });
 				pageContent = content.data;
 			}
-			this.doc = docUtil.parseDocContent(pageContent, this.baseURI);
+			this.doc = util.parseDocContent(pageContent, this.baseURI);
 			if (this.options.saveRawPage) {
 				let charset;
 				this.doc.querySelectorAll("meta[charset], meta[http-equiv=\"content-type\"]").forEach(element => {
@@ -392,7 +392,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				const maffMetaData = await this.maffMetaDataPromise;
 				if (maffMetaData && maffMetaData.content) {
 					const NAMESPACE_RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
-					const maffDoc = docUtil.parseXMLContent(maffMetaData.content);
+					const maffDoc = util.parseXMLContent(maffMetaData.content);
 					const originalURLElement = maffDoc.querySelector("RDF > Description > originalurl");
 					const archiveTimeElement = maffDoc.querySelector("RDF > Description > archivetime");
 					if (originalURLElement) {
@@ -426,8 +426,8 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		}
 
 		async getPageData() {
-			docUtil.postProcessDoc(this.doc, this.options);
-			const url = docUtil.parseURL(this.baseURI);
+			util.postProcessDoc(this.doc, this.options);
+			const url = util.parseURL(this.baseURI);
 			if (this.options.insertSingleFileComment) {
 				const infobarContent = (this.options.infobarContent || "").replace(/\\n/g, "\n").replace(/\\t/g, "\t");
 				const commentNode = this.doc.createComment("\n Page saved with SingleFile" +
@@ -438,11 +438,11 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			}
 			let size;
 			if (this.options.displayStats) {
-				size = docUtil.getContentSize(this.doc.documentElement.outerHTML);
+				size = util.getContentSize(this.doc.documentElement.outerHTML);
 			}
-			const content = docUtil.serialize(this.doc, this.options.compressHTML);
+			const content = util.serialize(this.doc, this.options.compressHTML);
 			if (this.options.displayStats) {
-				const contentSize = docUtil.getContentSize(content);
+				const contentSize = util.getContentSize(content);
 				this.stats.set("processed", "HTML bytes", contentSize);
 				this.stats.add("discarded", "HTML bytes", size - contentSize);
 			}
@@ -452,10 +452,10 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			if (!this.options.backgroundSave) {
 				filename = filename.replace(/\//g, "_");
 			}
-			if (docUtil.getContentSize(filename) > 192) {
+			if (util.getContentSize(filename) > 192) {
 				const extensionMatch = filename.match(/(\.[^.]{3,4})$/);
 				const extension = extensionMatch && extensionMatch[0] && extensionMatch[0].length > 1 ? extensionMatch[0] : "";
-				filename = await docUtil.truncateText(filename, 192 - extension.length);
+				filename = await util.truncateText(filename, 192 - extension.length);
 				filename = filename + "…" + extension;
 			}
 			if (!filename) {
@@ -475,7 +475,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				this.doc.body.querySelectorAll(":not(svg) title, meta, link[href][rel*=\"icon\"]").forEach(element => element instanceof this.options.win.HTMLElement && this.doc.head.appendChild(element));
 			}
 			if (this.options.imagesData && !this.options.saveRawPage) {
-				const dataAttributeName = docUtil.IMAGE_ATTRIBUTE_NAME;
+				const dataAttributeName = util.IMAGE_ATTRIBUTE_NAME;
 				this.doc.querySelectorAll("img").forEach(imgElement => {
 					const imgData = this.options.imagesData[Number(imgElement.getAttribute(dataAttributeName))];
 					if (this.options.removeHiddenElements && imgData.size && !imgData.size.pxWidth && !imgData.size.pxHeight) {
@@ -561,7 +561,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 					} else {
 						videoElement = element.parentElement;
 					}
-					const videoIndex = Number(element.getAttribute(docUtil.POSTER_ATTRIBUTE_NAME));
+					const videoIndex = Number(element.getAttribute(util.POSTER_ATTRIBUTE_NAME));
 					if (!videoElement.poster && this.options.postersData[videoIndex]) {
 						videoElement.setAttribute("poster", this.options.postersData[videoIndex]);
 					}
@@ -673,22 +673,22 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 
 		setInputValues() {
 			this.doc.querySelectorAll("input").forEach(input => {
-				const value = input.getAttribute(docUtil.INPUT_VALUE_ATTRIBUTE_NAME);
+				const value = input.getAttribute(util.INPUT_VALUE_ATTRIBUTE_NAME);
 				input.setAttribute("value", value || "");
 			});
 			this.doc.querySelectorAll("input[type=radio], input[type=checkbox]").forEach(input => {
-				const value = input.getAttribute(docUtil.INPUT_VALUE_ATTRIBUTE_NAME);
+				const value = input.getAttribute(util.INPUT_VALUE_ATTRIBUTE_NAME);
 				if (value == "true") {
 					input.setAttribute("checked", "");
 				}
 			});
 			this.doc.querySelectorAll("textarea").forEach(textarea => {
-				const value = textarea.getAttribute(docUtil.INPUT_VALUE_ATTRIBUTE_NAME);
+				const value = textarea.getAttribute(util.INPUT_VALUE_ATTRIBUTE_NAME);
 				textarea.textContent = value || "";
 			});
 			this.doc.querySelectorAll("select").forEach(select => {
 				select.querySelectorAll("option").forEach(option => {
-					const selected = option.getAttribute(docUtil.INPUT_VALUE_ATTRIBUTE_NAME) != null;
+					const selected = option.getAttribute(util.INPUT_VALUE_ATTRIBUTE_NAME) != null;
 					if (selected) {
 						option.setAttribute("selected", "");
 					}
@@ -713,7 +713,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		replaceCanvasElements() {
 			if (this.options.canvasData) {
 				this.doc.querySelectorAll("canvas").forEach(canvasElement => {
-					const canvasIndex = Number(canvasElement.getAttribute(docUtil.CANVAS_ATTRIBUTE_NAME));
+					const canvasIndex = Number(canvasElement.getAttribute(util.CANVAS_ATTRIBUTE_NAME));
 					const canvasData = this.options.canvasData[canvasIndex];
 					if (canvasData) {
 						ProcessorHelper.setBackgroundImage(canvasElement, "url(" + canvasData.dataURI + ")");
@@ -753,7 +753,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		}
 
 		removeHiddenElements() {
-			const hiddenElements = this.doc.querySelectorAll("[" + docUtil.REMOVED_CONTENT_ATTRIBUTE_NAME + "]");
+			const hiddenElements = this.doc.querySelectorAll("[" + util.REMOVED_CONTENT_ATTRIBUTE_NAME + "]");
 			this.stats.set("discarded", "hidden elements", hiddenElements.length);
 			this.stats.set("processed", "hidden elements", hiddenElements.length);
 			hiddenElements.forEach(element => element.remove());
@@ -765,7 +765,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				if (!Util.testIgnoredPath(href)) {
 					let resolvedURL;
 					try {
-						resolvedURL = docUtil.resolveURL(href, this.options.baseURI || this.options.url);
+						resolvedURL = util.resolveURL(href, this.options.baseURI || this.options.url);
 					} catch (error) {
 						// ignored
 					}
@@ -787,7 +787,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			this.doc.querySelectorAll("[style]").forEach(element => {
 				let styleContent = element.getAttribute("style");
 				if (this.options.compressCSS) {
-					styleContent = docUtil.compressCSS(styleContent);
+					styleContent = util.compressCSS(styleContent);
 				}
 				styleContent = ProcessorHelper.resolveStylesheetURLs(styleContent, this.baseURI);
 				const declarationList = cssTree.parse(styleContent, { context: "declarationList" });
@@ -844,7 +844,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 						frameElement.removeAttribute("src");
 						frameElement.removeAttribute("srcdoc");
 					}
-					const frameWindowId = frameElement.getAttribute(docUtil.WIN_ID_ATTRIBUTE_NAME);
+					const frameWindowId = frameElement.getAttribute(util.WIN_ID_ATTRIBUTE_NAME);
 					if (frameWindowId) {
 						const frameData = this.options.framesData.find(frame => frame.windowId == frameWindowId);
 						if (frameData) {
@@ -890,14 +890,14 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			}
 
 			function processElement(element) {
-				const shadowRootElements = Array.from((element.querySelectorAll("[" + docUtil.SHADOW_ROOT_ATTRIBUTE_NAME + "]")));
+				const shadowRootElements = Array.from((element.querySelectorAll("[" + util.SHADOW_ROOT_ATTRIBUTE_NAME + "]")));
 				shadowRootElements.forEach(element => {
-					const id = element.getAttribute(docUtil.SHADOW_ROOT_ATTRIBUTE_NAME);
+					const id = element.getAttribute(util.SHADOW_ROOT_ATTRIBUTE_NAME);
 					const shadowRootData = options.shadowRootsData[Number(id)];
 					if (shadowRootData) {
 						const templateElement = doc.createElement("template");
 						templateElement.setAttribute(WC_ATTRIBUTE_NAME, "");
-						const shadowDoc = docUtil.parseDocContent(shadowRootData.content);
+						const shadowDoc = util.parseDocContent(shadowRootData.content);
 						if (shadowDoc.head) {
 							const metaCharset = shadowDoc.head.querySelector("meta[charset]");
 							if (metaCharset) {
@@ -944,19 +944,19 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 
 		removeUnusedStyles() {
 			if (!this.mediaAllInfo) {
-				this.mediaAllInfo = docUtil.getMediaAllInfo(this.doc, this.stylesheets, this.styles);
+				this.mediaAllInfo = util.getMediaAllInfo(this.doc, this.stylesheets, this.styles);
 			}
-			const stats = docUtil.minifyCSSRules(this.stylesheets, this.styles, this.mediaAllInfo);
+			const stats = util.minifyCSSRules(this.stylesheets, this.styles, this.mediaAllInfo);
 			this.stats.set("processed", "CSS rules", stats.processed);
 			this.stats.set("discarded", "CSS rules", stats.discarded);
 		}
 
 		removeUnusedFonts() {
-			docUtil.removeUnusedFonts(this.doc, this.stylesheets, this.styles, this.options);
+			util.removeUnusedFonts(this.doc, this.stylesheets, this.styles, this.options);
 		}
 
 		removeAlternativeMedias() {
-			const stats = docUtil.minifyMedias(this.stylesheets);
+			const stats = util.minifyMedias(this.stylesheets);
 			this.stats.set("processed", "medias", stats.processed);
 			this.stats.set("discarded", "medias", stats.discarded);
 		}
@@ -1007,31 +1007,31 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				scriptElement.removeAttribute("src");
 				scriptElement.textContent = "";
 				try {
-					resourceURL = docUtil.resolveURL(scriptSrc, this.baseURI);
+					resourceURL = util.resolveURL(scriptSrc, this.baseURI);
 				} catch (error) {
 					// ignored
 				}
 				if (Util.testValidURL(resourceURL)) {
 					this.stats.add("processed", "scripts", 1);
-					const content = await docUtil.getContent(resourceURL, { asDataURI: true, maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled });
+					const content = await util.getContent(resourceURL, { asDataURI: true, maxResourceSize: this.options.maxResourceSize, maxResourceSizeEnabled: this.options.maxResourceSizeEnabled });
 					scriptElement.setAttribute("src", content.data);
 				}
 			}));
 		}
 
 		removeAlternativeImages() {
-			docUtil.removeAlternativeImages(this.doc);
+			util.removeAlternativeImages(this.doc);
 		}
 
 		removeAlternativeFonts() {
-			docUtil.removeAlternativeFonts(this.doc, this.stylesheets);
+			util.removeAlternativeFonts(this.doc, this.stylesheets);
 		}
 
 		async processFrames() {
 			if (this.options.framesData) {
 				const frameElements = Array.from(this.doc.querySelectorAll("iframe, frame, object[type=\"text/html\"][data]"));
 				await Promise.all(frameElements.map(async frameElement => {
-					const frameWindowId = frameElement.getAttribute(docUtil.WIN_ID_ATTRIBUTE_NAME);
+					const frameWindowId = frameElement.getAttribute(util.WIN_ID_ATTRIBUTE_NAME);
 					if (frameWindowId) {
 						const frameData = this.options.framesData.find(frame => frame.windowId == frameWindowId);
 						if (frameData) {
@@ -1040,7 +1040,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 								this.stats.add("processed", "frames", 1);
 								await frameData.processor.run();
 								const pageData = await frameData.processor.getPageData();
-								frameElement.removeAttribute(docUtil.WIN_ID_ATTRIBUTE_NAME);
+								frameElement.removeAttribute(util.WIN_ID_ATTRIBUTE_NAME);
 								let sandbox = "allow-popups allow-top-navigation allow-top-navigation-by-user-activation";
 								if (pageData.content.match(NOSCRIPT_TAG_FOUND) || pageData.content.match(SCRIPT_TAG_FOUND)) {
 									sandbox += " allow-scripts allow-same-origin";
@@ -1150,11 +1150,11 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		compressHTML() {
 			let size;
 			if (this.options.displayStats) {
-				size = docUtil.getContentSize(this.doc.documentElement.outerHTML);
+				size = util.getContentSize(this.doc.documentElement.outerHTML);
 			}
-			docUtil.minifyHTML(this.doc, { PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME: docUtil.PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME });
+			util.minifyHTML(this.doc, { PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME: util.PRESERVED_SPACE_ELEMENT_ATTRIBUTE_NAME });
 			if (this.options.displayStats) {
-				this.stats.add("discarded", "HTML bytes", size - docUtil.getContentSize(this.doc.documentElement.outerHTML));
+				this.stats.add("discarded", "HTML bytes", size - util.getContentSize(this.doc.documentElement.outerHTML));
 			}
 		}
 	}
@@ -1176,7 +1176,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 	class ProcessorHelper {
 		static async evalTemplate(template = "", options, content, dontReplaceSlash) {
 			const date = options.saveDate;
-			const url = docUtil.parseURL(options.saveUrl);
+			const url = util.parseURL(options.saveUrl);
 			template = await Util.evalTemplateVariable(template, "page-title", () => options.title || "No title", dontReplaceSlash);
 			template = await Util.evalTemplateVariable(template, "page-language", () => options.info.lang || "No language", dontReplaceSlash);
 			template = await Util.evalTemplateVariable(template, "page-description", () => options.info.description || "No description", dontReplaceSlash);
@@ -1222,9 +1222,9 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			template = await Util.evalTemplateVariable(template, "tab-index", () => String(options.tabIndex || "No tab index"), dontReplaceSlash);
 			template = await Util.evalTemplateVariable(template, "url-last-segment", () => decodeURI(Util.getLastSegment(url)) || "No last segment", dontReplaceSlash);
 			if (content) {
-				template = await Util.evalTemplateVariable(template, "digest-sha-256", async () => docUtil.digest("SHA-256", content), dontReplaceSlash);
-				template = await Util.evalTemplateVariable(template, "digest-sha-384", async () => docUtil.digest("SHA-384", content), dontReplaceSlash);
-				template = await Util.evalTemplateVariable(template, "digest-sha-512", async () => docUtil.digest("SHA-512", content), dontReplaceSlash);
+				template = await Util.evalTemplateVariable(template, "digest-sha-256", async () => util.digest("SHA-256", content), dontReplaceSlash);
+				template = await Util.evalTemplateVariable(template, "digest-sha-384", async () => util.digest("SHA-384", content), dontReplaceSlash);
+				template = await Util.evalTemplateVariable(template, "digest-sha-512", async () => util.digest("SHA-512", content), dontReplaceSlash);
 			}
 			return template.trim();
 		}
@@ -1277,17 +1277,17 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 					let resourceURL = Util.normalizeURL(match.resourceURL);
 					if (!Util.testIgnoredPath(resourceURL) && Util.testValidPath(resourceURL)) {
 						try {
-							resourceURL = docUtil.resolveURL(match.resourceURL, baseURI);
+							resourceURL = util.resolveURL(match.resourceURL, baseURI);
 						} catch (error) {
 							// ignored
 						}
 						if (Util.testValidURL(resourceURL)) {
 							const downloadOptions = { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, validateTextContentType: true };
-							const content = await docUtil.getContent(resourceURL, downloadOptions);
+							const content = await util.getContent(resourceURL, downloadOptions);
 							resourceURL = content.resourceURL;
 							let importedStylesheetContent = Util.removeCssComments(content.data);
 							if (options.compressCSS) {
-								importedStylesheetContent = docUtil.compressCSS(importedStylesheetContent);
+								importedStylesheetContent = util.compressCSS(importedStylesheetContent);
 							}
 							importedStylesheetContent = Util.wrapMediaQuery(importedStylesheetContent, match.media);
 							if (stylesheetContent.includes(cssImport)) {
@@ -1315,7 +1315,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 					if (!resourceURL || Util.testValidPath(resourceURL)) {
 						let resolvedURL;
 						try {
-							resolvedURL = docUtil.resolveURL(resourceURL, baseURI);
+							resolvedURL = util.resolveURL(resourceURL, baseURI);
 						} catch (error) {
 							// ignored
 						}
@@ -1347,11 +1347,11 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			resourceURL = Util.normalizeURL(resourceURL);
 			if (resourceURL && resourceURL != baseURI && resourceURL != ABOUT_BLANK_URI) {
 				const downloadOptions = { asDataURI: false, maxResourceSize: options.maxResourceSize, maxResourceSizeEnabled: options.maxResourceSizeEnabled, charset: options.charset };
-				const content = await docUtil.getContent(resourceURL, downloadOptions);
+				const content = await util.getContent(resourceURL, downloadOptions);
 				resourceURL = content.resourceURL;
 				let stylesheetContent = Util.removeCssComments(content.data);
 				if (options.compressCSS) {
-					stylesheetContent = docUtil.compressCSS(stylesheetContent);
+					stylesheetContent = util.compressCSS(stylesheetContent);
 				}
 				stylesheetContent = await ProcessorHelper.resolveImportURLs(stylesheetContent, resourceURL, options, workStylesheet);
 				return stylesheetContent;
@@ -1389,7 +1389,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 								if (Util.testValidURL(resourceURL)) {
 									let { content } = await batchRequest.addURL(resourceURL, true);
 									if (content != EMPTY_DATA_URI && !content.startsWith(PREFIX_DATA_URI_VND) && !content.startsWith(PREFIX_DATA_URI_IMAGE_SVG)) {
-										const validResource = await docUtil.validFont(urlFunction);
+										const validResource = await util.validFont(urlFunction);
 										if (!validResource) {
 											content = EMPTY_DATA_URI;
 										}
@@ -1397,7 +1397,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 									replaceURLs(declaration, originalResourceURL, content);
 								}
 							} else if (resourceURL.startsWith(DATA_URI_PREFIX) && !resourceURL.startsWith(PREFIX_DATA_URI_VND) && !resourceURL.startsWith(PREFIX_DATA_URI_IMAGE_SVG)) {
-								const validResource = await docUtil.validFont(urlFunction);
+								const validResource = await util.validFont(urlFunction);
 								if (!validResource) {
 									replaceURLs(declaration, originalResourceURL, EMPTY_DATA_URI);
 								}
@@ -1408,7 +1408,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 
 				function replaceURLs(declaration, oldURL, newURL) {
 					declaration.value.children.forEach(token => {
-						if (token.type == "Url" && docUtil.removeQuotes(Util.getCSSValue(token.value)) == oldURL) {
+						if (token.type == "Url" && util.removeQuotes(Util.getCSSValue(token.value)) == oldURL) {
 							token.value.value = newURL;
 						}
 					});
@@ -1452,7 +1452,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 					if (token.data.children) {
 						findURLToken(url, token.data.children, callback, depth + 1);
 					}
-					if (token.data.type == "Url" && docUtil.removeQuotes(Util.getCSSValue(token.data.value)) == url) {
+					if (token.data.type == "Url" && util.removeQuotes(Util.getCSSValue(token.data.value)) == url) {
 						callback(token, children, depth == 0);
 					}
 				}
@@ -1467,7 +1467,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 					resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
 					if (Util.testValidPath(resourceURL)) {
 						try {
-							resourceURL = docUtil.resolveURL(resourceURL, baseURI);
+							resourceURL = util.resolveURL(resourceURL, baseURI);
 						} catch (error) {
 							// ignored
 						}
@@ -1506,7 +1506,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				if (Util.testValidPath(resourceURL) && !Util.testIgnoredPath(resourceURL)) {
 					resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
 					try {
-						resourceURL = docUtil.resolveURL(resourceURL, baseURI);
+						resourceURL = util.resolveURL(resourceURL, baseURI);
 					} catch (error) {
 						// ignored
 					}
@@ -1515,7 +1515,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 							const { content } = await batchRequest.addURL(resourceURL);
 							const hashMatch = originalResourceURL.match(REGEXP_URL_HASH);
 							if (hashMatch && hashMatch[0]) {
-								const svgDoc = docUtil.parseSVGContent(content);
+								const svgDoc = util.parseSVGContent(content);
 								const symbolElement = svgDoc.querySelector(hashMatch[0]);
 								if (symbolElement) {
 									resourceElement.setAttribute(attributeName, hashMatch[0]);
@@ -1536,13 +1536,13 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 
 		static async processSrcset(resourceElements, attributeName, baseURI, batchRequest) {
 			await Promise.all(Array.from(resourceElements).map(async resourceElement => {
-				const srcset = docUtil.parseSrcset(resourceElement.getAttribute(attributeName));
+				const srcset = util.parseSrcset(resourceElement.getAttribute(attributeName));
 				const srcsetValues = await Promise.all(srcset.map(async srcsetValue => {
 					let resourceURL = Util.normalizeURL(srcsetValue.url);
 					if (!Util.testIgnoredPath(resourceURL)) {
 						if (Util.testValidPath(resourceURL)) {
 							try {
-								resourceURL = docUtil.resolveURL(resourceURL, baseURI);
+								resourceURL = util.resolveURL(resourceURL, baseURI);
 							} catch (error) {
 								// ignored
 							}
@@ -1568,7 +1568,7 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 		}
 
 		static replaceImageSource(imgElement, variableName, options) {
-			const dataAttributeName = docUtil.IMAGE_ATTRIBUTE_NAME;
+			const dataAttributeName = util.IMAGE_ATTRIBUTE_NAME;
 			if (imgElement.getAttribute(dataAttributeName) != null) {
 				const imgData = options.imagesData[Number(imgElement.getAttribute(dataAttributeName))];
 				if (imgData.replaceable) {