Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
布及
uni-app
提交
cc799473
U
uni-app
项目概览
布及
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
cc799473
编写于
1月 31, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): refactor
上级
6691b0f7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
23 deletion
+42
-23
lib/apis.js
lib/apis.js
+9
-2
src/core/helpers/promise.js
src/core/helpers/promise.js
+1
-1
src/platforms/app-plus/service/api/index.js
src/platforms/app-plus/service/api/index.js
+6
-6
src/platforms/app-plus/service/api/plugin/uts.js
src/platforms/app-plus/service/api/plugin/uts.js
+26
-14
未找到文件。
lib/apis.js
浏览文件 @
cc799473
...
...
@@ -263,7 +263,14 @@ const third = [
'
sendHostEvent
'
,
'
navigateToMiniProgram
'
,
'
getLaunchOptionsSync
'
,
'
getEnterOptionsSync
'
'
getEnterOptionsSync
'
,
'
initUTSProxyClass
'
,
'
initUTSProxyFunction
'
,
'
initUTSIndexClassName
'
,
'
initUTSClassName
'
,
'
initUTSPackageName
'
,
'
requireUTSPlugin
'
,
'
registerUTSPlugin
'
,
]
const
ad
=
[
...
...
@@ -299,4 +306,4 @@ const apis = [
...
plugin
]
module
.
exports
=
apis
module
.
exports
=
apis
src/core/helpers/promise.js
浏览文件 @
cc799473
...
...
@@ -8,7 +8,7 @@ import {
}
from
'
./interceptor
'
const
SYNC_API_RE
=
/^
\$
|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting/
/^
\$
|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting
|initUTS|requireUTS|registerUTS
/
const
CONTEXT_API_RE
=
/^create|Manager$/
...
...
src/platforms/app-plus/service/api/index.js
浏览文件 @
cc799473
...
...
@@ -65,12 +65,12 @@ export * from './plugin/get-launch-options-sync'
// 内部使用
export
{
initU
tsProxyClass
,
initU
tsProxyFunction
,
initU
tsIndexClassName
,
initU
tsClassName
,
initU
tsPackageName
,
requireUTSPlugin
,
initU
TSProxyClass
,
initU
TSProxyFunction
,
initU
TSIndexClassName
,
initU
TSClassName
,
initU
TSPackageName
,
requireUTSPlugin
,
registerUTSPlugin
,
}
from
'
./plugin/uts
'
...
...
src/platforms/app-plus/service/api/plugin/uts.js
浏览文件 @
cc799473
...
...
@@ -18,7 +18,7 @@ function normalizeArg(arg) {
}
return
arg
;
}
function
initU
ts
InstanceMethod
(
async
,
opts
,
instanceId
)
{
function
initU
TS
InstanceMethod
(
async
,
opts
,
instanceId
)
{
return
initProxyFunction
(
async
,
opts
,
instanceId
);
}
function
getProxy
()
{
...
...
@@ -40,7 +40,7 @@ function invokePropGetter(args) {
delete
args
.
errMsg
;
return
resolveSyncResult
(
getProxy
().
invokeSync
(
args
,
()
=>
{
}));
}
function
initProxyFunction
(
async
,
{
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
)
{
const
invokeCallback
=
({
id
,
name
,
params
,
keepAlive
,
})
=>
{
const
callback
=
callbacks
[
id
];
if
(
callback
)
{
...
...
@@ -54,8 +54,16 @@ function initProxyFunction(async, { package: pkg, class: cls, name: propOrMethod
}
};
const
baseArgs
=
instanceId
?
{
id
:
instanceId
,
name
:
propOrMethod
,
method
:
methodParams
}
?
{
moduleName
,
moduleType
,
id
:
instanceId
,
name
:
propOrMethod
,
method
:
methodParams
,
}
:
{
moduleName
,
moduleType
,
package
:
pkg
,
class
:
cls
,
name
:
method
||
propOrMethod
,
...
...
@@ -89,7 +97,7 @@ function initProxyFunction(async, { package: pkg, class: cls, name: propOrMethod
return
resolveSyncResult
(
getProxy
().
invokeSync
(
invokeArgs
,
invokeCallback
));
};
}
function
initU
ts
StaticMethod
(
async
,
opts
)
{
function
initU
TS
StaticMethod
(
async
,
opts
)
{
if
(
opts
.
main
&&
!
opts
.
method
)
{
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
os
.
name
===
'
iOS
'
)
{
opts
.
method
=
'
s_
'
+
opts
.
name
;
...
...
@@ -97,14 +105,16 @@ function initUtsStaticMethod(async, opts) {
}
return
initProxyFunction
(
async
,
opts
,
0
);
}
const
initU
tsProxyFunction
=
initUts
StaticMethod
;
function
initU
tsProxyClass
({
package
:
pkg
,
class
:
cls
,
constructor
:
{
params
:
constructorParams
},
methods
,
props
,
staticProps
,
staticMethods
,
errMsg
,
})
{
const
initU
TSProxyFunction
=
initUTS
StaticMethod
;
function
initU
TSProxyClass
({
moduleName
,
moduleType
,
package
:
pkg
,
class
:
cls
,
constructor
:
{
params
:
constructorParams
},
methods
,
props
,
staticProps
,
staticMethods
,
errMsg
,
})
{
const
baseOptions
=
{
moduleName
,
moduleType
,
package
:
pkg
,
class
:
cls
,
errMsg
,
};
const
ProxyClass
=
class
U
ts
Class
{
const
ProxyClass
=
class
U
TS
Class
{
constructor
(...
params
)
{
if
(
errMsg
)
{
throw
new
Error
(
errMsg
);
...
...
@@ -121,7 +131,7 @@ function initUtsProxyClass({ package: pkg, class: cls, constructor: { params: co
//实例方法
if
(
hasOwn
(
methods
,
name
))
{
const
{
async
,
params
}
=
methods
[
name
];
target
[
name
]
=
initU
ts
InstanceMethod
(
!!
async
,
extend
({
target
[
name
]
=
initU
TS
InstanceMethod
(
!!
async
,
extend
({
name
,
params
,
},
baseOptions
),
instanceId
);
...
...
@@ -129,6 +139,8 @@ function initUtsProxyClass({ package: pkg, class: cls, constructor: { params: co
else
if
(
props
.
includes
(
name
))
{
// 实例属性
return
invokePropGetter
({
moduleName
,
moduleType
,
id
:
instanceId
,
name
:
name
,
errMsg
,
...
...
@@ -147,7 +159,7 @@ function initUtsProxyClass({ package: pkg, class: cls, constructor: { params: co
if
(
!
staticMethodCache
[
name
])
{
const
{
async
,
params
}
=
staticMethods
[
name
];
// 静态方法
staticMethodCache
[
name
]
=
initU
ts
StaticMethod
(
!!
async
,
extend
({
name
,
companion
:
true
,
params
},
baseOptions
));
staticMethodCache
[
name
]
=
initU
TS
StaticMethod
(
!!
async
,
extend
({
name
,
companion
:
true
,
params
},
baseOptions
));
}
return
staticMethodCache
[
name
];
}
...
...
@@ -159,19 +171,19 @@ function initUtsProxyClass({ package: pkg, class: cls, constructor: { params: co
},
});
}
function
initU
ts
PackageName
(
name
,
is_uni_modules
)
{
function
initU
TS
PackageName
(
name
,
is_uni_modules
)
{
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
os
.
name
===
'
Android
'
)
{
return
'
uts.sdk.
'
+
(
is_uni_modules
?
'
modules.
'
:
''
)
+
name
;
}
return
''
;
}
function
initU
ts
IndexClassName
(
moduleName
,
is_uni_modules
)
{
function
initU
TS
IndexClassName
(
moduleName
,
is_uni_modules
)
{
if
(
typeof
plus
===
'
undefined
'
)
{
return
''
;
}
return
initU
ts
ClassName
(
moduleName
,
plus
.
os
.
name
===
'
iOS
'
?
'
IndexSwift
'
:
'
IndexKt
'
,
is_uni_modules
);
return
initU
TS
ClassName
(
moduleName
,
plus
.
os
.
name
===
'
iOS
'
?
'
IndexSwift
'
:
'
IndexKt
'
,
is_uni_modules
);
}
function
initU
ts
ClassName
(
moduleName
,
className
,
is_uni_modules
)
{
function
initU
TS
ClassName
(
moduleName
,
className
,
is_uni_modules
)
{
if
(
typeof
plus
===
'
undefined
'
)
{
return
''
;
}
...
...
@@ -198,4 +210,4 @@ function requireUTSPlugin(name) {
return
define
;
}
export
{
initU
tsClassName
,
initUtsIndexClassName
,
initUtsPackageName
,
initUtsProxyClass
,
initUts
ProxyFunction
,
normalizeArg
,
registerUTSPlugin
,
requireUTSPlugin
};
export
{
initU
TSClassName
,
initUTSIndexClassName
,
initUTSPackageName
,
initUTSProxyClass
,
initUTS
ProxyFunction
,
normalizeArg
,
registerUTSPlugin
,
requireUTSPlugin
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录