From bf4d0719aad61e9c159e7459764319fc1d1ae527 Mon Sep 17 00:00:00 2001 From: KonghaYao <20192831006@m.scnu.edu.cn> Date: Mon, 2 Aug 2021 21:45:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(madge):=20madge=20=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=97=B6=E9=9C=80=E8=A6=81=20alias=20=E7=9A=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=EF=BC=8C=E6=89=80=E4=BB=A5=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=20webpack.config.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FakeServer/ajax/XMLHttpRequest/constant.js | 5 + .../XMLHttpRequest/defineGetterAndSetter.js | 5 + FakeServer/ajax/XMLHttpRequest/xhr.js | 5 + FakeServer/ajax/fetch/fetch.js | 5 + FakeServer/ajax/fetch/src/INTERNALS.js | 5 + FakeServer/ajax/fetch/src/body.js | 44 +- FakeServer/ajax/fetch/src/body/consumeBody.js | 8 +- .../ajax/fetch/src/body/exactContentType.js | 21 +- FakeServer/ajax/fetch/src/response.js | 22 +- .../ajax/fetch/src/utils/is-redirect.js | 11 +- FakeServer/ajax/index.js | 6 +- FakeServer/fakeServer.js | 5 + FakeServer/src/Route.js | 5 + FakeServer/src/Server.js | 5 + docs/assets/dependencies.drawio | 6 +- docs/assets/dependencies.svg | 1016 +++++++++-------- jspider.drawio | 139 ++- package.json | 12 +- rollup.config.build.js | 8 +- script/webpack.config.js | 20 + src/ControlPanel/ControlPanel.js | 2 +- src/{ControlPanel => Mirror}/TaskManager.js | 2 +- src/Spider/index.js | 3 +- 23 files changed, 713 insertions(+), 647 deletions(-) create mode 100644 script/webpack.config.js rename src/{ControlPanel => Mirror}/TaskManager.js (96%) diff --git a/FakeServer/ajax/XMLHttpRequest/constant.js b/FakeServer/ajax/XMLHttpRequest/constant.js index e408ffa..f943a83 100644 --- a/FakeServer/ajax/XMLHttpRequest/constant.js +++ b/FakeServer/ajax/XMLHttpRequest/constant.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 + */ export default { 100: 'Continue', 101: 'Switching Protocols', diff --git a/FakeServer/ajax/XMLHttpRequest/defineGetterAndSetter.js b/FakeServer/ajax/XMLHttpRequest/defineGetterAndSetter.js index 3c5749d..93d9350 100644 --- a/FakeServer/ajax/XMLHttpRequest/defineGetterAndSetter.js +++ b/FakeServer/ajax/XMLHttpRequest/defineGetterAndSetter.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 + */ // 不可以在原生的 XMLHttpRequest 上直接定义 getter 和 setter, // 也不可以在 XHR 实例上定义 // 这样的话会导致无法接收到数据 diff --git a/FakeServer/ajax/XMLHttpRequest/xhr.js b/FakeServer/ajax/XMLHttpRequest/xhr.js index 0ad60bc..87946af 100644 --- a/FakeServer/ajax/XMLHttpRequest/xhr.js +++ b/FakeServer/ajax/XMLHttpRequest/xhr.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 + */ // 使用不完全覆盖的方式,使用继承方式继承所有的属性 // 只在 send 方式调用的时候对其进行数据返回 import { pick } from 'lodash-es'; diff --git a/FakeServer/ajax/fetch/fetch.js b/FakeServer/ajax/fetch/fetch.js index 40b9f2c..0f92040 100644 --- a/FakeServer/ajax/fetch/fetch.js +++ b/FakeServer/ajax/fetch/fetch.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 + */ const config = { proxy: null, silent: false }; let realFetch; diff --git a/FakeServer/ajax/fetch/src/INTERNALS.js b/FakeServer/ajax/fetch/src/INTERNALS.js index 88cf295..30d17e6 100644 --- a/FakeServer/ajax/fetch/src/INTERNALS.js +++ b/FakeServer/ajax/fetch/src/INTERNALS.js @@ -1,2 +1,7 @@ +/** + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 + */ export const BODY = Symbol('Body internals'); export const RESPONSE = Symbol('Response internals'); diff --git a/FakeServer/ajax/fetch/src/body.js b/FakeServer/ajax/fetch/src/body.js index 16bfd94..eeec69d 100644 --- a/FakeServer/ajax/fetch/src/body.js +++ b/FakeServer/ajax/fetch/src/body.js @@ -1,22 +1,13 @@ /** - * Body.js - * - * Body interface provides common methods for Request and Response + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 */ - import { isURLSearchParameters } from './utils/is.js'; import { BODY as INTERNALS } from './INTERNALS.js'; import { consumeBody } from './body/consumeBody.js'; -/** - * Body mixin - * - * Ref: https://fetch.spec.whatwg.org/#body - * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void - */ + export default class Body { constructor(body, { size = 0 } = {}) { if (body === null) { @@ -49,53 +40,26 @@ export default class Body { return this[INTERNALS].disturbed; } - /** - * Decode response as ArrayBuffer - * - * @return Promise - */ async arrayBuffer() { const blob = await consumeBody(this[INTERNALS]); return blob.arrayBuffer(); } - /** - * Return raw response as Blob - * - * @return Promise - */ async blob() { return consumeBody(this[INTERNALS]); } - /** - * Decode response as json - * - * @return Promise - */ async json() { const text = await this.text(); return JSON.parse(text || '{}'); } - /** - * Decode response as text - * - * @return Promise - */ async text() { const blob = await consumeBody(this[INTERNALS]); return blob.text(); } - - /** - * Decode response as buffer (non-spec api) - * - * @return Promise - */ } -// In browsers, all properties are enumerable. Object.defineProperties(Body.prototype, { body: { enumerable: true }, bodyUsed: { enumerable: true }, diff --git a/FakeServer/ajax/fetch/src/body/consumeBody.js b/FakeServer/ajax/fetch/src/body/consumeBody.js index 2e4fe00..2dd6962 100644 --- a/FakeServer/ajax/fetch/src/body/consumeBody.js +++ b/FakeServer/ajax/fetch/src/body/consumeBody.js @@ -1,9 +1,7 @@ /** - * Consume and convert an entire Body to a Buffer. - * - * Ref: https://fetch.spec.whatwg.org/#concept-body-consume-body - * - * @return Promise + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 */ export async function consumeBody(data) { // 标记为已经使用 diff --git a/FakeServer/ajax/fetch/src/body/exactContentType.js b/FakeServer/ajax/fetch/src/body/exactContentType.js index 802875d..29d7482 100644 --- a/FakeServer/ajax/fetch/src/body/exactContentType.js +++ b/FakeServer/ajax/fetch/src/body/exactContentType.js @@ -1,32 +1,22 @@ -import { isURLSearchParameters } from '../utils/is.js'; -import { BODY as INTERNALS } from '../INTERNALS'; /** - * Performs the operation "extract a `Content-Type` value from |object|" as - * specified in the specification: - * https://fetch.spec.whatwg.org/#concept-bodyinit-extract - * - * This function assumes that instance.body is present. - * - * @param {any} body Any options.body input - * @return {string | null} + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 */ +import { isURLSearchParameters } from '../utils/is.js'; +import { BODY as INTERNALS } from '../INTERNALS'; export const extractContentType = (body, request) => { - // Body is null or undefined if (body === null) { return null; } - // Body is string if (typeof body === 'string') { return 'text/plain;charset=UTF-8'; } - // Body is a URLSearchParams if (isURLSearchParameters(body)) { return 'application/x-www-form-urlencoded;charset=UTF-8'; } - - // Body is blob if (body instanceof Blob) { return body.type || null; } @@ -35,6 +25,5 @@ export const extractContentType = (body, request) => { return `multipart/form-data; boundary=${request[INTERNALS].boundary}`; } - // Body constructor defaults other things to string return 'text/plain;charset=UTF-8'; }; diff --git a/FakeServer/ajax/fetch/src/response.js b/FakeServer/ajax/fetch/src/response.js index 1f04f47..504f2f7 100644 --- a/FakeServer/ajax/fetch/src/response.js +++ b/FakeServer/ajax/fetch/src/response.js @@ -1,7 +1,7 @@ /** - * Response.js - * - * Response class provides content decoding + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 */ import Body from './body.js'; @@ -9,13 +9,6 @@ import { extractContentType } from './body/exactContentType.js'; import { isRedirect } from './utils/is-redirect.js'; import { RESPONSE as INTERNALS } from './INTERNALS.js'; const Response = (globalThis.window && globalThis.window.Response) || class Null {}; -/** - * Response class - * - * @param Stream body Readable stream - * @param Object opts Response options - * @return Void - */ export default class fakeResponse extends Body { constructor(body = null, options = {}) { super(body, options); @@ -48,10 +41,6 @@ export default class fakeResponse extends Body { get status() { return this[INTERNALS].status; } - - /** - * Convenience property representing if the request ended normally - */ get ok() { return this[INTERNALS].status >= 200 && this[INTERNALS].status < 300; } @@ -90,11 +79,6 @@ export default class fakeResponse extends Body { }); } - /** - * @param {string} url The URL that the new response is to originate from. - * @param {number} status An optional status code for the response (e.g., 302.) - * @return {Response} A Response object. - */ static redirect(url, status = 302) { if (!isRedirect(status)) { throw new RangeError('Failed to execute "redirect" on "response": Invalid status code'); diff --git a/FakeServer/ajax/fetch/src/utils/is-redirect.js b/FakeServer/ajax/fetch/src/utils/is-redirect.js index 1ffb222..6c68d1d 100644 --- a/FakeServer/ajax/fetch/src/utils/is-redirect.js +++ b/FakeServer/ajax/fetch/src/utils/is-redirect.js @@ -1,11 +1,10 @@ -const redirectStatus = new Set([301, 302, 303, 307, 308]); - /** - * Redirect code matching - * - * @param {number} code - Status code - * @return {boolean} + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 */ +const redirectStatus = new Set([301, 302, 303, 307, 308]); + export const isRedirect = (code) => { return redirectStatus.has(code); }; diff --git a/FakeServer/ajax/index.js b/FakeServer/ajax/index.js index 5f2ca80..bea5c74 100644 --- a/FakeServer/ajax/index.js +++ b/FakeServer/ajax/index.js @@ -1,4 +1,8 @@ +/** + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 + */ // 在 fetch 的代理中只需要进行 fetch 的数据代理即可 -// export { mockFetch } from './fetch/fetch.js'; export { mockXHR } from './XMLHttpRequest/xhr.js'; diff --git a/FakeServer/fakeServer.js b/FakeServer/fakeServer.js index 7ab50e5..dc4dcc4 100644 --- a/FakeServer/fakeServer.js +++ b/FakeServer/fakeServer.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 + */ import { match } from 'path-to-regexp'; import { Request, Response } from './src/Server.js'; import { Route, RouteMap } from './src/Route.js'; diff --git a/FakeServer/src/Route.js b/FakeServer/src/Route.js index 6eea73b..89aff2a 100644 --- a/FakeServer/src/Route.js +++ b/FakeServer/src/Route.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 + */ // 每一个 Route 只有一个 main 函数进行数据的返回 export class Route { constructor({ matcher, name, path, callback, redirect = '' }) { diff --git a/FakeServer/src/Server.js b/FakeServer/src/Server.js index 2dcbb35..c15f5dd 100644 --- a/FakeServer/src/Server.js +++ b/FakeServer/src/Server.js @@ -1,3 +1,8 @@ +/** + * @license + * Copyright 2021 KonghaYao 江夏尧 + * SPDX-License-Identifier: Apache-2.0 + */ import { parseURL } from './parseURL.js'; export class Request { constructor(path, options) { diff --git a/docs/assets/dependencies.drawio b/docs/assets/dependencies.drawio index 7931fed..bfc326b 100644 --- a/docs/assets/dependencies.drawio +++ b/docs/assets/dependencies.drawio @@ -1,11 +1,11 @@ - + - + - + diff --git a/docs/assets/dependencies.svg b/docs/assets/dependencies.svg index e046ba2..d3b3ee1 100644 --- a/docs/assets/dependencies.svg +++ b/docs/assets/dependencies.svg @@ -4,688 +4,718 @@ - - + + G - - + + -ControlPanel/ControlPanel.js - -ControlPanel/ControlPanel.js +FakeServer/src/parseURL.js + +FakeServer/src/parseURL.js - + -ControlPanel/StaticEvent.js - -ControlPanel/StaticEvent.js - - - -ControlPanel/ControlPanel.js->ControlPanel/StaticEvent.js - - +index.js + +index.js - + -ControlPanel/TaskManager.js - -ControlPanel/TaskManager.js +plugins/index.js + +plugins/index.js - - -ControlPanel/ControlPanel.js->ControlPanel/TaskManager.js - - + + +index.js->plugins/index.js + + - + -utils/EventHub.js - -utils/EventHub.js +src/Pipeline/PluginSystem.js + +src/Pipeline/PluginSystem.js - - -ControlPanel/ControlPanel.js->utils/EventHub.js - - + + +index.js->src/Pipeline/PluginSystem.js + + - + -utils/functionQueue.js - -utils/functionQueue.js +src/Spider/index.js + +src/Spider/index.js - - -ControlPanel/ControlPanel.js->utils/functionQueue.js - - + + +index.js->src/Spider/index.js + + - + -utils/pauseToggle.js - -utils/pauseToggle.js - - - -ControlPanel/ControlPanel.js->utils/pauseToggle.js - - - - - -TaskSystem/TaskGroup.js - -TaskSystem/TaskGroup.js - - - -ControlPanel/StaticEvent.js->TaskSystem/TaskGroup.js - - - - - -TaskSystem/Task.js - -TaskSystem/Task.js - - - -ControlPanel/TaskManager.js->TaskSystem/Task.js - - - - - -TaskSystem/TaskGroup.js->TaskSystem/Task.js - - - - - -TaskSystem/Task.js->utils/EventHub.js - - - - - -TaskSystem/Data.js - -TaskSystem/Data.js - - - -TaskSystem/Task.js->TaskSystem/Data.js - - - - - -TaskSystem/StaticEvent.js - -TaskSystem/StaticEvent.js - - - -TaskSystem/Task.js->TaskSystem/StaticEvent.js - - - - - -ControlPanel/index.js - -ControlPanel/index.js - - - -ControlPanel/index.js->ControlPanel/ControlPanel.js - - - - - -Errors/errors.js - -Errors/errors.js - - - -Pipeline/PluginSystem.js - -Pipeline/PluginSystem.js - - - -Pipeline/PluginSystem.js->Errors/errors.js - - - - - -utils/createUUID.js - -utils/createUUID.js - - - -Pipeline/PluginSystem.js->utils/createUUID.js - - - - - -Pipeline/index.js - -Pipeline/index.js - - - -Pipeline/index.js->utils/functionQueue.js - - - - - -Pipeline/index.js->utils/createUUID.js - - - - - -Spider/index.js - -Spider/index.js - - - -Spider/index.js->utils/EventHub.js - - - - - -Spider/index.js->ControlPanel/index.js - - - - - -Spider/index.js->Pipeline/index.js - - - - - -Spider/staticEvent.js - -Spider/staticEvent.js - - - -Spider/index.js->Spider/staticEvent.js - - - - - -TaskSystem/index.js - -TaskSystem/index.js - - - -TaskSystem/index.js->TaskSystem/TaskGroup.js - - - - - -TaskSystem/index.js->TaskSystem/Task.js - - - - - -index.js - -index.js - - - -index.js->Pipeline/PluginSystem.js - - - - - -index.js->Spider/index.js - - - - - -index.js->TaskSystem/index.js - - - - - -plugins/index.js - -plugins/index.js +src/TaskSystem/index.js + +src/TaskSystem/index.js - - -index.js->plugins/index.js - - + + +index.js->src/TaskSystem/index.js + + - + tools/index.js - -tools/index.js + +tools/index.js - + index.js->tools/index.js - - + + - + plugins/Download.js - -plugins/Download.js + +plugins/Download.js - + plugins/index.js->plugins/Download.js - - + + - + plugins/ExcelHelper.js - -plugins/ExcelHelper.js + +plugins/ExcelHelper.js - + plugins/index.js->plugins/ExcelHelper.js - - + + - + plugins/Request.js - -plugins/Request.js + +plugins/Request.js - + plugins/index.js->plugins/Request.js - - + + - + plugins/zipFile.js - -plugins/zipFile.js + +plugins/zipFile.js - + plugins/index.js->plugins/zipFile.js - - + + - + +src/Errors/errors.js + +src/Errors/errors.js + + + +src/Pipeline/PluginSystem.js->src/Errors/errors.js + + + + + +src/utils/createUUID.js + +src/utils/createUUID.js + + + +src/Pipeline/PluginSystem.js->src/utils/createUUID.js + + + + + +src/ControlPanel/index.js + +src/ControlPanel/index.js + + + +src/Spider/index.js->src/ControlPanel/index.js + + + + + +src/Mirror/Mirror.js + +src/Mirror/Mirror.js + + + +src/Spider/index.js->src/Mirror/Mirror.js + + + + + +src/Pipeline/index.js + +src/Pipeline/index.js + + + +src/Spider/index.js->src/Pipeline/index.js + + + + + +src/TaskSystem/TaskGroup.js + +src/TaskSystem/TaskGroup.js + + + +src/TaskSystem/index.js->src/TaskSystem/TaskGroup.js + + + + + +src/TaskSystem/Task.js + +src/TaskSystem/Task.js + + + +src/TaskSystem/index.js->src/TaskSystem/Task.js + + + + + +tools/index.js->FakeServer/src/parseURL.js + + + + + tools/loader/loader.js - -tools/loader/loader.js + +tools/loader/loader.js - + tools/index.js->tools/loader/loader.js - - + + - + tools/Mock/Mock.js - -tools/Mock/Mock.js + +tools/Mock/Mock.js - + tools/index.js->tools/Mock/Mock.js - - + + - + tools/analysis/index.js - -tools/analysis/index.js + +tools/analysis/index.js - + tools/index.js->tools/analysis/index.js - - + + - - -plugins/Download.js->Pipeline/PluginSystem.js - - + + +plugins/Download.js->src/Pipeline/PluginSystem.js + + - + plugins/utils/toFile.js - -plugins/utils/toFile.js + +plugins/utils/toFile.js - + plugins/Download.js->plugins/utils/toFile.js - - + + - - -plugins/ExcelHelper.js->Pipeline/PluginSystem.js - - + + +plugins/ExcelHelper.js->src/Pipeline/PluginSystem.js + + - + plugins/ExcelHelper/createExcelFile.js - -plugins/ExcelHelper/createExcelFile.js + +plugins/ExcelHelper/createExcelFile.js - + plugins/ExcelHelper.js->plugins/ExcelHelper/createExcelFile.js - - + + - + plugins/ExcelHelper/xlsx.js - -plugins/ExcelHelper/xlsx.js + +plugins/ExcelHelper/xlsx.js - + plugins/ExcelHelper.js->plugins/ExcelHelper/xlsx.js - - + + - + plugins/ExcelHelper/createExcelFile.js->plugins/ExcelHelper/xlsx.js - - + + - + plugins/ExcelHelper/xlsx.js->tools/loader/loader.js - - + + - - -utils/type.js - -utils/type.js + + +src/utils/type.js + +src/utils/type.js - - -tools/loader/loader.js->utils/type.js - - + + +tools/loader/loader.js->src/utils/type.js + + - + tools/loader/jsDelivr.js - -tools/loader/jsDelivr.js + +tools/loader/jsDelivr.js - + tools/loader/loader.js->tools/loader/jsDelivr.js - - + + - + tools/loader/loaderFunction.js - -tools/loader/loaderFunction.js + +tools/loader/loaderFunction.js - + tools/loader/loader.js->tools/loader/loaderFunction.js - - + + - + tools/loader/scriptStore.js - -tools/loader/scriptStore.js + +tools/loader/scriptStore.js - + tools/loader/loader.js->tools/loader/scriptStore.js - - + + - + plugins/JSzip/JSzip.js - -plugins/JSzip/JSzip.js + +plugins/JSzip/JSzip.js - + plugins/JSzip/JSzip.js->tools/loader/loader.js - - + + - + plugins/JSzip/zipper.js - -plugins/JSzip/zipper.js + +plugins/JSzip/zipper.js - + plugins/JSzip/zipper.js->plugins/JSzip/JSzip.js - - + + - - -plugins/Request.js->Pipeline/PluginSystem.js - - - - - -utils/concurrent.js - -utils/concurrent.js + + +plugins/Request.js->src/Pipeline/PluginSystem.js + + - - -plugins/Request.js->utils/concurrent.js - - + + +src/utils/concurrent.js + +src/utils/concurrent.js - - -utils/retryAndDelay.js - -utils/retryAndDelay.js + + +plugins/Request.js->src/utils/concurrent.js + + - - -utils/concurrent.js->utils/retryAndDelay.js - - + + +src/utils/retryAndDelay.js + +src/utils/retryAndDelay.js - - -plugins/zipFile.js->TaskSystem/TaskGroup.js - - + + +src/utils/concurrent.js->src/utils/retryAndDelay.js + + - - -plugins/zipFile.js->Pipeline/PluginSystem.js - - + + +plugins/zipFile.js->src/Pipeline/PluginSystem.js + + - + plugins/zipFile.js->plugins/utils/toFile.js - - + + - + plugins/zipFile.js->plugins/JSzip/JSzip.js - - + + - + plugins/zipFile.js->plugins/JSzip/zipper.js - - + + + + + +plugins/zipFile.js->src/TaskSystem/TaskGroup.js + + + + + +src/TaskSystem/TaskGroup.js->src/TaskSystem/Task.js + + + + + +src/ControlPanel/ControlPanel.js + +src/ControlPanel/ControlPanel.js + + + +src/ControlPanel/StaticEvent.js + +src/ControlPanel/StaticEvent.js + + + +src/ControlPanel/ControlPanel.js->src/ControlPanel/StaticEvent.js + + + + + +src/Mirror/TaskManager.js + +src/Mirror/TaskManager.js + + + +src/ControlPanel/ControlPanel.js->src/Mirror/TaskManager.js + + + + + +src/utils/EventHub.js + +src/utils/EventHub.js + + + +src/ControlPanel/ControlPanel.js->src/utils/EventHub.js + + + + + +src/utils/functionQueue.js + +src/utils/functionQueue.js + + + +src/ControlPanel/ControlPanel.js->src/utils/functionQueue.js + + + + + +src/utils/pauseToggle.js + +src/utils/pauseToggle.js + + + +src/ControlPanel/ControlPanel.js->src/utils/pauseToggle.js + + + + + +src/ControlPanel/StaticEvent.js->src/TaskSystem/TaskGroup.js + + + + + +src/Mirror/TaskManager.js->src/Mirror/Mirror.js + + + + + +src/Mirror/TaskManager.js->src/TaskSystem/Task.js + + + + + +src/ControlPanel/index.js->src/ControlPanel/ControlPanel.js + + + + + +src/Mirror/Mirror.js->src/utils/EventHub.js + + + + + +src/TaskSystem/Task.js->src/utils/EventHub.js + + + + + +src/TaskSystem/TaskState.js + +src/TaskSystem/TaskState.js + + + +src/TaskSystem/Task.js->src/TaskSystem/TaskState.js + + + + + +src/Pipeline/index.js->src/utils/functionQueue.js + + + + + +src/Pipeline/index.js->src/utils/createUUID.js + + + + + +src/TaskSystem/TaskProps.js + +src/TaskSystem/TaskProps.js + + + +src/TaskSystem/TaskState.js->src/TaskSystem/TaskProps.js + + + + + +src/TaskSystem/TaskTypes.js + +src/TaskSystem/TaskTypes.js + + + +src/TaskSystem/TaskState.js->src/TaskSystem/TaskTypes.js + + + + + +src/utils/retryAndDelay.js->src/Errors/errors.js + + - + tools/Mock/Mock.js->tools/loader/loader.js - - + + - + tools/Mock/Server/index.js - -tools/Mock/Server/index.js + +tools/Mock/Server/index.js - + tools/Mock/Mock.js->tools/Mock/Server/index.js - - + + - + tools/Mock/Server/excel.js - -tools/Mock/Server/excel.js + +tools/Mock/Server/excel.js - + tools/Mock/Server/index.js->tools/Mock/Server/excel.js - - + + - + tools/analysis/Search/GlobalVars.js - -tools/analysis/Search/GlobalVars.js + +tools/analysis/Search/GlobalVars.js - + tools/analysis/Search/window-default.json - -tools/analysis/Search/window-default.json + +tools/analysis/Search/window-default.json - + tools/analysis/Search/GlobalVars.js->tools/analysis/Search/window-default.json - - + + - + tools/analysis/Search/Search.js - -tools/analysis/Search/Search.js + +tools/analysis/Search/Search.js - + tools/analysis/Search/searchObj.js - -tools/analysis/Search/searchObj.js + +tools/analysis/Search/searchObj.js - + tools/analysis/Search/Search.js->tools/analysis/Search/searchObj.js - - + + - - -tools/analysis/Search/searchObj.js->utils/type.js - - + + +tools/analysis/Search/searchObj.js->src/utils/type.js + + - + tools/analysis/antiDebugger.js - -tools/analysis/antiDebugger.js + +tools/analysis/antiDebugger.js - + tools/analysis/copy.js - -tools/analysis/copy.js + +tools/analysis/copy.js - + tools/analysis/index.js->tools/analysis/Search/GlobalVars.js - - + + - + tools/analysis/index.js->tools/analysis/Search/Search.js - - + + - + tools/analysis/index.js->tools/analysis/antiDebugger.js - - + + - + tools/analysis/index.js->tools/analysis/copy.js - - - - - -utils/retryAndDelay.js->Errors/errors.js - - + + diff --git a/jspider.drawio b/jspider.drawio index b7f8ea6..dbb438c 100644 --- a/jspider.drawio +++ b/jspider.drawio @@ -1,14 +1,17 @@ - + - - + + + + + - + @@ -28,81 +31,66 @@ - + + - + + - - + - - - - - - - - - - - - - - - - - - - - - + + - - - - - + + + + + + + + - - + + - + - + - + - + - + - + - + - + - + @@ -110,28 +98,61 @@ - + - + - + - + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + @@ -142,7 +163,7 @@ - + diff --git a/package.json b/package.json index b9c9165..4f9da3b 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "lint": "eslint src plugins FakeServer tools", "Lint": "npm run Prettier && npm run lint", "Prettier": "prettier -w FakeServer/**/*.{ts,json,md,yml,js} plugins/**/*.{ts,json,md,yml,js} src/**/*.{ts,json,md,yml,js} tools/**/*.{ts,json,md,yml,js} docs/**/*.md", - "graph": "madge --image docs/assets/dependencies.svg src/index.js", + "graph": "madge --image docs/assets/dependencies.svg ./index.js", "release": "standard-version", "lint-staged": "lint-staged", "commitlint": "commitlint --config commitlint.config.js -e -V", @@ -31,6 +31,16 @@ "browser", "front-end" ], + "madge": { + "webpackConfig": "./script/webpack.config.js", + "fileExtensions": [ + "js", + "jsx", + "ts", + "tsx", + "json" + ] + }, "husky": { "hooks": { "pre-commit": "lint-staged", diff --git a/rollup.config.build.js b/rollup.config.build.js index 237bf85..5d1b6de 100644 --- a/rollup.config.build.js +++ b/rollup.config.build.js @@ -18,13 +18,19 @@ const plugins = [ }), replace({ preventAssignment: true, - values: { __version__: JSON.stringify(CONFIG.version), __buildDate__: new Date().getTime() }, + values: { + __version__: JSON.stringify(CONFIG.version), + __buildDate__: new Date().getTime(), + 'process.env.NODE_ENV': JSON.stringify(env), + }, }), json(), resolve({ + jsnext: true, browser: true, }), commonjs(), // 将 CommonJS 转换成 ES2015 模块供 Rollup 处理 + terser(), license({ banner: { diff --git a/script/webpack.config.js b/script/webpack.config.js new file mode 100644 index 0000000..217c61c --- /dev/null +++ b/script/webpack.config.js @@ -0,0 +1,20 @@ +const path = require('path'); +const resolve = (dir) => path.resolve(__dirname, dir); +// ! 这个文件并非是 webpack 的打包文件,只是因为 madge 生成代码依赖图的时候需要进行 alias 的声明 + +module.exports = { + entry: '../main.js', + output: { + filename: 'bundle.js', + path: './dist', + }, + resolve: { + // 设置别名 + alias: { + '@tools': resolve('../tools'), + '@src': resolve('../src'), + '@plugins': resolve('../plugins'), + '@FakeServer': resolve('../FakeServer'), + }, + }, +}; diff --git a/src/ControlPanel/ControlPanel.js b/src/ControlPanel/ControlPanel.js index 74cabff..f507800 100644 --- a/src/ControlPanel/ControlPanel.js +++ b/src/ControlPanel/ControlPanel.js @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ import staticEvent from './StaticEvent'; -import { TaskManager } from './TaskManager'; +import { TaskManager } from '../Mirror/TaskManager'; import { functionQueue } from '../utils/functionQueue'; import { EventHub } from '../utils/EventHub'; import { pauseToggle } from '../utils/pauseToggle'; diff --git a/src/ControlPanel/TaskManager.js b/src/Mirror/TaskManager.js similarity index 96% rename from src/ControlPanel/TaskManager.js rename to src/Mirror/TaskManager.js index 5fa0561..e551531 100644 --- a/src/ControlPanel/TaskManager.js +++ b/src/Mirror/TaskManager.js @@ -5,7 +5,7 @@ */ /* eslint-disable no-invalid-this */ import { Task } from '../TaskSystem/Task'; -import { MessageHub } from '../Mirror/Mirror.js'; +import { MessageHub } from './Mirror.js'; // ! 用于维护全局 Task 数据的中心 export class TaskManager { diff --git a/src/Spider/index.js b/src/Spider/index.js index 58cf547..2222e9c 100644 --- a/src/Spider/index.js +++ b/src/Spider/index.js @@ -21,10 +21,11 @@ export class Spider { this.config = { logEvery, }; - if (logEvery) + if (logEvery) { TaskUpdate.subscribe((data) => { console.log(data); }); + } } crawl(...args) { ControlPanel.createFlow(args.flat());