view-contracts 0.3.0 → 0.3.3

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 CHANGED
@@ -78,19 +78,17 @@ A `.view.tsx` file defines:
78
78
  - component hierarchy
79
79
  - layout structure
80
80
  - visual composition
81
+ - `variant` names (appearance resolved from `views/design/theme.yaml`)
81
82
 
82
- Example:
83
+ ### Design tokens and theme own appearance
83
84
 
84
- ```tsx
85
- export default screen<AdminDashboardViewModel>(({ vm }) => (
86
- <Page id={vm.screenId} title={vm.title}>
87
- <Heading level={1}>{vm.title}</Heading>
88
- <Table rows={vm.projects} />
89
- </Page>
90
- ));
91
- ```
85
+ Color, spacing, typography, and component variants are defined in project YAML — not in view source:
86
+
87
+ - `views/design/tokens.yaml` — DTCG design tokens
88
+ - `views/design/theme.yaml` — `Button.primary`, `Text.muted`, etc.
89
+ - `views/design/extensions.css` — optional `ext-*` styles for extension components
92
90
 
93
- The view describes **structure only** — not API calls, routing logic, or styling implementation details.
91
+ See [docs/design-tokens-and-theme.md](./docs/design-tokens-and-theme.md).
94
92
 
95
93
  ### Compile instead of hand-coding
96
94
 
@@ -112,11 +110,12 @@ The generated output is deterministic.
112
110
 
113
111
  ### Supported
114
112
 
115
- - React generation (`generated/react/`, `generated/components/`)
116
- - DSL preview runtime (`src/preview/`)
113
+ - React generation (`generated/react/`, `generated/components/`, `generated/theme.css`)
114
+ - Design tokens + theme variants (`views/design/tokens.yaml`, `theme.yaml`)
115
+ - Live DSL preview (`dev:preview`) with `views/preview/*.mock.yaml` sample data
116
+ - Extension registry (`extensions.yaml`) with plain HTML/CSS implementations
117
117
  - In-memory View IR compilation
118
118
  - Standalone app scaffold (`.vite/` per example project)
119
- - Static catalog generation
120
119
 
121
120
  ### Planned
122
121
 
@@ -139,15 +138,18 @@ flowchart TB
139
138
  end
140
139
 
141
140
  subgraph design ["Visual design"]
142
- viewTsx["views/*.view.tsx<br/>layout · composition"]
141
+ viewTsx["views/*.view.tsx<br/>layout · composition · variant names"]
142
+ tokens["views/design/tokens.yaml"]
143
+ theme["views/design/theme.yaml"]
143
144
  end
144
145
 
145
146
  openapi --> microContracts["micro-contracts generate"]
146
147
  microContracts --> contractsTs["generated/contracts.ts"]
147
- microContracts --> mockTs["generated/mock.ts"]
148
148
 
149
149
  openapi --> bindings["view-bindings.yaml"]
150
150
  viewTsx --> bindings
151
+ tokens --> build
152
+ theme --> build
151
153
 
152
154
  contractsTs -->|"imports ViewModel type<br/>validates vm.* and operationId"| viewTsx
153
155
 
@@ -156,14 +158,15 @@ flowchart TB
156
158
 
157
159
  build --> viewIr["View IR (in-memory)"]
158
160
  viewIr --> reactRenderer["renderComponents"]
161
+ reactRenderer --> generatedReact["generated/react/*.generated.tsx"]
159
162
  build --> runtimeCopy["renderRuntime → generated/"]
160
163
  build --> bridgeGen["render bridge"]
161
-
162
- reactRenderer --> generatedReact["generated/react/*.generated.tsx"]
164
+ runtimeCopy --> generatedTheme["generated/theme.css"]
163
165
  bridgeGen --> bridgeTs["generated/view-bridge.generated.ts"]
164
166
  runtimeCopy --> generatedRuntime["generated/components + runtime/"]
165
167
 
166
168
  generatedReact --> app["Standalone app (src/main.tsx)"]
169
+ generatedTheme --> app
167
170
  bridgeTs --> app
168
171
  generatedRuntime --> app
