@pygmalionjs/pygmalion 0.2.15 → 0.2.16

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
@@ -98,6 +98,34 @@ 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
+ Preview artifacts are cached per source SHA, so switching invalidates that cache
120
+ and the next capture runs again from scratch. A capture already running for the
121
+ previous revision is discarded instead of published, so it cannot overwrite the
122
+ artifact the editor moved to.
123
+
124
+ A design session's worktree is branched from one source SHA. Once it holds
125
+ unapplied edits, `switchSource` refuses rather than leave the canvas on a
126
+ revision those edits were never written against — apply or revert them first, or
127
+ pass `{ discardEdits: true }`.
128
+
101
129
  ## Register screens and scenarios
102
130
 
103
131
  The host owns application-specific routes, fixtures, authentication, mock data,