Repository: puppeteer/puppeteer
File: packages/puppeteer-core/src/cdp/BrowserConnector.ts (TypeScript)

Code before:
 *
 *     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.
 */

import type {
  IsPageTargetCallback,
  TargetFilterCallback,
} from '../api/Browser.js';
import type {ConnectionTransport} from '../common/ConnectionTransport.js';
import {getFetch} from '../common/fetch.js';
import {debugError} from '../common/util.js';
import type {Viewport} from '../common/Viewport.js';
import {isNode} from '../environment.js';
import {assert} from '../util/assert.js';
import {isErrorLike} from '../util/ErrorLike.js';

import {CdpBrowser} from './Browser.js';
import {Connection} from './Connection.js';
import type {ConnectOptions} from './ConnectOptions.js';
import {BidiBrowser} from '../bidi/Browser';

/**
 * Generic browser options that can be passed when launching any browser or when
 * connecting to an existing browser instance.
 * @public
 */
export interface BrowserConnectOptions {
  /**
   * Whether to ignore HTTPS errors during navigation.
   * @defaultValue `false`
   */
  ignoreHTTPSErrors?: boolean;
  /**
   * Sets the viewport for each page.
   */
  defaultViewport?: Viewport | null;
  /**
   * Slows down Puppeteer operations by the specified amount of milliseconds to
   * aid debugging.
   */
  slowMo?: number;
  /**
   * Callback to decide if Puppeteer should connect to a given target or not.
   */
  targetFilter?: TargetFilterCallback;

Review comment (suggestion):
We should be doing this part with dynamic import similar to `launch`. Note Type imports are allowed

Code after:
 *
 *     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.
 */

import type {
  IsPageTargetCallback,
  TargetFilterCallback,
} from '../api/Browser.js';
import type {ConnectionTransport} from '../common/ConnectionTransport.js';
import {getFetch} from '../common/fetch.js';
import {debugError} from '../common/util.js';
import type {Viewport} from '../common/Viewport.js';
import {isNode} from '../environment.js';
import {assert} from '../util/assert.js';
import {isErrorLike} from '../util/ErrorLike.js';

import {CdpBrowser} from './Browser.js';
import {Connection} from './Connection.js';
import type {ConnectOptions} from './ConnectOptions.js';
/**
 * Generic browser options that can be passed when launching any browser or when
 * connecting to an existing browser instance.
 * @public
 */
export interface BrowserConnectOptions {
  /**
   * Whether to ignore HTTPS errors during navigation.
   * @defaultValue `false`
   */
  ignoreHTTPSErrors?: boolean;
  /**
   * Sets the viewport for each page.
   */
  defaultViewport?: Viewport | null;
  /**
   * Slows down Puppeteer operations by the specified amount of milliseconds to
   * aid debugging.
   */
  slowMo?: number;
  /**
   * Callback to decide if Puppeteer should connect to a given target or not.
   */
  targetFilter?: TargetFilterCallback;
  /**
   * @internal