169
172
  ```
@@ -175,6 +178,7 @@ flowchart TB
175
178
  | Authoring | OpenAPI types flow into `.view.tsx` via `generated/contracts.ts` | Type-safe view source |
176
179
  | Binding | `view-bindings.yaml` links a screen (`operationId`, `ViewModel`) to a view file | No schema duplication |
177
180
  | Compilation | Compiler reads layout from TSX and lowers `vm.*` / `action` to language-neutral IR | In-memory View IR |
181
+ | Design | `tokens.yaml` + `theme.yaml` validate and emit `generated/theme.css` | CSS variables + `.vc-*` variant rules |
178
182
  | Generation | Renderer copies runtime + emits React from IR + bridge registry | `generated/` (no `@view-contracts` imports) |
179
183
 
180
184
  ### Preview path (no compile step)
@@ -183,18 +187,18 @@ flowchart TB
183
187
  flowchart LR
184
188
  openapi["openapi.yaml"] --> microContracts["micro-contracts"]
185
189
  microContracts --> contractsTs["contracts.ts"]
186
- microContracts --> mockTs["mock.ts"]
187
190
 
188
191
  contractsTs --> viewTsx["*.view.tsx"]
189
- viewTsx --> preview["src/preview/"]
190
- mockTs --> preview
192
+ mockYaml["views/preview/*.mock.yaml"] --> previewPlugin["preview mock plugin"]
193
+ viewTsx --> preview["Vite preview"]
194
+ previewPlugin --> preview
191
195
 
192
196
  preview --> reactDev["Vite dev server<br/>design verification"]
193
197
  ```
194
198
 
195
- Designers and developers validate layouts **without running the full build**. The preview still consumes OpenAPI-derived ViewModel types and mock data.
199
+ Designers and developers validate layouts **without running the full build**. Preview loads sample ViewModels from `views/preview/*.mock.yaml` (not from `generated/`). Production apps load real data via `operationId` in view-bindings.
196
200
 
197
- See [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md) and [docs/SPEC_COVERAGE.md](./docs/SPEC_COVERAGE.md) for implementation details.
201
+ See [docs/ARCHITECTURE.md](./docs/ARCHITECTURE.md), [docs/design-tokens-and-theme.md](./docs/design-tokens-and-theme.md), [docs/extensions.md](./docs/extensions.md), and [docs/SPEC_COVERAGE.md](./docs/SPEC_COVERAGE.md).
198
202
 
199
203
  ---
200
204
 
@@ -219,7 +223,6 @@ Other useful commands:
219
223
  npm run dev:preview # preview only
220
224
  npm run dev:app # standalone dev app only
221
225
  npm run check:both # build + preview dev + production bundle (4174)
222
- npm run build:catalog # static gallery HTML
223
226
  ```
224
227
 
225
228
  ---
@@ -230,10 +233,13 @@ The repository includes an example admin dashboard:
230
233
 
231
234
  ```txt
232
235
  examples/admin-dashboard/
233
- ├── views/ # restricted .view.tsx (may import @view-contracts/*)
234
- ├── src/ # app wiring, extension components, handlers
236
+ ├── views/ # restricted .view.tsx (preview compiles live)
237
+ ├── design/ # tokens.yaml, theme.yaml, extensions.css
238
+ │ └── preview/ # *.mock.yaml — preview sample ViewModels only
239
+ ├── src/ # app wiring, extension components (HTML/CSS), handlers
235
240
  ├── generated/ # build output (standalone — no @view-contracts imports)
236
241
  ├── contracts/ # OpenAPI + micro-contracts config
242
+ ├── extensions.yaml # extension registry (Grid, Table, …)
237
243
  ├── dev.ports.ts # fixed dev server ports
238
244
  ├── scripts/ # dev-both.sh, check-both.sh, ports.sh
239
245
  └── .vite/ # auto-generated Vite configs (gitignored)
@@ -241,6 +247,10 @@ examples/admin-dashboard/
241
247
 
242
248
  See [examples/admin-dashboard/README.md](./examples/admin-dashboard/README.md) for local verification steps.
