@estiva-app/ui 0.46.0 → 0.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/BlockNodes.d.ts +73 -0
  2. package/dist/BlockNodes.d.ts.map +1 -0
  3. package/dist/editor.d.ts +1 -0
  4. package/dist/editor.d.ts.map +1 -1
  5. package/dist/editor.js +141 -0
  6. package/dist/editor.js.map +4 -4
  7. package/dist/gates/app-checks.d.ts.map +1 -1
  8. package/dist/gates/{chunk-P5W6O5TF.js → chunk-BS5JASHV.js} +14 -9
  9. package/dist/gates/{chunk-P5W6O5TF.js.map → chunk-BS5JASHV.js.map} +3 -3
  10. package/dist/gates/cli.js +1 -1
  11. package/dist/gates/index.js +2 -1
  12. package/dist/gates/index.js.map +2 -2
  13. package/dist/gates/status.d.ts +2 -0
  14. package/dist/gates/status.d.ts.map +1 -1
  15. package/dist/registry/{chunk-XK747STJ.js → chunk-4QWD3EBY.js} +5 -1
  16. package/dist/registry/chunk-4QWD3EBY.js.map +7 -0
  17. package/dist/registry/cli.js +4 -3
  18. package/dist/registry/cli.js.map +2 -2
  19. package/dist/registry/contract.d.ts +7 -0
  20. package/dist/registry/contract.d.ts.map +1 -1
  21. package/dist/registry/index.d.ts +1 -1
  22. package/dist/registry/index.d.ts.map +1 -1
  23. package/dist/registry/index.js +3 -1
  24. package/package.json +1 -1
  25. package/registry.json +79 -3
  26. package/skill/estiva-ui.md +14 -11
  27. package/src/BlockNodes.mdx +82 -0
  28. package/src/BlockNodes.stories.tsx +79 -0
  29. package/src/BlockNodes.test.tsx +117 -0
  30. package/src/BlockNodes.tsx +242 -0
  31. package/src/editor.ts +10 -0
  32. package/src/gates/app-checks.ts +1 -0
  33. package/src/gates/gates.test.ts +22 -0
  34. package/src/gates/status.ts +19 -8
  35. package/src/registry/cli.ts +2 -2
  36. package/src/registry/contract.test.ts +18 -2
  37. package/src/registry/contract.ts +10 -0
  38. package/src/registry/index.ts +1 -1
  39. package/src/registry/registry.test.ts +10 -8
  40. package/src/registry/skill.test.ts +2 -0
  41. package/stories/Choosing.mdx +1 -0
  42. package/dist/registry/chunk-XK747STJ.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/registry/cli.ts", "../../src/registry/siblings.ts", "../../src/registry/skill.ts", "../../src/registry/storymap.ts"],
