@buaa_smat/hometrans 26.0.5 → 26.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +249 -279
- package/agents/code-reviewer.md +1 -1
- package/dist/cli/editors.json +20 -0
- package/dist/platform/registry.js +1 -0
- package/dist/platform/validate.js +2 -1
- package/i18n/agents/code-reviewer.md +1 -1
- package/i18n/platforms/atomcode/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/claude-code/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/i18n/platforms/codex/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/cursor/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +10 -0
- package/i18n/platforms/qoder/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/qoder-cn/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/i18n/platforms/trae/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/platforms/trae-cn/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/i18n/skills/a2h-app-migrate/SKILL.md +32 -15
- package/i18n/skills/a2h-app-migrate/references/stage-map.md +4 -2
- package/i18n/skills/a2h-app-migrate/references/workflow.yaml +148 -89
- package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +51 -2
- package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +0 -2
- package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
- package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +9 -3
- package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +4 -2
- package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +8 -7
- package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -2
- package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +33 -12
- package/i18n/skills/a2h-batch-ui-align/SKILL.md +14 -12
- package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +1 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +32 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +3 -2
- package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +4 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +19 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +13 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +2 -2
- package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +205 -7
- package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +10 -17
- package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +3 -4
- package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +47 -2
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +52 -328
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +1 -138
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +2 -11
- package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +1 -1
- package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +8 -23
- package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +2 -1
- package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +17 -9
- package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +239 -16
- package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +6 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +6 -3
- package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +170 -10
- package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +42 -1
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +20 -1
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +81 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/click_handler.ts +140 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/collapsing_toolbar.ts +124 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/compose_semantics.ts +287 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/flowitem_width.ts +78 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +194 -8
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/inset_stacked.ts +138 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/int_division.ts +181 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +62 -2
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_path.ts +77 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_ready.ts +109 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +88 -18
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_cycle.ts +140 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +2 -2
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/see_through_overlay.ts +149 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_builder.ts +139 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_show_close.ts +53 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/space_between_optional.ts +115 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +7 -1
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/width_fill.ts +160 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_inset_stacked.test.mjs +155 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +60 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +38 -0
- package/i18n/skills/a2h-module-semantic-docs/SKILL.md +3 -2
- package/i18n/skills/a2h-page-specgen/SKILL.md +36 -5
- package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +89 -21
- package/i18n/skills/a2h-page-specgen/references/gates.md +33 -7
- package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +67 -13
- package/i18n/skills/a2h-page-specgen/references/spec-example.md +166 -32
- package/i18n/skills/a2h-page-specgen/references/spec-template.md +8 -5
- package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +37 -1
- package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +241 -22
- package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +29 -2
- package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +32 -0
- package/i18n/skills/a2h-page-specgen/scripts/contract-calls.mjs +715 -0
- package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +129 -2
- package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +19 -10
- package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +62 -3
- package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +27 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +116 -6
- package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +270 -29
- package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +26 -14
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +104 -19
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +104 -19
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +216 -216
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +1 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +2 -2
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +100 -15
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +118 -25
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +104 -19
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +155 -3
- package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +529 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +27 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +158 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +11 -13
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +97 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +737 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +75 -3
- package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +24 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +124 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +6 -2
- package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +106 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +32 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +12 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +6 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +11 -3
- package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +1 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +1 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +159 -27
- package/i18n/skills/a2h-resource-convert/SKILL.md +1 -1
- package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +2 -2
- package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +124 -8
- package/i18n/skills/a2h-resource-convert/scripts/sync-framework-strings.mjs +147 -0
- package/i18n/skills/a2h-resource-convert/scripts/tests/framework_strings.test.mjs +131 -0
- package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +15 -12
- package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +38 -10
- package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +2 -2
- package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +2 -2
- package/i18n/skills/a2h-spec-design-pipeline/references/reply-recovery.md +172 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +2 -2
- package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +5 -3
- package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +7 -1
- package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +1 -1
- package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +2 -0
- package/i18n/skills/a2h-spec-generate/references/input-formats.md +1 -1
- package/i18n/skills/a2h-utg-explorer/SKILL.md +11 -5
- package/i18n/skills/a2h-utg-explorer/references/architecture.md +37 -19
- package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +48 -3
- package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +21 -0
- package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +67 -8
- package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +32 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/dialog_own_layout.test.mjs +40 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +63 -2
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +143 -14
- package/i18n/skills/a2h-utg-static/SKILL.md +3 -3
- package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +4 -3
- package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +1 -1
- package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +25 -0
- package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +1 -0
- package/package.json +2 -1
- package/platforms/atomcode/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/claude-code/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/codebuddy/agents/build-fixer.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/code-reviewer.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/model-render-worker.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/model-worker.frontmatter.md +5 -0
- package/platforms/codebuddy/agents/specgen-worker.frontmatter.md +5 -0
- package/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/platforms/codex/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/cursor/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/deveco/agents/build-fixer.frontmatter.md +2 -0
- package/platforms/deveco/agents/code-reviewer.frontmatter.md +2 -0
- package/platforms/deveco/agents/model-render-worker.frontmatter.md +2 -0
- package/platforms/deveco/agents/model-worker.frontmatter.md +2 -0
- package/platforms/deveco/agents/specgen-worker.frontmatter.md +2 -0
- package/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/opencode/agents/build-fixer.frontmatter.md +2 -0
- package/platforms/opencode/agents/code-reviewer.frontmatter.md +2 -0
- package/platforms/opencode/agents/model-render-worker.frontmatter.md +2 -0
- package/platforms/opencode/agents/model-worker.frontmatter.md +2 -0
- package/platforms/opencode/agents/specgen-worker.frontmatter.md +2 -0
- package/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +10 -0
- package/platforms/qoder/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/qoder-cn/skills/a2h-app-migrate/SKILL.unique.md +8 -0
- package/platforms/trae/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/platforms/trae-cn/skills/a2h-app-migrate/SKILL.unique.md +3 -0
- package/skills/a2h-app-migrate/SKILL.md +31 -14
- package/skills/a2h-app-migrate/references/stage-map.md +4 -2
- package/skills/a2h-app-migrate/references/workflow.yaml +152 -89
- package/skills/a2h-app-migrate/scripts/assert_dag_complete.mjs +1 -1
- package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +28 -11
- package/skills/a2h-app-migrate/scripts/dag_action_catalog.mjs +76 -0
- package/skills/a2h-app-migrate/scripts/dag_production_executor.mjs +60 -5
- package/skills/a2h-app-migrate/scripts/dag_runner.mjs +184 -4
- package/skills/a2h-app-migrate/scripts/env_preflight.mjs +1 -1
- package/skills/a2h-app-migrate/scripts/ledger.mjs +2 -2
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +3 -3
- package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +51 -2
- package/skills/a2h-app-migrate/test/test_dag_blocked_guard.mjs +291 -0
- package/skills/a2h-app-migrate/test/test_dag_production.mjs +40 -0
- package/skills/a2h-app-migrate/test/test_dag_runner.mjs +4 -3
- package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_interaction.mjs +0 -2
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_skill_doc.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
- package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +36 -0
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +19 -6
- package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +4 -2
- package/skills/a2h-arkts-logic-coder/SKILL.md +8 -7
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -2
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +33 -12
- package/skills/a2h-batch-ui-align/SKILL.md +14 -12
- package/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -0
- package/skills/a2h-batch-ui-align/references/cards/canvas.md +1 -0
- package/skills/a2h-batch-ui-align/references/cards/dynamics.md +32 -1
- package/skills/a2h-batch-ui-align/references/cards/geometry.md +3 -2
- package/skills/a2h-batch-ui-align/references/cards/interaction.md +4 -0
- package/skills/a2h-batch-ui-align/references/cards/resources.md +19 -1
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +13 -1
- package/skills/a2h-batch-ui-align/references/cards/window.md +2 -2
- package/skills/a2h-batch-ui-align/references/checker-rules.md +205 -7
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +10 -17
- package/skills/a2h-batch-ui-align/references/incremental-scope.md +3 -4
- package/skills/a2h-batch-ui-align/references/lottie-integration.md +47 -2
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +52 -328
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +1 -138
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +2 -11
- package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +1 -1
- package/skills/a2h-batch-ui-align/references/step3-capture.md +8 -23
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +2 -1
- package/skills/a2h-batch-ui-align/references/step5-convert.md +17 -9
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +239 -16
- package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +6 -1
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +6 -0
- package/skills/a2h-batch-ui-align/scripts/group_pass.mjs +270 -0
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +134 -16
- package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +39 -8
- package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +6 -3
- package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +170 -10
- package/skills/a2h-batch-ui-align/scripts/module_placement.mjs +189 -0
- package/skills/a2h-batch-ui-align/scripts/overlay_effects.mjs +205 -0
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +42 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +20 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +28 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +81 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/click_handler.ts +140 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/collapsing_toolbar.ts +124 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/compose_semantics.ts +287 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/flowitem_width.ts +78 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +194 -8
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/inset_stacked.ts +138 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/int_division.ts +181 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +62 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_path.ts +77 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_ready.ts +109 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +88 -18
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_cycle.ts +140 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +2 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/see_through_overlay.ts +149 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_builder.ts +139 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_show_close.ts +53 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/space_between_optional.ts +115 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +7 -1
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/width_fill.ts +160 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +28 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_chrome_defaults.test.mjs +328 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_click_handler.test.mjs +127 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_compose_semantics.test.mjs +150 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +117 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_inset_stacked.test.mjs +155 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +60 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +413 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +159 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_sheet_builder.test.mjs +192 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +4 -2
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +38 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_compose.test.mjs +106 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +15 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_pass.test.mjs +150 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +125 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +56 -0
- package/skills/a2h-batch-ui-align/scripts/tests/measure_pack_icon_leaf.test.mjs +143 -0
- package/skills/a2h-batch-ui-align/scripts/tests/module_placement.test.mjs +248 -0
- package/skills/a2h-batch-ui-align/scripts/tests/overlay_effects.test.mjs +214 -0
- package/skills/a2h-fix-build-errors/references/known-patterns.md +5 -5
- package/skills/a2h-module-semantic-docs/SKILL.md +3 -2
- package/skills/a2h-module-semantic-docs/scripts/commit_module_state.mjs +10 -0
- package/skills/a2h-module-semantic-docs/scripts/design_baseline.mjs +158 -0
- package/skills/a2h-module-semantic-docs/test/test_design_baseline.mjs +128 -0
- package/skills/a2h-page-specgen/SKILL.md +36 -5
- package/skills/a2h-page-specgen/references/behavior-ledger.md +88 -21
- package/skills/a2h-page-specgen/references/evidence.md +2 -1
- package/skills/a2h-page-specgen/references/execution-model.md +13 -5
- package/skills/a2h-page-specgen/references/gates.md +33 -7
- package/skills/a2h-page-specgen/references/scenario-authoring.md +67 -13
- package/skills/a2h-page-specgen/references/spec-example.md +166 -32
- package/skills/a2h-page-specgen/references/spec-template.md +8 -5
- package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +40 -2
- package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +241 -22
- package/skills/a2h-page-specgen/scripts/behavior-model.mjs +29 -2
- package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +35 -2
- package/skills/a2h-page-specgen/scripts/contract-calls.mjs +715 -0
- package/skills/a2h-page-specgen/scripts/finalize.mjs +55 -2
- package/skills/a2h-page-specgen/scripts/footprint.mjs +129 -2
- package/skills/a2h-page-specgen/scripts/gate.mjs +20 -11
- package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +56 -3
- package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +27 -0
- package/skills/a2h-page-specgen/scripts/lib/hg.mjs +114 -5
- package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +20 -3
- package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +270 -29
- package/skills/a2h-page-specgen/scripts/prepare.mjs +25 -14
- package/skills/a2h-page-specgen/scripts/report.mjs +26 -5
- package/skills/a2h-page-specgen/scripts/submission.mjs +69 -2
- package/skills/a2h-page-specgen/scripts/submit.mjs +105 -4
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +224 -224
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +1 -1
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +2 -2
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +110 -18
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +97 -12
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +153 -3
- package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +529 -1
- package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +27 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +158 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +11 -13
- package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +97 -0
- package/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +737 -0
- package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +82 -3
- package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +24 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +11 -0
- package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +6 -2
- package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +94 -1
- package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +32 -0
- package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +14 -0
- package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +49 -1
- package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +6 -1
- package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +12 -4
- package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +1 -1
- package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +1 -0
- package/skills/a2h-page-specgen/scripts/test/report.test.mjs +80 -1
- package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +159 -27
- package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +23 -0
- package/skills/a2h-page-specgen/scripts/waker.mjs +8 -1
- package/skills/a2h-resource-convert/SKILL.md +1 -1
- package/skills/a2h-resource-convert/data/framework-strings/NOTICE +10 -0
- package/skills/a2h-resource-convert/data/framework-strings/manifest.json +90 -0
- package/skills/a2h-resource-convert/data/framework-strings/strings.json +382 -0
- package/skills/a2h-resource-convert/references/conversion-rules.md +7 -1
- package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +2 -2
- package/skills/a2h-resource-convert/references/step5-reference-resolution.md +16 -0
- package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +124 -8
- package/skills/a2h-resource-convert/scripts/sync-framework-strings.mjs +147 -0
- package/skills/a2h-resource-convert/scripts/tests/framework_strings.test.mjs +131 -0
- package/skills/a2h-spec-design-pipeline/SKILL.md +14 -11
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +38 -10
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +3 -0
- package/skills/a2h-spec-design-pipeline/references/final-report-template.md +6 -3
- package/skills/a2h-spec-design-pipeline/references/initialization.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/post-loop.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/reply-recovery.md +172 -0
- package/skills/a2h-spec-design-pipeline/references/review-loop.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/scripts.md +4 -3
- package/skills/a2h-spec-design-pipeline/references/shared-layer.md +24 -19
- package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +7 -1
- package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +12 -5
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +5 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +4 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +27 -3
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +46 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +2511 -295
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +27 -72
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +39 -83
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +132 -101
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +158 -115
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +60 -93
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +73 -100
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/route-page-side-effect-import-cn.md +52 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/route-page-side-effect-import-en.md +59 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +57 -8
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +475 -18
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +472 -4
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/RoutePageSideEffectImportCheck.js +570 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/arkui/RouteParamCarrierSubCheck.js +1053 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/sql/SqlIdentifierAnalysis.js +427 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +7 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +1 -1
- package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +1 -1
- package/skills/a2h-spec-design-pipeline/scripts/settle.ts +785 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +286 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +166 -2
- package/skills/a2h-spec-design-pipeline/scripts/test_docs_refresh_contract.ts +40 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +2 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +350 -7
- package/skills/a2h-spec-design-pipeline/scripts/test_route_page_side_effect_import.ts +185 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_route_param_carrier.ts +341 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_settle.ts +593 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +92 -1
- package/skills/a2h-spec-design-pipeline/scripts/test_sql_identifier_analysis.ts +137 -0
- package/skills/a2h-spec-generate/references/input-formats.md +1 -1
- package/skills/a2h-utg-explorer/SKILL.md +11 -5
- package/skills/a2h-utg-explorer/references/architecture.md +37 -19
- package/skills/a2h-utg-explorer/scripts/audit.mjs +6 -2
- package/skills/a2h-utg-explorer/scripts/close_phases.mjs +8 -5
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +95 -19
- package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +192 -4
- package/skills/a2h-utg-explorer/scripts/final_utg.mjs +21 -0
- package/skills/a2h-utg-explorer/scripts/panel_routes.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/plan.mjs +16 -1
- package/skills/a2h-utg-explorer/scripts/predicates.mjs +270 -0
- package/skills/a2h-utg-explorer/scripts/promote_dynamic.mjs +2 -0
- package/skills/a2h-utg-explorer/scripts/recover.mjs +4 -3
- package/skills/a2h-utg-explorer/scripts/recover_d.mjs +67 -8
- package/skills/a2h-utg-explorer/scripts/rejudge.mjs +4 -3
- package/skills/a2h-utg-explorer/scripts/report.mjs +32 -2
- package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +103 -36
- package/skills/a2h-utg-explorer/scripts/run_device.mjs +3 -8
- package/skills/a2h-utg-explorer/scripts/schedule_states.mjs +189 -0
- package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +9 -0
- package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +11 -0
- package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +31 -2
- package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +32 -0
- package/skills/a2h-utg-explorer/scripts/tests/dialog_own_layout.test.mjs +40 -0
- package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +4 -1
- package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +6 -28
- package/skills/a2h-utg-explorer/scripts/tests/in_route_surface.test.mjs +125 -0
- package/skills/a2h-utg-explorer/scripts/tests/list_probe_target_wait.test.mjs +86 -0
- package/skills/a2h-utg-explorer/scripts/tests/multi_host.test.mjs +167 -0
- package/skills/a2h-utg-explorer/scripts/tests/nested_list.test.mjs +58 -0
- package/skills/a2h-utg-explorer/scripts/tests/overlay_opener.test.mjs +100 -0
- package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +8 -1
- package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +1 -0
- package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +2 -31
- package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +56 -7
- package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +117 -6
- package/skills/a2h-utg-explorer/scripts/tests/state_inventory.test.mjs +414 -0
- package/skills/a2h-utg-explorer/scripts/tests/tree_unreliable.test.mjs +197 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +196 -30
- package/skills/a2h-utg-explorer/scripts/utg_explorer/hosts.mjs +146 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +63 -2
- package/skills/a2h-utg-explorer/scripts/utg_explorer/states.mjs +286 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +197 -19
- package/skills/a2h-utg-static/SKILL.md +3 -3
- package/skills/a2h-utg-static/references/extractors.md +7 -0
- package/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +4 -3
- package/skills/a2h-utg-static/scripts/click_paths.mjs +1 -1
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +642 -22
- package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +25 -0
- package/skills/a2h-utg-static/scripts/tests/test_in_route_surface.mjs +123 -0
- package/skills/a2h-utg-static/scripts/tests/test_overlay_host_effects.mjs +239 -0
- package/skills/a2h-utg-static/scripts/tests/test_shared_host_depths.mjs +48 -0
- package/skills/a2h-utg-static/scripts/utg_html.mjs +2 -0
- package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +1 -0
- package/i18n/skills/a2h-app-migrate/references/specs.example.json +0 -19
- package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +0 -79
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +0 -47
- package/resource/convert_pipeline_process.svg +0 -114
- package/resource/project_architecture.svg +0 -120
- package/resource/set_environment.png +0 -0
- package/resource/set_multimodel.png +0 -0
- package/skills/a2h-app-migrate/references/specs.example.json +0 -19
- package/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +0 -79
- package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +0 -47
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// static_check/rules/collapsing_toolbar.ts — CAND collapsing-toolbar-not-nested-scroll.
|
|
2
|
+
//
|
|
3
|
+
// M3 LargeTopAppBar / MediumTopAppBar + TopAppBarScrollBehavior is ONE nested-scroll container in which the title
|
|
4
|
+
// translates and collapses as part of the scroll. Migrations tend to split it into a fixed / sibling header plus a
|
|
5
|
+
// separate Scroll, binding a scroll offset to a fraction that then resizes the title in place (.fontSize / .scale).
|
|
6
|
+
// That reads as "the title jumps / shrinks in the wrong place", and when the collapse is gated on the inner list
|
|
7
|
+
// overflowing, it never fires at all if the content is shorter than the viewport (CoolMall About / Profile pages).
|
|
8
|
+
|
|
9
|
+
import { report } from '../core/findings.ts';
|
|
10
|
+
import { lineOfIndex, markedAbove, maskStrings, matchBracket } from '../core/parse.ts';
|
|
11
|
+
import { ownerStart } from '../core/scan.ts';
|
|
12
|
+
import type { FileCtx } from '../core/scan.ts';
|
|
13
|
+
import type { RuleMeta } from '../core/meta.ts';
|
|
14
|
+
|
|
15
|
+
/** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
|
|
16
|
+
export const meta: RuleMeta[] = [
|
|
17
|
+
{
|
|
18
|
+
id: "collapsing-toolbar-not-nested-scroll",
|
|
19
|
+
levels: ["CAND"],
|
|
20
|
+
invariant: "geometry",
|
|
21
|
+
card: "alignment",
|
|
22
|
+
needs: [],
|
|
23
|
+
summary: "a scroll callback (`onDidScroll`/`onScroll`/`onScrollFrameBegin`) writes the scroll amount into a member field, and that field (or a getter derived from it) drives a `.fontSize()` / `.scale()` — the collapsing toolbar is built as \"fixed header + separate Scroll + title resized in place by the scroll fraction\" instead of the title translating with the scroll inside one nested-scroll container.",
|
|
24
|
+
fix: "follow the M3 `LargeTopAppBar`/`MediumTopAppBar` + `TopAppBarScrollBehavior` semantics: put the title inside the **same** scrollable region and let its Y offset follow the scroll offset (one nested-scroll container); do not use \"a non-scrolling sibling layer + in-place scale / font size from a fraction\". Also: if the collapse amount is bound to the inner Scroll overflowing, it never fires when the content is shorter than the viewport and the title stays expanded. When it is correct, write `// COLLAPSING-OK: <basis>` above the line to silence it.",
|
|
25
|
+
escape: "// COLLAPSING-OK:",
|
|
26
|
+
cases: [
|
|
27
|
+
"Measured (CoolMall AboutPage / ProfilePage): the large title in a fixed / sibling header layer fades and scales with .scale()/.fontSize() by scrollFraction instead of translating with the scroll; on ProfilePage the collapse is tied to inner overflow, content (662vp) < viewport (754vp) → collapse is always 0 and the title stays expanded.",
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `{ … }` body of a member method `name(...) { … }` (not a getter), or null. Anchored to a member declaration (line start,
|
|
34
|
+
* optional modifiers) with the return type on the same line, so a call site such as `c ? this.name() : 0;` followed by a
|
|
35
|
+
* later `{` is not mistaken for the definition.
|
|
36
|
+
*/
|
|
37
|
+
function methodBody(code: string, name: string): string | null {
|
|
38
|
+
const m: RegExpExecArray | null = new RegExp(
|
|
39
|
+
`(?:^|\\n)[ \\t]*(?:(?:private|public|protected|static|async)\\s+)*${esc(name)}\\s*\\([^)]*\\)\\s*(?::[^{;\\n]*)?\\{`).exec(code);
|
|
40
|
+
if (m === null) { return null; }
|
|
41
|
+
const open: number = m.index + m[0].length - 1;
|
|
42
|
+
const close: number = matchBracket(code, open);
|
|
43
|
+
return close < 0 ? null : code.slice(open, close);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Escape an identifier for a RegExp (member names may contain `$`). */
|
|
47
|
+
const esc = (s: string): string => s.replace(/\$/g, '\\$');
|
|
48
|
+
|
|
49
|
+
/** `\bthis.<field>\b`, safe for a `$` in the name. */
|
|
50
|
+
const thisRef = (f: string): RegExp => new RegExp(`(?<![\\w$])this\\.${esc(f)}(?![\\w$])`);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Member fields assigned (`this.X = …`) inside a scroll-offset callback of one struct body — directly, or via a method it
|
|
54
|
+
* calls (one level). Only callbacks that report the scroll offset count: onReachEnd / onScrollStop carry no offset and
|
|
55
|
+
* mostly set pagination flags (`this.loading = true`), which say nothing about a collapsing title.
|
|
56
|
+
*/
|
|
57
|
+
function scrollDrivenFields(code: string): Set<string> {
|
|
58
|
+
const fields: Set<string> = new Set();
|
|
59
|
+
const addAssignments = (body: string): void => {
|
|
60
|
+
for (const a of body.matchAll(/(?<![\w$])this\.([A-Za-z_$][\w$]*)\s*=(?!=)/g)) { fields.add(a[1]); }
|
|
61
|
+
};
|
|
62
|
+
for (const m of code.matchAll(/\.(onDidScroll|onScroll|onScrollFrameBegin)\s*\(/g)) {
|
|
63
|
+
const open: number = code.indexOf('(', (m.index ?? 0) + m[0].length - 1);
|
|
64
|
+
const close: number = matchBracket(code, open);
|
|
65
|
+
if (close < 0) { continue; }
|
|
66
|
+
const body: string = code.slice(open, close);
|
|
67
|
+
addAssignments(body);
|
|
68
|
+
// A handler often delegates to a method (`.onDidScroll(() => this.onScrollChange())`): follow it one level.
|
|
69
|
+
for (const call of body.matchAll(/(?<![\w$])this\.([A-Za-z_$][\w$]*)\s*\(/g)) {
|
|
70
|
+
const mb: string | null = methodBody(code, call[1]);
|
|
71
|
+
if (mb !== null) { addAssignments(mb); }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (fields.size === 0) { return fields; }
|
|
75
|
+
// One level of derivation: a getter / @Computed whose body reads a scroll field is itself scroll-driven.
|
|
76
|
+
for (const m of code.matchAll(/\bget\s+([A-Za-z_$][\w$]*)\s*\(\s*\)\s*(?::[^\{]*)?\{/g)) {
|
|
77
|
+
const open: number = code.indexOf('{', (m.index ?? 0) + m[0].length - 1);
|
|
78
|
+
const close: number = matchBracket(code, open);
|
|
79
|
+
if (close < 0) { continue; }
|
|
80
|
+
const body: string = code.slice(open, close);
|
|
81
|
+
if ([...fields].some((f) => thisRef(f).test(body))) { fields.add(m[1]); }
|
|
82
|
+
}
|
|
83
|
+
return fields;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Text-like components whose .fontSize() / .scale() is the collapsing title. */
|
|
87
|
+
const TITLE: Set<string> = new Set(['Text', 'Span']);
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* CAND collapsing-toolbar-not-nested-scroll: within one struct, a scroll-offset callback writes a member field, and that
|
|
91
|
+
* field (or a getter derived from it) drives a Text's .fontSize() / .scale() — the collapsing title resized in place
|
|
92
|
+
* instead of a title translating inside one nested-scroll container. Fields are matched per struct, so a same-named
|
|
93
|
+
* field in another struct of the file does not count. `// COLLAPSING-OK: <basis>` above the attribute silences it.
|
|
94
|
+
*/
|
|
95
|
+
export function checkCollapsingToolbar(fctx: FileCtx): void {
|
|
96
|
+
const { rel, code, rawLines } = fctx;
|
|
97
|
+
const masked: string = maskStrings(code);
|
|
98
|
+
for (const sm of masked.matchAll(/\bstruct\s+[A-Za-z_$][\w$]*[^{]*\{/g)) {
|
|
99
|
+
const sOpen: number = (sm.index ?? 0) + sm[0].length - 1;
|
|
100
|
+
const sClose: number = matchBracket(code, sOpen);
|
|
101
|
+
if (sClose < 0) { continue; }
|
|
102
|
+
const body: string = code.slice(sOpen, sClose);
|
|
103
|
+
const fields: Set<string> = scrollDrivenFields(body);
|
|
104
|
+
if (fields.size === 0) { continue; }
|
|
105
|
+
for (const m of body.matchAll(/\.(fontSize|scale)\s*\(/g)) {
|
|
106
|
+
const dot: number = sOpen + (m.index ?? 0);
|
|
107
|
+
const open: number = dot + m[0].length - 1;
|
|
108
|
+
const close: number = matchBracket(code, open);
|
|
109
|
+
if (close < 0) { continue; }
|
|
110
|
+
const used: string[] = [...fields].filter((f) => thisRef(f).test(code.slice(open + 1, close)));
|
|
111
|
+
if (used.length === 0) { continue; }
|
|
112
|
+
const start: number = ownerStart(masked, dot);
|
|
113
|
+
if (start < 0 || !TITLE.has(/^[A-Za-z_$][\w$]*/.exec(code.slice(start))?.[0] ?? '')) { continue; }
|
|
114
|
+
const line: number = lineOfIndex(code, dot);
|
|
115
|
+
if (markedAbove(rawLines, line, 'COLLAPSING-OK')) { continue; }
|
|
116
|
+
report('CAND', 'collapsing-toolbar-not-nested-scroll', rel, line,
|
|
117
|
+
`.${m[1]}() is driven by a scroll-offset field (${used.join(' / ')}) — the title is resized in place from a scroll fraction, ` +
|
|
118
|
+
'the shape of a collapsing toolbar split into a fixed/sibling header + a separate Scroll. M3 LargeTopAppBar + TopAppBarScrollBehavior is one ' +
|
|
119
|
+
'nested-scroll container whose title translates with the scroll; put the title inside the scrollable region and bind its Y offset to the scroll, ' +
|
|
120
|
+
'and do not gate the collapse on the inner list overflowing (it never fires when content is shorter than the viewport). ' +
|
|
121
|
+
'If this really is intended, write // COLLAPSING-OK: <basis> above it');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
// static_check/rules/compose_semantics.ts — Compose behaviours that a one-to-one API mapping loses:
|
|
2
|
+
// a Refresh that re-enters on a code-driven refresh, a theme parameter that is declared but never read,
|
|
3
|
+
// a layer hidden by opacity whose children still hit-test, a Canvas drawing above its own top edge, and an
|
|
4
|
+
// opaque page that does not cover the bottom bar a layer below it extends into.
|
|
5
|
+
|
|
6
|
+
import { report } from '../core/findings.ts';
|
|
7
|
+
import { attrsWithArgs, directUiChildren, exclusiveBranches, fullOnAxis, lineOfIndex, markedAbove, matchBracket, structBuildRoots } from '../core/parse.ts';
|
|
8
|
+
import type { UiAttr, UiChild } from '../core/parse.ts';
|
|
9
|
+
import { inAttrArgs, maskedOf } from '../core/scan.ts';
|
|
10
|
+
import type { FileScan } from '../core/scan.ts';
|
|
11
|
+
import type { RuleMeta } from '../core/meta.ts';
|
|
12
|
+
import { rangeInteractive, spansParent } from './hit_test.ts';
|
|
13
|
+
import type { Tri } from './hit_test.ts';
|
|
14
|
+
|
|
15
|
+
/** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
|
|
16
|
+
export const meta: RuleMeta[] = [
|
|
17
|
+
{
|
|
18
|
+
id: "refresh-programmatic-reentry",
|
|
19
|
+
levels: ["GATE", "CAND"],
|
|
20
|
+
invariant: "state",
|
|
21
|
+
card: "interaction",
|
|
22
|
+
needs: [],
|
|
23
|
+
summary: "`Refresh({ refreshing: <one-way bound state> })` has `.onRefreshing(…)` on its chain but no `.onStateChange(…)` to tell a user pull apart.",
|
|
24
|
+
fix: "`onRefreshing` fires when the refresh state is entered (API reference refresh.d.ts: \"Called when the refresh state is entered\"); code setting `refreshing` to true (first load, a request after the location resolves) enters it too, and a request sent from the callback re-enters, so concurrent requests keep re-projecting data. Android `setRefreshing(true)` does not notify the `OnRefreshListener`. Record in `.onStateChange` whether the user is dragging (`RefreshStatus.Drag` / `OverDrag` set it, `Inactive` / `Done` clear it) and forward `onRefreshing` only for a user pull. When `refreshing` is written only by this component's pull and code never sets it true, write `// REFRESH-REENTRY: <basis>` above it (downgrades to CAND).",
|
|
25
|
+
escape: "// REFRESH-REENTRY:",
|
|
26
|
+
cases: [
|
|
27
|
+
"Measured (a View-based weather app): home page `Refresh({ refreshing: vm.loading }).onRefreshing(() => vm.refresh())`; after the location resolved, loadBoth() set loading to true, onRefreshing fired refresh() again, two requests ran concurrently, and the i18n date formatter in the projection hit SIGSEGV in native code, which try/catch cannot catch.",
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "theme-param-unread",
|
|
32
|
+
levels: ["GATE"],
|
|
33
|
+
invariant: "appearance",
|
|
34
|
+
card: "resources",
|
|
35
|
+
needs: [],
|
|
36
|
+
summary: "A component declares a dark/light or theme parameter (`@Param` / `@Prop` / `@Link` named like `isDark`, `isXxxDark`, `isLight`, `darkMode`, `theme`) but never reads `this.<param>`.",
|
|
37
|
+
fix: "Colours picked by a parameter in Compose, such as `colorResource(if (isDark) R.color.color_white else R.color.color_black).copy(alpha = …)`, need both branches: `.fontColor(this.isDark ? 'rgba(255,255,255,0.5)' : 'rgba(0,0,0,0.5)')`, and every call site must pass the parameter. Keeping one branch (hard-coded white) makes text, borders and icons unreadable on a light background. Delete the declaration when the parameter is truly not needed.",
|
|
38
|
+
escape: null,
|
|
39
|
+
cases: [
|
|
40
|
+
"Measured (a Compose weather app): the home footer `WeatherFooter(isDark)` picks black/white for the source text and the card-sort button by isDark; the port declared `@Param isDark` but hard-coded white@0.4/0.5 and the call site did not pass it, so the text was too light on the orange background.",
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "hidden-layer-children-hit",
|
|
45
|
+
levels: ["GATE", "CAND"],
|
|
46
|
+
invariant: "interaction",
|
|
47
|
+
card: "interaction",
|
|
48
|
+
needs: [],
|
|
49
|
+
summary: "One node has both `.opacity(<state expression>)` and a `.hitTestBehavior(<conditional>)` that switches between `HitTestMode.None` and another mode, and its subtree has interactive nodes (clicks, gestures, Scroll/List/Refresh/Swiper, …). CAND when the subtree has components outside the scanned files.",
|
|
50
|
+
fix: "`HitTestMode.None` only stops the node itself; its children still respond (enum reference: \"Self not respond … but children respond\"). A page or layer hidden by opacity stays in the tree, and the Scroll and buttons in its subtree keep taking taps meant for the layer below. When Compose hides it by not composing it (`if (animValue < 1) { … }`), write `if` in ArkUI and unmount it when the transition ends; when the node must stay during the transition, use `HitTestMode.BLOCK_DESCENDANTS` in the hidden state (API 20+, neither the node nor any descendant responds), or wrap the hidden state in `if` on lower versions. When the subtree cannot be tapped while hidden (for example it is also `visibility(Visibility.Hidden)`), write `// HIDDEN-LAYER: <basis>` above it (downgrades to CAND).",
|
|
51
|
+
escape: "// HIDDEN-LAYER:",
|
|
52
|
+
cases: [
|
|
53
|
+
"Measured (a Compose weather app): the home Stack has the city manager below and the weather page above; collapsing the weather page only set opacity + 4% scale and `.hitTestBehavior(shown > 0.5 ? Default : None)`. Once hidden, the Refresh/Scroll in the weather page still took taps, so the city manager's back button and city rows did nothing. Android stops composing the weather page when animValue == 1.",
|
|
54
|
+
],
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "canvas-negative-draw-offset",
|
|
58
|
+
levels: ["CAND"],
|
|
59
|
+
invariant: "geometry",
|
|
60
|
+
card: "canvas",
|
|
61
|
+
needs: [],
|
|
62
|
+
summary: "In a file with `CanvasRenderingContext2D`, a y variable (name containing `Y` / `Top`) is initialised to a negative constant, or a draw call (`fillText` / `roundRect` / `moveTo`, …) has a negative literal after its first argument.",
|
|
63
|
+
fix: "Compose `Canvas` / `drawBehind` does not clip by default, so the source often draws bubbles and labels above the canvas top edge (negative y), into space reserved above it. ArkUI `Canvas` draws only inside the component, so content at negative coordinates is not where it was and competes with siblings outside the canvas. Fold the reserved height into the Canvas (grow it and shift every y by the same amount), or make the bubble a separate layer outside the Canvas (Stack + a position computed from the selected point). After checking, state the approach in the report under Transition Implementation Evidence or Position Anchor Evidence.",
|
|
64
|
+
escape: null,
|
|
65
|
+
cases: [
|
|
66
|
+
"Measured (a Compose weather app): the 40-day trend chart reserves 24dp above the chart and draws the selection bubble at `bubbleY = -14dp`; the port copied -14 and the bubble covered the counters row above it.",
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
id: "opaque-layer-safe-area-mismatch",
|
|
71
|
+
levels: ["GATE"],
|
|
72
|
+
invariant: "window",
|
|
73
|
+
card: "window",
|
|
74
|
+
needs: [],
|
|
75
|
+
summary: "In a `Stack`, an earlier filling layer extends its content or background into the bottom navigation bar (`expandSafeArea` with `SafeAreaEdge.BOTTOM` or no edges list, or `background(…, { ignoresLayoutSafeAreaEdges })` with `BOTTOM`), while a later filling opaque layer (its own chain or its custom component's root has `backgroundColor` / `background`) does not extend to BOTTOM.",
|
|
76
|
+
fix: "With two stacked layers, an upper layer that extends only to TOP lets the bottom navigation bar show the lower layer's background (gradient, image). Extend the upper layer's background to the same edges: `.background(<colour>, { ignoresLayoutSafeAreaEdges: [LayoutSafeAreaEdge.TOP, LayoutSafeAreaEdge.BOTTOM] })`, keeping the content inside the safe area. When the bar is meant to show the layer below, make the upper background transparent.",
|
|
77
|
+
escape: null,
|
|
78
|
+
cases: [
|
|
79
|
+
"Measured (a Compose weather app): the home root Stack draws the weather gradient with expandSafeArea(TOP, BOTTOM) at the bottom; the city manager above it only ignoresLayoutSafeAreaEdges [TOP], so a band of gradient showed in the bottom navigation bar.",
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
/** Args text of the call whose `(` is at paren. */
|
|
85
|
+
function argsOf(code: string, paren: number): string {
|
|
86
|
+
const close: number = matchBracket(code, paren);
|
|
87
|
+
return close < 0 ? '' : code.slice(paren + 1, close);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** [open, close] of `{ … }` after the `(…)` at paren, or null. */
|
|
91
|
+
function blockAfter(code: string, paren: number): [number, number] | null {
|
|
92
|
+
const pe: number = matchBracket(code, paren);
|
|
93
|
+
if (pe < 0) { return null; }
|
|
94
|
+
let k: number = pe + 1;
|
|
95
|
+
while (k < code.length && /\s/.test(code[k])) { k++; }
|
|
96
|
+
if (code[k] !== '{') { return null; }
|
|
97
|
+
const be: number = matchBracket(code, k);
|
|
98
|
+
return be < 0 ? null : [k, be];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Every built-in or custom component call `Name(` in s that is a node (not inside an attribute's arguments). */
|
|
102
|
+
function calls(s: FileScan, name: string): number[] {
|
|
103
|
+
const masked: string = maskedOf(s);
|
|
104
|
+
const out: number[] = [];
|
|
105
|
+
for (const m of masked.matchAll(new RegExp(`(?<![\\w$.])${name}\\s*\\(`, 'g'))) {
|
|
106
|
+
const at: number = m.index ?? 0;
|
|
107
|
+
if (inAttrArgs(masked, at)) { continue; }
|
|
108
|
+
out.push(at + m[0].length - 1);
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** GATE refresh-programmatic-reentry. */
|
|
114
|
+
export function checkRefreshReentry(scans: FileScan[]): void {
|
|
115
|
+
for (const s of scans) {
|
|
116
|
+
const raw: string[] = s.src.split('\n');
|
|
117
|
+
for (const paren of calls(s, 'Refresh')) {
|
|
118
|
+
const args: string = argsOf(s.code, paren);
|
|
119
|
+
const rm: RegExpExecArray | null = /\brefreshing\s*:\s*([^,}]+)/.exec(args);
|
|
120
|
+
if (rm === null) { continue; }
|
|
121
|
+
const v: string = rm[1].trim();
|
|
122
|
+
// Two-way binding: the component writes the value back; code-driven entries are still possible but rarer.
|
|
123
|
+
if (v.startsWith('$$') || v.endsWith('!!') || /^(true|false)$/.test(v)) { continue; }
|
|
124
|
+
const attrs: UiAttr[] = attrsWithArgs(s.code, paren);
|
|
125
|
+
if (!attrs.some((a) => a.name === 'onRefreshing')) { continue; }
|
|
126
|
+
if (attrs.some((a) => a.name === 'onStateChange')) { continue; }
|
|
127
|
+
const line: number = lineOfIndex(s.code, paren);
|
|
128
|
+
const marked: boolean = markedAbove(raw, line, 'REFRESH-REENTRY');
|
|
129
|
+
report(marked ? 'CAND' : 'GATE', 'refresh-programmatic-reentry', s.rel, line,
|
|
130
|
+
`Refresh({ refreshing: ${v} }) fires .onRefreshing whenever the state becomes true, including when code sets it; ` +
|
|
131
|
+
'Android setRefreshing(true) does not call the listener. Track the user drag in .onStateChange (Drag/OverDrag) and ' +
|
|
132
|
+
'forward onRefreshing only for a pull, or mark // REFRESH-REENTRY: <basis> if code never sets it true');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const THEME_PARAM: RegExp = /@(?:Param|Prop|Link|Require\s+@Param)\s+(?:(?:readonly|private|public)\s+)*((?:is[A-Z]\w*)?(?:Dark|Light)\w*|is(?:Dark|Light)\w*|dark\w*|light(?:Mode|Theme)\w*|\w*[Tt]heme(?:Mode)?)\s*[:?=]/g;
|
|
138
|
+
|
|
139
|
+
/** GATE theme-param-unread. */
|
|
140
|
+
export function checkThemeParamUnread(scans: FileScan[]): void {
|
|
141
|
+
for (const s of scans) {
|
|
142
|
+
const masked: string = maskedOf(s);
|
|
143
|
+
for (const sm of masked.matchAll(/\bstruct\s+([A-Za-z_$][\w$]*)[^{]*\{/g)) {
|
|
144
|
+
const open: number = (sm.index ?? 0) + sm[0].length - 1;
|
|
145
|
+
const close: number = matchBracket(s.code, open);
|
|
146
|
+
if (close < 0) { continue; }
|
|
147
|
+
const body: string = s.code.slice(open, close);
|
|
148
|
+
for (const pm of body.matchAll(THEME_PARAM)) {
|
|
149
|
+
const name: string = pm[1];
|
|
150
|
+
if (new RegExp(`\\bthis\\.${name}\\b`).test(body)) { continue; }
|
|
151
|
+
report('GATE', 'theme-param-unread', s.rel, lineOfIndex(s.code, open + (pm.index ?? 0)),
|
|
152
|
+
`${sm[1]} declares ${name} but never reads this.${name}: the Android colours switch on it ` +
|
|
153
|
+
'(if (isDark) white else black), so a hard-coded colour shows only one branch. Translate both branches and pass it at every call site');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** GATE hidden-layer-children-hit. */
|
|
160
|
+
export function checkHiddenLayerChildrenHit(scans: FileScan[]): void {
|
|
161
|
+
const builtins: string[] = ['Column', 'Row', 'Stack', 'Flex', 'RelativeContainer', 'GridRow', 'Scroll', 'List', 'Refresh'];
|
|
162
|
+
for (const s of scans) {
|
|
163
|
+
const raw: string[] = s.src.split('\n');
|
|
164
|
+
for (const name of builtins) {
|
|
165
|
+
for (const paren of calls(s, name)) {
|
|
166
|
+
const attrs: UiAttr[] = attrsWithArgs(s.code, paren);
|
|
167
|
+
const hit: UiAttr | undefined = attrs.find((a) => a.name === 'hitTestBehavior');
|
|
168
|
+
if (hit === undefined || !/HitTestMode\.None\b/.test(hit.args) || !/\?/.test(hit.args)) { continue; }
|
|
169
|
+
const op: UiAttr | undefined = attrs.find((a) => a.name === 'opacity');
|
|
170
|
+
if (op === undefined || /^\s*[\d.]+\s*$/.test(op.args)) { continue; }
|
|
171
|
+
// The hit-test switch must follow the same state as the opacity (a page shown/hidden by one value);
|
|
172
|
+
// a switch on an unrelated condition (data present or not) is a different decision.
|
|
173
|
+
const ids = (x: string): string[] => [...x.matchAll(/\b(?:this\.)?((?:[A-Za-z_$][\w$]*\.)*[A-Za-z_$][\w$]*)/g)]
|
|
174
|
+
.map((m) => m[1]).filter((n) => !/^(HitTestMode|Default|None|Block|Transparent|this)$/.test(n));
|
|
175
|
+
const opIds: Set<string> = new Set(ids(op.args));
|
|
176
|
+
if (!ids(hit.args).some((n) => opIds.has(n))) { continue; }
|
|
177
|
+
const blk: [number, number] | null = blockAfter(s.code, paren);
|
|
178
|
+
if (blk === null) { continue; }
|
|
179
|
+
const inter: Tri = rangeInteractive(scans, s, blk[0], blk[1]);
|
|
180
|
+
if (inter === false) { continue; }
|
|
181
|
+
const line: number = lineOfIndex(s.code, paren);
|
|
182
|
+
const marked: boolean = markedAbove(raw, line, 'HIDDEN-LAYER');
|
|
183
|
+
report(inter === null || marked ? 'CAND' : 'GATE', 'hidden-layer-children-hit', s.rel, line,
|
|
184
|
+
`${name} is hidden by .opacity(${op.args.trim()}) and switches .hitTestBehavior(${hit.args.trim()}), but HitTestMode.None ` +
|
|
185
|
+
'only stops the node itself: its children (scroll, buttons) still take taps while it is invisible' +
|
|
186
|
+
(inter === null ? ' (part of the subtree is outside the scanned files)' : '') +
|
|
187
|
+
'. Unmount it with if when the Android source stops composing it, or use HitTestMode.BLOCK_DESCENDANTS (API 20+) in the hidden state');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const NEG_Y_DECL: RegExp = /\b(?:const|let|readonly|private|public|static)\s+([A-Za-z_$]*(?:Y|Top)[\w$]*|y[A-Z][\w$]*|y|top)\s*(?::\s*number)?\s*=\s*-\s*\d+(?:\.\d+)?/g;
|
|
194
|
+
const NEG_Y_CALL: RegExp = /\.(fillText|strokeText|fillRect|strokeRect|clearRect|rect|roundRect|moveTo|lineTo|arc|drawImage)\s*\([^();]*?,\s*-\s*\d/g;
|
|
195
|
+
|
|
196
|
+
/** CAND canvas-negative-draw-offset. */
|
|
197
|
+
export function checkCanvasNegativeOffset(scans: FileScan[]): void {
|
|
198
|
+
for (const s of scans) {
|
|
199
|
+
if (!/\bCanvasRenderingContext2D\b/.test(s.code)) { continue; }
|
|
200
|
+
const masked: string = maskedOf(s);
|
|
201
|
+
const seen: Set<number> = new Set();
|
|
202
|
+
for (const re of [NEG_Y_DECL, NEG_Y_CALL]) {
|
|
203
|
+
for (const m of masked.matchAll(re)) {
|
|
204
|
+
// -1 is the usual "nothing selected" sentinel, not a coordinate.
|
|
205
|
+
if (/=\s*-\s*1\b(?!\.)/.test(m[0]) && re === NEG_Y_DECL) { continue; }
|
|
206
|
+
const line: number = lineOfIndex(s.code, m.index ?? 0);
|
|
207
|
+
if (seen.has(line)) { continue; }
|
|
208
|
+
seen.add(line);
|
|
209
|
+
report('CAND', 'canvas-negative-draw-offset', s.rel, line,
|
|
210
|
+
`${s.code.split('\n')[line - 1].trim()} — a y above the Canvas top edge. Compose does not clip a Canvas, ArkUI draws only inside the component: ` +
|
|
211
|
+
'grow the Canvas by the reserved space and shift every y, or move the bubble/label into a separate layer');
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
type Edges = { top: boolean; bottom: boolean };
|
|
218
|
+
|
|
219
|
+
/** Safe-area edges the chain extends into (expandSafeArea / background ignoresLayoutSafeAreaEdges), or null when it does neither. */
|
|
220
|
+
function extendedEdges(attrs: UiAttr[]): Edges | null {
|
|
221
|
+
let any: boolean = false;
|
|
222
|
+
const e: Edges = { top: false, bottom: false };
|
|
223
|
+
for (const a of attrs) {
|
|
224
|
+
let list: string;
|
|
225
|
+
if (a.name === 'expandSafeArea') {
|
|
226
|
+
// expandSafeArea() / expandSafeArea([types]) with no edges list extends every edge.
|
|
227
|
+
const edges: RegExpExecArray | null = /,\s*\[([^\]]*)\]/.exec(a.args);
|
|
228
|
+
list = edges === null ? 'TOP BOTTOM' : edges[1];
|
|
229
|
+
} else if (a.name === 'background') {
|
|
230
|
+
const m: RegExpExecArray | null = /ignoresLayoutSafeAreaEdges\s*:\s*\[([^\]]*)\]/.exec(a.args);
|
|
231
|
+
if (m === null) { continue; }
|
|
232
|
+
list = m[1];
|
|
233
|
+
} else { continue; }
|
|
234
|
+
any = true;
|
|
235
|
+
e.top = e.top || /\bTOP\b/.test(list);
|
|
236
|
+
e.bottom = e.bottom || /\bBOTTOM\b/.test(list);
|
|
237
|
+
}
|
|
238
|
+
return any ? e : null;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** The chain paints an opaque surface of its own. */
|
|
242
|
+
function opaque(attrs: UiAttr[]): boolean {
|
|
243
|
+
return attrs.some((a) => (a.name === 'backgroundColor' || a.name === 'background' || a.name === 'linearGradient') &&
|
|
244
|
+
!/transparent|Color\.Transparent|['"]#00[0-9A-Fa-f]{6}['"]|['"]rgba\([^)]*,\s*0(?:\.0*)?%?\s*\)['"]/.test(a.args));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Root attrs of struct name's build() in the scanned files, or null. */
|
|
248
|
+
function structRootAttrs(scans: FileScan[], name: string): UiAttr[] | null {
|
|
249
|
+
for (const s of scans) {
|
|
250
|
+
if (!s.declaredStructs.includes(name)) { continue; }
|
|
251
|
+
const r = structBuildRoots(s.code).find((x) => x.struct === name);
|
|
252
|
+
if (r !== undefined) { return attrsWithArgs(s.code, r.paren); }
|
|
253
|
+
}
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** GATE opaque-layer-safe-area-mismatch. */
|
|
258
|
+
export function checkOpaqueLayerSafeArea(scans: FileScan[]): void {
|
|
259
|
+
for (const s of scans) {
|
|
260
|
+
for (const paren of calls(s, 'Stack')) {
|
|
261
|
+
const blk: [number, number] | null = blockAfter(s.code, paren);
|
|
262
|
+
if (blk === null) { continue; }
|
|
263
|
+
const stackAttrs: UiAttr[] = attrsWithArgs(s.code, paren);
|
|
264
|
+
const kids: UiChild[] = directUiChildren(s.code, blk[0], blk[1], undefined, { intoBranches: true })
|
|
265
|
+
.filter((c) => c.control !== true && !c.isBuilderCall);
|
|
266
|
+
const fills = (attrs: UiAttr[]): boolean =>
|
|
267
|
+
(fullOnAxis(attrs, 'width') || spansParent(attrs, stackAttrs, 'width')) &&
|
|
268
|
+
(fullOnAxis(attrs, 'height') || spansParent(attrs, stackAttrs, 'height'));
|
|
269
|
+
for (let i = 1; i < kids.length; i++) {
|
|
270
|
+
const top: UiChild = kids[i];
|
|
271
|
+
const rootAttrs: UiAttr[] = /^[A-Z]/.test(top.name) ? (structRootAttrs(scans, top.name) ?? []) : [];
|
|
272
|
+
const own: UiAttr[] = [...top.attrs, ...rootAttrs];
|
|
273
|
+
if (!fills(top.attrs) && !fills(rootAttrs)) { continue; }
|
|
274
|
+
if (!opaque(own)) { continue; }
|
|
275
|
+
const mine: Edges | null = extendedEdges(own);
|
|
276
|
+
if (mine !== null && mine.bottom) { continue; }
|
|
277
|
+
const under: UiChild | undefined = kids.slice(0, i).find((c) =>
|
|
278
|
+
!exclusiveBranches(c, top) && fills(c.attrs) && (extendedEdges(c.attrs)?.bottom ?? false));
|
|
279
|
+
if (under === undefined) { continue; }
|
|
280
|
+
report('GATE', 'opaque-layer-safe-area-mismatch', s.rel, lineOfIndex(s.code, top.at),
|
|
281
|
+
`${top.name} covers the Stack with an opaque background that extends ${mine?.top ? 'only to TOP' : 'into no system bar'}, ` +
|
|
282
|
+
`while the earlier ${under.name} (line ${lineOfIndex(s.code, under.at)}) extends into the bottom bar: the bottom bar shows the layer below. ` +
|
|
283
|
+
'Extend the background of this layer to BOTTOM as well: .background(<colour>, { ignoresLayoutSafeAreaEdges: [LayoutSafeAreaEdge.TOP, LayoutSafeAreaEdge.BOTTOM] })');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// static_check/rules/flowitem_width.ts — GATE flowitem-no-cross-size.
|
|
2
|
+
//
|
|
3
|
+
// In a vertical WaterFlow (columnsTemplate) the column width is where each FlowItem is placed, but a FlowItem with no
|
|
4
|
+
// width of its own does not hand that column width down as the percentage reference: a card root inside it written as
|
|
5
|
+
// `.width('100%')` resolved against the whole WaterFlow width. Measured: each card came out about as wide as the list,
|
|
6
|
+
// `aspectRatio(1)` made its image a full-width square, the next column's card was drawn over the overflow, so the
|
|
7
|
+
// column gap and the card padding disappeared and the first card's subtitle was cut at the column edge. The SDK's own
|
|
8
|
+
// WaterFlow examples all set `.width('100%')` on the FlowItem itself.
|
|
9
|
+
|
|
10
|
+
import { report } from '../core/findings.ts';
|
|
11
|
+
import { attrsWithArgs, lineOfIndex, markedAbove, maskStrings } from '../core/parse.ts';
|
|
12
|
+
import type { UiAttr } from '../core/parse.ts';
|
|
13
|
+
import { ancestorsOf, verticalScroller } from '../core/scan.ts';
|
|
14
|
+
import type { Ancestor, FileCtx } from '../core/scan.ts';
|
|
15
|
+
import type { RuleMeta } from '../core/meta.ts';
|
|
16
|
+
|
|
17
|
+
/** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
|
|
18
|
+
export const meta: RuleMeta[] = [
|
|
19
|
+
{
|
|
20
|
+
id: "flowitem-no-cross-size",
|
|
21
|
+
levels: ["GATE", "CAND"],
|
|
22
|
+
invariant: "geometry",
|
|
23
|
+
card: "geometry",
|
|
24
|
+
needs: [],
|
|
25
|
+
summary: "A `FlowItem()` inside a `WaterFlow` has no size of its own on the cross axis (no `.width(…)` in a vertical flow, no `.height(…)` in a horizontal one) — the column width is not handed down as the percentage reference, a child's `'100%'` resolves against the whole WaterFlow, and the card spreads to screen width over the neighbouring column.",
|
|
26
|
+
fix: "Give the `FlowItem` its cross-axis size: vertical (`columnsTemplate`) `.width('100%')`, horizontal (`layoutDirection(FlexDirection.Row)` + `rowsTemplate`) `.height('100%')`, so a child's percentage resolves against the column width / row height. When there is a real reason, write `// FLOWITEM-SIZE: <basis>` above the line to downgrade to CAND.",
|
|
27
|
+
escape: "// FLOWITEM-SIZE:",
|
|
28
|
+
cases: [
|
|
29
|
+
"Measured (e-commerce app footprint page): a two-column WaterFlow, `FlowItem() { GoodsGridItem(...) }` with no width, the card root `.width('100%')` and the image box `.width('100%').aspectRatio(1)`; on the device each card was about as wide as the screen, the image became a screen-wide square, the second column's card covered the first one's overflow, the column gap and card padding were invisible, and the first card's subtitle was cut at the column boundary. Build, GATE and smoke all passed.",
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* GATE flowitem-no-cross-size: a FlowItem() whose own attribute chain gives no size on the WaterFlow's cross axis
|
|
36
|
+
* (width for a vertical flow, height for one laid out as a row). The direction is read from the WaterFlow enclosing the
|
|
37
|
+
* FlowItem. A FlowItem with no enclosing WaterFlow in its file (inside a @Builder, or a component used elsewhere) takes
|
|
38
|
+
* the direction of the file's WaterFlows when they all agree, vertical when the file has none, and is not judged when
|
|
39
|
+
* the file has both. `// FLOWITEM-SIZE: <basis>` within three lines above downgrades to CAND.
|
|
40
|
+
*/
|
|
41
|
+
export function checkFlowItemCrossSize(fctx: FileCtx): void {
|
|
42
|
+
const { rel, code, rawLines } = fctx;
|
|
43
|
+
if (!/\bFlowItem\s*\(/.test(code)) { return; }
|
|
44
|
+
const masked: string = maskStrings(code);
|
|
45
|
+
const fileDirs: Set<boolean> = new Set<boolean>(); // true = horizontal
|
|
46
|
+
for (const w of masked.matchAll(/\bWaterFlow\s*\(/g)) {
|
|
47
|
+
fileDirs.add(!verticalScroller('WaterFlow', attrsWithArgs(code, (w.index ?? 0) + w[0].length - 1)));
|
|
48
|
+
}
|
|
49
|
+
for (const m of masked.matchAll(/\bFlowItem\s*\(/g)) {
|
|
50
|
+
const paren: number = (m.index ?? 0) + m[0].length - 1;
|
|
51
|
+
const flow: Ancestor | undefined = ancestorsOf(code, masked, m.index ?? 0)
|
|
52
|
+
.find((a) => a.kind === 'comp' && a.name === 'WaterFlow');
|
|
53
|
+
let horizontal: boolean;
|
|
54
|
+
if (flow !== undefined && flow.kind === 'comp') {
|
|
55
|
+
horizontal = !verticalScroller('WaterFlow', flow.attrs);
|
|
56
|
+
} else if (fileDirs.size > 1) {
|
|
57
|
+
continue; // direction unknown: GATE prefers a miss
|
|
58
|
+
} else {
|
|
59
|
+
horizontal = fileDirs.has(true);
|
|
60
|
+
}
|
|
61
|
+
const axis: 'width' | 'height' = horizontal ? 'height' : 'width';
|
|
62
|
+
const attrs: UiAttr[] = attrsWithArgs(code, paren);
|
|
63
|
+
const sized: boolean = attrs.some((a) => a.name === axis ||
|
|
64
|
+
(a.name === 'size' && new RegExp('\\b' + axis + '\\s*:').test(a.args)));
|
|
65
|
+
if (sized) { continue; }
|
|
66
|
+
const line: number = lineOfIndex(code, m.index ?? 0);
|
|
67
|
+
const msg: string = `FlowItem() sets no ${axis}: the ${horizontal ? 'row height' : 'column width'} is not handed down as ` +
|
|
68
|
+
`the percentage reference, so a child's '100%' ${axis} resolves against the whole WaterFlow — the card spreads ` +
|
|
69
|
+
`across the ${horizontal ? 'list height' : 'list width'}, aspectRatio images blow up, and the next ` +
|
|
70
|
+
`${horizontal ? 'row' : 'column'} is drawn over it (gap and card padding vanish). Write .${axis}('100%') on the FlowItem`;
|
|
71
|
+
if (markedAbove(rawLines, line, 'FLOWITEM-SIZE')) {
|
|
72
|
+
report('CAND', 'flowitem-no-cross-size', rel, line, `${msg}; marked FLOWITEM-SIZE — confirm on a device`);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
report('GATE', 'flowitem-no-cross-size', rel, line,
|
|
76
|
+
`${msg}. If there is a real reason, write // FLOWITEM-SIZE: <basis> above it`);
|
|
77
|
+
}
|
|
78
|
+
}
|