243
249
 
250
+ **Extensions** (`Grid`, `Table`, …) are declared in `extensions.yaml` and implemented in `src/components/extensions.tsx` with plain HTML/CSS — not DSL. See [docs/extensions.md](./docs/extensions.md).
251
+
252
+ **Appearance** for vocabulary elements comes from `views/design/theme.yaml` and `tokens.yaml`. See [docs/design-tokens-and-theme.md](./docs/design-tokens-and-theme.md).
253
+
244
254
  ---
245
255
 
246
256
  ## Project Layout
@@ -248,24 +258,26 @@ See [examples/admin-dashboard/README.md](./examples/admin-dashboard/README.md) f
248
258
  ```txt
249
259
  src/
250
260
  ├── compiler/ # TSX → View IR
251
- ├── renderer/
252
- │ └── react/
253
- ├── renderComponents.ts # IR generated/react/*.tsx
254
- │ ├── renderRuntime.ts # runtime SSoT → example/generated/
255
- │ └── runtime/ # React primitives (@view-contracts/components SSoT)
256
- ├── preview/ # DSL preview helpers (@view-contracts/preview)
261
+ ├── design/ # tokens/theme parse, validate, CSS emit
262
+ ├── extensions/ # extension registry load + validation
263
+ ├── preview/ # Vite plugins (live views, theme, mock YAML)
257
264
  ├── scaffold/ # .vite/ + package.json for example projects
258
- ├── catalog/ # static catalog builder
259
265
  └── commands/ # CLI handlers (build orchestrator)
260
266
 
261
267
  packages/
262
268
  ├── core/ # screen(), types (@view-contracts/core)
263
- └── runtime/ # action dispatcher (@view-contracts/runtime)
269
+ └── runtime/ # legacy preview shim
264
270
 
265
271
  renderers/
266
- ├── react/ # element/property maps, routes.yaml
272
+ ├── react/ # lowering, element map, runtime, templates
267
273
  ├── swiftui/ # (planned)
268
274
  └── compose/ # (planned)
275
+
276
+ docs/
277
+ ├── design-tokens-and-theme.md
278
+ ├── extensions.md
279
+ ├── ARCHITECTURE.md
280
+ └── SPEC_COVERAGE.md # auto-generated vocabulary reference
269
281
  ```
270
282
 
271
283
  ---
package/cli-contract.yaml CHANGED
@@ -3,7 +3,7 @@ cli_contracts: 0.1.0
3
3
 
4
4
  info:
5
5
  title: view-contracts CLI
6
- version: 0.3.0
6
+ version: 0.3.3
7
7
  description: >-
8
8
  Contract-first UI design toolchain. Compiles restricted view-contract TSX
9
9
  to language-neutral View IR and renders platform targets (React, SwiftUI, Compose).
@@ -162,40 +162,3 @@ command_sets:
162
162
  description: Lint passed.
163
163
  '1':
164
164
  description: Lint failed.
165
-
166
- catalog.build:
167
- summary: Build static catalog HTML for design review.
168
- description: >-
169
- Renders all registered views with mock ViewModels into a single HTML file
170
- for design review, screenshot baselines, and accessibility checks.
171
- usage:
172
- - view-contracts catalog build
173
- - view-contracts catalog build -c view-contracts.config.yaml
174
- - view-contracts catalog build -o dist/catalog.html
175
- options:
176
- - name: config
177
- aliases: [c]
178
- description: Path to view-contracts.config.yaml (discovered upward from cwd when omitted).
179
- value_name: path
180
- schema:
181
- type: string
182
- - name: output
183
- aliases: [o]
184
- description: Output HTML path (defaults to dist/catalog.html next to bindings).
185
- value_name: path
186
- schema:
187
- type: string
188
- file:
189
- mode: write
190
- media_type: text/html
191
- encoding: utf-8
192
- exits:
193
- '0':
194
- description: Catalog built.
195
- files:
196
- - path: dist/catalog.html
197
- required: false
198
- media_type: text/html
199
- encoding: utf-8
200
- '1':
201
- description: Build failed.