@nanisoft/prism-ui 0.6.0 → 0.8.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 (52) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/catalog.d.ts.map +1 -1
  3. package/dist/catalog.js +40 -0
  4. package/dist/components/index.d.ts +6 -0
  5. package/dist/components/index.d.ts.map +1 -1
  6. package/dist/components/index.js +3 -0
  7. package/dist/components/ui/breadcrumb.d.ts +6 -2
  8. package/dist/components/ui/breadcrumb.d.ts.map +1 -1
  9. package/dist/components/ui/breadcrumb.js +5 -3
  10. package/dist/components/ui/dialog.d.ts +12 -1
  11. package/dist/components/ui/dialog.d.ts.map +1 -1
  12. package/dist/components/ui/dialog.js +2 -2
  13. package/dist/components/ui/live-region.d.ts +78 -0
  14. package/dist/components/ui/live-region.d.ts.map +1 -0
  15. package/dist/components/ui/live-region.js +48 -0
  16. package/dist/components/ui/mark.d.ts +44 -0
  17. package/dist/components/ui/mark.d.ts.map +1 -0
  18. package/dist/components/ui/mark.js +79 -0
  19. package/dist/components/ui/pagination.d.ts +24 -6
  20. package/dist/components/ui/pagination.d.ts.map +1 -1
  21. package/dist/components/ui/pagination.js +23 -9
  22. package/dist/components/ui/product-switcher.d.ts +7 -0
  23. package/dist/components/ui/product-switcher.d.ts.map +1 -1
  24. package/dist/components/ui/product-switcher.js +2 -2
  25. package/dist/components/ui/slider.d.ts +1 -1
  26. package/dist/components/ui/slider.d.ts.map +1 -1
  27. package/dist/components/ui/tree.d.ts +115 -0
  28. package/dist/components/ui/tree.d.ts.map +1 -0
  29. package/dist/components/ui/tree.js +137 -0
  30. package/dist/pages/docs-shell/docs-shell.d.ts +250 -0
  31. package/dist/pages/docs-shell/docs-shell.d.ts.map +1 -0
  32. package/dist/pages/docs-shell/docs-shell.js +197 -0
  33. package/dist/pages/docs-shell/index.d.ts +3 -0
  34. package/dist/pages/docs-shell/index.d.ts.map +1 -0
  35. package/dist/pages/docs-shell/index.js +1 -0
  36. package/dist/pages/index.d.ts +9 -2
  37. package/dist/pages/index.d.ts.map +1 -1
  38. package/dist/pages/index.js +8 -2
  39. package/dist/styles.css +93 -0
  40. package/gates/README.md +98 -0
  41. package/gates/cli.mjs +133 -0
  42. package/gates/hidden-state.mjs +243 -0
  43. package/gates/index.mjs +81 -0
  44. package/gates/laws.mjs +170 -0
  45. package/gates/links.mjs +187 -0
  46. package/gates/pack-boundary.mjs +421 -0
  47. package/gates/pin.mjs +130 -0
  48. package/gates/retired-line.mjs +314 -0
  49. package/gates/run.mjs +320 -0
  50. package/gates/runtime-token-read.mjs +129 -0
  51. package/gates/stylesheet-ownership.mjs +207 -0
  52. package/package.json +14 -2
