chromium-bidi 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -4
- package/lib/cjs/bidiMapper/BidiServer.d.ts +3 -3
- package/lib/cjs/bidiMapper/BidiServer.js +13 -13
- package/lib/cjs/bidiMapper/BidiServer.js.map +1 -1
- package/lib/cjs/bidiMapper/BidiTransport.d.ts +2 -2
- package/lib/cjs/bidiMapper/CdpConnection.d.ts +5 -5
- package/lib/cjs/bidiMapper/CommandProcessor.d.ts +8 -4
- package/lib/cjs/bidiMapper/CommandProcessor.js +45 -23
- package/lib/cjs/bidiMapper/CommandProcessor.js.map +1 -1
- package/lib/cjs/bidiMapper/OutgoingBidiMessage.js +1 -2
- package/lib/cjs/bidiMapper/OutgoingBidiMessage.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.d.ts +25 -13
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.js +186 -144
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.d.ts +10 -5
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.js +117 -87
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.d.ts +16 -4
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.js +30 -6
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.spec.d.ts +17 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.spec.js +36 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.spec.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/context/cdpTarget.d.ts +24 -0
- package/lib/cjs/bidiMapper/domains/context/cdpTarget.js +112 -0
- package/lib/cjs/bidiMapper/domains/context/cdpTarget.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/events/EventManager.d.ts +9 -7
- package/lib/cjs/bidiMapper/domains/events/EventManager.js +50 -30
- package/lib/cjs/bidiMapper/domains/events/EventManager.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.d.ts +18 -1
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.js +88 -41
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.spec.d.ts +1 -0
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.spec.js +138 -50
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.spec.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/log/logHelper.d.ts +1 -1
- package/lib/cjs/bidiMapper/domains/log/logHelper.js +7 -7
- package/lib/cjs/bidiMapper/domains/log/logHelper.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/log/logHelper_getRemoteValuesText.spec.js +5 -29
- package/lib/cjs/bidiMapper/domains/log/logHelper_getRemoteValuesText.spec.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/log/logHelper_logMessageFormatter.spec.js +5 -29
- package/lib/cjs/bidiMapper/domains/log/logHelper_logMessageFormatter.spec.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/log/logManager.d.ts +2 -2
- package/lib/cjs/bidiMapper/domains/log/logManager.js +11 -33
- package/lib/cjs/bidiMapper/domains/log/logManager.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/network/networkProcessor.d.ts +7 -0
- package/lib/cjs/bidiMapper/domains/network/networkProcessor.js +68 -0
- package/lib/cjs/bidiMapper/domains/network/networkProcessor.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/network/networkRequest.d.ts +16 -0
- package/lib/cjs/bidiMapper/domains/network/networkRequest.js +254 -0
- package/lib/cjs/bidiMapper/domains/network/networkRequest.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/script/realm.d.ts +11 -11
- package/lib/cjs/bidiMapper/domains/script/realm.js +23 -16
- package/lib/cjs/bidiMapper/domains/script/realm.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/script/realmStorage.d.ts +4 -3
- package/lib/cjs/bidiMapper/domains/script/realmStorage.js +1 -0
- package/lib/cjs/bidiMapper/domains/script/realmStorage.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/script/scriptEvaluator.d.ts +15 -13
- package/lib/cjs/bidiMapper/domains/script/scriptEvaluator.js +318 -266
- package/lib/cjs/bidiMapper/domains/script/scriptEvaluator.js.map +1 -1
- package/lib/cjs/bidiMapper/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/bidiServer/bidiServerRunner.d.ts +1 -17
- package/lib/cjs/bidiServer/bidiServerRunner.js +23 -7
- package/lib/cjs/bidiServer/bidiServerRunner.js.map +1 -1
- package/lib/cjs/bidiServer/index.js +50 -26
- package/lib/cjs/bidiServer/index.js.map +1 -1
- package/lib/cjs/bidiServer/mapperReader.js +1 -1
- package/lib/cjs/bidiServer/mapperReader.js.map +1 -1
- package/lib/cjs/bidiServer/mapperServer.d.ts +2 -10
- package/lib/cjs/bidiServer/mapperServer.js +60 -27
- package/lib/cjs/bidiServer/mapperServer.js.map +1 -1
- package/lib/cjs/bidiServer/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/bidiTab/bidiTab.d.ts +1 -0
- package/lib/cjs/bidiTab/bidiTab.js +44 -33
- package/lib/cjs/bidiTab/bidiTab.js.map +1 -1
- package/lib/cjs/bidiTab/mapperTabPage.js +5 -3
- package/lib/cjs/bidiTab/mapperTabPage.js.map +1 -1
- package/lib/cjs/bidiTab/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/cdp/cdpClient.d.ts +11 -12
- package/lib/cjs/cdp/cdpClient.js +15 -16
- package/lib/cjs/cdp/cdpClient.js.map +1 -1
- package/lib/cjs/cdp/cdpClient.spec.js +23 -23
- package/lib/cjs/cdp/cdpClient.spec.js.map +1 -1
- package/lib/cjs/cdp/cdpConnection.d.ts +7 -7
- package/lib/cjs/cdp/cdpConnection.js +9 -24
- package/lib/cjs/cdp/cdpConnection.js.map +1 -1
- package/lib/cjs/cdp/cdpConnection.spec.js +15 -14
- package/lib/cjs/cdp/cdpConnection.spec.js.map +1 -1
- package/lib/cjs/cdp/cdpMessage.d.ts +4 -3
- package/lib/cjs/cdp/cdpMessage.js +0 -16
- package/lib/cjs/cdp/cdpMessage.js.map +1 -1
- package/lib/cjs/cdp/index.d.ts +1 -1
- package/lib/cjs/cdp/index.js +1 -1
- package/lib/cjs/cdp/index.js.map +1 -1
- package/lib/cjs/cdp/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/protocol/protocol.d.ts +262 -39
- package/lib/cjs/protocol/protocol.js +93 -21
- package/lib/cjs/protocol/protocol.js.map +1 -1
- package/lib/cjs/protocol/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/protocol-parser/protocol-parser.d.ts +67 -639
- package/lib/cjs/protocol-parser/protocol-parser.js +158 -48
- package/lib/cjs/protocol-parser/protocol-parser.js.map +1 -1
- package/lib/cjs/protocol-parser/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/DefaultMap.d.ts +26 -0
- package/lib/cjs/utils/DefaultMap.js +40 -0
- package/lib/cjs/utils/DefaultMap.js.map +1 -0
- package/lib/cjs/utils/DefaultMap.spec.d.ts +17 -0
- package/lib/cjs/utils/DefaultMap.spec.js +62 -0
- package/lib/cjs/utils/DefaultMap.spec.js.map +1 -0
- package/lib/cjs/utils/EventEmitter.d.ts +12 -12
- package/lib/cjs/utils/EventEmitter.js +6 -6
- package/lib/cjs/utils/EventEmitter.js.map +1 -1
- package/lib/cjs/utils/EventEmitter.spec.d.ts +2 -1
- package/lib/cjs/utils/EventEmitter.spec.js +37 -42
- package/lib/cjs/utils/EventEmitter.spec.js.map +1 -1
- package/lib/cjs/utils/buffer.spec.js +6 -7
- package/lib/cjs/utils/buffer.spec.js.map +1 -1
- package/lib/cjs/utils/deferred.d.ts +1 -1
- package/lib/cjs/utils/deferred.js +5 -2
- package/lib/cjs/utils/deferred.js.map +1 -1
- package/lib/cjs/utils/deferred.spec.d.ts +17 -0
- package/lib/cjs/utils/deferred.spec.js +46 -0
- package/lib/cjs/utils/deferred.spec.js.map +1 -0
- package/lib/cjs/utils/idWrapper.spec.js +4 -28
- package/lib/cjs/utils/idWrapper.spec.js.map +1 -1
- package/lib/cjs/utils/log.js +2 -0
- package/lib/cjs/utils/log.js.map +1 -1
- package/lib/cjs/utils/processingQueue.js +2 -4
- package/lib/cjs/utils/processingQueue.js.map +1 -1
- package/lib/cjs/utils/processingQueue.spec.js +6 -5
- package/lib/cjs/utils/processingQueue.spec.js.map +1 -1
- package/lib/cjs/utils/transport.d.ts +2 -2
- package/lib/cjs/{cdp/stubTransport.spec.d.ts → utils/transportStub.spec.d.ts} +2 -2
- package/lib/cjs/{cdp/stubTransport.spec.js → utils/transportStub.spec.js} +3 -3
- package/lib/cjs/utils/transportStub.spec.js.map +1 -0
- package/lib/cjs/utils/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/unitConversions.d.ts +18 -0
- package/lib/cjs/utils/unitConversions.js +25 -0
- package/lib/cjs/utils/unitConversions.js.map +1 -0
- package/lib/cjs/utils/unitConversions.spec.d.ts +17 -0
- package/lib/cjs/utils/unitConversions.spec.js +27 -0
- package/lib/cjs/utils/unitConversions.spec.js.map +1 -0
- package/lib/cjs/{cdp → utils}/websocketTransport.d.ts +4 -5
- package/lib/cjs/{cdp → utils}/websocketTransport.js +11 -13
- package/lib/cjs/utils/websocketTransport.js.map +1 -0
- package/lib/iife/mapperTab.js +2 -2
- package/lib/iife/mapperTab.js.map +1 -1
- package/package.json +23 -18
- package/lib/cjs/cdp/stubTransport.spec.js.map +0 -1
- package/lib/cjs/cdp/websocketTransport.js.map +0 -1
package/README.md
CHANGED
|
@@ -172,14 +172,26 @@ npm run server -- --headless=false
|
|
|
172
172
|
```
|
|
173
173
|
|
|
174
174
|
Use the `CHANNEL=...` environment variable or `--channel=...` argument with one of
|
|
175
|
-
the following values to run the specific Chrome channel: `
|
|
176
|
-
`
|
|
175
|
+
the following values to run the specific Chrome channel: `stable`,
|
|
176
|
+
`beta`, `canary`, `dev`.
|
|
177
177
|
|
|
178
178
|
The requested Chrome version should be installed.
|
|
179
179
|
|
|
180
180
|
```sh
|
|
181
|
-
CHANNEL=
|
|
182
|
-
npm run server -- --channel=
|
|
181
|
+
CHANNEL=dev npm run server
|
|
182
|
+
npm run server -- --channel=dev
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Use the CLI argument `--verbose` to have CDP events printed to the console. Note: you have to enable debugging output `bidiMapper:mapperDebug:*` as well.
|
|
186
|
+
|
|
187
|
+
```sh
|
|
188
|
+
DEBUG=bidiMapper:mapperDebug:* npm run server -- --verbose
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
or
|
|
192
|
+
|
|
193
|
+
```sh
|
|
194
|
+
DEBUG=* npm run server -- --verbose
|
|
183
195
|
```
|
|
184
196
|
|
|
185
197
|
### Starting on Linux and Mac
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
+
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
18
|
+
import { LoggerFn } from '../utils/log.js';
|
|
19
|
+
import type { Message } from '../protocol/protocol.js';
|
|
17
20
|
import { BidiParser } from './CommandProcessor.js';
|
|
18
21
|
import { BidiTransport } from './BidiTransport.js';
|
|
19
22
|
import { BrowsingContextStorage } from './domains/context/browsingContextStorage.js';
|
|
20
23
|
import { CdpConnection } from './CdpConnection.js';
|
|
21
|
-
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
22
|
-
import { LoggerFn } from '../utils/log.js';
|
|
23
|
-
import type { Message } from '../protocol/protocol.js';
|
|
24
24
|
import { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
|
|
25
25
|
declare type BidiServerEvents = {
|
|
26
26
|
message: Message.RawCommandRequest;
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.BidiServer = void 0;
|
|
20
|
+
const EventEmitter_js_1 = require("../utils/EventEmitter.js");
|
|
21
|
+
const processingQueue_js_1 = require("../utils/processingQueue.js");
|
|
20
22
|
const CommandProcessor_js_1 = require("./CommandProcessor.js");
|
|
21
23
|
const browsingContextStorage_js_1 = require("./domains/context/browsingContextStorage.js");
|
|
22
|
-
const EventEmitter_js_1 = require("../utils/EventEmitter.js");
|
|
23
24
|
const EventManager_js_1 = require("./domains/events/EventManager.js");
|
|
24
|
-
const processingQueue_js_1 = require("../utils/processingQueue.js");
|
|
25
25
|
const realmStorage_js_1 = require("./domains/script/realmStorage.js");
|
|
26
26
|
class BidiServer extends EventEmitter_js_1.EventEmitter {
|
|
27
27
|
#messageQueue;
|
|
@@ -30,12 +30,22 @@ class BidiServer extends EventEmitter_js_1.EventEmitter {
|
|
|
30
30
|
#browsingContextStorage;
|
|
31
31
|
#realmStorage;
|
|
32
32
|
#logger;
|
|
33
|
+
#handleIncomingMessage = (message) => {
|
|
34
|
+
this.#commandProcessor.processCommand(message);
|
|
35
|
+
};
|
|
36
|
+
#processOutgoingMessage = async (messageEntry) => {
|
|
37
|
+
const message = messageEntry.message;
|
|
38
|
+
if (messageEntry.channel !== null) {
|
|
39
|
+
message['channel'] = messageEntry.channel;
|
|
40
|
+
}
|
|
41
|
+
await this.#transport.sendMessage(message);
|
|
42
|
+
};
|
|
33
43
|
constructor(bidiTransport, cdpConnection, selfTargetId, parser, logger) {
|
|
34
44
|
super();
|
|
35
45
|
this.#logger = logger;
|
|
36
46
|
this.#browsingContextStorage = new browsingContextStorage_js_1.BrowsingContextStorage();
|
|
37
47
|
this.#realmStorage = new realmStorage_js_1.RealmStorage();
|
|
38
|
-
this.#messageQueue = new processingQueue_js_1.ProcessingQueue(this.#processOutgoingMessage,
|
|
48
|
+
this.#messageQueue = new processingQueue_js_1.ProcessingQueue(this.#processOutgoingMessage, () => Promise.resolve(), this.#logger);
|
|
39
49
|
this.#transport = bidiTransport;
|
|
40
50
|
this.#transport.setOnMessage(this.#handleIncomingMessage);
|
|
41
51
|
this.#commandProcessor = new CommandProcessor_js_1.CommandProcessor(this.#realmStorage, cdpConnection, new EventManager_js_1.EventManager(this), selfTargetId, parser, this.#browsingContextStorage, this.#logger);
|
|
@@ -62,13 +72,6 @@ class BidiServer extends EventEmitter_js_1.EventEmitter {
|
|
|
62
72
|
.getTopLevelContexts()
|
|
63
73
|
.map((c) => c.awaitLoaded()));
|
|
64
74
|
}
|
|
65
|
-
#processOutgoingMessage = async (messageEntry) => {
|
|
66
|
-
const message = messageEntry.message;
|
|
67
|
-
if (messageEntry.channel !== null) {
|
|
68
|
-
message['channel'] = messageEntry.channel;
|
|
69
|
-
}
|
|
70
|
-
await this.#transport.sendMessage(message);
|
|
71
|
-
};
|
|
72
75
|
/**
|
|
73
76
|
* Sends BiDi message.
|
|
74
77
|
*/
|
|
@@ -78,9 +81,6 @@ class BidiServer extends EventEmitter_js_1.EventEmitter {
|
|
|
78
81
|
close() {
|
|
79
82
|
this.#transport.close();
|
|
80
83
|
}
|
|
81
|
-
#handleIncomingMessage = async (message) => {
|
|
82
|
-
this.#commandProcessor.processCommand(message);
|
|
83
|
-
};
|
|
84
84
|
getBrowsingContextStorage() {
|
|
85
85
|
return this.#browsingContextStorage;
|
|
86
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BidiServer.js","sourceRoot":"","sources":["../../../src/bidiMapper/BidiServer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,+DAAmE;AAEnE,2FAAmF;AAEnF,
|
|
1
|
+
{"version":3,"file":"BidiServer.js","sourceRoot":"","sources":["../../../src/bidiMapper/BidiServer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;G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,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;IAED,yBAAyB;QACvB,OAAO,IAAI,CAAC,uBAAuB,CAAC;IACtC,CAAC;CACF;AA7GD,gCA6GC"}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import type { Message } from '../protocol/protocol.js';
|
|
18
18
|
export interface BidiTransport {
|
|
19
|
-
setOnMessage: (handler: (message: Message.RawCommandRequest) => Promise<void>) => void;
|
|
20
|
-
sendMessage: (message: Message.OutgoingMessage) => Promise<void
|
|
19
|
+
setOnMessage: (handler: (message: Message.RawCommandRequest) => Promise<void> | void) => void;
|
|
20
|
+
sendMessage: (message: Message.OutgoingMessage) => Promise<void> | void;
|
|
21
21
|
close(): void;
|
|
22
22
|
}
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @fileoverview CDP interfaces and types that BiDi Mapper expects.
|
|
19
|
+
*/
|
|
18
20
|
import type { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';
|
|
21
|
+
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
19
22
|
declare type CdpEvents = {
|
|
20
23
|
[Property in keyof ProtocolMapping.Events]: ProtocolMapping.Events[Property][0];
|
|
21
24
|
};
|
|
22
|
-
/**
|
|
23
|
-
* CDP interfaces that BiDi Mapper expects.
|
|
24
|
-
*/
|
|
25
25
|
export interface CdpConnection {
|
|
26
26
|
browserClient(): CdpClient;
|
|
27
27
|
getCdpClient(sessionId: string): CdpClient;
|
|
28
28
|
}
|
|
29
29
|
export interface CdpClient extends EventEmitter<CdpEvents> {
|
|
30
|
-
sendCommand<
|
|
30
|
+
sendCommand<CdpMethod extends keyof ProtocolMapping.Commands>(method: CdpMethod, ...params: ProtocolMapping.Commands[CdpMethod]['paramsType']): Promise<ProtocolMapping.Commands[CdpMethod]['returnType']>;
|
|
31
31
|
}
|
|
32
32
|
export {};
|
|
@@ -15,32 +15,36 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { BrowsingContext, CDP, Message, Script, Session } from '../protocol/protocol.js';
|
|
18
|
+
import { LoggerFn } from '../utils/log.js';
|
|
19
|
+
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
18
20
|
import { BrowsingContextStorage } from './domains/context/browsingContextStorage.js';
|
|
19
21
|
import { CdpConnection } from './CdpConnection.js';
|
|
20
|
-
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
21
22
|
import { IEventManager } from './domains/events/EventManager.js';
|
|
22
|
-
import { LoggerFn } from '../utils/log.js';
|
|
23
23
|
import { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
|
|
24
24
|
import { RealmStorage } from './domains/script/realmStorage.js';
|
|
25
25
|
declare type CommandProcessorEvents = {
|
|
26
26
|
response: Promise<OutgoingBidiMessage>;
|
|
27
27
|
};
|
|
28
28
|
export interface BidiParser {
|
|
29
|
+
parseAddPreloadScriptParams(params: object): Script.AddPreloadScriptParameters;
|
|
30
|
+
parseRemovePreloadScriptParams(params: object): Script.RemovePreloadScriptParameters;
|
|
29
31
|
parseGetRealmsParams(params: object): Script.GetRealmsParameters;
|
|
30
32
|
parseCallFunctionParams(params: object): Script.CallFunctionParameters;
|
|
31
33
|
parseEvaluateParams(params: object): Script.EvaluateParameters;
|
|
32
34
|
parseDisownParams(params: object): Script.DisownParameters;
|
|
33
35
|
parseSendCommandParams(params: object): CDP.SendCommandParams;
|
|
34
36
|
parseGetSessionParams(params: object): CDP.GetSessionParams;
|
|
37
|
+
parseSubscribeParams(params: object): Session.SubscribeParameters;
|
|
35
38
|
parseNavigateParams(params: object): BrowsingContext.NavigateParameters;
|
|
36
39
|
parseGetTreeParams(params: object): BrowsingContext.GetTreeParameters;
|
|
37
|
-
parseSubscribeParams(params: object): Session.SubscribeParameters;
|
|
38
40
|
parseCreateParams(params: object): BrowsingContext.CreateParameters;
|
|
39
41
|
parseCloseParams(params: object): BrowsingContext.CloseParameters;
|
|
42
|
+
parseCaptureScreenshotParams(params: object): BrowsingContext.CaptureScreenshotParameters;
|
|
43
|
+
parsePrintParams(params: object): BrowsingContext.PrintParameters;
|
|
40
44
|
}
|
|
41
45
|
export declare class CommandProcessor extends EventEmitter<CommandProcessorEvents> {
|
|
42
46
|
#private;
|
|
43
47
|
constructor(realmStorage: RealmStorage, cdpConnection: CdpConnection, eventManager: IEventManager, selfTargetId: string, parser: BidiParser | undefined, browsingContextStorage: BrowsingContextStorage, logger?: LoggerFn);
|
|
44
|
-
processCommand
|
|
48
|
+
processCommand(command: Message.RawCommandRequest): Promise<void>;
|
|
45
49
|
}
|
|
46
50
|
export {};
|
|
@@ -18,10 +18,17 @@
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.CommandProcessor = void 0;
|
|
20
20
|
const protocol_js_1 = require("../protocol/protocol.js");
|
|
21
|
-
const
|
|
21
|
+
const log_js_1 = require("../utils/log.js");
|
|
22
22
|
const EventEmitter_js_1 = require("../utils/EventEmitter.js");
|
|
23
|
+
const browsingContextProcessor_js_1 = require("./domains/context/browsingContextProcessor.js");
|
|
23
24
|
const OutgoingBidiMessage_js_1 = require("./OutgoingBidiMessage.js");
|
|
24
25
|
class BidiNoOpParser {
|
|
26
|
+
parseAddPreloadScriptParams(params) {
|
|
27
|
+
return params;
|
|
28
|
+
}
|
|
29
|
+
parseRemovePreloadScriptParams(params) {
|
|
30
|
+
return params;
|
|
31
|
+
}
|
|
25
32
|
parseGetRealmsParams(params) {
|
|
26
33
|
return params;
|
|
27
34
|
}
|
|
@@ -40,13 +47,13 @@ class BidiNoOpParser {
|
|
|
40
47
|
parseGetSessionParams(params) {
|
|
41
48
|
return params;
|
|
42
49
|
}
|
|
43
|
-
|
|
50
|
+
parseSubscribeParams(params) {
|
|
44
51
|
return params;
|
|
45
52
|
}
|
|
46
|
-
|
|
53
|
+
parseNavigateParams(params) {
|
|
47
54
|
return params;
|
|
48
55
|
}
|
|
49
|
-
|
|
56
|
+
parseGetTreeParams(params) {
|
|
50
57
|
return params;
|
|
51
58
|
}
|
|
52
59
|
parseCreateParams(params) {
|
|
@@ -55,19 +62,26 @@ class BidiNoOpParser {
|
|
|
55
62
|
parseCloseParams(params) {
|
|
56
63
|
return params;
|
|
57
64
|
}
|
|
65
|
+
parseCaptureScreenshotParams(params) {
|
|
66
|
+
return params;
|
|
67
|
+
}
|
|
68
|
+
parsePrintParams(params) {
|
|
69
|
+
return params;
|
|
70
|
+
}
|
|
58
71
|
}
|
|
59
72
|
class CommandProcessor extends EventEmitter_js_1.EventEmitter {
|
|
60
73
|
#contextProcessor;
|
|
61
74
|
#eventManager;
|
|
62
75
|
#parser;
|
|
76
|
+
#logger;
|
|
63
77
|
constructor(realmStorage, cdpConnection, eventManager, selfTargetId, parser = new BidiNoOpParser(), browsingContextStorage, logger) {
|
|
64
78
|
super();
|
|
65
79
|
this.#eventManager = eventManager;
|
|
80
|
+
this.#logger = logger;
|
|
66
81
|
this.#contextProcessor = new browsingContextProcessor_js_1.BrowsingContextProcessor(realmStorage, cdpConnection, selfTargetId, eventManager, browsingContextStorage, logger);
|
|
67
82
|
this.#parser = parser;
|
|
68
83
|
}
|
|
69
|
-
|
|
70
|
-
async #process_session_status() {
|
|
84
|
+
static #process_session_status() {
|
|
71
85
|
return { result: { ready: false, message: 'already connected' } };
|
|
72
86
|
}
|
|
73
87
|
async #process_session_subscribe(params, channel) {
|
|
@@ -81,36 +95,44 @@ class CommandProcessor extends EventEmitter_js_1.EventEmitter {
|
|
|
81
95
|
async #processCommand(commandData) {
|
|
82
96
|
switch (commandData.method) {
|
|
83
97
|
case 'session.status':
|
|
84
|
-
return
|
|
98
|
+
return CommandProcessor.#process_session_status();
|
|
85
99
|
case 'session.subscribe':
|
|
86
|
-
return
|
|
100
|
+
return this.#process_session_subscribe(this.#parser.parseSubscribeParams(commandData.params), commandData.channel ?? null);
|
|
87
101
|
case 'session.unsubscribe':
|
|
88
|
-
return
|
|
102
|
+
return this.#process_session_unsubscribe(this.#parser.parseSubscribeParams(commandData.params), commandData.channel ?? null);
|
|
89
103
|
case 'browsingContext.create':
|
|
90
|
-
return
|
|
104
|
+
return this.#contextProcessor.process_browsingContext_create(this.#parser.parseCreateParams(commandData.params));
|
|
91
105
|
case 'browsingContext.close':
|
|
92
|
-
return
|
|
106
|
+
return this.#contextProcessor.process_browsingContext_close(this.#parser.parseCloseParams(commandData.params));
|
|
93
107
|
case 'browsingContext.getTree':
|
|
94
|
-
return
|
|
108
|
+
return this.#contextProcessor.process_browsingContext_getTree(this.#parser.parseGetTreeParams(commandData.params));
|
|
95
109
|
case 'browsingContext.navigate':
|
|
96
|
-
return
|
|
110
|
+
return this.#contextProcessor.process_browsingContext_navigate(this.#parser.parseNavigateParams(commandData.params));
|
|
111
|
+
case 'browsingContext.captureScreenshot':
|
|
112
|
+
return this.#contextProcessor.process_browsingContext_captureScreenshot(this.#parser.parseCaptureScreenshotParams(commandData.params));
|
|
113
|
+
case 'browsingContext.print':
|
|
114
|
+
return this.#contextProcessor.process_browsingContext_print(this.#parser.parsePrintParams(commandData.params));
|
|
115
|
+
case 'script.addPreloadScript':
|
|
116
|
+
return this.#contextProcessor.process_script_addPreloadScript(this.#parser.parseAddPreloadScriptParams(commandData.params));
|
|
117
|
+
case 'script.removePreloadScript':
|
|
118
|
+
return this.#contextProcessor.process_script_removePreloadScript(this.#parser.parseRemovePreloadScriptParams(commandData.params));
|
|
97
119
|
case 'script.getRealms':
|
|
98
120
|
return this.#contextProcessor.process_script_getRealms(this.#parser.parseGetRealmsParams(commandData.params));
|
|
99
121
|
case 'script.callFunction':
|
|
100
|
-
return
|
|
122
|
+
return this.#contextProcessor.process_script_callFunction(this.#parser.parseCallFunctionParams(commandData.params));
|
|
101
123
|
case 'script.evaluate':
|
|
102
|
-
return
|
|
124
|
+
return this.#contextProcessor.process_script_evaluate(this.#parser.parseEvaluateParams(commandData.params));
|
|
103
125
|
case 'script.disown':
|
|
104
|
-
return
|
|
126
|
+
return this.#contextProcessor.process_script_disown(this.#parser.parseDisownParams(commandData.params));
|
|
105
127
|
case 'cdp.sendCommand':
|
|
106
|
-
return
|
|
128
|
+
return this.#contextProcessor.process_cdp_sendCommand(this.#parser.parseSendCommandParams(commandData.params));
|
|
107
129
|
case 'cdp.getSession':
|
|
108
|
-
return
|
|
130
|
+
return this.#contextProcessor.process_cdp_getSession(this.#parser.parseGetSessionParams(commandData.params));
|
|
109
131
|
default:
|
|
110
132
|
throw new protocol_js_1.Message.UnknownCommandException(`Unknown command '${commandData.method}'.`);
|
|
111
133
|
}
|
|
112
134
|
}
|
|
113
|
-
|
|
135
|
+
async processCommand(command) {
|
|
114
136
|
try {
|
|
115
137
|
const result = await this.#processCommand(command);
|
|
116
138
|
const response = {
|
|
@@ -120,17 +142,17 @@ class CommandProcessor extends EventEmitter_js_1.EventEmitter {
|
|
|
120
142
|
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(response, command.channel ?? null));
|
|
121
143
|
}
|
|
122
144
|
catch (e) {
|
|
123
|
-
if (e instanceof protocol_js_1.Message.
|
|
145
|
+
if (e instanceof protocol_js_1.Message.ErrorResponse) {
|
|
124
146
|
const errorResponse = e;
|
|
125
147
|
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(errorResponse.toErrorResponse(command.id), command.channel ?? null));
|
|
126
148
|
}
|
|
127
149
|
else {
|
|
128
150
|
const error = e;
|
|
129
|
-
|
|
130
|
-
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(new protocol_js_1.Message.
|
|
151
|
+
this.#logger?.(log_js_1.LogType.bidi, error);
|
|
152
|
+
this.emit('response', OutgoingBidiMessage_js_1.OutgoingBidiMessage.createResolved(new protocol_js_1.Message.ErrorResponse(protocol_js_1.Message.ErrorCode.UnknownError, error.message).toErrorResponse(command.id), command.channel ?? null));
|
|
131
153
|
}
|
|
132
154
|
}
|
|
133
|
-
}
|
|
155
|
+
}
|
|
134
156
|
}
|
|
135
157
|
exports.CommandProcessor = CommandProcessor;
|
|
136
158
|
//# sourceMappingURL=CommandProcessor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandProcessor.js","sourceRoot":"","sources":["../../../src/bidiMapper/CommandProcessor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,yDAMiC;AACjC
|
|
1
|
+
{"version":3,"file":"CommandProcessor.js","sourceRoot":"","sources":["../../../src/bidiMapper/CommandProcessor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,yDAMiC;AACjC,4CAAkD;AAClD,8DAAsD;AAEtD,+FAAuF;AAIvF,qEAA6D;AA+B7D,MAAM,cAAc;IAClB,2BAA2B,CACzB,MAAc;QAEd,OAAO,MAA2C,CAAC;IACrD,CAAC;IAED,8BAA8B,CAC5B,MAAc;QAEd,OAAO,MAA8C,CAAC;IACxD,CAAC;IAED,oBAAoB,CAAC,MAAc;QACjC,OAAO,MAAoC,CAAC;IAC9C,CAAC;IACD,uBAAuB,CAAC,MAAc;QACpC,OAAO,MAAuC,CAAC;IACjD,CAAC;IACD,mBAAmB,CAAC,MAAc;QAChC,OAAO,MAAmC,CAAC;IAC7C,CAAC;IACD,iBAAiB,CAAC,MAAc;QAC9B,OAAO,MAAiC,CAAC;IAC3C,CAAC;IACD,sBAAsB,CAAC,MAAc;QACnC,OAAO,MAA+B,CAAC;IACzC,CAAC;IACD,qBAAqB,CAAC,MAAc;QAClC,OAAO,MAA8B,CAAC;IACxC,CAAC;IACD,oBAAoB,CAAC,MAAc;QACjC,OAAO,MAAqC,CAAC;IAC/C,CAAC;IACD,mBAAmB,CAAC,MAAc;QAChC,OAAO,MAA4C,CAA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CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBACpC,IAAI,CAAC,IAAI,CACP,UAAU,EACV,4CAAmB,CAAC,cAAc,CAChC,IAAI,qBAAO,CAAC,aAAa,CACvB,qBAAO,CAAC,SAAS,CAAC,YAAY,EAC9B,KAAK,CAAC,OAAO,CACd,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,EAC7B,OAAO,CAAC,OAAO,IAAI,IAAI,CACxB,CACF,CAAC;aACH;SACF;IACH,CAAC;CACF;AAnLD,4CAmLC"}
|
|
@@ -25,8 +25,7 @@ class OutgoingBidiMessage {
|
|
|
25
25
|
this.#channel = channel;
|
|
26
26
|
}
|
|
27
27
|
static async createFromPromise(messagePromise, channel) {
|
|
28
|
-
|
|
29
|
-
return new OutgoingBidiMessage(message, channel);
|
|
28
|
+
return messagePromise.then((message) => new OutgoingBidiMessage(message, channel));
|
|
30
29
|
}
|
|
31
30
|
static createResolved(message, channel) {
|
|
32
31
|
return Promise.resolve(new OutgoingBidiMessage(message, channel));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OutgoingBidiMessage.js","sourceRoot":"","sources":["../../../src/bidiMapper/OutgoingBidiMessage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAIH,MAAa,mBAAmB;IACrB,QAAQ,CAA0B;IAClC,QAAQ,CAAgB;IAEjC,YACE,OAAgC,EAChC,OAAsB;QAEtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAC5B,cAAgD,EAChD,OAAsB;QAEtB,
|
|
1
|
+
{"version":3,"file":"OutgoingBidiMessage.js","sourceRoot":"","sources":["../../../src/bidiMapper/OutgoingBidiMessage.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAIH,MAAa,mBAAmB;IACrB,QAAQ,CAA0B;IAClC,QAAQ,CAAgB;IAEjC,YACE,OAAgC,EAChC,OAAsB;QAEtB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAC5B,cAAgD,EAChD,OAAsB;QAEtB,OAAO,cAAc,CAAC,IAAI,CACxB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CACvD,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,cAAc,CACnB,OAAgC,EAChC,OAAsB;QAEtB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAnCD,kDAmCC"}
|
|
@@ -14,31 +14,43 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { BrowsingContext } from '../../../protocol/protocol.js';
|
|
17
|
+
import { BrowsingContext, CommonDataTypes, Script } from '../../../protocol/protocol.js';
|
|
18
18
|
import { LoggerFn } from '../../../utils/log.js';
|
|
19
|
-
import { BrowsingContextStorage } from './browsingContextStorage.js';
|
|
20
|
-
import { CdpClient } from '../../CdpConnection.js';
|
|
21
19
|
import { IEventManager } from '../events/EventManager.js';
|
|
22
20
|
import { Realm } from '../script/realm.js';
|
|
23
21
|
import { RealmStorage } from '../script/realmStorage.js';
|
|
22
|
+
import { BrowsingContextStorage } from './browsingContextStorage.js';
|
|
23
|
+
import { CdpTarget } from './cdpTarget';
|
|
24
24
|
export declare class BrowsingContextImpl {
|
|
25
25
|
#private;
|
|
26
26
|
private constructor();
|
|
27
|
-
static
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
static create(cdpTarget: CdpTarget, realmStorage: RealmStorage, contextId: CommonDataTypes.BrowsingContext, parentId: CommonDataTypes.BrowsingContext | null, eventManager: IEventManager, browsingContextStorage: BrowsingContextStorage, logger?: LoggerFn): BrowsingContextImpl;
|
|
28
|
+
/**
|
|
29
|
+
* @see https://html.spec.whatwg.org/multipage/document-sequences.html#navigable
|
|
30
|
+
*/
|
|
30
31
|
get navigableId(): string | null;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
get contextId():
|
|
34
|
-
|
|
35
|
-
get
|
|
32
|
+
delete(): void;
|
|
33
|
+
/** Returns the ID of this context. */
|
|
34
|
+
get contextId(): CommonDataTypes.BrowsingContext;
|
|
35
|
+
/** Returns the parent context ID. */
|
|
36
|
+
get parentId(): CommonDataTypes.BrowsingContext | null;
|
|
37
|
+
/** Returns all children contexts. */
|
|
36
38
|
get children(): BrowsingContextImpl[];
|
|
37
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Returns true if this is a top-level context.
|
|
41
|
+
* This is the case whenever the parent context ID is null.
|
|
42
|
+
*/
|
|
43
|
+
isTopLevelContext(): boolean;
|
|
38
44
|
addChild(child: BrowsingContextImpl): void;
|
|
45
|
+
get cdpTarget(): CdpTarget;
|
|
46
|
+
updateCdpTarget(cdpTarget: CdpTarget): void;
|
|
47
|
+
get url(): string;
|
|
39
48
|
awaitLoaded(): Promise<void>;
|
|
40
49
|
awaitUnblocked(): Promise<void>;
|
|
50
|
+
getOrCreateSandbox(sandbox: string | undefined): Promise<Realm>;
|
|
41
51
|
serializeToBidiValue(maxDepth?: number, addParentFiled?: boolean): BrowsingContext.Info;
|
|
42
52
|
navigate(url: string, wait: BrowsingContext.ReadinessState): Promise<BrowsingContext.NavigateResult>;
|
|
43
|
-
|
|
53
|
+
captureScreenshot(): Promise<BrowsingContext.CaptureScreenshotResult>;
|
|
54
|
+
print(params: BrowsingContext.PrintParameters): Promise<BrowsingContext.PrintResult>;
|
|
55
|
+
addPreloadScript(params: Script.AddPreloadScriptParameters): Promise<Script.AddPreloadScriptResult>;
|
|
44
56
|
}
|