107ac75b1Sopenharmony_ci/* 207ac75b1Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 307ac75b1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 407ac75b1Sopenharmony_ci * you may not use this file except in compliance with the License. 507ac75b1Sopenharmony_ci * You may obtain a copy of the License at 607ac75b1Sopenharmony_ci * 707ac75b1Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 807ac75b1Sopenharmony_ci * 907ac75b1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1007ac75b1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1107ac75b1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1207ac75b1Sopenharmony_ci * See the License for the specific language governing permissions and 1307ac75b1Sopenharmony_ci * limitations under the License. 1407ac75b1Sopenharmony_ci */ 1507ac75b1Sopenharmony_ci 1607ac75b1Sopenharmony_ciexports.source = ` 1707ac75b1Sopenharmony_ciimport 1807ac75b1Sopenharmony_ciLinkComponentDefault, { 1907ac75b1Sopenharmony_ci LinkComponent as LinkComponent1Ref, 2007ac75b1Sopenharmony_ci LinkComponent2 as LinkComponent2Ref, 2107ac75b1Sopenharmony_ci LinkComponent3 2207ac75b1Sopenharmony_ci} from './test/pages/LinkComponent' 2307ac75b1Sopenharmony_ciimport DefaultComponent from "./test/pages/DefaultComponent" 2407ac75b1Sopenharmony_ciimport AMDComponentDefault = require('./test/pages/AMDComponent') 2507ac75b1Sopenharmony_ciimport TsModule from './test/pages/TsModule' 2607ac75b1Sopenharmony_ci 2707ac75b1Sopenharmony_ci@Entry 2807ac75b1Sopenharmony_ci@Component 2907ac75b1Sopenharmony_cistruct ImportTest { 3007ac75b1Sopenharmony_ci @State myState1: any = new TsModule(1).method() 3107ac75b1Sopenharmony_ci @State myState2: number = 0 3207ac75b1Sopenharmony_ci @State myState3: boolean = false 3307ac75b1Sopenharmony_ci @State myState4: string = 'ImportTest' 3407ac75b1Sopenharmony_ci 3507ac75b1Sopenharmony_ci build() { 3607ac75b1Sopenharmony_ci Column() { 3707ac75b1Sopenharmony_ci LinkComponent2Ref({ 3807ac75b1Sopenharmony_ci LinkComponent2Link1: $myState1, 3907ac75b1Sopenharmony_ci LinkComponent2Link2: $myState2, 4007ac75b1Sopenharmony_ci LinkComponent2Link3: $myState3, 4107ac75b1Sopenharmony_ci LinkComponent2Link4: $myState4, 4207ac75b1Sopenharmony_ci indexState1: { count: 1 }, 4307ac75b1Sopenharmony_ci indexState2: 1, 4407ac75b1Sopenharmony_ci indexState3: true, 4507ac75b1Sopenharmony_ci indexState4: 'LinkComponent2' 4607ac75b1Sopenharmony_ci }) 4707ac75b1Sopenharmony_ci Text('space') 4807ac75b1Sopenharmony_ci .fontSize(20) 4907ac75b1Sopenharmony_ci .fontColor(Color.Red) 5007ac75b1Sopenharmony_ci LinkComponent1Ref({ 5107ac75b1Sopenharmony_ci LinkComponent1Link1: $myState1, 5207ac75b1Sopenharmony_ci LinkComponent1Link2: $myState2, 5307ac75b1Sopenharmony_ci LinkComponent1Link3: $myState3, 5407ac75b1Sopenharmony_ci LinkComponent1Link4: $myState4, 5507ac75b1Sopenharmony_ci indexState1: { count: 1 }, 5607ac75b1Sopenharmony_ci indexState2: 1, 5707ac75b1Sopenharmony_ci indexState3: true, 5807ac75b1Sopenharmony_ci indexState4: 'LinkComponent1' 5907ac75b1Sopenharmony_ci }) 6007ac75b1Sopenharmony_ci DefaultComponent({ 6107ac75b1Sopenharmony_ci DefaultComponentLink1: $myState1, 6207ac75b1Sopenharmony_ci DefaultComponentLink2: $myState2, 6307ac75b1Sopenharmony_ci DefaultComponentLink3: $myState3, 6407ac75b1Sopenharmony_ci DefaultComponentLink4: $myState4, 6507ac75b1Sopenharmony_ci myVar: 100, 6607ac75b1Sopenharmony_ci myVar2: 100 6707ac75b1Sopenharmony_ci }) 6807ac75b1Sopenharmony_ci LinkComponentDefault({ 6907ac75b1Sopenharmony_ci LinkComponent3Link1: $myState1, 7007ac75b1Sopenharmony_ci LinkComponent3Link2: $myState2, 7107ac75b1Sopenharmony_ci LinkComponent3Link3: $myState3, 7207ac75b1Sopenharmony_ci LinkComponent3Link4: $myState4, 7307ac75b1Sopenharmony_ci indexState1: { count: 1 }, 7407ac75b1Sopenharmony_ci indexState2: 1, 7507ac75b1Sopenharmony_ci indexState3: true, 7607ac75b1Sopenharmony_ci indexState4: 'LinkComponent3' 7707ac75b1Sopenharmony_ci }) 7807ac75b1Sopenharmony_ci AMDComponentDefault({ 7907ac75b1Sopenharmony_ci AMDComponentLink1: $myState1, 8007ac75b1Sopenharmony_ci AMDComponentLink2: $myState2, 8107ac75b1Sopenharmony_ci AMDComponentLink3: $myState3, 8207ac75b1Sopenharmony_ci AMDComponentLink4: $myState4, 8307ac75b1Sopenharmony_ci myVar: 100, 8407ac75b1Sopenharmony_ci myVar2: 100 8507ac75b1Sopenharmony_ci }) 8607ac75b1Sopenharmony_ci LinkComponent3({ 8707ac75b1Sopenharmony_ci LinkComponent3Link1: $myState1, 8807ac75b1Sopenharmony_ci LinkComponent3Link2: $myState2, 8907ac75b1Sopenharmony_ci LinkComponent3Link3: $myState3, 9007ac75b1Sopenharmony_ci LinkComponent3Link4: $myState4, 9107ac75b1Sopenharmony_ci indexState1: { count: 1 }, 9207ac75b1Sopenharmony_ci indexState2: 1, 9307ac75b1Sopenharmony_ci indexState3: true, 9407ac75b1Sopenharmony_ci indexState4: 'LinkComponent1' 9507ac75b1Sopenharmony_ci }) 9607ac75b1Sopenharmony_ci } 9707ac75b1Sopenharmony_ci } 9807ac75b1Sopenharmony_ci} 9907ac75b1Sopenharmony_ci` 10007ac75b1Sopenharmony_ci 10107ac75b1Sopenharmony_ciexports.expectResult = 10207ac75b1Sopenharmony_ci`"use strict"; 10307ac75b1Sopenharmony_civar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 10407ac75b1Sopenharmony_ci if (k2 === undefined) k2 = k; 10507ac75b1Sopenharmony_ci var desc = Object.getOwnPropertyDescriptor(m, k); 10607ac75b1Sopenharmony_ci if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { 10707ac75b1Sopenharmony_ci desc = { enumerable: true, get: function() { return m[k]; } }; 10807ac75b1Sopenharmony_ci } 10907ac75b1Sopenharmony_ci Object.defineProperty(o, k2, desc); 11007ac75b1Sopenharmony_ci}) : (function(o, m, k, k2) { 11107ac75b1Sopenharmony_ci if (k2 === undefined) k2 = k; 11207ac75b1Sopenharmony_ci o[k2] = m[k]; 11307ac75b1Sopenharmony_ci})); 11407ac75b1Sopenharmony_civar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 11507ac75b1Sopenharmony_ci Object.defineProperty(o, "default", { enumerable: true, value: v }); 11607ac75b1Sopenharmony_ci}) : function(o, v) { 11707ac75b1Sopenharmony_ci o["default"] = v; 11807ac75b1Sopenharmony_ci}); 11907ac75b1Sopenharmony_civar __importStar = (this && this.__importStar) || function (mod) { 12007ac75b1Sopenharmony_ci if (mod && mod.__esModule) return mod; 12107ac75b1Sopenharmony_ci var result = {}; 12207ac75b1Sopenharmony_ci if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 12307ac75b1Sopenharmony_ci __setModuleDefault(result, mod); 12407ac75b1Sopenharmony_ci return result; 12507ac75b1Sopenharmony_ci}; 12607ac75b1Sopenharmony_civar __importDefault = (this && this.__importDefault) || function (mod) { 12707ac75b1Sopenharmony_ci return (mod && mod.__esModule) ? mod : { "default": mod }; 12807ac75b1Sopenharmony_ci}; 12907ac75b1Sopenharmony_ciObject.defineProperty(exports, "__esModule", { value: true }); 13007ac75b1Sopenharmony_cilet __generate__Id = 0; 13107ac75b1Sopenharmony_cifunction generateId() { 13207ac75b1Sopenharmony_ci return "importEts_" + ++__generate__Id; 13307ac75b1Sopenharmony_ci} 13407ac75b1Sopenharmony_ciconst LinkComponent_1 = __importStar(require("./test/pages/LinkComponent")); 13507ac75b1Sopenharmony_ciconst DefaultComponent_1 = __importDefault(require("./test/pages/DefaultComponent")); 13607ac75b1Sopenharmony_ciconst AMDComponentDefault = require("./test/pages/AMDComponent"); 13707ac75b1Sopenharmony_ciconst TsModule_1 = __importDefault(require("./test/pages/TsModule")); 13807ac75b1Sopenharmony_ciclass ImportTest extends View { 13907ac75b1Sopenharmony_ci constructor(compilerAssignedUniqueChildId, parent, params, localStorage) { 14007ac75b1Sopenharmony_ci super(compilerAssignedUniqueChildId, parent, localStorage); 14107ac75b1Sopenharmony_ci this.__myState1 = new ObservedPropertyObject(new TsModule_1.default(1).method(), this, "myState1"); 14207ac75b1Sopenharmony_ci this.__myState2 = new ObservedPropertySimple(0, this, "myState2"); 14307ac75b1Sopenharmony_ci this.__myState3 = new ObservedPropertySimple(false, this, "myState3"); 14407ac75b1Sopenharmony_ci this.__myState4 = new ObservedPropertySimple('ImportTest', this, "myState4"); 14507ac75b1Sopenharmony_ci this.updateWithValueParams(params); 14607ac75b1Sopenharmony_ci } 14707ac75b1Sopenharmony_ci updateWithValueParams(params) { 14807ac75b1Sopenharmony_ci if (params.myState1 !== undefined) { 14907ac75b1Sopenharmony_ci this.myState1 = params.myState1; 15007ac75b1Sopenharmony_ci } 15107ac75b1Sopenharmony_ci if (params.myState2 !== undefined) { 15207ac75b1Sopenharmony_ci this.myState2 = params.myState2; 15307ac75b1Sopenharmony_ci } 15407ac75b1Sopenharmony_ci if (params.myState3 !== undefined) { 15507ac75b1Sopenharmony_ci this.myState3 = params.myState3; 15607ac75b1Sopenharmony_ci } 15707ac75b1Sopenharmony_ci if (params.myState4 !== undefined) { 15807ac75b1Sopenharmony_ci this.myState4 = params.myState4; 15907ac75b1Sopenharmony_ci } 16007ac75b1Sopenharmony_ci } 16107ac75b1Sopenharmony_ci aboutToBeDeleted() { 16207ac75b1Sopenharmony_ci this.__myState1.aboutToBeDeleted(); 16307ac75b1Sopenharmony_ci this.__myState2.aboutToBeDeleted(); 16407ac75b1Sopenharmony_ci this.__myState3.aboutToBeDeleted(); 16507ac75b1Sopenharmony_ci this.__myState4.aboutToBeDeleted(); 16607ac75b1Sopenharmony_ci SubscriberManager.Get().delete(this.id()); 16707ac75b1Sopenharmony_ci } 16807ac75b1Sopenharmony_ci get myState1() { 16907ac75b1Sopenharmony_ci return this.__myState1.get(); 17007ac75b1Sopenharmony_ci } 17107ac75b1Sopenharmony_ci set myState1(newValue) { 17207ac75b1Sopenharmony_ci this.__myState1.set(newValue); 17307ac75b1Sopenharmony_ci } 17407ac75b1Sopenharmony_ci get myState2() { 17507ac75b1Sopenharmony_ci return this.__myState2.get(); 17607ac75b1Sopenharmony_ci } 17707ac75b1Sopenharmony_ci set myState2(newValue) { 17807ac75b1Sopenharmony_ci this.__myState2.set(newValue); 17907ac75b1Sopenharmony_ci } 18007ac75b1Sopenharmony_ci get myState3() { 18107ac75b1Sopenharmony_ci return this.__myState3.get(); 18207ac75b1Sopenharmony_ci } 18307ac75b1Sopenharmony_ci set myState3(newValue) { 18407ac75b1Sopenharmony_ci this.__myState3.set(newValue); 18507ac75b1Sopenharmony_ci } 18607ac75b1Sopenharmony_ci get myState4() { 18707ac75b1Sopenharmony_ci return this.__myState4.get(); 18807ac75b1Sopenharmony_ci } 18907ac75b1Sopenharmony_ci set myState4(newValue) { 19007ac75b1Sopenharmony_ci this.__myState4.set(newValue); 19107ac75b1Sopenharmony_ci } 19207ac75b1Sopenharmony_ci render() { 19307ac75b1Sopenharmony_ci Column.create(); 19407ac75b1Sopenharmony_ci let earlierCreatedChild_2 = (this && this.findChildById) ? this.findChildById("2") : undefined; 19507ac75b1Sopenharmony_ci if (earlierCreatedChild_2 == undefined) { 19607ac75b1Sopenharmony_ci View.create(new LinkComponent_1.LinkComponent2("2", this, { 19707ac75b1Sopenharmony_ci LinkComponent2Link1: this.__myState1, 19807ac75b1Sopenharmony_ci LinkComponent2Link2: this.__myState2, 19907ac75b1Sopenharmony_ci LinkComponent2Link3: this.__myState3, 20007ac75b1Sopenharmony_ci LinkComponent2Link4: this.__myState4, 20107ac75b1Sopenharmony_ci indexState1: { count: 1 }, 20207ac75b1Sopenharmony_ci indexState2: 1, 20307ac75b1Sopenharmony_ci indexState3: true, 20407ac75b1Sopenharmony_ci indexState4: 'LinkComponent2' 20507ac75b1Sopenharmony_ci })); 20607ac75b1Sopenharmony_ci } 20707ac75b1Sopenharmony_ci else { 20807ac75b1Sopenharmony_ci earlierCreatedChild_2.updateWithValueParams({ 20907ac75b1Sopenharmony_ci indexState1: { count: 1 }, 21007ac75b1Sopenharmony_ci indexState2: 1, 21107ac75b1Sopenharmony_ci indexState3: true, 21207ac75b1Sopenharmony_ci indexState4: 'LinkComponent2' 21307ac75b1Sopenharmony_ci }); 21407ac75b1Sopenharmony_ci View.create(earlierCreatedChild_2); 21507ac75b1Sopenharmony_ci } 21607ac75b1Sopenharmony_ci Text.create('space'); 21707ac75b1Sopenharmony_ci Text.fontSize(20); 21807ac75b1Sopenharmony_ci Text.fontColor(Color.Red); 21907ac75b1Sopenharmony_ci Text.pop(); 22007ac75b1Sopenharmony_ci let earlierCreatedChild_3 = (this && this.findChildById) ? this.findChildById("3") : undefined; 22107ac75b1Sopenharmony_ci if (earlierCreatedChild_3 == undefined) { 22207ac75b1Sopenharmony_ci View.create(new LinkComponent_1.LinkComponent("3", this, { 22307ac75b1Sopenharmony_ci LinkComponent1Link1: this.__myState1, 22407ac75b1Sopenharmony_ci LinkComponent1Link2: this.__myState2, 22507ac75b1Sopenharmony_ci LinkComponent1Link3: this.__myState3, 22607ac75b1Sopenharmony_ci LinkComponent1Link4: this.__myState4, 22707ac75b1Sopenharmony_ci indexState1: { count: 1 }, 22807ac75b1Sopenharmony_ci indexState2: 1, 22907ac75b1Sopenharmony_ci indexState3: true, 23007ac75b1Sopenharmony_ci indexState4: 'LinkComponent1' 23107ac75b1Sopenharmony_ci })); 23207ac75b1Sopenharmony_ci } 23307ac75b1Sopenharmony_ci else { 23407ac75b1Sopenharmony_ci earlierCreatedChild_3.updateWithValueParams({ 23507ac75b1Sopenharmony_ci indexState1: { count: 1 }, 23607ac75b1Sopenharmony_ci indexState2: 1, 23707ac75b1Sopenharmony_ci indexState3: true, 23807ac75b1Sopenharmony_ci indexState4: 'LinkComponent1' 23907ac75b1Sopenharmony_ci }); 24007ac75b1Sopenharmony_ci View.create(earlierCreatedChild_3); 24107ac75b1Sopenharmony_ci } 24207ac75b1Sopenharmony_ci let earlierCreatedChild_4 = (this && this.findChildById) ? this.findChildById("4") : undefined; 24307ac75b1Sopenharmony_ci if (earlierCreatedChild_4 == undefined) { 24407ac75b1Sopenharmony_ci View.create(new DefaultComponent_1.default("4", this, { 24507ac75b1Sopenharmony_ci DefaultComponentLink1: this.__myState1, 24607ac75b1Sopenharmony_ci DefaultComponentLink2: this.__myState2, 24707ac75b1Sopenharmony_ci DefaultComponentLink3: this.__myState3, 24807ac75b1Sopenharmony_ci DefaultComponentLink4: this.__myState4, 24907ac75b1Sopenharmony_ci myVar: 100, 25007ac75b1Sopenharmony_ci myVar2: 100 25107ac75b1Sopenharmony_ci })); 25207ac75b1Sopenharmony_ci } 25307ac75b1Sopenharmony_ci else { 25407ac75b1Sopenharmony_ci earlierCreatedChild_4.updateWithValueParams({ 25507ac75b1Sopenharmony_ci myVar: 100, 25607ac75b1Sopenharmony_ci myVar2: 100 25707ac75b1Sopenharmony_ci }); 25807ac75b1Sopenharmony_ci View.create(earlierCreatedChild_4); 25907ac75b1Sopenharmony_ci } 26007ac75b1Sopenharmony_ci let earlierCreatedChild_5 = (this && this.findChildById) ? this.findChildById("5") : undefined; 26107ac75b1Sopenharmony_ci if (earlierCreatedChild_5 == undefined) { 26207ac75b1Sopenharmony_ci View.create(new LinkComponent_1.default("5", this, { 26307ac75b1Sopenharmony_ci LinkComponent3Link1: this.__myState1, 26407ac75b1Sopenharmony_ci LinkComponent3Link2: this.__myState2, 26507ac75b1Sopenharmony_ci LinkComponent3Link3: this.__myState3, 26607ac75b1Sopenharmony_ci LinkComponent3Link4: this.__myState4, 26707ac75b1Sopenharmony_ci indexState1: { count: 1 }, 26807ac75b1Sopenharmony_ci indexState2: 1, 26907ac75b1Sopenharmony_ci indexState3: true, 27007ac75b1Sopenharmony_ci indexState4: 'LinkComponent3' 27107ac75b1Sopenharmony_ci })); 27207ac75b1Sopenharmony_ci } 27307ac75b1Sopenharmony_ci else { 27407ac75b1Sopenharmony_ci earlierCreatedChild_5.updateWithValueParams({ 27507ac75b1Sopenharmony_ci indexState1: { count: 1 }, 27607ac75b1Sopenharmony_ci indexState2: 1, 27707ac75b1Sopenharmony_ci indexState3: true, 27807ac75b1Sopenharmony_ci indexState4: 'LinkComponent3' 27907ac75b1Sopenharmony_ci }); 28007ac75b1Sopenharmony_ci View.create(earlierCreatedChild_5); 28107ac75b1Sopenharmony_ci } 28207ac75b1Sopenharmony_ci let earlierCreatedChild_6 = (this && this.findChildById) ? this.findChildById("6") : undefined; 28307ac75b1Sopenharmony_ci if (earlierCreatedChild_6 == undefined) { 28407ac75b1Sopenharmony_ci View.create(new AMDComponentDefault("6", this, { 28507ac75b1Sopenharmony_ci AMDComponentLink1: this.__myState1, 28607ac75b1Sopenharmony_ci AMDComponentLink2: this.__myState2, 28707ac75b1Sopenharmony_ci AMDComponentLink3: this.__myState3, 28807ac75b1Sopenharmony_ci AMDComponentLink4: this.__myState4, 28907ac75b1Sopenharmony_ci myVar: 100, 29007ac75b1Sopenharmony_ci myVar2: 100 29107ac75b1Sopenharmony_ci })); 29207ac75b1Sopenharmony_ci } 29307ac75b1Sopenharmony_ci else { 29407ac75b1Sopenharmony_ci earlierCreatedChild_6.updateWithValueParams({ 29507ac75b1Sopenharmony_ci myVar: 100, 29607ac75b1Sopenharmony_ci myVar2: 100 29707ac75b1Sopenharmony_ci }); 29807ac75b1Sopenharmony_ci View.create(earlierCreatedChild_6); 29907ac75b1Sopenharmony_ci } 30007ac75b1Sopenharmony_ci let earlierCreatedChild_7 = (this && this.findChildById) ? this.findChildById("7") : undefined; 30107ac75b1Sopenharmony_ci if (earlierCreatedChild_7 == undefined) { 30207ac75b1Sopenharmony_ci View.create(new LinkComponent_1.LinkComponent3("7", this, { 30307ac75b1Sopenharmony_ci LinkComponent3Link1: this.__myState1, 30407ac75b1Sopenharmony_ci LinkComponent3Link2: this.__myState2, 30507ac75b1Sopenharmony_ci LinkComponent3Link3: this.__myState3, 30607ac75b1Sopenharmony_ci LinkComponent3Link4: this.__myState4, 30707ac75b1Sopenharmony_ci indexState1: { count: 1 }, 30807ac75b1Sopenharmony_ci indexState2: 1, 30907ac75b1Sopenharmony_ci indexState3: true, 31007ac75b1Sopenharmony_ci indexState4: 'LinkComponent1' 31107ac75b1Sopenharmony_ci })); 31207ac75b1Sopenharmony_ci } 31307ac75b1Sopenharmony_ci else { 31407ac75b1Sopenharmony_ci earlierCreatedChild_7.updateWithValueParams({ 31507ac75b1Sopenharmony_ci indexState1: { count: 1 }, 31607ac75b1Sopenharmony_ci indexState2: 1, 31707ac75b1Sopenharmony_ci indexState3: true, 31807ac75b1Sopenharmony_ci indexState4: 'LinkComponent1' 31907ac75b1Sopenharmony_ci }); 32007ac75b1Sopenharmony_ci View.create(earlierCreatedChild_7); 32107ac75b1Sopenharmony_ci } 32207ac75b1Sopenharmony_ci Column.pop(); 32307ac75b1Sopenharmony_ci } 32407ac75b1Sopenharmony_ci} 32507ac75b1Sopenharmony_ciloadDocument(new ImportTest("1", undefined, {})); 32607ac75b1Sopenharmony_ci` 327