Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yangkaifeng
uni-app
提交
febf317f
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,体验更适合开发者的 AI 搜索 >>
提交
febf317f
编写于
10月 20, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): compiler
上级
72ea400d
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
152 addition
and
45 deletion
+152
-45
.gitignore
.gitignore
+1
-1
packages/uni-app-vite/src/plugins/uts.ts
packages/uni-app-vite/src/plugins/uts.ts
+1
-1
packages/uni-cli-shared/package.json
packages/uni-cli-shared/package.json
+2
-2
packages/uni-cli-shared/src/resolve.ts
packages/uni-cli-shared/src/resolve.ts
+2
-2
packages/uni-uts-v1/package.json
packages/uni-uts-v1/package.json
+6
-7
packages/uni-uts-v1/src/code.ts
packages/uni-uts-v1/src/code.ts
+2
-3
packages/uni-uts-v1/src/index.ts
packages/uni-uts-v1/src/index.ts
+0
-0
packages/uni-uts-v1/src/kotlin.ts
packages/uni-uts-v1/src/kotlin.ts
+57
-16
packages/uni-uts-v1/src/shared.ts
packages/uni-uts-v1/src/shared.ts
+71
-0
packages/uni-uts-v1/src/swift.ts
packages/uni-uts-v1/src/swift.ts
+1
-1
packages/uni-uts-v1/src/utils.ts
packages/uni-uts-v1/src/utils.ts
+2
-2
packages/uni-uts-v1/tsconfig.json
packages/uni-uts-v1/tsconfig.json
+0
-0
packages/uni-uts-v1/types/types.d.ts
packages/uni-uts-v1/types/types.d.ts
+0
-0
packages/uni-uts/src/index.ts
packages/uni-uts/src/index.ts
+0
-1
pnpm-lock.yaml
pnpm-lock.yaml
+5
-7
scripts/utils.js
scripts/utils.js
+2
-2
未找到文件。
.gitignore
浏览文件 @
febf317f
...
...
@@ -8,7 +8,7 @@ packages/uni-mp-compiler/dist
packages/uni-nvue-styler/dist
packages/vite-plugin-uni/dist
packages/uts/dist
packages/uni-uts/dist
packages/uni-uts
-v1
/dist
.DS_Store
...
...
packages/uni-app-vite/src/plugins/uts.ts
浏览文件 @
febf317f
...
...
@@ -47,7 +47,7 @@ export function uniUtsV1Plugin(): Plugin {
resolvePackage
,
resolvePlatformIndex
,
resolveRootIndex
,
}
=
resolveUTSCompiler
()
.
v1
}
=
resolveUTSCompiler
()
const
pkg
=
resolvePackage
(
module
)
if
(
!
pkg
)
{
...
...
packages/uni-cli-shared/package.json
浏览文件 @
febf317f
...
...
@@ -64,7 +64,7 @@
},
"gitHead"
:
"33e807d66e1fe47e2ee08ad9c59247e37b8884da"
,
"devDependencies"
:
{
"@dcloudio/uni-uts"
:
"3.0.0-alpha-3060720221018002"
,
"@dcloudio/uni-uts
-v1
"
:
"3.0.0-alpha-3060720221018002"
,
"@types/babel__core"
:
"^7.1.19"
,
"@types/debug"
:
"^4.1.7"
,
"@types/estree"
:
"^0.0.51"
,
...
...
@@ -79,4 +79,4 @@
"postcss"
:
"^8.4.16"
,
"vue"
:
"3.2.41"
}
}
}
\ No newline at end of file
packages/uni-cli-shared/src/resolve.ts
浏览文件 @
febf317f
...
...
@@ -4,7 +4,7 @@ import path from 'path'
import
debug
from
'
debug
'
import
resolve
from
'
resolve
'
import
{
once
}
from
'
@dcloudio/uni-shared
'
import
*
as
UTSCompiler
from
'
@dcloudio/uni-uts
'
import
*
as
UTSCompiler
from
'
@dcloudio/uni-uts
-v1
'
import
{
normalizePath
}
from
'
./utils
'
import
{
isInHBuilderX
}
from
'
./hbx/env
'
...
...
@@ -207,7 +207,7 @@ export function resolveUTSCompiler(): typeof UTSCompiler {
'
uniapp-uts
'
))
}
return
require
(
require
.
resolve
(
'
@dcloudio/uni-uts
'
,
{
return
require
(
require
.
resolve
(
'
@dcloudio/uni-uts
-v1
'
,
{
paths
:
[
process
.
env
.
UNI_CLI_CONTEXT
],
}))
}
packages/uni-uts/package.json
→
packages/uni-uts
-v1
/package.json
浏览文件 @
febf317f
{
"name"
:
"@dcloudio/uni-uts"
,
"name"
:
"@dcloudio/uni-uts
-v1
"
,
"version"
:
"3.0.0-alpha-3060720221018002"
,
"description"
:
"uni-uts"
,
"description"
:
"uni-uts
-v1
"
,
"main"
:
"dist/index.js"
,
"types"
:
"dist/index.d.ts"
,
"files"
:
[
...
...
@@ -10,24 +10,23 @@
"repository"
:
{
"type"
:
"git"
,
"url"
:
"git+https://github.com/dcloudio/uni-app.git"
,
"directory"
:
"packages/uni-uts"
"directory"
:
"packages/uni-uts
-v1
"
},
"scripts"
:
{
"test"
:
"echo
\"
Error: no test specified
\"
&& exit 1"
},
"license"
:
"Apache-2.0"
,
"dependencies"
:
{
"@dcloudio/uni-cli-shared"
:
"3.0.0-alpha-3060720221018002"
,
"@dcloudio/uni-shared"
:
"3.0.0-alpha-3060720221018002"
,
"@dcloudio/uts"
:
"3.0.0-alpha-3060720221018002"
,
"@vue/shared"
:
"3.2.41"
,
"adm-zip"
:
"^0.5.9"
,
"execa"
:
"^5.1.1"
,
"fast-glob"
:
"^3.2.11"
,
"fs-extra"
:
"^10.0.0"
"fs-extra"
:
"^10.0.0"
,
"jsonc-parser"
:
"^3.0.0"
},
"devDependencies"
:
{
"@types/adm-zip"
:
"^0.5.0"
,
"@types/fs-extra"
:
"^9.0.13"
}
}
}
\ No newline at end of file
packages/uni-uts
/src/v1
/code.ts
→
packages/uni-uts
-v1/src
/code.ts
浏览文件 @
febf317f
import
fs
from
'
fs
'
import
path
from
'
path
'
import
{
isInHBuilderX
}
from
'
@dcloudio/uni-cli-shared
'
import
{
BindingIdentifier
,
...
...
@@ -14,9 +13,9 @@ import {
Param
,
TsTypeAnnotation
,
VariableDeclaration
,
}
from
'
../
../
types/types
'
}
from
'
../types/types
'
import
{
createResolveTypeReferenceName
}
from
'
./utils
'
import
{
isInHBuilderX
}
from
'
./shared
'
interface
GenProxyCodeOptions
{
is_uni_modules
:
boolean
name
:
string
...
...
packages/uni-uts
/src/v1
/index.ts
→
packages/uni-uts
-v1/src
/index.ts
浏览文件 @
febf317f
文件已移动
packages/uni-uts
/src/v1
/kotlin.ts
→
packages/uni-uts
-v1/src
/kotlin.ts
浏览文件 @
febf317f
...
...
@@ -3,14 +3,15 @@ import fs from 'fs-extra'
import
path
from
'
path
'
import
AdmZip
from
'
adm-zip
'
import
{
sync
}
from
'
fast-glob
'
import
{
isArray
}
from
'
@vue/shared
'
import
{
installHBuilderXPlugin
,
isInHBuilderX
,
normalizePath
,
parseJson
,
resolveSourceMapPath
,
runByHBuilderX
,
}
from
'
@dcloudio/uni-cli-
shared
'
}
from
'
./
shared
'
import
{
genUTSPlatformResource
,
getUtsCompiler
,
...
...
@@ -20,7 +21,7 @@ import {
resolveUTSPlatformFile
,
resolveUTSSourceMapPath
,
}
from
'
./utils
'
import
{
Module
}
from
'
../
../
types/types
'
import
{
Module
}
from
'
../types/types
'
export
function
createKotlinResolveTypeReferenceName
(
_namespace
:
string
,
...
...
@@ -71,7 +72,11 @@ export async function runKotlinDev(filename: string) {
if
(
!
compilerServer
)
{
return
}
const
{
getDefaultJar
,
getKotlincHome
,
compile
}
=
compilerServer
const
{
getDefaultJar
,
getKotlincHome
,
compile
,
checkDependencies
}
=
compilerServer
if
(
checkDependencies
)
{
await
checkDeps
(
filename
,
checkDependencies
)
}
// time = Date.now()
const
jarFile
=
resolveJarPath
(
kotlinFile
)
const
options
=
{
...
...
@@ -103,6 +108,41 @@ export async function runKotlinDev(filename: string) {
}
}
function
checkDeps
(
filename
:
string
,
checkDependencies
:
(
configJsonFile
:
string
)
=>
Promise
<
{
code
:
number
;
msg
:
string
;
data
:
string
[]
}
>
)
{
const
configJsonFile
=
resolveConfigJsonFile
(
filename
)
if
(
configJsonFile
&&
hasDeps
(
configJsonFile
))
{
return
checkDependencies
(
configJsonFile
).
then
(({
code
,
msg
,
data
})
=>
{
if
(
code
>
0
)
{
throw
msg
}
return
data
})
}
return
Promise
.
resolve
([])
}
function
hasDeps
(
configJsonFile
:
string
)
{
const
deps
=
parseJson
(
configJsonFile
).
dependencies
||
[]
if
(
isArray
(
deps
)
&&
deps
.
length
)
{
return
true
}
return
false
}
function
resolveConfigJsonFile
(
filename
:
string
)
{
const
configJsonFile
=
path
.
resolve
(
resolveAndroidDir
(
filename
),
'
config.json
'
)
if
(
fs
.
existsSync
(
configJsonFile
))
{
return
configJsonFile
}
}
function
resolveSourceMapFile
(
outputDir
:
string
,
kotlinFile
:
string
)
{
return
(
path
.
resolve
(
resolveSourceMapPath
(),
path
.
relative
(
outputDir
,
kotlinFile
))
+
...
...
@@ -221,16 +261,19 @@ function resolveClassPath(jars: string[]) {
return
jars
.
join
(
os
.
platform
()
===
'
win32
'
?
'
;
'
:
'
:
'
)
}
const
getCompilerServer
=
():
|
{
getKotlincHome
():
string
getDefaultJar
():
string
[]
compile
(
options
:
{
kotlinc
:
string
[];
d8
:
string
[]
},
projectPath
:
string
):
Promise
<
boolean
>
}
|
false
=>
{
interface
CompilerServer
{
getKotlincHome
():
string
getDefaultJar
():
string
[]
compile
(
options
:
{
kotlinc
:
string
[];
d8
:
string
[]
},
projectPath
:
string
):
Promise
<
boolean
>
checkDependencies
?:
(
configJsonPath
:
string
)
=>
Promise
<
{
code
:
number
;
msg
:
string
;
data
:
string
[]
}
>
}
function
getCompilerServer
():
CompilerServer
|
undefined
{
const
compilerServerPath
=
path
.
resolve
(
process
.
env
.
UNI_HBUILDERX_PLUGINS
,
'
uniapp-runextension/out/main.js
'
...
...
@@ -245,6 +288,4 @@ const getCompilerServer = ():
console
.
error
(
compilerServerPath
+
'
is not found
'
)
}
}
return
false
}
packages/uni-uts-v1/src/shared.ts
0 → 100644
浏览文件 @
febf317f
import
os
from
'
os
'
import
path
from
'
path
'
import
{
parse
}
from
'
jsonc-parser
'
export
function
parseJson
(
jsonStr
:
string
)
{
return
parse
(
jsonStr
)
}
export
function
once
<
T
extends
(...
args
:
any
[])
=>
any
>
(
fn
:
T
,
ctx
:
unknown
=
null
):
T
{
let
res
:
any
return
((...
args
:
any
[])
=>
{
if
(
fn
)
{
res
=
fn
.
apply
(
ctx
,
args
)
fn
=
null
as
any
}
return
res
})
as
T
}
export
const
runByHBuilderX
=
once
(()
=>
{
return
!!
process
.
env
.
UNI_HBUILDERX_PLUGINS
&&
!!
process
.
env
.
RUN_BY_HBUILDERX
})
export
const
isInHBuilderX
=
once
(()
=>
{
try
{
// eslint-disable-next-line no-restricted-globals
const
{
name
}
=
require
(
path
.
resolve
(
process
.
cwd
(),
'
../about/package.json
'
))
if
(
name
===
'
about
'
)
{
process
.
env
.
UNI_HBUILDERX_PLUGINS
=
path
.
resolve
(
process
.
cwd
(),
'
..
'
)
return
true
}
}
catch
(
e
)
{
// console.error(e)
}
return
false
})
export
function
resolveSourceMapPath
(
outputDir
?:
string
,
platform
?:
UniApp
.
PLATFORM
)
{
return
path
.
resolve
(
outputDir
||
process
.
env
.
UNI_OUTPUT_DIR
,
'
../.sourcemap/
'
+
(
platform
||
process
.
env
.
UNI_SUB_PLATFORM
||
process
.
env
.
UNI_PLATFORM
)
)
}
export
const
isWindows
=
os
.
platform
()
===
'
win32
'
export
function
normalizePath
(
id
:
string
):
string
{
return
isWindows
?
id
.
replace
(
/
\\
/g
,
'
/
'
)
:
id
}
function
supportAutoInstallPlugin
()
{
return
!!
process
.
env
.
HX_Version
}
export
function
installHBuilderXPlugin
(
plugin
:
string
)
{
if
(
!
supportAutoInstallPlugin
())
{
return
}
return
console
.
error
(
`%HXRunUniAPPPluginName%
${
plugin
}
%HXRunUniAPPPluginName%`
)
}
packages/uni-uts
/src/v1
/swift.ts
→
packages/uni-uts
-v1/src
/swift.ts
浏览文件 @
febf317f
import
{
isInHBuilderX
}
from
'
@dcloudio/uni-cli-shared
'
import
{
capitalize
}
from
'
@vue/shared
'
import
{
genUTSPlatformResource
,
...
...
@@ -7,6 +6,7 @@ import {
resolvePackage
,
resolveUTSSourceMapPath
,
}
from
'
./utils
'
import
{
isInHBuilderX
}
from
'
./shared
'
function
parseSwiftPackage
(
filename
:
string
)
{
const
res
=
resolvePackage
(
filename
)
...
...
packages/uni-uts
/src/v1
/utils.ts
→
packages/uni-uts
-v1/src
/utils.ts
浏览文件 @
febf317f
import
path
from
'
path
'
import
fs
from
'
fs-extra
'
import
type
{
parse
,
bundle
,
UtsTarget
}
from
'
@dcloudio/uts
'
import
{
normalizePath
,
resolveSourceMapPath
}
from
'
@dcloudio/uni-cli-shared
'
import
{
camelize
,
capitalize
}
from
'
@vue/shared
'
import
{
Module
,
ModuleItem
}
from
'
../../types/types
'
import
{
Module
,
ModuleItem
}
from
'
../types/types
'
import
{
normalizePath
,
resolveSourceMapPath
}
from
'
./shared
'
export
function
resolveUTSSourceMapPath
(
_filename
:
string
)
{
return
resolveSourceMapPath
()
...
...
packages/uni-uts/tsconfig.json
→
packages/uni-uts
-v1
/tsconfig.json
浏览文件 @
febf317f
文件已移动
packages/uni-uts/types/types.d.ts
→
packages/uni-uts
-v1
/types/types.d.ts
浏览文件 @
febf317f
文件已移动
packages/uni-uts/src/index.ts
已删除
100644 → 0
浏览文件 @
72ea400d
export
*
as
v1
from
'
./v1
'
pnpm-lock.yaml
浏览文件 @
febf317f
...
...
@@ -304,7 +304,7 @@ importers:
'
@babel/types'
:
^7.17.0
'
@dcloudio/uni-i18n'
:
3.0.0-alpha-3060720221018002
'
@dcloudio/uni-shared'
:
3.0.0-alpha-3060720221018002
'
@dcloudio/uni-uts'
:
3.0.0-alpha-3060720221018002
'
@dcloudio/uni-uts
-v1
'
:
3.0.0-alpha-3060720221018002
'
@intlify/core-base'
:
9.1.9
'
@intlify/shared'
:
9.1.9
'
@intlify/vue-devtools'
:
9.1.9
...
...
@@ -394,7 +394,7 @@ importers:
tapable
:
2.2.1
xregexp
:
3.1.0
devDependencies
:
'
@dcloudio/uni-uts
'
:
link:../uni-uts
'
@dcloudio/uni-uts
-v1'
:
link:../uni-uts-v1
'
@types/babel__core'
:
7.1.19
'
@types/debug'
:
4.1.7
'
@types/estree'
:
0.0.51
...
...
@@ -799,10 +799,8 @@ importers:
devDependencies
:
'
@types/debug'
:
4.1.7
packages/uni-uts
:
packages/uni-uts
-v1
:
specifiers
:
'
@dcloudio/uni-cli-shared'
:
3.0.0-alpha-3060720221018002
'
@dcloudio/uni-shared'
:
3.0.0-alpha-3060720221018002
'
@dcloudio/uts'
:
3.0.0-alpha-3060720221018002
'
@types/adm-zip'
:
^0.5.0
'
@types/fs-extra'
:
^9.0.13
...
...
@@ -811,15 +809,15 @@ importers:
execa
:
^5.1.1
fast-glob
:
^3.2.11
fs-extra
:
^10.0.0
jsonc-parser
:
^3.0.0
dependencies
:
'
@dcloudio/uni-cli-shared'
:
link:../uni-cli-shared
'
@dcloudio/uni-shared'
:
link:../uni-shared
'
@dcloudio/uts'
:
link:../uts
'
@vue/shared'
:
3.2.41
adm-zip
:
0.5.9
execa
:
5.1.1
fast-glob
:
3.2.12
fs-extra
:
10.1.0
jsonc-parser
:
3.2.0
devDependencies
:
'
@types/adm-zip'
:
0.5.0
'
@types/fs-extra'
:
9.0.13
...
...
scripts/utils.js
浏览文件 @
febf317f
...
...
@@ -32,7 +32,7 @@ const priority = {
'
uni-cloud
'
:
10
,
'
uni-automator
'
:
10
,
uts
:
10
,
'
uni-uts
'
:
9
,
'
uni-uts
-v1
'
:
9
,
'
uni-stacktracey
'
:
8
,
'
size-check
'
:
0
,
}
...
...
@@ -51,7 +51,7 @@ const targets = (exports.targets = fs.readdirSync('packages').filter((f) => {
)
||
fs
.
existsSync
(
path
.
resolve
(
__dirname
,
`../packages/
${
f
}
/tsconfig.json`
))
)
}
catch
(
e
)
{}
}
catch
(
e
)
{
}
return
false
})).
sort
((
a
,
b
)
=>
priority
[
b
]
-
priority
[
a
])
exports
.
fuzzyMatchTarget
=
(
partialTargets
,
includeAllMatching
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录