annil 1.6.5 → 1.7.2
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 +21 -0
- package/README.md +1 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.d.ts +1 -3
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.js +9 -6
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.js.map +1 -1
- package/dist/api/SubComponent/SubInherit/SubInheritConstraint.d.ts +2 -1
- package/dist/thirdLib/wm/scrollView.d.ts +0 -2
- package/dist/thirdLib/wm/swiper.d.ts +1 -1
- package/dist/thirdLib/wm/view.d.ts +4 -6
- package/package.json +1 -1
- package/src/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.ts +14 -10
- package/src/api/DefineComponent/assignOptions/computedWatchHandle/initComputedAndGetCache.ts +1 -1
- package/src/api/SubComponent/SubInherit/SubInheritConstraint.ts +4 -2
- package/src/api/SubComponent/SubInherit/test/error.test.ts +8 -0
- package/src/api/SubComponent/SubInherit/test/normal.test.ts +11 -0
- package/src/api/SubComponent/SubWatch/test/error.test.ts +3 -3
- package/src/thirdLib/wm/scrollView.ts +0 -2
- package/src/thirdLib/wm/swiper.ts +1 -1
- package/src/thirdLib/wm/view.ts +4 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
* 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
|
|
6
6
|
|
|
7
|
+
## [1.7.2](https://github.com/missannil/annil/compare/v1.7.1...v1.7.2) (2024-04-30)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* 1. 计算属性依赖优化和返回值为代理的问题 ([6f28738](https://github.com/missannil/annil/commit/6f28738256c1884334b440271741ee1efb9e5519))
|
|
13
|
+
|
|
14
|
+
## [1.7.1](https://github.com/missannil/annil/compare/v1.7.0...v1.7.1) (2024-04-12)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* 1.7.0action发布时npm密钥过期问题 ([0ad71b9](https://github.com/missannil/annil/commit/0ad71b96aaa02668a4052cd57ea2ff8c46598107))
|
|
20
|
+
|
|
21
|
+
## [1.7.0](https://github.com/missannil/annil/compare/v1.6.5...v1.7.0) (2024-04-11)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* subComponent的inherit字段加入数组类型,表示联合类型 ([a7930ff](https://github.com/missannil/annil/commit/a7930ff1abe18579bff6f1746911c2f30274325b))
|
|
27
|
+
|
|
7
28
|
## [1.6.5](https://github.com/missannil/annil/compare/v1.6.4...v1.6.5) (2024-02-13)
|
|
8
29
|
|
|
9
30
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { ComputedDependence } from "./computedUpdater";
|
|
2
2
|
export declare function deepProxy(data: object, dependences: ComputedDependence[], basePath?: string[]): object;
|
|
3
|
-
export declare function getProxyOriginalValue
|
|
4
|
-
__original__?: string;
|
|
5
|
-
}>(value: T): unknown;
|
|
3
|
+
export declare function getProxyOriginalValue(value: any): any;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { deepClone } from "../../../../utils/deepClone";
|
|
2
1
|
import { uniqueDependences } from "./uniqueDependences";
|
|
3
2
|
export function deepProxy(data, dependences, basePath = []) {
|
|
4
3
|
const handler = {
|
|
@@ -7,8 +6,8 @@ export function deepProxy(data, dependences, basePath = []) {
|
|
|
7
6
|
return target;
|
|
8
7
|
}
|
|
9
8
|
const val = target[prop];
|
|
10
|
-
if (
|
|
11
|
-
return val.bind(target);
|
|
9
|
+
if (prop in target && !target.hasOwnProperty(prop)) {
|
|
10
|
+
return typeof val === "function" ? val.bind(target) : val;
|
|
12
11
|
}
|
|
13
12
|
dependences = uniqueDependences(dependences, basePath, prop);
|
|
14
13
|
const curPath = basePath.concat(prop);
|
|
@@ -24,11 +23,15 @@ export function deepProxy(data, dependences, basePath = []) {
|
|
|
24
23
|
return new Proxy(data, handler);
|
|
25
24
|
}
|
|
26
25
|
export function getProxyOriginalValue(value) {
|
|
27
|
-
if (typeof value !== "object" || value === null
|
|
26
|
+
if (typeof value !== "object" || value === null) {
|
|
28
27
|
return value;
|
|
29
28
|
}
|
|
30
|
-
|
|
31
|
-
return
|
|
29
|
+
if (value.__original__)
|
|
30
|
+
return value.__original__;
|
|
31
|
+
const ret = Array.isArray(value) ? [] : {};
|
|
32
|
+
for (const key in value) {
|
|
33
|
+
ret[key] = getProxyOriginalValue(value[key]);
|
|
32
34
|
}
|
|
35
|
+
return ret;
|
|
33
36
|
}
|
|
34
37
|
//# sourceMappingURL=data-tracer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-tracer.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-tracer.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,WAAiC,EACjC,WAAqB,EAAE;IAEvB,MAAM,OAAO,GAAG;QACd,GAAG,CAAmB,MAAS,EAAE,IAAsB;YACrD,IAAI,IAAI,KAAK,cAAc,EAAE,CAAC;gBAC5B,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YAGzB,IAAI,IAAI,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC;gBACnD,OAAO,OAAO,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@ import type { SelectKeys } from "hry-types/src/Object/_api";
|
|
|
2
2
|
import type { RemoveInnerData } from "../../../types/RemoveInnerData";
|
|
3
3
|
import type { ComponentDoc } from "../../DefineComponent/ReturnType/ComponentDoc";
|
|
4
4
|
type WXMLSign = "wxml";
|
|
5
|
+
type unionAddList<Keys extends string> = Keys | Keys[];
|
|
5
6
|
export type InheritConstraint<AllRootData extends object, TComponentDoc extends ComponentDoc> = {
|
|
6
|
-
[k in keyof TComponentDoc["properties"]]?: RemoveInnerData<SelectKeys<AllRootData, TComponentDoc["properties"][k]> & string
|
|
7
|
+
[k in keyof TComponentDoc["properties"]]?: unionAddList<RemoveInnerData<SelectKeys<AllRootData, TComponentDoc["properties"][k]> & string>> | WXMLSign;
|
|
7
8
|
};
|
|
8
9
|
export {};
|
|
@@ -2,8 +2,6 @@ import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
|
|
|
2
2
|
import type { CreateComponentDoc } from "../../types/CreateComponentDoc";
|
|
3
3
|
export type ScrollView = CreateComponentDoc<"scrollView", {
|
|
4
4
|
properties: {
|
|
5
|
-
class?: string;
|
|
6
|
-
style?: string;
|
|
7
5
|
scroll_x?: boolean;
|
|
8
6
|
scroll_y?: boolean;
|
|
9
7
|
upper_threshold?: number | string;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { CreateComponentDoc } from "../../types/CreateComponentDoc";
|
|
2
2
|
export type View = CreateComponentDoc<"view", {
|
|
3
3
|
properties: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
hover_start_time?: number;
|
|
9
|
-
hover_stay_time?: number;
|
|
4
|
+
hoverClass?: string;
|
|
5
|
+
hoverStopPropagation?: boolean;
|
|
6
|
+
hoverStartTime?: number;
|
|
7
|
+
hoverStayTime?: number;
|
|
10
8
|
};
|
|
11
9
|
}>;
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
|
-
import { deepClone } from "../../../../utils/deepClone";
|
|
3
2
|
import type { ComputedDependence } from "./computedUpdater";
|
|
4
3
|
import { uniqueDependences } from "./uniqueDependences";
|
|
5
4
|
|
|
@@ -15,12 +14,10 @@ export function deepProxy(
|
|
|
15
14
|
}
|
|
16
15
|
const val = target[prop];
|
|
17
16
|
|
|
18
|
-
//
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
return (val as Function).bind(target);
|
|
17
|
+
// 自身没有但原型链上有的属性不收集依赖
|
|
18
|
+
if (prop in target && !target.hasOwnProperty(prop)) {
|
|
19
|
+
return typeof val === "function" ? val.bind(target) : val;
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
dependences = uniqueDependences(dependences, basePath, prop);
|
|
25
22
|
|
|
26
23
|
const curPath = basePath.concat(prop);
|
|
@@ -40,10 +37,17 @@ export function deepProxy(
|
|
|
40
37
|
return new Proxy(data, handler);
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
export function getProxyOriginalValue
|
|
44
|
-
if (typeof value !== "object" || value === null
|
|
40
|
+
export function getProxyOriginalValue(value: any): any {
|
|
41
|
+
if (typeof value !== "object" || value === null) {
|
|
45
42
|
return value;
|
|
46
|
-
} else {
|
|
47
|
-
return deepClone(value.__original__);
|
|
48
43
|
}
|
|
44
|
+
if (value.__original__) return value.__original__;
|
|
45
|
+
|
|
46
|
+
const ret = Array.isArray(value) ? [] : {};
|
|
47
|
+
for (const key in value) {
|
|
48
|
+
// @ts-ignore 隐式索引
|
|
49
|
+
ret[key] = getProxyOriginalValue(value[key]);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return ret;
|
|
49
53
|
}
|
package/src/api/DefineComponent/assignOptions/computedWatchHandle/initComputedAndGetCache.ts
CHANGED
|
@@ -15,7 +15,7 @@ type ComputedId = string;
|
|
|
15
15
|
export type ComputedCache = Record<ComputedId, ItemCache>;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* 如果依赖列表某项的首个字段值为undefined并且字段为其他计算属性字段 返回false
|
|
18
|
+
* 如果依赖列表某项的首个字段值为undefined并且字段为其他计算属性字段(即被依赖的计算字段写在了依赖他的计算字段后面) 返回false, 否则返回true表示依赖有效。
|
|
19
19
|
*/
|
|
20
20
|
function isValidDependences(dependences: ComputedDependence[], computedKeys: string[]): boolean {
|
|
21
21
|
for (const { paths: path, val } of dependences) {
|
|
@@ -4,12 +4,14 @@ import type { ComponentDoc } from "../../DefineComponent/ReturnType/ComponentDoc
|
|
|
4
4
|
|
|
5
5
|
type WXMLSign = "wxml";
|
|
6
6
|
|
|
7
|
+
type unionAddList<Keys extends string> = Keys | Keys[];
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
|
-
* 子组件inherit字段约束,key为构建组件所需的properties字段,类型为根组件数据的key或`WXMLSign`。要求根数据类型为子数据类型的子类型。当key的值来自wxml(循环产生的子数据等情况)时用`WXMLSign`表示。
|
|
10
|
+
* 子组件inherit字段约束,key为构建组件所需的properties字段,类型为根组件数据的key或key[]或`WXMLSign`。要求根数据类型为子数据类型的子类型。当key的值来自wxml(循环产生的子数据等情况)时用`WXMLSign`表示。
|
|
9
11
|
* @returns object
|
|
10
12
|
*/
|
|
11
13
|
export type InheritConstraint<AllRootData extends object, TComponentDoc extends ComponentDoc> = {
|
|
12
14
|
[k in keyof TComponentDoc["properties"]]?:
|
|
13
|
-
| RemoveInnerData<SelectKeys<AllRootData, TComponentDoc["properties"][k]> & string
|
|
15
|
+
| unionAddList<RemoveInnerData<SelectKeys<AllRootData, TComponentDoc["properties"][k]> & string>>
|
|
14
16
|
| WXMLSign;
|
|
15
17
|
};
|
|
@@ -54,3 +54,14 @@ SubComponent<Mock_RootDoc, Mock_CompDoc>()({
|
|
|
54
54
|
aaa_obj1: "" as "required_obj" | "optional_obj" | "wxml",
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
|
+
|
|
58
|
+
// 3 value为数组时,表示多个字段的联合类型
|
|
59
|
+
|
|
60
|
+
SubComponent<Mock_RootDoc, Mock_CompDoc>()({
|
|
61
|
+
inherit: {
|
|
62
|
+
aaa_num: ["optional_literal_num", "required_num"],
|
|
63
|
+
aaa_str: ["literal_str", "str"],
|
|
64
|
+
aaa_obj: "" as "required_obj" | "optional_obj" | ["required_obj" | "optional_obj"] | "wxml",
|
|
65
|
+
aaa_obj1: "" as "required_obj" | "optional_obj" | ["required_obj" | "optional_obj"] | "wxml",
|
|
66
|
+
},
|
|
67
|
+
});
|
|
@@ -14,16 +14,16 @@ SubComponent<{ events: { a: string } }, Wm.View>()({
|
|
|
14
14
|
*/
|
|
15
15
|
SubComponent<{ events: { a: string } }, Wm.View>()({
|
|
16
16
|
data: {
|
|
17
|
-
|
|
17
|
+
view_hoverClass: " h-100",
|
|
18
18
|
},
|
|
19
19
|
watch: {
|
|
20
|
-
|
|
20
|
+
view_hoverClass(newValue, oldValue) { // ok
|
|
21
21
|
newValue;
|
|
22
22
|
|
|
23
23
|
oldValue;
|
|
24
24
|
},
|
|
25
25
|
// @ts-expect-error 超出约束字段错误
|
|
26
|
-
|
|
26
|
+
view_xxxhoverClass() {
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
});
|
package/src/thirdLib/wm/view.ts
CHANGED
|
@@ -2,27 +2,25 @@ import type { CreateComponentDoc } from "../../types/CreateComponentDoc";
|
|
|
2
2
|
|
|
3
3
|
export type View = CreateComponentDoc<"view", {
|
|
4
4
|
properties: {
|
|
5
|
-
class?: string;
|
|
6
|
-
style?: string;
|
|
7
5
|
/**
|
|
8
6
|
* 指定按下去的样式类。当 hover-class="none" 时,没有点击态效果
|
|
9
7
|
* @defaultValue 'none'
|
|
10
8
|
*/
|
|
11
|
-
|
|
9
|
+
hoverClass?: string;
|
|
12
10
|
/**
|
|
13
11
|
* 指定是否阻止本节点的祖先节点出现点击态
|
|
14
12
|
* @defaultValue false
|
|
15
13
|
*/
|
|
16
|
-
|
|
14
|
+
hoverStopPropagation?: boolean;
|
|
17
15
|
/**
|
|
18
16
|
* 按住后多久出现点击态,单位毫秒
|
|
19
17
|
* @defaultValue 50
|
|
20
18
|
*/
|
|
21
|
-
|
|
19
|
+
hoverStartTime?: number;
|
|
22
20
|
/**
|
|
23
21
|
* 手指松开后点击态保留时间,单位毫秒
|
|
24
22
|
* @defaultValue 400
|
|
25
23
|
*/
|
|
26
|
-
|
|
24
|
+
hoverStayTime?: number;
|
|
27
25
|
};
|
|
28
26
|
}>;
|