diff --git a/.gitmodules b/.gitmodules index 2bcc65f..2c609f2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "specs/permissions"] path = specs/permissions url = https://github.com/w3c/permissions.git +[submodule "specs/web-bluetooth"] + path = specs/web-bluetooth + url = https://github.com/WebBluetoothCG/web-bluetooth.git diff --git a/out/gen/main.d.ts b/out/gen/main.d.ts index 7df83e9..241586f 100644 --- a/out/gen/main.d.ts +++ b/out/gen/main.d.ts @@ -56,6 +56,7 @@ export declare const enum ErrorCode { InvalidArgument = 'invalid argument', InvalidSelector = 'invalid selector', InvalidSessionId = 'invalid session id', + InvalidWebExtension = 'invalid web extension', MoveTargetOutOfBounds = 'move target out of bounds', NoSuchAlert = 'no such alert', NoSuchElement = 'no such element', @@ -68,6 +69,7 @@ export declare const enum ErrorCode { NoSuchScript = 'no such script', NoSuchStoragePartition = 'no such storage partition', NoSuchUserContext = 'no such user context', + NoSuchWebExtension = 'no such web extension', SessionNotCreated = 'session not created', UnableToCaptureScreen = 'unable to capture screen', UnableToCloseBrowser = 'unable to close browser', @@ -235,11 +237,28 @@ export declare namespace Session { export type BrowserCommand = | Browser.Close | Browser.CreateUserContext + | Browser.GetClientWindows | Browser.GetUserContexts - | Browser.RemoveUserContext; + | Browser.RemoveUserContext + | Browser.SetClientWindowState + | Record; export type BrowserResult = | Browser.CreateUserContextResult | Browser.GetUserContextsResult; +export declare namespace Browser { + type ClientWindow = string; +} +export declare namespace Browser { + type ClientWindowInfo = { + active: boolean; + clientWindow: Browser.ClientWindow; + height: JsUint; + state: 'fullscreen' | 'maximized' | 'minimized' | 'normal'; + width: JsUint; + x: JsInt; + y: JsInt; + }; +} export declare namespace Browser { type UserContext = string; } @@ -263,6 +282,17 @@ export declare namespace Browser { export declare namespace Browser { type CreateUserContextResult = Browser.UserContextInfo; } +export declare namespace Browser { + type GetClientWindows = { + method: 'browser.getClientWindows'; + params: EmptyParams; + }; +} +export declare namespace Browser { + type GetClientWindowsResult = { + clientWindows: [...Browser.ClientWindowInfo[]]; + }; +} export declare namespace Browser { type GetUserContexts = { method: 'browser.getUserContexts'; @@ -285,6 +315,33 @@ export declare namespace Browser { userContext: Browser.UserContext; }; } +export declare namespace Browser { + type SetClientWindowState = { + method: 'browser.setClientWindowState'; + params: Browser.SetClientWindowStateParameters; + }; +} +export declare namespace Browser { + type SetClientWindowStateParameters = + | ({ + clientWindow: Browser.ClientWindow; + } & Browser.ClientWindowNamedState) + | Browser.ClientWindowRectState; +} +export declare namespace Browser { + type ClientWindowNamedState = { + state: 'fullscreen' | 'maximized' | 'minimized'; + }; +} +export declare namespace Browser { + type ClientWindowRectState = { + state: 'normal'; + width?: JsUint; + height?: JsUint; + x?: JsInt; + y?: JsInt; + }; +} export type BrowsingContextCommand = | BrowsingContext.Activate | BrowsingContext.CaptureScreenshot @@ -304,6 +361,7 @@ export type BrowsingContextEvent = | BrowsingContext.DomContentLoaded | BrowsingContext.DownloadWillBegin | BrowsingContext.FragmentNavigated + | BrowsingContext.HistoryUpdated | BrowsingContext.Load | BrowsingContext.NavigationAborted | BrowsingContext.NavigationFailed @@ -327,6 +385,7 @@ export declare namespace BrowsingContext { export declare namespace BrowsingContext { type Info = { children: BrowsingContext.InfoList | null; + clientWindow: Browser.ClientWindow; context: BrowsingContext.BrowsingContext; originalOpener: BrowsingContext.BrowsingContext | null; url: string; @@ -729,6 +788,18 @@ export declare namespace BrowsingContext { params: BrowsingContext.NavigationInfo; }; } +export declare namespace BrowsingContext { + type HistoryUpdated = { + method: 'browsingContext.historyUpdated'; + params: BrowsingContext.HistoryUpdatedParameters; + }; +} +export declare namespace BrowsingContext { + type HistoryUpdatedParameters = { + context: BrowsingContext.BrowsingContext; + url: string; + }; +} export declare namespace BrowsingContext { type DomContentLoaded = { method: 'browsingContext.domContentLoaded'; @@ -894,11 +965,11 @@ export declare namespace Network { } export declare namespace Network { type Initiator = { - type: 'parser' | 'script' | 'preflight' | 'other'; columnNumber?: JsUint; lineNumber?: JsUint; - stackTrace?: Script.StackTrace; request?: Network.Request; + stackTrace?: Script.StackTrace; + type?: 'parser' | 'script' | 'preflight' | 'other'; }; } export declare namespace Network { @@ -916,6 +987,8 @@ export declare namespace Network { cookies: [...Network.Cookie[]]; headersSize: JsUint; bodySize: JsUint | null; + destination: string; + initiatorType: string | null; timings: Network.FetchTimingInfo; }; } @@ -1121,7 +1194,7 @@ export declare namespace Network { } export declare namespace Network { type BeforeRequestSentParameters = Network.BaseParameters & { - initiator: Network.Initiator; + initiator?: Network.Initiator; }; } export declare namespace Network { @@ -2185,3 +2258,60 @@ export declare namespace Input { files: [...string[]]; }; } +export type WebExtensionsCommand = WebExtension.Install & + WebExtension.Uninstall; +export type WebExtensionsResult = WebExtension.InstallResult; +export declare namespace WebExtension { + type Extension = string; +} +export declare namespace WebExtension { + type InstallParameters = { + extensionData: WebExtension.ExtensionData; + }; +} +export declare namespace WebExtension { + type Install = { + method: 'webExtension.install'; + params: WebExtension.InstallParameters; + }; +} +export declare namespace WebExtension { + type ExtensionData = + | WebExtension.ExtensionArchivePath + | WebExtension.ExtensionBase64Encoded + | WebExtension.ExtensionPath; +} +export declare namespace WebExtension { + type ExtensionPath = { + type: 'path'; + path: string; + }; +} +export declare namespace WebExtension { + type ExtensionArchivePath = { + type: 'archivePath'; + path: string; + }; +} +export declare namespace WebExtension { + type ExtensionBase64Encoded = { + type: 'base64'; + value: string; + }; +} +export declare namespace WebExtension { + type InstallResult = { + extension: WebExtension.Extension; + }; +} +export declare namespace WebExtension { + type Uninstall = { + method: 'webExtension.uninstall'; + params: WebExtension.UninstallParameters; + }; +} +export declare namespace WebExtension { + type UninstallParameters = { + extension: WebExtension.Extension; + }; +} diff --git a/out/gen/web-bluetooth.d.ts b/out/gen/web-bluetooth.d.ts new file mode 100644 index 0000000..8ea92e8 --- /dev/null +++ b/out/gen/web-bluetooth.d.ts @@ -0,0 +1,114 @@ +export declare namespace Bluetooth { + type BluetoothServiceUuid = string; +} +export declare namespace Bluetooth { + type BluetoothManufacturerData = { + key: number; + data: string; + }; +} +export declare namespace Bluetooth { + type RequestDevice = string; +} +export declare namespace Bluetooth { + type RequestDeviceInfo = { + id: Bluetooth.RequestDevice; + name: string | null; + }; +} +export declare namespace Bluetooth { + type RequestDevicePrompt = string; +} +export declare namespace Bluetooth { + type ScanRecord = { + name?: string; + uuids?: [...Bluetooth.BluetoothServiceUuid[]]; + appearance?: number; + manufacturerData?: [...Bluetooth.BluetoothManufacturerData[]]; + }; +} +export declare namespace Bluetooth { + type HandleRequestDevicePrompt = { + method: 'bluetooth.handleRequestDevicePrompt'; + params: Bluetooth.HandleRequestDevicePromptParameters; + }; +} +export declare namespace Bluetooth { + type HandleRequestDevicePromptParameters = { + context: string; + prompt: Bluetooth.RequestDevicePrompt; + } & ( + | Bluetooth.HandleRequestDevicePromptAcceptParameters + | Bluetooth.HandleRequestDevicePromptCancelParameters + ); +} +export declare namespace Bluetooth { + type HandleRequestDevicePromptAcceptParameters = { + accept: true; + device: Bluetooth.RequestDevice; + }; +} +export declare namespace Bluetooth { + type HandleRequestDevicePromptCancelParameters = { + accept: false; + }; +} +export declare namespace Bluetooth { + type SimulateAdapter = { + method: 'bluetooth.simulateAdapter'; + params: Bluetooth.SimulateAdapterParameters; + }; +} +export declare namespace Bluetooth { + type SimulateAdapterParameters = { + context: string; + state: 'absent' | 'powered-off' | 'powered-on'; + }; +} +export declare namespace Bluetooth { + type SimulatePreconnectedPeripheral = { + method: 'bluetooth.simulatePreconnectedPeripheral'; + params: Bluetooth.SimulatePreconnectedPeripheralParameters; + }; +} +export declare namespace Bluetooth { + type SimulatePreconnectedPeripheralParameters = { + context: string; + address: string; + name: string; + manufacturerData: [...Bluetooth.BluetoothManufacturerData[]]; + knownServiceUuids: [...Bluetooth.BluetoothServiceUuid[]]; + }; +} +export declare namespace Bluetooth { + type SimulateAdvertisement = { + method: 'bluetooth.simulateAdvertisement'; + params: Bluetooth.SimulateAdvertisementParameters; + }; +} +export declare namespace Bluetooth { + type SimulateAdvertisementParameters = { + context: string; + scanEntry: Bluetooth.SimulateAdvertisementScanEntryParameters; + }; +} +export declare namespace Bluetooth { + type SimulateAdvertisementScanEntryParameters = { + deviceAddress: string; + rssi: number; + scanRecord: Bluetooth.ScanRecord; + }; +} +export declare namespace Bluetooth { + type RequestDevicePromptUpdated = { + method: 'bluetooth.requestDevicePromptUpdated'; + params: Bluetooth.RequestDevicePromptUpdatedParameters; + }; +} +export declare namespace Bluetooth { + type RequestDevicePromptUpdatedParameters = { + context: string; + prompt: Bluetooth.RequestDevicePrompt; + devices: [...Bluetooth.RequestDeviceInfo[]]; + }; +} diff --git a/out/gen/web-bluetooth.js b/out/gen/web-bluetooth.js new file mode 100644 index 0000000..38813da --- /dev/null +++ b/out/gen/web-bluetooth.js @@ -0,0 +1,2 @@ +'use strict'; +Object.defineProperty(exports, '__esModule', {value: true}); diff --git a/out/index.d.ts b/out/index.d.ts index dc9f345..15afe07 100644 --- a/out/index.d.ts +++ b/out/index.d.ts @@ -5,29 +5,38 @@ */ import * as Bidi from './gen/main.js'; import * as BidiPermissions from './gen/permissions.js'; +import * as BidiBluetooth from './gen/web-bluetooth.js'; export * from './gen/main.js'; export * from './gen/permissions.js'; -export type Command = Bidi.Command | BidiPermissions.Permissions.SetPermission; -export type Event = Bidi.Event; +export * from './gen/web-bluetooth.js'; +export type Command = + | Bidi.Command + | BidiPermissions.Permissions.SetPermission + | BidiBluetooth.Bluetooth.SimulateAdapter + | BidiBluetooth.Bluetooth.HandleRequestDevicePrompt + | BidiBluetooth.Bluetooth.SimulateAdvertisement + | BidiBluetooth.Bluetooth.SimulatePreconnectedPeripheral; +export type Event = + | Bidi.Event + | ({ + type: 'event'; + } & BidiBluetooth.Bluetooth.RequestDevicePromptUpdated & + Bidi.Extensible); export interface Commands { - 'script.evaluate': { - params: Bidi.Script.EvaluateParameters; - returnType: Bidi.Script.EvaluateResult; - }; - 'script.callFunction': { - params: Bidi.Script.CallFunctionParameters; - returnType: Bidi.Script.EvaluateResult; + 'bluetooth.handleRequestDevicePrompt': { + params: BidiBluetooth.Bluetooth.HandleRequestDevicePromptParameters; + returnType: Bidi.EmptyResult; }; - 'script.disown': { - params: Bidi.Script.DisownParameters; + 'bluetooth.simulateAdapter': { + params: BidiBluetooth.Bluetooth.SimulateAdapterParameters; returnType: Bidi.EmptyResult; }; - 'script.addPreloadScript': { - params: Bidi.Script.AddPreloadScriptParameters; - returnType: Bidi.Script.AddPreloadScriptResult; + 'bluetooth.simulateAdvertisement': { + params: BidiBluetooth.Bluetooth.SimulateAdvertisementParameters; + returnType: Bidi.EmptyResult; }; - 'script.removePreloadScript': { - params: Bidi.Script.RemovePreloadScriptParameters; + 'bluetooth.simulatePreconnectedPeripheral': { + params: BidiBluetooth.Bluetooth.SimulatePreconnectedPeripheral; returnType: Bidi.EmptyResult; }; 'browser.close': { @@ -112,6 +121,26 @@ export interface Commands { params: BidiPermissions.Permissions.SetPermissionParameters; returnType: Bidi.EmptyResult; }; + 'script.evaluate': { + params: Bidi.Script.EvaluateParameters; + returnType: Bidi.Script.EvaluateResult; + }; + 'script.callFunction': { + params: Bidi.Script.CallFunctionParameters; + returnType: Bidi.Script.EvaluateResult; + }; + 'script.disown': { + params: Bidi.Script.DisownParameters; + returnType: Bidi.EmptyResult; + }; + 'script.addPreloadScript': { + params: Bidi.Script.AddPreloadScriptParameters; + returnType: Bidi.Script.AddPreloadScriptResult; + }; + 'script.removePreloadScript': { + params: Bidi.Script.RemovePreloadScriptParameters; + returnType: Bidi.EmptyResult; + }; 'session.end': { params: Bidi.EmptyParams; returnType: Bidi.EmptyResult; @@ -168,4 +197,12 @@ export interface Commands { params: Bidi.Network.ProvideResponseParameters; returnType: Bidi.EmptyResult; }; + 'webExtension.install': { + params: Bidi.WebExtension.InstallParameters; + returnType: Bidi.WebExtension.InstallResult; + }; + 'webExtension.uninstall': { + params: Bidi.WebExtension.UninstallParameters; + returnType: Bidi.EmptyResult; + }; } diff --git a/out/index.js b/out/index.js index b3ff8c8..7a7008f 100644 --- a/out/index.js +++ b/out/index.js @@ -37,3 +37,4 @@ var __exportStar = Object.defineProperty(exports, '__esModule', {value: true}); __exportStar(require('./gen/main.js'), exports); __exportStar(require('./gen/permissions.js'), exports); +__exportStar(require('./gen/web-bluetooth.js'), exports); diff --git a/specs/web-bluetooth b/specs/web-bluetooth new file mode 160000 index 0000000..f3b3187 --- /dev/null +++ b/specs/web-bluetooth @@ -0,0 +1 @@ +Subproject commit f3b31870764ce76fa1fa671f7bcdac7944a246a0 diff --git a/src/gen/main.ts b/src/gen/main.ts index 3849487..a442ce7 100644 --- a/src/gen/main.ts +++ b/src/gen/main.ts @@ -58,6 +58,7 @@ export const enum ErrorCode { InvalidArgument = 'invalid argument', InvalidSelector = 'invalid selector', InvalidSessionId = 'invalid session id', + InvalidWebExtension = 'invalid web extension', MoveTargetOutOfBounds = 'move target out of bounds', NoSuchAlert = 'no such alert', NoSuchElement = 'no such element', @@ -70,6 +71,7 @@ export const enum ErrorCode { NoSuchScript = 'no such script', NoSuchStoragePartition = 'no such storage partition', NoSuchUserContext = 'no such user context', + NoSuchWebExtension = 'no such web extension', SessionNotCreated = 'session not created', UnableToCaptureScreen = 'unable to capture screen', UnableToCloseBrowser = 'unable to close browser', @@ -237,11 +239,28 @@ export namespace Session { export type BrowserCommand = | Browser.Close | Browser.CreateUserContext + | Browser.GetClientWindows | Browser.GetUserContexts - | Browser.RemoveUserContext; + | Browser.RemoveUserContext + | Browser.SetClientWindowState + | Record; export type BrowserResult = | Browser.CreateUserContextResult | Browser.GetUserContextsResult; +export namespace Browser { + export type ClientWindow = string; +} +export namespace Browser { + export type ClientWindowInfo = { + active: boolean; + clientWindow: Browser.ClientWindow; + height: JsUint; + state: 'fullscreen' | 'maximized' | 'minimized' | 'normal'; + width: JsUint; + x: JsInt; + y: JsInt; + }; +} export namespace Browser { export type UserContext = string; } @@ -265,6 +284,17 @@ export namespace Browser { export namespace Browser { export type CreateUserContextResult = Browser.UserContextInfo; } +export namespace Browser { + export type GetClientWindows = { + method: 'browser.getClientWindows'; + params: EmptyParams; + }; +} +export namespace Browser { + export type GetClientWindowsResult = { + clientWindows: [...Browser.ClientWindowInfo[]]; + }; +} export namespace Browser { export type GetUserContexts = { method: 'browser.getUserContexts'; @@ -287,6 +317,33 @@ export namespace Browser { userContext: Browser.UserContext; }; } +export namespace Browser { + export type SetClientWindowState = { + method: 'browser.setClientWindowState'; + params: Browser.SetClientWindowStateParameters; + }; +} +export namespace Browser { + export type SetClientWindowStateParameters = + | ({ + clientWindow: Browser.ClientWindow; + } & Browser.ClientWindowNamedState) + | Browser.ClientWindowRectState; +} +export namespace Browser { + export type ClientWindowNamedState = { + state: 'fullscreen' | 'maximized' | 'minimized'; + }; +} +export namespace Browser { + export type ClientWindowRectState = { + state: 'normal'; + width?: JsUint; + height?: JsUint; + x?: JsInt; + y?: JsInt; + }; +} export type BrowsingContextCommand = | BrowsingContext.Activate | BrowsingContext.CaptureScreenshot @@ -306,6 +363,7 @@ export type BrowsingContextEvent = | BrowsingContext.DomContentLoaded | BrowsingContext.DownloadWillBegin | BrowsingContext.FragmentNavigated + | BrowsingContext.HistoryUpdated | BrowsingContext.Load | BrowsingContext.NavigationAborted | BrowsingContext.NavigationFailed @@ -329,6 +387,7 @@ export namespace BrowsingContext { export namespace BrowsingContext { export type Info = { children: BrowsingContext.InfoList | null; + clientWindow: Browser.ClientWindow; context: BrowsingContext.BrowsingContext; originalOpener: BrowsingContext.BrowsingContext | null; url: string; @@ -731,6 +790,18 @@ export namespace BrowsingContext { params: BrowsingContext.NavigationInfo; }; } +export namespace BrowsingContext { + export type HistoryUpdated = { + method: 'browsingContext.historyUpdated'; + params: BrowsingContext.HistoryUpdatedParameters; + }; +} +export namespace BrowsingContext { + export type HistoryUpdatedParameters = { + context: BrowsingContext.BrowsingContext; + url: string; + }; +} export namespace BrowsingContext { export type DomContentLoaded = { method: 'browsingContext.domContentLoaded'; @@ -896,11 +967,11 @@ export namespace Network { } export namespace Network { export type Initiator = { - type: 'parser' | 'script' | 'preflight' | 'other'; columnNumber?: JsUint; lineNumber?: JsUint; - stackTrace?: Script.StackTrace; request?: Network.Request; + stackTrace?: Script.StackTrace; + type?: 'parser' | 'script' | 'preflight' | 'other'; }; } export namespace Network { @@ -918,6 +989,8 @@ export namespace Network { cookies: [...Network.Cookie[]]; headersSize: JsUint; bodySize: JsUint | null; + destination: string; + initiatorType: string | null; timings: Network.FetchTimingInfo; }; } @@ -1123,7 +1196,7 @@ export namespace Network { } export namespace Network { export type BeforeRequestSentParameters = Network.BaseParameters & { - initiator: Network.Initiator; + initiator?: Network.Initiator; }; } export namespace Network { @@ -2189,3 +2262,60 @@ export namespace Input { files: [...string[]]; }; } +export type WebExtensionsCommand = WebExtension.Install & + WebExtension.Uninstall; +export type WebExtensionsResult = WebExtension.InstallResult; +export namespace WebExtension { + export type Extension = string; +} +export namespace WebExtension { + export type InstallParameters = { + extensionData: WebExtension.ExtensionData; + }; +} +export namespace WebExtension { + export type Install = { + method: 'webExtension.install'; + params: WebExtension.InstallParameters; + }; +} +export namespace WebExtension { + export type ExtensionData = + | WebExtension.ExtensionArchivePath + | WebExtension.ExtensionBase64Encoded + | WebExtension.ExtensionPath; +} +export namespace WebExtension { + export type ExtensionPath = { + type: 'path'; + path: string; + }; +} +export namespace WebExtension { + export type ExtensionArchivePath = { + type: 'archivePath'; + path: string; + }; +} +export namespace WebExtension { + export type ExtensionBase64Encoded = { + type: 'base64'; + value: string; + }; +} +export namespace WebExtension { + export type InstallResult = { + extension: WebExtension.Extension; + }; +} +export namespace WebExtension { + export type Uninstall = { + method: 'webExtension.uninstall'; + params: WebExtension.UninstallParameters; + }; +} +export namespace WebExtension { + export type UninstallParameters = { + extension: WebExtension.Extension; + }; +} diff --git a/src/gen/web-bluetooth.ts b/src/gen/web-bluetooth.ts new file mode 100644 index 0000000..2581c51 --- /dev/null +++ b/src/gen/web-bluetooth.ts @@ -0,0 +1,114 @@ +export namespace Bluetooth { + export type BluetoothServiceUuid = string; +} +export namespace Bluetooth { + export type BluetoothManufacturerData = { + key: number; + data: string; + }; +} +export namespace Bluetooth { + export type RequestDevice = string; +} +export namespace Bluetooth { + export type RequestDeviceInfo = { + id: Bluetooth.RequestDevice; + name: string | null; + }; +} +export namespace Bluetooth { + export type RequestDevicePrompt = string; +} +export namespace Bluetooth { + export type ScanRecord = { + name?: string; + uuids?: [...Bluetooth.BluetoothServiceUuid[]]; + appearance?: number; + manufacturerData?: [...Bluetooth.BluetoothManufacturerData[]]; + }; +} +export namespace Bluetooth { + export type HandleRequestDevicePrompt = { + method: 'bluetooth.handleRequestDevicePrompt'; + params: Bluetooth.HandleRequestDevicePromptParameters; + }; +} +export namespace Bluetooth { + export type HandleRequestDevicePromptParameters = { + context: string; + prompt: Bluetooth.RequestDevicePrompt; + } & ( + | Bluetooth.HandleRequestDevicePromptAcceptParameters + | Bluetooth.HandleRequestDevicePromptCancelParameters + ); +} +export namespace Bluetooth { + export type HandleRequestDevicePromptAcceptParameters = { + accept: true; + device: Bluetooth.RequestDevice; + }; +} +export namespace Bluetooth { + export type HandleRequestDevicePromptCancelParameters = { + accept: false; + }; +} +export namespace Bluetooth { + export type SimulateAdapter = { + method: 'bluetooth.simulateAdapter'; + params: Bluetooth.SimulateAdapterParameters; + }; +} +export namespace Bluetooth { + export type SimulateAdapterParameters = { + context: string; + state: 'absent' | 'powered-off' | 'powered-on'; + }; +} +export namespace Bluetooth { + export type SimulatePreconnectedPeripheral = { + method: 'bluetooth.simulatePreconnectedPeripheral'; + params: Bluetooth.SimulatePreconnectedPeripheralParameters; + }; +} +export namespace Bluetooth { + export type SimulatePreconnectedPeripheralParameters = { + context: string; + address: string; + name: string; + manufacturerData: [...Bluetooth.BluetoothManufacturerData[]]; + knownServiceUuids: [...Bluetooth.BluetoothServiceUuid[]]; + }; +} +export namespace Bluetooth { + export type SimulateAdvertisement = { + method: 'bluetooth.simulateAdvertisement'; + params: Bluetooth.SimulateAdvertisementParameters; + }; +} +export namespace Bluetooth { + export type SimulateAdvertisementParameters = { + context: string; + scanEntry: Bluetooth.SimulateAdvertisementScanEntryParameters; + }; +} +export namespace Bluetooth { + export type SimulateAdvertisementScanEntryParameters = { + deviceAddress: string; + rssi: number; + scanRecord: Bluetooth.ScanRecord; + }; +} +export namespace Bluetooth { + export type RequestDevicePromptUpdated = { + method: 'bluetooth.requestDevicePromptUpdated'; + params: Bluetooth.RequestDevicePromptUpdatedParameters; + }; +} +export namespace Bluetooth { + export type RequestDevicePromptUpdatedParameters = { + context: string; + prompt: Bluetooth.RequestDevicePrompt; + devices: [...Bluetooth.RequestDeviceInfo[]]; + }; +} diff --git a/src/index.ts b/src/index.ts index 2a3099e..bcab8fc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,33 +6,42 @@ import * as Bidi from './gen/main.js'; import * as BidiPermissions from './gen/permissions.js'; +import * as BidiBluetooth from './gen/web-bluetooth.js'; export * from './gen/main.js'; export * from './gen/permissions.js'; +export * from './gen/web-bluetooth.js'; -export type Command = Bidi.Command | BidiPermissions.Permissions.SetPermission; -export type Event = Bidi.Event; +export type Command = + | Bidi.Command + | BidiPermissions.Permissions.SetPermission + | BidiBluetooth.Bluetooth.SimulateAdapter + | BidiBluetooth.Bluetooth.HandleRequestDevicePrompt + | BidiBluetooth.Bluetooth.SimulateAdvertisement + | BidiBluetooth.Bluetooth.SimulatePreconnectedPeripheral; +export type Event = + | Bidi.Event + | ({ + type: 'event'; + } & BidiBluetooth.Bluetooth.RequestDevicePromptUpdated & + Bidi.Extensible); // TODO: is there a way to generate this mapping? export interface Commands { - 'script.evaluate': { - params: Bidi.Script.EvaluateParameters; - returnType: Bidi.Script.EvaluateResult; - }; - 'script.callFunction': { - params: Bidi.Script.CallFunctionParameters; - returnType: Bidi.Script.EvaluateResult; + 'bluetooth.handleRequestDevicePrompt': { + params: BidiBluetooth.Bluetooth.HandleRequestDevicePromptParameters; + returnType: Bidi.EmptyResult; }; - 'script.disown': { - params: Bidi.Script.DisownParameters; + 'bluetooth.simulateAdapter': { + params: BidiBluetooth.Bluetooth.SimulateAdapterParameters; returnType: Bidi.EmptyResult; }; - 'script.addPreloadScript': { - params: Bidi.Script.AddPreloadScriptParameters; - returnType: Bidi.Script.AddPreloadScriptResult; + 'bluetooth.simulateAdvertisement': { + params: BidiBluetooth.Bluetooth.SimulateAdvertisementParameters; + returnType: Bidi.EmptyResult; }; - 'script.removePreloadScript': { - params: Bidi.Script.RemovePreloadScriptParameters; + 'bluetooth.simulatePreconnectedPeripheral': { + params: BidiBluetooth.Bluetooth.SimulatePreconnectedPeripheral; returnType: Bidi.EmptyResult; }; @@ -40,7 +49,6 @@ export interface Commands { params: Bidi.EmptyParams; returnType: Bidi.EmptyResult; }; - 'browser.createUserContext': { params: Bidi.EmptyParams; returnType: Bidi.Browser.CreateUserContextResult; @@ -123,6 +131,27 @@ export interface Commands { returnType: Bidi.EmptyResult; }; + 'script.evaluate': { + params: Bidi.Script.EvaluateParameters; + returnType: Bidi.Script.EvaluateResult; + }; + 'script.callFunction': { + params: Bidi.Script.CallFunctionParameters; + returnType: Bidi.Script.EvaluateResult; + }; + 'script.disown': { + params: Bidi.Script.DisownParameters; + returnType: Bidi.EmptyResult; + }; + 'script.addPreloadScript': { + params: Bidi.Script.AddPreloadScriptParameters; + returnType: Bidi.Script.AddPreloadScriptResult; + }; + 'script.removePreloadScript': { + params: Bidi.Script.RemovePreloadScriptParameters; + returnType: Bidi.EmptyResult; + }; + 'session.end': { params: Bidi.EmptyParams; returnType: Bidi.EmptyResult; @@ -181,4 +210,13 @@ export interface Commands { params: Bidi.Network.ProvideResponseParameters; returnType: Bidi.EmptyResult; }; + + 'webExtension.install': { + params: Bidi.WebExtension.InstallParameters; + returnType: Bidi.WebExtension.InstallResult; + }; + 'webExtension.uninstall': { + params: Bidi.WebExtension.UninstallParameters; + returnType: Bidi.EmptyResult; + }; } diff --git a/test-d/webdriver-bidi-protocol.test-d.ts b/test-d/webdriver-bidi-protocol.test-d.ts index 9715c61..40212b0 100644 --- a/test-d/webdriver-bidi-protocol.test-d.ts +++ b/test-d/webdriver-bidi-protocol.test-d.ts @@ -42,5 +42,21 @@ handleEvent({ url: '', userContext: '', originalOpener: null, + clientWindow: '', + }, +}); + +sendCommandMultipleArgs('bluetooth.simulateAdapter', { + context: '', + state: 'powered-on', +}); + +handleEvent({ + type: 'event', + method: 'bluetooth.requestDevicePromptUpdated', + params: { + context: '', + prompt: '', + devices: [], }, }); diff --git a/tools/build.sh b/tools/build.sh index 3b227ed..3bffd7e 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -11,12 +11,15 @@ git submodule update --init (cd specs/webdriver-bidi && scripts/cddl/generate.js) (cd specs/permissions && ../webdriver-bidi/scripts/cddl/generate.js index.html) +(cd specs/web-bluetooth && ../webdriver-bidi/scripts/cddl/generate.js index.bs) cddlconv specs/webdriver-bidi/all.cddl > src/gen/main.ts cddlconv specs/permissions/all.cddl > src/gen/permissions.ts +cddlconv specs/web-bluetooth/all.cddl > src/gen/web-bluetooth.ts (cd specs/webdriver-bidi && git reset --hard HEAD && git clean -fd) (cd specs/permissions && git reset --hard HEAD && git clean -fd) +(cd specs/web-bluetooth && git reset --hard HEAD && git clean -fd) git submodule deinit --all