@pygmalionjs/pygmalion 0.2.15 → 0.2.17
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 +48 -0
- package/dist-lib/pygmalion.js +932 -840
- package/node/dev-mirror.mjs +163 -5
- package/node/preview-artifact-plugin.mjs +0 -0
- package/node/vite.mjs +2 -0
- package/package.json +1 -1
- package/types.d.ts +49 -1
- package/vite.d.ts +3 -0
package/README.md
CHANGED
|
@@ -98,6 +98,54 @@ export default definePygmalionProject({
|
|
|
98
98
|
});
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
+
## Switch what the mirror renders
|
|
102
|
+
|
|
103
|
+
The mirror follows `source.branch` unless `source.ref` pins it. Either can be
|
|
104
|
+
repointed at runtime, so comparing two revisions no longer means restarting the
|
|
105
|
+
dev server:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const { switchSource, mirror } = usePygmalionProject();
|
|
109
|
+
|
|
110
|
+
await switchSource("origin/dev");
|
|
111
|
+
await switchSource(PYGMALION_WORKTREE_SOURCE_REF); // uncommitted work
|
|
112
|
+
mirror.sourceRef; // what it is tracking now
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
`PYGMALION_WORKTREE_SOURCE_REF` renders the current working tree by resolving it
|
|
116
|
+
to a throwaway commit, leaving your branch, HEAD, and index untouched. It covers
|
|
117
|
+
tracked changes only; untracked files raise a warning on the returned status.
|
|
118
|
+
|
|
119
|
+
To offer a choice instead of asking for a ref string, list the revisions and
|
|
120
|
+
render the shipped control in your toolbar:
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
const { sourceRefs, switchSource, mirror } = usePygmalionProject();
|
|
124
|
+
|
|
125
|
+
<SourceRefControl
|
|
126
|
+
value={mirror.sourceRef}
|
|
127
|
+
refs={sourceRefs.refs}
|
|
128
|
+
defaultRef={sourceRefs.defaultRef}
|
|
129
|
+
worktreeRef={sourceRefs.worktreeRef}
|
|
130
|
+
busy={mirror.state === 'syncing'}
|
|
131
|
+
onChange={(ref) => void switchSource(ref)}
|
|
132
|
+
/>;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
`GET /__pygmalion-dev-control/refs` backs this list with local branches, remote
|
|
136
|
+
tracking branches, the default revision, and the worktree ref. `loadSourceRefs()`
|
|
137
|
+
reloads it after branches change.
|
|
138
|
+
|
|
139
|
+
Preview artifacts are cached per source SHA, so switching invalidates that cache
|
|
140
|
+
and the next capture runs again from scratch. A capture already running for the
|
|
141
|
+
previous revision is discarded instead of published, so it cannot overwrite the
|
|
142
|
+
artifact the editor moved to.
|
|
143
|
+
|
|
144
|
+
A design session's worktree is branched from one source SHA. Once it holds
|
|
145
|
+
unapplied edits, `switchSource` refuses rather than leave the canvas on a
|
|
146
|
+
revision those edits were never written against — apply or revert them first, or
|
|
147
|
+
pass `{ discardEdits: true }`.
|
|
148
|
+
|
|
101
149
|
## Register screens and scenarios
|
|
102
150
|
|
|
103
151
|
The host owns application-specific routes, fixtures, authentication, mock data,
|