frameboard 0.34.0 → 0.36.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.
@@ -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-CDrU_o7Y.js"></script>
27
- <link rel="stylesheet" crossorigin href="/assets/index-Bw5nMnAO.css">
26
+ <script type="module" crossorigin src="/assets/index-DiLmy0gj.js"></script>
27
+ <link rel="stylesheet" crossorigin href="/assets/index-C9FWP23N.css">
28
28
  </head>
29
29
  <body>
30
30
  <div id="root"></div>
package/dist/hook.js CHANGED
@@ -19450,6 +19450,16 @@ function findingFor(docs) {
19450
19450
  };
19451
19451
  }
19452
19452
  /**
19453
+ * `findings` without those of a rule `off` names, which a project's
19454
+ * `checks.off` lists. Every path that reports a finding returns through it,
19455
+ * so the board, `check`, and the hook agree on what is off. An id no rule
19456
+ * declares matches no finding and drops nothing.
19457
+ */
19458
+ function withoutOff(findings, off) {
19459
+ if (!off || off.length === 0) return findings;
19460
+ return findings.filter((finding) => !off.includes(finding.rule));
19461
+ }
19462
+ /**
19453
19463
  * One finding as `path:line:column rule message`, as `check` and the hook
19454
19464
  * print it, the path taking `@<width>` for one read at a linked width.
19455
19465
  */
@@ -19457,7 +19467,7 @@ function formatFinding(finding) {
19457
19467
  const path = finding.width === void 0 ? finding.path : `${finding.path}@${finding.width}`;
19458
19468
  return `${finding.location ? `${path}:${finding.location.line}:${finding.location.column}` : path} ${finding.rule} ${finding.message}`;
19459
19469
  }
