@ohos-cpf/3rdloop 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +244 -244
- package/bin/3rdloop.mjs +46 -46
- package/lib/cli.js +781 -781
- package/lib/config-cmd.js +451 -451
- package/lib/config.js +318 -318
- package/lib/doctor.js +113 -113
- package/lib/exit-codes.js +30 -30
- package/lib/opencode.js +155 -155
- package/lib/orch.js +426 -426
- package/lib/queries.js +263 -263
- package/lib/step.js +325 -325
- package/lib/ui.js +222 -222
- package/lib/update.js +279 -279
- package/lib/workflow.js +308 -308
- package/lib/workflows.js +131 -131
- package/package.json +50 -50
- package/vendor/Server/Agent/SkillSelector/README.md +343 -343
- package/vendor/Server/Agent/SkillSelector/core/Agent.js +207 -207
- package/vendor/Server/Agent/SkillSelector/index.js +14 -14
- package/vendor/Server/Agent/SkillSelector/llm/llmClient.js +313 -313
- package/vendor/Server/Agent/SkillSelector/llm/prompts.js +161 -161
- package/vendor/Server/Agent/SkillSelector/llm/reactSteps.js +144 -144
- package/vendor/Server/Agent/SkillSelector/matcher/fuzzyMatcher.js +433 -433
- package/vendor/Server/Agent/SkillSelector/scanner/skillScanner.js +382 -382
- package/vendor/Server/Agent/SkillSelector/utils/actionWords.js +59 -59
- package/vendor/Server/Brain/AnalysisStrategies.js +422 -422
- package/vendor/Server/Brain/Brain.js +686 -686
- package/vendor/Server/Brain/DecompositionStrategies.js +621 -621
- package/vendor/Server/Brain/PlanPersistence.js +196 -196
- package/vendor/Server/Brain/SkillExecutor.js +251 -251
- package/vendor/Server/Brain/index.js +11 -11
- package/vendor/Server/CLI/cli.js +275 -275
- package/vendor/Server/CLI/deveco-code/index.js +71 -71
- package/vendor/Server/CLI/deveco-code.js +5 -5
- package/vendor/Server/CLI/opencode/index.js +817 -818
- package/vendor/Server/CLI/opencode.js +5 -5
- package/vendor/Server/DbUse/MessageArchive.js +61 -61
- package/vendor/Server/DbUse/StorageManager.js +107 -107
- package/vendor/Server/DbUse/adapters/BaseAdapter.js +94 -94
- package/vendor/Server/DbUse/adapters/FileAdapter.js +138 -138
- package/vendor/Server/DbUse/adapters/JsonAdapter.js +138 -138
- package/vendor/Server/DbUse/adapters/JsonlAdapter.js +114 -114
- package/vendor/Server/DbUse/adapters/SqliteAdapter.js +157 -157
- package/vendor/Server/DbUse/index.js +160 -160
- package/vendor/Server/DbUse/stores/SessionStore.js +279 -279
- package/vendor/Server/DbUse/stores/TaskExecutionStore.js +133 -133
- package/vendor/Server/DbUse/stores/TaskRegistryStore.js +262 -262
- package/vendor/Server/DbUse/stores/TaskStepStore.js +279 -279
- package/vendor/Server/FlexRunner/FlexRunner.js +1759 -1759
- package/vendor/Server/FlexRunner/index.js +12 -12
- package/vendor/Server/Knowledge/KnowledgeImporter.js +523 -523
- package/vendor/Server/Knowledge/KnowledgeManager.js +341 -341
- package/vendor/Server/Knowledge/index.js +33 -33
- package/vendor/Server/LoopEngine/LoopEngine.js +1133 -1133
- package/vendor/Server/LoopEngine/index.js +11 -11
- package/vendor/Server/Orchestrator/Orchestrator.js +0 -3
- package/vendor/Server/Orchestrator/StepNode.js +312 -312
- package/vendor/Server/Orchestrator/index.js +13 -13
- package/vendor/Server/Routes/controllers/BrainController.js +241 -241
- package/vendor/Server/Routes/controllers/FlexRunnerController.js +1125 -1125
- package/vendor/Server/Routes/controllers/HealthController.js +44 -44
- package/vendor/Server/Routes/controllers/KnowledgeImportController.js +355 -355
- package/vendor/Server/Routes/controllers/LoopEngineController.js +788 -788
- package/vendor/Server/Routes/controllers/StatsController.js +57 -57
- package/vendor/Server/Routes/controllers/StreamController.js +67 -67
- package/vendor/Server/Routes/library/logger.js +179 -179
- package/vendor/Server/Routes/library/zipArchive.js +172 -172
- package/vendor/Server/Routes/router/Router.js +204 -204
- package/vendor/Server/Routes/routes/brain.js +47 -47
- package/vendor/Server/Routes/routes/flexrunner.js +72 -72
- package/vendor/Server/Routes/routes/health.js +28 -28
- package/vendor/Server/Routes/routes/index.js +57 -57
- package/vendor/Server/Routes/routes/knowledge.js +55 -55
- package/vendor/Server/Routes/routes/loopengine.js +58 -58
- package/vendor/Server/Routes/routes/orchestrator.js +61 -61
- package/vendor/Server/Routes/routes/registry.js +97 -97
- package/vendor/Server/Routes/routes/stats.js +23 -23
- package/vendor/Server/Routes/routes/stream.js +30 -30
- package/vendor/Server/Routes/server.js +203 -203
- package/vendor/Server/Routes/sse/SseHub.js +308 -308
- package/vendor/Server/Skills/acceptance-check/SKILL.md +191 -191
- package/vendor/Server/Skills/acceptance-check/references/PHASE1_ARTIFACT_COLLECTION.md +52 -52
- package/vendor/Server/Skills/acceptance-check/references/PHASE2_CRITERIA_EVALUATION.md +77 -77
- package/vendor/Server/Skills/acceptance-check/references/PHASE2_EVIDENCE_VERIFICATION.md +70 -70
- package/vendor/Server/Skills/arkts-code-check/SKILL.md +320 -320
- package/vendor/Server/Skills/arkts-code-check/references/CODE_CHECK_GUIDE.md +210 -210
- package/vendor/Server/Skills/arkts-code-check/references/FILE_TYPE_GUIDE.md +28 -28
- package/vendor/Server/Skills/arkts-code-check/references/PHASE1_INFO_COLLECTION.md +233 -233
- package/vendor/Server/Skills/arkts-code-check/references/REPORT_TEMPLATE.md +219 -219
- package/vendor/Server/Skills/arkts-library-compile-validate/SKILL.md +328 -328
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/build.ps1 +93 -93
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/code-linter.cjs +432 -432
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/migrate.cjs +851 -851
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/ohpm-switch.cjs +788 -788
- package/vendor/Server/Skills/arkts-library-demo-code/SKILL.md +291 -291
- package/vendor/Server/Skills/arkts-library-demo-code/references/API_SIGNATURE_CHECKS.md +68 -68
- package/vendor/Server/Skills/arkts-library-demo-code/references/BUILD_VALIDATION.md +184 -184
- package/vendor/Server/Skills/arkts-library-demo-code/references/CODE_STANDARDS.md +337 -337
- package/vendor/Server/Skills/arkts-library-demo-code/references/EXAMPLES.md +400 -400
- package/vendor/Server/Skills/arkts-library-demo-code/references/SYSTEM_API_LOOKUP.md +98 -98
- package/vendor/Server/Skills/arkts-library-demo-code/references/TEMPLATE.md +544 -544
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/build.ps1 +93 -93
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/code-linter.cjs +432 -432
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/migrate.cjs +851 -851
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/ohpm-switch.cjs +788 -788
- package/vendor/Server/Skills/arkts-library-demo-coverage/SKILL.md +174 -174
- package/vendor/Server/Skills/arkts-library-demo-scenario/SKILL.md +321 -321
- package/vendor/Server/Skills/arkts-library-demo-scenario/references/EXAMPLES.md +100 -100
- package/vendor/Server/Skills/arkts-library-demo-scenario/references/TEMPLATE.md +185 -185
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/SKILL.md +233 -233
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/assets/REPORT_TEMPLATE.md +102 -102
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/CHECK_DIMENSIONS.md +89 -89
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/COMPLIANCE_CHECKLIST.md +62 -62
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/KB_QUERY_GUIDE.md +107 -107
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/MCP_TOOL_DISCOVERY.md +124 -124
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/REPORT_TEMPLATE.md +90 -90
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/SCORING_FORMULA.md +57 -57
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/scripts/validate-skill.cjs +259 -259
- package/vendor/Server/Skills/arkts-library-interface-spec/SKILL.md +97 -97
- package/vendor/Server/Skills/arkts-library-memory-leak-check/SKILL.md +391 -391
- package/vendor/Server/Skills/arkts-library-source-clone/SKILL.md +113 -113
- package/vendor/Server/Skills/arkts-library-stability-check/SKILL.md +312 -312
- package/vendor/Server/Skills/arkts-library-stability-check/assets/REPORT_TEMPLATE.md +154 -154
- package/vendor/Server/Skills/arkts-library-stability-check/references/CHECKLIST.md +165 -165
- package/vendor/Server/Skills/arkts-library-stability-check/references/CODE_EXAMPLES.md +308 -308
- package/vendor/Server/Skills/arkts-library-stability-check/references/SCORING_RULES.md +90 -90
- package/vendor/Server/Skills/arkts-library-stability-check/scripts/validate-skill.cjs +282 -282
- package/vendor/Server/Skills/arkts-library-test-coverage-check/SKILL.md +360 -360
- package/vendor/Server/Skills/arkts-library-test-coverage-check/assets/REPORT_TEMPLATE.md +145 -145
- package/vendor/Server/Skills/arkts-library-test-coverage-check/references/CHECKLIST.md +252 -252
- package/vendor/Server/Skills/arkts-library-test-coverage-check/references/MCP_TOOL_USAGE.md +114 -114
- package/vendor/Server/Skills/arkts-library-test-coverage-check/scripts/validate-skill.cjs +262 -262
- package/vendor/Server/Skills/arkts-library-xts-code/SKILL.md +455 -455
- package/vendor/Server/Skills/arkts-library-xts-code/assets/report-template.md +60 -60
- package/vendor/Server/Skills/arkts-library-xts-code/references/ACCESS_MODIFIER_PRECHECK.md +76 -76
- package/vendor/Server/Skills/arkts-library-xts-code/references/BUILD_VERIFICATION.md +200 -200
- package/vendor/Server/Skills/arkts-library-xts-code/references/CODE_STANDARDS.md +518 -518
- package/vendor/Server/Skills/arkts-library-xts-code/references/SUBAGENT_PROMPT_TEMPLATE.md +276 -276
- package/vendor/Server/Skills/arkts-library-xts-code/references/SYSTEM_API_LOOKUP.md +92 -92
- package/vendor/Server/Skills/arkts-library-xts-code/references/XTS_TEMPLATE.md +767 -767
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/build.ps1 +93 -93
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/code-linter.cjs +432 -432
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/migrate.cjs +851 -851
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/ohpm-switch.cjs +788 -788
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/precheck-access-modifiers.cjs +221 -221
- package/vendor/Server/Skills/arkts-library-xts-code-fix/SKILL.md +228 -228
- package/vendor/Server/Skills/arkts-library-xts-coverage/SKILL.md +97 -97
- package/vendor/Server/Skills/arkts-library-xts-doc/SKILL.md +194 -194
- package/vendor/Server/Skills/arkts-library-xts-doc/references/EXAMPLES.md +575 -575
- package/vendor/Server/Skills/arkts-library-xts-doc/references/TEMPLATE.md +574 -574
- package/vendor/Server/Skills/arkts-library-xts-doc/references/TESTABILITY_GUIDE.md +182 -182
- package/vendor/Server/Skills/arkts-library-xts-execution/SKILL.md +490 -490
- package/vendor/Server/Skills/arkts-library-xts-execution/references/error-fixing-examples.md +217 -217
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/build.ps1 +93 -93
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/code-linter.cjs +432 -432
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/migrate.cjs +851 -851
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/ohpm-switch.cjs +788 -788
- package/vendor/Server/Skills/flutter-code-check/SKILL.md +299 -299
- package/vendor/Server/Skills/flutter-code-check/assets/OUTPUT_TEMPLATE.md +311 -311
- package/vendor/Server/Skills/flutter-code-check/references/CHECKLIST.md +190 -190
- package/vendor/Server/Skills/flutter-code-check/references/PLATFORMS.md +133 -133
- package/vendor/Server/Skills/flutter-code-check/scripts/validate-skill.cjs +259 -259
- package/vendor/Server/Skills/flutter-interface/README.md +75 -75
- package/vendor/Server/Skills/flutter-interface/SKILL.md +291 -291
- package/vendor/Server/Skills/flutter-interface/references/EXAMPLES.md +336 -336
- package/vendor/Server/Skills/flutter-interface/references/GIT_CLONE_GUIDE.md +190 -190
- package/vendor/Server/Skills/flutter-interface/references/SCRIPT_REFERENCE.md +258 -258
- package/vendor/Server/Skills/flutter-interface/references/TEMPLATE.md +254 -254
- package/vendor/Server/Skills/flutter-library-consistency-check/SKILL.md +517 -517
- package/vendor/Server/Skills/flutter-library-consistency-check/references/CHECKLIST.md +381 -381
- package/vendor/Server/Skills/flutter-library-consistency-check/references/FUNCTION_COMPARISON_GUIDE.md +341 -341
- package/vendor/Server/Skills/flutter-library-consistency-check/references/PLATFORM_LIMITATION_GUIDE.md +71 -71
- package/vendor/Server/Skills/flutter-library-documentation-quality-check/SKILL.md +518 -518
- package/vendor/Server/Skills/flutter-library-documentation-quality-check/references/CHECKLIST.md +406 -406
- package/vendor/Server/Skills/flutter-library-memory-leak-check/SKILL.md +652 -652
- package/vendor/Server/Skills/flutter-library-memory-leak-check/references/CHECKLIST.md +396 -396
- package/vendor/Server/Skills/flutter-library-stability-check/SKILL.md +744 -744
- package/vendor/Server/Skills/flutter-library-stability-check/references/CHECKLIST.md +720 -720
- package/vendor/Server/Skills/flutter-library-test-coverage-check/SKILL.md +414 -414
- package/vendor/Server/Skills/flutter-library-test-coverage-check/assets/REPORT_TEMPLATE.md +150 -150
- package/vendor/Server/Skills/flutter-library-test-coverage-check/references/CHECKLIST.md +304 -304
- package/vendor/Server/Skills/flutter-library-test-coverage-check/references/SCORING_RULES.md +265 -265
- package/vendor/Server/Skills/flutter-library-test-coverage-check/references/SCRIPT_USAGE.md +286 -286
- package/vendor/Server/Skills/knowledge-import/SKILL.md +383 -383
- package/vendor/Server/Skills/knowledge-import/references/MCP_TOOL_USAGE.md +165 -165
- package/vendor/Server/Skills/knowledge-import/references/SKILL_LOCATOR_GUIDE.md +91 -91
- package/vendor/Server/Skills/knowledge-import/references/SKILL_OPTIMIZATION_GUIDE.md +127 -127
- package/vendor/Server/Skills/ohos-lib-pr-push/SKILL.md +453 -301
- package/vendor/Server/Skills/ohos-lib-pr-push/assets/PR_CHECKLIST.md +151 -0
- package/vendor/Server/Skills/ohos-lib-pr-push/assets/PR_ISSUE_TEMPLATE.md +257 -105
- package/vendor/Server/Skills/ohos-lib-pr-push/references/GITCODE_API.md +191 -127
- package/vendor/Server/Skills/ohos-lib-pr-push/scripts/gitcode-api.cjs +317 -208
- package/vendor/Server/Skills/rn-code-check/SKILL.md +320 -320
- package/vendor/Server/Skills/rn-code-check/references/API-GUIDE.md +234 -234
- package/vendor/Server/Skills/rn-code-check/references/CHECKLIST.md +188 -188
- package/vendor/Server/Skills/rn-code-check/references/REPORT-TEMPLATE.md +246 -246
- package/vendor/Server/Skills/rn-lib-add-example/SKILL.md +198 -198
- package/vendor/Server/Skills/rn-lib-add-example/references/APP_RENAME_GUIDE.md +40 -40
- package/vendor/Server/Skills/rn-lib-add-example/references/SHELL_ADAPTATION_CHECKLIST.md +78 -78
- package/vendor/Server/Skills/rn-lib-add-example/references/TEMPLATE_REPO_GUIDE.md +70 -70
- package/vendor/Server/Skills/rn-lib-add-example/references/VERIFICATION_GUIDE.md +47 -47
- package/vendor/Server/Skills/rn-lib-add-example/scripts/create-example.cjs +252 -252
- package/vendor/Server/Skills/rn-lib-update-doc/SKILL.md +176 -176
- package/vendor/Server/Skills/rn-lib-update-doc/config.json +5 -5
- package/vendor/Server/Skills/rn-lib-update-doc/references/changelog-template.md +35 -35
- package/vendor/Server/Skills/rn-lib-update-doc/references/format-diff.md +137 -137
- package/vendor/Server/Skills/rn-lib-update-doc/references/link-registry.json +33 -33
- package/vendor/Server/Skills/rn-lib-update-doc/references/model-0.4.2-overview.md +40 -40
- package/vendor/Server/Skills/rn-lib-update-doc/references/model-0.4.2.md +429 -429
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/detect-readme-format.cjs +105 -105
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/find-usage-doc.cjs +90 -90
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/link-verify.cjs +213 -213
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/normalize-changelog.cjs +73 -73
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/normalize-package-meta.cjs +258 -258
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/normalize-readme-links.cjs +341 -341
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/resolve-usage-docs.cjs +67 -67
- package/vendor/Server/Skills/rn-library-consistency-check/SKILL.md +299 -299
- package/vendor/Server/Skills/rn-library-consistency-check/assets/REPORT_TEMPLATE.md +293 -293
- package/vendor/Server/Skills/rn-library-consistency-check/references/ARKTS_COMPONENT_CHECK_GUIDE.md +857 -857
- package/vendor/Server/Skills/rn-library-consistency-check/references/ARKTS_TURBOMODULE_CHECK_GUIDE.md +856 -856
- package/vendor/Server/Skills/rn-library-consistency-check/references/CHECKLIST.md +157 -157
- package/vendor/Server/Skills/rn-library-consistency-check/references/CPP_COMPONENT_CHECK_GUIDE.md +801 -801
- package/vendor/Server/Skills/rn-library-consistency-check/references/CPP_TURBOMODULE_CHECK_GUIDE.md +683 -683
- package/vendor/Server/Skills/rn-library-consistency-check/references/FUNCTION_COMPARISON_GUIDE.md +233 -233
- package/vendor/Server/Skills/rn-library-consistency-check/references/NATIVE_COMPONENT_IDENTIFICATION.md +1373 -1373
- package/vendor/Server/Skills/rn-library-consistency-check/references/SCORING_STANDARD.md +220 -220
- package/vendor/Server/Skills/rn-library-consistency-check/scripts/validate-skill.py +245 -245
- package/vendor/Server/Skills/rn-library-documentation-quality-check/SKILL.md +263 -263
- package/vendor/Server/Skills/rn-library-documentation-quality-check/assets/MODEL.md +414 -414
- package/vendor/Server/Skills/rn-library-documentation-quality-check/assets/MODEL_en.md +413 -413
- package/vendor/Server/Skills/rn-library-documentation-quality-check/assets/REPORT_TEMPLATE.md +311 -311
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/CHECK_CHECKLIST.md +355 -355
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/CROSS_VALIDATION_GUIDE.md +115 -115
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/DOC_COLLECTION_GUIDE.md +139 -139
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/EXAMPLES.md +586 -586
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/GOTCHAS.md +57 -57
- package/vendor/Server/Skills/rn-library-documentation-quality-check/scripts/validate-skill.py +259 -259
- package/vendor/Server/Skills/rn-library-interface-analyzer/SKILL.md +301 -301
- package/vendor/Server/Skills/rn-library-interface-analyzer/assets/REPORT_TEMPLATE.md +148 -148
- package/vendor/Server/Skills/rn-library-interface-analyzer/references/DOC_ANNOTATION_GUIDE.md +118 -118
- package/vendor/Server/Skills/rn-library-interface-analyzer/references/SCRIPT_USAGE_GUIDE.md +168 -168
- package/vendor/Server/Skills/rn-library-interface-analyzer/references/URL_PARSING_RULES.md +176 -176
- package/vendor/Server/Skills/rn-library-issue-generalizer/SKILL.md +274 -274
- package/vendor/Server/Skills/rn-library-issue-generalizer/assets/case-template.md +45 -45
- package/vendor/Server/Skills/rn-library-issue-generalizer/assets/rule-template.md +25 -25
- package/vendor/Server/Skills/rn-library-issue-generalizer/references/PR_FETCH_GUIDE.md +61 -61
- package/vendor/Server/Skills/rn-library-issue-generalizer/references/RULE_TEMPLATE_GUIDE.md +165 -165
- package/vendor/Server/Skills/rn-library-issue-generalizer/scripts/fetch-pr-info.py +239 -239
- package/vendor/Server/Skills/rn-library-known-issue-check/SKILL.md +263 -263
- package/vendor/Server/Skills/rn-library-known-issue-check/assets/REPORT_TEMPLATE.md +96 -96
- package/vendor/Server/Skills/rn-library-known-issue-check/references/COMPLIANCE_CHECKLIST.md +57 -57
- package/vendor/Server/Skills/rn-library-known-issue-check/references/INSPECTION_GUIDE.md +99 -99
- package/vendor/Server/Skills/rn-library-known-issue-check/references/PRESCREEN_GUIDE.md +64 -64
- package/vendor/Server/Skills/rn-library-known-issue-check/references/SOURCE_PREP_GUIDE.md +74 -74
- package/vendor/Server/Skills/rn-library-known-issue-check/scripts/validate-known-issue-report.py +164 -164
- package/vendor/Server/Skills/rn-library-memory-leak-check/SKILL.md +356 -339
- package/vendor/Server/Skills/rn-library-memory-leak-check/assets/REPORT_TEMPLATE.md +85 -83
- package/vendor/Server/Skills/rn-library-memory-leak-check/references/CHECKLIST.md +905 -859
- package/vendor/Server/Skills/rn-library-memory-leak-check/references/HARMONY_CODE_PATTERNS.md +124 -122
- package/vendor/Server/Skills/rn-library-memory-leak-check/scripts/scan_harmony_code.py +287 -279
- package/vendor/Server/Skills/rn-library-stability-check/SKILL.md +273 -273
- package/vendor/Server/Skills/rn-library-stability-check/assets/REPORT_TEMPLATE.md +129 -129
- package/vendor/Server/Skills/rn-library-stability-check/references/CHECKLIST.md +581 -581
- package/vendor/Server/Skills/rn-library-stability-check/references/SCORING_RULES.md +138 -138
- package/vendor/Server/Skills/rn-library-stability-check/scripts/scan-harmony-code.py +168 -168
- package/vendor/Server/Skills/rn-library-test-coverage-check/SKILL.md +526 -506
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/CHECKLIST.md +321 -280
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/DEMO_LOCATION.md +221 -221
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/REPORT_TEMPLATE.md +220 -209
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/SCRIPT_USAGE.md +325 -325
- package/vendor/Server/Skills/rn-ohos-xts-generator/SKILL.md +279 -279
- package/vendor/Server/Skills/rn-ohos-xts-generator/assets/TEST_FILE_TEMPLATES.md +404 -404
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/BUILD_TROUBLESHOOTING.md +185 -185
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/BUILD_WORKFLOW.md +265 -265
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/COMMON_CONFIG.md +189 -189
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/CONFIG_GUIDE.md +203 -203
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/COVERAGE_ANALYZER.md +147 -147
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/DESIGN_DOC_GUIDE.md +148 -148
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/GENERATION_FLOW.md +165 -165
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/GENERATION_STRATEGY.md +195 -195
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/HARMONY_SCANNER.md +249 -249
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/JEST_FRAMEWORK.md +235 -235
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/PLATFORM_COMPAT.md +161 -161
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/RN_TEST_PATTERNS.md +413 -413
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/SOURCE_PARSER.md +235 -235
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/TEST_CONVENTIONS.md +245 -245
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/TROUBLESHOOTING.md +282 -282
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/USAGE_GUIDE.md +251 -251
- package/vendor/Server/Skills/rnoh-cptf-api-test/SKILL.md +469 -469
- package/vendor/Server/Skills/rnoh-cptf-api-test/assets/CPTF_TEST_TEMPLATE.md +310 -310
- package/vendor/Server/Skills/rnoh-cptf-api-test/assets/DEMO_PAGE_TEMPLATE.md +303 -303
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/CPTF_TEST_GENERATION_GUIDE.md +421 -421
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/DEMO_GENERATION_GUIDE.md +358 -358
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/QUALITY_CHECKLIST.md +114 -114
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/SPEC_PARSING_GUIDE.md +274 -274
- package/vendor/Server/Skills/rnoh-cptf-api-test/scripts/validate-rnoh-cptf-api-test.sh +185 -185
- package/vendor/Server/Skills/rnoh-cptf-demo-test/SKILL.md +191 -191
- package/vendor/Server/Skills/rnoh-cptf-demo-test/assets/TEST_TEMPLATE.md +216 -216
- package/vendor/Server/Skills/rnoh-cptf-demo-test/references/CPTF_SETUP.md +107 -107
- package/vendor/Server/Skills/rnoh-cptf-demo-test/references/DEMO_ANALYSIS.md +120 -120
- package/vendor/Server/Skills/rnoh-cptf-demo-test/scripts/validate-rnoh-cptf-test.sh +108 -108
- package/vendor/Server/Skills/rnoh-cptf-test-run/SKILL.md +237 -237
- package/vendor/Server/Skills/rnoh-cptf-test-run/references/DEBUG_PLAYBOOK.md +261 -261
- package/vendor/Server/Skills/rnoh-cptf-test-run/scripts/validate-run-env.sh +112 -112
- package/vendor/Server/Skills/rnoh-lib-code-adapt/SKILL.md +497 -497
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/adapt-checklist.md +270 -270
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/api-migration-checklist.md +164 -164
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/common-compile-errors.md +556 -556
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/deveco-cli-tools.md +459 -459
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/edge-cases.md +65 -65
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/har-tgz-build.md +512 -512
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/version-compat-matrix.md +132 -132
- package/vendor/Server/Skills/rnoh-lib-code-adapt/scripts/auto-integrate.sh +424 -424
- package/vendor/Server/Skills/rnoh-lib-demo-coverage/SKILL.md +137 -137
- package/vendor/Server/Skills/rnoh-lib-demo-create/SKILL.md +306 -306
- package/vendor/Server/Skills/rnoh-lib-demo-create/assets/DEMO_PAGE_TEMPLATE.md +485 -485
- package/vendor/Server/Skills/rnoh-lib-demo-create/assets/INDEX_TEMPLATE.md +172 -172
- package/vendor/Server/Skills/rnoh-lib-demo-create/references/DEMO_CODE_RULES.md +422 -422
- package/vendor/Server/Skills/rnoh-lib-demo-create/references/QUALITY_CHECKLIST.md +95 -95
- package/vendor/Server/Skills/rnoh-lib-demo-create/references/SOURCE_EXPLORATION.md +169 -169
- package/vendor/Server/Skills/rnoh-lib-demo-doc/SKILL.md +554 -554
- package/vendor/Server/Skills/rnoh-lib-demo-doc/assets/DEMO_DOC_TEMPLATE.md +106 -106
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/COVERAGE_INCREMENTAL.md +216 -216
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/DEMO_DESIGN_RULES.md +413 -413
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/OUTPUT_FORMAT.md +269 -269
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/QUALITY_CHECKLIST.md +98 -98
- package/vendor/Server/Skills/rnoh-lib-func-test/SKILL.md +337 -337
- package/vendor/Server/Skills/rnoh-lib-rnt-search/SKILL.md +722 -722
- package/vendor/Server/Skills/rnoh-lib-rnt-search/assets/PORT_REPORT_TEMPLATE.md +219 -219
- package/vendor/Server/Skills/rnoh-lib-rnt-search/references/DEMO_PORTING_GUIDE.md +345 -345
- package/vendor/Server/Skills/rnoh-lib-rnt-search/references/PORT_VERIFICATION.md +269 -269
- package/vendor/Server/Skills/rnoh-lib-rnt-search/references/RNT_PROJECT_STRUCTURE.md +173 -173
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/analyze-demo-deps.cjs +267 -267
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/detect-rnoh-version.cjs +174 -174
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/find-rnt-demo.sh +111 -111
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/port-demo.sh +186 -186
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/read-lib-meta.cjs +150 -150
- package/vendor/Server/Skills/rnoh-lib-test-align/SKILL.md +296 -296
- package/vendor/Server/Skills/rnoh-lib-test-align/references/jest-troubleshooting.md +371 -371
- package/vendor/Server/Skills/rnoh-lib-test-align/references/port-test-demo-guide.md +212 -212
- package/vendor/Server/Skills/rnoh-lib-test-align/references/runtime-troubleshooting.md +345 -345
- package/vendor/Server/Skills/rnoh-lib-test-align/references/unit-test-template.md +223 -223
- package/vendor/Server/Skills/rnoh-lib-test-align/scripts/port-test-demo.sh +1053 -1053
- package/vendor/Server/Skills/rnoh-lib-version-diff/SKILL.md +295 -255
- package/vendor/Server/Skills/rnoh-lib-version-diff/references/OHOS_ADAPTATION.md +82 -77
- package/vendor/Server/Skills/rnoh-lib-version-diff/references/OHOS_API_LOOKUP.md +224 -224
- package/vendor/Server/Skills/rnoh-lib-version-diff/references/script-reference.md +175 -174
- package/vendor/Server/Skills/rnoh-lib-version-diff/scripts/detect-upstream-version.js +967 -967
- package/vendor/Server/Skills/rnoh-lib-version-diff/scripts/generate-diff.js +1798 -1798
- package/vendor/Server/Skills/rnoh-lib-version-diff/scripts/package.json +5 -5
- package/vendor/Server/Skills/rnoh-lib-version-diff/templates/report-template.md +180 -137
- package/vendor/Server/Skills/rnoh-lib-xts-coverage/SKILL.md +145 -145
- package/vendor/Server/Skills/skill-generator/SKILL.md +365 -365
- package/vendor/Server/Skills/skill-generator/assets/SKILL_TEMPLATE.md +183 -183
- package/vendor/Server/Skills/skill-generator/references/COMPLIANCE_CHECKLIST.md +82 -82
- package/vendor/Server/Skills/skill-generator/references/KB_QUERY_GUIDE.md +110 -110
- package/vendor/Server/Skills/skill-generator/references/MCP_TOOL_DISCOVERY.md +122 -122
- package/vendor/Server/Skills/skill-generator/references/SKILL_SPEC.md +121 -121
- package/vendor/Server/Skills/skill-generator/scripts/validate-skill.cjs +259 -259
- package/vendor/Server/Skills/task-analysis/SKILL.md +234 -234
- package/vendor/Server/Skills/task-analysis/assets/OUTPUT_EXAMPLES.md +160 -160
- package/vendor/Server/Skills/task-analysis/references/ACCEPTANCE_CRITERIA_GUIDE.md +190 -190
- package/vendor/Server/Skills/task-analysis/references/ANALYSIS_SCHEMA.md +224 -224
- package/vendor/Server/Skills/task-analysis/references/INTEGRATION_CONTEXT.md +162 -162
- package/vendor/Server/Skills/task-analysis/references/LESSONS_LEARNED.md +55 -55
- package/vendor/Server/Skills/task-analysis/references/REPLAN_CONTEXT_GUIDE.md +126 -126
- package/vendor/Server/Skills/task-analysis/scripts/validate-analysis-output.sh +256 -256
- package/vendor/Server/Skills/task-decomposition/SKILL.md +528 -528
- package/vendor/Server/Skills/task-decomposition/assets/OUTPUT_EXAMPLES.md +451 -451
- package/vendor/Server/Skills/task-decomposition/references/ACCEPTANCE_CRITERIA_GUIDE.md +179 -179
- package/vendor/Server/Skills/task-decomposition/references/DEPENDENCY_GRAPH_GUIDE.md +152 -152
- package/vendor/Server/Skills/task-decomposition/references/INTEGRATION_CONTEXT.md +175 -175
- package/vendor/Server/Skills/task-decomposition/references/REPLAN_CONTEXT_GUIDE.md +195 -195
- package/vendor/Server/Skills/task-decomposition/references/TASK_DECOMPOSITION_TEMPLATES.md +226 -226
- package/vendor/Server/Skills/task-decomposition/scripts/list-available-skills.cjs +263 -263
- package/vendor/Server/Skills/task-decomposition/scripts/skill-blacklist.json +29 -29
- package/vendor/Server/Skills/task-decomposition/scripts/validate-decomposition-output.cjs +376 -376
- package/vendor/Server/Skills/task-decomposition/scripts/validate-param-consistency.cjs +259 -259
- package/vendor/Server/Skills/task-decomposition/scripts/validate-specified-skills.cjs +216 -216
- package/vendor/Server/Skills/task-decomposition/scripts/validate-step-graph.cjs +424 -424
- package/vendor/Server/Skills/tpc-cpp-check/SKILL.md +427 -427
- package/vendor/Server/Skills/tpc-cpp-check/references/CHECKLIST.md +214 -214
- package/vendor/Server/Skills/tpc-cpp-check/references/HPKBUILD_GUIDE.md +235 -235
- package/vendor/Server/Skills/tpc-cpp-check/references/REPORT_TEMPLATE.md +250 -250
- package/vendor/Server/TestCheck/TestCheck.js +775 -775
- package/vendor/Server/TestCheck/index.js +11 -11
- package/vendor/Server/library/McpToolGuide.js +280 -280
- package/vendor/Server/library/StatsService.js +126 -126
- package/vendor/Server/library/cstTime.js +16 -16
- package/vendor/VERSION +3 -3
- package/workflows/pr-check.mjs +105 -105
- package/workflows/pr-push.mjs +192 -192
- package/vendor/Server/Agent/SkillSelector/types.js +0 -63
|
@@ -1,358 +1,358 @@
|
|
|
1
|
-
# Demo 生成指南
|
|
2
|
-
|
|
3
|
-
> Phase 2-3 的详细操作手册。核心是平台兼容性分析、可测试性设计、Demo 代码生成规范。
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## 1. 平台兼容性分析
|
|
8
|
-
|
|
9
|
-
### 1.1 Platform.OS 分支分析
|
|
10
|
-
|
|
11
|
-
搜索入口文件中的平台分支:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
grep -n "Platform.OS" {projectRoot}/node_modules/{harmonyPkgName}/index.js
|
|
15
|
-
grep -n "Platform.OS" {projectRoot}/node_modules/{harmonyPkgName}/src/**/*.ts
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
分析结果分类:
|
|
19
|
-
|
|
20
|
-
| 分类 | 特征 | 处理 |
|
|
21
|
-
|------|------|------|
|
|
22
|
-
| harmony 可用 | `Platform.OS === 'harmony'` 分支内定义 | 生成 Demo + Test |
|
|
23
|
-
| iOS/Android 专属 | 仅在其他分支定义 | 跳过,不生成 |
|
|
24
|
-
| 无平台分支 | TurboModule 原生适配,全部可用 | 全部生成 |
|
|
25
|
-
| 条件导出 | `if (Platform.OS === 'harmony')` 包裹整个导出 | 按实际导出处理 |
|
|
26
|
-
|
|
27
|
-
### 1.2 方法实现状态确认
|
|
28
|
-
|
|
29
|
-
探查 ArkTS 实现文件,排除未实现方法:
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
grep -r "throw new Error('not implemented')" {projectRoot}/harmony/
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
| 状态 | 处理 |
|
|
36
|
-
|------|------|
|
|
37
|
-
| 已实现 | 正常生成 Demo + Test |
|
|
38
|
-
| `throw new Error('not implemented')` | 跳过,不生成 |
|
|
39
|
-
| 部分实现 | 标注,生成但测试中放宽断言 |
|
|
40
|
-
|
|
41
|
-
### 1.3 权限需求分析
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
cat {projectRoot}/harmony/entry/src/main/module.json5 | grep -A5 "requestPermissions"
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
常见权限映射:
|
|
48
|
-
|
|
49
|
-
| 功能 | 权限 | Demo 处理 |
|
|
50
|
-
|------|------|-----------|
|
|
51
|
-
| 麦克风 | ohos.permission.MICROPHONE | 调用前请求权限 |
|
|
52
|
-
| 相机 | ohos.permission.CAMERA | 调用前请求权限 |
|
|
53
|
-
| 定位 | ohos.permission.LOCATION | 调用前请求权限 |
|
|
54
|
-
| 文件读写 | ohos.permission.FILE_READ/WRITE | 调用前请求权限 |
|
|
55
|
-
| 网络 | ohos.permission.INTERNET | 通常自动授予 |
|
|
56
|
-
|
|
57
|
-
### 1.4 MCP 工具辅助
|
|
58
|
-
|
|
59
|
-
调用 `script_rn_scan_exports` 交叉验证:
|
|
60
|
-
|
|
61
|
-
- `dir`:`{projectRoot}/node_modules/{harmonyPkgName}`
|
|
62
|
-
- `compare`:false
|
|
63
|
-
- 单目录扫描模式,提取 exports/interface/TurboModule 方法签名
|
|
64
|
-
|
|
65
|
-
调用 `kb_search` 查询鸿蒙平台特定约束:
|
|
66
|
-
- `HarmonyOS 权限 {功能}`
|
|
67
|
-
- `RNOH TurboModule 适配`
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## 2. 可测试性设计规则
|
|
72
|
-
|
|
73
|
-
> ⚠️ 这是本技能与 `rnoh-lib-demo-create` 的核心差异。Demo 必须为 CPTF 自动化测试而设计。
|
|
74
|
-
|
|
75
|
-
### 2.1 testID 规则
|
|
76
|
-
|
|
77
|
-
| 元素 | testID 格式 | 示例 |
|
|
78
|
-
|------|------------|------|
|
|
79
|
-
| 触发按钮 | `{apiName}-btn` | `methodA-btn` |
|
|
80
|
-
| 结果文本 | `{apiName}-result` | `methodA-result` |
|
|
81
|
-
| 状态指示 | `{apiName}-status` | `recording-status` |
|
|
82
|
-
|
|
83
|
-
```tsx
|
|
84
|
-
<Button testID="methodA-btn" title="调用 methodA" onPress={...} />
|
|
85
|
-
<Text testID="methodA-result">methodA结果:{result}</Text>
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### 2.2 固定文本前缀规则
|
|
89
|
-
|
|
90
|
-
所有动态值必须附加固定前缀,格式:`{API名}结果:{值}`
|
|
91
|
-
|
|
92
|
-
| 场景 | 前缀格式 | 示例 |
|
|
93
|
-
|------|----------|------|
|
|
94
|
-
| 正常结果 | `{API名}结果:{值}` | `methodA结果:success` |
|
|
95
|
-
| 错误信息 | `错误信息:{error}` | `错误信息:TypeError` |
|
|
96
|
-
| 状态值 | `{API名}状态:{值}` | `录音状态:recording` |
|
|
97
|
-
| 数组结果 | `{API名}结果:{JSON}` | `getList结果:[1,2,3]` |
|
|
98
|
-
| 布尔值 | `{API名}结果:{true/false}` | `isEnabled结果:true` |
|
|
99
|
-
|
|
100
|
-
> ⚠️ 冒号统一使用**全角** `:`(中文冒号),与 testerino demo 常见风格一致。CPTF 的 `waitForText` 是子串精确匹配,断言时可省略冒号(如 `methodA结果`)以兼容两种冒号。
|
|
101
|
-
|
|
102
|
-
### 2.3 确定性输出规则
|
|
103
|
-
|
|
104
|
-
| 数据类型 | 处理方式 | 示例 |
|
|
105
|
-
|----------|----------|------|
|
|
106
|
-
| 随机数 | 附加范围标注 | `随机数结果:{value}(范围:0-100)` |
|
|
107
|
-
| 时间戳 | 转为可读格式 | `时间结果:{HH:MM:SS}` |
|
|
108
|
-
| UUID | 仅验证格式 | `UUID结果:{uuid}(格式校验)` |
|
|
109
|
-
| 大数据 | 截断显示 | `数据结果:{前100字符}...` |
|
|
110
|
-
| null/undefined | 显示字面量 | `结果:null` |
|
|
111
|
-
|
|
112
|
-
### 2.4 按钮唯一标识规则
|
|
113
|
-
|
|
114
|
-
每个按钮 title 必须包含 API 名,保证 `textContains` 全局唯一:
|
|
115
|
-
|
|
116
|
-
```tsx
|
|
117
|
-
// 正确:title 含 API 名,唯一
|
|
118
|
-
<Button title="调用 methodA(参数1)" />
|
|
119
|
-
<Button title="调用 methodB" />
|
|
120
|
-
|
|
121
|
-
// 错误:title 重复或不唯一
|
|
122
|
-
<Button title="执行" />
|
|
123
|
-
<Button title="测试" />
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## 3. Demo 页面代码规范
|
|
129
|
-
|
|
130
|
-
### 3.1 目录结构
|
|
131
|
-
|
|
132
|
-
```
|
|
133
|
-
{exampleDir}/cptf/
|
|
134
|
-
├── index.tsx # 主入口
|
|
135
|
-
└── demo/
|
|
136
|
-
├── 001_{apiCategory1}Page.tsx # 按 API 分类拆分页面
|
|
137
|
-
├── 002_{apiCategory2}Page.tsx
|
|
138
|
-
└── ...
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
文件命名规则:
|
|
142
|
-
- 前缀序号:`001_`、`002_`,按 API 分类顺序
|
|
143
|
-
- 分类名:kebab-case,如 `turbo-module-methods`、`component-props`、`events`
|
|
144
|
-
- 示例:`001_turbo-module-methods.tsx`、`002_component-props.tsx`、`003_events.tsx`
|
|
145
|
-
|
|
146
|
-
### 3.2 页面代码核心规则
|
|
147
|
-
|
|
148
|
-
| 规则 | 说明 | 原因 |
|
|
149
|
-
|------|------|------|
|
|
150
|
-
| 根组件用 `View` | 禁止 `ScrollView` 作为根 | Tester 已有 ScrollView,嵌套导致高度塌陷 |
|
|
151
|
-
| 不用 `SafeAreaView`/`StatusBar` | Tester 框架不需要 | 避免冗余 |
|
|
152
|
-
| 不用 `Slider` | HarmonyOS 不支持 | 用按钮组替代 |
|
|
153
|
-
| 不用 `console.error()` | 会触发系统弹窗 | 用 `console.warn()` 替代 |
|
|
154
|
-
| 每个按钮设 `testID` | CPTF 优先 testID 定位 | 可测试性设计核心 |
|
|
155
|
-
| 结果 Text 固定前缀 | CPTF `waitForText` 可靠匹配 | 可测试性设计核心 |
|
|
156
|
-
| 无裸值渲染 | 所有动态值附加固定前缀 | 消除快照差集需求 |
|
|
157
|
-
| 平台兼容性 | 只用 harmony 分支 API | 基于 Phase 2.1 |
|
|
158
|
-
| 权限请求 | 敏感操作前请求权限 | HarmonyOS 权限模型 |
|
|
159
|
-
| 异步处理 | `async/await` + `try/catch` | 不用 `.then()/.catch()` 链 |
|
|
160
|
-
| 无注释 | 代码中不使用 `//` 或 `/* */` | 代码规范 |
|
|
161
|
-
| Hook 顶层调用 | 不在事件回调中调用 Hook | React Hooks 规则 |
|
|
162
|
-
| type 导入 | `import { type Xxx }` inline 语法 | 避免类型进入打包 |
|
|
163
|
-
| Provider 子组件拆分 | 依赖 Context 的 Hook/组件拆分 | 确保 Context 有值 |
|
|
164
|
-
| 废弃接口验证 | 使用 `===` 引用相等性比较 | 比功能对比更可靠 |
|
|
165
|
-
|
|
166
|
-
### 3.3 各 API 类型的 Demo 页面设计
|
|
167
|
-
|
|
168
|
-
#### 3.3.1 TurboModule 同步方法
|
|
169
|
-
|
|
170
|
-
```tsx
|
|
171
|
-
<View>
|
|
172
|
-
<Button testID="syncMethod-btn" title="调用 syncMethod(param)" onPress={() => {
|
|
173
|
-
try {
|
|
174
|
-
const result = NativeModule.syncMethod('param');
|
|
175
|
-
setResult(`syncMethod结果:${result}`);
|
|
176
|
-
} catch (e) {
|
|
177
|
-
setResult(`错误信息:${e}`);
|
|
178
|
-
}
|
|
179
|
-
}} />
|
|
180
|
-
<Text testID="syncMethod-result">{result}</Text>
|
|
181
|
-
</View>
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
#### 3.3.2 TurboModule 异步方法
|
|
185
|
-
|
|
186
|
-
```tsx
|
|
187
|
-
<View>
|
|
188
|
-
<Button testID="asyncMethod-btn" title="调用 asyncMethod(param)" onPress={async () => {
|
|
189
|
-
setLoading(true);
|
|
190
|
-
try {
|
|
191
|
-
const result = await NativeModule.asyncMethod('param');
|
|
192
|
-
setResult(`asyncMethod结果:${JSON.stringify(result)}`);
|
|
193
|
-
} catch (e) {
|
|
194
|
-
setResult(`错误信息:${e}`);
|
|
195
|
-
} finally {
|
|
196
|
-
setLoading(false);
|
|
197
|
-
}
|
|
198
|
-
}} />
|
|
199
|
-
<Text testID="asyncMethod-result">{loading ? '加载中...' : result}</Text>
|
|
200
|
-
</View>
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
#### 3.3.3 事件回调
|
|
204
|
-
|
|
205
|
-
```tsx
|
|
206
|
-
<View>
|
|
207
|
-
<Button testID="startListen-btn" title="开始监听 onEvent" onPress={() => {
|
|
208
|
-
const sub = DeviceEventEmitter.addListener('onEvent', (data) => {
|
|
209
|
-
setEventResult(`onEvent结果:${JSON.stringify(data)}`);
|
|
210
|
-
});
|
|
211
|
-
setSubscription(sub);
|
|
212
|
-
}} />
|
|
213
|
-
<Button testID="stopListen-btn" title="停止监听 onEvent" onPress={() => {
|
|
214
|
-
subscription?.remove();
|
|
215
|
-
setEventResult('onEvent状态:已停止');
|
|
216
|
-
}} />
|
|
217
|
-
<Text testID="onEvent-result">{eventResult}</Text>
|
|
218
|
-
</View>
|
|
219
|
-
```
|
|
220
|
-
|
|
221
|
-
#### 3.3.4 组件属性
|
|
222
|
-
|
|
223
|
-
```tsx
|
|
224
|
-
<View>
|
|
225
|
-
<Button testID="toggleProp-btn" title="切换 prop1 值" onPress={() => setProp1(!prop1)} />
|
|
226
|
-
<Text testID="componentProp-result">组件属性prop1:{String(prop1)}</Text>
|
|
227
|
-
<ComponentA prop1={prop1} />
|
|
228
|
-
</View>
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
#### 3.3.5 常量/枚举
|
|
232
|
-
|
|
233
|
-
```tsx
|
|
234
|
-
<View>
|
|
235
|
-
<Text testID="constant-result">常量CONSTANT_A:{NativeModule.CONSTANT_A}</Text>
|
|
236
|
-
</View>
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### 3.4 权限请求模板
|
|
240
|
-
|
|
241
|
-
```tsx
|
|
242
|
-
import { Permissions } from 'react-native';
|
|
243
|
-
|
|
244
|
-
const requestPermission = async (permission: string): Promise<boolean> => {
|
|
245
|
-
try {
|
|
246
|
-
const granted = await Permissions.request(permission);
|
|
247
|
-
return granted === 'granted';
|
|
248
|
-
} catch (e) {
|
|
249
|
-
console.warn(`权限请求失败: ${e}`);
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
|
-
};
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
---
|
|
256
|
-
|
|
257
|
-
## 4. 主入口文件与注册
|
|
258
|
-
|
|
259
|
-
### 4.1 index.tsx 结构
|
|
260
|
-
|
|
261
|
-
```tsx
|
|
262
|
-
import { Tester, TestSuite, TestCase } from '@rnoh/testerino';
|
|
263
|
-
import React from 'react';
|
|
264
|
-
import { TurboModuleMethodsPage } from './demo/001_turbo-module-methods';
|
|
265
|
-
import { ComponentPropsPage } from './demo/002_component-props';
|
|
266
|
-
import { EventsPage } from './demo/003_events';
|
|
267
|
-
|
|
268
|
-
function {LibName}Tester() {
|
|
269
|
-
return (
|
|
270
|
-
<Tester>
|
|
271
|
-
<TestSuite name="{libName}">
|
|
272
|
-
<TestCase itShould="TurboModule 方法测试" tags={['C_API']}>
|
|
273
|
-
<TurboModuleMethodsPage />
|
|
274
|
-
</TestCase>
|
|
275
|
-
<TestCase itShould="组件属性测试" tags={['C_API']}>
|
|
276
|
-
<ComponentPropsPage />
|
|
277
|
-
</TestCase>
|
|
278
|
-
<TestCase itShould="事件回调测试" tags={['C_API']}>
|
|
279
|
-
<EventsPage />
|
|
280
|
-
</TestCase>
|
|
281
|
-
</TestSuite>
|
|
282
|
-
</Tester>
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
export default {LibName}Tester;
|
|
287
|
-
export const displayName = '{libName}';
|
|
288
|
-
export const framework = 'react';
|
|
289
|
-
export const category = '{category}';
|
|
290
|
-
export const title = '{libName}';
|
|
291
|
-
export const description = '{libName} 接口规格驱动 Demo';
|
|
292
|
-
export const examples = [
|
|
293
|
-
{ title: 'TurboModule 方法', description: '...' },
|
|
294
|
-
{ title: '组件属性', description: '...' },
|
|
295
|
-
{ title: '事件回调', description: '...' },
|
|
296
|
-
];
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
### 4.2 Demo 入口切换
|
|
300
|
-
|
|
301
|
-
> 本技能不修改现有 `registerFile`(如 `RNTesterList.ts`),而是直接修改 `{exampleDir}/index.js`,将 App 入口指向 CPTF Demo:
|
|
302
|
-
|
|
303
|
-
```js
|
|
304
|
-
// {exampleDir}/index.js — 修改前
|
|
305
|
-
import App from './src/index';
|
|
306
|
-
// 修改后
|
|
307
|
-
import App from './cptf/index';
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
这样 CPTF 测试运行时 App 直接加载 CPTF Demo 页面,无需在现有 Demo 注册体系中追加。
|
|
311
|
-
|
|
312
|
-
### 4.3 入口切换说明
|
|
313
|
-
|
|
314
|
-
本技能采用**直接修改 `index.js`** 的方式切换 Demo 入口,而非在现有 `registerFile`(如 `RNTesterList.ts`)中追加注册。原因:
|
|
315
|
-
|
|
316
|
-
1. CPTF 测试需要 App 启动即加载 CPTF Demo 页面(含 testerino Tester 框架),不经过现有 Demo 选择器
|
|
317
|
-
2. 不污染现有 Demo 注册体系,交付后可轻松恢复(将 `index.js` 改回 `./src/index`)
|
|
318
|
-
3. 无需识别 registerFile 的注册模式(A/B/C)
|
|
319
|
-
|
|
320
|
-
> ⚠️ 修改 `index.js` 后必须重新构建 HAP(`npm run dev` + `devecocli build`),否则设备上的 `bundle.harmony.js` 不含新入口。
|
|
321
|
-
|
|
322
|
-
---
|
|
323
|
-
|
|
324
|
-
## 5. 常见陷阱
|
|
325
|
-
|
|
326
|
-
### 5.1 全角/半角冒号
|
|
327
|
-
|
|
328
|
-
Demo 代码中结果文本的冒号必须统一使用全角 `:`,CPTF 测试的 `waitForText` 参数也必须逐字符匹配。
|
|
329
|
-
|
|
330
|
-
如果 Demo 代码中混用了半角 `:`,CPTF 测试将无法匹配,导致步骤超时。
|
|
331
|
-
|
|
332
|
-
### 5.2 异步渲染时序
|
|
333
|
-
|
|
334
|
-
异步方法调用后,结果 Text 可能需要一段时间才渲染。Demo 代码应:
|
|
335
|
-
- 异步执行期间显示 `加载中...` 文本
|
|
336
|
-
- CPTF 测试的 `waitForText` 应轮询等待(timeout 8000ms)
|
|
337
|
-
|
|
338
|
-
### 5.3 事件监听清理
|
|
339
|
-
|
|
340
|
-
Demo 中注册的事件监听器必须在组件卸载时清理:
|
|
341
|
-
|
|
342
|
-
```tsx
|
|
343
|
-
useEffect(() => {
|
|
344
|
-
return () => {
|
|
345
|
-
subscription?.remove();
|
|
346
|
-
};
|
|
347
|
-
}, [subscription]);
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
否则 CPTF 测试重复进入页面时可能出现内存泄漏。
|
|
351
|
-
|
|
352
|
-
### 5.4 无平台分支库
|
|
353
|
-
|
|
354
|
-
部分库(如 `react-native-safe-area-context`)没有 `Platform.OS === 'harmony'` 分支,而是通过 TurboModule 原生适配。探查时需区分此类库,无需过滤 iOS/Android 专属属性,JS 层所有导出在 HarmonyOS 上全部可用。
|
|
355
|
-
|
|
356
|
-
### 5.5 废弃接口
|
|
357
|
-
|
|
358
|
-
部分库包含 `@deprecated` 废弃别名接口。废弃接口在 HarmonyOS 平台仍正常可用,需生成 Demo 验证其兼容性,并使用引用相等性比较(`===`)验证别名关系。
|
|
1
|
+
# Demo 生成指南
|
|
2
|
+
|
|
3
|
+
> Phase 2-3 的详细操作手册。核心是平台兼容性分析、可测试性设计、Demo 代码生成规范。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. 平台兼容性分析
|
|
8
|
+
|
|
9
|
+
### 1.1 Platform.OS 分支分析
|
|
10
|
+
|
|
11
|
+
搜索入口文件中的平台分支:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
grep -n "Platform.OS" {projectRoot}/node_modules/{harmonyPkgName}/index.js
|
|
15
|
+
grep -n "Platform.OS" {projectRoot}/node_modules/{harmonyPkgName}/src/**/*.ts
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
分析结果分类:
|
|
19
|
+
|
|
20
|
+
| 分类 | 特征 | 处理 |
|
|
21
|
+
|------|------|------|
|
|
22
|
+
| harmony 可用 | `Platform.OS === 'harmony'` 分支内定义 | 生成 Demo + Test |
|
|
23
|
+
| iOS/Android 专属 | 仅在其他分支定义 | 跳过,不生成 |
|
|
24
|
+
| 无平台分支 | TurboModule 原生适配,全部可用 | 全部生成 |
|
|
25
|
+
| 条件导出 | `if (Platform.OS === 'harmony')` 包裹整个导出 | 按实际导出处理 |
|
|
26
|
+
|
|
27
|
+
### 1.2 方法实现状态确认
|
|
28
|
+
|
|
29
|
+
探查 ArkTS 实现文件,排除未实现方法:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
grep -r "throw new Error('not implemented')" {projectRoot}/harmony/
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
| 状态 | 处理 |
|
|
36
|
+
|------|------|
|
|
37
|
+
| 已实现 | 正常生成 Demo + Test |
|
|
38
|
+
| `throw new Error('not implemented')` | 跳过,不生成 |
|
|
39
|
+
| 部分实现 | 标注,生成但测试中放宽断言 |
|
|
40
|
+
|
|
41
|
+
### 1.3 权限需求分析
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cat {projectRoot}/harmony/entry/src/main/module.json5 | grep -A5 "requestPermissions"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
常见权限映射:
|
|
48
|
+
|
|
49
|
+
| 功能 | 权限 | Demo 处理 |
|
|
50
|
+
|------|------|-----------|
|
|
51
|
+
| 麦克风 | ohos.permission.MICROPHONE | 调用前请求权限 |
|
|
52
|
+
| 相机 | ohos.permission.CAMERA | 调用前请求权限 |
|
|
53
|
+
| 定位 | ohos.permission.LOCATION | 调用前请求权限 |
|
|
54
|
+
| 文件读写 | ohos.permission.FILE_READ/WRITE | 调用前请求权限 |
|
|
55
|
+
| 网络 | ohos.permission.INTERNET | 通常自动授予 |
|
|
56
|
+
|
|
57
|
+
### 1.4 MCP 工具辅助
|
|
58
|
+
|
|
59
|
+
调用 `script_rn_scan_exports` 交叉验证:
|
|
60
|
+
|
|
61
|
+
- `dir`:`{projectRoot}/node_modules/{harmonyPkgName}`
|
|
62
|
+
- `compare`:false
|
|
63
|
+
- 单目录扫描模式,提取 exports/interface/TurboModule 方法签名
|
|
64
|
+
|
|
65
|
+
调用 `kb_search` 查询鸿蒙平台特定约束:
|
|
66
|
+
- `HarmonyOS 权限 {功能}`
|
|
67
|
+
- `RNOH TurboModule 适配`
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## 2. 可测试性设计规则
|
|
72
|
+
|
|
73
|
+
> ⚠️ 这是本技能与 `rnoh-lib-demo-create` 的核心差异。Demo 必须为 CPTF 自动化测试而设计。
|
|
74
|
+
|
|
75
|
+
### 2.1 testID 规则
|
|
76
|
+
|
|
77
|
+
| 元素 | testID 格式 | 示例 |
|
|
78
|
+
|------|------------|------|
|
|
79
|
+
| 触发按钮 | `{apiName}-btn` | `methodA-btn` |
|
|
80
|
+
| 结果文本 | `{apiName}-result` | `methodA-result` |
|
|
81
|
+
| 状态指示 | `{apiName}-status` | `recording-status` |
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
<Button testID="methodA-btn" title="调用 methodA" onPress={...} />
|
|
85
|
+
<Text testID="methodA-result">methodA结果:{result}</Text>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 2.2 固定文本前缀规则
|
|
89
|
+
|
|
90
|
+
所有动态值必须附加固定前缀,格式:`{API名}结果:{值}`
|
|
91
|
+
|
|
92
|
+
| 场景 | 前缀格式 | 示例 |
|
|
93
|
+
|------|----------|------|
|
|
94
|
+
| 正常结果 | `{API名}结果:{值}` | `methodA结果:success` |
|
|
95
|
+
| 错误信息 | `错误信息:{error}` | `错误信息:TypeError` |
|
|
96
|
+
| 状态值 | `{API名}状态:{值}` | `录音状态:recording` |
|
|
97
|
+
| 数组结果 | `{API名}结果:{JSON}` | `getList结果:[1,2,3]` |
|
|
98
|
+
| 布尔值 | `{API名}结果:{true/false}` | `isEnabled结果:true` |
|
|
99
|
+
|
|
100
|
+
> ⚠️ 冒号统一使用**全角** `:`(中文冒号),与 testerino demo 常见风格一致。CPTF 的 `waitForText` 是子串精确匹配,断言时可省略冒号(如 `methodA结果`)以兼容两种冒号。
|
|
101
|
+
|
|
102
|
+
### 2.3 确定性输出规则
|
|
103
|
+
|
|
104
|
+
| 数据类型 | 处理方式 | 示例 |
|
|
105
|
+
|----------|----------|------|
|
|
106
|
+
| 随机数 | 附加范围标注 | `随机数结果:{value}(范围:0-100)` |
|
|
107
|
+
| 时间戳 | 转为可读格式 | `时间结果:{HH:MM:SS}` |
|
|
108
|
+
| UUID | 仅验证格式 | `UUID结果:{uuid}(格式校验)` |
|
|
109
|
+
| 大数据 | 截断显示 | `数据结果:{前100字符}...` |
|
|
110
|
+
| null/undefined | 显示字面量 | `结果:null` |
|
|
111
|
+
|
|
112
|
+
### 2.4 按钮唯一标识规则
|
|
113
|
+
|
|
114
|
+
每个按钮 title 必须包含 API 名,保证 `textContains` 全局唯一:
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
// 正确:title 含 API 名,唯一
|
|
118
|
+
<Button title="调用 methodA(参数1)" />
|
|
119
|
+
<Button title="调用 methodB" />
|
|
120
|
+
|
|
121
|
+
// 错误:title 重复或不唯一
|
|
122
|
+
<Button title="执行" />
|
|
123
|
+
<Button title="测试" />
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## 3. Demo 页面代码规范
|
|
129
|
+
|
|
130
|
+
### 3.1 目录结构
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
{exampleDir}/cptf/
|
|
134
|
+
├── index.tsx # 主入口
|
|
135
|
+
└── demo/
|
|
136
|
+
├── 001_{apiCategory1}Page.tsx # 按 API 分类拆分页面
|
|
137
|
+
├── 002_{apiCategory2}Page.tsx
|
|
138
|
+
└── ...
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
文件命名规则:
|
|
142
|
+
- 前缀序号:`001_`、`002_`,按 API 分类顺序
|
|
143
|
+
- 分类名:kebab-case,如 `turbo-module-methods`、`component-props`、`events`
|
|
144
|
+
- 示例:`001_turbo-module-methods.tsx`、`002_component-props.tsx`、`003_events.tsx`
|
|
145
|
+
|
|
146
|
+
### 3.2 页面代码核心规则
|
|
147
|
+
|
|
148
|
+
| 规则 | 说明 | 原因 |
|
|
149
|
+
|------|------|------|
|
|
150
|
+
| 根组件用 `View` | 禁止 `ScrollView` 作为根 | Tester 已有 ScrollView,嵌套导致高度塌陷 |
|
|
151
|
+
| 不用 `SafeAreaView`/`StatusBar` | Tester 框架不需要 | 避免冗余 |
|
|
152
|
+
| 不用 `Slider` | HarmonyOS 不支持 | 用按钮组替代 |
|
|
153
|
+
| 不用 `console.error()` | 会触发系统弹窗 | 用 `console.warn()` 替代 |
|
|
154
|
+
| 每个按钮设 `testID` | CPTF 优先 testID 定位 | 可测试性设计核心 |
|
|
155
|
+
| 结果 Text 固定前缀 | CPTF `waitForText` 可靠匹配 | 可测试性设计核心 |
|
|
156
|
+
| 无裸值渲染 | 所有动态值附加固定前缀 | 消除快照差集需求 |
|
|
157
|
+
| 平台兼容性 | 只用 harmony 分支 API | 基于 Phase 2.1 |
|
|
158
|
+
| 权限请求 | 敏感操作前请求权限 | HarmonyOS 权限模型 |
|
|
159
|
+
| 异步处理 | `async/await` + `try/catch` | 不用 `.then()/.catch()` 链 |
|
|
160
|
+
| 无注释 | 代码中不使用 `//` 或 `/* */` | 代码规范 |
|
|
161
|
+
| Hook 顶层调用 | 不在事件回调中调用 Hook | React Hooks 规则 |
|
|
162
|
+
| type 导入 | `import { type Xxx }` inline 语法 | 避免类型进入打包 |
|
|
163
|
+
| Provider 子组件拆分 | 依赖 Context 的 Hook/组件拆分 | 确保 Context 有值 |
|
|
164
|
+
| 废弃接口验证 | 使用 `===` 引用相等性比较 | 比功能对比更可靠 |
|
|
165
|
+
|
|
166
|
+
### 3.3 各 API 类型的 Demo 页面设计
|
|
167
|
+
|
|
168
|
+
#### 3.3.1 TurboModule 同步方法
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
<View>
|
|
172
|
+
<Button testID="syncMethod-btn" title="调用 syncMethod(param)" onPress={() => {
|
|
173
|
+
try {
|
|
174
|
+
const result = NativeModule.syncMethod('param');
|
|
175
|
+
setResult(`syncMethod结果:${result}`);
|
|
176
|
+
} catch (e) {
|
|
177
|
+
setResult(`错误信息:${e}`);
|
|
178
|
+
}
|
|
179
|
+
}} />
|
|
180
|
+
<Text testID="syncMethod-result">{result}</Text>
|
|
181
|
+
</View>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### 3.3.2 TurboModule 异步方法
|
|
185
|
+
|
|
186
|
+
```tsx
|
|
187
|
+
<View>
|
|
188
|
+
<Button testID="asyncMethod-btn" title="调用 asyncMethod(param)" onPress={async () => {
|
|
189
|
+
setLoading(true);
|
|
190
|
+
try {
|
|
191
|
+
const result = await NativeModule.asyncMethod('param');
|
|
192
|
+
setResult(`asyncMethod结果:${JSON.stringify(result)}`);
|
|
193
|
+
} catch (e) {
|
|
194
|
+
setResult(`错误信息:${e}`);
|
|
195
|
+
} finally {
|
|
196
|
+
setLoading(false);
|
|
197
|
+
}
|
|
198
|
+
}} />
|
|
199
|
+
<Text testID="asyncMethod-result">{loading ? '加载中...' : result}</Text>
|
|
200
|
+
</View>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
#### 3.3.3 事件回调
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
<View>
|
|
207
|
+
<Button testID="startListen-btn" title="开始监听 onEvent" onPress={() => {
|
|
208
|
+
const sub = DeviceEventEmitter.addListener('onEvent', (data) => {
|
|
209
|
+
setEventResult(`onEvent结果:${JSON.stringify(data)}`);
|
|
210
|
+
});
|
|
211
|
+
setSubscription(sub);
|
|
212
|
+
}} />
|
|
213
|
+
<Button testID="stopListen-btn" title="停止监听 onEvent" onPress={() => {
|
|
214
|
+
subscription?.remove();
|
|
215
|
+
setEventResult('onEvent状态:已停止');
|
|
216
|
+
}} />
|
|
217
|
+
<Text testID="onEvent-result">{eventResult}</Text>
|
|
218
|
+
</View>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
#### 3.3.4 组件属性
|
|
222
|
+
|
|
223
|
+
```tsx
|
|
224
|
+
<View>
|
|
225
|
+
<Button testID="toggleProp-btn" title="切换 prop1 值" onPress={() => setProp1(!prop1)} />
|
|
226
|
+
<Text testID="componentProp-result">组件属性prop1:{String(prop1)}</Text>
|
|
227
|
+
<ComponentA prop1={prop1} />
|
|
228
|
+
</View>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
#### 3.3.5 常量/枚举
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
<View>
|
|
235
|
+
<Text testID="constant-result">常量CONSTANT_A:{NativeModule.CONSTANT_A}</Text>
|
|
236
|
+
</View>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 3.4 权限请求模板
|
|
240
|
+
|
|
241
|
+
```tsx
|
|
242
|
+
import { Permissions } from 'react-native';
|
|
243
|
+
|
|
244
|
+
const requestPermission = async (permission: string): Promise<boolean> => {
|
|
245
|
+
try {
|
|
246
|
+
const granted = await Permissions.request(permission);
|
|
247
|
+
return granted === 'granted';
|
|
248
|
+
} catch (e) {
|
|
249
|
+
console.warn(`权限请求失败: ${e}`);
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## 4. 主入口文件与注册
|
|
258
|
+
|
|
259
|
+
### 4.1 index.tsx 结构
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
import { Tester, TestSuite, TestCase } from '@rnoh/testerino';
|
|
263
|
+
import React from 'react';
|
|
264
|
+
import { TurboModuleMethodsPage } from './demo/001_turbo-module-methods';
|
|
265
|
+
import { ComponentPropsPage } from './demo/002_component-props';
|
|
266
|
+
import { EventsPage } from './demo/003_events';
|
|
267
|
+
|
|
268
|
+
function {LibName}Tester() {
|
|
269
|
+
return (
|
|
270
|
+
<Tester>
|
|
271
|
+
<TestSuite name="{libName}">
|
|
272
|
+
<TestCase itShould="TurboModule 方法测试" tags={['C_API']}>
|
|
273
|
+
<TurboModuleMethodsPage />
|
|
274
|
+
</TestCase>
|
|
275
|
+
<TestCase itShould="组件属性测试" tags={['C_API']}>
|
|
276
|
+
<ComponentPropsPage />
|
|
277
|
+
</TestCase>
|
|
278
|
+
<TestCase itShould="事件回调测试" tags={['C_API']}>
|
|
279
|
+
<EventsPage />
|
|
280
|
+
</TestCase>
|
|
281
|
+
</TestSuite>
|
|
282
|
+
</Tester>
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export default {LibName}Tester;
|
|
287
|
+
export const displayName = '{libName}';
|
|
288
|
+
export const framework = 'react';
|
|
289
|
+
export const category = '{category}';
|
|
290
|
+
export const title = '{libName}';
|
|
291
|
+
export const description = '{libName} 接口规格驱动 Demo';
|
|
292
|
+
export const examples = [
|
|
293
|
+
{ title: 'TurboModule 方法', description: '...' },
|
|
294
|
+
{ title: '组件属性', description: '...' },
|
|
295
|
+
{ title: '事件回调', description: '...' },
|
|
296
|
+
];
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### 4.2 Demo 入口切换
|
|
300
|
+
|
|
301
|
+
> 本技能不修改现有 `registerFile`(如 `RNTesterList.ts`),而是直接修改 `{exampleDir}/index.js`,将 App 入口指向 CPTF Demo:
|
|
302
|
+
|
|
303
|
+
```js
|
|
304
|
+
// {exampleDir}/index.js — 修改前
|
|
305
|
+
import App from './src/index';
|
|
306
|
+
// 修改后
|
|
307
|
+
import App from './cptf/index';
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
这样 CPTF 测试运行时 App 直接加载 CPTF Demo 页面,无需在现有 Demo 注册体系中追加。
|
|
311
|
+
|
|
312
|
+
### 4.3 入口切换说明
|
|
313
|
+
|
|
314
|
+
本技能采用**直接修改 `index.js`** 的方式切换 Demo 入口,而非在现有 `registerFile`(如 `RNTesterList.ts`)中追加注册。原因:
|
|
315
|
+
|
|
316
|
+
1. CPTF 测试需要 App 启动即加载 CPTF Demo 页面(含 testerino Tester 框架),不经过现有 Demo 选择器
|
|
317
|
+
2. 不污染现有 Demo 注册体系,交付后可轻松恢复(将 `index.js` 改回 `./src/index`)
|
|
318
|
+
3. 无需识别 registerFile 的注册模式(A/B/C)
|
|
319
|
+
|
|
320
|
+
> ⚠️ 修改 `index.js` 后必须重新构建 HAP(`npm run dev` + `devecocli build`),否则设备上的 `bundle.harmony.js` 不含新入口。
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## 5. 常见陷阱
|
|
325
|
+
|
|
326
|
+
### 5.1 全角/半角冒号
|
|
327
|
+
|
|
328
|
+
Demo 代码中结果文本的冒号必须统一使用全角 `:`,CPTF 测试的 `waitForText` 参数也必须逐字符匹配。
|
|
329
|
+
|
|
330
|
+
如果 Demo 代码中混用了半角 `:`,CPTF 测试将无法匹配,导致步骤超时。
|
|
331
|
+
|
|
332
|
+
### 5.2 异步渲染时序
|
|
333
|
+
|
|
334
|
+
异步方法调用后,结果 Text 可能需要一段时间才渲染。Demo 代码应:
|
|
335
|
+
- 异步执行期间显示 `加载中...` 文本
|
|
336
|
+
- CPTF 测试的 `waitForText` 应轮询等待(timeout 8000ms)
|
|
337
|
+
|
|
338
|
+
### 5.3 事件监听清理
|
|
339
|
+
|
|
340
|
+
Demo 中注册的事件监听器必须在组件卸载时清理:
|
|
341
|
+
|
|
342
|
+
```tsx
|
|
343
|
+
useEffect(() => {
|
|
344
|
+
return () => {
|
|
345
|
+
subscription?.remove();
|
|
346
|
+
};
|
|
347
|
+
}, [subscription]);
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
否则 CPTF 测试重复进入页面时可能出现内存泄漏。
|
|
351
|
+
|
|
352
|
+
### 5.4 无平台分支库
|
|
353
|
+
|
|
354
|
+
部分库(如 `react-native-safe-area-context`)没有 `Platform.OS === 'harmony'` 分支,而是通过 TurboModule 原生适配。探查时需区分此类库,无需过滤 iOS/Android 专属属性,JS 层所有导出在 HarmonyOS 上全部可用。
|
|
355
|
+
|
|
356
|
+
### 5.5 废弃接口
|
|
357
|
+
|
|
358
|
+
部分库包含 `@deprecated` 废弃别名接口。废弃接口在 HarmonyOS 平台仍正常可用,需生成 Demo 验证其兼容性,并使用引用相等性比较(`===`)验证别名关系。
|