annil 1.16.0 → 1.18.0

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.
Files changed (435) hide show
  1. package/README.md +38 -169
  2. package/dist/api/ChunkComponent/ChunkComputed/ChunkComputedConstraint.d.ts +1 -0
  3. package/dist/api/ChunkComponent/ChunkComputed/ChunkComputedConstraint.js +2 -0
  4. package/dist/api/ChunkComponent/ChunkComputed/ChunkComputedConstraint.js.map +1 -0
  5. package/dist/api/ChunkComponent/ChunkComputed/ChunkComputedOption.d.ts +10 -0
  6. package/dist/api/ChunkComponent/ChunkComputed/ChunkComputedOption.js +2 -0
  7. package/dist/api/ChunkComponent/ChunkComputed/ChunkComputedOption.js.map +1 -0
  8. package/dist/api/ChunkComponent/ChunkData/chunkDataOption.d.ts +9 -0
  9. package/dist/api/ChunkComponent/ChunkData/chunkDataOption.js +2 -0
  10. package/dist/api/ChunkComponent/ChunkData/chunkDataOption.js.map +1 -0
  11. package/dist/api/ChunkComponent/ChunkData/validatePrefix.d.ts +2 -0
  12. package/dist/api/ChunkComponent/ChunkData/validatePrefix.js +2 -0
  13. package/dist/api/ChunkComponent/ChunkData/validatePrefix.js.map +1 -0
  14. package/dist/api/ChunkComponent/ChunkMethods/ChunkMethodsOption.d.ts +10 -0
  15. package/dist/api/ChunkComponent/ChunkMethods/ChunkMethodsOption.js +2 -0
  16. package/dist/api/ChunkComponent/ChunkMethods/ChunkMethodsOption.js.map +1 -0
  17. package/dist/api/ChunkComponent/ChunkStore/ChunkStoreConstraint.d.ts +2 -0
  18. package/dist/api/ChunkComponent/ChunkStore/ChunkStoreConstraint.js +2 -0
  19. package/dist/api/ChunkComponent/ChunkStore/ChunkStoreConstraint.js.map +1 -0
  20. package/dist/api/ChunkComponent/ChunkStore/ChunkStoreOption.d.ts +12 -0
  21. package/dist/api/ChunkComponent/ChunkStore/ChunkStoreOption.js +2 -0
  22. package/dist/api/ChunkComponent/ChunkStore/ChunkStoreOption.js.map +1 -0
  23. package/dist/api/ChunkComponent/ChunklEvents/ChunkEventsConstraint.d.ts +2 -0
  24. package/dist/api/ChunkComponent/ChunklEvents/ChunkEventsConstraint.js +2 -0
  25. package/dist/api/ChunkComponent/ChunklEvents/ChunkEventsConstraint.js.map +1 -0
  26. package/dist/api/ChunkComponent/ChunklEvents/ChunkEventsOption.d.ts +10 -0
  27. package/dist/api/ChunkComponent/ChunklEvents/ChunkEventsOption.js +2 -0
  28. package/dist/api/ChunkComponent/ChunklEvents/ChunkEventsOption.js.map +1 -0
  29. package/dist/api/ChunkComponent/SlotComponentReturnType.d.ts +20 -0
  30. package/dist/api/ChunkComponent/SlotComponentReturnType.js +2 -0
  31. package/dist/api/ChunkComponent/SlotComponentReturnType.js.map +1 -0
  32. package/dist/api/ChunkComponent/index.d.ts +24 -0
  33. package/dist/api/ChunkComponent/index.js +4 -0
  34. package/dist/api/ChunkComponent/index.js.map +1 -0
  35. package/dist/api/CustomComponent/CustomComputed/CustomComputedConstraint.d.ts +3 -0
  36. package/dist/api/CustomComponent/CustomComputed/CustomComputedConstraint.js +2 -0
  37. package/dist/api/CustomComponent/CustomComputed/CustomComputedConstraint.js.map +1 -0
  38. package/dist/api/{SubComponent/SubComputed/SubComputedOption.d.ts → CustomComponent/CustomComputed/CustomComputedOption.d.ts} +1 -1
  39. package/dist/api/CustomComponent/CustomComputed/CustomComputedOption.js +2 -0
  40. package/dist/api/CustomComponent/CustomComputed/CustomComputedOption.js.map +1 -0
  41. package/dist/api/CustomComponent/CustomComputed/GetCustomComputedDoc.d.ts +3 -0
  42. package/dist/api/CustomComponent/CustomComputed/GetCustomComputedDoc.js +2 -0
  43. package/dist/api/CustomComponent/CustomComputed/GetCustomComputedDoc.js.map +1 -0
  44. package/dist/api/CustomComponent/CustomData/CustomDataConstraint.d.ts +3 -0
  45. package/dist/api/CustomComponent/CustomData/CustomDataConstraint.js +2 -0
  46. package/dist/api/CustomComponent/CustomData/CustomDataConstraint.js.map +1 -0
  47. package/dist/api/{SubComponent/SubData/SubDataOption.d.ts → CustomComponent/CustomData/CustomDataOption.d.ts} +1 -1
  48. package/dist/api/CustomComponent/CustomData/CustomDataOption.js +2 -0
  49. package/dist/api/CustomComponent/CustomData/CustomDataOption.js.map +1 -0
  50. package/dist/api/{SubComponent/SubEvents/SubEventsConstraint.d.ts → CustomComponent/CustomEvents/CustomEventsConstraint.d.ts} +1 -1
  51. package/dist/api/CustomComponent/CustomEvents/CustomEventsConstraint.js +2 -0
  52. package/dist/api/CustomComponent/CustomEvents/CustomEventsConstraint.js.map +1 -0
  53. package/dist/api/CustomComponent/CustomEvents/CustomEventsOption.d.ts +4 -0
  54. package/dist/api/CustomComponent/CustomEvents/CustomEventsOption.js +2 -0
  55. package/dist/api/CustomComponent/CustomEvents/CustomEventsOption.js.map +1 -0
  56. package/dist/api/{SubComponent/SubInherit/SubInheritConstraint.d.ts → CustomComponent/CustomInherit/CustomInheritConstraint.d.ts} +1 -1
  57. package/dist/api/CustomComponent/CustomInherit/CustomInheritConstraint.js +2 -0
  58. package/dist/api/CustomComponent/CustomInherit/CustomInheritConstraint.js.map +1 -0
  59. package/dist/api/{SubComponent/SubInherit/SubInheritOption.d.ts → CustomComponent/CustomInherit/CustomInheritOption.d.ts} +1 -1
  60. package/dist/api/CustomComponent/CustomInherit/CustomInheritOption.js +2 -0
  61. package/dist/api/CustomComponent/CustomInherit/CustomInheritOption.js.map +1 -0
  62. package/dist/api/CustomComponent/CustomInstance/CustomInstance.d.ts +2 -0
  63. package/dist/api/CustomComponent/CustomInstance/CustomInstance.js +2 -0
  64. package/dist/api/CustomComponent/CustomInstance/CustomInstance.js.map +1 -0
  65. package/dist/api/{SubComponent/SubLifetimes/SubLifetimesOption.d.ts → CustomComponent/CustomLifetimes/CustomLifetimesOption.d.ts} +1 -1
  66. package/dist/api/CustomComponent/CustomLifetimes/CustomLifetimesOption.js +2 -0
  67. package/dist/api/CustomComponent/CustomLifetimes/CustomLifetimesOption.js.map +1 -0
  68. package/dist/api/CustomComponent/CustomMethods/CustomMethodsConstraint.d.ts +2 -0
  69. package/dist/api/CustomComponent/CustomMethods/CustomMethodsConstraint.js +2 -0
  70. package/dist/api/CustomComponent/CustomMethods/CustomMethodsConstraint.js.map +1 -0
  71. package/dist/api/CustomComponent/CustomMethods/CustomMethodsOption.d.ts +5 -0
  72. package/dist/api/CustomComponent/CustomMethods/CustomMethodsOption.js +2 -0
  73. package/dist/api/CustomComponent/CustomMethods/CustomMethodsOption.js.map +1 -0
  74. package/dist/api/CustomComponent/CustomObservers/CustomObserversOption.d.ts +2 -0
  75. package/dist/api/CustomComponent/CustomObservers/CustomObserversOption.js +2 -0
  76. package/dist/api/CustomComponent/CustomObservers/CustomObserversOption.js.map +1 -0
  77. package/dist/api/CustomComponent/CustomPageLifetimes/CustomPageLifetimesOption.d.ts +2 -0
  78. package/dist/api/CustomComponent/CustomPageLifetimes/CustomPageLifetimesOption.js +2 -0
  79. package/dist/api/CustomComponent/CustomPageLifetimes/CustomPageLifetimesOption.js.map +1 -0
  80. package/dist/api/{SubComponent/SubReturnType/CreateSubComponentDoc.d.ts → CustomComponent/CustomReturnType/CreateCustomComponentDoc.d.ts} +1 -1
  81. package/dist/api/CustomComponent/CustomReturnType/CreateCustomComponentDoc.js +2 -0
  82. package/dist/api/CustomComponent/CustomReturnType/CreateCustomComponentDoc.js.map +1 -0
  83. package/dist/api/{SubComponent/SubStore/SubStoreConstraint.d.ts → CustomComponent/CustomStore/CustomStoreConstraint.d.ts} +1 -1
  84. package/dist/api/CustomComponent/CustomStore/CustomStoreConstraint.js +2 -0
  85. package/dist/api/CustomComponent/CustomStore/CustomStoreConstraint.js.map +1 -0
  86. package/dist/api/{SubComponent/SubStore/SubStoreOption.d.ts → CustomComponent/CustomStore/CustomStoreOption.d.ts} +1 -1
  87. package/dist/api/CustomComponent/CustomStore/CustomStoreOption.js +2 -0
  88. package/dist/api/CustomComponent/CustomStore/CustomStoreOption.js.map +1 -0
  89. package/dist/api/CustomComponent/CustomWatch/CustomWatchOption.d.ts +2 -0
  90. package/dist/api/CustomComponent/CustomWatch/CustomWatchOption.js +2 -0
  91. package/dist/api/CustomComponent/CustomWatch/CustomWatchOption.js.map +1 -0
  92. package/dist/api/CustomComponent/index.d.ts +49 -0
  93. package/dist/api/CustomComponent/index.js +4 -0
  94. package/dist/api/CustomComponent/index.js.map +1 -0
  95. package/dist/api/{SubComponent → CustomComponent}/returnType.d.ts +3 -3
  96. package/dist/api/CustomComponent/returnType.js.map +1 -0
  97. package/dist/api/DefineComponent/SubComponents/SubComponentsOption.d.ts +2 -2
  98. package/dist/api/DefineComponent/index.d.ts +4 -4
  99. package/dist/api/DefineComponent/normalizeOptions/__throttleDebounce__FieldCheck.d.ts +3 -2
  100. package/dist/api/DefineComponent/normalizeOptions/__throttleDebounce__FieldCheck.js.map +1 -1
  101. package/dist/api/DefineComponent/normalizeOptions/customEventsHandle.js +3 -3
  102. package/dist/api/DefineComponent/normalizeOptions/customEventsHandle.js.map +1 -1
  103. package/dist/api/DefineComponent/normalizeOptions/handleStore/reactionRegister.js +1 -2
  104. package/dist/api/DefineComponent/normalizeOptions/handleStore/reactionRegister.js.map +1 -1
  105. package/dist/api/DefineComponent/normalizeOptions/handleSubComponents.d.ts +3 -2
  106. package/dist/api/DefineComponent/normalizeOptions/handleSubComponents.js.map +1 -1
  107. package/dist/api/DefineComponent/normalizeOptions/index.js +1 -2
  108. package/dist/api/DefineComponent/normalizeOptions/index.js.map +1 -1
  109. package/dist/api/DefineComponent/normalizeOptions/injectInfoHandler.js +1 -1
  110. package/dist/api/DefineComponent/normalizeOptions/injectInfoHandler.js.map +1 -1
  111. package/dist/api/DefineComponent/normalizeOptions/sameFuncFieldsCollect.d.ts +3 -2
  112. package/dist/api/DefineComponent/normalizeOptions/sameFuncFieldsCollect.js +1 -2
  113. package/dist/api/DefineComponent/normalizeOptions/sameFuncFieldsCollect.js.map +1 -1
  114. package/dist/api/DefineComponent/normalizeOptions/watchHandler/getPathsValue.js +1 -1
  115. package/dist/api/DefineComponent/normalizeOptions/watchHandler/getPathsValue.js.map +1 -1
  116. package/dist/api/DefineComponent/normalizeOptions/watchHandler/index.js +3 -4
  117. package/dist/api/DefineComponent/normalizeOptions/watchHandler/index.js.map +1 -1
  118. package/dist/api/DefineComponent/returnType/ComponentDoc.d.ts +1 -4
  119. package/dist/api/DefineComponent/returnType/GenerateComponentDoc.d.ts +3 -3
  120. package/dist/api/DefineComponent/returnType/GetCustomEventDocOfSubDoc.d.ts +3 -3
  121. package/dist/api/InstanceInject/instanceConfig.d.ts +2 -2
  122. package/dist/api/InstanceInject/instanceConfig.js +1 -3
  123. package/dist/api/InstanceInject/instanceConfig.js.map +1 -1
  124. package/dist/api/RootComponent/Events/EventsConstraint.d.ts +9 -7
  125. package/dist/api/RootComponent/index.d.ts +6 -5
  126. package/dist/api/RootComponent/index.js.map +1 -1
  127. package/dist/behaviors/BbeforeCreated.d.ts +1 -1
  128. package/dist/behaviors/BthrottleDebounce.d.ts +1 -1
  129. package/dist/index.d.ts +4 -4
  130. package/dist/index.js +3 -2
  131. package/dist/index.js.map +1 -1
  132. package/dist/thirdLib/vant/Button.d.ts +2 -2
  133. package/dist/thirdLib/vant/NoticeBar.d.ts +2 -2
  134. package/dist/thirdLib/vant/Popup.d.ts +2 -2
  135. package/dist/thirdLib/wm/Textarea.d.ts +2 -2
  136. package/dist/thirdLib/wm/map.d.ts +2 -2
  137. package/dist/thirdLib/wm/scrollView.d.ts +2 -2
  138. package/dist/thirdLib/wm/swiper.d.ts +2 -2
  139. package/dist/thirdLib/wm/view.d.ts +2 -2
  140. package/dist/types/{CreateComponentType.d.ts → CreateComponentDoc.d.ts} +5 -2
  141. package/dist/types/CreateComponentDoc.js +2 -0
  142. package/dist/types/CreateComponentDoc.js.map +1 -0
  143. package/dist/utils/nonNullable.js +1 -1
  144. package/dist/utils/nonNullable.js.map +1 -1
  145. package/package.json +8 -11
  146. package/CHANGELOG.md +0 -943
  147. package/dist/api/SubComponent/SubComputed/GetSubComputedDoc.d.ts +0 -3
  148. package/dist/api/SubComponent/SubComputed/GetSubComputedDoc.js +0 -2
  149. package/dist/api/SubComponent/SubComputed/GetSubComputedDoc.js.map +0 -1
  150. package/dist/api/SubComponent/SubComputed/SubComputedConstraint.d.ts +0 -3
  151. package/dist/api/SubComponent/SubComputed/SubComputedConstraint.js +0 -2
  152. package/dist/api/SubComponent/SubComputed/SubComputedConstraint.js.map +0 -1
  153. package/dist/api/SubComponent/SubComputed/SubComputedOption.js +0 -2
  154. package/dist/api/SubComponent/SubComputed/SubComputedOption.js.map +0 -1
  155. package/dist/api/SubComponent/SubData/SubDataConstraint.d.ts +0 -3
  156. package/dist/api/SubComponent/SubData/SubDataConstraint.js +0 -2
  157. package/dist/api/SubComponent/SubData/SubDataConstraint.js.map +0 -1
  158. package/dist/api/SubComponent/SubData/SubDataOption.js +0 -2
  159. package/dist/api/SubComponent/SubData/SubDataOption.js.map +0 -1
  160. package/dist/api/SubComponent/SubEvents/SubEventsConstraint.js +0 -2
  161. package/dist/api/SubComponent/SubEvents/SubEventsConstraint.js.map +0 -1
  162. package/dist/api/SubComponent/SubEvents/SubEventsOption.d.ts +0 -4
  163. package/dist/api/SubComponent/SubEvents/SubEventsOption.js +0 -2
  164. package/dist/api/SubComponent/SubEvents/SubEventsOption.js.map +0 -1
  165. package/dist/api/SubComponent/SubInherit/SubInheritConstraint.js +0 -2
  166. package/dist/api/SubComponent/SubInherit/SubInheritConstraint.js.map +0 -1
  167. package/dist/api/SubComponent/SubInherit/SubInheritOption.js +0 -2
  168. package/dist/api/SubComponent/SubInherit/SubInheritOption.js.map +0 -1
  169. package/dist/api/SubComponent/SubInstance/SubInstance.d.ts +0 -2
  170. package/dist/api/SubComponent/SubInstance/SubInstance.js +0 -2
  171. package/dist/api/SubComponent/SubInstance/SubInstance.js.map +0 -1
  172. package/dist/api/SubComponent/SubLifetimes/SubLifetimesOption.js +0 -2
  173. package/dist/api/SubComponent/SubLifetimes/SubLifetimesOption.js.map +0 -1
  174. package/dist/api/SubComponent/SubMethods/SubMethodsConstraint.d.ts +0 -2
  175. package/dist/api/SubComponent/SubMethods/SubMethodsConstraint.js +0 -2
  176. package/dist/api/SubComponent/SubMethods/SubMethodsConstraint.js.map +0 -1
  177. package/dist/api/SubComponent/SubMethods/SubMethodsOption.d.ts +0 -5
  178. package/dist/api/SubComponent/SubMethods/SubMethodsOption.js +0 -2
  179. package/dist/api/SubComponent/SubMethods/SubMethodsOption.js.map +0 -1
  180. package/dist/api/SubComponent/SubObservers/SubObserversOption.d.ts +0 -2
  181. package/dist/api/SubComponent/SubObservers/SubObserversOption.js +0 -2
  182. package/dist/api/SubComponent/SubObservers/SubObserversOption.js.map +0 -1
  183. package/dist/api/SubComponent/SubPageLifetimes/SubPageLifetimesOption.d.ts +0 -2
  184. package/dist/api/SubComponent/SubPageLifetimes/SubPageLifetimesOption.js +0 -2
  185. package/dist/api/SubComponent/SubPageLifetimes/SubPageLifetimesOption.js.map +0 -1
  186. package/dist/api/SubComponent/SubReturnType/CreateSubComponentDoc.js +0 -2
  187. package/dist/api/SubComponent/SubReturnType/CreateSubComponentDoc.js.map +0 -1
  188. package/dist/api/SubComponent/SubStore/SubStoreConstraint.js +0 -2
  189. package/dist/api/SubComponent/SubStore/SubStoreConstraint.js.map +0 -1
  190. package/dist/api/SubComponent/SubStore/SubStoreOption.js +0 -2
  191. package/dist/api/SubComponent/SubStore/SubStoreOption.js.map +0 -1
  192. package/dist/api/SubComponent/SubWatch/SubWatchOption.d.ts +0 -2
  193. package/dist/api/SubComponent/SubWatch/SubWatchOption.js +0 -2
  194. package/dist/api/SubComponent/SubWatch/SubWatchOption.js.map +0 -1
  195. package/dist/api/SubComponent/index.d.ts +0 -49
  196. package/dist/api/SubComponent/index.js +0 -4
  197. package/dist/api/SubComponent/index.js.map +0 -1
  198. package/dist/api/SubComponent/returnType.js.map +0 -1
  199. package/dist/types/CreateComponentType.js +0 -2
  200. package/dist/types/CreateComponentType.js.map +0 -1
  201. package/dist/types/ExtendComponentType.d.ts +0 -7
  202. package/dist/types/ExtendComponentType.js +0 -2
  203. package/dist/types/ExtendComponentType.js.map +0 -1
  204. package/dist/types/RemoveNullOfRequired.d.ts +0 -4
  205. package/dist/types/RemoveNullOfRequired.js +0 -2
  206. package/dist/types/RemoveNullOfRequired.js.map +0 -1
  207. package/src/api/DefineComponent/NameOrPath/NameOrPathOption.ts +0 -31
  208. package/src/api/DefineComponent/NameOrPath/test/error.test.ts +0 -32
  209. package/src/api/DefineComponent/NameOrPath/test/normal.test.ts +0 -13
  210. package/src/api/DefineComponent/RootComponent/RootComponentOption.ts +0 -11
  211. package/src/api/DefineComponent/SubComponents/SubComponentsOption.ts +0 -13
  212. package/src/api/DefineComponent/SubComponents/test/normal.test.ts +0 -1049
  213. package/src/api/DefineComponent/index.ts +0 -58
  214. package/src/api/DefineComponent/normalizeOptions/__throttleDebounce__FieldCheck.ts +0 -29
  215. package/src/api/DefineComponent/normalizeOptions/customEventsHandle.ts +0 -55
  216. package/src/api/DefineComponent/normalizeOptions/handleRootComponent.ts +0 -33
  217. package/src/api/DefineComponent/normalizeOptions/handleStore/disposeStore.ts +0 -10
  218. package/src/api/DefineComponent/normalizeOptions/handleStore/initStore.ts +0 -9
  219. package/src/api/DefineComponent/normalizeOptions/handleStore/reactionRegister.ts +0 -70
  220. package/src/api/DefineComponent/normalizeOptions/handleSubComponents.ts +0 -23
  221. package/src/api/DefineComponent/normalizeOptions/hijackHandle/addDetachedData.ts +0 -10
  222. package/src/api/DefineComponent/normalizeOptions/hijackHandle/hijack.ts +0 -26
  223. package/src/api/DefineComponent/normalizeOptions/hijackHandle/index.ts +0 -57
  224. package/src/api/DefineComponent/normalizeOptions/hijackHandle/isPageCheck.ts +0 -22
  225. package/src/api/DefineComponent/normalizeOptions/hijackHandle/loadReceivedDataHandle.ts +0 -25
  226. package/src/api/DefineComponent/normalizeOptions/hijackHandle/onLoadReceivedDataHandle.ts +0 -33
  227. package/src/api/DefineComponent/normalizeOptions/hijackHandle/pagePathCheck.ts +0 -9
  228. package/src/api/DefineComponent/normalizeOptions/index.ts +0 -143
  229. package/src/api/DefineComponent/normalizeOptions/initComputed/computedUpdater.ts +0 -51
  230. package/src/api/DefineComponent/normalizeOptions/initComputed/data-tracer.ts +0 -62
  231. package/src/api/DefineComponent/normalizeOptions/initComputed/dependencesOptimize.ts +0 -45
  232. package/src/api/DefineComponent/normalizeOptions/initComputed/index.ts +0 -42
  233. package/src/api/DefineComponent/normalizeOptions/initComputed/initComputedAndGetCache.ts +0 -105
  234. package/src/api/DefineComponent/normalizeOptions/injectInfoHandler.ts +0 -51
  235. package/src/api/DefineComponent/normalizeOptions/internalFieldProtection.ts +0 -27
  236. package/src/api/DefineComponent/normalizeOptions/otherFieldsHandle.ts +0 -29
  237. package/src/api/DefineComponent/normalizeOptions/sameFuncFieldsCollect.ts +0 -23
  238. package/src/api/DefineComponent/normalizeOptions/sameFuncOptionsHandle.ts +0 -36
  239. package/src/api/DefineComponent/normalizeOptions/watchHandler/getPathsValue.ts +0 -31
  240. package/src/api/DefineComponent/normalizeOptions/watchHandler/getPropertiesValue.ts +0 -51
  241. package/src/api/DefineComponent/normalizeOptions/watchHandler/hasComputedPath.ts +0 -9
  242. package/src/api/DefineComponent/normalizeOptions/watchHandler/index.ts +0 -78
  243. package/src/api/DefineComponent/returnType/ComponentDoc.ts +0 -25
  244. package/src/api/DefineComponent/returnType/GenerateComponentDoc.ts +0 -46
  245. package/src/api/DefineComponent/returnType/GeneratePageDoc.ts +0 -22
  246. package/src/api/DefineComponent/returnType/GetCustomEventDocOfSubDoc.ts +0 -24
  247. package/src/api/DefineComponent/returnType/GetPropertiesDocOfSubDoc.ts +0 -7
  248. package/src/api/DefineComponent/returnType/PageDoc.ts +0 -19
  249. package/src/api/DefineComponent/returnType/test/normalComponentDoc.test.ts +0 -248
  250. package/src/api/DefineComponent/returnType/test/normalPageDoc.test.ts +0 -49
  251. package/src/api/InstanceInject/inject.ts +0 -36
  252. package/src/api/InstanceInject/instanceConfig.ts +0 -50
  253. package/src/api/InstanceInject/test/normal.test.ts +0 -41
  254. package/src/api/RootComponent/Computed/ComputedConstraint.ts +0 -4
  255. package/src/api/RootComponent/Computed/ComputedOption.ts +0 -35
  256. package/src/api/RootComponent/Computed/GetComputedDef.ts +0 -10
  257. package/src/api/RootComponent/Computed/test/GetComputedDoc.test.ts +0 -25
  258. package/src/api/RootComponent/Computed/test/error.test.ts +0 -50
  259. package/src/api/RootComponent/Computed/test/normal.test.ts +0 -124
  260. package/src/api/RootComponent/CustomEvents/CustomEventConstraint.ts +0 -89
  261. package/src/api/RootComponent/CustomEvents/CustomEventsDef.ts +0 -4
  262. package/src/api/RootComponent/CustomEvents/CustomEventsDoc.ts +0 -4
  263. package/src/api/RootComponent/CustomEvents/CustomEventsOption.ts +0 -41
  264. package/src/api/RootComponent/CustomEvents/CustomEventsTag.ts +0 -59
  265. package/src/api/RootComponent/CustomEvents/GetCustomEventDef.ts +0 -29
  266. package/src/api/RootComponent/CustomEvents/GetCustomEventDoc.ts +0 -47
  267. package/src/api/RootComponent/CustomEvents/test/GetCustomEventDoc.test.ts +0 -38
  268. package/src/api/RootComponent/CustomEvents/test/GetFullEventDoc.test.ts +0 -57
  269. package/src/api/RootComponent/CustomEvents/test/GetShortEventDoc.test.ts +0 -36
  270. package/src/api/RootComponent/CustomEvents/test/error.test.ts +0 -101
  271. package/src/api/RootComponent/CustomEvents/test/normal.test.ts +0 -99
  272. package/src/api/RootComponent/Data/DataConstraint.ts +0 -1
  273. package/src/api/RootComponent/Data/DataOption.ts +0 -25
  274. package/src/api/RootComponent/Data/GetDataDef.ts +0 -8
  275. package/src/api/RootComponent/Data/GetDataDoc.ts +0 -8
  276. package/src/api/RootComponent/Data/test/GetDataDoc.test.ts +0 -32
  277. package/src/api/RootComponent/Data/test/error.test.ts +0 -14
  278. package/src/api/RootComponent/Data/test/normal.test.ts +0 -33
  279. package/src/api/RootComponent/Events/EventsConstraint.ts +0 -74
  280. package/src/api/RootComponent/Events/EventsOption.ts +0 -55
  281. package/src/api/RootComponent/Events/test/normal.test.ts +0 -161
  282. package/src/api/RootComponent/Instance/CustomEventMethods.ts +0 -11
  283. package/src/api/RootComponent/Instance/CustomSetData.ts +0 -17
  284. package/src/api/RootComponent/Instance/RootComponentInstance.ts +0 -46
  285. package/src/api/RootComponent/Instance/test/CustomEventsDoc.test.ts +0 -70
  286. package/src/api/RootComponent/Instance/test/CustomSetData.test.ts +0 -44
  287. package/src/api/RootComponent/Instance/test/customEvents/error.test.ts +0 -13
  288. package/src/api/RootComponent/Instance/test/customEvents/normal.test.ts +0 -71
  289. package/src/api/RootComponent/Instance/test/methods/error.test.ts +0 -14
  290. package/src/api/RootComponent/Instance/test/methods/mormal.test.ts +0 -18
  291. package/src/api/RootComponent/Instance/test/properties/mormal.test.ts +0 -58
  292. package/src/api/RootComponent/Instance/test/setData/error.test.ts +0 -65
  293. package/src/api/RootComponent/Instance/test/setData/normal.test.ts +0 -51
  294. package/src/api/RootComponent/IsPage/IsPageOption.ts +0 -6
  295. package/src/api/RootComponent/IsPage/test/normal.test.ts +0 -29
  296. package/src/api/RootComponent/Lifetimes/LifetimesConstraint.ts +0 -14
  297. package/src/api/RootComponent/Lifetimes/LifetimesOption.ts +0 -31
  298. package/src/api/RootComponent/Lifetimes/test/error.test.ts +0 -31
  299. package/src/api/RootComponent/Lifetimes/test/normal.test.ts +0 -34
  300. package/src/api/RootComponent/Methods/MethodsConstraint.ts +0 -3
  301. package/src/api/RootComponent/Methods/MethodsOption.ts +0 -15
  302. package/src/api/RootComponent/Methods/test/error.test.ts +0 -41
  303. package/src/api/RootComponent/Methods/test/mormal.test.ts +0 -25
  304. package/src/api/RootComponent/Observers/ObserversOption.ts +0 -58
  305. package/src/api/RootComponent/Observers/test/normal.test.ts +0 -30
  306. package/src/api/RootComponent/PageLifetimes/PageLifetimesOption.ts +0 -29
  307. package/src/api/RootComponent/PageLifetimes/test/error.test.ts +0 -37
  308. package/src/api/RootComponent/PageLifetimes/test/normal.test.ts +0 -71
  309. package/src/api/RootComponent/Properties/GetOptionalDef.ts +0 -18
  310. package/src/api/RootComponent/Properties/GetPropertiesDef.ts +0 -22
  311. package/src/api/RootComponent/Properties/GetRequiredDef.ts +0 -16
  312. package/src/api/RootComponent/Properties/PropertiesConstraint.ts +0 -38
  313. package/src/api/RootComponent/Properties/PropertiesOption.ts +0 -25
  314. package/src/api/RootComponent/Properties/PropertiesValueValidator.ts +0 -21
  315. package/src/api/RootComponent/Properties/test/error.test.ts +0 -49
  316. package/src/api/RootComponent/Properties/test/normalEmpty.test.ts +0 -42
  317. package/src/api/RootComponent/Properties/test/normalOptional.test.ts +0 -118
  318. package/src/api/RootComponent/Properties/test/normalRequired.test.ts +0 -107
  319. package/src/api/RootComponent/Store/GetStoreDef.ts +0 -34
  320. package/src/api/RootComponent/Store/StoreConstraint.ts +0 -2
  321. package/src/api/RootComponent/Store/StoreOption.ts +0 -53
  322. package/src/api/RootComponent/Store/test/error.test.ts +0 -30
  323. package/src/api/RootComponent/Store/test/normal.test.ts +0 -35
  324. package/src/api/RootComponent/Watch/WatchOption.ts +0 -67
  325. package/src/api/RootComponent/Watch/test/WatchComputed.test.ts +0 -40
  326. package/src/api/RootComponent/Watch/test/WatchData.test.ts +0 -55
  327. package/src/api/RootComponent/Watch/test/WatchProperties.test.ts +0 -170
  328. package/src/api/RootComponent/Watch/test/WtachInject.test.ts +0 -16
  329. package/src/api/RootComponent/Watch/test/error.test.ts +0 -54
  330. package/src/api/RootComponent/index.ts +0 -151
  331. package/src/api/RootComponent/returnType.ts +0 -57
  332. package/src/api/SubComponent/SubComputed/GetSubComputedDoc.ts +0 -4
  333. package/src/api/SubComponent/SubComputed/SubComputedConstraint.ts +0 -1
  334. package/src/api/SubComponent/SubComputed/SubComputedOption.ts +0 -11
  335. package/src/api/SubComponent/SubComputed/test/error.test.ts +0 -88
  336. package/src/api/SubComponent/SubComputed/test/normal.test.ts +0 -207
  337. package/src/api/SubComponent/SubData/SubDataConstraint.ts +0 -9
  338. package/src/api/SubComponent/SubData/SubDataOption.ts +0 -17
  339. package/src/api/SubComponent/SubData/test/error.test.ts +0 -64
  340. package/src/api/SubComponent/SubData/test/normal.test.ts +0 -91
  341. package/src/api/SubComponent/SubEvents/SubEventsConstraint.ts +0 -27
  342. package/src/api/SubComponent/SubEvents/SubEventsOption.ts +0 -12
  343. package/src/api/SubComponent/SubEvents/test/error.test.ts +0 -36
  344. package/src/api/SubComponent/SubEvents/test/normal.test.ts +0 -209
  345. package/src/api/SubComponent/SubInherit/SubInheritConstraint.ts +0 -17
  346. package/src/api/SubComponent/SubInherit/SubInheritOption.ts +0 -15
  347. package/src/api/SubComponent/SubInherit/test/error.test.ts +0 -84
  348. package/src/api/SubComponent/SubInherit/test/normal.test.ts +0 -81
  349. package/src/api/SubComponent/SubInstance/SubInstance.ts +0 -9
  350. package/src/api/SubComponent/SubInstance/test/error.test.ts +0 -22
  351. package/src/api/SubComponent/SubInstance/test/normal.test.ts +0 -87
  352. package/src/api/SubComponent/SubLifetimes/SubLifetimesOption.ts +0 -3
  353. package/src/api/SubComponent/SubMethods/SubMethodsConstraint.ts +0 -3
  354. package/src/api/SubComponent/SubMethods/SubMethodsOption.ts +0 -17
  355. package/src/api/SubComponent/SubMethods/test/error.test.ts +0 -51
  356. package/src/api/SubComponent/SubMethods/test/normarl.test.ts +0 -33
  357. package/src/api/SubComponent/SubObservers/SubObserversOption.ts +0 -3
  358. package/src/api/SubComponent/SubPageLifetimes/SubPageLifetimesOption.ts +0 -6
  359. package/src/api/SubComponent/SubPageLifetimes/test/error.test.ts +0 -1
  360. package/src/api/SubComponent/SubPageLifetimes/test/normal.test.ts +0 -1
  361. package/src/api/SubComponent/SubReturnType/CreateSubComponentDoc.ts +0 -41
  362. package/src/api/SubComponent/SubReturnType/test/error.test.ts +0 -18
  363. package/src/api/SubComponent/SubReturnType/test/normal.test.ts +0 -98
  364. package/src/api/SubComponent/SubStore/SubStoreConstraint.ts +0 -13
  365. package/src/api/SubComponent/SubStore/SubStoreOption.ts +0 -32
  366. package/src/api/SubComponent/SubStore/test/error.test.ts +0 -60
  367. package/src/api/SubComponent/SubStore/test/normal.test.ts +0 -43
  368. package/src/api/SubComponent/SubWatch/SubWatchOption.ts +0 -3
  369. package/src/api/SubComponent/SubWatch/test/WatchComputed.test.ts +0 -90
  370. package/src/api/SubComponent/SubWatch/test/WatchProperties.test.ts +0 -151
  371. package/src/api/SubComponent/SubWatch/test/WatchRootData.test.ts +0 -122
  372. package/src/api/SubComponent/SubWatch/test/WatchSubData.test.ts +0 -49
  373. package/src/api/SubComponent/SubWatch/test/WtachInject.test.ts +0 -16
  374. package/src/api/SubComponent/SubWatch/test/error.test.ts +0 -60
  375. package/src/api/SubComponent/index.ts +0 -301
  376. package/src/api/SubComponent/returnType.ts +0 -39
  377. package/src/api/wxSugar.ts +0 -107
  378. package/src/behaviors/BbeforeCreated.ts +0 -18
  379. package/src/behaviors/BthrottleDebounce.ts +0 -28
  380. package/src/index.ts +0 -46
  381. package/src/thirdLib/index.ts +0 -3
  382. package/src/thirdLib/vant/Button.ts +0 -23
  383. package/src/thirdLib/vant/NoticeBar.ts +0 -32
  384. package/src/thirdLib/vant/Popup.ts +0 -70
  385. package/src/thirdLib/vant/index.ts +0 -5
  386. package/src/thirdLib/wm/Textarea.ts +0 -117
  387. package/src/thirdLib/wm/baseEvents.ts +0 -54
  388. package/src/thirdLib/wm/index.ts +0 -9
  389. package/src/thirdLib/wm/map.ts +0 -266
  390. package/src/thirdLib/wm/scrollView.ts +0 -86
  391. package/src/thirdLib/wm/swiper.test.ts +0 -22
  392. package/src/thirdLib/wm/swiper.ts +0 -111
  393. package/src/thirdLib/wm/view.ts +0 -28
  394. package/src/types/AddNullForObject.ts +0 -6
  395. package/src/types/AddPrefix.ts +0 -10
  396. package/src/types/Assert.ts +0 -1
  397. package/src/types/Assign.ts +0 -1
  398. package/src/types/ComputeObject.ts +0 -1
  399. package/src/types/CreateComponentType.ts +0 -37
  400. package/src/types/DetailedType.ts +0 -15
  401. package/src/types/ExtendComponentType.ts +0 -60
  402. package/src/types/Extra.ts +0 -1
  403. package/src/types/GetComponentPrefix.ts +0 -36
  404. package/src/types/GetPropertiesDuplicatedKeys.ts +0 -14
  405. package/src/types/Has.ts +0 -1
  406. package/src/types/InferDetailedType.test.ts +0 -13
  407. package/src/types/InferDetailedType.ts +0 -12
  408. package/src/types/InnerData.ts +0 -1
  409. package/src/types/ListOfSamePrimitive.ts +0 -20
  410. package/src/types/OfficialTypeAlias.ts +0 -107
  411. package/src/types/RemoveInnerData.ts +0 -5
  412. package/src/types/RemoveNever.ts +0 -6
  413. package/src/types/RemoveNullOfRequired.ts +0 -8
  414. package/src/types/RemovePrefix.ts +0 -3
  415. package/src/types/Replace.ts +0 -24
  416. package/src/types/ReplacePrefix.ts +0 -46
  417. package/src/types/RequiredKeys.ts +0 -8
  418. package/src/types/Shift.ts +0 -2
  419. package/src/types/TwoParamsEqual.ts +0 -3
  420. package/src/types/UnionToComma.test.ts +0 -9
  421. package/src/types/Validators.ts +0 -17
  422. package/src/types/includes.ts +0 -3
  423. package/src/utils/InnerMarker.ts +0 -3
  424. package/src/utils/_utils.ts +0 -8
  425. package/src/utils/applyDebounceAndThrottle.ts +0 -31
  426. package/src/utils/debounce.ts +0 -22
  427. package/src/utils/deepClone.ts +0 -20
  428. package/src/utils/deepEqual.ts +0 -32
  429. package/src/utils/isEmptyObject.ts +0 -14
  430. package/src/utils/nonNullable.ts +0 -20
  431. package/src/utils/throttle.ts +0 -24
  432. package/src/utils/typeEqual.ts +0 -30
  433. package/src/utils/typeNotEqual.ts +0 -48
  434. package/tsconfig.json +0 -24
  435. /package/dist/api/{SubComponent → CustomComponent}/returnType.js +0 -0
