Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
605d50f8
U
uni-app
项目概览
DCloud
/
uni-app
6 个月 前同步成功
通知
751
Star
38709
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
8
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
8
Issue
8
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
605d50f8
编写于
3月 14, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): compiler
上级
67fa76e0
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
93 addition
and
4 deletion
+93
-4
packages/playground/uts/unpackage/dist/dev/.sourcemap/app/uni_modules/test-uniplugin/utssdk/app-ios/index.swift.map
...uni_modules/test-uniplugin/utssdk/app-ios/index.swift.map
+1
-1
packages/playground/uts/unpackage/dist/dev/app-plus/uni_modules/test-uniplugin/utssdk/app-ios/index.swift
...lus/uni_modules/test-uniplugin/utssdk/app-ios/index.swift
+0
-3
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+29
-0
packages/uni-app-plus/src/service/api/plugin/uts.js
packages/uni-app-plus/src/service/api/plugin/uts.js
+29
-0
packages/uni-app-plus/src/service/api/plugin/uts.ts
packages/uni-app-plus/src/service/api/plugin/uts.ts
+34
-0
packages/uts-darwin-arm64/uts.darwin-arm64.node
packages/uts-darwin-arm64/uts.darwin-arm64.node
+0
-0
packages/uts-darwin-x64/uts.darwin-x64.node
packages/uts-darwin-x64/uts.darwin-x64.node
+0
-0
packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node
packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node
+0
-0
packages/uts-linux-x64-musl/uts.linux-x64-musl.node
packages/uts-linux-x64-musl/uts.linux-x64-musl.node
+0
-0
packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node
packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node
+0
-0
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
+0
-0
未找到文件。
packages/playground/uts/unpackage/dist/dev/.sourcemap/app/uni_modules/test-uniplugin/utssdk/app-ios/index.swift.map
浏览文件 @
605d50f8
{
"version"
:
3
,
"sources"
:
[
"uni_modules/test-uniplugin/utssdk/app-ios/index.uts"
,
"uni_modules/test-uniplugin/utssdk/interface.uts"
],
"sourcesContent"
:
[
"import { UIDevice } from 'UIKit'
\n
import { CLLocationManager, CLAuthorizationStatus } from 'CoreLocation'
\n
import { ShowToast } from '../interface.uts'
\n\n
type GetBatteryInfoOptions = {\n name: string
\n
pwd: number
\n
success?: (res: UTSJSONObject) => void
\n
fail?: (res: UTSJSONObject) => void
\n
complete?: (res: UTSJSONObject) => void
\n
}
\n\n
export default function getBatteryInfo(options: GetBatteryInfoOptions) {\n new UIAlertController(
\n
(title = title),
\n
(message = message),
\n
(preferredStyle = UIAlertController.Style.alert)
\n
)
\n
const res = {\n errMsg: 'getBatteryInfo:ok',
\n
level: UIDevice.current.batteryLevel * 100,
\n
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,
\n
}
\n
if (options.success != null) {\n options.success!(res)
\n
}
\n
if (options.complete != null) {\n options.complete!(res)
\n
}
\n
}
\n\n
export function test1(callback: () => void): string {\n console.log({
\"
a
\"
:
\"
b
\"
})
\n
console.log('test1')
\n\n\n\n\n
console.log('def ios')
\n\n\n
console.log('ndef android')
\n\n\n\n\n\n
console.log('def android || def ios')
\n\n\n\n\n
console.log(CLLocationManager, CLAuthorizationStatus)
\n
const a = -3
\n
console.log(~a)
\n
return 'test1'
\n
}
\n\n
class Test1 { }
\n
export class Test {\n constructor() {\n new Test1()
\n
}
\n
test(): string | null {\n if (UTSiOS.macros(
\"
swift(>=1)
\"
)) {\n console.log(
\"
swift(>=1)
\"
)
\n
}
\n
if (UTSiOS.macros(
\"
arch(i386) || arch(arm)
\"
)) {\n console.log(
\"
arch(i386) || arch(arm)
\"
)
\n
}
\n
if (UTSiOS.available(
\"
iOS 14, macOS 11.0, *
\"
)) {\n console.log(
\"
iOS 14, macOS 11.0, *
\"
)
\n
} else if (UTSiOS.available(
\"
iOS 13,*
\"
)) {\n console.log(
\"
iOS 13,*
\"
)
\n
} else if (UTSiOS.unavailable(
\"
tvOS 12
\"
)) {\n console.log(
\"
tvOS 12
\"
)
\n
}
\n
return null
\n
}
\n
}
\n\n
export async function testAsync() {\n uni.showToast()
\n
uni.showToast()
\n
uni.showModel()
\n
return { a: 1 }
\n
}
\n\n
export const showToast1: ShowToast = (msg) => { }
\n
export const showToast2: ShowToast = function (msg) { }
\n
export const showToast3: ShowToast = function showToast(msg) { }
\n
"
,
"export type ShowToast = (msg: string) => void
\n
"
],
"names"
:
[],
"mappings"
:
";;AAAA,aAAgC;AAChC,oBAAuE;;;iBCD3D,eAAa,KAAK,MAAM,KAAK,IAAI;ADIhB;;aAAxB;IACH,WAAA,MAAM,MAAM,EAAA;IACZ,WAAA,KAAK,QAAM,EAAA;IACX,WAAA,aAAW,KAAK,kBAAkB,IAAI,GAAA;IACtC,WAAA,UAAQ,KAAK,kBAAkB,IAAI,GAAA;IACnC,WAAA,cAAY,KAAK,kBAAkB,IAAI,GAAA;;;;;QAJvC,uBAAM,MAAM;QACZ,qBAAK,QAAM;QACX,iCAAW,KAAK,kBAAkB,IAAI;QACtC,2BAAQ,KAAK,kBAAkB,IAAI;QACnC,mCAAY,KAAK,kBAAkB,IAAI;;AACzC;AAEe,YAAS,eAAe,EAAA,SAAS,qB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AK,QAAM,EAAA;IACX,WAAA,SAAQ,aAA8B;IACtC,WAAA,MAAK,aAA8B;IACnC,WAAA,UAAS,aAA8B;AACzC;+BAEuC,EAAA,SAAS,+BAAqB;;;;;SALxD,KAAK;yBAAL;;;SACH,KAAK;sBAAL;;;SACI,KAAK;0BAAL;;;;wBAsBQ,0BAAuB,MAAM;;QAA7B;;;;;;;;;;8BAgCZ,MAAM;;;;;;;;6BC/DS,KAAK,MAAM,KAAK,IAAI;sBAApB;;6BAAA,KAAK,MAAM,KAAK,IAAI;sBAApB;;6BAAA,KAAK,MAAM,KAAK,IAAI;sBAApB;;;;;4CDYc,EAAA,SAAS,+BAAqB;kCAA9B;;qCAmBjB,0BAAuB,MAAM;yBAA7B;;;;;;0CC/BG,KAAK,MAAM,KAAK,IAAI;8BAApB;;0CAAA,KAAK,MAAM,KAAK,IAAI;8BAApB;;0CAAA,KAAK,MAAM,KAAK,IAAI;8BAApB"
}
{
"version"
:
3
,
"sources"
:
[
"uni_modules/test-uniplugin/utssdk/app-ios/index.uts"
,
"uni_modules/test-uniplugin/utssdk/interface.uts"
],
"sourcesContent"
:
[
"import { UIDevice } from 'UIKit'
\n
import { CLLocationManager, CLAuthorizationStatus } from 'CoreLocation'
\n
import { ShowToast } from '../interface.uts'
\n\n
type GetBatteryInfoOptions = {\n name: string
\n
pwd: number
\n
success?: (res: UTSJSONObject) => void
\n
fail?: (res: UTSJSONObject) => void
\n
complete?: (res: UTSJSONObject) => void
\n
}
\n\n
export default function getBatteryInfo(options: GetBatteryInfoOptions) {\n new UIAlertController(
\n
(title = title),
\n
(message = message),
\n
(preferredStyle = UIAlertController.Style.alert)
\n
)
\n
const res = {\n errMsg: 'getBatteryInfo:ok',
\n
level: UIDevice.current.batteryLevel * 100,
\n
isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,
\n
}
\n
if (options.success != null) {\n options.success!(res)
\n
}
\n
if (options.complete != null) {\n options.complete!(res)
\n
}
\n
}
\n\n
export function test1(callback: () => void): string {\n console.log({
\"
a
\"
:
\"
b
\"
})
\n
console.log('test1')
\n\n\n\n\n
console.log('def ios')
\n\n\n
console.log('ndef android')
\n\n\n\n\n\n
console.log('def android || def ios')
\n\n\n\n\n
console.log(CLLocationManager, CLAuthorizationStatus)
\n
const a = -3
\n
console.log(~a)
\n
return 'test1'
\n
}
\n\n
class Test1 { }
\n
export class Test {\n constructor() {\n new Test1()
\n
}
\n
test(): string | null {\n if (UTSiOS.macros(
\"
swift(>=1)
\"
)) {\n console.log(
\"
swift(>=1)
\"
)
\n
}
\n
if (UTSiOS.macros(
\"
arch(i386) || arch(arm)
\"
)) {\n console.log(
\"
arch(i386) || arch(arm)
\"
)
\n
}
\n
if (UTSiOS.available(
\"
iOS 14, macOS 11.0, *
\"
)) {\n console.log(
\"
iOS 14, macOS 11.0, *
\"
)
\n
} else if (UTSiOS.available(
\"
iOS 13,*
\"
)) {\n console.log(
\"
iOS 13,*
\"
)
\n
} else if (UTSiOS.unavailable(
\"
tvOS 12
\"
)) {\n console.log(
\"
tvOS 12
\"
)
\n
}
\n
return null
\n
}
\n
}
\n\n
export async function testAsync() {\n uni.showToast()
\n
uni.showToast()
\n
uni.showModel()
\n
return { a: 1 }
\n
}
\n\n
export const showToast1: ShowToast = (msg) => { }
\n
export const showToast2: ShowToast = function (msg) { }
\n
export const showToast3: ShowToast = function showToast(msg) { }
\n
"
,
"export type ShowToast = (msg: string) => void
\n
"
],
"names"
:
[],
"mappings"
:
";;AAAA,aAAgC;AAChC,oBAAuE;;;iBCD3D,eAAa,KAAK,MAAM,KAAK,IAAI;ADIhB;;aAAxB;IACH,WAAA,MAAM,MAAM,EAAA;IACZ,WAAA,KAAK,QAAM,EAAA;IACX,WAAA,aAAW,KAAK,kBAAkB,IAAI,GAAA;IACtC,WAAA,UAAQ,KAAK,kBAAkB,IAAI,GAAA;IACnC,WAAA,cAAY,KAAK,kBAAkB,IAAI,GAAA;;;;;QAJvC,uBAAM,MAAM;QACZ,qBAAK,QAAM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;;AAC/B,WAAM,wBAAwB;CAAU,EAAA,GAAG;;AAC3C,WAAM,wBAAwB;CAAmB,EAAA,GAAG;;AAtF9B;;;IAC3B,WAAA,MAAM,MAAM,EAAA;IACZ,WAAA,KAAK,QAAM,EAAA;IACX,WAAA,SAAQ,aAA8B;IACtC,WAAA,MAAK,aAA8B;IACnC,WAAA,UAAS,aAA8B;AACzC;+BAEuC,EAAA,SAAS,+BAAqB;;;;;SALxD,KAAK;yBAAL;;;SACH,KAAK;sBAAL;;;SACI,KAAK;0BAAL;;;;wBAsBQ,0BAAuB,MAAM;;QAA7B;;;;;;;8BAgCZ,MAAM;;;;;;;;6BC/DS,KAAK,MAAM,KAAK,IAAI;sBAApB;;6BAAA,KAAK,MAAM,KAAK,IAAI;sBAApB;;6BAAA,KAAK,MAAM,KAAK,IAAI;sBAApB;;;;;4CDYc,EAAA,SAAS,+BAAqB;kCAA9B;;qCAmBjB,0BAAuB,MAAM;yBAA7B;;;;;;0CC/BG,KAAK,MAAM,KAAK,IAAI;8BAApB;;0CAAA,KAAK,MAAM,KAAK,IAAI;8BAApB;;0CAAA,KAAK,MAAM,KAAK,IAAI;8BAApB"
}
\ No newline at end of file
\ No newline at end of file
packages/playground/uts/unpackage/dist/dev/app-plus/uni_modules/test-uniplugin/utssdk/app-ios/index.swift
浏览文件 @
605d50f8
...
@@ -136,9 +136,6 @@ public func test1ByJs(_ callback: UTSCallback) -> String {
...
@@ -136,9 +136,6 @@ public func test1ByJs(_ callback: UTSCallback) -> String {
@objc
(
UTSSDKModulesTestUniPluginTestByJs
)
@objc
(
UTSSDKModulesTestUniPluginTestByJs
)
@objcMembers
@objcMembers
public
class
TestByJs
:
Test
{
public
class
TestByJs
:
Test
{
override
public
init
(){
super
.
init
();
}
public
func
testByJs
()
->
String
?
{
public
func
testByJs
()
->
String
?
{
return
test
();
return
test
();
}
}
...
...
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
605d50f8
...
@@ -17302,6 +17302,9 @@ function getProxy() {
...
@@ -17302,6 +17302,9 @@ function getProxy() {
return proxy;
return proxy;
}
}
function resolveSyncResult(res) {
function resolveSyncResult(res) {
if ((process.env.NODE_ENV !== 'production')) {
console.log('uts.invokeSync.result', res);
}
if (res.errMsg) {
if (res.errMsg) {
throw new Error(res.errMsg);
throw new Error(res.errMsg);
}
}
...
@@ -17312,6 +17315,9 @@ function invokePropGetter(args) {
...
@@ -17312,6 +17315,9 @@ function invokePropGetter(args) {
throw new Error(args.errMsg);
throw new Error(args.errMsg);
}
}
delete args.errMsg;
delete args.errMsg;
if ((process.env.NODE_ENV !== 'production')) {
console.log('uts.invokePropGetter.args', args);
}
return resolveSyncResult(getProxy().invokeSync(args, () => { }));
return resolveSyncResult(getProxy().invokeSync(args, () => { }));
}
}
function initProxyFunction(async, { moduleName, moduleType, package: pkg, class: cls, name: propOrMethod, method, companion, params: methodParams, errMsg, }, instanceId) {
function initProxyFunction(async, { moduleName, moduleType, package: pkg, class: cls, name: propOrMethod, method, companion, params: methodParams, errMsg, }, instanceId) {
...
@@ -17353,7 +17359,13 @@ function initProxyFunction(async, { moduleName, moduleType, package: pkg, class:
...
@@ -17353,7 +17359,13 @@ function initProxyFunction(async, { moduleName, moduleType, package: pkg, class:
});
});
if (async) {
if (async) {
return new Promise((resolve, reject) => {
return new Promise((resolve, reject) => {
if ((process.env.NODE_ENV !== 'production')) {
console.log('uts.invokeAsync.args', invokeArgs);
}
getProxy().invokeAsync(invokeArgs, (res) => {
getProxy().invokeAsync(invokeArgs, (res) => {
if ((process.env.NODE_ENV !== 'production')) {
console.log('uts.invokeAsync.result', res);
}
if (res.type !== 'return') {
if (res.type !== 'return') {
invokeCallback(res);
invokeCallback(res);
}
}
...
@@ -17368,6 +17380,9 @@ function initProxyFunction(async, { moduleName, moduleType, package: pkg, class:
...
@@ -17368,6 +17380,9 @@ function initProxyFunction(async, { moduleName, moduleType, package: pkg, class:
});
});
});
});
}
}
if ((process.env.NODE_ENV !== 'production')) {
console.log('uts.invokeSync.args', invokeArgs);
}
return resolveSyncResult(getProxy().invokeSync(invokeArgs, invokeCallback));
return resolveSyncResult(getProxy().invokeSync(invokeArgs, invokeCallback));
};
};
}
}
...
@@ -17380,6 +17395,12 @@ function initUTSStaticMethod(async, opts) {
...
@@ -17380,6 +17395,12 @@ function initUTSStaticMethod(async, opts) {
return initProxyFunction(async, opts, 0);
return initProxyFunction(async, opts, 0);
}
}
const initUTSProxyFunction = initUTSStaticMethod;
const initUTSProxyFunction = initUTSStaticMethod;
function parseClassMethodName(name, methods) {
if (hasOwn$1(methods, name + 'ByJs')) {
return name + 'ByJs';
}
return name;
}
function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, constructor: { params: constructorParams }, methods, props, staticProps, staticMethods, errMsg, }) {
function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, constructor: { params: constructorParams }, methods, props, staticProps, staticMethods, errMsg, }) {
const baseOptions = {
const baseOptions = {
moduleName,
moduleName,
...
@@ -17388,6 +17409,12 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
...
@@ -17388,6 +17409,12 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
class: cls,
class: cls,
errMsg,
errMsg,
};
};
// iOS 需要为 ByJs 的 class 构造函数(如果包含JSONObject或UTSCallback类型)补充最后一个参数
if (typeof plus !== 'undefined' && plus.os.name === 'iOS') {
if (constructorParams.find((p) => p.type === 'UTSCallback' || p.type.indexOf('JSONObject') > 0)) {
constructorParams.push({ name: '_byJs', type: 'boolean' });
}
}
const ProxyClass = class UTSClass {
const ProxyClass = class UTSClass {
constructor(...params) {
constructor(...params) {
if (errMsg) {
if (errMsg) {
...
@@ -17403,6 +17430,7 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
...
@@ -17403,6 +17430,7 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
get(_, name) {
get(_, name) {
if (!target[name]) {
if (!target[name]) {
//实例方法
//实例方法
name = parseClassMethodName(name, methods);
if (hasOwn$1(methods, name)) {
if (hasOwn$1(methods, name)) {
const { async, params } = methods[name];
const { async, params } = methods[name];
target[name] = initUTSInstanceMethod(!!async, extend({
target[name] = initUTSInstanceMethod(!!async, extend({
...
@@ -17429,6 +17457,7 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
...
@@ -17429,6 +17457,7 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
const staticMethodCache = {};
const staticMethodCache = {};
return new Proxy(ProxyClass, {
return new Proxy(ProxyClass, {
get(target, name, receiver) {
get(target, name, receiver) {
name = parseClassMethodName(name, staticMethods);
if (hasOwn$1(staticMethods, name)) {
if (hasOwn$1(staticMethods, name)) {
if (!staticMethodCache[name]) {
if (!staticMethodCache[name]) {
const { async, params } = staticMethods[name];
const { async, params } = staticMethods[name];
...
...
packages/uni-app-plus/src/service/api/plugin/uts.js
浏览文件 @
605d50f8
...
@@ -28,6 +28,9 @@ function getProxy() {
...
@@ -28,6 +28,9 @@ function getProxy() {
return
proxy
;
return
proxy
;
}
}
function
resolveSyncResult
(
res
)
{
function
resolveSyncResult
(
res
)
{
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
console
.
log
(
'
uts.invokeSync.result
'
,
res
);
}
if
(
res
.
errMsg
)
{
if
(
res
.
errMsg
)
{
throw
new
Error
(
res
.
errMsg
);
throw
new
Error
(
res
.
errMsg
);
}
}
...
@@ -38,6 +41,9 @@ function invokePropGetter(args) {
...
@@ -38,6 +41,9 @@ function invokePropGetter(args) {
throw
new
Error
(
args
.
errMsg
);
throw
new
Error
(
args
.
errMsg
);
}
}
delete
args
.
errMsg
;
delete
args
.
errMsg
;
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
console
.
log
(
'
uts.invokePropGetter.args
'
,
args
);
}
return
resolveSyncResult
(
getProxy
().
invokeSync
(
args
,
()
=>
{
}));
return
resolveSyncResult
(
getProxy
().
invokeSync
(
args
,
()
=>
{
}));
}
}
function
initProxyFunction
(
async
,
{
moduleName
,
moduleType
,
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
method
,
companion
,
params
:
methodParams
,
errMsg
,
},
instanceId
)
{
function
initProxyFunction
(
async
,
{
moduleName
,
moduleType
,
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
method
,
companion
,
params
:
methodParams
,
errMsg
,
},
instanceId
)
{
...
@@ -79,7 +85,13 @@ function initProxyFunction(async, { moduleName, moduleType, package: pkg, class:
...
@@ -79,7 +85,13 @@ function initProxyFunction(async, { moduleName, moduleType, package: pkg, class:
});
});
if
(
async
)
{
if
(
async
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
console
.
log
(
'
uts.invokeAsync.args
'
,
invokeArgs
);
}
getProxy
().
invokeAsync
(
invokeArgs
,
(
res
)
=>
{
getProxy
().
invokeAsync
(
invokeArgs
,
(
res
)
=>
{
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
console
.
log
(
'
uts.invokeAsync.result
'
,
res
);
}
if
(
res
.
type
!==
'
return
'
)
{
if
(
res
.
type
!==
'
return
'
)
{
invokeCallback
(
res
);
invokeCallback
(
res
);
}
}
...
@@ -94,6 +106,9 @@ function initProxyFunction(async, { moduleName, moduleType, package: pkg, class:
...
@@ -94,6 +106,9 @@ function initProxyFunction(async, { moduleName, moduleType, package: pkg, class:
});
});
});
});
}
}
if
((
process
.
env
.
NODE_ENV
!==
'
production
'
))
{
console
.
log
(
'
uts.invokeSync.args
'
,
invokeArgs
);
}
return
resolveSyncResult
(
getProxy
().
invokeSync
(
invokeArgs
,
invokeCallback
));
return
resolveSyncResult
(
getProxy
().
invokeSync
(
invokeArgs
,
invokeCallback
));
};
};
}
}
...
@@ -106,6 +121,12 @@ function initUTSStaticMethod(async, opts) {
...
@@ -106,6 +121,12 @@ function initUTSStaticMethod(async, opts) {
return
initProxyFunction
(
async
,
opts
,
0
);
return
initProxyFunction
(
async
,
opts
,
0
);
}
}
const
initUTSProxyFunction
=
initUTSStaticMethod
;
const
initUTSProxyFunction
=
initUTSStaticMethod
;
function
parseClassMethodName
(
name
,
methods
)
{
if
(
hasOwn
(
methods
,
name
+
'
ByJs
'
))
{
return
name
+
'
ByJs
'
;
}
return
name
;
}
function
initUTSProxyClass
({
moduleName
,
moduleType
,
package
:
pkg
,
class
:
cls
,
constructor
:
{
params
:
constructorParams
},
methods
,
props
,
staticProps
,
staticMethods
,
errMsg
,
})
{
function
initUTSProxyClass
({
moduleName
,
moduleType
,
package
:
pkg
,
class
:
cls
,
constructor
:
{
params
:
constructorParams
},
methods
,
props
,
staticProps
,
staticMethods
,
errMsg
,
})
{
const
baseOptions
=
{
const
baseOptions
=
{
moduleName
,
moduleName
,
...
@@ -114,6 +135,12 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
...
@@ -114,6 +135,12 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
class
:
cls
,
class
:
cls
,
errMsg
,
errMsg
,
};
};
// iOS 需要为 ByJs 的 class 构造函数(如果包含JSONObject或UTSCallback类型)补充最后一个参数
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
os
.
name
===
'
iOS
'
)
{
if
(
constructorParams
.
find
((
p
)
=>
p
.
type
===
'
UTSCallback
'
||
p
.
type
.
indexOf
(
'
JSONObject
'
)
>
0
))
{
constructorParams
.
push
({
name
:
'
_byJs
'
,
type
:
'
boolean
'
});
}
}
const
ProxyClass
=
class
UTSClass
{
const
ProxyClass
=
class
UTSClass
{
constructor
(...
params
)
{
constructor
(...
params
)
{
if
(
errMsg
)
{
if
(
errMsg
)
{
...
@@ -129,6 +156,7 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
...
@@ -129,6 +156,7 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
get
(
_
,
name
)
{
get
(
_
,
name
)
{
if
(
!
target
[
name
])
{
if
(
!
target
[
name
])
{
//实例方法
//实例方法
name
=
parseClassMethodName
(
name
,
methods
);
if
(
hasOwn
(
methods
,
name
))
{
if
(
hasOwn
(
methods
,
name
))
{
const
{
async
,
params
}
=
methods
[
name
];
const
{
async
,
params
}
=
methods
[
name
];
target
[
name
]
=
initUTSInstanceMethod
(
!!
async
,
extend
({
target
[
name
]
=
initUTSInstanceMethod
(
!!
async
,
extend
({
...
@@ -155,6 +183,7 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
...
@@ -155,6 +183,7 @@ function initUTSProxyClass({ moduleName, moduleType, package: pkg, class: cls, c
const
staticMethodCache
=
{};
const
staticMethodCache
=
{};
return
new
Proxy
(
ProxyClass
,
{
return
new
Proxy
(
ProxyClass
,
{
get
(
target
,
name
,
receiver
)
{
get
(
target
,
name
,
receiver
)
{
name
=
parseClassMethodName
(
name
,
staticMethods
);
if
(
hasOwn
(
staticMethods
,
name
))
{
if
(
hasOwn
(
staticMethods
,
name
))
{
if
(
!
staticMethodCache
[
name
])
{
if
(
!
staticMethodCache
[
name
])
{
const
{
async
,
params
}
=
staticMethods
[
name
];
const
{
async
,
params
}
=
staticMethods
[
name
];
...
...
packages/uni-app-plus/src/service/api/plugin/uts.ts
浏览文件 @
605d50f8
...
@@ -176,6 +176,9 @@ function getProxy(): {
...
@@ -176,6 +176,9 @@ function getProxy(): {
}
}
function
resolveSyncResult
(
res
:
InvokeSyncRes
)
{
function
resolveSyncResult
(
res
:
InvokeSyncRes
)
{
if
(
__DEV__
)
{
console
.
log
(
'
uts.invokeSync.result
'
,
res
)
}
if
(
res
.
errMsg
)
{
if
(
res
.
errMsg
)
{
throw
new
Error
(
res
.
errMsg
)
throw
new
Error
(
res
.
errMsg
)
}
}
...
@@ -187,6 +190,9 @@ function invokePropGetter(args: InvokeArgs) {
...
@@ -187,6 +190,9 @@ function invokePropGetter(args: InvokeArgs) {
throw
new
Error
(
args
.
errMsg
)
throw
new
Error
(
args
.
errMsg
)
}
}
delete
args
.
errMsg
delete
args
.
errMsg
if
(
__DEV__
)
{
console
.
log
(
'
uts.invokePropGetter.args
'
,
args
)
}
return
resolveSyncResult
(
getProxy
().
invokeSync
(
args
,
()
=>
{}))
return
resolveSyncResult
(
getProxy
().
invokeSync
(
args
,
()
=>
{}))
}
}
...
@@ -247,7 +253,13 @@ function initProxyFunction(
...
@@ -247,7 +253,13 @@ function initProxyFunction(
})
})
if
(
async
)
{
if
(
async
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
__DEV__
)
{
console
.
log
(
'
uts.invokeAsync.args
'
,
invokeArgs
)
}
getProxy
().
invokeAsync
(
invokeArgs
,
(
res
)
=>
{
getProxy
().
invokeAsync
(
invokeArgs
,
(
res
)
=>
{
if
(
__DEV__
)
{
console
.
log
(
'
uts.invokeAsync.result
'
,
res
)
}
if
(
res
.
type
!==
'
return
'
)
{
if
(
res
.
type
!==
'
return
'
)
{
invokeCallback
(
res
)
invokeCallback
(
res
)
}
else
{
}
else
{
...
@@ -260,6 +272,9 @@ function initProxyFunction(
...
@@ -260,6 +272,9 @@ function initProxyFunction(
})
})
})
})
}
}
if
(
__DEV__
)
{
console
.
log
(
'
uts.invokeSync.args
'
,
invokeArgs
)
}
return
resolveSyncResult
(
getProxy
().
invokeSync
(
invokeArgs
,
invokeCallback
))
return
resolveSyncResult
(
getProxy
().
invokeSync
(
invokeArgs
,
invokeCallback
))
}
}
}
}
...
@@ -275,6 +290,13 @@ function initUTSStaticMethod(async: boolean, opts: ProxyFunctionOptions) {
...
@@ -275,6 +290,13 @@ function initUTSStaticMethod(async: boolean, opts: ProxyFunctionOptions) {
export
const
initUTSProxyFunction
=
initUTSStaticMethod
export
const
initUTSProxyFunction
=
initUTSStaticMethod
function
parseClassMethodName
(
name
:
string
,
methods
:
Record
<
string
,
unknown
>
)
{
if
(
hasOwn
(
methods
,
name
+
'
ByJs
'
))
{
return
name
+
'
ByJs
'
}
return
name
}
export
function
initUTSProxyClass
({
export
function
initUTSProxyClass
({
moduleName
,
moduleName
,
moduleType
,
moduleType
,
...
@@ -294,6 +316,16 @@ export function initUTSProxyClass({
...
@@ -294,6 +316,16 @@ export function initUTSProxyClass({
class
:
cls
,
class
:
cls
,
errMsg
,
errMsg
,
}
}
// iOS 需要为 ByJs 的 class 构造函数(如果包含JSONObject或UTSCallback类型)补充最后一个参数
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
os
.
name
===
'
iOS
'
)
{
if
(
constructorParams
.
find
(
(
p
)
=>
p
.
type
===
'
UTSCallback
'
||
p
.
type
.
indexOf
(
'
JSONObject
'
)
>
0
)
)
{
constructorParams
.
push
({
name
:
'
_byJs
'
,
type
:
'
boolean
'
})
}
}
const
ProxyClass
=
class
UTSClass
{
const
ProxyClass
=
class
UTSClass
{
constructor
(...
params
:
unknown
[])
{
constructor
(...
params
:
unknown
[])
{
if
(
errMsg
)
{
if
(
errMsg
)
{
...
@@ -313,6 +345,7 @@ export function initUTSProxyClass({
...
@@ -313,6 +345,7 @@ export function initUTSProxyClass({
get
(
_
,
name
)
{
get
(
_
,
name
)
{
if
(
!
target
[
name
as
string
])
{
if
(
!
target
[
name
as
string
])
{
//实例方法
//实例方法
name
=
parseClassMethodName
(
name
as
string
,
methods
)
if
(
hasOwn
(
methods
,
name
))
{
if
(
hasOwn
(
methods
,
name
))
{
const
{
async
,
params
}
=
methods
[
name
]
const
{
async
,
params
}
=
methods
[
name
]
target
[
name
]
=
initUTSInstanceMethod
(
target
[
name
]
=
initUTSInstanceMethod
(
...
@@ -345,6 +378,7 @@ export function initUTSProxyClass({
...
@@ -345,6 +378,7 @@ export function initUTSProxyClass({
const
staticMethodCache
:
Record
<
string
,
Function
>
=
{}
const
staticMethodCache
:
Record
<
string
,
Function
>
=
{}
return
new
Proxy
(
ProxyClass
,
{
return
new
Proxy
(
ProxyClass
,
{
get
(
target
,
name
,
receiver
)
{
get
(
target
,
name
,
receiver
)
{
name
=
parseClassMethodName
(
name
as
string
,
staticMethods
)
if
(
hasOwn
(
staticMethods
,
name
))
{
if
(
hasOwn
(
staticMethods
,
name
))
{
if
(
!
staticMethodCache
[
name
as
string
])
{
if
(
!
staticMethodCache
[
name
as
string
])
{
const
{
async
,
params
}
=
staticMethods
[
name
]
const
{
async
,
params
}
=
staticMethods
[
name
]
...
...
packages/uts-darwin-arm64/uts.darwin-arm64.node
浏览文件 @
605d50f8
无法预览此类型文件
packages/uts-darwin-x64/uts.darwin-x64.node
浏览文件 @
605d50f8
无法预览此类型文件
packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node
浏览文件 @
605d50f8
无法预览此类型文件
packages/uts-linux-x64-musl/uts.linux-x64-musl.node
浏览文件 @
605d50f8
无法预览此类型文件
packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node
浏览文件 @
605d50f8
无法预览此类型文件
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
浏览文件 @
605d50f8
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录