From 11e621ba5647ad93a6f410b9c557423dca989b6b Mon Sep 17 00:00:00 2001 From: naumovdmitrii Date: Tue, 11 Feb 2025 15:46:43 +0300 Subject: [PATCH 1/6] add test Signed-off-by: naumovdmitrii --- arkoala/ets-plugin/src/DollarTransformer.ts | 11 ++-- arkoala/ets-plugin/src/utils.ts | 1 + .../test/ets/dollar-dollar/components.ets | 65 +++++++++++++++++++ arkoala/ets-plugin/test/rewrites.test.ts | 4 +- arkoala/ets-plugin/test/utils.ts | 3 +- 5 files changed, 75 insertions(+), 9 deletions(-) create mode 100644 arkoala/ets-plugin/test/ets/dollar-dollar/components.ets diff --git a/arkoala/ets-plugin/src/DollarTransformer.ts b/arkoala/ets-plugin/src/DollarTransformer.ts index 12a3dfe99..f2c1ce222 100644 --- a/arkoala/ets-plugin/src/DollarTransformer.ts +++ b/arkoala/ets-plugin/src/DollarTransformer.ts @@ -18,7 +18,6 @@ import { AbstractVisitor } from "./AbstractVisitor"; import { NameTable } from "./utils"; import { Importer } from "./Importer"; - export interface ApplicationInfo { bundleName: string, moduleName: string @@ -44,7 +43,7 @@ export class DollarTransformer extends AbstractVisitor { if (!name.startsWith("$")) return false const fieldName = name.substring(1) // TODO: is it correct? - // The white list has a preference over the fields. + // The white list has a preference over the fields. if (this.whiteList.includes(name)) return false if (!this.currentStruct) return false if (this.currentStruct.members.find(it => ( @@ -74,12 +73,12 @@ export class DollarTransformer extends AbstractVisitor { const name = ts.idText(node.expression as ts.Identifier).replace('$', '_') const args = node.arguments.slice() - + args.unshift( - ts.factory.createStringLiteral(this.applicationInfo?.bundleName ?? ""), + ts.factory.createStringLiteral(this.applicationInfo?.bundleName ?? ""), ts.factory.createStringLiteral(this.applicationInfo?.moduleName ?? "entry") ) - + return ts.factory.updateCallExpression( node, ts.factory.createIdentifier(this.importer.withAdaptorImport(name)), @@ -90,13 +89,11 @@ export class DollarTransformer extends AbstractVisitor { } visitor(node: ts.Node): ts.Node { - if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) { if (this.isDollarCallExpression(node)) { return this.transformDollarCallExpression(node) } } - if (ts.isStruct(node)) { this.currentStruct = node const transformed = this.visitEachChild(node) diff --git a/arkoala/ets-plugin/src/utils.ts b/arkoala/ets-plugin/src/utils.ts index 3dd818307..d1124bb23 100644 --- a/arkoala/ets-plugin/src/utils.ts +++ b/arkoala/ets-plugin/src/utils.ts @@ -46,6 +46,7 @@ export const ArkCommonMethodComponent = "ArkCommonMethodComponent" export const T_TypeParameter = "T" export const CommonInstance = "CommonInstance" export const Instance = "Instance" +export const DollarDollar = "$$" export enum SyncedPropertyConstructor { propState = "propState", diff --git a/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets b/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets new file mode 100644 index 000000000..a7df2046d --- /dev/null +++ b/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets @@ -0,0 +1,65 @@ +@Entry +@Component +struct Index { + @State n: number = 0.5 + @State s: string = "0.5" + @State b: boolean = true + @State d: Date = new Date('2021-08-08') + @State m: PanelMode = PanelMode.Mini + @State l: ListItemStyle = ListItemStyle.NONE + + build() { + Column() { + Slider({ value: this.n }) + Toggle({ type: ToggleType.Switch, isOn: $$this.b }) + Stepper({ index: this.n }) + Checkbox() + .select($$this.b) + CheckboxGroup() + .selectAll($$this.b) + DatePicker({ selected: $$this.d }) + TimePicker({ selected: $$this.d }) + MenuItem() + .selected($$this.b) + Panel(false) + .mode($$this.m) + Radio({group: "", value: ""}) + .checked($$this.b) + Search({ value: $$this.s }) + SideBarContainer(SideBarContainerType.Embed) + .showSideBar($$this.b) + Swiper() + .index($$this.n) + Tabs({ index: $$this.n }) + TextInput({ text: $$this.s }) + TextArea({ text: $$this.s }) + TextInput({ text: $$this.s }) + Toggle({ type: ToggleType.Checkbox, isOn: $$this.b }) + AlphabetIndexer({arrayValue: [], selected: $$this.n }) + Refresh({ refreshing: $$this.b }) + TextPicker({ range: [], value: $$this.s, selected: $$this.n }) + Select([]) + .value($$this.s) + .selected($$this.n) + List() { + ListItemGroup() { + ListItem({ style: this.l }) + .selected($$this.b) + } + } + Grid() { + GridItem({}) + .selected($$this.b) + } + + Button() + .bindSheet($$this.b, builder) + .bindContentCover($$this.b, builder) + } + } +} + +@Builder +function builder() { + Text() +} \ No newline at end of file diff --git a/arkoala/ets-plugin/test/rewrites.test.ts b/arkoala/ets-plugin/test/rewrites.test.ts index 7568987c1..42b6978a4 100644 --- a/arkoala/ets-plugin/test/rewrites.test.ts +++ b/arkoala/ets-plugin/test/rewrites.test.ts @@ -13,7 +13,7 @@ * limitations under the License. */ -import { assertGeneratedEqualsGolden } from "./utils" +import { assertGeneratedEqualsGolden, testFolder } from "./utils" suite("Basic rewrites of ArkUI syntactic features", () => { test("Basic rewrites", () => assertGeneratedEqualsGolden("Rewrite.ts")) @@ -39,6 +39,8 @@ suite("Basic rewrites of ArkUI syntactic features", () => { test("Trailing block user structs", () => assertGeneratedEqualsGolden("trailing-block.ts")) }) +testFolder("dollar-dollar") + suite("Arkts rewrites", () => { test("Rewrite.ets", () => assertGeneratedEqualsGolden("arkts/Rewrite.ts")) test("Rewrite2.ets", () => assertGeneratedEqualsGolden("arkts/Rewrite2.ts")) diff --git a/arkoala/ets-plugin/test/utils.ts b/arkoala/ets-plugin/test/utils.ts index a4da1e0c1..aba4f32aa 100644 --- a/arkoala/ets-plugin/test/utils.ts +++ b/arkoala/ets-plugin/test/utils.ts @@ -28,7 +28,8 @@ export function testFolder(folder: string) { test(file, () => { assertEqualFiles( path.resolve(golden, file), - path.resolve(current, file)) + path.resolve(current, file) + ) }) }) }) -- Gitee From 9b475a71f602d7e2b6cc86076605181ad8899efd Mon Sep 17 00:00:00 2001 From: naumovdmitrii Date: Tue, 11 Feb 2025 20:36:18 +0300 Subject: [PATCH 2/6] somewhat works Signed-off-by: naumovdmitrii --- arkoala/arkui-types/index-full.d.ts | 2 + arkoala/ets-plugin/src/ArkExpander.ts | 117 +++++----- arkoala/ets-plugin/src/CallTransformer.ts | 1 - .../ets-plugin/src/DollarDollarTransformer.ts | 214 ++++++++++++++++++ .../test/ets/dollar-dollar/components.ets | 50 ++-- 5 files changed, 301 insertions(+), 83 deletions(-) create mode 100644 arkoala/ets-plugin/src/DollarDollarTransformer.ts diff --git a/arkoala/arkui-types/index-full.d.ts b/arkoala/arkui-types/index-full.d.ts index a4386b04d..209353a2d 100644 --- a/arkoala/arkui-types/index-full.d.ts +++ b/arkoala/arkui-types/index-full.d.ts @@ -16,6 +16,8 @@ // WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION! +declare function $$ (value: T): T + declare const Component: ClassDecorator & ((options: ComponentOptions) => ClassDecorator); declare const ComponentV2: ClassDecorator & ((options: ComponentOptions) => ClassDecorator); diff --git a/arkoala/ets-plugin/src/ArkExpander.ts b/arkoala/ets-plugin/src/ArkExpander.ts index c5cdf8d6e..4ea4d31c7 100644 --- a/arkoala/ets-plugin/src/ArkExpander.ts +++ b/arkoala/ets-plugin/src/ArkExpander.ts @@ -33,6 +33,7 @@ import { CallTransformer } from './CallTransformer' import { DebugVisitor } from './AbstractVisitor' import { LegacyCallTransformer } from './LegacyCallTransformer' import { AbilityTransformer } from './AbilityTransformer' +import { DollarDollarTransformer } from "./DollarDollarTransformer" import { ObservedResolver } from "./ObservedResolver" interface ArkToKoOptions { @@ -110,67 +111,69 @@ export function arkExpandFile( moduleInfo?: (moduleName: string) => any, applicationInfo?: ApplicationInfo ): ts.SourceFile { - const importer = new Importer(arkuiPackage, moduleInfo) - const nameTable = new NameTable() - const issueTable = new IssueTable() - const callTable = new CallTable() + const importer = new Importer(arkuiPackage, moduleInfo) + const nameTable = new NameTable() + const issueTable = new IssueTable() + const callTable = new CallTable() - /* Uncomment to dump AST on entry */ + /* Uncomment to dump AST on entry */ - // const debug = new DebugVisitor(sourceFile, ctx) - // debug.visitor(sourceFile) + // const debug = new DebugVisitor(sourceFile, ctx) + // debug.visitor(sourceFile) // resolve identifiers automatically imported from index-full.d.ts - new EtsIdentifierResolver(sourceFile, ctx, typeChecker, importer) - .visitor(sourceFile) - - const callTransformer = new CallTransformer(sourceFile, ctx, typeChecker, callTable, importer) - const lazyTransformer = new LazyTransformer(sourceFile, ctx, importer, callTable) - const newTransformer = new NewTransformer(sourceFile, ctx, importer, issueTable) - const customBuilderTransformer = new CustomBuilderTransformer(sourceFile, ctx, typeChecker, callTable) - const legacyCallTransformer = new LegacyCallTransformer(sourceFile, ctx, importer, callTable) - const extensionStylesTransformer = new ExtensionStylesTransformer(sourceFile, ctx, typeChecker, importer) - const preprocessorTransformer = new EtsFirstArgTransformer(sourceFile, ctx, importer, callTable) - const styleTransformer = new StyleTransformer(sourceFile, ctx, typeChecker, importer, extensionStylesTransformer, callTable) - const structTransformer = new StructTransformer(sourceFile, ctx, typeChecker, importer, nameTable, entryTracker, callTable, extras) - const nameCollector = new NameCollector(sourceFile, ctx, nameTable, issueTable) - const dollarTransformer = new DollarTransformer(sourceFile, ctx, nameTable, importer, applicationInfo) - const abilityTransformer = new AbilityTransformer(sourceFile, ctx, importer) - const observedResolver = new ObservedResolver(sourceFile, ctx, importer) - - nameCollector.visitor(sourceFile) - - const translatedCalls = callTransformer.visitor(sourceFile) as ts.SourceFile - const translatedDollar = dollarTransformer.visitor(translatedCalls) as ts.SourceFile - const translatedLazy = lazyTransformer.visitor(translatedDollar) as ts.SourceFile - const translatedNew = newTransformer.visitor(translatedLazy) as ts.SourceFile - const translatedCustomBuilders = customBuilderTransformer.visitor(translatedNew) as ts.SourceFile - const translatedLegacyCalls = legacyCallTransformer.visitor(translatedCustomBuilders) as ts.SourceFile - const translatedStyleFunctions = extensionStylesTransformer.visitor(translatedLegacyCalls) as ts.SourceFile - const preprocessedEts = preprocessorTransformer.visitor(translatedStyleFunctions) as ts.SourceFile - const translatedStyle = styleTransformer.visitor(preprocessedEts) as ts.SourceFile - const translatedStruct = structTransformer.visitor(translatedStyle) as ts.SourceFile - const translatedAbility = abilityTransformer.visitor(translatedStruct) as ts.SourceFile - const resolvedObserved = observedResolver.visitor(translatedAbility) as ts.SourceFile - - const finalStage = resolvedObserved - - filterOutDiagnostics(sourceFile, nameTable, issueTable, extras) - - return ts.factory.updateSourceFile( - finalStage, - [ - ...importer.generate(), - ...finalStage.statements, - // TODO: do we need a better way to obtain it? - // ...structTranslator.entryCode - ], - finalStage.isDeclarationFile, - finalStage.referencedFiles, - finalStage.typeReferenceDirectives, - finalStage.hasNoDefaultLib, - finalStage.libReferenceDirectives - ) + new EtsIdentifierResolver(sourceFile, ctx, typeChecker, importer) + .visitor(sourceFile) + + const dollarDollarTransformer = new DollarDollarTransformer(sourceFile, ctx) + const callTransformer = new CallTransformer(sourceFile, ctx, typeChecker, callTable, importer) + const lazyTransformer = new LazyTransformer(sourceFile, ctx, importer, callTable) + const newTransformer = new NewTransformer(sourceFile, ctx, importer, issueTable) + const customBuilderTransformer = new CustomBuilderTransformer(sourceFile, ctx, typeChecker, callTable) + const legacyCallTransformer = new LegacyCallTransformer(sourceFile, ctx, importer, callTable) + const extensionStylesTransformer = new ExtensionStylesTransformer(sourceFile, ctx, typeChecker, importer) + const preprocessorTransformer = new EtsFirstArgTransformer(sourceFile, ctx, importer, callTable) + const styleTransformer = new StyleTransformer(sourceFile, ctx, typeChecker, importer, extensionStylesTransformer, callTable) + const structTransformer = new StructTransformer(sourceFile, ctx, typeChecker, importer, nameTable, entryTracker, callTable, extras) + const nameCollector = new NameCollector(sourceFile, ctx, nameTable, issueTable) + const dollarTransformer = new DollarTransformer(sourceFile, ctx, nameTable, importer, applicationInfo) + const abilityTransformer = new AbilityTransformer(sourceFile, ctx, importer) + const observedResolver = new ObservedResolver(sourceFile, ctx, importer) + + nameCollector.visitor(sourceFile) + + const translatedDollarDollar = dollarDollarTransformer.visitor(sourceFile) as ts.SourceFile + const translatedCalls = callTransformer.visitor(translatedDollarDollar) as ts.SourceFile + const translatedDollar = dollarTransformer.visitor(translatedCalls) as ts.SourceFile + const translatedLazy = lazyTransformer.visitor(translatedDollar) as ts.SourceFile + const translatedNew = newTransformer.visitor(translatedLazy) as ts.SourceFile + const translatedCustomBuilders = customBuilderTransformer.visitor(translatedNew) as ts.SourceFile + const translatedLegacyCalls = legacyCallTransformer.visitor(translatedCustomBuilders) as ts.SourceFile + const translatedStyleFunctions = extensionStylesTransformer.visitor(translatedLegacyCalls) as ts.SourceFile + const preprocessedEts = preprocessorTransformer.visitor(translatedStyleFunctions) as ts.SourceFile + const translatedStyle = styleTransformer.visitor(preprocessedEts) as ts.SourceFile + const translatedStruct = structTransformer.visitor(translatedStyle) as ts.SourceFile + const translatedAbility = abilityTransformer.visitor(translatedStruct) as ts.SourceFile + const resolvedObserved = observedResolver.visitor(translatedAbility) as ts.SourceFile + + const finalStage = resolvedObserved + + filterOutDiagnostics(sourceFile, nameTable, issueTable, extras) + + return ts.factory.updateSourceFile( + finalStage, + [ + ...importer.generate(), + ...finalStage.statements, + // TODO: do we need a better way to obtain it? + // ...structTranslator.entryCode + ], + finalStage.isDeclarationFile, + finalStage.referencedFiles, + finalStage.typeReferenceDirectives, + finalStage.hasNoDefaultLib, + finalStage.libReferenceDirectives + ) } export default function arkExpander(program: ts.Program, userPluginOptions: ArkToKoOptions, extras: ts.TransformerExtras) { diff --git a/arkoala/ets-plugin/src/CallTransformer.ts b/arkoala/ets-plugin/src/CallTransformer.ts index 78cae77ec..e1a2d6a33 100644 --- a/arkoala/ets-plugin/src/CallTransformer.ts +++ b/arkoala/ets-plugin/src/CallTransformer.ts @@ -91,7 +91,6 @@ export class CallTransformer extends AbstractVisitor { * - it is not user defined */ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression)) { - const func = node.expression const name = ts.idText(func) if (isBuiltinComponentName(this.ctx, name)) { diff --git a/arkoala/ets-plugin/src/DollarDollarTransformer.ts b/arkoala/ets-plugin/src/DollarDollarTransformer.ts new file mode 100644 index 000000000..0dab59884 --- /dev/null +++ b/arkoala/ets-plugin/src/DollarDollarTransformer.ts @@ -0,0 +1,214 @@ +/* + * Copyright (c) 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. + */ + +import * as ts from "@koalaui/ets-tsc" +import { AbstractVisitor } from "./AbstractVisitor" +import { DollarDollar, isDefined } from "./utils" + +abstract class PassType { + protected constructor( + public parameter: string, + public type: ts.KeywordTypeNode + ) {} +} +class ComponentCall extends PassType { + constructor( + parameter: string, + type: ts.KeywordTypeNode, + public readonly component: string, + ) { + super(parameter, type) + } +} +class InitializerObject extends PassType { + constructor( + parameter: string, + type: ts.KeywordTypeNode, + public readonly component: string, + ) { + super(parameter, type) + } +} +function isInitializerObject(value: PassType): value is InitializerObject { + return value instanceof InitializerObject +} +class ComponentMethodCall extends PassType { + constructor( + parameter: string, + type: ts.KeywordTypeNode, + public readonly component: string, + public readonly method: string, + ) { + super(parameter, type) + } +} +class MethodCall extends PassType { + constructor( + parameter: string, + type: ts.KeywordTypeNode, + public readonly method: string, + ) { + super(parameter, type) + } +} + +const knownViablePasses: PassType[] = [ + // new ComponentMethodCall(`value`, `Checkbox`, `select`), + // new ComponentMethodCall(`value`, `CheckboxGroup`, `selectAll`), + // new ComponentMethodCall(`select`, `Checkbox`, `select`), + new InitializerObject(`selected`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `DatePicker`), // TODO: Date + new InitializerObject(`selected`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `TimePicker`), + new InitializerObject(`isOn`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Toggle`), + new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `MenuItem`, `selected`), + new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Select`, `value`), + new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Select`, `selected`), + // new ComponentMethodCall(`value`, `Panel`, `mode`), + // new InitializerObject(`value`, `Search`), + // TODO +] + +type Initialization = { parameter: string, type: ts.KeywordTypeNode, initializer: ts.Expression } + +export class DollarDollarTransformer extends AbstractVisitor { + private static callExpressionName(node: ts.CallExpression | ts.EtsComponentExpression): string | undefined { + if (!ts.isIdentifier(node.expression)) { + return undefined + } + return ts.idText(node.expression) + } + + private static isDollarDollar(node: ts.CallExpression): boolean { + if (!ts.isIdentifier(node.expression)) { + return false + } + return ts.idText(node.expression) === DollarDollar + } + + visitor(node: ts.Node): ts.Node { + node = this.visitEachChild(node) + if (ts.isCallExpression(node)) { + if (DollarDollarTransformer.isEtsComponentCallInside(node)) { + // console.error(node.getText()) + } + } + if (ts.isEtsComponentExpression(node)) { + this.visitEachChild(node) + + const x = DollarDollarTransformer.initializations(node) + if (x.length === 0) return node + + const r = DollarDollarTransformer.addOnChanged(node, x[0]) + return r + } + return node + } + + static addOnChanged(node: ts.EtsComponentExpression | ts.CallExpression, initialization: Initialization): ts.CallExpression { + return ts.factory.createCallExpression( + ts.factory.createPropertyAccessExpression( + node, + `__OnChanged_${initialization.parameter}`, + ), + undefined, + [ + ts.factory.createArrowFunction( + undefined, + undefined, + [ + ts.factory.createParameterDeclaration( + undefined, + undefined, + initialization.parameter, + undefined, + initialization.type + ) + ], + ts.factory.createKeywordTypeNode(ts.SyntaxKind.VoidKeyword), + ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), + ts.factory.createBlock( + [ + ts.factory.createExpressionStatement( + ts.factory.createAssignment( + initialization.initializer, + ts.factory.createIdentifier(initialization.parameter) + ) + ) + ], + false + ) + ) + ] + ) + } + + static initializations(node: ts.EtsComponentExpression): Initialization[] { + const singleArgument = node.arguments[0] + if (singleArgument === undefined) { + return [] + } + if (!ts.isObjectLiteralExpression(singleArgument)) { + return [] + } + + const viablePasses = knownViablePasses + .filter(isInitializerObject) + .filter(it => it.component === DollarDollarTransformer.callExpressionName(node)) + + return singleArgument.properties + .filter(ts.isPropertyAssignment) + .map(it => { + if (!ts.isIdentifier(it.name)) { + return undefined + } + return { + name: ts.idText(it.name), + initializer: it.initializer + } + }) + .filter(isDefined) + .map(initialization => { + const viablePass = viablePasses + .find(it => it.parameter === initialization.name) + if (viablePass === undefined) { + return undefined + } + if (!ts.isCallExpression(initialization.initializer)) { + return undefined + } + if (!DollarDollarTransformer.isDollarDollar(initialization.initializer)) { + return undefined + } + return { + parameter: initialization.name, + type: viablePass.type, + initializer: initialization.initializer.arguments[0] + } + }) + .filter(isDefined) + } + + static isEtsComponentCallInside(node: ts.CallExpression): boolean { + if (!ts.isPropertyAccessExpression(node.expression)) { + return false + } + if (ts.isEtsComponentExpression(node.expression.expression)) { + return true + } + if (!ts.isCallExpression(node.expression.expression)) { + return false + } + return this.isEtsComponentCallInside(node.expression.expression) + } +} diff --git a/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets b/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets index a7df2046d..720005b38 100644 --- a/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets +++ b/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets @@ -11,50 +11,50 @@ struct Index { build() { Column() { Slider({ value: this.n }) - Toggle({ type: ToggleType.Switch, isOn: $$this.b }) + Toggle({ type: ToggleType.Switch, isOn: $$(this.b) }) Stepper({ index: this.n }) Checkbox() - .select($$this.b) + .select($$(this.b)) CheckboxGroup() - .selectAll($$this.b) - DatePicker({ selected: $$this.d }) - TimePicker({ selected: $$this.d }) + .selectAll($$(this.b)) + DatePicker({ selected: $$(this.d) }) + TimePicker({ selected: $$(this.d) }) MenuItem() - .selected($$this.b) + .selected($$(this.b)) Panel(false) - .mode($$this.m) + .mode($$(this.m)) Radio({group: "", value: ""}) - .checked($$this.b) - Search({ value: $$this.s }) + .checked($$(this.b)) + Search({ value: $$(this.s) }) SideBarContainer(SideBarContainerType.Embed) - .showSideBar($$this.b) + .showSideBar($$(this.b)) Swiper() - .index($$this.n) - Tabs({ index: $$this.n }) - TextInput({ text: $$this.s }) - TextArea({ text: $$this.s }) - TextInput({ text: $$this.s }) - Toggle({ type: ToggleType.Checkbox, isOn: $$this.b }) - AlphabetIndexer({arrayValue: [], selected: $$this.n }) - Refresh({ refreshing: $$this.b }) - TextPicker({ range: [], value: $$this.s, selected: $$this.n }) + .index($$(this.n)) + Tabs({ index: $$(this.n) }) + TextInput({ text: $$(this.s) }) + TextArea({ text: $$(this.s) }) + TextInput({ text: $$(this.s) }) + Toggle({ type: ToggleType.Checkbox, isOn: $$(this.b) }) + AlphabetIndexer({arrayValue: [], selected: $$(this.n) }) + Refresh({ refreshing: $$(this.b) }) + TextPicker({ range: [], value: $$(this.s), selected: $$(this.n) }) Select([]) - .value($$this.s) - .selected($$this.n) + .value($$(this.s)) + .selected($$(this.n)) List() { ListItemGroup() { ListItem({ style: this.l }) - .selected($$this.b) + .selected($$(this.b)) } } Grid() { GridItem({}) - .selected($$this.b) + .selected($$(this.b)) } Button() - .bindSheet($$this.b, builder) - .bindContentCover($$this.b, builder) + .bindSheet($$(this.b), builder) + .bindContentCover($$(this.b), builder) } } } -- Gitee From 6cab362272e0f089abe5c686d15f635e8c8a4bd7 Mon Sep 17 00:00:00 2001 From: naumovdmitrii Date: Wed, 12 Feb 2025 14:53:13 +0300 Subject: [PATCH 3/6] wip Signed-off-by: naumovdmitrii --- .../ets-plugin/src/DollarDollarTransformer.ts | 115 ++++++++++++------ 1 file changed, 80 insertions(+), 35 deletions(-) diff --git a/arkoala/ets-plugin/src/DollarDollarTransformer.ts b/arkoala/ets-plugin/src/DollarDollarTransformer.ts index 0dab59884..3175a8632 100644 --- a/arkoala/ets-plugin/src/DollarDollarTransformer.ts +++ b/arkoala/ets-plugin/src/DollarDollarTransformer.ts @@ -20,22 +20,13 @@ import { DollarDollar, isDefined } from "./utils" abstract class PassType { protected constructor( public parameter: string, - public type: ts.KeywordTypeNode + public type: ts.TypeNode ) {} } -class ComponentCall extends PassType { - constructor( - parameter: string, - type: ts.KeywordTypeNode, - public readonly component: string, - ) { - super(parameter, type) - } -} class InitializerObject extends PassType { constructor( parameter: string, - type: ts.KeywordTypeNode, + type: ts.TypeNode, public readonly component: string, ) { super(parameter, type) @@ -47,17 +38,20 @@ function isInitializerObject(value: PassType): value is InitializerObject { class ComponentMethodCall extends PassType { constructor( parameter: string, - type: ts.KeywordTypeNode, + type: ts.TypeNode, public readonly component: string, public readonly method: string, ) { super(parameter, type) } } +function isComponentMethodCall(value: PassType): value is ComponentMethodCall { + return value instanceof ComponentMethodCall +} class MethodCall extends PassType { constructor( parameter: string, - type: ts.KeywordTypeNode, + type: ts.TypeNode, public readonly method: string, ) { super(parameter, type) @@ -65,11 +59,10 @@ class MethodCall extends PassType { } const knownViablePasses: PassType[] = [ - // new ComponentMethodCall(`value`, `Checkbox`, `select`), - // new ComponentMethodCall(`value`, `CheckboxGroup`, `selectAll`), - // new ComponentMethodCall(`select`, `Checkbox`, `select`), - new InitializerObject(`selected`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `DatePicker`), // TODO: Date - new InitializerObject(`selected`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `TimePicker`), + new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Checkbox`, `select`), + new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `CheckboxGroup`, `selectAll`), + new InitializerObject(`selected`, ts.factory.createTypeReferenceNode(`Date`), `DatePicker`), + new InitializerObject(`selected`, ts.factory.createTypeReferenceNode(`Date`), `TimePicker`), new InitializerObject(`isOn`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Toggle`), new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `MenuItem`, `selected`), new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Select`, `value`), @@ -79,7 +72,7 @@ const knownViablePasses: PassType[] = [ // TODO ] -type Initialization = { parameter: string, type: ts.KeywordTypeNode, initializer: ts.Expression } +type Initialization = { parameter: string, type: ts.TypeNode, initializer: ts.Expression } export class DollarDollarTransformer extends AbstractVisitor { private static callExpressionName(node: ts.CallExpression | ts.EtsComponentExpression): string | undefined { @@ -93,24 +86,42 @@ export class DollarDollarTransformer extends AbstractVisitor { if (!ts.isIdentifier(node.expression)) { return false } - return ts.idText(node.expression) === DollarDollar + if (node.arguments.length !== 1) { + return false + } + if (ts.idText(node.expression) !== DollarDollar) { + return false + } + return true } visitor(node: ts.Node): ts.Node { node = this.visitEachChild(node) if (ts.isCallExpression(node)) { - if (DollarDollarTransformer.isEtsComponentCallInside(node)) { - // console.error(node.getText()) + const initializations = DollarDollarTransformer.componentMethodCallInitializations(node) + if (initializations.length > 0) { + return initializations + .map(it => + (node: ts.EtsComponentExpression | ts.CallExpression) => + DollarDollarTransformer.addOnChanged(node, it) + ) + .reduce( + (addTo, add) => add(addTo), + node + ) } + } if (ts.isEtsComponentExpression(node)) { - this.visitEachChild(node) - - const x = DollarDollarTransformer.initializations(node) - if (x.length === 0) return node - - const r = DollarDollarTransformer.addOnChanged(node, x[0]) - return r + return DollarDollarTransformer.componentCallInitializations(node) + .map(it => + (node: ts.EtsComponentExpression | ts.CallExpression) => + DollarDollarTransformer.addOnChanged(node, it) + ) + .reduce( + (addTo, add) => add(addTo), + node as ts.EtsComponentExpression | ts.CallExpression + ) } return node } @@ -153,7 +164,7 @@ export class DollarDollarTransformer extends AbstractVisitor { ) } - static initializations(node: ts.EtsComponentExpression): Initialization[] { + static componentCallInitializations(node: ts.EtsComponentExpression): Initialization[] { const singleArgument = node.arguments[0] if (singleArgument === undefined) { return [] @@ -199,16 +210,50 @@ export class DollarDollarTransformer extends AbstractVisitor { .filter(isDefined) } - static isEtsComponentCallInside(node: ts.CallExpression): boolean { + static componentMethodCallInitializations(node: ts.CallExpression, collected: Initialization[] = []): Initialization[] { + if (collected.length !== 0) throw new Error(`YOO`) + if (ts.isIdentifier(node.expression)) { + console.error(`looking at ${ts.idText(node.expression)}`) + } if (!ts.isPropertyAccessExpression(node.expression)) { - return false + return [] } if (ts.isEtsComponentExpression(node.expression.expression)) { - return true + return collected } if (!ts.isCallExpression(node.expression.expression)) { - return false + return [] + } + return this.componentMethodCallInitializations( + node.expression.expression, + collected.concat( + DollarDollarTransformer.callInitializations(node) + ) + ) + } + + static callInitializations(node: ts.CallExpression): Initialization[] { + if (!ts.isIdentifier(node.expression)) { + return [] + } + const firstArgument = node.arguments[0] + if (firstArgument === undefined) { + return [] + } + if (!ts.isCallExpression(firstArgument)) { + return [] + } + if (!DollarDollarTransformer.isDollarDollar(firstArgument)) { + return [] } - return this.isEtsComponentCallInside(node.expression.expression) + const method = ts.idText(node.expression) + return knownViablePasses + .filter(isComponentMethodCall) // TODO: bindSheet too + .filter(it => it.method === method) + .map(it => ({ + parameter: it.parameter, + type: it.type, + initializer: firstArgument.arguments[0] + })) } } -- Gitee From a4b433fbd462bcd91aa70f751cf0ce894a9b5d9c Mon Sep 17 00:00:00 2001 From: naumovdmitrii Date: Thu, 13 Feb 2025 10:55:25 +0300 Subject: [PATCH 4/6] support for Toggle, Search Signed-off-by: naumovdmitrii --- .../ets-plugin/src/DollarDollarTransformer.ts | 85 +++---------------- .../dollar-dollar-viable-passes.ts | 77 +++++++++++++++++ 2 files changed, 87 insertions(+), 75 deletions(-) create mode 100644 arkoala/ets-plugin/src/arkui-knowledge-base/dollar-dollar-viable-passes.ts diff --git a/arkoala/ets-plugin/src/DollarDollarTransformer.ts b/arkoala/ets-plugin/src/DollarDollarTransformer.ts index 3175a8632..1890c27a4 100644 --- a/arkoala/ets-plugin/src/DollarDollarTransformer.ts +++ b/arkoala/ets-plugin/src/DollarDollarTransformer.ts @@ -16,61 +16,11 @@ import * as ts from "@koalaui/ets-tsc" import { AbstractVisitor } from "./AbstractVisitor" import { DollarDollar, isDefined } from "./utils" - -abstract class PassType { - protected constructor( - public parameter: string, - public type: ts.TypeNode - ) {} -} -class InitializerObject extends PassType { - constructor( - parameter: string, - type: ts.TypeNode, - public readonly component: string, - ) { - super(parameter, type) - } -} -function isInitializerObject(value: PassType): value is InitializerObject { - return value instanceof InitializerObject -} -class ComponentMethodCall extends PassType { - constructor( - parameter: string, - type: ts.TypeNode, - public readonly component: string, - public readonly method: string, - ) { - super(parameter, type) - } -} -function isComponentMethodCall(value: PassType): value is ComponentMethodCall { - return value instanceof ComponentMethodCall -} -class MethodCall extends PassType { - constructor( - parameter: string, - type: ts.TypeNode, - public readonly method: string, - ) { - super(parameter, type) - } -} - -const knownViablePasses: PassType[] = [ - new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Checkbox`, `select`), - new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `CheckboxGroup`, `selectAll`), - new InitializerObject(`selected`, ts.factory.createTypeReferenceNode(`Date`), `DatePicker`), - new InitializerObject(`selected`, ts.factory.createTypeReferenceNode(`Date`), `TimePicker`), - new InitializerObject(`isOn`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Toggle`), - new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `MenuItem`, `selected`), - new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Select`, `value`), - new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Select`, `selected`), - // new ComponentMethodCall(`value`, `Panel`, `mode`), - // new InitializerObject(`value`, `Search`), - // TODO -] +import { + isComponentMethodCall, + isInitializerObject, + dollarDollarViablePasses +} from "./arkui-knowledge-base/dollar-dollar-viable-passes" type Initialization = { parameter: string, type: ts.TypeNode, initializer: ts.Expression } @@ -95,22 +45,11 @@ export class DollarDollarTransformer extends AbstractVisitor { return true } - visitor(node: ts.Node): ts.Node { - node = this.visitEachChild(node) + visitor(beforeChildren: ts.Node): ts.Node { + const node = this.visitEachChild(beforeChildren) if (ts.isCallExpression(node)) { const initializations = DollarDollarTransformer.componentMethodCallInitializations(node) - if (initializations.length > 0) { - return initializations - .map(it => - (node: ts.EtsComponentExpression | ts.CallExpression) => - DollarDollarTransformer.addOnChanged(node, it) - ) - .reduce( - (addTo, add) => add(addTo), - node - ) - } - + // TODO } if (ts.isEtsComponentExpression(node)) { return DollarDollarTransformer.componentCallInitializations(node) @@ -173,7 +112,7 @@ export class DollarDollarTransformer extends AbstractVisitor { return [] } - const viablePasses = knownViablePasses + const viablePasses = dollarDollarViablePasses .filter(isInitializerObject) .filter(it => it.component === DollarDollarTransformer.callExpressionName(node)) @@ -211,10 +150,6 @@ export class DollarDollarTransformer extends AbstractVisitor { } static componentMethodCallInitializations(node: ts.CallExpression, collected: Initialization[] = []): Initialization[] { - if (collected.length !== 0) throw new Error(`YOO`) - if (ts.isIdentifier(node.expression)) { - console.error(`looking at ${ts.idText(node.expression)}`) - } if (!ts.isPropertyAccessExpression(node.expression)) { return [] } @@ -247,7 +182,7 @@ export class DollarDollarTransformer extends AbstractVisitor { return [] } const method = ts.idText(node.expression) - return knownViablePasses + return dollarDollarViablePasses .filter(isComponentMethodCall) // TODO: bindSheet too .filter(it => it.method === method) .map(it => ({ diff --git a/arkoala/ets-plugin/src/arkui-knowledge-base/dollar-dollar-viable-passes.ts b/arkoala/ets-plugin/src/arkui-knowledge-base/dollar-dollar-viable-passes.ts new file mode 100644 index 000000000..f7857f0eb --- /dev/null +++ b/arkoala/ets-plugin/src/arkui-knowledge-base/dollar-dollar-viable-passes.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 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. + */ + +import * as ts from "@koalaui/ets-tsc" + +abstract class PassType { + protected constructor( + public parameter: string, + public type: ts.TypeNode + ) {} +} + +class InitializerObject extends PassType { + constructor( + parameter: string, + type: ts.TypeNode, + public readonly component: string, + ) { + super(parameter, type) + } +} + +class ComponentMethodCall extends PassType { + constructor( + parameter: string, + type: ts.TypeNode, + public readonly component: string, + public readonly method: string, + ) { + super(parameter, type) + } +} + +class MethodCall extends PassType { + constructor( + parameter: string, + type: ts.TypeNode, + public readonly method: string, + ) { + super(parameter, type) + } +} + +export function isInitializerObject(value: PassType): value is InitializerObject { + return value instanceof InitializerObject +} + +export function isComponentMethodCall(value: PassType): value is ComponentMethodCall { + return value instanceof ComponentMethodCall +} + +export const dollarDollarViablePasses: PassType[] = [ + new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Checkbox`, `select`), + new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `CheckboxGroup`, `selectAll`), + new InitializerObject(`selected`, ts.factory.createTypeReferenceNode(`Date`), `DatePicker`), + new InitializerObject(`selected`, ts.factory.createTypeReferenceNode(`Date`), `TimePicker`), + new InitializerObject(`isOn`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Toggle`), + new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `MenuItem`, `selected`), + new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Select`, `value`), + new ComponentMethodCall(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.BooleanKeyword), `Select`, `selected`), + new InitializerObject(`value`, ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), `Search`), + // new ComponentMethodCall(`value`, `Panel`, `mode`), + // new InitializerObject(`value`, `Search`), + // TODO +] -- Gitee From 2bb80437aea5fb5827e9edc877ced9ab54398947 Mon Sep 17 00:00:00 2001 From: naumovdmitrii Date: Thu, 13 Feb 2025 13:20:10 +0300 Subject: [PATCH 5/6] golden Signed-off-by: naumovdmitrii --- .../arkoala/ets/dollar-dollar/components.ts | 169 +++++++++++++++++ .../arkts/ets/dollar-dollar/components.ts | 169 +++++++++++++++++ .../koala/ets/dollar-dollar/components.ts | 171 ++++++++++++++++++ 3 files changed, 509 insertions(+) create mode 100644 arkoala/ets-plugin/test/golden/arkoala/ets/dollar-dollar/components.ts create mode 100644 arkoala/ets-plugin/test/golden/arkts/ets/dollar-dollar/components.ts create mode 100644 arkoala/ets-plugin/test/golden/koala/ets/dollar-dollar/components.ts diff --git a/arkoala/ets-plugin/test/golden/arkoala/ets/dollar-dollar/components.ts b/arkoala/ets-plugin/test/golden/arkoala/ets/dollar-dollar/components.ts new file mode 100644 index 000000000..45b956f09 --- /dev/null +++ b/arkoala/ets-plugin/test/golden/arkoala/ets/dollar-dollar/components.ts @@ -0,0 +1,169 @@ +import { $$, ArkAlphabetIndexer, ArkButton, ArkButtonComponent, ArkCheckbox, ArkCheckboxComponent, ArkCheckboxGroup, ArkCheckboxGroupComponent, ArkColumn, ArkCommonMethodComponent, ArkDatePicker, ArkDatePickerComponent, ArkGrid, ArkGridItem, ArkGridItemComponent, ArkList, ArkListItem, ArkListItemComponent, ArkListItemGroup, ArkMenuItem, ArkMenuItemComponent, ArkPageTransitionEnterComponent, ArkPageTransitionExitComponent, ArkPanel, ArkPanelComponent, ArkRadio, ArkRadioComponent, ArkRefresh, ArkSearch, ArkSearchComponent, ArkSelect, ArkSelectComponent, ArkSideBarContainer, ArkSideBarContainerComponent, ArkSlider, ArkStepper, ArkStructBase, ArkSwiper, ArkSwiperComponent, ArkTabs, ArkText, ArkTextArea, ArkTextInput, ArkTextPicker, ArkTimePicker, ArkTimePickerComponent, ArkToggle, ArkToggleComponent, ListItemStyle, LocalStorage, MutableState, PanelMode, SideBarContainerType, ToggleType, contextLocalStateOf, observableProxy, stateOf } from "@koalaui/arkoala-arkui"; +import { registerArkuiEntry } from "@koalaui/arkoala-arkui/ohos.router"; +class ArkIndexComponent extends ArkStructBase { + private _entry_local_storage_ = new LocalStorage(); + __initializeStruct(/**/ + /** @memo */ + content?: () => void, initializers?: IndexOptions): void { + this.__backing_n = stateOf(initializers?.n ?? (0.5), this); + this.__backing_s = stateOf(initializers?.s ?? ("0.5"), this); + this.__backing_b = stateOf(initializers?.b ?? (true), this); + this.__backing_d = stateOf(initializers?.d ?? (new Date('2021-08-08')), this); + this.__backing_m = stateOf(initializers?.m ?? (PanelMode.Mini), this); + this.__backing_l = stateOf(initializers?.l ?? (ListItemStyle.NONE), this); + } + private __backing_n?: MutableState; + private get n(): number { + return this.__backing_n!.value; + } + private set n(value: number) { + this.__backing_n!.value = observableProxy(value); + } + private __backing_s?: MutableState; + private get s(): string { + return this.__backing_s!.value; + } + private set s(value: string) { + this.__backing_s!.value = observableProxy(value); + } + private __backing_b?: MutableState; + private get b(): boolean { + return this.__backing_b!.value; + } + private set b(value: boolean) { + this.__backing_b!.value = observableProxy(value); + } + private __backing_d?: MutableState; + private get d(): Date { + return this.__backing_d!.value; + } + private set d(value: Date) { + this.__backing_d!.value = observableProxy(value); + } + private __backing_m?: MutableState; + private get m(): PanelMode { + return this.__backing_m!.value; + } + private set m(value: PanelMode) { + this.__backing_m!.value = observableProxy(value); + } + private __backing_l?: MutableState; + private get l(): ListItemStyle { + return this.__backing_l!.value; + } + private set l(value: ListItemStyle) { + this.__backing_l!.value = observableProxy(value); + } + /** @memo */ + __build(/**/ + /** @memo */ + __builder: ((__instance: ArkCommonMethodComponent) => void) | undefined, /**/ + /** @memo */ + content?: () => void, initializers?: IndexOptions) { + ArkColumn(__builder, () => { + ArkSlider(undefined, undefined, { value: this.n }); + ArkToggle((__instance: ArkToggleComponent) => { + __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); + }, undefined, { type: ToggleType.Switch, isOn: $$(this.b) }); + ArkStepper(undefined, undefined, { index: this.n }); + ArkCheckbox((__instance: ArkCheckboxComponent) => { + __instance.select($$(this.b)); + }, undefined); + ArkCheckboxGroup((__instance: ArkCheckboxGroupComponent) => { + __instance.selectAll($$(this.b)); + }, undefined); + ArkDatePicker((__instance: ArkDatePickerComponent) => { + __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); + }, undefined, { selected: $$(this.d) }); + ArkTimePicker((__instance: ArkTimePickerComponent) => { + __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); + }, undefined, { selected: $$(this.d) }); + ArkMenuItem((__instance: ArkMenuItemComponent) => { + __instance.selected($$(this.b)); + }, undefined); + ArkPanel((__instance: ArkPanelComponent) => { + __instance.mode($$(this.m)); + }, undefined, false); + ArkRadio((__instance: ArkRadioComponent) => { + __instance.checked($$(this.b)); + }, undefined, { group: "", value: "" }); + ArkSearch((__instance: ArkSearchComponent) => { + __instance.__OnChanged_value((value: string): void => { this.s = value; }); + }, undefined, { value: $$(this.s) }); + ArkSideBarContainer((__instance: ArkSideBarContainerComponent) => { + __instance.showSideBar($$(this.b)); + }, undefined, SideBarContainerType.Embed); + ArkSwiper((__instance: ArkSwiperComponent) => { + __instance.index($$(this.n)); + }, undefined); + ArkTabs(undefined, undefined, { index: $$(this.n) }); + ArkTextInput(undefined, undefined, { text: $$(this.s) }); + ArkTextArea(undefined, undefined, { text: $$(this.s) }); + ArkTextInput(undefined, undefined, { text: $$(this.s) }); + ArkToggle((__instance: ArkToggleComponent) => { + __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); + }, undefined, { type: ToggleType.Checkbox, isOn: $$(this.b) }); + ArkAlphabetIndexer(undefined, undefined, { arrayValue: [], selected: $$(this.n) }); + ArkRefresh(undefined, undefined, { refreshing: $$(this.b) }); + ArkTextPicker(undefined, undefined, { range: [], value: $$(this.s), selected: $$(this.n) }); + ArkSelect((__instance: ArkSelectComponent) => { + __instance.value($$(this.s)) + .selected($$(this.n)); + }, undefined, []); + ArkList(undefined, () => { + ArkListItemGroup(undefined, () => { + ArkListItem((__instance: ArkListItemComponent) => { + __instance.selected($$(this.b)); + }, undefined, { style: this.l }); + }); + }); + ArkGrid(undefined, () => { + ArkGridItem((__instance: ArkGridItemComponent) => { + __instance.selected($$(this.b)); + }, undefined, {}); + }); + ArkButton((__instance: ArkButtonComponent) => { + __instance.bindSheet($$(this.b), builder) + .bindContentCover($$(this.b), builder); + }, undefined); + }); + } +} +/** @memo */ +function builder() { + ArkText(undefined, undefined); +} +/** @memo */ +export function Index(/**/ +/** @memo */ +style?: (__instance: ArkCommonMethodComponent) => void, /**/ +/** @memo */ +content?: () => void, initializers?: IndexOptions): void { + contextLocalStateOf("contextLocalMapOfRadioGroups", () => new Map()); + contextLocalStateOf("contextLocalMapOfCheckboxGroups", () => new Map()); + const updatedInitializers: IndexOptions = { + __backing_n: initializers?.__backing_n, + __backing_s: initializers?.__backing_s, + __backing_b: initializers?.__backing_b, + __backing_d: initializers?.__backing_d, + __backing_m: initializers?.__backing_m, + __backing_l: initializers?.__backing_l + }; + ArkIndexComponent._instantiate(style, () => new ArkIndexComponent, content, updatedInitializers); +} +export interface IndexOptions { + __backing_n?: MutableState; + n?: number; + __backing_s?: MutableState; + s?: string; + __backing_b?: MutableState; + b?: boolean; + __backing_d?: MutableState; + d?: Date; + __backing_m?: MutableState; + m?: PanelMode; + __backing_l?: MutableState; + l?: ListItemStyle; +} +registerArkuiEntry(Index, "dollar-dollar/components"); +export const __Entry = Index; diff --git a/arkoala/ets-plugin/test/golden/arkts/ets/dollar-dollar/components.ts b/arkoala/ets-plugin/test/golden/arkts/ets/dollar-dollar/components.ts new file mode 100644 index 000000000..c3df14913 --- /dev/null +++ b/arkoala/ets-plugin/test/golden/arkts/ets/dollar-dollar/components.ts @@ -0,0 +1,169 @@ +import { $$, AlphabetIndexerOptions, ArkAlphabetIndexer, ArkButton, ArkButtonComponent, ArkCheckbox, ArkCheckboxComponent, ArkCheckboxGroup, ArkCheckboxGroupComponent, ArkColumn, ArkCommonMethodComponent, ArkDatePicker, ArkDatePickerComponent, ArkGrid, ArkGridItem, ArkGridItemComponent, ArkList, ArkListItem, ArkListItemComponent, ArkListItemGroup, ArkMenuItem, ArkMenuItemComponent, ArkPageTransitionEnterComponent, ArkPageTransitionExitComponent, ArkPanel, ArkPanelComponent, ArkRadio, ArkRadioComponent, ArkRefresh, ArkSearch, ArkSearchComponent, ArkSelect, ArkSelectComponent, ArkSideBarContainer, ArkSideBarContainerComponent, ArkSlider, ArkStepper, ArkStructBase, ArkSwiper, ArkSwiperComponent, ArkTabs, ArkText, ArkTextArea, ArkTextInput, ArkTextPicker, ArkTimePicker, ArkTimePickerComponent, ArkToggle, ArkToggleComponent, DatePickerOptions, GridItemOptions, ListItemOptions, ListItemStyle, PanelMode, RadioOptions, RefreshOptions, SearchOptions, SideBarContainerType, SliderOptions, StepperOptions, TabsOptions, TextAreaOptions, TextInputOptions, TextPickerOptions, TimePickerOptions, ToggleOptions, ToggleType, contextLocalStateOf, stateOf } from "@koalaui/arkts-arkui"; +import { MutableState } from "@koalaui/runtime"; +import { LocalStorage } from "@koalaui/arkui-common"; +import { observableProxy } from "@koalaui/common"; +class ArkIndexComponent extends ArkStructBase { + private _entry_local_storage_ = new LocalStorage(); + __initializeStruct(/**/ + /** @memo */ + content?: () => void, initializers?: IndexOptions): void { + this.__backing_n = stateOf(initializers?.n ?? (0.5), this); + this.__backing_s = stateOf(initializers?.s ?? ("0.5"), this); + this.__backing_b = stateOf(initializers?.b ?? (true), this); + this.__backing_d = stateOf(initializers?.d ?? (new Date('2021-08-08')), this); + this.__backing_m = stateOf(initializers?.m ?? (PanelMode.Mini), this); + this.__backing_l = stateOf(initializers?.l ?? (ListItemStyle.NONE), this); + } + private __backing_n?: MutableState; + private get n(): number { + return this.__backing_n!.value; + } + private set n(value: number) { + this.__backing_n!.value = observableProxy(value); + } + private __backing_s?: MutableState; + private get s(): string { + return this.__backing_s!.value; + } + private set s(value: string) { + this.__backing_s!.value = observableProxy(value); + } + private __backing_b?: MutableState; + private get b(): boolean { + return this.__backing_b!.value; + } + private set b(value: boolean) { + this.__backing_b!.value = observableProxy(value); + } + private __backing_d?: MutableState; + private get d(): Date { + return this.__backing_d!.value; + } + private set d(value: Date) { + this.__backing_d!.value = observableProxy(value); + } + private __backing_m?: MutableState; + private get m(): PanelMode { + return this.__backing_m!.value; + } + private set m(value: PanelMode) { + this.__backing_m!.value = observableProxy(value); + } + private __backing_l?: MutableState; + private get l(): ListItemStyle { + return this.__backing_l!.value; + } + private set l(value: ListItemStyle) { + this.__backing_l!.value = observableProxy(value); + } + /** @memo */ + __build(/**/ + /** @memo */ + __builder: ((__instance: ArkCommonMethodComponent) => void) | undefined, /**/ + /** @memo */ + content?: () => void, initializers?: IndexOptions) { + ArkColumn(__builder, () => { + ArkSlider(undefined, undefined, { value: this.n } as SliderOptions); + ArkToggle((__instance: ArkToggleComponent) => { + __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); + }, undefined, { type: ToggleType.Switch, isOn: $$(this.b) } as ToggleOptions); + ArkStepper(undefined, undefined, { index: this.n } as StepperOptions); + ArkCheckbox((__instance: ArkCheckboxComponent) => { + __instance.select($$(this.b)); + }, undefined); + ArkCheckboxGroup((__instance: ArkCheckboxGroupComponent) => { + __instance.selectAll($$(this.b)); + }, undefined); + ArkDatePicker((__instance: ArkDatePickerComponent) => { + __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); + }, undefined, { selected: $$(this.d) } as DatePickerOptions); + ArkTimePicker((__instance: ArkTimePickerComponent) => { + __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); + }, undefined, { selected: $$(this.d) } as TimePickerOptions); + ArkMenuItem((__instance: ArkMenuItemComponent) => { + __instance.selected($$(this.b)); + }, undefined); + ArkPanel((__instance: ArkPanelComponent) => { + __instance.mode($$(this.m)); + }, undefined, false); + ArkRadio((__instance: ArkRadioComponent) => { + __instance.checked($$(this.b)); + }, undefined, { group: "", value: "" } as RadioOptions); + ArkSearch((__instance: ArkSearchComponent) => { + __instance.__OnChanged_value((value: string): void => { this.s = value; }); + }, undefined, { value: $$(this.s) } as SearchOptions); + ArkSideBarContainer((__instance: ArkSideBarContainerComponent) => { + __instance.showSideBar($$(this.b)); + }, undefined, SideBarContainerType.Embed); + ArkSwiper((__instance: ArkSwiperComponent) => { + __instance.index($$(this.n)); + }, undefined); + ArkTabs(undefined, undefined, { index: $$(this.n) } as TabsOptions); + ArkTextInput(undefined, undefined, { text: $$(this.s) } as TextInputOptions); + ArkTextArea(undefined, undefined, { text: $$(this.s) } as TextAreaOptions); + ArkTextInput(undefined, undefined, { text: $$(this.s) } as TextInputOptions); + ArkToggle((__instance: ArkToggleComponent) => { + __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); + }, undefined, { type: ToggleType.Checkbox, isOn: $$(this.b) } as ToggleOptions); + ArkAlphabetIndexer(undefined, undefined, { arrayValue: [], selected: $$(this.n) } as AlphabetIndexerOptions); + ArkRefresh(undefined, undefined, { refreshing: $$(this.b) } as RefreshOptions); + ArkTextPicker(undefined, undefined, { range: [], value: $$(this.s), selected: $$(this.n) } as TextPickerOptions); + ArkSelect((__instance: ArkSelectComponent) => { + __instance.value($$(this.s)) + .selected($$(this.n)); + }, undefined, []); + ArkList(undefined, () => { + ArkListItemGroup(undefined, () => { + ArkListItem((__instance: ArkListItemComponent) => { + __instance.selected($$(this.b)); + }, undefined, { style: this.l } as ListItemOptions); + }); + }); + ArkGrid(undefined, () => { + ArkGridItem((__instance: ArkGridItemComponent) => { + __instance.selected($$(this.b)); + }, undefined, {} as GridItemOptions); + }); + ArkButton((__instance: ArkButtonComponent) => { + __instance.bindSheet($$(this.b), builder) + .bindContentCover($$(this.b), builder); + }, undefined); + }); + } +} +/** @memo */ +function builder() { + ArkText(undefined, undefined); +} +/** @memo */ +export function Index(/**/ +/** @memo */ +style?: (__instance: ArkCommonMethodComponent) => void, /**/ +/** @memo */ +content?: () => void, initializers?: IndexOptions): void { + contextLocalStateOf("contextLocalMapOfRadioGroups", () => new Map()); + contextLocalStateOf("contextLocalMapOfCheckboxGroups", () => new Map()); + const updatedInitializers: IndexOptions = { + __backing_n: initializers?.__backing_n, + __backing_s: initializers?.__backing_s, + __backing_b: initializers?.__backing_b, + __backing_d: initializers?.__backing_d, + __backing_m: initializers?.__backing_m, + __backing_l: initializers?.__backing_l + }; + ArkIndexComponent._instantiate(style, () => new ArkIndexComponent, content, updatedInitializers); +} +export interface IndexOptions { + __backing_n?: MutableState; + n?: number; + __backing_s?: MutableState; + s?: string; + __backing_b?: MutableState; + b?: boolean; + __backing_d?: MutableState; + d?: Date; + __backing_m?: MutableState; + m?: PanelMode; + __backing_l?: MutableState; + l?: ListItemStyle; +} diff --git a/arkoala/ets-plugin/test/golden/koala/ets/dollar-dollar/components.ts b/arkoala/ets-plugin/test/golden/koala/ets/dollar-dollar/components.ts new file mode 100644 index 000000000..73cdb7868 --- /dev/null +++ b/arkoala/ets-plugin/test/golden/koala/ets/dollar-dollar/components.ts @@ -0,0 +1,171 @@ +import { $$, $r, $rawfile, AppStorage, ArkAlphabetIndexer, ArkButton, ArkButtonComponent, ArkCheckbox, ArkCheckboxComponent, ArkCheckboxGroup, ArkCheckboxGroupComponent, ArkColumn, ArkCommonMethodComponent, ArkDatePicker, ArkDatePickerComponent, ArkGrid, ArkGridItem, ArkGridItemComponent, ArkList, ArkListItem, ArkListItemComponent, ArkListItemGroup, ArkMenuItem, ArkMenuItemComponent, ArkPageTransitionEnterComponent, ArkPageTransitionExitComponent, ArkPanel, ArkPanelComponent, ArkRadio, ArkRadioComponent, ArkRefresh, ArkSearch, ArkSearchComponent, ArkSelect, ArkSelectComponent, ArkSideBarContainer, ArkSideBarContainerComponent, ArkSlider, ArkStepper, ArkStructBase, ArkSwiper, ArkSwiperComponent, ArkTabs, ArkText, ArkTextArea, ArkTextInput, ArkTextPicker, ArkTimePicker, ArkTimePickerComponent, ArkToggle, ArkToggleComponent, CanvasRenderingContext2D, CustomDialogController, DataChangeListener, Environment, ForEach, GestureGroup, IDataSource, ListItemStyle, LocalStorage, LongPressGesture, PanGesture, PanGestureOptions, PanelMode, PersistentStorage, PinchGesture, RenderingContextSettings, RotationGesture, Scroller, SideBarContainerType, SubscribedAbstractProperty, SwipeGesture, SwiperController, TabsController, TapGesture, TextAreaController, ToggleType, VideoController, animateTo, contextLocalStateOf, fp2px, getContext, getInspectorByKey, lpx2px, px2fp, px2lpx, px2vp, stateOf, vp2px } from "@koalaui/arkui"; +import { MutableState } from "@koalaui/runtime"; +import { registerArkuiEntry } from "@koalaui/arkui/ohos.router"; +import { observableProxy } from "@koalaui/common"; +class ArkIndexComponent extends ArkStructBase { + private _entry_local_storage_ = new LocalStorage(); + __initializeStruct(/**/ + /** @memo */ + content?: () => void, initializers?: IndexOptions): void { + this.__backing_n = stateOf(initializers?.n ?? (0.5), this); + this.__backing_s = stateOf(initializers?.s ?? ("0.5"), this); + this.__backing_b = stateOf(initializers?.b ?? (true), this); + this.__backing_d = stateOf(initializers?.d ?? (new Date('2021-08-08')), this); + this.__backing_m = stateOf(initializers?.m ?? (PanelMode.Mini), this); + this.__backing_l = stateOf(initializers?.l ?? (ListItemStyle.NONE), this); + } + private __backing_n?: MutableState; + private get n(): number { + return this.__backing_n!.value; + } + private set n(value: number) { + this.__backing_n!.value = observableProxy(value); + } + private __backing_s?: MutableState; + private get s(): string { + return this.__backing_s!.value; + } + private set s(value: string) { + this.__backing_s!.value = observableProxy(value); + } + private __backing_b?: MutableState; + private get b(): boolean { + return this.__backing_b!.value; + } + private set b(value: boolean) { + this.__backing_b!.value = observableProxy(value); + } + private __backing_d?: MutableState; + private get d(): Date { + return this.__backing_d!.value; + } + private set d(value: Date) { + this.__backing_d!.value = observableProxy(value); + } + private __backing_m?: MutableState; + private get m(): PanelMode { + return this.__backing_m!.value; + } + private set m(value: PanelMode) { + this.__backing_m!.value = observableProxy(value); + } + private __backing_l?: MutableState; + private get l(): ListItemStyle { + return this.__backing_l!.value; + } + private set l(value: ListItemStyle) { + this.__backing_l!.value = observableProxy(value); + } + /** @memo */ + __build(/**/ + /** @memo */ + __builder: ((__instance: ArkCommonMethodComponent) => void) | undefined, /**/ + /** @memo */ + content?: () => void, initializers?: IndexOptions) { + ArkColumn(__builder, () => { + ArkSlider(undefined, undefined, { value: this.n }); + ArkToggle((__instance: ArkToggleComponent) => { + __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); + }, undefined, { type: ToggleType.Switch, isOn: $$(this.b) }); + ArkStepper(undefined, undefined, { index: this.n }); + ArkCheckbox((__instance: ArkCheckboxComponent) => { + __instance.select($$(this.b)); + }, undefined); + ArkCheckboxGroup((__instance: ArkCheckboxGroupComponent) => { + __instance.selectAll($$(this.b)); + }, undefined); + ArkDatePicker((__instance: ArkDatePickerComponent) => { + __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); + }, undefined, { selected: $$(this.d) }); + ArkTimePicker((__instance: ArkTimePickerComponent) => { + __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); + }, undefined, { selected: $$(this.d) }); + ArkMenuItem((__instance: ArkMenuItemComponent) => { + __instance.selected($$(this.b)); + }, undefined); + ArkPanel((__instance: ArkPanelComponent) => { + __instance.mode($$(this.m)); + }, undefined, false); + ArkRadio((__instance: ArkRadioComponent) => { + __instance.checked($$(this.b)); + }, undefined, { group: "", value: "" }); + ArkSearch((__instance: ArkSearchComponent) => { + __instance.__OnChanged_value((value: string): void => { this.s = value; }); + }, undefined, { value: $$(this.s) }); + ArkSideBarContainer((__instance: ArkSideBarContainerComponent) => { + __instance.showSideBar($$(this.b)); + }, undefined, SideBarContainerType.Embed); + ArkSwiper((__instance: ArkSwiperComponent) => { + __instance.index($$(this.n)); + }, undefined); + ArkTabs(undefined, undefined, { index: $$(this.n) }); + ArkTextInput(undefined, undefined, { text: $$(this.s) }); + ArkTextArea(undefined, undefined, { text: $$(this.s) }); + ArkTextInput(undefined, undefined, { text: $$(this.s) }); + ArkToggle((__instance: ArkToggleComponent) => { + __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); + }, undefined, { type: ToggleType.Checkbox, isOn: $$(this.b) }); + ArkAlphabetIndexer(undefined, undefined, { arrayValue: [], selected: $$(this.n) }); + ArkRefresh(undefined, undefined, { refreshing: $$(this.b) }); + ArkTextPicker(undefined, undefined, { range: [], value: $$(this.s), selected: $$(this.n) }); + ArkSelect((__instance: ArkSelectComponent) => { + __instance.value($$(this.s)) + .selected($$(this.n)); + }, undefined, []); + ArkList(undefined, () => { + ArkListItemGroup(undefined, () => { + ArkListItem((__instance: ArkListItemComponent) => { + __instance.selected($$(this.b)); + }, undefined, { style: this.l }); + }); + }); + ArkGrid(undefined, () => { + ArkGridItem((__instance: ArkGridItemComponent) => { + __instance.selected($$(this.b)); + }, undefined, {}); + }); + ArkButton((__instance: ArkButtonComponent) => { + __instance.bindSheet($$(this.b), builder) + .bindContentCover($$(this.b), builder); + }, undefined); + }); + } +} +/** @memo */ +function builder() { + ArkText(undefined, undefined); +} +/** @memo */ +export function Index(/**/ +/** @memo */ +style?: (__instance: ArkCommonMethodComponent) => void, /**/ +/** @memo */ +content?: () => void, initializers?: IndexOptions): void { + contextLocalStateOf("contextLocalMapOfRadioGroups", () => new Map()); + contextLocalStateOf("contextLocalMapOfCheckboxGroups", () => new Map()); + const updatedInitializers: IndexOptions = { + __backing_n: initializers?.__backing_n, + __backing_s: initializers?.__backing_s, + __backing_b: initializers?.__backing_b, + __backing_d: initializers?.__backing_d, + __backing_m: initializers?.__backing_m, + __backing_l: initializers?.__backing_l + }; + ArkIndexComponent._instantiate(style, () => new ArkIndexComponent, content, updatedInitializers); +} +export interface IndexOptions { + __backing_n?: MutableState; + n?: number; + __backing_s?: MutableState; + s?: string; + __backing_b?: MutableState; + b?: boolean; + __backing_d?: MutableState; + d?: Date; + __backing_m?: MutableState; + m?: PanelMode; + __backing_l?: MutableState; + l?: ListItemStyle; +} +registerArkuiEntry(Index, "dollar-dollar/components"); +export const __Entry = Index; -- Gitee From 6cbcff0e6b05c2ca186e1d4f66a645d3518cb51b Mon Sep 17 00:00:00 2001 From: naumovdmitrii Date: Mon, 17 Feb 2025 19:50:18 +0300 Subject: [PATCH 6/6] rebase Signed-off-by: naumovdmitrii --- .../test/ets/dollar-dollar/components.ets | 2 +- .../arkoala/ets/__router_initialization.ts | 4 +- .../arkoala/ets/dollar-dollar/components.ts | 72 +++++++++---------- .../arkts/ets/dollar-dollar/components.ts | 68 +++++++++--------- .../koala/ets/__router_initialization.ts | 4 +- .../koala/ets/dollar-dollar/components.ts | 72 +++++++++---------- 6 files changed, 113 insertions(+), 109 deletions(-) diff --git a/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets b/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets index 720005b38..3e7cfa06f 100644 --- a/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets +++ b/arkoala/ets-plugin/test/ets/dollar-dollar/components.ets @@ -1,6 +1,6 @@ @Entry @Component -struct Index { +struct DollarDollar { @State n: number = 0.5 @State s: string = "0.5" @State b: boolean = true diff --git a/arkoala/ets-plugin/test/golden/arkoala/ets/__router_initialization.ts b/arkoala/ets-plugin/test/golden/arkoala/ets/__router_initialization.ts index acedfbdd3..b9a4cbf7c 100644 --- a/arkoala/ets-plugin/test/golden/arkoala/ets/__router_initialization.ts +++ b/arkoala/ets-plugin/test/golden/arkoala/ets/__router_initialization.ts @@ -2,11 +2,13 @@ import { EntryExample as Entry0 } from "./Rewrite" import { LocalStorageLinkExample as Entry1 } from "./Rewrite2" import { LocalStoragePropExample as Entry2 } from "./Rewrite3" -import { Index as Entry3 } from "./dollar-functions/dollar-functions" +import { DollarDollar as Entry3 } from "./dollar-dollar/components" +import { Index as Entry4 } from "./dollar-functions/dollar-functions" export function registerRoutes() { const __forceEntry0Use = Entry0 const __forceEntry1Use = Entry1 const __forceEntry2Use = Entry2 const __forceEntry3Use = Entry3 + const __forceEntry4Use = Entry4 } diff --git a/arkoala/ets-plugin/test/golden/arkoala/ets/dollar-dollar/components.ts b/arkoala/ets-plugin/test/golden/arkoala/ets/dollar-dollar/components.ts index 45b956f09..7071e10c5 100644 --- a/arkoala/ets-plugin/test/golden/arkoala/ets/dollar-dollar/components.ts +++ b/arkoala/ets-plugin/test/golden/arkoala/ets/dollar-dollar/components.ts @@ -1,10 +1,10 @@ -import { $$, ArkAlphabetIndexer, ArkButton, ArkButtonComponent, ArkCheckbox, ArkCheckboxComponent, ArkCheckboxGroup, ArkCheckboxGroupComponent, ArkColumn, ArkCommonMethodComponent, ArkDatePicker, ArkDatePickerComponent, ArkGrid, ArkGridItem, ArkGridItemComponent, ArkList, ArkListItem, ArkListItemComponent, ArkListItemGroup, ArkMenuItem, ArkMenuItemComponent, ArkPageTransitionEnterComponent, ArkPageTransitionExitComponent, ArkPanel, ArkPanelComponent, ArkRadio, ArkRadioComponent, ArkRefresh, ArkSearch, ArkSearchComponent, ArkSelect, ArkSelectComponent, ArkSideBarContainer, ArkSideBarContainerComponent, ArkSlider, ArkStepper, ArkStructBase, ArkSwiper, ArkSwiperComponent, ArkTabs, ArkText, ArkTextArea, ArkTextInput, ArkTextPicker, ArkTimePicker, ArkTimePickerComponent, ArkToggle, ArkToggleComponent, ListItemStyle, LocalStorage, MutableState, PanelMode, SideBarContainerType, ToggleType, contextLocalStateOf, observableProxy, stateOf } from "@koalaui/arkoala-arkui"; +import { $$, ArkAlphabetIndexer, ArkButton, ArkButtonComponent, ArkCheckbox, ArkCheckboxComponent, ArkCheckboxGroup, ArkCheckboxGroupComponent, ArkColumn, ArkCommonMethodComponent, ArkDatePicker, ArkDatePickerComponent, ArkGrid, ArkGridItem, ArkGridItemComponent, ArkList, ArkListItem, ArkListItemComponent, ArkListItemGroup, ArkMenuItem, ArkMenuItemComponent, ArkPageTransitionEnterComponent, ArkPageTransitionExitComponent, ArkPanel, ArkPanelComponent, ArkRadio, ArkRadioComponent, ArkRefresh, ArkSearch, ArkSearchComponent, ArkSelect, ArkSelectComponent, ArkSideBarContainer, ArkSideBarContainerComponent, ArkSlider, ArkStepper, ArkStructBase, ArkSwiper, ArkSwiperComponent, ArkTabs, ArkText, ArkTextArea, ArkTextInput, ArkTextPicker, ArkTimePicker, ArkTimePickerComponent, ArkToggle, ArkToggleComponent, ListItemStyle, LocalStorage, MutableState, PanelMode, SideBarContainerType, ToggleType, _$, contextLocalStateOf, observableProxy, stateOf } from "@koalaui/arkoala-arkui"; import { registerArkuiEntry } from "@koalaui/arkoala-arkui/ohos.router"; -class ArkIndexComponent extends ArkStructBase { +class ArkDollarDollarComponent extends ArkStructBase { private _entry_local_storage_ = new LocalStorage(); __initializeStruct(/**/ /** @memo */ - content?: () => void, initializers?: IndexOptions): void { + content?: () => void, initializers?: DollarDollarOptions): void { this.__backing_n = stateOf(initializers?.n ?? (0.5), this); this.__backing_s = stateOf(initializers?.s ?? ("0.5"), this); this.__backing_b = stateOf(initializers?.b ?? (true), this); @@ -59,72 +59,72 @@ class ArkIndexComponent extends ArkStructBase { /** @memo */ __builder: ((__instance: ArkCommonMethodComponent) => void) | undefined, /**/ /** @memo */ - content?: () => void, initializers?: IndexOptions) { + content?: () => void, initializers?: DollarDollarOptions) { ArkColumn(__builder, () => { ArkSlider(undefined, undefined, { value: this.n }); ArkToggle((__instance: ArkToggleComponent) => { __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); - }, undefined, { type: ToggleType.Switch, isOn: $$(this.b) }); + }, undefined, { type: ToggleType.Switch, isOn: _$("com.application.example", "entry", this.b) }); ArkStepper(undefined, undefined, { index: this.n }); ArkCheckbox((__instance: ArkCheckboxComponent) => { - __instance.select($$(this.b)); + __instance.select(_$("com.application.example", "entry", this.b)); }, undefined); ArkCheckboxGroup((__instance: ArkCheckboxGroupComponent) => { - __instance.selectAll($$(this.b)); + __instance.selectAll(_$("com.application.example", "entry", this.b)); }, undefined); ArkDatePicker((__instance: ArkDatePickerComponent) => { __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); - }, undefined, { selected: $$(this.d) }); + }, undefined, { selected: _$("com.application.example", "entry", this.d) }); ArkTimePicker((__instance: ArkTimePickerComponent) => { __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); - }, undefined, { selected: $$(this.d) }); + }, undefined, { selected: _$("com.application.example", "entry", this.d) }); ArkMenuItem((__instance: ArkMenuItemComponent) => { - __instance.selected($$(this.b)); + __instance.selected(_$("com.application.example", "entry", this.b)); }, undefined); ArkPanel((__instance: ArkPanelComponent) => { - __instance.mode($$(this.m)); + __instance.mode(_$("com.application.example", "entry", this.m)); }, undefined, false); ArkRadio((__instance: ArkRadioComponent) => { - __instance.checked($$(this.b)); + __instance.checked(_$("com.application.example", "entry", this.b)); }, undefined, { group: "", value: "" }); ArkSearch((__instance: ArkSearchComponent) => { __instance.__OnChanged_value((value: string): void => { this.s = value; }); - }, undefined, { value: $$(this.s) }); + }, undefined, { value: _$("com.application.example", "entry", this.s) }); ArkSideBarContainer((__instance: ArkSideBarContainerComponent) => { - __instance.showSideBar($$(this.b)); + __instance.showSideBar(_$("com.application.example", "entry", this.b)); }, undefined, SideBarContainerType.Embed); ArkSwiper((__instance: ArkSwiperComponent) => { - __instance.index($$(this.n)); + __instance.index(_$("com.application.example", "entry", this.n)); }, undefined); - ArkTabs(undefined, undefined, { index: $$(this.n) }); - ArkTextInput(undefined, undefined, { text: $$(this.s) }); - ArkTextArea(undefined, undefined, { text: $$(this.s) }); - ArkTextInput(undefined, undefined, { text: $$(this.s) }); + ArkTabs(undefined, undefined, { index: _$("com.application.example", "entry", this.n) }); + ArkTextInput(undefined, undefined, { text: _$("com.application.example", "entry", this.s) }); + ArkTextArea(undefined, undefined, { text: _$("com.application.example", "entry", this.s) }); + ArkTextInput(undefined, undefined, { text: _$("com.application.example", "entry", this.s) }); ArkToggle((__instance: ArkToggleComponent) => { __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); - }, undefined, { type: ToggleType.Checkbox, isOn: $$(this.b) }); - ArkAlphabetIndexer(undefined, undefined, { arrayValue: [], selected: $$(this.n) }); - ArkRefresh(undefined, undefined, { refreshing: $$(this.b) }); - ArkTextPicker(undefined, undefined, { range: [], value: $$(this.s), selected: $$(this.n) }); + }, undefined, { type: ToggleType.Checkbox, isOn: _$("com.application.example", "entry", this.b) }); + ArkAlphabetIndexer(undefined, undefined, { arrayValue: [], selected: _$("com.application.example", "entry", this.n) }); + ArkRefresh(undefined, undefined, { refreshing: _$("com.application.example", "entry", this.b) }); + ArkTextPicker(undefined, undefined, { range: [], value: _$("com.application.example", "entry", this.s), selected: _$("com.application.example", "entry", this.n) }); ArkSelect((__instance: ArkSelectComponent) => { - __instance.value($$(this.s)) - .selected($$(this.n)); + __instance.value(_$("com.application.example", "entry", this.s)) + .selected(_$("com.application.example", "entry", this.n)); }, undefined, []); ArkList(undefined, () => { ArkListItemGroup(undefined, () => { ArkListItem((__instance: ArkListItemComponent) => { - __instance.selected($$(this.b)); + __instance.selected(_$("com.application.example", "entry", this.b)); }, undefined, { style: this.l }); }); }); ArkGrid(undefined, () => { ArkGridItem((__instance: ArkGridItemComponent) => { - __instance.selected($$(this.b)); + __instance.selected(_$("com.application.example", "entry", this.b)); }, undefined, {}); }); ArkButton((__instance: ArkButtonComponent) => { - __instance.bindSheet($$(this.b), builder) - .bindContentCover($$(this.b), builder); + __instance.bindSheet(_$("com.application.example", "entry", this.b), builder) + .bindContentCover(_$("com.application.example", "entry", this.b), builder); }, undefined); }); } @@ -134,14 +134,14 @@ function builder() { ArkText(undefined, undefined); } /** @memo */ -export function Index(/**/ +export function DollarDollar(/**/ /** @memo */ style?: (__instance: ArkCommonMethodComponent) => void, /**/ /** @memo */ -content?: () => void, initializers?: IndexOptions): void { +content?: () => void, initializers?: DollarDollarOptions): void { contextLocalStateOf("contextLocalMapOfRadioGroups", () => new Map()); contextLocalStateOf("contextLocalMapOfCheckboxGroups", () => new Map()); - const updatedInitializers: IndexOptions = { + const updatedInitializers: DollarDollarOptions = { __backing_n: initializers?.__backing_n, __backing_s: initializers?.__backing_s, __backing_b: initializers?.__backing_b, @@ -149,9 +149,9 @@ content?: () => void, initializers?: IndexOptions): void { __backing_m: initializers?.__backing_m, __backing_l: initializers?.__backing_l }; - ArkIndexComponent._instantiate(style, () => new ArkIndexComponent, content, updatedInitializers); + ArkDollarDollarComponent._instantiate(style, () => new ArkDollarDollarComponent, content, updatedInitializers); } -export interface IndexOptions { +export interface DollarDollarOptions { __backing_n?: MutableState; n?: number; __backing_s?: MutableState; @@ -165,5 +165,5 @@ export interface IndexOptions { __backing_l?: MutableState; l?: ListItemStyle; } -registerArkuiEntry(Index, "dollar-dollar/components"); -export const __Entry = Index; +registerArkuiEntry(DollarDollar, "dollar-dollar/components"); +export const __Entry = DollarDollar; diff --git a/arkoala/ets-plugin/test/golden/arkts/ets/dollar-dollar/components.ts b/arkoala/ets-plugin/test/golden/arkts/ets/dollar-dollar/components.ts index c3df14913..2756437eb 100644 --- a/arkoala/ets-plugin/test/golden/arkts/ets/dollar-dollar/components.ts +++ b/arkoala/ets-plugin/test/golden/arkts/ets/dollar-dollar/components.ts @@ -1,12 +1,12 @@ -import { $$, AlphabetIndexerOptions, ArkAlphabetIndexer, ArkButton, ArkButtonComponent, ArkCheckbox, ArkCheckboxComponent, ArkCheckboxGroup, ArkCheckboxGroupComponent, ArkColumn, ArkCommonMethodComponent, ArkDatePicker, ArkDatePickerComponent, ArkGrid, ArkGridItem, ArkGridItemComponent, ArkList, ArkListItem, ArkListItemComponent, ArkListItemGroup, ArkMenuItem, ArkMenuItemComponent, ArkPageTransitionEnterComponent, ArkPageTransitionExitComponent, ArkPanel, ArkPanelComponent, ArkRadio, ArkRadioComponent, ArkRefresh, ArkSearch, ArkSearchComponent, ArkSelect, ArkSelectComponent, ArkSideBarContainer, ArkSideBarContainerComponent, ArkSlider, ArkStepper, ArkStructBase, ArkSwiper, ArkSwiperComponent, ArkTabs, ArkText, ArkTextArea, ArkTextInput, ArkTextPicker, ArkTimePicker, ArkTimePickerComponent, ArkToggle, ArkToggleComponent, DatePickerOptions, GridItemOptions, ListItemOptions, ListItemStyle, PanelMode, RadioOptions, RefreshOptions, SearchOptions, SideBarContainerType, SliderOptions, StepperOptions, TabsOptions, TextAreaOptions, TextInputOptions, TextPickerOptions, TimePickerOptions, ToggleOptions, ToggleType, contextLocalStateOf, stateOf } from "@koalaui/arkts-arkui"; +import { $$, AlphabetIndexerOptions, ArkAlphabetIndexer, ArkButton, ArkButtonComponent, ArkCheckbox, ArkCheckboxComponent, ArkCheckboxGroup, ArkCheckboxGroupComponent, ArkColumn, ArkCommonMethodComponent, ArkDatePicker, ArkDatePickerComponent, ArkGrid, ArkGridItem, ArkGridItemComponent, ArkList, ArkListItem, ArkListItemComponent, ArkListItemGroup, ArkMenuItem, ArkMenuItemComponent, ArkPageTransitionEnterComponent, ArkPageTransitionExitComponent, ArkPanel, ArkPanelComponent, ArkRadio, ArkRadioComponent, ArkRefresh, ArkSearch, ArkSearchComponent, ArkSelect, ArkSelectComponent, ArkSideBarContainer, ArkSideBarContainerComponent, ArkSlider, ArkStepper, ArkStructBase, ArkSwiper, ArkSwiperComponent, ArkTabs, ArkText, ArkTextArea, ArkTextInput, ArkTextPicker, ArkTimePicker, ArkTimePickerComponent, ArkToggle, ArkToggleComponent, DatePickerOptions, GridItemOptions, ListItemOptions, ListItemStyle, PanelMode, RadioOptions, RefreshOptions, SearchOptions, SideBarContainerType, SliderOptions, StepperOptions, TabsOptions, TextAreaOptions, TextInputOptions, TextPickerOptions, TimePickerOptions, ToggleOptions, ToggleType, _$, contextLocalStateOf, stateOf } from "@koalaui/arkts-arkui"; import { MutableState } from "@koalaui/runtime"; import { LocalStorage } from "@koalaui/arkui-common"; import { observableProxy } from "@koalaui/common"; -class ArkIndexComponent extends ArkStructBase { +class ArkDollarDollarComponent extends ArkStructBase { private _entry_local_storage_ = new LocalStorage(); __initializeStruct(/**/ /** @memo */ - content?: () => void, initializers?: IndexOptions): void { + content?: () => void, initializers?: DollarDollarOptions): void { this.__backing_n = stateOf(initializers?.n ?? (0.5), this); this.__backing_s = stateOf(initializers?.s ?? ("0.5"), this); this.__backing_b = stateOf(initializers?.b ?? (true), this); @@ -61,72 +61,72 @@ class ArkIndexComponent extends ArkStructBase { /** @memo */ __builder: ((__instance: ArkCommonMethodComponent) => void) | undefined, /**/ /** @memo */ - content?: () => void, initializers?: IndexOptions) { + content?: () => void, initializers?: DollarDollarOptions) { ArkColumn(__builder, () => { ArkSlider(undefined, undefined, { value: this.n } as SliderOptions); ArkToggle((__instance: ArkToggleComponent) => { __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); - }, undefined, { type: ToggleType.Switch, isOn: $$(this.b) } as ToggleOptions); + }, undefined, { type: ToggleType.Switch, isOn: _$("com.application.example", "entry", this.b) } as ToggleOptions); ArkStepper(undefined, undefined, { index: this.n } as StepperOptions); ArkCheckbox((__instance: ArkCheckboxComponent) => { - __instance.select($$(this.b)); + __instance.select(_$("com.application.example", "entry", this.b)); }, undefined); ArkCheckboxGroup((__instance: ArkCheckboxGroupComponent) => { - __instance.selectAll($$(this.b)); + __instance.selectAll(_$("com.application.example", "entry", this.b)); }, undefined); ArkDatePicker((__instance: ArkDatePickerComponent) => { __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); - }, undefined, { selected: $$(this.d) } as DatePickerOptions); + }, undefined, { selected: _$("com.application.example", "entry", this.d) } as DatePickerOptions); ArkTimePicker((__instance: ArkTimePickerComponent) => { __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); - }, undefined, { selected: $$(this.d) } as TimePickerOptions); + }, undefined, { selected: _$("com.application.example", "entry", this.d) } as TimePickerOptions); ArkMenuItem((__instance: ArkMenuItemComponent) => { - __instance.selected($$(this.b)); + __instance.selected(_$("com.application.example", "entry", this.b)); }, undefined); ArkPanel((__instance: ArkPanelComponent) => { - __instance.mode($$(this.m)); + __instance.mode(_$("com.application.example", "entry", this.m)); }, undefined, false); ArkRadio((__instance: ArkRadioComponent) => { - __instance.checked($$(this.b)); + __instance.checked(_$("com.application.example", "entry", this.b)); }, undefined, { group: "", value: "" } as RadioOptions); ArkSearch((__instance: ArkSearchComponent) => { __instance.__OnChanged_value((value: string): void => { this.s = value; }); - }, undefined, { value: $$(this.s) } as SearchOptions); + }, undefined, { value: _$("com.application.example", "entry", this.s) } as SearchOptions); ArkSideBarContainer((__instance: ArkSideBarContainerComponent) => { - __instance.showSideBar($$(this.b)); + __instance.showSideBar(_$("com.application.example", "entry", this.b)); }, undefined, SideBarContainerType.Embed); ArkSwiper((__instance: ArkSwiperComponent) => { - __instance.index($$(this.n)); + __instance.index(_$("com.application.example", "entry", this.n)); }, undefined); - ArkTabs(undefined, undefined, { index: $$(this.n) } as TabsOptions); - ArkTextInput(undefined, undefined, { text: $$(this.s) } as TextInputOptions); - ArkTextArea(undefined, undefined, { text: $$(this.s) } as TextAreaOptions); - ArkTextInput(undefined, undefined, { text: $$(this.s) } as TextInputOptions); + ArkTabs(undefined, undefined, { index: _$("com.application.example", "entry", this.n) } as TabsOptions); + ArkTextInput(undefined, undefined, { text: _$("com.application.example", "entry", this.s) } as TextInputOptions); + ArkTextArea(undefined, undefined, { text: _$("com.application.example", "entry", this.s) } as TextAreaOptions); + ArkTextInput(undefined, undefined, { text: _$("com.application.example", "entry", this.s) } as TextInputOptions); ArkToggle((__instance: ArkToggleComponent) => { __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); - }, undefined, { type: ToggleType.Checkbox, isOn: $$(this.b) } as ToggleOptions); - ArkAlphabetIndexer(undefined, undefined, { arrayValue: [], selected: $$(this.n) } as AlphabetIndexerOptions); - ArkRefresh(undefined, undefined, { refreshing: $$(this.b) } as RefreshOptions); - ArkTextPicker(undefined, undefined, { range: [], value: $$(this.s), selected: $$(this.n) } as TextPickerOptions); + }, undefined, { type: ToggleType.Checkbox, isOn: _$("com.application.example", "entry", this.b) } as ToggleOptions); + ArkAlphabetIndexer(undefined, undefined, { arrayValue: [], selected: _$("com.application.example", "entry", this.n) } as AlphabetIndexerOptions); + ArkRefresh(undefined, undefined, { refreshing: _$("com.application.example", "entry", this.b) } as RefreshOptions); + ArkTextPicker(undefined, undefined, { range: [], value: _$("com.application.example", "entry", this.s), selected: _$("com.application.example", "entry", this.n) } as TextPickerOptions); ArkSelect((__instance: ArkSelectComponent) => { - __instance.value($$(this.s)) - .selected($$(this.n)); + __instance.value(_$("com.application.example", "entry", this.s)) + .selected(_$("com.application.example", "entry", this.n)); }, undefined, []); ArkList(undefined, () => { ArkListItemGroup(undefined, () => { ArkListItem((__instance: ArkListItemComponent) => { - __instance.selected($$(this.b)); + __instance.selected(_$("com.application.example", "entry", this.b)); }, undefined, { style: this.l } as ListItemOptions); }); }); ArkGrid(undefined, () => { ArkGridItem((__instance: ArkGridItemComponent) => { - __instance.selected($$(this.b)); + __instance.selected(_$("com.application.example", "entry", this.b)); }, undefined, {} as GridItemOptions); }); ArkButton((__instance: ArkButtonComponent) => { - __instance.bindSheet($$(this.b), builder) - .bindContentCover($$(this.b), builder); + __instance.bindSheet(_$("com.application.example", "entry", this.b), builder) + .bindContentCover(_$("com.application.example", "entry", this.b), builder); }, undefined); }); } @@ -136,14 +136,14 @@ function builder() { ArkText(undefined, undefined); } /** @memo */ -export function Index(/**/ +export function DollarDollar(/**/ /** @memo */ style?: (__instance: ArkCommonMethodComponent) => void, /**/ /** @memo */ -content?: () => void, initializers?: IndexOptions): void { +content?: () => void, initializers?: DollarDollarOptions): void { contextLocalStateOf("contextLocalMapOfRadioGroups", () => new Map()); contextLocalStateOf("contextLocalMapOfCheckboxGroups", () => new Map()); - const updatedInitializers: IndexOptions = { + const updatedInitializers: DollarDollarOptions = { __backing_n: initializers?.__backing_n, __backing_s: initializers?.__backing_s, __backing_b: initializers?.__backing_b, @@ -151,9 +151,9 @@ content?: () => void, initializers?: IndexOptions): void { __backing_m: initializers?.__backing_m, __backing_l: initializers?.__backing_l }; - ArkIndexComponent._instantiate(style, () => new ArkIndexComponent, content, updatedInitializers); + ArkDollarDollarComponent._instantiate(style, () => new ArkDollarDollarComponent, content, updatedInitializers); } -export interface IndexOptions { +export interface DollarDollarOptions { __backing_n?: MutableState; n?: number; __backing_s?: MutableState; diff --git a/arkoala/ets-plugin/test/golden/koala/ets/__router_initialization.ts b/arkoala/ets-plugin/test/golden/koala/ets/__router_initialization.ts index acedfbdd3..b9a4cbf7c 100644 --- a/arkoala/ets-plugin/test/golden/koala/ets/__router_initialization.ts +++ b/arkoala/ets-plugin/test/golden/koala/ets/__router_initialization.ts @@ -2,11 +2,13 @@ import { EntryExample as Entry0 } from "./Rewrite" import { LocalStorageLinkExample as Entry1 } from "./Rewrite2" import { LocalStoragePropExample as Entry2 } from "./Rewrite3" -import { Index as Entry3 } from "./dollar-functions/dollar-functions" +import { DollarDollar as Entry3 } from "./dollar-dollar/components" +import { Index as Entry4 } from "./dollar-functions/dollar-functions" export function registerRoutes() { const __forceEntry0Use = Entry0 const __forceEntry1Use = Entry1 const __forceEntry2Use = Entry2 const __forceEntry3Use = Entry3 + const __forceEntry4Use = Entry4 } diff --git a/arkoala/ets-plugin/test/golden/koala/ets/dollar-dollar/components.ts b/arkoala/ets-plugin/test/golden/koala/ets/dollar-dollar/components.ts index 73cdb7868..db935bf50 100644 --- a/arkoala/ets-plugin/test/golden/koala/ets/dollar-dollar/components.ts +++ b/arkoala/ets-plugin/test/golden/koala/ets/dollar-dollar/components.ts @@ -1,12 +1,12 @@ -import { $$, $r, $rawfile, AppStorage, ArkAlphabetIndexer, ArkButton, ArkButtonComponent, ArkCheckbox, ArkCheckboxComponent, ArkCheckboxGroup, ArkCheckboxGroupComponent, ArkColumn, ArkCommonMethodComponent, ArkDatePicker, ArkDatePickerComponent, ArkGrid, ArkGridItem, ArkGridItemComponent, ArkList, ArkListItem, ArkListItemComponent, ArkListItemGroup, ArkMenuItem, ArkMenuItemComponent, ArkPageTransitionEnterComponent, ArkPageTransitionExitComponent, ArkPanel, ArkPanelComponent, ArkRadio, ArkRadioComponent, ArkRefresh, ArkSearch, ArkSearchComponent, ArkSelect, ArkSelectComponent, ArkSideBarContainer, ArkSideBarContainerComponent, ArkSlider, ArkStepper, ArkStructBase, ArkSwiper, ArkSwiperComponent, ArkTabs, ArkText, ArkTextArea, ArkTextInput, ArkTextPicker, ArkTimePicker, ArkTimePickerComponent, ArkToggle, ArkToggleComponent, CanvasRenderingContext2D, CustomDialogController, DataChangeListener, Environment, ForEach, GestureGroup, IDataSource, ListItemStyle, LocalStorage, LongPressGesture, PanGesture, PanGestureOptions, PanelMode, PersistentStorage, PinchGesture, RenderingContextSettings, RotationGesture, Scroller, SideBarContainerType, SubscribedAbstractProperty, SwipeGesture, SwiperController, TabsController, TapGesture, TextAreaController, ToggleType, VideoController, animateTo, contextLocalStateOf, fp2px, getContext, getInspectorByKey, lpx2px, px2fp, px2lpx, px2vp, stateOf, vp2px } from "@koalaui/arkui"; +import { $$, $r, $rawfile, AppStorage, ArkAlphabetIndexer, ArkButton, ArkButtonComponent, ArkCheckbox, ArkCheckboxComponent, ArkCheckboxGroup, ArkCheckboxGroupComponent, ArkColumn, ArkCommonMethodComponent, ArkDatePicker, ArkDatePickerComponent, ArkGrid, ArkGridItem, ArkGridItemComponent, ArkList, ArkListItem, ArkListItemComponent, ArkListItemGroup, ArkMenuItem, ArkMenuItemComponent, ArkPageTransitionEnterComponent, ArkPageTransitionExitComponent, ArkPanel, ArkPanelComponent, ArkRadio, ArkRadioComponent, ArkRefresh, ArkSearch, ArkSearchComponent, ArkSelect, ArkSelectComponent, ArkSideBarContainer, ArkSideBarContainerComponent, ArkSlider, ArkStepper, ArkStructBase, ArkSwiper, ArkSwiperComponent, ArkTabs, ArkText, ArkTextArea, ArkTextInput, ArkTextPicker, ArkTimePicker, ArkTimePickerComponent, ArkToggle, ArkToggleComponent, CanvasRenderingContext2D, CustomDialogController, DataChangeListener, Environment, ForEach, GestureGroup, IDataSource, ListItemStyle, LocalStorage, LongPressGesture, PanGesture, PanGestureOptions, PanelMode, PersistentStorage, PinchGesture, RenderingContextSettings, RotationGesture, Scroller, SideBarContainerType, SubscribedAbstractProperty, SwipeGesture, SwiperController, TabsController, TapGesture, TextAreaController, ToggleType, VideoController, _$, animateTo, contextLocalStateOf, fp2px, getContext, getInspectorByKey, lpx2px, px2fp, px2lpx, px2vp, stateOf, vp2px } from "@koalaui/arkui"; import { MutableState } from "@koalaui/runtime"; import { registerArkuiEntry } from "@koalaui/arkui/ohos.router"; import { observableProxy } from "@koalaui/common"; -class ArkIndexComponent extends ArkStructBase { +class ArkDollarDollarComponent extends ArkStructBase { private _entry_local_storage_ = new LocalStorage(); __initializeStruct(/**/ /** @memo */ - content?: () => void, initializers?: IndexOptions): void { + content?: () => void, initializers?: DollarDollarOptions): void { this.__backing_n = stateOf(initializers?.n ?? (0.5), this); this.__backing_s = stateOf(initializers?.s ?? ("0.5"), this); this.__backing_b = stateOf(initializers?.b ?? (true), this); @@ -61,72 +61,72 @@ class ArkIndexComponent extends ArkStructBase { /** @memo */ __builder: ((__instance: ArkCommonMethodComponent) => void) | undefined, /**/ /** @memo */ - content?: () => void, initializers?: IndexOptions) { + content?: () => void, initializers?: DollarDollarOptions) { ArkColumn(__builder, () => { ArkSlider(undefined, undefined, { value: this.n }); ArkToggle((__instance: ArkToggleComponent) => { __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); - }, undefined, { type: ToggleType.Switch, isOn: $$(this.b) }); + }, undefined, { type: ToggleType.Switch, isOn: _$("", "entry", this.b) }); ArkStepper(undefined, undefined, { index: this.n }); ArkCheckbox((__instance: ArkCheckboxComponent) => { - __instance.select($$(this.b)); + __instance.select(_$("", "entry", this.b)); }, undefined); ArkCheckboxGroup((__instance: ArkCheckboxGroupComponent) => { - __instance.selectAll($$(this.b)); + __instance.selectAll(_$("", "entry", this.b)); }, undefined); ArkDatePicker((__instance: ArkDatePickerComponent) => { __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); - }, undefined, { selected: $$(this.d) }); + }, undefined, { selected: _$("", "entry", this.d) }); ArkTimePicker((__instance: ArkTimePickerComponent) => { __instance.__OnChanged_selected((selected: Date): void => { this.d = selected; }); - }, undefined, { selected: $$(this.d) }); + }, undefined, { selected: _$("", "entry", this.d) }); ArkMenuItem((__instance: ArkMenuItemComponent) => { - __instance.selected($$(this.b)); + __instance.selected(_$("", "entry", this.b)); }, undefined); ArkPanel((__instance: ArkPanelComponent) => { - __instance.mode($$(this.m)); + __instance.mode(_$("", "entry", this.m)); }, undefined, false); ArkRadio((__instance: ArkRadioComponent) => { - __instance.checked($$(this.b)); + __instance.checked(_$("", "entry", this.b)); }, undefined, { group: "", value: "" }); ArkSearch((__instance: ArkSearchComponent) => { __instance.__OnChanged_value((value: string): void => { this.s = value; }); - }, undefined, { value: $$(this.s) }); + }, undefined, { value: _$("", "entry", this.s) }); ArkSideBarContainer((__instance: ArkSideBarContainerComponent) => { - __instance.showSideBar($$(this.b)); + __instance.showSideBar(_$("", "entry", this.b)); }, undefined, SideBarContainerType.Embed); ArkSwiper((__instance: ArkSwiperComponent) => { - __instance.index($$(this.n)); + __instance.index(_$("", "entry", this.n)); }, undefined); - ArkTabs(undefined, undefined, { index: $$(this.n) }); - ArkTextInput(undefined, undefined, { text: $$(this.s) }); - ArkTextArea(undefined, undefined, { text: $$(this.s) }); - ArkTextInput(undefined, undefined, { text: $$(this.s) }); + ArkTabs(undefined, undefined, { index: _$("", "entry", this.n) }); + ArkTextInput(undefined, undefined, { text: _$("", "entry", this.s) }); + ArkTextArea(undefined, undefined, { text: _$("", "entry", this.s) }); + ArkTextInput(undefined, undefined, { text: _$("", "entry", this.s) }); ArkToggle((__instance: ArkToggleComponent) => { __instance.__OnChanged_isOn((isOn: boolean): void => { this.b = isOn; }); - }, undefined, { type: ToggleType.Checkbox, isOn: $$(this.b) }); - ArkAlphabetIndexer(undefined, undefined, { arrayValue: [], selected: $$(this.n) }); - ArkRefresh(undefined, undefined, { refreshing: $$(this.b) }); - ArkTextPicker(undefined, undefined, { range: [], value: $$(this.s), selected: $$(this.n) }); + }, undefined, { type: ToggleType.Checkbox, isOn: _$("", "entry", this.b) }); + ArkAlphabetIndexer(undefined, undefined, { arrayValue: [], selected: _$("", "entry", this.n) }); + ArkRefresh(undefined, undefined, { refreshing: _$("", "entry", this.b) }); + ArkTextPicker(undefined, undefined, { range: [], value: _$("", "entry", this.s), selected: _$("", "entry", this.n) }); ArkSelect((__instance: ArkSelectComponent) => { - __instance.value($$(this.s)) - .selected($$(this.n)); + __instance.value(_$("", "entry", this.s)) + .selected(_$("", "entry", this.n)); }, undefined, []); ArkList(undefined, () => { ArkListItemGroup(undefined, () => { ArkListItem((__instance: ArkListItemComponent) => { - __instance.selected($$(this.b)); + __instance.selected(_$("", "entry", this.b)); }, undefined, { style: this.l }); }); }); ArkGrid(undefined, () => { ArkGridItem((__instance: ArkGridItemComponent) => { - __instance.selected($$(this.b)); + __instance.selected(_$("", "entry", this.b)); }, undefined, {}); }); ArkButton((__instance: ArkButtonComponent) => { - __instance.bindSheet($$(this.b), builder) - .bindContentCover($$(this.b), builder); + __instance.bindSheet(_$("", "entry", this.b), builder) + .bindContentCover(_$("", "entry", this.b), builder); }, undefined); }); } @@ -136,14 +136,14 @@ function builder() { ArkText(undefined, undefined); } /** @memo */ -export function Index(/**/ +export function DollarDollar(/**/ /** @memo */ style?: (__instance: ArkCommonMethodComponent) => void, /**/ /** @memo */ -content?: () => void, initializers?: IndexOptions): void { +content?: () => void, initializers?: DollarDollarOptions): void { contextLocalStateOf("contextLocalMapOfRadioGroups", () => new Map()); contextLocalStateOf("contextLocalMapOfCheckboxGroups", () => new Map()); - const updatedInitializers: IndexOptions = { + const updatedInitializers: DollarDollarOptions = { __backing_n: initializers?.__backing_n, __backing_s: initializers?.__backing_s, __backing_b: initializers?.__backing_b, @@ -151,9 +151,9 @@ content?: () => void, initializers?: IndexOptions): void { __backing_m: initializers?.__backing_m, __backing_l: initializers?.__backing_l }; - ArkIndexComponent._instantiate(style, () => new ArkIndexComponent, content, updatedInitializers); + ArkDollarDollarComponent._instantiate(style, () => new ArkDollarDollarComponent, content, updatedInitializers); } -export interface IndexOptions { +export interface DollarDollarOptions { __backing_n?: MutableState; n?: number; __backing_s?: MutableState; @@ -167,5 +167,5 @@ export interface IndexOptions { __backing_l?: MutableState; l?: ListItemStyle; } -registerArkuiEntry(Index, "dollar-dollar/components"); -export const __Entry = Index; +registerArkuiEntry(DollarDollar, "dollar-dollar/components"); +export const __Entry = DollarDollar; -- Gitee