Skip to content

kayac-chang/plug

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plug

Tags Checks Dependencies License

FFI Plugin management library featuring automatic caching of local and remote binaries, cross-platform automatic url guessing, deno_plugin_prepare backwards compatibility and pretty deno-like logging when caching and downloading binaries.


⚠️ FFI in deno is unstable and undergoing BREAKING CHANGES. This library aims to follow changes to deno as closly as possible.


import { Plug } from "https://deno.land/x/plug/mod.ts";

// Backwards compatibility with deno-plugin-prepare
const options: Plug.Options = {
  name: "test_lib",
  urls: {
    darwin: `https://example.com/some/path/libtest_lib.dylib`,
    windows: `https://example.com/some/path/test_lib.dll`,
    linux: `https://example.com/some/path/libtest_lib.so`,
  },
};

// Or if you want plug to guess your binary names
const options: Plug.Options = {
  name: "test_lib",
  url: "https://example.com/some/path/",
  // Becomes:
  // darwin: "https://example.com/some/path/libtest_lib.dylib"
  // windows: "https://example.com/some/path/test_lib.dll"
  // linux: "https://example.com/some/path/libtest_lib.so"
};

// Drop-in replacement for `Deno.dlopen`
const library = await Plug.prepare(options, {
  noop: { parameters: [], result: "void" },
});

library.symbols.noop();

Other

Related

Contribution

Pull request, issues and feedback are very welcome. Code style is formatted with deno fmt and commit messages are done following Conventional Commits spec.

Licence

Copyright 2020-2022, the denosaurs team. All rights reserved. MIT license.

About

🔌 Deno plugin management library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 96.6%
  • Rust 3.4%