1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ECMASCRIPT_MODULE_NAPI_MODULE_LOADER_H 17 #define ECMASCRIPT_MODULE_NAPI_MODULE_LOADER_H 18 19 #include "ecmascript/js_tagged_value-inl.h" 20 namespace panda::ecmascript { 21 class NapiModuleLoader { 22 public: 23 template<ForHybridApp isHybrid = ForHybridApp::Normal> 24 static JSHandle<JSTaggedValue> LoadModuleNameSpace(EcmaVM *vm, CString requestPath, const CString &moduleName, 25 CString &abcFilePath); 26 template<ForHybridApp isHybrid = ForHybridApp::Normal> 27 static JSHandle<JSTaggedValue> LoadModuleNameSpace(EcmaVM *vm, CString requestPath, 28 CString modulePath); 29 30 static JSHandle<JSTaggedValue> GetModuleNameSpace(JSThread *thread, const CString &entryPoint, 31 const CString &abcFilePath); 32 33 template<ForHybridApp isHybrid = ForHybridApp::Normal> 34 static JSHandle<JSTaggedValue> LoadModuleNameSpaceFromFile(JSThread *thread, const CString &entryPoint, 35 const CString &abcFilePath); 36 private: 37 template<ForHybridApp isHybrid = ForHybridApp::Normal> 38 static JSHandle<JSTaggedValue> LoadModuleNameSpaceWithModuleInfo( 39 EcmaVM *vm, CString &requestPath, CString &modulePath, 40 CString &abcFilePath); 41 42 static JSHandle<JSTaggedValue> LoadModuleNameSpaceWithPath( 43 JSThread *thread, CString &abcFilePath, const CString &requestPath, 44 const CString &modulePath, const JSPandaFile *pandaFile); 45 46 template<ForHybridApp isHybrid = ForHybridApp::Normal> 47 static JSHandle<JSTaggedValue> LoadFilePathWithinModule( 48 JSThread *thread, const CString &abcFilePath, const CString &srcPrefix, 49 const CString &requestPath, const CString &modulePath); 50 }; 51 } 52 53 #endif // ECMASCRIPT_MODULE_NAPI_MODULE_LOADER_H