Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

chromium-bidi

Package Overview
Dependencies
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chromium-bidi - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

1

lib/cjs/bidiMapper/BidiServer.d.ts

@@ -32,2 +32,3 @@ /**

unhandledPromptBehavior?: Session.UserPromptHandler;
'goog:prerenderingDisabled'?: boolean;
};

@@ -34,0 +35,0 @@ export declare class BidiServer extends EventEmitter<BidiServerEvent> {

@@ -67,3 +67,3 @@ "use strict";

});
new CdpTargetManager_js_1.CdpTargetManager(cdpConnection, browserCdpClient, selfTargetId, this.#eventManager, this.#browsingContextStorage, this.#realmStorage, networkStorage, this.#bluetoothProcessor, this.#preloadScriptStorage, defaultUserContextId, options?.unhandledPromptBehavior, logger);
new CdpTargetManager_js_1.CdpTargetManager(cdpConnection, browserCdpClient, selfTargetId, this.#eventManager, this.#browsingContextStorage, this.#realmStorage, networkStorage, this.#bluetoothProcessor, this.#preloadScriptStorage, defaultUserContextId, options?.['goog:prerenderingDisabled'] ?? false, options?.unhandledPromptBehavior, logger);
// Needed to get events about new targets.

@@ -78,2 +78,11 @@ await browserCdpClient.sendCommand('Target.setDiscoverTargets', {

flatten: true,
// Browser session should attach to tab instead of the page, so that
// prerendering is not blocked.
filter: [
{
type: 'page',
exclude: true,
},
{},
],
});

@@ -80,0 +89,0 @@ await this.#topLevelContextsLoaded();

@@ -75,2 +75,8 @@ "use strict";

return await this.#bluetoothProcessor.handleRequestDevicePrompt(this.#parser.parseHandleRequestDevicePromptParams(command.params));
case 'bluetooth.simulateAdapter':
return await this.#bluetoothProcessor.simulateAdapter(command.params);
case 'bluetooth.simulateAdvertisement':
return await this.#bluetoothProcessor.simulateAdvertisement(command.params);
case 'bluetooth.simulatePreconnectedPeripheral':
return await this.#bluetoothProcessor.simulatePreconnectedPeripheral(command.params);
// keep-sorted end

@@ -77,0 +83,0 @@ // Browser domain

@@ -24,4 +24,7 @@ /**

constructor(eventManager: EventManager, browsingContextStorage: BrowsingContextStorage);
simulateAdapter(params: Bluetooth.SimulateAdapterParameters): Promise<EmptyResult>;
simulatePreconnectedPeripheral(params: Bluetooth.SimulatePreconnectedPeripheralParameters): Promise<EmptyResult>;
simulateAdvertisement(params: Bluetooth.SimulateAdvertisementParameters): Promise<EmptyResult>;
onCdpTargetCreated(cdpTarget: CdpTarget): void;
handleRequestDevicePrompt(params: Bluetooth.HandleRequestDevicePromptParameters): Promise<EmptyResult>;
}

@@ -27,2 +27,26 @@ "use strict";

}
async simulateAdapter(params) {
const context = this.#browsingContextStorage.getContext(params.context);
await context.cdpTarget.browserCdpClient.sendCommand('BluetoothEmulation.enable', {
state: params.state,
});
return {};
}
async simulatePreconnectedPeripheral(params) {
const context = this.#browsingContextStorage.getContext(params.context);
await context.cdpTarget.browserCdpClient.sendCommand('BluetoothEmulation.simulatePreconnectedPeripheral', {
address: params.address,
name: params.name,
knownServiceUuids: params.knownServiceUuids,
manufacturerData: params.manufacturerData,
});
return {};
}
async simulateAdvertisement(params) {
const context = this.#browsingContextStorage.getContext(params.context);
await context.cdpTarget.browserCdpClient.sendCommand('BluetoothEmulation.simulateAdvertisement', {
entry: params.scanEntry,
});
return {};
}
onCdpTargetCreated(cdpTarget) {

@@ -29,0 +53,0 @@ cdpTarget.cdpClient.on('DeviceAccess.deviceRequestPrompted', (event) => {

5

lib/cjs/bidiMapper/modules/cdp/CdpTarget.d.ts

@@ -15,4 +15,4 @@ import type { Protocol } from 'devtools-protocol';

#private;
static create(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, realmStorage: RealmStorage, eventManager: EventManager, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn): CdpTarget;
constructor(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, eventManager: EventManager, realmStorage: RealmStorage, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn);
static create(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, parentCdpClient: CdpClient, realmStorage: RealmStorage, eventManager: EventManager, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, prerenderingDisabled: boolean, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn): CdpTarget;
constructor(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, parentCdpClient: CdpClient, eventManager: EventManager, realmStorage: RealmStorage, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, prerenderingDisabled: boolean, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn);
/** Returns a deferred that resolves when the target is unblocked. */

@@ -22,2 +22,3 @@ get unblocked(): Deferred<Result<void>>;

get cdpClient(): CdpClient;
get parentCdpClient(): CdpClient;
get browserCdpClient(): CdpClient;

@@ -24,0 +25,0 @@ /** Needed for CDP escape path. */

@@ -13,2 +13,3 @@ "use strict";

#browserCdpClient;
#parentCdpClient;
#realmStorage;

@@ -18,2 +19,3 @@ #eventManager;

#browsingContextStorage;
#prerenderingDisabled;
#networkStorage;

@@ -31,4 +33,4 @@ #unblocked = new Deferred_js_1.Deferred();

};
static create(targetId, cdpClient, browserCdpClient, realmStorage, eventManager, preloadScriptStorage, browsingContextStorage, networkStorage, unhandledPromptBehavior, logger) {
const cdpTarget = new CdpTarget(targetId, cdpClient, browserCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, unhandledPromptBehavior, logger);
static create(targetId, cdpClient, browserCdpClient, parentCdpClient, realmStorage, eventManager, preloadScriptStorage, browsingContextStorage, networkStorage, prerenderingDisabled, unhandledPromptBehavior, logger) {
const cdpTarget = new CdpTarget(targetId, cdpClient, browserCdpClient, parentCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, prerenderingDisabled, unhandledPromptBehavior, logger);
LogManager_js_1.LogManager.create(cdpTarget, realmStorage, eventManager, logger);

@@ -41,6 +43,7 @@ cdpTarget.#setEventListeners();

}
constructor(targetId, cdpClient, browserCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, unhandledPromptBehavior, logger) {
constructor(targetId, cdpClient, browserCdpClient, parentCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, prerenderingDisabled, unhandledPromptBehavior, logger) {
this.#id = targetId;
this.#cdpClient = cdpClient;
this.#browserCdpClient = browserCdpClient;
this.#parentCdpClient = parentCdpClient;
this.#eventManager = eventManager;

@@ -51,2 +54,3 @@ this.#realmStorage = realmStorage;

this.#browsingContextStorage = browsingContextStorage;
this.#prerenderingDisabled = prerenderingDisabled;
this.#unhandledPromptBehavior = unhandledPromptBehavior;

@@ -65,2 +69,5 @@ this.#logger = logger;

}
get parentCdpClient() {
return this.#parentCdpClient;
}
get browserCdpClient() {

@@ -96,2 +103,11 @@ return this.#browserCdpClient;

}),
this.#cdpClient
.sendCommand('Page.setPrerenderingAllowed', {
isAllowed: !this.#prerenderingDisabled,
})
.catch(() => {
// Ignore CDP errors, as the command is not supported by iframe targets or
// prerendered pages. Generic catch, as the error can vary between CdpClient
// implementations: Tab vs Puppeteer.
}),
this.toggleNetworkIfNeeded(),

@@ -105,2 +121,4 @@ this.#cdpClient.sendCommand('Target.setAutoAttach', {

this.#cdpClient.sendCommand('Runtime.runIfWaitingForDebugger'),
// Resume tab execution as well if it was paused by the debugger.
this.#parentCdpClient.sendCommand('Runtime.runIfWaitingForDebugger'),
this.toggleDeviceAccessIfNeeded(),

@@ -249,4 +267,5 @@ ]);

