mosaic-headless 1.40.3 → 1.42.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/README.ja.md +2 -2
- package/README.ko.md +2 -2
- package/README.md +2 -2
- package/README.zh-TW.md +2 -2
- package/SKILL.md +1 -1
- 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/pending.csv +4 -0
- package/package.json +1 -1
- package/references/facts.md +96 -0
- package/references/tools.md +2 -2
- package/tools/from_elementor.py +2 -2
- package/tools/inline_html.py +2 -1
- package/tools/sync_nodes.py +160 -13
- package/tools/test_mosaic.py +98 -0
- package/tools/verify_browser.py +245 -1
package/README.ja.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<img src="https://img.shields.io/badge/node_properties-120-success?style=flat-square" alt="120 個の node プロパティ">
|
|
19
19
|
<img src="https://img.shields.io/badge/style_properties-101-success?style=flat-square" alt="101 個のスタイルプロパティ">
|
|
20
20
|
<img src="https://img.shields.io/badge/responsive_checks-733-blueviolet?style=flat-square" alt="733 件のレスポンシブ検査">
|
|
21
|
-
<img src="https://img.shields.io/badge/self--tests-
|
|
21
|
+
<img src="https://img.shields.io/badge/self--tests-62-blueviolet?style=flat-square" alt="62 項目のセルフテスト">
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
24
|
<p align="center">
|
|
@@ -183,7 +183,7 @@ node type、node プロパティ、スタイルプロパティ、スタイル状
|
|
|
183
183
|
| `data/theme-zip-verification.csv` | 22 | Mosaic 自身のテーマ ZIP を往復させて比較 |
|
|
184
184
|
| `data/conversion-batch.csv` | 19 | あるサイトのすべての Elementor ページを変換・構築・検査 |
|
|
185
185
|
|
|
186
|
-
- セルフテスト:`python tools/test_mosaic.py`、オフラインの
|
|
186
|
+
- セルフテスト:`python tools/test_mosaic.py`、オフラインの 62 項目(検索、中国語の用語、構築結果の形と拒否ルール、公開されている構築インターフェース、このリポジトリの数値とプライバシー)。
|
|
187
187
|
- evals:Mosaic 1.0.10〜1.0.12 の挙動に関する 16 問。skill ありで 16/16、なしで 0/16。結果:[evals/RESULTS.md](evals/RESULTS.md)。
|
|
188
188
|
- `SKILL.md`、これらの README、バッジの数値は、`tools/check_numbers.py` がデータと照合しています。詳細:[verification-record.md](references/verification-record.md)。
|
|
189
189
|
|
package/README.ko.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<img src="https://img.shields.io/badge/node_properties-120-success?style=flat-square" alt="120개 node 속성">
|
|
19
19
|
<img src="https://img.shields.io/badge/style_properties-101-success?style=flat-square" alt="101개 스타일 속성">
|
|
20
20
|
<img src="https://img.shields.io/badge/responsive_checks-733-blueviolet?style=flat-square" alt="733개 반응형 검사">
|
|
21
|
-
<img src="https://img.shields.io/badge/self--tests-
|
|
21
|
+
<img src="https://img.shields.io/badge/self--tests-62-blueviolet?style=flat-square" alt="62개 자체 테스트">
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
24
|
<p align="center">
|
|
@@ -183,7 +183,7 @@ node type, node 속성, 스타일 속성, 스타일 상태는 플러그인 소
|
|
|
183
183
|
| `data/theme-zip-verification.csv` | 22 | Mosaic 자체 테마 ZIP을 왕복시켜 비교 |
|
|
184
184
|
| `data/conversion-batch.csv` | 19 | 한 사이트의 모든 Elementor 페이지를 변환, 구축, 검사 |
|
|
185
185
|
|
|
186
|
-
- 자체 테스트: `python tools/test_mosaic.py`, 오프라인 테스트
|
|
186
|
+
- 자체 테스트: `python tools/test_mosaic.py`, 오프라인 테스트 62개(조회, 중국어 용어, 구축 결과의 형태와 거부 규칙, 공개된 구축 인터페이스, 이 저장소의 숫자와 개인정보).
|
|
187
187
|
- evals: Mosaic 1.0.10~1.0.12 동작에 관한 16문항. skill 사용 시 16/16, 미사용 시 0/16. 결과: [evals/RESULTS.md](evals/RESULTS.md).
|
|
188
188
|
- `SKILL.md`, 이 README들, 배지의 숫자는 `tools/check_numbers.py`가 데이터와 대조합니다. 자세한 내용: [verification-record.md](references/verification-record.md).
|
|
189
189
|
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<img src="https://img.shields.io/badge/node_properties-120-success?style=flat-square" alt="120 node properties">
|
|
19
19
|
<img src="https://img.shields.io/badge/style_properties-101-success?style=flat-square" alt="101 style properties">
|
|
20
20
|
<img src="https://img.shields.io/badge/responsive_checks-733-blueviolet?style=flat-square" alt="733 responsive checks">
|
|
21
|
-
<img src="https://img.shields.io/badge/self--tests-
|
|
21
|
+
<img src="https://img.shields.io/badge/self--tests-62-blueviolet?style=flat-square" alt="62 self-tests">
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
24
|
<p align="center">
|
|
@@ -183,7 +183,7 @@ Node types, node properties, style properties and style states are extracted fro
|
|
|
183
183
|
| `data/theme-zip-verification.csv` | 22 | Mosaic's own theme ZIP round-tripped and compared |
|
|
184
184
|
| `data/conversion-batch.csv` | 19 | every Elementor page of a site converted, built and checked |
|
|
185
185
|
|
|
186
|
-
- Self-test: `python tools/test_mosaic.py`,
|
|
186
|
+
- Self-test: `python tools/test_mosaic.py`, 62 offline tests (lookups, Chinese terms, the build output's shape and refusals, the public build interface, this repository's numbers and privacy).
|
|
187
187
|
- Evals: 16 questions about Mosaic 1.0.10 to 1.0.12 behaviour; with the skill 16/16, without it 0/16. Results: [evals/RESULTS.md](evals/RESULTS.md).
|
|
188
188
|
- Every number in `SKILL.md`, these READMEs and their badges is checked against the data by `tools/check_numbers.py`. Detail: [verification-record.md](references/verification-record.md).
|
|
189
189
|
|
package/README.zh-TW.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<img src="https://img.shields.io/badge/node_properties-120-success?style=flat-square" alt="120 個 node 屬性">
|
|
19
19
|
<img src="https://img.shields.io/badge/style_properties-101-success?style=flat-square" alt="101 個樣式屬性">
|
|
20
20
|
<img src="https://img.shields.io/badge/responsive_checks-733-blueviolet?style=flat-square" alt="733 條 RWD 檢查">
|
|
21
|
-
<img src="https://img.shields.io/badge/self--tests-
|
|
21
|
+
<img src="https://img.shields.io/badge/self--tests-62-blueviolet?style=flat-square" alt="62 項自我測試">
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
24
|
<p align="center">
|
|
@@ -183,7 +183,7 @@ node type、node 屬性、樣式屬性、樣式狀態從外掛原始碼抽出(
|
|
|
183
183
|
| `data/theme-zip-verification.csv` | 22 | Mosaic 自己的佈景 ZIP 匯出再匯入並比對 |
|
|
184
184
|
| `data/conversion-batch.csv` | 19 | 一個網站的每個 Elementor 頁面都轉換、建置並檢查 |
|
|
185
185
|
|
|
186
|
-
- 自我測試:`python tools/test_mosaic.py`,
|
|
186
|
+
- 自我測試:`python tools/test_mosaic.py`,62 項離線測試(查詢、中文用語、建頁產出的結構與拒收規則、對外的建頁介面、本 repo 的數字與隱私)。
|
|
187
187
|
- evals:16 題 Mosaic 1.0.10 到 1.0.12 的行為題;有 skill 16/16,沒有 skill 0/16。結果見 [evals/RESULTS.md](evals/RESULTS.md)。
|
|
188
188
|
- `SKILL.md`、這幾份 README 和徽章上的數字,都由 `tools/check_numbers.py` 對照資料核對。細節見 [verification-record.md](references/verification-record.md)。
|
|
189
189
|
|
package/SKILL.md
CHANGED
package/data/pending.csv
CHANGED
|
@@ -15,3 +15,7 @@ date,question,why_not_found,asked_by,status
|
|
|
15
15
|
2026-11-21,"Should build_site.py look up a post's existing template before binding, instead of always creating a new master and template?","a design decision, not a gap: em925's deploy tool imports build_site, so its behaviour is left unchanged (its md5 is part of em925's agreement). sync_nodes.py + list_bindings.php now cover in-place updates; build_site.py's limits are documented in SKILL.md and references/tools.md","skill 總機 (batch 3 item 20, batch 4 item 32)",open
|
|
16
16
|
2026-11-24,"Does Mosaic 1.0.14 really answer 503 (Retry-After 30, no-cache) and write no root when the database connection is lost mid-render?","read from the 1.0.14 source and WordPress 7.1.5's wpdb only; measuring it needs the database to go away under a front-end render, not done on the shared demo site",skill 總機 (Mosaic 1.0.14 re-verification),open
|
|
17
17
|
2026-11-24,Mosaic's own ZIP import of a ~24k-node theme exhausts a 512M PHP memory limit in createTemplates,"measured once on the demo site (1.0.14; the import flow's PHP is unchanged since 1.0.12); how much memory a theme that size needs, or whether Mosaic splits the tick, is not known. theme_import.php handles it",skill 總機 (Mosaic 1.0.14 re-verification),open
|
|
18
|
+
2026-11-24,"Add a RELEASING.md (rewrite of gutenberg-headless's for this repo: PR, merge, push the tag, CI publishes via OIDC)","a to-do, not a gap: the repo has none, so v1.41.0 followed gutenberg-headless's; skill 總機 asked for it with the next release",skill 總機 (round-button brief 2026-11-24),"closed 2026-11-25: RELEASING.md added with v1.42.0 (PR, merge, push the tag, CI publishes via OIDC)"
|
|
19
|
+
2026-11-24,Add a references/facts.md entry: WooCommerce coming-soon mode (store pages only) + Mosaic -> store pages answer 406. Woo renders its coming-soon page and returns '' from template_include; Mosaic's themes/mosaic/functions.php forces its index.php anyway; with no archive-product/single-product Mosaic template FrontendRenderer sets status_header(406). Also: does a store page that HAS a Mosaic template print two documents (Woo's page + Mosaic's) while coming-soon is on?,"the 406 is traced from source and read on the demo site (1.0.14, /shop/ and a product page, read-only); the two-document case is predicted from the code only - measuring it needs a store template written on the demo site, which waits for moksa 總機. Do the facts entry with the next release, together with RELEASING.md",skill 總機 (demo /shop/ 406 trace 2026-11-24),closed 2026-11-25: references/facts.md section added with v1.42.0; the two-document case is still open (row below)
|
|
20
|
+
2026-11-25,Does a WooCommerce store page that HAS a Mosaic template print two documents while coming-soon is on?,"predicted from the code only (references/facts.md, WooCommerce coming soon section); measuring it needs a store template written on the shared demo site, which waits for moksa 總機",skill 總機 (demo /shop/ 406 trace 2026-11-24),open
|
|
21
|
+
2026-11-25,"Variable-mode switch vs Chrome's visited-link colour, and @property <color> vs var() fallbacks on links","reported by a fourth site (references/facts.md, fourth site); not reproduced here - needs a theme with a mode collection, a visited link and screenshots (getComputedStyle cannot show visited colours)",skill 總機 (sync_nodes interaction target brief 2026-11-25),open
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mosaic-headless",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.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",
|
package/references/facts.md
CHANGED
|
@@ -147,6 +147,18 @@ Platform and rendered-tag facts, each measured. Moved out of SKILL.md on 2026-11
|
|
|
147
147
|
whose spec set neither; between a masthead and the block below it that is a
|
|
148
148
|
160px hole. Set `paddingTop`/`paddingBottom` explicitly when a section's rhythm
|
|
149
149
|
is meant to come from its contents.
|
|
150
|
+
- **`button` arrives with `padding: 12px 24px`, so a round button is an ellipse until
|
|
151
|
+
all four paddings are 0.** `.m-button{…width:fit-content;padding:12px 24px;…}` in the
|
|
152
|
+
1.0.14 stylesheet (the `:where(button.m-button)` reset to `padding:0` has no
|
|
153
|
+
specificity and loses). Measured on the demo site (1.0.14, Chromium, 1440px,
|
|
154
|
+
`getBoundingClientRect`, at rest and hovered): a button with no style is 48 x 24;
|
|
155
|
+
`width`/`height` 44px with `borderRadius` 999px - or 50% - renders **48 x 44**,
|
|
156
|
+
because 24 + 24 > 44; the same button with `paddingTop`, `paddingBottom`,
|
|
157
|
+
`paddingLeft` and `paddingRight` all `0px` renders 44 x 44. Reported first from a
|
|
158
|
+
client site (four 44px circles at 48 x 44, 44 x 44 after the fix). The fill that
|
|
159
|
+
shows the shape is often a `hover` background, so a screenshot at rest looks fine:
|
|
160
|
+
`verify_browser.py` reports it as `ROUND_NOT_ROUND`, measured hovered too
|
|
161
|
+
(`--round URL` runs that check alone on any public page).
|
|
150
162
|
- **A `code` node's content is a template, and `@media(` is a function call.**
|
|
151
163
|
Mosaic parses `code` content for `@VAR(...)`; a CSS at-rule glued to its
|
|
152
164
|
parenthesis - the form every minifier emits - is parsed as a call with
|
|
@@ -482,3 +494,87 @@ also checked here against the 1.0.13 source.
|
|
|
482
494
|
- The `modal` open state is `:popover-open`, not `dialog[open]` (already above, under
|
|
483
495
|
1.0.10), and there is no `flex` style key (above, second site): both confirmed again
|
|
484
496
|
on this site.
|
|
497
|
+
|
|
498
|
+
## Measured on a fourth site (Mosaic 1.0.13, 2026-11-25)
|
|
499
|
+
|
|
500
|
+
From another site's conversion (an intro animation and a dark mode), handed to this
|
|
501
|
+
skill; each line says what was reproduced here on the demo site (Mosaic 1.0.14).
|
|
502
|
+
|
|
503
|
+
- **An interaction's target is a node ID, and an in-place sync used to break it.**
|
|
504
|
+
`settings.target = {"type": "element", "uuid": ...}` names the target node's `ID`.
|
|
505
|
+
`build_page.py` gives every pinned `nodeID` a fresh random uuid on each run, so a
|
|
506
|
+
spec never knows the live ids. `sync_nodes.py` before 1.42.0 wrote the spec's
|
|
507
|
+
interactions as they were: the targets named this run's random uuids, no node on
|
|
508
|
+
the site, and the animation did nothing (that site: an intro's curtain, horse and
|
|
509
|
+
logo stood still; only the wrapper faded). Reproduced on the demo: built with three
|
|
510
|
+
targets that existed, synced a duration change with 1.41.0 -> all three targets
|
|
511
|
+
MISSING; its read-back did say `@st-intro differs`, but next to two false
|
|
512
|
+
differences (below), so it read as noise. 1.42.0 rewrites spec ids to live ids
|
|
513
|
+
(spec `nodeID` -> attrID -> live `ID`) before writing, refuses a write whose target
|
|
514
|
+
is not a node of the document (or of the master, for a template), and fails the run
|
|
515
|
+
(exit 1) if a written node targets a missing node after the commit. Re-synced on
|
|
516
|
+
the demo with 1.42.0: the three targets were the live ids again, `document.getAnimations()`
|
|
517
|
+
in Chromium had an animation on each, and a dry run after it showed 0 differences.
|
|
518
|
+
- **Two tweens of the same property on one element do not chain.** At page load every
|
|
519
|
+
tween's `initial` is applied at once, so the later one's start value wins and the
|
|
520
|
+
first never shows. Demo, 1.0.14, Chromium: one element with `translateX` 0 -> 100px
|
|
521
|
+
(1.5 s) then 100px -> 200px (1.5 s, delay 1.5 s) stood at 100px from the first
|
|
522
|
+
sample (14 ms) until 1.5 s, then moved 100 -> 200px; a control with one tween
|
|
523
|
+
0 -> 200px over 3 s started at 0. Each tween is its own Web Animation (both on
|
|
524
|
+
`--mosaic-translate-x`). Use ONE tween with a longer duration (to
|
|
525
|
+
`calc(100vw + <width>)` for "runs off the screen") instead of two legs.
|
|
526
|
+
- **A variable-mode switch is an animation on `<html>`, and Chrome's visited-link
|
|
527
|
+
colour does not see it.** The mode-switch action is an `animation` action with a
|
|
528
|
+
`collectionMode` property meta (`tools/interactions.py` `mode_switch`), and it
|
|
529
|
+
runs as a Web Animation on `<html>` (the demo's `document.getAnimations()` lists one
|
|
530
|
+
targeting `HTML`). That site found that Chrome computes the colour of a VISITED link
|
|
531
|
+
without the animated values: after a switch to dark, links the visitor has opened
|
|
532
|
+
keep the light value and can disappear, and `getComputedStyle` cannot show it (it
|
|
533
|
+
reports the unvisited value, for privacy) - only a screenshot does. Its fix: after
|
|
534
|
+
every switch (and on load) copy the current value of each `--*` variable onto
|
|
535
|
+
`<html style>`. Reported by that site, not reproduced here (needs a theme with a
|
|
536
|
+
mode collection and a visited link).
|
|
537
|
+
- **A colour variable registered as `@property <color>` makes `var(--x, fallback)`
|
|
538
|
+
use the fallback on links** (that site: outlines and colours on `<a>` came out in the
|
|
539
|
+
fallback colour). Write colour variables without a fallback in generated CSS (font
|
|
540
|
+
variables are not affected). Reported by that site, not reproduced here.
|
|
541
|
+
- **Dark mode has to remap Mosaic's front-end colours too.** Mosaic's theme
|
|
542
|
+
stylesheet paints form fields from its own variables:
|
|
543
|
+
`input:where(:not([type=file],[type=checkbox],[type=radio])),textarea,select` get
|
|
544
|
+
`background-color: var(--mosaic-frontend-white)` (#ffffff), `color` from
|
|
545
|
+
`--mosaic-frontend-neutral-800` and the border from `-neutral-300`; `[type=checkbox],
|
|
546
|
+
[type=radio]` get the same white background, and a checked box is `-neutral-900` with
|
|
547
|
+
a `-white` tick (1.0.14 `themes/mosaic/public/style.css`). And
|
|
548
|
+
WooCommerce's fields use its own `--wc-form-color-*`. Without setting those on
|
|
549
|
+
`:root` for the dark mode, inputs and checkboxes stay white (that site). Map
|
|
550
|
+
`--mosaic-frontend-white`, `--mosaic-frontend-black`, `--mosaic-frontend-neutral-*`
|
|
551
|
+
and `--wc-form-color-*` to the mode's tokens.
|
|
552
|
+
- **Stored values `sync_nodes.py` now treats as equal** (demo, 1.0.14): `opacity ".35"`
|
|
553
|
+
is stored `"0.35"`; `url(x)` in `customDeclarations` is stored `url("x")`; an `rgba()`
|
|
554
|
+
keeps `.85` but gains spaces. And **`rel` must be a list**: on a `wysiwyg-link`,
|
|
555
|
+
`"rel": "noopener"` was stored as null and `["noopener"]` was kept (its validator is
|
|
556
|
+
`ValidatorArray`; `data/node-property-verification.csv` already had the list
|
|
557
|
+
APPLIED). `inline_html.py` and `from_elementor.py` wrote a string until 1.42.0, so
|
|
558
|
+
every converted `rel` was lost; they write a list now, and a sync treats an old
|
|
559
|
+
string `rel` against an empty one as no difference (with a note).
|
|
560
|
+
|
|
561
|
+
## WooCommerce "coming soon" + Mosaic: store pages answer 406 (demo, 2026-11-24)
|
|
562
|
+
|
|
563
|
+
Traced in source and read on the demo (Mosaic 1.0.14, WooCommerce 11.2, read only):
|
|
564
|
+
with WooCommerce's coming-soon mode on for **store pages only**, `/shop/` and every
|
|
565
|
+
product page answer **HTTP 406**.
|
|
566
|
+
|
|
567
|
+
- WooCommerce renders its coming-soon page itself and then returns `''` from the
|
|
568
|
+
`template_include` filter (`ComingSoonRequestHandler.php`, line 117) so WordPress
|
|
569
|
+
loads no theme template.
|
|
570
|
+
- Mosaic's theme ignores that and forces its own `index.php`
|
|
571
|
+
(`themes/mosaic/functions.php`, line 54).
|
|
572
|
+
- With no Mosaic template for the store (`archive-product` / `single-product`, nor a
|
|
573
|
+
generic archive / index one), the renderer throws `TemplateNotFoundException` and
|
|
574
|
+
`FrontendRenderer.php` (line 62) sends `status_header(406)`.
|
|
575
|
+
- A `200` seen with a query string was a cached copy (Varnish HIT), not a fix.
|
|
576
|
+
|
|
577
|
+
What to do: take the store out of coming-soon mode (go live), and give the store its
|
|
578
|
+
Mosaic templates. Not measured: a store page that DOES have a Mosaic template while
|
|
579
|
+
coming-soon is on may print two documents (WooCommerce's page and Mosaic's) - the
|
|
580
|
+
code predicts it; testing it needs a store template written on the demo.
|
package/references/tools.md
CHANGED
|
@@ -11,7 +11,7 @@ Every tool in `tools/`, and where the REST session comes from. Moved out of SKIL
|
|
|
11
11
|
| `build_page.py` | commit one page spec through the verified write path |
|
|
12
12
|
| `build_site.py` | a whole site: one master with the shell, one document per page. It makes a NEW master and new templates on EVERY run and re-binds every page it builds, so a one-line change means a full rebuild, and building only some pages leaves the site split across masters (a header edit then reaches some pages and not others). For changes to a built site use `sync_nodes.py` |
|
|
13
13
|
| `verify_rwd.py` | does every `_t`/`_m` declaration reach the served stylesheet? |
|
|
14
|
-
| `verify_browser.py` | does the **browser** compute what the stylesheet promised - and does the result pass a design audit? |
|
|
14
|
+
| `verify_browser.py` | does the **browser** compute what the stylesheet promised - and does the result pass a design audit? The audit includes `ROUND_NOT_ROUND`: every element whose corners are all >= 999px or >= 50% is measured with `getBoundingClientRect` at rest and hovered, and an unequal width and height is an error (a pill longer than 1.5 : 1, or one showing more than 2 characters of text, is not). `--round URL ...` runs that check alone on any public page: no spec, no session, images and fonts not fetched, stops at the first 403 |
|
|
15
15
|
| `verify_intro.py` | does the page-load animation play, and - the part that matters - does it END and hand the page back? |
|
|
16
16
|
| `verify_menus.py` | build and drive every site-menu option: does hover hold, do the keyboard and a touch tablet work, does the phone drawer trap focus, close on Esc and stay above a sticky header? |
|
|
17
17
|
| `verify_loop.py` | a decoration that runs forever: does it loop (paused-timeline scrub), does it bury text or controls anywhere a reader can rest, does it open by pointer and by keyboard, is it still under reduced motion? |
|
|
@@ -40,7 +40,7 @@ Every tool in `tools/`, and where the REST session comes from. Moved out of SKIL
|
|
|
40
40
|
| `verify_dialog.py` | the modal in a real browser (1.0.9 and 1.0.10 alike: open is read as `:popover-open` or `dialog.open`): does it open, close, answer Esc, remember, cap - and does an OpenStreetMap carry the coordinates it was given |
|
|
41
41
|
| `verify_popovers.py` | 1.0.10's popover in a real browser: opens, lands where its positioning says, blocks nothing, closes the way closedby says, flips, chains, and ends - every check reads `:popover-open`, never an attribute |
|
|
42
42
|
| `verify_dialog_lab.py` | the question after "does the modal work": can three nodes be made into a bottom sheet, a side drawer, a corner notice, a full takeover and a gate with no way out - and does each one still fit at phone width, which the page's own width check cannot see |
|
|
43
|
-
| `sync_nodes.py` | update a built site IN PLACE: matches the spec to the live master and each page's template by `attrID`, commits only the nodes whose data changed, rebuilds a page's template when its structure changed (one commit, or new tree first and old removed after in batches of 150), refuses a site split across masters or a document with two roots, saves every document's JSON before writing, re-reads and verifies after. Dry run unless `--apply`; `--attr a,b` limits the comparison and the writes to those subtrees. Before comparing it normalises what Mosaic rewrites on save (re-spaced CSS and colours, rewritten svg, keys a type does not keep, interaction ids, build_page's random list-item uuids) and leaves alone the children heal inserts (references/facts.md, third site). Read the dry run before `--apply`: it should list only what you changed. `build_site.py` makes a new master every run, so use this for any change to a site that is already built |
|
|
43
|
+
| `sync_nodes.py` | update a built site IN PLACE: matches the spec to the live master and each page's template by `attrID`, commits only the nodes whose data changed, rebuilds a page's template when its structure changed (one commit, or new tree first and old removed after in batches of 150), refuses a site split across masters or a document with two roots, saves every document's JSON before writing, re-reads and verifies after. Dry run unless `--apply`; `--attr a,b` limits the comparison and the writes to those subtrees. Before comparing it normalises what Mosaic rewrites on save (re-spaced CSS and colours, rewritten svg, keys a type does not keep, interaction ids, build_page's random list-item uuids) and leaves alone the children heal inserts (references/facts.md, third site). Interaction targets (`settings.target = {"type": "element", "uuid": ...}`) and any other reference to a spec node are rewritten to the live node's id before writing (spec `nodeID` -> attrID -> live id); a target that would name a node not in the document (or, for a template, its master) is refused before the commit and fails the run after it (exit 1). Read the dry run before `--apply`: it should list only what you changed. `build_site.py` makes a new master every run, so use this for any change to a site that is already built |
|
|
44
44
|
| `list_bindings.php` | read only, `wp eval-file tools/list_bindings.php <themeID> > bindings.json`: which template and master serve each post (`wp_mosaic_template_assigns`, which the REST API does not list) - the input `sync_nodes.py` needs |
|
|
45
45
|
| `verify_lightbox.py` | the WooCommerce product-image lightbox (PhotoSwipe) at 390 / 820 / 1024 / 1440px: close button flush with the toolbar's top-right corner, counter top-left, spinner out of the flow - WooCommerce's own skin breaks the first at 1024px and below (references/standard-fixes.md) |
|
|
46
46
|
| `verify_sticky.py` | a sticky element while the page scrolls: rectangle intersection with every `--avoid` element at each step, never past its `--bound` container, actually stuck at `--top` - a computed `position: sticky` passes a column that rides over the whole page |
|
package/tools/from_elementor.py
CHANGED
|
@@ -284,7 +284,7 @@ def as_button(el, ctx):
|
|
|
284
284
|
if link.get("is_external"):
|
|
285
285
|
data["target"] = "_blank"
|
|
286
286
|
if link.get("nofollow"):
|
|
287
|
-
data["rel"] = "nofollow"
|
|
287
|
+
data["rel"] = ["nofollow"] # a list; a string is dropped on save
|
|
288
288
|
node = {"type": "button", "data": data,
|
|
289
289
|
"children": inline_children(s.get("text") or s.get("button_text") or "")}
|
|
290
290
|
extra = {}
|
|
@@ -440,7 +440,7 @@ class Ctx:
|
|
|
440
440
|
if link.get("is_external"):
|
|
441
441
|
data["target"] = "_blank"
|
|
442
442
|
if link.get("nofollow"):
|
|
443
|
-
data["rel"] = "nofollow"
|
|
443
|
+
data["rel"] = ["nofollow"] # a list; a string is dropped on save
|
|
444
444
|
return {"type": "menu-link", "data": data, "children": [node]}
|
|
445
445
|
|
|
446
446
|
def note(self, el, why):
|
package/tools/inline_html.py
CHANGED
|
@@ -95,7 +95,8 @@ def _inline(nodes):
|
|
|
95
95
|
if attrs.get("target") in ("_self", "_blank", "_parent", "_top"):
|
|
96
96
|
data["target"] = attrs["target"]
|
|
97
97
|
if attrs.get("rel"):
|
|
98
|
-
|
|
98
|
+
# a list: rel's validator is ValidatorArray, a string is dropped on save
|
|
99
|
+
data["rel"] = attrs["rel"].split()
|
|
99
100
|
out.append({"type": "wysiwyg-link", "data": data, "children": _inline(kids)})
|
|
100
101
|
elif tag in SPAN_STYLE:
|
|
101
102
|
out.append({"type": "wysiwyg-span", "data": {},
|
package/tools/sync_nodes.py
CHANGED
|
@@ -18,7 +18,9 @@ What this does, per document (the shared master, and each page's own template):
|
|
|
18
18
|
is written to compute them - and matches spec nodes to live nodes by `attrID`
|
|
19
19
|
(nodes without one by their position under the nearest node that has one);
|
|
20
20
|
3. same structure, different content -> one commit to that document updating only
|
|
21
|
-
the nodes that differ (each node's top-level data keys the spec sets)
|
|
21
|
+
the nodes that differ (each node's top-level data keys the spec sets), with every
|
|
22
|
+
spec node id inside the written data - an interaction's target above all -
|
|
23
|
+
rewritten to the id of the live node it was matched to;
|
|
22
24
|
4. different structure in a PAGE -> that page's template is rebuilt in ONE commit
|
|
23
25
|
(old nodes deleted and new ones created together, so the page is never served
|
|
24
26
|
empty), on the master it already has. A structural change in the master's header
|
|
@@ -27,9 +29,11 @@ What this does, per document (the shared master, and each page's own template):
|
|
|
27
29
|
Safety: dry run unless --apply. Before writing, every document it will touch is
|
|
28
30
|
saved as JSON under --backup (a restore source; also take `wp db export` of
|
|
29
31
|
wp_mosaic_nodes on the host). It refuses a site whose pages sit on more than one
|
|
30
|
-
master.
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
master. Before a commit, every element target in it must name a node of the
|
|
33
|
+
document (or of the master, for a template). After writing it re-reads each
|
|
34
|
+
document: no extra root, no component instance newly reduced to override shells,
|
|
35
|
+
no written node targeting a node that does not exist, and the diff now empty -
|
|
36
|
+
otherwise exit 1. It writes only through the editor's REST routes (an admin request), never
|
|
33
37
|
from a front-end render. Pages that use components can be content-synced but not
|
|
34
38
|
rebuilt here (their overrides need build_site.py's override pass).
|
|
35
39
|
|
|
@@ -76,6 +80,11 @@ UUID_RE = re.compile(r"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]
|
|
|
76
80
|
TAG_RE = re.compile(r"<([A-Za-z][\w:.-]*)((?:\s+[^\s=>/]+(?:\s*=\s*(?:\"[^\"]*\"|'[^']*'|[^\s>]+))?)*)\s*(/?)>")
|
|
77
81
|
ATTR_RE = re.compile(r"([^\s=>/]+)(?:\s*=\s*(\"[^\"]*\"|'[^']*'|[^\s>]+))?")
|
|
78
82
|
COLOR_FN_RE = re.compile(r"^\s*(?:rgba?|hsla?)\(", re.I)
|
|
83
|
+
LEAD_DOT_RE = re.compile(r"(?<![\w.])\.(\d)")
|
|
84
|
+
URL_ARG_RE = re.compile(r"url\((\"?)([^\")]*)\1\)")
|
|
85
|
+
NUMBERISH_RE = re.compile(r"^[-+]?(?:\d*\.)?\d+[a-z%]*$", re.I)
|
|
86
|
+
# Text keys: words, not values; .35 inside a sentence is left alone.
|
|
87
|
+
TEXT_KEYS = {"text", "v", "url", "alt", "title", "label", "placeholder"}
|
|
79
88
|
# Data keys a node type does not keep: sent, accepted, and stored as null (button and
|
|
80
89
|
# menu-link `attributes`, a form label's `forInput`, tabs-menu `accessibleLabel`;
|
|
81
90
|
# measured 2026-11-21). Compared only when the site does hold a value for them.
|
|
@@ -114,8 +123,15 @@ def css_norm(text: str) -> str:
|
|
|
114
123
|
# the spaces around them are significant.
|
|
115
124
|
text = (text or "").replace("'", '"')
|
|
116
125
|
text = re.sub(r"\s+", " ", text).strip()
|
|
117
|
-
text = re.sub(r"\s*([:;,{}()
|
|
118
|
-
|
|
126
|
+
text = re.sub(r"\s*([:;,{}()/!>])\s*", r"\1", text)
|
|
127
|
+
text = re.sub(r";+", ";", text)
|
|
128
|
+
text = URL_ARG_RE.sub(lambda m: 'url("%s")' % m.group(2), text) # url(x) is stored as url("x")
|
|
129
|
+
return lead_zero(text).rstrip(";")
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def lead_zero(text: str) -> str:
|
|
133
|
+
""".35 and 0.35 are the same number; Mosaic stores 0.35 for a style value of .35."""
|
|
134
|
+
return LEAD_DOT_RE.sub(r"0.\1", text)
|
|
119
135
|
|
|
120
136
|
|
|
121
137
|
def svg_norm(text: str) -> str:
|
|
@@ -138,6 +154,68 @@ def svg_norm(text: str) -> str:
|
|
|
138
154
|
return re.sub(r">\s+<", "><", re.sub(r"\s+", " ", text)).strip()
|
|
139
155
|
|
|
140
156
|
|
|
157
|
+
def remap_ids(value, id_map: dict):
|
|
158
|
+
"""A copy of a spec data value with every spec node id replaced by the live id of the
|
|
159
|
+
node it was matched to. refresh_node_ids gives each pinned nodeID a NEW random uuid on
|
|
160
|
+
every run, and an interaction's `settings.target = {"type": "element", "uuid": ...}`
|
|
161
|
+
carries that uuid; written as is, the target names a node that is not on the site and
|
|
162
|
+
the animation silently does nothing (live site, 2026-11-25: three elements stopped)."""
|
|
163
|
+
def walk(v):
|
|
164
|
+
if isinstance(v, dict):
|
|
165
|
+
return {(id_map.get(k.lower(), k) if isinstance(k, str) else k): walk(x) for k, x in v.items()}
|
|
166
|
+
if isinstance(v, list):
|
|
167
|
+
return [walk(x) for x in v]
|
|
168
|
+
if isinstance(v, str):
|
|
169
|
+
return id_map.get(v.lower(), v)
|
|
170
|
+
return v
|
|
171
|
+
return walk(value)
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def id_strings(value) -> set:
|
|
175
|
+
"""Every string (and dict key) in a value, lower-cased: to find spec ids left in it."""
|
|
176
|
+
out = set()
|
|
177
|
+
|
|
178
|
+
def walk(v):
|
|
179
|
+
if isinstance(v, dict):
|
|
180
|
+
for k, x in v.items():
|
|
181
|
+
if isinstance(k, str):
|
|
182
|
+
out.add(k.lower())
|
|
183
|
+
walk(x)
|
|
184
|
+
elif isinstance(v, list):
|
|
185
|
+
for x in v:
|
|
186
|
+
walk(x)
|
|
187
|
+
elif isinstance(v, str):
|
|
188
|
+
out.add(v.lower())
|
|
189
|
+
walk(value)
|
|
190
|
+
return out
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def element_targets(value) -> list[str]:
|
|
194
|
+
"""The node ids a value points at: every {"type": "element", "uuid": <id>}."""
|
|
195
|
+
out = []
|
|
196
|
+
|
|
197
|
+
def walk(v):
|
|
198
|
+
if isinstance(v, dict):
|
|
199
|
+
t = v.get("target")
|
|
200
|
+
if isinstance(t, dict) and t.get("type") == "element" and isinstance(t.get("uuid"), str):
|
|
201
|
+
out.append(t["uuid"])
|
|
202
|
+
for x in v.values():
|
|
203
|
+
walk(x)
|
|
204
|
+
elif isinstance(v, list):
|
|
205
|
+
for x in v:
|
|
206
|
+
walk(x)
|
|
207
|
+
walk(value)
|
|
208
|
+
return out
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def dangling_targets(nodes: list[dict], also=()) -> list[tuple[dict, str]]:
|
|
212
|
+
"""(node, target id) for every element target that is not a live node of this document
|
|
213
|
+
(or of `also`: the master's node ids, for a template)."""
|
|
214
|
+
known = {n["ID"].lower() for n in nodes if n.get("status") != "delete"} | {x.lower() for x in also}
|
|
215
|
+
return [(n, t) for n in nodes if n.get("status") != "delete"
|
|
216
|
+
for t in element_targets(n.get("data") or {}) if t.lower() not in known]
|
|
217
|
+
|
|
218
|
+
|
|
141
219
|
def normalise(value, id_map: dict, stable: set, key=None):
|
|
142
220
|
"""A comparable copy of one data value: spec node ids mapped to live ones, run-random
|
|
143
221
|
uuids renamed in order of appearance, CSS and SVG text normalised."""
|
|
@@ -174,7 +252,9 @@ def normalise(value, id_map: dict, stable: set, key=None):
|
|
|
174
252
|
if key == "svg":
|
|
175
253
|
return svg_norm(v)
|
|
176
254
|
if COLOR_FN_RE.match(v): # rgba(0, 0, 0, 0) is stored for rgba(0,0,0,0)
|
|
177
|
-
return re.sub(r"\s+", "", v)
|
|
255
|
+
return lead_zero(re.sub(r"\s+", "", v))
|
|
256
|
+
if key not in TEXT_KEYS and NUMBERISH_RE.match(v.strip()):
|
|
257
|
+
return lead_zero(v.strip()) # opacity ".35" is stored as "0.35"
|
|
178
258
|
return u(v)
|
|
179
259
|
return v
|
|
180
260
|
return walk(value, key)
|
|
@@ -274,13 +354,19 @@ def plan(spec_records: list[dict], spec_top: str, live_nodes: list[dict], live_t
|
|
|
274
354
|
if struct:
|
|
275
355
|
return False, struct, updates, notes
|
|
276
356
|
id_map = {s["ID"].lower(): l["ID"].lower() for s, l, _, _ in pairs}
|
|
357
|
+
write_map = {s["ID"].lower(): l["ID"] for s, l, _, _ in pairs}
|
|
358
|
+
unmatched = {r["ID"].lower() for r in spec_records} - set(id_map)
|
|
277
359
|
stable = stable_uuids() | {v.lower() for v in VAR_IDS.values()} | {l["ID"].lower() for _, l, _, _ in pairs}
|
|
278
360
|
for s, l, key, anc in pairs:
|
|
279
361
|
if not inside(key, anc):
|
|
280
362
|
continue
|
|
281
363
|
sd, ld = s.get("data") or {}, l.get("data") or {}
|
|
364
|
+
if isinstance(sd.get("rel"), str) and ld.get("rel") in (None, [], ""):
|
|
365
|
+
notes.append("%s: rel %r is a string - Mosaic keeps rel only as a list (%r); not counted"
|
|
366
|
+
% (key, sd["rel"], sd["rel"].split()))
|
|
282
367
|
changed = [k for k in sd
|
|
283
368
|
if not (k in DROPPED_ON_SAVE and ld.get(k) in (None, [], ""))
|
|
369
|
+
and not (k == "rel" and isinstance(sd[k], str) and ld.get(k) in (None, [], ""))
|
|
284
370
|
and json.dumps(normalise(sd[k], id_map, stable, k), sort_keys=True)
|
|
285
371
|
!= json.dumps(normalise(ld.get(k), id_map, stable, k), sort_keys=True)]
|
|
286
372
|
extra_keys = [k for k in ld if k not in sd]
|
|
@@ -288,8 +374,17 @@ def plan(spec_records: list[dict], spec_top: str, live_nodes: list[dict], live_t
|
|
|
288
374
|
notes.append("%s keeps live-only keys %s" % (key, ", ".join(extra_keys)))
|
|
289
375
|
if changed:
|
|
290
376
|
merged = dict(ld)
|
|
291
|
-
|
|
377
|
+
# spec node ids -> live ids, so an interaction target names the node that is
|
|
378
|
+
# actually on the site, not this run's random uuid
|
|
379
|
+
merged.update({k: remap_ids(sd[k], write_map) for k in changed})
|
|
380
|
+
lost = id_strings({k: merged[k] for k in changed}) & unmatched
|
|
381
|
+
if lost:
|
|
382
|
+
struct.append("%s: %s points at spec node(s) not on the site (%s) - a target "
|
|
383
|
+
"outside --attr that does not exist yet?" % (key, ", ".join(changed), ", ".join(sorted(lost))[:80]))
|
|
384
|
+
continue
|
|
292
385
|
updates.append((dict(l, _key=key), merged, changed))
|
|
386
|
+
if struct:
|
|
387
|
+
return False, struct, [], notes
|
|
293
388
|
return True, struct, updates, notes
|
|
294
389
|
|
|
295
390
|
|
|
@@ -348,6 +443,7 @@ class Run:
|
|
|
348
443
|
self.batch, self.pause = max(1, batch), max(0.0, pause)
|
|
349
444
|
self.failed = False
|
|
350
445
|
self.wrote = 0
|
|
446
|
+
self._master_ids: dict[str, set] = {}
|
|
351
447
|
|
|
352
448
|
def commit_batches(self, instance: str, what: str, key: str, records: list[dict], label: str) -> bool:
|
|
353
449
|
"""Commit in batches of self.batch records: one request carrying ~420 deletes was
|
|
@@ -371,6 +467,14 @@ class Run:
|
|
|
371
467
|
return False
|
|
372
468
|
return True
|
|
373
469
|
|
|
470
|
+
def master_ids(self, master_id: str) -> set:
|
|
471
|
+
"""The master's node ids: a template's interaction may target a header node."""
|
|
472
|
+
if master_id not in self._master_ids:
|
|
473
|
+
doc = self.read("masterDocumentInstance/%s" % master_id, "masterDocumentInstance")
|
|
474
|
+
self._master_ids[master_id] = {n["ID"] for n in doc.get("node/master/%s" % master_id) or []
|
|
475
|
+
if n.get("status") != "delete"}
|
|
476
|
+
return self._master_ids[master_id]
|
|
477
|
+
|
|
374
478
|
def read(self, instance: str, what: str) -> dict:
|
|
375
479
|
return unwrap(self.client.get(instance), what)
|
|
376
480
|
|
|
@@ -390,12 +494,44 @@ class Run:
|
|
|
390
494
|
self.wrote += 1
|
|
391
495
|
return True
|
|
392
496
|
|
|
393
|
-
def
|
|
497
|
+
def targets_ok(self, label: str, records: list[dict], live_ids: set, also=()) -> bool:
|
|
498
|
+
"""Before a commit: every element target in what is about to be written names a
|
|
499
|
+
node that will exist (live, or created in this same write)."""
|
|
500
|
+
known = {x.lower() for x in live_ids} | {x.lower() for x in also}
|
|
501
|
+
known |= {r["newRevisionRecord"]["ID"].lower() for r in records
|
|
502
|
+
if r["newRevisionRecord"].get("status") != "delete"}
|
|
503
|
+
known -= {r["newRevisionRecord"]["ID"].lower() for r in records
|
|
504
|
+
if r["newRevisionRecord"].get("status") == "delete"}
|
|
505
|
+
bad = [(r["newRevisionRecord"], t) for r in records if r["newRevisionRecord"].get("status") != "delete"
|
|
506
|
+
for t in element_targets(r["newRevisionRecord"].get("data") or {}) if t.lower() not in known]
|
|
507
|
+
for n, t in bad[:8]:
|
|
508
|
+
print(" REFUSE %s: %s targets %s, which is not on the site" % (label, (n.get("data") or {}).get("attrID") or n["ID"][:8], t))
|
|
509
|
+
if bad:
|
|
510
|
+
self.failed = True
|
|
511
|
+
return not bad
|
|
512
|
+
|
|
513
|
+
def verify(self, instance: str, what: str, key: str, before_shells: int, recheck,
|
|
514
|
+
wrote=(), also=()) -> None:
|
|
394
515
|
doc = self.read(instance, what)
|
|
395
516
|
nodes = doc.get(key) or []
|
|
396
517
|
if extra_roots(nodes):
|
|
397
518
|
print(" FAIL %s now has more than one root" % what)
|
|
398
519
|
self.failed = True
|
|
520
|
+
# The data diff alone can miss a target that points nowhere (both sides can carry
|
|
521
|
+
# an id that is not a node), so every element target is checked against the
|
|
522
|
+
# document's node ids (and the master's, for a template).
|
|
523
|
+
wrote = {x.lower() for x in wrote}
|
|
524
|
+
mine, older = [], []
|
|
525
|
+
for n, t in dangling_targets(nodes, also):
|
|
526
|
+
(mine if n["ID"].lower() in wrote else older).append((n, t))
|
|
527
|
+
for n, t in mine[:8]:
|
|
528
|
+
print(" FAIL %s: %s targets %s - no such node in the document"
|
|
529
|
+
% (what, (n.get("data") or {}).get("attrID") or n["ID"][:8], t))
|
|
530
|
+
if mine:
|
|
531
|
+
self.failed = True
|
|
532
|
+
for n, t in older[:8]:
|
|
533
|
+
print(" note %s: %s (not written by this run) targets %s - no such node"
|
|
534
|
+
% (what, (n.get("data") or {}).get("attrID") or n["ID"][:8], t))
|
|
399
535
|
after = all_shell_instances(nodes)
|
|
400
536
|
if after > before_shells:
|
|
401
537
|
print(" FAIL %s: %d component instance(s) newly reduced to override shells - restore from %s"
|
|
@@ -447,11 +583,13 @@ def sync_shell(run: Run, site: dict, master_id: str, surface, comps) -> None:
|
|
|
447
583
|
print(" update %s %s (%s)" % (ln["_key"], ln["type"], ", ".join(changed)))
|
|
448
584
|
if not (updates and run.apply):
|
|
449
585
|
return
|
|
450
|
-
print(" backup %s" % run.save(label, doc))
|
|
451
586
|
before = all_shell_instances(nodes)
|
|
452
587
|
records = [{"newRevisionRecord": {k: v for k, v in dict(ln, data=merged).items() if not k.startswith("_")},
|
|
453
588
|
"originalRevisionRecord": {k: v for k, v in ln.items() if not k.startswith("_")}}
|
|
454
589
|
for ln, merged, _ in updates]
|
|
590
|
+
if not run.targets_ok(label, records, {n["ID"] for n in nodes if n.get("status") != "delete"}):
|
|
591
|
+
return
|
|
592
|
+
print(" backup %s" % run.save(label, doc))
|
|
455
593
|
if run.commit_batches(instance, "masterDocumentInstance", key, records, label):
|
|
456
594
|
def recheck(new_nodes):
|
|
457
595
|
left = []
|
|
@@ -460,7 +598,8 @@ def sync_shell(run: Run, site: dict, master_id: str, surface, comps) -> None:
|
|
|
460
598
|
same, struct, ups, _ = plan(recs, "SPEC-TOP", new_nodes, region_parent[region], run.attrs)
|
|
461
599
|
left += struct + ["%s differs" % u[0]["_key"] for u in ups]
|
|
462
600
|
return left
|
|
463
|
-
run.verify(instance, "masterDocumentInstance", key, before, recheck
|
|
601
|
+
run.verify(instance, "masterDocumentInstance", key, before, recheck,
|
|
602
|
+
wrote={r["newRevisionRecord"]["ID"] for r in records})
|
|
464
603
|
|
|
465
604
|
|
|
466
605
|
def sync_page(run: Run, page: dict, binding: dict, surface, comps) -> None:
|
|
@@ -490,10 +629,13 @@ def sync_page(run: Run, page: dict, binding: dict, surface, comps) -> None:
|
|
|
490
629
|
print(" update %s %s (%s)" % (ln["_key"], ln["type"], ", ".join(changed)))
|
|
491
630
|
if not (updates and run.apply):
|
|
492
631
|
return
|
|
493
|
-
print(" backup %s" % run.save(label, doc))
|
|
494
632
|
records = [{"newRevisionRecord": {k: v for k, v in dict(ln, data=merged).items() if not k.startswith("_")},
|
|
495
633
|
"originalRevisionRecord": {k: v for k, v in ln.items() if not k.startswith("_")}}
|
|
496
634
|
for ln, merged, _ in updates]
|
|
635
|
+
if not run.targets_ok(label, records, {n["ID"] for n in nodes if n.get("status") != "delete"},
|
|
636
|
+
run.master_ids(master_id)):
|
|
637
|
+
return
|
|
638
|
+
print(" backup %s" % run.save(label, doc))
|
|
497
639
|
ok = run.commit_batches(instance, "templateDocumentInstance", key, records, label)
|
|
498
640
|
else:
|
|
499
641
|
print("%s: structure changed (%d difference(s)) - rebuild template %s on master %s"
|
|
@@ -519,6 +661,10 @@ def sync_page(run: Run, page: dict, binding: dict, surface, comps) -> None:
|
|
|
519
661
|
deletes = [{"newRevisionRecord": dict(n, status="delete"), "originalRevisionRecord": n}
|
|
520
662
|
for n in depth_order(old)]
|
|
521
663
|
creates = [{"newRevisionRecord": r, "originalRevisionRecord": None} for r in new] # parents first
|
|
664
|
+
records = deletes + creates
|
|
665
|
+
if not run.targets_ok(label, records, {n["ID"] for n in nodes if n.get("status") != "delete"},
|
|
666
|
+
run.master_ids(master_id)):
|
|
667
|
+
return
|
|
522
668
|
if len(deletes) + len(creates) <= run.batch:
|
|
523
669
|
ok = run.commit(instance, doc, key, deletes + creates, label)
|
|
524
670
|
how = "in one commit"
|
|
@@ -536,7 +682,8 @@ def sync_page(run: Run, page: dict, binding: dict, surface, comps) -> None:
|
|
|
536
682
|
new_root = next((n for n in new_nodes if n["type"] == "template-internal" and n.get("status") != "delete"), None)
|
|
537
683
|
s2, st2, ups2, _ = plan(r2, "SPEC-TOP", new_nodes, new_root["ID"] if new_root else "", run.attrs)
|
|
538
684
|
return st2 + ["%s differs" % u[0]["_key"] for u in ups2]
|
|
539
|
-
run.verify(instance, "templateDocumentInstance", key, before, recheck
|
|
685
|
+
run.verify(instance, "templateDocumentInstance", key, before, recheck,
|
|
686
|
+
wrote={r["newRevisionRecord"]["ID"] for r in records}, also=run.master_ids(master_id))
|
|
540
687
|
body = run.client.page(page["slug"])
|
|
541
688
|
print(" page %s: %s, %d bytes" % (page["slug"], "OK" if len(body) >= MIN_HEALTHY_BYTES else "BROKEN", len(body)))
|
|
542
689
|
if len(body) < MIN_HEALTHY_BYTES:
|
package/tools/test_mosaic.py
CHANGED
|
@@ -407,6 +407,21 @@ class SkillDoc(unittest.TestCase):
|
|
|
407
407
|
self.assertTrue(hits, name)
|
|
408
408
|
|
|
409
409
|
|
|
410
|
+
class RoundCheck(unittest.TestCase):
|
|
411
|
+
"""verify_browser's ROUND_NOT_ROUND decision, without a browser."""
|
|
412
|
+
|
|
413
|
+
def test_round_and_oval(self):
|
|
414
|
+
import verify_browser as vb
|
|
415
|
+
self.assertTrue(vb._is_round(["999px"] * 4))
|
|
416
|
+
self.assertTrue(vb._is_round(["50%"] * 4))
|
|
417
|
+
self.assertFalse(vb._is_round(["999px", "999px", "0px", "999px"]))
|
|
418
|
+
self.assertFalse(vb._is_round(["8px"] * 4))
|
|
419
|
+
self.assertTrue(vb._oval(48, 44)) # the default-padding button
|
|
420
|
+
self.assertFalse(vb._oval(44, 44)) # all four paddings 0
|
|
421
|
+
self.assertFalse(vb._oval(140, 44)) # a pill
|
|
422
|
+
self.assertFalse(vb._oval(44.3, 44)) # sub-pixel rounding
|
|
423
|
+
|
|
424
|
+
|
|
410
425
|
class SyncNodesPlan(unittest.TestCase):
|
|
411
426
|
"""sync_nodes.py's matching, offline: a live document is simulated as the same spec
|
|
412
427
|
flattened again (fresh node ids, the way a commit stores it)."""
|
|
@@ -573,6 +588,89 @@ class SyncNodesPlan(unittest.TestCase):
|
|
|
573
588
|
self.assertNotEqual(self.sn.svg_norm('<svg a="1"><path d="M0"/></svg>'),
|
|
574
589
|
self.sn.svg_norm('<svg a="1"><path d="M1"/></svg>'))
|
|
575
590
|
|
|
591
|
+
# 2026-11-25, live site: a sync of a changed intro animation wrote run-random uuids
|
|
592
|
+
# into settings.target, so three animated elements pointed at nodes that do not exist
|
|
593
|
+
def opener_spec(self, duration):
|
|
594
|
+
t = self.rich_tree()
|
|
595
|
+
opener = t["children"][-1]
|
|
596
|
+
opener["data"]["interactions"][0]["settings"]["duration"] = duration
|
|
597
|
+
return t
|
|
598
|
+
|
|
599
|
+
def test_interaction_target_is_written_as_the_live_id(self):
|
|
600
|
+
live = self.as_stored(self.flat(self.opener_spec(300), "L"))
|
|
601
|
+
btn = next(n for n in live if (n.get("data") or {}).get("attrID") == "r-btn")
|
|
602
|
+
same, struct, updates, _ = self.sn.plan(self.flat(self.opener_spec(900), "S"), "S", live, "L")
|
|
603
|
+
self.assertTrue(same, struct)
|
|
604
|
+
self.assertEqual([(u[0]["data"].get("attrID"), u[2]) for u in updates], [("r-opener", ["interactions"])])
|
|
605
|
+
merged = updates[0][1]
|
|
606
|
+
self.assertEqual(self.sn.element_targets(merged), [btn["ID"]])
|
|
607
|
+
# and the document after that write has no dangling target
|
|
608
|
+
after = [dict(n, data=merged) if n["ID"] == updates[0][0]["ID"] else n for n in live]
|
|
609
|
+
self.assertEqual(self.sn.dangling_targets(after), [])
|
|
610
|
+
|
|
611
|
+
def test_the_old_write_left_a_dangling_target_and_is_caught(self):
|
|
612
|
+
# what 1.41.0 wrote: the spec's value as is - its target is this run's random uuid
|
|
613
|
+
live = self.as_stored(self.flat(self.opener_spec(300), "L"))
|
|
614
|
+
spec = self.flat(self.opener_spec(900), "S")
|
|
615
|
+
raw = next(r for r in spec if (r.get("data") or {}).get("attrID") == "r-opener")["data"]["interactions"]
|
|
616
|
+
after = [dict(n, data=dict(n["data"], interactions=raw))
|
|
617
|
+
if (n.get("data") or {}).get("attrID") == "r-opener" else n for n in live]
|
|
618
|
+
bad = self.sn.dangling_targets(after)
|
|
619
|
+
self.assertEqual(len(bad), 1)
|
|
620
|
+
self.assertEqual(bad[0][0]["data"]["attrID"], "r-opener")
|
|
621
|
+
# a target in the master counts as present for a template
|
|
622
|
+
self.assertEqual(self.sn.dangling_targets(after, also={bad[0][1]}), [])
|
|
623
|
+
|
|
624
|
+
def test_target_to_a_node_outside_attr_that_is_not_on_the_site_is_refused(self):
|
|
625
|
+
live = self.as_stored(self.flat(self.opener_spec(300), "L"))
|
|
626
|
+
spec = self.opener_spec(900)
|
|
627
|
+
spec["children"][4]["data"]["attrID"] = "r-btn-renamed" # the target is not on the site
|
|
628
|
+
same, struct, updates, _ = self.sn.plan(self.flat(spec, "S"), "S", live, "L", {"r-opener"})
|
|
629
|
+
self.assertFalse(same)
|
|
630
|
+
self.assertEqual(updates, [])
|
|
631
|
+
self.assertTrue(any("not on the site" in s for s in struct), struct)
|
|
632
|
+
|
|
633
|
+
def test_run_refuses_a_write_with_a_dangling_target(self):
|
|
634
|
+
run = self.sn.Run(None, True, "unused")
|
|
635
|
+
rec = {"newRevisionRecord": {"ID": "n1", "data": {"interactions": [
|
|
636
|
+
{"settings": {"target": {"type": "element", "uuid": "nowhere"}}}]}}, "originalRevisionRecord": None}
|
|
637
|
+
import contextlib
|
|
638
|
+
import io
|
|
639
|
+
with contextlib.redirect_stdout(io.StringIO()):
|
|
640
|
+
self.assertFalse(run.targets_ok("t", [rec], {"a", "b"}))
|
|
641
|
+
self.assertTrue(run.failed)
|
|
642
|
+
run2 = self.sn.Run(None, True, "unused")
|
|
643
|
+
self.assertTrue(run2.targets_ok("t", [rec], {"nowhere"}))
|
|
644
|
+
|
|
645
|
+
def test_stored_rewrites_are_not_differences(self):
|
|
646
|
+
# 2026-11-25, live site: opacity ".35" is stored "0.35"; url(x) as url("x");
|
|
647
|
+
# rgba(...,.85) keeps or drops its zero
|
|
648
|
+
self.assertEqual(self.sn.css_norm("mask:url(/a.webp) center/contain;transition:opacity .2s"),
|
|
649
|
+
self.sn.css_norm('mask: url("/a.webp") center / contain;\ntransition: opacity 0.2s;'))
|
|
650
|
+
self.assertEqual(self.sn.css_norm("color:red!important;;"), self.sn.css_norm("color: red !important;"))
|
|
651
|
+
n = lambda v, k="opacity": self.sn.normalise(v, {}, set(), k)
|
|
652
|
+
self.assertEqual(n(".35"), n("0.35"))
|
|
653
|
+
self.assertEqual(n("rgba(255,255,255,.85)", "color"), n("rgba(255, 255, 255, 0.85)", "color"))
|
|
654
|
+
self.assertNotEqual(n(".35"), n("0.36"))
|
|
655
|
+
self.assertNotEqual(n("Price .35", "text"), n("Price 0.35", "text")) # words are not values
|
|
656
|
+
|
|
657
|
+
def test_string_rel_is_not_a_difference_but_a_list_is_written(self):
|
|
658
|
+
# measured on the demo (1.0.14, 2026-11-25): rel "noopener" is stored as null,
|
|
659
|
+
# ["noopener"] is kept (rel's validator is ValidatorArray)
|
|
660
|
+
def tree(rel):
|
|
661
|
+
return {"type": "text", "data": {"attrID": "l-root"}, "children": [
|
|
662
|
+
{"type": "wysiwyg-link", "data": {"attrID": "l-a", "url": "/a/", "rel": rel},
|
|
663
|
+
"children": [{"type": "wysiwyg-text", "data": {"text": "a"}}]}]}
|
|
664
|
+
live = self.flat(tree(None), "L")
|
|
665
|
+
same, _, updates, notes = self.sn.plan(self.flat(tree("noopener"), "S"), "S", live, "L")
|
|
666
|
+
self.assertEqual(updates, [])
|
|
667
|
+
self.assertTrue(any("only as a list" in x for x in notes), notes)
|
|
668
|
+
same, _, updates, _ = self.sn.plan(self.flat(tree(["noopener"]), "S"), "S", live, "L")
|
|
669
|
+
self.assertEqual([u[2] for u in updates], [["rel"]])
|
|
670
|
+
import inline_html
|
|
671
|
+
link = inline_html.inline_children('<a href="/x/" rel="noopener nofollow">x</a>')[0]
|
|
672
|
+
self.assertEqual(link["data"]["rel"], ["noopener", "nofollow"])
|
|
673
|
+
|
|
576
674
|
def test_override_shell_counter(self):
|
|
577
675
|
shell = {"parentType": "override", "parentID": "I", "status": "publish",
|
|
578
676
|
"data": {"override": {"originalID": "X"}}}
|
package/tools/verify_browser.py
CHANGED
|
@@ -557,6 +557,213 @@ PROBE = r"""
|
|
|
557
557
|
"""
|
|
558
558
|
|
|
559
559
|
|
|
560
|
+
# ── ROUND: a circle that is not one ──────────────────────────────────────────
|
|
561
|
+
#
|
|
562
|
+
# A button set to 44 x 44 with `borderRadius: 999px` is meant to be a circle. Mosaic's
|
|
563
|
+
# `.m-button` rule arrives with `padding: 12px 24px`, and 24 + 24 is more than 44, so
|
|
564
|
+
# the box is 48 x 44 - an ellipse - unless every side of the padding is written as 0
|
|
565
|
+
# (references/facts.md). The fill that shows the shape is often a hover colour, so a
|
|
566
|
+
# screenshot at rest sees nothing wrong; the reading has to be taken while hovered too.
|
|
567
|
+
#
|
|
568
|
+
# An element counts as "meant to be round" when every corner's computed radius is
|
|
569
|
+
# >= 999px or >= 50%. Width and height are read with getBoundingClientRect, at rest
|
|
570
|
+
# and again with the pointer on it. A pill - a wide button with a 999px radius - is
|
|
571
|
+
# round by the same test and is not a defect, so only a box whose long side is at
|
|
572
|
+
# most ROUND_PILL_RATIO times its short side is reported: 48 x 44 is 1.09, a
|
|
573
|
+
# "Contact us" pill is 3 or more. A circle that only gets its radius under `:hover`
|
|
574
|
+
# is found from the stylesheet's :hover rules (same-origin sheets only).
|
|
575
|
+
# A short pill exists too - a "Home" nav link at 55 x 40 on a client site - so an
|
|
576
|
+
# element showing more than ROUND_MAX_TEXT characters of text is a labelled pill and
|
|
577
|
+
# is skipped; a circle holds an icon, a number or one character.
|
|
578
|
+
ROUND_PILL_RATIO = 1.5
|
|
579
|
+
ROUND_MAX_TEXT = 2
|
|
580
|
+
|
|
581
|
+
ROUND_JS = r"""
|
|
582
|
+
() => {
|
|
583
|
+
const qual = v => {
|
|
584
|
+
v = (v || '').trim().split(/\s+/)[0];
|
|
585
|
+
if (v.endsWith('%')) return parseFloat(v) >= 50;
|
|
586
|
+
if (v.endsWith('px')) return parseFloat(v) >= 999;
|
|
587
|
+
return false;
|
|
588
|
+
};
|
|
589
|
+
const corners = cs => [cs.borderTopLeftRadius, cs.borderTopRightRadius,
|
|
590
|
+
cs.borderBottomRightRadius, cs.borderBottomLeftRadius];
|
|
591
|
+
const round = cs => corners(cs).every(qual);
|
|
592
|
+
const seen = new Set();
|
|
593
|
+
for (const el of document.body.querySelectorAll('*')) {
|
|
594
|
+
if (round(getComputedStyle(el))) seen.add(el);
|
|
595
|
+
}
|
|
596
|
+
// a radius that only exists under :hover
|
|
597
|
+
const walk = rules => {
|
|
598
|
+
for (const r of rules) {
|
|
599
|
+
if (r.cssRules && !r.selectorText) {
|
|
600
|
+
if (!r.media || matchMedia(r.media.mediaText).matches) walk(r.cssRules);
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
if (!r.selectorText || !r.selectorText.includes(':hover') || !r.style) continue;
|
|
604
|
+
const s = r.style;
|
|
605
|
+
if (![s.borderTopLeftRadius, s.borderTopRightRadius,
|
|
606
|
+
s.borderBottomRightRadius, s.borderBottomLeftRadius].every(qual)) continue;
|
|
607
|
+
try {
|
|
608
|
+
document.querySelectorAll(r.selectorText.replace(/:hover/g, ''))
|
|
609
|
+
.forEach(el => seen.add(el));
|
|
610
|
+
} catch (e) {}
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
for (const sh of document.styleSheets) {
|
|
614
|
+
try { walk(sh.cssRules); } catch (e) {} // cross-origin sheet
|
|
615
|
+
}
|
|
616
|
+
const out = [];
|
|
617
|
+
let i = 0;
|
|
618
|
+
for (const el of seen) {
|
|
619
|
+
const cs = getComputedStyle(el);
|
|
620
|
+
if (cs.display === 'none' || cs.visibility === 'hidden') continue;
|
|
621
|
+
const r = el.getBoundingClientRect();
|
|
622
|
+
if (r.width < 4 || r.height < 4) continue;
|
|
623
|
+
el.setAttribute('data-round-probe', String(i));
|
|
624
|
+
const cls = (el.getAttribute('class') || '').trim().split(/\s+/).filter(Boolean);
|
|
625
|
+
const label = (el.getAttribute('aria-label') || el.getAttribute('title') ||
|
|
626
|
+
(el.innerText || '').trim()).replace(/\s+/g, ' ').slice(0, 30);
|
|
627
|
+
out.push({i: i, node: el.id || (el.tagName.toLowerCase() +
|
|
628
|
+
(cls.length ? '.' + cls.slice(0, 2).join('.') : '')),
|
|
629
|
+
label: label, href: el.getAttribute('href') || '',
|
|
630
|
+
text: (el.innerText || '').replace(/\s+/g, ''),
|
|
631
|
+
w: r.width, h: r.height, round: round(cs),
|
|
632
|
+
radius: cs.borderTopLeftRadius, padding: cs.padding});
|
|
633
|
+
i++;
|
|
634
|
+
}
|
|
635
|
+
return out;
|
|
636
|
+
}
|
|
637
|
+
"""
|
|
638
|
+
|
|
639
|
+
ROUND_READ_JS = r"""
|
|
640
|
+
el => {
|
|
641
|
+
const cs = getComputedStyle(el);
|
|
642
|
+
const r = el.getBoundingClientRect();
|
|
643
|
+
return {w: r.width, h: r.height, radius: cs.borderTopLeftRadius,
|
|
644
|
+
corners: [cs.borderTopLeftRadius, cs.borderTopRightRadius,
|
|
645
|
+
cs.borderBottomRightRadius, cs.borderBottomLeftRadius],
|
|
646
|
+
padding: cs.padding};
|
|
647
|
+
}
|
|
648
|
+
"""
|
|
649
|
+
|
|
650
|
+
|
|
651
|
+
def _is_round(corners):
|
|
652
|
+
for v in corners:
|
|
653
|
+
v = (v or "").split()[0] if (v or "").strip() else ""
|
|
654
|
+
try:
|
|
655
|
+
if v.endswith("%"):
|
|
656
|
+
if float(v[:-1]) < 50:
|
|
657
|
+
return False
|
|
658
|
+
elif v.endswith("px"):
|
|
659
|
+
if float(v[:-2]) < 999:
|
|
660
|
+
return False
|
|
661
|
+
else:
|
|
662
|
+
return False
|
|
663
|
+
except ValueError:
|
|
664
|
+
return False
|
|
665
|
+
return True
|
|
666
|
+
|
|
667
|
+
|
|
668
|
+
def _oval(w, h):
|
|
669
|
+
"""Unequal by half a pixel or more, and not long enough to be a pill."""
|
|
670
|
+
lo, hi = min(w, h), max(w, h)
|
|
671
|
+
return lo > 0 and hi - lo >= 0.5 and hi / lo <= ROUND_PILL_RATIO
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
def round_check(page, limit=80):
|
|
675
|
+
"""ROUND_NOT_ROUND findings for the page as it stands: every element whose
|
|
676
|
+
corners are all >= 999px or >= 50%, measured at rest and hovered."""
|
|
677
|
+
found = []
|
|
678
|
+
for c in page.evaluate(ROUND_JS)[:limit]:
|
|
679
|
+
if len(c["text"]) > ROUND_MAX_TEXT:
|
|
680
|
+
continue # a labelled pill, not a circle
|
|
681
|
+
rest = c if c["round"] else None
|
|
682
|
+
hover = None
|
|
683
|
+
loc = page.locator('[data-round-probe="%d"]' % c["i"])
|
|
684
|
+
try:
|
|
685
|
+
loc.hover(timeout=1500, force=True)
|
|
686
|
+
page.wait_for_timeout(350) # most hover transitions are <= 300ms
|
|
687
|
+
got = loc.evaluate(ROUND_READ_JS)
|
|
688
|
+
if _is_round(got["corners"]):
|
|
689
|
+
hover = got
|
|
690
|
+
except Exception:
|
|
691
|
+
pass # off-screen, covered, or gone
|
|
692
|
+
try:
|
|
693
|
+
page.mouse.move(0, 0)
|
|
694
|
+
except Exception:
|
|
695
|
+
pass
|
|
696
|
+
bad = []
|
|
697
|
+
if rest and _oval(rest["w"], rest["h"]):
|
|
698
|
+
bad.append("%gx%g at rest" % (round(rest["w"], 1), round(rest["h"], 1)))
|
|
699
|
+
if hover and _oval(hover["w"], hover["h"]):
|
|
700
|
+
bad.append("%gx%g hovered" % (round(hover["w"], 1), round(hover["h"], 1)))
|
|
701
|
+
if not bad:
|
|
702
|
+
continue
|
|
703
|
+
seen = hover or rest
|
|
704
|
+
found.append({
|
|
705
|
+
"check": "ROUND_NOT_ROUND", "level": "error", "node": c["node"],
|
|
706
|
+
"detail": "radius %s but %s (padding %s)"
|
|
707
|
+
% (seen["radius"], ", ".join(bad), seen["padding"]),
|
|
708
|
+
"sample": (c["label"] or c["href"])[:30],
|
|
709
|
+
})
|
|
710
|
+
return found
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
def round_scan(urls, viewports, block_media=True, gap_ms=1500):
|
|
714
|
+
"""The ROUND check alone, on public URLs, with no spec and no REST session.
|
|
715
|
+
|
|
716
|
+
Made for reading a front end that is not yours: no cache-buster (the cached copy
|
|
717
|
+
is what a visitor gets and costs the server nothing), images, video and fonts are
|
|
718
|
+
not fetched, one load per URL per viewport with a pause between loads, and the
|
|
719
|
+
run STOPS at the first 401/403/429/503 - the reason is returned, nothing is
|
|
720
|
+
retried."""
|
|
721
|
+
import time
|
|
722
|
+
try:
|
|
723
|
+
from playwright.sync_api import sync_playwright
|
|
724
|
+
except ImportError:
|
|
725
|
+
sys.exit("verify_browser.py needs Playwright:\n"
|
|
726
|
+
" pip install playwright && playwright install chromium")
|
|
727
|
+
findings, stopped, loads = [], None, 0
|
|
728
|
+
|
|
729
|
+
def no_media(route):
|
|
730
|
+
if route.request.resource_type in ("image", "media", "font"):
|
|
731
|
+
route.abort()
|
|
732
|
+
else:
|
|
733
|
+
route.continue_()
|
|
734
|
+
|
|
735
|
+
with sync_playwright() as pw:
|
|
736
|
+
browser = pw.chromium.launch()
|
|
737
|
+
for url in urls:
|
|
738
|
+
for bp, w, h in viewports:
|
|
739
|
+
page = browser.new_page(viewport={"width": w, "height": h},
|
|
740
|
+
device_scale_factor=1)
|
|
741
|
+
if block_media:
|
|
742
|
+
page.route("**/*", no_media)
|
|
743
|
+
try:
|
|
744
|
+
resp = page.goto(url, wait_until="load", timeout=45000)
|
|
745
|
+
loads += 1
|
|
746
|
+
status = resp.status if resp else 0
|
|
747
|
+
if status in (401, 403, 429, 503):
|
|
748
|
+
stopped = "%s answered HTTP %d (%s)" % (url, status, bp)
|
|
749
|
+
else:
|
|
750
|
+
page.wait_for_timeout(1200)
|
|
751
|
+
for f in round_check(page):
|
|
752
|
+
findings.append(dict(f, url=url, breakpoint=bp))
|
|
753
|
+
except Exception as e: # a timeout is reported, not retried
|
|
754
|
+
findings.append({"check": "LOAD", "level": "warn", "url": url,
|
|
755
|
+
"breakpoint": bp, "node": "", "sample": "",
|
|
756
|
+
"detail": str(e).splitlines()[0][:120]})
|
|
757
|
+
page.close()
|
|
758
|
+
if stopped:
|
|
759
|
+
break
|
|
760
|
+
time.sleep(gap_ms / 1000.0)
|
|
761
|
+
if stopped:
|
|
762
|
+
break
|
|
763
|
+
browser.close()
|
|
764
|
+
return findings, stopped, loads
|
|
765
|
+
|
|
766
|
+
|
|
560
767
|
def run(url, ids, shots_dir):
|
|
561
768
|
try:
|
|
562
769
|
from playwright.sync_api import sync_playwright
|
|
@@ -585,6 +792,8 @@ def run(url, ids, shots_dir):
|
|
|
585
792
|
page.screenshot(path=os.path.join(shots_dir, "browser-%s.png"
|
|
586
793
|
% bp.strip("_") or "desktop"),
|
|
587
794
|
full_page=False)
|
|
795
|
+
# after the screenshot, because this one hovers things
|
|
796
|
+
results[bp]["audit"].extend(round_check(page))
|
|
588
797
|
page.close()
|
|
589
798
|
browser.close()
|
|
590
799
|
return results
|
|
@@ -608,7 +817,13 @@ def main():
|
|
|
608
817
|
ap = argparse.ArgumentParser()
|
|
609
818
|
ap.add_argument("--config",
|
|
610
819
|
help="JSON with base/cookie/nonce; omit it and the MOSAIC_SITE_URL / MOSAIC_REST_COOKIE / MOSAIC_REST_NONCE environment variables supply them instead")
|
|
611
|
-
ap.add_argument("--site", required
|
|
820
|
+
ap.add_argument("--site", help="the site spec (required unless --round)")
|
|
821
|
+
ap.add_argument("--round", nargs="+", metavar="URL",
|
|
822
|
+
help="run ONLY the round-element check on these public URLs: "
|
|
823
|
+
"no spec, no REST session, images/fonts not fetched, "
|
|
824
|
+
"stops at the first 403")
|
|
825
|
+
ap.add_argument("--viewports", default="_,_m",
|
|
826
|
+
help="with --round: which of _,_t,_m to load (default _,_m)")
|
|
612
827
|
ap.add_argument("--csv", help="a DIRECTORY: the computed-value table is "
|
|
613
828
|
"written one file per page, <dir>/<slug>.csv")
|
|
614
829
|
ap.add_argument("--audit", help="the design-audit findings")
|
|
@@ -620,6 +835,10 @@ def main():
|
|
|
620
835
|
ap.add_argument("--page", help="only this slug")
|
|
621
836
|
a = ap.parse_args()
|
|
622
837
|
|
|
838
|
+
if a.round:
|
|
839
|
+
sys.exit(main_round(a))
|
|
840
|
+
if not a.site:
|
|
841
|
+
ap.error("--site is required (or use --round URL ...)")
|
|
623
842
|
cfg = mosaic_config.load(a.config)
|
|
624
843
|
spec = json.load(open(a.site, encoding="utf-8"))
|
|
625
844
|
|
|
@@ -797,5 +1016,30 @@ def main():
|
|
|
797
1016
|
sys.exit(1 if hard else 0)
|
|
798
1017
|
|
|
799
1018
|
|
|
1019
|
+
def main_round(a):
|
|
1020
|
+
want = [v.strip() for v in a.viewports.split(",") if v.strip()]
|
|
1021
|
+
vps = [v for v in VIEWPORTS if v[0] in want]
|
|
1022
|
+
findings, stopped, loads = round_scan(a.round, vps)
|
|
1023
|
+
errors = [f for f in findings if f["level"] == "error"]
|
|
1024
|
+
print("round check: %d URL(s), %d page loads, %d finding(s)"
|
|
1025
|
+
% (len(a.round), loads, len(errors)))
|
|
1026
|
+
for f in findings:
|
|
1027
|
+
print(" %-5s %-4s %-40s %-28s %s %s"
|
|
1028
|
+
% (f["level"], f["breakpoint"], f["url"][-40:], f["node"][:28],
|
|
1029
|
+
f["detail"], f.get("sample", "")))
|
|
1030
|
+
if a.audit:
|
|
1031
|
+
with open(a.audit, "w", newline="", encoding="utf-8") as fh:
|
|
1032
|
+
w = csv.writer(fh)
|
|
1033
|
+
w.writerow(["url", "breakpoint", "check", "level", "node", "detail",
|
|
1034
|
+
"sample"])
|
|
1035
|
+
for f in findings:
|
|
1036
|
+
w.writerow([f["url"], f["breakpoint"], f["check"], f["level"],
|
|
1037
|
+
f["node"], f["detail"], f.get("sample", "")])
|
|
1038
|
+
if stopped:
|
|
1039
|
+
print("STOPPED - " + stopped)
|
|
1040
|
+
return 2
|
|
1041
|
+
return 1 if errors else 0
|
|
1042
|
+
|
|
1043
|
+
|
|
800
1044
|
if __name__ == "__main__":
|
|
801
1045
|
main()
|