mosaic-headless 1.34.9 → 1.35.0
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/SKILL.md +59 -22
- package/assets/templates/platforms/claude-ai.json +1 -1
- package/assets/templates/platforms/claude-code.json +1 -1
- package/assets/templates/platforms/codex-cli.json +1 -1
- package/assets/templates/platforms/copilot.json +1 -1
- package/assets/templates/platforms/gemini-cli.json +1 -1
- package/data/interaction-verification.csv +4 -0
- package/data/tutorial-recipes-verification.csv +17 -0
- package/package.json +1 -1
- package/references/design-system.md +14 -0
- package/references/interactions.md +91 -48
- package/references/tutorials.md +57 -0
- package/scripts/check-release.mjs +2 -1
- package/tools/build_page.py +3 -1
- package/tools/interactions.py +215 -0
- package/tools/sweep_interactions.py +28 -1
- package/tools/verify_recipes.py +307 -0
package/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ description: |
|
|
|
5
5
|
license: "MIT"
|
|
6
6
|
metadata:
|
|
7
7
|
author: "moksa (https://moksaweb.com)"
|
|
8
|
-
version: "1.
|
|
8
|
+
version: "1.35.0"
|
|
9
9
|
homepage: "https://github.com/Moksa1123/mosaic-headless"
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -129,6 +129,33 @@ stylesheet. Fetch the page and check its size; then run `verify_browser.py` and
|
|
|
129
129
|
the element say what it actually got. `references/failure-modes.md` has all of them,
|
|
130
130
|
measured.
|
|
131
131
|
|
|
132
|
+
## Native first: what the client can open in the editor
|
|
133
|
+
|
|
134
|
+
The second rule, and the one an agent breaks most often: **build with Mosaic's own
|
|
135
|
+
features, not with code.** A `code` node, a `script` action, or a pile of
|
|
136
|
+
`customDeclarations` renders fine and is a dead end for the client - the editor
|
|
137
|
+
shows a box of text they cannot change, the Navigator shows nothing of its
|
|
138
|
+
structure, and the next agent has to reverse-engineer it. Mosaic's tutorials build
|
|
139
|
+
every one of the effects below with no custom code; this skill can now write all of
|
|
140
|
+
them headlessly, measured.
|
|
141
|
+
|
|
142
|
+
| the job | the native way | how, headlessly |
|
|
143
|
+
|---|---|---|
|
|
144
|
+
| dark / light mode, themed sections | a second mode on the colour collection; `collectionModesData` on a band, or the Variable modes action on `document` for the whole site | references/design-system.md (modes), the switcher recipe in references/interactions.md |
|
|
145
|
+
| any animation: reveal, fade, slide, loop, parallax | an interaction (`pageLoad`, `click`, `hover`, `elementScrollIntoView`, `scrollIntoView`...) | `tools/interactions.py`; never `@keyframes` in a code node |
|
|
146
|
+
| the same animation on many elements | a universal class as the interaction's trigger, empty target | `trigger=class_target(...)`, recipe in references/interactions.md |
|
|
147
|
+
| a hover / focus look with no motion sequence | a style state (`hover`, `focus`...) with a `transition` | references/styling.md |
|
|
148
|
+
| a loading screen, a cookie bar | a fixed div + `pageLoad` + `hide_at_end`, `data.hidden: true` so it does not block editing | recipe in references/interactions.md |
|
|
149
|
+
| a block repeated on several pages | a component, one definition, overrides per instance | references/design-system.md (components) |
|
|
150
|
+
| a popup, a drawer, a tour | the `modal` / `popover` nodes and their actions | references/dialog-and-triggers.md |
|
|
151
|
+
| remembering a visitor's choice | `setCookie`, `remember` / `forget`, cookie conditions | references/interactions.md |
|
|
152
|
+
| text that comes from the post, the user, a field | a dynamic `{"v": "@VAR(...)"}` value | references/dynamic-content.md |
|
|
153
|
+
| a colour, a size used twice | a collection variable | references/design-system.md |
|
|
154
|
+
|
|
155
|
+
Reach for custom code only when no row above fits and `mo.py` finds no node,
|
|
156
|
+
property or action for the job - and then say in the spec, next to the code, which
|
|
157
|
+
native path was checked and why it falls short.
|
|
158
|
+
|
|
132
159
|
## What was verified, and how
|
|
133
160
|
|
|
134
161
|
Everything ran against a live install: WordPress 7.1, WooCommerce 11.1,
|
|
@@ -272,13 +299,20 @@ COMPONENTS used on the example page: the service row is committed ONCE to the
|
|
|
272
299
|
negative control, and two instances placed on a page rendering the one
|
|
273
300
|
definition twice. data/component-verification.csv
|
|
274
301
|
|
|
275
|
-
INTERACTION the JS animation path,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
302
|
+
INTERACTION the JS animation path, values included, since v1.35: one tween
|
|
303
|
+
authored in the editor and read back showed the shape - values keyed
|
|
304
|
+
by the property META's uuid, written as CSS strings with units, and
|
|
305
|
+
`duration` on the keyframe for timed triggers. Written headlessly it
|
|
306
|
+
binds on the first commit; bare numbers and name keys, one field
|
|
307
|
+
apart, store nothing. data/interaction-verification.csv
|
|
308
|
+
|
|
309
|
+
TUTORIALS Mosaic's four docs tutorials built from tools/interactions.py and
|
|
310
|
+
driven in Chromium, 16 of 16: a dark/light switcher (variable-mode
|
|
311
|
+
action on `document`, session cookie, cookie-gated page load), a
|
|
312
|
+
loading overlay that ends display:none and stops catching clicks, a
|
|
313
|
+
class-triggered scroll reveal that fires per element, and a loop a
|
|
314
|
+
hover suspends and resumes by Interaction ID.
|
|
315
|
+
data/tutorial-recipes-verification.csv
|
|
282
316
|
|
|
283
317
|
INTRO the page-load sequence - an ukiyo-e sheet printing itself eleven
|
|
284
318
|
carved blocks at a time, each impression landing out of register and
|
|
@@ -484,17 +518,14 @@ so the pattern is in the data, not just in this paragraph.
|
|
|
484
518
|
All four are real entries in `data/style-properties.csv`, under `gridChildPosition`.
|
|
485
519
|
Measured: 16 `gridColumnStart` declarations committed, zero occurrences of
|
|
486
520
|
`grid-column` in the delivered CSS. Change the template; you cannot place a child.
|
|
487
|
-
- **Interaction
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
properties whose descriptor exists, and those are created during sync on a
|
|
496
|
-
`DataMeta` that starts empty. Animate with the CSS state path, which is fully
|
|
497
|
-
verified: 36 of 37 probed states compile to exactly the promised selector.
|
|
521
|
+
- **Interaction values bind in the editor's shape - build them with
|
|
522
|
+
`tools/interactions.py`.** `initial` and each keyframe's `properties` are keyed by
|
|
523
|
+
the property META's `uuid`, values are CSS strings with units (`"0%"`, `"40px"`),
|
|
524
|
+
and a timed trigger's keyframe carries `duration`/`delay` in ms (only
|
|
525
|
+
`scrollIntoView`/`pointerMove` use `progressData`). A simple action's fields go
|
|
526
|
+
under `<type>Options.settings` - under the opt-group's name they are dropped, and a
|
|
527
|
+
suspend without its ID suspends everything on the element, itself included. The
|
|
528
|
+
full table of stored shapes is in references/interactions.md.
|
|
498
529
|
- An element **condition** puts its comparator INSIDE the subject's options
|
|
499
530
|
(`subject.<type>Options.comparator`). One level up is a PHP fatal that blanks the
|
|
500
531
|
whole page; so is `{"v": …}` as a `variable` subject's `dynamicCode` (a plain
|
|
@@ -536,8 +567,10 @@ variable's `customProperty` is optional.
|
|
|
536
567
|
guessable, and a wrong guess renders as literal text rather than an error.
|
|
537
568
|
9. `references/templates-and-conditions.md` — how Mosaic picks a template, and the
|
|
538
569
|
condition grammar shared by templates, elements, interactions and form actions.
|
|
539
|
-
10. `references/interactions.md` — the JavaScript animation system
|
|
540
|
-
|
|
570
|
+
10. `references/interactions.md` — the JavaScript animation system in the shape the
|
|
571
|
+
editor stores, values included, and the measured tutorial recipes.
|
|
572
|
+
`references/tutorials.md` — all 24 official tutorials mapped to headless builds:
|
|
573
|
+
which are measured, which are built from measured parts, which are still open.
|
|
541
574
|
11. `references/vs-elementor-gutenberg.md` — which builder habits transfer.
|
|
542
575
|
12. `references/slider.md` — the slider nested as its factories require, and the
|
|
543
576
|
two things about it the markup does not announce.
|
|
@@ -596,7 +629,8 @@ variable's `customProperty` is optional.
|
|
|
596
629
|
| `data/custom-fields-verification.csv` | 62 | **rendered live** - ACF and Meta Box fields of every common type read back through `@VAR` / `@LOOP` off the delivered page, loops included |
|
|
597
630
|
| `data/theme-zip-verification.csv` | 22 | **round-tripped live** - Mosaic's own ZIP export imported in test mode and compared to its source, table by table and tree by tree |
|
|
598
631
|
| `data/node-type-notes.csv` | 8 | where a sweep outcome is true but misleading on its own, why. Surfaced by `mo.py type` |
|
|
599
|
-
| `data/interaction-verification.csv` |
|
|
632
|
+
| `data/interaction-verification.csv` | 11 | **probed live** - interaction animation shapes, with negative controls and the stored row beside the payload; the editor's shape binds, the six older candidates and two one-field-apart controls do not |
|
|
633
|
+
| `data/tutorial-recipes-verification.csv` | 16 | **driven live** - Mosaic's four docs tutorials (dark/light switcher, loading overlay, class-driven reveal, loop with hover pause) plus the off-canvas toggle and the reading progress bar, built from `tools/interactions.py` and checked in Chromium |
|
|
600
634
|
| `data/intro-verification.csv` | 8 + 15 | **sampled live** - the entrance sequence over fifteen timestamps on a monotonic clock, plus the eight assertions about it |
|
|
601
635
|
| `data/variants.csv` | 157 | **live** — the variant catalog (Mosaic's built-in element classes); their IDs are what a `variant` record must use, and `class_name` is what the element emits |
|
|
602
636
|
| `data/dynamic-variables.csv` | 75 | source — every `@VAR('ns/name')` expression, by namespace |
|
|
@@ -979,6 +1013,8 @@ with `tools/prune_unbound.php` (dry run by default) after a batch of rebuilds.
|
|
|
979
1013
|
| `sweep_style_states.py` | write every style state and check the selector it compiled to |
|
|
980
1014
|
| `sweep_components.py` | build a component, instance it twice, and prove one definition served both |
|
|
981
1015
|
| `sweep_interactions.py` | which interaction animation shapes survive to the frontend payload |
|
|
1016
|
+
| `interactions.py` | a library, not a command: `tween`, `on`, `mode_switch`, `set_cookie`, `cookie_is`, `hide_at_end`, `suspend` / `resume`, `class_target` - every interaction shape in the form the editor stores |
|
|
1017
|
+
| `verify_recipes.py` | builds Mosaic's four docs tutorials on one page and drives each in Chromium |
|
|
982
1018
|
| `theme_export.php` / `theme_import.php` | move a whole theme across installs, ids intact |
|
|
983
1019
|
| `theme_zip.py` | drive Mosaic's OWN export/import - the ZIP the editor makes, attachments included, over the milestone protocol; import lands in test mode unless told `--activate` |
|
|
984
1020
|
| `theme_zip_compare.php` | hold an imported copy against its source, tree for tree - every scoped table, the (parentType, type) shape, which ids survive, and orphans named rather than counted |
|
|
@@ -1072,6 +1108,7 @@ python tools/sweep_style_properties.py --config sweep.json --page moksa --csv da
|
|
|
1072
1108
|
python tools/sweep_node_properties.py --config sweep.json --page moksa --csv data/node-property-verification.csv
|
|
1073
1109
|
python tools/sweep_style_states.py --config sweep.json --post 20 --slug probe-lab --csv data/style-state-verification.csv
|
|
1074
1110
|
python tools/sweep_interactions.py --config sweep.json --post 20 --slug probe-lab --csv data/interaction-verification.csv
|
|
1111
|
+
python tools/verify_recipes.py --config sweep.json --post 21 --slug probe-recipes --csv data/tutorial-recipes-verification.csv
|
|
1075
1112
|
python tools/verify_loop.py --url https://site/ --window mk-loop --toggle mk-plate-title --panel mk-plate-item \
|
|
1076
1113
|
--parts ukw-sky,ukw-sun,ukw-fuji,ukw-mist,ukw-sea,ukw-crest,ukw-boat,ukw-wave,ukw-claw,ukw-swell,ukw-key,mk-loop-seal \
|
|
1077
1114
|
--period 14000 --csv data/loop-verification.csv
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.
|
|
23
|
+
"version": "1.35.0"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Upload via Settings -> Skills -> Upload. Claude.ai parses SKILL.md frontmatter and surfaces the skill in your library. The extraction tool (extract-block-schema.php) needs a live WP-CLI connection and won't run in the sandbox; use it from a local terminal against your own site instead.",
|
|
26
26
|
"uploadSteps": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.
|
|
23
|
+
"version": "1.35.0"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Auto-loads on session start when SKILL.md frontmatter parses successfully.",
|
|
26
26
|
"verified": true,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.
|
|
23
|
+
"version": "1.35.0"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Confirmed (2026-07-11): Codex CLI natively supports the SKILL.md spec. Place SKILL.md under .codex/skills/<name>/ (project) or ~/.codex/skills/<name>/ (personal) and Codex loads the name+description at session start, then the full body on demand. A parallel, broader convention .agents/skills/ (searched from cwd up to repo root, then ~/.agents/skills/) also exists across multiple tools - if your Codex CLI version prioritizes that path instead, mirror the same SKILL.md there.",
|
|
26
26
|
"verified": true,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.
|
|
23
|
+
"version": "1.35.0"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "CHANGED as of 2026-07-11: GitHub Copilot added a proper '.github/skills/' Agent Skills directory (December 2025), alongside the older single-file .github/copilot-instructions.md convention. This config targets the new skills-directory form. If your Copilot version predates this (pre Dec 2025), use the instructions-append fallback instead (see fallback below).",
|
|
26
26
|
"fallback": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 101 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.
|
|
23
|
+
"version": "1.35.0"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "CHANGED as of 2026-07-11: Gemini CLI now natively supports the same SKILL.md standard as Claude Code and Codex CLI - the same directory-based skill works unmodified. Gemini CLI discovers skills in this precedence order: built-in, extension skills, ~/.gemini/skills/ (personal), .gemini/skills/ (project, shared via version control). At session start Gemini injects each discovered skill's name+description into the system prompt and calls activate_skill when a task matches.",
|
|
26
26
|
"verified": true,
|
|
@@ -5,4 +5,8 @@ properties-keyed-by-meta-uuid,"NEGATIVE CONTROL - properties keyed by the meta's
|
|
|
5
5
|
no-initial,does the initial block have to be there?,TIMING_ONLY,"1 keyframes, no properties","stored: 1 metas, 0 property values"
|
|
6
6
|
two-properties,"more than one meta, and a transform among them",TIMING_ONLY,"1 keyframes, no properties","stored: 2 metas, 0 property values"
|
|
7
7
|
two-keyframes,a real timeline rather than a single step,TIMING_ONLY,"2 keyframes, no properties","stored: 1 metas, 0 property values"
|
|
8
|
+
editor-shape-pageload,"as the editor stores it: uuid keys, '0%'/'80%', duration on the keyframe",BOUND,1 keyframes driving opacity,"stored: 1 metas, 2 property values"
|
|
9
|
+
editor-shape-numbers,NEGATIVE CONTROL - editor shape but bare numbers 0 / 0.8,TIMING_ONLY,"1 keyframes, no properties","stored: 1 metas, 0 property values"
|
|
10
|
+
editor-shape-name-keys,NEGATIVE CONTROL - editor shape but keyed by 'opacity',TIMING_ONLY,"1 keyframes, no properties","stored: 1 metas, 0 property values"
|
|
11
|
+
editor-shape-scroll,uuid keys and '%' strings on the progress family (scrollIntoView),BOUND,1 keyframes driving opacity,"stored: 1 metas, 2 property values"
|
|
8
12
|
timed-trigger,the timed family rather than the progress family,NO_PAYLOAD,no entry for this trigger selector,"stored: 0 metas, 0 property values"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
recipe,check,status,evidence
|
|
2
|
+
OVERLAY,faded and display:none after load,PASS,"{'bg': 'rgb(255, 255, 255)', 'op': '0', 'd': 'none', 'tr': 'none'}"
|
|
3
|
+
OVERLAY,page underneath takes a real click,PASS,clicked #rx-dark
|
|
4
|
+
DARK,Dark switches the page,PASS,"rgb(250, 250, 245) -> rgb(20, 22, 28)"
|
|
5
|
+
DARK,Dark sets the cookie,PASS,rx-mode=dark
|
|
6
|
+
DARK,a reload keeps Dark,PASS,"rgb(20, 22, 28)"
|
|
7
|
+
DARK,Light switches back,PASS,"rgb(250, 250, 245), rx-mode=light"
|
|
8
|
+
LOOP,moves on its own,PASS,154.357px -> 183.185px
|
|
9
|
+
LOOP,hover suspends it by Interaction ID,PASS,184.09px = 184.09px
|
|
10
|
+
LOOP,leaving resumes it,PASS,184.09px -> 196.866px
|
|
11
|
+
LOOP,still moving past one 4s cycle,PASS,198.658px -> 1.153px
|
|
12
|
+
OFFCANV,"odd click opens: display flex, slid in",PASS,"{'bg': 'rgb(240, 240, 240)', 'op': '1', 'd': 'flex', 'tr': '0%'}"
|
|
13
|
+
OFFCANV,even click closes: display none at the end,PASS,"{'bg': 'rgb(240, 240, 240)', 'op': '1', 'd': 'none', 'tr': '100%'}"
|
|
14
|
+
PROGRESS,bar fills as the article scrolls,PASS,-100% -> -55.0498% -> -0.968498%
|
|
15
|
+
REVEAL,first section reveals on scroll,PASS,"{'bg': 'rgb(9, 99, 199)', 'op': '1', 'd': 'block', 'tr': '0px'}"
|
|
16
|
+
REVEAL,second stays hidden until reached,PASS,"{'bg': 'rgb(9, 99, 199)', 'op': '0', 'd': 'block', 'tr': '0px 40px'}"
|
|
17
|
+
REVEAL,second reveals by class alone,PASS,"{'bg': 'rgb(9, 99, 199)', 'op': '1', 'd': 'block', 'tr': '0px'}"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mosaic-headless",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"description": "AI-agent skill: build Mosaic Pro (Nextend) WordPress sites by writing the underlying data model directly - 23 custom tables, no visual editor, no DOM. Every node type, style property and node property swept against a live install and asserted on the delivered HTML and compiled CSS. Installs into Claude Code, Cursor, Codex CLI, Gemini CLI, Copilot, Continue, Windsurf and Claude.ai.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wordpress",
|
|
@@ -174,6 +174,20 @@ inheritance (measured on 1.0.11: 18 declarations on one div). A dark band is one
|
|
|
174
174
|
targets the `html` element with a `collectionMode` property, since interactions can
|
|
175
175
|
set it too. The mode listed first in a collection is the default.
|
|
176
176
|
|
|
177
|
+
A theme `heal()` made has one mode; a second one is a record on any document
|
|
178
|
+
instance's commit, under the key `collectionMode` (measured on 1.0.11):
|
|
179
|
+
|
|
180
|
+
```json
|
|
181
|
+
{"ID": "<uuid>", "parentType": "collection", "parentID": "<collectionID>",
|
|
182
|
+
"ordering": "a5", "status": "publish", "revision": "", "version": "",
|
|
183
|
+
"data": {"name": "Dark", "icon": ""}}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Each variable then carries a value per mode - `skinsData: {<skin>: {<lightMode>:
|
|
187
|
+
{"value": …}, <darkMode>: {"value": …}}}` - and a variable with no value for the new
|
|
188
|
+
mode shows the sub-factory default there. The site-wide switcher (buttons, cookie,
|
|
189
|
+
page-load re-apply) is a recipe in references/interactions.md, measured end to end.
|
|
190
|
+
|
|
177
191
|
### Which class wins
|
|
178
192
|
|
|
179
193
|
From lowest to highest: **Variant < Variant sub class < Universal class < Universal
|
|
@@ -8,8 +8,10 @@ every node-type state in `data/style-states.csv`. Reach for it first;
|
|
|
8
8
|
`references/styling.md` has the shapes.
|
|
9
9
|
|
|
10
10
|
**The interaction path** is this document: scroll-driven and event-driven animation
|
|
11
|
-
with keyframes, run by Mosaic's own JavaScript.
|
|
12
|
-
|
|
11
|
+
with keyframes, run by Mosaic's own JavaScript. Since v1.35 it is verified end to end
|
|
12
|
+
- values included - in the shape the editor stores; `tools/interactions.py` writes it.
|
|
13
|
+
Prefer it over custom code for anything the editor can express: a client can open
|
|
14
|
+
and change an interaction, but not a script.
|
|
13
15
|
|
|
14
16
|
## What is confirmed
|
|
15
17
|
|
|
@@ -68,61 +70,102 @@ Confirmed from it:
|
|
|
68
70
|
it is a percentage of the scroll range, not milliseconds.
|
|
69
71
|
- **`easing` is defaulted to `ease`** by the server.
|
|
70
72
|
|
|
71
|
-
##
|
|
73
|
+
## Animation values: solved, in the editor's own shape
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
**`propertyMetas` is NOT the problem, and the previous claim here was wrong.** It is
|
|
79
|
-
accepted, stored, and keeps its order:
|
|
75
|
+
Until v1.35 this section said the property VALUES could not be written headlessly:
|
|
76
|
+
every attempt stored the timing and the `propertyMetas` and lost `initial` and the
|
|
77
|
+
keyframes' `properties`. The experiment that settled it was the one this page kept
|
|
78
|
+
recommending - author one tween in the 1.0.11 editor and read the row back - and the
|
|
79
|
+
editor's shape differs from every candidate tried in three ways:
|
|
80
80
|
|
|
81
81
|
```json
|
|
82
|
-
"
|
|
83
|
-
|
|
82
|
+
"animationOptions": {
|
|
83
|
+
"propertyMetas": [{"type": "predefined", "timelineKey": "_",
|
|
84
|
+
"predefinedOptions": {"name": "opacity"}, "uuid": "M"}],
|
|
85
|
+
"initial": {"M": "0%"},
|
|
86
|
+
"keyframes": [{"uuid": "K", "duration": 1000, "properties": {"M": "80%"}}]
|
|
87
|
+
}
|
|
84
88
|
```
|
|
85
89
|
|
|
86
|
-
`
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
1. **`initial` and `properties` are keyed by the META's uuid**, never by the property
|
|
91
|
+
name. (The old reading - "for a predefined meta the name is the property" - was
|
|
92
|
+
wrong: a meta is a data-array item, and an item's name is its id.)
|
|
93
|
+
2. **Values are CSS strings with their unit** - `"0%"`, `"40px"`, `"0px"` - not
|
|
94
|
+
bare numbers.
|
|
95
|
+
3. **On a timed trigger the keyframe carries `duration` / `delay` in ms**; only the
|
|
96
|
+
progress family (`scrollIntoView`, `pointerMove`) uses `progressData` 0-100.
|
|
91
97
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
`tools/sweep_interactions.py` holds the proof: the editor shape BOUND on `pageLoad`
|
|
99
|
+
and on `scrollIntoView` on the FIRST commit, while the same shape with bare numbers,
|
|
100
|
+
and the same shape keyed by `"opacity"`, both stored zero values - one field apart
|
|
101
|
+
each (data/interaction-verification.csv; the six older candidates are kept as the
|
|
102
|
+
record of what does not work). Don't hand-write these: `tools/interactions.py`
|
|
103
|
+
builds every shape on this page.
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
attempts, each with the row read back:
|
|
105
|
+
The rest of what the editor stores, each read back from a hand-authored interaction:
|
|
101
106
|
|
|
102
|
-
|
|
|
107
|
+
| what | where it lives |
|
|
103
108
|
|---|---|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-
| the
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
`
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
109
|
+
| Interaction ID (what suspend/resume name) | `<type>Options.ID`, `[a-z0-9_]+` |
|
|
110
|
+
| Out of view: keep / suspend / reset | `<type>Options.outOfView` `"0"` / `"1"` / `"2"` |
|
|
111
|
+
| Loop | `<type>Options.actionSlots.<slot>.options.isLoop = "1"` - on the SLOT, not the interaction |
|
|
112
|
+
| Trigger other than the element itself | `<type>Options.trigger` = `{"type": "element" \| "variant" \| "universalClass", "uuid": id}` (`"<id>/<subID>"` for a sub class) |
|
|
113
|
+
| Conditions | `<type>Options.conditions` - see the cookie shape below |
|
|
114
|
+
| Display at the end of the timeline | a meta `{"type": "display", "displayOptions": {"endDisplay": "none"}}`, no keyframe value |
|
|
115
|
+
| Variable mode (Variables > Variable modes) | a meta `{"type": "collectionMode", "collectionModeOptions": {"id": <collectionID>}}`, keyframe value = the mode ID |
|
|
116
|
+
| Set cookie | `{"type": "setCookie", "setCookieOptions": {"settings": {"name", "value"}}}` |
|
|
117
|
+
| Suspend / resume by ID | `{"type": "interactionSuspend", "interactionSuspendOptions": {"settings": {"interactionID": "loop_id"}}}`, `interactionResume` alike |
|
|
118
|
+
| Hide in editor (Navigator) | the node's `data.hidden: true` - the live page still renders it |
|
|
119
|
+
|
|
120
|
+
Two traps in that table, both measured:
|
|
121
|
+
|
|
122
|
+
- **A simple action's fields go under `settings`, not under its opt-group's name.**
|
|
123
|
+
The suspend fields are declared in a group called `suspend`; written there they are
|
|
124
|
+
accepted and dropped, the interaction ID falls back to `all`, and a hover that
|
|
125
|
+
suspends "all" on its element suspends ITSELF - its `out` slot never fires, so the
|
|
126
|
+
resume never runs. The runtime looked broken; the payload showed
|
|
127
|
+
`interactionSuspendOptions: {timelines: {_: null}}`.
|
|
128
|
+
- **A `collectionMode` tween exports as every variable of the collection at that
|
|
129
|
+
mode's value**, so the switch is one keyframe of `duration: 0` on the `document`
|
|
130
|
+
node (the editor's "HTML" element) and the whole page follows.
|
|
131
|
+
|
|
132
|
+
The cookie condition, exactly as the editor stores it:
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
"conditions": [{"uuid": "…", "evaluationUnits": [{"uuid": "…",
|
|
136
|
+
"type": "browserCondition",
|
|
137
|
+
"browserConditionOptions": {"subject": {"type": "httpCookie", "httpCookieOptions": {
|
|
138
|
+
"settings": {"name": "color-mode"},
|
|
139
|
+
"comparator": {"type": "text", "textOptions": {
|
|
140
|
+
"operator": "equals", "settings": {"value": "dark"}}}}}}}]}]
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Mosaic's tutorials, built headlessly
|
|
144
|
+
|
|
145
|
+
https://mosaicbuilder.com/docs/tutorials/ builds four things without custom code.
|
|
146
|
+
`tools/verify_recipes.py` builds all four from `tools/interactions.py` on one page and
|
|
147
|
+
drives them in Chromium - 16 of 16 checks (data/tutorial-recipes-verification.csv):
|
|
148
|
+
|
|
149
|
+
- **Dark/light switcher.** A second mode on the colour collection (a `collectionMode`
|
|
150
|
+
record parented to the collection, values per mode in each variable's
|
|
151
|
+
`skinsData[skin][mode]` - see design-system.md); Dark and Light buttons whose click
|
|
152
|
+
runs `mode_switch` on the `document` node plus `set_cookie`; and a `pageLoad` on
|
|
153
|
+
`document` gated by `cookie_is("color-mode", "dark")`. Measured: background
|
|
154
|
+
switches, the cookie is set, a reload keeps Dark, Light switches back. The cookie
|
|
155
|
+
is a session cookie, so a closed browser starts Light again - as the tutorial says.
|
|
156
|
+
- **Loading overlay.** A fixed full-page div with `data.hidden: true`, a `pageLoad`
|
|
157
|
+
fading opacity to `0%` and `hide_at_end`. Measured: `display:none` after load, and
|
|
158
|
+
the button under it takes a real click.
|
|
159
|
+
- **Reusable animation.** One `elementScrollIntoView` interaction on the FIRST
|
|
160
|
+
section, `trigger` = the section's universal class, no target, a `children`
|
|
161
|
+
modifier naming the child class. Measured: the second section, which has no
|
|
162
|
+
interaction of its own, stays at opacity 0 until scrolled to, then reveals - each
|
|
163
|
+
element fires on its own. (Naming the trigger class as the TARGET would animate
|
|
164
|
+
every section at once.)
|
|
165
|
+
- **Loop with hover pause.** A looping `pageLoad` tween with an Interaction ID and
|
|
166
|
+
`outOfView: "1"`, plus one `hover` whose `in` suspends and `out` resumes that ID.
|
|
167
|
+
Measured: it moves alone, holds still while hovered, moves on leaving, and keeps
|
|
168
|
+
looping past one cycle.
|
|
126
169
|
|
|
127
170
|
## The failure mode that makes this hard
|
|
128
171
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Mosaic's tutorials, mapped to headless builds
|
|
2
|
+
|
|
3
|
+
Mosaic publishes 24 tutorials: four under https://mosaicbuilder.com/docs/tutorials/
|
|
4
|
+
and twenty under https://mosaicbuilder.com/tutorials/ (basics, menus, interactions,
|
|
5
|
+
integrations - all of them listed in the site's `tutorial-sitemap.xml`; the index
|
|
6
|
+
pages load the list with JavaScript, so a plain fetch of them finds only four).
|
|
7
|
+
**None of the 24 uses custom code.** Several say so outright ("without writing any
|
|
8
|
+
JavaScript", "no code required"). That is the bar for this skill too - see "Native
|
|
9
|
+
first" in SKILL.md.
|
|
10
|
+
|
|
11
|
+
Status, per tutorial:
|
|
12
|
+
|
|
13
|
+
- **MEASURED** - built from `tools/interactions.py` by `tools/verify_recipes.py`
|
|
14
|
+
and driven in Chromium (data/tutorial-recipes-verification.csv, 16 of 16).
|
|
15
|
+
- **PARTS** - every piece it uses is measured elsewhere in this skill; the
|
|
16
|
+
tutorial as a whole has not been rebuilt.
|
|
17
|
+
- **OPEN** - at least one piece has not been driven headlessly yet. Named.
|
|
18
|
+
|
|
19
|
+
| tutorial | what it builds | status | how, headlessly |
|
|
20
|
+
|---|---|---|---|
|
|
21
|
+
| docs: dark-light-mode-switcher | site-wide mode toggle, remembered | MEASURED | second `collectionMode`, `mode_switch` on `document` + `set_cookie`, `pageLoad` gated by `cookie_is` |
|
|
22
|
+
| docs: loading-animation | full-page loader that fades out | MEASURED | fixed div, `data.hidden: true`, `pageLoad` opacity + `hide_at_end` |
|
|
23
|
+
| docs: reusable-animations | one scroll reveal reused by class | MEASURED | `elementScrollIntoView`, `trigger=class_target`, no target, `children` modifier; per-child delay with `tween(delay=)` |
|
|
24
|
+
| docs: animation-loop | endless vertical ticker, pause on hover | MEASURED (loop + hover pause) | `on(..., loop=True, ix_id=, out_of_view="1")`, hover `suspend`/`resume` by ID; the reposition tweens are `duration: 0` with a `delay` |
|
|
25
|
+
| interactions: reading-progress-bar | bar that fills while reading | MEASURED | sticky outer, `scrollIntoView` on the article targeting the bar, translateX `-100%` to `0%`, `progress=True, easing="linear"` |
|
|
26
|
+
| menus: off-canvas-menu | full-screen menu, hamburger/close | MEASURED (the toggle) | click `odd` slot: `display(start="flex")` + translateX `100%`>`0%`; `even`: back + `display(end="none")`; `data.hidden: true` on the panel; arrow-on-hover is a CSS state + `transition` |
|
|
27
|
+
| interactions: animated-shape-dividers | SVG divider that scales in and loops | PARTS | icon node with SVG, `transformOrigin`, `pageLoad` scaleY `70%`>`100%`, a second tween back, `loop=True` |
|
|
28
|
+
| interactions: background-clip | image through the letters | PARTS | `backgroundStyle` (clip text, fixed) + transparent `color`; references/styling.md |
|
|
29
|
+
| interactions: background-parallax | fixed section background | PARTS | `backgroundStyle` fixed |
|
|
30
|
+
| interactions: blurred-sticky-cta | frosted sticky button | PARTS | `position: sticky`, `bottom`, `backdropFilter`, background with alpha |
|
|
31
|
+
| interactions: flip-box-3d | card flips on hover | PARTS | `perspective`, `transformStyle`, back-face via `customDeclarations` (the tutorial does the same), hover `in`/`out` rotateY `180deg`/`0deg` on the wrapper |
|
|
32
|
+
| interactions: parallax-effect | rows drifting at two speeds | PARTS | `scrollIntoView` on the section targeting each grid, translateX `10%`>`-10%` and back; start/end via `settings` |
|
|
33
|
+
| interactions: scroll-timeline | sticky icons, fading rows, nested components | PARTS | `elementScrollIntoView` `in`/`out` slots, opacity and colour tweens with variables, sticky `top: 50vh`, nested Part components |
|
|
34
|
+
| interactions: video-controls | custom play / pause / overlay | OPEN (player actions) | click `odd`/`even`, opacity tweens, `player_play` / `player_pause` - their shape is read from the source, not driven yet |
|
|
35
|
+
| interactions: vimeo-hover-play | Vimeo plays on hover, pauses on leave | OPEN (player actions) | hover `in`/`out`, translateY overlay, `player_play`/`player_pause` |
|
|
36
|
+
| menus: mega-menu | dropdown with a component per item | OPEN (dropdown open-on-hover settings) | navbar > dropdown nodes (`mo.py placement`), a menu-item component, grid with an image |
|
|
37
|
+
| basics: layout-system | Section / Container / Row / Column / Grid / Div | PARTS | variants in `mo.py classes`; a node changes kind by its element class |
|
|
38
|
+
| basics: style-icons | library or pasted SVG icons, sized and coloured | PARTS | icon node, `currentColor`, colour variable |
|
|
39
|
+
| basics: context-bar | the editor's search bar | n/a | an editor UI feature; nothing to write |
|
|
40
|
+
| integrations: google-map | Google Maps element | PARTS | `googlemaps` node; the API key is a Mosaic setting the user enters |
|
|
41
|
+
| integrations: metabox | Loop over a CPT with Meta Box fields | PARTS | loop nodes and Meta Box variables, references/custom-fields.md; Order by "Publish date GMT" |
|
|
42
|
+
| integrations: webhook-setup | form posts to Zapier/Make | OPEN (webhook action not driven) | form node + a webhook form action; references/placement.md (forms) |
|
|
43
|
+
| integrations: mailchimp | form subscribes to Mailchimp | OPEN | form action with audience and field map; needs the user's API key |
|
|
44
|
+
| integrations: mailerlite | form subscribes to MailerLite | OPEN | form action; needs the user's API key |
|
|
45
|
+
|
|
46
|
+
What the measured ones settled that the tutorials leave implicit:
|
|
47
|
+
|
|
48
|
+
- The "HTML" element in the Navigator is the `document` node of the master; a
|
|
49
|
+
variable-mode action there re-declares every variable of the collection on it.
|
|
50
|
+
- A suspend without an Interaction ID suspends every interaction on its target,
|
|
51
|
+
including the hover that issued it - so "pause on hover" never resumes. Always pass
|
|
52
|
+
the ID.
|
|
53
|
+
- `click` carries three slots at once - `click` (every click), `odd`, `even` - and
|
|
54
|
+
the off-canvas toggle is odd/even on one interaction, not two interactions.
|
|
55
|
+
- A panel that starts `display: none` in its style can still be opened by a
|
|
56
|
+
`display(start="flex")` action: the action wins for as long as it holds, and
|
|
57
|
+
`display(end="none")` on the closing slot puts it back.
|
|
@@ -128,7 +128,8 @@ const counts = {
|
|
|
128
128
|
"data/rwd-verification.csv": 733,
|
|
129
129
|
"data/browser-verification": 4132,
|
|
130
130
|
"data/style-state-verification.csv": 52,
|
|
131
|
-
"data/interaction-verification.csv":
|
|
131
|
+
"data/interaction-verification.csv": 11,
|
|
132
|
+
"data/tutorial-recipes-verification.csv": 16,
|
|
132
133
|
"data/data-class-hierarchy.csv": 126,
|
|
133
134
|
"data/custom-fields-verification.csv": 62,
|
|
134
135
|
"data/dialog-verification.csv": 19,
|
package/tools/build_page.py
CHANGED
|
@@ -436,7 +436,9 @@ def flatten(node, parent_id, master_id, surface, force, ordering="a0",
|
|
|
436
436
|
data = dict(node.get("data") or {})
|
|
437
437
|
style = to_style(node.get("style"))
|
|
438
438
|
if style:
|
|
439
|
-
data
|
|
439
|
+
# merge, not replace: data.style may already carry universalClasses or a
|
|
440
|
+
# variant, which the states from node["style"] must not wipe out
|
|
441
|
+
data["style"] = dict(data.get("style") or {}, **style)
|
|
440
442
|
# A node that names a component becomes an INSTANCE of it, and an instance's
|
|
441
443
|
# type carries the component's id after a slash - the factory splits on it, and
|
|
442
444
|
# a bare `component-instance` has no id to read and fatals. `overrides` is not
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Build Mosaic interactions in the shape the editor itself stores.
|
|
3
|
+
|
|
4
|
+
from interactions import tween, on, set_cookie, cookie_is, mode_switch, hide_at_end
|
|
5
|
+
|
|
6
|
+
reveal = on("elementScrollIntoView", [tween([("opacity", "0%", "100%")],
|
|
7
|
+
children=class_target(child_cls))],
|
|
8
|
+
trigger=class_target(section_cls), slot="in")
|
|
9
|
+
|
|
10
|
+
Every shape here was authored by hand in the 1.0.11 editor, read back out of
|
|
11
|
+
wp_mosaic_nodes, then written headlessly and checked against `var mosaicInteractions`
|
|
12
|
+
in the delivered page and in Chromium (data/interaction-verification.csv,
|
|
13
|
+
data/tutorial-recipes-verification.csv). The three rules that made animation values
|
|
14
|
+
bind, after every earlier attempt stored the timing and lost the values:
|
|
15
|
+
|
|
16
|
+
- `initial` and each keyframe's `properties` are keyed by the property META's
|
|
17
|
+
`uuid`, never by the property name;
|
|
18
|
+
- values are CSS strings with their unit - "0%", "40px" - not bare numbers;
|
|
19
|
+
- on a timed trigger (pageLoad, click, hover...) the keyframe carries `duration`
|
|
20
|
+
(and `delay`) in ms; on a progress trigger (scrollIntoView, pointerMove) it
|
|
21
|
+
carries `progressData` {delay, duration} as 0-100.
|
|
22
|
+
|
|
23
|
+
A bare number or a name key is accepted by the commit and silently dropped - the
|
|
24
|
+
negative controls in the sweep show both.
|
|
25
|
+
"""
|
|
26
|
+
import uuid
|
|
27
|
+
|
|
28
|
+
# the 16 trigger ids; the editor's "Scroll into view" is elementScrollIntoView and
|
|
29
|
+
# its "While scrolling" is scrollIntoView (references/interactions.md)
|
|
30
|
+
PROGRESS = {"scrollIntoView", "pointerMove"}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _id():
|
|
34
|
+
return str(uuid.uuid4())
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def element(node_id):
|
|
38
|
+
return {"type": "element", "uuid": node_id}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def class_target(class_id):
|
|
42
|
+
"""A universal class (the editor's "Class") as trigger or modifier target."""
|
|
43
|
+
return {"type": "universalClass", "uuid": class_id}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def variant_target(variant_id):
|
|
47
|
+
return {"type": "variant", "uuid": variant_id}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _settings(target=None, children=None):
|
|
51
|
+
s = {}
|
|
52
|
+
if target:
|
|
53
|
+
s["target"] = target
|
|
54
|
+
if children:
|
|
55
|
+
s["targetModifiers"] = [{"uuid": _id(), "type": "children", "data": children}]
|
|
56
|
+
return s
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def tween(props, duration=600, delay=0, target=None, children=None, progress=False,
|
|
60
|
+
easing=None):
|
|
61
|
+
"""An animation action. props: [(property, initial, to)], values as CSS strings;
|
|
62
|
+
initial may be None. Property names are data/animatable-properties.csv.
|
|
63
|
+
|
|
64
|
+
target None means the element that fired the trigger - with a class trigger,
|
|
65
|
+
each element animates on its own. children narrows that to matching children."""
|
|
66
|
+
metas, initial, frame_props = [], {}, {}
|
|
67
|
+
for name, start, end in props:
|
|
68
|
+
mid = _id()
|
|
69
|
+
metas.append({"type": "predefined", "timelineKey": "_",
|
|
70
|
+
"predefinedOptions": {"name": name}, "uuid": mid})
|
|
71
|
+
if start is not None:
|
|
72
|
+
initial[mid] = start
|
|
73
|
+
frame_props[mid] = end
|
|
74
|
+
frame = {"uuid": _id(), "properties": frame_props}
|
|
75
|
+
if easing:
|
|
76
|
+
frame["easing"] = easing # "linear", "ease" (the server's default)...
|
|
77
|
+
if progress:
|
|
78
|
+
frame["progressData"] = {"delay": delay, "duration": duration}
|
|
79
|
+
else:
|
|
80
|
+
frame["duration"] = duration
|
|
81
|
+
if delay:
|
|
82
|
+
frame["delay"] = delay
|
|
83
|
+
opts = {"propertyMetas": metas, "keyframes": [frame]}
|
|
84
|
+
if initial:
|
|
85
|
+
opts["initial"] = initial
|
|
86
|
+
action = {"type": "animation", "uuid": _id(), "animationOptions": opts}
|
|
87
|
+
s = _settings(target, children)
|
|
88
|
+
if s:
|
|
89
|
+
action["settings"] = s
|
|
90
|
+
return action
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def display(start=None, end=None, duration=0, target=None):
|
|
94
|
+
"""Display at the start and/or end of the timeline: display(start="flex") opens
|
|
95
|
+
an off-canvas panel, display(end="none") takes it out once it has slid away."""
|
|
96
|
+
opts = {}
|
|
97
|
+
if start:
|
|
98
|
+
opts["startDisplay"] = start
|
|
99
|
+
if end:
|
|
100
|
+
opts["endDisplay"] = end
|
|
101
|
+
action = {"type": "animation", "uuid": _id(), "animationOptions": {
|
|
102
|
+
"propertyMetas": [{"type": "display", "timelineKey": "_",
|
|
103
|
+
"displayOptions": opts, "uuid": _id()}],
|
|
104
|
+
"keyframes": [{"uuid": _id(), "duration": duration}]}}
|
|
105
|
+
s = _settings(target)
|
|
106
|
+
if s:
|
|
107
|
+
action["settings"] = s
|
|
108
|
+
return action
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def hide_at_end(duration=0, target=None):
|
|
112
|
+
"""display:none once the timeline ends - what lets a faded overlay stop
|
|
113
|
+
catching clicks. Not keyframe specific: the meta carries the value."""
|
|
114
|
+
action = {"type": "animation", "uuid": _id(), "animationOptions": {
|
|
115
|
+
"propertyMetas": [{"type": "display", "timelineKey": "_",
|
|
116
|
+
"displayOptions": {"endDisplay": "none"}, "uuid": _id()}],
|
|
117
|
+
"keyframes": [{"uuid": _id(), "duration": duration}]}}
|
|
118
|
+
s = _settings(target)
|
|
119
|
+
if s:
|
|
120
|
+
action["settings"] = s
|
|
121
|
+
return action
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def mode_switch(collection_id, mode_id, target):
|
|
125
|
+
"""Variables > Variable modes: switch a collection to a mode on target - the
|
|
126
|
+
`document` node for the whole page. Compiles to every variable of the collection
|
|
127
|
+
at that mode's value."""
|
|
128
|
+
mid = _id()
|
|
129
|
+
return {"type": "animation", "uuid": _id(), "animationOptions": {
|
|
130
|
+
"propertyMetas": [{"type": "collectionMode", "timelineKey": "_",
|
|
131
|
+
"collectionModeOptions": {"id": collection_id}, "uuid": mid}],
|
|
132
|
+
"keyframes": [{"uuid": _id(), "duration": 0, "properties": {mid: mode_id}}]},
|
|
133
|
+
"settings": _settings(target)}
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def set_cookie(name, value):
|
|
137
|
+
"""A session cookie - gone when the browser closes."""
|
|
138
|
+
return {"type": "setCookie", "uuid": _id(),
|
|
139
|
+
"setCookieOptions": {"settings": {"name": name, "value": value}}}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def suspend(ix_id=None, target=None):
|
|
143
|
+
"""Pause the interaction with Interaction ID ix_id on target (default: the
|
|
144
|
+
trigger element). Without ix_id it pauses EVERY interaction there - including
|
|
145
|
+
the hover that is running it, whose "out" then never fires to resume."""
|
|
146
|
+
return _simple("interactionSuspend", ix_id, target)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def resume(ix_id=None, target=None):
|
|
150
|
+
return _simple("interactionResume", ix_id, target)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def _simple(kind, ix_id, target):
|
|
154
|
+
# The editor groups these fields under an opt-group named after the action
|
|
155
|
+
# ("suspend", "setCookie"...), but stores them under `settings` - a key named
|
|
156
|
+
# after the group is accepted and dropped, and the ID falls back to "all".
|
|
157
|
+
action = {"type": kind, "uuid": _id(),
|
|
158
|
+
"%sOptions" % kind: {"settings": {"interactionID": ix_id}} if ix_id else {}}
|
|
159
|
+
s = _settings(target)
|
|
160
|
+
if s:
|
|
161
|
+
action["settings"] = s
|
|
162
|
+
return action
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
def player_play(target):
|
|
166
|
+
"""Video / Vimeo / YouTube element: play. Shape from the source
|
|
167
|
+
(InteractionSimpleActionPlayerPlayAbstract); not driven in a browser yet."""
|
|
168
|
+
return {"type": "playerPlay", "uuid": _id(), "settings": _settings(target)}
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def player_pause(target):
|
|
172
|
+
return {"type": "playerPause", "uuid": _id(), "settings": _settings(target)}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def cookie_is(name, value, operator="equals"):
|
|
176
|
+
"""One condition group: run only when cookie `name` compares true to value."""
|
|
177
|
+
return {"uuid": _id(), "evaluationUnits": [{
|
|
178
|
+
"uuid": _id(), "type": "browserCondition",
|
|
179
|
+
"browserConditionOptions": {"subject": {
|
|
180
|
+
"type": "httpCookie", "httpCookieOptions": {
|
|
181
|
+
"settings": {"name": name},
|
|
182
|
+
"comparator": {"type": "text", "textOptions": {
|
|
183
|
+
"operator": operator, "settings": {"value": value}}}}}}}]}
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
def on(trigger_type, actions, trigger=None, slot=None, ix_id=None, loop=False,
|
|
187
|
+
out_of_view=None, conditions=None, settings=None):
|
|
188
|
+
"""One interaction. slot defaults to the trigger's own id (pageLoad, click...);
|
|
189
|
+
elementScrollIntoView uses "in"/"out". ix_id is the Interaction ID other
|
|
190
|
+
interactions suspend/resume by ([a-z0-9_]+). out_of_view: "0" keep running,
|
|
191
|
+
"1" suspend, "2" reset. settings: the trigger's own options, e.g. for
|
|
192
|
+
scrollIntoView {"startWhen": "startEntering", "endWhen": ...} (see the
|
|
193
|
+
`defaultSettings` each type prints into the page). click has three slots -
|
|
194
|
+
"click" every click, "odd", "even" - add the second with add_slot()."""
|
|
195
|
+
opts = {"actionSlots": {slot or trigger_type: {"actions": actions}}}
|
|
196
|
+
if loop:
|
|
197
|
+
opts["actionSlots"][slot or trigger_type]["options"] = {"isLoop": "1"}
|
|
198
|
+
if trigger:
|
|
199
|
+
opts["trigger"] = trigger
|
|
200
|
+
if ix_id:
|
|
201
|
+
opts["ID"] = ix_id
|
|
202
|
+
if out_of_view is not None:
|
|
203
|
+
opts["outOfView"] = out_of_view
|
|
204
|
+
if conditions:
|
|
205
|
+
opts["conditions"] = conditions
|
|
206
|
+
if settings:
|
|
207
|
+
opts["settings"] = settings
|
|
208
|
+
return {"type": trigger_type, "uuid": _id(), "%sOptions" % trigger_type: opts}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def add_slot(interaction, slot, actions):
|
|
212
|
+
"""A second slot on the same interaction: hover "out", click "even"..."""
|
|
213
|
+
opts = interaction["%sOptions" % interaction["type"]]
|
|
214
|
+
opts["actionSlots"][slot] = {"actions": actions}
|
|
215
|
+
return interaction
|
|
@@ -153,6 +153,33 @@ def candidates():
|
|
|
153
153
|
"progressData": {"delay": 50, "duration": 50},
|
|
154
154
|
"properties": {OPACITY: 0.35}}]})))
|
|
155
155
|
|
|
156
|
+
# The shape the editor itself stores (1.0.11, an opacity tween authored by hand and
|
|
157
|
+
# read back from wp_mosaic_nodes): values keyed by the META's uuid, written as CSS
|
|
158
|
+
# strings with their unit, and on a timed trigger the timing sits on the keyframe
|
|
159
|
+
# as `duration` rather than in `progressData`.
|
|
160
|
+
def editor_like(values, keyed_by_uuid=True, trigger="pageLoad", progress=False):
|
|
161
|
+
mid = str(uuid.uuid4())
|
|
162
|
+
key = mid if keyed_by_uuid else OPACITY
|
|
163
|
+
kf = {"uuid": str(uuid.uuid4()), "properties": {key: values[1]}}
|
|
164
|
+
kf.update({"progressData": {"delay": 0, "duration": 100}} if progress
|
|
165
|
+
else {"duration": 1000})
|
|
166
|
+
return interaction({"propertyMetas": [meta(OPACITY, mid)],
|
|
167
|
+
"initial": {key: values[0]}, "keyframes": [kf]},
|
|
168
|
+
trigger=trigger)
|
|
169
|
+
|
|
170
|
+
cases.append(("editor-shape-pageload",
|
|
171
|
+
"as the editor stores it: uuid keys, '0%'/'80%', duration on the keyframe",
|
|
172
|
+
editor_like(("0%", "80%"))))
|
|
173
|
+
cases.append(("editor-shape-numbers",
|
|
174
|
+
"NEGATIVE CONTROL - editor shape but bare numbers 0 / 0.8",
|
|
175
|
+
editor_like((0, 0.8))))
|
|
176
|
+
cases.append(("editor-shape-name-keys",
|
|
177
|
+
"NEGATIVE CONTROL - editor shape but keyed by 'opacity'",
|
|
178
|
+
editor_like(("0%", "80%"), keyed_by_uuid=False)))
|
|
179
|
+
cases.append(("editor-shape-scroll",
|
|
180
|
+
"uuid keys and '%' strings on the progress family (scrollIntoView)",
|
|
181
|
+
editor_like(("0%", "80%"), trigger="scrollIntoView", progress=True)))
|
|
182
|
+
|
|
156
183
|
cases.append(("timed-trigger",
|
|
157
184
|
"the timed family rather than the progress family",
|
|
158
185
|
interaction({
|
|
@@ -294,7 +321,7 @@ def main():
|
|
|
294
321
|
cases = candidates()
|
|
295
322
|
|
|
296
323
|
site = {"pages": [], "shell": {}}
|
|
297
|
-
master = build_shell(client, cfg, site, surface)
|
|
324
|
+
master, _header, _footer = build_shell(client, cfg, site, surface)
|
|
298
325
|
template = bind_page(client, cfg, master, a.slug, a.post)
|
|
299
326
|
n, _uses = build_page_document(client, cfg, master, template, probe_tree(cases), surface)
|
|
300
327
|
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Build Mosaic's four official tutorials headlessly and drive each one in Chromium.
|
|
3
|
+
|
|
4
|
+
python tools/verify_recipes.py --config c.json --post 292 --slug probe-recipes \
|
|
5
|
+
--csv data/tutorial-recipes-verification.csv
|
|
6
|
+
|
|
7
|
+
https://mosaicbuilder.com/docs/tutorials/ shows four things built with no custom
|
|
8
|
+
code: a dark/light mode switcher, a loading animation, reusable (class-driven)
|
|
9
|
+
animations and an animation loop. Each is a different corner of the interaction
|
|
10
|
+
system, and until the editor's own stored shape was read back (tools/interactions.py)
|
|
11
|
+
none of them could be written headlessly - every animation stored its timing and lost
|
|
12
|
+
its values. This builds all four on one page from tools/interactions.py and checks
|
|
13
|
+
what a visitor gets, not what the payload says:
|
|
14
|
+
|
|
15
|
+
DARK Dark/Light buttons switch the colour collection on the `document` node and
|
|
16
|
+
set a cookie; a pageLoad on `document`, gated on the cookie, re-applies it.
|
|
17
|
+
Asserted: the computed background before, after Dark, after a reload, and
|
|
18
|
+
after Light, plus the cookie each time.
|
|
19
|
+
OVERLAY a fixed full-page div that fades out on pageLoad and ends `display:none`,
|
|
20
|
+
marked hidden in the editor. Asserted: gone, and the page under it clickable.
|
|
21
|
+
REVEAL one elementScrollIntoView interaction on the first section, triggered by a
|
|
22
|
+
universal class, empty target, `children` modifier. Asserted: the second
|
|
23
|
+
section - which carries no interaction of its own - stays hidden until it is
|
|
24
|
+
scrolled to, then reveals.
|
|
25
|
+
LOOP a pageLoad translate that loops, `outOfView` suspend, an Interaction ID, and
|
|
26
|
+
a hover that suspends / resumes it by that ID. Asserted: it moves on its
|
|
27
|
+
own, it holds still while hovered, it moves again on leaving.
|
|
28
|
+
|
|
29
|
+
The Dark mode is created on the theme's first collection if it has none
|
|
30
|
+
(`ensure_mode`), so the run leaves a second mode behind; the first mode stays the
|
|
31
|
+
default and nothing else on the site changes.
|
|
32
|
+
"""
|
|
33
|
+
from __future__ import annotations
|
|
34
|
+
|
|
35
|
+
import mosaic_config
|
|
36
|
+
import argparse
|
|
37
|
+
import csv
|
|
38
|
+
import os
|
|
39
|
+
import sys
|
|
40
|
+
import time
|
|
41
|
+
import uuid
|
|
42
|
+
|
|
43
|
+
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
44
|
+
import interactions as ix # noqa: E402
|
|
45
|
+
from build_page import Surface # noqa: E402
|
|
46
|
+
from build_site import bind_page, build_page_document, build_shell, commit # noqa: E402
|
|
47
|
+
from sweep_node_types import Client, unwrap # noqa: E402
|
|
48
|
+
|
|
49
|
+
NS = uuid.UUID("6d6f7361-6963-4865-6164-6c657373ff0b")
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def det(name):
|
|
53
|
+
return str(uuid.uuid5(NS, name))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def ensure_mode(client, inst, doc, name):
|
|
57
|
+
"""The mode called `name` on the theme's first collection, created if missing."""
|
|
58
|
+
coll = doc["collection"][0]["ID"]
|
|
59
|
+
for m in doc.get("collectionMode") or []:
|
|
60
|
+
if m.get("parentID") == coll and (m.get("data") or {}).get("name") == name:
|
|
61
|
+
return coll, m["ID"]
|
|
62
|
+
mid = det("mode-" + name)
|
|
63
|
+
commit(client, inst, doc, {"collectionMode": [{"newRevisionRecord": {
|
|
64
|
+
"ID": mid, "parentType": "collection", "parentID": coll, "ordering": "a5",
|
|
65
|
+
"status": "publish", "revision": "", "version": "",
|
|
66
|
+
"data": {"name": name, "icon": ""}}, "originalRevisionRecord": None}]}, "mode")
|
|
67
|
+
return coll, mid
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def build(client, cfg, post, slug):
|
|
71
|
+
surface = Surface()
|
|
72
|
+
master, _h, _f = build_shell(client, cfg, {"pages": [], "shell": {}}, surface)
|
|
73
|
+
inst, key = "masterDocumentInstance/%s" % master, "node/master/%s" % master
|
|
74
|
+
doc = unwrap(client.get(inst), "masterDocumentInstance")
|
|
75
|
+
coll, dark = ensure_mode(client, inst, doc, "Dark")
|
|
76
|
+
doc = unwrap(client.get(inst), "masterDocumentInstance")
|
|
77
|
+
light = next(m["ID"] for m in doc["collectionMode"] if m.get("parentID") == coll)
|
|
78
|
+
skin = doc["collectionSkin"][0]["ID"]
|
|
79
|
+
|
|
80
|
+
bg, fg = det("var-bg"), det("var-fg")
|
|
81
|
+
commit(client, inst, doc, {"collectionVariable": [{"newRevisionRecord": {
|
|
82
|
+
"ID": vid, "parentType": "collection", "parentID": coll, "ordering": "a0",
|
|
83
|
+
"status": "publish", "revision": "", "version": "",
|
|
84
|
+
"data": {"name": cp.lstrip("-"), "type": "color", "customProperty": cp,
|
|
85
|
+
"skinsData": {skin: {light: {"value": lv}, dark: {"value": dv}}}}},
|
|
86
|
+
"originalRevisionRecord": None}
|
|
87
|
+
for vid, cp, lv, dv in ((bg, "--rx-bg", "rgb(250, 250, 245)", "rgb(20, 22, 28)"),
|
|
88
|
+
(fg, "--rx-fg", "rgb(20, 22, 28)", "rgb(240, 240, 235)"))]},
|
|
89
|
+
"variables")
|
|
90
|
+
|
|
91
|
+
sec, child = det("cls-rx-section"), det("cls-rx-child")
|
|
92
|
+
commit(client, inst, doc, {"universalClass": [{"newRevisionRecord": {
|
|
93
|
+
"ID": cid, "parentType": "", "parentID": "", "ordering": "a0", "status": "publish",
|
|
94
|
+
"revision": "", "version": "", "data": {"name": n, "label": n, "states": {}}},
|
|
95
|
+
"originalRevisionRecord": None} for cid, n in ((sec, "rx-section"), (child, "rx-child"))]},
|
|
96
|
+
"classes")
|
|
97
|
+
|
|
98
|
+
document = next(n for n in doc[key] if n["type"] == "document")
|
|
99
|
+
to_doc = ix.element(document["ID"])
|
|
100
|
+
gate = [ix.on("pageLoad", [ix.mode_switch(coll, dark, to_doc)],
|
|
101
|
+
conditions=[ix.cookie_is("rx-mode", "dark")])]
|
|
102
|
+
commit(client, inst, doc, {key: [{"newRevisionRecord": dict(
|
|
103
|
+
document, data=dict(document.get("data") or {}, interactions=gate)),
|
|
104
|
+
"originalRevisionRecord": document}]}, "document gate")
|
|
105
|
+
|
|
106
|
+
def button(attr, label, mode, value):
|
|
107
|
+
return {"type": "div", "data": {"attrID": attr, "interactions": [ix.on("click", [
|
|
108
|
+
ix.mode_switch(coll, mode, to_doc), ix.set_cookie("rx-mode", value)])]},
|
|
109
|
+
"style": {"&": {"_": {"paddingTop": "8px", "paddingBottom": "8px"}}},
|
|
110
|
+
"children": [{"type": "text", "data": {"tagName": "p"}, "text": label}]}
|
|
111
|
+
|
|
112
|
+
def section(attr, interactions=None):
|
|
113
|
+
data = {"attrID": attr, "style": {"universalClasses": {sec: sec}}}
|
|
114
|
+
if interactions:
|
|
115
|
+
data["interactions"] = interactions
|
|
116
|
+
return {"type": "div", "data": data,
|
|
117
|
+
"style": {"&": {"_": {"paddingTop": "40px", "marginBottom": "1200px"}}},
|
|
118
|
+
"children": [{"type": "div", "data": {
|
|
119
|
+
"attrID": "%s-c%d" % (attr, i), "style": {"universalClasses": {child: child}}},
|
|
120
|
+
"style": {"&": {"_": {"height": "50px", "marginBottom": "8px",
|
|
121
|
+
"backgroundColor": "rgb(9, 99, 199)"}}}}
|
|
122
|
+
for i in (1, 2)]}
|
|
123
|
+
|
|
124
|
+
reveal = [ix.on("elementScrollIntoView",
|
|
125
|
+
[ix.tween([("translateY", "40px", "0px"), ("opacity", "0%", "100%")],
|
|
126
|
+
children=ix.class_target(child))],
|
|
127
|
+
trigger=ix.class_target(sec), slot="in")]
|
|
128
|
+
overlay = [ix.on("pageLoad", [ix.tween([("opacity", "100%", "0%")], 400),
|
|
129
|
+
ix.hide_at_end(400)])]
|
|
130
|
+
hover = ix.on("hover", [ix.suspend("rx_loop")], slot="in")
|
|
131
|
+
hover["hoverOptions"]["actionSlots"]["out"] = {"actions": [ix.resume("rx_loop")]}
|
|
132
|
+
loop = [ix.on("pageLoad", [ix.tween([("translateX", "0px", "200px")], 4000)],
|
|
133
|
+
ix_id="rx_loop", loop=True, out_of_view="1"), hover]
|
|
134
|
+
|
|
135
|
+
panel_id, bar_id = str(uuid.uuid4()), str(uuid.uuid4())
|
|
136
|
+
toggle = ix.on("click", [ix.display(start="flex", target=ix.element(panel_id)),
|
|
137
|
+
ix.tween([("translateX", "100%", "0%")], 400,
|
|
138
|
+
target=ix.element(panel_id))], slot="odd")
|
|
139
|
+
ix.add_slot(toggle, "even", [ix.tween([("translateX", "0%", "100%")], 400,
|
|
140
|
+
target=ix.element(panel_id)),
|
|
141
|
+
ix.display(end="none", duration=400,
|
|
142
|
+
target=ix.element(panel_id))])
|
|
143
|
+
progress = [ix.on("scrollIntoView", [ix.tween([("translateX", "-100%", "0%")], 100,
|
|
144
|
+
progress=True, easing="linear",
|
|
145
|
+
target=ix.element(bar_id))])]
|
|
146
|
+
|
|
147
|
+
tree = {"type": "div", "data": {"attrID": "rx-root"},
|
|
148
|
+
"style": {"&": {"_": {"backgroundColor": {"var": bg}, "color": {"var": fg},
|
|
149
|
+
"paddingTop": "20px"}}},
|
|
150
|
+
"children": [
|
|
151
|
+
{"type": "div", "data": {"attrID": "rx-overlay", "hidden": True,
|
|
152
|
+
"interactions": overlay},
|
|
153
|
+
"style": {"&": {"_": {"position": "fixed", "zIndex": "100", "top": "0px",
|
|
154
|
+
"right": "0px", "bottom": "0px", "left": "0px",
|
|
155
|
+
"backgroundColor": "rgb(255, 255, 255)"}}}},
|
|
156
|
+
button("rx-dark", "Dark", dark, "dark"),
|
|
157
|
+
button("rx-light", "Light", light, "light"),
|
|
158
|
+
{"type": "div", "data": {"attrID": "rx-loop", "interactions": loop},
|
|
159
|
+
"style": {"&": {"_": {"width": "60px", "height": "60px",
|
|
160
|
+
"backgroundColor": "rgb(200, 60, 40)"}}}},
|
|
161
|
+
{"type": "div", "data": {"attrID": "rx-oc-toggle", "interactions": [toggle]},
|
|
162
|
+
"style": {"&": {"_": {"width": "40px", "height": "40px",
|
|
163
|
+
"backgroundColor": "rgb(40, 40, 40)"}}}},
|
|
164
|
+
{"type": "div", "nodeID": panel_id, "data": {"attrID": "rx-oc-panel"},
|
|
165
|
+
"style": {"&": {"_": {"display": "none", "position": "fixed", "zIndex": "50",
|
|
166
|
+
"top": "0px", "right": "0px", "bottom": "0px",
|
|
167
|
+
"width": "300px",
|
|
168
|
+
"backgroundColor": "rgb(240, 240, 240)"}}}},
|
|
169
|
+
{"type": "div", "data": {"attrID": "rx-bar-outer"},
|
|
170
|
+
"style": {"&": {"_": {"position": "sticky", "top": "0px", "zIndex": "40",
|
|
171
|
+
"overflow": "hidden", "height": "8px"}}},
|
|
172
|
+
"children": [{"type": "div", "nodeID": bar_id, "data": {"attrID": "rx-bar"},
|
|
173
|
+
"style": {"&": {"_": {"height": "8px", "width": "100%",
|
|
174
|
+
"backgroundColor": "rgb(9, 99, 199)"}}}}]},
|
|
175
|
+
{"type": "div", "data": {"attrID": "rx-article", "interactions": progress},
|
|
176
|
+
"style": {"&": {"_": {"height": "2400px"}}}},
|
|
177
|
+
{"type": "div", "data": {"attrID": "rx-gap"},
|
|
178
|
+
"style": {"&": {"_": {"height": "1200px"}}}},
|
|
179
|
+
section("rx-s1", reveal), section("rx-s2")]}
|
|
180
|
+
template = bind_page(client, cfg, master, slug, post)
|
|
181
|
+
build_page_document(client, cfg, master, template, tree, surface)
|
|
182
|
+
return master
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def drive(url):
|
|
186
|
+
from playwright.sync_api import sync_playwright
|
|
187
|
+
rows = []
|
|
188
|
+
|
|
189
|
+
def row(recipe, check, ok, evidence):
|
|
190
|
+
rows.append([recipe, check, "PASS" if ok else "FAIL", evidence])
|
|
191
|
+
print(" %-8s %-34s %-4s %s" % (recipe, check, "PASS" if ok else "FAIL", evidence))
|
|
192
|
+
|
|
193
|
+
css = ("id => { const s = getComputedStyle(document.getElementById(id));"
|
|
194
|
+
" return {bg: s.backgroundColor, op: s.opacity, d: s.display, tr: s.translate}; }")
|
|
195
|
+
with sync_playwright() as pw:
|
|
196
|
+
b = pw.chromium.launch()
|
|
197
|
+
page = b.new_page(viewport={"width": 1280, "height": 800})
|
|
198
|
+
bust = lambda: "%s?_v=%d" % (url, time.time() * 1000) # noqa: E731
|
|
199
|
+
page.goto(bust(), wait_until="networkidle")
|
|
200
|
+
page.wait_for_timeout(900)
|
|
201
|
+
cookie = lambda: next((c["value"] for c in page.context.cookies() # noqa: E731
|
|
202
|
+
if c["name"] == "rx-mode"), None)
|
|
203
|
+
|
|
204
|
+
bg0 = page.evaluate(css, "rx-root")["bg"]
|
|
205
|
+
row("OVERLAY", "faded and display:none after load",
|
|
206
|
+
page.evaluate(css, "rx-overlay")["d"] == "none", str(page.evaluate(css, "rx-overlay")))
|
|
207
|
+
try:
|
|
208
|
+
page.click("#rx-dark", timeout=3000)
|
|
209
|
+
clickable = True
|
|
210
|
+
except Exception as exc: # noqa: BLE001
|
|
211
|
+
clickable, bg0 = False, "%s (%s)" % (bg0, exc.__class__.__name__)
|
|
212
|
+
row("OVERLAY", "page underneath takes a real click", clickable, "clicked #rx-dark")
|
|
213
|
+
page.wait_for_timeout(400)
|
|
214
|
+
bg1 = page.evaluate(css, "rx-root")["bg"]
|
|
215
|
+
row("DARK", "Dark switches the page", bg1 != bg0, "%s -> %s" % (bg0, bg1))
|
|
216
|
+
row("DARK", "Dark sets the cookie", cookie() == "dark", "rx-mode=%s" % cookie())
|
|
217
|
+
page.goto(bust(), wait_until="networkidle")
|
|
218
|
+
page.wait_for_timeout(900)
|
|
219
|
+
bg2 = page.evaluate(css, "rx-root")["bg"]
|
|
220
|
+
row("DARK", "a reload keeps Dark", bg2 == bg1, bg2)
|
|
221
|
+
page.click("#rx-light")
|
|
222
|
+
page.wait_for_timeout(400)
|
|
223
|
+
bg3 = page.evaluate(css, "rx-root")["bg"]
|
|
224
|
+
row("DARK", "Light switches back", bg3 == bg0, "%s, rx-mode=%s" % (bg3, cookie()))
|
|
225
|
+
|
|
226
|
+
t = [page.evaluate(css, "rx-loop")["tr"]]
|
|
227
|
+
page.wait_for_timeout(700)
|
|
228
|
+
t.append(page.evaluate(css, "rx-loop")["tr"])
|
|
229
|
+
row("LOOP", "moves on its own", t[0] != t[1], " -> ".join(t))
|
|
230
|
+
# a moving element is never "stable" for page.hover; put the pointer on it
|
|
231
|
+
box = page.locator("#rx-loop").bounding_box()
|
|
232
|
+
page.mouse.move(box["x"] + box["width"] / 2, box["y"] + box["height"] / 2)
|
|
233
|
+
page.wait_for_timeout(300)
|
|
234
|
+
h = [page.evaluate(css, "rx-loop")["tr"]]
|
|
235
|
+
page.wait_for_timeout(700)
|
|
236
|
+
h.append(page.evaluate(css, "rx-loop")["tr"])
|
|
237
|
+
row("LOOP", "hover suspends it by Interaction ID", h[0] == h[1], " = ".join(h))
|
|
238
|
+
page.mouse.move(900, 700)
|
|
239
|
+
page.wait_for_timeout(700)
|
|
240
|
+
r = page.evaluate(css, "rx-loop")["tr"]
|
|
241
|
+
row("LOOP", "leaving resumes it", r != h[1], "%s -> %s" % (h[1], r))
|
|
242
|
+
page.wait_for_timeout(4200)
|
|
243
|
+
lp = [page.evaluate(css, "rx-loop")["tr"]]
|
|
244
|
+
page.wait_for_timeout(500)
|
|
245
|
+
lp.append(page.evaluate(css, "rx-loop")["tr"])
|
|
246
|
+
row("LOOP", "still moving past one 4s cycle", lp[0] != lp[1], " -> ".join(lp))
|
|
247
|
+
|
|
248
|
+
page.mouse.move(5, 5)
|
|
249
|
+
page.click("#rx-oc-toggle")
|
|
250
|
+
page.wait_for_timeout(700)
|
|
251
|
+
op = page.evaluate(css, "rx-oc-panel")
|
|
252
|
+
row("OFFCANV", "odd click opens: display flex, slid in",
|
|
253
|
+
op["d"] == "flex" and op["tr"] in ("0%", "0px", "none"), str(op))
|
|
254
|
+
page.click("#rx-oc-toggle", position={"x": 2, "y": 2}, force=True)
|
|
255
|
+
page.wait_for_timeout(900)
|
|
256
|
+
cl = page.evaluate(css, "rx-oc-panel")
|
|
257
|
+
row("OFFCANV", "even click closes: display none at the end", cl["d"] == "none", str(cl))
|
|
258
|
+
|
|
259
|
+
ys = []
|
|
260
|
+
top = page.evaluate("document.getElementById('rx-article').getBoundingClientRect().top + scrollY")
|
|
261
|
+
for f in (0.0, 0.5, 1.0):
|
|
262
|
+
page.evaluate("y => scrollTo(0, y)", top - 400 + f * 2400)
|
|
263
|
+
page.wait_for_timeout(500)
|
|
264
|
+
ys.append(page.evaluate(css, "rx-bar")["tr"])
|
|
265
|
+
nums = [float(str(t).split()[0].rstrip("px%") or 0) if t != "none" else 0.0 for t in ys]
|
|
266
|
+
row("PROGRESS", "bar fills as the article scrolls", nums[0] < nums[1] < nums[2] or
|
|
267
|
+
(nums[0] < nums[2] and nums[1] <= nums[2]), " -> ".join(ys))
|
|
268
|
+
|
|
269
|
+
before = page.evaluate(css, "rx-s2-c1")
|
|
270
|
+
page.evaluate("document.getElementById('rx-s1').scrollIntoView({block:'center'})")
|
|
271
|
+
page.wait_for_timeout(1200)
|
|
272
|
+
s1, s2_still = page.evaluate(css, "rx-s1-c1"), page.evaluate(css, "rx-s2-c1")
|
|
273
|
+
row("REVEAL", "first section reveals on scroll", s1["op"] == "1", str(s1))
|
|
274
|
+
row("REVEAL", "second stays hidden until reached",
|
|
275
|
+
s2_still["op"] == "0" and before["op"] == "0", str(s2_still))
|
|
276
|
+
page.evaluate("document.getElementById('rx-s2').scrollIntoView({block:'center'})")
|
|
277
|
+
page.wait_for_timeout(1200)
|
|
278
|
+
s2 = [page.evaluate(css, "rx-s2-c%d" % i) for i in (1, 2)]
|
|
279
|
+
row("REVEAL", "second reveals by class alone", all(x["op"] == "1" for x in s2),
|
|
280
|
+
str(s2[0]))
|
|
281
|
+
b.close()
|
|
282
|
+
return rows
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def main():
|
|
286
|
+
ap = argparse.ArgumentParser()
|
|
287
|
+
ap.add_argument("--config")
|
|
288
|
+
ap.add_argument("--post", type=int, required=True)
|
|
289
|
+
ap.add_argument("--slug", required=True)
|
|
290
|
+
ap.add_argument("--csv")
|
|
291
|
+
a = ap.parse_args()
|
|
292
|
+
cfg = mosaic_config.load(a.config)
|
|
293
|
+
master = build(Client(cfg), cfg, a.post, a.slug)
|
|
294
|
+
print("built on master %s" % master[:8])
|
|
295
|
+
rows = drive("%s/%s/" % (cfg["base"].rstrip("/"), a.slug))
|
|
296
|
+
fails = sum(r[2] == "FAIL" for r in rows)
|
|
297
|
+
print("%d of %d checks passed" % (len(rows) - fails, len(rows)))
|
|
298
|
+
if a.csv:
|
|
299
|
+
with open(a.csv, "w", newline="", encoding="utf-8") as fh:
|
|
300
|
+
w = csv.writer(fh)
|
|
301
|
+
w.writerow(["recipe", "check", "status", "evidence"])
|
|
302
|
+
w.writerows(rows)
|
|
303
|
+
sys.exit(1 if fails else 0)
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
if __name__ == "__main__":
|
|
307
|
+
main()
|