@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.
- package/agents/a2h-executor.md +37 -0
- package/env-requirements.json +15 -1
- package/i18n/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +2 -2
- package/i18n/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +1 -1
- package/i18n/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +13 -6
- package/i18n/skills/a2h-app-migrate/SKILL.md +2 -2
- package/i18n/skills/a2h-app-migrate/references/workflow.yaml +27 -4
- package/i18n/skills/a2h-app-migrate/scripts/opencode_depth.mjs +418 -0
- package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
- package/i18n/skills/a2h-batch-ui-align/SKILL.md +7 -7
- package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -1
- package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +20 -2
- package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +2 -2
- package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +3 -3
- package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +3 -1
- package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +2 -2
- package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +10 -6
- package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +13 -9
- package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +59 -7
- package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/interactions.mjs +186 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +33 -7
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +83 -22
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +39 -5
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +25 -1
- package/i18n/skills/a2h-page-specgen/SKILL.md +1 -1
- package/i18n/skills/a2h-page-specgen/references/gates.md +3 -1
- package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +11 -11
- package/i18n/skills/a2h-page-specgen/references/spec-template.md +3 -3
- package/i18n/skills/a2h-page-specgen/scripts/contract-calls.mjs +40 -3
- package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +73 -5
- package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +144 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +10 -10
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +1 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +11 -11
- package/i18n/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +45 -1
- package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +100 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +132 -3
- package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +36 -1
- package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +1 -1
- package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +16 -0
- package/i18n/skills/a2h-utg-static/SKILL.md +2 -0
- package/package.json +1 -1
- package/platforms/atomcode/agents/a2h-executor.frontmatter.md +6 -0
- package/platforms/codebuddy/agents/a2h-executor.frontmatter.md +5 -0
- package/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +2 -2
- package/platforms/deveco/agents/a2h-executor.frontmatter.md +7 -0
- package/platforms/deveco/agents/build-fixer.frontmatter.md +0 -2
- package/platforms/deveco/agents/code-reviewer.frontmatter.md +0 -2
- package/platforms/deveco/agents/model-render-worker.frontmatter.md +0 -2
- package/platforms/deveco/agents/model-worker.frontmatter.md +0 -2
- package/platforms/deveco/agents/specgen-worker.frontmatter.md +0 -2
- package/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +1 -1
- package/platforms/opencode/agents/a2h-executor.frontmatter.md +7 -0
- package/platforms/opencode/agents/build-fixer.frontmatter.md +0 -2
- package/platforms/opencode/agents/code-reviewer.frontmatter.md +0 -2
- package/platforms/opencode/agents/model-render-worker.frontmatter.md +0 -2
- package/platforms/opencode/agents/model-worker.frontmatter.md +0 -2
- package/platforms/opencode/agents/specgen-worker.frontmatter.md +0 -2
- package/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +13 -6
- package/skills/a2h-app-migrate/SKILL.md +29 -3
- package/skills/a2h-app-migrate/references/host-rules.md +33 -0
- package/skills/a2h-app-migrate/references/workflow.yaml +24 -4
- package/skills/a2h-app-migrate/scripts/opencode_depth.mjs +418 -0
- package/skills/a2h-app-migrate/test/test_executor_header_sync.mjs +78 -0
- package/skills/a2h-app-migrate/test/test_opencode_depth.mjs +312 -0
- package/skills/a2h-app-migrate/tools/dag.mjs +267 -0
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -0
- package/skills/a2h-batch-ui-align/SKILL.md +7 -7
- package/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -1
- package/skills/a2h-batch-ui-align/references/cards/state.md +20 -2
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +2 -2
- package/skills/a2h-batch-ui-align/references/checker-rules.md +3 -3
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +3 -1
- package/skills/a2h-batch-ui-align/references/host-dispatch.md +5 -5
- package/skills/a2h-batch-ui-align/references/incremental-scope.md +2 -2
- package/skills/a2h-batch-ui-align/references/step3-capture.md +10 -6
- package/skills/a2h-batch-ui-align/references/step5-convert.md +13 -9
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +59 -7
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -0
- package/skills/a2h-batch-ui-align/scripts/group_pass.mjs +3 -2
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +139 -23
- package/skills/a2h-batch-ui-align/scripts/host_env.mjs +32 -8
- package/skills/a2h-batch-ui-align/scripts/interactions.mjs +186 -0
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +33 -7
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +83 -22
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +39 -5
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +82 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +25 -1
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +184 -2
- package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +33 -0
- package/skills/a2h-batch-ui-align/scripts/tests/interactions.test.mjs +258 -0
- package/skills/a2h-page-specgen/SKILL.md +1 -1
- package/skills/a2h-page-specgen/references/evidence.md +15 -0
- package/skills/a2h-page-specgen/references/gates.md +3 -1
- package/skills/a2h-page-specgen/references/scenario-authoring.md +10 -10
- package/skills/a2h-page-specgen/references/spec-template.md +2 -2
- package/skills/a2h-page-specgen/scripts/contract-calls.mjs +40 -3
- package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +73 -5
- package/skills/a2h-page-specgen/scripts/gate.mjs +141 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +1 -1
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +10 -10
- package/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +45 -1
- package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +100 -0
- package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +104 -3
- package/skills/a2h-resource-convert/references/conversion-rules.md +2 -0
- package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +36 -1
- package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +42 -0
- package/skills/a2h-spec-design-pipeline/SKILL.md +1 -1
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +16 -0
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +2 -2
- package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +5 -1
- 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/document/checker/hometrans/arkui-runtime-pitfall-cn.md +2 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +3 -1
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-v2-observation-cn.md +105 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-v2-observation-en.md +122 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +4 -4
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIV2ObservationCheck.js +1862 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +2 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +1 -1
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +15 -2
- package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +20 -4
- package/skills/a2h-spec-design-pipeline/scripts/test_arkui_v2_observation.ts +284 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +32 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +22 -1
- package/skills/a2h-utg-static/SKILL.md +2 -0
- package/skills/a2h-utg-static/references/extractors.md +16 -0
- package/skills/a2h-utg-static/scripts/run_pipeline.mjs +22 -1
- package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +4 -0
- package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +15 -0
- package/skills/a2h-utg-static/scripts/tests/test_view_attachments.mjs +330 -0
- package/skills/a2h-utg-static/scripts/view_attachments.mjs +465 -0
- package/platforms/codebuddy/agents/build-fixer.frontmatter.md +0 -5
- package/platforms/codebuddy/agents/code-reviewer.frontmatter.md +0 -5
- package/platforms/codebuddy/agents/model-render-worker.frontmatter.md +0 -5
- package/platforms/codebuddy/agents/model-worker.frontmatter.md +0 -5
- package/platforms/codebuddy/agents/specgen-worker.frontmatter.md +0 -5
|
@@ -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
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
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 {
|
|
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
|
-
|
|
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 degraded 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: "a node `'100%'` in width and height (in a `Stack`/`RelativeContainer`, an axis written with the parent's own size expression counts too) with no `hitTestBehavior` that the checker cannot prove, from the layer structure, leaves the taps below it alone. Nodes it can prove (taking input itself, a non-layered parent, nothing clickable below, a page root) are no longer listed. Any `hitTestBehavior` (`Block` / `Default` included) counts as the author's explicit choice and is out of scope.",
|
|
38
|
-
fix: "GATE \"conditional overlay\": while shown it covers clickable elements below it. When blocking input is the intent (loading mask, modal layer) write the downgrade marker `// HIT-TEST: blocks-input: <basis>`; otherwise add `.hitTestBehavior(HitTestMode.None)`. GATE \"layer whose children take input\": its own area covers clickable elements below it; size or place it so it does not, or add `.hitTestBehavior(HitTestMode.Transparent)` when a tap on it should reach them too; when covering the lower layer is the intent (a full-screen sheet over its own scrim) write `// HIT-TEST: covers-below: <basis
|
|
38
|
+
fix: "GATE \"conditional overlay\": while shown it covers clickable elements below it. When blocking input is the intent (loading mask, modal layer) write the downgrade marker `// HIT-TEST: blocks-input: <basis>`; otherwise add `.hitTestBehavior(HitTestMode.None)`. GATE \"layer whose children take input\": its own area covers clickable elements below it; size or place it so it does not, or add `.hitTestBehavior(HitTestMode.Transparent)` when a tap on it should reach them too; when covering the lower layer is the intent (a full-screen sheet over its own scrim) write `// HIT-TEST: covers-below: <basis>`; the marker does not apply when a covered sibling is a scrollable container (Scroll / List / Grid / WaterFlow / Swiper …): only a code fix closes it. CAND (a component outside the scanned files drawn by it or below it, `zIndex` reordering, no call site found): the checker cannot decide it; check it under \"Interaction Reachability Evidence\".",
|
|
39
39
|
escape: "// HIT-TEST: <blocks-input|covers-below>:",
|
|
40
40
|
cases: [
|
|
41
41
|
"Same incident: the old fullsize-container was only a lexical candidate, often listing 5-10 nodes per page; the report closed them in one sentence (\"all background extension layers\") and missed the one layer that really swallowed taps.",
|
|
@@ -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
|
|
141
|
-
*
|
|
142
|
-
* a package that is not among the scanned files
|
|
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
|
|
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
|
-
|
|
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(
|
|
177
|
+
if (b !== null) { parts.push(walk(b)); continue; }
|
|
163
178
|
// A @BuilderParam draws what the callers pass in.
|
|
164
|
-
const bp: Tri | undefined =
|
|
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])) {
|
|
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(
|
|
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
|
|
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 :
|
|
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 ?
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
436
|
-
|
|
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 ? ''
|
|
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: "the `app.media.*` tinted by `.fillColor()` exists only as a bitmap (png/webp/jpg/bmp/gif) in every resource qualifier directory, with no SVG.",
|
|
61
|
-
fix: "SDK: fillColor \"only applies to SVG sources … use colorFilter to recolour png images\".
|
|
60
|
+
summary: "the `app.media.*` tinted by `.fillColor()` exists only as a bitmap (png/webp/jpg/bmp/gif) in every resource qualifier directory, with no SVG; or it has an SVG but some directory holds a same-named bitmap and no SVG — a qualifier directory (xxldpi/ …) is matched before base/, and base/ is used when none of the SVG's directories match, so the device loads the bitmap.",
|
|
61
|
+
fix: "SDK: fillColor \"only applies to SVG sources … use colorFilter to recolour png images\"; resource matching \"looks in the matching qualifier directory first … base only when none matches\". With the SVG in base/, delete the same-named bitmaps in qualifier directories (usually density fallback PNGs Android generated for a vector); with no SVG in base/, copy the SVG into base/ and delete the bitmaps. With bitmaps only, drop fillColor and 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` / `ColorFilter SRC_IN`); or convert the icon from the Android `<vector>` to 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
|
|
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
|
|
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
|
-
'
|
|
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
|
}
|
|
@@ -172,12 +172,36 @@ test('fillcolor_on_bitmap_in_density_folder_is_gate', () => {
|
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
test('fillcolor_on_svg_or_unknown_media_is_clean', () => {
|
|
175
|
-
const svg = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'base/ic_a.svg': SVG
|
|
175
|
+
const svg = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'base/ic_a.svg': SVG });
|
|
176
|
+
const both = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'base/ic_a.svg': SVG, 'xxldpi/ic_a.svg': SVG });
|
|
176
177
|
const missing = run({ 'pages/P.ets': tinted("$r('app.media.ic_none')") });
|
|
177
178
|
assert.deepEqual(hits(svg, 'fillcolor-on-raster-media'), []);
|
|
179
|
+
assert.deepEqual(hits(both, 'fillcolor-on-raster-media'), []);
|
|
178
180
|
assert.deepEqual(hits(missing, 'fillcolor-on-raster-media'), []);
|
|
179
181
|
});
|
|
180
182
|
|
|
183
|
+
test('fillcolor_on_base_svg_shadowed_by_a_density_bitmap_is_gate', () => {
|
|
184
|
+
// resources are matched qualifier dir first, base/ last: an xxldpi device loads the png, which fillColor cannot tint
|
|
185
|
+
const out = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'base/ic_a.svg': SVG, 'xxldpi/ic_a.png': 'x' });
|
|
186
|
+
assert.deepEqual(hits(out, 'fillcolor-on-raster-media'), [{ sev: 'GATE', at: 'pages/P.ets:11' }]);
|
|
187
|
+
assert.match(out, /svg in base\/; bitmap in xxldpi\/: delete the bitmap in xxldpi\//);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test('fillcolor_on_qualifier_svg_with_a_base_bitmap_is_gate', () => {
|
|
191
|
+
// svg only in xxldpi/, a bitmap in base/: a device that does not match xxldpi loads the base png
|
|
192
|
+
const out = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'xxldpi/ic_a.svg': SVG, 'base/ic_a.png': 'x' });
|
|
193
|
+
assert.deepEqual(hits(out, 'fillcolor-on-raster-media'), [{ sev: 'GATE', at: 'pages/P.ets:11' }]);
|
|
194
|
+
assert.ok(out.includes('svg in xxldpi/; bitmap in base/: no SVG in base/: copy the SVG into base/'), out);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test('fillcolor_shadow_hint_names_the_real_svg_dir', () => {
|
|
198
|
+
// svg only in dark/: a light-mode xxldpi device loads the png; deleting it alone would leave no base/ copy
|
|
199
|
+
const out = run({ 'pages/P.ets': tinted("$r('app.media.ic_a')") }, { 'dark/ic_a.svg': SVG, 'xxldpi/ic_a.png': 'x' });
|
|
200
|
+
assert.deepEqual(hits(out, 'fillcolor-on-raster-media'), [{ sev: 'GATE', at: 'pages/P.ets:11' }]);
|
|
201
|
+
assert.match(out, /svg in dark\/; bitmap in xxldpi\/: no SVG in base\/: copy the SVG into base\//);
|
|
202
|
+
assert.doesNotMatch(out, /svg in base\//);
|
|
203
|
+
});
|
|
204
|
+
|
|
181
205
|
// ---------------------------------------------------------------- review fixes
|
|
182
206
|
|
|
183
207
|
test('a_qualifier_whose_media_is_a_file_does_not_crash_the_checker', () => {
|
|
@@ -244,7 +244,7 @@ coverage. Only a run that produced no SPEC at all aborts. See
|
|
|
244
244
|
## Gates
|
|
245
245
|
|
|
246
246
|
- **G1:** Exactly one SPEC per page in a new run, exactly one page per SPEC, no extra SPECs, and coverage of every page
|
|
247
|
-
- **G2:** H1 is `# <title> SPEC` (one space before SPEC), there is at least one scenario, scenario headings are numbered in draft order, and the final section is `## Android Code Reference`. An `Implementation Contract` heading is rejected. Any declared page-level `contracts` container is rejected (even `{"endpoints": []}`), every non-empty but unusable `scenarios[].contracts` declaration is an error (a non-`rules` entry must yield a fact token), and every fact token of a usable declaration must appear in that scenario's `steps`, matched on token boundaries so `10` does not stand in for `1` or `0` (the authoring pass merges facts naturally; the gate proves nothing was dropped); a rule's numeric literals count as fact tokens, normalized to the shape the steps state them (thousands grouping, a sign written in words, an exponent written out), while a literal that only states how a value is printed (a zero-padded field width, a decimal-place count) is not required. Keeping the existing step count and order is a review item, not a gate claim
|
|
247
|
+
- **G2:** H1 is `# <title> SPEC` (one space before SPEC), there is at least one scenario, scenario headings are numbered in draft order, and the final section is `## Android Code Reference`. An `Implementation Contract` heading is rejected. Any declared page-level `contracts` container is rejected (even `{"endpoints": []}`), every non-empty but unusable `scenarios[].contracts` declaration is an error (a non-`rules` entry must yield a fact token), and every fact token of a usable declaration must appear in that scenario's `steps`, matched on token boundaries so `10` does not stand in for `1` or `0` (the authoring pass merges facts naturally; the gate proves nothing was dropped); a rule's numeric literals count as fact tokens, normalized to the shape the steps state them (thousands grouping, a sign written in words, an exponent written out), while a literal that only states how a value is printed (a zero-padded field width, a decimal-place count) is not required. When a scenario declares at least one `in: "query"` or `in: "body"` parameter, its steps must contain the four-label field table (`field:` / `type/encoding:` / `default:` / `send:`), one row per query/body parameter, with `send:` starting with required/optional/never; a path/header-only endpoint (no query/body params) is exempt. When steps describe a request body (POST/PUT/PATCH + URL + request body/request parameters/form) or carry a field table without a declared body contract, G2 emits a warning; an explicit "carries no request body" statement closes it. Keeping the existing step count and order is a review item, not a gate claim
|
|
248
248
|
- **G3:** The body contains no `file:line` (a scheme-qualified URL with `:port` is a URL, not an anchor), project symbol-table matches (except names the gate requires as fact tokens), framework type names, `dp/sp/px`/`dip` (bare or with a number), `#hex`, or assignment/comparison expressions. The same rules apply to steps carrying merged endpoint, key, field, and rule facts: write them as ordinary sentences ("the code field is 1001"), never as `key=value` assignments
|
|
249
249
|
- **G4:** Coverage: for behavior-enabled pages, assertion links are the primary authoring-coverage contract, and every planned assertion must have a valid explicit `coverage.behaviors` link (with valid scenario/step indices, a restated navigation gate, a legal waiver, or a related unresolved unknown) that passes semantic review. The legacy UTG denominator remains a secondary check: every `out_edges` entry and every `is_trigger` widget is claimed by a scenario (verified with `claim_token`) or has a reason recorded in `excluded`; an `edges` claim may carry its own `claim_token` when the derived token would be meaningless (Compose route, overlay name), and that token is matched verbatim in the scenario; an interaction signal follows its interaction-signal candidate disposition instead — promoted → claim, waived → exclusion, unknown or unfinished → partial with neither
|
|
250
250
|
- **G5:** Every `file:line` in `anchors` actually exists under `<source-project>` and has a valid line number
|
|
@@ -17,7 +17,7 @@ This document defines the gate identifiers enforced by a2h-page-specgen (`script
|
|
|
17
17
|
| G7 | For page SPECs, the difference between `est(P)` and the actual scenario count exceeds 2×; shared SPECs are exempt because their fixed `est` is not a scenario estimate | Add a G7 entry to `warnings` and record it in `report.md` |
|
|
18
18
|
| G8 | `deps` is non-empty but has no non-empty `deps_reason` entry | Add a G8 entry to `warnings` and record it in `report.md` |
|
|
19
19
|
|
|
20
|
-
**Request
|
|
20
|
+
**Request field tables are step text.** A table whose rows carry four labels (`field:` / `type/encoding:` / `default:` / `send:`) lives inside the request step, so G2, G3 and G6 read it as that step's own text: the parameter-name, default and value-source tokens that `contracts.endpoints[].params` declares must appear inside the table; G3's prose rules apply to every table line (a path glued to `:0` reads as a `file:line`, and `default=false` reads as an assignment); and the step keeps its single `- N. ` marker with the table as a top-level fenced block. **G2 requires this table when the scenario declares at least one `in: "query"` or `in: "body"` parameter**: one row per query/body field, and `send:` starts with `required` / `optional` / `never`; a path/header-only endpoint is exempt. When no query/body contract is declared but a step still describes a request body (or carries a table), G2 emits a warning; an explicit "carries no request body" statement closes it.
|
|
21
21
|
|
|
22
22
|
**Core gates**: G3, G4, and G5 are the core gates.
|
|
23
23
|
- **G3** ensures that the SPEC describes implementable business behavior rather than restating source code.
|
|
@@ -332,6 +332,8 @@ After drafting, review the following checklist:
|
|
|
332
332
|
- [ ] G3: The strict body rules also hold in steps carrying merged endpoint, key, field, and rule facts; no exempt zone exists.
|
|
333
333
|
- [ ] G2: No `Implementation Contract` heading at any level is present; facts are merged into the consuming steps.
|
|
334
334
|
- [ ] G2: Non-empty page-level `contracts` is absent — any declared container counts, even `{"endpoints": []}`; every non-empty `scenarios[].contracts` declaration is usable and every fact token (URL, method, parameter name, response field, key, default, enum value, field name, unit) appears in that scenario's steps, and every numeric enum value appears as its own value (`10` does not cover `1` or `0`).
|
|
335
|
+
- [ ] G2: A scenario that declares an `in: "query"` or `in: "body"` parameter carries the four-label field table (`field:` / `type/encoding:` / `default:` / `send:`), one row per query/body field, with `send:` starting with required/optional/never; a path/header-only endpoint needs no table.
|
|
336
|
+
- [ ] G2 (warn-only): a step that describes a request body (POST/PUT/PATCH + URL + request body/request parameters/form) or carries a field table without any `scenarios[].contracts.endpoints` body contract is warned; an explicit "carries no request body" closes it.
|
|
335
337
|
- [ ] G2: The merge rewrote step text without deleting, merging, reordering, or renumbering existing steps (append-only at the end); the gate cannot verify this, so it is a review item.
|
|
336
338
|
- [ ] Contracts: Enumerations are complete, with no vague endings such as "etc." or "and so on"; every numeric literal in a rule statement that the rule can be wrong about (coefficient, offset, threshold, enum value) appears in the consuming steps in the shape the steps state it (a thousands separator groups, a sign is written in words, an exponent is written out), while display-only literals (field width, decimal-place count) are not required; non-numeric rule prose is checked against the steps by review.
|
|
337
339
|
- [ ] G4: For behavior-enabled pages, `discovery.json` contains every immutable assertion unchanged plus only validated semantic additions.
|
|
@@ -187,18 +187,18 @@ Review every lifecycle-signal candidate and choose one of three: a user-observab
|
|
|
187
187
|
|
|
188
188
|
Timing wording follows the source: "refreshes immediately" when it takes effect on completion, "re-read on return" or "re-read on next entry" when it waits until the page is visible again — never mix the two. An axis scenario's trigger sequence starts from the timing event, and its last step lands on an assertable observable outcome.
|
|
189
189
|
|
|
190
|
-
## Request
|
|
190
|
+
## Request Parameters and Responses
|
|
191
191
|
|
|
192
|
-
When a scenario performs a network request, write the request body as a **tree-shaped field table inside the request step that sends it
|
|
192
|
+
When a scenario performs a network request, write the request parameters (`query` and `body`) as a **tree-shaped field table inside the request step that sends it**; list path parameters and request headers explicitly with their `in`. Write the response key by key.
|
|
193
193
|
|
|
194
194
|
The table has four fixed, labelled segments in a fixed order and is a top-level fenced code block, so every renderer keeps its line breaks:
|
|
195
195
|
|
|
196
196
|
```text
|
|
197
|
-
<Request
|
|
197
|
+
<Request parameter name>
|
|
198
198
|
├─ field:<path> type/encoding:<type> default:<value> send:<rule>
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
-
- **Write every key**: list each key of the source's request
|
|
201
|
+
- **Write every key**: list each key of the source's request construction (`query` or `body`), including keys that are **always the default**, **always sent**, or **never sent on this page**; dropping one is a failure, and fields may not be picked by scenario. **A field with a default is not necessarily sent** — whether it appears must be confirmed from the source's serializer or request-construction site.
|
|
202
202
|
- `field:` a top-level field is written with its plain name; a nested leaf is `a.b`; an array element is `a[].b`; the array itself is `a[]` (type `array<T>`). A parent object appears together with its children; give it its own `object` row only when the parent itself carries a send rule.
|
|
203
203
|
- `type/encoding:` only the closed vocabulary `string`, `int`, `int64`, `float`, `double`, `bool`, `object`, `array<T>`; put a time format, a byte encoding or a radix in parentheses (`string(yyyy-MM-dd HH:mm)`, `string(Base64)`, `int(>=1)`). Never write "text" or "number" as loose prose, and keep the token byte-identical to the contract's `type`.
|
|
204
204
|
- `default:` `—` means the field has no default value; strings are quoted; write only the value, never whether the key is sent.
|
|
@@ -206,22 +206,22 @@ The table has four fixed, labelled segments in a fixed order and is a top-level
|
|
|
206
206
|
- `required`: the key is always present. Stop there when a missing source value is a defect; add ", falls back to the default" when the default fills it, and name the source or failure when it matters, for example ", falls back to the default unknown when it cannot be read";
|
|
207
207
|
- `optional`: the key may be absent, immediately followed by a decidable condition written as ", not sent when <condition>" or ", sent only when <condition>", for example ", not sent when it has no value", ", not sent when the array is empty", ", not sent when it equals the default 0", ", not sent when the source cannot be determined", ", not sent when the user specifies no insert position";
|
|
208
208
|
- `never`: never appears; the field stays in the data model and is skipped when serializing.
|
|
209
|
-
- Whether a key is sent follows the source's serializer or request-construction site: a nullable field, a field with a default, and a model-required field do not mean "always sent"
|
|
209
|
+
- Whether a key is sent follows the source's serializer or request-construction site: a nullable field, a field with a default, and a model-required field do not mean "always sent", and `"nullable": false` only means the value cannot be empty. **None of these is equivalent to `required`** — a field with a default may be omitted when it equals the default, and may also always be sent.
|
|
210
210
|
- The condition must be writable as a single `if`: name a concrete condition such as "has no value", "the array is empty", "equals the default", "the control is off", "nothing is selected", "cannot be read", "the source cannot be determined". Never write "as needed", "depending on", "generally", "maybe"; list every condition separately instead of "except in special cases".
|
|
211
211
|
- `required` and `optional` differ only in whether the key is always present; the `default:` segment says what value fills a missing value and never whether the key appears, so the two segments never substitute for each other. A boolean that uses `false` for "the user set nothing" must say "not sent when it equals the default false", not "not sent when it has no value".
|
|
212
212
|
- When writing a condition, "no value" means unassigned or `null`; for strings and arrays a length of 0 also counts as no value; `0` and `false` count as values.
|
|
213
|
-
- Start the step with an executable action, not a caption such as "the structure is as follows": "the request
|
|
213
|
+
- Start the step with an executable action, not a caption such as "the structure is as follows": "the request parameters are serialized field by field from the table below and then sent; the key order follows the table's row order and whether a key appears follows the send segment".
|
|
214
214
|
- Separate the segments with at least one space: the path after `field:` must not be glued to the next segment, or the path and `default:` read as a `file:line`; write `default:false`, never `default=false`; no table line starts with `#`.
|
|
215
|
-
- Name the table root in business terms (for example "sync request body"), never with the request type name from the source.
|
|
215
|
+
- Name the table root in business terms (for example "sync request body" or "weather query parameters"), never with the request type name from the source.
|
|
216
216
|
- When a field's value does not come from this page's input (local storage, the previous response, a fixed value, a computed value), add one line after the table naming each such field, for example: "Value sources: `userId` is the current signed-in user number in local storage, `deviceId` is the device identifier in local storage, and `payload` is the pending-queue record count." Fields fed by page input need no entry.
|
|
217
217
|
|
|
218
|
-
**Relation to the contracts.** Each table row is also declared once in that scenario's `contracts.endpoints[].params` with `in: "body"`, byte-identical. The contracts are the audited fact base: G2 compares every parameter name, default and value source against the step text, and one missing token fails the gate. The table is what the reader and the downstream coder see.
|
|
218
|
+
**Relation to the contracts.** Each table row is also declared once in that scenario's `contracts.endpoints[].params` with `in: "query"` or `in: "body"`, byte-identical. The contracts are the audited fact base: G2 compares every parameter name, default and value source against the step text, and one missing token fails the gate. The table is what the reader and the downstream coder see. Path parameters and headers are listed with their own `in` (no table required); key names, defaults and fixed values follow the source — never guess, and never drop a key that has a default.
|
|
219
219
|
|
|
220
220
|
**Response.** List one field path per string in `response_fields[]` (`current_temperature`, `hourly.temperatures[]`); the envelope (code/data/message), types, nullability and the handling of a missing or default-valued field go into that endpoint's `note` and are merged into the step — never into a `response_fields` element, because G2 requires each element to appear verbatim in the step.
|
|
221
221
|
|
|
222
222
|
**G2 checks verbatim.** A method, URL, parameter name, parameter default, value source or response field present in the contracts but absent from the steps fails the gate. The envelope, types, nullability and missing-value handling are outside that check and must still be written into the steps, not left in `contracts` alone.
|
|
223
223
|
|
|
224
|
-
When the same request appears in several scenarios, each scenario repeats the complete table; never write "same as above" or "see scenario 1". The send condition lives only in the table; the steps state the server behaviour or the user-visible result once the condition holds. When the body is an object or an array, state the nesting and every child key; never write "other fields", "etc.", or a single sample value.
|
|
224
|
+
When the same request appears in several scenarios, each scenario repeats the complete table; never write "same as above" or "see scenario 1". The send condition lives only in the table; the steps state the server behaviour or the user-visible result once the condition holds. When the body (or a nested query object) is an object or an array, state the nesting and every child key; never write "other fields", "etc.", or a single sample value.
|
|
225
225
|
|
|
226
226
|
## Platform-Neutral Body Text
|
|
227
227
|
|
|
@@ -317,9 +317,9 @@ Before submission, confirm all of the following:
|
|
|
317
317
|
- Numeric inputs state integer versus decimal and whether a negative value is accepted, with no “accepts digits only” standing in for the type; the decimal places, bounds, whitespace and invalid-character handling the source implements are written out, and no unimplemented constraint is written as existing behavior.
|
|
318
318
|
- Every data boundary names both sides — present (source and destination) and absent (what it does not carry, write or send, and where empty, missing or default goes); entries over one data set line up item by item, absent items are written out, and absence is never written as -1, 0 or an empty string.
|
|
319
319
|
- Every value answers where it comes from (including the field’s origin in the consuming code), how it is processed (including the inputs that change the result and the difference after they change), and where it is consumed; missing any of the three leaves the scenario incomplete.
|
|
320
|
-
- Every branch states how its condition is determined and both outcomes; every step traces to a source location or an evidence entry; whether a key is sent follows the source serializer, never
|
|
320
|
+
- Every branch states how its condition is determined and both outcomes; every step traces to a source location or an evidence entry; whether a key is sent follows the source serializer, never nullability (for example `"nullable": false`), a default value, or a model-required flag.
|
|
321
321
|
- Scenarios that create, read, update, or delete data, or synchronize state or data, list every affected piece of data and how it changes, with no vague “related data updates in sync.”
|
|
322
|
-
- Network scenarios write the request body as a field table inside the sending step, each row carrying the four labelled segments `field:`, `type/encoding:`, `default:` and `send:`; declare the same fields in `contracts.endpoints[].params`, list every value source that is not page input, start every send segment with `required`/`optional`/`never` and follow it with a decidable condition (never "as needed" or "depending on"), describe the response structure as fully as possible, and keep all of these facts in that same step.
|
|
322
|
+
- Network scenarios write the request parameters (`query` and `body`) as a field table inside the sending step, each row carrying the four labelled segments `field:`, `type/encoding:`, `default:` and `send:`; path parameters and headers are listed with their `in` (no table required); declare the same fields in `contracts.endpoints[].params`, list every value source that is not page input, start every send segment with `required`/`optional`/`never` and follow it with a decidable condition (never "as needed" or "depending on"), describe the response structure as fully as possible, and keep all of these facts in that same step.
|
|
323
323
|
- No vague phrase such as “handle all other errors uniformly” substitutes for concrete branches.
|
|
324
324
|
- Every scenario is independently readable, with no abbreviated cross-scenario references and no unsupported copy, branches, thresholds, or outcomes added to fill gaps.
|
|
325
325
|
- Each scenario is exactly one normal or one edge/boundary case, with no success/failure mix.
|
|
@@ -105,14 +105,14 @@ Percent encoding is **reversible** (`%` itself becomes `%25`, and the encoded re
|
|
|
105
105
|
|
|
106
106
|
| kind | Contents | Written into the steps as |
|
|
107
107
|
|---|---|---|
|
|
108
|
-
| `endpoints` | `operation_id` / `branch` / `state_version` (audit-only) / `name` / `method` / `url` / `params[]` (`in`∈`query`\|`path`\|`header`\|`body`, `name` / `type` / `required` / `default` / `source` / `note`) / `response_fields[]` / `timeouts[]` / `note` | The request step: method, complete URL, request headers and timeouts; the body as a field table whose rows carry four labels (`field:` / `type/encoding:` / `default:` / `send:`) plus a value-source line for fields not fed by this page's input; every response field. `operation_id`, `branch`, and `state_version` are not rendered |
|
|
108
|
+
| `endpoints` | `operation_id` / `branch` / `state_version` (audit-only) / `name` / `method` / `url` / `params[]` (`in`∈`query`\|`path`\|`header`\|`body`, `name` / `type` / `required` / `default` / `source` / `note`) / `response_fields[]` / `timeouts[]` / `note` | The request step: method, complete URL, request headers and timeouts; the query and body parameters as a field table whose rows carry four labels (`field:` / `type/encoding:` / `default:` / `send:`) plus a value-source line for fields not fed by this page's input; every response field. `operation_id`, `branch`, and `state_version` are not rendered |
|
|
109
109
|
| `stores` | `name` / `key` / `type` / `default` / `values[]` (strings or `{value, label}`) / `note` | The persistence step: key name, type, default, and every enum value — never "etc." |
|
|
110
110
|
| `entities` | `name` / `fields[]` (`name` / `type` / `nullable` / `unit` / `note`) / `note` | The display or computation step: the entity's business name and every field with its type, nullability, and unit |
|
|
111
111
|
| `rules` | `name` / `statement` | The step that performs the conversion or applies the boundary: an instruction that can be followed verbatim, carrying every numeric value the rule can be wrong about (a coefficient, an offset, a threshold, an enum value) |
|
|
112
112
|
|
|
113
113
|
**Request and response keys are written key by key.** A parameter's default and value source belong in its `default` and `source` fields (`default: 0`, `source: local storage`) and are merged into the request step; a nested key keeps its path in `name` (`data.list[].id`); a non-required parameter also states in its `note` when it is absent from the wire (e.g. “equals its default, so the request body omits it”) or that it is always sent with its default (“always sent, uses the default value”), and the request step carries that rule too so the coder does not turn a default value into a sent key; `response_fields[]` lists one field path per string (`current_temperature`, `hourly.temperatures[]`), while the envelope (code/data/message), types, nullability and missing-value handling go into the entry's `note` and the step text. An endpoint or parameter field outside the lists above, or a non-string `response_fields[]` item, is rejected by G2 because the fact base cannot carry it.
|
|
114
114
|
|
|
115
|
-
**The request body
|
|
115
|
+
**The request parameters (query and body) are a field table inside the request step.** Every row carries four labelled segments in a fixed order — `field:`, `type/encoding:`, `default:`, `send:` — and the table is a top-level fenced block whose row order is the serialization key order. The send segment starts with `required` (always present), `optional` (may be absent) or `never` (never present), followed by a decidable condition such as “, not sent when it equals the default 0”; a plain `required` means a missing source value is a defect, while “, falls back to the default” means the default fills it. A value-source line follows the table for every field not fed by this page's input. Each row must also be declared in `params[]` with the same `in` (`query` or `body`): the path goes after `field:` (`a.b` nested, `a[].b` for an array element), the type matches the table token verbatim, and the default/source hold the same values. A `params[]` entry missing from the table is reported by G2 as a missing field row. See `scenario-authoring.md`, “Request Parameters and Responses”, for the complete rule.
|
|
116
116
|
|
|
117
117
|
**The body language rules apply to the merged steps.** Contract-only syntax is no longer legal anywhere: no `dp`/`sp`/`px`/`dip` (with or without a number), no `#hex`, no `key=value` (write "the code field is 1001"), no framework type names, no `file:line`. Visual values are rewritten as business descriptions ("the size is large"). Data values keep their source spelling (`maxRows`, `countryName`, `temperaturePrefs`, `kmh`) because the coder must use the same names. A value the body rules forbid verbatim (`600dp`, `#FF5733`, `timezone=auto`, a framework type) is therefore rewritten, and G2 does not require it token by token.
|
|
118
118
|
|
|
@@ -180,7 +180,7 @@ Rendering rules (`scripts/render.mjs`, deterministic):
|
|
|
180
180
|
- The H1 is always `# <title> SPEC`—**there is one space before `SPEC`**.
|
|
181
181
|
- Scenario headings are always `## Scenario <N>` (one space after `##`, a digit after `Scenario`), ensuring that `countScenarios` matches them.
|
|
182
182
|
- Steps always use `- 1. ` / `- 2. ` numbering, one step per item. Implementation facts are already merged into the consuming steps; the renderer prints `steps` verbatim and never appends a contract section.
|
|
183
|
-
- A step may carry a fenced code block (the request-
|
|
183
|
+
- A step may carry a fenced code block (the request-parameter field table); the block's row order defines the serialization key order.
|
|
184
184
|
- `## Android Code Reference` is always the final section, with one `- <file:line>` per entry.
|
|
185
185
|
- Do not produce a `Deviations from Requirement` section.
|
|
186
186
|
- The filename is `<title>-SPEC.md` (characters in `title` that are unsuitable for filenames are replaced with `-`). Note that downstream `specTitle` comes from the H1 (after trimming, `<title> SPEC`, preserving the space in the middle), while `spec_stem` comes from the filename (`<title>-SPEC`). They differ only in the separator and do not need to be aligned.
|