Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
genary
uni-app
提交
d583bd8a
U
uni-app
项目概览
genary
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d583bd8a
编写于
9月 23, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): compiler
上级
9c2e7276
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
129 addition
and
42 deletion
+129
-42
packages/playground/uts/unpackage/dist/app/uni_modules/test-uniplugin/app-ios/index.swift
...e/dist/app/uni_modules/test-uniplugin/app-ios/index.swift
+25
-17
packages/playground/uts/unpackage/dist/app/uni_modules/test-uniplugin/app-ios/index.swift.map
...st/app/uni_modules/test-uniplugin/app-ios/index.swift.map
+1
-1
packages/uni-app/dist/uni-app.cjs.js
packages/uni-app/dist/uni-app.cjs.js
+20
-5
packages/uni-app/dist/uni-app.d.ts
packages/uni-app/dist/uni-app.d.ts
+11
-1
packages/uni-app/dist/uni-app.es.js
packages/uni-app/dist/uni-app.es.js
+20
-6
packages/uni-app/src/index.ts
packages/uni-app/src/index.ts
+1
-0
packages/uni-app/src/uts.ts
packages/uni-app/src/uts.ts
+42
-4
packages/uni-uts-vite/src/utils/compiler/code.ts
packages/uni-uts-vite/src/utils/compiler/code.ts
+9
-8
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-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/app/uni_modules/test-uniplugin/app-ios/index.swift
浏览文件 @
d583bd8a
...
...
@@ -9,8 +9,29 @@ class GetBatteryInfoOptions : UTSJSONObject {
public
var
fail
:
UTSCallback
?;
public
var
complete
:
UTSCallback
?;
}
func
getBatteryInfo
(
_
options
:
GetBatteryInfoOptions
)
{
var
res
=
[
"errMsg"
:
"getBatteryInfo:ok"
,
"level"
:
UIDevice
.
current
.
batteryLevel
*
100
,
"isCharging"
:
UIDevice
.
current
.
batteryState
==
UIDevice
.
BatteryState
.
charging
]
as
[
String
:
Any
];
if
(
options
.
success
!=
nil
)
{
options
.
success
!
(
res
);
}
if
(
options
.
complete
!=
nil
)
{
options
.
complete
!
(
res
);
}
}
func
test1
(
_
callback
:
UTSCallback
)
{
console
.
log
(
"test1"
,
" at uni_modules/test-uniplugin/app-ios/index.uts:26"
);
console
.
log
(
"def ios"
,
" at uni_modules/test-uniplugin/app-ios/index.uts:31"
);
console
.
log
(
"ndef android"
,
" at uni_modules/test-uniplugin/app-ios/index.uts:34"
);
console
.
log
(
"def android || def ios"
,
" at uni_modules/test-uniplugin/app-ios/index.uts:40"
);
}
class
Test1
:
NSObject
{
}
@objc
(
UTSSDKModulesTestUniPluginTest
)
@objcMembers
class
Test
:
NSObject
{
public
init
(){
Test1
();
...
...
@@ -22,23 +43,10 @@ class Test : NSObject {
@objc
(
UTSSDKModulesTestUniPluginIndexSwift
)
@objcMembers
class
IndexSwift
:
NSObject
{
public
static
func
getBatteryInfo
(
_
options
:
GetBatteryInfoOptions
)
{
var
res
=
[
"errMsg"
:
"getBatteryInfo:ok"
,
"level"
:
UIDevice
.
current
.
batteryLevel
*
100
,
"isCharging"
:
UIDevice
.
current
.
batteryState
==
UIDevice
.
BatteryState
.
charging
]
as
[
String
:
Any
];
if
(
options
.
success
!=
nil
)
{
options
.
success
!
(
res
);
}
if
(
options
.
complete
!=
nil
)
{
options
.
complete
!
(
res
);
}
public
static
func
s_getBatteryInfo
(
_
options
:
GetBatteryInfoOptions
)
{
return
getBatteryInfo
(
options
);
}
public
static
func
test1
(
_
callback
:
UTSCallback
)
{
console
.
log
(
"test1"
,
" at uni_modules/test-uniplugin/app-ios/index.uts:26"
);
console
.
log
(
"def ios"
,
" at uni_modules/test-uniplugin/app-ios/index.uts:31"
);
console
.
log
(
"ndef android"
,
" at uni_modules/test-uniplugin/app-ios/index.uts:34"
);
console
.
log
(
"def android || def ios"
,
" at uni_modules/test-uniplugin/app-ios/index.uts:40"
);
public
static
func
s_test1
(
_
callback
:
UTSCallback
)
{
return
test1
(
callback
);
}
}
packages/playground/uts/unpackage/dist/app/uni_modules/test-uniplugin/app-ios/index.swift.map
浏览文件 @
d583bd8a
{"version":3,"sources":["/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-ios/index.uts"],"sourcesContent":["import { UIDevice } from 'UIKit'\n\ntype GetBatteryInfoOptions = {\n name: string\n pwd: number\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\n\nexport default function getBatteryInfo(options: GetBatteryInfoOptions) {\n const res = {\n errMsg: 'getBatteryInfo:ok',\n level: UIDevice.current.batteryLevel * 100,\n isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,\n }\n if (options.success != null) {\n options.success!(res)\n }\n if (options.complete != null) {\n options.complete!(res)\n }\n}\n\nexport function test1(callback: () => void) {\n console.log('test1')\n\n\n\n\n console.log('def ios')\n\n\n console.log('ndef android')\n\n\n\n\n\n console.log('def android || def ios')\n\n\n\n\n}\n\nclass Test1 {}\nexport class Test {\n constructor() {\n new Test1()\n }\n test(): string | null {\n return null\n }\n}\n"],"names":[],"mappings":";AAAA;AAEA;;AAA6B,MAAxB,qBAAqB;IACxB,WAAA,IAAI,EAAE,MAAM,EAAA;IACZ,WAAA,GAAG,EAAE,QAAM,EAAA;IACX,WAAA,OAAO,EAAC,WAA8B,EAAA;IACtC,WAAA,IAAI,EAAC,WAA8B,EAAA;IACnC,WAAA,QAAQ,EAAC,WAA8B,EAAA;CACxC;AAsCD,MAAM,KAAK;CAAG;AACP,MAAM,IAAI;IACf,aAAc;QACZ,AAAI,KAAK,EAAE;IACb;gBACA,IAAI,MAAI,MAAM,EAAQ;QACpB,OAAO,GAAI,CAAA;IACb;CACD;;;;uBA5CuB,cAAc,CAAC,EAAA,OAA8B,EAArB,qBAAqB,EAAE;QACrE,IAAM,GAAG,GAAG;YACV,CAAA,MAAM,GAAE,mBAAmB;YAC3B,CAAA,KAAK,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG;YAC1C,CAAA,UAAU,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY,CAAC,QAAQ;0BAC5E;QACD,IAAI,OAAO,CAAC,OAAO,IAAI,GAAI;YACzB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;;QAEvB,IAAI,OAAO,CAAC,QAAQ,IAAI,GAAI;YAC1B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;;IAE1B;uBAEgB,KAAK,CAAC,EAAA,QAAoB,aAAA,EAAE;QAC1C,OAAO,CAAC,GAAG,CAAC,OAAO,wDAAC;QAKpB,OAAO,CAAC,GAAG,CAAC,SAAS,wDAAC;QAGtB,OAAO,CAAC,GAAG,CAAC,cAAc,wDAAC;QAM3B,OAAO,CAAC,GAAG,CAAC,wBAAwB,wDAAC;IAKvC"}
\ No newline at end of file
{"version":3,"sources":["/Users/fxy/Projects/GitHub/uni-app/uni-app-next/packages/playground/uts/uni_modules/test-uniplugin/app-ios/index.uts"],"sourcesContent":["import { UIDevice } from 'UIKit'\n\ntype GetBatteryInfoOptions = {\n name: string\n pwd: number\n success?: (res: UTSJSONObject) => void\n fail?: (res: UTSJSONObject) => void\n complete?: (res: UTSJSONObject) => void\n}\n\nexport default function getBatteryInfo(options: GetBatteryInfoOptions) {\n const res = {\n errMsg: 'getBatteryInfo:ok',\n level: UIDevice.current.batteryLevel * 100,\n isCharging: UIDevice.current.batteryState == UIDevice.BatteryState.charging,\n }\n if (options.success != null) {\n options.success!(res)\n }\n if (options.complete != null) {\n options.complete!(res)\n }\n}\n\nexport function test1(callback: () => void) {\n console.log('test1')\n\n\n\n\n console.log('def ios')\n\n\n console.log('ndef android')\n\n\n\n\n\n console.log('def android || def ios')\n\n\n\n\n}\n\nclass Test1 {}\nexport class Test {\n constructor() {\n new Test1()\n }\n test(): string | null {\n return null\n }\n}\n"],"names":[],"mappings":";AAAA;AAE6B;;MAAxB,qBAAqB;IACxB,WAAA,IAAI,EAAE,MAAM,EAAA;IACZ,WAAA,GAAG,EAAE,QAAM,EAAA;IACX,WAAA,OAAO,EAAC,WAA8B,EAAA;IACtC,WAAA,IAAI,EAAC,WAA8B,EAAA;IACnC,WAAA,QAAQ,EAAC,WAA8B,EAAA;CACxC;AAEc,KAAS,cAAc,CAAC,EAAA,OAA8B,EAArB,qBAAqB,EAAE;IACrE,IAAM,GAAG,GAAG;QACV,CAAA,MAAM,GAAE,mBAAmB;QAC3B,CAAA,KAAK,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG;QAC1C,CAAA,UAAU,GAAE,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY,CAAC,QAAQ;sBAC5E;IACD,IAAI,OAAO,CAAC,OAAO,IAAI,GAAI;QACzB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC;;IAEvB,IAAI,OAAO,CAAC,QAAQ,IAAI,GAAI;QAC1B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;;AAE1B;AAEO,KAAS,KAAK,CAAC,EAAA,QAAoB,aAAA,EAAE;IAC1C,OAAO,CAAC,GAAG,CAAC,OAAO,wDAAC;IAKpB,OAAO,CAAC,GAAG,CAAC,SAAS,wDAAC;IAGtB,OAAO,CAAC,GAAG,CAAC,cAAc,wDAAC;IAM3B,OAAO,CAAC,GAAG,CAAC,wBAAwB,wDAAC;AAKvC;AAEA,MAAM,KAAK;CAAG;AACP;;MAAM,IAAI;IACf,aAAc;QACZ,AAAI,KAAK,EAAE;IACb;gBACA,IAAI,MAAI,MAAM,EAAQ;QACpB,OAAO,GAAI,CAAA;IACb;CACD;;;;wCA5CsC,EAAA,OAA8B,EAArB,qBAAqB;eAA7C,cAAc,CAAC,OAA8B;;+BAc/C,EAAA,QAAoB,aAAA;eAA1B,KAAK,CAAC,QAAoB"}
\ No newline at end of file
packages/uni-app/dist/uni-app.cjs.js
浏览文件 @
d583bd8a
...
...
@@ -183,7 +183,7 @@ function resolveSyncResult(res) {
function
invokePropGetter
(
args
)
{
return
resolveSyncResult
(
getProxy
().
invokeSync
(
args
,
()
=>
{
}));
}
function
initProxyFunction
(
async
,
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
companion
,
params
:
methodParams
,
},
instanceId
)
{
function
initProxyFunction
(
async
,
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
method
,
companion
,
params
:
methodParams
,
},
instanceId
)
{
const
invokeCallback
=
({
id
,
name
,
params
,
keepAlive
,
})
=>
{
const
callback
=
callbacks
[
id
];
if
(
callback
)
{
...
...
@@ -201,7 +201,7 @@ function initProxyFunction(async, { package: pkg, class: cls, name: propOrMethod
:
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
name
:
method
||
propOrMethod
,
companion
,
method
:
methodParams
,
};
...
...
@@ -230,6 +230,11 @@ function initProxyFunction(async, { package: pkg, class: cls, name: propOrMethod
};
}
function
initUtsStaticMethod
(
async
,
opts
)
{
if
(
opts
.
main
&&
!
opts
.
method
)
{
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
os
.
name
===
'
iOS
'
)
{
opts
.
method
=
'
s_
'
+
opts
.
name
;
}
}
return
initProxyFunction
(
async
,
opts
);
}
const
initUtsProxyFunction
=
initUtsStaticMethod
;
...
...
@@ -290,15 +295,24 @@ function initUtsPackageName(name, is_uni_modules) {
}
return
''
;
}
function
initUtsClassName
(
name
,
is_uni_modules
)
{
function
initUtsIndexClassName
(
moduleName
,
is_uni_modules
)
{
if
(
typeof
plus
===
'
undefined
'
)
{
return
''
;
}
return
initUtsClassName
(
moduleName
,
plus
.
os
.
name
===
'
iOS
'
?
'
IndexSwift
'
:
'
IndexKt
'
,
is_uni_modules
);
}
function
initUtsClassName
(
moduleName
,
className
,
is_uni_modules
)
{
if
(
typeof
plus
===
'
undefined
'
)
{
return
''
;
}
if
(
plus
.
os
.
name
===
'
Android
'
)
{
return
'
IndexKt
'
;
return
className
;
}
if
(
plus
.
os
.
name
===
'
iOS
'
)
{
return
'
UTSSDK
'
+
(
is_uni_modules
?
'
Modules
'
:
''
)
+
shared
.
capitalize
(
name
);
return
(
'
UTSSDK
'
+
(
is_uni_modules
?
'
Modules
'
:
''
)
+
shared
.
capitalize
(
moduleName
)
+
shared
.
capitalize
(
className
));
}
return
''
;
}
...
...
@@ -308,6 +322,7 @@ exports.formatH5Log = formatH5Log;
exports
.
getCurrentSubNVue
=
getCurrentSubNVue
;
exports
.
getSsrGlobalData
=
getSsrGlobalData
;
exports
.
initUtsClassName
=
initUtsClassName
;
exports
.
initUtsIndexClassName
=
initUtsIndexClassName
;
exports
.
initUtsPackageName
=
initUtsPackageName
;
exports
.
initUtsProxyClass
=
initUtsProxyClass
;
exports
.
initUtsProxyFunction
=
initUtsProxyFunction
;
...
...
packages/uni-app/dist/uni-app.d.ts
浏览文件 @
d583bd8a
...
...
@@ -39,7 +39,9 @@ export declare function getCurrentSubNVue(): any;
export
declare
function
getSsrGlobalData
():
any
;
export
declare
function
initUtsClassName
(
name
:
string
,
is_uni_modules
:
boolean
):
string
;
export
declare
function
initUtsClassName
(
moduleName
:
string
,
className
:
string
,
is_uni_modules
:
boolean
):
string
;
export
declare
function
initUtsIndexClassName
(
moduleName
:
string
,
is_uni_modules
:
boolean
):
string
;
export
declare
function
initUtsPackageName
(
name
:
string
,
is_uni_modules
:
boolean
):
string
;
...
...
@@ -203,6 +205,10 @@ declare interface ProxyClassOptions {
}
declare
interface
ProxyFunctionOptions
{
/**
* 是否是入口类
*/
main
?:
boolean
;
/**
* 包名
*/
...
...
@@ -215,6 +221,10 @@ declare interface ProxyFunctionOptions {
* 属性名或方法名
*/
name
:
string
;
/**
* 方法名 指定的方法名(用于 IndexSwift 静态方法,自动补充前缀 s_)
*/
method
?:
string
;
/**
* 是否伴生对象
*/
...
...
packages/uni-app/dist/uni-app.es.js
浏览文件 @
d583bd8a
...
...
@@ -151,7 +151,7 @@ function resolveSyncResult(res) {
function
invokePropGetter
(
args
)
{
return
resolveSyncResult
(
getProxy
().
invokeSync
(
args
,
()
=>
{
}));
}
function
initProxyFunction
(
async
,
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
companion
,
params
:
methodParams
,
},
instanceId
)
{
function
initProxyFunction
(
async
,
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
method
,
companion
,
params
:
methodParams
,
},
instanceId
)
{
const
invokeCallback
=
({
id
,
name
,
params
,
keepAlive
,
})
=>
{
const
callback
=
callbacks
[
id
];
if
(
callback
)
{
...
...
@@ -169,7 +169,7 @@ function initProxyFunction(async, { package: pkg, class: cls, name: propOrMethod
:
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
name
:
method
||
propOrMethod
,
companion
,
method
:
methodParams
,
};
...
...
@@ -198,6 +198,11 @@ function initProxyFunction(async, { package: pkg, class: cls, name: propOrMethod
};
}
function
initUtsStaticMethod
(
async
,
opts
)
{
if
(
opts
.
main
&&
!
opts
.
method
)
{
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
os
.
name
===
'
iOS
'
)
{
opts
.
method
=
'
s_
'
+
opts
.
name
;
}
}
return
initProxyFunction
(
async
,
opts
);
}
const
initUtsProxyFunction
=
initUtsStaticMethod
;
...
...
@@ -258,17 +263,26 @@ function initUtsPackageName(name, is_uni_modules) {
}
return
''
;
}
function
initUtsClassName
(
name
,
is_uni_modules
)
{
function
initUtsIndexClassName
(
moduleName
,
is_uni_modules
)
{
if
(
typeof
plus
===
'
undefined
'
)
{
return
''
;
}
return
initUtsClassName
(
moduleName
,
plus
.
os
.
name
===
'
iOS
'
?
'
IndexSwift
'
:
'
IndexKt
'
,
is_uni_modules
);
}
function
initUtsClassName
(
moduleName
,
className
,
is_uni_modules
)
{
if
(
typeof
plus
===
'
undefined
'
)
{
return
''
;
}
if
(
plus
.
os
.
name
===
'
Android
'
)
{
return
'
IndexKt
'
;
return
className
;
}
if
(
plus
.
os
.
name
===
'
iOS
'
)
{
return
'
UTSSDK
'
+
(
is_uni_modules
?
'
Modules
'
:
''
)
+
capitalize
(
name
);
return
(
'
UTSSDK
'
+
(
is_uni_modules
?
'
Modules
'
:
''
)
+
capitalize
(
moduleName
)
+
capitalize
(
className
));
}
return
''
;
}
export
{
formatAppLog
,
formatH5Log
,
getCurrentSubNVue
,
getSsrGlobalData
,
initUtsClassName
,
initUtsPackageName
,
initUtsProxyClass
,
initUtsProxyFunction
,
onAddToFavorites
,
onBackPress
,
onError
,
onHide
,
onInit
,
onLaunch
,
onLoad
,
onNavigationBarButtonTap
,
onNavigationBarSearchInputChanged
,
onNavigationBarSearchInputClicked
,
onNavigationBarSearchInputConfirmed
,
onNavigationBarSearchInputFocusChanged
,
onPageNotFound
,
onPageScroll
,
onPullDownRefresh
,
onReachBottom
,
onReady
,
onResize
,
onSaveExitState
,
onShareAppMessage
,
onShareTimeline
,
onShow
,
onTabItemTap
,
onThemeChange
,
onUnhandledRejection
,
onUnload
,
requireNativePlugin
,
resolveEasycom
,
shallowSsrRef
,
ssrRef
};
export
{
formatAppLog
,
formatH5Log
,
getCurrentSubNVue
,
getSsrGlobalData
,
initUtsClassName
,
initUts
IndexClassName
,
initUts
PackageName
,
initUtsProxyClass
,
initUtsProxyFunction
,
onAddToFavorites
,
onBackPress
,
onError
,
onHide
,
onInit
,
onLaunch
,
onLoad
,
onNavigationBarButtonTap
,
onNavigationBarSearchInputChanged
,
onNavigationBarSearchInputClicked
,
onNavigationBarSearchInputConfirmed
,
onNavigationBarSearchInputFocusChanged
,
onPageNotFound
,
onPageScroll
,
onPullDownRefresh
,
onReachBottom
,
onReady
,
onResize
,
onSaveExitState
,
onShareAppMessage
,
onShareTimeline
,
onShow
,
onTabItemTap
,
onThemeChange
,
onUnhandledRejection
,
onUnload
,
requireNativePlugin
,
resolveEasycom
,
shallowSsrRef
,
ssrRef
};
packages/uni-app/src/index.ts
浏览文件 @
d583bd8a
...
...
@@ -6,6 +6,7 @@ export * from './apiLifecycle'
export
{
initUtsProxyClass
,
initUtsProxyFunction
,
initUtsIndexClassName
,
initUtsClassName
,
initUtsPackageName
,
}
from
'
./uts
'
packages/uni-app/src/uts.ts
浏览文件 @
d583bd8a
...
...
@@ -26,6 +26,10 @@ interface Parameter {
type
:
string
}
interface
ProxyFunctionOptions
{
/**
* 是否是入口类
*/
main
?:
boolean
/**
* 包名
*/
...
...
@@ -38,6 +42,10 @@ interface ProxyFunctionOptions {
* 属性名或方法名
*/
name
:
string
/**
* 方法名 指定的方法名(用于 IndexSwift 静态方法,自动补充前缀 s_)
*/
method
?:
string
/**
* 是否伴生对象
*/
...
...
@@ -153,6 +161,7 @@ function initProxyFunction(
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
method
,
companion
,
params
:
methodParams
,
}:
ProxyFunctionOptions
,
...
...
@@ -179,7 +188,7 @@ function initProxyFunction(
:
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
name
:
method
||
propOrMethod
,
companion
,
method
:
methodParams
,
}
...
...
@@ -207,8 +216,14 @@ function initProxyFunction(
}
function
initUtsStaticMethod
(
async
:
boolean
,
opts
:
ProxyFunctionOptions
)
{
if
(
opts
.
main
&&
!
opts
.
method
)
{
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
os
.
name
===
'
iOS
'
)
{
opts
.
method
=
'
s_
'
+
opts
.
name
}
}
return
initProxyFunction
(
async
,
opts
)
}
export
const
initUtsProxyFunction
=
initUtsStaticMethod
export
function
initUtsProxyClass
({
...
...
@@ -292,15 +307,38 @@ export function initUtsPackageName(name: string, is_uni_modules: boolean) {
return
''
}
export
function
initUtsClassName
(
name
:
string
,
is_uni_modules
:
boolean
)
{
export
function
initUtsIndexClassName
(
moduleName
:
string
,
is_uni_modules
:
boolean
)
{
if
(
typeof
plus
===
'
undefined
'
)
{
return
''
}
return
initUtsClassName
(
moduleName
,
plus
.
os
.
name
===
'
iOS
'
?
'
IndexSwift
'
:
'
IndexKt
'
,
is_uni_modules
)
}
export
function
initUtsClassName
(
moduleName
:
string
,
className
:
string
,
is_uni_modules
:
boolean
)
{
if
(
typeof
plus
===
'
undefined
'
)
{
return
''
}
if
(
plus
.
os
.
name
===
'
Android
'
)
{
return
'
IndexKt
'
return
className
}
if
(
plus
.
os
.
name
===
'
iOS
'
)
{
return
'
UTSSDK
'
+
(
is_uni_modules
?
'
Modules
'
:
''
)
+
capitalize
(
name
)
return
(
'
UTSSDK
'
+
(
is_uni_modules
?
'
Modules
'
:
''
)
+
capitalize
(
moduleName
)
+
capitalize
(
className
)
)
}
return
''
}
packages/uni-uts-vite/src/utils/compiler/code.ts
浏览文件 @
d583bd8a
...
...
@@ -29,11 +29,12 @@ export async function genProxyCode(
)
{
const
{
name
,
is_uni_modules
}
=
options
return
`
import { initUtsProxyClass, initUtsProxyFunction, initUtsPackageName, initUtsClassName } from '@dcloudio/uni-app'
import { extend } from '@vue/shared'
import { initUtsProxyClass, initUtsProxyFunction, initUtsPackageName, initUtsIndexClassName, initUtsClassName } from '@dcloudio/uni-app'
const name = '
${
name
}
'
const is_uni_modules =
${
is_uni_modules
}
const pkg = initUtsPackageName(name, is_uni_modules)
const cls = initUtsClassName(name, is_uni_modules)
const cls = initUts
Index
ClassName(name, is_uni_modules)
${
genModuleCode
(
await
parseModuleDecls
(
module
,
options
))}
`
}
...
...
@@ -63,17 +64,17 @@ function genModuleCode(decls: ProxyDecl[]) {
if
(
decl
.
type
===
'
Class
'
)
{
if
(
decl
.
isDefault
)
{
codes
.
push
(
`export default initUtsProxyClass(
{ package: pkg, class:
'
${
`export default initUtsProxyClass(
extend({ package: pkg, class: initUtsClassName(name,
'
${
decl
.
cls
}
',
...
${
JSON
.
stringify
(
decl
.
options
)}
}
)`
}
',
is_uni_modules) },
${
JSON
.
stringify
(
decl
.
options
)}
)
)`
)
}
else
{
codes
.
push
(
`export const
${
decl
.
cls
}
= initUtsProxyClass(
{ package: pkg, class:
'
${
}
= initUtsProxyClass(
extend({ package: pkg, class: initUtsClassName(name,
'
${
decl
.
cls
}
',
...
${
JSON
.
stringify
(
decl
.
options
)}
}
)`
}
',
is_uni_modules) },
${
JSON
.
stringify
(
decl
.
options
)}
)
)`
)
}
}
else
if
(
decl
.
type
===
'
FunctionDeclaration
'
)
{
...
...
@@ -81,7 +82,7 @@ function genModuleCode(decls: ProxyDecl[]) {
codes
.
push
(
`export default initUtsProxyFunction(
${
decl
.
async
}
, { package: pkg, class: cls, name: '
${
}
, {
main: true,
package: pkg, class: cls, name: '
${
decl
.
method
}
', params:
${
JSON
.
stringify
(
decl
.
params
)}
})`
)
...
...
@@ -89,7 +90,7 @@ function genModuleCode(decls: ProxyDecl[]) {
codes
.
push
(
`export const
${
decl
.
method
}
= initUtsProxyFunction(
${
decl
.
async
}
, { package: pkg, class: cls, name: '
${
}
, {
main: true,
package: pkg, class: cls, name: '
${
decl
.
method
}
', params:
${
JSON
.
stringify
(
decl
.
params
)}
})`
)
...
...
packages/uts-darwin-arm64/uts.darwin-arm64.node
浏览文件 @
d583bd8a
无法预览此类型文件
packages/uts-darwin-x64/uts.darwin-x64.node
浏览文件 @
d583bd8a
无法预览此类型文件
packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node
浏览文件 @
d583bd8a
无法预览此类型文件
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
浏览文件 @
d583bd8a
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录