@pygmalionjs/pygmalion 0.6.20 → 0.6.22

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 "./FrozenRoutePreview-B6UY1aLt.js";
1
+ import { F as s, N as a, e as r, s as i, a as t } from "./FrozenRoutePreview-BQDZOtJG.js";
2
2
  export {
3
3
  s as FrozenRoutePreviewView,
4
4
  a as NodeModel,
@@ -190,6 +190,13 @@ export interface DesignImportPage {
190
190
  componentName?: string;
191
191
  gallery?: string[];
192
192
  route?: string;
193
+ /**
194
+ * Host-owned routed entry used only to reproduce this screen in previews.
195
+ * `route` remains the canonical product address shown in inventory and
196
+ * coverage. Use this for a development authentication or fixture gateway
197
+ * that lands on the same screen without exposing its mechanics to core.
198
+ */
199
+ previewRoute?: string;
193
200
  path?: string;
194
201
  publish?: boolean;
195
202
  width?: number;
@@ -314,6 +321,8 @@ export interface DesignImportInitialPage {
314
321
  componentName?: string;
315
322
  gallery?: string[];
316
323
  route?: string;
324
+ /** Routed host entry used to reproduce the canonical `route` in previews. */
325
+ previewRoute?: string;
317
326
  path?: string;
318
327
  publish?: boolean;
319
328
  width?: number;
@@ -10,7 +10,7 @@ export interface PreviewCacheNamespaceOptions {
10
10
  recipeVersion?: number;
11
11
  scope?: string;
12
12
  }
13
- export type StoryboardCaptureRecipeInput = Pick<DesignScreenCase, 'route' | 'path' | 'componentName' | 'gallery' | 'width' | 'height' | 'environment' | 'preset' | 'interactions' | 'assertions'>;
13
+ export type StoryboardCaptureRecipeInput = Pick<DesignScreenCase, 'route' | 'previewRoute' | 'path' | 'componentName' | 'gallery' | 'width' | 'height' | 'environment' | 'preset' | 'interactions' | 'assertions'>;
14
14
  export interface PreviewArtifactExpectation {
15
15
  namespace: string;
16
16
  sourceRevision: string;
@@ -169,6 +169,7 @@ export declare function previewDependencyDigest(route: string): string | undefin
169
169
  export interface PreviewFramePage {
170
170
  canonicalId: string;
171
171
  route: string;
172
+ previewRoute?: string;
172
173
  width?: number;
173
174
  height?: number;
174
175
  environment?: StoryboardEnvironment;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The route that boots a screen preview.
3
+ *
4
+ * `route` remains the product's canonical address for inventory, coverage, and
5
+ * source identity. A host may expose a development-only routed entry that
6
+ * prepares authentication or fixture state before rendering the same screen;
7
+ * `previewRoute` names that entry without relabelling the product screen.
8
+ */
9
+ export declare function resolvePreviewRoute(page: {
10
+ route?: string | null;
11
+ previewRoute?: string | null;
12
+ }): string | null;
@@ -8,6 +8,7 @@ export interface PreviewWarmupPage {
8
8
  importPageId?: string;
9
9
  session?: string;
10
10
  route?: string | null;
11
+ previewRoute?: string | null;
11
12
  width?: number;
12
13
  height?: number;
13
14
  heightMode?: DesignFrameHeightMode;
@@ -48,6 +48,7 @@ export interface RoutePreviewShadowArtifact {
48
48
  export interface RoutePreviewArtifactPage {
49
49
  canonicalId: string;
50
50
  route: string;
51
+ previewRoute?: string;
51
52
  /** What this page's capture must have come from. Compared per frame. */
52
53
  fingerprint?: string;
53
54
  width?: number;
@@ -10,8 +10,10 @@ export interface ScreenFlowWaypoint {
10
10
  }
11
11
  export interface ScreenFlowPath {
12
12
  id: string;
13
- /** Route the instance boots on. */
13
+ /** Canonical product route the instance starts from. */
14
14
  route: string;
15
+ /** Optional host-owned gateway used only to boot this flow in previews. */
16
+ previewRoute?: string;
15
17
  /**
16
18
  * Declarative browser environment of the whole instance, merged over the
17
19
  * storyboard baseline. Branch paths (error states, special fixtures)
@@ -174,6 +174,8 @@ export interface PageModel {
174
174
  section?: string;
175
175
  /** Actual app routes running (iframe referencing page — not editable, actual routing in preview). */
176
176
  route?: string;
177
+ /** Host-owned routed entry used to boot the canonical route in previews. */
178
+ previewRoute?: string;
177
179
  /** Whether the design importer replaces the first actual DOM render with the entire layer tree and the processing status. */
178
180
  importLayers?: boolean;
179
181
  layersImported?: boolean;
@@ -496,6 +498,7 @@ export declare class EditorStore {
496
498
  canvas?: string;
497
499
  section?: string;
498
500
  route?: string;
501
+ previewRoute?: string;
499
502
  width?: number;
500
503
  height?: number;
501
504
  frameSizeMode?: DesignFrameSizeMode;
@@ -43,6 +43,7 @@ export interface StoryboardResolvedPage {
43
43
  componentName?: string;
44
44
  gallery?: string[];
45
45
  route?: string;
46
+ previewRoute?: string;
46
47
  path?: string;
47
48
  publish?: boolean;
48
49
  width?: number;
@@ -183,7 +183,11 @@ function instrumentJsxInto(code, componentFile, magic) {
183
183
  }
184
184
  if (injected.length > 0) {
185
185
  // Insert as first properties. Afterwards, if there are spread/explicit properties, they follow React's general property priority.
186
- magic.appendLeft(node.tagName.getEnd(), injected.join(''));
186
+ // A generic JSX component keeps its type arguments between the tag name
187
+ // and its props (`<List<Row> rows={rows} />`). The attributes position
188
+ // is after the type argument's closing `>`; the type-argument end itself
189
+ // is before that token and would still inject metadata inside `<Row>`.
190
+ magic.appendLeft(node.attributes.pos, injected.join(''));
187
191
  }
188
192
  const ownInjected = [];
189
193
  if (!hasOwnIdentity) {
@@ -0,0 +1,5 @@
1
+ export {
2
+ PYGMALION_STORYBOARD_RUNTIME_ATTRIBUTE,
3
+ storyboardEnvironmentBootstrapSource,
4
+ } from './storyboard-environment.mjs';
5
+
@@ -1,4 +1,5 @@
1
1
  const path = require('node:path');
2
+ const ts = require('typescript');
2
3
 
3
4
  const inspectPlugins = new Map();
4
5
 
@@ -27,6 +28,23 @@ function inspectPlugin(root, sourceDirectory) {
27
28
  return promise;
28
29
  }
29
30
 
31
+ function transpileForJavaScriptLoader(code, resourcePath) {
32
+ const result = ts.transpileModule(code, {
33
+ fileName: resourcePath,
34
+ compilerOptions: {
35
+ target: ts.ScriptTarget.ESNext,
36
+ module: ts.ModuleKind.ESNext,
37
+ jsx: ts.JsxEmit.Preserve,
38
+ sourceMap: true,
39
+ inlineSources: true,
40
+ },
41
+ });
42
+ return {
43
+ code: result.outputText,
44
+ map: result.sourceMapText ? JSON.parse(result.sourceMapText) : null,
45
+ };
46
+ }
47
+
30
48
  module.exports = function pygmalionWebpackLoader(source, inputMap) {
31
49
  const callback = this.async();
32
50
  const options = typeof this.getOptions === 'function' ? this.getOptions() : {};
@@ -50,9 +68,25 @@ module.exports = function pygmalionWebpackLoader(source, inputMap) {
50
68
  .then((plugin) => {
51
69
  const transformed = plugin.transform(String(source), this.resourcePath);
52
70
  if (!transformed) {
71
+ if (options.transpile === true) {
72
+ const transpiled = transpileForJavaScriptLoader(
73
+ String(source),
74
+ this.resourcePath,
75
+ );
76
+ callback(null, transpiled.code, transpiled.map);
77
+ return;
78
+ }
53
79
  callback(null, source, inputMap);
54
80
  return;
55
81
  }
82
+ if (options.transpile === true) {
83
+ const transpiled = transpileForJavaScriptLoader(
84
+ transformed.code,
85
+ this.resourcePath,
86
+ );
87
+ callback(null, transpiled.code, transpiled.map);
88
+ return;
89
+ }
56
90
  callback(null, transformed.code, transformed.map);
57
91
  })
58
92
  .catch((error) => callback(error));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pygmalionjs/pygmalion",
3
- "version": "0.6.20",
3
+ "version": "0.6.22",
4
4
  "description": "Code-backed DOM design sandbox and visual QA editor",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {
@@ -29,6 +29,10 @@
29
29
  },
30
30
  "./dev-view": "./node/dev-view.vite.mjs",
31
31
  "./webpack-loader": "./node/webpack-loader.cjs",
32
+ "./runtime": {
33
+ "types": "./runtime.d.ts",
34
+ "default": "./node/runtime.mjs"
35
+ },
32
36
  "./testing": {
33
37
  "types": "./dist-lib/types/testing.d.ts",
34
38
  "default": "./dist-lib/testing.js"
@@ -67,9 +71,11 @@
67
71
  "node/storyboard.mjs",
68
72
  "node/vite.mjs",
69
73
  "node/webpack-loader.cjs",
74
+ "node/runtime.mjs",
70
75
  "inspect.d.ts",
71
76
  "qa.d.ts",
72
77
  "storyboard.d.ts",
78
+ "runtime.d.ts",
73
79
  "vite.d.ts"
74
80
  ],
75
81
  "scripts": {
package/runtime.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ /** Attribute used to identify an installed Pygmalion pre-mount runtime. */
2
+ export declare const PYGMALION_STORYBOARD_RUNTIME_ATTRIBUTE: string;
3
+
4
+ /**
5
+ * Inline script source for hosts whose bundler cannot run the Pygmalion Vite
6
+ * HTML plugin. Render it before application scripts on every previewable route.
7
+ */
8
+ export declare function storyboardEnvironmentBootstrapSource(): string;
9
+