• 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 * as AllComponent from './test/pages/NamespaceComponent'
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        AllComponent.NamespaceComponent1({
31            NamespaceComponent1Link1: $myState1,
32            NamespaceComponent1Link2: $myState2,
33            NamespaceComponent1Link3: $myState3,
34            NamespaceComponent1Link4: $myState4,
35            myVar: 100,
36            myVar2: 80
37          })
38        AllComponent.NamespaceComponent1({
39            NamespaceComponent1Link1: $myState1,
40            NamespaceComponent1Link2: $myState2,
41            NamespaceComponent1Link3: $myState3,
42            NamespaceComponent1Link4: $myState4,
43            myVar: 100,
44            myVar2: 80
45          })
46          .width(100)
47          AllComponent.default({
48            NamespaceComponent3Link1: $myState1,
49            NamespaceComponent3Link2: $myState2,
50            NamespaceComponent3Link3: $myState3,
51            NamespaceComponent3Link4: $myState4,
52            myVar: 100,
53            myVar2: 80
54          })
55          AllComponent.default({
56            NamespaceComponent3Link1: $myState1,
57            NamespaceComponent3Link2: $myState2,
58            NamespaceComponent3Link3: $myState3,
59            NamespaceComponent3Link4: $myState4,
60            myVar: 100,
61            myVar2: 80
62          })
63          .height(200)
64    }
65  }
66}
67`
68
69exports.expectResult =
70`"use strict";
71var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
72    if (k2 === undefined) k2 = k;
73    var desc = Object.getOwnPropertyDescriptor(m, k);
74    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
75      desc = { enumerable: true, get: function() { return m[k]; } };
76    }
77    Object.defineProperty(o, k2, desc);
78}) : (function(o, m, k, k2) {
79    if (k2 === undefined) k2 = k;
80    o[k2] = m[k];
81}));
82var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
83    Object.defineProperty(o, "default", { enumerable: true, value: v });
84}) : function(o, v) {
85    o["default"] = v;
86});
87var __importStar = (this && this.__importStar) || function (mod) {
88    if (mod && mod.__esModule) return mod;
89    var result = {};
90    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
91    __setModuleDefault(result, mod);
92    return result;
93};
94var __importDefault = (this && this.__importDefault) || function (mod) {
95    return (mod && mod.__esModule) ? mod : { "default": mod };
96};
97Object.defineProperty(exports, "__esModule", { value: true });
98if (!("finalizeConstruction" in ViewPU.prototype)) {
99    Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
100}
101const AllComponent = __importStar(require("./test/pages/NamespaceComponent"));
102const TsModule_1 = __importDefault(require("./test/pages/TsModule"));
103class ImportTest extends ViewPU {
104    constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) {
105        super(parent, __localStorage, elmtId, extraInfo);
106        if (typeof paramsLambda === "function") {
107            this.paramsGenerator_ = paramsLambda;
108        }
109        this.__myState1 = new ObservedPropertyObjectPU(new TsModule_1.default(1).method(), this, "myState1");
110        this.__myState2 = new ObservedPropertySimplePU(0, this, "myState2");
111        this.__myState3 = new ObservedPropertySimplePU(false, this, "myState3");
112        this.__myState4 = new ObservedPropertySimplePU('ImportTest', this, "myState4");
113        this.setInitiallyProvidedValue(params);
114        this.finalizeConstruction();
115    }
116    setInitiallyProvidedValue(params) {
117        if (params.myState1 !== undefined) {
118            this.myState1 = params.myState1;
119        }
120        if (params.myState2 !== undefined) {
121            this.myState2 = params.myState2;
122        }
123        if (params.myState3 !== undefined) {
124            this.myState3 = params.myState3;
125        }
126        if (params.myState4 !== undefined) {
127            this.myState4 = params.myState4;
128        }
129    }
130    updateStateVars(params) {
131    }
132    purgeVariableDependenciesOnElmtId(rmElmtId) {
133        this.__myState1.purgeDependencyOnElmtId(rmElmtId);
134        this.__myState2.purgeDependencyOnElmtId(rmElmtId);
135        this.__myState3.purgeDependencyOnElmtId(rmElmtId);
136        this.__myState4.purgeDependencyOnElmtId(rmElmtId);
137    }
138    aboutToBeDeleted() {
139        this.__myState1.aboutToBeDeleted();
140        this.__myState2.aboutToBeDeleted();
141        this.__myState3.aboutToBeDeleted();
142        this.__myState4.aboutToBeDeleted();
143        SubscriberManager.Get().delete(this.id__());
144        this.aboutToBeDeletedInternal();
145    }
146    get myState1() {
147        return this.__myState1.get();
148    }
149    set myState1(newValue) {
150        this.__myState1.set(newValue);
151    }
152    get myState2() {
153        return this.__myState2.get();
154    }
155    set myState2(newValue) {
156        this.__myState2.set(newValue);
157    }
158    get myState3() {
159        return this.__myState3.get();
160    }
161    set myState3(newValue) {
162        this.__myState3.set(newValue);
163    }
164    get myState4() {
165        return this.__myState4.get();
166    }
167    set myState4(newValue) {
168        this.__myState4.set(newValue);
169    }
170    initialRender() {
171        this.observeComponentCreation2((elmtId, isInitialRender) => {
172            Column.create();
173        }, Column);
174        {
175            this.observeComponentCreation2((elmtId, isInitialRender) => {
176                if (isInitialRender) {
177                    let componentCall = new AllComponent.NamespaceComponent1(this, {
178                        NamespaceComponent1Link1: this.__myState1,
179                        NamespaceComponent1Link2: this.__myState2,
180                        NamespaceComponent1Link3: this.__myState3,
181                        NamespaceComponent1Link4: this.__myState4,
182                        myVar: 100,
183                        myVar2: 80
184                    }, undefined, elmtId, () => { }, { page: "importAllEts.ets", line: 15, col: 9 });
185                    ViewPU.create(componentCall);
186                    let paramsLambda = () => {
187                        return {
188                            NamespaceComponent1Link1: this.myState1,
189                            NamespaceComponent1Link2: this.myState2,
190                            NamespaceComponent1Link3: this.myState3,
191                            NamespaceComponent1Link4: this.myState4,
192                            myVar: 100,
193                            myVar2: 80
194                        };
195                    };
196                    componentCall.paramsGenerator_ = paramsLambda;
197                }
198                else {
199                    this.updateStateVarsOfChildByElmtId(elmtId, {});
200                }
201            }, { name: "NamespaceComponent1" });
202        }
203        this.observeComponentCreation2((elmtId, isInitialRender) => {
204            __Common__.create();
205            __Common__.width(100);
206        }, __Common__);
207        {
208            this.observeComponentCreation2((elmtId, isInitialRender) => {
209                if (isInitialRender) {
210                    let componentCall = new AllComponent.NamespaceComponent1(this, {
211                        NamespaceComponent1Link1: this.__myState1,
212                        NamespaceComponent1Link2: this.__myState2,
213                        NamespaceComponent1Link3: this.__myState3,
214                        NamespaceComponent1Link4: this.__myState4,
215                        myVar: 100,
216                        myVar2: 80
217                    }, undefined, elmtId, () => { }, { page: "importAllEts.ets", line: 23, col: 9 });
218                    ViewPU.create(componentCall);
219                    let paramsLambda = () => {
220                        return {
221                            NamespaceComponent1Link1: this.myState1,
222                            NamespaceComponent1Link2: this.myState2,
223                            NamespaceComponent1Link3: this.myState3,
224                            NamespaceComponent1Link4: this.myState4,
225                            myVar: 100,
226                            myVar2: 80
227                        };
228                    };
229                    componentCall.paramsGenerator_ = paramsLambda;
230                }
231                else {
232                    this.updateStateVarsOfChildByElmtId(elmtId, {});
233                }
234            }, { name: "NamespaceComponent1" });
235        }
236        __Common__.pop();
237        {
238            this.observeComponentCreation2((elmtId, isInitialRender) => {
239                if (isInitialRender) {
240                    let componentCall = new AllComponent.default(this, {
241                        NamespaceComponent3Link1: this.__myState1,
242                        NamespaceComponent3Link2: this.__myState2,
243                        NamespaceComponent3Link3: this.__myState3,
244                        NamespaceComponent3Link4: this.__myState4,
245                        myVar: 100,
246                        myVar2: 80
247                    }, undefined, elmtId, () => { }, { page: "importAllEts.ets", line: 32, col: 11 });
248                    ViewPU.create(componentCall);
249                    let paramsLambda = () => {
250                        return {
251                            NamespaceComponent3Link1: this.myState1,
252                            NamespaceComponent3Link2: this.myState2,
253                            NamespaceComponent3Link3: this.myState3,
254                            NamespaceComponent3Link4: this.myState4,
255                            myVar: 100,
256                            myVar2: 80
257                        };
258                    };
259                    componentCall.paramsGenerator_ = paramsLambda;
260                }
261                else {
262                    this.updateStateVarsOfChildByElmtId(elmtId, {});
263                }
264            }, { name: "default" });
265        }
266        this.observeComponentCreation2((elmtId, isInitialRender) => {
267            __Common__.create();
268            __Common__.height(200);
269        }, __Common__);
270        {
271            this.observeComponentCreation2((elmtId, isInitialRender) => {
272                if (isInitialRender) {
273                    let componentCall = new AllComponent.default(this, {
274                        NamespaceComponent3Link1: this.__myState1,
275                        NamespaceComponent3Link2: this.__myState2,
276                        NamespaceComponent3Link3: this.__myState3,
277                        NamespaceComponent3Link4: this.__myState4,
278                        myVar: 100,
279                        myVar2: 80
280                    }, undefined, elmtId, () => { }, { page: "importAllEts.ets", line: 40, col: 11 });
281                    ViewPU.create(componentCall);
282                    let paramsLambda = () => {
283                        return {
284                            NamespaceComponent3Link1: this.myState1,
285                            NamespaceComponent3Link2: this.myState2,
286                            NamespaceComponent3Link3: this.myState3,
287                            NamespaceComponent3Link4: this.myState4,
288                            myVar: 100,
289                            myVar2: 80
290                        };
291                    };
292                    componentCall.paramsGenerator_ = paramsLambda;
293                }
294                else {
295                    this.updateStateVarsOfChildByElmtId(elmtId, {});
296                }
297            }, { name: "default" });
298        }
299        __Common__.pop();
300        Column.pop();
301    }
302    rerender() {
303        this.updateDirtyElements();
304    }
305}
306ViewStackProcessor.StartGetAccessRecordingFor(ViewStackProcessor.AllocateNewElmetIdForNextComponent());
307loadDocument(new ImportTest(undefined, {}));
308ViewStackProcessor.StopGetAccessRecording();
309`
310