Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
8fdb4d84
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看板
提交
8fdb4d84
编写于
12月 06, 2023
作者:
fxy060608
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
wip(uts): 修复 v-once
上级
92ae3050
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
33 addition
and
29 deletion
+33
-29
packages/uni-app-uts/__tests__/android/codegen.spec.ts
packages/uni-app-uts/__tests__/android/codegen.spec.ts
+7
-7
packages/uni-app-uts/__tests__/android/transforms/__snapshots__/vMemo.spec.ts.snap
...sts__/android/transforms/__snapshots__/vMemo.spec.ts.snap
+6
-6
packages/uni-app-uts/__tests__/android/transforms/__snapshots__/vOnce.spec.ts.snap
...sts__/android/transforms/__snapshots__/vOnce.spec.ts.snap
+8
-8
packages/uni-app-uts/__tests__/android/transforms/component.spec.ts
...ni-app-uts/__tests__/android/transforms/component.spec.ts
+1
-1
packages/uni-app-uts/__tests__/android/transforms/vSlot.spec.ts
...es/uni-app-uts/__tests__/android/transforms/vSlot.spec.ts
+4
-4
packages/uni-app-uts/src/plugins/android/uvue/compiler/codegen.ts
.../uni-app-uts/src/plugins/android/uvue/compiler/codegen.ts
+4
-3
packages/uni-app-uts/src/plugins/android/uvue/compiler/runtimeHelpers.ts
...p-uts/src/plugins/android/uvue/compiler/runtimeHelpers.ts
+3
-0
未找到文件。
packages/uni-app-uts/__tests__/android/codegen.spec.ts
浏览文件 @
8fdb4d84
...
...
@@ -34,7 +34,7 @@ describe('compiler:codegen', () => {
assert
(
`<view/>`
,
`
function PagesIndexIndexRender(): VNode | null {\nconst _ctx = this\nconst _cache = this.$
!
.renderCache\n return createElementVNode("view")\n}`
,
function PagesIndexIndexRender(): VNode | null {\nconst _ctx = this\nconst _cache = this.$.renderCache\n return createElementVNode("view")\n}`
,
{
targetLanguage
:
'
kotlin
'
,
mode
:
'
function
'
,
...
...
@@ -44,7 +44,7 @@ function PagesIndexIndexRender(): VNode | null {\nconst _ctx = this\nconst _cach
test
(
`UTSComponents`
,
()
=>
{
assert
(
`<view><uts-hello/><uts-hello/></view>`
,
`import { UtsHelloElement } from 'uts.sdk.modules.utsHello';\nfunction PagesIndexIndexRender(): VNode | null {\nconst _ctx = this\nconst _cache = this.$
!
.renderCache\n return createElementVNode("view", null, [\n createElementVNode(uts.sdk.modules.utsHello.UtsHelloComponent.name),\n createElementVNode(uts.sdk.modules.utsHello.UtsHelloComponent.name)\n ])\n}`
,
`import { UtsHelloElement } from 'uts.sdk.modules.utsHello';\nfunction PagesIndexIndexRender(): VNode | null {\nconst _ctx = this\nconst _cache = this.$.renderCache\n return createElementVNode("view", null, [\n createElementVNode(uts.sdk.modules.utsHello.UtsHelloComponent.name),\n createElementVNode(uts.sdk.modules.utsHello.UtsHelloComponent.name)\n ])\n}`
,
{
targetLanguage
:
'
kotlin
'
,
mode
:
'
function
'
,
...
...
@@ -61,7 +61,7 @@ function PagesIndexIndexRender(): VNode | null {\nconst _ctx = this\nconst _cach
)
assert
(
`<view><uts-hello/><uts-hello/><uts-hello1/></view>`
,
`import { UtsHelloElement } from 'uts.sdk.modules.utsHello';import { UtsHello1Element } from 'uts.sdk.modules.utsHello';\nfunction PagesIndexIndexRender(): VNode | null {\nconst _ctx = this\nconst _cache = this.$
!
.renderCache\n return createElementVNode("view", null, [\n createElementVNode(uts.sdk.modules.utsHello.UtsHelloComponent.name),\n createElementVNode(uts.sdk.modules.utsHello.UtsHelloComponent.name),\n createElementVNode(uts.sdk.modules.utsHello.UtsHello1Component.name)\n ])\n}`
,
`import { UtsHelloElement } from 'uts.sdk.modules.utsHello';import { UtsHello1Element } from 'uts.sdk.modules.utsHello';\nfunction PagesIndexIndexRender(): VNode | null {\nconst _ctx = this\nconst _cache = this.$.renderCache\n return createElementVNode("view", null, [\n createElementVNode(uts.sdk.modules.utsHello.UtsHelloComponent.name),\n createElementVNode(uts.sdk.modules.utsHello.UtsHelloComponent.name),\n createElementVNode(uts.sdk.modules.utsHello.UtsHello1Component.name)\n ])\n}`
,
{
targetLanguage
:
'
kotlin
'
,
mode
:
'
function
'
,
...
...
@@ -92,7 +92,7 @@ import _easycom_custom1 from '@/components/custom1/custom1.vue'
import _easycom_index from '@/components/index/index.vue'
function PagesIndexIndexRender(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
const _component_custom = resolveEasyComponent("custom",_easycom_custom)
const _component_custom1 = resolveEasyComponent("custom1",_easycom_custom1)
const _component_index = resolveEasyComponent("index",_easycom_index)
...
...
@@ -121,7 +121,7 @@ const _component_index1 = resolveComponent("index1")
`
function PagesIndexIndexRender(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
const _component_index = resolveComponent("index", true)
return createVNode(_component_index)
...
...
@@ -141,7 +141,7 @@ import _easycom_custom1 from '@/components/custom1/custom1.vue'
import _easycom_index from '@/components/index/index.vue'
function PagesIndexIndexRender(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
const _component_custom = resolveEasyComponent("custom",_easycom_custom)
const _component_custom1 = resolveEasyComponent("custom1",_easycom_custom1)
const _component_index = resolveEasyComponent("index",_easycom_index)
...
...
@@ -185,7 +185,7 @@ import _imports_0 from './logo.png'
function PagesIndexIndexRender(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
return createElementVNode(\"image\", utsMapOf({ src: _imports_0 }))
}`
,
{
...
...
packages/uni-app-uts/__tests__/android/transforms/__snapshots__/vMemo.spec.ts.snap
浏览文件 @
8fdb4d84
...
...
@@ -4,7 +4,7 @@ exports[`compiler: v-memo transform on component 1`] = `
"
function Render(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
const _component_Comp = resolveComponent("Comp")
return createElementVNode("view", null, [
...
...
@@ -17,7 +17,7 @@ exports[`compiler: v-memo transform on normal element 1`] = `
"
function Render(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
return createElementVNode("view", null, [
withMemo([_ctx.x], (): VNode => createElementVNode("view"), _cache, 0)
])
...
...
@@ -28,7 +28,7 @@ exports[`compiler: v-memo transform on root element 1`] = `
"
function Render(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
return withMemo([_ctx.x], (): VNode => createElementVNode("view"), _cache, 0)
}"
`;
...
...
@@ -37,7 +37,7 @@ exports[`compiler: v-memo transform on template v-for 1`] = `
"
function Render(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
return createElementVNode("view", null, [
createElementVNode(Fragment, null, RenderHelpers.renderList(_ctx.list, ({ x, y }, _, _, _cached): VNode => {
const _memo: Array<any | null> = ([x, y === _ctx.z])
...
...
@@ -54,7 +54,7 @@ exports[`compiler: v-memo transform on v-for 1`] = `
"
function Render(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
return createElementVNode("view", null, [
createElementVNode(Fragment, null, RenderHelpers.renderList(_ctx.list, ({ x, y }, _, _, _cached): VNode => {
const _memo: Array<any | null> = ([x, y === _ctx.z])
...
...
@@ -73,7 +73,7 @@ exports[`compiler: v-memo transform on v-if 1`] = `
"
function Render(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
const _component_Comp = resolveComponent("Comp")
return createElementVNode("view", null, [
...
...
packages/uni-app-uts/__tests__/android/transforms/__snapshots__/vOnce.spec.ts.snap
浏览文件 @
8fdb4d84
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`compiler: v-once transform as root node 1`] = `
"
_cache[0] ?? run((): VNode | null
=> {
"
resolveCache(_cache, 0, (): VNode
=> {
setBlockTracking(-1)
_cache[0] = createElementVNode("view", utsMapOf({ id: foo }), null, 8 /* PROPS */, ["id"])
setBlockTracking(1)
return _cache[0] as VNode
| null
return _cache[0] as VNode
})"
`;
exports[`compiler: v-once transform on component 1`] = `
"createElementVNode("view", null, [
_cache[0] ?? run((): VNode | null
=> {
resolveCache(_cache, 0, (): VNode
=> {
setBlockTracking(-1)
_cache[0] = createVNode(_component_Comp, utsMapOf({ id: foo }), null, 8 /* PROPS */, ["id"])
setBlockTracking(1)
return _cache[0] as VNode
| null
return _cache[0] as VNode
})
])"
`;
exports[`compiler: v-once transform on nested plain element 1`] = `
"createElementVNode("view", null, [
_cache[0] ?? run((): VNode | null
=> {
resolveCache(_cache, 0, (): VNode
=> {
setBlockTracking(-1)
_cache[0] = createElementVNode("view", utsMapOf({ id: foo }), null, 8 /* PROPS */, ["id"])
setBlockTracking(1)
return _cache[0] as VNode
| null
return _cache[0] as VNode
})
])"
`;
exports[`compiler: v-once transform on slot outlet 1`] = `
"createElementVNode("view", null, [
_cache[0] ?? run((): VNode | null
=> {
resolveCache(_cache, 0, (): VNode
=> {
setBlockTracking(-1)
_cache[0] = renderSlot($slots, "default")
setBlockTracking(1)
return _cache[0] as VNode
| null
return _cache[0] as VNode
})
])"
`;
packages/uni-app-uts/__tests__/android/transforms/component.spec.ts
浏览文件 @
8fdb4d84
...
...
@@ -7,7 +7,7 @@ describe('compiler: component', () => {
`
function PagesIndexIndexRender(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
const _component_Foo = resolveComponent("Foo")
return createElementVNode("view", null, [
...
...
packages/uni-app-uts/__tests__/android/transforms/vSlot.spec.ts
浏览文件 @
8fdb4d84
...
...
@@ -95,7 +95,7 @@ describe('compiler: slot', () => {
`
function PagesIndexIndexRender(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
return createElementVNode("view", null, [
renderSlot(_ctx.$slots, "default", utsMapOf({ data: "data" }))
])
...
...
@@ -113,7 +113,7 @@ const _cache = this.$!.renderCache
`
function PagesIndexIndexRender(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
const _component_Foo = resolveComponent("Foo")
return createElementVNode("view", null, [
...
...
@@ -150,7 +150,7 @@ const _component_Foo = resolveComponent("Foo")
`
function PagesIndexIndexRender(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
const _component_Foo = resolveComponent("Foo")
return createElementVNode("view", null, [
...
...
@@ -175,7 +175,7 @@ const _component_Foo = resolveComponent("Foo")
`
function PagesIndexIndexRender(): VNode | null {
const _ctx = this
const _cache = this.$
!
.renderCache
const _cache = this.$.renderCache
const _component_Foo = resolveComponent("Foo")
return createElementVNode("view", null, [
...
...
packages/uni-app-uts/src/plugins/android/uvue/compiler/codegen.ts
浏览文件 @
8fdb4d84
...
...
@@ -45,6 +45,7 @@ import { addEasyComponentAutoImports, genRenderFunctionDecl } from './utils'
import
{
IS_TRUE
,
RENDER_LIST
,
RESOLVE_CACHE
,
RESOLVE_COMPONENT
,
RESOLVE_DIRECTIVE
,
RESOLVE_EASY_COMPONENT
,
...
...
@@ -214,7 +215,7 @@ export function generate(
newline
()
push
(
`const _ctx = this`
)
newline
()
push
(
`const _cache = this.$
!
.renderCache`
)
push
(
`const _cache = this.$.renderCache`
)
// generate asset resolution statements
if
(
ast
.
components
.
length
)
{
newline
()
...
...
@@ -822,7 +823,7 @@ function genConditionalExpression(
function
genCacheExpression
(
node
:
CacheExpression
,
context
:
CodegenContext
)
{
const
{
push
,
helper
,
indent
,
deindent
,
newline
}
=
context
push
(
`
_cache[
${
node
.
index
}
] ?? run((): VNode | null
=> {`
)
push
(
`
${
helperNameMap
[
RESOLVE_CACHE
]}
(_cache,
${
node
.
index
}
, (): VNode
=> {`
)
if
(
node
.
isVNode
)
{
indent
()
push
(
`
${
helper
(
SET_BLOCK_TRACKING
)}
(-1)`
)
...
...
@@ -834,7 +835,7 @@ function genCacheExpression(node: CacheExpression, context: CodegenContext) {
newline
()
push
(
`
${
helper
(
SET_BLOCK_TRACKING
)}
(1)`
)
newline
()
push
(
`return _cache[
${
node
.
index
}
] as VNode
| null
`
)
push
(
`return _cache[
${
node
.
index
}
] as VNode`
)
deindent
()
}
push
(
`})`
)
...
...
packages/uni-app-uts/src/plugins/android/uvue/compiler/runtimeHelpers.ts
浏览文件 @
8fdb4d84
...
...
@@ -15,6 +15,8 @@ export const V_ON_WITH_MODIFIERS = Symbol(`vOnModifiersGuard`)
export
const
WITH_SLOT_CTX
=
Symbol
(
`withSlotCtx`
)
export
const
WITH_SCOPED_SLOT_CTX
=
Symbol
(
`withScopedSlotCtx`
)
export
const
RESOLVE_CACHE
=
Symbol
(
`resolveCache`
)
registerRuntimeHelpers
({
[
IS_TRUE
]:
'
isTrue
'
,
[
V_SHOW
]:
'
vShow
'
,
...
...
@@ -28,4 +30,5 @@ registerRuntimeHelpers({
[
V_ON_WITH_MODIFIERS
]:
`withModifiers`
,
[
WITH_SLOT_CTX
]:
`withSlotCtx`
,
[
WITH_SCOPED_SLOT_CTX
]:
`withScopedSlotCtx`
,
[
RESOLVE_CACHE
]:
`resolveCache`
,
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录