diff --git a/arkoala-arkts/arkui/config/etsconfig-base.json b/arkoala-arkts/arkui/config/etsconfig-base.json index a1bc1c4e3cb49a2235a702a6b4e3f4f7125c59a9..585ba893e2bb122ddc7626de38e81965f4507ee5 100644 --- a/arkoala-arkts/arkui/config/etsconfig-base.json +++ b/arkoala-arkts/arkui/config/etsconfig-base.json @@ -6,7 +6,7 @@ "compilerOptions": { "target": "es2020", "sourceMap": true, - "strict": false, + "strict": true, "removeComments": false, "module": "commonjs", "experimentalDecorators": true, @@ -225,6 +225,7 @@ "UIExtensionComponent", "RichEditor", "CachedImage", + "WithTheme", "MediaCachedImage" ], "extend": { @@ -798,10 +799,20 @@ "type": "CachedImageAttribute", "instance": "CachedImageInstance" }, + { + "name": "WithTheme", + "type": "WithThemeAttribute", + "instance": "WithThemeInstance" + }, { "name": "MediaCachedImage", "type": "MediaCachedImageAttribute", "instance": "MediaCachedImageInstance" + }, + { + "name": "Column", + "type": "ColumnAttribute", + "instance": "ColumnInstance" } ] }, @@ -823,7 +834,7 @@ "allowSyntheticDefaultImports": true, "esModuleInterop": true, "importsNotUsedAsValues": "preserve", - "noImplicitAny": false, + "noImplicitAny": true, "noUnusedLocals": false, "noUnusedParameters": false, "moduleResolution": "node", diff --git a/arkoala-arkts/arkui/src/generated/ArkWithTheme.ts b/arkoala-arkts/arkui/src/generated/ArkWithTheme.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ecd44756fb5102cecd68928d373727ed1c72eb5 --- /dev/null +++ b/arkoala-arkts/arkui/src/generated/ArkWithTheme.ts @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2024-2025 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. + */ + + +// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION! + +import { int32, float32 } from "@koalaui/common" +import { KStringPtr, KBoolean, RuntimeType, runtimeType, isResource, isInstanceOf } from "@koalaui/interop" +import { NodeAttach, remember } from "@koalaui/runtime" +import { ComponentBase } from "./ComponentBase" +import { TypeChecker } from "#components" +import { ArkCommonMethodComponent } from "./ArkCommon" +// import { ArkWithThemePeer } from "./peers/ArkWithThemePeer" +import { CommonMethod, PointLightStyle } from "./ArkCommonInterfaces" +import { WithThemeAttribute, WithThemeOptions } from "./ArkWithThemeInterfaces" +import { HorizontalAlign, FlexAlign } from "./ArkEnumsInterfaces" +/** @memo:stable */ +export class ArkWithThemeComponent extends ArkCommonMethodComponent { + // getPeer(): ArkWithThemePeer { + // return (this.peer as ArkWithThemePeer) + // } + // /** @memo */ + // public setColumnOptions(options?: WithThemeOptions): this { + // if (this.checkPriority("setColumnOptions")) { + // const options_casted = options as (WithThemeOptions | undefined) + // this.getPeer()?.setColumnOptionsAttribute(options_casted) + // return this + // } + // return this + // } + // /** @memo */ + // public alignItems(value: HorizontalAlign): this { + // if (this.checkPriority("alignItems")) { + // const value_casted = value as (HorizontalAlign) + // this.getPeer()?.alignItemsAttribute(value_casted) + // return this + // } + // return this + // } + // /** @memo */ + // public justifyContent(value: FlexAlign): this { + // if (this.checkPriority("justifyContent")) { + // const value_casted = value as (FlexAlign) + // this.getPeer()?.justifyContentAttribute(value_casted) + // return this + // } + // return this + // } + // /** @memo */ + // public pointLight(value: PointLightStyle): this { + // if (this.checkPriority("pointLight")) { + // const value_casted = value as (PointLightStyle) + // this.getPeer()?.pointLightAttribute(value_casted) + // return this + // } + // return this + // } + // /** @memo */ + // public reverse(value?: boolean): this { + // if (this.checkPriority("reverse")) { + // const value_casted = value as (boolean | undefined) + // this.getPeer()?.reverseAttribute(value_casted) + // return this + // } + // return this + // } + // public applyAttributesFinish(): void { + // // we calls this function outside of class, so need to make it public + // super.applyAttributesFinish() + // } +} + +/** @memo */ +export function ArkWithTheme( + /** @memo */ + style: ((attributes: ArkWithThemeComponent) => void) | undefined, + /** @memo */ + content_: (() => void) | undefined, + options?: WithThemeOptions | undefined +) { + const receiver = remember(() => { + return new ArkWithThemeComponent() + }) + // NodeAttach((): ArkWithThemePeer => ArkWithThemePeer.create(receiver), (_: ArkWithThemePeer) => { + // receiver.setColumnOptions(options) + // style?.(receiver) + // content_?.() + // receiver.applyAttributesFinish() + // }) +} diff --git a/arkoala-arkts/arkui/src/generated/ArkWithThemeInterfaces.ts b/arkoala-arkts/arkui/src/generated/ArkWithThemeInterfaces.ts index 7ddd061676358e3bbab082ef8175911c345754dc..b1d574fa44e3065a6064fb061768170ceb0e9dd9 100644 --- a/arkoala-arkts/arkui/src/generated/ArkWithThemeInterfaces.ts +++ b/arkoala-arkts/arkui/src/generated/ArkWithThemeInterfaces.ts @@ -20,13 +20,49 @@ import { int32, int64, float32 } from "@koalaui/common" import { KInt, KPointer, KBoolean, KStringPtr, wrapCallback, NativeBuffer } from "@koalaui/interop" import { NodeAttach, remember } from "@koalaui/runtime" import { ThemeColorMode } from "./ArkCommonInterfaces" + + + + + + + +declare interface Colors { + +} + +declare type CustomColors = Partial export interface CustomTheme { - _CustomThemeStub: string; + /** + * Define tokens associated with color resources.. + * + * @type { ?CustomColors } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 12 + */ + colors?: CustomColors; } + export interface WithThemeOptions { theme?: CustomTheme; colorMode?: ThemeColorMode; } + +// export type WithThemeInterface = (p: any,func: () => any, r: WithThemeOptions) => void + +// /** @memo */ +// export const ArkWithTheme: WithThemeInterface = (p: any,func: () => any, r: WithThemeOptions) => void {} + + +// export interface CustomTheme { +// _CustomThemeStub: string; +// } +// export interface WithThemeOptions { +// theme?: CustomTheme; +// colorMode?: ThemeColorMode; +// } export type WithThemeInterface = (options: WithThemeOptions) => WithThemeAttribute; export interface WithThemeAttribute { } diff --git a/arkoala-arkts/arkui/src/generated/index.ts b/arkoala-arkts/arkui/src/generated/index.ts index 6607c0e112515c370fb79609d242ea633b1d3bf5..88c2dc81930a803f1d7b423bef446f10361c8a0f 100644 --- a/arkoala-arkts/arkui/src/generated/index.ts +++ b/arkoala-arkts/arkui/src/generated/index.ts @@ -416,3 +416,5 @@ export * from "./ArkCustomSpanMaterialized" export * from "./ArkLinearIndicatorControllerMaterialized" export * from "./ArkGlobalScopeInspectorMaterialized" export * from "./GlobalScope" + +export * from "./ArkWithTheme" diff --git a/arkoala-arkts/arkui/src/generated/peers/CallbackDeserializeCall.ts b/arkoala-arkts/arkui/src/generated/peers/CallbackDeserializeCall.ts index 0d6509997d5c3f4d96cfad0c68e8fbfa627a2582..d724223021b7b65472a43db43e64ed0d16296eb5 100644 --- a/arkoala-arkts/arkui/src/generated/peers/CallbackDeserializeCall.ts +++ b/arkoala-arkts/arkui/src/generated/peers/CallbackDeserializeCall.ts @@ -1980,8 +1980,8 @@ export function deserializeAndCallWithThemeInterface(thisDeserializer: Deseriali const _call = (ResourceHolder.instance().get(_resourceId) as WithThemeInterface) let options : WithThemeOptions = thisDeserializer.readWithThemeOptions() let _continuation : ((value: WithThemeAttribute) => void) = thisDeserializer.readCallback_WithThemeAttribute_Void(true) - const _callResult = _call(options) - _continuation(_callResult) + // const _callResult = _call(options) + // _continuation(_callResult) } export function deserializeAndCallCallback(thisDeserializer: Deserializer): void { const kind : int32 = thisDeserializer.readInt32() diff --git a/arkoala-arkts/arkui/src/generated/peers/Serializer.ts b/arkoala-arkts/arkui/src/generated/peers/Serializer.ts index fee711b456a3e765daf88c9b295d6ba21f56cc0a..4a61f87c3b48f2042b32f4f676d58c39bb5352eb 100644 --- a/arkoala-arkts/arkui/src/generated/peers/Serializer.ts +++ b/arkoala-arkts/arkui/src/generated/peers/Serializer.ts @@ -3577,7 +3577,8 @@ export class Serializer extends SerializerBase { } writeCustomTheme(value: CustomTheme): void { let valueSerializer : Serializer = this - const value__CustomThemeStub = value._CustomThemeStub + // const value__CustomThemeStub = value._CustomThemeStub + const value__CustomThemeStub = "value._CustomThemeStub" valueSerializer.writeString(value__CustomThemeStub) } writeRestrictedWorker(value: RestrictedWorker): void { diff --git a/arkoala-arkts/arkui/src/index.ts b/arkoala-arkts/arkui/src/index.ts index b8ebda64d9c0bea28ee0443322ce9c17244da51b..65f013d0fb1e2764c806b82f7d3d11f5f7130900 100644 --- a/arkoala-arkts/arkui/src/index.ts +++ b/arkoala-arkts/arkui/src/index.ts @@ -13,6 +13,7 @@ * limitations under the License. */ +// import { memoBind } from "@koalaui/runtime" export { Observed, observableProxy } from "@koalaui/common" export * from "@koalaui/arkui-common" @@ -25,4 +26,32 @@ export * from "./stateOf" export * from "./ForEach" export * from "./LazyForEach" export * from "./ohos.router" -export * from "./ArkNavigation" \ No newline at end of file +export * from "./ArkNavigation" + + + + +export declare function memoBind( + /** @memo */ + item: (arg: T) => void, value: T): + /** @memo */ + () => void; + + +export interface AiWallpaperDialogOptions { +} + + +export function bindCustomDialog( + /** @memo */ + item: (arg: T) => void, + value: T +): ()=>void { + return memoBind(item, value) +} + + +export interface AiWallpaperDialogReturnType { + build:()=>void; + buildOptions: AiWallpaperDialogOptions +} diff --git a/arkoala-arkts/arkui/types/index-full.d.ts b/arkoala-arkts/arkui/types/index-full.d.ts index 228f2bfde7bb613129437b24e7a0bbf5b35d0ae9..6e1f283cb0188e91b61dc85849ac732bbe082702 100644 --- a/arkoala-arkts/arkui/types/index-full.d.ts +++ b/arkoala-arkts/arkui/types/index-full.d.ts @@ -7388,9 +7388,24 @@ declare class ToggleAttribute extends CommonMethod { switchStyle(value: SwitchStyle): ToggleAttribute; _onChangeEvent_isOn(callback_: ((parameter: boolean) => void)): void; } +declare interface Colors { + +} + +declare type CustomColors = Partial; declare interface CustomTheme { - _CustomThemeStub: string; + /** + * Define tokens associated with color resources.. + * + * @type { ?CustomColors } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 12 + */ + colors?: CustomColors; } +declare const WithTheme: WithThemeInterface declare interface WithThemeOptions { theme?: CustomTheme; colorMode?: ThemeColorMode; @@ -9079,4 +9094,4 @@ declare const WaterFlowInstance: WaterFlowAttribute declare const UIExtensionComponent: UIExtensionComponentInterface declare const UIExtensionComponentInstance: UIExtensionComponentAttribute declare const LinearIndicator: LinearIndicatorInterface -declare const LinearIndicatorInstance: LinearIndicatorAttribute \ No newline at end of file +declare const LinearIndicatorInstance: LinearIndicatorAttribute diff --git a/arkoala-arkts/shopping/user/arktsconfig-run-unmemoized.json b/arkoala-arkts/shopping/user/arktsconfig-run-unmemoized.json index 26a55886841846bc07f570f8ee1eaf73ad6a30e4..e266c20920b9275aaa072ef5372661657d6c572e 100644 --- a/arkoala-arkts/shopping/user/arktsconfig-run-unmemoized.json +++ b/arkoala-arkts/shopping/user/arktsconfig-run-unmemoized.json @@ -1,5 +1,6 @@ { "compilerOptions": { + "noImplicitAny": true, "package": "@koalaui/user", "outDir": "build/abc", "baseUrl": ".", diff --git a/arkoala-arkts/shopping/user/src/Page.ts b/arkoala-arkts/shopping/user/src/Page similarity index 100% rename from arkoala-arkts/shopping/user/src/Page.ts rename to arkoala-arkts/shopping/user/src/Page diff --git a/arkoala-arkts/shopping/user/src/ets/@Builder.ets b/arkoala-arkts/shopping/user/src/ets/@Builder.ets new file mode 100644 index 0000000000000000000000000000000000000000..66231eec25e37920a2f3a461d21101c685c58777 --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/@Builder.ets @@ -0,0 +1,31 @@ +export const x: number = 5 + +@Component +struct CustomContentDialog { + @BuilderParam contentBuilder: () => void + + build() { + Column() { + + } + } +} + +@Entry +@Component +struct Page2 { + build() { + Column() { + CustomContentDialog({ + contentBuilder: this.hidden + }) + } + } + @Builder + hidden() { + Column() { + + } + } +} + diff --git a/arkoala-arkts/shopping/user/src/ets/@CustomBuilder.ets b/arkoala-arkts/shopping/user/src/ets/@CustomBuilder.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd01d4d79a3866a2773531569c5a83883e38babb --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/@CustomBuilder.ets @@ -0,0 +1,9 @@ + + + +@CustomDialog +export struct AiWallpaperDialog { + build(){ + + } +} diff --git a/arkoala-arkts/shopping/user/src/ets/@Provide.ets b/arkoala-arkts/shopping/user/src/ets/@Provide.ets new file mode 100644 index 0000000000000000000000000000000000000000..f949acb72d747985febfd79dc15455fa1ec11b81 --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/@Provide.ets @@ -0,0 +1,9 @@ +@Component +struct allow { + @Provide({ allowOverride: 'bar'}) bar:number = 1 + @Provide({ allowOverride: 'har'}) har:number = 1 + + build(){ + Text() + } +} \ No newline at end of file diff --git a/arkoala-arkts/shopping/user/src/ets/Private.ets b/arkoala-arkts/shopping/user/src/ets/Private.ets new file mode 100644 index 0000000000000000000000000000000000000000..6f6738b06bc40449b7d1b28be1873be414dafbd8 --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/Private.ets @@ -0,0 +1,28 @@ + + +@CustomDialog +export struct AiWallpaperDialog { + private disableService: boolean = false; + build(){ + Column(){ + + } + } +} + + +@Component +struct myprivate { + /* + cs:CustomDialogController = new CustomDialogController({ + builder: AiWallpaperDialog({ + disableService: true + }) + }) + */ + build(){ + AiWallpaperDialog({ + disableService: true + }) + } +} diff --git a/arkoala-arkts/shopping/user/src/ets/WithTheme.ets b/arkoala-arkts/shopping/user/src/ets/WithTheme.ets new file mode 100644 index 0000000000000000000000000000000000000000..13168ce15892c181faf08ded317c818586970024 --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/WithTheme.ets @@ -0,0 +1,26 @@ + + +import { CustomColors, CustomTheme, Theme } from '@ohos.arkui.theme' + +class CustomThemeImpl implements CustomTheme { + public colors?: CustomColors; + constructor(colors: CustomColors) { + this.colors = colors; + } +} + + +@Component +struct Customdia { + theme?: Theme | CustomTheme = new CustomThemeImpl({}); + themeColorMode?: ThemeColorMode = ThemeColorMode.SYSTEM; + build() { + WithTheme({ theme: this.theme, colorMode: this.themeColorMode }) { + Scroll() { + Column() { + + } + } + } + } +} diff --git a/arkoala-arkts/shopping/user/src/ets/dollar-dollar b/arkoala-arkts/shopping/user/src/ets/dollar-dollar new file mode 100644 index 0000000000000000000000000000000000000000..907c444dab76b54a4b4f76fe496ffed0c3981b77 --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/dollar-dollar @@ -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-arkts/shopping/user/src/ets/etsconfig.json b/arkoala-arkts/shopping/user/src/ets/etsconfig.json index 17f34867349cdedefcb25eb77fac20a324c0576a..2c235cd92e912d3643e03bf8154abc7bf751b05f 100644 --- a/arkoala-arkts/shopping/user/src/ets/etsconfig.json +++ b/arkoala-arkts/shopping/user/src/ets/etsconfig.json @@ -1,9 +1,11 @@ { "extends": "../../../../arkui/config/etsconfig-base.json", "include": [ - "./**/*.ets" + // "./**/*.ets" + "./@CustomBuilder.ets" ], "compilerOptions": { + "noImplicitAny": true, "types": [], "baseUrl": ".", "rootDirs": [ diff --git a/arkoala-arkts/shopping/user/src/ets/test.ets b/arkoala-arkts/shopping/user/src/ets/test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee5a80d5d7960349f339d1d956e96be3d1e6bee7 --- /dev/null +++ b/arkoala-arkts/shopping/user/src/ets/test.ets @@ -0,0 +1,2 @@ +import { x } from './@Builder' +let a = x + 5 \ No newline at end of file diff --git a/arkoala-arkts/shopping/user/tsconfig-unmemoize.json b/arkoala-arkts/shopping/user/tsconfig-unmemoize.json index 2abbabdde2f936ab1172c39bccee6d2e47bc60fb..02310e944a2cfd0aab7d5cd9931e610752731e50 100644 --- a/arkoala-arkts/shopping/user/tsconfig-unmemoize.json +++ b/arkoala-arkts/shopping/user/tsconfig-unmemoize.json @@ -1,6 +1,8 @@ { "extends": "@koalaui/build-common/tsconfig.json", "compilerOptions": { + "strict": true, + "noImplicitAny": true, "types": [], "plugins": [ { @@ -30,6 +32,9 @@ ], "app/*": [ "./build/generated/*" + ], + "@ohos.*": [ + "../../../arkoala/arkui-common/interface_sdk-js/api/@ohos.*" ] } }, diff --git a/arkoala/ets-plugin/src/ApiUtils.ts b/arkoala/ets-plugin/src/ApiUtils.ts index b469a9d12752177b97e78c8ecd24d9e01cdb9bba..b6e6437771fec23c32b2a5aaac3ca3af62f7a589 100644 --- a/arkoala/ets-plugin/src/ApiUtils.ts +++ b/arkoala/ets-plugin/src/ApiUtils.ts @@ -104,23 +104,23 @@ export function undefinedValue(): ts.Expression { return ts.factory.createIdentifier("undefined") } -export function partialForName(className: string) { - return ts.factory.createTypeReferenceNode( - "Partial", - [ - ts.factory.createTypeReferenceNode(className) - ] - ) -} - -export function partial(className: ts.Identifier) { - return ts.factory.createTypeReferenceNode( - "Partial", - [ - ts.factory.createTypeReferenceNode(ts.idText(className)) - ] - ) -} +// export function partialForName(className: string) { +// return ts.factory.createTypeReferenceNode( +// "Partial", +// [ +// ts.factory.createTypeReferenceNode(className) +// ] +// ) +// } + +// export function partial(className: ts.Identifier) { +// return ts.factory.createTypeReferenceNode( +// "Partial", +// [ +// ts.factory.createTypeReferenceNode(ts.idText(className)) +// ] +// ) +// } export function anyIfNoType(type: ts.TypeNode | undefined): ts.TypeNode { if (!type) return Any() diff --git a/arkoala/ets-plugin/src/CallTransformer.ts b/arkoala/ets-plugin/src/CallTransformer.ts index 78cae77ec41d61da33f9cc7c1f5ac47f443fa971..4f3e7126aecd17067651c653ee74b8b81345b3ca 100644 --- a/arkoala/ets-plugin/src/CallTransformer.ts +++ b/arkoala/ets-plugin/src/CallTransformer.ts @@ -108,18 +108,38 @@ export class CallTransformer extends AbstractVisitor { const builderLambdaRedirect = findBuilderLambdaRedirect(this.typechecker, node) if (builderLambdaRedirect) { this.callTable.builderLambdas.set(node, builderLambdaRedirect) + // this.callTable.builderLambdas.forEach((value, key) => { + // const callText = key.getText(key.getSourceFile()); + // console.log(`findBuilderLambdaRedirect: Key (CallExpression Text): ${callText}`); + // console.log(`Value: ${value}`); + // }); } if (this.refersToGlobalBuilder(node)) { this.callTable.globalBuilderCalls.add(node) + // this.callTable.globalBuilderCalls.forEach((value, key) => { + // const callText = key.getText(key.getSourceFile()); + // console.log(`refersToGlobalBuilder: Key (CallExpression Text): ${callText}`); + // console.log(`Value: ${value}`); + // }); } if (this.isLegacyCall(node.expression)) { this.callTable.legacyCalls.add(node) + // this.callTable.legacyCalls.forEach((value, key) => { + // const callText = key.getText(key.getSourceFile()); + // console.log(`isLegacyCall: Key (CallExpression Text): ${callText}`); + // console.log(`Value: ${value}`); + // }); } if (this.isComponentStructCall(node.expression)) { this.callTable.structCalls.add(ts.getOriginalNode(node) as ts.CallExpression) + // this.callTable.structCalls.forEach((value, key) => { + // const callText = key.getText(key.getSourceFile()); + // console.log(`isComponentStructCall: Key (CallExpression Text): ${callText}`); + // console.log(`Value: ${value}`); + // }); } } diff --git a/arkoala/ets-plugin/src/CustomBuilderTransformer.ts b/arkoala/ets-plugin/src/CustomBuilderTransformer.ts index bd2ba6d694b54a4e82a357443e907817b0b1ab89..254d7263c2f989c79a3a8561ae594456d73e3d06 100644 --- a/arkoala/ets-plugin/src/CustomBuilderTransformer.ts +++ b/arkoala/ets-plugin/src/CustomBuilderTransformer.ts @@ -97,6 +97,11 @@ export class CustomBuilderTransformer extends AbstractVisitor { this.isBuilderCall(node) && !this.parentIsStatement(node) ) { + const indent = ' '.repeat(1); + console.log(`${indent} CustomBuilderTransformer.ts Node:`); + console.log(`${indent} Kind: ${ts.SyntaxKind[node.kind]}`); + console.log(`${indent} Flags: ${ts.NodeFlags[node.flags]}`); + return this.wrapInMemoLambda(node) } diff --git a/arkoala/ets-plugin/src/DollarTransformer.ts b/arkoala/ets-plugin/src/DollarTransformer.ts index caac6830f671108fa7611fdd0c3ac129ea539d6b..754ab33580c4dfcf3796da72986c98eaa535040d 100644 --- a/arkoala/ets-plugin/src/DollarTransformer.ts +++ b/arkoala/ets-plugin/src/DollarTransformer.ts @@ -52,6 +52,10 @@ export class DollarTransformer extends AbstractVisitor { transformDollarVariableAccess(node: ts.Identifier): ts.Expression { this.nameTable.dollars.push(ts.idText(node)) + // for (const dollar of this.nameTable.dollars) { + // // 打印每个元素 + // console.log(dollar); + // } return ts.factory.createPropertyAccessExpression( ts.factory.createThis(), node diff --git a/arkoala/ets-plugin/src/LegacyCallTransformer.ts b/arkoala/ets-plugin/src/LegacyCallTransformer.ts index e8fcf623fc52866a1cb679e28d2a592f01f337ba..f1d97d7f1ebfb452a0680f9b2c0a72b23444b9ad 100644 --- a/arkoala/ets-plugin/src/LegacyCallTransformer.ts +++ b/arkoala/ets-plugin/src/LegacyCallTransformer.ts @@ -35,6 +35,26 @@ export class LegacyCallTransformer extends AbstractVisitor { isLegacyStructCall(call: ts.CallExpression): boolean { const originalCall = ts.getOriginalNode(call) as ts.CallExpression + // console.log('CallExpression found:'); + // console.log(` Text: ${call.getText()}`); + // console.log(` Start: ${call.getStart()}`); + // console.log(` End: ${call.getEnd()}`); + + // const expression = call.expression; + // console.log(` Expression (function name or object):`); + // console.log(` Text: ${expression.getText()}`); + + // const argumentsArray = call.arguments; + // console.log(' Arguments:'); + // argumentsArray.forEach((arg, index) => { + // console.log(` Argument ${index + 1}:`); + // console.log(` Text: ${arg.getText()}`); + // }); + + // console.log('Original CallExpression found:'); + // console.log(` Text: ${originalCall.getText()}`); + // console.log(` Text: ${expression.getText()}`); + return this.callTable.legacyCalls.has(originalCall) } diff --git a/arkoala/ets-plugin/src/StructTransformer.ts b/arkoala/ets-plugin/src/StructTransformer.ts index 289e041a33357ad80b8b4d7b4aaab8f5e93454ce..07a0d1cb5df22f4846fda71f89bc0c8029ffb642 100644 --- a/arkoala/ets-plugin/src/StructTransformer.ts +++ b/arkoala/ets-plugin/src/StructTransformer.ts @@ -667,17 +667,19 @@ export class StructTransformer extends AbstractVisitor { [ parameter( id("initializer"), - ts.factory.createTypeReferenceNode( - ts.factory.createIdentifier("Partial"), - [ts.factory.createTypeReferenceNode( - this.translateComponentName(adaptorClassName(node.name))!, - undefined - )] - ), + // ts.factory.createTypeReferenceNode( + // ts.factory.createIdentifier("Partial"), + // [ts.factory.createTypeReferenceNode( + // this.translateComponentName(adaptorClassName(node.name))!, + // undefined + // )] + // ), + this.structOptions.createTypeReference(node), ts.factory.createObjectLiteralExpression() ) ], - undefined, + // ts.factory.createTypeReferenceNode(id(this.importer.withAdaptorImport(node.name?.getText() + "ReturnType")), undefined), + ts.factory.createTypeReferenceNode(id(node.name?.getText() + "ReturnType"), undefined), ts.factory.createBlock( [ ts.factory.createReturnStatement( @@ -791,6 +793,28 @@ export class StructTransformer extends AbstractVisitor { const className = this.translateComponentName(adaptorClassName(node.name)) // TODO make me string for proper reuse const baseClassName = this.importer.withAdaptorImport("ArkStructBase") this.createOptionsDeclaration(node) + this.topLevelInitialization.push( + ts.factory.createInterfaceDeclaration( + [ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], + id(node.name?.getText() + "ReturnType"), + [], + [], + [ + ts.factory.createPropertySignature( + undefined, // 修饰符 + 'build', // 属性名 + undefined, // 可选标记 + ts.factory.createTypeReferenceNode(id("() => void"), undefined), // 属性类型 + ), + ts.factory.createPropertySignature( + undefined, // 修饰符 + 'buildOptions', // 属性名 + undefined, // 可选标记 + ts.factory.createTypeReferenceNode(id(node.name?.getText() + "Options"), undefined), // 属性类型 + ) + ] + ) + ) let entryLocalStorage: ts.Expression | undefined = undefined diff --git a/arkoala/ets-plugin/src/StyleTransformer.ts b/arkoala/ets-plugin/src/StyleTransformer.ts index 169a8b0c69d2a436f89ba0876e5447f5d581db4a..1c3ea56ed151cee9ed79457e7da2bf95675340b2 100644 --- a/arkoala/ets-plugin/src/StyleTransformer.ts +++ b/arkoala/ets-plugin/src/StyleTransformer.ts @@ -242,6 +242,8 @@ export class EtsFirstArgTransformer extends AbstractVisitor { const node = this.visitEachChild(beforeChildren) if (ts.isEtsComponentExpression(node)) { const casted = this.castIfComponentInitialization(node) + // console.log(casted.expression.getText()) + // console.log(casted.expression.getText()) return ts.factory.updateEtsComponentExpression( casted, casted.expression, diff --git a/arkoala/ets-plugin/src/utils.ts b/arkoala/ets-plugin/src/utils.ts index 5ac9f4c700424e71f99f57d1962829f45751e1f3..5f1ba6ef4a5f8c10d7889f3e7e25cbedc8d6ba6c 100644 --- a/arkoala/ets-plugin/src/utils.ts +++ b/arkoala/ets-plugin/src/utils.ts @@ -274,13 +274,25 @@ export function deduceProvideConsumeName(property: ts.PropertyDeclaration, name: } // @Provide({ allowOverride: 'bar'}) bar if (ts.isObjectLiteralExpression(arg)) { - return (arg as ts.ObjectLiteralExpression).properties - .filter( - (property) => - ts.isPropertyAssignment(property) && - property.name.getText() === "allowOveride" - ) - .map((p) => (p as ts.PropertyAssignment).initializer.getText())[0]; + // return (arg as ts.ObjectLiteralExpression).properties + // .filter( + // (property) => + // ts.isPropertyAssignment(property) && + // property.name.getText() === "allowOveride" + // ) + // .map((p) => (p as ts.PropertyAssignment).initializer.getText())[0]; + const propertiesName = (arg as ts.ObjectLiteralExpression).properties + .filter( + (property) => + ts.isPropertyAssignment(property) && + property.name.getText() === "allowOverride" + ) + if (propertiesName.length > 0) { + const arg = propertiesName[0] as ts.PropertyAssignment + if (ts.isStringLiteral(arg.initializer)) { + return arg.initializer.text + } + } } }