19460
- const finding$5 = findingFor([{
19470
+ const finding$6 = findingFor([{
19461
19471
  id: "unknown-token",
19462
19472
  tier: "exact",
19463
19473
  severity: "warning",
@@ -19521,7 +19531,7 @@ function checkUnknownTokens(source, tokens) {
19521
19531
  if (element.name !== "script") continue;
19522
19532
  for (const name of scriptWrites(scriptText(element, source))) declared.add(name);
19523
19533
  }
19524
- return uses.filter((use) => !declared.has(use.name)).map((use) => finding$5("unknown-token", {
19534
+ return uses.filter((use) => !declared.has(use.name)).map((use) => finding$6("unknown-token", {
19525
19535
  frame: source.ref,
19526
19536
  path: use.path,
19527
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.`,
@@ -19573,7 +19583,7 @@ function parseOrNull(css) {
19573
19583
  return null;
19574
19584
  }
19575
19585
  }
19576
- const finding$4 = findingFor([
19586
+ const finding$5 = findingFor([
19577
19587
  {
19578
19588
  id: "default-font",
19579
19589
  tier: "selector",
@@ -19636,7 +19646,7 @@ function checkFonts(source, cascade, config) {
19636
19646
  else if (allowed && !allowed.includes(family.toLowerCase())) push(unlisted, family, element);
19637
19647
  }
19638
19648
  const path = boardPath(source.root, source.path);
19639
- const at = (rule, elements, message) => finding$4(rule, {
19649
+ const at = (rule, elements, message) => finding$5(rule, {
19640
19650
  frame: source.ref,
19641
19651
  path,
19642
19652
  message: `${message} ${described(elements)}`,
@@ -19665,7 +19675,7 @@ function push(map, key, element) {
19665
19675
  if (list) list.push(element);
19666
19676
  else map.set(key, [element]);
19667
19677
  }
19668
- const finding$3 = findingFor([
19678
+ const finding$4 = findingFor([
19669
19679
  {
19670
19680
  id: "outside-link",
19671
19681
  tier: "exact",
@@ -19760,16 +19770,16 @@ function judge(source, load) {
19760
19770
  path: load.path,
19761
19771
  location: load.location
19762
19772
  };
19763
- if (hasScheme(url)) return [finding$3("network", {
19773
+ if (hasScheme(url)) return [finding$4("network", {
19764
19774
  ...fields,
19765
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.`
19766
19776
  })];
19767
19777
  const target = localTarget(url, load.base);
19768
- if (target === null || !allowed(source, target)) return [finding$3("outside-link", {
19778
+ if (target === null || !allowed(source, target)) return [finding$4("outside-link", {
19769
19779
  ...fields,
19770
19780
  message: `${load.via} loads ${url}, outside this page's folder and the project's assets/. Move the file into one of them.`
19771
19781
  })];
19772
- if (!existsSync(target)) return [finding$3("missing-file", {
19782
+ if (!existsSync(target)) return [finding$4("missing-file", {
19773
19783
  ...fields,
19774
19784
  message: `${load.via} loads ${url}, which does not exist.`
19775
19785
  })];
@@ -19834,7 +19844,7 @@ function isReservedPageName(name) {
19834
19844
  function namesCollide(a, b) {
19835
19845
  return a.toLowerCase() === b.toLowerCase();
19836
19846
  }
19837
- const finding$2 = findingFor([
19847
+ const finding$3 = findingFor([
19838
19848
  {
19839
19849
  id: "naming",
19840
19850
  tier: "exact",
@@ -19934,12 +19944,12 @@ const MALFORMED = {
19934
19944
  function checkNaming(target, path) {
19935
19945
  const ref = `${target.project}/${target.page}/${target.name}`;
19936
19946
  const findings = [];
19937
- if (!isValidName(target.page) || isReservedPageName(target.page)) findings.push(finding$2("naming", {
19947
+ if (!isValidName(target.page) || isReservedPageName(target.page)) findings.push(finding$3("naming", {
19938
19948
  frame: ref,
19939
19949
  path,
19940
19950
  message: `Page name ${target.page} is not valid. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit.`
19941
19951
  }));
19942
- if (!isValidName(target.name)) findings.push(finding$2("naming", {
19952
+ if (!isValidName(target.name)) findings.push(finding$3("naming", {
19943
19953
  frame: ref,
19944
19954
  path,
19945
19955
  message: `Frame name ${target.name} is not valid. Use letters, digits, dots, dashes, and underscores, opening with a letter or digit.`
@@ -19952,13 +19962,13 @@ function checkMarkup(source) {
19952
19962
  const findings = [];
19953
19963
  const head = source.elements.find((element) => element.name === "head");
19954
19964
  const body = source.elements.find((element) => element.name === "body");
19955
- if (head && startTagLocation(head) && !(body && startTagLocation(body))) findings.push(finding$2("head-body", {
19965
+ if (head && startTagLocation(head) && !(body && startTagLocation(body))) findings.push(finding$3("head-body", {
19956
19966
  frame: source.ref,
19957
19967
  path,
19958
19968
  message: "The frame states <head> and no <body>. Wrap the visible content in <body>.",
19959
19969
  location: startTagLocation(head)
19960
19970
  }));
19961
- 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$2("table-tbody", {
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", {
19962
19972
  frame: source.ref,
19963
19973
  path,
19964
19974
  message: "This table holds rows with no <tbody>, so the browser adds one the file does not hold. State the <tbody>.",
@@ -19985,7 +19995,7 @@ function checkMalformedTags(source) {
19985
19995
  if (reported.has(tag)) continue;
19986
19996
  reported.add(tag);
19987
19997
  }
19988
- findings.push(finding$2("malformed-tag", {
19998
+ findings.push(finding$3("malformed-tag", {
19989
19999
  frame: source.ref,
19990
20000
  path,
19991
20001
  message: `${tag ? `<${tag.name}> raises ${error.code}` : error.code}. ${message}`,
@@ -20003,7 +20013,7 @@ function checkMalformedTags(source) {
20003
20013
  function checkNesting(source) {
20004
20014
  const path = boardPath(source.root, source.path);
20005
20015
  const findings = [];
20006
- const report = (message, location) => findings.push(finding$2("nesting", {
20016
+ const report = (message, location) => findings.push(finding$3("nesting", {
20007
20017
  frame: source.ref,
20008
20018
  path,
20009
20019
  message,
@@ -20058,7 +20068,7 @@ function strayEndTag(html, element) {
20058
20068
  function isTable(element) {
20059
20069
  return element.name === "table";
20060
20070
  }
20061
- const finding$1 = findingFor([{
20071
+ const finding$2 = findingFor([{
20062
20072
  id: "theme",
20063
20073
  tier: "selector",
20064
20074
  severity: "error",
@@ -20073,7 +20083,7 @@ function checkTheme(source) {
20073
20083
  const { firstColor, bothThemes } = readThemeColors(source);
20074
20084
  if (!firstColor || bothThemes) return [];
20075
20085
  const { path, location } = firstColor;
20076
- return [finding$1("theme", {
20086
+ return [finding$2("theme", {
20077
20087
  frame: source.ref,
20078
20088
  path,
20079
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.",
@@ -20249,7 +20259,7 @@ function tokenSheets(root, project, tokens) {
20249
20259
  offset: 0
20250
20260
  }));
20251
20261
  }
20252
- const finding = findingFor([{
20262
+ const finding$1 = findingFor([{
20253
20263
  id: "uppercase",
20254
20264
  tier: "selector",
20255
20265
  severity: "warning",
@@ -20262,7 +20272,7 @@ function checkUppercase(source, cascade) {
20262
20272
  const capitalized = textElements(source).filter((element) => cascade.textTransform(element) === "uppercase" || ownText(element).some((text) => CAPITALS.test(text)));
20263
20273
  const first = capitalized[0];
20264
20274
  if (!first) return [];
20265
- return [finding("uppercase", {
20275
+ return [finding$1("uppercase", {
20266
20276
  frame: source.ref,
20267
20277
  path: boardPath(source.root, source.path),
20268
20278
  message: `Text is set in capitals, which the project does not allow. Write it in sentence case. ${described(capitalized)}`,
@@ -20287,7 +20297,7 @@ function checkFrame(target) {
20287
20297
  function checkFrameIn(target, { config, tokens }) {
20288
20298
  const source = readFrame(target);
20289
20299
  const cascade = buildCascade(source, tokens);
20290
- return [
20300
+ return withoutOff([
20291
20301
  ...checkNaming(target, boardPath(target.root, source.path)),
20292
20302
  ...checkMarkup(source),
20293
20303
  ...checkMalformedTags(source),
@@ -20297,7 +20307,7 @@ function checkFrameIn(target, { config, tokens }) {
20297
20307
  ...checkTheme(source),
20298
20308
  ...checkUnknownTokens(source, tokens),
20299
20309
  ...config.noUppercase ? checkUppercase(source, cascade) : []
20300
- ];
20310
+ ], config.off);
20301
20311
  }
20302
20312
  /**
20303
20313
  * The project's config and token sheets, read once for every frame a call
@@ -20313,8 +20323,9 @@ function readProjectContext(root, project, boardSheet) {
20313
20323
  /**
20314
20324
  * The project's `checks` config, read by hand rather than through the
20315
20325
  * project record's schema, which the hook cannot afford to load. A file that
20316
- * does not read, or a key of the wrong type, leaves that rule off. The
20317
- * server's browser checker reads it too, for `minFontSize` and `minContrast`.
20326
+ * does not read, or a key of the wrong type, leaves that rule off, and an
20327
+ * `off` that is not a list of ids turns nothing off. The server's browser
20328
+ * checker reads it too, for `minFontSize`, `minContrast`, and `off`.
20318
20329
  */
20319
20330
  function readConfig(root, project) {
20320
20331
  let parsed;
@@ -20330,45 +20341,273 @@ function readConfig(root, project) {
20330
20341
  if (typeof checks.noUppercase === "boolean") config.noUppercase = checks.noUppercase;
20331
20342
  if (typeof checks.minFontSize === "number" && checks.minFontSize > 0) config.minFontSize = checks.minFontSize;
20332
20343
  if (typeof checks.minContrast === "number" && checks.minContrast >= 1) config.minContrast = checks.minContrast;
20344
+ if (Array.isArray(checks.off) && checks.off.every((rule) => typeof rule === "string")) config.off = checks.off;
20333
20345
  return config;
20334
20346
  }
20335
20347
  function isRecord(value) {
20336
20348
  return typeof value === "object" && value !== null && !Array.isArray(value);
20337
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
+ }
20338
20540
  // src/cli/hook-reply.ts
20339
20541
  /**
20340
20542
  * What the write hook prints for one hook payload: a `block` decision whose
20341
20543
  * reason lists the findings, which Claude Code hands the agent beside the
20342
- * tool result, or null to print nothing. A write that is not a frame, a frame
20343
- * outside any board, a file gone since, and a payload that does not read all
20344
- * answer null, so the hook never reports a write as failed.
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.
20345
20548
  *
20346
20549
  * Imports nothing beyond the rules and `src/shared/`, since process start is
20347
20550
  * the hook's whole budget on every agent write.
20348
20551
  */
20349
20552
  function hookReply(stdin) {
20350
20553
  try {
20351
- const target = frameOf(JSON.parse(stdin));
20352
- if (!target) return null;
20353
- const { findings } = checkFrame(target);
20354
- if (findings.length === 0) return null;
20355
- const ref = `${target.project}/${target.page}/${target.name}`;
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;
20356
20559
  const count = `${findings.length} finding${findings.length === 1 ? "" : "s"}`;
20357
20560
  return JSON.stringify({
20358
20561
  decision: "block",
20359
- reason: [`frameboard check found ${count} in ${ref}. Fix each and write the frame again.`, ...findings.map(formatFinding)].join("\n")
20562
+ reason: [`frameboard check found ${count} in ${subject}. Fix each and write the ${noun} again.`, ...findings.map(formatFinding)].join("\n")
20360
20563
  });
20361
20564
  } catch {
20362
20565
  return null;
20363
20566
  }
20364
20567
  }
20365
- /** The frame a payload wrote, when it sits in a page of a board. */
20366
- function frameOf(payload) {
20568
+ /** The absolute path a payload wrote, null for a payload naming none. */
20569
+ function writtenPath(payload) {
20367
20570
  if (typeof payload !== "object" || payload === null) return null;
20368
20571
  const { tool_input: input, cwd } = payload;
20369
20572
  const written = input?.file_path;
20370
- if (typeof written !== "string" || !written.endsWith(".html")) return null;
20371
- const path = isAbsolute(written) ? written : resolve(typeof cwd === "string" ? cwd : process.cwd(), written);
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;
20372
20611
  const pageDir = dirname(path);
20373
20612
  const projectDir = dirname(pageDir);
20374
20613
  const root = dirname(projectDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "frameboard",
3
- "version": "0.34.0",
3
+ "version": "0.36.0",
4
4
  "description": "A local design board that coding agents draw on as plain HTML files",
5
5
  "keywords": [
6
6
  "design",