• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16exports.source = `
17import { AllStarComponent } from './test/pages/ExportStarComponent'
18import TsModule from './test/pages/TsModule'
19
20@Entry
21@Component
22struct ImportTest {
23  @State myState1: any = new TsModule(1).method();
24  @State myState2: number = 0
25  @State myState3: boolean = false
26  @State myState4: string = 'ImportTest'
27
28  build() {
29    Column() {
30      AllStarComponent.ExportComponent({
31        ExportComponent1Link1: $myState1,
32        ExportComponent1Link2: $myState2,
33        ExportComponent1Link3: $myState3,
34        ExportComponent1Link4: $myState4,
35        indexState1: { count: 1 },
36        indexState2: 1,
37        indexState3: true,
38        indexState4: 'ExportComponent1'
39      })
40      AllStarComponent.default({
41        ExportComponent4Link1: $myState1,
42        ExportComponent4Link2: $myState2,
43        ExportComponent4Link3: $myState3,
44        ExportComponent4Link4: $myState4,
45        indexState1: { count: 1 },
46        indexState2: 1,
47        indexState3: true,
48        indexState4: 'ExportComponent4'
49      })
50    }
51  }
52}
53`
54
55exports.expectResult =
56`"use strict";
57var __importDefault = (this && this.__importDefault) || function (mod) {
58    return (mod && mod.__esModule) ? mod : { "default": mod };
59};
60Object.defineProperty(exports, "__esModule", { value: true });
61const ExportStarComponent_1 = require("./test/pages/ExportStarComponent");
62const TsModule_1 = __importDefault(require("./test/pages/TsModule"));
63class ImportTest extends ViewPU {
64    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
65        super(parent, __localStorage, elmtId, extraInfo);
66        if (typeof paramsLambda === "function") {
67            this.paramsGenerator_ = paramsLambda;
68        }
69        this.__myState1 = new ObservedPropertyObjectPU(new TsModule_1.default(1).method(), this, "myState1");
70        this.__myState2 = new ObservedPropertySimplePU(0, this, "myState2");
71        this.__myState3 = new ObservedPropertySimplePU(false, this, "myState3");
72        this.__myState4 = new ObservedPropertySimplePU('ImportTest', this, "myState4");
73        this.setInitiallyProvidedValue(params);
74    }
75    setInitiallyProvidedValue(params) {
76        if (params.myState1 !== undefined) {
77            this.myState1 = params.myState1;
78        }
79        if (params.myState2 !== undefined) {
80            this.myState2 = params.myState2;
81        }
82        if (params.myState3 !== undefined) {
83            this.myState3 = params.myState3;
84        }
85        if (params.myState4 !== undefined) {
86            this.myState4 = params.myState4;
87        }
88    }
89    updateStateVars(params) {
90    }
91    purgeVariableDependenciesOnElmtId(rmElmtId) {
92        this.__myState1.purgeDependencyOnElmtId(rmElmtId);
93        this.__myState2.purgeDependencyOnElmtId(rmElmtId);
94        this.__myState3.purgeDependencyOnElmtId(rmElmtId);
95        this.__myState4.purgeDependencyOnElmtId(rmElmtId);
96    }
97    aboutToBeDeleted() {
98        this.__myState1.aboutToBeDeleted();
99        this.__myState2.aboutToBeDeleted();
100        this.__myState3.aboutToBeDeleted();
101        this.__myState4.aboutToBeDeleted();
102        SubscriberManager.Get().delete(this.id__());
103        this.aboutToBeDeletedInternal();
104    }
105    get myState1() {
106        return this.__myState1.get();
107    }
108    set myState1(newValue) {
109        this.__myState1.set(newValue);
110    }
111    get myState2() {
112        return this.__myState2.get();
113    }
114    set myState2(newValue) {
115        this.__myState2.set(newValue);
116    }
117    get myState3() {
118        return this.__myState3.get();
119    }
120    set myState3(newValue) {
121        this.__myState3.set(newValue);
122    }
123    get myState4() {
124        return this.__myState4.get();
125    }
126    set myState4(newValue) {
127        this.__myState4.set(newValue);
128    }
129    initialRender() {
130        this.observeComponentCreation2((elmtId, isInitialRender) => {
131            Column.create();
132        }, Column);
133        {
134            this.observeComponentCreation2((elmtId, isInitialRender) => {
135                if (isInitialRender) {
136                    let componentCall = new ExportStarComponent_1.AllStarComponent.ExportComponent(this, {
137                        ExportComponent1Link1: this.__myState1,
138                        ExportComponent1Link2: this.__myState2,
139                        ExportComponent1Link3: this.__myState3,
140                        ExportComponent1Link4: this.__myState4,
141                        indexState1: { count: 1 },
142                        indexState2: 1,
143                        indexState3: true,
144                        indexState4: 'ExportComponent1'
145                    }, undefined, elmtId, () => { }, { page: "importTs.ets", line: 15 });
146                    ViewPU.create(componentCall);
147                    let paramsLambda = () => {
148                        return {
149                            ExportComponent1Link1: this.myState1,
150                            ExportComponent1Link2: this.myState2,
151                            ExportComponent1Link3: this.myState3,
152                            ExportComponent1Link4: this.myState4,
153                            indexState1: { count: 1 },
154                            indexState2: 1,
155                            indexState3: true,
156                            indexState4: 'ExportComponent1'
157                        };
158                    };
159                    componentCall.paramsGenerator_ = paramsLambda;
160                }
161                else {
162                    this.updateStateVarsOfChildByElmtId(elmtId, {});
163                }
164            }, { name: "ExportComponent" });
165        }
166        {
167            this.observeComponentCreation2((elmtId, isInitialRender) => {
168                if (isInitialRender) {
169                    let componentCall = new ExportStarComponent_1.AllStarComponent.default(this, {
170                        ExportComponent4Link1: this.__myState1,
171                        ExportComponent4Link2: this.__myState2,
172                        ExportComponent4Link3: this.__myState3,
173                        ExportComponent4Link4: this.__myState4,
174                        indexState1: { count: 1 },
175                        indexState2: 1,
176                        indexState3: true,
177                        indexState4: 'ExportComponent4'
178                    }, undefined, elmtId, () => { }, { page: "importTs.ets", line: 25 });
179                    ViewPU.create(componentCall);
180                    let paramsLambda = () => {
181                        return {
182                            ExportComponent4Link1: this.myState1,
183                            ExportComponent4Link2: this.myState2,
184                            ExportComponent4Link3: this.myState3,
185                            ExportComponent4Link4: this.myState4,
186                            indexState1: { count: 1 },
187                            indexState2: 1,
188                            indexState3: true,
189                            indexState4: 'ExportComponent4'
190                        };
191                    };
192                    componentCall.paramsGenerator_ = paramsLambda;
193                }
194                else {
195                    this.updateStateVarsOfChildByElmtId(elmtId, {});
196                }
197            }, { name: "default" });
198        }
199        Column.pop();
200    }
201    rerender() {
202        this.updateDirtyElements();
203    }
204}
205ViewStackProcessor.StartGetAccessRecordingFor(ViewStackProcessor.AllocateNewElmetIdForNextComponent());
206loadDocument(new ImportTest(undefined, {}));
207ViewStackProcessor.StopGetAccessRecording();
208`
209