@@ -0,0 +1,197 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Prose } from '../../components/ui/prose';
3
+ import { Heading, Text } from '../../components/ui/typography';
4
+ import { cn } from '../../lib/utils';
5
+ /**
6
+ * A documentation screen: a navigation rail, the document, a contents rail and
7
+ * the pager to the neighbouring pages.
8
+ *
9
+ * **This is the Page the other three NaniSoft sites import, and the name is
10
+ * theirs.** All three already read `import { DocsShell, type DocsNavEntry }
11
+ * from '@nanisoft/prism-ui/pages'` in their own document template, and all three
12
+ * map their page tree into that shape in their own `lib/to-prism-tree`. A
13
+ * published name cannot be cheaply changed and there is no redirect lane for item
14
+ * routes, so the name follows the three import lines rather than this file's
15
+ * shape. It was `docs-shell` in the retired line, where it was an empty
16
+ * `div` plus a class name that each site then had to style from scratch, and it
17
+ * is `docs-shell` here because that is what the three call sites already say.
18
+ *
19
+ * **A section is a label, not a control.** It carries no status, no badge, no
20
+ * count, no collapse and no sort, and that is the whole of its interface. The
21
+ * reason is specific: AlphaLens files its documentation as a pipeline, where
22
+ * "Unified data contract (approved)" is a stage of the work and not a topic a
23
+ * reader may visit in any order, and every structural affordance says the
24
+ * opposite. A status in the title is part of the title and stays there as words:
25
+ * the Page reads no parentheses, matches no vocabulary, and renders no pill
26
+ * beside a heading that has one. A tree is data, and a Page that parsed a
27
+ * consumer's data would be a Page that had opinions about it.
28
+ *
29
+ * **A group with no index is a label rather than a route.** `href` is optional
30
+ * on `DocsNavGroup` for exactly that, and the absence means the label. The three
31
+ * consumer sites all write `url: node.index?.url ?? ''` in their own adapter
32
+ * today, which is the same fact spelled as an empty string, and two of the three
33
+ * then carry a stylesheet rule that styles the resulting anchor-with-no-href
34
+ * back into a label. Naming the case in the type makes those two rules dead
35
+ * rather than load-bearing, and the type is the only place that had to change.
36
+ *
37
+ * **The pager is derived from the navigation rather than passed.** The rail
38
+ * already knows every page and the order a reader meets them in, and deriving the
39
+ * two neighbours from that plus `currentHref` removes one derivation from each
40
+ * of the three sites. It is derived rather than passed for a second reason: a
41
+ * caller who passes neighbours can pass a neighbour that is not in the tree, and
42
+ * this is the one arrangement where a reader would notice.
43
+ *
44
+ * **The consumer supplies two orders and the Page imposes neither.** `nav` is in
45
+ * the order the rail shows, and `toc` is in the order the contents rail shows.
46
+ * Both are read as given: nothing is sorted, deduplicated or alphabetised, and a
47
+ * tree whose sections are named for subject matter reads in the order its
48
+ * author filed it. A Page that sorted its rail would flatten the one thing the
49
+ * three sites disagree about and cannot both be right about.
50
+ *
51
+ * **The rail is bounded in height.** Atlas files nineteen pages and AlphaLens
52
+ * files twenty-seven, so the taller tree is half again as long, and an unbounded
53
+ * rail on a tall tree is a rail that pushes the document below the fold before
54
+ * the reader has read a line of it. The rail and the contents rail are each
55
+ * capped against the viewport and scroll inside it, so a nineteen-page tree and a
56
+ * twenty-seven-page tree are both a full screen and neither is a page-long
57
+ * sidebar.
58
+ *
59
+ * It is a Page rather than a Block because it is a whole screen and it is the
60
+ * screen a content pipeline targets: a route that reads one document and hands
61
+ * it the page tree, the outline and the current address. A Block would be the
62
+ * rail, and the rail's job is not separable from the screen's, because the
63
+ * arrangement of rail, document, contents and pager is what the three sites each
64
+ * wrote separately and are here written once.
65
+ *
66
+ * It is a server Component. It fetches nothing, it holds no state and it imports
67
+ * no router, so a consumer renders it from whichever route their framework names
68
+ * and hands it the document their pipeline produced.
69
+ */
70
+ export function DocsShell({ title, description, nav, toc, currentHref, navLabel, tocLabel, pagerLabel, pagerLabels, header, footer, className, children, }) {
71
+ const rail = nav && nav.length > 0 ? nav : undefined;
72
+ const contents = toc && toc.length > 0 ? toc : undefined;
73
+ const neighbours = currentHref === undefined ? undefined : deriveNeighbours(nav ?? [], currentHref);
74
+ return (_jsxs("div", { "data-slot": "docs-shell", className: cn('mx-auto w-full max-w-6xl px-6 py-10 lg:px-8', className), children: [header, _jsxs("div", { "data-slot": "docs-shell-frame", className: cn('flex flex-col gap-8 lg:flex-row lg:gap-10',
75
+ // One column for the document, and a third for whichever rails are
76
+ // present. The frame is sized by what the consumer passed rather than
77
+ // by a fixed three-column grid, so a tree with no contents rail leaves
78
+ // the document the width the two remaining columns divide between
79
+ // them.
80
+ contents ? 'lg:grid lg:grid-cols-[15rem_minmax(0,1fr)] xl:grid-cols-[15rem_minmax(0,1fr)_13rem]' : 'lg:grid lg:grid-cols-[15rem_minmax(0,1fr)]'), children: [rail ? (_jsx("aside", { "data-slot": "docs-rail", className: "hidden lg:col-start-1 lg:row-start-1 lg:block", children: _jsx("nav", { "aria-label": navLabel, className: "lg:sticky lg:top-20 lg:max-h-[calc(100svh-7rem)] lg:overflow-y-auto lg:pe-4", children: _jsx(NavList, { entries: rail, currentHref: currentHref, depth: 0 }) }) })) : null, _jsxs("article", { "data-slot": "docs-article", className: "flex min-w-0 flex-col gap-8", children: [title ? (_jsxs("header", { className: "flex flex-col gap-3", children: [_jsx(Heading, { as: "h1", size: "3xl", children: title }), description ? (_jsx(Text, { size: "lg", tone: "muted", className: "max-w-measure", children: description })) : null] })) : description ? (_jsx(Text, { size: "lg", tone: "muted", className: "max-w-measure", children: description })) : null, _jsx(Prose, { fullWidth: true, children: children }), neighbours ? (_jsx(Pager, { previous: neighbours.previous, next: neighbours.next, label: pagerLabel, labels: pagerLabels })) : null] }), contents ? (_jsx("aside", { "data-slot": "docs-contents", className: "hidden lg:col-start-3 lg:row-start-1 lg:block", children: _jsx("nav", { "aria-label": tocLabel, className: "lg:sticky lg:top-20 lg:max-h-[calc(100svh-7rem)] lg:overflow-y-auto", children: _jsx(NavList, { entries: contents, currentHref: currentHref, depth: 0 }) }) })) : null] }), footer] }));
81
+ }
82
+ /* ------------------------------------------------------------------ *
83
+ * The rail
84
+ * ------------------------------------------------------------------ */
85
+ /**
86
+ * One level of the tree as a list, at whatever depth it sits.
87
+ *
88
+ * The nesting is a rule rather than a special case: the tree is the shape the
89
+ * navigation has, and one level of that is the whole renderer. A tree one deep
90
+ * and a tree seven deep are the same code with different data, which is what
91
+ * lets one Page carry a site that files nine pages under a heading and a site
92
+ * that files six sections separated by rules.
93
+ */
94
+ function NavList({ entries, currentHref, depth, }) {
95
+ return (_jsx("ul", { "data-slot": "docs-nav-list", "data-depth": depth, className: cn('border-border flex flex-col gap-1 border-l',
96
+ // One level of indent per nested group, and none at the top, so the
97
+ // depth reads from the rule rather than from the words.
98
+ depth > 0 && 'ps-3'), children: entries.map((entry, index) => (_jsx(NavNode, { entry: entry, currentHref: currentHref, depth: depth }, `${entry.type}:${index}`))) }));
99
+ }
100
+ /**
101
+ * One entry, in whichever of the three shapes it arrives.
102
+ *
103
+ * The switch is on `type` rather than on the presence of fields, so an entry
104
+ * that arrives malformed falls to the last arm and renders nothing rather than
105
+ * rendering a destination it has no address for.
106
+ */
107
+ function NavNode({ entry, currentHref, depth, }) {
108
+ if (entry.type === 'divider') {
109
+ // A rule between entries. It is a label, so it is not focusable and a reader
110
+ // does not meet it as a destination, and the empty title renders no words
111
+ // above the hairline rather than a word a reader has to interpret.
112
+ return (_jsx("li", { "data-slot": "docs-nav-divider", className: "border-border mt-2 border-t pt-2 first:mt-0 first:border-t-0 first:pt-0", children: entry.title ? (_jsx("span", { className: "text-muted-foreground text-xs font-medium tracking-wide uppercase", children: entry.title })) : null }));
113
+ }
114
+ if (entry.type === 'group') {
115
+ return (_jsx("li", { "data-slot": "docs-nav-group", children: _jsxs("div", { className: "flex flex-col gap-1", children: [entry.href === undefined ? (_jsx("span", { "data-slot": "docs-nav-label", className: cn('rounded-sm text-sm font-semibold tracking-tight', containsHref(entry, currentHref) ? 'text-foreground' : 'text-muted-foreground'), children: entry.title })) : (_jsx("a", { "data-slot": "docs-nav-heading", href: entry.href, "aria-current": currentHref === entry.href ? 'page' : undefined, className: cn('hover:text-foreground rounded-sm text-sm font-semibold tracking-tight transition-colors duration-fast ease-out', under(entry.href, currentHref) ? 'text-foreground' : 'text-muted-foreground'), children: entry.title })), entry.items.length > 0 ? (_jsx(NavList, { entries: entry.items, currentHref: currentHref, depth: depth + 1 })) : null] }) }));
116
+ }
117
+ return (_jsx("li", { "data-slot": "docs-nav-page", children: _jsx("a", { "data-slot": "docs-nav-link", href: entry.href, "aria-current": currentHref === entry.href ? 'page' : undefined, className: cn('-ms-px block border-l-2 py-1 ps-3 text-sm transition-colors duration-fast ease-out', currentHref === entry.href
118
+ ? 'text-foreground border-primary font-medium'
119
+ : 'text-muted-foreground hover:text-foreground border-transparent'), children: entry.title }) }));
120
+ }
121
+ /**
122
+ * Every page the tree holds, in the order a reader meets them.
123
+ *
124
+ * A group's own index page comes before the pages under it, because that is the
125
+ * order the tree states and the Page does not reorder it. A group with no index
126
+ * contributes its children and nothing else, which is the second thing that
127
+ * makes an absent `href` a label rather than a route: there is no page there for
128
+ * the pager to reach either. A divider contributes nothing at all.
129
+ */
130
+ function flatten(entries, into = []) {
131
+ for (const entry of entries) {
132
+ if (entry.type === 'page') {
133
+ into.push({ title: entry.title, href: entry.href });
134
+ continue;
135
+ }
136
+ if (entry.type === 'group') {
137
+ if (entry.href !== undefined)
138
+ into.push({ title: entry.title, href: entry.href });
139
+ flatten(entry.items, into);
140
+ }
141
+ }
142
+ return into;
143
+ }
144
+ /**
145
+ * The pages either side of `currentHref`, or nothing when it is not in the tree.
146
+ *
147
+ * It returns `undefined` rather than a pair of blanks when the address is not in
148
+ * the navigation, because a pager with two empty halves is a rule above nothing
149
+ * and a reader cannot tell it from a page that has no neighbours.
150
+ */
151
+ function deriveNeighbours(entries, currentHref) {
152
+ const flat = flatten(entries);
153
+ const at = flat.findIndex((entry) => entry.href === currentHref);
154
+ if (at === -1)
155
+ return undefined;
156
+ return { previous: flat[at - 1], next: flat[at + 1] };
157
+ }
158
+ /**
159
+ * The two pages either side of this one, rendered as native links.
160
+ *
161
+ * Each half renders only when there is a page for it. A "previous" link on the
162
+ * first page is a link to the page the reader has already read, and a "next"
163
+ * link on the last is a promise the site cannot keep.
164
+ */
165
+ function Pager({ previous, next, label, labels, }) {
166
+ if (!previous && !next)
167
+ return null;
168
+ return (_jsxs("nav", { "aria-label": label, "data-slot": "docs-pager", className: "border-border mt-4 flex flex-wrap items-start justify-between gap-4 border-t pt-6", children: [previous ? (_jsxs("a", { href: previous.href, className: "hover:text-foreground flex flex-col rounded-sm transition-colors duration-fast ease-out", children: [_jsx("span", { className: "text-muted-foreground text-xs font-medium tracking-wide uppercase", children: labels.previous }), _jsx("span", { className: "text-sm font-semibold", children: previous.title })] })) : (_jsx("span", {})), next ? (_jsxs("a", { href: next.href, className: "hover:text-foreground ms-auto flex flex-col rounded-sm text-right transition-colors duration-fast ease-out", children: [_jsx("span", { className: "text-muted-foreground text-xs font-medium tracking-wide uppercase", children: labels.next }), _jsx("span", { className: "text-sm font-semibold", children: next.title })] })) : null] }));
169
+ }
170
+ /* ------------------------------------------------------------------ *
171
+ * The current address
172
+ * ------------------------------------------------------------------ */
173
+ /** Under a route, or at it, and never under a route that merely starts the same. */
174
+ function under(href, currentHref) {
175
+ return (href !== undefined &&
176
+ currentHref !== undefined &&
177
+ (currentHref === href || currentHref.startsWith(`${href}/`)));
178
+ }
179
+ /**
180
+ * Whether the current page is inside this group.
181
+ *
182
+ * A group with a route answers for that route and everything under it. A group
183
+ * without one has no route to answer with, so it asks its children, which is the
184
+ * only way a label can still show a reader that they are inside it.
185
+ */
186
+ function containsHref(group, currentHref) {
187
+ if (under(group.href, currentHref))
188
+ return true;
189
+ return group.items.some((entry) => {
190
+ if (entry.type === 'page')
191
+ return under(entry.href, currentHref);
192
+ if (entry.type === 'group')
193
+ return containsHref(entry, currentHref);
194
+ return false;
195
+ });
196
+ }
197
+ export default DocsShell;
@@ -0,0 +1,3 @@
1
+ export { DocsShell, default } from './docs-shell';
2
+ export type { DocsShellProps, DocsNavEntry, DocsNavPage, DocsNavGroup, DocsNavDivider, DocsPagerLabels, } from './docs-shell';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pages/docs-shell/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACjD,YAAY,EACV,cAAc,EACd,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ export { DocsShell, default } from './docs-shell';
@@ -3,8 +3,13 @@
3
3
  *
