create-uniapps 1.0.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 (538) hide show
  1. package/README.md +191 -0
  2. package/index.mjs +187 -0
  3. package/package.json +40 -0
  4. package/template/.prettierrc +11 -0
  5. package/template/eslint.config.mjs +30 -0
  6. package/template/index.html +23 -0
  7. package/template/package-lock.json +14557 -0
  8. package/template/package.json +101 -0
  9. package/template/prettier.config.ts +4 -0
  10. package/template/shims-uni.d.ts +10 -0
  11. package/template/src/App.vue +18 -0
  12. package/template/src/auto-imports.d.ts +334 -0
  13. package/template/src/components.d.ts +14 -0
  14. package/template/src/env.d.ts +8 -0
  15. package/template/src/main.ts +22 -0
  16. package/template/src/manifest.json +72 -0
  17. package/template/src/pages/index/index.vue +9 -0
  18. package/template/src/pages.json +23 -0
  19. package/template/src/shime-uni.d.ts +6 -0
  20. package/template/src/static/css/index.scss +14 -0
  21. package/template/src/static/css/tailwind.css +1 -0
  22. package/template/src/static/logo.png +0 -0
  23. package/template/src/uni.scss +77 -0
  24. package/template/src/uni_modules/uview-plus/LICENSE +21 -0
  25. package/template/src/uni_modules/uview-plus/README.md +74 -0
  26. package/template/src/uni_modules/uview-plus/changelog.md +940 -0
  27. package/template/src/uni_modules/uview-plus/components/u--form/u--form.vue +85 -0
  28. package/template/src/uni_modules/uview-plus/components/u--image/u--image.vue +50 -0
  29. package/template/src/uni_modules/uview-plus/components/u--input/u--input.vue +74 -0
  30. package/template/src/uni_modules/uview-plus/components/u--text/u--text.vue +45 -0
  31. package/template/src/uni_modules/uview-plus/components/u--textarea/u--textarea.vue +47 -0
  32. package/template/src/uni_modules/uview-plus/components/u-action-sheet/actionSheet.js +26 -0
  33. package/template/src/uni_modules/uview-plus/components/u-action-sheet/props.js +62 -0
  34. package/template/src/uni_modules/uview-plus/components/u-action-sheet/u-action-sheet.vue +282 -0
  35. package/template/src/uni_modules/uview-plus/components/u-action-sheet-data/u-action-sheet-data.vue +109 -0
  36. package/template/src/uni_modules/uview-plus/components/u-album/album.js +28 -0
  37. package/template/src/uni_modules/uview-plus/components/u-album/props.js +86 -0
  38. package/template/src/uni_modules/uview-plus/components/u-album/u-album.vue +300 -0
  39. package/template/src/uni_modules/uview-plus/components/u-alert/alert.js +22 -0
  40. package/template/src/uni_modules/uview-plus/components/u-alert/props.js +46 -0
  41. package/template/src/uni_modules/uview-plus/components/u-alert/u-alert.vue +250 -0
  42. package/template/src/uni_modules/uview-plus/components/u-avatar/avatar.js +28 -0
  43. package/template/src/uni_modules/uview-plus/components/u-avatar/props.js +81 -0
  44. package/template/src/uni_modules/uview-plus/components/u-avatar/u-avatar.vue +179 -0
  45. package/template/src/uni_modules/uview-plus/components/u-avatar-group/avatarGroup.js +23 -0
  46. package/template/src/uni_modules/uview-plus/components/u-avatar-group/props.js +54 -0
  47. package/template/src/uni_modules/uview-plus/components/u-avatar-group/u-avatar-group.vue +109 -0
  48. package/template/src/uni_modules/uview-plus/components/u-back-top/backtop.js +27 -0
  49. package/template/src/uni_modules/uview-plus/components/u-back-top/props.js +56 -0
  50. package/template/src/uni_modules/uview-plus/components/u-back-top/u-back-top.vue +132 -0
  51. package/template/src/uni_modules/uview-plus/components/u-badge/badge.js +27 -0
  52. package/template/src/uni_modules/uview-plus/components/u-badge/props.js +79 -0
  53. package/template/src/uni_modules/uview-plus/components/u-badge/u-badge.vue +176 -0
  54. package/template/src/uni_modules/uview-plus/components/u-box/props.js +27 -0
  55. package/template/src/uni_modules/uview-plus/components/u-box/u-box.vue +91 -0
  56. package/template/src/uni_modules/uview-plus/components/u-button/button.js +43 -0
  57. package/template/src/uni_modules/uview-plus/components/u-button/nvue.scss +46 -0
  58. package/template/src/uni_modules/uview-plus/components/u-button/props.js +159 -0
  59. package/template/src/uni_modules/uview-plus/components/u-button/u-button.vue +503 -0
  60. package/template/src/uni_modules/uview-plus/components/u-button/vue.scss +81 -0
  61. package/template/src/uni_modules/uview-plus/components/u-calendar/calendar.js +45 -0
  62. package/template/src/uni_modules/uview-plus/components/u-calendar/header.vue +109 -0
  63. package/template/src/uni_modules/uview-plus/components/u-calendar/month.vue +608 -0
  64. package/template/src/uni_modules/uview-plus/components/u-calendar/props.js +160 -0
  65. package/template/src/uni_modules/uview-plus/components/u-calendar/u-calendar.vue +411 -0
  66. package/template/src/uni_modules/uview-plus/components/u-calendar/util.js +86 -0
  67. package/template/src/uni_modules/uview-plus/components/u-car-keyboard/carKeyboard.js +15 -0
  68. package/template/src/uni_modules/uview-plus/components/u-car-keyboard/props.js +17 -0
  69. package/template/src/uni_modules/uview-plus/components/u-car-keyboard/u-car-keyboard.vue +314 -0
  70. package/template/src/uni_modules/uview-plus/components/u-card/card.js +40 -0
  71. package/template/src/uni_modules/uview-plus/components/u-card/props.js +134 -0
  72. package/template/src/uni_modules/uview-plus/components/u-card/u-card.vue +184 -0
  73. package/template/src/uni_modules/uview-plus/components/u-cate-tab/u-cate-tab.vue +342 -0
  74. package/template/src/uni_modules/uview-plus/components/u-cell/cell.js +35 -0
  75. package/template/src/uni_modules/uview-plus/components/u-cell/props.js +112 -0
  76. package/template/src/uni_modules/uview-plus/components/u-cell/u-cell.vue +267 -0
  77. package/template/src/uni_modules/uview-plus/components/u-cell-group/cellGroup.js +17 -0
  78. package/template/src/uni_modules/uview-plus/components/u-cell-group/props.js +16 -0
  79. package/template/src/uni_modules/uview-plus/components/u-cell-group/u-cell-group.vue +66 -0
  80. package/template/src/uni_modules/uview-plus/components/u-checkbox/checkbox.js +27 -0
  81. package/template/src/uni_modules/uview-plus/components/u-checkbox/props.js +76 -0
  82. package/template/src/uni_modules/uview-plus/components/u-checkbox/u-checkbox.vue +388 -0
  83. package/template/src/uni_modules/uview-plus/components/u-checkbox-group/checkboxGroup.js +29 -0
  84. package/template/src/uni_modules/uview-plus/components/u-checkbox-group/props.js +93 -0
  85. package/template/src/uni_modules/uview-plus/components/u-checkbox-group/u-checkbox-group.vue +133 -0
  86. package/template/src/uni_modules/uview-plus/components/u-circle-progress/circleProgress.js +15 -0
  87. package/template/src/uni_modules/uview-plus/components/u-circle-progress/props.js +10 -0
  88. package/template/src/uni_modules/uview-plus/components/u-circle-progress/u-circle-progress.vue +200 -0
  89. package/template/src/uni_modules/uview-plus/components/u-city-locate/u-city-locate.vue +161 -0
  90. package/template/src/uni_modules/uview-plus/components/u-code/code.js +21 -0
  91. package/template/src/uni_modules/uview-plus/components/u-code/props.js +36 -0
  92. package/template/src/uni_modules/uview-plus/components/u-code/u-code.vue +131 -0
  93. package/template/src/uni_modules/uview-plus/components/u-code-input/codeInput.js +29 -0
  94. package/template/src/uni_modules/uview-plus/components/u-code-input/props.js +90 -0
  95. package/template/src/uni_modules/uview-plus/components/u-code-input/u-code-input.vue +299 -0
  96. package/template/src/uni_modules/uview-plus/components/u-col/col.js +19 -0
  97. package/template/src/uni_modules/uview-plus/components/u-col/props.js +31 -0
  98. package/template/src/uni_modules/uview-plus/components/u-col/u-col.vue +169 -0
  99. package/template/src/uni_modules/uview-plus/components/u-collapse/collapse.js +17 -0
  100. package/template/src/uni_modules/uview-plus/components/u-collapse/props.js +21 -0
  101. package/template/src/uni_modules/uview-plus/components/u-collapse/u-collapse.vue +90 -0
  102. package/template/src/uni_modules/uview-plus/components/u-collapse-item/collapseItem.js +31 -0
  103. package/template/src/uni_modules/uview-plus/components/u-collapse-item/props.js +97 -0
  104. package/template/src/uni_modules/uview-plus/components/u-collapse-item/u-collapse-item.vue +243 -0
  105. package/template/src/uni_modules/uview-plus/components/u-column-notice/columnNotice.js +25 -0
  106. package/template/src/uni_modules/uview-plus/components/u-column-notice/props.js +61 -0
  107. package/template/src/uni_modules/uview-plus/components/u-column-notice/u-column-notice.vue +165 -0
  108. package/template/src/uni_modules/uview-plus/components/u-copy/u-copy.vue +70 -0
  109. package/template/src/uni_modules/uview-plus/components/u-count-down/countDown.js +18 -0
  110. package/template/src/uni_modules/uview-plus/components/u-count-down/props.js +26 -0
  111. package/template/src/uni_modules/uview-plus/components/u-count-down/u-count-down.vue +165 -0
  112. package/template/src/uni_modules/uview-plus/components/u-count-down/utils.js +62 -0
  113. package/template/src/uni_modules/uview-plus/components/u-count-to/countTo.js +25 -0
  114. package/template/src/uni_modules/uview-plus/components/u-count-to/props.js +61 -0
  115. package/template/src/uni_modules/uview-plus/components/u-count-to/u-count-to.vue +187 -0
  116. package/template/src/uni_modules/uview-plus/components/u-datetime-picker/datetimePicker.js +42 -0
  117. package/template/src/uni_modules/uview-plus/components/u-datetime-picker/props.js +168 -0
  118. package/template/src/uni_modules/uview-plus/components/u-datetime-picker/u-datetime-picker.vue +520 -0
  119. package/template/src/uni_modules/uview-plus/components/u-divider/divider.js +23 -0
  120. package/template/src/uni_modules/uview-plus/components/u-divider/props.js +46 -0
  121. package/template/src/uni_modules/uview-plus/components/u-divider/u-divider.vue +120 -0
  122. package/template/src/uni_modules/uview-plus/components/u-dragsort/u-dragsort.vue +372 -0
  123. package/template/src/uni_modules/uview-plus/components/u-dropdown/props.js +61 -0
  124. package/template/src/uni_modules/uview-plus/components/u-dropdown/u-dropdown.vue +259 -0
  125. package/template/src/uni_modules/uview-plus/components/u-dropdown-item/props.js +47 -0
  126. package/template/src/uni_modules/uview-plus/components/u-dropdown-item/u-dropdown-item.vue +120 -0
  127. package/template/src/uni_modules/uview-plus/components/u-empty/empty.js +26 -0
  128. package/template/src/uni_modules/uview-plus/components/u-empty/props.js +61 -0
  129. package/template/src/uni_modules/uview-plus/components/u-empty/u-empty.vue +132 -0
  130. package/template/src/uni_modules/uview-plus/components/u-float-button/u-float-button.vue +167 -0
  131. package/template/src/uni_modules/uview-plus/components/u-form/form.js +22 -0
  132. package/template/src/uni_modules/uview-plus/components/u-form/props.js +47 -0
  133. package/template/src/uni_modules/uview-plus/components/u-form/u-form.vue +258 -0
  134. package/template/src/uni_modules/uview-plus/components/u-form-item/formItem.js +24 -0
  135. package/template/src/uni_modules/uview-plus/components/u-form-item/props.js +55 -0
  136. package/template/src/uni_modules/uview-plus/components/u-form-item/u-form-item.vue +261 -0
  137. package/template/src/uni_modules/uview-plus/components/u-gap/gap.js +19 -0
  138. package/template/src/uni_modules/uview-plus/components/u-gap/props.js +26 -0
  139. package/template/src/uni_modules/uview-plus/components/u-gap/u-gap.vue +40 -0
  140. package/template/src/uni_modules/uview-plus/components/u-grid/grid.js +17 -0
  141. package/template/src/uni_modules/uview-plus/components/u-grid/props.js +26 -0
  142. package/template/src/uni_modules/uview-plus/components/u-grid/u-grid.vue +113 -0
  143. package/template/src/uni_modules/uview-plus/components/u-grid-item/gridItem.js +16 -0
  144. package/template/src/uni_modules/uview-plus/components/u-grid-item/props.js +16 -0
  145. package/template/src/uni_modules/uview-plus/components/u-grid-item/u-grid-item.vue +218 -0
  146. package/template/src/uni_modules/uview-plus/components/u-icon/icon.js +36 -0
  147. package/template/src/uni_modules/uview-plus/components/u-icon/icons.js +214 -0
  148. package/template/src/uni_modules/uview-plus/components/u-icon/props.js +91 -0
  149. package/template/src/uni_modules/uview-plus/components/u-icon/u-icon.vue +237 -0
  150. package/template/src/uni_modules/uview-plus/components/u-icon/util.js +75 -0
  151. package/template/src/uni_modules/uview-plus/components/u-image/image.js +30 -0
  152. package/template/src/uni_modules/uview-plus/components/u-image/props.js +86 -0
  153. package/template/src/uni_modules/uview-plus/components/u-image/u-image.vue +267 -0
  154. package/template/src/uni_modules/uview-plus/components/u-index-anchor/indexAnchor.js +19 -0
  155. package/template/src/uni_modules/uview-plus/components/u-index-anchor/props.js +31 -0
  156. package/template/src/uni_modules/uview-plus/components/u-index-anchor/u-index-anchor.vue +110 -0
  157. package/template/src/uni_modules/uview-plus/components/u-index-item/props.js +8 -0
  158. package/template/src/uni_modules/uview-plus/components/u-index-item/u-index-item.vue +89 -0
  159. package/template/src/uni_modules/uview-plus/components/u-index-list/indexList.js +20 -0
  160. package/template/src/uni_modules/uview-plus/components/u-index-list/props.js +36 -0
  161. package/template/src/uni_modules/uview-plus/components/u-index-list/u-index-list.vue +593 -0
  162. package/template/src/uni_modules/uview-plus/components/u-input/input.js +48 -0
  163. package/template/src/uni_modules/uview-plus/components/u-input/props.js +198 -0
  164. package/template/src/uni_modules/uview-plus/components/u-input/u-input.vue +399 -0
  165. package/template/src/uni_modules/uview-plus/components/u-keyboard/keyboard.js +30 -0
  166. package/template/src/uni_modules/uview-plus/components/u-keyboard/props.js +86 -0
  167. package/template/src/uni_modules/uview-plus/components/u-keyboard/u-keyboard.vue +166 -0
  168. package/template/src/uni_modules/uview-plus/components/u-lazy-load/u-lazy-load.vue +260 -0
  169. package/template/src/uni_modules/uview-plus/components/u-line/line.js +20 -0
  170. package/template/src/uni_modules/uview-plus/components/u-line/props.js +35 -0
  171. package/template/src/uni_modules/uview-plus/components/u-line/u-line.vue +64 -0
  172. package/template/src/uni_modules/uview-plus/components/u-line-progress/lineProgress.js +20 -0
  173. package/template/src/uni_modules/uview-plus/components/u-line-progress/props.js +35 -0
  174. package/template/src/uni_modules/uview-plus/components/u-line-progress/u-line-progress.vue +152 -0
  175. package/template/src/uni_modules/uview-plus/components/u-link/link.js +26 -0
  176. package/template/src/uni_modules/uview-plus/components/u-link/props.js +41 -0
  177. package/template/src/uni_modules/uview-plus/components/u-link/u-link.vue +86 -0
  178. package/template/src/uni_modules/uview-plus/components/u-list/list.js +28 -0
  179. package/template/src/uni_modules/uview-plus/components/u-list/props.js +101 -0
  180. package/template/src/uni_modules/uview-plus/components/u-list/u-list.vue +182 -0
  181. package/template/src/uni_modules/uview-plus/components/u-list-item/listItem.js +15 -0
  182. package/template/src/uni_modules/uview-plus/components/u-list-item/props.js +11 -0
  183. package/template/src/uni_modules/uview-plus/components/u-list-item/u-list-item.vue +118 -0
  184. package/template/src/uni_modules/uview-plus/components/u-loading-icon/loadingIcon.js +30 -0
  185. package/template/src/uni_modules/uview-plus/components/u-loading-icon/props.js +61 -0
  186. package/template/src/uni_modules/uview-plus/components/u-loading-icon/u-loading-icon.vue +348 -0
  187. package/template/src/uni_modules/uview-plus/components/u-loading-page/loadingPage.js +24 -0
  188. package/template/src/uni_modules/uview-plus/components/u-loading-page/props.js +57 -0
  189. package/template/src/uni_modules/uview-plus/components/u-loading-page/u-loading-page.vue +121 -0
  190. package/template/src/uni_modules/uview-plus/components/u-loadmore/loadmore.js +32 -0
  191. package/template/src/uni_modules/uview-plus/components/u-loadmore/props.js +96 -0
  192. package/template/src/uni_modules/uview-plus/components/u-loadmore/u-loadmore.vue +154 -0
  193. package/template/src/uni_modules/uview-plus/components/u-message-input/u-message-input.vue +318 -0
  194. package/template/src/uni_modules/uview-plus/components/u-modal/modal.js +35 -0
  195. package/template/src/uni_modules/uview-plus/components/u-modal/props.js +111 -0
  196. package/template/src/uni_modules/uview-plus/components/u-modal/u-modal.vue +265 -0
  197. package/template/src/uni_modules/uview-plus/components/u-navbar/navbar.js +33 -0
  198. package/template/src/uni_modules/uview-plus/components/u-navbar/props.js +97 -0
  199. package/template/src/uni_modules/uview-plus/components/u-navbar/u-navbar.vue +200 -0
  200. package/template/src/uni_modules/uview-plus/components/u-navbar-mini/props.js +51 -0
  201. package/template/src/uni_modules/uview-plus/components/u-navbar-mini/u-navbar-mini.vue +137 -0
  202. package/template/src/uni_modules/uview-plus/components/u-no-network/noNetwork.js +18 -0
  203. package/template/src/uni_modules/uview-plus/components/u-no-network/props.js +21 -0
  204. package/template/src/uni_modules/uview-plus/components/u-no-network/u-no-network.vue +222 -0
  205. package/template/src/uni_modules/uview-plus/components/u-notice-bar/noticeBar.js +28 -0
  206. package/template/src/uni_modules/uview-plus/components/u-notice-bar/props.js +76 -0
  207. package/template/src/uni_modules/uview-plus/components/u-notice-bar/u-notice-bar.vue +105 -0
  208. package/template/src/uni_modules/uview-plus/components/u-notify/notify.js +22 -0
  209. package/template/src/uni_modules/uview-plus/components/u-notify/props.js +51 -0
  210. package/template/src/uni_modules/uview-plus/components/u-notify/u-notify.vue +216 -0
  211. package/template/src/uni_modules/uview-plus/components/u-number-box/numberBox.js +39 -0
  212. package/template/src/uni_modules/uview-plus/components/u-number-box/props.js +140 -0
  213. package/template/src/uni_modules/uview-plus/components/u-number-box/u-number-box.vue +478 -0
  214. package/template/src/uni_modules/uview-plus/components/u-number-keyboard/numberKeyboard.js +17 -0
  215. package/template/src/uni_modules/uview-plus/components/u-number-keyboard/props.js +21 -0
  216. package/template/src/uni_modules/uview-plus/components/u-number-keyboard/u-number-keyboard.vue +198 -0
  217. package/template/src/uni_modules/uview-plus/components/u-overlay/overlay.js +18 -0
  218. package/template/src/uni_modules/uview-plus/components/u-overlay/props.js +26 -0
  219. package/template/src/uni_modules/uview-plus/components/u-overlay/u-overlay.vue +71 -0
  220. package/template/src/uni_modules/uview-plus/components/u-pagination/u-pagination.vue +283 -0
  221. package/template/src/uni_modules/uview-plus/components/u-parse/node/node.vue +598 -0
  222. package/template/src/uni_modules/uview-plus/components/u-parse/parse.js +22 -0
  223. package/template/src/uni_modules/uview-plus/components/u-parse/parser.js +1400 -0
  224. package/template/src/uni_modules/uview-plus/components/u-parse/props.js +48 -0
  225. package/template/src/uni_modules/uview-plus/components/u-parse/u-parse.vue +504 -0
  226. package/template/src/uni_modules/uview-plus/components/u-picker/picker.js +40 -0
  227. package/template/src/uni_modules/uview-plus/components/u-picker/props.js +147 -0
  228. package/template/src/uni_modules/uview-plus/components/u-picker/u-picker.vue +472 -0
  229. package/template/src/uni_modules/uview-plus/components/u-picker-column/props.js +7 -0
  230. package/template/src/uni_modules/uview-plus/components/u-picker-column/u-picker-column.vue +28 -0
  231. package/template/src/uni_modules/uview-plus/components/u-picker-data/u-picker-data.vue +130 -0
  232. package/template/src/uni_modules/uview-plus/components/u-popup/popup.js +29 -0
  233. package/template/src/uni_modules/uview-plus/components/u-popup/props.js +81 -0
  234. package/template/src/uni_modules/uview-plus/components/u-popup/u-popup.vue +335 -0
  235. package/template/src/uni_modules/uview-plus/components/u-qrcode/qrcode.js +1319 -0
  236. package/template/src/uni_modules/uview-plus/components/u-qrcode/u-qrcode.vue +449 -0
  237. package/template/src/uni_modules/uview-plus/components/u-radio/props.js +71 -0
  238. package/template/src/uni_modules/uview-plus/components/u-radio/radio.js +27 -0
  239. package/template/src/uni_modules/uview-plus/components/u-radio/u-radio.vue +350 -0
  240. package/template/src/uni_modules/uview-plus/components/u-radio-group/props.js +100 -0
  241. package/template/src/uni_modules/uview-plus/components/u-radio-group/radioGroup.js +31 -0
  242. package/template/src/uni_modules/uview-plus/components/u-radio-group/u-radio-group.vue +136 -0
  243. package/template/src/uni_modules/uview-plus/components/u-rate/props.js +80 -0
  244. package/template/src/uni_modules/uview-plus/components/u-rate/rate.js +26 -0
  245. package/template/src/uni_modules/uview-plus/components/u-rate/u-rate.vue +327 -0
  246. package/template/src/uni_modules/uview-plus/components/u-read-more/props.js +63 -0
  247. package/template/src/uni_modules/uview-plus/components/u-read-more/readMore.js +22 -0
  248. package/template/src/uni_modules/uview-plus/components/u-read-more/u-read-more.vue +165 -0
  249. package/template/src/uni_modules/uview-plus/components/u-row/props.js +21 -0
  250. package/template/src/uni_modules/uview-plus/components/u-row/row.js +17 -0
  251. package/template/src/uni_modules/uview-plus/components/u-row/u-row.vue +96 -0
  252. package/template/src/uni_modules/uview-plus/components/u-row-notice/props.js +41 -0
  253. package/template/src/uni_modules/uview-plus/components/u-row-notice/rowNotice.js +21 -0
  254. package/template/src/uni_modules/uview-plus/components/u-row-notice/u-row-notice.vue +336 -0
  255. package/template/src/uni_modules/uview-plus/components/u-safe-bottom/props.js +7 -0
  256. package/template/src/uni_modules/uview-plus/components/u-safe-bottom/u-safe-bottom.vue +59 -0
  257. package/template/src/uni_modules/uview-plus/components/u-scroll-list/nvue.js +31 -0
  258. package/template/src/uni_modules/uview-plus/components/u-scroll-list/other.js +0 -0
  259. package/template/src/uni_modules/uview-plus/components/u-scroll-list/props.js +36 -0
  260. package/template/src/uni_modules/uview-plus/components/u-scroll-list/scrollList.js +20 -0
  261. package/template/src/uni_modules/uview-plus/components/u-scroll-list/scrollWxs.wxs +50 -0
  262. package/template/src/uni_modules/uview-plus/components/u-scroll-list/u-scroll-list.vue +233 -0
  263. package/template/src/uni_modules/uview-plus/components/u-search/props.js +138 -0
  264. package/template/src/uni_modules/uview-plus/components/u-search/search.js +38 -0
  265. package/template/src/uni_modules/uview-plus/components/u-search/u-search.vue +342 -0
  266. package/template/src/uni_modules/uview-plus/components/u-section/section.js +24 -0
  267. package/template/src/uni_modules/uview-plus/components/u-select/u-select.vue +218 -0
  268. package/template/src/uni_modules/uview-plus/components/u-skeleton/props.js +61 -0
  269. package/template/src/uni_modules/uview-plus/components/u-skeleton/skeleton.js +25 -0
  270. package/template/src/uni_modules/uview-plus/components/u-skeleton/u-skeleton.vue +248 -0
  271. package/template/src/uni_modules/uview-plus/components/u-slider/mpother.js +113 -0
  272. package/template/src/uni_modules/uview-plus/components/u-slider/mpwxs.js +43 -0
  273. package/template/src/uni_modules/uview-plus/components/u-slider/mpwxs.wxs +121 -0
  274. package/template/src/uni_modules/uview-plus/components/u-slider/nvue.js +193 -0
  275. package/template/src/uni_modules/uview-plus/components/u-slider/props.js +91 -0
  276. package/template/src/uni_modules/uview-plus/components/u-slider/slider.js +27 -0
  277. package/template/src/uni_modules/uview-plus/components/u-slider/u-slider.vue +506 -0
  278. package/template/src/uni_modules/uview-plus/components/u-status-bar/props.js +15 -0
  279. package/template/src/uni_modules/uview-plus/components/u-status-bar/statusBar.js +16 -0
  280. package/template/src/uni_modules/uview-plus/components/u-status-bar/u-status-bar.vue +63 -0
  281. package/template/src/uni_modules/uview-plus/components/u-steps/props.js +41 -0
  282. package/template/src/uni_modules/uview-plus/components/u-steps/steps.js +21 -0
  283. package/template/src/uni_modules/uview-plus/components/u-steps/u-steps.vue +94 -0
  284. package/template/src/uni_modules/uview-plus/components/u-steps-item/props.js +31 -0
  285. package/template/src/uni_modules/uview-plus/components/u-steps-item/stepsItem.js +18 -0
  286. package/template/src/uni_modules/uview-plus/components/u-steps-item/u-steps-item.vue +342 -0
  287. package/template/src/uni_modules/uview-plus/components/u-sticky/props.js +42 -0
  288. package/template/src/uni_modules/uview-plus/components/u-sticky/sticky.js +20 -0
  289. package/template/src/uni_modules/uview-plus/components/u-sticky/u-sticky.vue +221 -0
  290. package/template/src/uni_modules/uview-plus/components/u-subsection/props.js +67 -0
  291. package/template/src/uni_modules/uview-plus/components/u-subsection/subsection.js +26 -0
  292. package/template/src/uni_modules/uview-plus/components/u-subsection/u-subsection.vue +401 -0
  293. package/template/src/uni_modules/uview-plus/components/u-swipe-action/props.js +16 -0
  294. package/template/src/uni_modules/uview-plus/components/u-swipe-action/swipeAction.js +15 -0
  295. package/template/src/uni_modules/uview-plus/components/u-swipe-action/u-swipe-action.vue +84 -0
  296. package/template/src/uni_modules/uview-plus/components/u-swipe-action-item/alipay.sjs +229 -0
  297. package/template/src/uni_modules/uview-plus/components/u-swipe-action-item/index - backup.wxs +256 -0
  298. package/template/src/uni_modules/uview-plus/components/u-swipe-action-item/index.wxs +234 -0
  299. package/template/src/uni_modules/uview-plus/components/u-swipe-action-item/nvue - backup.js +270 -0
  300. package/template/src/uni_modules/uview-plus/components/u-swipe-action-item/nvue.js +174 -0
  301. package/template/src/uni_modules/uview-plus/components/u-swipe-action-item/other.js +178 -0
  302. package/template/src/uni_modules/uview-plus/components/u-swipe-action-item/props.js +47 -0
  303. package/template/src/uni_modules/uview-plus/components/u-swipe-action-item/swipeActionItem.js +22 -0
  304. package/template/src/uni_modules/uview-plus/components/u-swipe-action-item/u-swipe-action-item.vue +249 -0
  305. package/template/src/uni_modules/uview-plus/components/u-swipe-action-item/wxs.js +15 -0
  306. package/template/src/uni_modules/uview-plus/components/u-swiper/props.js +127 -0
  307. package/template/src/uni_modules/uview-plus/components/u-swiper/swiper.js +39 -0
  308. package/template/src/uni_modules/uview-plus/components/u-swiper/u-swiper.vue +269 -0
  309. package/template/src/uni_modules/uview-plus/components/u-swiper-indicator/props.js +31 -0
  310. package/template/src/uni_modules/uview-plus/components/u-swiper-indicator/swipterIndicator.js +19 -0
  311. package/template/src/uni_modules/uview-plus/components/u-swiper-indicator/u-swiper-indicator.vue +114 -0
  312. package/template/src/uni_modules/uview-plus/components/u-switch/props.js +64 -0
  313. package/template/src/uni_modules/uview-plus/components/u-switch/switch.js +24 -0
  314. package/template/src/uni_modules/uview-plus/components/u-switch/u-switch.vue +215 -0
  315. package/template/src/uni_modules/uview-plus/components/u-tabbar/props.js +47 -0
  316. package/template/src/uni_modules/uview-plus/components/u-tabbar/tabbar.js +22 -0
  317. package/template/src/uni_modules/uview-plus/components/u-tabbar/u-tabbar.vue +144 -0
  318. package/template/src/uni_modules/uview-plus/components/u-tabbar-item/props.js +37 -0
  319. package/template/src/uni_modules/uview-plus/components/u-tabbar-item/tabbarItem.js +20 -0
  320. package/template/src/uni_modules/uview-plus/components/u-tabbar-item/u-tabbar-item.vue +157 -0
  321. package/template/src/uni_modules/uview-plus/components/u-table/props.js +7 -0
  322. package/template/src/uni_modules/uview-plus/components/u-table/u-table.vue +104 -0
  323. package/template/src/uni_modules/uview-plus/components/u-table2/u-table2.vue +517 -0
  324. package/template/src/uni_modules/uview-plus/components/u-tabs/props.js +71 -0
  325. package/template/src/uni_modules/uview-plus/components/u-tabs/tabs.js +33 -0
  326. package/template/src/uni_modules/uview-plus/components/u-tabs/u-tabs.vue +411 -0
  327. package/template/src/uni_modules/uview-plus/components/u-tabs-item/props.js +7 -0
  328. package/template/src/uni_modules/uview-plus/components/u-tabs-item/u-tabs-item.vue +31 -0
  329. package/template/src/uni_modules/uview-plus/components/u-tag/props.js +116 -0
  330. package/template/src/uni_modules/uview-plus/components/u-tag/tag.js +35 -0
  331. package/template/src/uni_modules/uview-plus/components/u-tag/u-tag.vue +402 -0
  332. package/template/src/uni_modules/uview-plus/components/u-td/props.js +7 -0
  333. package/template/src/uni_modules/uview-plus/components/u-td/u-td.vue +98 -0
  334. package/template/src/uni_modules/uview-plus/components/u-text/props.js +117 -0
  335. package/template/src/uni_modules/uview-plus/components/u-text/text.js +39 -0
  336. package/template/src/uni_modules/uview-plus/components/u-text/u-text.vue +234 -0
  337. package/template/src/uni_modules/uview-plus/components/u-text/value.js +87 -0
  338. package/template/src/uni_modules/uview-plus/components/u-textarea/props.js +127 -0
  339. package/template/src/uni_modules/uview-plus/components/u-textarea/textarea.js +36 -0
  340. package/template/src/uni_modules/uview-plus/components/u-textarea/u-textarea.vue +285 -0
  341. package/template/src/uni_modules/uview-plus/components/u-th/props.js +7 -0
  342. package/template/src/uni_modules/uview-plus/components/u-th/u-th.vue +66 -0
  343. package/template/src/uni_modules/uview-plus/components/u-title/u-title.vue +36 -0
  344. package/template/src/uni_modules/uview-plus/components/u-toast/toast.js +30 -0
  345. package/template/src/uni_modules/uview-plus/components/u-toast/u-toast.vue +304 -0
  346. package/template/src/uni_modules/uview-plus/components/u-toolbar/props.js +41 -0
  347. package/template/src/uni_modules/uview-plus/components/u-toolbar/toolbar.js +21 -0
  348. package/template/src/uni_modules/uview-plus/components/u-toolbar/u-toolbar.vue +125 -0
  349. package/template/src/uni_modules/uview-plus/components/u-tooltip/props.js +61 -0
  350. package/template/src/uni_modules/uview-plus/components/u-tooltip/tooltip.js +25 -0
  351. package/template/src/uni_modules/uview-plus/components/u-tooltip/u-tooltip.vue +341 -0
  352. package/template/src/uni_modules/uview-plus/components/u-tr/props.js +7 -0
  353. package/template/src/uni_modules/uview-plus/components/u-tr/u-tr.vue +34 -0
  354. package/template/src/uni_modules/uview-plus/components/u-transition/nvue-ani-map.js +68 -0
  355. package/template/src/uni_modules/uview-plus/components/u-transition/props.js +26 -0
  356. package/template/src/uni_modules/uview-plus/components/u-transition/transition.js +18 -0
  357. package/template/src/uni_modules/uview-plus/components/u-transition/transitionMixin.js +163 -0
  358. package/template/src/uni_modules/uview-plus/components/u-transition/u-transition.vue +207 -0
  359. package/template/src/uni_modules/uview-plus/components/u-transition/vue.ani-style.scss +113 -0
  360. package/template/src/uni_modules/uview-plus/components/u-tree/tree-node.vue +128 -0
  361. package/template/src/uni_modules/uview-plus/components/u-tree/u-tree.vue +117 -0
  362. package/template/src/uni_modules/uview-plus/components/u-upload/mixin.js +23 -0
  363. package/template/src/uni_modules/uview-plus/components/u-upload/props.js +176 -0
  364. package/template/src/uni_modules/uview-plus/components/u-upload/u-upload.vue +925 -0
  365. package/template/src/uni_modules/uview-plus/components/u-upload/upload.js +46 -0
  366. package/template/src/uni_modules/uview-plus/components/u-upload/utils.js +184 -0
  367. package/template/src/uni_modules/uview-plus/components/u-view/u-view.vue +71 -0
  368. package/template/src/uni_modules/uview-plus/components/u-waterfall/u-waterfall.vue +244 -0
  369. package/template/src/uni_modules/uview-plus/components/uview-plus/uview-plus.vue +15 -0
  370. package/template/src/uni_modules/uview-plus/index.js +154 -0
  371. package/template/src/uni_modules/uview-plus/index.scss +25 -0
  372. package/template/src/uni_modules/uview-plus/libs/config/color.js +17 -0
  373. package/template/src/uni_modules/uview-plus/libs/config/config.js +54 -0
  374. package/template/src/uni_modules/uview-plus/libs/config/props.js +216 -0
  375. package/template/src/uni_modules/uview-plus/libs/config/zIndex.js +20 -0
  376. package/template/src/uni_modules/uview-plus/libs/css/color.scss +311 -0
  377. package/template/src/uni_modules/uview-plus/libs/css/common.scss +112 -0
  378. package/template/src/uni_modules/uview-plus/libs/css/components.scss +34 -0
  379. package/template/src/uni_modules/uview-plus/libs/css/flex.scss +368 -0
  380. package/template/src/uni_modules/uview-plus/libs/css/h5.scss +0 -0
  381. package/template/src/uni_modules/uview-plus/libs/css/mixin.scss +8 -0
  382. package/template/src/uni_modules/uview-plus/libs/css/mp.scss +0 -0
  383. package/template/src/uni_modules/uview-plus/libs/css/nvue.scss +0 -0
  384. package/template/src/uni_modules/uview-plus/libs/css/vue.scss +28 -0
  385. package/template/src/uni_modules/uview-plus/libs/function/calc.js +64 -0
  386. package/template/src/uni_modules/uview-plus/libs/function/colorGradient.js +134 -0
  387. package/template/src/uni_modules/uview-plus/libs/function/debounce.js +29 -0
  388. package/template/src/uni_modules/uview-plus/libs/function/digit.js +167 -0
  389. package/template/src/uni_modules/uview-plus/libs/function/http.js +4 -0
  390. package/template/src/uni_modules/uview-plus/libs/function/index.js +853 -0
  391. package/template/src/uni_modules/uview-plus/libs/function/platform.js +75 -0
  392. package/template/src/uni_modules/uview-plus/libs/function/test.js +327 -0
  393. package/template/src/uni_modules/uview-plus/libs/function/throttle.js +30 -0
  394. package/template/src/uni_modules/uview-plus/libs/luch-request/adapters/index.js +97 -0
  395. package/template/src/uni_modules/uview-plus/libs/luch-request/core/InterceptorManager.js +50 -0
  396. package/template/src/uni_modules/uview-plus/libs/luch-request/core/Request.js +199 -0
  397. package/template/src/uni_modules/uview-plus/libs/luch-request/core/buildFullPath.js +20 -0
  398. package/template/src/uni_modules/uview-plus/libs/luch-request/core/defaults.js +29 -0
  399. package/template/src/uni_modules/uview-plus/libs/luch-request/core/dispatchRequest.js +3 -0
  400. package/template/src/uni_modules/uview-plus/libs/luch-request/core/mergeConfig.js +103 -0
  401. package/template/src/uni_modules/uview-plus/libs/luch-request/core/settle.js +16 -0
  402. package/template/src/uni_modules/uview-plus/libs/luch-request/helpers/buildURL.js +69 -0
  403. package/template/src/uni_modules/uview-plus/libs/luch-request/helpers/combineURLs.js +14 -0
  404. package/template/src/uni_modules/uview-plus/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
  405. package/template/src/uni_modules/uview-plus/libs/luch-request/index.d.ts +116 -0
  406. package/template/src/uni_modules/uview-plus/libs/luch-request/index.js +3 -0
  407. package/template/src/uni_modules/uview-plus/libs/luch-request/utils/clone.js +264 -0
  408. package/template/src/uni_modules/uview-plus/libs/luch-request/utils.js +131 -0
  409. package/template/src/uni_modules/uview-plus/libs/mixin/button.js +18 -0
  410. package/template/src/uni_modules/uview-plus/libs/mixin/mixin.js +201 -0
  411. package/template/src/uni_modules/uview-plus/libs/mixin/mpMixin.js +13 -0
  412. package/template/src/uni_modules/uview-plus/libs/mixin/mpShare.js +26 -0
  413. package/template/src/uni_modules/uview-plus/libs/mixin/openType.js +27 -0
  414. package/template/src/uni_modules/uview-plus/libs/mixin/style.js +249 -0
  415. package/template/src/uni_modules/uview-plus/libs/mixin/touch.js +61 -0
  416. package/template/src/uni_modules/uview-plus/libs/util/async-validator.js +1343 -0
  417. package/template/src/uni_modules/uview-plus/libs/util/calendar.js +546 -0
  418. package/template/src/uni_modules/uview-plus/libs/util/emitter.js +51 -0
  419. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/bridge/bridge-weex.js +241 -0
  420. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
  421. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-2d/FillStylePattern.js +8 -0
  422. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
  423. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-2d/RenderingContext.js +666 -0
  424. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/ActiveInfo.js +11 -0
  425. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/Buffer.js +21 -0
  426. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/Framebuffer.js +21 -0
  427. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/GLenum.js +298 -0
  428. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/GLmethod.js +142 -0
  429. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/GLtype.js +23 -0
  430. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/Program.js +21 -0
  431. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/Renderbuffer.js +21 -0
  432. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/RenderingContext.js +1191 -0
  433. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/Shader.js +22 -0
  434. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
  435. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/Texture.js +22 -0
  436. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/UniformLocation.js +22 -0
  437. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/context-webgl/classUtils.js +3 -0
  438. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/env/canvas.js +74 -0
  439. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/env/image.js +96 -0
  440. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/env/tool.js +24 -0
  441. package/template/src/uni_modules/uview-plus/libs/util/gcanvas/index.js +39 -0
  442. package/template/src/uni_modules/uview-plus/libs/util/route.js +124 -0
  443. package/template/src/uni_modules/uview-plus/libs/vue.js +3 -0
  444. package/template/src/uni_modules/uview-plus/package.json +113 -0
  445. package/template/src/uni_modules/uview-plus/theme.scss +44 -0
  446. package/template/src/uni_modules/uview-plus/types/comps/_common.d.ts +9 -0
  447. package/template/src/uni_modules/uview-plus/types/comps/actionSheet.d.ts +121 -0
  448. package/template/src/uni_modules/uview-plus/types/comps/album.d.ts +82 -0
  449. package/template/src/uni_modules/uview-plus/types/comps/alert.d.ts +55 -0
  450. package/template/src/uni_modules/uview-plus/types/comps/avatar.d.ts +85 -0
  451. package/template/src/uni_modules/uview-plus/types/comps/avatarGroup.d.ts +62 -0
  452. package/template/src/uni_modules/uview-plus/types/comps/backTop.d.ts +74 -0
  453. package/template/src/uni_modules/uview-plus/types/comps/badge.d.ts +76 -0
  454. package/template/src/uni_modules/uview-plus/types/comps/button.d.ts +169 -0
  455. package/template/src/uni_modules/uview-plus/types/comps/calendar.d.ts +164 -0
  456. package/template/src/uni_modules/uview-plus/types/comps/cell.d.ts +133 -0
  457. package/template/src/uni_modules/uview-plus/types/comps/cellGroup.d.ts +27 -0
  458. package/template/src/uni_modules/uview-plus/types/comps/checkbox.d.ts +69 -0
  459. package/template/src/uni_modules/uview-plus/types/comps/checkboxGroup.d.ts +93 -0
  460. package/template/src/uni_modules/uview-plus/types/comps/code.d.ts +69 -0
  461. package/template/src/uni_modules/uview-plus/types/comps/codeInput.d.ts +98 -0
  462. package/template/src/uni_modules/uview-plus/types/comps/col.d.ts +43 -0
  463. package/template/src/uni_modules/uview-plus/types/comps/collapse.d.ts +52 -0
  464. package/template/src/uni_modules/uview-plus/types/comps/collapseItem.d.ts +83 -0
  465. package/template/src/uni_modules/uview-plus/types/comps/countDown.d.ts +60 -0
  466. package/template/src/uni_modules/uview-plus/types/comps/countTo.d.ts +88 -0
  467. package/template/src/uni_modules/uview-plus/types/comps/datetimePicker.d.ts +146 -0
  468. package/template/src/uni_modules/uview-plus/types/comps/divider.d.ts +58 -0
  469. package/template/src/uni_modules/uview-plus/types/comps/empty.d.ts +72 -0
  470. package/template/src/uni_modules/uview-plus/types/comps/form.d.ts +76 -0
  471. package/template/src/uni_modules/uview-plus/types/comps/formItem.d.ts +68 -0
  472. package/template/src/uni_modules/uview-plus/types/comps/gap.d.ts +35 -0
  473. package/template/src/uni_modules/uview-plus/types/comps/grid.d.ts +34 -0
  474. package/template/src/uni_modules/uview-plus/types/comps/gridItem.d.ts +28 -0
  475. package/template/src/uni_modules/uview-plus/types/comps/icon.d.ts +93 -0
  476. package/template/src/uni_modules/uview-plus/types/comps/image.d.ts +119 -0
  477. package/template/src/uni_modules/uview-plus/types/comps/indexAnchor.d.ts +38 -0
  478. package/template/src/uni_modules/uview-plus/types/comps/indexItem.d.ts +18 -0
  479. package/template/src/uni_modules/uview-plus/types/comps/indexList.d.ts +39 -0
  480. package/template/src/uni_modules/uview-plus/types/comps/input.d.ts +234 -0
  481. package/template/src/uni_modules/uview-plus/types/comps/keyboard.d.ts +125 -0
  482. package/template/src/uni_modules/uview-plus/types/comps/line.d.ts +44 -0
  483. package/template/src/uni_modules/uview-plus/types/comps/lineProgress.d.ts +51 -0
  484. package/template/src/uni_modules/uview-plus/types/comps/link.d.ts +51 -0
  485. package/template/src/uni_modules/uview-plus/types/comps/list.d.ts +92 -0
  486. package/template/src/uni_modules/uview-plus/types/comps/listItem.d.ts +18 -0
  487. package/template/src/uni_modules/uview-plus/types/comps/loadMore.d.ts +108 -0
  488. package/template/src/uni_modules/uview-plus/types/comps/loadingIcon.d.ts +68 -0
  489. package/template/src/uni_modules/uview-plus/types/comps/loadingPage.d.ts +58 -0
  490. package/template/src/uni_modules/uview-plus/types/comps/modal.d.ts +115 -0
  491. package/template/src/uni_modules/uview-plus/types/comps/navbar.d.ts +118 -0
  492. package/template/src/uni_modules/uview-plus/types/comps/noNetwork.d.ts +40 -0
  493. package/template/src/uni_modules/uview-plus/types/comps/noticeBar.d.ts +85 -0
  494. package/template/src/uni_modules/uview-plus/types/comps/notify.d.ts +73 -0
  495. package/template/src/uni_modules/uview-plus/types/comps/numberBox.d.ts +155 -0
  496. package/template/src/uni_modules/uview-plus/types/comps/overlay.d.ts +46 -0
  497. package/template/src/uni_modules/uview-plus/types/comps/parse.d.ts +101 -0
  498. package/template/src/uni_modules/uview-plus/types/comps/picker.d.ts +115 -0
  499. package/template/src/uni_modules/uview-plus/types/comps/popup.d.ts +103 -0
  500. package/template/src/uni_modules/uview-plus/types/comps/qrcode.d.ts +77 -0
  501. package/template/src/uni_modules/uview-plus/types/comps/radio.d.ts +77 -0
  502. package/template/src/uni_modules/uview-plus/types/comps/radioGroup.d.ts +97 -0
  503. package/template/src/uni_modules/uview-plus/types/comps/rate.d.ts +85 -0
  504. package/template/src/uni_modules/uview-plus/types/comps/readMore.d.ts +80 -0
  505. package/template/src/uni_modules/uview-plus/types/comps/row.d.ts +34 -0
  506. package/template/src/uni_modules/uview-plus/types/comps/safeBottom.d.ts +16 -0
  507. package/template/src/uni_modules/uview-plus/types/comps/scrollList.d.ts +51 -0
  508. package/template/src/uni_modules/uview-plus/types/comps/search.d.ts +180 -0
  509. package/template/src/uni_modules/uview-plus/types/comps/skeleton.d.ts +70 -0
  510. package/template/src/uni_modules/uview-plus/types/comps/slider.d.ts +79 -0
  511. package/template/src/uni_modules/uview-plus/types/comps/statusBar.d.ts +22 -0
  512. package/template/src/uni_modules/uview-plus/types/comps/steps.d.ts +48 -0
  513. package/template/src/uni_modules/uview-plus/types/comps/stepsItem.d.ts +41 -0
  514. package/template/src/uni_modules/uview-plus/types/comps/sticky.d.ts +48 -0
  515. package/template/src/uni_modules/uview-plus/types/comps/subsection.d.ts +80 -0
  516. package/template/src/uni_modules/uview-plus/types/comps/swipeAction.d.ts +24 -0
  517. package/template/src/uni_modules/uview-plus/types/comps/swipeActionItem.d.ts +58 -0
  518. package/template/src/uni_modules/uview-plus/types/comps/swiper.d.ts +142 -0
  519. package/template/src/uni_modules/uview-plus/types/comps/swiperIndicator.d.ts +37 -0
  520. package/template/src/uni_modules/uview-plus/types/comps/switch.d.ts +73 -0
  521. package/template/src/uni_modules/uview-plus/types/comps/tabbar.d.ts +54 -0
  522. package/template/src/uni_modules/uview-plus/types/comps/tabbarItem.d.ts +52 -0
  523. package/template/src/uni_modules/uview-plus/types/comps/tabs.d.ts +85 -0
  524. package/template/src/uni_modules/uview-plus/types/comps/tag.d.ts +93 -0
  525. package/template/src/uni_modules/uview-plus/types/comps/text.d.ts +110 -0
  526. package/template/src/uni_modules/uview-plus/types/comps/textarea.d.ts +158 -0
  527. package/template/src/uni_modules/uview-plus/types/comps/toast.d.ts +63 -0
  528. package/template/src/uni_modules/uview-plus/types/comps/tooltip.d.ts +71 -0
  529. package/template/src/uni_modules/uview-plus/types/comps/transition.d.ts +61 -0
  530. package/template/src/uni_modules/uview-plus/types/comps/upload.d.ts +204 -0
  531. package/template/src/uni_modules/uview-plus/types/comps.d.ts +102 -0
  532. package/template/src/uni_modules/uview-plus/types/index.d.ts +172 -0
  533. package/template/src/uni_modules/uview-plus/types/package.json +26 -0
  534. package/template/src/utils/request.ts +3 -0
  535. package/template/src/uview-plus.d.ts +2 -0
  536. package/template/tailwind.config.ts +15 -0
  537. package/template/tsconfig.json +26 -0
  538. package/template/vite.config.ts +45 -0
