提交 c8217d52 编写于 作者: Q qiang

chore: Merge branch 'next' of github.com:dcloudio/uni-app into next

# Conflicts:
#	packages/playground/uts/unpackage/dist/app/uni_modules/test-uniplugin/app-android/index.kt.map
#	packages/playground/uts/unpackage/dist/app/uni_modules/test-uniplugin/app-ios/index.swift.map
#	pnpm-lock.yaml
# uni-app 贡献指南
## 环境搭建
* 需要安装 [Node.js](http://nodejs.org/) 16+,以及 [pnpm](https://pnpm.io/)
* 克隆仓库到本地后,执行 ```pnpm install``` 安装开发依赖。
## 开发
* 执行命令编译指定包,如:```npm run build uni-mp-weixin```
* 执行 ```npm run lint``` 检查代码风格。
* 执行 ```npm run test``` 运行测试。
## 测试
* 创建 uni-app 测试工程。
```
npx degit dcloudio/uni-preset-vue#vite uniapp-test
```
* 从本地安装改动过的依赖
```
pnpm add @dcloudio/%包名%@%uni-app本地仓库路径%/packages/%包名%
```
* 编写测试代码。
* 编译到对应平台进行测试。
## 提交 PR
* fork 本仓库,在自己仓库基于 next 分支创建专用分支用于提交更改。
* commit 规范遵循 Vue 仓库 [Git Commit Message Convention](https://github.com/vuejs/vue/blob/dev/.github/COMMIT_CONVENTION.md)
* 提交之前确保进行了完善的测试。
* 确保 PR 提交到 next 分支。
* 修复 Bug 请提供详细的描述信息,或链接到对应的 issue。
* 提交新功能请阐明起用途以及提交到主仓库的必要性。除抹平不同平台 API 与组件差异的功能外,最好事先仓库主要成员商议后再进行。
## 项目结构
* packages:uni-app 编译器以及运行时依赖
* uni-cli-shared:编译器共享包
* ``__tests__``:单元测试
* dist:编译后的文件
* lib:其他依赖
* src:源文件
* messages:编译器国际化语言包
* uni-app:框架接口、生命周期等
* uni-api:运行时全局 uni 对象提供的接口,平台公用
* uni-components:运行时全局组件,平台公用
* uni-i18n:国际化依赖包(运行时)
* uni-h5-vite:H5 平台 Vite 插件
* uni-h5-vue:H5 平台使用的 Vue 框架
* uni-h5:H5 平台运行时依赖包
* dist:编译后的文件
* lib:其他依赖
* src:源文件
* compiler:编译器(当前平台独有部分)
* service:逻辑层
* view:视图层
* uni-app-vite:App 平台 Vite 插件
* uni-app-vue:App 平台使用的 Vue 框架
* uni-app-plus:App 平台依赖包
* dist:编译后的文件
* lib:其他依赖
* src:源文件
* compiler:编译器(当前平台独有部分)
* service:逻辑层
* view:视图层
* uni-app-plus-nvue:App(nvue)平台依赖包
* uni-mp-vite:小程序平台 Vite 插件
* uni-mp-vue:小程序平台使用的 Vue 框架
* uni-mp-compiler:小程序编译器(各小程序平台通用部分)
* ``__tests__``:单元测试
* dist:编译后的文件
* lib:其他依赖
* src:源文件
* template:模版编译
* transforms:属性转换
* uni-mp-core:小程序平台运行时(各小程序平台通用部分)
* ``__tests__``:单元测试
* src:源文件
* api:uni 对象接口适配
* runtime:运行时框架生命周期等
* uni-mp-weixin:微信小程序平台依赖包
* dist:编译后的文件
* lib:其他依赖
* src:源文件
* api:uni 对象接口适配,抹平 wx 对象的平台差异
* compiler:编译器(当前平台独有部分)
* runtime:运行时框架生命周期等
* uni-mp-alipay:支付宝小程序平台依赖包
* uni-mp-baidu:百度小程序平台依赖包
* uni-mp-qq:QQ小程序平台依赖包
* uni-mp-toutiao:字节小程序平台依赖包
* uni-mp-kuaishou:快手小程序平台依赖包
* uni-mp-lark:飞书小程序平台依赖包
* uni-quickapp-webview:快应用平台依赖包
* uni-stat:uni统计依赖包
* scripts:编译脚本
......@@ -29,6 +29,12 @@ export class User implements IUser {
//#ifndef APP-IOS
console.log('ndef ios')
//#endif
//#ifdef APP-ANDROID || APP-IOS
console.log('def android || def ios')
//#endif
//#ifdef MP-WEIXIN
console.log('def weixin')
//#endif
}
register(name: string, callback: () => void) {
Log.info(logo as FrameLayout)
......
......@@ -36,6 +36,12 @@ export function test1(callback: () => void) {
//#ifndef APP-IOS
console.log('ndef ios')
//#endif
//#ifdef APP-ANDROID || APP-IOS
console.log('def android || def ios')
//#endif
//#ifdef MP-WEIXIN
console.log('def weixin')
//#endif
}
class Test1 {}
......@@ -43,4 +49,7 @@ export class Test {
constructor() {
new Test1()
}
test(): string | null {
return null
}
}
......@@ -31,6 +31,7 @@ open class User : IUser {
Log.info(__default);
console.log("def android", " at uni_modules/test-uniplugin/app-android/index.uts:21");
console.log("ndef ios", " at uni_modules/test-uniplugin/app-android/index.uts:30");
console.log("def android || def ios", " at uni_modules/test-uniplugin/app-android/index.uts:33");
}
override fun register(name: String, callback: UTSCallback) {
Log.info(__default as FrameLayout);
......
{"version":3,"sources":["/Users/guoshengqiang/Documents/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/static/logo.png","/Users/guoshengqiang/Documents/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-android/index.uts","/Users/guoshengqiang/Documents/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-android/interface.uts","/Users/guoshengqiang/Documents/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-android/login.uts"],"sourcesContent":["import { getResourcePath } from 'io.dcloud.uts.android'\nexport default getResourcePath('uni_modules/test-uniplugin/static/logo.png')\n ","import Log from 'android.util.Log'\nimport FrameLayout from 'android.widget.FrameLayout'\nimport View from 'android.view.View'\nimport { IUser } from './interface.uts'\nimport { login } from './login.uts'\nimport logo from '../static/logo.png'\n\ntype GetBatteryInfoOptions = {\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\nexport class User implements IUser {\n async login(name: string, pwd: string) {\n setTimeout(() => {\n console.log('timeout')\n }, 1000)\n login(name, pwd)\n Log.info(logo)\n\n console.log('def android')\n\n\n\n\n\n\n\n\n console.log('ndef ios')\n\n }\n register(name: string, callback: () => void) {\n Log.info(logo as FrameLayout)\n }\n test(view: View) {}\n}\nfunction login(name: string, callback: () => void) {}\nexport function register(name: string, callback: () => void) {}\n","export interface IUser {\n register(name: string): void\n}\n","export function login(name: string, pwd: string) {\n console.log('login')\n return { name, pwd }\n}\n"],"names":[],"mappings":";;;AAAA;ACAA,OAAgB,gBAAkB,CAAA;AAClC,OAAwB,0BAA4B,CAAA;AACpD,OAAiB,iBAAmB,CAAA;UCFnB,KAAK;QACpB,QAAQ,CAAC,IAAY,EAAN,MAAM,GAAG,IAAI;;ACDvB,IAAS,KAAK,CAAC,IAAY,EAAN,MAAM,EAAE,GAAW,EAAN,MAAM,iBAAE;IAC/C,OAAO,CAAC,GAAG,CAAC,OAAO,2DAAC;IACpB,OAAO;QAAE,IAAA,IAAI,GAAJ,IAAI;QAAE,IAAA,GAAG,GAAH,GAAG;KAAE,CAAA;AACtB;gBHFe,eAAe,CAAC,4CAA4C,CAAC;ACM/C,WAAxB,qBAAqB;IACxB,SAAA,OAAO,EAAC,WAA8B,SAAA;IACtC,SAAA,IAAI,EAAC,WAA8B,SAAA;IACnC,SAAA,QAAQ,EAAC,WAA8B,SAAA;CACxC;AACM,WAAM,IAAI,GAAY,KAAK;qBAC1B,KAAK,CAAC,IAAY,EAAN,MAAM,EAAE,GAAW,EAAN,MAAM,8CAAE;QACrC,UAAU,CAAC,KAAM;YACf,OAAO,CAAC,GAAG,CAAC,SAAS,4DAAC;QACxB;QAAC,EAAE,IAAI,CAAC;QACR,MAAM,IAAI,EAAE,GAAG,CAAC;QAChB,GAAG,CAAC,IAAI,WAAM;QAEd,OAAO,CAAC,GAAG,CAAC,aAAa,4DAAC;QAS1B,OAAO,CAAC,GAAG,CAAC,UAAU,4DAAC;IAEzB;iBACA,QAAQ,CAAC,IAAY,EAAN,MAAM,EAAE,QAAoB,aAAA,EAAE;QAC3C,GAAG,CAAC,IAAI,cAAS,WAAW,CAAC;IAC/B;aACA,IAAI,CAAC,IAAU,EAAJ,IAAI,EAAE,CAAC;CACnB;AACD,UAAe,IAAY,EAAN,MAAM,EAAE,QAAoB,QAAJ,IAAI,EAAE,CAAC,CAAC;AAC9C,IAAS,QAAQ,CAAC,IAAY,EAAN,MAAM,EAAE,QAAoB,aAAA,EAAE,CAAC,CAAC"}
\ No newline at end of file
{"version":3,"sources":["/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/static/logo.png","/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-android/index.uts","/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-android/interface.uts","/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-android/login.uts"],"sourcesContent":["import { getResourcePath } from 'io.dcloud.uts.android'\nexport default getResourcePath('uni_modules/test-uniplugin/static/logo.png')\n ","import Log from 'android.util.Log'\nimport FrameLayout from 'android.widget.FrameLayout'\nimport View from 'android.view.View'\nimport { IUser } from './interface.uts'\nimport { login } from './login.uts'\nimport logo from '../static/logo.png'\n\ntype GetBatteryInfoOptions = {\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\nexport class User implements IUser {\n async login(name: string, pwd: string) {\n setTimeout(() => {\n console.log('timeout')\n }, 1000)\n login(name, pwd)\n Log.info(logo)\n\n console.log('def android')\n\n\n\n\n\n\n\n\n console.log('ndef ios')\n\n\n console.log('def android || def ios')\n\n\n\n\n }\n register(name: string, callback: () => void) {\n Log.info(logo as FrameLayout)\n }\n test(view: View) {}\n}\nfunction login(name: string, callback: () => void) {}\nexport function register(name: string, callback: () => void) {}\n","export interface IUser {\n register(name: string): void\n}\n","export function login(name: string, pwd: string) {\n console.log('login')\n return { name, pwd }\n}\n"],"names":[],"mappings":";;;AAAA;ACAA,OAAgB,gBAAkB,CAAA;AAClC,OAAwB,0BAA4B,CAAA;AACpD,OAAiB,iBAAmB,CAAA;UCFnB,KAAK;QACpB,QAAQ,CAAC,IAAY,EAAN,MAAM,GAAG,IAAI;;ACDvB,IAAS,KAAK,CAAC,IAAY,EAAN,MAAM,EAAE,GAAW,EAAN,MAAM,iBAAE;IAC/C,OAAO,CAAC,GAAG,CAAC,OAAO,2DAAC;IACpB,OAAO;QAAE,IAAA,IAAI,GAAJ,IAAI;QAAE,IAAA,GAAG,GAAH,GAAG;KAAE,CAAA;AACtB;gBHFe,eAAe,CAAC,4CAA4C,CAAC;ACM/C,WAAxB,qBAAqB;IACxB,SAAA,OAAO,EAAC,WAA8B,SAAA;IACtC,SAAA,IAAI,EAAC,WAA8B,SAAA;IACnC,SAAA,QAAQ,EAAC,WAA8B,SAAA;CACxC;AACM,WAAM,IAAI,GAAY,KAAK;qBAC1B,KAAK,CAAC,IAAY,EAAN,MAAM,EAAE,GAAW,EAAN,MAAM,8CAAE;QACrC,UAAU,CAAC,KAAM;YACf,OAAO,CAAC,GAAG,CAAC,SAAS,4DAAC;QACxB;QAAC,EAAE,IAAI,CAAC;QACR,MAAM,IAAI,EAAE,GAAG,CAAC;QAChB,GAAG,CAAC,IAAI,WAAM;QAEd,OAAO,CAAC,GAAG,CAAC,aAAa,4DAAC;QAS1B,OAAO,CAAC,GAAG,CAAC,UAAU,4DAAC;QAGvB,OAAO,CAAC,GAAG,CAAC,wBAAwB,4DAAC;IAKvC;iBACA,QAAQ,CAAC,IAAY,EAAN,MAAM,EAAE,QAAoB,aAAA,EAAE;QAC3C,GAAG,CAAC,IAAI,cAAS,WAAW,CAAC;IAC/B;aACA,IAAI,CAAC,IAAU,EAAJ,IAAI,EAAE,CAAC;CACnB;AACD,UAAe,IAAY,EAAN,MAAM,EAAE,QAAoB,QAAJ,IAAI,EAAE,CAAC,CAAC;AAC9C,IAAS,QAAQ,CAAC,IAAY,EAAN,MAAM,EAAE,QAAoB,aAAA,EAAE,CAAC,CAAC"}
\ No newline at end of file
......@@ -15,6 +15,9 @@ class Test : NSObject {
public init(){
Test1();
}
public func test() -> String? {
return nil;
}
}
@objc(UTSSDKModulesTestUniPluginIndexSwift)
@objcMembers
......@@ -36,5 +39,6 @@ class IndexSwift : NSObject {
console.log("test1", " at uni_modules/test-uniplugin/app-ios/index.uts:26");
console.log("def ios", " at uni_modules/test-uniplugin/app-ios/index.uts:31");
console.log("ndef android", " at uni_modules/test-uniplugin/app-ios/index.uts:34");
console.log("def android || def ios", " at uni_modules/test-uniplugin/app-ios/index.uts:40");
}
}
{"version":3,"sources":["/Users/guoshengqiang/Documents/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-ios/index.uts"],"sourcesContent":["import { UIDevice } from 'UIKit'\n\ntype GetBatteryInfoOptions = {\n name: string\n pwd: number\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\n\nexport default function getBatteryInfo(options: GetBatteryInfoOptions) {\n const res = {\n errMsg: 'getBatteryInfo:ok',\n level: UIDevice.current.batteryLevel * 100,\n isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,\n }\n if (options.success != null) {\n options.success!(res)\n }\n if (options.complete != null) {\n options.complete!(res)\n }\n}\n\nexport function test1(callback: () => void) {\n console.log('test1')\n\n\n\n\n console.log('def ios')\n\n\n console.log('ndef android')\n\n\n\n\n}\n\nclass Test1 {}\nexport class Test {\n constructor() {\n new Test1()\n }\n}\n"],"names":[],"mappings":";AAAA;AAEA;;AAA6B,MAAxB,qBAAqB;IACxB,WAAA,IAAI,EAAE,MAAM,EAAA;IACZ,WAAA,GAAG,EAAE,QAAM,EAAA;IACX,WAAA,OAAO,EAAC,WAA8B,EAAA;IACtC,WAAA,IAAI,EAAC,WAA8B,EAAA;IACnC,WAAA,QAAQ,EAAC,WAA8B,EAAA;CACxC;AAgCD,MAAM,KAAK;CAAG;AACP,MAAM,IAAI;IACf,aAAc;QACZ,AAAI,KAAK,EAAE;IACb;CACD;;;;uBAnCuB,cAAc,CAAC,EAAA,OAA8B,EAArB,qBAAqB,EAAE;QACrE,IAAM,GAAG,GAAG;YACV,CAAA,MAAM,GAAE,mBAAmB;YAC3B,CAAA,KAAK,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG;YAC1C,CAAA,UAAU,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY,CAAC,QAAQ;0BAC5E;QACD,IAAI,OAAO,CAAC,OAAO,IAAI,GAAI;YACzB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;;QAEvB,IAAI,OAAO,CAAC,QAAQ,IAAI,GAAI;YAC1B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;;IAE1B;uBAEgB,KAAK,CAAC,EAAA,QAAoB,aAAA,EAAE;QAC1C,OAAO,CAAC,GAAG,CAAC,OAAO,wDAAC;QAKpB,OAAO,CAAC,GAAG,CAAC,SAAS,wDAAC;QAGtB,OAAO,CAAC,GAAG,CAAC,cAAc,wDAAC;IAK7B"}
\ No newline at end of file
{"version":3,"sources":["/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-ios/index.uts"],"sourcesContent":["import { UIDevice } from 'UIKit'\n\ntype GetBatteryInfoOptions = {\n name: string\n pwd: number\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\n\nexport default function getBatteryInfo(options: GetBatteryInfoOptions) {\n const res = {\n errMsg: 'getBatteryInfo:ok',\n level: UIDevice.current.batteryLevel * 100,\n isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,\n }\n if (options.success != null) {\n options.success!(res)\n }\n if (options.complete != null) {\n options.complete!(res)\n }\n}\n\nexport function test1(callback: () => void) {\n console.log('test1')\n\n\n\n\n console.log('def ios')\n\n\n console.log('ndef android')\n\n\n\n\n\n console.log('def android || def ios')\n\n\n\n\n}\n\nclass Test1 {}\nexport class Test {\n constructor() {\n new Test1()\n }\n test(): string | null {\n return null\n }\n}\n"],"names":[],"mappings":";AAAA;AAEA;;AAA6B,MAAxB,qBAAqB;IACxB,WAAA,IAAI,EAAE,MAAM,EAAA;IACZ,WAAA,GAAG,EAAE,QAAM,EAAA;IACX,WAAA,OAAO,EAAC,WAA8B,EAAA;IACtC,WAAA,IAAI,EAAC,WAA8B,EAAA;IACnC,WAAA,QAAQ,EAAC,WAA8B,EAAA;CACxC;AAsCD,MAAM,KAAK;CAAG;AACP,MAAM,IAAI;IACf,aAAc;QACZ,AAAI,KAAK,EAAE;IACb;gBACA,IAAI,MAAI,MAAM,EAAQ;QACpB,OAAO,GAAI,CAAA;IACb;CACD;;;;uBA5CuB,cAAc,CAAC,EAAA,OAA8B,EAArB,qBAAqB,EAAE;QACrE,IAAM,GAAG,GAAG;YACV,CAAA,MAAM,GAAE,mBAAmB;YAC3B,CAAA,KAAK,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG;YAC1C,CAAA,UAAU,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY,CAAC,QAAQ;0BAC5E;QACD,IAAI,OAAO,CAAC,OAAO,IAAI,GAAI;YACzB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;;QAEvB,IAAI,OAAO,CAAC,QAAQ,IAAI,GAAI;YAC1B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;;IAE1B;uBAEgB,KAAK,CAAC,EAAA,QAAoB,aAAA,EAAE;QAC1C,OAAO,CAAC,GAAG,CAAC,OAAO,wDAAC;QAKpB,OAAO,CAAC,GAAG,CAAC,SAAS,wDAAC;QAGtB,OAAO,CAAC,GAAG,CAAC,cAAc,wDAAC;QAM3B,OAAO,CAAC,GAAG,CAAC,wBAAwB,wDAAC;IAKvC"}
\ No newline at end of file
......@@ -35,7 +35,7 @@
"@dcloudio/uni-shared": "3.0.0-alpha-3060320220919001",
"@types/pako": "1.0.2",
"@vue/compiler-sfc": "3.2.39",
"autoprefixer": "^10.4.9",
"autoprefixer": "^10.4.11",
"pako": "^1.0.11",
"postcss": "^8.4.13",
"vue": "3.2.39"
......
import path from 'path'
export const templateDir = path.resolve(__dirname, '../lib/template/')
export function nvueOutDir() {
return path.join(
process.env.UNI_OUTPUT_DIR,
'../.nvue',
'app' +
(process.env.UNI_APP_PLATFORM ? '-' + process.env.UNI_APP_PLATFORM : '')
)
return path.join(process.env.UNI_OUTPUT_DIR, '../.nvue')
}
......@@ -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;
......
......@@ -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;
......
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 };
......@@ -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'
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<string, Function> = {}
......@@ -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 ''
}
......@@ -33,7 +33,7 @@
"@vue/compiler-sfc": "3.2.39",
"@vue/server-renderer": "3.2.39",
"@vue/shared": "3.2.39",
"autoprefixer": "^10.4.9",
"autoprefixer": "^10.4.11",
"base64url": "^3.0.1",
"chokidar": "^3.5.3",
"compare-versions": "^3.6.0",
......
......@@ -28,8 +28,5 @@ export function getPlatforms() {
}
export function getPlatformDir() {
if (process.env.UNI_PLATFORM === 'app' && process.env.UNI_APP_PLATFORM) {
return process.env.UNI_PLATFORM + '-' + process.env.UNI_APP_PLATFORM
}
return process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM
}
......@@ -63,15 +63,6 @@ export function initPreContext(
nvueContext.APP_NVUE = true
nvueContext.APP_PLUS_NVUE = true
if (process.env.UNI_APP_PLATFORM === 'android') {
defaultContext.APP_ANDROID = true
} else if (process.env.UNI_APP_PLATFORM === 'ios') {
defaultContext.APP_IOS = true
} else {
defaultContext.APP_ANDROID = true
defaultContext.APP_IOS = true
}
} else if (platform.startsWith('mp-')) {
defaultContext.MP = true
} else if (platform.startsWith('quickapp-webview')) {
......
......@@ -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)
}
}
}
......
......@@ -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",
......
......@@ -60,7 +60,11 @@ export default defineComponent({
const indicatorStyle = computed(() =>
getStyle(pickerViewProps.indicatorStyle)
)
const maskStyle = computed(() => getStyle(pickerViewProps.maskStyle))
// const maskStyle = computed(() => getStyle(pickerViewProps.maskStyle))
const maskTopStyle = computed(() => getStyle(pickerViewProps.maskTopStyle))
const maskBottomStyle = computed(() =>
getStyle(pickerViewProps.maskBottomStyle)
)
let indicatorHeight = ref(0)
indicatorHeight.value = getHeight(indicatorStyle.value)
let pickerViewHeight = ref(0)
......@@ -149,18 +153,18 @@ export default defineComponent({
{createScrollViewChild(children)}
</view>
</scroll-view>
<u-scalable class="uni-picker-view-mask" style={maskStyle.value}>
<u-scalable class="uni-picker-view-mask">
<u-scalable
class="uni-picker-view-mask uni-picker-view-mask-top"
style={{
style={extend({}, maskTopStyle.value, {
bottom: maskPosition,
}}
})}
></u-scalable>
<u-scalable
class="uni-picker-view-mask uni-picker-view-mask-bottom"
style={{
style={extend({}, maskBottomStyle.value, {
top: maskPosition,
}}
})}
></u-scalable>
</u-scalable>
<u-scalable
......
......@@ -24,6 +24,14 @@ const nvuePickerViewProps = extend({}, pickerViewProps, {
type: [Number, String],
default: 0,
},
maskTopStyle: {
type: String,
default: '',
},
maskBottomStyle: {
type: String,
default: '',
},
})
type Props = ExtractPropTypes<typeof nvuePickerViewProps>
export default defineComponent({
......
......@@ -843,7 +843,9 @@ const useSwiperNavigation = /*#__PURE__*/ (
onMouseout: (event: MouseEvent) => navigationHover(event, 'out'),
}
function navigationClick(type: NavigationClickType) {
function navigationClick($event: MouseEvent, type: NavigationClickType) {
$event.stopPropagation()
const swiperItemLength = swiperContext.value.length
let _current = state.current
......@@ -868,32 +870,41 @@ const useSwiperNavigation = /*#__PURE__*/ (
const createNavigationSVG = () =>
createSvgIconVNode(ICON_PATH_BACK, props.navigationColor, 26)
const _mouseMove = (e: MouseEvent) => {
let setHideNavigationTimer: number | undefined
const _mousemove = (e: MouseEvent) => {
clearTimeout(setHideNavigationTimer)
const { clientX, clientY } = e
const { left, right, top, bottom, width, height } =
rootRef.value!.getBoundingClientRect()
let hide = false
if (props.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) {
// @ts-ignore setTimeout -> NodeJS.Timeout
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)
}
}
}
......@@ -918,7 +929,7 @@ const useSwiperNavigation = /*#__PURE__*/ (
},
navigationClass
)}
onClick={() => navigationClick('prev')}
onClick={(e) => navigationClick(e, 'prev')}
{...navigationAttr}
>
{createNavigationSVG()}
......@@ -932,7 +943,7 @@ const useSwiperNavigation = /*#__PURE__*/ (
},
navigationClass
)}
onClick={() => navigationClick('next')}
onClick={(e) => navigationClick(e, 'next')}
{...navigationAttr}
>
{createNavigationSVG()}
......
......@@ -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;
......
......@@ -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"]);
};
}
});
......
......@@ -7,10 +7,12 @@ import {
watch,
nextTick,
} from 'vue'
import { StyleValue } from '@vue/runtime-dom'
import { defineSystemComponent } from '@dcloudio/uni-components'
import { Swiper, SwiperItem } from '@dcloudio/uni-components'
import { usePreventScroll } from '../../../../helpers/usePreventScroll'
import ImageView from './ImageView'
import { createSvgIconVNode, ICON_PATH_CLOSE } from '@dcloudio/uni-core'
const props = {
urls: {
......@@ -82,6 +84,21 @@ export default /*#__PURE__*/ defineSystemComponent({
indexRef.value = event.detail.current
}
const closeBtnStyle: StyleValue = {
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 () => {
return (
<div
......@@ -99,6 +116,7 @@ export default /*#__PURE__*/ defineSystemComponent({
onClick={onClick}
>
<Swiper
navigation="auto"
current={indexRef.value}
// @ts-ignore
onChange={onChange}
......@@ -118,6 +136,9 @@ export default /*#__PURE__*/ defineSystemComponent({
</SwiperItem>
))}
</Swiper>
<div style={closeBtnStyle}>
{createSvgIconVNode(ICON_PATH_CLOSE, '#ffffff', 26)}
</div>
</div>
)
}
......
import type { Plugin } from 'vite'
import path from 'path'
import { isInHBuilderX, parseVueRequest, preJs } from '@dcloudio/uni-cli-shared'
import { isInHBuilderX, parseVueRequest } from '@dcloudio/uni-cli-shared'
import {
BindingIdentifier,
ClassDeclaration,
......@@ -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,24 +42,35 @@ 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 编译器
// eslint-disable-next-line no-restricted-globals
const { parse } = require('@dcloudio/uts')
const ast = await parse(preJs(code), { noColor: isInHBuilderX() })
const ast = await parse(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) {
......
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,
}
}
......@@ -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',
}
}
......
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',
}
}
......
......@@ -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
}
}
......@@ -44,15 +44,6 @@ export function uniCopyPlugin({
})
.map((p) => '/' + PUBLIC_DIR + '/' + p)
if (process.env.UNI_APP_PLATFORM === 'android') {
ignorePlatformStaticDirs.push(`/${PUBLIC_DIR}/app-ios`)
} else if (process.env.UNI_APP_PLATFORM === 'ios') {
ignorePlatformStaticDirs.push(`/${PUBLIC_DIR}/app-android`)
} else {
ignorePlatformStaticDirs.push(`/${PUBLIC_DIR}/app-android`)
ignorePlatformStaticDirs.push(`/${PUBLIC_DIR}/app-ios`)
}
const targets: UniViteCopyPluginTarget[] = [
{
src: assets,
......
此差异已折叠。
......@@ -37,10 +37,10 @@ const pkgs = {
latest: '1.8.2',
},
'@dcloudio/types': {
next: '3.0.14',
next: '3.0.16',
},
autoprefixer: {
latest: '10.4.9',
latest: '10.4.11',
},
'rollup-plugin-copy': {
latest: '3.4.0',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册