summaryrefslogtreecommitdiff
path: root/cli/dts/lib.deno.unstable.d.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/dts/lib.deno.unstable.d.ts')
-rw-r--r--cli/dts/lib.deno.unstable.d.ts76
1 files changed, 42 insertions, 34 deletions
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts
index 64efa0a2f..ab4a63729 100644
--- a/cli/dts/lib.deno.unstable.d.ts
+++ b/cli/dts/lib.deno.unstable.d.ts
@@ -107,36 +107,44 @@ declare namespace Deno {
swapFree: number;
}
- /** **UNSTABLE**: new API, yet to be vetted.
- *
- * Open and initialize a plugin.
- *
- * ```ts
- * import { assert } from "https://deno.land/std/testing/asserts.ts";
- * const rid = Deno.openPlugin("./path/to/some/plugin.so");
- *
- * // The Deno.core namespace is needed to interact with plugins, but this is
- * // internal so we use ts-ignore to skip type checking these calls.
- * // @ts-ignore
- * const { op_test_sync, op_test_async } = Deno.core.ops();
- *
- * assert(op_test_sync);
- * assert(op_test_async);
- *
- * // @ts-ignore
- * const result = Deno.core.opSync("op_test_sync");
- *
- * // @ts-ignore
- * const result = await Deno.core.opAsync("op_test_sync");
- * ```
- *
- * Requires `allow-plugin` permission.
+ /** All possible types for interfacing with foreign functions */
+ export type NativeType =
+ | "void"
+ | "u8"
+ | "i8"
+ | "u16"
+ | "i16"
+ | "u32"
+ | "i32"
+ | "u64"
+ | "i64"
+ | "usize"
+ | "isize"
+ | "f32"
+ | "f64";
+
+ /** A foreign function as defined by its parameter and result types */
+ export interface ForeignFunction {
+ parameters: NativeType[];
+ result: NativeType;
+ }
+
+ /** A dynamic library resource */
+ export interface DynamicLibrary<S extends Record<string, ForeignFunction>> {
+ /** All of the registered symbols along with functions for calling them */
+ symbols: { [K in keyof S]: (...args: unknown[]) => unknown };
+
+ close(): void;
+ }
+
+ /** **UNSTABLE**: new API
*
- * The plugin system is not stable and will change in the future, hence the
- * lack of docs. For now take a look at the example
- * https://github.com/denoland/deno/tree/main/test_plugin
+ * Opens a dynamic library and registers symbols
*/
- export function openPlugin(filename: string): number;
+ export function dlopen<S extends Record<string, ForeignFunction>>(
+ filename: string,
+ symbols: S,
+ ): DynamicLibrary<S>;
/** The log category for a diagnostic message. */
export enum DiagnosticCategory {
@@ -1043,14 +1051,14 @@ declare namespace Deno {
*/
net?: "inherit" | boolean | string[];
- /** Specifies if the `plugin` permission should be requested or revoked.
- * If set to `"inherit"`, the current `plugin` permission will be inherited.
- * If set to `true`, the global `plugin` permission will be requested.
- * If set to `false`, the global `plugin` permission will be revoked.
+ /** Specifies if the `ffi` permission should be requested or revoked.
+ * If set to `"inherit"`, the current `ffi` permission will be inherited.
+ * If set to `true`, the global `ffi` permission will be requested.
+ * If set to `false`, the global `ffi` permission will be revoked.
*
* Defaults to "inherit".
*/
- plugin?: "inherit" | boolean;
+ ffi?: "inherit" | boolean;
/** Specifies if the `read` permission should be requested or revoked.
* If set to `"inherit"`, the current `read` permission will be inherited.
@@ -1137,7 +1145,7 @@ declare interface WorkerOptions {
* For example: `["https://deno.land", "localhost:8080"]`.
*/
net?: "inherit" | boolean | string[];
- plugin?: "inherit" | boolean;
+ ffi?: "inherit" | boolean;
read?: "inherit" | boolean | Array<string | URL>;
run?: "inherit" | boolean | Array<string | URL>;
write?: "inherit" | boolean | Array<string | URL>;