Socket
Socket
Sign inDemoInstall

chromium-bidi

Package Overview
Dependencies
Maintainers
2
Versions
69
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.4.14 to 0.4.15

6

lib/cjs/bidiMapper/CommandProcessor.d.ts

@@ -17,3 +17,3 @@ /**

*/
import { type BrowsingContext, type CDP, type Input, Message, type Script, type Session } from '../protocol/protocol.js';
import { type BrowsingContext, type Cdp, type Input, Message, type Script, type Session } from '../protocol/protocol.js';
import { type LoggerFn } from '../utils/log.js';

@@ -36,4 +36,4 @@ import { EventEmitter } from '../utils/EventEmitter.js';

parseDisownParams(params: object): Script.DisownParameters;
parseSendCommandParams(params: object): CDP.SendCommandParams;
parseGetSessionParams(params: object): CDP.GetSessionParams;
parseSendCommandParams(params: object): Cdp.SendCommandParams;
parseGetSessionParams(params: object): Cdp.GetSessionParams;
parseSubscribeParams(params: object): Session.SubscriptionRequest;

@@ -40,0 +40,0 @@ parseNavigateParams(params: object): BrowsingContext.NavigateParameters;

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

#maybeDefaultRealm;
#isNavigating = false;
#logger;

@@ -210,2 +211,16 @@ constructor(cdpTarget, realmStorage, id, parentId, eventManager, browsingContextStorage, logger) {

this.#url = params.targetInfo.url;
if (this.#isNavigating) {
this.#eventManager.registerEvent({
method: protocol_js_1.BrowsingContext.EventNames.NavigationStarted,
params: {
context: this.id,
// TODO: The network event is send before the CDP Page.frameStartedLoading
// It theory there should be a way to get the data.
navigation: null,
timestamp: BrowsingContextImpl.getTimestamp(),
url: this.#url,
},
}, this.id);
this.#isNavigating = false;
}
}

@@ -240,2 +255,3 @@ #initListeners() {

this.#deferreds.Page.navigatedWithinDocument.resolve(params);
// TODO: Remove this once History event for BiDi are added
this.#eventManager.registerEvent({

@@ -245,3 +261,3 @@ method: protocol_js_1.BrowsingContext.EventNames.FragmentNavigated,

context: this.id,
navigation: this.#loaderId ?? null,
navigation: null,
timestamp,

@@ -252,2 +268,14 @@ url: this.#url,

});
this.#cdpTarget.cdpClient.on('Page.frameStartedLoading', (params) => {
if (this.id !== params.frameId) {
return;
}
this.#isNavigating = true;
});
this.#cdpTarget.cdpClient.on('Page.frameStoppedLoading', (params) => {
if (this.id !== params.frameId) {
return;
}
this.#isNavigating = false;
});
this.#cdpTarget.cdpClient.on('Page.lifecycleEvent', (params) => {

@@ -254,0 +282,0 @@ if (this.id !== params.frameId) {

@@ -1,2 +0,2 @@

import { type BrowsingContext, type CDP, Input, Message, type Script } from '../../../protocol/protocol.js';
import { type BrowsingContext, type Cdp, Input, Message, type Script } from '../../../protocol/protocol.js';
import { type LoggerFn } from '../../../utils/log.js';

@@ -26,4 +26,4 @@ import type { IEventManager } from '../events/EventManager.js';

process_browsingContext_close(commandParams: BrowsingContext.CloseParameters): Promise<Message.EmptyResult>;
process_cdp_sendCommand(params: CDP.SendCommandParams): Promise<CDP.SendCommandResult>;
process_cdp_getSession(params: CDP.GetSessionParams): CDP.GetSessionResult;
process_cdp_sendCommand(params: Cdp.SendCommandParams): Promise<Cdp.SendCommandResult>;
process_cdp_getSession(params: Cdp.GetSessionParams): Cdp.GetSessionResult;
}

@@ -94,4 +94,4 @@ "use strict";

