@ohos-cpf/3rdloop 0.0.8 → 0.0.9
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 +25 -0
- package/lib/cli.js +22 -5
- package/lib/doctor.js +111 -10
- package/lib/mcp.js +498 -0
- package/package.json +6 -2
- package/vendor/Archive/data/.index/meta.json +7 -0
- package/vendor/Archive/data/.index/search.db +0 -0
- package/vendor/Archive/data/docs/experiences/arkts-check-tool-pitfalls-baseline-comparison.md +13 -0
- package/vendor/Archive/data/docs/experiences/arkts-deep-path-import-recognition.md +31 -0
- package/vendor/Archive/data/docs/experiences/arkts-demo-coverage-entry-file-case-mismatch.md +25 -0
- package/vendor/Archive/data/docs/experiences/arkts-demo-coverage-import-trailing-slash.md +20 -0
- package/vendor/Archive/data/docs/experiences/arkts-library-source-files-may-be-ts.md +18 -0
- package/vendor/Archive/data/docs/experiences/arkts-typedarray-buffer-interface-cast-compile-fixes.md +36 -0
- package/vendor/Archive/data/docs/experiences/arkts-xts-compile-error-clustering-fix.md +24 -0
- package/vendor/Archive/data/docs/experiences/arkts-xts-doc-expected-value-runtime-probe.md +35 -0
- package/vendor/Archive/data/docs/experiences/arkts-xts-fixture-rawfile-testability-injection.md +33 -0
- package/vendor/Archive/data/docs/experiences/code-linter-chinese-comment-false-positive.md +16 -0
- package/vendor/Archive/data/docs/experiences/esobject-new-expression-variable-tracking.md +33 -0
- package/vendor/Archive/data/docs/experiences/filesystem-case-sensitivity-module-resolution.md +31 -0
- package/vendor/Archive/data/docs/experiences/gitcode-clone-redirect-warning-normal.md +13 -0
- package/vendor/Archive/data/docs/experiences/kn_msgvq1w585ec8319.md +77 -0
- package/vendor/Archive/data/docs/experiences/kn_msovnm6rd46de72c.md +98 -0
- package/vendor/Archive/data/docs/experiences/kn_mspt8vntfe708576.md +87 -0
- package/vendor/Archive/data/docs/experiences/kn_mspu1ei77adbbb48.md +133 -0
- package/vendor/Archive/data/docs/experiences/kn_mspubgak8d30bfce.md +128 -0
- package/vendor/Archive/data/docs/experiences/kn_mspug2de3cb1f7c3.md +115 -0
- package/vendor/Archive/data/docs/experiences/kn_skill_opt_001.md +38 -0
- package/vendor/Archive/data/docs/experiences/loop-artifacts-verification-evidence-triangle.md +19 -0
- package/vendor/Archive/data/docs/experiences/macos-bash-replace-build-ps1.md +19 -0
- package/vendor/Archive/data/docs/experiences/macos-bsd-diff-q-illegal-option.md +15 -0
- package/vendor/Archive/data/docs/experiences/migrate-cjs-compatible-api-version-map-limit.md +17 -0
- package/vendor/Archive/data/docs/experiences/mp3agic-arkts-library-behavior-quirks.md +21 -0
- package/vendor/Archive/data/docs/experiences/ohos-face-detection-scan-api-mapping.md +15 -0
- package/vendor/Archive/data/docs/experiences/pr-metadata-and-diff-integrity-verification.md +12 -0
- package/vendor/Archive/data/docs/experiences/rn-coverage-index-signature-pseudo-member-false-negative.md +32 -0
- package/vendor/Archive/data/docs/experiences/rn-memory-check-severity-calibration.md +21 -0
- package/vendor/Archive/data/docs/experiences/rn-platform-specific-api-exclusion-evidence.md +24 -0
- package/vendor/Archive/data/docs/experiences/rn-upstream-version-diff-pitfalls.md +17 -0
- package/vendor/Archive/data/docs/experiences/rn-version-gap-risk-rating-rules.md +13 -0
- package/vendor/Archive/data/docs/experiences/rn-view-lib-native-contract-diff-fabric-spec.md +16 -0
- package/vendor/Archive/data/docs/experiences/rnoh-adapter-package-version-field-semantics.md +18 -0
- package/vendor/Archive/data/docs/experiences/rnoh-arkts-sqlite-rows-array-format.md +18 -0
- package/vendor/Archive/data/docs/experiences/rnoh-dependency-residue-scan-strategy.md +18 -0
- package/vendor/Archive/data/docs/experiences/rnoh-example-local-lib-dep-use-tgz.md +53 -0
- package/vendor/Archive/data/docs/experiences/rnoh-example-prereserve-rntesterlist.md +17 -0
- package/vendor/Archive/data/docs/experiences/rnoh-example-template-compatiblesdkversion-upgrade.md +29 -0
- package/vendor/Archive/data/docs/experiences/rnoh-example-turbomodule-shell-adaptation-checklist.md +41 -0
- package/vendor/Archive/data/docs/experiences/rnoh-mcp-build-project-tool-risk.md +18 -0
- package/vendor/Archive/data/docs/experiences/rnoh-npm-devdependencies-version-precheck.md +29 -0
- package/vendor/Archive/data/docs/experiences/rnoh-repo-baseline-version-verification.md +13 -0
- package/vendor/Archive/data/docs/experiences/rnoh-repo-upstream-directory-mapping.md +18 -0
- package/vendor/Archive/data/docs/experiences/rnoh-stateless-library-zero-leak-verification.md +31 -0
- package/vendor/Archive/data/docs/experiences/rnoh-template-npmrc-credential-removal.md +15 -0
- package/vendor/Archive/data/docs/experiences/rnoh-turbomodule-codegen-wiring-verification.md +19 -0
- package/vendor/Archive/data/docs/experiences/rnoh-turbomodule-cpp-methodmap-compatibility-check.md +20 -0
- package/vendor/Archive/data/docs/experiences/scenario-doc-vs-source-signature-diff-four-patterns.md +24 -0
- package/vendor/Archive/data/docs/experiences/static-analysis-grep-cross-validation.md +29 -0
- package/vendor/Archive/demo.js +489 -0
- package/vendor/Archive/index.js +43 -0
- package/vendor/Archive/package.json +16 -0
- package/vendor/Archive/src/constants.js +83 -0
- package/vendor/Archive/src/data/stopwords.txt +110 -0
- package/vendor/Archive/src/data/synonyms.json +25 -0
- package/vendor/Archive/src/data/terms.txt +59 -0
- package/vendor/Archive/src/db/sqlite-backend.js +312 -0
- package/vendor/Archive/src/db/sqlite-schema.js +64 -0
- package/vendor/Archive/src/engine.js +501 -0
- package/vendor/Archive/src/index/index-manager.js +203 -0
- package/vendor/Archive/src/index/index-state.js +94 -0
- package/vendor/Archive/src/index/search-text-builder.js +106 -0
- package/vendor/Archive/src/index.js +22 -0
- package/vendor/Archive/src/parser/api-identifiers.js +121 -0
- package/vendor/Archive/src/parser/api-suffixes.js +48 -0
- package/vendor/Archive/src/parser/heading-normalize.js +40 -0
- package/vendor/Archive/src/parser/markdown-splitter.js +215 -0
- package/vendor/Archive/src/search/catalog-routing.js +87 -0
- package/vendor/Archive/src/search/fts-search.js +289 -0
- package/vendor/Archive/src/search/query-normalizer.js +159 -0
- package/vendor/Archive/src/search/query-rewriter.js +72 -0
- package/vendor/Archive/src/search/search-engine.js +72 -0
- package/vendor/Archive/src/search/snippet.js +64 -0
- package/vendor/Archive/src/store/dir-store.js +103 -0
- package/vendor/Archive/src/store/doc-store.js +36 -0
- package/vendor/Archive/src/tokenizer/lexicon.js +151 -0
- package/vendor/Archive/src/tokenizer/tokenizer.js +167 -0
- package/vendor/Archive/src/types.js +86 -0
- package/vendor/Archive/src/utils/hash.js +16 -0
- package/vendor/Archive/src/utils/lock.js +73 -0
- package/vendor/Archive/src/utils/path-safety.js +96 -0
- package/vendor/Archive/src/utils/paths.js +39 -0
- package/vendor/BadCase/rn/INDEX.md +127 -0
- package/vendor/BadCase/rn/cases/KI-001-webview/350/247/206/351/242/221/346/227/240/346/263/225/346/250/252/345/261/217.md +52 -0
- package/vendor/BadCase/rn/cases/KI-002-fastImage/347/203/255/346/233/264/346/226/260/345/233/276/347/211/207/345/244/261/350/264/245.md +37 -0
- package/vendor/BadCase/rn/cases/KI-003-wechat/347/274/251/347/225/245/345/233/276/346/234/254/345/234/260/345/233/276/347/211/207.md +62 -0
- package/vendor/BadCase/rn/cases/KI-004-wechat/345/233/236/350/260/203/346/227/266/345/272/217.md +47 -0
- package/vendor/BadCase/rn/cases/KI-005-geolocation/345/257/274/345/205/245/350/267/257/345/276/204/345/220/216/347/274/200.md +31 -0
- package/vendor/BadCase/rn/cases/KI-006-SmartRefreshLayout/346/231/272/350/203/275/346/214/207/351/222/210/345/264/251/346/272/203.md +55 -0
- package/vendor/BadCase/rn/cases/KI-007-orientation-locker/344/274/240/346/204/237/345/231/250/345/210/235/345/247/213/345/214/226.md +58 -0
- package/vendor/BadCase/rn/cases/KI-008-orientation-locker/344/274/240/346/204/237/345/231/250/345/274/225/347/224/250/350/256/241/346/225/260.md +47 -0
- package/vendor/BadCase/rn/cases/KI-009-pager-view/345/265/214/345/245/227/346/273/221/345/212/250.md +38 -0
- package/vendor/BadCase/rn/cases/KI-010-screens/346/211/213/345/212/277/345/206/262/347/252/201.md +48 -0
- package/vendor/BadCase/rn/cases/KI-011-spring-scrollview/346/211/213/345/212/277/351/207/215/345/244/215/347/273/221/345/256/232.md +49 -0
- package/vendor/BadCase/rn/cases/KI-012-qr-camera/346/250/252/345/261/217/351/200/202/351/205/215.md +59 -0
- package/vendor/BadCase/rn/cases/KI-013-webview/346/267/261/350/211/262/346/250/241/345/274/217/350/203/214/346/231/257/350/211/262.md +37 -0
- package/vendor/BadCase/rn/cases/KI-014-amap-geolocation/345/233/236/350/260/203/347/274/272/345/244/261.md +42 -0
- package/vendor/BadCase/rn/cases/KI-015-reanimated/350/277/220/350/241/214/346/227/266/346/236/220/346/236/204/345/264/251/346/272/203.md +54 -0
- package/vendor/BadCase/rn/cases/KI-016-fs/346/226/207/344/273/266/350/257/273/345/217/226/347/274/226/347/240/201.md +58 -0
- package/vendor/BadCase/rn/cases/KI-017-blob-util/345/217/202/346/225/260/347/274/226/347/240/201/351/224/231/350/257/257.md +39 -0
- package/vendor/BadCase/rn/cases/KI-018-modal/345/274/271/347/252/227/351/227/252/347/203/201.md +53 -0
- package/vendor/BadCase/rn/cases/KI-019-code-push/351/207/215/345/220/257/351/200/273/350/276/221/345/244/261/346/225/210.md +79 -0
- package/vendor/BadCase/rn/cases/KI-020-netinfo/346/225/217/346/204/237/344/277/241/346/201/257/346/263/204/351/234/262.md +60 -0
- package/vendor/BadCase/rn/cases/KI-021-video/346/234/254/345/234/260/350/247/206/351/242/221/346/222/255/346/224/276/345/274/202/345/270/270.md +79 -0
- package/vendor/BadCase/rn/cases/KI-022-audio-recorder-player/346/236/232/344/270/276/347/274/272/345/244/261.md +38 -0
- package/vendor/BadCase/rn/cases/KI-023-svg/346/270/220/345/217/230/347/273/247/346/211/277/345/244/261/346/225/210.md +62 -0
- package/vendor/BadCase/rn/generalization-log.md +55 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-SmartRefreshLayout-32.json +328 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-SmartRefreshLayout-32.md +382 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-amap-geolocation-27.json +1351 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-amap-geolocation-27.md +1176 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-audio-recorder-player-22.json +538 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-audio-recorder-player-22.md +1488 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-blob-util-23.json +211 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-blob-util-23.md +35 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-code-push-17.json +2048 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-code-push-17.md +3866 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-fast-image-102.json +198 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-fast-image-102.md +40 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-fs-38.json +751 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-fs-38.md +883 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-geolocation-24.json +1544 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-geolocation-24.md +2598 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-modal-20.json +246 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-modal-20.md +554 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-netinfo-31.json +211 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-netinfo-31.md +54 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-45.json +1626 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-45.md +2213 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-51.json +208 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-51.md +77 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-pager-view-32.json +377 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-pager-view-32.md +174 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-qr-decode-image-camera-37.json +232 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-qr-decode-image-camera-37.md +194 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-reanimated-82.json +198 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-reanimated-82.md +67 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-87.json +198 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-87.md +38 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-93.json +208 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-93.md +34 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-spring-scrollview-38.json +222 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-spring-scrollview-38.md +56 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-svg-117.json +463 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-svg-117.md +383 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-video-66.json +464 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-video-66.md +565 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-112.json +198 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-112.md +47 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-121.json +232 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-121.md +422 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-wechat-lib-15.json +295 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-wechat-lib-15.md +1038 -0
- package/vendor/BadCase/rn/rules/R-01-/345/205/250/345/261/217/347/252/227/345/217/243/347/212/266/346/200/201/347/256/241/347/220/206/345/256/214/346/225/264/346/200/247.md +20 -0
- package/vendor/BadCase/rn/rules/R-02-/350/265/204/346/272/220URI/345/275/242/346/200/201/345/210/206/346/224/257/350/246/206/347/233/226.md +21 -0
- package/vendor/BadCase/rn/rules/R-03-/351/231/204/345/261/236/346/223/215/344/275/234/345/244/261/350/264/245/351/230/273/346/226/255/344/270/273/346/265/201/347/250/213.md +20 -0
- package/vendor/BadCase/rn/rules/R-04-/345/274/202/346/255/245/345/233/236/350/260/203/346/263/250/345/206/214/346/227/266/345/272/217.md +20 -0
- package/vendor/BadCase/rn/rules/R-05-/346/250/241/345/235/227/345/257/274/345/205/245/350/267/257/345/276/204/350/247/204/350/214/203.md +19 -0
- package/vendor/BadCase/rn/rules/R-06-/344/274/240/346/204/237/345/231/250/347/241/254/344/273/266/346/235/203/351/231/220/346/214/211/351/234/200/350/216/267/345/217/226.md +21 -0
- package/vendor/BadCase/rn/rules/R-07-/346/231/272/350/203/275/346/214/207/351/222/210/347/224/237/345/221/275/345/221/250/346/234/237/347/256/241/347/220/206.md +20 -0
- package/vendor/BadCase/rn/rules/R-08-/346/211/213/345/212/277/344/272/213/344/273/266/346/263/250/345/206/214/344/270/216/345/206/262/347/252/201/345/244/204/347/220/206.md +22 -0
- package/vendor/BadCase/rn/rules/R-09-/346/250/252/347/253/226/345/261/217/345/244/232/345/275/242/346/200/201/345/270/203/345/261/200/351/200/202/351/205/215.md +20 -0
- package/vendor/BadCase/rn/rules/R-10-/346/267/261/350/211/262/346/250/241/345/274/217/344/270/273/351/242/230/351/242/234/350/211/262/351/200/202/351/205/215.md +19 -0
- package/vendor/BadCase/rn/rules/R-11-/346/216/245/345/217/243/345/233/236/350/260/203/345/256/236/347/216/260/345/256/214/346/225/264/346/200/247.md +20 -0
- package/vendor/BadCase/rn/rules/R-12-/345/216/237/347/224/237/350/277/220/350/241/214/346/227/266/350/265/204/346/272/220/346/236/220/346/236/204/346/227/266/345/272/217.md +20 -0
- package/vendor/BadCase/rn/rules/R-13-/346/226/207/344/273/266/346/225/260/346/215/256/347/274/226/347/240/201/344/270/216/346/240/274/345/274/217/345/205/274/345/256/271.md +21 -0
- package/vendor/BadCase/rn/rules/R-14-/345/212/250/347/224/273/345/210/235/345/247/213/345/214/226/346/227/266/345/272/217/344/270/216/347/212/266/346/200/201/345/220/214/346/255/245.md +20 -0
- package/vendor/BadCase/rn/rules/R-15-/347/212/266/346/200/201/346/214/201/344/271/205/345/214/226/344/270/216/351/207/215/345/220/257/351/200/273/350/276/221/344/270/200/350/207/264/346/200/247.md +20 -0
- package/vendor/BadCase/rn/rules/R-16-/346/225/217/346/204/237/344/277/241/346/201/257/346/227/245/345/277/227/346/263/204/351/234/262.md +19 -0
- package/vendor/BadCase/rn/rules/R-17-/345/252/222/344/275/223/350/265/204/346/272/220/347/224/237/345/221/275/345/221/250/346/234/237/344/270/216/351/224/231/350/257/257/345/244/204/347/220/206.md +21 -0
- package/vendor/BadCase/rn/rules/R-18-/350/203/275/345/212/233/346/236/232/344/270/276/351/205/215/347/275/256/345/256/214/346/225/264/346/200/247.md +19 -0
- package/vendor/BadCase/rn/rules/R-19-/345/233/276/345/275/242/346/270/262/346/237/223/345/261/236/346/200/247/347/273/247/346/211/277/344/270/216/351/207/215/347/275/256.md +19 -0
- package/vendor/MCP/README.md +490 -0
- package/vendor/MCP/config.json +29 -0
- package/vendor/MCP/package.json +23 -0
- package/vendor/MCP/scripts/analyze-demo-coverage.cjs +1203 -0
- package/vendor/MCP/scripts/analyze-xts-coverage.cjs +1245 -0
- package/vendor/MCP/scripts/deveco_docs.js +247 -0
- package/vendor/MCP/scripts/extract-interfaces.cjs +1487 -0
- package/vendor/MCP/scripts/flutter-analyze-demo-coverage.cjs +666 -0
- package/vendor/MCP/scripts/flutter-analyze-xts-coverage.cjs +684 -0
- package/vendor/MCP/scripts/flutter-extract-interfaces.cjs +1251 -0
- package/vendor/MCP/scripts/flutter-render-spec-doc.cjs +351 -0
- package/vendor/MCP/scripts/render-spec-doc.cjs +347 -0
- package/vendor/MCP/scripts/rn-analyze-demo-coverage.cjs +645 -0
- package/vendor/MCP/scripts/rn-analyze-test-coverage.cjs +614 -0
- package/vendor/MCP/scripts/rn-extract-interfaces.cjs +1462 -0
- package/vendor/MCP/scripts/rn-render-spec-doc.cjs +327 -0
- package/vendor/MCP/scripts/rn-scan-exports.cjs +1336 -0
- package/vendor/MCP/src/client/MCPClientPool.js +220 -0
- package/vendor/MCP/src/config/ConfigLoader.js +189 -0
- package/vendor/MCP/src/executor/ScriptExecutor.js +110 -0
- package/vendor/MCP/src/gateway/Gateway.js +451 -0
- package/vendor/MCP/src/index.js +87 -0
- package/vendor/MCP/src/library/KBToolProvider.js +229 -0
- package/vendor/MCP/src/library/logger.js +60 -0
- package/vendor/MCP/src/registry/ScriptRegistry.js +238 -0
- package/vendor/MCP/src/registry/ToolRegistry.js +111 -0
- package/vendor/MCP/src/types.js +115 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/references/MCP_TOOL_USAGE.md +4 -2
- package/vendor/Server/Skills/arkts-library-xts-coverage/SKILL.md +3 -3
- package/vendor/Server/Skills/knowledge-import/SKILL.md +1 -1
- package/vendor/Server/Skills/knowledge-import/references/MCP_TOOL_USAGE.md +12 -4
- package/vendor/Server/Skills/ohos-lib-pr-push/SKILL.md +5 -4
- package/vendor/Server/Skills/rn-library-issue-generalizer/SKILL.md +2 -2
- package/vendor/Server/Skills/rn-library-known-issue-check/SKILL.md +2 -2
- package/vendor/Server/Skills/rnoh-lib-demo-coverage/SKILL.md +1 -2
- package/vendor/Server/Skills/rnoh-lib-test-align/references/port-test-demo-guide.md +1 -1
- package/vendor/Server/Skills/rnoh-lib-xts-coverage/SKILL.md +1 -2
- package/vendor/Server/package.json +5 -1
- package/vendor/VERSION +3 -3
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
的
|
|
2
|
+
了
|
|
3
|
+
是
|
|
4
|
+
在
|
|
5
|
+
和
|
|
6
|
+
与
|
|
7
|
+
或
|
|
8
|
+
及
|
|
9
|
+
等
|
|
10
|
+
为
|
|
11
|
+
对
|
|
12
|
+
从
|
|
13
|
+
向
|
|
14
|
+
上
|
|
15
|
+
下
|
|
16
|
+
中
|
|
17
|
+
内
|
|
18
|
+
外
|
|
19
|
+
这
|
|
20
|
+
那
|
|
21
|
+
个
|
|
22
|
+
些
|
|
23
|
+
什么
|
|
24
|
+
怎么
|
|
25
|
+
如何
|
|
26
|
+
可以
|
|
27
|
+
需要
|
|
28
|
+
应该
|
|
29
|
+
使用
|
|
30
|
+
通过
|
|
31
|
+
进行
|
|
32
|
+
实现
|
|
33
|
+
a
|
|
34
|
+
an
|
|
35
|
+
the
|
|
36
|
+
of
|
|
37
|
+
to
|
|
38
|
+
in
|
|
39
|
+
on
|
|
40
|
+
at
|
|
41
|
+
by
|
|
42
|
+
for
|
|
43
|
+
with
|
|
44
|
+
from
|
|
45
|
+
into
|
|
46
|
+
onto
|
|
47
|
+
is
|
|
48
|
+
are
|
|
49
|
+
was
|
|
50
|
+
were
|
|
51
|
+
be
|
|
52
|
+
been
|
|
53
|
+
being
|
|
54
|
+
have
|
|
55
|
+
has
|
|
56
|
+
had
|
|
57
|
+
do
|
|
58
|
+
does
|
|
59
|
+
did
|
|
60
|
+
will
|
|
61
|
+
would
|
|
62
|
+
can
|
|
63
|
+
could
|
|
64
|
+
should
|
|
65
|
+
shall
|
|
66
|
+
may
|
|
67
|
+
might
|
|
68
|
+
must
|
|
69
|
+
this
|
|
70
|
+
that
|
|
71
|
+
these
|
|
72
|
+
those
|
|
73
|
+
it
|
|
74
|
+
its
|
|
75
|
+
they
|
|
76
|
+
them
|
|
77
|
+
their
|
|
78
|
+
there
|
|
79
|
+
here
|
|
80
|
+
which
|
|
81
|
+
who
|
|
82
|
+
whom
|
|
83
|
+
whose
|
|
84
|
+
what
|
|
85
|
+
when
|
|
86
|
+
where
|
|
87
|
+
why
|
|
88
|
+
how
|
|
89
|
+
all
|
|
90
|
+
any
|
|
91
|
+
both
|
|
92
|
+
each
|
|
93
|
+
few
|
|
94
|
+
more
|
|
95
|
+
most
|
|
96
|
+
other
|
|
97
|
+
some
|
|
98
|
+
such
|
|
99
|
+
no
|
|
100
|
+
nor
|
|
101
|
+
not
|
|
102
|
+
only
|
|
103
|
+
own
|
|
104
|
+
same
|
|
105
|
+
so
|
|
106
|
+
than
|
|
107
|
+
too
|
|
108
|
+
very
|
|
109
|
+
just
|
|
110
|
+
now
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[
|
|
2
|
+
["弹窗", "dialog", "Dialog", "popup", "Popup", "对话框"],
|
|
3
|
+
["路由", "router", "Router", "navigation", "导航", "Navigation"],
|
|
4
|
+
["生命周期", "lifecycle", "Lifecycle", "LifeCycle"],
|
|
5
|
+
["权限", "permission", "Permission", "授权"],
|
|
6
|
+
["动画", "animation", "Animation", "animateTo"],
|
|
7
|
+
["状态管理", "state", "State", "状态", "@State"],
|
|
8
|
+
["列表", "list", "List", "列表组件"],
|
|
9
|
+
["网络", "network", "Network", "http", "HTTP", "请求"],
|
|
10
|
+
["存储", "storage", "Storage", "持久化", "Persistent"],
|
|
11
|
+
["事件", "event", "Event", "回调", "callback", "Callback"],
|
|
12
|
+
["布局", "layout", "Layout", "Flex", "布局容器"],
|
|
13
|
+
["手势", "gesture", "Gesture", "触摸"],
|
|
14
|
+
["相机", "camera", "Camera", "cameraManager"],
|
|
15
|
+
["预览", "preview", "Preview", "预览流"],
|
|
16
|
+
["音频", "audio", "Audio", "播放"],
|
|
17
|
+
["视频", "video", "Video", "播放器"],
|
|
18
|
+
["通知", "notification", "Notification", "推送"],
|
|
19
|
+
["后台", "background", "Background", "后台任务"],
|
|
20
|
+
["线程", "thread", "Thread", "TaskPool", "Worker"],
|
|
21
|
+
["日志", "log", "Log", "hilog"],
|
|
22
|
+
["调试", "debug", "Debug", "profiler"],
|
|
23
|
+
["打包", "build", "Build", "hap", "打包构建"],
|
|
24
|
+
["签名", "sign", "Sign", "证书", "certificate"]
|
|
25
|
+
]
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
AbilityStage
|
|
2
|
+
UIAbility
|
|
3
|
+
ExtensionAbility
|
|
4
|
+
ArkUI
|
|
5
|
+
ArkTS
|
|
6
|
+
cameraManager
|
|
7
|
+
Navigation
|
|
8
|
+
NavDestination
|
|
9
|
+
AbilityConstant
|
|
10
|
+
Want
|
|
11
|
+
AbilityContext
|
|
12
|
+
UIContext
|
|
13
|
+
component
|
|
14
|
+
Builder
|
|
15
|
+
Entry
|
|
16
|
+
Component
|
|
17
|
+
State
|
|
18
|
+
Prop
|
|
19
|
+
Link
|
|
20
|
+
Provide
|
|
21
|
+
Consume
|
|
22
|
+
Watch
|
|
23
|
+
Observed
|
|
24
|
+
Track
|
|
25
|
+
Persistent
|
|
26
|
+
LocalStorage
|
|
27
|
+
AppStorage
|
|
28
|
+
Environment
|
|
29
|
+
XComponent
|
|
30
|
+
WebView
|
|
31
|
+
List
|
|
32
|
+
Grid
|
|
33
|
+
Swiper
|
|
34
|
+
Tabs
|
|
35
|
+
Image
|
|
36
|
+
Text
|
|
37
|
+
TextInput
|
|
38
|
+
Button
|
|
39
|
+
Stack
|
|
40
|
+
Flex
|
|
41
|
+
Column
|
|
42
|
+
Row
|
|
43
|
+
RelativeContainer
|
|
44
|
+
Shape
|
|
45
|
+
Path
|
|
46
|
+
Circle
|
|
47
|
+
Rect
|
|
48
|
+
Ellipse
|
|
49
|
+
Polyline
|
|
50
|
+
Polygon
|
|
51
|
+
animateTo
|
|
52
|
+
transition
|
|
53
|
+
geometryTransition
|
|
54
|
+
sharedTransition
|
|
55
|
+
Inspector
|
|
56
|
+
profiler
|
|
57
|
+
hdc
|
|
58
|
+
hilog
|
|
59
|
+
ohpm
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sqlite-backend.js — SQLite 后端(基于 node:sqlite)
|
|
3
|
+
*
|
|
4
|
+
* 使用 Node.js 内置的 node:sqlite 模块(DatabaseSync / StatementSync),
|
|
5
|
+
* 完整支持 FTS5 + bm25,直接操作文件持久化,无需 WASM。
|
|
6
|
+
*
|
|
7
|
+
* 对外暴露适配后的 DB 对象,提供与原 WASM 方案一致的 API:
|
|
8
|
+
* db.exec(sql)
|
|
9
|
+
* db.prepare(sql) → StmtAdapter
|
|
10
|
+
* db.selectValue(sql)
|
|
11
|
+
*
|
|
12
|
+
* StatementSync 适配层(StmtAdapter):
|
|
13
|
+
* stmt.bind(params[]) → 缓存参数
|
|
14
|
+
* stmt.step() → 执行一次,返回是否有行
|
|
15
|
+
* stmt.get() → 取当前行(对象形式)
|
|
16
|
+
* stmt.reset() → 重置语句状态
|
|
17
|
+
* stmt.finalize() → 释放语句(node:sqlite 自动管理,此处空操作)
|
|
18
|
+
*
|
|
19
|
+
* 读写分离:
|
|
20
|
+
* - openWriteDb:打开持久化文件 DB(DatabaseSync),支持增删改查。
|
|
21
|
+
* - openReadDb:复用写库连接(node:sqlite 同进程内支持并发读),
|
|
22
|
+
* 按 mtimeMs 缓存独立只读连接,写入后失效。
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import fs from 'node:fs';
|
|
26
|
+
import path from 'node:path';
|
|
27
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
28
|
+
import { SCHEMA_SQL } from './sqlite-schema.js';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* StatementSync 适配器 — 兼容 WASM 风格的 bind/step/get/finalize/reset。
|
|
32
|
+
*
|
|
33
|
+
* node:sqlite 的 StatementSync 不支持逐行 step() 游标推进。
|
|
34
|
+
* get() 每次返回第一行,iterate() 返回迭代器,all() 返回全部行。
|
|
35
|
+
* 为兼容 WASM 风格的 while(stmt.step()) { stmt.get() } 循环,
|
|
36
|
+
* 在首次 step() 时用 all() 预取全部行,后续 step() 推进索引。
|
|
37
|
+
*/
|
|
38
|
+
class StmtAdapter {
|
|
39
|
+
/**
|
|
40
|
+
* @param {import('node:sqlite').StatementSync} stmt
|
|
41
|
+
*/
|
|
42
|
+
constructor(stmt) {
|
|
43
|
+
this._stmt = stmt;
|
|
44
|
+
/** @type {unknown[]|null} */
|
|
45
|
+
this._bound = null;
|
|
46
|
+
/** @type {object[]|null} 预取的全部行 */
|
|
47
|
+
this._rows = null;
|
|
48
|
+
/** @type {number} 当前行索引 */
|
|
49
|
+
this._index = -1;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 绑定参数(WASM 风格接受数组)。
|
|
54
|
+
* @param {unknown[]} params
|
|
55
|
+
*/
|
|
56
|
+
bind(params) {
|
|
57
|
+
this._bound = Array.isArray(params) ? params : [params];
|
|
58
|
+
this._rows = null;
|
|
59
|
+
this._index = -1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* 执行一步,返回是否还有数据行。
|
|
64
|
+
*
|
|
65
|
+
* 首次调用:用 all() 预取全部行(SELECT)或 run() 执行(INSERT/UPDATE/DELETE)。
|
|
66
|
+
* 后续调用:推进行索引。
|
|
67
|
+
*
|
|
68
|
+
* @returns {boolean}
|
|
69
|
+
*/
|
|
70
|
+
step() {
|
|
71
|
+
if (!this._stmt) return false;
|
|
72
|
+
|
|
73
|
+
// 首次 step:执行语句并预取结果
|
|
74
|
+
if (this._rows === null) {
|
|
75
|
+
const params = this._bound || [];
|
|
76
|
+
try {
|
|
77
|
+
// SELECT 语句:all() 返回全部行
|
|
78
|
+
this._rows = this._stmt.all(...params);
|
|
79
|
+
} catch {
|
|
80
|
+
// 非 SELECT 语句(INSERT/UPDATE/DELETE):用 run() 执行
|
|
81
|
+
try {
|
|
82
|
+
this._stmt.run(...params);
|
|
83
|
+
} catch {
|
|
84
|
+
// 忽略执行错误,上层通过返回空结果感知
|
|
85
|
+
}
|
|
86
|
+
this._rows = [];
|
|
87
|
+
}
|
|
88
|
+
this._index = 0;
|
|
89
|
+
} else {
|
|
90
|
+
// 后续 step:推进索引
|
|
91
|
+
this._index++;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return this._index < this._rows.length;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* 获取当前行数据(对象形式)。
|
|
99
|
+
* @returns {object}
|
|
100
|
+
*/
|
|
101
|
+
get() {
|
|
102
|
+
if (this._rows === null || this._index < 0 || this._index >= this._rows.length) {
|
|
103
|
+
return {};
|
|
104
|
+
}
|
|
105
|
+
return this._rows[this._index];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 重置语句(WASM 风格)。
|
|
110
|
+
* 清空预取结果,下次 step() 会重新执行。
|
|
111
|
+
*/
|
|
112
|
+
reset() {
|
|
113
|
+
this._rows = null;
|
|
114
|
+
this._index = -1;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 释放语句(WASM 风格)。
|
|
119
|
+
* node:sqlite 的 StatementSync 由 GC 管理,此处清空引用。
|
|
120
|
+
*/
|
|
121
|
+
finalize() {
|
|
122
|
+
this._stmt = null;
|
|
123
|
+
this._bound = null;
|
|
124
|
+
this._rows = null;
|
|
125
|
+
this._index = -1;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* DatabaseSync 适配器 — 在原 DB 上添加 selectValue 等便捷方法。
|
|
131
|
+
*/
|
|
132
|
+
class DbAdapter {
|
|
133
|
+
/**
|
|
134
|
+
* @param {import('node:sqlite').DatabaseSync} db
|
|
135
|
+
*/
|
|
136
|
+
constructor(db) {
|
|
137
|
+
this._db = db;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 执行 SQL(无参数)。
|
|
142
|
+
* @param {string} sql
|
|
143
|
+
*/
|
|
144
|
+
exec(sql) {
|
|
145
|
+
this._db.exec(sql);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 预处理 SQL,返回适配后的语句。
|
|
150
|
+
* @param {string} sql
|
|
151
|
+
* @returns {StmtAdapter}
|
|
152
|
+
*/
|
|
153
|
+
prepare(sql) {
|
|
154
|
+
const stmt = this._db.prepare(sql);
|
|
155
|
+
return new StmtAdapter(stmt);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* 执行查询并返回单个标量值。
|
|
160
|
+
* @param {string} sql
|
|
161
|
+
* @param {...unknown} params
|
|
162
|
+
* @returns {unknown}
|
|
163
|
+
*/
|
|
164
|
+
selectValue(sql, ...params) {
|
|
165
|
+
const stmt = this._db.prepare(sql);
|
|
166
|
+
const row = stmt.get(...params);
|
|
167
|
+
if (!row) return undefined;
|
|
168
|
+
const keys = Object.keys(row);
|
|
169
|
+
if (keys.length === 0) return undefined;
|
|
170
|
+
return row[keys[0]];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* 关闭数据库连接。
|
|
175
|
+
*/
|
|
176
|
+
close() {
|
|
177
|
+
this._db.close();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export default class SqliteBackend {
|
|
182
|
+
constructor() {
|
|
183
|
+
/** @type {DbAdapter|null} */
|
|
184
|
+
this.writeDb = null;
|
|
185
|
+
/** @type {{path:string,mtimeMs:number,db:DbAdapter}|null} */
|
|
186
|
+
this.readCache = null;
|
|
187
|
+
/** @type {string|null} */
|
|
188
|
+
this._dbPath = null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* 初始化后端(node:sqlite 无需异步初始化)。
|
|
193
|
+
* @returns {Promise<void>}
|
|
194
|
+
*/
|
|
195
|
+
async init() {
|
|
196
|
+
// node:sqlite 是同步内置模块,无需异步初始化
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 打开(或复用)持久化读写数据库。
|
|
201
|
+
* @param {string} dbPath
|
|
202
|
+
* @returns {Promise<DbAdapter>}
|
|
203
|
+
*/
|
|
204
|
+
async openWriteDb(dbPath) {
|
|
205
|
+
if (this.writeDb) return this.writeDb;
|
|
206
|
+
|
|
207
|
+
await fs.promises.mkdir(path.dirname(dbPath), { recursive: true });
|
|
208
|
+
|
|
209
|
+
const isNew = !fs.existsSync(dbPath);
|
|
210
|
+
const rawDb = new DatabaseSync(dbPath);
|
|
211
|
+
// 启用 WAL 模式提升并发读写性能
|
|
212
|
+
rawDb.exec('PRAGMA journal_mode = WAL;');
|
|
213
|
+
rawDb.exec('PRAGMA foreign_keys = ON;');
|
|
214
|
+
|
|
215
|
+
if (isNew) {
|
|
216
|
+
rawDb.exec(SCHEMA_SQL);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
this.writeDb = new DbAdapter(rawDb);
|
|
220
|
+
this._dbPath = dbPath;
|
|
221
|
+
return this.writeDb;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* 打开只读数据库连接(按 mtime 缓存)。
|
|
226
|
+
* 优先复用写库连接,避免多连接开销。
|
|
227
|
+
* @param {string} dbPath
|
|
228
|
+
* @returns {Promise<DbAdapter>}
|
|
229
|
+
*/
|
|
230
|
+
async openReadDb(dbPath) {
|
|
231
|
+
// 同路径直接复用写库(node:sqlite 单连接支持读写并发)
|
|
232
|
+
if (this.writeDb && this._dbPath === dbPath) {
|
|
233
|
+
return this.writeDb;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const stat = await fs.promises.stat(dbPath);
|
|
237
|
+
|
|
238
|
+
if (
|
|
239
|
+
this.readCache &&
|
|
240
|
+
this.readCache.path === dbPath &&
|
|
241
|
+
this.readCache.mtimeMs === stat.mtimeMs
|
|
242
|
+
) {
|
|
243
|
+
return this.readCache.db;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
this.readCache?.db.close();
|
|
247
|
+
const rawDb = new DatabaseSync(dbPath);
|
|
248
|
+
rawDb.exec('PRAGMA query_only = ON;');
|
|
249
|
+
this.readCache = {
|
|
250
|
+
path: dbPath,
|
|
251
|
+
mtimeMs: stat.mtimeMs,
|
|
252
|
+
db: new DbAdapter(rawDb),
|
|
253
|
+
};
|
|
254
|
+
return this.readCache.db;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 写入后调用,使只读缓存失效。
|
|
259
|
+
*/
|
|
260
|
+
invalidateReadCache() {
|
|
261
|
+
this.readCache?.db.close();
|
|
262
|
+
this.readCache = null;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* 执行 VACUUM 压缩数据库,回收碎片空间。
|
|
267
|
+
*
|
|
268
|
+
* 删除/更新文档会产生空闲页(freelist),VACUUM 重建数据库文件,
|
|
269
|
+
* 消除碎片,保持文件紧凑。适合在批量删除或 rebuildIndex 后调用。
|
|
270
|
+
*
|
|
271
|
+
* @returns {Promise<void>}
|
|
272
|
+
*/
|
|
273
|
+
async vacuum() {
|
|
274
|
+
if (!this.writeDb) return;
|
|
275
|
+
// VACUUM 不能在事务中执行
|
|
276
|
+
this.writeDb.exec('VACUUM;');
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 将 WAL 日志合并回主数据库文件(checkpoint)。
|
|
281
|
+
*
|
|
282
|
+
* WAL 模式下写入先进入 -wal 文件,checkpoint 后才合并到 .db。
|
|
283
|
+
* 关闭连接前调用可确保 .db 文件包含最新数据,
|
|
284
|
+
* 这对 git 提交尤为重要——避免提交的 .db 缺少近期写入。
|
|
285
|
+
*
|
|
286
|
+
* @returns {Promise<void>}
|
|
287
|
+
*/
|
|
288
|
+
async checkpoint() {
|
|
289
|
+
if (!this.writeDb) return;
|
|
290
|
+
// TRUNCATE 模式:合并 WAL 到主库并截断 WAL 文件
|
|
291
|
+
this.writeDb.exec('PRAGMA wal_checkpoint(TRUNCATE);');
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* 关闭所有数据库连接,释放资源。
|
|
296
|
+
* 关闭前执行 checkpoint 确保 WAL 数据合并到主库文件。
|
|
297
|
+
* @returns {Promise<void>}
|
|
298
|
+
*/
|
|
299
|
+
async close() {
|
|
300
|
+
if (this.writeDb) {
|
|
301
|
+
try {
|
|
302
|
+
await this.checkpoint();
|
|
303
|
+
} catch {
|
|
304
|
+
// checkpoint 失败不影响关闭
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
this.writeDb?.close();
|
|
308
|
+
this.readCache?.db.close();
|
|
309
|
+
this.writeDb = null;
|
|
310
|
+
this.readCache = null;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sqlite-schema.js — SQLite FTS5 DDL
|
|
3
|
+
*
|
|
4
|
+
* 定义 documents / segments / segments_fts 虚拟表及同步触发器。
|
|
5
|
+
* 通过外部内容表模式(content='segments')保持 FTS 与段表一致。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const SCHEMA_SQL = `
|
|
9
|
+
-- 文档表: 记录文档元信息
|
|
10
|
+
CREATE TABLE IF NOT EXISTS documents (
|
|
11
|
+
id INTEGER PRIMARY KEY,
|
|
12
|
+
document_id TEXT NOT NULL UNIQUE,
|
|
13
|
+
catalog_id INTEGER NOT NULL,
|
|
14
|
+
doc_title TEXT NOT NULL,
|
|
15
|
+
metadata TEXT DEFAULT '{}',
|
|
16
|
+
created_at INTEGER NOT NULL,
|
|
17
|
+
updated_at INTEGER NOT NULL
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
-- 段表: 文档拆分后的索引单元
|
|
21
|
+
CREATE TABLE IF NOT EXISTS segments (
|
|
22
|
+
id INTEGER PRIMARY KEY,
|
|
23
|
+
doc_id INTEGER NOT NULL REFERENCES documents(id) ON DELETE CASCADE,
|
|
24
|
+
section_title TEXT NOT NULL DEFAULT '',
|
|
25
|
+
lead_text TEXT NOT NULL DEFAULT '',
|
|
26
|
+
search_text TEXT NOT NULL,
|
|
27
|
+
excerpt_truncated INTEGER NOT NULL DEFAULT 0
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
-- FTS5 全文索引虚拟表(外部内容表模式)
|
|
31
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS segments_fts USING fts5(
|
|
32
|
+
search_text,
|
|
33
|
+
content='segments',
|
|
34
|
+
content_rowid='id',
|
|
35
|
+
tokenize='unicode61'
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
-- 同步触发器: segments 增删改自动同步 FTS
|
|
39
|
+
CREATE TRIGGER IF NOT EXISTS segments_ai AFTER INSERT ON segments BEGIN
|
|
40
|
+
INSERT INTO segments_fts(rowid, search_text) VALUES (new.id, new.search_text);
|
|
41
|
+
END;
|
|
42
|
+
|
|
43
|
+
CREATE TRIGGER IF NOT EXISTS segments_ad AFTER DELETE ON segments BEGIN
|
|
44
|
+
INSERT INTO segments_fts(segments_fts, rowid, search_text)
|
|
45
|
+
VALUES ('delete', old.id, old.search_text);
|
|
46
|
+
END;
|
|
47
|
+
|
|
48
|
+
CREATE TRIGGER IF NOT EXISTS segments_au AFTER UPDATE ON segments BEGIN
|
|
49
|
+
INSERT INTO segments_fts(segments_fts, rowid, search_text)
|
|
50
|
+
VALUES ('delete', old.id, old.search_text);
|
|
51
|
+
INSERT INTO segments_fts(rowid, search_text)
|
|
52
|
+
VALUES (new.id, new.search_text);
|
|
53
|
+
END;
|
|
54
|
+
|
|
55
|
+
-- 辅助索引
|
|
56
|
+
CREATE INDEX IF NOT EXISTS segments_doc_id_idx ON segments(doc_id);
|
|
57
|
+
CREATE INDEX IF NOT EXISTS documents_catalog_idx ON documents(catalog_id);
|
|
58
|
+
|
|
59
|
+
-- 索引元数据表
|
|
60
|
+
CREATE TABLE IF NOT EXISTS index_meta (
|
|
61
|
+
key TEXT PRIMARY KEY,
|
|
62
|
+
value TEXT NOT NULL
|
|
63
|
+
);
|
|
64
|
+
`;
|