frameboard 0.30.0 → 0.32.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/dist/cli.js +1385 -245
- package/dist/client/assets/index-B3-XL1cU.js +115 -0
- package/dist/client/assets/index-D_ZnMRyk.css +2 -0
- package/dist/client/index.html +2 -2
- package/dist/hook.js +6 -2
- package/package.json +1 -1
- package/dist/client/assets/index-DLAfZ8l-.js +0 -114
- package/dist/client/assets/index-c8ObdNHS.css +0 -2
package/dist/cli.js
CHANGED
|
@@ -3033,6 +3033,7 @@ const EXIT_CODES = {
|
|
|
3033
3033
|
"browser-not-found": 9,
|
|
3034
3034
|
"font-missing": 10,
|
|
3035
3035
|
"fit-unbounded": 10,
|
|
3036
|
+
"fit-scroll": 10,
|
|
3036
3037
|
"capture-too-large": 10,
|
|
3037
3038
|
"frame-locked": 11,
|
|
3038
3039
|
"stale-layout": 11,
|
|
@@ -3055,7 +3056,9 @@ const EXIT_CODES = {
|
|
|
3055
3056
|
"formatter-not-found": 9,
|
|
3056
3057
|
"references-stale": 14,
|
|
3057
3058
|
"page-file-load": 10,
|
|
3058
|
-
"image-missing": 10
|
|
3059
|
+
"image-missing": 10,
|
|
3060
|
+
"motion-missing": 10,
|
|
3061
|
+
"motion-unbounded": 10
|
|
3059
3062
|
};
|
|
3060
3063
|
var FrameboardError = class extends Error {
|
|
3061
3064
|
code;
|
|
@@ -3178,10 +3181,7 @@ async function acquire(lock, timeoutMs) {
|
|
|
3178
3181
|
if (!isCode(error, "EEXIST")) throw error;
|
|
3179
3182
|
}
|
|
3180
3183
|
const stale = await staleContent(lock);
|
|
3181
|
-
if (stale !== null)
|
|
3182
|
-
await breakLock(lock, stale);
|
|
3183
|
-
continue;
|
|
3184
|
-
}
|
|
3184
|
+
if (stale !== null && await breakLock(lock, stale)) continue;
|
|
3185
3185
|
if (Date.now() >= deadline) throw new FrameboardError("lock-timeout", `Another writer held ${lock} for more than ${timeoutMs} ms.`, { path: lock });
|
|
3186
3186
|
await setTimeout$1(LOCK_POLL_MS);
|
|
3187
3187
|
}
|
|
@@ -3204,26 +3204,72 @@ async function staleContent(lock) {
|
|
|
3204
3204
|
return Number.isInteger(pid) && !isAlive(pid) ? text : null;
|
|
3205
3205
|
}
|
|
3206
3206
|
/**
|
|
3207
|
-
* Breaks a stale lock
|
|
3208
|
-
* lock
|
|
3209
|
-
*
|
|
3207
|
+
* Breaks a stale lock under a guard, so one writer at a time re-reads the
|
|
3208
|
+
* lock and retires it only while it still holds the content judged stale.
|
|
3209
|
+
* Without the guard, a second breaker could rename aside the lock a first
|
|
3210
|
+
* one had just taken, and put it back after its owner released it, leaving
|
|
3211
|
+
* a lock nobody holds. A guard a crashed breaker left behind ages out like a
|
|
3212
|
+
* lock. False while another breaker holds the guard, so the caller waits.
|
|
3210
3213
|
*/
|
|
3211
3214
|
async function breakLock(lock, judged) {
|
|
3212
|
-
const
|
|
3215
|
+
const guard = `${lock.slice(0, -5)}.break${LOCK_SUFFIX}`;
|
|
3216
|
+
const nonce = randomBytes(8).toString("hex");
|
|
3213
3217
|
try {
|
|
3214
|
-
await
|
|
3218
|
+
const handle = await open(guard, "wx");
|
|
3219
|
+
await handle.writeFile(nonce);
|
|
3220
|
+
await handle.close();
|
|
3221
|
+
} catch (error) {
|
|
3222
|
+
if (!isCode(error, "EEXIST")) throw error;
|
|
3223
|
+
await clearAgedGuard(guard);
|
|
3224
|
+
return false;
|
|
3225
|
+
}
|
|
3226
|
+
try {
|
|
3227
|
+
if (await readOrNull$1(lock) === judged) await retire(lock, judged);
|
|
3228
|
+
return true;
|
|
3229
|
+
} finally {
|
|
3230
|
+
if (await readOrNull$1(guard) === nonce) await rm(guard, { force: true });
|
|
3231
|
+
}
|
|
3232
|
+
}
|
|
3233
|
+
async function clearAgedGuard(guard) {
|
|
3234
|
+
let text;
|
|
3235
|
+
let modifiedAt;
|
|
3236
|
+
try {
|
|
3237
|
+
[text, {mtimeMs: modifiedAt}] = await Promise.all([readFile(guard, "utf8"), stat(guard)]);
|
|
3238
|
+
} catch (error) {
|
|
3239
|
+
if (isCode(error, "ENOENT")) return;
|
|
3240
|
+
throw error;
|
|
3241
|
+
}
|
|
3242
|
+
if (Date.now() - modifiedAt > LOCK_STALE_MS) await retire(guard, text);
|
|
3243
|
+
}
|
|
3244
|
+
/**
|
|
3245
|
+
* Removes a file by renaming it aside, so of two writers retiring it only
|
|
3246
|
+
* the first rename wins. A rename that caught a newer file, written since
|
|
3247
|
+
* the content was judged, puts that file back.
|
|
3248
|
+
*/
|
|
3249
|
+
async function retire(path, judged) {
|
|
3250
|
+
const aside = `${path.slice(0, -5)}.${randomBytes(4).toString("hex")}.broken${LOCK_SUFFIX}`;
|
|
3251
|
+
try {
|
|
3252
|
+
await rename(path, aside);
|
|
3215
3253
|
} catch (error) {
|
|
3216
3254
|
if (isCode(error, "ENOENT")) return;
|
|
3217
3255
|
throw error;
|
|
3218
3256
|
}
|
|
3219
3257
|
try {
|
|
3220
|
-
if (await readFile(aside, "utf8") !== judged) await link(aside,
|
|
3258
|
+
if (await readFile(aside, "utf8") !== judged) await link(aside, path).catch((error) => {
|
|
3221
3259
|
if (!isCode(error, "EEXIST")) throw error;
|
|
3222
3260
|
});
|
|
3223
3261
|
} finally {
|
|
3224
3262
|
await rm(aside, { force: true });
|
|
3225
3263
|
}
|
|
3226
3264
|
}
|
|
3265
|
+
async function readOrNull$1(path) {
|
|
3266
|
+
try {
|
|
3267
|
+
return await readFile(path, "utf8");
|
|
3268
|
+
} catch (error) {
|
|
3269
|
+
if (isCode(error, "ENOENT")) return null;
|
|
3270
|
+
throw error;
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3227
3273
|
/** Removes the lock only while it still holds this writer's nonce. */
|
|
3228
3274
|
async function release$2(lock, nonce) {
|
|
3229
3275
|
try {
|
|
@@ -9050,6 +9096,25 @@ const FRAME_SIZES = {
|
|
|
9050
9096
|
}
|
|
9051
9097
|
};
|
|
9052
9098
|
/**
|
|
9099
|
+
* The widths each preset reads as, inclusive, so a 393 phone is a phone. The
|
|
9100
|
+
* preset's own width is the default a preview takes from outside its range.
|
|
9101
|
+
* They sit apart from `FRAME_SIZES`, whose entries spread into a frame's box.
|
|
9102
|
+
*/
|
|
9103
|
+
const PRESET_RANGES = {
|
|
9104
|
+
phone: {
|
|
9105
|
+
min: 320,
|
|
9106
|
+
max: 479
|
|
9107
|
+
},
|
|
9108
|
+
tablet: {
|
|
9109
|
+
min: 480,
|
|
9110
|
+
max: 1023
|
|
9111
|
+
},
|
|
9112
|
+
desktop: {
|
|
9113
|
+
min: 1024,
|
|
9114
|
+
max: Number.POSITIVE_INFINITY
|
|
9115
|
+
}
|
|
9116
|
+
};
|
|
9117
|
+
/**
|
|
9053
9118
|
* The devices the Frame tool and `--size` offer beside the three presets.
|
|
9054
9119
|
* The iPad Pro 11 and a 1440 desktop are the tablet and desktop presets, so
|
|
9055
9120
|
* neither repeats here.
|
|
@@ -9138,6 +9203,20 @@ const DEVICE_SIZES = [
|
|
|
9138
9203
|
group: "social",
|
|
9139
9204
|
width: 1200,
|
|
9140
9205
|
height: 627
|
|
9206
|
+
},
|
|
9207
|
+
{
|
|
9208
|
+
name: "video-landscape",
|
|
9209
|
+
label: "Video landscape",
|
|
9210
|
+
group: "video",
|
|
9211
|
+
width: 1920,
|
|
9212
|
+
height: 1080
|
|
9213
|
+
},
|
|
9214
|
+
{
|
|
9215
|
+
name: "video-portrait",
|
|
9216
|
+
label: "Video portrait",
|
|
9217
|
+
group: "video",
|
|
9218
|
+
width: 1080,
|
|
9219
|
+
height: 1920
|
|
9141
9220
|
}
|
|
9142
9221
|
];
|
|
9143
9222
|
/** Every size name, the three presets first, then the devices. */
|
|
@@ -9159,6 +9238,78 @@ function frameSizeOf(name) {
|
|
|
9159
9238
|
height
|
|
9160
9239
|
};
|
|
9161
9240
|
}
|
|
9241
|
+
/** The preset whose range holds a width, or none below the phone range. */
|
|
9242
|
+
function presetAt(width) {
|
|
9243
|
+
return Object.keys(PRESET_RANGES).filter(isFrameSizePreset).find((preset) => {
|
|
9244
|
+
const { min, max } = PRESET_RANGES[preset];
|
|
9245
|
+
return width >= min && width <= max;
|
|
9246
|
+
});
|
|
9247
|
+
}
|
|
9248
|
+
/**
|
|
9249
|
+
* The viewport height a frame's content is read at, being the height of the
|
|
9250
|
+
* preset whose range holds the width, or the desktop height below every
|
|
9251
|
+
* range. Reading at the box's own height lets content sized off the viewport
|
|
9252
|
+
* grow by that height on every fit.
|
|
9253
|
+
*/
|
|
9254
|
+
function referenceHeight(width) {
|
|
9255
|
+
return FRAME_SIZES[presetAt(width) ?? "desktop"].height;
|
|
9256
|
+
}
|
|
9257
|
+
// src/shared/frame-widths.ts
|
|
9258
|
+
/**
|
|
9259
|
+
* A layout entry's `widths` value as a clean list. Anything but an array of
|
|
9260
|
+
* objects each holding a positive integer `width` and `height`, with no width
|
|
9261
|
+
* repeated, reads as none, so a value no reader understands never refuses the
|
|
9262
|
+
* page's layout.
|
|
9263
|
+
*/
|
|
9264
|
+
function widthsOf(value) {
|
|
9265
|
+
if (!Array.isArray(value)) return [];
|
|
9266
|
+
const widths = [];
|
|
9267
|
+
for (const item of value) {
|
|
9268
|
+
if (typeof item !== "object" || item === null) return [];
|
|
9269
|
+
const { width, height } = item;
|
|
9270
|
+
if (!isSize(width) || !isSize(height)) return [];
|
|
9271
|
+
if (widths.some((linked) => linked.width === width)) return [];
|
|
9272
|
+
widths.push({
|
|
9273
|
+
width,
|
|
9274
|
+
height
|
|
9275
|
+
});
|
|
9276
|
+
}
|
|
9277
|
+
return widths;
|
|
9278
|
+
}
|
|
9279
|
+
function isSize(value) {
|
|
9280
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 1;
|
|
9281
|
+
}
|
|
9282
|
+
/**
|
|
9283
|
+
* Where each linked width draws: in a row at the frame's `y`, the first
|
|
9284
|
+
* `FRAME_GAP` past the frame's right edge and each next one past the last.
|
|
9285
|
+
*/
|
|
9286
|
+
function linkedBoxes(box, widths) {
|
|
9287
|
+
const boxes = [];
|
|
9288
|
+
let x = box.x + box.width;
|
|
9289
|
+
for (const { width, height } of widths) {
|
|
9290
|
+
x += 80;
|
|
9291
|
+
boxes.push({
|
|
9292
|
+
x,
|
|
9293
|
+
y: box.y,
|
|
9294
|
+
width,
|
|
9295
|
+
height
|
|
9296
|
+
});
|
|
9297
|
+
x += width;
|
|
9298
|
+
}
|
|
9299
|
+
return boxes;
|
|
9300
|
+
}
|
|
9301
|
+
/** The box holding a frame and every linked width it draws, the frame's own with none. */
|
|
9302
|
+
function drawnExtent(box, widths) {
|
|
9303
|
+
const boxes = linkedBoxes(box, widths);
|
|
9304
|
+
const last = boxes.at(-1);
|
|
9305
|
+
if (!last) return { ...box };
|
|
9306
|
+
return {
|
|
9307
|
+
x: box.x,
|
|
9308
|
+
y: box.y,
|
|
9309
|
+
width: last.x + last.width - box.x,
|
|
9310
|
+
height: Math.max(box.height, ...boxes.map(({ height }) => height))
|
|
9311
|
+
};
|
|
9312
|
+
}
|
|
9162
9313
|
// src/shared/records/board.ts
|
|
9163
9314
|
const boardFileSchema = looseObject({ version: literal(1) });
|
|
9164
9315
|
/** A project's own check rules, absent meaning the built-in rules alone. */
|
|
@@ -9187,7 +9338,12 @@ const layoutEntrySchema = looseObject({
|
|
|
9187
9338
|
hidden: boolean$1().optional(),
|
|
9188
9339
|
locked: boolean$1().optional(),
|
|
9189
9340
|
hugWidth: boolean$1().optional(),
|
|
9190
|
-
hugHeight: boolean$1().optional()
|
|
9341
|
+
hugHeight: boolean$1().optional(),
|
|
9342
|
+
scroll: boolean$1().optional(),
|
|
9343
|
+
widths: union([array$1(looseObject({
|
|
9344
|
+
width: int$1().min(1),
|
|
9345
|
+
height: int$1().min(1)
|
|
9346
|
+
})), unknown()]).optional()
|
|
9191
9347
|
});
|
|
9192
9348
|
/** A named box grouping the frames whose center it holds, which it never lists. */
|
|
9193
9349
|
const sectionEntrySchema = looseObject({
|
|
@@ -9317,6 +9473,7 @@ function placeFrames(frames, names) {
|
|
|
9317
9473
|
unplaced.push(name);
|
|
9318
9474
|
continue;
|
|
9319
9475
|
}
|
|
9476
|
+
const scroll = entry.scroll ?? false;
|
|
9320
9477
|
placements.set(name, {
|
|
9321
9478
|
box: {
|
|
9322
9479
|
x: entry.x,
|
|
@@ -9327,8 +9484,10 @@ function placeFrames(frames, names) {
|
|
|
9327
9484
|
order: entry.order,
|
|
9328
9485
|
hidden: entry.hidden ?? false,
|
|
9329
9486
|
locked: entry.locked ?? false,
|
|
9330
|
-
hugWidth: entry.hugWidth ?? false,
|
|
9331
|
-
hugHeight: entry.hugHeight ?? false,
|
|
9487
|
+
hugWidth: !scroll && (entry.hugWidth ?? false),
|
|
9488
|
+
hugHeight: !scroll && (entry.hugHeight ?? false),
|
|
9489
|
+
scroll,
|
|
9490
|
+
widths: widthsOf(entry.widths),
|
|
9332
9491
|
placed: true
|
|
9333
9492
|
});
|
|
9334
9493
|
}
|
|
@@ -9342,12 +9501,15 @@ function placeFrames(frames, names) {
|
|
|
9342
9501
|
}
|
|
9343
9502
|
/**
|
|
9344
9503
|
* Where a frame with no layout entry sits: desktop size at `y` 0, 80 past the
|
|
9345
|
-
* right edge of every frame already placed, on top of all of them. The board
|
|
9504
|
+
* right edge of every frame already placed and the linked widths it draws, on top of all of them. The board
|
|
9346
9505
|
* draws what the scanner returns, and `frame add` persists the same box for
|
|
9347
9506
|
* the first unplaced file, placing any other past the placed frames alone.
|
|
9348
9507
|
*/
|
|
9349
9508
|
function placeNext(placed) {
|
|
9350
|
-
const right = Math.max(...placed.map(({ box }) =>
|
|
9509
|
+
const right = Math.max(...placed.map(({ box, widths }) => {
|
|
9510
|
+
const extent = drawnExtent(box, widths);
|
|
9511
|
+
return extent.x + extent.width + 80;
|
|
9512
|
+
}), 0);
|
|
9351
9513
|
const order = Math.max(...placed.map((placement) => placement.order + 1), 0);
|
|
9352
9514
|
return {
|
|
9353
9515
|
box: {
|
|
@@ -9360,6 +9522,8 @@ function placeNext(placed) {
|
|
|
9360
9522
|
locked: false,
|
|
9361
9523
|
hugWidth: false,
|
|
9362
9524
|
hugHeight: false,
|
|
9525
|
+
scroll: false,
|
|
9526
|
+
widths: [],
|
|
9363
9527
|
placed: false
|
|
9364
9528
|
};
|
|
9365
9529
|
}
|
|
@@ -9528,7 +9692,7 @@ async function isDirectory(path) {
|
|
|
9528
9692
|
}
|
|
9529
9693
|
}
|
|
9530
9694
|
// package.json
|
|
9531
|
-
var version$1 = "0.
|
|
9695
|
+
var version$1 = "0.32.0";
|
|
9532
9696
|
var dependencies = { "playwright-core": "1.65.0" };
|
|
9533
9697
|
var peerDependencies = { "oxfmt": "0.77.0" };
|
|
9534
9698
|
// src/shared/version.ts
|
|
@@ -9988,7 +10152,8 @@ async function framePathParts(root, ref, cwd) {
|
|
|
9988
10152
|
* as `placeNext` puts it, ignoring the page's other unplaced files, unless a
|
|
9989
10153
|
* size or position is given. Every axis no size names hugs its
|
|
9990
10154
|
* content, a preset fixing the width alone, and the box stands in until the
|
|
9991
|
-
* server measures.
|
|
10155
|
+
* server measures. A scroll frame hugs neither axis, and with no height named
|
|
10156
|
+
* takes the reference height of its width.
|
|
9992
10157
|
*/
|
|
9993
10158
|
async function addFrame(root, ref, options) {
|
|
9994
10159
|
const { journal } = options;
|
|
@@ -10003,7 +10168,11 @@ async function addFrame(root, ref, options) {
|
|
|
10003
10168
|
width: reserved.width,
|
|
10004
10169
|
height: reserved.height
|
|
10005
10170
|
} : sizeOf(options);
|
|
10006
|
-
const
|
|
10171
|
+
const scroll = options.scroll ?? false;
|
|
10172
|
+
const hugs = scroll ? {
|
|
10173
|
+
hugWidth: false,
|
|
10174
|
+
hugHeight: false
|
|
10175
|
+
} : reserved && !sized ? {
|
|
10007
10176
|
hugWidth: reserved.hugWidth ?? false,
|
|
10008
10177
|
hugHeight: reserved.hugHeight ?? false
|
|
10009
10178
|
} : hugsOf(options);
|
|
@@ -10015,6 +10184,12 @@ async function addFrame(root, ref, options) {
|
|
|
10015
10184
|
const slot = names.filter((name) => name === frame.name || layout.hasEntry(name));
|
|
10016
10185
|
const computed = placeFrames(layout.file.frames, slot).get(frame.name);
|
|
10017
10186
|
if (!computed) throw new Error(`No placement computed for ${frame.name}.`);
|
|
10187
|
+
const width = size.width ?? computed.box.width;
|
|
10188
|
+
const widths = linkedWidths(refOf$1(frame), options.widths, {
|
|
10189
|
+
width,
|
|
10190
|
+
hugWidth: hugs.hugWidth,
|
|
10191
|
+
held: []
|
|
10192
|
+
});
|
|
10018
10193
|
if (!exists) {
|
|
10019
10194
|
await writeFile(frame.path, skeleton(frame.name), { flag: "wx" });
|
|
10020
10195
|
await journal?.created(frame.path);
|
|
@@ -10025,10 +10200,13 @@ async function addFrame(root, ref, options) {
|
|
|
10025
10200
|
box: {
|
|
10026
10201
|
...computed.box,
|
|
10027
10202
|
...size,
|
|
10203
|
+
...scroll && size.height === void 0 ? { height: referenceHeight(width) } : {},
|
|
10028
10204
|
x: options.x ?? reserved?.x ?? computed.box.x,
|
|
10029
10205
|
y: options.y ?? reserved?.y ?? computed.box.y
|
|
10030
10206
|
},
|
|
10031
|
-
...hugs
|
|
10207
|
+
...hugs,
|
|
10208
|
+
scroll,
|
|
10209
|
+
widths
|
|
10032
10210
|
});
|
|
10033
10211
|
layout.renumber();
|
|
10034
10212
|
}, journal);
|
|
@@ -10056,7 +10234,7 @@ async function duplicateFrame(root, ref, { to, name, offset, journal, ...options
|
|
|
10056
10234
|
y: placement.box.y + offset.y
|
|
10057
10235
|
} : into === from ? {
|
|
10058
10236
|
...placement.box,
|
|
10059
|
-
x: placement
|
|
10237
|
+
x: pastExtent(placement)
|
|
10060
10238
|
} : placement.box;
|
|
10061
10239
|
const copyPath = join(into, `${copyName}${FRAME_EXTENSION}`);
|
|
10062
10240
|
await copyFile(source.path, copyPath, constants.COPYFILE_EXCL);
|
|
@@ -10129,32 +10307,157 @@ async function renameFrame(root, ref, newName, options) {
|
|
|
10129
10307
|
name: newName
|
|
10130
10308
|
});
|
|
10131
10309
|
}
|
|
10310
|
+
/**
|
|
10311
|
+
* Sets the size each option names and fixes those axes. `scroll` on fixes
|
|
10312
|
+
* both, dropping a hugging height no option names to the reference height of
|
|
10313
|
+
* the width, since a frame kept at its content's full height has nothing to
|
|
10314
|
+
* scroll. `scroll` off clears the key and keeps the box as it stands.
|
|
10315
|
+
*/
|
|
10132
10316
|
async function resizeFrame(root, ref, options) {
|
|
10133
10317
|
const size = sizeOf(options);
|
|
10134
|
-
if (Object.keys(size).length === 0) throw new FrameboardError("usage", "Pass --size, --width, or --
|
|
10135
|
-
return updatePlacement(root, ref, options, (placement) => (
|
|
10318
|
+
if (Object.keys(size).length === 0 && options.scroll === void 0 && options.widths === void 0) throw new FrameboardError("usage", "Pass --size, --width, --height, --scroll, --no-scroll, --widths, or --no-widths to resize a frame.");
|
|
10319
|
+
return updatePlacement(root, ref, options, (placement, frameRef) => resizedPlacement(placement, frameRef, size, options));
|
|
10320
|
+
}
|
|
10321
|
+
/** The placement `resizeFrame` writes, for the size it read off its options. */
|
|
10322
|
+
function resizedPlacement(placement, frameRef, size, options) {
|
|
10323
|
+
const scroll = options.scroll ?? placement.scroll;
|
|
10324
|
+
const width = size.width ?? placement.box.width;
|
|
10325
|
+
const drops = scroll && placement.hugHeight && size.height === void 0;
|
|
10326
|
+
const hugWidth = !scroll && placement.hugWidth && size.width === void 0;
|
|
10327
|
+
const widths = linkedWidths(frameRef, options.widths ?? placement.widths.map((linked) => linked.width), {
|
|
10328
|
+
width,
|
|
10329
|
+
hugWidth,
|
|
10330
|
+
held: placement.widths
|
|
10331
|
+
});
|
|
10332
|
+
return {
|
|
10136
10333
|
...placement,
|
|
10137
10334
|
box: {
|
|
10138
10335
|
...placement.box,
|
|
10139
|
-
...size
|
|
10336
|
+
...size,
|
|
10337
|
+
...drops ? { height: referenceHeight(width) } : {}
|
|
10140
10338
|
},
|
|
10141
|
-
hugWidth
|
|
10142
|
-
hugHeight: placement.hugHeight && size.height === void 0
|
|
10339
|
+
hugWidth,
|
|
10340
|
+
hugHeight: !scroll && placement.hugHeight && size.height === void 0,
|
|
10341
|
+
scroll,
|
|
10342
|
+
widths: scroll && placement.hugHeight ? widths.map((linked) => ({
|
|
10343
|
+
...linked,
|
|
10344
|
+
height: referenceHeight(linked.width)
|
|
10345
|
+
})) : widths
|
|
10346
|
+
};
|
|
10347
|
+
}
|
|
10348
|
+
/**
|
|
10349
|
+
* The linked widths a verb writes, keeping the height each one already held
|
|
10350
|
+
* and giving a new one the reference height of its width, which a hugging
|
|
10351
|
+
* frame's measure replaces. A repeated width, the frame's own width, or a
|
|
10352
|
+
* frame hugging its width refuses `usage`.
|
|
10353
|
+
*/
|
|
10354
|
+
function linkedWidths(ref, requested, { width, hugWidth, held }) {
|
|
10355
|
+
if (!requested || requested.length === 0) return [];
|
|
10356
|
+
if (hugWidth) throw new FrameboardError("usage", `${ref} hugs its width, so it has no width to show beside others. Fix it with --size or --width first.`, {
|
|
10357
|
+
ref,
|
|
10358
|
+
widths: requested
|
|
10359
|
+
});
|
|
10360
|
+
const repeated = requested.find((linked, index) => requested.indexOf(linked) !== index);
|
|
10361
|
+
if (repeated !== void 0) throw new FrameboardError("usage", `--widths lists ${repeated} twice, so pass each width once.`, {
|
|
10362
|
+
ref,
|
|
10363
|
+
widths: requested
|
|
10364
|
+
});
|
|
10365
|
+
if (requested.includes(width)) throw new FrameboardError("usage", `${ref} is ${width} px wide already, so --widths lists the other widths alone.`, {
|
|
10366
|
+
ref,
|
|
10367
|
+
width,
|
|
10368
|
+
widths: requested
|
|
10369
|
+
});
|
|
10370
|
+
return requested.map((linked) => ({
|
|
10371
|
+
width: linked,
|
|
10372
|
+
height: held.find((each) => each.width === linked)?.height ?? referenceHeight(linked)
|
|
10143
10373
|
}));
|
|
10144
10374
|
}
|
|
10375
|
+
/** The x a copy placed beside a frame takes, past the row of linked widths it draws. */
|
|
10376
|
+
function pastExtent({ box, widths }) {
|
|
10377
|
+
const extent = drawnExtent(box, widths);
|
|
10378
|
+
return extent.x + extent.width + 80;
|
|
10379
|
+
}
|
|
10145
10380
|
/**
|
|
10146
10381
|
* Sets a frame's height to its content's measured height and turns hugging
|
|
10147
|
-
* back on for that axis, the inverse of the resize that fixed it
|
|
10382
|
+
* back on for that axis, the inverse of the resize that fixed it, writing
|
|
10383
|
+
* each linked width's measured height beside it while the entry lists it. A
|
|
10384
|
+
* scroll frame refuses `fit-scroll`, since its height is fixed on purpose.
|
|
10148
10385
|
*/
|
|
10149
10386
|
async function fitHeight(root, ref, height, options) {
|
|
10150
|
-
return updatePlacement(root, ref, options, (placement) =>
|
|
10387
|
+
return updatePlacement(root, ref, options, (placement) => {
|
|
10388
|
+
if (placement.scroll) throw fitScrollError(ref);
|
|
10389
|
+
return fittedPlacement(placement, height, options.widths);
|
|
10390
|
+
});
|
|
10391
|
+
}
|
|
10392
|
+
/** A placement hugging its measured height, each listed linked width taking its own. */
|
|
10393
|
+
function fittedPlacement(placement, height, widths) {
|
|
10394
|
+
return {
|
|
10151
10395
|
...placement,
|
|
10152
10396
|
box: {
|
|
10153
10397
|
...placement.box,
|
|
10154
10398
|
height
|
|
10155
10399
|
},
|
|
10156
|
-
hugHeight: true
|
|
10157
|
-
|
|
10400
|
+
hugHeight: true,
|
|
10401
|
+
widths: placement.widths.map((linked) => ({
|
|
10402
|
+
...linked,
|
|
10403
|
+
height: widths?.find((each) => each.width === linked.width)?.height ?? linked.height
|
|
10404
|
+
}))
|
|
10405
|
+
};
|
|
10406
|
+
}
|
|
10407
|
+
/**
|
|
10408
|
+
* Sets how each frame holds its height in one write under one lock, all of
|
|
10409
|
+
* them or none. `fixed` keeps the box and clears hugging and scroll. `fit`
|
|
10410
|
+
* takes the measured height and hugs it, clearing scroll. `scroll` fixes both
|
|
10411
|
+
* axes as `frame resize --scroll` does. Every frame is checked before any is
|
|
10412
|
+
* set: one moved or sized since its `expected` refuses `stale-layout`, leaving
|
|
10413
|
+
* out an axis the frame hugs, since the server measures that one, and a `fit`
|
|
10414
|
+
* without `measured` refuses `usage`.
|
|
10415
|
+
*/
|
|
10416
|
+
async function setHeightModes(root, targets, mode, options) {
|
|
10417
|
+
const frames = await Promise.all(targets.map(async (target) => ({
|
|
10418
|
+
target,
|
|
10419
|
+
frame: await resolveFrameRef(root, target.ref, options)
|
|
10420
|
+
})));
|
|
10421
|
+
await withLayouts(frames.map(({ frame }) => pageDir(frame)), async (layouts) => {
|
|
10422
|
+
const next = frames.map(({ target, frame }) => {
|
|
10423
|
+
const layout = layoutAt(layouts, pageDir(frame));
|
|
10424
|
+
const placement = layout.placement(frame.name);
|
|
10425
|
+
const frameRef = refOf$1(frame);
|
|
10426
|
+
refuseStale(frameRef, placement, target.expected);
|
|
10427
|
+
return {
|
|
10428
|
+
layout,
|
|
10429
|
+
name: frame.name,
|
|
10430
|
+
placement: heightPlacement(placement, frameRef, mode, target.measured)
|
|
10431
|
+
};
|
|
10432
|
+
});
|
|
10433
|
+
for (const { layout, name, placement } of next) layout.set(name, placement);
|
|
10434
|
+
}, options.journal);
|
|
10435
|
+
return Promise.all(frames.map(({ frame }) => frameRecord(root, frame.project, frame.page, frame.name)));
|
|
10436
|
+
}
|
|
10437
|
+
function heightPlacement(placement, frameRef, mode, measured) {
|
|
10438
|
+
if (mode === "scroll") return resizedPlacement(placement, frameRef, {}, { scroll: true });
|
|
10439
|
+
if (mode === "fixed") return {
|
|
10440
|
+
...placement,
|
|
10441
|
+
hugHeight: false,
|
|
10442
|
+
scroll: false
|
|
10443
|
+
};
|
|
10444
|
+
if (!measured) throw new FrameboardError("usage", `Fitting ${frameRef} needs its measured height.`, { ref: frameRef });
|
|
10445
|
+
return {
|
|
10446
|
+
...fittedPlacement(placement, measured.height, measured.widths),
|
|
10447
|
+
scroll: false
|
|
10448
|
+
};
|
|
10449
|
+
}
|
|
10450
|
+
function refuseStale(ref, placement, expected) {
|
|
10451
|
+
const { box } = placement;
|
|
10452
|
+
if (!(box.x === expected.x && box.y === expected.y && (placement.hugWidth || box.width === expected.width) && (placement.hugHeight || box.height === expected.height))) throw new FrameboardError("stale-layout", `${ref} moved since this edit began, so nothing was written.`, {
|
|
10453
|
+
ref,
|
|
10454
|
+
stored: boxOf(box),
|
|
10455
|
+
expected
|
|
10456
|
+
});
|
|
10457
|
+
}
|
|
10458
|
+
/** The refusal a fit of a scroll frame answers, before or after measuring. */
|
|
10459
|
+
function fitScrollError(ref) {
|
|
10460
|
+
return new FrameboardError("fit-scroll", `${ref} holds scroll, which fixes its height so the page scrolls past it, so it has no height to fit. Clear it with frame resize --no-scroll first.`, { ref });
|
|
10158
10461
|
}
|
|
10159
10462
|
/**
|
|
10160
10463
|
* Writes the sizes the server measured, on the axes each frame's stored entry
|
|
@@ -10172,13 +10475,18 @@ async function setMeasured(root, pageRef, sizes, options) {
|
|
|
10172
10475
|
const placement = layout.placement(name);
|
|
10173
10476
|
const box = {
|
|
10174
10477
|
...placement.box,
|
|
10175
|
-
width: placement.hugWidth ? size.width : placement.box.width,
|
|
10176
|
-
height: placement.hugHeight ? size.height : placement.box.height
|
|
10478
|
+
width: placement.hugWidth && size.width !== void 0 ? size.width : placement.box.width,
|
|
10479
|
+
height: placement.hugHeight && size.height !== void 0 ? size.height : placement.box.height
|
|
10177
10480
|
};
|
|
10178
|
-
|
|
10481
|
+
const widths = placement.widths.map((linked) => ({
|
|
10482
|
+
...linked,
|
|
10483
|
+
height: placement.hugHeight ? size.widths?.find((each) => each.width === linked.width)?.height ?? linked.height : linked.height
|
|
10484
|
+
}));
|
|
10485
|
+
if (sameBox(box, placement.box) && isDeepStrictEqual(widths, placement.widths)) continue;
|
|
10179
10486
|
layout.set(name, {
|
|
10180
10487
|
...placement,
|
|
10181
|
-
box
|
|
10488
|
+
box,
|
|
10489
|
+
widths
|
|
10182
10490
|
});
|
|
10183
10491
|
written.push(name);
|
|
10184
10492
|
}
|
|
@@ -10255,7 +10563,8 @@ async function setBoxes(root, pageRef, boxes, expected, options) {
|
|
|
10255
10563
|
...kept
|
|
10256
10564
|
},
|
|
10257
10565
|
hugWidth: placement.hugWidth && box.width === started.width,
|
|
10258
|
-
hugHeight: placement.hugHeight && box.height === started.height
|
|
10566
|
+
hugHeight: placement.hugHeight && box.height === started.height,
|
|
10567
|
+
widths: placement.widths.filter((linked) => linked.width !== (kept.width ?? box.width))
|
|
10259
10568
|
});
|
|
10260
10569
|
}
|
|
10261
10570
|
}, options.journal);
|
|
@@ -10322,7 +10631,7 @@ async function updatePlacement(root, ref, options, change) {
|
|
|
10322
10631
|
const page = pageDir(frame);
|
|
10323
10632
|
await withLayouts([page], async (layouts) => {
|
|
10324
10633
|
const layout = layoutAt(layouts, page);
|
|
10325
|
-
layout.set(frame.name, change(layout.placement(frame.name)));
|
|
10634
|
+
layout.set(frame.name, change(layout.placement(frame.name), refOf$1(frame)));
|
|
10326
10635
|
}, options.journal);
|
|
10327
10636
|
return frameRecord(root, frame.project, frame.page, frame.name);
|
|
10328
10637
|
}
|
|
@@ -10394,11 +10703,17 @@ var PageLayout = class {
|
|
|
10394
10703
|
* Writes the seven fixed keys on the entry it creates or changes, after any
|
|
10395
10704
|
* key the entry already held, so unknown keys survive in place. A hug flag
|
|
10396
10705
|
* is written on an entry it creates, once it is on, or when the entry holds
|
|
10397
|
-
* it, so a write to an entry from before the flags adds no key.
|
|
10398
|
-
|
|
10399
|
-
|
|
10706
|
+
* it, so a write to an entry from before the flags adds no key. `scroll` is
|
|
10707
|
+
* written once it is on or when the entry holds it, and a scroll entry
|
|
10708
|
+
* writes both hug flags false, since it fixes both axes. `widths` is
|
|
10709
|
+
* written while it lists one and removed once it lists none, and a held
|
|
10710
|
+
* value no reader understands is left as it stands.
|
|
10711
|
+
*/
|
|
10712
|
+
set(name, { box, order, hidden, locked, scroll, widths, hugWidth: hugsWidth, hugHeight: hugsHeight }) {
|
|
10713
|
+
const hugWidth = hugsWidth && !scroll;
|
|
10714
|
+
const hugHeight = hugsHeight && !scroll;
|
|
10400
10715
|
const held = this.file.frames[name];
|
|
10401
|
-
|
|
10716
|
+
const entry = {
|
|
10402
10717
|
...held,
|
|
10403
10718
|
x: box.x,
|
|
10404
10719
|
y: box.y,
|
|
@@ -10408,8 +10723,15 @@ var PageLayout = class {
|
|
|
10408
10723
|
hidden,
|
|
10409
10724
|
locked,
|
|
10410
10725
|
...!held || hugWidth || held.hugWidth !== void 0 ? { hugWidth } : {},
|
|
10411
|
-
...!held || hugHeight || held.hugHeight !== void 0 ? { hugHeight } : {}
|
|
10412
|
-
|
|
10726
|
+
...!held || hugHeight || held.hugHeight !== void 0 ? { hugHeight } : {},
|
|
10727
|
+
...scroll || held?.scroll !== void 0 ? { scroll } : {},
|
|
10728
|
+
...widths.length > 0 ? { widths: widths.map(({ width, height }) => ({
|
|
10729
|
+
width,
|
|
10730
|
+
height
|
|
10731
|
+
})) } : {}
|
|
10732
|
+
};
|
|
10733
|
+
if (widths.length === 0 && widthsOf(held?.widths).length > 0) delete entry.widths;
|
|
10734
|
+
this.file.frames[name] = entry;
|
|
10413
10735
|
this.changed = true;
|
|
10414
10736
|
}
|
|
10415
10737
|
remove(name) {
|
|
@@ -29002,9 +29324,13 @@ function findingFor(docs) {
|
|
|
29002
29324
|
};
|
|
29003
29325
|
};
|
|
29004
29326
|
}
|
|
29005
|
-
/**
|
|
29327
|
+
/**
|
|
29328
|
+
* One finding as `path:line:column rule message`, as `check` and the hook
|
|
29329
|
+
* print it, the path taking `@<width>` for one read at a linked width.
|
|
29330
|
+
*/
|
|
29006
29331
|
function formatFinding(finding) {
|
|
29007
|
-
|
|
29332
|
+
const path = finding.width === void 0 ? finding.path : `${finding.path}@${finding.width}`;
|
|
29333
|
+
return `${finding.location ? `${path}:${finding.location.line}:${finding.location.column}` : path} ${finding.rule} ${finding.message}`;
|
|
29008
29334
|
}
|
|
29009
29335
|
// src/server/checks/theme.ts
|
|
29010
29336
|
const THEME_RULES = [{
|
|
@@ -29013,7 +29339,7 @@ const THEME_RULES = [{
|
|
|
29013
29339
|
severity: "error",
|
|
29014
29340
|
description: "A frame setting literal colors defines the other theme too, through a [data-theme] selector, a prefers-color-scheme query, or light-dark()"
|
|
29015
29341
|
}];
|
|
29016
|
-
const finding$
|
|
29342
|
+
const finding$11 = findingFor(THEME_RULES);
|
|
29017
29343
|
const COLOR_PROPERTIES$2 = /^(color|background(-color|-image)?|border(-(top|right|bottom|left|block|inline)(-(start|end))?)?(-color)?|outline(-color)?|fill|stroke|box-shadow|text-shadow|caret-color|accent-color|text-decoration(-color)?|column-rule(-color)?)$/i;
|
|
29018
29344
|
const COLOR_FUNCTION = /\b(rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\(/i;
|
|
29019
29345
|
const HEX_COLOR = /#[0-9a-f]{3,8}\b/i;
|
|
@@ -29023,7 +29349,7 @@ function checkTheme(source) {
|
|
|
29023
29349
|
const { firstColor, bothThemes } = readThemeColors(source);
|
|
29024
29350
|
if (!firstColor || bothThemes) return [];
|
|
29025
29351
|
const { path, location } = firstColor;
|
|
29026
|
-
return [finding$
|
|
29352
|
+
return [finding$11("theme", {
|
|
29027
29353
|
frame: source.ref,
|
|
29028
29354
|
path,
|
|
29029
29355
|
message: "The frame sets its own colors for one theme alone. Define the other through [data-theme] or prefers-color-scheme, or take the colors from token variables.",
|
|
@@ -29861,6 +30187,7 @@ const STATUS$4 = {
|
|
|
29861
30187
|
"layout-invalid": 422,
|
|
29862
30188
|
"project-file-invalid": 422,
|
|
29863
30189
|
"fit-unbounded": 422,
|
|
30190
|
+
"fit-scroll": 422,
|
|
29864
30191
|
"claims-invalid": 422,
|
|
29865
30192
|
"lock-timeout": 503,
|
|
29866
30193
|
"browser-not-found": 503
|
|
@@ -40158,8 +40485,10 @@ const CONTENT_TYPES$1 = {
|
|
|
40158
40485
|
* caller what exists.
|
|
40159
40486
|
*
|
|
40160
40487
|
* A frame served from a page gets the faces and the token sheets spliced
|
|
40161
|
-
* first into its `head`, in the response alone, and
|
|
40162
|
-
* served byte for byte
|
|
40488
|
+
* first into its `head`, in the response alone, and is never cached. Every
|
|
40489
|
+
* other file is served byte for byte under a validator the browser checks on
|
|
40490
|
+
* each use, so an edit shows on the next load and an unchanged file answers
|
|
40491
|
+
* 304 with no body. A frame path carrying `?at=<hash>` serves the
|
|
40163
40492
|
* version `version` holds under that hash in its place, with the same head,
|
|
40164
40493
|
* and any other path carrying it answers 404.
|
|
40165
40494
|
*/
|
|
@@ -40195,6 +40524,21 @@ function frameRoutes(root, look, version) {
|
|
|
40195
40524
|
return c.body(stream, 206, headers);
|
|
40196
40525
|
}
|
|
40197
40526
|
}
|
|
40527
|
+
if (!isFrame && at === void 0) {
|
|
40528
|
+
const tag = weakTag(await stat(file, { bigint: true }));
|
|
40529
|
+
const revalidate = {
|
|
40530
|
+
ETag: tag,
|
|
40531
|
+
"Cache-Control": "no-cache"
|
|
40532
|
+
};
|
|
40533
|
+
if (matchesTag(c.req.header("If-None-Match"), tag)) return c.body(null, 304, revalidate);
|
|
40534
|
+
const headers = {
|
|
40535
|
+
"Content-Type": contentType,
|
|
40536
|
+
"Accept-Ranges": "bytes",
|
|
40537
|
+
...revalidate
|
|
40538
|
+
};
|
|
40539
|
+
if (c.req.method === "HEAD") return c.body(null, 200, headers);
|
|
40540
|
+
return c.body(new Uint8Array(await readFile(file)), 200, headers);
|
|
40541
|
+
}
|
|
40198
40542
|
let bytes;
|
|
40199
40543
|
if (at === void 0) bytes = new Uint8Array(await readFile(file));
|
|
40200
40544
|
else {
|
|
@@ -40203,16 +40547,30 @@ function frameRoutes(root, look, version) {
|
|
|
40203
40547
|
if (held === null) return c.notFound();
|
|
40204
40548
|
bytes = new TextEncoder().encode(held);
|
|
40205
40549
|
}
|
|
40206
|
-
const body =
|
|
40550
|
+
const body = injectHead(bytes, frameHead(sheetUrls(project, look.sheets(project)), contentHash(bytes)));
|
|
40207
40551
|
return c.body(body, 200, {
|
|
40208
40552
|
"Content-Type": contentType,
|
|
40209
|
-
"Cache-Control": "no-store"
|
|
40210
|
-
...isFrame ? {} : { "Accept-Ranges": "bytes" }
|
|
40553
|
+
"Cache-Control": "no-store"
|
|
40211
40554
|
});
|
|
40212
40555
|
});
|
|
40213
40556
|
return app;
|
|
40214
40557
|
}
|
|
40215
40558
|
/**
|
|
40559
|
+
* A weak validator from a file's size and nanosecond mtime, so a check costs
|
|
40560
|
+
* one stat rather than a read of every byte. A same-size rewrite inside one
|
|
40561
|
+
* timestamp tick keeps its tag, which a coarse mount makes likelier.
|
|
40562
|
+
*/
|
|
40563
|
+
function weakTag({ size, mtimeNs }) {
|
|
40564
|
+
return `W/"${size.toString(16)}-${mtimeNs.toString(16)}"`;
|
|
40565
|
+
}
|
|
40566
|
+
/** Whether an `If-None-Match` header names `tag`, compared weakly per RFC 9110. */
|
|
40567
|
+
function matchesTag(header, tag) {
|
|
40568
|
+
if (header === void 0) return false;
|
|
40569
|
+
if (header.trim() === "*") return true;
|
|
40570
|
+
const opaque = tag.replace(/^W\//, "");
|
|
40571
|
+
return header.split(",").some((listed) => listed.trim().replace(/^W\//, "") === opaque);
|
|
40572
|
+
}
|
|
40573
|
+
/**
|
|
40216
40574
|
* The inclusive bytes a single `bytes=` range names within `size`,
|
|
40217
40575
|
* `'unsatisfiable'` for a valid range that names none of them, or null for a
|
|
40218
40576
|
* header to ignore, which RFC 9110 allows for any range a server does not
|
|
@@ -40751,6 +41109,8 @@ const STATUS = {
|
|
|
40751
41109
|
"font-missing": 422,
|
|
40752
41110
|
"image-missing": 422,
|
|
40753
41111
|
"capture-too-large": 422,
|
|
41112
|
+
"motion-missing": 422,
|
|
41113
|
+
"motion-unbounded": 422,
|
|
40754
41114
|
"browser-not-found": 503
|
|
40755
41115
|
};
|
|
40756
41116
|
/** The route's scale when none is asked for, matching Copy as PNG. */
|
|
@@ -40758,23 +41118,28 @@ const DEFAULT_SCALE = 2;
|
|
|
40758
41118
|
/**
|
|
40759
41119
|
* `GET /api/frames/png?ref=<frame-ref>&theme=<light|dark>&scale=<1|2|3>`, a
|
|
40760
41120
|
* frame rendered at `scale` times its layout size, twice when no scale is
|
|
40761
|
-
* given.
|
|
40762
|
-
*
|
|
40763
|
-
* `
|
|
41121
|
+
* given. An added `filmstrip=<n>` of 2 or more renders `n` moments of its
|
|
41122
|
+
* timeline in one row instead, refusing a frame with no timeline as
|
|
41123
|
+
* `motion-missing` and one that never ends as `motion-unbounded`. It takes
|
|
41124
|
+
* no token, since the image shows only what the frame route already serves,
|
|
41125
|
+
* and a refusal answers the CLI's `{ ok, error }` envelope.
|
|
40764
41126
|
*/
|
|
40765
|
-
function pngRoutes(root, render) {
|
|
41127
|
+
function pngRoutes(root, render, renderFilmstrip) {
|
|
40766
41128
|
const app = new Hono();
|
|
40767
41129
|
app.get("/api/frames/png", async (c) => {
|
|
40768
41130
|
try {
|
|
40769
41131
|
const ref = c.req.query("ref") ?? "";
|
|
40770
41132
|
const theme = c.req.query("theme") ?? "";
|
|
40771
41133
|
const scale = parseScale$1(c.req.query("scale"));
|
|
40772
|
-
|
|
41134
|
+
const filmstrip = parseFilmstrip(c.req.query("filmstrip"));
|
|
41135
|
+
if (ref === "" || !isTheme(theme) || scale === null || filmstrip === null) throw new FrameboardError("usage", "Ask for /api/frames/png?ref=<frame-ref>&theme=<light|dark>&scale=<1|2|3>, adding &filmstrip=<n> of 2 or more for a filmstrip.", {
|
|
40773
41136
|
ref,
|
|
40774
41137
|
theme,
|
|
40775
|
-
scale: c.req.query("scale") ?? null
|
|
41138
|
+
scale: c.req.query("scale") ?? null,
|
|
41139
|
+
filmstrip: c.req.query("filmstrip") ?? null
|
|
40776
41140
|
});
|
|
40777
|
-
const
|
|
41141
|
+
const frame = await readFrame$1(root, ref, { cwd: root });
|
|
41142
|
+
const bytes = filmstrip === void 0 ? await render(frame, theme, scale) : await renderFilmstrip(frame, theme, scale, filmstrip);
|
|
40778
41143
|
return c.body(new Uint8Array(bytes), 200, {
|
|
40779
41144
|
"Content-Type": "image/png",
|
|
40780
41145
|
"Cache-Control": "no-store"
|
|
@@ -40801,6 +41166,12 @@ function parseScale$1(value) {
|
|
|
40801
41166
|
if (value === "1" || value === "2" || value === "3") return Number(value);
|
|
40802
41167
|
return null;
|
|
40803
41168
|
}
|
|
41169
|
+
function parseFilmstrip(value) {
|
|
41170
|
+
if (value === void 0) return void 0;
|
|
41171
|
+
if (!/^[1-9][0-9]*$/.test(value)) return null;
|
|
41172
|
+
const count = Number(value);
|
|
41173
|
+
return count >= 2 ? count : null;
|
|
41174
|
+
}
|
|
40804
41175
|
// src/server/board/paste.ts
|
|
40805
41176
|
/** Reads each frame's file and placement under its page's lock, in the order given. */
|
|
40806
41177
|
async function holdFrames(root, refs, options) {
|
|
@@ -40839,7 +41210,7 @@ async function pasteFrames(root, pageRef, held, options) {
|
|
|
40839
41210
|
};
|
|
40840
41211
|
return frame.page === target.path ? {
|
|
40841
41212
|
...box,
|
|
40842
|
-
x:
|
|
41213
|
+
x: pastExtent(frame.placement)
|
|
40843
41214
|
} : box;
|
|
40844
41215
|
};
|
|
40845
41216
|
const names = await withLayouts([target.path], async (layouts) => {
|
|
@@ -41006,7 +41377,20 @@ const frameDuplicateSchema = object$1({
|
|
|
41006
41377
|
y: coordinate
|
|
41007
41378
|
}).optional()
|
|
41008
41379
|
});
|
|
41009
|
-
const
|
|
41380
|
+
const frameHeightSchema = object$1({
|
|
41381
|
+
refs,
|
|
41382
|
+
mode: _enum$1([
|
|
41383
|
+
"fixed",
|
|
41384
|
+
"fit",
|
|
41385
|
+
"scroll"
|
|
41386
|
+
]),
|
|
41387
|
+
expected: record(ref, object$1({
|
|
41388
|
+
x: coordinate,
|
|
41389
|
+
y: coordinate,
|
|
41390
|
+
width: int$1().min(1),
|
|
41391
|
+
height: int$1().min(1)
|
|
41392
|
+
})).refine((boxes) => Object.keys(boxes).length <= 1e3)
|
|
41393
|
+
});
|
|
41010
41394
|
const pasteSchema = object$1({
|
|
41011
41395
|
ref,
|
|
41012
41396
|
at: object$1({
|
|
@@ -41289,29 +41673,54 @@ function structureRoutes(root, access, history, measure, tokens = null) {
|
|
|
41289
41673
|
});
|
|
41290
41674
|
});
|
|
41291
41675
|
/**
|
|
41292
|
-
* Sets
|
|
41293
|
-
*
|
|
41294
|
-
*
|
|
41676
|
+
* Sets how each frame holds its height, `fixed`, `fit`, or `scroll`, in one
|
|
41677
|
+
* step. `expected` holds each frame's box as the caller saw it, keyed by the
|
|
41678
|
+
* ref the body names, and a frame changed since refuses `stale-layout`
|
|
41679
|
+
* before any frame is written. A locked or claimed frame refuses the whole
|
|
41680
|
+
* write, and `fit` measures each frame and its linked widths on the warm
|
|
41681
|
+
* browser first, refusing `browser-not-found` where none runs.
|
|
41295
41682
|
*/
|
|
41296
|
-
app.post("/api/frame/
|
|
41297
|
-
const body = await parseBody$1(c.req.raw,
|
|
41298
|
-
|
|
41299
|
-
|
|
41300
|
-
|
|
41301
|
-
|
|
41302
|
-
|
|
41303
|
-
|
|
41683
|
+
app.post("/api/frame/height", async (c) => {
|
|
41684
|
+
const body = await parseBody$1(c.req.raw, frameHeightSchema);
|
|
41685
|
+
const targets = body.refs.map((ref) => {
|
|
41686
|
+
const expected = body.expected[ref];
|
|
41687
|
+
if (!expected) throw new FrameboardError("usage", `The body gives ${ref} no expected box.`, { ref });
|
|
41688
|
+
return {
|
|
41689
|
+
ref,
|
|
41690
|
+
expected
|
|
41691
|
+
};
|
|
41692
|
+
});
|
|
41693
|
+
await refuseLocked(body.refs);
|
|
41694
|
+
await refuseHeldFrames(body.refs);
|
|
41695
|
+
if (body.mode === "fit") {
|
|
41696
|
+
if (!measure) throw new FrameboardError("browser-not-found", "Fit height needs the board server's browser, and none runs here.");
|
|
41697
|
+
for (const target of targets) {
|
|
41698
|
+
const frame = await readFrame$1(root, target.ref, { cwd });
|
|
41699
|
+
const content = await measure(frame);
|
|
41700
|
+
const widths = [];
|
|
41701
|
+
for (const { width } of frame.widths) {
|
|
41702
|
+
const linked = await measure(frame, {
|
|
41703
|
+
width,
|
|
41704
|
+
height: referenceHeight(width)
|
|
41705
|
+
});
|
|
41706
|
+
widths.push({
|
|
41707
|
+
width,
|
|
41708
|
+
height: linked.height
|
|
41709
|
+
});
|
|
41710
|
+
}
|
|
41711
|
+
target.measured = {
|
|
41712
|
+
height: content.height,
|
|
41713
|
+
widths
|
|
41714
|
+
};
|
|
41715
|
+
}
|
|
41716
|
+
}
|
|
41717
|
+
const frames = await recorded((journal) => setHeightModes(root, targets, body.mode, {
|
|
41304
41718
|
cwd,
|
|
41305
41719
|
journal
|
|
41306
|
-
}), (
|
|
41720
|
+
}), (records) => onFrames(records.map((record) => record.ref)));
|
|
41307
41721
|
return c.json({
|
|
41308
41722
|
ok: true,
|
|
41309
|
-
data:
|
|
41310
|
-
frame: fit,
|
|
41311
|
-
contentHeight: measured.height,
|
|
41312
|
-
contentWidth: measured.contentWidth,
|
|
41313
|
-
tooWide: measured.contentWidth > fit.box.width
|
|
41314
|
-
}
|
|
41723
|
+
data: frames
|
|
41315
41724
|
});
|
|
41316
41725
|
});
|
|
41317
41726
|
app.post("/api/frame/delete", async (c) => {
|
|
@@ -41704,7 +42113,7 @@ function boardHostGuard(port) {
|
|
|
41704
42113
|
await next();
|
|
41705
42114
|
};
|
|
41706
42115
|
}
|
|
41707
|
-
function createApp({ clientDir, root, port, actions, tickets, openRoute, renderFrame, clipboard = null, facesDir, tokens, delivery, dispatch, history, selection, checks, thumbnails, measure, frameVersion, settledVersion, assetUsage }) {
|
|
42116
|
+
function createApp({ clientDir, root, port, actions, tickets, openRoute, renderFrame, renderFilmstrip, clipboard = null, facesDir, tokens, delivery, dispatch, history, selection, checks, thumbnails, measure, frameVersion, settledVersion, assetUsage }) {
|
|
41708
42117
|
const app = new Hono();
|
|
41709
42118
|
const given = tokens ?? null;
|
|
41710
42119
|
app.use("*", async (c, next) => {
|
|
@@ -41734,7 +42143,7 @@ function createApp({ clientDir, root, port, actions, tickets, openRoute, renderF
|
|
|
41734
42143
|
app.route("/", claimsRoutes(root, actions.access));
|
|
41735
42144
|
app.route("/", tokenRoutes(root, actions.access, history, frames.look));
|
|
41736
42145
|
app.route("/", editRoutes(root, actions.access, history, settledVersion, frames.look.sheets));
|
|
41737
|
-
app.route("/", pngRoutes(root, renderFrame));
|
|
42146
|
+
app.route("/", pngRoutes(root, renderFrame, renderFilmstrip));
|
|
41738
42147
|
app.route("/", clipboardRoutes(root, actions.access, renderFrame, clipboard));
|
|
41739
42148
|
if (checks) app.route("/", checkRoutes(actions.access, checks));
|
|
41740
42149
|
if (thumbnails) app.route("/", thumbnailRoutes(root, thumbnails));
|
|
@@ -41837,6 +42246,13 @@ async function withFrameHost(board, purpose, run) {
|
|
|
41837
42246
|
await host.close();
|
|
41838
42247
|
}
|
|
41839
42248
|
}
|
|
42249
|
+
// src/shared/capture-limits.ts
|
|
42250
|
+
/** Chromium's screenshot surface stops at this many pixels on either side. */
|
|
42251
|
+
const MAX_COMPOSITE_SIDE = 16384;
|
|
42252
|
+
/** A filmstrip's width in CSS pixels: `count` copies of the frame in a row, one margin around and between them. */
|
|
42253
|
+
function filmstripWidth(frameWidth, count) {
|
|
42254
|
+
return count * frameWidth + (count + 1) * 40;
|
|
42255
|
+
}
|
|
41840
42256
|
// src/server/capture/animation-settle.ts
|
|
41841
42257
|
/**
|
|
41842
42258
|
* Waits, within `timeoutMs`, until every running animation and transition
|
|
@@ -42091,11 +42507,134 @@ async function waitForImages(timeoutMs) {
|
|
|
42091
42507
|
});
|
|
42092
42508
|
return unsettled;
|
|
42093
42509
|
}
|
|
42510
|
+
// src/shared/motion.ts
|
|
42511
|
+
/**
|
|
42512
|
+
* Finds the timeline a page's motion runs on, taking `__hf` alone when
|
|
42513
|
+
* present, else every `__timelines` entry, else the page's animations, and
|
|
42514
|
+
* resolves null when none registers within `timeoutMs`.
|
|
42515
|
+
*
|
|
42516
|
+
* Capture evaluates this in a page by its source text and the board calls it
|
|
42517
|
+
* on an iframe's window, so it reads nothing outside its own body and takes
|
|
42518
|
+
* its clock, frames, and document from `view`, never the caller's realm.
|
|
42519
|
+
*/
|
|
42520
|
+
async function readMotionIn(view, timeoutMs) {
|
|
42521
|
+
const end = view.performance.now() + timeoutMs;
|
|
42522
|
+
const nextFrame = () => new Promise((done) => view.requestAnimationFrame(() => done()));
|
|
42523
|
+
const seconds = (value) => typeof value === "number" && Number.isFinite(value) ? Math.round(value * 1e3) : null;
|
|
42524
|
+
const read = () => {
|
|
42525
|
+
const hf = view.__hf;
|
|
42526
|
+
const hfDuration = seconds(hf?.duration);
|
|
42527
|
+
if (typeof hf?.seek === "function" && hfDuration !== null && hfDuration > 0) return {
|
|
42528
|
+
source: "hf",
|
|
42529
|
+
duration: hfDuration
|
|
42530
|
+
};
|
|
42531
|
+
const registry = view.__timelines;
|
|
42532
|
+
const timelines = Object.values(registry ?? {}).filter((timeline) => typeof timeline?.seek === "function");
|
|
42533
|
+
if (timelines.length > 0) {
|
|
42534
|
+
const finite = timelines.map((timeline) => seconds(typeof timeline.duration === "function" ? timeline.duration.call(timeline) : timeline.duration)).filter((length) => length !== null);
|
|
42535
|
+
return {
|
|
42536
|
+
source: "timelines",
|
|
42537
|
+
duration: finite.length === 0 ? null : Math.max(...finite)
|
|
42538
|
+
};
|
|
42539
|
+
}
|
|
42540
|
+
const animations = view.document.getAnimations();
|
|
42541
|
+
if (animations.length > 0) {
|
|
42542
|
+
const ends = animations.map((animation) => animation.effect?.getComputedTiming().endTime).filter((endTime) => typeof endTime === "number" && Number.isFinite(endTime));
|
|
42543
|
+
return {
|
|
42544
|
+
source: "css",
|
|
42545
|
+
duration: ends.length === 0 ? null : Math.round(Math.max(...ends))
|
|
42546
|
+
};
|
|
42547
|
+
}
|
|
42548
|
+
return null;
|
|
42549
|
+
};
|
|
42550
|
+
await nextFrame();
|
|
42551
|
+
for (;;) {
|
|
42552
|
+
const motion = read();
|
|
42553
|
+
if (motion !== null || view.performance.now() >= end) return motion;
|
|
42554
|
+
await nextFrame();
|
|
42555
|
+
}
|
|
42556
|
+
}
|
|
42557
|
+
/**
|
|
42558
|
+
* Holds the page at `ms`, clamped to the timeline's end, and resolves with
|
|
42559
|
+
* the moment it holds once a frame has painted it. HyperFrames and GSAP take
|
|
42560
|
+
* seconds, and the conversion happens here alone. Self-contained for the
|
|
42561
|
+
* same reason as `readMotionIn`.
|
|
42562
|
+
*/
|
|
42563
|
+
async function holdMotionIn(view, { motion, ms }) {
|
|
42564
|
+
const at = motion.duration === null ? ms : Math.min(Math.max(ms, 0), motion.duration);
|
|
42565
|
+
if (motion.source === "hf") await view.__hf.seek(at / 1e3);
|
|
42566
|
+
else if (motion.source === "timelines") {
|
|
42567
|
+
const registry = view.__timelines;
|
|
42568
|
+
for (const timeline of Object.values(registry)) {
|
|
42569
|
+
if (typeof timeline?.seek !== "function") continue;
|
|
42570
|
+
timeline.pause?.();
|
|
42571
|
+
await timeline.seek(at / 1e3);
|
|
42572
|
+
}
|
|
42573
|
+
} else for (const animation of view.document.getAnimations()) {
|
|
42574
|
+
animation.pause();
|
|
42575
|
+
animation.currentTime = at;
|
|
42576
|
+
}
|
|
42577
|
+
await new Promise((done) => view.requestAnimationFrame(() => view.requestAnimationFrame(() => done())));
|
|
42578
|
+
return at;
|
|
42579
|
+
}
|
|
42580
|
+
/**
|
|
42581
|
+
* `count` moments spaced evenly from 0 to the timeline's end inclusive.
|
|
42582
|
+
* Refuses `motion-unbounded` when every animation repeats forever, since no
|
|
42583
|
+
* end exists to space them across.
|
|
42584
|
+
*/
|
|
42585
|
+
function filmstripMoments(ref, motion, count) {
|
|
42586
|
+
const { duration } = motion;
|
|
42587
|
+
if (duration === null) throw new FrameboardError("motion-unbounded", `${ref} only runs animations that repeat forever, so a filmstrip has no end to space its moments across. Name the moments with --at instead.`, {
|
|
42588
|
+
ref,
|
|
42589
|
+
source: motion.source
|
|
42590
|
+
});
|
|
42591
|
+
return Array.from({ length: count }, (_, index) => Math.round(duration * index / (count - 1)));
|
|
42592
|
+
}
|
|
42593
|
+
// src/server/capture/seek.ts
|
|
42594
|
+
/**
|
|
42595
|
+
* Stops the page's animation clock, through the DevTools Animation domain,
|
|
42596
|
+
* before the page loads. A CSS animation with no fill that ended during the
|
|
42597
|
+
* load would otherwise drop out of `document.getAnimations()` before the seek
|
|
42598
|
+
* reads it. Script timelines run on their own clocks and keep running.
|
|
42599
|
+
*/
|
|
42600
|
+
async function holdAnimationClock(page) {
|
|
42601
|
+
const session = await page.context().newCDPSession(page);
|
|
42602
|
+
await session.send("Animation.enable");
|
|
42603
|
+
await session.send("Animation.setPlaybackRate", { playbackRate: 0 });
|
|
42604
|
+
}
|
|
42605
|
+
/**
|
|
42606
|
+
* Finds the timeline a frame's motion runs on, taking `window.__hf` alone
|
|
42607
|
+
* when present, else every `window.__timelines` entry, else the page's
|
|
42608
|
+
* animations. A script loading its timeline late gets until `timeoutMs` to
|
|
42609
|
+
* register one, and a frame showing none by then refuses `motion-missing`,
|
|
42610
|
+
* since a scene stepped by a script timer cannot be held at a moment.
|
|
42611
|
+
*/
|
|
42612
|
+
async function findMotion(page, ref, timeoutMs) {
|
|
42613
|
+
const found = await page.evaluate(inPage(readMotionIn, timeoutMs));
|
|
42614
|
+
if (found === null) throw new FrameboardError("motion-missing", `${ref} shows no animation, transition, window.__hf, or window.__timelines to seek, so it has no moment to capture. A scene a script steps on a timer cannot be held still.`, { ref });
|
|
42615
|
+
return found;
|
|
42616
|
+
}
|
|
42617
|
+
/**
|
|
42618
|
+
* Holds the frame at `ms`, clamped to the timeline's end, and resolves with
|
|
42619
|
+
* the moment it holds once a frame has painted it.
|
|
42620
|
+
*/
|
|
42621
|
+
function seekMotion(page, motion, ms) {
|
|
42622
|
+
return page.evaluate(inPage(holdMotionIn, {
|
|
42623
|
+
motion,
|
|
42624
|
+
ms
|
|
42625
|
+
}));
|
|
42626
|
+
}
|
|
42627
|
+
/**
|
|
42628
|
+
* The expression calling a shared window function on the page's own
|
|
42629
|
+
* `window`, by its source text, since Playwright sends a page only text and
|
|
42630
|
+
* the board imports the same function to call on an iframe's window.
|
|
42631
|
+
*/
|
|
42632
|
+
function inPage(run, arg) {
|
|
42633
|
+
return `(${run.toString()})(window, ${JSON.stringify(arg)})`;
|
|
42634
|
+
}
|
|
42094
42635
|
// src/server/capture/render.ts
|
|
42095
42636
|
/** How long a frame has to load, its faces and images included, before its capture fails. */
|
|
42096
42637
|
const LOAD_TIMEOUT_MS = 1e4;
|
|
42097
|
-
/** Chromium's screenshot surface stops at this many pixels on either side. */
|
|
42098
|
-
const MAX_COMPOSITE_SIDE = 16384;
|
|
42099
42638
|
/**
|
|
42100
42639
|
* Loads a frame in its own browser context at its layout size, in the theme
|
|
42101
42640
|
* asked for, and resolves once it has loaded, its faces have settled, and its
|
|
@@ -42103,9 +42642,9 @@ const MAX_COMPOSITE_SIDE = 16384;
|
|
|
42103
42642
|
* the default, a missing face refuses `font-missing`, an image that failed or
|
|
42104
42643
|
* outran the budget refuses `image-missing`, and either closes the context.
|
|
42105
42644
|
* It then waits, on what is left of the budget, for running animations with
|
|
42106
|
-
* a finite end to finish, and never refuses for one
|
|
42645
|
+
* a finite end to finish, and never refuses for one, unless `motion` is `hold`.
|
|
42107
42646
|
*/
|
|
42108
|
-
async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts = "require", timeoutMs = LOAD_TIMEOUT_MS }) {
|
|
42647
|
+
async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts = "require", timeoutMs = LOAD_TIMEOUT_MS, motion = "settle" }) {
|
|
42109
42648
|
const context = await browser.newContext({
|
|
42110
42649
|
viewport: {
|
|
42111
42650
|
width: box.width,
|
|
@@ -42118,6 +42657,7 @@ async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts =
|
|
|
42118
42657
|
const deadline = Date.now() + timeoutMs;
|
|
42119
42658
|
try {
|
|
42120
42659
|
const page = await context.newPage();
|
|
42660
|
+
if (motion === "hold") await holdAnimationClock(page);
|
|
42121
42661
|
await page.goto(new URL(frameThemeUrl(ref, theme), baseUrl).href, {
|
|
42122
42662
|
timeout: timeoutMs,
|
|
42123
42663
|
waitUntil: "domcontentloaded"
|
|
@@ -42130,7 +42670,7 @@ async function openFrame(browser, { baseUrl, ref, box, theme, scale = 1, fonts =
|
|
|
42130
42670
|
await page.evaluate(() => document.fonts.ready.then(() => void 0));
|
|
42131
42671
|
if (fonts === "require") await assertFontsPresent(page, ref);
|
|
42132
42672
|
await settleImages(page, ref, fonts, deadline - Date.now());
|
|
42133
|
-
if (fonts === "require") await settleAnimations(page, deadline - Date.now());
|
|
42673
|
+
if (fonts === "require" && motion === "settle") await settleAnimations(page, deadline - Date.now());
|
|
42134
42674
|
return {
|
|
42135
42675
|
page,
|
|
42136
42676
|
close
|
|
@@ -42212,20 +42752,32 @@ function createWarmRenderer({ baseUrl, browser, scale: defaultScale }) {
|
|
|
42212
42752
|
return run;
|
|
42213
42753
|
};
|
|
42214
42754
|
}
|
|
42755
|
+
// src/server/capture/images.ts
|
|
42215
42756
|
const SCREENSHOT = {
|
|
42216
42757
|
animations: "disabled",
|
|
42217
42758
|
caret: "hide"
|
|
42218
42759
|
};
|
|
42760
|
+
const HELD_SCREENSHOT = {
|
|
42761
|
+
animations: "allow",
|
|
42762
|
+
caret: "hide"
|
|
42763
|
+
};
|
|
42219
42764
|
/**
|
|
42220
42765
|
* The file name of one image, `<name>.<theme>.png` at 1x so a path an agent
|
|
42221
|
-
* saved stays true, and `<name>.<theme>@<n>x.png` at any other scale.
|
|
42222
|
-
|
|
42223
|
-
|
|
42224
|
-
|
|
42766
|
+
* saved stays true, and `<name>.<theme>@<n>x.png` at any other scale. A shot
|
|
42767
|
+
* scrolled down takes `.scroll-<px>` after the name, the offset asked for,
|
|
42768
|
+
* and a linked width takes `@<width>` ahead of both. A timed shot takes
|
|
42769
|
+
* `.at-<ms>`, the moment asked for, and a filmstrip `.filmstrip-<n>`, each
|
|
42770
|
+
* after the width.
|
|
42771
|
+
*/
|
|
42772
|
+
function imageName(name, theme, scale, scroll, width, moment) {
|
|
42773
|
+
const named = width === void 0 ? name : `${name}@${width}`;
|
|
42774
|
+
const scrolled = scroll === void 0 ? named : `${named}.scroll-${scroll}`;
|
|
42775
|
+
const stem = moment === void 0 ? scrolled : "at" in moment ? `${scrolled}.at-${moment.at}` : `${scrolled}.filmstrip-${moment.filmstrip}`;
|
|
42776
|
+
return scale === 1 ? `${stem}.${theme}.png` : `${stem}.${theme}@${scale}x.png`;
|
|
42225
42777
|
}
|
|
42226
42778
|
/** Where one frame's capture in one theme lands under `out`. */
|
|
42227
|
-
function frameImagePath(out, frame, theme, scale = 1) {
|
|
42228
|
-
return join(out, frame.project, frame.page, imageName(frame.name, theme, scale));
|
|
42779
|
+
function frameImagePath(out, frame, theme, scale = 1, scroll, width, moment) {
|
|
42780
|
+
return join(out, frame.project, frame.page, imageName(frame.name, theme, scale, scroll, width, moment));
|
|
42229
42781
|
}
|
|
42230
42782
|
/** Where a page's composite in one theme lands under `out`. */
|
|
42231
42783
|
function compositeImagePath(out, page, theme, scale = 1) {
|
|
@@ -42234,13 +42786,15 @@ function compositeImagePath(out, page, theme, scale = 1) {
|
|
|
42234
42786
|
/**
|
|
42235
42787
|
* The composite's size and the shift placing each frame in it, so the
|
|
42236
42788
|
* leftmost and topmost frames sit one margin in and one margin is left past
|
|
42237
|
-
* the far edges
|
|
42789
|
+
* the far edges, each frame's linked widths included. Refuses
|
|
42790
|
+
* `capture-too-large` past Chromium's screenshot limit.
|
|
42238
42791
|
*/
|
|
42239
42792
|
function compositeBounds(page, frames, scale = 1) {
|
|
42240
|
-
const
|
|
42241
|
-
const
|
|
42242
|
-
const
|
|
42243
|
-
const
|
|
42793
|
+
const extents = frames.map(({ box, widths }) => drawnExtent(box, widths ?? []));
|
|
42794
|
+
const left = Math.min(...extents.map((box) => box.x));
|
|
42795
|
+
const top = Math.min(...extents.map((box) => box.y));
|
|
42796
|
+
const right = Math.max(...extents.map((box) => box.x + box.width));
|
|
42797
|
+
const bottom = Math.max(...extents.map((box) => box.y + box.height));
|
|
42244
42798
|
const width = right - left + 80;
|
|
42245
42799
|
const height = bottom - top + 80;
|
|
42246
42800
|
if (width * scale > 16384 || height * scale > 16384) {
|
|
@@ -42261,23 +42815,59 @@ function compositeBounds(page, frames, scale = 1) {
|
|
|
42261
42815
|
};
|
|
42262
42816
|
}
|
|
42263
42817
|
/**
|
|
42264
|
-
*
|
|
42265
|
-
*
|
|
42266
|
-
*
|
|
42818
|
+
* A filmstrip's size: `count` copies of the frame's box in one row, one
|
|
42819
|
+
* margin around and between them. Refuses `capture-too-large` past
|
|
42820
|
+
* Chromium's screenshot limit.
|
|
42267
42821
|
*/
|
|
42268
|
-
|
|
42269
|
-
const
|
|
42270
|
-
|
|
42271
|
-
|
|
42272
|
-
|
|
42273
|
-
|
|
42274
|
-
|
|
42275
|
-
height: frame.box.height,
|
|
42822
|
+
function filmstripBounds(ref, box, count, scale = 1) {
|
|
42823
|
+
const width = filmstripWidth(box.width, count);
|
|
42824
|
+
const height = box.height + 80;
|
|
42825
|
+
if (width * scale > 16384 || height * scale > 16384) throw new FrameboardError("capture-too-large", `A filmstrip of ${count} frames of ${ref}${scale === 1 ? "" : ` at ${scale}x`} would be ${width * scale} by ${height * scale} px, past the ${MAX_COMPOSITE_SIDE} px a browser screenshot holds. Ask for fewer frames or a smaller scale.`, {
|
|
42826
|
+
ref,
|
|
42827
|
+
width,
|
|
42828
|
+
height,
|
|
42276
42829
|
scale,
|
|
42277
|
-
|
|
42830
|
+
max: MAX_COMPOSITE_SIDE
|
|
42278
42831
|
});
|
|
42832
|
+
return {
|
|
42833
|
+
width,
|
|
42834
|
+
height
|
|
42835
|
+
};
|
|
42836
|
+
}
|
|
42837
|
+
/**
|
|
42838
|
+
* Captures each frame in each theme at its layout size times `scale`, one PNG
|
|
42839
|
+
* apiece, and again at each linked width it lists, at the height that width
|
|
42840
|
+
* holds. Every image renders before any is written, so a refusal on one frame
|
|
42841
|
+
* leaves no half-written set an agent could read as current. A `scroll`
|
|
42842
|
+
* offset shoots each view that far down, clamped to the page's end. `width`
|
|
42843
|
+
* shoots each frame at that one width alone, its own or a linked one.
|
|
42844
|
+
*/
|
|
42845
|
+
async function captureFrameImages(browser, { baseUrl, frames, themes, out, scale = 1, scroll, width }) {
|
|
42846
|
+
const rendered = [];
|
|
42847
|
+
for (const frame of frames) for (const view of viewsOf(frame, width)) for (const theme of themes) {
|
|
42848
|
+
const shot = await renderFrame(browser, baseUrl, frame, view, theme, scale, scroll);
|
|
42849
|
+
const linked = view.width === frame.box.width ? void 0 : view.width;
|
|
42850
|
+
rendered.push({
|
|
42851
|
+
ref: frame.ref,
|
|
42852
|
+
theme,
|
|
42853
|
+
path: frameImagePath(out, frame, theme, scale, scroll, linked),
|
|
42854
|
+
width: view.width,
|
|
42855
|
+
height: view.height,
|
|
42856
|
+
scale,
|
|
42857
|
+
...shot.scrollY === void 0 ? {} : { scrollY: shot.scrollY },
|
|
42858
|
+
bytes: shot.bytes
|
|
42859
|
+
});
|
|
42860
|
+
}
|
|
42279
42861
|
return writeImages(rendered);
|
|
42280
42862
|
}
|
|
42863
|
+
/** The boxes a frame shows at, its own first, or the one `width` names. */
|
|
42864
|
+
function viewsOf(frame, width) {
|
|
42865
|
+
const views = [{
|
|
42866
|
+
width: frame.box.width,
|
|
42867
|
+
height: frame.box.height
|
|
42868
|
+
}, ...frame.widths];
|
|
42869
|
+
return width === void 0 ? views : views.filter((view) => view.width === width);
|
|
42870
|
+
}
|
|
42281
42871
|
/**
|
|
42282
42872
|
* Captures one image of a page per theme, every frame at its layout box on
|
|
42283
42873
|
* the theme's canvas color. Each frame renders as it does alone, font check
|
|
@@ -42288,9 +42878,9 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
|
|
|
42288
42878
|
const rendered = [];
|
|
42289
42879
|
for (const theme of themes) {
|
|
42290
42880
|
const tiles = [];
|
|
42291
|
-
for (const frame of frames) {
|
|
42292
|
-
const bytes = await renderFrame(browser, baseUrl, frame, theme, scale);
|
|
42293
|
-
tiles.push(`<img src="data:image/png;base64,${bytes.toString("base64")}" style="position:absolute;left:${
|
|
42881
|
+
for (const frame of frames) for (const box of [frame.box, ...linkedBoxes(frame.box, frame.widths)]) {
|
|
42882
|
+
const { bytes } = await renderFrame(browser, baseUrl, frame, box, theme, scale);
|
|
42883
|
+
tiles.push(`<img src="data:image/png;base64,${bytes.toString("base64")}" style="position:absolute;left:${box.x + bounds.dx}px;top:${box.y + bounds.dy}px;width:${box.width}px;height:${box.height}px">`);
|
|
42294
42884
|
}
|
|
42295
42885
|
rendered.push({
|
|
42296
42886
|
ref: page.ref,
|
|
@@ -42304,11 +42894,141 @@ async function captureComposite(browser, { baseUrl, page, frames, themes, out, s
|
|
|
42304
42894
|
}
|
|
42305
42895
|
return writeImages(rendered);
|
|
42306
42896
|
}
|
|
42307
|
-
|
|
42308
|
-
|
|
42897
|
+
/**
|
|
42898
|
+
* Captures one frame held at set moments of its timeline, in each theme and
|
|
42899
|
+
* at each width it shows at, or the one `width` names. `timing.at` writes one
|
|
42900
|
+
* PNG per moment, and `timing.filmstrip` one PNG per view and theme holding that many
|
|
42901
|
+
* moments spaced from 0 to the timeline's end. A frame with no seekable
|
|
42902
|
+
* timeline refuses `motion-missing`, and a filmstrip of one that never ends
|
|
42903
|
+
* `motion-unbounded`. Every image renders before any is written.
|
|
42904
|
+
*/
|
|
42905
|
+
async function captureMotionImages(browser, { baseUrl, frame, themes, out, scale = 1, width, timing, motionTimeoutMs = LOAD_TIMEOUT_MS }) {
|
|
42906
|
+
const rendered = [];
|
|
42907
|
+
let found = null;
|
|
42908
|
+
for (const view of viewsOf(frame, width)) {
|
|
42909
|
+
const linked = view.width === frame.box.width ? void 0 : view.width;
|
|
42910
|
+
for (const theme of themes) {
|
|
42911
|
+
if ("filmstrip" in timing) {
|
|
42912
|
+
const strip = await renderFilmstrip(browser, {
|
|
42913
|
+
baseUrl,
|
|
42914
|
+
frame: {
|
|
42915
|
+
ref: frame.ref,
|
|
42916
|
+
box: view
|
|
42917
|
+
},
|
|
42918
|
+
theme,
|
|
42919
|
+
scale,
|
|
42920
|
+
count: timing.filmstrip,
|
|
42921
|
+
motionTimeoutMs
|
|
42922
|
+
});
|
|
42923
|
+
found ??= strip.motion;
|
|
42924
|
+
rendered.push({
|
|
42925
|
+
ref: frame.ref,
|
|
42926
|
+
theme,
|
|
42927
|
+
path: frameImagePath(out, frame, theme, scale, void 0, linked, { filmstrip: strip.moments.length }),
|
|
42928
|
+
width: strip.width,
|
|
42929
|
+
height: strip.height,
|
|
42930
|
+
scale,
|
|
42931
|
+
moments: strip.moments,
|
|
42932
|
+
bytes: strip.bytes
|
|
42933
|
+
});
|
|
42934
|
+
continue;
|
|
42935
|
+
}
|
|
42936
|
+
const shots = await holdShots(browser, {
|
|
42937
|
+
baseUrl,
|
|
42938
|
+
ref: frame.ref,
|
|
42939
|
+
view,
|
|
42940
|
+
theme,
|
|
42941
|
+
scale,
|
|
42942
|
+
motionTimeoutMs,
|
|
42943
|
+
moments: () => timing.at
|
|
42944
|
+
});
|
|
42945
|
+
found ??= shots.motion;
|
|
42946
|
+
shots.held.forEach(({ held, bytes }, index) => {
|
|
42947
|
+
rendered.push({
|
|
42948
|
+
ref: frame.ref,
|
|
42949
|
+
theme,
|
|
42950
|
+
path: frameImagePath(out, frame, theme, scale, void 0, linked, { at: timing.at[index] ?? held }),
|
|
42951
|
+
width: view.width,
|
|
42952
|
+
height: view.height,
|
|
42953
|
+
scale,
|
|
42954
|
+
at: held,
|
|
42955
|
+
bytes
|
|
42956
|
+
});
|
|
42957
|
+
});
|
|
42958
|
+
}
|
|
42959
|
+
}
|
|
42960
|
+
return {
|
|
42961
|
+
images: await writeImages(rendered),
|
|
42962
|
+
motion: found
|
|
42963
|
+
};
|
|
42964
|
+
}
|
|
42965
|
+
/**
|
|
42966
|
+
* One frame's filmstrip in one theme: `count` moments spaced from 0 to the
|
|
42967
|
+
* timeline's end, held one by one and laid in a row on the theme's canvas
|
|
42968
|
+
* color. Refuses `motion-missing` for a frame with no seekable timeline and
|
|
42969
|
+
* `motion-unbounded` for one that never ends, and `capture-too-large` before
|
|
42970
|
+
* opening the frame for a strip past the screenshot limit.
|
|
42971
|
+
*/
|
|
42972
|
+
async function renderFilmstrip(browser, { baseUrl, frame, theme, scale = 1, count, motionTimeoutMs = LOAD_TIMEOUT_MS }) {
|
|
42973
|
+
const view = {
|
|
42309
42974
|
width: frame.box.width,
|
|
42310
42975
|
height: frame.box.height
|
|
42311
42976
|
};
|
|
42977
|
+
const strip = filmstripBounds(frame.ref, view, count, scale);
|
|
42978
|
+
const { motion, held } = await holdShots(browser, {
|
|
42979
|
+
baseUrl,
|
|
42980
|
+
ref: frame.ref,
|
|
42981
|
+
view,
|
|
42982
|
+
theme,
|
|
42983
|
+
scale,
|
|
42984
|
+
motionTimeoutMs,
|
|
42985
|
+
moments: (found) => filmstripMoments(frame.ref, found, count)
|
|
42986
|
+
});
|
|
42987
|
+
return {
|
|
42988
|
+
bytes: await renderComposite(browser, strip, theme, held.map(({ bytes }, index) => `<img src="data:image/png;base64,${bytes.toString("base64")}" style="position:absolute;left:${40 + index * (view.width + 40)}px;top:40px;width:${view.width}px;height:${view.height}px">`), scale),
|
|
42989
|
+
width: strip.width,
|
|
42990
|
+
height: strip.height,
|
|
42991
|
+
moments: held.map((shot) => shot.held),
|
|
42992
|
+
motion
|
|
42993
|
+
};
|
|
42994
|
+
}
|
|
42995
|
+
/**
|
|
42996
|
+
* Opens one frame with its animation clock held, finds its timeline, and
|
|
42997
|
+
* shoots it at each moment `moments` picks from what it found.
|
|
42998
|
+
*/
|
|
42999
|
+
async function holdShots(browser, { baseUrl, ref, view, theme, scale, motionTimeoutMs, moments }) {
|
|
43000
|
+
assertScreenshotFits(ref, view, scale);
|
|
43001
|
+
const opened = await openFrame(browser, {
|
|
43002
|
+
baseUrl,
|
|
43003
|
+
ref,
|
|
43004
|
+
box: view,
|
|
43005
|
+
theme,
|
|
43006
|
+
scale,
|
|
43007
|
+
motion: "hold"
|
|
43008
|
+
});
|
|
43009
|
+
try {
|
|
43010
|
+
const motion = await findMotion(opened.page, ref, motionTimeoutMs);
|
|
43011
|
+
const held = [];
|
|
43012
|
+
for (const moment of moments(motion)) {
|
|
43013
|
+
const at = await seekMotion(opened.page, motion, moment);
|
|
43014
|
+
held.push({
|
|
43015
|
+
held: at,
|
|
43016
|
+
bytes: await opened.page.screenshot(HELD_SCREENSHOT)
|
|
43017
|
+
});
|
|
43018
|
+
}
|
|
43019
|
+
return {
|
|
43020
|
+
motion,
|
|
43021
|
+
held
|
|
43022
|
+
};
|
|
43023
|
+
} finally {
|
|
43024
|
+
await opened.close();
|
|
43025
|
+
}
|
|
43026
|
+
}
|
|
43027
|
+
async function renderFrame(browser, baseUrl, frame, view, theme, scale, scroll) {
|
|
43028
|
+
const box = {
|
|
43029
|
+
width: view.width,
|
|
43030
|
+
height: view.height
|
|
43031
|
+
};
|
|
42312
43032
|
assertScreenshotFits(frame.ref, box, scale);
|
|
42313
43033
|
const opened = await openFrame(browser, {
|
|
42314
43034
|
baseUrl,
|
|
@@ -42318,11 +43038,24 @@ async function renderFrame(browser, baseUrl, frame, theme, scale) {
|
|
|
42318
43038
|
scale
|
|
42319
43039
|
});
|
|
42320
43040
|
try {
|
|
42321
|
-
|
|
43041
|
+
const scrollY = scroll === void 0 ? void 0 : await opened.page.evaluate(scrollAndSettle, scroll);
|
|
43042
|
+
return {
|
|
43043
|
+
bytes: await opened.page.screenshot(SCREENSHOT),
|
|
43044
|
+
scrollY
|
|
43045
|
+
};
|
|
42322
43046
|
} finally {
|
|
42323
43047
|
await opened.close();
|
|
42324
43048
|
}
|
|
42325
43049
|
}
|
|
43050
|
+
function scrollAndSettle(top) {
|
|
43051
|
+
window.scrollTo({
|
|
43052
|
+
top,
|
|
43053
|
+
behavior: "instant"
|
|
43054
|
+
});
|
|
43055
|
+
return new Promise((resolve) => {
|
|
43056
|
+
requestAnimationFrame(() => requestAnimationFrame(() => resolve(Math.round(window.scrollY))));
|
|
43057
|
+
});
|
|
43058
|
+
}
|
|
42326
43059
|
async function renderComposite(browser, { width, height }, theme, tiles, scale) {
|
|
42327
43060
|
const context = await browser.newContext({
|
|
42328
43061
|
viewport: {
|
|
@@ -42348,6 +43081,27 @@ async function writeImages(rendered) {
|
|
|
42348
43081
|
}));
|
|
42349
43082
|
return rendered.map(({ bytes: _bytes, ...image }) => image);
|
|
42350
43083
|
}
|
|
43084
|
+
/**
|
|
43085
|
+
* Renders filmstrips on a server's warm browser one at a time. The queue is
|
|
43086
|
+
* its own, so Copy as PNG and a plain export never wait behind a strip of
|
|
43087
|
+
* many moments.
|
|
43088
|
+
*/
|
|
43089
|
+
function createWarmFilmstripRenderer({ baseUrl, browser }) {
|
|
43090
|
+
let queue = Promise.resolve();
|
|
43091
|
+
return (frame, theme, scale, count) => {
|
|
43092
|
+
const run = queue.then(async () => {
|
|
43093
|
+
return (await renderFilmstrip(await browser.get(), {
|
|
43094
|
+
baseUrl: baseUrl(),
|
|
43095
|
+
frame,
|
|
43096
|
+
theme,
|
|
43097
|
+
scale,
|
|
43098
|
+
count
|
|
43099
|
+
})).bytes;
|
|
43100
|
+
});
|
|
43101
|
+
queue = run.catch(() => {});
|
|
43102
|
+
return run;
|
|
43103
|
+
};
|
|
43104
|
+
}
|
|
42351
43105
|
// src/cli/commands/capture.ts
|
|
42352
43106
|
function registerCapture(program, context) {
|
|
42353
43107
|
const { io } = context;
|
|
@@ -42355,9 +43109,14 @@ function registerCapture(program, context) {
|
|
|
42355
43109
|
"light",
|
|
42356
43110
|
"dark",
|
|
42357
43111
|
"both"
|
|
42358
|
-
]).default("both")).addOption(new Option("--scale <n>", "device pixels per CSS pixel, adding @<n>x to the file name past 1").default(1).argParser(parseScale)).option("--out <dir>", "the folder images land in, defaulting to the board's .run/captures/"), context, async ([ref], options) => {
|
|
43112
|
+
]).default("both")).addOption(new Option("--scale <n>", "device pixels per CSS pixel, adding @<n>x to the file name past 1").default(1).argParser(parseScale)).option("--scroll <px>", "shoot a scroll frame this far down, clamped to the end of its page, adding .scroll-<px> to the file name", parseInteger(0)).option("--at <ms,...>", "hold the frame at each of these moments of its timeline, in ms, one image apiece, adding .at-<ms> to the file name", parseMoments).option("--filmstrip <n>", "one image of n moments spaced from the start of the timeline to its end, adding .filmstrip-<n> to the file name", parseInteger(2)).option("--out <dir>", "the folder images land in, defaulting to the board's .run/captures/"), context, async ([ref], options) => {
|
|
42359
43113
|
if (ref === void 0 === (options.page === void 0)) throw new FrameboardError("usage", "Pass a frame ref or --page <page-ref>, exactly one of the two.");
|
|
42360
43114
|
if (options.composite && options.page === void 0) throw new FrameboardError("usage", "--composite needs --page.");
|
|
43115
|
+
if (options.scroll !== void 0 && options.page !== void 0) throw new FrameboardError("usage", "--scroll shoots one frame, so pass a frame ref rather than --page.");
|
|
43116
|
+
const timing = options.at !== void 0 ? { at: options.at } : options.filmstrip !== void 0 ? { filmstrip: options.filmstrip } : void 0;
|
|
43117
|
+
if (options.at !== void 0 && options.filmstrip !== void 0) throw new FrameboardError("usage", "Pass --at or --filmstrip, not both.");
|
|
43118
|
+
if (timing !== void 0 && options.page !== void 0) throw new FrameboardError("usage", "--at and --filmstrip seek one frame, so pass a frame ref rather than --page.");
|
|
43119
|
+
if (timing !== void 0 && options.scroll !== void 0) throw new FrameboardError("usage", "--at and --filmstrip shoot the frame at the top, so drop --scroll.");
|
|
42361
43120
|
const root = await boardOf(options, io);
|
|
42362
43121
|
const refOptions = {
|
|
42363
43122
|
project: options.project,
|
|
@@ -42396,11 +43155,32 @@ function registerCapture(program, context) {
|
|
|
42396
43155
|
}));
|
|
42397
43156
|
return {
|
|
42398
43157
|
data: { images },
|
|
42399
|
-
human: describe$
|
|
43158
|
+
human: describe$7(images)
|
|
42400
43159
|
};
|
|
42401
43160
|
}
|
|
42402
43161
|
const frame = await readFrame$1(root, ref ?? "", refOptions);
|
|
43162
|
+
if (options.scroll !== void 0 && !frame.scroll) throw new FrameboardError("usage", `${frame.ref} holds no scroll key, so it has nothing to scroll. Set it with frame resize --scroll first.`, { ref: frame.ref });
|
|
42403
43163
|
const out = await outOf();
|
|
43164
|
+
if (timing !== void 0) {
|
|
43165
|
+
const { images, motion } = await withFrameHost({
|
|
43166
|
+
root,
|
|
43167
|
+
facesDir: context.facesDir
|
|
43168
|
+
}, "capture", (browser, baseUrl) => captureMotionImages(browser, {
|
|
43169
|
+
baseUrl,
|
|
43170
|
+
frame,
|
|
43171
|
+
themes,
|
|
43172
|
+
out,
|
|
43173
|
+
scale: options.scale,
|
|
43174
|
+
timing
|
|
43175
|
+
}));
|
|
43176
|
+
return {
|
|
43177
|
+
data: {
|
|
43178
|
+
images,
|
|
43179
|
+
...motion === null ? {} : { motion }
|
|
43180
|
+
},
|
|
43181
|
+
human: describe$7(images)
|
|
43182
|
+
};
|
|
43183
|
+
}
|
|
42404
43184
|
const images = await withFrameHost({
|
|
42405
43185
|
root,
|
|
42406
43186
|
facesDir: context.facesDir
|
|
@@ -42409,11 +43189,12 @@ function registerCapture(program, context) {
|
|
|
42409
43189
|
frames: [frame],
|
|
42410
43190
|
themes,
|
|
42411
43191
|
out,
|
|
42412
|
-
scale: options.scale
|
|
43192
|
+
scale: options.scale,
|
|
43193
|
+
scroll: options.scroll
|
|
42413
43194
|
}));
|
|
42414
43195
|
return {
|
|
42415
43196
|
data: { images },
|
|
42416
|
-
human: describe$
|
|
43197
|
+
human: describe$7(images)
|
|
42417
43198
|
};
|
|
42418
43199
|
});
|
|
42419
43200
|
}
|
|
@@ -42421,12 +43202,17 @@ function parseScale(value) {
|
|
|
42421
43202
|
if (value !== "1" && value !== "2" && value !== "3") throw new InvalidArgumentError("Expected 1, 2, or 3.");
|
|
42422
43203
|
return Number(value);
|
|
42423
43204
|
}
|
|
43205
|
+
function parseMoments(value) {
|
|
43206
|
+
const moments = value.split(",").map((part) => part.trim());
|
|
43207
|
+
if (!moments.every((part) => /^\d+$/.test(part) && Number.isSafeInteger(Number(part)))) throw new InvalidArgumentError("Expected whole milliseconds, comma separated, such as 0,500,1000.");
|
|
43208
|
+
return [...new Set(moments.map(Number))];
|
|
43209
|
+
}
|
|
42424
43210
|
async function pageOf(root, ref, options) {
|
|
42425
43211
|
const resolved = await resolvePageRef(root, ref, options);
|
|
42426
43212
|
const { pages } = await readPageOrder(join(root, resolved.project));
|
|
42427
43213
|
return scanPage(root, resolved.project, resolved.page, pages.indexOf(resolved.page));
|
|
42428
43214
|
}
|
|
42429
|
-
function describe$
|
|
43215
|
+
function describe$7(images) {
|
|
42430
43216
|
return images.map((image) => `Wrote ${image.path}`).join("\n");
|
|
42431
43217
|
}
|
|
42432
43218
|
// src/server/checks/custom-properties.ts
|
|
@@ -42436,7 +43222,7 @@ const CUSTOM_PROPERTY_RULES = [{
|
|
|
42436
43222
|
severity: "warning",
|
|
42437
43223
|
description: "A var() with no fallback names a custom property no token sheet, frame sheet, style attribute, or script write declares"
|
|
42438
43224
|
}];
|
|
42439
|
-
const finding$
|
|
43225
|
+
const finding$10 = findingFor(CUSTOM_PROPERTY_RULES);
|
|
42440
43226
|
/** A `var()` naming its property, with no fallback after a comma. */
|
|
42441
43227
|
const BARE_VAR = /var\(\s*(--[\w-]+)\s*\)/g;
|
|
42442
43228
|
/**
|
|
@@ -42495,7 +43281,7 @@ function checkUnknownTokens(source, tokens) {
|
|
|
42495
43281
|
if (element.name !== "script") continue;
|
|
42496
43282
|
for (const name of scriptWrites(scriptText(element, source))) declared.add(name);
|
|
42497
43283
|
}
|
|
42498
|
-
return uses.filter((use) => !declared.has(use.name)).map((use) => finding$
|
|
43284
|
+
return uses.filter((use) => !declared.has(use.name)).map((use) => finding$10("unknown-token", {
|
|
42499
43285
|
frame: source.ref,
|
|
42500
43286
|
path: use.path,
|
|
42501
43287
|
message: `var(${use.name}) names a custom property nothing declares, so the declaration resolves to nothing. Use a token the project's tokens.css declares, or give it a fallback, such as var(${use.name}, red). If a script sets it at runtime under a name the check cannot read, the fallback is the way out.`,
|
|
@@ -42569,7 +43355,7 @@ const FONT_RULES = [
|
|
|
42569
43355
|
description: "Every text element's first family is one of the project's allowed fonts"
|
|
42570
43356
|
}
|
|
42571
43357
|
];
|
|
42572
|
-
const finding$
|
|
43358
|
+
const finding$9 = findingFor(FONT_RULES);
|
|
42573
43359
|
const GENERIC_FAMILIES = /* @__PURE__ */ new Set([
|
|
42574
43360
|
"serif",
|
|
42575
43361
|
"sans-serif",
|
|
@@ -42612,7 +43398,7 @@ function checkFonts(source, cascade, config) {
|
|
|
42612
43398
|
else if (allowed && !allowed.includes(family.toLowerCase())) push(unlisted, family, element);
|
|
42613
43399
|
}
|
|
42614
43400
|
const path = boardPath(source.root, source.path);
|
|
42615
|
-
const at = (rule, elements, message) => finding$
|
|
43401
|
+
const at = (rule, elements, message) => finding$9(rule, {
|
|
42616
43402
|
frame: source.ref,
|
|
42617
43403
|
path,
|
|
42618
43404
|
message: `${message} ${described(elements)}`,
|
|
@@ -42662,7 +43448,7 @@ const LINK_RULES = [
|
|
|
42662
43448
|
description: "Every local file a frame loads exists"
|
|
42663
43449
|
}
|
|
42664
43450
|
];
|
|
42665
|
-
const finding$
|
|
43451
|
+
const finding$8 = findingFor(LINK_RULES);
|
|
42666
43452
|
/**
|
|
42667
43453
|
* The attributes that load a resource, by element. An `a href` navigates
|
|
42668
43454
|
* rather than loads, so it is left out.
|
|
@@ -42738,16 +43524,16 @@ function judge(source, load) {
|
|
|
42738
43524
|
path: load.path,
|
|
42739
43525
|
location: load.location
|
|
42740
43526
|
};
|
|
42741
|
-
if (hasScheme(url)) return [finding$
|
|
43527
|
+
if (hasScheme(url)) return [finding$8("network", {
|
|
42742
43528
|
...fields,
|
|
42743
43529
|
message: `${load.via} loads ${url} over the network. Save the file into the page folder or the project's assets/ and link it there.`
|
|
42744
43530
|
})];
|
|
42745
43531
|
const target = localTarget(url, load.base);
|
|
42746
|
-
if (target === null || !allowed(source, target)) return [finding$
|
|
43532
|
+
if (target === null || !allowed(source, target)) return [finding$8("outside-link", {
|
|
42747
43533
|
...fields,
|
|
42748
43534
|
message: `${load.via} loads ${url}, outside this page's folder and the project's assets/. Move the file into one of them.`
|
|
42749
43535
|
})];
|
|
42750
|
-
if (!existsSync(target)) return [finding$
|
|
43536
|
+
if (!existsSync(target)) return [finding$8("missing-file", {
|
|
42751
43537
|
...fields,
|
|
42752
43538
|
message: `${load.via} loads ${url}, which does not exist.`
|
|
42753
43539
|
})];
|
|
@@ -42836,7 +43622,7 @@ const STRUCTURE_RULES = [
|
|
|
42836
43622
|
description: "The browser rebuilds the tree the file writes, adding an element it never opens, closing one it never closed, or moving one out of a table"
|
|
42837
43623
|
}
|
|
42838
43624
|
];
|
|
42839
|
-
const finding$
|
|
43625
|
+
const finding$7 = findingFor(STRUCTURE_RULES);
|
|
42840
43626
|
/**
|
|
42841
43627
|
* Elements a parser may imply with no start tag in a valid file. A `tbody`
|
|
42842
43628
|
* is `table-tbody`'s to report.
|
|
@@ -42899,12 +43685,12 @@ const MALFORMED = {
|
|
|
42899
43685
|
function checkNaming(target, path) {
|
|
42900
43686
|
const ref = `${target.project}/${target.page}/${target.name}`;
|
|
42901
43687
|
const findings = [];
|
|
42902
|
-
if (!isValidName(target.page) || isReservedPageName(target.page)) findings.push(finding$
|
|
43688
|
+
if (!isValidName(target.page) || isReservedPageName(target.page)) findings.push(finding$7("naming", {
|
|
42903
43689
|
frame: ref,
|
|
42904
43690
|
path,
|
|
42905
43691
|
message: `Page name ${target.page} is not valid. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit.`
|
|
42906
43692
|
}));
|
|
42907
|
-
if (!isValidName(target.name)) findings.push(finding$
|
|
43693
|
+
if (!isValidName(target.name)) findings.push(finding$7("naming", {
|
|
42908
43694
|
frame: ref,
|
|
42909
43695
|
path,
|
|
42910
43696
|
message: `Frame name ${target.name} is not valid. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit.`
|
|
@@ -42913,7 +43699,7 @@ function checkNaming(target, path) {
|
|
|
42913
43699
|
}
|
|
42914
43700
|
/** `dot-folder`, over a project's folder names. */
|
|
42915
43701
|
function checkDotFolders(root, projectDir, folders) {
|
|
42916
|
-
return folders.filter((name) => name.startsWith(".")).map((name) => finding$
|
|
43702
|
+
return folders.filter((name) => name.startsWith(".")).map((name) => finding$7("dot-folder", {
|
|
42917
43703
|
frame: null,
|
|
42918
43704
|
path: boardPath(root, `${projectDir}/${name}`),
|
|
42919
43705
|
message: `Folder ${name} opens with a dot, so the board never shows it. Rename it or move it out of the project.`
|
|
@@ -42925,13 +43711,13 @@ function checkMarkup(source) {
|
|
|
42925
43711
|
const findings = [];
|
|
42926
43712
|
const head = source.elements.find((element) => element.name === "head");
|
|
42927
43713
|
const body = source.elements.find((element) => element.name === "body");
|
|
42928
|
-
if (head && startTagLocation(head) && !(body && startTagLocation(body))) findings.push(finding$
|
|
43714
|
+
if (head && startTagLocation(head) && !(body && startTagLocation(body))) findings.push(finding$7("head-body", {
|
|
42929
43715
|
frame: source.ref,
|
|
42930
43716
|
path,
|
|
42931
43717
|
message: "The frame states <head> and no <body>. Wrap the visible content in <body>.",
|
|
42932
43718
|
location: startTagLocation(head)
|
|
42933
43719
|
}));
|
|
42934
|
-
for (const table of source.elements.filter(isTable)) if (table.children.some((child) => child.type === "tag" && child.name === "tbody" && !child.sourceCodeLocation?.startTag)) findings.push(finding$
|
|
43720
|
+
for (const table of source.elements.filter(isTable)) if (table.children.some((child) => child.type === "tag" && child.name === "tbody" && !child.sourceCodeLocation?.startTag)) findings.push(finding$7("table-tbody", {
|
|
42935
43721
|
frame: source.ref,
|
|
42936
43722
|
path,
|
|
42937
43723
|
message: "This table holds rows with no <tbody>, so the browser adds one the file does not hold. State the <tbody>.",
|
|
@@ -42958,7 +43744,7 @@ function checkMalformedTags(source) {
|
|
|
42958
43744
|
if (reported.has(tag)) continue;
|
|
42959
43745
|
reported.add(tag);
|
|
42960
43746
|
}
|
|
42961
|
-
findings.push(finding$
|
|
43747
|
+
findings.push(finding$7("malformed-tag", {
|
|
42962
43748
|
frame: source.ref,
|
|
42963
43749
|
path,
|
|
42964
43750
|
message: `${tag ? `<${tag.name}> raises ${error.code}` : error.code}. ${message}`,
|
|
@@ -42976,7 +43762,7 @@ function checkMalformedTags(source) {
|
|
|
42976
43762
|
function checkNesting(source) {
|
|
42977
43763
|
const path = boardPath(source.root, source.path);
|
|
42978
43764
|
const findings = [];
|
|
42979
|
-
const report = (message, location) => findings.push(finding$
|
|
43765
|
+
const report = (message, location) => findings.push(finding$7("nesting", {
|
|
42980
43766
|
frame: source.ref,
|
|
42981
43767
|
path,
|
|
42982
43768
|
message,
|
|
@@ -43039,14 +43825,14 @@ const UPPERCASE_RULES = [{
|
|
|
43039
43825
|
configKey: "noUppercase",
|
|
43040
43826
|
description: "No text is set in capitals, through text-transform: uppercase or a word of more than three capital letters"
|
|
43041
43827
|
}];
|
|
43042
|
-
const finding$
|
|
43828
|
+
const finding$6 = findingFor(UPPERCASE_RULES);
|
|
43043
43829
|
const CAPITALS = /(?<![\p{L}\p{N}])\p{Lu}{4,}(?![\p{L}\p{N}])/u;
|
|
43044
43830
|
/** `uppercase`, which runs only when the project sets `noUppercase`. */
|
|
43045
43831
|
function checkUppercase(source, cascade) {
|
|
43046
43832
|
const capitalized = textElements(source).filter((element) => cascade.textTransform(element) === "uppercase" || ownText(element).some((text) => CAPITALS.test(text)));
|
|
43047
43833
|
const first = capitalized[0];
|
|
43048
43834
|
if (!first) return [];
|
|
43049
|
-
return [finding$
|
|
43835
|
+
return [finding$6("uppercase", {
|
|
43050
43836
|
frame: source.ref,
|
|
43051
43837
|
path: boardPath(source.root, source.path),
|
|
43052
43838
|
message: `Text is set in capitals, which the project does not allow. Write it in sentence case. ${described(capitalized)}`,
|
|
@@ -43127,7 +43913,7 @@ const CONTRAST_RULES = [{
|
|
|
43127
43913
|
configKey: "minContrast",
|
|
43128
43914
|
description: "Text contrasts with the solid color behind it at a lower ratio than the project sets, 4.5 being WCAG's, with large text held to two thirds of it. Text over an image, a gradient, or an effect is not measured."
|
|
43129
43915
|
}];
|
|
43130
|
-
const finding$
|
|
43916
|
+
const finding$5 = findingFor(CONTRAST_RULES);
|
|
43131
43917
|
/** WCAG's large text is 18 pt, or 14 pt bold, which hold 3:1 against 4.5:1. */
|
|
43132
43918
|
const LARGE_SHARE = 2 / 3;
|
|
43133
43919
|
/**
|
|
@@ -43145,7 +43931,7 @@ async function checkContrast(page, target, minContrast) {
|
|
|
43145
43931
|
const others = under.length - 1;
|
|
43146
43932
|
const rest = others === 0 ? "" : `, and ${others} more ${others === 1 ? "element is" : "elements are"} under it`;
|
|
43147
43933
|
const minimum = worst.large ? `${formatRatio(worst.minimum)}:1 minimum for large text` : `${formatRatio(worst.minimum)}:1 minimum`;
|
|
43148
|
-
return [finding$
|
|
43934
|
+
return [finding$5("min-contrast", {
|
|
43149
43935
|
frame: target.ref,
|
|
43150
43936
|
path: target.path,
|
|
43151
43937
|
message: `${target.ref} sets text in <${worst.tag}> at element ${worst.index} at ${floorRatio(worst.ratio)}:1, ${worst.foreground} on ${worst.background}, under the project's ${minimum}${rest}.`
|
|
@@ -43318,7 +44104,7 @@ const DECLARATION_RULES = [{
|
|
|
43318
44104
|
severity: "warning",
|
|
43319
44105
|
description: "A declaration the page's own CSS parser drops, being a misspelled property, a value it cannot read, or a sheet that stops parsing"
|
|
43320
44106
|
}];
|
|
43321
|
-
const finding$
|
|
44107
|
+
const finding$4 = findingFor(DECLARATION_RULES);
|
|
43322
44108
|
/**
|
|
43323
44109
|
* At-rules whose blocks hold descriptors rather than properties, which
|
|
43324
44110
|
* `CSS.supports` cannot answer, and `@supports`, whose block is a
|
|
@@ -43343,7 +44129,7 @@ async function checkDeclarations(page, source) {
|
|
|
43343
44129
|
const path = boardPath(source.root, sheet.path);
|
|
43344
44130
|
const text = sheet.origin === "style" ? source.html : sheet.css;
|
|
43345
44131
|
const { root, errors } = parseSheet$1(sheet.css);
|
|
43346
|
-
for (const error of errors) findings.push(finding$
|
|
44132
|
+
for (const error of errors) findings.push(finding$4("dropped-declaration", {
|
|
43347
44133
|
frame: source.ref,
|
|
43348
44134
|
path,
|
|
43349
44135
|
message: breakMessage(error),
|
|
@@ -43382,7 +44168,7 @@ async function checkDeclarations(page, source) {
|
|
|
43382
44168
|
const supported = await page.evaluate((pairs) => pairs.map(([property, value]) => CSS.supports(property, value)), written.map((each) => [each.property, each.value]));
|
|
43383
44169
|
written.forEach((each, index) => {
|
|
43384
44170
|
if (supported[index]) return;
|
|
43385
|
-
findings.push(finding$
|
|
44171
|
+
findings.push(finding$4("dropped-declaration", {
|
|
43386
44172
|
frame: source.ref,
|
|
43387
44173
|
path: each.path,
|
|
43388
44174
|
message: `The browser drops ${each.property}: ${each.value}, since it reads no such property or no such value for it. Check the spelling of both, and the unit of a length, such as 12px.`,
|
|
@@ -43422,7 +44208,7 @@ const FONT_SIZE_RULES = [{
|
|
|
43422
44208
|
configKey: "minFontSize",
|
|
43423
44209
|
description: "Text renders smaller than the project sets as its minimum size in pixels"
|
|
43424
44210
|
}];
|
|
43425
|
-
const finding$
|
|
44211
|
+
const finding$3 = findingFor(FONT_SIZE_RULES);
|
|
43426
44212
|
/**
|
|
43427
44213
|
* Reports text under `minFontSize` pixels, naming the smallest element and
|
|
43428
44214
|
* how many more fall under, at most one finding per frame.
|
|
@@ -43433,7 +44219,7 @@ async function checkFontSize(page, target, minFontSize) {
|
|
|
43433
44219
|
const smallest = under.reduce((least, text) => text.size < least.size ? text : least);
|
|
43434
44220
|
const others = under.length - 1;
|
|
43435
44221
|
const rest = others === 0 ? "" : `, and ${others} more ${others === 1 ? "element is" : "elements are"} under it`;
|
|
43436
|
-
return [finding$
|
|
44222
|
+
return [finding$3("min-font-size", {
|
|
43437
44223
|
frame: target.ref,
|
|
43438
44224
|
path: target.path,
|
|
43439
44225
|
message: `${target.ref} sets text at ${smallest.size} px in <${smallest.tag}> at element ${smallest.index}, under the project's ${minFontSize} px minimum${rest}.`
|
|
@@ -43472,20 +44258,30 @@ const HUG_MAX_WIDTH = FRAME_SIZES.desktop.width;
|
|
|
43472
44258
|
* Measures a frame's content the way `frame fit` and the server's hug step
|
|
43473
44259
|
* both read it, in one page resized between readings. A hugging width takes
|
|
43474
44260
|
* the content's `fit-content` width up to `HUG_MAX_WIDTH`, and the height is
|
|
43475
|
-
* read at that width with a 1 px tall viewport and again at the
|
|
44261
|
+
* read at that width with a 1 px tall viewport and again at the reference
|
|
44262
|
+
* height of the box's width, never the box's own height, so content sized off
|
|
44263
|
+
* the window height reads one height however tall the frame already is.
|
|
43476
44264
|
* Readings that differ mean the content sizes itself off the viewport, which
|
|
43477
|
-
* has no height of its own to fit, so that refuses `fit-unbounded`.
|
|
44265
|
+
* has no height of its own to fit, so that refuses `fit-unbounded`. A fresh
|
|
44266
|
+
* page then loads at the width and height it would answer, and content
|
|
44267
|
+
* drawing another height there, as a block sized once off the window height,
|
|
44268
|
+
* refuses the same way. Finite
|
|
43478
44269
|
* animations finish before the first reading, so an entrance is read at its
|
|
43479
44270
|
* settled size.
|
|
43480
44271
|
*/
|
|
43481
44272
|
async function measureContent(browser, { baseUrl, ref, box, hugWidth, fonts }) {
|
|
44273
|
+
const reference = referenceHeight(box.width);
|
|
43482
44274
|
const opened = await openFrame(browser, {
|
|
43483
44275
|
baseUrl,
|
|
43484
44276
|
ref,
|
|
43485
|
-
box
|
|
44277
|
+
box: {
|
|
44278
|
+
width: box.width,
|
|
44279
|
+
height: reference
|
|
44280
|
+
},
|
|
43486
44281
|
theme: "light",
|
|
43487
44282
|
fonts
|
|
43488
44283
|
});
|
|
44284
|
+
let size;
|
|
43489
44285
|
try {
|
|
43490
44286
|
const { page } = opened;
|
|
43491
44287
|
await page.evaluate(finishAnimations);
|
|
@@ -43494,8 +44290,9 @@ async function measureContent(browser, { baseUrl, ref, box, hugWidth, fonts }) {
|
|
|
43494
44290
|
if (hugWidth && !empty) {
|
|
43495
44291
|
await page.setViewportSize({
|
|
43496
44292
|
width: HUG_MAX_WIDTH,
|
|
43497
|
-
height:
|
|
44293
|
+
height: reference
|
|
43498
44294
|
});
|
|
44295
|
+
await settleResize(page);
|
|
43499
44296
|
width = Math.min(HUG_MAX_WIDTH, await page.evaluate(readFitWidth));
|
|
43500
44297
|
}
|
|
43501
44298
|
const short = await readAt(page, {
|
|
@@ -43504,13 +44301,13 @@ async function measureContent(browser, { baseUrl, ref, box, hugWidth, fonts }) {
|
|
|
43504
44301
|
});
|
|
43505
44302
|
const current = await readAt(page, {
|
|
43506
44303
|
width,
|
|
43507
|
-
height:
|
|
44304
|
+
height: reference
|
|
43508
44305
|
});
|
|
43509
|
-
if (short.height !== current.height) throw new FrameboardError("fit-unbounded", `${ref} grows with the viewport, measuring ${short.height} px in a 1 px viewport and ${current.height} px at its ${
|
|
44306
|
+
if (short.height !== current.height) throw new FrameboardError("fit-unbounded", `${ref} grows with the viewport, measuring ${short.height} px in a 1 px viewport and ${current.height} px at its ${reference} px reference height, so it has no content height to fit. Size it by hand with frame resize.`, {
|
|
43510
44307
|
ref,
|
|
43511
44308
|
heights: [short.height, current.height]
|
|
43512
44309
|
});
|
|
43513
|
-
|
|
44310
|
+
size = {
|
|
43514
44311
|
width,
|
|
43515
44312
|
height: short.height,
|
|
43516
44313
|
contentWidth: current.width,
|
|
@@ -43519,10 +44316,45 @@ async function measureContent(browser, { baseUrl, ref, box, hugWidth, fonts }) {
|
|
|
43519
44316
|
} finally {
|
|
43520
44317
|
await opened.close();
|
|
43521
44318
|
}
|
|
44319
|
+
if (size.empty || size.width === box.width && size.height === reference) return size;
|
|
44320
|
+
const confirmed = await readFreshAt(browser, {
|
|
44321
|
+
baseUrl,
|
|
44322
|
+
ref,
|
|
44323
|
+
box: {
|
|
44324
|
+
width: size.width,
|
|
44325
|
+
height: size.height
|
|
44326
|
+
}
|
|
44327
|
+
});
|
|
44328
|
+
if (confirmed.height !== size.height) throw new FrameboardError("fit-unbounded", `${ref} measures ${size.height} px but draws ${confirmed.height} px when opened at that height, so it sizes itself off the viewport it loads in, as a block set once from innerHeight does, and has no content height to fit. Size it by hand with frame resize, or with frame resize --scroll if it is meant to scroll.`, {
|
|
44329
|
+
ref,
|
|
44330
|
+
heights: [size.height, confirmed.height]
|
|
44331
|
+
});
|
|
44332
|
+
return size;
|
|
44333
|
+
}
|
|
44334
|
+
/**
|
|
44335
|
+
* Reads a frame's content in a page loaded fresh at `box`, animations
|
|
44336
|
+
* finished. It loads under `fonts: 'wait'` whatever the first open took, since
|
|
44337
|
+
* that open already refused a missing face or image, and `require` would wait
|
|
44338
|
+
* out a long entrance a second time on the load budget.
|
|
44339
|
+
*/
|
|
44340
|
+
async function readFreshAt(browser, options) {
|
|
44341
|
+
const opened = await openFrame(browser, {
|
|
44342
|
+
...options,
|
|
44343
|
+
theme: "light",
|
|
44344
|
+
fonts: "wait"
|
|
44345
|
+
});
|
|
44346
|
+
try {
|
|
44347
|
+
await opened.page.evaluate(finishAnimations);
|
|
44348
|
+
return await opened.page.evaluate(readContentSize);
|
|
44349
|
+
} finally {
|
|
44350
|
+
await opened.close();
|
|
44351
|
+
}
|
|
43522
44352
|
}
|
|
43523
44353
|
/**
|
|
43524
44354
|
* Sets a frame's height to its content's own height at its layout width and
|
|
43525
|
-
* turns its height hugging on
|
|
44355
|
+
* turns its height hugging on, measuring each linked width at its own width
|
|
44356
|
+
* and writing its height beside the frame's. The width is reported, never
|
|
44357
|
+
* changed.
|
|
43526
44358
|
*/
|
|
43527
44359
|
async function fitFrame(browser, { baseUrl, frame, ...options }) {
|
|
43528
44360
|
const measured = await measureContent(browser, {
|
|
@@ -43531,8 +44363,27 @@ async function fitFrame(browser, { baseUrl, frame, ...options }) {
|
|
|
43531
44363
|
box: frame.box,
|
|
43532
44364
|
hugWidth: false
|
|
43533
44365
|
});
|
|
44366
|
+
const widths = [];
|
|
44367
|
+
for (const { width } of frame.widths) {
|
|
44368
|
+
const linked = await measureContent(browser, {
|
|
44369
|
+
baseUrl,
|
|
44370
|
+
ref: frame.ref,
|
|
44371
|
+
box: {
|
|
44372
|
+
width,
|
|
44373
|
+
height: referenceHeight(width)
|
|
44374
|
+
},
|
|
44375
|
+
hugWidth: false
|
|
44376
|
+
});
|
|
44377
|
+
widths.push({
|
|
44378
|
+
width,
|
|
44379
|
+
height: linked.height
|
|
44380
|
+
});
|
|
44381
|
+
}
|
|
43534
44382
|
return {
|
|
43535
|
-
frame: await fitHeight(options.root, frame.ref, measured.height,
|
|
44383
|
+
frame: await fitHeight(options.root, frame.ref, measured.height, {
|
|
44384
|
+
...options,
|
|
44385
|
+
widths
|
|
44386
|
+
}),
|
|
43536
44387
|
contentHeight: measured.height,
|
|
43537
44388
|
contentWidth: measured.contentWidth,
|
|
43538
44389
|
tooWide: measured.contentWidth > frame.box.width
|
|
@@ -43540,8 +44391,19 @@ async function fitFrame(browser, { baseUrl, frame, ...options }) {
|
|
|
43540
44391
|
}
|
|
43541
44392
|
async function readAt(page, viewport) {
|
|
43542
44393
|
await page.setViewportSize(viewport);
|
|
44394
|
+
await settleResize(page);
|
|
43543
44395
|
return page.evaluate(readContentSize);
|
|
43544
44396
|
}
|
|
44397
|
+
/**
|
|
44398
|
+
* Waits two animation frames after a viewport resize, so a page's `resize`
|
|
44399
|
+
* listener has run and its layout settled before the next reading. A reading
|
|
44400
|
+
* taken straight after the resize sees the layout from before it.
|
|
44401
|
+
*/
|
|
44402
|
+
async function settleResize(page) {
|
|
44403
|
+
await page.evaluate(() => new Promise((resolve) => {
|
|
44404
|
+
requestAnimationFrame(() => requestAnimationFrame(() => resolve()));
|
|
44405
|
+
}));
|
|
44406
|
+
}
|
|
43545
44407
|
function finishAnimations() {
|
|
43546
44408
|
for (const animation of document.getAnimations()) {
|
|
43547
44409
|
const end = animation.effect?.getComputedTiming().endTime;
|
|
@@ -43651,7 +44513,7 @@ const LAYOUT_RULES = [
|
|
|
43651
44513
|
description: "Content sizes itself off the viewport height rather than holding a height of its own, a warning since a full-height screen does it on purpose"
|
|
43652
44514
|
}
|
|
43653
44515
|
];
|
|
43654
|
-
const finding$
|
|
44516
|
+
const finding$2 = findingFor(LAYOUT_RULES);
|
|
43655
44517
|
/**
|
|
43656
44518
|
* The slack a reading takes before it counts, so a subpixel edge rounding up
|
|
43657
44519
|
* is never a finding. One pixel matches what the groundwork spike measured.
|
|
@@ -43660,7 +44522,9 @@ const SLACK_PX = 1;
|
|
|
43660
44522
|
/**
|
|
43661
44523
|
* Runs the three layout rules on a frame open at its own box, at most one
|
|
43662
44524
|
* finding each. `viewport` reads a second time with the viewport twice as
|
|
43663
|
-
* tall, then puts the box back.
|
|
44525
|
+
* tall, then puts the box back. Each resize settles before the next read, so
|
|
44526
|
+
* a script sizing content on `resize` reads as the CSS case does, and the
|
|
44527
|
+
* rules after this one see the page back at its box.
|
|
43664
44528
|
*/
|
|
43665
44529
|
async function checkLayout(page, target) {
|
|
43666
44530
|
const { width, height } = target.box;
|
|
@@ -43671,18 +44535,20 @@ async function checkLayout(page, target) {
|
|
|
43671
44535
|
height: height * 2
|
|
43672
44536
|
});
|
|
43673
44537
|
try {
|
|
44538
|
+
await settleResize(page);
|
|
43674
44539
|
const tall = await page.evaluate(readContentSize);
|
|
43675
44540
|
const atTall = await page.evaluate(readLayout);
|
|
43676
44541
|
return [
|
|
43677
44542
|
clipped(target, atBox),
|
|
43678
44543
|
scrollbar(target, atBox),
|
|
43679
|
-
viewport(target, content.height, tall.height, atBox, atTall)
|
|
44544
|
+
target.scroll ? null : viewport(target, content.height, tall.height, atBox, atTall)
|
|
43680
44545
|
].filter((found) => found !== null);
|
|
43681
44546
|
} finally {
|
|
43682
44547
|
await page.setViewportSize({
|
|
43683
44548
|
width,
|
|
43684
44549
|
height
|
|
43685
44550
|
});
|
|
44551
|
+
await settleResize(page);
|
|
43686
44552
|
}
|
|
43687
44553
|
}
|
|
43688
44554
|
function clipped(target, read) {
|
|
@@ -43690,19 +44556,19 @@ function clipped(target, read) {
|
|
|
43690
44556
|
const shown = read.boxes.filter((box) => !box.cropped);
|
|
43691
44557
|
const bottom = Math.max(read.root.bottom, ...shown.map((box) => box.bottom));
|
|
43692
44558
|
const right = Math.max(read.root.right, ...shown.map((box) => box.right));
|
|
43693
|
-
const tall = bottom > height + SLACK_PX;
|
|
44559
|
+
const tall = !target.scroll && bottom > height + SLACK_PX;
|
|
43694
44560
|
const wide = right > width + SLACK_PX;
|
|
43695
44561
|
if (!tall && !wide) return null;
|
|
43696
44562
|
const past = shown.filter((box) => tall && box.bottom > height + SLACK_PX || wide && box.right > width + SLACK_PX);
|
|
43697
44563
|
const reach = [tall ? `${bottom} px tall in its ${height} px height` : null, wide ? `${right} px wide in its ${width} px width` : null].filter((part) => part !== null).join(" and ");
|
|
43698
|
-
return finding$
|
|
44564
|
+
return finding$2("clipped", {
|
|
43699
44565
|
frame: target.ref,
|
|
43700
44566
|
path: target.path,
|
|
43701
44567
|
message: `${target.ref} is ${reach}, so the board cuts it off${offenders(past, "past the box")}. ${clippedAdvice(tall, wide, width)}`
|
|
43702
44568
|
});
|
|
43703
44569
|
}
|
|
43704
44570
|
function clippedAdvice(tall, wide, width) {
|
|
43705
|
-
if (!wide) return "Run frame fit, or shorten the content.";
|
|
44571
|
+
if (!wide) return "Run frame fit, run frame resize --scroll for a page meant to scroll, or shorten the content.";
|
|
43706
44572
|
if (!tall) return `Reflow or shorten the content to fit its ${width} px width, since frame fit sets the height alone.`;
|
|
43707
44573
|
return `Run frame fit for the height, and reflow or shorten the content to fit its ${width} px width.`;
|
|
43708
44574
|
}
|
|
@@ -43711,7 +44577,7 @@ function scrollbar(target, read) {
|
|
|
43711
44577
|
const [first] = scrolling;
|
|
43712
44578
|
if (!first) return null;
|
|
43713
44579
|
const by = Math.max(first.overflowX, first.overflowY);
|
|
43714
|
-
return finding$
|
|
44580
|
+
return finding$2("scrollbar", {
|
|
43715
44581
|
frame: target.ref,
|
|
43716
44582
|
path: target.path,
|
|
43717
44583
|
message: `${target.ref} scrolls inside ${element(first)}, whose content is ${by} px past its box${more(scrolling.length - 1, "scrolls", "scroll")}. Size it to its content, or set overflow to hidden.`
|
|
@@ -43721,7 +44587,7 @@ function viewport(target, atBox, atTall, boxRead, tallRead) {
|
|
|
43721
44587
|
if (atTall <= atBox + SLACK_PX) return null;
|
|
43722
44588
|
const before = new Map(boxRead.boxes.map((box) => [box.index, box.height]));
|
|
43723
44589
|
const grown = tallRead.boxes.filter((box) => box.height > (before.get(box.index) ?? box.height) + SLACK_PX);
|
|
43724
|
-
return finding$
|
|
44590
|
+
return finding$2("viewport", {
|
|
43725
44591
|
frame: target.ref,
|
|
43726
44592
|
path: target.path,
|
|
43727
44593
|
message: `${target.ref} grows with the viewport, measuring ${atBox} px at its ${target.box.height} px height and ${atTall} px at twice that${offenders(grown, "growing")}. Give it a height of its own unless it is a full-height screen on purpose.`
|
|
@@ -43846,6 +44712,92 @@ function readLayout() {
|
|
|
43846
44712
|
scrollers
|
|
43847
44713
|
};
|
|
43848
44714
|
}
|
|
44715
|
+
// src/server/checks/browser/scroll-effect.ts
|
|
44716
|
+
const SCROLL_EFFECT_RULES = [{
|
|
44717
|
+
id: "scroll-effect",
|
|
44718
|
+
tier: "browser",
|
|
44719
|
+
severity: "warning",
|
|
44720
|
+
description: "A frame whose height hugs its content holds an effect driven by scrolling, being position: sticky, a window or document scroll listener, or a scroll or view timeline, which never runs since the frame never scrolls"
|
|
44721
|
+
}];
|
|
44722
|
+
const finding$1 = findingFor(SCROLL_EFFECT_RULES);
|
|
44723
|
+
/**
|
|
44724
|
+
* `scroll-effect`, at most one finding, on a frame that hugs its height and
|
|
44725
|
+
* holds no `scroll` key, naming the first trigger found. A listener counts
|
|
44726
|
+
* only on the window or the document, since those are the objects the
|
|
44727
|
+
* DevTools protocol is asked about, so one on an inner scroll container or an
|
|
44728
|
+
* observer driving the effect goes unseen and costs a hint, never an error.
|
|
44729
|
+
*/
|
|
44730
|
+
async function checkScrollEffect(page, target) {
|
|
44731
|
+
if (target.scroll || !target.hugHeight) return [];
|
|
44732
|
+
const trigger = await page.evaluate(readScrollStyles) ?? await readListener(page);
|
|
44733
|
+
if (!trigger) return [];
|
|
44734
|
+
return [finding$1("scroll-effect", {
|
|
44735
|
+
frame: target.ref,
|
|
44736
|
+
path: target.path,
|
|
44737
|
+
message: `${target.ref} ${describe$6(trigger)}, which needs the frame to scroll, but its height hugs the content so it never does. Run frame resize --scroll to hold a screen height and scroll past it.`
|
|
44738
|
+
})];
|
|
44739
|
+
}
|
|
44740
|
+
function describe$6(trigger) {
|
|
44741
|
+
switch (trigger.kind) {
|
|
44742
|
+
case "sticky": return `holds position: sticky on <${trigger.tag}> at element ${trigger.index}`;
|
|
44743
|
+
case "timeline": return `runs an animation on a scroll or view timeline from <${trigger.tag}> at element ${trigger.index}`;
|
|
44744
|
+
case "listener": return `listens for scroll on the ${trigger.target}`;
|
|
44745
|
+
}
|
|
44746
|
+
}
|
|
44747
|
+
async function readListener(page) {
|
|
44748
|
+
const session = await page.context().newCDPSession(page);
|
|
44749
|
+
try {
|
|
44750
|
+
for (const name of ["window", "document"]) {
|
|
44751
|
+
const { result } = await session.send("Runtime.evaluate", { expression: name });
|
|
44752
|
+
if (!result.objectId) continue;
|
|
44753
|
+
const { listeners } = await session.send("DOMDebugger.getEventListeners", { objectId: result.objectId });
|
|
44754
|
+
if (listeners.some((listener) => listener.type === "scroll")) return {
|
|
44755
|
+
kind: "listener",
|
|
44756
|
+
target: name
|
|
44757
|
+
};
|
|
44758
|
+
}
|
|
44759
|
+
return null;
|
|
44760
|
+
} finally {
|
|
44761
|
+
await session.detach();
|
|
44762
|
+
}
|
|
44763
|
+
}
|
|
44764
|
+
function readScrollStyles() {
|
|
44765
|
+
const isScrollTimeline = (timeline) => {
|
|
44766
|
+
const name = timeline?.constructor.name;
|
|
44767
|
+
return name === "ScrollTimeline" || name === "ViewTimeline";
|
|
44768
|
+
};
|
|
44769
|
+
const insideScroller = (element) => {
|
|
44770
|
+
for (let parent = element.parentElement; parent && parent !== document.body && parent !== document.documentElement; parent = parent.parentElement) {
|
|
44771
|
+
const { overflowX, overflowY } = getComputedStyle(parent);
|
|
44772
|
+
if (overflowX !== "visible" || overflowY !== "visible") return true;
|
|
44773
|
+
}
|
|
44774
|
+
return false;
|
|
44775
|
+
};
|
|
44776
|
+
let index = 0;
|
|
44777
|
+
for (const node of document.querySelectorAll("*")) {
|
|
44778
|
+
if (node.closest("[data-frameboard]")) continue;
|
|
44779
|
+
const own = index;
|
|
44780
|
+
index += 1;
|
|
44781
|
+
const style = getComputedStyle(node);
|
|
44782
|
+
const tag = node.tagName.toLowerCase();
|
|
44783
|
+
if (style.position === "sticky" && !insideScroller(node)) return {
|
|
44784
|
+
kind: "sticky",
|
|
44785
|
+
index: own,
|
|
44786
|
+
tag
|
|
44787
|
+
};
|
|
44788
|
+
const timeline = style.getPropertyValue("animation-timeline");
|
|
44789
|
+
if (/\b(scroll|view)\(/.test(timeline)) return {
|
|
44790
|
+
kind: "timeline",
|
|
44791
|
+
index: own,
|
|
44792
|
+
tag
|
|
44793
|
+
};
|
|
44794
|
+
}
|
|
44795
|
+
return document.getAnimations().some((animation) => isScrollTimeline(animation.timeline)) ? {
|
|
44796
|
+
kind: "timeline",
|
|
44797
|
+
index: 0,
|
|
44798
|
+
tag: "html"
|
|
44799
|
+
} : null;
|
|
44800
|
+
}
|
|
43849
44801
|
// src/server/checks/outranked.ts
|
|
43850
44802
|
const OUTRANKED_RULES = [{
|
|
43851
44803
|
id: "outranked",
|
|
@@ -44069,7 +45021,8 @@ const RULES = [
|
|
|
44069
45021
|
...LAYOUT_RULES,
|
|
44070
45022
|
...FONT_SIZE_RULES,
|
|
44071
45023
|
...CONTRAST_RULES,
|
|
44072
|
-
...DECLARATION_RULES
|
|
45024
|
+
...DECLARATION_RULES,
|
|
45025
|
+
...SCROLL_EFFECT_RULES
|
|
44073
45026
|
];
|
|
44074
45027
|
/** Checks every frame on one page. */
|
|
44075
45028
|
async function checkPage(root, project, page) {
|
|
@@ -44315,6 +45268,13 @@ const frameRecordSchema = object$1({
|
|
|
44315
45268
|
/** Whether each axis takes its size from the content rather than holding it. */
|
|
44316
45269
|
hugWidth: boolean$1(),
|
|
44317
45270
|
hugHeight: boolean$1(),
|
|
45271
|
+
/** Whether the frame holds a fixed screen height and scrolls past it, fixing both axes. */
|
|
45272
|
+
scroll: boolean$1(),
|
|
45273
|
+
/** The extra widths the frame also shows at, beside it in a row, none when it lists none. */
|
|
45274
|
+
widths: array$1(object$1({
|
|
45275
|
+
width: number(),
|
|
45276
|
+
height: number()
|
|
45277
|
+
})),
|
|
44318
45278
|
placed: boolean$1(),
|
|
44319
45279
|
modifiedAt: string$1()
|
|
44320
45280
|
});
|
|
@@ -44361,16 +45321,34 @@ const listResultSchema = object$1({
|
|
|
44361
45321
|
// src/shared/records/capture.ts
|
|
44362
45322
|
const themeSchema$1 = _enum$1(["light", "dark"]);
|
|
44363
45323
|
/** What `capture` returns: every PNG it wrote, one per frame and theme, or one per theme for a composite. */
|
|
44364
|
-
const captureResultSchema = object$1({
|
|
44365
|
-
|
|
44366
|
-
|
|
44367
|
-
|
|
44368
|
-
|
|
44369
|
-
|
|
44370
|
-
|
|
44371
|
-
|
|
44372
|
-
|
|
44373
|
-
|
|
45324
|
+
const captureResultSchema = object$1({
|
|
45325
|
+
images: array$1(object$1({
|
|
45326
|
+
ref: string$1(),
|
|
45327
|
+
theme: themeSchema$1,
|
|
45328
|
+
path: string$1(),
|
|
45329
|
+
/** The layout box in CSS pixels, whatever the scale. */
|
|
45330
|
+
width: int$1().min(1),
|
|
45331
|
+
height: int$1().min(1),
|
|
45332
|
+
/** Device pixels per CSS pixel, so the file is `width * scale` wide. */
|
|
45333
|
+
scale: int$1().min(1).max(3),
|
|
45334
|
+
/** How far down a `--scroll` shot reached, absent on a shot taken at the top. */
|
|
45335
|
+
scrollY: int$1().min(0).optional(),
|
|
45336
|
+
/** The moment in ms an `--at` shot holds, clamped to the timeline's end. */
|
|
45337
|
+
at: int$1().min(0).optional(),
|
|
45338
|
+
/** The moment in ms each `--filmstrip` frame holds, left to right. */
|
|
45339
|
+
moments: array$1(int$1().min(0)).optional()
|
|
45340
|
+
})),
|
|
45341
|
+
/** The timeline an `--at` or `--filmstrip` capture seeked, absent on any other. */
|
|
45342
|
+
motion: object$1({
|
|
45343
|
+
source: _enum$1([
|
|
45344
|
+
"hf",
|
|
45345
|
+
"timelines",
|
|
45346
|
+
"css"
|
|
45347
|
+
]),
|
|
45348
|
+
/** Its length in ms, or null when every animation repeats forever. */
|
|
45349
|
+
duration: int$1().min(0).nullable()
|
|
45350
|
+
}).optional()
|
|
45351
|
+
});
|
|
44374
45352
|
/** What `frame fit` returns: the frame as resized, the height it measured, and its width against the layout's. */
|
|
44375
45353
|
const fitResultSchema = object$1({
|
|
44376
45354
|
frame: frameRecordSchema,
|
|
@@ -44537,7 +45515,9 @@ const findingSchema = /* @__PURE__ */ object({
|
|
|
44537
45515
|
/** Board-relative, with forward slashes. */
|
|
44538
45516
|
path: /* @__PURE__ */ string(),
|
|
44539
45517
|
message: /* @__PURE__ */ string(),
|
|
44540
|
-
location: /* @__PURE__ */ nullable(findingLocationSchema)
|
|
45518
|
+
location: /* @__PURE__ */ nullable(findingLocationSchema),
|
|
45519
|
+
/** The linked width a browser finding was read at, absent at the frame's own. */
|
|
45520
|
+
width: /* @__PURE__ */ optional(int().check(/* @__PURE__ */ _gte(1)))
|
|
44541
45521
|
});
|
|
44542
45522
|
/**
|
|
44543
45523
|
* Whether the browser rules ran, so a reader can tell no browser findings
|
|
@@ -44806,7 +45786,9 @@ function contentFormat() {
|
|
|
44806
45786
|
defaultFrameSize: DEFAULT_FRAME_SIZE,
|
|
44807
45787
|
layout: [
|
|
44808
45788
|
"x and y are integers, width and height integers of at least 1, and order an integer of at least 0, where a higher order draws on top.",
|
|
44809
|
-
"hidden, locked, hugWidth, and
|
|
45789
|
+
"hidden, locked, hugWidth, hugHeight, and scroll read as false when absent, and an axis whose hug flag is false holds the size its entry states.",
|
|
45790
|
+
`scroll marks a frame that holds a fixed screen height and scrolls past it, such as a page with a sticky section. It fixes both axes, so either hug flag beside it reads as false, frame fit refuses it, and serve never measures it. frame add --scroll sets it, taking the height given or else the preset height of the width (${FRAME_SIZES.desktop.height} px at ${FRAME_SIZES.desktop.width}). frame resize --scroll sets it on a placed frame, dropping a hugging height to that preset height unless a height is given and keeping a fixed height as it stands, so resize a frame fixed past a screen with --height too. frame resize --no-scroll clears it, keeping the box.`,
|
|
45791
|
+
`widths lists the extra widths one frame file also shows at, as { width, height } objects, each drawn 80 px past the last in a row beside the frame at its y, so a responsive page is one file rather than a copy per width. Each width follows the frame's own height mode: it hugs its content at that width while hugHeight is on, and otherwise holds its height, the preset height of its width when first set and on frame resize --scroll. A value of any other shape reads as none. frame add --widths 834,390 and frame resize --widths set it, refusing a repeated width, the frame's own width, or a frame hugging its width, and frame resize --no-widths clears it. capture writes <frame>@<width>.<theme>.png beside <frame>.<theme>.png, check reports a browser finding at a linked width with that width and prints it as <path>@<width>, and a frames.json value of <project>/<page>/<frame>@<width> syncs that width's images.`,
|
|
44810
45792
|
`An axis that hugs takes its size from the frame's content: a running serve measures it after each write to the frame file and when frame add places a file already written, its width at most ${FRAME_SIZES.desktop.width} px, and writes width and height alone, never a flag. Content sized off the viewport keeps the box it has.`,
|
|
44811
45793
|
"frame add with no size hugs both axes, --size or --width fixes the width and hugs the height, and --height fixes the height alone, its box standing in until serve measures. frame resize and a hand resize fix each axis they set, and frame fit sets the height and turns hugHeight on.",
|
|
44812
45794
|
"Frames sort by order, then name, and a write that changes order renumbers the page from 0.",
|
|
@@ -45127,11 +46109,11 @@ async function reservationsOf(root, refs, options, cwd, now) {
|
|
|
45127
46109
|
}
|
|
45128
46110
|
return reservations;
|
|
45129
46111
|
}
|
|
45130
|
-
/** Where a new row starts on a frame's page, past its frames and reserved boxes. */
|
|
46112
|
+
/** Where a new row starts on a frame's page, past its frames' drawn rows and reserved boxes. */
|
|
45131
46113
|
async function rightOf(root, frame, live) {
|
|
45132
46114
|
const page = await scanPage(root, frame.project, frame.page, 0);
|
|
45133
46115
|
const prefix = `${frame.project}/${frame.page}/`;
|
|
45134
|
-
const boxes = [...page.frames.map((each) => each.box), ...live.flatMap((each) => each.box && each.frame.startsWith(prefix) ? [each.box] : [])];
|
|
46116
|
+
const boxes = [...page.frames.map((each) => drawnExtent(each.box, each.widths)), ...live.flatMap((each) => each.box && each.frame.startsWith(prefix) ? [each.box] : [])];
|
|
45135
46117
|
return Math.max(...boxes.map((box) => box.x + box.width + 80), 0);
|
|
45136
46118
|
}
|
|
45137
46119
|
function describe$4(claims, now) {
|
|
@@ -45145,6 +46127,14 @@ function describe$4(claims, now) {
|
|
|
45145
46127
|
// src/cli/commands/frame.ts
|
|
45146
46128
|
const FRAME_REF = "a frame ref, <page>/<frame> or <project>/<page>/<frame>, or a path to its .html file";
|
|
45147
46129
|
const ANY_INTEGER = parseInteger(Number.MIN_SAFE_INTEGER);
|
|
46130
|
+
const WIDTHS_HELP = "the extra widths the frame also shows at, a comma list such as 834,390, each drawn beside it and hugging or holding its height as the frame does";
|
|
46131
|
+
const POSITIVE = parseInteger(1);
|
|
46132
|
+
/** A comma list of positive integers, each checked as `--width` checks one. */
|
|
46133
|
+
function parseWidths(value) {
|
|
46134
|
+
return value.split(",").map((part) => POSITIVE(part.trim()));
|
|
46135
|
+
}
|
|
46136
|
+
const SCROLL_HELP = "hold a fixed screen height and scroll past it, fixing both axes, at the reference height of the width when no height is given";
|
|
46137
|
+
const RESIZE_SCROLL_HELP = "hold a fixed screen height and scroll past it, fixing both axes, dropping a hugging height to the reference height of the width and keeping a fixed one";
|
|
45148
46138
|
function registerFrame(program, context) {
|
|
45149
46139
|
const { io } = context;
|
|
45150
46140
|
const frame = program.command("frame").description("Manage frames");
|
|
@@ -45155,7 +46145,7 @@ function registerFrame(program, context) {
|
|
|
45155
46145
|
data: record,
|
|
45156
46146
|
human: `${what} ${record.ref}`
|
|
45157
46147
|
});
|
|
45158
|
-
act(withPosition(withSize(verb("add", "Place a frame past every frame, as written when its file exists and with a skeleton file only when none does, so write the file first to show no empty box. Each axis no size names hugs its content, so a preset or --width fixes the width and the height hugs."))), context, async ([ref = ""], options) => done(await addFrame(await boardOf(options, io), ref, {
|
|
46148
|
+
act(withPosition(withSize(verb("add", "Place a frame past every frame, as written when its file exists and with a skeleton file only when none does, so write the file first to show no empty box. Each axis no size names hugs its content, so a preset or --width fixes the width and the height hugs.").option("--scroll", SCROLL_HELP).option("--widths <list>", WIDTHS_HELP, parseWidths))), context, async ([ref = ""], options) => done(await addFrame(await boardOf(options, io), ref, {
|
|
45159
46149
|
...options,
|
|
45160
46150
|
cwd: io.cwd
|
|
45161
46151
|
}), "Added"));
|
|
@@ -45167,7 +46157,7 @@ function registerFrame(program, context) {
|
|
|
45167
46157
|
...options,
|
|
45168
46158
|
cwd: io.cwd
|
|
45169
46159
|
}), "Moved to"));
|
|
45170
|
-
act(withSize(verb("resize", "Set a frame size, fixing each axis it sets")), context, async ([ref = ""], options) => done(await resizeFrame(await boardOf(options, io), ref, {
|
|
46160
|
+
act(withSize(verb("resize", "Set a frame size, fixing each axis it sets").option("--scroll", RESIZE_SCROLL_HELP).option("--no-scroll", "clear scroll, keeping the box as it stands").option("--widths <list>", WIDTHS_HELP, parseWidths).option("--no-widths", "clear the extra widths")), context, async ([ref = ""], options) => done(await resizeFrame(await boardOf(options, io), ref, {
|
|
45171
46161
|
...options,
|
|
45172
46162
|
cwd: io.cwd
|
|
45173
46163
|
}), "Resized"));
|
|
@@ -45178,6 +46168,7 @@ function registerFrame(program, context) {
|
|
|
45178
46168
|
cwd: io.cwd
|
|
45179
46169
|
};
|
|
45180
46170
|
const frame = await readFrame$1(root, ref, refOptions);
|
|
46171
|
+
if (frame.scroll) throw fitScrollError(frame.ref);
|
|
45181
46172
|
const result = await withFrameHost({
|
|
45182
46173
|
root,
|
|
45183
46174
|
facesDir: context.facesDir
|
|
@@ -49364,7 +50355,7 @@ const OPTIONS = {
|
|
|
49364
50355
|
* write and `--check` both build through it, so they compare the same bytes.
|
|
49365
50356
|
*/
|
|
49366
50357
|
async function toReference(source, reference, folder) {
|
|
49367
|
-
const result = await (await importFormat(folder))(`${reference}.html`, withProjectAssets(source), OPTIONS);
|
|
50358
|
+
const result = await (await importFormat(folder))(`${reference}.html`, withProjectAssets(source, reference), OPTIONS);
|
|
49368
50359
|
const [error] = result.errors;
|
|
49369
50360
|
if (error) {
|
|
49370
50361
|
const [reason] = error.message.split("\n");
|
|
@@ -49375,14 +50366,17 @@ async function toReference(source, reference, folder) {
|
|
|
49375
50366
|
/**
|
|
49376
50367
|
* Rewrites the frame's text only at the spans its loads occupy, so text naming
|
|
49377
50368
|
* `../assets/` that loads nothing, such as a `<code>` sample, keeps its bytes.
|
|
50369
|
+
* The link climbs one folder per folder the reference sits in, to the folder's
|
|
50370
|
+
* `assets/`.
|
|
49378
50371
|
*/
|
|
49379
|
-
function withProjectAssets(source) {
|
|
50372
|
+
function withProjectAssets(source, reference) {
|
|
50373
|
+
const assets = `${"../".repeat(reference.split("/").length - 1)}assets/${source.project}/`;
|
|
49380
50374
|
const framePath = boardPath(source.root, source.path);
|
|
49381
50375
|
const spans = /* @__PURE__ */ new Map();
|
|
49382
50376
|
for (const { path, location } of frameLoads(source)) if (path === framePath && location) spans.set(location.startOffset, location.endOffset);
|
|
49383
50377
|
let html = source.html;
|
|
49384
50378
|
for (const [start, end] of [...spans].sort(([a], [b]) => b - a)) {
|
|
49385
|
-
const span = html.slice(start, end).replace(BOARD_ASSETS,
|
|
50379
|
+
const span = html.slice(start, end).replace(BOARD_ASSETS, assets);
|
|
49386
50380
|
html = `${html.slice(0, start)}${span}${html.slice(end)}`;
|
|
49387
50381
|
}
|
|
49388
50382
|
return html;
|
|
@@ -49410,12 +50404,15 @@ async function importFormat(folder) {
|
|
|
49410
50404
|
}
|
|
49411
50405
|
}
|
|
49412
50406
|
// src/server/references/frame-map.ts
|
|
49413
|
-
const
|
|
49414
|
-
const
|
|
50407
|
+
const SEGMENT = "[a-z0-9]+(-[a-z0-9]+)*";
|
|
50408
|
+
const REFERENCE = new RegExp(`^${SEGMENT}(/${SEGMENT}){1,2}$`);
|
|
50409
|
+
const BOARD_REF = /^[^/\s]+\/[^/\s]+\/[^/\s@]+(@[1-9]\d*)?$/;
|
|
49415
50410
|
/**
|
|
49416
|
-
* Reads `frames.json`, mapping each reference, `<group>/<name
|
|
49417
|
-
* board frame `<project>/<page>/<frame>`
|
|
49418
|
-
*
|
|
50411
|
+
* Reads `frames.json`, mapping each reference, `<group>/<name>` or
|
|
50412
|
+
* `<group>/<section>/<name>`, to the board frame `<project>/<page>/<frame>`
|
|
50413
|
+
* it is captured from, or `<project>/<page>/<frame>@<width>` to capture it at
|
|
50414
|
+
* one of its widths. An entry in any other shape refuses rather than filing
|
|
50415
|
+
* into the wrong folder.
|
|
49419
50416
|
*/
|
|
49420
50417
|
function parseFrameMap(json) {
|
|
49421
50418
|
const parsed = parseJson(json);
|
|
@@ -49424,8 +50421,8 @@ function parseFrameMap(json) {
|
|
|
49424
50421
|
if (Object.keys(frames).length === 0) throw new FrameboardError("frame-map-invalid", "frames.json maps no frames, so a sync would remove every reference.");
|
|
49425
50422
|
const map = /* @__PURE__ */ new Map();
|
|
49426
50423
|
for (const [reference, ref] of Object.entries(frames)) {
|
|
49427
|
-
if (!REFERENCE.test(reference)) throw new FrameboardError("frame-map-invalid", `frames.json entry "${reference}" needs a kebab-case <group>/<name>.`, { reference });
|
|
49428
|
-
if (typeof ref !== "string" || !BOARD_REF.test(ref)) throw new FrameboardError("frame-map-invalid", `frames.json entry "${reference}" needs a board frame as <project>/<page>/<frame>.`, { reference });
|
|
50424
|
+
if (!REFERENCE.test(reference)) throw new FrameboardError("frame-map-invalid", `frames.json entry "${reference}" needs a kebab-case <group>/<name> or <group>/<section>/<name>.`, { reference });
|
|
50425
|
+
if (typeof ref !== "string" || !BOARD_REF.test(ref)) throw new FrameboardError("frame-map-invalid", `frames.json entry "${reference}" needs a board frame as <project>/<page>/<frame> or <project>/<page>/<frame>@<width>.`, { reference });
|
|
49429
50426
|
map.set(reference, ref);
|
|
49430
50427
|
}
|
|
49431
50428
|
return map;
|
|
@@ -49437,7 +50434,23 @@ function parseJson(json) {
|
|
|
49437
50434
|
throw new FrameboardError("frame-map-invalid", "frames.json does not parse as JSON.", {}, { cause: error });
|
|
49438
50435
|
}
|
|
49439
50436
|
}
|
|
49440
|
-
/**
|
|
50437
|
+
/** A mapped value as the board frame it names and the width it asks for, if any. */
|
|
50438
|
+
function mappedTarget(value) {
|
|
50439
|
+
const at = value.lastIndexOf("@");
|
|
50440
|
+
if (at === -1) return { ref: value };
|
|
50441
|
+
return {
|
|
50442
|
+
ref: value.slice(0, at),
|
|
50443
|
+
width: Number(value.slice(at + 1))
|
|
50444
|
+
};
|
|
50445
|
+
}
|
|
50446
|
+
/** Every value a map may name for one frame: its ref, and its ref at each width it shows at. */
|
|
50447
|
+
function frameTargets(frame) {
|
|
50448
|
+
return [frame.ref, ...[frame.box, ...frame.widths].map(({ width }) => `${frame.ref}@${width}`)];
|
|
50449
|
+
}
|
|
50450
|
+
/**
|
|
50451
|
+
* The mapped values the board does not hold, being a frame it lacks or a
|
|
50452
|
+
* width the frame does not show at, read against `frameTargets`.
|
|
50453
|
+
*/
|
|
49441
50454
|
function missingFrames(map, board) {
|
|
49442
50455
|
return [...map.values()].filter((ref) => !board.has(ref));
|
|
49443
50456
|
}
|
|
@@ -49484,8 +50497,8 @@ async function buildOutput({ root, folder, facesDir }) {
|
|
|
49484
50497
|
const map = parseFrameMap(await readFile(join(folder, "frames.json"), "utf8"));
|
|
49485
50498
|
const frames = await mappedFrames(root, map);
|
|
49486
50499
|
const output = /* @__PURE__ */ new Map();
|
|
49487
|
-
await Promise.all([...map].map(async ([reference,
|
|
49488
|
-
const { project, page, name } = frameOf(frames, ref);
|
|
50500
|
+
await Promise.all([...map].map(async ([reference, value]) => {
|
|
50501
|
+
const { project, page, name } = frameOf(frames, mappedTarget(value).ref);
|
|
49489
50502
|
const source = readFrame({
|
|
49490
50503
|
root,
|
|
49491
50504
|
project,
|
|
@@ -49495,18 +50508,35 @@ async function buildOutput({ root, folder, facesDir }) {
|
|
|
49495
50508
|
output.set(`${reference}.html`, await toReference(source, reference, folder));
|
|
49496
50509
|
for (const asset of frameAssets(source)) output.set(join("assets", project, asset), await readFile(join(assetsDirOf(source), asset)));
|
|
49497
50510
|
}));
|
|
50511
|
+
const targets = new Map([...map.values()].map((value) => {
|
|
50512
|
+
const { ref, width } = mappedTarget(value);
|
|
50513
|
+
const frame = frameOf(frames, ref);
|
|
50514
|
+
return [`${ref}@${width ?? frame.box.width}`, {
|
|
50515
|
+
frame,
|
|
50516
|
+
width
|
|
50517
|
+
}];
|
|
50518
|
+
}));
|
|
49498
50519
|
const captures = await mkdtemp(join(tmpdir(), "frameboard-references-"));
|
|
49499
50520
|
try {
|
|
49500
50521
|
const images = await withFrameHost({
|
|
49501
50522
|
root,
|
|
49502
50523
|
facesDir
|
|
49503
|
-
}, "references sync", (browser, baseUrl) =>
|
|
49504
|
-
|
|
49505
|
-
|
|
49506
|
-
|
|
49507
|
-
|
|
49508
|
-
|
|
49509
|
-
|
|
50524
|
+
}, "references sync", async (browser, baseUrl) => {
|
|
50525
|
+
const shot = [];
|
|
50526
|
+
for (const { frame, width } of targets.values()) shot.push(...await captureFrameImages(browser, {
|
|
50527
|
+
baseUrl,
|
|
50528
|
+
frames: [frame],
|
|
50529
|
+
themes: THEMES,
|
|
50530
|
+
out: captures,
|
|
50531
|
+
width: width ?? frame.box.width
|
|
50532
|
+
}));
|
|
50533
|
+
return shot;
|
|
50534
|
+
});
|
|
50535
|
+
for (const [reference, value] of map) {
|
|
50536
|
+
const { ref, width } = mappedTarget(value);
|
|
50537
|
+
const wanted = width ?? frameOf(frames, ref).box.width;
|
|
50538
|
+
for (const image of images.filter((image) => image.ref === ref && image.width === wanted)) output.set(`${reference}-${image.theme}.png`, await readFile(image.path));
|
|
50539
|
+
}
|
|
49510
50540
|
} finally {
|
|
49511
50541
|
await rm(captures, {
|
|
49512
50542
|
recursive: true,
|
|
@@ -49519,9 +50549,12 @@ async function buildOutput({ root, folder, facesDir }) {
|
|
|
49519
50549
|
async function mappedFrames(root, map) {
|
|
49520
50550
|
const { projects } = await scanBoard(root);
|
|
49521
50551
|
const board = new Map(projects.flatMap((project) => project.pages).flatMap((page) => page.frames).map((frame) => [frame.ref, frame]));
|
|
49522
|
-
const missing = missingFrames(map, new Set(board.
|
|
50552
|
+
const missing = missingFrames(map, new Set([...board.values()].flatMap(frameTargets)));
|
|
49523
50553
|
if (missing.length > 0) throw new FrameboardError("frame-not-found", `No board frame for: ${missing.join(", ")}. Nothing written.`, { missing });
|
|
49524
|
-
return new Map([...map.values()].map((
|
|
50554
|
+
return new Map([...map.values()].map((value) => {
|
|
50555
|
+
const { ref } = mappedTarget(value);
|
|
50556
|
+
return [ref, frameOf(board, ref)];
|
|
50557
|
+
}));
|
|
49525
50558
|
}
|
|
49526
50559
|
function frameOf(frames, ref) {
|
|
49527
50560
|
const frame = frames.get(ref);
|
|
@@ -49817,7 +50850,8 @@ function createThumbnailStore({ root, run, render, onRendered }) {
|
|
|
49817
50850
|
...LAYOUT_RULES,
|
|
49818
50851
|
...FONT_SIZE_RULES,
|
|
49819
50852
|
...CONTRAST_RULES,
|
|
49820
|
-
...DECLARATION_RULES
|
|
50853
|
+
...DECLARATION_RULES,
|
|
50854
|
+
...SCROLL_EFFECT_RULES
|
|
49821
50855
|
];
|
|
49822
50856
|
/** The rules that read one theme's page and land one finding at most. */
|
|
49823
50857
|
const THEMED_RULES = [
|
|
@@ -49830,7 +50864,8 @@ const THEMED_RULES = [
|
|
|
49830
50864
|
* dark, and merges the two. A rule tripping in one theme alone names that
|
|
49831
50865
|
* theme in its message. A missing face is measured in the fallback the board
|
|
49832
50866
|
* shows rather than refused, since the board shows it too. The declaration
|
|
49833
|
-
*
|
|
50867
|
+
* and scroll-effect rules read no theme, so they run on the first theme's
|
|
50868
|
+
* page alone.
|
|
49834
50869
|
*/
|
|
49835
50870
|
async function checkRendered(browser, { baseUrl, root, frame, config }) {
|
|
49836
50871
|
const [project = "", page = "", name = ""] = frame.ref.split("/");
|
|
@@ -49841,7 +50876,7 @@ async function checkRendered(browser, { baseUrl, root, frame, config }) {
|
|
|
49841
50876
|
name
|
|
49842
50877
|
});
|
|
49843
50878
|
const byTheme = /* @__PURE__ */ new Map();
|
|
49844
|
-
let
|
|
50879
|
+
let unthemed = [];
|
|
49845
50880
|
for (const theme of THEMES) {
|
|
49846
50881
|
const opened = await openFrame(browser, {
|
|
49847
50882
|
baseUrl,
|
|
@@ -49856,12 +50891,12 @@ async function checkRendered(browser, { baseUrl, root, frame, config }) {
|
|
|
49856
50891
|
...config.minFontSize === void 0 ? [] : await checkFontSize(opened.page, frame, config.minFontSize),
|
|
49857
50892
|
...config.minContrast === void 0 ? [] : await checkContrast(opened.page, frame, config.minContrast)
|
|
49858
50893
|
]);
|
|
49859
|
-
if (theme === THEMES[0])
|
|
50894
|
+
if (theme === THEMES[0]) unthemed = [...await checkDeclarations(opened.page, source), ...await checkScrollEffect(opened.page, frame)];
|
|
49860
50895
|
} finally {
|
|
49861
50896
|
await opened.close();
|
|
49862
50897
|
}
|
|
49863
50898
|
}
|
|
49864
|
-
return [...mergeThemes(byTheme), ...
|
|
50899
|
+
return [...mergeThemes(byTheme), ...unthemed];
|
|
49865
50900
|
}
|
|
49866
50901
|
/**
|
|
49867
50902
|
* One finding per rule across themes, in rule order. A rule both themes trip
|
|
@@ -49934,6 +50969,8 @@ async function landReserved(root, now) {
|
|
|
49934
50969
|
locked: false,
|
|
49935
50970
|
hugWidth: hugWidth ?? false,
|
|
49936
50971
|
hugHeight: hugHeight ?? false,
|
|
50972
|
+
scroll: false,
|
|
50973
|
+
widths: [],
|
|
49937
50974
|
placed: true
|
|
49938
50975
|
});
|
|
49939
50976
|
layout.renumber();
|
|
@@ -53315,6 +54352,23 @@ function placedRefs(previous, next, paths) {
|
|
|
53315
54352
|
const before = new Set(previous.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.filter((frame) => frame.placed).map((frame) => frame.ref))));
|
|
53316
54353
|
return next.projects.flatMap((project) => project.pages.filter((page) => !written || written.has(join(page.path, "layout.json"))).flatMap((page) => page.frames.filter((frame) => frame.placed && (frame.hugWidth || frame.hugHeight) && !before.has(frame.ref)).map((frame) => frame.ref)));
|
|
53317
54354
|
}
|
|
54355
|
+
/**
|
|
54356
|
+
* The frames hugging their height whose list of linked widths differs
|
|
54357
|
+
* between two scans, as a `frame resize --widths` leaves one. That write
|
|
54358
|
+
* touches `layout.json` alone, which reloads nothing, so a width it adds is
|
|
54359
|
+
* measured here or holds its stand-in height until the frame file is next
|
|
54360
|
+
* written. A frame absent from `previous` is `placedRefs`'s to name.
|
|
54361
|
+
*/
|
|
54362
|
+
function relistedRefs(previous, next) {
|
|
54363
|
+
const before = new Map(previous.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.map((frame) => [frame.ref, listed(frame)]))));
|
|
54364
|
+
return next.projects.flatMap((project) => project.pages.flatMap((page) => page.frames.filter((frame) => {
|
|
54365
|
+
const was = before.get(frame.ref);
|
|
54366
|
+
return frame.placed && frame.hugHeight && frame.widths.length > 0 && was !== void 0 && was !== listed(frame);
|
|
54367
|
+
}).map((frame) => frame.ref)));
|
|
54368
|
+
}
|
|
54369
|
+
function listed(frame) {
|
|
54370
|
+
return frame.widths.map(({ width }) => width).join(",");
|
|
54371
|
+
}
|
|
53318
54372
|
// src/server/live/findings.ts
|
|
53319
54373
|
/**
|
|
53320
54374
|
* The board's check findings, held between batches so a hello needs no
|
|
@@ -53568,20 +54622,20 @@ function send(socket, message) {
|
|
|
53568
54622
|
function createHug({ root, measure }) {
|
|
53569
54623
|
let queue = Promise.resolve();
|
|
53570
54624
|
let closed = false;
|
|
53571
|
-
const run = async (board, refs) => {
|
|
54625
|
+
const run = async (board, refs, parts) => {
|
|
53572
54626
|
const pages = /* @__PURE__ */ new Map();
|
|
53573
54627
|
let stale = false;
|
|
53574
|
-
for (const frame of huggingFrames(board, refs)) {
|
|
54628
|
+
for (const frame of huggingFrames(board, refs, parts)) {
|
|
53575
54629
|
if (closed) return false;
|
|
53576
54630
|
let size;
|
|
53577
54631
|
try {
|
|
53578
|
-
size = await measure
|
|
54632
|
+
size = await measureParts(measure, frame, parts);
|
|
53579
54633
|
} catch (error) {
|
|
53580
54634
|
if (error instanceof FrameboardError && error.code === "browser-not-found") break;
|
|
53581
54635
|
continue;
|
|
53582
54636
|
}
|
|
53583
|
-
if (size.
|
|
53584
|
-
stale ||= frame.hugWidth && size.width !== frame.box.width || frame.hugHeight && size.height !== frame.box.height;
|
|
54637
|
+
if (Object.keys(size).length === 0) continue;
|
|
54638
|
+
stale ||= frame.hugWidth && size.width !== void 0 && size.width !== frame.box.width || frame.hugHeight && size.height !== void 0 && size.height !== frame.box.height;
|
|
53585
54639
|
const page = `${frame.project}/${frame.page}`;
|
|
53586
54640
|
pages.set(page, [...pages.get(page) ?? [], {
|
|
53587
54641
|
frame,
|
|
@@ -53603,20 +54657,55 @@ function createHug({ root, measure }) {
|
|
|
53603
54657
|
}
|
|
53604
54658
|
return written || stale;
|
|
53605
54659
|
};
|
|
54660
|
+
const enqueue = (board, refs, parts) => {
|
|
54661
|
+
if (closed || huggingFrames(board, refs, parts).length === 0) return;
|
|
54662
|
+
queue = queue.then(() => run(board, refs, parts)).catch(() => {});
|
|
54663
|
+
};
|
|
53606
54664
|
return {
|
|
53607
|
-
now: (board, refs) =>
|
|
53608
|
-
|
|
53609
|
-
|
|
53610
|
-
|
|
54665
|
+
now: async (board, refs) => {
|
|
54666
|
+
const stale = await run(board, refs, "own");
|
|
54667
|
+
enqueue(board, refs, "linked");
|
|
54668
|
+
return stale;
|
|
53611
54669
|
},
|
|
54670
|
+
later: (board, refs) => enqueue(board, refs, "all"),
|
|
53612
54671
|
close: () => {
|
|
53613
54672
|
closed = true;
|
|
53614
54673
|
}
|
|
53615
54674
|
};
|
|
53616
54675
|
}
|
|
53617
|
-
|
|
54676
|
+
/**
|
|
54677
|
+
* Reads the parts a run asks for, a linked width only on a frame hugging its
|
|
54678
|
+
* height. An empty body at the frame's own box, or at every linked width,
|
|
54679
|
+
* reads nothing for that part, so the box it stands in for holds.
|
|
54680
|
+
*/
|
|
54681
|
+
async function measureParts(measure, frame, parts) {
|
|
54682
|
+
const size = {};
|
|
54683
|
+
if (parts !== "linked") {
|
|
54684
|
+
const own = await measure(frame);
|
|
54685
|
+
if (!own.empty) Object.assign(size, {
|
|
54686
|
+
width: own.width,
|
|
54687
|
+
height: own.height
|
|
54688
|
+
});
|
|
54689
|
+
}
|
|
54690
|
+
if (parts !== "own" && frame.hugHeight && frame.widths.length > 0) {
|
|
54691
|
+
const widths = [];
|
|
54692
|
+
for (const { width } of frame.widths) {
|
|
54693
|
+
const linked = await measure(frame, {
|
|
54694
|
+
width,
|
|
54695
|
+
height: referenceHeight(width)
|
|
54696
|
+
});
|
|
54697
|
+
if (!linked.empty) widths.push({
|
|
54698
|
+
width,
|
|
54699
|
+
height: linked.height
|
|
54700
|
+
});
|
|
54701
|
+
}
|
|
54702
|
+
if (widths.length > 0) size.widths = widths;
|
|
54703
|
+
}
|
|
54704
|
+
return size;
|
|
54705
|
+
}
|
|
54706
|
+
function huggingFrames(board, refs, parts) {
|
|
53618
54707
|
const wanted = new Set(refs);
|
|
53619
|
-
return board.projects.flatMap((project) => project.pages).flatMap((page) => page.frames).filter((frame) => wanted.has(frame.ref) && frame.placed && (frame.hugWidth || frame.hugHeight));
|
|
54708
|
+
return board.projects.flatMap((project) => project.pages).flatMap((page) => page.frames).filter((frame) => wanted.has(frame.ref) && frame.placed && (parts === "linked" ? frame.hugHeight && frame.widths.length > 0 : frame.hugWidth || frame.hugHeight));
|
|
53620
54709
|
}
|
|
53621
54710
|
/**
|
|
53622
54711
|
* The hugging frames whose file was written after their page's `layout.json`,
|
|
@@ -53649,6 +54738,41 @@ function ownFileRefs(board, paths) {
|
|
|
53649
54738
|
}
|
|
53650
54739
|
// src/server/live/rendered-findings.ts
|
|
53651
54740
|
/**
|
|
54741
|
+
* Runs `check` at the frame's own box, then at each linked width it lists,
|
|
54742
|
+
* tagging each finding read at a linked width with that width. A linked
|
|
54743
|
+
* finding the own box already reported, being the same rule and message at
|
|
54744
|
+
* the same place, is left out, since it is no fault of that width. A null
|
|
54745
|
+
* reading at any box answers null for the frame.
|
|
54746
|
+
*/
|
|
54747
|
+
async function acrossWidths(frame, check) {
|
|
54748
|
+
const own = await check({
|
|
54749
|
+
width: frame.box.width,
|
|
54750
|
+
height: frame.box.height
|
|
54751
|
+
});
|
|
54752
|
+
if (own === null) return null;
|
|
54753
|
+
const seen = new Set(own.map(sameness));
|
|
54754
|
+
const findings = [...own];
|
|
54755
|
+
for (const { width, height } of frame.widths) {
|
|
54756
|
+
const linked = await check({
|
|
54757
|
+
width,
|
|
54758
|
+
height
|
|
54759
|
+
});
|
|
54760
|
+
if (linked === null) return null;
|
|
54761
|
+
for (const finding of linked) if (!seen.has(sameness(finding))) findings.push({
|
|
54762
|
+
...finding,
|
|
54763
|
+
width
|
|
54764
|
+
});
|
|
54765
|
+
}
|
|
54766
|
+
return findings;
|
|
54767
|
+
}
|
|
54768
|
+
function sameness(finding) {
|
|
54769
|
+
return JSON.stringify([
|
|
54770
|
+
finding.rule,
|
|
54771
|
+
finding.message,
|
|
54772
|
+
finding.location
|
|
54773
|
+
]);
|
|
54774
|
+
}
|
|
54775
|
+
/**
|
|
53652
54776
|
* The server's warm checker. Rechecks run one at a time on their own queue,
|
|
53653
54777
|
* so a PNG never waits behind them, and a ref queued again before its result
|
|
53654
54778
|
* lands drops that result, so the board never shows findings from an older
|
|
@@ -53718,7 +54842,7 @@ function createRenderedFindings({ check, onResult }) {
|
|
|
53718
54842
|
known = frames;
|
|
53719
54843
|
const due = new Set(refs);
|
|
53720
54844
|
for (const [ref, frame] of frames) {
|
|
53721
|
-
const from = `${frame.box.width}x${
|
|
54845
|
+
const from = `${[frame.box, ...frame.widths].map(({ width, height }) => `${width}x${height}`).join(",")}@${frame.modifiedAt}`;
|
|
53722
54846
|
if (seen.get(ref) !== from) due.add(ref);
|
|
53723
54847
|
seen.set(ref, from);
|
|
53724
54848
|
}
|
|
@@ -53935,6 +55059,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
53935
55059
|
scanning = run.catch(() => {});
|
|
53936
55060
|
return run;
|
|
53937
55061
|
};
|
|
55062
|
+
let closing;
|
|
53938
55063
|
const findings = createBoardFindings(root, tokens ?? null);
|
|
53939
55064
|
const delivery = createDelivery({
|
|
53940
55065
|
pending: (session) => queuedFor(root, session),
|
|
@@ -54048,6 +55173,10 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
54048
55173
|
browser,
|
|
54049
55174
|
scale: 2
|
|
54050
55175
|
});
|
|
55176
|
+
const renderFilmstrip = createWarmFilmstripRenderer({
|
|
55177
|
+
baseUrl,
|
|
55178
|
+
browser
|
|
55179
|
+
});
|
|
54051
55180
|
const thumbnails = createThumbnailStore({
|
|
54052
55181
|
root,
|
|
54053
55182
|
run: randomUUID().slice(0, 8),
|
|
@@ -54065,19 +55194,19 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
54065
55194
|
await thumbnails.empty();
|
|
54066
55195
|
const rendered = createRenderedFindings({
|
|
54067
55196
|
check: async (frame) => {
|
|
54068
|
-
const list = await checkRendered(await browser.get(), {
|
|
55197
|
+
const list = await acrossWidths(frame, async (box) => checkRendered(await browser.get(), {
|
|
54069
55198
|
baseUrl: baseUrl(),
|
|
54070
55199
|
root,
|
|
54071
55200
|
frame: {
|
|
54072
55201
|
ref: frame.ref,
|
|
54073
55202
|
path: boardPath(root, frame.path),
|
|
54074
|
-
box
|
|
54075
|
-
|
|
54076
|
-
|
|
54077
|
-
}
|
|
55203
|
+
box,
|
|
55204
|
+
scroll: frame.scroll,
|
|
55205
|
+
hugHeight: frame.hugHeight
|
|
54078
55206
|
},
|
|
54079
55207
|
config: readConfig(root, frame.project)
|
|
54080
|
-
});
|
|
55208
|
+
}));
|
|
55209
|
+
if (list === null) return null;
|
|
54081
55210
|
return await modifiedAt(frame.path) === frame.modifiedAt ? list : null;
|
|
54082
55211
|
},
|
|
54083
55212
|
onResult: (ref, list) => {
|
|
@@ -54090,11 +55219,11 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
54090
55219
|
});
|
|
54091
55220
|
}
|
|
54092
55221
|
});
|
|
54093
|
-
const measure = async (frame) => measureContent(await browser.get(), {
|
|
55222
|
+
const measure = async (frame, box) => measureContent(await browser.get(), {
|
|
54094
55223
|
baseUrl: baseUrl(),
|
|
54095
55224
|
ref: frame.ref,
|
|
54096
|
-
box: frame.box,
|
|
54097
|
-
hugWidth: frame.hugWidth,
|
|
55225
|
+
box: box ?? frame.box,
|
|
55226
|
+
hugWidth: box === void 0 && frame.hugWidth,
|
|
54098
55227
|
fonts: "wait"
|
|
54099
55228
|
});
|
|
54100
55229
|
const hug = createHug({
|
|
@@ -54115,6 +55244,7 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
54115
55244
|
history,
|
|
54116
55245
|
selection,
|
|
54117
55246
|
renderFrame,
|
|
55247
|
+
renderFilmstrip,
|
|
54118
55248
|
clipboard: clipboardFiles(),
|
|
54119
55249
|
thumbnails,
|
|
54120
55250
|
measure,
|
|
@@ -54217,24 +55347,32 @@ async function listen({ clientDir, facesDir, root, tokens, port, openUrl, launch
|
|
|
54217
55347
|
token = next;
|
|
54218
55348
|
},
|
|
54219
55349
|
boardUrl,
|
|
54220
|
-
close:
|
|
54221
|
-
|
|
54222
|
-
|
|
54223
|
-
|
|
54224
|
-
|
|
54225
|
-
|
|
54226
|
-
|
|
54227
|
-
|
|
54228
|
-
|
|
54229
|
-
|
|
54230
|
-
|
|
54231
|
-
|
|
54232
|
-
|
|
54233
|
-
|
|
54234
|
-
|
|
54235
|
-
|
|
54236
|
-
|
|
54237
|
-
|
|
55350
|
+
close: () => {
|
|
55351
|
+
closing ??= (async () => {
|
|
55352
|
+
rendered.close();
|
|
55353
|
+
hug.close();
|
|
55354
|
+
claims.close();
|
|
55355
|
+
for (const [timer, release] of settling) {
|
|
55356
|
+
clearTimeout(timer);
|
|
55357
|
+
release();
|
|
55358
|
+
}
|
|
55359
|
+
await Promise.all([
|
|
55360
|
+
watcher.close(),
|
|
55361
|
+
hub.close(),
|
|
55362
|
+
browser.close(),
|
|
55363
|
+
emptyTrash(root)
|
|
55364
|
+
]);
|
|
55365
|
+
await new Promise((done, fail) => {
|
|
55366
|
+
server.close((error) => error ? fail(error) : done());
|
|
55367
|
+
server.closeAllConnections();
|
|
55368
|
+
});
|
|
55369
|
+
let tail;
|
|
55370
|
+
do {
|
|
55371
|
+
tail = scanning;
|
|
55372
|
+
await tail;
|
|
55373
|
+
} while (tail !== scanning);
|
|
55374
|
+
})();
|
|
55375
|
+
return closing;
|
|
54238
55376
|
}
|
|
54239
55377
|
};
|
|
54240
55378
|
}
|
|
@@ -54250,6 +55388,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
54250
55388
|
let board;
|
|
54251
55389
|
let own;
|
|
54252
55390
|
let placed;
|
|
55391
|
+
let relisted = [];
|
|
54253
55392
|
try {
|
|
54254
55393
|
await landReserved(root, /* @__PURE__ */ new Date()).catch(() => []);
|
|
54255
55394
|
board = await scanBoard(root);
|
|
@@ -54257,6 +55396,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
54257
55396
|
scanned.board = board;
|
|
54258
55397
|
own = ownFileRefs(board, paths);
|
|
54259
55398
|
placed = previous ? placedRefs(previous, board, paths).filter((ref) => !own.includes(ref)) : [];
|
|
55399
|
+
relisted = previous ? relistedRefs(previous, board) : [];
|
|
54260
55400
|
if (await hug.now(board, [...own, ...placed]).catch(() => false)) {
|
|
54261
55401
|
const measured = board;
|
|
54262
55402
|
board = await scanBoard(root);
|
|
@@ -54277,7 +55417,7 @@ async function pushBatch(root, tokens, paths, { hub, findings, rendered, deliver
|
|
|
54277
55417
|
const last = shown.board;
|
|
54278
55418
|
shown.board = board;
|
|
54279
55419
|
const refs = reloadRefs(root, paths, board, tokens);
|
|
54280
|
-
hug.later(board, refs.filter((ref) => !own.includes(ref) && !placed.includes(ref)));
|
|
55420
|
+
hug.later(board, [.../* @__PURE__ */ new Set([...refs, ...relisted])].filter((ref) => !own.includes(ref) && !placed.includes(ref)));
|
|
54281
55421
|
if (refs.length > 0) {
|
|
54282
55422
|
const reloads = unmovedRefs(refs, board, moved(), last);
|
|
54283
55423
|
if (reloads.length > 0) hub.broadcast({
|