frameboard 0.21.0 → 0.23.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 +166 -63
- package/dist/client/assets/index-CVpCu40m.css +2 -0
- package/dist/client/assets/index-b7uAYbhX.js +111 -0
- package/dist/client/index.html +2 -2
- package/dist/hook.js +143 -27
- package/package.json +1 -1
- package/dist/client/assets/index-Dclm9S1k.js +0 -111
- package/dist/client/assets/index-r_meC2Dg.css +0 -2
package/dist/cli.js
CHANGED
|
@@ -9109,6 +9109,20 @@ const DEVICE_SIZES = [
|
|
|
9109
9109
|
group: "slide",
|
|
9110
9110
|
width: 1024,
|
|
9111
9111
|
height: 768
|
|
9112
|
+
},
|
|
9113
|
+
{
|
|
9114
|
+
name: "og-card",
|
|
9115
|
+
label: "Open Graph",
|
|
9116
|
+
group: "social",
|
|
9117
|
+
width: 1200,
|
|
9118
|
+
height: 630
|
|
9119
|
+
},
|
|
9120
|
+
{
|
|
9121
|
+
name: "linkedin-post",
|
|
9122
|
+
label: "LinkedIn post",
|
|
9123
|
+
group: "social",
|
|
9124
|
+
width: 1200,
|
|
9125
|
+
height: 627
|
|
9112
9126
|
}
|
|
9113
9127
|
];
|
|
9114
9128
|
/** Every size name, the three presets first, then the devices. */
|
|
@@ -9482,7 +9496,7 @@ async function isDirectory(path) {
|
|
|
9482
9496
|
}
|
|
9483
9497
|
}
|
|
9484
9498
|
// package.json
|
|
9485
|
-
var version$1 = "0.
|
|
9499
|
+
var version$1 = "0.23.0";
|
|
9486
9500
|
var dependencies = { "playwright-core": "1.64.1" };
|
|
9487
9501
|
// src/shared/version.ts
|
|
9488
9502
|
const version = version$1;
|
|
@@ -27851,15 +27865,22 @@ function sheetBase(sheet) {
|
|
|
27851
27865
|
return dirname(sheet.path);
|
|
27852
27866
|
}
|
|
27853
27867
|
// src/server/checks/rule.ts
|
|
27854
|
-
/**
|
|
27855
|
-
|
|
27856
|
-
|
|
27857
|
-
|
|
27858
|
-
|
|
27859
|
-
|
|
27860
|
-
|
|
27861
|
-
|
|
27862
|
-
|
|
27868
|
+
/**
|
|
27869
|
+
* Builds findings for the rules `docs` declares, each at the level its doc
|
|
27870
|
+
* sets, so a module reports only the rules it documents.
|
|
27871
|
+
*/
|
|
27872
|
+
function findingFor(docs) {
|
|
27873
|
+
return (rule, fields) => {
|
|
27874
|
+
const doc = docs.find((candidate) => candidate.id === rule);
|
|
27875
|
+
if (!doc) throw new Error(`No rule doc declares ${rule}`);
|
|
27876
|
+
return {
|
|
27877
|
+
rule,
|
|
27878
|
+
severity: doc.severity,
|
|
27879
|
+
frame: fields.frame,
|
|
27880
|
+
path: fields.path,
|
|
27881
|
+
message: fields.message,
|
|
27882
|
+
location: fields.location ?? null
|
|
27883
|
+
};
|
|
27863
27884
|
};
|
|
27864
27885
|
}
|
|
27865
27886
|
/** One finding as `path:line:column rule message`, as `check` and the hook print it. */
|
|
@@ -27870,8 +27891,10 @@ function formatFinding(finding) {
|
|
|
27870
27891
|
const THEME_RULES = [{
|
|
27871
27892
|
id: "theme",
|
|
27872
27893
|
tier: "selector",
|
|
27894
|
+
severity: "error",
|
|
27873
27895
|
description: "A frame setting literal colors defines the other theme too, through a [data-theme] selector, a prefers-color-scheme query, or light-dark()"
|
|
27874
27896
|
}];
|
|
27897
|
+
const finding$9 = findingFor(THEME_RULES);
|
|
27875
27898
|
const COLOR_PROPERTIES$1 = /^(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;
|
|
27876
27899
|
const COLOR_FUNCTION = /\b(rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\(/i;
|
|
27877
27900
|
const HEX_COLOR = /#[0-9a-f]{3,8}\b/i;
|
|
@@ -27881,7 +27904,7 @@ function checkTheme(source) {
|
|
|
27881
27904
|
const { firstColor, bothThemes } = readThemeColors(source);
|
|
27882
27905
|
if (!firstColor || bothThemes) return [];
|
|
27883
27906
|
const { path, location } = firstColor;
|
|
27884
|
-
return [finding("theme", {
|
|
27907
|
+
return [finding$9("theme", {
|
|
27885
27908
|
frame: source.ref,
|
|
27886
27909
|
path,
|
|
27887
27910
|
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.",
|
|
@@ -28086,7 +28109,7 @@ function readTokenTable(root, paths) {
|
|
|
28086
28109
|
read.push({
|
|
28087
28110
|
label,
|
|
28088
28111
|
kind,
|
|
28089
|
-
tokens: readSheet(bytes.toString("utf8"))
|
|
28112
|
+
tokens: readSheet$1(bytes.toString("utf8"))
|
|
28090
28113
|
});
|
|
28091
28114
|
sheets.push({
|
|
28092
28115
|
path: label,
|
|
@@ -28125,7 +28148,7 @@ function readTokenTable(root, paths) {
|
|
|
28125
28148
|
}))
|
|
28126
28149
|
};
|
|
28127
28150
|
}
|
|
28128
|
-
function readSheet(css) {
|
|
28151
|
+
function readSheet$1(css) {
|
|
28129
28152
|
const tokens = /* @__PURE__ */ new Map();
|
|
28130
28153
|
postcss_default.parse(css).walkRules((rule) => {
|
|
28131
28154
|
const side = sideOf(rule);
|
|
@@ -38405,9 +38428,10 @@ function themeOf(value, usage) {
|
|
|
38405
38428
|
const NAME = /^--[\w-]+$/;
|
|
38406
38429
|
const UNSAFE_VALUE = /[;{}\n\r]|\/\*/;
|
|
38407
38430
|
/**
|
|
38408
|
-
* The project sheet with `edit` applied, every byte outside the
|
|
38409
|
-
* declarations left as it stood. `board` is the token's declarations
|
|
38410
|
-
* board sheet
|
|
38431
|
+
* The project or board sheet with `edit` applied, every byte outside the
|
|
38432
|
+
* token's declarations left as it stood. `board` is the token's declarations
|
|
38433
|
+
* in the board sheet under it, none when `css` is the board sheet itself. A
|
|
38434
|
+
* one-theme edit keeps the other theme rendering as it did,
|
|
38411
38435
|
* pinning its old value under that theme's rule when the new declaration
|
|
38412
38436
|
* would reach it, since a project `:root` ties a board dark rule on
|
|
38413
38437
|
* specificity and wins by coming later. Refuses `invalid-edit` for a name or
|
|
@@ -38460,7 +38484,7 @@ function tokenSides(css, name) {
|
|
|
38460
38484
|
return sidesIn(parseSheet(css), name);
|
|
38461
38485
|
}
|
|
38462
38486
|
/**
|
|
38463
|
-
* Writes the
|
|
38487
|
+
* Writes the token sheet at `path` through a temporary file and a rename,
|
|
38464
38488
|
* reading the sheet again just before the rename and leaving it as it is
|
|
38465
38489
|
* when its hash is no longer `hash`. A null `hash` means the sheet did not
|
|
38466
38490
|
* exist, so it is created only while none does. Takes no lock, since an
|
|
@@ -38503,7 +38527,7 @@ function parseSheet(css) {
|
|
|
38503
38527
|
try {
|
|
38504
38528
|
return postcss_default.parse(css);
|
|
38505
38529
|
} catch (error) {
|
|
38506
|
-
return refuse(`The
|
|
38530
|
+
return refuse(`The token sheet does not parse: ${error instanceof postcss_default.CssSyntaxError ? error.reason : String(error)}.`);
|
|
38507
38531
|
}
|
|
38508
38532
|
}
|
|
38509
38533
|
/** Every declaration of `name` in a rule the table reads, by side, in sheet order. */
|
|
@@ -38622,7 +38646,9 @@ function refuse(message) {
|
|
|
38622
38646
|
const common = {
|
|
38623
38647
|
project: string$1().min(1).max(256),
|
|
38624
38648
|
name: string$1().min(1).max(256),
|
|
38625
|
-
/** The
|
|
38649
|
+
/** The sheet the edit writes, the project's own when absent. */
|
|
38650
|
+
sheet: _enum$1(["project", "board"]).default("project"),
|
|
38651
|
+
/** That sheet's hash as the tab read it, null when it had none. */
|
|
38626
38652
|
hash: string$1().regex(/^[0-9a-f]{64}$/).nullable()
|
|
38627
38653
|
};
|
|
38628
38654
|
const editSchema = union([object$1({
|
|
@@ -38640,15 +38666,19 @@ const editSchema = union([object$1({
|
|
|
38640
38666
|
/**
|
|
38641
38667
|
* The Theme tab's token write, behind `requireWriter`. `POST
|
|
38642
38668
|
* /api/tokens/edit` sets one token the project's sheets list on one theme or
|
|
38643
|
-
* both
|
|
38644
|
-
*
|
|
38645
|
-
*
|
|
38646
|
-
*
|
|
38647
|
-
*
|
|
38648
|
-
*
|
|
38649
|
-
*
|
|
38650
|
-
*
|
|
38651
|
-
*
|
|
38669
|
+
* both in the sheet `sheet` names. `project`, the default, writes the
|
|
38670
|
+
* project's `tokens.css`, creating it when the project has none, and a reset
|
|
38671
|
+
* there takes the project's override back to the board's value. `board`
|
|
38672
|
+
* writes the board's sheet, which every project without an override follows,
|
|
38673
|
+
* for a token that sheet already sets. A `hash` the named sheet no longer
|
|
38674
|
+
* has, or a project sheet created since the tab read none, answers 409
|
|
38675
|
+
* `stale-tokens` with nothing written, which also lands a retried edit once.
|
|
38676
|
+
* A name the sheets do not list, a value that is not one declaration, a
|
|
38677
|
+
* reset with no board value, and a sheet that does not parse answer 409
|
|
38678
|
+
* `invalid-edit`, as does a board edit that is a reset, names a token the
|
|
38679
|
+
* board sheet does not set, or meets a `--tokens` sheet outside the board
|
|
38680
|
+
* folder, which belongs to whatever handed it over. A landed edit records
|
|
38681
|
+
* one step and answers the token's values after it with the hash written.
|
|
38652
38682
|
*/
|
|
38653
38683
|
function tokenRoutes(root, access, history, look) {
|
|
38654
38684
|
const app = new Hono();
|
|
@@ -38656,9 +38686,14 @@ function tokenRoutes(root, access, history, look) {
|
|
|
38656
38686
|
const body = await parseBody$1(c.req.raw, editSchema);
|
|
38657
38687
|
const project = await resolveProject(root, body.project);
|
|
38658
38688
|
const sheets = look.sheets(project.name);
|
|
38659
|
-
const path = join(project.path, TOKEN_FILE);
|
|
38660
38689
|
if (!readTokenTable(root, sheets).tokens.some((row) => row.name === body.name)) throw new FrameboardError("invalid-edit", `${project.name}'s token sheets set no ${body.name}.`, { name: body.name });
|
|
38661
|
-
const
|
|
38690
|
+
const target = body.sheet === "board" ? boardTarget(root, sheets.board, "reset" in body) : {
|
|
38691
|
+
path: join(project.path, TOKEN_FILE),
|
|
38692
|
+
under: boardSides(sheets.board, body.name)
|
|
38693
|
+
};
|
|
38694
|
+
const refuseStale = () => stale(project.name, body.sheet);
|
|
38695
|
+
const css = readSheet(target.path, body.hash, refuseStale);
|
|
38696
|
+
if (body.sheet === "board" && Object.keys(tokenSides(css, body.name)).length === 0) throw new FrameboardError("invalid-edit", `The board token sheet sets no ${body.name}, so it has no board value to change.`, { name: body.name });
|
|
38662
38697
|
const edit = "reset" in body ? {
|
|
38663
38698
|
name: body.name,
|
|
38664
38699
|
reset: true
|
|
@@ -38667,12 +38702,12 @@ function tokenRoutes(root, access, history, look) {
|
|
|
38667
38702
|
side: body.side,
|
|
38668
38703
|
value: body.value
|
|
38669
38704
|
};
|
|
38670
|
-
const written = editTokenCss(css,
|
|
38671
|
-
const outcome = writeTokenSheet(path, body.hash, written);
|
|
38672
|
-
if (outcome === "stale")
|
|
38705
|
+
const written = editTokenCss(css, target.under, edit);
|
|
38706
|
+
const outcome = writeTokenSheet(target.path, body.hash, written);
|
|
38707
|
+
if (outcome === "stale") refuseStale();
|
|
38673
38708
|
const journal = history.journal();
|
|
38674
|
-
if (outcome === "created") await journal.created(path);
|
|
38675
|
-
else journal.token(path, body.name, tokenSides(css, body.name), tokenSides(written, body.name));
|
|
38709
|
+
if (outcome === "created") await journal.created(target.path);
|
|
38710
|
+
else journal.token(target.path, body.name, tokenSides(css, body.name), tokenSides(written, body.name));
|
|
38676
38711
|
history.record({
|
|
38677
38712
|
id: journal.id,
|
|
38678
38713
|
changes: journal.changes,
|
|
@@ -38686,6 +38721,7 @@ function tokenRoutes(root, access, history, look) {
|
|
|
38686
38721
|
light: row?.light ?? null,
|
|
38687
38722
|
dark: row?.dark ?? null,
|
|
38688
38723
|
hash: contentHash(written),
|
|
38724
|
+
sheet: body.sheet,
|
|
38689
38725
|
created: outcome === "created"
|
|
38690
38726
|
};
|
|
38691
38727
|
return c.json({
|
|
@@ -38696,14 +38732,25 @@ function tokenRoutes(root, access, history, look) {
|
|
|
38696
38732
|
app.onError(answerRefusal);
|
|
38697
38733
|
return app;
|
|
38698
38734
|
}
|
|
38699
|
-
/** The
|
|
38700
|
-
function
|
|
38735
|
+
/** The board sheet as an edit target, refusing a reset, a board with no sheet, and a sheet outside the board folder. */
|
|
38736
|
+
function boardTarget(root, board, reset) {
|
|
38737
|
+
if (reset) throw new FrameboardError("invalid-edit", "A board token has no value under it to reset to.");
|
|
38738
|
+
if (!board) throw new FrameboardError("invalid-edit", "The board has no token sheet.");
|
|
38739
|
+
const inside = relative(root, board);
|
|
38740
|
+
if (inside.startsWith("..") || isAbsolute(inside)) throw new FrameboardError("invalid-edit", `${board} sits outside the board folder, so it belongs to whatever handed it over and stays read-only here.`, { path: board });
|
|
38741
|
+
return {
|
|
38742
|
+
path: board,
|
|
38743
|
+
under: {}
|
|
38744
|
+
};
|
|
38745
|
+
}
|
|
38746
|
+
/** The sheet's text as `hash` names it, empty for a null hash, refusing a sheet that moved since. */
|
|
38747
|
+
function readSheet(path, hash, refuseStale) {
|
|
38701
38748
|
const now = hashOrNull(path);
|
|
38702
|
-
if (now !== hash)
|
|
38749
|
+
if (now !== hash) refuseStale();
|
|
38703
38750
|
if (now === null) return "";
|
|
38704
38751
|
const bytes = readFileSync(path);
|
|
38705
38752
|
const text = bytes.toString("utf8");
|
|
38706
|
-
if (!Buffer.from(text, "utf8").equals(bytes)) throw new FrameboardError("invalid-edit", "The
|
|
38753
|
+
if (!Buffer.from(text, "utf8").equals(bytes)) throw new FrameboardError("invalid-edit", "The token sheet is not UTF-8, so it was left as it is.");
|
|
38707
38754
|
return text;
|
|
38708
38755
|
}
|
|
38709
38756
|
/** The token's declarations in the board sheet, none when it has no sheet or one that does not parse. */
|
|
@@ -38716,8 +38763,11 @@ function boardSides(board, name) {
|
|
|
38716
38763
|
throw error;
|
|
38717
38764
|
}
|
|
38718
38765
|
}
|
|
38719
|
-
function stale(project) {
|
|
38720
|
-
throw new FrameboardError("stale-tokens", `${project}'s token sheet changed since the Theme tab read it, so nothing was written.`, {
|
|
38766
|
+
function stale(project, sheet) {
|
|
38767
|
+
throw new FrameboardError("stale-tokens", `${sheet === "board" ? "The board" : `${project}'s`} token sheet changed since the Theme tab read it, so nothing was written.`, {
|
|
38768
|
+
project,
|
|
38769
|
+
sheet
|
|
38770
|
+
});
|
|
38721
38771
|
}
|
|
38722
38772
|
// src/server/app.ts
|
|
38723
38773
|
const LOOPBACK_NAMES = /* @__PURE__ */ new Set(["127.0.0.1", "localhost"]);
|
|
@@ -39349,8 +39399,10 @@ function describe$6(images) {
|
|
|
39349
39399
|
const CUSTOM_PROPERTY_RULES = [{
|
|
39350
39400
|
id: "unknown-token",
|
|
39351
39401
|
tier: "exact",
|
|
39402
|
+
severity: "warning",
|
|
39352
39403
|
description: "A var() with no fallback names a custom property no token sheet, frame sheet, or style attribute declares"
|
|
39353
39404
|
}];
|
|
39405
|
+
const finding$8 = findingFor(CUSTOM_PROPERTY_RULES);
|
|
39354
39406
|
/** A `var()` naming its property, with no fallback after a comma. */
|
|
39355
39407
|
const BARE_VAR = /var\(\s*(--[\w-]+)\s*\)/g;
|
|
39356
39408
|
/**
|
|
@@ -39358,6 +39410,9 @@ const BARE_VAR = /var\(\s*(--[\w-]+)\s*\)/g;
|
|
|
39358
39410
|
* and style attributes whose name nothing declares. A token sheet's own
|
|
39359
39411
|
* references are the board's to answer for, so only its declarations count.
|
|
39360
39412
|
* A property a script sets reads as unknown, which a fallback silences.
|
|
39413
|
+
* A linked sheet's rule matching no element in the frame stays quiet, since a
|
|
39414
|
+
* site sheet styles other pages. The frame's own `<style>` keeps reporting,
|
|
39415
|
+
* since its theme and state rules match elements no static tree marks.
|
|
39361
39416
|
*/
|
|
39362
39417
|
function checkUnknownTokens(source, tokens) {
|
|
39363
39418
|
const declared = /* @__PURE__ */ new Set();
|
|
@@ -39371,6 +39426,7 @@ function checkUnknownTokens(source, tokens) {
|
|
|
39371
39426
|
root.walkDecls((node) => {
|
|
39372
39427
|
if (node.prop.startsWith("--")) declared.add(node.prop);
|
|
39373
39428
|
if (sheet.origin === "token") return;
|
|
39429
|
+
if (sheet.origin === "linked" && matchesNothing(node, source.elements)) return;
|
|
39374
39430
|
for (const name of bareVars(node.value)) uses.push({
|
|
39375
39431
|
name,
|
|
39376
39432
|
path: boardPath(source.root, sheet.path),
|
|
@@ -39393,13 +39449,26 @@ function checkUnknownTokens(source, tokens) {
|
|
|
39393
39449
|
});
|
|
39394
39450
|
});
|
|
39395
39451
|
}
|
|
39396
|
-
return uses.filter((use) => !declared.has(use.name)).map((use) => finding("unknown-token", {
|
|
39452
|
+
return uses.filter((use) => !declared.has(use.name)).map((use) => finding$8("unknown-token", {
|
|
39397
39453
|
frame: source.ref,
|
|
39398
39454
|
path: use.path,
|
|
39399
39455
|
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).`,
|
|
39400
39456
|
location: use.location
|
|
39401
39457
|
}));
|
|
39402
39458
|
}
|
|
39459
|
+
/**
|
|
39460
|
+
* Whether `node` sits in a rule none of whose selectors matches an element.
|
|
39461
|
+
* A declaration outside a rule, or a selector the check cannot match
|
|
39462
|
+
* statically, counts as matching, so the use still reports.
|
|
39463
|
+
*/
|
|
39464
|
+
function matchesNothing(node, elements) {
|
|
39465
|
+
const rule = node.parent;
|
|
39466
|
+
if (rule?.type !== "rule" || !styles(rule)) return false;
|
|
39467
|
+
return rule.selectors.every((selector) => {
|
|
39468
|
+
const matches = compileSelector(selector);
|
|
39469
|
+
return matches !== null && !elements.some(matches);
|
|
39470
|
+
});
|
|
39471
|
+
}
|
|
39403
39472
|
function bareVars(value) {
|
|
39404
39473
|
return [...new Set([...value.matchAll(BARE_VAR)].map((match) => match[1] ?? ""))];
|
|
39405
39474
|
}
|
|
@@ -39415,20 +39484,24 @@ const FONT_RULES = [
|
|
|
39415
39484
|
{
|
|
39416
39485
|
id: "default-font",
|
|
39417
39486
|
tier: "selector",
|
|
39487
|
+
severity: "warning",
|
|
39418
39488
|
description: "Every text element reaches a font-family, so the browser's default font never renders"
|
|
39419
39489
|
},
|
|
39420
39490
|
{
|
|
39421
39491
|
id: "generic-font",
|
|
39422
39492
|
tier: "selector",
|
|
39493
|
+
severity: "warning",
|
|
39423
39494
|
description: "No text element renders in a generic family such as sans-serif or monospace as its first choice"
|
|
39424
39495
|
},
|
|
39425
39496
|
{
|
|
39426
39497
|
id: "allowed-fonts",
|
|
39427
39498
|
tier: "selector",
|
|
39499
|
+
severity: "error",
|
|
39428
39500
|
configKey: "allowedFonts",
|
|
39429
39501
|
description: "Every text element's first family is one of the project's allowed fonts"
|
|
39430
39502
|
}
|
|
39431
39503
|
];
|
|
39504
|
+
const finding$7 = findingFor(FONT_RULES);
|
|
39432
39505
|
const GENERIC_FAMILIES = /* @__PURE__ */ new Set([
|
|
39433
39506
|
"serif",
|
|
39434
39507
|
"sans-serif",
|
|
@@ -39471,7 +39544,7 @@ function checkFonts(source, cascade, config) {
|
|
|
39471
39544
|
else if (allowed && !allowed.includes(family.toLowerCase())) push(unlisted, family, element);
|
|
39472
39545
|
}
|
|
39473
39546
|
const path = boardPath(source.root, source.path);
|
|
39474
|
-
const at = (rule, elements, message) => finding(rule, {
|
|
39547
|
+
const at = (rule, elements, message) => finding$7(rule, {
|
|
39475
39548
|
frame: source.ref,
|
|
39476
39549
|
path,
|
|
39477
39550
|
message: `${message} ${described(elements)}`,
|
|
@@ -39505,19 +39578,23 @@ const LINK_RULES = [
|
|
|
39505
39578
|
{
|
|
39506
39579
|
id: "outside-link",
|
|
39507
39580
|
tier: "exact",
|
|
39581
|
+
severity: "error",
|
|
39508
39582
|
description: "A frame loads files from its own page folder and its project's assets/ folder alone, never from a sibling page or the server root"
|
|
39509
39583
|
},
|
|
39510
39584
|
{
|
|
39511
39585
|
id: "network",
|
|
39512
39586
|
tier: "exact",
|
|
39587
|
+
severity: "error",
|
|
39513
39588
|
description: "A frame loads nothing over the network, while a navigation link passes"
|
|
39514
39589
|
},
|
|
39515
39590
|
{
|
|
39516
39591
|
id: "missing-file",
|
|
39517
39592
|
tier: "exact",
|
|
39593
|
+
severity: "error",
|
|
39518
39594
|
description: "Every local file a frame loads exists"
|
|
39519
39595
|
}
|
|
39520
39596
|
];
|
|
39597
|
+
const finding$6 = findingFor(LINK_RULES);
|
|
39521
39598
|
/**
|
|
39522
39599
|
* The attributes that load a resource, by element. An `a href` navigates
|
|
39523
39600
|
* rather than loads, so it is left out.
|
|
@@ -39593,16 +39670,16 @@ function judge(source, load) {
|
|
|
39593
39670
|
path: load.path,
|
|
39594
39671
|
location: load.location
|
|
39595
39672
|
};
|
|
39596
|
-
if (hasScheme(url)) return [finding("network", {
|
|
39673
|
+
if (hasScheme(url)) return [finding$6("network", {
|
|
39597
39674
|
...fields,
|
|
39598
39675
|
message: `${load.via} loads ${url} over the network. Save the file into the page folder or the project's assets/ and link it there.`
|
|
39599
39676
|
})];
|
|
39600
39677
|
const target = localTarget(url, load.base);
|
|
39601
|
-
if (target === null || !allowed(source, target)) return [finding("outside-link", {
|
|
39678
|
+
if (target === null || !allowed(source, target)) return [finding$6("outside-link", {
|
|
39602
39679
|
...fields,
|
|
39603
39680
|
message: `${load.via} loads ${url}, outside this page's folder and the project's assets/. Move the file into one of them.`
|
|
39604
39681
|
})];
|
|
39605
|
-
if (!existsSync(target)) return [finding("missing-file", {
|
|
39682
|
+
if (!existsSync(target)) return [finding$6("missing-file", {
|
|
39606
39683
|
...fields,
|
|
39607
39684
|
message: `${load.via} loads ${url}, which does not exist.`
|
|
39608
39685
|
})];
|
|
@@ -39657,34 +39734,41 @@ const STRUCTURE_RULES = [
|
|
|
39657
39734
|
{
|
|
39658
39735
|
id: "naming",
|
|
39659
39736
|
tier: "exact",
|
|
39737
|
+
severity: "error",
|
|
39660
39738
|
description: "A page or frame name uses letters, digits, dots, dashes, and underscores, opening with a letter or digit, at most 64 characters"
|
|
39661
39739
|
},
|
|
39662
39740
|
{
|
|
39663
39741
|
id: "dot-folder",
|
|
39664
39742
|
tier: "exact",
|
|
39743
|
+
severity: "error",
|
|
39665
39744
|
description: "No folder in a project opens with a dot, since the board never shows it"
|
|
39666
39745
|
},
|
|
39667
39746
|
{
|
|
39668
39747
|
id: "head-body",
|
|
39669
39748
|
tier: "exact",
|
|
39749
|
+
severity: "error",
|
|
39670
39750
|
description: "A frame stating <head> states <body> too"
|
|
39671
39751
|
},
|
|
39672
39752
|
{
|
|
39673
39753
|
id: "table-tbody",
|
|
39674
39754
|
tier: "exact",
|
|
39755
|
+
severity: "error",
|
|
39675
39756
|
description: "A table holding rows states its <tbody>, since the browser adds one the file does not hold"
|
|
39676
39757
|
},
|
|
39677
39758
|
{
|
|
39678
39759
|
id: "malformed-tag",
|
|
39679
39760
|
tier: "exact",
|
|
39761
|
+
severity: "error",
|
|
39680
39762
|
description: "A tag or attribute the HTML tokenizer cannot read as written, such as a quote ending an attribute early, which the browser recovers from silently"
|
|
39681
39763
|
},
|
|
39682
39764
|
{
|
|
39683
39765
|
id: "nesting",
|
|
39684
39766
|
tier: "exact",
|
|
39767
|
+
severity: "error",
|
|
39685
39768
|
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"
|
|
39686
39769
|
}
|
|
39687
39770
|
];
|
|
39771
|
+
const finding$5 = findingFor(STRUCTURE_RULES);
|
|
39688
39772
|
/**
|
|
39689
39773
|
* Elements a parser may imply with no start tag in a valid file. A `tbody`
|
|
39690
39774
|
* is `table-tbody`'s to report.
|
|
@@ -39747,12 +39831,12 @@ const MALFORMED = {
|
|
|
39747
39831
|
function checkNaming(target, path) {
|
|
39748
39832
|
const ref = `${target.project}/${target.page}/${target.name}`;
|
|
39749
39833
|
const findings = [];
|
|
39750
|
-
if (!isValidName(target.page) || isReservedPageName(target.page)) findings.push(finding("naming", {
|
|
39834
|
+
if (!isValidName(target.page) || isReservedPageName(target.page)) findings.push(finding$5("naming", {
|
|
39751
39835
|
frame: ref,
|
|
39752
39836
|
path,
|
|
39753
39837
|
message: `Page name ${target.page} is not valid. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit.`
|
|
39754
39838
|
}));
|
|
39755
|
-
if (!isValidName(target.name)) findings.push(finding("naming", {
|
|
39839
|
+
if (!isValidName(target.name)) findings.push(finding$5("naming", {
|
|
39756
39840
|
frame: ref,
|
|
39757
39841
|
path,
|
|
39758
39842
|
message: `Frame name ${target.name} is not valid. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit.`
|
|
@@ -39761,7 +39845,7 @@ function checkNaming(target, path) {
|
|
|
39761
39845
|
}
|
|
39762
39846
|
/** `dot-folder`, over a project's folder names. */
|
|
39763
39847
|
function checkDotFolders(root, projectDir, folders) {
|
|
39764
|
-
return folders.filter((name) => name.startsWith(".")).map((name) => finding("dot-folder", {
|
|
39848
|
+
return folders.filter((name) => name.startsWith(".")).map((name) => finding$5("dot-folder", {
|
|
39765
39849
|
frame: null,
|
|
39766
39850
|
path: boardPath(root, `${projectDir}/${name}`),
|
|
39767
39851
|
message: `Folder ${name} opens with a dot, so the board never shows it. Rename it or move it out of the project.`
|
|
@@ -39773,13 +39857,13 @@ function checkMarkup(source) {
|
|
|
39773
39857
|
const findings = [];
|
|
39774
39858
|
const head = source.elements.find((element) => element.name === "head");
|
|
39775
39859
|
const body = source.elements.find((element) => element.name === "body");
|
|
39776
|
-
if (head && startTagLocation(head) && !(body && startTagLocation(body))) findings.push(finding("head-body", {
|
|
39860
|
+
if (head && startTagLocation(head) && !(body && startTagLocation(body))) findings.push(finding$5("head-body", {
|
|
39777
39861
|
frame: source.ref,
|
|
39778
39862
|
path,
|
|
39779
39863
|
message: "The frame states <head> and no <body>. Wrap the visible content in <body>.",
|
|
39780
39864
|
location: startTagLocation(head)
|
|
39781
39865
|
}));
|
|
39782
|
-
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("table-tbody", {
|
|
39866
|
+
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$5("table-tbody", {
|
|
39783
39867
|
frame: source.ref,
|
|
39784
39868
|
path,
|
|
39785
39869
|
message: "This table holds rows with no <tbody>, so the browser adds one the file does not hold. State the <tbody>.",
|
|
@@ -39806,7 +39890,7 @@ function checkMalformedTags(source) {
|
|
|
39806
39890
|
if (reported.has(tag)) continue;
|
|
39807
39891
|
reported.add(tag);
|
|
39808
39892
|
}
|
|
39809
|
-
findings.push(finding("malformed-tag", {
|
|
39893
|
+
findings.push(finding$5("malformed-tag", {
|
|
39810
39894
|
frame: source.ref,
|
|
39811
39895
|
path,
|
|
39812
39896
|
message: `${tag ? `<${tag.name}> raises ${error.code}` : error.code}. ${message}`,
|
|
@@ -39824,7 +39908,7 @@ function checkMalformedTags(source) {
|
|
|
39824
39908
|
function checkNesting(source) {
|
|
39825
39909
|
const path = boardPath(source.root, source.path);
|
|
39826
39910
|
const findings = [];
|
|
39827
|
-
const report = (message, location) => findings.push(finding("nesting", {
|
|
39911
|
+
const report = (message, location) => findings.push(finding$5("nesting", {
|
|
39828
39912
|
frame: source.ref,
|
|
39829
39913
|
path,
|
|
39830
39914
|
message,
|
|
@@ -39883,16 +39967,18 @@ function isTable(element) {
|
|
|
39883
39967
|
const UPPERCASE_RULES = [{
|
|
39884
39968
|
id: "uppercase",
|
|
39885
39969
|
tier: "selector",
|
|
39970
|
+
severity: "warning",
|
|
39886
39971
|
configKey: "noUppercase",
|
|
39887
39972
|
description: "No text is set in capitals, through text-transform: uppercase or a word of more than three capital letters"
|
|
39888
39973
|
}];
|
|
39974
|
+
const finding$4 = findingFor(UPPERCASE_RULES);
|
|
39889
39975
|
const CAPITALS = /(?<![\p{L}\p{N}])\p{Lu}{4,}(?![\p{L}\p{N}])/u;
|
|
39890
39976
|
/** `uppercase`, which runs only when the project sets `noUppercase`. */
|
|
39891
39977
|
function checkUppercase(source, cascade) {
|
|
39892
39978
|
const capitalized = textElements(source).filter((element) => cascade.textTransform(element) === "uppercase" || ownText$1(element).some((text) => CAPITALS.test(text)));
|
|
39893
39979
|
const first = capitalized[0];
|
|
39894
39980
|
if (!first) return [];
|
|
39895
|
-
return [finding("uppercase", {
|
|
39981
|
+
return [finding$4("uppercase", {
|
|
39896
39982
|
frame: source.ref,
|
|
39897
39983
|
path: boardPath(source.root, source.path),
|
|
39898
39984
|
message: `Text is set in capitals, which the project does not allow. Write it in sentence case. ${described(capitalized)}`,
|
|
@@ -39968,8 +40054,10 @@ function isRecord(value) {
|
|
|
39968
40054
|
const DECLARATION_RULES = [{
|
|
39969
40055
|
id: "dropped-declaration",
|
|
39970
40056
|
tier: "browser",
|
|
40057
|
+
severity: "warning",
|
|
39971
40058
|
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"
|
|
39972
40059
|
}];
|
|
40060
|
+
const finding$3 = findingFor(DECLARATION_RULES);
|
|
39973
40061
|
/**
|
|
39974
40062
|
* At-rules whose blocks hold descriptors rather than properties, which
|
|
39975
40063
|
* `CSS.supports` cannot answer, and `@supports`, whose block is a
|
|
@@ -39978,6 +40066,8 @@ const DECLARATION_RULES = [{
|
|
|
39978
40066
|
const SKIPPED_BLOCKS = /^(font-face|property|page|counter-style|font-palette-values|supports)$/i;
|
|
39979
40067
|
/** Prefixes for engines the board never renders in. */
|
|
39980
40068
|
const FOREIGN_PREFIX = /^-(moz|ms|o)-/i;
|
|
40069
|
+
/** The one engine prefix the board renders, which a build tool writes beside the standard property as a fallback. */
|
|
40070
|
+
const FALLBACK_PREFIX = /^-webkit-/i;
|
|
39981
40071
|
/**
|
|
39982
40072
|
* `dropped-declaration`, one finding per declaration in the frame's own
|
|
39983
40073
|
* sheets and style attributes that the open page's `CSS.supports` refuses,
|
|
@@ -39992,7 +40082,7 @@ async function checkDeclarations(page, source) {
|
|
|
39992
40082
|
const path = boardPath(source.root, sheet.path);
|
|
39993
40083
|
const text = sheet.origin === "style" ? source.html : sheet.css;
|
|
39994
40084
|
const { root, errors } = parseSheet$1(sheet.css);
|
|
39995
|
-
for (const error of errors) findings.push(finding("dropped-declaration", {
|
|
40085
|
+
for (const error of errors) findings.push(finding$3("dropped-declaration", {
|
|
39996
40086
|
frame: source.ref,
|
|
39997
40087
|
path,
|
|
39998
40088
|
message: breakMessage(error),
|
|
@@ -40031,7 +40121,7 @@ async function checkDeclarations(page, source) {
|
|
|
40031
40121
|
const supported = await page.evaluate((pairs) => pairs.map(([property, value]) => CSS.supports(property, value)), written.map((each) => [each.property, each.value]));
|
|
40032
40122
|
written.forEach((each, index) => {
|
|
40033
40123
|
if (supported[index]) return;
|
|
40034
|
-
findings.push(finding("dropped-declaration", {
|
|
40124
|
+
findings.push(finding$3("dropped-declaration", {
|
|
40035
40125
|
frame: source.ref,
|
|
40036
40126
|
path: each.path,
|
|
40037
40127
|
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.`,
|
|
@@ -40042,9 +40132,16 @@ async function checkDeclarations(page, source) {
|
|
|
40042
40132
|
}
|
|
40043
40133
|
function checkable(node) {
|
|
40044
40134
|
if (node.prop.startsWith("--") || FOREIGN_PREFIX.test(node.prop)) return false;
|
|
40135
|
+
if (isFallback(node)) return false;
|
|
40045
40136
|
for (let parent = node.parent; parent; parent = parent.parent) if (parent.type === "atrule" && SKIPPED_BLOCKS.test(parent.name)) return false;
|
|
40046
40137
|
return true;
|
|
40047
40138
|
}
|
|
40139
|
+
/** A prefixed declaration whose standard property sits in the same rule. */
|
|
40140
|
+
function isFallback(node) {
|
|
40141
|
+
if (!FALLBACK_PREFIX.test(node.prop)) return false;
|
|
40142
|
+
const standard = node.prop.replace(FALLBACK_PREFIX, "").toLowerCase();
|
|
40143
|
+
return node.parent?.some((sibling) => sibling.type === "decl" && sibling.prop.toLowerCase() === standard) ?? false;
|
|
40144
|
+
}
|
|
40048
40145
|
/** What to tell the agent about a break, by the cure its kind takes. */
|
|
40049
40146
|
function breakMessage(error) {
|
|
40050
40147
|
if (error.reason.startsWith("Unknown word")) return `The browser drops this declaration, since it reads no property and value in it (${error.reason}). Check for a missing colon between the two.`;
|
|
@@ -40060,9 +40157,11 @@ function syntaxLocation(text, sheet, error) {
|
|
|
40060
40157
|
const FONT_SIZE_RULES = [{
|
|
40061
40158
|
id: "min-font-size",
|
|
40062
40159
|
tier: "browser",
|
|
40160
|
+
severity: "warning",
|
|
40063
40161
|
configKey: "minFontSize",
|
|
40064
40162
|
description: "Text renders smaller than the project sets as its minimum size in pixels"
|
|
40065
40163
|
}];
|
|
40164
|
+
const finding$2 = findingFor(FONT_SIZE_RULES);
|
|
40066
40165
|
/**
|
|
40067
40166
|
* Reports text under `minFontSize` pixels, naming the smallest element and
|
|
40068
40167
|
* how many more fall under, at most one finding per frame.
|
|
@@ -40073,7 +40172,7 @@ async function checkFontSize(page, target, minFontSize) {
|
|
|
40073
40172
|
const smallest = under.reduce((least, text) => text.size < least.size ? text : least);
|
|
40074
40173
|
const others = under.length - 1;
|
|
40075
40174
|
const rest = others === 0 ? "" : `, and ${others} more ${others === 1 ? "element is" : "elements are"} under it`;
|
|
40076
|
-
return [finding("min-font-size", {
|
|
40175
|
+
return [finding$2("min-font-size", {
|
|
40077
40176
|
frame: target.ref,
|
|
40078
40177
|
path: target.path,
|
|
40079
40178
|
message: `${target.ref} sets text at ${smallest.size} px in <${smallest.tag}> at element ${smallest.index}, under the project's ${minFontSize} px minimum${rest}.`
|
|
@@ -40275,19 +40374,23 @@ const LAYOUT_RULES = [
|
|
|
40275
40374
|
{
|
|
40276
40375
|
id: "clipped",
|
|
40277
40376
|
tier: "browser",
|
|
40377
|
+
severity: "error",
|
|
40278
40378
|
description: "Content reaches past the box the frame renders at, so the board cuts it off"
|
|
40279
40379
|
},
|
|
40280
40380
|
{
|
|
40281
40381
|
id: "scrollbar",
|
|
40282
40382
|
tier: "browser",
|
|
40383
|
+
severity: "warning",
|
|
40283
40384
|
description: "An element inside the frame scrolls by more than a pixel, showing a scrollbar in the design"
|
|
40284
40385
|
},
|
|
40285
40386
|
{
|
|
40286
40387
|
id: "viewport",
|
|
40287
40388
|
tier: "browser",
|
|
40389
|
+
severity: "warning",
|
|
40288
40390
|
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"
|
|
40289
40391
|
}
|
|
40290
40392
|
];
|
|
40393
|
+
const finding$1 = findingFor(LAYOUT_RULES);
|
|
40291
40394
|
/**
|
|
40292
40395
|
* The slack a reading takes before it counts, so a subpixel edge rounding up
|
|
40293
40396
|
* is never a finding. One pixel matches what the groundwork spike measured.
|
|
@@ -40331,7 +40434,7 @@ function clipped(target, read) {
|
|
|
40331
40434
|
if (!tall && !wide) return null;
|
|
40332
40435
|
const past = shown.filter((box) => tall && box.bottom > height + SLACK_PX || wide && box.right > width + SLACK_PX);
|
|
40333
40436
|
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 ");
|
|
40334
|
-
return finding("clipped", {
|
|
40437
|
+
return finding$1("clipped", {
|
|
40335
40438
|
frame: target.ref,
|
|
40336
40439
|
path: target.path,
|
|
40337
40440
|
message: `${target.ref} is ${reach}, so the board cuts it off${offenders(past, "past the box")}. ${clippedAdvice(tall, wide, width)}`
|
|
@@ -40347,7 +40450,7 @@ function scrollbar(target, read) {
|
|
|
40347
40450
|
const [first] = scrolling;
|
|
40348
40451
|
if (!first) return null;
|
|
40349
40452
|
const by = Math.max(first.overflowX, first.overflowY);
|
|
40350
|
-
return finding("scrollbar", {
|
|
40453
|
+
return finding$1("scrollbar", {
|
|
40351
40454
|
frame: target.ref,
|
|
40352
40455
|
path: target.path,
|
|
40353
40456
|
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.`
|
|
@@ -40357,10 +40460,9 @@ function viewport(target, atBox, atTall, boxRead, tallRead) {
|
|
|
40357
40460
|
if (atTall <= atBox + SLACK_PX) return null;
|
|
40358
40461
|
const before = new Map(boxRead.boxes.map((box) => [box.index, box.height]));
|
|
40359
40462
|
const grown = tallRead.boxes.filter((box) => box.height > (before.get(box.index) ?? box.height) + SLACK_PX);
|
|
40360
|
-
return finding("viewport", {
|
|
40463
|
+
return finding$1("viewport", {
|
|
40361
40464
|
frame: target.ref,
|
|
40362
40465
|
path: target.path,
|
|
40363
|
-
severity: "warning",
|
|
40364
40466
|
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.`
|
|
40365
40467
|
});
|
|
40366
40468
|
}
|
|
@@ -40487,8 +40589,10 @@ function readLayout() {
|
|
|
40487
40589
|
const OUTRANKED_RULES = [{
|
|
40488
40590
|
id: "outranked",
|
|
40489
40591
|
tier: "selector",
|
|
40592
|
+
severity: "warning",
|
|
40490
40593
|
description: "An agent's write changed a rule in the frame's own <style> that an element's unchanged style attribute also sets, so that element keeps its inline value, which may be the developer's hand edit. A warning the server raises against the bytes the write replaced, so the hook never reports it."
|
|
40491
40594
|
}];
|
|
40595
|
+
const finding = findingFor(OUTRANKED_RULES);
|
|
40492
40596
|
const SIDES = [
|
|
40493
40597
|
"top",
|
|
40494
40598
|
"right",
|
|
@@ -40598,7 +40702,6 @@ function checkOutranked(before, after) {
|
|
|
40598
40702
|
return [finding("outranked", {
|
|
40599
40703
|
frame: after.ref,
|
|
40600
40704
|
path: boardPath(after.root, after.path),
|
|
40601
|
-
severity: "warning",
|
|
40602
40705
|
message: `This write changed the ${first.selector} rule, but <${first.element.name}> at element ${first.index} sets ${first.property} in its style attribute, which outranks every rule${others}. The style attribute may hold a value the developer set by hand, so change it too only if the new value should reach that element.`,
|
|
40603
40706
|
location: attributeLocation(first.element, "style")
|
|
40604
40707
|
})];
|
|
@@ -41443,7 +41546,7 @@ function renderDocs(docs) {
|
|
|
41443
41546
|
section("Exit codes", table(Object.entries(docs.exitCodes))),
|
|
41444
41547
|
section("Records", [`${INDENT}${Object.keys(docs.records).join(", ")}`, `${INDENT}Run frameboard docs --json for each record's JSON schema.`]),
|
|
41445
41548
|
section("Content format", formatLines(docs.contentFormat)),
|
|
41446
|
-
section("Check rules", docs.checks.rules.map((rule) => `${INDENT}${rule.id} ${rule.tier}${rule.configKey ? `, on with checks.${rule.configKey}` : ""}. ${rule.description}`))
|
|
41549
|
+
section("Check rules", docs.checks.rules.map((rule) => `${INDENT}${rule.id} ${rule.severity}, ${rule.tier}${rule.configKey ? `, on with checks.${rule.configKey}` : ""}. ${rule.description}`))
|
|
41447
41550
|
].join("\n\n");
|
|
41448
41551
|
}
|
|
41449
41552
|
function section(heading, lines) {
|