diff --git a/native_engine/impl/ark/ark_native_engine.cpp b/native_engine/impl/ark/ark_native_engine.cpp index 6bf8e4b559c34cf85077671417427241dce3fcab..1d45cf8bc04be30724aea82d8009295020fab8bf 100644 --- a/native_engine/impl/ark/ark_native_engine.cpp +++ b/native_engine/impl/ark/ark_native_engine.cpp @@ -1449,45 +1449,17 @@ Local ArkNativeEngine::NapiLoadNativeModule(std::string path) return panda::JSNApi::ExecuteNativeModule(vm_, key); } -ModuleTypes ArkNativeEngine::CheckLoadType(const std::string &path) -{ - if (path[0] == '@') { - return ModuleTypes::NATIVE_MODULE; - } else if (path.find("ets/") == 0) { // ets/xxx/xxx - return ModuleTypes::MODULE_INNER_FILE; - } - return ModuleTypes::UNKNOWN; -} - -napi_value ArkNativeEngine::NapiLoadModule(const char* path, const char* module_info) +napi_value ArkNativeEngine::NapiLoadModule(const char* path) { if (path == nullptr) { HILOG_ERROR("ArkNativeEngine:The module name is empty"); return nullptr; } panda::EscapeLocalScope scope(vm_); - Local undefObj = JSValueRef::Undefined(vm_); - Local exportObj(undefObj); std::string inputPath(path); - std::string modulePath; - if (module_info != nullptr) { - modulePath = module_info; - } - switch (CheckLoadType(inputPath)) { - case ModuleTypes::NATIVE_MODULE: { - exportObj = NapiLoadNativeModule(inputPath); - break; - } - case ModuleTypes::MODULE_INNER_FILE: { - exportObj = panda::JSNApi::GetModuleNameSpaceFromFile(vm_, inputPath, modulePath); - break; - } - default: { - std::string msg = "ArkNativeEngine:NapiLoadModule input path:" + inputPath + " is invalid."; - ThrowException(msg.c_str()); - } - } + Local exportObj = panda::JSNApi::GetModuleNameSpaceFromFile(vm_, inputPath); if (!exportObj->IsObject(vm_)) { + Local undefObj = JSValueRef::Undefined(vm_); ThrowException("ArkNativeEngine:NapiLoadModule failed."); return JsValueFromLocalValue(scope.Escape(undefObj)); } diff --git a/native_engine/impl/ark/ark_native_engine.h b/native_engine/impl/ark/ark_native_engine.h index 9dc931390ea1479e128ad0b2f6bf1b0ffa77fd3f..c9686c66d80249dc8d0e8a9e12888886bb07ac4b 100644 --- a/native_engine/impl/ark/ark_native_engine.h +++ b/native_engine/impl/ark/ark_native_engine.h @@ -307,11 +307,10 @@ public: panda::Local GetModuleFromName( const std::string& moduleName, bool isAppModule, const std::string& id, const std::string& param, const std::string& instanceName, void** instance); - napi_value NapiLoadModule(const char* path, const char* module_info) override; + napi_value NapiLoadModule(const char* path) override; napi_value NapiLoadModuleWithInfo(const char* path, const char* module_info) override; std::string GetOhmurl(std::string str); Local NapiLoadNativeModule(std::string path); - ModuleTypes CheckLoadType(const std::string &path); NativeReference* GetPromiseRejectCallBackRef() { return promiseRejectCallbackRef_; diff --git a/native_engine/native_api.cpp b/native_engine/native_api.cpp index caabfc121bd23397f2214251b840185128bd2c5c..dc118d1b9b559149070249240e228789d6533533 100644 --- a/native_engine/native_api.cpp +++ b/native_engine/native_api.cpp @@ -2995,7 +2995,7 @@ NAPI_EXTERN napi_status napi_load_module(napi_env env, const char* path, napi_va NAPI_PREAMBLE(env); CHECK_ARG(env, result); auto engine = reinterpret_cast(env); - *result = engine->NapiLoadModule(path, nullptr); + *result = engine->NapiLoadModule(path); return GET_RETURN_STATUS(env); } diff --git a/native_engine/native_engine.h b/native_engine/native_engine.h index 1169b569d3aae1b76764330d77cdc886b295a2f6..60de897f2878ad104f48a535d4432c47080eac84 100644 --- a/native_engine/native_engine.h +++ b/native_engine/native_engine.h @@ -447,7 +447,7 @@ public: */ void SetModuleLoadChecker(const std::shared_ptr& moduleCheckerDelegate); - virtual napi_value NapiLoadModule(const char* path, const char* module_info) = 0; + virtual napi_value NapiLoadModule(const char* path) = 0; virtual napi_value NapiLoadModuleWithInfo(const char* path, const char* module_info) = 0; virtual std::string GetPkgName(const std::string &moduleName) = 0;