annil 1.7.5-beta.4 → 1.7.6
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 +14 -0
- package/README.md +45 -38
- 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/getPropertiesValue.js +1 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/getPropertiesValue.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/DefineComponent/normalizeOptions/internalFieldProtection.js +1 -0
- package/dist/api/DefineComponent/normalizeOptions/internalFieldProtection.js.map +1 -1
- package/dist/api/RootComponent/Events/EventsConstraint.d.ts +4 -4
- package/dist/api/RootComponent/PageLifetimes/PageLifetimesOption.d.ts +3 -1
- package/dist/api/RootComponent/Properties/GetPropertiesDoc.d.ts +2 -1
- package/dist/api/RootComponent/Properties/GetRequiredDoc.d.ts +2 -2
- 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 +5 -4
- package/dist/api/RootComponent/index.js.map +1 -1
- 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/SubComputed/SubComputedOption.d.ts +2 -2
- 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 +9 -6
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/behaviors/BStore.d.ts +1 -1
- package/dist/behaviors/BStore.js +33 -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/RemoveNullOfRequired.d.ts +7 -0
- package/dist/types/RemoveNullOfRequired.js +2 -0
- package/dist/types/RemoveNullOfRequired.js.map +1 -0
- package/dist/types/ReplacePrefix.d.ts +2 -2
- package/dist/utils/assertNonNullable.js +1 -0
- package/dist/utils/assertNonNullable.js.map +1 -1
- 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/getPropertiesValue.ts +1 -0
- package/src/api/DefineComponent/normalizeOptions/computedWatchHandle/index.ts +2 -2
- package/src/api/DefineComponent/normalizeOptions/index.ts +1 -1
- package/src/api/DefineComponent/normalizeOptions/internalFieldProtection.ts +1 -0
- package/src/api/RootComponent/Computed/test/normal.test.ts +20 -0
- package/src/api/RootComponent/Events/EventsConstraint.ts +5 -5
- package/src/api/RootComponent/Events/test/normal.test.ts +5 -5
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +2 -4
- package/src/api/RootComponent/PageLifetimes/PageLifetimesOption.ts +4 -1
- package/src/api/RootComponent/PageLifetimes/test/normal.test.ts +26 -0
- package/src/api/RootComponent/Properties/GetOptionalDoc.ts +4 -4
- package/src/api/RootComponent/Properties/GetPropertiesDoc.ts +2 -1
- package/src/api/RootComponent/Properties/GetRequiredDoc.ts +9 -23
- package/src/api/RootComponent/{RootComponentDoc.ts → RootComponentType.ts} +16 -15
- package/src/api/RootComponent/index.ts +10 -4
- package/src/api/SubComponent/{SubComponentDoc.ts → SubComponentType.ts} +3 -3
- package/src/api/SubComponent/SubComputed/SubComputedOption.ts +2 -0
- package/src/api/SubComponent/SubComputed/test/error.test.ts +3 -3
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +5 -5
- 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 +18 -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 +17 -11
- package/src/behaviors/BStore.ts +37 -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/utils/assertNonNullable.ts +1 -0
- 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,20 @@
|
|
|
4
4
|
|
|
5
5
|
* 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
|
|
6
6
|
|
|
7
|
+
## [1.7.6](https://github.com/missannil/annil/compare/v1.7.5...v1.7.6) (2024-08-10)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* 1.7.6 ([e0e83c7](https://github.com/missannil/annil/commit/e0e83c7f44512abe9475d93b051a4e3364513b79))
|
|
13
|
+
|
|
14
|
+
## [1.7.5](https://github.com/missannil/annil/compare/v1.7.5-beta.4...v1.7.5) (2024-08-08)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Miscellaneous Chores
|
|
18
|
+
|
|
19
|
+
* 更改README,SubComponentDoc->SubComponentType,RootComponentDoc->RootComponentType ([073d273](https://github.com/missannil/annil/commit/073d2733f5b15923d67f3a04a7a15902f73a9205))
|
|
20
|
+
|
|
7
21
|
## [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
22
|
|
|
9
23
|
|
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`错误,并可一键修复,不必在书写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
|
+
# 使用状态管理
|
|
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,31 @@ annil(安奈儿)是微信小程序原生开发插件。她会让你获得新的
|
|
|
101
97
|
module.exports = require("./mobx.cjs.production.min.js");
|
|
102
98
|
```
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
100
|
+
开发者工具左上部工具栏——工具——构建npm
|
|
101
|
+
3. tsconfig.json推荐配置(使用ts开发时)
|
|
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
|
+
"exactOptionalPropertyTypes": true, // 带有?标志的属性类型不在包含undefined类型
|
|
112
|
+
"noEmit": true, // 编译时不生成文件。
|
|
113
|
+
"strictFunctionTypes": false, // 忽略函数参数逆变引起的问题
|
|
114
|
+
"types": [
|
|
115
|
+
"hry-types",
|
|
116
|
+
"mobx",
|
|
117
|
+
"miniprogram-api-typings"
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
"include": [
|
|
121
|
+
"**/*.ts"
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
```
|
|
118
125
|
|
|
119
126
|
### 使用文档
|
|
120
127
|
|
|
@@ -122,20 +129,20 @@ annil(安奈儿)是微信小程序原生开发插件。她会让你获得新的
|
|
|
122
129
|
|
|
123
130
|
[DefineComponent](./doc/api/DefineComponent.md)
|
|
124
131
|
|
|
125
|
-
[
|
|
132
|
+
[RootComponent](./doc/api/RootComponent.md)
|
|
126
133
|
|
|
127
134
|
[SubComponent](./doc/api/SubComponent.md)
|
|
128
135
|
|
|
129
|
-
- **
|
|
136
|
+
- **常用API**
|
|
130
137
|
|
|
131
138
|
[navigateTo](./doc/api/navigateTo.md)
|
|
132
139
|
|
|
133
|
-
-
|
|
140
|
+
- 实用泛型
|
|
141
|
+
|
|
142
|
+
[CreateComponentType](./src/types/CreateComponentType.ts)
|
|
143
|
+
|
|
144
|
+
[ExtendComponentType](./src/types/ExtendComponentType.ts)
|
|
134
145
|
|
|
135
146
|
### 更新日志
|
|
136
147
|
|
|
137
148
|
[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,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C;YACtC,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/getPropertiesValue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPropertiesValue.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/normalizeOptions/computedWatchHandle/getPropertiesValue.ts"],"names":[],"mappings":"AASA,SAAS,sBAAsB,CAC7B,QAAwB;IAExB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,MAAM;YACT,OAAO,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,CAAC,CAAC;QACX,KAAK,KAAK;YACR,OAAO,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,IAAI,CAAC;QACd,KAAK,OAAO;YACV,OAAO,KAAK,CAAC;QACf;YACE,MAAM,KAAK,CACT,+DAA+D,CAChE,CAAC;IACN,CAAC;AACH,CAAC;AACD,SAAS,gBAAgB,CAAC,MAAuB;IAC/C,OAAO,MAAM,YAAY,QAAQ,CAAC;AACpC,CAAC;AACD,SAAS,eAAe,CAAC,MAAuB;IAC9C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC;AACD,MAAM,UAAU,kBAAkB,CAAC,aAA+C;IAChF,IAAI,aAAa,KAAK,SAAS;QAAE,OAAO;IACxC,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,kBAAkB;YAClB,MAAM,CAAC,GAAG,CAAC,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;aAAM,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,kBAAkB;YAClB,MAAM,CAAC,GAAG,CAAC,GAAG,sBAAsB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,kBAAkB;YAClB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"getPropertiesValue.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/normalizeOptions/computedWatchHandle/getPropertiesValue.ts"],"names":[],"mappings":"AASA,SAAS,sBAAsB,CAC7B,QAAwB;IAExB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,MAAM;YACT,OAAO,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,CAAC,CAAC;QACX,KAAK,KAAK;YACR,OAAO,EAAE,CAAC;QACZ,KAAK,MAAM;YACT,OAAO,IAAI,CAAC;QACd,KAAK,OAAO;YACV,OAAO,KAAK,CAAC;QACf;YACE,0BAA0B;YAC1B,MAAM,KAAK,CACT,+DAA+D,CAChE,CAAC;IACN,CAAC;AACH,CAAC;AACD,SAAS,gBAAgB,CAAC,MAAuB;IAC/C,OAAO,MAAM,YAAY,QAAQ,CAAC;AACpC,CAAC;AACD,SAAS,eAAe,CAAC,MAAuB;IAC9C,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC;AACD,MAAM,UAAU,kBAAkB,CAAC,aAA+C;IAChF,IAAI,aAAa,KAAK,SAAS;QAAE,OAAO;IACxC,MAAM,MAAM,GAAG,EAAE,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC7B,kBAAkB;YAClB,MAAM,CAAC,GAAG,CAAC,GAAG,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;aAAM,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,kBAAkB;YAClB,MAAM,CAAC,GAAG,CAAC,GAAG,sBAAsB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,kBAAkB;YAClB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { deepEqual } from "../../../../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;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAMhE,SAAS,iBAAiB,CAAC,IAAqC,EAAE,WAAmB;IACnF,MAAM,aAAa,GAAG,EAAE,CAAC;IACzB,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,kBAAkB;QAClB,aAAa,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AACD,MAAM,UAAU,mBAAmB,CAAC,OAAgC;IAClE,iBAAiB;IACjB,MAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IACxC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAClE,IAAI,cAAc,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,CAAC;QACrD,wCAAwC;QAExC,MAAM,qBAAqB,GAAG,uBAAuB,CAAC,OAAO,EAAE,cAAc,kCACxE,OAAO,CAAC,IAAI,GACZ,kBAAkB,EACrB,CAAC;QAEH,Y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a,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,4BAA4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"internalFieldProtection.js","sourceRoot":"","sources":["../../../../src/api/DefineComponent/normalizeOptions/internalFieldProtection.ts"],"names":[],"mappings":"AAEA,OAAO;AACP,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC5C,IAAI,EAAE,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,mBAAmB,CAAC;CACpE,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,wBAAiD;IACvF,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACvE,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAEjE,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACnC,IAAI,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACxC,MAAM,KAAK,CAAC,cAAc,GAAG,YAAY,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,MAAM,KAAK,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
1
|
+
{"version":3,"file":"internalFieldProtection.js","sourceRoot":"","sources":["../../../../src/api/DefineComponent/normalizeOptions/internalFieldProtection.ts"],"names":[],"mappings":"AAEA,OAAO;AACP,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,CAAC,UAAU,EAAE,qBAAqB,CAAC;IAC5C,IAAI,EAAE,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,mBAAmB,CAAC;CACpE,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,wBAAiD;IACvF,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACvE,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;IAEjE,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACnC,IAAI,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACxC,MAAM,KAAK,CAAC,cAAc,GAAG,YAAY,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;IACD,KAAK,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;QAChC,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACrC,4BAA4B;YAC5B,MAAM,KAAK,CAAC,WAAW,GAAG,YAAY,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;AACH,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,8 @@
|
|
|
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 { ComputeObject } from "../../../types/ComputeObj";
|
|
3
4
|
import type { WMCompPageLifetimes, WMPageLifetimes } from "../../../types/OfficialTypeAlias";
|
|
5
|
+
import type { RemoveNullOfRequired } from "../../../types/RemoveNullOfRequired";
|
|
4
6
|
export type PageLifetimesOption<TIsPage extends boolean, PropertiesDoc extends object> = IfExtends<TIsPage, false, {
|
|
5
7
|
pageLifetimes?: ComputeIntersection<Partial<WMCompPageLifetimes> & {
|
|
6
8
|
/**
|
|
@@ -18,6 +20,6 @@ export type PageLifetimesOption<TIsPage extends boolean, PropertiesDoc extends o
|
|
|
18
20
|
*
|
|
19
21
|
* 页面加载时触发。一个页面只会调用一次,可以在 onLoad 的参数中获取Properties定义的数据。
|
|
20
22
|
*/
|
|
21
|
-
onLoad?: (props: PropertiesDoc) => void | Promise<void>;
|
|
23
|
+
onLoad?: (props: ComputeObject<RemoveNullOfRequired<PropertiesDoc>>) => void | Promise<void>;
|
|
22
24
|
}>;
|
|
23
25
|
}>;
|
|
@@ -3,9 +3,10 @@ import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
|
3
3
|
import type { GetOptionalDoc } from "./GetOptionalDoc";
|
|
4
4
|
import type { GetRequiredDoc } from "./GetRequiredDoc";
|
|
5
5
|
import type { OptionalType, PropertiesConstraint } from "./PropertiesConstraint";
|
|
6
|
-
type _GetPropertiesDoc<TProperties extends PropertiesConstraint, TIsPage extends boolean, OptionalDoc extends object = GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>, RequiredDoc extends object = GetRequiredDoc<Omit<TProperties, keyof OptionalDoc
|
|
6
|
+
type _GetPropertiesDoc<TProperties extends PropertiesConstraint, TIsPage extends boolean, OptionalDoc extends object = GetOptionalDoc<Select<TProperties, OptionalType>, TIsPage>, RequiredDoc extends object = GetRequiredDoc<Omit<TProperties, keyof OptionalDoc>>> = ComputeIntersection<OptionalDoc & RequiredDoc>;
|
|
7
7
|
/**
|
|
8
8
|
* properties字段的文档类型
|
|
9
|
+
* @remarks 必传的字段如果是object,要联合上null类型,选传的object根据是否是页面来决定是否加null
|
|
9
10
|
*/
|
|
10
11
|
export type GetPropertiesDoc<TProperties extends PropertiesConstraint, TisPage extends boolean> = _GetPropertiesDoc<TProperties, TisPage>;
|
|
11
12
|
export {};
|
|
@@ -6,6 +6,6 @@ import type { RequiredSingle, RequiredType } from "./PropertiesConstraint";
|
|
|
6
6
|
* 获取properties必传字段的文档类型
|
|
7
7
|
* @remarks 小程序中必传字段如果是object,默认类型为null,所以组件文档对象类型要联合上null类型
|
|
8
8
|
*/
|
|
9
|
-
export type GetRequiredDoc<TProperties extends Record<string, RequiredType
|
|
10
|
-
-readonly [k in keyof TProperties]: IfExtends<TProperties[k], RequiredSingle,
|
|
9
|
+
export type GetRequiredDoc<TProperties extends Record<string, RequiredType>> = {
|
|
10
|
+
-readonly [k in keyof TProperties]: IfExtends<TProperties[k], RequiredSingle, AddNullForObject<InferDetailedType<TProperties[k]>>, AddNullForObject<InferDetailedType<TProperties[k]["type"]> | InferDetailedType<TProperties[k]["optionalTypes"][number]>>>;
|
|
11
11
|
};
|
|
@@ -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,8 @@ 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 { RemoveNullOfRequired } from "../../types/RemoveNullOfRequired";
|
|
8
|
+
import type { ComponentType } from "../DefineComponent/ReturnType/ComponentType";
|
|
8
9
|
import type { IInjectAllData, IInjectStore } from "../InstanceInject/instanceConfig";
|
|
9
10
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
10
11
|
import type { ComputedOption } from "./Computed/ComputedOption";
|
|
@@ -34,10 +35,10 @@ import type { WatchOption } from "./Watch/WatchOption";
|
|
|
34
35
|
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
36
|
data: ComputeObject<DataDoc & Required<PropertiesDoc> & StoreDoc & ComputedDoc & IInjectAllData>;
|
|
36
37
|
}> & 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
|
|
38
|
+
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
39
|
isPage: true;
|
|
39
40
|
}> & IfExtends<EmptyObject, PropertiesDoc, {}, {
|
|
40
|
-
properties: PropertiesDoc
|
|
41
|
+
properties: IfExtends<false, TIsPage, PropertiesDoc, RemoveNullOfRequired<PropertiesDoc>>;
|
|
41
42
|
}> & IfExtends<EmptyObject, DataDoc, {}, {
|
|
42
43
|
data: DataDoc;
|
|
43
44
|
}> & IfExtends<EmptyObject, StoreDoc, {}, {
|
|
@@ -51,7 +52,7 @@ type RootComponentConstructor<TComponentDocList extends ComponentDoc[]> = <TEven
|
|
|
51
52
|
}> & IfExtends<EmptyObject, CustomEventsDoc, {}, {
|
|
52
53
|
customEvents: ComputeObject<CustomEventsDoc>;
|
|
53
54
|
}>>;
|
|
54
|
-
export declare function RootComponent<TComponentDocList extends
|
|
55
|
+
export declare function RootComponent<TComponentDocList extends ComponentType[] = []>(): RootComponentConstructor<TComponentDocList>;
|
|
55
56
|
export type RootComponentTrueOptions = {
|
|
56
57
|
isPage?: boolean;
|
|
57
58
|
properties?: PropertiesConstraint;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/RootComponent/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/RootComponent/index.ts"],"names":[],"mappings":"AA+IA,MAAM,UAAU,aAAa;IAM3B,8DAA8D;IAC9D,OAAO,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC;AACnC,CAAC"}
|