@pygmalionjs/pygmalion 0.6.20 → 0.6.21
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 +43 -0
- package/dist-lib/{FrozenRoutePreview-B6UY1aLt.js → FrozenRoutePreview-BQDZOtJG.js} +101 -99
- package/dist-lib/pygmalion.js +5842 -5815
- package/dist-lib/testing.js +1 -1
- package/dist-lib/types/editor/designImport.d.ts +9 -0
- package/dist-lib/types/editor/previewBootstrap.d.ts +2 -1
- package/dist-lib/types/editor/previewRoute.d.ts +12 -0
- package/dist-lib/types/editor/previewWarmup.d.ts +1 -0
- package/dist-lib/types/editor/routePreview.d.ts +1 -0
- package/dist-lib/types/editor/screenFlows.d.ts +3 -1
- package/dist-lib/types/editor/store.d.ts +3 -0
- package/dist-lib/types/editor/storyboardDiscovery.d.ts +1 -0
- package/node/inspect-plugin.mjs +5 -1
- package/node/webpack-loader.cjs +34 -0
- package/package.json +1 -1
package/dist-lib/testing.js
CHANGED
|
@@ -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;
|
|
@@ -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
|
-
/**
|
|
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;
|
package/node/inspect-plugin.mjs
CHANGED
|
@@ -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
|
-
|
|
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) {
|
package/node/webpack-loader.cjs
CHANGED
|
@@ -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));
|