Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
9a636875
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看板
提交
9a636875
编写于
7月 10, 2024
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(x-android): tsc
上级
1c19012e
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
124 addition
and
106 deletion
+124
-106
packages/uni-app-uts/__tests__/android/transforms/__snapshots__/vFor.spec.ts.snap
...ests__/android/transforms/__snapshots__/vFor.spec.ts.snap
+15
-15
packages/uni-app-uts/__tests__/android/transforms/__snapshots__/vMemo.spec.ts.snap
...sts__/android/transforms/__snapshots__/vMemo.spec.ts.snap
+2
-2
packages/uni-app-uts/__tests__/android/transforms/vFor.spec.ts
...ges/uni-app-uts/__tests__/android/transforms/vFor.spec.ts
+69
-69
packages/uni-app-uts/src/plugins/android/manifestJson.ts
packages/uni-app-uts/src/plugins/android/manifestJson.ts
+1
-1
packages/uni-app-uts/src/plugins/android/uvue/compiler/transforms/vFor.ts
...-uts/src/plugins/android/uvue/compiler/transforms/vFor.ts
+15
-12
packages/uni-uts-v1/lib/kotlin/dist/index.js
packages/uni-uts-v1/lib/kotlin/dist/index.js
+1
-1
packages/uni-uts-v1/lib/kotlin/types/global.d.ts
packages/uni-uts-v1/lib/kotlin/types/global.d.ts
+11
-3
packages/uni-uts-v1/src/sourceMap.ts
packages/uni-uts-v1/src/sourceMap.ts
+1
-1
packages/uni-uts-v1/src/tsc/kotlin/index.ts
packages/uni-uts-v1/src/tsc/kotlin/index.ts
+9
-2
未找到文件。
packages/uni-app-uts/__tests__/android/transforms/__snapshots__/vFor.spec.ts.snap
浏览文件 @
9a636875
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`compiler: v-for codegen basic v-for 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
, _, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
_key, __index, _cached
): VNode => {
return createElementVNode("text")
}), 256 /* UNKEYED_FRAGMENT */)"
`;
exports[`compiler: v-for codegen keyed template v-for 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
, _, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
_key, __index, _cached
): VNode => {
return createElementVNode(Fragment, utsMapOf({ key: item }), [
"hello",
createElementVNode("text")
...
...
@@ -16,31 +16,31 @@ exports[`compiler: v-for codegen keyed template v-for 1`] = `
`;
exports[`compiler: v-for codegen keyed v-for 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
, _, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
_key, __index, _cached
): VNode => {
return createElementVNode("text", utsMapOf({ key: item }))
}), 128 /* KEYED_FRAGMENT */)"
`;
exports[`compiler: v-for codegen skipped key 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
, index, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
_key, index, _cached
): VNode => {
return createElementVNode("text")
}), 256 /* UNKEYED_FRAGMENT */)"
`;
exports[`compiler: v-for codegen skipped value & key 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (_
, _, index, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (_
_value, __key, index, _cached
): VNode => {
return createElementVNode("text")
}), 256 /* UNKEYED_FRAGMENT */)"
`;
exports[`compiler: v-for codegen skipped value 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (_
, key, index, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (_
_value, key, index, _cached
): VNode => {
return createElementVNode("text")
}), 256 /* UNKEYED_FRAGMENT */)"
`;
exports[`compiler: v-for codegen template v-for 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
, _, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
_key, __index, _cached
): VNode => {
return createElementVNode(Fragment, null, [
"hello",
createElementVNode("text")
...
...
@@ -49,7 +49,7 @@ exports[`compiler: v-for codegen template v-for 1`] = `
`;
exports[`compiler: v-for codegen template v-for key injection with single child 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
, _, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
_key, __index, _cached
): VNode => {
return createElementVNode("text", utsMapOf({
key: item.id,
id: item.id
...
...
@@ -58,19 +58,19 @@ exports[`compiler: v-for codegen template v-for key injection with single child
`;
exports[`compiler: v-for codegen template v-for w/ <slot/> 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
, _, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
_key, __index, _cached
): VNode => {
return renderSlot($slots, "default")
}), 256 /* UNKEYED_FRAGMENT */)"
`;
exports[`compiler: v-for codegen v-for on <slot/> 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
, _, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, _
_key, __index, _cached
): VNode => {
return renderSlot($slots, "default")
}), 256 /* UNKEYED_FRAGMENT */)"
`;
exports[`compiler: v-for codegen v-for on element with custom directive 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(list, (i, _
, _, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(list, (i, _
_key, __index, _cached
): VNode => {
return withDirectives(createElementVNode("view", null, null, 512 /* NEED_PATCH */), [
[_directive_foo]
])
...
...
@@ -78,14 +78,14 @@ exports[`compiler: v-for codegen v-for on element with custom directive 1`] = `
`;
exports[`compiler: v-for codegen v-for with constant expression 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(10, (item, _
, _, _
): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(10, (item, _
_key, __index, _cached
): VNode => {
return createElementVNode("p", null, toDisplayString(item), 1 /* TEXT */)
}), 64 /* STABLE_FRAGMENT */)"
`;
exports[`compiler: v-for codegen v-if + v-for 1`] = `
"isTrue(ok)
? createElementVNode(Fragment, utsMapOf({ key: 0 }), RenderHelpers.renderList(list, (i, _
, _, _
): VNode => {
? createElementVNode(Fragment, utsMapOf({ key: 0 }), RenderHelpers.renderList(list, (i, _
_key, __index, _cached
): VNode => {
return createElementVNode("view")
}), 256 /* UNKEYED_FRAGMENT */)
: createCommentVNode("v-if", true)"
...
...
@@ -93,14 +93,14 @@ exports[`compiler: v-for codegen v-if + v-for 1`] = `
exports[`compiler: v-for codegen v-if + v-for on <template> 1`] = `
"isTrue(ok)
? createElementVNode(Fragment, utsMapOf({ key: 0 }), RenderHelpers.renderList(list, (i, _
, _, _
): VNode => {
? createElementVNode(Fragment, utsMapOf({ key: 0 }), RenderHelpers.renderList(list, (i, _
_key, __index, _cached
): VNode => {
return createElementVNode(Fragment, null, [], 64 /* STABLE_FRAGMENT */)
}), 256 /* UNKEYED_FRAGMENT */)
: createCommentVNode("v-if", true)"
`;
exports[`compiler: v-for codegen value + key + index 1`] = `
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, key, index, _): VNode => {
"createElementVNode(Fragment, null, RenderHelpers.renderList(items, (item, key, index, _
cached
): VNode => {
return createElementVNode("text")
}), 256 /* UNKEYED_FRAGMENT */)"
`;
packages/uni-app-uts/__tests__/android/transforms/__snapshots__/vMemo.spec.ts.snap
浏览文件 @
9a636875
...
...
@@ -39,7 +39,7 @@ function Render(): any | null {
const _ctx = this
const _cache = this.$.renderCache
return createElementVNode("view", null, [
createElementVNode(Fragment, null, RenderHelpers.renderList(_ctx.list, ({ x, y }, _
, _
, _cached): VNode => {
createElementVNode(Fragment, null, RenderHelpers.renderList(_ctx.list, ({ x, y }, _
_key, __index
, _cached): VNode => {
const _memo: Array<any | null> = ([x, y === _ctx.z])
if (_cached != null && _cached.key === x && isMemoSame(_cached, _memo)) return _cached
const _item = createElementVNode("text", utsMapOf({ key: x }), "foobar")
...
...
@@ -56,7 +56,7 @@ function Render(): any | null {
const _ctx = this
const _cache = this.$.renderCache
return createElementVNode("view", null, [
createElementVNode(Fragment, null, RenderHelpers.renderList(_ctx.list, ({ x, y }, _
, _
, _cached): VNode => {
createElementVNode(Fragment, null, RenderHelpers.renderList(_ctx.list, ({ x, y }, _
_key, __index
, _cached): VNode => {
const _memo: Array<any | null> = ([x, y === _ctx.z])
if (_cached != null && _cached.key === x && isMemoSame(_cached, _memo)) return _cached
const _item = createElementVNode("view", utsMapOf({ key: x }), [
...
...
packages/uni-app-uts/__tests__/android/transforms/vFor.spec.ts
浏览文件 @
9a636875
此差异已折叠。
点击以展开。
packages/uni-app-uts/src/plugins/android/manifestJson.ts
浏览文件 @
9a636875
...
...
@@ -100,7 +100,7 @@ export class UniAppConfig extends io.dcloud.uniapp.appframe.AppConfig {
process
.
env
.
UNI_COMPILER_VERSION
||
''
}
"
${
codes
}
constructor() {}
constructor() {
super()
}
}
`
}
...
...
packages/uni-app-uts/src/plugins/android/uvue/compiler/transforms/vFor.ts
浏览文件 @
9a636875
...
...
@@ -209,9 +209,10 @@ export const transformFor = createStructuralDirectiveTransform(
if
(
memo
)
{
const
loop
=
createFunctionExpression
(
createForLoopParams
(
forNode
.
parseResult
,
[
createSimpleExpression
(
`_cached`
),
])
createForLoopParams
(
forNode
.
parseResult
,
createSimpleExpression
(
`_cached`
)
)
)
loop
.
body
=
createBlockStatement
([
createCompoundExpression
([
...
...
@@ -238,9 +239,10 @@ export const transformFor = createStructuralDirectiveTransform(
}
else
{
renderExp
.
arguments
.
push
(
createFunctionExpression
(
createForLoopParams
(
forNode
.
parseResult
,
[
createSimpleExpression
(
`_`
),
]),
createForLoopParams
(
forNode
.
parseResult
,
createSimpleExpression
(
`_cached`
)
),
childBlock
,
true
/* force newline */
)
as
ForIteratorExpression
...
...
@@ -285,7 +287,7 @@ export function processFor(
if
(
key
===
undefined
)
{
parseResult
.
key
=
{
constType
:
2
,
content
:
'
_
'
,
content
:
'
_
_key
'
,
isStatic
:
false
,
loc
:
value
?.
loc
!
,
type
:
4
,
...
...
@@ -295,7 +297,7 @@ export function processFor(
if
(
index
===
undefined
)
{
parseResult
.
index
=
{
constType
:
2
,
content
:
'
_
'
,
content
:
'
_
_index
'
,
isStatic
:
false
,
loc
:
value
?.
loc
!
,
type
:
4
,
...
...
@@ -473,13 +475,14 @@ function createAliasExpression(
)
}
export
function
createForLoopParams
(
function
createForLoopParams
(
{
value
,
key
,
index
}:
ForParseResult
,
memoArgs
:
ExpressionNode
[]
=
[]
memoArgs
:
ExpressionNode
):
ExpressionNode
[]
{
return
createParamsList
([
value
,
key
,
index
,
...
memoArgs
])
return
createParamsList
([
value
,
key
,
index
,
memoArgs
])
}
const
paramNames
=
[
'
__value
'
,
'
__key
'
,
'
__item
'
,
'
_cached
'
]
function
createParamsList
(
args
:
(
ExpressionNode
|
undefined
)[]
):
ExpressionNode
[]
{
...
...
@@ -489,5 +492,5 @@ function createParamsList(
}
return
args
.
slice
(
0
,
i
+
1
)
.
map
((
arg
,
i
)
=>
arg
||
createSimpleExpression
(
`_`
.
repeat
(
i
+
1
)
,
false
))
.
map
((
arg
,
i
)
=>
arg
||
createSimpleExpression
(
paramNames
[
i
]
,
false
))
}
packages/uni-uts-v1/lib/kotlin/dist/index.js
浏览文件 @
9a636875
此差异已折叠。
点击以展开。
packages/uni-uts-v1/lib/kotlin/types/global.d.ts
浏览文件 @
9a636875
import
{
defineComponent
as
defineComponentOrigin
}
from
'
@vue/runtime-core
'
import
{
defineApp
as
defineAppOrigin
,
defineComponent
as
defineComponentOrigin
}
from
'
@vue/runtime-core
'
declare
global
{
const
CSS_VAR_WINDOW_TOP
:
number
const
CSS_VAR_WINDOW_BOTTOM
:
number
const
CSS_VAR_STATUS_BAR_HEIGHT
:
number
const
defineApp
:
typeof
defineAppOrigin
const
defineComponent
:
typeof
defineComponentOrigin
const
__uniConfig
:
UniConfig
const
__uniRoutes
:
UniPageRoute
[]
function
utsMapOf
(
obj
:
Record
<
string
,
any
>
):
Map
<
string
,
any
|
null
>
function
utsMapOf
<
K
,
V
>
(
obj
:
Array
<
Array
<
any
>>
):
Map
<
string
,
any
|
null
>
function
utsMapOf
(
obj
?
:
Record
<
string
,
any
>
):
Map
<
string
,
any
|
null
>
function
utsMapOf
<
K
,
V
>
(
obj
?
:
Array
<
Array
<
any
>>
):
Map
<
string
,
any
|
null
>
function
padStyleMapOf
(
style
:
Map
<
string
,
any
>
):
Map
<
string
,
Map
<
string
,
any
>>
type
UniPageMeta
=
{
...
...
packages/uni-uts-v1/src/sourceMap.ts
浏览文件 @
9a636875
...
...
@@ -173,7 +173,7 @@ export function generatedPositionFor({
* @param generatedPosition
* @returns
*/
export
function
originalPositionFor
(
export
async
function
originalPositionFor
(
generatedPosition
:
Omit
<
PositionFor
,
'
filename
'
>
&
{
inputDir
?:
string
}
):
Promise
<
NullableMappedPosition
&
{
sourceContent
?:
string
}
>
{
return
resolveSourceMapConsumer
(
generatedPosition
.
sourceMapFile
).
then
(
...
...
packages/uni-uts-v1/src/tsc/kotlin/index.ts
浏览文件 @
9a636875
...
...
@@ -9,7 +9,8 @@ import {
SourceMapConsumer
,
SourceMapGenerator
,
}
from
'
source-map-js
'
import
{
isInHBuilderX
,
normalizePath
}
from
'
../../shared
'
import
{
normalizePath
}
from
'
../../shared
'
import
{
originalPositionForSync
}
from
'
../../sourceMap
'
export
interface
UTS2KotlinOptions
{
typescript
?:
typeof
import
(
'
typescript
'
)
...
...
@@ -33,7 +34,7 @@ export function runUTS2Kotlin(
):
{
watcher
?:
WatchProgramHelper
}
{
const
pluginPath
=
isInHBuilderX
()
const
pluginPath
=
process
.
env
.
UNI_HBUILDERX_PLUGINS
?
process
.
env
.
UNI_HBUILDERX_PLUGINS
:
path
.
resolve
(
process
.
cwd
(),
'
../
'
)
...
...
@@ -43,6 +44,10 @@ export function runUTS2Kotlin(
)
const
kotlinTypesPath
=
path
.
resolve
(
__dirname
,
'
../../../lib/kotlin/types
'
)
const
rootFiles
:
string
[]
=
[
path
.
resolve
(
hbxLanguageServicePath
,
'
uniappx/node_modules/@dcloudio/uni-app-x/types/shim-uts-basic.d.ts
'
),
path
.
resolve
(
kotlinTypesPath
,
'
global.d.ts
'
),
path
.
resolve
(
hbxLanguageServicePath
,
'
uts-types/common/index.d.ts
'
),
//path.resolve(hbxLanguageServicePath, 'uts-types/app-android/index.d.ts'),
...
...
@@ -98,6 +103,7 @@ export function runUTS2Kotlin(
type
RunDevOptions
=
Required
<
UTS2KotlinOptions
&
{
originalPositionForSync
?:
typeof
originalPositionForSync
sourceMapCallback
?:
(
id
:
string
,
map
:
string
,
...
...
@@ -117,6 +123,7 @@ export function runUTS2Kotlin(
rootFiles
,
hxLanguageServiceDir
:
hbxLanguageServicePath
,
compilerOptions
,
originalPositionForSync
,
normalizeFileName
:
options
.
normalizeFileName
,
sourceMapCallback
:
(
fileName
,
text
,
writeFile
)
=>
{
const
relativeFileName
=
normalizePath
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录