@pygmalionjs/pygmalion 0.6.0 → 0.6.1
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/dist-lib/{FrozenRoutePreview-DStbZQD4.js → FrozenRoutePreview-3yddEUJs.js} +1528 -1514
- package/dist-lib/pygmalion.js +5352 -4906
- package/dist-lib/style.css +1 -1
- package/dist-lib/testing.js +1 -1
- package/dist-lib/types/editor/automaticPseudoStates.d.ts +20 -0
- package/dist-lib/types/editor/previewBootstrap.d.ts +8 -0
- package/dist-lib/types/lib.d.ts +1 -1
- package/docs/screen-state-contract.md +23 -0
- package/node/automatic-pseudo-runtime.mjs +376 -0
- package/node/inspect-plugin.mjs +37 -0
- package/node/storyboard-capture-runtime.mjs +8 -0
- package/package.json +2 -1
package/node/inspect-plugin.mjs
CHANGED
|
@@ -45,8 +45,20 @@ const INTERNAL_SOURCE_ATTRIBUTES = new Set([
|
|
|
45
45
|
'data-pygmalion-slot-count',
|
|
46
46
|
'data-pygmalion-own-source',
|
|
47
47
|
'data-pygmalion-own-props',
|
|
48
|
+
'data-pygmalion-pseudo-events',
|
|
48
49
|
]);
|
|
49
50
|
|
|
51
|
+
const HOVER_EVENT_ATTRIBUTES = new Set([
|
|
52
|
+
'onMouseEnter',
|
|
53
|
+
'onMouseOver',
|
|
54
|
+
'onMouseMove',
|
|
55
|
+
'onPointerEnter',
|
|
56
|
+
'onPointerOver',
|
|
57
|
+
'onPointerMove',
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
const FOCUS_EVENT_ATTRIBUTES = new Set(['onFocus']);
|
|
61
|
+
|
|
50
62
|
function primitiveJsxAttributeValue(attribute, sourceFile) {
|
|
51
63
|
if (!attribute.initializer) return true;
|
|
52
64
|
if (ts.isStringLiteral(attribute.initializer)) return attribute.initializer.text;
|
|
@@ -144,6 +156,31 @@ function instrumentJsxInto(code, componentFile, magic) {
|
|
|
144
156
|
: 0;
|
|
145
157
|
injected.push(` data-pygmalion-slot-count="${slotCount}"`);
|
|
146
158
|
}
|
|
159
|
+
if (
|
|
160
|
+
/^[a-z]/.test(elementName) &&
|
|
161
|
+
!authoredAttributes.has('data-pygmalion-pseudo-events')
|
|
162
|
+
) {
|
|
163
|
+
const pseudoEvents = [];
|
|
164
|
+
if (
|
|
165
|
+
[...authoredAttributes].some((name) =>
|
|
166
|
+
HOVER_EVENT_ATTRIBUTES.has(name),
|
|
167
|
+
)
|
|
168
|
+
) {
|
|
169
|
+
pseudoEvents.push('hover');
|
|
170
|
+
}
|
|
171
|
+
if (
|
|
172
|
+
[...authoredAttributes].some((name) =>
|
|
173
|
+
FOCUS_EVENT_ATTRIBUTES.has(name),
|
|
174
|
+
)
|
|
175
|
+
) {
|
|
176
|
+
pseudoEvents.push('focus');
|
|
177
|
+
}
|
|
178
|
+
if (pseudoEvents.length > 0) {
|
|
179
|
+
injected.push(
|
|
180
|
+
` data-pygmalion-pseudo-events="${pseudoEvents.join(',')}"`,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
147
184
|
if (injected.length > 0) {
|
|
148
185
|
// Insert as first properties. Afterwards, if there are spread/explicit properties, they follow React's general property priority.
|
|
149
186
|
magic.appendLeft(node.tagName.getEnd(), injected.join(''));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
+
import { annotateStoryboardAutomaticPseudoStates } from './automatic-pseudo-runtime.mjs';
|
|
2
3
|
|
|
3
4
|
const DEFAULT_VIEWPORT = Object.freeze({ width: 1280, height: 800 });
|
|
4
5
|
const QA_FAILURE_STAGES = new Set(['interaction', 'assertion']);
|
|
@@ -1252,6 +1253,13 @@ async function collectStableEvidence(
|
|
|
1252
1253
|
} catch (error) {
|
|
1253
1254
|
errors.push(new StoryboardCaptureStageError('stabilize', error));
|
|
1254
1255
|
}
|
|
1256
|
+
if (includePreviewSnapshot) {
|
|
1257
|
+
try {
|
|
1258
|
+
await page.evaluate(annotateStoryboardAutomaticPseudoStates);
|
|
1259
|
+
} catch (error) {
|
|
1260
|
+
errors.push(new StoryboardCaptureStageError('serialize', error));
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1255
1263
|
if (includeDomTree) {
|
|
1256
1264
|
try {
|
|
1257
1265
|
evidence.domTree = await page.evaluate(collectStoryboardDomTree);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pygmalionjs/pygmalion",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Code-backed DOM design sandbox and visual QA editor",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"dist-lib",
|
|
35
35
|
"docs/screen-state-contract.md",
|
|
36
36
|
"node/component-branches.mjs",
|
|
37
|
+
"node/automatic-pseudo-runtime.mjs",
|
|
37
38
|
"node/design-session.mjs",
|
|
38
39
|
"node/dev-mirror.mjs",
|
|
39
40
|
"node/dev-view.vite.mjs",
|