@buaa_smat/hometrans 26.0.0 → 26.0.1

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 (147) hide show
  1. package/package.json +11 -82
  2. package/skills/a2h-arch-generate/scripts/module_create/hap/src/main/ets/pages/Index.ets +2 -2
  3. package/skills/a2h-arch-generate/scripts/module_create/har/src/main/ets/components/MainPage.ets +2 -2
  4. package/skills/a2h-arch-generate/scripts/module_create/hsp/src/main/ets/pages/Index.ets +2 -2
  5. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +1 -1
  6. package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +1 -1
  7. package/skills/a2h-batch-ui-align/references/step3-capture.md +3 -3
  8. package/skills/a2h-batch-ui-align/references/step4-prepare.md +1 -1
  9. package/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +11 -6
  10. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +59 -21
  11. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +3 -3
  12. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +1 -1
  13. package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +1 -1
  14. package/skills/a2h-utg-explorer/SKILL.md +1 -1
  15. package/skills/a2h-utg-explorer/references/architecture.md +2 -2
  16. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +36 -11
  17. package/skills/a2h-utg-explorer/scripts/device_health.mjs +91 -6
  18. package/skills/a2h-utg-explorer/scripts/final_utg.mjs +20 -2
  19. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +64 -8
  20. package/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
  21. package/skills/a2h-utg-explorer/scripts/recover.mjs +7 -1
  22. package/skills/a2h-utg-explorer/scripts/recover_b.mjs +8 -1
  23. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +89 -7
  24. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +173 -4
  25. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +82 -14
  26. package/skills/a2h-utg-static/SKILL.md +1 -1
  27. package/skills/a2h-utg-static/references/view-interactions.md +1 -1
  28. package/skills/a2h-utg-static/scripts/assemble.mjs +6 -3
  29. package/skills/a2h-utg-static/scripts/compose_body_text.mjs +23 -5
  30. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +29 -3
  31. package/skills/a2h-utg-static/scripts/compose_titles.mjs +10 -1
  32. package/skills/a2h-utg-static/scripts/label_resolve.mjs +51 -2
  33. package/skills/a2h-utg-static/scripts/static_prior.mjs +2 -1
  34. package/skills/a2h-utg-static/scripts/tests/_zipw.mjs +28 -0
  35. package/skills/a2h-utg-static/scripts/tests/probe_autoload.mjs +108 -0
  36. package/skills/a2h-utg-static/scripts/tests/probe_layout_fragments.mjs +90 -0
  37. package/skills/a2h-utg-static/scripts/tests/probe_unknown_scope.mjs +61 -0
  38. package/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
  39. package/skills/a2h-utg-static/scripts/tests/test_activity_alias_launcher.mjs +135 -0
  40. package/skills/a2h-utg-static/scripts/tests/test_activity_supertype_chain.mjs +106 -0
  41. package/skills/a2h-utg-static/scripts/tests/test_bottom_sheet_container.mjs +58 -0
  42. package/skills/a2h-utg-static/scripts/tests/test_branch_guard.mjs +19 -0
  43. package/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
  44. package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +103 -0
  45. package/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
  46. package/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
  47. package/skills/a2h-utg-static/scripts/tests/test_commit_scope.mjs +113 -0
  48. package/skills/a2h-utg-static/scripts/tests/test_compose_file_private_route.mjs +117 -0
  49. package/skills/a2h-utg-static/scripts/tests/test_compose_nested_graph.mjs +166 -0
  50. package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +108 -0
  51. package/skills/a2h-utg-static/scripts/tests/test_compose_route_holder_collision.mjs +112 -0
  52. package/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
  53. package/skills/a2h-utg-static/scripts/tests/test_custom_source_root.mjs +71 -0
  54. package/skills/a2h-utg-static/scripts/tests/test_defensive_null_guard.mjs +77 -0
  55. package/skills/a2h-utg-static/scripts/tests/test_dialog_orphan_entries.mjs +99 -0
  56. package/skills/a2h-utg-static/scripts/tests/test_dialog_page_owner.mjs +69 -0
  57. package/skills/a2h-utg-static/scripts/tests/test_dialogshow_builder_forms.mjs +96 -0
  58. package/skills/a2h-utg-static/scripts/tests/test_dialogshow_java_factory.mjs +37 -0
  59. package/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
  60. package/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
  61. package/skills/a2h-utg-static/scripts/tests/test_edge_dedupe_by_gesture.mjs +111 -0
  62. package/skills/a2h-utg-static/scripts/tests/test_edge_provenance_lint.mjs +70 -0
  63. package/skills/a2h-utg-static/scripts/tests/test_enclosing_gesture.mjs +69 -0
  64. package/skills/a2h-utg-static/scripts/tests/test_external_surface_roots.mjs +43 -0
  65. package/skills/a2h-utg-static/scripts/tests/test_find_package_indirect.mjs +67 -0
  66. package/skills/a2h-utg-static/scripts/tests/test_forwarding_wrapper.mjs +38 -0
  67. package/skills/a2h-utg-static/scripts/tests/test_fragment_containment.mjs +85 -0
  68. package/skills/a2h-utg-static/scripts/tests/test_fragment_helper_trigger.mjs +92 -0
  69. package/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
  70. package/skills/a2h-utg-static/scripts/tests/test_graph.mjs +55 -0
  71. package/skills/a2h-utg-static/scripts/tests/test_guard_clause.mjs +86 -0
  72. package/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
  73. package/skills/a2h-utg-static/scripts/tests/test_host_kind_by_chain.mjs +68 -0
  74. package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
  75. package/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
  76. package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +293 -0
  77. package/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
  78. package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +155 -0
  79. package/skills/a2h-utg-static/scripts/tests/test_interaction_sites.mjs +272 -0
  80. package/skills/a2h-utg-static/scripts/tests/test_item_data_instance.mjs +51 -0
  81. package/skills/a2h-utg-static/scripts/tests/test_kotlin_fn_spans.mjs +69 -0
  82. package/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
  83. package/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
  84. package/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
  85. package/skills/a2h-utg-static/scripts/tests/test_layout_declared_fragment.mjs +103 -0
  86. package/skills/a2h-utg-static/scripts/tests/test_listener_call_forms.mjs +79 -0
  87. package/skills/a2h-utg-static/scripts/tests/test_listener_receiver_binding.mjs +47 -0
  88. package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +328 -0
  89. package/skills/a2h-utg-static/scripts/tests/test_manifest_exported_default.mjs +40 -0
  90. package/skills/a2h-utg-static/scripts/tests/test_manifest_filters_modules.mjs +84 -0
  91. package/skills/a2h-utg-static/scripts/tests/test_manifest_srcfile.mjs +68 -0
  92. package/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
  93. package/skills/a2h-utg-static/scripts/tests/test_module_namespace.mjs +83 -0
  94. package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +44 -0
  95. package/skills/a2h-utg-static/scripts/tests/test_multiple_entry_contracts.mjs +80 -0
  96. package/skills/a2h-utg-static/scripts/tests/test_nav_graph_xml.mjs +35 -0
  97. package/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
  98. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
  99. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
  100. package/skills/a2h-utg-static/scripts/tests/test_node_id_collision.mjs +57 -0
  101. package/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
  102. package/skills/a2h-utg-static/scripts/tests/test_out_of_scope_and_settings.mjs +72 -0
  103. package/skills/a2h-utg-static/scripts/tests/test_overload_and_climb.mjs +86 -0
  104. package/skills/a2h-utg-static/scripts/tests/test_pager_page_source.mjs +78 -0
  105. package/skills/a2h-utg-static/scripts/tests/test_pager_position_zero.mjs +65 -0
  106. package/skills/a2h-utg-static/scripts/tests/test_pager_variant_guard.mjs +172 -0
  107. package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +107 -0
  108. package/skills/a2h-utg-static/scripts/tests/test_plain_dialog_nodes.mjs +167 -0
  109. package/skills/a2h-utg-static/scripts/tests/test_plaindialog_shared_anchor.mjs +117 -0
  110. package/skills/a2h-utg-static/scripts/tests/test_preference_click_nav.mjs +98 -0
  111. package/skills/a2h-utg-static/scripts/tests/test_preference_host_binding.mjs +87 -0
  112. package/skills/a2h-utg-static/scripts/tests/test_preference_nesting.mjs +183 -0
  113. package/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
  114. package/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
  115. package/skills/a2h-utg-static/scripts/tests/test_resolver_tier_parity.mjs +126 -0
  116. package/skills/a2h-utg-static/scripts/tests/test_result_launcher.mjs +142 -0
  117. package/skills/a2h-utg-static/scripts/tests/test_review_fixes.mjs +135 -0
  118. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +66 -0
  119. package/skills/a2h-utg-static/scripts/tests/test_same_name_decl_scope.mjs +236 -0
  120. package/skills/a2h-utg-static/scripts/tests/test_scope_utils.mjs +85 -0
  121. package/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
  122. package/skills/a2h-utg-static/scripts/tests/test_shared_overlay_split.mjs +63 -0
  123. package/skills/a2h-utg-static/scripts/tests/test_slug_parity.mjs +58 -0
  124. package/skills/a2h-utg-static/scripts/tests/test_starter_node_id.mjs +41 -0
  125. package/skills/a2h-utg-static/scripts/tests/test_state_guard_arity.mjs +109 -0
  126. package/skills/a2h-utg-static/scripts/tests/test_state_guard_commented_candidates.mjs +68 -0
  127. package/skills/a2h-utg-static/scripts/tests/test_state_guard_model_gates.mjs +127 -0
  128. package/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
  129. package/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
  130. package/skills/a2h-utg-static/scripts/tests/test_template_method_layout.mjs +81 -0
  131. package/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
  132. package/skills/a2h-utg-static/scripts/tests/test_trigger_id_spelling.mjs +68 -0
  133. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_action_override.mjs +91 -0
  134. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
  135. package/skills/a2h-utg-static/scripts/tests/test_ui_elements_nl_hint_key.mjs +89 -0
  136. package/skills/a2h-utg-static/scripts/tests/test_uiless_host_fold.mjs +98 -0
  137. package/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
  138. package/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
  139. package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +231 -0
  140. package/skills/a2h-utg-static/scripts/tests/test_view_click_refs.mjs +104 -0
  141. package/skills/a2h-utg-static/scripts/tests/test_view_id_label.mjs +69 -0
  142. package/skills/a2h-utg-static/scripts/tests/test_view_interactions.mjs +346 -0
  143. package/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
  144. package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +98 -0
  145. package/skills/a2h-utg-static/scripts/tests/test_widget_class_scope.mjs +92 -0
  146. package/skills/a2h-utg-static/scripts/tests/test_window_nav_kotlin.mjs +158 -0
  147. package/skills/a2h-utg-static/scripts/tests/test_worklist_parts.mjs +65 -0
