@jonandev/longbeard 0.13.0 → 0.15.0
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/AGENTS.md +5 -5
- package/CHANGELOG.md +35 -0
- package/README.md +3 -4
- package/beard.json +6 -17
- package/bin/long-beard.js +2 -2
- package/package.json +1 -1
- package/skills/design/SKILL.md +7 -11
- package/skills/design-brief/SKILL.md +5 -35
- package/skills/design-check/SKILL.md +5 -7
- package/skills/design-check/references/design-rules.md +26 -4
- package/skills/design-check/scripts/rules.mjs +143 -9
- package/skills/design-content/SKILL.md +3 -8
- package/skills/design-direction/SKILL.md +58 -53
- package/skills/design-direction/references/design-floor.md +118 -0
- package/skills/design-direction/references/graphic.md +5 -6
- package/skills/design-direction/references/library.md +7 -7
- package/skills/design-direction/references/screen-template.html +7 -164
- package/skills/design-direction/references/screen.js +163 -0
- package/skills/design-direction/references/subject.md +3 -3
- package/skills/design-direction/references/variants.js +43 -0
- package/skills/design-direction/scripts/canvas.mjs +12 -9
- package/skills/design-direction/scripts/colours.mjs +247 -0
- package/skills/design-direction/scripts/moodboard.mjs +1 -1
- package/skills/design-direction/scripts/rules.mjs +747 -0
- package/skills/design-direction/scripts/sheet.mjs +3 -1
- package/skills/design-figma/SKILL.md +4 -6
- package/skills/design-identity/SKILL.md +12 -14
- package/skills/design-identity/references/design-floor.md +118 -0
- package/skills/design-identity/scripts/colours.mjs +35 -1
- package/skills/design-identity/scripts/sheet.mjs +3 -1
- package/skills/design-moodboard/SKILL.md +11 -11
- package/skills/design-moodboard/references/graphic.md +1 -1
- package/skills/design-moodboard/references/sources.md +1 -1
- package/skills/design-moodboard/scripts/group.mjs +1 -1
- package/skills/design-moodboard/scripts/moodboard.mjs +1 -1
- package/skills/design-prototype/SKILL.md +51 -49
- package/skills/design-prototype/references/design-floor.md +118 -0
- package/skills/design-prototype/references/design-md-template.md +4 -2
- package/skills/design-prototype/references/graphic.md +6 -5
- package/skills/design-prototype/references/variants.js +43 -0
- package/skills/design-prototype/scripts/links.mjs +5 -4
- package/skills/design-prototype/scripts/rules.mjs +143 -9
- package/skills/design-prototype/scripts/sheet.mjs +3 -1
- package/skills/design-wordmark/SKILL.md +9 -8
- package/skills/design-wordmark/scripts/sheet.mjs +3 -1
- package/skills/framework-skills/SKILL.md +3 -5
- package/skills/idea/SKILL.md +7 -9
- package/skills/design-direction/references/design-rules.md +0 -204
- package/skills/design-direction/references/full-build.md +0 -20
- package/skills/design-direction/references/grid.md +0 -97
- package/skills/design-direction/scripts/layout-diff.mjs +0 -118
- package/skills/design-families/SKILL.md +0 -139
- package/skills/design-families/scripts/contact-sheet.mjs +0 -259
- package/skills/design-families/scripts/families.mjs +0 -607
- package/skills/design-families/scripts/measure.mjs +0 -1728
- package/skills/design-families/scripts/moodboard.mjs +0 -609
- package/skills/design-families/scripts/tag.mjs +0 -289
- package/skills/design-prototype/references/design-rules.md +0 -204
- package/skills/design-prototype/references/five-second.md +0 -46
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# Building the screens
|
|
2
|
-
|
|
3
|
-
Read by `design-direction`, steps 3 and 4. Each screen is one reference rebuilt faithfully with the product's content, changed by one or two things borrowed from others. The agent's own taste adds nothing.
|
|
4
|
-
|
|
5
|
-
Each screen is `.longbeard/design/direction/screens/<n>.html` from [screen-template.html](screen-template.html): plain HTML and CSS in px at 1440 (or the device width for an app), every face and colour a variable in `LOOK`, and a `PROVENANCE` list. The translation before its moves is kept as `screens/<n>-base.html`. Anything the product does not really have yet carries `data-standin="picture"` or `data-standin="fact"`, with `data-standin-note`; their own pictures carry nothing.
|
|
6
|
-
|
|
7
|
-
`.longbeard/design/direction/screens.json`, one entry per screen:
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
[{ "n": 1, "base": "<card name>", "moves": [{ "what": "<the move>", "from": "<card name>", "like": "<their words, or null>" }], "picture": "<its main picture>", "tone": "<light or dark, warm or cool>", "why": "<one line>", "proposed": false, "build": "quick", "state": "built" }]
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
`build` is `quick` or `full`. `state` is where it ended: a quick screen `built`; a full screen (their favourite and its hardest screen) `built` while it runs, then `critiqued` (only small spots, nothing fixed) or `fixed`; any job that failed twice `failed` with `"failure": "<why>"`. Optional: `round` (1 when left out), `of` and `part` for a part's version, `of` and `test` for the hardest screen, `fault` (one line), `shot`. The canvas is drawn only when every screen has ended.
|
|
14
|
-
|
|
15
|
-
## Five principles
|
|
16
|
-
|
|
17
|
-
Decide any case by these. They go to every builder as written.
|
|
18
|
-
|
|
19
|
-
### 1. The base stands unless a move names it
|
|
20
|
-
|
|
21
|
-
What no move names stays as the base has it: layout (zones, proportions, margins, where headline, pictures and small text sit), anchors, balance, alignments, devices and picture treatment. The layout always comes from a reference; a move may turn it or take another's, never invent one.
|
|
22
|
-
|
|
23
|
-
- **Left out:** what they wrote to leave out of the base is dropped, or, when the composition needs its role (a ground, a frame, a face), filled from the nearest reference on the board. Never by the agent's own choice.
|
|
24
|
-
- **Liked:** what they like in the base is kept exactly, even against contrast. A liked colour is never stepped to pass: fix the text with what the screen has (the pair's other colour, large text, another crop, the colour moved to a fill behind it); when nothing fits, keep it with a warning and its ratio ("liked terracotta under the label: 3.9:1, AA asks 4.5"). What they never named is kept by its role, and may be swapped for another reference's colour of the same role and strength.
|
|
25
|
-
- A borrowed thing fits around the base's anchors, or goes to another base.
|
|
26
|
-
- Text on a picture sits on a calm area, as light or dark as the source's: the picture is chosen and cropped to the text, never the text moved. With no such picture, say so.
|
|
27
|
-
- A device that held content in its source holds the product's content, or is left out; never empty.
|
|
28
|
-
|
|
29
|
-
### 2. Every measure is a share of the screen, and is kept
|
|
30
|
-
|
|
31
|
-
Sizes, gaps and fills, measured in the source as a share of its width and height, are kept at 1440 within 15%: type sizes, gaps, the room between headline and menu, text to the margin, a label to its picture, a small device's parts, how much of its zone a text block fills.
|
|
32
|
-
|
|
33
|
-
- An element that grew (longer copy) is set smaller within its role; it never eats a neighbour's gap unless the source collides on purpose.
|
|
34
|
-
- A rule ends where it ends in the source; what runs off the screen runs off as there.
|
|
35
|
-
- Text read to act (the menu, a label) takes the size the board's screen references give it, never a poster's smaller size.
|
|
36
|
-
- **A turned layout** turns every gap and alignment with its zone, mirrored, never closed up. Each text block keeps the edge it hangs from and its ragged side; what is grouped with it moves with it.
|
|
37
|
-
|
|
38
|
-
### 3. A borrowed thing keeps its geometry and its why
|
|
39
|
-
|
|
40
|
-
Measure how it sits in its source (size against the screen, what it overlaps and how far, its room) and keep that. **Nothing they left out of a reference is borrowed from it.**
|
|
41
|
-
|
|
42
|
-
**Their why is the rule for using it.** "The orange dot, the only contrast on a quiet page" goes only on a quiet base, alone. A why that describes an arrangement goes only where the arrangement is. If the why would not be true on this base, the move goes to another. A like belongs to its reference, never a house style.
|
|
43
|
-
|
|
44
|
-
### 4. A move changes only what it names
|
|
45
|
-
|
|
46
|
-
One or two moves per screen, spread across the round. A move is one of:
|
|
47
|
-
- **a palette:** another reference's whole palette, or the subject's;
|
|
48
|
-
- **a thing from the subject** they liked (a stamp, a number), changed in form to fit;
|
|
49
|
-
- **a colour by its role:** one they did not name, for another of the same role and strength;
|
|
50
|
-
- **an element:** one device, or a surface finish, from another reference;
|
|
51
|
-
- **the face:** another's display face that can carry the base's headline;
|
|
52
|
-
- **the picture treatment:** another's crop, tone or frame, never its kind of picture;
|
|
53
|
-
- **the layout turned:** mirrored, headline and picture traded, or one zone moved;
|
|
54
|
-
- **the scale:** the headline larger or smaller, as far as another reference goes.
|
|
55
|
-
|
|
56
|
-
A move brings only its one thing: a face move brings no colour, a palette move no face. Moves come from what they like; where they named nothing, propose one from the reading, marked `"proposed": true`. A move the base cannot take is dropped for another.
|
|
57
|
-
|
|
58
|
-
### 5. Nothing from outside the board
|
|
59
|
-
|
|
60
|
-
Every face, colour, element and effect names its reference in `PROVENANCE`; the subject's card counts. The design brief rules out only what it names; a like it rules out is carried by its role.
|
|
61
|
-
|
|
62
|
-
## Which screens
|
|
63
|
-
|
|
64
|
-
Every like is the base of at least one screen, the lead of two; with fewer than eight, the lead and then the likes take a second. **Check the spread on the plan, before building:** no main picture on more than two screens, no tone on more than half, a borrowed thing on two screens at most. A plan that fails changes its pairings. Only a like that says it is the point ("always black and white") repeats.
|
|
65
|
-
|
|
66
|
-
## A quick round
|
|
67
|
-
|
|
68
|
-
**1. Plan (you).** Pair bases and moves, write `screens.json`, check the spread, then one brief per screen, `briefs/<n>.md`: the base's reading and picture path with what they left out of it; each move with its source picture, like and why; the content in fill order; the product's pictures for it; the five principles. Nothing else.
|
|
69
|
-
|
|
70
|
-
**2. Build (a fresh agent per screen, from its brief only).** Translate the base into `screens/<n>-base.html` with the product's content, capture it, and measure it against the reference:
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
node <skill>/scripts/layout-diff.mjs <reference picture> .longbeard/design/direction/grid/<n>-base.png --out .longbeard/design/direction/checks/<n>-base
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Fix it until nothing listed is off without a reason. Then make the moves into `screens/<n>.html`, capture, state `built`.
|
|
77
|
-
|
|
78
|
-
**3. Check the round (you).**
|
|
79
|
-
- **Not a copy:** one fresh judge sees every screen beside its base, as numbered thumbnails, and answers yes or no each: *can you tell them apart at a glance* (ground or accent, face, layout turned, a device added or gone, picture treatment)? A no gets another move and is rebuilt; the rebuilt ones go to one judge together.
|
|
80
|
-
- **Spread** again, on what was built.
|
|
81
|
-
- **Contrast,** every screen; a failure blocks the canvas, except a liked colour with its warning. Fixed with the screen's own colours or another crop:
|
|
82
|
-
```
|
|
83
|
-
node <skill>/scripts/screen-contrast.mjs "file://$PWD/.longbeard/design/direction/screens/1.html" --wait-title ready
|
|
84
|
-
```
|
|
85
|
-
- **Faults:** a clipped word, text under 12 px at 1440, a lone last word in a heading, a sentence twice.
|
|
86
|
-
- **Pictures:** `picture-cast.mjs` on the product's pictures; a cast or blown highlights the reference lacks means another picture.
|
|
87
|
-
|
|
88
|
-
**Without fresh agents,** do each job yourself, one screen at a time from its brief alone; as critic, write the list from the prepared pictures before fixing anything. Say the round is weaker, in each screen's `fault` ("built and judged by one agent").
|
|
89
|
-
|
|
90
|
-
## Capture and the canvas
|
|
91
|
-
|
|
92
|
-
```
|
|
93
|
-
node <skill>/scripts/capture.mjs "file://$PWD/.longbeard/design/direction/screens/1.html" --out .longbeard/design/direction/grid/1.png --clip 0,0,1440,900
|
|
94
|
-
node <skill>/scripts/canvas.mjs .longbeard/design/direction/screens.json --board .longbeard/design/direction/board.md --shots .longbeard/design/direction/grid --out .longbeard/design/direction/canvas.html
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Every screen is captured as `grid/<n>.png` (a full build's newer version as its `shot`). The canvas shows each one with its build (`quick`, `full` or `failed`), its fault, and beside it its base and moves with their pictures and likes; "Beside its base" shows the two together. Rows: each `round`, then each favourite's parts (`of`, `part`) and its hardest screen (`of`, `test`). Without fresh agents, put the round's weakness in a screen's `fault` ("built and judged by one agent"). For an app, or `first seen on: phone`, build and capture at the device size (`?size=390x844`, `--width 390`).
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Put a screen beside the reference it was built from, measured the same way,
|
|
3
|
-
// so the critic's eye has numbers under it. Node 22+, an installed Chrome.
|
|
4
|
-
//
|
|
5
|
-
// node layout-diff.mjs <reference picture> <screen capture> --out <folder> [--mirror]
|
|
6
|
-
//
|
|
7
|
-
// Both pictures are read by measure.mjs (a reference in a presentation frame
|
|
8
|
-
// is read inside it). Writes to --out:
|
|
9
|
-
// diff.json each measure on both sides and whether it is off: the
|
|
10
|
-
// headline's size against the screen, its box, its lines, the
|
|
11
|
-
// type scale, the margins the text keeps on each side, how
|
|
12
|
-
// much is empty and how much is pictures, and every line of
|
|
13
|
-
// text matched to its nearest line in the reference;
|
|
14
|
-
// side.png the reference (cropped to its screen) and the screen, side by side, at one size;
|
|
15
|
-
// overlay.png the screen with the reference faintly over it, at the same size,
|
|
16
|
-
// so a box that moved, a gap that closed or a size that drifted shows.
|
|
17
|
-
// --mirror compares against the reference flipped, for a screen whose layout turned.
|
|
18
|
-
// Sizes are shares of the screen; "off" is more than 15% apart, or a box more
|
|
19
|
-
// than 3% of the screen away. Exit 0 whenever both pictures were read, whatever is
|
|
20
|
-
// off: it reports, the critic decides. Exit 1 when a picture could not be read,
|
|
21
|
-
// 2 when called wrong. A picture that could not be drawn is said on stderr and
|
|
22
|
-
// leaves the exit alone; diff.json is already written.
|
|
23
|
-
// A tall capture is read on its first screen only, and the pictures show that
|
|
24
|
-
// first screen and nothing below it. --out may be relative: it is taken from
|
|
25
|
-
// where this is run, and the pictures land beside diff.json.
|
|
26
|
-
import { spawnSync } from "node:child_process";
|
|
27
|
-
import { mkdirSync, writeFileSync } from "node:fs";
|
|
28
|
-
import { dirname, join, resolve } from "node:path";
|
|
29
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
30
|
-
|
|
31
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
32
|
-
const args = process.argv.slice(2);
|
|
33
|
-
const flag = (name) => {
|
|
34
|
-
const i = args.indexOf(`--${name}`);
|
|
35
|
-
return i === -1 ? null : args.splice(i, 2)[1];
|
|
36
|
-
};
|
|
37
|
-
const has = (name) => {
|
|
38
|
-
const i = args.indexOf(`--${name}`);
|
|
39
|
-
return i === -1 ? false : (args.splice(i, 1), true);
|
|
40
|
-
};
|
|
41
|
-
const out = flag("out");
|
|
42
|
-
const mirror = has("mirror");
|
|
43
|
-
if (args.length !== 2 || !out) {
|
|
44
|
-
console.error("usage: node layout-diff.mjs <reference picture> <screen capture> --out <folder> [--mirror]");
|
|
45
|
-
process.exit(2);
|
|
46
|
-
}
|
|
47
|
-
const [refFile, screenFile] = args.map((f) => resolve(f));
|
|
48
|
-
const outDir = resolve(out);
|
|
49
|
-
mkdirSync(outDir, { recursive: true });
|
|
50
|
-
|
|
51
|
-
function read(file) {
|
|
52
|
-
const r = spawnSync(process.execPath, [join(here, "measure.mjs"), file, "--lines"], { encoding: "utf8", maxBuffer: 1 << 26 });
|
|
53
|
-
if (r.status !== 0) {
|
|
54
|
-
console.error(`layout-diff: could not read ${file}: ${r.stderr.trim()}`);
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
return JSON.parse(r.stdout);
|
|
58
|
-
}
|
|
59
|
-
const ref = read(refFile);
|
|
60
|
-
const screen = read(screenFile);
|
|
61
|
-
|
|
62
|
-
// Boxes as [x, y, w, h] shares of the screen read; the reference's flipped when it turned.
|
|
63
|
-
const flip = (b) => (mirror ? [1 - b[0] - b[2], b[1], b[2], b[3]] : b);
|
|
64
|
-
const lines = (m, f = (b) => b) => (m.type?.lines || []).map((l) => ({ size: l.size, px: l.px1440, box: f(l.box), case: l.case }));
|
|
65
|
-
const R = lines(ref, flip);
|
|
66
|
-
const S = lines(screen);
|
|
67
|
-
const round = (n, d = 3) => (n == null ? null : Math.round(n * 10 ** d) / 10 ** d);
|
|
68
|
-
const ratioOff = (a, b) => a != null && b != null && a > 0 && b > 0 && Math.max(a / b, b / a) > 1.15;
|
|
69
|
-
const rows = [];
|
|
70
|
-
const row = (what, r, s, off) => rows.push({ what, reference: r, screen: s, off: Boolean(off) });
|
|
71
|
-
|
|
72
|
-
const rd = ref.type?.display, sd = screen.type?.display;
|
|
73
|
-
row("headline size (share of the screen's height)", round(rd?.size), round(sd?.size), ratioOff(rd?.size, sd?.size));
|
|
74
|
-
if (rd?.box && sd?.box) {
|
|
75
|
-
const rb = flip(rd.box);
|
|
76
|
-
const far = Math.max(...rb.map((v, i) => Math.abs(v - sd.box[i]))) > 0.03;
|
|
77
|
-
row("headline box [x, y, w, h]", rb.map((v) => round(v)), sd.box.map((v) => round(v)), far);
|
|
78
|
-
}
|
|
79
|
-
row("headline lines", ref.type?.headline?.lines ?? null, screen.type?.headline?.lines ?? null, (ref.type?.headline?.lines ?? 0) !== (screen.type?.headline?.lines ?? 0));
|
|
80
|
-
row("type scale (headline over body)", ref.type?.scale ?? null, screen.type?.scale ?? null, ratioOff(ref.type?.scale, screen.type?.scale));
|
|
81
|
-
const margins = (L) => (L.length ? { left: round(Math.min(...L.map((l) => l.box[0]))), right: round(1 - Math.max(...L.map((l) => l.box[0] + l.box[2]))), top: round(Math.min(...L.map((l) => l.box[1]))), bottom: round(1 - Math.max(...L.map((l) => l.box[1] + l.box[3]))) } : null);
|
|
82
|
-
const rm = margins(R), sm = margins(S);
|
|
83
|
-
for (const side of ["left", "right", "top", "bottom"]) if (rm && sm) row(`text margin, ${side}`, rm[side], sm[side], Math.abs(rm[side] - sm[side]) > 0.03 && ratioOff(rm[side] + 0.001, sm[side] + 0.001));
|
|
84
|
-
row("empty (%)", ref.traits?.empty ?? null, screen.traits?.empty ?? null, Math.abs((ref.traits?.empty ?? 0) - (screen.traits?.empty ?? 0)) > 15);
|
|
85
|
-
row("pictures (%)", ref.traits?.pictures ?? null, screen.traits?.pictures ?? null, Math.abs((ref.traits?.pictures ?? 0) - (screen.traits?.pictures ?? 0)) > 15);
|
|
86
|
-
row("small text blocks", ref.type?.small ?? null, screen.type?.small ?? null, (screen.type?.small ?? 0) > (ref.type?.small ?? 0) + 1);
|
|
87
|
-
|
|
88
|
-
// Each line of the screen matched to the nearest line of the reference of a like size.
|
|
89
|
-
const matched = S.map((s) => {
|
|
90
|
-
let best = null, cost = Infinity;
|
|
91
|
-
for (const r of R) {
|
|
92
|
-
const c = Math.hypot(s.box[0] - r.box[0], s.box[1] - r.box[1]) + Math.abs(Math.log(s.size / r.size));
|
|
93
|
-
if (c < cost) (cost = c), (best = r);
|
|
94
|
-
}
|
|
95
|
-
if (!best) return { screen: s, reference: null, off: true };
|
|
96
|
-
const moved = Math.hypot(s.box[0] - best.box[0], s.box[1] - best.box[1]);
|
|
97
|
-
return { screen: { px: s.px, box: s.box.map((v) => round(v)) }, reference: { px: best.px, box: best.box.map((v) => round(v)) }, moved: round(moved), off: moved > 0.03 || ratioOff(s.size, best.size) };
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
const off = rows.filter((r) => r.off).map((r) => r.what);
|
|
101
|
-
const report = { reference: refFile, screen: screenFile, mirror, off, measures: rows, lines: matched, unread: "pictures' boxes and the gaps between them are not measured here: the critic judges them on side.png and overlay.png" };
|
|
102
|
-
writeFileSync(join(outDir, "diff.json"), JSON.stringify(report, null, 1));
|
|
103
|
-
|
|
104
|
-
// The pictures: the reference cropped to the screen measure.mjs read, both at 1440 wide.
|
|
105
|
-
// That is the frame it found, else (a tall capture, firstScreen) the top 1440 by 900 share, else the whole.
|
|
106
|
-
const [fx, fy, fw, fh] = ref.frame?.box || [0, 0, ref.width, ref.firstScreen ? Math.round((ref.width * 900) / 1440) : ref.height];
|
|
107
|
-
const W = 1440, H = Math.round((W * fh) / fw);
|
|
108
|
-
const refLayer = (opacity) => `<div style="position:absolute;inset:0;overflow:hidden;opacity:${opacity}"><img src="${pathToFileURL(refFile)}" style="position:absolute;left:${(-fx * W) / fw}px;top:${(-fy * W) / fw}px;width:${(ref.width * W) / fw}px;${mirror ? "transform:scaleX(-1);transform-origin:" + ((fx + fw / 2) * W) / fw + "px 0;" : ""}"></div>`;
|
|
109
|
-
const shot = `<img src="${pathToFileURL(screenFile)}" style="position:absolute;inset:0;width:${W}px;height:${H}px;object-fit:cover;object-position:top">`;
|
|
110
|
-
const page = (body, w) => `<!doctype html><html><head><title>ready</title><style>*{margin:0}body{width:${w}px;background:#777}.f{position:relative;width:${W}px;height:${H}px;overflow:hidden;display:inline-block;vertical-align:top}</style></head><body>${body}</body></html>`;
|
|
111
|
-
writeFileSync(join(outDir, "side.html"), page(`<div class="f">${refLayer(1)}</div><div class="f" style="margin-left:20px">${shot}</div>`, W * 2 + 20));
|
|
112
|
-
writeFileSync(join(outDir, "overlay.html"), page(`<div class="f">${shot}${refLayer(0.4)}</div>`, W));
|
|
113
|
-
for (const [name, w] of [["side", W * 2 + 20], ["overlay", W]]) {
|
|
114
|
-
const c = spawnSync(process.execPath, [join(here, "capture.mjs"), pathToFileURL(join(outDir, `${name}.html`)).href, "--out", join(outDir, `${name}.png`), "--width", String(w), "--clip", `0,0,${w},${H}`], { encoding: "utf8" });
|
|
115
|
-
if (c.status !== 0) console.error(`layout-diff: ${name}.png not drawn: ${c.stderr.trim()}`);
|
|
116
|
-
}
|
|
117
|
-
console.log(off.length ? `off: ${off.join("; ")}` : "nothing measured is off");
|
|
118
|
-
console.log(`lines off: ${matched.filter((m) => m.off).length} of ${matched.length}. ${join(outDir, "diff.json")}, side.png, overlay.png`);
|
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: design-families
|
|
3
|
-
description: >
|
|
4
|
-
Optional. Sort a big or messy moodboard (a large Figma board, a folder, a
|
|
5
|
-
wide search) into families: groups of references that look alike from across
|
|
6
|
-
a room. Every reference is measured and tagged, sorted by script, checked by
|
|
7
|
-
eye, and named for what is seen. The families become the headings of the
|
|
8
|
-
board design-direction shows; nothing is dropped, since a reference they
|
|
9
|
-
like can come from any family. Call it by hand, or when
|
|
10
|
-
design or design-moodboard offers it for a board over about 60 references.
|
|
11
|
-
Never worth it for a board someone already curated to a few dozen.
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
# Design families
|
|
15
|
-
|
|
16
|
-
**Needs:** `docs/design/design-moodboard.md`
|
|
17
|
-
**Uses if there:** `docs/design/design-brief.md`
|
|
18
|
-
**Writes:** `docs/design/design-families.md`
|
|
19
|
-
|
|
20
|
-
One job: sort a board into looks so choosing is easy. It reads and sorts the board; it builds no screens, and it never narrows it: every family stays on the board `design-direction` shows, as its headings.
|
|
21
|
-
|
|
22
|
-
Comes out:
|
|
23
|
-
|
|
24
|
-
- **`docs/design/design-families.md`**, committed: each family named, what it shares, and how big it is.
|
|
25
|
-
- **In Figma**, for a Figma board: a new page, `Families`, with one section per family holding copies of its cards. Their own pages are never moved or changed.
|
|
26
|
-
- **`.longbeard/design/families/`**, gitignored: `profiles.json`, `tags.tsv`, one TSV per family, the families page.
|
|
27
|
-
|
|
28
|
-
**At every stop,** say what is new and the one question, in up to five lines: a path or a sheet instead of pasted content, one line per option, nothing they already know.
|
|
29
|
-
|
|
30
|
-
## Gate
|
|
31
|
-
|
|
32
|
-
1. No board → `design-moodboard` first, or they give one now (a Figma link, a folder, a list of links).
|
|
33
|
-
2. Under about 60 references → say a board this size is easier to choose from as it is, and stop unless they insist.
|
|
34
|
-
3. A Figma board of hundreds → ask once, "The whole file, or one page or section?", and offer to read only cards their own tags mark as screens. Reading and tagging 1,300 cards cost about 800K tokens.
|
|
35
|
-
|
|
36
|
-
A board `design-moodboard` already read has its captures in `.longbeard/design/moodboard/refs/` and `board.md`. Otherwise run `design-moodboard` on it first: it reads the board (Figma originals, crops from shared sheets, captures for links) and keeps every card, with no picker.
|
|
37
|
-
|
|
38
|
-
## 1. Measure, in one browser run
|
|
39
|
-
|
|
40
|
-
`links.tsv` (`name<TAB>link`) for the keeps with a live page, then:
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
node <skill>/scripts/measure.mjs .longbeard/design/moodboard/refs --links .longbeard/design/families/links.tsv --profiles .longbeard/design/families/profiles.json --jobs 6
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
From each picture: how light, how empty, how loud, how busy, its colours, and where things sit on a 6×4 grid. From a live page: the largest type and where it sits, what the screen is made of, its fonts, gradients and patterns. A screen on a presentation surround is measured inside the surround. Never one call per image, and never read the profiles into the chat.
|
|
47
|
-
|
|
48
|
-
## 2. Tag what numbers cannot see
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
node <skill>/scripts/tag.mjs .longbeard/design/families/profiles.json --sheets <scratch>/tag
|
|
52
|
-
node <skill>/scripts/tag.mjs .longbeard/design/families/profiles.json .longbeard/design/families/tags.tsv
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
The first makes sheets of 16 untagged keeps and prints the vocabulary, one vocabulary in two layers:
|
|
56
|
-
|
|
57
|
-
- **The look**, sorted on, stored in `tags`: picture, photo, type, weight, layout, colour, surface, scale, and `motion` (none, kinetic, blur-grain, ui, repetition) for gifs, videos and live pages.
|
|
58
|
-
- **What it is and is for**, stored in `about`, checked but never sorted on: format, domain, mood, hue, density, and `shows` (portrait, close-crop, landscape, still-life, classical-art, cutout, type-only), what the picture shows. It is what a brief and a search pick references by.
|
|
59
|
-
|
|
60
|
-
Write a header row naming the columns (`name<TAB>picture<TAB>…<TAB>scale<TAB>motion<TAB>format<TAB>domain<TAB>mood<TAB>hue<TAB>density<TAB>note`, any order), then one row per keep from the sheets. The eight look fields are required; motion, the about fields and the note are optional, an empty cell when not seen. A row without a header is the old one: name, the eight look fields, an optional note. A header can also name one `line` column: the keep's tags as one flat line of words, the way people keep them by hand, look first, then ` · `, then about: `photo colour serif weight:bold split muted grain large kinetic · web-hero fashion calm red airy portrait`. It fills the fields the cells leave empty; a field in both is refused. A word in two fields (today none, ui, collage, mono, duotone, bold, editorial) is written `field:word`, as `type:mono` or `mood:editorial`; bare, or in no field, it refuses the merge and is named. Leave none out: a line without picture, photo or motion reads them as none. Every tool reads such a line with `parseTagLine` from `tag.mjs`, and writes one with `formatTagLine`. The second command checks every word against its field. Their own board tags seed the rows: map each to the vocabulary and tag only what is left. Tag what is there, never what is good. On a big board, split the sheets across a few agents.
|
|
61
|
-
|
|
62
|
-
## 3. Sort, then the eye
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
node <skill>/scripts/families.mjs .longbeard/design/families/profiles.json --board .longbeard/design/families/board.md --sliders "loud=2,picture=4,rich=2,cool=2,dense=2"
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
The sliders are the design brief's personality, copied from its `personality:` line (`picture-led` is `picture`; `playful` and `new` are passed over, since a picture cannot tell them: judge those by eye in step 4). It joins the closest references first and stops when groups no longer look alike, so outliers stay strays. A wide gap on what is seen first (how empty, how loud, type size, where things sit, what the picture is) keeps two apart; light or dark does not. A bin far bigger than the rest is sorted again on its own and said; one it cannot split is sorted alone with `--only .longbeard/design/families/families/f3.tsv --spread 0.4` (its parts land in `families/families/f3-split/`). `--spread` lower splits finer.
|
|
69
|
-
|
|
70
|
-
Then check each family by eye on contact sheets, never picture by picture:
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
node <skill>/scripts/contact-sheet.mjs .longbeard/design/families/families/f1.tsv --out <scratch>/f1 --contain
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
- Split a family that holds two looks, merge two that are one, place each stray. Strays are often the most distinctive references: never drop one for being a stray.
|
|
77
|
-
- **Name each family for what is seen**, in words a person outside design would use ("one huge word is the picture", "dark app pages, headline centred"). If the only honest name is a number ("dark, all picture"), it is a bin: break it up.
|
|
78
|
-
- As many families as there are looks. Never merge to reach a number.
|
|
79
|
-
- On hundreds of references: check each family's six most typical now, and every member of a family once it is taken.
|
|
80
|
-
|
|
81
|
-
## 4. Show them, once
|
|
82
|
-
|
|
83
|
-
The families page, each family as its six most typical, its size and what it shares:
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
node <skill>/scripts/moodboard.mjs .longbeard/design/families/board.md --overview 6 --out .longbeard/design/families/families.html
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
For a Figma board, also build the `Families` page with `use_figma` (load `figma-use` first): a section per family, named, with copies of its cards, most typical first. Read the names back from the nodes.
|
|
90
|
-
|
|
91
|
-
In the same message, one line per family: its name, what the eye changed from the numbers, and, as hints only, which fit the design brief's personality, which look like its "never", and which rely on pictures they do not have. Where what they chose sits far from what they said ("you said quiet; your board is loud"), say it once. Then:
|
|
92
|
-
|
|
93
|
-
> These are the headings of your board from here on; every reference stays on it. Note any family that looks like two, or belongs with another, or say go.
|
|
94
|
-
|
|
95
|
-
- **A split or merge note:** apply it, show the page again. `families.mjs` will not overwrite a board: remove `.longbeard/design/families/board.md` before sorting again.
|
|
96
|
-
- **Go:** write the doc.
|
|
97
|
-
|
|
98
|
-
## Write `docs/design/design-families.md`
|
|
99
|
-
|
|
100
|
-
```markdown
|
|
101
|
-
# Families: <product>
|
|
102
|
-
|
|
103
|
-
<n> references sorted into <n> families and <n> strays.
|
|
104
|
-
|
|
105
|
-
## <family name>
|
|
106
|
-
<what its members share, in one or two lines: how much type against picture, how empty, how loud, how pictures are treated> · <n> references
|
|
107
|
-
|
|
108
|
-
## <family name>
|
|
109
|
-
…
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
No names, links or paths. The members of each family are in `.longbeard/design/families/families/f<n>.tsv`, and `.longbeard/design/families/board.md` holds every card under its family: the board `design-direction` shows.
|
|
113
|
-
|
|
114
|
-
Then the next step in one line: `design-direction`.
|
|
115
|
-
|
|
116
|
-
## A library that grows
|
|
117
|
-
|
|
118
|
-
When new references arrive after the families are named, add them without sorting again: nothing already in a family moves, and the names stay. Measure and tag only the new keeps into the same `profiles.json` (steps 1 and 2), then:
|
|
119
|
-
|
|
120
|
-
```
|
|
121
|
-
node <skill>/scripts/families.mjs .longbeard/design/families/profiles.json --assign .longbeard/design/families/families.json
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Every reference in no family is new. Each joins the nearest family when it sits within `--spread`, with a confidence from 0 to 1 and its 5 nearest references already in families. The new ones that join nothing are sorted among themselves: a group of three or more is a **seed**, a proposed new family; the rest are strays with their nearest family. It writes `assign.json` and never changes `families.json`.
|
|
125
|
-
|
|
126
|
-
- Check each join by eye on a contact sheet beside its family, low confidence first. Move one that does not belong.
|
|
127
|
-
- Name each seed for what is seen, as in step 3, or fold it into a family by eye.
|
|
128
|
-
- Place each stray as in step 3.
|
|
129
|
-
- Show only what changed: which family each new reference went to, and any new family. Then update `docs/design/design-families.md`: sizes, and any new family.
|
|
130
|
-
|
|
131
|
-
Sort the whole pool again only when they ask, or when the new references outnumber the ones already sorted.
|
|
132
|
-
|
|
133
|
-
## Do not
|
|
134
|
-
|
|
135
|
-
- Run on a curated board of a few dozen without being asked.
|
|
136
|
-
- Move, rename or delete anything on their own Figma pages.
|
|
137
|
-
- Pick a family for them, ask them to take one, or hide one because it looks like their "never". Every family stays on the board.
|
|
138
|
-
- Sort before every keep is measured and tagged, or read profiles into the chat.
|
|
139
|
-
- Sort a named pool from scratch to add a few new references: use `--assign`.
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Build labelled contact sheets from a TSV of label\timageURL. The image can
|
|
3
|
-
// be a local file too, so a family's references are sorted by eye from a few
|
|
4
|
-
// sheets of thumbnails, not opened one at a time.
|
|
5
|
-
// Writes JPEG grids (~36 per sheet) into an output directory (scratch, not .longbeard/design/).
|
|
6
|
-
// Viewing listing thumbnails is allowed; this is not a capture.
|
|
7
|
-
//
|
|
8
|
-
// node contact-sheet.mjs candidates.tsv --out /tmp/hunt-sheets
|
|
9
|
-
// node contact-sheet.mjs family-f3.tsv --out <scratch>/f3 --contain # TSV: label<TAB>refs/name.jpg
|
|
10
|
-
import { spawn } from "node:child_process";
|
|
11
|
-
import {
|
|
12
|
-
existsSync,
|
|
13
|
-
mkdirSync,
|
|
14
|
-
mkdtempSync,
|
|
15
|
-
readFileSync,
|
|
16
|
-
rmSync,
|
|
17
|
-
writeFileSync,
|
|
18
|
-
} from "node:fs";
|
|
19
|
-
import { tmpdir } from "node:os";
|
|
20
|
-
import { join, resolve } from "node:path";
|
|
21
|
-
import { pathToFileURL } from "node:url";
|
|
22
|
-
|
|
23
|
-
const args = process.argv.slice(2);
|
|
24
|
-
const flag = (name, def) => {
|
|
25
|
-
const i = args.indexOf(`--${name}`);
|
|
26
|
-
if (i === -1) return def;
|
|
27
|
-
const v = args[i + 1];
|
|
28
|
-
args.splice(i, 2);
|
|
29
|
-
return v;
|
|
30
|
-
};
|
|
31
|
-
const tsvPath = args[0];
|
|
32
|
-
const outDir = resolve(flag("out", "") || "");
|
|
33
|
-
const perSheet = Math.max(1, Number(flag("per", "36")) || 36);
|
|
34
|
-
const cols = Math.min(8, Math.max(1, Number(flag("cols", "6")) || 6));
|
|
35
|
-
const containAt = args.indexOf("--contain");
|
|
36
|
-
const contain = containAt !== -1;
|
|
37
|
-
if (contain) args.splice(containAt, 1);
|
|
38
|
-
if (!tsvPath || !outDir) {
|
|
39
|
-
console.error("usage: node contact-sheet.mjs candidates.tsv --out <scratch>/sheets [--per 36] [--cols 6] [--contain]");
|
|
40
|
-
process.exit(2);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const lines = readFileSync(tsvPath, "utf8")
|
|
44
|
-
.split(/\r?\n/)
|
|
45
|
-
.map((l) => l.trim())
|
|
46
|
-
.filter(Boolean)
|
|
47
|
-
.map((l) => {
|
|
48
|
-
// label\timageURL, and any columns after that (a listing URL) are ignored.
|
|
49
|
-
const cols = l.split("\t").map((c) => c.trim());
|
|
50
|
-
if (cols.length === 1) return { label: l, url: l };
|
|
51
|
-
return { label: cols[0], url: cols[1] };
|
|
52
|
-
})
|
|
53
|
-
.map((r) => (/^https?:\/\//i.test(r.url) || !existsSync(r.url) ? r : { ...r, url: pathToFileURL(resolve(r.url)).href }))
|
|
54
|
-
.filter((r) => /^(https?|file):\/\//i.test(r.url));
|
|
55
|
-
|
|
56
|
-
if (!lines.length) {
|
|
57
|
-
console.error("no label\timageURL rows found");
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function findChrome() {
|
|
62
|
-
const env = process.env.CHROME_PATH;
|
|
63
|
-
// CHROME_PATH=none: run as if no browser were installed (a quick test run).
|
|
64
|
-
if (env === "none") return null;
|
|
65
|
-
if (env && existsSync(env)) return env;
|
|
66
|
-
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
67
|
-
const local = process.env.LOCALAPPDATA || "";
|
|
68
|
-
const pf = process.env.PROGRAMFILES || "C:\\Program Files";
|
|
69
|
-
const pf86 = process.env["PROGRAMFILES(X86)"] || "C:\\Program Files (x86)";
|
|
70
|
-
const candidates = [
|
|
71
|
-
join(pf, "Google/Chrome/Application/chrome.exe"),
|
|
72
|
-
join(pf86, "Google/Chrome/Application/chrome.exe"),
|
|
73
|
-
join(local, "Google/Chrome/Application/chrome.exe"),
|
|
74
|
-
join(pf, "Microsoft/Edge/Application/msedge.exe"),
|
|
75
|
-
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
76
|
-
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
77
|
-
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
78
|
-
join(home, "Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),
|
|
79
|
-
"/usr/bin/google-chrome",
|
|
80
|
-
"/usr/bin/google-chrome-stable",
|
|
81
|
-
"/usr/bin/chromium",
|
|
82
|
-
"/usr/bin/chromium-browser",
|
|
83
|
-
];
|
|
84
|
-
return candidates.find((path) => path && existsSync(path)) || null;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
88
|
-
const exe = findChrome();
|
|
89
|
-
if (!exe) {
|
|
90
|
-
console.error("No Chrome/Edge/Chromium found. Install one or set CHROME_PATH.");
|
|
91
|
-
process.exit(1);
|
|
92
|
-
}
|
|
93
|
-
if (typeof WebSocket === "undefined") {
|
|
94
|
-
console.error("Node 22+ is required.");
|
|
95
|
-
process.exit(1);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
const dir = mkdtempSync(join(tmpdir(), "hunt-sheet-"));
|
|
99
|
-
let proc;
|
|
100
|
-
const drop = () => {
|
|
101
|
-
try {
|
|
102
|
-
if (proc?.pid) process.kill(proc.pid, "SIGKILL");
|
|
103
|
-
} catch {}
|
|
104
|
-
try {
|
|
105
|
-
rmSync(dir, { recursive: true, force: true });
|
|
106
|
-
} catch {}
|
|
107
|
-
};
|
|
108
|
-
process.once("exit", drop);
|
|
109
|
-
|
|
110
|
-
proc = spawn(
|
|
111
|
-
exe,
|
|
112
|
-
[
|
|
113
|
-
"--headless=new",
|
|
114
|
-
"--remote-debugging-port=0",
|
|
115
|
-
`--user-data-dir=${dir}`,
|
|
116
|
-
"--no-first-run",
|
|
117
|
-
"--hide-scrollbars",
|
|
118
|
-
"--mute-audio",
|
|
119
|
-
"--force-color-profile=srgb",
|
|
120
|
-
"--window-size=1600,1200",
|
|
121
|
-
"about:blank",
|
|
122
|
-
],
|
|
123
|
-
{ stdio: ["ignore", "ignore", "pipe"] },
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
let buf = "";
|
|
127
|
-
const wsUrl = await new Promise((resolveWs, reject) => {
|
|
128
|
-
const t = setTimeout(() => reject(new Error("Chrome did not start")), 20000);
|
|
129
|
-
proc.stderr.on("data", (d) => {
|
|
130
|
-
buf += d.toString();
|
|
131
|
-
const m = buf.match(/DevTools listening on (ws:\/\/[^\s]+)/);
|
|
132
|
-
if (m) {
|
|
133
|
-
clearTimeout(t);
|
|
134
|
-
resolveWs(m[1]);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
proc.on("exit", (code) => {
|
|
138
|
-
clearTimeout(t);
|
|
139
|
-
reject(new Error(`Chrome exited ${code}`));
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
const ws = new WebSocket(wsUrl);
|
|
144
|
-
await new Promise((res, rej) => {
|
|
145
|
-
ws.onopen = res;
|
|
146
|
-
ws.onerror = () => rej(new Error("CDP socket failed"));
|
|
147
|
-
});
|
|
148
|
-
let nextId = 1;
|
|
149
|
-
const pending = new Map();
|
|
150
|
-
ws.onmessage = (ev) => {
|
|
151
|
-
const msg = JSON.parse(typeof ev.data === "string" ? ev.data : Buffer.from(ev.data).toString());
|
|
152
|
-
if (msg.id && pending.has(msg.id)) {
|
|
153
|
-
const { resolve: ok, reject: bad } = pending.get(msg.id);
|
|
154
|
-
pending.delete(msg.id);
|
|
155
|
-
if (msg.error) bad(new Error(msg.error.message));
|
|
156
|
-
else ok(msg.result);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const send = (method, params = {}, sessionId, timeoutMs = 30000) => {
|
|
160
|
-
const id = nextId++;
|
|
161
|
-
return new Promise((resolveSend, reject) => {
|
|
162
|
-
const timer = setTimeout(() => {
|
|
163
|
-
pending.delete(id);
|
|
164
|
-
reject(new Error(`CDP timeout: ${method}`));
|
|
165
|
-
}, timeoutMs);
|
|
166
|
-
pending.set(id, {
|
|
167
|
-
resolve: (v) => {
|
|
168
|
-
clearTimeout(timer);
|
|
169
|
-
resolveSend(v);
|
|
170
|
-
},
|
|
171
|
-
reject: (e) => {
|
|
172
|
-
clearTimeout(timer);
|
|
173
|
-
reject(e);
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
ws.send(JSON.stringify(sessionId ? { id, method, params, sessionId } : { id, method, params }));
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const { targetId } = await send("Target.createTarget", { url: "about:blank" });
|
|
181
|
-
const { sessionId } = await send("Target.attachToTarget", { targetId, flatten: true });
|
|
182
|
-
const page = (method, params, timeoutMs) => send(method, params, sessionId, timeoutMs);
|
|
183
|
-
|
|
184
|
-
await page("Page.enable");
|
|
185
|
-
await page("Runtime.enable");
|
|
186
|
-
await page("Emulation.setDeviceMetricsOverride", {
|
|
187
|
-
width: 1600,
|
|
188
|
-
height: 1200,
|
|
189
|
-
deviceScaleFactor: 1,
|
|
190
|
-
mobile: false,
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
mkdirSync(outDir, { recursive: true });
|
|
194
|
-
const sheets = [];
|
|
195
|
-
for (let i = 0; i < lines.length; i += perSheet) {
|
|
196
|
-
sheets.push(lines.slice(i, i + perSheet));
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const esc = (s) =>
|
|
200
|
-
String(s)
|
|
201
|
-
.replace(/&/g, "&")
|
|
202
|
-
.replace(/</g, "<")
|
|
203
|
-
.replace(/>/g, ">")
|
|
204
|
-
.replace(/"/g, """);
|
|
205
|
-
|
|
206
|
-
for (let s = 0; s < sheets.length; s++) {
|
|
207
|
-
const cells = sheets[s]
|
|
208
|
-
.map(
|
|
209
|
-
(r) =>
|
|
210
|
-
`<figure><img src="${esc(r.url)}" loading="eager"><figcaption>${esc(r.label)}</figcaption></figure>`,
|
|
211
|
-
)
|
|
212
|
-
.join("\n");
|
|
213
|
-
const html = `<!doctype html><meta charset=utf-8>
|
|
214
|
-
<style>
|
|
215
|
-
body { margin: 16px; background: #1a1a1a; color: #eee; font: 11px/1.2 system-ui, sans-serif; }
|
|
216
|
-
.grid { display: grid; grid-template-columns: repeat(${cols}, 1fr); gap: 10px; }
|
|
217
|
-
figure { margin: 0; background: #2a2a2a; border-radius: 4px; overflow: hidden; }
|
|
218
|
-
img { display: block; width: 100%; height: ${contain ? Math.round(1200 / cols) : 140}px; object-fit: ${contain ? "contain" : "cover"}; background: #111; }
|
|
219
|
-
figcaption { padding: 6px 8px; word-break: break-word; max-height: 2.4em; overflow: hidden; }
|
|
220
|
-
</style>
|
|
221
|
-
<div class="grid">${cells}</div>
|
|
222
|
-
<script>
|
|
223
|
-
Promise.all([...document.images].map((img) => img.decode().catch(() => {}))).then(() => {
|
|
224
|
-
document.title = "ready";
|
|
225
|
-
});
|
|
226
|
-
</script>`;
|
|
227
|
-
const htmlPath = join(dir, `sheet-${s + 1}.html`);
|
|
228
|
-
writeFileSync(htmlPath, html);
|
|
229
|
-
await page("Page.navigate", { url: pathToFileURL(htmlPath).href }, 30000);
|
|
230
|
-
await sleep(500);
|
|
231
|
-
for (let i = 0; i < 60; i++) {
|
|
232
|
-
const title = (
|
|
233
|
-
await page("Runtime.evaluate", { expression: "document.title", returnByValue: true })
|
|
234
|
-
).result.value;
|
|
235
|
-
if (title === "ready") break;
|
|
236
|
-
await sleep(150);
|
|
237
|
-
}
|
|
238
|
-
await sleep(400);
|
|
239
|
-
const metrics = await page("Page.getLayoutMetrics");
|
|
240
|
-
const size = metrics.cssContentSize || metrics.contentSize;
|
|
241
|
-
const width = Math.max(1, Math.ceil(size.width || 1600));
|
|
242
|
-
const height = Math.max(1, Math.min(Math.ceil(size.height || 1200), 8000));
|
|
243
|
-
const { data } = await page(
|
|
244
|
-
"Page.captureScreenshot",
|
|
245
|
-
{
|
|
246
|
-
format: "jpeg",
|
|
247
|
-
quality: 80,
|
|
248
|
-
captureBeyondViewport: true,
|
|
249
|
-
clip: { x: 0, y: 0, width, height, scale: 1 },
|
|
250
|
-
},
|
|
251
|
-
60000,
|
|
252
|
-
);
|
|
253
|
-
const outPath = join(outDir, `sheet-${String(s + 1).padStart(2, "0")}.jpg`);
|
|
254
|
-
writeFileSync(outPath, Buffer.from(data, "base64"));
|
|
255
|
-
console.log(outPath);
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
drop();
|
|
259
|
-
process.exit(0);
|