@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,570 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* @hometrans/route-page-side-effect-import
|
|
5
|
+
*
|
|
6
|
+
* A HAR/HSP route page declared with `@Entry({ routeName })` only enters the named-route
|
|
7
|
+
* table when the HAP that consumes it actually compiles the page module. A named (value)
|
|
8
|
+
* import whose symbol is never referenced is tree-shaken away, so the page never reaches
|
|
9
|
+
* ets/modules.abc and `router.pushNamedRoute` / `replaceNamedRoute` throws 100004 at
|
|
10
|
+
* runtime (the splash page then stays on screen).
|
|
11
|
+
*
|
|
12
|
+
* Rule: for every route page declared in a library module (module.json5 type har/shared)
|
|
13
|
+
* that is reachable from an entry/feature HAP, that HAP's module graph must contain a
|
|
14
|
+
* side-effect import (`import '<pkg>/src/main/ets/pages/<Page>';`) resolving to the page
|
|
15
|
+
* file. A value/barrel import does not count: evaluating a re-export barrel does not
|
|
16
|
+
* evaluate the page module, and an unreferenced binding is removed by tree shaking.
|
|
17
|
+
*
|
|
18
|
+
* Scope/assumptions (documented in document/checker/hometrans/route-page-side-effect-import-*.md):
|
|
19
|
+
* - Only pages in modules whose module.json5 `type` is `har` / `shared` / `hsp` are graded;
|
|
20
|
+
* a route page owned by the HAP itself is out of scope.
|
|
21
|
+
* - A page is graded only when some entry/feature HAP can reach its library through the
|
|
22
|
+
* oh-package dependency graph or the project's import graph; an orphan library is silent.
|
|
23
|
+
* - Import specifiers are resolved through oh-package.json5 `name` (package subpaths) and
|
|
24
|
+
* relative paths; unresolved specifiers stay silent (never a guess).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const fs = require('fs');
|
|
28
|
+
const path = require('path');
|
|
29
|
+
|
|
30
|
+
const hc = require(process.env.HOMECHECK_MODULE_PATH || 'homecheck');
|
|
31
|
+
const { GlobalChecker, Rule, AlertLevel } = hc;
|
|
32
|
+
|
|
33
|
+
const RULE_ID = '@hometrans/route-page-side-effect-import';
|
|
34
|
+
const PACKAGE_FILE = 'oh-package.json5';
|
|
35
|
+
const MODULE_FILE = 'module.json5';
|
|
36
|
+
const APP_SCOPE_DIR = 'AppScope';
|
|
37
|
+
const MAX_PARENT_HOPS = 16;
|
|
38
|
+
const MAX_PACKAGE_HOPS = 5;
|
|
39
|
+
const MAX_WALK_DEPTH = 8;
|
|
40
|
+
const MAX_WALKED_FILES = 20000;
|
|
41
|
+
const SKIP_DIRS = new Set([
|
|
42
|
+
'node_modules', 'oh_modules', 'build', '.hvigor', '.hometrans', '.git',
|
|
43
|
+
'ohosSdk', 'hmsSdk', '.idea', '.gradle', '.tmp',
|
|
44
|
+
]);
|
|
45
|
+
const LIBRARY_TYPES = new Set(['har', 'shared', 'hsp']);
|
|
46
|
+
const HAP_TYPES = new Set(['entry', 'feature']);
|
|
47
|
+
|
|
48
|
+
function safe(fn, fallback) {
|
|
49
|
+
try {
|
|
50
|
+
return fn();
|
|
51
|
+
} catch (_err) {
|
|
52
|
+
return fallback;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** ohosTest / test HAPs share the library package name and are not real consumers. */
|
|
57
|
+
function isTestModuleFile(filePath) {
|
|
58
|
+
const p = String(filePath || '').replace(/\\/g, '/');
|
|
59
|
+
return /\/src\/ohosTest\//.test(p) || /\/src\/test\//.test(p);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function isGeneratedFile(filePath) {
|
|
63
|
+
const p = String(filePath || '').replace(/\\/g, '/');
|
|
64
|
+
return /\/oh_modules\//.test(p) || /\/node_modules\//.test(p) ||
|
|
65
|
+
/\/build\//.test(p) || /\.d\.ts$/i.test(p) ||
|
|
66
|
+
/\/(ohosSdk|hmsSdk)\//.test(p);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Strip JSON5 comments/trailing commas, then JSON.parse. */
|
|
70
|
+
function parseJson5(text) {
|
|
71
|
+
let out = '';
|
|
72
|
+
let i = 0;
|
|
73
|
+
let inString = false;
|
|
74
|
+
let quote = '';
|
|
75
|
+
while (i < text.length) {
|
|
76
|
+
const c = text[i];
|
|
77
|
+
const n = text[i + 1];
|
|
78
|
+
if (inString) {
|
|
79
|
+
out += c;
|
|
80
|
+
if (c === '\\' && n !== undefined) {
|
|
81
|
+
out += n;
|
|
82
|
+
i += 2;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
if (c === quote) inString = false;
|
|
86
|
+
i += 1;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (c === '"' || c === "'") {
|
|
90
|
+
inString = true;
|
|
91
|
+
quote = c;
|
|
92
|
+
out += c;
|
|
93
|
+
i += 1;
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (c === '/' && n === '/') {
|
|
97
|
+
while (i < text.length && text[i] !== '\n') i += 1;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
if (c === '/' && n === '*') {
|
|
101
|
+
i += 2;
|
|
102
|
+
while (i < text.length && !(text[i] === '*' && text[i + 1] === '/')) i += 1;
|
|
103
|
+
i += 2;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
out += c;
|
|
107
|
+
i += 1;
|
|
108
|
+
}
|
|
109
|
+
return JSON.parse(out.replace(/,\s*([}\]])/g, '$1'));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** Replace comment contents with spaces (length-preserving, string-safe). */
|
|
113
|
+
function stripComments(code) {
|
|
114
|
+
let out = '';
|
|
115
|
+
let i = 0;
|
|
116
|
+
let q = '';
|
|
117
|
+
while (i < code.length) {
|
|
118
|
+
const c = code[i];
|
|
119
|
+
const n = code[i + 1];
|
|
120
|
+
if (q !== '') {
|
|
121
|
+
out += c;
|
|
122
|
+
if (c === '\\' && n !== undefined) {
|
|
123
|
+
out += n;
|
|
124
|
+
i += 2;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (c === q) q = '';
|
|
128
|
+
i += 1;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
if (c === '"' || c === "'" || c === '`') {
|
|
132
|
+
q = c;
|
|
133
|
+
out += c;
|
|
134
|
+
i += 1;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (c === '/' && n === '/') {
|
|
138
|
+
while (i < code.length && code[i] !== '\n') { out += ' '; i += 1; }
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (c === '/' && n === '*') {
|
|
142
|
+
out += ' ';
|
|
143
|
+
i += 2;
|
|
144
|
+
while (i < code.length && !(code[i] === '*' && code[i + 1] === '/')) {
|
|
145
|
+
out += code[i] === '\n' ? '\n' : ' ';
|
|
146
|
+
i += 1;
|
|
147
|
+
}
|
|
148
|
+
if (i < code.length) { out += ' '; i += 2; }
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
out += c;
|
|
152
|
+
i += 1;
|
|
153
|
+
}
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function lineOf(code, index) {
|
|
158
|
+
let line = 1;
|
|
159
|
+
const end = Math.min(index, code.length);
|
|
160
|
+
for (let i = 0; i < end; i += 1) {
|
|
161
|
+
if (code[i] === '\n') line += 1;
|
|
162
|
+
}
|
|
163
|
+
return line;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function findCloseParen(code, open) {
|
|
167
|
+
let depth = 0;
|
|
168
|
+
let q = '';
|
|
169
|
+
for (let i = open; i < code.length; i += 1) {
|
|
170
|
+
const c = code[i];
|
|
171
|
+
if (q !== '') {
|
|
172
|
+
if (c === '\\') { i += 1; continue; }
|
|
173
|
+
if (c === q) q = '';
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (c === '"' || c === "'" || c === '`') { q = c; continue; }
|
|
177
|
+
if (c === '(') { depth += 1; continue; }
|
|
178
|
+
if (c === ')') {
|
|
179
|
+
depth -= 1;
|
|
180
|
+
if (depth === 0) return i;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return -1;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function normalizeKey(filePath) {
|
|
187
|
+
const resolved = path.resolve(filePath).replace(/\\/g, '/');
|
|
188
|
+
return process.platform === 'win32' ? resolved.toLowerCase() : resolved;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/* ------------------------------------------------------------------ */
|
|
192
|
+
/* Project model (disk) */
|
|
193
|
+
/* ------------------------------------------------------------------ */
|
|
194
|
+
|
|
195
|
+
class ProjectModel {
|
|
196
|
+
constructor(root) {
|
|
197
|
+
this.root = root;
|
|
198
|
+
this.exists = new Map();
|
|
199
|
+
this.jsonCache = new Map();
|
|
200
|
+
this.moduleDirCache = new Map();
|
|
201
|
+
this.packages = new Map();
|
|
202
|
+
this.modules = [];
|
|
203
|
+
this.files = [];
|
|
204
|
+
this.walk();
|
|
205
|
+
this.indexModules();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
fileExists(p) {
|
|
209
|
+
if (this.exists.has(p)) return this.exists.get(p);
|
|
210
|
+
const value = safe(() => fs.existsSync(p), false);
|
|
211
|
+
this.exists.set(p, value);
|
|
212
|
+
return value;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
readJson(file) {
|
|
216
|
+
if (this.jsonCache.has(file)) return this.jsonCache.get(file);
|
|
217
|
+
const value = safe(() => parseJson5(fs.readFileSync(file, 'utf8')), null);
|
|
218
|
+
this.jsonCache.set(file, value);
|
|
219
|
+
return value;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
walk() {
|
|
223
|
+
const stack = [{ dir: this.root, depth: 0 }];
|
|
224
|
+
while (stack.length > 0 && this.files.length < MAX_WALKED_FILES) {
|
|
225
|
+
const { dir, depth } = stack.pop();
|
|
226
|
+
let entries;
|
|
227
|
+
try {
|
|
228
|
+
entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
229
|
+
} catch (_err) {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
for (const entry of entries) {
|
|
233
|
+
const full = path.join(dir, entry.name);
|
|
234
|
+
if (entry.isDirectory()) {
|
|
235
|
+
if (entry.name.startsWith('.') || SKIP_DIRS.has(entry.name)) continue;
|
|
236
|
+
if (depth >= MAX_WALK_DEPTH) continue;
|
|
237
|
+
stack.push({ dir: full, depth: depth + 1 });
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
if (!entry.isFile()) continue;
|
|
241
|
+
this.files.push(full);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
packageRootOf(dir) {
|
|
247
|
+
let cur = path.resolve(dir);
|
|
248
|
+
for (let hop = 0; hop < MAX_PACKAGE_HOPS; hop += 1) {
|
|
249
|
+
if (this.fileExists(path.join(cur, PACKAGE_FILE))) return cur;
|
|
250
|
+
if (normalizeKey(cur) === normalizeKey(this.root)) break;
|
|
251
|
+
const parent = path.dirname(cur);
|
|
252
|
+
if (parent === cur) break;
|
|
253
|
+
cur = parent;
|
|
254
|
+
}
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
indexModules() {
|
|
259
|
+
for (const file of this.files) {
|
|
260
|
+
const base = path.basename(file);
|
|
261
|
+
if (base === PACKAGE_FILE) {
|
|
262
|
+
const json = this.readJson(file);
|
|
263
|
+
if (!json || typeof json.name !== 'string' || !json.name) continue;
|
|
264
|
+
const deps = Object.keys(json.dependencies && typeof json.dependencies === 'object'
|
|
265
|
+
? json.dependencies : {});
|
|
266
|
+
this.packages.set(json.name, {
|
|
267
|
+
name: json.name,
|
|
268
|
+
dir: path.dirname(file),
|
|
269
|
+
main: typeof json.main === 'string' && json.main ? json.main : 'Index.ets',
|
|
270
|
+
deps,
|
|
271
|
+
});
|
|
272
|
+
} else if (base === MODULE_FILE) {
|
|
273
|
+
if (!isTestModuleFile(file)) this.modules.push(file);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
for (const moduleFile of this.modules) {
|
|
278
|
+
const json = this.readJson(moduleFile);
|
|
279
|
+
const module = json && json.module && typeof json.module === 'object' ? json.module : null;
|
|
280
|
+
if (!module) continue;
|
|
281
|
+
const type = typeof module.type === 'string' ? module.type : '';
|
|
282
|
+
const moduleDir = path.dirname(moduleFile);
|
|
283
|
+
const pkgDir = this.packageRootOf(moduleDir);
|
|
284
|
+
if (!pkgDir) continue;
|
|
285
|
+
const pkg = this.packages.get(this.pkgNameOfDir(pkgDir));
|
|
286
|
+
this.modulesInfo = this.modulesInfo || [];
|
|
287
|
+
this.modulesInfo.push({
|
|
288
|
+
moduleFile,
|
|
289
|
+
moduleDir: path.resolve(moduleDir),
|
|
290
|
+
name: typeof module.name === 'string' ? module.name : pkgDir.split(/[\\/]/).pop(),
|
|
291
|
+
type,
|
|
292
|
+
pkgDir,
|
|
293
|
+
pkgName: pkg ? pkg.name : null,
|
|
294
|
+
isHap: HAP_TYPES.has(type),
|
|
295
|
+
isLibrary: LIBRARY_TYPES.has(type),
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
this.modulesInfo = this.modulesInfo || [];
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
pkgNameOfDir(pkgDir) {
|
|
302
|
+
for (const info of this.packages.values()) {
|
|
303
|
+
if (normalizeKey(info.dir) === normalizeKey(pkgDir)) return info.name;
|
|
304
|
+
}
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
moduleInfoOfFile(filePath) {
|
|
309
|
+
const key = normalizeKey(filePath);
|
|
310
|
+
if (this.moduleDirCache.has(key)) return this.moduleDirCache.get(key);
|
|
311
|
+
let cur = path.dirname(path.resolve(filePath));
|
|
312
|
+
for (let hop = 0; hop < MAX_PARENT_HOPS; hop += 1) {
|
|
313
|
+
const candidate = path.join(cur, MODULE_FILE);
|
|
314
|
+
if (this.fileExists(candidate)) {
|
|
315
|
+
const found = this.modulesInfo.find((m) => normalizeKey(m.moduleDir) === normalizeKey(cur));
|
|
316
|
+
this.moduleDirCache.set(key, found || null);
|
|
317
|
+
return found || null;
|
|
318
|
+
}
|
|
319
|
+
if (normalizeKey(cur) === normalizeKey(this.root)) break;
|
|
320
|
+
const parent = path.dirname(cur);
|
|
321
|
+
if (parent === cur) break;
|
|
322
|
+
cur = parent;
|
|
323
|
+
}
|
|
324
|
+
this.moduleDirCache.set(key, null);
|
|
325
|
+
return null;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
resolveSpecifier(spec, importer) {
|
|
329
|
+
const raw = String(spec || '').trim();
|
|
330
|
+
if (!raw) return null;
|
|
331
|
+
const bases = [];
|
|
332
|
+
if (raw.startsWith('.') || raw.startsWith('/')) {
|
|
333
|
+
bases.push(raw.startsWith('/')
|
|
334
|
+
? path.join(this.root, raw)
|
|
335
|
+
: path.resolve(path.dirname(importer), raw));
|
|
336
|
+
} else {
|
|
337
|
+
const slash = raw.indexOf('/');
|
|
338
|
+
const pkgName = slash < 0 ? raw : raw.slice(0, slash);
|
|
339
|
+
const sub = slash < 0 ? '' : raw.slice(slash + 1);
|
|
340
|
+
const pkg = this.packages.get(pkgName);
|
|
341
|
+
if (!pkg) return null;
|
|
342
|
+
if (sub) {
|
|
343
|
+
bases.push(path.resolve(pkg.dir, sub));
|
|
344
|
+
} else {
|
|
345
|
+
bases.push(path.resolve(pkg.dir, pkg.main));
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const candidates = [];
|
|
349
|
+
for (const base of bases) {
|
|
350
|
+
candidates.push(base, `${base}.ets`, `${base}.ts`, `${base}.d.ets`,
|
|
351
|
+
path.join(base, 'Index.ets'), path.join(base, 'index.ets'));
|
|
352
|
+
}
|
|
353
|
+
for (const candidate of candidates) {
|
|
354
|
+
if (this.fileExists(candidate)) return path.resolve(candidate);
|
|
355
|
+
}
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function findProjectRoot(filePaths) {
|
|
361
|
+
// A module also has its own build-profile.json5, so the root marker must be AppScope first.
|
|
362
|
+
for (const filePath of filePaths) {
|
|
363
|
+
let cur = path.dirname(path.resolve(filePath));
|
|
364
|
+
for (let hop = 0; hop < MAX_PARENT_HOPS; hop += 1) {
|
|
365
|
+
if (fs.existsSync(path.join(cur, APP_SCOPE_DIR))) return cur;
|
|
366
|
+
const parent = path.dirname(cur);
|
|
367
|
+
if (parent === cur) break;
|
|
368
|
+
cur = parent;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// Fallback for projects without AppScope: the root build-profile.json5 is the only one with
|
|
372
|
+
// a top-level "modules" array plus a sibling oh-package.json5.
|
|
373
|
+
for (const filePath of filePaths) {
|
|
374
|
+
let cur = path.dirname(path.resolve(filePath));
|
|
375
|
+
for (let hop = 0; hop < MAX_PARENT_HOPS; hop += 1) {
|
|
376
|
+
const buildProfile = path.join(cur, 'build-profile.json5');
|
|
377
|
+
if (fs.existsSync(buildProfile) && fs.existsSync(path.join(cur, PACKAGE_FILE))) {
|
|
378
|
+
const text = safe(() => fs.readFileSync(buildProfile, 'utf8'), '');
|
|
379
|
+
if (/"modules"\s*:/.test(text) && /"app"\s*:/.test(text)) return cur;
|
|
380
|
+
}
|
|
381
|
+
const parent = path.dirname(cur);
|
|
382
|
+
if (parent === cur) break;
|
|
383
|
+
cur = parent;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function importSpecifierFromLine(line) {
|
|
390
|
+
const stateSide = /^\s*import\s*(['"])([^'"]+)\1/.exec(line);
|
|
391
|
+
const anyImport = /^\s*import\s+(?:[\s\S]*?\bfrom\s*)?(['"])([^'"]+)\1/.exec(line);
|
|
392
|
+
const fromOnly = /\bfrom\s*(['"])([^'"]+)\1/.exec(line);
|
|
393
|
+
return {
|
|
394
|
+
sideEffect: stateSide ? stateSide[2] : null,
|
|
395
|
+
specifier: anyImport ? anyImport[2] : (fromOnly ? fromOnly[2] : null),
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
class RoutePageSideEffectImportCheck extends GlobalChecker {
|
|
400
|
+
constructor() {
|
|
401
|
+
super();
|
|
402
|
+
this.reported = new Set();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
reset() {
|
|
406
|
+
super.reset();
|
|
407
|
+
this.reported = new Set();
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
report(filePath, line, routeName, libPkg, hapName, spec, pageRel) {
|
|
411
|
+
const key = `${normalizeKey(filePath)}|${line}|${hapName}`;
|
|
412
|
+
if (this.reported.has(key)) return;
|
|
413
|
+
this.reported.add(key);
|
|
414
|
+
const en = '[route-page-side-effect-import] route page `%s` (routeName `%s`) is declared in dependency `%s` but HAP `%s` has no side-effect import of its page file. Add `import \'%s\';` to a route-registry file the entry ability imports. A value import that is never referenced is tree-shaken and the route stays unregistered (100004 at runtime).';
|
|
415
|
+
const cn = '[route-page-side-effect-import] 路由页 `%s`(routeName `%s`)属于依赖 `%s`,但 HAP `%s` 中没有任何指向该页面文件的副作用 import。请在入口 Ability 可达的登记文件里补一行 `import \'%s\';`;命名 import 若符号未被引用会被构建时代码优化去掉,路由不会注册(运行时 100004)。';
|
|
416
|
+
const build = (text) => String(text)
|
|
417
|
+
.replace('%s', pageRel)
|
|
418
|
+
.replace('%s', routeName)
|
|
419
|
+
.replace('%s', libPkg)
|
|
420
|
+
.replace('%s', hapName)
|
|
421
|
+
.replace('%s', spec);
|
|
422
|
+
this.addIssue({
|
|
423
|
+
filePath,
|
|
424
|
+
line,
|
|
425
|
+
colStart: 0,
|
|
426
|
+
colEnd: 0,
|
|
427
|
+
message: { en: build(en), cn: build(cn) },
|
|
428
|
+
severity: AlertLevel.ERROR,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
checkScene(scene) {
|
|
433
|
+
const files = safe(() => scene.getFiles(), []) || [];
|
|
434
|
+
if (!Array.isArray(files) || files.length === 0) return;
|
|
435
|
+
const filePaths = [];
|
|
436
|
+
for (const arkFile of files) {
|
|
437
|
+
const filePath = safe(() => arkFile.getFilePath(), '');
|
|
438
|
+
if (filePath && !isGeneratedFile(filePath)) filePaths.push(filePath);
|
|
439
|
+
}
|
|
440
|
+
if (filePaths.length === 0) return;
|
|
441
|
+
const root = findProjectRoot(filePaths);
|
|
442
|
+
if (!root) return;
|
|
443
|
+
const project = new ProjectModel(root);
|
|
444
|
+
|
|
445
|
+
const scans = [];
|
|
446
|
+
for (const filePath of filePaths) {
|
|
447
|
+
let raw = '';
|
|
448
|
+
try {
|
|
449
|
+
raw = fs.readFileSync(filePath, 'utf8');
|
|
450
|
+
} catch (_err) {
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
scans.push({ filePath, raw, code: stripComments(raw) });
|
|
454
|
+
}
|
|
455
|
+
if (scans.length === 0) return;
|
|
456
|
+
|
|
457
|
+
// Route pages declared in library modules.
|
|
458
|
+
const routes = [];
|
|
459
|
+
for (const scan of scans) {
|
|
460
|
+
const re = /@Entry\s*\(/g;
|
|
461
|
+
let m;
|
|
462
|
+
while ((m = re.exec(scan.code)) !== null) {
|
|
463
|
+
const open = scan.code.indexOf('(', m.index);
|
|
464
|
+
const close = findCloseParen(scan.code, open);
|
|
465
|
+
if (close < 0) continue;
|
|
466
|
+
const args = scan.code.slice(open + 1, close);
|
|
467
|
+
const rm = /routeName\s*:\s*(['"])([^'"]+)\1/.exec(args);
|
|
468
|
+
if (!rm) { re.lastIndex = close + 1; continue; }
|
|
469
|
+
const moduleInfo = project.moduleInfoOfFile(scan.filePath);
|
|
470
|
+
if (moduleInfo && moduleInfo.isLibrary && moduleInfo.pkgName) {
|
|
471
|
+
routes.push({
|
|
472
|
+
filePath: scan.filePath,
|
|
473
|
+
line: lineOf(scan.raw, m.index),
|
|
474
|
+
routeName: rm[2],
|
|
475
|
+
moduleInfo,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
re.lastIndex = close + 1;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (routes.length === 0) return;
|
|
482
|
+
|
|
483
|
+
// Per-file imports: side-effect targets and module-graph edges.
|
|
484
|
+
const sideEffectImporters = new Map(); // normalized page path -> Set(pkgName)
|
|
485
|
+
const edgeMap = new Map();
|
|
486
|
+
const addEdge = (from, to) => {
|
|
487
|
+
if (!from || !to || from === to) return;
|
|
488
|
+
if (!edgeMap.has(from)) edgeMap.set(from, new Set());
|
|
489
|
+
edgeMap.get(from).add(to);
|
|
490
|
+
};
|
|
491
|
+
for (const [pkgName, pkg] of project.packages) {
|
|
492
|
+
for (const dep of pkg.deps) addEdge(pkgName, dep);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
for (const scan of scans) {
|
|
496
|
+
const importerModule = project.moduleInfoOfFile(scan.filePath);
|
|
497
|
+
const importerPkg = importerModule ? importerModule.pkgName : null;
|
|
498
|
+
const lines = scan.code.split(/\r?\n/);
|
|
499
|
+
for (const line of lines) {
|
|
500
|
+
const parsed = importSpecifierFromLine(line);
|
|
501
|
+
if (!parsed.specifier) continue;
|
|
502
|
+
const resolved = project.resolveSpecifier(parsed.specifier, scan.filePath);
|
|
503
|
+
if (!resolved) continue;
|
|
504
|
+
if (importerPkg && !parsed.specifier.startsWith('.') && !parsed.specifier.startsWith('/')) {
|
|
505
|
+
const slash = parsed.specifier.indexOf('/');
|
|
506
|
+
const importedPkg = slash < 0 ? parsed.specifier : parsed.specifier.slice(0, slash);
|
|
507
|
+
addEdge(importerPkg, importedPkg);
|
|
508
|
+
}
|
|
509
|
+
if (!parsed.sideEffect) continue;
|
|
510
|
+
const key = normalizeKey(resolved);
|
|
511
|
+
if (!sideEffectImporters.has(key)) sideEffectImporters.set(key, new Set());
|
|
512
|
+
if (importerPkg) sideEffectImporters.get(key).add(importerPkg);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
const reachableCache = new Map();
|
|
517
|
+
const reachableFrom = (start) => {
|
|
518
|
+
if (!start) return new Set();
|
|
519
|
+
if (reachableCache.has(start)) return reachableCache.get(start);
|
|
520
|
+
const seen = new Set([start]);
|
|
521
|
+
const queue = [start];
|
|
522
|
+
while (queue.length > 0) {
|
|
523
|
+
const current = queue.shift();
|
|
524
|
+
const next = edgeMap.get(current);
|
|
525
|
+
if (!next) continue;
|
|
526
|
+
for (const dep of next) {
|
|
527
|
+
if (seen.has(dep)) continue;
|
|
528
|
+
seen.add(dep);
|
|
529
|
+
queue.push(dep);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
reachableCache.set(start, seen);
|
|
533
|
+
return seen;
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
const haps = project.modulesInfo.filter((m) => m.isHap && m.pkgName);
|
|
537
|
+
if (haps.length === 0) return;
|
|
538
|
+
|
|
539
|
+
for (const route of routes) {
|
|
540
|
+
const libPkg = route.moduleInfo.pkgName;
|
|
541
|
+
const pageKey = normalizeKey(route.filePath);
|
|
542
|
+
const importers = sideEffectImporters.get(pageKey) || new Set();
|
|
543
|
+
const relFromPkg = path.relative(route.moduleInfo.pkgDir, route.filePath)
|
|
544
|
+
.replace(/\\/g, '/')
|
|
545
|
+
.replace(/\.(ets|ts)$/i, '');
|
|
546
|
+
const spec = `${libPkg}/${relFromPkg}`;
|
|
547
|
+
const pageRel = path.relative(root, route.filePath).replace(/\\/g, '/');
|
|
548
|
+
|
|
549
|
+
for (const hap of haps) {
|
|
550
|
+
const reachable = reachableFrom(hap.pkgName);
|
|
551
|
+
if (!reachable.has(libPkg)) continue;
|
|
552
|
+
let registered = false;
|
|
553
|
+
for (const importerPkg of importers) {
|
|
554
|
+
if (reachable.has(importerPkg)) { registered = true; break; }
|
|
555
|
+
}
|
|
556
|
+
if (registered) continue;
|
|
557
|
+
this.report(route.filePath, route.line, route.routeName, libPkg,
|
|
558
|
+
hap.name || hap.pkgName, spec, pageRel);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
Rule({
|
|
565
|
+
ruleId: RULE_ID,
|
|
566
|
+
severity: AlertLevel.ERROR,
|
|
567
|
+
fileExtensions: ['.ets', '.ts'],
|
|
568
|
+
})(RoutePageSideEffectImportCheck);
|
|
569
|
+
|
|
570
|
+
module.exports = { RoutePageSideEffectImportCheck };
|