Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manyuanrong/deno-plugin-prepare
A library for managing deno native plugin dependencies
https://github.com/manyuanrong/deno-plugin-prepare
Last synced: about 1 month ago
JSON representation
A library for managing deno native plugin dependencies
- Host: GitHub
- URL: https://github.com/manyuanrong/deno-plugin-prepare
- Owner: manyuanrong
- License: mit
- Created: 2020-03-01T10:01:48.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-13T05:35:33.000Z (about 4 years ago)
- Last Synced: 2024-10-26T06:52:11.452Z (about 2 months ago)
- Language: TypeScript
- Size: 6.55 MB
- Stars: 47
- Watchers: 2
- Forks: 12
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-deno - deno-plugin-prepare - 一个用于管理Deno Native插件依赖关系的库 (Uncategorized / Uncategorized)
- awesome-deno-cn - @manyuanrong/deno-plugin-prepare
- awesome-deno - deno-plugin-prepare - A library for managing Deno native plugin dependencies.![GitHub stars](https://img.shields.io/github/stars/manyuanrong/deno-plugin-prepare?style=plastic) (Modules / Online Playgrounds)
- awesome-deno - deno-plugin-prepare - A library for managing Deno native plugin dependencies. (Modules / Utils)
README
# deno-plugin-prepare
A library for managing deno native plugin dependencies
[![tag](https://img.shields.io/github/tag/manyuanrong/deno-plugin-prepare.svg)](https://github.com/manyuanrong/deno-plugin-prepare)
[![Build Status](https://github.com/manyuanrong/deno-plugin-prepare/workflows/ci/badge.svg?branch=master)](https://github.com/manyuanrong/deno-plugin-prepare/actions)
[![license](https://img.shields.io/github/license/manyuanrong/deno-plugin-prepare.svg)](https://github.com/manyuanrong/deno-plugin-prepare)
[![tag](https://img.shields.io/badge/deno-v1.4.0-green.svg)](https://github.com/denoland/deno)### Why do you need this module?
Because Deno's plugin is not a first-class citizen, it cannot be loaded directly using `import` like `js`, `ts`, and `json`.
Deno's plugin is compiled with other system-level languages, and cannot be compiled into one target result across multiple platforms, usually compiled into multiple platform target binaries. These binary files are usually much larger than scripts such as `js/ts`, so they should not be downloaded all, need to be dynamically loaded according to the platform.
### API
#### prepare
The API needs to provide some plug-in information, including the name of the plugin, and the remote url of the binary file for different platforms. It is similar to an asynchronous version of `Deno.openPlugin`, which will automatically download the corresponding binary file according to the platform and cache it in the `.deno_plugins` directory of the current working directory.
### Usage
```ts
import {
prepare,
PrepareOptions,
} from "https://deno.land/x/[email protected]/mod.ts";const releaseUrl =
"https://github.com/manyuanrong/deno-plugin-prepare/releases/download/plugin_bins";const pluginOptions: PrepareOptions = {
name: "test_plugin",// Whether to output log. Optional, default is true
// printLog: true,// Whether to use locally cached files. Optional, default is true
// checkCache: true,// Support "http://", "https://", "file://"
urls: {
darwin: `${releaseUrl}/libtest_plugin.dylib`,
windows: `${releaseUrl}/test_plugin.dll`,
linux: `${releaseUrl}/libtest_plugin.so`,
},
};
const rid = await prepare(pluginOptions);
//@ts-ignore
const { testSync } = Deno.core.ops();
//@ts-ignore
const response = Deno.core.dispatch(
testSync,
new Uint8Array([116, 101, 115, 116])
)!;console.log(response);
Deno.close(rid);
```### Custom cache path
By default, binary files will be cached in the `.deno_plugins` directory. In some cases, we need to store in other locations, you can set the `DENO_PLUGIN_DIR` environment variable
### TODOs
- [x] Caching binary files with URL hash (multi-version coexistence)
- [ ] Supports downloading and decompressing .GZ files