1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

feat(unstable): Support file URLs in Deno.dlopen() (#11658)

This commit is contained in:
Nayeem Rahman 2021-08-24 14:09:00 +01:00 committed by GitHub
parent 8c57a6b7e3
commit 1b7848c4a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -142,7 +142,7 @@ declare namespace Deno {
* Opens a dynamic library and registers symbols
*/
export function dlopen<S extends Record<string, ForeignFunction>>(
filename: string,
filename: string | URL,
symbols: S,
): DynamicLibrary<S>;

View file

@ -3,6 +3,7 @@
((window) => {
const core = window.Deno.core;
const __bootstrap = window.__bootstrap;
class DynamicLibrary {
#rid;
@ -23,7 +24,9 @@
}
function dlopen(path, symbols) {
return new DynamicLibrary(path, symbols);
// URL support is progressively enhanced by util in `runtime/js`.
const pathFromURL = __bootstrap.util.pathFromURL ?? ((p) => p);
return new DynamicLibrary(pathFromURL(path), symbols);
}
window.__bootstrap.ffi = { dlopen };