@buaa_smat/hometrans 26.0.7 → 26.0.8

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.
Files changed (154) hide show
  1. package/agents/a2h-executor.md +37 -0
  2. package/env-requirements.json +15 -1
  3. package/i18n/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +2 -2
  4. package/i18n/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +1 -1
  5. package/i18n/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +13 -6
  6. package/i18n/skills/a2h-app-migrate/SKILL.md +2 -2
  7. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +27 -4
  8. package/i18n/skills/a2h-app-migrate/scripts/opencode_depth.mjs +418 -0
  9. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
  10. package/i18n/skills/a2h-batch-ui-align/SKILL.md +7 -7
  11. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -1
  12. package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +20 -2
  13. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +2 -2
  14. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +3 -3
  15. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +3 -1
  16. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +2 -2
  17. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +10 -6
  18. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +13 -9
  19. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +59 -7
  20. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -0
  21. package/i18n/skills/a2h-batch-ui-align/scripts/interactions.mjs +186 -0
  22. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +33 -7
  23. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +83 -22
  24. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +39 -5
  25. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +25 -1
  26. package/i18n/skills/a2h-page-specgen/SKILL.md +1 -1
  27. package/i18n/skills/a2h-page-specgen/references/gates.md +3 -1
  28. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +11 -11
  29. package/i18n/skills/a2h-page-specgen/references/spec-template.md +3 -3
  30. package/i18n/skills/a2h-page-specgen/scripts/contract-calls.mjs +40 -3
  31. package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +73 -5
  32. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +144 -0
  33. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +11 -11
  34. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +11 -11
  35. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +11 -11
  36. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +11 -11
  37. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +10 -10
  38. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +1 -1
  39. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +11 -11
  40. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +11 -11
  41. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +11 -11
  42. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +11 -11
  43. package/i18n/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +45 -1
  44. package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +100 -0
  45. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +132 -3
  46. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +36 -1
  47. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +1 -1
  48. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +16 -0
  49. package/i18n/skills/a2h-utg-static/SKILL.md +2 -0
  50. package/package.json +1 -1
  51. package/platforms/atomcode/agents/a2h-executor.frontmatter.md +6 -0
  52. package/platforms/codebuddy/agents/a2h-executor.frontmatter.md +5 -0
  53. package/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +2 -2
  54. package/platforms/deveco/agents/a2h-executor.frontmatter.md +7 -0
  55. package/platforms/deveco/agents/build-fixer.frontmatter.md +0 -2
  56. package/platforms/deveco/agents/code-reviewer.frontmatter.md +0 -2
  57. package/platforms/deveco/agents/model-render-worker.frontmatter.md +0 -2
  58. package/platforms/deveco/agents/model-worker.frontmatter.md +0 -2
  59. package/platforms/deveco/agents/specgen-worker.frontmatter.md +0 -2
  60. package/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +1 -1
  61. package/platforms/opencode/agents/a2h-executor.frontmatter.md +7 -0
  62. package/platforms/opencode/agents/build-fixer.frontmatter.md +0 -2
  63. package/platforms/opencode/agents/code-reviewer.frontmatter.md +0 -2
  64. package/platforms/opencode/agents/model-render-worker.frontmatter.md +0 -2
  65. package/platforms/opencode/agents/model-worker.frontmatter.md +0 -2
  66. package/platforms/opencode/agents/specgen-worker.frontmatter.md +0 -2
  67. package/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +13 -6
  68. package/skills/a2h-app-migrate/SKILL.md +29 -3
  69. package/skills/a2h-app-migrate/references/host-rules.md +33 -0
  70. package/skills/a2h-app-migrate/references/workflow.yaml +24 -4
  71. package/skills/a2h-app-migrate/scripts/opencode_depth.mjs +418 -0
  72. package/skills/a2h-app-migrate/test/test_executor_header_sync.mjs +78 -0
  73. package/skills/a2h-app-migrate/test/test_opencode_depth.mjs +312 -0
  74. package/skills/a2h-app-migrate/tools/dag.mjs +267 -0
  75. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
  76. package/skills/a2h-batch-ui-align/SKILL.md +7 -7
  77. package/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -1
  78. package/skills/a2h-batch-ui-align/references/cards/state.md +20 -2
  79. package/skills/a2h-batch-ui-align/references/cards/widgets.md +2 -2
  80. package/skills/a2h-batch-ui-align/references/checker-rules.md +3 -3
  81. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +3 -1
  82. package/skills/a2h-batch-ui-align/references/host-dispatch.md +5 -5
  83. package/skills/a2h-batch-ui-align/references/incremental-scope.md +2 -2
  84. package/skills/a2h-batch-ui-align/references/step3-capture.md +10 -6
  85. package/skills/a2h-batch-ui-align/references/step5-convert.md +13 -9
  86. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +59 -7
  87. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -0
  88. package/skills/a2h-batch-ui-align/scripts/group_pass.mjs +3 -2
  89. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +139 -23
  90. package/skills/a2h-batch-ui-align/scripts/host_env.mjs +32 -8
  91. package/skills/a2h-batch-ui-align/scripts/interactions.mjs +186 -0
  92. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +33 -7
  93. package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +83 -22
  94. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +39 -5
  95. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +82 -0
  96. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +25 -1
  97. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +184 -2
  98. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +33 -0
  99. package/skills/a2h-batch-ui-align/scripts/tests/interactions.test.mjs +258 -0
  100. package/skills/a2h-page-specgen/SKILL.md +1 -1
  101. package/skills/a2h-page-specgen/references/evidence.md +15 -0
  102. package/skills/a2h-page-specgen/references/gates.md +3 -1
  103. package/skills/a2h-page-specgen/references/scenario-authoring.md +10 -10
  104. package/skills/a2h-page-specgen/references/spec-template.md +2 -2
  105. package/skills/a2h-page-specgen/scripts/contract-calls.mjs +40 -3
  106. package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +73 -5
  107. package/skills/a2h-page-specgen/scripts/gate.mjs +141 -0
  108. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +10 -10
  109. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +10 -10
  110. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +10 -10
  111. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +10 -10
  112. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +10 -10
  113. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +1 -1
  114. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +10 -10
  115. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +10 -10
  116. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +10 -10
  117. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +10 -10
  118. package/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +45 -1
  119. package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +100 -0
  120. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +104 -3
  121. package/skills/a2h-resource-convert/references/conversion-rules.md +2 -0
  122. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +36 -1
  123. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +42 -0
  124. package/skills/a2h-spec-design-pipeline/SKILL.md +1 -1
  125. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +16 -0
  126. package/skills/a2h-spec-design-pipeline/references/execution-model.md +2 -2
  127. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +5 -1
  128. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +5 -0
  129. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +4 -0
  130. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +2 -1
  131. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +3 -1
  132. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-v2-observation-cn.md +105 -0
  133. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-v2-observation-en.md +122 -0
  134. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +4 -4
  135. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIV2ObservationCheck.js +1862 -0
  136. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +2 -0
  137. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +1 -1
  138. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +15 -2
  139. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +20 -4
  140. package/skills/a2h-spec-design-pipeline/scripts/test_arkui_v2_observation.ts +284 -0
  141. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +32 -0
  142. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +22 -1
  143. package/skills/a2h-utg-static/SKILL.md +2 -0
  144. package/skills/a2h-utg-static/references/extractors.md +16 -0
  145. package/skills/a2h-utg-static/scripts/run_pipeline.mjs +22 -1
  146. package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +4 -0
  147. package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +15 -0
  148. package/skills/a2h-utg-static/scripts/tests/test_view_attachments.mjs +330 -0
  149. package/skills/a2h-utg-static/scripts/view_attachments.mjs +465 -0
  150. package/platforms/codebuddy/agents/build-fixer.frontmatter.md +0 -5
  151. package/platforms/codebuddy/agents/code-reviewer.frontmatter.md +0 -5
  152. package/platforms/codebuddy/agents/model-render-worker.frontmatter.md +0 -5
  153. package/platforms/codebuddy/agents/model-worker.frontmatter.md +0 -5
  154. package/platforms/codebuddy/agents/specgen-worker.frontmatter.md +0 -5