4
- "sourcesContent": ["/// <reference types=\"node\" />\n/**\n * `estiva-ui` \u2014 the catalogue as a command (UIG-12, UIG-13; docs/GATES.md \u00A723\n * for why it ships in the package rather than as a script pasted into each repo).\n *\n * estiva-ui find <words\u2026> [--here | --also [name=]<folder>\u2026] [--json] [--limit n]\n * estiva-ui build [--out <path>]\n * estiva-ui check\n * estiva-ui skill [--out <folder>]\n *\n * Every command takes `--root <folder>` (the library it reads; default: here)\n * and `--repo <name>` (what an app's entries are called; default: its package name).\n *\n * **In the package** (`@estiva-app/ui` itself): `build` writes the committed\n * `registry.json`, and `check` rebuilds it and fails on a single byte of drift.\n *\n * **In an app**: nothing is committed (Katerina, 18 September 2026 \u2014 the\n * package is public, the apps are private). `check` builds the app's catalogue\n * and fails when a part has no one-line description or cannot be sorted, or\n * when a reusable part breaks the usage-page contract (UIG-19, `./contract`),\n * or when the app's hand-written map of its Storybook no longer matches it\n * (`./storymap`); CI's `gate` job runs it. `build` writes the catalogue to a file only when asked.\n *\n * `find` searches the package's catalogue \u2014 the one shipped inside the installed\n * package, or this repo's own in the package \u2014 plus, in an app, the app's own,\n * built fresh, plus every app beside it (UIG-20, `./siblings`): found, not\n * named, so one command answers the same from any repository, or from the\n * folder that holds them. `--here` searches no neighbour; `--also` names them.\n *\n * `skill` writes the repository's Claude skill loader (UIG-20, `./skill`), or\n * the one for `--out <folder>`; `check` fails when the repository's is missing\n * or differs.\n */\nimport { spawnSync } from 'node:child_process'\nimport { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { basename, dirname, join, relative, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { CONTRACT_KINDS, contractProblems, linkProblems, nameProblems } from './contract'\nimport { findInRegistries, formatFindings } from './find'\nimport { behindBy, findSiblings, workspaceOf } from './siblings'\nimport { loaderPath, loaderProblem, loaderText, repositoryOf, settingsPath, settingsWithSearch } from './skill'\nimport { indexHeadings, storyMapProblems } from './storymap'\nimport { CLASSES, validateRegistry, type Registry } from './schema'\n\n/**\n * The builders, loaded only when they are used.\n *\n * They read TypeScript with TypeScript, and `typescript` is a dev dependency of\n * the app that installs this package \u2014 a real one in Peek, Ship and this repo,\n * and possibly absent elsewhere. A static import made the bundler put the whole\n * builder in the same chunk as `find`, so `npx estiva-ui find \u2026` died with\n * ERR_MODULE_NOT_FOUND before opening the file it needed.\n */\nconst packageBuilder = () => import('./build')\nconst appBuilder = () => import('./app')\nconst gatedScan = () => import('./gated')\n\nconst [command, ...rest] = process.argv.slice(2)\nconst VALUED = ['--limit', '--out', '--file', '--root', '--repo', '--also']\nconst flag = (name: string) => rest.includes(`--${name}`)\nconst value = (name: string) => {\n const at = rest.indexOf(`--${name}`)\n return at === -1 ? undefined : rest[at + 1]\n}\nconst values = (name: string) => rest.flatMap((word, i) => (word === `--${name}` && rest[i + 1] !== undefined ? [rest[i + 1]] : []))\n/** Everything that is not a flag or a flag's value: the words of the question. */\nconst plain = () => {\n const out: string[] = []\n for (let i = 0; i < rest.length; i++) {\n if (rest[i].startsWith('--')) {\n if (VALUED.includes(rest[i])) i += 1\n continue\n }\n out.push(rest[i])\n }\n return out\n}\n\nconst root = resolve(value('root') ?? '.')\nconst manifestAt = (folder: string) => JSON.parse(readFileSync(resolve(folder, 'package.json'), 'utf8')) as { name?: string }\n/** The package itself, or an app that installs it. */\nconst isPackage = existsSync(resolve(root, 'package.json')) && manifestAt(root).name === '@estiva-app/ui'\n\n/** The package's committed catalogue: `--file`, this repo's own in the package, else the copy inside the installed package. */\nfunction packageRegistryPath(): string {\n const named = value('file')\n if (named) return resolve(named)\n if (isPackage) return resolve(root, 'registry.json')\n // dist/registry/cli.js \u2192 the package's own root. Never an app's own folder:\n // a registry.json there is the app's, written by `estiva-ui build`.\n return fileURLToPath(new URL('../../registry.json', import.meta.url))\n}\n\nfunction readPackageRegistry(): Registry {\n const path = packageRegistryPath()\n if (!existsSync(path)) throw new Error(`no registry.json at ${path} \u2014 run \"estiva-ui build\" in the package first`)\n const registry = JSON.parse(readFileSync(path, 'utf8')) as Registry\n const problems = validateRegistry(registry)\n // A malformed catalogue is worse than none: it would answer, wrongly.\n if (problems.length) throw new Error(`${path} does not match the schema:\\n ${problems.join('\\n ')}`)\n return registry\n}\n\n/** The installed package whose skill text a loader reads: this repo in the package, else the app's install. */\nconst packageRoot = () => (isPackage ? root : resolve(root, 'node_modules', '@estiva-app', 'ui'))\n\n/** The Claude skill loader (UIG-20): reports, and says whether it passed. */\nfunction checkLoader(): boolean {\n const problem = loaderProblem(repositoryOf(root), packageRoot())\n if (problem) {\n process.stderr.write(`claude skill: ${problem}\\n`)\n return false\n }\n process.stdout.write('claude skill: the loader reads the package\u2019s text\\n')\n return true\n}\n\nasync function buildApp(folder: string, repo: string | undefined): Promise<Registry> {\n const { buildAppRegistry } = await appBuilder()\n const registry = buildAppRegistry({ root: folder, repo })\n const problems = validateRegistry(registry)\n if (problems.length) throw new Error(`the catalogue of ${registry.builtFrom.repo} does not match its own schema:\\n ${problems.join('\\n ')}`)\n return registry\n}\n\n/**\n * Every story and docs link in a catalogue, against the Storybook beside it\n * (UIG-19). `storybook index` writes the ids Storybook itself would serve \u2014 no\n * server, no browser, seconds \u2014 so a renamed story, or a page that no longer\n * compiles, fails here rather than as a dead link somebody finds later.\n * Reports, and says whether it passed. A folder with no Storybook has nothing\n * to check.\n */\nfunction checkLinks(registry: Registry, folder: string): { ok: boolean; headings?: Set<string>; titles?: Set<string> } {\n const bin = resolve(folder, 'node_modules', '.bin', process.platform === 'win32' ? 'storybook.cmd' : 'storybook')\n if (!existsSync(resolve(folder, '.storybook')) || !existsSync(bin)) {\n process.stdout.write('story links: no Storybook here, nothing to check\\n')\n return { ok: true }\n }\n const out = join(mkdtempSync(join(tmpdir(), 'estiva-ui-index-')), 'index.json')\n // A `.cmd` needs a shell on Windows, and Node wants that as one quoted line\n // rather than an argument list. Both paths are ours: the app's folder and a temp file.\n const run =\n process.platform === 'win32'\n ? spawnSync(`\"${bin}\" index -o \"${out}\" --quiet`, { cwd: folder, encoding: 'utf8', shell: true })\n : spawnSync(bin, ['index', '-o', out, '--quiet'], { cwd: folder, encoding: 'utf8' })\n if (run.status !== 0 || !existsSync(out)) {\n process.stderr.write(`story links: Storybook could not index its stories, so no link can be trusted:\\n${(run.stderr || run.stdout || '').trim()}\\n`)\n return { ok: false }\n }\n const entries = (JSON.parse(readFileSync(out, 'utf8')) as { entries: Record<string, { title?: string }> }).entries\n const ids = new Set(Object.keys(entries))\n const headings = indexHeadings(entries)\n const titles = new Set(Object.values(entries).flatMap((e) => (e.title ? [e.title] : [])))\n const dead = linkProblems(registry, ids)\n const count = registry.entries.reduce((n, entry) => n + (entry.storyId ? 1 : 0) + (entry.docsId ? 1 : 0), 0)\n if (dead.length) {\n process.stderr.write(`story links: ${dead.length} of ${count} lead nowhere:\\n ${dead.join('\\n ')}\\n`)\n return { ok: false, headings, titles }\n }\n process.stdout.write(`story links: all ${count} open a story or docs page Storybook has\\n`)\n return { ok: true, headings, titles }\n}\n\n/**\n * What a part draws only when a prop is passed, where no story passes it\n * (UIG-19, `./gated`). Strict, by Katerina's ruling: a part's own stories show\n * everything it can draw. In an app it reads the reusable parts; in the package,\n * every component (`kinds` is the package's one class, `component`).\n */\nasync function checkGated(registry: Registry, folder: string, kinds?: string[]): Promise<boolean> {\n const { gatedFindings } = await gatedScan()\n const found = gatedFindings(registry, folder, { ...(kinds ? { kinds } : {}), pictured: 'own' })\n if (found.length) {\n const lines = found.map((f) => `${f.part} (${f.file}) draws something only when given \\`${f.prop}\\`, and no story that draws it passes \\`${f.prop}\\`: pass it in a story`)\n process.stderr.write(`stories: ${found.length === 1 ? 'one thing a part draws is' : `${found.length} things parts draw are`} never shown:\\n ${lines.join('\\n ')}\\n`)\n return false\n }\n process.stdout.write('stories: everything a part draws behind a prop is shown by a story\\n')\n return true\n}\n\n/**\n * The repository's hand-written map of its Storybook \u2014 the heading order and the\n * Introduction \u2014 against the Storybook (its own index, when there is one) and,\n * in an app, the catalogue (`./storymap`). Reports, and says whether it passed.\n */\nfunction checkStoryMap(folder: string, registry?: Registry, headings?: Set<string>): boolean {\n const problems = storyMapProblems(folder, { ...(registry ? { registry } : {}), ...(headings ? { real: headings } : {}) })\n if (problems.length) {\n process.stderr.write(`storybook map: ${problems.length === 1 ? 'one line no longer matches' : `${problems.length} lines no longer match`}:\\n ${problems.join('\\n ')}\\n`)\n return false\n }\n process.stdout.write('storybook map: the heading order and the Introduction match the Storybook and the catalogue\\n')\n return true\n}\n\n/** One line per kind, in a fixed order, so two runs read the same. */\nfunction summary(registry: Registry): string {\n const count = (cls: string) => registry.entries.filter((entry) => entry.app?.class === cls).length\n const kinds = CLASSES.map((cls) => `${count(cls)} ${cls}`).join(', ')\n const files = registry.builtFrom.files ?? 0\n return `${registry.builtFrom.repo}: ${registry.entries.length} parts in ${files - registry.filesWithoutParts.length} files (${registry.filesWithoutParts.length} more hold none) \u2014 ${kinds}. Every part is described and sorted.`\n}\n\nasync function main(): Promise<number> {\n switch (command) {\n case 'find': {\n const query = plain().join(' ')\n if (!query.trim()) {\n process.stderr.write('estiva-ui find <words\u2026> \u2014 what the thing you need does, in words\\n')\n return 1\n }\n const registries: Registry[] = [readPackageRegistry()]\n // An app that cannot be read is said out loud, and the rest still answer.\n const add = async (folder: string, repo: string | undefined) => {\n const behind = behindBy(folder)\n if (behind) process.stderr.write(`note: ${repo ?? basename(folder)} (${folder}) is ${behind} commit${behind === 1 ? '' : 's'} behind main as last fetched \u2014 its answers may name parts that are gone; pull it\\n`)\n try {\n registries.push(await buildApp(folder, repo))\n } catch (error) {\n const [first, ...more] = String(error instanceof Error ? error.message : error).split('\\n')\n process.stderr.write(`not searched: ${first}${more.length ? `\\n${more.slice(0, 3).join('\\n')}${more.length > 3 ? `\\n \u2026and ${more.length - 3} more \u2014 run \"estiva-ui check\" there` : ''}` : ''}\\n`)\n }\n }\n // The folder it runs in is searched when it is an app; the folder that\n // holds the repositories is not one, and only its neighbours answer.\n const here = !isPackage && existsSync(resolve(root, 'package.json')) ? (manifestAt(root).name ?? basename(root)) : null\n if (here) await add(root, value('repo'))\n if (!values('also').length && !flag('here')) {\n for (const sibling of findSiblings(workspaceOf(root), { skip: here ? [here] : [] })) await add(sibling.folder, sibling.name)\n }\n for (const also of values('also')) {\n const [name, folder] = also.includes('=') ? [also.slice(0, also.indexOf('=')), also.slice(also.indexOf('=') + 1)] : [undefined, also]\n const at = resolve(root, folder)\n if (!existsSync(resolve(at, 'package.json'))) {\n process.stderr.write(`not searched: ${name ?? basename(at)} \u2014 nothing at ${at}\\n`)\n continue\n }\n await add(at, name)\n }\n const limit = Number(value('limit') ?? 5)\n const findings = findInRegistries(registries, query, { limit: Number.isFinite(limit) && limit > 0 ? limit : 5 })\n if (flag('json')) {\n process.stdout.write(`${JSON.stringify(findings.map((finding) => finding.entry), null, 2)}\\n`)\n return 0\n }\n process.stdout.write(`${formatFindings(registries, findings, query)}\\n`)\n // Nothing found is not a failure \u2014 it is the answer that sends a session\n // to ask rather than to invent.\n return 0\n }\n\n case 'build': {\n const out = resolve(root, value('out') ?? 'registry.json')\n if (isPackage) {\n const { buildRegistry, serializeRegistry } = await packageBuilder()\n const registry = buildRegistry({ root })\n const problems = validateRegistry(registry)\n if (problems.length) {\n process.stderr.write(`the registry this build produced does not match its own schema:\\n ${problems.join('\\n ')}\\n`)\n return 1\n }\n writeFileSync(out, serializeRegistry(registry), 'utf8')\n process.stdout.write(`${out}: ${registry.entries.length} entries from ${registry.builtFrom.exports} exports\\n`)\n return 0\n }\n const { serializeRegistry } = await packageBuilder()\n const registry = await buildApp(root, value('repo'))\n writeFileSync(out, serializeRegistry(registry), 'utf8')\n process.stdout.write(`${out}: ${summary(registry)}\\n`)\n return 0\n }\n\n case 'check': {\n if (!isPackage) {\n const registry = await buildApp(root, value('repo'))\n process.stdout.write(`${summary(registry)}\\n`)\n // The usage-page contract and the story links (UIG-19): the one copy, run by every app's `gate` job.\n // A When not may name a part of the package or of this app (B8).\n const pkg = readPackageRegistry()\n const known = new Set([...pkg.entries, ...registry.entries].map((e) => e.name))\n const broken = contractProblems(registry, root, known)\n if (broken.length) {\n process.stderr.write(`${broken.length === 1 ? 'a part breaks' : `${broken.length} parts break`} the usage-page contract:\\n ${broken.join('\\n ')}\\n`)\n } else {\n const owed = registry.entries.filter((entry) => (CONTRACT_KINDS as readonly string[]).includes(entry.app?.class ?? '')).length\n process.stdout.write(`usage pages: all ${owed} reusable parts keep the contract and are drawn somewhere\\n`)\n }\n const linked = checkLinks(registry, root)\n const shown = await checkGated(registry, root)\n const loaded = checkLoader()\n const mapped = checkStoryMap(root, registry, linked.headings)\n // What the pages name must still be there (R14): parts under When and When not,\n // and the stories a Seen in line sends a reader to, here or in the package.\n const stale = nameProblems(registry, root, {\n known,\n ...(linked.titles ? { titles: linked.titles } : {}),\n packageIds: pkg.entries.flatMap((e) => [e.storyId, e.docsId].filter((id): id is string => Boolean(id))),\n })\n if (stale.length) process.stderr.write(`usage pages: ${stale.length === 1 ? 'one name leads' : `${stale.length} names lead`} nowhere:\\n ${stale.join('\\n ')}\\n`)\n else process.stdout.write('usage pages: every part and story they name is there\\n')\n return broken.length || stale.length || !linked.ok || !shown || !loaded || !mapped ? 1 : 0\n }\n const { buildRegistry, serializeRegistry } = await packageBuilder()\n const path = packageRegistryPath()\n const built = buildRegistry({ root })\n const problems = validateRegistry(built)\n if (problems.length) {\n process.stderr.write(`the registry does not match its own schema:\\n ${problems.join('\\n ')}\\n`)\n return 1\n }\n if (!existsSync(path)) {\n process.stderr.write(`${path} is missing \u2014 run \"npm run registry\"\\n`)\n return 1\n }\n // Byte for byte. The point of the check is that the committed file cannot\n // drift from the code; \"near enough\" is drift.\n if (readFileSync(path, 'utf8').replace(/\\r\\n/g, '\\n') !== serializeRegistry(built)) {\n process.stderr.write(`${path} is not what the code produces \u2014 run \"npm run registry\" and commit the result\\n`)\n return 1\n }\n process.stdout.write(`${path}: current, ${built.entries.length} entries from ${built.builtFrom.exports} exports\\n`)\n const linked = checkLinks(built, root)\n const shown = await checkGated(built, root, ['component'])\n const loaded = checkLoader()\n // The package keeps a heading order too (R16): it left out Layout, and nothing saw.\n const mapped = checkStoryMap(root, undefined, linked.headings)\n return linked.ok && shown && loaded && mapped ? 0 : 1\n }\n\n case 'skill': {\n const out = value('out')\n const folder = out ? resolve(out) : repositoryOf(root)\n // The loader's path starts where the session does and cannot climb out:\n // Claude Code refuses a `..` in it.\n if (relative(folder, packageRoot()).startsWith('..')) {\n process.stderr.write(`${folder} does not hold ${packageRoot()}: a loader there could not reach the skill's text\\n`)\n return 1\n }\n const path = loaderPath(folder)\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, loaderText(folder, packageRoot()), 'utf8')\n process.stdout.write(`${path}: the Claude skill, read from ${packageRoot()}\\n`)\n const settings = settingsWithSearch(folder)\n if (settings) {\n writeFileSync(settingsPath(folder), settings, 'utf8')\n process.stdout.write(`${settingsPath(folder)}: the search allowed without a prompt\\n`)\n }\n return 0\n }\n\n default:\n process.stderr.write('estiva-ui <find | build | check | skill>\\n')\n return 1\n }\n}\n\ntry {\n process.exitCode = await main()\n} catch (error) {\n process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`)\n process.exitCode = 1\n}\n", "/// <reference types=\"node\" />\n/**\n * The apps beside this one, found rather than named (UIG-20).\n *\n * `estiva-ui find` with nothing else typed searches the package, the app it is\n * run in, and every app that sits beside it. Katerina's condition for having no\n * shared Storybook is that one search, run unasked from any repository, covers\n * every catalogue; a list of names written into each repository's script would\n * be the drifting copy the gates exist to remove, and would miss the next app.\n *\n * An app is a folder, or one folder inside it, whose `package.json` depends on\n * `@estiva-app/ui` and which has a `src` to read. A service that does not\n * install the package is not an app of this catalogue until it does.\n *\n * Each app is searched once. A second checkout of the same app (a worktree, or\n * somebody's copy) carries the same package name; the app the search runs in\n * wins, then the one whose top folder has the shortest name.\n */\nimport { execFileSync } from 'node:child_process'\nimport { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'\nimport { basename, dirname, join, resolve } from 'node:path'\n\nexport const PACKAGE_NAME = '@estiva-app/ui'\n\nexport interface Sibling {\n /** What its entries are called: its top folder's name. */\n name: string\n /** The folder the catalogue is built from. */\n folder: string\n /** Its `package.json` name, which says two checkouts are one app. */\n packageName: string\n}\n\nfunction manifest(folder: string): { name?: string; dependencies?: Record<string, string>; devDependencies?: Record<string, string> } | null {\n const file = join(folder, 'package.json')\n if (!existsSync(file)) return null\n try {\n return JSON.parse(readFileSync(file, 'utf8'))\n } catch {\n return null\n }\n}\n\n/** The name of the app in `folder`, or null when the folder is not one. */\nexport function appName(folder: string): string | null {\n const m = manifest(folder)\n if (!m || m.name === PACKAGE_NAME) return null\n const uses = Boolean(m.dependencies?.[PACKAGE_NAME] ?? m.devDependencies?.[PACKAGE_NAME])\n return uses && existsSync(join(folder, 'src')) ? (m.name ?? basename(folder)) : null\n}\n\nconst isDir = (path: string) => {\n try {\n return statSync(path).isDirectory()\n } catch {\n return false\n }\n}\n\n/**\n * The folder that holds the repositories: the parent of the repository `from`\n * is in, or `from` itself when it is in none (a folder that only holds them).\n */\nexport function workspaceOf(from: string): string {\n let at = resolve(from)\n for (;;) {\n if (existsSync(join(at, '.git'))) return dirname(at)\n const up = dirname(at)\n if (up === at) return resolve(from)\n at = up\n }\n}\n\n/** Every app in `workspace`, one per package name, except those named in `skip`. */\nexport function findSiblings(workspace: string, { skip = [] }: { skip?: string[] } = {}): Sibling[] {\n let tops: string[]\n try {\n tops = readdirSync(workspace).filter((name) => !name.startsWith('.') && name !== 'node_modules' && isDir(join(workspace, name)))\n } catch {\n return []\n }\n const found: Sibling[] = []\n for (const top of tops) {\n const folder = join(workspace, top)\n const inside = readdirSync(folder).filter((name) => !name.startsWith('.') && name !== 'node_modules' && isDir(join(folder, name)))\n for (const candidate of [folder, ...inside.map((name) => join(folder, name))]) {\n const packageName = appName(candidate)\n if (packageName) found.push({ name: top, folder: candidate, packageName })\n }\n }\n const byPackage = new Map<string, Sibling>()\n for (const sibling of found.sort((a, b) => a.name.length - b.name.length || a.name.localeCompare(b.name))) {\n if (skip.includes(sibling.packageName) || byPackage.has(sibling.packageName)) continue\n byPackage.set(sibling.packageName, sibling)\n }\n return [...byPackage.values()].sort((a, b) => a.name.localeCompare(b.name))\n}\n\n/**\n * How many commits the checkout that holds `folder` is behind its remote's main,\n * as last fetched: nothing is fetched, so a search stays quick. Null when it is\n * not a git checkout or has no remote main. A search that reads a stale copy\n * answers with parts that are gone (the re-review after the audit before UIG-26:\n * \"files panel\" found Peek's deleted FilesPanel in an old checkout), so `find`\n * says so beside its answer.\n */\nexport function behindBy(folder: string): number | null {\n const git = (...a: string[]) => {\n try {\n return execFileSync('git', ['-C', folder, ...a], { stdio: ['ignore', 'pipe', 'ignore'], timeout: 10000 }).toString().trim()\n } catch {\n return null\n }\n }\n const main = git('symbolic-ref', '--short', 'refs/remotes/origin/HEAD') ?? (git('rev-parse', '--verify', '--quiet', 'origin/main') ? 'origin/main' : null)\n if (!main) return null\n const count = Number(git('rev-list', '--count', `HEAD..${main}`))\n return Number.isFinite(count) ? count : null\n}\n", "/// <reference types=\"node\" />\n/**\n * The Claude skill (UIG-20): search the catalogue before building anything.\n *\n * Its text lives once, in this package, as `skill/estiva-ui.md` (Katerina,\n * 17 September 2026: the same gate text pasted into two repositories is a\n * defect). Claude Code only loads a skill from a `SKILL.md` under a folder's\n * `.claude/skills/`, and no plugin source can point into `node_modules`, so each\n * repository commits a loader: the trigger below, and one line that reads the\n * installed package's text into the skill when it opens (`` !`\u2026` `` runs before\n * Claude sees the skill). `estiva-ui skill` writes it; `estiva-ui check` fails\n * when a repository's loader is missing or is not what this writes.\n *\n * Measured with fresh sessions of Claude Code 2.1.215 (UIG-20), three things\n * shape that line and the settings beside it:\n *\n * - An injected command runs without a prompt only when Claude Code can read it\n * statically as read-only: a plain `cat` of a plain path. A path with `..`\n * (\"may follow a symlink outside the working directory\"), a `$(\u2026)`, or a\n * `node -e` are all refused, and a refused command stops the skill opening.\n * So the path starts at `${CLAUDE_PROJECT_DIR}`, the folder the session\n * started in, as the editor gate's hook does: a session started above or\n * below the repository gets neither.\n * - An `allowed-tools` line makes opening the skill itself ask for permission\n * (\"Execute skill\"). So the search is allowed in the repository's committed\n * `.claude/settings.json` instead, and the skill carries no `allowed-tools`.\n * - Claude reads a skill's description before it opens the skill, so the\n * trigger is written into the loader; it is the one part that cannot be\n * pulled in later.\n */\nimport { existsSync, readFileSync } from 'node:fs'\nimport { dirname, join, relative, resolve, sep } from 'node:path'\n\nexport const SKILL_NAME = 'estiva-ui'\n\n/** When Claude opens the skill by itself. Kept under Claude Code's 1,536 characters. */\nexport const SKILL_DESCRIPTION =\n 'Use before building, adding or changing anything on screen in an app that uses @estiva-app/ui, or in @estiva-app/ui itself: ' +\n 'a screen, panel, list, row, header, dialog, menu, empty state, a new component, or how something looks. ' +\n 'Also when someone asks for a component in plain words (\"I need a\u2026\", \"add a\u2026\", \"is there a\u2026\"). ' +\n \"It searches every catalogue at once, the package's and each app's Storybook, for a part that already does the job, \" +\n 'and lists the mistakes this codebase keeps making.'\n\n/** The search, allowed without a prompt in the folder's committed `.claude/settings.json`. */\nexport const SEARCH_RULES = ['Bash(npm run ui:find *)', 'Bash(npm --prefix * run ui:find *)', 'PowerShell(npm run ui:find *)', 'PowerShell(npm --prefix * run ui:find *)']\n\n/** The skill's text, inside a package folder. */\nexport const skillTextPath = (packageRoot: string) => join(packageRoot, 'skill', `${SKILL_NAME}.md`)\n\n/** Where a folder keeps its loader. */\nexport const loaderPath = (folder: string) => join(folder, '.claude', 'skills', SKILL_NAME, 'SKILL.md')\n\n/** Where a folder keeps the settings that allow the search. */\nexport const settingsPath = (folder: string) => join(folder, '.claude', 'settings.json')\n\n/** The loader for `folder`, reading the text from `packageRoot`, from where a session in `folder` starts. */\nexport function loaderText(folder: string, packageRoot: string): string {\n const fromTop = relative(folder, skillTextPath(packageRoot)).split(sep).join('/')\n return [\n '---',\n `name: ${SKILL_NAME}`,\n `description: ${JSON.stringify(SKILL_DESCRIPTION)}`,\n '---',\n '',\n '<!-- Written by `estiva-ui skill` from @estiva-app/ui; `estiva-ui check` fails when it differs. The text is the installed package\u2019s, read in below. -->',\n '',\n `!\\`cat \"\\${CLAUDE_PROJECT_DIR}/${fromTop}\"\\``,\n '',\n ].join('\\n')\n}\n\ntype Settings = { permissions?: { allow?: string[] } & Record<string, unknown> } & Record<string, unknown>\n\nconst readSettings = (folder: string): Settings | null => {\n const path = settingsPath(folder)\n if (!existsSync(path)) return {}\n try {\n return JSON.parse(readFileSync(path, 'utf8')) as Settings\n } catch {\n return null\n }\n}\n\n/** `folder`'s settings with the search allowed, everything else as it was; null when they cannot be read. */\nexport function settingsWithSearch(folder: string): string | null {\n const settings = readSettings(folder)\n if (!settings) return null\n const allow = settings.permissions?.allow ?? []\n const missing = SEARCH_RULES.filter((rule) => !allow.includes(rule))\n if (!missing.length && existsSync(settingsPath(folder))) return null\n settings.permissions = { ...settings.permissions, allow: [...allow, ...missing] }\n return `${JSON.stringify(settings, null, 2)}\\n`\n}\n\n/** The repository `from` is in: the nearest folder with `.git`, or `from` when there is none. */\nexport function repositoryOf(from: string): string {\n let at = resolve(from)\n for (;;) {\n if (existsSync(join(at, '.git'))) return at\n const up = dirname(at)\n if (up === at) return resolve(from)\n at = up\n }\n}\n\n/** What is wrong with `folder`'s loader, or null when it is what `loaderText` writes. */\nexport function loaderProblem(folder: string, packageRoot: string): string | null {\n const path = loaderPath(folder)\n const shown = relative(process.cwd(), path).split(sep).join('/') || path\n if (!existsSync(path)) return `${shown} is missing: run \"estiva-ui skill\" and commit it`\n if (readFileSync(path, 'utf8').replace(/\\r\\n/g, '\\n') !== loaderText(folder, packageRoot)) return `${shown} is not what the package writes: run \"estiva-ui skill\" and commit it`\n if (!existsSync(skillTextPath(packageRoot))) return `${shown} reads ${skillTextPath(packageRoot)}, which is not there`\n const allow = readSettings(folder)?.permissions?.allow ?? []\n const missing = SEARCH_RULES.filter((rule) => !allow.includes(rule))\n if (missing.length) return `.claude/settings.json does not allow the search (${missing.join(', ')}): run \"estiva-ui skill\" and commit it`\n return null\n}\n", "/// <reference types=\"node\" />\n/**\n * The hand-written map of a Storybook, held against the Storybook it describes\n * (moved here from Peek's own status checks, audit A3; widened by the re-review\n * after it, R16).\n *\n * A repository may keep two maps of its sidebar: the order of its top-level\n * headings in `.storybook/preview.tsx` \u2014 a `const HEADINGS = [...]` list read by\n * a `storySort` function (Peek), or `storySort: { order: [...] }` (Ship, this\n * package) \u2014 and the Introduction page, which names each heading, in a table row\n * (`| **Folders** | \u2026 |`, Peek) or a bullet (`- **Primitives \u00B7 Inputs** \u2014 \u2026`,\n * Ship), and in an app states how many parts are worth reusing. Both are written\n * by hand and both describe something that moves, so both rot: Peek's named a\n * Huddles heading for a day after its stories were deleted and said 49 reusable\n * parts when the catalogue built 41; Ship's named a Feedback heading it does not\n * have and left out four it does.\n *\n * The real headings are read from Storybook's own index when the command has\n * one, so a title written any way at all counts; otherwise from the story files.\n * Every check runs only when the repository states the thing it checks.\n */\nimport { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport type { Registry } from './schema'\n\nconst PREVIEW = '.storybook/preview.tsx'\nconst INTRODUCTIONS = ['src/stories/Introduction.mdx', 'stories/Introduction.mdx']\n/** The classes an app's Introduction counts as \"worth reusing\". */\nconst WORTH_REUSING = ['reusable', 'promote-candidate']\n\nfunction storyFiles(root: string): string[] {\n const out: string[] = []\n const walk = (dir: string) => {\n if (!existsSync(dir)) return\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue\n const path = join(dir, entry.name)\n if (entry.isDirectory()) walk(path)\n else if (entry.name.endsWith('.stories.tsx') || entry.name.endsWith('.mdx')) out.push(path)\n }\n }\n walk(join(root, 'src'))\n walk(join(root, 'stories'))\n return out\n}\n\n/** Every top-level heading the sidebar has, read from the story files: the first segment of each title. */\nexport function sidebarHeadings(root: string): Set<string> {\n const real = new Set<string>()\n for (const file of storyFiles(root)) {\n const text = readFileSync(file, 'utf8')\n const start = text.indexOf('const meta')\n const meta = start === -1 ? '' : text.slice(start, text.indexOf('satisfies Meta', start) + 1 || undefined)\n const title = meta.match(/\\btitle: *['\"]([^'\"]+)['\"]/) ?? text.match(/<Meta\\s+title=['\"]([^'\"]+)['\"]/)\n if (title) real.add(title[1].split('/')[0].trim())\n }\n return real\n}\n\n/** The top-level headings of Storybook's own index (`storybook index`): the first segment of every entry's title. */\nexport function indexHeadings(entries: Record<string, { title?: string }>): Set<string> {\n return new Set(Object.values(entries).flatMap((e) => (e.title ? [e.title.split('/')[0].trim()] : [])))\n}\n\n/** The strings at the top level of the array that starts at `open` (the index of its `[`), skipping nested arrays. */\nfunction topLevelStrings(text: string, open: number): string[] {\n const out: string[] = []\n let depth = 0\n for (let i = open; i < text.length; i++) {\n const c = text[i]\n if (c === '/' && text[i + 1] === '*') {\n const end = text.indexOf('*/', i + 2)\n if (end < 0) break\n i = end + 1\n } else if (c === '/' && text[i + 1] === '/') i = text.indexOf('\\n', i)\n else if (c === '[') depth++\n else if (c === ']') {\n if (--depth === 0) return out\n } else if (c === \"'\" || c === '\"') {\n const end = text.indexOf(c, i + 1)\n if (depth === 1) out.push(text.slice(i + 1, end))\n i = end\n }\n if (i < 0) break\n }\n return out\n}\n\n/** The headings the preview orders \u2014 a `HEADINGS` list or `storySort: { order: [...] }` \u2014 or null when it keeps no order. */\nexport function orderedHeadings(previewText: string): string[] | null {\n const list = /const HEADINGS = \\[/.exec(previewText) ?? /\\border:\\s*\\[/.exec(previewText)\n if (!list) return null\n return topLevelStrings(previewText, list.index + list[0].length - 1)\n}\n\n/**\n * The headings the Introduction names: a table row that opens with a bold name,\n * or a bullet that opens with bold names joined by \" \u00B7 \".\n */\nexport function introductionHeadings(introText: string): Set<string> {\n const rows = [...introText.matchAll(/^\\|\\s*\\*\\*([^*]+)\\*\\*\\s*\\|/gm)].map((m) => m[1])\n const bullets = [...introText.matchAll(/^[-*]\\s+\\*\\*([^*]+)\\*\\*\\s*[\u2014\u2013-]/gm)].flatMap((m) => m[1].split('\u00B7'))\n return new Set([...rows, ...bullets].map((h) => h.trim()).filter(Boolean))\n}\n\n/** The number the Introduction states, or null when it states none. */\nexport function introductionCount(introText: string): number | null {\n const said = introText.match(/\\*\\*(\\d+) parts worth reusing\\*\\*/)\n return said ? Number(said[1]) : null\n}\n\n/**\n * What is wrong with the repository's hand-written map of its Storybook; empty\n * when nothing is. `real` is the sidebar's top-level headings from Storybook's\n * index, when the caller has it; `registry` is needed only for an app's count.\n */\nexport function storyMapProblems(root: string, { registry, real = sidebarHeadings(root) }: { registry?: Registry; real?: Set<string> } = {}): string[] {\n const problems: string[] = []\n const previewPath = join(root, PREVIEW)\n if (existsSync(previewPath)) {\n const ordered = orderedHeadings(readFileSync(previewPath, 'utf8'))\n if (ordered) {\n const unordered = [...real].filter((r) => !ordered.includes(r))\n const empty = ordered.filter((o) => !real.has(o))\n if (unordered.length) problems.push(`${PREVIEW}: not in the heading order, so they fall to the bottom of the sidebar: ${unordered.join(', ')}`)\n if (empty.length) problems.push(`${PREVIEW}: in the heading order but no story uses them: ${empty.join(', ')}`)\n }\n }\n const intro = INTRODUCTIONS.find((p) => existsSync(join(root, p)))\n if (intro) {\n const text = readFileSync(join(root, intro), 'utf8')\n const named = introductionHeadings(text)\n if (named.size) {\n const missing = [...real].filter((r) => !named.has(r))\n const stale = [...named].filter((n) => !real.has(n))\n if (missing.length) problems.push(`${intro}: the sidebar has, the page does not name: ${missing.join(', ')}`)\n if (stale.length) problems.push(`${intro}: the page names, the sidebar does not have: ${stale.join(', ')}`)\n }\n const said = introductionCount(text)\n if (said !== null && registry) {\n const reusable = registry.entries.filter((entry) => WORTH_REUSING.includes(entry.app?.class ?? '')).length\n if (said !== reusable) problems.push(`${intro}: says ${said} parts worth reusing; the catalogue builds ${reusable}`)\n }\n }\n return problems\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;AAiCA,SAAS,iBAAiB;AAC1B,SAAS,cAAAA,aAAY,WAAW,aAAa,gBAAAC,eAAc,qBAAqB;AAChF,SAAS,cAAc;AACvB,SAAS,YAAAC,WAAU,WAAAC,UAAS,QAAAC,OAAM,YAAAC,WAAU,WAAAC,gBAAe;AAC3D,SAAS,qBAAqB;;;ACnB9B,SAAS,oBAAoB;AAC7B,SAAS,YAAY,aAAa,cAAc,gBAAgB;AAChE,SAAS,UAAU,SAAS,MAAM,eAAe;AAE1C,IAAM,eAAe;AAW5B,SAAS,SAAS,QAA2H;AAC3I,QAAM,OAAO,KAAK,QAAQ,cAAc;AACxC,MAAI,CAAC,WAAW,IAAI,EAAG,QAAO;AAC9B,MAAI;AACF,WAAO,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;AAAA,EAC9C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAGO,SAAS,QAAQ,QAA+B;AACrD,QAAM,IAAI,SAAS,MAAM;AACzB,MAAI,CAAC,KAAK,EAAE,SAAS,aAAc,QAAO;AAC1C,QAAM,OAAO,QAAQ,EAAE,eAAe,YAAY,KAAK,EAAE,kBAAkB,YAAY,CAAC;AACxF,SAAO,QAAQ,WAAW,KAAK,QAAQ,KAAK,CAAC,IAAK,EAAE,QAAQ,SAAS,MAAM,IAAK;AAClF;AAEA,IAAM,QAAQ,CAAC,SAAiB;AAC9B,MAAI;AACF,WAAO,SAAS,IAAI,EAAE,YAAY;AAAA,EACpC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAMO,SAAS,YAAY,MAAsB;AAChD,MAAI,KAAK,Q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package rather than as a script pasted into each repo).\n *\n * estiva-ui find <words\u2026> [--here | --also [name=]<folder>\u2026] [--json] [--limit n]\n * estiva-ui build [--out <path>]\n * estiva-ui check\n * estiva-ui skill [--out <folder>]\n *\n * Every command takes `--root <folder>` (the library it reads; default: here)\n * and `--repo <name>` (what an app's entries are called; default: its package name).\n *\n * **In the package** (`@estiva-app/ui` itself): `build` writes the committed\n * `registry.json`, and `check` rebuilds it and fails on a single byte of drift.\n *\n * **In an app**: nothing is committed (Katerina, 18 September 2026 \u2014 the\n * package is public, the apps are private). `check` builds the app's catalogue\n * and fails when a part has no one-line description or cannot be sorted, or\n * when a reusable part breaks the usage-page contract (UIG-19, `./contract`),\n * or when the app's hand-written map of its Storybook no longer matches it\n * (`./storymap`); CI's `gate` job runs it. `build` writes the catalogue to a file only when asked.\n *\n * `find` searches the package's catalogue \u2014 the one shipped inside the installed\n * package, or this repo's own in the package \u2014 plus, in an app, the app's own,\n * built fresh, plus every app beside it (UIG-20, `./siblings`): found, not\n * named, so one command answers the same from any repository, or from the\n * folder that holds them. `--here` searches no neighbour; `--also` names them.\n *\n * `skill` writes the repository's Claude skill loader (UIG-20, `./skill`), or\n * the one for `--out <folder>`; `check` fails when the repository's is missing\n * or differs.\n */\nimport { spawnSync } from 'node:child_process'\nimport { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs'\nimport { tmpdir } from 'node:os'\nimport { basename, dirname, join, relative, resolve } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport { CONTRACT_KINDS, contractProblems, linkProblems, nameableParts, nameProblems } from './contract'\nimport { findInRegistries, formatFindings } from './find'\nimport { behindBy, findSiblings, workspaceOf } from './siblings'\nimport { loaderPath, loaderProblem, loaderText, repositoryOf, settingsPath, settingsWithSearch } from './skill'\nimport { indexHeadings, storyMapProblems } from './storymap'\nimport { CLASSES, validateRegistry, type Registry } from './schema'\n\n/**\n * The builders, loaded only when they are used.\n *\n * They read TypeScript with TypeScript, and `typescript` is a dev dependency of\n * the app that installs this package \u2014 a real one in Peek, Ship and this repo,\n * and possibly absent elsewhere. A static import made the bundler put the whole\n * builder in the same chunk as `find`, so `npx estiva-ui find \u2026` died with\n * ERR_MODULE_NOT_FOUND before opening the file it needed.\n */\nconst packageBuilder = () => import('./build')\nconst appBuilder = () => import('./app')\nconst gatedScan = () => import('./gated')\n\nconst [command, ...rest] = process.argv.slice(2)\nconst VALUED = ['--limit', '--out', '--file', '--root', '--repo', '--also']\nconst flag = (name: string) => rest.includes(`--${name}`)\nconst value = (name: string) => {\n const at = rest.indexOf(`--${name}`)\n return at === -1 ? undefined : rest[at + 1]\n}\nconst values = (name: string) => rest.flatMap((word, i) => (word === `--${name}` && rest[i + 1] !== undefined ? [rest[i + 1]] : []))\n/** Everything that is not a flag or a flag's value: the words of the question. */\nconst plain = () => {\n const out: string[] = []\n for (let i = 0; i < rest.length; i++) {\n if (rest[i].startsWith('--')) {\n if (VALUED.includes(rest[i])) i += 1\n continue\n }\n out.push(rest[i])\n }\n return out\n}\n\nconst root = resolve(value('root') ?? '.')\nconst manifestAt = (folder: string) => JSON.parse(readFileSync(resolve(folder, 'package.json'), 'utf8')) as { name?: string }\n/** The package itself, or an app that installs it. */\nconst isPackage = existsSync(resolve(root, 'package.json')) && manifestAt(root).name === '@estiva-app/ui'\n\n/** The package's committed catalogue: `--file`, this repo's own in the package, else the copy inside the installed package. */\nfunction packageRegistryPath(): string {\n const named = value('file')\n if (named) return resolve(named)\n if (isPackage) return resolve(root, 'registry.json')\n // dist/registry/cli.js \u2192 the package's own root. Never an app's own folder:\n // a registry.json there is the app's, written by `estiva-ui build`.\n return fileURLToPath(new URL('../../registry.json', import.meta.url))\n}\n\nfunction readPackageRegistry(): Registry {\n const path = packageRegistryPath()\n if (!existsSync(path)) throw new Error(`no registry.json at ${path} \u2014 run \"estiva-ui build\" in the package first`)\n const registry = JSON.parse(readFileSync(path, 'utf8')) as Registry\n const problems = validateRegistry(registry)\n // A malformed catalogue is worse than none: it would answer, wrongly.\n if (problems.length) throw new Error(`${path} does not match the schema:\\n ${problems.join('\\n ')}`)\n return registry\n}\n\n/** The installed package whose skill text a loader reads: this repo in the package, else the app's install. */\nconst packageRoot = () => (isPackage ? root : resolve(root, 'node_modules', '@estiva-app', 'ui'))\n\n/** The Claude skill loader (UIG-20): reports, and says whether it passed. */\nfunction checkLoader(): boolean {\n const problem = loaderProblem(repositoryOf(root), packageRoot())\n if (problem) {\n process.stderr.write(`claude skill: ${problem}\\n`)\n return false\n }\n process.stdout.write('claude skill: the loader reads the package\u2019s text\\n')\n return true\n}\n\nasync function buildApp(folder: string, repo: string | undefined): Promise<Registry> {\n const { buildAppRegistry } = await appBuilder()\n const registry = buildAppRegistry({ root: folder, repo })\n const problems = validateRegistry(registry)\n if (problems.length) throw new Error(`the catalogue of ${registry.builtFrom.repo} does not match its own schema:\\n ${problems.join('\\n ')}`)\n return registry\n}\n\n/**\n * Every story and docs link in a catalogue, against the Storybook beside it\n * (UIG-19). `storybook index` writes the ids Storybook itself would serve \u2014 no\n * server, no browser, seconds \u2014 so a renamed story, or a page that no longer\n * compiles, fails here rather than as a dead link somebody finds later.\n * Reports, and says whether it passed. A folder with no Storybook has nothing\n * to check.\n */\nfunction checkLinks(registry: Registry, folder: string): { ok: boolean; headings?: Set<string>; titles?: Set<string> } {\n const bin = resolve(folder, 'node_modules', '.bin', process.platform === 'win32' ? 'storybook.cmd' : 'storybook')\n if (!existsSync(resolve(folder, '.storybook')) || !existsSync(bin)) {\n process.stdout.write('story links: no Storybook here, nothing to check\\n')\n return { ok: true }\n }\n const out = join(mkdtempSync(join(tmpdir(), 'estiva-ui-index-')), 'index.json')\n // A `.cmd` needs a shell on Windows, and Node wants that as one quoted line\n // rather than an argument list. Both paths are ours: the app's folder and a temp file.\n const run =\n process.platform === 'win32'\n ? spawnSync(`\"${bin}\" index -o \"${out}\" --quiet`, { cwd: folder, encoding: 'utf8', shell: true })\n : spawnSync(bin, ['index', '-o', out, '--quiet'], { cwd: folder, encoding: 'utf8' })\n if (run.status !== 0 || !existsSync(out)) {\n process.stderr.write(`story links: Storybook could not index its stories, so no link can be trusted:\\n${(run.stderr || run.stdout || '').trim()}\\n`)\n return { ok: false }\n }\n const entries = (JSON.parse(readFileSync(out, 'utf8')) as { entries: Record<string, { title?: string }> }).entries\n const ids = new Set(Object.keys(entries))\n const headings = indexHeadings(entries)\n const titles = new Set(Object.values(entries).flatMap((e) => (e.title ? [e.title] : [])))\n const dead = linkProblems(registry, ids)\n const count = registry.entries.reduce((n, entry) => n + (entry.storyId ? 1 : 0) + (entry.docsId ? 1 : 0), 0)\n if (dead.length) {\n process.stderr.write(`story links: ${dead.length} of ${count} lead nowhere:\\n ${dead.join('\\n ')}\\n`)\n return { ok: false, headings, titles }\n }\n process.stdout.write(`story links: all ${count} open a story or docs page Storybook has\\n`)\n return { ok: true, headings, titles }\n}\n\n/**\n * What a part draws only when a prop is passed, where no story passes it\n * (UIG-19, `./gated`). Strict, by Katerina's ruling: a part's own stories show\n * everything it can draw. In an app it reads the reusable parts; in the package,\n * every component (`kinds` is the package's one class, `component`).\n */\nasync function checkGated(registry: Registry, folder: string, kinds?: string[]): Promise<boolean> {\n const { gatedFindings } = await gatedScan()\n const found = gatedFindings(registry, folder, { ...(kinds ? { kinds } : {}), pictured: 'own' })\n if (found.length) {\n const lines = found.map((f) => `${f.part} (${f.file}) draws something only when given \\`${f.prop}\\`, and no story that draws it passes \\`${f.prop}\\`: pass it in a story`)\n process.stderr.write(`stories: ${found.length === 1 ? 'one thing a part draws is' : `${found.length} things parts draw are`} never shown:\\n ${lines.join('\\n ')}\\n`)\n return false\n }\n process.stdout.write('stories: everything a part draws behind a prop is shown by a story\\n')\n return true\n}\n\n/**\n * The repository's hand-written map of its Storybook \u2014 the heading order and the\n * Introduction \u2014 against the Storybook (its own index, when there is one) and,\n * in an app, the catalogue (`./storymap`). Reports, and says whether it passed.\n */\nfunction checkStoryMap(folder: string, registry?: Registry, headings?: Set<string>): boolean {\n const problems = storyMapProblems(folder, { ...(registry ? { registry } : {}), ...(headings ? { real: headings } : {}) })\n if (problems.length) {\n process.stderr.write(`storybook map: ${problems.length === 1 ? 'one line no longer matches' : `${problems.length} lines no longer match`}:\\n ${problems.join('\\n ')}\\n`)\n return false\n }\n process.stdout.write('storybook map: the heading order and the Introduction match the Storybook and the catalogue\\n')\n return true\n}\n\n/** One line per kind, in a fixed order, so two runs read the same. */\nfunction summary(registry: Registry): string {\n const count = (cls: string) => registry.entries.filter((entry) => entry.app?.class === cls).length\n const kinds = CLASSES.map((cls) => `${count(cls)} ${cls}`).join(', ')\n const files = registry.builtFrom.files ?? 0\n return `${registry.builtFrom.repo}: ${registry.entries.length} parts in ${files - registry.filesWithoutParts.length} files (${registry.filesWithoutParts.length} more hold none) \u2014 ${kinds}. Every part is described and sorted.`\n}\n\nasync function main(): Promise<number> {\n switch (command) {\n case 'find': {\n const query = plain().join(' ')\n if (!query.trim()) {\n process.stderr.write('estiva-ui find <words\u2026> \u2014 what the thing you need does, in words\\n')\n return 1\n }\n const registries: Registry[] = [readPackageRegistry()]\n // An app that cannot be read is said out loud, and the rest still answer.\n const add = async (folder: string, repo: string | undefined) => {\n const behind = behindBy(folder)\n if (behind) process.stderr.write(`note: ${repo ?? basename(folder)} (${folder}) is ${behind} commit${behind === 1 ? '' : 's'} behind main as last fetched \u2014 its answers may name parts that are gone; pull it\\n`)\n try {\n registries.push(await buildApp(folder, repo))\n } catch (error) {\n const [first, ...more] = String(error instanceof Error ? error.message : error).split('\\n')\n process.stderr.write(`not searched: ${first}${more.length ? `\\n${more.slice(0, 3).join('\\n')}${more.length > 3 ? `\\n \u2026and ${more.length - 3} more \u2014 run \"estiva-ui check\" there` : ''}` : ''}\\n`)\n }\n }\n // The folder it runs in is searched when it is an app; the folder that\n // holds the repositories is not one, and only its neighbours answer.\n const here = !isPackage && existsSync(resolve(root, 'package.json')) ? (manifestAt(root).name ?? basename(root)) : null\n if (here) await add(root, value('repo'))\n if (!values('also').length && !flag('here')) {\n for (const sibling of findSiblings(workspaceOf(root), { skip: here ? [here] : [] })) await add(sibling.folder, sibling.name)\n }\n for (const also of values('also')) {\n const [name, folder] = also.includes('=') ? [also.slice(0, also.indexOf('=')), also.slice(also.indexOf('=') + 1)] : [undefined, also]\n const at = resolve(root, folder)\n if (!existsSync(resolve(at, 'package.json'))) {\n process.stderr.write(`not searched: ${name ?? basename(at)} \u2014 nothing at ${at}\\n`)\n continue\n }\n await add(at, name)\n }\n const limit = Number(value('limit') ?? 5)\n const findings = findInRegistries(registries, query, { limit: Number.isFinite(limit) && limit > 0 ? limit : 5 })\n if (flag('json')) {\n process.stdout.write(`${JSON.stringify(findings.map((finding) => finding.entry), null, 2)}\\n`)\n return 0\n }\n process.stdout.write(`${formatFindings(registries, findings, query)}\\n`)\n // Nothing found is not a failure \u2014 it is the answer that sends a session\n // to ask rather than to invent.\n return 0\n }\n\n case 'build': {\n const out = resolve(root, value('out') ?? 'registry.json')\n if (isPackage) {\n const { buildRegistry, serializeRegistry } = await packageBuilder()\n const registry = buildRegistry({ root })\n const problems = validateRegistry(registry)\n if (problems.length) {\n process.stderr.write(`the registry this build produced does not match its own schema:\\n ${problems.join('\\n ')}\\n`)\n return 1\n }\n writeFileSync(out, serializeRegistry(registry), 'utf8')\n process.stdout.write(`${out}: ${registry.entries.length} entries from ${registry.builtFrom.exports} exports\\n`)\n return 0\n }\n const { serializeRegistry } = await packageBuilder()\n const registry = await buildApp(root, value('repo'))\n writeFileSync(out, serializeRegistry(registry), 'utf8')\n process.stdout.write(`${out}: ${summary(registry)}\\n`)\n return 0\n }\n\n case 'check': {\n if (!isPackage) {\n const registry = await buildApp(root, value('repo'))\n process.stdout.write(`${summary(registry)}\\n`)\n // The usage-page contract and the story links (UIG-19): the one copy, run by every app's `gate` job.\n // A When not may name a part of the package or of this app (B8).\n const pkg = readPackageRegistry()\n const known = nameableParts(registry, pkg)\n const broken = contractProblems(registry, root, known)\n if (broken.length) {\n process.stderr.write(`${broken.length === 1 ? 'a part breaks' : `${broken.length} parts break`} the usage-page contract:\\n ${broken.join('\\n ')}\\n`)\n } else {\n const owed = registry.entries.filter((entry) => (CONTRACT_KINDS as readonly string[]).includes(entry.app?.class ?? '')).length\n process.stdout.write(`usage pages: all ${owed} reusable parts keep the contract and are drawn somewhere\\n`)\n }\n const linked = checkLinks(registry, root)\n const shown = await checkGated(registry, root)\n const loaded = checkLoader()\n const mapped = checkStoryMap(root, registry, linked.headings)\n // What the pages name must still be there (R14): parts under When and When not,\n // and the stories a Seen in line sends a reader to, here or in the package.\n const stale = nameProblems(registry, root, {\n known,\n ...(linked.titles ? { titles: linked.titles } : {}),\n packageIds: pkg.entries.flatMap((e) => [e.storyId, e.docsId].filter((id): id is string => Boolean(id))),\n })\n if (stale.length) process.stderr.write(`usage pages: ${stale.length === 1 ? 'one name leads' : `${stale.length} names lead`} nowhere:\\n ${stale.join('\\n ')}\\n`)\n else process.stdout.write('usage pages: every part and story they name is there\\n')\n return broken.length || stale.length || !linked.ok || !shown || !loaded || !mapped ? 1 : 0\n }\n const { buildRegistry, serializeRegistry } = await packageBuilder()\n const path = packageRegistryPath()\n const built = buildRegistry({ root })\n const problems = validateRegistry(built)\n if (problems.length) {\n process.stderr.write(`the registry does not match its own schema:\\n ${problems.join('\\n ')}\\n`)\n return 1\n }\n if (!existsSync(path)) {\n process.stderr.write(`${path} is missing \u2014 run \"npm run registry\"\\n`)\n return 1\n }\n // Byte for byte. The point of the check is that the committed file cannot\n // drift from the code; \"near enough\" is drift.\n if (readFileSync(path, 'utf8').replace(/\\r\\n/g, '\\n') !== serializeRegistry(built)) {\n process.stderr.write(`${path} is not what the code produces \u2014 run \"npm run registry\" and commit the result\\n`)\n return 1\n }\n process.stdout.write(`${path}: current, ${built.entries.length} entries from ${built.builtFrom.exports} exports\\n`)\n const linked = checkLinks(built, root)\n const shown = await checkGated(built, root, ['component'])\n const loaded = checkLoader()\n // The package keeps a heading order too (R16): it left out Layout, and nothing saw.\n const mapped = checkStoryMap(root, undefined, linked.headings)\n return linked.ok && shown && loaded && mapped ? 0 : 1\n }\n\n case 'skill': {\n const out = value('out')\n const folder = out ? resolve(out) : repositoryOf(root)\n // The loader's path starts where the session does and cannot climb out:\n // Claude Code refuses a `..` in it.\n if (relative(folder, packageRoot()).startsWith('..')) {\n process.stderr.write(`${folder} does not hold ${packageRoot()}: a loader there could not reach the skill's text\\n`)\n return 1\n }\n const path = loaderPath(folder)\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, loaderText(folder, packageRoot()), 'utf8')\n process.stdout.write(`${path}: the Claude skill, read from ${packageRoot()}\\n`)\n const settings = settingsWithSearch(folder)\n if (settings) {\n writeFileSync(settingsPath(folder), settings, 'utf8')\n process.stdout.write(`${settingsPath(folder)}: the search allowed without a prompt\\n`)\n }\n return 0\n }\n\n default:\n process.stderr.write('estiva-ui <find | build | check | skill>\\n')\n return 1\n }\n}\n\ntry {\n process.exitCode = await main()\n} catch (error) {\n process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`)\n process.exitCode = 1\n}\n", "/// <reference types=\"node\" />\n/**\n * The apps beside this one, found rather than named (UIG-20).\n *\n * `estiva-ui find` with nothing else typed searches the package, the app it is\n * run in, and every app that sits beside it. Katerina's condition for having no\n * shared Storybook is that one search, run unasked from any repository, covers\n * every catalogue; a list of names written into each repository's script would\n * be the drifting copy the gates exist to remove, and would miss the next app.\n *\n * An app is a folder, or one folder inside it, whose `package.json` depends on\n * `@estiva-app/ui` and which has a `src` to read. A service that does not\n * install the package is not an app of this catalogue until it does.\n *\n * Each app is searched once. A second checkout of the same app (a worktree, or\n * somebody's copy) carries the same package name; the app the search runs in\n * wins, then the one whose top folder has the shortest name.\n */\nimport { execFileSync } from 'node:child_process'\nimport { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'\nimport { basename, dirname, join, resolve } from 'node:path'\n\nexport const PACKAGE_NAME = '@estiva-app/ui'\n\nexport interface Sibling {\n /** What its entries are called: its top folder's name. */\n name: string\n /** The folder the catalogue is built from. */\n folder: string\n /** Its `package.json` name, which says two checkouts are one app. */\n packageName: string\n}\n\nfunction manifest(folder: string): { name?: string; dependencies?: Record<string, string>; devDependencies?: Record<string, string> } | null {\n const file = join(folder, 'package.json')\n if (!existsSync(file)) return null\n try {\n return JSON.parse(readFileSync(file, 'utf8'))\n } catch {\n return null\n }\n}\n\n/** The name of the app in `folder`, or null when the folder is not one. */\nexport function appName(folder: string): string | null {\n const m = manifest(folder)\n if (!m || m.name === PACKAGE_NAME) return null\n const uses = Boolean(m.dependencies?.[PACKAGE_NAME] ?? m.devDependencies?.[PACKAGE_NAME])\n return uses && existsSync(join(folder, 'src')) ? (m.name ?? basename(folder)) : null\n}\n\nconst isDir = (path: string) => {\n try {\n return statSync(path).isDirectory()\n } catch {\n return false\n }\n}\n\n/**\n * The folder that holds the repositories: the parent of the repository `from`\n * is in, or `from` itself when it is in none (a folder that only holds them).\n */\nexport function workspaceOf(from: string): string {\n let at = resolve(from)\n for (;;) {\n if (existsSync(join(at, '.git'))) return dirname(at)\n const up = dirname(at)\n if (up === at) return resolve(from)\n at = up\n }\n}\n\n/** Every app in `workspace`, one per package name, except those named in `skip`. */\nexport function findSiblings(workspace: string, { skip = [] }: { skip?: string[] } = {}): Sibling[] {\n let tops: string[]\n try {\n tops = readdirSync(workspace).filter((name) => !name.startsWith('.') && name !== 'node_modules' && isDir(join(workspace, name)))\n } catch {\n return []\n }\n const found: Sibling[] = []\n for (const top of tops) {\n const folder = join(workspace, top)\n const inside = readdirSync(folder).filter((name) => !name.startsWith('.') && name !== 'node_modules' && isDir(join(folder, name)))\n for (const candidate of [folder, ...inside.map((name) => join(folder, name))]) {\n const packageName = appName(candidate)\n if (packageName) found.push({ name: top, folder: candidate, packageName })\n }\n }\n const byPackage = new Map<string, Sibling>()\n for (const sibling of found.sort((a, b) => a.name.length - b.name.length || a.name.localeCompare(b.name))) {\n if (skip.includes(sibling.packageName) || byPackage.has(sibling.packageName)) continue\n byPackage.set(sibling.packageName, sibling)\n }\n return [...byPackage.values()].sort((a, b) => a.name.localeCompare(b.name))\n}\n\n/**\n * How many commits the checkout that holds `folder` is behind its remote's main,\n * as last fetched: nothing is fetched, so a search stays quick. Null when it is\n * not a git checkout or has no remote main. A search that reads a stale copy\n * answers with parts that are gone (the re-review after the audit before UIG-26:\n * \"files panel\" found Peek's deleted FilesPanel in an old checkout), so `find`\n * says so beside its answer.\n */\nexport function behindBy(folder: string): number | null {\n const git = (...a: string[]) => {\n try {\n return execFileSync('git', ['-C', folder, ...a], { stdio: ['ignore', 'pipe', 'ignore'], timeout: 10000 }).toString().trim()\n } catch {\n return null\n }\n }\n const main = git('symbolic-ref', '--short', 'refs/remotes/origin/HEAD') ?? (git('rev-parse', '--verify', '--quiet', 'origin/main') ? 'origin/main' : null)\n if (!main) return null\n const count = Number(git('rev-list', '--count', `HEAD..${main}`))\n return Number.isFinite(count) ? count : null\n}\n", "/// <reference types=\"node\" />\n/**\n * The Claude skill (UIG-20): search the catalogue before building anything.\n *\n * Its text lives once, in this package, as `skill/estiva-ui.md` (Katerina,\n * 17 September 2026: the same gate text pasted into two repositories is a\n * defect). Claude Code only loads a skill from a `SKILL.md` under a folder's\n * `.claude/skills/`, and no plugin source can point into `node_modules`, so each\n * repository commits a loader: the trigger below, and one line that reads the\n * installed package's text into the skill when it opens (`` !`\u2026` `` runs before\n * Claude sees the skill). `estiva-ui skill` writes it; `estiva-ui check` fails\n * when a repository's loader is missing or is not what this writes.\n *\n * Measured with fresh sessions of Claude Code 2.1.215 (UIG-20), three things\n * shape that line and the settings beside it:\n *\n * - An injected command runs without a prompt only when Claude Code can read it\n * statically as read-only: a plain `cat` of a plain path. A path with `..`\n * (\"may follow a symlink outside the working directory\"), a `$(\u2026)`, or a\n * `node -e` are all refused, and a refused command stops the skill opening.\n * So the path starts at `${CLAUDE_PROJECT_DIR}`, the folder the session\n * started in, as the editor gate's hook does: a session started above or\n * below the repository gets neither.\n * - An `allowed-tools` line makes opening the skill itself ask for permission\n * (\"Execute skill\"). So the search is allowed in the repository's committed\n * `.claude/settings.json` instead, and the skill carries no `allowed-tools`.\n * - Claude reads a skill's description before it opens the skill, so the\n * trigger is written into the loader; it is the one part that cannot be\n * pulled in later.\n */\nimport { existsSync, readFileSync } from 'node:fs'\nimport { dirname, join, relative, resolve, sep } from 'node:path'\n\nexport const SKILL_NAME = 'estiva-ui'\n\n/** When Claude opens the skill by itself. Kept under Claude Code's 1,536 characters. */\nexport const SKILL_DESCRIPTION =\n 'Use before building, adding or changing anything on screen in an app that uses @estiva-app/ui, or in @estiva-app/ui itself: ' +\n 'a screen, panel, list, row, header, dialog, menu, empty state, a new component, or how something looks. ' +\n 'Also when someone asks for a component in plain words (\"I need a\u2026\", \"add a\u2026\", \"is there a\u2026\"). ' +\n \"It searches every catalogue at once, the package's and each app's Storybook, for a part that already does the job, \" +\n 'and lists the mistakes this codebase keeps making.'\n\n/** The search, allowed without a prompt in the folder's committed `.claude/settings.json`. */\nexport const SEARCH_RULES = ['Bash(npm run ui:find *)', 'Bash(npm --prefix * run ui:find *)', 'PowerShell(npm run ui:find *)', 'PowerShell(npm --prefix * run ui:find *)']\n\n/** The skill's text, inside a package folder. */\nexport const skillTextPath = (packageRoot: string) => join(packageRoot, 'skill', `${SKILL_NAME}.md`)\n\n/** Where a folder keeps its loader. */\nexport const loaderPath = (folder: string) => join(folder, '.claude', 'skills', SKILL_NAME, 'SKILL.md')\n\n/** Where a folder keeps the settings that allow the search. */\nexport const settingsPath = (folder: string) => join(folder, '.claude', 'settings.json')\n\n/** The loader for `folder`, reading the text from `packageRoot`, from where a session in `folder` starts. */\nexport function loaderText(folder: string, packageRoot: string): string {\n const fromTop = relative(folder, skillTextPath(packageRoot)).split(sep).join('/')\n return [\n '---',\n `name: ${SKILL_NAME}`,\n `description: ${JSON.stringify(SKILL_DESCRIPTION)}`,\n '---',\n '',\n '<!-- Written by `estiva-ui skill` from @estiva-app/ui; `estiva-ui check` fails when it differs. The text is the installed package\u2019s, read in below. -->',\n '',\n `!\\`cat \"\\${CLAUDE_PROJECT_DIR}/${fromTop}\"\\``,\n '',\n ].join('\\n')\n}\n\ntype Settings = { permissions?: { allow?: string[] } & Record<string, unknown> } & Record<string, unknown>\n\nconst readSettings = (folder: string): Settings | null => {\n const path = settingsPath(folder)\n if (!existsSync(path)) return {}\n try {\n return JSON.parse(readFileSync(path, 'utf8')) as Settings\n } catch {\n return null\n }\n}\n\n/** `folder`'s settings with the search allowed, everything else as it was; null when they cannot be read. */\nexport function settingsWithSearch(folder: string): string | null {\n const settings = readSettings(folder)\n if (!settings) return null\n const allow = settings.permissions?.allow ?? []\n const missing = SEARCH_RULES.filter((rule) => !allow.includes(rule))\n if (!missing.length && existsSync(settingsPath(folder))) return null\n settings.permissions = { ...settings.permissions, allow: [...allow, ...missing] }\n return `${JSON.stringify(settings, null, 2)}\\n`\n}\n\n/** The repository `from` is in: the nearest folder with `.git`, or `from` when there is none. */\nexport function repositoryOf(from: string): string {\n let at = resolve(from)\n for (;;) {\n if (existsSync(join(at, '.git'))) return at\n const up = dirname(at)\n if (up === at) return resolve(from)\n at = up\n }\n}\n\n/** What is wrong with `folder`'s loader, or null when it is what `loaderText` writes. */\nexport function loaderProblem(folder: string, packageRoot: string): string | null {\n const path = loaderPath(folder)\n const shown = relative(process.cwd(), path).split(sep).join('/') || path\n if (!existsSync(path)) return `${shown} is missing: run \"estiva-ui skill\" and commit it`\n if (readFileSync(path, 'utf8').replace(/\\r\\n/g, '\\n') !== loaderText(folder, packageRoot)) return `${shown} is not what the package writes: run \"estiva-ui skill\" and commit it`\n if (!existsSync(skillTextPath(packageRoot))) return `${shown} reads ${skillTextPath(packageRoot)}, which is not there`\n const allow = readSettings(folder)?.permissions?.allow ?? []\n const missing = SEARCH_RULES.filter((rule) => !allow.includes(rule))\n if (missing.length) return `.claude/settings.json does not allow the search (${missing.join(', ')}): run \"estiva-ui skill\" and commit it`\n return null\n}\n", "/// <reference types=\"node\" />\n/**\n * The hand-written map of a Storybook, held against the Storybook it describes\n * (moved here from Peek's own status checks, audit A3; widened by the re-review\n * after it, R16).\n *\n * A repository may keep two maps of its sidebar: the order of its top-level\n * headings in `.storybook/preview.tsx` \u2014 a `const HEADINGS = [...]` list read by\n * a `storySort` function (Peek), or `storySort: { order: [...] }` (Ship, this\n * package) \u2014 and the Introduction page, which names each heading, in a table row\n * (`| **Folders** | \u2026 |`, Peek) or a bullet (`- **Primitives \u00B7 Inputs** \u2014 \u2026`,\n * Ship), and in an app states how many parts are worth reusing. Both are written\n * by hand and both describe something that moves, so both rot: Peek's named a\n * Huddles heading for a day after its stories were deleted and said 49 reusable\n * parts when the catalogue built 41; Ship's named a Feedback heading it does not\n * have and left out four it does.\n *\n * The real headings are read from Storybook's own index when the command has\n * one, so a title written any way at all counts; otherwise from the story files.\n * Every check runs only when the repository states the thing it checks.\n */\nimport { existsSync, readdirSync, readFileSync } from 'node:fs'\nimport { join } from 'node:path'\nimport type { Registry } from './schema'\n\nconst PREVIEW = '.storybook/preview.tsx'\nconst INTRODUCTIONS = ['src/stories/Introduction.mdx', 'stories/Introduction.mdx']\n/** The classes an app's Introduction counts as \"worth reusing\". */\nconst WORTH_REUSING = ['reusable', 'promote-candidate']\n\nfunction storyFiles(root: string): string[] {\n const out: string[] = []\n const walk = (dir: string) => {\n if (!existsSync(dir)) return\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n if (entry.name === 'node_modules' || entry.name.startsWith('.')) continue\n const path = join(dir, entry.name)\n if (entry.isDirectory()) walk(path)\n else if (entry.name.endsWith('.stories.tsx') || entry.name.endsWith('.mdx')) out.push(path)\n }\n }\n walk(join(root, 'src'))\n walk(join(root, 'stories'))\n return out\n}\n\n/** Every top-level heading the sidebar has, read from the story files: the first segment of each title. */\nexport function sidebarHeadings(root: string): Set<string> {\n const real = new Set<string>()\n for (const file of storyFiles(root)) {\n const text = readFileSync(file, 'utf8')\n const start = text.indexOf('const meta')\n const meta = start === -1 ? '' : text.slice(start, text.indexOf('satisfies Meta', start) + 1 || undefined)\n const title = meta.match(/\\btitle: *['\"]([^'\"]+)['\"]/) ?? text.match(/<Meta\\s+title=['\"]([^'\"]+)['\"]/)\n if (title) real.add(title[1].split('/')[0].trim())\n }\n return real\n}\n\n/** The top-level headings of Storybook's own index (`storybook index`): the first segment of every entry's title. */\nexport function indexHeadings(entries: Record<string, { title?: string }>): Set<string> {\n return new Set(Object.values(entries).flatMap((e) => (e.title ? [e.title.split('/')[0].trim()] : [])))\n}\n\n/** The strings at the top level of the array that starts at `open` (the index of its `[`), skipping nested arrays. */\nfunction topLevelStrings(text: string, open: number): string[] {\n const out: string[] = []\n let depth = 0\n for (let i = open; i < text.length; i++) {\n const c = text[i]\n if (c === '/' && text[i + 1] === '*') {\n const end = text.indexOf('*/', i + 2)\n if (end < 0) break\n i = end + 1\n } else if (c === '/' && text[i + 1] === '/') i = text.indexOf('\\n', i)\n else if (c === '[') depth++\n else if (c === ']') {\n if (--depth === 0) return out\n } else if (c === \"'\" || c === '\"') {\n const end = text.indexOf(c, i + 1)\n if (depth === 1) out.push(text.slice(i + 1, end))\n i = end\n }\n if (i < 0) break\n }\n return out\n}\n\n/** The headings the preview orders \u2014 a `HEADINGS` list or `storySort: { order: [...] }` \u2014 or null when it keeps no order. */\nexport function orderedHeadings(previewText: string): string[] | null {\n const list = /const HEADINGS = \\[/.exec(previewText) ?? /\\border:\\s*\\[/.exec(previewText)\n if (!list) return null\n return topLevelStrings(previewText, list.index + list[0].length - 1)\n}\n\n/**\n * The headings the Introduction names: a table row that opens with a bold name,\n * or a bullet that opens with bold names joined by \" \u00B7 \".\n */\nexport function introductionHeadings(introText: string): Set<string> {\n const rows = [...introText.matchAll(/^\\|\\s*\\*\\*([^*]+)\\*\\*\\s*\\|/gm)].map((m) => m[1])\n const bullets = [...introText.matchAll(/^[-*]\\s+\\*\\*([^*]+)\\*\\*\\s*[\u2014\u2013-]/gm)].flatMap((m) => m[1].split('\u00B7'))\n return new Set([...rows, ...bullets].map((h) => h.trim()).filter(Boolean))\n}\n\n/** The number the Introduction states, or null when it states none. */\nexport function introductionCount(introText: string): number | null {\n const said = introText.match(/\\*\\*(\\d+) parts worth reusing\\*\\*/)\n return said ? Number(said[1]) : null\n}\n\n/**\n * What is wrong with the repository's hand-written map of its Storybook; empty\n * when nothing is. `real` is the sidebar's top-level headings from Storybook's\n * index, when the caller has it; `registry` is needed only for an app's count.\n */\nexport function storyMapProblems(root: string, { registry, real = sidebarHeadings(root) }: { registry?: Registry; real?: Set<string> } = {}): string[] {\n const problems: string[] = []\n const previewPath = join(root, PREVIEW)\n if (existsSync(previewPath)) {\n const ordered = orderedHeadings(readFileSync(previewPath, 'utf8'))\n if (ordered) {\n const unordered = [...real].filter((r) => !ordered.includes(r))\n const empty = ordered.filter((o) => !real.has(o))\n if (unordered.length) problems.push(`${PREVIEW}: not in the heading order, so they fall to the bottom of the sidebar: ${unordered.join(', ')}`)\n if (empty.length) problems.push(`${PREVIEW}: in the heading order but no story uses them: ${empty.join(', ')}`)\n }\n }\n const intro = INTRODUCTIONS.find((p) => existsSync(join(root, p)))\n if (intro) {\n const text = readFileSync(join(root, intro), 'utf8')\n const named = introductionHeadings(text)\n if (named.size) {\n const missing = [...real].filter((r) => !named.has(r))\n const stale = [...named].filter((n) => !real.has(n))\n if (missing.length) problems.push(`${intro}: the sidebar has, the page does not name: ${missing.join(', ')}`)\n if (stale.length) problems.push(`${intro}: the page names, the sidebar does not have: ${stale.join(', ')}`)\n }\n const said = introductionCount(text)\n if (said !== null && registry) {\n const reusable = registry.entries.filter((entry) => WORTH_REUSING.includes(entry.app?.class ?? '')).length\n if (said !== reusable) problems.push(`${intro}: says ${said} parts worth reusing; the catalogue builds ${reusable}`)\n }\n }\n return problems\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAiCA,SAAS,iBAAiB;AAC1B,SAAS,cAAAA,aAAY,WAAW,aAAa,gBAAAC,eAAc,qBAAqB;AAChF,SAAS,cAAc;AACvB,SAAS,YAAAC,WAAU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AAAA,MACT;AACA,YAAM,OAAO,WAAW,MAAM;AAC9B,gBAAUC,SAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AAC5C,oBAAc,MAAM,WAAW,QAAQ,YAAY,CAAC,GAAG,MAAM;AAC7D,cAAQ,OAAO,MAAM,GAAG,IAAI,iCAAiC,YAAY,CAAC;AAAA,CAAI;AAC9E,YAAM,WAAW,mBAAmB,MAAM;AAC1C,UAAI,UAAU;AACZ,sBAAc,aAAa,MAAM,GAAG,UAAU,MAAM;AACpD,gBAAQ,OAAO,MAAM,GAAG,aAAa,MAAM,CAAC;AAAA,CAAyC;AAAA,MACvF;AACA,aAAO;AAAA,IACT;AAAA,IAEA;AACE,cAAQ,OAAO,MAAM,4CAA4C;AACjE,aAAO;AAAA,EACX;AACF;AAEA,IAAI;AACF,UAAQ,WAAW,MAAM,KAAK;AAChC,SAAS,OAAO;AACd,UAAQ,OAAO,MAAM,GAAG,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,CAAI;AAClF,UAAQ,WAAW;AACrB;",
6
6
  "names": ["existsSync", "readFileSync", "basename", "dirname", "join", "relative", "resolve", "main", "existsSync", "readFileSync", "dirname", "join", "resolve", "packageRoot", "existsSync", "readdirSync", "readFileSync", "join", "root", "resolve", "readFileSync", "existsSync", "join", "basename", "serializeRegistry", "registry", "linked", "shown", "loaded", "mapped", "relative", "dirname"]
7
7
  }