@@ -0,0 +1,1400 @@
1
+ /**
2
+ * @fileoverview html 解析器
3
+ */
4
+
5
+ // 配置
6
+ const config = {
7
+ // 信任的标签(保持标签名不变)
8
+ trustTags: makeMap('a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,ruby,rt,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video'),
9
+
10
+ // 块级标签(转为 div,其他的非信任标签转为 span)
11
+ blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,pre,section'),
12
+
13
+ // #ifdef (MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE3
14
+ // 行内标签
15
+ inlineTags: makeMap('abbr,b,big,code,del,em,i,ins,label,q,small,span,strong,sub,sup'),
16
+ // #endif
17
+
18
+ // 要移除的标签
19
+ ignoreTags: makeMap('area,base,canvas,embed,frame,head,iframe,input,link,map,meta,param,rp,script,source,style,textarea,title,track,wbr'),
20
+
21
+ // 自闭合的标签
22
+ voidTags: makeMap('area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr'),
23
+
24
+ // html 实体
25
+ entities: {
26
+ lt: '<',
27
+ gt: '>',
28
+ quot: '"',
29
+ apos: "'",
30
+ ensp: '\u2002',
31
+ emsp: '\u2003',
32
+ nbsp: '\xA0',
33
+ semi: ';',
34
+ ndash: '–',
35
+ mdash: '—',
36
+ middot: '·',
37
+ lsquo: '‘',
38
+ rsquo: '’',
39
+ ldquo: '“',
40
+ rdquo: '”',
41
+ bull: '•',
42
+ hellip: '…',
43
+ larr: '←',
44
+ uarr: '↑',
45
+ rarr: '→',
46
+ darr: '↓'
47
+ },
48
+
49
+ // 默认的标签样式
50
+ tagStyle: {
51
+ // #ifndef APP-PLUS-NVUE
52
+ address: 'font-style:italic',
53
+ big: 'display:inline;font-size:1.2em',
54
+ caption: 'display:table-caption;text-align:center',
55
+ center: 'text-align:center',
56
+ cite: 'font-style:italic',
57
+ dd: 'margin-left:40px',
58
+ mark: 'background-color:yellow',
59
+ pre: 'font-family:monospace;white-space:pre',
60
+ s: 'text-decoration:line-through',
61
+ small: 'display:inline;font-size:0.8em',
62
+ strike: 'text-decoration:line-through',
63
+ u: 'text-decoration:underline'
64
+ // #endif
65
+ },
66
+
67
+ // svg 大小写对照表
68
+ svgDict: {
69
+ animatetransform: 'animateTransform',
70
+ lineargradient: 'linearGradient',
71
+ viewbox: 'viewBox',
72
+ attributename: 'attributeName',
73
+ repeatcount: 'repeatCount',
74
+ repeatdur: 'repeatDur',
75
+ foreignobject: 'foreignObject'
76
+ }
77
+ }
78
+ const tagSelector = {}
79
+ let windowWidth, system
80
+ // #ifdef MP-WEIXIN
81
+ if (uni.canIUse('getWindowInfo')) {
82
+ windowWidth = uni.getWindowInfo().windowWidth
83
+ system = uni.getDeviceInfo().system
84
+ } else {
85
+ // #endif
86
+ const systemInfo = uni.getSystemInfoSync()
87
+ windowWidth = systemInfo.windowWidth
88
+ // #ifdef MP-WEIXIN
89
+ system = systemInfo.system
90
+ }
91
+ // #endif
92
+ const blankChar = makeMap(' ,\r,\n,\t,\f')
93
+ let idIndex = 0
94
+
95
+ // #ifdef H5 || APP-PLUS
96
+ config.ignoreTags.iframe = undefined
97
+ config.trustTags.iframe = true
98
+ config.ignoreTags.embed = undefined
99
+ config.trustTags.embed = true
100
+ // #endif
101
+ // #ifdef APP-PLUS-NVUE
102
+ config.ignoreTags.source = undefined
103
+ config.ignoreTags.style = undefined
104
+ // #endif
105
+
106
+ /**
107
+ * @description 创建 map
108
+ * @param {String} str 逗号分隔
109
+ */
110
+ function makeMap (str) {
111
+ const map = Object.create(null)
112
+ const list = str.split(',')
113
+ for (let i = list.length; i--;) {
114
+ map[list[i]] = true
115
+ }
116
+ return map
117
+ }
118
+
119
+ /**
120
+ * @description 解码 html 实体
121
+ * @param {String} str 要解码的字符串
122
+ * @param {Boolean} amp 要不要解码 &amp;
123
+ * @returns {String} 解码后的字符串
124
+ */
125
+ function decodeEntity (str, amp) {
126
+ let i = str.indexOf('&')
127
+ while (i !== -1) {
128
+ const j = str.indexOf(';', i + 3)
129
+ let code
130
+ if (j === -1) break
131
+ if (str[i + 1] === '#') {
132
+ // &#123; 形式的实体
133
+ code = parseInt((str[i + 2] === 'x' ? '0' : '') + str.substring(i + 2, j))
134
+ if (!isNaN(code)) {
135
+ str = str.substr(0, i) + String.fromCharCode(code) + str.substr(j + 1)
136
+ }
137
+ } else {
138
+ // &nbsp; 形式的实体
139
+ code = str.substring(i + 1, j)
140
+ if (config.entities[code] || (code === 'amp' && amp)) {
141
+ str = str.substr(0, i) + (config.entities[code] || '&') + str.substr(j + 1)
142
+ }
143
+ }
144
+ i = str.indexOf('&', i + 1)
145
+ }
146
+ return str
147
+ }
148
+
149
+ /**
150
+ * @description 合并多个块级标签,加快长内容渲染
151
+ * @param {Array} nodes 要合并的标签数组
152
+ */
153
+ function mergeNodes (nodes) {
154
+ let i = nodes.length - 1
155
+ for (let j = i; j >= -1; j--) {
156
+ if (j === -1 || nodes[j].c || !nodes[j].name || (nodes[j].name !== 'div' && nodes[j].name !== 'p' && nodes[j].name[0] !== 'h') || (nodes[j].attrs.style || '').includes('inline')) {
157
+ if (i - j >= 5) {
158
+ nodes.splice(j + 1, i - j, {
159
+ name: 'div',
160
+ attrs: {},
161
+ children: nodes.slice(j + 1, i + 1)
162
+ })
163
+ }
164
+ i = j - 1
165
+ }
166
+ }
167
+ }
168
+
169
+ /**
170
+ * @description html 解析器
171
+ * @param {Object} vm 组件实例
172
+ */
173
+ function Parser (vm) {
174
+ this.options = vm || {}
175
+ this.tagStyle = Object.assign({}, config.tagStyle, this.options.tagStyle)
176
+ this.imgList = vm.imgList || []
177
+ this.imgList._unloadimgs = 0
178
+ this.plugins = vm.plugins || []
179
+ this.attrs = Object.create(null)
180
+ this.stack = []
181
+ this.nodes = []
182
+ this.pre = (this.options.containerStyle || '').includes('white-space') && this.options.containerStyle.includes('pre') ? 2 : 0
183
+ }
184
+
185
+ /**
186
+ * @description 执行解析
187
+ * @param {String} content 要解析的文本
188
+ */
189
+ Parser.prototype.parse = function (content) {
190
+ // 插件处理
191
+ for (let i = this.plugins.length; i--;) {
192
+ if (this.plugins[i].onUpdate) {
193
+ content = this.plugins[i].onUpdate(content, config) || content
194
+ }
195
+ }
196
+
197
+ new Lexer(this).parse(content)
198
+ // 出栈未闭合的标签
199
+ while (this.stack.length) {
200
+ this.popNode()
201
+ }
202
+ if (this.nodes.length > 50) {
203
+ mergeNodes(this.nodes)
204
+ }
205
+ return this.nodes
206
+ }
207
+
208
+ /**
209
+ * @description 将标签暴露出来(不被 rich-text 包含)
210
+ */
211
+ Parser.prototype.expose = function () {
212
+ // #ifndef APP-PLUS-NVUE
213
+ for (let i = this.stack.length; i--;) {
214
+ const item = this.stack[i]
215
+ if (item.c || item.name === 'a' || item.name === 'video' || item.name === 'audio') return
216
+ item.c = 1
217
+ }
218
+ // #endif
219
+ }
220
+
221
+ /**
222
+ * @description 处理插件
223
+ * @param {Object} node 要处理的标签
224
+ * @returns {Boolean} 是否要移除此标签
225
+ */
226
+ Parser.prototype.hook = function (node) {
227
+ for (let i = this.plugins.length; i--;) {
228
+ if (this.plugins[i].onParse && this.plugins[i].onParse(node, this) === false) {
229
+ return false
230
+ }
231
+ }
232
+ return true
233
+ }
234
+
235
+ /**
236
+ * @description 将链接拼接上主域名
237
+ * @param {String} url 需要拼接的链接
238
+ * @returns {String} 拼接后的链接
239
+ */
240
+ Parser.prototype.getUrl = function (url) {
241
+ const domain = this.options.domain
242
+ if (url[0] === '/') {
243
+ if (url[1] === '/') {
244
+ // // 开头的补充协议名
245
+ url = (domain ? domain.split('://')[0] : 'http') + ':' + url
246
+ } else if (domain) {
247
+ // 否则补充整个域名
248
+ url = domain + url
249
+ } /* #ifdef APP-PLUS */ else {
250
+ url = plus.io.convertLocalFileSystemURL(url)
251
+ } /* #endif */
252
+ } else if (!url.includes('data:') && !url.includes('://')) {
253
+ if (domain) {
254
+ url = domain + '/' + url
255
+ } /* #ifdef APP-PLUS */ else {
256
+ url = plus.io.convertLocalFileSystemURL(url)
257
+ } /* #endif */
258
+ }
259
+ return url
260
+ }
261
+
262
+ /**
263
+ * @description 解析样式表
264
+ * @param {Object} node 标签
265
+ * @returns {Object}
266
+ */
267
+ Parser.prototype.parseStyle = function (node) {
268
+ const attrs = node.attrs
269
+ const list = (this.tagStyle[node.name] || '').split(';').concat((attrs.style || '').split(';'))
270
+ const styleObj = {}
271
+ let tmp = ''
272
+
273
+ if (attrs.id && !this.xml) {
274
+ // 暴露锚点
275
+ if (this.options.useAnchor) {
276
+ this.expose()
277
+ } else if (node.name !== 'img' && node.name !== 'a' && node.name !== 'video' && node.name !== 'audio') {
278
+ attrs.id = undefined
279
+ }
280
+ }
281
+
282
+ // 转换 width 和 height 属性
283
+ if (attrs.width) {
284
+ styleObj.width = parseFloat(attrs.width) + (attrs.width.includes('%') ? '%' : 'px')
285
+ attrs.width = undefined
286
+ }
287
+ if (attrs.height) {
288
+ styleObj.height = parseFloat(attrs.height) + (attrs.height.includes('%') ? '%' : 'px')
289
+ attrs.height = undefined
290
+ }
291
+
292
+ for (let i = 0, len = list.length; i < len; i++) {
293
+ const info = list[i].split(':')
294
+ if (info.length < 2) continue
295
+ const key = info.shift().trim().toLowerCase()
296
+ let value = info.join(':').trim()
297
+ if ((value[0] === '-' && value.lastIndexOf('-') > 0) || value.includes('safe')) {
298
+ // 兼容性的 css 不压缩
299
+ tmp += `;${key}:${value}`
300
+ } else if (!styleObj[key] || value.includes('import') || !styleObj[key].includes('import')) {
301
+ // 重复的样式进行覆盖
302
+ if (value.includes('url')) {
303
+ // 填充链接
304
+ let j = value.indexOf('(') + 1
305
+ if (j) {
306
+ while (value[j] === '"' || value[j] === "'" || blankChar[value[j]]) {
307
+ j++
308
+ }
309
+ value = value.substr(0, j) + this.getUrl(value.substr(j))
310
+ }
311
+ } else if (value.includes('rpx')) {
312
+ // 转换 rpx(rich-text 内部不支持 rpx)
313
+ value = value.replace(/[0-9.]+\s*rpx/g, $ => parseFloat($) * windowWidth / 750 + 'px')
314
+ }
315
+ styleObj[key] = value
316
+ }
317
+ }
318
+
319
+ node.attrs.style = tmp
320
+ return styleObj
321
+ }
322
+
323
+ /**
324
+ * @description 解析到标签名
325
+ * @param {String} name 标签名
326
+ * @private
327
+ */
328
+ Parser.prototype.onTagName = function (name) {
329
+ this.tagName = this.xml ? name : name.toLowerCase()
330
+ if (this.tagName === 'svg') {
331
+ this.xml = (this.xml || 0) + 1 // svg 标签内大小写敏感
332
+ config.ignoreTags.style = undefined // svg 标签内 style 可用
333
+ }
334
+ }
335
+
336
+ /**
337
+ * @description 解析到属性名
338
+ * @param {String} name 属性名
339
+ * @private
340
+ */
341
+ Parser.prototype.onAttrName = function (name) {
342
+ name = this.xml ? name : name.toLowerCase()
343
+ // #ifdef (VUE3 && (H5 || APP-PLUS)) || APP-PLUS-NVUE
344
+ if (name.includes('?') || name.includes(';')) {
345
+ this.attrName = undefined
346
+ return
347
+ }
348
+ // #endif
349
+ if (name.substr(0, 5) === 'data-') {
350
+ if (name === 'data-src' && !this.attrs.src) {
351
+ // data-src 自动转为 src
352
+ this.attrName = 'src'
353
+ } else if (this.tagName === 'img' || this.tagName === 'a') {
354
+ // a 和 img 标签保留 data- 的属性,可以在 imgtap 和 linktap 事件中使用
355
+ this.attrName = name
356
+ } else {
357
+ // 剩余的移除以减小大小
358
+ this.attrName = undefined
359
+ }
360
+ } else {
361
+ this.attrName = name
362
+ this.attrs[name] = 'T' // boolean 型属性缺省设置
363
+ }
364
+ }
365
+
366
+ /**
367
+ * @description 解析到属性值
368
+ * @param {String} val 属性值
369
+ * @private
370
+ */
371
+ Parser.prototype.onAttrVal = function (val) {
372
+ const name = this.attrName || ''
373
+ if (name === 'style' || name === 'href') {
374
+ // 部分属性进行实体解码
375
+ this.attrs[name] = decodeEntity(val, true)
376
+ } else if (name.includes('src')) {
377
+ // 拼接主域名
378
+ this.attrs[name] = this.getUrl(decodeEntity(val, true))
379
+ } else if (name) {
380
+ this.attrs[name] = val
381
+ }
382
+ }
383
+
384
+ /**
385
+ * @description 解析到标签开始
386
+ * @param {Boolean} selfClose 是否有自闭合标识 />
387
+ * @private
388
+ */
389
+ Parser.prototype.onOpenTag = function (selfClose) {
390
+ // 拼装 node
391
+ const node = Object.create(null)
392
+ node.name = this.tagName
393
+ node.attrs = this.attrs
394
+ // 避免因为自动 diff 使得 type 被设置为 null 导致部分内容不显示
395
+ if (this.options.nodes.length) {
396
+ node.type = 'node'
397
+ }
398
+ this.attrs = Object.create(null)
399
+
400
+ const attrs = node.attrs
401
+ const parent = this.stack[this.stack.length - 1]
402
+ const siblings = parent ? parent.children : this.nodes
403
+ const close = this.xml ? selfClose : config.voidTags[node.name]
404
+
405
+ // 替换标签名选择器
406
+ if (tagSelector[node.name]) {
407
+ attrs.class = tagSelector[node.name] + (attrs.class ? ' ' + attrs.class : '')
408
+ }
409
+
410
+ // 转换 embed 标签
411
+ if (node.name === 'embed') {
412
+ // #ifndef H5 || APP-PLUS
413
+ const src = attrs.src || ''
414
+ // 按照后缀名和 type 将 embed 转为 video 或 audio
415
+ if (src.includes('.mp4') || src.includes('.3gp') || src.includes('.m3u8') || (attrs.type || '').includes('video')) {
416
+ node.name = 'video'
417
+ } else if (src.includes('.mp3') || src.includes('.wav') || src.includes('.aac') || src.includes('.m4a') || (attrs.type || '').includes('audio')) {
418
+ node.name = 'audio'
419
+ }
420
+ if (attrs.autostart) {
421
+ attrs.autoplay = 'T'
422
+ }
423
+ attrs.controls = 'T'
424
+ // #endif
425
+ // #ifdef H5 || APP-PLUS
426
+ this.expose()
427
+ // #endif
428
+ }
429
+
430
+ // #ifndef APP-PLUS-NVUE
431
+ // 处理音视频
432
+ if (node.name === 'video' || node.name === 'audio') {
433
+ // 设置 id 以便获取 context
434
+ if (node.name === 'video' && !attrs.id) {
435
+ attrs.id = 'v' + idIndex++
436
+ }
437
+ // 没有设置 controls 也没有设置 autoplay 的自动设置 controls
438
+ if (!attrs.controls && !attrs.autoplay) {
439
+ attrs.controls = 'T'
440
+ }
441
+ // 用数组存储所有可用的 source
442
+ node.src = []
443
+ if (attrs.src) {
444
+ node.src.push(attrs.src)
445
+ attrs.src = undefined
446
+ }
447
+ this.expose()
448
+ }
449
+ // #endif
450
+
451
+ // 处理自闭合标签
452
+ if (close) {
453
+ if (!this.hook(node) || config.ignoreTags[node.name]) {
454
+ // 通过 base 标签设置主域名
455
+ if (node.name === 'base' && !this.options.domain) {
456
+ this.options.domain = attrs.href
457
+ } /* #ifndef APP-PLUS-NVUE */ else if (node.name === 'source' && parent && (parent.name === 'video' || parent.name === 'audio') && attrs.src) {
458
+ // 设置 source 标签(仅父节点为 video 或 audio 时有效)
459
+ parent.src.push(attrs.src)
460
+ } /* #endif */
461
+ return
462
+ }
463
+
464
+ // 解析 style
465
+ const styleObj = this.parseStyle(node)
466
+
467
+ // 处理图片
468
+ if (node.name === 'img') {
469
+ if (attrs.src) {
470
+ // 标记 webp
471
+ if (attrs.src.includes('webp')) {
472
+ node.webp = 'T'
473
+ }
474
+ // data url 图片如果没有设置 original-src 默认为不可预览的小图片
475
+ if (attrs.src.includes('data:') && this.options.previewImg !== 'all' && !attrs['original-src']) {
476
+ attrs.ignore = 'T'
477
+ }
478
+ if (!attrs.ignore || node.webp || attrs.src.includes('cloud://')) {
479
+ for (let i = this.stack.length; i--;) {
480
+ const item = this.stack[i]
481
+ if (item.name === 'a') {
482
+ node.a = item.attrs
483
+ }
484
+ if (item.name === 'table' && !node.webp && !attrs.src.includes('cloud://')) {
485
+ if (!styleObj.display || styleObj.display.includes('inline')) {
486
+ node.t = 'inline-block'
487
+ } else {
488
+ node.t = styleObj.display
489
+ }
490
+ styleObj.display = undefined
491
+ }
492
+ // #ifndef H5 || APP-PLUS
493
+ const style = item.attrs.style || ''
494
+ if (style.includes('flex:') && !style.includes('flex:0') && !style.includes('flex: 0') && (!styleObj.width || parseInt(styleObj.width) > 100)) {
495
+ styleObj.width = '100% !important'
496
+ styleObj.height = ''
497
+ for (let j = i + 1; j < this.stack.length; j++) {
498
+ this.stack[j].attrs.style = (this.stack[j].attrs.style || '').replace('inline-', '')
499
+ }
500
+ } else if (style.includes('flex') && styleObj.width === '100%') {
501
+ for (let j = i + 1; j < this.stack.length; j++) {
502
+ const style = this.stack[j].attrs.style || ''
503
+ if (!style.includes(';width') && !style.includes(' width') && style.indexOf('width') !== 0) {
504
+ styleObj.width = ''
505
+ break
506
+ }
507
+ }
508
+ } else if (style.includes('inline-block')) {
509
+ if (styleObj.width && styleObj.width[styleObj.width.length - 1] === '%') {
510
+ item.attrs.style += ';max-width:' + styleObj.width
511
+ styleObj.width = ''
512
+ } else {
513
+ item.attrs.style += ';max-width:100%'
514
+ }
515
+ }
516
+ // #endif
517
+ item.c = 1
518
+ }
519
+ attrs.i = this.imgList.length.toString()
520
+ let src = attrs['original-src'] || attrs.src
521
+ // #ifndef H5 || MP-ALIPAY || APP-PLUS || MP-360
522
+ if (this.imgList.includes(src)) {
523
+ // 如果有重复的链接则对域名进行随机大小写变换避免预览时错位
524
+ let i = src.indexOf('://')
525
+ if (i !== -1) {
526
+ i += 3
527
+ let newSrc = src.substr(0, i)
528
+ for (; i < src.length; i++) {
529
+ if (src[i] === '/') break
530
+ newSrc += Math.random() > 0.5 ? src[i].toUpperCase() : src[i]
531
+ }
532
+ newSrc += src.substr(i)
533
+ src = newSrc
534
+ }
535
+ }
536
+ // #endif
537
+ this.imgList.push(src)
538
+ if (!node.t) {
539
+ this.imgList._unloadimgs += 1
540
+ }
541
+ // #ifdef H5 || APP-PLUS
542
+ if (this.options.lazyLoad) {
543
+ attrs['data-src'] = attrs.src
544
+ attrs.src = undefined
545
+ }
546
+ // #endif
547
+ }
548
+ }
549
+ if (styleObj.display === 'inline') {
550
+ styleObj.display = ''
551
+ }
552
+ // #ifndef APP-PLUS-NVUE
553
+ if (attrs.ignore) {
554
+ styleObj['max-width'] = styleObj['max-width'] || '100%'
555
+ attrs.style += ';-webkit-touch-callout:none'
556
+ }
557
+ // #endif
558
+ // 设置的宽度超出屏幕,为避免变形,高度转为自动
559
+ if (parseInt(styleObj.width) > windowWidth) {
560
+ styleObj.height = undefined
561
+ }
562
+ // 记录是否设置了宽高
563
+ if (!isNaN(parseInt(styleObj.width))) {
564
+ node.w = 'T'
565
+ }
566
+ if (!isNaN(parseInt(styleObj.height)) && (!styleObj.height.includes('%') || (parent && (parent.attrs.style || '').includes('height')))) {
567
+ node.h = 'T'
568
+ }
569
+ if (node.w && node.h && styleObj['object-fit']) {
570
+ if (styleObj['object-fit'] === 'contain') {
571
+ node.m = 'aspectFit'
572
+ } else if (styleObj['object-fit'] === 'cover') {
573
+ node.m = 'aspectFill'
574
+ }
575
+ }
576
+ } else if (node.name === 'svg') {
577
+ siblings.push(node)
578
+ this.stack.push(node)
579
+ this.popNode()
580
+ return
581
+ }
582
+ for (const key in styleObj) {
583
+ if (styleObj[key]) {
584
+ attrs.style += `;${key}:${styleObj[key].replace(' !important', '')}`
585
+ }
586
+ }
587
+ attrs.style = attrs.style.substr(1) || undefined
588
+ // #ifdef (MP-WEIXIN || MP-QQ) && VUE3
589
+ if (!attrs.style) {
590
+ delete attrs.style
591
+ }
592
+ // #endif
593
+ } else {
594
+ if ((node.name === 'pre' || ((attrs.style || '').includes('white-space') && attrs.style.includes('pre'))) && this.pre !== 2) {
595
+ this.pre = node.pre = 1
596
+ }
597
+ node.children = []
598
+ this.stack.push(node)
599
+ }
600
+
601
+ // 加入节点树
602
+ siblings.push(node)
603
+ }
604
+
605
+ /**
606
+ * @description 解析到标签结束
607
+ * @param {String} name 标签名
608
+ * @private
609
+ */
610
+ Parser.prototype.onCloseTag = function (name) {
611
+ // 依次出栈到匹配为止
612
+ name = this.xml ? name : name.toLowerCase()
613
+ let i
614
+ for (i = this.stack.length; i--;) {
615
+ if (this.stack[i].name === name) break
616
+ }
617
+ if (i !== -1) {
618
+ while (this.stack.length > i) {
619
+ this.popNode()
620
+ }
621
+ } else if (name === 'p' || name === 'br') {
622
+ const siblings = this.stack.length ? this.stack[this.stack.length - 1].children : this.nodes
623
+ siblings.push({
624
+ name,
625
+ attrs: {
626
+ class: tagSelector[name] || '',
627
+ style: this.tagStyle[name] || ''
628
+ }
629
+ })
630
+ }
631
+ }
632
+
633
+ /**
634
+ * @description 处理标签出栈
635
+ * @private
636
+ */
637
+ Parser.prototype.popNode = function () {
638
+ const node = this.stack.pop()
639
+ let attrs = node.attrs
640
+ const children = node.children
641
+ const parent = this.stack[this.stack.length - 1]
642
+ const siblings = parent ? parent.children : this.nodes
643
+
644
+ if (!this.hook(node) || config.ignoreTags[node.name]) {
645
+ // 获取标题
646
+ if (node.name === 'title' && children.length && children[0].type === 'text' && this.options.setTitle) {
647
+ uni.setNavigationBarTitle({
648
+ title: children[0].text
649
+ })
650
+ }
651
+ siblings.pop()
652
+ return
653
+ }
654
+
655
+ if (node.pre && this.pre !== 2) {
656
+ // 是否合并空白符标识
657
+ this.pre = node.pre = undefined
658
+ for (let i = this.stack.length; i--;) {
659
+ if (this.stack[i].pre) {
660
+ this.pre = 1
661
+ }
662
+ }
663
+ }
664
+
665
+ const styleObj = {}
666
+
667
+ // 转换 svg
668
+ if (node.name === 'svg') {
669
+ if (this.xml > 1) {
670
+ // 多层 svg 嵌套
671
+ this.xml--
672
+ return
673
+ }
674
+ // #ifdef APP-PLUS-NVUE
675
+ (function traversal (node) {
676
+ if (node.name) {
677
+ // 调整 svg 的大小写
678
+ node.name = config.svgDict[node.name] || node.name
679
+ for (const item in node.attrs) {
680
+ if (config.svgDict[item]) {
681
+ node.attrs[config.svgDict[item]] = node.attrs[item]
682
+ node.attrs[item] = undefined
683
+ }
684
+ }
685
+ for (let i = 0; i < (node.children || []).length; i++) {
686
+ traversal(node.children[i])
687
+ }
688
+ }
689
+ })(node)
690
+ // #endif
691
+ // #ifndef APP-PLUS-NVUE
692
+ let src = ''
693
+ const style = attrs.style
694
+ attrs.style = ''
695
+ attrs.xmlns = 'http://www.w3.org/2000/svg';
696
+ (function traversal (node) {
697
+ if (node.type === 'text') {
698
+ src += node.text
699
+ return
700
+ }
701
+ const name = config.svgDict[node.name] || node.name
702
+ if (name === 'foreignObject') {
703
+ for (const child of (node.children || [])) {
704
+ if (child.attrs && !child.attrs.xmlns) {
705
+ child.attrs.xmlns = 'http://www.w3.org/1999/xhtml'
706
+ break
707
+ }
708
+ }
709
+ }
710
+ src += '<' + name
711
+ for (const item in node.attrs) {
712
+ const val = node.attrs[item]
713
+ if (val) {
714
+ src += ` ${config.svgDict[item] || item}="${val.replace(/"/g, '')}"`
715
+ }
716
+ }
717
+ if (!node.children) {
718
+ src += '/>'
719
+ } else {
720
+ src += '>'
721
+ for (let i = 0; i < node.children.length; i++) {
722
+ traversal(node.children[i])
723
+ }
724
+ src += '</' + name + '>'
725
+ }
726
+ })(node)
727
+ node.name = 'img'
728
+ node.attrs = {
729
+ src: 'data:image/svg+xml;utf8,' + src.replace(/#/g, '%23'),
730
+ style,
731
+ ignore: 'T'
732
+ }
733
+ node.children = undefined
734
+ // #endif
735
+ this.xml = false
736
+ config.ignoreTags.style = true
737
+ return
738
+ }
739
+
740
+ // #ifndef APP-PLUS-NVUE
741
+ // 转换 align 属性
742
+ if (attrs.align) {
743
+ if (node.name === 'table') {
744
+ if (attrs.align === 'center') {
745
+ styleObj['margin-inline-start'] = styleObj['margin-inline-end'] = 'auto'
746
+ } else {
747
+ styleObj.float = attrs.align
748
+ }
749
+ } else {
750
+ styleObj['text-align'] = attrs.align
751
+ }
752
+ attrs.align = undefined
753
+ }
754
+
755
+ // 转换 dir 属性
756
+ if (attrs.dir) {
757
+ styleObj.direction = attrs.dir
758
+ attrs.dir = undefined
759
+ }
760
+
761
+ // 转换 font 标签的属性
762
+ if (node.name === 'font') {
763
+ if (attrs.color) {
764
+ styleObj.color = attrs.color
765
+ attrs.color = undefined
766
+ }
767
+ if (attrs.face) {
768
+ styleObj['font-family'] = attrs.face
769
+ attrs.face = undefined
770
+ }
771
+ if (attrs.size) {
772
+ let size = parseInt(attrs.size)
773
+ if (!isNaN(size)) {
774
+ if (size < 1) {
775
+ size = 1
776
+ } else if (size > 7) {
777
+ size = 7
778
+ }
779
+ styleObj['font-size'] = ['x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', 'xxx-large'][size - 1]
780
+ }
781
+ attrs.size = undefined
782
+ }
783
+ }
784
+ // #endif
785
+
786
+ // 一些编辑器的自带 class
787
+ if ((attrs.class || '').includes('align-center')) {
788
+ styleObj['text-align'] = 'center'
789
+ }
790
+
791
+ Object.assign(styleObj, this.parseStyle(node))
792
+
793
+ if (node.name !== 'table' && parseInt(styleObj.width) > windowWidth) {
794
+ styleObj['max-width'] = '100%'
795
+ styleObj['box-sizing'] = 'border-box'
796
+ }
797
+
798
+ // #ifndef APP-PLUS-NVUE
799
+ if (config.blockTags[node.name]) {
800
+ node.name = 'div'
801
+ } else if (!config.trustTags[node.name] && !this.xml) {
802
+ // 未知标签转为 span,避免无法显示
803
+ node.name = 'span'
804
+ }
805
+
806
+ if (node.name === 'a' || node.name === 'ad'
807
+ // #ifdef H5 || APP-PLUS
808
+ || node.name === 'iframe' // eslint-disable-line
809
+ // #endif
810
+ ) {
811
+ this.expose()
812
+ } else if (node.name === 'video') {
813
+ if ((styleObj.height || '').includes('auto')) {
814
+ styleObj.height = undefined
815
+ }
816
+ /* #ifdef APP-PLUS */
817
+ let str = '<video style="width:100%;height:100%"'
818
+ for (const item in attrs) {
819
+ if (attrs[item]) {
820
+ str += ' ' + item + '="' + attrs[item] + '"'
821
+ }
822
+ }
823
+ if (this.options.pauseVideo) {
824
+ str += ' onplay="this.dispatchEvent(new CustomEvent(\'vplay\',{bubbles:!0}));for(var e=document.getElementsByTagName(\'video\'),t=0;t<e.length;t++)e[t]!=this&&e[t].pause()"'
825
+ }
826
+ str += '>'
827
+ for (let i = 0; i < node.src.length; i++) {
828
+ str += '<source src="' + node.src[i] + '">'
829
+ }
830
+ str += '</video>'
831
+ node.html = str
832
+ /* #endif */
833
+ } else if ((node.name === 'ul' || node.name === 'ol') && node.c) {
834
+ // 列表处理
835
+ const types = {
836
+ a: 'lower-alpha',
837
+ A: 'upper-alpha',
838
+ i: 'lower-roman',
839
+ I: 'upper-roman'
840
+ }
841
+ if (types[attrs.type]) {
842
+ attrs.style += ';list-style-type:' + types[attrs.type]
843
+ attrs.type = undefined
844
+ }
845
+ for (let i = children.length; i--;) {
846
+ if (children[i].name === 'li') {
847
+ children[i].c = 1
848
+ }
849
+ }
850
+ } else if (node.name === 'table') {
851
+ // 表格处理
852
+ // cellpadding、cellspacing、border 这几个常用表格属性需要通过转换实现
853
+ let padding = parseFloat(attrs.cellpadding)
854
+ let spacing = parseFloat(attrs.cellspacing)
855
+ const border = parseFloat(attrs.border)
856
+ const bordercolor = styleObj['border-color']
857
+ const borderstyle = styleObj['border-style']
858
+ if (node.c) {
859
+ // padding 和 spacing 默认 2
860
+ if (isNaN(padding)) {
861
+ padding = 2
862
+ }
863
+ if (isNaN(spacing)) {
864
+ spacing = 2
865
+ }
866
+ }
867
+ if (border) {
868
+ attrs.style += `;border:${border}px ${borderstyle || 'solid'} ${bordercolor || 'gray'}`
869
+ }
870
+ if (node.flag && node.c) {
871
+ // 有 colspan 或 rowspan 且含有链接的表格通过 grid 布局实现
872
+ styleObj.display = 'grid'
873
+ if (styleObj['border-collapse'] === 'collapse') {
874
+ styleObj['border-collapse'] = undefined
875
+ spacing = 0
876
+ }
877
+ if (spacing) {
878
+ styleObj['grid-gap'] = spacing + 'px'
879
+ styleObj.padding = spacing + 'px'
880
+ } else if (border) {
881
+ // 无间隔的情况下避免边框重叠
882
+ attrs.style += ';border-left:0;border-top:0'
883
+ }
884
+
885
+ const width = [] // 表格的列宽
886
+ const trList = [] // tr 列表
887
+ const cells = [] // 保存新的单元格
888
+ const map = {}; // 被合并单元格占用的格子
889
+
890
+ (function traversal (nodes) {
891
+ for (let i = 0; i < nodes.length; i++) {
892
+ if (nodes[i].name === 'tr') {
893
+ trList.push(nodes[i])
894
+ } else if (nodes[i].name === 'colgroup') {
895
+ let colI = 1
896
+ for (const col of (nodes[i].children || [])) {
897
+ if (col.name === 'col') {
898
+ const style = col.attrs.style || ''
899
+ const start = style.indexOf('width') ? style.indexOf(';width') : 0
900
+ // 提取出宽度
901
+ if (start !== -1) {
902
+ let end = style.indexOf(';', start + 6)
903
+ if (end === -1) {
904
+ end = style.length
905
+ }
906
+ width[colI] = style.substring(start ? start + 7 : 6, end)
907
+ }
908
+ colI += 1
909
+ }
910
+ }
911
+ } else {
912
+ traversal(nodes[i].children || [])
913
+ }
914
+ }
915
+ })(children)
916
+
917
+ for (let row = 1; row <= trList.length; row++) {
918
+ let col = 1
919
+ for (let j = 0; j < trList[row - 1].children.length; j++) {
920
+ const td = trList[row - 1].children[j]
921
+ if (td.name === 'td' || td.name === 'th') {
922
+ // 这个格子被上面的单元格占用,则列号++
923
+ while (map[row + '.' + col]) {
924
+ col++
925
+ }
926
+ let style = td.attrs.style || ''
927
+ let start = style.indexOf('width') ? style.indexOf(';width') : 0
928
+ // 提取出 td 的宽度
929
+ if (start !== -1) {
930
+ let end = style.indexOf(';', start + 6)
931
+ if (end === -1) {
932
+ end = style.length
933
+ }
934
+ if (!td.attrs.colspan) {
935
+ width[col] = style.substring(start ? start + 7 : 6, end)
936
+ }
937
+ style = style.substr(0, start) + style.substr(end)
938
+ }
939
+ // 设置竖直对齐
940
+ style += ';display:flex'
941
+ start = style.indexOf('vertical-align')
942
+ if (start !== -1) {
943
+ const val = style.substr(start + 15, 10)
944
+ if (val.includes('middle')) {
945
+ style += ';align-items:center'
946
+ } else if (val.includes('bottom')) {
947
+ style += ';align-items:flex-end'
948
+ }
949
+ } else {
950
+ style += ';align-items:center'
951
+ }
952
+ // 设置水平对齐
953
+ start = style.indexOf('text-align')
954
+ if (start !== -1) {
955
+ const val = style.substr(start + 11, 10)
956
+ if (val.includes('center')) {
957
+ style += ';justify-content: center'
958
+ } else if (val.includes('right')) {
959
+ style += ';justify-content: right'
960
+ }
961
+ }
962
+ style = (border ? `;border:${border}px ${borderstyle || 'solid'} ${bordercolor || 'gray'}` + (spacing ? '' : ';border-right:0;border-bottom:0') : '') + (padding ? `;padding:${padding}px` : '') + ';' + style
963
+ // 处理列合并
964
+ if (td.attrs.colspan) {
965
+ style += `;grid-column-start:${col};grid-column-end:${col + parseInt(td.attrs.colspan)}`
966
+ if (!td.attrs.rowspan) {
967
+ style += `;grid-row-start:${row};grid-row-end:${row + 1}`
968
+ }
969
+ col += parseInt(td.attrs.colspan) - 1
970
+ }
971
+ // 处理行合并
972
+ if (td.attrs.rowspan) {
973
+ style += `;grid-row-start:${row};grid-row-end:${row + parseInt(td.attrs.rowspan)}`
974
+ if (!td.attrs.colspan) {
975
+ style += `;grid-column-start:${col};grid-column-end:${col + 1}`
976
+ }
977
+ // 记录下方单元格被占用
978
+ for (let rowspan = 1; rowspan < td.attrs.rowspan; rowspan++) {
979
+ for (let colspan = 0; colspan < (td.attrs.colspan || 1); colspan++) {
980
+ map[(row + rowspan) + '.' + (col - colspan)] = 1
981
+ }
982
+ }
983
+ }
984
+ if (style) {
985
+ td.attrs.style = style
986
+ }
987
+ cells.push(td)
988
+ col++
989
+ }
990
+ }
991
+ if (row === 1) {
992
+ let temp = ''
993
+ for (let i = 1; i < col; i++) {
994
+ temp += (width[i] ? width[i] : 'auto') + ' '
995
+ }
996
+ styleObj['grid-template-columns'] = temp
997
+ }
998
+ }
999
+ node.children = cells
1000
+ } else {
1001
+ // 没有使用合并单元格的表格通过 table 布局实现
1002
+ if (node.c) {
1003
+ styleObj.display = 'table'
1004
+ }
1005
+ if (!isNaN(spacing)) {
1006
+ styleObj['border-spacing'] = spacing + 'px'
1007
+ }
1008
+ if (border || padding) {
1009
+ // 遍历
1010
+ (function traversal (nodes) {
1011
+ for (let i = 0; i < nodes.length; i++) {
1012
+ const td = nodes[i]
1013
+ if (td.name === 'th' || td.name === 'td') {
1014
+ if (border) {
1015
+ td.attrs.style = `border:${border}px ${borderstyle || 'solid'} ${bordercolor || 'gray'};${td.attrs.style || ''}`
1016
+ }
1017
+ if (padding) {
1018
+ td.attrs.style = `padding:${padding}px;${td.attrs.style || ''}`
1019
+ }
1020
+ } else if (td.children) {
1021
+ traversal(td.children)
1022
+ }
1023
+ }
1024
+ })(children)
1025
+ }
1026
+ }
1027
+ // 给表格添加一个单独的横向滚动层
1028
+ if (this.options.scrollTable && !(attrs.style || '').includes('inline')) {
1029
+ const table = Object.assign({}, node)
1030
+ node.name = 'div'
1031
+ node.attrs = {
1032
+ style: 'overflow:auto'
1033
+ }
1034
+ node.children = [table]
1035
+ attrs = table.attrs
1036
+ }
1037
+ } else if ((node.name === 'tbody' || node.name === 'tr') && node.flag && node.c) {
1038
+ node.flag = undefined;
1039
+ (function traversal (nodes) {
1040
+ for (let i = 0; i < nodes.length; i++) {
1041
+ if (nodes[i].name === 'td') {
1042
+ // 颜色样式设置给单元格避免丢失
1043
+ for (const style of ['color', 'background', 'background-color']) {
1044
+ if (styleObj[style]) {
1045
+ nodes[i].attrs.style = style + ':' + styleObj[style] + ';' + (nodes[i].attrs.style || '')
1046
+ }
1047
+ }
1048
+ } else {
1049
+ traversal(nodes[i].children || [])
1050
+ }
1051
+ }
1052
+ })(children)
1053
+ } else if ((node.name === 'td' || node.name === 'th') && (attrs.colspan || attrs.rowspan)) {
1054
+ for (let i = this.stack.length; i--;) {
1055
+ if (this.stack[i].name === 'table' || this.stack[i].name === 'tbody' || this.stack[i].name === 'tr') {
1056
+ this.stack[i].flag = 1 // 指示含有合并单元格
1057
+ }
1058
+ }
1059
+ } else if (node.name === 'ruby') {
1060
+ // 转换 ruby
1061
+ node.name = 'span'
1062
+ for (let i = 0; i < children.length - 1; i++) {
1063
+ if (children[i].type === 'text' && children[i + 1].name === 'rt') {
1064
+ children[i] = {
1065
+ name: 'div',
1066
+ attrs: {
1067
+ style: 'display:inline-block;text-align:center'
1068
+ },
1069
+ children: [{
1070
+ name: 'div',
1071
+ attrs: {
1072
+ style: 'font-size:50%;' + (children[i + 1].attrs.style || '')
1073
+ },
1074
+ children: children[i + 1].children
1075
+ }, children[i]]
1076
+ }
1077
+ children.splice(i + 1, 1)
1078
+ }
1079
+ }
1080
+ } else if (node.c) {
1081
+ (function traversal (node) {
1082
+ node.c = 2
1083
+ for (let i = node.children.length; i--;) {
1084
+ const child = node.children[i]
1085
+ // #ifdef (MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE3
1086
+ if (child.name && (config.inlineTags[child.name] || ((child.attrs.style || '').includes('inline') && child.children)) && !child.c) {
1087
+ traversal(child)
1088
+ }
1089
+ // #endif
1090
+ if (!child.c || child.name === 'table') {
1091
+ node.c = 1
1092
+ }
1093
+ }
1094
+ })(node)
1095
+ }
1096
+
1097
+ if ((styleObj.display || '').includes('flex') && !node.c) {
1098
+ for (let i = children.length; i--;) {
1099
+ const item = children[i]
1100
+ if (item.f) {
1101
+ item.attrs.style = (item.attrs.style || '') + item.f
1102
+ item.f = undefined
1103
+ }
1104
+ }
1105
+ }
1106
+ // flex 布局时部分样式需要提取到 rich-text 外层
1107
+ const flex = parent && ((parent.attrs.style || '').includes('flex') || (parent.attrs.style || '').includes('grid'))
1108
+ // #ifdef MP-WEIXIN
1109
+ // 检查基础库版本 virtualHost 是否可用
1110
+ && !(node.c && wx.getNFCAdapter) // eslint-disable-line
1111
+ // #endif
1112
+ // #ifndef MP-WEIXIN || MP-QQ || MP-BAIDU || MP-TOUTIAO
1113
+ && !node.c // eslint-disable-line
1114
+ // #endif
1115
+ if (flex) {
1116
+ node.f = ';max-width:100%'
1117
+ }
1118
+
1119
+ if (children.length >= 50 && node.c && !(styleObj.display || '').includes('flex')) {
1120
+ mergeNodes(children)
1121
+ }
1122
+ // #endif
1123
+
1124
+ for (const key in styleObj) {
1125
+ if (styleObj[key]) {
1126
+ const val = `;${key}:${styleObj[key].replace(' !important', '')}`
1127
+ /* #ifndef APP-PLUS-NVUE */
1128
+ if (flex && ((key.includes('flex') && key !== 'flex-direction') || key === 'align-self' || key.includes('grid') || styleObj[key][0] === '-' || (key.includes('width') && val.includes('%')))) {
1129
+ node.f += val
1130
+ if (key === 'width') {
1131
+ attrs.style += ';width:100%'
1132
+ }
1133
+ } else /* #endif */ {
1134
+ attrs.style += val
1135
+ }
1136
+ }
1137
+ }
1138
+ attrs.style = attrs.style.substr(1) || undefined
1139
+ // #ifdef (MP-WEIXIN || MP-QQ) && VUE3
1140
+ for (const key in attrs) {
1141
+ if (!attrs[key]) {
1142
+ delete attrs[key]
1143
+ }
1144
+ }
1145
+ // #endif
1146
+ }
1147
+
1148
+ /**
1149
+ * @description 解析到文本
1150
+ * @param {String} text 文本内容
1151
+ */
1152
+ Parser.prototype.onText = function (text) {
1153
+ if (!this.pre) {
1154
+ // 合并空白符
1155
+ let trim = ''
1156
+ let flag
1157
+ for (let i = 0, len = text.length; i < len; i++) {
1158
+ if (!blankChar[text[i]]) {
1159
+ trim += text[i]
1160
+ } else {
1161
+ if (trim[trim.length - 1] !== ' ') {
1162
+ trim += ' '
1163
+ }
1164
+ if (text[i] === '\n' && !flag) {
1165
+ flag = true
1166
+ }
1167
+ }
1168
+ }
1169
+ // 去除含有换行符的空串
1170
+ if (trim === ' ') {
1171
+ if (flag) return
1172
+ // #ifdef VUE3
1173
+ else {
1174
+ const parent = this.stack[this.stack.length - 1]
1175
+ if (parent && parent.name[0] === 't') return
1176
+ }
1177
+ // #endif
1178
+ }
1179
+ text = trim
1180
+ }
1181
+ const node = Object.create(null)
1182
+ node.type = 'text'
1183
+ // #ifdef (MP-BAIDU || MP-ALIPAY || MP-TOUTIAO) && VUE3
1184
+ node.attrs = {}
1185
+ // #endif
1186
+ node.text = decodeEntity(text)
1187
+ if (this.hook(node)) {
1188
+ // #ifdef MP-WEIXIN
1189
+ if (this.options.selectable === 'force' && system.includes('iOS') && !uni.canIUse('rich-text.user-select')) {
1190
+ this.expose()
1191
+ }
1192
+ // #endif
1193
+ const siblings = this.stack.length ? this.stack[this.stack.length - 1].children : this.nodes
1194
+ siblings.push(node)
1195
+ }
1196
+ }
1197
+
1198
+ /**
1199
+ * @description html 词法分析器
1200
+ * @param {Object} handler 高层处理器
1201
+ */
1202
+ function Lexer (handler) {
1203
+ this.handler = handler
1204
+ }
1205
+
1206
+ /**
1207
+ * @description 执行解析
1208
+ * @param {String} content 要解析的文本
1209
+ */
1210
+ Lexer.prototype.parse = function (content) {
1211
+ this.content = content || ''
1212
+ this.i = 0 // 标记解析位置
1213
+ this.start = 0 // 标记一个单词的开始位置
1214
+ this.state = this.text // 当前状态
1215
+ for (let len = this.content.length; this.i !== -1 && this.i < len;) {
1216
+ this.state()
1217
+ }
1218
+ }
1219
+
1220
+ /**
1221
+ * @description 检查标签是否闭合
1222
+ * @param {String} method 如果闭合要进行的操作
1223
+ * @returns {Boolean} 是否闭合
1224
+ * @private
1225
+ */
1226
+ Lexer.prototype.checkClose = function (method) {
1227
+ const selfClose = this.content[this.i] === '/'
1228
+ if (this.content[this.i] === '>' || (selfClose && this.content[this.i + 1] === '>')) {
1229
+ if (method) {
1230
+ this.handler[method](this.content.substring(this.start, this.i))
1231
+ }
1232
+ this.i += selfClose ? 2 : 1
1233
+ this.start = this.i
1234
+ this.handler.onOpenTag(selfClose)
1235
+ if (this.handler.tagName === 'script') {
1236
+ this.i = this.content.indexOf('</', this.i)
1237
+ if (this.i !== -1) {
1238
+ this.i += 2
1239
+ this.start = this.i
1240
+ }
1241
+ this.state = this.endTag
1242
+ } else {
1243
+ this.state = this.text
1244
+ }
1245
+ return true
1246
+ }
1247
+ return false
1248
+ }
1249
+
1250
+ /**
1251
+ * @description 文本状态
1252
+ * @private
1253
+ */
1254
+ Lexer.prototype.text = function () {
1255
+ this.i = this.content.indexOf('<', this.i) // 查找最近的标签
1256
+ if (this.i === -1) {
1257
+ // 没有标签了
1258
+ if (this.start < this.content.length) {
1259
+ this.handler.onText(this.content.substring(this.start, this.content.length))
1260
+ }
1261
+ return
1262
+ }
1263
+ const c = this.content[this.i + 1]
1264
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) {
1265
+ // 标签开头
1266
+ if (this.start !== this.i) {
1267
+ this.handler.onText(this.content.substring(this.start, this.i))
1268
+ }
1269
+ this.start = ++this.i
1270
+ this.state = this.tagName
1271
+ } else if (c === '/' || c === '!' || c === '?') {
1272
+ if (this.start !== this.i) {
1273
+ this.handler.onText(this.content.substring(this.start, this.i))
1274
+ }
1275
+ const next = this.content[this.i + 2]
1276
+ if (c === '/' && ((next >= 'a' && next <= 'z') || (next >= 'A' && next <= 'Z'))) {
1277
+ // 标签结尾
1278
+ this.i += 2
1279
+ this.start = this.i
1280
+ this.state = this.endTag
1281
+ return
1282
+ }
1283
+ // 处理注释
1284
+ let end = '-->'
1285
+ if (c !== '!' || this.content[this.i + 2] !== '-' || this.content[this.i + 3] !== '-') {
1286
+ end = '>'
1287
+ }
1288
+ this.i = this.content.indexOf(end, this.i)
1289
+ if (this.i !== -1) {
1290
+ this.i += end.length
1291
+ this.start = this.i
1292
+ }
1293
+ } else {
1294
+ this.i++
1295
+ }
1296
+ }
1297
+
1298
+ /**
1299
+ * @description 标签名状态
1300
+ * @private
1301
+ */
1302
+ Lexer.prototype.tagName = function () {
1303
+ if (blankChar[this.content[this.i]]) {
1304
+ // 解析到标签名
1305
+ this.handler.onTagName(this.content.substring(this.start, this.i))
1306
+ while (blankChar[this.content[++this.i]]);
1307
+ if (this.i < this.content.length && !this.checkClose()) {
1308
+ this.start = this.i
1309
+ this.state = this.attrName
1310
+ }
1311
+ } else if (!this.checkClose('onTagName')) {
1312
+ this.i++
1313
+ }
1314
+ }
1315
+
1316
+ /**
1317
+ * @description 属性名状态
1318
+ * @private
1319
+ */
1320
+ Lexer.prototype.attrName = function () {
1321
+ let c = this.content[this.i]
1322
+ if (blankChar[c] || c === '=') {
1323
+ // 解析到属性名
1324
+ this.handler.onAttrName(this.content.substring(this.start, this.i))
1325
+ let needVal = c === '='
1326
+ const len = this.content.length
1327
+ while (++this.i < len) {
1328
+ c = this.content[this.i]
1329
+ if (!blankChar[c]) {
1330
+ if (this.checkClose()) return
1331
+ if (needVal) {
1332
+ // 等号后遇到第一个非空字符
1333
+ this.start = this.i
1334
+ this.state = this.attrVal
1335
+ return
1336
+ }
1337
+ if (this.content[this.i] === '=') {
1338
+ needVal = true
1339
+ } else {
1340
+ this.start = this.i
1341
+ this.state = this.attrName
1342
+ return
1343
+ }
1344
+ }
1345
+ }
1346
+ } else if (!this.checkClose('onAttrName')) {
1347
+ this.i++
1348
+ }
1349
+ }
1350
+
1351
+ /**
1352
+ * @description 属性值状态
1353
+ * @private
1354
+ */
1355
+ Lexer.prototype.attrVal = function () {
1356
+ const c = this.content[this.i]
1357
+ const len = this.content.length
1358
+ if (c === '"' || c === "'") {
1359
+ // 有冒号的属性
1360
+ this.start = ++this.i
1361
+ this.i = this.content.indexOf(c, this.i)
1362
+ if (this.i === -1) return
1363
+ this.handler.onAttrVal(this.content.substring(this.start, this.i))
1364
+ } else {
1365
+ // 没有冒号的属性
1366
+ for (; this.i < len; this.i++) {
1367
+ if (blankChar[this.content[this.i]]) {
1368
+ this.handler.onAttrVal(this.content.substring(this.start, this.i))
1369
+ break
1370
+ } else if (this.checkClose('onAttrVal')) return
1371
+ }
1372
+ }
1373
+ while (blankChar[this.content[++this.i]]);
1374
+ if (this.i < len && !this.checkClose()) {
1375
+ this.start = this.i
1376
+ this.state = this.attrName
1377
+ }
1378
+ }
1379
+
1380
+ /**
1381
+ * @description 结束标签状态
1382
+ * @returns {String} 结束的标签名
1383
+ * @private
1384
+ */
1385
+ Lexer.prototype.endTag = function () {
1386
+ const c = this.content[this.i]
1387
+ if (blankChar[c] || c === '>' || c === '/') {
1388
+ this.handler.onCloseTag(this.content.substring(this.start, this.i))
1389
+ if (c !== '>') {
1390
+ this.i = this.content.indexOf('>', this.i)
1391
+ if (this.i === -1) return
1392
+ }
1393
+ this.start = ++this.i
1394
+ this.state = this.text
1395
+ } else {
1396
+ this.i++
1397
+ }
1398
+ }
1399
+
1400
+ export default Parser