From c569499cccc51d55bd5bbd97e05a5459895ba64f Mon Sep 17 00:00:00 2001 From: Yan Xingyu <285685173@qq.com> Date: Fri, 28 Jun 2024 11:27:03 +0800 Subject: [PATCH 01/18] skeleton Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/process_component_build.ts | 102 +++++++++++++++++++++++- 1 file changed, 99 insertions(+), 3 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 07f164df0..d095b1220 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -191,6 +191,68 @@ import { resourceFileName } from './process_ui_syntax'; import { regularCollection } from './validate_ui_syntax'; +import { To } from 'copy-webpack-plugin'; + +function attrExpHasProp(temp: ts.CallExpression, propName : string, attrArgs : ts.Expression[]): boolean { + let attrAccessExp = temp.expression as ts.PropertyAccessExpression; + let expName = attrAccessExp.name.getText(); + + if(expName == propName) { + attrArgs.push(...temp.arguments); + return true; + } + + if(temp.arguments.length) { + let arg = temp.arguments[0] as ts.ObjectLiteralExpression; + for(let prop of arg.properties as ts.NodeArray) { + if (prop.name.getText() == propName) { + attrArgs.push(prop.initializer); + return true; + } + } + } + return false; +} + + +export const HANDLE_COMPLEX_ATTRS: Map> = new Map([ + ["size", new Map([ + ["width", "width"], + ["height", "height"], + ])], + + ["height", new Map([ + ["height", "height"], + ])], + + ["width", new Map([ + ["width", "width"], + ])], + + ["border", new Map([ + ["width", "borderWidth"], + ["color", "borderColor"], + ["radius", "borderRadius"], + ["style", "borderStyle"], + ])], + + ["borderWidth", new Map([ + ["borderWidth", "borderWidth"], + ])], + + ["borderColor", new Map([ + ["borderColor", "borderColor"], + ])], + + ["borderRadius", new Map([ + ["borderRadius", "borderRadius"], + ])], + + ["borderStyle", new Map([ + ["borderStyle", "borderStyle"], + ])], +]); + export function processComponentBuild(node: ts.MethodDeclaration, log: LogInfo[]): ts.MethodDeclaration { @@ -2148,6 +2210,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: kind: false, hasAnimationAttr: false }; + const complexAttrMap: Map = new Map(); const isRecycleComponent: boolean = isRecycle(componentCollection.currentClassName); if (ts.isPropertyAccessExpression(temp)) { log.push({ @@ -2182,9 +2245,13 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: temp.expression.name && ts.isIdentifier(temp.expression.name) && (!componentCollection.customComponents.has(temp.expression.name.getText()) || STYLES_ATTRIBUTE.has(temp.expression.name.getText()))) { parseRecycleId(temp, temp.expression.name, isRecycleComponent, componentAttrInfo); - addComponentAttr(temp, temp.expression.name, lastStatement, statements, identifierNode, log, - isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, - isRecycleComponent, isStyleFunction); + if (HANDLE_COMPLEX_ATTRS.has(temp.expression.name.getText())) { + collectComplextComponentAttr(temp, complexAttrMap, identifierNode); + } else { + addComponentAttr(temp, temp.expression.name, lastStatement, statements, identifierNode, log, + isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, + isRecycleComponent, isStyleFunction); + } temp = temp.expression.expression; flag = true; } else if (ts.isIdentifier(temp.expression)) { @@ -2202,6 +2269,12 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: temp = temp.expression; } } + if (complexAttrMap.size) { + for (let entry of complexAttrMap.entries()) { + statements.push(entry[1]); + updateStatements.push(entry[1]); + } + } if (lastStatement.statement && lastStatement.kind) { statements.push(lastStatement.statement); } @@ -2672,6 +2745,29 @@ function verifyComponentId(temp: any, node: ts.Identifier, propName: string, } } +function createAttrFunction(node : ts.Identifier, name: string, argumentsArr : ts.Expression[]) { + return ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression(node, ts.factory.createIdentifier(name)), + undefined, + argumentsArr); +} + +function collectComplextComponentAttr(temp : ts.CallExpression, complexAttrMap: Map, + identifierNode: ts.Identifier): void { + let attrAccessExp = temp.expression as ts.PropertyAccessExpression; + const expName = attrAccessExp.name.getText(); + + let map = HANDLE_COMPLEX_ATTRS.get(expName); + for(let [propName, attrName] of map.entries()) { + const attrArgs : ts.Expression[] = []; + if (!complexAttrMap.has(attrName) && attrExpHasProp(temp, propName, attrArgs)) { + const attrStatement: ts.Statement = ts.factory.createExpressionStatement( + createAttrFunction(identifierNode, attrName, attrArgs)); + complexAttrMap.set(attrName, attrStatement); + } + } +} + function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, statements: ts.Statement[], identifierNode: ts.Identifier, log: LogInfo[], isStylesAttr: boolean, immutableStatements: ts.Statement[], updateStatements: ts.Statement[], -- Gitee From 7ae624f4fee7b742b47bcf61f0a4d7af7d60b74a Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Tue, 2 Jul 2024 15:54:50 +0800 Subject: [PATCH 02/18] read mapping from files Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/complex_attr.json | 48 ++++++++++++++++++++++++ compiler/src/process_component_build.ts | 49 ++++++------------------- 2 files changed, 60 insertions(+), 37 deletions(-) create mode 100644 compiler/complex_attr.json diff --git a/compiler/complex_attr.json b/compiler/complex_attr.json new file mode 100644 index 000000000..bfa6301cc --- /dev/null +++ b/compiler/complex_attr.json @@ -0,0 +1,48 @@ +{ + "size": { + "width": "width", + "height": "height" + }, + "height": { + "height": "height" + }, + "width": { + "width": "width" + }, + "border": { + "width": "borderWidth", + "color": "borderColor", + "radius": "borderRadius", + "style": "borderStyle" + }, + "borderWidth": { + "borderWidth": "borderWidth" + }, + "borderColor": { + "borderColor": "borderColor" + }, + "borderRadius": { + "borderRadius": "borderRadius" + }, + "borderStyle": { + "borderStyle": "borderStyle" + }, + "font": { + "size": "fontSize", + "weight": "fontWeight", + "family": "fontFamily", + "style": "fontStyle" + }, + "fontSize": { + "fontSize": "fontSize" + }, + "fontWeight": { + "fontWeight": "fontWeight" + }, + "fontFamily": { + "fontFamily": "fontFamily" + }, + "fontStyle": { + "fontStyle": "fontStyle" + } +} diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index d095b1220..30a1f3c28 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -15,6 +15,7 @@ import ts from 'typescript'; import path from 'path'; +import fs from 'fs'; import { COMPONENT_RENDER_FUNCTION, @@ -215,44 +216,18 @@ function attrExpHasProp(temp: ts.CallExpression, propName : string, attrArgs : t } -export const HANDLE_COMPLEX_ATTRS: Map> = new Map([ - ["size", new Map([ - ["width", "width"], - ["height", "height"], - ])], - - ["height", new Map([ - ["height", "height"], - ])], - - ["width", new Map([ - ["width", "width"], - ])], - - ["border", new Map([ - ["width", "borderWidth"], - ["color", "borderColor"], - ["radius", "borderRadius"], - ["style", "borderStyle"], - ])], - - ["borderWidth", new Map([ - ["borderWidth", "borderWidth"], - ])], - - ["borderColor", new Map([ - ["borderColor", "borderColor"], - ])], - - ["borderRadius", new Map([ - ["borderRadius", "borderRadius"], - ])], - - ["borderStyle", new Map([ - ["borderStyle", "borderStyle"], - ])], -]); +interface ComplexAttrMap { + [key: string]: { [key: string]: string }; +} + +const jsonFilePath = path.join(__dirname, '../complex_attr.json'); +const jsonData = fs.readFileSync(jsonFilePath, 'utf-8'); + +const rawObject = JSON.parse(jsonData); +const HANDLE_COMPLEX_ATTRS: Map> = new Map( + Object.entries(rawObject).map(([key, value]) => [key, new Map(Object.entries(value))]) +); export function processComponentBuild(node: ts.MethodDeclaration, log: LogInfo[]): ts.MethodDeclaration { -- Gitee From 10b5e81df751f74012be5d9bed7b37be2d503036 Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Thu, 4 Jul 2024 21:28:38 +0800 Subject: [PATCH 03/18] Draft: attribute refresh Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/process_component_build.ts | 57 +++++++++++++++++++++---- compiler/src/process_component_class.ts | 12 +++++- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 30a1f3c28..3f37b130b 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -191,6 +191,7 @@ import { builderTypeParameter, resourceFileName } from './process_ui_syntax'; +import { curPropMap } from './process_component_member'; import { regularCollection } from './validate_ui_syntax'; import { To } from 'copy-webpack-plugin'; @@ -2160,6 +2161,37 @@ function isXComponentContainer(item: ts.PropertyAssignment): boolean { item.initializer.name.getText() === XCOMPONENTTYPE_CONTAINER); } +function isReuseArgument(argument : ts.Expression): boolean { + + if(ts.isObjectLiteralExpression(argument)) { + let props = argument.properties; + for(let prop of props as ts.NodeArray) { + if(!isReuseArgument(prop.initializer)) + return false; + } + } else if(ts.isPropertyAccessExpression(argument)) { + if(argument.expression.kind == ts.SyntaxKind.ThisKeyword && curPropMap.get(argument.name.getText()) == "@State") + return false; + } + // todo: template + return true; +} + +function isReuseStatement(statement : ts.ExpressionStatement): boolean { + let callExp = statement.expression; + if(!ts.isCallExpression(callExp)) + return false; + let args = callExp.arguments; + let res = true; + for(let arg of args) { + if(!isReuseArgument(arg)) { + res = false; + break; + } + } + return res; +} + interface AnimationInfo { statement: ts.Statement, kind: boolean, @@ -2185,7 +2217,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: kind: false, hasAnimationAttr: false }; - const complexAttrMap: Map = new Map(); + const complexAttrMap: Map = new Map(); const isRecycleComponent: boolean = isRecycle(componentCollection.currentClassName); if (ts.isPropertyAccessExpression(temp)) { log.push({ @@ -2245,15 +2277,24 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: } } if (complexAttrMap.size) { - for (let entry of complexAttrMap.entries()) { - statements.push(entry[1]); - updateStatements.push(entry[1]); + for (let [ _ , statement] of complexAttrMap.entries()) { + statements.push(statement); + if(isReuseStatement(statement)) + immutableStatements.push(statement); + else + updateStatements.push(statement); } } if (lastStatement.statement && lastStatement.kind) { statements.push(lastStatement.statement); } - if (!isRecycleComponent || lastStatement.hasAnimationAttr) { + + if(isReuseStatement(newStatements[0] as ts.ExpressionStatement)) { + immutableStatements.push(newStatements[0]); + newStatements.length = 0; + } + + if (lastStatement.hasAnimationAttr) { if (statements.length) { reverse ? newStatements.push(...statements.reverse()) : newStatements.push(...statements); } @@ -2727,7 +2768,7 @@ function createAttrFunction(node : ts.Identifier, name: string, argumentsArr : t argumentsArr); } -function collectComplextComponentAttr(temp : ts.CallExpression, complexAttrMap: Map, +function collectComplextComponentAttr(temp : ts.CallExpression, complexAttrMap: Map, identifierNode: ts.Identifier): void { let attrAccessExp = temp.expression as ts.PropertyAccessExpression; const expName = attrAccessExp.name.getText(); @@ -2736,7 +2777,7 @@ function collectComplextComponentAttr(temp : ts.CallExpression, complexAttrMap: for(let [propName, attrName] of map.entries()) { const attrArgs : ts.Expression[] = []; if (!complexAttrMap.has(attrName) && attrExpHasProp(temp, propName, attrArgs)) { - const attrStatement: ts.Statement = ts.factory.createExpressionStatement( + const attrStatement: ts.ExpressionStatement = ts.factory.createExpressionStatement( createAttrFunction(identifierNode, attrName, attrArgs)); complexAttrMap.set(attrName, attrStatement); } @@ -2841,7 +2882,7 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, const attrStatement: ts.Statement = ts.factory.createExpressionStatement( createFunction(identifierNode, node, temp.arguments, isAttributeModifier)); statements.push(attrStatement); - if (isRecycleComponent && (!isStylesAttr || isStyleFunction) && + if (isReuseStatement(attrStatement as ts.ExpressionStatement) && (!isStylesAttr || isStyleFunction) && !isGestureType(identifierNode) && filterRegularAttrNode(temp.arguments)) { immutableStatements.push(attrStatement); } else { diff --git a/compiler/src/process_component_class.ts b/compiler/src/process_component_class.ts index 8bb76fcc0..303ad05f5 100644 --- a/compiler/src/process_component_class.ts +++ b/compiler/src/process_component_class.ts @@ -189,6 +189,7 @@ function processMembers(members: ts.NodeArray, parentComponentN const purgeVariableDepStatements: ts.Statement[] = []; const rerenderStatements: ts.Statement[] = []; const deleteParamsStatements: ts.PropertyDeclaration[] = []; + const methodMembers: ts.MethodDeclaration[] = []; const checkController: ControllerType = { hasController: !componentCollection.customDialogs.has(parentComponentName.getText()) }; const interfaceNode = ts.factory.createInterfaceDeclaration(undefined, @@ -233,13 +234,20 @@ function processMembers(members: ts.NodeArray, parentComponentN } } if (ts.isMethodDeclaration(item) && item.name) { - updateItem = - processComponentMethod(item, context, log, buildCount); + methodMembers.push(item); } if (updateItem) { newMembers.push(updateItem); } }); + + methodMembers.forEach((item : ts.MethodDeclaration) => { + let updateItem: ts.ClassElement; + updateItem = processComponentMethod(item, context, log, buildCount); + if (updateItem) { + newMembers.push(updateItem); + } + }); INTERFACE_NODE_SET.add(interfaceNode); validateBuildMethodCount(buildCount, parentComponentName, log); validateHasController(parentComponentName, checkController, log); -- Gitee From 528e47dade595d3eab51a1b5255f5ee47b00215c Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Tue, 9 Jul 2024 17:08:49 +0800 Subject: [PATCH 04/18] pass import unit test Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/process_component_build.ts | 62 +++++++++++++------ .../import/import@CustomDialog.ts | 8 ++- .../import/import@Observed.ts | 48 ++++++++------ .../utForPartialUpdate/import/importAllEts.ts | 16 +++-- .../utForPartialUpdate/import/importEts.ts | 12 ++-- .../import/importExportEts.ts | 4 +- .../import/importExportNest.ts | 4 +- .../utForPartialUpdate/import/importTs.ts | 4 +- 8 files changed, 105 insertions(+), 53 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 3f37b130b..48e035a6b 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -917,6 +917,13 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe } if (etsComponentResult.hasAttr) { bindComponentAttr(node, res.identifierNode, newStatements, log, true, false, immutableStatements); + } else if(partialUpdateConfig.partialUpdateMode && isReuseStatement(res.newNode)) { + if (projectConfig.isPreview || projectConfig.enableDebugLine) { + newStatements.splice(-2, 1); + } else { + newStatements.splice(-1, 1); + } + immutableStatements.push(res.newNode); } processInnerCompStatements(innerCompStatements, newStatements, node, isGlobalBuilder, isTransition, undefined, immutableStatements, componentName, builderParamsResult); @@ -1154,7 +1161,7 @@ function createInitRenderStatement(node: ts.Statement, immutableStatements: ts.Statement[], blockArr: ts.Statement[]): void { if (partialUpdateConfig.optimizeComponent) { if (immutableStatements && immutableStatements.length) { - blockArr.push(ts.factory.createIfStatement( + blockArr.splice(0, 0, ts.factory.createIfStatement( ts.factory.createIdentifier(ISINITIALRENDER), ts.factory.createBlock(immutableStatements, true) )); @@ -2163,15 +2170,34 @@ function isXComponentContainer(item: ts.PropertyAssignment): boolean { function isReuseArgument(argument : ts.Expression): boolean { + const mayChangedAnnotation : Set = new Set(["@State", "@ObjectLink"]); if(ts.isObjectLiteralExpression(argument)) { let props = argument.properties; for(let prop of props as ts.NodeArray) { - if(!isReuseArgument(prop.initializer)) + if(!isReuseArgument(prop.initializer)) { return false; + } } } else if(ts.isPropertyAccessExpression(argument)) { - if(argument.expression.kind == ts.SyntaxKind.ThisKeyword && curPropMap.get(argument.name.getText()) == "@State") - return false; + if(argument.expression.kind == ts.SyntaxKind.ThisKeyword && + mayChangedAnnotation.has(curPropMap.get(argument.name.getText()))) { + return false; + } + + if(ts.isPropertyAccessExpression(argument.expression)) + return isReuseArgument(argument.expression); + } else if(ts.isBinaryExpression(argument)) { + return isReuseArgument(argument.left) && isReuseArgument(argument.right); + } else if(ts.isCallExpression(argument)) { + let args = argument.arguments; + let res = true; + for(let arg of args) { + if(!isReuseArgument(arg)) { + res = false; + break; + } + } + return res; } // todo: template return true; @@ -2179,17 +2205,10 @@ function isReuseArgument(argument : ts.Expression): boolean { function isReuseStatement(statement : ts.ExpressionStatement): boolean { let callExp = statement.expression; - if(!ts.isCallExpression(callExp)) + if(!ts.isCallExpression(callExp)) { return false; - let args = callExp.arguments; - let res = true; - for(let arg of args) { - if(!isReuseArgument(arg)) { - res = false; - break; - } } - return res; + return isReuseArgument(callExp); } interface AnimationInfo { @@ -2238,6 +2257,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: } switch (true) { case BIND_POPUP_SET.has(propertyName): + console.log("fcuk bindpopup"); temp = processBindPopupBuilder(temp); break; case BIND_DRAG_SET.has(propertyName): @@ -2252,7 +2272,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: temp.expression.name && ts.isIdentifier(temp.expression.name) && (!componentCollection.customComponents.has(temp.expression.name.getText()) || STYLES_ATTRIBUTE.has(temp.expression.name.getText()))) { parseRecycleId(temp, temp.expression.name, isRecycleComponent, componentAttrInfo); - if (HANDLE_COMPLEX_ATTRS.has(temp.expression.name.getText())) { + if (partialUpdateConfig.partialUpdateMode && HANDLE_COMPLEX_ATTRS.has(temp.expression.name.getText())) { collectComplextComponentAttr(temp, complexAttrMap, identifierNode); } else { addComponentAttr(temp, temp.expression.name, lastStatement, statements, identifierNode, log, @@ -2276,6 +2296,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: temp = temp.expression; } } + if (complexAttrMap.size) { for (let [ _ , statement] of complexAttrMap.entries()) { statements.push(statement); @@ -2289,12 +2310,15 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: statements.push(lastStatement.statement); } - if(isReuseStatement(newStatements[0] as ts.ExpressionStatement)) { - immutableStatements.push(newStatements[0]); + if(partialUpdateConfig.partialUpdateMode && isReuseStatement(newStatements[0] as ts.ExpressionStatement)) { + reverse? immutableStatements.push(newStatements[0]) : immutableStatements.splice(0,0,newStatements[0]); newStatements.length = 0; + } else { + updateStatements.push(...immutableStatements); + immutableStatements.length = 0; } - if (lastStatement.hasAnimationAttr) { + if (!partialUpdateConfig.partialUpdateMode || lastStatement.hasAnimationAttr) { if (statements.length) { reverse ? newStatements.push(...statements.reverse()) : newStatements.push(...statements); } @@ -2882,8 +2906,8 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, const attrStatement: ts.Statement = ts.factory.createExpressionStatement( createFunction(identifierNode, node, temp.arguments, isAttributeModifier)); statements.push(attrStatement); - if (isReuseStatement(attrStatement as ts.ExpressionStatement) && (!isStylesAttr || isStyleFunction) && - !isGestureType(identifierNode) && filterRegularAttrNode(temp.arguments)) { + if ((isReuseStatement(attrStatement as ts.ExpressionStatement)||filterRegularAttrNode(temp.arguments)) + && (!isStylesAttr || isStyleFunction) && !isGestureType(identifierNode)) { immutableStatements.push(attrStatement); } else { updateStatements.push(attrStatement); diff --git a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts index 05e616286..5aea2b053 100644 --- a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts +++ b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts @@ -150,9 +150,11 @@ class CustomDialogUser extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); - Column.margin({ top: 5 }); + if (isInitialRender) { + Column.create(); + Column.width('100%'); + Column.margin({ top: 5 }); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.inputValue); diff --git a/compiler/test/utForPartialUpdate/import/import@Observed.ts b/compiler/test/utForPartialUpdate/import/import@Observed.ts index 6cb1a2e04..a2d840bd8 100644 --- a/compiler/test/utForPartialUpdate/import/import@Observed.ts +++ b/compiler/test/utForPartialUpdate/import/import@Observed.ts @@ -103,8 +103,10 @@ class ViewA extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); - Row.margin({ top: 10 }); + if (isInitialRender) { + Row.create(); + Row.margin({ top: 10 }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('ViewA' + JSON.stringify(this.label) + 'this.a.c=' + JSON.stringify(this.a.c)); @@ -152,8 +154,10 @@ class ViewB extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.create(); + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -224,27 +228,33 @@ class ViewB extends ViewPU { }, { name: "ViewA" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel('ViewB: reset array'); - Button.margin({ top: 10 }); - Button.onClick(() => { - this.arrA = [new import_Observed_1.ClassB(0), new import_Observed_1.ClassB(0)]; - }); + if (isInitialRender) { + Button.createWithLabel('ViewB: reset array'); + Button.margin({ top: 10 }); + Button.onClick(() => { + this.arrA = [new import_Observed_1.ClassB(0), new import_Observed_1.ClassB(0)]; + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel('ViewB: push'); - Button.margin({ top: 10 }); - Button.onClick(() => { - this.arrA.push(new import_Observed_1.ClassB(0)); - }); + if (isInitialRender) { + Button.createWithLabel('ViewB: push'); + Button.margin({ top: 10 }); + Button.onClick(() => { + this.arrA.push(new import_Observed_1.ClassB(0)); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel('ViewB: shift'); - Button.margin({ top: 10 }); - Button.onClick(() => { - this.arrA.shift(); - }); + if (isInitialRender) { + Button.createWithLabel('ViewB: shift'); + Button.margin({ top: 10 }); + Button.onClick(() => { + this.arrA.shift(); + }); + } }, Button); Button.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/import/importAllEts.ts b/compiler/test/utForPartialUpdate/import/importAllEts.ts index c773c74d9..c939f02e7 100644 --- a/compiler/test/utForPartialUpdate/import/importAllEts.ts +++ b/compiler/test/utForPartialUpdate/import/importAllEts.ts @@ -169,7 +169,9 @@ class ImportTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -201,8 +203,10 @@ class ImportTest extends ViewPU { }, { name: "NamespaceComponent1" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { - __Common__.create(); - __Common__.width(100); + if (isInitialRender) { + __Common__.create(); + __Common__.width(100); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -264,8 +268,10 @@ class ImportTest extends ViewPU { }, { name: "default" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { - __Common__.create(); - __Common__.height(200); + if (isInitialRender) { + __Common__.create(); + __Common__.height(200); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/import/importEts.ts b/compiler/test/utForPartialUpdate/import/importEts.ts index 8f4962340..181b735fd 100644 --- a/compiler/test/utForPartialUpdate/import/importEts.ts +++ b/compiler/test/utForPartialUpdate/import/importEts.ts @@ -203,7 +203,9 @@ class ImportTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -239,9 +241,11 @@ class ImportTest extends ViewPU { }, { name: "LinkComponent2Ref" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('space'); - Text.fontSize(20); - Text.fontColor(Color.Red); + if (isInitialRender) { + Text.create('space'); + Text.fontSize(20); + Text.fontColor(Color.Red); + } }, Text); Text.pop(); { diff --git a/compiler/test/utForPartialUpdate/import/importExportEts.ts b/compiler/test/utForPartialUpdate/import/importExportEts.ts index 22aaadbe0..7b79325d2 100644 --- a/compiler/test/utForPartialUpdate/import/importExportEts.ts +++ b/compiler/test/utForPartialUpdate/import/importExportEts.ts @@ -132,7 +132,9 @@ class ImportTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/import/importExportNest.ts b/compiler/test/utForPartialUpdate/import/importExportNest.ts index 203334b09..47fee4c15 100644 --- a/compiler/test/utForPartialUpdate/import/importExportNest.ts +++ b/compiler/test/utForPartialUpdate/import/importExportNest.ts @@ -191,7 +191,9 @@ class ImportTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.testText1); diff --git a/compiler/test/utForPartialUpdate/import/importTs.ts b/compiler/test/utForPartialUpdate/import/importTs.ts index 698659e6a..e3cde133e 100644 --- a/compiler/test/utForPartialUpdate/import/importTs.ts +++ b/compiler/test/utForPartialUpdate/import/importTs.ts @@ -132,7 +132,9 @@ class ImportTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { -- Gitee From ef90e198e24fa5d056ea07a10d2e8e248e2ca20e Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Tue, 9 Jul 2024 20:29:35 +0800 Subject: [PATCH 05/18] add complex_attr.json to sdk Signed-off-by: YanXingyu <285685173@qq.com> --- BUILD.gn | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/BUILD.gn b/BUILD.gn index 486d9cf1f..1f20b6279 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -34,6 +34,9 @@ ets_loader_form_config_file = ets_loader_build_config_file = get_label_info(":build_ets_loader_library", "target_out_dir") + "/build_config.json" +ets_loader_complex_attr_file = + get_label_info(":build_ets_loader_library", "target_out_dir") + + "/complex_attr.json" ets_sysResource = get_label_info(":build_ets_sysResource", "target_out_dir") + "/sysResource.js" ets_loader_kit_configs_dir = get_label_info(":build_ets_loader_library", @@ -55,6 +58,7 @@ action("build_ets_loader_library") { ets_loader_form_config_file, ets_loader_kit_configs_dir, ets_loader_build_config_file, + ets_loader_complex_attr_file, ] _ets_loader_dir = "compiler" @@ -120,6 +124,8 @@ action("build_ets_loader_library") { rebase_path(ets_loader_form_config_file, root_build_dir), "--output-build-config-file", rebase_path(ets_loader_build_config_file, root_build_dir), + "--output-complex-attr-file", + rebase_path(ets_loader_complex_attr_file, root_build_dir), "--kit-configs-file-dir", rebase_path(_kit_configs_file_dir, root_build_dir), "--build-kit-configs-file-js", @@ -202,6 +208,17 @@ ohos_copy("ets_loader_form_config") { module_install_name = "" } +ohos_copy("ets_loader_component_config") { + deps = [ ":build_ets_loader_library" ] + sources = [ + ets_loader_complex_attr_file, + ] + + outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] + module_source_dir = target_out_dir + "/$target_name" + module_install_name = "" +} + ohos_copy("ets_loader_library") { deps = [ ":build_ets_loader_library" ] sources = [ ets_loader_lib_dir ] -- Gitee From a18d2b45471112c8bff61566cb1a8ec628d7c0f9 Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Wed, 10 Jul 2024 14:17:00 +0800 Subject: [PATCH 06/18] format BUILD.gn Signed-off-by: YanXingyu <285685173@qq.com> --- BUILD.gn | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 1f20b6279..8756b29bc 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -210,9 +210,7 @@ ohos_copy("ets_loader_form_config") { ohos_copy("ets_loader_component_config") { deps = [ ":build_ets_loader_library" ] - sources = [ - ets_loader_complex_attr_file, - ] + sources = [ ets_loader_complex_attr_file ] outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] module_source_dir = target_out_dir + "/$target_name" -- Gitee From f2760fbdb3505a5626bc6dda81cd84479819a64b Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Thu, 11 Jul 2024 14:13:52 +0800 Subject: [PATCH 07/18] fix duplicate bug Signed-off-by: YanXingyu <285685173@qq.com> --- BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BUILD.gn b/BUILD.gn index 8756b29bc..f9a9a07eb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -208,7 +208,7 @@ ohos_copy("ets_loader_form_config") { module_install_name = "" } -ohos_copy("ets_loader_component_config") { +ohos_copy("ets_loader_complex_attr") { deps = [ ":build_ets_loader_library" ] sources = [ ets_loader_complex_attr_file ] -- Gitee From 6a27aa48a99982ca460b713499f4af3e4f680e8e Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Thu, 11 Jul 2024 14:46:56 +0800 Subject: [PATCH 08/18] remove unused args Signed-off-by: YanXingyu <285685173@qq.com> --- BUILD.gn | 2 -- 1 file changed, 2 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index f9a9a07eb..359495038 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -124,8 +124,6 @@ action("build_ets_loader_library") { rebase_path(ets_loader_form_config_file, root_build_dir), "--output-build-config-file", rebase_path(ets_loader_build_config_file, root_build_dir), - "--output-complex-attr-file", - rebase_path(ets_loader_complex_attr_file, root_build_dir), "--kit-configs-file-dir", rebase_path(_kit_configs_file_dir, root_build_dir), "--build-kit-configs-file-js", -- Gitee From 57ba05ad7d9548a87b995ce1fa988a5a1a5ef47f Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Thu, 11 Jul 2024 15:17:40 +0800 Subject: [PATCH 09/18] read attribute mappings from ts file Signed-off-by: YanXingyu <285685173@qq.com> --- BUILD.gn | 13 ------- compiler/src/pre_define.ts | 49 +++++++++++++++++++++++++ compiler/src/process_component_build.ts | 20 +++++++--- 3 files changed, 63 insertions(+), 19 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 359495038..486d9cf1f 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -34,9 +34,6 @@ ets_loader_form_config_file = ets_loader_build_config_file = get_label_info(":build_ets_loader_library", "target_out_dir") + "/build_config.json" -ets_loader_complex_attr_file = - get_label_info(":build_ets_loader_library", "target_out_dir") + - "/complex_attr.json" ets_sysResource = get_label_info(":build_ets_sysResource", "target_out_dir") + "/sysResource.js" ets_loader_kit_configs_dir = get_label_info(":build_ets_loader_library", @@ -58,7 +55,6 @@ action("build_ets_loader_library") { ets_loader_form_config_file, ets_loader_kit_configs_dir, ets_loader_build_config_file, - ets_loader_complex_attr_file, ] _ets_loader_dir = "compiler" @@ -206,15 +202,6 @@ ohos_copy("ets_loader_form_config") { module_install_name = "" } -ohos_copy("ets_loader_complex_attr") { - deps = [ ":build_ets_loader_library" ] - sources = [ ets_loader_complex_attr_file ] - - outputs = [ target_out_dir + "/$target_name/{{source_file_part}}" ] - module_source_dir = target_out_dir + "/$target_name" - module_install_name = "" -} - ohos_copy("ets_loader_library") { deps = [ ":build_ets_loader_library" ] sources = [ ets_loader_lib_dir ] diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 44cf5a0f3..faa4ac5e7 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -617,3 +617,52 @@ export const USE_SHARED_STORAGE: string = 'useSharedStorage'; export const ARKTS_MODULE_PREFIX: string = '@arkts'; export const ARKTS_MODULE_NAME: string = 'arkts'; export const COLD_RELOAD_MODE: string = 'coldReload'; + +export const ATTRS_MAPPING = { + "size": { + "width": "width", + "height": "height" + }, + "height": { + "height": "height" + }, + "width": { + "width": "width" + }, + "border": { + "width": "borderWidth", + "color": "borderColor", + "radius": "borderRadius", + "style": "borderStyle" + }, + "borderWidth": { + "borderWidth": "borderWidth" + }, + "borderColor": { + "borderColor": "borderColor" + }, + "borderRadius": { + "borderRadius": "borderRadius" + }, + "borderStyle": { + "borderStyle": "borderStyle" + }, + "font": { + "size": "fontSize", + "weight": "fontWeight", + "family": "fontFamily", + "style": "fontStyle" + }, + "fontSize": { + "fontSize": "fontSize" + }, + "fontWeight": { + "fontWeight": "fontWeight" + }, + "fontFamily": { + "fontFamily": "fontFamily" + }, + "fontStyle": { + "fontStyle": "fontStyle" + } +}; diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 48e035a6b..b731beb6d 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -140,7 +140,8 @@ import { PROTO, NATIVE_VIEW_PARTIAL_UPDATE, NAV_PATH_STACK, - IS_USER_CREATE_STACK + IS_USER_CREATE_STACK, + ATTRS_MAPPING, } from './pre_define'; import { INNER_COMPONENT_NAMES, @@ -221,13 +222,20 @@ interface ComplexAttrMap { [key: string]: { [key: string]: string }; } -const jsonFilePath = path.join(__dirname, '../complex_attr.json'); -const jsonData = fs.readFileSync(jsonFilePath, 'utf-8'); +// const jsonFilePath = path.join(__dirname, '../complex_attr.json'); +// const jsonData = fs.readFileSync(jsonFilePath, 'utf-8'); -const rawObject = JSON.parse(jsonData); +// const rawObject = JSON.parse(jsonData); -const HANDLE_COMPLEX_ATTRS: Map> = new Map( - Object.entries(rawObject).map(([key, value]) => [key, new Map(Object.entries(value))]) +// const HANDLE_COMPLEX_ATTRS: Map> = new Map( +// Object.entries(rawObject).map(([key, value]) => [key, new Map(Object.entries(value))]) +// ); + +const HANDLE_COMPLEX_ATTRS : Map> = new Map( + Object.entries(ATTRS_MAPPING).map(([key, value]) => [ + key, + new Map(Object.entries(value)) + ]) ); export function processComponentBuild(node: ts.MethodDeclaration, -- Gitee From 0c3a51e95931e4de9bcc5043685db39cce92149c Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Mon, 15 Jul 2024 17:04:02 +0800 Subject: [PATCH 10/18] fix bugs of $$ component and custom component Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/process_component_build.ts | 60 ++++++++----- compiler/src/process_custom_component.ts | 13 ++- .../$$_component/$$_component.ts | 84 ++++++++++++------- 3 files changed, 103 insertions(+), 54 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index b731beb6d..8f9c605d7 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -906,7 +906,11 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe } const immutableStatements: ts.Statement[] = []; const res: CreateResult = createComponent(node, COMPONENT_CREATE_FUNCTION); - newStatements.push(res.newNode); + if(partialUpdateConfig.partialUpdateMode && res.isReusable) { + immutableStatements.push(res.newNode); + } else { + newStatements.push(res.newNode); + } processDebug(node, nameResult, newStatements); const etsComponentResult: EtsComponentResult = parseEtsComponentExpression(node); const componentName: string = res.identifierNode.getText(); @@ -917,21 +921,19 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe if (etsComponentResult.etsComponentNode.body && ts.isBlock(etsComponentResult.etsComponentNode.body)) { if (res.isButton) { checkButtonParamHasLabel(etsComponentResult.etsComponentNode, log); - if (projectConfig.isPreview || projectConfig.enableDebugLine) { - newStatements.splice(-2, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); + let removeIndex : number = (projectConfig.isPreview || projectConfig.enableDebugLine)? -2:-1; + if(partialUpdateConfig.partialUpdateMode && res.isReusable) { + immutableStatements.splice(removeIndex, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); } else { - newStatements.splice(-1, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); + newStatements.splice(removeIndex, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); } } if (etsComponentResult.hasAttr) { bindComponentAttr(node, res.identifierNode, newStatements, log, true, false, immutableStatements); - } else if(partialUpdateConfig.partialUpdateMode && isReuseStatement(res.newNode)) { - if (projectConfig.isPreview || projectConfig.enableDebugLine) { - newStatements.splice(-2, 1); - } else { - newStatements.splice(-1, 1); + if(partialUpdateConfig.partialUpdateMode && !res.isReusable) { + newStatements.push(...immutableStatements); + immutableStatements.length = 0; } - immutableStatements.push(res.newNode); } processInnerCompStatements(innerCompStatements, newStatements, node, isGlobalBuilder, isTransition, undefined, immutableStatements, componentName, builderParamsResult); @@ -941,6 +943,10 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe isGlobalBuilder, false, builderParamsResult); } else { bindComponentAttr(node, res.identifierNode, newStatements, log, true, false, immutableStatements); + if(partialUpdateConfig.partialUpdateMode && !res.isReusable) { + newStatements.push(...immutableStatements); + immutableStatements.length = 0; + } processInnerCompStatements(innerCompStatements, newStatements, node, isGlobalBuilder, isTransition, undefined, immutableStatements, componentName, builderParamsResult); } @@ -2085,6 +2091,7 @@ interface CreateResult { isContainerComponent: boolean; isButton: boolean; needPop: boolean; + isReusable: boolean; } function createComponent(node: ts.ExpressionStatement, type: string): CreateResult { @@ -2093,7 +2100,8 @@ function createComponent(node: ts.ExpressionStatement, type: string): CreateResu identifierNode: null, isContainerComponent: false, isButton: false, - needPop: false + needPop: false, + isReusable: false, }; let identifierNode: ts.Identifier = ts.factory.createIdentifier(type); let temp: any = node.expression; @@ -2114,6 +2122,9 @@ function createComponent(node: ts.ExpressionStatement, type: string): CreateResu if (checkContainer(temp.getText(), temp.parent)) { res.isContainerComponent = true; } + if (isReuseArgument(temp.parent)) { + res.isReusable = true; + } res.newNode = type === COMPONENT_POP_FUNCTION ? ts.factory.createExpressionStatement(createFunction(temp, identifierNode, null)) : ts.factory.createExpressionStatement(createFunction(temp, identifierNode, checkArguments(temp, type))); @@ -2187,16 +2198,21 @@ function isReuseArgument(argument : ts.Expression): boolean { } } } else if(ts.isPropertyAccessExpression(argument)) { + //@State this.value if(argument.expression.kind == ts.SyntaxKind.ThisKeyword && mayChangedAnnotation.has(curPropMap.get(argument.name.getText()))) { return false; } - + // $$this.value + if(ts.isIdentifier(argument.expression) && argument.expression.getText() == $$_THIS) { + return false; + } + // this.a.c if(ts.isPropertyAccessExpression(argument.expression)) return isReuseArgument(argument.expression); } else if(ts.isBinaryExpression(argument)) { return isReuseArgument(argument.left) && isReuseArgument(argument.right); - } else if(ts.isCallExpression(argument)) { + } else if(ts.isCallExpression(argument) || ts.isEtsComponentExpression(argument)) { let args = argument.arguments; let res = true; for(let arg of args) { @@ -2206,12 +2222,19 @@ function isReuseArgument(argument : ts.Expression): boolean { } } return res; + } else if(ts.isIdentifier(argument) && argument.getText().match(/^\$\$(.|\n)+/)) { + //start with $$ + return false; + } else if(ts.isConditionalExpression(argument)) { + if(!(isReuseArgument(argument.condition) && isReuseArgument(argument.whenTrue) + && isReuseArgument(argument.whenFalse))) + return false; } // todo: template return true; } -function isReuseStatement(statement : ts.ExpressionStatement): boolean { +export function isReuseStatement(statement : ts.ExpressionStatement): boolean { let callExp = statement.expression; if(!ts.isCallExpression(callExp)) { return false; @@ -2265,7 +2288,6 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: } switch (true) { case BIND_POPUP_SET.has(propertyName): - console.log("fcuk bindpopup"); temp = processBindPopupBuilder(temp); break; case BIND_DRAG_SET.has(propertyName): @@ -2318,14 +2340,6 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: statements.push(lastStatement.statement); } - if(partialUpdateConfig.partialUpdateMode && isReuseStatement(newStatements[0] as ts.ExpressionStatement)) { - reverse? immutableStatements.push(newStatements[0]) : immutableStatements.splice(0,0,newStatements[0]); - newStatements.length = 0; - } else { - updateStatements.push(...immutableStatements); - immutableStatements.length = 0; - } - if (!partialUpdateConfig.partialUpdateMode || lastStatement.hasAnimationAttr) { if (statements.length) { reverse ? newStatements.push(...statements.reverse()) : newStatements.push(...statements); diff --git a/compiler/src/process_custom_component.ts b/compiler/src/process_custom_component.ts index c7c0c0ab9..2af6db5f0 100644 --- a/compiler/src/process_custom_component.ts +++ b/compiler/src/process_custom_component.ts @@ -101,7 +101,8 @@ import { transferBuilderCall, createCollectElmtIdNode, createViewStackProcessorStatement, - BuilderParamsResult + BuilderParamsResult, + isReuseStatement } from './process_component_build'; import { partialUpdateConfig, @@ -167,10 +168,16 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen let needCommon: boolean = false; if (hasChainCall) { if (partialUpdateConfig.partialUpdateMode) { - const commomComponentNode: ts.Statement[] = [ts.factory.createExpressionStatement( + let createStatment = ts.factory.createExpressionStatement( createFunction(ts.factory.createIdentifier(COMPONENT_COMMON), - ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null))]; + ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null)); + const commomComponentNode: ts.Statement[] = []; const immutableStatements: ts.Statement[] = []; + if(isReuseStatement(createStatment)) { + immutableStatements.push(createStatment); + } else { + commomComponentNode.push(createStatment); + } bindComponentAttr(node, ts.factory.createIdentifier(COMPONENT_COMMON), commomComponentNode, log, true, false, immutableStatements, false, componentAttrInfo); needCommon = commomComponentNode.length > 1 || immutableStatements.length > 0; diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts index 1aa178f87..2626e9786 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts @@ -139,54 +139,76 @@ class HomeComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.height(500); + if (isInitialRender) { + Column.create(); + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create(this.value1); + if (isInitialRender) { + Text.create(this.value1); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Radio.create({ value: "Radio", group: "1" }); + if (isInitialRender) { + Radio.create({ value: "Radio", group: "1" }); + } Radio.checked(this.value4, newValue => { this.value4 = newValue; }); }, Radio); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); - Row.width(20); + if (isInitialRender) { + Row.create(); + Row.width(20); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithChild(); + if (isInitialRender) { + Button.createWithChild(); + Button.width(100); + Button.height(20); + } Button.bindPopup({ value: this.value4, changeEvent: newValue => { this.value4 = newValue; } }, { message: "This is $$ for regular" }); - Button.width(100); - Button.height(20); }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create(this.value1); + if (isInitialRender) { + Text.create(this.value1); + } Text.bindPopup({ value: value5[0], changeEvent: newValue => { value5[0] = newValue; } }, { message: "This is $$ for Array" }); }, Text); Text.pop(); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create(this.value2); - Text.fontSize(100); + if (isInitialRender) { + Text.create(this.value2); + Text.fontSize(100); + } Text.bindPopup({ value: value6.item1, changeEvent: newValue => { value6.item1 = newValue; } }, { message: "This is $$ for Obj" }); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create(this.value3); + if (isInitialRender) { + Text.create(this.value3); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Radio.create({ value: "Radio", group: "1" }); + if (isInitialRender) { + Radio.create({ value: "Radio", group: "1" }); + } Radio.checked(value5[0], newValue => { value5[0] = newValue; }); }, Radio); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { TextTimer.create({ controller: this.myTimeController, isCountDown: { value: isCountDown, changeEvent: newValue => { isCountDown = newValue; } }, count: { value: this.count, changeEvent: newValue => { this.count = newValue; } } }); @@ -194,24 +216,30 @@ class HomeComponent extends ViewPU { }, TextTimer); TextTimer.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel("start"); - Button.onClick(() => { - this.myTimeController.start(); - }); + if (isInitialRender) { + Button.createWithLabel("start"); + Button.onClick(() => { + this.myTimeController.start(); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel("pause"); - Button.onClick(() => { - this.myTimeController.pause(); - }); + if (isInitialRender) { + Button.createWithLabel("pause"); + Button.onClick(() => { + this.myTimeController.pause(); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel("reset"); - Button.onClick(() => { - this.myTimeController.reset(); - }); + if (isInitialRender) { + Button.createWithLabel("reset"); + Button.onClick(() => { + this.myTimeController.reset(); + }); + } }, Button); Button.pop(); Row.pop(); -- Gitee From b6cb5a962778af59289e0d7464484b459193c2f5 Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Tue, 16 Jul 2024 16:27:25 +0800 Subject: [PATCH 11/18] fix bug of @State Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/process_component_build.ts | 41 ++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 8f9c605d7..6fda897fe 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -2307,7 +2307,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: } else { addComponentAttr(temp, temp.expression.name, lastStatement, statements, identifierNode, log, isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, - isRecycleComponent, isStyleFunction); + isRecycleComponent, isStyleFunction, complexAttrMap); } temp = temp.expression.expression; flag = true; @@ -2318,7 +2318,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: parseRecycleId(temp, temp.expression.name, isRecycleComponent, componentAttrInfo); addComponentAttr(temp, temp.expression, lastStatement, statements, identifierNode, log, isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, - isRecycleComponent, isStyleFunction); + isRecycleComponent, isStyleFunction, complexAttrMap); } break; } @@ -2834,7 +2834,7 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, statements: ts.Statement[], identifierNode: ts.Identifier, log: LogInfo[], isStylesAttr: boolean, immutableStatements: ts.Statement[], updateStatements: ts.Statement[], newImmutableStatements: ts.Statement[] = null, isRecycleComponent: boolean = false, - isStyleFunction: boolean = false): void { + isStyleFunction: boolean = false, complexAttrMap: Map): void { const propName: string = node.getText(); verifyComponentId(temp, node, propName, log); const extendType: ExtendType = {type: ''}; @@ -2901,8 +2901,41 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, const styleBlock: ts.Block = INNER_STYLE_FUNCTION.get(propName) || GLOBAL_STYLE_FUNCTION.get(propName); if (styleBlock.statements.length > 0) { + let styleBlockStatements : ts.Statement[] = []; + let styleBlockImmutableStatements: ts.Statement[] = []; bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode, - statements, log, false, true, newImmutableStatements); + styleBlockStatements, log, false, true, styleBlockImmutableStatements); + + styleBlockStatements.forEach((statement)=>{ + let expStatement = statement as ts.ExpressionStatement; + if(!ts.isCallExpression(expStatement.expression)) { + console.log("fuck! style function output is not a call?"); + } + let callExp = expStatement.expression as ts.CallExpression; + if(!ts.isPropertyAccessExpression(callExp.expression)){ + console.log("fuck! style function output is not a call wrap property access?"); + } + let propAccessExp = callExp.expression as ts.PropertyAccessExpression; + if(!complexAttrMap.has(propAccessExp.name.escapedText.toString())) { + // updateStatements.push(statement); + complexAttrMap.set(propAccessExp.name.escapedText.toString(),expStatement); + } + }); + styleBlockImmutableStatements.forEach((statement)=>{ + let expStatement = statement as ts.ExpressionStatement; + if(!ts.isCallExpression(expStatement.expression)) { + console.log("fuck! style function output is not a call?"); + } + let callExp = expStatement.expression as ts.CallExpression; + if(!ts.isPropertyAccessExpression(callExp.expression)){ + console.log("fuck! style function output is not a call wrap property access?"); + } + let propAccessExp = callExp.expression as ts.PropertyAccessExpression; + if(!complexAttrMap.has(propAccessExp.name.escapedText.toString())) { + // newImmutableStatements.push(statement); + complexAttrMap.set(propAccessExp.name.escapedText.toString(),expStatement); + } + }); if (isRecycleComponent) { bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode, updateStatements, log, false, true, newImmutableStatements, true); -- Gitee From c5a7b93e2ce381776bba321fb8c168429de68674 Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Tue, 16 Jul 2024 17:04:49 +0800 Subject: [PATCH 12/18] fix bug of tab Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/pre_define.ts | 3 + compiler/src/process_component_build.ts | 29 ++++++- .../import/import@CustomDialog.ts | 2 +- .../$$_component/$$_componentCheck1.ts | 87 +++++++++---------- .../$$_component/$$_componentCheck2.ts | 20 ++--- 5 files changed, 82 insertions(+), 59 deletions(-) diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index faa4ac5e7..61498ec5a 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -664,5 +664,8 @@ export const ATTRS_MAPPING = { }, "fontStyle": { "fontStyle": "fontStyle" + }, + "backgroundColor": { + "backgroundColor": "backgroundColor" } }; diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 6fda897fe..d5296bc02 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -1509,6 +1509,7 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. tabAttrs.push(createCollectElmtIdNode()); } const immutableStatements: ts.Statement[] = []; + const newStatements: ts.Statement[] = []; let judgeIdStart: number; if (idName) { judgeIdStart = innerCompStatements.length; @@ -1528,9 +1529,21 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression( ts.factory.createIdentifier(name), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, navDestinationCallback)); + let isTabContentReusable = false; + if(partialUpdateConfig.partialUpdateMode && isReuseStatement(tabContentCreation as ts.ExpressionStatement)) { + isTabContentReusable = true; + immutableStatements.push(tabContentCreation); + } else { + newStatements.push(tabContentCreation); + } bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableStatements); + newStatements.push(...tabAttrs); + if(partialUpdateConfig.partialUpdateMode && !isTabContentReusable) { + newStatements.push(...immutableStatements); + immutableStatements.length = 0; + } processInnerCompStatements( - innerCompStatements, [tabContentCreation, ...tabAttrs], node, isGlobalBuilder, false, + innerCompStatements, newStatements, node, isGlobalBuilder, false, nameResult, immutableStatements, name, builderParamsResult); storedFileInfo.lazyForEachInfo.isDependItem = false; } else { @@ -1538,9 +1551,21 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(name), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, name === NAV_DESTINATION ? navigationCreateParam(NAV_DESTINATION, COMPONENT_CREATE_FUNCTION) : [])); + let isTabContentReusable = false; + if(partialUpdateConfig.partialUpdateMode && isReuseStatement(tabContentCreation as ts.ExpressionStatement)) { + isTabContentReusable = true; + immutableStatements.push(tabContentCreation); + } else { + newStatements.push(tabContentCreation); + } bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableStatements); + newStatements.push(...tabAttrs); + if(partialUpdateConfig.partialUpdateMode && !isTabContentReusable) { + newStatements.push(...immutableStatements); + immutableStatements.length = 0; + } processInnerCompStatements( - innerCompStatements, [tabContentCreation, ...tabAttrs], node, isGlobalBuilder, false, + innerCompStatements, newStatements, node, isGlobalBuilder, false, nameResult, immutableStatements, name, builderParamsResult); } innerCompStatements.push(tabContentPop); diff --git a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts index 5aea2b053..b65f5d467 100644 --- a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts +++ b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts @@ -158,10 +158,10 @@ class CustomDialogUser extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.inputValue); + Button.backgroundColor(0x317aff); Button.onClick(() => { this.dialogController.open(); }); - Button.backgroundColor(0x317aff); }, Button); Button.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts index de9e61b49..59a088123 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts @@ -146,40 +146,45 @@ class TabsExample extends ViewPU { } tabBuilder(index, name, parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.create(); + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create(name); - Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); - Text.fontSize(16); + if (isInitialRender) { + Text.create(name); + Text.fontSize(16); + Text.lineHeight(22); + Text.margin({ top: 17, bottom: 7 }); + } Text.fontWeight(this.currentIndex === index ? 500 : 400); - Text.lineHeight(22); - Text.margin({ top: 17, bottom: 7 }); + Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Divider.create(); - Divider.strokeWidth(2); - Divider.color('#007DFF'); + if (isInitialRender) { + Divider.create(); + Divider.strokeWidth(2); + Divider.color('#007DFF'); + } Divider.opacity(this.currentIndex === index ? 1 : 0); }, Divider); Column.pop(); } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.create(); + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Tabs.create({ barPosition: BarPosition.Start, index: { value: this.currentIndex, changeEvent: newValue => { this.currentIndex = newValue; } }, controller: this.controller }); + Tabs.width(360); + Tabs.height(296); + Tabs.backgroundColor('#F1F3F5'); Tabs.vertical(false); - Tabs.width(150); - Tabs.height(100); - Tabs.backgroundColor(Color.Pink); - Tabs.width(150); - Tabs.height(100); - Tabs.backgroundColor(Color.Pink); Tabs.barMode(BarMode.Fixed); Tabs.barWidth(360); Tabs.barHeight(56); @@ -187,36 +192,28 @@ class TabsExample extends ViewPU { Tabs.onChange((index) => { this.currentIndex = index; }); - Tabs.width(360); - Tabs.height(296); Tabs.margin({ top: 52 }); - Tabs.backgroundColor('#F1F3F5'); }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { - TabContent.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); - Column.height('100%'); - Column.backgroundColor('#00CB87'); - Column.width(150); - Column.height(100); - Column.backgroundColor(Color.Pink); - Column.width(150); - Column.height(100); - Column.backgroundColor(Color.Pink); - }, Column); - Column.pop(); - }); - TabContent.tabBar({ builder: () => { - this.tabBuilder.call(this, 0, 'green'); - } }); - TabContent.width(150); - TabContent.height(100); - TabContent.backgroundColor(Color.Pink); - TabContent.width(150); - TabContent.height(100); - TabContent.backgroundColor(Color.Pink); + if (isInitialRender) { + TabContent.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + Column.create(); + Column.height(100); + Column.backgroundColor(Color.Pink); + Column.width(150); + } + }, Column); + Column.pop(); + }); + TabContent.height(100); + TabContent.backgroundColor(Color.Pink); + TabContent.width(150); + TabContent.tabBar({ builder: () => { + this.tabBuilder.call(this, 0, 'green'); + } }); + } }, TabContent); TabContent.pop(); Tabs.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts index 54c737cef..e09e3eebd 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts @@ -84,10 +84,12 @@ class TextInputExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create({ space: 20 }); - Column.width('100%'); - Column.height('100%'); - Column.justifyContent(FlexAlign.Center); + if (isInitialRender) { + Column.create({ space: 20 }); + Column.width('100%'); + Column.height('100%'); + Column.justifyContent(FlexAlign.Center); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.text); @@ -95,16 +97,12 @@ class TextInputExample extends ViewPU { Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TextInput.create({ text: { value: this.text, changeEvent: newValue => { this.text = newValue; } } }); - TextInput.placeholderColor(Color.Grey); - TextInput.placeholderFont({ size: 14, weight: 400 }); - TextInput.width(150); - TextInput.height(100); - TextInput.backgroundColor(Color.Pink); - TextInput.width(150); TextInput.height(100); TextInput.backgroundColor(Color.Pink); - TextInput.caretColor(Color.Blue); TextInput.width(300); + TextInput.placeholderColor(Color.Grey); + TextInput.placeholderFont({ size: 14, weight: 400 }); + TextInput.caretColor(Color.Blue); }, TextInput); Column.pop(); } -- Gitee From c1d788df4be9b835773989d293f5d1a373517d80 Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Mon, 29 Jul 2024 20:28:49 +0800 Subject: [PATCH 13/18] fix bug of style function Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/process_component_build.ts | 57 +++++++----- .../$$_component/$$_componentCheck1.ts | 4 +- .../$$_component/$$_componentCheck2.ts | 2 +- .../$$_component/$$_componentCheck3.ts | 35 ++++---- .../$$_component/$$_componentCheck4.ts | 35 ++++---- .../$$_component/$$_componentCheck5.ts | 20 ++--- .../$$_component/$$_componentCheck6.ts | 87 +++++++++---------- .../$$_component/$$_componentCheck7.ts | 41 ++++----- .../$$_component/$$_componentCheck8.ts | 41 ++++----- .../$$_component/$$_componentCheck9.ts | 10 ++- .../$$_component/$$_if_elseIf_else.ts | 8 +- .../custom_component/component_object.ts | 16 +++- .../custom_component/custom_component.ts | 40 ++++++--- .../gesture_component/GestureModeParallel.ts | 8 +- .../gesture_component/longPressGesture.ts | 14 +-- .../gesture_component/panGestrue.ts | 14 +-- .../gesture_component/pinchGesture.ts | 14 +-- .../gesture_component/rotationGesture.ts | 14 +-- .../gesture_component/swipeGesture.ts | 10 ++- .../gesture_component/tapGesture.ts | 18 ++-- .../foreach/forEachSecondFunction.ts | 30 ++++--- .../foreach/forEachThreeParam.ts | 8 +- .../render_component/foreach/forEachTwo.ts | 12 ++- .../render_component/foreach/foreach.ts | 4 +- .../render_component/if/id_if.ts | 82 ++++++++++------- .../render_component/if/if.ts | 20 +++-- .../render_component/item/GridItem.ts | 18 ++-- .../render_component/item/ListItem.ts | 18 ++-- .../lazyforeach/lazyforEachThreeParam.ts | 24 +++-- .../render_component/repeat/repeat.ts | 18 ++-- .../repeat/repeatVirtualScroll.ts | 6 +- .../render_component/tab/tab.ts | 62 ++++++++----- .../simple_component/button/button.ts | 56 +++++++----- .../xcomponent/XComponentContainer.ts | 16 +++- .../animateTo/animateTo.ts | 38 +++++--- .../navDestination_component.ts | 28 +++--- .../navigation/navigation_component.ts | 16 ++-- .../render_decorator/@styles/@styles.ts | 62 +++++++------ .../localStorage/localStorage.ts | 6 +- .../localStorage/localStorageForBoth.ts | 6 +- .../localStorage/localStorageForChainCall.ts | 4 +- .../localStorage/localStorageForRoute.ts | 6 +- .../localStorage/localStorageForStorage.ts | 6 +- .../localStorage/localStorageForThree.ts | 4 +- .../localStorage/localStorageForThreeParam.ts | 4 +- .../localStorage/localStorageParam.ts | 4 +- .../@link/@link.ts | 4 +- .../@objectLink/@objectLink.ts | 8 +- .../@prop/@prop.ts | 4 +- .../@prop/@propComplexType.ts | 8 +- .../@state/@state.ts | 4 +- .../@observed_@objectLink.ts | 16 +++- .../others/@watch/@watch.ts | 28 +++--- .../param_event_twoway_binding.ts | 4 +- 54 files changed, 691 insertions(+), 431 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index d5296bc02..2c73d2bec 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -196,9 +196,7 @@ import { curPropMap } from './process_component_member'; import { regularCollection } from './validate_ui_syntax'; import { To } from 'copy-webpack-plugin'; -function attrExpHasProp(temp: ts.CallExpression, propName : string, attrArgs : ts.Expression[]): boolean { - let attrAccessExp = temp.expression as ts.PropertyAccessExpression; - let expName = attrAccessExp.name.getText(); +function attrExpHasProp(temp: ts.CallExpression, expName : string, propName : string, attrArgs : ts.Expression[]): boolean { if(expName == propName) { attrArgs.push(...temp.arguments); @@ -2214,7 +2212,7 @@ function isXComponentContainer(item: ts.PropertyAssignment): boolean { function isReuseArgument(argument : ts.Expression): boolean { - const mayChangedAnnotation : Set = new Set(["@State", "@ObjectLink"]); + const mayChangedAnnotation : Set = new Set(["@State", "@ObjectLink", "@Prop", "@Link"]); if(ts.isObjectLiteralExpression(argument)) { let props = argument.properties; for(let prop of props as ts.NodeArray) { @@ -2341,9 +2339,13 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: !GESTURE_TYPE_NAMES.has(temp.expression.getText()) && !componentCollection.customComponents.has(temp.expression.getText())) { parseRecycleId(temp, temp.expression.name, isRecycleComponent, componentAttrInfo); - addComponentAttr(temp, temp.expression, lastStatement, statements, identifierNode, log, - isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, - isRecycleComponent, isStyleFunction, complexAttrMap); + if (partialUpdateConfig.partialUpdateMode && HANDLE_COMPLEX_ATTRS.has(temp.expression.getText())) { + collectComplextComponentAttr(temp, complexAttrMap, identifierNode); + } else { + addComponentAttr(temp, temp.expression, lastStatement, statements, identifierNode, log, + isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, + isRecycleComponent, isStyleFunction, complexAttrMap); + } } break; } @@ -2354,6 +2356,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: if (complexAttrMap.size) { for (let [ _ , statement] of complexAttrMap.entries()) { + if (!statement) continue; statements.push(statement); if(isReuseStatement(statement)) immutableStatements.push(statement); @@ -2841,13 +2844,17 @@ function createAttrFunction(node : ts.Identifier, name: string, argumentsArr : t function collectComplextComponentAttr(temp : ts.CallExpression, complexAttrMap: Map, identifierNode: ts.Identifier): void { - let attrAccessExp = temp.expression as ts.PropertyAccessExpression; - const expName = attrAccessExp.name.getText(); + let expName : string; + if (ts.isPropertyAccessExpression(temp.expression)) { + expName = temp.expression.name.getText(); + } else if(ts.isIdentifier(temp.expression)) { + expName = temp.expression.getText(); + } let map = HANDLE_COMPLEX_ATTRS.get(expName); for(let [propName, attrName] of map.entries()) { const attrArgs : ts.Expression[] = []; - if (!complexAttrMap.has(attrName) && attrExpHasProp(temp, propName, attrArgs)) { + if (!complexAttrMap.has(attrName) && attrExpHasProp(temp, expName, propName, attrArgs)) { const attrStatement: ts.ExpressionStatement = ts.factory.createExpressionStatement( createAttrFunction(identifierNode, attrName, attrArgs)); complexAttrMap.set(attrName, attrStatement); @@ -2941,9 +2948,13 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, console.log("fuck! style function output is not a call wrap property access?"); } let propAccessExp = callExp.expression as ts.PropertyAccessExpression; - if(!complexAttrMap.has(propAccessExp.name.escapedText.toString())) { - // updateStatements.push(statement); - complexAttrMap.set(propAccessExp.name.escapedText.toString(),expStatement); + let compExp = propAccessExp.expression as ts.Identifier; + if(!complexAttrMap.has(propAccessExp.name.escapedText.toString()) + || compExp.escapedText.toString() != identifierNode.escapedText.toString()) { + statements.push(statement); + updateStatements.push(statement); + if(compExp.escapedText.toString() == identifierNode.escapedText.toString()) + complexAttrMap.set(propAccessExp.name.escapedText.toString(), null); } }); styleBlockImmutableStatements.forEach((statement)=>{ @@ -2956,15 +2967,19 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, console.log("fuck! style function output is not a call wrap property access?"); } let propAccessExp = callExp.expression as ts.PropertyAccessExpression; - if(!complexAttrMap.has(propAccessExp.name.escapedText.toString())) { - // newImmutableStatements.push(statement); - complexAttrMap.set(propAccessExp.name.escapedText.toString(),expStatement); + let compExp = propAccessExp.expression as ts.Identifier; + if(!complexAttrMap.has(propAccessExp.name.escapedText.toString()) + || compExp.escapedText.toString()!= identifierNode.escapedText.toString()) { + statements.push(statement) + newImmutableStatements.push(statement); + if(compExp.escapedText.toString() == identifierNode.escapedText.toString()) + complexAttrMap.set(propAccessExp.name.escapedText.toString(), null); } }); - if (isRecycleComponent) { - bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode, - updateStatements, log, false, true, newImmutableStatements, true); - } + // if (isRecycleComponent) { + // bindComponentAttr(styleBlock.statements[0] as ts.ExpressionStatement, identifierNode, + // updateStatements, log, false, true, newImmutableStatements, true); + // } } lastStatement.kind = true; } else if (isDoubleDollarToChange(isStylesAttr, identifierNode, propName, temp)) { @@ -2987,7 +3002,7 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, createFunction(identifierNode, node, temp.arguments, isAttributeModifier)); statements.push(attrStatement); if ((isReuseStatement(attrStatement as ts.ExpressionStatement)||filterRegularAttrNode(temp.arguments)) - && (!isStylesAttr || isStyleFunction) && !isGestureType(identifierNode)) { + && !isGestureType(identifierNode)) { immutableStatements.push(attrStatement); } else { updateStatements.push(attrStatement); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts index 59a088123..05d33a10b 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts @@ -200,15 +200,15 @@ class TabsExample extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { if (isInitialRender) { Column.create(); - Column.height(100); Column.backgroundColor(Color.Pink); + Column.height(100); Column.width(150); } }, Column); Column.pop(); }); - TabContent.height(100); TabContent.backgroundColor(Color.Pink); + TabContent.height(100); TabContent.width(150); TabContent.tabBar({ builder: () => { this.tabBuilder.call(this, 0, 'green'); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts index e09e3eebd..de8b66be7 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts @@ -97,8 +97,8 @@ class TextInputExample extends ViewPU { Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TextInput.create({ text: { value: this.text, changeEvent: newValue => { this.text = newValue; } } }); - TextInput.height(100); TextInput.backgroundColor(Color.Pink); + TextInput.height(100); TextInput.width(300); TextInput.placeholderColor(Color.Grey); TextInput.placeholderFont({ size: 14, weight: 400 }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts index 39c763f5d..d279bd5c0 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts @@ -90,32 +90,33 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); if (1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Checkbox.create(); + if (isInitialRender) { + Checkbox.create(); + Checkbox.backgroundColor(Color.Pink); + Checkbox.width(30); + Checkbox.height(30); + Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); + Checkbox.selectedColor('red'); + Checkbox.unselectedColor('red'); + Checkbox.mark({ + strokeColor: 'red' + }); + } Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); - Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); - Checkbox.selectedColor('red'); - Checkbox.unselectedColor('red'); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.mark({ - strokeColor: 'red' - }); - Checkbox.width(30); - Checkbox.height(30); }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts index 74169c7a6..e1d7162e5 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts @@ -89,32 +89,33 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); if (1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Checkbox.create(); + if (isInitialRender) { + Checkbox.create(); + Checkbox.backgroundColor(Color.Pink); + Checkbox.width(30); + Checkbox.height(30); + Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); + Checkbox.selectedColor('red'); + Checkbox.unselectedColor('red'); + Checkbox.mark({ + strokeColor: 'red' + }); + } Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); - Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); - Checkbox.selectedColor('red'); - Checkbox.unselectedColor('red'); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.mark({ - strokeColor: 'red' - }); - Checkbox.width(30); - Checkbox.height(30); }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts index a87333c3d..cf6372dca 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts @@ -84,10 +84,12 @@ class TextInputExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create({ space: 20 }); - Column.width('100%'); - Column.height('100%'); - Column.justifyContent(FlexAlign.Center); + if (isInitialRender) { + Column.create({ space: 20 }); + Column.width('100%'); + Column.height('100%'); + Column.justifyContent(FlexAlign.Center); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.text); @@ -95,16 +97,12 @@ class TextInputExample extends ViewPU { Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TextInput.create({ text: { value: this.text, changeEvent: newValue => { this.text = newValue; } } }); - TextInput.placeholderColor(Color.Grey); - TextInput.placeholderFont({ size: 14, weight: 400 }); - TextInput.width(150); - TextInput.height(100); TextInput.backgroundColor(Color.Pink); - TextInput.width(150); TextInput.height(100); - TextInput.backgroundColor(Color.Pink); - TextInput.caretColor(Color.Blue); TextInput.width(300); + TextInput.placeholderColor(Color.Grey); + TextInput.placeholderFont({ size: 14, weight: 400 }); + TextInput.caretColor(Color.Blue); }, TextInput); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts index 57c813d60..c6a4eeeab 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts @@ -146,40 +146,45 @@ class TabsExample extends ViewPU { } tabBuilder(index, name, parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.create(); + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create(name); - Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); - Text.fontSize(16); + if (isInitialRender) { + Text.create(name); + Text.fontSize(16); + Text.lineHeight(22); + Text.margin({ top: 17, bottom: 7 }); + } Text.fontWeight(this.currentIndex === index ? 500 : 400); - Text.lineHeight(22); - Text.margin({ top: 17, bottom: 7 }); + Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Divider.create(); - Divider.strokeWidth(2); - Divider.color('#007DFF'); + if (isInitialRender) { + Divider.create(); + Divider.strokeWidth(2); + Divider.color('#007DFF'); + } Divider.opacity(this.currentIndex === index ? 1 : 0); }, Divider); Column.pop(); } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.create(); + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Tabs.create({ barPosition: BarPosition.Start, index: { value: this.currentIndex, changeEvent: newValue => { this.currentIndex = newValue; } }, controller: this.controller }); + Tabs.width(360); + Tabs.height(296); + Tabs.backgroundColor('#F1F3F5'); Tabs.vertical(false); - Tabs.width(150); - Tabs.height(100); - Tabs.backgroundColor(Color.Pink); - Tabs.width(150); - Tabs.height(100); - Tabs.backgroundColor(Color.Pink); Tabs.barMode(BarMode.Fixed); Tabs.barWidth(360); Tabs.barHeight(56); @@ -187,36 +192,28 @@ class TabsExample extends ViewPU { Tabs.onChange((index) => { this.currentIndex = index; }); - Tabs.width(360); - Tabs.height(296); Tabs.margin({ top: 52 }); - Tabs.backgroundColor('#F1F3F5'); }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { - TabContent.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); - Column.height('100%'); - Column.backgroundColor('#00CB87'); - Column.width(150); - Column.height(100); - Column.backgroundColor(Color.Pink); - Column.width(150); - Column.height(100); - Column.backgroundColor(Color.Pink); - }, Column); - Column.pop(); - }); - TabContent.tabBar({ builder: () => { - this.tabBuilder.call(this, 0, 'green'); - } }); - TabContent.width(150); - TabContent.height(100); - TabContent.backgroundColor(Color.Pink); - TabContent.width(150); - TabContent.height(100); - TabContent.backgroundColor(Color.Pink); + if (isInitialRender) { + TabContent.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + Column.create(); + Column.backgroundColor(Color.Pink); + Column.height(100); + Column.width(150); + } + }, Column); + Column.pop(); + }); + TabContent.backgroundColor(Color.Pink); + TabContent.height(100); + TabContent.width(150); + TabContent.tabBar({ builder: () => { + this.tabBuilder.call(this, 0, 'green'); + } }); + } }, TabContent); TabContent.pop(); Tabs.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts index 5a1b066b0..01d27ba8c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts @@ -118,35 +118,36 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); if (1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Checkbox.create(); + if (isInitialRender) { + Checkbox.create(); + Checkbox.backgroundColor(Color.Pink); + Checkbox.width(dd().ee); + Checkbox.height(30); + Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); + Checkbox.selectedColor(xx()); + Checkbox.unselectedColor(bb().cc); + Checkbox.mark({ + strokeColor: aa() + }); + Checkbox.mark({ + strokeColor: 'red' + }); + } Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); - Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); - Checkbox.selectedColor(xx()); - Checkbox.unselectedColor(bb().cc); - Checkbox.mark({ - strokeColor: aa() - }); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.mark({ - strokeColor: 'red' - }); - Checkbox.width(dd().ee); - Checkbox.height(30); }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts index 5a1b066b0..01d27ba8c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts @@ -118,35 +118,36 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); if (1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Checkbox.create(); + if (isInitialRender) { + Checkbox.create(); + Checkbox.backgroundColor(Color.Pink); + Checkbox.width(dd().ee); + Checkbox.height(30); + Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); + Checkbox.selectedColor(xx()); + Checkbox.unselectedColor(bb().cc); + Checkbox.mark({ + strokeColor: aa() + }); + Checkbox.mark({ + strokeColor: 'red' + }); + } Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); - Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); - Checkbox.selectedColor(xx()); - Checkbox.unselectedColor(bb().cc); - Checkbox.mark({ - strokeColor: aa() - }); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.width(150); - Checkbox.height(100); - Checkbox.backgroundColor(Color.Pink); - Checkbox.mark({ - strokeColor: 'red' - }); - Checkbox.width(dd().ee); - Checkbox.height(30); }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts index e5d063316..104ee7f08 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts @@ -111,11 +111,15 @@ class SheetSizeExample1 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.justifyContent(FlexAlign.Start); + if (isInitialRender) { + Column.create(); + Column.justifyContent(FlexAlign.Start); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel("transition modal 1"); + if (isInitialRender) { + Button.createWithLabel("transition modal 1"); + } Button.bindSheet({ value: this.isShow, changeEvent: newValue => { this.isShow = newValue; } }, { builder: () => { this.myBuilder.call(this); } }, { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_if_elseIf_else.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_if_elseIf_else.ts index 37b4d21f0..e40d982bf 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_if_elseIf_else.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_if_elseIf_else.ts @@ -91,10 +91,14 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.message); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/component_object.ts b/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/component_object.ts index a893abe82..0a35149e6 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/component_object.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/component_object.ts @@ -97,7 +97,9 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -185,7 +187,9 @@ class Child extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.message1); @@ -222,10 +226,14 @@ class Child2 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create(this.message); + if (isInitialRender) { + Text.create(this.message); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts index 38b6280a0..dcf088a28 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts @@ -71,7 +71,9 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -89,8 +91,10 @@ class MyComponent extends ViewPU { }, { name: "Banner" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { - __Common__.create(); - __Common__.width(100); + if (isInitialRender) { + __Common__.create(); + __Common__.width(100); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -109,9 +113,11 @@ class MyComponent extends ViewPU { } __Common__.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - __Common__.create(); - __Common__.width(100); - __Common__.height(200); + if (isInitialRender) { + __Common__.create(); + __Common__.width(100); + __Common__.height(200); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -147,8 +153,10 @@ class MyComponent extends ViewPU { }, { name: "Banner" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { - __Common__.create(); - __Common__.width(100); + if (isInitialRender) { + __Common__.create(); + __Common__.width(100); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -169,9 +177,11 @@ class MyComponent extends ViewPU { } __Common__.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - __Common__.create(); - __Common__.width(100); - __Common__.height(200); + if (isInitialRender) { + __Common__.create(); + __Common__.width(100); + __Common__.height(200); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -222,10 +232,14 @@ class Banner extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create(this.value); + if (isInitialRender) { + Text.create(this.value); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/GestureModeParallel.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/GestureModeParallel.ts index 7a869af4c..17238ae38 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/GestureModeParallel.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/GestureModeParallel.ts @@ -65,10 +65,14 @@ class childTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create("hello"); + if (isInitialRender) { + Text.create("hello"); + } Gesture.create(GesturePriority.Low); GestureGroup.create(GestureMode.Parallel); TapGesture.create({ count: 2 }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts index e5e70abfe..ac78e163c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts @@ -74,12 +74,14 @@ class LongPressGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(200); - Flex.width(300); - Flex.padding(60); - Flex.border({ width: 1 }); - Flex.margin(30); + if (isInitialRender) { + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); + Flex.height(200); + Flex.width(300); + Flex.borderWidth(1); + Flex.padding(60); + Flex.margin(30); + } Gesture.create(GesturePriority.Low); LongPressGesture.create({ repeat: true }); LongPressGesture.onAction((event) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts index b42ca935e..2aeb27bb5 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts @@ -94,12 +94,14 @@ class PanGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(100); - Flex.width(200); - Flex.padding(20); - Flex.border({ width: 1 }); - Flex.margin(80); + if (isInitialRender) { + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); + Flex.height(100); + Flex.width(200); + Flex.borderWidth(1); + Flex.padding(20); + Flex.margin(80); + } Flex.translate({ x: this.offsetX, y: this.offsetY, z: 5 }); Gesture.create(GesturePriority.Low); PanGesture.create({}); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts index 57a22fae5..50db1f4b5 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts @@ -78,12 +78,14 @@ class PinchGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(100); - Flex.width(200); - Flex.padding(20); - Flex.border({ width: 1 }); - Flex.margin(80); + if (isInitialRender) { + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); + Flex.height(100); + Flex.width(200); + Flex.borderWidth(1); + Flex.padding(20); + Flex.margin(80); + } Flex.scale({ x: this.scale2, y: this.scale2, z: this.scale2 }); Gesture.create(GesturePriority.Low); PinchGesture.create(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts index 41b224b56..21883f921 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts @@ -78,12 +78,14 @@ class RotationGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(100); - Flex.width(200); - Flex.padding(20); - Flex.border({ width: 1 }); - Flex.margin(80); + if (isInitialRender) { + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); + Flex.height(100); + Flex.width(200); + Flex.borderWidth(1); + Flex.padding(20); + Flex.margin(80); + } Flex.rotate({ x: 1, y: 2, z: 3, angle: this.angle }); Gesture.create(GesturePriority.Low); RotationGesture.create(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts index c2fe439a4..180f45064 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts @@ -88,10 +88,12 @@ class SwipeGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.border({ width: 2 }); - Column.width(260); - Column.height(260); + if (isInitialRender) { + Column.create(); + Column.borderWidth(2); + Column.width(260); + Column.height(260); + } Column.rotate({ x: 0, y: 0, z: 1, angle: this.rotateAngle }); Gesture.create(GesturePriority.Low); SwipeGesture.create({ fingers: 1, direction: SwipeDirection.Vertical }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts index be082149e..1c1958c60 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts @@ -72,12 +72,14 @@ class TapGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(200); - Flex.width(300); - Flex.padding(60); - Flex.border({ width: 1 }); - Flex.margin(30); + if (isInitialRender) { + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); + Flex.height(200); + Flex.width(300); + Flex.borderWidth(1); + Flex.padding(60); + Flex.margin(30); + } Gesture.create(GesturePriority.Low); TapGesture.create({ count: 2 }); TapGesture.onAction(() => { @@ -87,7 +89,9 @@ class TapGestureExample extends ViewPU { Gesture.pop(); }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('Click twice'); + if (isInitialRender) { + Text.create('Click twice'); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts index 49aaa968c..63af46d2c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts @@ -70,15 +70,19 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create({ space: 5 }); - Column.width("100%"); - Column.height("100%"); + if (isInitialRender) { + Column.create({ space: 5 }); + Column.width("100%"); + Column.height("100%"); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel('Reverse Array'); - Button.onClick(() => { - this.arr.reverse(); - }); + if (isInitialRender) { + Button.createWithLabel('Reverse Array'); + Button.onClick(() => { + this.arr.reverse(); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -86,13 +90,17 @@ class MyComponent extends ViewPU { const forEachItemGenFunction = _item => { const item = _item; this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('item'); - Text.fontSize(18); + if (isInitialRender) { + Text.create('item'); + Text.fontSize(18); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Divider.create(); - Divider.strokeWidth(2); + if (isInitialRender) { + Divider.create(); + Divider.strokeWidth(2); + } }, Divider); }; this.forEachUpdateFunction(elmtId, this.arr, forEachItemGenFunction, (item) => item.toString(), false, false); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts index 1c1375b15..84ea9823d 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts @@ -85,14 +85,18 @@ class foreachThreeParam extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); const forEachItemGenFunction = _item => { const item = _item; this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create(item); + if (isInitialRender) { + Text.create(item); + } }, Text); Text.pop(); }; diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts index 2631ef098..131140040 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts @@ -83,12 +83,16 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); - Row.height('100%'); + if (isInitialRender) { + Row.create(); + Row.height('100%'); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.create(); + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts index e8cfc46c3..4ef610312 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts @@ -160,7 +160,9 @@ class ParentView extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create(); + if (isInitialRender) { + List.create(); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts index c03aab1c2..2038539bc 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts @@ -147,7 +147,9 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); @@ -159,9 +161,11 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(0, () => { if (!If.canRetake('id1')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('count is negative'); - Text.fontSize(32); - Text.id('id1'); + if (isInitialRender) { + Text.create('count is negative'); + Text.fontSize(32); + Text.id('id1'); + } }, Text); Text.pop(); } @@ -171,15 +175,19 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(1, () => { if (!If.canRetake('id2')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - Divider.create(); - Divider.id('id2'); + if (isInitialRender) { + Divider.create(); + Divider.id('id2'); + } }, Divider); } if (!If.canRetake('id3')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('even'); - Text.fontSize(32); - Text.id('id3'); + if (isInitialRender) { + Text.create('even'); + Text.fontSize(32); + Text.id('id3'); + } }, Text); Text.pop(); } @@ -189,19 +197,25 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(2, () => { if (!If.canRetake('id4')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - Divider.create(); - Divider.id('id4'); + if (isInitialRender) { + Divider.create(); + Divider.id('id4'); + } }, Divider); } if (!If.canRetake('id10')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.id('id10'); + if (isInitialRender) { + Column.create(); + Column.id('id10'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('odd'); - Text.fontSize(32); - Text.id('id5'); + if (isInitialRender) { + Text.create('odd'); + Text.fontSize(32); + Text.id('id5'); + } }, Text); Text.pop(); Column.pop(); @@ -216,9 +230,11 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(1, () => { if (!If.canRetake('id6')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('fail'); - Text.id('id6'); - Text.fontSize(32); + if (isInitialRender) { + Text.create('fail'); + Text.id('id6'); + Text.fontSize(32); + } }, Text); Text.pop(); } @@ -232,9 +248,11 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(0, () => { if (!If.canRetake('id7')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('odd2'); - Text.fontSize(32); - Text.id('id7'); + if (isInitialRender) { + Text.create('odd2'); + Text.fontSize(32); + Text.id('id7'); + } }, Text); Text.pop(); } @@ -247,7 +265,9 @@ class MyComponent extends ViewPU { }, If); If.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create({ space: 3 }); + if (isInitialRender) { + List.create({ space: 3 }); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); @@ -270,14 +290,18 @@ class MyComponent extends ViewPU { const deepRenderFunction = (elmtId, isInitialRender) => { itemCreation(elmtId, isInitialRender); this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); - Row.margin({ left: 10, right: 10 }); - Row.id('id11'); + if (isInitialRender) { + Row.create(); + Row.margin({ left: 10, right: 10 }); + Row.id('id11'); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create(); - Text.fontSize(20); - Text.margin({ left: 10 }); + if (isInitialRender) { + Text.create(); + Text.fontSize(20); + Text.margin({ left: 10 }); + } }, Text); Text.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts index 9137624c1..e819b090c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts @@ -108,7 +108,9 @@ class IFView extends ViewPU { if (this.toggle1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('toggle1'); + if (isInitialRender) { + Text.create('toggle1'); + } }, Text); Text.pop(); }); @@ -116,7 +118,9 @@ class IFView extends ViewPU { else if (this.toggle2) { this.ifElseBranchUpdateFunction(1, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('toggle2'); + if (isInitialRender) { + Text.create('toggle2'); + } }, Text); Text.pop(); }); @@ -124,7 +128,9 @@ class IFView extends ViewPU { else if (this.toggle3) { this.ifElseBranchUpdateFunction(2, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('toggle3'); + if (isInitialRender) { + Text.create('toggle3'); + } }, Text); Text.pop(); }); @@ -132,7 +138,9 @@ class IFView extends ViewPU { else { this.ifElseBranchUpdateFunction(3, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('toggle no thing'); + if (isInitialRender) { + Text.create('toggle no thing'); + } }, Text); Text.pop(); }); @@ -144,7 +152,9 @@ class IFView extends ViewPU { if (this.toggle1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('toggle1 Single'); + if (isInitialRender) { + Text.create('toggle1 Single'); + } }, Text); Text.pop(); }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts index 5eba71354..8b1c3f7f0 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts @@ -52,19 +52,25 @@ class ParentView extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Grid.create(); + if (isInitialRender) { + Grid.create(); + } }, Grid); { const itemCreation2 = (elmtId, isInitialRender) => { - GridItem.create(() => { }, false, 'true'); - GridItem.width(200); - GridItem.height(100); + if (isInitialRender) { + GridItem.create(() => { }, false, 'true'); + GridItem.width(200); + GridItem.height(100); + } }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, GridItem); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('xx'); - Text.width(100); + if (isInitialRender) { + Text.create('xx'); + Text.width(100); + } }, Text); Text.pop(); GridItem.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts index 67520dff1..604124e83 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts @@ -52,7 +52,9 @@ class ParentView extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create(); + if (isInitialRender) { + List.create(); + } }, List); { const itemCreation = (elmtId, isInitialRender) => { @@ -64,15 +66,19 @@ class ParentView extends ViewPU { ViewStackProcessor.StopGetAccessRecording(); }; const itemCreation2 = (elmtId, isInitialRender) => { - ListItem.create(deepRenderFunction, true, 'true'); - ListItem.width(200); - ListItem.height(100); + if (isInitialRender) { + ListItem.create(deepRenderFunction, true, 'true'); + ListItem.width(200); + ListItem.height(100); + } }; const deepRenderFunction = (elmtId, isInitialRender) => { itemCreation(elmtId, isInitialRender); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('xx'); - Text.width(100); + if (isInitialRender) { + Text.create('xx'); + Text.width(100); + } }, Text); Text.pop(); ListItem.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts index 70547fc09..69acdf4e6 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts @@ -256,8 +256,10 @@ class lazyforEachThreeParam extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create({ space: 3 }); - List.cachedCount(5); + if (isInitialRender) { + List.create({ space: 3 }); + List.cachedCount(5); + } }, List); { const __lazyForEachItemGenFunction = _item => { @@ -269,8 +271,10 @@ class lazyforEachThreeParam extends ViewPU { const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, ListItem); this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); - Row.margin({ left: 10, right: 10 }); + if (isInitialRender) { + Row.create(); + Row.margin({ left: 10, right: 10 }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(item); @@ -300,8 +304,10 @@ class lazyforEachThreeParam extends ViewPU { const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, ListItem); this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); - Row.margin({ left: 10, right: 10 }); + if (isInitialRender) { + Row.create(); + Row.margin({ left: 10, right: 10 }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(item); @@ -331,8 +337,10 @@ class lazyforEachThreeParam extends ViewPU { const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, ListItem); this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); - Row.margin({ left: 10, right: 10 }); + if (isInitialRender) { + Row.create(); + Row.margin({ left: 10, right: 10 }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(item); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts index 894ab0ddd..b5308ecf0 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts @@ -118,8 +118,10 @@ class HomeComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.height(500); + if (isInitialRender) { + Column.create(); + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Repeat(this.arr, this).each((obj) => { @@ -186,8 +188,10 @@ class ChildComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.height(500); + if (isInitialRender) { + Column.create(); + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Repeat(this.arr, this).onMove((from, to) => { @@ -243,8 +247,10 @@ class ChildComponent2 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create(); - List.height(500); + if (isInitialRender) { + List.create(); + List.height(500); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { Repeat(this.arr, this).each((obj) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts index a8533218d..fd734725e 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts @@ -98,8 +98,10 @@ class ChildComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create(); - List.height(500); + if (isInitialRender) { + List.create(); + List.height(500); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { Repeat(this.arr, this).each((obj) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts index ccdae0985..b069c48e8 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts @@ -81,33 +81,45 @@ class TabSimple extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Tabs.create({ barPosition: BarPosition.Start, index: 1, controller: this.controller }); + if (isInitialRender) { + Tabs.create({ barPosition: BarPosition.Start, index: 1, controller: this.controller }); + } }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Flex.create(); - Flex.height(100); - Flex.width(200); + if (isInitialRender) { + Flex.create(); + Flex.height(100); + Flex.width(200); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.height(100); - Column.width(200); + if (isInitialRender) { + Column.create(); + Column.height(100); + Column.width(200); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('text1'); - Text.height(100); - Text.width(200); + if (isInitialRender) { + Text.create('text1'); + Text.height(100); + Text.width(200); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('xxx'); - Text.height(100); - Text.width(200); + if (isInitialRender) { + Text.create('xxx'); + Text.height(100); + Text.width(200); + } }, Text); Text.pop(); Column.pop(); @@ -119,15 +131,19 @@ class TabSimple extends ViewPU { }, TabContent); TabContent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - TabContent.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('text2'); - }, Text); - Text.pop(); - }); - TabContent.tabBar("TabBar 2"); - TabContent.height(100); - TabContent.width(200); + if (isInitialRender) { + TabContent.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + Text.create('text2'); + } + }, Text); + Text.pop(); + }); + TabContent.tabBar("TabBar 2"); + TabContent.height(100); + TabContent.width(200); + } }, TabContent); TabContent.pop(); Tabs.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts index 1e2ee909b..929788bf0 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts @@ -59,43 +59,57 @@ class ButtonExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }); + if (isInitialRender) { + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { - Flex.create({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); + if (isInitialRender) { + Flex.create({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel('Ok', { type: ButtonType.Normal, stateEffect: true }); - Button.borderRadius(8); - Button.backgroundColor(0x317aff); - Button.width(90); + if (isInitialRender) { + Button.createWithLabel('Ok', { type: ButtonType.Normal, stateEffect: true }); + Button.borderRadius(8); + Button.backgroundColor(0x317aff); + Button.width(90); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithChild({ type: ButtonType.Normal, stateEffect: true }); - Button.borderRadius(8); - Button.backgroundColor(0x317aff); - Button.width(90); + if (isInitialRender) { + Button.createWithChild({ type: ButtonType.Normal, stateEffect: true }); + Button.borderRadius(8); + Button.backgroundColor(0x317aff); + Button.width(90); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); - Row.alignItems(VerticalAlign.Center); + if (isInitialRender) { + Row.create(); + Row.alignItems(VerticalAlign.Center); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('loading'); - Text.fontSize(12); - Text.fontColor(0xffffff); - Text.margin({ left: 5, right: 12 }); + if (isInitialRender) { + Text.create('loading'); + Text.fontSize(12); + Text.fontColor(0xffffff); + Text.margin({ left: 5, right: 12 }); + } }, Text); Text.pop(); Row.pop(); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel('Disable', { type: ButtonType.Normal, stateEffect: false }); - Button.opacity(0.5); - Button.borderRadius(8); - Button.backgroundColor(0x317aff); - Button.width(90); + if (isInitialRender) { + Button.createWithLabel('Disable', { type: ButtonType.Normal, stateEffect: false }); + Button.opacity(0.5); + Button.borderRadius(8); + Button.backgroundColor(0x317aff); + Button.width(90); + } }, Button); Button.pop(); Flex.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/xcomponent/XComponentContainer.ts b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/xcomponent/XComponentContainer.ts index f9eb9354d..b62c9175c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/xcomponent/XComponentContainer.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/xcomponent/XComponentContainer.ts @@ -54,18 +54,26 @@ class HomeComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - XComponent.create({ id: '1', type: 'component' }); + if (isInitialRender) { + XComponent.create({ id: '1', type: 'component' }); + } }, XComponent); XComponent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - XComponent.create({ id: '2', type: 1 }); + if (isInitialRender) { + XComponent.create({ id: '2', type: 1 }); + } }, XComponent); XComponent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - XComponent.create({ id: '3', type: XComponentType.COMPONENT }); + if (isInitialRender) { + XComponent.create({ id: '3', type: XComponentType.COMPONENT }); + } }, XComponent); XComponent.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts index c5569b795..850784391 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts @@ -216,10 +216,12 @@ class TransitionExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, }); - Flex.height(400); - Flex.width("100%"); - Flex.padding({ top: 100 }); + if (isInitialRender) { + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, }); + Flex.height(400); + Flex.width("100%"); + Flex.padding({ top: 100 }); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.show); @@ -241,11 +243,13 @@ class TransitionExample extends ViewPU { if (this.btn1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel(); - Button.width("80%"); - Button.height(30); - Button.transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } }); - Button.transition({ type: TransitionType.Delete, scale: { x: 1.0, y: 0.0 } }); + if (isInitialRender) { + Button.createWithLabel(); + Button.width("80%"); + Button.height(30); + Button.transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } }); + Button.transition({ type: TransitionType.Delete, scale: { x: 1.0, y: 0.0 } }); + } }, Button); Button.pop(); }); @@ -257,7 +261,9 @@ class TransitionExample extends ViewPU { }, If); If.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel('animation'); + if (isInitialRender) { + Button.createWithLabel('animation'); + } Context.animation({ duration: 1000, curve: Curve.EaseOut, @@ -274,12 +280,16 @@ class TransitionExample extends ViewPU { }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create({ space: 5 }); - Column.width("100%"); - Column.height("100%"); + if (isInitialRender) { + Column.create({ space: 5 }); + Column.width("100%"); + Column.height("100%"); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } Context.animation({ duration: 1000 }); Column.opacity(this.opacity1); Column.backgroundColor(ObservedObject.GetRawObject(this.color)); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts index b9b83cf64..c4958e695 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts @@ -61,22 +61,28 @@ class PageOne extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - NavDestination.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); - Column.height('100%'); - }, Column); - Column.pop(); - }, { moduleName: "", pagePath: "navDestination_component" }); - NavDestination.title('pageOne'); + if (isInitialRender) { + NavDestination.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + Column.width('100%'); + Column.height('100%'); + }, Column); + Column.pop(); + }, { moduleName: "", pagePath: "navDestination_component" }); + NavDestination.title('pageOne'); + } }, NavDestination); NavDestination.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - NavDestination.create(() => { }, { moduleName: "", pagePath: "navDestination_component" }); + if (isInitialRender) { + NavDestination.create(() => { }, { moduleName: "", pagePath: "navDestination_component" }); + } }, NavDestination); NavDestination.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts index 2b5c49ede..5312ad94c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts @@ -61,16 +61,22 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - Navigation.create(this.pageStack, { moduleName: "", pagePath: "navigation_component", isUserCreateStack: true }); - Navigation.title('Main'); + if (isInitialRender) { + Navigation.create(this.pageStack, { moduleName: "", pagePath: "navigation_component", isUserCreateStack: true }); + Navigation.title('Main'); + } }, Navigation); Navigation.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Navigation.create(new NavPathStack(), { moduleName: "", pagePath: "navigation_component", isUserCreateStack: false }); - Navigation.title('Main'); + if (isInitialRender) { + Navigation.create(new NavPathStack(), { moduleName: "", pagePath: "navigation_component", isUserCreateStack: false }); + Navigation.title('Main'); + } }, Navigation); Navigation.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts b/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts index a4befdd4f..6e17c41ea 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts @@ -101,46 +101,58 @@ class FancyUse extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create({ space: 10 }); + if (isInitialRender) { + Column.create({ space: 10 }); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create("Fancy"); - Text.backgroundColor(Color.Red); - Text.width(100); - Text.height(100); + if (isInitialRender) { + Text.create("Fancy"); + Text.backgroundColor(Color.Red); + Text.width(100); + Text.height(100); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create("Fancy"); - Text.backgroundColor(Color.Blue); - Text.width(100); - Text.height(100); + if (isInitialRender) { + Text.create("Fancy"); + Text.backgroundColor(Color.Blue); + Text.width(100); + Text.height(100); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithChild(); + if (isInitialRender) { + Button.createWithChild(); + Button.onClick(() => { + this.enable = false; + }); + ViewStackProcessor.visualState("normal"); + Button.backgroundColor(Color.Green); + ViewStackProcessor.visualState("disabled"); + Button.backgroundColor(Color.Blue); + ViewStackProcessor.visualState("pressed"); + Button.backgroundColor(Color.Red); + ViewStackProcessor.visualState(); + } Button.enabled(this.enable); - Button.onClick(() => { - this.enable = false; - }); - ViewStackProcessor.visualState("normal"); - Button.backgroundColor(Color.Green); - ViewStackProcessor.visualState("disabled"); - Button.backgroundColor(Color.Blue); - ViewStackProcessor.visualState("pressed"); - Button.backgroundColor(Color.Red); - ViewStackProcessor.visualState(); }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create("Fancy"); + if (isInitialRender) { + Text.create("Fancy"); + } }, Text); Text.pop(); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create("Fancy"); - ViewStackProcessor.visualState("normal"); - Text.width(200); - ViewStackProcessor.visualState(); + if (isInitialRender) { + Text.create("Fancy"); + ViewStackProcessor.visualState("normal"); + Text.width(200); + ViewStackProcessor.visualState(); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts index bef1e2486..fa4ba9c7c 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts @@ -95,8 +95,10 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.height(500); + if (isInitialRender) { + Column.create(); + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.objectName.a); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts index e66c5b35f..1aaaeaf9a 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts @@ -100,8 +100,10 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.height(500); + if (isInitialRender) { + Column.create(); + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.objectName.a); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForChainCall.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForChainCall.ts index f29a385eb..c20512ccc 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForChainCall.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForChainCall.ts @@ -86,7 +86,9 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts index 8d16adab8..b3f851680 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts @@ -55,8 +55,10 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.height(500); + if (isInitialRender) { + Column.create(); + Column.height(500); + } }, Column); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts index ae20e0c91..ffcaea9d7 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts @@ -97,8 +97,10 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.height(500); + if (isInitialRender) { + Column.create(); + Column.height(500); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.objectName.a); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThree.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThree.ts index 15c5c1eb6..e5cc89702 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThree.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThree.ts @@ -83,7 +83,9 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThreeParam.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThreeParam.ts index 776ac4c2c..f94b4a7d3 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThreeParam.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThreeParam.ts @@ -81,7 +81,9 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageParam.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageParam.ts index d180ff00e..37e51ce91 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageParam.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageParam.ts @@ -97,7 +97,9 @@ class localStorageParam extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@link/@link.ts b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@link/@link.ts index acf5a20f9..a7eac2ebe 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@link/@link.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@link/@link.ts @@ -109,7 +109,9 @@ class ParentComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ts b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ts index 3e23db5f7..a8ed9dad1 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ts @@ -103,7 +103,9 @@ class CustomText extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.model.text); @@ -152,7 +154,9 @@ class Parent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@prop.ts b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@prop.ts index 4a9a1d1d5..d77ee41c6 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@prop.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@prop.ts @@ -109,7 +109,9 @@ class CustomY extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@propComplexType.ts b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@propComplexType.ts index 8ce03ca99..b31c516ce 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@propComplexType.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@propComplexType.ts @@ -105,7 +105,9 @@ class CustomX extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(JSON.stringify(this.fruit.c)); @@ -150,7 +152,9 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ts b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ts index f60667b47..a7dd3218b 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ts @@ -63,7 +63,9 @@ class StatePage extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("counter:" + this.counter); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink.ts b/compiler/test/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink.ts index b83b304ca..ab2fbd874 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink.ts @@ -114,7 +114,9 @@ class ViewA extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('ViewA-' + this.varA.id); @@ -159,10 +161,14 @@ class ViewB extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -184,7 +190,9 @@ class ViewB extends ViewPU { }, { name: "ViewA" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('ViewB'); + if (isInitialRender) { + Text.create('ViewB'); + } }, Text); Text.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts b/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts index fa9d8a6cb..b458c50c8 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts @@ -162,13 +162,17 @@ class CompA extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel("add to basket"); - Button.onClick(() => { - this.shopBasket.push(Math.round(100 * Math.random())); - }); + if (isInitialRender) { + Button.createWithLabel("add to basket"); + Button.onClick(() => { + this.shopBasket.push(Math.round(100 * Math.random())); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -177,12 +181,14 @@ class CompA extends ViewPU { }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel("put item"); - Button.onClick(() => { - let alList = 'abcdefghijklmnopqrstuvwxyz'; - let ranItem = alList[Math.floor(Math.random() * 26)]; - this.defArray.push(ranItem); - }); + if (isInitialRender) { + Button.createWithLabel("put item"); + Button.onClick(() => { + let alList = 'abcdefghijklmnopqrstuvwxyz'; + let ranItem = alList[Math.floor(Math.random() * 26)]; + this.defArray.push(ranItem); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/v2_component_decorator/param_event_twoway_binding.ts b/compiler/test/utForPartialUpdate/v2_component_decorator/param_event_twoway_binding.ts index e8d30cbf0..ae7468aa5 100644 --- a/compiler/test/utForPartialUpdate/v2_component_decorator/param_event_twoway_binding.ts +++ b/compiler/test/utForPartialUpdate/v2_component_decorator/param_event_twoway_binding.ts @@ -72,7 +72,9 @@ class HomeComponent extends ViewV2 { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { -- Gitee From 8adb356967602d145d6bb066243d655353369295 Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Tue, 30 Jul 2024 13:44:15 +0800 Subject: [PATCH 14/18] fix ForEach and Custom Component Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/process_component_build.ts | 61 ++++++++----- compiler/src/process_custom_component.ts | 8 +- .../foreach/forEachThreeParam.ts | 4 +- .../render_component/foreach/forEachTwo.ts | 4 +- .../render_component/foreach/foreach.ts | 24 +++-- .../render_component/if/id_if.ts | 90 ++++++++++++------- .../render_component/if/if.ts | 4 +- .../lazyforeach/lazyforEachThreeParam.ts | 16 ++-- .../simple_component/button/button.ts | 2 +- .../navDestination_component.ts | 8 +- .../pageTransition/pageTransition.ts | 22 +++-- .../decoratorKeyCheck/decoratorKeyCheck.ts | 4 +- 12 files changed, 166 insertions(+), 81 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 2c73d2bec..317b9e22a 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -213,21 +213,7 @@ function attrExpHasProp(temp: ts.CallExpression, expName : string, propName : st } } return false; -} - - -interface ComplexAttrMap { - [key: string]: { [key: string]: string }; -} - -// const jsonFilePath = path.join(__dirname, '../complex_attr.json'); -// const jsonData = fs.readFileSync(jsonFilePath, 'utf-8'); - -// const rawObject = JSON.parse(jsonData); - -// const HANDLE_COMPLEX_ATTRS: Map> = new Map( -// Object.entries(rawObject).map(([key, value]) => [key, new Map(Object.entries(value))]) -// ); +} const HANDLE_COMPLEX_ATTRS : Map> = new Map( Object.entries(ATTRS_MAPPING).map(([key, value]) => [ @@ -236,6 +222,8 @@ const HANDLE_COMPLEX_ATTRS : Map> = new Map( ]) ); +const forEachPropMap : Map = new Map(); + export function processComponentBuild(node: ts.MethodDeclaration, log: LogInfo[]): ts.MethodDeclaration { let newNode: ts.MethodDeclaration; @@ -1209,7 +1197,13 @@ function processItemComponent(node: ts.ExpressionStatement, nameResult: NameResu const res: CreateResult = createComponent(node, COMPONENT_CREATE_FUNCTION); const isLazyCreate: boolean = checkLazyCreate(node, nameResult); const itemCreateStatement: ts.Statement = createItemCreate(nameResult, isLazyCreate); - itemRenderInnerStatements.push(itemCreateStatement); + let isItemReuse = false; + if (partialUpdateConfig.partialUpdateMode && isReuseStatement(itemCreateStatement as ts.ExpressionStatement)) { + isItemReuse = true; + immutableStatements.push(itemCreateStatement); + } else { + itemRenderInnerStatements.push(itemCreateStatement); + } const etsComponentResult: EtsComponentResult = parseEtsComponentExpression(node); if (etsComponentResult.etsComponentNode.body && ts.isBlock(etsComponentResult.etsComponentNode.body)) { if (etsComponentResult.hasAttr) { @@ -1222,6 +1216,10 @@ function processItemComponent(node: ts.ExpressionStatement, nameResult: NameResu } else { bindComponentAttr(node, res.identifierNode, itemRenderInnerStatements, log, true, false, immutableStatements); } + if (partialUpdateConfig.partialUpdateMode && !isItemReuse) { + itemRenderInnerStatements.push(...immutableStatements); + immutableStatements.length = 0; + } let generateItem: ts.IfStatement | ts.Block; if (idName) { generateItem = ifRetakeId([createItemBlock( @@ -1659,6 +1657,21 @@ function processForEachComponentNew(node: ts.ExpressionStatement, newStatements: newNode.expression.expression as ts.Identifier, ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, [])); const newForEachArrowFunc: ts.ArrowFunction = processForEachFunctionBlock(newNode.expression); + if (newForEachArrowFunc.parameters[0] && !isReuseArgument(argumentsArray[0])) { + // set arguments of + let arrowFunctionArg = newForEachArrowFunc.parameters[0]; + if (ts.isIdentifier(arrowFunctionArg.name)) { + forEachPropMap.set(arrowFunctionArg.name.escapedText.toString(), "@State"); + } else if (ts.isObjectBindingPattern(arrowFunctionArg.name)) { + arrowFunctionArg.name.elements.forEach((element)=>{ + let varName = element.name as ts.Identifier; + forEachPropMap.set(varName.escapedText.toString(), "@State"); + }); + } else{ + console.log("invalid arrow function args in ForEach!"); + } + } + const newArrowNode: ts.NodeArray = processForEachBlock(newNode.expression, log, newForEachArrowFunc, false, isGlobalBuilder, builderParamsResult) as ts.NodeArray; @@ -1683,6 +1696,7 @@ function processForEachComponentNew(node: ts.ExpressionStatement, newStatements: } else { storedFileInfo.processLazyForEach -= 1; } + forEachPropMap.clear(); } } @@ -2228,7 +2242,7 @@ function isReuseArgument(argument : ts.Expression): boolean { } // $$this.value if(ts.isIdentifier(argument.expression) && argument.expression.getText() == $$_THIS) { - return false; + return false; } // this.a.c if(ts.isPropertyAccessExpression(argument.expression)) @@ -2245,13 +2259,20 @@ function isReuseArgument(argument : ts.Expression): boolean { } } return res; - } else if(ts.isIdentifier(argument) && argument.getText().match(/^\$\$(.|\n)+/)) { - //start with $$ - return false; + } else if(ts.isIdentifier(argument)) { + if (argument.escapedText.toString().match(/^\$\$(.|\n)+/)) { + //start with $$ + return false; + } + if (mayChangedAnnotation.has(forEachPropMap.get(argument.escapedText.toString()))) { + return false; + } } else if(ts.isConditionalExpression(argument)) { if(!(isReuseArgument(argument.condition) && isReuseArgument(argument.whenTrue) && isReuseArgument(argument.whenFalse))) return false; + } else if(ts.isParenthesizedExpression(argument)) { + return isReuseArgument(argument.expression); } // todo: template return true; diff --git a/compiler/src/process_custom_component.ts b/compiler/src/process_custom_component.ts index 2af6db5f0..a041e4396 100644 --- a/compiler/src/process_custom_component.ts +++ b/compiler/src/process_custom_component.ts @@ -173,7 +173,8 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null)); const commomComponentNode: ts.Statement[] = []; const immutableStatements: ts.Statement[] = []; - if(isReuseStatement(createStatment)) { + let isCustomCreateReusable = isReuseStatement(createStatment); + if(isCustomCreateReusable) { immutableStatements.push(createStatment); } else { commomComponentNode.push(createStatment); @@ -182,7 +183,10 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen log, true, false, immutableStatements, false, componentAttrInfo); needCommon = commomComponentNode.length > 1 || immutableStatements.length > 0; if (componentAttrInfo.hasIdAttr && componentAttrInfo.attrCount === 1) { - commomComponentNode[0] = createCommonIdAttrNode(); + if(isCustomCreateReusable) + immutableStatements[0] = createCommonIdAttrNode(); + else + commomComponentNode[0] = createCommonIdAttrNode(); } if (needCommon) { newStatements.push(createComponentCreationStatement(componentAttributes(COMPONENT_COMMON), diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts index 84ea9823d..25ae625c5 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts @@ -94,9 +94,7 @@ class foreachThreeParam extends ViewPU { const forEachItemGenFunction = _item => { const item = _item; this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create(item); - } + Text.create(item); }, Text); Text.pop(); }; diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts index 131140040..049b238c9 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts @@ -99,7 +99,9 @@ class Index extends ViewPU { const forEachItemGenFunction = _item => { const { w, h } = _item; this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithLabel(); + if (isInitialRender) { + Button.createWithLabel(); + } Button.width(w); Button.height(h); }, Button); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts index 4ef610312..4b30fc99a 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts @@ -215,7 +215,9 @@ class ParentView1 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create(); + if (isInitialRender) { + List.create(); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -268,7 +270,9 @@ class ParentView2 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create(); + if (isInitialRender) { + List.create(); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -321,7 +325,9 @@ class ParentView3 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create(); + if (isInitialRender) { + List.create(); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -374,7 +380,9 @@ class ParentView4 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create(); + if (isInitialRender) { + List.create(); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -427,7 +435,9 @@ class ParentView5 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create(); + if (isInitialRender) { + List.create(); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -484,7 +494,9 @@ class ParentView6 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - List.create(); + if (isInitialRender) { + List.create(); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts index 2038539bc..e0afef1f9 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts @@ -232,8 +232,8 @@ class MyComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { if (isInitialRender) { Text.create('fail'); - Text.id('id6'); Text.fontSize(32); + Text.id('id6'); } }, Text); Text.pop(); @@ -284,8 +284,10 @@ class MyComponent extends ViewPU { ViewStackProcessor.StopGetAccessRecording(); }; const itemCreation2 = (elmtId, isInitialRender) => { - ListItem.create(deepRenderFunction, true); - ListItem.id('id8'); + if (isInitialRender) { + ListItem.create(deepRenderFunction, true); + ListItem.id('id8'); + } }; const deepRenderFunction = (elmtId, isInitialRender) => { itemCreation(elmtId, isInitialRender); @@ -321,7 +323,9 @@ class MyComponent extends ViewPU { If.pop(); List.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - Tabs.create({ barPosition: BarPosition.Start, controller: this.controller }); + if (isInitialRender) { + Tabs.create({ barPosition: BarPosition.Start, controller: this.controller }); + } }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); @@ -329,17 +333,21 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(0, () => { if (!If.canRetake('id9')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - TabContent.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('111'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Pink); - }, Text); - Text.pop(); - }); - TabContent.tabBar('pink'); - TabContent.id('id9'); + if (isInitialRender) { + TabContent.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + Text.create('111'); + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Pink); + } + }, Text); + Text.pop(); + }); + TabContent.tabBar('pink'); + TabContent.id('id9'); + } }, TabContent); TabContent.pop(); } @@ -361,35 +369,49 @@ class MyComponent extends ViewPU { if (this.count === 10) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('111'); + if (isInitialRender) { + Text.create('111'); + } }, Text); Text.pop(); Column.pop(); if (!If.canRetake('id12')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - XComponent.create({ id: 'special', type: '' }); - XComponent.id('id12'); + if (isInitialRender) { + XComponent.create({ id: 'special', type: '' }); + XComponent.id('id12'); + } }, XComponent); } if (!If.canRetake('id13')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.id('id13'); + if (isInitialRender) { + Column.create(); + Column.id('id13'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('11'); + if (isInitialRender) { + Text.create('11'); + } }, Text); Text.pop(); Column.pop(); } this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('222'); + if (isInitialRender) { + Text.create('222'); + } }, Text); Text.pop(); Column.pop(); @@ -415,8 +437,10 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(0, () => { if (!If.canRetake('id14')) { this.observeComponentCreation2((elmtId, isInitialRender) => { - __Common__.create(true); - __Common__.id('id14'); + if (isInitialRender) { + __Common__.create(true); + __Common__.id('id14'); + } }, __Common__); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -436,7 +460,9 @@ class MyComponent extends ViewPU { __Common__.pop(); } this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('111'); + if (isInitialRender) { + Text.create('111'); + } }, Text); Text.pop(); }); @@ -474,11 +500,15 @@ class Child extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('Child'); - Text.fontSize(50); + if (isInitialRender) { + Text.create('Child'); + Text.fontSize(50); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts index e819b090c..8308b8022 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts @@ -101,7 +101,9 @@ class IFView extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts index 69acdf4e6..d3cd182b7 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts @@ -266,14 +266,16 @@ class lazyforEachThreeParam extends ViewPU { const item = _item; { const itemCreation2 = (elmtId, isInitialRender) => { - ListItem.create(() => { }, false); + if (isInitialRender) { + ListItem.create(() => { }, false); + } }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, ListItem); this.observeComponentCreation2((elmtId, isInitialRender) => { if (isInitialRender) { - Row.create(); - Row.margin({ left: 10, right: 10 }); + Row.create(); + Row.margin({ left: 10, right: 10 }); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -299,7 +301,9 @@ class lazyforEachThreeParam extends ViewPU { const item = _item; { const itemCreation2 = (elmtId, isInitialRender) => { - ListItem.create(() => { }, false); + if (isInitialRender) { + ListItem.create(() => { }, false); + } }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, ListItem); @@ -332,7 +336,9 @@ class lazyforEachThreeParam extends ViewPU { const item = _item; { const itemCreation2 = (elmtId, isInitialRender) => { - ListItem.create(() => { }, false); + if (isInitialRender) { + ListItem.create(() => { }, false); + } }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, ListItem); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts index 929788bf0..703b63873 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts @@ -105,10 +105,10 @@ class ButtonExample extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { if (isInitialRender) { Button.createWithLabel('Disable', { type: ButtonType.Normal, stateEffect: false }); - Button.opacity(0.5); Button.borderRadius(8); Button.backgroundColor(0x317aff); Button.width(90); + Button.opacity(0.5); } }, Button); Button.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts index c4958e695..e7b22e3e3 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts @@ -69,9 +69,11 @@ class PageOne extends ViewPU { if (isInitialRender) { NavDestination.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); - Column.width('100%'); - Column.height('100%'); + if (isInitialRender) { + Column.create(); + Column.width('100%'); + Column.height('100%'); + } }, Column); Column.pop(); }, { moduleName: "", pagePath: "navDestination_component" }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts index 98e41637d..d818d1750 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts @@ -107,20 +107,26 @@ class PageTransitionExample1 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } Column.scale({ x: this.scale2 }); Column.opacity(this.opacity2); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Navigator.create({ target: 'pages/page1', type: NavigationType.Push }); - Navigator.onClick(() => { - this.active = true; - }); + if (isInitialRender) { + Navigator.create({ target: 'pages/page1', type: NavigationType.Push }); + Navigator.onClick(() => { + this.active = true; + }); + } }, Navigator); this.observeComponentCreation2((elmtId, isInitialRender) => { - Text.create('page transition'); - Text.width("100%"); - Text.height("100%"); + if (isInitialRender) { + Text.create('page transition'); + Text.width("100%"); + Text.height("100%"); + } }, Text); Text.pop(); Navigator.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck.ts b/compiler/test/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck.ts index 46bd26d83..25d899b65 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck.ts @@ -393,7 +393,9 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create(); + if (isInitialRender) { + Row.create(); + } }, Row); Row.pop(); } -- Gitee From 117b4dc68cdeab8f82f2c45b1c5bd97e5ae503d3 Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Mon, 5 Aug 2024 11:43:27 +0800 Subject: [PATCH 15/18] fix disorder of attrs and pageTransition Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/process_component_build.ts | 51 ++++++++----- .../import/import@CustomDialog.ts | 2 +- .../$$_component/$$_componentCheck1.ts | 8 +- .../$$_component/$$_componentCheck2.ts | 2 +- .../$$_component/$$_componentCheck3.ts | 4 +- .../$$_component/$$_componentCheck4.ts | 4 +- .../$$_component/$$_componentCheck5.ts | 2 +- .../$$_component/$$_componentCheck6.ts | 8 +- .../$$_component/$$_componentCheck7.ts | 4 +- .../$$_component/$$_componentCheck8.ts | 4 +- .../gesture_component/longPressGesture.ts | 2 +- .../gesture_component/panGestrue.ts | 2 +- .../gesture_component/pinchGesture.ts | 2 +- .../gesture_component/rotationGesture.ts | 2 +- .../gesture_component/tapGesture.ts | 2 +- .../render_component/if/id_if.ts | 2 +- .../lazyforeach/lazyforeach.ts | 16 +++- .../render_component/tab/tab.ts | 76 ++++++++++--------- .../simple_component/button/button.ts | 2 +- .../@storageLink/@storageLink.ts | 4 +- .../@storageProp/@storageProp.ts | 4 +- .../appStorage/appStorage.ts | 4 +- .../@consume_@provide/@consume_@provide.ts | 32 +++++--- 23 files changed, 139 insertions(+), 100 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 317b9e22a..c1cf164fb 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -196,6 +196,10 @@ import { curPropMap } from './process_component_member'; import { regularCollection } from './validate_ui_syntax'; import { To } from 'copy-webpack-plugin'; +export function isReuseMode() { + return partialUpdateConfig.partialUpdateMode && !storedFileInfo.processRepeat; +} + function attrExpHasProp(temp: ts.CallExpression, expName : string, propName : string, attrArgs : ts.Expression[]): boolean { if(expName == propName) { @@ -892,7 +896,7 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe } const immutableStatements: ts.Statement[] = []; const res: CreateResult = createComponent(node, COMPONENT_CREATE_FUNCTION); - if(partialUpdateConfig.partialUpdateMode && res.isReusable) { + if(isReuseMode() && !isTransition && res.isReusable) { immutableStatements.push(res.newNode); } else { newStatements.push(res.newNode); @@ -908,7 +912,7 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe if (res.isButton) { checkButtonParamHasLabel(etsComponentResult.etsComponentNode, log); let removeIndex : number = (projectConfig.isPreview || projectConfig.enableDebugLine)? -2:-1; - if(partialUpdateConfig.partialUpdateMode && res.isReusable) { + if(isReuseMode() && !isTransition && res.isReusable) { immutableStatements.splice(removeIndex, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); } else { newStatements.splice(removeIndex, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); @@ -916,7 +920,7 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe } if (etsComponentResult.hasAttr) { bindComponentAttr(node, res.identifierNode, newStatements, log, true, false, immutableStatements); - if(partialUpdateConfig.partialUpdateMode && !res.isReusable) { + if(isReuseMode() && (isTransition || !res.isReusable)) { newStatements.push(...immutableStatements); immutableStatements.length = 0; } @@ -929,7 +933,7 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe isGlobalBuilder, false, builderParamsResult); } else { bindComponentAttr(node, res.identifierNode, newStatements, log, true, false, immutableStatements); - if(partialUpdateConfig.partialUpdateMode && !res.isReusable) { + if(isReuseMode() && (isTransition || !res.isReusable)) { newStatements.push(...immutableStatements); immutableStatements.length = 0; } @@ -1198,7 +1202,7 @@ function processItemComponent(node: ts.ExpressionStatement, nameResult: NameResu const isLazyCreate: boolean = checkLazyCreate(node, nameResult); const itemCreateStatement: ts.Statement = createItemCreate(nameResult, isLazyCreate); let isItemReuse = false; - if (partialUpdateConfig.partialUpdateMode && isReuseStatement(itemCreateStatement as ts.ExpressionStatement)) { + if (isReuseMode() && isReuseStatement(itemCreateStatement as ts.ExpressionStatement)) { isItemReuse = true; immutableStatements.push(itemCreateStatement); } else { @@ -1216,7 +1220,7 @@ function processItemComponent(node: ts.ExpressionStatement, nameResult: NameResu } else { bindComponentAttr(node, res.identifierNode, itemRenderInnerStatements, log, true, false, immutableStatements); } - if (partialUpdateConfig.partialUpdateMode && !isItemReuse) { + if (isReuseMode() && !isItemReuse) { itemRenderInnerStatements.push(...immutableStatements); immutableStatements.length = 0; } @@ -1526,7 +1530,7 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. ts.factory.createIdentifier(name), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, navDestinationCallback)); let isTabContentReusable = false; - if(partialUpdateConfig.partialUpdateMode && isReuseStatement(tabContentCreation as ts.ExpressionStatement)) { + if(isReuseMode() && isReuseStatement(tabContentCreation as ts.ExpressionStatement)) { isTabContentReusable = true; immutableStatements.push(tabContentCreation); } else { @@ -1534,7 +1538,7 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. } bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableStatements); newStatements.push(...tabAttrs); - if(partialUpdateConfig.partialUpdateMode && !isTabContentReusable) { + if(isReuseMode() && !isTabContentReusable) { newStatements.push(...immutableStatements); immutableStatements.length = 0; } @@ -1548,7 +1552,7 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, name === NAV_DESTINATION ? navigationCreateParam(NAV_DESTINATION, COMPONENT_CREATE_FUNCTION) : [])); let isTabContentReusable = false; - if(partialUpdateConfig.partialUpdateMode && isReuseStatement(tabContentCreation as ts.ExpressionStatement)) { + if(isReuseMode() && isReuseStatement(tabContentCreation as ts.ExpressionStatement)) { isTabContentReusable = true; immutableStatements.push(tabContentCreation); } else { @@ -1556,7 +1560,7 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. } bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableStatements); newStatements.push(...tabAttrs); - if(partialUpdateConfig.partialUpdateMode && !isTabContentReusable) { + if(isReuseMode() && !isTabContentReusable) { newStatements.push(...immutableStatements); immutableStatements.length = 0; } @@ -1657,7 +1661,8 @@ function processForEachComponentNew(node: ts.ExpressionStatement, newStatements: newNode.expression.expression as ts.Identifier, ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, [])); const newForEachArrowFunc: ts.ArrowFunction = processForEachFunctionBlock(newNode.expression); - if (newForEachArrowFunc.parameters[0] && !isReuseArgument(argumentsArray[0])) { + if (newForEachArrowFunc.parameters[0] && + (!isReuseArgument(argumentsArray[0]) || name == COMPONENT_LAZYFOREACH)) { // set arguments of let arrowFunctionArg = newForEachArrowFunc.parameters[0]; if (ts.isIdentifier(arrowFunctionArg.name)) { @@ -2226,7 +2231,10 @@ function isXComponentContainer(item: ts.PropertyAssignment): boolean { function isReuseArgument(argument : ts.Expression): boolean { - const mayChangedAnnotation : Set = new Set(["@State", "@ObjectLink", "@Prop", "@Link"]); + const mayChangedAnnotation : Set = new Set([ + "@State", "@ObjectLink", "@Prop", "@Link", "@Provide", "@Consume", + "@LocalStorageLink", "@LocalStorageProp", "@StorageLink", "@StorageProp" + ]); if(ts.isObjectLiteralExpression(argument)) { let props = argument.properties; for(let prop of props as ts.NodeArray) { @@ -2346,8 +2354,8 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: temp.expression.name && ts.isIdentifier(temp.expression.name) && (!componentCollection.customComponents.has(temp.expression.name.getText()) || STYLES_ATTRIBUTE.has(temp.expression.name.getText()))) { parseRecycleId(temp, temp.expression.name, isRecycleComponent, componentAttrInfo); - if (partialUpdateConfig.partialUpdateMode && HANDLE_COMPLEX_ATTRS.has(temp.expression.name.getText())) { - collectComplextComponentAttr(temp, complexAttrMap, identifierNode); + if (isReuseMode() && HANDLE_COMPLEX_ATTRS.has(temp.expression.name.getText())) { + collectComplextComponentAttr(temp, complexAttrMap, identifierNode, statements, immutableStatements, updateStatements); } else { addComponentAttr(temp, temp.expression.name, lastStatement, statements, identifierNode, log, isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, @@ -2360,8 +2368,8 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: !GESTURE_TYPE_NAMES.has(temp.expression.getText()) && !componentCollection.customComponents.has(temp.expression.getText())) { parseRecycleId(temp, temp.expression.name, isRecycleComponent, componentAttrInfo); - if (partialUpdateConfig.partialUpdateMode && HANDLE_COMPLEX_ATTRS.has(temp.expression.getText())) { - collectComplextComponentAttr(temp, complexAttrMap, identifierNode); + if (isReuseMode() && HANDLE_COMPLEX_ATTRS.has(temp.expression.getText())) { + collectComplextComponentAttr(temp, complexAttrMap, identifierNode, statements, immutableStatements, updateStatements); } else { addComponentAttr(temp, temp.expression, lastStatement, statements, identifierNode, log, isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, @@ -2389,7 +2397,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: statements.push(lastStatement.statement); } - if (!partialUpdateConfig.partialUpdateMode || lastStatement.hasAnimationAttr) { + if (!isReuseMode() || lastStatement.hasAnimationAttr) { if (statements.length) { reverse ? newStatements.push(...statements.reverse()) : newStatements.push(...statements); } @@ -2864,7 +2872,7 @@ function createAttrFunction(node : ts.Identifier, name: string, argumentsArr : t } function collectComplextComponentAttr(temp : ts.CallExpression, complexAttrMap: Map, - identifierNode: ts.Identifier): void { + identifierNode: ts.Identifier, statements: ts.Statement[],immutableStatements: ts.Statement[], updateStatements: ts.Statement[]): void { let expName : string; if (ts.isPropertyAccessExpression(temp.expression)) { expName = temp.expression.name.getText(); @@ -2878,7 +2886,12 @@ function collectComplextComponentAttr(temp : ts.CallExpression, complexAttrMap: if (!complexAttrMap.has(attrName) && attrExpHasProp(temp, expName, propName, attrArgs)) { const attrStatement: ts.ExpressionStatement = ts.factory.createExpressionStatement( createAttrFunction(identifierNode, attrName, attrArgs)); - complexAttrMap.set(attrName, attrStatement); + complexAttrMap.set(attrName, null); + statements.push(attrStatement); + if(isReuseStatement(attrStatement)) + immutableStatements.push(attrStatement); + else + updateStatements.push(attrStatement); } } } diff --git a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts index b65f5d467..5aea2b053 100644 --- a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts +++ b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts @@ -158,10 +158,10 @@ class CustomDialogUser extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.inputValue); - Button.backgroundColor(0x317aff); Button.onClick(() => { this.dialogController.open(); }); + Button.backgroundColor(0x317aff); }, Button); Button.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts index 05d33a10b..c91048f08 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts @@ -158,8 +158,8 @@ class TabsExample extends ViewPU { Text.lineHeight(22); Text.margin({ top: 17, bottom: 7 }); } - Text.fontWeight(this.currentIndex === index ? 500 : 400); Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); + Text.fontWeight(this.currentIndex === index ? 500 : 400); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -181,9 +181,6 @@ class TabsExample extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Tabs.create({ barPosition: BarPosition.Start, index: { value: this.currentIndex, changeEvent: newValue => { this.currentIndex = newValue; } }, controller: this.controller }); - Tabs.width(360); - Tabs.height(296); - Tabs.backgroundColor('#F1F3F5'); Tabs.vertical(false); Tabs.barMode(BarMode.Fixed); Tabs.barWidth(360); @@ -192,7 +189,10 @@ class TabsExample extends ViewPU { Tabs.onChange((index) => { this.currentIndex = index; }); + Tabs.width(360); + Tabs.height(296); Tabs.margin({ top: 52 }); + Tabs.backgroundColor('#F1F3F5'); }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { if (isInitialRender) { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts index de8b66be7..4cb64dae5 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts @@ -99,10 +99,10 @@ class TextInputExample extends ViewPU { TextInput.create({ text: { value: this.text, changeEvent: newValue => { this.text = newValue; } } }); TextInput.backgroundColor(Color.Pink); TextInput.height(100); - TextInput.width(300); TextInput.placeholderColor(Color.Grey); TextInput.placeholderFont({ size: 14, weight: 400 }); TextInput.caretColor(Color.Blue); + TextInput.width(300); }, TextInput); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts index d279bd5c0..2a1a5517a 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts @@ -107,14 +107,14 @@ class Index extends ViewPU { if (isInitialRender) { Checkbox.create(); Checkbox.backgroundColor(Color.Pink); - Checkbox.width(30); - Checkbox.height(30); Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); Checkbox.selectedColor('red'); Checkbox.unselectedColor('red'); Checkbox.mark({ strokeColor: 'red' }); + Checkbox.width(30); + Checkbox.height(30); } Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); }, Checkbox); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts index e1d7162e5..84e7b9531 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts @@ -106,14 +106,14 @@ class Index extends ViewPU { if (isInitialRender) { Checkbox.create(); Checkbox.backgroundColor(Color.Pink); - Checkbox.width(30); - Checkbox.height(30); Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); Checkbox.selectedColor('red'); Checkbox.unselectedColor('red'); Checkbox.mark({ strokeColor: 'red' }); + Checkbox.width(30); + Checkbox.height(30); } Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); }, Checkbox); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts index cf6372dca..1b6e837b7 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts @@ -99,10 +99,10 @@ class TextInputExample extends ViewPU { TextInput.create({ text: { value: this.text, changeEvent: newValue => { this.text = newValue; } } }); TextInput.backgroundColor(Color.Pink); TextInput.height(100); - TextInput.width(300); TextInput.placeholderColor(Color.Grey); TextInput.placeholderFont({ size: 14, weight: 400 }); TextInput.caretColor(Color.Blue); + TextInput.width(300); }, TextInput); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts index c6a4eeeab..98da7f7da 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts @@ -158,8 +158,8 @@ class TabsExample extends ViewPU { Text.lineHeight(22); Text.margin({ top: 17, bottom: 7 }); } - Text.fontWeight(this.currentIndex === index ? 500 : 400); Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); + Text.fontWeight(this.currentIndex === index ? 500 : 400); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -181,9 +181,6 @@ class TabsExample extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Tabs.create({ barPosition: BarPosition.Start, index: { value: this.currentIndex, changeEvent: newValue => { this.currentIndex = newValue; } }, controller: this.controller }); - Tabs.width(360); - Tabs.height(296); - Tabs.backgroundColor('#F1F3F5'); Tabs.vertical(false); Tabs.barMode(BarMode.Fixed); Tabs.barWidth(360); @@ -192,7 +189,10 @@ class TabsExample extends ViewPU { Tabs.onChange((index) => { this.currentIndex = index; }); + Tabs.width(360); + Tabs.height(296); Tabs.margin({ top: 52 }); + Tabs.backgroundColor('#F1F3F5'); }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { if (isInitialRender) { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts index 01d27ba8c..ea86e20de 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts @@ -135,8 +135,6 @@ class Index extends ViewPU { if (isInitialRender) { Checkbox.create(); Checkbox.backgroundColor(Color.Pink); - Checkbox.width(dd().ee); - Checkbox.height(30); Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); Checkbox.selectedColor(xx()); Checkbox.unselectedColor(bb().cc); @@ -146,6 +144,8 @@ class Index extends ViewPU { Checkbox.mark({ strokeColor: 'red' }); + Checkbox.width(dd().ee); + Checkbox.height(30); } Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); }, Checkbox); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts index 01d27ba8c..ea86e20de 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts @@ -135,8 +135,6 @@ class Index extends ViewPU { if (isInitialRender) { Checkbox.create(); Checkbox.backgroundColor(Color.Pink); - Checkbox.width(dd().ee); - Checkbox.height(30); Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); Checkbox.selectedColor(xx()); Checkbox.unselectedColor(bb().cc); @@ -146,6 +144,8 @@ class Index extends ViewPU { Checkbox.mark({ strokeColor: 'red' }); + Checkbox.width(dd().ee); + Checkbox.height(30); } Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); }, Checkbox); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts index ac78e163c..4a4cf4d74 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts @@ -78,8 +78,8 @@ class LongPressGestureExample extends ViewPU { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); Flex.height(200); Flex.width(300); - Flex.borderWidth(1); Flex.padding(60); + Flex.borderWidth(1); Flex.margin(30); } Gesture.create(GesturePriority.Low); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts index 2aeb27bb5..8a94e420f 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts @@ -98,8 +98,8 @@ class PanGestureExample extends ViewPU { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); Flex.height(100); Flex.width(200); - Flex.borderWidth(1); Flex.padding(20); + Flex.borderWidth(1); Flex.margin(80); } Flex.translate({ x: this.offsetX, y: this.offsetY, z: 5 }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts index 50db1f4b5..af80b34d7 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts @@ -82,8 +82,8 @@ class PinchGestureExample extends ViewPU { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); Flex.height(100); Flex.width(200); - Flex.borderWidth(1); Flex.padding(20); + Flex.borderWidth(1); Flex.margin(80); } Flex.scale({ x: this.scale2, y: this.scale2, z: this.scale2 }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts index 21883f921..f87599b3d 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts @@ -82,8 +82,8 @@ class RotationGestureExample extends ViewPU { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); Flex.height(100); Flex.width(200); - Flex.borderWidth(1); Flex.padding(20); + Flex.borderWidth(1); Flex.margin(80); } Flex.rotate({ x: 1, y: 2, z: 3, angle: this.angle }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts index 1c1958c60..775f4ef19 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts @@ -76,8 +76,8 @@ class TapGestureExample extends ViewPU { Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); Flex.height(200); Flex.width(300); - Flex.borderWidth(1); Flex.padding(60); + Flex.borderWidth(1); Flex.margin(30); } Gesture.create(GesturePriority.Low); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts index e0afef1f9..6d22bf337 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts @@ -232,8 +232,8 @@ class MyComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { if (isInitialRender) { Text.create('fail'); - Text.fontSize(32); Text.id('id6'); + Text.fontSize(32); } }, Text); Text.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforeach.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforeach.ts index 7fcdfe04f..972eccd40 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforeach.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforeach.ts @@ -221,14 +221,18 @@ class Test extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Grid.create(); + if (isInitialRender) { + Grid.create(); + } }, Grid); { const __lazyForEachItemGenFunction = _item => { const row = _item; { const itemCreation2 = (elmtId, isInitialRender) => { - GridItem.create(() => { }, false); + if (isInitialRender) { + GridItem.create(() => { }, false); + } }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, GridItem); @@ -280,14 +284,18 @@ class ChildTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Grid.create(); + if (isInitialRender) { + Grid.create(); + } }, Grid); { const __lazyForEachItemGenFunction = _item => { const row = _item; { const itemCreation2 = (elmtId, isInitialRender) => { - GridItem.create(() => { }, false); + if (isInitialRender) { + GridItem.create(() => { }, false); + } }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, GridItem); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts index b069c48e8..fddd17ce7 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts @@ -91,43 +91,45 @@ class TabSimple extends ViewPU { } }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { - TabContent.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Flex.create(); - Flex.height(100); - Flex.width(200); - } - }, Flex); - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - Column.height(100); - Column.width(200); - } - }, Column); - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('text1'); - Text.height(100); - Text.width(200); - } - }, Text); - Text.pop(); - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('xxx'); - Text.height(100); - Text.width(200); - } - }, Text); - Text.pop(); - Column.pop(); - Flex.pop(); - }); - TabContent.tabBar("TabBar"); - TabContent.height(100); - TabContent.width(200); + if (isInitialRender) { + TabContent.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + Flex.create(); + Flex.height(100); + Flex.width(200); + } + }, Flex); + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + Column.create(); + Column.height(100); + Column.width(200); + } + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + Text.create('text1'); + Text.height(100); + Text.width(200); + } + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + if (isInitialRender) { + Text.create('xxx'); + Text.height(100); + Text.width(200); + } + }, Text); + Text.pop(); + Column.pop(); + Flex.pop(); + }); + TabContent.tabBar("TabBar"); + TabContent.height(100); + TabContent.width(200); + } }, TabContent); TabContent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts index 703b63873..929788bf0 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts @@ -105,10 +105,10 @@ class ButtonExample extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { if (isInitialRender) { Button.createWithLabel('Disable', { type: ButtonType.Normal, stateEffect: false }); + Button.opacity(0.5); Button.borderRadius(8); Button.backgroundColor(0x317aff); Button.width(90); - Button.opacity(0.5); } }, Button); Button.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts index 33b55ca43..791760a73 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts @@ -100,7 +100,9 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create({ space: 20 }); + if (isInitialRender) { + Row.create({ space: 20 }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.label + ': ' + this.varA); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts index 33b55ca43..791760a73 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts @@ -100,7 +100,9 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create({ space: 20 }); + if (isInitialRender) { + Row.create({ space: 20 }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.label + ': ' + this.varA); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts index 33b55ca43..791760a73 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts @@ -100,7 +100,9 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Row.create({ space: 20 }); + if (isInitialRender) { + Row.create({ space: 20 }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.label + ': ' + this.varA); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts b/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts index f6781230f..dc1251e92 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts @@ -113,7 +113,9 @@ class CompA extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -131,10 +133,12 @@ class CompA extends ViewPU { }, { name: "CompB" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithChild(); - Button.onClick(() => { - this.reviewVotes += 1; - }); + if (isInitialRender) { + Button.createWithChild(); + Button.onClick(() => { + this.reviewVotes += 1; + }); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('' + this.reviewVotes); @@ -169,7 +173,9 @@ class CompB extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -222,13 +228,17 @@ class CompC extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - Column.create(); + if (isInitialRender) { + Column.create(); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - Button.createWithChild(); - Button.onClick(() => { - this.reviewVotes += 1; - }); + if (isInitialRender) { + Button.createWithChild(); + Button.onClick(() => { + this.reviewVotes += 1; + }); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('' + this.reviewVotes); -- Gitee From b639229afabad1cd5a955a410f6e8c73e59cfc92 Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Mon, 5 Aug 2024 11:57:16 +0800 Subject: [PATCH 16/18] update create statements everytime(tests to be modified) Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/process_component_build.ts | 61 +++---------------------- 1 file changed, 6 insertions(+), 55 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index c1cf164fb..1b9a3d294 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -896,11 +896,7 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe } const immutableStatements: ts.Statement[] = []; const res: CreateResult = createComponent(node, COMPONENT_CREATE_FUNCTION); - if(isReuseMode() && !isTransition && res.isReusable) { - immutableStatements.push(res.newNode); - } else { - newStatements.push(res.newNode); - } + newStatements.push(res.newNode); processDebug(node, nameResult, newStatements); const etsComponentResult: EtsComponentResult = parseEtsComponentExpression(node); const componentName: string = res.identifierNode.getText(); @@ -912,18 +908,10 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe if (res.isButton) { checkButtonParamHasLabel(etsComponentResult.etsComponentNode, log); let removeIndex : number = (projectConfig.isPreview || projectConfig.enableDebugLine)? -2:-1; - if(isReuseMode() && !isTransition && res.isReusable) { - immutableStatements.splice(removeIndex, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); - } else { - newStatements.splice(removeIndex, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); - } + newStatements.splice(removeIndex, 1, createComponent(node, COMPONENT_CREATE_CHILD_FUNCTION).newNode); } if (etsComponentResult.hasAttr) { bindComponentAttr(node, res.identifierNode, newStatements, log, true, false, immutableStatements); - if(isReuseMode() && (isTransition || !res.isReusable)) { - newStatements.push(...immutableStatements); - immutableStatements.length = 0; - } } processInnerCompStatements(innerCompStatements, newStatements, node, isGlobalBuilder, isTransition, undefined, immutableStatements, componentName, builderParamsResult); @@ -933,10 +921,6 @@ function processNormalComponent(node: ts.ExpressionStatement, nameResult: NameRe isGlobalBuilder, false, builderParamsResult); } else { bindComponentAttr(node, res.identifierNode, newStatements, log, true, false, immutableStatements); - if(isReuseMode() && (isTransition || !res.isReusable)) { - newStatements.push(...immutableStatements); - immutableStatements.length = 0; - } processInnerCompStatements(innerCompStatements, newStatements, node, isGlobalBuilder, isTransition, undefined, immutableStatements, componentName, builderParamsResult); } @@ -1165,7 +1149,7 @@ function createInitRenderStatement(node: ts.Statement, immutableStatements: ts.Statement[], blockArr: ts.Statement[]): void { if (partialUpdateConfig.optimizeComponent) { if (immutableStatements && immutableStatements.length) { - blockArr.splice(0, 0, ts.factory.createIfStatement( + blockArr.push(ts.factory.createIfStatement( ts.factory.createIdentifier(ISINITIALRENDER), ts.factory.createBlock(immutableStatements, true) )); @@ -1201,13 +1185,7 @@ function processItemComponent(node: ts.ExpressionStatement, nameResult: NameResu const res: CreateResult = createComponent(node, COMPONENT_CREATE_FUNCTION); const isLazyCreate: boolean = checkLazyCreate(node, nameResult); const itemCreateStatement: ts.Statement = createItemCreate(nameResult, isLazyCreate); - let isItemReuse = false; - if (isReuseMode() && isReuseStatement(itemCreateStatement as ts.ExpressionStatement)) { - isItemReuse = true; - immutableStatements.push(itemCreateStatement); - } else { - itemRenderInnerStatements.push(itemCreateStatement); - } + itemRenderInnerStatements.push(itemCreateStatement); const etsComponentResult: EtsComponentResult = parseEtsComponentExpression(node); if (etsComponentResult.etsComponentNode.body && ts.isBlock(etsComponentResult.etsComponentNode.body)) { if (etsComponentResult.hasAttr) { @@ -1220,10 +1198,6 @@ function processItemComponent(node: ts.ExpressionStatement, nameResult: NameResu } else { bindComponentAttr(node, res.identifierNode, itemRenderInnerStatements, log, true, false, immutableStatements); } - if (isReuseMode() && !isItemReuse) { - itemRenderInnerStatements.push(...immutableStatements); - immutableStatements.length = 0; - } let generateItem: ts.IfStatement | ts.Block; if (idName) { generateItem = ifRetakeId([createItemBlock( @@ -1529,19 +1503,9 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression( ts.factory.createIdentifier(name), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, navDestinationCallback)); - let isTabContentReusable = false; - if(isReuseMode() && isReuseStatement(tabContentCreation as ts.ExpressionStatement)) { - isTabContentReusable = true; - immutableStatements.push(tabContentCreation); - } else { - newStatements.push(tabContentCreation); - } + newStatements.push(tabContentCreation); bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableStatements); newStatements.push(...tabAttrs); - if(isReuseMode() && !isTabContentReusable) { - newStatements.push(...immutableStatements); - immutableStatements.length = 0; - } processInnerCompStatements( innerCompStatements, newStatements, node, isGlobalBuilder, false, nameResult, immutableStatements, name, builderParamsResult); @@ -1551,19 +1515,9 @@ function processTabAndNav(node: ts.ExpressionStatement, innerCompStatements: ts. ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(name), ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION)), undefined, name === NAV_DESTINATION ? navigationCreateParam(NAV_DESTINATION, COMPONENT_CREATE_FUNCTION) : [])); - let isTabContentReusable = false; - if(isReuseMode() && isReuseStatement(tabContentCreation as ts.ExpressionStatement)) { - isTabContentReusable = true; - immutableStatements.push(tabContentCreation); - } else { - newStatements.push(tabContentCreation); - } + newStatements.push(tabContentCreation); bindComponentAttr(node, ts.factory.createIdentifier(name), tabAttrs, log, true, false, immutableStatements); newStatements.push(...tabAttrs); - if(isReuseMode() && !isTabContentReusable) { - newStatements.push(...immutableStatements); - immutableStatements.length = 0; - } processInnerCompStatements( innerCompStatements, newStatements, node, isGlobalBuilder, false, nameResult, immutableStatements, name, builderParamsResult); @@ -2164,9 +2118,6 @@ function createComponent(node: ts.ExpressionStatement, type: string): CreateResu if (checkContainer(temp.getText(), temp.parent)) { res.isContainerComponent = true; } - if (isReuseArgument(temp.parent)) { - res.isReusable = true; - } res.newNode = type === COMPONENT_POP_FUNCTION ? ts.factory.createExpressionStatement(createFunction(temp, identifierNode, null)) : ts.factory.createExpressionStatement(createFunction(temp, identifierNode, checkArguments(temp, type))); -- Gitee From 4f84c653e6776447fd2f1201f9df0f9c1473bc44 Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Tue, 13 Aug 2024 14:53:51 +0800 Subject: [PATCH 17/18] Support stateStyles and fix Custom Component bug Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/process_component_build.ts | 51 +++++----- compiler/src/process_custom_component.ts | 10 +- compiler/src/utils.ts | 1 + .../import/import@CustomDialog.ts | 12 ++- .../import/import@Observed.ts | 18 ++-- .../utForPartialUpdate/import/importAllEts.ts | 8 +- .../utForPartialUpdate/import/importEts.ts | 6 +- .../import/importExportEts.ts | 4 +- .../import/importExportNest.ts | 12 ++- .../utForPartialUpdate/import/importTs.ts | 4 +- .../$$_component/$$_component.ts | 46 ++++------ .../$$_component/$$_componentCheck1.ts | 62 +++++++------ .../$$_component/$$_componentCheck2.ts | 16 ++-- .../$$_component/$$_componentCheck3.ts | 12 +-- .../$$_component/$$_componentCheck4.ts | 12 +-- .../$$_component/$$_componentCheck5.ts | 16 ++-- .../$$_component/$$_componentCheck6.ts | 62 +++++++------ .../$$_component/$$_componentCheck7.ts | 12 +-- .../$$_component/$$_componentCheck8.ts | 12 +-- .../$$_component/$$_componentCheck9.ts | 6 +- .../$$_component/$$_if_elseIf_else.ts | 8 +- .../custom_component/component_object.ts | 16 +--- .../custom_component/custom_component.ts | 20 ++-- .../gesture_component/GestureModeParallel.ts | 8 +- .../gesture_component/longPressGesture.ts | 16 ++-- .../gesture_component/panGestrue.ts | 16 ++-- .../gesture_component/pinchGesture.ts | 16 ++-- .../gesture_component/rotationGesture.ts | 16 ++-- .../gesture_component/swipeGesture.ts | 12 +-- .../gesture_component/tapGesture.ts | 20 ++-- .../foreach/forEachSecondFunction.ts | 8 +- .../foreach/forEachThreeParam.ts | 4 +- .../render_component/foreach/forEachTwo.ts | 8 +- .../render_component/foreach/foreach.ts | 28 ++---- .../render_component/if/id_if.ts | 92 ++++++++----------- .../render_component/if/if.ts | 24 ++--- .../render_component/item/GridItem.ts | 8 +- .../render_component/item/ListItem.ts | 8 +- .../lazyforeach/lazyforEachThreeParam.ts | 50 +++++----- .../lazyforeach/lazyforeach.ts | 16 +--- .../render_component/repeat/repeat.ts | 6 +- .../repeat/repeatVirtualScroll.ts | 2 +- .../render_component/tab/tab.ts | 90 +++++++++--------- .../simple_component/button/button.ts | 18 ++-- .../xcomponent/XComponentContainer.ts | 16 +--- .../animateTo/animateTo.ts | 36 ++++---- .../navDestination_component.ts | 28 +++--- .../navigation/navigation_component.ts | 8 +- .../pageTransition/pageTransition.ts | 8 +- .../@AnimatableExtend/animatableExtend.ts | 8 +- .../render_decorator/@builder/@builder.ts | 4 +- .../@customDialog/@customDialog.ts | 64 ++++++++----- .../render_decorator/@preview/@preview.ts | 4 +- .../@recycle/recycle_extend_styles.ts | 8 +- .../@recycle/recycle_gesture.ts | 6 +- .../@recycle/recycle_reuseId.ts | 15 ++- .../render_decorator/@styles/@styles.ts | 40 ++++---- .../render_decorator/@styles/@stylesExport.ts | 24 +++-- .../@styles/@stylesOrComponentAsName.ts | 30 +++--- .../@storageLink/@storageLink.ts | 32 ++++--- .../@storageProp/@storageProp.ts | 32 ++++--- .../appStorage/appStorage.ts | 32 ++++--- .../localStorage/localStorage.ts | 12 ++- .../localStorage/localStorageForBoth.ts | 12 ++- .../localStorage/localStorageForChainCall.ts | 4 +- .../localStorage/localStorageForRoute.ts | 2 +- .../localStorage/localStorageForStorage.ts | 12 ++- .../localStorage/localStorageForThree.ts | 4 +- .../localStorage/localStorageForThreeParam.ts | 4 +- .../localStorage/localStorageParam.ts | 4 +- .../@link/@link.ts | 4 +- .../@objectLink/@objectLink.ts | 8 +- .../@prop/@prop.ts | 4 +- .../@prop/@propComplexType.ts | 8 +- .../@state/@state.ts | 4 +- .../@consume_@provide/@consume_@provide.ts | 24 +++-- .../@observed_@objectLink.ts | 16 +--- .../others/@watch/@watch.ts | 16 ++-- .../decoratorKeyCheck/decoratorKeyCheck.ts | 4 +- .../builderParamStyles.ts | 6 +- .../param_event_twoway_binding.ts | 4 +- 81 files changed, 651 insertions(+), 788 deletions(-) diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 1b9a3d294..97f00d1d9 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -197,7 +197,7 @@ import { regularCollection } from './validate_ui_syntax'; import { To } from 'copy-webpack-plugin'; export function isReuseMode() { - return partialUpdateConfig.partialUpdateMode && !storedFileInfo.processRepeat; + return partialUpdateConfig.partialUpdateMode && !storedFileInfo.processRepeat && (storedFileInfo.processStateStyles===0); } function attrExpHasProp(temp: ts.CallExpression, expName : string, propName : string, attrArgs : ts.Expression[]): boolean { @@ -1107,6 +1107,8 @@ export function createComponentCreationStatement(node: ts.Statement, innerStatem } if (!isTransition) { createInitRenderStatement(node, immutableStatements, blockArr); + } else if (immutableStatements) { + blockArr.push(...immutableStatements); } if (!partialUpdateConfig.optimizeComponent) { blockArr.unshift(createViewStackProcessorStatement(STARTGETACCESSRECORDINGFOR, ELMTID)); @@ -2209,15 +2211,7 @@ function isReuseArgument(argument : ts.Expression): boolean { } else if(ts.isBinaryExpression(argument)) { return isReuseArgument(argument.left) && isReuseArgument(argument.right); } else if(ts.isCallExpression(argument) || ts.isEtsComponentExpression(argument)) { - let args = argument.arguments; - let res = true; - for(let arg of args) { - if(!isReuseArgument(arg)) { - res = false; - break; - } - } - return res; + return argument.arguments.every((arg)=>{ return isReuseArgument(arg);}); } else if(ts.isIdentifier(argument)) { if (argument.escapedText.toString().match(/^\$\$(.|\n)+/)) { //start with $$ @@ -2232,6 +2226,10 @@ function isReuseArgument(argument : ts.Expression): boolean { return false; } else if(ts.isParenthesizedExpression(argument)) { return isReuseArgument(argument.expression); + } else if(ts.isArrayLiteralExpression(argument)) { + return argument.elements.every((elem)=>{ return isReuseArgument(elem); }); + } else if(ts.isTemplateExpression(argument)) { + return argument.templateSpans.every((span)=>{ return isReuseArgument(span.expression); }); } // todo: template return true; @@ -2348,7 +2346,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: statements.push(lastStatement.statement); } - if (!isReuseMode() || lastStatement.hasAnimationAttr) { + if (!isReuseMode() || lastStatement.hasAnimationAttr || !newImmutableStatements) { if (statements.length) { reverse ? newStatements.push(...statements.reverse()) : newStatements.push(...statements); } @@ -2905,11 +2903,12 @@ function addComponentAttr(temp: any, node: ts.Identifier, lastStatement: any, } else if (propName === ATTRIBUTE_STATESTYLES) { if (temp.arguments.length === 1 && ts.isObjectLiteralExpression(temp.arguments[0])) { statements.push(createViewStackProcessor(temp, true)); - if (isRecycleComponent) { - updateStatements.push(createViewStackProcessor(temp, true)); - } + updateStatements.push(createViewStackProcessor(temp, true)); + + storedFileInfo.processStateStyles += 1; traverseStateStylesAttr(temp, statements, identifierNode, log, updateStatements, newImmutableStatements, isRecycleComponent); + storedFileInfo.processStateStyles -= 1; lastStatement.kind = true; } else { validateStateStyleSyntax(temp, log); @@ -3157,30 +3156,24 @@ function traverseStateStylesAttr(temp: any, statements: ts.Statement[], const name: string = item.initializer.name.getText(); bindComponentAttr(INNER_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, identifierNode, statements, log, false, true, newImmutableStatements); - if (isRecycleComponent) { - bindComponentAttr(INNER_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, - identifierNode, updateStatements, log, false, true, newImmutableStatements); - } + bindComponentAttr(INNER_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, + identifierNode, updateStatements, log, false, true, newImmutableStatements); } else if (ts.isIdentifier(item.initializer) && GLOBAL_STYLE_FUNCTION.get(item.initializer.getText())) { const name: string = item.initializer.getText(); bindComponentAttr(GLOBAL_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, identifierNode, statements, log, false, true, newImmutableStatements); - if (isRecycleComponent) { - bindComponentAttr(GLOBAL_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, - identifierNode, updateStatements, log, false, true, newImmutableStatements); - } + bindComponentAttr(GLOBAL_STYLE_FUNCTION.get(name).statements[0] as ts.ExpressionStatement, + identifierNode, updateStatements, log, false, true, newImmutableStatements); } else if (ts.isObjectLiteralExpression(item.initializer) && item.initializer.properties.length === 1 && ts.isPropertyAssignment(item.initializer.properties[0])) { bindComponentAttr(ts.factory.createExpressionStatement( item.initializer.properties[0].initializer), identifierNode, statements, log, false, true, newImmutableStatements); - if (isRecycleComponent) { - bindComponentAttr(ts.factory.createExpressionStatement( - item.initializer.properties[0].initializer), identifierNode, updateStatements, log, false, true, - newImmutableStatements); - } + bindComponentAttr(ts.factory.createExpressionStatement( + item.initializer.properties[0].initializer), identifierNode, updateStatements, log, false, true, + newImmutableStatements); } else { if (!(ts.isObjectLiteralExpression(item.initializer) && item.initializer.properties.length === 0)) { validateStateStyleSyntax(temp, log); @@ -3189,9 +3182,7 @@ function traverseStateStylesAttr(temp: any, statements: ts.Statement[], if (item.name) { const viewNode: ts.Statement = createViewStackProcessor(item, false); statements.push(viewNode); - if (isRecycleComponent) { - updateStatements.push(viewNode); - } + updateStatements.push(viewNode); } }); } diff --git a/compiler/src/process_custom_component.ts b/compiler/src/process_custom_component.ts index a041e4396..d0a48d33c 100644 --- a/compiler/src/process_custom_component.ts +++ b/compiler/src/process_custom_component.ts @@ -173,19 +173,11 @@ export function processCustomComponent(node: ts.ExpressionStatement, newStatemen ts.factory.createIdentifier(COMPONENT_CREATE_FUNCTION), null)); const commomComponentNode: ts.Statement[] = []; const immutableStatements: ts.Statement[] = []; - let isCustomCreateReusable = isReuseStatement(createStatment); - if(isCustomCreateReusable) { - immutableStatements.push(createStatment); - } else { - commomComponentNode.push(createStatment); - } + commomComponentNode.push(createStatment); bindComponentAttr(node, ts.factory.createIdentifier(COMPONENT_COMMON), commomComponentNode, log, true, false, immutableStatements, false, componentAttrInfo); needCommon = commomComponentNode.length > 1 || immutableStatements.length > 0; if (componentAttrInfo.hasIdAttr && componentAttrInfo.attrCount === 1) { - if(isCustomCreateReusable) - immutableStatements[0] = createCommonIdAttrNode(); - else commomComponentNode[0] = createCommonIdAttrNode(); } if (needCommon) { diff --git a/compiler/src/utils.ts b/compiler/src/utils.ts index 633f04716..797e2d3ab 100644 --- a/compiler/src/utils.ts +++ b/compiler/src/utils.ts @@ -748,6 +748,7 @@ export class ProcessFileInfo { processForEach: number = 0; processLazyForEach: number = 0; processRepeat: boolean = false; + processStateStyles: number = 0; isAsPageImport: boolean = false; overallObjectLinkCollection: Map> = new Map(); overallLinkCollection: Map> = new Map(); diff --git a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts index 5aea2b053..a6f98f66c 100644 --- a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts +++ b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts @@ -150,18 +150,20 @@ class CustomDialogUser extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.width('100%'); Column.margin({ top: 5 }); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.inputValue); - Button.onClick(() => { - this.dialogController.open(); - }); - Button.backgroundColor(0x317aff); + if (isInitialRender) { + Button.onClick(() => { + this.dialogController.open(); + }); + Button.backgroundColor(0x317aff); + } }, Button); Button.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/import/import@Observed.ts b/compiler/test/utForPartialUpdate/import/import@Observed.ts index a2d840bd8..4c8a850bf 100644 --- a/compiler/test/utForPartialUpdate/import/import@Observed.ts +++ b/compiler/test/utForPartialUpdate/import/import@Observed.ts @@ -103,16 +103,18 @@ class ViewA extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); if (isInitialRender) { - Row.create(); Row.margin({ top: 10 }); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('ViewA' + JSON.stringify(this.label) + 'this.a.c=' + JSON.stringify(this.a.c)); - Button.onClick(() => { - this.a.c += 1; - }); + if (isInitialRender) { + Button.onClick(() => { + this.a.c += 1; + }); + } }, Button); Button.pop(); Row.pop(); @@ -154,8 +156,8 @@ class ViewB extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.width('100%'); } }, Column); @@ -228,8 +230,8 @@ class ViewB extends ViewPU { }, { name: "ViewA" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('ViewB: reset array'); if (isInitialRender) { - Button.createWithLabel('ViewB: reset array'); Button.margin({ top: 10 }); Button.onClick(() => { this.arrA = [new import_Observed_1.ClassB(0), new import_Observed_1.ClassB(0)]; @@ -238,8 +240,8 @@ class ViewB extends ViewPU { }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('ViewB: push'); if (isInitialRender) { - Button.createWithLabel('ViewB: push'); Button.margin({ top: 10 }); Button.onClick(() => { this.arrA.push(new import_Observed_1.ClassB(0)); @@ -248,8 +250,8 @@ class ViewB extends ViewPU { }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('ViewB: shift'); if (isInitialRender) { - Button.createWithLabel('ViewB: shift'); Button.margin({ top: 10 }); Button.onClick(() => { this.arrA.shift(); diff --git a/compiler/test/utForPartialUpdate/import/importAllEts.ts b/compiler/test/utForPartialUpdate/import/importAllEts.ts index c939f02e7..9fc43af04 100644 --- a/compiler/test/utForPartialUpdate/import/importAllEts.ts +++ b/compiler/test/utForPartialUpdate/import/importAllEts.ts @@ -169,9 +169,7 @@ class ImportTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -203,8 +201,8 @@ class ImportTest extends ViewPU { }, { name: "NamespaceComponent1" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); if (isInitialRender) { - __Common__.create(); __Common__.width(100); } }, __Common__); @@ -268,8 +266,8 @@ class ImportTest extends ViewPU { }, { name: "default" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); if (isInitialRender) { - __Common__.create(); __Common__.height(200); } }, __Common__); diff --git a/compiler/test/utForPartialUpdate/import/importEts.ts b/compiler/test/utForPartialUpdate/import/importEts.ts index 181b735fd..c0617a48b 100644 --- a/compiler/test/utForPartialUpdate/import/importEts.ts +++ b/compiler/test/utForPartialUpdate/import/importEts.ts @@ -203,9 +203,7 @@ class ImportTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -241,8 +239,8 @@ class ImportTest extends ViewPU { }, { name: "LinkComponent2Ref" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('space'); if (isInitialRender) { - Text.create('space'); Text.fontSize(20); Text.fontColor(Color.Red); } diff --git a/compiler/test/utForPartialUpdate/import/importExportEts.ts b/compiler/test/utForPartialUpdate/import/importExportEts.ts index 7b79325d2..22aaadbe0 100644 --- a/compiler/test/utForPartialUpdate/import/importExportEts.ts +++ b/compiler/test/utForPartialUpdate/import/importExportEts.ts @@ -132,9 +132,7 @@ class ImportTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/import/importExportNest.ts b/compiler/test/utForPartialUpdate/import/importExportNest.ts index 47fee4c15..d3fc532ce 100644 --- a/compiler/test/utForPartialUpdate/import/importExportNest.ts +++ b/compiler/test/utForPartialUpdate/import/importExportNest.ts @@ -191,13 +191,13 @@ class ImportTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.testText1); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); ImportNestAll_1.tExtend.bind(this)(20, this); @@ -212,7 +212,9 @@ class ImportTest extends ViewPU { Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.testText4); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); { diff --git a/compiler/test/utForPartialUpdate/import/importTs.ts b/compiler/test/utForPartialUpdate/import/importTs.ts index e3cde133e..698659e6a 100644 --- a/compiler/test/utForPartialUpdate/import/importTs.ts +++ b/compiler/test/utForPartialUpdate/import/importTs.ts @@ -132,9 +132,7 @@ class ImportTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts index 2626e9786..c48658a46 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_component.ts @@ -139,76 +139,62 @@ class HomeComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.height(500); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create(this.value1); - } + Text.create(this.value1); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Radio.create({ value: "Radio", group: "1" }); - } + Radio.create({ value: "Radio", group: "1" }); Radio.checked(this.value4, newValue => { this.value4 = newValue; }); }, Radio); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); if (isInitialRender) { - Row.create(); Row.width(20); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithChild(); + Button.bindPopup({ value: this.value4, changeEvent: newValue => { this.value4 = newValue; } }, { message: "This is $$ for regular" }); if (isInitialRender) { - Button.createWithChild(); Button.width(100); Button.height(20); } - Button.bindPopup({ value: this.value4, changeEvent: newValue => { this.value4 = newValue; } }, { message: "This is $$ for regular" }); }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create(this.value1); - } + Text.create(this.value1); Text.bindPopup({ value: value5[0], changeEvent: newValue => { value5[0] = newValue; } }, { message: "This is $$ for Array" }); }, Text); Text.pop(); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(this.value2); + Text.bindPopup({ value: value6.item1, changeEvent: newValue => { value6.item1 = newValue; } }, { message: "This is $$ for Obj" }); if (isInitialRender) { - Text.create(this.value2); Text.fontSize(100); } - Text.bindPopup({ value: value6.item1, changeEvent: newValue => { value6.item1 = newValue; } }, { message: "This is $$ for Obj" }); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create(this.value3); - } + Text.create(this.value3); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Radio.create({ value: "Radio", group: "1" }); - } + Radio.create({ value: "Radio", group: "1" }); Radio.checked(value5[0], newValue => { value5[0] = newValue; }); }, Radio); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { TextTimer.create({ controller: this.myTimeController, isCountDown: { value: isCountDown, changeEvent: newValue => { isCountDown = newValue; } }, count: { value: this.count, changeEvent: newValue => { this.count = newValue; } } }); @@ -216,8 +202,8 @@ class HomeComponent extends ViewPU { }, TextTimer); TextTimer.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel("start"); if (isInitialRender) { - Button.createWithLabel("start"); Button.onClick(() => { this.myTimeController.start(); }); @@ -225,8 +211,8 @@ class HomeComponent extends ViewPU { }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel("pause"); if (isInitialRender) { - Button.createWithLabel("pause"); Button.onClick(() => { this.myTimeController.pause(); }); @@ -234,8 +220,8 @@ class HomeComponent extends ViewPU { }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel("reset"); if (isInitialRender) { - Button.createWithLabel("reset"); Button.onClick(() => { this.myTimeController.reset(); }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts index c91048f08..bfee93bcc 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts @@ -146,67 +146,69 @@ class TabsExample extends ViewPU { } tabBuilder(index, name, parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.width('100%'); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(name); + Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); + Text.fontWeight(this.currentIndex === index ? 500 : 400); if (isInitialRender) { - Text.create(name); Text.fontSize(16); Text.lineHeight(22); Text.margin({ top: 17, bottom: 7 }); } - Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); - Text.fontWeight(this.currentIndex === index ? 500 : 400); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); + Divider.opacity(this.currentIndex === index ? 1 : 0); if (isInitialRender) { - Divider.create(); Divider.strokeWidth(2); Divider.color('#007DFF'); } - Divider.opacity(this.currentIndex === index ? 1 : 0); }, Divider); Column.pop(); } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.width('100%'); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Tabs.create({ barPosition: BarPosition.Start, index: { value: this.currentIndex, changeEvent: newValue => { this.currentIndex = newValue; } }, controller: this.controller }); - Tabs.vertical(false); - Tabs.barMode(BarMode.Fixed); - Tabs.barWidth(360); - Tabs.barHeight(56); - Tabs.animationDuration(400); - Tabs.onChange((index) => { - this.currentIndex = index; - }); - Tabs.width(360); - Tabs.height(296); - Tabs.margin({ top: 52 }); - Tabs.backgroundColor('#F1F3F5'); + if (isInitialRender) { + Tabs.vertical(false); + Tabs.barMode(BarMode.Fixed); + Tabs.barWidth(360); + Tabs.barHeight(56); + Tabs.animationDuration(400); + Tabs.onChange((index) => { + this.currentIndex = index; + }); + Tabs.width(360); + Tabs.height(296); + Tabs.margin({ top: 52 }); + Tabs.backgroundColor('#F1F3F5'); + } }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { + TabContent.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + if (isInitialRender) { + Column.backgroundColor(Color.Pink); + Column.height(100); + Column.width(150); + } + }, Column); + Column.pop(); + }); if (isInitialRender) { - TabContent.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - Column.backgroundColor(Color.Pink); - Column.height(100); - Column.width(150); - } - }, Column); - Column.pop(); - }); TabContent.backgroundColor(Color.Pink); TabContent.height(100); TabContent.width(150); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts index 4cb64dae5..1e03c3eed 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck2.ts @@ -84,8 +84,8 @@ class TextInputExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create({ space: 20 }); if (isInitialRender) { - Column.create({ space: 20 }); Column.width('100%'); Column.height('100%'); Column.justifyContent(FlexAlign.Center); @@ -97,12 +97,14 @@ class TextInputExample extends ViewPU { Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TextInput.create({ text: { value: this.text, changeEvent: newValue => { this.text = newValue; } } }); - TextInput.backgroundColor(Color.Pink); - TextInput.height(100); - TextInput.placeholderColor(Color.Grey); - TextInput.placeholderFont({ size: 14, weight: 400 }); - TextInput.caretColor(Color.Blue); - TextInput.width(300); + if (isInitialRender) { + TextInput.backgroundColor(Color.Pink); + TextInput.height(100); + TextInput.placeholderColor(Color.Grey); + TextInput.placeholderFont({ size: 14, weight: 400 }); + TextInput.caretColor(Color.Blue); + TextInput.width(300); + } }, TextInput); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts index 2a1a5517a..9dbab4ebd 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck3.ts @@ -90,22 +90,19 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); if (1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { + Checkbox.create(); + Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); if (isInitialRender) { - Checkbox.create(); Checkbox.backgroundColor(Color.Pink); Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); Checkbox.selectedColor('red'); @@ -116,7 +113,6 @@ class Index extends ViewPU { Checkbox.width(30); Checkbox.height(30); } - Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts index 84e7b9531..4f6ccf270 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck4.ts @@ -89,22 +89,19 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); if (1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { + Checkbox.create(); + Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); if (isInitialRender) { - Checkbox.create(); Checkbox.backgroundColor(Color.Pink); Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); Checkbox.selectedColor('red'); @@ -115,7 +112,6 @@ class Index extends ViewPU { Checkbox.width(30); Checkbox.height(30); } - Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts index 1b6e837b7..5b51e44c1 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck5.ts @@ -84,8 +84,8 @@ class TextInputExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create({ space: 20 }); if (isInitialRender) { - Column.create({ space: 20 }); Column.width('100%'); Column.height('100%'); Column.justifyContent(FlexAlign.Center); @@ -97,12 +97,14 @@ class TextInputExample extends ViewPU { Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TextInput.create({ text: { value: this.text, changeEvent: newValue => { this.text = newValue; } } }); - TextInput.backgroundColor(Color.Pink); - TextInput.height(100); - TextInput.placeholderColor(Color.Grey); - TextInput.placeholderFont({ size: 14, weight: 400 }); - TextInput.caretColor(Color.Blue); - TextInput.width(300); + if (isInitialRender) { + TextInput.backgroundColor(Color.Pink); + TextInput.height(100); + TextInput.placeholderColor(Color.Grey); + TextInput.placeholderFont({ size: 14, weight: 400 }); + TextInput.caretColor(Color.Blue); + TextInput.width(300); + } }, TextInput); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts index 98da7f7da..73e5a420e 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts @@ -146,67 +146,69 @@ class TabsExample extends ViewPU { } tabBuilder(index, name, parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.width('100%'); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(name); + Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); + Text.fontWeight(this.currentIndex === index ? 500 : 400); if (isInitialRender) { - Text.create(name); Text.fontSize(16); Text.lineHeight(22); Text.margin({ top: 17, bottom: 7 }); } - Text.fontColor(this.currentIndex === index ? this.selectedFontColor : this.fontColor); - Text.fontWeight(this.currentIndex === index ? 500 : 400); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); + Divider.opacity(this.currentIndex === index ? 1 : 0); if (isInitialRender) { - Divider.create(); Divider.strokeWidth(2); Divider.color('#007DFF'); } - Divider.opacity(this.currentIndex === index ? 1 : 0); }, Divider); Column.pop(); } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.width('100%'); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Tabs.create({ barPosition: BarPosition.Start, index: { value: this.currentIndex, changeEvent: newValue => { this.currentIndex = newValue; } }, controller: this.controller }); - Tabs.vertical(false); - Tabs.barMode(BarMode.Fixed); - Tabs.barWidth(360); - Tabs.barHeight(56); - Tabs.animationDuration(400); - Tabs.onChange((index) => { - this.currentIndex = index; - }); - Tabs.width(360); - Tabs.height(296); - Tabs.margin({ top: 52 }); - Tabs.backgroundColor('#F1F3F5'); + if (isInitialRender) { + Tabs.vertical(false); + Tabs.barMode(BarMode.Fixed); + Tabs.barWidth(360); + Tabs.barHeight(56); + Tabs.animationDuration(400); + Tabs.onChange((index) => { + this.currentIndex = index; + }); + Tabs.width(360); + Tabs.height(296); + Tabs.margin({ top: 52 }); + Tabs.backgroundColor('#F1F3F5'); + } }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { + TabContent.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + if (isInitialRender) { + Column.backgroundColor(Color.Pink); + Column.height(100); + Column.width(150); + } + }, Column); + Column.pop(); + }); if (isInitialRender) { - TabContent.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - Column.backgroundColor(Color.Pink); - Column.height(100); - Column.width(150); - } - }, Column); - Column.pop(); - }); TabContent.backgroundColor(Color.Pink); TabContent.height(100); TabContent.width(150); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts index ea86e20de..fef668ad7 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck7.ts @@ -118,22 +118,19 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); if (1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { + Checkbox.create(); + Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); if (isInitialRender) { - Checkbox.create(); Checkbox.backgroundColor(Color.Pink); Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); Checkbox.selectedColor(xx()); @@ -147,7 +144,6 @@ class Index extends ViewPU { Checkbox.width(dd().ee); Checkbox.height(30); } - Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts index ea86e20de..fef668ad7 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck8.ts @@ -118,22 +118,19 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); if (1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { + Checkbox.create(); + Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); if (isInitialRender) { - Checkbox.create(); Checkbox.backgroundColor(Color.Pink); Checkbox.shape(CheckBoxShape.ROUNDED_SQUARE); Checkbox.selectedColor(xx()); @@ -147,7 +144,6 @@ class Index extends ViewPU { Checkbox.width(dd().ee); Checkbox.height(30); } - Checkbox.select(this.applyToAll, newValue => { this.applyToAll = newValue; }); }, Checkbox); Checkbox.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts index 104ee7f08..d95ed6be0 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck9.ts @@ -111,15 +111,13 @@ class SheetSizeExample1 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.justifyContent(FlexAlign.Start); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Button.createWithLabel("transition modal 1"); - } + Button.createWithLabel("transition modal 1"); Button.bindSheet({ value: this.isShow, changeEvent: newValue => { this.isShow = newValue; } }, { builder: () => { this.myBuilder.call(this); } }, { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_if_elseIf_else.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_if_elseIf_else.ts index e40d982bf..37b4d21f0 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_if_elseIf_else.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_if_elseIf_else.ts @@ -91,14 +91,10 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.message); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/component_object.ts b/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/component_object.ts index 0a35149e6..a893abe82 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/component_object.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/component_object.ts @@ -97,9 +97,7 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -187,9 +185,7 @@ class Child extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.message1); @@ -226,14 +222,10 @@ class Child2 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create(this.message); - } + Text.create(this.message); }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts index dcf088a28..48ffa4dda 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/custom_component/custom_component.ts @@ -71,9 +71,7 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -91,8 +89,8 @@ class MyComponent extends ViewPU { }, { name: "Banner" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); if (isInitialRender) { - __Common__.create(); __Common__.width(100); } }, __Common__); @@ -113,8 +111,8 @@ class MyComponent extends ViewPU { } __Common__.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); if (isInitialRender) { - __Common__.create(); __Common__.width(100); __Common__.height(200); } @@ -153,8 +151,8 @@ class MyComponent extends ViewPU { }, { name: "Banner" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); if (isInitialRender) { - __Common__.create(); __Common__.width(100); } }, __Common__); @@ -177,8 +175,8 @@ class MyComponent extends ViewPU { } __Common__.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(); if (isInitialRender) { - __Common__.create(); __Common__.width(100); __Common__.height(200); } @@ -232,14 +230,10 @@ class Banner extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create(this.value); - } + Text.create(this.value); }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/GestureModeParallel.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/GestureModeParallel.ts index 17238ae38..7a869af4c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/GestureModeParallel.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/GestureModeParallel.ts @@ -65,14 +65,10 @@ class childTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create("hello"); - } + Text.create("hello"); Gesture.create(GesturePriority.Low); GestureGroup.create(GestureMode.Parallel); TapGesture.create({ count: 2 }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts index 4a4cf4d74..b70f92d6f 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts @@ -74,14 +74,7 @@ class LongPressGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(200); - Flex.width(300); - Flex.padding(60); - Flex.borderWidth(1); - Flex.margin(30); - } + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); Gesture.create(GesturePriority.Low); LongPressGesture.create({ repeat: true }); LongPressGesture.onAction((event) => { @@ -94,6 +87,13 @@ class LongPressGestureExample extends ViewPU { }); LongPressGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Flex.height(200); + Flex.width(300); + Flex.padding(60); + Flex.borderWidth(1); + Flex.margin(30); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('LongPress onAction:' + this.count); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts index 8a94e420f..82aa69864 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts @@ -94,14 +94,7 @@ class PanGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(100); - Flex.width(200); - Flex.padding(20); - Flex.borderWidth(1); - Flex.margin(80); - } + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); Flex.translate({ x: this.offsetX, y: this.offsetY, z: 5 }); Gesture.create(GesturePriority.Low); PanGesture.create({}); @@ -117,6 +110,13 @@ class PanGestureExample extends ViewPU { }); PanGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Flex.height(100); + Flex.width(200); + Flex.padding(20); + Flex.borderWidth(1); + Flex.margin(80); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('PanGesture offset X: ' + this.offsetX); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts index af80b34d7..56e795939 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts @@ -78,14 +78,7 @@ class PinchGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(100); - Flex.width(200); - Flex.padding(20); - Flex.borderWidth(1); - Flex.margin(80); - } + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); Flex.scale({ x: this.scale2, y: this.scale2, z: this.scale2 }); Gesture.create(GesturePriority.Low); PinchGesture.create(); @@ -100,6 +93,13 @@ class PinchGestureExample extends ViewPU { }); PinchGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Flex.height(100); + Flex.width(200); + Flex.padding(20); + Flex.borderWidth(1); + Flex.margin(80); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('PinchGesture scale:' + this.scale2); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts index f87599b3d..790ce93cd 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts @@ -78,14 +78,7 @@ class RotationGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(100); - Flex.width(200); - Flex.padding(20); - Flex.borderWidth(1); - Flex.margin(80); - } + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); Flex.rotate({ x: 1, y: 2, z: 3, angle: this.angle }); Gesture.create(GesturePriority.Low); RotationGesture.create(); @@ -100,6 +93,13 @@ class RotationGestureExample extends ViewPU { }); RotationGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Flex.height(100); + Flex.width(200); + Flex.padding(20); + Flex.borderWidth(1); + Flex.margin(80); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('RotationGesture angle:' + this.angle); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts index 180f45064..c662ff6fd 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/swipeGesture.ts @@ -88,12 +88,7 @@ class SwipeGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - Column.borderWidth(2); - Column.width(260); - Column.height(260); - } + Column.create(); Column.rotate({ x: 0, y: 0, z: 1, angle: this.rotateAngle }); Gesture.create(GesturePriority.Low); SwipeGesture.create({ fingers: 1, direction: SwipeDirection.Vertical }); @@ -103,6 +98,11 @@ class SwipeGestureExample extends ViewPU { }); SwipeGesture.pop(); Gesture.pop(); + if (isInitialRender) { + Column.borderWidth(2); + Column.width(260); + Column.height(260); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("SwipGesture speed : " + this.speed); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts index 775f4ef19..5eb453b7d 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts @@ -72,14 +72,7 @@ class TapGestureExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - Flex.height(200); - Flex.width(300); - Flex.padding(60); - Flex.borderWidth(1); - Flex.margin(30); - } + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); Gesture.create(GesturePriority.Low); TapGesture.create({ count: 2 }); TapGesture.onAction(() => { @@ -87,11 +80,16 @@ class TapGestureExample extends ViewPU { }); TapGesture.pop(); Gesture.pop(); - }, Flex); - this.observeComponentCreation2((elmtId, isInitialRender) => { if (isInitialRender) { - Text.create('Click twice'); + Flex.height(200); + Flex.width(300); + Flex.padding(60); + Flex.borderWidth(1); + Flex.margin(30); } + }, Flex); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Click twice'); }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts index 63af46d2c..10ac9aae7 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachSecondFunction.ts @@ -70,15 +70,15 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create({ space: 5 }); if (isInitialRender) { - Column.create({ space: 5 }); Column.width("100%"); Column.height("100%"); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('Reverse Array'); if (isInitialRender) { - Button.createWithLabel('Reverse Array'); Button.onClick(() => { this.arr.reverse(); }); @@ -90,15 +90,15 @@ class MyComponent extends ViewPU { const forEachItemGenFunction = _item => { const item = _item; this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('item'); if (isInitialRender) { - Text.create('item'); Text.fontSize(18); } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); if (isInitialRender) { - Divider.create(); Divider.strokeWidth(2); } }, Divider); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts index 25ae625c5..1c1375b15 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachThreeParam.ts @@ -85,9 +85,7 @@ class foreachThreeParam extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts index 049b238c9..9edee32db 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/forEachTwo.ts @@ -83,14 +83,14 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); if (isInitialRender) { - Row.create(); Row.height('100%'); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.width('100%'); } }, Column); @@ -99,9 +99,7 @@ class Index extends ViewPU { const forEachItemGenFunction = _item => { const { w, h } = _item; this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Button.createWithLabel(); - } + Button.createWithLabel(); Button.width(w); Button.height(h); }, Button); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts index 4b30fc99a..e8cfc46c3 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/foreach/foreach.ts @@ -160,9 +160,7 @@ class ParentView extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - List.create(); - } + List.create(); }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -215,9 +213,7 @@ class ParentView1 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - List.create(); - } + List.create(); }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -270,9 +266,7 @@ class ParentView2 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - List.create(); - } + List.create(); }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -325,9 +319,7 @@ class ParentView3 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - List.create(); - } + List.create(); }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -380,9 +372,7 @@ class ParentView4 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - List.create(); - } + List.create(); }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -435,9 +425,7 @@ class ParentView5 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - List.create(); - } + List.create(); }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -494,9 +482,7 @@ class ParentView6 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - List.create(); - } + List.create(); }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts index 6d22bf337..62bc9ad43 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts @@ -147,9 +147,7 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); @@ -161,8 +159,8 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(0, () => { if (!If.canRetake('id1')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('count is negative'); if (isInitialRender) { - Text.create('count is negative'); Text.fontSize(32); Text.id('id1'); } @@ -175,16 +173,16 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(1, () => { if (!If.canRetake('id2')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); if (isInitialRender) { - Divider.create(); Divider.id('id2'); } }, Divider); } if (!If.canRetake('id3')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('even'); if (isInitialRender) { - Text.create('even'); Text.fontSize(32); Text.id('id3'); } @@ -197,22 +195,22 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(2, () => { if (!If.canRetake('id4')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + Divider.create(); if (isInitialRender) { - Divider.create(); Divider.id('id4'); } }, Divider); } if (!If.canRetake('id10')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.id('id10'); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('odd'); if (isInitialRender) { - Text.create('odd'); Text.fontSize(32); Text.id('id5'); } @@ -230,8 +228,8 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(1, () => { if (!If.canRetake('id6')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('fail'); if (isInitialRender) { - Text.create('fail'); Text.id('id6'); Text.fontSize(32); } @@ -248,8 +246,8 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(0, () => { if (!If.canRetake('id7')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('odd2'); if (isInitialRender) { - Text.create('odd2'); Text.fontSize(32); Text.id('id7'); } @@ -265,9 +263,7 @@ class MyComponent extends ViewPU { }, If); If.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - List.create({ space: 3 }); - } + List.create({ space: 3 }); }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); @@ -284,23 +280,23 @@ class MyComponent extends ViewPU { ViewStackProcessor.StopGetAccessRecording(); }; const itemCreation2 = (elmtId, isInitialRender) => { + ListItem.create(deepRenderFunction, true); if (isInitialRender) { - ListItem.create(deepRenderFunction, true); ListItem.id('id8'); } }; const deepRenderFunction = (elmtId, isInitialRender) => { itemCreation(elmtId, isInitialRender); this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); if (isInitialRender) { - Row.create(); Row.margin({ left: 10, right: 10 }); Row.id('id11'); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create(); if (isInitialRender) { - Text.create(); Text.fontSize(20); Text.margin({ left: 10 }); } @@ -323,9 +319,7 @@ class MyComponent extends ViewPU { If.pop(); List.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Tabs.create({ barPosition: BarPosition.Start, controller: this.controller }); - } + Tabs.create({ barPosition: BarPosition.Start, controller: this.controller }); }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); @@ -333,18 +327,18 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(0, () => { if (!If.canRetake('id9')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + TabContent.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('111'); + if (isInitialRender) { + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Pink); + } + }, Text); + Text.pop(); + }); if (isInitialRender) { - TabContent.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('111'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Pink); - } - }, Text); - Text.pop(); - }); TabContent.tabBar('pink'); TabContent.id('id9'); } @@ -369,49 +363,39 @@ class MyComponent extends ViewPU { if (this.count === 10) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('111'); - } + Text.create('111'); }, Text); Text.pop(); Column.pop(); if (!If.canRetake('id12')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + XComponent.create({ id: 'special', type: '' }); if (isInitialRender) { - XComponent.create({ id: 'special', type: '' }); XComponent.id('id12'); } }, XComponent); } if (!If.canRetake('id13')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.id('id13'); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('11'); - } + Text.create('11'); }, Text); Text.pop(); Column.pop(); } this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('222'); - } + Text.create('222'); }, Text); Text.pop(); Column.pop(); @@ -437,8 +421,8 @@ class MyComponent extends ViewPU { this.ifElseBranchUpdateFunction(0, () => { if (!If.canRetake('id14')) { this.observeComponentCreation2((elmtId, isInitialRender) => { + __Common__.create(true); if (isInitialRender) { - __Common__.create(true); __Common__.id('id14'); } }, __Common__); @@ -460,9 +444,7 @@ class MyComponent extends ViewPU { __Common__.pop(); } this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('111'); - } + Text.create('111'); }, Text); Text.pop(); }); @@ -500,13 +482,11 @@ class Child extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('Child'); if (isInitialRender) { - Text.create('Child'); Text.fontSize(50); } }, Text); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts index 8308b8022..9137624c1 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/if.ts @@ -101,18 +101,14 @@ class IFView extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { If.create(); if (this.toggle1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('toggle1'); - } + Text.create('toggle1'); }, Text); Text.pop(); }); @@ -120,9 +116,7 @@ class IFView extends ViewPU { else if (this.toggle2) { this.ifElseBranchUpdateFunction(1, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('toggle2'); - } + Text.create('toggle2'); }, Text); Text.pop(); }); @@ -130,9 +124,7 @@ class IFView extends ViewPU { else if (this.toggle3) { this.ifElseBranchUpdateFunction(2, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('toggle3'); - } + Text.create('toggle3'); }, Text); Text.pop(); }); @@ -140,9 +132,7 @@ class IFView extends ViewPU { else { this.ifElseBranchUpdateFunction(3, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('toggle no thing'); - } + Text.create('toggle no thing'); }, Text); Text.pop(); }); @@ -154,9 +144,7 @@ class IFView extends ViewPU { if (this.toggle1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('toggle1 Single'); - } + Text.create('toggle1 Single'); }, Text); Text.pop(); }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts index 8b1c3f7f0..83df16b53 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/GridItem.ts @@ -52,14 +52,12 @@ class ParentView extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Grid.create(); - } + Grid.create(); }, Grid); { const itemCreation2 = (elmtId, isInitialRender) => { + GridItem.create(() => { }, false, 'true'); if (isInitialRender) { - GridItem.create(() => { }, false, 'true'); GridItem.width(200); GridItem.height(100); } @@ -67,8 +65,8 @@ class ParentView extends ViewPU { const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, GridItem); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('xx'); if (isInitialRender) { - Text.create('xx'); Text.width(100); } }, Text); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts index 604124e83..81ee833dc 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/item/ListItem.ts @@ -52,9 +52,7 @@ class ParentView extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - List.create(); - } + List.create(); }, List); { const itemCreation = (elmtId, isInitialRender) => { @@ -66,8 +64,8 @@ class ParentView extends ViewPU { ViewStackProcessor.StopGetAccessRecording(); }; const itemCreation2 = (elmtId, isInitialRender) => { + ListItem.create(deepRenderFunction, true, 'true'); if (isInitialRender) { - ListItem.create(deepRenderFunction, true, 'true'); ListItem.width(200); ListItem.height(100); } @@ -75,8 +73,8 @@ class ParentView extends ViewPU { const deepRenderFunction = (elmtId, isInitialRender) => { itemCreation(elmtId, isInitialRender); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('xx'); if (isInitialRender) { - Text.create('xx'); Text.width(100); } }, Text); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts index d3cd182b7..b0df01602 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts @@ -256,8 +256,8 @@ class lazyforEachThreeParam extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + List.create({ space: 3 }); if (isInitialRender) { - List.create({ space: 3 }); List.cachedCount(5); } }, List); @@ -266,24 +266,24 @@ class lazyforEachThreeParam extends ViewPU { const item = _item; { const itemCreation2 = (elmtId, isInitialRender) => { - if (isInitialRender) { - ListItem.create(() => { }, false); - } + ListItem.create(() => { }, false); }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, ListItem); this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); if (isInitialRender) { - Row.create(); Row.margin({ left: 10, right: 10 }); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(item); - Text.fontSize(50); - Text.onAppear(() => { - console.info("appear:" + item); - }); + if (isInitialRender) { + Text.fontSize(50); + Text.onAppear(() => { + console.info("appear:" + item); + }); + } }, Text); Text.pop(); Row.pop(); @@ -301,24 +301,24 @@ class lazyforEachThreeParam extends ViewPU { const item = _item; { const itemCreation2 = (elmtId, isInitialRender) => { - if (isInitialRender) { - ListItem.create(() => { }, false); - } + ListItem.create(() => { }, false); }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, ListItem); this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); if (isInitialRender) { - Row.create(); Row.margin({ left: 10, right: 10 }); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(item); - Text.fontSize(50); - Text.onAppear(() => { - console.info("appear:" + item); - }); + if (isInitialRender) { + Text.fontSize(50); + Text.onAppear(() => { + console.info("appear:" + item); + }); + } }, Text); Text.pop(); Row.pop(); @@ -336,24 +336,24 @@ class lazyforEachThreeParam extends ViewPU { const item = _item; { const itemCreation2 = (elmtId, isInitialRender) => { - if (isInitialRender) { - ListItem.create(() => { }, false); - } + ListItem.create(() => { }, false); }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, ListItem); this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); if (isInitialRender) { - Row.create(); Row.margin({ left: 10, right: 10 }); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(item); - Text.fontSize(50); - Text.onAppear(() => { - console.info("appear:" + item); - }); + if (isInitialRender) { + Text.fontSize(50); + Text.onAppear(() => { + console.info("appear:" + item); + }); + } }, Text); Text.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforeach.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforeach.ts index 972eccd40..7fcdfe04f 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforeach.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforeach.ts @@ -221,18 +221,14 @@ class Test extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Grid.create(); - } + Grid.create(); }, Grid); { const __lazyForEachItemGenFunction = _item => { const row = _item; { const itemCreation2 = (elmtId, isInitialRender) => { - if (isInitialRender) { - GridItem.create(() => { }, false); - } + GridItem.create(() => { }, false); }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, GridItem); @@ -284,18 +280,14 @@ class ChildTest extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Grid.create(); - } + Grid.create(); }, Grid); { const __lazyForEachItemGenFunction = _item => { const row = _item; { const itemCreation2 = (elmtId, isInitialRender) => { - if (isInitialRender) { - GridItem.create(() => { }, false); - } + GridItem.create(() => { }, false); }; const observedDeepRender = () => { this.observeComponentCreation2(itemCreation2, GridItem); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts index b5308ecf0..e2bd781a2 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeat.ts @@ -118,8 +118,8 @@ class HomeComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.height(500); } }, Column); @@ -188,8 +188,8 @@ class ChildComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.height(500); } }, Column); @@ -247,8 +247,8 @@ class ChildComponent2 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + List.create(); if (isInitialRender) { - List.create(); List.height(500); } }, List); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts index fd734725e..e79535d14 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/repeat/repeatVirtualScroll.ts @@ -98,8 +98,8 @@ class ChildComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + List.create(); if (isInitialRender) { - List.create(); List.height(500); } }, List); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts index fddd17ce7..68a6f7d5c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/tab/tab.ts @@ -81,51 +81,47 @@ class TabSimple extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Tabs.create({ barPosition: BarPosition.Start, index: 1, controller: this.controller }); - } + Tabs.create({ barPosition: BarPosition.Start, index: 1, controller: this.controller }); }, Tabs); this.observeComponentCreation2((elmtId, isInitialRender) => { + TabContent.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Flex.create(); + if (isInitialRender) { + Flex.height(100); + Flex.width(200); + } + }, Flex); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + if (isInitialRender) { + Column.height(100); + Column.width(200); + } + }, Column); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('text1'); + if (isInitialRender) { + Text.height(100); + Text.width(200); + } + }, Text); + Text.pop(); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('xxx'); + if (isInitialRender) { + Text.height(100); + Text.width(200); + } + }, Text); + Text.pop(); + Column.pop(); + Flex.pop(); + }); if (isInitialRender) { - TabContent.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Flex.create(); - Flex.height(100); - Flex.width(200); - } - }, Flex); - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - Column.height(100); - Column.width(200); - } - }, Column); - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('text1'); - Text.height(100); - Text.width(200); - } - }, Text); - Text.pop(); - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('xxx'); - Text.height(100); - Text.width(200); - } - }, Text); - Text.pop(); - Column.pop(); - Flex.pop(); - }); TabContent.tabBar("TabBar"); TabContent.height(100); TabContent.width(200); @@ -133,15 +129,13 @@ class TabSimple extends ViewPU { }, TabContent); TabContent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + TabContent.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('text2'); + }, Text); + Text.pop(); + }); if (isInitialRender) { - TabContent.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('text2'); - } - }, Text); - Text.pop(); - }); TabContent.tabBar("TabBar 2"); TabContent.height(100); TabContent.width(200); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts index 929788bf0..bb974f336 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts @@ -59,18 +59,14 @@ class ButtonExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }); - } + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }); }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Flex.create({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); - } + Flex.create({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }); }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('Ok', { type: ButtonType.Normal, stateEffect: true }); if (isInitialRender) { - Button.createWithLabel('Ok', { type: ButtonType.Normal, stateEffect: true }); Button.borderRadius(8); Button.backgroundColor(0x317aff); Button.width(90); @@ -78,22 +74,22 @@ class ButtonExample extends ViewPU { }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithChild({ type: ButtonType.Normal, stateEffect: true }); if (isInitialRender) { - Button.createWithChild({ type: ButtonType.Normal, stateEffect: true }); Button.borderRadius(8); Button.backgroundColor(0x317aff); Button.width(90); } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); if (isInitialRender) { - Row.create(); Row.alignItems(VerticalAlign.Center); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('loading'); if (isInitialRender) { - Text.create('loading'); Text.fontSize(12); Text.fontColor(0xffffff); Text.margin({ left: 5, right: 12 }); @@ -103,8 +99,8 @@ class ButtonExample extends ViewPU { Row.pop(); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel('Disable', { type: ButtonType.Normal, stateEffect: false }); if (isInitialRender) { - Button.createWithLabel('Disable', { type: ButtonType.Normal, stateEffect: false }); Button.opacity(0.5); Button.borderRadius(8); Button.backgroundColor(0x317aff); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/xcomponent/XComponentContainer.ts b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/xcomponent/XComponentContainer.ts index b62c9175c..f9eb9354d 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/xcomponent/XComponentContainer.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/xcomponent/XComponentContainer.ts @@ -54,26 +54,18 @@ class HomeComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - XComponent.create({ id: '1', type: 'component' }); - } + XComponent.create({ id: '1', type: 'component' }); }, XComponent); XComponent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - XComponent.create({ id: '2', type: 1 }); - } + XComponent.create({ id: '2', type: 1 }); }, XComponent); XComponent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - XComponent.create({ id: '3', type: XComponentType.COMPONENT }); - } + XComponent.create({ id: '3', type: XComponentType.COMPONENT }); }, XComponent); XComponent.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts index 850784391..534638898 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts @@ -216,8 +216,8 @@ class TransitionExample extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, }); if (isInitialRender) { - Flex.create({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, }); Flex.height(400); Flex.width("100%"); Flex.padding({ top: 100 }); @@ -225,17 +225,19 @@ class TransitionExample extends ViewPU { }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.show); - Button.onClick(() => { - Context.animateTo({ duration: 1000 }, () => { - this.btn1 = !this.btn1; - if (this.btn1) { - this.show = "hide"; - } - else { - this.show = "show"; - } + if (isInitialRender) { + Button.onClick(() => { + Context.animateTo({ duration: 1000 }, () => { + this.btn1 = !this.btn1; + if (this.btn1) { + this.show = "hide"; + } + else { + this.show = "show"; + } + }); }); - }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -243,8 +245,8 @@ class TransitionExample extends ViewPU { if (this.btn1) { this.ifElseBranchUpdateFunction(0, () => { this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel(); if (isInitialRender) { - Button.createWithLabel(); Button.width("80%"); Button.height(30); Button.transition({ type: TransitionType.Insert, scale: { x: 0, y: 1.0 } }); @@ -261,9 +263,7 @@ class TransitionExample extends ViewPU { }, If); If.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Button.createWithLabel('animation'); - } + Button.createWithLabel('animation'); Context.animation({ duration: 1000, curve: Curve.EaseOut, @@ -280,16 +280,14 @@ class TransitionExample extends ViewPU { }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create({ space: 5 }); if (isInitialRender) { - Column.create({ space: 5 }); Column.width("100%"); Column.height("100%"); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); Context.animation({ duration: 1000 }); Column.opacity(this.opacity1); Column.backgroundColor(ObservedObject.GetRawObject(this.color)); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts index e7b22e3e3..ae3878bb0 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navDestination_component/navDestination_component.ts @@ -61,30 +61,26 @@ class PageOne extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { + NavDestination.create(() => { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); + if (isInitialRender) { + Column.width('100%'); + Column.height('100%'); + } + }, Column); + Column.pop(); + }, { moduleName: "", pagePath: "navDestination_component" }); if (isInitialRender) { - NavDestination.create(() => { - this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - Column.width('100%'); - Column.height('100%'); - } - }, Column); - Column.pop(); - }, { moduleName: "", pagePath: "navDestination_component" }); NavDestination.title('pageOne'); } }, NavDestination); NavDestination.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - NavDestination.create(() => { }, { moduleName: "", pagePath: "navDestination_component" }); - } + NavDestination.create(() => { }, { moduleName: "", pagePath: "navDestination_component" }); }, NavDestination); NavDestination.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts index 5312ad94c..f8a674892 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/navigation/navigation_component.ts @@ -61,20 +61,18 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { + Navigation.create(this.pageStack, { moduleName: "", pagePath: "navigation_component", isUserCreateStack: true }); if (isInitialRender) { - Navigation.create(this.pageStack, { moduleName: "", pagePath: "navigation_component", isUserCreateStack: true }); Navigation.title('Main'); } }, Navigation); Navigation.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Navigation.create(new NavPathStack(), { moduleName: "", pagePath: "navigation_component", isUserCreateStack: false }); if (isInitialRender) { - Navigation.create(new NavPathStack(), { moduleName: "", pagePath: "navigation_component", isUserCreateStack: false }); Navigation.title('Main'); } }, Navigation); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts index d818d1750..6109f4dfa 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/pageTransition/pageTransition.ts @@ -107,23 +107,21 @@ class PageTransitionExample1 extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); Column.scale({ x: this.scale2 }); Column.opacity(this.opacity2); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { + Navigator.create({ target: 'pages/page1', type: NavigationType.Push }); if (isInitialRender) { - Navigator.create({ target: 'pages/page1', type: NavigationType.Push }); Navigator.onClick(() => { this.active = true; }); } }, Navigator); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create('page transition'); if (isInitialRender) { - Text.create('page transition'); Text.width("100%"); Text.height("100%"); } diff --git a/compiler/test/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ts b/compiler/test/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ts index 4d7656b28..da8c00ff9 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@AnimatableExtend/animatableExtend.ts @@ -110,9 +110,11 @@ class HomeComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Polyline.create(); animatablePoints(this.points, elmtId, isInitialRender, this); - Polyline.strokeWidth(3); - Polyline.height(100); - Polyline.width(100); + if (isInitialRender) { + Polyline.strokeWidth(3); + Polyline.height(100); + Polyline.width(100); + } }, Polyline); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hello"); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts index a93e12525..dd897f34f 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts @@ -245,7 +245,9 @@ class MyComponent extends ViewPU { textBuilder(parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("文本"); - Text.fontSize(30); + if (isInitialRender) { + Text.fontSize(30); + } }, Text); Text.pop(); } diff --git a/compiler/test/utForPartialUpdate/render_decorator/@customDialog/@customDialog.ts b/compiler/test/utForPartialUpdate/render_decorator/@customDialog/@customDialog.ts index 5daf057e1..d58acb757 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@customDialog/@customDialog.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@customDialog/@customDialog.ts @@ -169,9 +169,11 @@ class DialogExample extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('current count is: ' + this.count); - Button.onClick(() => { - this.count++; - }); + if (isInitialRender) { + Button.onClick(() => { + this.count++; + }); + } }, Button); Button.pop(); Row.pop(); @@ -180,9 +182,11 @@ class DialogExample extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.isPlaying ? 'play' : 'pause'); - Button.onClick(() => { - this.isPlaying = !this.isPlaying; - }); + if (isInitialRender) { + Button.onClick(() => { + this.isPlaying = !this.isPlaying; + }); + } }, Button); Button.pop(); Row.pop(); @@ -191,18 +195,22 @@ class DialogExample extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("Option A"); - Button.onClick(() => { - this.controller.close(); - this.action1(); - }); + if (isInitialRender) { + Button.onClick(() => { + this.controller.close(); + this.action1(); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("Option B"); - Button.onClick(() => { - this.controller.close(); - this.action2(47, "Option B is great choice"); - }); + if (isInitialRender) { + Button.onClick(() => { + this.controller.close(); + this.action2(47, "Option B is great choice"); + }); + } }, Button); Button.pop(); Row.pop(); @@ -295,28 +303,36 @@ class CustomDialogUser extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('current countInitValue is: ' + this.countInitValue); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('current playingInitValue is: ' + this.playingInitValue); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("Click to open Dialog -1"); - Button.onClick(() => { - this.countInitValue--; - this.dialogController.open(); - }); + if (isInitialRender) { + Button.onClick(() => { + this.countInitValue--; + this.dialogController.open(); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel("Click to close Dialog +1"); - Button.onClick(() => { - this.countInitValue++; - this.dialogController.close(); - }); + if (isInitialRender) { + Button.onClick(() => { + this.countInitValue++; + this.dialogController.close(); + }); + } }, Button); Button.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@preview/@preview.ts b/compiler/test/utForPartialUpdate/render_decorator/@preview/@preview.ts index 08f8d74d7..a1395f1d4 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@preview/@preview.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@preview/@preview.ts @@ -67,7 +67,9 @@ class HomePreviewComponent extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.value); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); } diff --git a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_extend_styles.ts b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_extend_styles.ts index 83e9e3e70..7cd3840de 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_extend_styles.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_extend_styles.ts @@ -205,26 +205,25 @@ class StylesComponent extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Red); Text.width(this.width_value); if (isInitialRender) { + Text.backgroundColor(Color.Red); Text.height(100); } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Blue); Text.width(this.width_value); Text.fontSize(this.size_value); if (isInitialRender) { + Text.backgroundColor(Color.Blue); Text.height(100); } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild(); - Button.backgroundColor(Color.Blue); Button.width(this.width_value); ViewStackProcessor.visualState("normal"); Button.backgroundColor(Color.Green); @@ -236,6 +235,7 @@ class StylesComponent extends ViewPU { Button.backgroundColor(Color.Red); ViewStackProcessor.visualState(); if (isInitialRender) { + Button.backgroundColor(Color.Blue); Button.enabled(this.enable); Button.onClick(() => { this.enable = false; @@ -245,9 +245,9 @@ class StylesComponent extends ViewPU { }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Red); Text.fontSize(this.size_value); if (isInitialRender) { + Text.backgroundColor(Color.Red); Text.height(100); } }, Text); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts index 08aefbe5a..8755430ee 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts @@ -24,7 +24,7 @@ struct GestureTest { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { Text('LongPress onAction:' + this.count) .height(100) - .width(width_value) + .width(this.width_value) } .height(100).width(this.width_value).padding(60).border({ width:1 }).margin(30) .gesture( @@ -110,13 +110,13 @@ class GestureTest extends ViewPU { if (isInitialRender) { Flex.height(100); Flex.padding(60); - Flex.border({ width: 1 }); + Flex.borderWidth(1); Flex.margin(30); } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('LongPress onAction:' + this.count); - Text.width(width_value); + Text.width(this.width_value); if (isInitialRender) { Text.height(100); } diff --git a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_reuseId.ts b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_reuseId.ts index 3b72a5a40..b0fa5d849 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_reuseId.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_reuseId.ts @@ -107,8 +107,11 @@ class HomeComponent extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.border({ width: 3, color: Color.Red }); __Common__.width(this.state_value); + if (isInitialRender) { + __Common__.borderColor(Color.Red); + __Common__.borderWidth(3); + } }, __Common__); this.observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); @@ -149,7 +152,10 @@ class HomeComponent extends ViewPU { __Recycle__.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.border({ width: 3, color: Color.Red }); + if (isInitialRender) { + __Common__.borderColor(Color.Red); + __Common__.borderWidth(3); + } }, __Common__); this.observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); @@ -226,8 +232,11 @@ class HomeComponent extends ViewPU { __Recycle__.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.border({ width: 3, color: Color.Red }); __Common__.width(this.state_value); + if (isInitialRender) { + __Common__.borderColor(Color.Red); + __Common__.borderWidth(3); + } }, __Common__); this.observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts b/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts index 6e17c41ea..0daa9c735 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@styles/@styles.ts @@ -101,13 +101,11 @@ class FancyUse extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create({ space: 10 }); - } + Column.create({ space: 10 }); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create("Fancy"); if (isInitialRender) { - Text.create("Fancy"); Text.backgroundColor(Color.Red); Text.width(100); Text.height(100); @@ -115,8 +113,8 @@ class FancyUse extends ViewPU { }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Text.create("Fancy"); if (isInitialRender) { - Text.create("Fancy"); Text.backgroundColor(Color.Blue); Text.width(100); Text.height(100); @@ -124,35 +122,31 @@ class FancyUse extends ViewPU { }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithChild(); + Button.enabled(this.enable); + ViewStackProcessor.visualState("normal"); + Button.backgroundColor(Color.Green); + ViewStackProcessor.visualState("disabled"); + Button.backgroundColor(Color.Blue); + ViewStackProcessor.visualState("pressed"); + Button.backgroundColor(Color.Red); + ViewStackProcessor.visualState(); if (isInitialRender) { - Button.createWithChild(); Button.onClick(() => { this.enable = false; }); - ViewStackProcessor.visualState("normal"); - Button.backgroundColor(Color.Green); - ViewStackProcessor.visualState("disabled"); - Button.backgroundColor(Color.Blue); - ViewStackProcessor.visualState("pressed"); - Button.backgroundColor(Color.Red); - ViewStackProcessor.visualState(); } - Button.enabled(this.enable); }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create("Fancy"); - } + Text.create("Fancy"); }, Text); Text.pop(); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create("Fancy"); - ViewStackProcessor.visualState("normal"); - Text.width(200); - ViewStackProcessor.visualState(); - } + Text.create("Fancy"); + ViewStackProcessor.visualState("normal"); + Text.width(200); + ViewStackProcessor.visualState(); }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesExport.ts b/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesExport.ts index fa77cedea..6d45f2e92 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesExport.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesExport.ts @@ -98,24 +98,25 @@ class FancyUseExp extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Red); - Text.width(100); - Text.height(100); + if (isInitialRender) { + Text.backgroundColor(Color.Red); + Text.width(100); + Text.height(100); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); - Text.backgroundColor(Color.Blue); - Text.width(100); - Text.height(100); + if (isInitialRender) { + Text.backgroundColor(Color.Blue); + Text.width(100); + Text.height(100); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild(); Button.enabled(this.enable); - Button.onClick(() => { - this.enable = false; - }); ViewStackProcessor.visualState("normal"); Button.backgroundColor(Color.Green); ViewStackProcessor.visualState("disabled"); @@ -123,6 +124,11 @@ class FancyUseExp extends ViewPU { ViewStackProcessor.visualState("pressed"); Button.backgroundColor(Color.Red); ViewStackProcessor.visualState(); + if (isInitialRender) { + Button.onClick(() => { + this.enable = false; + }); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Fancy"); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesOrComponentAsName.ts b/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesOrComponentAsName.ts index e5580730a..844875da1 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesOrComponentAsName.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@styles/@stylesOrComponentAsName.ts @@ -112,9 +112,11 @@ class Index extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('111'); - Text.width(30); - Text.backgroundColor(Color.Blue); - Text.height(30); + if (isInitialRender) { + Text.backgroundColor(Color.Blue); + Text.width(30); + Text.height(30); + } }, Text); Text.pop(); { @@ -193,9 +195,11 @@ class ComA extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('111'); - Text.backgroundColor(Color.Blue); - Text.width(30); - Text.height(30); + if (isInitialRender) { + Text.backgroundColor(Color.Blue); + Text.width(30); + Text.height(30); + } }, Text); Text.pop(); Row.pop(); @@ -229,9 +233,11 @@ class ComB extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('111'); - Text.width(30); - Text.height(30); - Text.backgroundColor(Color.Blue); + if (isInitialRender) { + Text.backgroundColor(Color.Blue); + Text.width(30); + Text.height(30); + } }, Text); Text.pop(); Row.pop(); @@ -265,11 +271,13 @@ class MyComponent extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Text1'); - Text.fontSize(50); - Text.fontColor(Color.White); ViewStackProcessor.visualState("normal"); Text.backgroundColor(Color.Gray); ViewStackProcessor.visualState(); + if (isInitialRender) { + Text.fontSize(50); + Text.fontColor(Color.White); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts index 791760a73..71b95db5c 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageLink/@storageLink.ts @@ -100,28 +100,30 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create({ space: 20 }); - } + Row.create({ space: 20 }); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.label + ': ' + this.varA); - Button.onClick(() => { - AppStorage.Set('varA', AppStorage.Get('varA') + 1); - }); + if (isInitialRender) { + Button.onClick(() => { + AppStorage.Set('varA', AppStorage.Get('varA') + 1); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('lang: ' + this.lang); - Button.onClick(() => { - if (this.lang === 'zh') { - AppStorage.Set('languageCode', 'en'); - } - else { - AppStorage.Set('languageCode', 'zh'); - } - this.label = (this.lang === 'zh') ? '数' : 'Count'; - }); + if (isInitialRender) { + Button.onClick(() => { + if (this.lang === 'zh') { + AppStorage.Set('languageCode', 'en'); + } + else { + AppStorage.Set('languageCode', 'zh'); + } + this.label = (this.lang === 'zh') ? '数' : 'Count'; + }); + } }, Button); Button.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts index 791760a73..71b95db5c 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/@storageProp/@storageProp.ts @@ -100,28 +100,30 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create({ space: 20 }); - } + Row.create({ space: 20 }); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.label + ': ' + this.varA); - Button.onClick(() => { - AppStorage.Set('varA', AppStorage.Get('varA') + 1); - }); + if (isInitialRender) { + Button.onClick(() => { + AppStorage.Set('varA', AppStorage.Get('varA') + 1); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('lang: ' + this.lang); - Button.onClick(() => { - if (this.lang === 'zh') { - AppStorage.Set('languageCode', 'en'); - } - else { - AppStorage.Set('languageCode', 'zh'); - } - this.label = (this.lang === 'zh') ? '数' : 'Count'; - }); + if (isInitialRender) { + Button.onClick(() => { + if (this.lang === 'zh') { + AppStorage.Set('languageCode', 'en'); + } + else { + AppStorage.Set('languageCode', 'zh'); + } + this.label = (this.lang === 'zh') ? '数' : 'Count'; + }); + } }, Button); Button.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts index 791760a73..71b95db5c 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/appStorage/appStorage.ts @@ -100,28 +100,30 @@ class MyComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create({ space: 20 }); - } + Row.create({ space: 20 }); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.label + ': ' + this.varA); - Button.onClick(() => { - AppStorage.Set('varA', AppStorage.Get('varA') + 1); - }); + if (isInitialRender) { + Button.onClick(() => { + AppStorage.Set('varA', AppStorage.Get('varA') + 1); + }); + } }, Button); Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('lang: ' + this.lang); - Button.onClick(() => { - if (this.lang === 'zh') { - AppStorage.Set('languageCode', 'en'); - } - else { - AppStorage.Set('languageCode', 'zh'); - } - this.label = (this.lang === 'zh') ? '数' : 'Count'; - }); + if (isInitialRender) { + Button.onClick(() => { + if (this.lang === 'zh') { + AppStorage.Set('languageCode', 'en'); + } + else { + AppStorage.Set('languageCode', 'zh'); + } + this.label = (this.lang === 'zh') ? '数' : 'Count'; + }); + } }, Button); Button.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts index fa4ba9c7c..c40a3d900 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorage.ts @@ -95,17 +95,19 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.height(500); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.objectName.a); - Text.onClick(() => { - this.simpleVarName += 1; - this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; - }); + if (isInitialRender) { + Text.onClick(() => { + this.simpleVarName += 1; + this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; + }); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts index 1aaaeaf9a..d3d0e55f0 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForBoth.ts @@ -100,17 +100,19 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.height(500); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.objectName.a); - Text.onClick(() => { - this.simpleVarName += 1; - this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; - }); + if (isInitialRender) { + Text.onClick(() => { + this.simpleVarName += 1; + this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; + }); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForChainCall.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForChainCall.ts index c20512ccc..f29a385eb 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForChainCall.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForChainCall.ts @@ -86,9 +86,7 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts index b3f851680..e7180e7a2 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForRoute.ts @@ -55,8 +55,8 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.height(500); } }, Column); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts index ffcaea9d7..31744f397 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForStorage.ts @@ -97,17 +97,19 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { + Column.create(); if (isInitialRender) { - Column.create(); Column.height(500); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.objectName.a); - Text.onClick(() => { - this.simpleVarName += 1; - this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; - }); + if (isInitialRender) { + Text.onClick(() => { + this.simpleVarName += 1; + this.objectName.a = this.objectName.a === 'x' ? 'yex' : 'no'; + }); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThree.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThree.ts index e5cc89702..15c5c1eb6 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThree.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThree.ts @@ -83,9 +83,7 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThreeParam.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThreeParam.ts index f94b4a7d3..776ac4c2c 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThreeParam.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageForThreeParam.ts @@ -81,9 +81,7 @@ class LocalStorageComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageParam.ts b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageParam.ts index 37e51ce91..d180ff00e 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageParam.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/application_state_management/localStorage/localStorageParam.ts @@ -97,9 +97,7 @@ class localStorageParam extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@link/@link.ts b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@link/@link.ts index a7eac2ebe..acf5a20f9 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@link/@link.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@link/@link.ts @@ -109,9 +109,7 @@ class ParentComponent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ts b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ts index a8ed9dad1..3e23db5f7 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@objectLink/@objectLink.ts @@ -103,9 +103,7 @@ class CustomText extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.model.text); @@ -154,9 +152,7 @@ class Parent extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@prop.ts b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@prop.ts index d77ee41c6..4a9a1d1d5 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@prop.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@prop.ts @@ -109,9 +109,7 @@ class CustomY extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@propComplexType.ts b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@propComplexType.ts index b31c516ce..8ce03ca99 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@propComplexType.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@prop/@propComplexType.ts @@ -105,9 +105,7 @@ class CustomX extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(JSON.stringify(this.fruit.c)); @@ -152,9 +150,7 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); { this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ts b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ts index a7dd3218b..f60667b47 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/inner_struct_state_management/@state/@state.ts @@ -63,9 +63,7 @@ class StatePage extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("counter:" + this.counter); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts b/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts index dc1251e92..1933fbcd5 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/others/@consume_@provide/@consume_@provide.ts @@ -113,9 +113,7 @@ class CompA extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -133,8 +131,8 @@ class CompA extends ViewPU { }, { name: "CompB" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithChild(); if (isInitialRender) { - Button.createWithChild(); Button.onClick(() => { this.reviewVotes += 1; }); @@ -142,7 +140,9 @@ class CompA extends ViewPU { }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('' + this.reviewVotes); - Text.fontSize(30); + if (isInitialRender) { + Text.fontSize(30); + } }, Text); Text.pop(); Button.pop(); @@ -173,9 +173,7 @@ class CompB extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -228,13 +226,11 @@ class CompC extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithChild(); if (isInitialRender) { - Button.createWithChild(); Button.onClick(() => { this.reviewVotes += 1; }); @@ -242,7 +238,9 @@ class CompC extends ViewPU { }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('' + this.reviewVotes); - Text.fontSize(30); + if (isInitialRender) { + Text.fontSize(30); + } }, Text); Text.pop(); Button.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink.ts b/compiler/test/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink.ts index ab2fbd874..b83b304ca 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/others/@observed_@objectLink/@observed_@objectLink.ts @@ -114,9 +114,7 @@ class ViewA extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('ViewA-' + this.varA.id); @@ -161,14 +159,10 @@ class ViewB extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); { this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -190,9 +184,7 @@ class ViewB extends ViewPU { }, { name: "ViewA" }); } this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Text.create('ViewB'); - } + Text.create('ViewB'); }, Text); Text.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts b/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts index b458c50c8..66c4d604e 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/others/@watch/@watch.ts @@ -162,13 +162,11 @@ class CompA extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel("add to basket"); if (isInitialRender) { - Button.createWithLabel("add to basket"); Button.onClick(() => { this.shopBasket.push(Math.round(100 * Math.random())); }); @@ -177,12 +175,14 @@ class CompA extends ViewPU { Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('totalPurchase: ' + this.totalPurchase); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { + Button.createWithLabel("put item"); if (isInitialRender) { - Button.createWithLabel("put item"); Button.onClick(() => { let alList = 'abcdefghijklmnopqrstuvwxyz'; let ranItem = alList[Math.floor(Math.random() * 26)]; @@ -193,7 +193,9 @@ class CompA extends ViewPU { Button.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('tips: ' + this.resultTip); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck.ts b/compiler/test/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck.ts index 25d899b65..46bd26d83 100644 --- a/compiler/test/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck.ts +++ b/compiler/test/utForPartialUpdate/ui_state_management/others/decoratorKeyCheck/decoratorKeyCheck.ts @@ -393,9 +393,7 @@ class Index extends ViewPU { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Row.create(); - } + Row.create(); }, Row); Row.pop(); } diff --git a/compiler/test/utForPartialUpdate/v2_component_decorator/builderParamStyles.ts b/compiler/test/utForPartialUpdate/v2_component_decorator/builderParamStyles.ts index 769b78b99..28ce75743 100644 --- a/compiler/test/utForPartialUpdate/v2_component_decorator/builderParamStyles.ts +++ b/compiler/test/utForPartialUpdate/v2_component_decorator/builderParamStyles.ts @@ -94,8 +94,10 @@ class HomeComponent extends ViewV2 { }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hello HomeComponent"); - Text.fontSize(30); - Text.backgroundColor(Color.Red); + if (isInitialRender) { + Text.backgroundColor(Color.Red); + Text.fontSize(30); + } }, Text); Text.pop(); Button.pop(); diff --git a/compiler/test/utForPartialUpdate/v2_component_decorator/param_event_twoway_binding.ts b/compiler/test/utForPartialUpdate/v2_component_decorator/param_event_twoway_binding.ts index ae7468aa5..e8d30cbf0 100644 --- a/compiler/test/utForPartialUpdate/v2_component_decorator/param_event_twoway_binding.ts +++ b/compiler/test/utForPartialUpdate/v2_component_decorator/param_event_twoway_binding.ts @@ -72,9 +72,7 @@ class HomeComponent extends ViewV2 { } initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { - if (isInitialRender) { - Column.create(); - } + Column.create(); }, Column); { this.observeComponentCreation2((elmtId, isInitialRender) => { -- Gitee From 2354b675a3280f1f9a9c98b18e12781b62064dbc Mon Sep 17 00:00:00 2001 From: YanXingyu <285685173@qq.com> Date: Tue, 13 Aug 2024 16:45:07 +0800 Subject: [PATCH 18/18] pass all test Signed-off-by: YanXingyu <285685173@qq.com> --- compiler/src/pre_define.ts | 38 +++- compiler/src/process_component_build.ts | 20 +- .../import/import@CustomDialog.ts | 2 +- .../import/import@Observed.ts | 8 +- .../$$_component/$$_componentCheck1.ts | 5 +- .../$$_component/$$_componentCheck6.ts | 5 +- .../gesture_component/longPressGesture.ts | 10 +- .../gesture_component/panGestrue.ts | 10 +- .../gesture_component/pinchGesture.ts | 10 +- .../gesture_component/rotationGesture.ts | 10 +- .../gesture_component/tapGesture.ts | 10 +- .../render_component/if/id_if.ts | 5 +- .../lazyforeach/lazyforEachThreeParam.ts | 9 +- .../simple_component/button/button.ts | 3 +- .../animateTo/animateTo.ts | 2 +- .../render_decorator/@builder/@builder.ts | 191 ++++++++++++------ .../@builder/@builderDynamicUsage$$.ts | 32 +-- .../@builder/@builderTransFormFirst.ts | 4 +- .../@builder/@builderTransFormFourth.ts | 121 +++++++---- .../@builder/@builderTransFormSecond.ts | 4 +- .../@builder/@builderTransFormThird.ts | 4 +- .../@builder/@builderVisilibity$$.ts | 4 +- .../@builder/@builderWithForEach.ts | 8 +- .../@builder/handleCustomBuilder.ts | 78 ++++--- .../@builderParam/@builderParam.ts | 52 +++-- .../@builderParamQuestionMark.ts | 14 +- .../render_decorator/@recycle/recycle.ts | 34 +++- .../@recycle/recycle_gesture.ts | 10 +- 28 files changed, 486 insertions(+), 217 deletions(-) diff --git a/compiler/src/pre_define.ts b/compiler/src/pre_define.ts index 61498ec5a..1c95f6050 100644 --- a/compiler/src/pre_define.ts +++ b/compiler/src/pre_define.ts @@ -667,5 +667,41 @@ export const ATTRS_MAPPING = { }, "backgroundColor": { "backgroundColor": "backgroundColor" - } + }, + "margin": { + "left": "marginLeft", + "right": "marginRight", + "top": "marginTop", + "bottom": "marginBottom" + }, + "marginLeft": { + "marginLeft": "marginLeft" + }, + "marginRight": { + "marginRight": "marginRight" + }, + "marginTop": { + "marginTop": "marginTop" + }, + "marginBottom": { + "marginBottom": "marginBottom" + }, + "padding": { + "left": "paddingLeft", + "right": "paddingRight", + "top": "paddingTop", + "bottom": "paddingBottom" + }, + "paddingLeft": { + "paddingLeft": "paddingLeft" + }, + "paddingRight": { + "paddingRight": "paddingRight" + }, + "paddingTop": { + "paddingTop": "paddingTop" + }, + "paddingBottom": { + "paddingBottom": "paddingBottom" + }, }; diff --git a/compiler/src/process_component_build.ts b/compiler/src/process_component_build.ts index 97f00d1d9..29e7111a2 100644 --- a/compiler/src/process_component_build.ts +++ b/compiler/src/process_component_build.ts @@ -206,9 +206,13 @@ function attrExpHasProp(temp: ts.CallExpression, expName : string, propName : st attrArgs.push(...temp.arguments); return true; } - + if(temp.arguments.length) { - let arg = temp.arguments[0] as ts.ObjectLiteralExpression; + let arg = temp.arguments[0]; + if(!ts.isObjectLiteralExpression(arg)) { + attrArgs.push(arg); + return true; + } for(let prop of arg.properties as ts.NodeArray) { if (prop.name.getText() == propName) { attrArgs.push(prop.initializer); @@ -2201,10 +2205,14 @@ function isReuseArgument(argument : ts.Expression): boolean { mayChangedAnnotation.has(curPropMap.get(argument.name.getText()))) { return false; } - // $$this.value - if(ts.isIdentifier(argument.expression) && argument.expression.getText() == $$_THIS) { + // $$this.value $$.val + if(ts.isIdentifier(argument.expression) && [$$_THIS,$$].includes(argument.expression.getText()) ) { return false; } + // $$.val + if(ts.isIdentifier(argument.expression) && argument.expression.getText() == $$) { + return false; + } // this.a.c if(ts.isPropertyAccessExpression(argument.expression)) return isReuseArgument(argument.expression); @@ -2305,6 +2313,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: parseRecycleId(temp, temp.expression.name, isRecycleComponent, componentAttrInfo); if (isReuseMode() && HANDLE_COMPLEX_ATTRS.has(temp.expression.name.getText())) { collectComplextComponentAttr(temp, complexAttrMap, identifierNode, statements, immutableStatements, updateStatements); + lastStatement.kind = true; } else { addComponentAttr(temp, temp.expression.name, lastStatement, statements, identifierNode, log, isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, @@ -2319,6 +2328,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: parseRecycleId(temp, temp.expression.name, isRecycleComponent, componentAttrInfo); if (isReuseMode() && HANDLE_COMPLEX_ATTRS.has(temp.expression.getText())) { collectComplextComponentAttr(temp, complexAttrMap, identifierNode, statements, immutableStatements, updateStatements); + lastStatement.kind = true; } else { addComponentAttr(temp, temp.expression, lastStatement, statements, identifierNode, log, isStylesAttr, immutableStatements, updateStatements, newImmutableStatements, @@ -2331,7 +2341,7 @@ export function bindComponentAttr(node: ts.ExpressionStatement, identifierNode: temp = temp.expression; } } - + if (complexAttrMap.size) { for (let [ _ , statement] of complexAttrMap.entries()) { if (!statement) continue; diff --git a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts index a6f98f66c..4af2c44ab 100644 --- a/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts +++ b/compiler/test/utForPartialUpdate/import/import@CustomDialog.ts @@ -153,7 +153,7 @@ class CustomDialogUser extends ViewPU { Column.create(); if (isInitialRender) { Column.width('100%'); - Column.margin({ top: 5 }); + Column.marginTop(5); } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/import/import@Observed.ts b/compiler/test/utForPartialUpdate/import/import@Observed.ts index 4c8a850bf..e1fadb4ce 100644 --- a/compiler/test/utForPartialUpdate/import/import@Observed.ts +++ b/compiler/test/utForPartialUpdate/import/import@Observed.ts @@ -105,7 +105,7 @@ class ViewA extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); if (isInitialRender) { - Row.margin({ top: 10 }); + Row.marginTop(10); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -232,7 +232,7 @@ class ViewB extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('ViewB: reset array'); if (isInitialRender) { - Button.margin({ top: 10 }); + Button.marginTop(10); Button.onClick(() => { this.arrA = [new import_Observed_1.ClassB(0), new import_Observed_1.ClassB(0)]; }); @@ -242,7 +242,7 @@ class ViewB extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('ViewB: push'); if (isInitialRender) { - Button.margin({ top: 10 }); + Button.marginTop(10); Button.onClick(() => { this.arrA.push(new import_Observed_1.ClassB(0)); }); @@ -252,7 +252,7 @@ class ViewB extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel('ViewB: shift'); if (isInitialRender) { - Button.margin({ top: 10 }); + Button.marginTop(10); Button.onClick(() => { this.arrA.shift(); }); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts index bfee93bcc..41481290d 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck1.ts @@ -158,7 +158,8 @@ class TabsExample extends ViewPU { if (isInitialRender) { Text.fontSize(16); Text.lineHeight(22); - Text.margin({ top: 17, bottom: 7 }); + Text.marginBottom(7); + Text.marginTop(17); } }, Text); Text.pop(); @@ -192,7 +193,7 @@ class TabsExample extends ViewPU { }); Tabs.width(360); Tabs.height(296); - Tabs.margin({ top: 52 }); + Tabs.marginTop(52); Tabs.backgroundColor('#F1F3F5'); } }, Tabs); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts index 73e5a420e..bdf0673d4 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/$$_component/$$_componentCheck6.ts @@ -158,7 +158,8 @@ class TabsExample extends ViewPU { if (isInitialRender) { Text.fontSize(16); Text.lineHeight(22); - Text.margin({ top: 17, bottom: 7 }); + Text.marginBottom(7); + Text.marginTop(17); } }, Text); Text.pop(); @@ -192,7 +193,7 @@ class TabsExample extends ViewPU { }); Tabs.width(360); Tabs.height(296); - Tabs.margin({ top: 52 }); + Tabs.marginTop(52); Tabs.backgroundColor('#F1F3F5'); } }, Tabs); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts index b70f92d6f..ced2ffbe7 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/longPressGesture.ts @@ -90,9 +90,15 @@ class LongPressGestureExample extends ViewPU { if (isInitialRender) { Flex.height(200); Flex.width(300); - Flex.padding(60); + Flex.paddingBottom(60); + Flex.paddingTop(60); + Flex.paddingRight(60); + Flex.paddingLeft(60); Flex.borderWidth(1); - Flex.margin(30); + Flex.marginBottom(30); + Flex.marginTop(30); + Flex.marginRight(30); + Flex.marginLeft(30); } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts index 82aa69864..39798abbe 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/panGestrue.ts @@ -113,9 +113,15 @@ class PanGestureExample extends ViewPU { if (isInitialRender) { Flex.height(100); Flex.width(200); - Flex.padding(20); + Flex.paddingBottom(20); + Flex.paddingTop(20); + Flex.paddingRight(20); + Flex.paddingLeft(20); Flex.borderWidth(1); - Flex.margin(80); + Flex.marginBottom(80); + Flex.marginTop(80); + Flex.marginRight(80); + Flex.marginLeft(80); } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts index 56e795939..7b24b5c5c 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/pinchGesture.ts @@ -96,9 +96,15 @@ class PinchGestureExample extends ViewPU { if (isInitialRender) { Flex.height(100); Flex.width(200); - Flex.padding(20); + Flex.paddingBottom(20); + Flex.paddingTop(20); + Flex.paddingRight(20); + Flex.paddingLeft(20); Flex.borderWidth(1); - Flex.margin(80); + Flex.marginBottom(80); + Flex.marginTop(80); + Flex.marginRight(80); + Flex.marginLeft(80); } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts index 790ce93cd..193712e86 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/rotationGesture.ts @@ -96,9 +96,15 @@ class RotationGestureExample extends ViewPU { if (isInitialRender) { Flex.height(100); Flex.width(200); - Flex.padding(20); + Flex.paddingBottom(20); + Flex.paddingTop(20); + Flex.paddingRight(20); + Flex.paddingLeft(20); Flex.borderWidth(1); - Flex.margin(80); + Flex.marginBottom(80); + Flex.marginTop(80); + Flex.marginRight(80); + Flex.marginLeft(80); } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts index 5eb453b7d..48208f39f 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/gesture_component/tapGesture.ts @@ -83,9 +83,15 @@ class TapGestureExample extends ViewPU { if (isInitialRender) { Flex.height(200); Flex.width(300); - Flex.padding(60); + Flex.paddingBottom(60); + Flex.paddingTop(60); + Flex.paddingRight(60); + Flex.paddingLeft(60); Flex.borderWidth(1); - Flex.margin(30); + Flex.marginBottom(30); + Flex.marginTop(30); + Flex.marginRight(30); + Flex.marginLeft(30); } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts index 62bc9ad43..dc5581721 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/if/id_if.ts @@ -290,7 +290,8 @@ class MyComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); if (isInitialRender) { - Row.margin({ left: 10, right: 10 }); + Row.marginRight(10); + Row.marginLeft(10); Row.id('id11'); } }, Row); @@ -298,7 +299,7 @@ class MyComponent extends ViewPU { Text.create(); if (isInitialRender) { Text.fontSize(20); - Text.margin({ left: 10 }); + Text.marginLeft(10); } }, Text); Text.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts index b0df01602..940e8cbeb 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/render_component/lazyforeach/lazyforEachThreeParam.ts @@ -273,7 +273,8 @@ class lazyforEachThreeParam extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); if (isInitialRender) { - Row.margin({ left: 10, right: 10 }); + Row.marginRight(10); + Row.marginLeft(10); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -308,7 +309,8 @@ class lazyforEachThreeParam extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); if (isInitialRender) { - Row.margin({ left: 10, right: 10 }); + Row.marginRight(10); + Row.marginLeft(10); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { @@ -343,7 +345,8 @@ class lazyforEachThreeParam extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); if (isInitialRender) { - Row.margin({ left: 10, right: 10 }); + Row.marginRight(10); + Row.marginLeft(10); } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts index bb974f336..891978784 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/simple_component/button/button.ts @@ -92,7 +92,8 @@ class ButtonExample extends ViewPU { if (isInitialRender) { Text.fontSize(12); Text.fontColor(0xffffff); - Text.margin({ left: 5, right: 12 }); + Text.marginRight(12); + Text.marginLeft(5); } }, Text); Text.pop(); diff --git a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts index 534638898..0efcc1c36 100644 --- a/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts +++ b/compiler/test/utForPartialUpdate/inner_component_transform/transition_component/animateTo/animateTo.ts @@ -220,7 +220,7 @@ class TransitionExample extends ViewPU { if (isInitialRender) { Flex.height(400); Flex.width("100%"); - Flex.padding({ top: 100 }); + Flex.paddingTop(100); } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts index dd897f34f..fbe81c322 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builder.ts @@ -257,8 +257,10 @@ class MyComponent extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(label); - Text.width(80); - Text.bindMenu({ builder: this.textBuilder.bind(this) }); + if (isInitialRender) { + Text.width(80); + Text.bindMenu({ builder: this.textBuilder.bind(this) }); + } }, Text); Text.pop(); Column.pop(); @@ -266,20 +268,28 @@ class MyComponent extends ViewPU { MenuBuilder(parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { Flex.create({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }); - Flex.width(100); + if (isInitialRender) { + Flex.width(100); + } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Test menu item 1'); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Divider.create(); - Divider.height(10); + if (isInitialRender) { + Divider.height(10); + } }, Divider); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Test menu item 2'); - Text.fontSize(20); + if (isInitialRender) { + Text.fontSize(20); + } }, Text); Text.pop(); Flex.pop(); @@ -293,31 +303,43 @@ class MyComponent extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.padding(10); - Row.bindMenu({ builder: () => { - this.NavigationTitlePara.call(this, "111"); - } }); + if (isInitialRender) { + Row.paddingBottom(10); + Row.paddingTop(10); + Row.paddingRight(10); + Row.paddingLeft(10); + Row.bindMenu({ builder: () => { + this.NavigationTitlePara.call(this, "111"); + } }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("Drag Me"); - Text.onDragStart((event, extraParams) => { - console.log('Text onDragStarts, ' + extraParams); - }); + if (isInitialRender) { + Text.onDragStart((event, extraParams) => { + console.log('Text onDragStarts, ' + extraParams); + }); + } }, Text); Text.pop(); specificParam.bind(this)('test1', 'test2', this); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.padding(10); - Row.bindPopup(false, { - builder: { builder: this.MenuBuilder.bind(this) }, - onStateChange: (e) => { - if (!e.isVisible) { - console.warn(JSON.stringify(e.isVisible)); + if (isInitialRender) { + Row.paddingBottom(10); + Row.paddingTop(10); + Row.paddingRight(10); + Row.paddingLeft(10); + Row.bindPopup(false, { + builder: { builder: this.MenuBuilder.bind(this) }, + onStateChange: (e) => { + if (!e.isVisible) { + console.warn(JSON.stringify(e.isVisible)); + } } - } - }); + }); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Test Text'); @@ -326,8 +348,13 @@ class MyComponent extends ViewPU { Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.padding(10); - Row.bindContextMenu({ builder: this.MenuBuilder.bind(this) }, ResponseType.RightClick); + if (isInitialRender) { + Row.paddingBottom(10); + Row.paddingTop(10); + Row.paddingRight(10); + Row.paddingLeft(10); + Row.bindContextMenu({ builder: this.MenuBuilder.bind(this) }, ResponseType.RightClick); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('rightclick for menu'); @@ -336,31 +363,41 @@ class MyComponent extends ViewPU { Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.padding(10); + if (isInitialRender) { + Row.paddingBottom(10); + Row.paddingTop(10); + Row.paddingRight(10); + Row.paddingLeft(10); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Navigation.create(new NavPathStack(), { moduleName: "", pagePath: "@builder", isUserCreateStack: false }); - Navigation.title({ builder: noParam.bind(this) }); - Navigation.menus({ builder: this.textBuilder.bind(this) }); - Navigation.toolBar({ items: [ - { value: 'app', text: 'Grid', action: () => { - console.log("app"); - } }, - { value: 'add', text: 'Add', action: () => { - console.log("add"); - } }, - { value: 'collect', text: 'Collect', action: () => { - console.log("collect"); - } } - ] }); Navigation.hideToolBar(this.hideBar); + if (isInitialRender) { + Navigation.title({ builder: noParam.bind(this) }); + Navigation.menus({ builder: this.textBuilder.bind(this) }); + Navigation.toolBar({ items: [ + { value: 'app', text: 'Grid', action: () => { + console.log("app"); + } }, + { value: 'add', text: 'Add', action: () => { + console.log("add"); + } }, + { value: 'collect', text: 'Collect', action: () => { + console.log("collect"); + } } + ] }); + } }, Navigation); this.observeComponentCreation2((elmtId, isInitialRender) => { List.create({ space: 5, initialIndex: 0 }); - List.listDirection(Axis.Vertical); - List.height(300); - List.margin({ top: 10, left: 18 }); - List.width('100%'); + if (isInitialRender) { + List.listDirection(Axis.Vertical); + List.height(300); + List.marginTop(10); + List.marginLeft(18); + List.width('100%'); + } }, List); this.observeComponentCreation2((elmtId, isInitialRender) => { ForEach.create(); @@ -377,18 +414,22 @@ class MyComponent extends ViewPU { }; const itemCreation2 = (elmtId, isInitialRender) => { ListItem.create(deepRenderFunction, true); - ListItem.editable(true); + if (isInitialRender) { + ListItem.editable(true); + } }; const deepRenderFunction = (elmtId, isInitialRender) => { itemCreation(elmtId, isInitialRender); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('' + item); - Text.width('90%'); - Text.height(80); - Text.backgroundColor('#3366CC'); - Text.borderRadius(15); - Text.fontSize(16); - Text.textAlign(TextAlign.Center); + if (isInitialRender) { + Text.width('90%'); + Text.height(80); + Text.backgroundColor('#3366CC'); + Text.borderRadius(15); + Text.fontSize(16); + Text.textAlign(TextAlign.Center); + } }, Text); Text.pop(); ListItem.pop(); @@ -403,17 +444,25 @@ class MyComponent extends ViewPU { List.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithLabel(this.hideBar ? "tool bar" : "hide bar"); - Button.onClick(() => { - this.hideBar = !this.hideBar; - }); - Button.margin({ left: 135, top: 60 }); + if (isInitialRender) { + Button.onClick(() => { + this.hideBar = !this.hideBar; + }); + Button.marginTop(60); + Button.marginLeft(135); + } }, Button); Button.pop(); Navigation.pop(); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.padding(10); + if (isInitialRender) { + Row.paddingBottom(10); + Row.paddingTop(10); + Row.paddingRight(10); + Row.paddingLeft(10); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Tabs.create({ barPosition: BarPosition.Start, controller: this.controller }); @@ -422,39 +471,51 @@ class MyComponent extends ViewPU { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('111'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Pink); + if (isInitialRender) { + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Pink); + } }, Text); Text.pop(); }); - TabContent.tabBar('pink'); + if (isInitialRender) { + TabContent.tabBar('pink'); + } }, TabContent); TabContent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('222'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Yellow); + if (isInitialRender) { + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Yellow); + } }, Text); Text.pop(); }); - TabContent.tabBar('yellow'); + if (isInitialRender) { + TabContent.tabBar('yellow'); + } }, TabContent); TabContent.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TabContent.create(() => { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('333'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Blue); + if (isInitialRender) { + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Blue); + } }, Text); Text.pop(); }); - TabContent.tabBar('blue'); + if (isInitialRender) { + TabContent.tabBar('blue'); + } }, TabContent); TabContent.pop(); Tabs.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderDynamicUsage$$.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderDynamicUsage$$.ts index 25bb3a72e..87a1b4381 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderDynamicUsage$$.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderDynamicUsage$$.ts @@ -136,17 +136,22 @@ class VideoPlayer extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Hello' + $$.playedTimeNumber); - Text.fontSize(13); - Text.margin({ left: 4, bottom: 12 }); - Text.id("played_time"); + if (isInitialRender) { + Text.fontSize(13); + Text.marginBottom(12); + Text.marginLeft(4); + Text.id("played_time"); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { TextInput.create({ text: $$.totalTime, placeholder: 'builder test' }); - TextInput.placeholderColor(Color.Grey); - TextInput.placeholderFont({ size: 14, weight: 400 }); - TextInput.caretColor(Color.Blue); - TextInput.width(300); + if (isInitialRender) { + TextInput.placeholderColor(Color.Grey); + TextInput.placeholderFont({ size: 14, weight: 400 }); + TextInput.caretColor(Color.Blue); + TextInput.width(300); + } }, TextInput); this.observeComponentCreation2((elmtId, isInitialRender) => { Slider.create({ @@ -156,11 +161,14 @@ class VideoPlayer extends ViewPU { step: 1, style: SliderStyle.OutSet }); - Slider.width('100%'); - Slider.margin({ left: 8, right: 8 }); - Slider.trackColor(Color.Gray); - Slider.showSteps(true); - Slider.id("slider"); + if (isInitialRender) { + Slider.width('100%'); + Slider.marginRight(8); + Slider.marginLeft(8); + Slider.trackColor(Color.Gray); + Slider.showSteps(true); + Slider.id("slider"); + } }, Slider); Column.pop(); } diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFirst.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFirst.ts index f07c5e898..e8bbbd8f9 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFirst.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFirst.ts @@ -159,7 +159,9 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id14')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { __Common__.create(true); - __Common__.id('id14'); + if (isInitialRender) { + __Common__.id('id14'); + } }, __Common__); { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFourth.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFourth.ts index e92f1458a..404f9b1dd 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFourth.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormFourth.ts @@ -502,8 +502,10 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id1')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('count is negative'); - Text.fontSize(32); - Text.id('id1'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id1'); + } }, Text); Text.pop(); } @@ -514,14 +516,18 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id2')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Divider.create(); - Divider.id('id2'); + if (isInitialRender) { + Divider.id('id2'); + } }, Divider); } if (!If.canRetake('id3')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('even'); - Text.fontSize(32); - Text.id('id3'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id3'); + } }, Text); Text.pop(); } @@ -532,18 +538,24 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id4')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Divider.create(); - Divider.id('id4'); + if (isInitialRender) { + Divider.id('id4'); + } }, Divider); } if (!If.canRetake('id10')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Column.create(); - Column.id('id10'); + if (isInitialRender) { + Column.id('id10'); + } }, Column); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('odd'); - Text.fontSize(32); - Text.id('id5'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id5'); + } }, Text); Text.pop(); Column.pop(); @@ -559,8 +571,10 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id6')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('fail'); - Text.id('id6'); - Text.fontSize(32); + if (isInitialRender) { + Text.id('id6'); + Text.fontSize(32); + } }, Text); Text.pop(); } @@ -575,8 +589,10 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id7')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('odd2'); - Text.fontSize(32); - Text.id('id7'); + if (isInitialRender) { + Text.fontSize(32); + Text.id('id7'); + } }, Text); Text.pop(); } @@ -607,19 +623,26 @@ function testIfIdComponent(value, parent = null) { }; const itemCreation2 = (elmtId, isInitialRender, value = __value__) => { ListItem.create(deepRenderFunction, true); - ListItem.id('id8'); + if (isInitialRender) { + ListItem.id('id8'); + } }; const deepRenderFunction = (elmtId, isInitialRender, value = __value__) => { itemCreation(elmtId, isInitialRender, value); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Row.create(); - Row.margin({ left: 10, right: 10 }); - Row.id('id11'); + if (isInitialRender) { + Row.marginRight(10); + Row.marginLeft(10); + Row.id('id11'); + } }, Row); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create(); - Text.fontSize(20); - Text.margin({ left: 10 }); + if (isInitialRender) { + Text.fontSize(20); + Text.marginLeft(10); + } }, Text); Text.pop(); Row.pop(); @@ -650,14 +673,18 @@ function testIfIdComponent(value, parent = null) { TabContent.create(() => { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('111'); - Text.width('100%'); - Text.height('20'); - Text.backgroundColor(Color.Pink); + if (isInitialRender) { + Text.width('100%'); + Text.height('20'); + Text.backgroundColor(Color.Pink); + } }, Text); Text.pop(); }); - TabContent.tabBar('pink'); - TabContent.id('id9'); + if (isInitialRender) { + TabContent.tabBar('pink'); + TabContent.id('id9'); + } }, TabContent); TabContent.pop(); } @@ -689,13 +716,17 @@ function testIfIdComponent(value, parent = null) { if (!If.canRetake('id12')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { XComponent.create({ id: 'special', type: '' }); - XComponent.id('id12'); + if (isInitialRender) { + XComponent.id('id12'); + } }, XComponent); } if (!If.canRetake('id13')) { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Column.create(); - Column.id('id13'); + if (isInitialRender) { + Column.id('id13'); + } }, Column); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('11'); @@ -833,32 +864,42 @@ function testTabComponent(value, parent = null) { TabContent.create(() => { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Flex.create(); - Flex.height(100); - Flex.width(200); + if (isInitialRender) { + Flex.height(100); + Flex.width(200); + } }, Flex); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Column.create(); - Column.height(100); - Column.width(200); + if (isInitialRender) { + Column.height(100); + Column.width(200); + } }, Column); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create('text1'); - Text.height(100); - Text.width(200); + if (isInitialRender) { + Text.height(100); + Text.width(200); + } }, Text); Text.pop(); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { Text.create(value.toString()); - Text.height(100); - Text.width(200); + if (isInitialRender) { + Text.height(100); + Text.width(200); + } }, Text); Text.pop(); Column.pop(); Flex.pop(); }); - TabContent.tabBar("TabBar"); - TabContent.height(100); - TabContent.width(200); + if (isInitialRender) { + TabContent.tabBar("TabBar"); + TabContent.height(100); + TabContent.width(200); + } }, TabContent); TabContent.pop(); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { @@ -868,9 +909,11 @@ function testTabComponent(value, parent = null) { }, Text); Text.pop(); }); - TabContent.tabBar("TabBar 2"); - TabContent.height(100); - TabContent.width(200); + if (isInitialRender) { + TabContent.tabBar("TabBar 2"); + TabContent.height(100); + TabContent.width(200); + } }, TabContent); TabContent.pop(); Tabs.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormSecond.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormSecond.ts index b4f49b3c0..e184df057 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormSecond.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormSecond.ts @@ -174,7 +174,9 @@ function testInnerComponent(value, parent = null) { } (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { __Common__.create(); - __Common__.width(value); + if (isInitialRender) { + __Common__.width(value); + } }, __Common__); { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, value = __value__) => { diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormThird.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormThird.ts index f4d6f5e66..ad1baa19a 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormThird.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderTransFormThird.ts @@ -186,7 +186,9 @@ function testInnerComponent(value, parent = null) { __Recycle__.pop(); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.height(value); + if (isInitialRender) { + __Common__.height(value); + } }, __Common__); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderVisilibity$$.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderVisilibity$$.ts index 204a378dd..d6cfd825d 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderVisilibity$$.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderVisilibity$$.ts @@ -180,7 +180,9 @@ class visibility$$Demo extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.height('100%'); + if (isInitialRender) { + Column.height('100%'); + } }, Column); comp.bind(this)(makeBuilderParameterProxy("comp", { vis: () => (this["__vis"] ? this["__vis"] : this["vis"]), data: () => (this["__data"] ? this["__data"] : this["data"]), width: () => (this["__w"] ? this["__w"] : this["w"]) }), this); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderWithForEach.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderWithForEach.ts index e3f8dce66..476f41124 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderWithForEach.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/@builderWithForEach.ts @@ -56,7 +56,9 @@ function ComB(param, parent = null) { const item = _item; (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, param = __param__) => { __Common__.create(); - __Common__.backgroundColor('red'); + if (isInitialRender) { + __Common__.backgroundColor('red'); + } }, __Common__); { (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender, param = __param__) => { @@ -146,7 +148,9 @@ class ComA extends ViewPU { }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('自定义组件'); - Text.fontSize(30); + if (isInitialRender) { + Text.fontSize(30); + } }, Text); Text.pop(); Row.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builder/handleCustomBuilder.ts b/compiler/test/utForPartialUpdate/render_decorator/@builder/handleCustomBuilder.ts index aed6b8850..ebd026cc2 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builder/handleCustomBuilder.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builder/handleCustomBuilder.ts @@ -101,20 +101,24 @@ class Index extends ViewPU { inner(param, parent = null) { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Inner Builder Text'); - Text.bindPopup(false, { - onStateChange: (e) => { }, - builder: { builder: () => { - global.call(this); - } } - }); + if (isInitialRender) { + Text.bindPopup(false, { + onStateChange: (e) => { }, + builder: { builder: () => { + global.call(this); + } } + }); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Inner Builder Text2'); - Text.bindPopup(false, { - onStateChange: (e) => { }, - builder: this.judge ? { builder: global.bind(this) } : undefined - }); + if (isInitialRender) { + Text.bindPopup(false, { + onStateChange: (e) => { }, + builder: this.judge ? { builder: global.bind(this) } : undefined + }); + } }, Text); Text.pop(); } @@ -124,44 +128,54 @@ class Index extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.bindMenu({ builder: () => { - this.inner.call(this, "111"); - } }); + if (isInitialRender) { + Row.bindMenu({ builder: () => { + this.inner.call(this, "111"); + } }); + } }, Row); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.bindMenu(this.judge ? { builder: () => { - this.inner.call(this, "111"); - } } : { builder: global.bind(this) }); + if (isInitialRender) { + Row.bindMenu(this.judge ? { builder: () => { + this.inner.call(this, "111"); + } } : { builder: global.bind(this) }); + } }, Row); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.onDragStart((event, extraParams) => { - console.log('Text onDragStarts, ' + extraParams); - return this.judge ? { builder: this.inner.bind(this) } : { builder: () => { - global.call(this); - } }; - }); + if (isInitialRender) { + Row.onDragStart((event, extraParams) => { + console.log('Text onDragStarts, ' + extraParams); + return this.judge ? { builder: this.inner.bind(this) } : { builder: () => { + global.call(this); + } }; + }); + } }, Row); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.onDragStart((event, extraParams) => { - console.log('Text onDragStarts, ' + extraParams); - return { builder: this.judge ? { builder: () => { - this.inner.call(this); - } } : undefined }; - }); + if (isInitialRender) { + Row.onDragStart((event, extraParams) => { + console.log('Text onDragStarts, ' + extraParams); + return { builder: this.judge ? { builder: () => { + this.inner.call(this); + } } : undefined }; + }); + } }, Row); Row.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create('Text'); - Text.bindPopup(false, { - onStateChange: (e) => { }, - builder: undefined - }); + if (isInitialRender) { + Text.bindPopup(false, { + onStateChange: (e) => { }, + builder: undefined + }); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParam.ts b/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParam.ts index d95fd5404..ac8c7620e 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParam.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParam.ts @@ -210,12 +210,16 @@ function specificWithParam(label1, label2, parent = null) { }, Column); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { Text.create(label1); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); (parent ? parent : this).observeComponentCreation2((elmtId, isInitialRender) => { Text.create(label2); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); Column.pop(); @@ -257,7 +261,9 @@ class CustomContainerUser extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("content"); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); Column.pop(); @@ -268,12 +274,16 @@ class CustomContainerUser extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(label1); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(label2); - Text.fontSize(50); + if (isInitialRender) { + Text.fontSize(50); + } }, Text); Text.pop(); Column.pop(); @@ -290,9 +300,11 @@ class CustomContainerUser extends ViewPU { closer: () => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.onClick(() => { - this.text = "changeHeader"; - }); + if (isInitialRender) { + Column.onClick(() => { + this.text = "changeHeader"; + }); + } }, Column); specificWithParam.bind(this)("111", "22", this); Column.pop(); @@ -305,9 +317,11 @@ class CustomContainerUser extends ViewPU { closer: () => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.onClick(() => { - this.text = "changeHeader"; - }); + if (isInitialRender) { + Column.onClick(() => { + this.text = "changeHeader"; + }); + } }, Column); specificWithParam.bind(this)("111", "22", this); Column.pop(); @@ -361,9 +375,11 @@ class CustomContainerUser extends ViewPU { content: () => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.onClick(() => { - this.text = "changeHeader"; - }); + if (isInitialRender) { + Column.onClick(() => { + this.text = "changeHeader"; + }); + } }, Column); this.callSpecificParam.bind(this)("111", '222', this); Column.pop(); @@ -376,9 +392,11 @@ class CustomContainerUser extends ViewPU { content: () => { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.onClick(() => { - this.text = "changeHeader"; - }); + if (isInitialRender) { + Column.onClick(() => { + this.text = "changeHeader"; + }); + } }, Column); this.callSpecificParam.bind(this)("111", '222', this); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParamQuestionMark.ts b/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParamQuestionMark.ts index 070f76205..4533e99f7 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParamQuestionMark.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@builderParam/@builderParamQuestionMark.ts @@ -118,16 +118,22 @@ class Index extends ViewPU { initialRender() { this.observeComponentCreation2((elmtId, isInitialRender) => { Row.create(); - Row.height('100%'); + if (isInitialRender) { + Row.height('100%'); + } }, Row); this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); - Column.width('100%'); + if (isInitialRender) { + Column.width('100%'); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create(this.message); - Text.fontSize(50); - Text.fontWeight(FontWeight.Bold); + if (isInitialRender) { + Text.fontSize(50); + Text.fontWeight(FontWeight.Bold); + } }, Text); Text.pop(); { diff --git a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle.ts b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle.ts index fe159caa1..30f0bfd92 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle.ts @@ -187,12 +187,17 @@ class HomeComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Column.create(); Column.width(this.state_value); - Column.height(100); + if (isInitialRender) { + Column.height(100); + } }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.border({ width: 3, color: Color.Red }); __Common__.width(this.state_value); + if (isInitialRender) { + __Common__.borderColor(Color.Red); + __Common__.borderWidth(3); + } }, __Common__); this.observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); @@ -234,7 +239,9 @@ class HomeComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("aa"); Text.width(this.state_value); - Text.height(100); + if (isInitialRender) { + Text.height(100); + } }, Text); Text.pop(); Column.pop(); @@ -338,8 +345,11 @@ class child extends ViewPU { }, Column); this.observeComponentCreation2((elmtId, isInitialRender) => { __Common__.create(); - __Common__.border({ width: 3, color: Color.Red }); __Common__.height(this.heightValue); + if (isInitialRender) { + __Common__.borderColor(Color.Red); + __Common__.borderWidth(3); + } }, __Common__); this.observeComponentCreation2((elmtId, isInitialRender) => { __Recycle__.create(); @@ -376,17 +386,23 @@ class child extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hello"); Text.width(this.propvalue); - Text.fontColor(Color.Red); - Text.border({ width: this.propvalue, color: Color.Red, radius: 100 }); + Text.borderWidth(this.propvalue); if (isInitialRender) { Text.fontSize(this.reguar_value); Text.height(100); + Text.fontColor(Color.Red); + Text.borderRadius(100); + Text.borderColor(Color.Red); } }, Text); Text.pop(); this.observeComponentCreation2((elmtId, isInitialRender) => { Button.createWithChild(); - Button.border({ width: this.reguar_value, color: Color.Red, radius: 100 }); + if (isInitialRender) { + Button.borderRadius(100); + Button.borderColor(Color.Red); + Button.borderWidth(this.reguar_value); + } }, Button); this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hhhhhhhhhhhhh"); @@ -563,7 +579,9 @@ class NormalComponent extends ViewPU { this.observeComponentCreation2((elmtId, isInitialRender) => { Text.create("hello"); Text.width(this.width_value); - Text.height(100); + if (isInitialRender) { + Text.height(100); + } }, Text); Text.pop(); Column.pop(); diff --git a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts index 8755430ee..92c8d8621 100644 --- a/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts +++ b/compiler/test/utForPartialUpdate/render_decorator/@recycle/recycle_gesture.ts @@ -109,9 +109,15 @@ class GestureTest extends ViewPU { Gesture.pop(); if (isInitialRender) { Flex.height(100); - Flex.padding(60); + Flex.paddingBottom(60); + Flex.paddingTop(60); + Flex.paddingRight(60); + Flex.paddingLeft(60); Flex.borderWidth(1); - Flex.margin(30); + Flex.marginBottom(30); + Flex.marginTop(30); + Flex.marginRight(30); + Flex.marginLeft(30); } }, Flex); this.observeComponentCreation2((elmtId, isInitialRender) => { -- Gitee