annil 1.7.2 → 1.7.4
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/dist/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.js +4 -4
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.js.map +1 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.js +2 -2
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.js.map +1 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/dependencesOptimize.d.ts +3 -0
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/dependencesOptimize.js +23 -0
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/dependencesOptimize.js.map +1 -0
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/initComputedAndGetCache.js +2 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/initComputedAndGetCache.js.map +1 -1
- package/dist/api/RootComponent/RootComponentDoc.d.ts +0 -1
- package/dist/api/SubComponent/SubComputed/GetSubComputedDoc.d.ts +0 -1
- package/dist/api/navigateTo.d.ts +0 -1
- package/dist/thirdLib/index.js +1 -2
- package/dist/thirdLib/index.js.map +1 -1
- package/dist/types/OfficialTypeAlias.d.ts +0 -4
- package/package.json +3 -3
- package/src/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.ts +5 -6
- package/src/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.ts +2 -2
- package/src/api/DefineComponent/assignOptions/computedWatchHandle/dependencesOptimize.ts +33 -0
- package/src/api/DefineComponent/assignOptions/computedWatchHandle/initComputedAndGetCache.ts +2 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/uniqueDependences.d.ts +0 -2
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/uniqueDependences.js +0 -40
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/uniqueDependences.js.map +0 -1
- package/src/api/DefineComponent/assignOptions/computedWatchHandle/uniqueDependences.ts +0 -98
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.4](https://github.com/missannil/annil/compare/v1.7.3...v1.7.4) (2024-06-30)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* jest.config.ts的transform项修复,update typescript version from 5.3.2 to 5.5.2 ([00e221c](https://github.com/missannil/annil/commit/00e221ca37b042f042715b26dd5d158c0671a30e))
|
|
13
|
+
|
|
14
|
+
## [1.7.3](https://github.com/missannil/annil/compare/v1.7.2...v1.7.3) (2024-05-03)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* 优化计算属性依赖 ([017ad55](https://github.com/missannil/annil/commit/017ad55d0bc3edcc2cdeec68474adba766da57b7))
|
|
20
|
+
|
|
7
21
|
## [1.7.2](https://github.com/missannil/annil/compare/v1.7.1...v1.7.2) (2024-04-30)
|
|
8
22
|
|
|
9
23
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { deepProxy, getProxyOriginalValue } from "./data-tracer";
|
|
2
|
+
import { removeSubDependences } from "./dependencesOptimize";
|
|
2
3
|
import { getPathsValue } from "./getPathsValue";
|
|
3
4
|
import { isEqual } from "./isEqual";
|
|
4
5
|
export function computedUpdater(isUpdated = false) {
|
|
@@ -14,13 +15,12 @@ export function computedUpdater(isUpdated = false) {
|
|
|
14
15
|
}
|
|
15
16
|
if (changed) {
|
|
16
17
|
const newDependences = [];
|
|
17
|
-
|
|
18
|
-
newValue = getProxyOriginalValue(newValue);
|
|
18
|
+
const newValue = itemCache.method.call({ data: deepProxy(this.data, newDependences) });
|
|
19
19
|
this.setData({
|
|
20
|
-
[key]: newValue,
|
|
20
|
+
[key]: getProxyOriginalValue(newValue),
|
|
21
21
|
});
|
|
22
22
|
isUpdated = true;
|
|
23
|
-
this.data.__computedCache__[key].dependences = newDependences;
|
|
23
|
+
this.data.__computedCache__[key].dependences = removeSubDependences(newDependences);
|
|
24
24
|
return computedUpdater.call(this, isUpdated);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computedUpdater.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,UAAU,eAAe,CAAiB,SAAS,GAAG,KAAK;IAC/D,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACnD,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,GAAG,IAAI,SAAS,CAAC,WAAW,EAAE,CAAC;YAExC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAGhE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9B,OAAO,GAAG,IAAI,CAAC;gBAEf,MAAM;YACR,CAAC;QACH,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,cAAc,GAAyB,EAAE,CAAC;YAChD,
|
|
1
|
+
{"version":3,"file":"computedUpdater.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.ts"],"names":[],"mappings":"AACA,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;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,MAAM,UAAU,eAAe,CAAiB,SAAS,GAAG,KAAK;IAC/D,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACnD,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,GAAG,IAAI,SAAS,CAAC,WAAW,EAAE,CAAC;YAExC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAGhE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9B,OAAO,GAAG,IAAI,CAAC;gBAEf,MAAM;YACR,CAAC;QACH,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,cAAc,GAAyB,EAAE,CAAC;YAChD,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC;YAGvF,IAAI,CAAC,OAAO,CAAC;gBACX,CAAC,GAAG,CAAC,EAAE,qBAAqB,CAAC,QAAQ,CAAC;aACvC,CAAC,CAAC;YAEH,SAAS,GAAG,IAAI,CAAC;YAGjB,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,WAAW,GAAG,oBAAoB,CAAC,cAAc,CAAC,CAAC;YAGpF,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { removePreviousDependence } from "./dependencesOptimize";
|
|
2
2
|
export function deepProxy(data, dependences, basePath = []) {
|
|
3
3
|
const handler = {
|
|
4
4
|
get(target, prop) {
|
|
@@ -9,7 +9,7 @@ export function deepProxy(data, dependences, basePath = []) {
|
|
|
9
9
|
if (prop in target && !target.hasOwnProperty(prop)) {
|
|
10
10
|
return typeof val === "function" ? val.bind(target) : val;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
removePreviousDependence(dependences, basePath);
|
|
13
13
|
const curPath = basePath.concat(prop);
|
|
14
14
|
dependences.push({ paths: curPath, val });
|
|
15
15
|
if (typeof val !== "object" || val === null)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-tracer.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"data-tracer.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,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,CA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ExB,GAAG,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ComputedDependence } from "./computedUpdater";
|
|
2
|
+
export declare function removeSubDependences(dependences: ComputedDependence[]): ComputedDependence[];
|
|
3
|
+
export declare function removePreviousDependence(dependences: ComputedDependence[], basePath: string[]): ComputedDependence[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function removeSubDependences(dependences) {
|
|
2
|
+
dependences.sort((a, b) => a.paths.length - b.paths.length);
|
|
3
|
+
for (let f = 0; f < dependences.length; f++) {
|
|
4
|
+
const sortPath = dependences[f].paths.toString();
|
|
5
|
+
for (let i = dependences.length - 1; i > f; i--) {
|
|
6
|
+
const curPath = dependences[i].paths.toString();
|
|
7
|
+
if (curPath.startsWith(sortPath)) {
|
|
8
|
+
dependences.splice(i, 1);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return dependences;
|
|
13
|
+
}
|
|
14
|
+
export function removePreviousDependence(dependences, basePath) {
|
|
15
|
+
if (dependences.length === 0 || basePath.length === 0)
|
|
16
|
+
return dependences;
|
|
17
|
+
const lastDependence = dependences[dependences.length - 1];
|
|
18
|
+
if (lastDependence.paths.toString() === basePath.toString()) {
|
|
19
|
+
dependences.pop();
|
|
20
|
+
}
|
|
21
|
+
return dependences;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=dependencesOptimize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencesOptimize.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/dependencesOptimize.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CAAC,WAAiC;IAEpE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EA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
2
|
+
import { removeSubDependences } from "./dependencesOptimize";
|
|
2
3
|
function isValidDependences(dependences, computedKeys) {
|
|
3
4
|
for (const { paths: path, val } of dependences) {
|
|
4
5
|
if ((val === undefined) && computedKeys.includes(path[0])) {
|
|
@@ -18,7 +19,7 @@ export function initComputedAndGetCache(options, computedConfig, initAllData, un
|
|
|
18
19
|
options.data[key] = initValue;
|
|
19
20
|
initAllData[key] = initValue;
|
|
20
21
|
computedCache[key] = {
|
|
21
|
-
dependences,
|
|
22
|
+
dependences: removeSubDependences(dependences),
|
|
22
23
|
method: computedFunc,
|
|
23
24
|
value: initValue,
|
|
24
25
|
};
|
package/dist/api/DefineComponent/assignOptions/computedWatchHandle/initComputedAndGetCache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initComputedAndGetCache.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/initComputedAndGetCache.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"initComputedAndGetCache.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/initComputedAndGetCache.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAe7D,SAAS,kBAAkB,CAAC,WAAiC,EAAE,YAAsB;IACnF,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,WAAW,EAAE,CAAC;QAC/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;IAGD,OAAO,IAAI,CAAC;AACd,CA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1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/thirdLib/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/thirdLib/index.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/// <reference types="miniprogram-api-typings" />
|
|
2
|
-
/// <reference types="miniprogram-api-typings" />
|
|
3
|
-
/// <reference types="miniprogram-api-typings" />
|
|
4
|
-
/// <reference types="miniprogram-api-typings" />
|
|
5
1
|
export type WMTriggerEventOption = WechatMiniprogram.Component.TriggerEventOption;
|
|
6
2
|
export type WMCustomEvent<Detail = undefined, Mark extends object = object, CurrentTargetDataset extends object = object, TargetDataset extends object = CurrentTargetDataset> = WechatMiniprogram.CustomEvent<Detail, Mark, CurrentTargetDataset, TargetDataset>;
|
|
7
3
|
export type WMBaseEvent<Mark extends object = object, CurrentTargetDataset extends object = object, TargetDataset extends object = CurrentTargetDataset> = WechatMiniprogram.BaseEvent<Mark, CurrentTargetDataset, TargetDataset>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "annil",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.4",
|
|
4
4
|
"description": "微信小程序(原生开发)插件",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"commitlint": "^17.6.5",
|
|
27
27
|
"eslint": "^8.54.0",
|
|
28
28
|
"eslint-plugin-tsdoc": "^0.2.17",
|
|
29
|
-
"hry-types": "^0.18.1",
|
|
30
29
|
"husky": "^8.0.3",
|
|
31
30
|
"jest": "^29.7.0",
|
|
32
31
|
"jest-environment-jsdom": "^29.7.0",
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
"mobx": "^6.9.0",
|
|
35
34
|
"prettier": "^2.8.8",
|
|
36
35
|
"ts-jest": "^29.1.1",
|
|
37
|
-
"typescript": "^5.
|
|
36
|
+
"typescript": "^5.4.5"
|
|
38
37
|
},
|
|
39
38
|
"files": [
|
|
40
39
|
"LICENSE",
|
|
@@ -53,6 +52,7 @@
|
|
|
53
52
|
"author": "missannil",
|
|
54
53
|
"license": "MIT",
|
|
55
54
|
"peerDependencies": {
|
|
55
|
+
"hry-types": "^0.18.1",
|
|
56
56
|
"miniprogram-api-typings": "^3.12.2"
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Instance } from "..";
|
|
2
2
|
import { deepProxy, getProxyOriginalValue } from "./data-tracer";
|
|
3
|
+
import { removeSubDependences } from "./dependencesOptimize";
|
|
3
4
|
import { getPathsValue } from "./getPathsValue";
|
|
4
5
|
|
|
5
6
|
import { isEqual } from "./isEqual";
|
|
@@ -22,19 +23,17 @@ export function computedUpdater(this: Instance, isUpdated = false): boolean {
|
|
|
22
23
|
}
|
|
23
24
|
if (changed) {
|
|
24
25
|
const newDependences: ComputedDependence[] = [];
|
|
25
|
-
|
|
26
|
+
const newValue = itemCache.method.call({ data: deepProxy(this.data, newDependences) });
|
|
26
27
|
|
|
27
28
|
// 更新值不会立即再次进入**函数,而是当前**函数运行完毕后触发**函数,
|
|
28
|
-
newValue = getProxyOriginalValue(newValue);
|
|
29
|
-
|
|
30
29
|
this.setData({
|
|
31
|
-
[key]: newValue,
|
|
30
|
+
[key]: getProxyOriginalValue(newValue),
|
|
32
31
|
});
|
|
33
32
|
|
|
34
33
|
isUpdated = true;
|
|
35
34
|
|
|
36
|
-
//
|
|
37
|
-
this.data.__computedCache__[key].dependences = newDependences;
|
|
35
|
+
// 更新依赖(优化)
|
|
36
|
+
this.data.__computedCache__[key].dependences = removeSubDependences(newDependences);
|
|
38
37
|
|
|
39
38
|
// 有一个计算属性更新就重新更新所有计算互相,避免后置依赖导致前置依赖错误
|
|
40
39
|
return computedUpdater.call(this, isUpdated);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
2
|
import type { ComputedDependence } from "./computedUpdater";
|
|
3
|
-
import {
|
|
3
|
+
import { removePreviousDependence } from "./dependencesOptimize";
|
|
4
4
|
|
|
5
5
|
export function deepProxy(
|
|
6
6
|
data: object,
|
|
@@ -18,7 +18,7 @@ export function deepProxy(
|
|
|
18
18
|
if (prop in target && !target.hasOwnProperty(prop)) {
|
|
19
19
|
return typeof val === "function" ? val.bind(target) : val;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
removePreviousDependence(dependences, basePath);
|
|
22
22
|
|
|
23
23
|
const curPath = basePath.concat(prop);
|
|
24
24
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ComputedDependence } from "./computedUpdater";
|
|
2
|
+
// 去除子依赖
|
|
3
|
+
export function removeSubDependences(dependences: ComputedDependence[]) {
|
|
4
|
+
// 把dependences按照路径长度排序
|
|
5
|
+
dependences.sort((a, b) => a.paths.length - b.paths.length);
|
|
6
|
+
|
|
7
|
+
// 从最长的路径开始遍历,如果当前路径是上一个路径的子路径,则删除当前路径
|
|
8
|
+
for (let f = 0; f < dependences.length; f++) {
|
|
9
|
+
const sortPath = dependences[f].paths.toString();
|
|
10
|
+
// 从后往前遍历,删除子依赖,保留父依赖
|
|
11
|
+
for (let i = dependences.length - 1; i > f; i--) {
|
|
12
|
+
const curPath = dependences[i].paths.toString();
|
|
13
|
+
if (curPath.startsWith(sortPath)) {
|
|
14
|
+
dependences.splice(i, 1);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return dependences;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 当前依赖是上一个依赖的子依赖时,去除上一个依赖
|
|
23
|
+
export function removePreviousDependence(dependences: ComputedDependence[], basePath: string[]) {
|
|
24
|
+
if (dependences.length === 0 || basePath.length === 0) return dependences;
|
|
25
|
+
|
|
26
|
+
const lastDependence = dependences[dependences.length - 1];
|
|
27
|
+
|
|
28
|
+
if (lastDependence.paths.toString() === basePath.toString()) {
|
|
29
|
+
dependences.pop();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return dependences;
|
|
33
|
+
}
|
package/src/api/DefineComponent/assignOptions/computedWatchHandle/initComputedAndGetCache.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { FinalOptionsOfComponent } from "..";
|
|
|
3
3
|
|
|
4
4
|
import type { ComputedDependence } from "./computedUpdater";
|
|
5
5
|
import { deepProxy, getProxyOriginalValue } from "./data-tracer";
|
|
6
|
+
import { removeSubDependences } from "./dependencesOptimize";
|
|
6
7
|
|
|
7
8
|
type ItemCache = {
|
|
8
9
|
dependences: ComputedDependence[];
|
|
@@ -64,7 +65,7 @@ export function initComputedAndGetCache(
|
|
|
64
65
|
initAllData[key] = initValue;
|
|
65
66
|
|
|
66
67
|
computedCache[key] = {
|
|
67
|
-
dependences,
|
|
68
|
+
dependences: removeSubDependences(dependences),
|
|
68
69
|
method: computedFunc,
|
|
69
70
|
value: initValue,
|
|
70
71
|
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
function sameDependences(dependences) {
|
|
2
|
-
for (let f = 0; f < dependences.length; f++) {
|
|
3
|
-
const firstPath = dependences[f].paths.toString();
|
|
4
|
-
for (let i = f + 1; i < dependences.length; i++) {
|
|
5
|
-
const curPath = dependences[i].paths.toString();
|
|
6
|
-
if (firstPath === curPath) {
|
|
7
|
-
dependences.splice(f, 1);
|
|
8
|
-
return sameDependences(dependences);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return dependences;
|
|
13
|
-
}
|
|
14
|
-
function serialDependences(dependences, basePath) {
|
|
15
|
-
const lastDependence = dependences[dependences.length - 1];
|
|
16
|
-
if (lastDependence.paths.toString() === basePath.toString()) {
|
|
17
|
-
dependences.pop();
|
|
18
|
-
}
|
|
19
|
-
return dependences;
|
|
20
|
-
}
|
|
21
|
-
function separatedDependences(dependences, basePath, prop) {
|
|
22
|
-
const lastDependence = dependences[dependences.length - 1].val;
|
|
23
|
-
if (typeof lastDependence === "string"
|
|
24
|
-
&& dependences[dependences.length - 2].paths.concat(lastDependence).toString()
|
|
25
|
-
=== basePath.concat(prop).toString()) {
|
|
26
|
-
dependences.splice(dependences.length - 2, 1);
|
|
27
|
-
}
|
|
28
|
-
return dependences;
|
|
29
|
-
}
|
|
30
|
-
export function uniqueDependences(dependences, basePath, prop) {
|
|
31
|
-
if (dependences.length === 0)
|
|
32
|
-
return dependences;
|
|
33
|
-
dependences = sameDependences(dependences);
|
|
34
|
-
dependences = serialDependences(dependences, basePath);
|
|
35
|
-
if (dependences.length >= 2) {
|
|
36
|
-
dependences = separatedDependences(dependences, basePath, prop);
|
|
37
|
-
}
|
|
38
|
-
return dependences;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=uniqueDependences.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uniqueDependences.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/assignOptions/computedWatchHandle/uniqueDependences.ts"],"names":[],"mappings":"AAEA,SAAS,eAAe,CAAC,WAAiC;IACxD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5C,MAAM,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QAClD,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChD,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;YAChD,IAAI,SAAS,KAAK,OAAO,EAAE,CAAC;gBAC1B,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;g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5B,WAAW,GAAG,oBAAoB,CAAC,WAAW,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import type { ComputedDependence } from "./computedUpdater";
|
|
2
|
-
// 相同依赖去重
|
|
3
|
-
function sameDependences(dependences: ComputedDependence[]) {
|
|
4
|
-
for (let f = 0; f < dependences.length; f++) {
|
|
5
|
-
const firstPath = dependences[f].paths.toString();
|
|
6
|
-
for (let i = f + 1; i < dependences.length; i++) {
|
|
7
|
-
const curPath = dependences[i].paths.toString();
|
|
8
|
-
if (firstPath === curPath) {
|
|
9
|
-
dependences.splice(f, 1);
|
|
10
|
-
|
|
11
|
-
return sameDependences(dependences);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return dependences;
|
|
17
|
-
}
|
|
18
|
-
// 当前依赖是上一个依赖的子依赖时,去除上一个依赖
|
|
19
|
-
function serialDependences(dependences: ComputedDependence[], basePath: string[]) {
|
|
20
|
-
const lastDependence = dependences[dependences.length - 1];
|
|
21
|
-
if (lastDependence.paths.toString() === basePath.toString()) {
|
|
22
|
-
dependences.pop();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return dependences;
|
|
26
|
-
}
|
|
27
|
-
// -2依赖 + -1val === 当前依赖 去除-2依赖
|
|
28
|
-
function separatedDependences(dependences: ComputedDependence[], basePath: string[], prop: string) {
|
|
29
|
-
const lastDependence = dependences[dependences.length - 1].val;
|
|
30
|
-
if (
|
|
31
|
-
typeof lastDependence === "string"
|
|
32
|
-
&& dependences[dependences.length - 2].paths.concat(lastDependence).toString()
|
|
33
|
-
=== basePath.concat(prop).toString()
|
|
34
|
-
) {
|
|
35
|
-
dependences.splice(dependences.length - 2, 1);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return dependences;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 依赖去重
|
|
43
|
-
*/
|
|
44
|
-
export function uniqueDependences(
|
|
45
|
-
dependences: ComputedDependence[],
|
|
46
|
-
basePath: string[],
|
|
47
|
-
prop: string,
|
|
48
|
-
): ComputedDependence[] {
|
|
49
|
-
if (dependences.length === 0) return dependences;
|
|
50
|
-
// 相同依赖去重 例如 [{path:['a','b']}, {path:['a','b']}] => [{path:['a','b'] }]
|
|
51
|
-
dependences = sameDependences(dependences);
|
|
52
|
-
|
|
53
|
-
// 连续依赖去除 当前依赖是上一个依赖的子依赖时,去除上一个依赖
|
|
54
|
-
dependences = serialDependences(dependences, basePath);
|
|
55
|
-
|
|
56
|
-
// -2依赖 + -1依赖 === 当前依赖 去除-2依赖
|
|
57
|
-
if (dependences.length >= 2) {
|
|
58
|
-
dependences = separatedDependences(dependences, basePath, prop);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return dependences;
|
|
62
|
-
}
|
|
63
|
-
// import type { ComputedDependence } from "./computedUpdater";
|
|
64
|
-
// export /**
|
|
65
|
-
// * 依赖去重
|
|
66
|
-
// * @example
|
|
67
|
-
// * ```ts
|
|
68
|
-
// * const dependences = [{path:['a','b']}, {path:['a','b','c']}, {path:['d','e']}, {path:['d']}]
|
|
69
|
-
// * const result = uniqueDependences(dependences)
|
|
70
|
-
// * // result = [{path:['a','b'] } ,{ path:['d'] }]
|
|
71
|
-
// * ```
|
|
72
|
-
// */
|
|
73
|
-
// function uniqueDependences(dependences: ComputedDependence[]): ComputedDependence[] {
|
|
74
|
-
// if (dependences.length === 1) return dependences;
|
|
75
|
-
// console.log("外部去重前", dependences);
|
|
76
|
-
|
|
77
|
-
// for (let f = 0; f < dependences.length; f++) {
|
|
78
|
-
// const firstPath = dependences[f].paths.join(".") + ".";
|
|
79
|
-
// for (let i = f + 1; i < dependences.length; i++) {
|
|
80
|
-
// const curPath = dependences[i].paths.join(".") + ".";
|
|
81
|
-
// if (firstPath.startsWith(curPath)) {
|
|
82
|
-
// // 例如 path[0] = 'a.b.c.',curPath = 'a.b.'
|
|
83
|
-
// dependences.splice(f, 1);
|
|
84
|
-
|
|
85
|
-
// return uniqueDependences(dependences);
|
|
86
|
-
// }
|
|
87
|
-
// if (curPath.startsWith(firstPath)) {
|
|
88
|
-
// // 例如 curPath = 'a.b.' path[0] = 'a.b.c.',
|
|
89
|
-
// dependences.splice(i, 1);
|
|
90
|
-
|
|
91
|
-
// return uniqueDependences(dependences);
|
|
92
|
-
// }
|
|
93
|
-
// }
|
|
94
|
-
// }
|
|
95
|
-
// console.log("外部去重后", dependences);
|
|
96
|
-
|
|
97
|
-
// return dependences;
|
|
98
|
-
// }
|