diff --git a/packages/uni-app/dist/uni-app.cjs.js b/packages/uni-app/dist/uni-app.cjs.js index f2931ef2cacff6245ba25d3ff1c6ff67ee736be2..32bf2eda77cccb2a79a6539b10974791a8fd2d1a 100644 --- a/packages/uni-app/dist/uni-app.cjs.js +++ b/packages/uni-app/dist/uni-app.cjs.js @@ -283,12 +283,32 @@ function initUtsProxyClass({ package: pkg, class: cls, constructor: { params: co return Reflect.get(target, name, receiver); }, }); +} +function initUtsPackageName(name, is_uni_modules) { + if (typeof plus !== 'undefined' && plus.os.name === 'Android') { + return 'uts.sdk.' + (is_uni_modules ? 'modules.' : '') + name; + } + return ''; +} +function initUtsClassName(name, is_uni_modules) { + if (typeof plus === 'undefined') { + return ''; + } + if (plus.os.name === 'Android') { + return 'IndexKt'; + } + if (plus.os.name === 'iOS') { + return 'UTSSDK' + (is_uni_modules ? 'Modules' : '') + shared.capitalize(name); + } + return ''; } exports.formatAppLog = formatAppLog; exports.formatH5Log = formatH5Log; exports.getCurrentSubNVue = getCurrentSubNVue; exports.getSsrGlobalData = getSsrGlobalData; +exports.initUtsClassName = initUtsClassName; +exports.initUtsPackageName = initUtsPackageName; exports.initUtsProxyClass = initUtsProxyClass; exports.initUtsProxyFunction = initUtsProxyFunction; exports.onAddToFavorites = onAddToFavorites; diff --git a/packages/uni-app/dist/uni-app.d.ts b/packages/uni-app/dist/uni-app.d.ts index 3a308a1a018b4e38565f4a97ae68c5b26c975135..35064f508616dd5843bb8830e3a72ee0157dab5e 100644 --- a/packages/uni-app/dist/uni-app.d.ts +++ b/packages/uni-app/dist/uni-app.d.ts @@ -39,6 +39,10 @@ export declare function getCurrentSubNVue(): any; export declare function getSsrGlobalData(): any; +export declare function initUtsClassName(name: string, is_uni_modules: boolean): string; + +export declare function initUtsPackageName(name: string, is_uni_modules: boolean): string; + export declare function initUtsProxyClass({ package: pkg, class: cls, constructor: { params: constructorParams }, methods, props, staticProps, staticMethods, }: ProxyClassOptions): any; export declare const initUtsProxyFunction: typeof initUtsStaticMethod; diff --git a/packages/uni-app/dist/uni-app.es.js b/packages/uni-app/dist/uni-app.es.js index 847b6f807c00dfef7352389aa6efd3448a1233f7..dfb6c029cdd841a7fea50468a9c729774b95d117 100644 --- a/packages/uni-app/dist/uni-app.es.js +++ b/packages/uni-app/dist/uni-app.es.js @@ -1,5 +1,5 @@ import { shallowRef, ref, getCurrentInstance, isInSSRComponentSetup, injectHook } from 'vue'; -import { hasOwn, isString, extend, isPlainObject } from '@vue/shared'; +import { hasOwn, isString, extend, capitalize, isPlainObject } from '@vue/shared'; import { sanitise, UNI_SSR_DATA, UNI_SSR_GLOBAL_DATA, UNI_SSR, ON_SHOW, ON_HIDE, ON_LAUNCH, ON_ERROR, ON_THEME_CHANGE, ON_PAGE_NOT_FOUND, ON_UNHANDLE_REJECTION, ON_INIT, ON_LOAD, ON_READY, ON_UNLOAD, ON_RESIZE, ON_BACK_PRESS, ON_PAGE_SCROLL, ON_TAB_ITEM_TAP, ON_REACH_BOTTOM, ON_PULL_DOWN_REFRESH, ON_SAVE_EXIT_STATE, ON_SHARE_TIMELINE, ON_ADD_TO_FAVORITES, ON_SHARE_APP_MESSAGE, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED } from '@dcloudio/uni-shared'; function getSSRDataType() { @@ -251,6 +251,24 @@ function initUtsProxyClass({ package: pkg, class: cls, constructor: { params: co return Reflect.get(target, name, receiver); }, }); +} +function initUtsPackageName(name, is_uni_modules) { + if (typeof plus !== 'undefined' && plus.os.name === 'Android') { + return 'uts.sdk.' + (is_uni_modules ? 'modules.' : '') + name; + } + return ''; +} +function initUtsClassName(name, is_uni_modules) { + if (typeof plus === 'undefined') { + return ''; + } + if (plus.os.name === 'Android') { + return 'IndexKt'; + } + if (plus.os.name === 'iOS') { + return 'UTSSDK' + (is_uni_modules ? 'Modules' : '') + capitalize(name); + } + return ''; } -export { formatAppLog, formatH5Log, getCurrentSubNVue, getSsrGlobalData, initUtsProxyClass, initUtsProxyFunction, onAddToFavorites, onBackPress, onError, onHide, onInit, onLaunch, onLoad, onNavigationBarButtonTap, onNavigationBarSearchInputChanged, onNavigationBarSearchInputClicked, onNavigationBarSearchInputConfirmed, onNavigationBarSearchInputFocusChanged, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onSaveExitState, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, requireNativePlugin, resolveEasycom, shallowSsrRef, ssrRef }; +export { formatAppLog, formatH5Log, getCurrentSubNVue, getSsrGlobalData, initUtsClassName, initUtsPackageName, initUtsProxyClass, initUtsProxyFunction, onAddToFavorites, onBackPress, onError, onHide, onInit, onLaunch, onLoad, onNavigationBarButtonTap, onNavigationBarSearchInputChanged, onNavigationBarSearchInputClicked, onNavigationBarSearchInputConfirmed, onNavigationBarSearchInputFocusChanged, onPageNotFound, onPageScroll, onPullDownRefresh, onReachBottom, onReady, onResize, onSaveExitState, onShareAppMessage, onShareTimeline, onShow, onTabItemTap, onThemeChange, onUnhandledRejection, onUnload, requireNativePlugin, resolveEasycom, shallowSsrRef, ssrRef }; diff --git a/packages/uni-app/src/index.ts b/packages/uni-app/src/index.ts index a331a7cb7ca1d15487b32e37637364121c29e348..285ce3458dd31b1ee963d23bac45340392090ca0 100644 --- a/packages/uni-app/src/index.ts +++ b/packages/uni-app/src/index.ts @@ -3,4 +3,9 @@ export * from './api' export * from './hbx' export * from './utils' export * from './apiLifecycle' -export { initUtsProxyClass, initUtsProxyFunction } from './uts' +export { + initUtsProxyClass, + initUtsProxyFunction, + initUtsClassName, + initUtsPackageName, +} from './uts' diff --git a/packages/uni-app/src/uts.ts b/packages/uni-app/src/uts.ts index 0903ee16c5648ad07b3296fd94d48a673a2898de..b90656dd627652b42fcb6b83e1808fb83ede2952 100644 --- a/packages/uni-app/src/uts.ts +++ b/packages/uni-app/src/uts.ts @@ -1,5 +1,6 @@ -import { isPlainObject, hasOwn, extend } from '@vue/shared' +import { isPlainObject, hasOwn, extend, capitalize } from '@vue/shared' declare const uni: any +declare const plus: any let callbackId = 1 let proxy: any const callbacks: Record = {} @@ -283,3 +284,23 @@ export function initUtsProxyClass({ }, }) } + +export function initUtsPackageName(name: string, is_uni_modules: boolean) { + if (typeof plus !== 'undefined' && plus.os.name === 'Android') { + return 'uts.sdk.' + (is_uni_modules ? 'modules.' : '') + name + } + return '' +} + +export function initUtsClassName(name: string, is_uni_modules: boolean) { + if (typeof plus === 'undefined') { + return '' + } + if (plus.os.name === 'Android') { + return 'IndexKt' + } + if (plus.os.name === 'iOS') { + return 'UTSSDK' + (is_uni_modules ? 'Modules' : '') + capitalize(name) + } + return '' +} diff --git a/packages/uni-cli-shared/src/resolve.ts b/packages/uni-cli-shared/src/resolve.ts index a8fd2a2b26031275eff8240f7a7945972f56e4d6..1edd85ac7f1a4b33f2fcce17e44b5e6ff3573f69 100644 --- a/packages/uni-cli-shared/src/resolve.ts +++ b/packages/uni-cli-shared/src/resolve.ts @@ -131,23 +131,27 @@ export function resolveUtsModule( const parts = normalizePath(id).split('/') const parentDir = parts[parts.length - 2] if (parentDir === 'uni_modules' || parentDir === 'utssdk') { - const index = path.resolve(id, 'index.uts') + const resolvePlatformDir = (p: typeof process.env.UNI_UTS_PLATFORM) => { + return path.resolve(id, parentDir === 'uni_modules' ? 'utssdk' : '', p) + } + // 未指定具体的平台 + if (platform === 'app') { + platform = 'app-android' + } + let index = resolveUtsFile(resolvePlatformDir(platform)) + if (index) { + return index + } + index = path.resolve(id, 'index.uts') if (fs.existsSync(index)) { return index } - if ( - parentDir === 'uni_modules' && - !fs.existsSync(path.join(id, 'utssdk')) - ) { - // uni_modules/test-plugin/utssdk不存在 - return + // 如果是 android 或 ios,本平台没有,则查找一下另一个平台 + if (platform === 'app-android') { + return resolveUtsFile(resolvePlatformDir('app-ios')) + } else if (platform === 'app-ios') { + return resolveUtsFile(resolvePlatformDir('app-android')) } - const platformDir = path.resolve( - id, - parentDir === 'uni_modules' ? 'utssdk' : '', - platform - ) - return resolveUtsFile(platformDir) } } } diff --git a/packages/uni-components/dist/components.js b/packages/uni-components/dist/components.js index 5ed6f7ed95dd53393b6e5e88c494ebe319d5a270..68d1c2d45842ecb079557fa2f54ff3b4b1cd872e 100644 --- a/packages/uni-components/dist/components.js +++ b/packages/uni-components/dist/components.js @@ -2246,6 +2246,14 @@ const nvuePickerViewProps = extend({}, pickerViewProps, { height: { type: [Number, String], default: 0 + }, + maskTopStyle: { + type: String, + default: "" + }, + maskBottomStyle: { + type: String, + default: "" } }); var PickerView = defineComponent({ @@ -2371,7 +2379,8 @@ var PickerViewColumn = defineComponent({ const getPickerViewColumn = inject("getPickerViewColumn"); const current = getPickerViewColumn(instance); const indicatorStyle = computed(() => getStyle(pickerViewProps2.indicatorStyle)); - const maskStyle = computed(() => getStyle(pickerViewProps2.maskStyle)); + const maskTopStyle = computed(() => getStyle(pickerViewProps2.maskTopStyle)); + const maskBottomStyle = computed(() => getStyle(pickerViewProps2.maskBottomStyle)); let indicatorHeight = ref(0); indicatorHeight.value = getHeight(indicatorStyle.value); let pickerViewHeight = ref(0); @@ -2445,18 +2454,17 @@ var PickerViewColumn = defineComponent({ paddingBottom: `${padding}px` } }, [createScrollViewChild(children)])]), createVNode("u-scalable", { - "class": "uni-picker-view-mask", - "style": maskStyle.value + "class": "uni-picker-view-mask" }, [createVNode("u-scalable", { "class": "uni-picker-view-mask uni-picker-view-mask-top", - "style": { + "style": extend({}, maskTopStyle.value, { bottom: maskPosition - } + }) }, null), createVNode("u-scalable", { "class": "uni-picker-view-mask uni-picker-view-mask-bottom", - "style": { + "style": extend({}, maskBottomStyle.value, { top: maskPosition - } + }) }, null)]), createVNode("u-scalable", { "ref": indicatorRef, "class": "uni-picker-view-indicator", diff --git a/packages/uni-h5/dist/uni-h5.cjs.js b/packages/uni-h5/dist/uni-h5.cjs.js index 6097aa1924b724c24f5d60ee581d92592df09f26..fe3bdc34d8ab085ebcf1b32e5c798b16cad67002 100644 --- a/packages/uni-h5/dist/uni-h5.cjs.js +++ b/packages/uni-h5/dist/uni-h5.cjs.js @@ -6344,7 +6344,8 @@ const useSwiperNavigation = (rootRef, props2, state, onSwiperDotClick, swiperCon onMouseover: (event) => navigationHover(event, "over"), onMouseout: (event) => navigationHover(event, "out") }; - function navigationClick(type) { + function navigationClick($event, type) { + $event.stopPropagation(); const swiperItemLength = swiperContext.value.length; let _current = state.current; switch (type) { @@ -6364,7 +6365,9 @@ const useSwiperNavigation = (rootRef, props2, state, onSwiperDotClick, swiperCon onSwiperDotClick(_current); } const createNavigationSVG = () => createSvgIconVNode(ICON_PATH_BACK, props2.navigationColor, 26); - const _mouseMove = (e2) => { + let setHideNavigationTimer; + const _mousemove = (e2) => { + clearTimeout(setHideNavigationTimer); const { clientX, clientY @@ -6377,22 +6380,29 @@ const useSwiperNavigation = (rootRef, props2, state, onSwiperDotClick, swiperCon width, height } = rootRef.value.getBoundingClientRect(); + let hide = false; if (props2.vertical) { - hideNavigation.value = !(clientY - top < height / 3 || bottom - clientY < height / 3); + hide = !(clientY - top < height / 3 || bottom - clientY < height / 3); } else { - hideNavigation.value = !(clientX - left < width / 3 || right - clientX < width / 3); + hide = !(clientX - left < width / 3 || right - clientX < width / 3); } + if (hide) { + return setHideNavigationTimer = setTimeout(() => { + hideNavigation.value = hide; + }, 300); + } + hideNavigation.value = hide; }; - const _mouseOut = () => { + const _mouseleave = () => { hideNavigation.value = true; }; function swiperAddMouseEvent() { if (rootRef.value) { - rootRef.value.removeEventListener("mousemove", _mouseMove); - rootRef.value.removeEventListener("mouseout", _mouseOut); + rootRef.value.removeEventListener("mousemove", _mousemove); + rootRef.value.removeEventListener("mouseleave", _mouseleave); if (isNavigationAuto) { - rootRef.value.addEventListener("mousemove", _mouseMove); - rootRef.value.addEventListener("mouseout", _mouseOut); + rootRef.value.addEventListener("mousemove", _mousemove); + rootRef.value.addEventListener("mouseleave", _mouseleave); } } } @@ -6406,12 +6416,12 @@ const useSwiperNavigation = (rootRef, props2, state, onSwiperDotClick, swiperCon "class": ["uni-swiper-navigation uni-swiper-navigation-prev", shared.extend({ "uni-swiper-navigation-disabled": prevDisabled }, navigationClass)], - "onClick": () => navigationClick("prev") + "onClick": (e2) => navigationClick(e2, "prev") }, navigationAttr), [createNavigationSVG()], 16, ["onClick"]), vue.createVNode("div", vue.mergeProps({ "class": ["uni-swiper-navigation uni-swiper-navigation-next", shared.extend({ "uni-swiper-navigation-disabled": nextDisabled }, navigationClass)], - "onClick": () => navigationClick("next") + "onClick": (e2) => navigationClick(e2, "next") }, navigationAttr), [createNavigationSVG()], 16, ["onClick"])]); } return null; diff --git a/packages/uni-h5/dist/uni-h5.es.js b/packages/uni-h5/dist/uni-h5.es.js index 3550d72d8e94675f04d13b1c4802652c88fa4b4e..2ec88d8de56d1196e3894ef0a904cb0be02b8cfd 100644 --- a/packages/uni-h5/dist/uni-h5.es.js +++ b/packages/uni-h5/dist/uni-h5.es.js @@ -13339,7 +13339,8 @@ const useSwiperNavigation = (rootRef, props2, state2, onSwiperDotClick, swiperCo onMouseover: (event) => navigationHover(event, "over"), onMouseout: (event) => navigationHover(event, "out") }; - function navigationClick(type) { + function navigationClick($event, type) { + $event.stopPropagation(); const swiperItemLength = swiperContext.value.length; let _current = state2.current; switch (type) { @@ -13359,7 +13360,9 @@ const useSwiperNavigation = (rootRef, props2, state2, onSwiperDotClick, swiperCo onSwiperDotClick(_current); } const createNavigationSVG = () => createSvgIconVNode(ICON_PATH_BACK, props2.navigationColor, 26); - const _mouseMove = (e2) => { + let setHideNavigationTimer; + const _mousemove = (e2) => { + clearTimeout(setHideNavigationTimer); const { clientX, clientY @@ -13372,22 +13375,29 @@ const useSwiperNavigation = (rootRef, props2, state2, onSwiperDotClick, swiperCo width, height } = rootRef.value.getBoundingClientRect(); + let hide = false; if (props2.vertical) { - hideNavigation.value = !(clientY - top < height / 3 || bottom - clientY < height / 3); + hide = !(clientY - top < height / 3 || bottom - clientY < height / 3); } else { - hideNavigation.value = !(clientX - left < width / 3 || right - clientX < width / 3); + hide = !(clientX - left < width / 3 || right - clientX < width / 3); } + if (hide) { + return setHideNavigationTimer = setTimeout(() => { + hideNavigation.value = hide; + }, 300); + } + hideNavigation.value = hide; }; - const _mouseOut = () => { + const _mouseleave = () => { hideNavigation.value = true; }; function swiperAddMouseEvent() { if (rootRef.value) { - rootRef.value.removeEventListener("mousemove", _mouseMove); - rootRef.value.removeEventListener("mouseout", _mouseOut); + rootRef.value.removeEventListener("mousemove", _mousemove); + rootRef.value.removeEventListener("mouseleave", _mouseleave); if (isNavigationAuto) { - rootRef.value.addEventListener("mousemove", _mouseMove); - rootRef.value.addEventListener("mouseout", _mouseOut); + rootRef.value.addEventListener("mousemove", _mousemove); + rootRef.value.addEventListener("mouseleave", _mouseleave); } } } @@ -13402,12 +13412,12 @@ const useSwiperNavigation = (rootRef, props2, state2, onSwiperDotClick, swiperCo "class": ["uni-swiper-navigation uni-swiper-navigation-prev", extend({ "uni-swiper-navigation-disabled": prevDisabled }, navigationClass)], - "onClick": () => navigationClick("prev") + "onClick": (e2) => navigationClick(e2, "prev") }, navigationAttr), [createNavigationSVG()], 16, ["onClick"]), createVNode("div", mergeProps({ "class": ["uni-swiper-navigation uni-swiper-navigation-next", extend({ "uni-swiper-navigation-disabled": nextDisabled }, navigationClass)], - "onClick": () => navigationClick("next") + "onClick": (e2) => navigationClick(e2, "next") }, navigationAttr), [createNavigationSVG()], 16, ["onClick"])]); } return null; @@ -17857,6 +17867,20 @@ var ImagePreview = /* @__PURE__ */ defineSystemComponent({ function onChange2(event) { indexRef.value = event.detail.current; } + const closeBtnStyle = { + position: "absolute", + "box-sizing": "border-box", + top: "0", + left: "0", + width: "60px", + height: "44px", + padding: "6px", + "line-height": "32px", + "font-size": "26px", + color: "white", + "text-align": "center", + cursor: "pointer" + }; return () => { let _slot; return createVNode("div", { @@ -17873,6 +17897,7 @@ var ImagePreview = /* @__PURE__ */ defineSystemComponent({ }, "onClick": onClick }, [createVNode(Swiper, { + "navigation": "auto", "current": indexRef.value, "onChange": onChange2, "indicator-dots": false, @@ -17891,7 +17916,9 @@ var ImagePreview = /* @__PURE__ */ defineSystemComponent({ }))) ? _slot : { default: () => [_slot], _: 1 - }, 8, ["current", "onChange"])], 8, ["onClick"]); + }, 8, ["current", "onChange"]), createVNode("div", { + "style": closeBtnStyle + }, [createSvgIconVNode(ICON_PATH_CLOSE, "#ffffff", 26)], 4)], 8, ["onClick"]); }; } }); diff --git a/packages/uni-uts-vite/src/plugins/v1.ts b/packages/uni-uts-vite/src/plugins/v1.ts index 74a4b7df81a22fde406d251bef1709c665256a7b..89d4517edae028ca66b75536f676ab50c4fc8f2f 100644 --- a/packages/uni-uts-vite/src/plugins/v1.ts +++ b/packages/uni-uts-vite/src/plugins/v1.ts @@ -15,6 +15,10 @@ import { VariableDeclaration, } from '../../types/types' import { getCompiler } from '../utils/compiler' +import { + createResolveTypeReferenceName, + resolvePackage, +} from '../utils/compiler/utils' export function uniUtsV1Plugin(): Plugin { let isFirst = true @@ -28,6 +32,7 @@ export function uniUtsV1Plugin(): Plugin { } // 目前仅支持 app-android|app-ios if ( + process.env.UNI_UTS_PLATFORM !== 'app' && process.env.UNI_UTS_PLATFORM !== 'app-android' && process.env.UNI_UTS_PLATFORM !== 'app-ios' ) { @@ -37,12 +42,11 @@ export function uniUtsV1Plugin(): Plugin { if (path.extname(filename) !== '.uts') { return } - const { compile, parsePackage, createResolveTypeReferenceName } = - getCompiler( - process.env.UNI_UTS_PLATFORM === 'app-ios' ? 'swift' : 'kotlin' - ) - const pkg = parsePackage(filename) - if (!pkg.class) { + const { compile } = getCompiler( + process.env.UNI_UTS_PLATFORM === 'app-ios' ? 'swift' : 'kotlin' + ) + const pkg = resolvePackage(filename) + if (!pkg) { return } // 懒加载 uts 编译器 @@ -50,11 +54,23 @@ export function uniUtsV1Plugin(): Plugin { const { parse } = require('@dcloudio/uts') const ast = await parse(preJs(code), { noColor: isInHBuilderX() }) code = ` -import { initUtsProxyClass, initUtsProxyFunction } from '@dcloudio/uni-app' -const pkg = '${pkg.package}' -const cls = '${pkg.class}' +import { initUtsProxyClass, initUtsProxyFunction, initUtsPackageName, initUtsClassName } from '@dcloudio/uni-app' +const name = '${pkg.name}' +const is_uni_modules = ${pkg.is_uni_modules} +const pkg = initUtsPackageName(name, is_uni_modules) +const cls = initUtsClassName(name, is_uni_modules) ${genProxyCode(ast, createResolveTypeReferenceName(pkg.namespace, ast))} ` + // 平台不匹配,不走平台代码编译,仅生成js代码 + if ( + process.env.UNI_UTS_PLATFORM === 'app' || + (process.env.UNI_UTS_PLATFORM === 'app-android' && + id.includes('app-ios')) || + (process.env.UNI_UTS_PLATFORM === 'app-ios' && + id.includes('app-android')) + ) { + return code + } const res = await compile(id) if (process.env.UNI_UTS_PLATFORM === 'app-android') { if (!isFirst && res) { diff --git a/packages/uni-uts-vite/src/utils/compiler/index.ts b/packages/uni-uts-vite/src/utils/compiler/index.ts index 0d8644e6fc1f2daeb28f3551842c2dae4c5fdbf6..3d2cffa52ad1bb67cd117b216bdef4fe695ab044 100644 --- a/packages/uni-uts-vite/src/utils/compiler/index.ts +++ b/packages/uni-uts-vite/src/utils/compiler/index.ts @@ -1,25 +1,13 @@ -import { - compileKotlin, - parseKotlinPackage, - createKotlinResolveTypeReferenceName, -} from './kotlin' -import { - compileSwift, - parseSwiftPackage, - createSwiftResolveTypeReferenceName, -} from './swift' +import { compileKotlin } from './kotlin' +import { compileSwift } from './swift' export function getCompiler(type: 'kotlin' | 'swift') { if (type === 'swift') { return { compile: compileSwift, - parsePackage: parseSwiftPackage, - createResolveTypeReferenceName: createSwiftResolveTypeReferenceName, } } return { compile: compileKotlin, - parsePackage: parseKotlinPackage, - createResolveTypeReferenceName: createKotlinResolveTypeReferenceName, } } diff --git a/packages/uni-uts-vite/src/utils/compiler/kotlin.ts b/packages/uni-uts-vite/src/utils/compiler/kotlin.ts index b7ccd94b272dfe999e85629bc56ed7f1c44153a5..7c4fdf648a480fc30b40e478b54a0602ecb1c8ff 100644 --- a/packages/uni-uts-vite/src/utils/compiler/kotlin.ts +++ b/packages/uni-uts-vite/src/utils/compiler/kotlin.ts @@ -27,15 +27,13 @@ export function createKotlinResolveTypeReferenceName( return (name: string) => name } -export function parseKotlinPackage(filename: string) { +function parseKotlinPackage(filename: string) { const res = resolvePackage(filename) if (!res) { - return { package: '', namespace: '', class: '' } + return { package: '' } } return { package: 'uts.sdk.' + (res.is_uni_modules ? 'modules.' : '') + res.name, - namespace: '', - class: 'IndexKt', } } diff --git a/packages/uni-uts-vite/src/utils/compiler/swift.ts b/packages/uni-uts-vite/src/utils/compiler/swift.ts index dae9908464031b4c8430625c489ac26d4812368d..1a4b2de49f7470a27e9ae765e0f0292df6dfbfcb 100644 --- a/packages/uni-uts-vite/src/utils/compiler/swift.ts +++ b/packages/uni-uts-vite/src/utils/compiler/swift.ts @@ -1,46 +1,18 @@ import { isInHBuilderX, resolveSourceMapPath } from '@dcloudio/uni-cli-shared' import { capitalize } from '@vue/shared' -import { Module, ModuleItem } from '../../../types/types' import { genUTSPlatformResource, getUtsCompiler, resolvePackage } from './utils' -function resolveTypeAliasDeclNames(items: ModuleItem[]) { - const names: string[] = [] - items.forEach((item) => { - if (item.type === 'TsTypeAliasDeclaration') { - names.push(item.id.value) - } - }) - return names -} - -export function createSwiftResolveTypeReferenceName( - namespace: string, - ast: Module -) { - const names = resolveTypeAliasDeclNames(ast.body) - return (name: string) => { - if (names.includes(name)) { - return namespace + capitalize(name) - } - return name - } -} - -export function parseSwiftPackage(filename: string) { +function parseSwiftPackage(filename: string) { const res = resolvePackage(filename) if (!res) { return { - package: '', namespace: '', - class: '', } } const namespace = 'UTSSDK' + (res.is_uni_modules ? 'Modules' : '') + capitalize(res.name) return { - package: '', namespace, - class: namespace + 'IndexSwift', } } diff --git a/packages/uni-uts-vite/src/utils/compiler/utils.ts b/packages/uni-uts-vite/src/utils/compiler/utils.ts index 9d708a2ea7336092ad034ca56a6cc6f8ea7454b3..184580a230745c4ed1680c0d6853a618da3f6bcf 100644 --- a/packages/uni-uts-vite/src/utils/compiler/utils.ts +++ b/packages/uni-uts-vite/src/utils/compiler/utils.ts @@ -2,7 +2,8 @@ import path from 'path' import fs from 'fs-extra' import type { parse, bundle, UtsTarget } from '@dcloudio/uts' import { normalizePath } from '@dcloudio/uni-cli-shared' -import { camelize } from '@vue/shared' +import { camelize, capitalize } from '@vue/shared' +import { Module, ModuleItem } from '../../../types/types' export function getUtsCompiler(): { parse: typeof parse @@ -21,9 +22,11 @@ export function resolvePackage(filename: string) { ? parts.findIndex((part) => part === 'uni_modules') : parts.findIndex((part) => part === 'utssdk') if (index > -1) { + const name = camelize(parts[index + 1]) return { is_uni_modules: isUniModules, - name: camelize(parts[index + 1]), + name, + namespace: 'UTSSDK' + (isUniModules ? 'Modules' : '') + capitalize(name), } } } @@ -110,3 +113,23 @@ export function resolveUTSPlatformFile( } return platformFile } + +function resolveTypeAliasDeclNames(items: ModuleItem[]) { + const names: string[] = [] + items.forEach((item) => { + if (item.type === 'TsTypeAliasDeclaration') { + names.push(item.id.value) + } + }) + return names +} + +export function createResolveTypeReferenceName(namespace: string, ast: Module) { + const names = resolveTypeAliasDeclNames(ast.body) + return (name: string) => { + if (names.includes(name)) { + return namespace + capitalize(name) + } + return name + } +} diff --git a/packages/uts-darwin-arm64/uts.darwin-arm64.node b/packages/uts-darwin-arm64/uts.darwin-arm64.node index f0522587993fab9d1eaa9c8646ecffb04e78fcf3..358d6542c66741bc8817edc7986ebf5b265c4058 100755 Binary files a/packages/uts-darwin-arm64/uts.darwin-arm64.node and b/packages/uts-darwin-arm64/uts.darwin-arm64.node differ diff --git a/packages/uts-darwin-x64/uts.darwin-x64.node b/packages/uts-darwin-x64/uts.darwin-x64.node index 1dbffdb1fccf88f1e63ef19c39a16409e27f4e15..d1b1789a9224a9d0e911ad054add2a6a7cbd542c 100755 Binary files a/packages/uts-darwin-x64/uts.darwin-x64.node and b/packages/uts-darwin-x64/uts.darwin-x64.node differ diff --git a/packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node b/packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node index fcd204cbe3ab459244ce58edb38974faeb372d89..df0e209053bea2fb50f6fc5093629ea85e0c13bd 100644 Binary files a/packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node and b/packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node differ diff --git a/packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node b/packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node index 25cb6b099279b863f597b4e0da3020602cc999c9..5a7d5473aa2245f1375be3d98891d926faf0a402 100644 Binary files a/packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node and b/packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node differ