{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "task",
  "title": "Task",
  "author": "zyx1121 (https://github.com/zyx1121)",
  "description": "A Next.js starter for a small task: the base, the four corners, the page motion and one centered column, plus an audit of the rendered page.",
  "devDependencies": [
    "playwright"
  ],
  "registryDependencies": [
    "https://ui.zyx.tw/r/corners.json",
    "https://ui.zyx.tw/r/page-decode-next.json",
    "https://ui.zyx.tw/r/layout.json",
    "https://ui.zyx.tw/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/zyx/components/task-shell.tsx",
      "content": "\"use client\"\n\nimport { BottomCorners, LegalLinks, TopCorners } from \"./corners\"\n\nimport { column, enterRow, page } from \"../lib/layout\"\nimport { cn } from \"../lib/utils\"\n\n/**\n * The page of a small task (a personal tool, a demo): the four corners, the\n * page motion and one centered column that holds the title and the task.\n * The root layout mounts the page motion once, as the task item's app/layout.tsx does. `actions` are short text links at the\n * top right, `wide` gives an editor or a comparison more room.\n */\nexport function TaskShell({\n  title,\n  description,\n  actions,\n  wide = false,\n  children,\n}: {\n  title: string\n  description?: string\n  actions?: React.ReactNode\n  wide?: boolean\n  children: React.ReactNode\n}) {\n  return (\n    <>\n      <TopCorners fade nav={actions} />\n      <main\n        id=\"task\"\n        className={cn(\n          column,\n          page,\n          wide && \"max-w-none lg:max-w-6xl 2xl:max-w-6xl\"\n        )}\n      >\n        <h1\n          className={cn(\n            \"text-headline font-medium tracking-tight\",\n            enterRow(1)\n          )}\n        >\n          {title}\n        </h1>\n        {description && (\n          <p className={cn(\"mt-3 text-muted-foreground\", enterRow(2))}>\n            {description}\n          </p>\n        )}\n        <div className={cn(\"mt-20\", enterRow(3))}>{children}</div>\n      </main>\n      <BottomCorners fade links={<LegalLinks />} />\n    </>\n  )\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/zyx/task/layout.tsx",
      "content": "import type { Metadata } from \"next\";\nimport { Noto_Sans_TC } from \"next/font/google\";\n\nimport \"./globals.css\";\nimport { NextPageDecode } from \"@/components/page-decode-next\";\n\n// Han characters outside Maple Mono's subset, in slices a page loads on use.\nconst notoSansTc = Noto_Sans_TC({\n  display: \"swap\",\n  preload: false,\n  variable: \"--font-noto-sans-tc\",\n});\n\nexport const metadata: Metadata = {\n  title: \"Task\",\n  icons: \"https://www.zyx.tw/favicon.ico\",\n};\n\nexport default function RootLayout({\n  children,\n}: Readonly<{ children: React.ReactNode }>) {\n  return (\n    <html lang=\"en\" className={notoSansTc.variable} suppressHydrationWarning>\n      <head>\n        <link\n          rel=\"stylesheet\"\n          href=\"https://ui.zyx.tw/fonts/maple-mono-nf-cn.css\"\n        />\n      </head>\n      <body>\n        <NextPageDecode />\n        {children}\n      </body>\n    </html>\n  );\n}\n",
      "type": "registry:file",
      "target": "~/app/layout.tsx"
    },
    {
      "path": "registry/zyx/task/page.tsx",
      "content": "import { TaskShell } from \"@/components/task-shell\";\n\nexport default function Page() {\n  return (\n    <TaskShell title=\"Task\">\n      <section aria-label=\"Workspace\"></section>\n    </TaskShell>\n  );\n}\n",
      "type": "registry:file",
      "target": "~/app/page.tsx"
    },
    {
      "path": "registry/zyx/task/audit.mjs",
      "content": "#!/usr/bin/env node\n// Measure a rendered page against the zyx contract (ui.zyx.tw DESIGN.md):\n// type scale, four corners, no sideways scroll and copy written for\n// the person using the page.\nimport { parseArgs } from \"node:util\";\n\nconst usage =\n  \"node scripts/audit.mjs <url> [--browser webkit|chromium] [--home https://www.zyx.tw]\";\nconst SIZES = [14, 16, 24, 80];\nconst WEIGHTS = [400, 500];\nconst VIEWPORTS = [\n  { width: 1280, height: 800 },\n  { width: 390, height: 844 },\n  { width: 320, height: 640 },\n];\n// Sentences written for the developer or the agent, not for the person using the page.\nconst NOTES = [\n  /\\b(?:todo|lorem ipsum|placeholder)\\b/i,\n  /\\b(?:will|would) (?:appear|show up|be shown) here\\b/i,\n  /\\breplace (?:this|me)\\b/i,\n  /(?:會|將)(?:顯示|出現)在(?:這裡|此處)/,\n  /(?:這裡|此處)(?:會|將)/,\n  // Instructions on how to use the page.\n  /\\b(?:click (?:here|the)|you can|feel free to)\\b/i,\n  /^(?:請先|請點|點擊|點選|按下)|(?:你|您)可以/,\n];\n// Placeholders name nothing; they must not suggest a value.\nconst SUGGESTION =\n  /^(?:e\\.g\\.|eg[:.]|ex[:.]|such as|for example)|例如|比如|範例[:：]/i;\n// Buttons are a verb or two.\nconst BUTTON = { words: 3, cjk: 6 };\n\nfunction measure({ sizes, weights, notes, suggestion, button }) {\n  // The corners sit --gutter in from the viewport, plus --bezel in the TV frame.\n  const probe = document.createElement(\"div\");\n  probe.style.cssText =\n    \"position:fixed;top:calc(var(--bezel, 0px) + var(--gutter, 0px))\";\n  document.body.append(probe);\n  // No --gutter means the layout item is missing: report it, do not pass at 0.\n  const inset = getComputedStyle(document.documentElement)\n    .getPropertyValue(\"--gutter\")\n    .trim()\n    ? probe.getBoundingClientRect().top\n    : -1;\n  probe.remove();\n  const visible = (element) => {\n    const style = getComputedStyle(element);\n    const box = element.getBoundingClientRect();\n    return (\n      style.visibility !== \"hidden\" &&\n      style.display !== \"none\" &&\n      Number(style.opacity) > 0 &&\n      box.width > 0 &&\n      box.height > 0\n    );\n  };\n  const describe = (element) => {\n    const id = element.id ? `#${element.id}` : \"\";\n    const slot = element.dataset.slot\n      ? `[data-slot=${element.dataset.slot}]`\n      : \"\";\n    return `${element.tagName.toLowerCase()}${id}${slot}`;\n  };\n  const snippet = (text) => text.replace(/\\s+/g, \" \").trim().slice(0, 40);\n  const type = new Map();\n  const copy = new Set();\n  for (const element of document.body.querySelectorAll(\"*\")) {\n    if (element.closest(\"svg, script, style, noscript, [aria-hidden=true]\"))\n      continue;\n    const field = element.matches(\"input:not([type=hidden]), textarea, select\");\n    const own = [...element.childNodes]\n      .filter((node) => node.nodeType === Node.TEXT_NODE)\n      .map((node) => node.textContent)\n      .join(\"\");\n    const text = field\n      ? element.value || element.getAttribute(\"placeholder\") || \"\"\n      : own;\n    if (!text.trim() || !visible(element)) continue;\n    const style = getComputedStyle(element);\n    const size = Math.round(parseFloat(style.fontSize) * 100) / 100;\n    const weight = Number(style.fontWeight);\n    // Bold is real emphasis in prose, and code highlighting owns its weights.\n    const emphasis = element.closest(\"strong, b, code, pre\");\n    if (!sizes.includes(size) || (!emphasis && !weights.includes(weight))) {\n      const key = `${size}px/${weight} ${describe(element)}`;\n      if (!type.has(key)) type.set(key, snippet(text));\n    }\n    for (const note of notes)\n      if (new RegExp(note.source, note.flags).test(text))\n        copy.add(snippet(text));\n    const hint = element.getAttribute(\"placeholder\");\n    if (\n      field &&\n      hint &&\n      new RegExp(suggestion.source, suggestion.flags).test(hint.trim())\n    )\n      copy.add(`placeholder suggests a value: ${snippet(hint)}`);\n  }\n  for (const element of document.body.querySelectorAll(\n    \"button, [role=button], a[data-slot=button]\"\n  )) {\n    if (!visible(element)) continue;\n    const label = element.textContent.replace(/\\s+/g, \" \").trim();\n    const cjk = (label.match(/[\\u3400-\\u9fff]/g) ?? []).length;\n    const words = label\n      .replace(/[\\u3400-\\u9fff]/g, \" \")\n      .split(\" \")\n      .filter(Boolean).length;\n    if (cjk > button.cjk || words > button.words)\n      copy.add(`button is not a short verb: ${snippet(label)}`);\n  }\n  const vw = document.documentElement.clientWidth;\n  const vh = window.innerHeight;\n  const near = (a, b) => Math.abs(a - b) <= 1;\n  const fixed = [...document.body.querySelectorAll(\"*\")].filter(\n    (element) =>\n      getComputedStyle(element).position === \"fixed\" && visible(element)\n  );\n  const boxes = fixed.map((element) => ({\n    element,\n    box: element.getBoundingClientRect(),\n  }));\n  const corner = (test) => boxes.find(({ box }) => test(box))?.element;\n  const corners = {\n    \"top-left\": corner((box) => near(box.left, inset) && near(box.top, inset)),\n    \"top-right\": corner(\n      (box) => near(box.right, vw - inset) && near(box.top, inset)\n    ),\n    \"bottom-left\": corner(\n      (box) => near(box.left, inset) && near(box.bottom, vh - inset)\n    ),\n    \"bottom-right\": corner(\n      (box) => near(box.right, vw - inset) && near(box.bottom, vh - inset)\n    ),\n  };\n  const mark = corners[\"top-left\"]?.querySelector(\"a[href]\")?.href ?? null;\n  const wide = [...document.body.querySelectorAll(\"*\")]\n    .filter(\n      (element) =>\n        visible(element) && element.getBoundingClientRect().right > vw + 1\n    )\n    .slice(0, 5)\n    .map(\n      (element) =>\n        `${describe(element)} right=${Math.round(element.getBoundingClientRect().right)}`\n    );\n  return {\n    type: [...type].map(([key, text]) => `${key} \"${text}\"`),\n    copy: [...copy],\n    missing: Object.entries(corners)\n      .filter(([, element]) => !element)\n      .map(([at]) => at),\n    mark,\n    inset,\n    overflow: document.documentElement.scrollWidth > vw + 1 ? wide : [],\n  };\n}\n\nasync function audit() {\n  const { values, positionals } = parseArgs({\n    allowPositionals: true,\n    options: {\n      browser: { type: \"string\", default: \"webkit\" },\n      home: { type: \"string\", default: \"https://www.zyx.tw\" },\n      help: { type: \"boolean\" },\n    },\n  });\n  if (values.help) return console.log(usage);\n  if (positionals.length !== 1) throw new Error(usage);\n  if (![\"webkit\", \"chromium\"].includes(values.browser))\n    throw new Error(\"--browser must be webkit or chromium\");\n  const playwright = await import(\"playwright\");\n  const browser = await playwright[values.browser].launch();\n  const failures = [];\n  const copy = new Set();\n  const fail = (check, where, details) =>\n    failures.push(\n      `FAIL ${check} @ ${where}\\n${details.map((line) => `  ${line}`).join(\"\\n\")}`\n    );\n  try {\n    for (const viewport of VIEWPORTS) {\n      const page = await browser.newPage({ viewport, reducedMotion: \"reduce\" });\n      await page.goto(positionals[0], { waitUntil: \"networkidle\" });\n      await page.evaluate(() => document.fonts.ready);\n      const size = `${viewport.width}x${viewport.height}`;\n      // One fixed theme.\n      {\n        const where = size;\n        const result = await page.evaluate(measure, {\n          sizes: SIZES,\n          weights: WEIGHTS,\n          notes: NOTES.map((note) => ({\n            source: note.source,\n            flags: note.flags,\n          })),\n          suggestion: { source: SUGGESTION.source, flags: SUGGESTION.flags },\n          button: BUTTON,\n        });\n        if (result.type.length)\n          fail(\"type-scale\", where, [\n            `only ${SIZES.join(\"/\")}px at weight ${WEIGHTS.join(\"/\")} are legal`,\n            ...result.type,\n          ]);\n        if (result.missing.length)\n          fail(\"corners\", where, [\n            `no fixed element ${result.inset}px in from: ${result.missing.join(\", \")}`,\n          ]);\n        else if (\n          result.mark !== null &&\n          new URL(result.mark).origin !==\n            new URL(values.home, positionals[0]).origin\n        )\n          fail(\"corners\", where, [\n            `top-left links to ${result.mark}, expected ${values.home}`,\n          ]);\n        if (result.overflow.length)\n          fail(\"overflow\", where, [\n            \"page scrolls sideways; widest elements:\",\n            ...result.overflow,\n          ]);\n        for (const text of result.copy) copy.add(text);\n      }\n      await page.close();\n    }\n  } finally {\n    await browser.close();\n  }\n  if (copy.size)\n    fail(\"copy\", \"all viewports\", [\n      \"write for the person using the page, not the developer\",\n      ...[...copy].map((text) => `\"${text}\"`),\n    ]);\n  for (const failure of failures) console.error(failure);\n  if (failures.length) process.exitCode = 1;\n  else\n    console.log(\n      `PASS ${VIEWPORTS.length} viewports: type scale, corners, no sideways scroll, copy`\n    );\n}\n\naudit().catch((error) => {\n  console.error(error.message);\n  process.exitCode = 1;\n});\n",
      "type": "registry:file",
      "target": "~/scripts/audit.mjs"
    }
  ],
  "meta": {
    "useWhen": "Starting a personal tool or a research demo in Next.js, in one command.",
    "notFor": "Existing apps; add corners and page-decode-next to them instead.",
    "related": [
      "corners",
      "page-decode-next",
      "layout"
    ]
  },
  "docs": "Use when: Starting a personal tool or a research demo: bunx shadcn@latest create -t next -n <name> https://ui.zyx.tw/r/base.json https://ui.zyx.tw/r/task.json\nNot for: Existing apps; add corners and page-decode-next to them instead.\nCheck: npx playwright install webkit, then node scripts/audit.mjs <url>\nGuide: https://ui.zyx.tw/task.md",
  "categories": [
    "block",
    "starter",
    "layout",
    "nextjs"
  ],
  "type": "registry:block"
}