frameboard 0.35.0 → 0.37.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 +20506 -19891
- package/dist/client/assets/index-5vtY9zMD.css +2 -0
- package/dist/client/assets/index-C3AvCtOi.js +179 -0
- package/dist/client/index.html +2 -2
- package/dist/hook.js +260 -33
- package/package.json +4 -4
- package/dist/client/assets/index-DC0Zjzrw.css +0 -2
- package/dist/client/assets/index-DOsRyKWN.js +0 -178
package/dist/client/index.html
CHANGED
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
matchMedia('(prefers-color-scheme: dark)').matches),
|
|
24
24
|
)
|
|
25
25
|
</script>
|
|
26
|
-
<script type="module" crossorigin src="/assets/index-
|
|
27
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
26
|
+
<script type="module" crossorigin src="/assets/index-C3AvCtOi.js"></script>
|
|
27
|
+
<link rel="stylesheet" crossorigin href="/assets/index-5vtY9zMD.css">
|
|
28
28
|
</head>
|
|
29
29
|
<body>
|
|
30
30
|
<div id="root"></div>
|
package/dist/hook.js
CHANGED
|
@@ -8345,7 +8345,7 @@ var require_source_map_consumer = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
8345
8345
|
continue;
|
|
8346
8346
|
}
|
|
8347
8347
|
}
|
|
8348
|
-
mapping.lastGeneratedColumn =
|
|
8348
|
+
mapping.lastGeneratedColumn = 1e400;
|
|
8349
8349
|
}
|
|
8350
8350
|
};
|
|
8351
8351
|
/**
|
|
@@ -19467,7 +19467,7 @@ function formatFinding(finding) {
|
|
|
19467
19467
|
const path = finding.width === void 0 ? finding.path : `${finding.path}@${finding.width}`;
|
|
19468
19468
|
return `${finding.location ? `${path}:${finding.location.line}:${finding.location.column}` : path} ${finding.rule} ${finding.message}`;
|
|
19469
19469
|
}
|
|
19470
|
-
const finding$
|
|
19470
|
+
const finding$6 = findingFor([{
|
|
19471
19471
|
id: "unknown-token",
|
|
19472
19472
|
tier: "exact",
|
|
19473
19473
|
severity: "warning",
|
|
@@ -19531,7 +19531,7 @@ function checkUnknownTokens(source, tokens) {
|
|
|
19531
19531
|
if (element.name !== "script") continue;
|
|
19532
19532
|
for (const name of scriptWrites(scriptText(element, source))) declared.add(name);
|
|
19533
19533
|
}
|
|
19534
|
-
return uses.filter((use) => !declared.has(use.name)).map((use) => finding$
|
|
19534
|
+
return uses.filter((use) => !declared.has(use.name)).map((use) => finding$6("unknown-token", {
|
|
19535
19535
|
frame: source.ref,
|
|
19536
19536
|
path: use.path,
|
|
19537
19537
|
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.`,
|
|
@@ -19583,7 +19583,7 @@ function parseOrNull(css) {
|
|
|
19583
19583
|
return null;
|
|
19584
19584
|
}
|
|
19585
19585
|
}
|
|
19586
|
-
const finding$
|
|
19586
|
+
const finding$5 = findingFor([
|
|
19587
19587
|
{
|
|
19588
19588
|
id: "default-font",
|
|
19589
19589
|
tier: "selector",
|
|
@@ -19646,7 +19646,7 @@ function checkFonts(source, cascade, config) {
|
|
|
19646
19646
|
else if (allowed && !allowed.includes(family.toLowerCase())) push(unlisted, family, element);
|
|
19647
19647
|
}
|
|
19648
19648
|
const path = boardPath(source.root, source.path);
|
|
19649
|
-
const at = (rule, elements, message) => finding$
|
|
19649
|
+
const at = (rule, elements, message) => finding$5(rule, {
|
|
19650
19650
|
frame: source.ref,
|
|
19651
19651
|
path,
|
|
19652
19652
|
message: `${message} ${described(elements)}`,
|
|
@@ -19675,7 +19675,7 @@ function push(map, key, element) {
|
|
|
19675
19675
|
if (list) list.push(element);
|
|
19676
19676
|
else map.set(key, [element]);
|
|
19677
19677
|
}
|
|
19678
|
-
const finding$
|
|
19678
|
+
const finding$4 = findingFor([
|
|
19679
19679
|
{
|
|
19680
19680
|
id: "outside-link",
|
|
19681
19681
|
tier: "exact",
|
|
@@ -19770,16 +19770,16 @@ function judge(source, load) {
|
|
|
19770
19770
|
path: load.path,
|
|
19771
19771
|
location: load.location
|
|
19772
19772
|
};
|
|
19773
|
-
if (hasScheme(url)) return [finding$
|
|
19773
|
+
if (hasScheme(url)) return [finding$4("network", {
|
|
19774
19774
|
...fields,
|
|
19775
19775
|
message: `${load.via} loads ${url} over the network. Save the file into the page folder or the project's assets/ and link it there.`
|
|
19776
19776
|
})];
|
|
19777
19777
|
const target = localTarget(url, load.base);
|
|
19778
|
-
if (target === null || !allowed(source, target)) return [finding$
|
|
19778
|
+
if (target === null || !allowed(source, target)) return [finding$4("outside-link", {
|
|
19779
19779
|
...fields,
|
|
19780
19780
|
message: `${load.via} loads ${url}, outside this page's folder and the project's assets/. Move the file into one of them.`
|
|
19781
19781
|
})];
|
|
19782
|
-
if (!existsSync(target)) return [finding$
|
|
19782
|
+
if (!existsSync(target)) return [finding$4("missing-file", {
|
|
19783
19783
|
...fields,
|
|
19784
19784
|
message: `${load.via} loads ${url}, which does not exist.`
|
|
19785
19785
|
})];
|
|
@@ -19844,7 +19844,7 @@ function isReservedPageName(name) {
|
|
|
19844
19844
|
function namesCollide(a, b) {
|
|
19845
19845
|
return a.toLowerCase() === b.toLowerCase();
|
|
19846
19846
|
}
|
|
19847
|
-
const finding$
|
|
19847
|
+
const finding$3 = findingFor([
|
|
19848
19848
|
{
|
|
19849
19849
|
id: "naming",
|
|
19850
19850
|
tier: "exact",
|
|
@@ -19944,12 +19944,12 @@ const MALFORMED = {
|
|
|
19944
19944
|
function checkNaming(target, path) {
|
|
19945
19945
|
const ref = `${target.project}/${target.page}/${target.name}`;
|
|
19946
19946
|
const findings = [];
|
|
19947
|
-
if (!isValidName(target.page) || isReservedPageName(target.page)) findings.push(finding$
|
|
19947
|
+
if (!isValidName(target.page) || isReservedPageName(target.page)) findings.push(finding$3("naming", {
|
|
19948
19948
|
frame: ref,
|
|
19949
19949
|
path,
|
|
19950
19950
|
message: `Page name ${target.page} is not valid. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit.`
|
|
19951
19951
|
}));
|
|
19952
|
-
if (!isValidName(target.name)) findings.push(finding$
|
|
19952
|
+
if (!isValidName(target.name)) findings.push(finding$3("naming", {
|
|
19953
19953
|
frame: ref,
|
|
19954
19954
|
path,
|
|
19955
19955
|
message: `Frame name ${target.name} is not valid. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit.`
|
|
@@ -19962,13 +19962,13 @@ function checkMarkup(source) {
|
|
|
19962
19962
|
const findings = [];
|
|
19963
19963
|
const head = source.elements.find((element) => element.name === "head");
|
|
19964
19964
|
const body = source.elements.find((element) => element.name === "body");
|
|
19965
|
-
if (head && startTagLocation(head) && !(body && startTagLocation(body))) findings.push(finding$
|
|
19965
|
+
if (head && startTagLocation(head) && !(body && startTagLocation(body))) findings.push(finding$3("head-body", {
|
|
19966
19966
|
frame: source.ref,
|
|
19967
19967
|
path,
|
|
19968
19968
|
message: "The frame states <head> and no <body>. Wrap the visible content in <body>.",
|
|
19969
19969
|
location: startTagLocation(head)
|
|
19970
19970
|
}));
|
|
19971
|
-
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$
|
|
19971
|
+
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$3("table-tbody", {
|
|
19972
19972
|
frame: source.ref,
|
|
19973
19973
|
path,
|
|
19974
19974
|
message: "This table holds rows with no <tbody>, so the browser adds one the file does not hold. State the <tbody>.",
|
|
@@ -19995,7 +19995,7 @@ function checkMalformedTags(source) {
|
|
|
19995
19995
|
if (reported.has(tag)) continue;
|
|
19996
19996
|
reported.add(tag);
|
|
19997
19997
|
}
|
|
19998
|
-
findings.push(finding$
|
|
19998
|
+
findings.push(finding$3("malformed-tag", {
|
|
19999
19999
|
frame: source.ref,
|
|
20000
20000
|
path,
|
|
20001
20001
|
message: `${tag ? `<${tag.name}> raises ${error.code}` : error.code}. ${message}`,
|
|
@@ -20013,7 +20013,7 @@ function checkMalformedTags(source) {
|
|
|
20013
20013
|
function checkNesting(source) {
|
|
20014
20014
|
const path = boardPath(source.root, source.path);
|
|
20015
20015
|
const findings = [];
|
|
20016
|
-
const report = (message, location) => findings.push(finding$
|
|
20016
|
+
const report = (message, location) => findings.push(finding$3("nesting", {
|
|
20017
20017
|
frame: source.ref,
|
|
20018
20018
|
path,
|
|
20019
20019
|
message,
|
|
@@ -20068,7 +20068,7 @@ function strayEndTag(html, element) {
|
|
|
20068
20068
|
function isTable(element) {
|
|
20069
20069
|
return element.name === "table";
|
|
20070
20070
|
}
|
|
20071
|
-
const finding$
|
|
20071
|
+
const finding$2 = findingFor([{
|
|
20072
20072
|
id: "theme",
|
|
20073
20073
|
tier: "selector",
|
|
20074
20074
|
severity: "error",
|
|
@@ -20083,7 +20083,7 @@ function checkTheme(source) {
|
|
|
20083
20083
|
const { firstColor, bothThemes } = readThemeColors(source);
|
|
20084
20084
|
if (!firstColor || bothThemes) return [];
|
|
20085
20085
|
const { path, location } = firstColor;
|
|
20086
|
-
return [finding$
|
|
20086
|
+
return [finding$2("theme", {
|
|
20087
20087
|
frame: source.ref,
|
|
20088
20088
|
path,
|
|
20089
20089
|
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.",
|
|
@@ -20259,7 +20259,7 @@ function tokenSheets(root, project, tokens) {
|
|
|
20259
20259
|
offset: 0
|
|
20260
20260
|
}));
|
|
20261
20261
|
}
|
|
20262
|
-
const finding = findingFor([{
|
|
20262
|
+
const finding$1 = findingFor([{
|
|
20263
20263
|
id: "uppercase",
|
|
20264
20264
|
tier: "selector",
|
|
20265
20265
|
severity: "warning",
|
|
@@ -20272,7 +20272,7 @@ function checkUppercase(source, cascade) {
|
|
|
20272
20272
|
const capitalized = textElements(source).filter((element) => cascade.textTransform(element) === "uppercase" || ownText(element).some((text) => CAPITALS.test(text)));
|
|
20273
20273
|
const first = capitalized[0];
|
|
20274
20274
|
if (!first) return [];
|
|
20275
|
-
return [finding("uppercase", {
|
|
20275
|
+
return [finding$1("uppercase", {
|
|
20276
20276
|
frame: source.ref,
|
|
20277
20277
|
path: boardPath(source.root, source.path),
|
|
20278
20278
|
message: `Text is set in capitals, which the project does not allow. Write it in sentence case. ${described(capitalized)}`,
|
|
@@ -20347,40 +20347,267 @@ function readConfig(root, project) {
|
|
|
20347
20347
|
function isRecord(value) {
|
|
20348
20348
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20349
20349
|
}
|
|
20350
|
+
// src/shared/present-transition.ts
|
|
20351
|
+
/**
|
|
20352
|
+
* The transitions present mode draws between slides, in the order the
|
|
20353
|
+
* inspector lists them. The list is the board's own. A project adds its
|
|
20354
|
+
* own as stylesheets under `assets/transitions/`, each named by its stem,
|
|
20355
|
+
* and a name in neither reads as no transition.
|
|
20356
|
+
*/
|
|
20357
|
+
const TRANSITIONS = [
|
|
20358
|
+
"none",
|
|
20359
|
+
"fade",
|
|
20360
|
+
"slide",
|
|
20361
|
+
"push",
|
|
20362
|
+
"zoom",
|
|
20363
|
+
"flip",
|
|
20364
|
+
"dissolve"
|
|
20365
|
+
];
|
|
20366
|
+
/** The folder under a project's `assets/` holding its own transitions, one stylesheet each. */
|
|
20367
|
+
const TRANSITIONS_FOLDER = "transitions";
|
|
20368
|
+
const TRANSITION_FILE_EXTENSION = ".css";
|
|
20369
|
+
/** The two layers a transition animates, which name the keyframes a project's file holds. */
|
|
20370
|
+
const TRANSITION_ROLES = ["enter", "leave"];
|
|
20371
|
+
const OWN_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
20372
|
+
const OWN_NAME_MAX_LENGTH = 64;
|
|
20373
|
+
/**
|
|
20374
|
+
* Whether a project's transition may take `name`: lowercase kebab case, and
|
|
20375
|
+
* neither a built-in nor `page`, so a file never shadows what the board draws.
|
|
20376
|
+
*/
|
|
20377
|
+
function isOwnTransitionName(name) {
|
|
20378
|
+
return name.length <= OWN_NAME_MAX_LENGTH && OWN_NAME_PATTERN.test(name) && name !== "page" && transitionNameOf(name) === null;
|
|
20379
|
+
}
|
|
20380
|
+
function transitionNameOf(value) {
|
|
20381
|
+
return TRANSITIONS.find((name) => name === value) ?? null;
|
|
20382
|
+
}
|
|
20383
|
+
const finding = findingFor([{
|
|
20384
|
+
id: "transition-file",
|
|
20385
|
+
tier: "exact",
|
|
20386
|
+
severity: "error",
|
|
20387
|
+
description: `A stylesheet under ${ASSETS_FOLDER}/${TRANSITIONS_FOLDER}/ is named in lowercase kebab case and holds @keyframes enter, optionally @keyframes leave, and nothing else, with no url(), quoted string, or escape. The board refuses a file breaking it whole, whether or not the rule is on`
|
|
20388
|
+
}]);
|
|
20389
|
+
/** A keyframe step: `from`, `to`, or a percentage, alone or in a comma list. */
|
|
20390
|
+
const STEP = /^(?:from|to|\d+(?:\.\d+)?%)(?:\s*,\s*(?:from|to|\d+(?:\.\d+)?%))*$/i;
|
|
20391
|
+
/**
|
|
20392
|
+
* Reads one transition sheet named `name`, its file's stem. The board plays
|
|
20393
|
+
* what this returns in its own document, so the sheet is refused whole on
|
|
20394
|
+
* any stray rather than read past it: a name the board does not take, a
|
|
20395
|
+
* break postcss refuses, anything at the top level but a comment and the
|
|
20396
|
+
* `enter` and `leave` keyframes, anything in a keyframes block but steps of
|
|
20397
|
+
* declarations, and a value that could load a file. A value loads one
|
|
20398
|
+
* through `url()`, through a quoted string such as `image-set()` takes, or
|
|
20399
|
+
* through an escape spelling either, so all three are refused.
|
|
20400
|
+
*/
|
|
20401
|
+
function readTransitionSheet(name, css) {
|
|
20402
|
+
if (!isOwnTransitionName(name)) return refused([{
|
|
20403
|
+
message: `${name} is no transition name. Name the file in lowercase kebab case, and not after a built-in transition, none, or page`,
|
|
20404
|
+
location: null
|
|
20405
|
+
}]);
|
|
20406
|
+
let nodes;
|
|
20407
|
+
try {
|
|
20408
|
+
nodes = postcss_default.parse(css).nodes;
|
|
20409
|
+
} catch (error) {
|
|
20410
|
+
if (!(error instanceof CssSyntaxError)) throw error;
|
|
20411
|
+
const at = offsetOf(css, error.line ?? 1, error.column ?? 1);
|
|
20412
|
+
return refused([{
|
|
20413
|
+
message: `The stylesheet does not parse: ${error.reason}`,
|
|
20414
|
+
location: {
|
|
20415
|
+
line: error.line ?? 1,
|
|
20416
|
+
column: error.column ?? 1,
|
|
20417
|
+
startOffset: at,
|
|
20418
|
+
endOffset: at
|
|
20419
|
+
}
|
|
20420
|
+
}]);
|
|
20421
|
+
}
|
|
20422
|
+
const problems = [];
|
|
20423
|
+
const held = /* @__PURE__ */ new Map();
|
|
20424
|
+
for (const node of nodes) {
|
|
20425
|
+
if (node.type === "comment") continue;
|
|
20426
|
+
const role = roleOf(node);
|
|
20427
|
+
if (!role) problems.push(problemAt(node, strayMessage(node)));
|
|
20428
|
+
else if (held.has(role)) problems.push(problemAt(node, `@keyframes ${role} is written twice`));
|
|
20429
|
+
else {
|
|
20430
|
+
held.set(role, node);
|
|
20431
|
+
problems.push(...blockProblems(node, role));
|
|
20432
|
+
}
|
|
20433
|
+
}
|
|
20434
|
+
const enter = held.get("enter");
|
|
20435
|
+
if (!enter) problems.push({
|
|
20436
|
+
message: "@keyframes enter is missing",
|
|
20437
|
+
location: null
|
|
20438
|
+
});
|
|
20439
|
+
if (!enter || problems.length > 0) return refused(problems);
|
|
20440
|
+
const leave = held.get("leave");
|
|
20441
|
+
return {
|
|
20442
|
+
ok: true,
|
|
20443
|
+
enter: bodyOf(enter),
|
|
20444
|
+
leave: leave ? bodyOf(leave) : null
|
|
20445
|
+
};
|
|
20446
|
+
}
|
|
20447
|
+
function refused(problems) {
|
|
20448
|
+
return {
|
|
20449
|
+
ok: false,
|
|
20450
|
+
problems
|
|
20451
|
+
};
|
|
20452
|
+
}
|
|
20453
|
+
/** The role a top-level node holds the keyframes of, null for anything else. */
|
|
20454
|
+
function roleOf(node) {
|
|
20455
|
+
if (node.type !== "atrule" || node.name !== "keyframes") return null;
|
|
20456
|
+
return TRANSITION_ROLES.find((role) => role === node.params.trim()) ?? null;
|
|
20457
|
+
}
|
|
20458
|
+
function strayMessage(node) {
|
|
20459
|
+
if (node.type === "rule") return `A style rule (${node.selector}) sits outside the keyframes`;
|
|
20460
|
+
if (node.type === "decl") return `A declaration (${node.prop}) sits outside the keyframes`;
|
|
20461
|
+
return `${node.type === "atrule" && node.name === "keyframes" ? `@keyframes ${node.params.trim()}` : `@${node.type === "atrule" ? node.name : node.type}`} is not @keyframes enter or @keyframes leave`;
|
|
20462
|
+
}
|
|
20463
|
+
function blockProblems(block, role) {
|
|
20464
|
+
const problems = [];
|
|
20465
|
+
for (const step of block.nodes ?? []) {
|
|
20466
|
+
if (step.type === "comment") continue;
|
|
20467
|
+
if (step.type === "atrule") {
|
|
20468
|
+
problems.push(problemAt(step, `@${step.name} sits inside @keyframes ${role}`));
|
|
20469
|
+
continue;
|
|
20470
|
+
}
|
|
20471
|
+
if (step.type === "decl") {
|
|
20472
|
+
problems.push(problemAt(step, `${step.prop} sits in @keyframes ${role} outside a step`));
|
|
20473
|
+
continue;
|
|
20474
|
+
}
|
|
20475
|
+
if (!STEP.test(step.selector.trim())) {
|
|
20476
|
+
problems.push(problemAt(step, `${step.selector} is not a keyframe step such as from, to, or 50%`));
|
|
20477
|
+
continue;
|
|
20478
|
+
}
|
|
20479
|
+
for (const child of step.nodes) {
|
|
20480
|
+
if (child.type === "comment") continue;
|
|
20481
|
+
if (child.type !== "decl") {
|
|
20482
|
+
problems.push(problemAt(child, `Only declarations sit inside a keyframe step`));
|
|
20483
|
+
continue;
|
|
20484
|
+
}
|
|
20485
|
+
const loads = loadIn(`${child.prop}:${child.value}`);
|
|
20486
|
+
if (loads) problems.push(problemAt(child, `${child.prop} holds ${loads}`));
|
|
20487
|
+
}
|
|
20488
|
+
}
|
|
20489
|
+
return problems;
|
|
20490
|
+
}
|
|
20491
|
+
/** What in a declaration could load a file, null when nothing could. */
|
|
20492
|
+
function loadIn(declaration) {
|
|
20493
|
+
if (declaration.includes("\\")) return "a backslash escape, which can spell url()";
|
|
20494
|
+
if (/url\(/i.test(declaration)) return "url(), and a transition loads nothing";
|
|
20495
|
+
if (/["']/.test(declaration)) return "a quoted string, and a transition loads nothing";
|
|
20496
|
+
return null;
|
|
20497
|
+
}
|
|
20498
|
+
function problemAt(node, message) {
|
|
20499
|
+
const { start, end } = node.source ?? {};
|
|
20500
|
+
if (!start) return {
|
|
20501
|
+
message,
|
|
20502
|
+
location: null
|
|
20503
|
+
};
|
|
20504
|
+
return {
|
|
20505
|
+
message,
|
|
20506
|
+
location: {
|
|
20507
|
+
line: start.line,
|
|
20508
|
+
column: start.column,
|
|
20509
|
+
startOffset: start.offset,
|
|
20510
|
+
endOffset: end ? end.offset : start.offset
|
|
20511
|
+
}
|
|
20512
|
+
};
|
|
20513
|
+
}
|
|
20514
|
+
/** The steps inside a keyframes block, on one line, with its comments dropped. */
|
|
20515
|
+
function bodyOf(block) {
|
|
20516
|
+
return (block.nodes ?? []).filter((node) => node.type === "rule").map((step) => {
|
|
20517
|
+
const declarations = step.nodes.filter((child) => child.type === "decl").map((child) => `${child.prop}: ${child.value}${child.important ? " !important" : ""}`);
|
|
20518
|
+
return `${step.selector.trim()} { ${declarations.join("; ")} }`;
|
|
20519
|
+
}).join(" ");
|
|
20520
|
+
}
|
|
20521
|
+
/** Where a transition named `name` sits in its board, with forward slashes. */
|
|
20522
|
+
function transitionPath(project, name) {
|
|
20523
|
+
return `${project}/${ASSETS_FOLDER}/${TRANSITIONS_FOLDER}/${name}${TRANSITION_FILE_EXTENSION}`;
|
|
20524
|
+
}
|
|
20525
|
+
/**
|
|
20526
|
+
* `transition-file`, one finding per thing the sheet may not hold. The
|
|
20527
|
+
* caller filters it through `withoutOff`, which silences the finding and
|
|
20528
|
+
* leaves the file refused.
|
|
20529
|
+
*/
|
|
20530
|
+
function checkTransitionSheet({ project, name }, css) {
|
|
20531
|
+
const reading = readTransitionSheet(name, css);
|
|
20532
|
+
if (reading.ok) return [];
|
|
20533
|
+
return reading.problems.map(({ message, location }) => finding("transition-file", {
|
|
20534
|
+
frame: null,
|
|
20535
|
+
path: transitionPath(project, name),
|
|
20536
|
+
message,
|
|
20537
|
+
location
|
|
20538
|
+
}));
|
|
20539
|
+
}
|
|
20350
20540
|
// src/cli/hook-reply.ts
|
|
20351
20541
|
/**
|
|
20352
20542
|
* What the write hook prints for one hook payload: a `block` decision whose
|
|
20353
20543
|
* reason lists the findings, which Claude Code hands the agent beside the
|
|
20354
|
-
* tool result, or null to print nothing.
|
|
20355
|
-
*
|
|
20356
|
-
* answer null, so the hook
|
|
20544
|
+
* tool result, or null to print nothing. It answers a frame and a project's
|
|
20545
|
+
* transition file. Any other write, a file outside any board, a file gone
|
|
20546
|
+
* since, and a payload that does not read all answer null, so the hook
|
|
20547
|
+
* never reports a write as failed.
|
|
20357
20548
|
*
|
|
20358
20549
|
* Imports nothing beyond the rules and `src/shared/`, since process start is
|
|
20359
20550
|
* the hook's whole budget on every agent write.
|
|
20360
20551
|
*/
|
|
20361
20552
|
function hookReply(stdin) {
|
|
20362
20553
|
try {
|
|
20363
|
-
const
|
|
20364
|
-
if (!
|
|
20365
|
-
const
|
|
20366
|
-
if (findings.length === 0) return null;
|
|
20367
|
-
const
|
|
20554
|
+
const path = writtenPath(JSON.parse(stdin));
|
|
20555
|
+
if (!path) return null;
|
|
20556
|
+
const checked = frameFindings(path) ?? transitionFindings(path);
|
|
20557
|
+
if (!checked || checked.findings.length === 0) return null;
|
|
20558
|
+
const { findings, subject, noun } = checked;
|
|
20368
20559
|
const count = `${findings.length} finding${findings.length === 1 ? "" : "s"}`;
|
|
20369
20560
|
return JSON.stringify({
|
|
20370
20561
|
decision: "block",
|
|
20371
|
-
reason: [`frameboard check found ${count} in ${
|
|
20562
|
+
reason: [`frameboard check found ${count} in ${subject}. Fix each and write the ${noun} again.`, ...findings.map(formatFinding)].join("\n")
|
|
20372
20563
|
});
|
|
20373
20564
|
} catch {
|
|
20374
20565
|
return null;
|
|
20375
20566
|
}
|
|
20376
20567
|
}
|
|
20377
|
-
/** The
|
|
20378
|
-
function
|
|
20568
|
+
/** The absolute path a payload wrote, null for a payload naming none. */
|
|
20569
|
+
function writtenPath(payload) {
|
|
20379
20570
|
if (typeof payload !== "object" || payload === null) return null;
|
|
20380
20571
|
const { tool_input: input, cwd } = payload;
|
|
20381
20572
|
const written = input?.file_path;
|
|
20382
|
-
if (typeof written !== "string"
|
|
20383
|
-
|
|
20573
|
+
if (typeof written !== "string") return null;
|
|
20574
|
+
return isAbsolute(written) ? written : resolve(typeof cwd === "string" ? cwd : process.cwd(), written);
|
|
20575
|
+
}
|
|
20576
|
+
function frameFindings(path) {
|
|
20577
|
+
const target = frameOf(path);
|
|
20578
|
+
if (!target) return null;
|
|
20579
|
+
return {
|
|
20580
|
+
findings: checkFrame(target).findings,
|
|
20581
|
+
subject: `${target.project}/${target.page}/${target.name}`,
|
|
20582
|
+
noun: "frame"
|
|
20583
|
+
};
|
|
20584
|
+
}
|
|
20585
|
+
/**
|
|
20586
|
+
* The findings of a stylesheet written directly under a project's
|
|
20587
|
+
* `assets/transitions/` in a board, null for any other path.
|
|
20588
|
+
*/
|
|
20589
|
+
function transitionFindings(path) {
|
|
20590
|
+
if (!path.endsWith(".css")) return null;
|
|
20591
|
+
const folder = dirname(path);
|
|
20592
|
+
const assets = dirname(folder);
|
|
20593
|
+
const projectDir = dirname(assets);
|
|
20594
|
+
const root = dirname(projectDir);
|
|
20595
|
+
const project = basename(projectDir);
|
|
20596
|
+
const file = basename(path);
|
|
20597
|
+
if (basename(folder) !== "transitions" || basename(assets) !== "assets" || [project, file].some((part) => part.startsWith(".")) || !existsSync(path) || !existsSync(join(root, "board.json"))) return null;
|
|
20598
|
+
const name = file.slice(0, -4);
|
|
20599
|
+
return {
|
|
20600
|
+
findings: withoutOff(checkTransitionSheet({
|
|
20601
|
+
project,
|
|
20602
|
+
name
|
|
20603
|
+
}, readFileSync(path, "utf8")), readConfig(root, project).off),
|
|
20604
|
+
subject: transitionPath(project, name),
|
|
20605
|
+
noun: "file"
|
|
20606
|
+
};
|
|
20607
|
+
}
|
|
20608
|
+
/** The frame at `path`, when it sits in a page of a board. */
|
|
20609
|
+
function frameOf(path) {
|
|
20610
|
+
if (!path.endsWith(".html")) return null;
|
|
20384
20611
|
const pageDir = dirname(path);
|
|
20385
20612
|
const projectDir = dirname(pageDir);
|
|
20386
20613
|
const root = dirname(projectDir);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frameboard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "A local design board that coding agents draw on as plain HTML files",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"husky": "^9.1.7",
|
|
106
106
|
"jsdom": "^31.0.0",
|
|
107
107
|
"lucide-react": "^1.57.0",
|
|
108
|
-
"oxfmt": "0.
|
|
109
|
-
"oxlint": "1.
|
|
108
|
+
"oxfmt": "0.78.0",
|
|
109
|
+
"oxlint": "1.93.0",
|
|
110
110
|
"parse5": "^8.1.1",
|
|
111
111
|
"parse5-htmlparser2-tree-adapter": "^8.0.2",
|
|
112
112
|
"playwright": "^1.64.1",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"playwright-core": "1.65.0"
|
|
133
133
|
},
|
|
134
134
|
"peerDependencies": {
|
|
135
|
-
"oxfmt": "0.
|
|
135
|
+
"oxfmt": "0.78.0"
|
|
136
136
|
},
|
|
137
137
|
"peerDependenciesMeta": {
|
|
138
138
|
"oxfmt": {
|