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:
parent
8c57a6b7e3
commit
1b7848c4a9
2 changed files with 5 additions and 2 deletions
2
cli/dts/lib.deno.unstable.d.ts
vendored
2
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -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>;
|
||||
|
||||
|
|
|
@ -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 };
|
||||
|
|
Loading…
Reference in a new issue