feat(rpc): inline selectors.register options in the protocol (#3072)
This commit is contained in:
parent
3dd61629e0
commit
18cb1c017a
|
|
@ -118,9 +118,7 @@ export interface SelectorsChannel extends Channel {
|
||||||
export type SelectorsRegisterParams = {
|
export type SelectorsRegisterParams = {
|
||||||
name: string,
|
name: string,
|
||||||
source: string,
|
source: string,
|
||||||
options: {
|
contentScript?: boolean,
|
||||||
contentScript?: boolean,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
export type SelectorsRegisterResult = void;
|
export type SelectorsRegisterResult = void;
|
||||||
export type SelectorsCreateSelectorParams = {
|
export type SelectorsCreateSelectorParams = {
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export class Selectors extends ChannelOwner<SelectorsChannel, SelectorsInitializ
|
||||||
|
|
||||||
async register(name: string, script: string | Function | { path?: string, content?: string }, options: { contentScript?: boolean } = {}): Promise<void> {
|
async register(name: string, script: string | Function | { path?: string, content?: string }, options: { contentScript?: boolean } = {}): Promise<void> {
|
||||||
const source = await helper.evaluationScript(script, undefined, false);
|
const source = await helper.evaluationScript(script, undefined, false);
|
||||||
await this._channel.register({ name, source, options });
|
await this._channel.register({ ...options, name, source });
|
||||||
}
|
}
|
||||||
|
|
||||||
async _createSelector(name: string, handle: ElementHandle<Element>): Promise<string | undefined> {
|
async _createSelector(name: string, handle: ElementHandle<Element>): Promise<string | undefined> {
|
||||||
|
|
|
||||||
|
|
@ -108,8 +108,7 @@ interface Selectors
|
||||||
parameters
|
parameters
|
||||||
name: string
|
name: string
|
||||||
source: string
|
source: string
|
||||||
options: object
|
contentScript?: boolean
|
||||||
contentScript?: boolean
|
|
||||||
|
|
||||||
command createSelector
|
command createSelector
|
||||||
parameters
|
parameters
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ export class SelectorsDispatcher extends Dispatcher<Selectors, SelectorsInitiali
|
||||||
super(scope, selectors, 'selectors', {});
|
super(scope, selectors, 'selectors', {});
|
||||||
}
|
}
|
||||||
|
|
||||||
async register(params: { name: string, source: string, options: { contentScript?: boolean } }): Promise<void> {
|
async register(params: { name: string, source: string, contentScript?: boolean }): Promise<void> {
|
||||||
await this._object.register(params.name, params.source, params.options);
|
await this._object.register(params.name, params.source, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async createSelector(params: { name: string, handle: ElementHandleDispatcher }): Promise<{ value?: string }> {
|
async createSelector(params: { name: string, handle: ElementHandleDispatcher }): Promise<{ value?: string }> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue