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
|
@@ -17,7 +17,7 @@ import type { TreeArtifact } from '../../shared/types/component-tree-artifact.ty
|
|
|
17
17
|
import {
|
|
18
18
|
mergeSourcePackageAppConfig,
|
|
19
19
|
parseAppConfigYaml,
|
|
20
|
-
} from '../../
|
|
20
|
+
} from '../../shared/app-config-merge';
|
|
21
21
|
|
|
22
22
|
export interface SomaPrecompiledPage {
|
|
23
23
|
path: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** HOST 配置同步 — 供 bin/soma-sync.cjs 使用 */
|
|
2
2
|
const fs = require('node:fs');
|
|
3
3
|
const path = require('node:path');
|
|
4
|
-
const { resolveHostConfigRoot } = require('../../server/
|
|
4
|
+
const { resolveHostConfigRoot } = require('../../server/infra/host-config-paths.cjs');
|
|
5
5
|
|
|
6
6
|
const SYNC_FILES = [
|
|
7
7
|
'locale.yaml',
|
|
@@ -12,12 +12,7 @@ const createJiti = require('jiti');
|
|
|
12
12
|
const {
|
|
13
13
|
resolveAppConfigPath,
|
|
14
14
|
resolveHostAppConfigPath,
|
|
15
|
-
} = require('../../server/
|
|
16
|
-
const {
|
|
17
|
-
getSomaAssetSources,
|
|
18
|
-
collectPageEntries,
|
|
19
|
-
collectIncludes,
|
|
20
|
-
} = require('../../server/host/source-packages.cjs');
|
|
15
|
+
} = require('../../server/infra/host-config-paths.cjs');
|
|
21
16
|
|
|
22
17
|
function readFileOrEmpty(filePath) {
|
|
23
18
|
return fs.existsSync(filePath) ? fs.readFileSync(filePath, 'utf8') : '';
|
|
@@ -81,6 +76,7 @@ class SomaManifestWebpackPlugin {
|
|
|
81
76
|
const { loadPageMarkupConfig } = this.jiti('../../server/host/page-markup-config.ts');
|
|
82
77
|
const { resolveHostTreeCompileContext } = this.jiti('../../server/host/resolve-host-tree-context.ts');
|
|
83
78
|
const { runPrewarm, computePrewarmInputsDigest } = this.jiti('../../server/runtime-space/prewarm.ts');
|
|
79
|
+
const { getSomaAssetSources, collectPageEntries, collectIncludes } = this.jiti('../../server/host/source-packages.cjs');
|
|
84
80
|
|
|
85
81
|
const sources = getSomaAssetSources(hostDir);
|
|
86
82
|
const pageEntries = collectPageEntries(sources);
|
|
@@ -6218,6 +6218,16 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
6218
6218
|
"file": "core/server/registry/api-registry-store.ts",
|
|
6219
6219
|
"symbol": "SOMA_PIPELINE_LIMITS"
|
|
6220
6220
|
},
|
|
6221
|
+
{
|
|
6222
|
+
"module": "soma-core",
|
|
6223
|
+
"file": "core/client/engines/diff/index.ts",
|
|
6224
|
+
"symbol": "SOMA_PIPELINE_LIMITS"
|
|
6225
|
+
},
|
|
6226
|
+
{
|
|
6227
|
+
"module": "soma-core",
|
|
6228
|
+
"file": "core/client/engines/highlight/index.ts",
|
|
6229
|
+
"symbol": "SOMA_PIPELINE_LIMITS"
|
|
6230
|
+
},
|
|
6221
6231
|
{
|
|
6222
6232
|
"module": "soma-core",
|
|
6223
6233
|
"file": "core/server/registry/page-registry-store.ts",
|
|
@@ -6520,17 +6530,17 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
6520
6530
|
},
|
|
6521
6531
|
{
|
|
6522
6532
|
"module": "soma-ai",
|
|
6523
|
-
"file": "src/
|
|
6533
|
+
"file": "src/server/common/RateLimitBackend.ts",
|
|
6524
6534
|
"symbol": "SOMA_PIPELINE_LIMITS_AI"
|
|
6525
6535
|
},
|
|
6526
6536
|
{
|
|
6527
6537
|
"module": "soma-ai",
|
|
6528
|
-
"file": "src/
|
|
6538
|
+
"file": "src/server/common/RequestBodyLimit.ts",
|
|
6529
6539
|
"symbol": "SOMA_PIPELINE_LIMITS_AI"
|
|
6530
6540
|
},
|
|
6531
6541
|
{
|
|
6532
6542
|
"module": "soma-ai",
|
|
6533
|
-
"file": "src/
|
|
6543
|
+
"file": "src/server/services/ai-assistant/Chat.ts",
|
|
6534
6544
|
"symbol": "SOMA_PIPELINE_LIMITS_AI"
|
|
6535
6545
|
},
|
|
6536
6546
|
{
|
|
@@ -6545,7 +6555,7 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
6545
6555
|
},
|
|
6546
6556
|
{
|
|
6547
6557
|
"module": "soma-ai",
|
|
6548
|
-
"file": "src/
|
|
6558
|
+
"file": "src/domain/ai-shared/TrustedRequestContext.ts",
|
|
6549
6559
|
"symbol": "SOMA_PIPELINE_LIMITS_AI_RUNTIME"
|
|
6550
6560
|
},
|
|
6551
6561
|
{
|
|
@@ -6718,6 +6728,72 @@ var SOMA_PIPELINE_LIMITS = {
|
|
|
6718
6728
|
"tokensBytes": 40960,
|
|
6719
6729
|
"componentBytesPerPage": 163840,
|
|
6720
6730
|
"overrideBlockBytes": 8192
|
|
6731
|
+
},
|
|
6732
|
+
"contentEngines": {
|
|
6733
|
+
"diff": {
|
|
6734
|
+
"basis": {
|
|
6735
|
+
"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",
|
|
6736
|
+
"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",
|
|
6737
|
+
"timeoutMs": "\u4E00\u6B21 diffProse / diffItems \u7684\u603B\u65F6\u9650\uFF08\u6BEB\u79D2\uFF09\uFF0C\u540C VisualEditor timeout 1000\uFF08\u7B14\u8BB0 C.2\uFF09",
|
|
6738
|
+
"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",
|
|
6739
|
+
"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",
|
|
6740
|
+
"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",
|
|
6741
|
+
"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",
|
|
6742
|
+
"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",
|
|
6743
|
+
"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",
|
|
6744
|
+
"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",
|
|
6745
|
+
"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",
|
|
6746
|
+
"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",
|
|
6747
|
+
"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",
|
|
6748
|
+
"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"
|
|
6749
|
+
},
|
|
6750
|
+
"maxChars": 2e5,
|
|
6751
|
+
"maxCharsPerCompare": 2e4,
|
|
6752
|
+
"timeoutMs": 1e3,
|
|
6753
|
+
"maxItems": 2e3,
|
|
6754
|
+
"moveDetectMaxChanged": 500,
|
|
6755
|
+
"pairAt": 0.5,
|
|
6756
|
+
"rewriteBelow": 0.4,
|
|
6757
|
+
"absorbOrphan": 1,
|
|
6758
|
+
"absorbOrphanMax": 4,
|
|
6759
|
+
"titleAt": 0.6,
|
|
6760
|
+
"bodyAt": 0.5,
|
|
6761
|
+
"maxAlignTokens": 6400,
|
|
6762
|
+
"maxPairMatrix": 2500,
|
|
6763
|
+
"maxPairCandidates": 25e4
|
|
6764
|
+
},
|
|
6765
|
+
"highlight": {
|
|
6766
|
+
"basis": {
|
|
6767
|
+
"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",
|
|
6768
|
+
"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",
|
|
6769
|
+
"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",
|
|
6770
|
+
"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",
|
|
6771
|
+
"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"
|
|
6772
|
+
},
|
|
6773
|
+
"maxLines": 5e3,
|
|
6774
|
+
"maxLineLength": 2e3,
|
|
6775
|
+
"timeoutMs": 1e3,
|
|
6776
|
+
"maxChars": 1e6,
|
|
6777
|
+
"jsonSniffMaxChars": 2e5
|
|
6778
|
+
},
|
|
6779
|
+
"structured": {
|
|
6780
|
+
"basis": {
|
|
6781
|
+
"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",
|
|
6782
|
+
"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"
|
|
6783
|
+
},
|
|
6784
|
+
"maxChars": 1e6,
|
|
6785
|
+
"maxNodes": 2e5
|
|
6786
|
+
},
|
|
6787
|
+
"markdown": {
|
|
6788
|
+
"basis": {
|
|
6789
|
+
"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",
|
|
6790
|
+
"maxBlocks": "\u5757\u6570\u4E0A\u9650\uFF0C\u8D85\u51FA\u622A\u65AD\u5E76\u6807 truncated\uFF08\u7B14\u8BB0 C.2 maxBlocks 5 000\uFF09",
|
|
6791
|
+
"summaryChars": "meta.summary \u53D6\u53BB\u6807\u8BB0\u5168\u6587\u7684\u524D N \u5B57\uFF08\u7B14\u8BB0 C.2\u300C\u524D 80 \u5B57\u300D\uFF09"
|
|
6792
|
+
},
|
|
6793
|
+
"maxChars": 2e5,
|
|
6794
|
+
"maxBlocks": 5e3,
|
|
6795
|
+
"summaryChars": 80
|
|
6796
|
+
}
|
|
6721
6797
|
}
|
|
6722
6798
|
};
|
|
6723
6799
|
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
// core 只用 CSSOM `style.setProperty` 写,不持有任何几何值;缺省则不写样式,由 UI 体系按 `data-soma-announcer-host` 选择器隐藏。
|
|
12
12
|
// 去重 / 节流:design 真源没有规则,不做。
|
|
13
13
|
import { SOMA_PLATFORM_KEYS_CORE } from '../../shared/registry-generated/platform-keys';
|
|
14
|
+
import type { AnnounceOptions, AnnouncePoliteness, Announcer } from '../../shared/types/announcer.types';
|
|
14
15
|
|
|
15
|
-
export type
|
|
16
|
+
export type { AnnounceOptions, AnnouncePoliteness, Announcer };
|
|
16
17
|
|
|
17
18
|
/** politeness 闭集;宿主也按这个顺序创建 */
|
|
18
19
|
export const ANNOUNCE_POLITENESS: readonly AnnouncePoliteness[] = ['polite', 'assertive'];
|
|
@@ -41,21 +42,6 @@ export interface AnnouncerOptions {
|
|
|
41
42
|
readonly clock?: AnnouncerClock;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
export interface AnnounceOptions {
|
|
45
|
-
readonly politeness?: AnnouncePoliteness;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface Announcer {
|
|
49
|
-
/** 追加一条播报;空消息忽略;politeness 缺省 polite,未知值抛 TypeError */
|
|
50
|
-
announce(message: string, options?: AnnounceOptions): void;
|
|
51
|
-
/** 两个常驻宿主 */
|
|
52
|
-
hosts(): Readonly<Record<AnnouncePoliteness, HTMLElement>>;
|
|
53
|
-
/** 立即移除全部待清理节点 */
|
|
54
|
-
clear(): void;
|
|
55
|
-
/** 清空、取消计时并移除宿主;之后 announce 忽略 */
|
|
56
|
-
dispose(): void;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
45
|
/**
|
|
60
46
|
* 读 design `announcer.clearAfterMs`;真源(生成物)目前没有 `announcer` 族,缺该键时为 undefined。
|
|
61
47
|
* 按未知形状守卫读取,不再强转成生成物类型里并不存在的字段。
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import type { SomaPageRoot, SomaAppConfig } from '../../shared/types/domain.types';
|
|
5
5
|
import type { SomaPageState, SomaPageStateConfig } from '../../shared/types/page-state.types';
|
|
6
|
-
import type {
|
|
6
|
+
import type { SomaRuntimeServicesShape } from './runtime-services.types';
|
|
7
7
|
import type { SomaPageNav } from '../../shared/types/nav.types';
|
|
8
8
|
import { readQueryParam } from '../infra/router/router-path';
|
|
9
9
|
import { runAsync as runAsyncUtil } from './runAsync';
|
|
@@ -39,7 +39,7 @@ export abstract class SomaPageRootBase implements SomaPageRoot {
|
|
|
39
39
|
_config: SomaAppConfig = {} as SomaAppConfig;
|
|
40
40
|
|
|
41
41
|
/** 由引擎注入的运行时基础设施(router / http / notify 等) */
|
|
42
|
-
_services?:
|
|
42
|
+
_services?: SomaRuntimeServicesShape;
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* 导航目录的只读视图(E4 / R-15):`services.nav.entries()` 与 `activeOf()` 的当前快照,外壳(顶栏、框架菜单)绑定
|
|
@@ -84,6 +84,11 @@ function reservedMemberNames(): ReadonlySet<string> {
|
|
|
84
84
|
return names;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/** 判断对象是否持有页面根的 _viewContext 钩子(避免把行作用域数据误认成页面根) */
|
|
88
|
+
function isViewRoot(value: unknown): value is { _viewContext(): SomaViewContextHandle } {
|
|
89
|
+
return value !== null && typeof value === 'object' && typeof (value as { _viewContext?: unknown })._viewContext === 'function';
|
|
90
|
+
}
|
|
91
|
+
|
|
87
92
|
/** 取页面根(原始实例或响应式代理)上的 ctx */
|
|
88
93
|
function ctxOf(view: unknown): SomaViewContext {
|
|
89
94
|
return (view as { _viewContext(): SomaViewContextHandle })._viewContext().ctx;
|
|
@@ -163,9 +168,13 @@ export function defineSomaView<
|
|
|
163
168
|
Object.defineProperty(cls, 'name', { value: name });
|
|
164
169
|
for (const key of methodNames) {
|
|
165
170
|
const fn = methods[key]!;
|
|
166
|
-
// core 的 `UI_REFRESH | page.方法`
|
|
171
|
+
// core 的 `UI_REFRESH | page.方法` 或 `ACTION | 方法` 绑定页面根为 this;
|
|
172
|
+
// 行作用域内事件引擎第一实参会传入行数据而非页面根,优先取带 _viewContext 的 this(退回第一实参以兼容显式 unbound 调用)
|
|
167
173
|
Object.defineProperty(cls.prototype, key, {
|
|
168
|
-
value: function (this: unknown, view: unknown, payload: unknown): unknown {
|
|
174
|
+
value: function (this: unknown, view: unknown, payload: unknown): unknown {
|
|
175
|
+
const v = isViewRoot(this) ? this : (isViewRoot(view) ? view : (view ?? this));
|
|
176
|
+
return fn(v, payload, ctxOf(v));
|
|
177
|
+
},
|
|
169
178
|
writable: true,
|
|
170
179
|
configurable: true,
|
|
171
180
|
enumerable: false,
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// 运行时基础设施服务表形状类型(CORE-L01:放在 client/base 基础支撑层,供同层 SomaPageRootBase 引用,
|
|
2
|
+
// 既不反向依赖 client/runtime/SomaRuntimeServices.ts,也不违反 KI-8 对 core/shared 的隔离规则;
|
|
3
|
+
// 完整服务表在 client/runtime/SomaRuntimeServices.ts 继承并补齐领域引擎端口与返回栈类型)。
|
|
4
|
+
|
|
5
|
+
import type { TokenAuthService } from '../infra/auth/TokenAuthService';
|
|
6
|
+
import type { MemoryCache } from '../infra/cache/MemoryCache';
|
|
7
|
+
import type { SomaConfig } from '../infra/config/SomaConfig';
|
|
8
|
+
import type { SomaAppConfigPort } from '../infra/config/feature-flags';
|
|
9
|
+
import type { SomaEventBus } from '../infra/event-bus/SomaEventBus';
|
|
10
|
+
import type { SomaHttpService } from '../infra/http/SomaHttpService';
|
|
11
|
+
import type { SomaLocaleCatalog } from '../infra/i18n/locale-catalog';
|
|
12
|
+
import type { SomaIdentityPort } from '../infra/identity/identity-port';
|
|
13
|
+
import type { ConsoleLogger } from '../infra/logger/ConsoleLogger';
|
|
14
|
+
import type { DefaultNotifyService } from '../infra/notify/DefaultNotifyService';
|
|
15
|
+
import type { SomaPermission } from '../infra/permission/SomaPermission';
|
|
16
|
+
import type { IRealtimeService } from '../infra/realtime/IRealtimeService';
|
|
17
|
+
import type { SomaRouter } from '../infra/router/SomaRouter';
|
|
18
|
+
import type { IStorageService } from '../infra/storage/IStorageService';
|
|
19
|
+
import type { SomaTimer } from '../infra/timer/SomaTimer';
|
|
20
|
+
import type { SomaObservationChannel } from '../observability/runtime-observer';
|
|
21
|
+
import type { SomaRuntimeServicesBase } from '../../shared/types/domain.types';
|
|
22
|
+
import type { SomaNavPort } from '../../shared/types/nav.types';
|
|
23
|
+
import type { SomaShortcutRegistry } from '../../shared/types/write-runtime.types';
|
|
24
|
+
|
|
25
|
+
/** 界面中途提交服务(见 SomaRuntimeServices.ui) */
|
|
26
|
+
export interface SomaUiService {
|
|
27
|
+
publish(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 运行时基础设施形状契约(`SomaPageRootBase._services` 与 `SomaRuntimeServices` 共用)。
|
|
32
|
+
* `engines` 与 `navHistory` 为领域层具体类型,在此以泛型槽位留口,避免基础层反向依赖领域层。
|
|
33
|
+
*/
|
|
34
|
+
export interface SomaRuntimeServicesShape<TEngines = unknown, TNavHistory = unknown>
|
|
35
|
+
extends SomaRuntimeServicesBase {
|
|
36
|
+
router: SomaRouter;
|
|
37
|
+
notify: DefaultNotifyService;
|
|
38
|
+
logger: ConsoleLogger;
|
|
39
|
+
http: SomaHttpService;
|
|
40
|
+
storage: IStorageService;
|
|
41
|
+
timer: SomaTimer;
|
|
42
|
+
eventBus: SomaEventBus;
|
|
43
|
+
cache: MemoryCache<unknown>;
|
|
44
|
+
config: SomaConfig;
|
|
45
|
+
auth: TokenAuthService;
|
|
46
|
+
permission: SomaPermission;
|
|
47
|
+
i18n: SomaLocaleCatalog;
|
|
48
|
+
realtime: IRealtimeService;
|
|
49
|
+
ui: SomaUiService;
|
|
50
|
+
observation: SomaObservationChannel;
|
|
51
|
+
readonly engines: TEngines;
|
|
52
|
+
nav?: SomaNavPort;
|
|
53
|
+
readonly identity: SomaIdentityPort;
|
|
54
|
+
readonly navHistory?: TNavHistory;
|
|
55
|
+
readonly appConfig?: SomaAppConfigPort;
|
|
56
|
+
readonly shortcuts?: SomaShortcutRegistry;
|
|
57
|
+
}
|
|
@@ -9,15 +9,9 @@
|
|
|
9
9
|
// - 角色值只在函数内比较,不写入 DOM、诊断、观测或控制台;
|
|
10
10
|
// - 请求不附带任何 core 生成的身份字段(这里不碰 http)。
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
export interface SomaAuthOption {
|
|
14
|
-
getRoles(): readonly string[];
|
|
15
|
-
}
|
|
12
|
+
import type { SomaAuthOption, SomaRoleGate } from '../../shared/types/role-gate.types';
|
|
16
13
|
|
|
17
|
-
export
|
|
18
|
-
/** 当前角色集与 `required` 有交集才为真 */
|
|
19
|
-
hasAnyRole(required: readonly string[]): boolean;
|
|
20
|
-
}
|
|
14
|
+
export type { SomaAuthOption, SomaRoleGate };
|
|
21
15
|
|
|
22
16
|
function readRoles(auth: SomaAuthOption | undefined): ReadonlySet<string> {
|
|
23
17
|
if (auth === undefined || typeof auth.getRoles !== 'function') return new Set();
|
|
@@ -388,6 +388,7 @@ export class SomaEventEngine<TContext extends Record<string, unknown> = Record<s
|
|
|
388
388
|
runtime.status = 'error';
|
|
389
389
|
runtime.message = error instanceof Error ? error.message : String(error);
|
|
390
390
|
result = false;
|
|
391
|
+
console.error(`[soma-core][引擎] ${config.somaId}.${config.domEvent} (${config.funcPath}) 执行失败:${runtime.message}`);
|
|
391
392
|
} finally {
|
|
392
393
|
if (rowContext instanceof SomaRowScope) this.pendingRows.delete(element);
|
|
393
394
|
else this.pendingSet.delete(config.somaId);
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
// jsdiff 缺省适配器(core 引擎端口设计 §7.2):全仓唯一 import `diff` 的文件,只用动态 import()。
|
|
2
2
|
// 输出纯数据片段;不拼标记 HTML。
|
|
3
|
+
// `words-zh`:`diffWords` + `intlSegmenter`(jsdiff ≥ 8.0.4 才可靠,仓库固定 8.0.4);运行时没有 `Intl.Segmenter` 时退回 `diffChars`。
|
|
4
|
+
// `timeout`:交给 jsdiff,超时库返回 undefined → 本适配器返回 null(端口据此退化)。
|
|
3
5
|
|
|
4
6
|
import { loadEngineModule, type EngineLoadTelemetry } from '../load';
|
|
5
7
|
import type { DiffMode, DiffOptions, DiffPart, SomaDiffAdapter } from './port';
|
|
6
8
|
|
|
7
9
|
interface JsdiffChange { readonly value: string; readonly added?: boolean; readonly removed?: boolean }
|
|
10
|
+
interface JsdiffBaseOptions { timeout?: number }
|
|
8
11
|
interface JsdiffModule {
|
|
9
|
-
diffChars(a: string, b: string): JsdiffChange[];
|
|
10
|
-
diffWords(a: string, b: string): JsdiffChange[];
|
|
11
|
-
diffLines(a: string, b: string, options?: { ignoreWhitespace?: boolean }): JsdiffChange[];
|
|
12
|
+
diffChars(a: string, b: string, options?: JsdiffBaseOptions): JsdiffChange[] | undefined;
|
|
13
|
+
diffWords(a: string, b: string, options?: JsdiffBaseOptions & { intlSegmenter?: unknown }): JsdiffChange[] | undefined;
|
|
14
|
+
diffLines(a: string, b: string, options?: JsdiffBaseOptions & { ignoreWhitespace?: boolean }): JsdiffChange[] | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface SegmenterCtor { new (locale: string, options: { granularity: 'word' }): unknown }
|
|
18
|
+
|
|
19
|
+
/** 运行时的 `Intl.Segmenter`(没有则 null);词粒度分词器只建一次 */
|
|
20
|
+
let wordSegmenter: unknown;
|
|
21
|
+
function zhWordSegmenter(): unknown {
|
|
22
|
+
if (wordSegmenter !== undefined) return wordSegmenter;
|
|
23
|
+
const ctor = (Intl as unknown as { Segmenter?: SegmenterCtor }).Segmenter;
|
|
24
|
+
wordSegmenter = typeof ctor === 'function' ? new ctor('zh', { granularity: 'word' }) : null;
|
|
25
|
+
return wordSegmenter;
|
|
12
26
|
}
|
|
13
27
|
|
|
14
28
|
export interface JsdiffAdapterOptions { readonly telemetry?: EngineLoadTelemetry }
|
|
@@ -18,12 +32,17 @@ export function createJsdiffAdapter(adapterOptions: JsdiffAdapterOptions = {}):
|
|
|
18
32
|
loadEngineModule<JsdiffModule>('diff', () => import('diff') as unknown as Promise<JsdiffModule>, { telemetry: adapterOptions.telemetry });
|
|
19
33
|
|
|
20
34
|
return {
|
|
21
|
-
async diff(a: string, b: string, mode: DiffMode, options?: DiffOptions): Promise<readonly DiffPart[]> {
|
|
35
|
+
async diff(a: string, b: string, mode: DiffMode, options?: DiffOptions): Promise<readonly DiffPart[] | null> {
|
|
22
36
|
const lib = await load();
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
37
|
+
const base: JsdiffBaseOptions = options?.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {};
|
|
38
|
+
let changes: JsdiffChange[] | undefined;
|
|
39
|
+
if (mode === 'chars') changes = lib.diffChars(a, b, base);
|
|
40
|
+
else if (mode === 'words') changes = lib.diffWords(a, b, base);
|
|
41
|
+
else if (mode === 'words-zh') {
|
|
42
|
+
const seg = zhWordSegmenter();
|
|
43
|
+
changes = seg === null ? lib.diffChars(a, b, base) : lib.diffWords(a, b, { ...base, intlSegmenter: seg });
|
|
44
|
+
} else changes = lib.diffLines(a, b, options?.ignoreWhitespace === true ? { ...base, ignoreWhitespace: true } : base);
|
|
45
|
+
if (changes === undefined) return null;
|
|
27
46
|
const parts: DiffPart[] = [];
|
|
28
47
|
for (const change of changes) {
|
|
29
48
|
if (change.value === '') continue;
|
|
@@ -1,20 +1,70 @@
|
|
|
1
|
-
// exports `./diff`:文本差异端口。`createDiffPort(adapter?)`:缺省 jsdiff 适配器(动态加载);
|
|
2
|
-
//
|
|
3
|
-
|
|
1
|
+
// exports `./diff`:文本差异端口。`createDiffPort(adapter?, options?)`:缺省 jsdiff 适配器(动态加载);
|
|
2
|
+
// 输入校验(类型、粒度、上限)与散文 / 条目流水线在这里,换适配器也一样受约束。
|
|
3
|
+
// 上限与阈值的缺省只读 design(`limits.json#contentEngines.diff`);调用方给的时限 / 字数只能比缺省更小。
|
|
4
|
+
export type {
|
|
5
|
+
DiffFragment, DiffMode, DiffOptions, DiffPart, ItemDiff, ItemDiffEntry, ItemDiffOptions, ItemFieldDiff, ItemFieldSpec, ItemFieldType,
|
|
6
|
+
ItemState, ProseBlock, ProseDegraded, ProseDiff, ProseDiffOptions, ProseNormalizeOptions, SomaDiffAdapter, SomaDiffPort,
|
|
7
|
+
} from './port';
|
|
4
8
|
export { assertDiffAdapter } from './port';
|
|
5
9
|
|
|
6
10
|
import { SomaEngineError } from '../../../shared/engines/engine-error';
|
|
11
|
+
import { SOMA_PIPELINE_LIMITS } from '../../../shared/registry-generated/limits';
|
|
7
12
|
import type { EngineLoadTelemetry } from '../load';
|
|
8
13
|
import { createJsdiffAdapter } from './adapter-jsdiff';
|
|
9
|
-
import {
|
|
14
|
+
import { runItems, type ItemsConfig } from './items';
|
|
15
|
+
import {
|
|
16
|
+
assertDiffAdapter, type DiffMode, type DiffOptions, type DiffPart, type ItemDiff, type ItemDiffOptions, type ProseDiff,
|
|
17
|
+
type ProseDiffOptions, type SomaDiffAdapter, type SomaDiffPort,
|
|
18
|
+
} from './port';
|
|
19
|
+
import { clock, runProse, type ProseRun } from './prose';
|
|
10
20
|
|
|
11
21
|
export interface DiffPortOptions { readonly telemetry?: EngineLoadTelemetry }
|
|
12
22
|
|
|
13
|
-
const MODES: readonly DiffMode[] = ['chars', 'words', 'lines'];
|
|
23
|
+
const MODES: readonly DiffMode[] = ['chars', 'words', 'lines', 'words-zh'];
|
|
24
|
+
const LIMITS = SOMA_PIPELINE_LIMITS.contentEngines.diff;
|
|
25
|
+
|
|
26
|
+
const ratioOr = (v: unknown, fallback: number): number => (typeof v === 'number' && Number.isFinite(v) && v >= 0 && v <= 1 ? v : fallback);
|
|
27
|
+
/** 调用方的上限只能收紧:取 min(调用方, design) */
|
|
28
|
+
const capOr = (v: unknown, ceiling: number): number => (typeof v === 'number' && Number.isFinite(v) && v > 0 ? Math.min(v, ceiling) : ceiling);
|
|
29
|
+
|
|
30
|
+
function configOf(o: ProseDiffOptions | ItemDiffOptions | undefined): ItemsConfig {
|
|
31
|
+
const n = o?.normalize;
|
|
32
|
+
return {
|
|
33
|
+
nfkc: n?.nfkc !== false,
|
|
34
|
+
collapseWhitespace: n?.collapseWhitespace !== false,
|
|
35
|
+
newline: n?.newline !== false,
|
|
36
|
+
pairAt: ratioOr(o?.pairAt, LIMITS.pairAt),
|
|
37
|
+
rewriteBelow: ratioOr(o?.rewriteBelow, LIMITS.rewriteBelow),
|
|
38
|
+
absorbOrphan: typeof o?.absorbOrphan === 'number' && o.absorbOrphan >= 0 ? Math.min(o.absorbOrphan, LIMITS.absorbOrphanMax) : LIMITS.absorbOrphan,
|
|
39
|
+
maxChars: capOr((o as ProseDiffOptions | undefined)?.maxChars, LIMITS.maxChars),
|
|
40
|
+
maxCharsPerCompare: LIMITS.maxCharsPerCompare,
|
|
41
|
+
maxAlignTokens: LIMITS.maxAlignTokens,
|
|
42
|
+
maxPairMatrix: LIMITS.maxPairMatrix,
|
|
43
|
+
titleAt: ratioOr((o as ItemDiffOptions | undefined)?.titleAt, LIMITS.titleAt),
|
|
44
|
+
bodyAt: ratioOr((o as ItemDiffOptions | undefined)?.bodyAt, LIMITS.bodyAt),
|
|
45
|
+
maxItems: LIMITS.maxItems,
|
|
46
|
+
moveDetectMaxChanged: LIMITS.moveDetectMaxChanged,
|
|
47
|
+
maxPairCandidates: LIMITS.maxPairCandidates,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 整段替换(端口级退化:超时、适配器失败) */
|
|
52
|
+
function wholeReplace(a: string, b: string): DiffPart[] {
|
|
53
|
+
if (a === b) return a === '' ? [] : [{ op: 'equal', text: a }];
|
|
54
|
+
const parts: DiffPart[] = [];
|
|
55
|
+
if (a !== '') parts.push({ op: 'delete', text: a });
|
|
56
|
+
if (b !== '') parts.push({ op: 'insert', text: b });
|
|
57
|
+
return parts;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const textOrEmpty = (v: unknown): string => (typeof v === 'string' ? v : v === null || v === undefined ? '' : String(v));
|
|
14
61
|
|
|
15
62
|
export function createDiffPort(adapter?: SomaDiffAdapter, options: DiffPortOptions = {}): SomaDiffPort {
|
|
16
63
|
const impl = adapter ?? createJsdiffAdapter({ telemetry: options.telemetry });
|
|
17
64
|
assertDiffAdapter(impl);
|
|
65
|
+
const record = (name: string, started: number): void => options.telemetry?.record(`engine.diff.${name}`, clock() - started);
|
|
66
|
+
const newRun = (timeoutMs: unknown): ProseRun => ({ adapter: impl, deadline: clock() + capOr(timeoutMs, LIMITS.timeoutMs), usedChars: false, usedZh: false });
|
|
67
|
+
|
|
18
68
|
return {
|
|
19
69
|
async diff(a: string, b: string, mode: DiffMode, diffOptions?: DiffOptions): Promise<readonly DiffPart[]> {
|
|
20
70
|
if (typeof a !== 'string' || typeof b !== 'string') {
|
|
@@ -27,7 +77,32 @@ export function createDiffPort(adapter?: SomaDiffAdapter, options: DiffPortOptio
|
|
|
27
77
|
if (max !== undefined && (a.length > max || b.length > max)) {
|
|
28
78
|
throw new SomaEngineError('CORE-ALGO-DIFF-INPUT', 'diff', '输入超过调用方给定的最大长度');
|
|
29
79
|
}
|
|
30
|
-
|
|
80
|
+
if (a.length + b.length > LIMITS.maxCharsPerCompare) return wholeReplace(a, b);
|
|
81
|
+
const parts = await impl.diff(a, b, mode, { ...diffOptions, timeoutMs: capOr(diffOptions?.timeoutMs, LIMITS.timeoutMs) });
|
|
82
|
+
return parts ?? wholeReplace(a, b);
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
async diffProse(a: string, b: string, proseOptions?: ProseDiffOptions): Promise<ProseDiff> {
|
|
86
|
+
// 数据来的值不抛错:null / undefined → 空串,其余标量转字符串(组件层负责「类型不符」的判定与呈现)
|
|
87
|
+
const started = clock();
|
|
88
|
+
const run = newRun(proseOptions?.timeoutMs);
|
|
89
|
+
const out = await runProse(run, configOf(proseOptions), textOrEmpty(a), textOrEmpty(b));
|
|
90
|
+
record('prose', started);
|
|
91
|
+
return out;
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
async diffItems(before: readonly unknown[], after: readonly unknown[], itemOptions?: ItemDiffOptions): Promise<ItemDiff> {
|
|
95
|
+
const started = clock();
|
|
96
|
+
const run = newRun(itemOptions?.timeoutMs);
|
|
97
|
+
const cfg = configOf(itemOptions);
|
|
98
|
+
const out = await runItems(run, cfg, Array.isArray(before) ? before : [], Array.isArray(after) ? after : [], {
|
|
99
|
+
...(typeof itemOptions?.key === 'string' && itemOptions.key !== '' ? { key: itemOptions.key } : {}),
|
|
100
|
+
...(Array.isArray(itemOptions?.fields) ? { fields: itemOptions.fields.filter((f) => f !== null && typeof f === 'object' && typeof f.name === 'string').map((f) => ({ name: f.name, label: typeof f.label === 'string' && f.label !== '' ? f.label : f.name, type: f.type === 'value' ? 'value' as const : 'text' as const })) } : {}),
|
|
101
|
+
...(typeof itemOptions?.title === 'string' && itemOptions.title !== '' ? { title: itemOptions.title } : {}),
|
|
102
|
+
detectMoves: itemOptions?.detectMoves !== false,
|
|
103
|
+
});
|
|
104
|
+
record('items', started);
|
|
105
|
+
return out;
|
|
31
106
|
},
|
|
32
107
|
};
|
|
33
108
|
}
|