From 2bcfa4b3ffa98f06aefd61c42bbf23e3ac3e9860 Mon Sep 17 00:00:00 2001 From: Bojiang Date: Tue, 1 Apr 2025 20:46:35 +0800 Subject: [PATCH] jiangbo91@huawei.com fix $r $rawfile `` Signed-off-by: Bojiang Change-Id: I3dac930d0e4b71a513a007e3b209f4ca3a26d2aa --- compiler/src/process_ui_syntax.ts | 2 +- .../resource/resourceTest.js.sample | 58 +++++++++++++++++++ .../resource/resourceTest.ets | 25 ++++++++ .../test/transform_ut/helpers/pathConfig.ts | 2 + 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample create mode 100644 compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets diff --git a/compiler/src/process_ui_syntax.ts b/compiler/src/process_ui_syntax.ts index 72ec22d69..878b2b929 100644 --- a/compiler/src/process_ui_syntax.ts +++ b/compiler/src/process_ui_syntax.ts @@ -736,7 +736,7 @@ export function isAnimateToOrImmediately(node: ts.Node): boolean { export function processResourceData(node: ts.CallExpression, filePath: string, previewLog: {isAcceleratePreview: boolean, log: LogInfo[]} = {isAcceleratePreview: false, log: []}): ts.Node { - if (ts.isStringLiteral(node.arguments[0])) { + if (ts.isStringLiteral(node.arguments[0]) || ts.isNoSubstitutionTemplateLiteral(node.arguments[0])) { const resourceData: string[] = (node.arguments[0] as ts.StringLiteral).text.trim().split('.'); const isResourceModule: boolean = resourceData.length && /^\[.*\]$/g.test(resourceData[0]); if (node.expression.getText() === RESOURCE_RAWFILE) { diff --git a/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample new file mode 100644 index 000000000..f3d898bf4 --- /dev/null +++ b/compiler/test/transform_ut/application/entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.js.sample @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +"use strict"; +if (!("finalizeConstruction" in ViewPU.prototype)) { + Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { }); +} +class Index extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1, paramsLambda = undefined, extraInfo) { + super(parent, __localStorage, elmtId, extraInfo); + if (typeof paramsLambda === "function") { + this.paramsGenerator_ = paramsLambda; + } + this.setInitiallyProvidedValue(params); + this.finalizeConstruction(); + } + setInitiallyProvidedValue(params) { + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + } + aboutToBeDeleted() { + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + initialRender() { + this.observeComponentCreation2((elmtId, isInitialRender) => { + Row.create(); + }, Row); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Image.create({ "id": 0, "type": 30000, params: ['foreground.png'], "bundleName": "com.example.application", "moduleName": "application" }); + }, Image); + this.observeComponentCreation2((elmtId, isInitialRender) => { + Image.create({ "id": 0, "type": 30000, params: [`foreground.png`], "bundleName": "com.example.application", "moduleName": "application" }); + }, Image); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } + static getEntryName() { + return "Index"; + } +} +registerNamedRoute(() => new Index(undefined, {}), "", { bundleName: "com.example.application", moduleName: "application", pagePath: "pages/utForPartialUpdate/resource/resourceTest", pageFullPath: "application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest", integratedHsp: "false", moduleType: "followWithHap" }); +//# sourceMappingURL=resourceTest.js.map \ No newline at end of file diff --git a/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets new file mode 100644 index 000000000..57402fbdb --- /dev/null +++ b/compiler/test/transform_ut/application/entry/src/main/ets/pages/utForPartialUpdate/resource/resourceTest.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Reusable test +@Entry +@Component +struct Index { + build() { + Row() { + Image($rawfile('foreground.png')) + Image($rawfile(`foreground.png`)) + } + } +} \ No newline at end of file diff --git a/compiler/test/transform_ut/helpers/pathConfig.ts b/compiler/test/transform_ut/helpers/pathConfig.ts index 936ccfdc3..14a3de177 100644 --- a/compiler/test/transform_ut/helpers/pathConfig.ts +++ b/compiler/test/transform_ut/helpers/pathConfig.ts @@ -213,6 +213,8 @@ export const UT_PARTIAL_UPFATE_PAGES: string[] = [ 'v2_component_decorator/reusableV2/reusableV2_initialRender', 'v2_component_decorator/reusableV2/reusableV2_members', 'v2_component_decorator/reusableV2/reusableV2_component_nesting', + + 'resource/resourceTest', ]; export const UT_VALIDATE_PAGES_PREVIEW: string[] = []; -- Gitee