| 184 | auto moduleIndex = runtime->getJavaScriptRuntime()->pushModuleToMarshaller( |
| 185 | nativeObjectsManager, StringCache::getGlobal().makeString(moduleName), marshaller); |
| 186 | if (!exceptionTracker) { |
| 187 | return Error(STRING_FORMAT("Couldn't resolve module '{}'", moduleName)); |
| 188 | } |
| 189 | |
| 190 | return marshaller.get(moduleIndex); |
| 191 | } |
| 192 | |
| 193 | static Result<Value> getJsModulePropertyWithSchema( |
| 194 | Runtime* runtime, |
| 195 | const std::shared_ptr<snap::valdi_core::JSRuntimeNativeObjectsManager>& nativeObjectsManager, |
| 196 | ValueSchemaRegistry* registry, |
| 197 | std::string_view moduleName, |
| 198 | std::string_view propertyName, |
| 199 | std::string_view propertySchema) { |
| 200 | auto propertySchemaResult = ValueSchema::parse(propertySchema); |
| 201 | if (!propertySchemaResult) { |
| 202 | return propertySchemaResult.moveError(); |
| 203 | } |
| 204 | |
| 205 | auto schema = ValueSchema::cls( |
| 206 | STRING_LITERAL("JSModule"), |
| 207 | false, |
| 208 | {ClassPropertySchema(StringCache::getGlobal().makeString(propertyName), propertySchemaResult.value())}); |
| 209 | |
| 210 | auto unmarshalledJsModule = getJsModuleWithSchema(runtime, nativeObjectsManager, registry, moduleName, schema); |
| 211 | if (!unmarshalledJsModule) { |
| 212 | return unmarshalledJsModule.moveError(); |
no test coverage detected