@d-zero/archaeologist 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analize-url.d.ts +4 -0
- package/dist/analize-url.js +4 -0
- package/dist/analyze.d.ts +5 -0
- package/dist/analyze.js +9 -0
- package/dist/archaeologist.d.ts +5 -0
- package/dist/archaeologist.js +5 -0
- package/dist/diff-images.d.ts +9 -3
- package/dist/diff-images.js +12 -0
- package/dist/diff-tree.d.ts +7 -0
- package/dist/diff-tree.js +7 -0
- package/dist/freeze.d.ts +13 -0
- package/dist/freeze.js +34 -0
- package/dist/get-data.d.ts +7 -0
- package/dist/get-data.js +7 -0
- package/dist/output-utils.d.ts +5 -0
- package/dist/output-utils.js +5 -0
- package/dist/read-config.d.ts +4 -0
- package/dist/read-config.js +4 -0
- package/dist/utils.d.ts +5 -0
- package/dist/utils.js +5 -0
- package/package.json +10 -10
- package/dist/diff-tree-color.d.ts +0 -1
- package/dist/diff-tree-color.js +0 -15
- package/dist/read-hooks.d.ts +0 -2
- package/dist/read-hooks.js +0 -20
package/dist/analize-url.d.ts
CHANGED
package/dist/analize-url.js
CHANGED
package/dist/analyze.d.ts
CHANGED
package/dist/analyze.js
CHANGED
|
@@ -7,6 +7,11 @@ import { diffImages } from './diff-images.js';
|
|
|
7
7
|
import { diffTree } from './diff-tree.js';
|
|
8
8
|
import { getData } from './get-data.js';
|
|
9
9
|
import { score } from './output-utils.js';
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param list
|
|
13
|
+
* @param options
|
|
14
|
+
*/
|
|
10
15
|
export async function analyze(list, options) {
|
|
11
16
|
const results = [];
|
|
12
17
|
const dir = path.resolve(process.cwd(), '.archaeologist');
|
|
@@ -97,6 +102,10 @@ export async function analyze(list, options) {
|
|
|
97
102
|
});
|
|
98
103
|
return results;
|
|
99
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @param ms
|
|
108
|
+
*/
|
|
100
109
|
function delay(ms) {
|
|
101
110
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
102
111
|
}
|
package/dist/archaeologist.d.ts
CHANGED
|
@@ -2,4 +2,9 @@ import type { AnalyzeOptions } from './analyze.js';
|
|
|
2
2
|
import type { URLPair } from './types.js';
|
|
3
3
|
export interface ArchaeologistOptions extends AnalyzeOptions {
|
|
4
4
|
}
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param list
|
|
8
|
+
* @param options
|
|
9
|
+
*/
|
|
5
10
|
export declare function archaeologist(list: readonly URLPair[], options?: ArchaeologistOptions): Promise<void>;
|
package/dist/archaeologist.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import c from 'ansi-colors';
|
|
2
2
|
import { analyze } from './analyze.js';
|
|
3
3
|
import { score } from './output-utils.js';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param list
|
|
7
|
+
* @param options
|
|
8
|
+
*/
|
|
4
9
|
export async function archaeologist(list, options) {
|
|
5
10
|
const results = await analyze(list, options);
|
|
6
11
|
const output = [];
|
package/dist/diff-images.d.ts
CHANGED
|
@@ -16,12 +16,18 @@ export type DiffImagesPhase = {
|
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
18
|
type DiffImagesListener = (phase: keyof DiffImagesPhase, data: DiffImagesPhase[keyof DiffImagesPhase]) => void;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param dataA
|
|
22
|
+
* @param dataB
|
|
23
|
+
* @param listener
|
|
24
|
+
*/
|
|
19
25
|
export declare function diffImages(dataA: Screenshot, dataB: Screenshot, listener: DiffImagesListener): Promise<{
|
|
20
26
|
matches: number;
|
|
21
27
|
images: {
|
|
22
|
-
a: Buffer
|
|
23
|
-
b: Buffer
|
|
24
|
-
diff: Buffer
|
|
28
|
+
a: Buffer<ArrayBufferLike>;
|
|
29
|
+
b: Buffer<ArrayBufferLike>;
|
|
30
|
+
diff: Buffer<ArrayBufferLike>;
|
|
25
31
|
};
|
|
26
32
|
} | null>;
|
|
27
33
|
export {};
|
package/dist/diff-images.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { Jimp, HorizontalAlign, VerticalAlign, JimpMime } from 'jimp';
|
|
2
2
|
import pixelmatch from 'pixelmatch';
|
|
3
3
|
import { PNG } from 'pngjs';
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param dataA
|
|
7
|
+
* @param dataB
|
|
8
|
+
* @param listener
|
|
9
|
+
*/
|
|
4
10
|
export async function diffImages(dataA, dataB, listener) {
|
|
5
11
|
if (!dataA.binary || !dataB.binary) {
|
|
6
12
|
return null;
|
|
@@ -31,6 +37,12 @@ export async function diffImages(dataA, dataB, listener) {
|
|
|
31
37
|
},
|
|
32
38
|
};
|
|
33
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param bin
|
|
43
|
+
* @param width
|
|
44
|
+
* @param height
|
|
45
|
+
*/
|
|
34
46
|
async function resizeImg(bin, width, height) {
|
|
35
47
|
const img = await Jimp.read(bin);
|
|
36
48
|
img.contain({
|
package/dist/diff-tree.d.ts
CHANGED
package/dist/diff-tree.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { createTwoFilesPatch } from 'diff';
|
|
2
2
|
import parse from 'parse-diff';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param urlA
|
|
6
|
+
* @param urlB
|
|
7
|
+
* @param dataA
|
|
8
|
+
* @param dataB
|
|
9
|
+
*/
|
|
3
10
|
export function diffTree(urlA, urlB, dataA, dataB) {
|
|
4
11
|
const result = createTwoFilesPatch(urlA, urlB, dataA, dataB);
|
|
5
12
|
const info = parse(result)[0];
|
package/dist/freeze.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PageData } from './types.js';
|
|
2
|
+
import type { PageHook } from '@d-zero/puppeteer-screenshot';
|
|
3
|
+
export interface FreezeOptions {
|
|
4
|
+
readonly hooks: readonly PageHook[];
|
|
5
|
+
readonly limit?: number;
|
|
6
|
+
readonly debug?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param list
|
|
11
|
+
* @param options
|
|
12
|
+
*/
|
|
13
|
+
export declare function freeze(list: readonly string[], options?: FreezeOptions): Promise<PageData[]>;
|
package/dist/freeze.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mkdir } from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { deal } from '@d-zero/puppeteer-dealer';
|
|
4
|
+
import { delay } from '@d-zero/shared/delay';
|
|
5
|
+
import c from 'ansi-colors';
|
|
6
|
+
import { analyzeUrlList } from './analize-url.js';
|
|
7
|
+
import { getData } from './get-data.js';
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param list
|
|
11
|
+
* @param options
|
|
12
|
+
*/
|
|
13
|
+
export async function freeze(list, options) {
|
|
14
|
+
const results = [];
|
|
15
|
+
const dir = path.resolve(process.cwd(), '.archaeologist');
|
|
16
|
+
await mkdir(dir, { recursive: true }).catch(() => { });
|
|
17
|
+
const urlInfo = analyzeUrlList(list);
|
|
18
|
+
const useOldMode = urlInfo.hasAuth || urlInfo.hasNoSSL;
|
|
19
|
+
await deal(list.map((url) => ({ id: null, url })), (_, done, total) => {
|
|
20
|
+
return `${c.bold.magenta('🕵️ Archaeologist Freeze❄️')} ${done}/${total}`;
|
|
21
|
+
}, {
|
|
22
|
+
async deal(page, _, url, logger) {
|
|
23
|
+
const data = await getData(page, url, {
|
|
24
|
+
...options,
|
|
25
|
+
}, logger);
|
|
26
|
+
await delay(600);
|
|
27
|
+
results.push(data);
|
|
28
|
+
},
|
|
29
|
+
}, {
|
|
30
|
+
...options,
|
|
31
|
+
headless: useOldMode ? 'shell' : true,
|
|
32
|
+
});
|
|
33
|
+
return results;
|
|
34
|
+
}
|
package/dist/get-data.d.ts
CHANGED
|
@@ -5,4 +5,11 @@ export interface GetDataOptions {
|
|
|
5
5
|
readonly hooks?: readonly PageHook[];
|
|
6
6
|
readonly htmlDiffOnly?: boolean;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param page
|
|
11
|
+
* @param url
|
|
12
|
+
* @param options
|
|
13
|
+
* @param update
|
|
14
|
+
*/
|
|
8
15
|
export declare function getData(page: Page, url: string, options: GetDataOptions, update: (log: string) => void): Promise<PageData>;
|
package/dist/get-data.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { distill } from '@d-zero/html-distiller';
|
|
2
2
|
import { screenshotListener, screenshot } from '@d-zero/puppeteer-screenshot';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param page
|
|
6
|
+
* @param url
|
|
7
|
+
* @param options
|
|
8
|
+
* @param update
|
|
9
|
+
*/
|
|
3
10
|
export async function getData(page, url, options, update) {
|
|
4
11
|
const htmlDiffOnly = options.htmlDiffOnly ?? false;
|
|
5
12
|
const screenshots = await screenshot(page, url, {
|
package/dist/output-utils.d.ts
CHANGED
package/dist/output-utils.js
CHANGED
package/dist/read-config.d.ts
CHANGED
package/dist/read-config.js
CHANGED
|
@@ -3,6 +3,10 @@ import path from 'node:path';
|
|
|
3
3
|
import { readPageHooks } from '@d-zero/puppeteer-page-scan';
|
|
4
4
|
import { toList } from '@d-zero/readtext/list';
|
|
5
5
|
import fm from 'front-matter';
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param filePath
|
|
9
|
+
*/
|
|
6
10
|
export async function readConfig(filePath) {
|
|
7
11
|
const fileContent = await fs.readFile(filePath, 'utf8');
|
|
8
12
|
const content =
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/archaeologist",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "Uncover visual and HTML differences in web pages with precision",
|
|
5
5
|
"author": "D-ZERO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,25 +27,25 @@
|
|
|
27
27
|
"clean": "tsc --build --clean"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@d-zero/html-distiller": "1.0.
|
|
31
|
-
"@d-zero/puppeteer-dealer": "0.
|
|
32
|
-
"@d-zero/puppeteer-page-scan": "
|
|
33
|
-
"@d-zero/puppeteer-screenshot": "
|
|
34
|
-
"@d-zero/readtext": "1.1.
|
|
30
|
+
"@d-zero/html-distiller": "1.0.2",
|
|
31
|
+
"@d-zero/puppeteer-dealer": "0.3.0",
|
|
32
|
+
"@d-zero/puppeteer-page-scan": "3.0.0",
|
|
33
|
+
"@d-zero/puppeteer-screenshot": "3.0.0",
|
|
34
|
+
"@d-zero/readtext": "1.1.2",
|
|
35
35
|
"ansi-colors": "4.1.3",
|
|
36
36
|
"diff": "7.0.0",
|
|
37
37
|
"front-matter": "4.0.2",
|
|
38
38
|
"jimp": "1.6.0",
|
|
39
39
|
"minimist": "1.2.8",
|
|
40
40
|
"parse-diff": "0.11.1",
|
|
41
|
-
"pixelmatch": "
|
|
41
|
+
"pixelmatch": "7.1.0",
|
|
42
42
|
"pngjs": "7.0.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@d-zero/puppeteer-page": "0.
|
|
46
|
-
"@types/diff": "
|
|
45
|
+
"@d-zero/puppeteer-page": "0.3.0",
|
|
46
|
+
"@types/diff": "7.0.1",
|
|
47
47
|
"@types/pixelmatch": "5.2.6",
|
|
48
48
|
"@types/pngjs": "6.0.5"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "e4fd17857e31022d121527b00fd7f009dbdb2142"
|
|
51
51
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function diffTreeColor(diff: string): string;
|
package/dist/diff-tree-color.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import c from 'ansi-colors';
|
|
2
|
-
export function diffTreeColor(diff) {
|
|
3
|
-
return diff
|
|
4
|
-
.split('\n')
|
|
5
|
-
.map((line) => {
|
|
6
|
-
if (line.startsWith('+')) {
|
|
7
|
-
return c.green(line);
|
|
8
|
-
}
|
|
9
|
-
if (line.startsWith('-')) {
|
|
10
|
-
return c.red(line);
|
|
11
|
-
}
|
|
12
|
-
return c.gray(line);
|
|
13
|
-
})
|
|
14
|
-
.join('\n');
|
|
15
|
-
}
|
package/dist/read-hooks.d.ts
DELETED
package/dist/read-hooks.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
export async function readHooks(hooks, listfile) {
|
|
3
|
-
const listfileDir = path.dirname(listfile);
|
|
4
|
-
const pageHooks = await Promise.all(hooks.map(async (hook) => {
|
|
5
|
-
const hookAbsPath = path.isAbsolute(hook) ? hook : path.resolve(listfileDir, hook);
|
|
6
|
-
const { default: mod } = await import(hookAbsPath).catch((error) => {
|
|
7
|
-
if (error instanceof Error &&
|
|
8
|
-
'code' in error &&
|
|
9
|
-
error.code === 'ERR_MODULE_NOT_FOUND') {
|
|
10
|
-
throw new Error(`Hook: ${hook} not found`, { cause: error });
|
|
11
|
-
}
|
|
12
|
-
throw error;
|
|
13
|
-
});
|
|
14
|
-
if (typeof mod !== 'function') {
|
|
15
|
-
throw new TypeError(`Hook ${hook} is not a function`);
|
|
16
|
-
}
|
|
17
|
-
return mod;
|
|
18
|
-
}));
|
|
19
|
-
return pageHooks;
|
|
20
|
-
}
|