@@ -0,0 +1,231 @@
1
+ // Port of test_uniapp_source.py — a uni-app SOURCE project (pages.json + .vue) is analysable:
2
+ // uniapp_nav.mjs builds the route table / edges, uniapp_widgets.mjs stamps template widgets.
3
+ // Stages run as child processes, like the Python version. All checks run; failures are collected.
4
+ import { test } from 'node:test';
5
+ import assert from 'node:assert/strict';
6
+ import * as fs from 'node:fs';
7
+ import * as os from 'node:os';
8
+ import * as path from 'node:path';
9
+ import { spawnSync } from 'node:child_process';
10
+ import { fileURLToPath } from 'node:url';
11
+ import { jsonDumps } from '../_py.mjs';
12
+
13
+ const SCRIPTS = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
14
+ const NAV = path.join(SCRIPTS, 'uniapp_nav.mjs');
15
+ const WIDGETS = path.join(SCRIPTS, 'uniapp_widgets.mjs');
16
+
17
+ function run(argv) {
18
+ const p = spawnSync(process.execPath, argv, { encoding: 'utf8', maxBuffer: 1 << 28 });
19
+ const recs = (p.stdout || '').split(/\r?\n/).filter((l) => l.trim()).map((l) => JSON.parse(l));
20
+ return [recs.filter((r) => r.type === 'node'), recs.filter((r) => r.type === 'edge'), p.stderr || ''];
21
+ }
22
+ function write(root, rel, text) {
23
+ const p = path.join(root, ...rel.split('/'));
24
+ fs.mkdirSync(path.dirname(p), { recursive: true });
25
+ fs.writeFileSync(p, text, 'utf8');
26
+ }
27
+
28
+ const PAGES_JSON = jsonDumps({
29
+ easycom: { autoscan: true, custom: { '^s-(.*)': '@/comp/s-$1/s-$1.vue' } },
30
+ pages: [
31
+ { path: 'pages/index/index', style: { navigationBarTitleText: '首页' } },
32
+ // Opts BACK IN to the native bar while globalStyle says custom.
33
+ { path: 'pages/index/plain', style: { navigationBarTitleText: '实名页', navigationStyle: 'default' } },
34
+ { path: 'pages/index/cart', style: { navigationBarTitleText: '购物车' } },
35
+ ],
36
+ subPackages: [{ root: 'pages/order', pages: [{ path: 'detail/detail', style: { navigationBarTitleText: '订单详情' } }] }],
37
+ globalStyle: { navigationStyle: 'custom', navigationBarTitleText: '商城' },
38
+ tabBar: { list: [{ pagePath: 'pages/index/index', text: '首页' }, { pagePath: 'pages/index/cart', text: '购物车' }] },
39
+ }, { ensure_ascii: false });
40
+
41
+ const ROUTER_JS = `
42
+ const _go = (path, params = {}, options = {redirect: false}) => {
43
+ let url = path;
44
+ if (options.redirect) { uni.redirectTo({url}); return; }
45
+ uni.navigateTo({url});
46
+ };
47
+ function go(...args) { _go(...args); }
48
+ function redirect(path, params = {}) { go(path, params, {redirect: true}); }
49
+ export default { go, redirect };
50
+ `;
51
+ const INDEX_VUE = `<template>
52
+ <view>
53
+ <button
54
+ class="cart"
55
+ @tap="app.$router.go('/pages/index/cart')">去购物车</button>
56
+ <s-card />
57
+ <s-dispatch :type="blockType" />
58
+ <view @click="onBuy">立即购买</view>
59
+ <input placeholder="搜索商品" />
60
+ <text>欢迎</text>
61
+ </view>
62
+ </template>
63
+ <script setup>
64
+ import app from '@/router';
65
+ const whitelist = ['/pages/index/plain'];
66
+ function onBuy() {
67
+ if (whitelist.includes('/pages/index/plain')) { return; }
68
+ app.$router.go('/pages/order/detail/detail');
69
+ }
70
+ </script>
71
+ `;
72
+ const PLAIN_VUE = '<template><view><text>实名</text></view></template>';
73
+ const CART_VUE = '<template><view><text>购物车</text></view></template>';
74
+ const DETAIL_VUE = '<template><view><text>订单详情</text></view></template>';
75
+ const S_CARD = `<template>
76
+ <view @tap="app.$router.redirect('/pages/index/plain')">查看实名</view>
77
+ </template>
78
+ <script setup>import app from '@/router';</script>
79
+ `;
80
+ const S_DISPATCH = `<template>
81
+ <view>
82
+ <s-branch-a v-if="type === 'BlockA'" />
83
+ <s-branch-b v-if="type === 'BlockB'" />
84
+ <s-branch-c v-if="type === 'BlockC'" />
85
+ </view>
86
+ </template>
87
+ `;
88
+ const S_BRANCH_A = `<template>
89
+ <view @tap="app.$router.go('/pages/order/detail/detail')">A</view>
90
+ </template>
91
+ <script setup>import app from '@/router';</script>
92
+ `;
93
+
94
+ function buildFixture(root) {
95
+ write(root, 'pages.json', PAGES_JSON);
96
+ write(root, 'manifest.json', jsonDumps({ appid: '__UNI__TEST01', name: '测试商城' }, { ensure_ascii: false }));
97
+ write(root, 'router/index.js', ROUTER_JS);
98
+ write(root, 'pages/index/index.vue', INDEX_VUE);
99
+ write(root, 'pages/index/plain.vue', PLAIN_VUE);
100
+ write(root, 'pages/index/cart.vue', CART_VUE);
101
+ write(root, 'pages/order/detail/detail.vue', DETAIL_VUE);
102
+ write(root, 'comp/s-card/s-card.vue', S_CARD);
103
+ write(root, 'comp/s-dispatch/s-dispatch.vue', S_DISPATCH);
104
+ write(root, 'comp/s-branch-a/s-branch-a.vue', S_BRANCH_A);
105
+ }
106
+
107
+ const PID = 'hybrid-page:__UNI__TEST01/';
108
+ const comp = (e) => String((e.args || {}).component ?? '');
109
+
110
+ test('uni-app source project', () => {
111
+ const fails = [];
112
+ const check = (cond, msg, extra = '') => { if (!cond) { fails.push(msg + (extra ? ` [${extra}]` : '')); } };
113
+ const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'uniapp_src_'));
114
+ try {
115
+ const root = path.join(tmp, 'app');
116
+ buildFixture(root);
117
+
118
+ // [1] route table: pages + subPackages, launch page, entry marker
119
+ const [nodes, edges, err] = run([NAV, root]);
120
+ const byRoute = Object.fromEntries(nodes.map((n) => [n.route, n]));
121
+ check(nodes.length === 4, '4 routes (3 pages + 1 subpackage page)', `got ${nodes.length}: ${Object.keys(byRoute).sort()}`);
122
+ check('pages/order/detail/detail' in byRoute, 'subpackage route joined to its root');
123
+ const launch = nodes.filter((n) => n.entry);
124
+ check(launch.length === 1 && launch[0].route === 'pages/index/index', 'pages[0] is the entry/launcher',
125
+ String(launch.map((n) => n.route)));
126
+ check(nodes.every((n) => n.id.startsWith(PID)), 'node ids carry the manifest.json appid');
127
+ check(String(byRoute['pages/index/index']?.declared_at).startsWith('pages.json:'),
128
+ 'declared_at cites pages.json with a real line', byRoute['pages/index/index']?.declared_at);
129
+
130
+ // [2] a subpackage's bare relative half is NOT a route
131
+ check(!('detail/detail' in byRoute), 'relative half refused (no phantom route)');
132
+
133
+ // [3] custom nav bar demotes the title; opting back in keeps it
134
+ const idx = byRoute['pages/index/index'] ?? {};
135
+ check(idx.label_synthetic === true && idx.title_renders === false, 'globalStyle custom -> label_synthetic, title_renders false');
136
+ check(JSON.stringify((idx.expected || {}).hint_any) === JSON.stringify(['首页']),
137
+ 'its title goes to hint_any, never title_any', JSON.stringify(idx.expected));
138
+ check(!('title_any' in (idx.expected || {})), 'title_any absent (would be a decisive wrong-page veto)');
139
+ const plain = byRoute['pages/index/plain'] ?? {};
140
+ check(plain.title_renders === true && !plain.label_synthetic && plain.label === '实名页',
141
+ 'per-page navigationStyle:default keeps a real, matchable title',
142
+ `renders=${plain.title_renders} synth=${plain.label_synthetic}`);
143
+
144
+ // [4] the project router resolves structurally
145
+ check(err.includes('seed=') && err.includes('fixpoint='), 'forwarder counts reported');
146
+ const cart = edges.filter((e) => e.target === PID + 'pages/index/cart' && e.mechanism === 'hybrid-route');
147
+ check(cart.length === 1, "`go('/pages/index/cart')` became an edge", `got ${cart.length}`);
148
+ const red = edges.filter((e) => e.target === PID + 'pages/index/plain');
149
+ check(red.length === 1, '`redirect(...)` resolved (default-parameter body was read)', `got ${red.length}`);
150
+ if (red.length) {
151
+ check(['navigateTo', 'redirectTo'].includes(red[0].args.api), 'the recorded api is one the wrapper really reaches',
152
+ String(red[0].args.api));
153
+ check(red[0].args.resolved_by === 'forwarder', 'and the record says it came from a forwarder, not a direct call',
154
+ String(red[0].args.resolved_by));
155
+ }
156
+
157
+ // [5] a route literal via a NON-forwarder is refused
158
+ check(edges.filter((e) => e.target === PID + 'pages/index/plain').length === 1, "`includes('/pages/...')` is not navigation");
159
+
160
+ // [6] a data-driven dispatch table is not traversed through
161
+ const dsp = edges.filter((e) => comp(e).endsWith('s-branch-a.vue'));
162
+ check(!dsp.length, 'dispatch branch refused by default', `got ${dsp.length}`);
163
+ check(err.includes('dispatch_gated='), 'refusal is counted and printed');
164
+ const [, e2] = run([NAV, root, '--dispatch-edges']);
165
+ const dsp2 = e2.filter((e) => comp(e).endsWith('s-branch-a.vue'));
166
+ check(dsp2.length >= 1, '--dispatch-edges opts in', `got ${dsp2.length}`);
167
+ if (dsp2.length) {
168
+ const g = dsp2[0].guard;
169
+ check(typeof g === 'string' && g.includes('type ===') && g.includes('BlockA'),
170
+ "each opted-in edge carries its branch's own condition as guard", JSON.stringify(g));
171
+ check(dsp2[0].confidence < 0.7, "and a lower confidence than a page's own call", String(dsp2[0].confidence));
172
+ }
173
+
174
+ // [7] refusals are counted separately, and fan-out is capped
175
+ for (const token of ['no_owner=', 'ambiguous=', 'dispatch_gated=']) { check(err.includes(token), `\`${token}\` reported distinctly`); }
176
+ const [, e3] = run([NAV, root, '--max-component-fanout', '0']);
177
+ const anchored = e3.filter((e) => (e.args || {}).component);
178
+ check(!anchored.length, 'fan-out cap 0 refuses every component-anchored edge', String(anchored.length));
179
+
180
+ // [8] trigger shape: `<gesture>@<file>:<line>`, never doubled
181
+ for (const e of edges) {
182
+ const t = String(e.trigger || '');
183
+ check(t.includes('@') && !t.startsWith('ref@'), `trigger is prefixed and not mention-derived: ${t}`);
184
+ break;
185
+ }
186
+ const prefixes = new Set(edges.map((e) => String(e.trigger ?? '').split('@')[0]));
187
+ check(![...prefixes].some((p) => p.startsWith('onOn')), 'a handler already named onX is not prefixed twice',
188
+ String([...prefixes].sort()));
189
+ // Python indexes split('@', 1)[1], which raises on a trigger without '@'; mirror that strictly.
190
+ check(edges.every((e) => {
191
+ const t = String(e.trigger ?? ''); const i = t.indexOf('@');
192
+ if (i < 0) { throw new Error(`trigger without '@': ${t}`); }
193
+ return t.slice(i + 1).includes(':') || t.startsWith('tabBar@');
194
+ }), 'every non-tabBar trigger cites file:line');
195
+
196
+ // [9] tabBar entries become labelled tap edges
197
+ const tabs = edges.filter((e) => e.mechanism === 'hybrid-tabbar');
198
+ check(tabs.length === 1 && tabs[0].target === PID + 'pages/index/cart',
199
+ 'one tab edge (the launch tab is not an edge to itself)', `got ${tabs.length}`);
200
+ check(tabs.length > 0 && tabs[0].args.label === '购物车', "carrying the tab's printed text");
201
+
202
+ // [10] widgets: containment join, and the mustache refusal
203
+ const ws = path.join(tmp, 'ws');
204
+ fs.mkdirSync(ws, { recursive: true });
205
+ fs.writeFileSync(path.join(ws, 'nodes.jsonl'), nodes.map((n) => JSON.stringify(n) + '\n').join(''), 'utf8');
206
+ fs.writeFileSync(path.join(ws, 'edges.jsonl'), edges.map((e) => JSON.stringify(e) + '\n').join(''), 'utf8');
207
+ const p = spawnSync(process.execPath, [WIDGETS, ws, '--project', root, '--append'], { encoding: 'utf8' });
208
+ const stamped = fs.readFileSync(path.join(ws, 'nodes.jsonl'), 'utf8').split(/\r?\n/).filter((l) => l.trim())
209
+ .map((l) => JSON.parse(l));
210
+ const home = stamped.find((n) => n.route === 'pages/index/index');
211
+ assert.ok(home, 'home page present after stamping');
212
+ const wl = home.widgets || [];
213
+ check(wl.length > 0, "the home page's template yielded widgets", String(wl.length));
214
+ const kinds = new Set(wl.map((w) => w.kind));
215
+ check(kinds.has('input'), 'an <input> is kind=input', String([...kinds].sort()));
216
+ check(wl.some((w) => w.placeholder === '搜索商品'), 'its placeholder is read');
217
+ // The `@tap` sits on the THIRD line of the <button> tag: exact line equality would anchor nothing.
218
+ check(wl.some((w) => w.is_trigger), "a multi-line tag's gesture anchors by containment",
219
+ p.stderr ? p.stderr.trim().split(/\r?\n/).at(-1) : '');
220
+ check(wl.every((w) => !('_l0' in w) && !('_file' in w)), 'internal join keys are stripped from the record');
221
+
222
+ // [11] a non-uni-app project is a clean no-op
223
+ const other = path.join(tmp, 'plain');
224
+ write(other, 'src/main/java/A.java', 'class A {}');
225
+ write(other, 'pages.json', jsonDumps({ hello: 'world' }));
226
+ const [n4, e4, err4] = run([NAV, other]);
227
+ check(!n4.length && !e4.length, 'no nodes, no edges', `${n4.length}/${e4.length}`);
228
+ check(err4.includes('no uni-app project found'), 'and it says so', err4.trim().slice(0, 80));
229
+ } finally { fs.rmSync(tmp, { recursive: true, force: true }); }
230
+ assert.deepEqual(fails, []);
231
+ });
@@ -0,0 +1,104 @@
1
+ // Regression: setOnClickListener(this) / (this::onX) must not be prescreened as an action from
2
+ // the empty argument span; the callback is the class's onClick / the referenced method.
3
+ import { test } from 'node:test';
4
+ import assert from 'node:assert/strict';
5
+ import * as fs from 'node:fs';
6
+ import * as os from 'node:os';
7
+ import * as path from 'node:path';
8
+ import * as vi from '../view_interactions.mjs';
9
+
10
+ const JAVA = `package sample;
11
+ class Host extends Activity implements View.OnClickListener {
12
+ void onCreate() {
13
+ setContentView(R.layout.host);
14
+ open.setOnClickListener(this);
15
+ detail.setOnClickListener(this::openDetail);
16
+ save.setOnClickListener(this::persist);
17
+ other.setOnClickListener(helper::onTap);
18
+ }
19
+ public void onClick(View v) { startActivity(new Intent(this, Host.class)); }
20
+ void openDetail(View v) { panel.setVisibility(View.VISIBLE); }
21
+ void persist(View v) { repo.store(1); }
22
+ }
23
+ `;
24
+ const KT = `package sample
25
+ class Other : Activity(), View.OnClickListener {
26
+ fun onCreate() {
27
+ setContentView(R.layout.other)
28
+ go.setOnClickListener(this)
29
+ more.setOnClickListener(::showMore)
30
+ }
31
+ override fun onClick(v: View) { finish() }
32
+ private fun showMore(v: View) { sheet.show() }
33
+ }
34
+ `;
35
+
36
+ function fixture() {
37
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'vir-'));
38
+ const project = path.join(root, 'project'); const ws = path.join(root, 'ws');
39
+ fs.mkdirSync(ws);
40
+ const write = (rel, text) => {
41
+ const p = path.join(project, rel);
42
+ fs.mkdirSync(path.dirname(p), { recursive: true });
43
+ fs.writeFileSync(p, text, 'utf8');
44
+ };
45
+ write('app/src/main/java/sample/Host.java', JAVA);
46
+ write('app/src/main/java/sample/Other.kt', KT);
47
+ write('app/src/main/res/layout/host.xml', '<FrameLayout/>');
48
+ write('app/src/main/res/layout/other.xml', '<FrameLayout/>');
49
+ const nodes = [
50
+ { id: 'activity:Host', kind: 'activity', name: 'Host', fqn: 'sample.Host', provenance: 'static:manifest' },
51
+ { id: 'activity:Other', kind: 'activity', name: 'Other', fqn: 'sample.Other', provenance: 'static:manifest' }];
52
+ fs.writeFileSync(path.join(ws, 'nodes.jsonl'), nodes.map((n) => JSON.stringify(n) + '\n').join(''), 'utf8');
53
+ fs.writeFileSync(path.join(ws, 'edges.jsonl'), '', 'utf8');
54
+ return { root, project, ws };
55
+ }
56
+
57
+ function bucketOf(wl, file, fragment) {
58
+ const src = file.endsWith('.kt') ? KT : JAVA;
59
+ const line = src.split('\n').findIndex((x) => x.includes(fragment)) + 1;
60
+ const at = `app/src/main/java/sample/${file}:${line}`;
61
+ for (const b of ['items', 'prescreened']) {
62
+ const it = wl[b].find((x) => x.trigger_at === at);
63
+ if (it) { return [b, it]; }
64
+ }
65
+ throw new assert.AssertionError({ message: `no item at ${at}` });
66
+ }
67
+
68
+ test('this / method-reference listeners reach the worklist via the real handler', () => {
69
+ const t = fixture();
70
+ try {
71
+ const wl = vi.collect(t.project, t.ws);
72
+ const cases = [
73
+ ['Host.java', 'open.setOnClickListener(this)', 'items', 'startActivity'],
74
+ ['Host.java', 'this::openDetail', 'items', 'panel.setVisibility'],
75
+ ['Host.java', 'this::persist', 'prescreened', 'repo.store'],
76
+ ['Host.java', 'helper::onTap', 'items', null],
77
+ ['Other.kt', 'go.setOnClickListener(this)', 'items', 'finish()'],
78
+ ['Other.kt', '::showMore', 'items', 'sheet.show'],
79
+ ];
80
+ for (const [file, frag, bucket, inWindow] of cases) {
81
+ const [b, it] = bucketOf(wl, file, frag);
82
+ assert.equal(b, bucket, frag);
83
+ if (inWindow) {
84
+ assert.ok(it.code_window.some((c) => c.text.includes(inWindow)), `${frag}: window shows ${inWindow}`);
85
+ }
86
+ }
87
+ } finally { fs.rmSync(t.root, { recursive: true, force: true }); }
88
+ });
89
+
90
+ test('callbackRef forms', () => {
91
+ assert.deepEqual(vi.callbackRef('this', 'A'), { cls: 'A', name: 'onClick' });
92
+ assert.deepEqual(vi.callbackRef('Outer.this', 'A'), { cls: 'Outer', name: 'onClick' });
93
+ assert.deepEqual(vi.callbackRef('this::onX', 'A'), { cls: 'A', name: 'onX' });
94
+ assert.deepEqual(vi.callbackRef('::onX', 'A'), { cls: 'A', name: 'onX' });
95
+ assert.deepEqual(vi.callbackRef('Util::onX', 'A'), { cls: 'Util', name: 'onX' });
96
+ assert.deepEqual(vi.callbackRef('vm::onX', 'A'), { cls: null, name: 'onX' });
97
+ assert.equal(vi.callbackRef('listener', 'A'), null);
98
+ assert.equal(vi.callbackRef('', 'A'), null);
99
+ });
100
+
101
+ test('callbackRef: Kotlin labelled this@Outer names the outer class', () => {
102
+ assert.deepEqual(vi.callbackRef('this@MainActivity', 'Inner'), { cls: 'MainActivity', name: 'onClick' });
103
+ assert.deepEqual(vi.callbackRef('this @MainActivity', 'Inner'), null);
104
+ });
@@ -0,0 +1,69 @@
1
+ // Port of test_view_id_label.py: tap-target wording joined from res/layout through the view id.
2
+ import { test } from 'node:test';
3
+ import assert from 'node:assert/strict';
4
+ import * as an from '../activity_nav.mjs';
5
+
6
+ const PER_LAYOUT = new Map([
7
+ ['activity_a', new Map([['tv_go', 'Open A'], ['tv_title', 'Screen A']])],
8
+ ['activity_b', new Map([['tv_go', 'Open A'], ['tv_title', 'Screen B']])],
9
+ ]);
10
+ const GLOBAL = new Map([['tv_go', 'Open A']]);
11
+ const IDX = [PER_LAYOUT, GLOBAL];
12
+ const labelAt = (src, needle = 'startActivity', layouts = []) =>
13
+ an._viewIdLabel(src, src.indexOf(needle), IDX, { layout_names: layouts });
14
+
15
+ const VB = `void onEvent() {
16
+ db.tvGo.setOnClickListener(v -> {
17
+ startActivity(Target.class);
18
+ });
19
+ }
20
+ `;
21
+ const FVB = `void onEvent() {
22
+ findViewById(R.id.tv_go).setOnClickListener(v -> {
23
+ startActivity(Target.class);
24
+ });
25
+ }
26
+ `;
27
+ const GEN = `void onEvent() {
28
+ db.tvTitle.setOnClickListener(v -> {
29
+ startActivity(Target.class);
30
+ });
31
+ }
32
+ `;
33
+
34
+ test('view-id join', () => {
35
+ assert.equal(labelAt(VB)[0], 'Open A');
36
+ assert.equal(labelAt(FVB)[0], 'Open A');
37
+ assert.equal(labelAt(VB)[1], 'tv_go');
38
+ });
39
+
40
+ test('per-layout scoping', () => {
41
+ assert.equal(labelAt(GEN, 'startActivity', ['activity_a'])[0], 'Screen A');
42
+ assert.equal(labelAt(GEN, 'startActivity', ['activity_b'])[0], 'Screen B');
43
+ assert.equal(labelAt(GEN)[0], null);
44
+ });
45
+
46
+ test('no fabricated labels', () => {
47
+ const LIFECYCLE = `void onCreate(Bundle b) {
48
+ startActivity(Target.class);
49
+ }
50
+ `;
51
+ assert.equal(labelAt(LIFECYCLE)[0], null);
52
+ const UNKNOWN = `void onEvent() {
53
+ db.tvMissing.setOnClickListener(v -> {
54
+ startActivity(Target.class);
55
+ });
56
+ }
57
+ `;
58
+ assert.equal(labelAt(UNKNOWN)[0], null);
59
+ const NESTED = `void onEvent() {
60
+ db.tvTitle.setOnClickListener(v -> {
61
+ db.tvGo.setOnClickListener(w -> {
62
+ startActivity(Target.class);
63
+ });
64
+ });
65
+ }
66
+ `;
67
+ assert.equal(labelAt(NESTED, 'startActivity', ['activity_a'])[0], 'Open A');
68
+ assert.equal(an._viewIdLabel(VB, VB.indexOf('startActivity'), null)[0], null);
69
+ });