@milesroxas/design-hub 0.8.1 → 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.
- package/README.md +7 -2
- package/core/prototype.test.ts +83 -0
- package/core/prototype.ts +84 -0
- package/core/review/model.ts +7 -0
- package/core/review/policy.test.ts +4 -2
- package/core/review/policy.ts +4 -2
- package/core/review/service.test.ts +144 -4
- package/core/review/service.ts +70 -2
- package/core/review/store.ts +6 -0
- package/dist/core/prototype.d.ts +35 -0
- package/dist/core/prototype.js +84 -0
- package/dist/core/review/model.d.ts +2 -0
- package/dist/core/review/model.js +6 -0
- package/dist/core/review/policy.d.ts +1 -1
- package/dist/core/review/policy.js +1 -0
- package/dist/core/review/service.d.ts +23 -1
- package/dist/core/review/service.js +62 -3
- package/dist/core/review/store.d.ts +6 -0
- package/dist/core/review/store.js +6 -0
- package/dist/scripts/lib/cdp.js +6 -1
- package/dist/scripts/lib/export-smoke.d.ts +18 -0
- package/dist/scripts/lib/export-smoke.js +73 -0
- package/dist/scripts/new.js +5 -2
- package/dist/scripts/release-check.d.ts +5 -3
- package/dist/scripts/release-check.js +17 -4
- package/dist/scripts/share.d.ts +2 -2
- package/dist/server/api.js +8 -0
- package/dist/server/session.d.ts +5 -1
- package/dist/server/session.js +39 -21
- package/dist/vercel/proxy.js +44 -8
- package/dist/vite/boundary.d.ts +93 -0
- package/dist/vite/boundary.js +218 -0
- package/dist/vite/css-boundary.d.ts +39 -0
- package/dist/vite/css-boundary.js +167 -0
- package/dist/vite/kit.js +15 -6
- package/dist/vite/leaks.d.ts +37 -0
- package/dist/vite/leaks.js +331 -0
- package/dist/vite/plugin.js +2 -1
- package/dist/vite/registry.d.ts +15 -4
- package/dist/vite/registry.js +531 -27
- package/dist/vite/settle.d.ts +27 -0
- package/dist/vite/settle.js +185 -0
- package/package.json +4 -3
- package/shell/ClientViewNote.tsx +18 -0
- package/shell/Guide.tsx +17 -2
- package/shell/Index.tsx +257 -25
- package/shell/audience.test.ts +63 -0
- package/shell/audience.ts +47 -0
- package/shell/hub.ts +36 -0
- package/shell/main.tsx +39 -5
- package/shell/registry.ts +28 -7
- package/shell/registry.virtual.d.ts +12 -4
- package/shell/review/client.ts +16 -4
- package/shell/review/review.css +2 -2
- package/shell/shell.css +50 -3
- package/shell/system.css +5 -0
- package/skills/miles-deploy/SKILL.md +17 -0
- package/skills/miles-new-feature/SKILL.md +1 -1
- package/skills/miles-prototype/SKILL.md +14 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import {
|
|
4
|
+
AUDIENCE_LABEL,
|
|
5
|
+
audienceIn,
|
|
6
|
+
emptyState,
|
|
7
|
+
hiddenFor,
|
|
8
|
+
lensOf,
|
|
9
|
+
slugsFor,
|
|
10
|
+
withAudience,
|
|
11
|
+
} from './audience.ts';
|
|
12
|
+
|
|
13
|
+
const studio = { kind: 'studio' as const };
|
|
14
|
+
const client = { kind: 'client' as const };
|
|
15
|
+
|
|
16
|
+
test('a prototype is client-facing only when the server lists it', () => {
|
|
17
|
+
assert.equal(audienceIn(['a', 'b'], 'a'), 'client');
|
|
18
|
+
assert.equal(audienceIn(['a', 'b'], 'c'), 'internal');
|
|
19
|
+
assert.equal(audienceIn([], 'a'), 'internal');
|
|
20
|
+
assert.deepEqual(AUDIENCE_LABEL, { internal: 'Internal', client: 'Client-facing' });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('switching one prototype changes only it, and switching back restores the list', () => {
|
|
24
|
+
const start = ['b', 'd'];
|
|
25
|
+
const on = withAudience(start, 'c', 'client');
|
|
26
|
+
assert.deepEqual(on, ['b', 'c', 'd']);
|
|
27
|
+
assert.deepEqual(withAudience(on, 'c', 'client'), ['b', 'c', 'd']);
|
|
28
|
+
assert.deepEqual(withAudience(on, 'c', 'internal'), start);
|
|
29
|
+
assert.deepEqual(withAudience(start, 'x', 'internal'), start);
|
|
30
|
+
// The rollback after a failed switch is the switch the other way.
|
|
31
|
+
assert.deepEqual(withAudience(withAudience(start, 'b', 'internal'), 'b', 'client'), start);
|
|
32
|
+
assert.deepEqual(start, ['b', 'd']);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('Studio’s view loads every slug; a Client’s view only the client-facing', () => {
|
|
36
|
+
const all = ['a', 'b', 'c'];
|
|
37
|
+
assert.deepEqual(slugsFor({ view: 'studio', clientFacing: ['b'] }, all), all);
|
|
38
|
+
assert.deepEqual(slugsFor({ view: 'client', clientFacing: ['b'] }, all), ['b']);
|
|
39
|
+
assert.deepEqual(slugsFor({ view: 'client', clientFacing: [] }, all), []);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('Studio’s controls show outside Client view only; the Client view note for Studio only', () => {
|
|
43
|
+
assert.deepEqual(lensOf(studio, 'studio'), { controls: true, clientView: false });
|
|
44
|
+
assert.deepEqual(lensOf(studio, 'client'), { controls: false, clientView: true });
|
|
45
|
+
assert.deepEqual(lensOf(client, 'client'), { controls: false, clientView: false });
|
|
46
|
+
// A Client's stored Client view changes nothing; nobody signed in gets neither.
|
|
47
|
+
assert.deepEqual(lensOf(client, 'studio'), { controls: false, clientView: false });
|
|
48
|
+
assert.deepEqual(lensOf(null, 'studio'), { controls: false, clientView: false });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('the empty index speaks to its view', () => {
|
|
52
|
+
assert.equal(emptyState('studio', 0), 'studio');
|
|
53
|
+
assert.equal(emptyState('client', 0), 'client');
|
|
54
|
+
assert.equal(emptyState('client', 2), null);
|
|
55
|
+
assert.equal(emptyState('studio', 1), null);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('in Client view an internal prototype’s page reads as missing; no answer hides nothing', () => {
|
|
59
|
+
assert.equal(hiddenFor({ view: 'client', clientFacing: ['a'] }, 'b'), true);
|
|
60
|
+
assert.equal(hiddenFor({ view: 'client', clientFacing: ['a'] }, 'a'), false);
|
|
61
|
+
assert.equal(hiddenFor({ view: 'studio', clientFacing: [] }, 'b'), false);
|
|
62
|
+
assert.equal(hiddenFor(null, 'b'), false);
|
|
63
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// What the index decides from the server's answer, kept pure so it is
|
|
2
|
+
// tested (shell/audience.test.ts). The answer is the view the person gets
|
|
3
|
+
// and the client-facing slugs; the server and the gate decide what reaches
|
|
4
|
+
// whom, and nothing here is the boundary.
|
|
5
|
+
import type { Audience, Person, PersonKind } from '../core/review/model';
|
|
6
|
+
|
|
7
|
+
/** The index read (`prototypes`): the view the caller gets, and every client-facing slug. */
|
|
8
|
+
export type HubAnswer = { view: PersonKind; clientFacing: string[] };
|
|
9
|
+
|
|
10
|
+
export const AUDIENCE_LABEL: Record<Audience, string> = { internal: 'Internal', client: 'Client-facing' };
|
|
11
|
+
|
|
12
|
+
export const audienceIn = (clientFacing: readonly string[], slug: string): Audience =>
|
|
13
|
+
clientFacing.includes(slug) ? 'client' : 'internal';
|
|
14
|
+
|
|
15
|
+
/** The client-facing list after one prototype is switched, sorted, each slug once. */
|
|
16
|
+
export function withAudience(clientFacing: readonly string[], slug: string, audience: Audience): string[] {
|
|
17
|
+
const rest = clientFacing.filter((s) => s !== slug);
|
|
18
|
+
return audience === 'client' ? [...rest, slug].sort() : rest;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Which slugs the index loads: every one in Studio's view, only the client-facing in a Client's. */
|
|
22
|
+
export const slugsFor = (answer: HubAnswer, all: readonly string[]): string[] =>
|
|
23
|
+
answer.view === 'studio' ? [...all] : [...answer.clientFacing];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* How the index treats the person: Studio outside Client view sees each
|
|
27
|
+
* prototype's audience and its switch; Studio in Client view sees what a
|
|
28
|
+
* Client sees, with the note to leave it; anyone else sees neither.
|
|
29
|
+
*/
|
|
30
|
+
export function lensOf(me: Pick<Person, 'kind'> | null, view: PersonKind) {
|
|
31
|
+
const studio = me?.kind === 'studio';
|
|
32
|
+
return { controls: studio && view === 'studio', clientView: studio && view === 'client' };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The empty index, by view: Studio's says how to start one; a Client's says nothing is shared yet. Null when not empty. */
|
|
36
|
+
export function emptyState(view: PersonKind, total: number): 'studio' | 'client' | null {
|
|
37
|
+
if (total > 0) return null;
|
|
38
|
+
return view === 'studio' ? 'studio' : 'client';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Whether a prototype's page shows as missing: in Client view (or for a
|
|
43
|
+
* Client), when the prototype is not client-facing. No answer hides nothing,
|
|
44
|
+
* since the gate already refused it to a Client.
|
|
45
|
+
*/
|
|
46
|
+
export const hiddenFor = (answer: HubAnswer | null, slug: string): boolean =>
|
|
47
|
+
!!answer && answer.view === 'client' && !answer.clientFacing.includes(slug);
|
package/shell/hub.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// The index's one read and its one write, over the review API. The index is
|
|
2
|
+
// built from the server's answer (shell/audience.ts): Studio's view loads
|
|
3
|
+
// every slug, then each entry; a Client's view loads only the client-facing
|
|
4
|
+
// entries. An entry that is not there is skipped; one that fails otherwise is counted. Nothing here filters as
|
|
5
|
+
// the boundary: the server and the gate decide what reaches whom.
|
|
6
|
+
import type { Audience, PersonKind } from '../core/review/model';
|
|
7
|
+
import { type HubAnswer, slugsFor } from './audience';
|
|
8
|
+
import { type Entry, everySlug, getEntries } from './registry';
|
|
9
|
+
import { call, type Me, noApi } from './review/client';
|
|
10
|
+
|
|
11
|
+
/** `failed` counts entries that did not load for a reason other than not being there. */
|
|
12
|
+
export type Hub = HubAnswer & { me: Me | null; entries: Entry[]; failed: number };
|
|
13
|
+
|
|
14
|
+
/** Who is signed in and the index read. With no review API at all (a local preview of the build), Studio's view. */
|
|
15
|
+
export async function readHub(viewAs?: PersonKind): Promise<HubAnswer & { me: Me | null }> {
|
|
16
|
+
try {
|
|
17
|
+
const { person } = await call<{ person: Me | null }>('me');
|
|
18
|
+
const answer = await call<HubAnswer>('prototypes', undefined, viewAs ? { viewAs } : {});
|
|
19
|
+
return { me: person, ...answer };
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (noApi(error)) return { me: null, view: 'studio', clientFacing: [] };
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The index, as the server says this person sees it: Client view when `clientView` is on. */
|
|
27
|
+
export async function loadHub(clientView: boolean): Promise<Hub> {
|
|
28
|
+
const answer = await readHub(clientView ? 'client' : undefined);
|
|
29
|
+
// Studio's list failing to load is an error, never an empty index.
|
|
30
|
+
const all = answer.view === 'studio' ? await everySlug() : [];
|
|
31
|
+
return { ...answer, ...(await getEntries(slugsFor(answer, all))) };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Studio's switch: marks one prototype client-facing or internal. */
|
|
35
|
+
export const saveAudience = (prototype: string, audience: Audience) =>
|
|
36
|
+
call<{ prototype: string; audience: Audience }>('prototype.audience', { prototype, audience });
|
package/shell/main.tsx
CHANGED
|
@@ -2,13 +2,17 @@ import { setGuide } from '@kit/dials';
|
|
|
2
2
|
import '@kit/tokens.css';
|
|
3
3
|
import '@kit/base.css';
|
|
4
4
|
import './system.css';
|
|
5
|
-
import { attachLapse } from '@kit/prefs';
|
|
5
|
+
import { attachLapse, isClientView, setClientView } from '@kit/prefs';
|
|
6
6
|
import { lazy, type ReactNode, StrictMode, Suspense } from 'react';
|
|
7
7
|
import { createRoot } from 'react-dom/client';
|
|
8
8
|
import { guideHref } from '../core/feature';
|
|
9
|
+
import { hiddenFor } from './audience';
|
|
10
|
+
import { ClientViewNote } from './ClientViewNote';
|
|
11
|
+
import { readHub } from './hub';
|
|
9
12
|
import { Index } from './Index';
|
|
13
|
+
import { Notice } from './Notice';
|
|
10
14
|
import { Prototype } from './Prototype';
|
|
11
|
-
import {
|
|
15
|
+
import { getEntry, guides } from './registry';
|
|
12
16
|
|
|
13
17
|
const params = new URLSearchParams(location.search);
|
|
14
18
|
// `design-hub export` opens a prototype with ?export: its artboards alone, no
|
|
@@ -29,10 +33,40 @@ if (import.meta.env.DEV && !exporting && params.get('a11y') !== '0') {
|
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
// /<slug>/ is a prototype; /guide/<feature>/ is that feature's walkthrough.
|
|
32
|
-
//
|
|
36
|
+
// `guide`, `api` and `assets` belong to the hub (core/prototype.ts; new.ts refuses them).
|
|
33
37
|
const [slug, sub] = location.pathname.split('/').filter(Boolean);
|
|
34
38
|
const Guide = lazy(() => import('./Guide'));
|
|
35
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The prototype a page opens, or none, and whether Studio's Client view is
|
|
42
|
+
* what hides it: one a client cannot open reads as missing there, as it does
|
|
43
|
+
* for them (the gate refuses it to a Client).
|
|
44
|
+
*/
|
|
45
|
+
async function pageEntry(name: string) {
|
|
46
|
+
const entry = await getEntry(name);
|
|
47
|
+
if (!entry || !isClientView()) return { entry, hidden: false };
|
|
48
|
+
const answer = await readHub('client').catch(() => null);
|
|
49
|
+
const hidden = hiddenFor(answer, name) && answer?.me?.kind === 'studio';
|
|
50
|
+
return { entry: hidden ? undefined : entry, hidden };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Studio in Client view on a prototype a client cannot open: the missing page, with the way back. */
|
|
54
|
+
function HiddenInClientView({ name }: { name: string }) {
|
|
55
|
+
const leave = () => {
|
|
56
|
+
setClientView(false);
|
|
57
|
+
location.reload();
|
|
58
|
+
};
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
<Notice
|
|
62
|
+
title={`No prototype called “${name}”`}
|
|
63
|
+
body="Check the link, or open one from all prototypes."
|
|
64
|
+
/>
|
|
65
|
+
<ClientViewNote onLeave={leave} />
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
36
70
|
let page: ReactNode;
|
|
37
71
|
// Hub pages wear the neutral system look; a prototype keeps the project's tokens.
|
|
38
72
|
if (!slug || slug === 'guide') document.documentElement.classList.add('sys');
|
|
@@ -43,9 +77,9 @@ if (slug === 'guide') {
|
|
|
43
77
|
</Suspense>
|
|
44
78
|
);
|
|
45
79
|
} else if (slug) {
|
|
46
|
-
const entry =
|
|
80
|
+
const { entry, hidden } = await pageEntry(slug);
|
|
47
81
|
if (entry?.feature && guides.has(entry.feature)) setGuide(guideHref(entry.feature));
|
|
48
|
-
page = <Prototype slug={slug} entry={entry} />;
|
|
82
|
+
page = hidden ? <HiddenInClientView name={slug} /> : <Prototype slug={slug} entry={entry} />;
|
|
49
83
|
if (entry && !exporting) {
|
|
50
84
|
const { mountReview } = await import('./review/mount');
|
|
51
85
|
mountReview({ prototype: slug, feature: entry.feature, states: (entry.states ?? []).map((s) => s.name) });
|
package/shell/registry.ts
CHANGED
|
@@ -1,21 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { allSlugs, entryOf, guideDocs } from 'virtual:design-hub/registry';
|
|
2
2
|
import type { ComponentType } from 'react';
|
|
3
3
|
import { byIndexOrder, type Meta, readMeta } from '../core/catalog';
|
|
4
|
+
import { isPrototypeSlug } from '../core/prototype';
|
|
4
5
|
import type { Doc } from './doc';
|
|
5
6
|
|
|
6
7
|
export type Entry = Meta & { load?: () => Promise<{ default: ComponentType }> };
|
|
7
8
|
|
|
8
9
|
// The registry module is written by the Vite plugin (vite/registry.ts) from
|
|
9
|
-
// the project's prototypes/ and docs/sprints/ folders.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.sort(byIndexOrder);
|
|
10
|
+
// the project's prototypes/ and docs/sprints/ folders. In a build every
|
|
11
|
+
// prototype is a file of its own, fetched by path, so what reaches this page
|
|
12
|
+
// is what the gate let through.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/** One prototype's entry; undefined when the name is no slug or there is none (the gate refused it). Any other failure throws. */
|
|
15
|
+
async function readEntry(slug: string): Promise<Entry | undefined> {
|
|
16
|
+
if (!isPrototypeSlug(slug)) return undefined;
|
|
17
|
+
const found = await entryOf(slug);
|
|
18
|
+
return found ? { ...readMeta(slug, found.readme), load: found.load } : undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** One prototype's entry for its page; undefined when it is not there or did not load. */
|
|
22
|
+
export const getEntry = (slug: string): Promise<Entry | undefined> => readEntry(slug).catch(() => undefined);
|
|
23
|
+
|
|
24
|
+
/** The entries for these slugs, in index order: one that is not there is skipped, one that fails otherwise is counted. */
|
|
25
|
+
export async function getEntries(slugs: readonly string[]): Promise<{ entries: Entry[]; failed: number }> {
|
|
26
|
+
const loaded = await Promise.allSettled(slugs.map(readEntry));
|
|
27
|
+
const entries = loaded
|
|
28
|
+
.map((r) => (r.status === 'fulfilled' ? r.value : undefined))
|
|
29
|
+
.filter((e): e is Entry => e !== undefined)
|
|
30
|
+
.sort(byIndexOrder);
|
|
31
|
+
return { entries, failed: loaded.filter((r) => r.status === 'rejected').length };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Every slug, for Studio's view. Built, `_p/all.js` is Studio's alone; a failure to load it throws. */
|
|
35
|
+
export const everySlug = (): Promise<string[]> => allSlugs();
|
|
15
36
|
|
|
16
37
|
export const guides = new Map<string, () => Promise<Doc>>(Object.entries(guideDocs));
|
|
17
38
|
|
|
18
39
|
// The prototype a feature's walkthrough opens: the sprint itself, else the first one listed.
|
|
19
|
-
export const featureEntry = (feature: string) =>
|
|
40
|
+
export const featureEntry = (entries: readonly Entry[], feature: string) =>
|
|
20
41
|
entries.find((e) => e.feature === feature && e.kind === 'sprint') ??
|
|
21
42
|
entries.find((e) => e.feature === feature);
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
declare module 'virtual:design-hub/registry' {
|
|
2
2
|
import type { ComponentType } from 'react';
|
|
3
3
|
import type { Doc } from './doc';
|
|
4
|
-
/**
|
|
5
|
-
export
|
|
6
|
-
/**
|
|
7
|
-
|
|
4
|
+
/** One prototype's entry: its README text, and its module loader, absent when the folder has no index.tsx. */
|
|
5
|
+
export type RegistryEntry = { readme: string; load?: () => Promise<{ default: ComponentType }> };
|
|
6
|
+
/**
|
|
7
|
+
* Every prototype's slug. Built, this loads `_p/all.js`, which the gate
|
|
8
|
+
* gives Studio only; for a Client it fails.
|
|
9
|
+
*/
|
|
10
|
+
export function allSlugs(): Promise<string[]>;
|
|
11
|
+
/**
|
|
12
|
+
* One prototype's entry. Served, null for a slug with no prototype. Built,
|
|
13
|
+
* it loads `_p/<slug>/entry.js` and fails where the gate refuses it or there is none.
|
|
14
|
+
*/
|
|
15
|
+
export function entryOf(slug: string): Promise<RegistryEntry | null>;
|
|
8
16
|
/** Each feature's compiled walkthrough loader, by feature. */
|
|
9
17
|
export const guideDocs: Record<string, () => Promise<Doc>>;
|
|
10
18
|
}
|
package/shell/review/client.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
// The review UI's one store
|
|
1
|
+
// The review UI's one store, and the one way to the API (`call`), which the
|
|
2
|
+
// index uses too: who is signed in, this prototype's comments and,
|
|
2
3
|
// for Studio, the people. Components read it with useSyncExternalStore and
|
|
3
4
|
// call its actions; every call goes to /api/review (server/api.ts), and each
|
|
4
5
|
// answer is merged in place, so a write never refetches the list. The list is
|
|
@@ -25,6 +26,8 @@ class ApiError extends Error {
|
|
|
25
26
|
problems: string[];
|
|
26
27
|
/** A 503 with Retry-After: the store did not answer, and review is on. */
|
|
27
28
|
retry: boolean;
|
|
29
|
+
/** The answer was not JSON: no review API answered (`vite preview` serves its page instead). */
|
|
30
|
+
notJson = false;
|
|
28
31
|
constructor(status: number, message: string, problems: string[] = [], retry = false) {
|
|
29
32
|
super(message);
|
|
30
33
|
this.status = status;
|
|
@@ -38,7 +41,7 @@ const API = '/api/review';
|
|
|
38
41
|
/** For a click handler: the store shows every failure in the panel, so the handler has nothing left to do with one. */
|
|
39
42
|
export const act = (pending: Promise<unknown>) => void pending.catch(() => {});
|
|
40
43
|
|
|
41
|
-
async function call<T>(
|
|
44
|
+
export async function call<T>(
|
|
42
45
|
op: string,
|
|
43
46
|
body?: Record<string, unknown>,
|
|
44
47
|
params: Record<string, string> = {},
|
|
@@ -56,8 +59,14 @@ async function call<T>(
|
|
|
56
59
|
| null;
|
|
57
60
|
if (response.status === 503 && response.headers.has('retry-after'))
|
|
58
61
|
throw new ApiError(503, 'The review store did not answer. Reload in a minute.', [], true);
|
|
59
|
-
if (!json)
|
|
60
|
-
|
|
62
|
+
if (!json) {
|
|
63
|
+
const error = new ApiError(
|
|
64
|
+
response.status,
|
|
65
|
+
`The review API did not answer with JSON (${response.status}).`,
|
|
66
|
+
);
|
|
67
|
+
error.notJson = true;
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
61
70
|
if (!response.ok)
|
|
62
71
|
throw new ApiError(response.status, json.error ?? `Request failed (${response.status}).`, json.problems);
|
|
63
72
|
return json;
|
|
@@ -70,6 +79,9 @@ async function call<T>(
|
|
|
70
79
|
const isOff = (error: unknown) =>
|
|
71
80
|
error instanceof ApiError && !error.retry && (error.status === 503 || error.status === 404);
|
|
72
81
|
|
|
82
|
+
/** No review API at all: none set up (`isOff`), or an answer that is not the API's (a static preview's page). */
|
|
83
|
+
export const noApi = (error: unknown) => isOff(error) || (error instanceof ApiError && error.notJson);
|
|
84
|
+
|
|
73
85
|
export function createReviewStore(prototype: string) {
|
|
74
86
|
let state: State = { status: 'loading', me: null, comments: [], people: null, access: null, error: null };
|
|
75
87
|
const listeners = new Set<() => void>();
|
package/shell/review/review.css
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
--rv-mark: oklch(0.55 0 0); /* on the page: mid grey holds on light and dark */
|
|
22
22
|
--rv-pin: oklch(0.205 0 0);
|
|
23
23
|
--rv-done: oklch(0.8 0.13 155); /* resolved: green, on its check alone */
|
|
24
|
-
--rv-internal:
|
|
25
|
-
--rv-on-internal:
|
|
24
|
+
--rv-internal: var(--sys-internal); /* internal: the amber of a support tool's internal note (system.css) */
|
|
25
|
+
--rv-on-internal: var(--sys-on-internal); /* the label on amber, 8:1 */
|
|
26
26
|
--rv-internal-chip: oklch(0.35 0.06 85); /* the Internal tag on the card: a solid low tint, not amber at low opacity */
|
|
27
27
|
--rv-internal-chip-fg: oklch(0.88 0.12 85); /* 8:1 on the chip */
|
|
28
28
|
--rv-danger: oklch(0.779 0.131 23.4);
|
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
|
|
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:
|