فهرست منبع

moved all lib files into lib/single-file

Former-commit-id: c6ffb730bafe8827271517d6a8703c3fd4566a12
Gildas 6 سال پیش
والد
کامیت
df80714daf

+ 7 - 7
cli/back-ends/common/scripts.js

@@ -26,10 +26,10 @@
 const fs = require("fs");
 
 const SCRIPTS = [
-	"/lib/hooks/content/content-hooks.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/processors/hooks/content/content-hooks.js",
+	"/lib/single-file/processors/hooks/content/content-hooks-frames.js",
+	"/lib/single-file/processors/frame-tree/content/content-frame-tree.js",
+	"/lib/single-file/processors/lazy/content/content-lazy-loader.js",
 	"/lib/single-file/single-file-util.js",
 	"/lib/single-file/single-file-helper.js",
 	"/lib/single-file/vendor/css-tree.js",
@@ -51,13 +51,13 @@ const SCRIPTS = [
 ];
 
 const INDEX_SCRIPTS = [
-	"/lib/index.js",
+	"/lib/single-file/index.js",
 	"/common/index.js"
 ];
 
 const WEB_SCRIPTS = [
-	"/lib/hooks/content/content-hooks-web.js",
-	"/lib/hooks/content/content-hooks-frames-web.js",
+	"/lib/single-file/processors/hooks/content/content-hooks-web.js",
+	"/lib/single-file/processors/hooks/content/content-hooks-frames-web.js",
 	"/common/ui/content/content-infobar-web.js"
 ];
 

+ 4 - 4
extension/core/content/content-bootstrap.js

@@ -75,8 +75,8 @@ this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.cor
 			} else {
 				let frames = [];
 				autoSaveTimeout = null;
-				if (!options.removeFrames && singlefile.lib.frameTree.content.frames && window.frames && window.frames.length) {
-					frames = await singlefile.lib.frameTree.content.frames.getAsync(options);
+				if (!options.removeFrames && singlefile.lib.processors.frameTree.content.frames && window.frames && window.frames.length) {
+					frames = await singlefile.lib.processors.frameTree.content.frames.getAsync(options);
 				}
 				if (options.userScriptEnabled && helper.waitForUserScript) {
 					await helper.waitForUserScript(helper.ON_BEFORE_CAPTURE_EVENT_NAME);
@@ -111,8 +111,8 @@ this.singlefile.extension.core.content.bootstrap = this.singlefile.extension.cor
 		const helper = singlefile.lib.helper;
 		if (!pageAutoSaved || options.autoSaveUnload) {
 			let frames = [];
-			if (!options.removeFrames && singlefile.lib.frameTree.content.frames && window.frames && window.frames.length) {
-				frames = singlefile.lib.frameTree.content.frames.getSync(options);
+			if (!options.removeFrames && singlefile.lib.processors.frameTree.content.frames && window.frames && window.frames.length) {
+				frames = singlefile.lib.processors.frameTree.content.frames.getSync(options);
 			}
 			if (options.userScriptEnabled && helper.waitForUserScript) {
 				helper.waitForUserScript(helper.ON_BEFORE_CAPTURE_EVENT_NAME);

+ 2 - 2
extension/core/content/content-main.js

@@ -93,7 +93,7 @@ this.singlefile.extension.core.content.main = this.singlefile.extension.core.con
 	}
 
 	async function processPage(options) {
-		const frames = singlefile.lib.frameTree.content.frames;
+		const frames = singlefile.lib.processors.frameTree.content.frames;
 		singlefile.lib.helper.initDoc(document);
 		ui.onStartPage(options);
 		processor = new singlefile.lib.SingleFile(options);
@@ -116,7 +116,7 @@ this.singlefile.extension.core.content.main = this.singlefile.extension.core.con
 				preInitializationPromises.push(frameTreePromise);
 			}
 			if (options.loadDeferredImages) {
-				const lazyLoadPromise = singlefile.lib.lazy.content.loader.process(options);
+				const lazyLoadPromise = singlefile.lib.processors.lazy.content.loader.process(options);
 				ui.onLoadingDeferResources(options);
 				lazyLoadPromise.then(() => {
 					if (!processor.cancelled) {

+ 6 - 6
extension/lib/core/bg/scripts.js

@@ -28,7 +28,7 @@ singlefile.extension.lib.core.bg.scripts = (() => {
 	let contentScript, frameScript;
 
 	const contentScriptFiles = [
-		"lib/index.js",
+		"lib/single-file/index.js",
 		"lib/single-file/vendor/css-font-property-parser.js",
 		"lib/single-file/vendor/css-media-query-parser.js",
 		"lib/single-file/vendor/css-tree.js",
@@ -46,18 +46,18 @@ singlefile.extension.lib.core.bg.scripts = (() => {
 		"lib/single-file/single-file-helper.js",
 		"lib/single-file/single-file-core.js",
 		"lib/single-file/single-file.js",
-		"lib/lazy/content/content-lazy-loader.js",
-		"lib/hooks/content/content-hooks.js",
+		"lib/single-file/processors/lazy/content/content-lazy-loader.js",
+		"lib/single-file/processors/hooks/content/content-hooks.js",
 		"extension/index.js",
 		"extension/lib/browser-polyfill/chrome-browser-polyfill.js",
 		"extension/lib/fetch/content/content-fetch.js",
 	];
 
 	const frameScriptFiles = [
-		"lib/index.js",
-		"lib/hooks/content/content-hooks-frames.js",
+		"lib/single-file/index.js",
 		"lib/single-file/single-file-helper.js",
-		"lib/frame-tree/content/content-frame-tree.js",
+		"lib/single-file/processors/hooks/content/content-hooks-frames.js",
+		"lib/single-file/processors/frame-tree/content/content-frame-tree.js",
 		"extension/index.js",
 		"extension/lib/browser-polyfill/chrome-browser-polyfill.js",
 		"extension/lib/fetch/content/content-fetch.js"

+ 12 - 10
lib/index.js → lib/single-file/index.js

@@ -25,14 +25,16 @@
 
 this.singlefile = this.singlefile || {
 	lib: {
-		frameTree: {
-			content: {}
-		},
-		hooks: {
-			content: {}
-		},
-		lazy: {
-			content: {}
+		processors: {
+			frameTree: {
+				content: {}
+			},
+			hooks: {
+				content: {}
+			},
+			lazy: {
+				content: {}
+			}
 		},
 		vendor: {},
 		modules: {},
@@ -43,10 +45,10 @@ this.singlefile = this.singlefile || {
 				const preInitializationPromises = [];
 				if (!options.saveRawPage) {
 					if (!options.removeFrames) {
-						preInitializationPromises.push(this.frameTree.content.frames.getAsync(options));
+						preInitializationPromises.push(this.processors.frameTree.content.frames.getAsync(options));
 					}
 					if (options.loadDeferredImages) {
-						preInitializationPromises.push(this.lazy.content.loader.process(options));
+						preInitializationPromises.push(this.processors.lazy.content.loader.process(options));
 					}
 				}
 				[options.frames] = await Promise.all(preInitializationPromises);

+ 4 - 4
lib/frame-tree/content/content-frame-tree.js → lib/single-file/processors/frame-tree/content/content-frame-tree.js

@@ -23,7 +23,7 @@
 
 /* global window */
 
-this.singlefile.lib.frameTree.content.frames = this.singlefile.lib.frameTree.content.frames || (() => {
+this.singlefile.lib.processors.frameTree.content.frames = this.singlefile.lib.processors.frameTree.content.frames || (() => {
 
 	const singlefile = this.singlefile;
 
@@ -67,8 +67,8 @@ 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();
-				if (message.options.loadDeferredImages && singlefile.lib.lazy.content.loader) {
-					singlefile.lib.lazy.content.loader.process(message.options);
+				if (message.options.loadDeferredImages && singlefile.lib.processors.lazy.content.loader) {
+					singlefile.lib.processors.lazy.content.loader.process(message.options);
 				}
 				await initRequestAsync(message);
 			} else if (message.method == CLEANUP_REQUEST_MESSAGE) {
@@ -270,7 +270,7 @@ this.singlefile.lib.frameTree.content.frames = this.singlefile.lib.frameTree.con
 	function sendInitResponse(message) {
 		message.method = INIT_RESPONSE_MESSAGE;
 		try {
-			top.singlefile.lib.frameTree.content.frames.initResponse(message);
+			top.singlefile.lib.processors.frameTree.content.frames.initResponse(message);
 		} catch (error) {
 			sendMessage(top, message, true);
 		}

+ 0 - 0
lib/hooks/content/content-hooks-frames-web.js → lib/single-file/processors/hooks/content/content-hooks-frames-web.js


+ 3 - 3
lib/hooks/content/content-hooks-frames.js → lib/single-file/processors/hooks/content/content-hooks-frames.js

@@ -23,7 +23,7 @@
 
 /* global window */
 
-this.singlefile.lib.hooks.content.frames = this.singlefile.lib.hooks.content.frames || (() => {
+this.singlefile.lib.processors.hooks.content.frames = this.singlefile.lib.processors.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";
@@ -47,10 +47,10 @@ this.singlefile.lib.hooks.content.frames = this.singlefile.lib.hooks.content.fra
 	if (document instanceof HTMLDocument) {
 		let scriptElement = document.createElement("script");
 		if (browser && browser.runtime && browser.runtime.getURL) {
-			scriptElement.src = browser.runtime.getURL("/lib/hooks/content/content-hooks-frames-web.js");
+			scriptElement.src = browser.runtime.getURL("/lib/single-file/processors/hooks/content/content-hooks-frames-web.js");
 			scriptElement.async = false;
 		} else if (this.singlefile.lib.getFileContent) {
-			scriptElement.textContent = this.singlefile.lib.getFileContent("/lib/hooks/content/content-hooks-frames-web.js");
+			scriptElement.textContent = this.singlefile.lib.getFileContent("/lib/single-file/processors/hooks/content/content-hooks-frames-web.js");
 		}
 		(document.documentElement || document).appendChild(scriptElement);
 		scriptElement.remove();

+ 0 - 0
lib/hooks/content/content-hooks-web.js → lib/single-file/processors/hooks/content/content-hooks-web.js


+ 3 - 3
lib/hooks/content/content-hooks.js → lib/single-file/processors/hooks/content/content-hooks.js

@@ -23,7 +23,7 @@
 
 /* global window */
 
-this.singlefile.lib.hooks.content.main = this.singlefile.lib.hooks.content.main || (() => {
+this.singlefile.lib.processors.hooks.content.main = this.singlefile.lib.processors.hooks.content.main || (() => {
 
 	const browser = this.browser;
 	const document = window.document;	
@@ -33,10 +33,10 @@ this.singlefile.lib.hooks.content.main = this.singlefile.lib.hooks.content.main
 		const scriptElement = document.createElement("script");
 		scriptElement.async = false;
 		if (browser && browser.runtime && browser.runtime.getURL) {
-			scriptElement.src = browser.runtime.getURL("/lib/hooks/content/content-hooks-web.js");
+			scriptElement.src = browser.runtime.getURL("/lib/single-file/processors/hooks/content/content-hooks-web.js");
 			scriptElement.async = false;
 		} else if (this.singlefile.lib.getFileContent) {
-			scriptElement.textContent = this.singlefile.lib.getFileContent("/lib/hooks/content/content-hooks-web.js");
+			scriptElement.textContent = this.singlefile.lib.getFileContent("/lib/single-file/processors/hooks/content/content-hooks-web.js");
 		}
 		(document.documentElement || document).appendChild(scriptElement);
 		scriptElement.remove();

+ 4 - 4
lib/lazy/content/content-lazy-loader.js → lib/single-file/processors/lazy/content/content-lazy-loader.js

@@ -23,7 +23,7 @@
 
 /* global window, scrollY, scrollX */
 
-this.singlefile.lib.lazy.content.loader = this.singlefile.lib.lazy.content.loader || (() => {
+this.singlefile.lib.processors.lazy.content.loader = this.singlefile.lib.processors.lazy.content.loader || (() => {
 
 	const ATTRIBUTES_MUTATION_TYPE = "attributes";
 	const SINGLE_FILE_UI_ELEMENT_CLASS = "single-file-ui-element";
@@ -50,7 +50,7 @@ this.singlefile.lib.lazy.content.loader = this.singlefile.lib.lazy.content.loade
 	};
 
 	function process(options) {
-		const frames = singlefile.lib.hooks.content.frames;
+		const frames = singlefile.lib.processors.hooks.content.frames;
 		return new Promise(async resolve => {
 			let timeoutId, idleTimeoutId, maxTimeoutId, loadingImages;
 			const pendingImages = new Set();
@@ -128,8 +128,8 @@ this.singlefile.lib.lazy.content.loader = this.singlefile.lib.lazy.content.loade
 
 	function lazyLoadEnd(idleTimeoutId, observer, options, resolve) {
 		clearAsyncTimeout(idleTimeoutId);
-		if (singlefile.lib.hooks.content.frames) {
-			singlefile.lib.hooks.content.frames.loadDeferredImagesEnd(options);
+		if (singlefile.lib.processors.hooks.content.frames) {
+			singlefile.lib.processors.hooks.content.frames.loadDeferredImagesEnd(options);
 		}
 		setAsyncTimeout(resolve, 100);
 		observer.disconnect();

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

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

+ 8 - 8
manifest.json

@@ -17,12 +17,12 @@
 			],
 			"run_at": "document_start",
 			"js": [
-				"lib/index.js",
+				"lib/single-file/index.js",
 				"extension/index.js",
 				"extension/lib/browser-polyfill/chrome-browser-polyfill.js",
-				"lib/hooks/content/content-hooks-frames.js",
 				"lib/single-file/single-file-helper.js",
-				"lib/frame-tree/content/content-frame-tree.js"
+				"lib/single-file/processors/hooks/content/content-hooks-frames.js",
+				"lib/single-file/processors/frame-tree/content/content-frame-tree.js"
 			],
 			"all_frames": true,
 			"match_about_blank": true
@@ -41,8 +41,8 @@
 			],
 			"run_at": "document_start",
 			"js": [
-				"lib/index.js",
-				"lib/hooks/content/content-hooks.js",
+				"lib/single-file/index.js",
+				"lib/single-file/processors/hooks/content/content-hooks.js",
 				"extension/index.js",
 				"extension/core/content/content-bootstrap.js"
 			]
@@ -50,7 +50,7 @@
 	],
 	"background": {
 		"scripts": [
-			"lib/index.js",
+			"lib/single-file/index.js",
 			"extension/index.js",
 			"extension/lib/browser-polyfill/chrome-browser-polyfill.js",
 			"lib/single-file/vendor/css-minifier.js",
@@ -129,8 +129,8 @@
 		}
 	},
 	"web_accessible_resources": [
-		"lib/hooks/content/content-hooks-web.js",
-		"lib/hooks/content/content-hooks-frames-web.js",
+		"lib/single-file/processors/hooks/content/content-hooks-web.js",
+		"lib/single-file/processors/hooks/content/content-hooks-frames-web.js",
 		"common/ui/content/content-infobar-web.js"
 	],
 	"permissions": [