@@ -19,6 +19,13 @@ export declare function hasSeenIn(source: string): boolean;
19
19
  * it builds an id.
20
20
  */
21
21
  export declare function linkProblems(registry: Registry, ids: ReadonlySet<string>): string[];
22
+ /**
23
+ * The parts an app's page may name under When and When not: the package's and
24
+ * the app's own (B8). The one copy: `estiva-ui check` and `gates:status` both
25
+ * read it, so they cannot disagree. Status once knew the app's parts only, and
26
+ * read six of Peek's pages as broken that CI passed (UIG-26).
27
+ */
28
+ export declare function nameableParts(app: Registry, pkg: Registry): Set<string>;
22
29
  /**
23
30
  * Every way an app's catalogue breaks the contract, one line each, naming the
24
31
  * part, its file and what to do. Empty when it keeps it.
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/registry/contract.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,2DAA2D;AAC3D,eAAO,MAAM,aAAa,sDAAuD,CAAA;AAEjF,iDAAiD;AACjD,eAAO,MAAM,cAAc,4CAA6C,CAAA;AAKxE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAoBzD;AAED,sFAAsF;AACtF,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CASnF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,WAAW,CAAC,MAAM,CAAgD,GAAG,MAAM,EAAE,CA4BtJ;AASD,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAEpD;AAED,mFAAmF;AACnF,eAAO,MAAM,cAAc,QAAsB,CAAA;AAEjD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAMhH;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAe,EAAE,EAAE;IAAE,KAAK,EAAE,GAAG,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C,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAMhH;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,UAAe,EAAE,EAAE;IAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,MAAM,EAAE,CAsBhL"}
@@ -12,7 +12,7 @@
12
12
  */
