From fe4abddd4ae845727640de5bcc1878798f511ed2 Mon Sep 17 00:00:00 2001 From: VictorS67 Date: Mon, 8 Sep 2025 16:26:05 +0800 Subject: [PATCH] change EntryPoint from arkui.UserView to arkui.component.customComponent Signed-off-by: VictorS67 Change-Id: I03a25a8688d730eff6569fee32f6fce164f5acd8 --- arkui-plugins/common/predefines.ts | 1 - arkui-plugins/ui-plugins/component-transformer.ts | 13 ++++++------- .../ui-plugins/entry-translators/factory.ts | 10 +++++----- arkui-plugins/ui-plugins/ui-factory.ts | 2 +- arkui-plugins/ui-plugins/utils.ts | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/arkui-plugins/common/predefines.ts b/arkui-plugins/common/predefines.ts index 642d0219a..9c8983826 100644 --- a/arkui-plugins/common/predefines.ts +++ b/arkui-plugins/common/predefines.ts @@ -32,7 +32,6 @@ export const ARKUI_IMPORT_PREFIX_NAMES: (string | RegExp)[] = [/arkui\..*/, /@oh export const MEMO_IMPORT_SOURCE_NAME: string = 'arkui.stateManagement.runtime'; export const CUSTOM_COMPONENT_IMPORT_SOURCE_NAME: string = 'arkui.component.customComponent'; export const CUSTOM_DIALOG_CONTROLLER_SOURCE_NAME: string = 'arkui.component.customDialogController'; -export const ENTRY_POINT_IMPORT_SOURCE_NAME: string = 'arkui.UserView'; export const ARKUI_COMPONENT_COMMON_SOURCE_NAME: string = 'arkui.component.common'; export const ARKUI_FOREACH_SOURCE_NAME: string = 'arkui.component.forEach'; export const ARKUI_BUILDER_SOURCE_NAME: string = 'arkui.component.builder'; diff --git a/arkui-plugins/ui-plugins/component-transformer.ts b/arkui-plugins/ui-plugins/component-transformer.ts index ae383cc16..b87ef9618 100644 --- a/arkui-plugins/ui-plugins/component-transformer.ts +++ b/arkui-plugins/ui-plugins/component-transformer.ts @@ -50,7 +50,6 @@ import { DecoratorIntrinsicNames, DecoratorNames, DECORATOR_TYPE_MAP, - ENTRY_POINT_IMPORT_SOURCE_NAME, NavigationNames, EntryWrapperNames, } from '../common/predefines'; @@ -157,7 +156,7 @@ export class ComponentTransformer extends AbstractVisitor { if (arkts.isETSImportDeclaration(node) && !this.isEntryPointImported) { this.isEntryPointImported = !!findLocalImport( node, - ENTRY_POINT_IMPORT_SOURCE_NAME, + CUSTOM_COMPONENT_IMPORT_SOURCE_NAME, EntryWrapperNames.ENTRY_POINT_CLASS_NAME ); } @@ -172,7 +171,7 @@ export class ComponentTransformer extends AbstractVisitor { this.isLayoutCallbackImported = !!findLocalImport( node, CUSTOM_COMPONENT_IMPORT_SOURCE_NAME, - CustomComponentNames.LAYOUT_CALLBACK + CustomComponentNames.LAYOUT_CALLBACKS ); } } @@ -203,7 +202,7 @@ export class ComponentTransformer extends AbstractVisitor { } processEtsScript(node: arkts.EtsScript): arkts.EtsScript { - if (this.isExternal && this.externalSourceName === ENTRY_POINT_IMPORT_SOURCE_NAME) { + if (this.isExternal && this.externalSourceName === CUSTOM_COMPONENT_IMPORT_SOURCE_NAME) { const navInterface = entryFactory.createNavInterface(); navInterface.modifiers = arkts.Es2pandaModifierFlags.MODIFIER_FLAGS_EXPORT; return arkts.factory.updateEtsScript(node, [...node.statements, navInterface]); @@ -231,7 +230,7 @@ export class ComponentTransformer extends AbstractVisitor { updateStatements.push( entryFactory.callRegisterNamedRouter(this.entryRouteName, this.projectConfig, this.program?.absName) ); - this.createImportDeclaration(ENTRY_POINT_IMPORT_SOURCE_NAME, NavigationNames.NAVINTERFACE); + this.createImportDeclaration(CUSTOM_COMPONENT_IMPORT_SOURCE_NAME, NavigationNames.NAVINTERFACE); } if (updateStatements.length > 0) { return arkts.factory.updateEtsScript(node, [...node.statements, ...updateStatements]); @@ -259,7 +258,7 @@ export class ComponentTransformer extends AbstractVisitor { ); } if (!this.isLayoutCallbackImported && this.componentType.hasCustomLayout) { - this.createImportDeclaration(CUSTOM_COMPONENT_IMPORT_SOURCE_NAME, CustomComponentNames.LAYOUT_CALLBACK); + this.createImportDeclaration(CUSTOM_COMPONENT_IMPORT_SOURCE_NAME, CustomComponentNames.LAYOUT_CALLBACKS); } } @@ -551,7 +550,7 @@ export class ComponentTransformer extends AbstractVisitor { } if ( arkts.isClassDeclaration(newNode) && - this.externalSourceName === ENTRY_POINT_IMPORT_SOURCE_NAME && + this.externalSourceName === CUSTOM_COMPONENT_IMPORT_SOURCE_NAME && newNode.definition?.ident?.name === EntryWrapperNames.ENTRY_POINT_CLASS_NAME ) { return this.updateEntryPoint(newNode); diff --git a/arkui-plugins/ui-plugins/entry-translators/factory.ts b/arkui-plugins/ui-plugins/entry-translators/factory.ts index e4dd29d22..268355f40 100644 --- a/arkui-plugins/ui-plugins/entry-translators/factory.ts +++ b/arkui-plugins/ui-plugins/entry-translators/factory.ts @@ -16,7 +16,7 @@ import * as arkts from '@koalaui/libarkts'; import * as path from 'path'; import { annotation, createAndInsertImportDeclaration } from '../../common/arkts-utils'; -import { ENTRY_POINT_IMPORT_SOURCE_NAME, EntryWrapperNames, NavigationNames } from '../../common/predefines'; +import { CUSTOM_COMPONENT_IMPORT_SOURCE_NAME, EntryWrapperNames, NavigationNames } from '../../common/predefines'; import { ProjectConfig } from '../../common/plugin-context'; import { factory as uiFactory } from '../ui-factory'; import { getRelativePagePath } from './utils'; @@ -264,11 +264,11 @@ export class factory { } /** - * create and insert `import { EntryPoint as EntryPoint } from "@ohos.arkui.UserView";` + * create and insert `import { EntryPoint as EntryPoint } from "arkui.component.customComponent";` * to the top of script's statements. */ static createAndInsertEntryPointImport(program?: arkts.Program) { - const source: arkts.StringLiteral = arkts.factory.create1StringLiteral(ENTRY_POINT_IMPORT_SOURCE_NAME); + const source: arkts.StringLiteral = arkts.factory.create1StringLiteral(CUSTOM_COMPONENT_IMPORT_SOURCE_NAME); const imported: arkts.Identifier = arkts.factory.createIdentifier(EntryWrapperNames.ENTRY_POINT_CLASS_NAME); // Insert this import at the top of the script's statements. if (!program) { @@ -401,7 +401,7 @@ export class factory { } /** - * generate interface NavInterface in header arkui.UserView + * generate interface NavInterface in header arkui.component.customComponent */ static createNavInterface(): arkts.TSInterfaceDeclaration { return arkts.factory.createInterfaceDeclaration( @@ -444,7 +444,7 @@ export class factory { } /** - * generate generateRegisterNamedRouter method in header arkui.UserView + * generate generateRegisterNamedRouter method in header arkui.component.customComponent */ static generateRegisterNamedRouter(): arkts.MethodDefinition { const params = [ diff --git a/arkui-plugins/ui-plugins/ui-factory.ts b/arkui-plugins/ui-plugins/ui-factory.ts index 29cd1b6af..b597338a8 100644 --- a/arkui-plugins/ui-plugins/ui-factory.ts +++ b/arkui-plugins/ui-plugins/ui-factory.ts @@ -402,7 +402,7 @@ export class factory { implementsInfo.push(factory.createClassImplements(CustomComponentNames.PAGE_LIFE_CYCLE)); } if (annotations.customLayout) { - implementsInfo.push(factory.createClassImplements(CustomComponentNames.LAYOUT_CALLBACK)); + implementsInfo.push(factory.createClassImplements(CustomComponentNames.LAYOUT_CALLBACKS)); } return implementsInfo; } diff --git a/arkui-plugins/ui-plugins/utils.ts b/arkui-plugins/ui-plugins/utils.ts index 9c2960d1b..d05d8cc59 100644 --- a/arkui-plugins/ui-plugins/utils.ts +++ b/arkui-plugins/ui-plugins/utils.ts @@ -37,7 +37,7 @@ export enum CustomComponentNames { BUILDCOMPATIBLENODE = '_buildCompatibleNode', OPTIONS = 'options', PAGE_LIFE_CYCLE = 'PageLifeCycle', - LAYOUT_CALLBACK = 'LayoutCallback', + LAYOUT_CALLBACKS = 'LayoutCallbacks', } export enum CustomDialogNames { -- Gitee