Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
菜鸟程序猿_c
uni-app
提交
08b45f6b
U
uni-app
项目概览
菜鸟程序猿_c
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
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,发现更多精彩内容 >>
提交
08b45f6b
编写于
5月 06, 2022
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): api
上级
8c4af279
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
307 addition
and
215 deletion
+307
-215
packages/uts-darwin-arm64/uts.darwin-arm64.node
packages/uts-darwin-arm64/uts.darwin-arm64.node
+0
-0
packages/uts/dist/index.d.ts
packages/uts/dist/index.d.ts
+14
-4
packages/uts/dist/index.js
packages/uts/dist/index.js
+103
-37
packages/uts/dist/types.d.ts
packages/uts/dist/types.d.ts
+1
-0
packages/uts/src/api.ts
packages/uts/src/api.ts
+37
-0
packages/uts/src/cli/action.ts
packages/uts/src/cli/action.ts
+0
-142
packages/uts/src/cli/index.ts
packages/uts/src/cli/index.ts
+18
-10
packages/uts/src/index.ts
packages/uts/src/index.ts
+133
-22
packages/uts/src/types.ts
packages/uts/src/types.ts
+1
-0
未找到文件。
packages/uts-darwin-arm64/uts.darwin-arm64.node
浏览文件 @
08b45f6b
无法预览此类型文件
packages/uts/dist/index.d.ts
浏览文件 @
08b45f6b
import
{
UtsKotlinOptions
,
UtsResult
,
UtsSwiftOptions
}
from
'
./types
'
;
export
*
from
'
./types
'
;
export
declare
function
toKotlin
(
options
:
UtsKotlinOptions
):
Promise
<
UtsResult
>
;
export
declare
function
toSwift
(
options
:
UtsSwiftOptions
):
Promise
<
UtsResult
>
;
export
interface
ToOptions
{
watch
?:
boolean
;
input
:
{
dir
:
string
;
extname
?:
string
;
};
output
:
{
dir
:
string
;
sourceMap
:
boolean
|
string
;
inlineSourcesContent
?:
boolean
;
};
}
export
declare
function
runDev
(
target
:
'
kotlin
'
|
'
swift
'
,
opts
:
ToOptions
):
void
;
export
declare
function
runBuild
(
target
:
'
kotlin
'
|
'
swift
'
,
opts
:
ToOptions
):
void
|
Promise
<
void
[]
>
;
packages/uts/dist/index.js
浏览文件 @
08b45f6b
"
use strict
"
;
var
__createBinding
=
(
this
&&
this
.
__createBinding
)
||
(
Object
.
create
?
(
function
(
o
,
m
,
k
,
k2
)
{
if
(
k2
===
undefined
)
k2
=
k
;
var
desc
=
Object
.
getOwnPropertyDescriptor
(
m
,
k
);
if
(
!
desc
||
(
"
get
"
in
desc
?
!
m
.
__esModule
:
desc
.
writable
||
desc
.
configurable
))
{
desc
=
{
enumerable
:
true
,
get
:
function
()
{
return
m
[
k
];
}
};
}
Object
.
defineProperty
(
o
,
k2
,
desc
);
})
:
(
function
(
o
,
m
,
k
,
k2
)
{
if
(
k2
===
undefined
)
k2
=
k
;
o
[
k2
]
=
m
[
k
];
}));
var
__exportStar
=
(
this
&&
this
.
__exportStar
)
||
function
(
m
,
exports
)
{
for
(
var
p
in
m
)
if
(
p
!==
"
default
"
&&
!
Object
.
prototype
.
hasOwnProperty
.
call
(
exports
,
p
))
__createBinding
(
exports
,
m
,
p
);
var
__importDefault
=
(
this
&&
this
.
__importDefault
)
||
function
(
mod
)
{
return
(
mod
&&
mod
.
__esModule
)
?
mod
:
{
"
default
"
:
mod
};
};
Object
.
defineProperty
(
exports
,
"
__esModule
"
,
{
value
:
true
});
exports
.
toSwift
=
exports
.
toKotlin
=
void
0
;
const
path_1
=
require
(
"
path
"
);
__exportStar
(
require
(
"
./types
"
),
exports
);
// Allow overrides to the location of the .node binding file
const
bindingsOverride
=
process
.
env
[
'
UTS_BINARY_PATH
'
]
;
const
bindings
=
!!
bindingsOverride
?
require
((
0
,
path_1
.
resolve
)(
bindingsOverride
))
:
require
(
'
./binding
'
).
default
;
function
toKotlin
(
options
)
{
const
result
=
Promise
.
resolve
({});
const
{
input
,
output
}
=
option
s
;
if
(
!
(
input
===
null
||
input
===
void
0
?
void
0
:
input
.
root
))
{
return
result
;
exports
.
runBuild
=
exports
.
runDev
=
void
0
;
const
fs_1
=
__importDefault
(
require
(
"
fs
"
)
);
const
path_1
=
__importDefault
(
require
(
"
path
"
)
);
const
fast_glob_1
=
__importDefault
(
require
(
"
fast-glob
"
));
const
chokidar_1
=
require
(
"
chokidar
"
)
;
const
api_1
=
require
(
"
./api
"
);
function
resolveDefaultOutputDir
(
mode
,
inputDir
)
{
return
path_1
.
default
.
resolve
(
inputDir
,
'
../dist/
'
+
mode
+
'
/kotlin
'
)
;
}
function
parseOptions
(
mode
,
opts
)
{
const
{
input
}
=
opt
s
;
if
(
!
(
input
===
null
||
input
===
void
0
?
void
0
:
input
.
dir
))
{
throw
new
Error
(
`input.dir is required`
)
;
}
if
(
!
(
input
===
null
||
input
===
void
0
?
void
0
:
input
.
filename
))
{
return
result
;
if
(
!
fs_1
.
default
.
existsSync
(
input
.
dir
))
{
throw
new
Error
(
`
${
input
}
is not found`
)
;
}
if
(
!
(
output
===
null
||
output
===
void
0
?
void
0
:
output
.
outDir
))
{
return
result
;
if
(
!
opts
.
output
)
{
opts
.
output
=
{
dir
:
''
,
sourceMap
:
''
,
};
}
return
bindings
.
toKotlin
(
toBuffer
(
options
));
if
(
!
opts
.
output
.
dir
)
{
opts
.
output
.
dir
=
resolveDefaultOutputDir
(
mode
,
input
.
dir
);
}
return
opts
;
}
const
EXTNAME
=
'
.uts
'
;
function
watchSwift
(
_
)
{
}
function
buildSwift
(
_
)
{
}
function
watchKotlin
({
input
:
{
dir
:
inputDir
,
extname
},
output
:
{
dir
:
outputDir
,
sourceMap
},
})
{
const
input
=
{
root
:
inputDir
,
filename
:
''
,
};
const
output
=
{
outDir
:
outputDir
,
sourceMap
,
};
(
0
,
chokidar_1
.
watch
)(
'
**/*
'
+
(
extname
||
EXTNAME
),
{
cwd
:
inputDir
,
ignored
:
[
'
**/*.d
'
+
(
extname
||
EXTNAME
)],
})
.
on
(
'
add
'
,
(
filename
)
=>
buildKotlinFile
(
path_1
.
default
.
resolve
(
inputDir
,
filename
),
input
,
output
))
.
on
(
'
change
'
,
(
filename
)
=>
buildKotlinFile
(
path_1
.
default
.
resolve
(
inputDir
,
filename
),
input
,
output
))
.
on
(
'
unlink
'
,
(
filename
)
=>
{
try
{
fs_1
.
default
.
unlinkSync
(
path_1
.
default
.
resolve
(
outputDir
,
filename
));
}
catch
(
e
)
{
}
});
}
exports
.
toKotlin
=
toKotlin
;
function
toSwift
(
options
)
{
return
bindings
.
toSwift
(
toBuffer
(
options
));
function
buildKotlin
({
input
:
{
dir
:
inputDir
,
extname
},
output
:
{
dir
:
outputDir
,
sourceMap
,
inlineSourcesContent
},
})
{
const
files
=
fast_glob_1
.
default
.
sync
(
'
**/*
'
+
(
extname
||
EXTNAME
),
{
absolute
:
true
,
cwd
:
inputDir
,
ignore
:
[
'
**/*.d
'
+
(
extname
||
EXTNAME
)],
});
const
input
=
{
root
:
inputDir
,
filename
:
''
,
};
const
output
=
{
outDir
:
outputDir
,
sourceMap
,
inlineSourcesContent
:
!!
inlineSourcesContent
,
};
return
Promise
.
all
(
files
.
map
((
filename
)
=>
buildKotlinFile
(
filename
,
input
,
output
)));
}
exports
.
toSwift
=
toSwift
;
function
toBuffer
(
t
)
{
return
Buffer
.
from
(
JSON
.
stringify
(
t
));
function
buildKotlinFile
(
filename
,
input
,
output
)
{
const
label
=
path_1
.
default
.
posix
.
relative
(
input
.
root
,
filename
);
const
toKotlinOptions
=
{
input
:
{
...
input
,
filename
,
namespace
:
''
,
},
output
:
{
...
output
,
},
};
console
.
time
(
label
);
return
(
0
,
api_1
.
toKotlin
)(
toKotlinOptions
).
then
(()
=>
{
console
.
timeEnd
(
label
);
});
}
function
runDev
(
target
,
opts
)
{
opts
=
parseOptions
(
'
dev
'
,
opts
);
switch
(
target
)
{
case
'
kotlin
'
:
return
watchKotlin
(
opts
);
case
'
swift
'
:
return
watchSwift
(
opts
);
}
}
exports
.
runDev
=
runDev
;
function
runBuild
(
target
,
opts
)
{
opts
=
parseOptions
(
'
build
'
,
opts
);
switch
(
target
)
{
case
'
kotlin
'
:
return
buildKotlin
(
opts
);
case
'
swift
'
:
return
buildSwift
(
opts
);
}
}
exports
.
runBuild
=
runBuild
;
packages/uts/dist/types.d.ts
浏览文件 @
08b45f6b
...
...
@@ -29,6 +29,7 @@ export declare type InputKotlinOptions = UtsParseOptions & {
export
declare
type
OutputKotlinOptions
=
{
outDir
:
string
;
sourceMap
:
boolean
|
string
;
inlineSourcesContent
?:
boolean
;
};
export
interface
UtsKotlinOptions
{
input
:
InputKotlinOptions
;
...
...
packages/uts/src/api.ts
0 → 100644
浏览文件 @
08b45f6b
import
{
resolve
}
from
'
path
'
import
{
UtsKotlinOptions
,
UtsResult
,
UtsSwiftOptions
}
from
'
./types
'
export
*
from
'
./types
'
const
bindingsOverride
=
process
.
env
[
'
UTS_BINARY_PATH
'
]
const
bindings
=
!!
bindingsOverride
?
require
(
resolve
(
bindingsOverride
))
:
require
(
'
./binding
'
).
default
export
function
toKotlin
(
options
:
UtsKotlinOptions
):
Promise
<
UtsResult
>
{
const
result
=
Promise
.
resolve
({})
const
{
input
,
output
}
=
options
if
(
!
input
?.
root
)
{
return
result
}
if
(
!
input
?.
filename
)
{
return
result
}
if
(
!
output
?.
outDir
)
{
return
result
}
if
(
output
.
sourceMap
===
true
)
{
output
.
sourceMap
=
output
.
outDir
}
else
if
(
output
.
sourceMap
===
false
)
{
output
.
sourceMap
=
''
}
return
bindings
.
toKotlin
(
toBuffer
(
options
))
}
export
function
toSwift
(
options
:
UtsSwiftOptions
):
Promise
<
UtsResult
>
{
return
bindings
.
toSwift
(
toBuffer
(
options
))
}
function
toBuffer
(
t
:
any
):
Buffer
{
return
Buffer
.
from
(
JSON
.
stringify
(
t
))
}
packages/uts/src/cli/action.ts
已删除
100644 → 0
浏览文件 @
8c4af279
import
fs
from
'
fs
'
import
path
from
'
path
'
import
glob
from
'
fast-glob
'
import
{
watch
}
from
'
chokidar
'
import
{
InputKotlinOptions
,
toKotlin
}
from
'
../index
'
import
{
OutputKotlinOptions
,
UtsKotlinOptions
}
from
'
../types
'
export
interface
ToOptions
{
watch
?:
boolean
input
:
{
dir
:
string
extname
?:
string
}
output
:
{
dir
:
string
sourceMap
:
boolean
|
string
}
}
interface
ToKotlinOptions
extends
ToOptions
{}
interface
ToSwiftOptions
extends
ToOptions
{}
function
resolveDefaultOutputDir
(
inputDir
:
string
)
{
return
path
.
resolve
(
inputDir
,
'
../dist/kotlin
'
)
}
function
parseOptions
(
opts
:
Partial
<
ToKotlinOptions
>
)
{
const
{
input
}
=
opts
if
(
!
input
?.
dir
)
{
throw
new
Error
(
`input.dir is required`
)
}
if
(
!
fs
.
existsSync
(
input
.
dir
))
{
throw
new
Error
(
`
${
input
}
is not found`
)
}
if
(
!
opts
.
output
)
{
opts
.
output
=
{
dir
:
''
,
sourceMap
:
false
,
}
}
if
(
!
opts
.
output
.
dir
)
{
opts
.
output
.
dir
=
resolveDefaultOutputDir
(
input
.
dir
)
}
return
opts
as
ToKotlinOptions
}
const
EXTNAME
=
'
.uts
'
function
watchSwift
(
_
:
ToSwiftOptions
)
{}
function
buildSwift
(
_
:
ToSwiftOptions
)
{}
function
watchKotlin
({
input
:
{
dir
:
inputDir
,
extname
},
output
:
{
dir
:
outputDir
,
sourceMap
},
}:
ToKotlinOptions
)
{
const
input
:
InputKotlinOptions
=
{
root
:
inputDir
,
filename
:
''
,
}
const
output
:
OutputKotlinOptions
=
{
outDir
:
outputDir
,
sourceMap
,
}
watch
(
'
**/*
'
+
(
extname
||
EXTNAME
),
{
cwd
:
inputDir
,
ignored
:
[
'
**/*.d
'
+
(
extname
||
EXTNAME
)],
})
.
on
(
'
add
'
,
(
filename
)
=>
buildKotlinFile
(
path
.
resolve
(
inputDir
,
filename
),
input
,
output
)
)
.
on
(
'
change
'
,
(
filename
)
=>
buildKotlinFile
(
path
.
resolve
(
inputDir
,
filename
),
input
,
output
)
)
.
on
(
'
unlink
'
,
(
filename
)
=>
{
try
{
fs
.
unlinkSync
(
path
.
resolve
(
outputDir
,
filename
))
}
catch
(
e
)
{}
})
}
function
buildKotlin
({
input
:
{
dir
:
inputDir
,
extname
},
output
:
{
dir
:
outputDir
,
sourceMap
},
}:
ToKotlinOptions
)
{
const
files
=
glob
.
sync
(
'
**/*
'
+
(
extname
||
EXTNAME
),
{
absolute
:
true
,
cwd
:
inputDir
,
ignore
:
[
'
**/*.d
'
+
(
extname
||
EXTNAME
)],
})
const
input
:
InputKotlinOptions
=
{
root
:
inputDir
,
filename
:
''
,
}
const
output
:
OutputKotlinOptions
=
{
outDir
:
outputDir
,
sourceMap
,
}
return
Promise
.
all
(
files
.
map
((
filename
)
=>
buildKotlinFile
(
filename
,
input
,
output
))
)
}
function
buildKotlinFile
(
filename
:
string
,
input
:
InputKotlinOptions
,
output
:
OutputKotlinOptions
)
{
const
label
=
path
.
posix
.
relative
(
input
.
root
,
filename
)
const
toKotlinOptions
:
UtsKotlinOptions
=
{
input
:
{
...
input
,
filename
,
namespace
:
''
,
},
output
:
{
...
output
,
},
}
console
.
time
(
label
)
return
toKotlin
(
toKotlinOptions
).
then
(()
=>
{
console
.
timeEnd
(
label
)
})
}
export
function
runDev
(
target
:
'
kotlin
'
|
'
swift
'
,
opts
:
ToOptions
)
{
opts
=
parseOptions
(
opts
)
switch
(
target
)
{
case
'
kotlin
'
:
return
watchKotlin
(
opts
)
case
'
swift
'
:
return
watchSwift
(
opts
)
}
}
export
function
runBuild
(
target
:
'
kotlin
'
|
'
swift
'
,
opts
:
ToOptions
)
{
opts
=
parseOptions
(
opts
)
switch
(
target
)
{
case
'
kotlin
'
:
return
buildKotlin
(
opts
)
case
'
swift
'
:
return
buildSwift
(
opts
)
}
}
packages/uts/src/cli/index.ts
浏览文件 @
08b45f6b
import
{
cac
}
from
'
cac
'
import
{
runBuild
,
runDev
,
ToOptions
}
from
'
.
/action
'
import
{
runBuild
,
runDev
,
ToOptions
}
from
'
.
.
'
const
cli
=
cac
(
'
uts
'
)
export
interface
CliOptions
{
target
:
'
kotlin
'
|
'
swift
'
output
:
string
sourcemap
:
boolean
sourceMap
:
boolean
inlineSourcesContent
:
boolean
watch
:
boolean
extname
:
string
}
cli
.
command
(
'
<
root>
'
)
.
command
(
'
<
input> [output]
'
)
.
option
(
'
-t, --target <target>
'
,
'
[string] kotlin | swift
'
,
{
default
:
'
kotlin
'
,
})
.
option
(
'
-o, --output <output>
'
,
`[string] output dir path`
)
.
option
(
'
-s, --sourcemap
'
,
`[boolean] output sourcemap`
,
{
.
option
(
'
-s, --sourceMap [sourceMap]
'
,
`[boolean] output sourceMap`
,
{
default
:
false
,
})
.
option
(
'
-i, --inlineSourcesContent [inlineSourcesContent]
'
,
`[boolean] inline sources content`
,
{
default
:
false
,
}
)
.
option
(
'
-w, --watch
'
,
`[boolean] rebuilds when uts have changed on disk`
,
{
default
:
false
,
})
.
option
(
'
-e, --extname [extname]
'
,
`[string] extname`
,
{
default
:
'
.uts
'
,
})
.
action
((
roo
t
,
opts
:
CliOptions
)
=>
{
.
action
((
input
,
outpu
t
,
opts
:
CliOptions
)
=>
{
const
toOptions
:
ToOptions
=
{
watch
:
opts
.
watch
,
input
:
{
dir
:
roo
t
,
dir
:
inpu
t
,
extname
:
opts
.
extname
,
},
output
:
{
dir
:
opts
.
output
,
sourceMap
:
opts
.
sourcemap
,
dir
:
output
,
sourceMap
:
opts
.
sourceMap
,
inlineSourcesContent
:
opts
.
inlineSourcesContent
,
},
}
console
.
log
(
opts
,
toOptions
)
return
opts
.
watch
?
runDev
(
opts
.
target
,
toOptions
)
:
runBuild
(
opts
.
target
,
toOptions
)
...
...
packages/uts/src/index.ts
浏览文件 @
08b45f6b
import
{
resolve
}
from
'
path
'
import
{
UtsKotlinOptions
,
UtsResult
,
UtsSwiftOptions
}
from
'
./types
'
import
fs
from
'
fs
'
import
path
from
'
path
'
import
glob
from
'
fast-glob
'
import
{
watch
}
from
'
chokidar
'
export
*
from
'
./types
'
import
{
InputKotlinOptions
,
toKotlin
}
from
'
./api
'
import
{
OutputKotlinOptions
,
UtsKotlinOptions
}
from
'
./types
'
// Allow overrides to the location of the .node binding file
const
bindingsOverride
=
process
.
env
[
'
UTS_BINARY_PATH
'
]
const
bindings
=
!!
bindingsOverride
?
require
(
resolve
(
bindingsOverride
))
:
require
(
'
./binding
'
).
default
export
interface
ToOptions
{
watch
?:
boolean
input
:
{
dir
:
string
extname
?:
string
}
output
:
{
dir
:
string
sourceMap
:
boolean
|
string
inlineSourcesContent
?:
boolean
}
}
interface
ToKotlinOptions
extends
ToOptions
{}
interface
ToSwiftOptions
extends
ToOptions
{}
function
resolveDefaultOutputDir
(
mode
:
'
dev
'
|
'
build
'
,
inputDir
:
string
)
{
return
path
.
resolve
(
inputDir
,
'
../dist/
'
+
mode
+
'
/kotlin
'
)
}
function
parseOptions
(
mode
:
'
dev
'
|
'
build
'
,
opts
:
Partial
<
ToKotlinOptions
>
)
{
const
{
input
}
=
opts
if
(
!
input
?.
dir
)
{
throw
new
Error
(
`input.dir is required`
)
}
if
(
!
fs
.
existsSync
(
input
.
dir
))
{
throw
new
Error
(
`
${
input
}
is not found`
)
}
if
(
!
opts
.
output
)
{
opts
.
output
=
{
dir
:
''
,
sourceMap
:
''
,
}
}
if
(
!
opts
.
output
.
dir
)
{
opts
.
output
.
dir
=
resolveDefaultOutputDir
(
mode
,
input
.
dir
)
}
return
opts
as
ToKotlinOptions
}
const
EXTNAME
=
'
.uts
'
export
function
toKotlin
(
options
:
UtsKotlinOptions
):
Promise
<
UtsResult
>
{
const
result
=
Promise
.
resolve
({})
const
{
input
,
output
}
=
options
if
(
!
input
?.
root
)
{
return
result
function
watchSwift
(
_
:
ToSwiftOptions
)
{}
function
buildSwift
(
_
:
ToSwiftOptions
)
{}
function
watchKotlin
({
input
:
{
dir
:
inputDir
,
extname
},
output
:
{
dir
:
outputDir
,
sourceMap
},
}:
ToKotlinOptions
)
{
const
input
:
InputKotlinOptions
=
{
root
:
inputDir
,
filename
:
''
,
}
const
output
:
OutputKotlinOptions
=
{
outDir
:
outputDir
,
sourceMap
,
}
watch
(
'
**/*
'
+
(
extname
||
EXTNAME
),
{
cwd
:
inputDir
,
ignored
:
[
'
**/*.d
'
+
(
extname
||
EXTNAME
)],
})
.
on
(
'
add
'
,
(
filename
)
=>
buildKotlinFile
(
path
.
resolve
(
inputDir
,
filename
),
input
,
output
)
)
.
on
(
'
change
'
,
(
filename
)
=>
buildKotlinFile
(
path
.
resolve
(
inputDir
,
filename
),
input
,
output
)
)
.
on
(
'
unlink
'
,
(
filename
)
=>
{
try
{
fs
.
unlinkSync
(
path
.
resolve
(
outputDir
,
filename
))
}
catch
(
e
)
{}
})
}
function
buildKotlin
({
input
:
{
dir
:
inputDir
,
extname
},
output
:
{
dir
:
outputDir
,
sourceMap
,
inlineSourcesContent
},
}:
ToKotlinOptions
)
{
const
files
=
glob
.
sync
(
'
**/*
'
+
(
extname
||
EXTNAME
),
{
absolute
:
true
,
cwd
:
inputDir
,
ignore
:
[
'
**/*.d
'
+
(
extname
||
EXTNAME
)],
})
const
input
:
InputKotlinOptions
=
{
root
:
inputDir
,
filename
:
''
,
}
if
(
!
input
?.
filename
)
{
return
result
const
output
:
OutputKotlinOptions
=
{
outDir
:
outputDir
,
sourceMap
,
inlineSourcesContent
:
!!
inlineSourcesContent
,
}
if
(
!
output
?.
outDir
)
{
return
result
return
Promise
.
all
(
files
.
map
((
filename
)
=>
buildKotlinFile
(
filename
,
input
,
output
))
)
}
function
buildKotlinFile
(
filename
:
string
,
input
:
InputKotlinOptions
,
output
:
OutputKotlinOptions
)
{
const
label
=
path
.
posix
.
relative
(
input
.
root
,
filename
)
const
toKotlinOptions
:
UtsKotlinOptions
=
{
input
:
{
...
input
,
filename
,
namespace
:
''
,
},
output
:
{
...
output
,
},
}
return
bindings
.
toKotlin
(
toBuffer
(
options
))
console
.
time
(
label
)
return
toKotlin
(
toKotlinOptions
).
then
(()
=>
{
console
.
timeEnd
(
label
)
})
}
export
function
toSwift
(
options
:
UtsSwiftOptions
):
Promise
<
UtsResult
>
{
return
bindings
.
toSwift
(
toBuffer
(
options
))
export
function
runDev
(
target
:
'
kotlin
'
|
'
swift
'
,
opts
:
ToOptions
)
{
opts
=
parseOptions
(
'
dev
'
,
opts
)
switch
(
target
)
{
case
'
kotlin
'
:
return
watchKotlin
(
opts
)
case
'
swift
'
:
return
watchSwift
(
opts
)
}
}
function
toBuffer
(
t
:
any
):
Buffer
{
return
Buffer
.
from
(
JSON
.
stringify
(
t
))
export
function
runBuild
(
target
:
'
kotlin
'
|
'
swift
'
,
opts
:
ToOptions
)
{
opts
=
parseOptions
(
'
build
'
,
opts
)
switch
(
target
)
{
case
'
kotlin
'
:
return
buildKotlin
(
opts
)
case
'
swift
'
:
return
buildSwift
(
opts
)
}
}
packages/uts/src/types.ts
浏览文件 @
08b45f6b
...
...
@@ -43,6 +43,7 @@ export type InputKotlinOptions = UtsParseOptions & {
export
type
OutputKotlinOptions
=
{
outDir
:
string
sourceMap
:
boolean
|
string
inlineSourcesContent
?:
boolean
}
export
interface
UtsKotlinOptions
{
input
:
InputKotlinOptions
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录