4
4
  * A Page is a shipped, installable screen model composed of Blocks and
5
5
  * Components that receives application-owned navigation, content and data
6
- * (ticket 07). The v1 roster ships four Pages. Each is also importable on its
7
- * own subpath, `@nanisoft/prism-ui/pages/<slug>`.
6
+ * (ticket 07). Each is also importable on its own subpath,
7
+ * `@nanisoft/prism-ui/pages/<slug>`.
8
+ *
9
+ * `DocsShell` and `DocsNavEntry` keep the names the three consumer sites already
10
+ * import, so the name follows those import lines rather than this file's shape.
11
+ * A published name cannot be cheaply changed and there is no redirect lane for
12
+ * item routes.
8
13
  */
9
14
  export { MarketingPage } from './marketing-page';
10
15
  export type { MarketingPageProps } from './marketing-page';
@@ -18,4 +23,6 @@ export { NotFoundPage } from './not-found-page';
18
23
  export type { NotFoundPageProps, NotFoundLink } from './not-found-page';
19
24
  export { BlogPostPage } from './blog-post-page';
20
25
  export type { BlogPostPageProps, BlogPostTag, BlogPostNeighbour, BlogPostTrailLabels } from './blog-post-page';
26
+ export { DocsShell } from './docs-shell';
27
+ export type { DocsShellProps, DocsNavEntry, DocsNavPage, DocsNavGroup, DocsNavDivider, DocsPagerLabels, } from './docs-shell';
21
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,YAAY,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC9G,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,YAAY,EACV,cAAc,EACd,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,cAAc,CAAA"}
@@ -3,8 +3,13 @@
3
3
  *
