diff --git a/arkui-plugins/common/predefines.ts b/arkui-plugins/common/predefines.ts index 642d0219a8693c3b6e6ab4fad069871cdb3595ab..9c89838268b42919ce0a444d0c7fbc74ff293c23 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 ae383cc166a70560623afcb07714d182192f6777..b87ef961819e903fc0090dbec280b3427ff65eb9 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 e4dd29d224a73bb929913285ac9d5fb2cb602a91..268355f4087e1633b9b81fd8d42029d303fad1a5 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 29cd1b6af751eea9f7d4c1f64125aff6dd6ae9cf..b597338a8c8a09f2076a77db6655c417d047d52f 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 9c2960d1b9d9ef9808404b7c747df6f0451dbdeb..d05d8cc5998faeeeb0597cced479eab9fd90aa74 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 {