From 911735e0eed59cd5a59abb4fa247bdffe4ca0865 Mon Sep 17 00:00:00 2001 From: yanyilin Date: Tue, 8 Oct 2024 12:29:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81@HBuilderX4?= =?UTF-8?q?.29?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uni_modules/uni-addPhoneContact/changelog.md | 0 uni_modules/uni-addPhoneContact/package.json | 94 +++++++ uni_modules/uni-addPhoneContact/readme.md | 7 + .../utssdk/app-harmony/index.uts | 125 +++++++++ .../uni-addPhoneContact/utssdk/interface.uts | 231 +++++++++++++++++ .../uni-addPhoneContact/utssdk/protocol.uts | 50 ++++ .../uni-arrayBufferToBase64/changelog.md | 0 .../uni-arrayBufferToBase64/package.json | 94 +++++++ uni_modules/uni-arrayBufferToBase64/readme.md | 7 + .../utssdk/app-harmony/index.uts | 11 + .../utssdk/interface.uts | 77 ++++++ .../utssdk/protocol.uts | 10 + uni_modules/uni-authentication/changelog.md | 0 uni_modules/uni-authentication/package.json | 112 ++++++++ uni_modules/uni-authentication/readme.md | 7 + .../utssdk/app-harmony/index.uts | 243 ++++++++++++++++++ .../uni-authentication/utssdk/interface.uts | 171 ++++++++++++ .../uni-authentication/utssdk/protocol.uts | 60 +++++ .../uni-base64ToArrayBuffer/changelog.md | 0 .../uni-base64ToArrayBuffer/package.json | 94 +++++++ uni_modules/uni-base64ToArrayBuffer/readme.md | 7 + .../utssdk/app-harmony/index.uts | 11 + .../utssdk/interface.uts | 77 ++++++ .../utssdk/protocol.uts | 11 + uni_modules/uni-clipboard/changelog.md | 0 uni_modules/uni-clipboard/package.json | 103 ++++++++ uni_modules/uni-clipboard/readme.md | 7 + .../utssdk/app-harmony/index.uts | 35 +++ .../uni-clipboard/utssdk/interface.uts | 203 +++++++++++++++ uni_modules/uni-clipboard/utssdk/protocol.uts | 26 ++ .../changelog.md | 0 .../package.json | 93 +++++++ .../uni-createIntersectionObserver/readme.md | 6 + .../utssdk/app-harmony/index.uts | 134 ++++++++++ .../utssdk/interface.uts | 152 +++++++++++ uni_modules/uni-file/changelog.md | 0 uni_modules/uni-file/package.json | 130 ++++++++++ uni_modules/uni-file/readme.md | 6 + .../uni-file/utssdk/app-harmony/index.uts | 221 ++++++++++++++++ uni_modules/uni-file/utssdk/interface.uts | 174 +++++++++++++ uni_modules/uni-file/utssdk/protocol.uts | 52 ++++ .../utssdk/app-ios/info.plist | 7 - .../uni-getSystemInfo/utssdk/interface.uts | 2 +- uni_modules/uni-keyboard/changelog.md | 0 uni_modules/uni-keyboard/package.json | 94 +++++++ uni_modules/uni-keyboard/readme.md | 6 + .../uni-keyboard/utssdk/app-harmony/index.uts | 28 ++ uni_modules/uni-keyboard/utssdk/interface.uts | 60 +++++ uni_modules/uni-keyboard/utssdk/protocol.uts | 1 + uni_modules/uni-makePhoneCall/changelog.md | 0 uni_modules/uni-makePhoneCall/package.json | 94 +++++++ uni_modules/uni-makePhoneCall/readme.md | 7 + .../utssdk/app-harmony/index.uts | 54 ++++ .../uni-makePhoneCall/utssdk/interface.uts | 100 +++++++ .../uni-makePhoneCall/utssdk/protocol.uts | 11 + .../uni-media/utssdk/app-android/index.uts | 60 +---- .../utssdk/app-android/utils/MediaUtils.uts | 65 ++++- .../uni-media/utssdk/app-ios/index.uts | 12 +- uni_modules/uni-media/utssdk/interface.uts | 25 +- uni_modules/uni-openDocument/changelog.md | 0 uni_modules/uni-openDocument/package.json | 94 +++++++ uni_modules/uni-openDocument/readme.md | 6 + .../utssdk/app-harmony/index.uts | 69 +++++ .../uni-openDocument/utssdk/interface.uts | 70 +++++ .../uni-openDocument/utssdk/protocol.uts | 1 + uni_modules/uni-scanCode/changelog.md | 0 uni_modules/uni-scanCode/package.json | 94 +++++++ uni_modules/uni-scanCode/readme.md | 6 + .../uni-scanCode/utssdk/app-harmony/index.uts | 77 ++++++ uni_modules/uni-scanCode/utssdk/interface.uts | 73 ++++++ uni_modules/uni-scanCode/utssdk/protocol.uts | 1 + 71 files changed, 3892 insertions(+), 66 deletions(-) create mode 100644 uni_modules/uni-addPhoneContact/changelog.md create mode 100644 uni_modules/uni-addPhoneContact/package.json create mode 100644 uni_modules/uni-addPhoneContact/readme.md create mode 100644 uni_modules/uni-addPhoneContact/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-addPhoneContact/utssdk/interface.uts create mode 100644 uni_modules/uni-addPhoneContact/utssdk/protocol.uts create mode 100644 uni_modules/uni-arrayBufferToBase64/changelog.md create mode 100644 uni_modules/uni-arrayBufferToBase64/package.json create mode 100644 uni_modules/uni-arrayBufferToBase64/readme.md create mode 100644 uni_modules/uni-arrayBufferToBase64/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-arrayBufferToBase64/utssdk/interface.uts create mode 100644 uni_modules/uni-arrayBufferToBase64/utssdk/protocol.uts create mode 100644 uni_modules/uni-authentication/changelog.md create mode 100644 uni_modules/uni-authentication/package.json create mode 100644 uni_modules/uni-authentication/readme.md create mode 100644 uni_modules/uni-authentication/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-authentication/utssdk/interface.uts create mode 100644 uni_modules/uni-authentication/utssdk/protocol.uts create mode 100644 uni_modules/uni-base64ToArrayBuffer/changelog.md create mode 100644 uni_modules/uni-base64ToArrayBuffer/package.json create mode 100644 uni_modules/uni-base64ToArrayBuffer/readme.md create mode 100644 uni_modules/uni-base64ToArrayBuffer/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-base64ToArrayBuffer/utssdk/interface.uts create mode 100644 uni_modules/uni-base64ToArrayBuffer/utssdk/protocol.uts create mode 100644 uni_modules/uni-clipboard/changelog.md create mode 100644 uni_modules/uni-clipboard/package.json create mode 100644 uni_modules/uni-clipboard/readme.md create mode 100644 uni_modules/uni-clipboard/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-clipboard/utssdk/interface.uts create mode 100644 uni_modules/uni-clipboard/utssdk/protocol.uts create mode 100644 uni_modules/uni-createIntersectionObserver/changelog.md create mode 100644 uni_modules/uni-createIntersectionObserver/package.json create mode 100644 uni_modules/uni-createIntersectionObserver/readme.md create mode 100644 uni_modules/uni-createIntersectionObserver/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-createIntersectionObserver/utssdk/interface.uts create mode 100644 uni_modules/uni-file/changelog.md create mode 100644 uni_modules/uni-file/package.json create mode 100644 uni_modules/uni-file/readme.md create mode 100644 uni_modules/uni-file/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-file/utssdk/interface.uts create mode 100644 uni_modules/uni-file/utssdk/protocol.uts create mode 100644 uni_modules/uni-keyboard/changelog.md create mode 100644 uni_modules/uni-keyboard/package.json create mode 100644 uni_modules/uni-keyboard/readme.md create mode 100644 uni_modules/uni-keyboard/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-keyboard/utssdk/interface.uts create mode 100644 uni_modules/uni-keyboard/utssdk/protocol.uts create mode 100644 uni_modules/uni-makePhoneCall/changelog.md create mode 100644 uni_modules/uni-makePhoneCall/package.json create mode 100644 uni_modules/uni-makePhoneCall/readme.md create mode 100644 uni_modules/uni-makePhoneCall/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-makePhoneCall/utssdk/interface.uts create mode 100644 uni_modules/uni-makePhoneCall/utssdk/protocol.uts create mode 100644 uni_modules/uni-openDocument/changelog.md create mode 100644 uni_modules/uni-openDocument/package.json create mode 100644 uni_modules/uni-openDocument/readme.md create mode 100644 uni_modules/uni-openDocument/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-openDocument/utssdk/interface.uts create mode 100644 uni_modules/uni-openDocument/utssdk/protocol.uts create mode 100644 uni_modules/uni-scanCode/changelog.md create mode 100644 uni_modules/uni-scanCode/package.json create mode 100644 uni_modules/uni-scanCode/readme.md create mode 100644 uni_modules/uni-scanCode/utssdk/app-harmony/index.uts create mode 100644 uni_modules/uni-scanCode/utssdk/interface.uts create mode 100644 uni_modules/uni-scanCode/utssdk/protocol.uts diff --git a/uni_modules/uni-addPhoneContact/changelog.md b/uni_modules/uni-addPhoneContact/changelog.md new file mode 100644 index 0000000..e69de29 diff --git a/uni_modules/uni-addPhoneContact/package.json b/uni_modules/uni-addPhoneContact/package.json new file mode 100644 index 0000000..5c2e290 --- /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 0000000..e7c8907 --- /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 0000000..545edfd --- /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 0000000..c3acdd1 --- /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 0000000..a1b5a46 --- /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 0000000..e69de29 diff --git a/uni_modules/uni-arrayBufferToBase64/package.json b/uni_modules/uni-arrayBufferToBase64/package.json new file mode 100644 index 0000000..4369640 --- /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 0000000..1233fb5 --- /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 0000000..8522286 --- /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 0000000..03149d1 --- /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 0000000..3e2b623 --- /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 0000000..e69de29 diff --git a/uni_modules/uni-authentication/package.json b/uni_modules/uni-authentication/package.json new file mode 100644 index 0000000..97438a4 --- /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 0000000..402ef26 --- /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 0000000..41ab7af --- /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 0000000..564dc37 --- /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 0000000..46219ba --- /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 0000000..e69de29 diff --git a/uni_modules/uni-base64ToArrayBuffer/package.json b/uni_modules/uni-base64ToArrayBuffer/package.json new file mode 100644 index 0000000..50c1b0c --- /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 0000000..246073f --- /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 0000000..330400b --- /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 0000000..9a257a3 --- /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 0000000..87642e8 --- /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 0000000..e69de29 diff --git a/uni_modules/uni-clipboard/package.json b/uni_modules/uni-clipboard/package.json new file mode 100644 index 0000000..4e41b70 --- /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 0000000..a3b6f6a --- /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 0000000..221825a --- /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 0000000..da6b7b9 --- /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 0000000..cc65dea --- /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 0000000..e69de29 diff --git a/uni_modules/uni-createIntersectionObserver/package.json b/uni_modules/uni-createIntersectionObserver/package.json new file mode 100644 index 0000000..fe015ae --- /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 0000000..d086e3a --- /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 0000000..51d0908 --- /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 0000000..1211486 --- /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 0000000..e69de29 diff --git a/uni_modules/uni-file/package.json b/uni_modules/uni-file/package.json new file mode 100644 index 0000000..b5bc015 --- /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 0000000..53cdaf4 --- /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 0000000..4dd7147 --- /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 0000000..9ca607a --- /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 0000000..7124d73 --- /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 fd5f1cb..5309c54 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 f1824c3..125e628 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 0000000..e69de29 diff --git a/uni_modules/uni-keyboard/package.json b/uni_modules/uni-keyboard/package.json new file mode 100644 index 0000000..ff4ffd8 --- /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 0000000..bfaa827 --- /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 0000000..11a3c18 --- /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 0000000..30f0bae --- /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 0000000..ac6bbf9 --- /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 0000000..e69de29 diff --git a/uni_modules/uni-makePhoneCall/package.json b/uni_modules/uni-makePhoneCall/package.json new file mode 100644 index 0000000..8e29139 --- /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 0000000..a8b7938 --- /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 0000000..bb784e4 --- /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 0000000..93cfaa5 --- /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 0000000..df0c183 --- /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 44a8412..a84bad3 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 ae6ee26..0941c0d 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 b804d3b..ecaa418 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 ea0a78a..4fe0abe 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 0000000..e69de29 diff --git a/uni_modules/uni-openDocument/package.json b/uni_modules/uni-openDocument/package.json new file mode 100644 index 0000000..3fec1ca --- /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 0000000..8603729 --- /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 0000000..11bbbf2 --- /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 0000000..166b9a7 --- /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 0000000..9e3a37d --- /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 0000000..e69de29 diff --git a/uni_modules/uni-scanCode/package.json b/uni_modules/uni-scanCode/package.json new file mode 100644 index 0000000..bb184dc --- /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 0000000..53cdaf4 --- /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 0000000..32e0913 --- /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 0000000..17bf84c --- /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 0000000..9fcea9f --- /dev/null +++ b/uni_modules/uni-scanCode/utssdk/protocol.uts @@ -0,0 +1 @@ +export const API_SCAN_CODE = 'scanCode' -- GitLab