@@ -0,0 +1,186 @@
1
+ // interactions.mjs — in-page interactions a2h-utg-static found that no navigation edge expresses, end to end.
2
+ //
3
+ // a2h-utg-static stamps on a page node `attachments[]` (view_attachments.mjs): a project View constructed and
4
+ // handed to another view's non-layout sink — a chart marker, a tooltip, an empty view. The receiver shows it from
5
+ // its own touch handling, so no click listener names it and the explorer never taps it (clickable=false). Lead
6
+ // case: a weather app's TodayWeatherFragment.java:173 `chart.setMarker(new CustomMarkerView(ctx, R.layout.marker))`
7
+ // (tap the forecast curve → highlight line + a bubble with the temperature). The fragment was an `attach` node of
8
+ // the captured main page, the marker reached neither the meta.json nor the prompt, and the converted chart drew the
9
+ // curve with no touch handling at all.
10
+ //
11
+ // build_conversion_set.mjs turns each attachment into an interaction {id, kind, host, node, view_class, layout,
12
+ // sink, evidence} (interactionsOf), folds an attach node's interactions into its host page, and writes them to
13
+ // meta.json `interactions` and conversion_set.json `interactions`. This module reads them back for the group pack
14
+ // (renderInteractionsSection) and phase5_check (interactionCoverage): each interaction is implemented in the
15
+ // converted page and marked `// INTERACTION: <id>` on or up to 3 lines above the implementing statement, or waived
16
+ // with `// INTERACTION-OMIT: <id> — <basis>`.
17
+ //
18
+ // An older UTG has no attachments: every function returns nothing and the check is skipped silently.
19
+
20
+ import * as fs from 'node:fs';
21
+ import * as path from 'node:path';
22
+ import { hasBasis, realStatement } from './overlay_effects.mjs';
23
+
24
+ const LOOKAHEAD = 3;
25
+
26
+ function readJson(p) {
27
+ try { return JSON.parse(fs.readFileSync(p, 'utf8')); } catch { return null; }
28
+ }
29
+ const isObj = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
30
+
31
+ /** `app/src/.../X.java:173` -> `X.java:173`. */
32
+ const shortAt = (at) => String(at ?? '').split('/').at(-1);
33
+
34
+ /**
35
+ * Interactions of one UTG node: one per `attachments[]` entry (a2h-utg-static view_attachments). The id is
36
+ * `ix:<sink path>:<line>:<ViewClass>` — the line that attaches the view plus the attached class, so two views
37
+ * attached on one line (`chart.setMarker(new A(..)); chart.setEmptyView(new B(..));`) stay two interactions;
38
+ * stable across runs while the source does not move.
39
+ */
40
+ export function interactionsOf(node) {
41
+ const out = [];
42
+ if (!isObj(node)) { return out; }
43
+ const seen = new Set();
44
+ for (const a of Array.isArray(node.attachments) ? node.attachments : []) {
45
+ if (!isObj(a) || !isObj(a.sink) || !a.sink.at) { continue; }
46
+ const id = `ix:${a.sink.at}${a.view_class ? `:${a.view_class}` : ''}`;
47
+ if (seen.has(id)) { continue; }
48
+ seen.add(id);
49
+ out.push({
50
+ id, kind: 'attached-view', node: node.id,
51
+ view_class: a.view_class ?? null, view_class_at: a.view_class_at ?? null, base: a.base ?? null,
52
+ ...(a.layout ? { layout: a.layout } : {}),
53
+ sink: a.sink, at: a.at ?? a.sink.at,
54
+ ...(a.via_var ? { via_var: a.via_var } : {}), ...(a.via_fn ? { via_fn: a.via_fn } : {}),
55
+ });
56
+ }
57
+ return out;
58
+ }
59
+
60
+ /** conversion_set.json `interactions`, each {id, kind, host, node, ...}. [] for an older set. */
61
+ export function loadInteractions(uiInfo) {
62
+ const cs = uiInfo ? readJson(path.join(uiInfo, 'conversion_set.json')) : null;
63
+ return isObj(cs) && Array.isArray(cs.interactions) ? cs.interactions.filter((x) => isObj(x) && x.id) : [];
64
+ }
65
+
66
+ /** Interactions whose host page (or own node) is in `set`; all of them when `set` is null. */
67
+ export function interactionsInScope(items, set) {
68
+ return set === null || set === undefined ? items : items.filter((x) => set.has(x.host) || set.has(x.node));
69
+ }
70
+
71
+ // `ix:<path>:<line>:<ViewClass>`; path rules as overlay_effects FX_ID (no spaces or ':'). Without a view class (an
72
+ // attachment that names none) the line number ends it.
73
+ const IX_ID = String.raw`ix:(?:[A-Za-z]:)?[^\s:]+:\d+(?::[A-Za-z_]\w*|(?!\d|:\d))`;
74
+ const RE_MARK = new RegExp(String.raw`\/\/\s*INTERACTION(?!-)\s*[::]\s*(${IX_ID})`);
75
+ const RE_OMIT = new RegExp(String.raw`\/\/\s*INTERACTION-OMIT\s*[::]\s*(${IX_ID})\s*(?:[—–::-]+\s*)?(.*)$`);
76
+
77
+ /**
78
+ * A line that implements an interaction: overlay_effects.realStatement, plus an ArkUI event / gesture
79
+ * attribute (`.onTouch(`, `.gesture(`, `.onClick(`, `.bindPopup(`, ...) — the usual implementation of a
80
+ * touch-shown auxiliary view, which realStatement rejects as a component line.
81
+ */
82
+ export function implementingLine(line) {
83
+ const code = line.replace(/\/\/.*$/, '').trim();
84
+ // A chained attribute line implements an interaction only when it is an event / gesture / popup one:
85
+ // `.width(100)` is a call to realStatement, but a marker above it would cover nothing.
86
+ if (code.startsWith('.')) { return /^\.\s*(?:on[A-Z]\w*|gesture|priorityGesture|parallelGesture|bind[A-Z]\w*|overlay)\s*\(/.test(code); }
87
+ return realStatement(line);
88
+ }
89
+
90
+ /** markers in src: marks id -> [{line, attached}], omits id -> [{line, reason}]. */
91
+ export function scanInteractionMarkers(src) {
92
+ const lines = src.split(/\r?\n/);
93
+ const marks = new Map();
94
+ const omits = new Map();
95
+ lines.forEach((ln, i) => {
96
+ const o = RE_OMIT.exec(ln);
97
+ if (o) { if (!omits.has(o[1])) { omits.set(o[1], []); } omits.get(o[1]).push({ line: i + 1, reason: o[2].trim() }); return; }
98
+ const m = RE_MARK.exec(ln);
99
+ if (!m) { return; }
100
+ const attached = implementingLine(ln.slice(0, ln.indexOf('//'))) || lines.slice(i + 1, i + 1 + LOOKAHEAD).some(implementingLine);
101
+ if (!marks.has(m[1])) { marks.set(m[1], []); }
102
+ marks.get(m[1]).push({ line: i + 1, attached });
103
+ });
104
+ return { marks, omits };
105
+ }
106
+
107
+ /**
108
+ * GATE interaction-uncovered: an interaction in scope with no attached `// INTERACTION: <id>` in files or shared and
109
+ * no `// INTERACTION-OMIT: <id> — <basis>`. GATE interaction-marker-detached: a marker in files with no statement or
110
+ * event attribute on its line or the next 3. files / shared: [[rel, src]]; scope: a Set of node ids or null (all).
111
+ *
112
+ * An id is one sink line in the Android source. When that line sits in a base class or a reused component, several
113
+ * host pages carry the same id: it is ported once, as the shared component it is, and one marker covers every host.
114
+ * An uncovered one is reported once, naming all its hosts.
115
+ */
116
+ export function interactionCoverage({ items, scope = null, files = [], shared = [] }) {
117
+ const gate = [];
118
+ const marks = new Set();
119
+ const omits = new Map();
120
+ const seen = new Set();
121
+ const add = (rel, src, own) => {
122
+ const s = scanInteractionMarkers(src);
123
+ for (const [id, v] of s.marks) {
124
+ for (const x of v) {
125
+ if (x.attached) { marks.add(id); continue; }
126
+ if (own) { gate.push(`interaction-marker-detached ${rel}:${x.line} // INTERACTION: ${id} — no statement or event attribute on this line or the next ${LOOKAHEAD}`); }
127
+ }
128
+ }
129
+ for (const [id, v] of s.omits) { if (!omits.has(id)) { omits.set(id, []); } omits.get(id).push(...v.map((x) => ({ ...x, at: `${rel}:${x.line}` }))); }
130
+ };
131
+ for (const [rel, src] of files) { seen.add(rel); add(rel, src, true); }
132
+ for (const [rel, src] of shared) { if (!seen.has(rel)) { add(rel, src, false); } }
133
+ const byId = new Map();
134
+ for (const x of interactionsInScope(items, scope)) { if (!byId.has(x.id)) { byId.set(x.id, []); } byId.get(x.id).push(x); }
135
+ for (const [id, xs] of byId) {
136
+ if (marks.has(id) || (omits.get(id) ?? []).some((o) => hasBasis(o.reason))) { continue; }
137
+ const x = xs[0];
138
+ const where = [...new Set(xs.map((h) => `${h.host}${h.node !== h.host ? ` ← ${h.node}` : ''}`))].join(', ');
139
+ const bad = (omits.get(x.id) ?? [])[0];
140
+ gate.push(`interaction-uncovered ${x.id} (${where}): ${describe(x)} ` +
141
+ `has no // INTERACTION: ${x.id} on an implementing statement${bad ? ` (INTERACTION-OMIT at ${bad.at} has no basis)` : ''}`);
142
+ }
143
+ return { gate, checked: byId.size };
144
+ }
145
+
146
+ /** One-line description of an interaction for reports. */
147
+ export function describe(x) {
148
+ if (x.kind === 'attached-view') {
149
+ const recv = x.sink?.receiver ? `${x.sink.receiver}.` : '';
150
+ const how = x.sink?.kind === 'prop-assign' ? `${recv}${x.sink.target} = ${x.view_class}(..)` : `${recv}${x.sink?.callee}(${x.view_class}(..))`;
151
+ return `\`${how}\` at ${shortAt(x.sink?.at)}`;
152
+ }
153
+ return `${x.kind} at ${shortAt(x.at)}`;
154
+ }
155
+
156
+ /** Group pack section: every interaction of the group's pages, with the marker rule. [] when there is none. */
157
+ export function renderInteractionsSection(items) {
158
+ if (!items.length) { return []; }
159
+ const lines = ['## In-page interactions — implement each one in the converted page', '',
160
+ 'a2h-utg-static found these interactions in the Android source. No navigation edge or click listener expresses ' +
161
+ 'them, and the reference screenshots do not show them: an **attached view** is a project View the page hands to ' +
162
+ 'another view (`chart.setMarker(..)`, `x.marker = ..`, a tooltip, an empty view), and the receiving view shows it ' +
163
+ 'from its own touch / state handling. Read the receiver\'s configuration in the Android source around the sink ' +
164
+ '(what gesture shows it, what it displays, what is disabled) and implement the same behaviour in HarmonyOS: an ' +
165
+ 'ArkUI component has no such built-in, so a drawn chart needs its own touch handling (`.onTouch` / `.gesture`) ' +
166
+ 'plus the auxiliary view as an overlay. Put `// INTERACTION: <id>` on the implementing statement or event ' +
167
+ 'attribute, or up to 3 lines above it. An interaction that cannot or must not be ported gets ' +
168
+ '`// INTERACTION-OMIT: <id> — <basis>`. phase5_check gates both (`interaction-uncovered`, ' +
169
+ '`interaction-marker-detached`). An id listed under several pages comes from one line in a shared base class or ' +
170
+ 'component: port it once, in the shared component, and mark it once.', ''];
171
+ const byHost = new Map();
172
+ for (const x of items) { if (!byHost.has(x.host)) { byHost.set(x.host, []); } byHost.get(x.host).push(x); }
173
+ for (const [host, xs] of byHost) {
174
+ lines.push(`### ${host}`, '');
175
+ for (const x of xs) {
176
+ lines.push(`- \`${x.id}\` ${x.kind}${x.node !== host ? ` (from attached \`${x.node}\`)` : ''}: ${describe(x)}`);
177
+ if (x.kind === 'attached-view') {
178
+ lines.push(` - view class \`${x.view_class}\`${x.base ? ` extends \`${x.base}\`` : ''} at \`${x.view_class_at ?? ''}\`` +
179
+ `${x.layout ? `, layout \`${x.layout}\`` : ''}`);
180
+ if (x.via_var || x.via_fn) { lines.push(` - constructed at \`${x.at}\` via ${x.via_var ? `variable \`${x.via_var}\`` : `factory \`${x.via_fn}()\``}`); }
181
+ }
182
+ }
183
+ lines.push('');
184
+ }
185
+ return lines;
186
+ }
@@ -32,6 +32,7 @@ import { _reported, _replace, _uiModule, etsRoots, etsSplit, reportPath } from '
32
32
  import { textColorDiff } from './text_color_diff.mjs';
33
33
  import { iconCoverage } from './icon_coverage.mjs';
34
34
  import { convertedNodes, effectCoverage, groupNodes, loadEffects } from './overlay_effects.mjs';
35
+ import { interactionCoverage, loadInteractions } from './interactions.mjs';
35
36
  import { degradeReasons, drawCoverage } from './draw_coverage.mjs';
36
37
  import { branchCoverage } from './branch_coverage.mjs';
37
38
 
@@ -852,15 +853,19 @@ export function check(hp, files, rnd = null, group = null, android = null, repor
852
853
  // --files (Step 5.5 / Step 6 re-check) of an edge touching any converted node, has an attached
853
854
  // // EFFECT: <id> somewhere in the ets roots, or an EFFECT-OMIT with a basis. A UTG without host_effects: skipped.
854
855
  rep.effects = { gate: [], cand: [], checked: 0 };
856
+ rep.interactions = { gate: [], checked: 0 };
855
857
  {
856
858
  const uiInfo = String(or(get(progress, 'ui_info_root'), pjoin(meta, 'ui_info')));
857
859
  const edges = loadEffects(uiInfo);
860
+ const items = loadInteractions(uiInfo);
858
861
  const members = group ? groupNodes(uiInfo, group) : null;
859
- if (edges.length && (!group || members)) {
860
- const shared = [];
861
- // Every module's ETS root, not only those the given files live in: with module placement the effect
862
- // code sits in a feature module the --files list may not name. A file is named as `files` names it
863
- // (ETS-relative in the UI module, project-relative elsewhere), so same-named files of two modules differ.
862
+ // Every module's ETS root, not only those the given files live in: with module placement the effect /
863
+ // interaction code sits in a feature module the --files list may not name. A file is named as `files` names
864
+ // it (ETS-relative in the UI module, project-relative elsewhere), so same-named files of two modules differ.
865
+ let sharedCache = null;
866
+ const sharedEts = () => {
867
+ if (sharedCache) { return sharedCache; }
868
+ sharedCache = [];
864
869
  const walkFx = (r, d) => {
865
870
  let es = [];
866
871
  try { es = fs.readdirSync(d, { withFileTypes: true }); } catch { return; }
@@ -869,14 +874,25 @@ export function check(hp, files, rnd = null, group = null, android = null, repor
869
874
  if (e.isDirectory()) walkFx(r, p);
870
875
  else if (e.name.endsWith('.ets')) {
871
876
  const name = (r === uiRoot ? path.relative(r, p) : path.relative(path.resolve(hp), p)).replace(/\\/g, '/');
872
- try { shared.push([name, fs.readFileSync(p, 'utf8')]); } catch { /* skip */ }
877
+ try { sharedCache.push([name, fs.readFileSync(p, 'utf8')]); } catch { /* skip */ }
873
878
  }
874
879
  }
875
880
  };
876
881
  for (const r of new Set([...resOf.keys(), ...etsRoots(hp, ets).map((x) => path.resolve(x))])) walkFx(r, r);
877
- rep.effects = effectCoverage({ edges, members, converted: group ? null : convertedNodes(uiInfo), files: [...texts], shared });
882
+ return sharedCache;
883
+ };
884
+ if (edges.length && (!group || members)) {
885
+ rep.effects = effectCoverage({ edges, members, converted: group ? null : convertedNodes(uiInfo), files: [...texts], shared: sharedEts() });
878
886
  rep.blocking += rep.effects.gate.length;
879
887
  }
888
+ // In-page interactions (interactions.mjs): each interaction of a page in this group (with --files: of every
889
+ // converted page) has an attached // INTERACTION: <id>, or an INTERACTION-OMIT with a basis. A UTG without
890
+ // attachments: skipped. In group mode only the group's own pages count; an interaction is never a candidate,
891
+ // because it lives in the page that hosts it.
892
+ if (items.length && (!group || members)) {
893
+ rep.interactions = interactionCoverage({ items, scope: group ? members : convertedNodes(uiInfo), files: [...texts], shared: sharedEts() });
894
+ rep.blocking += rep.interactions.gate.length;
895
+ }
880
896
  }
881
897
  // Custom drawing in reach of this group without a drawing Harmony counterpart, and 已降级 lines whose only reason
882
898
  // is one conversion-procedure.md rules out (draw_coverage.mjs). The report is --report, else the --group's own
@@ -1010,6 +1026,16 @@ export function render(rep) {
1010
1026
  'an effect that must not be ported gets // EFFECT-OMIT: <id> — <basis>');
1011
1027
  }
1012
1028
  }
1029
+ const ix = rep.interactions;
1030
+ if (ix && ix.checked) {
1031
+ outp.push(`\n[interactions] in-page interactions vs // INTERACTION markers (${ix.checked} interactions): GATE ${ix.gate.length} (blocking)`);
1032
+ outp.push(...ix.gate.map((x) => ` ${x}`));
1033
+ if (ix.gate.length) {
1034
+ outp.push(' Fix: implement the interaction in the converted page (touch handling + the attached view, as the Android receiver shows it) ' +
1035
+ 'and put // INTERACTION: <id> on (or up to 3 lines above) the implementing statement or event attribute; ' +
1036
+ 'one that must not be ported gets // INTERACTION-OMIT: <id> — <basis>');
1037
+ }
1038
+ }
1013
1039
  for (const [k, title] of sections) {
1014
1040
  const v = or(rep[k], []);
1015
1041
  outp.push(`\n[${k}] ${title}: ${v.length}`);
@@ -35,7 +35,7 @@ export const meta: RuleMeta[] = [
35
35
  card: "interaction",
36
36
  needs: [],
37
37
  summary: "宽高 `'100%'`(在 `Stack`/`RelativeContainer` 里也包括与父容器写同一尺寸表达式的轴)且没有 `hitTestBehavior` 的节点,检查器按结构证明不了它不吞点击。证明得了的(自身可交互、父容器不层叠、下方没有可点击元素、整页根节点)不再列出。写了任何 `hitTestBehavior`(含 `Block`/`Default`)即视为作者已明确选择,不在检查范围内。",
38
- fix: "GATE「条件显示的覆盖层」:它显示时挡住下方的可点击元素。本意就是挡住输入(加载遮罩、模态层)时写降级标记 `// HIT-TEST: blocks-input: <依据>`,否则加 `.hitTestBehavior(HitTestMode.None)`。GATE「子树可交互的覆盖层」:它本身挡住下方的可点击元素,子节点仍要收点击时加 `.hitTestBehavior(HitTestMode.Transparent)`;本意就是盖住下层(全屏 sheet 盖住自己的遮罩)时写 `// HIT-TEST: covers-below: <依据>`。CAND(下方或自身含扫描范围外的组件、`zIndex` 改了层序、未找到调用处):检查器判不了,按「交互可达性证据」核对。",
38
+ fix: "GATE「条件显示的覆盖层」:它显示时挡住下方的可点击元素。本意就是挡住输入(加载遮罩、模态层)时写降级标记 `// HIT-TEST: blocks-input: <依据>`,否则加 `.hitTestBehavior(HitTestMode.None)`。GATE「子树可交互的覆盖层」:它本身挡住下方的可点击元素,子节点仍要收点击时加 `.hitTestBehavior(HitTestMode.Transparent)`;本意就是盖住下层(全屏 sheet 盖住自己的遮罩)时写 `// HIT-TEST: covers-below: <依据>`;被盖住的兄弟含可滚动容器(Scroll / List / Grid / WaterFlow / Swiper …)时该标记不生效,只能改代码。CAND(下方或自身含扫描范围外的组件、`zIndex` 改了层序、未找到调用处):检查器判不了,按「交互可达性证据」核对。",
39
39
  escape: "// HIT-TEST: <blocks-input|covers-below>:",
40
40
  cases: [
41
41
  "同上一条:旧版 fullsize-container 只是词法候选,一页常列出 5-10 处,报告用一句「均为背景延伸层」整批关闭,其中漏掉了真正吞点击的那一层。",
@@ -136,17 +136,31 @@ function packageImports(s: FileScan): Set<string> {
136
136
  return out;
137
137
  }
138
138
 
139
+ /** Whether masked[from, to) itself (no calls followed) shows what a range walk looks for. */
140
+ type Direct = (masked: string, from: number, to: number) => boolean;
141
+
142
+ /** `@Builder function name(` declared at the top level of a scanned file: s first, then the others. */
143
+ function globalBuilder(scans: FileScan[], s: FileScan, name: string): Body | null {
144
+ const esc: string = name.replace(/\$/g, '\\$');
145
+ const decl: RegExp = new RegExp(`@Builder\\s+(?:export\\s+)?function\\s+${esc}\\s*\\(`);
146
+ for (const f of [s, ...scans.filter((x) => x !== s)]) {
147
+ if (!decl.test(maskedOf(f))) { continue; }
148
+ const b: Body | null = builderBody(f, name);
149
+ if (b !== null) { return b; }
150
+ }
151
+ return null;
152
+ }
153
+
139
154
  /**
140
- * Whether code [from, to) of s draws anything that takes input: a handler, an interactive built-in, or one of
141
- * them inside a same-file @Builder or a scanned struct it calls. null when it calls a component imported from
142
- * a package that is not among the scanned files. Builders passed in attribute arguments (`.overlay`,
143
- * `.bindSheet`, `.background`) draw elsewhere and are not followed.
155
+ * Whether code [from, to) of s, or anything it draws, satisfies `direct`: followed into same-file @Builder methods,
156
+ * global `@Builder function`s, scanned structs, and the builders callers pass to a @BuilderParam. null when it calls
157
+ * a component imported from a package that is not among the scanned files, or past the depth budget. Builders
158
+ * passed in attribute arguments (`.overlay`, `.bindSheet`, `.background`) draw elsewhere and are not followed.
144
159
  */
145
- export function rangeInteractive(scans: FileScan[], s: FileScan, from: number, to: number, seen: Set<string> = new Set()): Tri {
160
+ export function rangeWalk(scans: FileScan[], s: FileScan, from: number, to: number, direct: Direct, seen: Set<string> = new Set()): Tri {
146
161
  // Read on the masked text: '.onClick(' or 'Scroll(' inside a string literal is no input.
147
162
  const masked: string = maskedOf(s);
148
- const code: string = masked.slice(from, to);
149
- if (RE_HANDLER.test(code) || RE_INTERACTIVE_COMP.test(code)) { return true; }
163
+ if (direct(masked, from, to)) { return true; }
150
164
  const imported: Set<string> = packageImports(s);
151
165
  const parts: Tri[] = [];
152
166
  for (const m of masked.slice(from, to).matchAll(/(?<![\w$.])(this\.)?([A-Za-z_$][\w$]*)\s*\(/g)) {
@@ -157,22 +171,38 @@ export function rangeInteractive(scans: FileScan[], s: FileScan, from: number, t
157
171
  // Past the depth budget the subtree is unread, not proven inert.
158
172
  if (seen.size > 24) { parts.push(null); continue; }
159
173
  const next: Set<string> = new Set([...seen, key]);
174
+ const walk = (b: Body): Tri => rangeWalk(scans, b.scan, b.open, b.close, direct, next);
160
175
  if (m[1]) {
161
176
  const b: Body | null = builderBody(s, m[2]);
162
- if (b !== null) { parts.push(rangeInteractive(scans, b.scan, b.open, b.close, next)); continue; }
177
+ if (b !== null) { parts.push(walk(b)); continue; }
163
178
  // A @BuilderParam draws what the callers pass in.
164
- const bp: Tri | undefined = builderParamInteractive(scans, s, at, m[2], next);
179
+ const bp: Tri | undefined = builderParamWalk(scans, s, at, m[2], direct, next);
165
180
  if (bp !== undefined) { parts.push(bp); }
166
181
  continue;
167
182
  }
168
- if (!/^[A-Z]/.test(m[2])) { continue; }
183
+ if (!/^[A-Z]/.test(m[2])) {
184
+ // a global `@Builder function listSection()` called without `this.`
185
+ const g: Body | null = globalBuilder(scans, s, m[2]);
186
+ if (g !== null) { parts.push(walk(g)); } else if (imported.has(m[2])) { parts.push(null); }
187
+ continue;
188
+ }
169
189
  const sb: Body | null = structBuild(scans, m[2]);
170
- if (sb !== null) { parts.push(rangeInteractive(scans, sb.scan, sb.open, sb.close, next)); continue; }
190
+ if (sb !== null) { parts.push(walk(sb)); continue; }
171
191
  if (imported.has(m[2])) { parts.push(null); }
172
192
  }
173
193
  return anyTri(parts);
174
194
  }
175
195
 
196
+ const directInteractive: Direct = (masked, from, to) => {
197
+ const code: string = masked.slice(from, to);
198
+ return RE_HANDLER.test(code) || RE_INTERACTIVE_COMP.test(code);
199
+ };
200
+
201
+ /** Whether code [from, to) of s draws anything that takes input: a handler or an interactive built-in (see rangeWalk). */
202
+ export function rangeInteractive(scans: FileScan[], s: FileScan, from: number, to: number, seen: Set<string> = new Set()): Tri {
203
+ return rangeWalk(scans, s, from, to, directInteractive, seen);
204
+ }
205
+
176
206
  /** `@BuilderParam X` of the struct wrapping pos: the struct, X's default builder (`= this.Y`), whether it is the only one. */
177
207
  function builderParamAt(s: FileScan, pos: number, name: string): { struct: string; def: string | null; only: boolean } | null {
178
208
  const masked: string = maskedOf(s);
@@ -214,12 +244,12 @@ function propValue(masked: string, from: number, to: number, name: string): [num
214
244
  * `this.X()` where X is a @BuilderParam: what the callers pass for X (`X: () => { this.b() }`, `X: this.b`, or the
215
245
  * trailing closure when X is the only one), else X's default builder. undefined when X is no @BuilderParam.
216
246
  */
217
- function builderParamInteractive(scans: FileScan[], s: FileScan, pos: number, name: string, seen: Set<string>): Tri | undefined {
247
+ function builderParamWalk(scans: FileScan[], s: FileScan, pos: number, name: string, direct: Direct, seen: Set<string>): Tri | undefined {
218
248
  const bp = builderParamAt(s, pos, name);
219
249
  if (bp === null) { return undefined; }
220
250
  const fallback = (): Tri => {
221
251
  const d: Body | null = bp.def === null ? null : builderBody(s, bp.def);
222
- return d === null ? false : rangeInteractive(scans, d.scan, d.open, d.close, seen);
252
+ return d === null ? false : rangeWalk(scans, d.scan, d.open, d.close, direct, seen);
223
253
  };
224
254
  const sites = structCallSites(scans, bp.struct);
225
255
  if (sites.length === 0) { return fallback(); }
@@ -231,11 +261,11 @@ function builderParamInteractive(scans: FileScan[], s: FileScan, pos: number, na
231
261
  if (v !== null) {
232
262
  const ref: RegExpMatchArray | null = site.scan.code.slice(v[0], v[1]).match(/^\s*this\.([A-Za-z_$][\w$]*)\s*$/);
233
263
  const b: Body | null = ref === null ? null : builderBody(site.scan, ref[1]);
234
- return b !== null ? rangeInteractive(scans, b.scan, b.open, b.close, seen) : rangeInteractive(scans, site.scan, v[0], v[1], seen);
264
+ return b !== null ? rangeWalk(scans, b.scan, b.open, b.close, direct, seen) : rangeWalk(scans, site.scan, v[0], v[1], direct, seen);
235
265
  }
236
266
  if (bp.only) {
237
267
  const blk: [number, number] | null = blockAfter(site.scan.code, site.paren);
238
- if (blk !== null) { return rangeInteractive(scans, site.scan, blk[0], blk[1], seen); }
268
+ if (blk !== null) { return rangeWalk(scans, site.scan, blk[0], blk[1], direct, seen); }
239
269
  }
240
270
  return fallback();
241
271
  }));
@@ -264,7 +294,25 @@ export function spansParent(attrs: UiAttr[], parent: UiAttr[], axis: 'width' | '
264
294
  }
265
295
 
266
296
  export type VerdictKind = 'safe' | 'swallows' | 'covers' | 'conditional' | 'unknown' | 'zindex' | 'unplaced' | 'unparsed';
267
- export type Verdict = { kind: VerdictKind; scan?: FileScan; at?: number; below?: string[] };
297
+ export type Verdict = { kind: VerdictKind; scan?: FileScan; at?: number; below?: string[]; scrollBelow?: string[]; scrollUnknown?: string[] };
298
+
299
+ /** Containers a user scrolls or swipes: a layer covering one of them is never meant to (`covers-below` does not apply). */
300
+ const RE_SCROLLABLE: RegExp = /(?<![\w$.])(?:Scroll|List|Grid|WaterFlow|Swiper|Refresh|Tabs|ArcList|ArcSwiper)\s*\(/g;
301
+
302
+ const directScrollable: Direct = (masked, from, to) => {
303
+ for (const m of masked.slice(from, to).matchAll(RE_SCROLLABLE)) {
304
+ if (!inAttrArgs(masked, from + (m.index ?? 0))) { return true; }
305
+ }
306
+ return false;
307
+ };
308
+
309
+ /**
310
+ * Whether code [from, to) of s draws a scrollable container, directly or through what it calls (`this.buildList()`,
311
+ * a global `listSection()`, `FeedList()` whose build() holds the List, a slot filled with a List): see rangeWalk.
312
+ */
313
+ export function rangeScrollable(scans: FileScan[], s: FileScan, from: number, to: number): Tri {
314
+ return rangeWalk(scans, s, from, to, directScrollable);
315
+ }
268
316
  const RANK: Record<VerdictKind, number> = { safe: 0, unplaced: 1, unknown: 2, zindex: 2, unparsed: 2, conditional: 3, covers: 3, swallows: 4 };
269
317
  const worst = (vs: Verdict[]): Verdict => vs.reduce((a, b) => (RANK[b.kind] > RANK[a.kind] ? b : a), { kind: 'safe' });
270
318
 
@@ -312,11 +360,15 @@ export function judgeLayer(scans: FileScan[], L: Layer, self: Self, conditional:
312
360
  const b: Tri = anyTri(parts);
313
361
  if (b === false) { return { kind: 'safe' }; }
314
362
  if (b === null) { return { kind: 'unknown', ...here }; }
315
- const names: string[] = below.filter((_, i) => parts[i] === true).map((k) => (k.isBuilderCall ? `this.${k.name}()` : k.name));
363
+ const label = (k: UiChild): string => (k.isBuilderCall ? `this.${k.name}()` : k.name);
364
+ const names: string[] = below.filter((_, i) => parts[i] === true).map(label);
316
365
  const mine: Tri = rangeInteractive(scans, self.scan, self.from, self.to);
317
366
  if (mine === null) { return { kind: 'unknown', ...here }; }
318
367
  if (cond || kids[n].branch === true) { return mine ? { kind: 'safe' } : { kind: 'conditional', ...here, below: names }; }
319
- return { kind: mine ? 'covers' : 'swallows', ...here, below: names };
368
+ const scroll: Tri[] = below.map((k, i) => (parts[i] === true ? rangeScrollable(scans, L.s, k.at, k.end) : false));
369
+ const scrollBelow: string[] = below.filter((_, i) => scroll[i] === true).map(label);
370
+ const scrollUnknown: string[] = below.filter((_, i) => scroll[i] === null).map(label);
371
+ return { kind: mine ? 'covers' : 'swallows', ...here, below: names, scrollBelow, scrollUnknown };
320
372
  }
321
373
  return judgeRoot(scans, L, self, cond, anc, seen);
322
374
  }
@@ -432,11 +484,20 @@ export function checkHitTest(scans: FileScan[]): void {
432
484
  ? 'size or place the layer so it does not cover them (a scrim meant for taps outside a sheet must lie outside it), ' +
433
485
  'or .hitTestBehavior(HitTestMode.Transparent) when a tap on this layer should reach them too'
434
486
  : '.hitTestBehavior(HitTestMode.None)';
435
- if (mark !== null && mark.disp === esc && hasBasis(mark.basis)) {
436
- report('CAND', 'fullsize-container', s.rel, line, `${m[1]}: ${REASON[v.kind]} ${below}${at}; marked HIT-TEST ${esc}: ${mark.basis}`);
487
+ // covers-below means "this layer is meant to hide what is under it" (a full-screen sheet over its own scrim);
488
+ // a scrollable sibling under it is content the user must reach, so the marker cannot close that GATE.
489
+ const scrolls: string[] = v.kind === 'covers' ? (v.scrollBelow ?? []) : [];
490
+ if (mark !== null && mark.disp === esc && hasBasis(mark.basis) && scrolls.length === 0) {
491
+ const unread: string[] = v.kind === 'covers' ? (v.scrollUnknown ?? []) : [];
492
+ const check: string = unread.length === 0 ? ''
493
+ : `; the checker cannot read whether ${unread.join(' / ')} scrolls: if it does, the marker does not hold (add .hitTestBehavior(HitTestMode.Transparent))`;
494
+ report('CAND', 'fullsize-container', s.rel, line, `${m[1]}: ${REASON[v.kind]} ${below}${at}; marked HIT-TEST ${esc}: ${mark.basis}${check}`);
437
495
  continue;
438
496
  }
439
- const wrong: string = mark === null ? '' : ` The marker HIT-TEST ${mark.disp} does not apply here (this case accepts only ${esc}, with a basis).`;
497
+ const wrong: string = mark === null ? ''
498
+ : scrolls.length > 0 && mark.disp === esc
499
+ ? ` The marker HIT-TEST ${esc} does not apply: it covers the scrollable ${scrolls.join(' / ')}, which must keep its taps and swipes; add .hitTestBehavior(HitTestMode.Transparent).`
500
+ : ` The marker HIT-TEST ${mark.disp} does not apply here (this case accepts only ${esc}, with a basis).`;
440
501
  report('GATE', 'fullsize-container', s.rel, line,
441
502
  `${m[1]}: ${REASON[v.kind]} ${below}${at}, taking their taps. Fix: ${fix}; or mark it // HIT-TEST: ${esc}: <basis> when that is the intent.${wrong}`);
442
503
  }
@@ -57,8 +57,8 @@ export const meta: RuleMeta[] = [
57
57
  invariant: "resources",
58
58
  card: "resources",
59
59
  needs: ["--resources"],
60
- summary: "被 `.fillColor()` 染色的 `app.media.*` 在任何资源限定目录下都只有位图(png/webp/jpg/bmp/gif),没有 SVG。",
61
- fix: "SDK:fillColor「仅对SVG图源生效…如需对png图片进行修改颜色,可以使用colorFilter」。去掉 fillColor,改用 `.colorFilter(new ColorFilter([0,0,0,0,r, 0,0,0,0,g, 0,0,0,0,b, 0,0,0,1,0]))`(r/g/b 取 0~1,保留 alpha,= Android `tint` / `ColorFilter SRC_IN`);或把该图标从 Android `<vector>` 转成 SVG。",
60
+ summary: "被 `.fillColor()` 染色的 `app.media.*` 在任何资源限定目录下都只有位图(png/webp/jpg/bmp/gif),没有 SVG;或有 SVG,但某个目录里只有同名位图、没有 SVG —— 限定目录(xxldpi/ 等)先于 base/ 匹配,SVG 所在目录都不匹配时用 base/,运行时拿到的是位图。",
61
+ fix: "SDK:fillColor「仅对SVG图源生效…如需对png图片进行修改颜色,可以使用colorFilter」;资源匹配「优先从相匹配的限定词目录中寻找…找不到时才会去base目录」。同名 SVG 在 base/ 时删掉限定目录里的同名位图(多为 Android 打包给矢量图生成的密度兜底 PNG);base/ 没有 SVG 时把 SVG 复制到 base/ 并删掉位图。只有位图时去掉 fillColor,改用 `.colorFilter(new ColorFilter([0,0,0,0,r, 0,0,0,0,g, 0,0,0,0,b, 0,0,0,1,0]))`(r/g/b 取 0~1,保留 alpha,= Android `tint` / `ColorFilter SRC_IN`);或把该图标从 Android `<vector>` 转成 SVG。",
62
62
  escape: null,
63
63
  cases: [],
64
64
  },
@@ -69,7 +69,9 @@ const RASTER_EXT: string[] = ['.png', '.webp', '.jpg', '.jpeg', '.bmp', '.gif'];
69
69
  /**
70
70
  * GATE fillcolor-on-raster-media: `.fillColor()` only works on SVG sources (SDK Image doc), so tinting a bitmap does nothing —
71
71
  * a white bitmap icon stays white on a light background. Resolution looks in **every** qualifier directory
72
- * (base/, xxldpi/, dark/ …): converted bitmaps usually land in density folders, not base/. A name that has an SVG anywhere is skipped.
72
+ * (base/, xxldpi/, dark/ …): converted bitmaps usually land in density folders, not base/. A name with an SVG is still
73
+ * reported when some directory holds a bitmap of it and no SVG: base/ (devices matching none of the SVG's qualifier
74
+ * dirs load that bitmap) or a qualifier dir (matched before base/, so it wins over a base/ SVG).
73
75
  */
74
76
  export function checkRasterTint(scans: FileScan[], resRoots: string[]): void {
75
77
  const mediaDirs: string[] = [];
@@ -85,13 +87,27 @@ export function checkRasterTint(scans: FileScan[], resRoots: string[]): void {
85
87
  }
86
88
  if (mediaDirs.length === 0) { return; }
87
89
  const files: Map<string, string[]> = new Map();
90
+ // name -> dirs (base/ included) that hold a bitmap of it and no SVG of it
91
+ const shadowing: Map<string, Set<string>> = new Map();
92
+ // name -> qualifier dirs (base/ included) that hold an SVG of it
93
+ const svgDirs: Map<string, Set<string>> = new Map();
88
94
  for (const d of mediaDirs) {
89
95
  let names: string[] = [];
90
96
  try { names = fs.readdirSync(d); } catch { continue; }
97
+ const q: string = path.basename(path.dirname(d));
98
+ const here: Map<string, string[]> = new Map();
91
99
  for (const f of names) {
92
100
  const ext: string = path.extname(f).toLowerCase();
93
101
  const name: string = path.basename(f, path.extname(f));
94
102
  files.set(name, [...(files.get(name) ?? []), ext]);
103
+ here.set(name, [...(here.get(name) ?? []), ext]);
104
+ }
105
+ for (const [name, exts] of here) {
106
+ if (exts.includes('.svg')) { svgDirs.set(name, (svgDirs.get(name) ?? new Set<string>()).add(q)); }
107
+ }
108
+ for (const [name, exts] of here) {
109
+ if (exts.includes('.svg') || !exts.some((e) => RASTER_EXT.includes(e))) { continue; }
110
+ shadowing.set(name, (shadowing.get(name) ?? new Set<string>()).add(q));
95
111
  }
96
112
  }
97
113
  for (const s of scans) {
@@ -99,6 +115,22 @@ export function checkRasterTint(scans: FileScan[], resRoots: string[]): void {
99
115
  const byLine: Map<number, string[]> = new Map();
100
116
  for (const t of s.tinted) {
101
117
  const exts: string[] = files.get(t.name) ?? [];
118
+ const shadow: Set<string> | undefined = shadowing.get(t.name);
119
+ if (exts.includes('.svg') && shadow !== undefined) {
120
+ // An SVG somewhere, a bitmap in a dir with no SVG: where that dir is the best match (a qualifier dir before
121
+ // base/; base/ when no SVG dir matches), the device resolves the bitmap. Name the SVG's real dirs: the remedy
122
+ // differs when base/ has none.
123
+ const svgs: string[] = [...(svgDirs.get(t.name) ?? [])].sort();
124
+ const bitmaps: string = [...shadow].sort().map((d) => `${d}/`).join(', ');
125
+ const remedy: string = svgs.includes('base')
126
+ ? `delete the bitmap in ${bitmaps}`
127
+ : `no SVG in base/: copy the SVG into base/ and delete the bitmap in ${bitmaps}, or drop fillColor`;
128
+ const label: string = `app.media.${t.name} (svg in ${svgs.map((d) => `${d}/`).join(', ')}; bitmap in ${bitmaps}: ${remedy})`;
129
+ const list: string[] = byLine.get(t.line) ?? [];
130
+ if (!list.includes(label)) { list.push(label); }
131
+ byLine.set(t.line, list);
132
+ continue;
133
+ }
102
134
  if (exts.length === 0 || exts.includes('.svg')) { continue; }
103
135
  const raster: string[] = [...new Set(exts.filter((e) => RASTER_EXT.includes(e)))];
104
136
  if (raster.length === 0) { continue; }
@@ -109,9 +141,11 @@ export function checkRasterTint(scans: FileScan[], resRoots: string[]): void {
109
141
  }
110
142
  for (const [line, labels] of byLine) {
111
143
  report('GATE', 'fillcolor-on-raster-media', s.rel, line,
112
- `.fillColor() is used on ${labels.join(', ')}, which exist only as bitmaps — fillColor only applies to SVG ` +
144
+ `.fillColor() is used on ${labels.join(', ')}, which resolve to bitmaps on a device (only bitmaps, or a bitmap ` +
145
+ 'in a directory the device matches before the SVG) — fillColor only applies to SVG ' +
113
146
  'sources (SDK Image doc), so the icon keeps the colour baked into the bitmap. ' +
114
- 'Use .colorFilter(new ColorFilter([0,0,0,0,r, 0,0,0,0,g, 0,0,0,0,b, 0,0,0,1,0])) (r/g/b in 0~1, keeps alpha, = Android tint), ' +
147
+ 'Where an SVG exists, follow the note next to it (qualifier-dir bitmaps are mostly vector density fallbacks); otherwise ' +
148
+ 'use .colorFilter(new ColorFilter([0,0,0,0,r, 0,0,0,0,g, 0,0,0,0,b, 0,0,0,1,0])) (r/g/b in 0~1, keeps alpha, = Android tint), ' +
115
149
  'or convert the icon from the Android <vector> to SVG');
116
150
  }
117
151
  }
@@ -174,6 +174,47 @@ ${mark} Column() { TextInput() }
174
174
  assert.deepEqual(hits(marked, 'fullsize-container').map((x) => x.sev), ['CAND']);
175
175
  });
176
176
 
177
+ test('covers-below does not close a layer over a scrollable sibling: a bottom-bar wrapper over the list stays GATE', () => {
178
+ const body = (mark) => ` Stack() {
179
+ Scroll() { Column() { Text('a').onClick(() => {}) } }
180
+ .width('100%')
181
+ .height('100%')
182
+ ${mark} Column() { Row() { Button('ok') } }
183
+ .width('100%')
184
+ .height('100%')
185
+ .justifyContent(FlexAlign.End)
186
+ }`;
187
+ const marked = run({ 'pages/P.ets': page(body(' // HIT-TEST: covers-below: the bottom bar is meant to sit over the list\n')) });
188
+ const h = hits(marked, 'fullsize-container');
189
+ assert.deepEqual(h.map((x) => x.sev), ['GATE']);
190
+ assert.match(marked, /covers the scrollable Scroll/);
191
+ });
192
+
193
+ test('covers-below over a list drawn by a @Builder call stays GATE; a List( in a string or comment does not count', () => {
194
+ const MARK = ' // HIT-TEST: covers-below: the bottom bar is meant to sit over the content\n';
195
+ const layer = `${MARK} Column() { Row() { Button('ok') } }
196
+ .width('100%')
197
+ .height('100%')
198
+ .justifyContent(FlexAlign.End)
199
+ `;
200
+ const viaBuilder = run({ 'pages/P.ets': page(` Stack() {
201
+ this.buildList()
202
+ ${layer} }`, ` @Builder buildList() {
203
+ List() { ListItem() { Text('a').onClick(() => {}) } }
204
+ .width('100%')
205
+ .height('100%')
206
+ }`) });
207
+ assert.deepEqual(hits(viaBuilder, 'fullsize-container').map((x) => x.sev), ['GATE']);
208
+ assert.match(viaBuilder, /covers the scrollable this\.buildList\(\)/);
209
+ const inText = run({ 'pages/P.ets': page(` Stack() {
210
+ // List (old layout) used to live here
211
+ Column() { Text('List (empty)').onClick(() => {}) }
212
+ .width('100%')
213
+ .height('100%')
214
+ ${layer} }`) });
215
+ assert.deepEqual(hits(inText, 'fullsize-container').map((x) => x.sev), ['CAND']);
216
+ });
217
+
177
218
  test('a component from a package below or inside the layer leaves it a candidate', () => {
178
219
  const out = run({ 'pages/P.ets': `import { MapView } from '@ohos/map';
179
220
  ` + page(` Stack() {
@@ -413,3 +454,44 @@ test('a HIT-TEST marker in a CRLF file is read', () => {
413
454
  const crlf = page(body).split(String.fromCharCode(10)).join(String.fromCharCode(13, 10));
414
455
  assert.deepEqual(hits(run({ 'pages/P.ets': crlf }), 'fullsize-container').map((x) => x.sev), ['CAND']);
415
456
  });
457
+
458
+ test('covers-below over a slot filled with a List, or a global @Builder function drawing one, stays GATE', () => {
459
+ const MARK = ' // HIT-TEST: covers-below: the bottom bar is meant to sit over the content\n';
460
+ const layer = `${MARK} Column() { Row() { Button('ok') } }
461
+ .width('100%')
462
+ .height('100%')
463
+ .justifyContent(FlexAlign.End)
464
+ `;
465
+ const slot = run({
466
+ 'common/Panel.ets': `@ComponentV2
467
+ export struct Panel {
468
+ @BuilderParam content: () => void
469
+ build() {
470
+ Stack() {
471
+ Column() { this.content() }
472
+ .width('100%')
473
+ .height('100%')
474
+ ${layer} }
475
+ }
476
+ }
477
+ `,
478
+ 'pages/P.ets': `import { Panel } from '../common/Panel'
479
+ ` + page(` Panel() {
480
+ List() { ListItem() { Text('a').onClick(() => {}) } }
481
+ }`),
482
+ });
483
+ assert.deepEqual(hits(slot, 'fullsize-container').map((x) => x.sev), ['GATE']);
484
+ assert.match(slot, /covers the scrollable/);
485
+ const global = run({ 'pages/P.ets': `@Builder
486
+ function listSection() {
487
+ List() { ListItem() { Text('a').onClick(() => {}) } }
488
+ .width('100%')
489
+ .height('100%')
490
+ }
491
+
492
+ ` + page(` Stack() {
493
+ listSection()
494
+ ${layer} }`) });
495
+ assert.deepEqual(hits(global, 'fullsize-container').map((x) => x.sev), ['GATE']);
496
+ assert.match(global, /covers the scrollable listSection/);
497
+ });