Skip to content

wevu / index / SetDataSnapshotOptions

接口: SetDataSnapshotOptions

定义于: packages/wevu/src/runtime/types.ts:27

属性

computedCompare?

optional computedCompare: "reference" | "shallow" | "deep"

定义于: packages/wevu/src/runtime/types.ts:94

patch 模式优化:computed 变更对比策略。

  • reference:仅 Object.is 比较(最快,可能会多下发)
  • shallow:仅比较数组/对象第一层(折中)
  • deep:深比较(可能较慢,适合小对象);会受 computedCompareMaxDepth/maxKeys 限制

computedCompareMaxDepth?

optional computedCompareMaxDepth: number

定义于: packages/wevu/src/runtime/types.ts:99

computed 深比较最大深度(仅在 computedCompare = "deep" 时生效)。


computedCompareMaxKeys?

optional computedCompareMaxKeys: number

定义于: packages/wevu/src/runtime/types.ts:104

computed 深比较最多比较 key 数(仅在 computedCompare = "deep" 时生效)。


debug()?

optional debug: (info) => void

定义于: packages/wevu/src/runtime/types.ts:119

setData 调试信息回调(用于观测 patch 命中率/回退原因/payload 大小)。

参数

info

SetDataDebugInfo

返回

void


debugSampleRate?

optional debugSampleRate: number

定义于: packages/wevu/src/runtime/types.ts:131

debug 采样率(0-1),用于降低 debug 频率与开销(默认 1)。


debugWhen?

optional debugWhen: "fallback" | "always"

定义于: packages/wevu/src/runtime/types.ts:126

debug 触发时机:

  • fallback:仅在回退 diff / 超阈值时触发(默认)
  • always:每次 flush 都触发

elevateTopKeyThreshold?

optional elevateTopKeyThreshold: number

定义于: packages/wevu/src/runtime/types.ts:136

patch 模式优化:当某个顶层字段下的变更路径数量过多时,直接提升为顶层字段整体替换。


includeComputed?

optional includeComputed: boolean

定义于: packages/wevu/src/runtime/types.ts:49

是否将 computed 的结果参与 setData(默认 true)。


maxPatchKeys?

optional maxPatchKeys: number

定义于: packages/wevu/src/runtime/types.ts:55

patch 模式阈值:当本轮变更路径数量超过该值时,自动回退到 diff。 说明:大量路径变更时,全量快照 diff 往往更快/更小。


maxPayloadBytes?

optional maxPayloadBytes: number

定义于: packages/wevu/src/runtime/types.ts:61

patch 模式阈值:当本轮 payload 估算字节数超过该值时,自动回退到 diff。 说明:该估算基于 JSON.stringify(payload).length,仅用于启发式降级。


mergeSiblingMaxInflationRatio?

optional mergeSiblingMaxInflationRatio: number

定义于: packages/wevu/src/runtime/types.ts:75

同级合并的“负优化”防护:若合并后的父路径估算体积大于子路径体积之和 * ratio,则不合并。


mergeSiblingMaxParentBytes?

optional mergeSiblingMaxParentBytes: number

定义于: packages/wevu/src/runtime/types.ts:80

同级合并的“负优化”防护:若父路径估算体积超过该值,则不合并。


mergeSiblingSkipArray?

optional mergeSiblingSkipArray: boolean

定义于: packages/wevu/src/runtime/types.ts:85

是否在父值为数组时跳过同级合并(默认 true)。


mergeSiblingThreshold?

optional mergeSiblingThreshold: number

定义于: packages/wevu/src/runtime/types.ts:70

patch 模式优化:当同一父路径下存在多个子路径变更时,合并为父路径整体下发。

例如:a.ba.c 同时变更,且 mergeSiblingThreshold = 2 时,会下发 a

注意:当子路径包含删除(null)时,为避免删除语义不一致,将不会触发合并。


omit?

optional omit: string[]

定义于: packages/wevu/src/runtime/types.ts:44

排除指定的顶层字段(包含 data/setup 返回值与 computed)。


pick?

optional pick: string[]

定义于: packages/wevu/src/runtime/types.ts:39

仅下发指定的顶层字段(包含 data/setup 返回值与 computed)。 若为空则默认下发所有字段。


prelinkMaxDepth?

optional prelinkMaxDepth: number

定义于: packages/wevu/src/runtime/types.ts:109

限制 patch 模式的预链接(prelinkReactiveTree)开销:最多向下遍历的深度(root 为 0)。


prelinkMaxKeys?

optional prelinkMaxKeys: number

定义于: packages/wevu/src/runtime/types.ts:114

限制 patch 模式的预链接(prelinkReactiveTree)开销:最多索引的节点数。


strategy?

optional strategy: "diff" | "patch"

定义于: packages/wevu/src/runtime/types.ts:33

setData 策略:

  • diff:全量快照 + diff(默认,兼容性最好)
  • patch:按变更路径增量产出 payload(性能更好;在共享引用等场景会自动回退 diff)

toPlainMaxDepth?

optional toPlainMaxDepth: number

定义于: packages/wevu/src/runtime/types.ts:141

setData 序列化上限:最大递归深度(root 为 0)。超过时将停止深拷贝,保留更浅层结构。


toPlainMaxKeys?

optional toPlainMaxKeys: number

定义于: packages/wevu/src/runtime/types.ts:146

setData 序列化上限:最多处理的对象 key 数(累计)。超过时将停止深拷贝,保留更浅层结构。

Released under the MIT License.