summaryrefslogtreecommitdiff
path: root/cli/js/lib.deno_runtime.d.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/lib.deno_runtime.d.ts')
-rw-r--r--cli/js/lib.deno_runtime.d.ts35
1 files changed, 35 insertions, 0 deletions
diff --git a/cli/js/lib.deno_runtime.d.ts b/cli/js/lib.deno_runtime.d.ts
index fb7767aa6..0d3463869 100644
--- a/cli/js/lib.deno_runtime.d.ts
+++ b/cli/js/lib.deno_runtime.d.ts
@@ -907,6 +907,7 @@ declare namespace Deno {
| "write"
| "net"
| "env"
+ | "plugin"
| "hrtime";
/** https://w3c.github.io/permissions/#status-of-a-permission */
export type PermissionState = "granted" | "denied" | "prompt";
@@ -924,6 +925,9 @@ declare namespace Deno {
interface EnvPermissionDescriptor {
name: "env";
}
+ interface PluginPermissionDescriptor {
+ name: "plugin";
+ }
interface HrtimePermissionDescriptor {
name: "hrtime";
}
@@ -933,6 +937,7 @@ declare namespace Deno {
| ReadWritePermissionDescriptor
| NetPermissionDescriptor
| EnvPermissionDescriptor
+ | PluginPermissionDescriptor
| HrtimePermissionDescriptor;
export class Permissions {
@@ -982,6 +987,36 @@ declare namespace Deno {
*/
export function truncate(name: string, len?: number): Promise<void>;
+ // @url js/plugins.d.ts
+
+ export interface AsyncHandler {
+ (msg: Uint8Array): void;
+ }
+
+ export interface PluginOp {
+ dispatch(
+ control: Uint8Array,
+ zeroCopy?: ArrayBufferView | null
+ ): Uint8Array | null;
+ setAsyncHandler(handler: AsyncHandler): void;
+ }
+
+ export interface Plugin {
+ ops: {
+ [name: string]: PluginOp;
+ };
+ }
+
+ /** Open and initalize a plugin.
+ * Requires the `--allow-plugin` flag.
+ *
+ * const plugin = Deno.openPlugin("./path/to/some/plugin.so");
+ * const some_op = plugin.ops.some_op;
+ * const response = some_op.dispatch(new Uint8Array([1,2,3,4]));
+ * console.log(`Response from plugin ${response}`);
+ */
+ export function openPlugin(filename: string): Plugin;
+
// @url js/net.d.ts
type Transport = "tcp";