13
13
  export { buildRegistry, readIndexExports, serializeRegistry, type BuildOptions } from './build';
14
14
  export { buildAppRegistry, type AppBuildOptions } from './app';
15
- export { CONTRACT_KINDS, NO_ALTERNATIVE, PAGE_SECTIONS, contractProblems, hasSeenIn, linkProblems, namedParts, pageProblem, whenNotProblem } from './contract';
15
+ export { CONTRACT_KINDS, NO_ALTERNATIVE, PAGE_SECTIONS, contractProblems, hasSeenIn, linkProblems, nameableParts, namedParts, pageProblem, whenNotProblem } from './contract';
16
16
  export { docsLink, findInRegistries, findInRegistry, formatFindings, type Finding } from './find';
17
17
  export { CLASSES, SCHEMA_VERSION, validateRegistry, type AppFacts, type EntryBehaviour, type EntryClass, type FileWithoutPart, type EntryKind, type EntryStatus, type EntryVariant, type PurposeSource, type Registry, type RegistryEntry, type RegistryExclusion, } from './schema';
18
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAA;AAC/F,OAAO,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,OAAO,CAAA;AAC9D,OAAO,EAAE,cAAc,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AQ,EACb,KAAK,aAAa,EAClB,KAAK,iBAAiB,GACvB,MAAM,UAAU,CAAA"}
@@ -10,10 +10,11 @@ import {
10
10
  formatFindings,
11
11
  hasSeenIn,
12
12
  linkProblems,
13
+ nameableParts,
13
14
  namedParts,
14
15
  pageProblem,
15
16
  whenNotProblem
16
- } from "./chunk-XK747STJ.js";
17
+ } from "./chunk-4QWD3EBY.js";
17
18
  import {
18
19
  buildAppRegistry
19
20
  } from "./chunk-TQ6UQER3.js";
