From cfb61509f1c94f494fb2419d1f5effc8c32c74b2 Mon Sep 17 00:00:00 2001 From: Arnav Bansal Date: Wed, 8 Nov 2023 02:12:23 +0530 Subject: [PATCH] [extensions] release commands to GA (#108) * [extensions] release commands to GA * fixes --- .../src/api/{experimental => }/commands.ts | 12 +++++----- .../extensions/src/api/experimental/index.ts | 4 +++- modules/extensions/src/api/index.ts | 2 ++ modules/extensions/src/types/index.ts | 22 +++++++++---------- 4 files changed, 22 insertions(+), 18 deletions(-) rename modules/extensions/src/api/{experimental => }/commands.ts (85%) diff --git a/modules/extensions/src/api/experimental/commands.ts b/modules/extensions/src/api/commands.ts similarity index 85% rename from modules/extensions/src/api/experimental/commands.ts rename to modules/extensions/src/api/commands.ts index bfc58fd..95c38d3 100644 --- a/modules/extensions/src/api/experimental/commands.ts +++ b/modules/extensions/src/api/commands.ts @@ -1,4 +1,4 @@ -import { extensionPort, proxy } from "../../util/comlink"; +import { extensionPort, proxy } from "../util/comlink"; import { CreateCommand, CommandProxy, @@ -8,7 +8,7 @@ import { CommandSymbol, CommandArgs, isCommandProxy, -} from "../../commands"; +} from "../commands"; export interface AddCommandArgs { /** @@ -46,7 +46,7 @@ export function add({ id, contributions, command }: AddCommandArgs) { return isCommandProxy(cmd) ? cmd : Command(cmd); }); - extensionPort.experimental.commands.registerCreateCommand( + extensionPort.commands.registerCreateCommand( { commandId: id, contributions }, createCommand ); @@ -55,7 +55,7 @@ export function add({ id, contributions, command }: AddCommandArgs) { return isCommandProxy(command) ? command : Command(command); }); - extensionPort.experimental.commands.registerCreateCommand( + extensionPort.commands.registerCreateCommand( { commandId: id, contributions }, createCommand ); @@ -66,7 +66,7 @@ export function add({ id, contributions, command }: AddCommandArgs) { * @deprecated Use `add` instead */ export function register(command: CommandProxy): void { - extensionPort.experimental.commands.registerCommand(command); + extensionPort.commands.registerCommand(command); } /** @@ -76,7 +76,7 @@ export function registerCreate( data: { commandId: string; contributions: Array }, createCommand: CreateCommand ): void { - extensionPort.experimental.commands.registerCreateCommand( + extensionPort.commands.registerCreateCommand( data, async (args: CommandFnArgs) => { const cmd = await createCommand(args); diff --git a/modules/extensions/src/api/experimental/index.ts b/modules/extensions/src/api/experimental/index.ts index 0f175bf..a5c988a 100644 --- a/modules/extensions/src/api/experimental/index.ts +++ b/modules/extensions/src/api/experimental/index.ts @@ -1,3 +1,5 @@ export * as auth from "./auth"; export * as editor from "./editor"; -export * as commands from "./commands"; + +// deprecated from the experimental namespace +export * as commands from "../commands"; diff --git a/modules/extensions/src/api/index.ts b/modules/extensions/src/api/index.ts index 34adb26..9434f59 100644 --- a/modules/extensions/src/api/index.ts +++ b/modules/extensions/src/api/index.ts @@ -9,6 +9,7 @@ import * as experimental from "./experimental"; import * as internal from "./internal"; import * as exec from "./exec"; import * as debug from "./debug"; +import * as commands from "./commands"; export { fs, @@ -22,6 +23,7 @@ export { internal, exec, debug, + commands, }; // deprecate this after migrating existing extensions diff --git a/modules/extensions/src/types/index.ts b/modules/extensions/src/types/index.ts index 5303841..61b1fa1 100644 --- a/modules/extensions/src/types/index.ts +++ b/modules/extensions/src/types/index.ts @@ -179,6 +179,17 @@ export type ExtensionPortAPI = { watchActiveFile: (callback: OnActiveFileChangeListener) => DisposerFunction; getActiveFile: () => Promise; + commands: { + registerCommand: (command: CommandProxy) => void; + registerCreateCommand: ( + data: { + commandId: string; + contributions: Array; + }, + create: (createArgs: CommandFnArgs) => Promise + ) => void; + }; + experimental: ExperimentalAPI; internal: InternalAPI; debug: DebugAPI; @@ -209,17 +220,6 @@ export type ExperimentalAPI = { auth: { getAuthToken: () => Promise; }; - - commands: { - registerCommand: (command: CommandProxy) => void; - registerCreateCommand: ( - data: { - commandId: string; - contributions: Array; - }, - create: (createArgs: CommandFnArgs) => Promise - ) => void; - }; }; export type DebugAPI = {