chromium-bidi 0.4.11 → 0.4.12
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/.browser +1 -1
- package/README.md +8 -0
- package/lib/cjs/bidiMapper/BidiServer.d.ts +6 -6
- package/lib/cjs/bidiMapper/BidiServer.js.map +1 -1
- package/lib/cjs/bidiMapper/CommandProcessor.d.ts +7 -7
- package/lib/cjs/bidiMapper/CommandProcessor.js.map +1 -1
- package/lib/cjs/bidiMapper/bidiMapper.d.ts +6 -3
- package/lib/cjs/bidiMapper/bidiMapper.js +8 -1
- package/lib/cjs/bidiMapper/bidiMapper.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/PreloadScriptStorage.d.ts +9 -57
- package/lib/cjs/bidiMapper/domains/context/PreloadScriptStorage.js +5 -71
- package/lib/cjs/bidiMapper/domains/context/PreloadScriptStorage.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/bidiPreloadScript.d.ts +42 -0
- package/lib/cjs/bidiMapper/domains/context/bidiPreloadScript.js +115 -0
- package/lib/cjs/bidiMapper/domains/context/bidiPreloadScript.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.d.ts +6 -6
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.js +67 -27
- package/lib/cjs/bidiMapper/domains/context/browsingContextImpl.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.d.ts +9 -9
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.js +11 -26
- package/lib/cjs/bidiMapper/domains/context/browsingContextProcessor.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.d.ts +2 -2
- package/lib/cjs/bidiMapper/domains/context/browsingContextStorage.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/context/cdpTarget.d.ts +6 -21
- package/lib/cjs/bidiMapper/domains/context/cdpTarget.js +9 -56
- package/lib/cjs/bidiMapper/domains/context/cdpTarget.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/events/EventManager.d.ts +1 -1
- package/lib/cjs/bidiMapper/domains/events/SubscriptionManager.d.ts +2 -2
- package/lib/cjs/bidiMapper/domains/input/ActionDispatcher.d.ts +3 -3
- package/lib/cjs/bidiMapper/domains/input/ActionDispatcher.js +1 -1
- package/lib/cjs/bidiMapper/domains/input/ActionDispatcher.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/input/ActionOption.d.ts +1 -1
- package/lib/cjs/bidiMapper/domains/input/InputState.d.ts +2 -2
- package/lib/cjs/bidiMapper/domains/input/InputStateManager.d.ts +1 -1
- package/lib/cjs/bidiMapper/domains/log/logManager.d.ts +3 -3
- package/lib/cjs/bidiMapper/domains/log/logManager.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/network/networkProcessor.d.ts +3 -3
- package/lib/cjs/bidiMapper/domains/network/networkProcessor.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/network/networkRequest.d.ts +2 -2
- package/lib/cjs/bidiMapper/domains/network/networkRequest.js +4 -6
- package/lib/cjs/bidiMapper/domains/network/networkRequest.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/script/channelProxy.d.ts +18 -0
- package/lib/cjs/bidiMapper/domains/script/channelProxy.js +151 -0
- package/lib/cjs/bidiMapper/domains/script/channelProxy.js.map +1 -0
- package/lib/cjs/bidiMapper/domains/script/realm.d.ts +9 -9
- package/lib/cjs/bidiMapper/domains/script/realm.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/script/realmStorage.d.ts +3 -3
- package/lib/cjs/bidiMapper/domains/script/realmStorage.js.map +1 -1
- package/lib/cjs/bidiMapper/domains/script/scriptEvaluator.d.ts +4 -4
- package/lib/cjs/bidiMapper/domains/script/scriptEvaluator.js +4 -88
- 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 -1
- package/lib/cjs/bidiServer/index.js +1 -1
- package/lib/cjs/bidiServer/mapperServer.js +4 -3
- package/lib/cjs/bidiServer/mapperServer.js.map +1 -1
- package/lib/cjs/bidiServer/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/bidiTab/bidiTab.js +5 -6
- package/lib/cjs/bidiTab/bidiTab.js.map +1 -1
- package/lib/cjs/bidiTab/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/cdp/cdpClient.d.ts +19 -11
- package/lib/cjs/cdp/cdpClient.js +8 -20
- package/lib/cjs/cdp/cdpClient.js.map +1 -1
- package/lib/cjs/cdp/cdpConnection.d.ts +11 -15
- package/lib/cjs/cdp/cdpConnection.js +31 -42
- package/lib/cjs/cdp/cdpConnection.js.map +1 -1
- package/lib/cjs/cdp/cdpMessage.d.ts +1 -1
- package/lib/cjs/cdp/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/protocol/protocol.d.ts +25 -17
- package/lib/cjs/protocol/protocol.js +11 -0
- 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 +3 -3
- package/lib/cjs/protocol-parser/protocol-parser.js +14 -17
- package/lib/cjs/protocol-parser/protocol-parser.js.map +1 -1
- package/lib/cjs/protocol-parser/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/EventEmitter.d.ts +1 -1
- package/lib/cjs/utils/EventEmitter.js.map +1 -1
- package/lib/cjs/utils/processingQueue.d.ts +1 -1
- package/lib/cjs/utils/processingQueue.js.map +1 -1
- package/lib/cjs/utils/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/websocketTransport.d.ts +2 -2
- package/lib/iife/mapperTab.js +2 -2
- package/lib/iife/mapperTab.js.map +1 -1
- package/package.json +11 -6
- package/lib/cjs/bidiMapper/CdpConnection.d.ts +0 -42
- package/lib/cjs/bidiMapper/CdpConnection.js +0 -19
- package/lib/cjs/bidiMapper/CdpConnection.js.map +0 -1
- package/lib/cjs/cdp/index.d.ts +0 -19
- package/lib/cjs/cdp/index.js +0 -26
- package/lib/cjs/cdp/index.js.map +0 -1
package/.browser
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
chrome@
|
|
1
|
+
chrome@116.0.5829.0
|
package/README.md
CHANGED
|
@@ -366,6 +366,14 @@ new command, add it to `_processCommand`, write and call processor for it.
|
|
|
366
366
|
|
|
367
367
|
### Publish new `npm` release
|
|
368
368
|
|
|
369
|
+
#### Semi-automatic release
|
|
370
|
+
|
|
371
|
+
Go to [GitHub Actions](https://github.com/GoogleChromeLabs/chromium-bidi/actions/workflows/create-release-pr.yml) and trigger a run with the correct SemVer
|
|
372
|
+
type.
|
|
373
|
+
That will create a PR. Once that is merge a new tag and release will be created.
|
|
374
|
+
|
|
375
|
+
#### Manual release
|
|
376
|
+
|
|
369
377
|
1. Dry-run
|
|
370
378
|
|
|
371
379
|
```sh
|
|
@@ -15,20 +15,20 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
18
|
-
import { LoggerFn } from '../utils/log.js';
|
|
18
|
+
import { type LoggerFn } from '../utils/log.js';
|
|
19
19
|
import type { Message } from '../protocol/protocol.js';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
import type { ICdpConnection } from '../cdp/cdpConnection.js';
|
|
21
|
+
import { type BidiParser } from './CommandProcessor.js';
|
|
22
|
+
import type { BidiTransport } from './BidiTransport.js';
|
|
22
23
|
import { BrowsingContextStorage } from './domains/context/browsingContextStorage.js';
|
|
23
|
-
import {
|
|
24
|
-
import { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
|
|
24
|
+
import type { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
|
|
25
25
|
type BidiServerEvents = {
|
|
26
26
|
message: Message.RawCommandRequest;
|
|
27
27
|
};
|
|
28
28
|
export declare class BidiServer extends EventEmitter<BidiServerEvents> {
|
|
29
29
|
#private;
|
|
30
30
|
private constructor();
|
|
31
|
-
static createAndStart(bidiTransport: BidiTransport, cdpConnection:
|
|
31
|
+
static createAndStart(bidiTransport: BidiTransport, cdpConnection: ICdpConnection, selfTargetId: string, parser?: BidiParser, logger?: LoggerFn): Promise<BidiServer>;
|
|
32
32
|
topLevelContextsLoaded(): Promise<void>;
|
|
33
33
|
/**
|
|
34
34
|
* Sends BiDi message.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BidiServer.js","sourceRoot":"","sources":["../../../src/bidiMapper/BidiServer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,8DAAsD;AACtD,
|
|
1
|
+
{"version":3,"file":"BidiServer.js","sourceRoot":"","sources":["../../../src/bidiMapper/BidiServer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,8DAAsD;AACtD,4CAAuD;AAEvD,oEAA4D;AAG5D,+DAAwE;AAExE,2FAAmF;AACnF,sEAA8D;AAE9D,sEAA8D;AAM9D,MAAa,UAAW,SAAQ,8BAA8B;IAC5D,aAAa,CAAuC;IACpD,UAAU,CAAgB;IAC1B,iBAAiB,CAAmB;IACpC,uBAAuB,CAAyB;IAChD,aAAa,CAAe;IAC5B,OAAO,CAAY;IAEnB,sBAAsB,GAAG,CAAC,OAAkC,EAAE,EAAE;QAC9D,KAAK,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAClE,IAAI,CAAC,OAAO,EAAE,CAAC,gBAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,uBAAuB,GAAG,KAAK,EAAE,YAAiC,EAAE,EAAE;QACpE,MAAM,OAAO,GAAG,YAAY,CAAC,OAAc,CAAC;QAE5C,IAAI,YAAY,CAAC,OAAO,KAAK,IAA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AS,GAAG,aAAa,CAAC,aAAa,EAAE,CAAC;QAEhD,0CAA0C;QAC1C,MAAM,SAAS,CAAC,WAAW,CAAC,2BAA2B,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;QAE3E,iDAAiD;QACjD,MAAM,SAAS,CAAC,WAAW,CAAC,sBAAsB,EAAE;YAClD,UAAU,EAAE,IAAI;YAChB,sBAAsB,EAAE,IAAI;YAC5B,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,sBAAsB,EAAE,CAAC;QACtC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,sBAAsB;QAC1B,MAAM,OAAO,CAAC,GAAG,CACf,IAAI,CAAC,uBAAuB;aACzB,mBAAmB,EAAE;aACrB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAC/B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,YAA0C;QAC5D,IAAI,CAAC,aAAa,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;AA9GD,gCA8GC"}
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { BrowsingContext, CDP, Input, Message, Script, Session } from '../protocol/protocol.js';
|
|
18
|
-
import { LoggerFn } from '../utils/log.js';
|
|
17
|
+
import { type BrowsingContext, type CDP, type Input, Message, type Script, type Session } from '../protocol/protocol.js';
|
|
18
|
+
import { type LoggerFn } from '../utils/log.js';
|
|
19
19
|
import { EventEmitter } from '../utils/EventEmitter.js';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { IEventManager } from './domains/events/EventManager.js';
|
|
20
|
+
import type { ICdpConnection } from '../cdp/cdpConnection.js';
|
|
21
|
+
import type { BrowsingContextStorage } from './domains/context/browsingContextStorage.js';
|
|
22
|
+
import type { IEventManager } from './domains/events/EventManager.js';
|
|
23
23
|
import { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
|
|
24
|
-
import { RealmStorage } from './domains/script/realmStorage.js';
|
|
24
|
+
import type { RealmStorage } from './domains/script/realmStorage.js';
|
|
25
25
|
type CommandProcessorEvents = {
|
|
26
26
|
response: Promise<OutgoingBidiMessage>;
|
|
27
27
|
};
|
|
@@ -47,7 +47,7 @@ export interface BidiParser {
|
|
|
47
47
|
}
|
|
48
48
|
export declare class CommandProcessor extends EventEmitter<CommandProcessorEvents> {
|
|
49
49
|
#private;
|
|
50
|
-
constructor(realmStorage: RealmStorage, cdpConnection:
|
|
50
|
+
constructor(realmStorage: RealmStorage, cdpConnection: ICdpConnection, eventManager: IEventManager, selfTargetId: string, parser: BidiParser | undefined, browsingContextStorage: BrowsingContextStorage, logger?: LoggerFn);
|
|
51
51
|
processCommand(command: Message.RawCommandRequest): Promise<void>;
|
|
52
52
|
}
|
|
53
53
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandProcessor.js","sourceRoot":"","sources":["../../../src/bidiMapper/CommandProcessor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,yDAOiC;AACjC,
|
|
1
|
+
{"version":3,"file":"CommandProcessor.js","sourceRoot":"","sources":["../../../src/bidiMapper/CommandProcessor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,yDAOiC;AACjC,4CAAuD;AACvD,8DAAsD;AAGtD,+FAAuF;AAGvF,qEAA6D;AAkC7D,MAAM,cAAc;IAClB,2BAA2B,CACzB,MAAc;QAEd,OAAO,MAA2C,CAAC;IACrD,CAAC;IAED,8BAA8B,CAC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AAE,KAAK,CAAC,CAAC;gBACpC,IAAI,CAAC,IAAI,CACP,UAAU,EACV,4CAAmB,CAAC,cAAc,CAChC,IAAI,qBAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,eAAe,CAC9D,OAAO,CAAC,EAAE,CACX,EACD,OAAO,CAAC,OAAO,IAAI,IAAI,CACxB,CACF,CAAC;aACH;SACF;IACH,CAAC;CACF;AAjMD,4CAiMC"}
|
|
@@ -17,9 +17,12 @@
|
|
|
17
17
|
/**
|
|
18
18
|
* @fileoverview The entry point to the BiDi Mapper namespace.
|
|
19
19
|
* Other modules should only access exports defined in this file.
|
|
20
|
-
* XXX:
|
|
20
|
+
* XXX: Add ESlint rule for this (https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-restricted-paths.md)
|
|
21
21
|
*/
|
|
22
|
-
export { CdpConnection, CdpClient } from './CdpConnection.js';
|
|
23
22
|
export { BidiServer } from './BidiServer.js';
|
|
24
|
-
export {
|
|
23
|
+
export type { ICdpConnection, ICdpConnection as CdpConnection, } from '../cdp/cdpConnection.js';
|
|
24
|
+
export type { ICdpClient, ICdpClient as CdpClient } from '../cdp/cdpClient.js';
|
|
25
25
|
export { EventEmitter } from '../utils/EventEmitter.js';
|
|
26
|
+
export type { BidiTransport } from './BidiTransport.js';
|
|
27
|
+
export { OutgoingBidiMessage } from './OutgoingBidiMessage.js';
|
|
28
|
+
export type { BidiParser } from './CommandProcessor.js';
|
|
@@ -16,9 +16,16 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.EventEmitter = exports.BidiServer = void 0;
|
|
19
|
+
exports.OutgoingBidiMessage = exports.EventEmitter = exports.BidiServer = void 0;
|
|
20
|
+
/**
|
|
21
|
+
* @fileoverview The entry point to the BiDi Mapper namespace.
|
|
22
|
+
* Other modules should only access exports defined in this file.
|
|
23
|
+
* XXX: Add ESlint rule for this (https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-restricted-paths.md)
|
|
24
|
+
*/
|
|
20
25
|
var BidiServer_js_1 = require("./BidiServer.js");
|
|
21
26
|
Object.defineProperty(exports, "BidiServer", { enumerable: true, get: function () { return BidiServer_js_1.BidiServer; } });
|
|
22
27
|
var EventEmitter_js_1 = require("../utils/EventEmitter.js");
|
|
23
28
|
Object.defineProperty(exports, "EventEmitter", { enumerable: true, get: function () { return EventEmitter_js_1.EventEmitter; } });
|
|
29
|
+
var OutgoingBidiMessage_js_1 = require("./OutgoingBidiMessage.js");
|
|
30
|
+
Object.defineProperty(exports, "OutgoingBidiMessage", { enumerable: true, get: function () { return OutgoingBidiMessage_js_1.OutgoingBidiMessage; } });
|
|
24
31
|
//# sourceMappingURL=bidiMapper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bidiMapper.js","sourceRoot":"","sources":["../../../src/bidiMapper/bidiMapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;
|
|
1
|
+
{"version":3,"file":"bidiMapper.js","sourceRoot":"","sources":["../../../src/bidiMapper/bidiMapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH;;;;GAIG;AACH,iDAA2C;AAAnC,2GAAA,UAAU,OAAA;AAMlB,4DAAsD;AAA9C,+GAAA,YAAY,OAAA;AAEpB,mEAA6D;AAArD,6HAAA,mBAAmB,OAAA"}
|
|
@@ -1,69 +1,21 @@
|
|
|
1
|
-
import { CommonDataTypes
|
|
2
|
-
import { CdpTarget } from './cdpTarget.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
functionDeclaration: string;
|
|
10
|
-
/** The script sandbox / world name. */
|
|
11
|
-
sandbox?: string;
|
|
12
|
-
/** Browsing context ID. */
|
|
13
|
-
contextId: CommonDataTypes.BrowsingContext | null;
|
|
14
|
-
};
|
|
15
|
-
/** BidiPreloadScripts can be filtered by either context ID or BiDi ID. */
|
|
16
|
-
export type BidiPreloadScriptFilter = Partial<Pick<BidiPreloadScript, 'contextId'> & Pick<BidiPreloadScript, 'id'>> & {
|
|
1
|
+
import type { CommonDataTypes } from '../../../protocol/protocol.js';
|
|
2
|
+
import type { CdpTarget } from './cdpTarget.js';
|
|
3
|
+
import { BidiPreloadScript } from './bidiPreloadScript.js';
|
|
4
|
+
/**
|
|
5
|
+
* BidiPreloadScripts can be filtered by either context ID, BiDi ID or
|
|
6
|
+
* target ID.
|
|
7
|
+
*/
|
|
8
|
+
export type BidiPreloadScriptFilter = Partial<Pick<BidiPreloadScript, 'contextId'> & Pick<BidiPreloadScript, 'id'> & Pick<CdpTarget, 'targetId'>> & {
|
|
17
9
|
contextIds?: (CommonDataTypes.BrowsingContext | null)[];
|
|
18
10
|
};
|
|
19
|
-
export type CdpPreloadScript = {
|
|
20
|
-
/** CDP target. Includes session ID and target ID. */
|
|
21
|
-
target: CdpTarget;
|
|
22
|
-
/** CDP preload script ID. */
|
|
23
|
-
preloadScriptId: Script.PreloadScript;
|
|
24
|
-
};
|
|
25
|
-
/** CdpPreloadScripts can be filtered by CDP session ID or target ID. */
|
|
26
|
-
export type CdpPreloadScriptFilter = {
|
|
27
|
-
/** CDP session ID. */
|
|
28
|
-
sessionId?: string;
|
|
29
|
-
/** CDP target ID. */
|
|
30
|
-
targetId?: string;
|
|
31
|
-
};
|
|
32
11
|
/**
|
|
33
12
|
* Container class for preload scripts.
|
|
34
|
-
*
|
|
35
|
-
* BiDi IDs are generated by the server and are unique within the context.
|
|
36
|
-
*
|
|
37
|
-
* CDP preload script IDs are generated by the client and are unique
|
|
38
|
-
* within the session.
|
|
39
|
-
*
|
|
40
|
-
* The mapping between BiDi and CDP preload script IDs is 1:many.
|
|
41
|
-
* BiDi IDs are needed by the mapper to keep track of potential multiple CDP IDs
|
|
42
|
-
* in the client.
|
|
43
|
-
*
|
|
44
|
-
* This class does not concern itself with the validity of the IDs.
|
|
45
13
|
*/
|
|
46
14
|
export declare class PreloadScriptStorage {
|
|
47
15
|
#private;
|
|
48
16
|
/** Finds all entries that match the given filter. */
|
|
49
17
|
findPreloadScripts(filter?: BidiPreloadScriptFilter): BidiPreloadScript[];
|
|
50
|
-
|
|
51
|
-
* Keeps track of the given CDP preload scripts associated with the given
|
|
52
|
-
* browsing context ID.
|
|
53
|
-
*
|
|
54
|
-
* @param contextId Browsing context ID, or null for global context.
|
|
55
|
-
* @param cdpPreloadScripts CDP preload scripts.
|
|
56
|
-
* @param functionDeclaration The script itself, in a format expected by the spec
|
|
57
|
-
* i.e. a function.
|
|
58
|
-
*/
|
|
59
|
-
addPreloadScripts(contextId: CommonDataTypes.BrowsingContext | null, cdpPreloadScripts: CdpPreloadScript[], functionDeclaration: string, sandbox?: string): BidiPreloadScript;
|
|
60
|
-
/**
|
|
61
|
-
* Keeps track of the given CDP preload script in the given BiDi preload
|
|
62
|
-
* script.
|
|
63
|
-
*/
|
|
64
|
-
appendCdpPreloadScript(script: BidiPreloadScript, cdpPreloadScript: CdpPreloadScript): void;
|
|
18
|
+
addPreloadScript(preloadScript: BidiPreloadScript): void;
|
|
65
19
|
/** Deletes all BiDi preload script entries that match the given filter. */
|
|
66
20
|
removeBiDiPreloadScripts(filter?: BidiPreloadScriptFilter): void;
|
|
67
|
-
/** Deletes all CDP preload script entries that match the given filter. */
|
|
68
|
-
removeCdpPreloadScripts(filter?: CdpPreloadScriptFilter): void;
|
|
69
21
|
}
|
|
@@ -1,36 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PreloadScriptStorage = void 0;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright 2023 Google LLC.
|
|
6
|
-
* Copyright (c) Microsoft Corporation.
|
|
7
|
-
*
|
|
8
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License.
|
|
10
|
-
* You may obtain a copy of the License at
|
|
11
|
-
*
|
|
12
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
-
* See the License for the specific language governing permissions and
|
|
18
|
-
* limitations under the License.
|
|
19
|
-
*/
|
|
20
|
-
const uuid_js_1 = require("../../../utils/uuid.js");
|
|
21
4
|
/**
|
|
22
5
|
* Container class for preload scripts.
|
|
23
|
-
*
|
|
24
|
-
* BiDi IDs are generated by the server and are unique within the context.
|
|
25
|
-
*
|
|
26
|
-
* CDP preload script IDs are generated by the client and are unique
|
|
27
|
-
* within the session.
|
|
28
|
-
*
|
|
29
|
-
* The mapping between BiDi and CDP preload script IDs is 1:many.
|
|
30
|
-
* BiDi IDs are needed by the mapper to keep track of potential multiple CDP IDs
|
|
31
|
-
* in the client.
|
|
32
|
-
*
|
|
33
|
-
* This class does not concern itself with the validity of the IDs.
|
|
34
6
|
*/
|
|
35
7
|
class PreloadScriptStorage {
|
|
36
8
|
/** Tracks all BiDi preload scripts. */
|
|
@@ -52,37 +24,15 @@ class PreloadScriptStorage {
|
|
|
52
24
|
!filter.contextIds.includes(script.contextId)) {
|
|
53
25
|
return false;
|
|
54
26
|
}
|
|
27
|
+
if (filter.targetId !== undefined &&
|
|
28
|
+
!script.targetIds.has(filter.targetId)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
55
31
|
return true;
|
|
56
32
|
});
|
|
57
33
|
}
|
|
58
|
-
|
|
59
|
-
* Keeps track of the given CDP preload scripts associated with the given
|
|
60
|
-
* browsing context ID.
|
|
61
|
-
*
|
|
62
|
-
* @param contextId Browsing context ID, or null for global context.
|
|
63
|
-
* @param cdpPreloadScripts CDP preload scripts.
|
|
64
|
-
* @param functionDeclaration The script itself, in a format expected by the spec
|
|
65
|
-
* i.e. a function.
|
|
66
|
-
*/
|
|
67
|
-
addPreloadScripts(contextId, cdpPreloadScripts, functionDeclaration, sandbox) {
|
|
68
|
-
// Generate a random ID.
|
|
69
|
-
const bidiId = (0, uuid_js_1.uuidv4)();
|
|
70
|
-
const preloadScript = {
|
|
71
|
-
id: bidiId,
|
|
72
|
-
contextId,
|
|
73
|
-
cdpPreloadScripts,
|
|
74
|
-
functionDeclaration,
|
|
75
|
-
sandbox,
|
|
76
|
-
};
|
|
34
|
+
addPreloadScript(preloadScript) {
|
|
77
35
|
this.#scripts.add(preloadScript);
|
|
78
|
-
return preloadScript;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Keeps track of the given CDP preload script in the given BiDi preload
|
|
82
|
-
* script.
|
|
83
|
-
*/
|
|
84
|
-
appendCdpPreloadScript(script, cdpPreloadScript) {
|
|
85
|
-
script.cdpPreloadScripts.push(cdpPreloadScript);
|
|
86
36
|
}
|
|
87
37
|
/** Deletes all BiDi preload script entries that match the given filter. */
|
|
88
38
|
removeBiDiPreloadScripts(filter) {
|
|
@@ -90,22 +40,6 @@ class PreloadScriptStorage {
|
|
|
90
40
|
this.#scripts.delete(preloadScript);
|
|
91
41
|
}
|
|
92
42
|
}
|
|
93
|
-
/** Deletes all CDP preload script entries that match the given filter. */
|
|
94
|
-
removeCdpPreloadScripts(filter) {
|
|
95
|
-
for (const preloadScript of this.#scripts) {
|
|
96
|
-
preloadScript.cdpPreloadScripts = preloadScript.cdpPreloadScripts.filter((cdpPreloadScript) => {
|
|
97
|
-
if (filter?.targetId !== undefined &&
|
|
98
|
-
filter.targetId !== cdpPreloadScript.target.targetId) {
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
if (filter?.sessionId !== undefined &&
|
|
102
|
-
filter.sessionId !== cdpPreloadScript.target.cdpSessionId) {
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
return false;
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
43
|
}
|
|
110
44
|
exports.PreloadScriptStorage = PreloadScriptStorage;
|
|
111
45
|
//# sourceMappingURL=PreloadScriptStorage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreloadScriptStorage.js","sourceRoot":"","sources":["../../../../../src/bidiMapper/domains/context/PreloadScriptStorage.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"PreloadScriptStorage.js","sourceRoot":"","sources":["../../../../../src/bidiMapper/domains/context/PreloadScriptStorage.ts"],"names":[],"mappings":";;;AA+BA;;GAEG;AACH,MAAa,oBAAoB;IAC/B,wCAAwC;IAC/B,QAAQ,GAAG,IAAI,GAAG,EAAqB,CAAC;IAEjD,qDAAqD;IACrD,kBAAkB,CAAC,MAAgC;QACjD,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC3B;QAED,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YAC1C,IAAI,MAAM,CAAC,EAAE,KAAK,SAAS,IAAI,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,EAAE;gBACtD,OAAO,KAAK,CAAC;aACd;YACD,IACE,MAAM,CAAC,SAAS,KAAK,SAAS;gBAC9B,MAAM,CAAC,SAAS,KAAK,MAAM,CAAC,SAAS,EACrC;gBACA,OAAO,KAAK,CAAC;aACd;YACD,IACE,MAAM,CAAC,UAAU,KAAK,SAAS;gBAC/B,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,EAC7C;gBACA,OAAO,KAAK,CAAC;aACd;YACD,IACE,MAAM,CAAC,QAAQ,KAAK,SAAS;gBAC7B,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,EACtC;gBACA,OAAO,KAAK,CAAC;aACd;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAED,gBAAgB,CAAC,aAAgC;QAC/C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACnC,CAAC;IAED,2EAA2E;IAC3E,wBAAwB,CAAC,MAAgC;QACvD,KAAK,MAAM,aAAa,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;YAC3D,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;SACrC;IACH,CAAC;CACF;AA9CD,oDA8CC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CommonDataTypes, Script } from '../../../protocol/protocol.js';
|
|
2
|
+
import type { CdpTarget } from './cdpTarget.js';
|
|
3
|
+
/**
|
|
4
|
+
* BiDi IDs are generated by the server and are unique within the context.
|
|
5
|
+
*
|
|
6
|
+
* CDP preload script IDs are generated by the client and are unique
|
|
7
|
+
* within the session.
|
|
8
|
+
*
|
|
9
|
+
* The mapping between BiDi and CDP preload script IDs is 1:many.
|
|
10
|
+
* BiDi IDs are needed by the mapper to keep track of potential multiple CDP IDs
|
|
11
|
+
* in the client.
|
|
12
|
+
*/
|
|
13
|
+
export declare class BidiPreloadScript {
|
|
14
|
+
#private;
|
|
15
|
+
get id(): string;
|
|
16
|
+
get contextId(): CommonDataTypes.BrowsingContext | null;
|
|
17
|
+
get targetIds(): Set<string>;
|
|
18
|
+
constructor(params: Script.AddPreloadScriptParameters);
|
|
19
|
+
/**
|
|
20
|
+
* Adds the script to the given CDP targets by calling the
|
|
21
|
+
* `Page.addScriptToEvaluateOnNewDocument` command.
|
|
22
|
+
*/
|
|
23
|
+
initInTargets(cdpTargets: Iterable<CdpTarget>): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Adds the script to the given CDP target by calling the
|
|
26
|
+
* `Page.addScriptToEvaluateOnNewDocument` command.
|
|
27
|
+
*/
|
|
28
|
+
initInTarget(cdpTarget: CdpTarget): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Schedules the script to be run right after
|
|
31
|
+
* `Runtime.runIfWaitingForDebugger`, but does not wait for result.
|
|
32
|
+
*/
|
|
33
|
+
scheduleEvaluateInTarget(cdpTarget: CdpTarget): void;
|
|
34
|
+
/**
|
|
35
|
+
* Removes this script from all CDP targets.
|
|
36
|
+
*/
|
|
37
|
+
remove(): Promise<void>;
|
|
38
|
+
/**
|
|
39
|
+
* Removes the provided cdp target from the list of cdp preload scripts.
|
|
40
|
+
*/
|
|
41
|
+
cdpTargetIsGone(cdpTargetId: string): Promise<void>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright 2023 Google LLC.
|
|
4
|
+
* Copyright (c) Microsoft Corporation.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.BidiPreloadScript = void 0;
|
|
21
|
+
const uuid_js_1 = require("../../../utils/uuid.js");
|
|
22
|
+
/**
|
|
23
|
+
* BiDi IDs are generated by the server and are unique within the context.
|
|
24
|
+
*
|
|
25
|
+
* CDP preload script IDs are generated by the client and are unique
|
|
26
|
+
* within the session.
|
|
27
|
+
*
|
|
28
|
+
* The mapping between BiDi and CDP preload script IDs is 1:many.
|
|
29
|
+
* BiDi IDs are needed by the mapper to keep track of potential multiple CDP IDs
|
|
30
|
+
* in the client.
|
|
31
|
+
*/
|
|
32
|
+
class BidiPreloadScript {
|
|
33
|
+
/** BiDi ID, an automatically generated UUID. */
|
|
34
|
+
#id = (0, uuid_js_1.uuidv4)();
|
|
35
|
+
/** CDP preload scripts. */
|
|
36
|
+
#cdpPreloadScripts = [];
|
|
37
|
+
/** The script itself, in a format expected by the spec i.e. a function. */
|
|
38
|
+
#functionDeclaration;
|
|
39
|
+
/** Browsing context ID. */
|
|
40
|
+
#contextId;
|
|
41
|
+
/** Targets, in which the preload script is initialized. */
|
|
42
|
+
#targetIds = new Set();
|
|
43
|
+
get id() {
|
|
44
|
+
return this.#id;
|
|
45
|
+
}
|
|
46
|
+
get contextId() {
|
|
47
|
+
return this.#contextId;
|
|
48
|
+
}
|
|
49
|
+
get targetIds() {
|
|
50
|
+
return this.#targetIds;
|
|
51
|
+
}
|
|
52
|
+
constructor(params) {
|
|
53
|
+
if (params.sandbox !== undefined) {
|
|
54
|
+
// TODO: Handle sandbox.
|
|
55
|
+
throw new Error('Sandbox is not supported yet');
|
|
56
|
+
}
|
|
57
|
+
if (params.arguments !== undefined && params.arguments.length > 0) {
|
|
58
|
+
// TODO: Handle arguments.
|
|
59
|
+
throw new Error('add preload script arguments are not supported');
|
|
60
|
+
}
|
|
61
|
+
this.#functionDeclaration = params.functionDeclaration;
|
|
62
|
+
this.#contextId = params.context ?? null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Adds the script to the given CDP targets by calling the
|
|
66
|
+
* `Page.addScriptToEvaluateOnNewDocument` command.
|
|
67
|
+
*/
|
|
68
|
+
async initInTargets(cdpTargets) {
|
|
69
|
+
await Promise.all(Array.from(cdpTargets).map((cdpTarget) => this.initInTarget(cdpTarget)));
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Adds the script to the given CDP target by calling the
|
|
73
|
+
* `Page.addScriptToEvaluateOnNewDocument` command.
|
|
74
|
+
*/
|
|
75
|
+
async initInTarget(cdpTarget) {
|
|
76
|
+
const addCdpPreloadScriptResult = await cdpTarget.cdpClient.sendCommand('Page.addScriptToEvaluateOnNewDocument', {
|
|
77
|
+
source: `(${this.#functionDeclaration})();`,
|
|
78
|
+
});
|
|
79
|
+
this.#cdpPreloadScripts.push({
|
|
80
|
+
target: cdpTarget,
|
|
81
|
+
preloadScriptId: addCdpPreloadScriptResult.identifier,
|
|
82
|
+
});
|
|
83
|
+
this.#targetIds.add(cdpTarget.targetId);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Schedules the script to be run right after
|
|
87
|
+
* `Runtime.runIfWaitingForDebugger`, but does not wait for result.
|
|
88
|
+
*/
|
|
89
|
+
scheduleEvaluateInTarget(cdpTarget) {
|
|
90
|
+
void cdpTarget.cdpClient.sendCommand('Runtime.evaluate', {
|
|
91
|
+
expression: `(${this.#functionDeclaration})();`,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Removes this script from all CDP targets.
|
|
96
|
+
*/
|
|
97
|
+
async remove() {
|
|
98
|
+
for (const cdpPreloadScript of this.#cdpPreloadScripts) {
|
|
99
|
+
const cdpTarget = cdpPreloadScript.target;
|
|
100
|
+
const cdpPreloadScriptId = cdpPreloadScript.preloadScriptId;
|
|
101
|
+
await cdpTarget.cdpClient.sendCommand('Page.removeScriptToEvaluateOnNewDocument', {
|
|
102
|
+
identifier: cdpPreloadScriptId,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Removes the provided cdp target from the list of cdp preload scripts.
|
|
108
|
+
*/
|
|
109
|
+
async cdpTargetIsGone(cdpTargetId) {
|
|
110
|
+
this.#cdpPreloadScripts = this.#cdpPreloadScripts.filter((cdpPreloadScript) => cdpPreloadScript.target?.targetId !== cdpTargetId);
|
|
111
|
+
this.#targetIds.delete(cdpTargetId);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
exports.BidiPreloadScript = BidiPreloadScript;
|
|
115
|
+
//# sourceMappingURL=bidiPreloadScript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bidiPreloadScript.js","sourceRoot":"","sources":["../../../../../src/bidiMapper/domains/context/bidiPreloadScript.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAGH,oDAA8C;AAU9C;;;;;;;;;GASG;AACH,MAAa,iBAAiB;IAC5B,gDAAgD;IACvC,GAAG,GAAW,IAAA,gBAAM,GAAE,CAAC;IAChC,2BAA2B;IAC3B,kBAAkB,GAAuB,EAAE,CAAC;IAC5C,2EAA2E;IAClE,oBAAoB,CAAS;IACtC,2BAA2B;IAClB,UAAU,CAAyC;IAC5D,2DAA2D;IAClD,UAAU,GAAgB,IAAI,GAAG,EAAE,CAAC;IAE7C,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,YAAY,MAAyC;QACnD,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE;YAChC,wBAAwB;YACxB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;SACjD;QACD,IAAI,MAAM,CAAC,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE;YACjE,0BAA0B;YAC1B,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;SACnE;QAED,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC,mBAAmB,CAAC;QACvD,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACH,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B,CAAC,MAAM,CACtD,CAAC,gBAAgB,EAAE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAE,QAAQ,KAAK,WAAW,CACxE,CAAC;QACF,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;CACF;AAtGD,8CAsGC"}
|
|
@@ -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 { BrowsingContext, CommonDataTypes, Message } from '../../../protocol/protocol.js';
|
|
18
|
-
import { LoggerFn } from '../../../utils/log.js';
|
|
19
|
-
import { IEventManager } from '../events/EventManager.js';
|
|
17
|
+
import { BrowsingContext, type CommonDataTypes, Message } from '../../../protocol/protocol.js';
|
|
18
|
+
import { type LoggerFn } from '../../../utils/log.js';
|
|
19
|
+
import type { IEventManager } from '../events/EventManager.js';
|
|
20
20
|
import { Realm } from '../script/realm.js';
|
|
21
|
-
import { RealmStorage } from '../script/realmStorage.js';
|
|
22
|
-
import { BrowsingContextStorage } from './browsingContextStorage.js';
|
|
23
|
-
import { CdpTarget } from './cdpTarget.js';
|
|
21
|
+
import type { RealmStorage } from '../script/realmStorage.js';
|
|
22
|
+
import type { BrowsingContextStorage } from './browsingContextStorage.js';
|
|
23
|
+
import type { CdpTarget } from './cdpTarget.js';
|
|
24
24
|
export declare class BrowsingContextImpl {
|
|
25
25
|
#private;
|
|
26
26
|
private constructor();
|