@@ -42,6 +43,7 @@ export {
42
43
  formatFindings,
43
44
  hasSeenIn,
44
45
  linkProblems,
46
+ nameableParts,
45
47
  namedParts,
46
48
  pageProblem,
47
49
  readIndexExports,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.46.0",
3
+ "version": "0.48.0",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/registry.json CHANGED
@@ -4,9 +4,9 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.46.0",
8
- "exports": 100,
9
- "typeExports": 109,
7
+ "packageVersion": "0.48.0",
8
+ "exports": 104,
9
+ "typeExports": 113,
10
10
  "files": null
11
11
  },
12
12
  "storybook": {
@@ -250,6 +250,25 @@
250
250
  "opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 transition-opacity"
251
251
  ]
252
252
  },
253
+ {
254
+ "name": "AttachmentNode",
255
+ "repo": "estiva-ui",
256
+ "kind": "component",
257
+ "importPath": "@estiva-app/ui/editor",
258
+ "sourceFile": "src/BlockNodes.tsx",
259
+ "purpose": "A file placed in a document — SPEC §13.3's `attachment` block (SHI-2).",
260
+ "purposeFrom": "comment",
261
+ "props": [],
262
+ "variants": [],
263
+ "ownsBehaviours": [],
264
+ "status": "stable",
265
+ "migrationStage": null,
266
+ "docsId": "primitives-blocknodes--docs",
267
+ "storyId": "primitives-blocknodes--default",
268
+ "docPage": null,
269
+ "app": null,
270
+ "looks": []
271
+ },
253
272
  {
254
273
  "name": "Avatar",
255
274
  "repo": "estiva-ui",
@@ -420,6 +439,25 @@
420
439
  "app": null,
421
440
  "looks": []
422
441
  },
