mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -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
|
* Opens a dynamic library and registers symbols
|
||||||
*/
|
*/
|
||||||
export function dlopen<S extends Record<string, ForeignFunction>>(
|
export function dlopen<S extends Record<string, ForeignFunction>>(
|
||||||
filename: string,
|
filename: string | URL,
|
||||||
symbols: S,
|
symbols: S,
|
||||||
): DynamicLibrary<S>;
|
): DynamicLibrary<S>;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
((window) => {
|
((window) => {
|
||||||
const core = window.Deno.core;
|
const core = window.Deno.core;
|
||||||
|
const __bootstrap = window.__bootstrap;
|
||||||
|
|
||||||
class DynamicLibrary {
|
class DynamicLibrary {
|
||||||
#rid;
|
#rid;
|
||||||
|
@ -23,7 +24,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dlopen(path, symbols) {
|
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 };
|
window.__bootstrap.ffi = { dlopen };
|
||||||
|
|
Loading…
Add table
Reference in a new issue