@@ -1,51 +0,0 @@
1
- import { deepEqual } from "../../../../utils/deepEqual";
2
- import type { Instance } from "../../../RootComponent/Instance/RootComponentInstance";
3
- import { deepProxy, getOriginalValue } from "./data-tracer";
4
- import { removeSubDependences } from "./dependencesOptimize";
5
- import type { ComputedDependence } from "./initComputedAndGetCache";
6
-
7
- export function computedUpdater(this: Instance): void {
8
- for (const key in this.data.__computedCache__) {
9
- const itemCache = this.data.__computedCache__[key];
10
- let changed = false;
11
- outLook: for (const dep of itemCache.dependences) {
12
- let curdepVal: unknown = this.data;
13
- for (const path of dep.paths) {
14
- // 如果依赖值为null,则直接跳出
15
- if (curdepVal === null) {
16
- changed = true;
17
- break outLook;
18
- }
19
- curdepVal = (curdepVal as Record<string, unknown>)[path];
20
- }
21
- // 检查依赖值是否改变
22
- if (!deepEqual(curdepVal, dep.val)) {
23
- changed = true;
24
- break;
25
- }
26
- }
27
- if (changed) {
28
- const newDependences: ComputedDependence[] = [];
29
- const proxyThis = new Proxy(this, {
30
- get(target, prop, receiver) {
31
- if (prop === "data") {
32
- return deepProxy(target.data, newDependences);
33
- }
34
- return Reflect.get(target, prop, receiver);
35
- },
36
- set() {
37
- throw "不可以在计算属性中修改实例的属性";
38
- },
39
- });
40
- const newValue = itemCache.method.call(proxyThis);
41
- // 更新值不会立即再次进入**函数,而是当前**函数运行完毕后触发**函数,\
42
- this.setData({
43
- [key]: getOriginalValue(newValue),
44
- });
45
- // 更新依赖(优化)
46
- this.data.__computedCache__[key].dependences = removeSubDependences(newDependences);
47
- // 有一个计算属性更新就重新更新所有计算互相,避免后置依赖导致前置依赖错误
48
- return computedUpdater.call(this);
49
- }
50
- }
51
- }
@@ -1,62 +0,0 @@
1
- import { removePreviousDependence } from "./dependencesOptimize";
2
- import type { ComputedDependence } from "./initComputedAndGetCache";
3
-
4
- // 判断属性字段是否为对象自身的属性
5
- function isOwnProp(target: object, prop: string) {
6
- return Object.prototype.hasOwnProperty.call(target, prop);
7
- }
8
- export function deepProxy(
9
- data: object,
10
- dependences: ComputedDependence[],
11
- basePath: string[] = [],
12
- ): object {
13
- let ignoreProxy = false;
14
- const handler = {
15
- get<T extends object>(target: T, prop: keyof T & string) {
16
- if (prop === "__original__") {
17
- return target;
18
- }
19
- const val = target[prop];
20
-
21
- // 原型链上的属性不收集依赖,比如数组上的方法 slice map forEach 对象上的toString等
22
- if ((val !== undefined && (isOwnProp(target, prop) === false)) || ignoreProxy) {
23
- return typeof val === "function" ? val.bind(target) : val; // : val 覆盖测试不到.
24
- }
25
- removePreviousDependence(dependences, basePath);
26
-
27
- const curPath = basePath.concat(prop);
28
-
29
- dependences.push({ paths: curPath, val });
30
-
31
- // 非对象不代理
32
- if (typeof val !== "object" || val === null) return val;
33
- return deepProxy(val, dependences, curPath);
34
- },
35
- // 使用in操作符时处理
36
- has(target: Record<string, unknown>, prop: string) {
37
- removePreviousDependence(dependences, basePath);
38
- const curPath = basePath.concat(prop);
39
- dependences.push({ paths: curPath, val: target[prop] });
40
- return Reflect.has(target, prop);
41
- },
42
- // 拦截Object.keys, Object.values, Object.entries时后续不收集依赖ignoreProxy=true
43
- ownKeys(target: object) {
44
- ignoreProxy = true;
45
- return Reflect.ownKeys(target);
46
- },
47
- set(_target: object, prop: string) {
48
- throw Error(`${prop}字段是只读的`);
49
- },
50
- };
51
-
52
- return new Proxy(data, handler);
53
- }
54
-
55
- // 如果是代理对象可以从__original__中获取原始值,否则返回自身
56
- export function getOriginalValue(value: { __original__?: unknown }): unknown {
57
- if (typeof value !== "object" || value === null || value.__original__ === undefined) {
58
- return value;
59
- }
60
-
61
- return value.__original__;
62
- }
@@ -1,45 +0,0 @@
1
- import type { ComputedDependence } from "./initComputedAndGetCache";
2
-
3
- // 删除子依赖
4
- export function removeSubDependences(dependences: ComputedDependence[]) {
5
- // 把dependences按照路径长度排序
6
- dependences.sort((a, b) => a.paths.length - b.paths.length);
7
- // 从最长的路径开始遍历,如果当前路径是上一个路径的子路径,则删除当前路径
8
- for (let f = 0; f < dependences.length; f++) {
9
- const sortPath = dependences[f].paths;
10
- // 从后往前遍历,删除子依赖,保留父依赖
11
- for (let i = dependences.length - 1; i > f; i--) {
12
- const curPath = dependences[i].paths;
13
- // 检查 curPath 是否以 sortPath 开头,并且下一个元素是子路径
14
- if (curPath.length > sortPath.length && curPath.slice(0, sortPath.length).toString() === sortPath.toString()) {
15
- dependences.splice(i, 1);
16
- }
17
- }
18
- }
19
- // 去重
20
- return dependences.filter((dep, index, self) =>
21
- index === self.findIndex((t) => (
22
- t.paths.toString() === dep.paths.toString()
23
- ))
24
- );
25
- }
26
- // const testA = removeSubDependences([{paths: ["test",'aaa']},{paths: ["test"]}]);
27
- // console.log('testA', testA); // [{paths: ["test"]}]
28
- // const testB = removeSubDependences([{paths: ["test"]},{paths: ["test",'aaa']},{paths: ["test",'aaa','bbb']}]);
29
- // console.log('testB', testB); // [{paths: ["test"]}]
30
- // const testC = removeSubDependences([{paths: ["test"]},{paths: ["test1"]}]);
31
- // console.log('testC', testC); // [{paths: ["test"]},{paths: ["test1"]}]
32
- // const testD = removeSubDependences([{paths: ["test"]},{paths: ["test"]}]);
33
- // console.log('testD', testD); // [{paths: ["test"]}]
34
- // 当前依赖是上一个依赖的子依赖时,去除上一个依赖
35
- export function removePreviousDependence(dependences: ComputedDependence[], basePath: string[]) {
36
- if (dependences.length === 0 || basePath.length === 0) return dependences;
37
-
38
- const lastDependence = dependences[dependences.length - 1];
39
-
40
- if (lastDependence.paths.toString() === basePath.toString()) {
41
- dependences.pop();
42
- }
43
-
44
- return dependences;
45
- }
@@ -1,42 +0,0 @@
1
- import type { Func } from "hry-types/src/Misc/Func";
2
- import { deepClone } from "../../../../utils/deepClone";
3
- import { isEmptyObject } from "../../../../utils/isEmptyObject";
4
- import { nonNullable } from "../../../../utils/nonNullable";
5
- import type { ComputedConstraint } from "../../../RootComponent/Computed/ComputedConstraint";
6
- import type { Instance } from "../../../RootComponent/Instance/RootComponentInstance";
7
- import { getPathsValue } from "../watchHandler/getPathsValue";
8
- import { hasComputedPath } from "../watchHandler/hasComputedPath";
9
- import { initComputedAndGetCache } from "./initComputedAndGetCache";
10
- /**
11
- * 初始化会在2个时间渲染,一个是observers.**的回调函数,一个是attached周期。
12
- * @param computedConfig
13
- * @param watchConfig
14
- * @param mark
15
- * @returns
16
- */
17
- export function initComputed(
18
- computedConfig: ComputedConstraint,
19
- watchConfig: Record<string, Func>,
20
- // mark?: string,
21
- ) {
22
- return function(this: Instance) {
23
- // __computedCache__ 用来避免重复初始化。
24
-
25
- const __computedInitCache__ = initComputedAndGetCache.call(this, computedConfig);
26
- // 缓存放入data中
27
- this.data.__computedCache__ = __computedInitCache__;
28
- // 为__watchOldValue__赋值(watchPath中包含计算属性的值的key)
29
- if (!isEmptyObject(watchConfig)) {
30
- // 有watchConfig配置时,watchOldValue已经初始过了,所以必有__watchOldValue__
31
- const watchOldValue: Record<string, unknown[]> = nonNullable(this.data.__watchOldValue__);
32
- for (const path in watchConfig) {
33
- // 只针对watchPath中包含计算属性的值的key进行赋值
34
- if (hasComputedPath(path, Object.keys(computedConfig))) {
35
- watchOldValue[path] = deepClone(getPathsValue(this.data, path));
36
- }
37
- }
38
- }
39
- // watch回调时会判断__computedInited__是否为true,如果为false则不执行watch回调
40
- this.data.__computedInited__ = true;
41
- };
42
- }
@@ -1,105 +0,0 @@
1
- import type { Func } from "hry-types/src/Misc/Func";
2
-
3
- import type { Instance } from "../../../RootComponent/Instance/RootComponentInstance";
4
-
5
- import { deepProxy, getOriginalValue } from "./data-tracer";
6
- import { removeSubDependences } from "./dependencesOptimize";
7
- export type ComputedDependence = { paths: string[]; val: unknown };
8
-
9
- type ItemCache = {
10
- dependences: ComputedDependence[];
11
- method: Func;
12
- value: unknown;
13
- };
14
-
15
- type ComputedId = string;
16
-
17
- export type ComputedCache = Record<ComputedId, ItemCache>;
18
-
19
- /**
20
- * 如果依赖列表某项的首个字段值为undefined并且字段为其他计算属性字段(即被依赖的计算字段写在了依赖他的计算字段后面) 返回false, 否则返回true表示依赖有效。
21
- */
22
- function isValidDependences(dependences: ComputedDependence[], computedKeys: string[]): boolean {
23
- for (const { paths: path, val } of dependences) {
24
- if ((val === undefined) && computedKeys.includes(path[0])) {
25
- return false;
26
- }
27
- }
28
-
29
- // 依赖有效
30
- return true;
31
- }
32
- export function _initComputedAndGetCache(
33
- this: Instance,
34
- computedConfig: Record<string, Func>,
35
- uninitedkeys: string[],
36
- computedCache: ComputedCache,
37
- ): ComputedCache {
38
- for (const key of uninitedkeys) {
39
- const computedFunc = computedConfig[key];
40
- const dependences: ComputedDependence[] = [];
41
- const proxyThis = new Proxy(this, {
42
- get(target, prop: string, receiver) {
43
- if (prop === "data") {
44
- return deepProxy(target.data, dependences);
45
- }
46
- return Reflect.get(target, prop, receiver);
47
- },
48
- set() {
49
- throw "不可以在计算属性中修改实例的属性";
50
- },
51
- });
52
- // 通过代理data获取计算字段的初始值和依赖
53
-
54
- let initValue;
55
- let errMsg;
56
- try {
57
- initValue = computedFunc.call(proxyThis);
58
- } catch (e) {
59
- errMsg = e;
60
- }
61
- // 计算属性执行失败,直接返回
62
- // 去除当前已初始的计算属性key
63
- uninitedkeys = uninitedkeys.filter(ele => ele !== key);
64
-
65
- // 验证依赖是否有效
66
- if (isValidDependences(dependences, uninitedkeys)) {
67
- // 依赖合法还有错误就报错
68
- if (errMsg) {
69
- throw errMsg;
70
- }
71
- initValue = getOriginalValue(initValue);
72
- // 把计算属性初始值加入到data中 此时会引起watch和observers触发
73
- this.setData({
74
- [key]: initValue,
75
- });
76
- computedCache[key] = {
77
- dependences: removeSubDependences(dependences),
78
- method: computedFunc,
79
- value: initValue,
80
- };
81
- } else {
82
- // 把当前依赖不正确的key放到后面去
83
- uninitedkeys.push(key);
84
- }
85
- }
86
- // 看uninitedkey是否未空,空表示所有依赖收集完毕直接返回
87
- if (uninitedkeys.length === 0) {
88
- return computedCache;
89
- }
90
-
91
- // uninitedkey不为空,递归调用
92
- return _initComputedAndGetCache.call(this, computedConfig, uninitedkeys, computedCache);
93
- }
94
-
95
- /**
96
- * 把计算属性初始值setData并返回缓存
97
- * @param this
98
- * @param computedConfig 计算属性配置
99
- */
100
- export function initComputedAndGetCache(
101
- this: Instance,
102
- computedConfig: Record<string, Func>,
103
- ): ComputedCache {
104
- return _initComputedAndGetCache.call(this, computedConfig, Object.keys(computedConfig), {});
105
- }
@@ -1,51 +0,0 @@
1
- import type { IInjectInfo } from "../../..";
2
- import type { InjectKey } from "../../InstanceInject/instanceConfig";
3
- import type { FinalOptionsOfComponent } from ".";
4
- /**
5
- * 把injectInfo字段合并到finalOptionsForComponent
6
- * @remarks 规则:
7
- * 1. behaviors字段 push
8
- * 2. 对象字段 没有的话直接赋值,有的话Object.assign
9
- * @param finalOptionsForComponent
10
- * @param injectInfo
11
- * @returns finalOptionsForComponent
12
- */
13
- function mergeOptions(
14
- finalOptionsForComponent: FinalOptionsOfComponent,
15
- injectInfo: IInjectInfo,
16
- ): FinalOptionsOfComponent {
17
- for (const key in injectInfo) {
18
- const isInjectKey = key as InjectKey;
19
- const injectVal = injectInfo[isInjectKey];
20
-
21
- if (key in finalOptionsForComponent) {
22
- const renamedKey = key as keyof FinalOptionsOfComponent;
23
- const originalVal = finalOptionsForComponent[renamedKey];
24
- switch (isInjectKey) {
25
- case "behaviors":
26
- finalOptionsForComponent["behaviors"].push(...injectVal as string[]);
27
-
28
- break;
29
-
30
- default:
31
- // @ts-ignore
32
- finalOptionsForComponent[renamedKey] = 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
- }
@@ -1,27 +0,0 @@
1
- import type { FinalOptionsOfComponent } from ".";
2
-
3
- // 内部字段
4
- const internalFiled = {
5
- methods: ["disposer"],
6
- data: ["__computedCache__", "__watchOldValue__"], // "__throttleDebounce__" 放在之前的位置验证
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
- /* istanbul ignore next 同上*/
24
- throw Error(`data配置中的${key}字段已被内部字段占用`);
25
- }
26
- }
27
- }
@@ -1,29 +0,0 @@
1
- import type { RootComponentDefinitionRuntime } from "../../RootComponent/returnType";
2
- import type { FinalOptionsOfComponent } from ".";
3
-
4
- /**
5
- * 其他字段加入到componentOptions对应字段配置中
6
- */
7
- export function otherFieldsHandle(
8
- finalOptions: FinalOptionsOfComponent,
9
- rootComponentOptions: Omit<RootComponentDefinitionRuntime, "customEvents" | "events">,
10
- ) {
11
- let key: keyof Omit<RootComponentDefinitionRuntime, "customEvents" | "events">;
12
- for (key in rootComponentOptions) {
13
- const config = rootComponentOptions[key];
14
- if (config === undefined) continue;
15
- if (key === "behaviors") {
16
- finalOptions[key].push(...config as string[]);
17
- } else if (typeof config === "object") {
18
- // @ts-ignore
19
- finalOptions[key] = finalOptions[key] || {};
20
- // @ts-ignore
21
- Object.assign(finalOptions[key], config);
22
- } else if (typeof config === "boolean") {
23
- finalOptions[key as "isPage"] = config;
24
- } else {
25
- // console.warn(`选项的${key}字段,无特殊处理`);
26
- finalOptions[key] = config;
27
- }
28
- }
29
- }
@@ -1,23 +0,0 @@
1
- import type { Func } from "hry-types/src/Misc/Func";
2
-
3
- import type { RootComponentDefinitionRuntime } from "../../RootComponent/returnType";
4
- import type { SubComponentDefinitionRuntime } from "../../SubComponent/returnType";
5
- import type { SameFuncOptions } from ".";
6
-
7
- /**
8
- * 把配置为函数的字段方法收集到funcOptions中
9
- */
10
- export function sameFuncFieldsCollect(
11
- options: SubComponentDefinitionRuntime | RootComponentDefinitionRuntime,
12
- funcOptions: SameFuncOptions,
13
- ) {
14
- let key: keyof SameFuncOptions;
15
- for (key in funcOptions) {
16
- const optionsKeyConfig: Record<string, Func> | undefined = options[key];
17
- if (optionsKeyConfig) {
18
- for (const _key in optionsKeyConfig) {
19
- (funcOptions[key][_key] ||= []).push(optionsKeyConfig[_key]);
20
- }
21
- }
22
- }
23
- }
@@ -1,36 +0,0 @@
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: Record<string, unknown>, configList: Record<string, Func[]>) {
8
- for (const key in configList) {
9
- config[key] = function(...args: unknown[]) {
10
- configList[key].forEach(ele => ele.call(this, ...args));
11
- };
12
- }
13
- }
14
- /**
15
- * 把函数列表配置放入一个配置中循环依次运行
16
- */
17
- export function sameFuncOptionsHandle(
18
- finalOptionsForComponent: FinalOptionsOfComponent,
19
- isPage: boolean | undefined,
20
- funcOptions: SameFuncOptions,
21
- ) {
22
- if (isPage) {
23
- // 页面时 生命周期方法(即 on 开头的方法),(https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/component.html)
24
- if (!isEmptyObject(funcOptions.pageLifetimes)) {
25
- _sameFuncOptionsHandle(finalOptionsForComponent.methods, funcOptions.pageLifetimes);
26
- }
27
- } else {
28
- // 组件时
29
- if (!isEmptyObject(funcOptions.pageLifetimes)) {
30
- _sameFuncOptionsHandle(finalOptionsForComponent.pageLifetimes, funcOptions.pageLifetimes);
31
- }
32
- }
33
- if (funcOptions.lifetimes) _sameFuncOptionsHandle(finalOptionsForComponent.lifetimes, funcOptions.lifetimes);
34
-
35
- if (funcOptions.watch) _sameFuncOptionsHandle(finalOptionsForComponent.watch, funcOptions.watch);
36
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * 获取指定paths的值
3
- * @param obj - 数据对象
4
- * @param paths - 支持多字段(用`,`分开) 例如 'obj.xxx,a,b.**'
5
- * @returns unknown[] 每项对应paths每项的值
6
- */
7
- export function getPathsValue(obj: object, paths: string) {
8
- const valueList: unknown[] = [];
9
-
10
- // ['obj.xxx','a','b.**'].forEach
11
- paths.split(",").forEach(path => {
12
- // path : 'obj.xxx' | 'a' | 'b.**'
13
- if (path.includes(".**")) {
14
- // "b.**" => 'b'
15
- path = path.slice(0, -3);
16
- }
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- const value = path.split(".").reduce((pre: any, path) => {
19
- // pre有可能为undefined|null,比如obj是未初始化的计算属性(undefined),还有可能是properties的对象类型(默认为null)
20
- try {
21
- return pre[path];
22
- } catch {
23
- return undefined;
24
- }
25
- }, obj);
26
-
27
- valueList.push(value);
28
- });
29
-
30
- return valueList;
31
- }
@@ -1,51 +0,0 @@
1
- import type {
2
- PropertiesConstraint,
3
- PropertiesTypes,
4
- RequiredSingle,
5
- RequiredUnion,
6
- } from "../../../RootComponent/Properties/PropertiesConstraint";
7
-
8
- type PropertiesDefaultValue = "" | 0 | [] | null | false;
9
- /* istanbul ignore next */
10
- function getRequiredSingleValue(
11
- PropType: RequiredSingle,
12
- ): PropertiesDefaultValue {
13
- switch (PropType) {
14
- case String:
15
- return "";
16
- case Number:
17
- return 0;
18
- case Array:
19
- return [];
20
- case Object:
21
- return null;
22
- case Boolean:
23
- return false;
24
- default:
25
- /* istanbul ignore next */
26
- throw Error(
27
- "properties字段类型只能为 String | Number | Array | Object | Boolean ",
28
- );
29
- }
30
- }
31
- function IsRequiredSingle(config: PropertiesTypes): config is RequiredSingle {
32
- return config instanceof Function;
33
- }
34
- function IsRequiredUnion(config: PropertiesTypes): config is RequiredUnion {
35
- return !Reflect.has(config, "value");
36
- }
37
- export function getPropertiesValue(propertiesOpt: PropertiesConstraint): object {
38
- const result: Record<string, unknown> = {};
39
- for (const key in propertiesOpt) {
40
- const config = propertiesOpt[key];
41
- if (IsRequiredSingle(config)) {
42
- result[key] = getRequiredSingleValue(config);
43
- } else if (IsRequiredUnion(config)) {
44
- result[key] = getRequiredSingleValue(config.type);
45
- } else {
46
- result[key] = config.value;
47
- }
48
- }
49
-
50
- return result;
51
- }
@@ -1,9 +0,0 @@
1
- export function hasComputedPath(watchPath: string, computedKeys: string[]) {
2
- return watchPath.split(",").some((path) => {
3
- const firstPath = path.split(".")[0];
4
- if (computedKeys.includes(firstPath)) {
5
- return true;
6
- }
7
- return false;
8
- });
9
- }
@@ -1,78 +0,0 @@
1
- import type { Func } from "hry-types/src/Misc/Func";
2
- import { deepClone, deepEqual, isEmptyObject, nonNullable } from "../../../../utils/_utils";
3
- import type { Instance } from "../../../RootComponent/Instance/RootComponentInstance";
4
- import type { FinalOptionsOfComponent, WatchOldValue } from "..";
5
- import { getPathsValue } from "./getPathsValue";
6
- import { getPropertiesValue } from "./getPropertiesValue";
7
- import { hasComputedPath } from "./hasComputedPath";
8
-
9
- // 初始化watch监控字段的旧值对象,排除有计算属性的字段。
10
- function initWatchOldValuesWithoutComputed(
11
- data: FinalOptionsOfComponent["data"],
12
- watchConfig: object,
13
- computedKeys: string[],
14
- ): WatchOldValue {
15
- const watchOldValue: WatchOldValue = {};
16
- for (const path in watchConfig) {
17
- // 有计算属性的路径,跳过会在计算属性初始化后赋值
18
- if (hasComputedPath(path, computedKeys)) continue;
19
- watchOldValue[path] = deepClone(getPathsValue(data, path));
20
- }
21
-
22
- return watchOldValue;
23
- }
24
- function observerHandler(
25
- this: Instance,
26
- key: string,
27
- originObserversHandle: Func | undefined,
28
- watchHadle: Func,
29
- ...newValue: unknown[]
30
- ) {
31
- // 先调用原生observers的回调函数,再调用watch的回调函数。因为watch的回调函数可能会用到原生observers回调函数中更新的数据。
32
- originObserversHandle?.call(this, ...newValue);
33
- const watchOldValue = nonNullable(this.data.__watchOldValue__);
34
- const oldValue = watchOldValue[key];
35
- if (deepEqual(newValue, oldValue)) return;
36
- watchOldValue[key] = deepClone(newValue);
37
- watchHadle.call(this, ...newValue, ...oldValue);
38
- }
39
-
40
- /**
41
- * 把watch配置转换成observers配置的形式,并在回调函数中调用watch的回调函数。
42
- * 小程序的observers是通过监控setData字段,来触发的,不会比较值的变化,小程序底层代码可以监控到properties变化时的setData动作.
43
- * watch字段的目的是数据变化时才触发回调函数,但由于实例中无法通过setData的调用来监听到properties字段变化,所以watch字段的实现方式是通过在observers回调函数中比较新旧值来实现的。
44
- * 还要在组件实例上维护一个__watchOldValue__对象来存储watch监控字段的旧值,以便在回调函数中进行比较。
45
- * @param finalOptionsForComponent
46
- */
47
- export function handleWatchConfig(
48
- finalOptionsForComponent: FinalOptionsOfComponent,
49
- ) {
50
- const { observers: observersConfig, watch: watchConfig, data, properties, computed: computedConfig } =
51
- finalOptionsForComponent;
52
- if (!isEmptyObject(watchConfig)) {
53
- const rawPropertiesValue = getPropertiesValue(properties);
54
- const computedKeys = Object.keys(computedConfig);
55
-
56
- data.__watchOldValue__ = initWatchOldValuesWithoutComputed(
57
- { ...data, ...rawPropertiesValue },
58
- watchConfig,
59
- computedKeys,
60
- );
61
- for (const key in watchConfig) {
62
- const watchHadle = watchConfig[key];
63
- const originObserversHandle = observersConfig[key] as Func | undefined;
64
- // 在监控多个数据时,参数是多个值
65
- observersConfig[key] = function(this: Instance, ...values: unknown[]) {
66
- // 计算属性初始化完成时直接调用。
67
- if (this.data.__computedInited__) {
68
- observerHandler.call(this, key, originObserversHandle, watchHadle, ...values);
69
- } else {
70
- // 计算属性未初始化完成时,先把watch的回调函数注册到实例上,等计算属性初始化完成时再调用。因为计算属性初始化完成时会把data中的值setData一次,会触发observers回调函数,所以在这里注册watch的回调函数,就能保证计算属性初始化完成后能正确调用watch的回调函数。
71
- (this.data.__oberverHandler__ ||= []).push(
72
- observerHandler.bind(this, key, originObserversHandle, watchHadle, ...values),
73
- );
74
- }
75
- };
76
- }
77
- }
78
- }
@@ -1,25 +0,0 @@
1
- type PrefixKey = `${string}_${string}`;
2
-
3
- type _ComponentDoc = {
4
- properties?: Record<PrefixKey, unknown>;
5
- events?: Record<PrefixKey, unknown>;
6
- };
7
-
8
- type Error = "{ properties?: Record<PrefixKey, any>; events?: Record<PrefixKey, any>;}";
9
-
10
- type _Validator<O> = keyof O extends keyof _ComponentDoc
11
- // @ts-ignore 要求ComponentDoc有前缀
12
- ? keyof (O["properties"] & O["events"]) extends PrefixKey ? _ComponentDoc
13
- : Error
14
- : Error;
15
-
16
- /**
17
- * 组件文档类型
18
- * ```ts
19
- * type XxxDoc = {
20
- * properties?: Record<PrefixKey, unknown>;
21
- * events?: Record<PrefixKey, unknown>;
22
- };
23
- * ```
24
- */
25
- export type ComponentDoc<O extends _Validator<O> = _ComponentDoc> = O;