@pygmalionjs/pygmalion 0.2.13 → 0.2.15

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.
@@ -1,4 +1,4 @@
1
- import { F as s, N as a, e as r, s as i, a as t } from "./App-BpS2IDVb.js";
1
+ import { F as s, N as a, e as r, s as i, a as t } from "./App-CiSnd2mV.js";
2
2
  export {
3
3
  s as FrozenRoutePreviewView,
4
4
  a as NodeModel,
@@ -7,6 +7,7 @@ import os from 'node:os';
7
7
  import path from 'node:path';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { promisify } from 'node:util';
10
+ import { normalizeViteMode } from './dev-mirror.mjs';
10
11
  import { writeStyleEdit, writeTextEdit } from './inspect-plugin.mjs';
11
12
  import { createUnifiedDiff } from './source-diff.mjs';
12
13
  import { writeSourceOperations } from './source-operations.mjs';
@@ -289,6 +290,9 @@ export function pygmalionDesignSessionPlugin(options) {
289
290
  options.previewConfig ?? fileURLToPath(new URL('./dev-view.vite.mjs', import.meta.url)),
290
291
  );
291
292
  const viteConfig = path.resolve(options.viteConfig ?? path.join(mirrorAppRoot, 'vite.config.ts'));
293
+ // Session previews are separate Vite processes too, so they need the same
294
+ // host-declared mode as the mirror or a session would render a different app.
295
+ const previewMode = normalizeViteMode(options.previewMode);
292
296
  const sourceDirectory = (options.sourceDirectory ?? 'src').replace(/^\.?\//, '').replace(/\/$/, '') || '.';
293
297
  const dependencies = options.dependencies ?? {};
294
298
  const inspect = options.inspect ?? {};
@@ -503,7 +507,17 @@ export function pygmalionDesignSessionPlugin(options) {
503
507
 
504
508
  const child = spawn(
505
509
  process.execPath,
506
- [viteBin, '--config', wrapperConfig, '--host', '127.0.0.1', '--port', String(port), '--strictPort'],
510
+ [
511
+ viteBin,
512
+ '--config',
513
+ wrapperConfig,
514
+ ...(previewMode ? ['--mode', previewMode] : []),
515
+ '--host',
516
+ '127.0.0.1',
517
+ '--port',
518
+ String(port),
519
+ '--strictPort',
520
+ ],
507
521
  {
508
522
  cwd: sessionAppRoot,
509
523
  env: {
@@ -122,6 +122,24 @@ function normalizeLocalSourceRef(value) {
122
122
  return value.trim();
123
123
  }
124
124
 
125
+ /**
126
+ * The mode becomes an argv entry for the spawned preview Vite, so it is
127
+ * restricted to the identifier shape Vite mode names actually use. Anything
128
+ * else could smuggle a second flag into that command line.
129
+ */
130
+ export function normalizeViteMode(value) {
131
+ if (value == null) return null;
132
+ if (typeof value !== 'string' || !/^[A-Za-z0-9._-]+$/.test(value)) {
133
+ throw new Error(
134
+ 'Pygmalion preview.mode must be a Vite mode name ([A-Za-z0-9._-]+)',
135
+ );
136
+ }
137
+ if (value.startsWith('-')) {
138
+ throw new Error('Pygmalion preview.mode must not start with "-"');
139
+ }
140
+ return value;
141
+ }
142
+
125
143
  function normalizeManagedOutputPaths(value) {
126
144
  if (value == null) return [];
127
145
  if (!Array.isArray(value)) {
@@ -278,6 +296,10 @@ export function pygmalionDevMirrorPlugin(options) {
278
296
  options.previewConfig ?? fileURLToPath(new URL('./dev-view.vite.mjs', import.meta.url)),
279
297
  );
280
298
  const viteConfig = path.resolve(options.viteConfig ?? path.join(mirrorAppRoot, 'vite.config.ts'));
299
+ // The mirror is a separate Vite process, so the editor's own `--mode` never
300
+ // reaches it. Hosts whose captured screens need a specific env file (a feature
301
+ // flag a screen depends on, a mock profile) declare that mode here.
302
+ const previewMode = normalizeViteMode(options.previewMode);
281
303
  const inventory = options.inventory;
282
304
  const inventoryOutputs = normalizeManagedOutputPaths(inventory?.outputs);
283
305
  const managedPaths = normalizeManagedOutputPaths(
@@ -450,6 +472,7 @@ export function pygmalionDevMirrorPlugin(options) {
450
472
  viteBin,
451
473
  '--config',
452
474
  wrapperConfig,
475
+ ...(previewMode ? ['--mode', previewMode] : []),
453
476
  '--host',
454
477
  '127.0.0.1',
455
478
  '--port',
package/node/vite.mjs CHANGED
@@ -267,6 +267,7 @@ export function createPygmalionVitePlugins(config) {
267
267
  previewConfig: project.preview.configFile,
268
268
  viteConfig: project.preview.viteConfig,
269
269
  viteBin: project.preview.viteBin,
270
+ previewMode: project.preview.mode,
270
271
  previewPort: project.mirror.previewPort ?? project.preview.mirrorPort,
271
272
  prefix: normalizeEndpoint(
272
273
  project.mirror.prefix,
@@ -298,6 +299,7 @@ export function createPygmalionVitePlugins(config) {
298
299
  previewConfig: project.preview.configFile,
299
300
  viteConfig: project.preview.viteConfig,
300
301
  viteBin: project.preview.viteBin,
302
+ previewMode: project.preview.mode,
301
303
  previewPort:
302
304
  project.sessions.previewPort ?? project.preview.sessionPort,
303
305
  worktreesRoot: project.sessions.worktreesRoot,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pygmalionjs/pygmalion",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "Code-backed DOM design sandbox and visual QA editor",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
package/types.d.ts CHANGED
@@ -1549,6 +1549,12 @@ export interface PygmalionProjectRuntime {
1549
1549
  ready: boolean;
1550
1550
  appOrigin: string | null;
1551
1551
  previewRevision: string;
1552
+ /**
1553
+ * Source SHA of previewRevision, without the session mutation counter.
1554
+ * Artifact bundles are stamped with this, so hosts must build artifact cache
1555
+ * namespaces from it instead of parsing previewRevision themselves.
1556
+ */
1557
+ previewSourceRevision: string;
1552
1558
  refresh(manual?: boolean): Promise<void>;
1553
1559
  previewVisual(payload: InspectApplyPayload): Promise<InspectPreviewResult>;
1554
1560
  inspectImpact(componentFiles: string[]): Promise<InspectImpactResult>;
package/vite.d.ts CHANGED
@@ -60,6 +60,15 @@ export interface PygmalionPreviewConfig {
60
60
  configFile?: string;
61
61
  viteConfig?: string;
62
62
  viteBin?: string;
63
+ /**
64
+ * Vite mode for the mirror and session preview servers.
65
+ *
66
+ * Those run as separate Vite processes, so the editor's own `--mode` never
67
+ * reaches the previewed application. Set this when a captured screen depends
68
+ * on a specific env file — for example a feature flag that has to be off for
69
+ * the screen to exist at all. Defaults to Vite's own default mode.
70
+ */
71
+ mode?: string;
63
72
  mirrorPort?: number;
64
73
  sessionPort?: number;
65
74
  artifactFile?: string;