uview-plus 3.8.55 → 3.8.106

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 (229) hide show
  1. package/changelog.md +2147 -1828
  2. package/components/u-action-sheet/props.js +3 -1
  3. package/components/u-action-sheet/u-action-sheet.vue +22 -2
  4. package/components/u-album/props.js +3 -1
  5. package/components/u-alert/props.js +4 -2
  6. package/components/u-avatar/props.js +4 -1
  7. package/components/u-avatar-group/props.js +4 -1
  8. package/components/u-back-top/props.js +4 -1
  9. package/components/u-badge/props.js +4 -1
  10. package/components/u-barcode/u-barcode.vue +44 -15
  11. package/components/u-box/props.js +5 -2
  12. package/components/u-button/props.js +4 -1
  13. package/components/u-button/u-button.vue +2 -5
  14. package/components/u-button/vue.scss +3 -3
  15. package/components/u-calendar/calendar.js +8 -0
  16. package/components/u-calendar/props.js +43 -1
  17. package/components/u-calendar/u-calendar.vue +16 -0
  18. package/components/u-calendar-strip/props.js +3 -1
  19. package/components/u-canvas/u-canvas.vue +1028 -423
  20. package/components/u-car-keyboard/props.js +3 -1
  21. package/components/u-card/props.js +3 -1
  22. package/components/u-cell/props.js +4 -1
  23. package/components/u-cell/u-cell.vue +9 -1
  24. package/components/u-cell-group/props.js +4 -1
  25. package/components/u-checkbox/props.js +4 -1
  26. package/components/u-checkbox/u-checkbox.vue +7 -3
  27. package/components/u-checkbox-group/props.js +3 -1
  28. package/components/u-circle-progress/props.js +4 -1
  29. package/components/u-code/props.js +4 -1
  30. package/components/u-code-input/props.js +4 -1
  31. package/components/u-col/props.js +4 -1
  32. package/components/u-collapse/props.js +4 -1
  33. package/components/u-collapse-item/props.js +4 -1
  34. package/components/u-color-picker/u-color-picker.vue +1 -0
  35. package/components/u-column-notice/props.js +4 -1
  36. package/components/u-count-down/props.js +4 -1
  37. package/components/u-count-to/props.js +4 -1
  38. package/components/u-cropper/u-cropper.vue +95 -51
  39. package/components/u-datetime-picker/props.js +4 -1
  40. package/components/u-datetime-picker/u-datetime-picker.vue +53 -4
  41. package/components/u-divider/props.js +4 -1
  42. package/components/u-dragsort/u-dragsort.vue +57 -32
  43. package/components/u-dropdown/props.js +3 -1
  44. package/components/u-dropdown-item/props.js +3 -1
  45. package/components/u-empty/props.js +4 -1
  46. package/components/u-form/props.js +4 -1
  47. package/components/u-form-item/props.js +4 -1
  48. package/components/u-gap/props.js +4 -1
  49. package/components/u-grid/props.js +4 -1
  50. package/components/u-grid-item/props.js +4 -1
  51. package/components/u-guide/props.js +3 -1
  52. package/components/u-icon/props.js +4 -1
  53. package/components/u-icon/u-icon.vue +11 -2
  54. package/components/u-icon/upicon.ttf +0 -0
  55. package/components/u-icon/util.js +103 -10
  56. package/components/u-image/props.js +4 -1
  57. package/components/u-image/u-image.vue +280 -267
  58. package/components/u-index-anchor/props.js +4 -1
  59. package/components/u-index-item/props.js +2 -1
  60. package/components/u-index-item/u-index-item.vue +1 -1
  61. package/components/u-index-list/props.js +4 -1
  62. package/components/u-index-list/u-index-list.vue +1 -1
  63. package/components/u-input/props.js +3 -1
  64. package/components/u-keyboard/props.js +4 -1
  65. package/components/u-line/props.js +4 -1
  66. package/components/u-line-progress/props.js +6 -3
  67. package/components/u-link/props.js +4 -1
  68. package/components/u-list/props.js +4 -1
  69. package/components/u-list-item/props.js +4 -1
  70. package/components/u-loading-icon/props.js +4 -1
  71. package/components/u-loading-page/props.js +3 -1
  72. package/components/u-loadmore/props.js +4 -1
  73. package/components/u-markdown/u-markdown.vue +45 -3
  74. package/components/u-modal/props.js +4 -1
  75. package/components/u-navbar/props.js +4 -2
  76. package/components/u-navbar/u-navbar.vue +15 -9
  77. package/components/u-no-network/props.js +4 -1
  78. package/components/u-notice-bar/props.js +4 -1
  79. package/components/u-notify/props.js +4 -1
  80. package/components/u-novel-reader/content-normalizer.js +80 -0
  81. package/components/u-novel-reader/layout-engine.js +225 -0
  82. package/components/u-novel-reader/measure-adapter.js +69 -0
  83. package/components/u-novel-reader/novelReader.js +35 -0
  84. package/components/u-novel-reader/persistence.js +144 -0
  85. package/components/u-novel-reader/props.js +100 -0
  86. package/components/u-novel-reader/reader-catalog.vue +234 -0
  87. package/components/u-novel-reader/reader-content.vue +226 -0
  88. package/components/u-novel-reader/reader-core.js +151 -0
  89. package/components/u-novel-reader/reader-settings.vue +325 -0
  90. package/components/u-novel-reader/reader-toolbar.vue +313 -0
  91. package/components/u-novel-reader/theme-vars.scss +49 -0
  92. package/components/u-novel-reader/u-novel-reader.vue +836 -0
  93. package/components/u-number-box/props.js +4 -1
  94. package/components/u-number-box/u-number-box.vue +2 -2
  95. package/components/u-number-keyboard/props.js +4 -1
  96. package/components/u-overlay/props.js +4 -1
  97. package/components/u-pagination/u-pagination.vue +60 -39
  98. package/components/u-parse/props.js +4 -1
  99. package/components/u-picker/props.js +4 -1
  100. package/components/u-picker-column/props.js +3 -1
  101. package/components/u-popover/props.js +2 -1
  102. package/components/u-popup/props.js +4 -1
  103. package/components/u-poster/u-poster.vue +246 -214
  104. package/components/u-qrcode/qrcode.js +105 -97
  105. package/components/u-qrcode/u-qrcode.vue +242 -289
  106. package/components/u-radio/props.js +4 -1
  107. package/components/u-radio/u-radio.vue +7 -3
  108. package/components/u-radio-group/props.js +4 -1
  109. package/components/u-rate/props.js +4 -1
  110. package/components/u-read-more/props.js +4 -1
  111. package/components/u-row/props.js +4 -1
  112. package/components/u-row-notice/props.js +4 -1
  113. package/components/u-safe-bottom/props.js +2 -1
  114. package/components/u-scroll-list/props.js +4 -1
  115. package/components/u-scroll-list/scrollWxs.wxs +1 -1
  116. package/components/u-search/props.js +3 -1
  117. package/components/u-skeleton/props.js +4 -1
  118. package/components/u-slider/props.js +3 -1
  119. package/components/u-slider/u-slider.vue +71 -29
  120. package/components/u-status-bar/props.js +4 -1
  121. package/components/u-steps/props.js +4 -1
  122. package/components/u-steps-item/props.js +4 -1
  123. package/components/u-sticky/props.js +4 -1
  124. package/components/u-sticky/u-sticky.vue +11 -0
  125. package/components/u-subsection/props.js +3 -1
  126. package/components/u-swipe-action/props.js +4 -1
  127. package/components/u-swipe-action-item/index.wxs +43 -25
  128. package/components/u-swipe-action-item/nvue.js +9 -0
  129. package/components/u-swipe-action-item/other.js +32 -21
  130. package/components/u-swipe-action-item/props.js +9 -1
  131. package/components/u-swipe-action-item/swipeActionItem.js +1 -0
  132. package/components/u-swipe-action-item/u-swipe-action-item.vue +42 -4
  133. package/components/u-swiper/props.js +9 -1
  134. package/components/u-swiper/swiper.js +1 -0
  135. package/components/u-swiper/u-swiper.vue +2 -0
  136. package/components/u-swiper-indicator/props.js +4 -1
  137. package/components/u-switch/props.js +4 -1
  138. package/components/u-switch/u-switch.vue +1 -1
  139. package/components/u-tabbar/props.js +3 -1
  140. package/components/u-tabbar/u-tabbar.vue +2 -1
  141. package/components/u-tabbar-item/props.js +4 -1
  142. package/components/u-tabbar-item/u-tabbar-item.vue +64 -21
  143. package/components/u-table/props.js +3 -1
  144. package/components/u-table2/tableRow.vue +155 -69
  145. package/components/u-table2/u-table2.vue +327 -137
  146. package/components/u-tabs/props.js +4 -1
  147. package/components/u-tabs/u-tabs.vue +11 -8
  148. package/components/u-tabs-item/props.js +3 -1
  149. package/components/u-tabs-pro/u-tabs-pro.vue +212 -0
  150. package/components/u-tag/props.js +4 -1
  151. package/components/u-td/props.js +3 -1
  152. package/components/u-text/props.js +4 -1
  153. package/components/u-text/text.js +1 -1
  154. package/components/u-text/u-text.vue +18 -6
  155. package/components/u-textarea/props.js +3 -1
  156. package/components/u-textarea/u-textarea.vue +16 -5
  157. package/components/u-th/props.js +3 -1
  158. package/components/u-toolbar/props.js +4 -1
  159. package/components/u-tooltip/props.js +10 -2
  160. package/components/u-tooltip/tooltip.js +2 -1
  161. package/components/u-tooltip/u-tooltip.vue +31 -3
  162. package/components/u-tr/props.js +3 -1
  163. package/components/u-transition/nvue-ani-map.js +75 -68
  164. package/components/u-transition/props.js +4 -1
  165. package/components/u-transition/transitionMixin.js +164 -163
  166. package/components/u-upload/props.js +4 -1
  167. package/components/u-upload/u-upload.vue +48 -41
  168. package/components/u-waterfall/u-waterfall.vue +162 -110
  169. package/index.js +65 -8
  170. package/libs/config/config.js +1 -1
  171. package/libs/config/props.js +180 -204
  172. package/libs/css/components.scss +3 -0
  173. package/libs/function/index.js +66 -0
  174. package/libs/function/uni-api-shims.js +29 -0
  175. package/libs/i18n/index.js +71 -36
  176. package/libs/i18n/locale-packs.js +11 -0
  177. package/libs/i18n/locales/all.js +23 -0
  178. package/libs/i18n/locales/{de.json → de.js} +1 -1
  179. package/libs/i18n/locales/{en.json → en.js} +2 -2
  180. package/libs/i18n/locales/{es.json → es.js} +1 -1
  181. package/libs/i18n/locales/{fr.json → fr.js} +2 -2
  182. package/libs/i18n/locales/{ja.json → ja.js} +1 -1
  183. package/libs/i18n/locales/{ko.json → ko.js} +1 -1
  184. package/libs/i18n/locales/{ru.json → ru.js} +1 -1
  185. package/libs/i18n/locales/{th.json → th.js} +1 -1
  186. package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
  187. package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
  188. package/libs/mixin/mixin.js +18 -54
  189. package/libs/root/index.js +78 -5
  190. package/libs/root/page.js +7 -7
  191. package/libs/root/root.js +73 -3
  192. package/libs/util/app-nvue-webview-canvas.js +486 -0
  193. package/libs/util/gcanvas/bridge/bridge-weex.js +10 -7
  194. package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +0 -0
  195. package/libs/util/gcanvas/context-2d/FillStylePattern.js +0 -0
  196. package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +0 -0
  197. package/libs/util/gcanvas/context-2d/RenderingContext.js +0 -0
  198. package/libs/util/gcanvas/context-webgl/ActiveInfo.js +0 -0
  199. package/libs/util/gcanvas/context-webgl/Buffer.js +0 -0
  200. package/libs/util/gcanvas/context-webgl/Framebuffer.js +0 -0
  201. package/libs/util/gcanvas/context-webgl/GLenum.js +0 -0
  202. package/libs/util/gcanvas/context-webgl/GLmethod.js +0 -0
  203. package/libs/util/gcanvas/context-webgl/GLtype.js +0 -0
  204. package/libs/util/gcanvas/context-webgl/Program.js +0 -0
  205. package/libs/util/gcanvas/context-webgl/Renderbuffer.js +0 -0
  206. package/libs/util/gcanvas/context-webgl/RenderingContext.js +0 -0
  207. package/libs/util/gcanvas/context-webgl/Shader.js +0 -0
  208. package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +0 -0
  209. package/libs/util/gcanvas/context-webgl/Texture.js +0 -0
  210. package/libs/util/gcanvas/context-webgl/UniformLocation.js +0 -0
  211. package/libs/util/gcanvas/context-webgl/classUtils.js +0 -0
  212. package/libs/util/gcanvas/env/canvas.js +0 -0
  213. package/libs/util/gcanvas/env/image.js +0 -0
  214. package/libs/util/gcanvas/env/tool.js +0 -0
  215. package/libs/util/gcanvas/index.js +3 -3
  216. package/package.json +4 -5
  217. package/tsconfig.json +18 -0
  218. package/types/comps/calendar.d.ts +38 -0
  219. package/types/comps/checkbox.d.ts +12 -0
  220. package/types/comps/lineProgress.d.ts +5 -0
  221. package/types/comps/navbar.d.ts +3 -3
  222. package/types/comps/swipeActionItem.d.ts +13 -0
  223. package/types/comps/swiper.d.ts +5 -0
  224. package/types/comps/tabs.d.ts +2 -1
  225. package/types/comps/text.d.ts +1 -1
  226. package/types/comps/tooltip.d.ts +36 -1
  227. package/types/func.d.ts +23 -0
  228. package/types/index.d.ts +1 -0
  229. /package/components/u-markdown/{marked.esm.js → marked.esm.mjs} +0 -0
