diff --git a/uni_modules/uni-addPhoneContact/changelog.md b/uni_modules/uni-addPhoneContact/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-addPhoneContact/package.json b/uni_modules/uni-addPhoneContact/package.json new file mode 100644 index 0000000000000000000000000000000000000000..5c2e2909ad558930411fe893c882f95ccb4b42d7 --- /dev/null +++ b/uni_modules/uni-addPhoneContact/package.json @@ -0,0 +1,94 @@ +{ + "id": "uni-addPhoneContact", + "displayName": "uni-addPhoneContact", + "version": "1.0.0", + "description": "uni-addPhoneContact", + "keywords": [ + "uni-addPhoneContact" +], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "uni-ext-api": { + "uni": { + "addPhoneContact": { + "name": "addPhoneContact", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "u", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-addPhoneContact/readme.md b/uni_modules/uni-addPhoneContact/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..e7c8907556360f637c1a57b27e57200293dfd80e --- /dev/null +++ b/uni_modules/uni-addPhoneContact/readme.md @@ -0,0 +1,7 @@ +# uni-addPhoneContact + +### 开发文档 + +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS 原生插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts/-/tree/dev) diff --git a/uni_modules/uni-addPhoneContact/utssdk/app-harmony/index.uts b/uni_modules/uni-addPhoneContact/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..545edfd19e4abe68f91d811b0a65c3bf649627bd --- /dev/null +++ b/uni_modules/uni-addPhoneContact/utssdk/app-harmony/index.uts @@ -0,0 +1,125 @@ +import { AddPhoneContact, AddPhoneContactOptions, AddPhoneContactSuccess } from '../interface.uts'; +import { API_ADD_PHONE_CONTACT, AddPhoneContactApiOptions, AddPhoneContactApiProtocol } from '../protocol.uts'; +import { contact } from '@kit.ContactsKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { UTSHarmony } from '@dcloudio/uni-runtime'; + +export const addPhoneContact: AddPhoneContact = defineAsyncApi( + API_ADD_PHONE_CONTACT, + (args: AddPhoneContactOptions, executor: ApiExecutor) => { + UTSHarmony.requestSystemPermission(['ohos.permission.WRITE_CONTACTS'], (allRight: boolean) => { + if (allRight) { + const { + photoFilePath, + nickName = '', + lastName = '', + middleName = '', + firstName = '', + remark = '', + mobilePhoneNumber = '', + weChatNumber, + addressCountry = '', + addressState = '', + addressCity = '', + addressStreet = '', + addressPostalCode = '', + organization = '', + url = '', + workPhoneNumber = '', + workFaxNumber = '', + hostNumber = '', + email = '', + title = '', + workAddressCountry = '', + workAddressState = '', + workAddressCity = '', + workAddressStreet = '', + workAddressPostalCode, + homeFaxNumber = '', + homePhoneNumber = '', + homeAddressCountry = '', + homeAddressState = '', + homeAddressCity = '', + homeAddressStreet = '', + homeAddressPostalCode = '' + } = args + + const contactInfo: contact.Contact = { + name: { + familyName: lastName!, + middleName: middleName!, + givenName: firstName!, + fullName: lastName! + middleName! + firstName! + }, + nickName: { + nickName: nickName! + }, + emails: [{ + email: email!, + displayName: '邮箱' + }], + phoneNumbers: [{ + phoneNumber: homePhoneNumber!, + labelId: contact.PhoneNumber.NUM_HOME + }, { + phoneNumber: mobilePhoneNumber!, + labelId: contact.PhoneNumber.NUM_MOBILE + }, { + phoneNumber: homeFaxNumber!, + labelId: contact.PhoneNumber.NUM_FAX_HOME + }, { + phoneNumber: workFaxNumber!, + labelId: contact.PhoneNumber.NUM_FAX_WORK + }, { + phoneNumber: workPhoneNumber!, + labelId: contact.PhoneNumber.NUM_WORK + }, { + phoneNumber: hostNumber!, + labelId: contact.PhoneNumber.NUM_COMPANY_MAIN + }], + portrait: { uri: photoFilePath! }, + postalAddresses: [{ + city: homeAddressCity!, + country: homeAddressCountry!, + postcode: homeAddressPostalCode!, + street: homeAddressStreet!, + postalAddress: homeAddressCountry! + homeAddressState! + homeAddressCity + homeAddressStreet, + labelId: contact.PostalAddress.ADDR_HOME + }, { + city: workAddressCity!, + country: workAddressCountry!, + postcode: workAddressPostalCode!, + street: workAddressStreet!, + postalAddress: workAddressCountry! + workAddressState! + workAddressCity + workAddressStreet, + labelId: contact.PostalAddress.ADDR_WORK + }, { + city: addressCity!, + country: addressCountry!, + postcode: addressPostalCode!, + street: addressStreet!, + postalAddress: addressCountry! + addressState! + addressCity + addressStreet, + labelId: contact.PostalAddress.CUSTOM_LABEL + }], + websites: [{ website: url! }], + note: { noteContent: remark! }, + organization: { + name: organization!, + title: title! + } + } + + contact.addContact(getContext(), contactInfo) + .then((contactId) => { + executor.resolve(contactId) + }) + .catch((err: BusinessError) => { + executor.reject(err.message) + }) + } else { + executor.reject('Permission denied') + } + }, () => executor.reject('Permission denied')) + }, + AddPhoneContactApiProtocol, + AddPhoneContactApiOptions +) as AddPhoneContact diff --git a/uni_modules/uni-addPhoneContact/utssdk/interface.uts b/uni_modules/uni-addPhoneContact/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..c3acdd15e3130469bc3da9b3f4030a162c0aa764 --- /dev/null +++ b/uni_modules/uni-addPhoneContact/utssdk/interface.uts @@ -0,0 +1,231 @@ +export interface Uni { + /** + * 手机通讯录联系人和联系方式的增加 + * @tutorial https://uniapp.dcloud.net.cn/api/system/contact.html + * @tutorial-uni-app https://uniapp.dcloud.net.cn/api/system/contact.html + * + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.25", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "x", + * "unixVer": "x" + * } + * "mp":{ + * weixin: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * alipay: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * baidu: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * toutiao: { + * hostVer: 'x', + * uniVer: 'x', + * unixVer: 'x' + * }, + * lark: { + * hostVer: 'x', + * uniVer: 'x', + * unixVer: 'x' + * }, + * qq: { + * hostVer: 'x', + * uniVer: 'x', + * unixVer: 'x' + * }, + * kuaishou: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * jd: { + * hostVer: 'x', + * uniVer: 'x', + * unixVer: 'x' + * } + * } + * } + */ + addPhoneContact: AddPhoneContact; +} + +export type AddPhoneContact = (options: AddPhoneContactOptions) => void; +export type AddPhoneContactSuccess = {}; +export type UniError = { + errSubject: string, + errCode: number, + errMsg: string, + data?: object | null, + cause?: any | null +}; +export type AddPhoneContactSuccessCallback = (result: AddPhoneContactSuccess) => void; +export type AddPhoneContactFail = UniError; +export type AddPhoneContactFailCallback = (result: AddPhoneContactFail) => void; +export type AddPhoneContactComplete = any; +export type AddPhoneContactCompleteCallback = (result: AddPhoneContactComplete) => void; +export type AddPhoneContactOptions = { + /** + * 头像本地文件路径 + */ + photoFilePath?: string | null, + /** + * 昵称 + */ + nickName?: string | null, + /** + * 姓氏 + */ + lastName?: string | null, + /** + * 中间名 + */ + middleName?: string | null, + /** + * 名字 + */ + firstName?: string | null, + /** + * 备注 + */ + remark?: string | null, + /** + * 手机号 + */ + mobilePhoneNumber?: string | null, + /** + * 微信号 + */ + weChatNumber?: string | null, + /** + * 联系地址国家 + */ + addressCountry?: string | null, + /** + * 联系地址省份 + */ + addressState?: string | null, + /** + * 联系地址城市 + */ + addressCity?: string | null, + /** + * 联系地址街道 + */ + addressStreet?: string | null, + /** + * 联系地址邮政编码 + */ + addressPostalCode?: string | null, + /** + * 公司 + */ + organization?: string | null, + /** + * 职位 + */ + title?: string | null, + /** + * 工作传真 + */ + workFaxNumber?: string | null, + /** + * 工作电话 + */ + workPhoneNumber?: string | null, + /** + * 公司电话 + */ + hostNumber?: string | null, + /** + * 电子邮件 + */ + email?: string | null, + /** + * 网站 + */ + url?: string | null, + /** + * 工作地址国家 + */ + workAddressCountry?: string | null, + /** + * 工作地址省份 + */ + workAddressState?: string | null, + /** + * 工作地址城市 + */ + workAddressCity?: string | null, + /** + * 工作地址街道 + */ + workAddressStreet?: string | null, + /** + * 工作地址邮政编码 + */ + workAddressPostalCode?: string | null, + /** + * 住宅传真 + */ + homeFaxNumber?: string | null, + /** + * 住宅电话 + */ + homePhoneNumber?: string | null, + /** + * 住宅地址国家 + */ + homeAddressCountry?: string | null, + /** + * 住宅地址省份 + */ + homeAddressState?: string | null, + /** + * 住宅地址城市 + */ + homeAddressCity?: string | null, + /** + * 住宅地址街道 + */ + homeAddressStreet?: string | null, + /** + * 住宅地址邮政编码 + */ + homeAddressPostalCode?: string | null, + /** + * 接口调用成功的回调函数 + */ + success?: AddPhoneContactSuccessCallback | null, + /** + * 接口调用失败的回调函数 + */ + fail?: AddPhoneContactFailCallback | null, + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + complete?: AddPhoneContactCompleteCallback | null +}; diff --git a/uni_modules/uni-addPhoneContact/utssdk/protocol.uts b/uni_modules/uni-addPhoneContact/utssdk/protocol.uts new file mode 100644 index 0000000000000000000000000000000000000000..a1b5a46b4611607558b63c460c84baefcd5d710b --- /dev/null +++ b/uni_modules/uni-addPhoneContact/utssdk/protocol.uts @@ -0,0 +1,50 @@ +import { AddPhoneContactOptions } from './interface.uts'; +export const API_ADD_PHONE_CONTACT = 'addPhoneContact' + +export const AddPhoneContactApiOptions: ApiOptions = { + formatArgs: new Map string | undefined)>([ + ['firstName', function (firstName: string) { + if (!firstName) { + return 'addPhoneContact:fail parameter error: parameter.firstName should not be empty;' + } + return undefined + }] + ]) +} + + +export const AddPhoneContactApiProtocol = new Map([ + ['firstName', { type: 'string', required: true }], + ['photoFilePath', { type: 'string' }], + ['nickName', { type: 'string' }], + ['lastName', { type: 'string' }], + ['middleName', { type: 'string' }], + ['remark', { type: 'string' }], + ['mobilePhoneNumber', { type: 'string' }], + ['weChatNumber', { type: 'string' }], + ['addressCountry', { type: 'string' }], + ['addressState', { type: 'string' }], + ['addressCity', { type: 'string' }], + ['addressStreet', { type: 'string' }], + ['addressPostalCode', { type: 'string' }], + ['organization', { type: 'string' }], + ['title', { type: 'string' }], + ['workFaxNumber', { type: 'string' }], + ['workPhoneNumber', { type: 'string' }], + ['hostNumber', { type: 'string' }], + ['email', { type: 'string' }], + ['url', { type: 'string' }], + ['workAddressCountry', { type: 'string' }], + ['workAddressState', { type: 'string' }], + ['workAddressCity', { type: 'string' }], + ['workAddressStreet', { type: 'string' }], + ['workAddressPostalCode', { type: 'string' }], + ['homeFaxNumber', { type: 'string' }], + ['homePhoneNumber', { type: 'string' }], + ['homeAddressCountry', { type: 'string' }], + ['homeAddressState', { type: 'string' }], + ['homeAddressCity', { type: 'string' }], + ['homeAddressStreet', { type: 'string' }], + ['homeAddressPostalCode', { type: 'string' }] +] +); diff --git a/uni_modules/uni-arrayBufferToBase64/changelog.md b/uni_modules/uni-arrayBufferToBase64/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-arrayBufferToBase64/package.json b/uni_modules/uni-arrayBufferToBase64/package.json new file mode 100644 index 0000000000000000000000000000000000000000..43696401ca472bd462d5d969cea43b60a6350e9c --- /dev/null +++ b/uni_modules/uni-arrayBufferToBase64/package.json @@ -0,0 +1,94 @@ +{ + "id": "uni-arrayBufferToBase64", + "displayName": "uni-arrayBufferToBase64", + "version": "1.0.0", + "description": "uni-arrayBufferToBase64", + "keywords": [ + "uni-arrayBufferToBase64" +], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "uni-ext-api": { + "uni": { + "arrayBufferToBase64": { + "name": "arrayBufferToBase64", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "u", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-arrayBufferToBase64/readme.md b/uni_modules/uni-arrayBufferToBase64/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..1233fb580e5bab8007b6161ffd6c3a2e3504a1c5 --- /dev/null +++ b/uni_modules/uni-arrayBufferToBase64/readme.md @@ -0,0 +1,7 @@ +# uni-arrayBufferToBase64 + +### 开发文档 + +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS 原生插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts/-/tree/dev) diff --git a/uni_modules/uni-arrayBufferToBase64/utssdk/app-harmony/index.uts b/uni_modules/uni-arrayBufferToBase64/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..8522286caac4f46e04b25c7f274c2fb8036a4d06 --- /dev/null +++ b/uni_modules/uni-arrayBufferToBase64/utssdk/app-harmony/index.uts @@ -0,0 +1,11 @@ +import buffer from '@ohos.buffer'; +import { ArrayBufferToBase64 } from '../interface.uts'; +import { ArrayBufferToBase64Protocol, API_ARRAY_BUFFER_TO_BASE64 } from '../protocol.uts'; + +export const arrayBufferToBase64: ArrayBufferToBase64 = defineSyncApi( + API_ARRAY_BUFFER_TO_BASE64, + (arrayBuffer: ArrayBuffer): string => { + return buffer.from(arrayBuffer).toString('base64') + }, + ArrayBufferToBase64Protocol +) as ArrayBufferToBase64 diff --git a/uni_modules/uni-arrayBufferToBase64/utssdk/interface.uts b/uni_modules/uni-arrayBufferToBase64/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..03149d1bf6f944b336f9f5440b5560fc109de818 --- /dev/null +++ b/uni_modules/uni-arrayBufferToBase64/utssdk/interface.uts @@ -0,0 +1,77 @@ +export interface Uni { + /** + * 将 ArrayBuffer 对象转成 Base64 字符串 + * + * @tutorial https://uniapp.dcloud.net.cn/api/arrayBufferToBase64.html + * @tutorial-uni-app https://uniapp.dcloud.net.cn/api/arrayBufferToBase64.html + * + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "ios": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.23", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * }, + * "mp":{ + * weixin: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * alipay: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * baidu: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * toutiao: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * lark: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * qq: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * kuaishou: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * jd: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * } + * } + * } + */ + arrayBufferToBase64: ArrayBufferToBase64; +} + +export type ArrayBufferToBase64 = (arrayBuffer: ArrayBuffer) => string; diff --git a/uni_modules/uni-arrayBufferToBase64/utssdk/protocol.uts b/uni_modules/uni-arrayBufferToBase64/utssdk/protocol.uts new file mode 100644 index 0000000000000000000000000000000000000000..3e2b6231aa6d78ae7f2b30a677496ede72a9e7fb --- /dev/null +++ b/uni_modules/uni-arrayBufferToBase64/utssdk/protocol.uts @@ -0,0 +1,10 @@ +export const API_ARRAY_BUFFER_TO_BASE64 = 'arrayBufferToBase64' +export const ArrayBufferToBase64Protocol = new Map([ + [ + 'arrayBuffer', + { + type: 'arrayBuffer', + required: true, + } + ] +]) diff --git a/uni_modules/uni-authentication/changelog.md b/uni_modules/uni-authentication/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-authentication/package.json b/uni_modules/uni-authentication/package.json new file mode 100644 index 0000000000000000000000000000000000000000..97438a4c45142c89c8847365e06cf2a24636f936 --- /dev/null +++ b/uni_modules/uni-authentication/package.json @@ -0,0 +1,112 @@ +{ + "id": "uni-authentication", + "displayName": "uni-authentication", + "version": "1.0.0", + "description": "uni-authentication", + "keywords": [ + "uni-authentication" +], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "uni-ext-api": { + "uni": { + "startSoterAuthentication": { + "name": "startSoterAuthentication", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + }, + "checkIsSupportSoterAuthentication": { + "name": "checkIsSupportSoterAuthentication", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + }, + "checkIsSoterEnrolledInDevice": { + "name": "checkIsSoterEnrolledInDevice", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "u", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-authentication/readme.md b/uni_modules/uni-authentication/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..402ef267f9967e4c6af443c7593ce0580fe65fc1 --- /dev/null +++ b/uni_modules/uni-authentication/readme.md @@ -0,0 +1,7 @@ +# uni-authentication + +### 开发文档 + +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS 原生插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts/-/tree/dev) diff --git a/uni_modules/uni-authentication/utssdk/app-harmony/index.uts b/uni_modules/uni-authentication/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..41ab7af1fd1bcbb49c189fe4859ea4abaf051169 --- /dev/null +++ b/uni_modules/uni-authentication/utssdk/app-harmony/index.uts @@ -0,0 +1,243 @@ +import { UTSHarmony } from '@dcloudio/uni-runtime'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { userAuth } from '@kit.UserAuthenticationKit'; +import { promptAction } from '@kit.ArkUI'; +import { + StartSoterAuthentication, StartSoterAuthenticationOptions, StartSoterAuthenticationSuccess, SoterAuthMode, + CheckIsSupportSoterAuthentication, CheckIsSupportSoterAuthenticationOptions, CheckIsSupportSoterAuthenticationSuccess, + CheckIsSoterEnrolledInDevice, CheckIsSoterEnrolledInDeviceOptions, CheckIsSoterEnrolledInDeviceSuccess +} from '../interface.uts'; +import { + API_START_SOTER_AUTHENTICATION, StartSoterAuthenticationApiOptions, StartSoterAuthenticationApiProtocols, + API_CHECK_IS_SOTER_ENROLLED_IN_DEVICE, CheckIsSoterEnrolledInDeviceApiOptions, CheckIsSoterEnrolledInDeviceProtocols, + API_CHECK_IS_SUPPORT_SOTER_AUTHENTICATION +} from '../protocol.uts'; + +function getErrorMessage(code: number): string { + switch (code) { + case 201: + return "权限认证失败"; + case 401: + return "参数不正确。可能的一个原因: 强制参数未指定"; + case userAuth.UserAuthResultCode.FAIL: + return "认证失败"; + case userAuth.UserAuthResultCode.GENERAL_ERROR: + return "操作通用错误"; + case userAuth.UserAuthResultCode.CANCELED: + return "操作取消"; + case userAuth.UserAuthResultCode.TIMEOUT: + return "操作超时"; + case userAuth.UserAuthResultCode.TYPE_NOT_SUPPORT: + return "不支持的认证类型"; + case userAuth.UserAuthResultCode.TRUST_LEVEL_NOT_SUPPORT: + return "不支持的认证等级"; + case userAuth.UserAuthResultCode.BUSY: + return "忙碌状态"; + case userAuth.UserAuthResultCode.LOCKED: + return "认证器已锁定"; + case userAuth.UserAuthResultCode.NOT_ENROLLED: + return "用户未录入认证信息"; + case userAuth.UserAuthResultCode.CANCELED_FROM_WIDGET: + return "切换到自定义身份验证过程"; + case 12500013: + return "系统锁屏密码过期"; + default: + return ''; + } +} + +function getUniErrMsg(code: number): number { + switch (code) { + case 201: + return 90002; + case 401: + return 90004; + case userAuth.UserAuthResultCode.FAIL: + return 90009; + case userAuth.UserAuthResultCode.GENERAL_ERROR: + return 90007; + case userAuth.UserAuthResultCode.CANCELED: + return 90008; + case userAuth.UserAuthResultCode.TIMEOUT: + return 90007; + case userAuth.UserAuthResultCode.TYPE_NOT_SUPPORT: + return 90003; + case userAuth.UserAuthResultCode.TRUST_LEVEL_NOT_SUPPORT: + return 90003; + case userAuth.UserAuthResultCode.BUSY: + return 90010; + case userAuth.UserAuthResultCode.LOCKED: + return 90010; + case userAuth.UserAuthResultCode.NOT_ENROLLED: + return 90011; + case userAuth.UserAuthResultCode.CANCELED_FROM_WIDGET: + return userAuth.UserAuthResultCode.CANCELED_FROM_WIDGET; + case 12500013: + return 12500013; + default: + return -1; + } +} + +function toUint8Arr(str: string) { + const buffer: number[] = []; + for (let i of str) { + const _code: number = i.charCodeAt(0); + if (_code < 0x80) { + buffer.push(_code); + } else if (_code < 0x800) { + buffer.push(0xc0 + (_code >> 6)); + buffer.push(0x80 + (_code & 0x3f)); + } else if (_code < 0x10000) { + buffer.push(0xe0 + (_code >> 12)); + buffer.push(0x80 + (_code >> 6 & 0x3f)); + buffer.push(0x80 + (_code & 0x3f)); + } + } + return Uint8Array.from(buffer); +} + +export const startSoterAuthentication: StartSoterAuthentication = defineAsyncApi( + API_START_SOTER_AUTHENTICATION, + (args: StartSoterAuthenticationOptions, executor: ApiExecutor) => { + const authType: userAuth.UserAuthType[] = [] + args.requestAuthModes.forEach((item) => { + if (item === 'fingerPrint') { + authType.push(userAuth.UserAuthType.FINGERPRINT) + } else if (item === 'facial') { + authType.push(userAuth.UserAuthType.FACE) + } + }) + + // uni的字符串challenge转换成鸿蒙的数组challenge + const challengeArr = toUint8Arr(args.challenge ?? '') + const authContent = args.authContent ?? '' + try { + const auth = userAuth.getUserAuthInstance( + { + challenge: challengeArr, + authType, + authTrustLevel: userAuth.AuthTrustLevel.ATL1 + } as userAuth.AuthParam, + { + title: authContent + } as userAuth.WidgetParam + ); + + auth.on("result", { + onResult: (result: userAuth.UserAuthResult) => { + if (result.result === userAuth.UserAuthResultCode.SUCCESS) { + executor.resolve({ + errCode: 0, + authMode: result.authType === userAuth.UserAuthType.FINGERPRINT ? 'fingerPrint' : 'facial' + } as StartSoterAuthenticationSuccess); + } else { + const errMsg = getErrorMessage(result.result) + const errCode = getUniErrMsg(result.result) + executor.reject(errMsg, { errCode } as ApiError); + } + } + } as userAuth.IAuthCallback); + + if (authContent) { + promptAction.showToast({ + message: authContent + } as promptAction.ShowToastOptions) + } + auth.start(); + } catch (error) { + const code = (error as BusinessError).code + executor.reject(getErrorMessage(code), { errCode: getUniErrMsg(code) } as ApiError); + } + }, + StartSoterAuthenticationApiProtocols, + StartSoterAuthenticationApiOptions +) as StartSoterAuthentication + +function fingerPrintAvailable() { + try { + userAuth.getAvailableStatus(userAuth.UserAuthType.FINGERPRINT, userAuth.AuthTrustLevel.ATL1); + return true + } catch (error) { + return false + } +} + +function faceAvailable() { + try { + userAuth.getAvailableStatus(userAuth.UserAuthType.FACE, userAuth.AuthTrustLevel.ATL1); + return true + } catch (error) { + return false + } +} + +const PERMISSIONS = ['ohos.permission.ACCESS_BIOMETRIC'] +export const checkIsSupportSoterAuthentication: CheckIsSupportSoterAuthentication = defineAsyncApi( + API_CHECK_IS_SUPPORT_SOTER_AUTHENTICATION, + (args: CheckIsSupportSoterAuthenticationOptions, executor: ApiExecutor) => { + UTSHarmony.requestSystemPermission(PERMISSIONS, (allRight: boolean) => { + if (allRight) { + try { + const supportMode: SoterAuthMode[] = [] + if (fingerPrintAvailable()) supportMode.push('fingerPrint') + if (faceAvailable()) supportMode.push('facial') + return executor.resolve({ supportMode, errMsg: '' } as CheckIsSupportSoterAuthenticationSuccess) + } catch (error) { + const code = (error as BusinessError).code + executor.reject(getErrorMessage(code), { errCode: getUniErrMsg(code) } as ApiError); + } + } else { + executor.reject(getErrorMessage(201)) + } + }, () => { + executor.reject(getErrorMessage(201)) + }) + } +) as CheckIsSupportSoterAuthentication + + + +function getFingerPrintEnrolledState() { + userAuth.getEnrolledState(userAuth.UserAuthType.FINGERPRINT); + return true +} + +function getFaceEnrolledState() { + userAuth.getEnrolledState(userAuth.UserAuthType.FACE); + return true +} + +function harmonyCheckIsSoterEnrolledInDevice(checkAuthMode: SoterAuthMode): boolean { + if (checkAuthMode === 'fingerPrint') { + return getFingerPrintEnrolledState() + } else if (checkAuthMode === 'facial') { + return getFaceEnrolledState() + } + return false +} +export const checkIsSoterEnrolledInDevice: CheckIsSoterEnrolledInDevice = defineAsyncApi( + API_CHECK_IS_SOTER_ENROLLED_IN_DEVICE, + (args: CheckIsSoterEnrolledInDeviceOptions, executor: ApiExecutor) => { + UTSHarmony.requestSystemPermission(PERMISSIONS, (allRight: boolean) => { + if (allRight) { + try { + const isEnrolled = harmonyCheckIsSoterEnrolledInDevice(args.checkAuthMode) + executor.resolve({ + isEnrolled, + errMsg: '' + } as CheckIsSoterEnrolledInDeviceSuccess) + } catch (error) { + const code = (error as BusinessError).code + executor.reject(getErrorMessage(code), { errCode: getUniErrMsg(code) } as ApiError); + } + } else { + executor.reject(getErrorMessage(201)) + } + }, () => { + executor.reject(getErrorMessage(201)) + }) + }, + CheckIsSoterEnrolledInDeviceProtocols, + CheckIsSoterEnrolledInDeviceApiOptions +) as CheckIsSoterEnrolledInDevice diff --git a/uni_modules/uni-authentication/utssdk/interface.uts b/uni_modules/uni-authentication/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..564dc37210f0a7eacb84b70b674072edcc439df9 --- /dev/null +++ b/uni_modules/uni-authentication/utssdk/interface.uts @@ -0,0 +1,171 @@ + +export interface Uni { + /** + * 开始 SOTER 生物认证 + * + * 文档: [http://uniapp.dcloud.io/api/system/authentication?id=startsoterauthentication](http://uniapp.dcloud.io/api/system/authentication?id=startsoterauthentication) + */ + startSoterAuthentication: StartSoterAuthentication; + /** + * 获取本机支持的 SOTER 生物认证方式 + * + * 文档: [http://uniapp.dcloud.io/api/system/authentication?id=checkissupportsoterauthentication](http://uniapp.dcloud.io/api/system/authentication?id=checkissupportsoterauthentication) + */ + checkIsSupportSoterAuthentication: CheckIsSupportSoterAuthentication; + /** + * 获取设备内是否录入如指纹等生物信息 + * + * 文档: [http://uniapp.dcloud.io/api/system/authentication?id=checkissoterenrolledindevice](http://uniapp.dcloud.io/api/system/authentication?id=checkissoterenrolledindevice) + */ + checkIsSoterEnrolledInDevice: CheckIsSoterEnrolledInDevice; +} + +export type StartSoterAuthentication = (options: StartSoterAuthenticationOptions) => void; +/** +* 生物认证方式 +*/ +export type SoterAuthMode = +/** + * 指纹识别 + */ +'fingerPrint' | +/** + * 人脸识别(暂未支持) + */ +'facial' | +/** + * 声纹识别(暂未支持) + */ +'speech'; + +export type StartSoterAuthenticationSuccess = { + /** + * 错误码 + */ + errCode: number, + /** + * 生物认证方式 + * - fingerPrint: 指纹识别 + * - facial: 人脸识别(暂未支持) + * - speech: 声纹识别(暂未支持) + */ + authMode: SoterAuthMode, + /** + * 在设备安全区域(TEE)内获得的本机安全信息以及本次认证信息 + */ + resultJSON?: string | null, + /** + * 用SOTER安全密钥对 resultJSON 的签名(SHA256 with RSA/PSS, saltlen=20) + */ + resultJSONSignature?: string | null, + /** + * 接口调用结果 + */ + errMsg: string +}; +export type StartSoterAuthenticationSuccessCallback = (result: StartSoterAuthenticationSuccess) => void; +export type StartSoterAuthenticationFail = UniError; +export type UniError = { + errSubject: string, + errCode: number, + errMsg: string, + data?: object | null, + cause?: any | null +}; +export type StartSoterAuthenticationFailCallback = (result: StartSoterAuthenticationFail) => void; +export type StartSoterAuthenticationComplete = any; +export type StartSoterAuthenticationCompleteCallback = (result: StartSoterAuthenticationComplete) => void; +export type StartSoterAuthenticationOptions = { + /** + * 请求使用的可接受的生物认证方式 + */ + requestAuthModes: SoterAuthMode[], + /** + * 挑战因子 + */ + challenge?: string | null, + /** + * 验证描述,即识别过程中显示在界面上的对话框提示内容 + */ + authContent?: string | null, + /** + * 接口调用成功的回调函数 + */ + success?: StartSoterAuthenticationSuccessCallback | null, + /** + * 接口调用失败的回调函数 + */ + fail?: StartSoterAuthenticationFailCallback | null, + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + complete?: StartSoterAuthenticationCompleteCallback | null +}; +export type CheckIsSupportSoterAuthentication = (options: CheckIsSupportSoterAuthenticationOptions) => void; +export type CheckIsSupportSoterAuthenticationSuccess = { + /** + * 接口调用成功的回调函数 + */ + supportMode: SoterAuthMode[], + /** + * 接口调用结果 + */ + errMsg: string +}; +export type CheckIsSupportSoterAuthenticationSuccessCallback = (result: CheckIsSupportSoterAuthenticationSuccess) => void; +export type CheckIsSupportSoterAuthenticationFail = UniError; +export type CheckIsSupportSoterAuthenticationFailCallback = (result: CheckIsSupportSoterAuthenticationFail) => void; +export type CheckIsSupportSoterAuthenticationComplete = any; +export type CheckIsSupportSoterAuthenticationCompleteCallback = (result: CheckIsSupportSoterAuthenticationComplete) => void; +export type CheckIsSupportSoterAuthenticationOptions = { + /** + * 接口调用成功的回调函数 + */ + success?: CheckIsSupportSoterAuthenticationSuccessCallback | null, + /** + * 接口调用失败的回调函数 + */ + fail?: CheckIsSupportSoterAuthenticationFailCallback | null, + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + complete?: CheckIsSupportSoterAuthenticationCompleteCallback | null +}; +export type CheckIsSoterEnrolledInDevice = (options: CheckIsSoterEnrolledInDeviceOptions) => void; +export type CheckIsSoterEnrolledInDeviceSuccess = { + /** + * 是否已录入信息 + * @type boolean + */ + isEnrolled: boolean, + /** + * 错误信息 + */ + errMsg: string +}; +export type CheckIsSoterEnrolledInDeviceSuccessCallback = (result: CheckIsSoterEnrolledInDeviceSuccess) => void; +export type CheckIsSoterEnrolledInDeviceFail = UniError; +export type CheckIsSoterEnrolledInDeviceFailCallback = (result: CheckIsSoterEnrolledInDeviceFail) => void; +export type CheckIsSoterEnrolledInDeviceComplete = any; +export type CheckIsSoterEnrolledInDeviceCompleteCallback = (result: CheckIsSoterEnrolledInDeviceComplete) => void; +export type CheckIsSoterEnrolledInDeviceOptions = { + /** + * 生物认证方式 + * - fingerPrint: 指纹识别 + * - facial: 人脸识别(暂未支持) + * - speech: 声纹识别(暂未支持) + */ + checkAuthMode: SoterAuthMode, + /** + * 接口调用成功的回调函数 + */ + success?: CheckIsSoterEnrolledInDeviceSuccessCallback | null, + /** + * 接口调用失败的回调函数 + */ + fail?: CheckIsSoterEnrolledInDeviceFailCallback | null, + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + complete?: CheckIsSoterEnrolledInDeviceCompleteCallback | null +}; diff --git a/uni_modules/uni-authentication/utssdk/protocol.uts b/uni_modules/uni-authentication/utssdk/protocol.uts new file mode 100644 index 0000000000000000000000000000000000000000..46219ba6213cbc6f4b0fd2300fbcb204cd3719c6 --- /dev/null +++ b/uni_modules/uni-authentication/utssdk/protocol.uts @@ -0,0 +1,60 @@ +import { StartSoterAuthenticationOptions, CheckIsSoterEnrolledInDeviceOptions, SoterAuthMode } from './interface.uts'; +export const API_START_SOTER_AUTHENTICATION = 'startSoterAuthentication' + +export const StartSoterAuthenticationApiOptions: ApiOptions = { + formatArgs: new Map string | undefined)>([ + ['requestAuthModes', function (value: string) { + if (!value.includes('fingerPrint') && !value.includes('facial')) { + return 'requestAuthModes 填写错误' + } + return undefined + }] + ]) +} + +export const StartSoterAuthenticationApiProtocols = new Map([ + [ + 'requestAuthModes', + { + type: 'array', + required: true + } + ], + [ + 'challenge', + { + type: 'string' + } + ], + [ + 'authContent', + { + type: 'string' + } + ] +]) + + +export const API_CHECK_IS_SOTER_ENROLLED_IN_DEVICE = 'checkIsSoterEnrolledInDevice' +export const checkAuthModes: SoterAuthMode[] = ['fingerPrint', 'facial', 'speech'] +export const CheckIsSoterEnrolledInDeviceApiOptions: ApiOptions = { + formatArgs: new Map string | undefined)>([ + ['checkAuthMode', function (value: string) { + if (!checkAuthModes.includes(value as SoterAuthMode)) { + return 'checkAuthMode 填写错误' + } + return undefined + }] + ]) +} + +export const CheckIsSoterEnrolledInDeviceProtocols = new Map([ + [ + 'checkAuthMode', + { + type: 'string' + } + ] +]) + +export const API_CHECK_IS_SUPPORT_SOTER_AUTHENTICATION = 'checkIsSupportSoterAuthentication' diff --git a/uni_modules/uni-base64ToArrayBuffer/changelog.md b/uni_modules/uni-base64ToArrayBuffer/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-base64ToArrayBuffer/package.json b/uni_modules/uni-base64ToArrayBuffer/package.json new file mode 100644 index 0000000000000000000000000000000000000000..50c1b0c0b7c9946e941ed349d90e5a5f1eb6fb2e --- /dev/null +++ b/uni_modules/uni-base64ToArrayBuffer/package.json @@ -0,0 +1,94 @@ +{ + "id": "uni-base64ToArrayBuffer", + "displayName": "uni-base64ToArrayBuffer", + "version": "1.0.0", + "description": "uni-base64ToArrayBuffer", + "keywords": [ + "uni-base64ToArrayBuffer" +], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "uni-ext-api": { + "uni": { + "base64ToArrayBuffer": { + "name": "base64ToArrayBuffer", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "u", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-base64ToArrayBuffer/readme.md b/uni_modules/uni-base64ToArrayBuffer/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..246073ffe4705e84d9799c16742f36051f2f3ac0 --- /dev/null +++ b/uni_modules/uni-base64ToArrayBuffer/readme.md @@ -0,0 +1,7 @@ +# uni-base64ToArrayBuffer + +### 开发文档 + +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS 原生插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts/-/tree/dev) diff --git a/uni_modules/uni-base64ToArrayBuffer/utssdk/app-harmony/index.uts b/uni_modules/uni-base64ToArrayBuffer/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..330400bd5b870f5a8e29a905dd53b17472908a5a --- /dev/null +++ b/uni_modules/uni-base64ToArrayBuffer/utssdk/app-harmony/index.uts @@ -0,0 +1,11 @@ +import buffer from '@ohos.buffer'; +import { Base64ToArrayBuffer } from '../interface.uts'; +import { Base64ToArrayBufferProtocol, API_BASE64_TO_ARRAY_BUFFER } from '../protocol.uts'; + +export const base64ToArrayBuffer: Base64ToArrayBuffer = defineSyncApi( + API_BASE64_TO_ARRAY_BUFFER, + (base64: string): ArrayBuffer => { + return buffer.from(base64, 'base64').buffer + }, + Base64ToArrayBufferProtocol +) as Base64ToArrayBuffer diff --git a/uni_modules/uni-base64ToArrayBuffer/utssdk/interface.uts b/uni_modules/uni-base64ToArrayBuffer/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..9a257a32138193d9e23e5bcd9c5338f0d465157e --- /dev/null +++ b/uni_modules/uni-base64ToArrayBuffer/utssdk/interface.uts @@ -0,0 +1,77 @@ +export interface Uni { + /** + * 将 Base64 字符串转成 ArrayBuffer 对象 + * + * @tutorial https://uniapp.dcloud.net.cn/api/base64ToArrayBuffer.html + * @tutorial-uni-app https://uniapp.dcloud.net.cn/api/base64ToArrayBuffer.html + * + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "ios": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.23", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * }, + * "mp":{ + * weixin: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * alipay: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * baidu: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * toutiao: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * lark: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * qq: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * kuaishou: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * }, + * jd: { + * hostVer: '√', + * uniVer: '√', + * unixVer: 'x' + * } + * } + * } + */ + base64ToArrayBuffer: Base64ToArrayBuffer; +} + +export type Base64ToArrayBuffer = (base64: string) => ArrayBuffer; diff --git a/uni_modules/uni-base64ToArrayBuffer/utssdk/protocol.uts b/uni_modules/uni-base64ToArrayBuffer/utssdk/protocol.uts new file mode 100644 index 0000000000000000000000000000000000000000..87642e87e3e7821676d16a380d2c0635ad6ea04f --- /dev/null +++ b/uni_modules/uni-base64ToArrayBuffer/utssdk/protocol.uts @@ -0,0 +1,11 @@ +export const API_BASE64_TO_ARRAY_BUFFER = 'base64ToArrayBuffer' +export const Base64ToArrayBufferProtocol = new Map([ + [ + 'base64', + { + type: 'string', + required: true, + } + ] + +]) diff --git a/uni_modules/uni-clipboard/changelog.md b/uni_modules/uni-clipboard/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-clipboard/package.json b/uni_modules/uni-clipboard/package.json new file mode 100644 index 0000000000000000000000000000000000000000..4e41b70d6ad56efb3124b2a20b085fd515434a89 --- /dev/null +++ b/uni_modules/uni-clipboard/package.json @@ -0,0 +1,103 @@ +{ + "id": "uni-clipboard", + "displayName": "uni-clipboard", + "version": "1.0.0", + "description": "uni-clipboard", + "keywords": [ + "uni-clipboard" +], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "uni-ext-api": { + "uni": { + "getClipboardData": { + "name": "getClipboardData", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + }, + "setClipboardData": { + "name": "setClipboardData", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "u", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-clipboard/readme.md b/uni_modules/uni-clipboard/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..a3b6f6a25f6c8f8ed62c5e62c439edff98cfc3fd --- /dev/null +++ b/uni_modules/uni-clipboard/readme.md @@ -0,0 +1,7 @@ +# uni-clipboard + +### 开发文档 + +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS 原生插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts/-/tree/dev) diff --git a/uni_modules/uni-clipboard/utssdk/app-harmony/index.uts b/uni_modules/uni-clipboard/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..221825a628c76e4bc71747a06bd75174c7d52302 --- /dev/null +++ b/uni_modules/uni-clipboard/utssdk/app-harmony/index.uts @@ -0,0 +1,35 @@ +import { clipboard } from '@dcloudio/uni-runtime'; +import { SetClipboardData, GetClipboardData, SetClipboardDataOptions, SetClipboardDataSuccess, GetClipboardDataOptions, GetClipboardDataSuccess } from '../interface.uts'; +import { API_GET_CLIPBOARD_DATA, API_SET_CLIPBOARD_DATA, SetClipboardDataApiOptions, SetClipboardDataProtocol } from '../protocol.uts'; + +export { SetClipboardData, GetClipboardData, SetClipboardDataOptions, SetClipboardDataSuccess, GetClipboardDataOptions, GetClipboardDataSuccess } + +interface ClipboardModuleGetStringOptions { + result: string + data: string +} + +export const getClipboardData: GetClipboardData = defineAsyncApi( + API_GET_CLIPBOARD_DATA, + (_: GetClipboardDataOptions, res: ApiExecutor) => { + clipboard.getString((ret: ClipboardModuleGetStringOptions) => { + if (ret.result === 'success') { + res.resolve({ + data: ret.data, + } as GetClipboardDataSuccess) + } else { + res.reject('getClipboardData:fail') + } + }) + } +) as GetClipboardData + +export const setClipboardData: SetClipboardData = defineAsyncApi( + API_SET_CLIPBOARD_DATA, + (options: SetClipboardDataOptions, res: ApiExecutor) => { + clipboard.setString(options.data) + res.resolve() + }, + SetClipboardDataProtocol, + SetClipboardDataApiOptions +) as SetClipboardData diff --git a/uni_modules/uni-clipboard/utssdk/interface.uts b/uni_modules/uni-clipboard/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..da6b7b9db863aba46933e75fd6f207e92895b8be --- /dev/null +++ b/uni_modules/uni-clipboard/utssdk/interface.uts @@ -0,0 +1,203 @@ +export interface Uni { + /** + * 设置系统剪贴板的内容 + * + * @tutorial https://uniapp.dcloud.net.cn/api/system/clipboard.html#setclipboarddata + * @tutorial-uni-app https://uniapp.dcloud.net.cn/api/system/clipboard.html#setclipboarddata + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.23", + * "unixVer": "x" + * } + * }, + * "mp": { + * "weixin": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "alipay": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "baidu": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "toutiao": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "lark": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "qq": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "kuaishou": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "jd": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * } + * } + */ + setClipboardData: SetClipboardData; + /** + * 获得系统剪贴板的内容 + * + * @tutorial https://uniapp.dcloud.net.cn/api/system/clipboard.html#getclipboarddata + * @tutorial-uni-app https://uniapp.dcloud.net.cn/api/system/clipboard.html#getclipboarddata + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.23", + * "unixVer": "x" + * } + * }, + * "mp": { + * "weixin": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "alipay": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "baidu": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "toutiao": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "lark": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "√" + * }, + * "qq": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "kuaishou": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "jd": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * } + * } + */ + getClipboardData: GetClipboardData; +} + +export type SetClipboardData = (options: SetClipboardDataOptions) => void; +export type SetClipboardDataSuccess = {}; +export type SetClipboardDataSuccessCallback = (result: SetClipboardDataSuccess) => void; +export type SetClipboardDataFail = UniError; +export type SetClipboardDataFailCallback = (result: SetClipboardDataFail) => void; +export type SetClipboardDataComplete = any; +export type SetClipboardDataCompleteCallback = (result: SetClipboardDataComplete) => void; +export type SetClipboardDataOptions = { + /** + * 需要设置的内容 + */ + data: string, + /** + * 是否弹出提示,默认弹出提示 + * @type boolean + */ + showToast?: boolean | null, + /** + * 成功返回的回调函数 + */ + success?: SetClipboardDataSuccessCallback | null, + /** + * 失败的回调函数 + */ + fail?: SetClipboardDataFailCallback | null, + /** + * 结束的回调函数(调用成功、失败都会执行) + */ + complete?: SetClipboardDataCompleteCallback | null +}; +export type GetClipboardData = (options: GetClipboardDataOptions) => void; +export type GetClipboardDataSuccess = { + /** + * 剪贴板的内容 + */ + data: string +}; +export type GetClipboardDataSuccessCallback = (result: GetClipboardDataSuccess) => void; +export type GetClipboardDataFail = UniError; +export type GetClipboardDataFailCallback = (result: GetClipboardDataFail) => void; +export type GetClipboardDataComplete = any; +export type GetClipboardDataCompleteCallback = (result: GetClipboardDataComplete) => void; +export type GetClipboardDataOptions = { + /** + * 成功返回的回调函数 + */ + success?: GetClipboardDataSuccessCallback | null, + /** + * 失败的回调函数 + */ + fail?: GetClipboardDataFailCallback | null, + /** + * 结束的回调函数(调用成功、失败都会执行) + */ + complete?: GetClipboardDataCompleteCallback | null +}; diff --git a/uni_modules/uni-clipboard/utssdk/protocol.uts b/uni_modules/uni-clipboard/utssdk/protocol.uts new file mode 100644 index 0000000000000000000000000000000000000000..cc65deaf6f98dacca924aa4c4b4c75fb4c67687f --- /dev/null +++ b/uni_modules/uni-clipboard/utssdk/protocol.uts @@ -0,0 +1,26 @@ +import { SetClipboardDataOptions } from './interface.uts'; + +export const API_GET_CLIPBOARD_DATA = 'getClipboardData' +export const API_SET_CLIPBOARD_DATA = 'setClipboardData' +export const SetClipboardDataApiOptions: ApiOptions = { + formatArgs: new Map([ + ['showToast', true] + ]) +} + +export const SetClipboardDataProtocol = new Map([ + [ + 'data', + { + type: 'string', + required: true, + } + ], + [ + 'showToast', + { + type: 'boolean' + } + + ] +]) diff --git a/uni_modules/uni-createIntersectionObserver/changelog.md b/uni_modules/uni-createIntersectionObserver/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-createIntersectionObserver/package.json b/uni_modules/uni-createIntersectionObserver/package.json new file mode 100644 index 0000000000000000000000000000000000000000..fe015ae1f137282413e4d78ed2fbb10c65ee88f8 --- /dev/null +++ b/uni_modules/uni-createIntersectionObserver/package.json @@ -0,0 +1,93 @@ +{ + "id": "uni-createIntersectionObserver", + "displayName": "uni-createIntersectionObserver", + "version": "1.0.0", + "description": "uni-createIntersectionObserver", + "keywords": [ + "uni-createIntersectionObserver" + ], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "encrypt": [], + "uni-ext-api": { + "uni": { + "createIntersectionObserver": { + "name": "createIntersectionObserver", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "u", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-createIntersectionObserver/readme.md b/uni_modules/uni-createIntersectionObserver/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..d086e3a5ef08535e4b10a7b6c78795e4d3db7c94 --- /dev/null +++ b/uni_modules/uni-createIntersectionObserver/readme.md @@ -0,0 +1,6 @@ +# uni-createIntersectionObserver +### 开发文档 +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts) diff --git a/uni_modules/uni-createIntersectionObserver/utssdk/app-harmony/index.uts b/uni_modules/uni-createIntersectionObserver/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..51d0908d762c20c0c64a37ff9ce4491336a3c50d --- /dev/null +++ b/uni_modules/uni-createIntersectionObserver/utssdk/app-harmony/index.uts @@ -0,0 +1,134 @@ +import { + resolveComponentInstance, + extend, + isFunction, + getCurrentPageVm, + getPageIdByVm, + addIntersectionObserver, + removeIntersectionObserver, +} from '@dcloudio/uni-runtime' +import { CreateIntersectionObserver, CreateIntersectionObserverOptions, ObserveCallback, IntersectionObserver } from '../interface.uts' + +export { CreateIntersectionObserver, CreateIntersectionObserverOptions, ObserveCallback, IntersectionObserver } + +interface AddIntersectionObserverArgs { + reqId: number + component: ComponentPublicInstance + options: ServiceIntersectionObserverOptions + callback: ObserveCallback +} + +interface RemoveIntersectionObserverArgs { + reqId: number + component: ComponentPublicInstance +} + +interface RequestComponentObserverOptions { + selector?: string + rootMargin?: string + relativeToSelector?: string +} + +interface ServiceIntersectionObserverOptions extends CreateIntersectionObserverOptions, RequestComponentObserverOptions { } + +interface Margins { + /** 节点布局区域的下边界 */ + bottom?: number, + /** 节点布局区域的左边界 */ + left?: number, + /** 节点布局区域的右边界 */ + right?: number, + /** 节点布局区域的上边界 */ + top?: number +} + +const defaultOptions = { + thresholds: [0], + initialRatio: 0, + observeAll: false, +} as CreateIntersectionObserverOptions + +let reqComponentObserverId = 1 + +function normalizeRootMargin(margins: Margins | null = {}) { + if (!margins) margins = {} + const top = Number(margins.top) || 0 + const right = Number(margins.right) || 0 + const bottom = Number(margins.bottom) || 0 + const left = Number(margins.left) || 0 + return `${top}px ${right}px ${bottom}px ${left}px` +} +class ServiceIntersectionObserver { + private _reqId?: number + private _pageId: number + private _component: ComponentPublicInstance + private _options: ServiceIntersectionObserverOptions + constructor( + component: ComponentPublicInstance, + options?: CreateIntersectionObserverOptions + ) { + this._pageId = getPageIdByVm(component)! + this._component = component + if (options) { + if (typeof options.thresholds === 'undefined') options.thresholds = defaultOptions.thresholds + if (typeof options.initialRatio === 'undefined') options.initialRatio = defaultOptions.initialRatio + if (typeof options.observeAll === 'undefined') options.observeAll = defaultOptions.observeAll + } + this._options = (options ?? defaultOptions) as ServiceIntersectionObserverOptions + } + + relativeTo(selector: string, margins?: Margins) { + this._options.relativeToSelector = selector + this._options.rootMargin = normalizeRootMargin(margins) + return this + } + + relativeToViewport(margins?: Margins) { + this._options.relativeToSelector = undefined + this._options.rootMargin = normalizeRootMargin(margins) + return this + } + + observe( + selector: string, + callback: ObserveCallback + ) { + if (!isFunction(callback)) { + return + } + this._options.selector = selector + this._reqId = reqComponentObserverId++ + addIntersectionObserver( + { + reqId: this._reqId, + component: this._component, + options: this._options, + callback, + } as AddIntersectionObserverArgs, + this._pageId + ) + } + + disconnect() { + this._reqId && + removeIntersectionObserver( + { reqId: this._reqId, component: this._component } as RemoveIntersectionObserverArgs, + this._pageId + ) + } +} +export const createIntersectionObserver = defineSyncApi( + 'createIntersectionObserver', + (context: ComponentPublicInstance | null, options?: CreateIntersectionObserverOptions) => { + let _options: ComponentPublicInstance | CreateIntersectionObserverOptions | null = options + context = resolveComponentInstance(context) + if (context && !getPageIdByVm(context)) { + _options = context + context = null + } + if (context) { + return new ServiceIntersectionObserver(context as ComponentPublicInstance, _options as CreateIntersectionObserverOptions) + } + return new ServiceIntersectionObserver(getCurrentPageVm()!, _options as CreateIntersectionObserverOptions) + } +) as CreateIntersectionObserver diff --git a/uni_modules/uni-createIntersectionObserver/utssdk/interface.uts b/uni_modules/uni-createIntersectionObserver/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..121148691184884d34e1bdef253b833077e3e777 --- /dev/null +++ b/uni_modules/uni-createIntersectionObserver/utssdk/interface.uts @@ -0,0 +1,152 @@ +export interface Uni { + /** + * 创建并返回一个 IntersectionObserver 对象实例 + * + * @tutorial https://uniapp.dcloud.net.cn/api/ui/intersection-observer.html#createintersectionobserver + * @tutorial-uni-app https://uniapp.dcloud.net.cn/api/ui/intersection-observer.html#createintersectionobserver + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.23", + * "unixVer": "x" + * } + * }, + * "mp": { + * "weixin": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "alipay": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "baidu": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "toutiao": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "lark": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "qq": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "kuaishou": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "jd": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * } + * } + */ + createIntersectionObserver: CreateIntersectionObserver; +} + +export type CreateIntersectionObserver = (component: any, options: CreateIntersectionObserverOptions) => IntersectionObserver; + +export interface CreateIntersectionObserverOptions { + /** + * 所有阈值 + */ + thresholds?: (any[]) | null, + /** + * 初始的相交比例 + */ + initialRatio?: number | null, + /** + * 是否同时观测多个参照节点(而非一个) + */ + observeAll?: boolean | null +}; +export type ObserveNodeRect = { + /** + * left + */ + left: number, + /** + * right + */ + right: number, + /** + * top + */ + top: number, + /** + * bottom + */ + bottom: number +}; +export type ObserveResult = { + /** + * 相交比例 + */ + intersectionRatio: number, + /** + * 相交区域的边界 + */ + intersectionRect: any, + /** + * 目标节点布局区域的边界 + */ + boundingClientRect: ObserveNodeRect, + /** + * 参照区域的边界 + */ + relativeRect: ObserveNodeRect, + /** + * 相交检测时的时间戳 + */ + time: number +}; + +export type ObserveCallback = (result: ObserveResult) => void; + +export interface IntersectionObserver { + /** + * 使用选择器指定一个节点,作为参照区域之一 + */ + relativeTo(selector: string, margins?: any): IntersectionObserver; + /** + * 指定页面显示区域作为参照区域之一 + */ + relativeToViewport(margins?: any): IntersectionObserver; + /** + * 指定目标节点并开始监听相交状态变化情况 + */ + observe(targetSelector: string, callback: ObserveCallback): void; + /** + * 停止监听 + */ + disconnect(): void; +} diff --git a/uni_modules/uni-file/changelog.md b/uni_modules/uni-file/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-file/package.json b/uni_modules/uni-file/package.json new file mode 100644 index 0000000000000000000000000000000000000000..b5bc015a0a856d07cb989a62f10558cdaaacf319 --- /dev/null +++ b/uni_modules/uni-file/package.json @@ -0,0 +1,130 @@ +{ + "id": "uni-file", + "displayName": "uni-file", + "version": "1.0.0", + "description": "uni-file", + "keywords": [ + "uni-file" + ], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "uni-ext-api": { + "uni": { + "saveFile": { + "name": "saveFile", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + }, + "getSavedFileList": { + "name": "getSavedFileList", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + }, + "getSavedFileInfo": { + "name": "getSavedFileInfo", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + }, + "removeSavedFile": { + "name": "removeSavedFile", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + }, + "getFileInfo": { + "name": "getFileInfo", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "y", + "vue3": "y" + }, + "App": { + "app-android": "y", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-file/readme.md b/uni_modules/uni-file/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..53cdaf4a3a751975806a4e0afbcbb8afcdc1a664 --- /dev/null +++ b/uni_modules/uni-file/readme.md @@ -0,0 +1,6 @@ +# uni-scanCode +### 开发文档 +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts) diff --git a/uni_modules/uni-file/utssdk/app-harmony/index.uts b/uni_modules/uni-file/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..4dd7147826e94edfead6a8c2c805a30ac90099ca --- /dev/null +++ b/uni_modules/uni-file/utssdk/app-harmony/index.uts @@ -0,0 +1,221 @@ +import { + API_SAVE_FILE, + API_GET_SAVED_FILE_LIST, + API_GET_SAVED_FILE_INFO, + API_REMOVE_SAVED_FILE, + API_GET_FILE_INFO +} from '../protocol.uts' +import { + SaveFile, + SaveFileOptions, + SaveFileSuccess, + SaveFileFail, + GetSavedFileList, + GetSavedFileListOptions, + SavedFileListItem, + GetSavedFileListSuccess, + GetSavedFileListFail, + GetSavedFileInfo, + GetSavedFileInfoOptions, + GetSavedFileInfoSuccess, + GetSavedFileInfoFail, + RemoveSavedFile, + RemoveSavedFileOptions, + RemoveSavedFileSuccess, + RemoveSavedFileFail, + GetFileInfo, + GetFileInfoOptions, + GetFileInfoSuccess, + GetFileInfoFail +} from '../interface.uts' +import { + getEnv, + getRealPath, +} from '@dcloudio/uni-runtime' +import fs from '@ohos.file.fs' +import { ListFileOptions } from '@ohos.file.fs' +import Hash from '@ohos.file.hash'; + +export { + SaveFile, + SaveFileOptions, + SaveFileSuccess, + SaveFileFail, + GetSavedFileList, + SavedFileListItem, + GetSavedFileListOptions, + GetSavedFileListSuccess, + GetSavedFileListFail, + GetSavedFileInfo, + GetSavedFileInfoOptions, + GetSavedFileInfoSuccess, + GetSavedFileInfoFail, + RemoveSavedFile, + RemoveSavedFileOptions, + RemoveSavedFileSuccess, + RemoveSavedFileFail, + GetFileInfo, + GetFileInfoOptions, + GetFileInfoSuccess, + GetFileInfoFail +} + +function getSavedDir(appId: string) { + return getEnv().USER_DATA_PATH + '/' + appId + '/saved' +} + +let savedIndex: [string, number] = ['0', 0] +function getSavedFileName(filePath: string) { + const ext = filePath.split('/').pop()?.split('.').slice(1).join('.') + let fileName = Date.now() + '' + if (savedIndex[0] === fileName) { + savedIndex[1]++ + if (savedIndex[1] > 0) { + fileName += '-' + savedIndex[1] + } + } else { + savedIndex[0] = fileName + savedIndex[1] = 0 + } + if (ext) { + fileName += '.' + ext + } + return fileName +} + +function getFsPath(filePath: string) { + filePath = getRealPath(filePath) as string + if (!/^file:/.test(filePath)) { + return filePath + } + const rawPath = filePath.replace(/^file:\/\//, '') + if (rawPath[0] === '/') { + return rawPath + } + return filePath +} + +export const saveFile: SaveFile = defineAsyncApi( + API_SAVE_FILE, + function (options: SaveFileOptions, exec: ApiExecutor) { + const tempFilePath = getRealPath(options.tempFilePath) as string; + const savedPath = getSavedDir(APP_ID) + if (!fs.accessSync(savedPath)) { + fs.mkdirSync(savedPath, true) + } + let srcFile: fs.File + try { + srcFile = fs.openSync(tempFilePath, fs.OpenMode.READ_ONLY) + } catch (error) { + exec.reject((error as Error).message) + return + } + const savedFilePath = savedPath + '/' + getSavedFileName(tempFilePath); + fs.copyFile(srcFile.fd, savedFilePath, (err) => { + fs.closeSync(srcFile) + if (err) { + exec.reject(err.message) + } else { + exec.resolve({ + savedFilePath: 'file://' + savedFilePath + } as SaveFileSuccess) + } + }) + } +) as SaveFile + +export const getSavedFileList: GetSavedFileList = defineAsyncApi( + API_GET_SAVED_FILE_LIST, + function (options: GetSavedFileListOptions, exec: ApiExecutor) { + const savedPath = getSavedDir(APP_ID) + if (!fs.accessSync(savedPath)) { + exec.resolve({ + fileList: [] + } as GetSavedFileListSuccess) + } + fs.listFile(savedPath, {} as ListFileOptions, (err, fileList) => { + if (err) { + exec.reject(err.message) + } else { + exec.resolve({ + fileList: fileList.map((filePath: string) => { + const fullPath = savedPath + '/' + filePath + const stat = fs.statSync(fullPath) + if (!stat.isFile()) { + return null + } + return { + filePath: 'file://' + fullPath, + size: stat.size, + createTime: stat.ctime + } as SavedFileListItem + }).filter((item) => !!item) + } as GetSavedFileListSuccess) + } + }) + } +) as GetSavedFileList + +export const getSavedFileInfo: GetSavedFileInfo = defineAsyncApi( + API_GET_SAVED_FILE_INFO, + function (options: GetSavedFileInfoOptions, exec: ApiExecutor) { + const savedFilePath = getFsPath(options.filePath); + if (!fs.accessSync(savedFilePath)) { + exec.reject('file not exist') + return + } + const stat = fs.statSync(savedFilePath) + if (!stat.isFile()) { + exec.reject('file not exist') + } + exec.resolve({ + size: stat.size, + createTime: stat.ctime + } as GetSavedFileInfoSuccess) + } +) as GetSavedFileInfo + +export const removeSavedFile: RemoveSavedFile = defineAsyncApi( + API_REMOVE_SAVED_FILE, + function (options: RemoveSavedFileOptions, exec: ApiExecutor) { + const savedFilePath = getFsPath(options.filePath); + if (!fs.accessSync(savedFilePath)) { + exec.reject('file not exist') + return + } + fs.unlink(savedFilePath, (err) => { + if (err) { + exec.reject(err.message) + } else { + exec.resolve() + } + }) + } +) as RemoveSavedFile + +const SupportedHashAlgorithm = ['md5', 'sha1'] +export const getFileInfo: GetFileInfo = defineAsyncApi( + API_GET_FILE_INFO, + function (options: GetFileInfoOptions, exec: ApiExecutor) { + const filePath = getFsPath(options.filePath); + const digestAlgorithm = options.digestAlgorithm && SupportedHashAlgorithm.includes(options.digestAlgorithm) ? options.digestAlgorithm : 'md5' + if (!fs.accessSync(filePath)) { + exec.reject('file not exist') + return + } + const stat = fs.statSync(filePath) + if (!stat.isFile()) { + exec.reject('file not exist') + } + Hash.hash(filePath, digestAlgorithm, (err, hash) => { + if (err) { + exec.reject(err.message) + } else { + exec.resolve({ + size: stat.size, + digest: hash + } as GetFileInfoSuccess) + } + }) + } +) as GetFileInfo diff --git a/uni_modules/uni-file/utssdk/interface.uts b/uni_modules/uni-file/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..9ca607a5097eaaa630c056a22575245bd5eea6c7 --- /dev/null +++ b/uni_modules/uni-file/utssdk/interface.uts @@ -0,0 +1,174 @@ +export type SaveFileSuccess = { + savedFilePath: string; +}; +export type SaveFileSuccessCallback = (res: SaveFileSuccess) => void; +export type SaveFileFail = {}; +export type SaveFileFailCallback = (res: SaveFileFail) => void; +export type SaveFileCompleteCallback = (res: any) => void; +export type SaveFileOptions = { + tempFilePath: string; + success?: SaveFileSuccessCallback | null; + fail?: SaveFileFailCallback | null; + complete?: SaveFileCompleteCallback | null; +}; + +export type GetFileInfoSuccess = { + digest: string; + size: number; +}; +export type GetFileInfoSuccessCallback = (res: GetFileInfoSuccess) => void; +export type GetFileInfoFail = {}; +export type GetFileInfoFailCallback = (res: GetFileInfoFail) => void; +export type GetFileInfoCompleteCallback = (res: any) => void; +export type GetFileInfoOptions = { + filePath: string; + digestAlgorithm?: string | null; + success?: GetFileInfoSuccessCallback | null; + fail?: GetFileInfoFailCallback | null; + complete?: GetFileInfoCompleteCallback | null; +}; + +export type GetSavedFileInfoSuccess = { + size: number; + createTime: number; +}; +export type GetSavedFileInfoSuccessCallback = (res: GetSavedFileInfoSuccess) => void; +export type GetSavedFileInfoFail = {}; +export type GetSavedFileInfoFailCallback = (res: GetSavedFileInfoFail) => void; +export type GetSavedFileInfoCompleteCallback = (res: any) => void; +export type GetSavedFileInfoOptions = { + filePath: string; + success?: GetSavedFileInfoSuccessCallback | null; + fail?: GetSavedFileInfoFailCallback | null; + complete?: GetSavedFileInfoCompleteCallback | null; +}; + +export type RemoveSavedFileSuccess = {}; +export type RemoveSavedFileSuccessCallback = (res: RemoveSavedFileSuccess) => void; +export type RemoveSavedFileFail = {}; +export type RemoveSavedFileFailCallback = (res: RemoveSavedFileFail) => void; +export type RemoveSavedFileCompleteCallback = (res: any) => void; +export type RemoveSavedFileOptions = { + filePath: string; + success?: RemoveSavedFileSuccessCallback | null; + fail?: RemoveSavedFileFailCallback | null; + complete?: RemoveSavedFileCompleteCallback | null; +}; + +export type SavedFileListItem = { + filePath: string; + size: number; + createTime: number; +}; +export type GetSavedFileListSuccess = { + fileList: SavedFileListItem[]; +}; +export type GetSavedFileListSuccessCallback = (res: GetSavedFileListSuccess) => void; +export type GetSavedFileListFail = {}; +export type GetSavedFileListFailCallback = (res: GetSavedFileListFail) => void; +export type GetSavedFileListCompleteCallback = (res: any) => void; +export type GetSavedFileListOptions = { + success?: GetSavedFileListSuccessCallback | null; + fail?: GetSavedFileListFailCallback | null; + complete?: GetSavedFileListCompleteCallback | null; +}; + +export type SaveFile = (options?: SaveFileOptions | null) => void; +export type GetFileInfo = (options?: GetFileInfoOptions | null) => void; +export type GetSavedFileInfo = (options?: GetSavedFileInfoOptions | null) => void; +export type RemoveSavedFile = (options?: RemoveSavedFileOptions | null) => void; +export type GetSavedFileList = (options?: GetSavedFileListOptions | null) => void; + + +export interface Uni { + /** + * 保存文件 + * @uniPlatform { + * "app": { + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.25", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "x", + * "unixVer": "x" + * } + * } + * @uniVueVersion 2,3 //支持的vue版本 + */ + saveFile(options?: SaveFileOptions | null): void; + /** + * 获取本地已保存的文件列表 + * @uniPlatform { + * "app": { + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.25", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "x", + * "unixVer": "x" + * } + * } + * @uniVueVersion 2,3 //支持的vue版本 + */ + getSavedFileList(options?: GetSavedFileListOptions | null): void; + /** + * 获取已保存到本地的文件信息 + * @uniPlatform { + * "app": { + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.25", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "x", + * "unixVer": "x" + * } + * } + * @uniVueVersion 2,3 //支持的vue版本 + */ + getSavedFileInfo(options?: GetSavedFileInfoOptions | null): void; + /** + * 删除已保存的文件 + * @uniPlatform { + * "app": { + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.25", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "x", + * "unixVer": "x" + * } + * } + * @uniVueVersion 2,3 //支持的vue版本 + */ + removeSavedFile(options?: RemoveSavedFileOptions | null): void; + /** + * 获取文件信息 + * @uniPlatform { + * "app": { + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.25", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "x", + * "unixVer": "x" + * } + * } + * @uniVueVersion 2,3 //支持的vue版本 + */ + getFileInfo(options?: GetFileInfoOptions | null): void; +} diff --git a/uni_modules/uni-file/utssdk/protocol.uts b/uni_modules/uni-file/utssdk/protocol.uts new file mode 100644 index 0000000000000000000000000000000000000000..7124d7345892118e1e187b6edf2ce220533f21c1 --- /dev/null +++ b/uni_modules/uni-file/utssdk/protocol.uts @@ -0,0 +1,52 @@ +export const API_SAVE_FILE = 'saveFile' +export const API_GET_FILE_INFO = 'getFileInfo' +export const API_GET_SAVED_FILE_INFO = 'getSavedFileInfo' +export const API_GET_SAVED_FILE_LIST = 'getSavedFileList' +export const API_REMOVE_SAVED_FILE = 'removeSavedFile' + +export const SaveFileApiProtocol = new Map([ + [ + 'tempFilePath', + { + type: 'string', + required: true + } + ] +]) + +export const GetFileInfoApiProtocol = new Map([ + [ + 'filePath', + { + type: 'string', + required: true + } + ], + [ + 'digestAlgorithm', + { + type: 'string', + required: false + } + ] +]) + +export const GetSavedFileInfoApiProtocol = new Map([ + [ + 'filePath', + { + type: 'string', + required: true + } + ] +]) + +export const RemoveSavedFileApiProtocol = new Map([ + [ + 'filePath', + { + type: 'string', + required: true + } + ] +]) diff --git a/uni_modules/uni-getLocation-tencent/utssdk/app-ios/info.plist b/uni_modules/uni-getLocation-tencent/utssdk/app-ios/info.plist index fd5f1cb9ab68302f4a0267fae42b4b2d9810c263..5309c5431f070fc84c891cc232f7baef162915a9 100644 --- a/uni_modules/uni-getLocation-tencent/utssdk/app-ios/info.plist +++ b/uni_modules/uni-getLocation-tencent/utssdk/app-ios/info.plist @@ -2,13 +2,6 @@ - TencentLBSAPIKey - WZCBZ-OLPCU-TJJVJ-4LZTE-SSG5O-6JFEM - UIBackgroundModes - - location - - NSLocationAlwaysAndWhenInUseUsageDescription 允许使用定位权限吗 NSLocationAlwaysUsageDescription diff --git a/uni_modules/uni-getSystemInfo/utssdk/interface.uts b/uni_modules/uni-getSystemInfo/utssdk/interface.uts index f1824c3c8d926711571e8b4e9d33dc2571303963..125e628fed555cdf54a7e29fa449768714e5259e 100644 --- a/uni_modules/uni-getSystemInfo/utssdk/interface.uts +++ b/uni_modules/uni-getSystemInfo/utssdk/interface.uts @@ -2109,8 +2109,8 @@ export type GetWindowInfoResult = { /** * 窗口上边缘的 y 值,单位为px * - * @uniPlatform * @deprecated 已废弃,仅为了向下兼容保留 + * @uniPlatform * { * "app": { * "android": { diff --git a/uni_modules/uni-keyboard/changelog.md b/uni_modules/uni-keyboard/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-keyboard/package.json b/uni_modules/uni-keyboard/package.json new file mode 100644 index 0000000000000000000000000000000000000000..ff4ffd8b50011892431f3ca372681806aa52f1bc --- /dev/null +++ b/uni_modules/uni-keyboard/package.json @@ -0,0 +1,94 @@ +{ + "id": "uni-exit", + "displayName": "uni-exit", + "version": "1.0.0", + "description": "uni-exit", + "keywords": [ + "uni-exit" + ], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "uni-ext-api": { + "uni": { + "hideKeyboard": { + "name": "hideKeyboard", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "y", + "vue3": "y" + }, + "App": { + "app-android": "y", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-keyboard/readme.md b/uni_modules/uni-keyboard/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..bfaa82766077c6bc3b3766a90fa9eafa023fe551 --- /dev/null +++ b/uni_modules/uni-keyboard/readme.md @@ -0,0 +1,6 @@ +# uni-keyboard +### 开发文档 +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts) diff --git a/uni_modules/uni-keyboard/utssdk/app-harmony/index.uts b/uni_modules/uni-keyboard/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..11a3c18a99338afa21f7aaa2286806dcb1f07826 --- /dev/null +++ b/uni_modules/uni-keyboard/utssdk/app-harmony/index.uts @@ -0,0 +1,28 @@ +import { UTSHarmony } from "@dcloudio/uni-runtime" +import { + API_HIDE_KEYBOARD +} from '../protocol.uts' +import { + HideKeyboardOptions, + HideKeyboardSuccess, + HideKeyboardFail, + HideKeyboard +} from '../interface.uts' +import inputMethod from '@ohos.inputMethod'; + +export { + HideKeyboardOptions, + HideKeyboardSuccess, + HideKeyboardFail, +} + +export const hideKeyboard: HideKeyboard = defineAsyncApi( + API_HIDE_KEYBOARD, + function (options: HideKeyboardOptions, exec: ApiExecutor) { + inputMethod.getController().hideTextInput().then(() => { + exec.resolve() + }, (err: Error) => { + exec.reject(err.message) + }) + } +) as HideKeyboard diff --git a/uni_modules/uni-keyboard/utssdk/interface.uts b/uni_modules/uni-keyboard/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..30f0bae578162dc533fde7a0c8f08de49702c9e9 --- /dev/null +++ b/uni_modules/uni-keyboard/utssdk/interface.uts @@ -0,0 +1,60 @@ +/** + * uni.hideKeyboard成功回调参数 + */ +export type HideKeyboardSuccess = {} + +export type HideKeyboardFail = {} +/** + * uni.hideKeyboard成功回调函数定义 + */ +export type HideKeyboardSuccessCallback = (res: HideKeyboardSuccess) => void +/** + * uni.hideKeyboard失败回调函数定义 + */ +export type HideKeyboardFailCallback = (res: HideKeyboardFail) => void +/** + * uni.hideKeyboard完成回调函数定义 + */ +export type HideKeyboardCompleteCallback = (res: any) => void + +/** + * uni.hideKeyboard参数定义 + */ +export type HideKeyboardOptions = { + /** + * 接口调用成功的回调函数 + */ + success?: HideKeyboardSuccessCallback | null, + /** + * 接口调用失败的回调函数 + */ + fail?: HideKeyboardFailCallback | null, + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + complete?: HideKeyboardCompleteCallback | null +} + + +export interface Uni { + /** + * 隐藏键盘 + * @uniPlatform { + * "app": { + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.23", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * } + * } + * @uniVueVersion 2,3 //支持的vue版本 + */ + hideKeyboard(options?: HideKeyboardOptions | null): void; +} + +export type HideKeyboard = (options?: HideKeyboardOptions | null) => void; diff --git a/uni_modules/uni-keyboard/utssdk/protocol.uts b/uni_modules/uni-keyboard/utssdk/protocol.uts new file mode 100644 index 0000000000000000000000000000000000000000..ac6bbf9fc28dcc67b724b380f1fa476d53195f2d --- /dev/null +++ b/uni_modules/uni-keyboard/utssdk/protocol.uts @@ -0,0 +1 @@ +export const API_HIDE_KEYBOARD = 'hideKeyboard' diff --git a/uni_modules/uni-makePhoneCall/changelog.md b/uni_modules/uni-makePhoneCall/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-makePhoneCall/package.json b/uni_modules/uni-makePhoneCall/package.json new file mode 100644 index 0000000000000000000000000000000000000000..8e2913969df06eef497fb967460713dc5b876748 --- /dev/null +++ b/uni_modules/uni-makePhoneCall/package.json @@ -0,0 +1,94 @@ +{ + "id": "uni-makePhoneCall", + "displayName": "uni-makePhoneCall", + "version": "1.0.0", + "description": "uni-makePhoneCall", + "keywords": [ + "uni-makePhoneCall" +], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "uni-ext-api": { + "uni": { + "makePhoneCall": { + "name": "makePhoneCall", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "u", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-makePhoneCall/readme.md b/uni_modules/uni-makePhoneCall/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..a8b7938806d28ab23ff2230b85268c9c66043a48 --- /dev/null +++ b/uni_modules/uni-makePhoneCall/readme.md @@ -0,0 +1,7 @@ +# uni-makePhoneCall + +### 开发文档 + +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS 原生插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts/-/tree/dev) diff --git a/uni_modules/uni-makePhoneCall/utssdk/app-harmony/index.uts b/uni_modules/uni-makePhoneCall/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..bb784e4889dc589e675fc21f598370ba9b323454 --- /dev/null +++ b/uni_modules/uni-makePhoneCall/utssdk/app-harmony/index.uts @@ -0,0 +1,54 @@ +import { UTSHarmony } from '@dcloudio/uni-runtime'; +import { BusinessError } from '@kit.BasicServicesKit' +import call from '@ohos.telephony.call' +import { MakePhoneCall, MakePhoneCallOptions, MakePhoneCallSuccess } from '../interface.uts'; +import { API_MAKE_PHONE_CALL, MakePhoneCallProtocol } from '../protocol.uts'; + +export { MakePhoneCall, MakePhoneCallOptions, MakePhoneCallSuccess } + +function isPromise(res: any) { + if ((typeof res === "object" || typeof res === "function") && typeof (res as Promise).then === "function") { + return true; + } + return false +} + +function dial(number: string, confirm = true) { + if (!confirm && typeof call.dial === 'function') { + return new Promise((resolve, reject) => { + UTSHarmony.requestSystemPermission(['ohos.permission.PLACE_CALL'], (allRight: boolean) => { + if (allRight) { + call + .dial(number) + .then(() => { + resolve() + }) + .catch(reject) + } else { + reject('permission denied') + } + }, () => { + reject('permission denied') + }) + }) + } else { + return call.makeCall(number) + } +} + +export const makePhoneCall: MakePhoneCall = defineAsyncApi( + API_MAKE_PHONE_CALL, + (options: MakePhoneCallOptions, res: ApiExecutor) => { + const dialRes = dial(options.phoneNumber) as unknown as Promise + if (isPromise(dialRes)) { + dialRes + .then(res.resolve) + .catch((err: BusinessError) => { + res.reject(err.message) + }) + } else { + res.resolve() + } + }, + MakePhoneCallProtocol +) as MakePhoneCall diff --git a/uni_modules/uni-makePhoneCall/utssdk/interface.uts b/uni_modules/uni-makePhoneCall/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..93cfaa5518618a021ecb58982fa1f20076a6abc7 --- /dev/null +++ b/uni_modules/uni-makePhoneCall/utssdk/interface.uts @@ -0,0 +1,100 @@ +export interface Uni { + /** + * 拨打电话 + * + * @tutorial https://uniapp.dcloud.net.cn/api/system/phone.html#makephonecall + * @tutorial-uni-app https://uniapp.dcloud.net.cn/api/system/phone.html#makephonecall + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "ios": { + * "osVer": "12.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.23", + * "unixVer": "x" + * } + * }, + * "mp": { + * "weixin": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "alipay": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "baidu": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "toutiao": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "lark": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "√" + * }, + * "qq": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "kuaishou": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "jd": { + * "hostVer": "√", + * "uniVer": "√", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * } + * } + */ + makePhoneCall: MakePhoneCall; +} + +export type MakePhoneCall = (options: MakePhoneCallOptions) => void; +export type MakePhoneCallSuccess = {}; +export type MakePhoneCallSuccessCallback = (result: MakePhoneCallSuccess) => void; +export type MakePhoneCallFail = UniError; +export type MakePhoneCallFailCallback = (result: MakePhoneCallFail) => void; +export type MakePhoneCallComplete = any; +export type MakePhoneCallCompleteCallback = (result: MakePhoneCallComplete) => void; +export type MakePhoneCallOptions = { + /** + * 需要拨打的电话号码 + */ + phoneNumber: string, + /** + * 成功返回的回调函数 + */ + success?: MakePhoneCallSuccessCallback | null, + /** + * 失败的回调函数 + */ + fail?: MakePhoneCallFailCallback | null, + /** + * 结束的回调函数(调用成功、失败都会执行) + */ + complete?: MakePhoneCallCompleteCallback | null +}; diff --git a/uni_modules/uni-makePhoneCall/utssdk/protocol.uts b/uni_modules/uni-makePhoneCall/utssdk/protocol.uts new file mode 100644 index 0000000000000000000000000000000000000000..df0c183a08267555d2b0d99bc30b5f979b41e057 --- /dev/null +++ b/uni_modules/uni-makePhoneCall/utssdk/protocol.uts @@ -0,0 +1,11 @@ +export const API_MAKE_PHONE_CALL = 'makePhoneCall' + +export const MakePhoneCallProtocol = new Map([ + [ + 'phoneNumber', + { + type: 'string', + required: true, + } + ] +]) diff --git a/uni_modules/uni-media/utssdk/app-android/index.uts b/uni_modules/uni-media/utssdk/app-android/index.uts index 44a84121a0cb88d261e974bc84d493ad0eb192b3..a84bad3a0ce417dd57d22565ea400004a8d3d0b5 100644 --- a/uni_modules/uni-media/utssdk/app-android/index.uts +++ b/uni_modules/uni-media/utssdk/app-android/index.uts @@ -17,7 +17,7 @@ import { } from "../unierror.uts" import { chooseMediaImage, chooseMediaVideo } from "./utils/ChooseMediaUtils.uts" import { transcodeImage, transcodeVideo } from './utils/CompressUtils.uts' -import { getVideoMetadata } from "./utils/MediaUtils.uts" +import { getVideoMetadata, copyFile } from "./utils/MediaUtils.uts" import Intent from 'android.content.Intent'; import Manifest from 'android.Manifest'; import Build from 'android.os.Build'; @@ -258,10 +258,16 @@ class ImageInfoTarget extends CustomTarget { function getExif(src : string, options : GetImageInfoOptions, bitmapOption : BitmapFactory.Options | null) { var exifInfo : ExifInterface | null = null + if(bitmapOption == null) { + bitmapOption = new BitmapFactory.Options(); + bitmapOption.inJustDecodeBounds = true; + } if (src.startsWith(ASSETS_PATH)) { exifInfo = new ExifInterface(UTSAndroid.getUniActivity()!.getAssets().open(src.replace(ASSETS_PATH, ""))); + BitmapFactory.decodeStream(UTSAndroid.getUniActivity()!.getAssets().open(src.replace(ASSETS_PATH, "")), null, bitmapOption) } else if (new File(src).exists()) { exifInfo = new ExifInterface(src) + BitmapFactory.decodeFile(src, bitmapOption) } else { let imageInfoCallback = new MediaErrorImpl(1101003, UniError_GetImageInfo); options.fail?.(imageInfoCallback) @@ -269,11 +275,6 @@ function getExif(src : string, options : GetImageInfoOptions, bitmapOption : Bit return } try { - if (bitmapOption == null) { - bitmapOption = new BitmapFactory.Options(); - bitmapOption.inJustDecodeBounds = true; - BitmapFactory.decodeFile(src, bitmapOption) - } let width = bitmapOption!.outWidth let height = bitmapOption!.outHeight let mimeType : string = bitmapOption!.outMimeType @@ -326,53 +327,6 @@ function getExif(src : string, options : GetImageInfoOptions, bitmapOption : Bit } } - -function copyFile(fromFilePath : string, toFilePath : string) : boolean { - var fis : InputStream | null = null - try { - if (fromFilePath.startsWith(ASSETS_PATH)) { - fis = UTSAndroid.getUniActivity()!.getAssets().open(fromFilePath.replace(ASSETS_PATH, "")); - } else { - let fromFile = new File(fromFilePath) - if (!fromFile.exists()) { - return false; - } - if (!fromFile.isFile()) { - return false - } - if (!fromFile.canRead()) { - return false; - } - fis = new FileInputStream(fromFile); - } - if (fis == null) { - return false - } - } catch (e) { - return false; - } - let toFile = new File(toFilePath) - if (!toFile.getParentFile().exists()) { - toFile.getParentFile().mkdirs() - } - if (!toFile.exists()) { - toFile.createNewFile() - } - try { - let fos = new FileOutputStream(toFile) - let byteArrays = ByteArray(1024) - var c = fis!!.read(byteArrays) - while (c > 0) { - fos.write(byteArrays, 0, c) - c = fis!!.read(byteArrays) - } - fis!!.close() - fos.close() - return true - } catch (e) { - return false; - } -} export const saveImageToPhotosAlbum : SaveImageToPhotosAlbum = function (options : SaveImageToPhotosAlbumOptions) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { let requestPermissionList : Array = [Manifest.permission.WRITE_EXTERNAL_STORAGE] diff --git a/uni_modules/uni-media/utssdk/app-android/utils/MediaUtils.uts b/uni_modules/uni-media/utssdk/app-android/utils/MediaUtils.uts index ae6ee26b4bb61c96022423f0a8c98afdbf4856ad..0941c0d3669b766c96b38db7f662f7633df2e99d 100644 --- a/uni_modules/uni-media/utssdk/app-android/utils/MediaUtils.uts +++ b/uni_modules/uni-media/utssdk/app-android/utils/MediaUtils.uts @@ -5,12 +5,18 @@ import { UniError_GetVideoInfo, MediaErrorImpl } from "../../unierror.uts" + import File from 'java.io.File'; import MediaMetadataRetriever from 'android.media.MediaMetadataRetriever'; import BigDecimal from 'java.math.BigDecimal'; import MediaExtractor from 'android.media.MediaExtractor'; import MediaFormat from 'android.media.MediaFormat'; import TextUtils from 'android.text.TextUtils'; +import FileOutputStream from 'java.io.FileOutputStream'; +import FileInputStream from 'java.io.FileInputStream'; +import InputStream from 'java.io.InputStream'; + +const ASSETS_PATH = '/android_asset/' export function getVideoMetadata(src : string) : any { let videoInfo : GetVideoInfoSuccess = { @@ -19,7 +25,16 @@ export function getVideoMetadata(src : string) : any { height: 0, width: 0 } - let path = UTSAndroid.convert2AbsFullPath(src) + var path = UTSAndroid.convert2AbsFullPath(src) + if (path.startsWith("/android_asset/")) { + var mediaCachePath = UTSAndroid.getAppCachePath() + "uni-media/_" + System.currentTimeMillis() + if (copyFile(path, mediaCachePath)) { + path = mediaCachePath + } else { + let error = new MediaErrorImpl(1101010, UniError_GetVideoInfo); + return error + } + } let videoFile = new File(path) if (!videoFile.exists()) { let error = new MediaErrorImpl(1101003, UniError_GetVideoInfo); @@ -97,4 +112,52 @@ export function getVideoMetadata(src : string) : any { let error = new MediaErrorImpl(1101010, UniError_GetVideoInfo); return error } +} + + +export function copyFile(fromFilePath : string, toFilePath : string) : boolean { + var fis : InputStream | null = null + try { + if (fromFilePath.startsWith(ASSETS_PATH)) { + fis = UTSAndroid.getUniActivity()!.getAssets().open(fromFilePath.replace(ASSETS_PATH, "")); + } else { + let fromFile = new File(fromFilePath) + if (!fromFile.exists()) { + return false; + } + if (!fromFile.isFile()) { + return false + } + if (!fromFile.canRead()) { + return false; + } + fis = new FileInputStream(fromFile); + } + if (fis == null) { + return false + } + } catch (e) { + return false; + } + let toFile = new File(toFilePath) + if (!toFile.getParentFile().exists()) { + toFile.getParentFile().mkdirs() + } + if (!toFile.exists()) { + toFile.createNewFile() + } + try { + let fos = new FileOutputStream(toFile) + let byteArrays = ByteArray(1024) + var c = fis!!.read(byteArrays) + while (c > 0) { + fos.write(byteArrays, 0, c) + c = fis!!.read(byteArrays) + } + fis!!.close() + fos.close() + return true + } catch (e) { + return false; + } } \ No newline at end of file diff --git a/uni_modules/uni-media/utssdk/app-ios/index.uts b/uni_modules/uni-media/utssdk/app-ios/index.uts index b804d3b8c6dde3e68b2f97afe886b9742cb6acda..ecaa418b04522434ce9c4f4285dd7459c01edb54 100644 --- a/uni_modules/uni-media/utssdk/app-ios/index.uts +++ b/uni_modules/uni-media/utssdk/app-ios/index.uts @@ -175,9 +175,15 @@ export const getImageInfo : GetImageInfo = function (options : GetImageInfoOptio if (options.src.length > 0) { if (isNetUrl(options.src)) { UTSiOS.loadImage(options.src, (image, data) => { - if (data != null && image != null) { - const type = getImageFormat(data!); - const path = saveImage(data!, type); + if (image != null) { + let imageData : Data | null = null; + if(data != null){ + imageData = data; + }else{ + imageData = image!.jpegData(compressionQuality= 1.0); + } + const type = getImageFormat(imageData!); + const path = saveImage(imageData!, type); if (path.count > 0) { DispatchQueue.main.async(execute = () : void => { let successCallback : GetImageInfoSuccess = { diff --git a/uni_modules/uni-media/utssdk/interface.uts b/uni_modules/uni-media/utssdk/interface.uts index ea0a78abd48e574b139aafb2dfbff2baeaa85f23..4fe0abea3e325a3c4dae58fc93dcb1e391f62b22 100644 --- a/uni_modules/uni-media/utssdk/interface.uts +++ b/uni_modules/uni-media/utssdk/interface.uts @@ -115,7 +115,6 @@ export type ChooseImageOptions = { count ?: (number) | null, /** * original 原图,compressed 压缩图,默认二者都有 - * @type string | string [] * @defaultValue ['original','compressed'] * @uniPlatform { * "app":{ @@ -250,6 +249,30 @@ export type PreviewImageOptions = { urls : Array, /** * 是否显示长按菜单 + * + * @uniPlatform { + * "app": { + * "android": { + * "osVer": "5.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "ios": { + * "osVer": "10.0", + * "uniVer": "√", + * "unixVer": "x" + * }, + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.23", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "√", + * "unixVer": "4.0" + * } + * } */ showmenu ?: boolean | null, /** diff --git a/uni_modules/uni-openDocument/changelog.md b/uni_modules/uni-openDocument/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-openDocument/package.json b/uni_modules/uni-openDocument/package.json new file mode 100644 index 0000000000000000000000000000000000000000..3fec1cae75e6beaf02a89f0eca8cd78da79ba6a0 --- /dev/null +++ b/uni_modules/uni-openDocument/package.json @@ -0,0 +1,94 @@ +{ + "id": "uni-openDocument", + "displayName": "uni-openDocument", + "version": "1.0.0", + "description": "uni-openDocument", + "keywords": [ + "uni-openDocument" + ], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "uni-ext-api": { + "uni": { + "openDocument": { + "name": "openDocument", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "y", + "vue3": "y" + }, + "App": { + "app-android": "y", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-openDocument/readme.md b/uni_modules/uni-openDocument/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..860372927ee9a5821694d5505265842a311f9201 --- /dev/null +++ b/uni_modules/uni-openDocument/readme.md @@ -0,0 +1,6 @@ +# uni-openDocument +### 开发文档 +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts) diff --git a/uni_modules/uni-openDocument/utssdk/app-harmony/index.uts b/uni_modules/uni-openDocument/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..11bbbf21c1c49e6dcd7856c0dc5699585578f31b --- /dev/null +++ b/uni_modules/uni-openDocument/utssdk/app-harmony/index.uts @@ -0,0 +1,69 @@ +import { + API_OPEN_DOCUMENT +} from '../protocol.uts' +import { + OpenDocumentFail, + OpenDocumentSuccess, + OpenDocumentOptions, + OpenDocument +} from '../interface.uts' +import { + getAbilityContext +} from '@dcloudio/uni-runtime' +import fileUri from '@ohos.file.fileuri'; +import Want from '@ohos.app.ability.Want'; +import wantConstant from '@ohos.app.ability.wantConstant'; +import common from '@ohos.app.ability.common'; + +export { + OpenDocumentFail, + OpenDocumentSuccess, + OpenDocumentOptions, +} + +function getContentType(filePath: string, fileType?: string | null): string | void { + const suffix = fileType || filePath.split('.').pop(); + if (!suffix) { + return; + } + switch (suffix) { + case 'doc': + case 'docx': + return 'application/msword'; + case 'xls': + case 'xlsx': + return 'application/vnd.ms-excel'; + case 'ppt': + case 'pptx': + return 'application/vnd.ms-powerpoint'; + case 'pdf': + return 'application/pdf'; + default: + return; + } +} + +export const openDocument: OpenDocument = defineAsyncApi( + API_OPEN_DOCUMENT, + function (options: OpenDocumentOptions, exec: ApiExecutor) { + const filePath = options.filePath + const uri = fileUri.getUriFromPath(filePath.replace(/^file:\/\//, '')); + const fileContentType = getContentType(filePath, options.fileType); + if (!fileContentType) { + exec.reject('file type not supported'); + return + } + const want: Want = { + flags: wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION | wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION | wantConstant.Flags.FLAG_AUTH_PERSISTABLE_URI_PERMISSION, + action: 'ohos.want.action.sendData', + uri: uri, + type: fileContentType as string + } + const abilityContext = getAbilityContext() as common.UIAbilityContext + abilityContext.startAbility(want).then(() => { + exec.resolve({} as OpenDocumentSuccess) + }, (err: Error) => { + exec.reject(err.message); + }) + } +) as OpenDocument diff --git a/uni_modules/uni-openDocument/utssdk/interface.uts b/uni_modules/uni-openDocument/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..166b9a7d071b3763b646550970e9f4370d9659da --- /dev/null +++ b/uni_modules/uni-openDocument/utssdk/interface.uts @@ -0,0 +1,70 @@ +/** + * uni.openDocument成功回调参数 + */ +export type OpenDocumentSuccess = {} + +export type OpenDocumentFail = {} +/** + * uni.openDocument成功回调函数定义 + */ +export type OpenDocumentSuccessCallback = (res: OpenDocumentSuccess) => void +/** + * uni.openDocument失败回调函数定义 + */ +export type OpenDocumentFailCallback = (res: OpenDocumentFail) => void +/** + * uni.openDocument完成回调函数定义 + */ +export type OpenDocumentCompleteCallback = (res: any) => void + +export type OpenDocumentSupportedTypes = 'doc' | 'xls' | 'ppt' | 'pdf' | 'docx' | 'xlsx' | 'pptx' + +/** + * uni.openDocument参数定义 + */ +export type OpenDocumentOptions = { + /** + * 文件路径,仅支持本地路径 + */ + filePath: string, + /** + * 文件类型,指定文件类型打开文件,有效值 doc, xls, ppt, pdf, docx, xlsx, pptx + */ + fileType?: OpenDocumentSupportedTypes | null, + /** + * 接口调用成功的回调函数 + */ + success?: OpenDocumentSuccessCallback | null, + /** + * 接口调用失败的回调函数 + */ + fail?: OpenDocumentFailCallback | null, + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + complete?: OpenDocumentCompleteCallback | null +} + + +export interface Uni { + /** + * 打开文档 + * @uniPlatform { + * "app": { + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.23", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "x", + * "unixVer": "x" + * } + * } + * @uniVueVersion 2,3 //支持的vue版本 + */ + openDocument(options?: OpenDocumentOptions | null): void; +} + +export type OpenDocument = (options?: OpenDocumentOptions | null) => void; diff --git a/uni_modules/uni-openDocument/utssdk/protocol.uts b/uni_modules/uni-openDocument/utssdk/protocol.uts new file mode 100644 index 0000000000000000000000000000000000000000..9e3a37d00ec83e527092be30fae820efb02647e3 --- /dev/null +++ b/uni_modules/uni-openDocument/utssdk/protocol.uts @@ -0,0 +1 @@ +export const API_OPEN_DOCUMENT = 'openDocument' diff --git a/uni_modules/uni-scanCode/changelog.md b/uni_modules/uni-scanCode/changelog.md new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uni-scanCode/package.json b/uni_modules/uni-scanCode/package.json new file mode 100644 index 0000000000000000000000000000000000000000..bb184dcc4ed838f922e58e84ccc20da5f3a15092 --- /dev/null +++ b/uni_modules/uni-scanCode/package.json @@ -0,0 +1,94 @@ +{ + "id": "uni-scanCode", + "displayName": "uni-scanCode", + "version": "1.0.0", + "description": "uni-scanCode", + "keywords": [ + "uni-scanCode" + ], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "uni-ext-api": { + "uni": { + "scanCode": { + "name": "scanCode", + "app": { + "js": false, + "kotlin": false, + "swift": false, + "arkts": true + } + } + } + }, + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u" + }, + "client": { + "Vue": { + "vue2": "y", + "vue3": "y" + }, + "App": { + "app-android": "y", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} diff --git a/uni_modules/uni-scanCode/readme.md b/uni_modules/uni-scanCode/readme.md new file mode 100644 index 0000000000000000000000000000000000000000..53cdaf4a3a751975806a4e0afbcbb8afcdc1a664 --- /dev/null +++ b/uni_modules/uni-scanCode/readme.md @@ -0,0 +1,6 @@ +# uni-scanCode +### 开发文档 +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts) diff --git a/uni_modules/uni-scanCode/utssdk/app-harmony/index.uts b/uni_modules/uni-scanCode/utssdk/app-harmony/index.uts new file mode 100644 index 0000000000000000000000000000000000000000..32e09134564ce42b1213541ed7cde524a1c477c4 --- /dev/null +++ b/uni_modules/uni-scanCode/utssdk/app-harmony/index.uts @@ -0,0 +1,77 @@ +import { + API_SCAN_CODE +} from '../protocol.uts' +import { + ScanCodeFail, + ScanCodeSuccess, + ScanCodeOptions, + ScanCodeSupportedTypes, + ScanCode +} from '../interface.uts' +import { + getAbilityContext +} from '@dcloudio/uni-runtime' +import { scanCore, scanBarcode } from '@kit.ScanKit'; + +export { + ScanCodeFail, + ScanCodeSuccess, + ScanCodeOptions, +} + +let supportedScanTypesMap: Map + +function initScanTypesMapOnce() { + if (supportedScanTypesMap) { + return + } + supportedScanTypesMap = new Map([ + ['barCode', scanCore.ScanType.CODABAR_CODE], + ['qrCode', scanCore.ScanType.QR_CODE], + ['datamatrix', scanCore.ScanType.DATAMATRIX_CODE], + ['pdf417', scanCore.ScanType.PDF417_CODE] + ]); +} + +function getUniScanType(scanType: scanCore.ScanType): ScanCodeSupportedTypes { + for (const [key, value] of supportedScanTypesMap.entries()) { + if (value === scanType) { + return key; + } + } + return 'qrCode'; +} + +export const scanCode: ScanCode = defineAsyncApi( + API_SCAN_CODE, + function (options: ScanCodeOptions, exec: ApiExecutor) { + if (!canIUse('SystemCapability.Multimedia.Scan.ScanBarcode')) { + exec.reject('not support'); + return + } + initScanTypesMapOnce(); + let scanTypes: scanCore.ScanType[] = [scanCore.ScanType.ALL]; + if (options.scanType && Array.isArray(options.scanType) && options.scanType.length > 0) { + scanTypes = options.scanType.filter((type) => { + return supportedScanTypesMap.has(type); + }).map((type) => { + return supportedScanTypesMap.get(type)!; + }) + } + const scanOptions: scanBarcode.ScanOptions = { + scanTypes, + enableMultiMode: true, + enableAlbum: !options.onlyFromCamera + }; + scanBarcode.startScanForResult(getAbilityContext()!, scanOptions, (err, data) => { + if (err) { + exec.reject(err.message); + return; + } + exec.resolve({ + result: data.originalValue, + scanType: getUniScanType(data.scanType), + } as ScanCodeSuccess) + }) + } +) as ScanCode diff --git a/uni_modules/uni-scanCode/utssdk/interface.uts b/uni_modules/uni-scanCode/utssdk/interface.uts new file mode 100644 index 0000000000000000000000000000000000000000..17bf84c10ca049dcab5c70776cc560628627f24a --- /dev/null +++ b/uni_modules/uni-scanCode/utssdk/interface.uts @@ -0,0 +1,73 @@ +/** + * uni.scanCode成功回调参数 + */ +export type ScanCodeSuccess = { + result: string, + scanType: ScanCodeSupportedTypes +} + +export type ScanCodeFail = {} +/** + * uni.scanCode成功回调函数定义 + */ +export type ScanCodeSuccessCallback = (res: ScanCodeSuccess) => void +/** + * uni.scanCode失败回调函数定义 + */ +export type ScanCodeFailCallback = (res: ScanCodeFail) => void +/** + * uni.scanCode完成回调函数定义 + */ +export type ScanCodeCompleteCallback = (res: any) => void + +export type ScanCodeSupportedTypes = 'barCode' | 'qrCode' | 'datamatrix' | 'pdf417' + +/** + * uni.scanCode参数定义 + */ +export type ScanCodeOptions = { + /** + * 是否只能从相机扫码,不允许从相册选择图片 + */ + onlyFromCamera?: boolean | null, + /** + * 扫码类型 + */ + scanType?: ScanCodeSupportedTypes[] | null, + /** + * 接口调用成功的回调函数 + */ + success?: ScanCodeSuccessCallback | null, + /** + * 接口调用失败的回调函数 + */ + fail?: ScanCodeFailCallback | null, + /** + * 接口调用结束的回调函数(调用成功、失败都会执行) + */ + complete?: ScanCodeCompleteCallback | null +} + + +export interface Uni { + /** + * 扫码 + * @uniPlatform { + * "app": { + * "harmony": { + * "osVer": "3.0", + * "uniVer": "4.23", + * "unixVer": "x" + * } + * }, + * "web": { + * "uniVer": "x", + * "unixVer": "x" + * } + * } + * @uniVueVersion 2,3 //支持的vue版本 + */ + scanCode(options?: ScanCodeOptions | null): void; +} + +export type ScanCode = (options?: ScanCodeOptions | null) => void; diff --git a/uni_modules/uni-scanCode/utssdk/protocol.uts b/uni_modules/uni-scanCode/utssdk/protocol.uts new file mode 100644 index 0000000000000000000000000000000000000000..9fcea9f2d2da34ee2774c6e92bbccf1dd3b14f2c --- /dev/null +++ b/uni_modules/uni-scanCode/utssdk/protocol.uts @@ -0,0 +1 @@ +export const API_SCAN_CODE = 'scanCode'