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.
- package/changelog.md +2147 -1828
- package/components/u-action-sheet/props.js +3 -1
- package/components/u-action-sheet/u-action-sheet.vue +22 -2
- package/components/u-album/props.js +3 -1
- package/components/u-alert/props.js +4 -2
- package/components/u-avatar/props.js +4 -1
- package/components/u-avatar-group/props.js +4 -1
- package/components/u-back-top/props.js +4 -1
- package/components/u-badge/props.js +4 -1
- package/components/u-barcode/u-barcode.vue +44 -15
- package/components/u-box/props.js +5 -2
- package/components/u-button/props.js +4 -1
- package/components/u-button/u-button.vue +2 -5
- package/components/u-button/vue.scss +3 -3
- package/components/u-calendar/calendar.js +8 -0
- package/components/u-calendar/props.js +43 -1
- package/components/u-calendar/u-calendar.vue +16 -0
- package/components/u-calendar-strip/props.js +3 -1
- package/components/u-canvas/u-canvas.vue +1028 -423
- package/components/u-car-keyboard/props.js +3 -1
- package/components/u-card/props.js +3 -1
- package/components/u-cell/props.js +4 -1
- package/components/u-cell/u-cell.vue +9 -1
- package/components/u-cell-group/props.js +4 -1
- package/components/u-checkbox/props.js +4 -1
- package/components/u-checkbox/u-checkbox.vue +7 -3
- package/components/u-checkbox-group/props.js +3 -1
- package/components/u-circle-progress/props.js +4 -1
- package/components/u-code/props.js +4 -1
- package/components/u-code-input/props.js +4 -1
- package/components/u-col/props.js +4 -1
- package/components/u-collapse/props.js +4 -1
- package/components/u-collapse-item/props.js +4 -1
- package/components/u-color-picker/u-color-picker.vue +1 -0
- package/components/u-column-notice/props.js +4 -1
- package/components/u-count-down/props.js +4 -1
- package/components/u-count-to/props.js +4 -1
- package/components/u-cropper/u-cropper.vue +95 -51
- package/components/u-datetime-picker/props.js +4 -1
- package/components/u-datetime-picker/u-datetime-picker.vue +53 -4
- package/components/u-divider/props.js +4 -1
- package/components/u-dragsort/u-dragsort.vue +57 -32
- package/components/u-dropdown/props.js +3 -1
- package/components/u-dropdown-item/props.js +3 -1
- package/components/u-empty/props.js +4 -1
- package/components/u-form/props.js +4 -1
- package/components/u-form-item/props.js +4 -1
- package/components/u-gap/props.js +4 -1
- package/components/u-grid/props.js +4 -1
- package/components/u-grid-item/props.js +4 -1
- package/components/u-guide/props.js +3 -1
- package/components/u-icon/props.js +4 -1
- package/components/u-icon/u-icon.vue +11 -2
- package/components/u-icon/upicon.ttf +0 -0
- package/components/u-icon/util.js +103 -10
- package/components/u-image/props.js +4 -1
- package/components/u-image/u-image.vue +280 -267
- package/components/u-index-anchor/props.js +4 -1
- package/components/u-index-item/props.js +2 -1
- package/components/u-index-item/u-index-item.vue +1 -1
- package/components/u-index-list/props.js +4 -1
- package/components/u-index-list/u-index-list.vue +1 -1
- package/components/u-input/props.js +3 -1
- package/components/u-keyboard/props.js +4 -1
- package/components/u-line/props.js +4 -1
- package/components/u-line-progress/props.js +6 -3
- package/components/u-link/props.js +4 -1
- package/components/u-list/props.js +4 -1
- package/components/u-list-item/props.js +4 -1
- package/components/u-loading-icon/props.js +4 -1
- package/components/u-loading-page/props.js +3 -1
- package/components/u-loadmore/props.js +4 -1
- package/components/u-markdown/u-markdown.vue +45 -3
- package/components/u-modal/props.js +4 -1
- package/components/u-navbar/props.js +4 -2
- package/components/u-navbar/u-navbar.vue +15 -9
- package/components/u-no-network/props.js +4 -1
- package/components/u-notice-bar/props.js +4 -1
- package/components/u-notify/props.js +4 -1
- package/components/u-novel-reader/content-normalizer.js +80 -0
- package/components/u-novel-reader/layout-engine.js +225 -0
- package/components/u-novel-reader/measure-adapter.js +69 -0
- package/components/u-novel-reader/novelReader.js +35 -0
- package/components/u-novel-reader/persistence.js +144 -0
- package/components/u-novel-reader/props.js +100 -0
- package/components/u-novel-reader/reader-catalog.vue +234 -0
- package/components/u-novel-reader/reader-content.vue +226 -0
- package/components/u-novel-reader/reader-core.js +151 -0
- package/components/u-novel-reader/reader-settings.vue +325 -0
- package/components/u-novel-reader/reader-toolbar.vue +313 -0
- package/components/u-novel-reader/theme-vars.scss +49 -0
- package/components/u-novel-reader/u-novel-reader.vue +836 -0
- package/components/u-number-box/props.js +4 -1
- package/components/u-number-box/u-number-box.vue +2 -2
- package/components/u-number-keyboard/props.js +4 -1
- package/components/u-overlay/props.js +4 -1
- package/components/u-pagination/u-pagination.vue +60 -39
- package/components/u-parse/props.js +4 -1
- package/components/u-picker/props.js +4 -1
- package/components/u-picker-column/props.js +3 -1
- package/components/u-popover/props.js +2 -1
- package/components/u-popup/props.js +4 -1
- package/components/u-poster/u-poster.vue +246 -214
- package/components/u-qrcode/qrcode.js +105 -97
- package/components/u-qrcode/u-qrcode.vue +242 -289
- package/components/u-radio/props.js +4 -1
- package/components/u-radio/u-radio.vue +7 -3
- package/components/u-radio-group/props.js +4 -1
- package/components/u-rate/props.js +4 -1
- package/components/u-read-more/props.js +4 -1
- package/components/u-row/props.js +4 -1
- package/components/u-row-notice/props.js +4 -1
- package/components/u-safe-bottom/props.js +2 -1
- package/components/u-scroll-list/props.js +4 -1
- package/components/u-scroll-list/scrollWxs.wxs +1 -1
- package/components/u-search/props.js +3 -1
- package/components/u-skeleton/props.js +4 -1
- package/components/u-slider/props.js +3 -1
- package/components/u-slider/u-slider.vue +71 -29
- package/components/u-status-bar/props.js +4 -1
- package/components/u-steps/props.js +4 -1
- package/components/u-steps-item/props.js +4 -1
- package/components/u-sticky/props.js +4 -1
- package/components/u-sticky/u-sticky.vue +11 -0
- package/components/u-subsection/props.js +3 -1
- package/components/u-swipe-action/props.js +4 -1
- package/components/u-swipe-action-item/index.wxs +43 -25
- package/components/u-swipe-action-item/nvue.js +9 -0
- package/components/u-swipe-action-item/other.js +32 -21
- package/components/u-swipe-action-item/props.js +9 -1
- package/components/u-swipe-action-item/swipeActionItem.js +1 -0
- package/components/u-swipe-action-item/u-swipe-action-item.vue +42 -4
- package/components/u-swiper/props.js +9 -1
- package/components/u-swiper/swiper.js +1 -0
- package/components/u-swiper/u-swiper.vue +2 -0
- package/components/u-swiper-indicator/props.js +4 -1
- package/components/u-switch/props.js +4 -1
- package/components/u-switch/u-switch.vue +1 -1
- package/components/u-tabbar/props.js +3 -1
- package/components/u-tabbar/u-tabbar.vue +2 -1
- package/components/u-tabbar-item/props.js +4 -1
- package/components/u-tabbar-item/u-tabbar-item.vue +64 -21
- package/components/u-table/props.js +3 -1
- package/components/u-table2/tableRow.vue +155 -69
- package/components/u-table2/u-table2.vue +327 -137
- package/components/u-tabs/props.js +4 -1
- package/components/u-tabs/u-tabs.vue +11 -8
- package/components/u-tabs-item/props.js +3 -1
- package/components/u-tabs-pro/u-tabs-pro.vue +212 -0
- package/components/u-tag/props.js +4 -1
- package/components/u-td/props.js +3 -1
- package/components/u-text/props.js +4 -1
- package/components/u-text/text.js +1 -1
- package/components/u-text/u-text.vue +18 -6
- package/components/u-textarea/props.js +3 -1
- package/components/u-textarea/u-textarea.vue +16 -5
- package/components/u-th/props.js +3 -1
- package/components/u-toolbar/props.js +4 -1
- package/components/u-tooltip/props.js +10 -2
- package/components/u-tooltip/tooltip.js +2 -1
- package/components/u-tooltip/u-tooltip.vue +31 -3
- package/components/u-tr/props.js +3 -1
- package/components/u-transition/nvue-ani-map.js +75 -68
- package/components/u-transition/props.js +4 -1
- package/components/u-transition/transitionMixin.js +164 -163
- package/components/u-upload/props.js +4 -1
- package/components/u-upload/u-upload.vue +48 -41
- package/components/u-waterfall/u-waterfall.vue +162 -110
- package/index.js +65 -8
- package/libs/config/config.js +1 -1
- package/libs/config/props.js +180 -204
- package/libs/css/components.scss +3 -0
- package/libs/function/index.js +66 -0
- package/libs/function/uni-api-shims.js +29 -0
- package/libs/i18n/index.js +71 -36
- package/libs/i18n/locale-packs.js +11 -0
- package/libs/i18n/locales/all.js +23 -0
- package/libs/i18n/locales/{de.json → de.js} +1 -1
- package/libs/i18n/locales/{en.json → en.js} +2 -2
- package/libs/i18n/locales/{es.json → es.js} +1 -1
- package/libs/i18n/locales/{fr.json → fr.js} +2 -2
- package/libs/i18n/locales/{ja.json → ja.js} +1 -1
- package/libs/i18n/locales/{ko.json → ko.js} +1 -1
- package/libs/i18n/locales/{ru.json → ru.js} +1 -1
- package/libs/i18n/locales/{th.json → th.js} +1 -1
- package/libs/i18n/locales/{zh-Hans.json → zh-Hans.js} +1 -1
- package/libs/i18n/locales/{zh-Hant.json → zh-Hant.js} +1 -1
- package/libs/mixin/mixin.js +18 -54
- package/libs/root/index.js +78 -5
- package/libs/root/page.js +7 -7
- package/libs/root/root.js +73 -3
- package/libs/util/app-nvue-webview-canvas.js +486 -0
- package/libs/util/gcanvas/bridge/bridge-weex.js +10 -7
- package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStylePattern.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/ActiveInfo.js +0 -0
- package/libs/util/gcanvas/context-webgl/Buffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/Framebuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLenum.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLmethod.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLtype.js +0 -0
- package/libs/util/gcanvas/context-webgl/Program.js +0 -0
- package/libs/util/gcanvas/context-webgl/Renderbuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/Shader.js +0 -0
- package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +0 -0
- package/libs/util/gcanvas/context-webgl/Texture.js +0 -0
- package/libs/util/gcanvas/context-webgl/UniformLocation.js +0 -0
- package/libs/util/gcanvas/context-webgl/classUtils.js +0 -0
- package/libs/util/gcanvas/env/canvas.js +0 -0
- package/libs/util/gcanvas/env/image.js +0 -0
- package/libs/util/gcanvas/env/tool.js +0 -0
- package/libs/util/gcanvas/index.js +3 -3
- package/package.json +4 -5
- package/tsconfig.json +18 -0
- package/types/comps/calendar.d.ts +38 -0
- package/types/comps/checkbox.d.ts +12 -0
- package/types/comps/lineProgress.d.ts +5 -0
- package/types/comps/navbar.d.ts +3 -3
- package/types/comps/swipeActionItem.d.ts +13 -0
- package/types/comps/swiper.d.ts +5 -0
- package/types/comps/tabs.d.ts +2 -1
- package/types/comps/text.d.ts +1 -1
- package/types/comps/tooltip.d.ts +36 -1
- package/types/func.d.ts +23 -0
- package/types/index.d.ts +1 -0
- /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": "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
|
+
}
|
package/libs/mixin/mixin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineMixin } from '../vue'
|
|
2
|
-
import { deepMerge, $parent,
|
|
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
|
|
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.
|
|
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 (
|
|
100
|
-
|
|
96
|
+
if (instance) {
|
|
97
|
+
instance.__upUCache = mergeU
|
|
98
|
+
return instance.__upUCache
|
|
101
99
|
}
|
|
102
|
-
return
|
|
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
|
-
|
|
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变量
|
package/libs/root/index.js
CHANGED
|
@@ -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
|
|
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(
|
|
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,
|
|
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('
|
|
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, '
|
|
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: {
|
|
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
|
|
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
|
|
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, '
|
|
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: {
|
|
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(
|
|
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
|
-
|
|
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
|
}
|