Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
6eae1e9f
U
uni-app
项目概览
yangkaifeng
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
3
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,发现更多精彩内容 >>
提交
6eae1e9f
编写于
8月 09, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): compiler
上级
7efd1e5c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
72 addition
and
34 deletion
+72
-34
packages/uni-app/__tests__/module.spec.ts
packages/uni-app/__tests__/module.spec.ts
+2
-2
packages/uni-app/dist/uni-app.cjs.js
packages/uni-app/dist/uni-app.cjs.js
+20
-10
packages/uni-app/dist/uni-app.es.js
packages/uni-app/dist/uni-app.es.js
+20
-10
packages/uni-app/src/uts.ts
packages/uni-app/src/uts.ts
+30
-12
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/uni-app/__tests__/module.spec.ts
浏览文件 @
6eae1e9f
...
...
@@ -86,7 +86,7 @@ describe('uts-module', () => {
const
wifi
=
new
WifiManager
()
wifi
.
preparePermission
(
1
,
2
,
3
,
()
=>
{})
wifi
.
count
wifi
.
staticCount
wifi
.
staticPreparePermission
(
1
)
WifiManager
.
staticCount
WifiManager
.
staticPreparePermission
(
1
)
})
})
packages/uni-app/dist/uni-app.cjs.js
浏览文件 @
6eae1e9f
...
...
@@ -169,7 +169,7 @@ function resolveSyncResult(res) {
function
invokePropGetter
(
args
)
{
return
resolveSyncResult
(
getProxy
().
invokeSync
(
args
,
()
=>
{
}));
}
function
initProxyFunction
(
async
,
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
id
:
instanceId
,
})
{
function
initProxyFunction
(
async
,
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
id
:
instanceId
,
companion
,
})
{
const
invokeCallback
=
({
id
,
name
,
params
,
keepAlive
,
})
=>
{
const
callback
=
callbacks
[
id
];
if
(
callback
)
{
...
...
@@ -188,6 +188,7 @@ function initProxyFunction(async, { package: pkg, class: cls, name: propOrMethod
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
companion
,
};
return
(...
args
)
=>
{
const
invokeArgs
=
shared
.
extend
({},
baseArgs
,
{
...
...
@@ -222,7 +223,7 @@ function initUtsProxyClass({ package: pkg, class: cls, methods, props, staticPro
package
:
pkg
,
class
:
cls
,
};
return
class
Proxy
Class
{
const
ProxyClass
=
class
Uts
Class
{
constructor
(...
params
)
{
const
target
=
{};
// 初始化实例 ID
...
...
@@ -237,24 +238,33 @@ function initUtsProxyClass({ package: pkg, class: cls, methods, props, staticPro
name
,
},
baseOptions
));
}
else
if
(
shared
.
hasOwn
(
staticMethods
,
name
))
{
// 静态方法
target
[
name
]
=
initUtsStaticMethod
(
!!
staticMethods
[
name
].
async
,
shared
.
extend
({
name
,
companion
:
true
},
baseOptions
));
}
else
if
(
props
.
includes
(
name
))
{
// 实例属性
return
invokePropGetter
({
id
:
instanceId
,
name
:
name
});
}
else
if
(
staticProps
.
includes
(
name
))
{
// 静态属性
return
invokePropGetter
(
shared
.
extend
({
name
:
name
,
companion
:
true
},
baseOptions
));
}
}
return
target
[
name
];
},
});
}
};
const
staticMethodCache
=
{};
return
new
Proxy
(
ProxyClass
,
{
get
(
target
,
name
,
receiver
)
{
if
(
shared
.
hasOwn
(
staticMethods
,
name
))
{
if
(
!
staticMethodCache
[
name
])
{
// 静态方法
staticMethodCache
[
name
]
=
initUtsStaticMethod
(
!!
staticMethods
[
name
].
async
,
shared
.
extend
({
name
,
companion
:
true
},
baseOptions
));
}
return
staticMethodCache
[
name
];
}
if
(
staticProps
.
includes
(
name
))
{
// 静态属性
return
invokePropGetter
(
shared
.
extend
({
name
:
name
,
companion
:
true
},
baseOptions
));
}
return
Reflect
.
get
(
target
,
name
,
receiver
);
},
});
}
exports
.
getCurrentSubNVue
=
getCurrentSubNVue
;
...
...
packages/uni-app/dist/uni-app.es.js
浏览文件 @
6eae1e9f
...
...
@@ -137,7 +137,7 @@ function resolveSyncResult(res) {
function
invokePropGetter
(
args
)
{
return
resolveSyncResult
(
getProxy
().
invokeSync
(
args
,
()
=>
{
}));
}
function
initProxyFunction
(
async
,
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
id
:
instanceId
,
})
{
function
initProxyFunction
(
async
,
{
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
id
:
instanceId
,
companion
,
})
{
const
invokeCallback
=
({
id
,
name
,
params
,
keepAlive
,
})
=>
{
const
callback
=
callbacks
[
id
];
if
(
callback
)
{
...
...
@@ -156,6 +156,7 @@ function initProxyFunction(async, { package: pkg, class: cls, name: propOrMethod
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
companion
,
};
return
(...
args
)
=>
{
const
invokeArgs
=
extend
({},
baseArgs
,
{
...
...
@@ -190,7 +191,7 @@ function initUtsProxyClass({ package: pkg, class: cls, methods, props, staticPro
package
:
pkg
,
class
:
cls
,
};
return
class
Proxy
Class
{
const
ProxyClass
=
class
Uts
Class
{
constructor
(...
params
)
{
const
target
=
{};
// 初始化实例 ID
...
...
@@ -205,24 +206,33 @@ function initUtsProxyClass({ package: pkg, class: cls, methods, props, staticPro
name
,
},
baseOptions
));
}
else
if
(
hasOwn
(
staticMethods
,
name
))
{
// 静态方法
target
[
name
]
=
initUtsStaticMethod
(
!!
staticMethods
[
name
].
async
,
extend
({
name
,
companion
:
true
},
baseOptions
));
}
else
if
(
props
.
includes
(
name
))
{
// 实例属性
return
invokePropGetter
({
id
:
instanceId
,
name
:
name
});
}
else
if
(
staticProps
.
includes
(
name
))
{
// 静态属性
return
invokePropGetter
(
extend
({
name
:
name
,
companion
:
true
},
baseOptions
));
}
}
return
target
[
name
];
},
});
}
};
const
staticMethodCache
=
{};
return
new
Proxy
(
ProxyClass
,
{
get
(
target
,
name
,
receiver
)
{
if
(
hasOwn
(
staticMethods
,
name
))
{
if
(
!
staticMethodCache
[
name
])
{
// 静态方法
staticMethodCache
[
name
]
=
initUtsStaticMethod
(
!!
staticMethods
[
name
].
async
,
extend
({
name
,
companion
:
true
},
baseOptions
));
}
return
staticMethodCache
[
name
];
}
if
(
staticProps
.
includes
(
name
))
{
// 静态属性
return
invokePropGetter
(
extend
({
name
:
name
,
companion
:
true
},
baseOptions
));
}
return
Reflect
.
get
(
target
,
name
,
receiver
);
},
});
}
export
{
getCurrentSubNVue
,
getSsrGlobalData
,
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/uts.ts
浏览文件 @
6eae1e9f
...
...
@@ -133,6 +133,10 @@ interface InitProxyFunctionOptions {
* 属性名或方法名
*/
name
:
string
/**
* 是否伴生对象
*/
companion
?:
boolean
/**
* 实例 ID
*/
...
...
@@ -146,6 +150,7 @@ function initProxyFunction(
class
:
cls
,
name
:
propOrMethod
,
id
:
instanceId
,
companion
,
}:
InitProxyFunctionOptions
)
{
const
invokeCallback
=
({
...
...
@@ -170,6 +175,7 @@ function initProxyFunction(
package
:
pkg
,
class
:
cls
,
name
:
propOrMethod
,
companion
,
}
return
(...
args
:
unknown
[])
=>
{
const
invokeArgs
=
extend
({},
baseArgs
,
{
...
...
@@ -198,6 +204,7 @@ function initUtsStaticMethod(async: boolean, opts: ProxyBaseOptions) {
return
initProxyFunction
(
async
,
opts
)
}
export
const
initUtsProxyFunction
=
initUtsStaticMethod
export
function
initUtsProxyClass
({
package
:
pkg
,
class
:
cls
,
...
...
@@ -210,7 +217,7 @@ export function initUtsProxyClass({
package
:
pkg
,
class
:
cls
,
}
return
class
Proxy
Class
{
const
ProxyClass
=
class
Uts
Class
{
constructor
(...
params
:
unknown
[])
{
const
target
:
Record
<
string
,
Function
>
=
{}
// 初始化实例 ID
...
...
@@ -234,20 +241,9 @@ export function initUtsProxyClass({
baseOptions
)
)
}
else
if
(
hasOwn
(
staticMethods
,
name
))
{
// 静态方法
target
[
name
]
=
initUtsStaticMethod
(
!!
staticMethods
[
name
].
async
,
extend
({
name
,
companion
:
true
},
baseOptions
)
)
}
else
if
(
props
.
includes
(
name
as
string
))
{
// 实例属性
return
invokePropGetter
({
id
:
instanceId
,
name
:
name
as
string
})
}
else
if
(
staticProps
.
includes
(
name
as
string
))
{
// 静态属性
return
invokePropGetter
(
extend
({
name
:
name
as
string
,
companion
:
true
},
baseOptions
)
)
}
}
return
target
[
name
as
string
]
...
...
@@ -255,4 +251,26 @@ export function initUtsProxyClass({
})
}
}
const
staticMethodCache
:
Record
<
string
,
Function
>
=
{}
return
new
Proxy
(
ProxyClass
,
{
get
(
target
,
name
,
receiver
)
{
if
(
hasOwn
(
staticMethods
,
name
))
{
if
(
!
staticMethodCache
[
name
as
string
])
{
// 静态方法
staticMethodCache
[
name
]
=
initUtsStaticMethod
(
!!
staticMethods
[
name
].
async
,
extend
({
name
,
companion
:
true
},
baseOptions
)
)
}
return
staticMethodCache
[
name
]
}
if
(
staticProps
.
includes
(
name
as
string
))
{
// 静态属性
return
invokePropGetter
(
extend
({
name
:
name
as
string
,
companion
:
true
},
baseOptions
)
)
}
return
Reflect
.
get
(
target
,
name
,
receiver
)
},
})
}
packages/uts-darwin-arm64/uts.darwin-arm64.node
浏览文件 @
6eae1e9f
无法预览此类型文件
packages/uts-darwin-x64/uts.darwin-x64.node
浏览文件 @
6eae1e9f
无法预览此类型文件
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录