Skip to content

Commit e42e8d9

Browse files
authored
feat: add bluetooth (GoogleChromeLabs#66)
1 parent b096a82 commit e42e8d9

File tree

12 files changed

+630
-41
lines changed

12 files changed

+630
-41
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "specs/permissions"]
55
path = specs/permissions
66
url = https://github.com/w3c/permissions.git
7+
[submodule "specs/web-bluetooth"]
8+
path = specs/web-bluetooth
9+
url = https://github.com/WebBluetoothCG/web-bluetooth.git

out/gen/main.d.ts

Lines changed: 134 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export declare const enum ErrorCode {
5656
InvalidArgument = 'invalid argument',
5757
InvalidSelector = 'invalid selector',
5858
InvalidSessionId = 'invalid session id',
59+
InvalidWebExtension = 'invalid web extension',
5960
MoveTargetOutOfBounds = 'move target out of bounds',
6061
NoSuchAlert = 'no such alert',
6162
NoSuchElement = 'no such element',
@@ -68,6 +69,7 @@ export declare const enum ErrorCode {
6869
NoSuchScript = 'no such script',
6970
NoSuchStoragePartition = 'no such storage partition',
7071
NoSuchUserContext = 'no such user context',
72+
NoSuchWebExtension = 'no such web extension',
7173
SessionNotCreated = 'session not created',
7274
UnableToCaptureScreen = 'unable to capture screen',
7375
UnableToCloseBrowser = 'unable to close browser',
@@ -235,11 +237,28 @@ export declare namespace Session {
235237
export type BrowserCommand =
236238
| Browser.Close
237239
| Browser.CreateUserContext
240+
| Browser.GetClientWindows
238241
| Browser.GetUserContexts
239-
| Browser.RemoveUserContext;
242+
| Browser.RemoveUserContext
243+
| Browser.SetClientWindowState
244+
| Record<string, never>;
240245
export type BrowserResult =
241246
| Browser.CreateUserContextResult
242247
| Browser.GetUserContextsResult;
248+
export declare namespace Browser {
249+
type ClientWindow = string;
250+
}
251+
export declare namespace Browser {
252+
type ClientWindowInfo = {
253+
active: boolean;
254+
clientWindow: Browser.ClientWindow;
255+
height: JsUint;
256+
state: 'fullscreen' | 'maximized' | 'minimized' | 'normal';
257+
width: JsUint;
258+
x: JsInt;
259+
y: JsInt;
260+
};
261+
}
243262
export declare namespace Browser {
244263
type UserContext = string;
245264
}
@@ -263,6 +282,17 @@ export declare namespace Browser {
263282
export declare namespace Browser {
264283
type CreateUserContextResult = Browser.UserContextInfo;
265284
}
285+
export declare namespace Browser {
286+
type GetClientWindows = {
287+
method: 'browser.getClientWindows';
288+
params: EmptyParams;
289+
};
290+
}
291+
export declare namespace Browser {
292+
type GetClientWindowsResult = {
293+
clientWindows: [...Browser.ClientWindowInfo[]];
294+
};
295+
}
266296
export declare namespace Browser {
267297
type GetUserContexts = {
268298
method: 'browser.getUserContexts';
@@ -285,6 +315,33 @@ export declare namespace Browser {
285315
userContext: Browser.UserContext;
286316
};
287317
}
318+
export declare namespace Browser {
319+
type SetClientWindowState = {
320+
method: 'browser.setClientWindowState';
321+
params: Browser.SetClientWindowStateParameters;
322+
};
323+
}
324+
export declare namespace Browser {
325+
type SetClientWindowStateParameters =
326+
| ({
327+
clientWindow: Browser.ClientWindow;
328+
} & Browser.ClientWindowNamedState)
329+
| Browser.ClientWindowRectState;
330+
}
331+
export declare namespace Browser {
332+
type ClientWindowNamedState = {
333+
state: 'fullscreen' | 'maximized' | 'minimized';
334+
};
335+
}
336+
export declare namespace Browser {
337+
type ClientWindowRectState = {
338+
state: 'normal';
339+
width?: JsUint;
340+
height?: JsUint;
341+
x?: JsInt;
342+
y?: JsInt;
343+
};
344+
}
288345
export type BrowsingContextCommand =
289346
| BrowsingContext.Activate
290347
| BrowsingContext.CaptureScreenshot
@@ -304,6 +361,7 @@ export type BrowsingContextEvent =
304361
| BrowsingContext.DomContentLoaded
305362
| BrowsingContext.DownloadWillBegin
306363
| BrowsingContext.FragmentNavigated
364+
| BrowsingContext.HistoryUpdated
307365
| BrowsingContext.Load
308366
| BrowsingContext.NavigationAborted
309367
| BrowsingContext.NavigationFailed
@@ -327,6 +385,7 @@ export declare namespace BrowsingContext {
327385
export declare namespace BrowsingContext {
328386
type Info = {
329387
children: BrowsingContext.InfoList | null;
388+
clientWindow: Browser.ClientWindow;
330389
context: BrowsingContext.BrowsingContext;
331390
originalOpener: BrowsingContext.BrowsingContext | null;
332391
url: string;
@@ -729,6 +788,18 @@ export declare namespace BrowsingContext {
729788
params: BrowsingContext.NavigationInfo;
730789
};
731790
}
791+
export declare namespace BrowsingContext {
792+
type HistoryUpdated = {
793+
method: 'browsingContext.historyUpdated';
794+
params: BrowsingContext.HistoryUpdatedParameters;
795+
};
796+
}
797+
export declare namespace BrowsingContext {
798+
type HistoryUpdatedParameters = {
799+
context: BrowsingContext.BrowsingContext;
800+
url: string;
801+
};
802+
}
732803
export declare namespace BrowsingContext {
733804
type DomContentLoaded = {
734805
method: 'browsingContext.domContentLoaded';
@@ -894,11 +965,11 @@ export declare namespace Network {
894965
}
895966
export declare namespace Network {
896967
type Initiator = {
897-
type: 'parser' | 'script' | 'preflight' | 'other';
898968
columnNumber?: JsUint;
899969
lineNumber?: JsUint;
900-
stackTrace?: Script.StackTrace;
901970
request?: Network.Request;
971+
stackTrace?: Script.StackTrace;
972+
type?: 'parser' | 'script' | 'preflight' | 'other';
902973
};
903974
}
904975
export declare namespace Network {
@@ -916,6 +987,8 @@ export declare namespace Network {
916987
cookies: [...Network.Cookie[]];
917988
headersSize: JsUint;
918989
bodySize: JsUint | null;
990+
destination: string;
991+
initiatorType: string | null;
919992
timings: Network.FetchTimingInfo;
920993
};
921994
}
@@ -1121,7 +1194,7 @@ export declare namespace Network {
11211194
}
11221195
export declare namespace Network {
11231196
type BeforeRequestSentParameters = Network.BaseParameters & {
1124-
initiator: Network.Initiator;
1197+
initiator?: Network.Initiator;
11251198
};
11261199
}
11271200
export declare namespace Network {
@@ -2185,3 +2258,60 @@ export declare namespace Input {
21852258
files: [...string[]];
21862259
};
21872260
}
2261+
export type WebExtensionsCommand = WebExtension.Install &
2262+
WebExtension.Uninstall;
2263+
export type WebExtensionsResult = WebExtension.InstallResult;
2264+
export declare namespace WebExtension {
2265+
type Extension = string;
2266+
}
2267+
export declare namespace WebExtension {
2268+
type InstallParameters = {
2269+
extensionData: WebExtension.ExtensionData;
2270+
};
2271+
}
2272+
export declare namespace WebExtension {
2273+
type Install = {
2274+
method: 'webExtension.install';
2275+
params: WebExtension.InstallParameters;
2276+
};
2277+
}
2278+
export declare namespace WebExtension {
2279+
type ExtensionData =
2280+
| WebExtension.ExtensionArchivePath
2281+
| WebExtension.ExtensionBase64Encoded
2282+
| WebExtension.ExtensionPath;
2283+
}
2284+
export declare namespace WebExtension {
2285+
type ExtensionPath = {
2286+
type: 'path';
2287+
path: string;
2288+
};
2289+
}
2290+
export declare namespace WebExtension {
2291+
type ExtensionArchivePath = {
2292+
type: 'archivePath';
2293+
path: string;
2294+
};
2295+
}
2296+
export declare namespace WebExtension {
2297+
type ExtensionBase64Encoded = {
2298+
type: 'base64';
2299+
value: string;
2300+
};
2301+
}
2302+
export declare namespace WebExtension {
2303+
type InstallResult = {
2304+
extension: WebExtension.Extension;
2305+
};
2306+
}
2307+
export declare namespace WebExtension {
2308+
type Uninstall = {
2309+
method: 'webExtension.uninstall';
2310+
params: WebExtension.UninstallParameters;
2311+
};
2312+
}
2313+
export declare namespace WebExtension {
2314+
type UninstallParameters = {
2315+
extension: WebExtension.Extension;
2316+
};
2317+
}

out/gen/web-bluetooth.d.ts

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
export declare namespace Bluetooth {
2+
type BluetoothServiceUuid = string;
3+
}
4+
export declare namespace Bluetooth {
5+
type BluetoothManufacturerData = {
6+
key: number;
7+
data: string;
8+
};
9+
}
10+
export declare namespace Bluetooth {
11+
type RequestDevice = string;
12+
}
13+
export declare namespace Bluetooth {
14+
type RequestDeviceInfo = {
15+
id: Bluetooth.RequestDevice;
16+
name: string | null;
17+
};
18+
}
19+
export declare namespace Bluetooth {
20+
type RequestDevicePrompt = string;
21+
}
22+
export declare namespace Bluetooth {
23+
type ScanRecord = {
24+
name?: string;
25+
uuids?: [...Bluetooth.BluetoothServiceUuid[]];
26+
appearance?: number;
27+
manufacturerData?: [...Bluetooth.BluetoothManufacturerData[]];
28+
};
29+
}
30+
export declare namespace Bluetooth {
31+
type HandleRequestDevicePrompt = {
32+
method: 'bluetooth.handleRequestDevicePrompt';
33+
params: Bluetooth.HandleRequestDevicePromptParameters;
34+
};
35+
}
36+
export declare namespace Bluetooth {
37+
type HandleRequestDevicePromptParameters = {
38+
context: string;
39+
prompt: Bluetooth.RequestDevicePrompt;
40+
} & (
41+
| Bluetooth.HandleRequestDevicePromptAcceptParameters
42+
| Bluetooth.HandleRequestDevicePromptCancelParameters
43+
);
44+
}
45+
export declare namespace Bluetooth {
46+
type HandleRequestDevicePromptAcceptParameters = {
47+
accept: true;
48+
device: Bluetooth.RequestDevice;
49+
};
50+
}
51+
export declare namespace Bluetooth {
52+
type HandleRequestDevicePromptCancelParameters = {
53+
accept: false;
54+
};
55+
}
56+
export declare namespace Bluetooth {
57+
type SimulateAdapter = {
58+
method: 'bluetooth.simulateAdapter';
59+
params: Bluetooth.SimulateAdapterParameters;
60+
};
61+
}
62+
export declare namespace Bluetooth {
63+
type SimulateAdapterParameters = {
64+
context: string;
65+
state: 'absent' | 'powered-off' | 'powered-on';
66+
};
67+
}
68+
export declare namespace Bluetooth {
69+
type SimulatePreconnectedPeripheral = {
70+
method: 'bluetooth.simulatePreconnectedPeripheral';
71+
params: Bluetooth.SimulatePreconnectedPeripheralParameters;
72+
};
73+
}
74+
export declare namespace Bluetooth {
75+
type SimulatePreconnectedPeripheralParameters = {
76+
context: string;
77+
address: string;
78+
name: string;
79+
manufacturerData: [...Bluetooth.BluetoothManufacturerData[]];
80+
knownServiceUuids: [...Bluetooth.BluetoothServiceUuid[]];
81+
};
82+
}
83+
export declare namespace Bluetooth {
84+
type SimulateAdvertisement = {
85+
method: 'bluetooth.simulateAdvertisement';
86+
params: Bluetooth.SimulateAdvertisementParameters;
87+
};
88+
}
89+
export declare namespace Bluetooth {
90+
type SimulateAdvertisementParameters = {
91+
context: string;
92+
scanEntry: Bluetooth.SimulateAdvertisementScanEntryParameters;
93+
};
94+
}
95+
export declare namespace Bluetooth {
96+
type SimulateAdvertisementScanEntryParameters = {
97+
deviceAddress: string;
98+
rssi: number;
99+
scanRecord: Bluetooth.ScanRecord;
100+
};
101+
}
102+
export declare namespace Bluetooth {
103+
type RequestDevicePromptUpdated = {
104+
method: 'bluetooth.requestDevicePromptUpdated';
105+
params: Bluetooth.RequestDevicePromptUpdatedParameters;
106+
};
107+
}
108+
export declare namespace Bluetooth {
109+
type RequestDevicePromptUpdatedParameters = {
110+
context: string;
111+
prompt: Bluetooth.RequestDevicePrompt;
112+
devices: [...Bluetooth.RequestDeviceInfo[]];
113+
};
114+
}

out/gen/web-bluetooth.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
'use strict';
2+
Object.defineProperty(exports, '__esModule', {value: true});

0 commit comments

Comments
 (0)