Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
a7ee91d8
U
uni-app
项目概览
DCloud
/
uni-app
13 天 前同步成功
通知
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看板
提交
a7ee91d8
编写于
1月 31, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): compiler
上级
952c8ad6
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
152 addition
and
104 deletion
+152
-104
packages/uni-app-plus/__tests__/uts.spec.ts
packages/uni-app-plus/__tests__/uts.spec.ts
+6
-6
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+16
-16
packages/uni-app-plus/src/service/api/index.ts
packages/uni-app-plus/src/service/api/index.ts
+5
-5
packages/uni-app-plus/src/service/api/plugin/uts.js
packages/uni-app-plus/src/service/api/plugin/uts.js
+12
-12
packages/uni-app-plus/src/service/api/plugin/uts.ts
packages/uni-app-plus/src/service/api/plugin/uts.ts
+11
-11
packages/uni-app-vite/src/plugins/uts.ts
packages/uni-app-vite/src/plugins/uts.ts
+8
-1
packages/uni-uts-v1/__tests__/__snapshots__/code.spec.ts.snap
...ages/uni-uts-v1/__tests__/__snapshots__/code.spec.ts.snap
+12
-14
packages/uni-uts-v1/src/code.ts
packages/uni-uts-v1/src/code.ts
+7
-7
packages/uni-uts-v1/src/encrypt.ts
packages/uni-uts-v1/src/encrypt.ts
+8
-5
packages/uni-uts-v1/src/index.ts
packages/uni-uts-v1/src/index.ts
+32
-23
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-musl/package.json
packages/uts-linux-x64-musl/package.json
+25
-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/package.json
packages/uts-win32-ia32-msvc/package.json
+1
-1
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
+0
-0
packages/uts/package.json
packages/uts/package.json
+2
-1
pnpm-lock.yaml
pnpm-lock.yaml
+5
-0
scripts/checkVersion.js
scripts/checkVersion.js
+2
-2
未找到文件。
packages/uni-app-plus/__tests__/uts.spec.ts
浏览文件 @
a7ee91d8
import
{
normalizeArg
,
initU
ts
ProxyFunction
,
initU
ts
ProxyClass
,
initU
TS
ProxyFunction
,
initU
TS
ProxyClass
,
}
from
'
../src/service/api/plugin/uts
'
describe
(
'
uts-module
'
,
()
=>
{
...
...
@@ -39,7 +39,7 @@ describe('uts-module', () => {
})
test
(
`initProxyFunction`
,
()
=>
{
;[
true
,
false
].
forEach
((
async
)
=>
{
const
preparePermission
=
initU
ts
ProxyFunction
(
async
,
{
const
preparePermission
=
initU
TS
ProxyFunction
(
async
,
{
package
:
'
uts.modules.TestPlugin
'
,
class
:
'
TestKt
'
,
name
:
'
preparePermission
'
,
...
...
@@ -73,14 +73,14 @@ describe('uts-module', () => {
const
errMsg
=
'
xx插件编译失败,无法使用
'
expect
(
initU
ts
ProxyFunction
(
async
,
{
initU
TS
ProxyFunction
(
async
,
{
errMsg
,
}
as
any
)
).
toThrowError
(
errMsg
)
})
})
test
(
`initProxyClass`
,
()
=>
{
const
WifiManager
=
initU
ts
ProxyClass
({
const
WifiManager
=
initU
TS
ProxyClass
({
package
:
'
uni.modules.TestPlugin
'
,
class
:
'
WifiManager
'
,
constructor
:
{
...
...
@@ -110,7 +110,7 @@ describe('uts-module', () => {
WifiManager
.
staticPreparePermission
(
1
)
const
errMsg
=
'
xx插件编译失败,无法使用
'
const
WifiManagerError
=
initU
ts
ProxyClass
({
const
WifiManagerError
=
initU
TS
ProxyClass
({
errMsg
,
staticMethods
:
{
staticPreparePermission
:
{
...
...
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
a7ee91d8
...
...
@@ -17267,7 +17267,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() {
...
...
@@ -17338,7 +17338,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;
...
...
@@ -17346,14 +17346,14 @@ function initUtsStaticMethod(async, opts) {
}
return initProxyFunction(async, opts, 0);
}
const initU
tsProxyFunction = initUts
StaticMethod;
function initU
ts
ProxyClass({ package: pkg, class: cls, constructor: { params: constructorParams }, methods, props, staticProps, staticMethods, errMsg, }) {
const initU
TSProxyFunction = initUTS
StaticMethod;
function initU
TS
ProxyClass({ package: pkg, class: cls, constructor: { params: constructorParams }, methods, props, staticProps, staticMethods, errMsg, }) {
const baseOptions = {
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);
...
...
@@ -17370,7 +17370,7 @@ function initUtsProxyClass({ package: pkg, class: cls, constructor: { params: co
//实例方法
if (hasOwn$1(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);
...
...
@@ -17396,7 +17396,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];
}
...
...
@@ -17408,19 +17408,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 '';
}
...
...
@@ -19562,11 +19562,11 @@ var uni$1 = {
onHostEventReceive: onHostEventReceive,
onNativeEventReceive: onNativeEventReceive,
__log__: __log__,
initU
tsProxyClass: initUts
ProxyClass,
initU
tsProxyFunction: initUts
ProxyFunction,
initU
tsIndexClassName: initUts
IndexClassName,
initU
tsClassName: initUts
ClassName,
initU
tsPackageName: initUts
PackageName,
initU
TSProxyClass: initUTS
ProxyClass,
initU
TSProxyFunction: initUTS
ProxyFunction,
initU
TSIndexClassName: initUTS
IndexClassName,
initU
TSClassName: initUTS
ClassName,
initU
TSPackageName: initUTS
PackageName,
requireUTSPlugin: requireUTSPlugin,
registerUTSPlugin: registerUTSPlugin,
navigateTo: navigateTo,
...
...
packages/uni-app-plus/src/service/api/index.ts
浏览文件 @
a7ee91d8
...
...
@@ -85,11 +85,11 @@ export {
export
{
__log__
}
from
'
./plugin/log
'
// 内部使用
export
{
initU
ts
ProxyClass
,
initU
ts
ProxyFunction
,
initU
ts
IndexClassName
,
initU
ts
ClassName
,
initU
ts
PackageName
,
initU
TS
ProxyClass
,
initU
TS
ProxyFunction
,
initU
TS
IndexClassName
,
initU
TS
ClassName
,
initU
TS
PackageName
,
requireUTSPlugin
,
registerUTSPlugin
,
}
from
'
./plugin/uts
'
...
...
packages/uni-app-plus/src/service/api/plugin/uts.js
浏览文件 @
a7ee91d8
...
...
@@ -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
()
{
...
...
@@ -89,7 +89,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 +97,14 @@ function initUtsStaticMethod(async, opts) {
}
return
initProxyFunction
(
async
,
opts
,
0
);
}
const
initU
tsProxyFunction
=
initUts
StaticMethod
;
function
initU
ts
ProxyClass
({
package
:
pkg
,
class
:
cls
,
constructor
:
{
params
:
constructorParams
},
methods
,
props
,
staticProps
,
staticMethods
,
errMsg
,
})
{
const
initU
TSProxyFunction
=
initUTS
StaticMethod
;
function
initU
TS
ProxyClass
({
package
:
pkg
,
class
:
cls
,
constructor
:
{
params
:
constructorParams
},
methods
,
props
,
staticProps
,
staticMethods
,
errMsg
,
})
{
const
baseOptions
=
{
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 +121,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
);
...
...
@@ -147,7 +147,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 +159,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 +198,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
};
packages/uni-app-plus/src/service/api/plugin/uts.ts
浏览文件 @
a7ee91d8
...
...
@@ -20,7 +20,7 @@ export function normalizeArg(arg: unknown) {
return
arg
}
function
initU
ts
InstanceMethod
(
function
initU
TS
InstanceMethod
(
async
:
boolean
,
opts
:
ProxyFunctionOptions
,
instanceId
:
number
...
...
@@ -248,7 +248,7 @@ function initProxyFunction(
}
}
function
initU
ts
StaticMethod
(
async
:
boolean
,
opts
:
ProxyFunctionOptions
)
{
function
initU
TS
StaticMethod
(
async
:
boolean
,
opts
:
ProxyFunctionOptions
)
{
if
(
opts
.
main
&&
!
opts
.
method
)
{
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
os
.
name
===
'
iOS
'
)
{
opts
.
method
=
'
s_
'
+
opts
.
name
...
...
@@ -257,9 +257,9 @@ function initUtsStaticMethod(async: boolean, opts: ProxyFunctionOptions) {
return
initProxyFunction
(
async
,
opts
,
0
)
}
export
const
initU
tsProxyFunction
=
initUts
StaticMethod
export
const
initU
TSProxyFunction
=
initUTS
StaticMethod
export
function
initU
ts
ProxyClass
({
export
function
initU
TS
ProxyClass
({
package
:
pkg
,
class
:
cls
,
constructor
:
{
params
:
constructorParams
},
...
...
@@ -274,7 +274,7 @@ export function initUtsProxyClass({
class
:
cls
,
errMsg
,
}
const
ProxyClass
=
class
U
ts
Class
{
const
ProxyClass
=
class
U
TS
Class
{
constructor
(...
params
:
unknown
[])
{
if
(
errMsg
)
{
throw
new
Error
(
errMsg
)
...
...
@@ -295,7 +295,7 @@ export function initUtsProxyClass({
//实例方法
if
(
hasOwn
(
methods
,
name
))
{
const
{
async
,
params
}
=
methods
[
name
]
target
[
name
]
=
initU
ts
InstanceMethod
(
target
[
name
]
=
initU
TS
InstanceMethod
(
!!
async
,
extend
(
{
...
...
@@ -327,7 +327,7 @@ export function initUtsProxyClass({
if
(
!
staticMethodCache
[
name
as
string
])
{
const
{
async
,
params
}
=
staticMethods
[
name
]
// 静态方法
staticMethodCache
[
name
]
=
initU
ts
StaticMethod
(
staticMethodCache
[
name
]
=
initU
TS
StaticMethod
(
!!
async
,
extend
({
name
,
companion
:
true
,
params
},
baseOptions
)
)
...
...
@@ -345,28 +345,28 @@ export function initUtsProxyClass({
})
}
export
function
initU
ts
PackageName
(
name
:
string
,
is_uni_modules
:
boolean
)
{
export
function
initU
TS
PackageName
(
name
:
string
,
is_uni_modules
:
boolean
)
{
if
(
typeof
plus
!==
'
undefined
'
&&
plus
.
os
.
name
===
'
Android
'
)
{
return
'
uts.sdk.
'
+
(
is_uni_modules
?
'
modules.
'
:
''
)
+
name
}
return
''
}
export
function
initU
ts
IndexClassName
(
export
function
initU
TS
IndexClassName
(
moduleName
:
string
,
is_uni_modules
:
boolean
)
{
if
(
typeof
plus
===
'
undefined
'
)
{
return
''
}
return
initU
ts
ClassName
(
return
initU
TS
ClassName
(
moduleName
,
plus
.
os
.
name
===
'
iOS
'
?
'
IndexSwift
'
:
'
IndexKt
'
,
is_uni_modules
)
}
export
function
initU
ts
ClassName
(
export
function
initU
TS
ClassName
(
moduleName
:
string
,
className
:
string
,
is_uni_modules
:
boolean
...
...
packages/uni-app-vite/src/plugins/uts.ts
浏览文件 @
a7ee91d8
...
...
@@ -14,7 +14,12 @@ function isUTSProxy(id: string) {
const
utsModuleCaches
=
new
Map
<
string
,
()
=>
Promise
<
void
|
{
code
:
string
;
deps
:
string
[];
encrypt
:
boolean
}
>
()
=>
Promise
<
void
|
{
code
:
string
deps
:
string
[]
encrypt
:
boolean
meta
?:
any
}
>
>
()
export
function
uniUtsV1Plugin
():
Plugin
{
return
{
...
...
@@ -61,6 +66,7 @@ export function uniUtsV1Plugin(): Plugin {
return
{
code
:
result
.
code
,
syntheticNamedExports
:
result
.
encrypt
,
meta
:
result
.
meta
,
}
}
})
...
...
@@ -77,6 +83,7 @@ export function uniUtsV1Plugin(): Plugin {
return
{
code
:
result
.
code
,
syntheticNamedExports
:
result
.
encrypt
,
meta
:
result
.
meta
,
}
}
},
...
...
packages/uni-uts-v1/__tests__/__snapshots__/code.spec.ts.snap
浏览文件 @
a7ee91d8
...
...
@@ -2,35 +2,33 @@
exports[`code genProxyCode 1`] = `
"
import { initUtsProxyClass, initUtsProxyFunction, initUtsPackageName, initUtsIndexClassName, initUtsClassName } from '@dcloudio/uni-app'
// const { initUtsProxyClass, initUtsProxyFunction, initUtsPackageName, initUtsIndexClassName, initUtsClassName } = uni
const { initUTSProxyClass, initUTSProxyFunction, initUTSPackageName, initUTSIndexClassName, initUTSClassName } = uni
const name = 'test-uts'
const errMsg = \`\`
const is_uni_modules = false
const pkg = initU
ts
PackageName(name, is_uni_modules)
const cls = initU
ts
IndexClassName(name, is_uni_modules)
const pkg = initU
TS
PackageName(name, is_uni_modules)
const cls = initU
TS
IndexClassName(name, is_uni_modules)
export const onMemoryWarning = initU
ts
ProxyFunction(false, { errMsg, main: true, package: pkg, class: cls, name: 'onMemoryWarning', params: [{"name":"callback","type":"UTSCallback"}]})
export const offMemoryWarning = initU
ts
ProxyFunction(false, { errMsg, main: true, package: pkg, class: cls, name: 'offMemoryWarning', params: [{"name":"callback","type":"UTSCallback","default":"UTSNull"}]})
export default initU
tsProxyClass(Object.assign({ errMsg, package: pkg, class: initUts
ClassName(name, 'User', is_uni_modules) }, {"constructor":{"params":[]},"methods":{},"staticMethods":{},"props":[],"staticProps":[]} ))
export const onMemoryWarning = initU
TS
ProxyFunction(false, { errMsg, main: true, package: pkg, class: cls, name: 'onMemoryWarning', params: [{"name":"callback","type":"UTSCallback"}]})
export const offMemoryWarning = initU
TS
ProxyFunction(false, { errMsg, main: true, package: pkg, class: cls, name: 'offMemoryWarning', params: [{"name":"callback","type":"UTSCallback","default":"UTSNull"}]})
export default initU
TSProxyClass(Object.assign({ errMsg, package: pkg, class: initUTS
ClassName(name, 'User', is_uni_modules) }, {"constructor":{"params":[]},"methods":{},"staticMethods":{},"props":[],"staticProps":[]} ))
export const a = 1
"
`;
exports[`code genProxyCode cjs 1`] = `
"
import { initUtsProxyClass, initUtsProxyFunction, initUtsPackageName, initUtsIndexClassName, initUtsClassName } from '@dcloudio/uni-app'
// const { initUtsProxyClass, initUtsProxyFunction, initUtsPackageName, initUtsIndexClassName, initUtsClassName } = uni
const { initUTSProxyClass, initUTSProxyFunction, initUTSPackageName, initUTSIndexClassName, initUTSClassName } = uni
const name = 'test-uts'
const errMsg = \`\`
const is_uni_modules = false
const pkg = initU
ts
PackageName(name, is_uni_modules)
const cls = initU
ts
IndexClassName(name, is_uni_modules)
const pkg = initU
TS
PackageName(name, is_uni_modules)
const cls = initU
TS
IndexClassName(name, is_uni_modules)
const exports = {}
exports.onMemoryWarning = initU
ts
ProxyFunction(false, { errMsg, main: true, package: pkg, class: cls, name: 'onMemoryWarning', params: [{"name":"callback","type":"UTSCallback"}]})
exports.offMemoryWarning = initU
ts
ProxyFunction(false, { errMsg, main: true, package: pkg, class: cls, name: 'offMemoryWarning', params: [{"name":"callback","type":"UTSCallback","default":"UTSNull"}]})
exports.default = initU
tsProxyClass(Object.assign({ errMsg, package: pkg, class: initUts
ClassName(name, 'User', is_uni_modules) }, {"constructor":{"params":[]},"methods":{},"staticMethods":{},"props":[],"staticProps":[]} ))
exports.onMemoryWarning = initU
TS
ProxyFunction(false, { errMsg, main: true, package: pkg, class: cls, name: 'onMemoryWarning', params: [{"name":"callback","type":"UTSCallback"}]})
exports.offMemoryWarning = initU
TS
ProxyFunction(false, { errMsg, main: true, package: pkg, class: cls, name: 'offMemoryWarning', params: [{"name":"callback","type":"UTSCallback","default":"UTSNull"}]})
exports.default = initU
TSProxyClass(Object.assign({ errMsg, package: pkg, class: initUTS
ClassName(name, 'User', is_uni_modules) }, {"constructor":{"params":[]},"methods":{},"staticMethods":{},"props":[],"staticProps":[]} ))
const a = 1
exports.a = a
uni.registerUTSPlugin('utssdk/test-uts', exports)
...
...
packages/uni-uts-v1/src/code.ts
浏览文件 @
a7ee91d8
...
...
@@ -41,12 +41,12 @@ export async function genProxyCode(
)
{
const
{
name
,
is_uni_modules
,
format
}
=
options
return
`
const { initU
tsProxyClass, initUtsProxyFunction, initUtsPackageName, initUtsIndexClassName, initUts
ClassName } = uni
const { initU
TSProxyClass, initUTSProxyFunction, initUTSPackageName, initUTSIndexClassName, initUTS
ClassName } = uni
const name = '
${
name
}
'
const errMsg =
\`
${
ERR_MSG_PLACEHOLDER
}
\`
const is_uni_modules =
${
is_uni_modules
}
const pkg = initU
ts
PackageName(name, is_uni_modules)
const cls = initU
ts
IndexClassName(name, is_uni_modules)
const pkg = initU
TS
PackageName(name, is_uni_modules)
const cls = initU
TS
IndexClassName(name, is_uni_modules)
${
genComponentsCode
(
options
.
androidComponents
||
{},
options
.
iosComponents
||
{}
...
...
@@ -129,7 +129,7 @@ function genModuleCode(
if
(
decl
.
type
===
'
Class
'
)
{
if
(
decl
.
isDefault
)
{
codes
.
push
(
`
${
exportDefault
}
initU
tsProxyClass(Object.assign({ errMsg, package: pkg, class: initUts
ClassName(name, '
${
`
${
exportDefault
}
initU
TSProxyClass(Object.assign({ errMsg, package: pkg, class: initUTS
ClassName(name, '
${
decl
.
cls
}
', is_uni_modules) },
${
JSON
.
stringify
(
decl
.
options
)}
))`
)
...
...
@@ -137,7 +137,7 @@ function genModuleCode(
codes
.
push
(
`
${
exportConst
}${
decl
.
cls
}
= initU
tsProxyClass(Object.assign({ errMsg, package: pkg, class: initUts
ClassName(name, '
${
}
= initU
TSProxyClass(Object.assign({ errMsg, package: pkg, class: initUTS
ClassName(name, '
${
decl
.
cls
}
', is_uni_modules) },
${
JSON
.
stringify
(
decl
.
options
)}
))`
)
...
...
@@ -145,7 +145,7 @@ function genModuleCode(
}
else
if
(
decl
.
type
===
'
FunctionDeclaration
'
)
{
if
(
decl
.
isDefault
)
{
codes
.
push
(
`
${
exportDefault
}
nitUts
ProxyFunction(
${
`
${
exportDefault
}
initUTS
ProxyFunction(
${
decl
.
async
}
, { errMsg, main: true, package: pkg, class: cls, name: '
${
decl
.
method
...
...
@@ -153,7 +153,7 @@ function genModuleCode(
)
}
else
{
codes
.
push
(
`
${
exportConst
}${
decl
.
method
}
= initU
ts
ProxyFunction(
${
`
${
exportConst
}${
decl
.
method
}
= initU
TS
ProxyFunction(
${
decl
.
async
}
, { errMsg, main: true, package: pkg, class: cls, name: '
${
decl
.
method
...
...
packages/uni-uts-v1/src/encrypt.ts
浏览文件 @
a7ee91d8
...
...
@@ -12,16 +12,18 @@ export async function compileEncrypt(pluginDir: string) {
const
outputDir
=
process
.
env
.
UNI_OUTPUT_DIR
const
utsPlatform
=
process
.
env
.
UNI_UTS_PLATFORM
as
APP_PLATFORM
const
pluginRelativeDir
=
relative
(
inputDir
,
pluginDir
)
const
code
=
`
Object.defineProperty(exports, '__esModule', { value: true })
module.exports = uni.requireUTSPlugin('
${
normalizePath
(
pluginRelativeDir
)}
')
`
if
(
process
.
env
.
NODE_ENV
!==
'
development
'
)
{
// 复制插件目录
fs
.
copySync
(
pluginDir
,
join
(
outputDir
,
pluginRelativeDir
))
return
{
code
:
`
Object.defineProperty(exports, '__esModule', { value: true })
module.exports = uni.requireUTSPlugin('
${
normalizePath
(
pluginRelativeDir
)}
')
`
,
code
,
deps
:
[]
as
string
[],
encrypt
:
true
,
meta
:
{
commonjs
:
{
isCommonJS
:
true
}
},
}
}
// 读取缓存目录的 js code
...
...
@@ -37,9 +39,10 @@ module.exports = uni.requireUTSPlugin('${normalizePath(pluginRelativeDir)}')
)
}
return
{
code
:
fs
.
readFileSync
(
indexJsPath
,
'
utf-8
'
),
code
:
fs
.
readFileSync
(
indexJsPath
,
'
utf-8
'
)
+
code
,
deps
:
[]
as
string
[],
encrypt
:
true
,
meta
:
{
commonjs
:
{
isCommonJS
:
true
}
},
}
}
...
...
packages/uni-uts-v1/src/index.ts
浏览文件 @
a7ee91d8
...
...
@@ -69,7 +69,29 @@ function warn(msg: string) {
console
.
warn
(
`提示:
${
msg
}
`
)
}
export
async
function
compile
(
pluginDir
:
string
)
{
export
interface
CompileResult
{
code
:
string
deps
:
string
[]
encrypt
:
boolean
meta
?:
any
}
function
createResult
(
errMsg
:
string
,
code
:
string
,
deps
:
string
[]
):
CompileResult
{
return
{
code
:
parseErrMsg
(
code
,
errMsg
),
deps
,
encrypt
:
false
,
meta
:
{},
}
}
export
async
function
compile
(
pluginDir
:
string
):
Promise
<
CompileResult
|
void
>
{
const
pkg
=
resolvePackage
(
pluginDir
)
if
(
!
pkg
)
{
return
...
...
@@ -176,20 +198,12 @@ export async function compile(pluginDir: string) {
if
(
utsPlatform
===
'
app-ios
'
)
{
if
(
isWindows
)
{
process
.
env
.
UNI_UTS_TIPS
=
`iOS手机在windows上真机运行时uts插件代码修改需提交云端打包自定义基座才能生效`
return
{
code
:
parseErrMsg
(
code
,
errMsg
),
deps
,
encrypt
:
false
,
}
return
createResult
(
errMsg
,
code
,
deps
)
}
// ios 模拟器不支持
if
(
process
.
env
.
HX_RUN_DEVICE_TYPE
===
'
ios_simulator
'
)
{
process
.
env
.
UNI_UTS_TIPS
=
`iOS手机在模拟器运行暂不支持uts插件,如需调用uts插件请使用自定义基座`
return
{
code
:
parseErrMsg
(
code
,
compileErrMsg
(
pkg
.
id
)),
deps
,
encrypt
:
false
,
}
return
createResult
(
compileErrMsg
(
pkg
.
id
),
code
,
deps
)
}
}
if
(
utsPlatform
===
'
app-android
'
||
utsPlatform
===
'
app-ios
'
)
{
...
...
@@ -250,13 +264,12 @@ export async function compile(pluginDir: string) {
if
(
versionTips
)
{
warn
(
versionTips
)
}
return
{
code
:
parseErrMsg
(
code
,
errMsg
),
// 所有文件加入依赖
deps
:
res
.
files
.
map
((
name
)
=>
join
(
pluginDir
,
name
)),
encrypt
:
false
,
}
// 所有文件加入依赖
return
createResult
(
errMsg
,
code
,
res
.
files
.
map
((
name
)
=>
join
(
pluginDir
,
name
))
)
}
}
let
filename
=
...
...
@@ -371,11 +384,7 @@ export async function compile(pluginDir: string) {
}
}
}
return
{
code
:
parseErrMsg
(
code
,
errMsg
),
deps
,
encrypt
:
false
,
}
return
createResult
(
errMsg
,
code
,
deps
)
}
function
getCompiler
(
type
:
'
kotlin
'
|
'
swift
'
)
{
...
...
packages/uts-darwin-arm64/uts.darwin-arm64.node
浏览文件 @
a7ee91d8
无法预览此类型文件
packages/uts-darwin-x64/uts.darwin-x64.node
浏览文件 @
a7ee91d8
无法预览此类型文件
packages/uts-linux-x64-musl/package.json
0 → 100644
浏览文件 @
a7ee91d8
{
"name"
:
"@dcloudio/uts-linux-x64-musl"
,
"version"
:
"3.0.0-alpha-3070020230117001"
,
"os"
:
[
"linux"
],
"cpu"
:
[
"x64"
],
"main"
:
"uts.linux-x64-musl.node"
,
"files"
:
[
"uts.linux-x64-musl.node"
],
"libc"
:
[
"musl"
],
"engines"
:
{
"node"
:
">=10"
},
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git+https://github.com/dcloudio/uni-app.git"
,
"directory"
:
"packages/uts-linux-x64-musl"
}
}
\ No newline at end of file
packages/uts-linux-x64-musl/uts.linux-x64-musl.node
0 → 100755
浏览文件 @
a7ee91d8
文件已添加
packages/uts-win32-ia32-msvc/package.json
浏览文件 @
a7ee91d8
...
...
@@ -17,6 +17,6 @@
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git+https://github.com/dcloudio/uni-app.git"
,
"directory"
:
"packages/uts
.
win32-ia32-msvc"
"directory"
:
"packages/uts
-
win32-ia32-msvc"
}
}
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
100644 → 100755
浏览文件 @
a7ee91d8
无法预览此类型文件
packages/uts/package.json
浏览文件 @
a7ee91d8
...
...
@@ -16,7 +16,8 @@
"optionalDependencies"
:
{
"@dcloudio/uts-darwin-arm64"
:
"3.0.0-alpha-3070020230117001"
,
"@dcloudio/uts-darwin-x64"
:
"3.0.0-alpha-3070020230117001"
,
"@dcloudio/uts-linux-x64-musl"
:
"3.0.0-alpha-3070020230117001"
,
"@dcloudio/uts-win32-ia32-msvc"
:
"3.0.0-alpha-3070020230117001"
,
"@dcloudio/uts-win32-x64-msvc"
:
"3.0.0-alpha-3070020230117001"
}
}
}
\ No newline at end of file
pnpm-lock.yaml
浏览文件 @
a7ee91d8
...
...
@@ -880,11 +880,13 @@ importers:
specifiers
:
'
@dcloudio/uts-darwin-arm64'
:
3.0.0-alpha-3070020230117001
'
@dcloudio/uts-darwin-x64'
:
3.0.0-alpha-3070020230117001
'
@dcloudio/uts-linux-x64-musl'
:
3.0.0-alpha-3070020230117001
'
@dcloudio/uts-win32-ia32-msvc'
:
3.0.0-alpha-3070020230117001
'
@dcloudio/uts-win32-x64-msvc'
:
3.0.0-alpha-3070020230117001
optionalDependencies
:
'
@dcloudio/uts-darwin-arm64'
:
link:../uts-darwin-arm64
'
@dcloudio/uts-darwin-x64'
:
link:../uts-darwin-x64
'
@dcloudio/uts-linux-x64-musl'
:
link:../uts-linux-x64-musl
'
@dcloudio/uts-win32-ia32-msvc'
:
link:../uts-win32-ia32-msvc
'
@dcloudio/uts-win32-x64-msvc'
:
link:../uts-win32-x64-msvc
...
...
@@ -894,6 +896,9 @@ importers:
packages/uts-darwin-x64
:
specifiers
:
{}
packages/uts-linux-x64-musl
:
specifiers
:
{}
packages/uts-win32-ia32-msvc
:
specifiers
:
{}
...
...
scripts/checkVersion.js
浏览文件 @
a7ee91d8
...
...
@@ -37,7 +37,7 @@ const pkgs = {
latest
:
'
3.0.2
'
,
},
'
@dcloudio/types
'
:
{
latest
:
'
3.2.
7
'
,
latest
:
'
3.2.
10
'
,
},
autoprefixer
:
{
latest
:
'
10.4.13
'
,
...
...
@@ -46,7 +46,7 @@ const pkgs = {
latest
:
'
3.4.0
'
,
},
typescript
:
{
latest
:
'
4.9.
4
'
,
latest
:
'
4.9.
5
'
,
},
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录