442
+ {
443
+ "name": "BlockId",
444
+ "repo": "estiva-ui",
445
+ "kind": "component",
446
+ "importPath": "@estiva-app/ui/editor",
447
+ "sourceFile": "src/BlockNodes.tsx",
448
+ "purpose": "`id` on every block, carried as the `blockId` attribute.",
449
+ "purposeFrom": "comment",
450
+ "props": [],
451
+ "variants": [],
452
+ "ownsBehaviours": [],
453
+ "status": "stable",
454
+ "migrationStage": null,
455
+ "docsId": "primitives-blocknodes--docs",
456
+ "storyId": "primitives-blocknodes--default",
457
+ "docPage": null,
458
+ "app": null,
459
+ "looks": []
460
+ },
423
461
  {
424
462
  "name": "Breadcrumb",
425
463
  "repo": "estiva-ui",
@@ -4274,6 +4312,25 @@
4274
4312
  "app": null,
4275
4313
  "looks": []
4276
4314
  },
4315
+ {
4316
+ "name": "ReferenceNode",
4317
+ "repo": "estiva-ui",
4318
+ "kind": "component",
4319
+ "importPath": "@estiva-app/ui/editor",
4320
+ "sourceFile": "src/BlockNodes.tsx",
4321
+ "purpose": "A `nostr:` reference, drawn as the thing it points at — SPEC §13.1.",
4322
+ "purposeFrom": "comment",
4323
+ "props": [],
4324
+ "variants": [],
4325
+ "ownsBehaviours": [],
4326
+ "status": "stable",
4327
+ "migrationStage": null,
4328
+ "docsId": "primitives-blocknodes--docs",
4329
+ "storyId": "primitives-blocknodes--default",
4330
+ "docPage": null,
4331
+ "app": null,
4332
+ "looks": []
4333
+ },
4277
4334
  {
4278
4335
  "name": "RichText",
4279
4336
  "repo": "estiva-ui",
@@ -6008,6 +6065,25 @@
6008
6065
  "app": null,
6009
6066
  "looks": []
6010
6067
  },
