#include "napi/native_api.h"
#include "GLCanvasManager/GLCanvasManager.h"

//using namespace NativeXComponentSample;

EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports)
{
    napi_property_descriptor desc[] = {
        { "CreateSurface", nullptr, GLCanvasManager::SetSurfaceId, nullptr, nullptr, nullptr, napi_default, nullptr },
        { "ChangeSurface", nullptr, GLCanvasManager::ChangeSurface, nullptr, nullptr, nullptr, napi_default, nullptr },
        { "DestroySurface", nullptr, GLCanvasManager::DestroySurface, nullptr, nullptr, nullptr, napi_default, nullptr },
        { "AddShader", nullptr, GLCanvasManager::AddShader, nullptr, nullptr, nullptr, napi_default, nullptr },
        { "RemoveShader", nullptr, GLCanvasManager::RemoveShader, nullptr, nullptr, nullptr, napi_default, nullptr },
        { "SetData", nullptr, GLCanvasManager::SetData, nullptr, nullptr, nullptr, napi_default, nullptr },
        { "LoadImage", nullptr, GLCanvasManager::LoadImage, nullptr, nullptr, nullptr, napi_default, nullptr },
        { "OnProgress", nullptr, GLCanvasManager::OnProgress, nullptr, nullptr, nullptr, napi_default, nullptr },
        { "GetContext", nullptr, GLCanvasManager::GetContext, nullptr, nullptr, nullptr, napi_default, nullptr }
    };
    napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
    return exports;
}
EXTERN_C_END

static napi_module demoModule = {
    .nm_version = 1,
    .nm_flags = 0,
    .nm_filename = nullptr,
    .nm_register_func = Init,
    .nm_modname = "glnative",
    .nm_priv = ((void*)0),
    .reserved = { 0 },
};

extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
{
    napi_module_register(&demoModule);
}
