The dir query parameter for load.php can set explicitly, but MediaWiki doesn't do this for its own urls. Instead, it passes lang only, and depends on ResourceLoaderContext to infer the correct directionality based on MediaWiki's localisation system.
This appears to be one of few non-trivial uses (if not, the only use) of MediaWiki Language classes in ResourceLoader and is a dependency I'd like to remove if possible.
Two changes required:
- For urls created server-side in PHP, move the responsibility for setting this information to MediaWiki OutputPage, where it creates the ResourceLoaderContext object for ResourceLoaderClientHtml.
- For urls created client-side in JS, the mw.loader code will need to be expanded to know the current directionality somehow and use it for subsequent load.php requests.