4
4
  * A Page is a shipped, installable screen model composed of Blocks and
5
5
  * Components that receives application-owned navigation, content and data
6
- * (ticket 07). The v1 roster ships four Pages. Each is also importable on its
7
- * own subpath, `@nanisoft/prism-ui/pages/<slug>`.
6
+ * (ticket 07). Each is also importable on its own subpath,
7
+ * `@nanisoft/prism-ui/pages/<slug>`.
8
+ *
9
+ * `DocsShell` and `DocsNavEntry` keep the names the three consumer sites already
10
+ * import, so the name follows those import lines rather than this file's shape.
11
+ * A published name cannot be cheaply changed and there is no redirect lane for
12
+ * item routes.
8
13
  */
9
14
  export { MarketingPage } from './marketing-page';
10
15
  export { DashboardPage } from './dashboard-page';
@@ -12,3 +17,4 @@ export { SettingsPage } from './settings-page';
12
17
  export { AuthPage } from './auth-page';
13
18
  export { NotFoundPage } from './not-found-page';
14
19
  export { BlogPostPage } from './blog-post-page';
20
+ export { DocsShell } from './docs-shell';
package/dist/styles.css CHANGED
@@ -364,6 +364,9 @@
364
364
  .my-6 {
365
365
  margin-block: var(--spacing-6);
366
366
  }
