@pygmalionjs/pygmalion 0.2.14 → 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
@@ -86,6 +86,46 @@ When the mirror preview reloads the host Vite configuration,
86
86
  `PYGMALION_PREVIEW_MODE=1` prevents the integration plugins from starting
87
87
  recursively.
88
88
 
89
+ Mirror and session previews run as their own Vite processes, so the mode you
90
+ pass to the editor does not reach them. Set `preview.mode` when a screen only
91
+ exists under a specific env file — a feature flag that has to be off, a mock
92
+ profile a recipe depends on:
93
+
94
+ ```ts
95
+ export default definePygmalionProject({
96
+ // ...
97
+ preview: { mode: "e2e" },
98
+ });
99
+ ```
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
+
89
129
  ## Register screens and scenarios
90
130
 
91
131
  The host owns application-specific routes, fixtures, authentication, mock data,