6068
+ {
6069
+ "name": "UnknownBlock",
6070
+ "repo": "estiva-ui",
6071
+ "kind": "component",
6072
+ "importPath": "@estiva-app/ui/editor",
6073
+ "sourceFile": "src/BlockNodes.tsx",
6074
+ "purpose": "A block this editor has no design for, kept whole.",
6075
+ "purposeFrom": "comment",
6076
+ "props": [],
6077
+ "variants": [],
6078
+ "ownsBehaviours": [],
6079
+ "status": "stable",
6080
+ "migrationStage": null,
6081
+ "docsId": "primitives-blocknodes--docs",
6082
+ "storyId": "primitives-blocknodes--default",
6083
+ "docPage": null,
6084
+ "app": null,
6085
+ "looks": []
6086
+ },
6011
6087
  {
6012
6088
  "name": "useToast",
6013
6089
  "repo": "estiva-ui",
@@ -39,20 +39,22 @@ and when not to. Most of what gets asked for already exists somewhere.
39
39
  ## Gotchas
40
40
 
41
41
  The mistakes made here more than once, from the record (UIG-20 counted 542
42
- recorded defects; these 24 cover the 111 that are screen work). Each says what
43
- to do instead. Apps differ in frame and theme: never carry one app's layout,
44
- sizes or colours into another; take them from tokens.
42
+ recorded defects to 23 September, UIG-26 counted 647 to 30 September; these 24
43
+ cover the 113 that are screen work). Each says what to do instead. Apps differ
44
+ in frame and theme: never carry one app's layout, sizes or colours into
45
+ another; take them from tokens.
45
46
 
