Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
44824123
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看板
提交
44824123
编写于
3月 10, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): compiler
上级
7b218e79
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
79 addition
and
49 deletion
+79
-49
packages/uni-cli-shared/src/messages/zh_CN.ts
packages/uni-cli-shared/src/messages/zh_CN.ts
+1
-1
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+9
-4
packages/uni-mp-weixin/dist/uni.compiler.js
packages/uni-mp-weixin/dist/uni.compiler.js
+2
-2
packages/uni-uts-v1/src/code.ts
packages/uni-uts-v1/src/code.ts
+63
-41
packages/uni-uts-v1/src/index.ts
packages/uni-uts-v1/src/index.ts
+1
-1
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-gnu/uts.linux-x64-gnu.node
packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node
+0
-0
packages/uts-linux-x64-musl/uts.linux-x64-musl.node
packages/uts-linux-x64-musl/uts.linux-x64-musl.node
+0
-0
packages/vite-plugin-uni/src/cli/action.ts
packages/vite-plugin-uni/src/cli/action.ts
+3
-0
未找到文件。
packages/uni-cli-shared/src/messages/zh_CN.ts
浏览文件 @
44824123
...
...
@@ -31,7 +31,7 @@ export default {
'
uts.android.compiler.server
'
:
'
项目使用了uts插件,正在安装 uts Android 运行扩展...
'
,
'
uts.ios.windows.tips
'
:
'
iOS手机在windows上
真机运行时uts插件代码修改需提交云端打包自定义基座才能生效
'
,
'
iOS手机在windows上
使用标准基座真机运行无法使用uts插件,如需使用uts插件请提交云端打包自定义基座
'
,
'
uts.ios.standard.tips
'
:
'
iOS手机在标准基座真机运行暂不支持uts插件,如需调用uts插件请使用自定义基座
'
,
}
as
const
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
44824123
...
...
@@ -67,7 +67,7 @@ function useI18n() {
let locale;
{
{
locale = window.localStorage && localStorage[UNI_STORAGE_LOCALE] || __uniConfig.locale || navigator.language;
locale =
navigator.cookieEnabled &&
window.localStorage && localStorage[UNI_STORAGE_LOCALE] || __uniConfig.locale || navigator.language;
}
}
i18n = initVueI18n(locale);
...
...
@@ -5086,7 +5086,7 @@ const setLocale = /* @__PURE__ */ defineSyncApi(
if (oldLocale !== locale) {
app.$vm.$locale = locale;
{
window.localStorage && (localStorage[UNI_STORAGE_LOCALE] = locale);
navigator.cookieEnabled &&
window.localStorage && (localStorage[UNI_STORAGE_LOCALE] = locale);
}
UniServiceJSBridge.invokeOnCallback(API_ON_LOCALE_CHANGE, { locale });
return true;
...
...
@@ -15622,7 +15622,7 @@ function setupApp(comp) {
const route = usePageRoute();
const onLaunch = () => {
injectAppHooks(instance2);
const { onLaunch: onLaunch2, onShow, onPageNotFound: onPageNotFound2 } = instance2;
const { onLaunch: onLaunch2, onShow, onPageNotFound: onPageNotFound2
, onError: onError2
} = instance2;
const path = route.path.slice(1);
const launchOptions2 = initLaunchOptions({
path: path || __uniRoutes[0].meta.route,
...
...
@@ -15642,6 +15642,11 @@ function setupApp(comp) {
onPageNotFound2 && invokeArrayFns$1(onPageNotFound2, pageNotFoundOptions);
}
}
if (onError2) {
instance2.appContext.config.errorHandler = (err) => {
invokeArrayFns$1(onError2, err);
};
}
};
if (__UNI_FEATURE_PAGES__) {
useRouter().isReady().then(onLaunch);
...
...
@@ -17915,7 +17920,7 @@ const makePhoneCall = /* @__PURE__ */ defineAsyncApi(
MakePhoneCallProtocol
);
const UUID_KEY = "__DC_STAT_UUID";
const storage =
window.localStorage || window.sessionStorage
|| {};
const storage =
navigator.cookieEnabled && (window.localStorage || window.sessionStorage)
|| {};
let deviceId;
function deviceId$1() {
deviceId = deviceId || storage[UUID_KEY];
...
...
packages/uni-mp-weixin/dist/uni.compiler.js
浏览文件 @
44824123
...
...
@@ -16,13 +16,13 @@ var uniad_app_json = function (appJson) {
}
if
(
!
appJson
.
plugins
[
'
uni-ad
'
])
{
appJson
.
plugins
[
'
uni-ad
'
]
=
{
version
:
'
1.
0
.1
'
,
version
:
'
1.
1
.1
'
,
provider
:
'
wxf72d316417b6767f
'
,
};
}
if
(
!
appJson
.
plugins
[
'
coral-adv
'
])
{
appJson
.
plugins
[
'
coral-adv
'
]
=
{
version
:
'
1.0.
9
'
,
version
:
'
1.0.
15
'
,
provider
:
'
wx0e203209e27b1e66
'
,
};
}
...
...
packages/uni-uts-v1/src/code.ts
浏览文件 @
44824123
import
fs
from
'
fs
'
import
path
from
'
path
'
import
{
camelize
,
capitalize
,
isArray
}
from
'
@vue/shared
'
import
{
camelize
,
capitalize
,
hasOwn
,
isArray
}
from
'
@vue/shared
'
import
type
{
ArrowFunctionExpression
,
...
...
@@ -16,6 +16,7 @@ import type {
Param
,
Span
,
TsFnParameter
,
TsType
,
TsTypeAnnotation
,
VariableDeclaration
,
VariableDeclarationKind
,
...
...
@@ -470,17 +471,19 @@ function parseAst(
switch
(
decl
.
type
)
{
case
'
FunctionDeclaration
'
:
decls
.
push
(
genFunctionDeclaration
(
decl
,
resolveTypeReferenceName
,
false
)
genFunctionDeclaration
(
types
,
decl
,
resolveTypeReferenceName
,
false
)
)
break
case
'
ClassDeclaration
'
:
decls
.
push
(
genClassDeclaration
(
decl
,
resolveTypeReferenceName
,
false
))
decls
.
push
(
genClassDeclaration
(
types
,
decl
,
resolveTypeReferenceName
,
false
)
)
break
case
'
VariableDeclaration
'
:
const
varDecl
=
genVariableDeclaration
(
types
,
decl
,
resolveTypeReferenceName
,
types
resolveTypeReferenceName
)
if
(
varDecl
)
{
decls
.
push
(
varDecl
)
...
...
@@ -492,12 +495,14 @@ function parseAst(
if
(
decl
.
type
===
'
ClassExpression
'
)
{
if
(
decl
.
identifier
)
{
// export default class test{}
decls
.
push
(
genClassDeclaration
(
decl
,
resolveTypeReferenceName
,
true
))
decls
.
push
(
genClassDeclaration
(
types
,
decl
,
resolveTypeReferenceName
,
true
)
)
}
}
else
if
(
decl
.
type
===
'
FunctionExpression
'
)
{
if
(
decl
.
identifier
)
{
decls
.
push
(
genFunctionDeclaration
(
decl
,
resolveTypeReferenceName
,
true
)
genFunctionDeclaration
(
types
,
decl
,
resolveTypeReferenceName
,
true
)
)
}
}
...
...
@@ -571,47 +576,57 @@ function resolveIdentifierDefaultValue(ident: Expression) {
return
null
}
function
resolveType
(
types
:
Types
,
typeAnnotation
:
TsType
,
resolveTypeReferenceName
:
ResolveTypeReferenceName
):
string
{
if
(
typeAnnotation
.
type
===
'
TsKeywordType
'
)
{
return
typeAnnotation
.
kind
}
else
if
(
typeAnnotation
.
type
===
'
TsFunctionType
'
)
{
return
'
UTSCallback
'
}
else
if
(
typeAnnotation
.
type
===
'
TsTypeReference
'
&&
typeAnnotation
.
typeName
.
type
===
'
Identifier
'
)
{
if
(
hasOwn
(
types
.
fn
,
typeAnnotation
.
typeName
.
value
))
{
return
'
UTSCallback
'
}
return
resolveTypeReferenceName
(
typeAnnotation
.
typeName
.
value
)
}
else
if
(
typeAnnotation
.
type
===
'
TsParenthesizedType
'
)
{
return
resolveType
(
types
,
typeAnnotation
.
typeAnnotation
,
resolveTypeReferenceName
)
}
else
if
(
typeAnnotation
.
type
===
'
TsUnionType
'
)
{
for
(
const
type
of
typeAnnotation
.
types
)
{
if
(
type
.
type
===
'
TsKeywordType
'
)
{
continue
}
return
resolveType
(
types
,
type
,
resolveTypeReferenceName
)
}
}
return
''
}
function
resolveIdentifierType
(
types
:
Types
,
ident
:
BindingIdentifier
,
resolveTypeReferenceName
:
ResolveTypeReferenceName
)
{
if
(
ident
.
typeAnnotation
)
{
const
{
typeAnnotation
}
=
ident
.
typeAnnotation
if
(
typeAnnotation
.
type
===
'
TsKeywordType
'
)
{
return
typeAnnotation
.
kind
}
else
if
(
typeAnnotation
.
type
===
'
TsFunctionType
'
)
{
return
'
UTSCallback
'
}
else
if
(
typeAnnotation
.
type
===
'
TsTypeReference
'
&&
typeAnnotation
.
typeName
.
type
===
'
Identifier
'
)
{
return
resolveTypeReferenceName
(
typeAnnotation
.
typeName
.
value
)
}
else
if
(
typeAnnotation
.
type
===
'
TsUnionType
'
)
{
if
(
typeAnnotation
.
types
.
length
===
2
)
{
const
[
type1
,
type2
]
=
typeAnnotation
.
types
if
(
type1
.
type
===
'
TsKeywordType
'
&&
type1
.
kind
===
'
null
'
)
{
if
(
type2
.
type
===
'
TsParenthesizedType
'
&&
type2
.
typeAnnotation
.
type
===
'
TsFunctionType
'
)
{
return
'
UTSCallback
'
}
}
if
(
type2
.
type
===
'
TsKeywordType
'
&&
type2
.
kind
===
'
null
'
)
{
if
(
type1
.
type
===
'
TsParenthesizedType
'
&&
type1
.
typeAnnotation
.
type
===
'
TsFunctionType
'
)
{
return
'
UTSCallback
'
}
}
}
}
return
resolveType
(
types
,
ident
.
typeAnnotation
.
typeAnnotation
,
resolveTypeReferenceName
)
}
return
''
}
function
resolveFunctionParams
(
types
:
Types
,
params
:
Param
[],
resolveTypeReferenceName
:
ResolveTypeReferenceName
)
{
...
...
@@ -621,6 +636,7 @@ function resolveFunctionParams(
result
.
push
({
name
:
pat
.
value
,
type
:
resolveIdentifierType
(
types
,
pat
as
BindingIdentifier
,
resolveTypeReferenceName
),
...
...
@@ -630,6 +646,7 @@ function resolveFunctionParams(
const
param
:
Parameter
=
{
name
:
pat
.
left
.
value
,
type
:
resolveIdentifierType
(
types
,
pat
.
left
as
BindingIdentifier
,
resolveTypeReferenceName
),
...
...
@@ -648,6 +665,7 @@ function resolveFunctionParams(
}
function
genFunctionDeclaration
(
types
:
Types
,
decl
:
FunctionDeclaration
|
FunctionExpression
,
resolveTypeReferenceName
:
ResolveTypeReferenceName
,
isDefault
:
boolean
=
false
,
...
...
@@ -656,13 +674,14 @@ function genFunctionDeclaration(
return
genProxyFunction
(
decl
.
identifier
!
.
value
,
decl
.
async
||
isReturnPromise
(
decl
.
returnType
),
resolveFunctionParams
(
decl
.
params
,
resolveTypeReferenceName
),
resolveFunctionParams
(
types
,
decl
.
params
,
resolveTypeReferenceName
),
isDefault
,
isVar
)
}
function
genClassDeclaration
(
types
:
Types
,
decl
:
ClassDeclaration
|
ClassExpression
,
resolveTypeReferenceName
:
ResolveTypeReferenceName
,
isDefault
:
boolean
=
false
...
...
@@ -679,6 +698,7 @@ function genClassDeclaration(
decl
.
body
.
forEach
((
item
)
=>
{
if
(
item
.
type
===
'
Constructor
'
)
{
constructor
.
params
=
resolveFunctionParams
(
types
,
item
.
params
as
Param
[],
resolveTypeReferenceName
)
...
...
@@ -689,6 +709,7 @@ function genClassDeclaration(
async
:
item
.
function
.
async
||
isReturnPromise
(
item
.
function
.
returnType
),
params
:
resolveFunctionParams
(
types
,
item
.
function
.
params
,
resolveTypeReferenceName
),
...
...
@@ -729,9 +750,9 @@ function genInitCode(expr: Expression) {
}
function
genVariableDeclaration
(
types
:
Types
,
decl
:
VariableDeclaration
,
resolveTypeReferenceName
:
ResolveTypeReferenceName
,
types
:
Types
resolveTypeReferenceName
:
ResolveTypeReferenceName
):
VariableDeclaration
|
ProxyFunctionDeclaration
|
undefined
{
// 目前仅支持 const 的 boolean,number,string
const
lits
=
[
'
BooleanLiteral
'
,
'
NumericLiteral
'
,
'
StringLiteral
'
]
...
...
@@ -775,6 +796,7 @@ function genVariableDeclaration(
}
}
return
genFunctionDeclaration
(
types
,
createFunctionDeclaration
(
id
.
value
,
init
,
params
),
resolveTypeReferenceName
,
false
,
...
...
packages/uni-uts-v1/src/index.ts
浏览文件 @
44824123
...
...
@@ -212,7 +212,7 @@ export async function compile(
// iOS windows 平台,标准基座不编译
if
(
utsPlatform
===
'
app-ios
'
)
{
if
(
isWindows
)
{
process
.
env
.
UNI_UTS_
TIPS
=
`iOS手机在windows上真机运行时uts插件代码修改需提交云端打包自定义基座才能生效
`
process
.
env
.
UNI_UTS_
ERRORS
=
`iOS手机在windows上使用标准基座真机运行无法使用uts插件,如需使用uts插件请提交云端打包自定义基座
`
return
createResult
(
outputPluginDir
,
errMsg
,
code
,
deps
,
meta
)
}
// ios 模拟器不支持
...
...
packages/uts-darwin-arm64/uts.darwin-arm64.node
浏览文件 @
44824123
无法预览此类型文件
packages/uts-darwin-x64/uts.darwin-x64.node
浏览文件 @
44824123
无法预览此类型文件
packages/uts-linux-x64-gnu/uts.linux-x64-gnu.node
浏览文件 @
44824123
无法预览此类型文件
packages/uts-linux-x64-musl/uts.linux-x64-musl.node
浏览文件 @
44824123
无法预览此类型文件
packages/vite-plugin-uni/src/cli/action.ts
浏览文件 @
44824123
...
...
@@ -54,6 +54,9 @@ export async function runDev(options: CliOptions & ServerOptions) {
isFirstEnd
=
false
output
(
'
log
'
,
M
[
'
dev.watching.end
'
])
printStartupDuration
(
createLogger
(
options
.
logLevel
),
false
)
if
(
process
.
env
.
UNI_UTS_ERRORS
)
{
console
.
error
(
process
.
env
.
UNI_UTS_ERRORS
)
}
if
(
process
.
env
.
UNI_UTS_TIPS
)
{
console
.
warn
(
process
.
env
.
UNI_UTS_TIPS
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录