367
+ .-ms-px {
368
+ margin-inline-start: -1px;
369
+ }
367
370
  .ms-auto {
368
371
  margin-inline-start: auto;
369
372
  }
@@ -632,6 +635,9 @@
632
635
  --tw-translate-y: var(--spacing-0\.5);
633
636
  translate: var(--tw-translate-x) var(--tw-translate-y);
634
637
  }
638
+ .transform {
639
+ transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
640
+ }
635
641
  .cursor-default {
636
642
  cursor: default;
637
643
  }
@@ -822,6 +828,10 @@
822
828
  border-left-style: var(--tw-border-style);
823
829
  border-left-width: 1px;
824
830
  }
831
+ .border-l-2 {
832
+ border-left-style: var(--tw-border-style);
833
+ border-left-width: 2px;
834
+ }
825
835
  .border-border {
826
836
  border-color: var(--border);
827
837
  }
@@ -995,6 +1005,9 @@
995
1005
  .p-6 {
996
1006
  padding: var(--spacing-6);
997
1007
  }
1008
+ .px-0\.5 {
1009
+ padding-inline: var(--spacing-0\.5);
1010
+ }
998
1011
  .px-1 {
999
1012
  padding-inline: var(--spacing-1);
1000
1013
  }
@@ -1055,9 +1068,15 @@
1055
1068
  .py-20 {
1056
1069
  padding-block: var(--spacing-20);
1057
1070
  }
1071
+ .ps-3 {
1072
+ padding-inline-start: var(--spacing-3);
1073
+ }
1058
1074
  .pt-0 {
1059
1075
  padding-top: var(--spacing-0);
1060
1076
  }
1077
+ .pt-2 {
1078
+ padding-top: var(--spacing-2);
1079
+ }
1061
1080
  .pt-4 {
1062
1081
  padding-top: var(--spacing-4);
1063
1082
  }
@@ -1405,10 +1424,20 @@
1405
1424
  .placeholder\:text-muted-foreground::placeholder {
1406
1425
  color: var(--muted-foreground);
1407
1426
  }
1427
+ .first\:mt-0:first-child {
1428
+ margin-top: var(--spacing-0);
1429
+ }
1408
1430
  .first\:border-t:first-child {
1409
1431
  border-top-style: var(--tw-border-style);
1410
1432
  border-top-width: 1px;
1411
1433
  }
1434
+ .first\:border-t-0:first-child {
1435
+ border-top-style: var(--tw-border-style);
1436
+ border-top-width: 0px;
1437
+ }
1438
+ .first\:pt-0:first-child {
1439
+ padding-top: var(--spacing-0);
1440
+ }
1412
1441
  .last\:border-b-0:last-child {
1413
1442
  border-bottom-style: var(--tw-border-style);
1414
1443
  border-bottom-width: 0px;
@@ -1778,12 +1807,36 @@
1778
1807
  }
