Pārlūkot izejas kodu

renamed content-hooks-frames and updated namespace

Gildas 6 gadi atpakaļ
vecāks
revīzija
1fdd44d899

+ 1 - 1
cli/back-ends/puppeteer.js

@@ -29,7 +29,7 @@ const puppeteer = require("puppeteer-core");
 
 const SCRIPTS = [
 	"../../index.js",
-	"../../lib/hooks/content/content-hooks-frame.js",
+	"../../lib/hooks/content/content-hooks-frames.js",
 	"../../lib/frame-tree/content/content-frame-tree.js",
 	"../../lib/lazy/content/content-lazy-loader.js",
 	"../../lib/single-file/single-file-util.js",

+ 1 - 1
cli/back-ends/webdriver-chromium.js

@@ -31,7 +31,7 @@ const { Builder } = require("selenium-webdriver");
 
 const SCRIPTS = [
 	"../../index.js",
-	"../../lib/hooks/content/content-hooks-frame.js",
+	"../../lib/hooks/content/content-hooks-frames.js",
 	"../../lib/frame-tree/content/content-frame-tree.js",
 	"../../lib/lazy/content/content-lazy-loader.js",
 	"../../lib/single-file/single-file-util.js",

+ 1 - 1
cli/back-ends/webdriver-gecko.js

@@ -31,7 +31,7 @@ const { Builder, By, Key } = require("selenium-webdriver");
 
 const SCRIPTS = [
 	"../../index.js",
-	"../../lib/hooks/content/content-hooks-frame.js",
+	"../../lib/hooks/content/content-hooks-frames.js",
 	"../../lib/frame-tree/content/content-frame-tree.js",
 	"../../lib/lazy/content/content-lazy-loader.js",
 	"../../lib/single-file/single-file-util.js",

+ 1 - 1
extension/core/bg/business.js

@@ -44,7 +44,7 @@ singlefile.extension.core.bg.business = (() => {
 
 	const frameScriptFiles = [
 		"/index.js",
-		"/lib/hooks/content/content-hooks-frame.js",
+		"/lib/hooks/content/content-hooks-frames.js",
 		"/lib/browser-polyfill/chrome-browser-polyfill.js",
 		"/lib/single-file/single-file-helper.js",
 		"/lib/fetch/content/content-fetch-resources.js",

+ 1 - 1
lib/frame-tree/content/content-frame-tree.js

@@ -59,10 +59,10 @@ this.singlefile.lib.frameTree.content.frames = this.singlefile.lib.frameTree.con
 			const message = JSON.parse(event.data.substring(MESSAGE_PREFIX.length));
 			if (!TOP_WINDOW && message.method == INIT_REQUEST_MESSAGE) {
 				window.stop();
-				initRequest(message);
 				if (message.options.loadDeferredImages && singlefile.lib.lazy.content.loader) {
 					singlefile.lib.lazy.content.loader.process(message.options);
 				}
+				initRequest(message);
 			} else if (message.method == CLEANUP_REQUEST_MESSAGE) {
 				cleanupRequest(message);
 			} else if (!browser.runtime && message.method == INIT_RESPONSE_MESSAGE) {

+ 1 - 1
lib/hooks/content/content-hooks-frame.js → lib/hooks/content/content-hooks-frames.js

@@ -23,7 +23,7 @@
 
 /* global browser, window, addEventListener, dispatchEvent, CustomEvent, document, HTMLDocument, FileReader, Blob */
 
-this.singlefile.lib.hooks.content.frame = this.singlefile.lib.hooks.content.frame || (() => {
+this.singlefile.lib.hooks.content.frames = this.singlefile.lib.hooks.content.frames || (() => {
 
 	const LOAD_DEFERRED_IMAGES_START_EVENT = "single-file-load-deferred-images-start";
 	const LOAD_DEFERRED_IMAGES_END_EVENT = "single-file-load-deferred-images-end";

+ 9 - 9
lib/lazy/content/content-lazy-loader.js

@@ -44,7 +44,7 @@ this.singlefile.lib.lazy.content.loader = this.singlefile.lib.lazy.content.loade
 	};
 
 	function process(options) {
-		const hooksFrame = singlefile.lib.hooks.content.frame;
+		const frames = singlefile.lib.hooks.content.frames;
 		return new Promise(async resolve => {
 			let timeoutId, idleTimeoutId, maxTimeoutId, loadingImages;
 			const pendingImages = new Set();
@@ -76,10 +76,10 @@ this.singlefile.lib.lazy.content.loader = this.singlefile.lib.lazy.content.loade
 			}, options.loadDeferredImagesMaxIdleTime * 1.2);
 			maxTimeoutId = await deferForceLazyLoadEnd(timeoutId, idleTimeoutId, maxTimeoutId, observer, options, cleanupAndResolve);
 			observer.observe(document, { subtree: true, childList: true, attributes: true });
-			addEventListener(hooksFrame.LOAD_IMAGE_EVENT, onImageLoadEvent);
-			addEventListener(hooksFrame.IMAGE_LOADED_EVENT, onImageLoadedEvent);
-			if (typeof hooksFrame != "undefined") {
-				hooksFrame.loadDeferredImagesStart();
+			addEventListener(frames.LOAD_IMAGE_EVENT, onImageLoadEvent);
+			addEventListener(frames.IMAGE_LOADED_EVENT, onImageLoadedEvent);
+			if (frames) {
+				frames.loadDeferredImagesStart();
 			}
 
 			async function onImageLoadEvent(event) {
@@ -100,8 +100,8 @@ this.singlefile.lib.lazy.content.loader = this.singlefile.lib.lazy.content.loade
 
 			function cleanupAndResolve(value) {
 				observer.disconnect();
-				removeEventListener(hooksFrame.LOAD_IMAGE_EVENT, onImageLoadEvent);
-				removeEventListener(hooksFrame.IMAGE_LOADED_EVENT, onImageLoadedEvent);
+				removeEventListener(frames.LOAD_IMAGE_EVENT, onImageLoadEvent);
+				removeEventListener(frames.IMAGE_LOADED_EVENT, onImageLoadedEvent);
 				resolve(value);
 			}
 		});
@@ -122,8 +122,8 @@ this.singlefile.lib.lazy.content.loader = this.singlefile.lib.lazy.content.loade
 
 	function lazyLoadEnd(idleTimeoutId, observer, resolve) {
 		clearAsyncTimeout(idleTimeoutId);
-		if (typeof hooksFrame != "undefined") {
-			singlefile.lib.hooks.content.frame.loadDeferredImagesEnd();
+		if (singlefile.lib.hooks.content.frames) {
+			singlefile.lib.hooks.content.frames.loadDeferredImagesEnd();
 		}
 		setAsyncTimeout(resolve, 100);
 		observer.disconnect();

+ 2 - 2
lib/single-file/single-file-helper.js

@@ -324,8 +324,8 @@ this.singlefile.lib.helper = this.singlefile.lib.helper || (() => {
 	}
 
 	function getFontsData() {
-		if (singlefile.lib.hooks.content.frame) {
-			return singlefile.lib.hooks.content.frame.getFontsData();
+		if (singlefile.lib.hooks.content.frames) {
+			return singlefile.lib.hooks.content.frames.getFontsData();
 		}
 	}
 

+ 1 - 1
maff2html/back-ends/webdriver-gecko.js

@@ -31,7 +31,7 @@ const { Builder, By, Key } = require("selenium-webdriver");
 
 const SCRIPTS = [
 	"../../index.js",
-	"../../lib/hooks/content/content-hooks-frame.js",
+	"../../lib/hooks/content/content-hooks-frames.js",
 	"../../lib/frame-tree/content/content-frame-tree.js",
 	"../../lib/lazy/content/content-lazy-loader.js",
 	"../../lib/single-file/single-file-util.js",

+ 1 - 1
manifest.json

@@ -19,7 +19,7 @@
 			"js": [
 				"index.js",
 				"lib/browser-polyfill/chrome-browser-polyfill.js",
-				"lib/hooks/content/content-hooks-frame.js",
+				"lib/hooks/content/content-hooks-frames.js",
 				"lib/single-file/single-file-util.js",
 				"lib/single-file/single-file-helper.js",
 				"lib/frame-tree/content/content-frame-tree.js"