| 1301 | } |
| 1302 | |
| 1303 | // NOLINTNEXTLINE(readability-convert-member-functions-to-static) |
| 1304 | JSValueRef JavaScriptRuntime::runtimeBytesToString(JSFunctionNativeCallContext& callContext) { |
| 1305 | auto convertedBytes = |
| 1306 | callContext.getContext().valueToTypedArray(callContext.getParameter(0), callContext.getExceptionTracker()); |
| 1307 | CHECK_CALL_CONTEXT(callContext); |
| 1308 | |
| 1309 | return callContext.getContext().newStringUTF8( |
| 1310 | std::string_view(reinterpret_cast<const char*>(convertedBytes.data), convertedBytes.length), |
| 1311 | callContext.getExceptionTracker()); |
| 1312 | } |
| 1313 | |
| 1314 | JSValueRef JavaScriptRuntime::runtimeIsModuleLoaded(JSFunctionNativeCallContext& callContext) { |
| 1315 | auto moduleName = callContext.getParameterAsString(0); |
| 1316 | CHECK_CALL_CONTEXT(callContext); |
| 1317 | |
| 1318 | auto moduleLoaded = _resourceManager.isBundleLoaded(moduleName); |
| 1319 | return callContext.getContext().newBool(moduleLoaded); |
| 1320 | } |
| 1321 | |
| 1322 | JSValueRef JavaScriptRuntime::runtimeGetModuleEntry(JSFunctionNativeCallContext& callContext) { |
| 1323 | auto moduleName = callContext.getParameterAsString(0); |
| 1324 | CHECK_CALL_CONTEXT(callContext); |
| 1325 | |
| 1326 | auto path = callContext.getParameterAsString(1); |
| 1327 | CHECK_CALL_CONTEXT(callContext); |
| 1328 | |
| 1329 | auto asString = callContext.getParameterAsBool(2); |
| 1330 | CHECK_CALL_CONTEXT(callContext); |
| 1331 | |
| 1332 | auto bundle = _resourceManager.getBundle(moduleName); |
| 1333 | |
| 1334 | if (bundle->hasRemoteArchiveNeedingLoad()) { |
| 1335 | return callContext.throwError( |
| 1336 | Error(STRING_FORMAT("Bundle '{}' is a remote bundle which was not loaded", moduleName))); |
| 1337 | } |
| 1338 | |
| 1339 | auto entry = bundle->getEntry(path); |
| 1340 | if (!entry) { |
| 1341 | return callContext.throwError(entry.moveError()); |
| 1342 | } |
| 1343 | |
| 1344 | if (asString) { |
| 1345 | return callContext.getContext().newStringUTF8(entry.value().asStringView(), callContext.getExceptionTracker()); |
| 1346 | } else { |
| 1347 | return newTypedArrayFromBytesView( |
| 1348 | callContext.getContext(), TypedArrayType::Uint8Array, entry.value(), callContext.getExceptionTracker()); |
| 1349 | } |
| 1350 | } |
| 1351 | |
| 1352 | JSValueRef JavaScriptRuntime::runtimeGetModuleJsPaths(JSFunctionNativeCallContext& callContext) { |
| 1353 | auto moduleName = callContext.getParameterAsString(0); |
| 1354 | CHECK_CALL_CONTEXT(callContext); |
nothing calls this directly
no test coverage detected