1779
1808
  }
1780
1809
  @media (width >= 64rem) {
1810
+ .lg\:sticky {
1811
+ position: sticky;
1812
+ }
1813
+ .lg\:top-20 {
1814
+ top: var(--spacing-20);
1815
+ }
1816
+ .lg\:col-start-1 {
1817
+ grid-column-start: 1;
1818
+ }
1819
+ .lg\:col-start-3 {
1820
+ grid-column-start: 3;
1821
+ }
1822
+ .lg\:row-start-1 {
1823
+ grid-row-start: 1;
1824
+ }
1825
+ .lg\:block {
1826
+ display: block;
1827
+ }
1781
1828
  .lg\:flex {
1782
1829
  display: flex;
1783
1830
  }
1831
+ .lg\:grid {
1832
+ display: grid;
1833
+ }
1784
1834
  .lg\:hidden {
1785
1835
  display: none;
1786
1836
  }
1837
+ .lg\:max-h-\[calc\(100svh-7rem\)\] {
1838
+ max-height: calc(100svh - 7rem);
1839
+ }
1787
1840
  .lg\:grid-cols-2 {
1788
1841
  grid-template-columns: repeat(2, minmax(0, 1fr));
1789
1842
  }
@@ -1793,12 +1846,27 @@
1793
1846
  .lg\:grid-cols-4 {
1794
1847
  grid-template-columns: repeat(4, minmax(0, 1fr));
1795
1848
  }
1849
+ .lg\:grid-cols-\[15rem_minmax\(0\,1fr\)\] {
1850
+ grid-template-columns: 15rem minmax(0,1fr);
1851
+ }
1852
+ .lg\:flex-row {
1853
+ flex-direction: row;
1854
+ }
1855
+ .lg\:gap-10 {
1856
+ gap: var(--spacing-10);
1857
+ }
1858
+ .lg\:overflow-y-auto {
1859
+ overflow-y: auto;
1860
+ }
1796
1861
  .lg\:p-6 {
1797
1862
  padding: var(--spacing-6);
1798
1863
  }
1799
1864
  .lg\:px-8 {
1800
1865
  padding-inline: var(--spacing-8);
1801
1866
  }
1867
+ .lg\:pe-4 {
1868
+ padding-inline-end: var(--spacing-4);
1869
+ }
1802
1870
  }
