frameboard 0.46.0 → 0.48.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 +245 -65
- package/dist/client/assets/index-BamvK2uK.css +2 -0
- package/dist/client/assets/index-JezGKuvY.js +165 -0
- package/dist/client/index.html +2 -2
- package/dist/frame-bridge.js +74 -74
- package/package.json +1 -1
- package/dist/client/assets/index-7T-3-XIO.css +0 -2
- package/dist/client/assets/index-DS22rwPq.js +0 -165
package/dist/cli.js
CHANGED
|
@@ -9635,22 +9635,42 @@ function topInset(device, turn) {
|
|
|
9635
9635
|
return device === "phone" && !isTurned(device, turn) ? STATUS_BAR.height : 0;
|
|
9636
9636
|
}
|
|
9637
9637
|
/**
|
|
9638
|
-
* The
|
|
9639
|
-
*
|
|
9640
|
-
* the page
|
|
9638
|
+
* The width a turned phone's or foldable's page stands in from each side edge
|
|
9639
|
+
* its island can stand on, 10 past the island as a phone's status bar ends,
|
|
9640
|
+
* so the island never covers it and the page stays centered. 0 otherwise.
|
|
9641
|
+
*/
|
|
9642
|
+
function sideInset(device, turn) {
|
|
9643
|
+
if (!isTurned(device, turn)) return 0;
|
|
9644
|
+
if (device === "phone") return STATUS_BAR.height;
|
|
9645
|
+
return device === "foldable" ? FOLDABLE_ISLAND.top + FOLDABLE_ISLAND.height + 10 : 0;
|
|
9646
|
+
}
|
|
9647
|
+
/** Whether a page stands in from its box, so the strips around it paint the page's fill. */
|
|
9648
|
+
function insetsPage(device, turn) {
|
|
9649
|
+
return topInset(device, turn) > 0 || sideInset(device, turn) > 0;
|
|
9650
|
+
}
|
|
9651
|
+
/**
|
|
9652
|
+
* The page's box inside a frame's box, less an upright phone's status bar or
|
|
9653
|
+
* a turned phone's or foldable's side insets. A frame's box keeps the screen's size, and
|
|
9654
|
+
* every surface reads the page through this.
|
|
9641
9655
|
*/
|
|
9642
9656
|
function pageBox(box, device, turn) {
|
|
9643
|
-
const
|
|
9657
|
+
const top = topInset(device, turn);
|
|
9658
|
+
const side = sideInset(device, turn);
|
|
9644
9659
|
return {
|
|
9645
|
-
x: box.x,
|
|
9646
|
-
y: box.y +
|
|
9647
|
-
width: box.width,
|
|
9648
|
-
height: Math.max(0, box.height -
|
|
9660
|
+
x: box.x + side,
|
|
9661
|
+
y: box.y + top,
|
|
9662
|
+
width: Math.max(0, box.width - 2 * side),
|
|
9663
|
+
height: Math.max(0, box.height - top)
|
|
9649
9664
|
};
|
|
9650
9665
|
}
|
|
9651
|
-
/**
|
|
9666
|
+
/**
|
|
9667
|
+
* The page's corners as a CSS `border-radius`, square on top under an upright
|
|
9668
|
+
* phone's status bar and square all round between a turned phone's or
|
|
9669
|
+
* foldable's strips.
|
|
9670
|
+
*/
|
|
9652
9671
|
function pageCorners(device, turn) {
|
|
9653
|
-
if (
|
|
9672
|
+
if (sideInset(device, turn) > 0) return "0";
|
|
9673
|
+
if (device !== "phone") return screenCorners(device);
|
|
9654
9674
|
const { screenRadius } = BEZELS.phone;
|
|
9655
9675
|
return `0 0 ${screenRadius}px ${screenRadius}px`;
|
|
9656
9676
|
}
|
|
@@ -25392,7 +25412,7 @@ async function isDirectory(path) {
|
|
|
25392
25412
|
}
|
|
25393
25413
|
}
|
|
25394
25414
|
// package.json
|
|
25395
|
-
var version$1 = "0.
|
|
25415
|
+
var version$1 = "0.48.0";
|
|
25396
25416
|
var dependencies = { "playwright-core": "1.65.0" };
|
|
25397
25417
|
var peerDependencies = { "oxfmt": "0.78.0" };
|
|
25398
25418
|
// src/shared/version.ts
|
|
@@ -38920,11 +38940,16 @@ function declaredValues(style, property) {
|
|
|
38920
38940
|
return declarations(style).segments.filter((segment) => propertyOf(segment) === property).map((segment) => segment.slice(segment.indexOf(":") + 1).trim());
|
|
38921
38941
|
}
|
|
38922
38942
|
/**
|
|
38923
|
-
* The part of a decoded style's last shorthand
|
|
38924
|
-
*
|
|
38925
|
-
*
|
|
38943
|
+
* The part of a decoded style's last shorthand a paint longhand or padding
|
|
38944
|
+
* side reads, which `setDeclaration` writes in place of the longhand.
|
|
38945
|
+
* Undefined where no shorthand or no such part is declared.
|
|
38926
38946
|
*/
|
|
38927
38947
|
function shorthandValue(style, property) {
|
|
38948
|
+
const side = PADDING_LONGHANDS.indexOf(property);
|
|
38949
|
+
if (side >= 0) {
|
|
38950
|
+
const padding = declaredValues(style, "padding").at(-1);
|
|
38951
|
+
return padding === void 0 ? void 0 : paddingSides(padding)?.[side];
|
|
38952
|
+
}
|
|
38928
38953
|
const shorthand = PART_SHORTHANDS[property];
|
|
38929
38954
|
if (!shorthand) return void 0;
|
|
38930
38955
|
const value = declaredValues(style, shorthand).at(-1);
|
|
@@ -38932,9 +38957,17 @@ function shorthandValue(style, property) {
|
|
|
38932
38957
|
}
|
|
38933
38958
|
/**
|
|
38934
38959
|
* Sets or drops one declaration, dropping later ones so nothing overrides the
|
|
38935
|
-
* edit, and refusing a style ending inside an open quote or comment.
|
|
38960
|
+
* edit, and refusing a style ending inside an open quote or comment. A padding
|
|
38961
|
+
* side folds the inline padding into one `padding` once all four are declared.
|
|
38936
38962
|
*/
|
|
38937
38963
|
function setDeclaration(style, property, value) {
|
|
38964
|
+
const written = writeDeclaration(style, property, value);
|
|
38965
|
+
return written.ok && PADDING_LONGHANDS.includes(property) ? {
|
|
38966
|
+
ok: true,
|
|
38967
|
+
style: foldPadding(written.style)
|
|
38968
|
+
} : written;
|
|
38969
|
+
}
|
|
38970
|
+
function writeDeclaration(style, property, value) {
|
|
38938
38971
|
const parsed = declarations(style);
|
|
38939
38972
|
if (parsed.isOpen) return { ok: false };
|
|
38940
38973
|
const longhands = SHORTHAND_LONGHANDS[property] ?? [];
|
|
@@ -38974,6 +39007,68 @@ function setDeclaration(style, property, value) {
|
|
|
38974
39007
|
}).join(";")
|
|
38975
39008
|
};
|
|
38976
39009
|
}
|
|
39010
|
+
const PADDING_LONGHANDS = SHORTHAND_LONGHANDS.padding ?? [];
|
|
39011
|
+
/**
|
|
39012
|
+
* A length or percentage `padding` accepts, so a fold never puts a value one
|
|
39013
|
+
* side would drop into a shorthand, where it would drop all four.
|
|
39014
|
+
*/
|
|
39015
|
+
const PADDING_LENGTH = /^(?:0|(?:\d+(?:\.\d+)?|\.\d+)(?:%|px|r?em|r?lh|r?ex|r?ch|r?cap|r?ic|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max)|pt|pc|cm|mm|q|in))$/i;
|
|
39016
|
+
/** The top, right, bottom, and left a padding shorthand sets, if each is a plain length. */
|
|
39017
|
+
function paddingSides(value) {
|
|
39018
|
+
const parts = value.trim().split(/\s+/);
|
|
39019
|
+
if (parts.length > 4 || !parts.every((part) => PADDING_LENGTH.test(part))) return;
|
|
39020
|
+
const [top = "", right = top, bottom = top, left = right] = parts;
|
|
39021
|
+
return [
|
|
39022
|
+
top,
|
|
39023
|
+
right,
|
|
39024
|
+
bottom,
|
|
39025
|
+
left
|
|
39026
|
+
];
|
|
39027
|
+
}
|
|
39028
|
+
function paddingShorthand([top, right, bottom, left]) {
|
|
39029
|
+
if (left !== right) return `${top} ${right} ${bottom} ${left}`;
|
|
39030
|
+
if (bottom !== top) return `${top} ${right} ${bottom}`;
|
|
39031
|
+
return right === top ? `${top}` : `${top} ${right}`;
|
|
39032
|
+
}
|
|
39033
|
+
/**
|
|
39034
|
+
* Folds the padding into one `padding` once all four sides are inline, so it
|
|
39035
|
+
* overrides nothing a sheet sets. Leaves it as written where a side is no plain
|
|
39036
|
+
* length, or a comment, a logical side, or a later shorthand would disagree.
|
|
39037
|
+
*/
|
|
39038
|
+
function foldPadding(style) {
|
|
39039
|
+
const { segments } = declarations(style);
|
|
39040
|
+
const sides = [
|
|
39041
|
+
void 0,
|
|
39042
|
+
void 0,
|
|
39043
|
+
void 0,
|
|
39044
|
+
void 0
|
|
39045
|
+
];
|
|
39046
|
+
const at = [];
|
|
39047
|
+
for (const [index, segment] of segments.entries()) {
|
|
39048
|
+
const property = propertyOf(segment);
|
|
39049
|
+
if (!property.startsWith("padding")) continue;
|
|
39050
|
+
if (segment.includes("/*")) return style;
|
|
39051
|
+
const value = segment.slice(segment.indexOf(":") + 1);
|
|
39052
|
+
if (property === "padding") {
|
|
39053
|
+
const all = paddingSides(value);
|
|
39054
|
+
if (!all || at.length > 0) return style;
|
|
39055
|
+
sides.splice(0, 4, ...all);
|
|
39056
|
+
} else {
|
|
39057
|
+
const side = PADDING_LONGHANDS.indexOf(property);
|
|
39058
|
+
if (side < 0 || !PADDING_LENGTH.test(value.trim())) return style;
|
|
39059
|
+
sides[side] = value.trim();
|
|
39060
|
+
}
|
|
39061
|
+
at.push(index);
|
|
39062
|
+
}
|
|
39063
|
+
const [first] = at;
|
|
39064
|
+
const known = sides.filter((side) => side !== void 0);
|
|
39065
|
+
if (first === void 0 || at.length < 2 || known.length < 4) return style;
|
|
39066
|
+
const lead = /^\s*/.exec(segments[first] ?? "")?.[0] ?? "";
|
|
39067
|
+
return segments.flatMap((segment, index) => {
|
|
39068
|
+
if (index === first) return [`${lead}padding: ${paddingShorthand(known)}`];
|
|
39069
|
+
return at.includes(index) ? [] : [segment];
|
|
39070
|
+
}).join(";");
|
|
39071
|
+
}
|
|
38977
39072
|
/**
|
|
38978
39073
|
* The segments with `value` in the last shorthand's part, so a paint edit
|
|
38979
39074
|
* leaves no dead token behind, null when a later declaration would still win.
|
|
@@ -39331,7 +39426,7 @@ function elementTree(source, layouts = [], rounds = [], facts = []) {
|
|
|
39331
39426
|
parent: parent === body ? null : index.get(parent) ?? null,
|
|
39332
39427
|
tag: element.tagName,
|
|
39333
39428
|
name: elementName(element),
|
|
39334
|
-
textOnly: ownText$1(element) !== null,
|
|
39429
|
+
textOnly: ownText$1(element) !== null || element.tagName === "p" && isEmpty(element),
|
|
39335
39430
|
layout: layouts[at] ?? "block",
|
|
39336
39431
|
round: (rounds[at] ?? false) && isEmpty(element),
|
|
39337
39432
|
placed: isPlaced(facts[at])
|
|
@@ -39532,7 +39627,7 @@ function elementMarkup(element, paint, font) {
|
|
|
39532
39627
|
};
|
|
39533
39628
|
const box = (shape) => `${size(shape)}; background: ${fill}`;
|
|
39534
39629
|
switch (element.kind) {
|
|
39535
|
-
case "text": return `<p data-name="Text" style="font-family: ${font}; width: fit-content"
|
|
39630
|
+
case "text": return `<p data-name="Text" style="font-family: ${font}; width: fit-content"></p>`;
|
|
39536
39631
|
case "rectangle": return `<div data-name="Rectangle" style="${box(element)}"></div>`;
|
|
39537
39632
|
case "ellipse": return `<div data-name="Ellipse" style="${box(element)}; border-radius: 50%"></div>`;
|
|
39538
39633
|
case "divider": return `<hr data-name="Divider" style="align-self: stretch; margin: 0; border: 0; ${element.vertical ? "border-left" : "border-top"}: 1px solid ${line}">`;
|
|
@@ -47795,7 +47890,7 @@ function createWarmRenderer({ baseUrl, browser, scale: defaultScale }) {
|
|
|
47795
47890
|
let colors = null;
|
|
47796
47891
|
try {
|
|
47797
47892
|
await hideControls(opened.page);
|
|
47798
|
-
if (
|
|
47893
|
+
if (insetsPage(device, frame.turn)) colors = await readPageColors(opened.page);
|
|
47799
47894
|
shot = element === void 0 ? await opened.page.screenshot({
|
|
47800
47895
|
animations: "disabled",
|
|
47801
47896
|
caret: "hide"
|
|
@@ -47851,16 +47946,14 @@ async function shootElement(page, ref, index, scale) {
|
|
|
47851
47946
|
* page the size of the body, so the PNG holds the body and nothing past it.
|
|
47852
47947
|
*/
|
|
47853
47948
|
async function drawBezel(browser, shot, box, { device, pose = "closed", island = "compact", turn, bar }, scale) {
|
|
47854
|
-
const
|
|
47949
|
+
const screen = {
|
|
47855
47950
|
x: 0,
|
|
47856
47951
|
y: 0,
|
|
47857
|
-
|
|
47858
|
-
|
|
47859
|
-
|
|
47860
|
-
|
|
47861
|
-
|
|
47862
|
-
...box
|
|
47863
|
-
}, device, turn);
|
|
47952
|
+
width: box.width,
|
|
47953
|
+
height: box.height
|
|
47954
|
+
};
|
|
47955
|
+
const outer = bezelBox(screen, device, turn);
|
|
47956
|
+
const page = pageBox(screen, device, turn);
|
|
47864
47957
|
const laptop = device === "laptop";
|
|
47865
47958
|
const context = await browser.newContext({
|
|
47866
47959
|
viewport: {
|
|
@@ -47872,9 +47965,9 @@ async function drawBezel(browser, shot, box, { device, pose = "closed", island =
|
|
|
47872
47965
|
try {
|
|
47873
47966
|
const tab = await context.newPage();
|
|
47874
47967
|
const sideways = turnOf(turn);
|
|
47875
|
-
const marks = device === "phone" ? sideways === "upright" ? statusBarHtml(bar.colors, bar.theme) + phoneMarks(island) : turnedPhoneMarks(island, sideways) : laptop ? laptopMarks(box) : device === "foldable" ? foldableMarks(pose, sideways) : "";
|
|
47968
|
+
const marks = device === "phone" ? sideways === "upright" ? statusBarHtml(bar.colors, bar.theme) + phoneMarks(island) : sideStripsHtml(bar.colors, bar.theme) + turnedPhoneMarks(island, sideways) : laptop ? laptopMarks(box) : device === "foldable" ? (sideways === "upright" ? "" : sideStripsHtml(bar.colors, bar.theme, { device })) + foldableMarks(pose, sideways) : "";
|
|
47876
47969
|
const radius = screenCorners(device);
|
|
47877
|
-
await tab.setContent(`<!doctype html><html><body style="margin:0;background:transparent"><div style="position:absolute;left:${-outer.x}px;top:${-outer.y}px;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left
|
|
47970
|
+
await tab.setContent(`<!doctype html><html><body style="margin:0;background:transparent"><div style="position:absolute;left:${-outer.x}px;top:${-outer.y}px;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left:${page.x}px;top:${page.y}px;width:${page.width}px;height:${page.height}px;border-radius:${pageCorners(device, turn)}"><div style="position:absolute;inset:0;border-radius:${radius};box-shadow:${bezelShadow(device, { board: false })}">${marks}</div></div></body></html>`, { waitUntil: "load" });
|
|
47878
47971
|
return await tab.screenshot({
|
|
47879
47972
|
omitBackground: true,
|
|
47880
47973
|
caret: "hide"
|
|
@@ -47884,22 +47977,27 @@ async function drawBezel(browser, shot, box, { device, pose = "closed", island =
|
|
|
47884
47977
|
}
|
|
47885
47978
|
}
|
|
47886
47979
|
/**
|
|
47887
|
-
* A phone frame's shot of its page set under the status bar,
|
|
47888
|
-
*
|
|
47980
|
+
* A phone frame's shot of its page set under the status bar upright, or a
|
|
47981
|
+
* phone's or foldable's between the side strips turned, at the frame's box
|
|
47982
|
+
* with no body, so a capture holds the screen the board draws.
|
|
47889
47983
|
*/
|
|
47890
|
-
async function
|
|
47984
|
+
async function underPageInsets(browser, shot, box, { device, turn, colors, theme }, scale) {
|
|
47891
47985
|
const page = pageBox({
|
|
47892
47986
|
x: 0,
|
|
47893
47987
|
y: 0,
|
|
47894
47988
|
...box
|
|
47895
|
-
},
|
|
47989
|
+
}, device, turn);
|
|
47990
|
+
const chrome = device && isTurned(device, turn) ? sideStripsHtml(colors, theme, {
|
|
47991
|
+
device,
|
|
47992
|
+
rounded: false
|
|
47993
|
+
}) : statusBarHtml(colors, theme, { rounded: false });
|
|
47896
47994
|
const context = await browser.newContext({
|
|
47897
47995
|
viewport: box,
|
|
47898
47996
|
deviceScaleFactor: scale
|
|
47899
47997
|
});
|
|
47900
47998
|
try {
|
|
47901
47999
|
const tab = await context.newPage();
|
|
47902
|
-
await tab.setContent(`<!doctype html><html><body style="margin:0;position:relative;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left
|
|
48000
|
+
await tab.setContent(`<!doctype html><html><body style="margin:0;position:relative;width:${box.width}px;height:${box.height}px"><img alt="" src="data:image/png;base64,${shot.toString("base64")}" style="position:absolute;left:${page.x}px;top:${page.y}px;width:${page.width}px;height:${page.height}px">` + chrome + `</body></html>`, { waitUntil: "load" });
|
|
47903
48001
|
return await tab.screenshot({ caret: "hide" });
|
|
47904
48002
|
} finally {
|
|
47905
48003
|
await context.close();
|
|
@@ -47909,7 +48007,7 @@ async function underStatusBar(browser, shot, box, { colors, theme }, scale) {
|
|
|
47909
48007
|
function readPageColors(page) {
|
|
47910
48008
|
return page.evaluate(pageColors);
|
|
47911
48009
|
}
|
|
47912
|
-
/** The viewport a frame's page opens at, its box less a phone's
|
|
48010
|
+
/** The viewport a frame's page opens at, its box less a phone's insets, at least one pixel tall. */
|
|
47913
48011
|
function pageSize(box, device, turn) {
|
|
47914
48012
|
const page = pageBox({
|
|
47915
48013
|
x: 0,
|
|
@@ -47934,6 +48032,17 @@ function statusBarHtml(colors, theme, { rounded = true } = {}) {
|
|
|
47934
48032
|
return `<div style="position:absolute;left:0;right:0;top:0;height:${STATUS_BAR.height}px;border-radius:${corners};color-scheme:${theme};background:${colors?.fill ?? "Canvas"};color:${colors?.ink ?? "CanvasText"}"><div style="position:absolute;left:0;right:0;top:${STATUS_BAR.band.top}px;height:${STATUS_BAR.band.height}px;box-sizing:border-box;display:flex;align-items:center;justify-content:space-between;padding:0 ${STATUS_BAR.side}px;font:600 ${STATUS_BAR.font}px/1 ${STATUS_FONT};font-variant-numeric:tabular-nums"><span>${STATUS_BAR.time}</span><span style="display:flex;align-items:center;gap:6px"><span style="display:flex;align-items:flex-end;gap:2px">${signal}</span>${battery}</span></div></div>`;
|
|
47935
48033
|
}
|
|
47936
48034
|
/**
|
|
48035
|
+
* A turned phone's or foldable's two side strips as the board draws them, the
|
|
48036
|
+
* side inset wide in the page's fill or its theme's own, rounded on the
|
|
48037
|
+
* screen's outer corners inside a body and square on a frame's bare box.
|
|
48038
|
+
*/
|
|
48039
|
+
function sideStripsHtml(colors, theme, { device = "phone", rounded = true } = {}) {
|
|
48040
|
+
const radius = rounded ? BEZELS[device].screenRadius : 0;
|
|
48041
|
+
const width = sideInset(device, "left");
|
|
48042
|
+
const strip = (side, corners) => `<div style="position:absolute;${side}:0;top:0;bottom:0;width:${width}px;border-radius:${corners};color-scheme:${theme};background:${colors?.fill ?? "Canvas"}"></div>`;
|
|
48043
|
+
return strip("left", `${radius}px 0 0 ${radius}px`) + strip("right", `0 ${radius}px ${radius}px 0`);
|
|
48044
|
+
}
|
|
48045
|
+
/**
|
|
47937
48046
|
* The laptop's chin and base as the board draws them, past the screen's
|
|
47938
48047
|
* bottom, with the body's edge as its last pixel rather than past it.
|
|
47939
48048
|
*/
|
|
@@ -48069,10 +48178,11 @@ async function readFreshAt(browser, options) {
|
|
|
48069
48178
|
* width too, reporting the width and never changing it.
|
|
48070
48179
|
*/
|
|
48071
48180
|
async function fitFrame(browser, { baseUrl, frame, ...options }) {
|
|
48181
|
+
const page = pageBox(frame.box, frame.device, frame.turn);
|
|
48072
48182
|
const measured = await measureContent(browser, {
|
|
48073
48183
|
baseUrl,
|
|
48074
48184
|
ref: frame.ref,
|
|
48075
|
-
box:
|
|
48185
|
+
box: page,
|
|
48076
48186
|
hugWidth: false
|
|
48077
48187
|
});
|
|
48078
48188
|
const widths = [];
|
|
@@ -48098,7 +48208,7 @@ async function fitFrame(browser, { baseUrl, frame, ...options }) {
|
|
|
48098
48208
|
}),
|
|
48099
48209
|
contentHeight: measured.height,
|
|
48100
48210
|
contentWidth: measured.contentWidth,
|
|
48101
|
-
tooWide: measured.contentWidth >
|
|
48211
|
+
tooWide: measured.contentWidth > page.width
|
|
48102
48212
|
};
|
|
48103
48213
|
}
|
|
48104
48214
|
async function readAt(page, viewport) {
|
|
@@ -50713,14 +50823,16 @@ async function holdShots(browser, { baseUrl, ref, view, device, turn, theme, sca
|
|
|
50713
50823
|
});
|
|
50714
50824
|
try {
|
|
50715
50825
|
const motion = await findMotion(opened.page, ref, motionTimeoutMs);
|
|
50716
|
-
const colors =
|
|
50826
|
+
const colors = insetsPage(device, turn) ? await readPageColors(opened.page) : null;
|
|
50717
50827
|
const held = [];
|
|
50718
50828
|
for (const moment of moments(motion)) {
|
|
50719
50829
|
const at = await seekMotion(opened.page, motion, moment);
|
|
50720
50830
|
const shot = await opened.page.screenshot(HELD_SCREENSHOT);
|
|
50721
50831
|
held.push({
|
|
50722
50832
|
held: at,
|
|
50723
|
-
bytes: colors ? await
|
|
50833
|
+
bytes: colors ? await underPageInsets(browser, shot, view, {
|
|
50834
|
+
device,
|
|
50835
|
+
turn,
|
|
50724
50836
|
colors,
|
|
50725
50837
|
theme
|
|
50726
50838
|
}, scale) : shot
|
|
@@ -50761,7 +50873,9 @@ async function renderFrame(browser, baseUrl, frame, view, theme, scale, scroll)
|
|
|
50761
50873
|
const scrollY = scroll === void 0 ? void 0 : await opened.page.evaluate(scrollAndSettle, scroll);
|
|
50762
50874
|
const shot = await opened.page.screenshot(SCREENSHOT);
|
|
50763
50875
|
return {
|
|
50764
|
-
bytes:
|
|
50876
|
+
bytes: insetsPage(device, frame.turn) ? await underPageInsets(browser, shot, box, {
|
|
50877
|
+
device,
|
|
50878
|
+
turn: frame.turn,
|
|
50765
50879
|
colors: await readPageColors(opened.page),
|
|
50766
50880
|
theme
|
|
50767
50881
|
}, scale) : shot,
|
|
@@ -51661,10 +51775,15 @@ const previewStartSchema = object$1({
|
|
|
51661
51775
|
/** What `preview --stop` returns: whether a link was running to end. */
|
|
51662
51776
|
const previewStopSchema = object$1({ stopped: boolean$1() });
|
|
51663
51777
|
// src/shared/records/references.ts
|
|
51664
|
-
/**
|
|
51778
|
+
/**
|
|
51779
|
+
* What `references sync` returns, each path relative to the folder and sorted.
|
|
51780
|
+
* `kept` names each held PNG left in place, since its frame's HTML, assets,
|
|
51781
|
+
* and size held still, and `written` the files the sync wrote.
|
|
51782
|
+
*/
|
|
51665
51783
|
const referencesSyncSchema = object$1({
|
|
51666
51784
|
folder: string$1(),
|
|
51667
51785
|
written: array$1(string$1()),
|
|
51786
|
+
kept: array$1(string$1()),
|
|
51668
51787
|
removed: array$1(string$1())
|
|
51669
51788
|
});
|
|
51670
51789
|
/**
|
|
@@ -51875,7 +51994,7 @@ function contentFormat() {
|
|
|
51875
51994
|
`showDevice true has the board draw the frame inside the device its width names: a phone from 320 to 479 px wide, a tablet from 480 to 1023, and a laptop from 1024 up, with none under 320. The phone's body stands ${BEZELS.phone.border} px past the box on every side, with side buttons 4 px past that, and the tablet's ${BEZELS.tablet.border}, and the laptop's lid ${BEZELS.laptop.border} px past its top and sides, with a chin and a wider base below. A resize redraws the body with no write, and list reports the device the width names as device, absent when off or under 320. It never changes the frame file, its size, or its box. frame add, frame duplicate, and a paste place a frame beside another with its own body, a laptop's base included, 80 px past the other's body. A frame given --x keeps that x, a frame landing in a reserved box keeps that box with no room for a device, and a placed frame stays where it stands when its device turns on. Linked widths draw no device. Any other value of showDevice reads as off and is kept on write. A device string from before showDevice reads as on, and the entry's next write replaces it with showDevice. frame add --device on and frame device <frame-ref> <on|off> set it, taking phone and tablet as on and none as off.`,
|
|
51876
51995
|
`While a phone shows, the board draws a status bar over the top ${STATUS_BAR.height} px of the frame's box, in the page's own fill and text color, and the page starts under it: a frame ${FRAME_SIZES.phone.width} by ${FRAME_SIZES.phone.height} shows a page ${FRAME_SIZES.phone.width} by ${FRAME_SIZES.phone.height - STATUS_BAR.height}. The box in layout.json keeps the screen's size, and the frame file gains no padding. A hugging height measures the page and stores it plus the bar, frame fit does the same, and capture, check, inspect, and present each read the page under the bar. An export draws the bar only with its device included, and lays the page out at the whole box without it. A linked width draws no device and no bar. With the device off, or on any other device, the page is the whole box.`,
|
|
51877
51996
|
`island wide has a phone draw its wide island, the one a call or a timer shows, and absent draws the compact one. It is kept while the device is off and reads as compact on any other device. Any other value reads as compact and is kept on write. frame device <frame-ref> --island wide sets it, --island compact clears it, and both refuse a frame whose width names no phone or that names the foldable.`,
|
|
51878
|
-
`turn left or right turns a phone, a tablet, or a foldable a quarter, with the island on the left side for left and the right for right, and absent stands it upright. A phone's or a tablet's first turn keeps the box's upright width and height in upright, and the upright width still picks the device, so a turned phone reads as a phone however wide its box. A fixed or scroll box swaps its sides, and a hugging one takes the reference height of its upright width, ${FRAME_SIZES.phone.height} px for a phone, and hugs its height at that width. A turned phone draws no status bar
|
|
51997
|
+
`turn left or right turns a phone, a tablet, or a foldable a quarter, with the island on the left side for left and the right for right, and absent stands it upright. A phone's or a tablet's first turn keeps the box's upright width and height in upright, and the upright width still picks the device, so a turned phone reads as a phone however wide its box. A fixed or scroll box swaps its sides, and a hugging one takes the reference height of its upright width, ${FRAME_SIZES.phone.height} px for a phone, and hugs its height at that width. A turned phone draws no status bar and insets its page ${STATUS_BAR.height} px from each short side instead, with both strips in the page's own fill so the island stands over no content, and its buttons stand on its long edges: an ${FRAME_SIZES.phone.height} by ${FRAME_SIZES.phone.width} turned box shows a page ${FRAME_SIZES.phone.height - 2 * STATUS_BAR.height} by ${FRAME_SIZES.phone.width}, and a hugging one hugs at that page width. list reports turn while the frame is turned, shown or not, and never upright. Turning upright restores the kept size, even after a hand resize of the turned box. A turned foldable keeps no upright, since its pose gives its screen: its box is that screen with the sides swapped, ${POSE_SIZES.closed.height} by ${POSE_SIZES.closed.width} closed and ${POSE_SIZES.open.height} by ${POSE_SIZES.open.width} half or open, its island sits where the quarter turn puts it, its fold runs across the screen, and its page insets ${sideInset("foldable", "left")} px from each side edge in the page's own fill as a turned phone's does, so a turned closed box shows a page ${POSE_SIZES.closed.height - 2 * sideInset("foldable", "left")} by ${POSE_SIZES.closed.width}. A fold keeps the turn and takes the new pose's swapped screen, upright restores the pose's screen, and --no-foldable stands it upright at that screen. frame device <frame-ref> --turn <upright|left|right> sets it, writing the layout entry alone, and a quarter turn refuses a laptop, a frame showing no device, and a frame holding extra widths, each with usage. A turned frame refuses new extra widths, and naming a turned phone or tablet the foldable stands it upright first. A phone's or a tablet's turn with no readable upright, or a value no reader knows, reads as upright.`,
|
|
51879
51998
|
`foldable true has the frame name the foldable device over the one its width picks, and pose folds it: closed is the cover screen at ${POSE_SIZES.closed.width} by ${POSE_SIZES.closed.height}, and half and open are the inner screen at ${POSE_SIZES.open.width} by ${POSE_SIZES.open.height}, half shading the fold. Naming a foldable or setting a pose sets the box's width and height to that screen and turns both hug flags off, and writes the layout entry alone, never the frame file, so one file shows every pose and its content reflows as on the device. The body stands ${BEZELS.foldable.border} px past the box on every side. A newly named foldable starts in the pose nearest its width, closed up to 678 px wide and open past it. list reports device as foldable while it shows, and pose on every frame naming one, shown or not. With showDevice off the box keeps its pose's size and no body draws. A foldable draws no linked width and refuses a new one, and widths its entry held from before stay in the file undrawn, draw again once --no-foldable un-names it, and clear on frame resize --no-widths. Any other value of foldable reads as width-picked, a pose no reader knows reads as closed, and both are kept on write. An older Frameboard rewriting the entry may drop both keys, leaving a width-picked frame at the pose's size. frame device <frame-ref> --foldable names it and shows it, --pose <closed|half|open> folds it, and --no-foldable hands the pick back to the width at the size it stands.`,
|
|
51880
51999
|
`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.`,
|
|
51881
52000
|
"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.",
|
|
@@ -52370,7 +52489,7 @@ function registerFrame(program, context) {
|
|
|
52370
52489
|
baseUrl,
|
|
52371
52490
|
frame
|
|
52372
52491
|
}));
|
|
52373
|
-
const wide = result.tooWide ? `, and its content is ${result.contentWidth} px wide against ${result.frame.box.width}` : "";
|
|
52492
|
+
const wide = result.tooWide ? `, and its content is ${result.contentWidth} px wide against its ${pageBox(result.frame.box, result.frame.device, result.frame.turn).width} px page` : "";
|
|
52374
52493
|
return {
|
|
52375
52494
|
data: result,
|
|
52376
52495
|
human: `Fit ${result.frame.ref} to ${result.contentHeight} px${wide}`
|
|
@@ -57623,37 +57742,74 @@ function frameTargets(frame) {
|
|
|
57623
57742
|
function missingFrames(map, board) {
|
|
57624
57743
|
return [...map.values()].filter((ref) => !board.has(ref));
|
|
57625
57744
|
}
|
|
57745
|
+
// src/server/references/keep.ts
|
|
57746
|
+
/**
|
|
57747
|
+
* The held PNGs whose reference's HTML, assets, and size held still, sorted,
|
|
57748
|
+
* since a re-capture of an unchanged frame can differ by browser and fonts.
|
|
57749
|
+
*/
|
|
57750
|
+
function keptImages(references, captured, held) {
|
|
57751
|
+
return references.filter(({ sources }) => sources.every((path) => sameBytes(captured.get(path), held.get(path)))).flatMap(({ images }) => images.filter((path) => sameSize(captured.get(path), held.get(path)))).sort();
|
|
57752
|
+
}
|
|
57753
|
+
function sameBytes(a, b) {
|
|
57754
|
+
return a !== void 0 && b !== void 0 && Buffer.from(a).equals(Buffer.from(b));
|
|
57755
|
+
}
|
|
57756
|
+
/** Whether both are held and the same size, or not PNGs to read a size from. */
|
|
57757
|
+
function sameSize(a, b) {
|
|
57758
|
+
if (a === void 0 || b === void 0) return false;
|
|
57759
|
+
const first = pngSize(Buffer.from(a));
|
|
57760
|
+
const second = pngSize(Buffer.from(b));
|
|
57761
|
+
if (!first || !second) return true;
|
|
57762
|
+
return first.width === second.width && first.height === second.height;
|
|
57763
|
+
}
|
|
57764
|
+
const SIGNATURE = Buffer.from([
|
|
57765
|
+
137,
|
|
57766
|
+
80,
|
|
57767
|
+
78,
|
|
57768
|
+
71,
|
|
57769
|
+
13,
|
|
57770
|
+
10,
|
|
57771
|
+
26,
|
|
57772
|
+
10
|
|
57773
|
+
]);
|
|
57774
|
+
/** The size a PNG's header states, which always opens on its IHDR chunk. */
|
|
57775
|
+
function pngSize(bytes) {
|
|
57776
|
+
if (bytes.length < 24 || !bytes.subarray(0, 8).equals(SIGNATURE)) return;
|
|
57777
|
+
return {
|
|
57778
|
+
width: bytes.readUInt32BE(16),
|
|
57779
|
+
height: bytes.readUInt32BE(20)
|
|
57780
|
+
};
|
|
57781
|
+
}
|
|
57626
57782
|
// src/server/references/sync.ts
|
|
57627
57783
|
/**
|
|
57628
|
-
* Writes
|
|
57629
|
-
*
|
|
57630
|
-
* the folder as it was.
|
|
57784
|
+
* Writes the board into the folder, keeping each PNG `keptImages` names unless
|
|
57785
|
+
* `rerender` is set, and removes every other file below its first level. A
|
|
57786
|
+
* refusal leaves the folder as it was, since the whole output is built first.
|
|
57631
57787
|
*/
|
|
57632
57788
|
async function syncReferences(options) {
|
|
57633
|
-
const { folder } = options;
|
|
57634
|
-
const output = await buildOutput(options);
|
|
57635
|
-
const
|
|
57636
|
-
|
|
57789
|
+
const { folder, rerender = false } = options;
|
|
57790
|
+
const { output, references } = await buildOutput(options);
|
|
57791
|
+
const files = await heldFiles(folder);
|
|
57792
|
+
const kept = rerender ? [] : keptImages(references, output, await readHeld(folder, files));
|
|
57793
|
+
const removed = files.filter((path) => !output.has(path));
|
|
57794
|
+
const written = [...output.keys()].filter((path) => !kept.includes(path));
|
|
57795
|
+
await Promise.all(written.map(async (path) => {
|
|
57637
57796
|
await mkdir(dirname(join(folder, path)), { recursive: true });
|
|
57638
|
-
await writeFile(join(folder, path),
|
|
57797
|
+
await writeFile(join(folder, path), output.get(path) ?? "");
|
|
57639
57798
|
}));
|
|
57640
57799
|
await Promise.all(removed.map((path) => rm(join(folder, path))));
|
|
57641
57800
|
await removeEmptyFolders(folder, folder);
|
|
57642
57801
|
return {
|
|
57643
57802
|
folder,
|
|
57644
|
-
written:
|
|
57803
|
+
written: written.sort(),
|
|
57804
|
+
kept,
|
|
57645
57805
|
removed: removed.sort()
|
|
57646
57806
|
};
|
|
57647
57807
|
}
|
|
57648
57808
|
/** Compares the folder against what a sync would write, writing nothing. */
|
|
57649
57809
|
async function checkReferences(options) {
|
|
57650
57810
|
const { folder } = options;
|
|
57651
|
-
const output = await buildOutput(options);
|
|
57652
|
-
const
|
|
57653
|
-
await Promise.all((await heldFiles(folder)).map(async (path) => {
|
|
57654
|
-
held.set(path, await readFile(join(folder, path)));
|
|
57655
|
-
}));
|
|
57656
|
-
const drift = classifyDrift(output, held);
|
|
57811
|
+
const { output } = await buildOutput(options);
|
|
57812
|
+
const drift = classifyDrift(output, await readHeld(folder, await heldFiles(folder)));
|
|
57657
57813
|
return {
|
|
57658
57814
|
folder,
|
|
57659
57815
|
changed: [...drift.changed].sort(),
|
|
@@ -57666,7 +57822,7 @@ async function buildOutput({ root, folder, facesDir }) {
|
|
|
57666
57822
|
const map = parseFrameMap(await readFile(join(folder, "frames.json"), "utf8"));
|
|
57667
57823
|
const frames = await mappedFrames(root, map);
|
|
57668
57824
|
const output = /* @__PURE__ */ new Map();
|
|
57669
|
-
await Promise.all([...map].map(async ([reference, value]) => {
|
|
57825
|
+
const references = await Promise.all([...map].map(async ([reference, value]) => {
|
|
57670
57826
|
const { project, page, name } = frameOf(frames, mappedTarget(value).ref);
|
|
57671
57827
|
const source = readFrame$1({
|
|
57672
57828
|
root,
|
|
@@ -57674,8 +57830,18 @@ async function buildOutput({ root, folder, facesDir }) {
|
|
|
57674
57830
|
page,
|
|
57675
57831
|
name
|
|
57676
57832
|
});
|
|
57677
|
-
|
|
57678
|
-
|
|
57833
|
+
const html = `${reference}.html`;
|
|
57834
|
+
output.set(html, await toReference(source, reference, folder));
|
|
57835
|
+
const assets = [];
|
|
57836
|
+
for (const asset of frameAssets(source)) {
|
|
57837
|
+
const path = join("assets", project, asset);
|
|
57838
|
+
assets.push(path);
|
|
57839
|
+
output.set(path, await readFile(join(assetsDirOf(source), asset)));
|
|
57840
|
+
}
|
|
57841
|
+
return {
|
|
57842
|
+
sources: [html, ...assets],
|
|
57843
|
+
images: THEMES.map((theme) => `${reference}-${theme}.png`)
|
|
57844
|
+
};
|
|
57679
57845
|
}));
|
|
57680
57846
|
const targets = new Map([...map.values()].map((value) => {
|
|
57681
57847
|
const { ref, width } = mappedTarget(value);
|
|
@@ -57712,7 +57878,17 @@ async function buildOutput({ root, folder, facesDir }) {
|
|
|
57712
57878
|
force: true
|
|
57713
57879
|
});
|
|
57714
57880
|
}
|
|
57715
|
-
return
|
|
57881
|
+
return {
|
|
57882
|
+
output,
|
|
57883
|
+
references
|
|
57884
|
+
};
|
|
57885
|
+
}
|
|
57886
|
+
async function readHeld(folder, paths) {
|
|
57887
|
+
const held = /* @__PURE__ */ new Map();
|
|
57888
|
+
await Promise.all(paths.map(async (path) => {
|
|
57889
|
+
held.set(path, await readFile(join(folder, path)));
|
|
57890
|
+
}));
|
|
57891
|
+
return held;
|
|
57716
57892
|
}
|
|
57717
57893
|
/** The board frame each mapped ref names, each once, or a refusal listing every one it lacks. */
|
|
57718
57894
|
async function mappedFrames(root, map) {
|
|
@@ -57745,7 +57921,7 @@ async function removeEmptyFolders(dir, folder) {
|
|
|
57745
57921
|
// src/cli/commands/references.ts
|
|
57746
57922
|
function registerReferences(program, context) {
|
|
57747
57923
|
const { io } = context;
|
|
57748
|
-
act(addVerb(program.command("references").description("Fill a folder of design references from the board's frames"), "sync", "Write each frame <folder>/frames.json maps as its HTML, a PNG per theme, and the project assets it loads, removing every other file below the folder's first level").argument("<folder>", "the folder holding frames.json").option("--check", "write nothing, and exit 14 when the folder differs from what a sync would write"), context, async ([given = ""], options) => {
|
|
57924
|
+
act(addVerb(program.command("references").description("Fill a folder of design references from the board's frames"), "sync", "Write each frame <folder>/frames.json maps as its HTML, a PNG per theme, and the project assets it loads, removing every other file below the folder's first level and keeping a held PNG whose frame's HTML, assets, and size held still").argument("<folder>", "the folder holding frames.json").option("--check", "write nothing, and exit 14 when the folder differs from what a sync would write").option("--rerender", "write every PNG, keeping none a held frame would, after a token sheet or kit edit or a change to how frames are captured, since the keep rule reads neither"), context, async ([given = ""], options) => {
|
|
57749
57925
|
const folder = resolve$1(io.cwd, given);
|
|
57750
57926
|
if (!existsSync(join(folder, "frames.json"))) throw new FrameboardError("usage", `${folder} holds no frames.json, mapping each reference to a board frame.`);
|
|
57751
57927
|
const target = {
|
|
@@ -57762,11 +57938,15 @@ function registerReferences(program, context) {
|
|
|
57762
57938
|
human: [`${folder} matches the board.`, ...lines].join("\n")
|
|
57763
57939
|
};
|
|
57764
57940
|
}
|
|
57765
|
-
const result = await syncReferences(
|
|
57941
|
+
const result = await syncReferences({
|
|
57942
|
+
...target,
|
|
57943
|
+
rerender: options.rerender
|
|
57944
|
+
});
|
|
57945
|
+
const kept = result.kept.length > 0 ? `, kept ${result.kept.length} held PNGs` : "";
|
|
57766
57946
|
const removed = result.removed.length > 0 ? `, removed ${result.removed.length}` : "";
|
|
57767
57947
|
return {
|
|
57768
57948
|
data: result,
|
|
57769
|
-
human: `Wrote ${result.written.length} files to ${folder}${removed}.`
|
|
57949
|
+
human: `Wrote ${result.written.length} files to ${folder}${kept}${removed}.`
|
|
57770
57950
|
};
|
|
57771
57951
|
});
|
|
57772
57952
|
}
|
|
@@ -61919,7 +62099,7 @@ async function measureParts(measure, frame, parts) {
|
|
|
61919
62099
|
box: page
|
|
61920
62100
|
});
|
|
61921
62101
|
if (!own.empty) Object.assign(size, {
|
|
61922
|
-
width: own.width,
|
|
62102
|
+
width: own.width + 2 * sideInset(frame.device, frame.turn),
|
|
61923
62103
|
height: own.height + topInset(frame.device, frame.turn)
|
|
61924
62104
|
});
|
|
61925
62105
|
}
|