soma-core 2.2.8 → 2.2.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/core/build/compiler/full-manifest-builder.ts +1 -1
- package/core/build/compiler/host-config-sync.cjs +1 -1
- package/core/build/compiler/soma-manifest-webpack-plugin.js +2 -6
- package/core/build/compiler/soma-precompile.js +80 -4
- package/core/client/a11y/announcer.ts +2 -16
- package/core/client/base/SomaPageRootBase.ts +2 -2
- package/core/client/base/defineSomaView.ts +11 -2
- package/core/client/base/runtime-services.types.ts +57 -0
- package/core/client/data/role-gate.ts +2 -8
- package/core/client/engine/event-engine.ts +1 -0
- package/core/client/engines/diff/adapter-jsdiff.ts +27 -8
- package/core/client/engines/diff/index.ts +81 -6
- package/core/client/engines/diff/items.ts +212 -0
- package/core/client/engines/diff/port.ts +140 -3
- package/core/client/engines/diff/prose.ts +443 -0
- package/core/client/engines/engine-adapters.ts +6 -0
- package/core/client/engines/highlight/adapter-lezer.ts +109 -0
- package/core/client/engines/highlight/index.ts +135 -0
- package/core/client/engines/highlight/port.ts +92 -0
- package/core/client/engines/markdown/adapter-markdown-it.ts +65 -0
- package/core/client/engines/markdown/blocks.ts +335 -0
- package/core/client/engines/markdown/index.ts +51 -0
- package/core/client/engines/markdown/port.ts +94 -0
- package/core/client/engines/markdown/vendor-modules.d.ts +6 -0
- package/core/client/engines/structured/adapter-js-yaml.ts +33 -0
- package/core/client/engines/structured/index.ts +139 -0
- package/core/client/engines/structured/port.ts +59 -0
- package/core/client/infra/http/SomaHttpService.ts +2 -4
- package/core/client/infra/notify/DefaultNotifyService.ts +2 -3
- package/core/client/infra/permission/SomaPermission.ts +1 -1
- package/core/client/render-ports/notify-renderer.ts +2 -46
- package/core/client/runtime/SomaRuntimeServices.ts +16 -45
- package/core/server/host/app-config-composer.ts +6 -52
- package/core/server/host/host-config-paths.cjs +2 -100
- package/core/server/host/precompiled-manifest.ts +69 -0
- package/core/server/infra/host-config-paths.cjs +100 -0
- package/core/server/page-assets.ts +2 -70
- package/core/server/runtime-space/bindings.ts +33 -4
- package/core/server/runtime-space/store.ts +16 -1
- package/core/shared/app-config-merge.ts +59 -0
- package/core/shared/registry-generated/limits.ts +80 -4
- package/core/shared/types/announcer.types.ts +18 -0
- package/core/shared/types/notify.types.ts +26 -0
- package/core/shared/types/role-gate.types.ts +11 -0
- package/dist/browser/runtime-bundle.manifest.json +50 -7
- package/dist/browser/soma-runtime.js +120741 -104799
- package/dist/core/index.cjs +113807 -97854
- package/dist/host-native/aot-builder.cjs +277 -189
- package/dist/host-native/native-server.cjs +196 -72
- package/dist/lsp/component-tree.cjs +80 -4
- package/dist/types/build/compiler/full-manifest-builder.d.ts +1 -1
- package/dist/types/client/a11y/announcer.d.ts +2 -14
- package/dist/types/client/base/SomaPageRootBase.d.ts +2 -2
- package/dist/types/client/base/runtime-services.types.d.ts +50 -0
- package/dist/types/client/data/role-gate.d.ts +2 -8
- package/dist/types/client/engines/diff/index.d.ts +1 -1
- package/dist/types/client/engines/diff/items.d.ts +24 -0
- package/dist/types/client/engines/diff/port.d.ts +124 -2
- package/dist/types/client/engines/diff/prose.d.ts +80 -0
- package/dist/types/client/engines/engine-adapters.d.ts +6 -0
- package/dist/types/client/engines/highlight/adapter-lezer.d.ts +6 -0
- package/dist/types/client/engines/highlight/index.d.ts +15 -0
- package/dist/types/client/engines/highlight/port.d.ts +64 -0
- package/dist/types/client/engines/markdown/adapter-markdown-it.d.ts +6 -0
- package/dist/types/client/engines/markdown/blocks.d.ts +29 -0
- package/dist/types/client/engines/markdown/index.d.ts +9 -0
- package/dist/types/client/engines/markdown/port.d.ts +166 -0
- package/dist/types/client/engines/structured/adapter-js-yaml.d.ts +6 -0
- package/dist/types/client/engines/structured/index.d.ts +29 -0
- package/dist/types/client/engines/structured/port.d.ts +45 -0
- package/dist/types/client/infra/http/SomaHttpService.d.ts +1 -1
- package/dist/types/client/infra/notify/DefaultNotifyService.d.ts +2 -3
- package/dist/types/client/infra/permission/SomaPermission.d.ts +1 -1
- package/dist/types/client/render-ports/notify-renderer.d.ts +1 -56
- package/dist/types/client/runtime/SomaRuntimeServices.d.ts +9 -44
- package/dist/types/server/host/app-config-composer.d.ts +2 -3
- package/dist/types/server/host/host-config-paths.d.cts +2 -7
- package/dist/types/server/host/precompiled-manifest.d.ts +5 -0
- package/dist/types/server/infra/host-config-paths.d.cts +7 -0
- package/dist/types/server/page-assets.d.ts +2 -5
- package/dist/types/server/runtime-space/store.d.ts +4 -0
- package/dist/types/shared/app-config-merge.d.ts +3 -0
- package/dist/types/shared/registry-generated/limits.d.ts +78 -4
- package/dist/types/shared/types/announcer.types.d.ts +14 -0
- package/dist/types/shared/types/notify.types.d.ts +36 -0
- package/dist/types/shared/types/role-gate.types.d.ts +8 -0
- package/host-native/src/aot-builder.ts +12 -5
- package/host-native/src/dev-chunk-gc.ts +104 -0
- package/host-native/src/host-prepare.ts +1 -1
- package/host-native/src/manifest-http.ts +1 -1
- package/host-native/src/page-http.ts +2 -67
- package/host-native/src/page-payload-cache.ts +68 -0
- 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/
|
|
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/
|
|
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/
|
|
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/
|
|
5622
|
+
"file": "src/domain/ai-shared/TrustedRequestContext.ts",
|
|
5613
5623
|
"symbol": "SOMA_PIPELINE_LIMITS_AI_RUNTIME"
|
|
5614
5624
|
},
|
|
5615
5625
|
{
|
|
@@ -5782,6 +5792,72 @@ 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
|
+
},
|
|
5814
|
+
"maxChars": 2e5,
|
|
5815
|
+
"maxCharsPerCompare": 2e4,
|
|
5816
|
+
"timeoutMs": 1e3,
|
|
5817
|
+
"maxItems": 2e3,
|
|
5818
|
+
"moveDetectMaxChanged": 500,
|
|
5819
|
+
"pairAt": 0.5,
|
|
5820
|
+
"rewriteBelow": 0.4,
|
|
5821
|
+
"absorbOrphan": 1,
|
|
5822
|
+
"absorbOrphanMax": 4,
|
|
5823
|
+
"titleAt": 0.6,
|
|
5824
|
+
"bodyAt": 0.5,
|
|
5825
|
+
"maxAlignTokens": 6400,
|
|
5826
|
+
"maxPairMatrix": 2500,
|
|
5827
|
+
"maxPairCandidates": 25e4
|
|
5828
|
+
},
|
|
5829
|
+
"highlight": {
|
|
5830
|
+
"basis": {
|
|
5831
|
+
"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",
|
|
5832
|
+
"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",
|
|
5833
|
+
"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",
|
|
5834
|
+
"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",
|
|
5835
|
+
"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"
|
|
5836
|
+
},
|
|
5837
|
+
"maxLines": 5e3,
|
|
5838
|
+
"maxLineLength": 2e3,
|
|
5839
|
+
"timeoutMs": 1e3,
|
|
5840
|
+
"maxChars": 1e6,
|
|
5841
|
+
"jsonSniffMaxChars": 2e5
|
|
5842
|
+
},
|
|
5843
|
+
"structured": {
|
|
5844
|
+
"basis": {
|
|
5845
|
+
"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",
|
|
5846
|
+
"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"
|
|
5847
|
+
},
|
|
5848
|
+
"maxChars": 1e6,
|
|
5849
|
+
"maxNodes": 2e5
|
|
5850
|
+
},
|
|
5851
|
+
"markdown": {
|
|
5852
|
+
"basis": {
|
|
5853
|
+
"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",
|
|
5854
|
+
"maxBlocks": "\u5757\u6570\u4E0A\u9650\uFF0C\u8D85\u51FA\u622A\u65AD\u5E76\u6807 truncated\uFF08\u7B14\u8BB0 C.2 maxBlocks 5 000\uFF09",
|
|
5855
|
+
"summaryChars": "meta.summary \u53D6\u53BB\u6807\u8BB0\u5168\u6587\u7684\u524D N \u5B57\uFF08\u7B14\u8BB0 C.2\u300C\u524D 80 \u5B57\u300D\uFF09"
|
|
5856
|
+
},
|
|
5857
|
+
"maxChars": 2e5,
|
|
5858
|
+
"maxBlocks": 5e3,
|
|
5859
|
+
"summaryChars": 80
|
|
5860
|
+
}
|
|
5785
5861
|
}
|
|
5786
5862
|
};
|
|
5787
5863
|
|
|
@@ -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 '../../
|
|
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
|
-
|
|
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 {
|
|
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?:
|
|
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
|
-
|
|
2
|
-
export
|
|
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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { DiffMode, DiffOptions, DiffPart, SomaDiffAdapter, SomaDiffPort } from './port';
|
|
1
|
+
export type { 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
3
|
import type { EngineLoadTelemetry } from '../load';
|
|
4
4
|
import { type SomaDiffAdapter, type SomaDiffPort } from './port';
|
|
@@ -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
|
-
|
|
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,130 @@ 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';
|
|
11
129
|
}
|
|
12
130
|
export interface SomaDiffPort {
|
|
131
|
+
/** 两段字符串按粒度求片段(超时退回整段替换,不抛错) */
|
|
13
132
|
diff(a: string, b: string, mode: DiffMode, options?: DiffOptions): Promise<readonly DiffPart[]>;
|
|
133
|
+
/** 散文两级差异(段 → 句 → 词);中文默认按词(Intl.Segmenter),无分词器时按字并标 degraded */
|
|
134
|
+
diffProse(a: string, b: string, options?: ProseDiffOptions): Promise<ProseDiff>;
|
|
135
|
+
/** 条目列表差异:key 或内容配对、字段差异、LIS 最少移动 */
|
|
136
|
+
diffItems(before: readonly unknown[], after: readonly unknown[], options?: ItemDiffOptions): Promise<ItemDiff>;
|
|
14
137
|
}
|
|
15
|
-
export type SomaDiffAdapter = SomaDiffPort;
|
|
16
138
|
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;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** 记号种类闭集(14 种) */
|
|
2
|
+
export declare const CODE_TOKEN_KINDS: readonly ["plain", "comment", "keyword", "string", "number", "constant", "function", "type", "variable", "property", "operator", "punctuation", "tag", "attribute"];
|
|
3
|
+
export type CodeTokenKind = (typeof CODE_TOKEN_KINDS)[number];
|
|
4
|
+
/** 语言闭集:规范 id → 别名 / 扩展名 / 整文件名(`resolveLanguage` 只做确定性推断,不猜内容) */
|
|
5
|
+
export interface CodeLanguageSpec {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly aliases: readonly string[];
|
|
9
|
+
readonly extensions: readonly string[];
|
|
10
|
+
readonly filenames: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
export declare const CODE_LANGUAGES: readonly CodeLanguageSpec[];
|
|
13
|
+
export interface CodeLanguageHint {
|
|
14
|
+
readonly language?: string;
|
|
15
|
+
readonly filename?: string;
|
|
16
|
+
/** Markdown 围栏信息串(如 ```ts title=a.ts) */
|
|
17
|
+
readonly fence?: string;
|
|
18
|
+
/** 第一行(只认 shebang) */
|
|
19
|
+
readonly firstLine?: string;
|
|
20
|
+
/** 全文(只用于「整体能 JSON.parse」这一条确定性推断) */
|
|
21
|
+
readonly sample?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface CodeHighlightOptions {
|
|
24
|
+
/** 缺省取 design `limits.json#contentEngines.highlight`;调用方只能更小 */
|
|
25
|
+
readonly maxLines?: number;
|
|
26
|
+
readonly maxLineLength?: number;
|
|
27
|
+
readonly timeoutMs?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface CodeToken {
|
|
30
|
+
readonly text: string;
|
|
31
|
+
readonly kind: CodeTokenKind;
|
|
32
|
+
}
|
|
33
|
+
export type CodeFallback = 'unknown-language' | 'too-large' | 'timeout' | 'engine-load-failed';
|
|
34
|
+
export interface CodeResult {
|
|
35
|
+
/** 实际使用的语言(未知时 'text') */
|
|
36
|
+
readonly language: string;
|
|
37
|
+
/** 第一维是行;每行是记号数组(拼起来 = 该行原文,不含换行) */
|
|
38
|
+
readonly lines: readonly (readonly CodeToken[])[];
|
|
39
|
+
/** 被截断成纯文本的起始行号(0 起;超过 maxLines 的行);没有截断为 -1 */
|
|
40
|
+
readonly plainFrom: number;
|
|
41
|
+
readonly fallback?: CodeFallback;
|
|
42
|
+
}
|
|
43
|
+
/** 适配器:把一段代码切成「起止 + 种类」的记号区间;语言不支持返回 'unsupported',超时返回 'timeout' */
|
|
44
|
+
export interface CodeSpan {
|
|
45
|
+
readonly from: number;
|
|
46
|
+
readonly to: number;
|
|
47
|
+
readonly kind: CodeTokenKind;
|
|
48
|
+
}
|
|
49
|
+
export interface SomaHighlightAdapter {
|
|
50
|
+
/** 适配器能高亮的规范语言 id(`text` 不在其中) */
|
|
51
|
+
languages(): readonly string[];
|
|
52
|
+
tokenize(code: string, language: string, options: {
|
|
53
|
+
readonly deadline: number;
|
|
54
|
+
}): Promise<readonly CodeSpan[] | 'unsupported' | 'timeout'>;
|
|
55
|
+
}
|
|
56
|
+
export interface SomaHighlightPort {
|
|
57
|
+
/** 显式 language → 整文件名 → 扩展名 → 围栏信息串 → shebang → 整体可 JSON.parse → 'text';纯函数、同步 */
|
|
58
|
+
resolveLanguage(hint: CodeLanguageHint): string;
|
|
59
|
+
highlight(code: string, language: string, options?: CodeHighlightOptions): Promise<CodeResult>;
|
|
60
|
+
supportedLanguages(): readonly string[];
|
|
61
|
+
/** 规范 id → 显示名(未知 id 原样返回) */
|
|
62
|
+
languageLabel(id: string): string;
|
|
63
|
+
}
|
|
64
|
+
export declare function assertHighlightAdapter(adapter: unknown): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type EngineLoadTelemetry } from '../load';
|
|
2
|
+
import type { SomaMarkdownAdapter } from './port';
|
|
3
|
+
export interface MarkdownItAdapterOptions {
|
|
4
|
+
readonly telemetry?: EngineLoadTelemetry;
|
|
5
|
+
}
|
|
6
|
+
export declare function createMarkdownItAdapter(options?: MarkdownItAdapterOptions): SomaMarkdownAdapter;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { MdBlock, MdInline, MdMeta, MdToken } from './port';
|
|
2
|
+
/** 链接地址:http / https / mailto / tel、站内路径(/…)、锚点(#…)、无协议的相对地址;其余(javascript: / data: / vbscript: …)拒绝 → '' */
|
|
3
|
+
export declare function safeMdHref(raw: string): string;
|
|
4
|
+
/** 图片地址:http / https、站内路径、data:image/(png|jpeg|gif|webp);base64;其余拒绝 → '' */
|
|
5
|
+
export declare function safeMdImage(raw: string): string;
|
|
6
|
+
export declare function softBreakJoiner(before: string, after: string): string;
|
|
7
|
+
export declare function mdSlug(text: string): string;
|
|
8
|
+
interface Ctx {
|
|
9
|
+
html: number;
|
|
10
|
+
unsafeUrls: number;
|
|
11
|
+
images: number;
|
|
12
|
+
links: number;
|
|
13
|
+
fnIndex: Map<string, number>;
|
|
14
|
+
ids: Map<string, number>;
|
|
15
|
+
}
|
|
16
|
+
/** 行内令牌 → 行内节点(容器令牌按 nesting 配对) */
|
|
17
|
+
export declare function inlineOf(tokens: readonly MdToken[], ctx: Ctx): MdInline[];
|
|
18
|
+
export declare function inlineText(nodes: readonly MdInline[]): string;
|
|
19
|
+
export interface MdBuild {
|
|
20
|
+
blocks: MdBlock[];
|
|
21
|
+
meta: MdMeta;
|
|
22
|
+
}
|
|
23
|
+
/** 令牌流 → 块树 + 元信息 */
|
|
24
|
+
export declare function buildMarkdown(tokens: readonly MdToken[], source: string, limits: {
|
|
25
|
+
readonly maxBlocks: number;
|
|
26
|
+
readonly summaryChars: number;
|
|
27
|
+
}): MdBuild;
|
|
28
|
+
export declare function plainOf(blocks: readonly MdBlock[]): string;
|
|
29
|
+
export {};
|