1803
1871
  @media (pointer: coarse) {
1804
1872
  .pointer-coarse\:size-11 {
@@ -2562,6 +2630,26 @@
2562
2630
  inherits: false;
2563
2631
  initial-value: 0;
2564
2632
  }
2633
+ @property --tw-rotate-x {
2634
+ syntax: "*";
2635
+ inherits: false;
2636
+ }
2637
+ @property --tw-rotate-y {
2638
+ syntax: "*";
2639
+ inherits: false;
2640
+ }
2641
+ @property --tw-rotate-z {
2642
+ syntax: "*";
2643
+ inherits: false;
2644
+ }
2645
+ @property --tw-skew-x {
2646
+ syntax: "*";
2647
+ inherits: false;
2648
+ }
2649
+ @property --tw-skew-y {
2650
+ syntax: "*";
2651
+ inherits: false;
2652
+ }
2565
2653
  @property --tw-border-style {
2566
2654
  syntax: "*";
2567
2655
  inherits: false;
@@ -2829,6 +2917,11 @@
2829
2917
  --tw-translate-x: 0;
2830
2918
  --tw-translate-y: 0;
2831
2919
  --tw-translate-z: 0;
2920
+ --tw-rotate-x: initial;
2921
+ --tw-rotate-y: initial;
2922
+ --tw-rotate-z: initial;
2923
+ --tw-skew-x: initial;
2924
+ --tw-skew-y: initial;
2832
2925
  --tw-border-style: solid;
2833
2926
  --tw-gradient-position: initial;
2834
2927
  --tw-gradient-from: #0000;
@@ -0,0 +1,98 @@
1
+ # `@nanisoft/prism-ui/gates`
2
+
3
+ The cross-repository laws, as programs, in the package a consumer already pins
4
+ exactly.
5
+
6
+ For four years the five NaniSoft repositories coordinated through a prose
7
+ contract mirrored in four files. It drifted into three implementations of one rule
8
+ and one of the three rules was false, and it could not be enforced because prose
9
+ cannot fail. This subpath is the replacement: every law is the failure message of
10
+ a gate, and the gate is here, so a change to a law lands once and reaches every
11
+ consumer in one release.
12
+
13
+ ## What a consumer holds, and what the package holds
14
+
15
+ A consumer's repository holds **data**:
16
+
17
+ | the consumer declares | because |
18
+ | --- | --- |
19
+ | its stylesheets | which sheets are its own is a fact about its own pages |
20
+ | its pack map | the regions it allows, and why each one exists |
21
+ | its region resolver | naming a region means knowing its own DOM |
22
+ | its coverage floors | how many rules or routes count as having read something |
23
+ | its destinations known to be broken | one site's content defect, with a reason |
24
+ | its custom properties the build supplies | one site's build, one site's font |
25
+
26
+ The package holds **every law**: what the judgements are, what each failure says,
27
+ and why each one exists. A consumer that restates any of it has two rules that will
28
+ disagree, and the disagreement is invisible until a reader sees the difference.
29
+
30
+ ## Running it
31
+
32
+ ```bash
33
+ pnpm exec prism-gates # every gate prism-gates.json names
34
+ pnpm exec prism-gates --gate=links # one gate
35
+ pnpm exec prism-gates --json # machine-readable, for a test
36
+ ```
37
+
38
+ In a consumer's `package.json`:
39
+
40
+ ```json
41
+ {
42
+ "scripts": {
43
+ "check:gates": "prism-gates"
44
+ }
45
+ }
46
+ ```
47
+
48
+ And in `prism-gates.json`, at the repository root:
49
+
50
+ ```json
51
+ {
52
+ "gateKit": 1,
53
+ "gates": ["pin", "retired-line", "stylesheet-ownership", "links", "hidden-state"],
54
+ "stylesheet-ownership": { "sheets": ["app/globals.css"], "minDeclarations": 20 },
55
+ "links": { "outDir": "out", "minRoutes": 30, "minAnchors": 200 },
56
+ "hidden-state": { "sheets": ["app/globals.css"], "minRules": 25 }
57
+ }
58
+ ```
59
+
60
+ `gateKit` is the generation of the contract the consumer is holding itself to. A
61
+ consumer that does not state one gets the package's current generation, and a law
62
+ rewritten in a later release is then a version the consumer has not moved to rather
63
+ than a silent change of wording underneath it.
64
+
65
+ ## The laws
66
+
67
+ | id | the law |
68
+ | --- | --- |
69
+ | `pin` | the design system is an exact version, and the token package is the component package's dependency rather than the consumer's |
70
+ | `retired-line` | no trace of the retired component library survives |
71
+ | `stylesheet-ownership` | a site stylesheet does not own a surface the design system owns |
72
+ | `token-read` | a custom property that nothing declares is not a wrong colour, it is no declaration at all |
73
+ | `links` | every internal destination resolves and every fragment names an element that exists |
74
+ | `pack-boundary` | a pack boundary lands on a mark, and a declared region set is the whole of what may carry a second pack |
75
+ | `hidden-state` | a CSS-authored hidden state is escapable, and its exit is not a clock |
76
+
77
+ The full text of each, and the failure each one prevents, is in `laws.mjs` and is
78
+ printed by the gate that holds it. It is not restated here on purpose: this file is
79
+ the one place a reader looks when a build is red, and a second copy of a law in a
80
+ second file is a second rule.
81
+
82
+ ## What a gate here cannot do
83
+
84
+ Stated here rather than left for a reader to discover:
85
+
86
+ - **It reads text, not a cascade.** The ownership gate sees a selector and a
87
+ declaration. It does not resolve which rule wins.
88
+ - **It reads the emitted export, not a browser.** The links and pack-boundary gates
89
+ read `out/`. Run the build first; a gate that read nothing fails rather than
90
+ reporting a clean page.
91
+ - **It does not see a runtime.** A `data-pack` attribute set after paint, or a
92
+ token read in client code, is outside every gate in this kit.
93
+ - **A stylesheet half is not a rendered half.** A consumer that ships a hidden
94
+ state also needs a test that renders with scripting switched off.
95
+
96
+ These limits are printed on every run as well, because a gate that appeared to
97
+ resolve cascades and did not would be worse than no gate: it would retire the
98
+ question.
package/gates/cli.mjs ADDED
@@ -0,0 +1,133 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * The consumer's gate chain. One program, one configuration file, one exit code.
4
+ *
5
+ * A consumer's repository holds data: its roots, its sheet, its pack map, its
6
+ * coverage floors, its destinations it knows are broken. It does not hold the
7
+ * wording of a rule, because a wording held in four places is four rules that will
8
+ * disagree, and the version they disagree at is the version nobody chose.
9
+ *
10
+ * pnpm prism-gates # every gate the configuration names
11
+ * pnpm prism-gates --gate=links # one gate
12
+ * pnpm prism-gates --gate=links --json # machine-readable, for a test
13
+ *
14
+ * `--json` exists because the assertion that matters about a gate is not that it
15
+ * passed: it is that it went red on a defect it can see. A test cannot watch a
16
+ * human-readable exit code and be sure it saw the failure it planted, so the
17
+ * machine form carries the findings and the coverage the run achieved.
18
+ *
19
+ * **The exit code is the contract.** 0 means every named gate ran and found
20
+ * nothing. 1 means a gate found something. 2 means a gate could not read what it
21
+ * was pointed at, which is a different answer from "clean" and is never reported
22
+ * as 0. A gate that read nothing and exited 0 is the failure this program exists
23
+ * to make impossible, and it is why the coverage floors live in the gates rather
24
+ * than in the consumer's expectations.
25
+ */
26
+ import process from 'node:process'
27
+ import path from 'node:path'
28
+
29
+ import { GATE_IDS, GATE_KIT_VERSION, gate, laws } from './index.mjs'
30
+ import { CoverageError, readJson } from './run.mjs'
31
+
32
+ const CONFIG_NAME = 'prism-gates.json'
33
+
34
+ const flag = (name) => process.argv.find((argument) => argument.startsWith(`--${name}=`))?.slice(name.length + 3)
35
+ const has = (name) => process.argv.includes(`--${name}`)
36
+
37
+ async function main() {
38
+ const root = path.resolve(process.cwd())
39
+ const configPath = flag('config') ?? CONFIG_NAME
40
+ const json = has('json')
41
+ const only = flag('gate')
42
+
43
+ let config
44
+ try {
45
+ config = readJson(root, configPath)
46
+ } catch (cause) {
47
+ return fail(`error prism-gates: ${cause.message}`)
48
+ }
49
+ if (!config) {
50
+ return fail(
51
+ `error prism-gates: ${path.join(root, configPath)} does not resolve.\n` +
52
+ ' A gate chain with no configuration is a chain that runs nothing, and nothing looks like a pass.\n' +
53
+ ' The configuration holds this repository\'s own data only: its roots, its sheet, its pack map, its\n' +
54
+ ' coverage floors. The laws are not in it, because they are in the package.',
55
+ )
56
+ }
57
+
58
+ const named = only ? [only] : (config.gates ?? [])
59
+ if (named.length === 0) {
60
+ return fail(
61
+ `error prism-gates: ${configPath} names no gates, so this run enforced nothing.\n` +
62
+ ` A chain that runs nothing exits the same as a chain that found nothing, which is the answer this\n` +
63
+ ` program exists to stop giving. The kit ships: ${GATE_IDS.join(', ')}.`,
64
+ )
65
+ }
66
+
67
+ const results = []
68
+ let findings = 0
69
+ let unreadable = 0
70
+
71
+ for (const id of named) {
72
+ const settings = config[id] ?? {}
73
+ try {
74
+ const { run } = await gate(id)
75
+ const result = await run({ root, config: settings })
76
+ findings += result.findings.length
77
+ results.push({ gate: id, law: result.law.id, ok: result.findings.length === 0, findings: result.findings, notes: result.notes, also: (result.also ?? []).map((l) => l.id) })
78
+ } catch (cause) {
79
+ unreadable += 1
80
+ const message =
81
+ cause instanceof CoverageError
82
+ ? `error prism-gates: ${id}: ${cause.message}`
83
+ : `error prism-gates: ${id} could not run: ${cause.stack ?? cause.message}`
84
+ if (json) {
85
+ results.push({ gate: id, ok: false, unreadable: true, findings: [], notes: [message] })
86
+ } else {
87
+ console.error(message)
88
+ }
89
+ }
90
+ }
91
+
92
+ if (json) {
93
+ console.log(
94
+ JSON.stringify(
95
+ { gateKit: GATE_KIT_VERSION, laws: laws().map((l) => l.id), results },
96
+ null,
97
+ 2,
98
+ ),
99
+ )
100
+ return findings > 0 || unreadable > 0 ? 1 : 0
101
+ }
102
+
103
+ for (const result of results) {
104
+ if (result.unreadable) continue
105
+ for (const line of result.notes) console.log(line)
106
+ for (const line of result.findings) console.error(line)
107
+ if (result.findings.length > 0) {
108
+ const law = laws().find((l) => l.id === result.law)
109
+ console.error(`\n${law.title}`)
110
+ console.error(law.message)
111
+ console.error(` It is here because: ${law.why}`)
112
+ }
113
+ }
114
+
115
+ console.log(
116
+ `\nprism-gates: gate kit ${GATE_KIT_VERSION}, ${named.length} gate(s) run, ${findings} finding(s), ` +
117
+ `${unreadable} unreadable`,
118
+ )
119
+ console.log(`prism-gates: the laws this run enforced: ${laws().map((l) => l.id).join(', ')}`)
120
+ console.log(
121
+ 'prism-gates: the wording of every law above is in the package you pinned, not in this repository. A change\n' +
122
+ ' to it reaches this repository in one release and cannot be declined here.',
123
+ )
124
+
125
+ return findings > 0 || unreadable > 0 ? 1 : 0
126
+ }
127
+
128
+ function fail(message) {
129
+ console.error(message)
130
+ return 2
131
+ }
132
+
133
+ process.exitCode = await main()