File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' @antv/l7-core ' : minor
3+ ---
4+
5+ refactor(core): type encodeStyleAttribute via IEncodedStyleMap (stage-3 3.2)
6+
7+ P4 阶段 3 第一刀(3.2,core 侧 typing 子集,minor)。
8+
9+ PLAN 3.2 列举四项替 ` any ` :经审 ` sourceOption ` /` shapeOption ` /` defaultSourceConfig `
10+ 已在历史阶段各自定型为 ` ISourceOption ` /` IShapeOption ` /` IDefaultSourceConfig `
11+ (PLAN 草拟时未及同步),故本轮仅收编真正剩余的 `encodeStyleAttribute:
12+ Record<string, any>` 缺口。
13+
14+ 新增(` services/layer/ILayerService.ts ` ,minor 依据):
15+
16+ - ` export interface IEncodedStyleValue ` — 单条数据映射样式值,对齐
17+ ` updateStyleAttribute ` 的 ` field ` /` values ` 形参(值键名历史为 ` value `
18+ 单数);` field?: StyleAttributeField ` 、` value?: StyleAttributeOption ` ,
19+ 保留 ` [key: string]: any ` 索引签名兼容历史透传的额外字段(非破坏性收窄)。
20+ - ` export type IEncodedStyleMap = Record<string, IEncodedStyleValue> ` 。
21+
22+ ` ILayer.encodeStyleAttribute: Record<string, any> ` → ` IEncodedStyleMap ` 。
23+
24+ ** 向后兼容** :` any ` →具名类型是收窄但非破坏——写入侧 ` encodeStyle(options: {[k]:any}) `
25+ 的 ` options[key] ` (` any ` )仍可赋值 ` IEncodedStyleValue ` ;读取侧 ` getDynamicStyleInject `
26+ 形参 ` Record<string, any> ` 接受 ` IEncodedStyleMap ` 。
27+
28+ 配套 layers 侧声明同步见 ` refactor-layers-encoded-style-map ` changeset。
29+ ` getScale(name) ` 泛型化归后续 scale delegate 专属刀(3.2 剩余子项),本刀聚焦
30+ ` encodeStyleAttribute ` 缺口。
31+
32+ 验证:core eslint 0 error、prettier 通过、core father build 98 files(d.ts 类型检查)。
Original file line number Diff line number Diff line change 1+ ---
2+ ' @antv/l7-layers ' : patch
3+ ---
4+
5+ refactor(layers): type encodeStyleAttribute field via IEncodedStyleMap (stage-3 3.2)
6+
7+ P4 阶段 3 第一刀(3.2,layers 侧,patch——纯内部字段类型对齐,无新增/改动公共 API)。
8+
9+ 配合 core 侧 ` IEncodedStyleMap ` (见 ` refactor-core-encoded-style-map ` ),将
10+ ` BaseLayer.encodeStyleAttribute: Record<string, any> ` 收窄为 ` IEncodedStyleMap `
11+ 并从 ` @antv/l7-core ` 导入。
12+
13+ ** 零行为变化** :
14+
15+ - 写入点 ` encodeStyle() ` 的 ` this.encodeStyleAttribute[key] = options[key] `
16+ 右值 ` options[key] ` 为 ` any ` ,赋值具名类型无类型错误、运行时同一对象引用。
17+ - 读取点 ` BaseModel.getInject() ` 经 `getDynamicStyleInject(..., this.layer
18+ .encodeStyleAttribute)` 传入(其形参 ` Record<string, any>` 接受
19+ ` IEncodedStyleMap ` )、` !this.layer.encodeStyleAttribute[key] ` 真值判断、
20+ ` Object.keys(...) ` 遍历均不受影响。
21+
22+ ` registerStyleAttribute ` /其他 BaseModel 自身的 `encodeStyleAttribute: Record<
23+ string, boolean>`(布尔 flag 表)与本字段同名但语义独立,不在本刀收窄范围。
24+
25+ 验证:layers eslint 0 error、prettier 通过、layers father build 278 files
26+ (含 declaration d.ts 类型检查)、jest layers+maps 77 suites 0 failed(1
27+ skipped ` citybuilding ` ,基线一致)。
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ citybuilding/ geometry/ — 12 个具体图层 extends BaseLayer(各自只 ove
9393### 阶段 3 — 配置模型与类型强化
9494
9595- 3.1 定义 ` LayerConfigModel ` 收敛三轨:` rawConfig ` (入参快照)/ ` needUpdateConfig ` (diff 暂存)/ ` getLayerConfig() ` (` globalConfigService ` 读回)→ 统一为 ` LayerConfigModel.read() ` 单一读路径 + ` apply(patch) ` 单一写路径,` prepareBuildModel ` 消费 diff。` ILayer.getLayerConfig<T>() ` 签名不变。
96- - 3.2 给 ` defaultSourceConfig/sourceOption/shapeOption/encodeStyleAttribute ` 补严格类型(替 ` any ` ):引入 ` ILayerSourceOption/IShapeOption/IEncodedStyleMap ` ,` get(name) ` /` getScale(name) ` 标泛型或返回联合类型。
96+ - 3.2 给 ` defaultSourceConfig/sourceOption/shapeOption/encodeStyleAttribute ` 补严格类型(替 ` any ` ):引入 ` ILayerSourceOption/IShapeOption/IEncodedStyleMap ` ,` get(name) ` /` getScale(name) ` 标泛型或返回联合类型。 ** (☑ 部分完成; ` defaultSourceConfig ` / ` sourceOption ` / ` shapeOption ` / ` get(name) ` 历史已各自定型为 ` IDefaultSourceConfig ` / ` ISourceOption ` / ` IShapeOption ` / ` number ` ,本刀补齐 ` encodeStyleAttribute ` → ` IEncodedStyleMap ` (core 新增 ` IEncodedStyleValue ` + ` IEncodedStyleMap ` );剩 ` getScale(name):any ` 泛型化归后续 scale delegate 专属刀。) **
9797- 3.3 ` enableShaderEncodeStyles/enableDataEncodeStyles: string[] ` → 收敛为 ` encodeStyles: Map<string,'shader'|'data'> ` (内部),公开数组 getter 保留过渡;补 spec 锁定编码开关行为。
9898
9999### 阶段 4 — 渲染管线收敛
Original file line number Diff line number Diff line change @@ -80,6 +80,26 @@ export interface IShapeOption {
8080 values : any ;
8181}
8282
83+ /**
84+ * 单条数据映射样式值(阶段 3.2:替 `encodeStyleAttribute: Record<string, any>`)。
85+ *
86+ * `BaseLayer.encodeStyleAttribute[key]` 存储该结构,对齐 `updateStyleAttribute`
87+ * 的 `field`/`values` 形参(值键名历史为 `value` 单数)。两者均可选,由
88+ * `encodeStyle()` 的 `field || value` guard 保证至少存在其一;保留索引签名
89+ * `[key: string]: any` 以兼容历史透传的额外字段(不做破坏性收窄)。
90+ */
91+ export interface IEncodedStyleValue {
92+ field ?: StyleAttributeField ;
93+ value ?: StyleAttributeOption ;
94+ [ key : string ] : any ;
95+ }
96+
97+ /**
98+ * 数据映射样式表(阶段 3.2)。键为样式属性名(`color`/`size`/...),值详见
99+ * `IEncodedStyleValue`。
100+ */
101+ export type IEncodedStyleMap = Record < string , IEncodedStyleValue > ;
102+
83103export interface IWorkerOption {
84104 modelType : string ;
85105 [ key : string ] : any ;
@@ -386,7 +406,7 @@ export interface ILayer {
386406 dataState : IDataState ; // 数据流状态
387407 defaultSourceConfig : IDefaultSourceConfig ;
388408 encodeDataLength : number ;
389- encodeStyleAttribute : Record < string , any > ;
409+ encodeStyleAttribute : IEncodedStyleMap ;
390410 pickedFeatureID : number | null ;
391411 hooks : {
392412 init : AsyncSeriesBailHook ;
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import type {
88 IDataState ,
99 IDefaultSourceConfig ,
1010 IEncodeFeature ,
11+ IEncodedStyleMap ,
1112 IGlobalConfigService ,
1213 ILayer ,
1314 ILayerAttributesOption ,
@@ -247,7 +248,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
247248
248249 private needUpdateConfig : Partial < ILayerConfig & ChildLayerStyleOptions > ;
249250
250- public encodeStyleAttribute : Record < string , any > = { } ;
251+ public encodeStyleAttribute : IEncodedStyleMap = { } ;
251252
252253 // Shader 的数据映射
253254 public enableShaderEncodeStyles : string [ ] = [ ] ;
You can’t perform that action at this time.
0 commit comments