From 511c48a03adee54aaadbefdeb2d2d521f6a45843 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 11 Jul 2021 18:12:26 -0700 Subject: Revert "Remove unstable native plugins (#10908)" This reverts commit 7dd4090c2a3dc0222fd6ff611eeb2bd69cd28224. --- cli/dts/lib.deno.unstable.d.ts | 31 +++++++++++++++++++++++++++++++ cli/tests/integration/lsp_tests.rs | 8 ++++---- 2 files changed, 35 insertions(+), 4 deletions(-) (limited to 'cli') diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index f3897407b..ac03e695c 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -129,6 +129,37 @@ declare namespace Deno { speed: number | undefined; } + /** **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. + * + * 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 + */ + export function openPlugin(filename: string): number; + /** The log category for a diagnostic message. */ export enum DiagnosticCategory { Warning = 0, diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index dcfd787fb..81eb64b7a 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -470,7 +470,7 @@ fn lsp_hover_unstable_enabled() { "uri": "file:///a/file.ts", "languageId": "typescript", "version": 1, - "text": "console.log(Deno.ppid);\n" + "text": "console.log(Deno.openPlugin);\n" } }), ); @@ -495,9 +495,9 @@ fn lsp_hover_unstable_enabled() { "contents":[ { "language":"typescript", - "value":"const Deno.ppid: number" + "value":"function Deno.openPlugin(filename: string): number" }, - "The pid of the current process's parent." + "**UNSTABLE**: new API, yet to be vetted.\n\nOpen and initialize a plugin.\n\n```ts\nimport { assert } from \"https://deno.land/std/testing/asserts.ts\";\nconst rid = Deno.openPlugin(\"./path/to/some/plugin.so\");\n\n// The Deno.core namespace is needed to interact with plugins, but this is\n// internal so we use ts-ignore to skip type checking these calls.\n// @ts-ignore\nconst { op_test_sync, op_test_async } = Deno.core.ops();\n\nassert(op_test_sync);\nassert(op_test_async);\n\n// @ts-ignore\nconst result = Deno.core.opSync(\"op_test_sync\");\n\n// @ts-ignore\nconst result = await Deno.core.opAsync(\"op_test_sync\");\n```\n\nRequires `allow-plugin` permission.\n\nThe plugin system is not stable and will change in the future, hence the\nlack of docs. For now take a look at the example\nhttps://github.com/denoland/deno/tree/main/test_plugin" ], "range":{ "start":{ @@ -506,7 +506,7 @@ fn lsp_hover_unstable_enabled() { }, "end":{ "line":0, - "character":21 + "character":27 } } })) -- cgit v1.2.3