From 5a08384ae1e3f4705f9cbceb72139aa20c3c5362 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Fri, 5 Jun 2026 19:42:24 -0500 Subject: [PATCH] start async --- .../script/module/require/modulerequire.c | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/dusk/script/module/require/modulerequire.c b/src/dusk/script/module/require/modulerequire.c index 35e8a5df..3f13bfc5 100644 --- a/src/dusk/script/module/require/modulerequire.c +++ b/src/dusk/script/module/require/modulerequire.c @@ -70,7 +70,44 @@ jerry_value_t moduleRequireAsyncFunc( const jerry_value_t args[], const jerry_length_t argc ) { - return jerry_undefined(); + assertNotNull(callInfo, "callInfo must not be null."); + assertNotNull(args, "args must not be null."); + + // Filename, required + if(argc < 1 || !jerry_value_is_string(args[0])) { + return moduleBaseThrow( + "requireAsync expects filename." + ); + } + + // Callback, optional. + if(argc >= 2 && !jerry_value_is_function(args[1])) { + return moduleBaseThrow( + "requireAsync callback must be a function." + ); + } + + // Is filename too long? + if( + jerry_string_size(args[0], JERRY_ENCODING_UTF8) >= ASSET_FILE_NAME_MAX + ) { + return moduleBaseThrow("Module name too long."); + } + + // Get C string + char_t moduleName[ASSET_FILE_NAME_MAX]; + moduleBaseToString(args[0], moduleName, sizeof(moduleName)); + + // Lock asset + assetloaderinput_t input; + input.script.nothing = NULL; + + assetentry_t *entry = assetLock( + moduleName, + ASSET_LOADER_TYPE_SCRIPT, + &input + ); + } void moduleRequireInit(void) {