1
import { NativeModuleEmpty } from "./NativeModuleEmpty"
4
providePlatformDefinedData,
10
} from "@koalaui/interop"
12
export type NodePointer = pointer
13
export type PipelineContext = pointer
15
let theModule: NativeModule | undefined = undefined
17
declare const LOAD_NATIVE: NativeModule
19
export function nativeModule(): NativeModule {
20
if (theModule) return theModule
22
theModule = new NativeModuleEmpty()
24
theModule = LOAD_NATIVE as NativeModule
28
class NativeString extends NativeStringBase {
29
constructor(ptr: KPointer) {
32
protected bytesLength(): int32 {
33
return nativeModule()._StringLength(this.ptr)
35
protected getData(data: Uint8Array): void {
36
withByteArray(data, Access.WRITE, (dataPtr: KUint8ArrayPtr) => {
37
nativeModule()._StringData(this.ptr, dataPtr, data.length)
41
nativeModule()._InvokeFinalizer(this.ptr, nativeModule()._GetStringFinalizer())
46
providePlatformDefinedData({
47
nativeString(ptr: KPointer): NativeStringBase { return new NativeString(ptr) },
48
nativeStringArrayDecoder(): ArrayDecoder<NativeStringBase> { throw new Error("Not implemented") },
49
callbackRegistry(): CallbackRegistry | undefined { return undefined }
52
export interface InteropOps {
53
_GetGroupedLog(index: KInt): KPointer
54
_StartGroupedLog(index: KInt): void
55
_StopGroupedLog(index: KInt): void
56
_GetStringFinalizer(): KPointer
57
_InvokeFinalizer(ptr: KPointer, finalizer: KPointer): void
58
_GetNodeFinalizer(): KPointer
59
_StringLength(ptr: KPointer): KInt
60
_StringData(ptr: KPointer, buffer: KUint8ArrayPtr, length: KInt): void
61
_StringMake(value: KStringPtr): KPointer
62
_ManagedStringWrite(value: KStringPtr, buffer: KUint8ArrayPtr, offset: KInt): KInt
63
_Test_SetEventsApi(): void
64
_Test_Common_OnChildTouchTest(valueArray: Uint8Array, valueSerializerLength: KInt): void
65
_Test_List_OnScrollVisibleContentChange(valueArray: Uint8Array, valueSerializerLength: KInt): void
66
_Test_TextPicker_OnAccept(valueArray: Uint8Array, valueSerializerLength: KInt): void
67
_TestPerfNumber(value: KInt): KInt
68
_TestPerfNumberWithArray(value: KUint8ArrayPtr, length: KInt): void
69
_StartPerf(traceName: KStringPtr): void
70
_EndPerf(traceName: KStringPtr): void
71
_DumpPerf(options: KInt): KPointer
74
export interface GraphicsOps {
75
// TODO fill me if needed
78
export interface NodeOps {
79
_CreateNode(type: KInt, id: KInt, flags: KInt): NodePointer
80
_GetNodeByViewStack(): NodePointer
81
_DisposeNode(ptr: NodePointer): void
83
_AddChild(parent: NodePointer, child: NodePointer): KInt
84
_RemoveChild(parent: NodePointer, child: NodePointer): void
85
_InsertChildAfter(parent: NodePointer, child: NodePointer, sibling: NodePointer): KInt
86
_InsertChildBefore(parent: NodePointer, child: NodePointer, sibling: NodePointer): KInt
87
_InsertChildAt(parent: NodePointer, child: NodePointer, position: KInt): KInt
88
_ApplyModifierFinish(ptr: NodePointer): void
89
_MarkDirty(ptr: NodePointer, flag: KUInt): void
90
_IsBuilderNode(ptr: NodePointer): KBoolean
91
_ConvertLengthMetricsUnit(value: KFloat, originUnit: KInt, targetUnit: KInt): KFloat
95
// getCanvasRenderingContext2DModifier
98
// setCustomMethodFlag
100
// registerCustomNodeAsyncEvent
101
// unregisterCustomNodeAsyncEvent
102
// registerCustomNodeAsyncEventReceiver
104
// #region EXTENDED NODE
105
_SetCustomCallback(node: NodePointer, callbackId: KInt): void
106
_MeasureLayoutAndDraw(root: NodePointer): void
107
_MeasureNode(root: NodePointer, data: KFloat32ArrayPtr): KInt
108
_LayoutNode(root: NodePointer, data: KFloat32ArrayPtr): KInt
109
_DrawNode(root: NodePointer, data: KFloat32ArrayPtr): KInt
114
_SetMeasureWidth(root: NodePointer, value: KInt): void
115
_GetMeasureWidth(root: NodePointer): KInt
116
_SetMeasureHeight(root: NodePointer, value: KInt): void
117
_GetMeasureHeight(root: NodePointer): KInt
118
_SetX(root: NodePointer, value: KInt): void
119
_GetX(root: NodePointer): KInt
120
_SetY(root: NodePointer, value: KInt): void
121
_GetY(root: NodePointer): KInt
123
// getLayoutConstraint
125
_SetAlignment(root: NodePointer, value: KInt): void
126
_GetAlignment(root: NodePointer): KInt
128
_IndexerChecker(node: NodePointer): KInt
130
_SetRangeUpdater(node: NodePointer, updaterId: KInt): void
131
_SetLazyItemIndexer(node: NodePointer, indexerId: KInt): KInt
133
_GetPipelineContext(nodePtr:NodePointer): PipelineContext
135
_SetVsyncCallback(pipelineContext: PipelineContext, callbackId: KInt): KInt
136
_UnblockVsyncWait(pipelineContext: PipelineContext): KInt
138
_SetChildTotalCount(ptr: NodePointer, value: KInt): void
139
_ShowCrash(messagePtr: KStringPtr): void
142
export interface ComponentOps {
146
export interface NativeModuleIntegrated extends InteropOps, /*GraphicsOps, NodeOps,*/ ComponentOps {}
147
export interface NativeModule extends InteropOps, GraphicsOps, NodeOps, ComponentOps {}