soma-core 2.2.8 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/core/build/compiler/full-manifest-builder.ts +1 -1
  2. package/core/build/compiler/host-config-sync.cjs +1 -1
  3. package/core/build/compiler/soma-manifest-webpack-plugin.js +2 -6
  4. package/core/build/compiler/soma-precompile.js +84 -4
  5. package/core/client/a11y/announcer.ts +2 -16
  6. package/core/client/base/SomaPageRootBase.ts +2 -2
  7. package/core/client/base/defineSomaView.ts +11 -2
  8. package/core/client/base/runtime-services.types.ts +57 -0
  9. package/core/client/data/role-gate.ts +2 -8
  10. package/core/client/engine/event-engine.ts +1 -0
  11. package/core/client/engines/diff/adapter-jsdiff.ts +27 -8
  12. package/core/client/engines/diff/code.ts +205 -0
  13. package/core/client/engines/diff/index.ts +107 -6
  14. package/core/client/engines/diff/items.ts +212 -0
  15. package/core/client/engines/diff/port.ts +215 -3
  16. package/core/client/engines/diff/prose.ts +443 -0
  17. package/core/client/engines/engine-adapters.ts +6 -0
  18. package/core/client/engines/highlight/adapter-lezer.ts +109 -0
  19. package/core/client/engines/highlight/index.ts +135 -0
  20. package/core/client/engines/highlight/port.ts +92 -0
  21. package/core/client/engines/markdown/adapter-markdown-it.ts +65 -0
  22. package/core/client/engines/markdown/blocks.ts +335 -0
  23. package/core/client/engines/markdown/index.ts +51 -0
  24. package/core/client/engines/markdown/port.ts +94 -0
  25. package/core/client/engines/markdown/vendor-modules.d.ts +6 -0
  26. package/core/client/engines/structured/adapter-js-yaml.ts +33 -0
  27. package/core/client/engines/structured/index.ts +139 -0
  28. package/core/client/engines/structured/port.ts +59 -0
  29. package/core/client/infra/http/SomaHttpService.ts +2 -4
  30. package/core/client/infra/notify/DefaultNotifyService.ts +2 -3
  31. package/core/client/infra/permission/SomaPermission.ts +1 -1
  32. package/core/client/render-ports/notify-renderer.ts +2 -46
  33. package/core/client/runtime/SomaRuntimeServices.ts +16 -45
  34. package/core/server/host/app-config-composer.ts +6 -52
  35. package/core/server/host/host-config-paths.cjs +2 -100
  36. package/core/server/host/precompiled-manifest.ts +69 -0
  37. package/core/server/host/source-packages.cjs +3 -0
  38. package/core/server/infra/host-config-paths.cjs +100 -0
  39. package/core/server/page-assets.ts +2 -70
  40. package/core/server/runtime-space/bindings.ts +33 -4
  41. package/core/server/runtime-space/store.ts +16 -1
  42. package/core/shared/app-config-merge.ts +59 -0
  43. package/core/shared/registry-generated/limits.ts +84 -4
  44. package/core/shared/types/announcer.types.ts +18 -0
  45. package/core/shared/types/notify.types.ts +26 -0
  46. package/core/shared/types/role-gate.types.ts +11 -0
  47. package/dist/browser/runtime-bundle.manifest.json +51 -7
  48. package/dist/browser/soma-runtime.js +120952 -104762
  49. package/dist/core/index.cjs +113613 -97412
  50. package/dist/host-native/aot-builder.cjs +582 -371
  51. package/dist/host-native/native-server.cjs +203 -72
  52. package/dist/lsp/component-tree.cjs +84 -4
  53. package/dist/types/build/compiler/full-manifest-builder.d.ts +1 -1
  54. package/dist/types/client/a11y/announcer.d.ts +2 -14
  55. package/dist/types/client/base/SomaPageRootBase.d.ts +2 -2
  56. package/dist/types/client/base/runtime-services.types.d.ts +50 -0
  57. package/dist/types/client/data/role-gate.d.ts +2 -8
  58. package/dist/types/client/engines/diff/code.d.ts +27 -0
  59. package/dist/types/client/engines/diff/index.d.ts +2 -1
  60. package/dist/types/client/engines/diff/items.d.ts +24 -0
  61. package/dist/types/client/engines/diff/port.d.ts +201 -2
  62. package/dist/types/client/engines/diff/prose.d.ts +80 -0
  63. package/dist/types/client/engines/engine-adapters.d.ts +6 -0
  64. package/dist/types/client/engines/highlight/adapter-lezer.d.ts +6 -0
  65. package/dist/types/client/engines/highlight/index.d.ts +15 -0
  66. package/dist/types/client/engines/highlight/port.d.ts +64 -0
  67. package/dist/types/client/engines/markdown/adapter-markdown-it.d.ts +6 -0
  68. package/dist/types/client/engines/markdown/blocks.d.ts +29 -0
  69. package/dist/types/client/engines/markdown/index.d.ts +9 -0
  70. package/dist/types/client/engines/markdown/port.d.ts +166 -0
  71. package/dist/types/client/engines/structured/adapter-js-yaml.d.ts +6 -0
  72. package/dist/types/client/engines/structured/index.d.ts +29 -0
  73. package/dist/types/client/engines/structured/port.d.ts +45 -0
  74. package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
  75. package/dist/types/client/infra/notify/DefaultNotifyService.d.ts +2 -3
  76. package/dist/types/client/infra/permission/SomaPermission.d.ts +1 -1
  77. package/dist/types/client/render-ports/notify-renderer.d.ts +1 -56
  78. package/dist/types/client/runtime/SomaRuntimeServices.d.ts +9 -44
  79. package/dist/types/server/host/app-config-composer.d.ts +2 -3
  80. package/dist/types/server/host/host-config-paths.d.cts +2 -7
  81. package/dist/types/server/host/precompiled-manifest.d.ts +5 -0
  82. package/dist/types/server/host/source-packages.d.cts +5 -0
  83. package/dist/types/server/infra/host-config-paths.d.cts +7 -0
  84. package/dist/types/server/page-assets.d.ts +2 -5
  85. package/dist/types/server/runtime-space/store.d.ts +4 -0
  86. package/dist/types/shared/app-config-merge.d.ts +3 -0
  87. package/dist/types/shared/registry-generated/limits.d.ts +82 -4
  88. package/dist/types/shared/types/announcer.types.d.ts +14 -0
  89. package/dist/types/shared/types/notify.types.d.ts +36 -0
  90. package/dist/types/shared/types/role-gate.types.d.ts +8 -0
  91. package/host-native/src/aot-builder.ts +159 -96
  92. package/host-native/src/dev-chunk-gc.ts +104 -0
  93. package/host-native/src/host-prepare.ts +1 -1
  94. package/host-native/src/manifest-http.ts +1 -1
  95. package/host-native/src/page-http.ts +2 -67
  96. package/host-native/src/page-payload-cache.ts +68 -0
  97. package/host-native/src/public-packages.cjs +147 -50
  98. package/package.json +16 -2
