@page-scanner/cli 0.1.1 → 0.2.1
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/README.md +58 -4
- package/dist/api.d.ts +82 -2
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +147 -18
- package/dist/api.js.map +1 -1
- package/dist/batch.d.ts +60 -0
- package/dist/batch.d.ts.map +1 -0
- package/dist/batch.js +116 -0
- package/dist/batch.js.map +1 -0
- package/dist/cli/args.d.ts +27 -4
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +129 -10
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/commands.d.ts +2 -0
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +170 -14
- package/dist/cli/commands.js.map +1 -1
- package/dist/daemon/rpc-server.d.ts.map +1 -1
- package/dist/daemon/rpc-server.js +17 -1
- package/dist/daemon/rpc-server.js.map +1 -1
- package/dist/diff/image.d.ts +42 -0
- package/dist/diff/image.d.ts.map +1 -0
- package/dist/diff/image.js +144 -0
- package/dist/diff/image.js.map +1 -0
- package/dist/diff/index.d.ts +46 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +108 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/diff/png.d.ts +12 -0
- package/dist/diff/png.d.ts.map +1 -0
- package/dist/diff/png.js +169 -0
- package/dist/diff/png.js.map +1 -0
- package/dist/diff/text.d.ts +54 -0
- package/dist/diff/text.d.ts.map +1 -0
- package/dist/diff/text.js +198 -0
- package/dist/diff/text.js.map +1 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/output.d.ts +10 -0
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +24 -4
- package/dist/output.js.map +1 -1
- package/dist/protocol.d.ts +37 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +23 -2
- package/dist/protocol.js.map +1 -1
- package/dist/verify.d.ts +31 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +115 -0
- package/dist/verify.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -2
package/dist/diff/png.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PNG in and out, on `node:zlib` alone, for the visual diff (#60).
|
|
3
|
+
*
|
|
4
|
+
* The CLI ships one runtime dependency, and an image library would be a
|
|
5
|
+
* second for one command. A capture's PNG is the plainest kind there is: 8
|
|
6
|
+
* bits a channel, not interlaced. Decoding covers every colour type at 8 bits
|
|
7
|
+
* (grey, RGB, palette, grey with alpha, RGBA), which is what Chrome, a canvas
|
|
8
|
+
* and most tools write; anything else is refused by name. Encoding writes
|
|
9
|
+
* RGBA only.
|
|
10
|
+
*/
|
|
11
|
+
import { crc32, deflateSync, inflateSync } from 'node:zlib';
|
|
12
|
+
const SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
|
13
|
+
export class PngError extends Error {
|
|
14
|
+
}
|
|
15
|
+
const CHANNELS = { 0: 1, 2: 3, 3: 1, 4: 2, 6: 4 };
|
|
16
|
+
function paeth(a, b, c) {
|
|
17
|
+
const p = a + b - c;
|
|
18
|
+
const pa = Math.abs(p - a);
|
|
19
|
+
const pb = Math.abs(p - b);
|
|
20
|
+
const pc = Math.abs(p - c);
|
|
21
|
+
return pa <= pb && pa <= pc ? a : pb <= pc ? b : c;
|
|
22
|
+
}
|
|
23
|
+
export function decodePng(bytes) {
|
|
24
|
+
const buffer = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
25
|
+
if (buffer.length < 8 || !buffer.subarray(0, 8).equals(SIGNATURE)) {
|
|
26
|
+
throw new PngError('not a PNG file');
|
|
27
|
+
}
|
|
28
|
+
let width = 0;
|
|
29
|
+
let height = 0;
|
|
30
|
+
let colorType = -1;
|
|
31
|
+
let palette = null;
|
|
32
|
+
let transparency = null;
|
|
33
|
+
const data = [];
|
|
34
|
+
for (let at = 8; at + 8 <= buffer.length;) {
|
|
35
|
+
const length = buffer.readUInt32BE(at);
|
|
36
|
+
const type = buffer.toString('latin1', at + 4, at + 8);
|
|
37
|
+
const body = buffer.subarray(at + 8, at + 8 + length);
|
|
38
|
+
if (type === 'IHDR') {
|
|
39
|
+
width = body.readUInt32BE(0);
|
|
40
|
+
height = body.readUInt32BE(4);
|
|
41
|
+
const depth = body[8];
|
|
42
|
+
colorType = body[9];
|
|
43
|
+
const interlace = body[12];
|
|
44
|
+
if (depth !== 8)
|
|
45
|
+
throw new PngError(`a ${depth}-bit PNG, and only 8 bits a channel is read`);
|
|
46
|
+
if (interlace !== 0)
|
|
47
|
+
throw new PngError('an interlaced PNG, which is not read');
|
|
48
|
+
if (CHANNELS[colorType] === undefined)
|
|
49
|
+
throw new PngError(`PNG colour type ${colorType}`);
|
|
50
|
+
}
|
|
51
|
+
else if (type === 'PLTE')
|
|
52
|
+
palette = body;
|
|
53
|
+
else if (type === 'tRNS')
|
|
54
|
+
transparency = body;
|
|
55
|
+
else if (type === 'IDAT')
|
|
56
|
+
data.push(body);
|
|
57
|
+
else if (type === 'IEND')
|
|
58
|
+
break;
|
|
59
|
+
at += 12 + length;
|
|
60
|
+
}
|
|
61
|
+
if (width === 0 || height === 0)
|
|
62
|
+
throw new PngError('a PNG with no image header');
|
|
63
|
+
const channels = CHANNELS[colorType];
|
|
64
|
+
const stride = width * channels;
|
|
65
|
+
const raw = inflateSync(Buffer.concat(data));
|
|
66
|
+
if (raw.length < (stride + 1) * height)
|
|
67
|
+
throw new PngError('a PNG whose image data is cut short');
|
|
68
|
+
const rows = new Uint8Array(stride * height);
|
|
69
|
+
for (let y = 0; y < height; y++) {
|
|
70
|
+
const filter = raw[y * (stride + 1)];
|
|
71
|
+
const source = y * (stride + 1) + 1;
|
|
72
|
+
const row = y * stride;
|
|
73
|
+
for (let x = 0; x < stride; x++) {
|
|
74
|
+
const value = raw[source + x];
|
|
75
|
+
const left = x >= channels ? rows[row + x - channels] : 0;
|
|
76
|
+
const up = y > 0 ? rows[row - stride + x] : 0;
|
|
77
|
+
const upLeft = y > 0 && x >= channels ? rows[row - stride + x - channels] : 0;
|
|
78
|
+
let out;
|
|
79
|
+
switch (filter) {
|
|
80
|
+
case 0:
|
|
81
|
+
out = value;
|
|
82
|
+
break;
|
|
83
|
+
case 1:
|
|
84
|
+
out = value + left;
|
|
85
|
+
break;
|
|
86
|
+
case 2:
|
|
87
|
+
out = value + up;
|
|
88
|
+
break;
|
|
89
|
+
case 3:
|
|
90
|
+
out = value + ((left + up) >> 1);
|
|
91
|
+
break;
|
|
92
|
+
case 4:
|
|
93
|
+
out = value + paeth(left, up, upLeft);
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
throw new PngError(`a PNG row with filter ${filter}`);
|
|
97
|
+
}
|
|
98
|
+
rows[row + x] = out & 0xff;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const rgba = new Uint8Array(width * height * 4);
|
|
102
|
+
for (let pixel = 0; pixel < width * height; pixel++) {
|
|
103
|
+
const from = pixel * channels;
|
|
104
|
+
const to = pixel * 4;
|
|
105
|
+
switch (colorType) {
|
|
106
|
+
case 0:
|
|
107
|
+
rgba[to] = rgba[to + 1] = rgba[to + 2] = rows[from];
|
|
108
|
+
rgba[to + 3] = 255;
|
|
109
|
+
break;
|
|
110
|
+
case 2:
|
|
111
|
+
rgba[to] = rows[from];
|
|
112
|
+
rgba[to + 1] = rows[from + 1];
|
|
113
|
+
rgba[to + 2] = rows[from + 2];
|
|
114
|
+
rgba[to + 3] = 255;
|
|
115
|
+
break;
|
|
116
|
+
case 3: {
|
|
117
|
+
const index = rows[from];
|
|
118
|
+
if (!palette)
|
|
119
|
+
throw new PngError('a palette PNG with no palette');
|
|
120
|
+
rgba[to] = palette[index * 3] ?? 0;
|
|
121
|
+
rgba[to + 1] = palette[index * 3 + 1] ?? 0;
|
|
122
|
+
rgba[to + 2] = palette[index * 3 + 2] ?? 0;
|
|
123
|
+
rgba[to + 3] = transparency?.[index] ?? 255;
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
case 4:
|
|
127
|
+
rgba[to] = rgba[to + 1] = rgba[to + 2] = rows[from];
|
|
128
|
+
rgba[to + 3] = rows[from + 1];
|
|
129
|
+
break;
|
|
130
|
+
default:
|
|
131
|
+
rgba.set(rows.subarray(from, from + 4), to);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return { width, height, data: rgba };
|
|
135
|
+
}
|
|
136
|
+
function chunk(type, body) {
|
|
137
|
+
const head = Buffer.alloc(8);
|
|
138
|
+
head.writeUInt32BE(body.length, 0);
|
|
139
|
+
head.write(type, 4, 'latin1');
|
|
140
|
+
const tail = Buffer.alloc(4);
|
|
141
|
+
tail.writeUInt32BE(crc32(Buffer.concat([head.subarray(4), body])) >>> 0, 0);
|
|
142
|
+
return Buffer.concat([head, body, tail]);
|
|
143
|
+
}
|
|
144
|
+
/** RGBA as a PNG, each row filtered Up, which suits a page's long runs of flat colour. */
|
|
145
|
+
export function encodePng(image) {
|
|
146
|
+
const stride = image.width * 4;
|
|
147
|
+
const raw = Buffer.alloc((stride + 1) * image.height);
|
|
148
|
+
for (let y = 0; y < image.height; y++) {
|
|
149
|
+
const out = y * (stride + 1);
|
|
150
|
+
raw[out] = 2;
|
|
151
|
+
for (let x = 0; x < stride; x++) {
|
|
152
|
+
const value = image.data[y * stride + x];
|
|
153
|
+
const up = y > 0 ? image.data[(y - 1) * stride + x] : 0;
|
|
154
|
+
raw[out + 1 + x] = (value - up) & 0xff;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const header = Buffer.alloc(13);
|
|
158
|
+
header.writeUInt32BE(image.width, 0);
|
|
159
|
+
header.writeUInt32BE(image.height, 4);
|
|
160
|
+
header[8] = 8;
|
|
161
|
+
header[9] = 6;
|
|
162
|
+
return Buffer.concat([
|
|
163
|
+
SIGNATURE,
|
|
164
|
+
chunk('IHDR', header),
|
|
165
|
+
chunk('IDAT', deflateSync(raw)),
|
|
166
|
+
chunk('IEND', new Uint8Array()),
|
|
167
|
+
]);
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=png.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"png.js","sourceRoot":"","sources":["../../src/diff/png.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE5D,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAShF,MAAM,OAAO,QAAS,SAAQ,KAAK;CAAG;AAEtC,MAAM,QAAQ,GAA2B,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC;AAE1E,SAAS,KAAK,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IAC5C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CA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AAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACzD,GAAG,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC;QACzC,CAAC;IACH,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAChC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACtC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACd,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACd,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,SAAS;QACT,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/B,KAAK,CAAC,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;KAChC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What changed in a page's text between two captures (#60): the Markdown
|
|
3
|
+
* `scan --markdown` writes (#61), compared a line at a time.
|
|
4
|
+
*
|
|
5
|
+
* A line of that Markdown is a block of the page (a heading, a paragraph, a
|
|
6
|
+
* list item, a table row), so a line diff is a passage diff: a reworded
|
|
7
|
+
* sentence shows as its paragraph removed and added again, which is how a
|
|
8
|
+
* person reading a policy for changes wants it. The front matter is set
|
|
9
|
+
* aside first, because its capture time differs on every run and would make
|
|
10
|
+
* two identical pages look changed.
|
|
11
|
+
*
|
|
12
|
+
* Myers' algorithm, the one `diff` and git use, with the common head and tail
|
|
13
|
+
* trimmed first. Past `MAX_EDIT_DISTANCE` edits it stops looking for the
|
|
14
|
+
* shortest script and reports the rest as removed and added whole: two
|
|
15
|
+
* captures that different are a different page, and the search would
|
|
16
|
+
* otherwise cost memory in the square of the edits.
|
|
17
|
+
*/
|
|
18
|
+
export declare const MAX_EDIT_DISTANCE = 2000;
|
|
19
|
+
/** Unchanged lines kept around each change, as `diff -u` does. */
|
|
20
|
+
export declare const CONTEXT_LINES = 3;
|
|
21
|
+
export type DiffOp = ' ' | '-' | '+';
|
|
22
|
+
export interface DiffLine {
|
|
23
|
+
op: DiffOp;
|
|
24
|
+
text: string;
|
|
25
|
+
}
|
|
26
|
+
export interface Hunk {
|
|
27
|
+
/** 1-based first line in the old text, and how many lines of it the hunk covers. */
|
|
28
|
+
oldStart: number;
|
|
29
|
+
oldLines: number;
|
|
30
|
+
newStart: number;
|
|
31
|
+
newLines: number;
|
|
32
|
+
lines: DiffLine[];
|
|
33
|
+
}
|
|
34
|
+
export interface TextDiff {
|
|
35
|
+
added: number;
|
|
36
|
+
removed: number;
|
|
37
|
+
hunks: Hunk[];
|
|
38
|
+
}
|
|
39
|
+
export interface FrontMatter {
|
|
40
|
+
/** Each `key: value` line, with a JSON-quoted value unquoted. */
|
|
41
|
+
fields: Record<string, string>;
|
|
42
|
+
body: string;
|
|
43
|
+
}
|
|
44
|
+
/** The YAML front matter a Markdown export starts with, taken off the text. */
|
|
45
|
+
export declare function splitFrontMatter(text: string): FrontMatter;
|
|
46
|
+
/** The edit script from `a` to `b`, as a line each: kept, removed or added. */
|
|
47
|
+
export declare function diffLines(a: readonly string[], b: readonly string[]): DiffLine[];
|
|
48
|
+
/** The script cut into hunks with `context` unchanged lines around each change. */
|
|
49
|
+
export declare function toHunks(lines: readonly DiffLine[], context?: number): Hunk[];
|
|
50
|
+
/** Two Markdown captures compared, front matter aside. */
|
|
51
|
+
export declare function diffText(before: string, after: string): TextDiff;
|
|
52
|
+
/** The hunks as `diff -u` prints them, under a header naming the two files. */
|
|
53
|
+
export declare function formatUnified(diff: TextDiff, oldLabel: string, newLabel: string): string;
|
|
54
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/diff/text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,iBAAiB,OAAO,CAAC;AACtC,kEAAkE;AAClE,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,MAAM,MAAM,MAAM,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAErC,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,IAAI;IACnB,oFAAoF;IACpF,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,QAAQ,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,iEAAiE;IACjE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAoB1D;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,MAAM,EAAE,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,QAAQ,EAAE,CAiBhF;AA2ED,mFAAmF;AACnF,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,EAAE,OAAO,SAAgB,GAAG,IAAI,EAAE,CA+BnF;AAED,0DAA0D;AAC1D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,CAUhE;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAYxF"}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What changed in a page's text between two captures (#60): the Markdown
|
|
3
|
+
* `scan --markdown` writes (#61), compared a line at a time.
|
|
4
|
+
*
|
|
5
|
+
* A line of that Markdown is a block of the page (a heading, a paragraph, a
|
|
6
|
+
* list item, a table row), so a line diff is a passage diff: a reworded
|
|
7
|
+
* sentence shows as its paragraph removed and added again, which is how a
|
|
8
|
+
* person reading a policy for changes wants it. The front matter is set
|
|
9
|
+
* aside first, because its capture time differs on every run and would make
|
|
10
|
+
* two identical pages look changed.
|
|
11
|
+
*
|
|
12
|
+
* Myers' algorithm, the one `diff` and git use, with the common head and tail
|
|
13
|
+
* trimmed first. Past `MAX_EDIT_DISTANCE` edits it stops looking for the
|
|
14
|
+
* shortest script and reports the rest as removed and added whole: two
|
|
15
|
+
* captures that different are a different page, and the search would
|
|
16
|
+
* otherwise cost memory in the square of the edits.
|
|
17
|
+
*/
|
|
18
|
+
export const MAX_EDIT_DISTANCE = 2000;
|
|
19
|
+
/** Unchanged lines kept around each change, as `diff -u` does. */
|
|
20
|
+
export const CONTEXT_LINES = 3;
|
|
21
|
+
/** The YAML front matter a Markdown export starts with, taken off the text. */
|
|
22
|
+
export function splitFrontMatter(text) {
|
|
23
|
+
const normalised = text.replace(/\r\n?/g, '\n');
|
|
24
|
+
const match = /^---\n([\s\S]*?)\n---\n?/.exec(normalised);
|
|
25
|
+
if (!match)
|
|
26
|
+
return { fields: {}, body: normalised };
|
|
27
|
+
const fields = {};
|
|
28
|
+
for (const line of match[1].split('\n')) {
|
|
29
|
+
const colon = line.indexOf(':');
|
|
30
|
+
if (colon <= 0)
|
|
31
|
+
continue;
|
|
32
|
+
const raw = line.slice(colon + 1).trim();
|
|
33
|
+
let value = raw;
|
|
34
|
+
if (raw.startsWith('"')) {
|
|
35
|
+
try {
|
|
36
|
+
value = String(JSON.parse(raw));
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
value = raw;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
fields[line.slice(0, colon).trim()] = value;
|
|
43
|
+
}
|
|
44
|
+
return { fields, body: normalised.slice(match[0].length) };
|
|
45
|
+
}
|
|
46
|
+
/** The edit script from `a` to `b`, as a line each: kept, removed or added. */
|
|
47
|
+
export function diffLines(a, b) {
|
|
48
|
+
let head = 0;
|
|
49
|
+
while (head < a.length && head < b.length && a[head] === b[head])
|
|
50
|
+
head++;
|
|
51
|
+
let tail = 0;
|
|
52
|
+
while (tail < a.length - head &&
|
|
53
|
+
tail < b.length - head &&
|
|
54
|
+
a[a.length - 1 - tail] === b[b.length - 1 - tail]) {
|
|
55
|
+
tail++;
|
|
56
|
+
}
|
|
57
|
+
const middle = myers(a.slice(head, a.length - tail), b.slice(head, b.length - tail));
|
|
58
|
+
return [
|
|
59
|
+
...a.slice(0, head).map((text) => ({ op: ' ', text })),
|
|
60
|
+
...middle,
|
|
61
|
+
...a.slice(a.length - tail).map((text) => ({ op: ' ', text })),
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
function myers(a, b) {
|
|
65
|
+
const n = a.length;
|
|
66
|
+
const m = b.length;
|
|
67
|
+
if (n === 0)
|
|
68
|
+
return b.map((text) => ({ op: '+', text }));
|
|
69
|
+
if (m === 0)
|
|
70
|
+
return a.map((text) => ({ op: '-', text }));
|
|
71
|
+
// Lines as numbers, so the inner loop compares integers.
|
|
72
|
+
const ids = new Map();
|
|
73
|
+
const id = (line) => {
|
|
74
|
+
let value = ids.get(line);
|
|
75
|
+
if (value === undefined)
|
|
76
|
+
ids.set(line, (value = ids.size));
|
|
77
|
+
return value;
|
|
78
|
+
};
|
|
79
|
+
const x0 = a.map(id);
|
|
80
|
+
const y0 = b.map(id);
|
|
81
|
+
const limit = Math.min(n + m, MAX_EDIT_DISTANCE);
|
|
82
|
+
const offset = limit + 1;
|
|
83
|
+
const v = new Int32Array(2 * limit + 3);
|
|
84
|
+
// Each round's diagonals, -d..d, for the walk back.
|
|
85
|
+
const trace = [];
|
|
86
|
+
for (let d = 0; d <= limit; d++) {
|
|
87
|
+
for (let k = -d; k <= d; k += 2) {
|
|
88
|
+
let x = k === -d || (k !== d && v[offset + k - 1] < v[offset + k + 1])
|
|
89
|
+
? v[offset + k + 1]
|
|
90
|
+
: v[offset + k - 1] + 1;
|
|
91
|
+
let y = x - k;
|
|
92
|
+
while (x < n && y < m && x0[x] === y0[y]) {
|
|
93
|
+
x++;
|
|
94
|
+
y++;
|
|
95
|
+
}
|
|
96
|
+
v[offset + k] = x;
|
|
97
|
+
if (x >= n && y >= m) {
|
|
98
|
+
trace.push(v.slice(offset - d, offset + d + 1));
|
|
99
|
+
return walkBack(trace, a, b);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
trace.push(v.slice(offset - d, offset + d + 1));
|
|
103
|
+
}
|
|
104
|
+
// Too far apart to be worth the search: all of one, then all of the other.
|
|
105
|
+
return [
|
|
106
|
+
...a.map((text) => ({ op: '-', text })),
|
|
107
|
+
...b.map((text) => ({ op: '+', text })),
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
function walkBack(trace, a, b) {
|
|
111
|
+
const out = [];
|
|
112
|
+
let x = a.length;
|
|
113
|
+
let y = b.length;
|
|
114
|
+
for (let d = trace.length - 1; d > 0; d--) {
|
|
115
|
+
const previous = trace[d - 1];
|
|
116
|
+
const at = (k) => previous[k + d - 1];
|
|
117
|
+
const k = x - y;
|
|
118
|
+
const down = k === -d || (k !== d && at(k - 1) < at(k + 1));
|
|
119
|
+
const prevK = down ? k + 1 : k - 1;
|
|
120
|
+
const prevX = at(prevK);
|
|
121
|
+
const prevY = prevX - prevK;
|
|
122
|
+
while (x > prevX && y > prevY) {
|
|
123
|
+
out.push({ op: ' ', text: a[--x] });
|
|
124
|
+
y--;
|
|
125
|
+
}
|
|
126
|
+
if (down)
|
|
127
|
+
out.push({ op: '+', text: b[--y] });
|
|
128
|
+
else
|
|
129
|
+
out.push({ op: '-', text: a[--x] });
|
|
130
|
+
}
|
|
131
|
+
while (x > 0 && y > 0) {
|
|
132
|
+
out.push({ op: ' ', text: a[--x] });
|
|
133
|
+
y--;
|
|
134
|
+
}
|
|
135
|
+
return out.reverse();
|
|
136
|
+
}
|
|
137
|
+
/** The script cut into hunks with `context` unchanged lines around each change. */
|
|
138
|
+
export function toHunks(lines, context = CONTEXT_LINES) {
|
|
139
|
+
// Where each script line sits in the old text and the new, 1-based.
|
|
140
|
+
const oldAt = [];
|
|
141
|
+
const newAt = [];
|
|
142
|
+
let oldLine = 1;
|
|
143
|
+
let newLine = 1;
|
|
144
|
+
for (const line of lines) {
|
|
145
|
+
oldAt.push(oldLine);
|
|
146
|
+
newAt.push(newLine);
|
|
147
|
+
if (line.op !== '+')
|
|
148
|
+
oldLine++;
|
|
149
|
+
if (line.op !== '-')
|
|
150
|
+
newLine++;
|
|
151
|
+
}
|
|
152
|
+
// Runs of changes no more than two contexts apart share a hunk.
|
|
153
|
+
const groups = [];
|
|
154
|
+
lines.forEach((line, index) => {
|
|
155
|
+
if (line.op === ' ')
|
|
156
|
+
return;
|
|
157
|
+
const last = groups[groups.length - 1];
|
|
158
|
+
if (last && index - last[1] - 1 <= context * 2)
|
|
159
|
+
last[1] = index;
|
|
160
|
+
else
|
|
161
|
+
groups.push([index, index]);
|
|
162
|
+
});
|
|
163
|
+
return groups.map(([first, last]) => {
|
|
164
|
+
const start = Math.max(0, first - context);
|
|
165
|
+
const slice = lines.slice(start, Math.min(lines.length, last + context + 1));
|
|
166
|
+
return {
|
|
167
|
+
oldStart: oldAt[start],
|
|
168
|
+
oldLines: slice.filter((line) => line.op !== '+').length,
|
|
169
|
+
newStart: newAt[start],
|
|
170
|
+
newLines: slice.filter((line) => line.op !== '-').length,
|
|
171
|
+
lines: slice,
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
/** Two Markdown captures compared, front matter aside. */
|
|
176
|
+
export function diffText(before, after) {
|
|
177
|
+
const lines = diffLines(splitFrontMatter(before).body.split('\n'), splitFrontMatter(after).body.split('\n'));
|
|
178
|
+
return {
|
|
179
|
+
added: lines.filter((line) => line.op === '+').length,
|
|
180
|
+
removed: lines.filter((line) => line.op === '-').length,
|
|
181
|
+
hunks: toHunks(lines),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/** The hunks as `diff -u` prints them, under a header naming the two files. */
|
|
185
|
+
export function formatUnified(diff, oldLabel, newLabel) {
|
|
186
|
+
if (diff.hunks.length === 0)
|
|
187
|
+
return '';
|
|
188
|
+
const range = (start, count) => count === 1 ? `${start}` : `${count === 0 ? start - 1 : start},${count}`;
|
|
189
|
+
return [
|
|
190
|
+
`--- ${oldLabel}`,
|
|
191
|
+
`+++ ${newLabel}`,
|
|
192
|
+
...diff.hunks.flatMap((hunk) => [
|
|
193
|
+
`@@ -${range(hunk.oldStart, hunk.oldLines)} +${range(hunk.newStart, hunk.newLines)} @@`,
|
|
194
|
+
...hunk.lines.map((line) => `${line.op}${line.text}`),
|
|
195
|
+
]),
|
|
196
|
+
].join('\n');
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/diff/text.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC;AACtC,kEAAkE;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AA8B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AAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;SACtD,CAAC;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,13 +5,16 @@
|
|
|
5
5
|
* a separate process. `@page-scanner/cli/daemon` is the entry point that starts
|
|
6
6
|
* one in-process, and it is the only one that pulls the WebSocket server in.
|
|
7
7
|
*/
|
|
8
|
-
export { listBrowsers, listTabs, pair, scan, status, stop, waitForBrowser, type CommonOptions, type PairResult, type ScanOptions, type ScanResult, type StatusReport, type TabsResult, } from './api.js';
|
|
8
|
+
export { listBrowsers, listTabs, pair, scan, scanMany, checkBatch, checkOutput, MARKDOWN_MODES, status, stop, waitForBrowser, type CommonOptions, type PairResult, type ScanOptions, type ScanResult, type BatchItem, type BatchOptions, type BatchResult, type MarkdownMode, type PageText, type StatusReport, type TabsResult, } from './api.js';
|
|
9
9
|
export { configDir, configPath, configFileIsOwnerOnly, ensureConfig, readConfig, DEFAULT_PORT, type PairingConfig, } from './config.js';
|
|
10
10
|
export { exitCodeFor, isPageScannerError, toPageScannerError, PageScannerError, ERROR_CODES, type ErrorCode, } from './errors.js';
|
|
11
|
-
export { resolveOutputPath, writeScanFile } from './output.js';
|
|
11
|
+
export { outputNamesAFile, resolveOutputPath, withExtension, writeScanFile, writeTextFile, } from './output.js';
|
|
12
|
+
export { diffCaptures, type DiffOptions, type DiffResult, type TextDiffResult, type VisualDiffResult, } from './diff/index.js';
|
|
13
|
+
export { verifyCapture, type VerifyResult } from './verify.js';
|
|
14
|
+
export { MAX_BATCH_URLS, NAME_FIELDS, checkNameTemplate, fillNameTemplate, readUrlList, type NameField, } from './batch.js';
|
|
12
15
|
export { connectDaemon, stopDaemon, DAEMON_START_TIMEOUT_MS, type ConnectOptions, type DaemonClient, } from './daemon/client.js';
|
|
13
16
|
export { daemonLogPath, daemonStatePath, readDaemonState, type DaemonState, } from './daemon/state.js';
|
|
14
17
|
export type { ConnectedBrowser } from './bridge/server.js';
|
|
15
|
-
export { BRIDGE_PING_INTERVAL_MS, BRIDGE_PROTOCOL_VERSION, DEFAULT_PAGE_SIZE, EXPORT_FORMAT_IDS, PAGE_SIZE_IDS, VIDEO_HANDLINGS, type ExportFormatId, type PageSizeId, type TabSummary, type TruncationReport, type VideoHandling, type WindowSummary, } from './protocol.js';
|
|
18
|
+
export { BRIDGE_PING_INTERVAL_MS, BRIDGE_PROTOCOL_VERSION, CAPTURE_WIDTHS, COLOR_SCHEME_PREFERENCES, DEFAULT_CAPTURE_WIDTH, DEFAULT_COLOR_SCHEME, DEFAULT_PAGE_SIZE, EXPORT_FORMAT_IDS, PAGE_SIZE_IDS, STRUCTURED_MODES, VIDEO_HANDLINGS, type CaptureWidth, type ColorSchemePreference, type ExportFormatId, type PageSizeId, type StructuredHeading, type StructuredMode, type StructuredPage, type TabSummary, type TruncationReport, type VideoHandling, type WindowSummary, } from './protocol.js';
|
|
16
19
|
export { CLI_VERSION } from './version.js';
|
|
17
20
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,UAAU,GAChB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,KAAK,SAAS,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,WAAW,EACX,cAAc,EACd,MAAM,EACN,IAAI,EACJ,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,UAAU,GAChB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,KAAK,aAAa,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,KAAK,SAAS,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAE/D,OAAO,EACL,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,KAAK,SAAS,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,aAAa,EACb,UAAU,EACV,uBAAuB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,KAAK,WAAW,GACjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,12 +5,15 @@
|
|
|
5
5
|
* a separate process. `@page-scanner/cli/daemon` is the entry point that starts
|
|
6
6
|
* one in-process, and it is the only one that pulls the WebSocket server in.
|
|
7
7
|
*/
|
|
8
|
-
export { listBrowsers, listTabs, pair, scan, status, stop, waitForBrowser, } from './api.js';
|
|
8
|
+
export { listBrowsers, listTabs, pair, scan, scanMany, checkBatch, checkOutput, MARKDOWN_MODES, status, stop, waitForBrowser, } from './api.js';
|
|
9
9
|
export { configDir, configPath, configFileIsOwnerOnly, ensureConfig, readConfig, DEFAULT_PORT, } from './config.js';
|
|
10
10
|
export { exitCodeFor, isPageScannerError, toPageScannerError, PageScannerError, ERROR_CODES, } from './errors.js';
|
|
11
|
-
export { resolveOutputPath, writeScanFile } from './output.js';
|
|
11
|
+
export { outputNamesAFile, resolveOutputPath, withExtension, writeScanFile, writeTextFile, } from './output.js';
|
|
12
|
+
export { diffCaptures, } from './diff/index.js';
|
|
13
|
+
export { verifyCapture } from './verify.js';
|
|
14
|
+
export { MAX_BATCH_URLS, NAME_FIELDS, checkNameTemplate, fillNameTemplate, readUrlList, } from './batch.js';
|
|
12
15
|
export { connectDaemon, stopDaemon, DAEMON_START_TIMEOUT_MS, } from './daemon/client.js';
|
|
13
16
|
export { daemonLogPath, daemonStatePath, readDaemonState, } from './daemon/state.js';
|
|
14
|
-
export { BRIDGE_PING_INTERVAL_MS, BRIDGE_PROTOCOL_VERSION, DEFAULT_PAGE_SIZE, EXPORT_FORMAT_IDS, PAGE_SIZE_IDS, VIDEO_HANDLINGS, } from './protocol.js';
|
|
17
|
+
export { BRIDGE_PING_INTERVAL_MS, BRIDGE_PROTOCOL_VERSION, CAPTURE_WIDTHS, COLOR_SCHEME_PREFERENCES, DEFAULT_CAPTURE_WIDTH, DEFAULT_COLOR_SCHEME, DEFAULT_PAGE_SIZE, EXPORT_FORMAT_IDS, PAGE_SIZE_IDS, STRUCTURED_MODES, VIDEO_HANDLINGS, } from './protocol.js';
|
|
15
18
|
export { CLI_VERSION } from './version.js';
|
|
16
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,WAAW,EACX,cAAc,EACd,MAAM,EACN,IAAI,EACJ,cAAc,GAYf,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,YAAY,GAEb,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,GAEZ,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,YAAY,GAKb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,aAAa,EAAqB,MAAM,aAAa,CAAC;AAE/D,OAAO,EACL,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,GAEZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,aAAa,EACb,UAAU,EACV,uBAAuB,GAGxB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,eAAe,EACf,eAAe,GAEhB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,cAAc,EACd,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,eAAe,GAYhB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/output.d.ts
CHANGED
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
* caller holding someone else's working directory can pass it.
|
|
6
6
|
*/
|
|
7
7
|
export declare function resolveOutputPath(outputPath: string | undefined, suggestedName: string, cwd?: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Whether `--out` names the file itself rather than a directory to put it in:
|
|
10
|
+
* no trailing separator, an extension, and not a directory that is already
|
|
11
|
+
* there. A batch (#59) writes several files, so it needs the directory.
|
|
12
|
+
*/
|
|
13
|
+
export declare function outputNamesAFile(outputPath: string, cwd?: string): boolean;
|
|
14
|
+
/** The same path with another extension: `page.pdf` to `page.md`. */
|
|
15
|
+
export declare function withExtension(path: string, extension: string): string;
|
|
16
|
+
/** Text as UTF-8, its directories made on the way, as `writeScanFile` does for bytes. */
|
|
17
|
+
export declare function writeTextFile(target: string, text: string): void;
|
|
8
18
|
/**
|
|
9
19
|
* `--out captures/2026/page.pdf` should not fail because `2026` is not there
|
|
10
20
|
* yet, so the parent chain is created on the way in.
|
package/dist/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AA+BA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,MAAM,EACrB,GAAG,GAAE,MAAsB,GAC1B,MAAM,
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AA+BA;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,MAAM,EACrB,GAAG,GAAE,MAAsB,GAC1B,MAAM,CAKR;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,GAAE,MAAsB,GAAG,OAAO,CAOzF;AAqBD,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAKrE;AAED,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAGhE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAGvE"}
|
package/dist/output.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* nothing to do with where the person typing the command is standing.
|
|
8
8
|
*/
|
|
9
9
|
import { mkdirSync, statSync, writeFileSync } from 'node:fs';
|
|
10
|
-
import { dirname, join, resolve } from 'node:path';
|
|
10
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
11
11
|
/**
|
|
12
12
|
* A trailing separator is how the user says "this is a directory", and the only
|
|
13
13
|
* way to say it about a directory that does not exist yet.
|
|
@@ -36,10 +36,18 @@ export function resolveOutputPath(outputPath, suggestedName, cwd = process.cwd()
|
|
|
36
36
|
if (!outputPath)
|
|
37
37
|
return resolve(cwd, suggestedName);
|
|
38
38
|
const target = resolve(cwd, outputPath);
|
|
39
|
-
|
|
39
|
+
return outputNamesAFile(outputPath, cwd) ? target : join(target, suggestedName);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Whether `--out` names the file itself rather than a directory to put it in:
|
|
43
|
+
* no trailing separator, an extension, and not a directory that is already
|
|
44
|
+
* there. A batch (#59) writes several files, so it needs the directory.
|
|
45
|
+
*/
|
|
46
|
+
export function outputNamesAFile(outputPath, cwd = process.cwd()) {
|
|
47
|
+
const target = resolve(cwd, outputPath);
|
|
48
|
+
return (!TRAILING_SEPARATOR.test(outputPath) &&
|
|
40
49
|
FILE_EXTENSION.test(target) &&
|
|
41
|
-
!isExistingDirectory(target);
|
|
42
|
-
return namesAFile ? target : join(target, suggestedName);
|
|
50
|
+
!isExistingDirectory(target));
|
|
43
51
|
}
|
|
44
52
|
/**
|
|
45
53
|
* An existing directory wins over the extension rule, so `--out ./v1.2` writes
|
|
@@ -60,6 +68,18 @@ function isExistingDirectory(candidate) {
|
|
|
60
68
|
return false;
|
|
61
69
|
}
|
|
62
70
|
}
|
|
71
|
+
/** The same path with another extension: `page.pdf` to `page.md`. */
|
|
72
|
+
export function withExtension(path, extension) {
|
|
73
|
+
const base = basename(path);
|
|
74
|
+
const dot = base.lastIndexOf('.');
|
|
75
|
+
const stem = dot > 0 ? path.slice(0, path.length - base.length + dot) : path;
|
|
76
|
+
return `${stem}.${extension}`;
|
|
77
|
+
}
|
|
78
|
+
/** Text as UTF-8, its directories made on the way, as `writeScanFile` does for bytes. */
|
|
79
|
+
export function writeTextFile(target, text) {
|
|
80
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
81
|
+
writeFileSync(target, text, 'utf8');
|
|
82
|
+
}
|
|
63
83
|
/**
|
|
64
84
|
* `--out captures/2026/page.pdf` should not fail because `2026` is not there
|
|
65
85
|
* yet, so the parent chain is created on the way in.
|
package/dist/output.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAEpC;;;;GAIG;AACH,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAA8B,EAC9B,aAAqB,EACrB,MAAc,OAAO,CAAC,GAAG,EAAE;IAE3B,IAAI,CAAC,UAAU;QAAE,OAAO,OAAO,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;IAEpD,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACxC,OAAO,gBAAgB,CAAC,UAAU,EAAE,G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