@milesroxas/design-hub 0.8.0 → 0.9.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 (64) hide show
  1. package/README.md +7 -2
  2. package/core/prototype.test.ts +83 -0
  3. package/core/prototype.ts +84 -0
  4. package/core/review/model.ts +20 -2
  5. package/core/review/policy.test.ts +4 -2
  6. package/core/review/policy.ts +4 -2
  7. package/core/review/service.test.ts +200 -16
  8. package/core/review/service.ts +91 -5
  9. package/core/review/store.ts +10 -1
  10. package/dist/core/prototype.d.ts +35 -0
  11. package/dist/core/prototype.js +84 -0
  12. package/dist/core/review/model.d.ts +13 -2
  13. package/dist/core/review/model.js +13 -0
  14. package/dist/core/review/policy.d.ts +1 -1
  15. package/dist/core/review/policy.js +1 -0
  16. package/dist/core/review/service.d.ts +24 -2
  17. package/dist/core/review/service.js +81 -6
  18. package/dist/core/review/store.d.ts +10 -1
  19. package/dist/core/review/store.js +10 -1
  20. package/dist/scripts/comments.js +4 -3
  21. package/dist/scripts/lib/cdp.js +6 -1
  22. package/dist/scripts/lib/export-smoke.d.ts +18 -0
  23. package/dist/scripts/lib/export-smoke.js +73 -0
  24. package/dist/scripts/new.js +5 -2
  25. package/dist/scripts/release-check.d.ts +5 -3
  26. package/dist/scripts/release-check.js +17 -4
  27. package/dist/scripts/share.d.ts +2 -2
  28. package/dist/server/api.js +8 -0
  29. package/dist/server/session.d.ts +5 -1
  30. package/dist/server/session.js +39 -21
  31. package/dist/vercel/proxy.js +44 -8
  32. package/dist/vite/boundary.d.ts +93 -0
  33. package/dist/vite/boundary.js +218 -0
  34. package/dist/vite/css-boundary.d.ts +39 -0
  35. package/dist/vite/css-boundary.js +167 -0
  36. package/dist/vite/kit.js +15 -6
  37. package/dist/vite/leaks.d.ts +37 -0
  38. package/dist/vite/leaks.js +331 -0
  39. package/dist/vite/plugin.js +2 -1
  40. package/dist/vite/registry.d.ts +15 -4
  41. package/dist/vite/registry.js +531 -27
  42. package/dist/vite/settle.d.ts +27 -0
  43. package/dist/vite/settle.js +185 -0
  44. package/package.json +4 -3
  45. package/shell/ClientViewNote.tsx +18 -0
  46. package/shell/Guide.tsx +17 -2
  47. package/shell/Index.tsx +257 -25
  48. package/shell/audience.test.ts +63 -0
  49. package/shell/audience.ts +47 -0
  50. package/shell/hub.ts +36 -0
  51. package/shell/main.tsx +39 -5
  52. package/shell/registry.ts +28 -7
  53. package/shell/registry.virtual.d.ts +12 -4
  54. package/shell/review/Pins.tsx +8 -6
  55. package/shell/review/Review.tsx +8 -4
  56. package/shell/review/ThreadCard.tsx +6 -14
  57. package/shell/review/client.ts +16 -4
  58. package/shell/review/review.css +37 -24
  59. package/shell/shell.css +50 -3
  60. package/shell/system.css +5 -0
  61. package/skills/miles-deploy/SKILL.md +17 -0
  62. package/skills/miles-new-feature/SKILL.md +1 -1
  63. package/skills/miles-prototype/SKILL.md +14 -1
  64. package/skills/miles-review/SKILL.md +1 -1
package/shell/shell.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /* The index: one group per feature (its primary prototype, its alternates on
2
- a rail, its internal explorations folded into cards), then prototypes with
2
+ a rail, its explorations folded into cards), then prototypes with
3
3
  no feature, then the archive. Rows draw no dividers; their hover surface
4
4
  bleeds 12px into the gutter. The list ends in a foot (the Ledger Foot Rule).
5
5
  The rules are in README.md, The index. */
@@ -13,6 +13,7 @@
13
13
  .index-head, .index-tracks, .index-filter, .index-section, .index-subsection, .index-empty, .index-none, .index-foot { padding-inline: 12px; }
14
14
 
15
15
  .index-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 40px; }
16
+ .index-head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 32px; }
16
17
  .index-head h1 { font-size: 18px; line-height: 28px; font-weight: 600; text-wrap: balance; }
