annil 1.7.4 → 1.7.5-beta.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 +30 -0
- package/README.md +11 -7
- package/dist/api/DefineComponent/NameOrPage/NameOrPathOption.d.ts +9 -0
- package/dist/api/DefineComponent/ReturnType/ComponentDoc.d.ts +9 -0
- package/dist/api/DefineComponent/ReturnType/GetCustomEventDocOfSubDoc.d.ts +8 -0
- package/dist/api/DefineComponent/ReturnType/PageDoc.d.ts +9 -0
- package/dist/api/DefineComponent/RootComponent/RootComponentOption.d.ts +6 -0
- package/dist/api/DefineComponent/SubComponents/SubComponentsOption.d.ts +6 -0
- package/dist/api/DefineComponent/index.d.ts +5 -4
- package/dist/api/DefineComponent/index.js +8 -2
- package/dist/api/DefineComponent/index.js.map +1 -1
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/computedUpdater.d.ts +1 -1
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/computedUpdater.js +5 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/computedUpdater.js.map +1 -0
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/data-tracer.d.ts +3 -1
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/data-tracer.js +4 -1
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/data-tracer.js.map +1 -0
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/dependencesOptimize.js +5 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/dependencesOptimize.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/getPathsValue.d.ts +7 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/getPathsValue.js +30 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/getPathsValue.js.map +1 -0
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/getPropertiesValue.js +3 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/getPropertiesValue.js.map +1 -0
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/index.js +13 -3
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/index.js.map +1 -0
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/initComputedAndGetCache.d.ts +9 -0
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/initComputedAndGetCache.js +21 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/initComputedAndGetCache.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/isEqual.d.ts +7 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/isEqual.js +69 -0
- package/dist/api/DefineComponent/normalizeOptions/computedWatchHandle/isEqual.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/customEventsHandle.d.ts +6 -0
- package/dist/api/DefineComponent/normalizeOptions/customEventsHandle.js +23 -0
- package/dist/api/DefineComponent/normalizeOptions/customEventsHandle.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/index.d.ts +6 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/index.js +16 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/index.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/isPageCheck.d.ts +5 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/isPageCheck.js +17 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/isPageCheck.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/loadReceivedDataHandle.d.ts +7 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/loadReceivedDataHandle.js +20 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/loadReceivedDataHandle.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/onLoadReceivedDataHandle.d.ts +10 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/onLoadReceivedDataHandle.js +26 -0
- package/dist/api/DefineComponent/normalizeOptions/hijackHandle/onLoadReceivedDataHandle.js.map +1 -0
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/index.d.ts +20 -18
- package/dist/api/DefineComponent/normalizeOptions/index.js +77 -0
- package/dist/api/DefineComponent/normalizeOptions/index.js.map +1 -0
- package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/initStore/index.js +2 -0
- package/dist/api/DefineComponent/normalizeOptions/initStore/index.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/injectInfoHandler.d.ts +3 -0
- package/dist/api/DefineComponent/normalizeOptions/injectInfoHandler.js +43 -0
- package/dist/api/DefineComponent/normalizeOptions/injectInfoHandler.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/internalFieldProtection.d.ts +5 -0
- package/dist/api/DefineComponent/normalizeOptions/internalFieldProtection.js +23 -0
- package/dist/api/DefineComponent/normalizeOptions/internalFieldProtection.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/otherFieldsHandle.d.ts +6 -0
- package/dist/api/DefineComponent/normalizeOptions/otherFieldsHandle.js +24 -0
- package/dist/api/DefineComponent/normalizeOptions/otherFieldsHandle.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/rootComponentOptionHandle.d.ts +9 -0
- package/dist/api/DefineComponent/normalizeOptions/rootComponentOptionHandle.js +18 -0
- package/dist/api/DefineComponent/normalizeOptions/rootComponentOptionHandle.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/sameFuncFieldsCollect.d.ts +7 -0
- package/dist/api/DefineComponent/normalizeOptions/sameFuncFieldsCollect.js +17 -0
- package/dist/api/DefineComponent/normalizeOptions/sameFuncFieldsCollect.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/sameFuncOptionsHandle.d.ts +5 -0
- package/dist/api/DefineComponent/normalizeOptions/sameFuncOptionsHandle.js +34 -0
- package/dist/api/DefineComponent/normalizeOptions/sameFuncOptionsHandle.js.map +1 -0
- package/dist/api/DefineComponent/normalizeOptions/subComponentsOptionHandle.d.ts +3 -0
- package/dist/api/DefineComponent/normalizeOptions/subComponentsOptionHandle.js +11 -0
- package/dist/api/DefineComponent/normalizeOptions/subComponentsOptionHandle.js.map +1 -0
- package/dist/api/InstanceInject/instanceConfig.d.ts +4 -0
- package/dist/api/InstanceInject/instanceConfig.js +5 -1
- package/dist/api/InstanceInject/instanceConfig.js.map +1 -1
- package/dist/api/RootComponent/Computed/ComputedConstraint.d.ts +4 -1
- package/dist/api/RootComponent/Computed/ComputedOption.d.ts +23 -0
- package/dist/api/RootComponent/Computed/GetComputedDoc.d.ts +5 -0
- package/dist/api/RootComponent/CustomEvents/CustomEventConstraint.d.ts +3 -0
- package/dist/api/RootComponent/CustomEvents/CustomEventsOption.d.ts +29 -0
- package/dist/api/RootComponent/CustomEvents/GetCustomEventDoc.d.ts +13 -0
- package/dist/api/RootComponent/Data/DataOption.d.ts +14 -0
- package/dist/api/RootComponent/Events/EventsConstraint.d.ts +4 -1
- package/dist/api/RootComponent/Events/EventsOption.d.ts +52 -0
- package/dist/api/RootComponent/Instance/CustomSetData.d.ts +6 -0
- package/dist/api/RootComponent/Instance/RootComponentInstance.d.ts +9 -0
- package/dist/api/RootComponent/IsPage/IsPageOption.d.ts +3 -0
- package/dist/api/RootComponent/Lifetimes/LifetimesConstraint.d.ts +5 -2
- package/dist/api/RootComponent/Lifetimes/LifetimesOption.d.ts +26 -0
- package/dist/api/RootComponent/Methods/MethodsOption.d.ts +3 -0
- package/dist/api/RootComponent/Observers/ObserversOption.d.ts +4 -0
- package/dist/api/RootComponent/PageLifetimes/PageLifetimesOption.d.ts +11 -0
- package/dist/api/RootComponent/Properties/GetOptionalDoc.d.ts +3 -0
- package/dist/api/RootComponent/Properties/GetPropertiesDoc.d.ts +3 -0
- package/dist/api/RootComponent/Properties/GetRequiredDoc.d.ts +4 -0
- package/dist/api/RootComponent/Properties/PropertiesConstraint.d.ts +18 -0
- package/dist/api/RootComponent/Properties/PropertiesOption.d.ts +10 -0
- package/dist/api/RootComponent/Properties/PropertiesValueValidator.d.ts +4 -0
- package/dist/api/RootComponent/RootComponentDoc.d.ts +19 -0
- package/dist/api/RootComponent/Store/StoreOption.d.ts +12 -0
- package/dist/api/RootComponent/Watch/WatchOption.d.ts +4 -0
- package/dist/api/RootComponent/index.d.ts +17 -19
- package/dist/api/RootComponent/index.js +1 -0
- package/dist/api/RootComponent/index.js.map +1 -1
- package/dist/api/SubComponent/SubComponentDoc.d.ts +9 -0
- package/dist/api/SubComponent/SubData/SubDataConstraint.d.ts +4 -0
- package/dist/api/SubComponent/SubData/SubDataOption.d.ts +4 -0
- package/dist/api/SubComponent/SubEvents/SubEventsConstraint.d.ts +3 -0
- package/dist/api/SubComponent/SubEvents/SubEventsOptions.d.ts +5 -0
- package/dist/api/SubComponent/SubInherit/SubInheritConstraint.d.ts +4 -0
- package/dist/api/SubComponent/SubInherit/SubInheritOption.d.ts +6 -1
- package/dist/api/SubComponent/SubMethods/SubMethodsConstraint.d.ts +1 -3
- package/dist/api/SubComponent/SubMethods/SubMethodsOption.d.ts +3 -0
- package/dist/api/SubComponent/SubStore/SubStoreConstraint.d.ts +4 -0
- package/dist/api/SubComponent/SubStore/SubStoreOption.d.ts +14 -0
- package/dist/api/SubComponent/index.d.ts +10 -8
- package/dist/api/SubComponent/index.js +5 -0
- package/dist/api/SubComponent/index.js.map +1 -1
- package/dist/api/navigateTo.d.ts +5 -0
- package/dist/api/navigateTo.js +10 -1
- package/dist/api/navigateTo.js.map +1 -1
- package/dist/behaviors/BStore.d.ts +4 -0
- package/dist/behaviors/BStore.js +9 -0
- package/dist/behaviors/BStore.js.map +1 -1
- package/dist/behaviors/BbeforeCreated.d.ts +3 -0
- package/dist/behaviors/BbeforeCreated.js +8 -1
- package/dist/behaviors/BbeforeCreated.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/thirdLib/vant/Button.d.ts +14 -2
- package/dist/thirdLib/vant/NoticeBar.d.ts +2 -2
- package/dist/thirdLib/vant/Popup.d.ts +42 -2
- package/dist/thirdLib/wm/Textarea.d.ts +11 -2
- package/dist/thirdLib/wm/baseEvents.d.ts +39 -2
- package/dist/thirdLib/wm/scrollView.d.ts +4 -2
- package/dist/thirdLib/wm/scrollView.js +6 -0
- package/dist/thirdLib/wm/scrollView.js.map +1 -1
- package/dist/thirdLib/wm/swiper.d.ts +75 -5
- package/dist/thirdLib/wm/view.d.ts +20 -2
- package/dist/types/AddNullForObject.d.ts +3 -0
- package/dist/types/AddPrefix.d.ts +7 -0
- package/dist/types/{GenerateDoc.d.ts → CreateComponentType.d.ts} +3 -3
- package/dist/types/CreateComponentType.js +2 -0
- package/dist/types/CreateComponentType.js.map +1 -0
- package/dist/types/DetailedType.d.ts +15 -5
- package/dist/types/DocAssign.d.ts +3 -0
- package/dist/types/DocAssign.js +4 -0
- package/dist/types/DocAssign.js.map +1 -1
- package/dist/types/GetComponentPrefix.d.ts +3 -0
- package/dist/types/GetComponentPrefix.js +10 -0
- package/dist/types/GetComponentPrefix.js.map +1 -1
- package/dist/types/InferDetailedType.d.ts +3 -0
- package/dist/types/OfficialTypeAlias.d.ts +15 -9
- package/dist/types/OfficialTypeAlias.js +30 -0
- package/dist/types/OfficialTypeAlias.js.map +1 -1
- package/dist/types/RemoveInnerData.d.ts +3 -0
- package/dist/types/Replace.d.ts +11 -0
- package/dist/types/ReplacePrefix.d.ts +5 -0
- package/dist/types/ReplacePrefix.js +9 -0
- package/dist/types/ReplacePrefix.js.map +1 -1
- package/dist/types/RequiredKeys.d.ts +4 -0
- package/dist/types/Validators.js +7 -0
- package/dist/types/Validators.js.map +1 -1
- package/dist/utils/InnerMarker.js +1 -1
- package/dist/utils/InnerMarker.js.map +1 -1
- package/dist/utils/assertNonNullable.d.ts +2 -0
- package/dist/utils/assertNonNullable.js +7 -0
- package/dist/utils/assertNonNullable.js.map +1 -0
- package/dist/utils/deepClone.d.ts +3 -0
- package/dist/utils/deepClone.js +3 -0
- package/dist/utils/deepClone.js.map +1 -1
- package/dist/utils/isEmptyObject.d.ts +3 -0
- package/dist/utils/isEmptyObject.js +3 -0
- package/dist/utils/isEmptyObject.js.map +1 -1
- package/package.json +6 -6
- package/src/api/DefineComponent/ReturnType/ComponentDoc.ts +1 -0
- package/src/api/DefineComponent/ReturnType/test/normalComponentDoc.test.ts +2 -0
- package/src/api/DefineComponent/ReturnType/test/normalPageDoc.test.ts +3 -2
- package/src/api/DefineComponent/SubComponents/SubComponentsOption.ts +0 -5
- package/src/api/DefineComponent/SubComponents/test/normal.test.ts +2 -2
- package/src/api/DefineComponent/index.ts +21 -23
- package/src/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/computedUpdater.ts +1 -1
- package/src/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/data-tracer.ts +2 -3
- package/src/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/getPathsValue.ts +2 -1
- package/src/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/index.ts +7 -9
- package/src/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/isEqual.ts +2 -2
- package/src/api/DefineComponent/normalizeOptions/customEventsHandle.ts +34 -0
- package/src/api/DefineComponent/normalizeOptions/hijackHandle/index.ts +26 -0
- package/src/api/DefineComponent/normalizeOptions/hijackHandle/isPageCheck.ts +22 -0
- package/src/api/DefineComponent/normalizeOptions/hijackHandle/loadReceivedDataHandle.ts +25 -0
- package/src/api/DefineComponent/normalizeOptions/hijackHandle/onLoadReceivedDataHandle.ts +33 -0
- package/src/api/DefineComponent/normalizeOptions/index.ts +142 -0
- package/src/api/DefineComponent/{assignOptions → normalizeOptions}/initStore/index.ts +1 -0
- package/src/api/DefineComponent/normalizeOptions/injectInfoHandler.ts +51 -0
- package/src/api/DefineComponent/normalizeOptions/internalFieldProtection.ts +26 -0
- package/src/api/DefineComponent/normalizeOptions/otherFieldsHandle.ts +27 -0
- package/src/api/DefineComponent/normalizeOptions/rootComponentOptionHandle.ts +25 -0
- package/src/api/DefineComponent/normalizeOptions/sameFuncFieldsCollect.ts +22 -0
- package/src/api/DefineComponent/normalizeOptions/sameFuncOptionsHandle.ts +37 -0
- package/src/api/DefineComponent/normalizeOptions/subComponentsOptionHandle.ts +18 -0
- package/src/api/InstanceInject/inject.ts +2 -0
- package/src/api/InstanceInject/instanceConfig.ts +2 -4
- package/src/api/InstanceInject/test/normal.test.ts +1 -0
- package/src/api/RootComponent/Computed/ComputedConstraint.ts +1 -1
- package/src/api/RootComponent/Computed/test/GetComputedDoc.test.ts +1 -0
- package/src/api/RootComponent/Computed/test/normal.test.ts +2 -0
- package/src/api/RootComponent/CustomEvents/test/GetCustomEventDoc.test.ts +2 -2
- package/src/api/RootComponent/CustomEvents/test/GetFullEventDoc.test.ts +2 -1
- package/src/api/RootComponent/CustomEvents/test/GetShortEventDoc.test.ts +2 -1
- package/src/api/RootComponent/CustomEvents/test/error.test.ts +2 -2
- package/src/api/RootComponent/CustomEvents/test/normal.test.ts +2 -0
- package/src/api/RootComponent/Data/test/GetDataDoc.test.ts +2 -2
- package/src/api/RootComponent/Data/test/normal.test.ts +3 -2
- package/src/api/RootComponent/Events/EventsConstraint.ts +1 -1
- package/src/api/RootComponent/Events/test/normal.test.ts +5 -2
- package/src/api/RootComponent/Instance/RootComponentInstance.ts +9 -0
- package/src/api/RootComponent/Instance/test/CustomEventsDoc.test.ts +1 -0
- package/src/api/RootComponent/Instance/test/customEvents/normal.test.ts +1 -0
- package/src/api/RootComponent/Instance/test/methods/mormal.test.ts +2 -2
- package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +2 -0
- package/src/api/RootComponent/Instance/test/setData/error.test.ts +1 -1
- package/src/api/RootComponent/Instance/test/setData/normal.test.ts +1 -1
- package/src/api/RootComponent/IsPage/test/normal.test.ts +2 -0
- package/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts +2 -2
- package/src/api/RootComponent/Lifetimes/test/error.test.ts +22 -8
- package/src/api/RootComponent/Lifetimes/test/normal.test.ts +8 -3
- package/src/api/RootComponent/Methods/test/error.test.ts +4 -4
- package/src/api/RootComponent/Methods/test/mormal.test.ts +2 -2
- package/src/api/RootComponent/Observers/test/normal.test.ts +8 -4
- package/src/api/RootComponent/PageLifetimes/test/error.test.ts +17 -7
- package/src/api/RootComponent/PageLifetimes/test/normal.test.ts +12 -5
- package/src/api/RootComponent/Properties/test/normalEmpty.test.ts +6 -6
- package/src/api/RootComponent/Properties/test/normalOptional.test.ts +4 -4
- package/src/api/RootComponent/Properties/test/normalRequired.test.ts +3 -3
- package/src/api/RootComponent/Store/test/normal.test.ts +4 -4
- package/src/api/RootComponent/Watch/test/WatchComputed.test.ts +6 -4
- package/src/api/RootComponent/Watch/test/WatchData.test.ts +16 -12
- package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +58 -40
- package/src/api/RootComponent/Watch/test/WtachInject.test.ts +3 -2
- package/src/api/RootComponent/Watch/test/error.test.ts +4 -2
- package/src/api/RootComponent/index.ts +47 -48
- package/src/api/SubComponent/SubComputed/test/error.test.ts +6 -2
- package/src/api/SubComponent/SubComputed/test/normal.test.ts +8 -7
- package/src/api/SubComponent/SubData/test/normal.test.ts +2 -2
- package/src/api/SubComponent/SubEvents/test/error.test.ts +4 -2
- package/src/api/SubComponent/SubEvents/test/normal.test.ts +4 -2
- package/src/api/SubComponent/SubInherit/SubInheritOption.ts +1 -3
- package/src/api/SubComponent/SubInherit/test/error.test.ts +2 -2
- package/src/api/SubComponent/SubInstance/test/error.test.ts +1 -1
- package/src/api/SubComponent/SubInstance/test/normal.test.ts +10 -6
- package/src/api/SubComponent/SubMethods/SubMethodsConstraint.ts +1 -3
- package/src/api/SubComponent/SubMethods/test/error.test.ts +8 -2
- package/src/api/SubComponent/SubMethods/test/normarl.test.ts +6 -2
- package/src/api/SubComponent/SubReturnType/test/error.test.ts +2 -2
- package/src/api/SubComponent/SubReturnType/test/normal.test.ts +2 -2
- package/src/api/SubComponent/SubWatch/test/WatchComputed.test.ts +21 -14
- package/src/api/SubComponent/SubWatch/test/WatchProperties.test.ts +58 -58
- package/src/api/SubComponent/SubWatch/test/WatchRootData.test.ts +43 -31
- package/src/api/SubComponent/SubWatch/test/WatchSubData.test.ts +9 -6
- package/src/api/SubComponent/SubWatch/test/WtachInject.test.ts +3 -2
- package/src/api/SubComponent/SubWatch/test/error.test.ts +5 -4
- package/src/api/SubComponent/index.ts +92 -95
- package/src/api/navigateTo.ts +1 -1
- package/src/behaviors/BStore.ts +7 -3
- package/src/behaviors/BbeforeCreated.ts +8 -3
- package/src/index.ts +2 -2
- package/src/thirdLib/vant/Button.ts +2 -2
- package/src/thirdLib/vant/NoticeBar.ts +2 -2
- package/src/thirdLib/vant/Popup.ts +2 -2
- package/src/thirdLib/wm/Textarea.ts +2 -2
- package/src/thirdLib/wm/baseEvents.ts +3 -2
- package/src/thirdLib/wm/scrollView.ts +4 -2
- package/src/thirdLib/wm/swiper.ts +10 -5
- package/src/thirdLib/wm/view.ts +4 -2
- package/src/types/{GenerateDoc.ts → CreateComponentType.ts} +3 -6
- package/src/types/DetailedType.ts +1 -1
- package/src/types/InferDetailedType.test.ts +8 -13
- package/src/types/OfficialTypeAlias.ts +31 -31
- package/src/utils/assertNonNullable.ts +11 -0
- package/src/utils/isEmptyObject.ts +1 -1
- package/tsconfig.json +11 -16
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/computedUpdater.js.map +0 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/data-tracer.js.map +0 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/dependencesOptimize.js.map +0 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/getPathsValue.d.ts +0 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/getPathsValue.js +0 -19
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/getPathsValue.js.map +0 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/getPropertiesValue.js.map +0 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/index.js.map +0 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/initComputedAndGetCache.js.map +0 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/isEqual.d.ts +0 -1
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/isEqual.js +0 -48
- package/dist/api/DefineComponent/assignOptions/computedWatchHandle/isEqual.js.map +0 -1
- package/dist/api/DefineComponent/assignOptions/index.js +0 -203
- package/dist/api/DefineComponent/assignOptions/index.js.map +0 -1
- package/dist/api/DefineComponent/assignOptions/initStore/index.js.map +0 -1
- package/dist/types/CreateComponentDoc.d.ts +0 -10
- package/dist/types/CreateComponentDoc.js +0 -2
- package/dist/types/CreateComponentDoc.js.map +0 -1
- package/dist/types/GenerateDoc.js +0 -2
- package/dist/types/GenerateDoc.js.map +0 -1
- package/src/api/DefineComponent/assignOptions/index.ts +0 -469
- package/src/types/CreateComponentDoc.ts +0 -17
- /package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/dependencesOptimize.d.ts +0 -0
- /package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/getPropertiesValue.d.ts +0 -0
- /package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/index.d.ts +0 -0
- /package/dist/api/DefineComponent/{assignOptions → normalizeOptions}/initStore/index.d.ts +0 -0
- /package/src/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/dependencesOptimize.ts +0 -0
- /package/src/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/getPropertiesValue.ts +0 -0
- /package/src/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/initComputedAndGetCache.ts +0 -0
package/src/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/index.ts
RENAMED
|
@@ -5,19 +5,17 @@ import { getPropertiesValue } from "./getPropertiesValue";
|
|
|
5
5
|
import { initComputedAndGetCache } from "./initComputedAndGetCache";
|
|
6
6
|
import { isEqual } from "./isEqual";
|
|
7
7
|
|
|
8
|
+
import { assertNonNullable } from "../../../../utils/assertNonNullable";
|
|
8
9
|
import { deepClone } from "../../../../utils/deepClone";
|
|
9
10
|
import { isEmptyObject } from "../../../../utils/isEmptyObject";
|
|
10
|
-
import type {
|
|
11
|
+
import type { Instance } from "../../../RootComponent/Instance/RootComponentInstance";
|
|
12
|
+
import type { FinalOptionsOfComponent } from "..";
|
|
11
13
|
|
|
12
14
|
type WatchOldValue = Record<string, unknown[]>;
|
|
13
15
|
|
|
14
16
|
function initWatchOldValue(data: FinalOptionsOfComponent["data"], watchConfig: object): WatchOldValue {
|
|
15
17
|
const watchOldValue = {};
|
|
16
18
|
for (const key in watchConfig) {
|
|
17
|
-
// watchOldValue[key] = deepClone(getPathsValue(data, key));
|
|
18
|
-
|
|
19
|
-
// watchOldValue[key] = getPathsValue(data, key);
|
|
20
|
-
|
|
21
19
|
// @ts-ignore 隐式索引
|
|
22
20
|
watchOldValue[key] = deepClone(getPathsValue(data, key));
|
|
23
21
|
}
|
|
@@ -29,7 +27,7 @@ export function computedWatchHandle(options: FinalOptionsOfComponent) {
|
|
|
29
27
|
const computedConfig = options.computed;
|
|
30
28
|
const rawPropertiesValue = getPropertiesValue(options.properties);
|
|
31
29
|
if (computedConfig && !isEmptyObject(computedConfig)) {
|
|
32
|
-
// 此时store已经初始化数据到data了
|
|
30
|
+
// 此时store已经初始化数据到data了(__storeConfig__)
|
|
33
31
|
|
|
34
32
|
const __computedInitCache__ = initComputedAndGetCache(options, computedConfig, {
|
|
35
33
|
...options.data,
|
|
@@ -50,7 +48,7 @@ export function computedWatchHandle(options: FinalOptionsOfComponent) {
|
|
|
50
48
|
// 任何setData都会触发计算属性更新(可能依赖数据并没变化)
|
|
51
49
|
this.__computedUpdater__?.();
|
|
52
50
|
|
|
53
|
-
originalFunc
|
|
51
|
+
originalFunc?.call(this);
|
|
54
52
|
};
|
|
55
53
|
|
|
56
54
|
// watch handle
|
|
@@ -68,9 +66,9 @@ export function computedWatchHandle(options: FinalOptionsOfComponent) {
|
|
|
68
66
|
|
|
69
67
|
// 在监控多个数据时,参数是多个值
|
|
70
68
|
observersConfig[key] = function(this: Instance, ...newValue: unknown[]) {
|
|
71
|
-
originObserversHandle
|
|
69
|
+
originObserversHandle?.call(this, ...newValue);
|
|
72
70
|
|
|
73
|
-
const watchOldValue = this.data.__watchOldValue__
|
|
71
|
+
const watchOldValue = assertNonNullable(this.data.__watchOldValue__);
|
|
74
72
|
const oldValue = watchOldValue[key];
|
|
75
73
|
|
|
76
74
|
if (isEqual(newValue, oldValue)) return;
|
package/src/api/DefineComponent/{assignOptions → normalizeOptions}/computedWatchHandle/isEqual.ts
RENAMED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable complexity */
|
|
2
|
-
|
|
3
1
|
function isSameType(a: object, b: object) {
|
|
4
2
|
return Object.prototype.toString.call(a) === Object.prototype.toString.call(b);
|
|
5
3
|
}
|
|
@@ -10,6 +8,7 @@ function isSameSize(a: object, b: object) {
|
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
// 定义一个辅助函数,用于判断两个函数的代码是否相同
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
13
12
|
function isSameCode(a: Function, b: Function) {
|
|
14
13
|
// 去除空格比较函数字符串
|
|
15
14
|
return a.toString().split(" ").join("") === b.toString().split(" ").join("");
|
|
@@ -46,6 +45,7 @@ export function isEqual(a: unknown, b: unknown) {
|
|
|
46
45
|
|
|
47
46
|
// 如果两个值是函数类型,再判断它们的代码是否相同
|
|
48
47
|
if (typeof a === "function") {
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
49
49
|
return isSameCode(a, b as Function);
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CustomEventConstraint,
|
|
3
|
+
CustomEvents,
|
|
4
|
+
FullCustomEvents,
|
|
5
|
+
} from "../../RootComponent/CustomEvents/CustomEventConstraint";
|
|
6
|
+
import type { Instance } from "../../RootComponent/Instance/RootComponentInstance";
|
|
7
|
+
import type { FinalOptionsOfComponent } from ".";
|
|
8
|
+
// 类型守卫
|
|
9
|
+
function IsFullCustomEvents(
|
|
10
|
+
customEventOptions: CustomEvents,
|
|
11
|
+
): customEventOptions is FullCustomEvents {
|
|
12
|
+
return Object.prototype.toString.call(customEventOptions) === "[object Object]";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 把customEvents字段配置变成函数放入到componentOptions.methods中
|
|
16
|
+
*/
|
|
17
|
+
export function customEventsHandle(
|
|
18
|
+
methods: FinalOptionsOfComponent["methods"],
|
|
19
|
+
customEventsConfig: CustomEventConstraint,
|
|
20
|
+
) {
|
|
21
|
+
for (const key in customEventsConfig) {
|
|
22
|
+
const customEventOptions = customEventsConfig[key];
|
|
23
|
+
|
|
24
|
+
if (IsFullCustomEvents(customEventOptions)) {
|
|
25
|
+
methods[key] = function(this: Instance, detail: unknown) {
|
|
26
|
+
this.triggerEvent(key, detail, customEventOptions.options);
|
|
27
|
+
};
|
|
28
|
+
} else {
|
|
29
|
+
methods[key] = function(this: Instance, detail: unknown) {
|
|
30
|
+
this.triggerEvent(key, detail);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Func } from "hry-types/src/Misc/Func";
|
|
2
|
+
import type { FinalOptionsOfComponent } from "..";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 劫持指定配置字段,在原有配置前执行指定函数
|
|
6
|
+
*/
|
|
7
|
+
export function hijack<T extends FinalOptionsOfComponent[keyof FinalOptionsOfComponent]>(
|
|
8
|
+
config: T,
|
|
9
|
+
field: keyof T,
|
|
10
|
+
before: Func[],
|
|
11
|
+
// after: Func[] = [],
|
|
12
|
+
) {
|
|
13
|
+
// @ts-ignore 隐式索引
|
|
14
|
+
const originalFunc: Func | undefined = config[field];
|
|
15
|
+
|
|
16
|
+
// @ts-ignore 隐式索引
|
|
17
|
+
config[field] = function(...args: unknown[]) {
|
|
18
|
+
before.forEach(func => func.call(this, ...args));
|
|
19
|
+
|
|
20
|
+
if (originalFunc) originalFunc.apply(this, args);
|
|
21
|
+
|
|
22
|
+
// after.forEach(func => func.call(this, ...args));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Instance, PageInstance } from "../../../RootComponent/Instance/RootComponentInstance";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 劫持attached,根据this.route做判断 isPage值是否正确
|
|
5
|
+
*/
|
|
6
|
+
export function isPageCheck(isPage: boolean | undefined) {
|
|
7
|
+
return function(this: Instance) {
|
|
8
|
+
const route = (this as PageInstance).route as string | undefined;
|
|
9
|
+
if (route && isPage !== true) {
|
|
10
|
+
// 页面isPage值错误
|
|
11
|
+
throw Error(
|
|
12
|
+
`页面 /${route} 中, RootComponent构建页面时,isPage字段值应为 true`,
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
if (!route && isPage !== false && isPage !== undefined) {
|
|
16
|
+
// 组件写了isPage = true
|
|
17
|
+
throw Error(
|
|
18
|
+
`组件 ${this.is} 中 RootComponent构建组件时,可不写isPage字段或值为 false`,
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 针对通过 navigateTo传过来的数据对组件load周期传入数据解析
|
|
3
|
+
* @param option - option中的url是拼接了encodeURIComponent转码的data对象的,key为INNERMARKER.url
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { INNERMARKER } from "../../../../utils/InnerMarker";
|
|
7
|
+
import type { PageInstance } from "../../../RootComponent/Instance/RootComponentInstance";
|
|
8
|
+
|
|
9
|
+
/* istanbul ignore next miniprogram-simulate(当前版本 1.6.1) 无法测试load */
|
|
10
|
+
export function loadReceivedDataHandle(
|
|
11
|
+
this: PageInstance,
|
|
12
|
+
option: Record<typeof INNERMARKER.url, string>,
|
|
13
|
+
) {
|
|
14
|
+
const innerData: string | undefined = option[INNERMARKER.url];
|
|
15
|
+
// 未使用自定义的navigateTo
|
|
16
|
+
if (innerData === undefined) return;
|
|
17
|
+
// 使用navigateTo API
|
|
18
|
+
const decodeOption = JSON.parse(decodeURIComponent(innerData));
|
|
19
|
+
|
|
20
|
+
for (const key in decodeOption) {
|
|
21
|
+
option[key] = decodeOption[key];
|
|
22
|
+
}
|
|
23
|
+
// 给onLoad劫持函数一个标记,判断在新框架下已经被解析过了
|
|
24
|
+
option[INNERMARKER.url] = INNERMARKER.url;
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 原生Component会对传入的对象字段匹配的properties字段setData赋值。不符合字段或Page时不会赋值。
|
|
3
|
+
* 此函数为给实例setData赋值,默认传递值与properties相符(ts类型安全)。
|
|
4
|
+
* @param option - 传入onLoad的参数 有以下两种可能
|
|
5
|
+
* 1. 使用wx.navigateTo传值的。这种情况无内置字段 option[INNERMARKER.url] 等于 undefined
|
|
6
|
+
* 2. 使用插件提供的navigateTo传值。这种情况 INNERMARKER.url被load周期劫持函数解码后赋值INNERMARKER.url字段为本身,即option[INNERMARKER.url] 等于 INNERMARKER.url
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { INNERMARKER } from "../../../../utils/InnerMarker";
|
|
10
|
+
import type { PageInstance } from "../../../RootComponent/Instance/RootComponentInstance";
|
|
11
|
+
|
|
12
|
+
/* istanbul ignore next miniprogram-simulate(当前版本 1.6.1) 无法测试页面生命周期 */
|
|
13
|
+
export function onLoadReceivedDataHandle(
|
|
14
|
+
this: PageInstance,
|
|
15
|
+
option: Record<typeof INNERMARKER.url, string>,
|
|
16
|
+
) {
|
|
17
|
+
const innerData: string | undefined = option[INNERMARKER.url];
|
|
18
|
+
|
|
19
|
+
// 情况1为undefined,2为INNERMARKER.url有值但不是本身,说明是老框架。3所以innerData等于 INNERMARKER.url即有组件配置了load(新框架在pageLifetimes.load中提前解析了)
|
|
20
|
+
if (innerData === undefined) return;
|
|
21
|
+
if (innerData !== INNERMARKER.url) {
|
|
22
|
+
// 需要情况2 需要解析
|
|
23
|
+
const decodeOption = JSON.parse(decodeURIComponent(innerData));
|
|
24
|
+
for (const key in decodeOption) {
|
|
25
|
+
option[key] = decodeOption[key];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
30
|
+
delete option[INNERMARKER.url];
|
|
31
|
+
|
|
32
|
+
this.setData(option);
|
|
33
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { Func } from "hry-types/src/Misc/_api";
|
|
2
|
+
import { instanceConfig } from "../../..";
|
|
3
|
+
import { BBeforeCreate } from "../../../behaviors/BbeforeCreated";
|
|
4
|
+
import { BStore } from "../../../behaviors/BStore";
|
|
5
|
+
import { isEmptyObject } from "../../../utils/isEmptyObject";
|
|
6
|
+
import type { ComputedConstraint } from "../../RootComponent/Computed/ComputedConstraint";
|
|
7
|
+
import type { DataConstraint } from "../../RootComponent/Data/DataConstraint";
|
|
8
|
+
import type { LifetimesConstraint } from "../../RootComponent/Lifetimes/LifetimesConstraint";
|
|
9
|
+
import type { MethodsConstraint } from "../../RootComponent/Methods/MethodsConstraint";
|
|
10
|
+
import type { PageLifetimesOption } from "../../RootComponent/PageLifetimes/PageLifetimesOption";
|
|
11
|
+
import type { PropertiesConstraint } from "../../RootComponent/Properties/PropertiesConstraint";
|
|
12
|
+
import type { StoreConstraint } from "../../RootComponent/Store/StoreConstraint";
|
|
13
|
+
import type { DefineComponentOption } from "..";
|
|
14
|
+
import { computedWatchHandle } from "./computedWatchHandle";
|
|
15
|
+
import type { ComputedCache } from "./computedWatchHandle/initComputedAndGetCache";
|
|
16
|
+
import { hijack } from "./hijackHandle";
|
|
17
|
+
import { isPageCheck } from "./hijackHandle/isPageCheck";
|
|
18
|
+
import { loadReceivedDataHandle } from "./hijackHandle/loadReceivedDataHandle";
|
|
19
|
+
import { onLoadReceivedDataHandle } from "./hijackHandle/onLoadReceivedDataHandle";
|
|
20
|
+
import { initStore } from "./initStore";
|
|
21
|
+
import { injectInfoHandler } from "./injectInfoHandler";
|
|
22
|
+
import { InternalFieldProtection } from "./internalFieldProtection";
|
|
23
|
+
import { rootComponentOptionHandle } from "./rootComponentOptionHandle";
|
|
24
|
+
import { sameFuncOptionsHandle } from "./sameFuncOptionsHandle";
|
|
25
|
+
import { subComponentsOptionHandle } from "./subComponentsOptionHandle";
|
|
26
|
+
|
|
27
|
+
export type WatchOldValue = Record<string, unknown[]>;
|
|
28
|
+
|
|
29
|
+
export type OptionsInnerFields = {
|
|
30
|
+
data: {
|
|
31
|
+
__computedCache__?: ComputedCache;
|
|
32
|
+
__storeConfig__?: StoreConstraint;
|
|
33
|
+
__watchOldValue__?: WatchOldValue;
|
|
34
|
+
};
|
|
35
|
+
methods: {
|
|
36
|
+
disposer?: Record<string, Func>;
|
|
37
|
+
// computedHandle加入
|
|
38
|
+
__computedUpdater__?: Func;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 临时的函数配置项
|
|
44
|
+
* 把根组件与子组件中配置类型为函数的相同字段配置收集在一起(数组)
|
|
45
|
+
*/
|
|
46
|
+
export type SameFuncOptions = Record<"pageLifetimes" | "lifetimes" | "watch" | "observers", Record<string, Func[]>>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 最终传入原生Component的配置项
|
|
50
|
+
*/
|
|
51
|
+
export type FinalOptionsOfComponent = {
|
|
52
|
+
data: DataConstraint & OptionsInnerFields["data"];
|
|
53
|
+
observers: Record<string, Func>;
|
|
54
|
+
behaviors: string[];
|
|
55
|
+
methods: MethodsConstraint & OptionsInnerFields["methods"];
|
|
56
|
+
externalClasses: string[];
|
|
57
|
+
pageLifetimes: PageLifetimesOption<false, object>["pageLifetimes"] & {};
|
|
58
|
+
isPage: boolean;
|
|
59
|
+
options: WechatMiniprogram.Component.ComponentOptions;
|
|
60
|
+
properties: PropertiesConstraint;
|
|
61
|
+
store?: StoreConstraint;
|
|
62
|
+
computed: ComputedConstraint;
|
|
63
|
+
watch: Record<string, Func>;
|
|
64
|
+
lifetimes: LifetimesConstraint;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* 把DefineComponentOption转化为原生Component API支持的配置
|
|
68
|
+
* @param defineComponentOption
|
|
69
|
+
* @returns 返回符合原生Component API配置
|
|
70
|
+
*/
|
|
71
|
+
export function normalizeOptions(
|
|
72
|
+
defineComponentOption: DefineComponentOption,
|
|
73
|
+
): FinalOptionsOfComponent {
|
|
74
|
+
const rootComponentOption = defineComponentOption.rootComponent;
|
|
75
|
+
const subComponentsOption = defineComponentOption.subComponents;
|
|
76
|
+
const finalOptionsForComponent: FinalOptionsOfComponent = injectInfoHandler({
|
|
77
|
+
observers: {},
|
|
78
|
+
data: {},
|
|
79
|
+
methods: {},
|
|
80
|
+
// 加入BStore,处理store字段的behavior
|
|
81
|
+
behaviors: [BStore],
|
|
82
|
+
externalClasses: [],
|
|
83
|
+
pageLifetimes: {},
|
|
84
|
+
isPage: false,
|
|
85
|
+
properties: {},
|
|
86
|
+
computed: {},
|
|
87
|
+
watch: {},
|
|
88
|
+
lifetimes: {},
|
|
89
|
+
options: {},
|
|
90
|
+
}, instanceConfig.injectInfo);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 为了更高的效率,在处理rootComponentOption和subComponentsOption数据时,把相同字段配置(pageLifetimes,lifetimes,watch,observers)收集到funcOptions中。
|
|
94
|
+
* 后续再一起处理这些字段,整合进finalOptionsForComponent配置中。即funcConfig是一个临时中介对象。
|
|
95
|
+
*/
|
|
96
|
+
const sameFuncOptions: SameFuncOptions = {
|
|
97
|
+
pageLifetimes: {},
|
|
98
|
+
lifetimes: {},
|
|
99
|
+
watch: {},
|
|
100
|
+
observers: {},
|
|
101
|
+
};
|
|
102
|
+
if (rootComponentOption && !isEmptyObject(rootComponentOption)) {
|
|
103
|
+
rootComponentOptionHandle(finalOptionsForComponent, sameFuncOptions, rootComponentOption);
|
|
104
|
+
}
|
|
105
|
+
if (subComponentsOption && !isEmptyObject(subComponentsOption)) {
|
|
106
|
+
subComponentsOptionHandle(finalOptionsForComponent, subComponentsOption, sameFuncOptions);
|
|
107
|
+
}
|
|
108
|
+
sameFuncOptionsHandle(finalOptionsForComponent, rootComponentOption?.isPage, sameFuncOptions);
|
|
109
|
+
|
|
110
|
+
// 配置与内部字段冲突验证
|
|
111
|
+
InternalFieldProtection(finalOptionsForComponent);
|
|
112
|
+
|
|
113
|
+
// 对页面传入参数进行处理 老框架劫持页面methods.onLoad,新框架劫持页面pageLifetimes.load
|
|
114
|
+
if (finalOptionsForComponent.isPage) {
|
|
115
|
+
hijack(finalOptionsForComponent.pageLifetimes, "load", [loadReceivedDataHandle]);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
hijack(finalOptionsForComponent.methods, "onLoad", [onLoadReceivedDataHandle]);
|
|
119
|
+
|
|
120
|
+
// 验证isPage字段是否配置正确
|
|
121
|
+
hijack(
|
|
122
|
+
finalOptionsForComponent.lifetimes,
|
|
123
|
+
"attached",
|
|
124
|
+
[isPageCheck(rootComponentOption?.isPage)],
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
// 页面时删除预设的虚拟组件字段
|
|
128
|
+
if (finalOptionsForComponent.isPage && finalOptionsForComponent.options) {
|
|
129
|
+
Reflect.deleteProperty(finalOptionsForComponent.options, "virtualHost");
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// 初始化store数据到data并把store配置放入到data的__storeConfig__下为后续使用
|
|
133
|
+
initStore(finalOptionsForComponent);
|
|
134
|
+
|
|
135
|
+
// 处理computed和watch配置
|
|
136
|
+
computedWatchHandle(finalOptionsForComponent);
|
|
137
|
+
|
|
138
|
+
// BBeforeCreate在最后面,让BeforeCreate生命周期运行在最终建立组件时。
|
|
139
|
+
finalOptionsForComponent.behaviors.push(BBeforeCreate);
|
|
140
|
+
|
|
141
|
+
return finalOptionsForComponent;
|
|
142
|
+
}
|
|
@@ -3,6 +3,7 @@ import type { FinalOptionsOfComponent } from "..";
|
|
|
3
3
|
export function initStore(finalOptionsForComponent: FinalOptionsOfComponent) {
|
|
4
4
|
const storeConfig = finalOptionsForComponent.store;
|
|
5
5
|
if (storeConfig) {
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
6
7
|
const { toJS } = require("mobx") as typeof mobx;
|
|
7
8
|
for (const key in storeConfig) {
|
|
8
9
|
finalOptionsForComponent.data[key] = toJS(storeConfig[key]());
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { IInjectInfo } from "../../..";
|
|
2
|
+
import type { FinalOptionsOfComponent } from ".";
|
|
3
|
+
/**
|
|
4
|
+
* 把injectInfo字段合并到finalOptionsForComponent
|
|
5
|
+
* @remarks 规则:
|
|
6
|
+
* 1. behaviors字段 push
|
|
7
|
+
* 2. 对象字段 没有的话直接赋值,有的话Object.assign
|
|
8
|
+
* @param finalOptionsForComponent
|
|
9
|
+
* @param injectInfo
|
|
10
|
+
* @returns finalOptionsForComponent
|
|
11
|
+
*/
|
|
12
|
+
function mergeOptions(
|
|
13
|
+
finalOptionsForComponent: FinalOptionsOfComponent,
|
|
14
|
+
injectInfo: IInjectInfo,
|
|
15
|
+
): FinalOptionsOfComponent {
|
|
16
|
+
for (const key in injectInfo) {
|
|
17
|
+
const injectVal = injectInfo[key];
|
|
18
|
+
if (key in finalOptionsForComponent) {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const originalVal = finalOptionsForComponent[key];
|
|
21
|
+
switch (key) {
|
|
22
|
+
case "behaviors":
|
|
23
|
+
{
|
|
24
|
+
// @ts-ignore behaviors 是数组类型
|
|
25
|
+
finalOptionsForComponent[key].push(...injectVal);
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
|
|
29
|
+
default:
|
|
30
|
+
{
|
|
31
|
+
// @ts-ignore 覆盖目标
|
|
32
|
+
finalOptionsForComponent[key] = Object.assign(originalVal, injectVal);
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
finalOptionsForComponent[key] = injectVal;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return finalOptionsForComponent;
|
|
43
|
+
}
|
|
44
|
+
export function injectInfoHandler(
|
|
45
|
+
finalOptionsForComponent: FinalOptionsOfComponent,
|
|
46
|
+
injectInfo: IInjectInfo | undefined,
|
|
47
|
+
): FinalOptionsOfComponent {
|
|
48
|
+
if (!injectInfo) return finalOptionsForComponent;
|
|
49
|
+
|
|
50
|
+
return mergeOptions(finalOptionsForComponent, injectInfo);
|
|
51
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { FinalOptionsOfComponent } from ".";
|
|
2
|
+
|
|
3
|
+
// 内部字段
|
|
4
|
+
const internalFiled = {
|
|
5
|
+
methods: ["disposer", "__computedUpdater__"],
|
|
6
|
+
data: ["__computedCache__", "__storeConfig__", "__watchOldValue__"],
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 报错的形式避免输入字段和内部字段冲突,保证config下不包含内部预定字段(列表)
|
|
11
|
+
*/
|
|
12
|
+
export function InternalFieldProtection(finalOptionsForComponent: FinalOptionsOfComponent) {
|
|
13
|
+
const methodsFieldKeys = Object.keys(finalOptionsForComponent.methods);
|
|
14
|
+
const dataFieldKeys = Object.keys(finalOptionsForComponent.data);
|
|
15
|
+
|
|
16
|
+
for (const key of methodsFieldKeys) {
|
|
17
|
+
if (internalFiled.methods.includes(key)) {
|
|
18
|
+
throw Error(`methods配置中的${key}字段已被内部字段占用`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const key of dataFieldKeys) {
|
|
22
|
+
if (internalFiled.data.includes(key)) {
|
|
23
|
+
throw Error(`data配置中的${key}字段已被内部字段占用`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RootComponentTrueOptions } from "../../RootComponent";
|
|
2
|
+
import type { FinalOptionsOfComponent } from ".";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 其他字段加入到componentOptions对应字段配置中
|
|
6
|
+
*/
|
|
7
|
+
export function otherFieldsHandle(
|
|
8
|
+
finalOptions: FinalOptionsOfComponent,
|
|
9
|
+
rootComponentOptions: RootComponentTrueOptions,
|
|
10
|
+
) {
|
|
11
|
+
for (const key in rootComponentOptions) {
|
|
12
|
+
// @ts-ignore 隐式索引
|
|
13
|
+
const config = rootComponentOptions[key];
|
|
14
|
+
if (Array.isArray(config) === true) {
|
|
15
|
+
// "behaviors" || "externalClasses"是数组
|
|
16
|
+
// @ts-ignore 只有 behaviors 和 externalClasses, 且都默认为[]
|
|
17
|
+
finalOptions[key].push(...config);
|
|
18
|
+
} else if (typeof config === "object") {
|
|
19
|
+
// @ts-ignore 隐式索引
|
|
20
|
+
Object.assign(finalOptions[key] ||= {}, config);
|
|
21
|
+
} else {
|
|
22
|
+
// 函数字段有 根组件有 `export` 子组件无此字段
|
|
23
|
+
// @ts-ignore 隐式索引
|
|
24
|
+
finalOptions[key] = config;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RootComponentTrueOptions } from "../../RootComponent";
|
|
2
|
+
import type { FinalOptionsOfComponent, SameFuncOptions } from ".";
|
|
3
|
+
import { customEventsHandle } from "./customEventsHandle";
|
|
4
|
+
import { otherFieldsHandle } from "./otherFieldsHandle";
|
|
5
|
+
import { sameFuncFieldsCollect } from "./sameFuncFieldsCollect";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 收集 rootComponentOptions 配置到 finalOptions 和 funcOptions 中
|
|
9
|
+
* @param finalOptions - 收集配置对象
|
|
10
|
+
* @param funcOptions - 收集特殊配置对象字段
|
|
11
|
+
* @param rootComponentOptions - 被收集的源配置对象
|
|
12
|
+
*/
|
|
13
|
+
export function rootComponentOptionHandle(
|
|
14
|
+
finalOptions: FinalOptionsOfComponent,
|
|
15
|
+
funcOptions: SameFuncOptions,
|
|
16
|
+
rootComponentOptions: RootComponentTrueOptions,
|
|
17
|
+
) {
|
|
18
|
+
if (rootComponentOptions.customEvents) customEventsHandle(finalOptions.methods, rootComponentOptions.customEvents);
|
|
19
|
+
|
|
20
|
+
if (rootComponentOptions.events) Object.assign(finalOptions.methods, rootComponentOptions.events);
|
|
21
|
+
|
|
22
|
+
sameFuncFieldsCollect(rootComponentOptions, funcOptions);
|
|
23
|
+
|
|
24
|
+
otherFieldsHandle(finalOptions, rootComponentOptions);
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RootComponentTrueOptions } from "../../RootComponent";
|
|
2
|
+
import type { SubComponentTrueOptions } from "../../SubComponent";
|
|
3
|
+
import type { SameFuncOptions } from ".";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 把配置为函数的字段方法收集到funcOptions中
|
|
7
|
+
*/
|
|
8
|
+
export function sameFuncFieldsCollect(
|
|
9
|
+
options: SubComponentTrueOptions | RootComponentTrueOptions,
|
|
10
|
+
funcOptions: SameFuncOptions,
|
|
11
|
+
) {
|
|
12
|
+
let key: keyof SameFuncOptions;
|
|
13
|
+
for (key in funcOptions) {
|
|
14
|
+
const optionsKeyConfig = options[key];
|
|
15
|
+
if (optionsKeyConfig) {
|
|
16
|
+
for (const _key in optionsKeyConfig) {
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
(funcOptions[key][_key] ||= []).push(optionsKeyConfig[_key]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Func } from "hry-types/src/Misc/_api";
|
|
2
|
+
import { isEmptyObject } from "../../../utils/isEmptyObject";
|
|
3
|
+
import type { FinalOptionsOfComponent, SameFuncOptions } from ".";
|
|
4
|
+
/**
|
|
5
|
+
* 把函数配置放入一个配置中依次运行
|
|
6
|
+
*/
|
|
7
|
+
function _sameFuncOptionsHandle(config: object, configList: Record<string, Func[]>) {
|
|
8
|
+
for (const key in configList) {
|
|
9
|
+
// @ts-ignore 隐式索引
|
|
10
|
+
config[key] = function(...args: unknown[]) {
|
|
11
|
+
configList[key].forEach(ele => ele.call(this, ...args));
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 把函数列表配置放入一个配置中循环依次运行
|
|
17
|
+
*/
|
|
18
|
+
export function sameFuncOptionsHandle(
|
|
19
|
+
finalOptionsForComponent: FinalOptionsOfComponent,
|
|
20
|
+
isPage: boolean | undefined,
|
|
21
|
+
funcOptions: SameFuncOptions,
|
|
22
|
+
) {
|
|
23
|
+
if (isPage) {
|
|
24
|
+
// 页面时 生命周期方法(即 on 开头的方法),(https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/component.html)
|
|
25
|
+
if (!isEmptyObject(funcOptions.pageLifetimes)) {
|
|
26
|
+
_sameFuncOptionsHandle(finalOptionsForComponent.methods, funcOptions.pageLifetimes);
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
// 组件时
|
|
30
|
+
if (!isEmptyObject(funcOptions.pageLifetimes)) {
|
|
31
|
+
_sameFuncOptionsHandle(finalOptionsForComponent.pageLifetimes, funcOptions.pageLifetimes);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (funcOptions.lifetimes) _sameFuncOptionsHandle(finalOptionsForComponent.lifetimes ||= {}, funcOptions.lifetimes);
|
|
35
|
+
|
|
36
|
+
if (funcOptions.watch) _sameFuncOptionsHandle(finalOptionsForComponent.watch ||= {}, funcOptions.watch);
|
|
37
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SubComponentTrueOptions } from "../../SubComponent";
|
|
2
|
+
import type { FinalOptionsOfComponent, SameFuncOptions } from ".";
|
|
3
|
+
import { otherFieldsHandle } from "./otherFieldsHandle";
|
|
4
|
+
import { sameFuncFieldsCollect } from "./sameFuncFieldsCollect";
|
|
5
|
+
|
|
6
|
+
export function subComponentsOptionHandle(
|
|
7
|
+
componentOptions: FinalOptionsOfComponent,
|
|
8
|
+
subComponents: SubComponentTrueOptions[],
|
|
9
|
+
funcOptions: SameFuncOptions,
|
|
10
|
+
) {
|
|
11
|
+
subComponents.forEach((subOption) => {
|
|
12
|
+
if (subOption.events) Object.assign(componentOptions.methods, subOption.events);
|
|
13
|
+
|
|
14
|
+
sameFuncFieldsCollect(subOption, funcOptions);
|
|
15
|
+
|
|
16
|
+
otherFieldsHandle(componentOptions, subOption);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1
2
|
import { observable, runInAction } from "mobx";
|
|
2
3
|
|
|
3
4
|
// 注入的响应式数据;
|
|
@@ -27,6 +28,7 @@ const store = {
|
|
|
27
28
|
// 声明注入类型 js开发可以忽略
|
|
28
29
|
declare module "../.." {
|
|
29
30
|
interface IInjectInfo {
|
|
31
|
+
[key: string]: unknown;
|
|
30
32
|
data: typeof data;
|
|
31
33
|
store: typeof store;
|
|
32
34
|
methods: typeof methods;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
|
|
2
|
-
|
|
3
1
|
import type { IfEquals } from "hry-types/src/Any/IfEquals";
|
|
4
2
|
import type { ComputeIntersection } from "hry-types/src/Object/ComputeIntersection";
|
|
5
3
|
import type { ReturnTypeInObject } from "hry-types/src/Object/ReturnTypeInObject";
|
|
@@ -10,6 +8,7 @@ import type { StoreConstraint } from "../RootComponent/Store/StoreConstraint";
|
|
|
10
8
|
|
|
11
9
|
// 利用继承的多态性 使得IInjectInfo类型可由使用者外部定义
|
|
12
10
|
interface BaseInjectInfo {
|
|
11
|
+
[key: string]: unknown;
|
|
13
12
|
options?: WMComponentOption;
|
|
14
13
|
methods?: MethodsConstraint;
|
|
15
14
|
data?: DataConstraint;
|
|
@@ -17,7 +16,6 @@ interface BaseInjectInfo {
|
|
|
17
16
|
behaviors?: string[];
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
21
19
|
export interface IInjectInfo extends BaseInjectInfo {
|
|
22
20
|
}
|
|
23
21
|
|
|
@@ -44,7 +42,7 @@ class InstanceConfig {
|
|
|
44
42
|
return this.info.injectInfo;
|
|
45
43
|
}
|
|
46
44
|
public setInjectInfo(info: IInjectInfo | undefined) {
|
|
47
|
-
info
|
|
45
|
+
if (info) this.info.injectInfo = info;
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1
3
|
import { Checking, type Test } from "hry-types";
|
|
2
4
|
import type { ComputeIntersection } from "hry-types/src/Object/_api";
|
|
3
5
|
import type { IInjectAllData } from "../../../InstanceInject/instanceConfig";
|