Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
4434b3de
U
uni-app
项目概览
DCloud
/
uni-app
14 天 前同步成功
通知
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看板
提交
4434b3de
编写于
7月 12, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): update compiler
上级
1d401f16
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
156 addition
and
66 deletion
+156
-66
packages/uni-app-plus/dist/uni.runtime.esm.js
packages/uni-app-plus/dist/uni.runtime.esm.js
+16
-4
packages/uni-h5/dist/uni-h5.es.js
packages/uni-h5/dist/uni-h5.es.js
+16
-4
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/uts/src/index.ts
packages/uts/src/index.ts
+114
-57
packages/uts/src/utils.ts
packages/uts/src/utils.ts
+10
-1
未找到文件。
packages/uni-app-plus/dist/uni.runtime.esm.js
浏览文件 @
4434b3de
...
...
@@ -11611,17 +11611,29 @@ const GetLocationProtocol = {
};
const API_OPEN_LOCATION = 'openLocation';
const checkProps = (key, value) => {
if (value === undefined) {
return `${key} should not be empty.`;
}
if (typeof value !== 'number') {
let receivedType = typeof value;
receivedType = receivedType[0].toUpperCase() + receivedType.substring(1);
return `Expected Number, got ${receivedType} with value ${JSON.stringify(value)}.`;
}
};
const OpenLocationOptions = {
formatArgs: {
latitude(value, params) {
if (value !== 0 && !value) {
return 'latitude should not be empty.';
const checkedInfo = checkProps('latitude', value);
if (checkedInfo) {
return checkedInfo;
}
params.latitude = value;
},
longitude(value, params) {
if (value !== 0 && !value) {
return 'longitude should not be empty.';
const checkedInfo = checkProps('longitude', value);
if (checkedInfo) {
return checkedInfo;
}
params.longitude = value;
},
...
...
packages/uni-h5/dist/uni-h5.es.js
浏览文件 @
4434b3de
...
...
@@ -4835,17 +4835,29 @@ const GetLocationProtocol = {
altitude: Boolean
};
const API_OPEN_LOCATION = "openLocation";
const checkProps = (key, value) => {
if (value === void 0) {
return `${key} should not be empty.`;
}
if (typeof value !== "number") {
let receivedType = typeof value;
receivedType = receivedType[0].toUpperCase() + receivedType.substring(1);
return `Expected Number, got ${receivedType} with value ${JSON.stringify(value)}.`;
}
};
const OpenLocationOptions = {
formatArgs: {
latitude(value, params) {
if (value !== 0 && !value) {
return "latitude should not be empty.";
const checkedInfo = checkProps("latitude", value);
if (checkedInfo) {
return checkedInfo;
}
params.latitude = value;
},
longitude(value, params) {
if (value !== 0 && !value) {
return "longitude should not be empty.";
const checkedInfo = checkProps("longitude", value);
if (checkedInfo) {
return checkedInfo;
}
params.longitude = value;
},
...
...
packages/uts-darwin-arm64/uts.darwin-arm64.node
浏览文件 @
4434b3de
无法预览此类型文件
packages/uts-darwin-x64/uts.darwin-x64.node
浏览文件 @
4434b3de
无法预览此类型文件
packages/uts-win32-ia32-msvc/uts.win32-ia32-msvc.node
浏览文件 @
4434b3de
无法预览此类型文件
packages/uts-win32-x64-msvc/uts.win32-x64-msvc.node
浏览文件 @
4434b3de
无法预览此类型文件
packages/uts/src/index.ts
浏览文件 @
4434b3de
...
...
@@ -11,7 +11,13 @@ import type {
UtsOutputOptions
,
UtsResult
,
}
from
'
./types
'
import
{
printStartup
,
printUtsResult
,
printUtsResults
,
timeEnd
}
from
'
./utils
'
import
{
printDone
,
printStartup
,
printUtsResult
,
printUtsResults
,
timeEnd
,
}
from
'
./utils
'
export
enum
UtsTarget
{
KOTLIN
=
'
kotlin
'
,
...
...
@@ -124,18 +130,13 @@ function initOutputOptions(
}
}
function
watch
(
function
initOptions
(
target
:
UtsTarget
,
{
silent
,
input
:
{
dir
:
inputDir
,
extname
},
input
:
{
dir
:
inputDir
},
output
:
{
dir
:
outputDir
,
sourceMap
,
inlineSourcesContent
},
}:
ToOptions
)
{
fs
.
emptyDirSync
(
outputDir
)
extname
=
extname
||
EXTNAME
const
inputSrcDir
=
resolveSrcDir
(
target
,
inputDir
)
const
outputSrcDir
=
resolveSrcDir
(
target
,
outputDir
)
...
...
@@ -146,63 +147,97 @@ function watch(
sourceMap
,
!!
inlineSourcesContent
)
return
{
input
,
output
}
}
chokidar
.
watch
(
'
**/*
'
+
extname
,
{
cwd
:
inputSrcDir
,
ignored
:
[
'
**/*.d
'
+
extname
],
})
.
on
(
'
add
'
,
(
filename
)
=>
{
buildFile
(
target
,
path
.
resolve
(
inputSrcDir
,
filename
),
input
,
output
).
then
((
res
)
=>
{
!
silent
&&
printUtsResult
(
res
)
async
function
watch
(
target
:
UtsTarget
,
toOptions
:
ToOptions
)
{
fs
.
emptyDirSync
(
toOptions
.
output
.
dir
)
const
{
input
,
output
}
=
initOptions
(
target
,
toOptions
)
const
inputDir
=
toOptions
.
input
.
dir
const
outputDir
=
toOptions
.
output
.
dir
const
inputSrcDir
=
input
.
root
const
outputSrcDir
=
output
.
outDir
const
extname
=
toOptions
.
input
.
extname
||
EXTNAME
const
silent
=
!!
toOptions
.
silent
// 先完整编译后,再启用监听
doBuild
(
target
,
{
watch
:
true
,
input
,
output
,
inputDir
,
outputDir
,
inputSrcDir
,
outputSrcDir
,
extname
,
silent
,
}).
then
(()
=>
{
// TODO 监听动态添加的资源文件
chokidar
.
watch
(
'
**/*
'
+
extname
,
{
cwd
:
inputSrcDir
,
ignored
:
[
'
**/*.d
'
+
extname
],
ignoreInitial
:
true
,
})
})
.
on
(
'
change
'
,
(
filename
)
=>
{
buildFile
(
target
,
path
.
resolve
(
inputSrcDir
,
filename
),
input
,
output
).
then
((
res
)
=>
{
!
silent
&&
printUtsResult
(
res
)
.
on
(
'
add
'
,
(
filename
)
=>
{
buildFile
(
target
,
path
.
resolve
(
inputSrcDir
,
filename
),
input
,
output
).
then
((
res
)
=>
{
if
(
!
silent
)
{
printUtsResult
(
res
)
printDone
(
true
)
}
})
})
})
.
on
(
'
unlink
'
,
(
filename
)
=>
{
try
{
fs
.
unlinkSync
(
path
.
resolve
(
outputSrcDir
,
filename
))
}
catch
(
e
)
{}
})
.
on
(
'
ready
'
,
()
=>
{
copyAssets
(
UtsTarget
.
KOTLIN
,
inputDir
,
outputDir
,
extname
!
)
})
.
on
(
'
change
'
,
(
filename
)
=>
{
buildFile
(
target
,
path
.
resolve
(
inputSrcDir
,
filename
),
input
,
output
).
then
((
res
)
=>
{
if
(
!
silent
)
{
printUtsResult
(
res
)
printDone
(
true
)
}
})
})
.
on
(
'
unlink
'
,
(
filename
)
=>
{
try
{
fs
.
unlinkSync
(
path
.
resolve
(
outputSrcDir
,
filename
))
}
catch
(
e
)
{}
})
})
}
interface
DoBuildOptions
{
watch
:
boolean
silent
:
boolean
input
:
UtsInputOptions
output
:
UtsOutputOptions
inputDir
:
string
inputSrcDir
:
string
outputDir
:
string
outputSrcDir
:
string
extname
:
string
}
function
b
uild
(
function
doB
uild
(
target
:
UtsTarget
,
{
watch
,
silent
,
input
:
{
dir
:
inputDir
,
extname
},
output
:
{
dir
:
outputDir
,
sourceMap
,
inlineSourcesContent
},
}:
ToOptions
extname
,
inputDir
,
inputSrcDir
,
outputDir
,
input
,
output
,
}:
DoBuildOptions
)
{
fs
.
emptyDirSync
(
outputDir
)
extname
=
extname
||
EXTNAME
const
inputSrcDir
=
resolveSrcDir
(
target
,
inputDir
)
const
outputSrcDir
=
resolveSrcDir
(
target
,
outputDir
)
const
input
=
initInputOptions
(
target
,
inputSrcDir
)
const
output
=
initOutputOptions
(
target
,
outputSrcDir
,
sourceMap
,
!!
inlineSourcesContent
)
const
files
=
glob
.
sync
(
'
**/*
'
+
extname
,
{
absolute
:
true
,
cwd
:
inputSrcDir
,
...
...
@@ -224,11 +259,33 @@ function build(
)
})
.
then
((
res
)
=>
{
!
silent
&&
printUtsResults
(
res
)
!
silent
&&
printUtsResults
(
res
,
watch
)
return
res
})
}
function
build
(
target
:
UtsTarget
,
toOptions
:
ToOptions
)
{
fs
.
emptyDirSync
(
toOptions
.
output
.
dir
)
const
{
input
,
output
}
=
initOptions
(
target
,
toOptions
)
const
inputDir
=
toOptions
.
input
.
dir
const
outputDir
=
toOptions
.
output
.
dir
const
inputSrcDir
=
input
.
root
const
outputSrcDir
=
output
.
outDir
const
extname
=
toOptions
.
input
.
extname
||
EXTNAME
const
silent
=
!!
toOptions
.
silent
return
doBuild
(
target
,
{
watch
:
false
,
input
,
output
,
inputDir
,
outputDir
,
inputSrcDir
,
outputSrcDir
,
extname
,
silent
,
})
}
function
copyAssets
(
target
:
UtsTarget
,
inputDir
:
string
,
...
...
packages/uts/src/utils.ts
浏览文件 @
4434b3de
...
...
@@ -28,7 +28,15 @@ export function printStartup(target: UtsTarget, mode: string) {
)
}
export
function
printUtsResults
(
results
:
UtsResult
[])
{
export
function
printDone
(
watch
:
boolean
=
false
)
{
if
(
watch
)
{
console
.
log
(
`DONE Build complete. Watching for changes...`
)
}
else
{
console
.
log
(
`DONE Build complete.`
)
}
}
export
function
printUtsResults
(
results
:
UtsResult
[],
watch
:
boolean
=
false
)
{
let
longest
=
0
let
failed
:
UtsResult
[]
=
[]
let
transformed
:
UtsResult
[]
=
[]
...
...
@@ -61,6 +69,7 @@ export function printUtsResults(results: UtsResult[]) {
}
})
}
printDone
(
watch
)
}
export
function
printUtsResult
(
result
:
UtsResult
,
maxLength
=
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录