@@ -1,4 +1,4 @@
1
- {
1
+ export default {
2
2
  "up.common.cancel": "Abbrechen",
3
3
  "up.common.confirm": "Bestätigen",
4
4
  "up.common.start": "Start",
@@ -1,4 +1,4 @@
1
- {
1
+ export default {
2
2
  "up.common.cancel": "Cancel",
3
3
  "up.common.confirm": "Confirm",
4
4
  "up.common.start": "Start",
@@ -83,4 +83,4 @@
83
83
  "up.goodsSku.amount": "Items",
84
84
  "up.goodsSku.choosed": "Selected",
85
85
  "up.goodsSku.buyAmount": "Quantity"
86
- }
86
+ }
@@ -1,4 +1,4 @@
1
- {
1
+ export default {
2
2
  "up.common.cancel": "Cancelar",
3
3
  "up.common.confirm": "Confirmar",
4
4
  "up.common.start": "Iniciar",
@@ -1,4 +1,4 @@
1
- {
1
+ export default {
2
2
  "up.common.cancel": "Annuler",
3
3
  "up.common.confirm": "Confirmer",
4
4
  "up.common.start": "Démarrer",
@@ -83,4 +83,4 @@
83
83
  "up.goodsSku.amount": "Pièces",
84
84
  "up.goodsSku.choosed": "Sélectionné",
85
85
  "up.goodsSku.buyAmount": "Quantité"
86
- }
86
+ }
@@ -1,4 +1,4 @@
1
- {
1
+ export default {
2
2
  "up.common.cancel": "キャンセル",
3
3
  "up.common.confirm": "確認",
4
4
  "up.common.start": "開始",
@@ -1,4 +1,4 @@
1
- {
1
+ export default {
2
2
  "up.common.cancel": "취소",
3
3
  "up.common.confirm": "확인",
4
4
  "up.common.start": "시작",
@@ -1,4 +1,4 @@
1
- {
1
+ export default {
2
2
  "up.common.cancel": "Отмена",
3
3
  "up.common.confirm": "Подтвердить",
4
4
  "up.common.start": "Начало",
@@ -1,4 +1,4 @@
1
- {
1
+ export default {
2
2
  "up.common.cancel": "ยกเลิก",
3
3
  "up.common.confirm": "ยืนยัน",
4
4
  "up.common.start": "เริ่มต้น",
@@ -1,4 +1,4 @@
1
- {
1
+ export default {
2
2
  "up.common.cancel": "取消",
3
3
  "up.common.confirm": "确定",
4
4
  "up.common.start": "开始",
@@ -1,4 +1,4 @@
1
- {
1
+ export default {
2
2
  "up.common.cancel": "取消",
3
3
  "up.common.confirm": "確定",
4
4
  "up.common.start": "開始",
@@ -1,5 +1,5 @@
1
1
  import { defineMixin } from '../vue'
2
- import { deepMerge, $parent, sleep } from '../function/index'
2
+ import { deepMerge, $parent, upGetRect } from '../function/index'
3
3
  import test from '../function/test'
4
4
  import route from '../util/route'
5
5
  import {
@@ -12,13 +12,6 @@ import {
12
12
  getThemeVarsForStyle,
13
13
  syncThemeRuntimeFromStorage
14
14
  } from '../theme/runtime'
15
- // #ifdef APP-NVUE
16
- // 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度
17
- const dom = (typeof uni !== 'undefined' && uni && typeof uni.requireNativePlugin === 'function')
18
- ? uni.requireNativePlugin('dom')
19
- : null
20
- // #endif
21
-
22
15
  export const mixin = defineMixin({
23
16
  // 定义每个组件都可能需要用到的外部样式以及类名
24
17
  props: {
@@ -49,7 +42,7 @@ export const mixin = defineMixin({
49
42
  }
50
43
  },
51
44
  onLoad() {
52
- // getRect挂载到$u上,因为这方法需要使用in(this),所以无法把它独立成一个单独的文件导出
45
+ // 保留 uni.$u.getRect 兼容入口
53
46
  this.upBindGetRect()
54
47
  this.upInitThemeVersion()
55
48
  if (this.upIsPageScope()) {
@@ -74,7 +67,7 @@ export const mixin = defineMixin({
74
67
  if (typeof uni !== 'undefined' && typeof uni.$on === 'function') {
75
68
  this.__uThemeChangeHandler = (payload = {}) => {
76
69
  this.upSyncThemeVersion(payload)
77
- this.chacheU = null
70
+ this.upClearUCache()
78
71
  if (typeof this.$forceUpdate === 'function') {
79
72
  this.$forceUpdate()
80
73
  }
@@ -89,6 +82,10 @@ export const mixin = defineMixin({
89
82
  $u() {
90
83
  this.upThemeVersion
91
84
  // #ifndef APP-NVUE
85
+ const instance = this.$
86
+ if (instance?.__upUCache) {
87
+ return instance.__upUCache
88
+ }
92
89
  // 在非nvue端,移除props,http,mixin等对象,避免在小程序setData时数据过大影响性能
93
90
  let mergeU = deepMerge(uni.$u, {
94
91
  props: undefined,
@@ -96,10 +93,11 @@ export const mixin = defineMixin({
96
93
  mixin: undefined
97
94
  })
98
95
  // 缓存结果避免每次计算
99
- if (!this.chacheU) {
100
- this.chacheU = mergeU
96
+ if (instance) {
97
+ instance.__upUCache = mergeU
98
+ return instance.__upUCache
101
99
  }
102
- return this.chacheU
100
+ return mergeU
103
101
  // #endif
104
102
  // #ifdef APP-NVUE
105
103
  return uni.$u
@@ -156,6 +154,11 @@ export const mixin = defineMixin({
156
154
  }
157
155
  },
158
156
  methods: {
157
+ upClearUCache() {
158
+ if (this.$) {
159
+ this.$.__upUCache = null
160
+ }
161
+ },
159
162
  upBindGetRect() {
160
163
  const upU = this.$u || (typeof uni !== 'undefined' ? uni.$u : null)
161
164
  if (upU) {
@@ -213,47 +216,8 @@ export const mixin = defineMixin({
213
216
  navTo(url = '', linkType = 'navigateTo') {
214
217
  route({ type: this.linkType, url })
215
218
  },
216
- // 查询节点信息
217
- // 目前此方法在支付宝小程序中无法获取组件跟接点的尺寸,为支付宝的bug(2020-07-21)
218
- // 解决办法为在组件根部再套一个没有任何作用的view元素
219
- $uGetRect(selector, all) {
220
- return new Promise((resolve) => {
221
- // #ifndef APP-NVUE
222
- uni.createSelectorQuery()
223
- .in(this)[all ? 'selectAll' : 'select'](selector)
224
- .boundingClientRect((rect) => {
225
- if (all && Array.isArray(rect) && rect.length) {
226
- resolve(rect)
227
- }
228
- if (!all && rect) {
229
- resolve(rect)
230
- }
231
- })
232
- .exec()
233
- // #endif
234
-
235
- // #ifdef APP-NVUE
236
- sleep(30).then(() => {
237
- let selectorNvue = selector.substring(1) // 去掉开头的#或者.
238
- let selectorRef = this.$refs[selectorNvue]
239
- if (!selectorRef) {
240
- // console.log('不存在元素,请检查是否设置了ref属性' + selectorNvue + '。')
241
- resolve({
242
- with: 0,
243
- height: 0,
244
- left: 0,
245
- right: 0,
246
- top: 0,
247
- bottom: 0
248
- })
249
- }
250
- dom.getComponentRect(selectorRef, res => {
251
- // console.log(res)
252
- resolve(res.size)
253
- })
254
- })
255
- // #endif
256
- })
219
+ $uGetRect(selector, all = false) {
220
+ return upGetRect(selector, all, this)
257
221
  },
258
222
  getParentData(parentName = '') {
259
223
  // 避免在created中去定义parent变量
@@ -1,7 +1,7 @@
1
1
  import { dirname, relative, resolve } from 'node:path'
2
2
  import { fileURLToPath } from 'node:url'
3
3
  import process from 'node:process'
4
- import { existsSync, mkdirSync, statSync, writeFileSync } from 'node:fs'
4
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'
5
5
 
6
6
  import { createFilter, normalizePath } from 'vite'
7
7
 
@@ -10,6 +10,12 @@ import { rebuildUpApp, registerUpApp } from './root.js'
10
10
  import { loadPagesJson, normalizePlatformPath, toArray } from './utils.js'
11
11
 
12
12
  const rootLibPath = normalizePath(dirname(fileURLToPath(import.meta.url)))
13
+ const appStaticIconFontRelativePath = 'static/app-plus/uview-plus/upicon.ttf'
14
+ const appStaticIconFontFlag = 'const useAppStaticIconFont = false;'
15
+ const appStaticIconFontEnabledFlag = 'const useAppStaticIconFont = true;'
16
+ const appRemoteIconFontCondition = /\/\*\s*#ifdef\s+APP\s+\|\|\s+(MP-QQ\s+\|\|\s+MP-TOUTIAO\s+\|\|\s+MP-BAIDU\s+\|\|\s+MP-KUAISHOU\s+\|\|\s+MP-XHS)\s*\*\//
17
+ const appCompiledRemoteIconFontFace = /[ \t]*(?:\/\/[^\n]*\n[ \t]*)?@font-face\s*\{[^{}]*font-family:\s*['"]?uicon-iconfont['"]?;?[^{}]*at\.alicdn\.com\/t\/font_2225171[^{}]*\}\s*/
18
+ const appCompiledRemoteIconFontFaceGlobal = /[ \t]*(?:\/\/[^\n]*\n[ \t]*)?@font-face\s*\{[^{}]*font-family:\s*['"]?uicon-iconfont['"]?;?[^{}]*at\.alicdn\.com\/t\/font_2225171[^{}]*\}\s*/g
13
19
 
14
20
  export default function UniUpRoot(options = {}) {
15
21
  const rootOptions = {
@@ -53,7 +59,10 @@ export default function UniUpRoot(options = {}) {
53
59
  const rootPath = normalizePath(projectInfo.rootPath)
54
60
  const appUpPath = normalizePath(resolve(rootPath, `${rootFileName}.vue`))
55
61
  const rootToastHostPath = normalizePath(resolve(rootLibPath, 'root-toast-host.vue'))
56
- const nvueRootPath = normalizePath(resolve(rootPath, 'uni_modules/uview-plus/libs/root/nvue-root.vue'))
62
+ const iconFontSourcePath = normalizePath(resolve(rootLibPath, '../../components/u-icon/upicon.ttf'))
63
+ const appStaticIconFontPath = normalizePath(resolve(rootPath, appStaticIconFontRelativePath))
64
+ const uIconUtilPath = normalizePath(resolve(rootPath, 'uni_modules/uview-plus/components/u-icon/util.js'))
65
+ const uIconVuePath = normalizePath(resolve(rootPath, 'uni_modules/uview-plus/components/u-icon/u-icon.vue'))
57
66
  const themeRuntimePath = normalizePath(resolve(rootPath, 'uni_modules/uview-plus/libs/theme/runtime.js'))
58
67
  const pagesPath = normalizePath(resolve(rootPath, 'pages.json'))
59
68
  const excludedPaths = toArray(rootOptions.excludePages)
@@ -90,6 +99,51 @@ export default function UniUpRoot(options = {}) {
90
99
  writeFileSync(appUpPath, defaultRootSfc, 'utf-8')
91
100
  }
92
101
 
102
+ const shouldCopyFile = (sourcePath, targetPath) => {
103
+ if (!existsSync(targetPath)) return true
104
+ if (statSync(sourcePath).size !== statSync(targetPath).size) return true
105
+ return !readFileSync(sourcePath).equals(readFileSync(targetPath))
106
+ }
107
+
108
+ const ensureAppStaticIconFont = () => {
109
+ if (process.env.UNI_PLATFORM !== 'app') return
110
+ if (!existsSync(iconFontSourcePath)) {
111
+ throw new Error(`uview-plus built-in icon font is missing: ${iconFontSourcePath}`)
112
+ }
113
+
114
+ mkdirSync(dirname(appStaticIconFontPath), { recursive: true })
115
+ if (shouldCopyFile(iconFontSourcePath, appStaticIconFontPath)) {
116
+ copyFileSync(iconFontSourcePath, appStaticIconFontPath)
117
+ }
118
+ }
119
+
120
+ const removeAppCompiledRemoteIconFontFace = (code) => code.replace(appCompiledRemoteIconFontFaceGlobal, '')
121
+
122
+ const transformAppStaticIconFont = (code, cleanId) => {
123
+ if (process.env.UNI_PLATFORM !== 'app') return null
124
+ if (cleanId === uIconUtilPath && code.includes(appStaticIconFontFlag)) {
125
+ return code.replace(appStaticIconFontFlag, appStaticIconFontEnabledFlag)
126
+ }
127
+ if (cleanId === uIconVuePath && appRemoteIconFontCondition.test(code)) {
128
+ return code.replace(appRemoteIconFontCondition, '/* #ifdef $1 */')
129
+ }
130
+ if (cleanId === uIconVuePath && appCompiledRemoteIconFontFace.test(code)) {
131
+ return removeAppCompiledRemoteIconFontFace(code)
132
+ }
133
+ return null
134
+ }
135
+
136
+ const removeAppRemoteIconFontFaceFromCssAssets = (bundle) => {
137
+ if (process.env.UNI_PLATFORM !== 'app') return
138
+ Object.values(bundle).forEach((asset) => {
139
+ if (asset.type !== 'asset') return
140
+ if (!asset.fileName.endsWith('.css')) return
141
+ if (typeof asset.source !== 'string') return
142
+ if (!appCompiledRemoteIconFontFace.test(asset.source)) return
143
+ asset.source = removeAppCompiledRemoteIconFontFace(asset.source)
144
+ })
145
+ }
146
+
93
147
  const refreshPagesJson = () => {
94
148
  if (!existsSync(pagesPath)) return
95
149
  const mtimeMs = statSync(pagesPath).mtimeMs
@@ -101,10 +155,16 @@ export default function UniUpRoot(options = {}) {
101
155
  return {
102
156
  name: 'vite-plugin-uni-up-root',
103
157
  enforce: 'pre',
104
- configResolved({ plugins }) {
158
+ configResolved(config) {
159
+ const { plugins } = config
105
160
  hasPlatformPlugin = plugins.some(v => v.name === 'vite-plugin-uni-platform')
161
+ if (plugins.some(v => v.name === 'uni:app-nvue')) {
162
+ config.build.rollupOptions = config.build.rollupOptions || {}
163
+ config.build.rollupOptions.treeshake = false
164
+ }
106
165
  },
107
166
  buildStart() {
167
+ ensureAppStaticIconFont()
108
168
  ensureRootFile()
109
169
  refreshPagesJson()
110
170
  },
@@ -113,6 +173,14 @@ export default function UniUpRoot(options = {}) {
113
173
  const isSfcBlock = id.includes('?')
114
174
  const cleanId = normalizePath(id.split('?')[0])
115
175
 
176
+ const iconFontCode = transformAppStaticIconFont(code, cleanId)
177
+ if (iconFontCode) {
178
+ return {
179
+ code: iconFontCode,
180
+ map: null,
181
+ }
182
+ }
183
+
116
184
  const filterMain = createFilter(mainFiles)
117
185
  if (filterMain(cleanId)) {
118
186
  ms = await registerUpApp(code, rootFileName, getRelativeImportPath(cleanId, rootToastHostPath))
@@ -120,7 +188,9 @@ export default function UniUpRoot(options = {}) {
120
188
 
121
189
  const filterUpRoot = createFilter(appUpPath)
122
190
  if (filterUpRoot(cleanId)) {
123
- ms = await rebuildUpApp(code, rootOptions.enabledVirtualHost)
191
+ ms = await rebuildUpApp(code, rootOptions.enabledVirtualHost, {
192
+ rootToastHostImportPath: getRelativeImportPath(cleanId, rootToastHostPath)
193
+ })
124
194
  }
125
195
 
126
196
  refreshPagesJson()
@@ -130,7 +200,7 @@ export default function UniUpRoot(options = {}) {
130
200
  if (cleanId.endsWith('.nvue')) {
131
201
  ms = await transformNvuePage(
132
202
  code,
133
- getRelativeImportPath(cleanId, nvueRootPath),
203
+ getRelativeImportPath(cleanId, appUpPath),
134
204
  getRelativeImportPath(cleanId, themeRuntimePath),
135
205
  rootOptions.enabledGlobalRef
136
206
  )
@@ -147,5 +217,8 @@ export default function UniUpRoot(options = {}) {
147
217
  }
148
218
  return null
149
219
  },
220
+ generateBundle(_, bundle) {
221
+ removeAppRemoteIconFontFaceFromCssAssets(bundle)
222
+ },
150
223
  }
151
224
  }
package/libs/root/page.js CHANGED
@@ -53,11 +53,11 @@ export async function transformPage(code, enabledGlobalRef = false) {
53
53
  }
54
54
 
55
55
  function ensureOptionsComponent(ms, scriptContent) {
56
- if (scriptContent.includes('UpNvueRoot')) return
56
+ if (scriptContent.includes('AppUpRoot')) return
57
57
 
58
58
  const componentsMatch = scriptContent.match(/components\s*:\s*\{/)
59
59
  if (componentsMatch) {
60
- ms.appendLeft(componentsMatch.index + componentsMatch[0].length, ' UpNvueRoot,')
60
+ ms.appendLeft(componentsMatch.index + componentsMatch[0].length, ' AppUpRoot,')
61
61
  return
62
62
  }
63
63
 
@@ -65,7 +65,7 @@ function ensureOptionsComponent(ms, scriptContent) {
65
65
  if (exportDefaultMatch) {
66
66
  ms.appendLeft(
67
67
  exportDefaultMatch.index + exportDefaultMatch[0].length,
68
- '\n components: { UpNvueRoot },'
68
+ '\n components: { AppUpRoot },'
69
69
  )
70
70
  }
71
71
  }
@@ -89,7 +89,7 @@ function ensureOptionsThemeMixin(ms, scriptContent) {
89
89
  }
90
90
 
91
91
  function getScriptSetupImports(componentImportPath, runtimeImportPath) {
92
- return `import UpNvueRoot from '${componentImportPath}'
92
+ return `import AppUpRoot from '${componentImportPath}'
93
93
  import { computed as __upComputed, onBeforeUnmount as __upOnBeforeUnmount, onMounted as __upOnMounted, ref as __upRef } from 'vue'
94
94
  import { onShow as __upOnShow } from '@dcloudio/uni-app'
95
95
  import {
@@ -161,7 +161,7 @@ const upThemeNavBgColor = __upComputed(() => {
161
161
  }
162
162
 
163
163
  function getOptionsImports(componentImportPath, runtimeImportPath) {
164
- return `import UpNvueRoot from '${componentImportPath}'
164
+ return `import AppUpRoot from '${componentImportPath}'
165
165
  import {
166
166
  applyNativeThemeUI as __upApplyNativeThemeUI,
167
167
  applyNativeThemeUIDeferred as __upApplyNativeThemeUIDeferred,
@@ -251,7 +251,7 @@ export async function transformNvuePage(
251
251
  const sfc = await parseSFC(code)
252
252
  const ms = new MagicString(code)
253
253
 
254
- wrapTemplate(ms, sfc, 'UpNvueRoot', getPageRootRefSource(sfc, enabledGlobalRef), true)
254
+ wrapTemplate(ms, sfc, 'AppUpRoot', getPageRootRefSource(sfc, enabledGlobalRef), true)
255
255
 
256
256
  if (sfc.scriptSetup) {
257
257
  ms.appendLeft(sfc.scriptSetup.loc.start.offset, getScriptSetupImports(componentImportPath, runtimeImportPath))
@@ -261,7 +261,7 @@ export async function transformNvuePage(
261
261
  ensureOptionsThemeMixin(ms, sfc.script.content)
262
262
  } else {
263
263
  ms.append(
264
- `\n<script>\n${getOptionsImports(componentImportPath, runtimeImportPath)}export default {\n components: { UpNvueRoot },\n mixins: [__upNvueThemeMixin]\n}\n</script>\n`
264
+ `\n<script>\n${getOptionsImports(componentImportPath, runtimeImportPath)}export default {\n components: { AppUpRoot },\n mixins: [__upNvueThemeMixin]\n}\n</script>\n`
265
265
  )
266
266
  }
267
267
 
package/libs/root/root.js CHANGED
@@ -2,6 +2,28 @@ import { MagicString } from 'vue/compiler-sfc'
2
2
 
3
3
  import { parseSFC } from './utils.js'
4
4
 
5
+ function ensureRootToastHostComponent(ms, scriptContent) {
6
+ const componentsMatch = scriptContent.match(/components\s*:\s*\{([\s\S]*?)\}/)
7
+ if (componentsMatch && /\bUpRootToastHost\b/.test(componentsMatch[1])) return
8
+
9
+ if (componentsMatch) {
10
+ ms.appendLeft(componentsMatch.index + componentsMatch[0].length, ' UpRootToastHost,')
11
+ return
12
+ }
13
+
14
+ const exportDefaultMatch = scriptContent.match(/export\s+default\s+(?:defineComponent\s*\()?\s*\{/)
15
+ if (exportDefaultMatch) {
16
+ ms.appendLeft(
17
+ exportDefaultMatch.index + exportDefaultMatch[0].length,
18
+ '\n components: { UpRootToastHost },'
19
+ )
20
+ }
21
+ }
22
+
23
+ function getRootToastHostImport(importPath) {
24
+ return `import UpRootToastHost from '${importPath}'\n`
25
+ }
26
+
5
27
  export async function registerUpApp(
6
28
  code,
7
29
  fileName = 'App.up',
@@ -21,17 +43,57 @@ import UpRootToastHost from "${rootToastHostPath}";`
21
43
  return ms
22
44
  }
23
45
 
24
- export async function rebuildUpApp(code, enabledVirtualHost = false) {
46
+ export async function rebuildUpApp(
47
+ code,
48
+ enabledVirtualHost = false,
49
+ { rootToastHostImportPath = '' } = {}
50
+ ) {
25
51
  const ms = new MagicString(code)
26
52
  const rootTagNameRE = /<(UpRootView|up-root-view)(?:\s*\/>|><\/\1>)/
27
- ms.replace(rootTagNameRE, '<slot />\n <ku-root-toast-host />')
53
+ const hasRootView = rootTagNameRE.test(code)
54
+ if (hasRootView) {
55
+ const rootToastHostTag = rootToastHostImportPath
56
+ ? '<UpRootToastHost />'
57
+ : '<ku-root-toast-host />'
58
+ ms.replace(rootTagNameRE, `<slot />\n ${rootToastHostTag}`)
59
+ }
60
+
61
+ const shouldInjectRootToastHost = hasRootView && rootToastHostImportPath
62
+ const sfc = enabledVirtualHost || shouldInjectRootToastHost
63
+ ? await parseSFC(code)
64
+ : null
65
+
66
+ if (shouldInjectRootToastHost) {
67
+ const importCode = getRootToastHostImport(rootToastHostImportPath)
68
+
69
+ if (sfc.scriptSetup) {
70
+ if (!/\bimport\s+UpRootToastHost\b/.test(sfc.scriptSetup.content)) {
71
+ ms.appendLeft(sfc.scriptSetup.loc.start.offset, importCode)
72
+ }
73
+ } else if (sfc.script) {
74
+ if (!/\bimport\s+UpRootToastHost\b/.test(sfc.script.content)) {
75
+ ms.appendLeft(sfc.script.loc.start.offset, importCode)
76
+ }
77
+ ensureRootToastHostComponent(ms, sfc.script.content)
78
+ }
79
+ }
28
80
 
29
81
  if (enabledVirtualHost) {
30
- const sfc = await parseSFC(code)
31
82
  if (sfc.script) {
32
83
  return ms
33
84
  }
34
85
  const langType = sfc.scriptSetup?.lang
86
+ if (!sfc.scriptSetup && shouldInjectRootToastHost) {
87
+ ms.append(`<script ${langType ? `lang="${langType}"` : ''}>
88
+ ${getRootToastHostImport(rootToastHostImportPath)}export default {
89
+ components: { UpRootToastHost },
90
+ options: {
91
+ virtualHost: true,
92
+ }
93
+ }
94
+ </script>`)
95
+ return ms
96
+ }
35
97
  ms.append(`<script ${langType ? `lang="${langType}"` : ''}>
36
98
  export default {
37
99
  options: {
@@ -40,5 +102,13 @@ export async function rebuildUpApp(code, enabledVirtualHost = false) {
40
102
  }\n</script>`)
41
103
  }
42
104
 
105
+ if (!sfc?.script && !sfc?.scriptSetup && shouldInjectRootToastHost) {
106
+ ms.append(`<script>
107
+ ${getRootToastHostImport(rootToastHostImportPath)}export default {
108
+ components: { UpRootToastHost },
109
+ }
110
+ </script>`)
111
+ }
112
+
43
113
  return ms
44
114
  }