UNPKG

@tvanlaerhoven/epex-client

Version:

Collect European Power Exchange (EPEX) market data

1,287 lines (1,230 loc) 877 kB
import { g as getAugmentedNamespace, C as CDPSession, D as Deferred$1, U as UnsupportedOperation, T as TargetCloseError, E as EventEmitter$1, a as CallbackRegistry, b as ConnectionClosedError, d as debugError, c as debug, e as DisposableStack, f as disposeSymbol, i as inertIfDisposed, t as throwIfDisposed, s as stringToTypedArray, P as ProtocolError, h as assert$1, J as JSHandle, j as environment, A as AsyncIterableUtil, k as ElementHandle, l as bindIsolatedHandle, m as Dialog, n as stringifyFunction, o as interpolateFunction, S as SecurityDetails, H as HTTPResponse, p as invokeAtMostOnceForArguments, q as HTTPRequest, I as InterceptResolutionAction, r as stringToBase64, u as handleError, v as STATUS_TEXTS, w as isPlainObject, x as isRegExp, y as isDate, z as PuppeteerURL, B as TimeoutError, R as Realm$2, F as scriptInjector, G as getSourceUrlComment, K as getSourcePuppeteerURLIfAvailable, L as isString, M as LazyArg, N as ARIAQueryHandler, O as SOURCE_URL_REGEX, W as WebWorker, Q as of, V as combineLatest, X as fromEmitterEvent, Y as map, Z as first, _ as raceWith, $ as timeout, a0 as Accessibility, a1 as ConsoleMessage, a2 as defer, a3 as filter, a4 as isErrorLike, a5 as firstValueFrom, a6 as race, a7 as switchMap, a8 as delayWhen, a9 as fromAbortSignal, aa as Frame, ab as throwIfDetached, ac as Keyboard, ad as Mouse, ae as MouseButton, af as Touchscreen, ag as TouchError, ah as EmulationManager, ai as Tracing, aj as Coverage, ak as parsePDFOptions, al as from, am as FileChooser, an as evaluationString, ao as Page, ap as bubble, aq as Target, ar as TargetType, as as WEB_PERMISSION_TO_PROTOCOL_PERMISSION, at as BrowserContext, au as Browser$1 } from './index-AR91hTJ5.js'; import require$$2 from 'crypto'; import 'node:fs/promises'; import 'node:os'; import 'node:path'; import 'node:child_process'; import 'node:events'; import 'node:fs'; import 'node:readline'; import 'node:http'; import 'node:https'; import 'node:url'; import 'http'; import 'https'; import 'url'; import 'net'; import 'tty'; import 'util'; import 'os'; import 'tls'; import 'events'; import 'assert'; import 'buffer'; import 'stream'; import 'dns'; import 'fs'; import 'path'; import 'node:assert'; import 'node:stream'; import 'node:process'; import 'zlib'; import 'fs/promises'; import 'module'; import 'inspector'; var BidiMapper = {}; var BidiServer = {}; var EventEmitter = {}; function mitt(n){return {all:n=n||new Map,on:function(t,e){var i=n.get(t);i?i.push(e):n.set(t,[e]);},off:function(t,e){var i=n.get(t);i&&(e?i.splice(i.indexOf(e)>>>0,1):n.set(t,[]));},emit:function(t,e){var i=n.get(t);i&&i.slice().map(function(n){n(e);}),(i=n.get("*"))&&i.slice().map(function(n){n(t,e);});}}} var mitt$1 = /*#__PURE__*/Object.freeze({ __proto__: null, default: mitt }); var require$$0 = /*@__PURE__*/getAugmentedNamespace(mitt$1); var hasRequiredEventEmitter; function requireEventEmitter () { if (hasRequiredEventEmitter) return EventEmitter; hasRequiredEventEmitter = 1; var __importDefault = (EventEmitter.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(EventEmitter, "__esModule", { value: true }); EventEmitter.EventEmitter = void 0; /** * Copyright 2022 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const mitt_1 = __importDefault(require$$0); let EventEmitter$1 = class EventEmitter { #emitter = (0, mitt_1.default)(); on(type, handler) { this.#emitter.on(type, handler); return this; } /** * Like `on` but the listener will only be fired once and then it will be removed. * @param event The event you'd like to listen to * @param handler The handler function to run when the event occurs * @return `this` to enable chaining method calls. */ once(event, handler) { const onceHandler = (eventData) => { handler(eventData); this.off(event, onceHandler); }; return this.on(event, onceHandler); } off(type, handler) { this.#emitter.off(type, handler); return this; } /** * Emits an event and call any associated listeners. * * @param event The event to emit. * @param eventData Any data to emit with the event. * @return `true` if there are any listeners, `false` otherwise. */ emit(event, eventData) { this.#emitter.emit(event, eventData); } /** * Removes all listeners. If given an event argument, it will remove only * listeners for that event. * @param event - the event to remove listeners for. * @returns `this` to enable you to chain method calls. */ removeAllListeners(event) { if (event) { this.#emitter.all.delete(event); } else { this.#emitter.all.clear(); } return this; } }; EventEmitter.EventEmitter = EventEmitter$1; return EventEmitter; } var log = {}; var hasRequiredLog; function requireLog () { if (hasRequiredLog) return log; hasRequiredLog = 1; /** * Copyright 2021 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(log, "__esModule", { value: true }); log.LogType = void 0; var LogType; (function (LogType) { // keep-sorted start LogType["bidi"] = "bidi"; LogType["cdp"] = "cdp"; LogType["debug"] = "debug"; LogType["debugError"] = "debug:error"; LogType["debugInfo"] = "debug:info"; LogType["debugWarn"] = "debug:warn"; // keep-sorted end })(LogType || (log.LogType = LogType = {})); return log; } var ProcessingQueue = {}; var hasRequiredProcessingQueue; function requireProcessingQueue () { if (hasRequiredProcessingQueue) return ProcessingQueue; hasRequiredProcessingQueue = 1; /** * Copyright 2022 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var _a; Object.defineProperty(ProcessingQueue, "__esModule", { value: true }); ProcessingQueue.ProcessingQueue = void 0; const log_js_1 = requireLog(); let ProcessingQueue$1 = class ProcessingQueue { static LOGGER_PREFIX = `${log_js_1.LogType.debug}:queue`; #logger; #processor; #queue = []; // Flag to keep only 1 active processor. #isProcessing = false; constructor(processor, logger) { this.#processor = processor; this.#logger = logger; } add(entry, name) { this.#queue.push([entry, name]); // No need in waiting. Just initialize processor if needed. void this.#processIfNeeded(); } async #processIfNeeded() { if (this.#isProcessing) { return; } this.#isProcessing = true; while (this.#queue.length > 0) { const arrayEntry = this.#queue.shift(); if (!arrayEntry) { continue; } const [entryPromise, name] = arrayEntry; this.#logger?.(_a.LOGGER_PREFIX, 'Processing event:', name); await entryPromise .then((entry) => { if (entry.kind === 'error') { this.#logger?.(log_js_1.LogType.debugError, 'Event threw before sending:', entry.error.message, entry.error.stack); return; } return this.#processor(entry.value); }) .catch((error) => { this.#logger?.(log_js_1.LogType.debugError, 'Event was not processed:', error?.message); }); } this.#isProcessing = false; } }; ProcessingQueue.ProcessingQueue = ProcessingQueue$1; _a = ProcessingQueue$1; return ProcessingQueue; } var CommandProcessor = {}; var protocol = {}; var cdp = {}; var hasRequiredCdp; function requireCdp () { if (hasRequiredCdp) return cdp; hasRequiredCdp = 1; Object.defineProperty(cdp, "__esModule", { value: true }); return cdp; } var chromiumBidi = {}; var hasRequiredChromiumBidi; function requireChromiumBidi () { if (hasRequiredChromiumBidi) return chromiumBidi; hasRequiredChromiumBidi = 1; /** * Copyright 2023 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(chromiumBidi, "__esModule", { value: true }); chromiumBidi.EVENT_NAMES = chromiumBidi.Speculation = chromiumBidi.Bluetooth = chromiumBidi.Network = chromiumBidi.Input = chromiumBidi.BrowsingContext = chromiumBidi.Log = chromiumBidi.Script = chromiumBidi.BiDiModule = void 0; // keep-sorted end var BiDiModule; (function (BiDiModule) { // keep-sorted start BiDiModule["Bluetooth"] = "bluetooth"; BiDiModule["Browser"] = "browser"; BiDiModule["BrowsingContext"] = "browsingContext"; BiDiModule["Cdp"] = "goog:cdp"; BiDiModule["Input"] = "input"; BiDiModule["Log"] = "log"; BiDiModule["Network"] = "network"; BiDiModule["Script"] = "script"; BiDiModule["Session"] = "session"; BiDiModule["Speculation"] = "speculation"; // keep-sorted end })(BiDiModule || (chromiumBidi.BiDiModule = BiDiModule = {})); var Script; (function (Script) { (function (EventNames) { // keep-sorted start EventNames["Message"] = "script.message"; EventNames["RealmCreated"] = "script.realmCreated"; EventNames["RealmDestroyed"] = "script.realmDestroyed"; // keep-sorted end })(Script.EventNames || (Script.EventNames = {})); })(Script || (chromiumBidi.Script = Script = {})); var Log; (function (Log) { (function (EventNames) { EventNames["LogEntryAdded"] = "log.entryAdded"; })(Log.EventNames || (Log.EventNames = {})); })(Log || (chromiumBidi.Log = Log = {})); var BrowsingContext; (function (BrowsingContext) { (function (EventNames) { // keep-sorted start EventNames["ContextCreated"] = "browsingContext.contextCreated"; EventNames["ContextDestroyed"] = "browsingContext.contextDestroyed"; EventNames["DomContentLoaded"] = "browsingContext.domContentLoaded"; EventNames["DownloadEnd"] = "browsingContext.downloadEnd"; EventNames["DownloadWillBegin"] = "browsingContext.downloadWillBegin"; EventNames["FragmentNavigated"] = "browsingContext.fragmentNavigated"; EventNames["HistoryUpdated"] = "browsingContext.historyUpdated"; EventNames["Load"] = "browsingContext.load"; EventNames["NavigationAborted"] = "browsingContext.navigationAborted"; EventNames["NavigationCommitted"] = "browsingContext.navigationCommitted"; EventNames["NavigationFailed"] = "browsingContext.navigationFailed"; EventNames["NavigationStarted"] = "browsingContext.navigationStarted"; EventNames["UserPromptClosed"] = "browsingContext.userPromptClosed"; EventNames["UserPromptOpened"] = "browsingContext.userPromptOpened"; // keep-sorted end })(BrowsingContext.EventNames || (BrowsingContext.EventNames = {})); })(BrowsingContext || (chromiumBidi.BrowsingContext = BrowsingContext = {})); var Input; (function (Input) { (function (EventNames) { // keep-sorted start EventNames["FileDialogOpened"] = "input.fileDialogOpened"; // keep-sorted end })(Input.EventNames || (Input.EventNames = {})); })(Input || (chromiumBidi.Input = Input = {})); var Network; (function (Network) { (function (EventNames) { // keep-sorted start EventNames["AuthRequired"] = "network.authRequired"; EventNames["BeforeRequestSent"] = "network.beforeRequestSent"; EventNames["FetchError"] = "network.fetchError"; EventNames["ResponseCompleted"] = "network.responseCompleted"; EventNames["ResponseStarted"] = "network.responseStarted"; // keep-sorted end })(Network.EventNames || (Network.EventNames = {})); })(Network || (chromiumBidi.Network = Network = {})); var Bluetooth; (function (Bluetooth) { (function (EventNames) { EventNames["RequestDevicePromptUpdated"] = "bluetooth.requestDevicePromptUpdated"; EventNames["GattConnectionAttempted"] = "bluetooth.gattConnectionAttempted"; EventNames["CharacteristicEventGenerated"] = "bluetooth.characteristicEventGenerated"; EventNames["DescriptorEventGenerated"] = "bluetooth.descriptorEventGenerated"; })(Bluetooth.EventNames || (Bluetooth.EventNames = {})); })(Bluetooth || (chromiumBidi.Bluetooth = Bluetooth = {})); var Speculation; (function (Speculation) { (function (EventNames) { EventNames["PrefetchStatusUpdated"] = "speculation.prefetchStatusUpdated"; })(Speculation.EventNames || (Speculation.EventNames = {})); })(Speculation || (chromiumBidi.Speculation = Speculation = {})); chromiumBidi.EVENT_NAMES = new Set([ // keep-sorted start ...Object.values(BiDiModule), ...Object.values(Bluetooth.EventNames), ...Object.values(BrowsingContext.EventNames), ...Object.values(Input.EventNames), ...Object.values(Log.EventNames), ...Object.values(Network.EventNames), ...Object.values(Script.EventNames), ...Object.values(Speculation.EventNames), // keep-sorted end ]); return chromiumBidi; } var webdriverBidi = {}; var hasRequiredWebdriverBidi; function requireWebdriverBidi () { if (hasRequiredWebdriverBidi) return webdriverBidi; hasRequiredWebdriverBidi = 1; /** * Copyright 2024 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(webdriverBidi, "__esModule", { value: true }); return webdriverBidi; } var ErrorResponse = {}; var hasRequiredErrorResponse; function requireErrorResponse () { if (hasRequiredErrorResponse) return ErrorResponse; hasRequiredErrorResponse = 1; Object.defineProperty(ErrorResponse, "__esModule", { value: true }); ErrorResponse.UnavailableNetworkDataException = ErrorResponse.NoSuchNetworkDataException = ErrorResponse.NoSuchNetworkCollectorException = ErrorResponse.NoSuchWebExtensionException = ErrorResponse.InvalidWebExtensionException = ErrorResponse.UnderspecifiedStoragePartitionException = ErrorResponse.UnableToSetFileInputException = ErrorResponse.UnableToSetCookieException = ErrorResponse.NoSuchStoragePartitionException = ErrorResponse.UnsupportedOperationException = ErrorResponse.UnableToCloseBrowserException = ErrorResponse.UnableToCaptureScreenException = ErrorResponse.UnknownErrorException = ErrorResponse.UnknownCommandException = ErrorResponse.SessionNotCreatedException = ErrorResponse.NoSuchUserContextException = ErrorResponse.NoSuchScriptException = ErrorResponse.NoSuchRequestException = ErrorResponse.NoSuchNodeException = ErrorResponse.NoSuchInterceptException = ErrorResponse.NoSuchHistoryEntryException = ErrorResponse.NoSuchHandleException = ErrorResponse.NoSuchFrameException = ErrorResponse.NoSuchElementException = ErrorResponse.NoSuchAlertException = ErrorResponse.MoveTargetOutOfBoundsException = ErrorResponse.InvalidSessionIdException = ErrorResponse.InvalidSelectorException = ErrorResponse.InvalidArgumentException = ErrorResponse.Exception = void 0; class Exception extends Error { error; message; stacktrace; constructor(error, message, stacktrace) { super(); this.error = error; this.message = message; this.stacktrace = stacktrace; } toErrorResponse(commandId) { return { type: 'error', id: commandId, error: this.error, message: this.message, stacktrace: this.stacktrace, }; } } ErrorResponse.Exception = Exception; class InvalidArgumentException extends Exception { constructor(message, stacktrace) { super("invalid argument" /* ErrorCode.InvalidArgument */, message, stacktrace); } } ErrorResponse.InvalidArgumentException = InvalidArgumentException; class InvalidSelectorException extends Exception { constructor(message, stacktrace) { super("invalid selector" /* ErrorCode.InvalidSelector */, message, stacktrace); } } ErrorResponse.InvalidSelectorException = InvalidSelectorException; class InvalidSessionIdException extends Exception { constructor(message, stacktrace) { super("invalid session id" /* ErrorCode.InvalidSessionId */, message, stacktrace); } } ErrorResponse.InvalidSessionIdException = InvalidSessionIdException; class MoveTargetOutOfBoundsException extends Exception { constructor(message, stacktrace) { super("move target out of bounds" /* ErrorCode.MoveTargetOutOfBounds */, message, stacktrace); } } ErrorResponse.MoveTargetOutOfBoundsException = MoveTargetOutOfBoundsException; class NoSuchAlertException extends Exception { constructor(message, stacktrace) { super("no such alert" /* ErrorCode.NoSuchAlert */, message, stacktrace); } } ErrorResponse.NoSuchAlertException = NoSuchAlertException; class NoSuchElementException extends Exception { constructor(message, stacktrace) { super("no such element" /* ErrorCode.NoSuchElement */, message, stacktrace); } } ErrorResponse.NoSuchElementException = NoSuchElementException; class NoSuchFrameException extends Exception { constructor(message, stacktrace) { super("no such frame" /* ErrorCode.NoSuchFrame */, message, stacktrace); } } ErrorResponse.NoSuchFrameException = NoSuchFrameException; class NoSuchHandleException extends Exception { constructor(message, stacktrace) { super("no such handle" /* ErrorCode.NoSuchHandle */, message, stacktrace); } } ErrorResponse.NoSuchHandleException = NoSuchHandleException; class NoSuchHistoryEntryException extends Exception { constructor(message, stacktrace) { super("no such history entry" /* ErrorCode.NoSuchHistoryEntry */, message, stacktrace); } } ErrorResponse.NoSuchHistoryEntryException = NoSuchHistoryEntryException; class NoSuchInterceptException extends Exception { constructor(message, stacktrace) { super("no such intercept" /* ErrorCode.NoSuchIntercept */, message, stacktrace); } } ErrorResponse.NoSuchInterceptException = NoSuchInterceptException; class NoSuchNodeException extends Exception { constructor(message, stacktrace) { super("no such node" /* ErrorCode.NoSuchNode */, message, stacktrace); } } ErrorResponse.NoSuchNodeException = NoSuchNodeException; class NoSuchRequestException extends Exception { constructor(message, stacktrace) { super("no such request" /* ErrorCode.NoSuchRequest */, message, stacktrace); } } ErrorResponse.NoSuchRequestException = NoSuchRequestException; class NoSuchScriptException extends Exception { constructor(message, stacktrace) { super("no such script" /* ErrorCode.NoSuchScript */, message, stacktrace); } } ErrorResponse.NoSuchScriptException = NoSuchScriptException; class NoSuchUserContextException extends Exception { constructor(message, stacktrace) { super("no such user context" /* ErrorCode.NoSuchUserContext */, message, stacktrace); } } ErrorResponse.NoSuchUserContextException = NoSuchUserContextException; class SessionNotCreatedException extends Exception { constructor(message, stacktrace) { super("session not created" /* ErrorCode.SessionNotCreated */, message, stacktrace); } } ErrorResponse.SessionNotCreatedException = SessionNotCreatedException; class UnknownCommandException extends Exception { constructor(message, stacktrace) { super("unknown command" /* ErrorCode.UnknownCommand */, message, stacktrace); } } ErrorResponse.UnknownCommandException = UnknownCommandException; class UnknownErrorException extends Exception { constructor(message, stacktrace = new Error().stack) { super("unknown error" /* ErrorCode.UnknownError */, message, stacktrace); } } ErrorResponse.UnknownErrorException = UnknownErrorException; class UnableToCaptureScreenException extends Exception { constructor(message, stacktrace) { super("unable to capture screen" /* ErrorCode.UnableToCaptureScreen */, message, stacktrace); } } ErrorResponse.UnableToCaptureScreenException = UnableToCaptureScreenException; class UnableToCloseBrowserException extends Exception { constructor(message, stacktrace) { super("unable to close browser" /* ErrorCode.UnableToCloseBrowser */, message, stacktrace); } } ErrorResponse.UnableToCloseBrowserException = UnableToCloseBrowserException; class UnsupportedOperationException extends Exception { constructor(message, stacktrace) { super("unsupported operation" /* ErrorCode.UnsupportedOperation */, message, stacktrace); } } ErrorResponse.UnsupportedOperationException = UnsupportedOperationException; class NoSuchStoragePartitionException extends Exception { constructor(message, stacktrace) { super("no such storage partition" /* ErrorCode.NoSuchStoragePartition */, message, stacktrace); } } ErrorResponse.NoSuchStoragePartitionException = NoSuchStoragePartitionException; class UnableToSetCookieException extends Exception { constructor(message, stacktrace) { super("unable to set cookie" /* ErrorCode.UnableToSetCookie */, message, stacktrace); } } ErrorResponse.UnableToSetCookieException = UnableToSetCookieException; class UnableToSetFileInputException extends Exception { constructor(message, stacktrace) { super("unable to set file input" /* ErrorCode.UnableToSetFileInput */, message, stacktrace); } } ErrorResponse.UnableToSetFileInputException = UnableToSetFileInputException; class UnderspecifiedStoragePartitionException extends Exception { constructor(message, stacktrace) { super("underspecified storage partition" /* ErrorCode.UnderspecifiedStoragePartition */, message, stacktrace); } } ErrorResponse.UnderspecifiedStoragePartitionException = UnderspecifiedStoragePartitionException; class InvalidWebExtensionException extends Exception { constructor(message, stacktrace) { super("invalid web extension" /* ErrorCode.InvalidWebExtension */, message, stacktrace); } } ErrorResponse.InvalidWebExtensionException = InvalidWebExtensionException; class NoSuchWebExtensionException extends Exception { constructor(message, stacktrace) { super("no such web extension" /* ErrorCode.NoSuchWebExtension */, message, stacktrace); } } ErrorResponse.NoSuchWebExtensionException = NoSuchWebExtensionException; class NoSuchNetworkCollectorException extends Exception { constructor(message, stacktrace) { super("no such network collector" /* ErrorCode.NoSuchNetworkCollector */, message, stacktrace); } } ErrorResponse.NoSuchNetworkCollectorException = NoSuchNetworkCollectorException; class NoSuchNetworkDataException extends Exception { constructor(message, stacktrace) { super("no such network data" /* ErrorCode.NoSuchNetworkData */, message, stacktrace); } } ErrorResponse.NoSuchNetworkDataException = NoSuchNetworkDataException; class UnavailableNetworkDataException extends Exception { constructor(message, stacktrace) { super("unavailable network data" /* ErrorCode.UnavailableNetworkData */, message, stacktrace); } } ErrorResponse.UnavailableNetworkDataException = UnavailableNetworkDataException; return ErrorResponse; } var webdriverBidiPermissions = {}; var hasRequiredWebdriverBidiPermissions; function requireWebdriverBidiPermissions () { if (hasRequiredWebdriverBidiPermissions) return webdriverBidiPermissions; hasRequiredWebdriverBidiPermissions = 1; /** * Copyright 2024 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(webdriverBidiPermissions, "__esModule", { value: true }); return webdriverBidiPermissions; } var webdriverBidiBluetooth = {}; var hasRequiredWebdriverBidiBluetooth; function requireWebdriverBidiBluetooth () { if (hasRequiredWebdriverBidiBluetooth) return webdriverBidiBluetooth; hasRequiredWebdriverBidiBluetooth = 1; /** * Copyright 2024 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(webdriverBidiBluetooth, "__esModule", { value: true }); return webdriverBidiBluetooth; } var webdriverBidiNavSpeculation = {}; var hasRequiredWebdriverBidiNavSpeculation; function requireWebdriverBidiNavSpeculation () { if (hasRequiredWebdriverBidiNavSpeculation) return webdriverBidiNavSpeculation; hasRequiredWebdriverBidiNavSpeculation = 1; /** * Copyright 2024 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(webdriverBidiNavSpeculation, "__esModule", { value: true }); return webdriverBidiNavSpeculation; } var hasRequiredProtocol; function requireProtocol () { if (hasRequiredProtocol) return protocol; hasRequiredProtocol = 1; (function (exports) { var __createBinding = (protocol.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (protocol.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (protocol.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __exportStar = (protocol.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChromiumBidi = exports.Cdp = void 0; /** * Copyright 2023 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ exports.Cdp = __importStar(requireCdp()); exports.ChromiumBidi = __importStar(requireChromiumBidi()); __exportStar(requireWebdriverBidi(), exports); __exportStar(requireErrorResponse(), exports); __exportStar(requireWebdriverBidiPermissions(), exports); __exportStar(requireWebdriverBidiBluetooth(), exports); __exportStar(requireWebdriverBidiNavSpeculation(), exports); } (protocol)); return protocol; } var BidiNoOpParser = {}; var hasRequiredBidiNoOpParser; function requireBidiNoOpParser () { if (hasRequiredBidiNoOpParser) return BidiNoOpParser; hasRequiredBidiNoOpParser = 1; /** * Copyright 2023 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(BidiNoOpParser, "__esModule", { value: true }); BidiNoOpParser.BidiNoOpParser = void 0; let BidiNoOpParser$1 = class BidiNoOpParser { // Bluetooth module // keep-sorted start block=yes parseDisableSimulationParameters(params) { return params; } parseHandleRequestDevicePromptParams(params) { return params; } parseSimulateAdapterParameters(params) { return params; } parseSimulateAdvertisementParameters(params) { return params; } parseSimulateCharacteristicParameters(params) { return params; } parseSimulateCharacteristicResponseParameters(params) { return params; } parseSimulateDescriptorParameters(params) { return params; } parseSimulateDescriptorResponseParameters(params) { return params; } parseSimulateGattConnectionResponseParameters(params) { return params; } parseSimulateGattDisconnectionParameters(params) { return params; } parseSimulatePreconnectedPeripheralParameters(params) { return params; } parseSimulateServiceParameters(params) { return params; } // keep-sorted end // Browser module // keep-sorted start block=yes parseCreateUserContextParameters(params) { return params; } parseRemoveUserContextParameters(params) { return params; } parseSetClientWindowStateParameters(params) { return params; } parseSetDownloadBehaviorParameters(params) { return params; } // keep-sorted end // Browsing Context module // keep-sorted start block=yes parseActivateParams(params) { return params; } parseCaptureScreenshotParams(params) { return params; } parseCloseParams(params) { return params; } parseCreateParams(params) { return params; } parseGetTreeParams(params) { return params; } parseHandleUserPromptParams(params) { return params; } parseLocateNodesParams(params) { return params; } parseNavigateParams(params) { return params; } parsePrintParams(params) { return params; } parseReloadParams(params) { return params; } parseSetViewportParams(params) { return params; } parseTraverseHistoryParams(params) { return params; } // keep-sorted end // CDP module // keep-sorted start block=yes parseGetSessionParams(params) { return params; } parseResolveRealmParams(params) { return params; } parseSendCommandParams(params) { return params; } // keep-sorted end // Emulation module // keep-sorted start block=yes parseSetForcedColorsModeThemeOverrideParams(params) { return params; } parseSetGeolocationOverrideParams(params) { return params; } parseSetLocaleOverrideParams(params) { return params; } parseSetNetworkConditionsParams(params) { return params; } parseSetScreenOrientationOverrideParams(params) { return params; } parseSetScriptingEnabledParams(params) { return params; } parseSetTimezoneOverrideParams(params) { return params; } parseSetUserAgentOverrideParams(params) { return params; } // keep-sorted end // Script module // keep-sorted start block=yes parseAddPreloadScriptParams(params) { return params; } parseCallFunctionParams(params) { return params; } parseDisownParams(params) { return params; } parseEvaluateParams(params) { return params; } parseGetRealmsParams(params) { return params; } parseRemovePreloadScriptParams(params) { return params; } // keep-sorted end // Input module // keep-sorted start block=yes parsePerformActionsParams(params) { return params; } parseReleaseActionsParams(params) { return params; } parseSetFilesParams(params) { return params; } // keep-sorted end // Network module // keep-sorted start block=yes parseAddDataCollectorParams(params) { return params; } parseAddInterceptParams(params) { return params; } parseContinueRequestParams(params) { return params; } parseContinueResponseParams(params) { return params; } parseContinueWithAuthParams(params) { return params; } parseDisownDataParams(params) { return params; } parseFailRequestParams(params) { return params; } parseGetDataParams(params) { return params; } parseProvideResponseParams(params) { return params; } parseRemoveDataCollectorParams(params) { return params; } parseRemoveInterceptParams(params) { return params; } parseSetCacheBehaviorParams(params) { return params; } parseSetExtraHeadersParams(params) { return params; } // keep-sorted end // Permissions module // keep-sorted start block=yes parseSetPermissionsParams(params) { return params; } // keep-sorted end // Session module // keep-sorted start block=yes parseSubscribeParams(params) { return params; } parseUnsubscribeParams(params) { return params; } // keep-sorted end // Storage module // keep-sorted start block=yes parseDeleteCookiesParams(params) { return params; } parseGetCookiesParams(params) { return params; } parseSetCookieParams(params) { return params; } // keep-sorted end // WebExtenstion module // keep-sorted start block=yes parseInstallParams(params) { return params; } parseUninstallParams(params) { return params; } }; BidiNoOpParser.BidiNoOpParser = BidiNoOpParser$1; return BidiNoOpParser; } var BrowserProcessor = {}; var hasRequiredBrowserProcessor; function requireBrowserProcessor () { if (hasRequiredBrowserProcessor) return BrowserProcessor; hasRequiredBrowserProcessor = 1; /** * Copyright 2023 Google LLC. * Copyright (c) Microsoft Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(BrowserProcessor, "__esModule", { value: true }); BrowserProcessor.BrowserProcessor = void 0; BrowserProcessor.getProxyStr = getProxyStr; const protocol_js_1 = requireProtocol(); let BrowserProcessor$1 = class BrowserProcessor { #browserCdpClient; #browsingContextStorage; #configStorage; #userContextStorage; constructor(browserCdpClient, browsingContextStorage, configStorage, userContextStorage) { this.#browserCdpClient = browserCdpClient; this.#browsingContextStorage = browsingContextStorage; this.#configStorage = configStorage; this.#userContextStorage = userContextStorage; } close() { // Ensure that it is put at the end of the event loop. // This way we send back the response before closing the tab. setTimeout(() => this.#browserCdpClient.sendCommand('Browser.close'), 0); return {}; } async createUserContext(params) { // `params` is a record to provide legacy `goog:` parameters. Now as the `proxy` // parameter is specified, we should get rid of `goog:proxyServer` and // `goog:proxyBypassList` and make the params of type // `Browser.CreateUserContextParameters`. const w3cParams = params; const globalConfig = this.#configStorage.getGlobalConfig(); if (w3cParams.acceptInsecureCerts !== undefined) { if (w3cParams.acceptInsecureCerts === false && globalConfig.acceptInsecureCerts === true) // TODO: https://github.com/GoogleChromeLabs/chromium-bidi/issues/3398 throw new protocol_js_1.UnknownErrorException(`Cannot set user context's "acceptInsecureCerts" to false, when a capability "acceptInsecureCerts" is set to true`); } const request = {}; if (w3cParams.proxy) { const proxyStr = getProxyStr(w3cParams.proxy); if (proxyStr) { request.proxyServer = proxyStr; } if (w3cParams.proxy.noProxy) { request.proxyBypassList = w3cParams.proxy.noProxy.join(','); } } else { // TODO: remove after Puppeteer stops using it. if (params['goog:proxyServer'] !== undefined) { request.proxyServer = params['goog:proxyServer']; } const proxyBypassList = params['goog:proxyBypassList'] ?? undefined; if (proxyBypassList) { request.proxyBypassList = proxyBypassList.join(','); } } const context = await this.#browserCdpClient.sendCommand('Target.createBrowserContext', request); await this.#applyDownloadBehavior(globalConfig.downloadBehavior ?? null, context.browserContextId); this.#configStorage.updateUserContextConfig(context.browserContextId, { acceptInsecureCerts: params['acceptInsecureCerts'], userPromptHandler: params['unhandledPromptBehavior'], }); return { userContext: context.browserContextId, }; } async removeUserContext(params) { const userContext = params.userContext; if (userContext === 'default') { throw new protocol_js_1.InvalidArgumentException('`default` user context cannot be removed'); } try { await this.#browserCdpClient.sendCommand('Target.disposeBrowserContext', { browserContextId: userContext, }); } catch (err) { // https://source.chromium.org/chromium/chromium/src/+/main:content/browser/devtools/protocol/target_handler.cc;l=1424;drc=c686e8f4fd379312469fe018f5c390e9c8f20d0d if (err.message.startsWith('Failed to find context with id')) { throw new protocol_js_1.NoSuchUserContextException(err.message); } throw err; } return {}; } async getUserContexts() { return { userContexts: await this.#userContextStorage.getUserContexts(), }; } async #getWindowInfo(targetId) { const windowInfo = await this.#browserCdpClient.sendCommand('Browser.getWindowForTarget', { targetId }); return { // `active` is not supported in CDP yet. active: false, clientWindow: `${windowInfo.windowId}`, state: windowInfo.bounds.windowState ?? 'normal', height: windowInfo.bounds.height ?? 0, width: windowInfo.bounds.width ?? 0, x: windowInfo.bounds.left ?? 0, y: windowInfo.bounds.top ?? 0, }; } async getClientWindows() { const topLevelTargetIds = this.#browsingContextStorage .getTopLevelContexts() .map((b) => b.cdpTarget.id); const clientWindows = await Promise.all(topLevelTargetIds.map(async (targetId) => await this.#getWindowInfo(targetId))); const uniqueClientWindowIds = new Set(); const uniqueClientWindows = new Array(); // Filter out duplicated client windows. for (const window of clientWindows) { if (!uniqueClientWindowIds.has(window.clientWindow)) { uniqueClientWindowIds.add(window.clientWindow); uniqueClientWindows.push(window); } } return { clientWindows: uniqueClientWindows }; } #toCdpDownloadBehavior(downloadBehavior) { if (downloadBehavior === null) // CDP "default" behavior. return { behavior: 'default', }; if (downloadBehavior?.type === 'denied') // Deny all the downloads. return { behavior: 'deny', }; if (downloadBehavior?.type === 'allowed') { // CDP behavior "allow" means "save downloaded files to the specific download path". return { behavior: 'allow', downloadPath: downloadBehavior.destinationFolder, }; } // Unreachable. Handled by params parser. throw new protocol_js_1.UnknownErrorException('Unexpected download behavior'); } async #applyDownloadBehavior(downloadBehavior, userContext) { await this.#browserCdpClient.sendCommand('Browser.setDownloadBehavior', { ...this.#toCdpDownloadBehavior(downloadBehavior), browserContextId: userContext === 'default' ? undefined : userContext, // Required for enabling download events. eventsEnabled: true, }); } async setDownloadBehavior(params) { let userContexts; if (params.userContexts === undefined) { // Global download behavior. userContexts = (await this.#userContextStorage.getUserContexts()).map((c) => c.userContext); } else { // Download behavior for the specific user contexts. userContexts = Array.from(await this.#userContextStorage.verifyUserContextIdList(params.userContexts)); } if (params.userContexts === undefined) { // Store the global setting to be applied for the future user contexts. this.#configStorage.updateGlobalConfig({ downloadBehavior: params.downloadBehavior, }); } else { params.userContexts.map((userContext) => this.#configStorage.updateUserContextConfig(userContext, { downloadBehavior: params.downloadBehavior, })); } await Promise.all(userContexts.map(async (userContext) => { // Download behavior can be already set per user context, in which case the global // one should not be applied. const downloadBehavior = this.#configStorage.getActiveConfig(undefined, userContext) .downloadBehavior ?? null; await this.#applyDownloadBehavior(downloadBehavior, userContext); })); return {}; } }; BrowserProcessor.BrowserProcessor = BrowserProcessor$1; /** * Proxy config parse implementation: * https://source.chromium.org/chromium/chromium/src/+/main:net/proxy_resolution/proxy_config.h;drc=743a82d08e59d803c94ee1b8564b8b11dd7b462f;l=107 */ function getProxyStr(proxyConfig) { if (proxyConfig.proxyType === 'direct' || proxyConfig.proxyType === 'system') { // These types imply that Chrome should use its default behavior (e.g., direct // connection or system-configured proxy). No specific `proxyServer` string is // needed. return undefined; } if (proxyConfig.proxyType === 'pac') { throw new protocol_js_1.UnsupportedOperationException(`PAC proxy configuration is not supported per user context`); } if (proxyConfig.proxyType === 'autodetect') { throw new protocol_js_1.UnsupportedOperationException(`Autodetect proxy is not supported per user context`); } if (proxyConfig.proxyType === 'manual') { const servers = []; // HTTP Proxy if (proxyConfig.httpProxy !== undefined) { // servers.push(proxyConfig.httpProxy); servers.push(`http=${proxyConfig.httpProxy}`); } // SSL Proxy (uses 'https' scheme) if (proxyConfig.sslProxy !== undefined) { // servers.push(pro