@brucesantos/design-space 0.2.0 → 0.4.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.
@@ -1,9 +1,22 @@
1
- import { Fixture, Flow, Module, Persona, ProductDefinition, Rule, Scenario, ScenarioStatus } from '../types/index.js';
1
+ import { ComponentPreview, ComponentPreviewFixture, Fixture, Flow, Module, Persona, ProductDefinition, Rule, Scenario, ScenarioStatus } from '../types/index.js';
2
2
  import { ValidationIssue } from './validate.js';
3
3
  export type ModuleNode = {
4
4
  module: Module;
5
5
  scenarios: Scenario[];
6
6
  };
7
+ export type ScenarioQueryOptions = {
8
+ /** Inclui material importado ainda não validado. Padrão: `false`. */
9
+ includePorted?: boolean;
10
+ /** Exceção para manter compreensível um portado aberto por deep link. */
11
+ activeScenario?: string;
12
+ };
13
+ export type ComponentFixtureResolution = {
14
+ fixture: ComponentPreviewFixture | undefined;
15
+ /** Id que veio da URL, inclusive quando não existe. */
16
+ requestedId: string | undefined;
17
+ /** `true` quando a URL pediu um id inexistente e o motor usou o fallback. */
18
+ didFallback: boolean;
19
+ };
7
20
  export type Registry = {
8
21
  product: ProductDefinition;
9
22
  /** Árvore de navegação: módulos com seus cenários, na ordem declarada. */
@@ -12,6 +25,9 @@ export type Registry = {
12
25
  orphans: Scenario[];
13
26
  issues: ValidationIssue[];
14
27
  scenario: (id: string | undefined) => Scenario | undefined;
28
+ component: (id: string | undefined) => ComponentPreview | undefined;
29
+ componentFixture: (componentId: string | undefined, fixtureId: string | undefined) => ComponentPreviewFixture | undefined;
30
+ resolveComponentFixture: (componentId: string | undefined, requestedId: string | undefined) => ComponentFixtureResolution;
15
31
  persona: (id: string | undefined) => Persona | undefined;
16
32
  fixture: (id: string | undefined) => Fixture | undefined;
17
33
  rule: (id: string | undefined) => Rule | undefined;
@@ -22,14 +38,19 @@ export type Registry = {
22
38
  /** Permissões efetivas: as do cenário, ou as da persona quando ausentes. */
23
39
  permissionsOf: (scenario: Scenario | undefined) => string[];
24
40
  /** Cenários que abrem a mesma rota. Serve para o seletor de situação. */
25
- scenariosForRoute: (route: string) => Scenario[];
41
+ scenariosForRoute: (route: string, options?: ScenarioQueryOptions) => Scenario[];
42
+ /** Cenários que contam como trabalho ativo; portados ficam fora por padrão. */
43
+ activeScenarios: (options?: ScenarioQueryOptions) => Scenario[];
44
+ /** Árvore filtrada para navegação, preservando `tree` como catálogo completo. */
45
+ treeFor: (options?: ScenarioQueryOptions) => ModuleNode[];
46
+ orphansFor: (options?: ScenarioQueryOptions) => Scenario[];
26
47
  /**
27
48
  * Busca por vocabulário de negócio. Um PO precisa achar "aprovação bloqueada"
28
49
  * sem saber o id nem o nome do arquivo (§15.1 "Compreensão de negócio").
29
50
  */
30
- search: (query: string) => Scenario[];
51
+ search: (query: string, options?: ScenarioQueryOptions) => Scenario[];
31
52
  byStatus: (status: ScenarioStatus) => Scenario[];
32
53
  /** Contagem por status, para o cabeçalho de cobertura. */
33
- coverage: () => Record<ScenarioStatus, number>;
54
+ coverage: (options?: ScenarioQueryOptions) => Record<ScenarioStatus, number>;
34
55
  };
35
56
  export declare function createRegistry(product: ProductDefinition): Registry;
@@ -1,8 +1,11 @@
1
- import { Registry } from '../registry/index.js';
2
- import { ControlsState } from '../types/index.js';
1
+ import { ComponentFixtureResolution, Registry } from '../registry/index.js';
2
+ import { ComponentPreview, ControlsState } from '../types/index.js';
3
3
  export type ControlsProps = {
4
4
  registry: Registry;
5
5
  controls: ControlsState;
6
+ scenarioActive: boolean;
7
+ component?: ComponentPreview;
8
+ componentFixture?: ComponentFixtureResolution;
6
9
  onChange: (patch: Partial<ControlsState>) => void;
7
10
  };
8
- export declare function Controls({ registry, controls, onChange }: ControlsProps): import("react").JSX.Element;
11
+ export declare function Controls({ registry, controls, scenarioActive, component, componentFixture, onChange, }: ControlsProps): import("react").JSX.Element;
@@ -2,5 +2,6 @@ import { Registry } from '../registry/index.js';
2
2
  export type HomeProps = {
3
3
  registry: Registry;
4
4
  onOpenScenario: (scenarioId: string) => void;
5
+ showPorted?: boolean;
5
6
  };
6
- export declare function Home({ registry, onOpenScenario }: HomeProps): import("react").JSX.Element;
7
+ export declare function Home({ registry, onOpenScenario, showPorted }: HomeProps): import("react").JSX.Element;
@@ -1,11 +1,13 @@
1
- import { Registry } from '../registry/index.js';
1
+ import { ComponentFixtureResolution, Registry } from '../registry/index.js';
2
2
  import { AccessibleNode } from '../a11y/accessible-tree.js';
3
- import { ControlsState, Scenario } from '../types/index.js';
3
+ import { ComponentPreview, ControlsState, Scenario } from '../types/index.js';
4
4
  export type InspectorProps = {
5
5
  registry: Registry;
6
6
  scenario: Scenario | undefined;
7
+ component?: ComponentPreview;
8
+ componentFixture?: ComponentFixtureResolution;
7
9
  controls: ControlsState;
8
10
  focusedNode: AccessibleNode | undefined;
9
11
  tabStopCount: number;
10
12
  };
11
- export declare function Inspector({ registry, scenario, controls, focusedNode, tabStopCount, }: InspectorProps): import("react").JSX.Element;
13
+ export declare function Inspector({ registry, scenario, component, componentFixture, controls, focusedNode, tabStopCount, }: InspectorProps): import("react").JSX.Element;
@@ -1,7 +1,14 @@
1
1
  import { Registry } from '../registry/index.js';
2
+ import { ControlsState, Scenario } from '../types/index.js';
2
3
  export type SidebarProps = {
3
4
  registry: Registry;
4
- activeScenario: string | undefined;
5
+ activeScenario: Scenario | undefined;
6
+ activeComponent: string | undefined;
7
+ controls: ControlsState;
5
8
  onOpenScenario: (scenarioId: string) => void;
9
+ onOpenComponent: (componentId: string) => void;
10
+ onShowPortedChange: (showPorted: boolean) => void;
6
11
  };
7
- export declare function Sidebar({ registry, activeScenario, onOpenScenario }: SidebarProps): import("react").JSX.Element;
12
+ export declare function Sidebar({ registry, activeScenario, activeComponent, controls, onOpenScenario, onOpenComponent, onShowPortedChange, }: SidebarProps): import("react").JSX.Element;
13
+ export declare function isSearchShortcut(event: Pick<KeyboardEvent, "key" | "metaKey" | "ctrlKey" | "altKey" | "shiftKey">): boolean;
14
+ export declare function nextItemId(ids: string[], currentId: string | undefined, offset: number): string | undefined;
@@ -1,13 +1,15 @@
1
1
  import { DeployContext } from '../deploy/index.js';
2
- import { ProductDefinition, Scenario } from '../types/index.js';
2
+ import { ChromeTheme, ProductDefinition, Scenario } from '../types/index.js';
3
3
  export type TopbarProps = {
4
4
  product: ProductDefinition;
5
5
  scenario: Scenario | undefined;
6
6
  deploy: DeployContext;
7
7
  inspectorOpen: boolean;
8
- sidebarOpen: boolean;
8
+ chromeTheme: ChromeTheme;
9
+ showPorted: boolean;
9
10
  onToggleInspector: () => void;
10
- onToggleSidebar: () => void;
11
- onHideChrome: () => void;
11
+ onToggleChromeTheme: () => void;
12
12
  };
13
- export declare function Topbar({ product, scenario, deploy, inspectorOpen, sidebarOpen, onToggleInspector, onToggleSidebar, onHideChrome, }: TopbarProps): import("react").JSX.Element;
13
+ export declare function Topbar({ product, scenario, deploy, inspectorOpen, chromeTheme, showPorted, onToggleInspector, onToggleChromeTheme, }: TopbarProps): import("react").JSX.Element;
14
+ export declare function buildCleanReviewUrl(href: string): string;
15
+ export declare function buildHomeUrl(origin: string, chromeTheme: ChromeTheme, showPorted?: boolean): string;
@@ -7,6 +7,7 @@ export type Labels = {
7
7
  /** Rótulo de viewport por id: `fit`, `mobile`, `tablet`, `desktop`, `custom`. */
8
8
  viewport: Record<string, string>;
9
9
  topbar: {
10
+ homeTitle: (product: string) => string;
10
11
  toggleNav: string;
11
12
  copyLink: string;
12
13
  copied: string;
@@ -14,23 +15,40 @@ export type Labels = {
14
15
  cleanReview: string;
15
16
  cleanReviewTitle: string;
16
17
  panel: string;
18
+ lightMode: string;
19
+ darkMode: string;
17
20
  branchTitle: (branch: string) => string;
18
21
  commitTitle: (commit: string) => string;
19
22
  envTitle: (env: string) => string;
20
23
  };
21
24
  sidebar: {
22
25
  region: string;
26
+ flowsTab: string;
27
+ componentsTab: string;
23
28
  searchPlaceholder: string;
24
29
  searchLabel: string;
30
+ componentSearchPlaceholder: string;
31
+ componentSearchLabel: string;
32
+ searchShortcut: string;
25
33
  noMatch: (query: string) => string;
26
34
  matchCount: (total: number) => string;
35
+ noComponentMatch: (query: string) => string;
36
+ componentMatchCount: (total: number) => string;
37
+ showPorted: string;
38
+ activePorted: string;
27
39
  emptyModule: string;
40
+ emptyComponents: string;
28
41
  withoutModule: string;
42
+ scope: string;
43
+ scopeData: string;
44
+ scopePersona: string;
45
+ scopeNetwork: string;
29
46
  };
30
47
  controls: {
31
48
  region: string;
32
49
  persona: string;
33
50
  fixture: string;
51
+ componentFixture: string;
34
52
  network: string;
35
53
  viewport: string;
36
54
  customWidth: string;
@@ -53,6 +71,11 @@ export type Labels = {
53
71
  tabDiagnostics: string;
54
72
  diagnosticsWithErrors: (count: number) => string;
55
73
  noScenario: string;
74
+ componentReference: string;
75
+ componentGroup: string;
76
+ componentFixture: string;
77
+ componentFixtureDescription: string;
78
+ componentFixtureFallback: (requested: string, fallback: string) => string;
56
79
  situation: string;
57
80
  reproduction: string;
58
81
  id: string;
@@ -103,6 +126,7 @@ export type Labels = {
103
126
  withoutModuleHint: string;
104
127
  emptyModule: string;
105
128
  keyboardBadge: string;
129
+ noActiveWork: string;
106
130
  };
107
131
  shell: {
108
132
  restoreChrome: string;
@@ -112,6 +136,8 @@ export type Labels = {
112
136
  };
113
137
  /** Português. É o padrão, não uma obrigação. */
114
138
  export declare const DEFAULT_LABELS: Labels;
139
+ /** English (United States), selectable by the product through `theme.labels`. */
140
+ export declare const EN_US_LABELS: Labels;
115
141
  /** Override por grupo. O que não vier declarado fica no padrão. */
116
142
  export type LabelsOverride = {
117
143
  [Group in keyof Labels]?: Partial<Labels[Group]>;
@@ -26,10 +26,10 @@ export declare function pathFor(scenario: Scenario, overrides?: Partial<Controls
26
26
  /**
27
27
  * Cenários que valem uma jornada automatizada.
28
28
  *
29
- * Deliberadamente não é "todos": rodar Playwright em cenário `proposed`
30
- * transforma exploração em trabalho de manutenção de teste, que é o oposto de
31
- * "governança proporcional" (Princípio 9). O piso é o cenário que já foi
32
- * aprovado ou já existe em produção.
29
+ * Deliberadamente não é "todos": rodar Playwright em cenário `ported` ou
30
+ * `proposed` transforma importação ou exploração em trabalho de manutenção de
31
+ * teste, que é o oposto de "governança proporcional" (Princípio 9). O piso é o
32
+ * cenário que já foi aprovado ou já existe em produção.
33
33
  */
34
34
  export declare function scenariosUnderTest(product: ProductDefinition, statuses?: ScenarioStatus[]): Scenario[];
35
35
  /** Cenários que declaram jornada completável só por teclado. */
package/dist/testing.js CHANGED
@@ -1,11 +1,11 @@
1
- import { v as n, j as o, i, s as t } from "./contrast-BXd_acxo.js";
2
- import { b as v, d as P, c as g, f as E } from "./contrast-BXd_acxo.js";
3
- function a(e = "http://localhost:5173") {
1
+ import { v as n, k as o, j as a, s as t } from "./contrast-B8I8gWGa.js";
2
+ import { b as v, d as P, c as g, h as k } from "./contrast-B8I8gWGa.js";
3
+ function i(e = "http://localhost:5173") {
4
4
  const r = typeof process < "u" ? process.env : {};
5
5
  return (r.PREVIEW_URL || r.BASE_URL || e).replace(/\/$/, "");
6
6
  }
7
7
  function u(e, r = {}) {
8
- return t(e, { origin: r.origin ?? a(), overrides: r.overrides });
8
+ return t(e, { origin: r.origin ?? i(), overrides: r.overrides });
9
9
  }
10
10
  function d(e, r = {}) {
11
11
  const s = new URL(t(e, { origin: "http://design-space.invalid", overrides: r }));
@@ -21,21 +21,21 @@ function p(e) {
21
21
  const r = n(e);
22
22
  if (o(r))
23
23
  throw new Error(`Contrato de cenário inválido:
24
- ${i(r)}`);
24
+ ${a(r)}`);
25
25
  }
26
26
  export {
27
27
  v as assertContrastPairs,
28
28
  p as assertValidProduct,
29
29
  P as checkContrastPair,
30
30
  g as checkContrastPairs,
31
- E as contrastRatio,
32
- i as formatIssues,
31
+ k as contrastRatio,
32
+ a as formatIssues,
33
33
  o as hasErrors,
34
34
  f as keyboardScenarios,
35
35
  d as pathFor,
36
36
  t as scenarioUrl,
37
37
  l as scenariosUnderTest,
38
- a as testOrigin,
38
+ i as testOrigin,
39
39
  u as urlFor,
40
40
  n as validateProduct
41
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","sources":["../src/testing/index.ts"],"sourcesContent":["/**\n * `@brucesantos/design-space/testing`\n *\n * Utilitários para os testes do produto. Vive num entrypoint separado porque\n * nada aqui deve chegar ao bundle do preview.\n *\n * O que este módulo assume: o preview é público, sem proteção de acesso (D-11).\n * Como não há segredo de bypass nem header de automação a emitir, o Playwright\n * aponta direto para a URL do preview — e é por isso que estas funções só\n * precisam de uma origem.\n */\n\nimport { scenarioUrl } from \"../deploy/index.js\";\nimport { validateProduct, hasErrors, formatIssues } from \"../registry/validate.js\";\nimport {\n assertContrastPairs,\n checkContrastPair,\n checkContrastPairs,\n contrastRatio,\n} from \"../a11y/contrast.js\";\nimport type { ControlsState, ProductDefinition, Scenario, ScenarioStatus } from \"../types/index.js\";\n\n/**\n * Origem contra a qual os testes rodam.\n *\n * `PREVIEW_URL` é o que o gatilho `deployment_status` do GitHub Actions entrega\n * pronto (§10.6), o que dispensa qualquer lógica de descobrir onde o preview foi\n * publicado. Sem ela, cai no dev server local.\n */\nexport function testOrigin(fallback = \"http://localhost:5173\"): string {\n const env = typeof process !== \"undefined\" ? process.env : {};\n const url = env.PREVIEW_URL || env.BASE_URL || fallback;\n return url.replace(/\\/$/, \"\");\n}\n\n/** URL absoluta de um cenário para uso em `page.goto`. */\nexport function urlFor(\n scenario: Scenario,\n options: { origin?: string; overrides?: Partial<ControlsState> } = {},\n): string {\n return scenarioUrl(scenario, { origin: options.origin ?? testOrigin(), overrides: options.overrides });\n}\n\n/**\n * Caminho relativo de um cenário: `/rota?scenario=…`.\n *\n * É a forma preferida em Playwright, porque deixa o `baseURL` da configuração\n * decidir se o teste roda contra o preview ou contra o dev server. Um teste que\n * embute a origem passa a existir em duas versões, e a versão local é a que\n * ninguém roda.\n */\nexport function pathFor(\n scenario: Scenario,\n overrides: Partial<ControlsState> = {},\n): string {\n const url = new URL(scenarioUrl(scenario, { origin: \"http://design-space.invalid\", overrides }));\n return `${url.pathname}${url.search}`;\n}\n\n/**\n * Cenários que valem uma jornada automatizada.\n *\n * Deliberadamente não é \"todos\": rodar Playwright em cenário `proposed`\n * transforma exploração em trabalho de manutenção de teste, que é o oposto de\n * \"governança proporcional\" (Princípio 9). O piso é o cenário que já foi\n * aprovado ou já existe em produção.\n */\nexport function scenariosUnderTest(\n product: ProductDefinition,\n statuses: ScenarioStatus[] = [\"approved\", \"in-implementation\", \"implemented\"],\n): Scenario[] {\n return product.scenarios.filter((scenario) => statuses.includes(scenario.status));\n}\n\n/** Cenários que declaram jornada completável só por teclado. */\nexport function keyboardScenarios(product: ProductDefinition): Scenario[] {\n return product.scenarios.filter((scenario) => scenario.a11y.keyboard === \"full\");\n}\n\n/**\n * Falha o teste quando o contrato de cenário do produto tem erro.\n *\n * É o equivalente do typecheck para o que o TypeScript não alcança: fixture\n * inexistente, persona escrita errada, rota que não casa com nada.\n */\nexport function assertValidProduct(product: ProductDefinition): void {\n const issues = validateProduct(product);\n if (hasErrors(issues)) {\n throw new Error(`Contrato de cenário inválido:\\n${formatIssues(issues)}`);\n }\n}\n\n// Medição de contraste também é ferramenta de teste: o produto valida os\n// próprios tokens, e o motor só sabe medir.\nexport {\n assertContrastPairs,\n checkContrastPair,\n checkContrastPairs,\n contrastRatio,\n formatIssues,\n hasErrors,\n validateProduct,\n};\nexport { scenarioUrl } from \"../deploy/index.js\";\n"],"names":["testOrigin","fallback","env","urlFor","scenario","options","scenarioUrl","pathFor","overrides","url","scenariosUnderTest","product","statuses","keyboardScenarios","assertValidProduct","issues","validateProduct","hasErrors","formatIssues"],"mappings":";;AA6BO,SAASA,EAAWC,IAAW,yBAAiC;AACrE,QAAMC,IAAM,OAAO,UAAY,MAAc,QAAQ,MAAM,CAAA;AAE3D,UADYA,EAAI,eAAeA,EAAI,YAAYD,GACpC,QAAQ,OAAO,EAAE;AAC9B;AAGO,SAASE,EACdC,GACAC,IAAmE,IAC3D;AACR,SAAOC,EAAYF,GAAU,EAAE,QAAQC,EAAQ,UAAUL,KAAc,WAAWK,EAAQ,UAAA,CAAW;AACvG;AAUO,SAASE,EACdH,GACAI,IAAoC,IAC5B;AACR,QAAMC,IAAM,IAAI,IAAIH,EAAYF,GAAU,EAAE,QAAQ,+BAA+B,WAAAI,EAAA,CAAW,CAAC;AAC/F,SAAO,GAAGC,EAAI,QAAQ,GAAGA,EAAI,MAAM;AACrC;AAUO,SAASC,EACdC,GACAC,IAA6B,CAAC,YAAY,qBAAqB,aAAa,GAChE;AACZ,SAAOD,EAAQ,UAAU,OAAO,CAACP,MAAaQ,EAAS,SAASR,EAAS,MAAM,CAAC;AAClF;AAGO,SAASS,EAAkBF,GAAwC;AACxE,SAAOA,EAAQ,UAAU,OAAO,CAACP,MAAaA,EAAS,KAAK,aAAa,MAAM;AACjF;AAQO,SAASU,EAAmBH,GAAkC;AACnE,QAAMI,IAASC,EAAgBL,CAAO;AACtC,MAAIM,EAAUF,CAAM;AAClB,UAAM,IAAI,MAAM;AAAA,EAAkCG,EAAaH,CAAM,CAAC,EAAE;AAE5E;"}
1
+ {"version":3,"file":"testing.js","sources":["../src/testing/index.ts"],"sourcesContent":["/**\n * `@brucesantos/design-space/testing`\n *\n * Utilitários para os testes do produto. Vive num entrypoint separado porque\n * nada aqui deve chegar ao bundle do preview.\n *\n * O que este módulo assume: o preview é público, sem proteção de acesso (D-11).\n * Como não há segredo de bypass nem header de automação a emitir, o Playwright\n * aponta direto para a URL do preview — e é por isso que estas funções só\n * precisam de uma origem.\n */\n\nimport { scenarioUrl } from \"../deploy/index.js\";\nimport { validateProduct, hasErrors, formatIssues } from \"../registry/validate.js\";\nimport {\n assertContrastPairs,\n checkContrastPair,\n checkContrastPairs,\n contrastRatio,\n} from \"../a11y/contrast.js\";\nimport type { ControlsState, ProductDefinition, Scenario, ScenarioStatus } from \"../types/index.js\";\n\n/**\n * Origem contra a qual os testes rodam.\n *\n * `PREVIEW_URL` é o que o gatilho `deployment_status` do GitHub Actions entrega\n * pronto (§10.6), o que dispensa qualquer lógica de descobrir onde o preview foi\n * publicado. Sem ela, cai no dev server local.\n */\nexport function testOrigin(fallback = \"http://localhost:5173\"): string {\n const env = typeof process !== \"undefined\" ? process.env : {};\n const url = env.PREVIEW_URL || env.BASE_URL || fallback;\n return url.replace(/\\/$/, \"\");\n}\n\n/** URL absoluta de um cenário para uso em `page.goto`. */\nexport function urlFor(\n scenario: Scenario,\n options: { origin?: string; overrides?: Partial<ControlsState> } = {},\n): string {\n return scenarioUrl(scenario, { origin: options.origin ?? testOrigin(), overrides: options.overrides });\n}\n\n/**\n * Caminho relativo de um cenário: `/rota?scenario=…`.\n *\n * É a forma preferida em Playwright, porque deixa o `baseURL` da configuração\n * decidir se o teste roda contra o preview ou contra o dev server. Um teste que\n * embute a origem passa a existir em duas versões, e a versão local é a que\n * ninguém roda.\n */\nexport function pathFor(\n scenario: Scenario,\n overrides: Partial<ControlsState> = {},\n): string {\n const url = new URL(scenarioUrl(scenario, { origin: \"http://design-space.invalid\", overrides }));\n return `${url.pathname}${url.search}`;\n}\n\n/**\n * Cenários que valem uma jornada automatizada.\n *\n * Deliberadamente não é \"todos\": rodar Playwright em cenário `ported` ou\n * `proposed` transforma importação ou exploração em trabalho de manutenção de\n * teste, que é o oposto de \"governança proporcional\" (Princípio 9). O piso é o\n * cenário que já foi aprovado ou já existe em produção.\n */\nexport function scenariosUnderTest(\n product: ProductDefinition,\n statuses: ScenarioStatus[] = [\"approved\", \"in-implementation\", \"implemented\"],\n): Scenario[] {\n return product.scenarios.filter((scenario) => statuses.includes(scenario.status));\n}\n\n/** Cenários que declaram jornada completável só por teclado. */\nexport function keyboardScenarios(product: ProductDefinition): Scenario[] {\n return product.scenarios.filter((scenario) => scenario.a11y.keyboard === \"full\");\n}\n\n/**\n * Falha o teste quando o contrato de cenário do produto tem erro.\n *\n * É o equivalente do typecheck para o que o TypeScript não alcança: fixture\n * inexistente, persona escrita errada, rota que não casa com nada.\n */\nexport function assertValidProduct(product: ProductDefinition): void {\n const issues = validateProduct(product);\n if (hasErrors(issues)) {\n throw new Error(`Contrato de cenário inválido:\\n${formatIssues(issues)}`);\n }\n}\n\n// Medição de contraste também é ferramenta de teste: o produto valida os\n// próprios tokens, e o motor só sabe medir.\nexport {\n assertContrastPairs,\n checkContrastPair,\n checkContrastPairs,\n contrastRatio,\n formatIssues,\n hasErrors,\n validateProduct,\n};\nexport { scenarioUrl } from \"../deploy/index.js\";\n"],"names":["testOrigin","fallback","env","urlFor","scenario","options","scenarioUrl","pathFor","overrides","url","scenariosUnderTest","product","statuses","keyboardScenarios","assertValidProduct","issues","validateProduct","hasErrors","formatIssues"],"mappings":";;AA6BO,SAASA,EAAWC,IAAW,yBAAiC;AACrE,QAAMC,IAAM,OAAO,UAAY,MAAc,QAAQ,MAAM,CAAA;AAE3D,UADYA,EAAI,eAAeA,EAAI,YAAYD,GACpC,QAAQ,OAAO,EAAE;AAC9B;AAGO,SAASE,EACdC,GACAC,IAAmE,IAC3D;AACR,SAAOC,EAAYF,GAAU,EAAE,QAAQC,EAAQ,UAAUL,KAAc,WAAWK,EAAQ,UAAA,CAAW;AACvG;AAUO,SAASE,EACdH,GACAI,IAAoC,IAC5B;AACR,QAAMC,IAAM,IAAI,IAAIH,EAAYF,GAAU,EAAE,QAAQ,+BAA+B,WAAAI,EAAA,CAAW,CAAC;AAC/F,SAAO,GAAGC,EAAI,QAAQ,GAAGA,EAAI,MAAM;AACrC;AAUO,SAASC,EACdC,GACAC,IAA6B,CAAC,YAAY,qBAAqB,aAAa,GAChE;AACZ,SAAOD,EAAQ,UAAU,OAAO,CAACP,MAAaQ,EAAS,SAASR,EAAS,MAAM,CAAC;AAClF;AAGO,SAASS,EAAkBF,GAAwC;AACxE,SAAOA,EAAQ,UAAU,OAAO,CAACP,MAAaA,EAAS,KAAK,aAAa,MAAM;AACjF;AAQO,SAASU,EAAmBH,GAAkC;AACnE,QAAMI,IAASC,EAAgBL,CAAO;AACtC,MAAIM,EAAUF,CAAM;AAClB,UAAM,IAAI,MAAM;AAAA,EAAkCG,EAAaH,CAAM,CAAC,EAAE;AAE5E;"}
@@ -4,7 +4,7 @@ import { LabelsOverride } from '../shell/labels.js';
4
4
  * Estado de ciclo de vida do cenário (§18.1). Existe para evitar que a
5
5
  * referência envelheça em silêncio quando o produto real muda.
6
6
  */
7
- export type ScenarioStatus = "proposed" | "in-review" | "approved" | "in-implementation" | "implemented" | "superseded";
7
+ export type ScenarioStatus = "ported" | "proposed" | "in-review" | "approved" | "in-implementation" | "implemented" | "superseded";
8
8
  export declare const SCENARIO_STATUSES: readonly ScenarioStatus[];
9
9
  /** Nível de conformidade alvo. O padrão interno é WCAG 2.2 AA. */
10
10
  export type ContrastTarget = "AA" | "AAA";
@@ -167,6 +167,51 @@ export type ScreenProps = {
167
167
  /** Contexto do cenário ativo, resolvido pelo motor. */
168
168
  context: ScenarioContext;
169
169
  };
170
+ /**
171
+ * Componente do produto exposto no catálogo do Design Space.
172
+ *
173
+ * O motor só organiza e renderiza a referência. Implementação, aparência e
174
+ * conteúdo continuam no repositório do produto.
175
+ */
176
+ export type ComponentPreviewFixture<T = unknown> = {
177
+ /** Identificador estável, com escopo apenas dentro deste componente. */
178
+ id: string;
179
+ /** Rótulo legível para o seletor de dados do componente. */
180
+ label: string;
181
+ description?: string;
182
+ /** Valor sintético determinístico, ou factory pura que o produz. */
183
+ data: T | (() => T);
184
+ };
185
+ /** Controles e dados que o motor entrega a um preview isolado. */
186
+ export type ComponentPreviewProps<T = unknown> = {
187
+ fixture?: ComponentPreviewFixture<T>;
188
+ data: T | undefined;
189
+ viewport: ViewportSetting;
190
+ /** `default` quando o produto não declara modos de tema. */
191
+ themeMode: string;
192
+ /** `default` quando o produto não declara idiomas. */
193
+ locale: string;
194
+ a11y: {
195
+ keyboardMode: boolean;
196
+ reducedMotion: boolean;
197
+ textScale: number;
198
+ };
199
+ };
200
+ export type ComponentPreview<T = unknown> = {
201
+ /** Identificador estável usado no deep link: `button.primary`. */
202
+ id: string;
203
+ /** Nome legível no vocabulário do produto. */
204
+ name: string;
205
+ /** Grupo de navegação: `Ações`, `Formulários`, `Feedback`. */
206
+ group?: string;
207
+ description?: string;
208
+ /** Composição visual fornecida e mantida pelo produto. */
209
+ preview: ComponentType<ComponentPreviewProps<T>>;
210
+ /** Dados sintéticos exclusivos deste componente; não usam o catálogo de cenários. */
211
+ fixtures?: ComponentPreviewFixture<T>[];
212
+ /** Id da fixture selecionada quando o deep link não informa outra. */
213
+ defaultFixture?: string;
214
+ };
170
215
  /**
171
216
  * A UI do produto nunca depende diretamente de um backend. A camada de
172
217
  * adapters permite alimentar o mesmo cenário por fixture, REST, GraphQL ou
@@ -239,6 +284,9 @@ export type ProductDefinition = {
239
284
  fixtures: Fixture[];
240
285
  rules?: Rule[];
241
286
  routes: RouteDefinition[];
287
+ /** Catálogo visual opcional, implementado integralmente pelo produto. */
288
+ /** Cada item pode ter seu próprio tipo de dados; o registry os trata como opacos. */
289
+ components?: ComponentPreview<any>[];
242
290
  theme?: ProductTheme;
243
291
  /**
244
292
  * Adapters de dados disponíveis. `fixtures` é o padrão (D-05); qualquer
@@ -343,8 +391,14 @@ export type ViewportSetting = {
343
391
  width?: number;
344
392
  height?: number;
345
393
  };
394
+ /** Aparência do chrome do Design Space. Não altera o tema da UI do produto. */
395
+ export type ChromeTheme = "dark" | "light";
346
396
  export type ControlsState = {
347
397
  scenario: string | undefined;
398
+ /** Inclui referências portadas nas áreas de trabalho ativo. Padrão: `false`. */
399
+ showPorted?: boolean;
400
+ /** Referência visual ativa. Opcional para preservar objetos do contrato anterior. */
401
+ component?: string;
348
402
  persona: string | undefined;
349
403
  fixture: string | undefined;
350
404
  network: NetworkState;
@@ -353,6 +407,8 @@ export type ControlsState = {
353
407
  themeMode: string | undefined;
354
408
  locale: string | undefined;
355
409
  dataSource: string | undefined;
410
+ /** Tema visual do chrome; independente de `themeMode` do produto. */
411
+ chromeTheme?: ChromeTheme;
356
412
  /** Chrome do Design Space oculto: revisão limpa e captura de tela. */
357
413
  chrome: boolean;
358
414
  keyboardMode: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brucesantos/design-space",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Motor neutro do Bananas Design Space: registry de cenários, shell, deep links, controles de persona/viewport/rede, inspetor de regras e ferramentas de acessibilidade. Não contém UI de cliente.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -64,4 +64,4 @@
64
64
  "typecheck": "tsc --noEmit",
65
65
  "test": "vitest run"
66
66
  }
67
- }
67
+ }