46
47
  **Layout**
47
48
 
48
- 1. **A header row drawn by hand** at the top of a column → `ContainerHeader`.
49
- Its actions are `IconButton`s with tooltips. A whole list column is
50
- `ListColumn`, which draws the bar; a field that adds to the list goes in its
51
- `above`.
49
+ 1. **A header row drawn by hand** at the top of a column, or `ContainerHeader`
50
+ over a box of your own → `Panel`, which draws `ContainerHeader`'s bar over a
51
+ body that scrolls. Its `actions` are `IconButton`s with tooltips. A whole list
52
+ column is `ListColumn`, which draws the bar; a field that adds to the list
53
+ goes in its `above`.
52
54
  2. **A list with no scroll container**, cut off at the fold (no lint sees a box
53
55
  that was never built) → a list column is `ListColumn`, which scrolls its
54
- rows; anything else that grows goes in a `ScrollArea`. Check with more rows
55
- than fit.
56
+ rows; a panel is `Panel`, whose body scrolls; anything else that grows goes
57
+ in a `ScrollArea`. Check with more rows than fit.
56
58
  3. **`EmptyState` at the wrong level** → `scope="page"` only when the whole
57
59
  page is empty, `scope="section"` for one part of it, placed inside the box
58
60
  its rows live in. Never wrap it in a box of your own that places it.
@@ -113,8 +115,9 @@ sizes or colours into another; take them from tokens.
113
115
  twice) → search for the thing first. Write the escape on the line above
114
116
  the statement: a gate escape never inside `eslint-disable`, a token-lint
115
117
  one inside `eslint-disable-next-line <rule> --`.
116
- 20. **Classes the lint cannot see**: in a const not named `…_CLASSES` or
117
- `…Styles`, or in an array that is `.join()`ed → keep classes in
118
+ 20. **Classes the lint cannot see**: in a const or map not named `…_CLASSES`
119
+ or `…Styles`, or in a list worked out while the code runs (a list of
120
+ written strings joined with `.join(' ')` is read) → keep classes in
118
121
  `className` or `cn()`, or in a map with one of those names.
119
122
  21. **The editor gate and this skill need a session started at the repository's
120
123
  top folder.** Started elsewhere, run the repository's `lint:rules` yourself
@@ -0,0 +1,82 @@
1
+ import { Meta, Canvas } from '@storybook/addon-docs/blocks'
2
+ import * as BlockNodesStories from './BlockNodes.stories'
3
+
4
+ <Meta of={BlockNodesStories} />
5
+
6
+ # BlockNodes
7
+
8
+ The Tiptap nodes an editor of a block document needs beside StarterKit: an id
9
+ on every block, a block it cannot edit kept whole, a reference, and a file.
10
+
11
+ <Canvas of={BlockNodesStories.Default} />
12
+
13
+ ## When
14
+
15
+ - **An editor that saves a block document** (SPEC §13.3) — anywhere a comment
16
+ can be anchored to one of its blocks. `BlockId` keeps each block's id across
17
+ every edit, so the anchor still finds its block after a save.
18
+ - Always with `@estiva-app/protocol`'s `toEditorDocument` to load the document
19
+ and `fromEditorDocument` (or `publishableFromEditor`) to save it. The node
20
+ names and the `blockId` attribute are that translation's.
21
+
22
+ ## When not
23
+
24
+ - Reading a document → **RichText**. Nothing here draws a document that is not
25
+ being edited.
26
+ - A message composer that writes marker text. It has no block ids to keep.
27
+
28
+ ## How
29
+
30
+ ```tsx
31
+ import type { JSONContent } from '@tiptap/core'
32
+ import { EditorContent, useEditor } from '@tiptap/react'
33
+ import StarterKit from '@tiptap/starter-kit'
34
+ import {
35
+ AttachmentNode,
36
+ BlockId,
37
+ ReferenceNode,
38
+ UnknownBlock,
39
+ type AttachmentViewProps,
40
+ type ReferenceViewProps,
41
+ } from '@estiva-app/ui/editor'
42
+
43
+ // toEditorDocument(documentForEditing(value, format)), from @estiva-app/protocol
44
+ const opened: JSONContent = { type: 'doc', content: [] }
45
+
46
+ const Reference = ({ uri }: ReferenceViewProps) => <span>{uri}</span>
47
+ const File = ({ attrs }: AttachmentViewProps) => <span>{String(attrs.filename)}</span>
48
+
49
+ const editor = useEditor({
50
+ extensions: [
51
+ StarterKit,
52
+ BlockId,
53
+ UnknownBlock,
54
+ ReferenceNode.configure({ view: Reference }),
55
+ AttachmentNode.configure({ view: File }),
56
+ ],
57
+ content: opened,
58
+ })
59
+
60
+ <EditorContent editor={editor} />
61
+ ```
62
+
63
+ - **Load and save through protocol.** `toEditorDocument(documentForEditing(value, format))`
64
+ opens the stored value; `publishableFromEditor(editor.getJSON())` is what a
65
+ save writes, with its `contentFormat`.
66
+ - **Add TableKit** (`@tiptap/extension-table`) beside StarterKit. The
67
+ translation opens a table as `table`, `tableRow`, `tableHeader` and
68
+ `tableCell` nodes, and ProseMirror drops a node its schema does not have —
69
+ the save would delete the table.
70
+ - `ReferenceNode`'s `view` gets the `uri` and draws the thing it points at,
71
+ resolved by the app. Without one, the URI is drawn as text.
72
+ - `AttachmentNode`'s `view` gets the block's `imeta` fields as `attrs`.
73
+ Without one, the file's name is drawn as text.
74
+ - `UnknownBlock` draws a block the editor has no design for as its text, in a
75
+ box. It cannot be changed here, only moved or deleted, and it is saved back
76
+ exactly as it arrived.
77
+
78
+ <Canvas of={BlockNodesStories.WithoutViews} />
79
+
80
+ ## What it owns
81
+
82
+ Nothing. It only draws. Clicks and keys are yours.