17
18
  .index-voice { font: 400 18px/28px var(--font-voice); letter-spacing: -0.01em; color: var(--text-secondary); max-width: 44ch; text-wrap: pretty; }
18
19
  .index code { font: 13px/20px var(--sys-font-mono); color: var(--text-secondary); }
@@ -114,6 +115,48 @@
114
115
 
115
116
  .index-foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border-secondary); color: var(--text-primary); }
116
117
 
118
+ /* Studio, outside Client view: each prototype's audience in a fifth column,
119
+ beside its row and never inside the link. Internal wears the internal
120
+ comments' amber; Client-facing stays quiet. The switch is the plain kind:
121
+ a 28px track, its hit area grown to 40px. */
122
+ .index.has-audience { grid-template-columns: minmax(0, 1fr) auto auto auto auto; }
123
+ .index.has-audience .index-row { grid-column: 1 / 5; }
124
+ .index-list > li > .index-audience { grid-column: 5; align-self: center; padding-right: 12px; }
125
+ .index-cards > li { flex-direction: column; gap: 6px; }
126
+ .index-cards > li > .index-audience { padding: 0 12px 4px; }
127
+ .index-audience { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 12px; line-height: 18px; color: var(--text-quaternary); white-space: nowrap; }
128
+ .index-cards .index-audience { justify-content: space-between; }
129
+ .index-audience-word[data-audience="internal"] { padding: 0 6px; border-radius: var(--radius-xs); background: var(--sys-internal); color: var(--sys-on-internal); font-weight: 500; }
130
+ .index-switch { position: relative; flex: none; width: 28px; height: 16px; padding: 0; border: 0; border-radius: var(--radius-full); background: var(--border-primary); cursor: pointer; transition: background-color var(--dur-hover) var(--ease-hover); }
131
+ .index-switch::before { content: ""; position: absolute; inset: -12px -6px; }
132
+ .index-switch[aria-disabled="true"] { cursor: progress; opacity: 0.6; }
133
+ .index-switch:focus-visible { outline: 2px solid transparent; box-shadow: var(--focus-ring); }
134
+ .index-switch-thumb { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: oklch(1 0 0); box-shadow: 0 1px 2px oklch(0 0 0 / 0.2); transition: translate 160ms var(--ease-out), background-color var(--dur-hover) var(--ease-hover); }
135
+ .index-switch[aria-checked="true"] { background: var(--fg-primary); }
136
+ .index-switch[aria-checked="true"] .index-switch-thumb { translate: 12px 0; background: var(--bg-primary); }
137
+
138
+ /* Studio's Client view, entered from the head and left from this note: the
139
+ comment layer's note (shell/review, .rv-viewing), in its words and look. */
140
+ .index-client-view { flex: none; }
141
+ .index-viewing {
142
+ --button-tertiary-fg: var(--harness-fg-muted);
143
+ --button-tertiary-fg_hover: oklch(1 0 0);
144
+ --button-tertiary-bg_hover: oklch(1 0 0 / 0.1);
145
+ --focus-ring: 0 0 0 2px var(--harness-bg), 0 0 0 4px oklch(1 0 0 / 0.7);
146
+ position: fixed; z-index: 10; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
147
+ translate: -50% 0;
148
+ display: flex; align-items: center; gap: 8px;
149
+ width: max-content; max-width: min(480px, calc(100vw - 32px)); margin: 0;
150
+ padding: 4px 4px 4px 14px; border-radius: 12px;
151
+ background: var(--harness-bg); color: oklch(1 0 0);
152
+ box-shadow: 0 0 0 1px oklch(1 0 0 / 0.09), 0 12px 32px -8px oklch(0 0 0 / 0.5), 0 2px 6px oklch(0 0 0 / 0.25);
153
+ font: 13px/18px var(--sys-font);
154
+ transition: opacity 200ms var(--ease-out), translate 200ms var(--ease-out);
155
+ }
156
+ @starting-style { .index-viewing { opacity: 0; translate: -50% 4px; } }
157
+ .index-viewing .icon { flex: none; color: var(--harness-fg-muted); }
158
+ .index-viewing .btn.index-viewing-act { height: 28px; padding: 0 8px; }
159
+
117
160
  @media (hover: hover) and (pointer: fine) {
118
161
  .index-row:hover { background: var(--bg-primary_hover); }
119
162
  .index-row:hover .index-summary { color: var(--text-secondary); }
@@ -140,9 +183,9 @@
140
183
  prototype, and the chosen row holds, so the eye keeps what it picked.
141
184
  The browser paints this page until the next one is ready, so the fade
142
185
  fills a wait that was blank. */
143
- .index-head, .index-tracks, .index-filter, .index-section, .index-subsection, .index-alternates-label, .index-foot { transition: opacity var(--dur-dialog-out) var(--ease-in); }
186
+ .index-head, .index-tracks, .index-filter, .index-section, .index-subsection, .index-alternates-label, .index-foot, .index-audience { transition: opacity var(--dur-dialog-out) var(--ease-in); }
144
187
  .index.is-leaving .index-alternates::before { opacity: 0; transition: opacity var(--dur-dialog-out) var(--ease-in); }
145
- .index.is-leaving :is(.index-head, .index-tracks, .index-filter, .index-section, .index-subsection, .index-alternates-label, .index-foot, .index-row:not([data-chosen]), .index-card:not([data-chosen])) { opacity: 0; }
188
+ .index.is-leaving :is(.index-head, .index-tracks, .index-filter, .index-section, .index-subsection, .index-alternates-label, .index-foot, .index-row:not([data-chosen]), .index-card:not([data-chosen]), .index-audience) { opacity: 0; }
146
189
  .index.is-leaving :is(.index-row, .index-card) { pointer-events: none; }
147
190
 
148
191
  :root[data-motion="reduce"] .index-rise { animation-name: index-fade; animation-duration: 120ms; animation-timing-function: linear; }
@@ -150,11 +193,15 @@
150
193
  :root[data-motion="reduce"] .index-fold { transition-property: opacity; }
151
194
  :root[data-motion="reduce"] .index-fold-toggle svg { transition: none; }
152
195
  :root[data-motion="reduce"] .index-card:hover .index-card-head svg { transform: none; }
196
+ :root[data-motion="reduce"] .index-switch-thumb { transition: none; }
197
+ :root[data-motion="reduce"] .index-viewing { transition-property: opacity; }
198
+ @starting-style { :root[data-motion="reduce"] .index-viewing { translate: -50% 0; } }
153
199
 
154
200
  @media (max-width: 560px) {
155
201
  .index, .index-group, .index-alternates, .index-list, .index-list > li, .index-row { display: flex; flex-direction: column; }
156
202
  .index-row { gap: 2px; }
157
203
  .index-meta { display: flex; gap: 12px; margin-top: 4px; }
204
+ .index-list > li > .index-audience { justify-content: flex-start; padding: 0 12px 8px; }
158
205
  }
159
206
 
160
207
  .shell-notice { width: min(720px, 100% - 32px); margin: 0 auto; padding: 96px 0; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
package/shell/system.css CHANGED
@@ -24,6 +24,11 @@
24
24
  --harness-fg-muted: oklch(1 0 0 / 0.55);
25
25
  --harness-border: oklch(1 0 0 / 0.1);
26
26
  --harness-shadow: 0 8px 24px oklch(0 0 0 / 0.4);
27
+
28
+ /* Internal: the amber an internal comment wears (shell/review), and the
29
+ label on it, 8:1. The index marks an Internal prototype with the same pair. */
30
+ --sys-internal: oklch(0.83 0.15 85);
31
+ --sys-on-internal: oklch(0.3 0.06 85);
27
32
  }
28
33
 
29
34
  .sys {
@@ -85,6 +85,23 @@ A signed-in device stays signed in until the person's access ends: 3 months, 6 m
85
85
  - One person: `pnpm people access <id> --access 3m|6m|open`, counted from today, or `--access` on `pnpm people add`.
86
86
  - When someone's access ends their links stop working at once, and every device signs out within five minutes. A changed access length reaches their signed-in devices within five minutes too. Change their access to let them back in, then send a new link.
87
87
 
88
+ ## Internal and client-facing prototypes
89
+
90
+ Every prototype is **Internal** until a Studio person marks it **Client-facing** with the switch beside it on the deployed site's **Prototypes** page; only then can a Client open it or see it listed. No command reads or sets it: to check one, open the site's index signed in as Studio and look at its switch, or turn on **Client view** there to see the index as a client gets it. A switch flipped under `pnpm dev` writes the local store only; the deployed site has its own. A new prototype is internal, and so is every prototype on a site upgraded to the release that brought this: after that upgrade, tell the user once that clients see nothing until they switch on the prototypes the client should see. Before sending a handover, ask the user to check that the prototype it names is switched on. Walkthroughs and feature names reach every signed-in person whatever the switches say, so a walkthrough that describes internal work must wait.
91
+
92
+ The same upgrade changes what a build accepts and writes. Tell the user once, and when a build fails fix the file it names; never work around the check:
93
+
94
+ - A stylesheet that does not parse (an unclosed block) fails `pnpm build` and stops `pnpm dev` (the page answers 500), naming file and line, where both worked before: every stylesheet is now read for reaches into a prototype's folder.
95
+ - A prototype that reaches into another prototype's folder fails in `pnpm dev` and `pnpm build`, naming both files: an import (any query), a CSS `@import` or `url()`, or a `new URL('…', import.meta.url)`. Copy the file into the prototype that uses it, or move it into `kit/`.
96
+ - Importing a file that sits directly in `prototypes/`, or in a folder there with no `README.md`, fails in `pnpm dev` and `pnpm build`: nothing in `prototypes/` is shared. Move shared code into `kit/`.
97
+ - A `kit/` file that imports or references anything in a prototype's folder fails in `pnpm dev` and `pnpm build`: the kit never reads a prototype. Move what it needs into `kit/`.
98
+ - A web worker in a prototype fails `pnpm build`. Run the work on the main thread, or build the worker from `kit/` files only.
99
+ - Sass, Less and Stylus are refused: importing a `.scss`, `.sass`, `.less`, `.styl` or `.stylus` file from a prototype or from `kit/` fails in `pnpm dev` and `pnpm build`, naming the file. Rewrite it as plain CSS or `.pcss`.
100
+ - Stylesheet ties resolve in source import order, as in `pnpm dev`: when a prototype imports a kit sheet and then its own, a rule of equal weight in its own sheet wins, where a build could put the kit's last before.
101
+ - A prototype's small images and SVGs are separate requests from its own folder, no longer inlined as `data:` URIs.
102
+ - A build fails when a file outside a prototype's folder is one of that prototype's files whole (the same bytes, a `data:` URI of it, or its whole text as a string), naming both files.
103
+ - `postcss` is a direct dependency of the hub, and Vite is pinned to 8.3 (it was any 8.x from 8.3.5): the project's next install may move its Vite to any 8.3 patch, never 8.4. Nothing to do.
104
+
88
105
  ## A project that shared before one-time links
89
106
 
90
107
  A project that shared with a password (before one-time links) needs this once, before its next `pnpm share`. The pre-flight `gate` step stops the share until the store is there, so production is never replaced by a gate nobody can pass.
@@ -34,7 +34,7 @@ One feature is one slug used in two places: `docs/sprints/<slug>/` and the `feat
34
34
 
35
35
  ## The walkthrough
36
36
 
37
- `docs/sprints/<feature>/guide.md` is for the reviewer who has a sign-in link and not the repo. It is written from the States table: one section per workflow, then "Every state, and how to reach it" copied from the README, then what the prototype does not do, then what the review must settle. Screenshots go in `assets/guide/` beside it, named in order (`01-list.jpg`); a missing file fails the build. Write it before the share link goes out (`miles-deploy` checks it exists for a sprint).
37
+ `docs/sprints/<feature>/guide.md` is for the reviewer who has a sign-in link and not the repo. It is written from the States table: one section per workflow, then "Every state, and how to reach it" copied from the README, then what the prototype does not do, then what the review must settle. Screenshots go in `assets/guide/` beside it, named in order (`01-list.jpg`); a missing file fails the build. Write it before the share link goes out (`miles-deploy` checks it exists for a sprint). It goes to every signed-in person, clients included, even while the feature's prototypes are internal, and so does the feature's name: never name or describe internal work in it until the client may see it.
38
38
 
39
39
  ## When done means decided
40
40
 
@@ -24,7 +24,7 @@ A finding with a log id (`log 3f9a…`) was Jev's. When the user says it was wro
24
24
 
25
25
  ### Low gravity
26
26
 
27
- A prototype imports only `@kit/*` and files in its own folder. Never another prototype, never the hub's own code in `node_modules/@milesroxas/design-hub`. Why: the moment two prototypes share a file, deleting one breaks the other, and a prototype that cannot be deleted is production.
27
+ A prototype imports only `@kit/*` and files in its own folder. Never another prototype, never the hub's own code in `node_modules/@milesroxas/design-hub`. Why: the moment two prototypes share a file, deleting one breaks the other, and a prototype that cannot be deleted is production. The build refuses an import from another prototype's folder, naming both files: copy the file in, or promote it to `kit/`.
28
28
 
29
29
  ### Fork, don't flex
30
30
 
@@ -54,6 +54,19 @@ A user-visible state the README's `## States` table does not list does not exist
54
54
 
55
55
  Anything a control would do that the prototype does not build says so: `notInPrototype('Model history')` or `toast(message, { kind: 'scope' })`. Never a product toast with a green check for something that did not happen. Why: a reviewer who sees a success they did not get stops trusting the ones they did.
56
56
 
57
+ ## Who sees it
58
+
59
+ A new prototype is **Internal**: only Studio can open it, until a Studio person marks it **Client-facing** with the switch beside it on the hub's index (no command reads or sets it). Never tell the user a new prototype is ready for the client before that. Everything in `prototypes/<slug>/` (code, README, styles, fixtures, images) ships only to people who may see that prototype: the deployed site refuses its page and files to a Client while it is internal. Why: an internal prototype stays inside the studio only because nothing of it leaves its folder.
60
+
61
+ - Never reach into another prototype's folder: an import, a CSS `@import` or `url()`, a `new URL(…, import.meta.url)`. The build refuses each, naming both files: copy the file in, or promote it to `kit/`. A link to another prototype's page is fine; reading its files is not. And nothing in `kit/` may point into a prototype's folder: the build refuses that too.
62
+ - No web worker in a prototype (`new Worker`, `?worker`, `?worker&inline`): Vite builds it outside the prototype's folder, so the build refuses it. Run the work on the main thread, or build the worker from `kit/` files that use no prototype's.
63
+ - Write styles in plain CSS (or `.pcss`). Sass, Less and Stylus are refused in prototypes and in `kit/`, in `pnpm dev` and `pnpm build`, naming the file. Why: their own `@import` and `@use` resolve inside the preprocessor, where no check can see a reach into another prototype.
64
+ - The build also reads what it wrote, as a backstop for a whole file copied out of the folder: a file outside a prototype's folder that is one of its files whole (the same bytes, a `data:` URI of it, or its whole text as a string in a script) fails it, naming both files. It does not look for a part of a file, so shared lines, rules or snippets build.
65
+ - Limits: a `new URL` whose path is built at run time is not seen, until its content lands outside the folder. `pnpm dev` checks less than `pnpm build` (no read or output check). Nothing directly in `prototypes/`, or in a folder there without a README: shared code belongs in `kit/`, and the build refuses the rest. Run `pnpm build` before sharing.
66
+ - A prototype's small images and SVGs are built as files of their own, never inlined as `data:` URIs, so the site can refuse them to a Client while the prototype is internal.
67
+ - `kit/` is shared with every signed-in person, the client included, so nothing client-secret goes there: no unreleased product name, internal note or real data that only one prototype may show.
68
+ - Walkthrough text (`docs/sprints/<feature>/guide.md`) and feature names go to every signed-in person, clients included, whether or not the feature's prototypes are client-facing. A walkthrough must not name or describe internal work until the client may see it.
69
+
57
70
  ## DialKit patterns
58
71
 
59
72
  Walk this for every number and every switch:
@@ -7,7 +7,7 @@ description: "Work from review comments on the deployed prototypes: pull them in
7
7
 
8
8
  Each comment is pinned to a prototype, its state (the URL and every dial value) and, usually, an element. The repo gets them as `docs/sprints/<feature>/comments.md`, grouped by README state, then by kind. That file is generated: read it, never edit it, and close comments in the store.
9
9
 
10
- Each thread line starts with its number, as the panel shows it, and its audience: `- #3 (internal) Ed (Studio): ...` or `- #4 (client-facing) Rae (Acme): ...`. A number is fixed and never reused, so gaps are normal. An internal thread is the studio's own note and no client ever sees it; a client-facing one is read by everyone, Studio's replies in it included.
10
+ Each thread line starts with its label and its audience: `- #I3 (internal) Ed (Studio): ...` or `- #4 (client-facing) Rae (Acme): ...`. Internal and client-facing threads count apart: I1, I2 are internal, 1, 2 client-facing, so `I2` and `2` are different threads. Name a thread by its label exactly. The panel shows both as a bare number; an internal pin is amber, so a person may say "the amber 2" for `I2`. A number is fixed and never reused, so gaps after a delete are normal. An internal thread is the studio's own note and no client ever sees it; a client-facing one is read by everyone, Studio's replies in it included.
11
11
 
12
12
  ## Working from comments
13
13