this.#cdpClient.on('*', (event, params) => {
// We may encounter uses for EventEmitter
// other then CDP events we want to skip them
// We may encounter uses for EventEmitter other than CDP events,
// which we want to skip.
if (typeof event !== 'string') {

@@ -98,0 +98,0 @@ return;

@@ -409,13 +409,16 @@ "use strict";

// to measure.
const text = [...key].length === 1 ? key : undefined;
let unmodifiedText = [...key].length === 1 ? key : undefined;
if (source.shift) {
unmodifiedText = unmodifiedText?.toLocaleUpperCase('en-US');
}
return this.#context.cdpTarget.cdpClient.sendCommand('Input.dispatchKeyEvent', {
type: text ? 'keyDown' : 'rawKeyDown',
type: unmodifiedText ? 'keyDown' : 'rawKeyDown',
windowsVirtualKeyCode: USKeyboardLayout_js_1.KeyToKeyCode[key],
key,
code,
text,
unmodifiedText: text,
text: unmodifiedText,
unmodifiedText,
autoRepeat: repeat,
isSystemKey: source.alt || undefined,
location: location < 2 ? location : undefined,
location: location < 3 ? location : undefined,
isKeypad: location === 3,

@@ -453,3 +456,6 @@ modifiers,

// to measure.
const text = [...key].length === 1 ? key : undefined;
let unmodifiedText = [...key].length === 1 ? key : undefined;
if (source.shift) {
unmodifiedText = unmodifiedText?.toLocaleUpperCase('en-US');
}
return this.#context.cdpTarget.cdpClient.sendCommand('Input.dispatchKeyEvent', {

@@ -460,5 +466,5 @@ type: 'keyUp',

code,
text,
unmodifiedText: text,
location: location < 2 ? location : undefined,
text: unmodifiedText,
unmodifiedText,
location: location < 3 ? location : undefined,
isSystemKey: source.alt || undefined,

@@ -465,0 +471,0 @@ isKeypad: location === 3,

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

else {
this.#modifiers ^= bit;
this.#modifiers &= ~bit;
}

@@ -67,0 +67,0 @@ }

@@ -220,6 +220,6 @@ "use strict";

parseSendCommandParams(params) {
return Parser.CDP.parseSendCommandParams(params);
return Parser.Cdp.parseSendCommandParams(params);
}
parseGetSessionParams(params) {
return Parser.CDP.parseGetSessionParams(params);
return Parser.Cdp.parseGetSessionParams(params);
}

