Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
b438a5a4
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看板
提交
b438a5a4
编写于
10月 25, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(uts): android、iOS 中相同interface、class支持属性,方法合并
上级
d4018255
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
77 addition
and
26 deletion
+77
-26
packages/uni-uts-v1/__tests__/__snapshots__/code.spec.ts.snap
...ages/uni-uts-v1/__tests__/__snapshots__/code.spec.ts.snap
+2
-2
packages/uni-uts-v1/__tests__/examples/uts/unpackage/cache/app-android/uts/utssdk/test-uts/manifest.json
...ckage/cache/app-android/uts/utssdk/test-uts/manifest.json
+3
-3
packages/uni-uts-v1/__tests__/examples/uts/unpackage/cache/app-ios/uts/utssdk/test-uts/manifest.json
...unpackage/cache/app-ios/uts/utssdk/test-uts/manifest.json
+3
-3
packages/uni-uts-v1/__tests__/examples/uts/utssdk/test-uts/app-android/index.uts
...ests__/examples/uts/utssdk/test-uts/app-android/index.uts
+4
-2
packages/uni-uts-v1/__tests__/examples/uts/utssdk/test-uts/app-ios/index.uts
.../__tests__/examples/uts/utssdk/test-uts/app-ios/index.uts
+28
-0
packages/uni-uts-v1/__tests__/manifest.spec.ts
packages/uni-uts-v1/__tests__/manifest.spec.ts
+2
-2
packages/uni-uts-v1/src/code.ts
packages/uni-uts-v1/src/code.ts
+35
-14
未找到文件。
packages/uni-uts-v1/__tests__/__snapshots__/code.spec.ts.snap
浏览文件 @
b438a5a4
...
...
@@ -16,7 +16,7 @@ export const TestUTSComponent = {}
registerUTSInterface('RequestTaskOptions',Object.assign({ moduleName, moduleType, errMsg, package: pkg, class: initUTSClassName(name, 'RequestTaskByJsProxy', is_uni_modules) }, {"methods":{"startByJs":{"async":false,"params":[],"return":{}},"abortByJs":{"async":false,"params":[],"return":{"type":"interface","options":"RequestTaskOptions"}}},"props":[]} ))
export const onMemoryWarning = /*#__PURE__*/ initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'onMemoryWarningByJs', params: [{"name":"callback","type":"UTSCallback"}], return: ""})
export const offMemoryWarning = /*#__PURE__*/ initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'offMemoryWarningByJs', params: [{"name":"callback","type":"UTSCallback","default":"UTSNull"}], return: ""})
export default /*#__PURE__*/ initUTSProxyClass(Object.assign({ moduleName, moduleType, errMsg, package: pkg, class: initUTSClassName(name, 'UserByJs', is_uni_modules) }, {"constructor":{"params":[]},"methods":{},"staticMethods":{},"props":[],"staticProps":[]} ))
export default /*#__PURE__*/ initUTSProxyClass(Object.assign({ moduleName, moduleType, errMsg, package: pkg, class: initUTSClassName(name, 'UserByJs', is_uni_modules) }, {"constructor":{"params":[]},"methods":{
"registerByJs":{"async":false,"params":[],"returnOptions":{}},"loginByJs":{"async":false,"params":[],"returnOptions":{}}
},"staticMethods":{},"props":[],"staticProps":[]} ))
export const a = 1
export const showToast1 = /*#__PURE__*/ initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'showToast1ByJs', params: [{"name":"msg","type":"string"}], return: ""})
export const showToast2 = /*#__PURE__*/ initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'showToast2ByJs', params: [{"name":"msg","type":"string"}], return: ""})
...
...
@@ -329,7 +329,7 @@ exports.TestUTSComponent = {}
registerUTSInterface('RequestTaskOptions',Object.assign({ moduleName, moduleType, errMsg, package: pkg, class: initUTSClassName(name, 'RequestTaskByJsProxy', is_uni_modules) }, {"methods":{"startByJs":{"async":false,"params":[],"return":{}},"abortByJs":{"async":false,"params":[],"return":{"type":"interface","options":"RequestTaskOptions"}}},"props":[]} ))
exports.onMemoryWarning = /*#__PURE__*/ initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'onMemoryWarningByJs', params: [{"name":"callback","type":"UTSCallback"}], return: ""})
exports.offMemoryWarning = /*#__PURE__*/ initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'offMemoryWarningByJs', params: [{"name":"callback","type":"UTSCallback","default":"UTSNull"}], return: ""})
exports.default = initUTSProxyClass(Object.assign({ moduleName, moduleType, errMsg, package: pkg, class: initUTSClassName(name, 'UserByJs', is_uni_modules) }, {"constructor":{"params":[]},"methods":{},"staticMethods":{},"props":[],"staticProps":[]} ))
exports.default = initUTSProxyClass(Object.assign({ moduleName, moduleType, errMsg, package: pkg, class: initUTSClassName(name, 'UserByJs', is_uni_modules) }, {"constructor":{"params":[]},"methods":{
"registerByJs":{"async":false,"params":[],"returnOptions":{}},"loginByJs":{"async":false,"params":[],"returnOptions":{}}
},"staticMethods":{},"props":[],"staticProps":[]} ))
const a = 1
exports.a = a
exports.showToast1 = /*#__PURE__*/ initUTSProxyFunction(false, { moduleName, moduleType, errMsg, main: true, package: pkg, class: cls, name: 'showToast1ByJs', params: [{"name":"msg","type":"string"}], return: ""})
...
...
packages/uni-uts-v1/__tests__/examples/uts/unpackage/cache/app-android/uts/utssdk/test-uts/manifest.json
浏览文件 @
b438a5a4
...
...
@@ -4,15 +4,15 @@
"compilerVersion"
:
"3.6.10"
},
"files"
:
{
"app-android/index.uts"
:
{
"md5"
:
"6958ca9d5c365d041dd72dc46091b839"
},
"common/test/test.uts"
:
{
"md5"
:
"d41d8cd98f00b204e9800998ecf8427e"
},
"common/utils.uts"
:
{
"md5"
:
"d41d8cd98f00b204e9800998ecf8427e"
},
"index.uts"
:
{
"md5"
:
"719035aae84f58b2028f63d102c49887"
},
"interface.uts"
:
{
"md5"
:
"4821d45870be9af550787418f7a4c34c"
},
...
...
packages/uni-uts-v1/__tests__/examples/uts/unpackage/cache/app-ios/uts/utssdk/test-uts/manifest.json
浏览文件 @
b438a5a4
...
...
@@ -4,15 +4,15 @@
"compilerVersion"
:
"3.6.10"
},
"files"
:
{
"app-ios/index.uts"
:
{
"md5"
:
"3134e94f54ea061ea2e6440ceec9cebf"
},
"common/test/test.uts"
:
{
"md5"
:
"d41d8cd98f00b204e9800998ecf8427e"
},
"common/utils.uts"
:
{
"md5"
:
"d41d8cd98f00b204e9800998ecf8427e"
},
"index.uts"
:
{
"md5"
:
"719035aae84f58b2028f63d102c49887"
},
"interface.uts"
:
{
"md5"
:
"4821d45870be9af550787418f7a4c34c"
},
...
...
packages/uni-uts-v1/__tests__/examples/uts/utssdk/test-uts/index.uts
→
packages/uni-uts-v1/__tests__/examples/uts/utssdk/test-uts/
app-android/
index.uts
浏览文件 @
b438a5a4
import { ShowToast, RequestTask } from './interface.uts'
import { ShowToast, RequestTask } from '.
.
/interface.uts'
export function onMemoryWarning(callback: (level: number) => void) {}
export function offMemoryWarning(
callback: ((level: number) => void) | null = null
) {}
export default class User {}
export default class User {
login() {}
}
export const a = 1
export let b = 2,
c = 3
...
...
packages/uni-uts-v1/__tests__/examples/uts/utssdk/test-uts/app-ios/index.uts
0 → 100644
浏览文件 @
b438a5a4
import { ShowToast, RequestTask } from '../interface.uts'
export function onMemoryWarning(callback: (level: number) => void) {}
export function offMemoryWarning(
callback: ((level: number) => void) | null = null
) {}
export default class User {
register() {}
}
export const a = 1
export let b = 2,
c = 3
export const showToast1: ShowToast = (msg) => {
console.log(msg)
}
export const showToast2: ShowToast = function showToast(msg) {
console.log(msg)
}
export function request(): RequestTask {}
export type User1 = {
name: string
}
export function addUsers1(users: User1[]) {}
export function addUsers2(users: Array<User1>) {}
export function addUsers3(user: User1, name: string[]) {}
export function addUsers4(user: User1, name: Array<string>) {}
packages/uni-uts-v1/__tests__/manifest.spec.ts
浏览文件 @
b438a5a4
...
...
@@ -41,11 +41,11 @@ const pluginOptions = {
describe
(
'
manifest
'
,
()
=>
{
test
(
'
resolve android files
'
,
async
()
=>
{
expect
(
await
resolvePluginFiles
(
'
app-android
'
,
pluginDir
,
false
)).
toEqual
([
'
index.uts
'
,
'
interface.uts
'
,
'
package.json
'
,
'
common/utils.uts
'
,
'
common/test/test.uts
'
,
'
app-android/index.uts
'
,
])
expect
(
await
resolvePluginFiles
(
'
app-android
'
,
pluginModuleDir
,
true
)
...
...
@@ -60,11 +60,11 @@ describe('manifest', () => {
})
test
(
'
resolve ios files
'
,
async
()
=>
{
expect
(
await
resolvePluginFiles
(
'
app-ios
'
,
pluginDir
,
false
)).
toEqual
([
'
index.uts
'
,
'
interface.uts
'
,
'
package.json
'
,
'
common/utils.uts
'
,
'
common/test/test.uts
'
,
'
app-ios/index.uts
'
,
])
expect
(
await
resolvePluginFiles
(
'
app-ios
'
,
pluginModuleDir
,
true
)).
toEqual
([
'
package.json
'
,
...
...
packages/uni-uts-v1/src/code.ts
浏览文件 @
b438a5a4
...
...
@@ -549,27 +549,48 @@ async function parseModuleDecls(module: string, options: GenProxyCodeOptions) {
return
decls
}
function
mergeRecord
(
from
:
Record
<
string
,
any
>
,
to
:
Record
<
string
,
any
>
)
{
Object
.
keys
(
from
).
forEach
((
key
)
=>
{
if
(
!
hasOwn
(
to
,
key
))
{
to
[
key
]
=
from
[
key
]
}
})
}
function
mergeArray
(
from
:
any
[],
to
:
any
[])
{
from
.
forEach
((
item
)
=>
{
if
(
!
to
.
includes
(
item
))
{
to
.
push
(
item
)
}
})
}
function
mergeDecls
(
from
:
ProxyDecl
[],
to
:
ProxyDecl
[])
{
from
.
forEach
((
item
)
=>
{
if
(
item
.
type
===
'
InterfaceDeclaration
'
)
{
if
(
!
to
.
find
(
(
toItem
)
=>
toItem
.
type
===
'
InterfaceDeclaration
'
&&
toItem
.
cls
===
item
.
cls
)
)
{
const
decl
=
to
.
find
(
(
toItem
)
=>
toItem
.
type
===
'
InterfaceDeclaration
'
&&
toItem
.
cls
===
item
.
cls
)
as
ProxyInterface
|
undefined
if
(
!
decl
)
{
to
.
push
(
item
)
}
else
{
mergeRecord
(
item
.
options
.
methods
,
decl
.
options
.
methods
)
mergeArray
(
item
.
options
.
props
,
decl
.
options
.
props
)
}
}
else
if
(
item
.
type
===
'
Class
'
)
{
if
(
!
to
.
find
(
(
toItem
)
=>
toItem
.
type
===
'
Class
'
&&
toItem
.
cls
===
item
.
cls
&&
toItem
.
isDefault
===
item
.
isDefault
)
)
{
const
decl
=
to
.
find
(
(
toItem
)
=>
toItem
.
type
===
'
Class
'
&&
toItem
.
cls
===
item
.
cls
&&
toItem
.
isDefault
===
item
.
isDefault
)
as
ProxyClass
|
undefined
if
(
!
decl
)
{
to
.
push
(
item
)
}
else
{
mergeRecord
(
item
.
options
.
methods
,
decl
.
options
.
methods
)
mergeRecord
(
item
.
options
.
staticMethods
,
decl
.
options
.
staticMethods
)
mergeArray
(
item
.
options
.
props
,
decl
.
options
.
props
)
mergeArray
(
item
.
options
.
staticProps
,
decl
.
options
.
staticProps
)
}
}
else
if
(
item
.
type
===
'
FunctionDeclaration
'
)
{
if
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录