@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,138 @@
|
|
|
1
|
+
// static_check/rules/inset_stacked.ts — the same horizontal padding written on a custom component's build() root
|
|
2
|
+
// and again on a container around its call site.
|
|
3
|
+
|
|
4
|
+
import { report } from '../core/findings.ts';
|
|
5
|
+
import { attrsWithArgs, lineOfIndex, markedAbove, splitTopLevel, structBuildRoots } from '../core/parse.ts';
|
|
6
|
+
import type { UiAttr } from '../core/parse.ts';
|
|
7
|
+
import { ancestorsOf, maskedOf, resolveStructFile, structCallSites, SCROLLERS } from '../core/scan.ts';
|
|
8
|
+
import type { FileScan } from '../core/scan.ts';
|
|
9
|
+
import type { RuleMeta } from '../core/meta.ts';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
|
|
12
|
+
/** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
|
|
13
|
+
export const meta: RuleMeta[] = [
|
|
14
|
+
{
|
|
15
|
+
id: "inset-double-applied",
|
|
16
|
+
levels: ["GATE", "CAND"],
|
|
17
|
+
invariant: "geometry",
|
|
18
|
+
card: "geometry",
|
|
19
|
+
needs: [],
|
|
20
|
+
summary: "自定义组件 build() 根节点写了左右 `.padding()`,而它的某个调用处、或调用处外层到滚动容器为止的某个容器,又写了左右值相同的 `.padding()` —— 同一层内缩被叠加两次。",
|
|
21
|
+
fix: "内嵌 Fragment / include 布局根上的 padding 只属于组件自己:保留组件根节点上的那份,删掉宿主侧的那份。宿主容器(如 `flTodayWeather` 对应的 Column)只写宿主自己的属性;宿主需要额外偏移(折叠头高度等)时只写那一项(如 `.padding({ top: HEADER_H })`),不要把子布局的左右内缩一起带上来。两层确实各自存在时(Android 宿主容器自身也有同值 padding),在宿主 `.padding(` 行上方写 `// INSET-STACKED: <宿主 XML 文件:行>`,降为 CAND。组件根节点自己画了盒子(背景、边框、圆角、阴影,即卡片)时,根上的 padding 是卡片内边距、宿主的是页边距,只报 CAND,对照 Android 宿主布局确认。",
|
|
22
|
+
escape: "// INSET-STACKED:",
|
|
23
|
+
cases: [
|
|
24
|
+
"WeatherApp 11-22 首页:TodayWeatherView 根 Column `.padding({left:16,right:16,top:16})` 对应 fragment_today_weather.xml:23-25,宿主 MainPage 包它的 Column 又写 `.padding({left:16,right:16,top:HEADER_H_E+16})`(flTodayWeather 无 padding)。卡片左缘 112px=32vp(Android 42px=16dp),满宽卡占屏宽 82.5%(Android 92%),2 列小卡 37%(Android 44%);phase5 与 static_check 全绿、冒烟 PASS。",
|
|
25
|
+
],
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
type Sides = { l: number | null; r: number | null };
|
|
30
|
+
|
|
31
|
+
/** A literal vp value: `16`, `'16vp'`, `LengthMetrics.vp(16)`; null for expressions, %, resources. */
|
|
32
|
+
function vp(v: string | undefined): number | null {
|
|
33
|
+
if (v === undefined) { return 0; }
|
|
34
|
+
const t: string = v.trim();
|
|
35
|
+
const lm: RegExpMatchArray | null = t.match(/^LengthMetrics\.vp\(\s*(\d+(?:\.\d+)?)\s*\)$/);
|
|
36
|
+
if (lm !== null) { return parseFloat(lm[1]); }
|
|
37
|
+
const m: RegExpMatchArray | null = t.match(/^(?:(\d+(?:\.\d+)?)|(['"`])(\d+(?:\.\d+)?)(?:vp)?\2)$/);
|
|
38
|
+
return m === null ? null : parseFloat(m[1] ?? m[3]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Left / right padding of `.padding(args)`; a side is null when it is not a literal. */
|
|
42
|
+
export function horizontalSides(args: string): Sides {
|
|
43
|
+
const all: number | null = vp(args);
|
|
44
|
+
if (all !== null) { return { l: all, r: all }; }
|
|
45
|
+
const t: string = args.trim();
|
|
46
|
+
if (!t.startsWith('{') || !t.endsWith('}')) { return { l: null, r: null }; }
|
|
47
|
+
const f: Map<string, string> = new Map();
|
|
48
|
+
for (const part of splitTopLevel(t.slice(1, -1))) {
|
|
49
|
+
const kv: RegExpMatchArray | null = part.match(/^\s*([A-Za-z_$][\w$]*)\s*:\s*([\s\S]+?)\s*$/);
|
|
50
|
+
if (kv !== null) { f.set(kv[1], kv[2]); }
|
|
51
|
+
}
|
|
52
|
+
return { l: vp(f.get('left') ?? f.get('start')), r: vp(f.get('right') ?? f.get('end')) };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The last `.padding()` of a chain (later writes win). */
|
|
56
|
+
function lastPadding(attrs: UiAttr[]): UiAttr | undefined {
|
|
57
|
+
return [...attrs].reverse().find((a) => a.name === 'padding');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Attributes that draw a box: padding inside one is the box's content inset, not the page's. */
|
|
61
|
+
const BOX_ATTRS: Set<string> = new Set(['backgroundColor', 'background', 'backgroundImage', 'linearGradient',
|
|
62
|
+
'border', 'borderWidth', 'borderRadius', 'shadow']);
|
|
63
|
+
|
|
64
|
+
/** Both sides known, at least one non-zero, and equal side by side. */
|
|
65
|
+
function sameInset(a: Sides, b: Sides): boolean {
|
|
66
|
+
if (a.l === null || a.r === null || b.l === null || b.r === null) { return false; }
|
|
67
|
+
if (a.l === 0 && a.r === 0) { return false; }
|
|
68
|
+
return a.l === b.l && a.r === b.r;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* GATE inset-double-applied.
|
|
73
|
+
*
|
|
74
|
+
* An embedded Fragment / `<include>` keeps its root padding in its own layout; the host container that
|
|
75
|
+
* holds it usually has none. Converting the two separately, the agent writes the fragment's padding on the
|
|
76
|
+
* component's build() root (correct) and copies it onto the host wrapper too (while it was deriving an
|
|
77
|
+
* unrelated top offset there). Each file looks right on its own and every per-file check passes; on screen
|
|
78
|
+
* every card is inset twice and visibly narrower than on Android.
|
|
79
|
+
*
|
|
80
|
+
* Only equal left/right values count: different values are usually a real page gutter plus a card gutter.
|
|
81
|
+
* The walk goes from the call site outward to the nearest scroll container or the build() root, and
|
|
82
|
+
* includes the call site's own chain (a `.padding()` there wraps the component in __Common__, same effect).
|
|
83
|
+
* A root that draws a box (background, border, radius, shadow) is a card: its padding insets the card's
|
|
84
|
+
* content and the host's is the page gutter, the Android "16dp page + 16dp CardView" shape. That is a CAND.
|
|
85
|
+
*/
|
|
86
|
+
export function checkInsetDoubleApplied(scans: FileScan[]): void {
|
|
87
|
+
const declCount: Map<string, number> = new Map();
|
|
88
|
+
for (const s of scans) {
|
|
89
|
+
for (const n of s.declaredStructs) { declCount.set(n, (declCount.get(n) || 0) + 1); }
|
|
90
|
+
}
|
|
91
|
+
for (const def of scans) {
|
|
92
|
+
for (const root of structBuildRoots(def.code)) {
|
|
93
|
+
const rootAttrs: UiAttr[] = attrsWithArgs(def.code, root.paren);
|
|
94
|
+
const rootPad: UiAttr | undefined = lastPadding(rootAttrs);
|
|
95
|
+
if (rootPad === undefined) { continue; }
|
|
96
|
+
const inner: Sides = horizontalSides(rootPad.args);
|
|
97
|
+
if (inner.l === null || inner.r === null || (inner.l === 0 && inner.r === 0)) { continue; }
|
|
98
|
+
const rootAt: string = `${def.rel}:${lineOfIndex(def.code, rootPad.index ?? root.paren)}`;
|
|
99
|
+
const card: boolean = rootAttrs.some((a) => BOX_ATTRS.has(a.name));
|
|
100
|
+
const ambiguous: boolean = (declCount.get(root.struct) || 0) > 1;
|
|
101
|
+
const defAbs: string = path.resolve(def.abs);
|
|
102
|
+
for (const site of structCallSites(scans, root.struct)) {
|
|
103
|
+
const s: FileScan = site.scan;
|
|
104
|
+
const resolved: string = resolveStructFile(s, root.struct);
|
|
105
|
+
if (resolved !== '' && resolved !== defAbs) { continue; }
|
|
106
|
+
if (resolved === '' && ambiguous) { continue; }
|
|
107
|
+
const layers: { name: string; attrs: UiAttr[] }[] = [
|
|
108
|
+
{ name: `${root.struct}(…)`, attrs: attrsWithArgs(s.code, site.paren) },
|
|
109
|
+
];
|
|
110
|
+
for (const a of ancestorsOf(s.code, maskedOf(s), site.index)) {
|
|
111
|
+
if (a.kind !== 'comp') { break; }
|
|
112
|
+
if (SCROLLERS.has(a.name)) { break; }
|
|
113
|
+
layers.push({ name: a.name, attrs: a.attrs });
|
|
114
|
+
}
|
|
115
|
+
for (const layer of layers) {
|
|
116
|
+
const pad: UiAttr | undefined = lastPadding(layer.attrs);
|
|
117
|
+
if (pad === undefined || !sameInset(horizontalSides(pad.args), inner)) { continue; }
|
|
118
|
+
const line: number = lineOfIndex(s.code, pad.index ?? site.index);
|
|
119
|
+
const marked: boolean = markedAbove(s.src.split(/\r?\n/), line, 'INSET-STACKED');
|
|
120
|
+
if (card) {
|
|
121
|
+
report('CAND', 'inset-double-applied', s.rel, line,
|
|
122
|
+
`${layer.name} around ${root.struct} sets horizontal padding ${inner.l}/${inner.r}, the same as ${root.struct}'s ` +
|
|
123
|
+
`build() root (${rootAt}), which draws a box: usually a page gutter plus the card's content inset. ` +
|
|
124
|
+
'Confirm against the Android host layout that the host container has this padding');
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
report(marked ? 'CAND' : 'GATE', 'inset-double-applied', s.rel, line,
|
|
128
|
+
`${layer.name} around ${root.struct} sets horizontal padding ${inner.l}/${inner.r}, and ${root.struct}'s build() root ` +
|
|
129
|
+
`already sets the same ${inner.l}/${inner.r} (${rootAt}) — the inset is applied twice, so every child is ` +
|
|
130
|
+
`${inner.l + inner.r}vp narrower than on Android. The embedded layout's root padding belongs to the component: ` +
|
|
131
|
+
'drop it here and keep only what the host itself needs (e.g. a top offset). ' +
|
|
132
|
+
'When the Android host container really has the same padding too, write // INSET-STACKED: <host XML file:line> above it');
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// static_check/rules/int_division.ts — GATE java-int-division-not-truncated.
|
|
2
|
+
//
|
|
3
|
+
// Java / Kotlin `int / int` truncates; ArkTS `number / number` does not. An expression copied verbatim from the
|
|
4
|
+
// Android source therefore changes value. Measured in a chart component: the Java source
|
|
5
|
+
// `int dayIndex = i / 24 + 1; float x = dayIndex + (i % 24) / 24.0f - 0.5f;` was written as
|
|
6
|
+
// `(i / 24 + 1) + (i % 24) / 24 - 0.5`: the fraction of the day counts twice, x runs 0.5 → 1.0 → 1.5 → 2.0 → 1.5,
|
|
7
|
+
// and the cubic curve folds back on itself at every day.
|
|
8
|
+
//
|
|
9
|
+
// The rule only looks where the .ets says which Android lines it ports (`Foo.java:148-161`, `Foo.kt:30`), so it never
|
|
10
|
+
// guesses which TypeScript division corresponds to which Java one.
|
|
11
|
+
|
|
12
|
+
import * as path from 'path';
|
|
13
|
+
import { report } from '../core/findings.ts';
|
|
14
|
+
import { lineOfIndex, markedAbove } from '../core/parse.ts';
|
|
15
|
+
import { androidFiles } from '../core/android.ts';
|
|
16
|
+
import type { AndroidFile } from '../core/android.ts';
|
|
17
|
+
import type { FileScan } from '../core/scan.ts';
|
|
18
|
+
import type { RuleMeta } from '../core/meta.ts';
|
|
19
|
+
|
|
20
|
+
/** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
|
|
21
|
+
export const meta: RuleMeta[] = [
|
|
22
|
+
{
|
|
23
|
+
id: "java-int-division-not-truncated",
|
|
24
|
+
levels: ["GATE"],
|
|
25
|
+
invariant: "state",
|
|
26
|
+
card: "dynamics",
|
|
27
|
+
needs: ["--android"],
|
|
28
|
+
summary: "`.ets` 注释引用了 Android 源码行(`X.java:148-161` / `X.kt:30`),那几行里有一个两侧都是整数的除法(`int`/`long`/`Int`/`Long` 变量或整数字面量,例如 `i / 24`),而 `.ets` 在引用处之后的 25 行内把同一个表达式原样写成了 `i / 24`,没有用 `Math.trunc(...)` / `Math.floor(...)` 包起来。Java/Kotlin 的整数除法会截断,ArkTS 的 `/` 是浮点除法,值变了。",
|
|
29
|
+
fix: "整数除法写成 `Math.trunc(a / b)`(操作数可能为负时也和 Java 一致;只有非负时 `Math.floor` 也可以)。Android 侧本来就是浮点除法(有一侧是 `float`/`double` 或带 `.0f` 的字面量)时不受影响;变量其实是浮点、只是同名时,在该行上方写 `// INT-DIV-OK: <依据>`。",
|
|
30
|
+
escape: "// INT-DIV-OK:",
|
|
31
|
+
cases: [
|
|
32
|
+
"实测中发现:Java 源码的 `int dayIndex = i / 24 + 1` 被写成 `(i / 24 + 1) + (i % 24) / 24 - 0.5`;一天内的小数部分算了两次,x 依次为 0.5→1.0→1.5→2.0→1.5,曲线在每个整天处折返打圈。",
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
/** `Foo.java:148`, `Foo.kt:30-41`, `Foo.java:148–161` (en dash) as cited in .ets comments. */
|
|
38
|
+
const CITE: RegExp = /\b([A-Z][\w$]*\.(?:java|kt)):(\d+)(?:\s*[-–~]\s*:?(\d+))?/g;
|
|
39
|
+
/** Lines after the citation searched for the ported expression. */
|
|
40
|
+
const WINDOW: number = 25;
|
|
41
|
+
/** Longest cited range read (a citation of a whole file is no pointer to one expression). */
|
|
42
|
+
const MAX_RANGE: number = 60;
|
|
43
|
+
|
|
44
|
+
/** Names whose every declaration in the Android file is an integer type. */
|
|
45
|
+
export function intNames(src: string, kotlin: boolean): Set<string> {
|
|
46
|
+
const ints: Set<string> = new Set();
|
|
47
|
+
const others: Set<string> = new Set();
|
|
48
|
+
if (kotlin) {
|
|
49
|
+
for (const m of src.matchAll(/\b(?:val|var)\s+([a-z_][\w]*)\s*(?::\s*([A-Za-z?]+))?\s*(=\s*([^\n;]+))?/g)) {
|
|
50
|
+
const [, name, type, , init] = m;
|
|
51
|
+
if (type !== undefined) { (/^(Int|Long|Short|Byte)\??$/.test(type) ? ints : others).add(name); continue; }
|
|
52
|
+
// only a bare integer literal: `val alpha = 1 - progress` starts with `1` but is a Float
|
|
53
|
+
if (init !== undefined && /^-?\d+[lL]?$/.test(init.trim())) {
|
|
54
|
+
ints.add(name);
|
|
55
|
+
} else if (init !== undefined && /\.(size|length|count\(\))\s*$/.test(init.trim())) {
|
|
56
|
+
ints.add(name);
|
|
57
|
+
} else { others.add(name); }
|
|
58
|
+
}
|
|
59
|
+
for (const m of src.matchAll(/\bfor\s*\(\s*([a-z_][\w]*)\s+in\s+-?\d+\s*(?:\.\.|until|downTo)/g)) { ints.add(m[1]); }
|
|
60
|
+
// indices of collections
|
|
61
|
+
for (const m of src.matchAll(/\bfor\s*\(\s*([a-z_][\w]*)\s+in\s+[\w.]+\.indices\b/g)) { ints.add(m[1]); }
|
|
62
|
+
} else {
|
|
63
|
+
for (const m of src.matchAll(/\b(int|long|short|byte|float|double|var|Integer|Long|String|boolean|char|[A-Z][\w<>,\s?]*?)\s+([a-z_][\w]*)\s*(?=[=;,:)])/g)) {
|
|
64
|
+
const [, type, name] = m;
|
|
65
|
+
if (/^(if|return|new|else|case)$/.test(type)) { continue; }
|
|
66
|
+
(/^(int|long|short|byte|Integer|Long)$/.test(type) ? ints : others).add(name);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const n of others) { ints.delete(n); }
|
|
70
|
+
return ints;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** An integer operand: a known integer name, or an integer literal without a float suffix or decimal point. */
|
|
74
|
+
const INT_LIT: RegExp = /^\d+[lL]?$/;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* `a / b` divisions in `line` whose both operands are integers (simple names or literals only: a parenthesised or
|
|
78
|
+
* cast operand is left alone). Returns normalised `a / b` texts.
|
|
79
|
+
*/
|
|
80
|
+
export function intDivisions(line: string, ints: Set<string>): string[] {
|
|
81
|
+
const out: string[] = [];
|
|
82
|
+
const isInt = (t: string): boolean => INT_LIT.test(t) || ints.has(t);
|
|
83
|
+
for (const m of line.matchAll(/(?<![\w$.)\]])([A-Za-z_$][\w$]*|\d+(?:\.\d*)?[fFdDlL]?)\s*\/(?![/*=])\s*([A-Za-z_$][\w$]*|\d+(?:\.\d*)?[fFdDlL]?)(?![\w$.(\[])/g)) {
|
|
84
|
+
const [, a, b] = m;
|
|
85
|
+
// a cast right before the left operand (`(float) i / 24`) makes it floating
|
|
86
|
+
const before: string = line.slice(0, m.index ?? 0);
|
|
87
|
+
if (/\(\s*(float|double)\s*\)\s*$/.test(before) || /\.to(Float|Double)\(\)\s*$/.test(before)) { continue; }
|
|
88
|
+
// `*` `/` `%` associate left to right: in `1.5f * i / 24` the left operand of `/` is `1.5f * i`, not `i`
|
|
89
|
+
if (/[*/%]\s*$/.test(before)) { continue; }
|
|
90
|
+
if (isInt(a) && isInt(b)) { out.push(`${a.replace(/[lL]$/, '')} / ${b.replace(/[lL]$/, '')}`); }
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Whether the division at `idx` in `code` sits inside `Math.trunc(` / `Math.floor(` (any enclosing level). */
|
|
96
|
+
function truncated(code: string, idx: number): boolean {
|
|
97
|
+
let depth: number = 0;
|
|
98
|
+
for (let i = idx - 1; i >= 0 && i > idx - 400; i--) {
|
|
99
|
+
const c: string = code[i];
|
|
100
|
+
if (c === ')') { depth++; } else if (c === '(') {
|
|
101
|
+
if (depth === 0) {
|
|
102
|
+
if (/Math\.(trunc|floor)\s*$/.test(code.slice(Math.max(0, i - 12), i))) { return true; }
|
|
103
|
+
// keep walking out through the next enclosing paren
|
|
104
|
+
} else { depth--; }
|
|
105
|
+
} else if (c === ';' || c === '{' || c === '}') { break; }
|
|
106
|
+
}
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* GATE java-int-division-not-truncated: an integer division of the Android lines a .ets comment cites is written as a
|
|
112
|
+
* plain `/` in the .ets lines that follow the citation.
|
|
113
|
+
*/
|
|
114
|
+
export function checkJavaIntDivision(scans: FileScan[], androidDir: string): void {
|
|
115
|
+
if (androidDir === '') { return; }
|
|
116
|
+
let files: AndroidFile[] | null = null;
|
|
117
|
+
const byName = (n: string): AndroidFile[] => {
|
|
118
|
+
files = files ?? androidFiles(androidDir);
|
|
119
|
+
return files.filter((f) => f.name === n);
|
|
120
|
+
};
|
|
121
|
+
const intCache: Map<string, Set<string>> = new Map();
|
|
122
|
+
for (const s of scans) {
|
|
123
|
+
const rawLines: string[] = s.src.split(/\r?\n/);
|
|
124
|
+
const seen: Set<string> = new Set();
|
|
125
|
+
rawLines.forEach((raw, li) => {
|
|
126
|
+
for (const c of raw.matchAll(CITE)) {
|
|
127
|
+
const [, name, fromS, toS] = c;
|
|
128
|
+
const cands: AndroidFile[] = byName(name);
|
|
129
|
+
if (cands.length !== 1) { continue; } // ambiguous or absent: no guess
|
|
130
|
+
const af: AndroidFile = cands[0];
|
|
131
|
+
const from: number = Number(fromS);
|
|
132
|
+
const to: number = Math.min(toS === undefined ? from : Number(toS), from + MAX_RANGE);
|
|
133
|
+
const asrc: string = af.read();
|
|
134
|
+
if (asrc === '') { continue; }
|
|
135
|
+
let ints: Set<string> | undefined = intCache.get(af.rel);
|
|
136
|
+
if (ints === undefined) { ints = intNames(asrc, path.extname(name) === '.kt'); intCache.set(af.rel, ints); }
|
|
137
|
+
const alines: string[] = asrc.split(/\r?\n/);
|
|
138
|
+
const divs: Set<string> = new Set();
|
|
139
|
+
for (let k = from - 1; k < Math.min(alines.length, to); k++) {
|
|
140
|
+
const code: string = alines[k].replace(/\/\/.*$/, '');
|
|
141
|
+
for (const d of intDivisions(code, ints)) { divs.add(d); }
|
|
142
|
+
}
|
|
143
|
+
if (divs.size === 0) { continue; }
|
|
144
|
+
// The ported expression: same operands, plain `/`, within WINDOW lines from the citation (comments stripped).
|
|
145
|
+
const winStart: number = lineStartIndex(s.code, li + 1);
|
|
146
|
+
const winEnd: number = lineStartIndex(s.code, li + 1 + WINDOW);
|
|
147
|
+
const win: string = s.code.slice(winStart, winEnd);
|
|
148
|
+
for (const d of divs) {
|
|
149
|
+
const [a, b] = d.split(' / ');
|
|
150
|
+
const re: RegExp = new RegExp(`(?<![\\w$.])${esc(a)}\\s*\\/(?![/*=])\\s*${esc(b)}(?![\\w$.(\\[])`, 'g');
|
|
151
|
+
for (const hit of win.matchAll(re)) {
|
|
152
|
+
const at: number = winStart + (hit.index ?? 0);
|
|
153
|
+
if (truncated(s.code, at)) { continue; }
|
|
154
|
+
const line: number = lineOfIndex(s.code, at);
|
|
155
|
+
const key: string = `${line}|${d}`;
|
|
156
|
+
if (seen.has(key) || markedAbove(rawLines, line, 'INT-DIV-OK')) { continue; }
|
|
157
|
+
seen.add(key);
|
|
158
|
+
report('GATE', 'java-int-division-not-truncated', s.rel, line,
|
|
159
|
+
`\`${d}\` is an integer division in ${af.rel}:${from}${to !== from ? `-${to}` : ''} (both operands are ` +
|
|
160
|
+
`integers there, so Java/Kotlin truncate it), but here it is a plain \`/\`, which ArkTS evaluates as a ` +
|
|
161
|
+
`floating-point division — the value changes. Write Math.trunc(${a} / ${b}). If the Android operand is not ` +
|
|
162
|
+
'really an integer, write // INT-DIV-OK: <basis> above it');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const esc = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
171
|
+
|
|
172
|
+
/** Code index of the start of 1-based line `line` (code.length past the end). */
|
|
173
|
+
function lineStartIndex(code: string, line: number): number {
|
|
174
|
+
let idx: number = 0;
|
|
175
|
+
for (let l = 1; l < line; l++) {
|
|
176
|
+
const nl: number = code.indexOf('\n', idx);
|
|
177
|
+
if (nl < 0) { return code.length; }
|
|
178
|
+
idx = nl + 1;
|
|
179
|
+
}
|
|
180
|
+
return idx;
|
|
181
|
+
}
|
|
@@ -29,8 +29,8 @@ export const meta: RuleMeta[] = [
|
|
|
29
29
|
invariant: "geometry",
|
|
30
30
|
card: "alignment",
|
|
31
31
|
needs: [],
|
|
32
|
-
summary: "`Stack` 未设 alignContent,子节点靠自身 `.align()`
|
|
33
|
-
fix: "
|
|
32
|
+
summary: "`Stack` 未设 alignContent(默认 Center),子节点靠自身 `.align()` 贴底/贴边,而它在那条轴上包裹内容;或 `Stack` 设了**显式非 Center** 的 alignContent,而子节点 `.align(Y)` 的方向与之**冲突**(子节点仍被放到 Stack 的 alignContent 处,不是 Y)。",
|
|
33
|
+
fix: "`.align()` 只排子节点自己的内容,不决定它在 Stack 中的位置 —— 子节点一律被放到 Stack 的 alignContent 处。要让子节点贴某条边:把 Stack 的 alignContent 设成该方向(其他依赖原对齐的子节点包进撑满容器),或先让子节点在该轴 `'100%'` 再用 `.align` 排内容。",
|
|
34
34
|
escape: null,
|
|
35
35
|
cases: [
|
|
36
36
|
"[where2study3] 设置页 `Stack()`(默认 alignContent=Center)里给导航外层 Column 写 `.align(Alignment.Bottom)`,`.align` 只排 Column 自己的内容、不决定它在 Stack 中的位置 —— 底部导航悬在屏幕中部",
|
|
@@ -372,6 +372,66 @@ export function checkLayoutPlacement(code: string, rel: string, rawLines: string
|
|
|
372
372
|
// The overlay / child-align-noop rules below hold for it equally; the bar rule only targets Box's default TopStart translated into a bare Stack(),
|
|
373
373
|
// and an explicit Center is intentional centering, not reported.
|
|
374
374
|
const explicitCenter: boolean = hasAlign && alignM !== null && alignM[1] === 'Alignment.Center';
|
|
375
|
+
|
|
376
|
+
// ---- GATE/CAND stack-child-align-noop for a Stack WITH an explicit (non-Center) alignContent
|
|
377
|
+
//
|
|
378
|
+
// The child is placed by the Stack's alignContent, never by its own .align(); flag a child whose .align(Y) asks
|
|
379
|
+
// for a different edge than the Stack's alignContent, so it does not end up where .align(Y) suggests (CoolMall
|
|
380
|
+
// goods-detail bottom bar: Stack alignContent TopStart, bar .align(Alignment.Bottom) → ends up top-left).
|
|
381
|
+
// Additive: this only runs for Stacks that the `continue` below would otherwise skip, so it changes no existing finding.
|
|
382
|
+
if (hasAlign && !explicitCenter && alignM !== null) {
|
|
383
|
+
const sv: string = /Top/.test(alignM[1]) ? 'Top' : /Bottom/.test(alignM[1]) ? 'Bottom' : 'Center';
|
|
384
|
+
const sh: string = /Start/.test(alignM[1]) ? 'Start' : /End/.test(alignM[1]) ? 'End' : 'Center';
|
|
385
|
+
// Children inside if / else branches count too (a bottom bar shown only in the SUCCESS state is still mis-anchored).
|
|
386
|
+
const alignKids: UiChild[] = directUiChildren(code, k, bodyClose, undefined, { intoBranches: true })
|
|
387
|
+
.filter((c) => c.control !== true);
|
|
388
|
+
for (const c of alignKids) {
|
|
389
|
+
const a: UiAttr[] = attrsOf(c);
|
|
390
|
+
const al: UiAttr | undefined = a.find((x) => x.name === 'align');
|
|
391
|
+
if (al === undefined || /Alignment\.Center\b/.test(al.args)) { continue; }
|
|
392
|
+
if (['Scroll', 'List', 'Grid', 'WaterFlow'].includes(c.name)) { continue; }
|
|
393
|
+
// Absolute placement (position / markAnchor / alignRules) genuinely places the child, so .align is moot and the child is where it is put — skip.
|
|
394
|
+
// A relative delta (offset / translate) only shifts the child from its alignContent-anchored position, so it does NOT fix the .align no-op; keep it, but as CAND (the delta's magnitude is unknown).
|
|
395
|
+
if (['position', 'markAnchor', 'alignRules'].some((n) => hasAttr(a, n))) { continue; }
|
|
396
|
+
const relDelta: boolean = hasAttr(a, 'offset') || hasAttr(a, 'translate');
|
|
397
|
+
const needV: boolean = /Top|Bottom/.test(al.args);
|
|
398
|
+
const needH: boolean = /Start|End/.test(al.args);
|
|
399
|
+
const childV: string = /Top/.test(al.args) ? 'Top' : /Bottom/.test(al.args) ? 'Bottom' : 'Center';
|
|
400
|
+
const childH: string = /Start/.test(al.args) ? 'Start' : /End/.test(al.args) ? 'End' : 'Center';
|
|
401
|
+
// Only a conflict when the Stack is EXPLICITLY non-Center on that axis: if the Stack's alignContent leaves an
|
|
402
|
+
// axis at Center (e.g. alignContent Bottom sets vertical only), a child's .align() on the other axis is the
|
|
403
|
+
// same ambiguous case the default-Center path already governs, and stays out of scope here.
|
|
404
|
+
const conflictV: boolean = needV && sv !== 'Center' && childV !== sv;
|
|
405
|
+
const conflictH: boolean = needH && sh !== 'Center' && childH !== sh;
|
|
406
|
+
if (!conflictV && !conflictH) { continue; }
|
|
407
|
+
// The axis size from .width()/.height(), or from the matching field of .size({ width, height }).
|
|
408
|
+
const dim = (n: string): string | null => {
|
|
409
|
+
const x: UiAttr | undefined = a.find((y) => y.name === n);
|
|
410
|
+
if (x !== undefined) { return x.args; }
|
|
411
|
+
const sz: UiAttr | undefined = a.find((y) => y.name === 'size');
|
|
412
|
+
const f: RegExpExecArray | null = sz === undefined ? null : new RegExp(`\\b${n}\\s*:\\s*([^,}]+)`).exec(sz.args);
|
|
413
|
+
return f === null ? null : f[1].trim();
|
|
414
|
+
};
|
|
415
|
+
const h: string | null = dim('height');
|
|
416
|
+
const w: string | null = dim('width');
|
|
417
|
+
const wraps: boolean = (conflictV && h === null) || (conflictH && w === null);
|
|
418
|
+
const notFull: boolean = (conflictV && h !== null && !RE_PCT_FULL_ARG.test(h)) ||
|
|
419
|
+
(conflictH && w !== null && !RE_PCT_FULL_ARG.test(w));
|
|
420
|
+
const msg: string = `Stack alignContent is ${alignM[1]}, and child ${c.name} sets .align(${al.args.trim()}) — ` +
|
|
421
|
+
'.align() only arranges that child\'s own content and does not decide its position in the Stack, so the child is placed at the Stack\'s alignContent, not where .align() asks. ' +
|
|
422
|
+
(relDelta ? 'A .offset()/.translate() on it only shifts it from that anchored position (it does not re-anchor to the edge). ' : '') +
|
|
423
|
+
`To hug ${al.args.trim()}: set the Stack's alignContent to it (wrap other children that rely on the current alignment in a full-size container), or first make the child fill that axis ('100%') and then arrange its content with .align`;
|
|
424
|
+
// A custom component's size comes from its own build() root, so "no size at the call site" does not prove it wraps: CAND.
|
|
425
|
+
const custom: boolean = !c.isBuilderCall && /^[A-Z]/.test(c.name) && !BUILTIN_KINDS.has(c.name);
|
|
426
|
+
if (wraps && !relDelta && !custom) {
|
|
427
|
+
report('GATE', 'stack-child-align-noop', rel, lineOfIndex(code, c.at), msg);
|
|
428
|
+
} else if (wraps || notFull) {
|
|
429
|
+
report('CAND', 'stack-child-align-noop', rel, lineOfIndex(code, c.at),
|
|
430
|
+
custom && wraps ? `${msg} (${c.name} is a custom component: its size comes from its build() root, check whether it fills that axis)` : msg);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
375
435
|
if (hasAlign && !explicitCenter) { continue; }
|
|
376
436
|
const centerWhy: string = explicitCenter ? 'Stack alignment is Center' : 'Stack has no alignContent (default Center)';
|
|
377
437
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// static_check/rules/lottie_path.ts — GATE lottie-path-not-ets.
|
|
2
|
+
//
|
|
3
|
+
// @ohos/lottie's `path` option is read with context2D.getJsonData(path) (DataManager.js loadAsset), which only resolves
|
|
4
|
+
// files under the module's ets/ directory (README: "path 参数只支持加载 entry/src/main/ets 文件夹下的相对路径"). The
|
|
5
|
+
// resource converter puts Lottie JSON in rawfile/lottie/, so `path: 'lottie/x.json'` reads nothing: the library fires
|
|
6
|
+
// data_failed and logs "Lottie: the path has no data", the canvas stays blank, and build + smoke still pass. Rawfile JSON
|
|
7
|
+
// must be read with resourceManager.getRawFileContentSync and passed as `animationData`.
|
|
8
|
+
|
|
9
|
+
import * as fs from 'fs';
|
|
10
|
+
import * as path from 'path';
|
|
11
|
+
import { report } from '../core/findings.ts';
|
|
12
|
+
import { lineOfIndex, markedAbove, matchBracket, splitTopLevel } from '../core/parse.ts';
|
|
13
|
+
import type { FileCtx } from '../core/scan.ts';
|
|
14
|
+
import type { RuleMeta } from '../core/meta.ts';
|
|
15
|
+
|
|
16
|
+
/** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
|
|
17
|
+
export const meta: RuleMeta[] = [
|
|
18
|
+
{
|
|
19
|
+
id: "lottie-path-not-ets",
|
|
20
|
+
levels: ["GATE", "CAND"],
|
|
21
|
+
invariant: "resources",
|
|
22
|
+
card: "resources",
|
|
23
|
+
needs: [],
|
|
24
|
+
summary: "`@ohos/lottie` 的 `loadAnimation({ … })` 选项写了 `path`,而它不是指向本模块 `ets/` 下实际存在文件的字符串字面量 —— `path` 只读 `ets/` 目录,父 skill 把动画 JSON 放在 `rawfile/lottie/`,读不到数据时只触发 `data_failed`,动画空白。",
|
|
25
|
+
fix: "按 `references/lottie-integration.md` 4.5.2:用 `this.getUIContext().getHostContext()!.resourceManager.getRawFileContentSync('lottie/<name>.json')` 读出字节,`new util.TextDecoder('utf-8', { ignoreBOM: true }).decodeToString(bytes)` 解码,`JSON.parse` 后传给 `animationData`,删掉 `path`。JSON 确实放在 `ets/` 下且路径由变量传入时,在该行上方写 `// LOTTIE-PATH: <依据>` 降为 CAND。",
|
|
26
|
+
escape: "// LOTTIE-PATH:",
|
|
27
|
+
cases: [
|
|
28
|
+
"实测(电商应用底部导航):四个页签 Lottie 的 JSON 在 `rawfile/lottie/`,代码写 `path: destination.lottiePath`('lottie/home.json'),四个图标全部空白;Main 页无参考截图,编译、GATE、冒烟全过。",
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
/** The module's ets/ root for a file under `<module>/src/main/ets/…`, or '' when the file is not under such a root. */
|
|
34
|
+
function etsRootOf(file: string): string {
|
|
35
|
+
const norm: string = file.replace(/\\/g, '/');
|
|
36
|
+
const at: number = norm.lastIndexOf('/src/main/ets/');
|
|
37
|
+
return at < 0 ? '' : norm.slice(0, at + '/src/main/ets'.length);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* GATE lottie-path-not-ets: a loadAnimation() whose literal options set `path` to anything but a string literal naming a
|
|
42
|
+
* file that exists under this module's ets/ root. A non-literal value (a variable / field) is reported too: the JSON the
|
|
43
|
+
* skill ships lives in rawfile/, which `path` cannot read. `// LOTTIE-PATH: <basis>` above the call downgrades to CAND.
|
|
44
|
+
*/
|
|
45
|
+
export function checkLottiePath(fctx: FileCtx): void {
|
|
46
|
+
const { file, rel, code, rawLines } = fctx;
|
|
47
|
+
if (!/\bloadAnimation\s*\(/.test(code)) { return; }
|
|
48
|
+
const root: string = etsRootOf(file);
|
|
49
|
+
for (const m of code.matchAll(/\bloadAnimation\s*\(/g)) {
|
|
50
|
+
const open: number = (m.index ?? 0) + m[0].length - 1;
|
|
51
|
+
const close: number = matchBracket(code, open);
|
|
52
|
+
if (close < 0) { continue; }
|
|
53
|
+
const opt: string = (splitTopLevel(code.slice(open + 1, close))[0] ?? '').trim();
|
|
54
|
+
if (!opt.startsWith('{') || !opt.endsWith('}')) { continue; }
|
|
55
|
+
let value: string | undefined;
|
|
56
|
+
for (const e of splitTopLevel(opt.slice(1, -1))) {
|
|
57
|
+
const kv: RegExpExecArray | null = /^\s*path\s*:\s*([\s\S]*?)\s*$/.exec(e);
|
|
58
|
+
if (kv !== null) { value = kv[1]; }
|
|
59
|
+
}
|
|
60
|
+
if (value === undefined) { continue; }
|
|
61
|
+
const lit: RegExpExecArray | null = /^(['"])([^'"]*)\1$/.exec(value);
|
|
62
|
+
if (lit !== null && root !== '' && fs.existsSync(path.join(root, lit[2]))) { continue; }
|
|
63
|
+
const line: number = lineOfIndex(code, m.index ?? 0);
|
|
64
|
+
const what: string = lit !== null
|
|
65
|
+
? `path: ${value} does not name a file under this module's ets/ (${lit[2]} not found there)`
|
|
66
|
+
: `path: ${value} is not a literal, and the Lottie JSON the resource step ships lives in rawfile/lottie/`;
|
|
67
|
+
if (markedAbove(rawLines, line, 'LOTTIE-PATH')) {
|
|
68
|
+
report('CAND', 'lottie-path-not-ets', rel, line, `${what}; marked LOTTIE-PATH — confirm the JSON really sits under ets/`);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
report('GATE', 'lottie-path-not-ets', rel, line,
|
|
72
|
+
`${what}. @ohos/lottie reads \`path\` only from the module's ets/ directory; a rawfile JSON yields no data, ` +
|
|
73
|
+
'fires data_failed and the animation stays blank. Read it with getHostContext()!.resourceManager.getRawFileContentSync(' +
|
|
74
|
+
"'lottie/<name>.json'), decode with util.TextDecoder, JSON.parse, and pass it as animationData (lottie-integration.md 4.5.2). " +
|
|
75
|
+
'If the JSON really is under ets/ and the path comes from a variable, write // LOTTIE-PATH: <basis> above the call');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// static_check/rules/lottie_ready.ts — GATE lottie-load-before-canvas-ready.
|
|
2
|
+
//
|
|
3
|
+
// @ohos/lottie draws into a CanvasRenderingContext2D. That context is only attached once the Canvas component is laid
|
|
4
|
+
// out, which the Canvas reports through its .onReady() callback. aboutToAppear() / aboutToBuild() run BEFORE build(),
|
|
5
|
+
// so the Canvas does not exist yet: a loadAnimation() called there paints into an unready context and the animation is
|
|
6
|
+
// blank (CoolMall bottom-nav tab icons: loadAnimation in aboutToAppear → icons never show).
|
|
7
|
+
|
|
8
|
+
import { report } from '../core/findings.ts';
|
|
9
|
+
import { lineOfIndex, markedAbove, maskStrings, matchBracket } from '../core/parse.ts';
|
|
10
|
+
import type { FileCtx } from '../core/scan.ts';
|
|
11
|
+
import type { RuleMeta } from '../core/meta.ts';
|
|
12
|
+
|
|
13
|
+
/** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
|
|
14
|
+
export const meta: RuleMeta[] = [
|
|
15
|
+
{
|
|
16
|
+
id: "lottie-load-before-canvas-ready",
|
|
17
|
+
levels: ["GATE", "CAND"],
|
|
18
|
+
invariant: "resources",
|
|
19
|
+
card: "resources",
|
|
20
|
+
needs: [],
|
|
21
|
+
summary: "文件里有 `Canvas(`,而 `@ohos/lottie` 的 `loadAnimation(` 写在 `aboutToAppear()` / `aboutToBuild()` 里 —— 这些生命周期在 `build()` 之前执行,Canvas 渲染上下文尚未就绪,动画画到空上下文上、不显示。",
|
|
22
|
+
fix: "把 `lottie.loadAnimation({ container: this.canvasContext, … })` 移进 `Canvas(this.canvasContext).onReady(() => { … })` 回调里(onReady 在 Canvas 完成布局、上下文可用后触发);销毁仍放 `aboutToDisappear` + `Canvas.onDisAppear`。确有依据时在该行上方写 `// LOTTIE-READY: <依据>` 降为 CAND。",
|
|
23
|
+
escape: "// LOTTIE-READY:",
|
|
24
|
+
cases: [
|
|
25
|
+
"实测(CoolMall 底部导航 BottomNavigationBar.ets):`TabLottieAnimation.aboutToAppear()` 里 `lottie.loadAnimation({ container: this.canvasContext, … })`,Canvas 未就绪 → 四个 tab 图标全部空白;编译、GATE、冒烟全过。",
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The `{ … }` body ranges of `name()` lifecycle methods (aboutToAppear / aboutToBuild) in code, with or without `async`
|
|
32
|
+
* and with any return annotation (`: void`, `: Promise<void>`).
|
|
33
|
+
*/
|
|
34
|
+
function lifecycleBodies(code: string, name: string): [number, number][] {
|
|
35
|
+
const out: [number, number][] = [];
|
|
36
|
+
const re: RegExp = new RegExp(`\\b${name}\\s*\\(\\s*\\)\\s*(?::[^{;]*)?\\{`, 'g');
|
|
37
|
+
let m: RegExpExecArray | null;
|
|
38
|
+
while ((m = re.exec(code)) !== null) {
|
|
39
|
+
const open: number = m.index + m[0].length - 1;
|
|
40
|
+
const close: number = matchBracket(code, open);
|
|
41
|
+
if (close > open) { out.push([open, close]); }
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Whether the call at `at` runs later than the lifecycle body that contains it (body `{` at `open`): it sits inside call
|
|
48
|
+
* arguments (`setTimeout(() => …)`, `.then(…)`), inside a function body (`() => { … }`, `function () { … }`), or after an
|
|
49
|
+
* expression-bodied arrow in its own statement (`this.load = () => lottie.loadAnimation(…)`). Plain control blocks
|
|
50
|
+
* (if / for / try / else) run in place and do not count. masked: strings and comments neutralised.
|
|
51
|
+
*/
|
|
52
|
+
function deferredIn(masked: string, open: number, at: number): boolean {
|
|
53
|
+
const stack: number[] = [];
|
|
54
|
+
for (let i = open + 1; i < at; i++) {
|
|
55
|
+
const c: string = masked[i];
|
|
56
|
+
if (c === '(' || c === '{' || c === '[') { stack.push(i); } else if (c === ')' || c === '}' || c === ']') { stack.pop(); }
|
|
57
|
+
}
|
|
58
|
+
for (const o of stack) {
|
|
59
|
+
if (masked[o] !== '{') { return true; } // inside a call's arguments / an array
|
|
60
|
+
const before: string = masked.slice(Math.max(open, o - 200), o).trimEnd();
|
|
61
|
+
if (before.endsWith('=>')) { return true; } // arrow function body
|
|
62
|
+
if (before.endsWith(')') && /\bfunction\s*[\w$]*\s*\([^()]*\)$/.test(before)) { return true; }
|
|
63
|
+
}
|
|
64
|
+
// Expression-bodied arrow in the same statement: scan back to the statement start at the call's own depth.
|
|
65
|
+
const from: number = stack.length > 0 ? stack[stack.length - 1] : open;
|
|
66
|
+
let s: number = at - 1;
|
|
67
|
+
let depth: number = 0;
|
|
68
|
+
for (; s > from; s--) {
|
|
69
|
+
const c: string = masked[s];
|
|
70
|
+
if (c === ')' || c === '}' || c === ']') { depth++; } else if (c === '(' || c === '{' || c === '[') { depth--; } else if (c === ';' && depth === 0) { break; }
|
|
71
|
+
}
|
|
72
|
+
return masked.slice(s + 1, at).includes('=>');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* GATE lottie-load-before-canvas-ready: a loadAnimation() call sits inside aboutToAppear()/aboutToBuild() of a file that
|
|
77
|
+
* draws a Canvas. The call must move into the Canvas's .onReady() callback, which fires after the rendering context is
|
|
78
|
+
* attached. `// LOTTIE-READY: <basis>` above the call downgrades it to CAND.
|
|
79
|
+
*/
|
|
80
|
+
export function checkLottieReady(fctx: FileCtx): void {
|
|
81
|
+
const { rel, code, rawLines } = fctx;
|
|
82
|
+
if (!/\bloadAnimation\s*\(/.test(code) || !/\bCanvas\s*\(/.test(code)) { return; }
|
|
83
|
+
const bodies: [number, number][] = [...lifecycleBodies(code, 'aboutToAppear'), ...lifecycleBodies(code, 'aboutToBuild')];
|
|
84
|
+
if (bodies.length === 0) { return; }
|
|
85
|
+
const masked: string = maskStrings(code);
|
|
86
|
+
for (const m of code.matchAll(/\bloadAnimation\s*\(/g)) {
|
|
87
|
+
const at: number = m.index ?? 0;
|
|
88
|
+
const body: [number, number] | undefined = bodies.find(([o, c]) => at > o && at < c);
|
|
89
|
+
if (body === undefined) { continue; }
|
|
90
|
+
const line: number = lineOfIndex(code, at);
|
|
91
|
+
if (markedAbove(rawLines, line, 'LOTTIE-READY')) {
|
|
92
|
+
report('CAND', 'lottie-load-before-canvas-ready', rel, line,
|
|
93
|
+
'loadAnimation() in aboutToAppear/aboutToBuild; marked LOTTIE-READY — confirm the Canvas context is ready at that point');
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (deferredIn(masked, body[0], at)) {
|
|
97
|
+
report('CAND', 'lottie-load-before-canvas-ready', rel, line,
|
|
98
|
+
'loadAnimation() sits inside a closure / callback within aboutToAppear/aboutToBuild — it runs only when that function is called, ' +
|
|
99
|
+
'so whether the Canvas context is ready then cannot be told statically. Confirm it is called from Canvas.onReady (or after it), ' +
|
|
100
|
+
'otherwise move loadAnimation into Canvas(this.canvasContext).onReady(() => { … })');
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
report('GATE', 'lottie-load-before-canvas-ready', rel, line,
|
|
104
|
+
'lottie.loadAnimation() is called inside aboutToAppear/aboutToBuild, which run before build(): the Canvas rendering ' +
|
|
105
|
+
'context is not attached yet, so the animation paints into an unready context and shows blank. Move loadAnimation into ' +
|
|
106
|
+
'Canvas(this.canvasContext).onReady(() => { … }) (it fires once the context is ready); keep destroy in aboutToDisappear / Canvas.onDisAppear. ' +
|
|
107
|
+
'If there is a real reason, write // LOTTIE-READY: <basis> above it');
|
|
108
|
+
}
|
|
109
|
+
}
|