@@ -226,0 +226,0 @@ parseSubscribeParams(params) {

@@ -22,3 +22,3 @@ /**

import { type ZodType, z as zod } from 'zod';
import { BrowsingContext as BrowsingContextTypes, Script as ScriptTypes, type CDP as CdpTypes, type Session as SessionTypes, type CommonDataTypes as CommonDataTypesTypes, Input as InputTypes } from '../protocol/protocol.js';
import { BrowsingContext as BrowsingContextTypes, Script as ScriptTypes, type Cdp as CdpTypes, type Session as SessionTypes, type CommonDataTypes as CommonDataTypesTypes, Input as InputTypes } from '../protocol/protocol.js';
export declare function parseObject<T extends ZodType>(obj: object, schema: T): zod.infer<T>;

@@ -238,3 +238,3 @@ export declare namespace CommonDataTypes {

}
export declare namespace CDP {
export declare namespace Cdp {
function parseSendCommandParams(params: object): CdpTypes.SendCommandParams;

@@ -241,0 +241,0 @@ function parseGetSessionParams(params: object): CdpTypes.GetSessionParams;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.Input = exports.Session = exports.CDP = exports.BrowsingContext = exports.Script = exports.CommonDataTypes = exports.parseObject = void 0;
exports.Input = exports.Session = exports.Cdp = exports.BrowsingContext = exports.Script = exports.CommonDataTypes = exports.parseObject = void 0;
/**

@@ -486,4 +486,4 @@ * @fileoverview Provides parsing and validator for WebDriver BiDi protocol.

})(BrowsingContext = exports.BrowsingContext || (exports.BrowsingContext = {}));
var CDP;
(function (CDP) {
var Cdp;
(function (Cdp) {
const SendCommandParamsSchema = zod_1.z.object({

@@ -500,3 +500,3 @@ // Allowing any cdpMethod, and casting to proper type later on.

}
CDP.parseSendCommandParams = parseSendCommandParams;
Cdp.parseSendCommandParams = parseSendCommandParams;
const GetSessionParamsSchema = zod_1.z.object({

@@ -508,11 +508,7 @@ context: CommonDataTypes.BrowsingContextSchema,

}
CDP.parseGetSessionParams = parseGetSessionParams;
})(CDP = exports.CDP || (exports.CDP = {}));
Cdp.parseGetSessionParams = parseGetSessionParams;
})(Cdp = exports.Cdp || (exports.Cdp = {}));
/** @see https://w3c.github.io/webdriver-bidi/#module-session */
var Session;
(function (Session) {
// BiDi+ events
const CDPSubscriptionRequestParametersEventsSchema = zod_1.z.custom((value) => {
return typeof value === 'string' ? value.startsWith('cdp.') : false;
}, 'Not a CDP event');
const BiDiSubscriptionRequestParametersEventsSchema = zod_1.z.enum([

@@ -528,5 +524,9 @@ protocol_js_1.BrowsingContext.AllEvents,

]);
// BiDi+ events
const CdpSubscriptionRequestParametersEventsSchema = zod_1.z.custom((value) => {
return typeof value === 'string' && value.startsWith('cdp.');
}, 'Not a CDP event');
const SubscriptionRequestParametersEventsSchema = zod_1.z.union([
CDPSubscriptionRequestParametersEventsSchema,
BiDiSubscriptionRequestParametersEventsSchema,
CdpSubscriptionRequestParametersEventsSchema,
]);

@@ -533,0 +533,0 @@ // SessionSubscriptionRequest = {

@@ -28,3 +28,3 @@ /**

}
type BiDiCommand = BrowsingContext.Command | CDP.Command | Input.Command | Network.Command | Script.Command | Session.Command;
type BiDiCommand = BrowsingContext.Command | Cdp.Command | Input.Command | Network.Command | Script.Command | Session.Command;
export declare namespace Message {

@@ -48,5 +48,6 @@ type OutgoingMessage = CommandResponse | EventMessage | {

};
type ResultData = EmptyResult | BrowsingContext.Result | CDP.Result | ErrorResult | Network.Result | Script.Result | Session.Result;
type EventMessage = BrowsingContext.Event | CDP.Event | Log.Event | Network.Event | Script.Event;
type EventNames = BrowsingContext.EventNames | CDP.EventNames | Log.EventNames | Network.EventNames | Script.EventNames;
type ResultData = EmptyResult | BrowsingContext.Result | Cdp.Result | ErrorResult | Network.Result | Script.Result | Session.Result;
type EventMessage = BrowsingContext.Event | Cdp.Event | Log.Event | Network.Event | Script.Event;
type EventNames = BrowsingContext.EventNames | Cdp.EventNames | Log.EventNames | Network.EventNames | Script.EventNames;
type AllEvents = typeof BrowsingContext.AllEvents | typeof Log.AllEvents | typeof Network.AllEvents | typeof Script.AllEvents;
enum ErrorCode {

@@ -468,3 +469,3 @@ InvalidArgument = "invalid argument",

type Result = CaptureScreenshotResult | CreateResult | GetTreeResult | NavigateResult | PrintResult;
type Event = ContextCreatedEvent | ContextDestroyedEvent | DomContentLoadedEvent | FragmentNavigatedEvent | LoadEvent;
type Event = ContextCreatedEvent | ContextDestroyedEvent | DomContentLoadedEvent | FragmentNavigatedEvent | LoadEvent | NavigationStartedEvent;
type Navigation = string;

@@ -600,2 +601,3 @@ type GetTreeCommand = {

type FragmentNavigatedEvent = EventResponse<EventNames.FragmentNavigated, BrowsingContext.NavigationInfo>;
type NavigationStartedEvent = EventResponse<EventNames.NavigationStarted, BrowsingContext.NavigationInfo>;
enum EventNames {

@@ -606,3 +608,4 @@ ContextCreatedEvent = "browsingContext.contextCreated",

FragmentNavigated = "browsingContext.fragmentNavigated",
LoadEvent = "browsingContext.load"
LoadEvent = "browsingContext.load",
NavigationStarted = "browsingContext.navigationStarted"
}

@@ -742,3 +745,3 @@ const AllEvents = "browsingContext";

}
export declare namespace CDP {
export declare namespace Cdp {
type Command = SendCommandCommand | GetSessionCommand;

@@ -772,4 +775,4 @@ type Result = SendCommandResult | GetSessionResult;

};
type EventReceivedEvent = EventResponse<EventNames, CDPEventParams>;
type CDPEventParams<EventName extends keyof ProtocolMapping.Events = keyof ProtocolMapping.Events> = {
type EventReceivedEvent = EventResponse<EventNames, EventParams>;
type EventParams<EventName extends keyof ProtocolMapping.Events = keyof ProtocolMapping.Events> = {
event: EventName;

@@ -799,3 +802,3 @@ params: ProtocolMapping.Events[EventName];

};
type SubscriptionRequestEvent = CDP.EventNames | Message.EventNames | typeof BrowsingContext.AllEvents | typeof Log.AllEvents | typeof Network.AllEvents | typeof Script.AllEvents;
type SubscriptionRequestEvent = Cdp.EventNames | Message.EventNames | Message.AllEvents;
type SubscriptionRequest = {

@@ -802,0 +805,0 @@ events: SubscriptionRequestEvent[];

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

(function (Message) {
// keep-sorted end;
// keep-sorted end
let ErrorCode;

@@ -165,2 +165,3 @@ (function (ErrorCode) {

EventNames["LoadEvent"] = "browsingContext.load";
EventNames["NavigationStarted"] = "browsingContext.navigationStarted";
// keep-sorted end

@@ -167,0 +168,0 @@ })(EventNames = BrowsingContext.EventNames || (BrowsingContext.EventNames = {}));

{
"name": "chromium-bidi",
"version": "0.4.14",
"version": "0.4.15",
"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.",

@@ -5,0 +5,0 @@ "scripts": {

@@ -35,3 +35,3 @@ # WebDriver BiDi for Chromium [![chromium-bidi on npm](https://img.shields.io/npm/v/chromium-bidi)](https://www.npmjs.com/package/chromium-bidi)

params: any,
cession?: text,
session?: text,
}

@@ -47,3 +47,3 @@

described [CDP command](https://chromedevtools.github.io/devtools-protocol)
and returns result.
and returns the result.

@@ -80,3 +80,3 @@ ### Command `cdp.getSession`

params: any,
session: string,
session: text,
}

@@ -83,0 +83,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 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