Kaynağa Gözat

store Runner instances into "runner" properties

Gildas 6 yıl önce
ebeveyn
işleme
3368b381b0
1 değiştirilmiş dosya ile 18 ekleme ve 14 silme
  1. 18 14
      lib/single-file/single-file-core.js

+ 18 - 14
lib/single-file/single-file-core.js

@@ -201,6 +201,10 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 			return this.processor.doc;
 		}
 
+		getStyleSheets() {
+			return this.processor.stylesheets;
+		}
+
 		async getPageData() {
 			if (this.root) {
 				this.onprogress(new ProgressEvent(PAGE_ENDED, { pageURL: this.options.url }));
@@ -891,10 +895,10 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 					options.usedFonts = frameData.usedFonts;
 					options.shadowRoots = frameData.shadowRoots;
 					options.imports = frameData.imports;
-					frameData.processor = new Runner(options);
+					frameData.runner = new Runner(options);
 					frameData.frameElement = frameElement;
-					await frameData.processor.loadPage();
-					await frameData.processor.initialize();
+					await frameData.runner.loadPage();
+					await frameData.runner.initialize();
 					frameData.maxResources = batchRequest.getMaxResources();
 				}
 			}
@@ -962,13 +966,13 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 					const importData = options.imports[Number(attributeValue)];
 					if (importData) {
 						options.content = importData.content;
-						importData.processor = new Runner(options);
-						await importData.processor.loadPage();
-						await importData.processor.initialize();
+						importData.runner = new Runner(options);
+						await importData.runner.loadPage();
+						await importData.runner.initialize();
 						if (!options.removeImports) {
-							importData.maxResources = importData.processor.batchRequest.getMaxResources();
+							importData.maxResources = importData.runner.batchRequest.getMaxResources();
 						}
-						importData.processor.processor.stylesheets.forEach(stylesheet => {
+						importData.runner.getStyleSheets().forEach(stylesheet => {
 							const importedStyleElement = this.doc.createElement("style");
 							linkElement.insertAdjacentElement("afterEnd", importedStyleElement);
 							this.stylesheets.set(importedStyleElement, stylesheet);
@@ -1075,10 +1079,10 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 						const frameData = this.options.frames.find(frame => frame.windowId == frameWindowId);
 						if (frameData) {
 							this.options.frames = this.options.frames.filter(frame => frame.windowId != frameWindowId);
-							if (frameData.processor) {
+							if (frameData.runner) {
 								this.stats.add("processed", "frames", 1);
-								await frameData.processor.run();
-								const pageData = await frameData.processor.getPageData();
+								await frameData.runner.run();
+								const pageData = await frameData.runner.getPageData();
 								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)) {
@@ -1111,10 +1115,10 @@ this.singlefile.lib.core = this.singlefile.lib.core || (() => {
 				const attributeValue = linkElement.getAttribute(util.HTML_IMPORT_ATTRIBUTE_NAME);
 				if (attributeValue) {
 					const importData = this.options.imports[Number(attributeValue)];
-					if (importData.processor) {
+					if (importData.runner) {
 						this.stats.add("processed", "HTML imports", 1);
-						await importData.processor.run();
-						const pageData = await importData.processor.getPageData();
+						await importData.runner.run();
+						const pageData = await importData.runner.getPageData();
 						linkElement.removeAttribute(util.HTML_IMPORT_ATTRIBUTE_NAME);
 						linkElement.setAttribute("href", "data:text/html," + pageData.content);
 						this.stats.addAll(pageData);