annil 1.6.0 → 1.6.1
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 +8 -0
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.js +3 -2
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.js.map +1 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.d.ts +0 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.js +2 -13
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.js.map +1 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/initComputed.js +3 -2
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/initComputed.js.map +1 -1
- package/dist/api/RootComponent/CustomEvents/GetCustomEventDoc.d.ts +1 -2
- package/package.json +1 -1
- package/src/api/DefineComponent/ReturnType/test/normalComponentDoc.test.ts +10 -0
- package/src/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.ts +3 -3
- package/src/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.ts +3 -25
- package/src/api/DefineComponent/assignOptions/computedWatchHandle/initComputed.ts +3 -2
- package/src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts +1 -3
- package/src/api/RootComponent/CustomEvents/test/GetShortEventDoc.test.ts +1 -2
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
* 解决DetailedType不接收接口类型的错误 ([ae8acbf](https://github.com/missannil/annil/commit/ae8acbfc2e62f99db565c448ad9253aa549e78bb))
|
|
6
6
|
|
|
7
|
+
## [1.6.1](https://github.com/missannil/annil/compare/v1.6.0...v1.6.1) (2024-02-02)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* 修正自定义事件文档类型,去除readonlyDeep ([b4d329b](https://github.com/missannil/annil/commit/b4d329b8c1b90407fd714fa42784c2dcb0c705f8))
|
|
13
|
+
* 用deepClone代替unwarp以修复计算属性返回数据包含代理对象 ([38cc56a](https://github.com/missannil/annil/commit/38cc56a477a8adcaaf73f4cbef44cd8b701a175d))
|
|
14
|
+
|
|
7
15
|
## [1.6.0](https://github.com/missannil/annil/compare/v1.5.15...v1.6.0) (2024-02-01)
|
|
8
16
|
|
|
9
17
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deepClone } from "../../../../utils/deepClone";
|
|
2
|
+
import { deepProxy } from "./data-tracer";
|
|
2
3
|
import { getPathsValue } from "./getPathsValue";
|
|
3
4
|
import { isEqual } from "./isEqual";
|
|
4
5
|
export function computedUpdater(isUpdated = false) {
|
|
@@ -16,7 +17,7 @@ export function computedUpdater(isUpdated = false) {
|
|
|
16
17
|
const newDependences = [];
|
|
17
18
|
const newValue = itemCache.method.call({ data: deepProxy(this.data, newDependences) });
|
|
18
19
|
this.setData({
|
|
19
|
-
[key]:
|
|
20
|
+
[key]: deepClone(newValue),
|
|
20
21
|
});
|
|
21
22
|
isUpdated = true;
|
|
22
23
|
this.data.__computedCache__[key].dependences = newDependences;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computedUpdater.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computedUpdater.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC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export function deepProxy(data, dependences, basePath = []) {
|
|
2
3
|
const handler = {
|
|
3
4
|
get(target, prop) {
|
|
4
|
-
if (prop === "__rawObject__")
|
|
5
|
-
return target;
|
|
6
5
|
const val = target[prop];
|
|
7
6
|
if (basePath.length !== 0) {
|
|
8
7
|
const lastDependences = dependences[dependences.length - 1];
|
|
@@ -11,7 +10,7 @@ export function deepProxy(data, dependences, basePath = []) {
|
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
const curPath = basePath.concat(prop);
|
|
14
|
-
dependences.push({ paths: curPath, val:
|
|
13
|
+
dependences.push({ paths: curPath, val: deepClone(val) });
|
|
15
14
|
if (!Object.prototype.hasOwnProperty.call(target, prop) || typeof val === "function") {
|
|
16
15
|
return typeof val === "function" ? val.bind(target) : val;
|
|
17
16
|
}
|
|
@@ -25,14 +24,4 @@ export function deepProxy(data, dependences, basePath = []) {
|
|
|
25
24
|
};
|
|
26
25
|
return new Proxy(data, handler);
|
|
27
26
|
}
|
|
28
|
-
export function unwrap(wrapped) {
|
|
29
|
-
if (typeof wrapped !== "object" || wrapped === null) {
|
|
30
|
-
return wrapped;
|
|
31
|
-
}
|
|
32
|
-
const originalValue = wrapped.__rawObject__;
|
|
33
|
-
if (originalValue) {
|
|
34
|
-
wrapped = originalValue;
|
|
35
|
-
}
|
|
36
|
-
return wrapped;
|
|
37
|
-
}
|
|
38
27
|
//# 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":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAGxD,MAAM,UAAU,SAAS,CACvB,IAAY,EACZ,WAAiC,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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deepClone } from "../../../../utils/deepClone";
|
|
2
|
+
import { deepProxy } from "./data-tracer";
|
|
2
3
|
function isValidDependences(dependences, computedKeys) {
|
|
3
4
|
for (const { paths: path, val } of dependences) {
|
|
4
5
|
if ((val === undefined) && computedKeys.includes(path[0])) {
|
|
@@ -14,7 +15,7 @@ export function getItemCache(initAllData, computedKeys, computedFunc) {
|
|
|
14
15
|
return {
|
|
15
16
|
dependences: uniqueDependences(dependences),
|
|
16
17
|
method: computedFunc,
|
|
17
|
-
value:
|
|
18
|
+
value: deepClone(initValue),
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initComputed.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/initComputed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"initComputed.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/initComputed.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAa1C,SAAS,kBAAkB,CAAC,WAAiC,EAAE,YAAsB;IACnF,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,WAAW,EAAE,CAAC;QAG/C,IAAI,CAAC,GAAG,KAAK,SAAS,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1D,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,WAAmB,EACnB,YAAsB,EACtB,YAAkB;IAGlB,MAAM,WAAW,GAAyB,EAAE,CAAC;IAC7C,MAAM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O,iBAAiB,CAAC,WAAW,CAAC,CAAC;YACxC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAKD,MAAM,UAAU,YAAY,CAC1B,OAAgC,EAChC,cAAoC,EACpC,WAAmB,EACnB,eAAyB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,EACpD,gBAA+B,EAAE;IAIjC,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;QAE/B,MAAM,SAAS,GAAG,YAAY,CAAC,WAAW,EAAE,YAAY,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;QAG/E,YAAY,GAAG,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;QAEvD,IAAI,SAAS,KAAK,KAAK,EAAE,CAAC;YAExB,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;aAAM,CAAC;YACN,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;YAE7B,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC;YAG/B,WAAW,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC;YAEnC,aAAa,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;QACjC,CAAC;IACH,CAAC;IAED,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,aAAa,CAAC;IACvB,CAAC;IAGD,OAAO,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;AACzF,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
|
|
2
1
|
import type { DetailedType } from "../../../types/DetailedType";
|
|
3
2
|
import type { InferDetailedType } from "../../../types/InferDetailedType";
|
|
4
3
|
import type { CustomEventConstraint, FullCustomEvents, ShortCustomeEvents, SimpleCustomeEventsList } from "./CustomEventConstraint";
|
|
5
4
|
import type { AddTagForCustomEventsDoc } from "./CustomEventsTag";
|
|
6
|
-
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType ?
|
|
5
|
+
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType ? InferDetailedType<T> : T extends null ? null : T extends undefined ? undefined : T extends SimpleCustomeEventsList ? GetShortCustomEventsDoc<T[number]> : never;
|
|
7
6
|
export type GetFullCustomEventsDoc<T extends FullCustomEvents> = GetShortCustomEventsDoc<T["detail"]> | AddTagForCustomEventsDoc<T["options"]>;
|
|
8
7
|
export type GetCustomEventDoc<T extends CustomEventConstraint> = {
|
|
9
8
|
[k in keyof T]: T[k] extends ShortCustomeEvents ? GetShortCustomEventsDoc<T[k]> : GetShortCustomEventsDoc<T[k]["detail"]> | AddTagForCustomEventsDoc<T[k]["options"]>;
|
package/package.json
CHANGED
|
@@ -197,3 +197,13 @@ const ComponetDoc = DefineComponent({
|
|
|
197
197
|
});
|
|
198
198
|
|
|
199
199
|
Checking<typeof ComponetDoc, {}, Test.Pass>;
|
|
200
|
+
|
|
201
|
+
// 8 自定义事件文档类型与定义的类型相同
|
|
202
|
+
const rootComponent8 = RootComponent()({
|
|
203
|
+
customEvents: {
|
|
204
|
+
// 减少商品
|
|
205
|
+
decrease: Object as DetailedType<Mock_User>,
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
Checking<(typeof rootComponent8)["customEvents"]["decrease"], Mock_User, Test.Pass>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { deepClone } from "../../../../utils/deepClone";
|
|
1
2
|
import type { Instance } from "..";
|
|
2
|
-
|
|
3
|
-
import { deepProxy, unwrap } from "./data-tracer";
|
|
3
|
+
import { deepProxy } from "./data-tracer";
|
|
4
4
|
import { getPathsValue } from "./getPathsValue";
|
|
5
5
|
|
|
6
6
|
import { isEqual } from "./isEqual";
|
|
@@ -27,7 +27,7 @@ export function computedUpdater(this: Instance, isUpdated = false): boolean {
|
|
|
27
27
|
|
|
28
28
|
// 更新值不会立即再次进入**函数,而是当前**函数运行完毕后触发**函数,
|
|
29
29
|
this.setData({
|
|
30
|
-
[key]:
|
|
30
|
+
[key]: deepClone(newValue),
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
isUpdated = true;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { deepClone } from "../../../../utils/deepClone";
|
|
1
2
|
import type { ComputedDependence } from "./computedUpdater";
|
|
2
3
|
|
|
3
4
|
export function deepProxy(
|
|
@@ -6,16 +7,8 @@ export function deepProxy(
|
|
|
6
7
|
basePath: string[] = [],
|
|
7
8
|
): object {
|
|
8
9
|
const handler = {
|
|
9
|
-
get(target:
|
|
10
|
-
// // 得到原始的对象 在unwrap时使用
|
|
11
|
-
// console.log(target, prop);
|
|
12
|
-
|
|
13
|
-
if (prop === "__rawObject__") return target;
|
|
14
|
-
// @ts-ignore 隐式索引
|
|
10
|
+
get<T extends object>(target: T, prop: keyof T & string) {
|
|
15
11
|
const val = target[prop];
|
|
16
|
-
|
|
17
|
-
// console.log("获取依赖", prop, val);
|
|
18
|
-
|
|
19
12
|
// 依赖长度不为0时 去重
|
|
20
13
|
if (basePath.length !== 0) {
|
|
21
14
|
// 依赖去重
|
|
@@ -30,7 +23,7 @@ export function deepProxy(
|
|
|
30
23
|
|
|
31
24
|
// console.log(prop, val,'in');
|
|
32
25
|
|
|
33
|
-
dependences.push({ paths: curPath, val:
|
|
26
|
+
dependences.push({ paths: curPath, val: deepClone(val) });
|
|
34
27
|
|
|
35
28
|
// 自身方法或原型属性不代理
|
|
36
29
|
if (!Object.prototype.hasOwnProperty.call(target, prop) || typeof val === "function") {
|
|
@@ -42,7 +35,6 @@ export function deepProxy(
|
|
|
42
35
|
|
|
43
36
|
return deepProxy(val, dependences, curPath);
|
|
44
37
|
},
|
|
45
|
-
/* istanbul ignore next */
|
|
46
38
|
set(_target: object, prop: string) {
|
|
47
39
|
throw Error(`${prop}字段是只读的`);
|
|
48
40
|
},
|
|
@@ -50,17 +42,3 @@ export function deepProxy(
|
|
|
50
42
|
|
|
51
43
|
return new Proxy(data, handler);
|
|
52
44
|
}
|
|
53
|
-
|
|
54
|
-
export function unwrap(wrapped: any): unknown {
|
|
55
|
-
// 非引用值 直接返回
|
|
56
|
-
if (typeof wrapped !== "object" || wrapped === null) {
|
|
57
|
-
return wrapped;
|
|
58
|
-
}
|
|
59
|
-
// 是引用值 取原值
|
|
60
|
-
const originalValue = wrapped.__rawObject__;
|
|
61
|
-
if (originalValue) {
|
|
62
|
-
wrapped = originalValue;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return wrapped;
|
|
66
|
-
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
2
2
|
import type { FinalOptionsOfComponent } from "..";
|
|
3
3
|
|
|
4
|
+
import { deepClone } from "../../../../utils/deepClone";
|
|
4
5
|
import type { ComputedDependence } from "./computedUpdater";
|
|
5
|
-
import { deepProxy
|
|
6
|
+
import { deepProxy } from "./data-tracer";
|
|
6
7
|
|
|
7
8
|
type ItemCache = {
|
|
8
9
|
dependences: ComputedDependence[];
|
|
@@ -41,7 +42,7 @@ export function getItemCache(
|
|
|
41
42
|
// 去重 避免 如: ` age(){ return this.data.xxx.num + this.data.xxx.str + this.data.xxx} ` 造成的多个依赖相同情况。应就要一个 xxx
|
|
42
43
|
dependences: uniqueDependences(dependences),
|
|
43
44
|
method: computedFunc,
|
|
44
|
-
value:
|
|
45
|
+
value: deepClone(initValue),
|
|
45
46
|
};
|
|
46
47
|
} else {
|
|
47
48
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
|
|
2
1
|
import type { DetailedType } from "../../../types/DetailedType";
|
|
3
2
|
import type { InferDetailedType } from "../../../types/InferDetailedType";
|
|
4
3
|
import type {
|
|
@@ -9,8 +8,7 @@ import type {
|
|
|
9
8
|
} from "./CustomEventConstraint";
|
|
10
9
|
import type { AddTagForCustomEventsDoc } from "./CustomEventsTag";
|
|
11
10
|
|
|
12
|
-
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType
|
|
13
|
-
? ReadonlyDeep<InferDetailedType<T>>
|
|
11
|
+
export type GetShortCustomEventsDoc<T extends ShortCustomeEvents> = T extends DetailedType ? InferDetailedType<T>
|
|
14
12
|
: T extends null ? null
|
|
15
13
|
: T extends undefined ? undefined
|
|
16
14
|
: T extends SimpleCustomeEventsList ? GetShortCustomEventsDoc<T[number]>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
2
|
|
|
3
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
|
|
4
3
|
import type { Mock_User } from "../../Properties/test/normalRequired.test";
|
|
5
4
|
import type { GetShortCustomEventsDoc } from "../GetCustomEventDoc";
|
|
6
5
|
import { mock_shortCustomEvents } from "./normal.test";
|
|
@@ -31,6 +30,6 @@ Checking<ListResult, ListExpected, Test.Pass>;
|
|
|
31
30
|
|
|
32
31
|
type ObjResult = GetShortCustomEventsDoc<typeof mock_shortCustomEvents["obj"]>;
|
|
33
32
|
|
|
34
|
-
export type ObjExpected =
|
|
33
|
+
export type ObjExpected = Mock_User;
|
|
35
34
|
|
|
36
35
|
Checking<ObjResult, ObjExpected, Test.Pass>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
|
|
3
2
|
import { type DetailedType, RootComponent } from "../../../..";
|
|
4
3
|
import type { Mock_User } from "../../Properties/test/normalRequired.test";
|
|
5
4
|
import type { CustomEventConstraint, FullCustomEvents, ShortCustomeEvents } from "../CustomEventConstraint";
|
|
@@ -71,7 +70,7 @@ type RootDoc = {
|
|
|
71
70
|
nothing: undefined;
|
|
72
71
|
unionStr: "male" | "female";
|
|
73
72
|
union: string | 0 | 1 | 2 | null;
|
|
74
|
-
obj:
|
|
73
|
+
obj: Mock_User;
|
|
75
74
|
// 带options字段 通过联合类型加入。
|
|
76
75
|
bubbles: string | Bubbles;
|
|
77
76
|
capturePhase: null | Capture;
|