annil 1.7.5-beta.4 → 1.7.5
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/CHANGELOG.md +7 -0
- package/README.md +43 -37
- package/dist/api/DefineComponent/ReturnType/ComponentType.d.ts +18 -0
- package/dist/api/DefineComponent/ReturnType/ComponentType.js +2 -0
- package/dist/api/DefineComponent/ReturnType/ComponentType.js.map +1 -0
- package/dist/api/DefineComponent/ReturnType/CreateComponentDoc.d.ts +3 -3
- package/dist/api/DefineComponent/ReturnType/CreatePageDoc.d.ts +2 -2
- package/dist/api/DefineComponent/ReturnType/GetCustomEventDocOfSubDoc.d.ts +3 -3
- package/dist/api/DefineComponent/RootComponent/RootComponentOption.d.ts +2 -2
- package/dist/api/DefineComponent/SubComponents/SubComponentsOption.d.ts +2 -2
- package/dist/api/DefineComponent/index.d.ts +5 -5
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/computedUpdater.js +2 -2
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/computedUpdater.js.map +1 -1
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/index.js +2 -2
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/index.js.map +1 -1
- package/dist/api/DefineComponent/normalizeOptions/index.js +1 -1
- package/dist/api/DefineComponent/normalizeOptions/index.js.map +1 -1
- package/dist/api/RootComponent/Events/EventsConstraint.d.ts +4 -4
- package/dist/api/RootComponent/{RootComponentDoc.d.ts → RootComponentType.d.ts} +16 -15
- package/dist/api/RootComponent/RootComponentType.js +2 -0
- package/dist/api/RootComponent/RootComponentType.js.map +1 -0
- package/dist/api/RootComponent/index.d.ts +3 -3
- package/dist/api/SubComponent/{SubComponentDoc.d.ts → SubComponentType.d.ts} +3 -3
- package/dist/api/SubComponent/SubComponentType.js +2 -0
- package/dist/api/SubComponent/SubComponentType.js.map +1 -0
- package/dist/api/SubComponent/SubEvents/SubEventsConstraint.d.ts +2 -2
- package/dist/api/SubComponent/SubInherit/SubInheritConstraint.d.ts +2 -2
- package/dist/api/SubComponent/index.d.ts +5 -5
- package/dist/behaviors/BStore.d.ts +1 -1
- package/dist/behaviors/BStore.js +31 -18
- package/dist/behaviors/BStore.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/types/CreateComponentType.d.ts +23 -2
- package/dist/types/ExtendComponentType.d.ts +34 -0
- package/dist/types/ExtendComponentType.js +6 -0
- package/dist/types/ExtendComponentType.js.map +1 -0
- package/dist/types/GetComponentPrefix.d.ts +2 -2
- package/dist/types/ReplacePrefix.d.ts +2 -2
- package/dist/{api/DefineComponent/normalizeOptions/computedWatchHandle/isEqual.d.ts → utils/deepEqual.d.ts} +1 -1
- package/dist/{api/DefineComponent/normalizeOptions/computedWatchHandle/isEqual.js → utils/deepEqual.js} +3 -3
- package/dist/utils/deepEqual.js.map +1 -0
- package/package.json +2 -3
- package/src/api/DefineComponent/NameOrPage/test/error.test.ts +6 -6
- package/src/api/DefineComponent/ReturnType/{ComponentDoc.ts → ComponentType.ts} +6 -7
- package/src/api/DefineComponent/ReturnType/CreateComponentDoc.ts +4 -4
- package/src/api/DefineComponent/ReturnType/CreatePageDoc.ts +2 -2
- package/src/api/DefineComponent/ReturnType/GetCustomEventDocOfSubDoc.ts +3 -3
- package/src/api/DefineComponent/ReturnType/GetPropertiesDocOfSubDoc.ts +3 -3
- package/src/api/DefineComponent/ReturnType/test/normalComponentDoc.test.ts +5 -5
- package/src/api/DefineComponent/RootComponent/RootComponentOption.ts +2 -2
- package/src/api/DefineComponent/SubComponents/SubComponentsOption.ts +2 -2
- package/src/api/DefineComponent/SubComponents/test/normal.test.ts +3 -3
- package/src/api/DefineComponent/index.ts +7 -7
- package/src/api/DefineComponent/normalizeOptions/computedWatchHandle/computedUpdater.ts +2 -2
- package/src/api/DefineComponent/normalizeOptions/computedWatchHandle/index.ts +2 -2
- package/src/api/DefineComponent/normalizeOptions/index.ts +1 -1
- package/src/api/RootComponent/Events/EventsConstraint.ts +5 -5
- package/src/api/RootComponent/Events/test/normal.test.ts +5 -5
- package/src/api/RootComponent/{RootComponentDoc.ts → RootComponentType.ts} +16 -15
- package/src/api/RootComponent/index.ts +3 -3
- package/src/api/SubComponent/{SubComponentDoc.ts → SubComponentType.ts} +3 -3
- package/src/api/SubComponent/SubComputed/test/error.test.ts +3 -3
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +4 -4
- package/src/api/SubComponent/SubData/test/error.test.ts +3 -3
- package/src/api/SubComponent/SubData/test/normal.test.ts +2 -2
- package/src/api/SubComponent/SubEvents/SubEventsConstraint.ts +2 -2
- package/src/api/SubComponent/SubEvents/test/error.test.ts +3 -3
- package/src/api/SubComponent/SubEvents/test/normal.test.ts +2 -2
- package/src/api/SubComponent/SubInherit/SubInheritConstraint.ts +2 -2
- package/src/api/SubComponent/SubInherit/test/error.test.ts +6 -6
- package/src/api/SubComponent/SubInherit/test/normal.test.ts +4 -4
- package/src/api/SubComponent/SubInstance/test/error.test.ts +2 -2
- package/src/api/SubComponent/SubInstance/test/normal.test.ts +4 -4
- package/src/api/SubComponent/SubMethods/test/error.test.ts +4 -4
- package/src/api/SubComponent/SubMethods/test/normarl.test.ts +4 -4
- package/src/api/SubComponent/SubReturnType/test/error.test.ts +2 -2
- package/src/api/SubComponent/SubReturnType/test/normal.test.ts +2 -2
- package/src/api/SubComponent/SubStore/test/error.test.ts +2 -2
- package/src/api/SubComponent/SubStore/test/normal.test.ts +2 -2
- package/src/api/SubComponent/SubWatch/test/WatchComputed.test.ts +4 -4
- package/src/api/SubComponent/SubWatch/test/WatchRootData.test.ts +2 -2
- package/src/api/SubComponent/SubWatch/test/WatchSubData.test.ts +2 -2
- package/src/api/SubComponent/index.ts +9 -9
- package/src/behaviors/BStore.ts +35 -23
- package/src/index.ts +2 -2
- package/src/types/CreateComponentType.ts +23 -2
- package/src/types/ExtendComponentType.ts +60 -0
- package/src/types/GetComponentPrefix.ts +2 -2
- package/src/types/GetPropertiesDuplicatedKeys.ts +3 -3
- package/src/types/ReplacePrefix.ts +2 -2
- package/src/{api/DefineComponent/normalizeOptions/computedWatchHandle/isEqual.ts → utils/deepEqual.ts} +2 -3
- package/dist/api/DefineComponent/ReturnType/ComponentDoc.d.ts +0 -18
- package/dist/api/DefineComponent/ReturnType/ComponentDoc.js +0 -2
- package/dist/api/DefineComponent/ReturnType/ComponentDoc.js.map +0 -1
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/isEqual.js.map +0 -1
- package/dist/api/RootComponent/RootComponentDoc.js +0 -2
- package/dist/api/RootComponent/RootComponentDoc.js.map +0 -1
- package/dist/api/SubComponent/SubComponentDoc.js +0 -2
- package/dist/api/SubComponent/SubComponentDoc.js.map +0 -1
- package/dist/types/DocAssign.d.ts +0 -10
- package/dist/types/DocAssign.js +0 -6
- package/dist/types/DocAssign.js.map +0 -1
- package/src/types/DocAssign.ts +0 -36
- package/tsconfig.json +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
* 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
|
|
6
6
|
|
|
7
|
+
## [1.7.5](https://github.com/missannil/annil/compare/v1.7.5-beta.4...v1.7.5) (2024-08-08)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Miscellaneous Chores
|
|
11
|
+
|
|
12
|
+
* 更改README,SubComponentDoc->SubComponentType,RootComponentDoc->RootComponentType ([073d273](https://github.com/missannil/annil/commit/073d2733f5b15923d67f3a04a7a15902f73a9205))
|
|
13
|
+
|
|
7
14
|
## [1.7.5-beta.4](https://github.com/missannil/annil/compare/v1.7.5-beta-3...v1.7.5-beta.4) (2024-08-07)
|
|
8
15
|
|
|
9
16
|
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
### 简介
|
|
25
25
|
|
|
26
|
-
annil(安奈儿)
|
|
26
|
+
annil(安奈儿)是微信小程序原生开发插件。她会让你获得新的开发体验,提高代码质量和开发效率。
|
|
27
27
|
|
|
28
28
|
### 特点
|
|
29
29
|
|
|
@@ -34,29 +34,26 @@ annil(安奈儿)是微信小程序原生开发插件。她会让你获得新的
|
|
|
34
34
|
- **复杂组件解决方案**
|
|
35
35
|
|
|
36
36
|
新的组件构建方案(根组件 + 子组件(可选)),组件逻辑与wxml标签一一对应。解决书写复杂组件时不同组件代码耦合的问题。
|
|
37
|
-
- **基于typescript设计**
|
|
38
|
-
|
|
39
|
-
annil中的api基于原生ts设计,js开发者只需懂得定义对象类型便可。
|
|
40
37
|
|
|
41
38
|
- **组件类型概念**
|
|
42
39
|
|
|
43
|
-
新的组件构建API(DefineComponent)返回的类型叫组件类型,好比传统组件(UI)库为每个组件书写的使用文档,在做为子组件构建新组件(页面)时,子组件API(SubComponent)
|
|
40
|
+
新的组件构建API(DefineComponent)返回的类型叫组件类型,好比传统组件(UI)库为每个组件书写的使用文档,在做为子组件构建新组件(页面)时,子组件API(SubComponent)需要使用者传入组件类型,这样在书写配置字段时会得到完美的类型提示和检测。这样实现了一个页面中所有子组件之间的类型耦合,无论组件嵌套多少层,无论哪层组件数据类型发生改变,所有相关组件类型都会得到感知。当您增改、重构代码时,只要无类型报错(tsc --noEmit --watch)就不会有运行时报错的心智负担。
|
|
44
41
|
|
|
45
42
|
- **高兼容性**
|
|
46
43
|
|
|
47
|
-
annil提供的API都是原生API
|
|
44
|
+
annil提供的API都是原生API的语法糖,不具有强制性和侵入性,可渐进的重构代码。
|
|
48
45
|
|
|
49
46
|
- **类型修补**
|
|
50
47
|
|
|
51
|
-
官方类型(miniprogram-api-typings)
|
|
48
|
+
官方类型(miniprogram-api-typings)更新可能不够及时,annil提供了新的类型(补全官方类型)方便开发,这些类型都采用ES模块化,不会污染全局类型。
|
|
52
49
|
|
|
53
|
-
-
|
|
50
|
+
- **完美适配第三方组件(UI)库**
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
第三方组件库一般都是以文档的形式对组件说明,annil提供了泛型[CreateComponentType](./src/types/CreateComponentType.ts),可根据组件文档快速书写组件类型,使第三方组件完美融入annil组件模型,也可以自己书写临时组件类型用于项目。内置的原生组件类型库(Wm)和第三方组件库(Vant)也会持续维护。
|
|
56
53
|
|
|
57
|
-
-
|
|
54
|
+
- **vscode插件 `annil`**
|
|
58
55
|
|
|
59
|
-
|
|
56
|
+
当使用ts开发时,可安装vscode插件,会自动检测组件中`.wxml` 和 `.json`错误,并可一键修复。详情见 [插件市场](https://marketplace.visualstudio.com/items?itemName=missannil.vscode-annil)
|
|
60
57
|
|
|
61
58
|
### 安装
|
|
62
59
|
|
|
@@ -71,20 +68,19 @@ annil(安奈儿)是微信小程序原生开发插件。她会让你获得新的
|
|
|
71
68
|
- 可选
|
|
72
69
|
|
|
73
70
|
```bash
|
|
74
|
-
# 使用ts开发
|
|
75
|
-
npm typescript
|
|
71
|
+
# 使用ts开发 hry-types为annil依赖的类型库
|
|
72
|
+
npm --save-dev typescript hry-types miniprogram-api-typings
|
|
76
73
|
```
|
|
77
74
|
|
|
78
75
|
```bash
|
|
79
|
-
# 使用全局状态管理
|
|
76
|
+
# 使用全局状态管理 当前为mobx6版本
|
|
80
77
|
npm i mobx
|
|
81
78
|
```
|
|
82
79
|
|
|
83
80
|
2. 构建npm
|
|
84
81
|
|
|
85
|
-
|
|
86
|
-
>
|
|
87
|
-
> 避免使用时出现 `ReferenceError: process is not defined` 错误。
|
|
82
|
+
> 若使用mobx(当前mobx为6.x.x),在构建npm前需要手动更改`node_modules/mobx/dist/index.js`文件
|
|
83
|
+
> 避免构建时出现 `ReferenceError: process is not defined` 错误。
|
|
88
84
|
```js
|
|
89
85
|
// 更改前
|
|
90
86
|
"use strict";
|
|
@@ -101,20 +97,30 @@ annil(安奈儿)是微信小程序原生开发插件。她会让你获得新的
|
|
|
101
97
|
module.exports = require("./mobx.cjs.production.min.js");
|
|
102
98
|
```
|
|
103
99
|
|
|
100
|
+
开发者工具左上部工具栏——工具——构建npm
|
|
104
101
|
3. 配置tsconfig.json(使用ts开发时)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"compilerOptions": {
|
|
106
|
+
"target": "ES2022",
|
|
107
|
+
"moduleResolution": "node",
|
|
108
|
+
"skipLibCheck": true, // 跳过声明文件的类型检查(.d.ts)。
|
|
109
|
+
"esModuleInterop": true, // 默认false. 兼容非ES模块引用的写法(如 import type mobx from 'mobx'等).
|
|
110
|
+
"strict": true, // 启用严格模式
|
|
111
|
+
"noEmit": true, // 编译时不生成文件。
|
|
112
|
+
"strictFunctionTypes": false, // 忽略函数参数逆变引起的问题
|
|
113
|
+
"types": [
|
|
114
|
+
"hry-types",
|
|
115
|
+
"mobx",
|
|
116
|
+
"miniprogram-api-typings"
|
|
117
|
+
]
|
|
118
|
+
},
|
|
119
|
+
"include": [
|
|
120
|
+
"**/*.ts"
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
```
|
|
118
124
|
|
|
119
125
|
### 使用文档
|
|
120
126
|
|
|
@@ -122,20 +128,20 @@ annil(安奈儿)是微信小程序原生开发插件。她会让你获得新的
|
|
|
122
128
|
|
|
123
129
|
[DefineComponent](./doc/api/DefineComponent.md)
|
|
124
130
|
|
|
125
|
-
[
|
|
131
|
+
[RootComponent](./doc/api/RootComponent.md)
|
|
126
132
|
|
|
127
133
|
[SubComponent](./doc/api/SubComponent.md)
|
|
128
134
|
|
|
129
|
-
- **
|
|
135
|
+
- **常用API**
|
|
130
136
|
|
|
131
137
|
[navigateTo](./doc/api/navigateTo.md)
|
|
132
138
|
|
|
133
|
-
-
|
|
139
|
+
- 实用泛型
|
|
140
|
+
|
|
141
|
+
[CreateComponentType](./src/types/CreateComponentType.ts)
|
|
142
|
+
|
|
143
|
+
[ExtendComponentType](./src/types/ExtendComponentType.ts)
|
|
134
144
|
|
|
135
145
|
### 更新日志
|
|
136
146
|
|
|
137
147
|
[CHANGELOG](./CHANGELOG.md)
|
|
138
|
-
|
|
139
|
-
测试1
|
|
140
|
-
测试2
|
|
141
|
-
测试3
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type PrefixKeys = `${string}_${string}`;
|
|
2
|
+
type _ComponentType = {
|
|
3
|
+
properties?: Record<PrefixKeys, unknown>;
|
|
4
|
+
customEvents?: Record<PrefixKeys, unknown>;
|
|
5
|
+
};
|
|
6
|
+
type Error = "{ properties?: Record<PrefixKeys, any>; customEvents?: Record<PrefixKeys, any>;}";
|
|
7
|
+
type _Validator<O> = keyof O extends keyof _ComponentType ? keyof (O["properties"] & O["customEvents"]) extends PrefixKeys ? _ComponentType : Error : Error;
|
|
8
|
+
/**
|
|
9
|
+
* RootComponent Api 返回的类型
|
|
10
|
+
* ```ts
|
|
11
|
+
* RootComponentDoc = {
|
|
12
|
+
* properties?: Record<PrefixKeys, any>;
|
|
13
|
+
* customEvents?: Record<PrefixKeys, any>;
|
|
14
|
+
* };
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export type ComponentType<O extends _Validator<O> = _ComponentType> = O;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComponentType.js","sourceRoot":"","sources":["../../../../src/api/DefineComponent/ReturnType/ComponentType.ts"],"names":[],"mappings":""}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
2
|
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
3
|
import type { AddNullForObject } from "../../../types/AddNullForObject";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
4
|
+
import type { RootComponentType } from "../../RootComponent/RootComponentType";
|
|
5
|
+
import type { SubComponentType } from "../../SubComponent/SubComponentType";
|
|
6
6
|
import type { GetCustomEventDocOfSubDoc } from "./GetCustomEventDocOfSubDoc";
|
|
7
7
|
type GetStopKeys<O> = {
|
|
8
8
|
[k in keyof O]: k extends `${string}_${infer Key}_${string}_catch` ? Key : never;
|
|
9
9
|
}[keyof O];
|
|
10
|
-
export type CreateComponentDoc<TRootDoc extends
|
|
10
|
+
export type CreateComponentDoc<TRootDoc extends RootComponentType, TName extends string, TSubComponentTuple extends SubComponentType[], AllPropertiesDoc extends unknown | object = TRootDoc["properties"], AllCustomEventsDoc extends unknown | object = TRootDoc["customEvents"] & GetCustomEventDocOfSubDoc<TSubComponentTuple[number]>, StopKeys extends string = GetStopKeys<TRootDoc["events"]>, FinalCustomEventDoc extends object = Omit<AllCustomEventsDoc, StopKeys>> = ComputeIntersection<IfExtends<unknown, AllPropertiesDoc, {}, {
|
|
11
11
|
properties: {
|
|
12
12
|
[k in keyof AllPropertiesDoc as `${TName}_${k & string}`]: AddNullForObject<AllPropertiesDoc[k]>;
|
|
13
13
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
2
|
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
3
|
-
import type {
|
|
4
|
-
export type CreatePageDoc<TRootDoc extends
|
|
3
|
+
import type { RootComponentType } from "../../RootComponent/RootComponentType";
|
|
4
|
+
export type CreatePageDoc<TRootDoc extends RootComponentType, TPath extends string> = ComputeIntersection<{
|
|
5
5
|
path: TPath;
|
|
6
6
|
} & IfExtends<unknown, TRootDoc["properties"], unknown, {
|
|
7
7
|
properties: TRootDoc["properties"];
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { IsNever, IsUnion } from "hry-types/src/Any/_api";
|
|
2
2
|
import type { UnionTwoObject } from "hry-types/src/Object/UnionTwoObject";
|
|
3
3
|
import type { Last } from "hry-types/src/Union/Last";
|
|
4
|
-
import type {
|
|
4
|
+
import type { SubComponentType } from "../../SubComponent/SubComponentType";
|
|
5
5
|
/**
|
|
6
6
|
* 因为子组件文档customEvents字段有可能相同(无前缀),所以使用UnionTwoObject
|
|
7
7
|
* 由于SubComponentDoc为空时返回never而不`{}`,所以`Exclude<U, TLast>`不影响结果。
|
|
8
8
|
*/
|
|
9
|
-
type _GetCustomEventDocOfSubDoc<U extends
|
|
9
|
+
type _GetCustomEventDocOfSubDoc<U extends SubComponentType, Result = {}, TLast = Last<U>> = IsNever<U> extends true ? Result : _GetCustomEventDocOfSubDoc<Exclude<U, TLast>, UnionTwoObject<Result, TLast>>;
|
|
10
10
|
/**
|
|
11
11
|
* 获取子组件自定义事件文档
|
|
12
12
|
* @remarks U 中 相同字段类型联合,所以使用元组推导不如Last性能好。
|
|
13
13
|
*/
|
|
14
|
-
export type GetCustomEventDocOfSubDoc<UnionSubDoc extends
|
|
14
|
+
export type GetCustomEventDocOfSubDoc<UnionSubDoc extends SubComponentType> = IsUnion<UnionSubDoc> extends true ? _GetCustomEventDocOfSubDoc<UnionSubDoc> : UnionSubDoc;
|
|
15
15
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RootComponentType } from "../../RootComponent/RootComponentType";
|
|
2
2
|
/**
|
|
3
3
|
* DefineComponent API`rootComponent`字段配置
|
|
4
4
|
*/
|
|
5
|
-
export type RootComponentOption<TRootComponent extends
|
|
5
|
+
export type RootComponentOption<TRootComponent extends RootComponentType> = {
|
|
6
6
|
/**
|
|
7
7
|
* 根组件配置
|
|
8
8
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SubComponentType } from "../../SubComponent/SubComponentType";
|
|
2
2
|
/**
|
|
3
3
|
* RootComponent API 的`subComponents`字段配置
|
|
4
4
|
*/
|
|
5
|
-
export type SubComponentsOption<TSubComponentTuple extends
|
|
5
|
+
export type SubComponentsOption<TSubComponentTuple extends SubComponentType[]> = {
|
|
6
6
|
/**
|
|
7
7
|
* 子组件列表
|
|
8
8
|
*/
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
2
2
|
import type { RootComponentTrueOptions } from "../RootComponent";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { RootComponentType } from "../RootComponent/RootComponentType";
|
|
4
|
+
import type { SubComponentType } from "../SubComponent/SubComponentType";
|
|
5
5
|
import type { NameOrPathOption } from "./NameOrPage/NameOrPathOption";
|
|
6
6
|
import type { CreateComponentDoc } from "./ReturnType/CreateComponentDoc";
|
|
7
7
|
import type { CreatePageDoc } from "./ReturnType/CreatePageDoc";
|
|
8
8
|
import type { RootComponentOption } from "./RootComponent/RootComponentOption";
|
|
9
9
|
import type { SubComponentsOption } from "./SubComponents/SubComponentsOption";
|
|
10
10
|
export type Path = `/${string}`;
|
|
11
|
-
type RootOptions<TRootComponentDoc extends
|
|
12
|
-
type DefineComponentConstructor = <TRootComponentDoc extends
|
|
11
|
+
type RootOptions<TRootComponentDoc extends RootComponentType, TSubComponentTuple extends SubComponentType[], TName extends string, TPath extends Path> = NameOrPathOption<TName, TPath, TRootComponentDoc["isPage"] & {}> & RootComponentOption<TRootComponentDoc> & SubComponentsOption<TSubComponentTuple>;
|
|
12
|
+
type DefineComponentConstructor = <TRootComponentDoc extends RootComponentType = {}, TSubComponentTuple extends SubComponentType[] = [], TName extends string = "", TPath extends Path = "/">(options: RootOptions<TRootComponentDoc, TSubComponentTuple, TName, TPath>) => IfExtends<"", TName, CreatePageDoc<TRootComponentDoc, TPath>, CreateComponentDoc<TRootComponentDoc, TName, TSubComponentTuple>>;
|
|
13
13
|
export type DefineComponentOption = {
|
|
14
14
|
name?: string;
|
|
15
15
|
path?: string;
|
|
16
16
|
rootComponent?: RootComponentTrueOptions;
|
|
17
|
-
subComponents?:
|
|
17
|
+
subComponents?: SubComponentType[];
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* 把根组件选项和子组件选项转化为原生Component API选项并执行
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { deepEqual } from "../../../../utils/deepEqual";
|
|
1
2
|
import { deepProxy, getProxyOriginalValue } from "./data-tracer";
|
|
2
3
|
import { removeSubDependences } from "./dependencesOptimize";
|
|
3
4
|
import { getPathsValue } from "./getPathsValue";
|
|
4
|
-
import { isEqual } from "./isEqual";
|
|
5
5
|
export function computedUpdater(isUpdated = false) {
|
|
6
6
|
for (const key in this.data.__computedCache__) {
|
|
7
7
|
const itemCache = this.data.__computedCache__[key];
|
|
@@ -10,7 +10,7 @@ export function computedUpdater(isUpdated = false) {
|
|
|
10
10
|
// getPathsValue返回的是数组
|
|
11
11
|
const curVal = getPathsValue(this.data, dep.paths.join("."))[0];
|
|
12
12
|
// 检查依赖是否更新
|
|
13
|
-
if (!
|
|
13
|
+
if (!deepEqual(curVal, dep.val)) {
|
|
14
14
|
changed = true;
|
|
15
15
|
break;
|
|
16
16
|
}
|
package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/computedUpdater.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computedUpdater.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/normalizeOptions/computedWatchHandle/computedUpdater.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computedUpdater.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/normalizeOptions/computedWatchHandle/computedUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD,MAAM,UAAU,eAAe,CAAiB,SAAS,GAAG,KAAK;IAC/D,KA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../../utils/deepEqual";
|
|
1
2
|
import { computedUpdater } from "./computedUpdater";
|
|
2
3
|
import { getPathsValue } from "./getPathsValue";
|
|
3
4
|
import { getPropertiesValue } from "./getPropertiesValue";
|
|
4
5
|
import { initComputedAndGetCache } from "./initComputedAndGetCache";
|
|
5
|
-
import { isEqual } from "./isEqual";
|
|
6
6
|
import { assertNonNullable } from "../../../../utils/assertNonNullable";
|
|
7
7
|
import { deepClone } from "../../../../utils/deepClone";
|
|
8
8
|
import { isEmptyObject } from "../../../../utils/isEmptyObject";
|
|
@@ -49,7 +49,7 @@ export function computedWatchHandle(options) {
|
|
|
49
49
|
originObserversHandle === null || originObserversHandle === void 0 ? void 0 : originObserversHandle.call(this, ...newValue);
|
|
50
50
|
const watchOldValue = assertNonNullable(this.data.__watchOldValue__);
|
|
51
51
|
const oldValue = watchOldValue[key];
|
|
52
|
-
if (
|
|
52
|
+
if (deepEqual(newValue, oldValue))
|
|
53
53
|
return;
|
|
54
54
|
watchOldValue[key] = deepClone(newValue);
|
|
55
55
|
watchHadle.call(this, ...newValue, ...oldValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/normalizeOptions/computedWatchHandle/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/normalizeOptions/computedWatchHandle/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;A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,eAAe;IACf,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;IAElC,IAAI,WAAW,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAE1B,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,iCAAM,IAAI,GAAK,kBAAkB,GAAI,WAAW,CAAC,CAAC;QAE5F,MAAM,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC;QAC1C,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;YAC9B,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YACpC,MAAM,qBAAqB,GAAG,eAAe,CAAC,GAAG,CAAqB,CAAC;YAEvE,kBAAkB;YAClB,eAAe,CAAC,GAAG,CAAC,GAAG,UAAyB,GAAG,QAAmB;gBACpE,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,CAAC;gBAE/C,MAAM,aAAa,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;gBACrE,MAAM,QAAQ,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;gBAEpC,IAAI,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC;oBAAE,OAAO;gBAC1C,aAAa,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;gBAEzC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC;YAClD,CAAC,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { instanceConfig } from "../../..";
|
|
2
1
|
import { BBeforeCreate } from "../../../behaviors/BbeforeCreated";
|
|
3
2
|
import { BStore } from "../../../behaviors/BStore";
|
|
4
3
|
import { isEmptyObject } from "../../../utils/isEmptyObject";
|
|
4
|
+
import { instanceConfig } from "../../InstanceInject/instanceConfig";
|
|
5
5
|
import { computedWatchHandle } from "./computedWatchHandle";
|
|
6
6
|
import { hijack } from "./hijackHandle";
|
|
7
7
|
import { isPageCheck } from "./hijackHandle/isPageCheck";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/DefineComponent/normalizeOptions/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/api/DefineComponent/normalizeOptions/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AASrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAyCxE;;;;GAIG;AACH,MAAM,UAAU,gBAA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AAE,MAAM,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC;IACnF,CAAC;IAED,MAAM,CAAC,wBAAwB,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,wBAAwB,CAAC,CAAC,CAAC;IAE/E,mBAAmB;IACnB,MAAM,CACJ,wBAAwB,CAAC,SAAS,EAClC,UAAU,EACV,CAAC,WAAW,CAAC,mBAAmB,aAAnB,mBAAmB,uBAAnB,mBAAmB,CAAE,MAAM,CAAC,CAAC,CAC3C,CAAC;IAEF,iBAAiB;IACjB,IAAI,wBAAwB,CAAC,MAAM,IAAI,wBAAwB,CAAC,OAAO,EAAE,CAAC;QACxE,OAAO,CAAC,cAAc,CAAC,wBAAwB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC1E,CAAC;IAED,wDAAwD;IACxD,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAEpC,qBAAqB;IACrB,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;IAE9C,iDAAiD;IACjD,wBAAwB,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAEvD,OAAO,wBAAwB,CAAC;AAClC,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { IfExtends } from "hry-types/src/Any/_api";
|
|
2
2
|
import type { Select } from "hry-types/src/Object/_api";
|
|
3
3
|
import type { Detail, WMBaseEvent } from "../../../types/OfficialTypeAlias";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ComponentType } from "../../DefineComponent/ReturnType/ComponentType";
|
|
5
5
|
import type { CustomEventsDoc } from "../CustomEvents/CustomEventsDoc";
|
|
6
6
|
import type { Bubbles, BubblesCaptureComposed, BubblesComposed, Capture, CaptureComposed, CustomEventsTags } from "../CustomEvents/CustomEventsTag";
|
|
7
7
|
type FilterNormalFields<O extends object> = Select<O, Bubbles | Capture, "contains->">;
|
|
8
|
-
type GetBubblesOrCaptureEventsFromCompDoc<ComponentDocList extends
|
|
8
|
+
type GetBubblesOrCaptureEventsFromCompDoc<ComponentDocList extends ComponentType[], Result extends CustomEventsDoc = {}> = ComponentDocList extends [infer Head extends ComponentType, ...infer Rest extends ComponentType[]] ? GetBubblesOrCaptureEventsFromCompDoc<Rest, Result & (FilterNormalFields<Head["customEvents"] & {}>)> : Result;
|
|
9
9
|
type _AddSuffixForKey<key extends string, Value extends CustomEventsTags> = Value extends BubblesComposed ? `${key}_bubbles` | `${key}_bubbles_catch` : Value extends CaptureComposed ? `${key}_capture` | `${key}_capture_catch` : Value extends BubblesCaptureComposed ? `${key}_bubbles&capture` | `${key}_bubbles&capture_catch` : never;
|
|
10
10
|
type TransformCustomEventsDocTypeToFunctionTypeAndAddSuffix<T extends CustomEventsDoc> = {
|
|
11
11
|
[k in keyof T as _AddSuffixForKey<k & string, Extract<T[k], CustomEventsTags>>]?: (detail: Detail<Exclude<T[k], CustomEventsTags>>) => void;
|
|
12
12
|
};
|
|
13
|
-
type GetAllSubCustomEventsConstraint<ComponentDocList extends
|
|
13
|
+
type GetAllSubCustomEventsConstraint<ComponentDocList extends ComponentType[], AllCustomEvents extends CustomEventsDoc = GetBubblesOrCaptureEventsFromCompDoc<ComponentDocList>> = IfExtends<{}, AllCustomEvents, BaseEvent, TransformCustomEventsDocTypeToFunctionTypeAndAddSuffix<AllCustomEvents>>;
|
|
14
14
|
type BaseEvent = Record<string, (e: WMBaseEvent) => unknown>;
|
|
15
15
|
/**
|
|
16
16
|
* events字段约束 由自身事件和冒泡的子组件事件组成。带前缀是子组件事件,带后缀(_catch)表示阻止冒泡
|
|
17
17
|
*/
|
|
18
|
-
export type EventsConstraint<ComponentDocList extends
|
|
18
|
+
export type EventsConstraint<ComponentDocList extends ComponentType[] = []> = IfExtends<[
|
|
19
19
|
], ComponentDocList, BaseEvent, GetAllSubCustomEventsConstraint<ComponentDocList>>;
|
|
20
20
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { WMCompPageLifetimes, WMPageLifetimes } from "../../types/OfficialTypeAlias";
|
|
2
2
|
import type { LifetimesConstraint } from "./Lifetimes/LifetimesConstraint";
|
|
3
|
-
type
|
|
3
|
+
type _RootComponentType = {
|
|
4
4
|
isPage?: boolean;
|
|
5
5
|
properties?: object;
|
|
6
6
|
data?: object;
|
|
@@ -21,21 +21,22 @@ type _Validator<O, Doc, ErrKeys = Exclude<keyof O, keyof Doc>> = [ErrKeys] exten
|
|
|
21
21
|
/**
|
|
22
22
|
* RootComponent Api 返回的类型
|
|
23
23
|
* ```ts
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
24
|
+
* {
|
|
25
|
+
* isPage?: boolean;
|
|
26
|
+
* properties?: object;
|
|
27
|
+
* data?: object;
|
|
28
|
+
* computed?: object;
|
|
29
|
+
* customEvents?: object;
|
|
30
|
+
* methods?: object;
|
|
31
|
+
* events?: object;
|
|
32
|
+
* store?: object;
|
|
33
|
+
* watch?: Record<string, AnyFunction>;
|
|
34
|
+
* lifetimes?: LifetimesConstraint;
|
|
35
|
+
* pageLifetimes?: Partial<WMCompPageLifetimes & { load:AnyFunction }> | Partial<WMPageLifetimes>;
|
|
36
|
+
* export?:AnyFunction
|
|
37
|
+
* externalClasses?: string[];
|
|
37
38
|
* };
|
|
38
39
|
* ```
|
|
39
40
|
*/
|
|
40
|
-
export type
|
|
41
|
+
export type RootComponentType<O extends _Validator<O, _RootComponentType> = _RootComponentType> = O;
|
|
41
42
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RootComponentType.js","sourceRoot":"","sources":["../../../src/api/RootComponent/RootComponentType.ts"],"names":[],"mappings":""}
|
|
@@ -4,7 +4,7 @@ import type { Func } from "hry-types/src/Misc/Func";
|
|
|
4
4
|
import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
5
5
|
import type { ComputeObject } from "../../types/ComputeObj";
|
|
6
6
|
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
7
|
-
import type {
|
|
7
|
+
import type { ComponentType } from "../DefineComponent/ReturnType/ComponentType";
|
|
8
8
|
import type { IInjectAllData, IInjectStore } from "../InstanceInject/instanceConfig";
|
|
9
9
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
10
10
|
import type { ComputedOption } from "./Computed/ComputedOption";
|
|
@@ -34,7 +34,7 @@ import type { WatchOption } from "./Watch/WatchOption";
|
|
|
34
34
|
type RootComponentOptions<TEvents extends object, TIsPage extends boolean, TCustomEvents extends CustomEventConstraint, TMethods extends MethodsConstraint, TProperties extends PropertiesConstraint, TData extends object, TStore extends StoreConstraint, TComputed extends Record<string, Func>, EventsDoc extends object, CustomEventsDoc extends object, PropertiesDoc extends object, DataDoc extends object, StoreDoc extends object, ComputedDoc extends object> = MethodsOption<TMethods, keyof (EventsDoc & CustomEventsDoc)> & PropertiesOption<TProperties> & IsPageOption<TIsPage> & EventsOption<TEvents> & CustomEventsOption<TCustomEvents, keyof EventsDoc> & DataOption<TData, keyof PropertiesDoc> & StoreOption<TStore, keyof (PropertiesDoc & DataDoc)> & ComputedOption<TComputed, keyof (PropertiesDoc & DataDoc & StoreDoc), {
|
|
35
35
|
data: ComputeObject<DataDoc & Required<PropertiesDoc> & StoreDoc & ComputedDoc & IInjectAllData>;
|
|
36
36
|
}> & PageLifetimesOption<TIsPage, PropertiesDoc> & LifetimesOption & WatchOption<ComputedDoc & Required<PropertiesDoc> & DataDoc & StoreDoc & IInjectStore> & Partial<Omit<WMCompOtherOption, "pageLifetimes" | "definitionFilter" | "observers">> & ObserversOption<ComputedDoc & Required<PropertiesDoc> & DataDoc & StoreDoc & IInjectStore> & ThisType<RootComponentInstance<TIsPage, TMethods, DataDoc, DataDoc & Required<PropertiesDoc> & StoreDoc & ComputedDoc, CustomEventsDoc, StoreDoc>>;
|
|
37
|
-
type RootComponentConstructor<TComponentDocList extends
|
|
37
|
+
type RootComponentConstructor<TComponentDocList extends ComponentType[]> = <TEvents extends EventsConstraint<TComponentDocList>, TIsPage extends boolean = false, const TProperties extends PropertiesConstraint = {}, TData extends object = {}, TStore extends StoreConstraint = {}, TComputed extends ComputedConstraint = {}, TCustomEvents extends IfExtends<TIsPage, false, CustomEventConstraint, EmptyObject> = {}, TMethods extends MethodsConstraint = {}, EventsDoc extends object = IfExtends<EventsConstraint<TComponentDocList>, TEvents, {}, TEvents>, CustomEventsDoc extends object = GetCustomEventDoc<TCustomEvents>, PropertiesDoc extends object = GetPropertiesDoc<TProperties, TIsPage>, DataDoc extends object = TData, StoreDoc extends object = GetStoreDoc<TStore>, ComputedDoc extends object = GetComputedDoc<TComputed>>(options: RootComponentOptions<TEvents, TIsPage, TCustomEvents, TMethods, TProperties, TData, TStore, TComputed, EventsDoc, CustomEventsDoc, PropertiesDoc, DataDoc, StoreDoc, ComputedDoc>) => ComputeIntersection<IfExtends<TIsPage, false, {}, {
|
|
38
38
|
isPage: true;
|
|
39
39
|
}> & IfExtends<EmptyObject, PropertiesDoc, {}, {
|
|
40
40
|
properties: PropertiesDoc;
|
|
@@ -51,7 +51,7 @@ type RootComponentConstructor<TComponentDocList extends ComponentDoc[]> = <TEven
|
|
|
51
51
|
}> & IfExtends<EmptyObject, CustomEventsDoc, {}, {
|
|
52
52
|
customEvents: ComputeObject<CustomEventsDoc>;
|
|
53
53
|
}>>;
|
|
54
|
-
export declare function RootComponent<TComponentDocList extends
|
|
54
|
+
export declare function RootComponent<TComponentDocList extends ComponentType[] = []>(): RootComponentConstructor<TComponentDocList>;
|
|
55
55
|
export type RootComponentTrueOptions = {
|
|
56
56
|
isPage?: boolean;
|
|
57
57
|
properties?: PropertiesConstraint;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { SelectKeys } from "hry-types/src/Object/_api";
|
|
2
2
|
import type { Composed, CustomEventsTags } from "../RootComponent/CustomEvents/CustomEventsTag";
|
|
3
|
-
type
|
|
3
|
+
type _SubComponentType = {
|
|
4
4
|
[k in string]: string | number | bigint | boolean | symbol | null | Record<string, unknown> | unknown[] | CustomEventsTags;
|
|
5
5
|
};
|
|
6
|
-
type _Validator<O, ErrKeys = Exclude<keyof O, SelectKeys<O, Composed, "contains->">>> = [ErrKeys] extends [never] ?
|
|
6
|
+
type _Validator<O, ErrKeys = Exclude<keyof O, SelectKeys<O, Composed, "contains->">>> = [ErrKeys] extends [never] ? _SubComponentType : `${ErrKeys & string} 不是穿透事件`;
|
|
7
7
|
/**
|
|
8
8
|
* SubComponent API 返回类型
|
|
9
9
|
* @remarks 穿透的子组件自定义事件
|
|
@@ -13,5 +13,5 @@ type _Validator<O, ErrKeys = Exclude<keyof O, SelectKeys<O, Composed, "contains-
|
|
|
13
13
|
* };
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export type
|
|
16
|
+
export type SubComponentType<O extends _Validator<O> = _SubComponentType> = O;
|
|
17
17
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubComponentType.js","sourceRoot":"","sources":["../../../src/api/SubComponent/SubComponentType.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Contains } from "hry-types/src/Any/Contains";
|
|
2
2
|
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
3
3
|
import type { Detail, WMBaseEvent } from "../../../types/OfficialTypeAlias";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ComponentType } from "../../DefineComponent/ReturnType/ComponentType";
|
|
5
5
|
import type { Bubbles, Capture, CustomEventsTags } from "../../RootComponent/CustomEvents/CustomEventsTag";
|
|
6
6
|
/**
|
|
7
7
|
* 把组件事件类型转为函数类型,冒泡事件捕获事件会多一个加后缀(_catch)的key,表示阻止事件冒泡和捕获。
|
|
8
8
|
*/
|
|
9
|
-
export type SubEventsConstraint<CompDoc extends
|
|
9
|
+
export type SubEventsConstraint<CompDoc extends ComponentType> = {
|
|
10
10
|
[k in keyof CompDoc["customEvents"] as Contains<CompDoc["customEvents"][k], Bubbles | Capture> extends true ? (k | `${k & string}_catch`) : k]?: (e: IfExtends<WMBaseEvent, CompDoc["customEvents"][k], WMBaseEvent, Detail<Exclude<CompDoc["customEvents"][k], CustomEventsTags>>>) => void;
|
|
11
11
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { SelectKeys } from "hry-types/src/Object/_api";
|
|
2
2
|
import type { RemoveInnerData } from "../../../types/RemoveInnerData";
|
|
3
|
-
import type {
|
|
3
|
+
import type { ComponentType } from "../../DefineComponent/ReturnType/ComponentType";
|
|
4
4
|
type WXMLSign = "wxml";
|
|
5
5
|
type unionAddList<Keys extends string> = Keys | Keys[];
|
|
6
6
|
/**
|
|
7
7
|
* 子组件inherit字段约束,key为构建组件所需的properties字段,类型为根组件数据的key或key[]或`WXMLSign`。要求根数据类型为子数据类型的子类型。当key的值来自wxml(循环产生的子数据等情况)时用`WXMLSign`表示。
|
|
8
8
|
* @returns object
|
|
9
9
|
*/
|
|
10
|
-
export type InheritConstraint<AllRootData extends object, TComponentDoc extends
|
|
10
|
+
export type InheritConstraint<AllRootData extends object, TComponentDoc extends ComponentType> = {
|
|
11
11
|
[k in keyof TComponentDoc["properties"]]?: unionAddList<RemoveInnerData<SelectKeys<AllRootData, TComponentDoc["properties"][k]> & string>> | WXMLSign;
|
|
12
12
|
};
|
|
13
13
|
export {};
|