@@ -5282,6 +5282,16 @@ var SOMA_PIPELINE_LIMITS = {
5282
5282
  "file": "core/server/registry/api-registry-store.ts",
5283
5283
  "symbol": "SOMA_PIPELINE_LIMITS"
5284
5284
  },
5285
+ {
5286
+ "module": "soma-core",
5287
+ "file": "core/client/engines/diff/index.ts",
5288
+ "symbol": "SOMA_PIPELINE_LIMITS"
5289
+ },
5290
+ {
5291
+ "module": "soma-core",
5292
+ "file": "core/client/engines/highlight/index.ts",
5293
+ "symbol": "SOMA_PIPELINE_LIMITS"
5294
+ },
5285
5295
  {
5286
5296
  "module": "soma-core",
5287
5297
  "file": "core/server/registry/page-registry-store.ts",
@@ -5584,17 +5594,17 @@ var SOMA_PIPELINE_LIMITS = {
5584
5594
  },
5585
5595
  {
5586
5596
  "module": "soma-ai",
5587
- "file": "src/api/common/RateLimitBackend.ts",
5597
+ "file": "src/server/common/RateLimitBackend.ts",
5588
5598
  "symbol": "SOMA_PIPELINE_LIMITS_AI"
5589
5599
  },
5590
5600
  {
5591
5601
  "module": "soma-ai",
5592
- "file": "src/api/common/RequestBodyLimit.ts",
5602
+ "file": "src/server/common/RequestBodyLimit.ts",
5593
5603
  "symbol": "SOMA_PIPELINE_LIMITS_AI"
5594
5604
  },
5595
5605
  {
5596
5606
  "module": "soma-ai",
5597
- "file": "src/api/service/ai-assistant/Chat.ts",
5607
+ "file": "src/server/services/ai-assistant/Chat.ts",
5598
5608
  "symbol": "SOMA_PIPELINE_LIMITS_AI"
5599
5609
  },
5600
5610
  {
@@ -5609,7 +5619,7 @@ var SOMA_PIPELINE_LIMITS = {
5609
5619
  },
5610
5620
  {
5611
5621
  "module": "soma-ai",
5612
- "file": "src/api/common/TrustedRequestContext.ts",
5622
+ "file": "src/domain/ai-shared/TrustedRequestContext.ts",
5613
5623
  "symbol": "SOMA_PIPELINE_LIMITS_AI_RUNTIME"
5614
5624
  },
5615
5625
  {
@@ -5782,6 +5792,76 @@ var SOMA_PIPELINE_LIMITS = {
5782
5792
  "tokensBytes": 40960,
5783
5793
  "componentBytesPerPage": 163840,
5784
5794
  "overrideBlockBytes": 8192
5795
+ },
5796
+ "contentEngines": {
5797
+ "diff": {
5798
+ "basis": {
5799
+ "maxChars": "\u5355\u4E2A\u5DEE\u5F02\u8BA1\u7B97\u4E24\u4FA7\u5408\u8BA1\u5B57\u6570\u4E0A\u9650\uFF1B\u8D85\u9650\u4E0D\u8BA1\u7B97\u3001\u6574\u6BB5\u66FF\u6362\uFF08\u53C2\u8003\u6587\u672C\u5DEE\u5F02\u7EC4\u4EF6\u7B14\u8BB0 C.5\u300C\u5355\u4E2A\u5DEE\u5F02\u7EC4\u4EF6\u603B\u91CF 200 000 \u5B57\u300D\uFF0C\u5B9E\u6D4B 4\uFF1A\u4E07\u5B57\u7EA7\u9010\u5B57\u6BD4\u8F83\u9700\u8D85\u65F6\u4E0E\u9000\u5316\uFF09",
5800
+ "maxCharsPerCompare": "\u5355\u6B21\u8BCD\u7EA7\u6BD4\u8F83\uFF08\u4E00\u5BF9\u53E5\u5B50 / \u4E00\u6B21 diff \u8C03\u7528\uFF09\u4E24\u4FA7\u5408\u8BA1\u5B57\u6570\u4E0A\u9650\uFF08\u7B14\u8BB0 C.2 BaseOpts maxChars 20 000\uFF09",
5801
+ "timeoutMs": "\u4E00\u6B21 diffProse / diffItems \u7684\u603B\u65F6\u9650\uFF08\u6BEB\u79D2\uFF09\uFF0C\u540C VisualEditor timeout 1000\uFF08\u7B14\u8BB0 C.2\uFF09",
5802
+ "maxItems": "\u6761\u76EE\u5217\u8868\u5355\u4FA7\u6761\u76EE\u6570\u4E0A\u9650\uFF1B\u8D85\u9650\u4E0D\u9010\u6761\u6BD4\u8F83\uFF08\u7B14\u8BB0 C.5\u300C\u6761\u76EE 2 000 \u4E2A\u300D\uFF09",
5803
+ "moveDetectMaxChanged": "\u53D8\u5316\u6761\u76EE\uFF08\u589E + \u5220\uFF09\u8D85\u8FC7\u6B64\u6570\u4E0D\u505A\u79FB\u52A8\u68C0\u6D4B\uFF08\u7B14\u8BB0 C.2\uFF0Cwikidiff2 \u589E\u5220\u5408\u8BA1 > 100 \u4E0D\u68C0\u6D4B\u7684\u653E\u5BBD\u7248\uFF0C\u7ECF\u9A8C\u503C\uFF09",
5804
+ "pairAt": "\u53E5 / \u6BB5\u914D\u5BF9\u9608\u503C\uFF1A\u5B57\u7B26\u591A\u91CD\u96C6 Dice \u2265 \u6B64\u503C\u89C6\u4E3A\u6539\u5199\uFF08VisualEditor diffThreshold 0.5\uFF1B\u5B9E\u6D4B 3 \u7684\u6539\u5199\u53E5\u4E3A 0.84\u20130.89\uFF09",
5805
+ "rewriteBelow": "\u6574\u4F53\u76F8\u4F3C\u5EA6\u4F4E\u4E8E\u6B64\u503C\u6574\u6BB5\u66FF\u6362\uFF08\u7B49\u6548 VE keep < 0.5 \xD7 diff\uFF1B\u5B9E\u6D4B 2 \u7684 C3 \u6574\u53E5\u91CD\u5199\u7EA6 0.16\uFF09",
5806
+ "absorbOrphan": "\u5B64\u5B57\u5438\u6536\uFF1A\u5939\u5728\u4E24\u5904\u6539\u52A8\u95F4\u3001\u957F\u5EA6 \u2264 \u6B64\u503C\uFF08\u5B57\uFF09\u7684\u975E\u6807\u70B9\u76F8\u540C\u7247\u6BB5\u5E76\u5165\u6539\u52A8\uFF08\u5B9E\u6D4B 2 \u7684 C5\u300C\u671F\u300D\uFF09",
5807
+ "absorbOrphanMax": "\u8C03\u7528\u65B9\u53EF\u8C03\u7684\u5B64\u5B57\u5438\u6536\u4E0A\u9650\uFF08\u5B57\uFF09\uFF0C\u9632\u6B62\u628A\u6574\u53E5\u5438\u6210\u6539\u52A8",
5808
+ "titleAt": "\u65E0 key \u6761\u76EE\u6309\u6807\u9898\u914D\u5BF9\u7684\u76F8\u4F3C\u5EA6\u9608\u503C\uFF08\u7B14\u8BB0 C.2 ItemOpts.match.titleAt 0.6\uFF09",
5809
+ "bodyAt": "\u65E0 key \u6761\u76EE\u6309\u6B63\u6587\u914D\u5BF9\u7684\u76F8\u4F3C\u5EA6\u9608\u503C\uFF08\u7B14\u8BB0 C.2 ItemOpts.match.bodyAt 0.5\uFF09",
5810
+ "maxAlignTokens": "\u5E8F\u5217\u5BF9\u9F50\u7684\u4E0D\u540C\u952E\u6570\u4E0A\u9650\uFF08\u6BCF\u4E2A\u952E\u6620\u5C04\u4E3A\u4E00\u4E2A BMP \u79C1\u7528\u533A\u5B57\u7B26\uFF0CU+E000\u2013U+F8FF \u5171 6400 \u4E2A\uFF09",
5811
+ "maxPairMatrix": "\u4E00\u6BB5\u5220\u589E\u533A\u95F4\u5185\u53E5 / \u6BB5\u914D\u5BF9\u7684\u5019\u9009\u77E9\u9635\u4E0A\u9650\uFF08\u5220\u6570 \xD7 \u589E\u6570\uFF09\uFF0C\u8D85\u51FA\u4E0D\u914D\u5BF9\u3001\u6309\u5220 + \u589E\u5448\u73B0\uFF1B\u7ECF\u9A8C\u503C\uFF0C\u8BC1\u636E\u5F31",
5812
+ "maxPairCandidates": "\u65E0 key \u6761\u76EE\u6309\u76F8\u4F3C\u5EA6\u914D\u5BF9\u7684\u5019\u9009\u77E9\u9635\u4E0A\u9650\uFF08\u5269\u4F59\u65E7\u6761\u76EE \xD7 \u5269\u4F59\u65B0\u6761\u76EE\uFF09\uFF1B\u7ECF\u9A8C\u503C\uFF0C\u8BC1\u636E\u5F31",
5813
+ "codeContext": "\u4EE3\u7801\u5DEE\u5F02\u6BCF\u5757\u7684\u4E0A\u4E0B\u6587\u884C\u6570\uFF08\u7B14\u8BB0 C.5\u300C\u4E0A\u4E0B\u6587 3 \u884C\u300D\uFF0C\u540C git diff -U3 / VS Code\uFF09",
5814
+ "codeIntraMaxLine": "\u4EE3\u7801\u6539\u884C\u505A\u884C\u5185\u5B57\u7B26\u5DEE\u5F02\u7684\u5355\u884C\u957F\u5EA6\u4E0A\u9650\uFF08\u5B57\u7B26\uFF09\uFF1B\u66F4\u957F\u7684\u884C\u53EA\u6807\u6574\u884C\u589E\u5220\uFF08\u7ECF\u9A8C\u503C\uFF1A\u538B\u7F29\u540E\u7684\u957F\u884C\u9010\u5B57\u6BD4\u8F83\u65E0\u610F\u4E49\u4E14\u8017\u65F6\uFF09"
5815
+ },
5816
+ "maxChars": 2e5,
5817
+ "maxCharsPerCompare": 2e4,
5818
+ "timeoutMs": 1e3,
5819
+ "maxItems": 2e3,
5820
+ "moveDetectMaxChanged": 500,
5821
+ "pairAt": 0.5,
5822
+ "rewriteBelow": 0.4,
5823
+ "absorbOrphan": 1,
5824
+ "absorbOrphanMax": 4,
5825
+ "titleAt": 0.6,
5826
+ "bodyAt": 0.5,
5827
+ "maxAlignTokens": 6400,
5828
+ "maxPairMatrix": 2500,
5829
+ "maxPairCandidates": 25e4,
5830
+ "codeContext": 3,
5831
+ "codeIntraMaxLine": 500
5832
+ },
5833
+ "highlight": {
5834
+ "basis": {
5835
+ "maxLines": "\u9AD8\u4EAE\u7684\u6700\u591A\u884C\u6570\uFF1B\u8D85\u51FA\u90E8\u5206\u6309\u7EAF\u6587\u672C\uFF08\u53C2\u8003\u6587\u672C\u5DEE\u5F02\u7EC4\u4EF6\u7B14\u8BB0 C.2 \u7AEF\u53E3 2 maxLines 5 000\uFF09",
5836
+ "maxLineLength": "\u5355\u884C\u8D85\u8FC7\u6B64\u5B57\u7B26\u6570\u6574\u884C\u6309\u7EAF\u6587\u672C\uFF08\u7B14\u8BB0 C.2 maxLineLength 2 000\uFF0C\u538B\u7F29\u540E\u7684\u5355\u884C JS / JSON \u5E38\u89C1\uFF09",
5837
+ "timeoutMs": "\u4E00\u6B21\u89E3\u6790\u7684\u65F6\u9650\uFF08\u6BEB\u79D2\uFF09\uFF1BLezer \u6309 advance() \u5206\u6B65\u89E3\u6790\uFF0C\u8D85\u65F6\u6574\u6BB5\u6309\u7EAF\u6587\u672C\uFF08\u7ECF\u9A8C\u503C\uFF0C\u4E0E\u5DEE\u5F02\u7AEF\u53E3\u540C\u53D6 1 000\uFF09",
5838
+ "maxChars": "\u6574\u6BB5\u8D85\u8FC7\u6B64\u5B57\u7B26\u6570\u4E0D\u89E3\u6790\u3001\u6309\u7EAF\u6587\u672C\uFF08\u7ECF\u9A8C\u503C\uFF0C\u8BC1\u636E\u5F31\uFF1A\u7EA6 1 MB \u6587\u672C\uFF09",
5839
+ "jsonSniffMaxChars": "\u8BED\u8A00\u63A8\u65AD\u300C\u6574\u4F53\u80FD JSON.parse\u300D\u53EA\u5BF9\u4E0D\u8D85\u8FC7\u6B64\u5B57\u7B26\u6570\u7684\u6837\u672C\u505A\uFF08\u907F\u514D\u5BF9\u5927\u6587\u672C\u53CD\u590D\u89E3\u6790\uFF1B\u7ECF\u9A8C\u503C\uFF09"
5840
+ },
5841
+ "maxLines": 5e3,
5842
+ "maxLineLength": 2e3,
5843
+ "timeoutMs": 1e3,
5844
+ "maxChars": 1e6,
5845
+ "jsonSniffMaxChars": 2e5
5846
+ },
5847
+ "structured": {
5848
+ "basis": {
5849
+ "maxChars": "JSON / YAML \u539F\u6587\u8D85\u8FC7\u6B64\u5B57\u7B26\u6570\u4E0D\u89E3\u6790\u3001\u6309\u539F\u6587\u663E\u793A\uFF08\u4E0E\u4EE3\u7801\u9AD8\u4EAE\u7AEF\u53E3 maxChars \u540C\u53D6\u7EA6 1 MB\uFF1B\u7ECF\u9A8C\u503C\uFF0C\u8BC1\u636E\u5F31\uFF09",
5850
+ "maxNodes": "\u89E3\u6790\u540E\u503C\u7684\u8282\u70B9\u603B\u6570\u4E0A\u9650\uFF08\u5BF9\u8C61 / \u6570\u7EC4 / \u53F6\u5B50\u5404\u8BA1 1\uFF09\uFF1BYAML \u522B\u540D\u5C55\u5F00\u8D85\u9650\u5373\u6309 too-many-nodes \u964D\u7EA7\uFF0C\u9632\u300C\u5341\u4EBF\u7B11\u58F0\u300D\u5F0F\u522B\u540D\u70B8\u5F39\uFF08\u7ECF\u9A8C\u503C\uFF1A20 \u4E07\u8282\u70B9\u7EA6\u4E3A 1 MB \u7D27\u51D1 JSON \u7684\u91CF\u7EA7\uFF09"
5851
+ },
5852
+ "maxChars": 1e6,
5853
+ "maxNodes": 2e5
5854
+ },
5855
+ "markdown": {
5856
+ "basis": {
5857
+ "maxChars": "Markdown \u539F\u6587\u8D85\u8FC7\u6B64\u5B57\u7B26\u6570\u4E0D\u89E3\u6790\u3001\u6309\u7EAF\u6587\u672C\u663E\u793A\uFF08\u53C2\u8003\u6587\u672C\u5DEE\u5F02\u7EC4\u4EF6\u7B14\u8BB0 C.2 \u7AEF\u53E3 1 limits.maxChars 200 000\uFF09",
5858
+ "maxBlocks": "\u5757\u6570\u4E0A\u9650\uFF0C\u8D85\u51FA\u622A\u65AD\u5E76\u6807 truncated\uFF08\u7B14\u8BB0 C.2 maxBlocks 5 000\uFF09",
5859
+ "summaryChars": "meta.summary \u53D6\u53BB\u6807\u8BB0\u5168\u6587\u7684\u524D N \u5B57\uFF08\u7B14\u8BB0 C.2\u300C\u524D 80 \u5B57\u300D\uFF09"
5860
+ },
5861
+ "maxChars": 2e5,
5862
+ "maxBlocks": 5e3,
5863
+ "summaryChars": 80
5864
+ }
5785
5865
  }
5786
5866
  };
5787
5867
 
@@ -9,7 +9,7 @@ import type { SomaPageGenerationAssets } from '../../shared/types/compile-port.t
9
9
  import { type SomaRouteEntry } from './route-builder';
10
10
  import type { SomaPageMarkup, TreeCompileContext } from '../../shared/types/component-tree.types';
11
11
  import type { TreeArtifact } from '../../shared/types/component-tree-artifact.types';
12
- import { parseAppConfigYaml } from '../../server/host/app-config-composer';
12
+ import { parseAppConfigYaml } from '../../shared/app-config-merge';
13
13
  export interface SomaPrecompiledPage {
14
14
  path: string;
15
15
  /** Optional only for compatibility with manifests created before REQ-016. */
@@ -1,4 +1,5 @@
1
- export type AnnouncePoliteness = 'polite' | 'assertive';
1
+ import type { AnnounceOptions, AnnouncePoliteness, Announcer } from '../../shared/types/announcer.types';
2
+ export type { AnnounceOptions, AnnouncePoliteness, Announcer };
2
3
  /** politeness 闭集;宿主也按这个顺序创建 */
3
4
  export declare const ANNOUNCE_POLITENESS: readonly AnnouncePoliteness[];
4
5
  /** 宿主元素上的标记属性,值为 politeness */
@@ -19,19 +20,6 @@ export interface AnnouncerOptions {
19
20
  /** 时钟(测试注入);缺省全局定时器 */
20
21
  readonly clock?: AnnouncerClock;
21
22
  }
22
- export interface AnnounceOptions {
23
- readonly politeness?: AnnouncePoliteness;
24
- }
25
- export interface Announcer {
26
- /** 追加一条播报;空消息忽略;politeness 缺省 polite,未知值抛 TypeError */
27
- announce(message: string, options?: AnnounceOptions): void;
28
- /** 两个常驻宿主 */
29
- hosts(): Readonly<Record<AnnouncePoliteness, HTMLElement>>;
30
- /** 立即移除全部待清理节点 */
31
- clear(): void;
32
- /** 清空、取消计时并移除宿主;之后 announce 忽略 */
33
- dispose(): void;
34
- }
35
23
  /**
36
24
  * 读 design `announcer.clearAfterMs`;真源(生成物)目前没有 `announcer` 族,缺该键时为 undefined。
37
25
  * 按未知形状守卫读取,不再强转成生成物类型里并不存在的字段。
@@ -1,6 +1,6 @@
1
1
  import type { SomaPageRoot, SomaAppConfig } from '../../shared/types/domain.types';
2
2
  import type { SomaPageState, SomaPageStateConfig } from '../../shared/types/page-state.types';
3
- import type { SomaRuntimeServices } from '../runtime/SomaRuntimeServices';
3
+ import type { SomaRuntimeServicesShape } from './runtime-services.types';
4
4
  import type { SomaPageNav } from '../../shared/types/nav.types';
5
5
  /**
6
6
  * SomaPageRootBase — 页面聚合根基类
@@ -29,7 +29,7 @@ export declare abstract class SomaPageRootBase implements SomaPageRoot {
29
29
  */
30
30
  _config: SomaAppConfig;
31
31
  /** 由引擎注入的运行时基础设施(router / http / notify 等) */
32
- _services?: SomaRuntimeServices;
32
+ _services?: SomaRuntimeServicesShape;
33
33
  /**
34
34
  * 导航目录的只读视图(E4 / R-15):`services.nav.entries()` 与 `activeOf()` 的当前快照,外壳(顶栏、框架菜单)绑定
35
35
  * `page._nav.entries` / `page._nav.active` 渲染,不再只读编译期写死的菜单。
@@ -0,0 +1,50 @@
1
+ import type { TokenAuthService } from '../infra/auth/TokenAuthService';
2
+ import type { MemoryCache } from '../infra/cache/MemoryCache';
3
+ import type { SomaConfig } from '../infra/config/SomaConfig';
4
+ import type { SomaAppConfigPort } from '../infra/config/feature-flags';
5
+ import type { SomaEventBus } from '../infra/event-bus/SomaEventBus';
6
+ import type { SomaHttpService } from '../infra/http/SomaHttpService';
7
+ import type { SomaLocaleCatalog } from '../infra/i18n/locale-catalog';
8
+ import type { SomaIdentityPort } from '../infra/identity/identity-port';
9
+ import type { ConsoleLogger } from '../infra/logger/ConsoleLogger';
10
+ import type { DefaultNotifyService } from '../infra/notify/DefaultNotifyService';
11
+ import type { SomaPermission } from '../infra/permission/SomaPermission';
12
+ import type { IRealtimeService } from '../infra/realtime/IRealtimeService';
13
+ import type { SomaRouter } from '../infra/router/SomaRouter';
14
+ import type { IStorageService } from '../infra/storage/IStorageService';
15
+ import type { SomaTimer } from '../infra/timer/SomaTimer';
16
+ import type { SomaObservationChannel } from '../observability/runtime-observer';
17
+ import type { SomaRuntimeServicesBase } from '../../shared/types/domain.types';
18
+ import type { SomaNavPort } from '../../shared/types/nav.types';
19
+ import type { SomaShortcutRegistry } from '../../shared/types/write-runtime.types';
20
+ /** 界面中途提交服务(见 SomaRuntimeServices.ui) */
21
+ export interface SomaUiService {
22
+ publish(): Promise<void>;
23
+ }
24
+ /**
25
+ * 运行时基础设施形状契约(`SomaPageRootBase._services` 与 `SomaRuntimeServices` 共用)。
26
+ * `engines` 与 `navHistory` 为领域层具体类型,在此以泛型槽位留口,避免基础层反向依赖领域层。
27
+ */
28
+ export interface SomaRuntimeServicesShape<TEngines = unknown, TNavHistory = unknown> extends SomaRuntimeServicesBase {
29
+ router: SomaRouter;
30
+ notify: DefaultNotifyService;
31
+ logger: ConsoleLogger;
32
+ http: SomaHttpService;
33
+ storage: IStorageService;
34
+ timer: SomaTimer;
35
+ eventBus: SomaEventBus;
36
+ cache: MemoryCache<unknown>;
37
+ config: SomaConfig;
38
+ auth: TokenAuthService;
39
+ permission: SomaPermission;
40
+ i18n: SomaLocaleCatalog;
41
+ realtime: IRealtimeService;
42
+ ui: SomaUiService;
43
+ observation: SomaObservationChannel;
44
+ readonly engines: TEngines;
45
+ nav?: SomaNavPort;
46
+ readonly identity: SomaIdentityPort;
47
+ readonly navHistory?: TNavHistory;
48
+ readonly appConfig?: SomaAppConfigPort;
49
+ readonly shortcuts?: SomaShortcutRegistry;
50
+ }
@@ -1,10 +1,4 @@
1
- /** Host 提供的角色集来源(`SomaBootstrapOptions.auth`) */
2
- export interface SomaAuthOption {
3
- getRoles(): readonly string[];
4
- }
5
- export interface SomaRoleGate {
6
- /** 当前角色集与 `required` 有交集才为真 */
7
- hasAnyRole(required: readonly string[]): boolean;
8
- }
1
+ import type { SomaAuthOption, SomaRoleGate } from '../../shared/types/role-gate.types';
2
+ export type { SomaAuthOption, SomaRoleGate };
9
3
  /** 每次判定现读角色集(登录态变化后立即生效,不缓存) */
10
4
  export declare function createRoleGate(auth: SomaAuthOption | undefined): SomaRoleGate;
@@ -0,0 +1,27 @@
1
+ import type { CodeDiff, CodeDiffHunk, CodeDiffLine, MarkdownBlockKind, MarkdownDiff } from './port';
2
+ import { type ProseRun } from './prose';
3
+ export interface CodeConfig {
4
+ readonly maxChars: number;
5
+ readonly maxAlignTokens: number;
6
+ readonly maxPairMatrix: number;
7
+ readonly pairAt: number;
8
+ /** 每块上下文行数 */
9
+ readonly context: number;
10
+ /** 行内字符差异只对不超过此长度的行做 */
11
+ readonly intraMaxLine: number;
12
+ }
13
+ /** 行级操作 → 按上下文切块(纯函数) */
14
+ export declare function hunksOf(lines: readonly CodeDiffLine[], context: number): CodeDiffHunk[];
15
+ export declare function runCode(run: ProseRun, cfg: CodeConfig, a: string, b: string): Promise<CodeDiff>;
16
+ /** 源码 → 块(空行分隔;围栏代码整块,围栏里的空行不切);纯函数 */
17
+ export declare function splitMarkdownBlocks(source: string): string[];
18
+ export declare function markdownBlockKind(block: string): {
19
+ kind: MarkdownBlockKind;
20
+ detail: string;
21
+ };
22
+ /** 块的可比文字:去掉块首标记(# / > / 列表符号 / 围栏行),空白归一 */
23
+ export declare function markdownBlockText(block: string, kind: MarkdownBlockKind): string;
24
+ export interface MarkdownConfig extends CodeConfig {
25
+ readonly maxBlocks: number;
26
+ }
27
+ export declare function runMarkdown(run: ProseRun, cfg: MarkdownConfig, a: string, b: string): Promise<MarkdownDiff>;
@@ -1,5 +1,6 @@
1
- export type { DiffMode, DiffOptions, DiffPart, SomaDiffAdapter, SomaDiffPort } from './port';
1
+ export type { CodeDiff, CodeDiffHunk, CodeDiffLine, CodeDiffOptions, MarkdownBlockKind, MarkdownDiff, MarkdownDiffBlock, DiffFragment, DiffMode, DiffOptions, DiffPart, ItemDiff, ItemDiffEntry, ItemDiffOptions, ItemFieldDiff, ItemFieldSpec, ItemFieldType, ItemState, ProseBlock, ProseDegraded, ProseDiff, ProseDiffOptions, ProseNormalizeOptions, SomaDiffAdapter, SomaDiffPort, } from './port';
2
2
  export { assertDiffAdapter } from './port';
3
+ export { hunksOf, markdownBlockKind, markdownBlockText, splitMarkdownBlocks } from './code';
3
4
  import type { EngineLoadTelemetry } from '../load';
4
5
  import { type SomaDiffAdapter, type SomaDiffPort } from './port';
5
6
  export interface DiffPortOptions {
@@ -0,0 +1,24 @@
1
+ import type { ItemDiff, ItemFieldSpec } from './port';
2
+ import { type ProseConfig, type ProseRun } from './prose';
3
+ export interface ItemsConfig extends ProseConfig {
4
+ readonly titleAt: number;
5
+ readonly bodyAt: number;
6
+ readonly maxItems: number;
7
+ readonly moveDetectMaxChanged: number;
8
+ readonly maxPairCandidates: number;
9
+ }
10
+ export interface ItemsInput {
11
+ readonly key?: string;
12
+ readonly fields?: readonly ItemFieldSpec[];
13
+ readonly title?: string;
14
+ readonly detectMoves: boolean;
15
+ }
16
+ type Rec = Readonly<Record<string, unknown>>;
17
+ /** 稳定序列化(键排序),用于 value 字段判等 */
18
+ export declare function stableStringify(v: unknown): string;
19
+ /** 缺省字段:两侧对象出现过的键(按首次出现顺序,除 key 外);字符串 → text,其余 → value */
20
+ export declare function inferFields(records: readonly Rec[], key: string | undefined): ItemFieldSpec[];
21
+ /** 最长递增子序列的成员下标(O(n log n)) */
22
+ export declare function lisMembers(seq: readonly number[]): Set<number>;
23
+ export declare function runItems(run: ProseRun, cfg: ItemsConfig, beforeRaw: readonly unknown[], afterRaw: readonly unknown[], input: ItemsInput): Promise<ItemDiff>;
24
+ export {};
@@ -1,4 +1,5 @@
1
- export type DiffMode = 'chars' | 'words' | 'lines';
1
+ /** 粒度:`words-zh` = jsdiff `diffWords` + `Intl.Segmenter(word)`(运行时没有分词器时适配器退回逐字) */
2
+ export type DiffMode = 'chars' | 'words' | 'lines' | 'words-zh';
2
3
  export interface DiffPart {
3
4
  readonly op: 'equal' | 'insert' | 'delete';
4
5
  readonly text: string;
@@ -8,9 +9,207 @@ export interface DiffOptions {
8
9
  readonly ignoreWhitespace?: boolean;
9
10
  /** 最大输入长度(调用方传);超限抛 `CORE-ALGO-DIFF-INPUT` */
10
11
  readonly maxLength?: number;
12
+ /** 本次比较的超时(毫秒);缺省取 design `limits.json#contentEngines.diff.timeoutMs`。超时端口退回整段替换 */
13
+ readonly timeoutMs?: number;
14
+ }
15
+ /** 适配器:两段字符串按粒度求片段;超时(库返回 undefined)时返回 null */
16
+ export interface SomaDiffAdapter {
17
+ diff(a: string, b: string, mode: DiffMode, options?: DiffOptions): Promise<readonly DiffPart[] | null>;
18
+ }
19
+ /** 行内片段:`eq` 未变、`ins` 新增、`del` 删除(显示用原文;判等用归一化文本) */
20
+ export interface DiffFragment {
21
+ readonly v: string;
22
+ readonly op: 'eq' | 'ins' | 'del';
23
+ }
24
+ export interface ProseNormalizeOptions {
25
+ /** NFKC(全角 ASCII 与 `,():;!?` → 半角;`。、“”` 不变) */
26
+ readonly nfkc?: boolean;
27
+ /** 连续空白折叠为一个,并去掉汉字与拉丁 / 数字之间的空白 */
28
+ readonly collapseWhitespace?: boolean;
29
+ /** 换行统一为 `\n` */
30
+ readonly newline?: boolean;
31
+ }
32
+ export interface ProseDiffOptions {
33
+ /** 归一化只用于判等;缺省全开 */
34
+ readonly normalize?: ProseNormalizeOptions;
35
+ /** 句 / 段配对阈值,缺省取 design(0.5) */
36
+ readonly pairAt?: number;
37
+ /** 整体相似度低于它 → 整段替换,缺省取 design(0.4) */
38
+ readonly rewriteBelow?: number;
39
+ /** 夹在两处改动间、长度 ≤ 此值的非标点相同片段并入改动,缺省取 design(1 字) */
40
+ readonly absorbOrphan?: number;
41
+ /** 本次计算的总时限(毫秒),缺省取 design(1000) */
42
+ readonly timeoutMs?: number;
43
+ /** 两侧合计字数上限,缺省取 design(200 000);超限不计算、整段替换 */
44
+ readonly maxChars?: number;
45
+ }
46
+ /** 段级块:`mod` 的 fragments 含句级与词级片段 */
47
+ export interface ProseBlock {
48
+ readonly op: 'eq' | 'ins' | 'del' | 'mod';
49
+ readonly fragments: readonly DiffFragment[];
50
+ }
51
+ export type ProseDegraded = 'timeout' | 'too-large' | 'no-segmenter';
52
+ export interface ProseDiff {
53
+ /** same = 归一化后相同;inline = 行内标注;rewrite = 相似度低于 rewriteBelow,组件上下堆叠旧 / 新 */
54
+ readonly kind: 'same' | 'inline' | 'rewrite';
55
+ /** 两版只有空白 / 全半角 / 换行差异(kind 为 same 时才可能为 true) */
56
+ readonly formatOnly: boolean;
57
+ /** Dice:2 × 相同字数 ÷ (旧字数 + 新字数),按归一化文本计 */
58
+ readonly similarity: number;
59
+ readonly blocks: readonly ProseBlock[];
60
+ readonly stats: {
61
+ readonly insChars: number;
62
+ readonly delChars: number;
63
+ readonly changes: number;
64
+ };
65
+ /** 实际用到的词粒度:`words-zh`(有分词器)/ `chars`(退回逐字)/ `words`(无中文) */
66
+ readonly granularity: 'words-zh' | 'words' | 'chars';
67
+ readonly degraded?: ProseDegraded;
68
+ }
69
+ export type ItemFieldType = 'text' | 'value';
70
+ export interface ItemFieldSpec {
71
+ readonly name: string;
72
+ readonly label: string;
73
+ /** text = 散文差异;value = 整值比较(数字、枚举、日期等,显示「旧 → 新」) */
74
+ readonly type: ItemFieldType;
75
+ }
76
+ export interface ItemDiffOptions extends Omit<ProseDiffOptions, 'maxChars'> {
77
+ /** 有则按 key 配对(字段名);无则按内容配对 */
78
+ readonly key?: string;
79
+ /** 要比较的字段;缺省取两侧对象共有的字段(字符串 → text,其余标量 → value),第一个 text 字段当标题 */
80
+ readonly fields?: readonly ItemFieldSpec[];
81
+ /** 无 key 时的标题字段;缺省取 fields 里第一个 text 字段 */
82
+ readonly title?: string;
83
+ /** 标题相似度 ≥ 此值视为同一条(缺省取 design 0.6) */
84
+ readonly titleAt?: number;
85
+ /** 正文相似度 ≥ 此值视为同一条(缺省取 design 0.5) */
86
+ readonly bodyAt?: number;
87
+ /** 缺省 true;变化条目超过 design `moveDetectMaxChanged` 时自动关并标 `movesSkipped` */
88
+ readonly detectMoves?: boolean;
89
+ }
90
+ export type ItemState = 'added' | 'removed' | 'modified' | 'moved' | 'moved-modified' | 'same';
91
+ export interface ItemFieldDiff {
92
+ readonly name: string;
93
+ readonly label: string;
94
+ readonly type: ItemFieldType;
95
+ /** 字段状态:added / removed = 该字段只在一侧有值 */
96
+ readonly state: 'same' | 'changed' | 'added' | 'removed';
97
+ readonly before: unknown;
98
+ readonly after: unknown;
99
+ /** text 字段且两侧都有值、有改动时给出 */
100
+ readonly prose?: ProseDiff;
101
+ }
102
+ export interface ItemDiffEntry {
103
+ readonly state: ItemState;
104
+ /** 配对键:有 key 时是 key 值,否则是 `b<旧序号>` / `a<新序号>` */
105
+ readonly key: string;
106
+ readonly beforeIndex?: number;
107
+ readonly afterIndex?: number;
108
+ readonly title: string;
109
+ readonly fields: readonly ItemFieldDiff[];
110
+ /** 0–1,= 1 − 全条目相似度 */
111
+ readonly magnitude: number;
112
+ }
113
+ export interface ItemDiff {
114
+ /** 按新版顺序排列,被删除的条目插在它原来前一条之后 */
115
+ readonly items: readonly ItemDiffEntry[];
116
+ readonly stats: {
117
+ readonly total: number;
118
+ readonly added: number;
119
+ readonly removed: number;
120
+ readonly modified: number;
121
+ readonly moved: number;
122
+ readonly same: number;
123
+ };
124
+ /** 告诉组件「无 id,按内容配对」,组件给一句说明 */
125
+ readonly pairing: 'key' | 'content';
126
+ readonly fields: readonly ItemFieldSpec[];
127
+ readonly movesSkipped: boolean;
128
+ readonly degraded?: ProseDegraded | 'too-many-items';
129
+ }
130
+ export interface CodeDiffLine {
131
+ readonly op: 'eq' | 'ins' | 'del';
132
+ /** 旧版行号(1 起;增行无) */
133
+ readonly a?: number;
134
+ /** 新版行号(1 起;删行无) */
135
+ readonly b?: number;
136
+ readonly text: string;
137
+ /** 改行:配对另一侧的行号(删行给新版行号,增行给旧版行号) */
138
+ readonly pair?: number;
139
+ /** 改行的行内字符差异(删行只含 eq / del,增行只含 eq / ins);行过长或超时缺省 */
140
+ readonly fragments?: readonly DiffFragment[];
141
+ }
142
+ export interface CodeDiffHunk {
143
+ readonly aStart: number;
144
+ readonly aLines: number;
145
+ readonly bStart: number;
146
+ readonly bLines: number;
147
+ /** 在 `lines` 中的起止下标(含) */
148
+ readonly from: number;
149
+ readonly to: number;
150
+ readonly lines: readonly CodeDiffLine[];
151
+ }
152
+ export interface CodeDiff {
153
+ readonly kind: 'same' | 'changed';
154
+ /** 全部行(合并视图顺序:改行组内删行在增行上方) */
155
+ readonly lines: readonly CodeDiffLine[];
156
+ /** 按 design `contentEngines.diff.codeContext` 行上下文切出的块 */
157
+ readonly hunks: readonly CodeDiffHunk[];
158
+ readonly stats: {
159
+ readonly added: number;
160
+ readonly removed: number;
161
+ readonly modified: number;
162
+ };
163
+ /** 去掉全部空白后两侧相同 */
164
+ readonly whitespaceOnly: boolean;
165
+ /** too-large / timeout:不逐行对齐,整体按「全删 + 全增」给出 */
166
+ readonly degraded?: 'too-large' | 'timeout';
167
+ }
168
+ export type MarkdownBlockKind = 'heading' | 'paragraph' | 'list' | 'quote' | 'code' | 'table' | 'hr';
169
+ export interface MarkdownDiffBlock {
170
+ readonly op: 'eq' | 'ins' | 'del' | 'mod';
171
+ readonly kind: MarkdownBlockKind;
172
+ /** 块的 Markdown 源码(组件经 Markdown 端口渲染) */
173
+ readonly before?: string;
174
+ readonly after?: string;
175
+ /** mod:块文字(去块首标记)的词级差异;代码块不给(组件改用 diffCode) */
176
+ readonly fragments?: readonly DiffFragment[];
177
+ /** 结构变化:标题层级、列表有序 / 无序、代码语言 */
178
+ readonly notes?: readonly {
179
+ readonly what: 'heading-level' | 'list-type' | 'code-language';
180
+ readonly before: string;
181
+ readonly after: string;
182
+ }[];
183
+ readonly similarity?: number;
184
+ }
185
+ export interface MarkdownDiff {
186
+ readonly kind: 'same' | 'changed';
187
+ readonly blocks: readonly MarkdownDiffBlock[];
188
+ readonly stats: {
189
+ readonly added: number;
190
+ readonly removed: number;
191
+ readonly modified: number;
192
+ readonly same: number;
193
+ };
194
+ /** too-large / timeout:blocks 为空,组件退回源码对比(diffCode) */
195
+ readonly degraded?: 'too-large' | 'timeout';
196
+ }
197
+ export interface CodeDiffOptions {
198
+ /** 时限(调用方只能更小) */
199
+ readonly timeoutMs?: number;
200
+ /** 上下文行数(调用方只能更小) */
201
+ readonly context?: number;
11
202
  }
12
203
  export interface SomaDiffPort {
204
+ /** 两段字符串按粒度求片段(超时退回整段替换,不抛错) */
13
205
  diff(a: string, b: string, mode: DiffMode, options?: DiffOptions): Promise<readonly DiffPart[]>;
206
+ /** 散文两级差异(段 → 句 → 词);中文默认按词(Intl.Segmenter),无分词器时按字并标 degraded */
207
+ diffProse(a: string, b: string, options?: ProseDiffOptions): Promise<ProseDiff>;
208
+ /** 条目列表差异:key 或内容配对、字段差异、LIS 最少移动 */
209
+ diffItems(before: readonly unknown[], after: readonly unknown[], options?: ItemDiffOptions): Promise<ItemDiff>;
210
+ /** 代码差异:按行对齐、改行行内字符差异、按上下文切块;超长 / 超时退化为全删 + 全增(不抛) */
211
+ diffCode(a: string, b: string, options?: CodeDiffOptions): Promise<CodeDiff>;
212
+ /** Markdown 差异:源码块级对齐 + 块内词级 + 结构变化说明;超长 / 超时 blocks 为空并标 degraded(不抛) */
213
+ diffMarkdown(a: string, b: string, options?: CodeDiffOptions): Promise<MarkdownDiff>;
14
214
  }
15
- export type SomaDiffAdapter = SomaDiffPort;
16
215
  export declare function assertDiffAdapter(adapter: unknown): void;
@@ -0,0 +1,80 @@
1
+ import type { DiffFragment, DiffMode, DiffPart, ProseDegraded, ProseDiff, SomaDiffAdapter } from './port';
2
+ export interface ProseConfig {
3
+ readonly nfkc: boolean;
4
+ readonly collapseWhitespace: boolean;
5
+ readonly newline: boolean;
6
+ readonly pairAt: number;
7
+ readonly rewriteBelow: number;
8
+ readonly absorbOrphan: number;
9
+ readonly maxChars: number;
10
+ readonly maxCharsPerCompare: number;
11
+ readonly maxAlignTokens: number;
12
+ readonly maxPairMatrix: number;
13
+ }
14
+ /** 一次计算的共享上下文:时限、退化标记、实际粒度 */
15
+ export interface ProseRun {
16
+ readonly adapter: SomaDiffAdapter;
17
+ readonly deadline: number;
18
+ degraded?: ProseDegraded;
19
+ usedChars: boolean;
20
+ usedZh: boolean;
21
+ }
22
+ export declare const clock: () => number;
23
+ export declare const hasHan: (s: string) => boolean;
24
+ export interface Normalized {
25
+ /** 归一化文本(判等、相似度、词级差异都在它上面算) */
26
+ readonly text: string;
27
+ /** text 的第 i 个码元来自原文第 origin[i] 个码元 */
28
+ readonly origin: readonly number[];
29
+ readonly source: string;
30
+ }
31
+ /** 归一化并记下每个码元的原文下标(显示用原文,判等用归一化文本) */
32
+ export declare function normalizeWithMap(source: string, cfg: Pick<ProseConfig, 'nfkc' | 'collapseWhitespace' | 'newline'>): Normalized;
33
+ /** 字符多重集 Dice(按码点):配对用,便宜、同步 */
34
+ export declare function diceSimilarity(a: string, b: string): number;
35
+ export type AlignOp = {
36
+ readonly op: 'eq';
37
+ readonly a: number;
38
+ readonly b: number;
39
+ } | {
40
+ readonly op: 'del';
41
+ readonly a: number;
42
+ } | {
43
+ readonly op: 'ins';
44
+ readonly b: number;
45
+ };
46
+ /** 两个键序列的 LCS 对齐:每个不同的键映射为一个私用区字符后交适配器 `chars` 粒度。null = 超时或不同键过多 */
47
+ export declare function alignKeys(run: ProseRun, aKeys: readonly string[], bKeys: readonly string[], maxTokens: number): Promise<AlignOp[] | null>;
48
+ /** 适配器调用:带剩余时限;超时 / 抛错 → null(并记退化) */
49
+ export declare function safeDiff(run: ProseRun, a: string, b: string, mode: DiffMode): Promise<readonly DiffPart[] | null>;
50
+ /** 一段删增区间内的单调贪心配对:按相似度从高到低取,且保持两侧顺序 */
51
+ export declare function pairRun(dels: readonly string[], inss: readonly string[], at: number, maxMatrix: number): Map<number, number>;
52
+ /** 对齐结果按「相同 / 删增区间」分组后配对,产出单元级操作序列 */
53
+ export type UnitOp = {
54
+ readonly op: 'eq';
55
+ readonly a: number;
56
+ readonly b: number;
57
+ } | {
58
+ readonly op: 'mod';
59
+ readonly a: number;
60
+ readonly b: number;
61
+ } | {
62
+ readonly op: 'del';
63
+ readonly a: number;
64
+ } | {
65
+ readonly op: 'ins';
66
+ readonly b: number;
67
+ };
68
+ export declare function pairAligned(ops: readonly AlignOp[], aKeys: readonly string[], bKeys: readonly string[], at: number, maxMatrix: number): UnitOp[];
69
+ export declare function splitParagraphs(text: string): string[];
70
+ /** 运行时是否有 `Intl.Segmenter`(无 → 词级退回逐字,摘要条注「按字比较」) */
71
+ export declare function hasSegmenter(): boolean;
72
+ export declare function splitSentences(paragraph: string): string[];
73
+ /** 合并相邻同类片段;每个改动簇内删在前、增在后 */
74
+ export declare function tidy(frags: readonly DiffFragment[]): DiffFragment[];
75
+ /** 孤字吸收:两处改动之间、长度 ≤ max 的非标点相同片段并入两侧改动 */
76
+ export declare function absorbOrphans(frags: readonly DiffFragment[], max: number): DiffFragment[];
77
+ /** 改动簇数(导航「第 i / 共 k 处」的 k) */
78
+ export declare function countChanges(frags: readonly DiffFragment[]): number;
79
+ /** 散文两级差异主入口(输入已校验为字符串) */
80
+ export declare function runProse(run: ProseRun, cfg: ProseConfig, a: string, b: string): Promise<ProseDiff>;
@@ -7,6 +7,9 @@ import type { SomaChartAdapter } from './chart/port';
7
7
  import type { SomaDragAdapter } from './dnd/port';
8
8
  import type { SomaDiffAdapter } from './diff/port';
9
9
  import type { SomaQrAdapter } from './qrcode/port';
10
+ import type { SomaHighlightAdapter } from './highlight/port';
11
+ import type { SomaStructuredAdapter } from './structured/port';
12
+ import type { SomaMarkdownAdapter } from './markdown/port';
10
13
  /** 各引擎端口可替换的适配器;键 = 端口,值 = 该端口 `port.ts` 导出的适配器类型 */
11
14
  export interface SomaEngineAdapters {
12
15
  readonly style: SomaStyleEngine;
@@ -19,5 +22,8 @@ export interface SomaEngineAdapters {
19
22
  readonly dnd: SomaDragAdapter;
20
23
  readonly diff: SomaDiffAdapter;
21
24
  readonly qrcode: SomaQrAdapter;
25
+ readonly highlight: SomaHighlightAdapter;
26
+ readonly structured: SomaStructuredAdapter;
27
+ readonly markdown: SomaMarkdownAdapter;
22
28
  }
23
29
  export type SomaEngineId = keyof SomaEngineAdapters;
@@ -0,0 +1,6 @@
1
+ import { type EngineLoadTelemetry } from '../load';
2
+ import type { SomaHighlightAdapter } from './port';
3
+ export interface LezerAdapterOptions {
4
+ readonly telemetry?: EngineLoadTelemetry;
5
+ }
6
+ export declare function createLezerAdapter(adapterOptions?: LezerAdapterOptions): SomaHighlightAdapter;
@@ -0,0 +1,15 @@
1
+ export type { CodeFallback, CodeHighlightOptions, CodeLanguageHint, CodeLanguageSpec, CodeResult, CodeSpan, CodeToken, CodeTokenKind, SomaHighlightAdapter, SomaHighlightPort, } from './port';
2
+ export { CODE_LANGUAGES, CODE_TOKEN_KINDS, assertHighlightAdapter } from './port';
3
+ import type { EngineLoadTelemetry } from '../load';
4
+ import { type CodeLanguageHint, type CodeSpan, type CodeToken, type SomaHighlightAdapter, type SomaHighlightPort } from './port';
5
+ export interface HighlightPortOptions {
6
+ readonly telemetry?: EngineLoadTelemetry;
7
+ }
8
+ /** 确定性语言推断(纯函数):显式 → 整文件名 → 扩展名 → 围栏信息串 → shebang → 整体可 JSON.parse → text */
9
+ export declare function resolveCodeLanguage(hint: CodeLanguageHint): string;
10
+ /** 记号区间 → 按行的记号数组(区间之间的空隙是 plain;跨行的区间在换行处拆开) */
11
+ export declare function spansToLines(code: string, spans: readonly CodeSpan[], maxLines: number, maxLineLength: number): {
12
+ lines: CodeToken[][];
13
+ plainFrom: number;
14
+ };
15
+ export declare function createHighlightPort(adapter?: SomaHighlightAdapter, options?: HighlightPortOptions): SomaHighlightPort;