@aestheticfunction/dspack-emit 0.3.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/LICENSE +201 -0
- package/README.md +285 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +186 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +15 -0
- package/dist/targets/a2ui/surface.d.ts +43 -0
- package/dist/targets/a2ui/surface.js +219 -0
- package/dist/targets/csr.d.ts +15 -0
- package/dist/targets/csr.js +9 -0
- package/dist/targets/json-render/codegen.d.ts +35 -0
- package/dist/targets/json-render/codegen.js +91 -0
- package/dist/targets/json-render/emit.d.ts +66 -0
- package/dist/targets/json-render/emit.js +142 -0
- package/dist/targets/json-render/model.d.ts +57 -0
- package/dist/targets/json-render/model.js +99 -0
- package/dist/targets/json-render/profile.d.ts +23 -0
- package/dist/targets/json-render/profile.js +3 -0
- package/dist/transform/color.d.ts +11 -0
- package/dist/transform/color.js +53 -0
- package/dist/transform/emit.d.ts +15 -0
- package/dist/transform/emit.js +100 -0
- package/dist/transform/index.d.ts +26 -0
- package/dist/transform/index.js +26 -0
- package/dist/transform/inline-defs.d.ts +22 -0
- package/dist/transform/inline-defs.js +172 -0
- package/dist/transform/mapping.d.ts +24 -0
- package/dist/transform/mapping.js +322 -0
- package/dist/transform/profiles.d.ts +120 -0
- package/dist/transform/profiles.js +282 -0
- package/dist/transform/report.d.ts +13 -0
- package/dist/transform/report.js +76 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.js +6 -0
- package/dist/validate/ajv.d.ts +15 -0
- package/dist/validate/ajv.js +132 -0
- package/dist/validate/meta/a2ui-catalog.meta.0_9_1.json +39 -0
- package/dist/validate/meta/a2ui-catalog.meta.1_0.json +34 -0
- package/package.json +41 -0
- package/src/cli.ts +197 -0
- package/src/index.ts +39 -0
- package/src/ingestion.test.ts +156 -0
- package/src/json-render-emit.test.ts +196 -0
- package/src/surface-emit.test.ts +184 -0
- package/src/targets/a2ui/surface.ts +287 -0
- package/src/targets/csr.ts +23 -0
- package/src/targets/json-render/codegen.ts +135 -0
- package/src/targets/json-render/emit.ts +227 -0
- package/src/targets/json-render/model.ts +170 -0
- package/src/targets/json-render/profile.ts +26 -0
- package/src/transform/color.ts +52 -0
- package/src/transform/emit.ts +128 -0
- package/src/transform/index.ts +54 -0
- package/src/transform/inline-defs.ts +209 -0
- package/src/transform/mapping.ts +391 -0
- package/src/transform/profiles.ts +425 -0
- package/src/transform/report.ts +105 -0
- package/src/transform.test.ts +112 -0
- package/src/types.ts +145 -0
- package/src/validate/ajv.ts +151 -0
- package/src/validate/meta/a2ui-catalog.meta.0_9_1.json +39 -0
- package/src/validate/meta/a2ui-catalog.meta.1_0.json +34 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# dspack-emit
|
|
2
|
+
|
|
3
|
+
dspack's multi-target emitter: compiles a **dspack** design-system contract and
|
|
4
|
+
governed dspack surfaces into protocol targets — an
|
|
5
|
+
**[A2UI](https://github.com/a2ui-project/a2ui) catalog + surface messages**
|
|
6
|
+
(rendered through the published React A2UI renderer) and
|
|
7
|
+
**[json-render](https://github.com/vercel-labs/json-render) catalog/registry
|
|
8
|
+
modules + specs**.
|
|
9
|
+
|
|
10
|
+
> **Naming note:** this repo was renamed from `dspack-to-a2ui` to `dspack-emit`
|
|
11
|
+
> when the second target landed (ADR-D2; the old GitHub URL redirects). The
|
|
12
|
+
> npm package is **`@aestheticfunction/dspack-emit`** from `0.3.0`; the last
|
|
13
|
+
> release under the old name is `@aestheticfunction/dspack-to-a2ui@0.2.0`,
|
|
14
|
+
> deprecated with a pointer here.
|
|
15
|
+
|
|
16
|
+
The project began as a proof-of-concept that compiles a dspack contract into a
|
|
17
|
+
valid A2UI catalog and renders a sample surface through the published React
|
|
18
|
+
A2UI renderer.
|
|
19
|
+
|
|
20
|
+
> **The question this answers:** *Can dspack function as a portable interchange contract
|
|
21
|
+
> for agent UI systems by compiling into an A2UI catalog with acceptable fidelity and
|
|
22
|
+
> minimal custom logic?*
|
|
23
|
+
>
|
|
24
|
+
> **Short answer (from this experiment):** **Yes for the renderable component surface;
|
|
25
|
+
> no for the design-intent layer — by design.** Component shapes, variant enums, and
|
|
26
|
+
> design tokens project onto an A2UI catalog cleanly enough to validate and render. The
|
|
27
|
+
> mapper is a generic engine plus a small *data-only* profile (no per-component code).
|
|
28
|
+
> dspack's *governance* layer (usage patterns, anti-patterns, accessibility contracts,
|
|
29
|
+
> compound composition, framework bindings) has no A2UI representation — A2UI catalogs
|
|
30
|
+
> describe renderable shape, not design intent. Those are documented as deliberate
|
|
31
|
+
> casualties, not gaps to be closed.
|
|
32
|
+
|
|
33
|
+
This is an experiment. It proves **contract portability only**. It does not implement
|
|
34
|
+
reconciliation, drift detection, Figma/AF integration, MCP tooling, bidirectional sync,
|
|
35
|
+
or runtime governance.
|
|
36
|
+
|
|
37
|
+
## Demo
|
|
38
|
+
|
|
39
|
+
The full chain: an example `dspack.json` queried via `ds-mcp`, compiled by this transformer, and rendered through the published A2UI renderer.
|
|
40
|
+
|
|
41
|
+
https://github.com/user-attachments/assets/510a781b-4214-49b3-b997-9cbecdc36961
|
|
42
|
+
|
|
43
|
+
## What's here
|
|
44
|
+
|
|
45
|
+
| Path | What |
|
|
46
|
+
| --- | --- |
|
|
47
|
+
| `input/shadcn-ui.dspack.json` | Example input: a dspack v0.2 contract from a React+Tailwind system (shadcn/ui). |
|
|
48
|
+
| `src/` | The transformer: source-agnostic engine + data-only profile + versioned emitter + validator. |
|
|
49
|
+
| `surface/settings-card.surface.json` | Hand-authored A2UI v0.9.1 surface instantiating the compiled components. |
|
|
50
|
+
| `out/catalog.v0_9_1.json`, `out/catalog.v1_0.json` | Generated catalogs (no external `$ref`, versioned `catalogId`). |
|
|
51
|
+
| `out/validation-report.*` | Validation + fidelity reports (Markdown + JSON). |
|
|
52
|
+
| `docs/MAPPING.md` | Per-field fidelity narrative and the deliberate casualties. |
|
|
53
|
+
| `demo/` | Standalone Vite + React 19 app rendering the surface via `@a2ui/react`. |
|
|
54
|
+
| `fixtures/a2ui/` | Checked-in A2UI schema fixtures used as ground truth. |
|
|
55
|
+
|
|
56
|
+
## The transformer
|
|
57
|
+
|
|
58
|
+
The mapper reads a **dspack JSON contract, not framework code** — React/Tailwind is
|
|
59
|
+
merely where this example's dspack happened to come from. The engine (`src/transform/`)
|
|
60
|
+
is generic; the only source-specific part is a declarative **profile**
|
|
61
|
+
(`src/transform/profiles.ts`) describing the dspack→A2UI component/prop/token
|
|
62
|
+
correspondence. Retargeting another design system means writing another profile, not
|
|
63
|
+
new engine code.
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
load dspack → map (engine + profile) → emit (versioned) → validate (ajv) → report
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Run it:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm install
|
|
73
|
+
npm run build:catalogs # emits v0.9.1 and v1.0 catalogs + reports into out/
|
|
74
|
+
npm test # vitest: color math, mapping, and the validation gates
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Or directly:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm run transform -- --in input/shadcn-ui.dspack.json --a2ui-version 1.0 --out out
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Versioned emitter (`--a2ui-version 0.9.1 | 1.0`)
|
|
84
|
+
|
|
85
|
+
The mapper targets and validates the **v1.0** catalog schema as the primary line, and
|
|
86
|
+
also emits **v0.9.1** for the renderer demo (maintained React renderers are stable on
|
|
87
|
+
v0.9.1). Confirmed against the checked-in fixtures, the only catalog-facing delta is:
|
|
88
|
+
|
|
89
|
+
- **v0.9.1** → `$defs.theme` (carries `primaryColor`, `#rrggbb`).
|
|
90
|
+
- **v1.0** → `$defs.surfaceProperties` + a top-level `instructions`.
|
|
91
|
+
|
|
92
|
+
(See `docs/MAPPING.md` for the full confirmation, including the dropped
|
|
93
|
+
`CatalogComponentCommon` def in v1.0, which washes out because we inline all defs.)
|
|
94
|
+
|
|
95
|
+
## Validation (the hard gate)
|
|
96
|
+
|
|
97
|
+
"Passes A2UI catalog schema validation" is operationalized as three ajv gates
|
|
98
|
+
(draft 2020-12, `strict:false`, `ajv-formats` — the same toolchain A2UI itself uses):
|
|
99
|
+
|
|
100
|
+
1. **schema-compile + no-external-ref** — ajv compiles the catalog *as a schema*;
|
|
101
|
+
fails on any unresolved `$ref`, proving it is a valid, fully self-contained schema.
|
|
102
|
+
2. **catalog-shape** — validates against a version-specific catalog-shape meta-schema
|
|
103
|
+
(`src/validate/meta/`), the check that makes v0.9.1 vs v1.0 conformance distinct.
|
|
104
|
+
3. **instance** — every component instance in the sample surface validates against the
|
|
105
|
+
catalog's own `#/$defs/anyComponent`.
|
|
106
|
+
|
|
107
|
+
The CLI exits non-zero if any gate fails. Both emitted versions currently pass all
|
|
108
|
+
three. The instance gate is proven non-vacuous in the test suite (it rejects a
|
|
109
|
+
malformed Button).
|
|
110
|
+
|
|
111
|
+
In the AF governance-pipeline naming these three checks are the **emitter gates
|
|
112
|
+
A1/A2/A3** (schema-compile, catalog-shape, instance); the protocol-neutral
|
|
113
|
+
**surface gates S1/S2/S3** (surface schema, contract vocabulary, governance lint)
|
|
114
|
+
run upstream in [dspack-gen](https://github.com/aestheticfunction/dspack-gen),
|
|
115
|
+
before anything reaches this emitter.
|
|
116
|
+
|
|
117
|
+
## Surface emission (dspack surface → A2UI)
|
|
118
|
+
|
|
119
|
+
The input contract is now **dspack v0.3**, whose `examples[]` embed *dspack
|
|
120
|
+
surface* documents — a protocol-neutral component tree in dspack vocabulary
|
|
121
|
+
(schema: `dspack.surface.v0_1.schema.json` in the dspack repo). This repo
|
|
122
|
+
compiles those surfaces to A2UI v0.9 messages:
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
npm run transform -- --in input/shadcn-ui.dspack.json --a2ui-version 0.9.1 --out out \
|
|
126
|
+
--emit-surface surface/delete-account.dsurface.json
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
emits `out/delete-account.surface.json` (createSurface with dspack-token theme +
|
|
130
|
+
updateComponents) and instance-validates it against the freshly generated catalog
|
|
131
|
+
(gate A3). Exit codes: `1` catalog gates failed, `3` strict-coverage, `4` the
|
|
132
|
+
surface could not be emitted (unknown component / structure the profile cannot
|
|
133
|
+
project). The projection is data in the profile (`surfacePlan` directives in
|
|
134
|
+
`src/transform/profiles.ts`); the engine has no component-specific code.
|
|
135
|
+
|
|
136
|
+
**Honest scope:** compound composition flattens per the documented casualties in
|
|
137
|
+
MAPPING.md (e.g. an `alert-dialog` subtree collapses onto
|
|
138
|
+
`triggerLabel/title/description/cancelLabel/confirmLabel`); A2UI's required
|
|
139
|
+
declarative actions are *synthesized* (deterministic event-name slug) and every
|
|
140
|
+
synthesis/drop is emitted as a warning — nothing is silent.
|
|
141
|
+
|
|
142
|
+
The package is also consumable as a library (`transform`, `emitSurface`,
|
|
143
|
+
`validateCatalog`, `extractInstances` via the exports map — verified by
|
|
144
|
+
`npm run test:pack`); dspack-gen consumes it from npm
|
|
145
|
+
(`@aestheticfunction/dspack-emit`).
|
|
146
|
+
|
|
147
|
+
## Second target: json-render (protocol neutrality, tested)
|
|
148
|
+
|
|
149
|
+
The same governed surfaces compile to a second protocol,
|
|
150
|
+
[json-render](https://github.com/vercel-labs/json-render) (Vercel Labs):
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
npm run transform -- --target json-render --in input/shadcn-ui.dspack.json --out out/json-render \
|
|
154
|
+
--emit-surface surface/delete-account.dsurface.json
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
generates `catalog.ts` (a `defineCatalog` module whose Zod prop schemas are
|
|
158
|
+
compiled from the contract's vocabulary — enums verbatim) and `registry.tsx`
|
|
159
|
+
(typed stub renderers, so the catalog's inferred prop typing is *compiled*,
|
|
160
|
+
not assumed), and emits the CSR as a json-render spec (`root` + flat
|
|
161
|
+
`elements` map). Unlike the a2ui projection, nothing flattens: every dspack
|
|
162
|
+
component **and sub-component** is a catalog component 1:1, so compound
|
|
163
|
+
composition survives as real nesting — the json-render profile
|
|
164
|
+
(`src/targets/json-render/profile.ts`) is near-empty, and that emptiness is
|
|
165
|
+
the point. The recorded projections that do exist: `text` leaves become a
|
|
166
|
+
universal `text` prop; slot *names* flatten into child order; function-typed
|
|
167
|
+
handler props are excluded from the declarative catalog — each one warned,
|
|
168
|
+
nothing silent.
|
|
169
|
+
|
|
170
|
+
Target gates, in the json-render idiom (`npm run test:json-render`, CI-run):
|
|
171
|
+
**J1** the generated modules compile (`tsc --noEmit`); **J2** spec structural
|
|
172
|
+
integrity (json-render's `validateSpec`); **J3** instance acceptance
|
|
173
|
+
(`catalog.validate()` — the generated Zod schemas parse the emitted tree).
|
|
174
|
+
J1–J3 run in `gates/json-render/`, a separate pinned package: json-render
|
|
175
|
+
requires zod v4 while this repo's root tree is pinned to zod v3 by
|
|
176
|
+
`@a2ui/web_core`'s peer range, so the two frameworks cannot share a
|
|
177
|
+
dependency tree. json-render is pre-1.0; its version is pinned there and
|
|
178
|
+
churn stays contained to `src/targets/json-render/` + that gate package.
|
|
179
|
+
|
|
180
|
+
**What the thesis test claims, precisely** (`src/json-render-emit.test.ts`):
|
|
181
|
+
governance runs pre-emission on the CSR, so governed/violating status is
|
|
182
|
+
identical across emitters *by construction*; the test demonstrates that every
|
|
183
|
+
governed CSR in this repo is **accepted by both emitters**. It does **not**
|
|
184
|
+
claim the two protocols are equally expressive.
|
|
185
|
+
|
|
186
|
+
## The render demo (headline deliverable)
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
cd demo
|
|
190
|
+
npm install
|
|
191
|
+
npm run dev # open the printed localhost URL
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
The demo loads `surface/settings-card.surface.json` and the generated
|
|
195
|
+
`out/catalog.v0_9_1.json`, **ingests that catalog** into a renderable
|
|
196
|
+
`Catalog<ReactComponentImplementation>` (see [Phase 2](#phase-2-rendering-off-the-generated-catalog)),
|
|
197
|
+
runs the surface through `MessageProcessor([ingestedCatalog])` from `@a2ui/web_core/v0_9`,
|
|
198
|
+
and renders it with `<A2uiSurface>` from `@a2ui/react/v0_9`. A side panel shows what survived
|
|
199
|
+
the transform (component provenance, the lossy Button variant projection, the primary token).
|
|
200
|
+
|
|
201
|
+
**What this demonstrates — and its honest scope:**
|
|
202
|
+
|
|
203
|
+
- The compiled surface **renders** through the maintained React renderer: a `Card`
|
|
204
|
+
containing a `Column` with `Text`, a `TextField`, and a primary `Button`.
|
|
205
|
+
- The dspack **design tokens drive the rendered theme** via A2UI's `--a2ui-*` CSS
|
|
206
|
+
variables: the primary button paints in `#0f172a` (dspack `color.primary`) and the
|
|
207
|
+
card border is `#e2e8f0` (dspack `color.border`).
|
|
208
|
+
- **Variants/enums survive** in the catalog; the panel shows the 6→3 lossy projection
|
|
209
|
+
with the original shadcn enum preserved in `x-dspack-source`.
|
|
210
|
+
|
|
211
|
+
**Framing caveats (not overstated):**
|
|
212
|
+
|
|
213
|
+
- The surface renders **off the generated catalog**: the accepted component vocabulary and
|
|
214
|
+
each component's schema are built from `out/catalog.v0_9_1.json` at load time (Phase 2).
|
|
215
|
+
The catalog governs names, props, and accept/refuse; the per-component **visual** is either
|
|
216
|
+
reused from the Basic Catalog (Button, Card, Text, TextField, Column) or hand-authored. See
|
|
217
|
+
the Phase 2 section for exactly where ingestion ends and hand-authoring begins.
|
|
218
|
+
- A2UI's model puts **component theming/presentation on the host**. The published
|
|
219
|
+
`@a2ui/react@0.10.1` ships empty CSS-module maps for its interactive components
|
|
220
|
+
(`Button_default = {}`), so the host (`demo/src/host-theme.css`) supplies the button/
|
|
221
|
+
input styling — driven entirely by the same dspack-token CSS variables.
|
|
222
|
+
- **v1.0 is validated, not rendered** — maintained React renderers are stable on
|
|
223
|
+
v0.9.1; a v1.0 catalog must pass schema validation but is not required to render until
|
|
224
|
+
renderers ship v1.0 support.
|
|
225
|
+
|
|
226
|
+
## Phase 2: rendering off the generated catalog
|
|
227
|
+
|
|
228
|
+
Phase 1 closed the loop at validation. Phase 2 makes the renderer **ingest** the generated
|
|
229
|
+
catalog: the accepted component vocabulary and each component's accepted schema are
|
|
230
|
+
constructed from `out/catalog.v*.json`, not from a hand-maintained list.
|
|
231
|
+
|
|
232
|
+
How it works (`demo/src/ingest/`, a generic, dspack-agnostic adapter):
|
|
233
|
+
|
|
234
|
+
- `buildComponentApi` turns one catalog component (JSON Schema) into a renderer
|
|
235
|
+
`ComponentApi` (`{ name, schema: Zod }`). It classifies each property from the catalog
|
|
236
|
+
itself, mapping the standard A2UI common-type `$ref` names (`DynamicString`, `Action`,
|
|
237
|
+
`ChildList`, `ComponentId`, ...) to the canonical Zod schemas exported by
|
|
238
|
+
`@a2ui/web_core/v0_9`, so the renderer's `scrapeSchemaBehavior` recognizes binding. This
|
|
239
|
+
is **generic A2UI ingestion**: it works on any conformant catalog, inlined or not. An
|
|
240
|
+
optional `x-a2ui` hint can disambiguate, but the adapter works with it entirely absent.
|
|
241
|
+
- `buildCatalog` iterates `catalog.components` (no hardcoded names) and pairs each with a
|
|
242
|
+
React visual from the `registry`: either delegated to the Basic Catalog, hand-authored, or
|
|
243
|
+
a visible "unimplemented" placeholder. It constructs `new Catalog(catalog.catalogId, ...)`.
|
|
244
|
+
|
|
245
|
+
**Where ingestion ends and hand-authoring begins (the honest split):** for every emitted
|
|
246
|
+
component the catalog governs the name, props, enums, defaults, and accept/refuse (true
|
|
247
|
+
ingestion). The per-component **visual** is reused (Button, Card, Text, TextField, Column) or
|
|
248
|
+
hand-authored. The renderer code (`demo/src/ingest/`) contains no component-name list; the
|
|
249
|
+
`registry` is the one hand-authored boundary.
|
|
250
|
+
|
|
251
|
+
**The acceptance gates** (`src/ingestion.test.ts`, run by `npm test`) prove this: recompiling
|
|
252
|
+
a changed contract changes the renderer's accepted vocabulary (Gate A, +`Table`) and accepted
|
|
253
|
+
props (Gate B, a new Button variant) with **no edit to the adapter or registry**; a catalog
|
|
254
|
+
name without a visual is a distinct, visible "unimplemented" state vs an absent name's
|
|
255
|
+
"Unknown component" (Gate C); `scrapeSchemaBehavior` recognizes the ingested dynamic/action/
|
|
256
|
+
child-list/checkable props (binding fidelity); Tier 1 works with `x-a2ui` stripped (tier
|
|
257
|
+
independence); and a static check enforces the no-hardcoded-names rule (negative control).
|
|
258
|
+
|
|
259
|
+
**No silent drops:** the transform now classifies **every** input dspack component as
|
|
260
|
+
mapped / adapted / omitted / unsupported and reports it (the `## Component coverage` section
|
|
261
|
+
of each validation report). An unclassified component emits a warning and, under
|
|
262
|
+
`--strict-coverage`, fails the CLI (exit 3).
|
|
263
|
+
|
|
264
|
+
**Access-management demo (P4/P5).** The updated dspack adds a `table` component and a
|
|
265
|
+
`data-table-with-row-actions` pattern, so the demo now includes a second surface,
|
|
266
|
+
`surface/access-management.surface.json`, for the prompt *"Build an access-management page
|
|
267
|
+
with a revoke action."* It renders off the generated catalog using ingested `Table` and
|
|
268
|
+
`Badge` components plus an `AlertDialog`. The **revoke** action is a destructive,
|
|
269
|
+
**non-dismissible** confirmation (the dspack `destructive-action-confirmation` pattern, and
|
|
270
|
+
the AlertDialog-vs-Dialog distinction): clicking the overlay does not dismiss it, and
|
|
271
|
+
confirming dispatches a `revoke_access` event through the A2UI action mechanism. As before,
|
|
272
|
+
the catalog governs names/props/accept-refuse; the `Table`/`Badge`/`AlertDialog` **visuals**
|
|
273
|
+
are hand-authored React in `demo/src/ingest/components/`.
|
|
274
|
+
|
|
275
|
+
**Honest scope / not yet done:** surfaces are hand-authored (the demo does **not** yet
|
|
276
|
+
generate surfaces from dspack patterns); `Table`/`Badge`/`AlertDialog` are synthesized A2UI
|
|
277
|
+
component *shapes* (the dspack sub-component composition is a documented casualty, not a
|
|
278
|
+
faithful compound contract); `dialog` and `dropdown-menu` remain unsupported casualties; and
|
|
279
|
+
v1.0 remains validated, not rendered.
|
|
280
|
+
|
|
281
|
+
## Pinned versions
|
|
282
|
+
|
|
283
|
+
`@a2ui/react@0.10.1`, `@a2ui/web_core@0.10.3` (both expose a `/v0_9` entry),
|
|
284
|
+
`@a2ui/markdown-it@0.0.4`, `react@19.2.7`. `demo/.npmrc` sets `legacy-peer-deps=true`
|
|
285
|
+
because `@a2ui/markdown-it` declares a stale peer; the mismatch is benign.
|
package/dist/cli.d.ts
ADDED