const error = err;
return (error.code === -32001 &&
error.message === 'Session with given id not found.');
return ((error.code === -32001 &&
error.message === 'Session with given id not found.') ||
this.#cdpClient.isCloseError(err));
}

@@ -253,0 +272,0 @@ #setEventListeners() {

@@ -13,3 +13,3 @@ import type { CdpClient } from '../../../cdp/CdpClient.js';

#private;
constructor(cdpConnection: CdpConnection, browserCdpClient: CdpClient, selfTargetId: string, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, networkStorage: NetworkStorage, bluetoothProcessor: BluetoothProcessor, preloadScriptStorage: PreloadScriptStorage, defaultUserContextId: Browser.UserContext, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn);
constructor(cdpConnection: CdpConnection, browserCdpClient: CdpClient, selfTargetId: string, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, networkStorage: NetworkStorage, bluetoothProcessor: BluetoothProcessor, preloadScriptStorage: PreloadScriptStorage, defaultUserContextId: Browser.UserContext, prerenderingDisabled: boolean, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn);
}

@@ -27,3 +27,4 @@ "use strict";

#unhandledPromptBehavior;
constructor(cdpConnection, browserCdpClient, selfTargetId, eventManager, browsingContextStorage, realmStorage, networkStorage, bluetoothProcessor, preloadScriptStorage, defaultUserContextId, unhandledPromptBehavior, logger) {
#prerenderingDisabled;
constructor(cdpConnection, browserCdpClient, selfTargetId, eventManager, browsingContextStorage, realmStorage, networkStorage, bluetoothProcessor, preloadScriptStorage, defaultUserContextId, prerenderingDisabled, unhandledPromptBehavior, logger) {
this.#cdpConnection = cdpConnection;

@@ -40,2 +41,3 @@ this.#browserCdpClient = browserCdpClient;

this.#defaultUserContextId = defaultUserContextId;
this.#prerenderingDisabled = prerenderingDisabled;
this.#unhandledPromptBehavior = unhandledPromptBehavior;

@@ -91,28 +93,41 @@ this.#logger = logger;

};
if (this.#selfTargetId !== targetInfo.targetId) {
// Service workers are special case because they attach to the
// browser target and the page target (so twice per worker) during
// the regular auto-attach and might hang if the CDP session on
// the browser level is not detached. The logic to detach the
// right session is handled in the switch below.
const targetKey = targetInfo.type === 'service_worker'
? `${parentSessionCdpClient.sessionId}_${targetInfo.targetId}`
: targetInfo.targetId;
// Mapper generally only needs one session per target. If we
// receive additional auto-attached sessions, that is very likely
// coming from custom CDP sessions.
if (this.#targetKeysToBeIgnoredByAutoAttach.has(targetKey)) {
// Return to leave the session untouched.
return;
}
this.#targetKeysToBeIgnoredByAutoAttach.add(targetKey);
// Do not attach to the Mapper target.
if (this.#selfTargetId === targetInfo.targetId) {
void detach();
return;
}
// Service workers are special case because they attach to the
// browser target and the page target (so twice per worker) during
// the regular auto-attach and might hang if the CDP session on
// the browser level is not detached. The logic to detach the
// right session is handled in the switch below.
const targetKey = targetInfo.type === 'service_worker'
? `${parentSessionCdpClient.sessionId}_${targetInfo.targetId}`
: targetInfo.targetId;
// Mapper generally only needs one session per target. If we
// receive additional auto-attached sessions, that is very likely
// coming from custom CDP sessions.
if (this.#targetKeysToBeIgnoredByAutoAttach.has(targetKey)) {
// Return to leave the session untouched.
return;
}
this.#targetKeysToBeIgnoredByAutoAttach.add(targetKey);
switch (targetInfo.type) {
case 'tab':
// Tab targets are required only to handle page targets beneath them.
this.#setEventListeners(targetCdpClient);
// Auto-attach to the page target. No need in resuming tab target debugger, as it
// should preserve the page target debugger state, and will be resumed by the page
// target.
void (async () => {
await targetCdpClient.sendCommand('Target.setAutoAttach', {
autoAttach: true,
waitForDebuggerOnStart: true,
flatten: true,
});
})();
return;
case 'page':
case 'iframe': {
if (this.#selfTargetId === targetInfo.targetId) {
void detach();
return;
}
const cdpTarget = this.#createCdpTarget(targetCdpClient, targetInfo);
const cdpTarget = this.#createCdpTarget(targetCdpClient, parentSessionCdpClient, targetInfo);
const maybeContext = this.#browsingContextStorage.findContext(targetInfo.targetId);

@@ -124,2 +139,5 @@ if (maybeContext && targetInfo.type === 'iframe') {

else {
// If attaching to existing browser instance, there could be OOPiF targets. This
// case is handled by the `findFrameParentId` method.
const parentId = this.#findFrameParentId(targetInfo, parentSessionCdpClient.sessionId);
const userContext = targetInfo.browserContextId &&

@@ -130,3 +148,3 @@ targetInfo.browserContextId !== this.#defaultUserContextId

// New context.
BrowsingContextImpl_js_1.BrowsingContextImpl.create(targetInfo.targetId, null, userContext, cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage,
BrowsingContextImpl_js_1.BrowsingContextImpl.create(targetInfo.targetId, parentId, userContext, cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage,
// Hack: when a new target created, CDP emits targetInfoChanged with an empty

@@ -154,3 +172,3 @@ // url, and navigates it to about:blank later. When the event is emitted for

}
const cdpTarget = this.#createCdpTarget(targetCdpClient, targetInfo);
const cdpTarget = this.#createCdpTarget(targetCdpClient, parentSessionCdpClient, targetInfo);
this.#handleWorkerTarget(cdpToBidiTargetTypes[targetInfo.type], cdpTarget, realm);

@@ -164,3 +182,3 @@ return;

case 'shared_worker': {
const cdpTarget = this.#createCdpTarget(targetCdpClient, targetInfo);
const cdpTarget = this.#createCdpTarget(targetCdpClient, parentSessionCdpClient, targetInfo);
this.#handleWorkerTarget(cdpToBidiTargetTypes[targetInfo.type], cdpTarget);

@@ -174,5 +192,20 @@ return;

}
#createCdpTarget(targetCdpClient, targetInfo) {
/** Try to find the parent browsing context ID for the given attached target. */
#findFrameParentId(targetInfo, parentSessionId) {
if (targetInfo.type !== 'iframe') {
return null;
}
const parentId = targetInfo.openerFrameId ?? targetInfo.openerId;
if (parentId !== undefined) {
return parentId;
}
if (parentSessionId !== undefined) {
return (this.#browsingContextStorage.findContextBySession(parentSessionId)
?.id ?? null);
}
return null;
}
#createCdpTarget(targetCdpClient, parentCdpClient, targetInfo) {
this.#setEventListeners(targetCdpClient);
const target = CdpTarget_js_1.CdpTarget.create(targetInfo.targetId, targetCdpClient, this.#browserCdpClient, this.#realmStorage, this.#eventManager, this.#preloadScriptStorage, this.#browsingContextStorage, this.#networkStorage, this.#unhandledPromptBehavior, this.#logger);
const target = CdpTarget_js_1.CdpTarget.create(targetInfo.targetId, targetCdpClient, this.#browserCdpClient, parentCdpClient, this.#realmStorage, this.#eventManager, this.#preloadScriptStorage, this.#browsingContextStorage, this.#networkStorage, this.#prerenderingDisabled, this.#unhandledPromptBehavior, this.#logger);
this.#networkStorage.onCdpTargetCreated(target);

@@ -179,0 +212,0 @@ this.#bluetoothProcessor.onCdpTargetCreated(target);

@@ -109,3 +109,10 @@ "use strict";

method: protocol_js_1.ChromiumBidi.BrowsingContext.EventNames.ContextCreated,
params: context.serializeToBidiValue(),
params: {
...context.serializeToBidiValue(),
// Hack to provide the initial URL of the context, as it can be changed
// between the page target is attached and unblocked, as the page is not
// fully paused in MPArch session (https://crbug.com/372842894).
// TODO: remove once https://crbug.com/372842894 is addressed.
url,
},
},

@@ -112,0 +119,0 @@ };

@@ -72,2 +72,5 @@ "use strict";

}
// Wait for the new target to be attached and to be added to the browsing context
// storage.
const context = await this.#browsingContextStorage.waitForContext(result.targetId);
// Wait for the new tab to be loaded to avoid race conditions in the

@@ -78,4 +81,2 @@ // `browsingContext` events, when the `browsingContext.domContentLoaded` and

// Details: https://github.com/web-platform-tests/wpt/issues/35846
const contextId = result.targetId;
const context = this.#browsingContextStorage.getContext(contextId);
await context.lifecycleLoaded();

@@ -147,2 +148,4 @@ return { context: context.id };

}
// Parent session of a page target session can be a `browser` or a `tab` session.
const parentCdpClient = context.cdpTarget.parentCdpClient;
try {

@@ -152,15 +155,24 @@ const detachedFromTargetPromise = new Promise((resolve) => {

if (event.targetId === params.context) {
this.#browserCdpClient.off('Target.detachedFromTarget', onContextDestroyed);
parentCdpClient.off('Target.detachedFromTarget', onContextDestroyed);
resolve();
}
};
this.#browserCdpClient.on('Target.detachedFromTarget', onContextDestroyed);
parentCdpClient.on('Target.detachedFromTarget', onContextDestroyed);
});
if (params.promptUnload) {
await context.close();
try {
if (params.promptUnload) {
await context.close();
}
else {
await parentCdpClient.sendCommand('Target.closeTarget', {
targetId: params.context,
});
}
}
else {
await this.#browserCdpClient.sendCommand('Target.closeTarget', {
targetId: params.context,
});
catch (error) {
// Swallow error that arise from the session being destroyed. Rely on the
// `detachedFromTargetPromise` event to be resolved.
if (!parentCdpClient.isCloseError(error)) {
throw error;
}
}

@@ -167,0 +179,0 @@ // Sometimes CDP command finishes before `detachedFromTarget` event,

@@ -32,2 +32,6 @@ /**

addContext(context: BrowsingContextImpl): void;
/**
* Waits for a context with the given ID to be added and returns it.
*/
waitForContext(browsingContextId: BrowsingContext.BrowsingContext): Promise<BrowsingContextImpl>;
/** Returns true whether there is an existing context with the given ID. */

@@ -34,0 +38,0 @@ hasContext(id: BrowsingContext.BrowsingContext): boolean;

@@ -21,2 +21,3 @@ "use strict";

const protocol_js_1 = require("../../../protocol/protocol.js");
const EventEmitter_js_1 = require("../../../utils/EventEmitter.js");
/** Container class for browsing contexts. */

@@ -26,2 +27,5 @@ class BrowsingContextStorage {

#contexts = new Map();
/** Event emitter for browsing context storage eventsis not expected to be exposed to
* the outside world. */
#eventEmitter = new EventEmitter_js_1.EventEmitter();
/** Gets all top-level contexts, i.e. those with no parent. */

@@ -46,3 +50,20 @@ getTopLevelContexts() {

this.#contexts.set(context.id, context);
this.#eventEmitter.emit("added" /* BrowsingContextStorageEvents.Added */, {
browsingContext: context,
});
}
/**
* Waits for a context with the given ID to be added and returns it.
*/
waitForContext(browsingContextId) {
return new Promise((resolve) => {
const listener = (event) => {
if (event.browsingContext.id === browsingContextId) {
this.#eventEmitter.off("added" /* BrowsingContextStorageEvents.Added */, listener);
resolve(event.browsingContext);
}
};
this.#eventEmitter.on("added" /* BrowsingContextStorageEvents.Added */, listener);
});
}
/** Returns true whether there is an existing context with the given ID. */

@@ -49,0 +70,0 @@ hasContext(id) {

@@ -57,9 +57,9 @@ /**

count: number;
"__#90491@#x": number;
"__#90491@#y": number;
"__#90491@#time": number;
"__#90798@#x": number;
"__#90798@#y": number;
"__#90798@#time": number;
compare(context: any): boolean;
};
"__#90491@#DOUBLE_CLICK_TIME_MS": number;
"__#90491@#MAX_DOUBLE_CLICK_RADIUS": number;
"__#90798@#DOUBLE_CLICK_TIME_MS": number;
"__#90798@#MAX_DOUBLE_CLICK_RADIUS": number;
};

@@ -66,0 +66,0 @@ setClickCount(button: number, context: InstanceType<typeof PointerSource.ClickContext>): number;

@@ -59,2 +59,3 @@ "use strict";

this.#commandCallbacks.set(id, {
sessionId,
resolve,

@@ -111,2 +112,8 @@ reject,

}
// Reject all the pending commands for the detached session.
for (const callback of this.#commandCallbacks.values()) {
if (callback.sessionId === sessionId) {
callback.reject(callback.error);
}
}
}

@@ -113,0 +120,0 @@ }

@@ -24,2 +24,17 @@ /**

export declare namespace Bluetooth {
const BluetoothServiceUuidSchema: z.ZodLazy<z.ZodString>;
}
export declare namespace Bluetooth {
const BluetoothManufacturerDataSchema: z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>;
}
export declare namespace Bluetooth {
const RequestDeviceSchema: z.ZodLazy<z.ZodString>;

@@ -43,2 +58,35 @@ }

export declare namespace Bluetooth {
const ScanRecordSchema: z.ZodLazy<z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
uuids: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodString>, "many">>;
appearance: z.ZodOptional<z.ZodNumber>;
manufacturerData: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">>;
}, "strip", z.ZodTypeAny, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}>>;
}
export declare namespace Bluetooth {
const HandleRequestDevicePromptSchema: z.ZodLazy<z.ZodObject<{

@@ -144,2 +192,428 @@ method: z.ZodLiteral<"bluetooth.handleRequestDevicePrompt">;

export declare namespace Bluetooth {
const SimulateAdapterSchema: z.ZodLazy<z.ZodObject<{
method: z.ZodLiteral<"bluetooth.simulateAdapter">;
params: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
state: z.ZodEnum<["absent", "powered-off", "powered-on"]>;
}, "strip", z.ZodTypeAny, {
context: string;
state: "absent" | "powered-off" | "powered-on";
}, {
context: string;
state: "absent" | "powered-off" | "powered-on";
}>>;
}, "strip", z.ZodTypeAny, {
params: {
context: string;
state: "absent" | "powered-off" | "powered-on";
};
method: "bluetooth.simulateAdapter";
}, {
params: {
context: string;
state: "absent" | "powered-off" | "powered-on";
};
method: "bluetooth.simulateAdapter";
}>>;
}
export declare namespace Bluetooth {
const SimulateAdapterParametersSchema: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
state: z.ZodEnum<["absent", "powered-off", "powered-on"]>;
}, "strip", z.ZodTypeAny, {
context: string;
state: "absent" | "powered-off" | "powered-on";
}, {
context: string;
state: "absent" | "powered-off" | "powered-on";
}>>;
}
export declare namespace Bluetooth {
const SimulatePreconnectedPeripheralSchema: z.ZodLazy<z.ZodObject<{
method: z.ZodLiteral<"bluetooth.simulatePreconnectedPeripheral">;
params: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
address: z.ZodString;
name: z.ZodString;
manufacturerData: z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">;
knownServiceUuids: z.ZodArray<z.ZodLazy<z.ZodString>, "many">;
}, "strip", z.ZodTypeAny, {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
}, {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
}>>;
}, "strip", z.ZodTypeAny, {
params: {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
};
method: "bluetooth.simulatePreconnectedPeripheral";
}, {
params: {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
};
method: "bluetooth.simulatePreconnectedPeripheral";
}>>;
}
export declare namespace Bluetooth {
const SimulatePreconnectedPeripheralParametersSchema: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
address: z.ZodString;
name: z.ZodString;
manufacturerData: z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">;
knownServiceUuids: z.ZodArray<z.ZodLazy<z.ZodString>, "many">;
}, "strip", z.ZodTypeAny, {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
}, {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
}>>;
}
export declare namespace Bluetooth {
const SimulateAdvertisementSchema: z.ZodLazy<z.ZodObject<{
method: z.ZodLiteral<"bluetooth.simulateAdvertisement">;
params: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
scanEntry: z.ZodLazy<z.ZodObject<{
deviceAddress: z.ZodString;
rssi: z.ZodNumber;
scanRecord: z.ZodLazy<z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
uuids: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodString>, "many">>;
appearance: z.ZodOptional<z.ZodNumber>;
manufacturerData: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">>;
}, "strip", z.ZodTypeAny, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}>>;
}, "strip", z.ZodTypeAny, {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
}, {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
}>>;
}, "strip", z.ZodTypeAny, {
params: {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
};
method: "bluetooth.simulateAdvertisement";
}, {
params: {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
};
method: "bluetooth.simulateAdvertisement";
}>>;
}
export declare namespace Bluetooth {
const SimulateAdvertisementParametersSchema: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
scanEntry: z.ZodLazy<z.ZodObject<{
deviceAddress: z.ZodString;
rssi: z.ZodNumber;
scanRecord: z.ZodLazy<z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
uuids: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodString>, "many">>;
appearance: z.ZodOptional<z.ZodNumber>;
manufacturerData: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">>;
}, "strip", z.ZodTypeAny, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}>>;
}, "strip", z.ZodTypeAny, {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
}, {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
}>>;
}
export declare namespace Bluetooth {
const SimulateAdvertisementScanEntryParametersSchema: z.ZodLazy<z.ZodObject<{
deviceAddress: z.ZodString;
rssi: z.ZodNumber;
scanRecord: z.ZodLazy<z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
uuids: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodString>, "many">>;
appearance: z.ZodOptional<z.ZodNumber>;
manufacturerData: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">>;
}, "strip", z.ZodTypeAny, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}>>;
}
export declare namespace Bluetooth {
const RequestDevicePromptUpdatedSchema: z.ZodLazy<z.ZodObject<{

@@ -146,0 +620,0 @@ method: z.ZodLiteral<"bluetooth.requestDevicePromptUpdated">;

@@ -33,2 +33,11 @@ "use strict";

(function (Bluetooth) {
Bluetooth.BluetoothServiceUuidSchema = zod_1.default.lazy(() => zod_1.default.string());
})(Bluetooth || (exports.Bluetooth = Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.BluetoothManufacturerDataSchema = zod_1.default.lazy(() => zod_1.default.object({
key: zod_1.default.number().int().nonnegative(),
data: zod_1.default.string(),
}));
})(Bluetooth || (exports.Bluetooth = Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.RequestDeviceSchema = zod_1.default.lazy(() => zod_1.default.string());

@@ -46,2 +55,12 @@ })(Bluetooth || (exports.Bluetooth = Bluetooth = {}));

(function (Bluetooth) {
Bluetooth.ScanRecordSchema = zod_1.default.lazy(() => zod_1.default.object({
name: zod_1.default.string().optional(),
uuids: zod_1.default.array(Bluetooth.BluetoothServiceUuidSchema).optional(),
appearance: zod_1.default.number().optional(),
manufacturerData: zod_1.default
.array(Bluetooth.BluetoothManufacturerDataSchema)
.optional(),
}));
})(Bluetooth || (exports.Bluetooth = Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.HandleRequestDevicePromptSchema = zod_1.default.lazy(() => zod_1.default.object({

@@ -75,2 +94,48 @@ method: zod_1.default.literal('bluetooth.handleRequestDevicePrompt'),

(function (Bluetooth) {
Bluetooth.SimulateAdapterSchema = zod_1.default.lazy(() => zod_1.default.object({
method: zod_1.default.literal('bluetooth.simulateAdapter'),
params: Bluetooth.SimulateAdapterParametersSchema,
}));
})(Bluetooth || (exports.Bluetooth = Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulateAdapterParametersSchema = zod_1.default.lazy(() => zod_1.default.object({
context: zod_1.default.string(),
state: zod_1.default.enum(['absent', 'powered-off', 'powered-on']),
}));
})(Bluetooth || (exports.Bluetooth = Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulatePreconnectedPeripheralSchema = zod_1.default.lazy(() => zod_1.default.object({
method: zod_1.default.literal('bluetooth.simulatePreconnectedPeripheral'),
params: Bluetooth.SimulatePreconnectedPeripheralParametersSchema,
}));
})(Bluetooth || (exports.Bluetooth = Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulatePreconnectedPeripheralParametersSchema = zod_1.default.lazy(() => zod_1.default.object({
context: zod_1.default.string(),
address: zod_1.default.string(),
name: zod_1.default.string(),
manufacturerData: zod_1.default.array(Bluetooth.BluetoothManufacturerDataSchema),
knownServiceUuids: zod_1.default.array(Bluetooth.BluetoothServiceUuidSchema),
}));
})(Bluetooth || (exports.Bluetooth = Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulateAdvertisementSchema = zod_1.default.lazy(() => zod_1.default.object({
method: zod_1.default.literal('bluetooth.simulateAdvertisement'),
params: Bluetooth.SimulateAdvertisementParametersSchema,
}));
})(Bluetooth || (exports.Bluetooth = Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulateAdvertisementParametersSchema = zod_1.default.lazy(() => zod_1.default.object({
context: zod_1.default.string(),
scanEntry: Bluetooth.SimulateAdvertisementScanEntryParametersSchema,
}));
})(Bluetooth || (exports.Bluetooth = Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulateAdvertisementScanEntryParametersSchema = zod_1.default.lazy(() => zod_1.default.object({
deviceAddress: zod_1.default.string(),
rssi: zod_1.default.number(),
scanRecord: Bluetooth.ScanRecordSchema,
}));
})(Bluetooth || (exports.Bluetooth = Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.RequestDevicePromptUpdatedSchema = zod_1.default.lazy(() => zod_1.default.object({

@@ -77,0 +142,0 @@ method: zod_1.default.literal('bluetooth.requestDevicePromptUpdated'),

@@ -78,3 +78,9 @@ /**

id: WebDriverBidi.JsUint;
} & WebDriverBidiBluetooth.Bluetooth.HandleRequestDevicePrompt)) & {
} & WebDriverBidiBluetooth.Bluetooth.HandleRequestDevicePrompt) | ({
id: WebDriverBidi.JsUint;
} & WebDriverBidiBluetooth.Bluetooth.SimulateAdapter) | ({
id: WebDriverBidi.JsUint;
} & WebDriverBidiBluetooth.Bluetooth.SimulatePreconnectedPeripheral) | ({
id: WebDriverBidi.JsUint;
} & WebDriverBidiBluetooth.Bluetooth.SimulateAdvertisement)) & {
channel?: WebDriverBidi.Script.Channel;

@@ -81,0 +87,0 @@ };

@@ -23,2 +23,11 @@ /**

export declare namespace Bluetooth {
type BluetoothServiceUuid = string;
}
export declare namespace Bluetooth {
type BluetoothManufacturerData = {
key: number;
data: string;
};
}
export declare namespace Bluetooth {
type RequestDevice = string;

@@ -36,2 +45,10 @@ }

export declare namespace Bluetooth {
type ScanRecord = {
name?: string;
uuids?: [...Bluetooth.BluetoothServiceUuid[]];
appearance?: number;
manufacturerData?: [...Bluetooth.BluetoothManufacturerData[]];
};
}
export declare namespace Bluetooth {
type HandleRequestDevicePrompt = {

@@ -60,2 +77,48 @@ method: 'bluetooth.handleRequestDevicePrompt';

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 = {

@@ -62,0 +125,0 @@ method: 'bluetooth.requestDevicePromptUpdated';

@@ -102,2 +102,3 @@ /**

unhandledPromptBehavior?: Session.UserPromptHandler;
'goog:prerenderingDisabled'?: boolean;
} & Extensible;

@@ -104,0 +105,0 @@ }

@@ -32,2 +32,3 @@ /**

unhandledPromptBehavior?: Session.UserPromptHandler;
'goog:prerenderingDisabled'?: boolean;
};

@@ -34,0 +35,0 @@ export declare class BidiServer extends EventEmitter<BidiServerEvent> {

@@ -64,3 +64,3 @@ /**

});
new CdpTargetManager(cdpConnection, browserCdpClient, selfTargetId, this.#eventManager, this.#browsingContextStorage, this.#realmStorage, networkStorage, this.#bluetoothProcessor, this.#preloadScriptStorage, defaultUserContextId, options?.unhandledPromptBehavior, logger);
new CdpTargetManager(cdpConnection, browserCdpClient, selfTargetId, this.#eventManager, this.#browsingContextStorage, this.#realmStorage, networkStorage, this.#bluetoothProcessor, this.#preloadScriptStorage, defaultUserContextId, options?.['goog:prerenderingDisabled'] ?? false, options?.unhandledPromptBehavior, logger);
// Needed to get events about new targets.

@@ -75,2 +75,11 @@ await browserCdpClient.sendCommand('Target.setDiscoverTargets', {

flatten: true,
// Browser session should attach to tab instead of the page, so that
// prerendering is not blocked.
filter: [
{
type: 'page',
exclude: true,
},
{},
],
});

@@ -77,0 +86,0 @@ await this.#topLevelContextsLoaded();

@@ -72,2 +72,8 @@ /**

return await this.#bluetoothProcessor.handleRequestDevicePrompt(this.#parser.parseHandleRequestDevicePromptParams(command.params));
case 'bluetooth.simulateAdapter':
return await this.#bluetoothProcessor.simulateAdapter(command.params);
case 'bluetooth.simulateAdvertisement':
return await this.#bluetoothProcessor.simulateAdvertisement(command.params);
case 'bluetooth.simulatePreconnectedPeripheral':
return await this.#bluetoothProcessor.simulatePreconnectedPeripheral(command.params);
// keep-sorted end

@@ -74,0 +80,0 @@ // Browser domain

@@ -24,4 +24,7 @@ /**

constructor(eventManager: EventManager, browsingContextStorage: BrowsingContextStorage);
simulateAdapter(params: Bluetooth.SimulateAdapterParameters): Promise<EmptyResult>;
simulatePreconnectedPeripheral(params: Bluetooth.SimulatePreconnectedPeripheralParameters): Promise<EmptyResult>;
simulateAdvertisement(params: Bluetooth.SimulateAdvertisementParameters): Promise<EmptyResult>;
onCdpTargetCreated(cdpTarget: CdpTarget): void;
handleRequestDevicePrompt(params: Bluetooth.HandleRequestDevicePromptParameters): Promise<EmptyResult>;
}

@@ -24,2 +24,26 @@ /**

}
async simulateAdapter(params) {
const context = this.#browsingContextStorage.getContext(params.context);
await context.cdpTarget.browserCdpClient.sendCommand('BluetoothEmulation.enable', {
state: params.state,
});
return {};
}
async simulatePreconnectedPeripheral(params) {
const context = this.#browsingContextStorage.getContext(params.context);
await context.cdpTarget.browserCdpClient.sendCommand('BluetoothEmulation.simulatePreconnectedPeripheral', {
address: params.address,
name: params.name,
knownServiceUuids: params.knownServiceUuids,
manufacturerData: params.manufacturerData,
});
return {};
}
async simulateAdvertisement(params) {
const context = this.#browsingContextStorage.getContext(params.context);
await context.cdpTarget.browserCdpClient.sendCommand('BluetoothEmulation.simulateAdvertisement', {
entry: params.scanEntry,
});
return {};
}
onCdpTargetCreated(cdpTarget) {

@@ -26,0 +50,0 @@ cdpTarget.cdpClient.on('DeviceAccess.deviceRequestPrompted', (event) => {

@@ -15,4 +15,4 @@ import type { Protocol } from 'devtools-protocol';

#private;
static create(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, realmStorage: RealmStorage, eventManager: EventManager, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn): CdpTarget;
constructor(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, eventManager: EventManager, realmStorage: RealmStorage, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn);
static create(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, parentCdpClient: CdpClient, realmStorage: RealmStorage, eventManager: EventManager, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, prerenderingDisabled: boolean, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn): CdpTarget;
constructor(targetId: Protocol.Target.TargetID, cdpClient: CdpClient, browserCdpClient: CdpClient, parentCdpClient: CdpClient, eventManager: EventManager, realmStorage: RealmStorage, preloadScriptStorage: PreloadScriptStorage, browsingContextStorage: BrowsingContextStorage, networkStorage: NetworkStorage, prerenderingDisabled: boolean, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn);
/** Returns a deferred that resolves when the target is unblocked. */

@@ -22,2 +22,3 @@ get unblocked(): Deferred<Result<void>>;

get cdpClient(): CdpClient;
get parentCdpClient(): CdpClient;
get browserCdpClient(): CdpClient;

@@ -24,0 +25,0 @@ /** Needed for CDP escape path. */

@@ -10,2 +10,3 @@ import { BiDiModule } from '../../../protocol/chromium-bidi.js';

#browserCdpClient;
#parentCdpClient;
#realmStorage;

@@ -15,2 +16,3 @@ #eventManager;

#browsingContextStorage;
#prerenderingDisabled;
#networkStorage;

@@ -28,4 +30,4 @@ #unblocked = new Deferred();

};
static create(targetId, cdpClient, browserCdpClient, realmStorage, eventManager, preloadScriptStorage, browsingContextStorage, networkStorage, unhandledPromptBehavior, logger) {
const cdpTarget = new CdpTarget(targetId, cdpClient, browserCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, unhandledPromptBehavior, logger);
static create(targetId, cdpClient, browserCdpClient, parentCdpClient, realmStorage, eventManager, preloadScriptStorage, browsingContextStorage, networkStorage, prerenderingDisabled, unhandledPromptBehavior, logger) {
const cdpTarget = new CdpTarget(targetId, cdpClient, browserCdpClient, parentCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, prerenderingDisabled, unhandledPromptBehavior, logger);
LogManager.create(cdpTarget, realmStorage, eventManager, logger);

@@ -38,6 +40,7 @@ cdpTarget.#setEventListeners();

}
constructor(targetId, cdpClient, browserCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, unhandledPromptBehavior, logger) {
constructor(targetId, cdpClient, browserCdpClient, parentCdpClient, eventManager, realmStorage, preloadScriptStorage, browsingContextStorage, networkStorage, prerenderingDisabled, unhandledPromptBehavior, logger) {
this.#id = targetId;
this.#cdpClient = cdpClient;
this.#browserCdpClient = browserCdpClient;
this.#parentCdpClient = parentCdpClient;
this.#eventManager = eventManager;

@@ -48,2 +51,3 @@ this.#realmStorage = realmStorage;

this.#browsingContextStorage = browsingContextStorage;
this.#prerenderingDisabled = prerenderingDisabled;
this.#unhandledPromptBehavior = unhandledPromptBehavior;

@@ -62,2 +66,5 @@ this.#logger = logger;

}
get parentCdpClient() {
return this.#parentCdpClient;
}
get browserCdpClient() {

@@ -93,2 +100,11 @@ return this.#browserCdpClient;

}),
this.#cdpClient
.sendCommand('Page.setPrerenderingAllowed', {
isAllowed: !this.#prerenderingDisabled,
})
.catch(() => {
// Ignore CDP errors, as the command is not supported by iframe targets or
// prerendered pages. Generic catch, as the error can vary between CdpClient
// implementations: Tab vs Puppeteer.
}),
this.toggleNetworkIfNeeded(),

@@ -102,2 +118,4 @@ this.#cdpClient.sendCommand('Target.setAutoAttach', {

this.#cdpClient.sendCommand('Runtime.runIfWaitingForDebugger'),
// Resume tab execution as well if it was paused by the debugger.
this.#parentCdpClient.sendCommand('Runtime.runIfWaitingForDebugger'),
this.toggleDeviceAccessIfNeeded(),

@@ -246,4 +264,5 @@ ]);

const error = err;
return (error.code === -32001 &&
error.message === 'Session with given id not found.');
return ((error.code === -32001 &&
error.message === 'Session with given id not found.') ||
this.#cdpClient.isCloseError(err));
}

@@ -250,0 +269,0 @@ #setEventListeners() {

@@ -13,3 +13,3 @@ import type { CdpClient } from '../../../cdp/CdpClient.js';

#private;
constructor(cdpConnection: CdpConnection, browserCdpClient: CdpClient, selfTargetId: string, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, networkStorage: NetworkStorage, bluetoothProcessor: BluetoothProcessor, preloadScriptStorage: PreloadScriptStorage, defaultUserContextId: Browser.UserContext, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn);
constructor(cdpConnection: CdpConnection, browserCdpClient: CdpClient, selfTargetId: string, eventManager: EventManager, browsingContextStorage: BrowsingContextStorage, realmStorage: RealmStorage, networkStorage: NetworkStorage, bluetoothProcessor: BluetoothProcessor, preloadScriptStorage: PreloadScriptStorage, defaultUserContextId: Browser.UserContext, prerenderingDisabled: boolean, unhandledPromptBehavior?: Session.UserPromptHandler, logger?: LoggerFn);
}

@@ -24,3 +24,4 @@ import { LogType } from '../../../utils/log.js';

#unhandledPromptBehavior;
constructor(cdpConnection, browserCdpClient, selfTargetId, eventManager, browsingContextStorage, realmStorage, networkStorage, bluetoothProcessor, preloadScriptStorage, defaultUserContextId, unhandledPromptBehavior, logger) {
#prerenderingDisabled;
constructor(cdpConnection, browserCdpClient, selfTargetId, eventManager, browsingContextStorage, realmStorage, networkStorage, bluetoothProcessor, preloadScriptStorage, defaultUserContextId, prerenderingDisabled, unhandledPromptBehavior, logger) {
this.#cdpConnection = cdpConnection;

@@ -37,2 +38,3 @@ this.#browserCdpClient = browserCdpClient;

this.#defaultUserContextId = defaultUserContextId;
this.#prerenderingDisabled = prerenderingDisabled;
this.#unhandledPromptBehavior = unhandledPromptBehavior;

@@ -88,28 +90,41 @@ this.#logger = logger;

};
if (this.#selfTargetId !== targetInfo.targetId) {
// Service workers are special case because they attach to the
// browser target and the page target (so twice per worker) during
// the regular auto-attach and might hang if the CDP session on
// the browser level is not detached. The logic to detach the
// right session is handled in the switch below.
const targetKey = targetInfo.type === 'service_worker'
? `${parentSessionCdpClient.sessionId}_${targetInfo.targetId}`
: targetInfo.targetId;
// Mapper generally only needs one session per target. If we
// receive additional auto-attached sessions, that is very likely
// coming from custom CDP sessions.
if (this.#targetKeysToBeIgnoredByAutoAttach.has(targetKey)) {
// Return to leave the session untouched.
return;
}
this.#targetKeysToBeIgnoredByAutoAttach.add(targetKey);
// Do not attach to the Mapper target.
if (this.#selfTargetId === targetInfo.targetId) {
void detach();
return;
}
// Service workers are special case because they attach to the
// browser target and the page target (so twice per worker) during
// the regular auto-attach and might hang if the CDP session on
// the browser level is not detached. The logic to detach the
// right session is handled in the switch below.
const targetKey = targetInfo.type === 'service_worker'
? `${parentSessionCdpClient.sessionId}_${targetInfo.targetId}`
: targetInfo.targetId;
// Mapper generally only needs one session per target. If we
// receive additional auto-attached sessions, that is very likely
// coming from custom CDP sessions.
if (this.#targetKeysToBeIgnoredByAutoAttach.has(targetKey)) {
// Return to leave the session untouched.
return;
}
this.#targetKeysToBeIgnoredByAutoAttach.add(targetKey);
switch (targetInfo.type) {
case 'tab':
// Tab targets are required only to handle page targets beneath them.
this.#setEventListeners(targetCdpClient);
// Auto-attach to the page target. No need in resuming tab target debugger, as it
// should preserve the page target debugger state, and will be resumed by the page
// target.
void (async () => {
await targetCdpClient.sendCommand('Target.setAutoAttach', {
autoAttach: true,
waitForDebuggerOnStart: true,
flatten: true,
});
})();
return;
case 'page':
case 'iframe': {
if (this.#selfTargetId === targetInfo.targetId) {
void detach();
return;
}
const cdpTarget = this.#createCdpTarget(targetCdpClient, targetInfo);
const cdpTarget = this.#createCdpTarget(targetCdpClient, parentSessionCdpClient, targetInfo);
const maybeContext = this.#browsingContextStorage.findContext(targetInfo.targetId);

@@ -121,2 +136,5 @@ if (maybeContext && targetInfo.type === 'iframe') {

else {
// If attaching to existing browser instance, there could be OOPiF targets. This
// case is handled by the `findFrameParentId` method.
const parentId = this.#findFrameParentId(targetInfo, parentSessionCdpClient.sessionId);
const userContext = targetInfo.browserContextId &&

@@ -127,3 +145,3 @@ targetInfo.browserContextId !== this.#defaultUserContextId

// New context.
BrowsingContextImpl.create(targetInfo.targetId, null, userContext, cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage,
BrowsingContextImpl.create(targetInfo.targetId, parentId, userContext, cdpTarget, this.#eventManager, this.#browsingContextStorage, this.#realmStorage,
// Hack: when a new target created, CDP emits targetInfoChanged with an empty

@@ -151,3 +169,3 @@ // url, and navigates it to about:blank later. When the event is emitted for

}
const cdpTarget = this.#createCdpTarget(targetCdpClient, targetInfo);
const cdpTarget = this.#createCdpTarget(targetCdpClient, parentSessionCdpClient, targetInfo);
this.#handleWorkerTarget(cdpToBidiTargetTypes[targetInfo.type], cdpTarget, realm);

@@ -161,3 +179,3 @@ return;

case 'shared_worker': {
const cdpTarget = this.#createCdpTarget(targetCdpClient, targetInfo);
const cdpTarget = this.#createCdpTarget(targetCdpClient, parentSessionCdpClient, targetInfo);
this.#handleWorkerTarget(cdpToBidiTargetTypes[targetInfo.type], cdpTarget);

@@ -171,5 +189,20 @@ return;

}
#createCdpTarget(targetCdpClient, targetInfo) {
/** Try to find the parent browsing context ID for the given attached target. */
#findFrameParentId(targetInfo, parentSessionId) {
if (targetInfo.type !== 'iframe') {
return null;
}
const parentId = targetInfo.openerFrameId ?? targetInfo.openerId;
if (parentId !== undefined) {
return parentId;
}
if (parentSessionId !== undefined) {
return (this.#browsingContextStorage.findContextBySession(parentSessionId)
?.id ?? null);
}
return null;
}
#createCdpTarget(targetCdpClient, parentCdpClient, targetInfo) {
this.#setEventListeners(targetCdpClient);
const target = CdpTarget.create(targetInfo.targetId, targetCdpClient, this.#browserCdpClient, this.#realmStorage, this.#eventManager, this.#preloadScriptStorage, this.#browsingContextStorage, this.#networkStorage, this.#unhandledPromptBehavior, this.#logger);
const target = CdpTarget.create(targetInfo.targetId, targetCdpClient, this.#browserCdpClient, parentCdpClient, this.#realmStorage, this.#eventManager, this.#preloadScriptStorage, this.#browsingContextStorage, this.#networkStorage, this.#prerenderingDisabled, this.#unhandledPromptBehavior, this.#logger);
this.#networkStorage.onCdpTargetCreated(target);

@@ -176,0 +209,0 @@ this.#bluetoothProcessor.onCdpTargetCreated(target);

@@ -105,3 +105,10 @@ /**

method: ChromiumBidi.BrowsingContext.EventNames.ContextCreated,
params: context.serializeToBidiValue(),
params: {
...context.serializeToBidiValue(),
// Hack to provide the initial URL of the context, as it can be changed
// between the page target is attached and unblocked, as the page is not
// fully paused in MPArch session (https://crbug.com/372842894).
// TODO: remove once https://crbug.com/372842894 is addressed.
url,
},
},

@@ -108,0 +115,0 @@ };

@@ -69,2 +69,5 @@ import { ChromiumBidi, InvalidArgumentException, NoSuchUserContextException, NoSuchAlertException, } from '../../../protocol/protocol.js';

}
// Wait for the new target to be attached and to be added to the browsing context
// storage.
const context = await this.#browsingContextStorage.waitForContext(result.targetId);
// Wait for the new tab to be loaded to avoid race conditions in the

@@ -75,4 +78,2 @@ // `browsingContext` events, when the `browsingContext.domContentLoaded` and

// Details: https://github.com/web-platform-tests/wpt/issues/35846
const contextId = result.targetId;
const context = this.#browsingContextStorage.getContext(contextId);
await context.lifecycleLoaded();

@@ -144,2 +145,4 @@ return { context: context.id };

}
// Parent session of a page target session can be a `browser` or a `tab` session.
const parentCdpClient = context.cdpTarget.parentCdpClient;
try {

@@ -149,15 +152,24 @@ const detachedFromTargetPromise = new Promise((resolve) => {

if (event.targetId === params.context) {
this.#browserCdpClient.off('Target.detachedFromTarget', onContextDestroyed);
parentCdpClient.off('Target.detachedFromTarget', onContextDestroyed);
resolve();
}
};
this.#browserCdpClient.on('Target.detachedFromTarget', onContextDestroyed);
parentCdpClient.on('Target.detachedFromTarget', onContextDestroyed);
});
if (params.promptUnload) {
await context.close();
try {
if (params.promptUnload) {
await context.close();
}
else {
await parentCdpClient.sendCommand('Target.closeTarget', {
targetId: params.context,
});
}
}
else {
await this.#browserCdpClient.sendCommand('Target.closeTarget', {
targetId: params.context,
});
catch (error) {
// Swallow error that arise from the session being destroyed. Rely on the
// `detachedFromTargetPromise` event to be resolved.
if (!parentCdpClient.isCloseError(error)) {
throw error;
}
}

@@ -164,0 +176,0 @@ // Sometimes CDP command finishes before `detachedFromTarget` event,

@@ -32,2 +32,6 @@ /**

addContext(context: BrowsingContextImpl): void;
/**
* Waits for a context with the given ID to be added and returns it.
*/
waitForContext(browsingContextId: BrowsingContext.BrowsingContext): Promise<BrowsingContextImpl>;
/** Returns true whether there is an existing context with the given ID. */

@@ -34,0 +38,0 @@ hasContext(id: BrowsingContext.BrowsingContext): boolean;

@@ -18,2 +18,3 @@ /**

import { NoSuchFrameException, InvalidArgumentException, } from '../../../protocol/protocol.js';
import { EventEmitter } from '../../../utils/EventEmitter.js';
/** Container class for browsing contexts. */

@@ -23,2 +24,5 @@ export class BrowsingContextStorage {

#contexts = new Map();
/** Event emitter for browsing context storage eventsis not expected to be exposed to
* the outside world. */
#eventEmitter = new EventEmitter();
/** Gets all top-level contexts, i.e. those with no parent. */

@@ -43,3 +47,20 @@ getTopLevelContexts() {

this.#contexts.set(context.id, context);
this.#eventEmitter.emit("added" /* BrowsingContextStorageEvents.Added */, {
browsingContext: context,
});
}
/**
* Waits for a context with the given ID to be added and returns it.
*/
waitForContext(browsingContextId) {
return new Promise((resolve) => {
const listener = (event) => {
if (event.browsingContext.id === browsingContextId) {
this.#eventEmitter.off("added" /* BrowsingContextStorageEvents.Added */, listener);
resolve(event.browsingContext);
}
};
this.#eventEmitter.on("added" /* BrowsingContextStorageEvents.Added */, listener);
});
}
/** Returns true whether there is an existing context with the given ID. */

@@ -46,0 +67,0 @@ hasContext(id) {

@@ -57,9 +57,9 @@ /**

count: number;
"__#90491@#x": number;
"__#90491@#y": number;
"__#90491@#time": number;
"__#90798@#x": number;
"__#90798@#y": number;
"__#90798@#time": number;
compare(context: any): boolean;
};
"__#90491@#DOUBLE_CLICK_TIME_MS": number;
"__#90491@#MAX_DOUBLE_CLICK_RADIUS": number;
"__#90798@#DOUBLE_CLICK_TIME_MS": number;
"__#90798@#MAX_DOUBLE_CLICK_RADIUS": number;
};

@@ -66,0 +66,0 @@ setClickCount(button: number, context: InstanceType<typeof PointerSource.ClickContext>): number;

@@ -56,2 +56,3 @@ var _a;

this.#commandCallbacks.set(id, {
sessionId,
resolve,

@@ -108,2 +109,8 @@ reject,

}
// Reject all the pending commands for the detached session.
for (const callback of this.#commandCallbacks.values()) {
if (callback.sessionId === sessionId) {
callback.reject(callback.error);
}
}
}

@@ -110,0 +117,0 @@ }

@@ -24,2 +24,17 @@ /**

export declare namespace Bluetooth {
const BluetoothServiceUuidSchema: z.ZodLazy<z.ZodString>;
}
export declare namespace Bluetooth {
const BluetoothManufacturerDataSchema: z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>;
}
export declare namespace Bluetooth {
const RequestDeviceSchema: z.ZodLazy<z.ZodString>;

@@ -43,2 +58,35 @@ }

export declare namespace Bluetooth {
const ScanRecordSchema: z.ZodLazy<z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
uuids: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodString>, "many">>;
appearance: z.ZodOptional<z.ZodNumber>;
manufacturerData: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">>;
}, "strip", z.ZodTypeAny, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}>>;
}
export declare namespace Bluetooth {
const HandleRequestDevicePromptSchema: z.ZodLazy<z.ZodObject<{

@@ -144,2 +192,428 @@ method: z.ZodLiteral<"bluetooth.handleRequestDevicePrompt">;

export declare namespace Bluetooth {
const SimulateAdapterSchema: z.ZodLazy<z.ZodObject<{
method: z.ZodLiteral<"bluetooth.simulateAdapter">;
params: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
state: z.ZodEnum<["absent", "powered-off", "powered-on"]>;
}, "strip", z.ZodTypeAny, {
context: string;
state: "absent" | "powered-off" | "powered-on";
}, {
context: string;
state: "absent" | "powered-off" | "powered-on";
}>>;
}, "strip", z.ZodTypeAny, {
params: {
context: string;
state: "absent" | "powered-off" | "powered-on";
};
method: "bluetooth.simulateAdapter";
}, {
params: {
context: string;
state: "absent" | "powered-off" | "powered-on";
};
method: "bluetooth.simulateAdapter";
}>>;
}
export declare namespace Bluetooth {
const SimulateAdapterParametersSchema: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
state: z.ZodEnum<["absent", "powered-off", "powered-on"]>;
}, "strip", z.ZodTypeAny, {
context: string;
state: "absent" | "powered-off" | "powered-on";
}, {
context: string;
state: "absent" | "powered-off" | "powered-on";
}>>;
}
export declare namespace Bluetooth {
const SimulatePreconnectedPeripheralSchema: z.ZodLazy<z.ZodObject<{
method: z.ZodLiteral<"bluetooth.simulatePreconnectedPeripheral">;
params: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
address: z.ZodString;
name: z.ZodString;
manufacturerData: z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">;
knownServiceUuids: z.ZodArray<z.ZodLazy<z.ZodString>, "many">;
}, "strip", z.ZodTypeAny, {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
}, {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
}>>;
}, "strip", z.ZodTypeAny, {
params: {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
};
method: "bluetooth.simulatePreconnectedPeripheral";
}, {
params: {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
};
method: "bluetooth.simulatePreconnectedPeripheral";
}>>;
}
export declare namespace Bluetooth {
const SimulatePreconnectedPeripheralParametersSchema: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
address: z.ZodString;
name: z.ZodString;
manufacturerData: z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">;
knownServiceUuids: z.ZodArray<z.ZodLazy<z.ZodString>, "many">;
}, "strip", z.ZodTypeAny, {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
}, {
context: string;
name: string;
address: string;
manufacturerData: {
key: number;
data: string;
}[];
knownServiceUuids: string[];
}>>;
}
export declare namespace Bluetooth {
const SimulateAdvertisementSchema: z.ZodLazy<z.ZodObject<{
method: z.ZodLiteral<"bluetooth.simulateAdvertisement">;
params: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
scanEntry: z.ZodLazy<z.ZodObject<{
deviceAddress: z.ZodString;
rssi: z.ZodNumber;
scanRecord: z.ZodLazy<z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
uuids: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodString>, "many">>;
appearance: z.ZodOptional<z.ZodNumber>;
manufacturerData: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">>;
}, "strip", z.ZodTypeAny, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}>>;
}, "strip", z.ZodTypeAny, {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
}, {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
}>>;
}, "strip", z.ZodTypeAny, {
params: {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
};
method: "bluetooth.simulateAdvertisement";
}, {
params: {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
};
method: "bluetooth.simulateAdvertisement";
}>>;
}
export declare namespace Bluetooth {
const SimulateAdvertisementParametersSchema: z.ZodLazy<z.ZodObject<{
context: z.ZodString;
scanEntry: z.ZodLazy<z.ZodObject<{
deviceAddress: z.ZodString;
rssi: z.ZodNumber;
scanRecord: z.ZodLazy<z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
uuids: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodString>, "many">>;
appearance: z.ZodOptional<z.ZodNumber>;
manufacturerData: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">>;
}, "strip", z.ZodTypeAny, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}>>;
}, "strip", z.ZodTypeAny, {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
}, {
context: string;
scanEntry: {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
};
}>>;
}
export declare namespace Bluetooth {
const SimulateAdvertisementScanEntryParametersSchema: z.ZodLazy<z.ZodObject<{
deviceAddress: z.ZodString;
rssi: z.ZodNumber;
scanRecord: z.ZodLazy<z.ZodObject<{
name: z.ZodOptional<z.ZodString>;
uuids: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodString>, "many">>;
appearance: z.ZodOptional<z.ZodNumber>;
manufacturerData: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodObject<{
key: z.ZodNumber;
data: z.ZodString;
}, "strip", z.ZodTypeAny, {
key: number;
data: string;
}, {
key: number;
data: string;
}>>, "many">>;
}, "strip", z.ZodTypeAny, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}, {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
}>>;
}, "strip", z.ZodTypeAny, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}, {
deviceAddress: string;
rssi: number;
scanRecord: {
name?: string | undefined;
appearance?: number | undefined;
manufacturerData?: {
key: number;
data: string;
}[] | undefined;
uuids?: string[] | undefined;
};
}>>;
}
export declare namespace Bluetooth {
const RequestDevicePromptUpdatedSchema: z.ZodLazy<z.ZodObject<{

@@ -146,0 +620,0 @@ method: z.ZodLiteral<"bluetooth.requestDevicePromptUpdated">;

@@ -27,2 +27,11 @@ /**

(function (Bluetooth) {
Bluetooth.BluetoothServiceUuidSchema = z.lazy(() => z.string());
})(Bluetooth || (Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.BluetoothManufacturerDataSchema = z.lazy(() => z.object({
key: z.number().int().nonnegative(),
data: z.string(),
}));
})(Bluetooth || (Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.RequestDeviceSchema = z.lazy(() => z.string());

@@ -40,2 +49,12 @@ })(Bluetooth || (Bluetooth = {}));

(function (Bluetooth) {
Bluetooth.ScanRecordSchema = z.lazy(() => z.object({
name: z.string().optional(),
uuids: z.array(Bluetooth.BluetoothServiceUuidSchema).optional(),
appearance: z.number().optional(),
manufacturerData: z
.array(Bluetooth.BluetoothManufacturerDataSchema)
.optional(),
}));
})(Bluetooth || (Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.HandleRequestDevicePromptSchema = z.lazy(() => z.object({

@@ -69,2 +88,48 @@ method: z.literal('bluetooth.handleRequestDevicePrompt'),

(function (Bluetooth) {
Bluetooth.SimulateAdapterSchema = z.lazy(() => z.object({
method: z.literal('bluetooth.simulateAdapter'),
params: Bluetooth.SimulateAdapterParametersSchema,
}));
})(Bluetooth || (Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulateAdapterParametersSchema = z.lazy(() => z.object({
context: z.string(),
state: z.enum(['absent', 'powered-off', 'powered-on']),
}));
})(Bluetooth || (Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulatePreconnectedPeripheralSchema = z.lazy(() => z.object({
method: z.literal('bluetooth.simulatePreconnectedPeripheral'),
params: Bluetooth.SimulatePreconnectedPeripheralParametersSchema,
}));
})(Bluetooth || (Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulatePreconnectedPeripheralParametersSchema = z.lazy(() => z.object({
context: z.string(),
address: z.string(),
name: z.string(),
manufacturerData: z.array(Bluetooth.BluetoothManufacturerDataSchema),
knownServiceUuids: z.array(Bluetooth.BluetoothServiceUuidSchema),
}));
})(Bluetooth || (Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulateAdvertisementSchema = z.lazy(() => z.object({
method: z.literal('bluetooth.simulateAdvertisement'),
params: Bluetooth.SimulateAdvertisementParametersSchema,
}));
})(Bluetooth || (Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulateAdvertisementParametersSchema = z.lazy(() => z.object({
context: z.string(),
scanEntry: Bluetooth.SimulateAdvertisementScanEntryParametersSchema,
}));
})(Bluetooth || (Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.SimulateAdvertisementScanEntryParametersSchema = z.lazy(() => z.object({
deviceAddress: z.string(),
rssi: z.number(),
scanRecord: Bluetooth.ScanRecordSchema,
}));
})(Bluetooth || (Bluetooth = {}));
(function (Bluetooth) {
Bluetooth.RequestDevicePromptUpdatedSchema = z.lazy(() => z.object({

@@ -71,0 +136,0 @@ method: z.literal('bluetooth.requestDevicePromptUpdated'),

@@ -78,3 +78,9 @@ /**

id: WebDriverBidi.JsUint;
} & WebDriverBidiBluetooth.Bluetooth.HandleRequestDevicePrompt)) & {
} & WebDriverBidiBluetooth.Bluetooth.HandleRequestDevicePrompt) | ({
id: WebDriverBidi.JsUint;
} & WebDriverBidiBluetooth.Bluetooth.SimulateAdapter) | ({
id: WebDriverBidi.JsUint;
} & WebDriverBidiBluetooth.Bluetooth.SimulatePreconnectedPeripheral) | ({
id: WebDriverBidi.JsUint;
} & WebDriverBidiBluetooth.Bluetooth.SimulateAdvertisement)) & {
channel?: WebDriverBidi.Script.Channel;

@@ -81,0 +87,0 @@ };

@@ -23,2 +23,11 @@ /**

export declare namespace Bluetooth {
type BluetoothServiceUuid = string;
}
export declare namespace Bluetooth {
type BluetoothManufacturerData = {
key: number;
data: string;
};
}
export declare namespace Bluetooth {
type RequestDevice = string;

@@ -36,2 +45,10 @@ }

export declare namespace Bluetooth {
type ScanRecord = {
name?: string;
uuids?: [...Bluetooth.BluetoothServiceUuid[]];
appearance?: number;
manufacturerData?: [...Bluetooth.BluetoothManufacturerData[]];
};
}
export declare namespace Bluetooth {
type HandleRequestDevicePrompt = {

@@ -60,2 +77,48 @@ method: 'bluetooth.handleRequestDevicePrompt';

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 = {

@@ -62,0 +125,0 @@ method: 'bluetooth.requestDevicePromptUpdated';

@@ -102,2 +102,3 @@ /**

unhandledPromptBehavior?: Session.UserPromptHandler;
'goog:prerenderingDisabled'?: boolean;
} & Extensible;

@@ -104,0 +105,0 @@ }

{
"name": "chromium-bidi",
"version": "0.8.0",
"version": "0.8.1",
"description": "An implementation of the WebDriver BiDi protocol for Chromium implemented as a JavaScript layer translating between BiDi and CDP, running inside a Chrome tab.",

@@ -185,3 +185,3 @@ "scripts": {

"debug": "4.3.7",
"devtools-protocol": "0.0.1359167",
"devtools-protocol": "0.0.1363470",
"eslint": "8.57.1",

@@ -188,0 +188,0 @@ "eslint-config-prettier": "9.1.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc