@pygmalionjs/pygmalion 0.6.32 → 0.6.34
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 +75 -2
- package/dist-lib/{FrozenRoutePreview-BwkyYvUV.js → FrozenRoutePreview-BbF5Ov5K.js} +2901 -2740
- package/dist-lib/pygmalion.js +11165 -9856
- package/dist-lib/testing.js +1 -1
- package/dist-lib/types/editor/captureSupply.d.ts +2 -0
- package/dist-lib/types/editor/documentSync.d.ts +15 -1
- package/dist-lib/types/editor/host.d.ts +9 -0
- package/dist-lib/types/editor/previewEnvironmentControls.d.ts +2 -0
- package/dist-lib/types/editor/projectBootGate.d.ts +15 -0
- package/dist-lib/types/editor/revisionCatalog.d.ts +135 -0
- package/dist-lib/types/editor/revisionCatalogInstall.d.ts +62 -0
- package/dist-lib/types/editor/routePreview.d.ts +1 -1
- package/dist-lib/types/editor/routePreviewStatus.d.ts +2 -1
- package/dist-lib/types/editor/store.d.ts +36 -37
- package/dist-lib/types/editor/tokens.d.ts +9 -0
- package/dist-lib/types/lib.d.ts +12 -3
- package/node/dev-mirror.mjs +567 -112
- package/node/preview-artifact-plugin.mjs +527 -68
- package/node/preview-artifact-store.mjs +370 -77
- package/node/vite.mjs +48 -2
- package/package.json +1 -1
- package/vite.d.ts +61 -4
package/README.md
CHANGED
|
@@ -58,6 +58,7 @@ export default definePygmalionProject({
|
|
|
58
58
|
"src/generated/design-registry.ts",
|
|
59
59
|
"src/generated/design-inventory.ts",
|
|
60
60
|
],
|
|
61
|
+
runtimeInputs: [".env.local"],
|
|
61
62
|
},
|
|
62
63
|
inspect: {
|
|
63
64
|
normalizeValue(property, value) {
|
|
@@ -68,8 +69,13 @@ export default definePygmalionProject({
|
|
|
68
69
|
```
|
|
69
70
|
|
|
70
71
|
`inventory.outputs` lists generator-owned paths relative to the application root. Pygmalion
|
|
71
|
-
restores
|
|
72
|
-
|
|
72
|
+
restores these paths in its dedicated mirror before switching revisions and checks again after
|
|
73
|
+
generation; any change outside the declared outputs stops synchronization.
|
|
74
|
+
Git does not report ignored files, so list ignored runtime or configuration
|
|
75
|
+
files a generator could affect in `inventory.runtimeInputs`. Each entry is one
|
|
76
|
+
file relative to the application root, with at most 64 files and 16 MiB total.
|
|
77
|
+
Pygmalion compares their content directly before and after generation; it does
|
|
78
|
+
not recursively scan `.git`, `node_modules`, or other unrelated directories.
|
|
73
79
|
|
|
74
80
|
Add the integration plugins to the host Vite configuration:
|
|
75
81
|
|
|
@@ -132,6 +138,73 @@ mirror.sourceRef; // what it is tracking now
|
|
|
132
138
|
to a throwaway commit, leaving your branch, HEAD, and index untouched. It covers
|
|
133
139
|
tracked changes only; untracked files raise a warning on the returned status.
|
|
134
140
|
|
|
141
|
+
### Bind screen declarations to the selected revision
|
|
142
|
+
|
|
143
|
+
An editor host is normally built once, while its mirror can switch among many
|
|
144
|
+
checkouts. Bundling routed pages into the host therefore lets a new preview run
|
|
145
|
+
under an old screen catalog. Generate a JSON catalog inside every mirror
|
|
146
|
+
checkout and let the exact-source endpoint serve it under a read lease:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
export default definePygmalionProject({
|
|
150
|
+
// ...
|
|
151
|
+
inventory: {
|
|
152
|
+
script: './scripts/generate-pygmalion-inventory.mjs',
|
|
153
|
+
outputs: ['artifacts/pygmalion-revision-catalog.json'],
|
|
154
|
+
},
|
|
155
|
+
preview: {
|
|
156
|
+
catalog: { file: 'artifacts/pygmalion-revision-catalog.json' },
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
With the default `inventory.script` invocation, Pygmalion passes
|
|
162
|
+
`--source-root <path> --out-root <path> --commit <sha>`. A custom
|
|
163
|
+
`inventory.args(context)` receives the same exact `context.commit` when the
|
|
164
|
+
generator uses another CLI shape.
|
|
165
|
+
|
|
166
|
+
The generated file uses the versioned, JSON-only contract exported as
|
|
167
|
+
`PygmalionRevisionCatalog`. Stamp `sourceRevision` from the inventory
|
|
168
|
+
generator's `commit` context and include routed `screens.pages`,
|
|
169
|
+
`screens.assets`, `tokens`, and every screen declaration that can differ by
|
|
170
|
+
revision. Put serializable registry metadata in `componentRegistry`; the editor
|
|
171
|
+
binds it by name to the React implementations already bundled by the host and
|
|
172
|
+
rejects a catalog whose implementation is unavailable. This keeps props,
|
|
173
|
+
defaults, adoption, and code-generation metadata revision-bound without putting
|
|
174
|
+
functions in JSON.
|
|
175
|
+
Repository-owned generated-code intent belongs in `codegenProject` so its
|
|
176
|
+
frame contracts and prompt provenance switch with the same catalog.
|
|
177
|
+
Then opt the editor into the endpoint:
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
const { appOrigin, previewRevision } = usePygmalionProject();
|
|
181
|
+
|
|
182
|
+
<PygmalionEditor
|
|
183
|
+
previewCacheNamespace="my-product"
|
|
184
|
+
previewRevision={previewRevision}
|
|
185
|
+
appOrigin={appOrigin ?? undefined}
|
|
186
|
+
previewCatalogEndpoint="/__pygmalion-route-preview/artifact/catalog"
|
|
187
|
+
/>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Pass the runtime's full `previewRevision`; the editor derives its source SHA
|
|
191
|
+
for the catalog request while retaining the session mutation counter for screen
|
|
192
|
+
cache invalidation.
|
|
193
|
+
|
|
194
|
+
The editor validates both namespace and source revision before installation.
|
|
195
|
+
While another checkout is preparing, it keeps the last complete catalog,
|
|
196
|
+
preview origin, and interaction declarations together. A late response from an
|
|
197
|
+
older dev → qa → dev request cannot overwrite the current selection.
|
|
198
|
+
Invalid, permanently unavailable, or catalogs that produce no installable page
|
|
199
|
+
fail closed on a dedicated error surface; the editor never relabels the
|
|
200
|
+
previous canvas as the requested revision. A catalog with no routed screens
|
|
201
|
+
remains installable when the host contributes non-screen library pages.
|
|
202
|
+
|
|
203
|
+
When `onDesignChange` is connected, each payload carries the exact
|
|
204
|
+
`sourceRevision` that owned the edited batch. Its non-enumerable `signal` is
|
|
205
|
+
aborted when that catalog is retired, allowing an in-process host adapter to
|
|
206
|
+
cancel work without changing an existing JSON request body.
|
|
207
|
+
|
|
135
208
|
To offer a choice instead of asking for a ref string, list the revisions and
|
|
136
209
|
render the shipped control in your toolbar:
|
|
137
210
|
|