diff --git a/arkoala-arkts/arkui/src/generated/arkts/index.ts b/arkoala-arkts/arkui/src/generated/arkts/index.ts index 69e843017a623c1def8445f0326290ba4649c3ab..0120a72b119507555d1a23b468fdc7f702316f10 100644 --- a/arkoala-arkts/arkui/src/generated/arkts/index.ts +++ b/arkoala-arkts/arkui/src/generated/arkts/index.ts @@ -1,4 +1,5 @@ export * from "./type_check" export * from "./ArkUINativeModule" export * from "./ArkUIGeneratedNativeModule" -export * from "./TestNativeModule" \ No newline at end of file +export * from "./TestNativeModule" +export * from "./ohos.arkui.inspector" \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/generated/arkts/ohos.arkui.inspector.ts b/arkoala-arkts/arkui/src/generated/arkts/ohos.arkui.inspector.ts new file mode 100644 index 0000000000000000000000000000000000000000..f053d1e0627ee24940861b8e7ec74c2228196c37 --- /dev/null +++ b/arkoala-arkts/arkui/src/generated/arkts/ohos.arkui.inspector.ts @@ -0,0 +1,22 @@ +import { loadNativeModuleLibrary } from "@koalaui/interop" + +export class ComponentObserver { + private nativeComponentObserver: long = 0; + + constructor(nativeAddr: long) { + if (this.nativeComponentObserver == 0) { + this.nativeComponentObserver = nativeAddr; + } + } + + public native on(type: string, callback: ()=>void) : void; + + public native off(type: string, callback?: ()=>void) : void; +} + +export class Inspector { + static { + loadNativeModuleLibrary("inspector_ani"); + } + native static createComponentObserver(id: string): ComponentObserver; +} \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/generated/ts/index.ts b/arkoala-arkts/arkui/src/generated/ts/index.ts index 4aedac570509d75071616798bc5674fc540db6f3..0120a72b119507555d1a23b468fdc7f702316f10 100644 --- a/arkoala-arkts/arkui/src/generated/ts/index.ts +++ b/arkoala-arkts/arkui/src/generated/ts/index.ts @@ -2,3 +2,4 @@ export * from "./type_check" export * from "./ArkUINativeModule" export * from "./ArkUIGeneratedNativeModule" export * from "./TestNativeModule" +export * from "./ohos.arkui.inspector" \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/generated/ts/ohos.arkui.inspector.ts b/arkoala-arkts/arkui/src/generated/ts/ohos.arkui.inspector.ts new file mode 100644 index 0000000000000000000000000000000000000000..842a6451475adab7ec578690f5d75a7be72cb761 --- /dev/null +++ b/arkoala-arkts/arkui/src/generated/ts/ohos.arkui.inspector.ts @@ -0,0 +1,6 @@ +export const Inspector: any = undefined + +export interface ComponentObserver { + on(type: string, callback: ()=>void) : void; + off(type: string, callback?: ()=>void) : void; +} \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/ohos.arkui.UIContext.ts b/arkoala-arkts/arkui/src/ohos.arkui.UIContext.ts index 83db5d1ce8cee002da9372c418a92491b7061996..1560ed2563b2519ebcdb061f79a6ecf101c8e8e8 100644 --- a/arkoala-arkts/arkui/src/ohos.arkui.UIContext.ts +++ b/arkoala-arkts/arkui/src/ohos.arkui.UIContext.ts @@ -21,7 +21,7 @@ import { GlobalScope_ohos_font } from "./generated/ArkGlobalScopeOhosFontMateria import { GlobalScope_ohos_measure_utils } from "./generated/ArkGlobalScopeOhosMeasureUtilsMaterialized" import { FontOptions, FontInfo, MeasureOptions } from "./generated/ArkArkuiExternalInterfaces" import { SizeOptions } from "./generated/ArkUnitsInterfaces" -import { ArkUIGeneratedNativeModule } from "#components" +import { ArkUIGeneratedNativeModule, Inspector, ComponentObserver } from "#components" import { int32 } from "@koalaui/common" import { nullptr } from "@koalaui/interop" @@ -69,6 +69,19 @@ export class MeasureUtils { } } +export class UIInspector { + instanceId_: int32 = 100000; + constructor(instanceId: int32) { + this.instanceId_ = instanceId; + } + public createComponentObserver(id: string): ComponentObserver { + ArkUIGeneratedNativeModule._SystemOps_syncInstanceId(this.instanceId_); + let componentObserver = Inspector.createComponentObserver(id); + ArkUIGeneratedNativeModule._SystemOps_restoreInstanceId(); + return componentObserver; + } +} + export class UIContext { instanceId_: int32 = 100000; constructor(instanceId: int32) { @@ -95,6 +108,10 @@ export class UIContext { ArkUIGeneratedNativeModule._SystemOps_restoreInstanceId(); return null; } + public getUIInspector(): UIInspector { + let uiInspector = new UIInspector(this.instanceId_); + return uiInspector; + } } export abstract class FrameCallback { abstract onFrame(frameTimeInNano: number): void; diff --git a/arkoala-arkts/arkui/types/index-full.d.ts b/arkoala-arkts/arkui/types/index-full.d.ts index 4de299b586003113694f51a0117a53011987d4fe..d47f74525133328355a571efdef600cba7d00386 100644 --- a/arkoala-arkts/arkui/types/index-full.d.ts +++ b/arkoala-arkts/arkui/types/index-full.d.ts @@ -2466,6 +2466,13 @@ declare interface RouterPageInfo { declare interface UIContext { _UIContextStub: string; } +declare interface ComponentObserver { + on(type: string, callback: ()=>void) : void; + off(type: string, callback?: ()=>void) : void; +} +declare interface UIInspector { + createComponentObserver(id: string): ComponentObserver; +} declare interface DrawContext { _DrawContextStub: string; }