diff --git a/interop/src/interop/loadLibraries.ts b/interop/src/interop/loadLibraries.ts index be37ebb229c89adaf63f31f7f2318b8104706363..ca9e6515d44453a4edfd825ce9773fcd150db141 100644 --- a/interop/src/interop/loadLibraries.ts +++ b/interop/src/interop/loadLibraries.ts @@ -1,18 +1,8 @@ -import * as path from "path" -import * as process from "process" -import * as os from "os" +import { loadLibrary } from "#platform/loader" const nativeModulesToLoad: Map = new Map() const lateInitNativeModules: Map = new Map() -function loadLibrary(name: string): Record { - const libPath = path.resolve(name + ".node"); // TODO lib dir, support es6 modules, etc. - console.debug("Loading native library from " + libPath) - const exports = {} - ;(process as any).dlopen({ exports }, libPath, (os.constants as any).dlopen.RTLD_NOW) ; //TODO fix @types/node - return exports -} - export function loadLibraries(libraries: string[]) { for (const lib of libraries) { const modules = loadLibrary(lib) diff --git a/interop/src/node/loader.ts b/interop/src/node/loader.ts new file mode 100644 index 0000000000000000000000000000000000000000..9008e568dcea86d182507647f4fde1b1b3e37c11 --- /dev/null +++ b/interop/src/node/loader.ts @@ -0,0 +1,11 @@ +import * as path from "path" +import * as process from "process" +import * as os from "os" + +export function loadLibrary(name: string): Record { + const libPath = path.resolve(name + ".node"); // TODO lib dir, support es6 modules, etc. + console.debug("Loading native library from " + libPath) + const exports = {} + ;(process as any).dlopen({ exports }, libPath, (os.constants as any).dlopen.RTLD_NOW) ; //TODO fix @types/node + return exports +} diff --git a/interop/src/ohos/loader.ts b/interop/src/ohos/loader.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa4949204670d693d6c79bdd9755cdd6cde05301 --- /dev/null +++ b/interop/src/ohos/loader.ts @@ -0,0 +1,3 @@ +export function loadLibrary(name: string): Record { + return requireNapi(name) +} diff --git a/interop/tsconfig.json b/interop/tsconfig.json index 61ede472fe8bd72750f9015c99838aee1543d49a..a920ec7b2eebf2c120f87837932efec0b0d697ce 100644 --- a/interop/tsconfig.json +++ b/interop/tsconfig.json @@ -19,7 +19,8 @@ "types": ["node"], "paths": { "@koalaui/common": ["../incremental/common/src"], - "#common/wrappers/*": ["./src/napi/wrappers/*", "./src/wasm/wrappers/*"] + "#common/wrappers/*": ["./src/napi/wrappers/*", "./src/wasm/wrappers/*"], + "#platform/*": ["./src/ohos/*", "./src/node/*"] } }, "include": ["src/**/*"],