annil 1.5.1 → 1.5.3
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 +15 -0
- package/README.md +22 -9
- package/dist/api/DefineComponent/collectOptionsForComponent.d.ts +1 -0
- package/dist/api/DefineComponent/collectOptionsForComponent.js +2 -1
- package/dist/api/DefineComponent/collectOptionsForComponent.js.map +1 -1
- package/dist/api/InstanceInject/instanceConfig.d.ts +6 -5
- package/dist/api/InstanceInject/instanceConfig.js.map +1 -1
- package/dist/api/RootComponent/Instance/RootComponentInstance.d.ts +3 -3
- package/dist/api/RootComponent/Observers/ObserversOption.d.ts +20 -0
- package/dist/api/RootComponent/Observers/ObserversOption.js +2 -0
- package/dist/api/RootComponent/Observers/ObserversOption.js.map +1 -0
- package/dist/api/RootComponent/RootComponentDoc.d.ts +1 -0
- package/dist/api/RootComponent/Watch/WatchOption.d.ts +2 -4
- package/dist/api/RootComponent/index.d.ts +3 -2
- package/dist/api/RootComponent/index.js.map +1 -1
- package/dist/api/SubComponent/SubObservers/SubObserversOption.d.ts +2 -0
- package/dist/api/SubComponent/SubObservers/SubObserversOption.js +2 -0
- package/dist/api/SubComponent/SubObservers/SubObserversOption.js.map +1 -0
- package/dist/api/SubComponent/index.d.ts +3 -1
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/getPathsValue.js +3 -0
- package/dist/behaviors/BComputedAndWatch/getPathsValue.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/index.js +3 -1
- package/dist/behaviors/BComputedAndWatch/index.js.map +1 -1
- package/dist/behaviors/BComputedAndWatch/isEqual.d.ts +1 -1
- package/dist/behaviors/BComputedAndWatch/isEqual.js +38 -10
- package/dist/behaviors/BComputedAndWatch/isEqual.js.map +1 -1
- package/dist/thirdLib/index.js +2 -1
- package/dist/thirdLib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/DefineComponent/collectOptionsForComponent.ts +4 -2
- package/src/api/InstanceInject/instanceConfig.ts +7 -5
- package/src/api/InstanceInject/test/normal.test.ts +1 -1
- package/src/api/RootComponent/Computed/test/normal.test.ts +1 -1
- package/src/api/RootComponent/Data/test/normal.test.ts +1 -1
- package/src/api/RootComponent/Instance/RootComponentInstance.ts +3 -3
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +1 -1
- package/src/api/RootComponent/Lifetimes/test/normal.test.ts +1 -1
- package/src/api/RootComponent/Observers/ObserversOption.ts +60 -0
- package/src/api/RootComponent/Observers/test/normal.test.ts +25 -0
- package/src/api/RootComponent/Properties/test/normalEmpty.test.ts +2 -2
- package/src/api/RootComponent/Properties/test/normalOptional.test.ts +1 -1
- package/src/api/RootComponent/Properties/test/normalRequired.test.ts +1 -1
- package/src/api/RootComponent/RootComponentDoc.ts +1 -0
- package/src/api/RootComponent/Watch/WatchOption.ts +28 -19
- package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +5 -0
- package/src/api/RootComponent/Watch/test/WtachInject.test.ts +2 -7
- package/src/api/RootComponent/index.ts +12 -3
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +1 -1
- package/src/api/SubComponent/SubData/test/normal.test.ts +1 -1
- package/src/api/SubComponent/SubInstance/test/normal.test.ts +1 -1
- package/src/api/SubComponent/SubObservers/SubObserversOption.ts +3 -0
- package/src/api/SubComponent/SubWatch/test/WatchComputed.test.ts +5 -0
- package/src/api/SubComponent/SubWatch/test/WatchRootData.test.ts +5 -0
- package/src/api/SubComponent/SubWatch/test/WtachInject.test.ts +15 -0
- package/src/api/SubComponent/index.ts +11 -1
- package/src/behaviors/BComputedAndWatch/getPathsValue.ts +7 -3
- package/src/behaviors/BComputedAndWatch/index.ts +5 -1
- package/src/behaviors/BComputedAndWatch/isEqual.ts +67 -16
- package/tsconfig.json +3 -1
- package/dist/api/DefineComponent/NameOrPage/test/error.test.d.ts +0 -1
- package/dist/api/DefineComponent/NameOrPage/test/error.test.js +0 -22
- package/dist/api/DefineComponent/NameOrPage/test/error.test.js.map +0 -1
- package/dist/api/DefineComponent/NameOrPage/test/normal.test.d.ts +0 -1
- package/dist/api/DefineComponent/NameOrPage/test/normal.test.js +0 -10
- package/dist/api/DefineComponent/NameOrPage/test/normal.test.js.map +0 -1
- package/dist/api/DefineComponent/ReturnType/GetPropertiesDocOfSubDoc.d.ts +0 -5
- package/dist/api/DefineComponent/ReturnType/GetPropertiesDocOfSubDoc.js +0 -2
- package/dist/api/DefineComponent/ReturnType/GetPropertiesDocOfSubDoc.js.map +0 -1
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.d.ts +0 -1
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js +0 -93
- package/dist/api/DefineComponent/ReturnType/test/normalComponentDoc.test.js.map +0 -1
- package/dist/api/DefineComponent/ReturnType/test/normalPageDoc.test.d.ts +0 -1
- package/dist/api/DefineComponent/ReturnType/test/normalPageDoc.test.js +0 -31
- package/dist/api/DefineComponent/ReturnType/test/normalPageDoc.test.js.map +0 -1
- package/dist/api/DefineComponent/SubComponents/test/normal.test.d.ts +0 -1
- package/dist/api/DefineComponent/SubComponents/test/normal.test.js +0 -1022
- package/dist/api/DefineComponent/SubComponents/test/normal.test.js.map +0 -1
- package/dist/api/InstanceInject/inject.d.ts +0 -18
- package/dist/api/InstanceInject/inject.js +0 -20
- package/dist/api/InstanceInject/inject.js.map +0 -1
- package/dist/api/InstanceInject/test/normal.test.d.ts +0 -1
- package/dist/api/InstanceInject/test/normal.test.js +0 -30
- package/dist/api/InstanceInject/test/normal.test.js.map +0 -1
- package/dist/api/RootComponent/Computed/test/GetComputedDoc.test.d.ts +0 -1
- package/dist/api/RootComponent/Computed/test/GetComputedDoc.test.js +0 -4
- package/dist/api/RootComponent/Computed/test/GetComputedDoc.test.js.map +0 -1
- package/dist/api/RootComponent/Computed/test/error.test.d.ts +0 -1
- package/dist/api/RootComponent/Computed/test/error.test.js +0 -28
- package/dist/api/RootComponent/Computed/test/error.test.js.map +0 -1
- package/dist/api/RootComponent/Computed/test/normal.test.d.ts +0 -1
- package/dist/api/RootComponent/Computed/test/normal.test.js +0 -48
- package/dist/api/RootComponent/Computed/test/normal.test.js.map +0 -1
- package/dist/api/RootComponent/CustomEvents/test/GetCustomEventDoc.test.d.ts +0 -15
- package/dist/api/RootComponent/CustomEvents/test/GetCustomEventDoc.test.js +0 -3
- package/dist/api/RootComponent/CustomEvents/test/GetCustomEventDoc.test.js.map +0 -1
- package/dist/api/RootComponent/CustomEvents/test/GetFullEventDoc.test.d.ts +0 -7
- package/dist/api/RootComponent/CustomEvents/test/GetFullEventDoc.test.js +0 -8
- package/dist/api/RootComponent/CustomEvents/test/GetFullEventDoc.test.js.map +0 -1
- package/dist/api/RootComponent/CustomEvents/test/GetShortEventDoc.test.d.ts +0 -4
- package/dist/api/RootComponent/CustomEvents/test/GetShortEventDoc.test.js +0 -6
- package/dist/api/RootComponent/CustomEvents/test/GetShortEventDoc.test.js.map +0 -1
- package/dist/api/RootComponent/CustomEvents/test/error.test.d.ts +0 -1
- package/dist/api/RootComponent/CustomEvents/test/error.test.js +0 -73
- package/dist/api/RootComponent/CustomEvents/test/error.test.js.map +0 -1
- package/dist/api/RootComponent/CustomEvents/test/normal.test.d.ts +0 -99
- package/dist/api/RootComponent/CustomEvents/test/normal.test.js +0 -47
- package/dist/api/RootComponent/CustomEvents/test/normal.test.js.map +0 -1
- package/dist/api/RootComponent/Data/GetDataDoc.d.ts +0 -1
- package/dist/api/RootComponent/Data/GetDataDoc.js +0 -2
- package/dist/api/RootComponent/Data/GetDataDoc.js.map +0 -1
- package/dist/api/RootComponent/Data/test/GetDataDoc.test.d.ts +0 -7
- package/dist/api/RootComponent/Data/test/GetDataDoc.test.js +0 -13
- package/dist/api/RootComponent/Data/test/GetDataDoc.test.js.map +0 -1
- package/dist/api/RootComponent/Data/test/error.test.d.ts +0 -1
- package/dist/api/RootComponent/Data/test/error.test.js +0 -10
- package/dist/api/RootComponent/Data/test/error.test.js.map +0 -1
- package/dist/api/RootComponent/Data/test/normal.test.d.ts +0 -1
- package/dist/api/RootComponent/Data/test/normal.test.js +0 -33
- package/dist/api/RootComponent/Data/test/normal.test.js.map +0 -1
- package/dist/api/RootComponent/Events/test/normal.test.d.ts +0 -1
- package/dist/api/RootComponent/Events/test/normal.test.js +0 -59
- package/dist/api/RootComponent/Events/test/normal.test.js.map +0 -1
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.d.ts +0 -1
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js +0 -60
- package/dist/api/RootComponent/Instance/test/CustomEventsDoc.test.js.map +0 -1
- package/dist/api/RootComponent/Instance/test/CustomSetData.test.d.ts +0 -1
- package/dist/api/RootComponent/Instance/test/CustomSetData.test.js +0 -42
- package/dist/api/RootComponent/Instance/test/CustomSetData.test.js.map +0 -1
- package/dist/api/RootComponent/Instance/test/customEvents/error.test.d.ts +0 -1
- package/dist/api/RootComponent/Instance/test/customEvents/error.test.js +0 -12
- package/dist/api/RootComponent/Instance/test/customEvents/error.test.js.map +0 -1
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.d.ts +0 -1
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js +0 -60
- package/dist/api/RootComponent/Instance/test/customEvents/normal.test.js.map +0 -1
- package/dist/api/RootComponent/Instance/test/methods/error.test.d.ts +0 -1
- package/dist/api/RootComponent/Instance/test/methods/error.test.js +0 -12
- package/dist/api/RootComponent/Instance/test/methods/error.test.js.map +0 -1
- package/dist/api/RootComponent/Instance/test/methods/mormal.test.d.ts +0 -1
- package/dist/api/RootComponent/Instance/test/methods/mormal.test.js +0 -15
- package/dist/api/RootComponent/Instance/test/methods/mormal.test.js.map +0 -1
- package/dist/api/RootComponent/Instance/test/properties/mormal.test.d.ts +0 -1
- package/dist/api/RootComponent/Instance/test/properties/mormal.test.js +0 -34
- package/dist/api/RootComponent/Instance/test/properties/mormal.test.js.map +0 -1
- package/dist/api/RootComponent/Instance/test/setData/error.test.d.ts +0 -1
- package/dist/api/RootComponent/Instance/test/setData/error.test.js +0 -49
- package/dist/api/RootComponent/Instance/test/setData/error.test.js.map +0 -1
- package/dist/api/RootComponent/Instance/test/setData/normal.test.d.ts +0 -1
- package/dist/api/RootComponent/Instance/test/setData/normal.test.js +0 -46
- package/dist/api/RootComponent/Instance/test/setData/normal.test.js.map +0 -1
- package/dist/api/RootComponent/IsPage/test/normal.test.d.ts +0 -1
- package/dist/api/RootComponent/IsPage/test/normal.test.js +0 -13
- package/dist/api/RootComponent/IsPage/test/normal.test.js.map +0 -1
- package/dist/api/RootComponent/Lifetimes/test/error.test.d.ts +0 -1
- package/dist/api/RootComponent/Lifetimes/test/error.test.js +0 -20
- package/dist/api/RootComponent/Lifetimes/test/error.test.js.map +0 -1
- package/dist/api/RootComponent/Lifetimes/test/normal.test.d.ts +0 -1
- package/dist/api/RootComponent/Lifetimes/test/normal.test.js +0 -24
- package/dist/api/RootComponent/Lifetimes/test/normal.test.js.map +0 -1
- package/dist/api/RootComponent/Methods/test/error.test.d.ts +0 -1
- package/dist/api/RootComponent/Methods/test/error.test.js +0 -30
- package/dist/api/RootComponent/Methods/test/error.test.js.map +0 -1
- package/dist/api/RootComponent/Methods/test/mormal.test.d.ts +0 -1
- package/dist/api/RootComponent/Methods/test/mormal.test.js +0 -14
- package/dist/api/RootComponent/Methods/test/mormal.test.js.map +0 -1
- package/dist/api/RootComponent/PageLifetimes/test/error.test.d.ts +0 -1
- package/dist/api/RootComponent/PageLifetimes/test/error.test.js +0 -22
- package/dist/api/RootComponent/PageLifetimes/test/error.test.js.map +0 -1
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.d.ts +0 -1
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.js +0 -38
- package/dist/api/RootComponent/PageLifetimes/test/normal.test.js.map +0 -1
- package/dist/api/RootComponent/Properties/test/error.test.d.ts +0 -1
- package/dist/api/RootComponent/Properties/test/error.test.js +0 -38
- package/dist/api/RootComponent/Properties/test/error.test.js.map +0 -1
- package/dist/api/RootComponent/Properties/test/normalEmpty.test.d.ts +0 -1
- package/dist/api/RootComponent/Properties/test/normalEmpty.test.js +0 -20
- package/dist/api/RootComponent/Properties/test/normalEmpty.test.js.map +0 -1
- package/dist/api/RootComponent/Properties/test/normalOptional.test.d.ts +0 -1
- package/dist/api/RootComponent/Properties/test/normalOptional.test.js +0 -64
- package/dist/api/RootComponent/Properties/test/normalOptional.test.js.map +0 -1
- package/dist/api/RootComponent/Properties/test/normalRequired.test.d.ts +0 -93
- package/dist/api/RootComponent/Properties/test/normalRequired.test.js +0 -44
- package/dist/api/RootComponent/Properties/test/normalRequired.test.js.map +0 -1
- package/dist/api/RootComponent/Store/test/error.test.d.ts +0 -1
- package/dist/api/RootComponent/Store/test/error.test.js +0 -24
- package/dist/api/RootComponent/Store/test/error.test.js.map +0 -1
- package/dist/api/RootComponent/Store/test/normal.test.d.ts +0 -1
- package/dist/api/RootComponent/Store/test/normal.test.js +0 -15
- package/dist/api/RootComponent/Store/test/normal.test.js.map +0 -1
- package/dist/api/RootComponent/Watch/test/WatchComputed.test.d.ts +0 -1
- package/dist/api/RootComponent/Watch/test/WatchComputed.test.js +0 -30
- package/dist/api/RootComponent/Watch/test/WatchComputed.test.js.map +0 -1
- package/dist/api/RootComponent/Watch/test/WatchData.test.d.ts +0 -1
- package/dist/api/RootComponent/Watch/test/WatchData.test.js +0 -40
- package/dist/api/RootComponent/Watch/test/WatchData.test.js.map +0 -1
- package/dist/api/RootComponent/Watch/test/WatchProperties.test.d.ts +0 -1
- package/dist/api/RootComponent/Watch/test/WatchProperties.test.js +0 -109
- package/dist/api/RootComponent/Watch/test/WatchProperties.test.js.map +0 -1
- package/dist/api/RootComponent/Watch/test/WtachInject.test.d.ts +0 -1
- package/dist/api/RootComponent/Watch/test/WtachInject.test.js +0 -15
- package/dist/api/RootComponent/Watch/test/WtachInject.test.js.map +0 -1
- package/dist/api/RootComponent/Watch/test/error.test.d.ts +0 -1
- package/dist/api/RootComponent/Watch/test/error.test.js +0 -25
- package/dist/api/RootComponent/Watch/test/error.test.js.map +0 -1
- package/dist/api/SubComponent/SubComputed/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubComputed/test/error.test.js +0 -30
- package/dist/api/SubComponent/SubComputed/test/error.test.js.map +0 -1
- package/dist/api/SubComponent/SubComputed/test/normal.test.d.ts +0 -1
- package/dist/api/SubComponent/SubComputed/test/normal.test.js +0 -61
- package/dist/api/SubComponent/SubComputed/test/normal.test.js.map +0 -1
- package/dist/api/SubComponent/SubData/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubData/test/error.test.js +0 -32
- package/dist/api/SubComponent/SubData/test/error.test.js.map +0 -1
- package/dist/api/SubComponent/SubData/test/normal.test.d.ts +0 -1
- package/dist/api/SubComponent/SubData/test/normal.test.js +0 -36
- package/dist/api/SubComponent/SubData/test/normal.test.js.map +0 -1
- package/dist/api/SubComponent/SubEvents/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubEvents/test/error.test.js +0 -15
- package/dist/api/SubComponent/SubEvents/test/error.test.js.map +0 -1
- package/dist/api/SubComponent/SubEvents/test/normal.test.d.ts +0 -1
- package/dist/api/SubComponent/SubEvents/test/normal.test.js +0 -91
- package/dist/api/SubComponent/SubEvents/test/normal.test.js.map +0 -1
- package/dist/api/SubComponent/SubInherit/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubInherit/test/error.test.js +0 -21
- package/dist/api/SubComponent/SubInherit/test/error.test.js.map +0 -1
- package/dist/api/SubComponent/SubInherit/test/normal.test.d.ts +0 -1
- package/dist/api/SubComponent/SubInherit/test/normal.test.js +0 -19
- package/dist/api/SubComponent/SubInherit/test/normal.test.js.map +0 -1
- package/dist/api/SubComponent/SubInstance/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubInstance/test/error.test.js +0 -10
- package/dist/api/SubComponent/SubInstance/test/error.test.js.map +0 -1
- package/dist/api/SubComponent/SubInstance/test/normal.test.d.ts +0 -1
- package/dist/api/SubComponent/SubInstance/test/normal.test.js +0 -26
- package/dist/api/SubComponent/SubInstance/test/normal.test.js.map +0 -1
- package/dist/api/SubComponent/SubMethods/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubMethods/test/error.test.js +0 -18
- package/dist/api/SubComponent/SubMethods/test/error.test.js.map +0 -1
- package/dist/api/SubComponent/SubMethods/test/normarl.test.d.ts +0 -1
- package/dist/api/SubComponent/SubMethods/test/normarl.test.js +0 -11
- package/dist/api/SubComponent/SubMethods/test/normarl.test.js.map +0 -1
- package/dist/api/SubComponent/SubPageLifetimes/test/error.test.d.ts +0 -0
- package/dist/api/SubComponent/SubPageLifetimes/test/error.test.js +0 -2
- package/dist/api/SubComponent/SubPageLifetimes/test/error.test.js.map +0 -1
- package/dist/api/SubComponent/SubPageLifetimes/test/normal.test.d.ts +0 -0
- package/dist/api/SubComponent/SubPageLifetimes/test/normal.test.js +0 -2
- package/dist/api/SubComponent/SubPageLifetimes/test/normal.test.js.map +0 -1
- package/dist/api/SubComponent/SubReturnType/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubReturnType/test/error.test.js +0 -5
- package/dist/api/SubComponent/SubReturnType/test/error.test.js.map +0 -1
- package/dist/api/SubComponent/SubReturnType/test/normal.test.d.ts +0 -1
- package/dist/api/SubComponent/SubReturnType/test/normal.test.js +0 -9
- package/dist/api/SubComponent/SubReturnType/test/normal.test.js.map +0 -1
- package/dist/api/SubComponent/SubStore/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubStore/test/error.test.js +0 -21
- package/dist/api/SubComponent/SubStore/test/error.test.js.map +0 -1
- package/dist/api/SubComponent/SubStore/test/normal.test.d.ts +0 -1
- package/dist/api/SubComponent/SubStore/test/normal.test.js +0 -14
- package/dist/api/SubComponent/SubStore/test/normal.test.js.map +0 -1
- package/dist/api/SubComponent/SubWatch/test/WatchComputed.test.d.ts +0 -1
- package/dist/api/SubComponent/SubWatch/test/WatchComputed.test.js +0 -45
- package/dist/api/SubComponent/SubWatch/test/WatchComputed.test.js.map +0 -1
- package/dist/api/SubComponent/SubWatch/test/WatchRootData.test.d.ts +0 -1
- package/dist/api/SubComponent/SubWatch/test/WatchRootData.test.js +0 -63
- package/dist/api/SubComponent/SubWatch/test/WatchRootData.test.js.map +0 -1
- package/dist/api/SubComponent/SubWatch/test/WatchSubData.test.d.ts +0 -1
- package/dist/api/SubComponent/SubWatch/test/WatchSubData.test.js +0 -29
- package/dist/api/SubComponent/SubWatch/test/WatchSubData.test.js.map +0 -1
- package/dist/api/SubComponent/SubWatch/test/error.test.d.ts +0 -1
- package/dist/api/SubComponent/SubWatch/test/error.test.js +0 -20
- package/dist/api/SubComponent/SubWatch/test/error.test.js.map +0 -1
- package/dist/types/GetPropertiesDuplicatedKeys.d.ts +0 -2
- package/dist/types/GetPropertiesDuplicatedKeys.js +0 -2
- package/dist/types/GetPropertiesDuplicatedKeys.js.map +0 -1
- package/dist/types/Has.d.ts +0 -1
- package/dist/types/Has.js +0 -2
- package/dist/types/Has.js.map +0 -1
- package/dist/types/InferDetailedType.test.d.ts +0 -1
- package/dist/types/InferDetailedType.test.js +0 -9
- package/dist/types/InferDetailedType.test.js.map +0 -1
- package/dist/types/ListOfSamePrimitive.d.ts +0 -8
- package/dist/types/ListOfSamePrimitive.js +0 -2
- package/dist/types/ListOfSamePrimitive.js.map +0 -1
- package/dist/types/PrefixValidator.d.ts +0 -4
- package/dist/types/PrefixValidator.js +0 -2
- package/dist/types/PrefixValidator.js.map +0 -1
- package/dist/types/RemoveNever.d.ts +0 -4
- package/dist/types/RemoveNever.js +0 -2
- package/dist/types/RemoveNever.js.map +0 -1
- package/dist/types/RemoveNullOfRequired.d.ts +0 -4
- package/dist/types/RemoveNullOfRequired.js +0 -2
- package/dist/types/RemoveNullOfRequired.js.map +0 -1
- package/dist/types/Shift.d.ts +0 -1
- package/dist/types/Shift.js +0 -2
- package/dist/types/Shift.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
2
|
import type { ReadonlyDeep } from "hry-types/src/Any/ReadonlyDeep";
|
|
3
3
|
import { type DetailedType, RootComponent } from "../../../../..";
|
|
4
|
-
import { IInjectData } from "../../../../InstanceInject/instanceConfig";
|
|
4
|
+
import type { IInjectData } from "../../../../InstanceInject/instanceConfig";
|
|
5
5
|
|
|
6
6
|
// 组件时
|
|
7
7
|
RootComponent()({
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
2
|
+
import type { IfExtends } from "hry-types/src/Any/IfExtends";
|
|
3
|
+
import type { IsPureObject } from "hry-types/src/Any/IsPureObject";
|
|
4
|
+
import type { NoInfer } from "hry-types/src/Generic/NoInfer";
|
|
5
|
+
import type { EmptyObject } from "hry-types/src/Misc/EmptyObject";
|
|
6
|
+
|
|
7
|
+
type getFirstKeys<T extends string> = T extends `${infer F}.${string}` ? F : never;
|
|
8
|
+
|
|
9
|
+
type getLastKeys<T extends string> = T extends `${string}.${infer L}` ? L : never;
|
|
10
|
+
|
|
11
|
+
// 加入对象字段一级key 例如 `obj.xxx`(newValue,oldValue){...}和`obj.**`
|
|
12
|
+
type AddFieldsOfObject<
|
|
13
|
+
TWatchData extends object,
|
|
14
|
+
_WatchKeys extends keyof TWatchData,
|
|
15
|
+
secondKeys extends string = {
|
|
16
|
+
[k in _WatchKeys]: IsPureObject<Exclude<TWatchData[k], null>> extends true
|
|
17
|
+
? `${k & string}.${(keyof Exclude<TWatchData[k], null>) & string}` | `${k & string}.**`
|
|
18
|
+
: never;
|
|
19
|
+
}[_WatchKeys],
|
|
20
|
+
> = {
|
|
21
|
+
[k in secondKeys]?: (
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
newValue: ReadonlyDeep<
|
|
24
|
+
IfExtends<
|
|
25
|
+
getLastKeys<k>,
|
|
26
|
+
"**",
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
TWatchData[getFirstKeys<k>],
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
NonNullable<(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>
|
|
31
|
+
>
|
|
32
|
+
>,
|
|
33
|
+
) => void;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type ObserversOption<TWatchData extends object, _WatchKeys extends keyof TWatchData = keyof TWatchData> = {
|
|
37
|
+
/**
|
|
38
|
+
* 监控所有data字段,值变化时(JSON.stringify判断)运行watch函数,一参为最新值,二参为变化前值。
|
|
39
|
+
* 对象数据可通过`obj.xxx:`监控具体字段(只加入了一级字段类型提示)
|
|
40
|
+
*/
|
|
41
|
+
observers?: IfExtends<
|
|
42
|
+
{},
|
|
43
|
+
TWatchData,
|
|
44
|
+
EmptyObject,
|
|
45
|
+
// 不加NoInfer会导致只监控计算字段时错误
|
|
46
|
+
NoInfer<
|
|
47
|
+
& {
|
|
48
|
+
[k in _WatchKeys]?: (
|
|
49
|
+
newValue: ReadonlyDeep<TWatchData[k]>,
|
|
50
|
+
) => void;
|
|
51
|
+
}
|
|
52
|
+
// 解决单独书写计算书写字段的报错(或许是:ts字面量约束检测提前计算属性key引起的错误提示)
|
|
53
|
+
& {
|
|
54
|
+
[k in _WatchKeys as never]: unknown;
|
|
55
|
+
}
|
|
56
|
+
// 加入对象的一级字段类型提示
|
|
57
|
+
& AddFieldsOfObject<TWatchData, _WatchKeys>
|
|
58
|
+
>
|
|
59
|
+
>;
|
|
60
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Checking, type Test } from "hry-types";
|
|
2
|
+
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
|
+
|
|
4
|
+
import type { User } from "../../../../../jest/common";
|
|
5
|
+
import { RootComponent } from "../..";
|
|
6
|
+
|
|
7
|
+
RootComponent()({
|
|
8
|
+
data: {
|
|
9
|
+
obj: {} as User | null,
|
|
10
|
+
},
|
|
11
|
+
observers: {
|
|
12
|
+
obj(a) {
|
|
13
|
+
Checking<typeof a, ReadonlyDeep<User> | null, Test.Pass>;
|
|
14
|
+
},
|
|
15
|
+
"obj.**"(a) {
|
|
16
|
+
Checking<typeof a, ReadonlyDeep<User> | null, Test.Pass>;
|
|
17
|
+
},
|
|
18
|
+
"obj.age"(a) {
|
|
19
|
+
Checking<typeof a, number, Test.Pass>;
|
|
20
|
+
},
|
|
21
|
+
"obj.name"(a) {
|
|
22
|
+
Checking<typeof a, string, Test.Pass>;
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
|
-
import { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
|
-
import { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
2
|
+
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
|
+
import type { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
4
4
|
import { RootComponent } from "../..";
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Checking, type Test } from "hry-types";
|
|
2
2
|
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
3
|
import type { DetailedType } from "../../../../types/DetailedType";
|
|
4
|
-
import { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
4
|
+
import type { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
5
5
|
import { RootComponent } from "../..";
|
|
6
6
|
import { type Mock_User } from "./normalRequired.test";
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@ import { Checking, type Test } from "hry-types";
|
|
|
2
2
|
import type { DetailedType } from "../../../../types/DetailedType";
|
|
3
3
|
|
|
4
4
|
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
5
|
-
import { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
5
|
+
import type { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
6
6
|
import { RootComponent } from "../..";
|
|
7
7
|
import type { RequiredSingle, RequiredType, RequiredUnion } from "../PropertiesConstraint";
|
|
8
8
|
|
|
@@ -8,32 +8,41 @@ type getFirstKeys<T extends string> = T extends `${infer F}.${string}` ? F : nev
|
|
|
8
8
|
|
|
9
9
|
type getLastKeys<T extends string> = T extends `${string}.${infer L}` ? L : never;
|
|
10
10
|
|
|
11
|
-
// 加入对象字段一级key 例如 `obj.xxx`(newValue,oldValue){...}
|
|
11
|
+
// 加入对象字段一级key 例如 `obj.xxx`(newValue,oldValue){...}和`obj.**`
|
|
12
12
|
type AddFieldsOfObject<
|
|
13
13
|
TWatchData extends object,
|
|
14
14
|
_WatchKeys extends keyof TWatchData,
|
|
15
15
|
secondKeys extends string = {
|
|
16
16
|
[k in _WatchKeys]: IsPureObject<Exclude<TWatchData[k], null>> extends true
|
|
17
|
-
? `${k & string}.${(keyof Exclude<TWatchData[k], null>) & string}`
|
|
17
|
+
? `${k & string}.${(keyof Exclude<TWatchData[k], null>) & string}` | `${k & string}.**`
|
|
18
18
|
: never;
|
|
19
19
|
}[_WatchKeys],
|
|
20
|
-
> =
|
|
21
|
-
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
20
|
+
> = {
|
|
21
|
+
[k in secondKeys]?: (
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
newValue: ReadonlyDeep<
|
|
24
|
+
IfExtends<
|
|
25
|
+
getLastKeys<k>,
|
|
26
|
+
"**",
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
Exclude<TWatchData[getFirstKeys<k>], null>,
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
NonNullable<(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>
|
|
31
|
+
>
|
|
32
|
+
>,
|
|
33
|
+
oldValue: ReadonlyDeep<
|
|
34
|
+
IfExtends<
|
|
35
|
+
getLastKeys<k>,
|
|
36
|
+
"**",
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
TWatchData[getFirstKeys<k>],
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]
|
|
41
|
+
>
|
|
42
|
+
>,
|
|
43
|
+
// ReadonlyDeep<(Exclude<TWatchData[getFirstKeys<k>], null>)[getLastKeys<k>]>,
|
|
44
|
+
) => void;
|
|
45
|
+
};
|
|
37
46
|
|
|
38
47
|
export type WatchOption<TWatchData extends object, _WatchKeys extends keyof TWatchData = keyof TWatchData> = {
|
|
39
48
|
/**
|
|
@@ -142,6 +142,11 @@ RootComponent()({
|
|
|
142
142
|
|
|
143
143
|
Checking<number | undefined, typeof oldValue, Test.Pass>;
|
|
144
144
|
},
|
|
145
|
+
"optional_obj.**"(newValue, oldValue) {
|
|
146
|
+
Checking<ReadonlyDeep<Mock_User>, typeof newValue, Test.Pass>;
|
|
147
|
+
|
|
148
|
+
Checking<ReadonlyDeep<Mock_User | null>, typeof oldValue, Test.Pass>;
|
|
149
|
+
},
|
|
145
150
|
"optional_obj.id"(newValue, oldValue) {
|
|
146
151
|
Checking<string, typeof newValue, Test.Pass>;
|
|
147
152
|
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
import { Checking, Test } from "hry-types";
|
|
1
|
+
import { Checking, type Test } from "hry-types";
|
|
2
2
|
import { RootComponent } from "../..";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* watch
|
|
5
|
+
* watch 只能监控 注入的store字段
|
|
6
6
|
*/
|
|
7
7
|
RootComponent()({
|
|
8
8
|
watch: {
|
|
9
|
-
injectStr(newValue, oldValue) {
|
|
10
|
-
Checking<string, typeof newValue, Test.Pass>;
|
|
11
|
-
|
|
12
|
-
Checking<string, typeof oldValue, Test.Pass>;
|
|
13
|
-
},
|
|
14
9
|
injectTheme(newValue, oldValue) {
|
|
15
10
|
Checking<"dark" | "light" | undefined, typeof newValue, Test.Pass>;
|
|
16
11
|
|
|
@@ -5,7 +5,7 @@ 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
7
|
import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
8
|
-
import {
|
|
8
|
+
import type { IInjectStore } from "../InstanceInject/instanceConfig";
|
|
9
9
|
import type { ComputedConstraint } from "./Computed/ComputedConstraint";
|
|
10
10
|
import type { ComputedOption } from "./Computed/ComputedOption";
|
|
11
11
|
import type { GetComputedDoc } from "./Computed/GetComputedDoc";
|
|
@@ -22,6 +22,7 @@ import type { LifetimesConstraint } from "./Lifetimes/LifetimesConstraint";
|
|
|
22
22
|
import type { LifetimesOption } from "./Lifetimes/LifetimesOption";
|
|
23
23
|
import type { MethodsConstraint } from "./Methods/MethodsConstraint";
|
|
24
24
|
import type { MethodsOption } from "./Methods/MethodsOption";
|
|
25
|
+
import type { ObserversOption } from "./Observers/ObserversOption";
|
|
25
26
|
import type { PageLifetimesOption } from "./PageLifetimes/PageLifetimesOption";
|
|
26
27
|
import type { GetPropertiesDoc } from "./Properties/GetPropertiesDoc";
|
|
27
28
|
import type { PropertiesConstraint } from "./Properties/PropertiesConstraint";
|
|
@@ -62,9 +63,16 @@ type RootComponentOptions<
|
|
|
62
63
|
& Required<PropertiesDoc>
|
|
63
64
|
& DataDoc
|
|
64
65
|
& StoreDoc
|
|
65
|
-
&
|
|
66
|
+
& IInjectStore
|
|
67
|
+
>
|
|
68
|
+
& Partial<Omit<WMCompOtherOption, "pageLifetimes" | "definitionFilter" | "export" | "observers">>
|
|
69
|
+
& ObserversOption<
|
|
70
|
+
& ComputedDoc
|
|
71
|
+
& Required<PropertiesDoc>
|
|
72
|
+
& DataDoc
|
|
73
|
+
& StoreDoc
|
|
74
|
+
& IInjectStore
|
|
66
75
|
>
|
|
67
|
-
& Partial<Omit<WMCompOtherOption, "pageLifetimes">>
|
|
68
76
|
& ThisType<
|
|
69
77
|
RootComponentInstance<
|
|
70
78
|
TIsPage,
|
|
@@ -104,6 +112,7 @@ type RootComponentConstructor<TComponentDocList extends ComponentDoc[]> = {
|
|
|
104
112
|
TData,
|
|
105
113
|
TStore,
|
|
106
114
|
TComputed,
|
|
115
|
+
// TObservers,
|
|
107
116
|
EventsDoc,
|
|
108
117
|
CustomEventsDoc,
|
|
109
118
|
PropertiesDoc,
|
|
@@ -2,7 +2,7 @@ import { Checking, type Test } from "hry-types";
|
|
|
2
2
|
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
3
|
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
4
4
|
|
|
5
|
-
import { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
5
|
+
import type { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
6
6
|
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
7
7
|
import { SubComponent } from "../..";
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ import { Checking, type Test } from "hry-types";
|
|
|
2
2
|
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
3
|
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
4
4
|
|
|
5
|
-
import { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
5
|
+
import type { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
6
6
|
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
7
7
|
import { SubComponent } from "../..";
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ import { Checking, type Test } from "hry-types";
|
|
|
2
2
|
import type { ReadonlyDeep } from "hry-types/src/Any/_api";
|
|
3
3
|
import type { ComponentDoc } from "../../../DefineComponent/ReturnType/ComponentDoc";
|
|
4
4
|
|
|
5
|
-
import { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
5
|
+
import type { IInjectData } from "../../../InstanceInject/instanceConfig";
|
|
6
6
|
import type { Mock_User } from "../../../RootComponent/Properties/test/normalRequired.test";
|
|
7
7
|
import type { RootComponentDoc } from "../../../RootComponent/RootComponentDoc";
|
|
8
8
|
import { SubComponent } from "../..";
|
|
@@ -64,6 +64,11 @@ SubComponent<RootDoc, CompDoc>()({
|
|
|
64
64
|
|
|
65
65
|
Checking<Mock_User | null, typeof oldValue, Test.Pass>;
|
|
66
66
|
},
|
|
67
|
+
"aaa_obj.**"(newValue: Mock_User, oldValue: Mock_User | null) {
|
|
68
|
+
Checking<Mock_User, typeof newValue, Test.Pass>;
|
|
69
|
+
|
|
70
|
+
Checking<Mock_User | null, typeof oldValue, Test.Pass>;
|
|
71
|
+
},
|
|
67
72
|
"aaa_obj.id"(newValue: string, oldValue: string) {
|
|
68
73
|
Checking<string, typeof newValue, Test.Pass>;
|
|
69
74
|
|
|
@@ -75,6 +75,11 @@ SubComponent<RootDoc, CompDoc>()({
|
|
|
75
75
|
|
|
76
76
|
Checking<ReadonlyDeep<TestObj>, typeof oldValue, Test.Pass>;
|
|
77
77
|
},
|
|
78
|
+
"optional_obj.**"(newValue, oldValue) {
|
|
79
|
+
Checking<ReadonlyDeep<TestObj>, typeof newValue, Test.Pass>;
|
|
80
|
+
|
|
81
|
+
Checking<ReadonlyDeep<TestObj>, typeof oldValue, Test.Pass>;
|
|
82
|
+
},
|
|
78
83
|
"optional_obj.subObj"(newValue, oldValue) {
|
|
79
84
|
Checking<ReadonlyDeep<Mock_User>, typeof newValue, Test.Pass>;
|
|
80
85
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Checking, type Test } from "hry-types";
|
|
2
|
+
import { SubComponent } from "../..";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* watch 注入的store字段
|
|
6
|
+
*/
|
|
7
|
+
SubComponent<{}, { properties: { aaa_num: number } }>()({
|
|
8
|
+
watch: {
|
|
9
|
+
injectTheme(newValue, oldValue) {
|
|
10
|
+
Checking<"dark" | "light" | undefined, typeof newValue, Test.Pass>;
|
|
11
|
+
|
|
12
|
+
Checking<"dark" | "light" | undefined, typeof oldValue, Test.Pass>;
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
@@ -7,6 +7,7 @@ import type { ComponentDoc } from "../DefineComponent/ReturnType/ComponentDoc";
|
|
|
7
7
|
|
|
8
8
|
import type { Func } from "hry-types/src/Misc/Func";
|
|
9
9
|
import type { WMCompOtherOption } from "../../types/OfficialTypeAlias";
|
|
10
|
+
import type { IInjectStore } from "../InstanceInject/instanceConfig";
|
|
10
11
|
import type { ComputedConstraint } from "../RootComponent/Computed/ComputedConstraint";
|
|
11
12
|
import type { DataConstraint } from "../RootComponent/Data/DataConstraint";
|
|
12
13
|
import type { EventsConstraint } from "../RootComponent/Events/EventsConstraint";
|
|
@@ -28,6 +29,7 @@ import type { SubInstance } from "./SubInstance/SubInstance";
|
|
|
28
29
|
import type { SubLifetimesOption } from "./SubLifetimes/SubLifetimesOption";
|
|
29
30
|
import type { SubMethodsConstraint } from "./SubMethods/SubMethodsConstraint";
|
|
30
31
|
import type { SubMethodsOption } from "./SubMethods/SubMethodsOption";
|
|
32
|
+
import type { SubObserversOption } from "./SubObservers/SubObserversOption";
|
|
31
33
|
import type { SubPageLifetimesOption } from "./SubPageLifetimes/SubPageLifetimesOption";
|
|
32
34
|
import type { CreateSubComponentDoc } from "./SubReturnType/CreateSubComponentDoc";
|
|
33
35
|
import type { SubStoreConstraint } from "./SubStore/SubDataConstraint";
|
|
@@ -80,8 +82,16 @@ type Options<
|
|
|
80
82
|
& SubDataDoc
|
|
81
83
|
& AllRootDataDoc
|
|
82
84
|
& SubStoreDoc
|
|
85
|
+
& IInjectStore
|
|
86
|
+
>
|
|
87
|
+
& Partial<Omit<WMCompOtherOption, "pageLifetimes" | "definitionFilter" | "export" | "observers">>
|
|
88
|
+
& SubObserversOption<
|
|
89
|
+
& SubComputedDoc
|
|
90
|
+
& SubDataDoc
|
|
91
|
+
& AllRootDataDoc
|
|
92
|
+
& SubStoreDoc
|
|
93
|
+
& IInjectStore
|
|
83
94
|
>
|
|
84
|
-
& Partial<Omit<WMCompOtherOption, "pageLifetimes">>
|
|
85
95
|
& ThisType<
|
|
86
96
|
SubInstance<
|
|
87
97
|
SubMethodsDoc & RootDoc["methods"],
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 获取指定paths的值
|
|
3
3
|
* @param this - 组件实例 Instance
|
|
4
|
-
* @param paths - 支持多字段(用`,`分开) 例如 'obj.xxx,a,b' 监控了3个字段
|
|
4
|
+
* @param paths - 支持多字段(用`,`分开) 例如 'obj.xxx,a,b.**' 监控了3个字段
|
|
5
5
|
* @returns unknown[] 每项对应paths每项的值
|
|
6
6
|
*/
|
|
7
7
|
export function getPathsValue(data: object, paths: string) {
|
|
8
8
|
const valueList: unknown[] = [];
|
|
9
9
|
|
|
10
|
-
// ['obj.xxx','a','b'].forEach
|
|
10
|
+
// ['obj.xxx','a','b.**'].forEach
|
|
11
11
|
paths.split(",").forEach(path => {
|
|
12
|
-
// path : 'obj.xxx' | 'a' | 'b'
|
|
12
|
+
// path : 'obj.xxx' | 'a' | 'b.**'
|
|
13
|
+
if (path.includes(".**")) {
|
|
14
|
+
// "b.**" => 'b'
|
|
15
|
+
path = path.slice(0, -3);
|
|
16
|
+
}
|
|
13
17
|
const value = path.split(".").reduce((pre: any, path) => {
|
|
14
18
|
// pre有可能为undefined|null,比如obj是未初始化的计算属性(undefined),还有可能是properties的对象类型(默认为null)
|
|
15
19
|
try {
|
|
@@ -89,14 +89,18 @@ export const BComputedAndWatch = Behavior({
|
|
|
89
89
|
methodsConfig.__watchConfig__ = () => watchConfig;
|
|
90
90
|
|
|
91
91
|
/* istanbul ignore next */
|
|
92
|
-
const observersConfig = options.observers
|
|
92
|
+
const observersConfig = options.observers;
|
|
93
93
|
for (const key in watchConfig) {
|
|
94
94
|
const watchHadle = watchConfig[key];
|
|
95
|
+
const originObserversHandle = observersConfig[key] as Func | undefined;
|
|
95
96
|
|
|
96
97
|
// 在监控多个数据时,参数是多个值
|
|
97
98
|
observersConfig[key] = function(this: Instance, ...newValue: unknown[]) {
|
|
99
|
+
originObserversHandle && originObserversHandle.call(this, ...newValue);
|
|
100
|
+
|
|
98
101
|
const watchOldValue = this.__watchOldValue__!;
|
|
99
102
|
const oldValue = watchOldValue[key];
|
|
103
|
+
|
|
100
104
|
if (isEqual(newValue, oldValue)) return;
|
|
101
105
|
watchOldValue[key] = deepClone(newValue);
|
|
102
106
|
|
|
@@ -1,28 +1,79 @@
|
|
|
1
|
+
/* eslint-disable complexity */
|
|
2
|
+
|
|
3
|
+
function isSameType(a: object, b: object) {
|
|
4
|
+
return Object.prototype.toString.call(a) === Object.prototype.toString.call(b);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// 定义一个辅助函数,用于判断两个对象的属性数量是否相同
|
|
8
|
+
function isSameSize(a: object, b: object) {
|
|
9
|
+
return Object.keys(a).length === Object.keys(b).length;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// 定义一个辅助函数,用于判断两个函数的代码是否相同
|
|
13
|
+
function isSameCode(a: Function, b: Function) {
|
|
14
|
+
return a.toString() === b.toString();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 定义一个辅助函数,用于判断两个日期的时间戳是否相同
|
|
18
|
+
function isSameTime(a: Date, b: Date) {
|
|
19
|
+
return a.getTime() === b.getTime();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 定义一个辅助函数,用于判断两个正则表达式的模式和标志是否相同
|
|
23
|
+
function isSamePattern(a: RegExp, b: RegExp) {
|
|
24
|
+
return a.source === b.source && a.flags === b.flags;
|
|
25
|
+
}
|
|
26
|
+
|
|
1
27
|
/**
|
|
2
|
-
*
|
|
28
|
+
* 深度判断两个值是否相等,有一个值为非对象类型即使用Object.is判断。
|
|
29
|
+
* 不支持原型上的属性
|
|
30
|
+
* 两个函数使用toString()比较
|
|
31
|
+
* 支持Date,RegExp
|
|
3
32
|
*/
|
|
4
|
-
export function isEqual(
|
|
5
|
-
|
|
6
|
-
|
|
33
|
+
export function isEqual(a: unknown, b: unknown) {
|
|
34
|
+
// 如果两个值是原始类型或null,直接用Object.is比较
|
|
35
|
+
if (a === null || b === null || typeof a !== "object" || typeof b !== "object") {
|
|
36
|
+
if (typeof a !== "function" || typeof b !== "function") {
|
|
37
|
+
return Object.is(a, b);
|
|
38
|
+
}
|
|
7
39
|
}
|
|
8
|
-
|
|
9
|
-
|
|
40
|
+
|
|
41
|
+
// 如果两个值是对象类型,先判断它们的类型、构造函数和属性数量是否相同
|
|
42
|
+
if (!isSameType(a, b) || a.constructor !== b.constructor || !isSameSize(a, b)) {
|
|
10
43
|
return false;
|
|
11
44
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
45
|
+
|
|
46
|
+
// 如果两个值是函数类型,再判断它们的代码是否相同
|
|
47
|
+
if (typeof a === "function") {
|
|
48
|
+
return isSameCode(a, b as Function);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 如果两个值是日期类型,再判断它们的时间戳是否相同
|
|
52
|
+
if (a instanceof Date) {
|
|
53
|
+
return isSameTime(a, b as Date);
|
|
18
54
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
55
|
+
|
|
56
|
+
// // 如果两个值是正则表达式类型,再判断它们的模式和标志是否相同
|
|
57
|
+
if (a instanceof RegExp) {
|
|
58
|
+
return isSamePattern(a, b as RegExp);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 对于其他对象类型,递归地比较它们的每个属性和值是否深度相等
|
|
62
|
+
const keysA = Object.keys(a);
|
|
63
|
+
|
|
64
|
+
const keysB = Object.keys(b);
|
|
65
|
+
|
|
66
|
+
for (const key of keysA) {
|
|
67
|
+
if (keysB.includes(key)) {
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
if (!isEqual(a[key], b[key])) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
23
73
|
return false;
|
|
24
74
|
}
|
|
25
75
|
}
|
|
26
76
|
|
|
77
|
+
// 如果以上的条件都满足,说明两个值是深度相等的
|
|
27
78
|
return true;
|
|
28
79
|
}
|
package/tsconfig.json
CHANGED
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
// "noUnusedParameters": false, // 报告函数中未使用参数的错误
|
|
19
19
|
// "suppressImplicitAnyIndexErrors": true, // 为true关闭隐式索引错误,但很激进,建议使用@ts-ignore
|
|
20
20
|
"isolatedModules": true, // 模块化(.ts文件必须有导入或导出) 默认false
|
|
21
|
-
|
|
21
|
+
"preserveValueImports": true, // 引入类型加type
|
|
22
|
+
"ignoreDeprecations": "5.0",
|
|
23
|
+
// "verbatimModuleSyntax": true, // 强制导入类型前缀type检测,在vscode中设置"typescript.preferences.preferTypeOnlyAutoImports":true
|
|
22
24
|
// 默认加载所有@types下的包 types指定具体的包,其他拒绝。包含上级目录
|
|
23
25
|
"types": ["hry-types", "mobx", "jest", "miniprogram-api-typings"]
|
|
24
26
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { DefineComponent } from "../..";
|
|
2
|
-
DefineComponent({
|
|
3
|
-
name: "test",
|
|
4
|
-
rootComponent: { isPage: true },
|
|
5
|
-
});
|
|
6
|
-
DefineComponent({
|
|
7
|
-
path: "/pages/index/index",
|
|
8
|
-
rootComponent: {},
|
|
9
|
-
});
|
|
10
|
-
DefineComponent({
|
|
11
|
-
path: "pages/index/index",
|
|
12
|
-
rootComponent: { isPage: true },
|
|
13
|
-
});
|
|
14
|
-
DefineComponent({
|
|
15
|
-
name: "",
|
|
16
|
-
rootComponent: {},
|
|
17
|
-
});
|
|
18
|
-
DefineComponent({
|
|
19
|
-
name: "ddd_ddd",
|
|
20
|
-
rootComponent: {},
|
|
21
|
-
});
|
|
22
|
-
//# sourceMappingURL=error.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error.test.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/NameOrPage/test/error.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAExC,eAAe,CAAC;IAEd,IAAI,EAAE,MAAM;IACZ,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAA6B;CAC3D,CAAC,CAAC;AAEH,eAAe,CAAC;IAEd,IAAI,EAAE,oBAAoB;IAC1B,aAAa,EAAE,EAA6B;CAC7C,CAAC,CAAC;AAEH,eAAe,CAAC;IAEd,IAAI,EAAE,mBAAmB;IACzB,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAA6B;CAC3D,CAAC,CAAC;AAEH,eAAe,CAAC;IAEd,IAAI,EAAE,EAAE;IACR,aAAa,EAAE,EAA6B;CAC7C,CAAC,CAAC;AAEH,eAAe,CAAC;IAEd,IAAI,EAAE,SAAS;IACf,aAAa,EAAE,EAA6B;CAC7C,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"normal.test.js","sourceRoot":"","sources":["../../../../../src/api/DefineComponent/NameOrPage/test/normal.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAGxC,eAAe,CAAC;IACd,IAAI,EAAE,oBAAoB;IAC1B,aAAa,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;CAChC,CAAC,CAAC;AAGH,eAAe,CAAC;IACd,IAAI,EAAE,MAAM;IACZ,aAAa,EAAE,EAAE;CAClB,CAAC,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SubComponentDoc } from "../../SubComponent/SubComponentDoc";
|
|
2
|
-
export type GetPropertiesDocOfSubDoc<Tuple extends SubComponentDoc[], Result = unknown> = Tuple extends [
|
|
3
|
-
infer Head extends SubComponentDoc,
|
|
4
|
-
...infer Rest extends SubComponentDoc[]
|
|
5
|
-
] ? GetPropertiesDocOfSubDoc<Rest, Result & Head["properties"]> : Result;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GetPropertiesDocOfSubDoc.js","sourceRoot":"","sources":["../../../../src/api/DefineComponent/ReturnType/GetPropertiesDocOfSubDoc.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|