@ohos-cpf/3rdloop 0.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.
- package/README.md +425 -0
- package/bin/3rdloop.mjs +48 -0
- package/lib/cli.js +741 -0
- package/lib/config.js +318 -0
- package/lib/doctor.js +114 -0
- package/lib/exit-codes.js +31 -0
- package/lib/opencode.js +156 -0
- package/lib/orch.js +427 -0
- package/lib/queries.js +264 -0
- package/lib/runner.js +979 -0
- package/lib/step.js +326 -0
- package/lib/ui.js +223 -0
- package/lib/workflow.js +291 -0
- package/lib/workflows.js +132 -0
- package/package.json +50 -0
- package/vendor/Server/Agent/SkillSelector/README.md +344 -0
- package/vendor/Server/Agent/SkillSelector/core/Agent.js +207 -0
- package/vendor/Server/Agent/SkillSelector/index.js +14 -0
- package/vendor/Server/Agent/SkillSelector/llm/llmClient.js +313 -0
- package/vendor/Server/Agent/SkillSelector/llm/prompts.js +161 -0
- package/vendor/Server/Agent/SkillSelector/llm/reactSteps.js +144 -0
- package/vendor/Server/Agent/SkillSelector/matcher/fuzzyMatcher.js +433 -0
- package/vendor/Server/Agent/SkillSelector/scanner/skillScanner.js +382 -0
- package/vendor/Server/Agent/SkillSelector/types.js +63 -0
- package/vendor/Server/Agent/SkillSelector/utils/actionWords.js +60 -0
- package/vendor/Server/Brain/AnalysisStrategies.js +422 -0
- package/vendor/Server/Brain/Brain.js +686 -0
- package/vendor/Server/Brain/DecompositionStrategies.js +621 -0
- package/vendor/Server/Brain/PlanPersistence.js +196 -0
- package/vendor/Server/Brain/SkillExecutor.js +251 -0
- package/vendor/Server/Brain/index.js +11 -0
- package/vendor/Server/CLI/cli.js +243 -0
- package/vendor/Server/CLI/opencode/index.js +804 -0
- package/vendor/Server/CLI/opencode.js +5 -0
- package/vendor/Server/DbUse/MessageArchive.js +61 -0
- package/vendor/Server/DbUse/StorageManager.js +107 -0
- package/vendor/Server/DbUse/adapters/BaseAdapter.js +94 -0
- package/vendor/Server/DbUse/adapters/FileAdapter.js +138 -0
- package/vendor/Server/DbUse/adapters/JsonAdapter.js +138 -0
- package/vendor/Server/DbUse/adapters/JsonlAdapter.js +114 -0
- package/vendor/Server/DbUse/adapters/SqliteAdapter.js +157 -0
- package/vendor/Server/DbUse/index.js +160 -0
- package/vendor/Server/DbUse/stores/SessionStore.js +279 -0
- package/vendor/Server/DbUse/stores/TaskExecutionStore.js +133 -0
- package/vendor/Server/DbUse/stores/TaskRegistryStore.js +262 -0
- package/vendor/Server/DbUse/stores/TaskStepStore.js +279 -0
- package/vendor/Server/FlexRunner/FlexRunner.js +1759 -0
- package/vendor/Server/FlexRunner/index.js +12 -0
- package/vendor/Server/Knowledge/KnowledgeImporter.js +523 -0
- package/vendor/Server/Knowledge/KnowledgeManager.js +341 -0
- package/vendor/Server/Knowledge/index.js +33 -0
- package/vendor/Server/LoopEngine/LoopEngine.js +1133 -0
- package/vendor/Server/LoopEngine/index.js +11 -0
- package/vendor/Server/Orchestrator/Orchestrator.js +1425 -0
- package/vendor/Server/Orchestrator/StepNode.js +312 -0
- package/vendor/Server/Orchestrator/index.js +13 -0
- package/vendor/Server/Routes/controllers/BrainController.js +241 -0
- package/vendor/Server/Routes/controllers/FlexRunnerController.js +1125 -0
- package/vendor/Server/Routes/controllers/HealthController.js +44 -0
- package/vendor/Server/Routes/controllers/KnowledgeImportController.js +355 -0
- package/vendor/Server/Routes/controllers/LoopEngineController.js +788 -0
- package/vendor/Server/Routes/controllers/OrchestratorController.js +911 -0
- package/vendor/Server/Routes/controllers/StatsController.js +57 -0
- package/vendor/Server/Routes/controllers/StreamController.js +67 -0
- package/vendor/Server/Routes/library/logger.js +179 -0
- package/vendor/Server/Routes/library/zipArchive.js +172 -0
- package/vendor/Server/Routes/router/Router.js +204 -0
- package/vendor/Server/Routes/routes/brain.js +47 -0
- package/vendor/Server/Routes/routes/flexrunner.js +72 -0
- package/vendor/Server/Routes/routes/health.js +28 -0
- package/vendor/Server/Routes/routes/index.js +57 -0
- package/vendor/Server/Routes/routes/knowledge.js +55 -0
- package/vendor/Server/Routes/routes/loopengine.js +58 -0
- package/vendor/Server/Routes/routes/orchestrator.js +61 -0
- package/vendor/Server/Routes/routes/registry.js +98 -0
- package/vendor/Server/Routes/routes/stats.js +23 -0
- package/vendor/Server/Routes/routes/stream.js +30 -0
- package/vendor/Server/Routes/server.js +202 -0
- package/vendor/Server/Routes/sse/SseHub.js +308 -0
- package/vendor/Server/Skills/acceptance-check/SKILL.md +174 -0
- package/vendor/Server/Skills/acceptance-check/references/PHASE1_ARTIFACT_COLLECTION.md +52 -0
- package/vendor/Server/Skills/acceptance-check/references/PHASE2_CRITERIA_EVALUATION.md +77 -0
- package/vendor/Server/Skills/arkts-code-check/SKILL.md +314 -0
- package/vendor/Server/Skills/arkts-code-check/references/CODE_CHECK_GUIDE.md +160 -0
- package/vendor/Server/Skills/arkts-code-check/references/FILE_TYPE_GUIDE.md +29 -0
- package/vendor/Server/Skills/arkts-code-check/references/PHASE1_INFO_COLLECTION.md +222 -0
- package/vendor/Server/Skills/arkts-code-check/references/REPORT_TEMPLATE.md +220 -0
- package/vendor/Server/Skills/arkts-library-compile-validate/SKILL.md +329 -0
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/build.ps1 +93 -0
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/code-linter.cjs +433 -0
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/migrate.cjs +851 -0
- package/vendor/Server/Skills/arkts-library-compile-validate/scripts/ohpm-switch.cjs +789 -0
- package/vendor/Server/Skills/arkts-library-demo-code/SKILL.md +291 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/API_SIGNATURE_CHECKS.md +68 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/BUILD_VALIDATION.md +184 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/CODE_STANDARDS.md +337 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/EXAMPLES.md +400 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/SYSTEM_API_LOOKUP.md +99 -0
- package/vendor/Server/Skills/arkts-library-demo-code/references/TEMPLATE.md +544 -0
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/build.ps1 +93 -0
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/code-linter.cjs +433 -0
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/migrate.cjs +851 -0
- package/vendor/Server/Skills/arkts-library-demo-code/scripts/ohpm-switch.cjs +789 -0
- package/vendor/Server/Skills/arkts-library-demo-coverage/SKILL.md +174 -0
- package/vendor/Server/Skills/arkts-library-demo-scenario/SKILL.md +321 -0
- package/vendor/Server/Skills/arkts-library-demo-scenario/references/EXAMPLES.md +100 -0
- package/vendor/Server/Skills/arkts-library-demo-scenario/references/TEMPLATE.md +185 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/SKILL.md +234 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/assets/REPORT_TEMPLATE.md +103 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/CHECK_DIMENSIONS.md +89 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/COMPLIANCE_CHECKLIST.md +62 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/KB_QUERY_GUIDE.md +108 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/MCP_TOOL_DISCOVERY.md +124 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/REPORT_TEMPLATE.md +90 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/references/SCORING_FORMULA.md +57 -0
- package/vendor/Server/Skills/arkts-library-documentation-quality-check/scripts/validate-skill.cjs +259 -0
- package/vendor/Server/Skills/arkts-library-interface-spec/SKILL.md +97 -0
- package/vendor/Server/Skills/arkts-library-memory-leak-check/SKILL.md +392 -0
- package/vendor/Server/Skills/arkts-library-source-clone/SKILL.md +113 -0
- package/vendor/Server/Skills/arkts-library-stability-check/SKILL.md +313 -0
- package/vendor/Server/Skills/arkts-library-stability-check/assets/REPORT_TEMPLATE.md +154 -0
- package/vendor/Server/Skills/arkts-library-stability-check/references/CHECKLIST.md +166 -0
- package/vendor/Server/Skills/arkts-library-stability-check/references/CODE_EXAMPLES.md +309 -0
- package/vendor/Server/Skills/arkts-library-stability-check/references/SCORING_RULES.md +90 -0
- package/vendor/Server/Skills/arkts-library-stability-check/scripts/validate-skill.cjs +282 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/SKILL.md +361 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/assets/REPORT_TEMPLATE.md +146 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/references/CHECKLIST.md +253 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/references/MCP_TOOL_USAGE.md +115 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/scripts/validate-skill.cjs +263 -0
- package/vendor/Server/Skills/arkts-library-xts-code/SKILL.md +455 -0
- package/vendor/Server/Skills/arkts-library-xts-code/assets/report-template.md +60 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/ACCESS_MODIFIER_PRECHECK.md +76 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/BUILD_VERIFICATION.md +200 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/CODE_STANDARDS.md +519 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/SUBAGENT_PROMPT_TEMPLATE.md +276 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/SYSTEM_API_LOOKUP.md +93 -0
- package/vendor/Server/Skills/arkts-library-xts-code/references/XTS_TEMPLATE.md +767 -0
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/build.ps1 +93 -0
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/code-linter.cjs +433 -0
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/migrate.cjs +851 -0
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/ohpm-switch.cjs +789 -0
- package/vendor/Server/Skills/arkts-library-xts-code/scripts/precheck-access-modifiers.cjs +221 -0
- package/vendor/Server/Skills/arkts-library-xts-code-fix/SKILL.md +229 -0
- package/vendor/Server/Skills/arkts-library-xts-coverage/SKILL.md +97 -0
- package/vendor/Server/Skills/arkts-library-xts-doc/SKILL.md +194 -0
- package/vendor/Server/Skills/arkts-library-xts-doc/references/EXAMPLES.md +576 -0
- package/vendor/Server/Skills/arkts-library-xts-doc/references/TEMPLATE.md +575 -0
- package/vendor/Server/Skills/arkts-library-xts-doc/references/TESTABILITY_GUIDE.md +182 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/SKILL.md +491 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/references/error-fixing-examples.md +217 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/build.ps1 +93 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/code-linter.cjs +433 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/migrate.cjs +851 -0
- package/vendor/Server/Skills/arkts-library-xts-execution/scripts/ohpm-switch.cjs +789 -0
- package/vendor/Server/Skills/flutter-code-check/SKILL.md +299 -0
- package/vendor/Server/Skills/flutter-code-check/assets/OUTPUT_TEMPLATE.md +312 -0
- package/vendor/Server/Skills/flutter-code-check/references/CHECKLIST.md +190 -0
- package/vendor/Server/Skills/flutter-code-check/references/PLATFORMS.md +134 -0
- package/vendor/Server/Skills/flutter-code-check/scripts/validate-skill.cjs +259 -0
- package/vendor/Server/Skills/flutter-interface/README.md +75 -0
- package/vendor/Server/Skills/flutter-interface/SKILL.md +291 -0
- package/vendor/Server/Skills/flutter-interface/references/EXAMPLES.md +336 -0
- package/vendor/Server/Skills/flutter-interface/references/GIT_CLONE_GUIDE.md +190 -0
- package/vendor/Server/Skills/flutter-interface/references/SCRIPT_REFERENCE.md +258 -0
- package/vendor/Server/Skills/flutter-interface/references/TEMPLATE.md +254 -0
- package/vendor/Server/Skills/flutter-library-consistency-check/SKILL.md +518 -0
- package/vendor/Server/Skills/flutter-library-consistency-check/references/CHECKLIST.md +382 -0
- package/vendor/Server/Skills/flutter-library-consistency-check/references/FUNCTION_COMPARISON_GUIDE.md +342 -0
- package/vendor/Server/Skills/flutter-library-consistency-check/references/PLATFORM_LIMITATION_GUIDE.md +71 -0
- package/vendor/Server/Skills/flutter-library-documentation-quality-check/SKILL.md +519 -0
- package/vendor/Server/Skills/flutter-library-documentation-quality-check/references/CHECKLIST.md +407 -0
- package/vendor/Server/Skills/flutter-library-memory-leak-check/SKILL.md +653 -0
- package/vendor/Server/Skills/flutter-library-memory-leak-check/references/CHECKLIST.md +397 -0
- package/vendor/Server/Skills/flutter-library-stability-check/SKILL.md +745 -0
- package/vendor/Server/Skills/flutter-library-stability-check/references/CHECKLIST.md +721 -0
- package/vendor/Server/Skills/flutter-library-test-coverage-check/SKILL.md +414 -0
- package/vendor/Server/Skills/flutter-library-test-coverage-check/assets/REPORT_TEMPLATE.md +150 -0
- package/vendor/Server/Skills/flutter-library-test-coverage-check/references/CHECKLIST.md +304 -0
- package/vendor/Server/Skills/flutter-library-test-coverage-check/references/SCORING_RULES.md +265 -0
- package/vendor/Server/Skills/flutter-library-test-coverage-check/references/SCRIPT_USAGE.md +286 -0
- package/vendor/Server/Skills/knowledge-import/SKILL.md +383 -0
- package/vendor/Server/Skills/knowledge-import/references/MCP_TOOL_USAGE.md +165 -0
- package/vendor/Server/Skills/knowledge-import/references/SKILL_LOCATOR_GUIDE.md +91 -0
- package/vendor/Server/Skills/knowledge-import/references/SKILL_OPTIMIZATION_GUIDE.md +127 -0
- package/vendor/Server/Skills/ohos-lib-pr-push/SKILL.md +301 -0
- package/vendor/Server/Skills/ohos-lib-pr-push/assets/PR_ISSUE_TEMPLATE.md +105 -0
- package/vendor/Server/Skills/ohos-lib-pr-push/references/GITCODE_API.md +127 -0
- package/vendor/Server/Skills/ohos-lib-pr-push/scripts/gitcode-api.cjs +208 -0
- package/vendor/Server/Skills/rn-code-check/SKILL.md +321 -0
- package/vendor/Server/Skills/rn-code-check/references/API-GUIDE.md +235 -0
- package/vendor/Server/Skills/rn-code-check/references/CHECKLIST.md +189 -0
- package/vendor/Server/Skills/rn-code-check/references/REPORT-TEMPLATE.md +247 -0
- package/vendor/Server/Skills/rn-lib-add-example/SKILL.md +198 -0
- package/vendor/Server/Skills/rn-lib-add-example/references/APP_RENAME_GUIDE.md +40 -0
- package/vendor/Server/Skills/rn-lib-add-example/references/SHELL_ADAPTATION_CHECKLIST.md +78 -0
- package/vendor/Server/Skills/rn-lib-add-example/references/TEMPLATE_REPO_GUIDE.md +70 -0
- package/vendor/Server/Skills/rn-lib-add-example/references/VERIFICATION_GUIDE.md +47 -0
- package/vendor/Server/Skills/rn-lib-add-example/scripts/create-example.cjs +252 -0
- package/vendor/Server/Skills/rn-lib-update-doc/SKILL.md +176 -0
- package/vendor/Server/Skills/rn-lib-update-doc/config.json +5 -0
- package/vendor/Server/Skills/rn-lib-update-doc/references/changelog-template.md +35 -0
- package/vendor/Server/Skills/rn-lib-update-doc/references/format-diff.md +137 -0
- package/vendor/Server/Skills/rn-lib-update-doc/references/link-registry.json +33 -0
- package/vendor/Server/Skills/rn-lib-update-doc/references/model-0.4.2-overview.md +40 -0
- package/vendor/Server/Skills/rn-lib-update-doc/references/model-0.4.2.md +429 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/detect-readme-format.cjs +105 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/find-usage-doc.cjs +90 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/link-verify.cjs +213 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/normalize-changelog.cjs +73 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/normalize-package-meta.cjs +258 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/normalize-readme-links.cjs +341 -0
- package/vendor/Server/Skills/rn-lib-update-doc/scripts/resolve-usage-docs.cjs +67 -0
- package/vendor/Server/Skills/rn-library-consistency-check/SKILL.md +299 -0
- package/vendor/Server/Skills/rn-library-consistency-check/assets/REPORT_TEMPLATE.md +293 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/ARKTS_COMPONENT_CHECK_GUIDE.md +857 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/ARKTS_TURBOMODULE_CHECK_GUIDE.md +856 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/CHECKLIST.md +157 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/CPP_COMPONENT_CHECK_GUIDE.md +801 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/CPP_TURBOMODULE_CHECK_GUIDE.md +684 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/FUNCTION_COMPARISON_GUIDE.md +233 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/NATIVE_COMPONENT_IDENTIFICATION.md +1373 -0
- package/vendor/Server/Skills/rn-library-consistency-check/references/SCORING_STANDARD.md +220 -0
- package/vendor/Server/Skills/rn-library-consistency-check/scripts/validate-skill.py +245 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/SKILL.md +263 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/assets/MODEL.md +414 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/assets/MODEL_en.md +413 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/assets/REPORT_TEMPLATE.md +311 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/CHECK_CHECKLIST.md +355 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/CROSS_VALIDATION_GUIDE.md +115 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/DOC_COLLECTION_GUIDE.md +139 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/EXAMPLES.md +586 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/references/GOTCHAS.md +57 -0
- package/vendor/Server/Skills/rn-library-documentation-quality-check/scripts/validate-skill.py +259 -0
- package/vendor/Server/Skills/rn-library-interface-analyzer/SKILL.md +301 -0
- package/vendor/Server/Skills/rn-library-interface-analyzer/assets/REPORT_TEMPLATE.md +148 -0
- package/vendor/Server/Skills/rn-library-interface-analyzer/references/DOC_ANNOTATION_GUIDE.md +118 -0
- package/vendor/Server/Skills/rn-library-interface-analyzer/references/SCRIPT_USAGE_GUIDE.md +168 -0
- package/vendor/Server/Skills/rn-library-interface-analyzer/references/URL_PARSING_RULES.md +176 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/SKILL.md +274 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/assets/case-template.md +45 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/assets/rule-template.md +25 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/references/PR_FETCH_GUIDE.md +61 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/references/RULE_TEMPLATE_GUIDE.md +165 -0
- package/vendor/Server/Skills/rn-library-issue-generalizer/scripts/fetch-pr-info.py +239 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/SKILL.md +263 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/assets/REPORT_TEMPLATE.md +96 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/references/COMPLIANCE_CHECKLIST.md +58 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/references/INSPECTION_GUIDE.md +99 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/references/PRESCREEN_GUIDE.md +64 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/references/SOURCE_PREP_GUIDE.md +75 -0
- package/vendor/Server/Skills/rn-library-known-issue-check/scripts/validate-known-issue-report.py +164 -0
- package/vendor/Server/Skills/rn-library-memory-leak-check/SKILL.md +339 -0
- package/vendor/Server/Skills/rn-library-memory-leak-check/assets/REPORT_TEMPLATE.md +83 -0
- package/vendor/Server/Skills/rn-library-memory-leak-check/references/CHECKLIST.md +859 -0
- package/vendor/Server/Skills/rn-library-memory-leak-check/references/HARMONY_CODE_PATTERNS.md +122 -0
- package/vendor/Server/Skills/rn-library-memory-leak-check/scripts/scan_harmony_code.py +279 -0
- package/vendor/Server/Skills/rn-library-stability-check/SKILL.md +273 -0
- package/vendor/Server/Skills/rn-library-stability-check/assets/REPORT_TEMPLATE.md +129 -0
- package/vendor/Server/Skills/rn-library-stability-check/references/CHECKLIST.md +581 -0
- package/vendor/Server/Skills/rn-library-stability-check/references/SCORING_RULES.md +138 -0
- package/vendor/Server/Skills/rn-library-stability-check/scripts/scan-harmony-code.py +168 -0
- package/vendor/Server/Skills/rn-library-test-coverage-check/SKILL.md +506 -0
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/CHECKLIST.md +280 -0
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/DEMO_LOCATION.md +221 -0
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/REPORT_TEMPLATE.md +209 -0
- package/vendor/Server/Skills/rn-library-test-coverage-check/references/SCRIPT_USAGE.md +325 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/SKILL.md +279 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/assets/TEST_FILE_TEMPLATES.md +404 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/BUILD_TROUBLESHOOTING.md +185 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/BUILD_WORKFLOW.md +265 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/COMMON_CONFIG.md +189 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/CONFIG_GUIDE.md +203 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/COVERAGE_ANALYZER.md +147 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/DESIGN_DOC_GUIDE.md +148 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/GENERATION_FLOW.md +165 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/GENERATION_STRATEGY.md +195 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/HARMONY_SCANNER.md +249 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/JEST_FRAMEWORK.md +235 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/PLATFORM_COMPAT.md +161 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/RN_TEST_PATTERNS.md +413 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/SOURCE_PARSER.md +235 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/TEST_CONVENTIONS.md +245 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/TROUBLESHOOTING.md +282 -0
- package/vendor/Server/Skills/rn-ohos-xts-generator/references/USAGE_GUIDE.md +251 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/SKILL.md +469 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/assets/CPTF_TEST_TEMPLATE.md +310 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/assets/DEMO_PAGE_TEMPLATE.md +303 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/CPTF_TEST_GENERATION_GUIDE.md +421 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/DEMO_GENERATION_GUIDE.md +358 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/QUALITY_CHECKLIST.md +114 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/references/SPEC_PARSING_GUIDE.md +274 -0
- package/vendor/Server/Skills/rnoh-cptf-api-test/scripts/validate-rnoh-cptf-api-test.sh +185 -0
- package/vendor/Server/Skills/rnoh-cptf-demo-test/SKILL.md +191 -0
- package/vendor/Server/Skills/rnoh-cptf-demo-test/assets/TEST_TEMPLATE.md +216 -0
- package/vendor/Server/Skills/rnoh-cptf-demo-test/references/CPTF_SETUP.md +107 -0
- package/vendor/Server/Skills/rnoh-cptf-demo-test/references/DEMO_ANALYSIS.md +120 -0
- package/vendor/Server/Skills/rnoh-cptf-demo-test/scripts/validate-rnoh-cptf-test.sh +108 -0
- package/vendor/Server/Skills/rnoh-cptf-test-run/SKILL.md +237 -0
- package/vendor/Server/Skills/rnoh-cptf-test-run/references/DEBUG_PLAYBOOK.md +261 -0
- package/vendor/Server/Skills/rnoh-cptf-test-run/scripts/validate-run-env.sh +112 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/SKILL.md +498 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/adapt-checklist.md +270 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/api-migration-checklist.md +164 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/common-compile-errors.md +556 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/deveco-cli-tools.md +459 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/edge-cases.md +65 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/har-tgz-build.md +512 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/references/version-compat-matrix.md +132 -0
- package/vendor/Server/Skills/rnoh-lib-code-adapt/scripts/auto-integrate.sh +424 -0
- package/vendor/Server/Skills/rnoh-lib-demo-coverage/SKILL.md +137 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/SKILL.md +306 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/assets/DEMO_PAGE_TEMPLATE.md +485 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/assets/INDEX_TEMPLATE.md +172 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/references/DEMO_CODE_RULES.md +422 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/references/QUALITY_CHECKLIST.md +95 -0
- package/vendor/Server/Skills/rnoh-lib-demo-create/references/SOURCE_EXPLORATION.md +169 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/SKILL.md +554 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/assets/DEMO_DOC_TEMPLATE.md +106 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/COVERAGE_INCREMENTAL.md +216 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/DEMO_DESIGN_RULES.md +413 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/OUTPUT_FORMAT.md +269 -0
- package/vendor/Server/Skills/rnoh-lib-demo-doc/references/QUALITY_CHECKLIST.md +98 -0
- package/vendor/Server/Skills/rnoh-lib-func-test/SKILL.md +337 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/SKILL.md +722 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/assets/PORT_REPORT_TEMPLATE.md +219 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/references/DEMO_PORTING_GUIDE.md +345 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/references/PORT_VERIFICATION.md +269 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/references/RNT_PROJECT_STRUCTURE.md +173 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/analyze-demo-deps.cjs +267 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/detect-rnoh-version.cjs +174 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/find-rnt-demo.sh +111 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/port-demo.sh +186 -0
- package/vendor/Server/Skills/rnoh-lib-rnt-search/scripts/read-lib-meta.cjs +150 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/SKILL.md +296 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/references/jest-troubleshooting.md +371 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/references/port-test-demo-guide.md +212 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/references/runtime-troubleshooting.md +345 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/references/unit-test-template.md +223 -0
- package/vendor/Server/Skills/rnoh-lib-test-align/scripts/port-test-demo.sh +1053 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/SKILL.md +255 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/references/OHOS_ADAPTATION.md +77 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/references/OHOS_API_LOOKUP.md +224 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/references/script-reference.md +174 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/scripts/detect-upstream-version.js +967 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/scripts/generate-diff.js +1798 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/scripts/package.json +5 -0
- package/vendor/Server/Skills/rnoh-lib-version-diff/templates/report-template.md +137 -0
- package/vendor/Server/Skills/rnoh-lib-xts-coverage/SKILL.md +145 -0
- package/vendor/Server/Skills/skill-generator/SKILL.md +365 -0
- package/vendor/Server/Skills/skill-generator/assets/SKILL_TEMPLATE.md +183 -0
- package/vendor/Server/Skills/skill-generator/references/COMPLIANCE_CHECKLIST.md +82 -0
- package/vendor/Server/Skills/skill-generator/references/KB_QUERY_GUIDE.md +110 -0
- package/vendor/Server/Skills/skill-generator/references/MCP_TOOL_DISCOVERY.md +122 -0
- package/vendor/Server/Skills/skill-generator/references/SKILL_SPEC.md +121 -0
- package/vendor/Server/Skills/skill-generator/scripts/validate-skill.cjs +259 -0
- package/vendor/Server/Skills/task-analysis/SKILL.md +234 -0
- package/vendor/Server/Skills/task-analysis/assets/OUTPUT_EXAMPLES.md +160 -0
- package/vendor/Server/Skills/task-analysis/references/ACCEPTANCE_CRITERIA_GUIDE.md +190 -0
- package/vendor/Server/Skills/task-analysis/references/ANALYSIS_SCHEMA.md +224 -0
- package/vendor/Server/Skills/task-analysis/references/INTEGRATION_CONTEXT.md +162 -0
- package/vendor/Server/Skills/task-analysis/references/LESSONS_LEARNED.md +55 -0
- package/vendor/Server/Skills/task-analysis/references/REPLAN_CONTEXT_GUIDE.md +126 -0
- package/vendor/Server/Skills/task-analysis/scripts/validate-analysis-output.sh +256 -0
- package/vendor/Server/Skills/task-decomposition/SKILL.md +529 -0
- package/vendor/Server/Skills/task-decomposition/assets/OUTPUT_EXAMPLES.md +451 -0
- package/vendor/Server/Skills/task-decomposition/references/ACCEPTANCE_CRITERIA_GUIDE.md +179 -0
- package/vendor/Server/Skills/task-decomposition/references/DEPENDENCY_GRAPH_GUIDE.md +152 -0
- package/vendor/Server/Skills/task-decomposition/references/INTEGRATION_CONTEXT.md +175 -0
- package/vendor/Server/Skills/task-decomposition/references/REPLAN_CONTEXT_GUIDE.md +195 -0
- package/vendor/Server/Skills/task-decomposition/references/TASK_DECOMPOSITION_TEMPLATES.md +226 -0
- package/vendor/Server/Skills/task-decomposition/scripts/list-available-skills.cjs +263 -0
- package/vendor/Server/Skills/task-decomposition/scripts/skill-blacklist.json +29 -0
- package/vendor/Server/Skills/task-decomposition/scripts/validate-decomposition-output.cjs +376 -0
- package/vendor/Server/Skills/task-decomposition/scripts/validate-param-consistency.cjs +259 -0
- package/vendor/Server/Skills/task-decomposition/scripts/validate-specified-skills.cjs +216 -0
- package/vendor/Server/Skills/task-decomposition/scripts/validate-step-graph.cjs +425 -0
- package/vendor/Server/Skills/tpc-cpp-check/SKILL.md +427 -0
- package/vendor/Server/Skills/tpc-cpp-check/references/CHECKLIST.md +214 -0
- package/vendor/Server/Skills/tpc-cpp-check/references/HPKBUILD_GUIDE.md +235 -0
- package/vendor/Server/Skills/tpc-cpp-check/references/REPORT_TEMPLATE.md +250 -0
- package/vendor/Server/TestCheck/TestCheck.js +775 -0
- package/vendor/Server/TestCheck/index.js +11 -0
- package/vendor/Server/library/McpToolGuide.js +280 -0
- package/vendor/Server/library/StatsService.js +127 -0
- package/vendor/Server/library/cstTime.js +16 -0
- package/vendor/Server/package.json +17 -0
- package/vendor/VERSION +3 -0
- package/workflows/pr-check.mjs +106 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
# Jest 单元测试排错指南
|
|
2
|
+
|
|
3
|
+
RN 0.84 + React 19 环境下,为鸿蒙化组件编写 jest 单元测试时遇到的常见问题及解决方案。
|
|
4
|
+
|
|
5
|
+
本文档基于 rntpc_picker 库的实战调试经验整理。
|
|
6
|
+
|
|
7
|
+
## 问题 1:React 多副本导致 hooks 失效
|
|
8
|
+
|
|
9
|
+
### 症状 1
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
TypeError: Cannot read properties of null (reading 'useRef')
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
组件中调用 `React.useRef()`、`React.useMemo()` 等 hooks 时崩溃。
|
|
16
|
+
|
|
17
|
+
### 根因 1
|
|
18
|
+
|
|
19
|
+
鸿蒙化工程的典型目录结构:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
rntpc_picker/ ← 库根目录
|
|
23
|
+
├── node_modules/react/ ← React 副本 A
|
|
24
|
+
├── js/
|
|
25
|
+
│ └── PickerHarmony.harmony.js ← 从此处解析 react → 副本 A
|
|
26
|
+
└── example/ ← 测试工程目录
|
|
27
|
+
├── node_modules/react/ ← React 副本 B
|
|
28
|
+
└── node_modules/react-test-renderer/ ← 使用副本 B
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`PickerHarmony.harmony.js` 位于 `js/` 目录,其 `import * as React from 'react'` 解析到 `rntpc_picker/node_modules/react`(副本 A)。
|
|
32
|
+
而 `react-test-renderer`(安装在 `example/node_modules/`)使用 `example/node_modules/react`(副本 B)。
|
|
33
|
+
|
|
34
|
+
两个不同的 React 实例导致 hooks dispatcher 不匹配——renderer 设置的 dispatcher 在副本 B 上,但组件调用的 hooks 在副本 A 上。
|
|
35
|
+
|
|
36
|
+
### 诊断方法
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# 检查 React 解析路径
|
|
40
|
+
node -e "
|
|
41
|
+
console.log('from example:', require.resolve('react', {paths: ['./example']}));
|
|
42
|
+
console.log('from js dir:', require.resolve('react', {paths: ['./js']}));
|
|
43
|
+
"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
如果两个路径不同,即为多副本问题。
|
|
47
|
+
|
|
48
|
+
### 解决方案 1
|
|
49
|
+
|
|
50
|
+
在 `jest.config.js` 的 `moduleNameMapper` 中强制统一 React:
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
moduleNameMapper: {
|
|
54
|
+
'^react-native$': '<rootDir>/__mocks__/react-native.js',
|
|
55
|
+
// 强制统一 React 副本
|
|
56
|
+
'^react$': '<rootDir>/node_modules/react/index.js',
|
|
57
|
+
'^react/jsx-runtime$': '<rootDir>/node_modules/react/jsx-runtime.js',
|
|
58
|
+
},
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**关键**:`<rootDir>` 是 jest 配置文件所在目录(通常是 `example/`),映射到 `example/node_modules/react`。
|
|
62
|
+
|
|
63
|
+
## 问题 2:React 19 react-test-renderer 异步渲染
|
|
64
|
+
|
|
65
|
+
### 症状 2
|
|
66
|
+
|
|
67
|
+
Mock 组件的 `forwardRef` 回调未执行,`globalThis.__CAPTURED_PROPS__` 为 null。
|
|
68
|
+
|
|
69
|
+
### 根因 2
|
|
70
|
+
|
|
71
|
+
React 19 中 `react-test-renderer` 已弃用,默认异步渲染。`TestRenderer.create()` 返回时,组件的 render 函数(含 forwardRef)可能尚未执行。
|
|
72
|
+
|
|
73
|
+
### 解决方案 2
|
|
74
|
+
|
|
75
|
+
1. 在 `jest.setup.js` 中启用 act 环境:
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
2. 用 `act()` 包裹 `TestRenderer.create()`:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import TestRenderer, {act} from 'react-test-renderer';
|
|
85
|
+
|
|
86
|
+
function renderComponent(element: React.ReactElement) {
|
|
87
|
+
let renderer;
|
|
88
|
+
act(() => {
|
|
89
|
+
renderer = TestRenderer.create(element);
|
|
90
|
+
});
|
|
91
|
+
return renderer;
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
3. 触发事件回调时也用 `act()` 包裹:
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
act(() => {
|
|
99
|
+
capturedOnChange()(mockEvent);
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## 问题 3:react-native 原生模块初始化崩溃
|
|
104
|
+
|
|
105
|
+
### 症状 3
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
Error: __fbBatchedBridgeConfig is not available
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
或类似的 native bridge 初始化错误。
|
|
112
|
+
|
|
113
|
+
### 根因 3
|
|
114
|
+
|
|
115
|
+
`react-native` 模块在 Node 环境中加载时尝试初始化原生桥接层,但测试环境中没有原生运行时。
|
|
116
|
+
|
|
117
|
+
### 解决方案 3
|
|
118
|
+
|
|
119
|
+
创建 `__mocks__/react-native.js` mock 文件,提供最小化的组件和工具函数:
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
const React = require('react');
|
|
123
|
+
|
|
124
|
+
const View = (props) => React.createElement('View', props, props.children);
|
|
125
|
+
const Text = (props) => React.createElement('Text', props, props.children);
|
|
126
|
+
const StyleSheet = { create: (styles) => styles, flatten: (style) => style };
|
|
127
|
+
const Platform = { OS: 'harmony', select: (obj) => obj.harmony || obj.default };
|
|
128
|
+
const processColor = (color) => color; // 直接透传,测试中不需要真实颜色转换
|
|
129
|
+
|
|
130
|
+
module.exports = {
|
|
131
|
+
View, Text, StyleSheet, Platform, processColor,
|
|
132
|
+
// 按需添加其他导出
|
|
133
|
+
};
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
在 `jest.config.js` 中映射:
|
|
137
|
+
|
|
138
|
+
```javascript
|
|
139
|
+
moduleNameMapper: {
|
|
140
|
+
'^react-native$': '<rootDir>/__mocks__/react-native.js',
|
|
141
|
+
},
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## 问题 4:Fabric 原生组件导入链崩溃
|
|
145
|
+
|
|
146
|
+
### 症状 4
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
Error: Cannot find module 'react-native/Libraries/Utilities/codegenNativeComponent'
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 根因 4
|
|
153
|
+
|
|
154
|
+
`*NativeComponent.js` 文件深度导入 react-native 内部模块(codegenNativeComponent 等),mock 的 react-native 不包含这些内部路径。
|
|
155
|
+
|
|
156
|
+
### 解决方案 4
|
|
157
|
+
|
|
158
|
+
为每个 Fabric 原生组件创建独立 mock:
|
|
159
|
+
|
|
160
|
+
`__mocks__/RNCPickerNativeComponent.js`:
|
|
161
|
+
|
|
162
|
+
```javascript
|
|
163
|
+
const React = require('react');
|
|
164
|
+
|
|
165
|
+
const Commands = {
|
|
166
|
+
setNativeSelectedIndex: jest.fn(),
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// 使用 forwardRef 捕获 props,通过 globalThis 传递给测试
|
|
170
|
+
const MockNativePicker = React.forwardRef((props, ref) => {
|
|
171
|
+
globalThis.__PICKER_CAPTURED_PROPS__ = props;
|
|
172
|
+
globalThis.__PICKER_CAPTURED_ONCHANGE__ = props.onChange;
|
|
173
|
+
React.useImperativeHandle(ref, () => ({
|
|
174
|
+
setNativeProps: jest.fn(),
|
|
175
|
+
}));
|
|
176
|
+
return React.createElement('RNCPicker', props);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
module.exports = {
|
|
180
|
+
__esModule: true,
|
|
181
|
+
default: MockNativePicker,
|
|
182
|
+
Commands,
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
在测试文件中声明 mock:
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
jest.mock('../../../js/RNCPickerNativeComponent', () => {
|
|
190
|
+
return require('../../__mocks__/RNCPickerNativeComponent');
|
|
191
|
+
});
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**注意**:`jest.mock()` 会被自动提升到文件顶部(hoisting),因此必须在 `import` 组件之前声明。使用 `require()` 方式引用 mock 文件可以避免变量提升问题。
|
|
195
|
+
|
|
196
|
+
## 问题 5:globalThis 变量传递 vs 模块实例不一致
|
|
197
|
+
|
|
198
|
+
### 症状 5
|
|
199
|
+
|
|
200
|
+
Mock 文件中设置的变量,在测试文件中读取时为 null 或 undefined。
|
|
201
|
+
|
|
202
|
+
### 根因 5
|
|
203
|
+
|
|
204
|
+
jest 模块缓存可能导致 mock 文件被 require 多次,产生不同的模块实例,变量不共享。
|
|
205
|
+
|
|
206
|
+
### 解决方案 5
|
|
207
|
+
|
|
208
|
+
使用 `globalThis` 而非模块级变量传递数据:
|
|
209
|
+
|
|
210
|
+
```javascript
|
|
211
|
+
// mock 文件中
|
|
212
|
+
globalThis.__PICKER_CAPTURED_PROPS__ = props;
|
|
213
|
+
|
|
214
|
+
// 测试文件中
|
|
215
|
+
const lastProps = () => globalThis.__PICKER_CAPTURED_PROPS__;
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
在 `beforeEach` 中重置:
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
beforeEach(() => {
|
|
222
|
+
globalThis.__PICKER_CAPTURED_PROPS__ = null;
|
|
223
|
+
globalThis.__PICKER_CAPTURED_ONCHANGE__ = null;
|
|
224
|
+
});
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## 问题 6:@react-native/typescript-config 阻塞 ts-jest
|
|
228
|
+
|
|
229
|
+
### 症状 6
|
|
230
|
+
|
|
231
|
+
```text
|
|
232
|
+
error TS2614: Module '"@react-native/typescript-config"' can only be default-imported using the 'esModuleInterop' flag
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### 根因 6
|
|
236
|
+
|
|
237
|
+
RN 0.84 的 `tsconfig.json` 继承 `@react-native/typescript-config`,其 `exports` 字段导致 ts-jest 解析失败。
|
|
238
|
+
|
|
239
|
+
### 解决方案 6
|
|
240
|
+
|
|
241
|
+
创建独立的 `tsconfig.jest.json`,不继承 RN 的配置:
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"compilerOptions": {
|
|
246
|
+
"jsx": "react",
|
|
247
|
+
"esModuleInterop": true,
|
|
248
|
+
"skipLibCheck": true,
|
|
249
|
+
"module": "commonjs",
|
|
250
|
+
"target": "es2017",
|
|
251
|
+
"moduleResolution": "node",
|
|
252
|
+
"types": ["react", "react-native", "jest", "node"]
|
|
253
|
+
},
|
|
254
|
+
"include": ["src/**/*"],
|
|
255
|
+
"exclude": ["harmony", "node_modules"]
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
在 `jest.config.js` 中指定:
|
|
260
|
+
|
|
261
|
+
```javascript
|
|
262
|
+
transform: {
|
|
263
|
+
'^.+\\.(ts|tsx)$': ['ts-jest', {
|
|
264
|
+
tsconfig: 'tsconfig.jest.json',
|
|
265
|
+
isolatedModules: true,
|
|
266
|
+
}],
|
|
267
|
+
},
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
## 问题 7:jest 扫描 harmony/oh_modules 目录
|
|
271
|
+
|
|
272
|
+
### 症状 7
|
|
273
|
+
|
|
274
|
+
jest 启动时扫描 `harmony/oh_modules/` 下的大量文件,导致超时或内存溢出。
|
|
275
|
+
|
|
276
|
+
### 解决方案 7
|
|
277
|
+
|
|
278
|
+
在 `jest.config.js` 中用 `testMatch` 精确限定测试文件:
|
|
279
|
+
|
|
280
|
+
```javascript
|
|
281
|
+
testMatch: ['<rootDir>/src/__tests__/*.test.tsx'],
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
同时确保 `tsconfig.jest.json` 的 `exclude` 包含 `harmony` 目录。
|
|
285
|
+
|
|
286
|
+
## 问题 8:NativeEventEmitter.addListener 返回值缺少 remove 方法
|
|
287
|
+
|
|
288
|
+
### 症状 8
|
|
289
|
+
|
|
290
|
+
```text
|
|
291
|
+
TypeError: this._nativeEventSubscription.remove is not a function
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
在 TurboModule 库(如 NetInfo)的测试中,`State.tearDown()` 调用 `this._nativeEventSubscription.remove()` 时崩溃。
|
|
295
|
+
|
|
296
|
+
### 根因 8
|
|
297
|
+
|
|
298
|
+
`__mocks__/react-native.js` 中的 `NativeEventEmitter` 继承 Node.js 的 `EventEmitter`,其 `addListener` 方法返回 EventEmitter 实例(boolean 值或 listener 引用),而非 RN 的 `NativeEventSubscription` 对象(`{ remove: () => void }`)。
|
|
299
|
+
|
|
300
|
+
### 解决方案 8
|
|
301
|
+
|
|
302
|
+
在 mock 中覆写 `addListener`,使其返回包含 `remove` 方法的对象:
|
|
303
|
+
|
|
304
|
+
```javascript
|
|
305
|
+
// __mocks__/react-native.js
|
|
306
|
+
const { EventEmitter } = require('events');
|
|
307
|
+
|
|
308
|
+
class MockNativeEventEmitter extends EventEmitter {
|
|
309
|
+
addListener(eventName, handler) {
|
|
310
|
+
const listener = super.addListener(eventName, handler);
|
|
311
|
+
// 返回 NativeEventSubscription 兼容对象
|
|
312
|
+
return {
|
|
313
|
+
remove: () => super.removeListener(eventName, handler),
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
module.exports = {
|
|
319
|
+
// ... 其他导出
|
|
320
|
+
NativeEventEmitter: MockNativeEventEmitter,
|
|
321
|
+
NativeModules: {
|
|
322
|
+
// 按需提供 mock 的原生模块
|
|
323
|
+
},
|
|
324
|
+
};
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
**关键**:所有 TurboModule 库(非 Fabric 组件库)的测试都需要此 mock。TurboModule 库不需要 mock `codegenNativeComponent`,但必须正确 mock `NativeEventEmitter`。
|
|
328
|
+
|
|
329
|
+
## 完整配置模板
|
|
330
|
+
|
|
331
|
+
### jest.config.js
|
|
332
|
+
|
|
333
|
+
```javascript
|
|
334
|
+
module.exports = {
|
|
335
|
+
preset: 'ts-jest',
|
|
336
|
+
testEnvironment: 'node',
|
|
337
|
+
testMatch: ['<rootDir>/src/__tests__/*.test.tsx'],
|
|
338
|
+
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
|
|
339
|
+
transform: {
|
|
340
|
+
'^.+\\.(ts|tsx)$': ['ts-jest', {
|
|
341
|
+
tsconfig: 'tsconfig.jest.json',
|
|
342
|
+
isolatedModules: true,
|
|
343
|
+
}],
|
|
344
|
+
'^.+\\.(js|jsx)$': 'babel-jest',
|
|
345
|
+
},
|
|
346
|
+
transformIgnorePatterns: [
|
|
347
|
+
'node_modules/(?!(react-native|@react-native|@react-native-picker|@react-native-oh)/)',
|
|
348
|
+
],
|
|
349
|
+
setupFiles: ['<rootDir>/jest.setup.js'],
|
|
350
|
+
moduleNameMapper: {
|
|
351
|
+
'^react-native$': '<rootDir>/__mocks__/react-native.js',
|
|
352
|
+
'^react$': '<rootDir>/node_modules/react/index.js',
|
|
353
|
+
'^react/jsx-runtime$': '<rootDir>/node_modules/react/jsx-runtime.js',
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
### jest.setup.js
|
|
359
|
+
|
|
360
|
+
```javascript
|
|
361
|
+
global.__DEV__ = true;
|
|
362
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
### `__mocks__/react-native.js`
|
|
366
|
+
|
|
367
|
+
提供 `View`、`Text`、`StyleSheet`、`Platform`(OS='harmony')、`processColor`(透传)等最小导出。
|
|
368
|
+
|
|
369
|
+
### `__mocks__/FabricComponent.js`
|
|
370
|
+
|
|
371
|
+
用 `React.forwardRef` 捕获 props,通过 `globalThis` 传递。导出 `{ __esModule: true, default: MockComponent, Commands: {...} }`。
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
# port-test-demo.sh 使用指南
|
|
2
|
+
|
|
3
|
+
## 脚本概述
|
|
4
|
+
|
|
5
|
+
从 RN 三方库 git 仓库中提取测试 demo / 用例代码,移植到 RNOH 模板工程的 `src/index.tsx` 中。
|
|
6
|
+
|
|
7
|
+
脚本位于本 skill 的 `scripts/` 目录下,可直接运行。
|
|
8
|
+
|
|
9
|
+
## 参数说明
|
|
10
|
+
|
|
11
|
+
### 必选参数
|
|
12
|
+
|
|
13
|
+
| 参数 | 说明 |
|
|
14
|
+
|------|------|
|
|
15
|
+
| `--git-url <url>` | git 仓库 URL |
|
|
16
|
+
| `--branch <branch>` | git 分支名或版本标签 |
|
|
17
|
+
|
|
18
|
+
### 可选参数
|
|
19
|
+
|
|
20
|
+
| 参数 | 说明 |
|
|
21
|
+
|------|------|
|
|
22
|
+
| `--template-dir <path>` | 模板工程目录,不指定则自动检测 |
|
|
23
|
+
| `--demo-dirs <dir1,dir2,...>` | 手动指定 demo 目录名(逗号分隔,跳过自动检测) |
|
|
24
|
+
| `--legacy-peer-deps` | npm install 时使用 `--legacy-peer-deps` |
|
|
25
|
+
| `--force` | npm install 时使用 `--force` |
|
|
26
|
+
| `--skip-npm-install` | 跳过依赖安装步骤 |
|
|
27
|
+
| `--skip-index-merge` | 跳过 index.tsx 合并步骤(只拷贝文件不修改入口) |
|
|
28
|
+
| `--verbose` | 显示详细调试信息 |
|
|
29
|
+
| `--dry-run` | 只检测不实际拷贝 |
|
|
30
|
+
|
|
31
|
+
## 工作流程
|
|
32
|
+
|
|
33
|
+
### 1. git clone 仓库
|
|
34
|
+
|
|
35
|
+
浅克隆(`--depth=1`)到当前目录下的 `TestGet/` 目录中。
|
|
36
|
+
|
|
37
|
+
### 2. 自动检测 demo 目录
|
|
38
|
+
|
|
39
|
+
按以下顺序检测:
|
|
40
|
+
|
|
41
|
+
- 已知目录名:`example`、`demo`、`Example`、`Demo`、`test`、`tests`、`Test`、`Tests`、`spec`、`specs`、`__tests__`、`e2e`、`cypress`
|
|
42
|
+
- monorepo 结构:`packages/*/example`、`packages/*/demo`
|
|
43
|
+
|
|
44
|
+
### 3. 依赖安装
|
|
45
|
+
|
|
46
|
+
解析 demo 的 package.json:
|
|
47
|
+
- 将三方库依赖安装到模板工程
|
|
48
|
+
- `workspace:` 协议依赖自动转换为 `file:` 本地依赖
|
|
49
|
+
- 支持通过 `--legacy-peer-deps` 或 `--force` 处理 peer 冲突
|
|
50
|
+
|
|
51
|
+
### 4. 支撑文件拷贝
|
|
52
|
+
|
|
53
|
+
将 demo 的 assets、animations 等资源文件拷贝到模板工程 `src/` 顶层,保持原有相对路径。
|
|
54
|
+
|
|
55
|
+
使用 `rsync` 进行文件拷贝,自动跳过 `node_modules`、`.git` 等目录。
|
|
56
|
+
|
|
57
|
+
### 5. 入口代码合并
|
|
58
|
+
|
|
59
|
+
将 demo 的入口文件(`App.tsx` / `index.tsx` 等)内容直接写入 `src/index.tsx`,过滤 `AppRegistry` 注册代码。
|
|
60
|
+
|
|
61
|
+
## 自动检测模板工程目录
|
|
62
|
+
|
|
63
|
+
脚本按以下顺序查找模板工程:
|
|
64
|
+
|
|
65
|
+
1. `--template-dir` 指定的路径
|
|
66
|
+
2. 当前工作目录(如果包含 `package.json` 和 `src/index.tsx`)
|
|
67
|
+
3. `RN3rdTemplate/0.77/` 或 `RN3rdTemplate/0.82/`(相对于脚本位置)
|
|
68
|
+
4. 向上查找(最多 5 层)
|
|
69
|
+
|
|
70
|
+
## 使用示例
|
|
71
|
+
|
|
72
|
+
### 基本用法
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
./scripts/port-test-demo.sh \
|
|
76
|
+
--git-url https://github.com/lottie-react-native/lottie-react-native \
|
|
77
|
+
--branch v7.4.0
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 指定模板目录
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
./scripts/port-test-demo.sh \
|
|
84
|
+
--git-url https://github.com/lottie-react-native/lottie-react-native \
|
|
85
|
+
--branch v7.4.0 \
|
|
86
|
+
--template-dir /Users/lalhan/Desktop/RNOH/RN3rdTemplate/0.84
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 手动指定 demo 目录
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
./scripts/port-test-demo.sh \
|
|
93
|
+
--git-url https://github.com/xxx/mono-repo \
|
|
94
|
+
--branch main \
|
|
95
|
+
--demo-dirs packages/core/example
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### dry-run 模式
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
./scripts/port-test-demo.sh \
|
|
102
|
+
--git-url https://github.com/lottie-react-native/lottie-react-native \
|
|
103
|
+
--branch v7.4.0 \
|
|
104
|
+
--dry-run
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 跳过 npm install
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
./scripts/port-test-demo.sh \
|
|
111
|
+
--git-url https://github.com/lottie-react-native/lottie-react-native \
|
|
112
|
+
--branch v7.4.0 \
|
|
113
|
+
--skip-npm-install
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 文件拷贝策略
|
|
117
|
+
|
|
118
|
+
### 拷贝的文件
|
|
119
|
+
|
|
120
|
+
- demo 目录下的所有 `.ts`、`.tsx`、`.js`、`.jsx` 文件
|
|
121
|
+
- assets 资源文件(图片、动画 JSON、字体等)
|
|
122
|
+
- 配置文件(如需要)
|
|
123
|
+
|
|
124
|
+
### 排除的文件
|
|
125
|
+
|
|
126
|
+
- `node_modules/`
|
|
127
|
+
- `.git/`
|
|
128
|
+
- `.DS_Store`
|
|
129
|
+
- `*.log`
|
|
130
|
+
|
|
131
|
+
### 目录结构映射
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
上游仓库:
|
|
135
|
+
example/
|
|
136
|
+
├── App.tsx ← 入口文件
|
|
137
|
+
├── src/
|
|
138
|
+
│ ├── components/
|
|
139
|
+
│ │ └── Example.tsx
|
|
140
|
+
│ └── assets/
|
|
141
|
+
│ └── animation.json
|
|
142
|
+
└── package.json
|
|
143
|
+
|
|
144
|
+
模板工程 (移植后):
|
|
145
|
+
src/
|
|
146
|
+
├── index.tsx ← App.tsx 内容写入此处
|
|
147
|
+
├── components/
|
|
148
|
+
│ └── Example.tsx ← 保持原目录结构
|
|
149
|
+
└── assets/
|
|
150
|
+
└── animation.json ← 资源文件保持相对路径
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## 入口文件合并策略
|
|
154
|
+
|
|
155
|
+
### 合并规则
|
|
156
|
+
|
|
157
|
+
1. 读取 demo 入口文件内容
|
|
158
|
+
2. 过滤掉 `AppRegistry.registerComponent` 调用
|
|
159
|
+
3. 过滤掉 `import` 中的 `react-native` 的 `AppRegistry`
|
|
160
|
+
4. 将剩余内容直接写入 `src/index.tsx`
|
|
161
|
+
5. 保留模板工程原有的 `AppRegistry.registerComponent` 调用
|
|
162
|
+
|
|
163
|
+
### 多入口文件处理
|
|
164
|
+
|
|
165
|
+
如果 demo 有多个入口文件(如 `App.tsx` + `examples/` 目录):
|
|
166
|
+
- 主入口文件内容写入 `src/index.tsx`
|
|
167
|
+
- 其他文件保持原目录结构拷贝到 `src/` 下
|
|
168
|
+
|
|
169
|
+
## 依赖安装策略
|
|
170
|
+
|
|
171
|
+
### workspace 协议转换
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
// 上游 demo package.json
|
|
175
|
+
"dependencies": {
|
|
176
|
+
"lottie-react-native": "workspace:*"
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// 转换后 (安装到模板工程)
|
|
180
|
+
"dependencies": {
|
|
181
|
+
"lottie-react-native": "file:../update_harmony_lib/target-repo"
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### file 协议依赖
|
|
186
|
+
|
|
187
|
+
如果 demo 依赖了本地路径的其他包:
|
|
188
|
+
- 自动检测 `file:` 协议依赖
|
|
189
|
+
- 尝试在克隆的仓库中找到对应路径
|
|
190
|
+
- 转换为相对于模板工程的路径
|
|
191
|
+
|
|
192
|
+
## 常见问题
|
|
193
|
+
|
|
194
|
+
### Q: 脚本提示"未找到 demo 目录"
|
|
195
|
+
|
|
196
|
+
**A**: 使用 `--demo-dirs` 手动指定目录名。先用 `--dry-run` 查看仓库结构。
|
|
197
|
+
|
|
198
|
+
### Q: 依赖安装失败
|
|
199
|
+
|
|
200
|
+
**A**: 尝试 `--legacy-peer-deps` 或 `--force`。如果仍失败,使用 `--skip-npm-install` 跳过,手动安装。
|
|
201
|
+
|
|
202
|
+
### Q: 资源文件路径不对
|
|
203
|
+
|
|
204
|
+
**A**: 检查 `rsync` 拷贝的目录结构是否与测试代码中的引用路径一致。可能需要手动调整路径或创建符号链接。
|
|
205
|
+
|
|
206
|
+
### Q: index.tsx 合并后编译错误
|
|
207
|
+
|
|
208
|
+
**A**: 使用 `--skip-index-merge` 跳过自动合并,手动将 demo 入口文件内容复制到 `src/index.tsx` 中。
|
|
209
|
+
|
|
210
|
+
### Q: 子目录中的 index.tsx 聚合入口被跳过
|
|
211
|
+
|
|
212
|
+
**A**: `port-test-demo.sh` 在拷贝支撑文件时,会将所有名为 `index.tsx` 的文件加入 `SKIP_FILES` 列表(因为主入口文件也叫 `index.tsx`)。这导致上游 `testCases/index.tsx` 等子目录中的聚合入口文件被跳过未拷贝。移植完成后需手动检查是否存在被跳过的聚合入口,并手动创建或拷贝。
|